Merge "Minor Telephony Unit test cleanup fixes" into main
diff --git a/assets/CarrierRestrictionOperatorDetails.json b/assets/CarrierRestrictionOperatorDetails.json
index a088f94..4f650a0 100644
--- a/assets/CarrierRestrictionOperatorDetails.json
+++ b/assets/CarrierRestrictionOperatorDetails.json
@@ -2,6 +2,7 @@
   "_comment": "Operator should register with its application package name, carrierId and all the corresponding  SHA256IDs",
   "_comment": "Example format :: << \"packageName\" : {\"carrierId\":[<int>], \"callerSHA256Ids\":[<SHAID1>, <SHAID2>]} >>",
   "com.vzw.hss.myverizon":{"carrierIds":[1839],"callerSHA256Ids":["AE23A03436DF07B0CD70FE881CDA2EC1D21215D7B7B0CC68E67B67F5DF89526A"]},
+  "com.verizon.mips.services":{"carrierIds":[1839],"callerSHA256Ids":["FF82050BF6BED1F152AC1A12DC83CACBAD401775161882872C6665FC5E15C8F2"]},
   "com.google.android.apps.tycho":{"carrierIds":[1989],"callerSHA256Ids":["B9CFCE1C47A6AC713442718F15EF55B00B3A6D1A6D48CB46249FA8EB51465350","4C36AF4A5BDAD97C1F3D8B283416D244496C2AC5EAFE8226079EF6F676FD1859"]},
   "com.comcast.mobile.mxs":{"carrierIds": [2032,2532,2556],"callerSHA256Ids":["914C26403B57D2D482359FC235CC825AD00D52B0121C18EF2B2B9D4DDA4B8996"]},
   "com.xfinity.digitalhome": {"carrierIds": [2032,2532,2556],"callerSHA256Ids":["31b4c17315c2269040d535f7b6a79cf4d11517c664d9de8f1ddf4f8a785aad47"]},
diff --git a/res/values-ca/strings.xml b/res/values-ca/strings.xml
index f4c5593..c6e4796 100644
--- a/res/values-ca/strings.xml
+++ b/res/values-ca/strings.xml
@@ -680,7 +680,7 @@
     <string name="accessibility_settings_activity_title" msgid="7883415189273700298">"Accessibilitat"</string>
     <string name="status_hint_label_incoming_wifi_call" msgid="2606052595898044071">"Trucada per Wi-Fi de"</string>
     <string name="status_hint_label_wifi_call" msgid="942993035689809853">"Trucada per Wi-Fi"</string>
-    <string name="message_decode_error" msgid="1061856591500290887">"S\'ha produït un error en descodificar el missatge."</string>
+    <string name="message_decode_error" msgid="1061856591500290887">"Hi ha hagut un error en descodificar el missatge."</string>
     <string name="callFailed_cdma_activation" msgid="5392057031552253550">"Una targeta SIM ha activat el servei, i s\'ha actualitzat la funció d\'itinerància del telèfon."</string>
     <string name="callFailed_cdma_call_limit" msgid="1074219746093031412">"Hi ha massa trucades actives. Finalitza\'n alguna o combina-les abans de fer-ne una de nova."</string>
     <string name="callFailed_imei_not_accepted" msgid="7257903653685147251">"No es pot establir la connexió. Insereix una targeta SIM vàlida."</string>
diff --git a/src/com/android/phone/PhoneGlobals.java b/src/com/android/phone/PhoneGlobals.java
index 149e1c2..dcddf2b 100644
--- a/src/com/android/phone/PhoneGlobals.java
+++ b/src/com/android/phone/PhoneGlobals.java
@@ -44,6 +44,7 @@
 import android.telecom.TelecomManager;
 import android.telephony.AnomalyReporter;
 import android.telephony.CarrierConfigManager;
+import android.telephony.NetworkRegistrationInfo;
 import android.telephony.ServiceState;
 import android.telephony.SubscriptionInfo;
 import android.telephony.SubscriptionManager;
@@ -373,12 +374,16 @@
                     break;
 
                 case EVENT_DATA_ROAMING_DISCONNECTED:
+                    Log.d(LOG_TAG, "EVENT_DATA_ROAMING_DISCONNECTED");
                     if (SubscriptionManagerService.getInstance()
                             .isEsimBootStrapProvisioningActiveForSubId(msg.arg1)) {
                         Log.i(LOG_TAG,
                                 "skip notification/warnings during esim bootstrap activation");
+                    } else if (skipDataRoamingDisconnectedNotificationInSatelliteMode((msg.arg1))) {
+                        Log.i(LOG_TAG, "skip data roaming disconnected notification when device is "
+                                + "connected to satellite network that does not support data.");
                     } else {
-                        notificationMgr.showDataRoamingNotification(msg.arg1, false);
+                        notificationMgr.showDataRoamingNotification((msg.arg1), false);
                     }
                     break;
 
@@ -1496,4 +1501,32 @@
         }
         pw.println("------- End PhoneGlobals -------");
     }
