Merge "Check active state of opportunistic subscription before returning its port index." into tm-qpr-dev am: b5f5eb3fa5

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/services/AlternativeNetworkAccess/+/19458812

Change-Id: I2c74bf84131a0b14569016eb201ea91025b4dc16
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/OWNERS b/OWNERS
index f4fd81c..6927b2e 100644
--- a/OWNERS
+++ b/OWNERS
@@ -1,6 +1 @@
-# Default code reviewers picked from top 3 or more developers.
-# Please update this list if you find better candidates.
-sasindran@google.com
-rgreenwalt@google.com
-amruthr@google.com
-jacknudelman@google.com
\ No newline at end of file
+file:platform/frameworks/opt/telephony:/OWNERS
diff --git a/PREUPLOAD.cfg b/PREUPLOAD.cfg
index de2615a..de4cf97 100644
--- a/PREUPLOAD.cfg
+++ b/PREUPLOAD.cfg
@@ -20,14 +20,4 @@
 [Hook Scripts]
 checkstyle_hook = ${REPO_ROOT}/prebuilts/checkstyle/checkstyle.py --sha ${PREUPLOAD_COMMIT}
 
-strings_lint_hook = ${REPO_ROOT}/frameworks/base/tools/stringslint/stringslint_sha.sh ${PREUPLOAD_COMMIT}
-
-hidden_api_txt_checksorted_hook = ${REPO_ROOT}/tools/platform-compat/hiddenapi/checksorted_sha.sh ${PREUPLOAD_COMMIT} ${REPO_ROOT}
-
-hidden_api_txt_exclude_hook = ${REPO_ROOT}/frameworks/base/tools/hiddenapi/exclude.sh ${PREUPLOAD_COMMIT} ${REPO_ROOT}
-
 ktlint_hook = ${REPO_ROOT}/prebuilts/ktlint/ktlint.py -f ${PREUPLOAD_FILES}
-
-owners_hook = ${REPO_ROOT}/frameworks/base/tools/aosp/aosp_sha.sh ${PREUPLOAD_COMMIT} "OWNERS$"
-
-shell_hook = ${REPO_ROOT}/frameworks/base/tools/aosp/aosp_sha.sh ${PREUPLOAD_COMMIT} "^packages/Shell/"
\ No newline at end of file
diff --git a/src/com/android/ons/ONSProfileSelector.java b/src/com/android/ons/ONSProfileSelector.java
index e6480c5..95287fc 100644
--- a/src/com/android/ons/ONSProfileSelector.java
+++ b/src/com/android/ons/ONSProfileSelector.java
@@ -35,7 +35,6 @@
 import android.telephony.SignalStrength;
 import android.telephony.SubscriptionInfo;
 import android.telephony.SubscriptionManager;
-import android.telephony.TelephonyFrameworkInitializer;
 import android.telephony.TelephonyManager;
 import android.telephony.UiccCardInfo;
 import android.telephony.UiccPortInfo;
@@ -44,7 +43,6 @@
 
 import com.android.internal.annotations.VisibleForTesting;
 import com.android.internal.telephony.ISetOpportunisticDataCallback;
-import com.android.internal.telephony.ISub;
 import com.android.internal.telephony.IUpdateAvailableNetworksCallback;
 import com.android.telephony.Rlog;
 
@@ -834,27 +832,12 @@
             ISetOpportunisticDataCallback callbackStub) {
         if ((subId == SubscriptionManager.DEFAULT_SUBSCRIPTION_ID)
                 || (isOpprotunisticSub(subId) && mSubscriptionManager.isActiveSubId(subId))) {
-            ISub iSub = ISub.Stub.asInterface(
-                    TelephonyFrameworkInitializer
-                            .getTelephonyServiceManager()
-                            .getSubscriptionServiceRegisterer()
-                            .get());
-            if (iSub == null) {
-                log("Could not get Subscription Service handle");
-                if (Compatibility.isChangeEnabled(
-                        OpportunisticNetworkService.CALLBACK_ON_MORE_ERROR_CODE_CHANGE)) {
-                    sendSetOpptCallbackHelper(callbackStub,
-                            TelephonyManager.SET_OPPORTUNISTIC_SUB_REMOTE_SERVICE_EXCEPTION);
-                } else {
-                    sendSetOpptCallbackHelper(callbackStub,
-                            TelephonyManager.SET_OPPORTUNISTIC_SUB_VALIDATION_FAILED);
-                }
-                return;
-            }
             try {
-                iSub.setPreferredDataSubscriptionId(subId, needValidation, callbackStub);
-            } catch (RemoteException ex) {
-                log("Could not connect to Subscription Service");
+                mSubscriptionManager.setPreferredDataSubscriptionId(subId, needValidation,
+                        mHandler::post, result -> sendSetOpptCallbackHelper(callbackStub, result));
+            } catch (Exception ex) {
+                log("setPreferredDataSubscriptionId failed. subId=" + subId + ", needValidation="
+                        + needValidation + ", ex=" + ex);
                 if (Compatibility.isChangeEnabled(
                         OpportunisticNetworkService.CALLBACK_ON_MORE_ERROR_CODE_CHANGE)) {
                     sendSetOpptCallbackHelper(callbackStub,