summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHakjun Choi <hakjunc@google.com>2023-10-24 08:45:48 +0000
committerHakjun Choi <hakjunc@google.com>2023-10-25 11:44:30 +0000
commit7fb979ca1981747f820e477eda31de8d0c16f1df (patch)
tree730a47743d56c380ae535dc8ea7b93d4e504543e
parent49230d4d108df12859da4ac32b61b90bc958f143 (diff)
downloadgsma_services-7fb979ca1981747f820e477eda31de8d0c16f1df.tar.gz
Add a way to get whether the subscription ID is exclusively for non-terrestrial networks.
Add wrapper API to provide a way to call SubscriptionInro.isOnlyNonTerrestrialNetwork() method from application Bug: 301620244 Test: manual 1. push updated SatelliteClient.jar into /system_ext/framework/ 2. insert Active SIM and activate it 3. run SatelliteTestApp to check whether correspondent SubscriptionInfo is obtained and isOnlyNonTerrestrialNetwork() called as expected. 4. deactivate SIM and test again. Change-Id: Ia5b2c6af22fade9c391e84e9fe08c897705e0961
-rw-r--r--satellite_client/src/android/telephony/satellite/wrapper/SatelliteManagerWrapper.java37
1 files changed, 36 insertions, 1 deletions
diff --git a/satellite_client/src/android/telephony/satellite/wrapper/SatelliteManagerWrapper.java b/satellite_client/src/android/telephony/satellite/wrapper/SatelliteManagerWrapper.java
index 28fb8b6..88ae1f8 100644
--- a/satellite_client/src/android/telephony/satellite/wrapper/SatelliteManagerWrapper.java
+++ b/satellite_client/src/android/telephony/satellite/wrapper/SatelliteManagerWrapper.java
@@ -26,6 +26,8 @@ import android.annotation.Nullable;
import android.content.Context;
import android.os.CancellationSignal;
import android.os.OutcomeReceiver;
+import android.telephony.SubscriptionInfo;
+import android.telephony.SubscriptionManager;
import android.telephony.satellite.AntennaPosition;
import android.telephony.satellite.NtnSignalStrength;
import android.telephony.satellite.NtnSignalStrengthCallback;
@@ -37,11 +39,15 @@ import android.telephony.satellite.SatelliteManager;
import android.telephony.satellite.SatelliteProvisionStateCallback;
import android.telephony.satellite.SatelliteStateCallback;
import android.telephony.satellite.SatelliteTransmissionUpdateCallback;
+
import com.android.internal.telephony.flags.Flags;
+import com.android.telephony.Rlog;
+
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.time.Duration;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executor;
@@ -74,9 +80,11 @@ public class SatelliteManagerWrapper {
sNtnSignalStrengthCallbackWrapperMap = new ConcurrentHashMap<>();
private final SatelliteManager mSatelliteManager;
+ private final SubscriptionManager mSubscriptionManager;
SatelliteManagerWrapper(Context context) {
- mSatelliteManager = (SatelliteManager) context.getSystemService("satellite");
+ mSatelliteManager = context.getSystemService(SatelliteManager.class);
+ mSubscriptionManager = context.getSystemService(SubscriptionManager.class);
}
/**
@@ -811,4 +819,31 @@ public class SatelliteManagerWrapper {
mSatelliteManager.unregisterForNtnSignalStrengthChanged(internalCallback);
}
}
+
+ /**
+ * Wrapper API to provide a way to check if the subscription is exclusively for non-terrestrial
+ * networks.
+ *
+ * @param subId The unique SubscriptionInfo key in database.
+ * @return {@code true} if it is a non-terrestrial network subscription, {@code false}
+ * otherwise.
+ * Note: The method returns {@code false} if the parameter is invalid or any other error occurs.
+ */
+ @FlaggedApi(Flags.FLAG_OEM_ENABLED_SATELLITE_FLAG)
+ public boolean isOnlyNonTerrestrialNetworkSubscription(int subId) {
+ List<SubscriptionInfo> subInfoList = mSubscriptionManager.getAvailableSubscriptionInfoList();
+
+ for (SubscriptionInfo subInfo : subInfoList) {
+ if (subInfo.getSubscriptionId() == subId) {
+ logd("found matched subscription info");
+ return subInfo.isOnlyNonTerrestrialNetwork();
+ }
+ }
+ logd("failed to found matched subscription info");
+ return false;
+ }
+
+ private void logd(String message) {
+ Rlog.d(TAG, message);
+ }
}