+
+    private boolean skipDataRoamingDisconnectedNotificationInSatelliteMode(int subId) {
+        SatelliteController satelliteController = SatelliteController.getInstance();
+        if (satelliteController.isSatelliteEnabledOrBeingEnabled()) {
+            Log.d(LOG_TAG, "skipDataRoamingDisconnected - skip notification as "
+                    + "satellite is enabled or being enabled");
+            return true;
+        }
+
+        int phoneId = SubscriptionManager.getPhoneId(subId);
+        Phone phone = PhoneFactory.getPhone(phoneId);
+        ServiceState serviceState = phone.getServiceState();
+        if (serviceState != null && serviceState.isUsingNonTerrestrialNetwork()) {
+            Log.d(LOG_TAG, "skipDataRoamingDisconnected - isUsingNtn");
+            List<Integer> capabilities =
+                    satelliteController.getCapabilitiesForCarrierRoamingSatelliteMode(phone);
+            if (!capabilities.contains(NetworkRegistrationInfo.SERVICE_TYPE_DATA)) {
+                // Skip data roaming disconnected notification as device is connected to
+                // non-terrestrial network that does not support data.
+                Log.d(LOG_TAG, "skipDataRoamingDisconnected - skip notification as "
+                        + "NTN does not support data");
+                return true;
+            }
+        }
+
+        Log.d(LOG_TAG, "skipDataRoamingDisconnected - do not skip notification.");
+        return false;
+    }
 }
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index daa4957..d7f7939 100644
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -13200,40 +13200,48 @@
     public void requestSatelliteEnabled(boolean enableSatellite, boolean enableDemoMode,
             boolean isEmergency, @NonNull IIntegerConsumer callback) {
         enforceSatelliteCommunicationPermission("requestSatelliteEnabled");
-        if (enableSatellite) {
-            ResultReceiver resultReceiver = new ResultReceiver(mMainThreadHandler) {
-                @Override
-                protected void onReceiveResult(int resultCode, Bundle resultData) {
-                    Log.d(LOG_TAG, "Satellite access restriction resultCode=" + resultCode
-                            + ", resultData=" + resultData);
-                    boolean isAllowed = false;
-                    Consumer<Integer> result = FunctionalUtils.ignoreRemoteException(
-                            callback::accept);
-                    if (resultCode == SATELLITE_RESULT_SUCCESS) {
-                        if (resultData != null
-                                && resultData.containsKey(KEY_SATELLITE_COMMUNICATION_ALLOWED)) {
-                            isAllowed = resultData.getBoolean(KEY_SATELLITE_COMMUNICATION_ALLOWED);
+        final long identity = Binder.clearCallingIdentity();
+        try {
+            if (enableSatellite) {
+                ResultReceiver resultReceiver = new ResultReceiver(mMainThreadHandler) {
+                    @Override
+                    protected void onReceiveResult(int resultCode, Bundle resultData) {
+                        Log.d(LOG_TAG, "Satellite access restriction resultCode=" + resultCode
+                                + ", resultData=" + resultData);
+                        boolean isAllowed = false;
+                        Consumer<Integer> result = FunctionalUtils.ignoreRemoteException(
+                                callback::accept);
+                        if (resultCode == SATELLITE_RESULT_SUCCESS) {
+                            if (resultData != null
+                                    && resultData.containsKey(
+                                    KEY_SATELLITE_COMMUNICATION_ALLOWED)) {
+                                isAllowed = resultData.getBoolean(
+                                        KEY_SATELLITE_COMMUNICATION_ALLOWED);
+                            } else {
+                                loge("KEY_SATELLITE_COMMUNICATION_ALLOWED does not exist.");
+                            }
                         } else {
-                            loge("KEY_SATELLITE_COMMUNICATION_ALLOWED does not exist.");
+                            result.accept(resultCode);
+                            return;
                         }
-                    } else {
-                        result.accept(resultCode);
-                        return;
+                        if (isAllowed) {
+                            mSatelliteController.requestSatelliteEnabled(
+                                    enableSatellite, enableDemoMode, isEmergency, callback);
+                        } else {
+                            result.accept(SATELLITE_RESULT_ACCESS_BARRED);
+                        }
                     }
-                    if (isAllowed) {
-                        mSatelliteController.requestSatelliteEnabled(
-                                enableSatellite, enableDemoMode, isEmergency, callback);
-                    } else {
-                        result.accept(SATELLITE_RESULT_ACCESS_BARRED);
-                    }
-                }
-            };
-            mSatelliteAccessController.requestIsCommunicationAllowedForCurrentLocation(
-                    resultReceiver, true);
-        } else {
-            // No need to check if satellite is allowed at current location when disabling satellite
-            mSatelliteController.requestSatelliteEnabled(
-                    enableSatellite, enableDemoMode, isEmergency, callback);
+                };
+                mSatelliteAccessController.requestIsCommunicationAllowedForCurrentLocation(
+                        resultReceiver, true);
+            } else {
+                // No need to check if satellite is allowed at current location when disabling
+                // satellite
+                mSatelliteController.requestSatelliteEnabled(
+                        enableSatellite, enableDemoMode, isEmergency, callback);
+            }
+        } finally {
+            Binder.restoreCallingIdentity(identity);
         }
     }
 
@@ -13248,7 +13256,12 @@
     @Override
     public void requestIsSatelliteEnabled(@NonNull ResultReceiver result) {
         enforceSatelliteCommunicationPermission("requestIsSatelliteEnabled");
-        mSatelliteController.requestIsSatelliteEnabled(result);
+        final long identity = Binder.clearCallingIdentity();
+        try {
+            mSatelliteController.requestIsSatelliteEnabled(result);
+        } finally {
+            Binder.restoreCallingIdentity(identity);
+        }
     }
 
     /**
@@ -13262,7 +13275,12 @@
     @Override
     public void requestIsDemoModeEnabled(@NonNull ResultReceiver result) {
         enforceSatelliteCommunicationPermission("requestIsDemoModeEnabled");
-        mSatelliteController.requestIsDemoModeEnabled(result);
+        final long identity = Binder.clearCallingIdentity();
+        try {
+            mSatelliteController.requestIsDemoModeEnabled(result);
+        } finally {
+            Binder.restoreCallingIdentity(identity);
+        }
     }
 
     /**
@@ -13276,7 +13294,12 @@
     @Override
     public void requestIsEmergencyModeEnabled(@NonNull ResultReceiver result) {
         enforceSatelliteCommunicationPermission("requestIsEmergencyModeEnabled");
-        mSatelliteController.requestIsEmergencyModeEnabled(result);
+        final long identity = Binder.clearCallingIdentity();
+        try {
+            mSatelliteController.requestIsEmergencyModeEnabled(result);
+        } finally {
+            Binder.restoreCallingIdentity(identity);
+        }
     }
 
     /**
@@ -13284,10 +13307,18 @@
      *
      * @param result The result receiver that returns whether the satellite service is supported on
      *               the device if the request is successful or an error code if the request failed.
+     *
+     * @throws SecurityException if the caller doesn't have the required permission.
      */
     @Override
     public void requestIsSatelliteSupported(@NonNull ResultReceiver result) {
-        mSatelliteController.requestIsSatelliteSupported(result);
+        enforceSatelliteCommunicationPermission("requestIsSatelliteSupported");
+        final long identity = Binder.clearCallingIdentity();
+        try {
+            mSatelliteController.requestIsSatelliteSupported(result);
+        } finally {
+            Binder.restoreCallingIdentity(identity);
+        }
     }
 
     /**
@@ -13301,7 +13332,12 @@
     @Override
     public void requestSatelliteCapabilities(@NonNull ResultReceiver result) {
         enforceSatelliteCommunicationPermission("requestSatelliteCapabilities");
-        mSatelliteController.requestSatelliteCapabilities(result);
+        final long identity = Binder.clearCallingIdentity();
+        try {
+            mSatelliteController.requestSatelliteCapabilities(result);
+        } finally {
+            Binder.restoreCallingIdentity(identity);
+        }
     }
 
     /**
@@ -13319,7 +13355,12 @@
             @NonNull IIntegerConsumer resultCallback,
             @NonNull ISatelliteTransmissionUpdateCallback callback) {
         enforceSatelliteCommunicationPermission("startSatelliteTransmissionUpdates");
-        mSatelliteController.startSatelliteTransmissionUpdates(resultCallback, callback);
+        final long identity = Binder.clearCallingIdentity();
+        try {
+            mSatelliteController.startSatelliteTransmissionUpdates(resultCallback, callback);
+        } finally {
+            Binder.restoreCallingIdentity(identity);
+        }
     }
 
     /**
@@ -13337,7 +13378,12 @@
             @NonNull IIntegerConsumer resultCallback,
             @NonNull ISatelliteTransmissionUpdateCallback callback) {
         enforceSatelliteCommunicationPermission("stopSatelliteTransmissionUpdates");
-        mSatelliteController.stopSatelliteTransmissionUpdates(resultCallback, callback);
+        final long identity = Binder.clearCallingIdentity();
+        try {
+            mSatelliteController.stopSatelliteTransmissionUpdates(resultCallback, callback);
+        } finally {
+            Binder.restoreCallingIdentity(identity);
+        }
     }
 
     /**
@@ -13359,8 +13405,13 @@
             @NonNull String token, @NonNull byte[] provisionData,
             @NonNull IIntegerConsumer callback) {
         enforceSatelliteCommunicationPermission("provisionSatelliteService");
-        return mSatelliteController.provisionSatelliteService(token, provisionData,
+        final long identity = Binder.clearCallingIdentity();
+        try {
+            return mSatelliteController.provisionSatelliteService(token, provisionData,
                 callback);
+        } finally {
+            Binder.restoreCallingIdentity(identity);
+        }
     }
 
     /**
@@ -13378,7 +13429,12 @@
     public void deprovisionSatelliteService(
             @NonNull String token, @NonNull IIntegerConsumer callback) {
         enforceSatelliteCommunicationPermission("deprovisionSatelliteService");
-        mSatelliteController.deprovisionSatelliteService(token, callback);
+        final long identity = Binder.clearCallingIdentity();
+        try {
+            mSatelliteController.deprovisionSatelliteService(token, callback);
+        } finally {
+            Binder.restoreCallingIdentity(identity);
+        }
     }
 
     /**
@@ -13394,7 +13450,12 @@
     @SatelliteManager.SatelliteResult public int registerForSatelliteProvisionStateChanged(
             @NonNull ISatelliteProvisionStateCallback callback) {
         enforceSatelliteCommunicationPermission("registerForSatelliteProvisionStateChanged");
-        return mSatelliteController.registerForSatelliteProvisionStateChanged(callback);
+        final long identity = Binder.clearCallingIdentity();
+        try {
+            return mSatelliteController.registerForSatelliteProvisionStateChanged(callback);
+        } finally {
+            Binder.restoreCallingIdentity(identity);
+        }
     }
 
     /**
@@ -13410,7 +13471,12 @@
     public void unregisterForSatelliteProvisionStateChanged(
             @NonNull ISatelliteProvisionStateCallback callback) {
         enforceSatelliteCommunicationPermission("unregisterForSatelliteProvisionStateChanged");
-        mSatelliteController.unregisterForSatelliteProvisionStateChanged(callback);
+        final long identity = Binder.clearCallingIdentity();
+        try {
+            mSatelliteController.unregisterForSatelliteProvisionStateChanged(callback);
+        } finally {
+            Binder.restoreCallingIdentity(identity);
+        }
     }
 
     /**
@@ -13425,7 +13491,12 @@
     @Override
     public void requestIsSatelliteProvisioned(@NonNull ResultReceiver result) {
         enforceSatelliteCommunicationPermission("requestIsSatelliteProvisioned");
-        mSatelliteController.requestIsSatelliteProvisioned(result);
+        final long identity = Binder.clearCallingIdentity();
+        try {
+            mSatelliteController.requestIsSatelliteProvisioned(result);
+        } finally {
+            Binder.restoreCallingIdentity(identity);
+        }
     }
 
     /**
@@ -13441,7 +13512,12 @@
     @SatelliteManager.SatelliteResult public int registerForSatelliteModemStateChanged(
             @NonNull ISatelliteModemStateCallback callback) {
         enforceSatelliteCommunicationPermission("registerForSatelliteModemStateChanged");
-        return mSatelliteController.registerForSatelliteModemStateChanged(callback);
+        final long identity = Binder.clearCallingIdentity();
+        try {
+            return mSatelliteController.registerForSatelliteModemStateChanged(callback);
+        } finally {
+            Binder.restoreCallingIdentity(identity);
+        }
     }
 
     /**
@@ -13456,7 +13532,12 @@
     @Override
     public void unregisterForModemStateChanged(@NonNull ISatelliteModemStateCallback callback) {
         enforceSatelliteCommunicationPermission("unregisterForModemStateChanged");
-        mSatelliteController.unregisterForModemStateChanged(callback);
+        final long identity = Binder.clearCallingIdentity();
+        try {
+            mSatelliteController.unregisterForModemStateChanged(callback);
+        } finally {
+            Binder.restoreCallingIdentity(identity);
+        }
     }
 
     /**
@@ -13472,7 +13553,12 @@
     @SatelliteManager.SatelliteResult public int registerForIncomingDatagram(
             @NonNull ISatelliteDatagramCallback callback) {
         enforceSatelliteCommunicationPermission("registerForIncomingDatagram");
-        return mSatelliteController.registerForIncomingDatagram(callback);
+        final long identity = Binder.clearCallingIdentity();
+        try {
+            return mSatelliteController.registerForIncomingDatagram(callback);
+        } finally {
+            Binder.restoreCallingIdentity(identity);
+        }
     }
 
     /**
@@ -13487,7 +13573,12 @@
     @Override
     public void unregisterForIncomingDatagram(@NonNull ISatelliteDatagramCallback callback) {
         enforceSatelliteCommunicationPermission("unregisterForIncomingDatagram");
-        mSatelliteController.unregisterForIncomingDatagram(callback);
+        final long identity = Binder.clearCallingIdentity();
+        try {
+            mSatelliteController.unregisterForIncomingDatagram(callback);
+        } finally {
+            Binder.restoreCallingIdentity(identity);
+        }
     }
 
     /**
@@ -13503,7 +13594,12 @@
      */
     public void pollPendingDatagrams(IIntegerConsumer callback) {
         enforceSatelliteCommunicationPermission("pollPendingDatagrams");
-        mSatelliteController.pollPendingDatagrams(callback);
+        final long identity = Binder.clearCallingIdentity();
+        try {
+            mSatelliteController.pollPendingDatagrams(callback);
+        } finally {
+            Binder.restoreCallingIdentity(identity);
+        }
     }
 
     /**
@@ -13528,8 +13624,13 @@
             @NonNull SatelliteDatagram datagram, boolean needFullScreenPointingUI,
             @NonNull IIntegerConsumer callback) {
         enforceSatelliteCommunicationPermission("sendDatagram");
-        mSatelliteController.sendDatagram(datagramType, datagram, needFullScreenPointingUI,
-                callback);
+        final long identity = Binder.clearCallingIdentity();
+        try {
+            mSatelliteController.sendDatagram(datagramType, datagram, needFullScreenPointingUI,
+                    callback);
+        } finally {
+            Binder.restoreCallingIdentity(identity);
+        }
     }
 
     /**
@@ -13547,7 +13648,13 @@
     public void requestIsCommunicationAllowedForCurrentLocation(int subId,
             @NonNull ResultReceiver result) {
         enforceSatelliteCommunicationPermission("requestIsCommunicationAllowedForCurrentLocation");
-        mSatelliteAccessController.requestIsCommunicationAllowedForCurrentLocation(result, false);
+        final long identity = Binder.clearCallingIdentity();
+        try {
+            mSatelliteAccessController.requestIsCommunicationAllowedForCurrentLocation(result,
+                    false);
+        } finally {
+            Binder.restoreCallingIdentity(identity);
+        }
     }
 
     /**
@@ -13561,7 +13668,12 @@
     @Override
     public void requestTimeForNextSatelliteVisibility(@NonNull ResultReceiver result) {
         enforceSatelliteCommunicationPermission("requestTimeForNextSatelliteVisibility");
-        mSatelliteController.requestTimeForNextSatelliteVisibility(result);
+        final long identity = Binder.clearCallingIdentity();
+        try {
+            mSatelliteController.requestTimeForNextSatelliteVisibility(result);
+        } finally {
+            Binder.restoreCallingIdentity(identity);
+        }
     }
 
     /**
@@ -13575,8 +13687,13 @@
     @RequiresPermission(Manifest.permission.SATELLITE_COMMUNICATION)
 
     public void setDeviceAlignedWithSatellite(@NonNull boolean isAligned) {
-        enforceSatelliteCommunicationPermission("informDeviceAlignedToSatellite");
-        mSatelliteController.setDeviceAlignedWithSatellite(isAligned);
+        enforceSatelliteCommunicationPermission("setDeviceAlignedWithSatellite");
+        final long identity = Binder.clearCallingIdentity();
+        try {
+            mSatelliteController.setDeviceAlignedWithSatellite(isAligned);
+        } finally {
+            Binder.restoreCallingIdentity(identity);
+        }
     }
 
     /**
@@ -13770,7 +13887,12 @@
     @SatelliteManager.SatelliteResult public int registerForSatelliteSupportedStateChanged(
             @NonNull ISatelliteSupportedStateCallback callback) {
         enforceSatelliteCommunicationPermission("registerForSatelliteSupportedStateChanged");
-        return mSatelliteController.registerForSatelliteSupportedStateChanged(callback);
+        final long identity = Binder.clearCallingIdentity();
+        try {
+            return mSatelliteController.registerForSatelliteSupportedStateChanged(callback);
+        } finally {
+            Binder.restoreCallingIdentity(identity);
+        }
     }
 
     /**
@@ -13786,7 +13908,12 @@
     public void unregisterForSatelliteSupportedStateChanged(
             @NonNull ISatelliteSupportedStateCallback callback) {
         enforceSatelliteCommunicationPermission("unregisterForSatelliteSupportedStateChanged");
-        mSatelliteController.unregisterForSatelliteSupportedStateChanged(callback);
+        final long identity = Binder.clearCallingIdentity();
+        try {
+            mSatelliteController.unregisterForSatelliteSupportedStateChanged(callback);
+        } finally {
+            Binder.restoreCallingIdentity(identity);
+        }
     }
 
     /**
@@ -13807,8 +13934,13 @@
         TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege(mApp,
                 SubscriptionManager.INVALID_SUBSCRIPTION_ID,
                 "setSatelliteServicePackageName");
-        return mSatelliteController.setSatelliteServicePackageName(servicePackageName,
-                provisioned);
+        final long identity = Binder.clearCallingIdentity();
+        try {
+            return mSatelliteController.setSatelliteServicePackageName(servicePackageName,
+                    provisioned);
+        } finally {
+            Binder.restoreCallingIdentity(identity);
+        }
     }
 
     /**
@@ -13825,7 +13957,12 @@
         TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege(mApp,
                 SubscriptionManager.INVALID_SUBSCRIPTION_ID,
                 "setSatelliteGatewayServicePackageName");
-        return mSatelliteController.setSatelliteGatewayServicePackageName(servicePackageName);
+        final long identity = Binder.clearCallingIdentity();
+        try {
+            return mSatelliteController.setSatelliteGatewayServicePackageName(servicePackageName);
+        } finally {
+            Binder.restoreCallingIdentity(identity);
+        }
     }
 
     /**
@@ -13844,8 +13981,13 @@
                 Binder.getCallingUid(), "setSatellitePointingUiClassName");
         TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege(mApp,
                 SubscriptionManager.INVALID_SUBSCRIPTION_ID,
-                "setSatelliteGatewayServicePackageName");
-        return mSatelliteController.setSatellitePointingUiClassName(packageName, className);
+                "setSatellitePointingUiClassName");
+        final long identity = Binder.clearCallingIdentity();
+        try {
+            return mSatelliteController.setSatellitePointingUiClassName(packageName, className);
+        } finally {
+            Binder.restoreCallingIdentity(identity);
+        }
     }
 
     /**
@@ -13863,7 +14005,12 @@
         TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege(mApp,
                 SubscriptionManager.INVALID_SUBSCRIPTION_ID,
                 "setSatelliteListeningTimeoutDuration");
-        return mSatelliteController.setSatelliteListeningTimeoutDuration(timeoutMillis);
+        final long identity = Binder.clearCallingIdentity();
+        try {
+            return mSatelliteController.setSatelliteListeningTimeoutDuration(timeoutMillis);
+        } finally {
+            Binder.restoreCallingIdentity(identity);
+        }
     }
 
     /**
@@ -13873,13 +14020,18 @@
      * @return {@code true} if the value is set successfully, {@code false} otherwise.
      */
     public boolean setSatelliteIgnoreCellularServiceState(boolean enabled) {
-        Log.d(LOG_TAG, "setSatelliteIgnoreServiceState - " + enabled);
+        Log.d(LOG_TAG, "setSatelliteIgnoreCellularServiceState - " + enabled);
         TelephonyPermissions.enforceShellOnly(
-                Binder.getCallingUid(), "setSatelliteIgnoreServiceState");
+                Binder.getCallingUid(), "setSatelliteIgnoreCellularServiceState");
         TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege(mApp,
                 SubscriptionManager.INVALID_SUBSCRIPTION_ID,
-                "setSatelliteIgnoreServiceState");
-        return mSatelliteController.setSatelliteIgnoreCellularServiceState(enabled);
+                "setSatelliteIgnoreCellularServiceState");
+        final long identity = Binder.clearCallingIdentity();
+        try {
+            return mSatelliteController.setSatelliteIgnoreCellularServiceState(enabled);
+        } finally {
+            Binder.restoreCallingIdentity(identity);
+        }
     }
 
     /**
@@ -13898,8 +14050,13 @@
         TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege(mApp,
                 SubscriptionManager.INVALID_SUBSCRIPTION_ID,
                 "setDatagramControllerTimeoutDuration");
-        return mSatelliteController.setDatagramControllerTimeoutDuration(
-                reset, timeoutType, timeoutMillis);
+        final long identity = Binder.clearCallingIdentity();
+        try {
+            return mSatelliteController.setDatagramControllerTimeoutDuration(
+                    reset, timeoutType, timeoutMillis);
+        } finally {
+            Binder.restoreCallingIdentity(identity);
+        }
     }
 
     /**
@@ -13918,7 +14075,13 @@
         TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege(mApp,
                 SubscriptionManager.INVALID_SUBSCRIPTION_ID,
                 "ssetDatagramControllerBooleanConfig");
-        return mSatelliteController.setDatagramControllerBooleanConfig(reset, booleanType, enable);
+        final long identity = Binder.clearCallingIdentity();
+        try {
+            return mSatelliteController.setDatagramControllerBooleanConfig(reset, booleanType,
+                    enable);
+        } finally {
+            Binder.restoreCallingIdentity(identity);
+        }
     }
 
 
@@ -13938,8 +14101,13 @@
         TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege(mApp,
                 SubscriptionManager.INVALID_SUBSCRIPTION_ID,
                 "setSatelliteControllerTimeoutDuration");
-        return mSatelliteController.setSatelliteControllerTimeoutDuration(
-                reset, timeoutType, timeoutMillis);
+        final long identity = Binder.clearCallingIdentity();
+        try {
+            return mSatelliteController.setSatelliteControllerTimeoutDuration(
+                    reset, timeoutType, timeoutMillis);
+        } finally {
+            Binder.restoreCallingIdentity(identity);
+        }
     }
 
     /**
@@ -13962,8 +14130,13 @@
         TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege(mApp,
                 SubscriptionManager.INVALID_SUBSCRIPTION_ID,
                 "setEmergencyCallToSatelliteHandoverType");
-        return mSatelliteController.setEmergencyCallToSatelliteHandoverType(
-                handoverType, delaySeconds);
+        final long identity = Binder.clearCallingIdentity();
+        try {
+            return mSatelliteController.setEmergencyCallToSatelliteHandoverType(
+                    handoverType, delaySeconds);
+        } finally {
+            Binder.restoreCallingIdentity(identity);
+        }
     }
 
     /**
@@ -13982,7 +14155,12 @@
         TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege(mApp,
                 SubscriptionManager.INVALID_SUBSCRIPTION_ID,
                 "setOemEnabledSatelliteProvisionStatus");
-        return mSatelliteController.setOemEnabledSatelliteProvisionStatus(reset, isProvisioned);
+        final long identity = Binder.clearCallingIdentity();
+        try {
+            return mSatelliteController.setOemEnabledSatelliteProvisionStatus(reset, isProvisioned);
+        } finally {
+            Binder.restoreCallingIdentity(identity);
+        }
     }
 
     /**
@@ -13999,14 +14177,18 @@
                 + ", locationCountryCodeTimestampNanos" + locationCountryCodeTimestampNanos
                 + ", reset=" + reset + ", cachedNetworkCountryCodes="
                 + String.join(", ", cachedNetworkCountryCodes.keySet()));
-        TelephonyPermissions.enforceShellOnly(
-                Binder.getCallingUid(), "setCachedLocationCountryCode");
+        TelephonyPermissions.enforceShellOnly(Binder.getCallingUid(), "setCountryCodes");
         TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege(mApp,
-                SubscriptionManager.INVALID_SUBSCRIPTION_ID,
-                "setCachedLocationCountryCode");
-        return TelephonyCountryDetector.getInstance(getDefaultPhone().getContext(), mFeatureFlags)
-                .setCountryCodes(reset, currentNetworkCountryCodes, cachedNetworkCountryCodes,
-                        locationCountryCode, locationCountryCodeTimestampNanos);
+                SubscriptionManager.INVALID_SUBSCRIPTION_ID, "setCountryCodes");
+        final long identity = Binder.clearCallingIdentity();
+        try {
+            return TelephonyCountryDetector.getInstance(getDefaultPhone().getContext(),
+                    mFeatureFlags).setCountryCodes(reset, currentNetworkCountryCodes,
+                    cachedNetworkCountryCodes, locationCountryCode,
+                    locationCountryCodeTimestampNanos);
+        } finally {
+            Binder.restoreCallingIdentity(identity);
+        }
     }
 
     /**
@@ -14030,8 +14212,13 @@
         TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege(mApp,
                 SubscriptionManager.INVALID_SUBSCRIPTION_ID,
                 "setSatelliteAccessControlOverlayConfigs");
-        return mSatelliteAccessController.setSatelliteAccessControlOverlayConfigs(reset, isAllowed,
-                s2CellFile, locationFreshDurationNanos, satelliteCountryCodes);
+        final long identity = Binder.clearCallingIdentity();
+        try {
+            return mSatelliteAccessController.setSatelliteAccessControlOverlayConfigs(reset,
+                    isAllowed, s2CellFile, locationFreshDurationNanos, satelliteCountryCodes);
+        } finally {
+            Binder.restoreCallingIdentity(identity);
+        }
     }
 
     /**
@@ -14056,8 +14243,13 @@
         TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege(mApp,
                 SubscriptionManager.INVALID_SUBSCRIPTION_ID,
                 "setShouldSendDatagramToModemInDemoMode");
-        return mSatelliteController.setShouldSendDatagramToModemInDemoMode(
-                shouldSendToModemInDemoMode);
+        final long identity = Binder.clearCallingIdentity();
+        try {
+            return mSatelliteController.setShouldSendDatagramToModemInDemoMode(
+                    shouldSendToModemInDemoMode);
+        } finally {
+            Binder.restoreCallingIdentity(identity);
+        }
     }
 
     /**
@@ -14082,8 +14274,13 @@
         TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege(mApp,
                 SubscriptionManager.INVALID_SUBSCRIPTION_ID,
                 "setIsSatelliteCommunicationAllowedForCurrentLocationCache");
-        return mSatelliteAccessController.setIsSatelliteCommunicationAllowedForCurrentLocationCache(
-                state);
+        final long identity = Binder.clearCallingIdentity();
+        try {
+            return mSatelliteAccessController
+                    .setIsSatelliteCommunicationAllowedForCurrentLocationCache(state);
+        } finally {
+            Binder.restoreCallingIdentity(identity);
+        }
     }
 
     /**
@@ -14532,7 +14729,12 @@
      */
     public boolean overrideCarrierRoamingNtnEligibilityChanged(boolean state,
             boolean resetRequired) {
-        return mSatelliteAccessController.overrideCarrierRoamingNtnEligibilityChanged(state,
-                resetRequired);
+        final long identity = Binder.clearCallingIdentity();
+        try {
+            return mSatelliteAccessController.overrideCarrierRoamingNtnEligibilityChanged(state,
+                    resetRequired);
+        } finally {
+            Binder.restoreCallingIdentity(identity);
+        }
     }
 }
