Merge "Add new datagram type sms" into main
diff --git a/satellite_client/src/android/telephony/satellite/wrapper/ProvisionSubscriberIdWrapper.java b/satellite_client/src/android/telephony/satellite/wrapper/ProvisionSubscriberIdWrapper.java
new file mode 100644
index 0000000..c547ee0
--- /dev/null
+++ b/satellite_client/src/android/telephony/satellite/wrapper/ProvisionSubscriberIdWrapper.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.telephony.satellite.wrapper;
+
+import android.annotation.NonNull;
+
+import java.util.Objects;
+
+public class ProvisionSubscriberIdWrapper {
+ @NonNull private final String subscriberId;
+ private int carrierId;
+ @NonNull private final String niddApn;
+
+ public ProvisionSubscriberIdWrapper(String subscriberId, int carrierId, String niddApn) {
+ this.subscriberId = subscriberId;
+ this.carrierId = carrierId;
+ this.niddApn = niddApn;
+ }
+
+ @NonNull
+ public String getSubscriberId() {
+ return subscriberId;
+ }
+
+ public int getCarrierId() {
+ return carrierId;
+ }
+
+ @NonNull
+ public String getNiddApn() {
+ return niddApn;
+ }
+
+ @Override
+ @NonNull
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("SubscriberId:");
+ sb.append(subscriberId);
+ sb.append(",");
+
+ sb.append("carrierId:");
+ sb.append(carrierId);
+ sb.append(",");
+
+ sb.append("niddApn:");
+ sb.append(niddApn);
+ return sb.toString();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ ProvisionSubscriberIdWrapper that = (ProvisionSubscriberIdWrapper) o;
+ return Objects.equals(subscriberId, that.subscriberId)
+ && carrierId == that.carrierId && Objects.equals(niddApn, that.niddApn);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(subscriberId, carrierId, niddApn);
+ }
+}
diff --git a/satellite_client/src/android/telephony/satellite/wrapper/SatelliteManagerWrapper.java b/satellite_client/src/android/telephony/satellite/wrapper/SatelliteManagerWrapper.java
index 35755b5..200103a 100644
--- a/satellite_client/src/android/telephony/satellite/wrapper/SatelliteManagerWrapper.java
+++ b/satellite_client/src/android/telephony/satellite/wrapper/SatelliteManagerWrapper.java
@@ -49,6 +49,7 @@
import android.telephony.satellite.SatelliteProvisionStateCallback;
import android.telephony.satellite.SatelliteSessionStats;
import android.telephony.satellite.SatelliteSupportedStateCallback;
+import android.telephony.satellite.ProvisionSubscriberId;
import android.telephony.satellite.SatelliteTransmissionUpdateCallback;
import com.android.internal.telephony.flags.Flags;
@@ -61,6 +62,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executor;
@@ -102,8 +104,8 @@
SatelliteSupportedStateCallbackWrapper, SatelliteSupportedStateCallback>
sSatelliteSupportedStateCallbackWrapperMap = new ConcurrentHashMap<>();
- private static final ConcurrentHashMap<
- CarrierRoamingNtnModeListenerWrapper, TelephonyCallback.CarrierRoamingNtnModeListener>
+ private static final ConcurrentHashMap<CarrierRoamingNtnModeListenerWrapper,
+ CarrierRoamingNtnModeListener>
sCarrierRoamingNtnModeListenerWrapperMap = new ConcurrentHashMap<>();
private static final ConcurrentHashMap<SatelliteCommunicationAllowedStateCallbackWrapper,
@@ -829,31 +831,43 @@
}
}
+ private class CarrierRoamingNtnModeListener extends TelephonyCallback
+ implements TelephonyCallback.CarrierRoamingNtnModeListener {
+
+ private CarrierRoamingNtnModeListenerWrapper mListenerWrapper;
+
+ public CarrierRoamingNtnModeListener(CarrierRoamingNtnModeListenerWrapper listenerWrapper) {
+ mListenerWrapper = listenerWrapper;
+ }
+
+ @Override
+ public void onCarrierRoamingNtnModeChanged(boolean active) {
+ logd("onCarrierRoamingNtnModeChanged: active=" + active);
+ mListenerWrapper.onCarrierRoamingNtnModeChanged(active);
+ }
+ }
+
/** Register for carrier roaming non-terrestrial network mode changes. */
public void registerForCarrierRoamingNtnModeChanged(int subId,
@NonNull @CallbackExecutor Executor executor,
@NonNull CarrierRoamingNtnModeListenerWrapper listener) {
- TelephonyCallback.CarrierRoamingNtnModeListener internalListener = new TelephonyCallback
- .CarrierRoamingNtnModeListener() {
- @Override
- public void onCarrierRoamingNtnModeChanged(boolean active) {
- listener.onCarrierRoamingNtnModeChanged(active);
- }
- };
+ logd("registerForCarrierRoamingNtnModeChanged: subId=" + subId);
+ CarrierRoamingNtnModeListener internalListener = new CarrierRoamingNtnModeListener(listener);
sCarrierRoamingNtnModeListenerWrapperMap.put(listener, internalListener);
TelephonyManager tm = mTelephonyManager.createForSubscriptionId(subId);
- tm.registerTelephonyCallback(executor, (TelephonyCallback) internalListener);
+ tm.registerTelephonyCallback(executor, internalListener);
}
/** Unregister for carrier roaming non-terrestrial network mode changes. */
public void unregisterForCarrierRoamingNtnModeChanged(int subId,
@NonNull CarrierRoamingNtnModeListenerWrapper listener) {
- TelephonyCallback.CarrierRoamingNtnModeListener internalListener =
+ logd("unregisterForCarrierRoamingNtnModeChanged: subId=" + subId);
+ CarrierRoamingNtnModeListener internalListener =
sCarrierRoamingNtnModeListenerWrapperMap.get(listener);
if (internalListener != null) {
TelephonyManager tm = mTelephonyManager.createForSubscriptionId(subId);
- tm.unregisterTelephonyCallback((TelephonyCallback) internalListener);
+ tm.unregisterTelephonyCallback(internalListener);
}
}
@@ -1374,6 +1388,120 @@
}
}
+ /**
+ * Wrapper API to provide a way to check if the subscription is capable for non-terrestrial
+ * networks for the carrier.
+ *
+ * @param subId The unique SubscriptionInfo key in database.
+ * @return {@code true} if it is a non-terrestrial network capable subscription,
+ * {@code false} otherwise.
+ * Note: The method returns {@code false} if the parameter is invalid or any other error occurs.
+ */
+ @FlaggedApi(Flags.FLAG_CARRIER_ROAMING_NB_IOT_NTN)
+ public boolean isSatelliteESOSSupportedSubscription(int subId) {
+ if (!mSubscriptionManager.isValidSubscriptionId(subId)) {
+ return false;
+ }
+
+ List<SubscriptionInfo> subInfoList = mSubscriptionManager.getAvailableSubscriptionInfoList();
+ for (SubscriptionInfo subInfo : subInfoList) {
+ if (subInfo.getSubscriptionId() == subId) {
+ logd("found matched subscription info");
+ return subInfo.isSatelliteESOSSupported();
+ }
+ }
+ logd("failed to found matched subscription info");
+ return false;
+ }
+
+ /**
+ * Request to get list of prioritized satellite subscriber ids to be used for provision.
+ *
+ * @param executor, The executor on which the callback will be called.
+ * @param callback, The callback object to which the result will be delivered.
+ * If successful, the callback returns a list of subscriberIds sorted in ascending priority
+ * order index 0 has the highest priority. Otherwise, it returns an error with a
+ * SatelliteException.
+ */
+ @FlaggedApi(Flags.FLAG_CARRIER_ROAMING_NB_IOT_NTN)
+ public void requestProvisionSubscriberIds(@NonNull @CallbackExecutor Executor executor,
+ @NonNull OutcomeReceiver<List<ProvisionSubscriberIdWrapper>,
+ SatelliteExceptionWrapper> callback) {
+ Objects.requireNonNull(executor);
+ Objects.requireNonNull(callback);
+
+ OutcomeReceiver internalCallback =
+ new OutcomeReceiver<List<ProvisionSubscriberId>, SatelliteException>() {
+ @Override
+ public void onResult(List<ProvisionSubscriberId> result) {
+ callback.onResult(result.stream().map(ids -> new ProvisionSubscriberIdWrapper(
+ ids.getSubscriberId(), ids.getCarrierId(), ids.getNiddApn())).collect(
+ Collectors.toList()));
+ }
+
+ @Override
+ public void onError(SatelliteException exception) {
+ callback.onError(new SatelliteExceptionWrapper(exception.getErrorCode()));
+ }
+ };
+ mSatelliteManager.requestProvisionSubscriberIds(executor, internalCallback);
+ }
+
+ /**
+ * Request to get provisioned status for given a satellite subscriber id.
+ *
+ * @param satelliteSubscriberId Satellite subscriber id requiring provisioned status check.
+ * @param executor The executor on which the callback will be called.
+ * @param callback The callback object to which the result will be delivered.
+ */
+ @FlaggedApi(Flags.FLAG_CARRIER_ROAMING_NB_IOT_NTN)
+ public void requestIsProvisioned(@NonNull String satelliteSubscriberId,
+ @NonNull @CallbackExecutor Executor executor,
+ @NonNull OutcomeReceiver<Boolean, SatelliteExceptionWrapper> callback) {
+ OutcomeReceiver internalCallback =
+ new OutcomeReceiver<Boolean, SatelliteException>() {
+ @Override
+ public void onResult(Boolean result) {
+ callback.onResult(result);
+ }
+
+ @Override
+ public void onError(SatelliteException exception) {
+ callback.onError(new SatelliteExceptionWrapper(exception.getErrorCode()));
+ }
+ };
+ mSatelliteManager.requestIsProvisioned(satelliteSubscriberId, executor, internalCallback);
+ }
+
+ /**
+ * Deliver the list of provisioned satellite subscriber ids.
+ *
+ * @param list List of ProvisionSubscriberId.
+ * @param executor The executor on which the callback will be called.
+ * @param callback The callback object to which the result will be delivered.
+ */
+ @FlaggedApi(Flags.FLAG_CARRIER_ROAMING_NB_IOT_NTN)
+ public void provisionSatellite(@NonNull List<ProvisionSubscriberIdWrapper> list,
+ @NonNull @CallbackExecutor Executor executor,
+ @NonNull OutcomeReceiver<Boolean, SatelliteExceptionWrapper> callback) {
+ OutcomeReceiver internalCallback =
+ new OutcomeReceiver<Boolean, SatelliteException>() {
+ @Override
+ public void onResult(Boolean result) {
+ callback.onResult(result);
+ }
+
+ @Override
+ public void onError(SatelliteException exception) {
+ callback.onError(new SatelliteExceptionWrapper(exception.getErrorCode()));
+ }
+ };
+ mSatelliteManager.provisionSatellite(list.stream()
+ .map(wrapper -> new ProvisionSubscriberId(wrapper.getSubscriberId(),
+ wrapper.getCarrierId(), wrapper.getNiddApn()))
+ .collect(Collectors.toList()), executor, internalCallback);
+ }
+
@Nullable
private ServiceState getServiceStateForSubscriptionId(int subId) {
if (!mSubscriptionManager.isValidSubscriptionId(subId)) {