diff --git a/src/com/android/phone/settings/RadioInfo.java b/src/com/android/phone/settings/RadioInfo.java
index 24d680c..7a1d093 100644
--- a/src/com/android/phone/settings/RadioInfo.java
+++ b/src/com/android/phone/settings/RadioInfo.java
@@ -85,7 +85,6 @@
 import android.telephony.ims.ProvisioningManager;
 import android.telephony.ims.feature.MmTelFeature;
 import android.telephony.ims.stub.ImsRegistrationImplBase;
-import android.telephony.satellite.EnableRequestAttributes;
 import android.telephony.satellite.SatelliteManager;
 import android.text.TextUtils;
 import android.util.Log;
@@ -2142,9 +2141,8 @@
      * Enable modem satellite for non-emergency mode.
      */
     private void enableSatelliteNonEmergencyMode() {
-        SatelliteManager sm = getSystemService(SatelliteManager.class);
         CarrierConfigManager cm = getSystemService(CarrierConfigManager.class);
-        if (sm == null || cm == null) {
+        if (cm == null) {
             loge("enableSatelliteNonEmergencyMode: sm or cm is null");
             return;
         }
@@ -2155,10 +2153,38 @@
             return;
         }
         log("enableSatelliteNonEmergencyMode: requestEnabled");
-        sm.requestEnabled(new EnableRequestAttributes.Builder(true)
-                        .setDemoMode(false).setEmergencyMode(false).build(),
-                Runnable::run, res -> log("enableSatelliteNonEmergencyMode: " + res)
-        );
+        sendBroadCastForSatelliteNonEmergencyMode();
+    }
+
+    private void sendBroadCastForSatelliteNonEmergencyMode() {
+        String packageName = getStringFromOverlayConfig(
+                com.android.internal.R.string.config_satellite_gateway_service_package);
+
+        String className = getStringFromOverlayConfig(com.android.internal.R.string
+                .config_satellite_carrier_roaming_non_emergency_session_class);
+        if (packageName == null || className == null
+                || packageName.isEmpty() || className.isEmpty()) {
+            Log.d(TAG, "sendBroadCastForSatelliteNonEmergencyMode:"
+                    + " packageName or className is null or empty.");
+            return;
+        }
+        String action  = SatelliteManager.ACTION_SATELLITE_START_NON_EMERGENCY_SESSION;
+
+        Intent intent = new Intent(action);
+        intent.setComponent(new ComponentName(packageName, className));
+        sendBroadcast(intent);
+        Log.d(TAG, "sendBroadCastForSatelliteNonEmergencyMode" + intent);
+    }
+
+    private String getStringFromOverlayConfig(int resourceId) {
+        String name;
+        try {
+            name = getResources().getString(resourceId);
+        } catch (Resources.NotFoundException ex) {
+            loge("getStringFromOverlayConfig: ex=" + ex);
+            name = null;
+        }
+        return name;
     }
 
     private boolean isImsVolteProvisioned() {
diff --git a/src/com/android/services/telephony/TelephonyConnectionService.java b/src/com/android/services/telephony/TelephonyConnectionService.java
index 4226635..c69880d 100644
--- a/src/com/android/services/telephony/TelephonyConnectionService.java
+++ b/src/com/android/services/telephony/TelephonyConnectionService.java
@@ -1202,20 +1202,17 @@
             }
         }
 
-        boolean forNormalRoutingEmergencyCall = false;
         if (mDomainSelectionResolver.isDomainSelectionSupported()) {
-            if (isEmergencyNumber) {
-                // Normal routing emergency number shall be handled by normal call domain selector.
-                int routing = getEmergencyCallRouting(phone, number, needToTurnOnRadio);
-                if (routing != EmergencyNumber.EMERGENCY_CALL_ROUTING_NORMAL) {
-                    final Connection resultConnection =
-                            placeEmergencyConnection(phone,
-                                    request, numberToDial, isTestEmergencyNumber,
-                                    handle, needToTurnOnRadio, routing);
-                    if (resultConnection != null) return resultConnection;
-                }
-                forNormalRoutingEmergencyCall = true;
-                Log.d(this, "onCreateOutgoingConnection, forNormalRoutingEmergencyCall");
+            // Normal routing emergency number shall be handled by normal call domain selector.
+            int routing = (isEmergencyNumber)
+                    ? getEmergencyCallRouting(phone, number, needToTurnOnRadio)
+                    : EmergencyNumber.EMERGENCY_CALL_ROUTING_UNKNOWN;
+            if (isEmergencyNumber && routing != EmergencyNumber.EMERGENCY_CALL_ROUTING_NORMAL) {
+                final Connection resultConnection =
+                        placeEmergencyConnection(phone,
+                                request, numberToDial, isTestEmergencyNumber,
+                                handle, needToTurnOnRadio, routing);
+                if (resultConnection != null) return resultConnection;
             }
         }
 
@@ -1303,7 +1300,7 @@
                     }
                 }
             }, isEmergencyNumber && !isTestEmergencyNumber, phone, isTestEmergencyNumber,
-                    timeoutToOnTimeoutCallback, forNormalRoutingEmergencyCall);
+                    timeoutToOnTimeoutCallback);
             // Return the still unconnected GsmConnection and wait for the Radios to boot before
             // connecting it to the underlying Phone.
             return resultConnection;
diff --git a/tests/src/com/android/services/telephony/ImsConferenceTest.java b/tests/src/com/android/services/telephony/ImsConferenceTest.java
index ca16bc7..b6cb11a 100644
--- a/tests/src/com/android/services/telephony/ImsConferenceTest.java
+++ b/tests/src/com/android/services/telephony/ImsConferenceTest.java
@@ -124,6 +124,30 @@
     }
 
     /**
+     * Verifies that the default address presentation of an ImsConference is
+     * {@link TelecomManager#PRESENTATION_UNKNOWN}
+     */
+    @Test
+    @SmallTest
+    public void testDefaultNumberPresentationIsValid() {
+        when(mMockTelecomAccountRegistry.isUsingSimCallManager(any(PhoneAccountHandle.class)))
+                .thenReturn(false);
+        mConferenceHost.setConnectionProperties(Connection.PROPERTY_ASSISTED_DIALING
+                | Connection.PROPERTY_WIFI);
+        Bundle extras = new Bundle();
+        extras.putInt(TelecomManager.EXTRA_CALL_NETWORK_TYPE, TelephonyManager.NETWORK_TYPE_IWLAN);
+        mConferenceHost.putTelephonyExtras(extras);
+        mConferenceHost.setStatusHints(new StatusHints("WIFIs", null, null));
+
+        ImsConference imsConference = new ImsConference(mMockTelecomAccountRegistry,
+                mMockTelephonyConnectionServiceProxy, mConferenceHost,
+                null /* phoneAccountHandle */, () -> true /* featureFlagProxy */,
+                new ImsConference.CarrierConfiguration.Builder().build());
+
+        assertEquals(TelecomManager.PRESENTATION_UNKNOWN, imsConference.getAddressPresentation());
+    }
+
+    /**
      * Verifies that an ImsConference will inform listeners when the "fullness" of the conference
      * changes as participants come and go.
      */
diff --git a/tests/src/com/android/services/telephony/TelephonyConnectionServiceTest.java b/tests/src/com/android/services/telephony/TelephonyConnectionServiceTest.java
index e8b84d9..5618770 100644
--- a/tests/src/com/android/services/telephony/TelephonyConnectionServiceTest.java
+++ b/tests/src/com/android/services/telephony/TelephonyConnectionServiceTest.java
@@ -1309,7 +1309,7 @@
         ArgumentCaptor<RadioOnStateListener.Callback> callback =
                 ArgumentCaptor.forClass(RadioOnStateListener.Callback.class);
         verify(mRadioOnHelper).triggerRadioOnAndListen(callback.capture(), eq(true),
-                eq(testPhone), eq(false), eq(0), eq(false));
+                eq(testPhone), eq(false), eq(0));
 
         assertFalse(callback.getValue()
                 .isOkToCall(testPhone, ServiceState.STATE_OUT_OF_SERVICE, false));
@@ -1337,7 +1337,7 @@
         ArgumentCaptor<RadioOnStateListener.Callback> callback =
                 ArgumentCaptor.forClass(RadioOnStateListener.Callback.class);
         verify(mRadioOnHelper).triggerRadioOnAndListen(callback.capture(), eq(true),
-                eq(testPhone), eq(false), eq(0), eq(false));
+                eq(testPhone), eq(false), eq(0));
 
         assertFalse(callback.getValue()
                 .isOkToCall(testPhone, ServiceState.STATE_OUT_OF_SERVICE, false));
@@ -1449,7 +1449,7 @@
         ArgumentCaptor<RadioOnStateListener.Callback> callback =
                 ArgumentCaptor.forClass(RadioOnStateListener.Callback.class);
         verify(mRadioOnHelper).triggerRadioOnAndListen(callback.capture(), eq(true),
-                eq(testPhone), eq(false), eq(0), eq(false));
+                eq(testPhone), eq(false), eq(0));
 
         assertFalse(callback.getValue()
                 .isOkToCall(testPhone, ServiceState.STATE_OUT_OF_SERVICE, false));
@@ -1600,7 +1600,7 @@
                 PHONE_ACCOUNT_HANDLE_1, connectionRequest);
 
         verify(mRadioOnHelper).triggerRadioOnAndListen(any(), eq(false),
-                eq(testPhone0), eq(false), eq(0), eq(false));
+                eq(testPhone0), eq(false), eq(0));
     }
 
     /**
@@ -1634,7 +1634,7 @@
                 PHONE_ACCOUNT_HANDLE_1, connectionRequest);
 
         verify(mRadioOnHelper).triggerRadioOnAndListen(any(), eq(false),
-                eq(testPhone0), eq(false), eq(0), eq(false));
+                eq(testPhone0), eq(false), eq(0));
     }
 
     /**
@@ -1667,7 +1667,7 @@
                 PHONE_ACCOUNT_HANDLE_1, connectionRequest);
 
         verify(mRadioOnHelper, times(0)).triggerRadioOnAndListen(any(),
-                eq(true), eq(testPhone0), eq(false), eq(0), eq(false));
+                eq(true), eq(testPhone0), eq(false), eq(0));
     }
 
     /**
@@ -2820,7 +2820,7 @@
         ArgumentCaptor<RadioOnStateListener.Callback> callback =
                 ArgumentCaptor.forClass(RadioOnStateListener.Callback.class);
         verify(mRadioOnHelper).triggerRadioOnAndListen(callback.capture(), eq(true),
-                eq(testPhone), eq(false), eq(TIMEOUT_TO_DYNAMIC_ROUTING_MS), eq(true));
+                eq(testPhone), eq(false), eq(TIMEOUT_TO_DYNAMIC_ROUTING_MS));
 
         ServiceState ss = new ServiceState();
         ss.setState(ServiceState.STATE_OUT_OF_SERVICE);
@@ -2859,7 +2859,7 @@
         ArgumentCaptor<RadioOnStateListener.Callback> callback =
                 ArgumentCaptor.forClass(RadioOnStateListener.Callback.class);
         verify(mRadioOnHelper).triggerRadioOnAndListen(callback.capture(), eq(true),
-                eq(testPhone), eq(false), eq(TIMEOUT_TO_DYNAMIC_ROUTING_MS), eq(true));
+                eq(testPhone), eq(false), eq(TIMEOUT_TO_DYNAMIC_ROUTING_MS));
 
         ServiceState ss = new ServiceState();
         ss.setState(ServiceState.STATE_OUT_OF_SERVICE);
@@ -2884,7 +2884,7 @@
         ArgumentCaptor<RadioOnStateListener.Callback> callback =
                 ArgumentCaptor.forClass(RadioOnStateListener.Callback.class);
         verify(mRadioOnHelper).triggerRadioOnAndListen(callback.capture(), eq(true),
-                eq(testPhone), eq(false), eq(TIMEOUT_TO_DYNAMIC_ROUTING_MS), eq(true));
+                eq(testPhone), eq(false), eq(TIMEOUT_TO_DYNAMIC_ROUTING_MS));
 
         ServiceState ss = new ServiceState();
         ss.setState(ServiceState.STATE_IN_SERVICE);
@@ -2920,7 +2920,7 @@
         ArgumentCaptor<RadioOnStateListener.Callback> callback =
                 ArgumentCaptor.forClass(RadioOnStateListener.Callback.class);
         verify(mRadioOnHelper).triggerRadioOnAndListen(callback.capture(), eq(true),
-                eq(testPhone), eq(false), eq(TIMEOUT_TO_DYNAMIC_ROUTING_MS), eq(true));
+                eq(testPhone), eq(false), eq(TIMEOUT_TO_DYNAMIC_ROUTING_MS));
 
         ServiceState ss = new ServiceState();
         ss.setState(ServiceState.STATE_IN_SERVICE);
@@ -2957,7 +2957,7 @@
         ArgumentCaptor<RadioOnStateListener.Callback> callback =
                 ArgumentCaptor.forClass(RadioOnStateListener.Callback.class);
         verify(mRadioOnHelper).triggerRadioOnAndListen(callback.capture(), eq(true),
-                eq(testPhone), eq(false), eq(TIMEOUT_TO_DYNAMIC_ROUTING_MS), eq(true));
+                eq(testPhone), eq(false), eq(TIMEOUT_TO_DYNAMIC_ROUTING_MS));
 
         ServiceState ss = new ServiceState();
         ss.setState(ServiceState.STATE_IN_SERVICE);
@@ -2994,7 +2994,7 @@
         ArgumentCaptor<RadioOnStateListener.Callback> callback =
                 ArgumentCaptor.forClass(RadioOnStateListener.Callback.class);
         verify(mRadioOnHelper).triggerRadioOnAndListen(callback.capture(), eq(true),
-                eq(testPhone), eq(false), eq(TIMEOUT_TO_DYNAMIC_ROUTING_MS), eq(true));
+                eq(testPhone), eq(false), eq(TIMEOUT_TO_DYNAMIC_ROUTING_MS));
 
         mConnection.setDisconnected(null);
 
diff --git a/tests/src/com/android/services/telephony/TelephonyManagerTest.java b/tests/src/com/android/services/telephony/TelephonyManagerTest.java
index 20c062f..efb7375 100644
--- a/tests/src/com/android/services/telephony/TelephonyManagerTest.java
+++ b/tests/src/com/android/services/telephony/TelephonyManagerTest.java
@@ -15,10 +15,12 @@
  */
 
 package com.android.services.telephony;
-import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.fail;
 import static org.junit.Assume.assumeFalse;
+import static org.junit.Assert.assertThrows;
 import static org.junit.Assume.assumeTrue;
+import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 import static org.mockito.ArgumentMatchers.anyInt;
@@ -34,7 +36,9 @@
 import android.content.ComponentName;
 import android.content.Context;
 import android.content.pm.PackageManager;
+import android.os.OutcomeReceiver;
 import android.os.RemoteException;
+import android.platform.test.annotations.RequiresFlagsEnabled;
 import android.telecom.PhoneAccountHandle;
 import android.telephony.SubscriptionManager;
 import android.telephony.TelephonyManager;
@@ -43,9 +47,10 @@
 
 import androidx.test.runner.AndroidJUnit4;
 
-import com.android.internal.telephony.ITelephony;
 import com.android.internal.telephony.IPhoneSubInfo;
+import com.android.internal.telephony.ITelephony;
 import com.android.internal.telephony.PhoneConstants;
+import com.android.internal.telephony.flags.Flags;
 
 import org.junit.After;
 import org.junit.Before;
@@ -53,13 +58,16 @@
 import org.junit.runner.RunWith;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.Executor;
 import java.util.concurrent.Executors;
 import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicReference;
 
 /** Unit tests for {@link TelephonyManager}. */
 @RunWith(AndroidJUnit4.class)
@@ -131,6 +139,55 @@
     }
 
     @Test
+    @RequiresFlagsEnabled(Flags.FLAG_SUPPORT_ISIM_RECORD)
+    public void testGetImsPcscfAddresses() throws Exception {
+        assumeTrue(hasFeature(PackageManager.FEATURE_TELEPHONY_SUBSCRIPTION, true));
+        List<String> pcscfs = Arrays.asList(new String[] { "1.1.1.1 ", " 2.2.2.2"});
+        when(mMockIPhoneSubInfo.getImsPcscfAddresses(anyInt(), anyString()))
+                .thenReturn(pcscfs);
+
+        List<String> actualResult = mTelephonyManager.getImsPcscfAddresses();
+
+        assertTrue(pcscfs.equals(actualResult));
+    }
+
+    @Test
+    @RequiresFlagsEnabled(Flags.FLAG_SUPPORT_ISIM_RECORD)
+    public void testGetImsPcscfAddresses_ReturnEmptyListWhenNotAvailable() throws Exception {
+        assumeTrue(hasFeature(PackageManager.FEATURE_TELEPHONY_SUBSCRIPTION, true));
+        List<String> pcscfs = new ArrayList<>();
+        when(mMockIPhoneSubInfo.getImsPcscfAddresses(anyInt(), anyString()))
+                .thenReturn(pcscfs);
+
+        List<String> actualResult = mTelephonyManager.getImsPcscfAddresses();
+
+        assertTrue(pcscfs.equals(actualResult));
+    }
+
+    @Test
+    @RequiresFlagsEnabled(Flags.FLAG_SUPPORT_ISIM_RECORD)
+    public void testGetImsPcscfAddresses_ReturnEmptyListForInvalidSubId() throws Exception {
+        assumeTrue(hasFeature(PackageManager.FEATURE_TELEPHONY_SUBSCRIPTION, true));
+        List<String> pcscfs = new ArrayList<>();
+        when(mMockIPhoneSubInfo.getImsPcscfAddresses(anyInt(), anyString()))
+                .thenThrow(new IllegalArgumentException("Invalid subscription"));
+
+        List<String> actualResult = mTelephonyManager.getImsPcscfAddresses();
+
+        assertTrue(pcscfs.equals(actualResult));
+    }
+
+    @Test
+    @RequiresFlagsEnabled(Flags.FLAG_SUPPORT_ISIM_RECORD)
+    public void testGetImsPcscfAddresses_ThrowRuntimeException() throws Exception {
+        assumeTrue(hasFeature(PackageManager.FEATURE_TELEPHONY_SUBSCRIPTION, true));
+        when(mMockIPhoneSubInfo.getImsPcscfAddresses(anyInt(), anyString()))
+                .thenThrow(new IllegalStateException("ISIM is not loaded"));
+
+        assertThrows(RuntimeException.class, () -> mTelephonyManager.getImsPcscfAddresses());
+    }
+
+    @Test
     public void testFilterEmergencyNumbersByCategories() throws Exception {
         Map<Integer, List<EmergencyNumber>> emergencyNumberLists = new HashMap<>();
         List<EmergencyNumber> emergencyNumberList = new ArrayList<>();
@@ -260,6 +317,70 @@
         assertEquals(null, mTelephonyManager.getSimServiceTable(PhoneConstants.APPTYPE_RUIM));
     }
 
+    @Test
+    @RequiresFlagsEnabled(Flags.FLAG_SUPPORT_ISIM_RECORD)
+    public void testGetSimServiceTableFromIsimAsByteArrayType() throws Exception {
+        assumeTrue(hasFeature(PackageManager.FEATURE_TELEPHONY_SUBSCRIPTION, true));
+        String simServiceTable = "34FA754E8390BD02";
+        Executor executor = Executors.newSingleThreadExecutor();
+        TestOutcomeReceiver<byte[], Exception> receiver = new TestOutcomeReceiver<>();
+        when(mMockIPhoneSubInfo.getIsimIst(anyInt())).thenReturn(simServiceTable);
+
+        mTelephonyManager.getSimServiceTable(
+                PhoneConstants.APPTYPE_ISIM, executor, receiver);
+
+        byte[] actualResult = receiver.getResult();
+        assertArrayEquals(hexStringToBytes(simServiceTable), actualResult);
+    }
+
+    @Test
+    @RequiresFlagsEnabled(Flags.FLAG_SUPPORT_ISIM_RECORD)
+    public void testGetSimServiceTableFromUsimAsByteArrayType() throws Exception {
+        assumeTrue(hasFeature(PackageManager.FEATURE_TELEPHONY_SUBSCRIPTION, true));
+        String simServiceTable = "34FA754E8390BD02";
+        Executor executor = Executors.newSingleThreadExecutor();
+        TestOutcomeReceiver<byte[], Exception> receiver = new TestOutcomeReceiver<>();
+        when(mMockIPhoneSubInfo.getSimServiceTable(anyInt(), anyInt()))
+                .thenReturn(simServiceTable);
+
+        mTelephonyManager.getSimServiceTable(
+                PhoneConstants.APPTYPE_USIM, executor, receiver);
+
+        byte[] actualResult = receiver.getResult();
+        assertArrayEquals(hexStringToBytes(simServiceTable), actualResult);
+    }
+
+    @Test
+    @RequiresFlagsEnabled(Flags.FLAG_SUPPORT_ISIM_RECORD)
+    public void testGetSimServiceTable_ReturnEmptyArrayWhenNotAvailable() throws Exception {
+        assumeTrue(hasFeature(PackageManager.FEATURE_TELEPHONY_SUBSCRIPTION, true));
+        Executor executor = Executors.newSingleThreadExecutor();
+        TestOutcomeReceiver<byte[], Exception> receiver = new TestOutcomeReceiver<>();
+        when(mMockIPhoneSubInfo.getSimServiceTable(anyInt(), anyInt())).thenReturn(null);
+
+        mTelephonyManager.getSimServiceTable(
+                PhoneConstants.APPTYPE_RUIM, executor, receiver);
+
+        byte[] actualResult = receiver.getResult();
+        assertArrayEquals(new byte[0], actualResult);
+    }
+
+    @Test
+    @RequiresFlagsEnabled(Flags.FLAG_SUPPORT_ISIM_RECORD)
+    public void testGetSimServiceTable_CallbackErrorIfExceptionIsThrown() throws Exception {
+        assumeTrue(hasFeature(PackageManager.FEATURE_TELEPHONY_SUBSCRIPTION, true));
+        Executor executor = Executors.newSingleThreadExecutor();
+        TestOutcomeReceiver<byte[], Exception> receiver = new TestOutcomeReceiver<>();
+        when(mMockIPhoneSubInfo.getIsimIst(anyInt()))
+                .thenThrow(new IllegalStateException("ISIM is not loaded"));
+
+        mTelephonyManager.getSimServiceTable(
+                PhoneConstants.APPTYPE_ISIM, executor, receiver);
+
+        Exception error = receiver.getError();
+        assertTrue(error instanceof IllegalStateException);
+    }
+
     private boolean hasFeature(String feature, boolean status) {
         doReturn(status)
                 .when(mPackageManager).hasSystemFeature(
@@ -295,4 +416,58 @@
         });
 
     }
+
+    private static class TestOutcomeReceiver<R, E extends Throwable>
+            implements OutcomeReceiver<R, E> {
+        final int mTimeoutSeconds = 3;
+        CountDownLatch mLatch = new CountDownLatch(1);
+        AtomicReference<R> mResult = new AtomicReference<>();
+        AtomicReference<E> mError = new AtomicReference<>();
+
+        public R getResult() throws InterruptedException {
+            assertTrue(mLatch.await(mTimeoutSeconds, TimeUnit.SECONDS));
+            assertNotNull(mResult.get());
+            return mResult.get();
+        }
+
+        public E getError() throws InterruptedException {
+            assertTrue(mLatch.await(mTimeoutSeconds, TimeUnit.SECONDS));
+            assertNotNull(mError.get());
+            return mError.get();
+        }
+
+        @Override
+        public void onResult(R result) {
+            mResult.set(result);
+            mLatch.countDown();
+        }
+
+        @Override
+        public void onError(E error) {
+            mError.set(error);
+            mLatch.countDown();
+        }
+    }
+
+    private static byte[] hexStringToBytes(String s) {
+        byte[] ret;
+        if (s == null) return null;
+        int sz = s.length();
+        ret = new byte[sz / 2];
+
+        for (int i = 0; i < sz; i += 2) {
+            ret[i / 2] = (byte) ((hexCharToInt(s.charAt(i)) << 4)
+                                | hexCharToInt(s.charAt(i + 1)));
+        }
+
+        return ret;
+    }
+
+    private static int hexCharToInt(char c) {
+        if (c >= '0' && c <= '9') return (c - '0');
+        if (c >= 'A' && c <= 'F') return (c - 'A' + 10);
+        if (c >= 'a' && c <= 'f') return (c - 'a' + 10);
+
+        throw new RuntimeException("invalid hex char '" + c + "'");
+    }
 }
\ No newline at end of file