diff --git a/Android.bp b/Android.bp
index 66cca32..301343c 100644
--- a/Android.bp
+++ b/Android.bp
@@ -90,7 +90,6 @@
         "android.hardware.radio.modem-V3-java",
         "android.hardware.radio.network-V3-java",
         "android.hardware.radio.sim-V3-java",
-        "android.hardware.radio.satellite-V1-java",
         "android.hardware.radio.voice-V3-java",
         "voip-common",
         "ims-common",
diff --git a/flags/data.aconfig b/flags/data.aconfig
index c769bcc..0bcd4bd 100644
--- a/flags/data.aconfig
+++ b/flags/data.aconfig
@@ -1,8 +1,22 @@
 package: "com.android.internal.telephony.flags"
 
 flag {
+  name: "unthrottle_check_transport"
+  namespace: "telephony"
+  description: "Check transport when unthrottle."
+  bug: "303922311"
+}
+
+flag {
   name: "relax_ho_teardown"
   namespace: "telephony"
   description: "Relax handover tear down if the device is currently in voice call."
   bug: "270895912"
-}
\ No newline at end of file
+}
+
+flag {
+  name: "allow_mmtel_in_non_vops"
+  namespace: "telephony"
+  description: "Allow bring up MMTEL in nonVops area specified by carrier config."
+  bug: "241198464"
+}
diff --git a/flags/messaging.aconfig b/flags/messaging.aconfig
index 777edb7..3c20d69 100644
--- a/flags/messaging.aconfig
+++ b/flags/messaging.aconfig
@@ -5,4 +5,11 @@
   namespace: "telephony"
   description: "Previously, the DB allows insertion of a random sub Id, but doesn't allow query it. This change rejects such interaction."
   bug: "294125411"
-}
\ No newline at end of file
+}
+
+flag {
+  name: "sms_domain_selection_enabled"
+  namespace: "telephony"
+  description: "This flag controls AP domain selection support for normal/emergency SMS."
+  bug: "262804071"
+}
diff --git a/flags/misc.aconfig b/flags/misc.aconfig
index 2b5ab2b..87acccc 100644
--- a/flags/misc.aconfig
+++ b/flags/misc.aconfig
@@ -13,4 +13,11 @@
   namespace: "telephony"
   description: "Whether to log MMS/SMS database access info and report anomaly when getting exception."
   bug: "275225402"
+}
+
+flag {
+  name: "enable_wps_check_api_flag"
+  namespace: "telephony"
+  description: "Enable system api isWpsCallNumber. Its an utility api to check if the dialed number is for Wireless Priority Service call."
+  bug: "304272356"
 }
\ No newline at end of file
diff --git a/flags/network.aconfig b/flags/network.aconfig
index 0c7873e..299a2a0 100644
--- a/flags/network.aconfig
+++ b/flags/network.aconfig
@@ -6,3 +6,10 @@
     description: "enabling this flag allows KEY_CARRIER_NR_AVAILABILITIES_INT_ARRAY to control N1 mode enablement"
     bug:"302033535"
 }
+
+flag {
+  name: "hide_roaming_icon"
+  namespace: "telephony"
+  description: "Allow carriers to hide the roaming (R) icon when roaming."
+  bug: "301467052"
+}
diff --git a/proto/src/persist_atoms.proto b/proto/src/persist_atoms.proto
index 722cb7c..993aa4d 100644
--- a/proto/src/persist_atoms.proto
+++ b/proto/src/persist_atoms.proto
@@ -427,6 +427,8 @@
     optional int64 video_available_millis = 10;
     optional int64 ut_capable_millis = 11;
     optional int64 ut_available_millis = 12;
+    optional int64 registering_millis = 13;
+    optional int64 unregistered_millis = 14;
 
     // Internal use only
     optional int64 last_used_millis = 10001;
diff --git a/src/java/com/android/internal/telephony/BaseCommands.java b/src/java/com/android/internal/telephony/BaseCommands.java
index f461e68..4ec1f71 100644
--- a/src/java/com/android/internal/telephony/BaseCommands.java
+++ b/src/java/com/android/internal/telephony/BaseCommands.java
@@ -18,7 +18,6 @@
 package com.android.internal.telephony;
 
 import android.annotation.NonNull;
-import android.annotation.Nullable;
 import android.compat.annotation.UnsupportedAppUsage;
 import android.content.Context;
 import android.os.AsyncResult;
@@ -119,13 +118,6 @@
     protected RegistrantList mConnectionSetupFailureRegistrants = new RegistrantList();
     protected RegistrantList mNotifyAnbrRegistrants = new RegistrantList();
     protected RegistrantList mTriggerImsDeregistrationRegistrants = new RegistrantList();
-    protected RegistrantList mPendingSatelliteMessageCountRegistrants = new RegistrantList();
-    protected RegistrantList mNewSatelliteMessagesRegistrants = new RegistrantList();
-    protected RegistrantList mSatelliteMessagesTransferCompleteRegistrants = new RegistrantList();
-    protected RegistrantList mSatellitePointingInfoChangedRegistrants = new RegistrantList();
-    protected RegistrantList mSatelliteModeChangedRegistrants = new RegistrantList();
-    protected RegistrantList mSatelliteRadioTechnologyChangedRegistrants = new RegistrantList();
-    protected RegistrantList mSatelliteProvisionStateChangedRegistrants = new RegistrantList();
 
     @UnsupportedAppUsage
     protected Registrant mGsmSmsRegistrant;
@@ -1182,81 +1174,4 @@
     public void unregisterForTriggerImsDeregistration(Handler h) {
         mTriggerImsDeregistrationRegistrants.remove(h);
     }
-
-    @Override
-    public void registerForPendingSatelliteMessageCount(
-            @NonNull Handler h, int what, @Nullable Object obj) {
-        mPendingSatelliteMessageCountRegistrants.add(h, what, obj);
-    }
-
-    @Override
-    public void unregisterForPendingSatelliteMessageCount(@NonNull Handler h) {
-        mPendingSatelliteMessageCountRegistrants.remove(h);
-    }
-
-    @Override
-    public void registerForNewSatelliteMessages(
-            @NonNull Handler h, int what, @Nullable Object obj) {
-        mNewSatelliteMessagesRegistrants.add(h, what, obj);
-    }
-
-    @Override
-    public void unregisterForNewSatelliteMessages(@NonNull Handler h) {
-        mNewSatelliteMessagesRegistrants.remove(h);
-    }
-
-    @Override
-    public void registerForSatelliteMessagesTransferComplete(@NonNull Handler h,
-            int what, @Nullable Object obj) {
-        mSatelliteMessagesTransferCompleteRegistrants.add(h, what, obj);
-    }
-
-    @Override
-    public void unregisterForSatelliteMessagesTransferComplete(@NonNull Handler h) {
-        mSatelliteMessagesTransferCompleteRegistrants.remove(h);
-    }
-
-    @Override
-    public void registerForSatellitePointingInfoChanged(@NonNull Handler h,
-            int what, @Nullable Object obj) {
-        mSatellitePointingInfoChangedRegistrants.add(h, what, obj);
-    }
-
-    @Override
-    public void unregisterForSatellitePointingInfoChanged(@NonNull Handler h) {
-        mSatellitePointingInfoChangedRegistrants.remove(h);
-    }
-
-    @Override
-    public void registerForSatelliteModeChanged(@NonNull Handler h,
-            int what, @Nullable Object obj) {
-        mSatelliteModeChangedRegistrants.add(h, what, obj);
-    }
-
-    @Override
-    public void unregisterForSatelliteModeChanged(@NonNull Handler h) {
-        mSatelliteModeChangedRegistrants.remove(h);
-    }
-
-    @Override
-    public void registerForSatelliteRadioTechnologyChanged(@NonNull Handler h,
-            int what, @Nullable Object obj) {
-        mSatelliteRadioTechnologyChangedRegistrants.add(h, what, obj);
-    }
-
-    @Override
-    public void unregisterForSatelliteRadioTechnologyChanged(@NonNull Handler h) {
-        mSatelliteRadioTechnologyChangedRegistrants.remove(h);
-    }
-
-    @Override
-    public void registerForSatelliteProvisionStateChanged(@NonNull Handler h,
-            int what, @Nullable Object obj) {
-        mSatelliteProvisionStateChangedRegistrants.add(h, what, obj);
-    }
-
-    @Override
-    public void unregisterForSatelliteProvisionStateChanged(@NonNull Handler h) {
-        mSatelliteProvisionStateChangedRegistrants.remove(h);
-    }
 }
diff --git a/src/java/com/android/internal/telephony/CarrierKeyDownloadManager.java b/src/java/com/android/internal/telephony/CarrierKeyDownloadManager.java
index beb6b26..195ef16 100644
--- a/src/java/com/android/internal/telephony/CarrierKeyDownloadManager.java
+++ b/src/java/com/android/internal/telephony/CarrierKeyDownloadManager.java
@@ -30,6 +30,7 @@
 import android.os.Handler;
 import android.os.Message;
 import android.os.PersistableBundle;
+import android.os.UserManager;
 import android.telephony.CarrierConfigManager;
 import android.telephony.ImsiEncryptionInfo;
 import android.telephony.SubscriptionManager;
@@ -108,6 +109,7 @@
     private boolean mAllowedOverMeteredNetwork = false;
     private boolean mDeleteOldKeyAfterDownload = false;
     private TelephonyManager mTelephonyManager;
+    private UserManager mUserManager;
 
     @VisibleForTesting
     public String mMccMncForDownload;
@@ -125,18 +127,35 @@
         mDownloadManager = (DownloadManager) mContext.getSystemService(Context.DOWNLOAD_SERVICE);
         mTelephonyManager = mContext.getSystemService(TelephonyManager.class)
                 .createForSubscriptionId(mPhone.getSubId());
+        mUserManager = mContext.getSystemService(UserManager.class);
         CarrierConfigManager carrierConfigManager = mContext.getSystemService(
                 CarrierConfigManager.class);
         // Callback which directly handle config change should be executed on handler thread
         carrierConfigManager.registerCarrierConfigChangeListener(this::post,
                 (slotIndex, subId, carrierId, specificCarrierId) -> {
-                    if (slotIndex == mPhone.getPhoneId()) {
+                    boolean isUserUnlocked = mUserManager.isUserUnlocked();
+
+                    if (isUserUnlocked && slotIndex == mPhone.getPhoneId()) {
                         Log.d(LOG_TAG, "Carrier Config changed: slotIndex=" + slotIndex);
                         handleAlarmOrConfigChange();
+                    } else {
+                        Log.d(LOG_TAG, "User is locked");
+                        mContext.registerReceiver(mUserUnlockedReceiver, new IntentFilter(
+                                Intent.ACTION_USER_UNLOCKED));
                     }
                 });
     }
 
+    private final BroadcastReceiver mUserUnlockedReceiver = new BroadcastReceiver() {
+        @Override
+        public void onReceive(Context context, Intent intent) {
+            if (Intent.ACTION_USER_UNLOCKED.equals(intent.getAction())) {
+                Log.d(LOG_TAG, "Received UserUnlockedReceiver");
+                handleAlarmOrConfigChange();
+            }
+        }
+    };
+
     private final BroadcastReceiver mDownloadReceiver = new BroadcastReceiver() {
         @Override
         public void onReceive(Context context, Intent intent) {
diff --git a/src/java/com/android/internal/telephony/CommandException.java b/src/java/com/android/internal/telephony/CommandException.java
index 6b6d84f..6b80e9f 100644
--- a/src/java/com/android/internal/telephony/CommandException.java
+++ b/src/java/com/android/internal/telephony/CommandException.java
@@ -352,28 +352,6 @@
                 return new CommandException(Error.RF_HARDWARE_ISSUE);
             case RILConstants.NO_RF_CALIBRATION_INFO:
                 return new CommandException(Error.NO_RF_CALIBRATION_INFO);
-            case RILConstants.ENCODING_NOT_SUPPORTED:
-                return new CommandException(Error.ENCODING_NOT_SUPPORTED);
-            case RILConstants.FEATURE_NOT_SUPPORTED:
-                return new CommandException(Error.FEATURE_NOT_SUPPORTED);
-            case RILConstants.INVALID_CONTACT:
-                return new CommandException(Error.INVALID_CONTACT);
-            case RILConstants.MODEM_INCOMPATIBLE:
-                return new CommandException(Error.MODEM_INCOMPATIBLE);
-            case RILConstants.NETWORK_TIMEOUT:
-                return new CommandException(Error.NETWORK_TIMEOUT);
-            case RILConstants.NO_SATELLITE_SIGNAL:
-                return new CommandException(Error.NO_SATELLITE_SIGNAL);
-            case RILConstants.NOT_SUFFICIENT_ACCOUNT_BALANCE:
-                return new CommandException(Error.NOT_SUFFICIENT_ACCOUNT_BALANCE);
-            case RILConstants.RADIO_TECHNOLOGY_NOT_SUPPORTED:
-                return new CommandException(Error.RADIO_TECHNOLOGY_NOT_SUPPORTED);
-            case RILConstants.SUBSCRIBER_NOT_AUTHORIZED:
-                return new CommandException(Error.SUBSCRIBER_NOT_AUTHORIZED);
-            case RILConstants.SWITCHED_FROM_SATELLITE_TO_TERRESTRIAL:
-                return new CommandException(Error.SWITCHED_FROM_SATELLITE_TO_TERRESTRIAL);
-            case RILConstants.UNIDENTIFIED_SUBSCRIBER:
-                return new CommandException(Error.UNIDENTIFIED_SUBSCRIBER);
             default:
                 Rlog.e("GSM", "Unrecognized RIL errno " + ril_errno);
                 return new CommandException(Error.INVALID_RESPONSE);
diff --git a/src/java/com/android/internal/telephony/CommandsInterface.java b/src/java/com/android/internal/telephony/CommandsInterface.java
index 006a421..71c2001 100644
--- a/src/java/com/android/internal/telephony/CommandsInterface.java
+++ b/src/java/com/android/internal/telephony/CommandsInterface.java
@@ -74,7 +74,6 @@
     // Used as parameters for call forward methods below
     static final int CF_ACTION_DISABLE          = 0;
     static final int CF_ACTION_ENABLE           = 1;
-//  static final int CF_ACTION_UNUSED           = 2;
     static final int CF_ACTION_REGISTRATION     = 3;
     static final int CF_ACTION_ERASURE          = 4;
 
@@ -628,85 +627,85 @@
     @UnsupportedAppUsage
     void setEmergencyCallbackMode(Handler h, int what, Object obj);
 
-     /**
-      * Fires on any CDMA OTA provision status change
-      */
-     @UnsupportedAppUsage
-     void registerForCdmaOtaProvision(Handler h,int what, Object obj);
-     @UnsupportedAppUsage
-     void unregisterForCdmaOtaProvision(Handler h);
+    /**
+     * Fires on any CDMA OTA provision status change
+     */
+    @UnsupportedAppUsage
+    void registerForCdmaOtaProvision(Handler h, int what, Object obj);
+    @UnsupportedAppUsage
+    void unregisterForCdmaOtaProvision(Handler h);
 
-     /**
-      * Registers the handler when out-band ringback tone is needed.<p>
-      *
-      *  Messages received from this:
-      *  Message.obj will be an AsyncResult
-      *  AsyncResult.userObj = obj
-      *  AsyncResult.result = boolean. <p>
-      */
-     void registerForRingbackTone(Handler h, int what, Object obj);
-     void unregisterForRingbackTone(Handler h);
+    /**
+     * Registers the handler when out-band ringback tone is needed.<p>
+     *
+     *  Messages received from this:
+     *  Message.obj will be an AsyncResult
+     *  AsyncResult.userObj = obj
+     *  AsyncResult.result = boolean. <p>
+     */
+    void registerForRingbackTone(Handler h, int what, Object obj);
+    void unregisterForRingbackTone(Handler h);
 
-     /**
-      * Registers the handler when mute/unmute need to be resent to get
-      * uplink audio during a call.<p>
-      *
-      * @param h Handler for notification message.
-      * @param what User-defined message code.
-      * @param obj User object.
-      *
-      */
-     void registerForResendIncallMute(Handler h, int what, Object obj);
-     void unregisterForResendIncallMute(Handler h);
+    /**
+     * Registers the handler when mute/unmute need to be resent to get
+     * uplink audio during a call.<p>
+     *
+     * @param h Handler for notification message.
+     * @param what User-defined message code.
+     * @param obj User object.
+     *
+     */
+    void registerForResendIncallMute(Handler h, int what, Object obj);
+    void unregisterForResendIncallMute(Handler h);
 
-     /**
-      * Registers the handler for when Cdma subscription changed events
-      *
-      * @param h Handler for notification message.
-      * @param what User-defined message code.
-      * @param obj User object.
-      *
-      */
-     void registerForCdmaSubscriptionChanged(Handler h, int what, Object obj);
-     void unregisterForCdmaSubscriptionChanged(Handler h);
+    /**
+     * Registers the handler for when Cdma subscription changed events
+     *
+     * @param h Handler for notification message.
+     * @param what User-defined message code.
+     * @param obj User object.
+     *
+     */
+    void registerForCdmaSubscriptionChanged(Handler h, int what, Object obj);
+    void unregisterForCdmaSubscriptionChanged(Handler h);
 
-     /**
-      * Registers the handler for when Cdma prl changed events
-      *
-      * @param h Handler for notification message.
-      * @param what User-defined message code.
-      * @param obj User object.
-      *
-      */
-     void registerForCdmaPrlChanged(Handler h, int what, Object obj);
-     void unregisterForCdmaPrlChanged(Handler h);
+    /**
+     * Registers the handler for when Cdma prl changed events
+     *
+     * @param h Handler for notification message.
+     * @param what User-defined message code.
+     * @param obj User object.
+     *
+     */
+    void registerForCdmaPrlChanged(Handler h, int what, Object obj);
+    void unregisterForCdmaPrlChanged(Handler h);
 
-     /**
-      * Registers the handler for when Cdma prl changed events
-      *
-      * @param h Handler for notification message.
-      * @param what User-defined message code.
-      * @param obj User object.
-      *
-      */
-     void registerForExitEmergencyCallbackMode(Handler h, int what, Object obj);
-     void unregisterForExitEmergencyCallbackMode(Handler h);
+    /**
+     * Registers the handler for when Cdma prl changed events
+     *
+     * @param h Handler for notification message.
+     * @param what User-defined message code.
+     * @param obj User object.
+     *
+     */
+    void registerForExitEmergencyCallbackMode(Handler h, int what, Object obj);
+    void unregisterForExitEmergencyCallbackMode(Handler h);
 
-     /**
-      * Registers the handler for RIL_UNSOL_RIL_CONNECT events.
-      *
-      * When ril connects or disconnects a message is sent to the registrant
-      * which contains an AsyncResult, ar, in msg.obj. The ar.result is an
-      * Integer which is the version of the ril or -1 if the ril disconnected.
-      *
-      * @param h Handler for notification message.
-      * @param what User-defined message code.
-      * @param obj User object.
-      */
-     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
-     void registerForRilConnected(Handler h, int what, Object obj);
-     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
-     void unregisterForRilConnected(Handler h);
+    /**
+     * Registers the handler for RIL_UNSOL_RIL_CONNECT events.
+     *
+     * When ril connects or disconnects a message is sent to the registrant
+     * which contains an AsyncResult, ar, in msg.obj. The ar.result is an
+     * Integer which is the version of the ril or -1 if the ril disconnected.
+     *
+     * @param h Handler for notification message.
+     * @param what User-defined message code.
+     * @param obj User object.
+     */
+    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
+    void registerForRilConnected(Handler h, int what, Object obj);
+    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
+    void unregisterForRilConnected(Handler h);
 
     /**
      * Registers the handler for RIL_UNSOL_SIM_DETACH_FROM_NETWORK_CONFIG_CHANGED events.
@@ -921,7 +920,7 @@
      * CLIR_INVOCATION  == on "CLIR invocation" (restrict CLI presentation)
      */
     void dial(String address, boolean isEmergencyCall, EmergencyNumber emergencyNumberInfo,
-              boolean hasKnownUserIntentEmergency, int clirMode, Message result);
+            boolean hasKnownUserIntentEmergency, int clirMode, Message result);
 
     /**
      *  returned message
@@ -935,7 +934,7 @@
      * CLIR_INVOCATION  == on "CLIR invocation" (restrict CLI presentation)
      */
     void dial(String address, boolean isEmergencyCall, EmergencyNumber emergencyNumberInfo,
-              boolean hasKnownUserIntentEmergency, int clirMode, UUSInfo uusInfo, Message result);
+            boolean hasKnownUserIntentEmergency, int clirMode, UUSInfo uusInfo, Message result);
 
     /**
      *  returned message
@@ -1372,7 +1371,7 @@
      */
     @UnsupportedAppUsage
     void setCallForward(int action, int cfReason, int serviceClass,
-                String number, int timeSeconds, Message response);
+            String number, int timeSeconds, Message response);
 
     /**
      * cfReason is one of CF_REASON_*
@@ -1450,7 +1449,7 @@
 
     @UnsupportedAppUsage
     void queryFacilityLock (String facility, String password, int serviceClass,
-        Message response);
+            Message response);
 
     /**
      * (AsyncResult)response.obj).result will be an Integer representing
@@ -1465,7 +1464,7 @@
      */
 
     void queryFacilityLockForApp(String facility, String password, int serviceClass, String appId,
-        Message response);
+            Message response);
 
     /**
      * @param facility one of CB_FACILTY_*
@@ -1476,7 +1475,7 @@
      */
     @UnsupportedAppUsage
     void setFacilityLock (String facility, boolean lockState, String password,
-        int serviceClass, Message response);
+            int serviceClass, Message response);
 
     /**
      * Set the facility lock for the app with this AID on the ICC card.
@@ -1489,7 +1488,7 @@
      * @param response is callback message
      */
     void setFacilityLockForApp(String facility, boolean lockState, String password,
-        int serviceClass, String appId, Message response);
+            int serviceClass, String appId, Message response);
 
     void sendUSSD (String ussdString, Message response);
 
@@ -1526,7 +1525,7 @@
     @UnsupportedAppUsage
     void setPreferredNetworkType(int networkType , Message response);
 
-     /**
+    /**
      *  Query the preferred network type setting
      *
      * @param response is callback message to report one of  NT_*_TYPE
@@ -1543,7 +1542,7 @@
     void setAllowedNetworkTypesBitmap(
             @TelephonyManager.NetworkTypeBitMask int networkTypeBitmask, Message response);
 
-     /**
+    /**
      *  Query the allowed network types setting.
      *
      * @param response is callback message to report allowed network types bitmask
@@ -2148,7 +2147,7 @@
         return HalVersion.UNKNOWN;
     }
 
-   /**
+    /**
      * Sets user selected subscription at Modem.
      *
      * @param slotId
@@ -2613,7 +2612,7 @@
         return true;
     };
 
-   /**
+    /**
      * Return the class name of the currently bound modem service.
      *
      * @return the class name of the modem service.
@@ -2622,18 +2621,18 @@
         return "default";
     };
 
-   /**
+    /**
      * Request the SIM phonebook records of all activated UICC applications
      *
      * @param result Callback message containing the count of ADN valid record.
      */
-    public void getSimPhonebookRecords(Message result);
+    void getSimPhonebookRecords(Message result);
 
-   /**
+    /**
      * Request the SIM phonebook Capacity of all activated UICC applications
      *
      */
-    public void getSimPhonebookCapacity(Message result);
+    void getSimPhonebookCapacity(Message result);
 
     /**
      * Request to insert/delete/update the SIM phonebook record
@@ -2641,7 +2640,7 @@
      * @param phonebookRecordInfo adn record information to be updated
      * @param result Callback message containing the SIM phonebook record index.
      */
-    public void updateSimPhonebookRecord(SimPhonebookRecord phonebookRecordInfo, Message result);
+    void updateSimPhonebookRecord(SimPhonebookRecord phonebookRecordInfo, Message result);
 
     /**
      * Registers the handler when the SIM phonebook is changed.
@@ -2650,14 +2649,14 @@
      * @param what User-defined message code.
      * @param obj User object .
      */
-    public void registerForSimPhonebookChanged(Handler h, int what, Object obj);
+    void registerForSimPhonebookChanged(Handler h, int what, Object obj);
 
     /**
      * Unregister for notifications when SIM phonebook has already init done.
      *
      * @param h Handler to be removed from the registrant list.
      */
-    public void unregisterForSimPhonebookChanged(Handler h);
+    void unregisterForSimPhonebookChanged(Handler h);
 
     /**
      * Registers the handler when a group of SIM phonebook records received.
@@ -2666,14 +2665,14 @@
      * @param what User-defined message code.
      * @param obj User object.
      */
-    public void registerForSimPhonebookRecordsReceived(Handler h, int what, Object obj);
+    void registerForSimPhonebookRecordsReceived(Handler h, int what, Object obj);
 
     /**
      * Unregister for notifications when a group of SIM phonebook records received.
      *
      * @param h Handler to be removed from the registrant list.
      */
-     public void unregisterForSimPhonebookRecordsReceived(Handler h);
+    void unregisterForSimPhonebookRecordsReceived(Handler h);
 
     /**
      * Registers for notifications of connection setup failure.
@@ -2892,263 +2891,4 @@
      * @param result Callback message to receive the result.
      */
     default void isN1ModeEnabled(Message result) {}
-
-    /**
-     * Get feature capabilities supported by satellite.
-     *
-     * @param result Message that will be sent back to the requester
-     */
-    default void getSatelliteCapabilities(Message result) {}
-
-    /**
-     * Turn satellite modem on/off.
-     *
-     * @param result Message that will be sent back to the requester
-     * @param on {@code true} for turning on.
-     *           {@code false} for turning off.
-     */
-    default void setSatellitePower(Message result, boolean on) {}
-
-    /**
-     * Get satellite modem state.
-     *
-     * @param result Message that will be sent back to the requester
-     */
-    default void getSatellitePowerState(Message result) {}
-
-    /**
-     * Get satellite provision state.
-     *
-     * @param result Message that will be sent back to the requester
-     */
-    default void getSatelliteProvisionState(Message result) {}
-
-    /**
-     * Check whether satellite modem is supported by the device.
-     *
-     * @param result Message that will be sent back to the requester
-     */
-    default void isSatelliteSupported(Message result) {}
-
-    /**
-     * Provision the subscription with a satellite provider. This is needed to register the
-     * subscription if the provider allows dynamic registration.
-     *
-     * @param result Message that will be sent back to the requester.
-     * @param imei IMEI of the SIM associated with the satellite modem.
-     * @param msisdn MSISDN of the SIM associated with the satellite modem.
-     * @param imsi IMSI of the SIM associated with the satellite modem.
-     * @param features List of features to be provisioned.
-     */
-    default void provisionSatelliteService(
-            Message result, String imei, String msisdn, String imsi, int[] features) {}
-
-    /**
-     * Add contacts that are allowed to be used for satellite communication. This is applicable for
-     * incoming messages as well.
-     *
-     * @param result Message that will be sent back to the requester.
-     * @param contacts List of allowed contacts to be added.
-     */
-    default void addAllowedSatelliteContacts(Message result, String[] contacts) {}
-
-    /**
-     * Remove contacts that are allowed to be used for satellite communication. This is applicable
-     * for incoming messages as well.
-     *
-     * @param result Message that will be sent back to the requester.
-     * @param contacts List of allowed contacts to be removed.
-     */
-    default void removeAllowedSatelliteContacts(Message result, String[] contacts) {}
-
-    /**
-     * Send text messages.
-     *
-     * @param result Message that will be sent back to the requester.
-     * @param messages List of messages in text format to be sent.
-     * @param destination The recipient of the message.
-     * @param latitude The current latitude of the device.
-     * @param longitude The current longitude of the device. The location (i.e., latitude and
-     *        longitude) of the device will be filled for emergency messages.
-     */
-    default void sendSatelliteMessages(Message result, String[] messages, String destination,
-            double latitude, double longitude) {}
-
-    /**
-     * Get pending messages.
-     *
-     * @param result Message that will be sent back to the requester.
-     */
-    default void getPendingSatelliteMessages(Message result) {}
-
-    /**
-     * Get current satellite registration mode.
-     *
-     * @param result Message that will be sent back to the requester.
-     */
-    default void getSatelliteMode(Message result) {}
-
-    /**
-     * Set the filter for what type of indication framework want to receive from modem.
-     *
-     * @param result Message that will be sent back to the requester.
-     * @param filterBitmask The filter bitmask identifying what type of indication Telephony
-     *                      framework wants to receive from modem.
-     */
-    default void setSatelliteIndicationFilter(Message result, int filterBitmask) {}
-
-    /**
-     * User started pointing to the satellite. Modem should continue to update the ponting input
-     * as user moves device.
-     *
-     * @param result Message that will be sent back to the requester.
-     */
-    default void startSendingSatellitePointingInfo(Message result) {}
-
-    /**
-     * Stop sending satellite pointing info to the framework.
-     *
-     * @param result Message that will be sent back to the requester.
-     */
-    default void stopSendingSatellitePointingInfo(Message result) {}
-
-    /**
-     * Get max number of characters per text message.
-     *
-     * @param result Message that will be sent back to the requester.
-     */
-    default void getMaxCharactersPerSatelliteTextMessage(Message result) {}
-
-    /**
-     * Get whether satellite communication is allowed for the current location.
-     *
-     * @param result Message that will be sent back to the requester.
-     */
-    default void isSatelliteCommunicationAllowedForCurrentLocation(Message result) {}
-
-    /**
-     * Get the time after which the satellite will be visible.
-     *
-     * @param result Message that will be sent back to the requester.
-     */
-    default void getTimeForNextSatelliteVisibility(Message result) {}
-
-    /**
-     * Registers for pending message count from satellite modem.
-     *
-     * @param h Handler for notification message.
-     * @param what User-defined message code.
-     * @param obj User object.
-     */
-    default void registerForPendingSatelliteMessageCount(@NonNull Handler h,
-            int what, @Nullable Object obj) {}
-
-    /**
-     * Unregisters for pending message count from satellite modem.
-     *
-     * @param h Handler to be removed from the registrant list.
-     */
-    default void unregisterForPendingSatelliteMessageCount(@NonNull Handler h) {}
-
-    /**
-     * Registers for new messages from satellite modem.
-     *
-     * @param h Handler for notification message.
-     * @param what User-defined message code.
-     * @param obj User object.
-     */
-    default void registerForNewSatelliteMessages(@NonNull Handler h,
-            int what, @Nullable Object obj) {}
-
-    /**
-     * Unregisters for new messages from satellite modem.
-     *
-     * @param h Handler to be removed from the registrant list.
-     */
-    default void unregisterForNewSatelliteMessages(@NonNull Handler h) {}
-
-    /**
-     * Registers for messages transfer complete from satellite modem.
-     *
-     * @param h Handler for notification message.
-     * @param what User-defined message code.
-     * @param obj User object.
-     */
-    default void registerForSatelliteMessagesTransferComplete(@NonNull Handler h,
-            int what, @Nullable Object obj) {}
-
-    /**
-     * Unregisters for messages transfer complete from satellite modem.
-     *
-     * @param h Handler to be removed from the registrant list.
-     */
-    default void unregisterForSatelliteMessagesTransferComplete(@NonNull Handler h) {}
-
-    /**
-     * Registers for pointing info changed from satellite modem.
-     *
-     * @param h Handler for notification message.
-     * @param what User-defined message code.
-     * @param obj User object.
-     */
-    default void registerForSatellitePointingInfoChanged(@NonNull Handler h,
-            int what, @Nullable Object obj) {}
-
-    /**
-     * Unregisters for pointing info changed from satellite modem.
-     *
-     * @param h Handler to be removed from the registrant list.
-     */
-    default void unregisterForSatellitePointingInfoChanged(@NonNull Handler h) {}
-
-    /**
-     * Registers for mode changed from satellite modem.
-     *
-     * @param h Handler for notification message.
-     * @param what User-defined message code.
-     * @param obj User object.
-     */
-    default void registerForSatelliteModeChanged(@NonNull Handler h,
-            int what, @Nullable Object obj) {}
-
-    /**
-     * Unregisters for mode changed from satellite modem.
-     *
-     * @param h Handler to be removed from the registrant list.
-     */
-    default void unregisterForSatelliteModeChanged(@NonNull Handler h) {}
-
-    /**
-     * Registers for radio technology changed from satellite modem.
-     *
-     * @param h Handler for notification message.
-     * @param what User-defined message code.
-     * @param obj User object.
-     */
-    default void registerForSatelliteRadioTechnologyChanged(@NonNull Handler h,
-            int what, @Nullable Object obj) {}
-
-    /**
-     * Unregisters for radio technology changed from satellite modem.
-     *
-     * @param h Handler to be removed from the registrant list.
-     */
-    default void unregisterForSatelliteRadioTechnologyChanged(@NonNull Handler h) {}
-
-    /**
-     * Registers for provision state changed from satellite modem.
-     *
-     * @param h Handler for notification message.
-     * @param what User-defined message code.
-     * @param obj User object.
-     */
-    default void registerForSatelliteProvisionStateChanged(@NonNull Handler h,
-            int what, @Nullable Object obj) {}
-
-    /**
-     * Unregisters for provision state changed from satellite modem.
-     *
-     * @param h Handler to be removed from the registrant list.
-     */
-    default void unregisterForSatelliteProvisionStateChanged(@NonNull Handler h) {}
-}
+}
\ No newline at end of file
diff --git a/src/java/com/android/internal/telephony/DeviceStateMonitor.java b/src/java/com/android/internal/telephony/DeviceStateMonitor.java
index ecc6208..7bdf2ff 100644
--- a/src/java/com/android/internal/telephony/DeviceStateMonitor.java
+++ b/src/java/com/android/internal/telephony/DeviceStateMonitor.java
@@ -22,6 +22,7 @@
 import static android.hardware.radio.V1_0.DeviceStateType.POWER_SAVE_MODE;
 import static android.telephony.TelephonyManager.HAL_SERVICE_NETWORK;
 
+import android.annotation.NonNull;
 import android.app.UiModeManager;
 import android.content.BroadcastReceiver;
 import android.content.Context;
@@ -47,6 +48,7 @@
 import android.view.Display;
 
 import com.android.internal.annotations.VisibleForTesting;
+import com.android.internal.telephony.flags.FeatureFlags;
 import com.android.internal.util.IndentingPrintWriter;
 import com.android.telephony.Rlog;
 
@@ -92,10 +94,14 @@
     private static final int NR_NSA_TRACKING_INDICATIONS_ALWAYS_ON = 2;
 
     private final Phone mPhone;
+    @NonNull
+    private final FeatureFlags mFeatureFlags;
 
     private final LocalLog mLocalLog = new LocalLog(64);
 
     private final RegistrantList mPhysicalChannelConfigRegistrants = new RegistrantList();
+    private final RegistrantList mSignalStrengthReportDecisionCallbackRegistrants =
+            new RegistrantList();
 
     private final NetworkRequest mWifiNetworkRequest =
             new NetworkRequest.Builder()
@@ -269,8 +275,9 @@
      *
      * @param phone Phone object
      */
-    public DeviceStateMonitor(Phone phone) {
+    public DeviceStateMonitor(Phone phone, @NonNull FeatureFlags featureFlags) {
         mPhone = phone;
+        mFeatureFlags = featureFlags;
         DisplayManager dm = (DisplayManager) phone.getContext().getSystemService(
                 Context.DISPLAY_SERVICE);
         dm.registerDisplayListener(mDisplayListener, null);
@@ -602,6 +609,15 @@
             // use a null message since we don't care of receiving response
             mPhone.mCi.getBarringInfo(null);
         }
+
+        // Determine whether to notify registrants about the non-terrestrial signal strength change.
+        if (mFeatureFlags.oemEnabledSatelliteFlag()) {
+            if (shouldEnableSignalStrengthReports()) {
+                mSignalStrengthReportDecisionCallbackRegistrants.notifyResult(true);
+            } else {
+                mSignalStrengthReportDecisionCallbackRegistrants.notifyResult(false);
+            }
+        }
     }
 
     /**
@@ -778,6 +794,33 @@
     }
 
     /**
+     * Register a callback to decide whether signal strength should be notified or not.
+     * @param h Handler to notify
+     * @param what msg.what when the message is delivered
+     * @param obj AsyncResult.userObj when the message is delivered
+     */
+    public void registerForSignalStrengthReportDecision(Handler h, int what, Object obj) {
+        if (!mFeatureFlags.oemEnabledSatelliteFlag()) {
+            Rlog.d(TAG, "oemEnabledSatelliteFlag is disabled");
+            return;
+        }
+        Registrant r = new Registrant(h, what, obj);
+        mSignalStrengthReportDecisionCallbackRegistrants.add(r);
+    }
+
+    /**
+     * Register a callback to decide whether signal strength should be notified or not.
+     * @param h Handler to notify
+     */
+    public void unregisterForSignalStrengthReportDecision(Handler h) {
+        if (!mFeatureFlags.oemEnabledSatelliteFlag()) {
+            Rlog.d(TAG, "oemEnabledSatelliteFlag is disabled");
+            return;
+        }
+        mSignalStrengthReportDecisionCallbackRegistrants.remove(h);
+    }
+
+    /**
      * @param msg Debug message
      * @param logIntoLocalLog True if log into the local log
      */
diff --git a/src/java/com/android/internal/telephony/DisplayInfoController.java b/src/java/com/android/internal/telephony/DisplayInfoController.java
index 567331d..945b640 100644
--- a/src/java/com/android/internal/telephony/DisplayInfoController.java
+++ b/src/java/com/android/internal/telephony/DisplayInfoController.java
@@ -19,9 +19,11 @@
 import android.annotation.NonNull;
 import android.os.Handler;
 import android.os.Message;
+import android.os.PersistableBundle;
 import android.os.Registrant;
 import android.os.RegistrantList;
 import android.telephony.AnomalyReporter;
+import android.telephony.CarrierConfigManager;
 import android.telephony.ServiceState;
 import android.telephony.TelephonyDisplayInfo;
 import android.telephony.TelephonyManager;
@@ -29,6 +31,7 @@
 import android.util.LocalLog;
 import android.util.Pair;
 
+import com.android.internal.telephony.flags.FeatureFlags;
 import com.android.telephony.Rlog;
 
 import java.io.FileDescriptor;
@@ -66,34 +69,55 @@
 
     /** Event for service state changed (roaming). */
     private static final int EVENT_SERVICE_STATE_CHANGED = 1;
+    /** Event for carrier config changed. */
+    private static final int EVENT_CARRIER_CONFIG_CHANGED = 2;
 
-    private final Phone mPhone;
-    private final NetworkTypeController mNetworkTypeController;
-    private final RegistrantList mTelephonyDisplayInfoChangedRegistrants = new RegistrantList();
-    private @NonNull TelephonyDisplayInfo mTelephonyDisplayInfo;
-    private @NonNull ServiceState mServiceState;
+    @NonNull private final Phone mPhone;
+    @NonNull private final NetworkTypeController mNetworkTypeController;
+    @NonNull private final RegistrantList mTelephonyDisplayInfoChangedRegistrants =
+            new RegistrantList();
+    @NonNull private final FeatureFlags mFeatureFlags;
+    @NonNull private TelephonyDisplayInfo mTelephonyDisplayInfo;
+    @NonNull private ServiceState mServiceState;
+    @NonNull private PersistableBundle mConfigs;
 
-    public DisplayInfoController(Phone phone) {
+    public DisplayInfoController(@NonNull Phone phone, @NonNull FeatureFlags featureFlags) {
         mPhone = phone;
+        mFeatureFlags = featureFlags;
         mLogTag = "DIC-" + mPhone.getPhoneId();
+        mServiceState = mPhone.getServiceStateTracker().getServiceState();
+        mConfigs = new PersistableBundle();
+        try {
+            mConfigs = mPhone.getContext().getSystemService(CarrierConfigManager.class)
+                    .getConfigForSubId(mPhone.getSubId(),
+                            CarrierConfigManager.KEY_SHOW_ROAMING_INDICATOR_BOOL);
+        } catch (Exception ignored) {
+            // CarrierConfigLoader might not be available yet.
+            // Once it's available, configs will be updated through the listener.
+        }
+        mPhone.getServiceStateTracker()
+                .registerForServiceStateChanged(this, EVENT_SERVICE_STATE_CHANGED, null);
+        mPhone.getContext().getSystemService(CarrierConfigManager.class)
+                .registerCarrierConfigChangeListener(Runnable::run,
+                        (slotIndex, subId, carrierId, specificCarrierId) -> {
+                            if (slotIndex == mPhone.getPhoneId()) {
+                                obtainMessage(EVENT_CARRIER_CONFIG_CHANGED).sendToTarget();
+                            }
+                        });
         mTelephonyDisplayInfo = new TelephonyDisplayInfo(
                 TelephonyManager.NETWORK_TYPE_UNKNOWN,
-                TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NONE);
+                TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NONE,
+                false);
         mNetworkTypeController = new NetworkTypeController(phone, this);
+        // EVENT_UPDATE will transition from DefaultState to the current state
+        // and update the TelephonyDisplayInfo based on the current state.
         mNetworkTypeController.sendMessage(NetworkTypeController.EVENT_UPDATE);
-
-        mServiceState = mPhone.getServiceStateTracker().getServiceState();
-        post(() -> {
-            mPhone.getServiceStateTracker()
-                    .registerForServiceStateChanged(this, EVENT_SERVICE_STATE_CHANGED, null);
-            updateTelephonyDisplayInfo();
-        });
     }
 
     /**
      * @return the current TelephonyDisplayInfo
      */
-    public @NonNull TelephonyDisplayInfo getTelephonyDisplayInfo() {
+    @NonNull public TelephonyDisplayInfo getTelephonyDisplayInfo() {
         return mTelephonyDisplayInfo;
     }
 
@@ -105,7 +129,7 @@
         TelephonyDisplayInfo newDisplayInfo = new TelephonyDisplayInfo(
                 mNetworkTypeController.getDataNetworkType(),
                 mNetworkTypeController.getOverrideNetworkType(),
-                mServiceState.getRoaming());
+                isRoaming());
         if (!newDisplayInfo.equals(mTelephonyDisplayInfo)) {
             logl("TelephonyDisplayInfo changed from " + mTelephonyDisplayInfo + " to "
                     + newDisplayInfo);
@@ -117,6 +141,24 @@
     }
 
     /**
+     * Determine the roaming status for icon display only.
+     * If this is {@code true}, the roaming indicator will be shown, and if this is {@code false},
+     * the roaming indicator will not be shown.
+     * To get the actual roaming status, use {@link ServiceState#getRoaming()} instead.
+     *
+     * @return Whether the device is considered roaming for display purposes.
+     */
+    private boolean isRoaming() {
+        boolean roaming = mServiceState.getRoaming();
+        if (roaming && mFeatureFlags.hideRoamingIcon()
+                && !mConfigs.getBoolean(CarrierConfigManager.KEY_SHOW_ROAMING_INDICATOR_BOOL)) {
+            logl("Override roaming for display due to carrier configs.");
+            roaming = false;
+        }
+        return roaming;
+    }
+
+    /**
      * Validate the display info and trigger anomaly report if needed.
      *
      * @param displayInfo The display info to validate.
@@ -175,6 +217,13 @@
                 log("ServiceState updated, isRoaming=" + mServiceState.getRoaming());
                 updateTelephonyDisplayInfo();
                 break;
+            case EVENT_CARRIER_CONFIG_CHANGED:
+                mConfigs = mPhone.getContext().getSystemService(CarrierConfigManager.class)
+                        .getConfigForSubId(mPhone.getSubId(),
+                                CarrierConfigManager.KEY_SHOW_ROAMING_INDICATOR_BOOL);
+                log("Carrier configs updated: " + mConfigs);
+                updateTelephonyDisplayInfo();
+                break;
         }
     }
 
diff --git a/src/java/com/android/internal/telephony/GsmCdmaPhone.java b/src/java/com/android/internal/telephony/GsmCdmaPhone.java
index ecf8e5f..6f30fb5 100644
--- a/src/java/com/android/internal/telephony/GsmCdmaPhone.java
+++ b/src/java/com/android/internal/telephony/GsmCdmaPhone.java
@@ -359,12 +359,13 @@
                 .inject(EmergencyNumberTracker.class.getName()).makeEmergencyNumberTracker(
                         this, this.mCi);
         mDeviceStateMonitor = mTelephonyComponentFactory.inject(DeviceStateMonitor.class.getName())
-                .makeDeviceStateMonitor(this);
+                .makeDeviceStateMonitor(this, mFeatureFlags);
 
         // DisplayInfoController creates an OverrideNetworkTypeController, which uses
         // DeviceStateMonitor so needs to be crated after it is instantiated.
         mDisplayInfoController = mTelephonyComponentFactory.inject(
-                DisplayInfoController.class.getName()).makeDisplayInfoController(this);
+                DisplayInfoController.class.getName())
+                .makeDisplayInfoController(this, featureFlags);
 
         mDataNetworkController = mTelephonyComponentFactory.inject(
                 DataNetworkController.class.getName())
@@ -463,7 +464,7 @@
         mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, LOG_TAG);
         mIccSmsInterfaceManager = mTelephonyComponentFactory
                 .inject(IccSmsInterfaceManager.class.getName())
-                .makeIccSmsInterfaceManager(this);
+                .makeIccSmsInterfaceManager(this, mFeatureFlags);
 
         mCi.registerForAvailable(this, EVENT_RADIO_AVAILABLE, null);
         mCi.registerForOffOrNotAvailable(this, EVENT_RADIO_OFF_OR_NOT_AVAILABLE, null);
diff --git a/src/java/com/android/internal/telephony/IccSmsInterfaceManager.java b/src/java/com/android/internal/telephony/IccSmsInterfaceManager.java
index 2d77631..7c1670c 100644
--- a/src/java/com/android/internal/telephony/IccSmsInterfaceManager.java
+++ b/src/java/com/android/internal/telephony/IccSmsInterfaceManager.java
@@ -21,6 +21,7 @@
 import static android.telephony.SmsManager.STATUS_ON_ICC_UNREAD;
 
 import android.Manifest;
+import android.annotation.NonNull;
 import android.annotation.RequiresPermission;
 import android.app.AppOpsManager;
 import android.app.PendingIntent;
@@ -47,6 +48,7 @@
 
 import com.android.internal.annotations.VisibleForTesting;
 import com.android.internal.telephony.cdma.CdmaSmsBroadcastConfigInfo;
+import com.android.internal.telephony.flags.FeatureFlags;
 import com.android.internal.telephony.gsm.SmsBroadcastConfigInfo;
 import com.android.internal.telephony.uicc.IccConstants;
 import com.android.internal.telephony.uicc.IccFileHandler;
@@ -155,11 +157,11 @@
         }
     };
 
-    protected IccSmsInterfaceManager(Phone phone) {
+    protected IccSmsInterfaceManager(Phone phone, @NonNull FeatureFlags featureFlags) {
         this(phone, phone.getContext(),
                 (AppOpsManager) phone.getContext().getSystemService(Context.APP_OPS_SERVICE),
                 new SmsDispatchersController(
-                        phone, phone.mSmsStorageMonitor, phone.mSmsUsageMonitor),
+                        phone, phone.mSmsStorageMonitor, phone.mSmsUsageMonitor, featureFlags),
                 new SmsPermissions(phone, phone.getContext(),
                         (AppOpsManager) phone.getContext().getSystemService(
                                 Context.APP_OPS_SERVICE)));
diff --git a/src/java/com/android/internal/telephony/ImsSmsDispatcher.java b/src/java/com/android/internal/telephony/ImsSmsDispatcher.java
index 67dbdb5..4e4d55d 100644
--- a/src/java/com/android/internal/telephony/ImsSmsDispatcher.java
+++ b/src/java/com/android/internal/telephony/ImsSmsDispatcher.java
@@ -202,10 +202,13 @@
                         tracker.onSent(mContext);
                         mTrackers.remove(token);
                         mPhone.notifySmsSent(tracker.mDestAddress);
+                        mSmsDispatchersController.notifySmsSentToEmergencyStateTracker(
+                                tracker.mDestAddress, tracker.mMessageId);
                         break;
                     case ImsSmsImplBase.SEND_STATUS_ERROR:
                         tracker.onFailed(mContext, reason, networkReasonCode);
                         mTrackers.remove(token);
+                        notifySmsSentFailedToEmergencyStateTracker(tracker);
                         break;
                     case ImsSmsImplBase.SEND_STATUS_ERROR_RETRY:
                         int maxRetryCountOverIms = getMaxRetryCountOverIms();
@@ -224,6 +227,7 @@
                         } else {
                             tracker.onFailed(mContext, reason, networkReasonCode);
                             mTrackers.remove(token);
+                            notifySmsSentFailedToEmergencyStateTracker(tracker);
                         }
                         break;
                     case ImsSmsImplBase.SEND_STATUS_ERROR_FALLBACK:
diff --git a/src/java/com/android/internal/telephony/MockModem.java b/src/java/com/android/internal/telephony/MockModem.java
index 83417c5..a20e748 100644
--- a/src/java/com/android/internal/telephony/MockModem.java
+++ b/src/java/com/android/internal/telephony/MockModem.java
@@ -21,7 +21,6 @@
 import static android.telephony.TelephonyManager.HAL_SERVICE_MESSAGING;
 import static android.telephony.TelephonyManager.HAL_SERVICE_MODEM;
 import static android.telephony.TelephonyManager.HAL_SERVICE_NETWORK;
-import static android.telephony.TelephonyManager.HAL_SERVICE_SATELLITE;
 import static android.telephony.TelephonyManager.HAL_SERVICE_SIM;
 import static android.telephony.TelephonyManager.HAL_SERVICE_VOICE;
 
@@ -45,8 +44,6 @@
     private static final String BIND_IRADIOVOICE = "android.telephony.mockmodem.iradiovoice";
     private static final String BIND_IRADIOIMS = "android.telephony.mockmodem.iradioims";
     private static final String BIND_IRADIOCONFIG = "android.telephony.mockmodem.iradioconfig";
-    private static final String BIND_IRADIOSATELLITE =
-            "android.telephony.mockmodem.iradiosatellite";
     private static final String PHONE_ID = "phone_id";
 
     private static final byte DEFAULT_PHONE_ID = 0x00;
@@ -68,7 +65,6 @@
     private IBinder mVoiceBinder;
     private IBinder mImsBinder;
     private IBinder mConfigBinder;
-    private IBinder mSatelliteBinder;
     private ServiceConnection mModemServiceConnection;
     private ServiceConnection mSimServiceConnection;
     private ServiceConnection mMessagingServiceConnection;
@@ -77,7 +73,6 @@
     private ServiceConnection mVoiceServiceConnection;
     private ServiceConnection mImsServiceConnection;
     private ServiceConnection mConfigServiceConnection;
-    private ServiceConnection mSatelliteServiceConnection;
 
     private byte mPhoneId;
     private String mTag;
@@ -120,8 +115,6 @@
                 mVoiceBinder = binder;
             } else if (mService == HAL_SERVICE_IMS) {
                 mImsBinder = binder;
-            } else if (mService == HAL_SERVICE_SATELLITE) {
-                mSatelliteBinder = binder;
             } else if (mService == RADIOCONFIG_SERVICE) {
                 mConfigBinder = binder;
             }
@@ -145,8 +138,6 @@
                 mVoiceBinder = null;
             } else if (mService == HAL_SERVICE_IMS) {
                 mImsBinder = null;
-            } else if (mService == HAL_SERVICE_SATELLITE) {
-                mSatelliteBinder = null;
             } else if (mService == RADIOCONFIG_SERVICE) {
                 mConfigBinder = null;
             }
@@ -188,8 +179,6 @@
                 return mVoiceBinder;
             case HAL_SERVICE_IMS:
                 return mImsBinder;
-            case HAL_SERVICE_SATELLITE:
-                return mSatelliteBinder;
             case RADIOCONFIG_SERVICE:
                 return mConfigBinder;
             default:
@@ -317,20 +306,6 @@
             } else {
                 Rlog.d(TAG, "IRadio Ims is bound");
             }
-        } else if (service == HAL_SERVICE_SATELLITE) {
-            if (mSatelliteBinder == null) {
-                mSatelliteServiceConnection = new MockModemConnection(HAL_SERVICE_SATELLITE);
-
-                boolean status =
-                        bindModuleToMockModemService(
-                                mPhoneId, BIND_IRADIOSATELLITE, mSatelliteServiceConnection);
-                if (!status) {
-                    Rlog.d(TAG, "IRadio Satellite bind fail");
-                    mSatelliteServiceConnection = null;
-                }
-            } else {
-                Rlog.d(TAG, "IRadio Satellite is bound");
-            }
         }
     }
 
@@ -393,13 +368,6 @@
                 mImsBinder = null;
                 Rlog.d(TAG, "unbind IRadio Ims");
             }
-        } else if (service == HAL_SERVICE_SATELLITE) {
-            if (mSatelliteServiceConnection != null) {
-                mContext.unbindService(mSatelliteServiceConnection);
-                mSatelliteServiceConnection = null;
-                mSatelliteBinder = null;
-                Rlog.d(TAG, "unbind IRadio Satellite");
-            }
         }
     }
 
@@ -423,8 +391,6 @@
                 return "voice";
             case HAL_SERVICE_IMS:
                 return "ims";
-            case HAL_SERVICE_SATELLITE:
-                return "satellite";
             case RADIOCONFIG_SERVICE:
                 return "config";
             default:
diff --git a/src/java/com/android/internal/telephony/Phone.java b/src/java/com/android/internal/telephony/Phone.java
index f4f756f..50cf844 100644
--- a/src/java/com/android/internal/telephony/Phone.java
+++ b/src/java/com/android/internal/telephony/Phone.java
@@ -72,7 +72,6 @@
 import android.telephony.ims.RegistrationManager;
 import android.telephony.ims.feature.MmTelFeature;
 import android.telephony.ims.stub.ImsRegistrationImplBase;
-import android.telephony.satellite.SatelliteDatagram;
 import android.text.TextUtils;
 import android.util.LocalLog;
 import android.util.Log;
@@ -728,6 +727,28 @@
     }
 
     /**
+     * Determines if the carrier prefers to use an in service sim for a normal routed emergency
+     * call.
+     * @return true when carrier config
+     * {@link CarrierConfigManager#KEY_PREFER_IN_SERVICE_SIM_FOR_NORMAL_ROUTED_EMERGENCY_CALLS_BOOL}
+     * is true.
+     */
+    public boolean shouldPreferInServiceSimForNormalRoutedEmergencyCall() {
+        CarrierConfigManager configManager = (CarrierConfigManager)
+                getContext().getSystemService(Context.CARRIER_CONFIG_SERVICE);
+        PersistableBundle b = configManager.getConfigForSubId(getSubId(), CarrierConfigManager
+                .KEY_PREFER_IN_SERVICE_SIM_FOR_NORMAL_ROUTED_EMERGENCY_CALLS_BOOL);
+        if (b != null) {
+            return b.getBoolean(CarrierConfigManager
+                            .KEY_PREFER_IN_SERVICE_SIM_FOR_NORMAL_ROUTED_EMERGENCY_CALLS_BOOL,
+                    false);
+        } else {
+            // Default value set in CarrierConfigManager
+            return false;
+        }
+    }
+
+    /**
      * When overridden the derived class needs to call
      * super.handleMessage(msg) so this method has a
      * a chance to process the message.
@@ -5175,279 +5196,6 @@
     }
 
     /**
-     * Start receiving satellite position updates.
-     * This can be called by the pointing UI when the user starts pointing to the satellite.
-     * Modem should continue to report the pointing input as the device or satellite moves.
-     *
-     * @param result The Message to send to result of the operation to.
-     **/
-    public void startSatellitePositionUpdates(Message result) {
-        mCi.startSendingSatellitePointingInfo(result);
-    }
-
-    /**
-     * Stop receiving satellite position updates.
-     * This can be called by the pointing UI when the user stops pointing to the satellite.
-     *
-     * @param result The Message to send to result of the operation to.
-     **/
-    public void stopSatellitePositionUpdates(Message result) {
-        mCi.stopSendingSatellitePointingInfo(result);
-    }
-
-    /**
-     * Get maximum number of characters per text message on satellite.
-     * @param result The Message to send the result of the operation to.
-     */
-    public void getMaxCharactersPerSatelliteTextMessage(Message result) {
-        mCi.getMaxCharactersPerSatelliteTextMessage(result);
-    }
-
-    /**
-     * Power on or off the satellite modem.
-     * @param result The Message to send the result of the operation to.
-     * @param powerOn {@code true} to power on the satellite modem and {@code false} to power off.
-     */
-    public void setSatellitePower(Message result, boolean powerOn) {
-        mCi.setSatellitePower(result, powerOn);
-    }
-
-    /**
-     * Check whether the satellite modem is powered on.
-     * @param result The Message to send the result of the operation to.
-     */
-    public void isSatellitePowerOn(Message result) {
-        mCi.getSatellitePowerState(result);
-    }
-
-    /**
-     * Check whether the satellite service is supported on the device.
-     * @param result The Message to send the result of the operation to.
-     */
-    public void isSatelliteSupported(Message result) {
-        mCi.isSatelliteSupported(result);
-    }
-
-    /**
-     * Check whether the satellite modem is provisioned.
-     * @param result The Message to send the result of the operation to.
-     */
-    public void isSatelliteProvisioned(Message result) {
-        mCi.getSatelliteProvisionState(result);
-    }
-
-    /**
-     * Get the satellite capabilities.
-     * @param result The Message to send the result of the operation to.
-     */
-    public void getSatelliteCapabilities(Message result) {
-        mCi.getSatelliteCapabilities(result);
-    }
-
-    /**
-     * Registers for pointing info changed from satellite modem.
-     *
-     * @param h Handler for notification message.
-     * @param what User-defined message code.
-     * @param obj User object.
-     */
-    public void registerForSatellitePositionInfoChanged(@NonNull Handler h,
-            int what, @Nullable Object obj) {
-        //TODO: Rename CommandsInterface and other modules when updating HAL APIs.
-        mCi.registerForSatellitePointingInfoChanged(h, what, obj);
-    }
-
-    /**
-     * Unregisters for pointing info changed from satellite modem.
-     *
-     * @param h Handler to be removed from the registrant list.
-     */
-    public void unregisterForSatellitePositionInfoChanged(@NonNull Handler h) {
-        //TODO: Rename CommandsInterface and other modules when updating HAL APIs.
-        mCi.unregisterForSatellitePointingInfoChanged(h);
-    }
-
-    /**
-     * Registers for datagrams delivered events from satellite modem.
-     *
-     * @param h Handler for notification message.
-     * @param what User-defined message code.
-     * @param obj User object.
-     */
-    public void registerForSatelliteDatagramsDelivered(@NonNull Handler h,
-            int what, @Nullable Object obj) {
-        //TODO: Remove.
-        mCi.registerForSatelliteMessagesTransferComplete(h, what, obj);
-    }
-
-    /**
-     * Unregisters for datagrams delivered events from satellite modem.
-     *
-     * @param h Handler to be removed from the registrant list.
-     */
-    public void unregisterForSatelliteDatagramsDelivered(@NonNull Handler h) {
-        //TODO: Remove.
-        mCi.unregisterForSatelliteMessagesTransferComplete(h);
-    }
-
-    /**
-     * Provision the subscription with a satellite provider.
-     * This is needed to register the device/subscription if the provider allows dynamic
-     * registration.
-     *
-     * @param result Callback message to receive the result.
-     * @param token The token of the device/subscription to be provisioned.
-     */
-    public void provisionSatelliteService(Message result, String token) {
-        // TODO: update parameters in HAL
-        // mCi.provisionSatelliteService(result, token);
-    }
-
-    /**
-     * Deprovision the device/subscription with a satellite provider.
-     * This is needed to unregister the device/subscription if the provider allows dynamic
-     * registration.
-     * If provisioning is in progress for the given SIM, cancel the request.
-     * If there is no request in progress, deprovision the given SIM.
-     *
-     * @param result Callback message to receive the result.
-     * @param token The token of the device/subscription to be deprovisioned.
-     */
-    public void deprovisionSatelliteService(Message result, String token) {
-        //TODO (b/266126070): add implementation.
-    }
-
-    /**
-     * Register for a satellite provision state changed event.
-     *
-     * @param h Handler for notification message.
-     * @param what User-defined message code.
-     * @param obj User object.
-     */
-    public void registerForSatelliteProvisionStateChanged(Handler h, int what, Object obj) {
-        mCi.registerForSatelliteProvisionStateChanged(h, what, obj);
-    }
-
-    /**
-     * Unregister for a satellite provision state changed event.
-     *
-     * @param h Handler to be removed from the registrant list.
-     */
-    public void unregisterForSatelliteProvisionStateChanged(Handler h) {
-        mCi.unregisterForSatelliteProvisionStateChanged(h);
-    }
-
-    /**
-     * Get the list of provisioned satellite features.
-     *
-     * @param result Callback message to receive the result.
-     */
-    public void getProvisionedSatelliteFeatures(Message result) {
-        //TODO (b/266126070): add implementation.
-    }
-
-    /**
-     * Registers for satellite state changed from satellite modem.
-     *
-     * @param h Handler for notification message.
-     * @param what User-defined message code.
-     * @param obj User object.
-     */
-    public void registerForSatelliteModemStateChanged(@NonNull Handler h, int what,
-            @Nullable Object obj) {
-        mCi.registerForSatelliteModeChanged(h, what, obj);
-    }
-
-    /**
-     * Unregisters for satellite state changed from satellite modem.
-     *
-     * @param h Handler to be removed from registrant list.
-     */
-    public void unregisterForSatelliteModemStateChanged(@NonNull Handler h) {
-        mCi.unregisterForSatelliteModeChanged(h);
-    }
-
-    /**
-     * Registers for pending datagram count info from satellite modem.
-     *
-     * @param h Handler for notification message.
-     * @param what User-defined message code.
-     * @param obj User object.
-     */
-    public void registerForPendingDatagramCount(@NonNull Handler h, int what,
-            @Nullable Object obj) {
-        mCi.registerForPendingSatelliteMessageCount(h, what, obj);
-    }
-
-    /**
-     * Unregisters for pending datagram count info from satellite modem.
-     *
-     * @param h Handler to be removed from registrant list.
-     */
-    public void unregisterForPendingDatagramCount(@NonNull Handler h) {
-        mCi.unregisterForPendingSatelliteMessageCount(h);
-    }
-
-    /**
-     * Register to receive incoming datagrams over satellite.
-     *
-     * @param h Handler for notification message.
-     * @param what User-defined message code.
-     * @param obj User object.
-     */
-    public void registerForSatelliteDatagramsReceived(@NonNull Handler h, int what,
-            @Nullable Object obj) {
-        // TODO: rename
-        mCi.registerForNewSatelliteMessages(h, what, obj);
-    }
-
-    /**
-     * Unregister to stop receiving incoming datagrams over satellite.
-     *
-     * @param h Handler to be removed from registrant list.
-     */
-    public void unregisterForSatelliteDatagramsReceived(@NonNull Handler h) {
-        // TODO: rename
-        mCi.unregisterForNewSatelliteMessages(h);
-    }
-
-    /**
-     * Poll pending datagrams over satellite.
-     * @param result The Message to send the result of the operation to.
-     */
-    public void pollPendingSatelliteDatagrams(Message result) {
-        //mCi.pollPendingSatelliteDatagrams(result);
-    }
-
-    /**
-     * Send datagram over satellite.
-     * @param result The Message to send the result of the operation to.
-     * @param datagram Datagram to send over satellite.
-     * @param needFullScreenPointingUI this is used to indicate pointingUI app to open in
-     *                                 full screen mode.
-     */
-    public void sendSatelliteDatagram(Message result, SatelliteDatagram datagram,
-            boolean needFullScreenPointingUI) {
-        //mCi.sendSatelliteDatagram(result, datagram);
-    }
-
-    /**
-     * Check whether satellite communication is allowed for the current location.
-     * @param result The Message to send the result of the operation to.
-     */
-    public void isSatelliteCommunicationAllowedForCurrentLocation(Message result) {
-        mCi.isSatelliteCommunicationAllowedForCurrentLocation(result);
-    }
-
-    /**
-     * Get the time after which the satellite will be visible.
-     * @param result The Message to send the result of the operation to.
-     */
-    public void requestTimeForNextSatelliteVisibility(Message result) {
-        mCi.getTimeForNextSatelliteVisibility(result);
-    }
-
-    /**
      * Start callback mode
      * @param type for callback mode entry.
      */
diff --git a/src/java/com/android/internal/telephony/RIL.java b/src/java/com/android/internal/telephony/RIL.java
index 3c8c5f3..7e8bfe8 100644
--- a/src/java/com/android/internal/telephony/RIL.java
+++ b/src/java/com/android/internal/telephony/RIL.java
@@ -22,7 +22,6 @@
 import static android.telephony.TelephonyManager.HAL_SERVICE_MODEM;
 import static android.telephony.TelephonyManager.HAL_SERVICE_NETWORK;
 import static android.telephony.TelephonyManager.HAL_SERVICE_RADIO;
-import static android.telephony.TelephonyManager.HAL_SERVICE_SATELLITE;
 import static android.telephony.TelephonyManager.HAL_SERVICE_SIM;
 import static android.telephony.TelephonyManager.HAL_SERVICE_VOICE;
 
@@ -207,7 +206,7 @@
 
     public static final int MIN_SERVICE_IDX = HAL_SERVICE_RADIO;
 
-    public static final int MAX_SERVICE_IDX = HAL_SERVICE_SATELLITE;
+    public static final int MAX_SERVICE_IDX = HAL_SERVICE_IMS;
 
     /**
      * An array of sets that records if services are disabled in the HAL for a specific phone ID
@@ -242,8 +241,6 @@
     private ModemIndication mModemIndication;
     private NetworkResponse mNetworkResponse;
     private NetworkIndication mNetworkIndication;
-    private SatelliteResponse mSatelliteResponse;
-    private SatelliteIndication mSatelliteIndication;
     private SimResponse mSimResponse;
     private SimIndication mSimIndication;
     private VoiceResponse mVoiceResponse;
@@ -682,7 +679,7 @@
     /**
      * Returns a {@link RadioDataProxy}, {@link RadioMessagingProxy}, {@link RadioModemProxy},
      * {@link RadioNetworkProxy}, {@link RadioSimProxy}, {@link RadioVoiceProxy},
-     * {@link RadioImsProxy}, {@link RadioSatelliteProxy}, or null if the service is not available.
+     * {@link RadioImsProxy}, or null if the service is not available.
      */
     @NonNull
     public <T extends RadioServiceProxy> T getRadioServiceProxy(Class<T> serviceClass) {
@@ -707,9 +704,6 @@
         if (serviceClass == RadioImsProxy.class) {
             return (T) getRadioServiceProxy(HAL_SERVICE_IMS);
         }
-        if (serviceClass == RadioSatelliteProxy.class) {
-            return (T) getRadioServiceProxy(HAL_SERVICE_SATELLITE);
-        }
         riljLoge("getRadioServiceProxy: unrecognized " + serviceClass);
         return null;
     }
@@ -847,21 +841,6 @@
                                             .asInterface(binder)));
                         }
                         break;
-                    case HAL_SERVICE_SATELLITE:
-                        if (mMockModem == null) {
-                            binder = ServiceManager.waitForDeclaredService(
-                                    android.hardware.radio.satellite.IRadioSatellite.DESCRIPTOR
-                                            + "/" + HIDL_SERVICE_NAME[mPhoneId]);
-                        } else {
-                            binder = mMockModem.getServiceBinder(HAL_SERVICE_SATELLITE);
-                        }
-                        if (binder != null) {
-                            mHalVersion.put(service, ((RadioSatelliteProxy) serviceProxy).setAidl(
-                                    mHalVersion.get(service),
-                                    android.hardware.radio.satellite.IRadioSatellite.Stub
-                                            .asInterface(binder)));
-                        }
-                        break;
                 }
 
                 if (serviceProxy.isEmpty()
@@ -947,12 +926,6 @@
                                 ((RadioImsProxy) serviceProxy).getAidl().setResponseFunctions(
                                         mImsResponse, mImsIndication);
                                 break;
-                            case HAL_SERVICE_SATELLITE:
-                                mDeathRecipients.get(service).linkToDeath(
-                                        ((RadioSatelliteProxy) serviceProxy).getAidl().asBinder());
-                                ((RadioSatelliteProxy) serviceProxy).getAidl().setResponseFunctions(
-                                        mSatelliteResponse, mSatelliteIndication);
-                                break;
                         }
                     } else {
                         if (mHalVersion.get(service).greaterOrEqual(RADIO_HAL_VERSION_2_0)) {
@@ -1061,8 +1034,6 @@
         mModemIndication = new ModemIndication(this);
         mNetworkResponse = new NetworkResponse(this);
         mNetworkIndication = new NetworkIndication(this);
-        mSatelliteResponse = new SatelliteResponse(this);
-        mSatelliteIndication = new SatelliteIndication(this);
         mSimResponse = new SimResponse(this);
         mSimIndication = new SimIndication(this);
         mVoiceResponse = new VoiceResponse(this);
@@ -1079,9 +1050,9 @@
                     }
                 } catch (SecurityException ex) {
                     /* TODO(b/211920208): instead of the following workaround (guessing if
-                    * we're in a test based on proxies being populated), mock ServiceManager
-                    * to not throw SecurityException and return correct value based on what
-                    * HAL we're testing. */
+                     * we're in a test based on proxies being populated), mock ServiceManager
+                     * to not throw SecurityException and return correct value based on what
+                     * HAL we're testing. */
                     if (proxies == null) throw ex;
                 }
                 mDeathRecipients.put(service, new BinderServiceDeathRecipient(service));
@@ -1097,7 +1068,6 @@
             mServiceProxies.put(HAL_SERVICE_SIM, new RadioSimProxy());
             mServiceProxies.put(HAL_SERVICE_VOICE, new RadioVoiceProxy());
             mServiceProxies.put(HAL_SERVICE_IMS, new RadioImsProxy());
-            mServiceProxies.put(HAL_SERVICE_SATELLITE, new RadioSatelliteProxy());
         } else {
             mServiceProxies = proxies;
         }
@@ -1180,9 +1150,6 @@
             case HAL_SERVICE_IMS:
                 serviceName = android.hardware.radio.ims.IRadioIms.DESCRIPTOR;
                 break;
-            case HAL_SERVICE_SATELLITE:
-                serviceName = android.hardware.radio.satellite.IRadioSatellite.DESCRIPTOR;
-                break;
         }
 
         if (!serviceName.equals("")
@@ -1270,8 +1237,6 @@
             service = HAL_SERVICE_VOICE;
         } else if (proxy instanceof RadioImsProxy) {
             service = HAL_SERVICE_IMS;
-        } else if (proxy instanceof RadioSatelliteProxy) {
-            service = HAL_SERVICE_SATELLITE;
         }
 
         if (mHalVersion.get(service).less(version)) {
@@ -5113,442 +5078,6 @@
         });
     }
 
-    /**
-     * Get feature capabilities supported by satellite.
-     *
-     * @param result Message that will be sent back to the requester
-     */
-    @Override
-    public void getSatelliteCapabilities(Message result) {
-        RadioSatelliteProxy satelliteProxy = getRadioServiceProxy(RadioSatelliteProxy.class);
-        if (!canMakeRequest("getSatelliteCapabilities", satelliteProxy, result,
-                RADIO_HAL_VERSION_2_0)) {
-            return;
-        }
-
-        RILRequest rr = obtainRequest(RIL_REQUEST_GET_SATELLITE_CAPABILITIES, result,
-                mRILDefaultWorkSource);
-
-        if (RILJ_LOGD) {
-            // Do not log function arg for privacy
-            riljLog(rr.serialString() + "> " + RILUtils.requestToString(rr.mRequest));
-        }
-
-        radioServiceInvokeHelper(HAL_SERVICE_SATELLITE, rr, "getSatelliteCapabilities", () -> {
-            satelliteProxy.getCapabilities(rr.mSerial);
-        });
-    }
-
-    /**
-     * Turn satellite modem on/off.
-     *
-     * @param result Message that will be sent back to the requester
-     * @param on True for turning on.
-     *           False for turning off.
-     */
-    @Override
-    public void setSatellitePower(Message result, boolean on) {
-        RadioSatelliteProxy satelliteProxy = getRadioServiceProxy(RadioSatelliteProxy.class);
-        if (!canMakeRequest("setSatellitePower", satelliteProxy, result, RADIO_HAL_VERSION_2_0)) {
-            return;
-        }
-
-        RILRequest rr = obtainRequest(RIL_REQUEST_SET_SATELLITE_POWER, result,
-                mRILDefaultWorkSource);
-
-        if (RILJ_LOGD) {
-            // Do not log function arg for privacy
-            riljLog(rr.serialString() + "> " + RILUtils.requestToString(rr.mRequest));
-        }
-
-        radioServiceInvokeHelper(HAL_SERVICE_SATELLITE, rr, "setSatellitePower", () -> {
-            satelliteProxy.setPower(rr.mSerial, on);
-        });
-    }
-
-    /**
-     * Get satellite modem state.
-     *
-     * @param result Message that will be sent back to the requester
-     */
-    @Override
-    public void getSatellitePowerState(Message result) {
-        RadioSatelliteProxy satelliteProxy = getRadioServiceProxy(RadioSatelliteProxy.class);
-        if (!canMakeRequest("getSatellitePowerState", satelliteProxy, result,
-                RADIO_HAL_VERSION_2_0)) {
-            return;
-        }
-
-        RILRequest rr = obtainRequest(RIL_REQUEST_GET_SATELLITE_POWER, result,
-                mRILDefaultWorkSource);
-
-        if (RILJ_LOGD) {
-            // Do not log function arg for privacy
-            riljLog(rr.serialString() + "> " + RILUtils.requestToString(rr.mRequest));
-        }
-
-        radioServiceInvokeHelper(HAL_SERVICE_SATELLITE, rr, "getSatellitePowerState", () -> {
-            satelliteProxy.getPowerState(rr.mSerial);
-        });
-    }
-
-    /**
-     * Get satellite provision state.
-     *
-     * @param result Message that will be sent back to the requester
-     */
-    @Override
-    public void getSatelliteProvisionState(Message result) {
-        // Satellite HAL APIs are not supported before Android V.
-        RadioSatelliteProxy satelliteProxy = getRadioServiceProxy(RadioSatelliteProxy.class);
-        if (!canMakeRequest("getSatelliteProvisionState", satelliteProxy, result,
-                RADIO_HAL_VERSION_2_0)) {
-            return;
-        }
-    }
-
-    /**
-     * Provision the subscription with a satellite provider. This is needed to register the
-     * subscription if the provider allows dynamic registration.
-     *
-     * @param result Message that will be sent back to the requester.
-     * @param imei IMEI of the SIM associated with the satellite modem.
-     * @param msisdn MSISDN of the SIM associated with the satellite modem.
-     * @param imsi IMSI of the SIM associated with the satellite modem.
-     * @param features List of features to be provisioned.
-     */
-    @Override
-    public void provisionSatelliteService(
-            Message result, String imei, String msisdn, String imsi, int[] features) {
-        RadioSatelliteProxy satelliteProxy = getRadioServiceProxy(RadioSatelliteProxy.class);
-        if (!canMakeRequest("provisionSatelliteService", satelliteProxy, result,
-                RADIO_HAL_VERSION_2_0)) {
-            return;
-        }
-
-        RILRequest rr = obtainRequest(RIL_REQUEST_PROVISION_SATELLITE_SERVICE, result,
-                mRILDefaultWorkSource);
-
-        if (RILJ_LOGD) {
-            // Do not log function arg for privacy
-            riljLog(rr.serialString() + "> " + RILUtils.requestToString(rr.mRequest));
-        }
-
-        radioServiceInvokeHelper(HAL_SERVICE_SATELLITE, rr, "provisionSatelliteService", () -> {
-            satelliteProxy.provisionService(rr.mSerial, imei, msisdn, imsi, features);
-        });
-    }
-
-    /**
-     * Add contacts that are allowed to be used for satellite communication. This is applicable for
-     * incoming messages as well.
-     *
-     * @param result Message that will be sent back to the requester.
-     * @param contacts List of allowed contacts to be added.
-     */
-    @Override
-    public void addAllowedSatelliteContacts(Message result, String[] contacts) {
-        RadioSatelliteProxy satelliteProxy = getRadioServiceProxy(RadioSatelliteProxy.class);
-        if (!canMakeRequest("addAllowedSatelliteContacts", satelliteProxy, result,
-                RADIO_HAL_VERSION_2_0)) {
-            return;
-        }
-
-        RILRequest rr = obtainRequest(RIL_REQUEST_ADD_ALLOWED_SATELLITE_CONTACTS, result,
-                mRILDefaultWorkSource);
-
-        if (RILJ_LOGD) {
-            // Do not log function arg for privacy
-            riljLog(rr.serialString() + "> " + RILUtils.requestToString(rr.mRequest));
-        }
-
-        radioServiceInvokeHelper(HAL_SERVICE_SATELLITE, rr, "addAllowedSatelliteContacts", () -> {
-            satelliteProxy.addAllowedSatelliteContacts(rr.mSerial, contacts);
-        });
-    }
-
-    /**
-     * Remove contacts that are allowed to be used for satellite communication. This is applicable
-     * for incoming messages as well.
-     *
-     * @param result Message that will be sent back to the requester.
-     * @param contacts List of allowed contacts to be removed.
-     */
-    @Override
-    public void removeAllowedSatelliteContacts(Message result, String[] contacts) {
-        RadioSatelliteProxy satelliteProxy = getRadioServiceProxy(RadioSatelliteProxy.class);
-        if (!canMakeRequest("removeAllowedSatelliteContacts", satelliteProxy, result,
-                RADIO_HAL_VERSION_2_0)) {
-            return;
-        }
-
-        RILRequest rr = obtainRequest(RIL_REQUEST_REMOVE_ALLOWED_SATELLITE_CONTACTS, result,
-                mRILDefaultWorkSource);
-
-        if (RILJ_LOGD) {
-            // Do not log function arg for privacy
-            riljLog(rr.serialString() + "> " + RILUtils.requestToString(rr.mRequest));
-        }
-
-        radioServiceInvokeHelper(HAL_SERVICE_SATELLITE, rr, "removeAllowedSatelliteContacts",
-                () -> {
-                    satelliteProxy.removeAllowedSatelliteContacts(rr.mSerial, contacts);
-                });
-    }
-
-    /**
-     * Send text messages.
-     *
-     * @param result Message that will be sent back to the requester.
-     * @param messages List of messages in text format to be sent.
-     * @param destination The recipient of the message.
-     * @param latitude The current latitude of the device.
-     * @param longitude The current longitude of the device.
-     */
-    @Override
-    public void sendSatelliteMessages(Message result, String[] messages, String destination,
-            double latitude, double longitude) {
-        RadioSatelliteProxy satelliteProxy = getRadioServiceProxy(RadioSatelliteProxy.class);
-        if (!canMakeRequest("sendSatelliteMessages", satelliteProxy, result,
-                RADIO_HAL_VERSION_2_0)) {
-            return;
-        }
-
-        RILRequest rr = obtainRequest(RIL_REQUEST_SEND_SATELLITE_MESSAGES, result,
-                mRILDefaultWorkSource);
-
-        if (RILJ_LOGD) {
-            // Do not log function arg for privacy
-            riljLog(rr.serialString() + "> " + RILUtils.requestToString(rr.mRequest));
-        }
-
-        radioServiceInvokeHelper(HAL_SERVICE_SATELLITE, rr, "sendSatelliteMessages", () -> {
-            satelliteProxy.sendMessages(rr.mSerial, messages, destination, latitude, longitude);
-        });
-    }
-
-    /**
-     * Get pending messages.
-     *
-     * @param result Message that will be sent back to the requester.
-     */
-    @Override
-    public void getPendingSatelliteMessages(Message result) {
-        RadioSatelliteProxy satelliteProxy = getRadioServiceProxy(RadioSatelliteProxy.class);
-        if (!canMakeRequest("getPendingSatelliteMessages", satelliteProxy, result,
-                RADIO_HAL_VERSION_2_0)) {
-            return;
-        }
-
-        RILRequest rr = obtainRequest(RIL_REQUEST_GET_PENDING_SATELLITE_MESSAGES, result,
-                mRILDefaultWorkSource);
-
-        if (RILJ_LOGD) {
-            // Do not log function arg for privacy
-            riljLog(rr.serialString() + "> " + RILUtils.requestToString(rr.mRequest));
-        }
-
-        radioServiceInvokeHelper(HAL_SERVICE_SATELLITE, rr, "getPendingSatelliteMessages", () -> {
-            satelliteProxy.getPendingMessages(rr.mSerial);
-        });
-    }
-
-    /**
-     * Get current satellite registration mode.
-     *
-     * @param result Message that will be sent back to the requester.
-     */
-    @Override
-    public void getSatelliteMode(Message result) {
-        RadioSatelliteProxy satelliteProxy = getRadioServiceProxy(RadioSatelliteProxy.class);
-        if (!canMakeRequest("getSatelliteMode", satelliteProxy, result, RADIO_HAL_VERSION_2_0)) {
-            return;
-        }
-
-        RILRequest rr = obtainRequest(RIL_REQUEST_GET_SATELLITE_MODE, result,
-                mRILDefaultWorkSource);
-
-        if (RILJ_LOGD) {
-            // Do not log function arg for privacy
-            riljLog(rr.serialString() + "> " + RILUtils.requestToString(rr.mRequest));
-        }
-
-        radioServiceInvokeHelper(HAL_SERVICE_SATELLITE, rr, "getSatelliteMode", () -> {
-            satelliteProxy.getSatelliteMode(rr.mSerial);
-        });
-    }
-
-    /**
-     * Set the filter for what type of indication framework want to receive from modem.
-     *
-     * @param result Message that will be sent back to the requester.
-     * @param filterBitmask The filter bitmask identifying what type of indication framework want to
-     *                         receive from modem.
-     */
-    @Override
-    public void setSatelliteIndicationFilter(Message result, int filterBitmask) {
-        RadioSatelliteProxy satelliteProxy = getRadioServiceProxy(RadioSatelliteProxy.class);
-        if (!canMakeRequest("setSatelliteIndicationFilter", satelliteProxy, result,
-                RADIO_HAL_VERSION_2_0)) {
-            return;
-        }
-
-        RILRequest rr = obtainRequest(RIL_REQUEST_SET_SATELLITE_INDICATION_FILTER, result,
-                mRILDefaultWorkSource);
-
-        if (RILJ_LOGD) {
-            // Do not log function arg for privacy
-            riljLog(rr.serialString() + "> " + RILUtils.requestToString(rr.mRequest));
-        }
-
-        radioServiceInvokeHelper(HAL_SERVICE_SATELLITE, rr, "setSatelliteIndicationFilter", () -> {
-            satelliteProxy.setIndicationFilter(rr.mSerial, filterBitmask);
-        });
-    }
-
-    /**
-     * Check whether satellite modem is supported by the device.
-     *
-     * @param result Message that will be sent back to the requester.
-     */
-    @Override
-    public void isSatelliteSupported(Message result) {
-        RadioSatelliteProxy satelliteProxy = getRadioServiceProxy(RadioSatelliteProxy.class);
-        if (!canMakeRequest("isSatelliteSupported", satelliteProxy, result,
-                RADIO_HAL_VERSION_2_0)) {
-            return;
-        }
-        /**
-         * TODO: when adding implementation of this method, we need to return successful result
-         * with satellite support set to false if radioSatelliteProxy.isEmpty() is true or
-         * mHalVersion.get(HAL_SERVICE_SATELLITE).greaterOrEqual(RADIO_HAL_VERSION_2_0) is false.
-         */
-    }
-
-    /**
-     * User started pointing to the satellite. Modem should continue to update the ponting input
-     * as user moves device.
-     *
-     * @param result Message that will be sent back to the requester.
-     */
-    @Override
-    public void startSendingSatellitePointingInfo(Message result) {
-        RadioSatelliteProxy satelliteProxy = getRadioServiceProxy(RadioSatelliteProxy.class);
-        if (!canMakeRequest("startSendingSatellitePointingInfo", satelliteProxy, result,
-                RADIO_HAL_VERSION_2_0)) {
-            return;
-        }
-
-        RILRequest rr = obtainRequest(RIL_REQUEST_START_SENDING_SATELLITE_POINTING_INFO, result,
-                mRILDefaultWorkSource);
-
-        if (RILJ_LOGD) {
-            // Do not log function arg for privacy
-            riljLog(rr.serialString() + "> " + RILUtils.requestToString(rr.mRequest));
-        }
-
-        radioServiceInvokeHelper(HAL_SERVICE_SATELLITE, rr, "startSendingSatellitePointingInfo",
-                () -> {
-                    satelliteProxy.startSendingSatellitePointingInfo(rr.mSerial);
-                });
-    }
-
-    /**
-     * Stop pointing to satellite indications.
-     *
-     * @param result Message that will be sent back to the requester.
-     */
-    @Override
-    public void stopSendingSatellitePointingInfo(Message result) {
-        RadioSatelliteProxy satelliteProxy = getRadioServiceProxy(RadioSatelliteProxy.class);
-        if (!canMakeRequest("stopSendingSatellitePointingInfo", satelliteProxy, result,
-                RADIO_HAL_VERSION_2_0)) {
-            return;
-        }
-
-        RILRequest rr = obtainRequest(RIL_REQUEST_STOP_SENDING_SATELLITE_POINTING_INFO, result,
-                mRILDefaultWorkSource);
-
-        if (RILJ_LOGD) {
-            // Do not log function arg for privacy
-            riljLog(rr.serialString() + "> " + RILUtils.requestToString(rr.mRequest));
-        }
-
-        radioServiceInvokeHelper(HAL_SERVICE_SATELLITE, rr, "stopSendingSatellitePointingInfo",
-                () -> {
-                    satelliteProxy.stopSendingSatellitePointingInfo(rr.mSerial);
-                });
-    }
-
-    /**
-     * Get max text limit for messaging per message.
-     *
-     * @param result Message that will be sent back to the requester.
-     */
-    @Override
-    public void getMaxCharactersPerSatelliteTextMessage(Message result) {
-        RadioSatelliteProxy satelliteProxy = getRadioServiceProxy(RadioSatelliteProxy.class);
-        if (!canMakeRequest("getMaxCharactersPerSatelliteTextMessage", satelliteProxy, result,
-                RADIO_HAL_VERSION_2_0)) {
-            return;
-        }
-
-        RILRequest rr = obtainRequest(RIL_REQUEST_GET_MAX_CHARACTERS_PER_SATELLITE_TEXT_MESSAGE,
-                result, mRILDefaultWorkSource);
-
-        if (RILJ_LOGD) {
-            // Do not log function arg for privacy
-            riljLog(rr.serialString() + "> " + RILUtils.requestToString(rr.mRequest));
-        }
-
-        radioServiceInvokeHelper(HAL_SERVICE_SATELLITE, rr,
-                "getMaxCharactersPerSatelliteTextMessage", () -> {
-                    satelliteProxy.getMaxCharactersPerTextMessage(rr.mSerial);
-                });
-    }
-
-    /**
-     * Get whether satellite communication is allowed for the current location
-     *
-     * @param result Message that will be sent back to the requester.
-     */
-    @Override
-    public void isSatelliteCommunicationAllowedForCurrentLocation(Message result) {
-        // TODO: link to HAL implementation
-        RadioSatelliteProxy satelliteProxy = getRadioServiceProxy(RadioSatelliteProxy.class);
-        if (!canMakeRequest("isSatelliteCommunicationAllowedForCurrentLocation", satelliteProxy,
-                result, RADIO_HAL_VERSION_2_0)) {
-            return;
-        }
-    }
-
-    /**
-     * Get time for next visibility of satellite.
-     *
-     * @param result Message that will be sent back to the requester.
-     */
-    @Override
-    public void getTimeForNextSatelliteVisibility(Message result) {
-        RadioSatelliteProxy satelliteProxy = getRadioServiceProxy(RadioSatelliteProxy.class);
-        if (!canMakeRequest("getTimeForNextSatelliteVisibility", satelliteProxy, result,
-                RADIO_HAL_VERSION_2_0)) {
-            return;
-        }
-
-        RILRequest rr = obtainRequest(RIL_REQUEST_GET_TIME_FOR_NEXT_SATELLITE_VISIBILITY, result,
-                mRILDefaultWorkSource);
-
-        if (RILJ_LOGD) {
-            // Do not log function arg for privacy
-            riljLog(rr.serialString() + "> " + RILUtils.requestToString(rr.mRequest));
-        }
-
-        radioServiceInvokeHelper(HAL_SERVICE_SATELLITE, rr, "getTimeForNextSatelliteVisibility",
-                () -> {
-                    satelliteProxy.getTimeForNextSatelliteVisibility(rr.mSerial);
-                });
-    }
-
     //***** Private Methods
     /**
      * This is a helper function to be called when an indication callback is called for any radio
@@ -5707,12 +5236,12 @@
         } else {
             switch (rr.mRequest) {
                 case RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND:
-                if (mTestingEmergencyCall.getAndSet(false)) {
-                    if (mEmergencyCallbackModeRegistrant != null) {
-                        riljLog("testing emergency call, notify ECM Registrants");
-                        mEmergencyCallbackModeRegistrant.notifyRegistrant();
+                    if (mTestingEmergencyCall.getAndSet(false)) {
+                        if (mEmergencyCallbackModeRegistrant != null) {
+                            riljLog("testing emergency call, notify ECM Registrants");
+                            mEmergencyCallbackModeRegistrant.notifyRegistrant();
+                        }
                     }
-                }
             }
         }
         return rr;
@@ -6341,7 +5870,6 @@
         pw.println(" " + mServiceProxies.get(HAL_SERVICE_SIM));
         pw.println(" " + mServiceProxies.get(HAL_SERVICE_VOICE));
         pw.println(" " + mServiceProxies.get(HAL_SERVICE_IMS));
-        pw.println(" " + mServiceProxies.get(HAL_SERVICE_SATELLITE));
         pw.println(" mWakeLock=" + mWakeLock);
         pw.println(" mWakeLockTimeout=" + mWakeLockTimeout);
         synchronized (mRequestList) {
@@ -6420,10 +5948,8 @@
                 return "VOICE";
             case HAL_SERVICE_IMS:
                 return "IMS";
-            case HAL_SERVICE_SATELLITE:
-                return "SATELLITE";
             default:
                 return "UNKNOWN:" + service;
         }
     }
-}
+}
\ No newline at end of file
diff --git a/src/java/com/android/internal/telephony/RILUtils.java b/src/java/com/android/internal/telephony/RILUtils.java
index d41b725..c2c29f8 100644
--- a/src/java/com/android/internal/telephony/RILUtils.java
+++ b/src/java/com/android/internal/telephony/RILUtils.java
@@ -25,7 +25,6 @@
 import static android.telephony.TelephonyManager.CAPABILITY_USES_ALLOWED_NETWORK_TYPES_BITMASK;
 
 import static com.android.internal.telephony.RILConstants.RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU;
-import static com.android.internal.telephony.RILConstants.RIL_REQUEST_ADD_ALLOWED_SATELLITE_CONTACTS;
 import static com.android.internal.telephony.RILConstants.RIL_REQUEST_ALLOCATE_PDU_SESSION_ID;
 import static com.android.internal.telephony.RILConstants.RIL_REQUEST_ALLOW_DATA;
 import static com.android.internal.telephony.RILConstants.RIL_REQUEST_ANSWER;
@@ -93,17 +92,12 @@
 import static com.android.internal.telephony.RILConstants.RIL_REQUEST_GET_IMEISV;
 import static com.android.internal.telephony.RILConstants.RIL_REQUEST_GET_IMSI;
 import static com.android.internal.telephony.RILConstants.RIL_REQUEST_GET_LOCATION_PRIVACY_SETTING;
-import static com.android.internal.telephony.RILConstants.RIL_REQUEST_GET_MAX_CHARACTERS_PER_SATELLITE_TEXT_MESSAGE;
 import static com.android.internal.telephony.RILConstants.RIL_REQUEST_GET_MODEM_STATUS;
 import static com.android.internal.telephony.RILConstants.RIL_REQUEST_GET_MUTE;
 import static com.android.internal.telephony.RILConstants.RIL_REQUEST_GET_NEIGHBORING_CELL_IDS;
-import static com.android.internal.telephony.RILConstants.RIL_REQUEST_GET_PENDING_SATELLITE_MESSAGES;
 import static com.android.internal.telephony.RILConstants.RIL_REQUEST_GET_PHONE_CAPABILITY;
 import static com.android.internal.telephony.RILConstants.RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE;
 import static com.android.internal.telephony.RILConstants.RIL_REQUEST_GET_RADIO_CAPABILITY;
-import static com.android.internal.telephony.RILConstants.RIL_REQUEST_GET_SATELLITE_CAPABILITIES;
-import static com.android.internal.telephony.RILConstants.RIL_REQUEST_GET_SATELLITE_MODE;
-import static com.android.internal.telephony.RILConstants.RIL_REQUEST_GET_SATELLITE_POWER;
 import static com.android.internal.telephony.RILConstants.RIL_REQUEST_GET_SIM_PHONEBOOK_CAPACITY;
 import static com.android.internal.telephony.RILConstants.RIL_REQUEST_GET_SIM_PHONEBOOK_RECORDS;
 import static com.android.internal.telephony.RILConstants.RIL_REQUEST_GET_SIM_STATUS;
@@ -111,7 +105,6 @@
 import static com.android.internal.telephony.RILConstants.RIL_REQUEST_GET_SLOT_STATUS;
 import static com.android.internal.telephony.RILConstants.RIL_REQUEST_GET_SMSC_ADDRESS;
 import static com.android.internal.telephony.RILConstants.RIL_REQUEST_GET_SYSTEM_SELECTION_CHANNELS;
-import static com.android.internal.telephony.RILConstants.RIL_REQUEST_GET_TIME_FOR_NEXT_SATELLITE_VISIBILITY;
 import static com.android.internal.telephony.RILConstants.RIL_REQUEST_GET_UICC_APPLICATIONS_ENABLEMENT;
 import static com.android.internal.telephony.RILConstants.RIL_REQUEST_GET_USAGE_SETTING;
 import static com.android.internal.telephony.RILConstants.RIL_REQUEST_GSM_BROADCAST_ACTIVATION;
@@ -136,7 +129,6 @@
 import static com.android.internal.telephony.RILConstants.RIL_REQUEST_OEM_HOOK_RAW;
 import static com.android.internal.telephony.RILConstants.RIL_REQUEST_OEM_HOOK_STRINGS;
 import static com.android.internal.telephony.RILConstants.RIL_REQUEST_OPERATOR;
-import static com.android.internal.telephony.RILConstants.RIL_REQUEST_PROVISION_SATELLITE_SERVICE;
 import static com.android.internal.telephony.RILConstants.RIL_REQUEST_PULL_LCEDATA;
 import static com.android.internal.telephony.RILConstants.RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE;
 import static com.android.internal.telephony.RILConstants.RIL_REQUEST_QUERY_AVAILABLE_NETWORKS;
@@ -148,14 +140,12 @@
 import static com.android.internal.telephony.RILConstants.RIL_REQUEST_QUERY_TTY_MODE;
 import static com.android.internal.telephony.RILConstants.RIL_REQUEST_RADIO_POWER;
 import static com.android.internal.telephony.RILConstants.RIL_REQUEST_RELEASE_PDU_SESSION_ID;
-import static com.android.internal.telephony.RILConstants.RIL_REQUEST_REMOVE_ALLOWED_SATELLITE_CONTACTS;
 import static com.android.internal.telephony.RILConstants.RIL_REQUEST_REPORT_SMS_MEMORY_STATUS;
 import static com.android.internal.telephony.RILConstants.RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING;
 import static com.android.internal.telephony.RILConstants.RIL_REQUEST_RESET_RADIO;
 import static com.android.internal.telephony.RILConstants.RIL_REQUEST_SCREEN_STATE;
 import static com.android.internal.telephony.RILConstants.RIL_REQUEST_SEND_ANBR_QUERY;
 import static com.android.internal.telephony.RILConstants.RIL_REQUEST_SEND_DEVICE_STATE;
-import static com.android.internal.telephony.RILConstants.RIL_REQUEST_SEND_SATELLITE_MESSAGES;
 import static com.android.internal.telephony.RILConstants.RIL_REQUEST_SEND_SMS;
 import static com.android.internal.telephony.RILConstants.RIL_REQUEST_SEND_SMS_EXPECT_MORE;
 import static com.android.internal.telephony.RILConstants.RIL_REQUEST_SEND_USSD;
@@ -186,8 +176,6 @@
 import static com.android.internal.telephony.RILConstants.RIL_REQUEST_SET_PREFERRED_DATA_MODEM;
 import static com.android.internal.telephony.RILConstants.RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE;
 import static com.android.internal.telephony.RILConstants.RIL_REQUEST_SET_RADIO_CAPABILITY;
-import static com.android.internal.telephony.RILConstants.RIL_REQUEST_SET_SATELLITE_INDICATION_FILTER;
-import static com.android.internal.telephony.RILConstants.RIL_REQUEST_SET_SATELLITE_POWER;
 import static com.android.internal.telephony.RILConstants.RIL_REQUEST_SET_SIGNAL_STRENGTH_REPORTING_CRITERIA;
 import static com.android.internal.telephony.RILConstants.RIL_REQUEST_SET_SIM_CARD_POWER;
 import static com.android.internal.telephony.RILConstants.RIL_REQUEST_SET_SMSC_ADDRESS;
@@ -213,7 +201,6 @@
 import static com.android.internal.telephony.RILConstants.RIL_REQUEST_START_KEEPALIVE;
 import static com.android.internal.telephony.RILConstants.RIL_REQUEST_START_LCE;
 import static com.android.internal.telephony.RILConstants.RIL_REQUEST_START_NETWORK_SCAN;
-import static com.android.internal.telephony.RILConstants.RIL_REQUEST_START_SENDING_SATELLITE_POINTING_INFO;
 import static com.android.internal.telephony.RILConstants.RIL_REQUEST_STK_GET_PROFILE;
 import static com.android.internal.telephony.RILConstants.RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM;
 import static com.android.internal.telephony.RILConstants.RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND;
@@ -224,7 +211,6 @@
 import static com.android.internal.telephony.RILConstants.RIL_REQUEST_STOP_KEEPALIVE;
 import static com.android.internal.telephony.RILConstants.RIL_REQUEST_STOP_LCE;
 import static com.android.internal.telephony.RILConstants.RIL_REQUEST_STOP_NETWORK_SCAN;
-import static com.android.internal.telephony.RILConstants.RIL_REQUEST_STOP_SENDING_SATELLITE_POINTING_INFO;
 import static com.android.internal.telephony.RILConstants.RIL_REQUEST_SWITCH_DUAL_SIM_CONFIG;
 import static com.android.internal.telephony.RILConstants.RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE;
 import static com.android.internal.telephony.RILConstants.RIL_REQUEST_TRIGGER_EMERGENCY_NETWORK_SCAN;
@@ -259,7 +245,6 @@
 import static com.android.internal.telephony.RILConstants.RIL_UNSOL_LCEDATA_RECV;
 import static com.android.internal.telephony.RILConstants.RIL_UNSOL_MODEM_RESTART;
 import static com.android.internal.telephony.RILConstants.RIL_UNSOL_NETWORK_SCAN_RESULT;
-import static com.android.internal.telephony.RILConstants.RIL_UNSOL_NEW_SATELLITE_MESSAGES;
 import static com.android.internal.telephony.RILConstants.RIL_UNSOL_NITZ_TIME_RECEIVED;
 import static com.android.internal.telephony.RILConstants.RIL_UNSOL_NOTIFY_ANBR;
 import static com.android.internal.telephony.RILConstants.RIL_UNSOL_OEM_HOOK_RAW;
@@ -267,7 +252,6 @@
 import static com.android.internal.telephony.RILConstants.RIL_UNSOL_ON_USSD;
 import static com.android.internal.telephony.RILConstants.RIL_UNSOL_ON_USSD_REQUEST;
 import static com.android.internal.telephony.RILConstants.RIL_UNSOL_PCO_DATA;
-import static com.android.internal.telephony.RILConstants.RIL_UNSOL_PENDING_SATELLITE_MESSAGE_COUNT;
 import static com.android.internal.telephony.RILConstants.RIL_UNSOL_PHYSICAL_CHANNEL_CONFIG;
 import static com.android.internal.telephony.RILConstants.RIL_UNSOL_RADIO_CAPABILITY;
 import static com.android.internal.telephony.RILConstants.RIL_UNSOL_REGISTRATION_FAILED;
@@ -287,11 +271,6 @@
 import static com.android.internal.telephony.RILConstants.RIL_UNSOL_RESTRICTED_STATE_CHANGED;
 import static com.android.internal.telephony.RILConstants.RIL_UNSOL_RIL_CONNECTED;
 import static com.android.internal.telephony.RILConstants.RIL_UNSOL_RINGBACK_TONE;
-import static com.android.internal.telephony.RILConstants.RIL_UNSOL_SATELLITE_MESSAGES_TRANSFER_COMPLETE;
-import static com.android.internal.telephony.RILConstants.RIL_UNSOL_SATELLITE_MODE_CHANGED;
-import static com.android.internal.telephony.RILConstants.RIL_UNSOL_SATELLITE_POINTING_INFO_CHANGED;
-import static com.android.internal.telephony.RILConstants.RIL_UNSOL_SATELLITE_PROVISION_STATE_CHANGED;
-import static com.android.internal.telephony.RILConstants.RIL_UNSOL_SATELLITE_RADIO_TECHNOLOGY_CHANGED;
 import static com.android.internal.telephony.RILConstants.RIL_UNSOL_SIGNAL_STRENGTH;
 import static com.android.internal.telephony.RILConstants.RIL_UNSOL_SIM_REFRESH;
 import static com.android.internal.telephony.RILConstants.RIL_UNSOL_SIM_SMS_STORAGE_FULL;
@@ -380,9 +359,6 @@
 import android.telephony.ims.feature.MmTelFeature;
 import android.telephony.ims.stub.ImsRegistrationImplBase;
 import android.telephony.ims.stub.ImsRegistrationImplBase.ImsDeregistrationReason;
-import android.telephony.satellite.PointingInfo;
-import android.telephony.satellite.SatelliteCapabilities;
-import android.telephony.satellite.SatelliteManager;
 import android.text.TextUtils;
 import android.util.ArraySet;
 import android.util.SparseArray;
@@ -980,8 +956,8 @@
      * @param dp Data profile
      * @return The converted DataProfileInfo
      */
-    public static android.hardware.radio.data.DataProfileInfo convertToHalDataProfile(@Nullable
-            DataProfile dp) {
+    public static android.hardware.radio.data.DataProfileInfo convertToHalDataProfile(
+            @Nullable DataProfile dp) {
         if (dp == null) return null;
         android.hardware.radio.data.DataProfileInfo dpi =
                 new android.hardware.radio.data.DataProfileInfo();
@@ -1007,8 +983,11 @@
         dpi.persistent = dp.isPersistent();
         dpi.preferred = dp.isPreferred();
         dpi.alwaysOn = false;
+        dpi.infrastructureBitmap = android.hardware.radio.data.DataProfileInfo
+                .INFRASTRUCTURE_CELLULAR;
         if (dp.getApnSetting() != null) {
             dpi.alwaysOn = dp.getApnSetting().isAlwaysOn();
+            dpi.infrastructureBitmap = dp.getApnSetting().getInfrastructureBitmask();
         }
         dpi.trafficDescriptor = convertToHalTrafficDescriptorAidl(dp.getTrafficDescriptor());
 
@@ -1046,6 +1025,7 @@
                 .setRoamingProtocol(dpi.roamingProtocol)
                 .setUser(dpi.user)
                 .setAlwaysOn(dpi.alwaysOn)
+                .setInfrastructureBitmask(dpi.infrastructureBitmap)
                 .build();
 
         TrafficDescriptor td;
@@ -3286,7 +3266,7 @@
             protocolType = result.type;
             ifname = result.ifname;
             laList = result.addresses.stream().map(la -> convertToLinkAddress(
-                    la.address, la.properties, la.deprecationTime, la.expirationTime))
+                            la.address, la.properties, la.deprecationTime, la.expirationTime))
                     .collect(Collectors.toList());
             dnses = result.dnses.toArray(new String[0]);
             gateways = result.gateways.toArray(new String[0]);
@@ -3304,7 +3284,7 @@
             protocolType = result.type;
             ifname = result.ifname;
             laList = result.addresses.stream().map(la -> convertToLinkAddress(
-                    la.address, la.properties, la.deprecationTime, la.expirationTime))
+                            la.address, la.properties, la.deprecationTime, la.expirationTime))
                     .collect(Collectors.toList());
             dnses = result.dnses.toArray(new String[0]);
             gateways = result.gateways.toArray(new String[0]);
@@ -3572,23 +3552,24 @@
     public static NetworkSlicingConfig convertHalSlicingConfig(
             android.hardware.radio.V1_6.SlicingConfig sc) {
         List<UrspRule> urspRules = sc.urspRules.stream().map(ur -> new UrspRule(ur.precedence,
-                ur.trafficDescriptors.stream()
-                        .map(td -> {
-                            try {
-                                return convertHalTrafficDescriptor(td);
-                            } catch (IllegalArgumentException e) {
-                                loge("convertHalSlicingConfig: Failed to convert traffic descriptor"
-                                        + ". e=" + e);
-                                return null;
-                            }
-                        })
-                        .filter(Objects::nonNull)
-                        .collect(Collectors.toList()),
-                ur.routeSelectionDescriptor.stream().map(rsd -> new RouteSelectionDescriptor(
-                        rsd.precedence, rsd.sessionType.value(), rsd.sscMode.value(),
-                        rsd.sliceInfo.stream().map(RILUtils::convertHalSliceInfo)
+                        ur.trafficDescriptors.stream()
+                                .map(td -> {
+                                    try {
+                                        return convertHalTrafficDescriptor(td);
+                                    } catch (IllegalArgumentException e) {
+                                        loge("convertHalSlicingConfig: Failed to convert traffic "
+                                                + "descriptor. e=" + e);
+                                        return null;
+                                    }
+                                })
+                                .filter(Objects::nonNull)
                                 .collect(Collectors.toList()),
-                        rsd.dnn)).collect(Collectors.toList())))
+                        ur.routeSelectionDescriptor.stream().map(
+                                rsd -> new RouteSelectionDescriptor(rsd.precedence,
+                                        rsd.sessionType.value(), rsd.sscMode.value(),
+                                        rsd.sliceInfo.stream().map(RILUtils::convertHalSliceInfo)
+                                                .collect(Collectors.toList()),
+                                        rsd.dnn)).collect(Collectors.toList())))
                 .collect(Collectors.toList());
         return new NetworkSlicingConfig(urspRules, sc.sliceInfo.stream()
                 .map(RILUtils::convertHalSliceInfo).collect(Collectors.toList()));
@@ -5145,34 +5126,6 @@
                 return "SET_LOCATION_PRIVACY_SETTING";
             case RIL_REQUEST_GET_LOCATION_PRIVACY_SETTING:
                 return "GET_LOCATION_PRIVACY_SETTING";
-            case RIL_REQUEST_GET_SATELLITE_CAPABILITIES:
-                return "GET_SATELLITE_CAPABILITIES";
-            case RIL_REQUEST_SET_SATELLITE_POWER:
-                return "SET_SATELLITE_POWER";
-            case RIL_REQUEST_GET_SATELLITE_POWER:
-                return "GET_SATELLITE_POWER";
-            case RIL_REQUEST_PROVISION_SATELLITE_SERVICE:
-                return "PROVISION_SATELLITE_SERVICE";
-            case RIL_REQUEST_ADD_ALLOWED_SATELLITE_CONTACTS:
-                return "ADD_ALLOWED_SATELLITE_CONTACTS";
-            case RIL_REQUEST_REMOVE_ALLOWED_SATELLITE_CONTACTS:
-                return "REMOVE_ALLOWED_SATELLITE_CONTACTS";
-            case RIL_REQUEST_SEND_SATELLITE_MESSAGES:
-                return "SEND_SATELLITE_MESSAGES";
-            case RIL_REQUEST_GET_PENDING_SATELLITE_MESSAGES:
-                return "GET_PENDING_SATELLITE_MESSAGES";
-            case RIL_REQUEST_GET_SATELLITE_MODE:
-                return "GET_SATELLITE_MODE";
-            case RIL_REQUEST_SET_SATELLITE_INDICATION_FILTER:
-                return "SET_SATELLITE_INDICATION_FILTER";
-            case RIL_REQUEST_START_SENDING_SATELLITE_POINTING_INFO:
-                return "START_SENDING_SATELLITE_POINTING_INFO";
-            case RIL_REQUEST_STOP_SENDING_SATELLITE_POINTING_INFO:
-                return "STOP_SENDING_SATELLITE_POINTING_INFO";
-            case RIL_REQUEST_GET_MAX_CHARACTERS_PER_SATELLITE_TEXT_MESSAGE:
-                return "GET_MAX_CHARACTERS_PER_SATELLITE_TEXT_MESSAGE";
-            case RIL_REQUEST_GET_TIME_FOR_NEXT_SATELLITE_VISIBILITY:
-                return "GET_TIME_FOR_NEXT_SATELLITE_VISIBILITY";
             default:
                 return "<unknown request " + request + ">";
         }
@@ -5295,20 +5248,6 @@
                 return "UNSOL_RESPONSE_SIM_PHONEBOOK_RECORDS_RECEIVED";
             case RIL_UNSOL_SLICING_CONFIG_CHANGED:
                 return "UNSOL_SLICING_CONFIG_CHANGED";
-            case RIL_UNSOL_PENDING_SATELLITE_MESSAGE_COUNT:
-                return "UNSOL_PENDING_SATELLITE_MESSAGE_COUNT";
-            case RIL_UNSOL_NEW_SATELLITE_MESSAGES:
-                return "UNSOL_NEW_SATELLITE_MESSAGES";
-            case RIL_UNSOL_SATELLITE_MESSAGES_TRANSFER_COMPLETE:
-                return "UNSOL_SATELLITE_MESSAGES_TRANSFER_COMPLETE";
-            case RIL_UNSOL_SATELLITE_POINTING_INFO_CHANGED:
-                return "UNSOL_SATELLITE_POINTING_INFO_CHANGED";
-            case RIL_UNSOL_SATELLITE_MODE_CHANGED:
-                return "UNSOL_SATELLITE_MODE_CHANGED";
-            case RIL_UNSOL_SATELLITE_RADIO_TECHNOLOGY_CHANGED:
-                return "UNSOL_SATELLITE_RADIO_TECHNOLOGY_CHANGED";
-            case RIL_UNSOL_SATELLITE_PROVISION_STATE_CHANGED:
-                return "UNSOL_SATELLITE_PROVISION_STATE_CHANGED";
             /* The follow unsols are not defined in RIL.h */
             case RIL_UNSOL_ICC_SLOT_STATUS:
                 return "UNSOL_ICC_SLOT_STATUS";
@@ -5324,12 +5263,12 @@
                 return "UNSOL_BARRING_INFO_CHANGED";
             case RIL_UNSOL_EMERGENCY_NETWORK_SCAN_RESULT:
                 return "UNSOL_EMERGENCY_NETWORK_SCAN_RESULT";
-            case RIL_UNSOL_TRIGGER_IMS_DEREGISTRATION:
-                return "UNSOL_TRIGGER_IMS_DEREGISTRATION";
             case RIL_UNSOL_CONNECTION_SETUP_FAILURE:
                 return "UNSOL_CONNECTION_SETUP_FAILURE";
             case RIL_UNSOL_NOTIFY_ANBR:
                 return "UNSOL_NOTIFY_ANBR";
+            case RIL_UNSOL_TRIGGER_IMS_DEREGISTRATION:
+                return "UNSOL_TRIGGER_IMS_DEREGISTRATION";
             default:
                 return "<unknown response " + response + ">";
         }
@@ -5446,7 +5385,7 @@
                 try {
                     val = o.getClass().getDeclaredMethod(getTagMethod).invoke(o);
                 } catch (NoSuchMethodException | IllegalAccessException
-                        | InvocationTargetException e) {
+                         | InvocationTargetException e) {
                     loge(e.toString());
                 }
                 if (val != null) {
@@ -5715,93 +5654,6 @@
     }
 
     /**
-     * Convert android.hardware.radio.satellite.SatelliteCapabilities to
-     * android.telephony.satellite.SatelliteCapabilities
-     */
-    public static SatelliteCapabilities convertHalSatelliteCapabilities(
-            android.hardware.radio.satellite.SatelliteCapabilities capabilities) {
-        Set<Integer> supportedRadioTechnologies = new HashSet<>();
-        if (capabilities.supportedRadioTechnologies != null
-                && capabilities.supportedRadioTechnologies.length > 0) {
-            for (int technology : capabilities.supportedRadioTechnologies) {
-                supportedRadioTechnologies.add(technology);
-            }
-        }
-        return new SatelliteCapabilities(supportedRadioTechnologies,
-                capabilities.needsPointingToSatellite, 0, null);
-    }
-
-    /**
-     * Convert from android.hardware.radio.satellite.PointingInfo to
-     * android.telephony.satellite.stub.PointingInfo
-     */
-    public static PointingInfo convertHalSatellitePointingInfo(
-            android.hardware.radio.satellite.PointingInfo pointingInfo) {
-        return new PointingInfo(pointingInfo.satelliteAzimuthDegrees,
-                pointingInfo.satelliteElevationDegrees);
-    }
-
-    /**
-     * Convert from android.telephony.satellite.stub.PointingInfo to
-     * android.hardware.radio.satellite.PointingInfo
-     */
-    public static android.hardware.radio.satellite.PointingInfo convertToHalSatellitePointingInfo(
-            PointingInfo pointingInfo) {
-        android.hardware.radio.satellite.PointingInfo halPointingInfo =
-                new android.hardware.radio.satellite.PointingInfo();
-        halPointingInfo.satelliteAzimuthDegrees = pointingInfo.getSatelliteAzimuthDegrees();
-        halPointingInfo.satelliteElevationDegrees = pointingInfo.getSatelliteElevationDegrees();
-        return halPointingInfo;
-    }
-
-    /**
-     * Convert satellite-related errors from CommandException.Error to
-     * SatelliteManager.SatelliteServiceResult.
-     * @param error The satellite error.
-     * @return The converted SatelliteServiceResult.
-     */
-    @SatelliteManager.SatelliteResult
-    public static int convertToSatelliteError(
-            CommandException.Error error) {
-        switch (error) {
-            case INTERNAL_ERR:
-                //fallthrough to SYSTEM_ERR
-            case MODEM_ERR:
-                //fallthrough to SYSTEM_ERR
-            case SYSTEM_ERR:
-                return SatelliteManager.SATELLITE_RESULT_MODEM_ERROR;
-            case INVALID_ARGUMENTS:
-                return SatelliteManager.SATELLITE_RESULT_INVALID_ARGUMENTS;
-            case INVALID_MODEM_STATE:
-                return SatelliteManager.SATELLITE_RESULT_INVALID_MODEM_STATE;
-            case RADIO_NOT_AVAILABLE:
-                return SatelliteManager.SATELLITE_RESULT_RADIO_NOT_AVAILABLE;
-            case REQUEST_NOT_SUPPORTED:
-                return SatelliteManager.SATELLITE_RESULT_REQUEST_NOT_SUPPORTED;
-            case NO_MEMORY:
-                //fallthrough to NO_RESOURCES
-            case NO_RESOURCES:
-                return SatelliteManager.SATELLITE_RESULT_NO_RESOURCES;
-            case NETWORK_ERR:
-                return SatelliteManager.SATELLITE_RESULT_NETWORK_ERROR;
-            case NETWORK_TIMEOUT:
-                return SatelliteManager.SATELLITE_RESULT_NETWORK_TIMEOUT;
-            case NO_NETWORK_FOUND:
-                //fallthrough to NO_SATELLITE_SIGNAL
-            case NO_SATELLITE_SIGNAL:
-                return SatelliteManager.SATELLITE_RESULT_NOT_REACHABLE;
-            case ABORTED:
-                return SatelliteManager.SATELLITE_RESULT_REQUEST_ABORTED;
-            case ACCESS_BARRED:
-                return SatelliteManager.SATELLITE_RESULT_ACCESS_BARRED;
-            case SUBSCRIBER_NOT_AUTHORIZED:
-                return SatelliteManager.SATELLITE_RESULT_NOT_AUTHORIZED;
-            default:
-                return SatelliteManager.SATELLITE_RESULT_ERROR;
-        }
-    }
-
-    /**
      * Converts the call state to HAL IMS call state.
      *
      * @param state The {@link Call.State}.
diff --git a/src/java/com/android/internal/telephony/RadioSatelliteProxy.java b/src/java/com/android/internal/telephony/RadioSatelliteProxy.java
deleted file mode 100644
index ec334b6..0000000
--- a/src/java/com/android/internal/telephony/RadioSatelliteProxy.java
+++ /dev/null
@@ -1,275 +0,0 @@
-/*
- * Copyright (C) 2022 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 com.android.internal.telephony;
-
-import android.os.RemoteException;
-import android.telephony.Rlog;
-
-/**
- * A holder for IRadioSatellite.
- * Use getAidl to get IRadioSatellite and call the AIDL implementations of the HAL APIs.
- */
-public class RadioSatelliteProxy extends RadioServiceProxy {
-    private static final String TAG = "RadioSatelliteProxy";
-    private volatile android.hardware.radio.satellite.IRadioSatellite mSatelliteProxy = null;
-
-    /**
-     * Sets IRadioSatellite as the AIDL implementation for RadioServiceProxy.
-     * @param halVersion Radio HAL version.
-     * @param satellite IRadioSatellite implementation.
-     *
-     * @return updated HAL version.
-     */
-    public HalVersion setAidl(HalVersion halVersion,
-            android.hardware.radio.satellite.IRadioSatellite satellite) {
-        HalVersion version = halVersion;
-        try {
-            version = RIL.getServiceHalVersion(satellite.getInterfaceVersion());
-        } catch (RemoteException e) {
-            Rlog.e(TAG, "setAidl: " + e);
-        }
-        mHalVersion = version;
-        mSatelliteProxy = satellite;
-        mIsAidl = true;
-
-        Rlog.d(TAG, "AIDL initialized mHalVersion=" + mHalVersion);
-        return mHalVersion;
-    }
-
-    /**
-     * Gets the AIDL implementation of RadioSatelliteProxy.
-     * @return IRadioSatellite implementation.
-     */
-    public android.hardware.radio.satellite.IRadioSatellite getAidl() {
-        return mSatelliteProxy;
-    }
-
-    /**
-     * Resets RadioSatelliteProxy.
-     */
-    @Override
-    public void clear() {
-        super.clear();
-        mSatelliteProxy = null;
-    }
-
-    /**
-     * Checks whether a IRadioSatellite implementation exists.
-     * @return true if there is neither a HIDL nor AIDL implementation.
-     */
-    @Override
-    public boolean isEmpty() {
-        return mRadioProxy == null && mSatelliteProxy == null;
-    }
-
-    /**
-     * Call IRadioSatellite#responseAcknowledgement
-     * @throws RemoteException Throws RemoteException when RadioSatellite service is not available.
-     */
-    @Override
-    public void responseAcknowledgement() throws RemoteException {
-        if (isEmpty()) return;
-        if (isAidl()) {
-            mSatelliteProxy.responseAcknowledgement();
-        }
-    }
-
-    /**
-     * Call IRadioSatellite#getCapabilities
-     * @param serial Serial number of request.
-     * @throws RemoteException Throws RemoteException when RadioSatellite service is not available.
-     */
-    public void getCapabilities(int serial) throws RemoteException {
-        if (isEmpty()) return;
-        if (isAidl()) {
-            mSatelliteProxy.getCapabilities(serial);
-        }
-    }
-
-    /**
-     * Call IRadioSatellite#setPower
-     * @param serial Serial number of request.
-     * @param on True for turning on.
-     *           False for turning off.
-     * @throws RemoteException Throws RemoteException when RadioSatellite service is not available.
-     */
-    public void setPower(int serial, boolean on) throws RemoteException {
-        if (isEmpty()) return;
-        if (isAidl()) {
-            mSatelliteProxy.setPower(serial, on);
-        }
-    }
-
-    /**
-     * Call IRadioSatellite#getPowerState
-     * @param serial Serial number of request.
-     * @throws RemoteException Throws RemoteException when RadioSatellite service is not available.
-     */
-    public void getPowerState(int serial) throws RemoteException {
-        if (isEmpty()) return;
-        if (isAidl()) {
-            mSatelliteProxy.getPowerState(serial);
-        }
-    }
-
-    /**
-     * Call IRadioSatellite#provisionService
-     * @param serial Serial number of request.
-     * @param imei IMEI of the SIM associated with the satellite modem.
-     * @param msisdn MSISDN of the SIM associated with the satellite modem.
-     * @param imsi IMSI of the SIM associated with the satellite modem.
-     * @param features List of features to be provisioned.
-     * @throws RemoteException Throws RemoteException when RadioSatellite service is not available.
-     */
-    public void provisionService(int serial, String imei, String msisdn, String imsi,
-            int[] features) throws RemoteException {
-        if (isEmpty()) return;
-        if (isAidl()) {
-            mSatelliteProxy.provisionService(serial, imei, msisdn, imsi, features);
-        }
-    }
-
-    /**
-     * Call IRadioSatellite#addAllowedSatelliteContacts
-     * @param serial Serial number of request.
-     * @param contacts List of allowed contacts to be added.
-     * @throws RemoteException Throws RemoteException when RadioSatellite service is not available.
-     */
-    public void addAllowedSatelliteContacts(int serial, String[] contacts) throws RemoteException {
-        if (isEmpty()) return;
-        if (isAidl()) {
-            mSatelliteProxy.addAllowedSatelliteContacts(serial, contacts);
-        }
-    }
-
-    /**
-     * Call IRadioSatellite#removeAllowedSatelliteContacts
-     * @param serial Serial number of request.
-     * @param contacts List of allowed contacts to be removed.
-     * @throws RemoteException Throws RemoteException when RadioSatellite service is not available.
-     */
-    public void removeAllowedSatelliteContacts(int serial, String[] contacts)
-            throws RemoteException {
-        if (isEmpty()) return;
-        if (isAidl()) {
-            mSatelliteProxy.removeAllowedSatelliteContacts(serial, contacts);
-        }
-    }
-
-    /**
-     * Call IRadioSatellite#sendMessages
-     * @param serial Serial number of request.
-     * @param messages List of messages in text format to be sent.
-     * @param destination The recipient of the message.
-     * @param latitude The current latitude of the device.
-     * @param longitude The current longitude of the device
-     * @throws RemoteException Throws RemoteException when RadioSatellite service is not available.
-     */
-    public void sendMessages(int serial, String[] messages, String destination, double latitude,
-            double longitude) throws RemoteException {
-        if (isEmpty()) return;
-        if (isAidl()) {
-            mSatelliteProxy.sendMessages(serial, messages, destination, latitude, longitude);
-        }
-    }
-
-    /**
-     * Call IRadioSatellite#getPendingMessages
-     * @param serial Serial number of request.
-     * @throws RemoteException Throws RemoteException when RadioSatellite service is not available.
-     */
-    public void getPendingMessages(int serial) throws RemoteException {
-        if (isEmpty()) return;
-        if (isAidl()) {
-            mSatelliteProxy.getPendingMessages(serial);
-        }
-    }
-
-    /**
-     * Call IRadioSatellite#getSatelliteMode
-     * @param serial Serial number of request.
-     * @throws RemoteException Throws RemoteException when RadioSatellite service is not available.
-     */
-    public void getSatelliteMode(int serial) throws RemoteException {
-        if (isEmpty()) return;
-        if (isAidl()) {
-            mSatelliteProxy.getSatelliteMode(serial);
-        }
-    }
-
-    /**
-     * Call IRadioSatellite#setIndicationFilter
-     * @param serial Serial number of request.
-     * @param filterBitmask The filter identifying what type of indication framework want to
-     *                         receive from modem.
-     * @throws RemoteException Throws RemoteException when RadioSatellite service is not available.
-     */
-    public void setIndicationFilter(int serial, int filterBitmask) throws RemoteException {
-        if (isEmpty()) return;
-        if (isAidl()) {
-            mSatelliteProxy.setIndicationFilter(serial, filterBitmask);
-        }
-    }
-
-    /**
-     * Call IRadioSatellite#startSendingSatellitePointingInfo
-     * @param serial Serial number of request.
-     * @throws RemoteException Throws RemoteException when RadioSatellite service is not available.
-     */
-    public void startSendingSatellitePointingInfo(int serial) throws RemoteException {
-        if (isEmpty()) return;
-        if (isAidl()) {
-            mSatelliteProxy.startSendingSatellitePointingInfo(serial);
-        }
-    }
-
-    /**
-     * Call IRadioSatellite#stopSendingSatellitePointingInfo
-     * @param serial Serial number of request.
-     * @throws RemoteException Throws RemoteException when RadioSatellite service is not available.
-     */
-    public void stopSendingSatellitePointingInfo(int serial) throws RemoteException {
-        if (isEmpty()) return;
-        if (isAidl()) {
-            mSatelliteProxy.stopSendingSatellitePointingInfo(serial);
-        }
-    }
-
-    /**
-     * Call IRadioSatellite#getMaxCharactersPerTextMessage
-     * @param serial Serial number of request.
-     * @throws RemoteException Throws RemoteException when RadioSatellite service is not available.
-     */
-    public void getMaxCharactersPerTextMessage(int serial) throws RemoteException {
-        if (isEmpty()) return;
-        if (isAidl()) {
-            mSatelliteProxy.getMaxCharactersPerTextMessage(serial);
-        }
-    }
-
-    /**
-     * Call IRadioSatellite#getTimeForNextSatelliteVisibility
-     * @param serial Serial number of request.
-     * @throws RemoteException Throws RemoteException when RadioSatellite service is not available.
-     */
-    public void getTimeForNextSatelliteVisibility(int serial) throws RemoteException {
-        if (isEmpty()) return;
-        if (isAidl()) {
-            mSatelliteProxy.getTimeForNextSatelliteVisibility(serial);
-        }
-    }
-}
diff --git a/src/java/com/android/internal/telephony/SMSDispatcher.java b/src/java/com/android/internal/telephony/SMSDispatcher.java
index 739ca8c..54c27c5 100644
--- a/src/java/com/android/internal/telephony/SMSDispatcher.java
+++ b/src/java/com/android/internal/telephony/SMSDispatcher.java
@@ -1010,6 +1010,16 @@
     protected abstract boolean shouldBlockSmsForEcbm();
 
     /**
+     * Notifies the {@link SmsDispatchersController} that sending MO SMS is failed.
+     *
+     * @param tracker holds the SMS message to be sent
+     */
+    protected void notifySmsSentFailedToEmergencyStateTracker(SmsTracker tracker) {
+        mSmsDispatchersController.notifySmsSentFailedToEmergencyStateTracker(
+                tracker.mDestAddress, tracker.mMessageId);
+    }
+
+    /**
      * Called when SMS send completes. Broadcasts a sentIntent on success.
      * On failure, either sets up retries or broadcasts a sentIntent with
      * the failure in the result code.
@@ -1041,6 +1051,8 @@
             }
             tracker.onSent(mContext);
             mPhone.notifySmsSent(tracker.mDestAddress);
+            mSmsDispatchersController.notifySmsSentToEmergencyStateTracker(
+                    tracker.mDestAddress, tracker.mMessageId);
 
             mPhone.getSmsStats().onOutgoingSms(
                     tracker.mImsRetry > 0 /* isOverIms */,
@@ -1091,6 +1103,7 @@
             // if sms over IMS is not supported on data and voice is not available...
             if (!isIms() && ss != ServiceState.STATE_IN_SERVICE) {
                 tracker.onFailed(mContext, getNotInServiceError(ss), NO_ERROR_CODE);
+                notifySmsSentFailedToEmergencyStateTracker(tracker);
                 mPhone.getSmsStats().onOutgoingSms(
                         tracker.mImsRetry > 0 /* isOverIms */,
                         SmsConstants.FORMAT_3GPP2.equals(getFormat()),
@@ -1151,6 +1164,7 @@
             } else {
                 int errorCode = (smsResponse != null) ? smsResponse.mErrorCode : NO_ERROR_CODE;
                 tracker.onFailed(mContext, error, errorCode);
+                notifySmsSentFailedToEmergencyStateTracker(tracker);
                 mPhone.getSmsStats().onOutgoingSms(
                         tracker.mImsRetry > 0 /* isOverIms */,
                         SmsConstants.FORMAT_3GPP2.equals(getFormat()),
@@ -2375,6 +2389,7 @@
             int errorCode) {
         for (SmsTracker tracker : trackers) {
             tracker.onFailed(mContext, error, errorCode);
+            notifySmsSentFailedToEmergencyStateTracker(tracker);
         }
         if (trackers.length > 0) {
             // This error occurs before the SMS is sent. Make an assumption if it would have
diff --git a/src/java/com/android/internal/telephony/SatelliteIndication.java b/src/java/com/android/internal/telephony/SatelliteIndication.java
deleted file mode 100644
index 2e561c3..0000000
--- a/src/java/com/android/internal/telephony/SatelliteIndication.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * Copyright (C) 2022 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 com.android.internal.telephony;
-
-import static android.telephony.TelephonyManager.HAL_SERVICE_SATELLITE;
-
-import static com.android.internal.telephony.RILConstants.RIL_UNSOL_NEW_SATELLITE_MESSAGES;
-import static com.android.internal.telephony.RILConstants.RIL_UNSOL_PENDING_SATELLITE_MESSAGE_COUNT;
-import static com.android.internal.telephony.RILConstants.RIL_UNSOL_SATELLITE_MESSAGES_TRANSFER_COMPLETE;
-import static com.android.internal.telephony.RILConstants.RIL_UNSOL_SATELLITE_MODE_CHANGED;
-import static com.android.internal.telephony.RILConstants.RIL_UNSOL_SATELLITE_POINTING_INFO_CHANGED;
-import static com.android.internal.telephony.RILConstants.RIL_UNSOL_SATELLITE_PROVISION_STATE_CHANGED;
-import static com.android.internal.telephony.RILConstants.RIL_UNSOL_SATELLITE_RADIO_TECHNOLOGY_CHANGED;
-
-import android.hardware.radio.satellite.IRadioSatelliteIndication;
-import android.os.AsyncResult;
-import android.telephony.satellite.SatelliteDatagram;
-import android.util.Pair;
-
-/**
- * Interface declaring unsolicited radio indications for Satellite APIs.
- */
-public class SatelliteIndication extends IRadioSatelliteIndication.Stub {
-    private final RIL mRil;
-
-    public SatelliteIndication(RIL ril) {
-        mRil = ril;
-    }
-
-    @Override
-    public String getInterfaceHash() {
-        return IRadioSatelliteIndication.HASH;
-    }
-
-    @Override
-    public int getInterfaceVersion() {
-        return IRadioSatelliteIndication.VERSION;
-    }
-
-    /**
-     * Indicates that satellite has pending messages for the device to be pulled.
-     *
-     * @param indicationType Type of radio indication
-     * @param count Number of pending messages.
-     */
-    public void onPendingMessageCount(int indicationType, int count) {
-        mRil.processIndication(HAL_SERVICE_SATELLITE, indicationType);
-
-        if (mRil.isLogOrTrace()) mRil.unsljLog(RIL_UNSOL_PENDING_SATELLITE_MESSAGE_COUNT);
-
-        if (mRil.mPendingSatelliteMessageCountRegistrants != null) {
-            mRil.mPendingSatelliteMessageCountRegistrants.notifyRegistrants(
-                    new AsyncResult(null, count, null));
-        }
-    }
-
-    /**
-     * Indicates new message received on device.
-     *
-     * @param indicationType Type of radio indication
-     * @param messages List of new messages received.
-     */
-    public void onNewMessages(int indicationType, String[] messages) {
-        mRil.processIndication(HAL_SERVICE_SATELLITE, indicationType);
-
-        if (mRil.isLogOrTrace()) mRil.unsljLog(RIL_UNSOL_NEW_SATELLITE_MESSAGES);
-
-        if (mRil.mNewSatelliteMessagesRegistrants != null) {
-            for (int i = 0; i < messages.length; i++) {
-                SatelliteDatagram datagram = new SatelliteDatagram(messages[i].getBytes());
-                mRil.mNewSatelliteMessagesRegistrants.notifyRegistrants(
-                        new AsyncResult(null, new Pair<>(datagram, messages.length - i - 1), null));
-            }
-        }
-    }
-
-    /**
-     * Confirms that ongoing message transfer is complete.
-     *
-     * @param indicationType Type of radio indication
-     * @param complete True mean the transfer is complete.
-     *                 False means the transfer is not complete.
-     */
-    public void onMessagesTransferComplete(int indicationType, boolean complete) {
-        mRil.processIndication(HAL_SERVICE_SATELLITE, indicationType);
-
-        if (mRil.isLogOrTrace()) mRil.unsljLog(RIL_UNSOL_SATELLITE_MESSAGES_TRANSFER_COMPLETE);
-
-        if (mRil.mSatelliteMessagesTransferCompleteRegistrants != null) {
-            mRil.mSatelliteMessagesTransferCompleteRegistrants.notifyRegistrants(
-                    new AsyncResult(null, complete, null));
-        }
-    }
-
-    /**
-     * Indicate that satellite Pointing input has changed.
-     *
-     * @param indicationType Type of radio indication
-     * @param pointingInfo The current pointing info.
-     */
-    public void onSatellitePointingInfoChanged(int indicationType,
-            android.hardware.radio.satellite.PointingInfo pointingInfo) {
-        mRil.processIndication(HAL_SERVICE_SATELLITE, indicationType);
-
-        if (mRil.isLogOrTrace()) mRil.unsljLog(RIL_UNSOL_SATELLITE_POINTING_INFO_CHANGED);
-
-        if (mRil.mSatellitePointingInfoChangedRegistrants != null) {
-            mRil.mSatellitePointingInfoChangedRegistrants.notifyRegistrants(
-                    new AsyncResult(
-                            null,
-                            RILUtils.convertHalSatellitePointingInfo(pointingInfo),
-                            null));
-        }
-    }
-
-    /**
-     * Indicate that satellite mode has changed.
-     *
-     * @param indicationType Type of radio indication
-     * @param mode The current mode of the satellite modem.
-     */
-    public void onSatelliteModeChanged(int indicationType, int mode) {
-        mRil.processIndication(HAL_SERVICE_SATELLITE, indicationType);
-
-        if (mRil.isLogOrTrace()) mRil.unsljLog(RIL_UNSOL_SATELLITE_MODE_CHANGED);
-
-        if (mRil.mSatelliteModeChangedRegistrants != null) {
-            mRil.mSatelliteModeChangedRegistrants.notifyRegistrants(
-                    new AsyncResult(null, mode, null));
-        }
-    }
-
-    /**
-     * Indicate that satellite radio technology has changed.
-     *
-     * @param indicationType Type of radio indication
-     * @param technology The current technology of the satellite modem.
-     */
-    public void onSatelliteRadioTechnologyChanged(int indicationType, int technology) {
-        mRil.processIndication(HAL_SERVICE_SATELLITE, indicationType);
-
-        if (mRil.isLogOrTrace()) mRil.unsljLog(RIL_UNSOL_SATELLITE_RADIO_TECHNOLOGY_CHANGED);
-
-        if (mRil.mSatelliteRadioTechnologyChangedRegistrants != null) {
-            mRil.mSatelliteRadioTechnologyChangedRegistrants.notifyRegistrants(
-                    new AsyncResult(null, technology, null));
-        }
-    }
-
-    /**
-     * Indicate that satellite provision state has changed.
-     *
-     * @param indicationType Type of radio indication
-     * @param provisioned True means the service is provisioned.
-     *                    False means the service is not provisioned.
-     * @param features List of Feature whose provision state has changed.
-     */
-    public void onProvisionStateChanged(int indicationType, boolean provisioned, int[] features) {
-        // TODO: remove features and update AsyncResult
-        mRil.processIndication(HAL_SERVICE_SATELLITE, indicationType);
-
-        if (mRil.isLogOrTrace()) mRil.unsljLog(RIL_UNSOL_SATELLITE_PROVISION_STATE_CHANGED);
-
-        if (mRil.mSatelliteProvisionStateChangedRegistrants != null) {
-            mRil.mSatelliteProvisionStateChangedRegistrants.notifyRegistrants(
-                    new AsyncResult(provisioned, null, null));
-        }
-    }
-}
diff --git a/src/java/com/android/internal/telephony/SatelliteResponse.java b/src/java/com/android/internal/telephony/SatelliteResponse.java
deleted file mode 100644
index 559691b..0000000
--- a/src/java/com/android/internal/telephony/SatelliteResponse.java
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- * Copyright (C) 2021 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 com.android.internal.telephony;
-
-import static android.telephony.TelephonyManager.HAL_SERVICE_SATELLITE;
-
-import android.hardware.radio.RadioError;
-import android.hardware.radio.RadioResponseInfo;
-import android.hardware.radio.satellite.IRadioSatelliteResponse;
-import android.telephony.satellite.SatelliteCapabilities;
-
-/**
- * Interface declaring response functions to solicited radio requests for Satellite APIs.
- */
-public class SatelliteResponse extends IRadioSatelliteResponse.Stub {
-    private final RIL mRil;
-
-    public SatelliteResponse(RIL ril) {
-        mRil = ril;
-    }
-
-    /**
-     * Acknowledge the receipt of radio request sent to the vendor. This must be sent only for
-     * radio request which take long time to respond.
-     * For more details, refer https://source.android.com/devices/tech/connect/ril.html
-     * @param serial Serial no. of the request whose acknowledgement is sent.
-     */
-    public void acknowledgeRequest(int serial) {
-        mRil.processRequestAck(serial);
-    }
-    /**
-     * Response of the request getCapabilities.
-     *
-     * @param responseInfo Response info struct containing serial no. and error
-     * @param capabilities List of capabilities that the satellite modem supports.
-     */
-    public void getCapabilitiesResponse(RadioResponseInfo responseInfo,
-            android.hardware.radio.satellite.SatelliteCapabilities capabilities) {
-        RILRequest rr = mRil.processResponse(HAL_SERVICE_SATELLITE, responseInfo);
-
-        if (rr != null) {
-            SatelliteCapabilities convertedSatelliteCapabilities =
-                    RILUtils.convertHalSatelliteCapabilities(capabilities);
-            if (responseInfo.error == RadioError.NONE) {
-                RadioResponse.sendMessageResponse(rr.mResult, convertedSatelliteCapabilities);
-            }
-            mRil.processResponseDone(rr, responseInfo, convertedSatelliteCapabilities);
-        }
-    }
-
-    /**
-     * Response of the request setPower.
-     *
-     * @param responseInfo Response info struct containing serial no. and error
-     */
-    public void setPowerResponse(RadioResponseInfo responseInfo) {
-        RadioResponse.responseVoid(HAL_SERVICE_SATELLITE, mRil, responseInfo);
-    }
-
-    /**
-     * Response of the request getPowerState.
-     *
-     * @param responseInfo Response info struct containing serial no. and error
-     * @param on True means the modem is ON.
-     *           False means the modem is OFF.
-     */
-    public void getPowerStateResponse(RadioResponseInfo responseInfo, boolean on) {
-        RadioResponse.responseInts(HAL_SERVICE_SATELLITE, mRil, responseInfo, on ? 1 : 0);
-    }
-
-    /**
-     * Response of the request provisionService.
-     *
-     * @param responseInfo Response info struct containing serial no. and error
-     * @param provisioned True means the service is provisioned.
-     *                    False means the service is not provisioned.
-     */
-    public void provisionServiceResponse(RadioResponseInfo responseInfo, boolean provisioned) {
-        RadioResponse.responseInts(HAL_SERVICE_SATELLITE, mRil, responseInfo, provisioned ? 1 : 0);
-    }
-
-    /**
-     * Response of the request addAllowedSatelliteContacts.
-     *
-     * @param responseInfo Response info struct containing serial no. and error
-     */
-    public void addAllowedSatelliteContactsResponse(RadioResponseInfo responseInfo) {
-        RadioResponse.responseVoid(HAL_SERVICE_SATELLITE, mRil, responseInfo);
-    }
-
-    /**
-     * Response of the request removeAllowedSatelliteContacts.
-     *
-     * @param responseInfo Response info struct containing serial no. and error
-     */
-    public void removeAllowedSatelliteContactsResponse(RadioResponseInfo responseInfo) {
-        RadioResponse.responseVoid(HAL_SERVICE_SATELLITE, mRil, responseInfo);
-    }
-
-    /**
-     * Response of the request sendMessages.
-     *
-     * @param responseInfo Response info struct containing serial no. and error
-     */
-    public void sendMessagesResponse(RadioResponseInfo responseInfo) {
-        RadioResponse.responseVoid(HAL_SERVICE_SATELLITE, mRil, responseInfo);
-    }
-
-    /**
-     * Response of the request getPendingMessages.
-     *
-     * @param responseInfo Response info struct containing serial no. and error
-     * @param messages List of pending messages received.
-     */
-    public void getPendingMessagesResponse(RadioResponseInfo responseInfo, String[] messages) {
-        RILRequest rr = mRil.processResponse(HAL_SERVICE_SATELLITE, responseInfo);
-
-        if (rr != null) {
-            if (responseInfo.error == RadioError.NONE) {
-                RadioResponse.sendMessageResponse(rr.mResult, messages);
-            }
-            mRil.processResponseDone(rr, responseInfo, messages);
-        }
-    }
-
-    /**
-     * Response of the request getSatelliteMode.
-     *
-     * @param responseInfo Response info struct containing serial no. and error
-     * @param mode Current Mode of the satellite modem.
-     * @param technology The current technology of the satellite modem.
-     */
-    public void getSatelliteModeResponse(RadioResponseInfo responseInfo, int mode, int technology) {
-        RILRequest rr = mRil.processResponse(HAL_SERVICE_SATELLITE, responseInfo);
-
-        if (rr != null) {
-            int[] ret = new int[]{mode, technology};
-            if (responseInfo.error == RadioError.NONE) {
-                RadioResponse.sendMessageResponse(rr.mResult, ret);
-            }
-            mRil.processResponseDone(rr, responseInfo, ret);
-        }
-    }
-
-    /**
-     * Response of the request setIndicationFilter.
-     *
-     * @param responseInfo Response info struct containing serial no. and error
-     */
-    public void setIndicationFilterResponse(RadioResponseInfo responseInfo) {
-        RadioResponse.responseVoid(HAL_SERVICE_SATELLITE, mRil, responseInfo);
-    }
-
-    /**
-     * Response of the request startSendingSatellitePointingInfo.
-     *
-     * @param responseInfo Response info struct containing serial no. and error
-     */
-    public void startSendingSatellitePointingInfoResponse(RadioResponseInfo responseInfo) {
-        RadioResponse.responseVoid(HAL_SERVICE_SATELLITE, mRil, responseInfo);
-    }
-
-    /**
-     * Response of the request stopSendingSatellitePointingInfo.
-     *
-     * @param responseInfo Response info struct containing serial no. and error
-     */
-    public void stopSendingSatellitePointingInfoResponse(RadioResponseInfo responseInfo) {
-        RadioResponse.responseVoid(HAL_SERVICE_SATELLITE, mRil, responseInfo);
-    }
-
-    /**
-     * Response of the request getMaxCharactersPerTextMessage.
-     *
-     * @param responseInfo Response info struct containing serial no. and error
-     * @param charLimit Maximum number of characters in a text message that can be sent.
-     */
-    public void getMaxCharactersPerTextMessageResponse(
-            RadioResponseInfo responseInfo, int charLimit) {
-        RadioResponse.responseInts(HAL_SERVICE_SATELLITE, mRil, responseInfo, charLimit);
-    }
-
-    /**
-     * Response of the request getTimeForNextSatelliteVisibility.
-     *
-     * @param responseInfo Response info struct containing serial no. and error
-     * @param timeInSeconds The duration in seconds after which the satellite will be visible.
-     */
-    public void getTimeForNextSatelliteVisibilityResponse(
-            RadioResponseInfo responseInfo, int timeInSeconds) {
-        RadioResponse.responseInts(HAL_SERVICE_SATELLITE, mRil, responseInfo, timeInSeconds);
-    }
-
-    @Override
-    public String getInterfaceHash() {
-        return IRadioSatelliteResponse.HASH;
-    }
-
-    @Override
-    public int getInterfaceVersion() {
-        return IRadioSatelliteResponse.VERSION;
-    }
-}
diff --git a/src/java/com/android/internal/telephony/SmsDispatchersController.java b/src/java/com/android/internal/telephony/SmsDispatchersController.java
index d2dfcac..8795840 100644
--- a/src/java/com/android/internal/telephony/SmsDispatchersController.java
+++ b/src/java/com/android/internal/telephony/SmsDispatchersController.java
@@ -45,16 +45,20 @@
 import android.telephony.SmsManager;
 import android.telephony.SmsMessage;
 import android.telephony.TelephonyManager;
+import android.telephony.emergency.EmergencyNumber;
 import android.text.TextUtils;
 
 import com.android.ims.ImsManager;
 import com.android.internal.annotations.VisibleForTesting;
+import com.android.internal.os.SomeArgs;
 import com.android.internal.telephony.cdma.CdmaInboundSmsHandler;
 import com.android.internal.telephony.cdma.CdmaSMSDispatcher;
 import com.android.internal.telephony.domainselection.DomainSelectionConnection;
 import com.android.internal.telephony.domainselection.DomainSelectionResolver;
 import com.android.internal.telephony.domainselection.EmergencySmsDomainSelectionConnection;
 import com.android.internal.telephony.domainselection.SmsDomainSelectionConnection;
+import com.android.internal.telephony.emergency.EmergencyStateTracker;
+import com.android.internal.telephony.flags.FeatureFlags;
 import com.android.internal.telephony.gsm.GsmInboundSmsHandler;
 import com.android.internal.telephony.gsm.GsmSMSDispatcher;
 import com.android.telephony.Rlog;
@@ -62,8 +66,10 @@
 import java.io.FileDescriptor;
 import java.io.PrintWriter;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.concurrent.CompletableFuture;
 
 /**
@@ -94,6 +100,15 @@
     /** InboundSmsHandler exited WaitingState */
     protected static final int EVENT_SMS_HANDLER_EXITING_WAITING_STATE = 17;
 
+    /** Called when SMS should be sent using AP domain selection. */
+    private static final int EVENT_SEND_SMS_USING_DOMAIN_SELECTION = 18;
+
+    /** Called when SMS is completely sent using AP domain selection regardless of the result. */
+    private static final int EVENT_SMS_SENT_COMPLETED_USING_DOMAIN_SELECTION = 19;
+
+    /** Called when AP domain selection is abnormally terminated. */
+    private static final int EVENT_DOMAIN_SELECTION_TERMINATED_ABNORMALLY = 20;
+
     /** Delete any partial message segments after being IN_SERVICE for 1 day. */
     private static final long PARTIAL_SEGMENT_WAIT_DURATION = (long) (60 * 60 * 1000) * 24;
     /** Constant for invalid time */
@@ -117,6 +132,7 @@
     private final SmsUsageMonitor mUsageMonitor;
     private final CommandsInterface mCi;
     private final Context mContext;
+    private final @NonNull FeatureFlags mFeatureFlags;
 
     /** true if IMS is registered and sms is supported, false otherwise.*/
     private boolean mIms = false;
@@ -183,7 +199,7 @@
             };
 
     /** Stores the sending SMS information for a pending request. */
-    private class PendingRequest {
+    private static class PendingRequest {
         public static final int TYPE_DATA = 1;
         public static final int TYPE_TEXT = 2;
         public static final int TYPE_MULTIPART_TEXT = 3;
@@ -310,13 +326,18 @@
 
         @Override
         public void onSelectionTerminated(@DisconnectCauses int cause) {
-            notifyDomainSelectionTerminated(this);
+            logd("onSelectionTerminated: emergency=" + mEmergency + ", cause=" + cause);
+            // This callback is invoked by another thread, so this operation is posted and handled
+            // through the execution flow of SmsDispatchersController.
+            SmsDispatchersController.this.sendMessage(
+                    obtainMessage(EVENT_DOMAIN_SELECTION_TERMINATED_ABNORMALLY, this));
         }
     }
 
     /** Manages the domain selection connections: MO SMS or emergency SMS. */
     private DomainSelectionConnectionHolder mDscHolder;
     private DomainSelectionConnectionHolder mEmergencyDscHolder;
+    private EmergencyStateTracker mEmergencyStateTracker;
 
     /**
      * Puts a delivery pending tracker to the map based on the format.
@@ -332,13 +353,13 @@
     }
 
     public SmsDispatchersController(Phone phone, SmsStorageMonitor storageMonitor,
-            SmsUsageMonitor usageMonitor) {
-        this(phone, storageMonitor, usageMonitor, phone.getLooper());
+            SmsUsageMonitor usageMonitor, @NonNull FeatureFlags featureFlags) {
+        this(phone, storageMonitor, usageMonitor, phone.getLooper(), featureFlags);
     }
 
     @VisibleForTesting
     public SmsDispatchersController(Phone phone, SmsStorageMonitor storageMonitor,
-            SmsUsageMonitor usageMonitor, Looper looper) {
+            SmsUsageMonitor usageMonitor, Looper looper, @NonNull FeatureFlags featureFlags) {
         super(looper);
 
         Rlog.d(TAG, "SmsDispatchersController created");
@@ -346,6 +367,7 @@
         mContext = phone.getContext();
         mUsageMonitor = usageMonitor;
         mCi = phone.mCi;
+        mFeatureFlags = featureFlags;
         mPhone = phone;
 
         // Create dispatchers, inbound SMS handlers and
@@ -447,7 +469,36 @@
                 mPhone.registerForServiceStateChanged(this, EVENT_SERVICE_STATE_CHANGED, null);
                 resetPartialSegmentWaitTimer();
                 break;
-
+            case EVENT_SEND_SMS_USING_DOMAIN_SELECTION: {
+                SomeArgs args = (SomeArgs) msg.obj;
+                DomainSelectionConnectionHolder holder =
+                        (DomainSelectionConnectionHolder) args.arg1;
+                PendingRequest request = (PendingRequest) args.arg2;
+                String logTag = (String) args.arg3;
+                try {
+                    handleSendSmsUsingDomainSelection(holder, request, logTag);
+                } finally {
+                    args.recycle();
+                }
+                break;
+            }
+            case EVENT_SMS_SENT_COMPLETED_USING_DOMAIN_SELECTION: {
+                SomeArgs args = (SomeArgs) msg.obj;
+                String destAddr = (String) args.arg1;
+                Long messageId = (Long) args.arg2;
+                Boolean success = (Boolean) args.arg3;
+                try {
+                    handleSmsSentCompletedUsingDomainSelection(destAddr, messageId, success);
+                } finally {
+                    args.recycle();
+                }
+                break;
+            }
+            case EVENT_DOMAIN_SELECTION_TERMINATED_ABNORMALLY: {
+                handleDomainSelectionTerminatedAbnormally(
+                        (DomainSelectionConnectionHolder) msg.obj);
+                break;
+            }
             default:
                 if (isCdmaMo()) {
                     mCdmaDispatcher.handleMessage(msg);
@@ -701,7 +752,7 @@
         boolean retryUsingImsService = false;
 
         if (!tracker.mUsesImsServiceForIms) {
-            if (mDomainSelectionResolverProxy.isDomainSelectionSupported()) {
+            if (isSmsDomainSelectionEnabled()) {
                 DomainSelectionConnectionHolder holder = getDomainSelectionConnection(false);
 
                 // If the DomainSelectionConnection is not available,
@@ -756,6 +807,8 @@
                 // should never come here...
                 Rlog.e(TAG, "sendRetrySms failed to re-encode per missing fields!");
                 tracker.onFailed(mContext, SmsManager.RESULT_SMS_SEND_RETRY_FAILED, NO_ERROR_CODE);
+                notifySmsSentFailedToEmergencyStateTracker(
+                        tracker.mDestAddress, tracker.mMessageId);
                 return;
             }
             String scAddr = (String) map.get("scAddr");
@@ -763,6 +816,8 @@
             if (destAddr == null) {
                 Rlog.e(TAG, "sendRetrySms failed due to null destAddr");
                 tracker.onFailed(mContext, SmsManager.RESULT_SMS_SEND_RETRY_FAILED, NO_ERROR_CODE);
+                notifySmsSentFailedToEmergencyStateTracker(
+                        tracker.mDestAddress, tracker.mMessageId);
                 return;
             }
 
@@ -803,6 +858,8 @@
                         + "scAddr: %s, "
                         + "destPort: %s", scAddr, map.get("destPort")));
                 tracker.onFailed(mContext, SmsManager.RESULT_SMS_SEND_RETRY_FAILED, NO_ERROR_CODE);
+                notifySmsSentFailedToEmergencyStateTracker(
+                        tracker.mDestAddress, tracker.mMessageId);
                 return;
             }
             // replace old smsc and pdu with newly encoded ones
@@ -889,6 +946,16 @@
     }
 
     /**
+     * Checks whether the SMS domain selection is enabled or not.
+     *
+     * @return {@code true} if the SMS domain selection is enabled, {@code false} otherwise.
+     */
+    private boolean isSmsDomainSelectionEnabled() {
+        return mFeatureFlags.smsDomainSelectionEnabled()
+                && mDomainSelectionResolverProxy.isDomainSelectionSupported();
+    }
+
+    /**
      * Determines whether or not to use CDMA format for MO SMS when the domain selection uses.
      * If the domain is {@link NetworkRegistrationInfo#DOMAIN_PS}, then format is based on
      * IMS SMS format, otherwise format is based on current phone type.
@@ -929,7 +996,6 @@
     private DomainSelectionConnectionHolder getDomainSelectionConnection(boolean emergency) {
         DomainSelectionConnectionHolder holder = getDomainSelectionConnectionHolder(emergency);
         DomainSelectionConnection connection = (holder != null) ? holder.getConnection() : null;
-        boolean created = false;
 
         if (connection == null) {
             connection = mDomainSelectionResolverProxy.getDomainSelectionConnection(
@@ -940,8 +1006,6 @@
                 // Use the legacy architecture.
                 return null;
             }
-
-            created = true;
         }
 
         if (holder == null) {
@@ -965,6 +1029,7 @@
      * @param holder The {@link DomainSelectionConnectionHolder} that contains the
      *               {@link DomainSelectionConnection} and its related information.
      */
+    @SuppressWarnings("FutureReturnValueIgnored")
     private void requestDomainSelection(@NonNull DomainSelectionConnectionHolder holder) {
         DomainSelectionService.SelectionAttributes attr =
                 new DomainSelectionService.SelectionAttributes.Builder(mPhone.getPhoneId(),
@@ -1001,16 +1066,14 @@
     }
 
     /**
-     * Sends a SMS after selecting the domain via the domain selection service.
+     * Requests the domain selection for MO SMS.
      *
      * @param holder The {@link DomainSelectionConnectionHolder} that contains the
      *               {@link DomainSelectionConnection} and its related information.
-     * @param request The {@link PendingRequest} that stores the SMS request
-     *                (data, text, multipart text) to be sent.
-     * @param logTag The log tag to display which method called this method.
+     * @param logTag The log string.
      */
-    private void sendSmsUsingDomainSelection(@NonNull DomainSelectionConnectionHolder holder,
-            @NonNull PendingRequest request, @NonNull String logTag) {
+    private void requestDomainSelection(@NonNull DomainSelectionConnectionHolder holder,
+            @NonNull PendingRequest request, String logTag) {
         boolean isDomainSelectionRequested = holder.isDomainSelectionRequested();
         // The domain selection is in progress so waits for the result of
         // the domain selection by adding this request to the pending list.
@@ -1025,6 +1088,120 @@
     }
 
     /**
+     * Handles an event for sending a SMS after selecting the domain via the domain selection
+     * service.
+     *
+     * @param holder The {@link DomainSelectionConnectionHolder} that contains the
+     *               {@link DomainSelectionConnection} and its related information.
+     * @param request The {@link PendingRequest} that stores the SMS request
+     *                (data, text, multipart text) to be sent.
+     * @param logTag The log tag to display which method called this method.
+     */
+    @SuppressWarnings("FutureReturnValueIgnored")
+    private void handleSendSmsUsingDomainSelection(@NonNull DomainSelectionConnectionHolder holder,
+            @NonNull PendingRequest request, @NonNull String logTag) {
+        if (holder.isEmergency()) {
+            if (mEmergencyStateTracker == null) {
+                mEmergencyStateTracker = EmergencyStateTracker.getInstance();
+            }
+
+            CompletableFuture<Integer> future = mEmergencyStateTracker.startEmergencySms(mPhone,
+                    String.valueOf(request.messageId),
+                    isTestEmergencyNumber(request.destAddr));
+            future.thenAccept((result) -> {
+                logi("startEmergencySms(" + logTag + "): messageId=" + request.messageId
+                        + ", result=" + result);
+                // An emergency SMS should be proceeded regardless of the result of the
+                // EmergencyStateTracker.
+                // So the domain selection request should be invoked without checking the result.
+                requestDomainSelection(holder, request, logTag);
+            });
+        } else {
+            requestDomainSelection(holder, request, logTag);
+        }
+    }
+
+    /**
+     * Sends a SMS after selecting the domain via the domain selection service.
+     *
+     * @param holder The {@link DomainSelectionConnectionHolder} that contains the
+     *               {@link DomainSelectionConnection} and its related information.
+     * @param request The {@link PendingRequest} that stores the SMS request
+     *                (data, text, multipart text) to be sent.
+     * @param logTag The log tag to display which method called this method.
+     */
+    private void sendSmsUsingDomainSelection(@NonNull DomainSelectionConnectionHolder holder,
+            @NonNull PendingRequest request, @NonNull String logTag) {
+        // Run on main thread for interworking with EmergencyStateTracker
+        // and adding the pending request.
+        SomeArgs args = SomeArgs.obtain();
+        args.arg1 = holder;
+        args.arg2 = request;
+        args.arg3 = logTag;
+        sendMessage(obtainMessage(EVENT_SEND_SMS_USING_DOMAIN_SELECTION, args));
+    }
+
+    /**
+     * Called when sending MO SMS is complete regardless of the sent result.
+     *
+     * @param destAddr The destination address for SMS.
+     * @param messageId The message id for SMS.
+     * @param success A flag specifying whether MO SMS is successfully sent or not.
+     */
+    private void handleSmsSentCompletedUsingDomainSelection(@NonNull String destAddr,
+            long messageId, boolean success) {
+        if (mEmergencyStateTracker != null) {
+            TelephonyManager tm = mContext.getSystemService(TelephonyManager.class);
+            if (tm.isEmergencyNumber(destAddr)) {
+                mEmergencyStateTracker.endSms(String.valueOf(messageId), success);
+            }
+        }
+    }
+
+    /**
+     * Called when MO SMS is successfully sent.
+     */
+    protected void notifySmsSentToEmergencyStateTracker(@NonNull String destAddr, long messageId) {
+        if (isSmsDomainSelectionEnabled()) {
+            // Run on main thread for interworking with EmergencyStateTracker.
+            SomeArgs args = SomeArgs.obtain();
+            args.arg1 = destAddr;
+            args.arg2 = Long.valueOf(messageId);
+            args.arg3 = Boolean.TRUE;
+            sendMessage(obtainMessage(EVENT_SMS_SENT_COMPLETED_USING_DOMAIN_SELECTION, args));
+        }
+    }
+
+    /**
+     * Called when sending MO SMS is failed.
+     */
+    protected void notifySmsSentFailedToEmergencyStateTracker(@NonNull String destAddr,
+            long messageId) {
+        if (isSmsDomainSelectionEnabled()) {
+            // Run on main thread for interworking with EmergencyStateTracker.
+            SomeArgs args = SomeArgs.obtain();
+            args.arg1 = destAddr;
+            args.arg2 = Long.valueOf(messageId);
+            args.arg3 = Boolean.FALSE;
+            sendMessage(obtainMessage(EVENT_SMS_SENT_COMPLETED_USING_DOMAIN_SELECTION, args));
+        }
+    }
+
+    private boolean isTestEmergencyNumber(String number) {
+        try {
+            TelephonyManager tm = mContext.getSystemService(TelephonyManager.class);
+            Map<Integer, List<EmergencyNumber>> eMap = tm.getEmergencyNumberList();
+            return eMap.values().stream().flatMap(Collection::stream).anyMatch(eNumber ->
+                    eNumber.isFromSources(EmergencyNumber.EMERGENCY_NUMBER_SOURCE_TEST)
+                    && number.equals(eNumber.getNumber()));
+        } catch (IllegalStateException ise) {
+            return false;
+        } catch (RuntimeException r) {
+            return false;
+        }
+    }
+
+    /**
      * Finishes the domain selection for MO SMS.
      *
      * @param holder The {@link DomainSelectionConnectionHolder} object that is being finished.
@@ -1054,21 +1231,16 @@
     }
 
     /**
-     * Notifies the application that MO SMS is not sent by the error of domain selection.
+     * Called when MO SMS is not sent by the error of domain selection.
      *
      * @param holder The {@link DomainSelectionConnectionHolder} object that is being terminated.
      */
-    private void notifyDomainSelectionTerminated(@NonNull DomainSelectionConnectionHolder holder) {
-        final List<PendingRequest> pendingRequests = holder.getPendingRequests();
-
-        logd("notifyDomainSelectionTerminated: pendingRequests=" + pendingRequests.size());
-
-        for (PendingRequest r : pendingRequests) {
-            triggerSentIntentForFailure(r.sentIntents);
-        }
-
+    private void handleDomainSelectionTerminatedAbnormally(
+            @NonNull DomainSelectionConnectionHolder holder) {
+        logd("handleDomainSelectionTerminatedAbnormally: pendingRequests="
+                + holder.getPendingRequests().size());
+        sendAllPendingRequests(holder, NetworkRegistrationInfo.DOMAIN_UNKNOWN);
         holder.setConnection(null);
-        holder.clearAllRequests();
     }
 
     /**
@@ -1089,12 +1261,36 @@
                     + ", size=" + pendingRequests.size());
         }
 
+        // When the domain selection request is failed, SMS should be fallback
+        // to the legacy implementation.
+        boolean wasDomainUnknown = false;
+
+        if (domain == NetworkRegistrationInfo.DOMAIN_UNKNOWN) {
+            logd("sendAllPendingRequests: fallback - imsAvailable="
+                    + mImsSmsDispatcher.isAvailable());
+
+            wasDomainUnknown = true;
+
+            if (mImsSmsDispatcher.isAvailable()) {
+                domain = NetworkRegistrationInfo.DOMAIN_PS;
+            } else {
+                domain = NetworkRegistrationInfo.DOMAIN_CS;
+            }
+        }
+
         for (PendingRequest r : pendingRequests) {
             switch (r.type) {
                 case PendingRequest.TYPE_DATA:
                     sendData(domain, r);
                     break;
                 case PendingRequest.TYPE_TEXT:
+                    // When the domain selection request is failed, emergency SMS should be fallback
+                    // to the legacy implementation.
+                    if (wasDomainUnknown
+                            && domain != NetworkRegistrationInfo.DOMAIN_PS
+                            && mImsSmsDispatcher.isEmergencySmsSupport(r.destAddr)) {
+                        domain = NetworkRegistrationInfo.DOMAIN_PS;
+                    }
                     sendText(domain, r);
                     break;
                 case PendingRequest.TYPE_MULTIPART_TEXT:
@@ -1308,7 +1504,7 @@
             scAddr = getSmscAddressFromUSIMWithPhoneIdentity(callingPackage);
         }
 
-        if (mDomainSelectionResolverProxy.isDomainSelectionSupported()) {
+        if (isSmsDomainSelectionEnabled()) {
             DomainSelectionConnectionHolder holder = getDomainSelectionConnection(false);
 
             // If the DomainSelectionConnection is not available,
@@ -1547,7 +1743,7 @@
             scAddr = getSmscAddressFromUSIMWithPhoneIdentity(callingPkg);
         }
 
-        if (mDomainSelectionResolverProxy.isDomainSelectionSupported()) {
+        if (isSmsDomainSelectionEnabled()) {
             TelephonyManager tm = mContext.getSystemService(TelephonyManager.class);
             boolean isEmergency = tm.isEmergencyNumber(destAddr);
             DomainSelectionConnectionHolder holder = getDomainSelectionConnection(isEmergency);
@@ -1696,7 +1892,7 @@
             scAddr = getSmscAddressFromUSIMWithPhoneIdentity(callingPkg);
         }
 
-        if (mDomainSelectionResolverProxy.isDomainSelectionSupported()) {
+        if (isSmsDomainSelectionEnabled()) {
             DomainSelectionConnectionHolder holder = getDomainSelectionConnection(false);
 
             // If the DomainSelectionConnection is not available,
diff --git a/src/java/com/android/internal/telephony/TelephonyComponentFactory.java b/src/java/com/android/internal/telephony/TelephonyComponentFactory.java
index 17a4a54..8b832dd 100644
--- a/src/java/com/android/internal/telephony/TelephonyComponentFactory.java
+++ b/src/java/com/android/internal/telephony/TelephonyComponentFactory.java
@@ -327,8 +327,12 @@
         return new IccPhoneBookInterfaceManager(phone);
     }
 
-    public IccSmsInterfaceManager makeIccSmsInterfaceManager(Phone phone) {
-        return new IccSmsInterfaceManager(phone);
+    /**
+     * Returns a new {@link IccSmsInterfaceManager} instance.
+     */
+    public IccSmsInterfaceManager makeIccSmsInterfaceManager(Phone phone,
+            @NonNull FeatureFlags featureFlags) {
+        return new IccSmsInterfaceManager(phone, featureFlags);
     }
 
     /**
@@ -402,8 +406,12 @@
         return new AppSmsManager(context);
     }
 
-    public DeviceStateMonitor makeDeviceStateMonitor(Phone phone) {
-        return new DeviceStateMonitor(phone);
+    /**
+     * Create a DeviceStateMonitor.
+     */
+    public DeviceStateMonitor makeDeviceStateMonitor(Phone phone,
+            @NonNull FeatureFlags featureFlags) {
+        return new DeviceStateMonitor(phone, featureFlags);
     }
 
     /**
@@ -444,8 +452,8 @@
     /**
      * Create a new DisplayInfoController.
      */
-    public DisplayInfoController makeDisplayInfoController(Phone phone) {
-        return new DisplayInfoController(phone);
+    public DisplayInfoController makeDisplayInfoController(Phone phone, FeatureFlags featureFlags) {
+        return new DisplayInfoController(phone, featureFlags);
     }
 
     /**
@@ -494,15 +502,17 @@
      * @param dataServiceManager Data service manager instance.
      * @param looper The looper to be used by the handler. Currently the handler thread is the phone
      * process's main thread.
+     * @param featureFlags Feature flags controlling which feature is enabled.     *
      * @param callback Callback for passing events back to data network controller.
      * @return The data profile manager instance.
      */
     public @NonNull DataProfileManager makeDataProfileManager(@NonNull Phone phone,
             @NonNull DataNetworkController dataNetworkController,
             @NonNull DataServiceManager dataServiceManager, @NonNull Looper looper,
+            @NonNull FeatureFlags featureFlags,
             @NonNull DataProfileManager.DataProfileManagerCallback callback) {
         return new DataProfileManager(phone, dataNetworkController, dataServiceManager, looper,
-                callback);
+                featureFlags, callback);
     }
 
     /**
diff --git a/src/java/com/android/internal/telephony/cdma/CdmaSMSDispatcher.java b/src/java/com/android/internal/telephony/cdma/CdmaSMSDispatcher.java
index ebc6342..2119003 100644
--- a/src/java/com/android/internal/telephony/cdma/CdmaSMSDispatcher.java
+++ b/src/java/com/android/internal/telephony/cdma/CdmaSMSDispatcher.java
@@ -129,6 +129,7 @@
         // if sms over IMS is not supported on data and voice is not available...
         if (!isIms() && ss != ServiceState.STATE_IN_SERVICE) {
             tracker.onFailed(mContext, getNotInServiceError(ss), NO_ERROR_CODE);
+            notifySmsSentFailedToEmergencyStateTracker(tracker);
             return;
         }
 
diff --git a/src/java/com/android/internal/telephony/data/DataConfigManager.java b/src/java/com/android/internal/telephony/data/DataConfigManager.java
index 22ad593..950ac10 100644
--- a/src/java/com/android/internal/telephony/data/DataConfigManager.java
+++ b/src/java/com/android/internal/telephony/data/DataConfigManager.java
@@ -31,6 +31,7 @@
 import android.telephony.Annotation.NetCapability;
 import android.telephony.Annotation.NetworkType;
 import android.telephony.CarrierConfigManager;
+import android.telephony.NetworkRegistrationInfo;
 import android.telephony.ServiceState;
 import android.telephony.SignalStrength;
 import android.telephony.SubscriptionManager;
@@ -46,6 +47,7 @@
 import com.android.internal.telephony.data.DataNetworkController.HandoverRule;
 import com.android.internal.telephony.data.DataRetryManager.DataHandoverRetryRule;
 import com.android.internal.telephony.data.DataRetryManager.DataSetupRetryRule;
+import com.android.internal.telephony.flags.FeatureFlags;
 import com.android.telephony.Rlog;
 
 import java.io.FileDescriptor;
@@ -259,6 +261,7 @@
     private @NonNull final Phone mPhone;
     private @NonNull final String mLogTag;
 
+    @NonNull private final FeatureFlags mFeatureFlags;
     private @NonNull final CarrierConfigManager mCarrierConfigManager;
     private @NonNull PersistableBundle mCarrierConfig = null;
     private @NonNull Resources mResources = null;
@@ -295,6 +298,9 @@
     private @NonNull final List<HandoverRule> mHandoverRuleList = new ArrayList<>();
     /** {@code True} keep IMS network in case of moving to non VOPS area; {@code false} otherwise.*/
     private boolean mShouldKeepNetworkUpInNonVops = false;
+    /** The set of network types that enable VOPS even in non VOPS area. */
+    @NonNull private final @CarrierConfigManager.Ims.NetworkType List<Integer>
+            mEnabledVopsNetworkTypesInNonVops = new ArrayList<>();
     /**
      * A map of network types to the estimated downlink values by signal strength 0 - 4 for that
      * network type
@@ -309,9 +315,11 @@
      * @param looper The looper to be used by the handler. Currently the handler thread is the
      * phone process's main thread.
      */
-    public DataConfigManager(@NonNull Phone phone, @NonNull Looper looper) {
+    public DataConfigManager(@NonNull Phone phone, @NonNull Looper looper,
+            @NonNull FeatureFlags featureFlags) {
         super(looper);
         mPhone = phone;
+        mFeatureFlags = featureFlags;
         mLogTag = "DCM-" + mPhone.getPhoneId();
         log("DataConfigManager created.");
 
@@ -666,6 +674,11 @@
         synchronized (this) {
             mShouldKeepNetworkUpInNonVops = mCarrierConfig.getBoolean(CarrierConfigManager
                     .Ims.KEY_KEEP_PDN_UP_IN_NO_VOPS_BOOL);
+            int[] allowedNetworkTypes = mCarrierConfig.getIntArray(
+                    CarrierConfigManager.Ims.KEY_IMS_PDN_ENABLED_IN_NO_VOPS_SUPPORT_INT_ARRAY);
+            if (allowedNetworkTypes != null) {
+                Arrays.stream(allowedNetworkTypes).forEach(mEnabledVopsNetworkTypesInNonVops::add);
+            }
         }
     }
 
@@ -684,9 +697,29 @@
         return Collections.unmodifiableSet(mCapabilitiesExemptFromSingleDataList);
     }
 
-    /** {@code True} keep IMS network in case of moving to non VOPS area; {@code false} otherwise.*/
-    public boolean shouldKeepNetworkUpInNonVops() {
-        return mShouldKeepNetworkUpInNonVops;
+    /**
+     * @param regState The modem reported data registration state.
+     * @return {@code true} if should keep IMS network in case of moving to non VOPS area.
+     */
+    public boolean shouldKeepNetworkUpInNonVops(@NetworkRegistrationInfo.RegistrationState
+            int regState) {
+        return mShouldKeepNetworkUpInNonVops || allowBringUpNetworkInNonVops(regState);
+    }
+
+    /**
+     * @param regState The modem reported data registration state.
+     * @return {@code true} if allow bring up IMS network in case of moving to non VOPS area.
+     */
+    public boolean allowBringUpNetworkInNonVops(@NetworkRegistrationInfo.RegistrationState
+            int regState) {
+        if (!mFeatureFlags.allowMmtelInNonVops()) return false;
+        int networkType = -1;
+        if (regState == NetworkRegistrationInfo.REGISTRATION_STATE_HOME) {
+            networkType = CarrierConfigManager.Ims.NETWORK_TYPE_HOME;
+        } else if (regState == NetworkRegistrationInfo.REGISTRATION_STATE_ROAMING) {
+            networkType = CarrierConfigManager.Ims.NETWORK_TYPE_ROAMING;
+        }
+        return mEnabledVopsNetworkTypesInNonVops.contains(networkType);
     }
 
     /** {@code True} requires ping test to pass on the target slot before switching to it.*/
@@ -1423,7 +1456,8 @@
         pw.println("Capabilities exempt from single PDN=" + mCapabilitiesExemptFromSingleDataList
                 .stream().map(DataUtils::networkCapabilityToString)
                 .collect(Collectors.joining(",")));
-        pw.println("mShouldKeepNetworkUpInNoVops=" + mShouldKeepNetworkUpInNonVops);
+        pw.println("mShouldKeepNetworkUpInNonVops=" + mShouldKeepNetworkUpInNonVops);
+        pw.println("mEnabledVopsNetworkTypesInNonVops=" + mEnabledVopsNetworkTypesInNonVops);
         pw.println("isPingTestBeforeAutoDataSwitchRequired="
                 + isPingTestBeforeAutoDataSwitchRequired());
         pw.println("Unmetered network types=" + String.join(",", mUnmeteredNetworkTypes));
diff --git a/src/java/com/android/internal/telephony/data/DataNetwork.java b/src/java/com/android/internal/telephony/data/DataNetwork.java
index 6b410ce..0c5c9cb 100644
--- a/src/java/com/android/internal/telephony/data/DataNetwork.java
+++ b/src/java/com/android/internal/telephony/data/DataNetwork.java
@@ -99,6 +99,7 @@
 import com.android.internal.telephony.data.DataSettingsManager.DataSettingsManagerCallback;
 import com.android.internal.telephony.data.LinkBandwidthEstimator.LinkBandwidthEstimatorCallback;
 import com.android.internal.telephony.data.TelephonyNetworkAgent.TelephonyNetworkAgentCallback;
+import com.android.internal.telephony.flags.FeatureFlags;
 import com.android.internal.telephony.metrics.DataCallSessionStats;
 import com.android.internal.telephony.metrics.TelephonyMetrics;
 import com.android.internal.util.ArrayUtils;
@@ -440,9 +441,9 @@
             // Connectivity service will support NOT_METERED as a mutable and requestable
             // capability.
             NetworkCapabilities.NET_CAPABILITY_NOT_METERED,
-            // Even though MMTEL is an immutable capability, we still make it an mutable capability
-            // here before we have a better solution to deal with network transition from VoPS
-            // to non-VoPS network.
+            // Dynamically add and remove MMTEL capability when network transition between VoPS
+            // and non-VoPS network if the request is not MMTEL. For MMTEL, we retain the capability
+            // to prevent immediate tear down.
             NetworkCapabilities.NET_CAPABILITY_MMTEL
     );
 
@@ -490,6 +491,9 @@
     /** The phone instance. */
     private final @NonNull Phone mPhone;
 
+    /** Feature flags */
+    private final @NonNull FeatureFlags mFlags;
+
     /**
      * The subscription id. This is assigned when the network is created, and not supposed to
      * change afterwards.
@@ -897,7 +901,7 @@
      * @param dataAllowedReason The reason that why setting up this data network is allowed.
      * @param callback The callback to receives data network state update.
      */
-    public DataNetwork(@NonNull Phone phone, @NonNull Looper looper,
+    public DataNetwork(@NonNull Phone phone, FeatureFlags featureFlags, @NonNull Looper looper,
             @NonNull SparseArray<DataServiceManager> dataServiceManagers,
             @NonNull DataProfile dataProfile,
             @NonNull NetworkRequestList networkRequestList,
@@ -911,6 +915,7 @@
         initializeStateMachine();
 
         mPhone = phone;
+        mFlags = featureFlags;
         mSubId = phone.getSubId();
         mRil = mPhone.mCi;
         mLinkProperties = new LinkProperties();
@@ -2141,30 +2146,34 @@
             }
         }
 
-        // Once we set the MMTEL capability, we should never remove it because it's an immutable
+        // If MMTEL capability is requested, we should not remove it because it's an immutable
         // capability defined by connectivity service. When the device enters from VoPS to non-VoPS,
         // we should perform grace tear down from data network controller if needed.
-        if (mNetworkCapabilities != null
-                && mNetworkCapabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_MMTEL)) {
-            // Previous capability has MMTEL, so add it again.
+        if (hasNetworkCapabilityInNetworkRequests(NetworkCapabilities.NET_CAPABILITY_MMTEL)) {
+            // Request has MMTEL, add it again so the network won't be unwanted by connectivity.
             builder.addCapability(NetworkCapabilities.NET_CAPABILITY_MMTEL);
-        } else {
+        } else if (mDataProfile.canSatisfy(NetworkCapabilities.NET_CAPABILITY_IMS)) {
+            // Request has IMS capability only.
             // Always add MMTEL capability on IMS network unless network explicitly indicates VoPS
             // not supported.
-            if (mDataProfile.canSatisfy(NetworkCapabilities.NET_CAPABILITY_IMS)) {
-                builder.addCapability(NetworkCapabilities.NET_CAPABILITY_MMTEL);
-                if (mTransport == AccessNetworkConstants.TRANSPORT_TYPE_WWAN) {
-                    NetworkRegistrationInfo nri = getNetworkRegistrationInfo();
-                    if (nri != null) {
-                        DataSpecificRegistrationInfo dsri = nri.getDataSpecificInfo();
-                        // Check if the network is non-VoPS.
-                        if (dsri != null && dsri.getVopsSupportInfo() != null
-                                && !dsri.getVopsSupportInfo().isVopsSupported()
-                                && !mDataConfigManager.shouldKeepNetworkUpInNonVops()) {
-                            builder.removeCapability(NetworkCapabilities.NET_CAPABILITY_MMTEL);
-                        }
-                        log("updateNetworkCapabilities: dsri=" + dsri);
+            builder.addCapability(NetworkCapabilities.NET_CAPABILITY_MMTEL);
+            if (mTransport == AccessNetworkConstants.TRANSPORT_TYPE_WWAN) {
+                NetworkRegistrationInfo nri = getNetworkRegistrationInfo();
+                if (nri != null) {
+                    DataSpecificRegistrationInfo dsri = nri.getDataSpecificInfo();
+                    // Check if the network is non-VoPS.
+                    if (dsri != null && dsri.getVopsSupportInfo() != null
+                            && !dsri.getVopsSupportInfo().isVopsSupported()
+                            // Reflect the actual MMTEL if flag on.
+                            && (mFlags.allowMmtelInNonVops()
+                            // Deceive Connectivity service to satisfy an MMTEL request, this should
+                            // be useless because we reach here if no MMTEL request, then removing
+                            // MMTEL capability shouldn't have any impacts.
+                            || !mDataConfigManager.shouldKeepNetworkUpInNonVops(
+                                    nri.getNetworkRegistrationState()))) {
+                        builder.removeCapability(NetworkCapabilities.NET_CAPABILITY_MMTEL);
                     }
+                    log("updateNetworkCapabilities: dsri=" + dsri);
                 }
             }
         }
@@ -2721,7 +2730,7 @@
     public boolean shouldDelayImsTearDownDueToInCall() {
         return mDataConfigManager.isImsDelayTearDownUntilVoiceCallEndEnabled()
                 && mNetworkCapabilities != null
-                && mNetworkCapabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_MMTEL)
+                && mNetworkCapabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_IMS)
                 && mPhone.getImsPhone() != null
                 && mPhone.getImsPhone().getCallTracker().getState()
                 != PhoneConstants.State.IDLE;
@@ -3308,7 +3317,8 @@
                 && !mAttachedNetworkRequestList.isEmpty()) {
             TelephonyNetworkRequest networkRequest = mAttachedNetworkRequestList.get(0);
             DataProfile dataProfile = mDataNetworkController.getDataProfileManager()
-                    .getDataProfileForNetworkRequest(networkRequest, targetNetworkType, false);
+                    .getDataProfileForNetworkRequest(networkRequest, targetNetworkType,
+                            mPhone.getServiceState().isUsingNonTerrestrialNetwork(), false);
             // Some carriers have different profiles between cellular and IWLAN. We need to
             // dynamically switch profile, but only when those profiles have same APN name.
             if (dataProfile != null && dataProfile.getApnSetting() != null
diff --git a/src/java/com/android/internal/telephony/data/DataNetworkController.java b/src/java/com/android/internal/telephony/data/DataNetworkController.java
index 3073f49..2d91967 100644
--- a/src/java/com/android/internal/telephony/data/DataNetworkController.java
+++ b/src/java/com/android/internal/telephony/data/DataNetworkController.java
@@ -813,7 +813,7 @@
             mDataServiceManagers.put(transport, new DataServiceManager(mPhone, looper, transport));
         }
 
-        mDataConfigManager = new DataConfigManager(mPhone, looper);
+        mDataConfigManager = new DataConfigManager(mPhone, looper, featureFlags);
 
         // ========== Anomaly counters ==========
         mImsThrottleCounter = new SlidingWindowEventCounter(
@@ -879,6 +879,7 @@
                 DataProfileManager.class.getName())
                 .makeDataProfileManager(mPhone, this, mDataServiceManagers
                                 .get(AccessNetworkConstants.TRANSPORT_TYPE_WWAN), looper,
+                        mFeatureFlags,
                         new DataProfileManagerCallback(this::post) {
                             @Override
                             public void onDataProfilesChanged() {
@@ -899,7 +900,7 @@
                     }
                 });
         mDataRetryManager = new DataRetryManager(mPhone, this,
-                mDataServiceManagers, looper,
+                mDataServiceManagers, looper, mFeatureFlags,
                 new DataRetryManagerCallback(this::post) {
                     @Override
                     public void onDataNetworkSetupRetry(
@@ -1328,6 +1329,7 @@
                 DataProfile candidate = mDataProfileManager
                         .getDataProfileForNetworkRequest(requestList.getFirst(),
                                 TelephonyManager.NETWORK_TYPE_IWLAN,
+                                mServiceState.isUsingNonTerrestrialNetwork(),
                                 false/*ignorePermanentFailure*/);
                 if (candidate != null && !dataNetwork.getDataProfile().equals(candidate)) {
                     logv("But skipped because found better data profile " + candidate
@@ -1491,7 +1493,8 @@
         if (networkRequest.hasCapability(NetworkCapabilities.NET_CAPABILITY_EIMS)) {
             evaluation.addDataAllowedReason(DataAllowedReason.EMERGENCY_REQUEST);
             evaluation.setCandidateDataProfile(mDataProfileManager.getDataProfileForNetworkRequest(
-                    networkRequest, getDataNetworkType(transport), true));
+                    networkRequest, getDataNetworkType(transport),
+                    mServiceState.isUsingNonTerrestrialNetwork(), true));
             networkRequest.setEvaluation(evaluation);
             log(evaluation.toString());
             return evaluation;
@@ -1526,7 +1529,9 @@
             if (nri != null) {
                 DataSpecificRegistrationInfo dsri = nri.getDataSpecificInfo();
                 if (dsri != null && dsri.getVopsSupportInfo() != null
-                        && !dsri.getVopsSupportInfo().isVopsSupported()) {
+                        && !dsri.getVopsSupportInfo().isVopsSupported()
+                        && !mDataConfigManager.allowBringUpNetworkInNonVops(
+                                nri.getNetworkRegistrationState())) {
                     evaluation.addDataDisallowedReason(DataDisallowedReason.VOPS_NOT_SUPPORTED);
                 }
             }
@@ -1647,6 +1652,7 @@
         }
         DataProfile dataProfile = mDataProfileManager
                 .getDataProfileForNetworkRequest(networkRequest, networkType,
+                        mServiceState.isUsingNonTerrestrialNetwork(),
                         // If the evaluation is due to environmental changes, then we should ignore
                         // the permanent failure reached earlier.
                         reason.isConditionBased());
@@ -1787,6 +1793,8 @@
             }
         }
 
+        // It's recommended for IMS service not requesting MMTEL capability, so that MMTEL
+        // capability is dynamically added when moving between vops and nonvops area.
         boolean vopsIsRequired = dataNetwork.hasNetworkCapabilityInNetworkRequests(
                 NetworkCapabilities.NET_CAPABILITY_MMTEL);
 
@@ -1809,7 +1817,8 @@
                         DataSpecificRegistrationInfo dsri = nri.getDataSpecificInfo();
                         if (dsri != null && dsri.getVopsSupportInfo() != null
                                 && !dsri.getVopsSupportInfo().isVopsSupported()
-                                && !mDataConfigManager.shouldKeepNetworkUpInNonVops()) {
+                                && !mDataConfigManager.shouldKeepNetworkUpInNonVops(
+                                        nri.getNetworkRegistrationState())) {
                             evaluation.addDataDisallowedReason(
                                     DataDisallowedReason.VOPS_NOT_SUPPORTED);
                         }
@@ -1989,6 +1998,8 @@
                 }
 
                 // Check if VoPS is required, but the target transport is non-VoPS.
+                // It's recommended for IMS service not requesting MMTEL capability, so that MMTEL
+                // capability is dynamically added when moving between vops and nonvops area.
                 NetworkRequestList networkRequestList =
                         dataNetwork.getAttachedNetworkRequestList();
                 if (networkRequestList.stream().anyMatch(request
@@ -1997,7 +2008,8 @@
                     // Check if the network is non-VoPS.
                     if (dsri != null && dsri.getVopsSupportInfo() != null
                             && !dsri.getVopsSupportInfo().isVopsSupported()
-                            && !mDataConfigManager.shouldKeepNetworkUpInNonVops()) {
+                            && !mDataConfigManager.shouldKeepNetworkUpInNonVops(
+                                    nri.getNetworkRegistrationState())) {
                         dataEvaluation.addDataDisallowedReason(
                                 DataDisallowedReason.VOPS_NOT_SUPPORTED);
                     }
@@ -2541,8 +2553,8 @@
                 + AccessNetworkConstants.transportTypeToString(transport) + " with " + dataProfile
                 + ", and attaching " + networkRequestList.size() + " network requests to it.");
 
-        mDataNetworkList.add(new DataNetwork(mPhone, getLooper(), mDataServiceManagers,
-                dataProfile, networkRequestList, transport, allowedReason,
+        mDataNetworkList.add(new DataNetwork(mPhone, mFeatureFlags, getLooper(),
+                mDataServiceManagers, dataProfile, networkRequestList, transport, allowedReason,
                 new DataNetworkCallback(this::post) {
                     @Override
                     public void onSetupDataFailed(@NonNull DataNetwork dataNetwork,
@@ -3386,7 +3398,8 @@
         }
 
         if (oldNri.getAccessNetworkTechnology() != newNri.getAccessNetworkTechnology()
-                || (!oldNri.isRoaming() && newNri.isRoaming())) {
+                // Some CarrierConfig disallows vops in nonVops area for specified home/roaming.
+                || (oldNri.isRoaming() != newNri.isRoaming())) {
             return true;
         }
 
@@ -3436,7 +3449,8 @@
         if (oldPsNri == null
                 || oldPsNri.getAccessNetworkTechnology() != newPsNri.getAccessNetworkTechnology()
                 || (!oldPsNri.isInService() && newPsNri.isInService())
-                || (oldPsNri.isRoaming() && !newPsNri.isRoaming())) {
+                // Some CarrierConfig allows vops in nonVops area for specified home/roaming.
+                || (oldPsNri.isRoaming() != newPsNri.isRoaming())) {
             return true;
         }
 
diff --git a/src/java/com/android/internal/telephony/data/DataProfileManager.java b/src/java/com/android/internal/telephony/data/DataProfileManager.java
index 23029e3..273dc8b 100644
--- a/src/java/com/android/internal/telephony/data/DataProfileManager.java
+++ b/src/java/com/android/internal/telephony/data/DataProfileManager.java
@@ -48,6 +48,7 @@
 import com.android.internal.telephony.Phone;
 import com.android.internal.telephony.data.DataConfigManager.DataConfigManagerCallback;
 import com.android.internal.telephony.data.DataNetworkController.DataNetworkControllerCallback;
+import com.android.internal.telephony.flags.FeatureFlags;
 import com.android.telephony.Rlog;
 
 import java.io.FileDescriptor;
@@ -113,6 +114,9 @@
     /** SIM state. */
     private @SimState int mSimState = TelephonyManager.SIM_STATE_UNKNOWN;
 
+    /** Feature flags controlling which feature is enabled. */
+    private final @NonNull FeatureFlags mFeatureFlags;
+
     /**
      * Data profile manager callback. This should be only used by {@link DataNetworkController}.
      */
@@ -140,15 +144,18 @@
      * @param dataServiceManager WWAN data service manager.
      * @param looper The looper to be used by the handler. Currently the handler thread is the
      * phone process's main thread.
+     * @param featureFlags Feature flags controlling which feature is enabled.
      * @param callback Data profile manager callback.
      */
     public DataProfileManager(@NonNull Phone phone,
             @NonNull DataNetworkController dataNetworkController,
             @NonNull DataServiceManager dataServiceManager, @NonNull Looper looper,
+            @NonNull FeatureFlags featureFlags,
             @NonNull DataProfileManagerCallback callback) {
         super(looper);
         mPhone = phone;
         mLogTag = "DPM-" + mPhone.getPhoneId();
+        mFeatureFlags = featureFlags;
         mDataNetworkController = dataNetworkController;
         mWwanDataServiceManager = dataServiceManager;
         mDataConfigManager = dataNetworkController.getDataConfigManager();
@@ -626,17 +633,18 @@
      *
      * @param networkRequest The network request.
      * @param networkType The current data network type.
+     * @param isNtn {@code true} if the device is currently attached to non-terrestrial network.
      * @param ignorePermanentFailure {@code true} to ignore {@link ApnSetting#getPermanentFailed()}.
      * This should be set to true for condition-based retry/setup.
      * @return The data profile. {@code null} if can't find any satisfiable data profile.
      */
     public @Nullable DataProfile getDataProfileForNetworkRequest(
             @NonNull TelephonyNetworkRequest networkRequest, @NetworkType int networkType,
-            boolean ignorePermanentFailure) {
+            boolean isNtn, boolean ignorePermanentFailure) {
         ApnSetting apnSetting = null;
         if (networkRequest.hasAttribute(TelephonyNetworkRequest
                 .CAPABILITY_ATTRIBUTE_APN_SETTING)) {
-            apnSetting = getApnSettingForNetworkRequest(networkRequest, networkType,
+            apnSetting = getApnSettingForNetworkRequest(networkRequest, networkType, isNtn,
                     ignorePermanentFailure);
         }
 
@@ -696,32 +704,56 @@
      *
      * @param networkRequest The network request.
      * @param networkType The current data network type.
+     * @param isNtn {@code true} if the device is currently attached to non-terrestrial network.
      * @param ignorePermanentFailure {@code true} to ignore {@link ApnSetting#getPermanentFailed()}.
      * This should be set to true for condition-based retry/setup.
      * @return The APN setting. {@code null} if can't find any satisfiable data profile.
      */
     private @Nullable ApnSetting getApnSettingForNetworkRequest(
             @NonNull TelephonyNetworkRequest networkRequest, @NetworkType int networkType,
-            boolean ignorePermanentFailure) {
+            boolean isNtn, boolean ignorePermanentFailure) {
         if (!networkRequest.hasAttribute(
                 TelephonyNetworkRequest.CAPABILITY_ATTRIBUTE_APN_SETTING)) {
             loge("Network request does not have APN setting attribute.");
             return null;
         }
 
-        // If the preferred data profile can be used, always use it if it can satisfy the network
-        // request with current network type (even though it's been marked as permanent failed.)
-        if (mPreferredDataProfile != null
-                && networkRequest.canBeSatisfiedBy(mPreferredDataProfile)
-                && mPreferredDataProfile.getApnSetting() != null
-                && mPreferredDataProfile.getApnSetting().canSupportNetworkType(networkType)) {
-            if (ignorePermanentFailure || !mPreferredDataProfile.getApnSetting()
-                    .getPermanentFailed()) {
-                return mPreferredDataProfile.getApnSetting();
+        if (mFeatureFlags.carrierEnabledSatelliteFlag()) {
+            // If the preferred data profile can be used, always use it if it can satisfy the
+            // network request with current network type (even though it's been marked as permanent
+            // failed.)
+            if (mPreferredDataProfile != null
+                    && networkRequest.canBeSatisfiedBy(mPreferredDataProfile)
+                    && mPreferredDataProfile.getApnSetting() != null
+                    && mPreferredDataProfile.getApnSetting().canSupportNetworkType(networkType)
+                    && ((isNtn && mPreferredDataProfile.getApnSetting().isForInfrastructure(
+                            ApnSetting.INFRASTRUCTURE_SATELLITE))
+                    || (!isNtn && mPreferredDataProfile.getApnSetting().isForInfrastructure(
+                            ApnSetting.INFRASTRUCTURE_CELLULAR)))) {
+                if (ignorePermanentFailure || !mPreferredDataProfile.getApnSetting()
+                        .getPermanentFailed()) {
+                    return mPreferredDataProfile.getApnSetting();
+                }
+                log("The preferred data profile is permanently failed. Only condition based "
+                        + "retry can happen.");
+                return null;
             }
-            log("The preferred data profile is permanently failed. Only condition based retry "
-                    + "can happen.");
-            return null;
+        } else {
+            // If the preferred data profile can be used, always use it if it can satisfy the
+            // network request with current network type (even though it's been marked as permanent
+            // failed.)
+            if (mPreferredDataProfile != null
+                    && networkRequest.canBeSatisfiedBy(mPreferredDataProfile)
+                    && mPreferredDataProfile.getApnSetting() != null
+                    && mPreferredDataProfile.getApnSetting().canSupportNetworkType(networkType)) {
+                if (ignorePermanentFailure || !mPreferredDataProfile.getApnSetting()
+                        .getPermanentFailed()) {
+                    return mPreferredDataProfile.getApnSetting();
+                }
+                log("The preferred data profile is permanently failed. Only condition based "
+                        + "retry can happen.");
+                return null;
+            }
         }
 
         // Filter out the data profile that can't satisfy the request.
@@ -743,8 +775,22 @@
 
         // Check if the remaining data profiles can used in current data network type.
         dataProfiles = dataProfiles.stream()
-                .filter(dp -> dp.getApnSetting() != null
-                        && dp.getApnSetting().canSupportNetworkType(networkType))
+                .filter((dp) -> {
+                    if (dp.getApnSetting() == null) return false;
+                    if (!dp.getApnSetting().canSupportNetworkType(networkType)) return false;
+                    if (mFeatureFlags.carrierEnabledSatelliteFlag()) {
+                        if (isNtn && !dp.getApnSetting().isForInfrastructure(
+                                ApnSetting.INFRASTRUCTURE_SATELLITE)) {
+                            return false;
+                        }
+                        if (!isNtn && !dp.getApnSetting().isForInfrastructure(
+                                ApnSetting.INFRASTRUCTURE_CELLULAR)) {
+                            return false;
+                        }
+                    }
+
+                    return true;
+                })
                 .collect(Collectors.toList());
         if (dataProfiles.size() == 0) {
             log("Can't find any data profile for network type "
@@ -818,7 +864,8 @@
                 new NetworkRequest.Builder()
                         .addCapability(NetworkCapabilities.NET_CAPABILITY_DUN)
                         .build(), mPhone);
-        return getDataProfileForNetworkRequest(networkRequest, networkType, true) != null;
+        return getDataProfileForNetworkRequest(networkRequest, networkType,
+                mPhone.getServiceState().isUsingNonTerrestrialNetwork(), true) != null;
     }
 
     /**
diff --git a/src/java/com/android/internal/telephony/data/DataRetryManager.java b/src/java/com/android/internal/telephony/data/DataRetryManager.java
index 4465fbb..754400e 100644
--- a/src/java/com/android/internal/telephony/data/DataRetryManager.java
+++ b/src/java/com/android/internal/telephony/data/DataRetryManager.java
@@ -51,6 +51,7 @@
 import com.android.internal.telephony.data.DataNetworkController.DataNetworkControllerCallback;
 import com.android.internal.telephony.data.DataNetworkController.NetworkRequestList;
 import com.android.internal.telephony.data.DataProfileManager.DataProfileManagerCallback;
+import com.android.internal.telephony.flags.FeatureFlags;
 import com.android.telephony.Rlog;
 
 import java.io.FileDescriptor;
@@ -141,6 +142,9 @@
     /** The phone instance. */
     private final @NonNull Phone mPhone;
 
+    /** Featureflags. */
+    private final @NonNull FeatureFlags mFlags;
+
     /** The RIL instance. */
     private final @NonNull CommandsInterface mRil;
 
@@ -952,10 +956,12 @@
     public DataRetryManager(@NonNull Phone phone,
             @NonNull DataNetworkController dataNetworkController,
             @NonNull SparseArray<DataServiceManager> dataServiceManagers,
-            @NonNull Looper looper, @NonNull DataRetryManagerCallback dataRetryManagerCallback) {
+            @NonNull Looper looper, @NonNull FeatureFlags flags,
+            @NonNull DataRetryManagerCallback dataRetryManagerCallback) {
         super(looper);
         mPhone = phone;
         mRil = phone.mCi;
+        mFlags = flags;
         mLogTag = "DRM-" + mPhone.getPhoneId();
         mDataRetryManagerCallbacks.add(dataRetryManagerCallback);
 
@@ -1480,9 +1486,12 @@
         DataThrottlingEntry entry = new DataThrottlingEntry(dataProfile, networkRequestList,
                 dataNetwork, transport, retryType, expirationTime);
         // Remove previous entry that contains the same data profile. Therefore it should always
-        // contain at maximum all the distinct data profiles of the current subscription.
+        // contain at maximu all the distinct data profiles of the current subscription times each
+        // transport.
         mDataThrottlingEntries.removeIf(
-                throttlingEntry -> dataProfile.equals(throttlingEntry.dataProfile));
+                throttlingEntry -> dataProfile.equals(throttlingEntry.dataProfile)
+                        && (!mFlags.unthrottleCheckTransport()
+                        || throttlingEntry.transport == transport));
 
         if (mDataThrottlingEntries.size() >= MAXIMUM_HISTORICAL_ENTRIES) {
             // If we don't see the anomaly report after U release, we should remove this check for
@@ -1544,7 +1553,8 @@
             // in DataProfileInfo.aidl), so we need to get the equivalent data profile from data
             // profile manager.
             Stream<DataThrottlingEntry> stream = mDataThrottlingEntries.stream();
-            stream = stream.filter(entry -> entry.expirationTimeMillis > now);
+            stream = stream.filter(entry -> entry.expirationTimeMillis > now
+                    && (!mFlags.unthrottleCheckTransport() || entry.transport == transport));
             if (dataProfile.getApnSetting() != null) {
                 stream = stream
                         .filter(entry -> entry.dataProfile.getApnSetting() != null)
diff --git a/src/java/com/android/internal/telephony/data/DataUtils.java b/src/java/com/android/internal/telephony/data/DataUtils.java
index fc0c4f1..259b482 100644
--- a/src/java/com/android/internal/telephony/data/DataUtils.java
+++ b/src/java/com/android/internal/telephony/data/DataUtils.java
@@ -90,6 +90,8 @@
                 return NetworkCapabilities.NET_CAPABILITY_PRIORITIZE_BANDWIDTH;
             case "PRIORITIZE_LATENCY":
                 return NetworkCapabilities.NET_CAPABILITY_PRIORITIZE_LATENCY;
+            case "RCS":
+                return NetworkCapabilities.NET_CAPABILITY_RCS;
             default:
                 return -1;
         }
@@ -254,6 +256,8 @@
                 return ApnSetting.TYPE_VSIM;
             case NetworkCapabilities.NET_CAPABILITY_BIP:
                 return ApnSetting.TYPE_BIP;
+            case NetworkCapabilities.NET_CAPABILITY_RCS:
+                return ApnSetting.TYPE_RCS;
             default:
                 return ApnSetting.TYPE_NONE;
         }
@@ -295,6 +299,8 @@
                 return NetworkCapabilities.NET_CAPABILITY_VSIM;
             case ApnSetting.TYPE_ENTERPRISE:
                 return NetworkCapabilities.NET_CAPABILITY_ENTERPRISE;
+            case ApnSetting.TYPE_RCS:
+                return NetworkCapabilities.NET_CAPABILITY_RCS;
             default:
                 return -1;
         }
diff --git a/src/java/com/android/internal/telephony/data/PhoneSwitcher.java b/src/java/com/android/internal/telephony/data/PhoneSwitcher.java
index ab759e9..36e6587 100644
--- a/src/java/com/android/internal/telephony/data/PhoneSwitcher.java
+++ b/src/java/com/android/internal/telephony/data/PhoneSwitcher.java
@@ -1546,7 +1546,7 @@
         // If validation feature is not supported, set it directly. Otherwise,
         // start validation on the subscription first.
         if (!mValidator.isValidationFeatureSupported()) {
-            setAutoSelectedDataSubIdInternal(subIdToValidate);
+            setAutoSelectedDataSubIdInternal(subId);
             sendSetOpptCallbackHelper(callback, SET_OPPORTUNISTIC_SUB_SUCCESS);
             return;
         }
diff --git a/src/java/com/android/internal/telephony/data/TelephonyNetworkRequest.java b/src/java/com/android/internal/telephony/data/TelephonyNetworkRequest.java
index b334b89..2668302 100644
--- a/src/java/com/android/internal/telephony/data/TelephonyNetworkRequest.java
+++ b/src/java/com/android/internal/telephony/data/TelephonyNetworkRequest.java
@@ -130,7 +130,9 @@
             new SimpleImmutableEntry<>(NetworkCapabilities.NET_CAPABILITY_PRIORITIZE_LATENCY,
                     CAPABILITY_ATTRIBUTE_TRAFFIC_DESCRIPTOR_OS_APP_ID),
             new SimpleImmutableEntry<>(NetworkCapabilities.NET_CAPABILITY_PRIORITIZE_BANDWIDTH,
-                    CAPABILITY_ATTRIBUTE_TRAFFIC_DESCRIPTOR_OS_APP_ID)
+                    CAPABILITY_ATTRIBUTE_TRAFFIC_DESCRIPTOR_OS_APP_ID),
+            new SimpleImmutableEntry<>(NetworkCapabilities.NET_CAPABILITY_RCS,
+                CAPABILITY_ATTRIBUTE_APN_SETTING | CAPABILITY_ATTRIBUTE_TRAFFIC_DESCRIPTOR_DNN)
     );
 
     /** The phone instance. */
diff --git a/src/java/com/android/internal/telephony/domainselection/DomainSelectionConnection.java b/src/java/com/android/internal/telephony/domainselection/DomainSelectionConnection.java
index 9a75b43..5ef8b8a 100644
--- a/src/java/com/android/internal/telephony/domainselection/DomainSelectionConnection.java
+++ b/src/java/com/android/internal/telephony/domainselection/DomainSelectionConnection.java
@@ -21,7 +21,6 @@
 import android.os.AsyncResult;
 import android.os.CancellationSignal;
 import android.os.Handler;
-import android.os.HandlerThread;
 import android.os.Looper;
 import android.os.Message;
 import android.telephony.AccessNetworkConstants.RadioAccessNetworkType;
@@ -44,8 +43,6 @@
 import java.io.PrintWriter;
 import java.util.List;
 import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.Executor;
-import java.util.concurrent.Executors;
 import java.util.function.Consumer;
 
 
@@ -74,42 +71,63 @@
     private final class TransportSelectorCallbackWrapper implements TransportSelectorCallback {
         @Override
         public void onCreated(@NonNull DomainSelector selector) {
-            mDomainSelector = selector;
-            DomainSelectionConnection.this.onCreated();
+            synchronized (mLock) {
+                mDomainSelector = selector;
+                if (mDisposed) {
+                    mDomainSelector.cancelSelection();
+                    return;
+                }
+                DomainSelectionConnection.this.onCreated();
+            }
         }
 
         @Override
         public void onWlanSelected(boolean useEmergencyPdn) {
-            DomainSelectionConnection.this.onWlanSelected(useEmergencyPdn);
+            synchronized (mLock) {
+                if (mDisposed) return;
+                DomainSelectionConnection.this.onWlanSelected(useEmergencyPdn);
+            }
         }
 
         @Override
         public @NonNull WwanSelectorCallback onWwanSelected() {
-            if (mWwanSelectorCallback == null) {
-                mWwanSelectorCallback = new WwanSelectorCallbackWrapper();
+            synchronized (mLock) {
+                if (mWwanSelectorCallback == null) {
+                    mWwanSelectorCallback = new WwanSelectorCallbackWrapper();
+                }
+                if (mDisposed) {
+                    return mWwanSelectorCallback;
+                }
+                DomainSelectionConnection.this.onWwanSelected();
+                return mWwanSelectorCallback;
             }
-            DomainSelectionConnection.this.onWwanSelected();
-            return mWwanSelectorCallback;
         }
 
         @Override
         public void onWwanSelected(final Consumer<WwanSelectorCallback> consumer) {
-            if (mWwanSelectorCallback == null) {
-                mWwanSelectorCallback = new WwanSelectorCallbackWrapper();
+            synchronized (mLock) {
+                if (mDisposed) return;
+                if (mWwanSelectorCallback == null) {
+                    mWwanSelectorCallback = new WwanSelectorCallbackWrapper();
+                }
+                initHandler();
+                mHandler.post(() -> {
+                    synchronized (mLock) {
+                        if (mDisposed) return;
+                        DomainSelectionConnection.this.onWwanSelected();
+                        consumer.accept(mWwanSelectorCallback);
+                    }
+                });
             }
-            if (mWwanSelectedExecutor == null) {
-                mWwanSelectedExecutor = Executors.newSingleThreadExecutor();
-            }
-            mWwanSelectedExecutor.execute(() -> {
-                DomainSelectionConnection.this.onWwanSelected();
-                consumer.accept(mWwanSelectorCallback);
-            });
         }
 
         @Override
         public void onSelectionTerminated(int cause) {
-            DomainSelectionConnection.this.onSelectionTerminated(cause);
-            dispose();
+            synchronized (mLock) {
+                if (mDisposed) return;
+                DomainSelectionConnection.this.onSelectionTerminated(cause);
+                dispose();
+            }
         }
     }
 
@@ -120,22 +138,38 @@
         public void onRequestEmergencyNetworkScan(@NonNull List<Integer> preferredNetworks,
                 @EmergencyScanType int scanType, @NonNull CancellationSignal signal,
                 @NonNull Consumer<EmergencyRegResult> consumer) {
-            if (signal != null) signal.setOnCancelListener(this);
-            mResultCallback = consumer;
-            initHandler();
-            DomainSelectionConnection.this.onRequestEmergencyNetworkScan(
-                    preferredNetworks.stream().mapToInt(Integer::intValue).toArray(), scanType);
+            synchronized (mLock) {
+                if (mDisposed) return;
+                if (signal != null) signal.setOnCancelListener(this);
+                mResultCallback = consumer;
+                initHandler();
+                mHandler.post(() -> {
+                    synchronized (mLock) {
+                        DomainSelectionConnection.this.onRequestEmergencyNetworkScan(
+                                preferredNetworks.stream().mapToInt(Integer::intValue).toArray(),
+                                scanType);
+                    }
+                });
+            }
         }
 
         @Override
         public void onDomainSelected(@NetworkRegistrationInfo.Domain int domain,
                 boolean useEmergencyPdn) {
-            DomainSelectionConnection.this.onDomainSelected(domain, useEmergencyPdn);
+            synchronized (mLock) {
+                if (mDisposed) return;
+                DomainSelectionConnection.this.onDomainSelected(domain, useEmergencyPdn);
+            }
         }
 
         @Override
         public void onCancel() {
-            DomainSelectionConnection.this.onCancel();
+            synchronized (mLock) {
+                if (mDisposed || mHandler == null) return;
+                mHandler.post(() -> {
+                    DomainSelectionConnection.this.onCancel();
+                });
+            }
         }
     }
 
@@ -156,7 +190,7 @@
                     if (DBG) logd("EVENT_EMERGENCY_NETWORK_SCAN_RESULT result=" + regResult);
                     CompletableFuture.runAsync(
                             () -> mResultCallback.accept(regResult),
-                            mController.getDomainSelectionServiceExecutor()).join();
+                            mController.getDomainSelectionServiceExecutor());
                     break;
                 case EVENT_QUALIFIED_NETWORKS_CHANGED:
                     onQualifiedNetworksChanged();
@@ -170,6 +204,8 @@
 
     protected String mTag = "DomainSelectionConnection";
 
+    private boolean mDisposed = false;
+    private final Object mLock = new Object();
     private final LocalLog mLocalLog = new LocalLog(30);
     private final @NonNull TransportSelectorCallback mTransportSelectorCallback;
 
@@ -196,15 +232,13 @@
     /** The attributes required to determine the domain. */
     private @Nullable DomainSelectionService.SelectionAttributes mSelectionAttributes;
 
-    private @Nullable Looper mLooper;
+    private final @NonNull Looper mLooper;
     protected @Nullable DomainSelectionConnectionHandler mHandler;
     private boolean mRegisteredRegistrant;
     private boolean mIsWaitingForScanResult;
 
     private @NonNull AndroidFuture<Integer> mOnComplete;
 
-    private @Nullable Executor mWwanSelectedExecutor;
-
     /**
      * Creates an instance.
      *
@@ -220,6 +254,7 @@
         mPhone = phone;
         mSelectorType = selectorType;
         mIsEmergency = isEmergency;
+        mLooper = Looper.getMainLooper();
 
         mTransportSelectorCallback = new TransportSelectorCallbackWrapper();
         mOnComplete = new AndroidFuture<>();
@@ -323,6 +358,8 @@
     public void onRequestEmergencyNetworkScan(
             @NonNull @RadioAccessNetworkType int[] preferredNetworks,
             @EmergencyScanType int scanType) {
+        if (mHandler == null) return;
+
         // Can be overridden if required
         if (!mRegisteredRegistrant) {
             mPhone.registerForEmergencyNetworkScan(mHandler,
@@ -376,9 +413,12 @@
      * to clean up all ongoing operations with the framework.
      */
     public void cancelSelection() {
-        if (mDomainSelector == null) return;
-        mDomainSelector.cancelSelection();
-        dispose();
+        synchronized (mLock) {
+            if (mDomainSelector != null) {
+                mDomainSelector.cancelSelection();
+            }
+            dispose();
+        }
     }
 
     /**
@@ -400,9 +440,12 @@
      * Finishes the selection procedure and cleans everything up.
      */
     public void finishSelection() {
-        if (mDomainSelector == null) return;
-        mDomainSelector.finishSelection();
-        dispose();
+        synchronized (mLock) {
+            if (mDomainSelector != null) {
+                mDomainSelector.finishSelection();
+            }
+            dispose();
+        }
     }
 
     /** Indicates that the service connection has been removed. */
@@ -412,23 +455,18 @@
     }
 
     private void dispose() {
+        mDisposed = true;
         if (mRegisteredRegistrant) {
             mPhone.unregisterForEmergencyNetworkScan(mHandler);
             mRegisteredRegistrant = false;
         }
         onCancel(true);
         mController.removeConnection(this);
-        if (mLooper != null) mLooper.quitSafely();
-        mLooper = null;
+        if (mHandler != null) mHandler.removeCallbacksAndMessages(null);
         mHandler = null;
     }
 
     protected void initHandler() {
-        if (mLooper == null) {
-            HandlerThread handlerThread = new HandlerThread(mTag);
-            handlerThread.start();
-            mLooper = handlerThread.getLooper();
-        }
         if (mHandler == null) mHandler = new DomainSelectionConnectionHandler(mLooper);
     }
 
diff --git a/src/java/com/android/internal/telephony/emergency/EmergencyNumberTracker.java b/src/java/com/android/internal/telephony/emergency/EmergencyNumberTracker.java
index 9b44001..e2418c5 100644
--- a/src/java/com/android/internal/telephony/emergency/EmergencyNumberTracker.java
+++ b/src/java/com/android/internal/telephony/emergency/EmergencyNumberTracker.java
@@ -935,6 +935,23 @@
     }
 
     /**
+     * Get a list of the {@link EmergencyNumber}s that have the corresponding emergency number.
+     * Note: {@link #getEmergencyNumber(String)} assumes there is ONLY one record for a phone number
+     * when in reality there CAN be multiple instances if the same number is reported by the radio
+     * for a specific mcc and the emergency number database specifies the number without an mcc
+     * specified.
+     *
+     * @param emergencyNumber the emergency number to find.
+     * @return the list of emergency numbers matching.
+     */
+    public List<EmergencyNumber> getEmergencyNumbers(String emergencyNumber) {
+        final String toFind = PhoneNumberUtils.stripSeparators(emergencyNumber);
+        return getEmergencyNumberList().stream()
+                .filter(num -> num.getNumber().equals(toFind))
+                .toList();
+    }
+
+    /**
      * Get the emergency service categories for the corresponding emergency number. The only
      * trusted sources for the categories are the
      * {@link EmergencyNumber#EMERGENCY_NUMBER_SOURCE_NETWORK_SIGNALING} and
diff --git a/src/java/com/android/internal/telephony/emergency/EmergencyStateTracker.java b/src/java/com/android/internal/telephony/emergency/EmergencyStateTracker.java
index a45e956..23473d2 100644
--- a/src/java/com/android/internal/telephony/emergency/EmergencyStateTracker.java
+++ b/src/java/com/android/internal/telephony/emergency/EmergencyStateTracker.java
@@ -47,7 +47,6 @@
 import android.telephony.ServiceState;
 import android.telephony.SubscriptionManager;
 import android.telephony.TelephonyManager;
-import android.telephony.emergency.EmergencyNumber;
 import android.util.ArraySet;
 
 import com.android.internal.annotations.VisibleForTesting;
@@ -981,9 +980,10 @@
      * This should be called once an emergency SMS is sent.
      *
      * @param smsId the SMS id on which to end the emergency SMS.
-     * @param emergencyNumber the emergency number which was used for the emergency SMS.
+     * @param success the flag specifying whether an emergency SMS is successfully sent or not.
+     *                {@code true} if SMS is successfully sent, {@code false} otherwise.
      */
-    public void endSms(@NonNull String smsId, EmergencyNumber emergencyNumber) {
+    public void endSms(@NonNull String smsId, boolean success) {
         mOngoingEmergencySmsIds.remove(smsId);
 
         // If the outgoing emergency SMSs are empty, we can try to exit the emergency mode.
diff --git a/src/java/com/android/internal/telephony/gsm/GsmSMSDispatcher.java b/src/java/com/android/internal/telephony/gsm/GsmSMSDispatcher.java
index 5b1f36d..dae808a 100644
--- a/src/java/com/android/internal/telephony/gsm/GsmSMSDispatcher.java
+++ b/src/java/com/android/internal/telephony/gsm/GsmSMSDispatcher.java
@@ -171,6 +171,7 @@
             if(mPhone.getServiceState().getRilDataRadioTechnology()
                     != ServiceState.RIL_RADIO_TECHNOLOGY_NR) {
                 tracker.onFailed(mContext, getNotInServiceError(ss), NO_ERROR_CODE);
+                notifySmsSentFailedToEmergencyStateTracker(tracker);
                 return;
             }
         }
diff --git a/src/java/com/android/internal/telephony/metrics/ImsStats.java b/src/java/com/android/internal/telephony/metrics/ImsStats.java
index 427595f..2420602 100644
--- a/src/java/com/android/internal/telephony/metrics/ImsStats.java
+++ b/src/java/com/android/internal/telephony/metrics/ImsStats.java
@@ -197,7 +197,7 @@
     @ImsRegistrationState private int mLastRegistrationState = REGISTRATION_STATE_NOT_REGISTERED;
 
     private long mLastTimestamp;
-    @Nullable private ImsRegistrationStats mLastRegistrationStats;
+    private ImsRegistrationStats mLastRegistrationStats;
     @TransportType int mLastTransportType = AccessNetworkConstants.TRANSPORT_TYPE_INVALID;
     // Available features are those reported by ImsService to be available for use.
     private MmTelCapabilities mLastAvailableFeatures = new MmTelCapabilities();
@@ -210,6 +210,10 @@
     public ImsStats(ImsPhone phone) {
         mPhone = phone;
         mStorage = PhoneFactory.getMetricsCollector().getAtomsStorage();
+
+        mLastRegistrationStats = getDefaultImsRegistrationStats();
+        updateImsRegistrationStats();
+        mLastTimestamp = getTimeMillis();
     }
 
     /**
@@ -221,40 +225,46 @@
     public synchronized void conclude() {
         long now = getTimeMillis();
 
-        // Currently not tracking time spent on registering.
-        if (mLastRegistrationState == REGISTRATION_STATE_REGISTERED) {
-            ImsRegistrationStats stats = copyOf(mLastRegistrationStats);
-            long duration = now - mLastTimestamp;
+        long duration = now - mLastTimestamp;
+        if (duration < MIN_REGISTRATION_DURATION_MILLIS) {
+            logw("conclude: discarding transient stats, duration=%d", duration);
+        } else {
+            ImsRegistrationStats stats = copyOfDimensionsOnly(mLastRegistrationStats);
 
-            if (duration < MIN_REGISTRATION_DURATION_MILLIS) {
-                logw("conclude: discarding transient stats, duration=%d", duration);
-            } else {
-                stats.registeredMillis = duration;
+            switch (mLastRegistrationState) {
+                case REGISTRATION_STATE_REGISTERED:
+                    stats.registeredMillis = duration;
 
-                stats.voiceAvailableMillis =
-                        mLastAvailableFeatures.isCapable(CAPABILITY_TYPE_VOICE) ? duration : 0;
-                stats.videoAvailableMillis =
-                        mLastAvailableFeatures.isCapable(CAPABILITY_TYPE_VIDEO) ? duration : 0;
-                stats.utAvailableMillis =
-                        mLastAvailableFeatures.isCapable(CAPABILITY_TYPE_UT) ? duration : 0;
-                stats.smsAvailableMillis =
-                        mLastAvailableFeatures.isCapable(CAPABILITY_TYPE_SMS) ? duration : 0;
+                    stats.voiceAvailableMillis =
+                            mLastAvailableFeatures.isCapable(CAPABILITY_TYPE_VOICE) ? duration : 0;
+                    stats.videoAvailableMillis =
+                            mLastAvailableFeatures.isCapable(CAPABILITY_TYPE_VIDEO) ? duration : 0;
+                    stats.utAvailableMillis =
+                            mLastAvailableFeatures.isCapable(CAPABILITY_TYPE_UT) ? duration : 0;
+                    stats.smsAvailableMillis =
+                            mLastAvailableFeatures.isCapable(CAPABILITY_TYPE_SMS) ? duration : 0;
 
-                MmTelCapabilities lastCapableFeatures =
-                        stats.rat == TelephonyManager.NETWORK_TYPE_IWLAN
-                                ? mLastWlanCapableFeatures
-                                : mLastWwanCapableFeatures;
-                stats.voiceCapableMillis =
-                        lastCapableFeatures.isCapable(CAPABILITY_TYPE_VOICE) ? duration : 0;
-                stats.videoCapableMillis =
-                        lastCapableFeatures.isCapable(CAPABILITY_TYPE_VIDEO) ? duration : 0;
-                stats.utCapableMillis =
-                        lastCapableFeatures.isCapable(CAPABILITY_TYPE_UT) ? duration : 0;
-                stats.smsCapableMillis =
-                        lastCapableFeatures.isCapable(CAPABILITY_TYPE_SMS) ? duration : 0;
-
-                mStorage.addImsRegistrationStats(stats);
+                    MmTelCapabilities lastCapableFeatures =
+                            stats.rat == TelephonyManager.NETWORK_TYPE_IWLAN
+                                    ? mLastWlanCapableFeatures
+                                    : mLastWwanCapableFeatures;
+                    stats.voiceCapableMillis =
+                            lastCapableFeatures.isCapable(CAPABILITY_TYPE_VOICE) ? duration : 0;
+                    stats.videoCapableMillis =
+                            lastCapableFeatures.isCapable(CAPABILITY_TYPE_VIDEO) ? duration : 0;
+                    stats.utCapableMillis =
+                            lastCapableFeatures.isCapable(CAPABILITY_TYPE_UT) ? duration : 0;
+                    stats.smsCapableMillis =
+                            lastCapableFeatures.isCapable(CAPABILITY_TYPE_SMS) ? duration : 0;
+                    break;
+                case REGISTRATION_STATE_REGISTERING:
+                    stats.registeringMillis = duration;
+                    break;
+                case REGISTRATION_STATE_NOT_REGISTERED:
+                    stats.unregisteredMillis = duration;
+                    break;
             }
+            mStorage.addImsRegistrationStats(stats);
         }
 
         mLastTimestamp = now;
@@ -271,7 +281,7 @@
                 (newRat == TelephonyManager.NETWORK_TYPE_IWLAN)
                         ? AccessNetworkConstants.TRANSPORT_TYPE_WLAN
                         : AccessNetworkConstants.TRANSPORT_TYPE_WWAN;
-        if (mLastRegistrationStats != null && mLastRegistrationStats.rat != newRat) {
+        if (mLastRegistrationStats.rat != newRat) {
             mLastRegistrationStats.rat = newRat;
             ratChanged = true;
         }
@@ -308,7 +318,7 @@
         conclude();
 
         mLastTransportType = imsRadioTech;
-        mLastRegistrationStats = getDefaultImsRegistrationStats();
+        updateImsRegistrationStats();
         mLastRegistrationStats.rat = convertTransportTypeToNetworkType(imsRadioTech);
         mLastRegistrationState = REGISTRATION_STATE_REGISTERING;
     }
@@ -318,9 +328,9 @@
         conclude();
 
         mLastTransportType = imsRadioTech;
-        // NOTE: mLastRegistrationStats can be null (no registering phase).
-        if (mLastRegistrationStats == null) {
-            mLastRegistrationStats = getDefaultImsRegistrationStats();
+        // NOTE: status can be unregistered (no registering phase)
+        if (mLastRegistrationState == REGISTRATION_STATE_NOT_REGISTERED) {
+            updateImsRegistrationStats();
         }
         mLastRegistrationStats.rat = convertTransportTypeToNetworkType(imsRadioTech);
         mLastRegistrationState = REGISTRATION_STATE_REGISTERED;
@@ -331,16 +341,14 @@
         conclude();
 
         // Generate end reason atom.
-        // NOTE: mLastRegistrationStats can be null (no registering phase).
         ImsRegistrationTermination termination = new ImsRegistrationTermination();
-        if (mLastRegistrationStats != null) {
+        if (mLastRegistrationState != REGISTRATION_STATE_NOT_REGISTERED) {
             termination.carrierId = mLastRegistrationStats.carrierId;
-            termination.ratAtEnd = getRatAtEnd(mLastRegistrationStats.rat);
         } else {
+            // if the registration state is from unregistered to unregistered.
             termination.carrierId = mPhone.getDefaultPhone().getCarrierId();
-            // We cannot tell whether the registration was intended for WWAN or WLAN
-            termination.ratAtEnd = TelephonyManager.NETWORK_TYPE_UNKNOWN;
         }
+        termination.ratAtEnd = getRatAtEnd(mLastRegistrationStats.rat);
         termination.isMultiSim = SimSlotState.isMultiSim();
         termination.setupFailed = (mLastRegistrationState != REGISTRATION_STATE_REGISTERED);
         termination.reasonCode = reasonInfo.getCode();
@@ -351,14 +359,14 @@
 
         // Reset state to unregistered.
         mLastRegistrationState = REGISTRATION_STATE_NOT_REGISTERED;
-        mLastRegistrationStats = null;
+        mLastRegistrationStats.rat = TelephonyManager.NETWORK_TYPE_UNKNOWN;
         mLastAvailableFeatures = new MmTelCapabilities();
     }
 
     /** Updates the RAT when service state changes. */
     public synchronized void onServiceStateChanged(ServiceState state) {
         if (mLastTransportType == AccessNetworkConstants.TRANSPORT_TYPE_WWAN
-                && mLastRegistrationStats != null) {
+                && mLastRegistrationState != REGISTRATION_STATE_NOT_REGISTERED) {
             mLastRegistrationStats.rat =
                     ServiceStateStats.getRat(state, NetworkRegistrationInfo.DOMAIN_PS);
         }
@@ -370,7 +378,7 @@
      */
     @NetworkType
     public synchronized int getImsVoiceRadioTech() {
-        if (mLastRegistrationStats == null
+        if (mLastRegistrationState == REGISTRATION_STATE_NOT_REGISTERED
                 || !mLastAvailableFeatures.isCapable(CAPABILITY_TYPE_VOICE)) {
             return TelephonyManager.NETWORK_TYPE_UNKNOWN;
         }
@@ -404,11 +412,16 @@
     private ImsRegistrationStats getDefaultImsRegistrationStats() {
         Phone phone = mPhone.getDefaultPhone();
         ImsRegistrationStats stats = new ImsRegistrationStats();
-        stats.carrierId = phone.getCarrierId();
-        stats.simSlotIndex = phone.getPhoneId();
+        stats.rat = TelephonyManager.NETWORK_TYPE_UNKNOWN;
         return stats;
     }
 
+    private void updateImsRegistrationStats() {
+        Phone phone = mPhone.getDefaultPhone();
+        mLastRegistrationStats.carrierId = phone.getCarrierId();
+        mLastRegistrationStats.simSlotIndex = phone.getPhoneId();
+    }
+
     @Nullable
     private MmTelCapabilities getLastCapableFeaturesForTech(@ImsRegistrationTech int radioTech) {
         switch (radioTech) {
@@ -438,21 +451,12 @@
         }
     }
 
-    private static ImsRegistrationStats copyOf(ImsRegistrationStats source) {
+    private static ImsRegistrationStats copyOfDimensionsOnly(ImsRegistrationStats source) {
         ImsRegistrationStats dest = new ImsRegistrationStats();
 
         dest.carrierId = source.carrierId;
         dest.simSlotIndex = source.simSlotIndex;
         dest.rat = source.rat;
-        dest.registeredMillis = source.registeredMillis;
-        dest.voiceCapableMillis = source.voiceCapableMillis;
-        dest.voiceAvailableMillis = source.voiceAvailableMillis;
-        dest.smsCapableMillis = source.smsCapableMillis;
-        dest.smsAvailableMillis = source.smsAvailableMillis;
-        dest.videoCapableMillis = source.videoCapableMillis;
-        dest.videoAvailableMillis = source.videoAvailableMillis;
-        dest.utCapableMillis = source.utCapableMillis;
-        dest.utAvailableMillis = source.utAvailableMillis;
 
         return dest;
     }
diff --git a/src/java/com/android/internal/telephony/metrics/MetricsCollector.java b/src/java/com/android/internal/telephony/metrics/MetricsCollector.java
index 1a53ee6..bd7ce2a 100644
--- a/src/java/com/android/internal/telephony/metrics/MetricsCollector.java
+++ b/src/java/com/android/internal/telephony/metrics/MetricsCollector.java
@@ -1077,7 +1077,9 @@
                 roundAndConvertMillisToSeconds(stats.videoCapableMillis),
                 roundAndConvertMillisToSeconds(stats.videoAvailableMillis),
                 roundAndConvertMillisToSeconds(stats.utCapableMillis),
-                roundAndConvertMillisToSeconds(stats.utAvailableMillis));
+                roundAndConvertMillisToSeconds(stats.utAvailableMillis),
+                roundAndConvertMillisToSeconds(stats.registeringMillis),
+                roundAndConvertMillisToSeconds(stats.unregisteredMillis));
     }
 
     private static StatsEvent buildStatsEvent(ImsRegistrationTermination termination) {
diff --git a/src/java/com/android/internal/telephony/metrics/PersistAtomsStorage.java b/src/java/com/android/internal/telephony/metrics/PersistAtomsStorage.java
index d495ca2..1da0c46 100644
--- a/src/java/com/android/internal/telephony/metrics/PersistAtomsStorage.java
+++ b/src/java/com/android/internal/telephony/metrics/PersistAtomsStorage.java
@@ -407,6 +407,8 @@
             existingStats.videoAvailableMillis += stats.videoAvailableMillis;
             existingStats.utCapableMillis += stats.utCapableMillis;
             existingStats.utAvailableMillis += stats.utAvailableMillis;
+            existingStats.registeringMillis += stats.registeringMillis;
+            existingStats.unregisteredMillis += stats.unregisteredMillis;
             existingStats.lastUsedMillis = getWallTimeMillis();
         } else {
             stats.lastUsedMillis = getWallTimeMillis();
@@ -2279,6 +2281,10 @@
                     normalizeDurationTo24H(stats[i].utCapableMillis, intervalMillis);
             stats[i].utAvailableMillis =
                     normalizeDurationTo24H(stats[i].utAvailableMillis, intervalMillis);
+            stats[i].registeringMillis =
+                    normalizeDurationTo24H(stats[i].registeringMillis, intervalMillis);
+            stats[i].unregisteredMillis =
+                    normalizeDurationTo24H(stats[i].unregisteredMillis, intervalMillis);
         }
         return stats;
     }
diff --git a/src/java/com/android/internal/telephony/satellite/DatagramDispatcher.java b/src/java/com/android/internal/telephony/satellite/DatagramDispatcher.java
index 591114b..6ccc3e6 100644
--- a/src/java/com/android/internal/telephony/satellite/DatagramDispatcher.java
+++ b/src/java/com/android/internal/telephony/satellite/DatagramDispatcher.java
@@ -190,50 +190,11 @@
                         (SendSatelliteDatagramArgument) request.argument;
                 onCompleted = obtainMessage(EVENT_SEND_SATELLITE_DATAGRAM_DONE, request);
 
-                if (SatelliteModemInterface.getInstance().isSatelliteServiceSupported()) {
-                    SatelliteModemInterface.getInstance().sendSatelliteDatagram(argument.datagram,
-                            argument.datagramType == SatelliteManager.DATAGRAM_TYPE_SOS_MESSAGE,
-                            argument.needFullScreenPointingUI, onCompleted);
-                    break;
-                }
-
-                Phone phone = request.phone;
-                if (phone != null) {
-                    phone.sendSatelliteDatagram(onCompleted, argument.datagram,
-                            argument.needFullScreenPointingUI);
-                } else {
-                    loge("sendSatelliteDatagram: No phone object");
-                    synchronized (mLock) {
-                        // Remove current datagram from pending map
-                        if (argument.datagramType == SatelliteManager.DATAGRAM_TYPE_SOS_MESSAGE) {
-                            mPendingEmergencyDatagramsMap.remove(argument.datagramId);
-                        } else {
-                            mPendingNonEmergencyDatagramsMap.remove(argument.datagramId);
-                        }
-
-                        // Update send status
-                        mDatagramController.updateSendStatus(argument.subId,
-                                SatelliteManager.SATELLITE_DATAGRAM_TRANSFER_STATE_SEND_FAILED,
-                                getPendingDatagramCount(),
-                                SatelliteManager.SATELLITE_RESULT_INVALID_TELEPHONY_STATE);
-                        mDatagramController.updateSendStatus(argument.subId,
-                                SatelliteManager.SATELLITE_DATAGRAM_TRANSFER_STATE_IDLE,
-                                0, SatelliteManager.SATELLITE_RESULT_SUCCESS);
-
-                        // report phone == null case
-                        reportSendDatagramCompleted(argument,
-                                SatelliteManager.SATELLITE_RESULT_INVALID_TELEPHONY_STATE);
-                        argument.callback.accept(
-                                SatelliteManager.SATELLITE_RESULT_INVALID_TELEPHONY_STATE);
-
-                        // Abort sending all the pending datagrams
-                        abortSendingPendingDatagrams(argument.subId,
-                                SatelliteManager.SATELLITE_RESULT_INVALID_TELEPHONY_STATE);
-                    }
-                }
+                SatelliteModemInterface.getInstance().sendSatelliteDatagram(argument.datagram,
+                        argument.datagramType == SatelliteManager.DATAGRAM_TYPE_SOS_MESSAGE,
+                        argument.needFullScreenPointingUI, onCompleted);
                 break;
             }
-
             case EVENT_SEND_SATELLITE_DATAGRAM_DONE: {
                 ar = (AsyncResult) msg.obj;
                 request = (DatagramDispatcherHandlerRequest) ar.userObj;
diff --git a/src/java/com/android/internal/telephony/satellite/DatagramReceiver.java b/src/java/com/android/internal/telephony/satellite/DatagramReceiver.java
index 35c78eb..fd04779 100644
--- a/src/java/com/android/internal/telephony/satellite/DatagramReceiver.java
+++ b/src/java/com/android/internal/telephony/satellite/DatagramReceiver.java
@@ -424,35 +424,7 @@
                 request = (DatagramReceiverHandlerRequest) msg.obj;
                 onCompleted =
                         obtainMessage(EVENT_POLL_PENDING_SATELLITE_DATAGRAMS_DONE, request);
-
-                if (SatelliteModemInterface.getInstance().isSatelliteServiceSupported()) {
-                    SatelliteModemInterface.getInstance()
-                            .pollPendingSatelliteDatagrams(onCompleted);
-                    break;
-                }
-
-                Phone phone = request.phone;
-                if (phone != null) {
-                    phone.pollPendingSatelliteDatagrams(onCompleted);
-                } else {
-                    loge("pollPendingSatelliteDatagrams: No phone object");
-                    mDatagramController.updateReceiveStatus(request.subId,
-                            SatelliteManager.SATELLITE_DATAGRAM_TRANSFER_STATE_RECEIVE_FAILED,
-                            mDatagramController.getReceivePendingCount(),
-                            SatelliteManager.SATELLITE_RESULT_INVALID_TELEPHONY_STATE);
-
-                    mDatagramController.updateReceiveStatus(request.subId,
-                            SatelliteManager.SATELLITE_DATAGRAM_TRANSFER_STATE_IDLE,
-                            mDatagramController.getReceivePendingCount(),
-                            SatelliteManager.SATELLITE_RESULT_SUCCESS);
-
-                    reportMetrics(null, SatelliteManager.SATELLITE_RESULT_INVALID_TELEPHONY_STATE);
-                    mControllerMetricsStats.reportIncomingDatagramCount(
-                                    SatelliteManager.SATELLITE_RESULT_INVALID_TELEPHONY_STATE);
-                    // Send response for current request
-                    ((Consumer<Integer>) request.argument)
-                            .accept(SatelliteManager.SATELLITE_RESULT_INVALID_TELEPHONY_STATE);
-                }
+                SatelliteModemInterface.getInstance().pollPendingSatelliteDatagrams(onCompleted);
                 break;
             }
 
@@ -534,15 +506,9 @@
         if (satelliteDatagramListenerHandler == null) {
             satelliteDatagramListenerHandler = new SatelliteDatagramListenerHandler(
                     mLooper, validSubId);
-            if (SatelliteModemInterface.getInstance().isSatelliteServiceSupported()) {
-                SatelliteModemInterface.getInstance().registerForSatelliteDatagramsReceived(
-                        satelliteDatagramListenerHandler,
-                        SatelliteDatagramListenerHandler.EVENT_SATELLITE_DATAGRAM_RECEIVED, null);
-            } else {
-                Phone phone = SatelliteServiceUtils.getPhone();
-                phone.registerForSatelliteDatagramsReceived(satelliteDatagramListenerHandler,
-                        SatelliteDatagramListenerHandler.EVENT_SATELLITE_DATAGRAM_RECEIVED, null);
-            }
+            SatelliteModemInterface.getInstance().registerForSatelliteDatagramsReceived(
+                    satelliteDatagramListenerHandler,
+                    SatelliteDatagramListenerHandler.EVENT_SATELLITE_DATAGRAM_RECEIVED, null);
         }
 
         satelliteDatagramListenerHandler.addListener(callback);
@@ -568,15 +534,8 @@
 
             if (!handler.hasListeners()) {
                 mSatelliteDatagramListenerHandlers.remove(validSubId);
-                if (SatelliteModemInterface.getInstance().isSatelliteServiceSupported()) {
-                    SatelliteModemInterface.getInstance()
-                            .unregisterForSatelliteDatagramsReceived(handler);
-                } else {
-                    Phone phone = SatelliteServiceUtils.getPhone();
-                    if (phone != null) {
-                        phone.unregisterForSatelliteDatagramsReceived(handler);
-                    }
-                }
+                SatelliteModemInterface.getInstance().unregisterForSatelliteDatagramsReceived(
+                        handler);
             }
         }
     }
diff --git a/src/java/com/android/internal/telephony/satellite/PointingAppController.java b/src/java/com/android/internal/telephony/satellite/PointingAppController.java
index 70d432e..9a6bd69 100644
--- a/src/java/com/android/internal/telephony/satellite/PointingAppController.java
+++ b/src/java/com/android/internal/telephony/satellite/PointingAppController.java
@@ -42,7 +42,6 @@
 
 import com.android.internal.R;
 import com.android.internal.annotations.VisibleForTesting;
-import com.android.internal.telephony.Phone;
 
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -276,31 +275,24 @@
      * Register to start receiving updates for satellite position and datagram transfer state
      * @param subId The subId of the subscription to register for receiving the updates.
      * @param callback The callback to notify of satellite transmission updates.
-     * @param phone The Phone object to unregister for receiving the updates.
      */
     public void registerForSatelliteTransmissionUpdates(int subId,
-            ISatelliteTransmissionUpdateCallback callback, Phone phone) {
+            ISatelliteTransmissionUpdateCallback callback) {
         SatelliteTransmissionUpdateHandler handler =
                 mSatelliteTransmissionUpdateHandlers.get(subId);
         if (handler != null) {
             handler.addListener(callback);
-            return;
         } else {
             handler = new SatelliteTransmissionUpdateHandler(Looper.getMainLooper());
             handler.addListener(callback);
             mSatelliteTransmissionUpdateHandlers.put(subId, handler);
-            if (SatelliteModemInterface.getInstance().isSatelliteServiceSupported()) {
-                SatelliteModemInterface.getInstance().registerForSatellitePositionInfoChanged(
-                        handler, SatelliteTransmissionUpdateHandler.EVENT_POSITION_INFO_CHANGED,
-                        null);
-                SatelliteModemInterface.getInstance().registerForDatagramTransferStateChanged(
-                        handler,
-                        SatelliteTransmissionUpdateHandler.EVENT_DATAGRAM_TRANSFER_STATE_CHANGED,
-                        null);
-            } else {
-                phone.registerForSatellitePositionInfoChanged(handler,
-                        SatelliteTransmissionUpdateHandler.EVENT_POSITION_INFO_CHANGED, null);
-            }
+            SatelliteModemInterface.getInstance().registerForSatellitePositionInfoChanged(
+                    handler, SatelliteTransmissionUpdateHandler.EVENT_POSITION_INFO_CHANGED,
+                    null);
+            SatelliteModemInterface.getInstance().registerForDatagramTransferStateChanged(
+                    handler,
+                    SatelliteTransmissionUpdateHandler.EVENT_DATAGRAM_TRANSFER_STATE_CHANGED,
+                    null);
         }
     }
 
@@ -310,11 +302,10 @@
      * @param subId The subId of the subscription to unregister for receiving the updates.
      * @param result The callback to get the error code in case of failure
      * @param callback The callback that was passed to {@link
-     * #registerForSatelliteTransmissionUpdates(int, ISatelliteTransmissionUpdateCallback, Phone)}.
-     * @param phone The Phone object to unregister for receiving the updates
+     * #registerForSatelliteTransmissionUpdates(int, ISatelliteTransmissionUpdateCallback)}.
      */
     public void unregisterForSatelliteTransmissionUpdates(int subId, Consumer<Integer> result,
-            ISatelliteTransmissionUpdateCallback callback, Phone phone) {
+            ISatelliteTransmissionUpdateCallback callback) {
         SatelliteTransmissionUpdateHandler handler =
                 mSatelliteTransmissionUpdateHandlers.get(subId);
         if (handler != null) {
@@ -323,20 +314,11 @@
                 result.accept(SatelliteManager.SATELLITE_RESULT_SUCCESS);
                 return;
             }
-
             mSatelliteTransmissionUpdateHandlers.remove(subId);
-            if (SatelliteModemInterface.getInstance().isSatelliteServiceSupported()) {
-                SatelliteModemInterface.getInstance().unregisterForSatellitePositionInfoChanged(
-                        handler);
-                SatelliteModemInterface.getInstance().unregisterForDatagramTransferStateChanged(
-                        handler);
-            } else {
-                if (phone == null) {
-                    result.accept(SatelliteManager.SATELLITE_RESULT_INVALID_TELEPHONY_STATE);
-                    return;
-                }
-                phone.unregisterForSatellitePositionInfoChanged(handler);
-            }
+
+            SatelliteModemInterface satelliteModemInterface = SatelliteModemInterface.getInstance();
+            satelliteModemInterface.unregisterForSatellitePositionInfoChanged(handler);
+            satelliteModemInterface.unregisterForDatagramTransferStateChanged(handler);
         }
     }
 
@@ -348,7 +330,7 @@
      * {@link android.telephony.satellite.SatelliteTransmissionUpdateCallback
      * #onSatellitePositionChanged(pointingInfo)}.
      */
-    public void startSatelliteTransmissionUpdates(@NonNull Message message, @Nullable Phone phone) {
+    public void startSatelliteTransmissionUpdates(@NonNull Message message) {
         if (mStartedSatelliteTransmissionUpdates) {
             logd("startSatelliteTransmissionUpdates: already started");
             AsyncResult.forMessage(message, null, new SatelliteManager.SatelliteException(
@@ -356,20 +338,8 @@
             message.sendToTarget();
             return;
         }
-        if (SatelliteModemInterface.getInstance().isSatelliteServiceSupported()) {
-            SatelliteModemInterface.getInstance().startSendingSatellitePointingInfo(message);
-            mStartedSatelliteTransmissionUpdates = true;
-            return;
-        }
-        if (phone != null) {
-            phone.startSatellitePositionUpdates(message);
-            mStartedSatelliteTransmissionUpdates = true;
-        } else {
-            loge("startSatelliteTransmissionUpdates: No phone object");
-            AsyncResult.forMessage(message, null, new SatelliteManager.SatelliteException(
-                    SatelliteManager.SATELLITE_RESULT_INVALID_TELEPHONY_STATE));
-            message.sendToTarget();
-        }
+        SatelliteModemInterface.getInstance().startSendingSatellitePointingInfo(message);
+        mStartedSatelliteTransmissionUpdates = true;
     }
 
     /**
@@ -377,20 +347,9 @@
      * Reset the flag mStartedSatelliteTransmissionUpdates
      * This can be called by the pointing UI when the user stops pointing to the satellite.
      */
-    public void stopSatelliteTransmissionUpdates(@NonNull Message message, @Nullable Phone phone) {
+    public void stopSatelliteTransmissionUpdates(@NonNull Message message) {
         setStartedSatelliteTransmissionUpdates(false);
-        if (SatelliteModemInterface.getInstance().isSatelliteServiceSupported()) {
-            SatelliteModemInterface.getInstance().stopSendingSatellitePointingInfo(message);
-            return;
-        }
-        if (phone != null) {
-            phone.stopSatellitePositionUpdates(message);
-        } else {
-            loge("startSatelliteTransmissionUpdates: No phone object");
-            AsyncResult.forMessage(message, null, new SatelliteManager.SatelliteException(
-                    SatelliteManager.SATELLITE_RESULT_INVALID_TELEPHONY_STATE));
-            message.sendToTarget();
-        }
+        SatelliteModemInterface.getInstance().stopSendingSatellitePointingInfo(message);
     }
 
     /**
diff --git a/src/java/com/android/internal/telephony/satellite/SatelliteController.java b/src/java/com/android/internal/telephony/satellite/SatelliteController.java
index cb68fcb..896063f 100644
--- a/src/java/com/android/internal/telephony/satellite/SatelliteController.java
+++ b/src/java/com/android/internal/telephony/satellite/SatelliteController.java
@@ -18,7 +18,10 @@
 
 import static android.telephony.SubscriptionManager.SATELLITE_ATTACH_ENABLED_FOR_CARRIER;
 import static android.telephony.SubscriptionManager.isValidSubscriptionId;
+import static android.telephony.satellite.NtnSignalStrength.NTN_SIGNAL_STRENGTH_NONE;
+import static android.telephony.satellite.SatelliteManager.KEY_NTN_SIGNAL_STRENGTH;
 import static android.telephony.satellite.SatelliteManager.SATELLITE_COMMUNICATION_RESTRICTION_REASON_USER;
+import static android.telephony.satellite.SatelliteManager.SATELLITE_RESULT_SUCCESS;
 
 import android.annotation.ArrayRes;
 import android.annotation.NonNull;
@@ -54,10 +57,12 @@
 import android.telephony.Rlog;
 import android.telephony.SubscriptionManager;
 import android.telephony.TelephonyManager;
+import android.telephony.satellite.INtnSignalStrengthCallback;
 import android.telephony.satellite.ISatelliteDatagramCallback;
 import android.telephony.satellite.ISatelliteProvisionStateCallback;
 import android.telephony.satellite.ISatelliteStateCallback;
 import android.telephony.satellite.ISatelliteTransmissionUpdateCallback;
+import android.telephony.satellite.NtnSignalStrength;
 import android.telephony.satellite.SatelliteCapabilities;
 import android.telephony.satellite.SatelliteDatagram;
 import android.telephony.satellite.SatelliteManager;
@@ -69,6 +74,7 @@
 import com.android.internal.annotations.GuardedBy;
 import com.android.internal.annotations.VisibleForTesting;
 import com.android.internal.telephony.CommandsInterface;
+import com.android.internal.telephony.DeviceStateMonitor;
 import com.android.internal.telephony.IIntegerConsumer;
 import com.android.internal.telephony.Phone;
 import com.android.internal.telephony.flags.FeatureFlags;
@@ -137,6 +143,11 @@
     private static final int EVENT_SET_SATELLITE_PLMN_INFO_DONE = 29;
     private static final int CMD_EVALUATE_SATELLITE_ATTACH_RESTRICTION_CHANGE = 30;
     private static final int EVENT_EVALUATE_SATELLITE_ATTACH_RESTRICTION_CHANGE_DONE = 31;
+    private static final int CMD_REQUEST_NTN_SIGNAL_STRENGTH = 32;
+    private static final int EVENT_REQUEST_NTN_SIGNAL_STRENGTH_DONE = 33;
+    private static final int EVENT_NTN_SIGNAL_STRENGTH_CHANGED = 34;
+    private static final int CMD_START_SENDING_NTN_SIGNAL_STRENGTH = 35;
+    private static final int EVENT_UPDATE_SIGNAL_STRENGTH_REPORTING = 36;
 
     @NonNull private static SatelliteController sInstance;
     @NonNull private final Context mContext;
@@ -149,6 +160,7 @@
     @NonNull private final SubscriptionManagerService mSubscriptionManagerService;
     private final CommandsInterface mCi;
     private ContentResolver mContentResolver = null;
+    private final DeviceStateMonitor mDSM;
 
     private final Object mRadioStateLock = new Object();
 
@@ -182,16 +194,11 @@
 
     private final AtomicBoolean mRegisteredForProvisionStateChangedWithSatelliteService =
             new AtomicBoolean(false);
-    private final AtomicBoolean mRegisteredForProvisionStateChangedWithPhone =
-            new AtomicBoolean(false);
     private final AtomicBoolean mRegisteredForPendingDatagramCountWithSatelliteService =
             new AtomicBoolean(false);
-    private final AtomicBoolean mRegisteredForPendingDatagramCountWithPhone =
-            new AtomicBoolean(false);
     private final AtomicBoolean mRegisteredForSatelliteModemStateChangedWithSatelliteService =
             new AtomicBoolean(false);
-    private final AtomicBoolean mRegisteredForSatelliteModemStateChangedWithPhone =
-            new AtomicBoolean(false);
+    private final AtomicBoolean mRegisteredForNtnSignalStrengthChanged = new AtomicBoolean(false);
     /**
      * Map key: subId, value: callback to get error code of the provision request.
      */
@@ -203,6 +210,12 @@
      */
     private final ConcurrentHashMap<IBinder, ISatelliteProvisionStateCallback>
             mSatelliteProvisionStateChangedListeners = new ConcurrentHashMap<>();
+    /**
+     * Map key: binder of the callback, value: callback to receive non-terrestrial signal strength
+     * state changed events.
+     */
+    private final ConcurrentHashMap<IBinder, INtnSignalStrengthCallback>
+            mNtnSignalStrengthChangedListeners = new ConcurrentHashMap<>();
     private final Object mIsSatelliteSupportedLock = new Object();
     @GuardedBy("mIsSatelliteSupportedLock")
     private Boolean mIsSatelliteSupported = null;
@@ -220,6 +233,10 @@
     private final Object mNeedsSatellitePointingLock = new Object();
     @GuardedBy("mNeedsSatellitePointingLock")
     private boolean mNeedsSatellitePointing = false;
+    private final Object mNtnSignalsStrengthLock = new Object();
+    @GuardedBy("mNtnSignalsStrengthLock")
+    private NtnSignalStrength mNtnSignalStrength =
+            new NtnSignalStrength(NTN_SIGNAL_STRENGTH_NONE);
     /** Key: subId, value: (key: PLMN, value: set of
      * {@link android.telephony.NetworkRegistrationInfo.ServiceType})
      */
@@ -284,6 +301,7 @@
         mFeatureFlags = featureFlags;
         Phone phone = SatelliteServiceUtils.getPhone();
         mCi = phone.mCi;
+        mDSM = phone.getDeviceStateMonitor();
         // Create the SatelliteModemInterface singleton, which is used to manage connections
         // to the satellite service and HAL interface.
         mSatelliteModemInterface = SatelliteModemInterface.make(mContext, this);
@@ -338,6 +356,8 @@
                         handleCarrierConfigChanged(slotIndex, subId, carrierId, specificCarrierId);
         mCarrierConfigManager.registerCarrierConfigChangeListener(
                         new HandlerExecutor(new Handler(looper)), mCarrierConfigChangeListener);
+        mDSM.registerForSignalStrengthReportDecision(this, CMD_START_SENDING_NTN_SIGNAL_STRENGTH,
+                null);
     }
 
     @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE)
@@ -611,8 +631,7 @@
                 request = (SatelliteControllerHandlerRequest) msg.obj;
                 onCompleted =
                         obtainMessage(EVENT_START_SATELLITE_TRANSMISSION_UPDATES_DONE, request);
-                mPointingAppController.startSatelliteTransmissionUpdates(onCompleted,
-                        request.phone);
+                mPointingAppController.startSatelliteTransmissionUpdates(onCompleted);
                 break;
             }
 
@@ -625,7 +644,7 @@
                 request = (SatelliteControllerHandlerRequest) msg.obj;
                 onCompleted =
                         obtainMessage(EVENT_STOP_SATELLITE_TRANSMISSION_UPDATES_DONE, request);
-                mPointingAppController.stopSatelliteTransmissionUpdates(onCompleted, request.phone);
+                mPointingAppController.stopSatelliteTransmissionUpdates(onCompleted);
                 break;
             }
 
@@ -652,26 +671,8 @@
                 onCompleted = obtainMessage(EVENT_PROVISION_SATELLITE_SERVICE_DONE, request);
                 // Log the current time for provision triggered
                 mProvisionMetricsStats.setProvisioningStartTime();
-                if (mSatelliteModemInterface.isSatelliteServiceSupported()) {
-                    mSatelliteModemInterface.provisionSatelliteService(argument.token,
-                            argument.provisionData, onCompleted);
-                    break;
-                }
-                Phone phone = request.phone;
-                if (phone != null) {
-                    phone.provisionSatelliteService(onCompleted, argument.token);
-                } else {
-                    loge("provisionSatelliteService: No phone object");
-                    argument.callback.accept(
-                            SatelliteManager.SATELLITE_RESULT_INVALID_TELEPHONY_STATE);
-                    notifyRequester(request);
-                    mProvisionMetricsStats
-                            .setResultCode(
-                                    SatelliteManager.SATELLITE_RESULT_INVALID_TELEPHONY_STATE)
-                            .reportProvisionMetrics();
-                    mControllerMetricsStats.reportProvisionCount(
-                            SatelliteManager.SATELLITE_RESULT_INVALID_TELEPHONY_STATE);
-                }
+                mSatelliteModemInterface.provisionSatelliteService(argument.token,
+                        argument.provisionData, onCompleted);
                 break;
             }
 
@@ -694,26 +695,7 @@
                 if (argument.callback != null) {
                     mProvisionMetricsStats.setProvisioningStartTime();
                 }
-                if (mSatelliteModemInterface.isSatelliteServiceSupported()) {
-                    mSatelliteModemInterface
-                            .deprovisionSatelliteService(argument.token, onCompleted);
-                    break;
-                }
-                Phone phone = request.phone;
-                if (phone != null) {
-                    phone.deprovisionSatelliteService(onCompleted, argument.token);
-                } else {
-                    loge("deprovisionSatelliteService: No phone object");
-                    if (argument.callback != null) {
-                        argument.callback.accept(
-                                SatelliteManager.SATELLITE_RESULT_INVALID_TELEPHONY_STATE);
-                        mProvisionMetricsStats.setResultCode(
-                                SatelliteManager.SATELLITE_RESULT_INVALID_TELEPHONY_STATE)
-                                .reportProvisionMetrics();
-                        mControllerMetricsStats.reportDeprovisionCount(
-                                SatelliteManager.SATELLITE_RESULT_INVALID_TELEPHONY_STATE);
-                    }
-                }
+                mSatelliteModemInterface.deprovisionSatelliteService(argument.token, onCompleted);
                 break;
             }
 
@@ -741,7 +723,7 @@
                 int error =  SatelliteServiceUtils.getSatelliteError(ar, "setSatelliteEnabled");
                 logd("EVENT_SET_SATELLITE_ENABLED_DONE = " + error);
 
-                if (error == SatelliteManager.SATELLITE_RESULT_SUCCESS) {
+                if (error == SATELLITE_RESULT_SUCCESS) {
                     if (argument.enableSatellite) {
                         synchronized (mSatelliteEnabledRequestLock) {
                             mWaitingForRadioDisabled = true;
@@ -770,14 +752,14 @@
                                 // Previous mSatelliteEnabledRequest is successful but waiting for
                                 // all radios to be turned off.
                                 mSatelliteEnabledRequest.callback.accept(
-                                        SatelliteManager.SATELLITE_RESULT_SUCCESS);
+                                        SATELLITE_RESULT_SUCCESS);
                             }
                         }
 
                         synchronized (mIsSatelliteEnabledLock) {
                             if (!mWaitingForSatelliteModemOff) {
                                 moveSatelliteToOffStateAndCleanUpResources(
-                                        SatelliteManager.SATELLITE_RESULT_SUCCESS,
+                                        SATELLITE_RESULT_SUCCESS,
                                         argument.callback);
                             } else {
                                 logd("Wait for satellite modem off before updating satellite"
@@ -794,7 +776,7 @@
                             // Previous mSatelliteEnabledRequest is successful but waiting for
                             // all radios to be turned off.
                             mSatelliteEnabledRequest.callback.accept(
-                                    SatelliteManager.SATELLITE_RESULT_SUCCESS);
+                                    SATELLITE_RESULT_SUCCESS);
                         }
                     }
                     resetSatelliteEnabledRequest();
@@ -804,7 +786,7 @@
                 }
 
                 if (argument.enableSatellite) {
-                    if (error == SatelliteManager.SATELLITE_RESULT_SUCCESS) {
+                    if (error == SATELLITE_RESULT_SUCCESS) {
                         mControllerMetricsStats.onSatelliteEnabled();
                         mControllerMetricsStats.reportServiceEnablementSuccessCount();
                     } else {
@@ -826,18 +808,7 @@
             case CMD_IS_SATELLITE_ENABLED: {
                 request = (SatelliteControllerHandlerRequest) msg.obj;
                 onCompleted = obtainMessage(EVENT_IS_SATELLITE_ENABLED_DONE, request);
-                if (mSatelliteModemInterface.isSatelliteServiceSupported()) {
-                    mSatelliteModemInterface.requestIsSatelliteEnabled(onCompleted);
-                    break;
-                }
-                Phone phone = request.phone;
-                if (phone != null) {
-                    phone.isSatellitePowerOn(onCompleted);
-                } else {
-                    loge("isSatelliteEnabled: No phone object");
-                    ((ResultReceiver) request.argument).send(
-                            SatelliteManager.SATELLITE_RESULT_INVALID_TELEPHONY_STATE, null);
-                }
+                mSatelliteModemInterface.requestIsSatelliteEnabled(onCompleted);
                 break;
             }
 
@@ -847,7 +818,7 @@
                 int error =  SatelliteServiceUtils.getSatelliteError(ar,
                         "isSatelliteEnabled");
                 Bundle bundle = new Bundle();
-                if (error == SatelliteManager.SATELLITE_RESULT_SUCCESS) {
+                if (error == SATELLITE_RESULT_SUCCESS) {
                     if (ar.result == null) {
                         loge("isSatelliteEnabled: result is null");
                         error = SatelliteManager.SATELLITE_RESULT_INVALID_TELEPHONY_STATE;
@@ -867,19 +838,7 @@
             case CMD_IS_SATELLITE_SUPPORTED: {
                 request = (SatelliteControllerHandlerRequest) msg.obj;
                 onCompleted = obtainMessage(EVENT_IS_SATELLITE_SUPPORTED_DONE, request);
-
-                if (mSatelliteModemInterface.isSatelliteServiceSupported()) {
-                    mSatelliteModemInterface.requestIsSatelliteSupported(onCompleted);
-                    break;
-                }
-                Phone phone = request.phone;
-                if (phone != null) {
-                    phone.isSatelliteSupported(onCompleted);
-                } else {
-                    loge("isSatelliteSupported: No phone object");
-                    ((ResultReceiver) request.argument).send(
-                            SatelliteManager.SATELLITE_RESULT_INVALID_TELEPHONY_STATE, null);
-                }
+                mSatelliteModemInterface.requestIsSatelliteSupported(onCompleted);
                 break;
             }
 
@@ -888,7 +847,7 @@
                 request = (SatelliteControllerHandlerRequest) ar.userObj;
                 int error =  SatelliteServiceUtils.getSatelliteError(ar, "isSatelliteSupported");
                 Bundle bundle = new Bundle();
-                if (error == SatelliteManager.SATELLITE_RESULT_SUCCESS) {
+                if (error == SATELLITE_RESULT_SUCCESS) {
                     if (ar.result == null) {
                         loge("isSatelliteSupported: result is null");
                         error = SatelliteManager.SATELLITE_RESULT_INVALID_TELEPHONY_STATE;
@@ -906,18 +865,7 @@
             case CMD_GET_SATELLITE_CAPABILITIES: {
                 request = (SatelliteControllerHandlerRequest) msg.obj;
                 onCompleted = obtainMessage(EVENT_GET_SATELLITE_CAPABILITIES_DONE, request);
-                if (mSatelliteModemInterface.isSatelliteServiceSupported()) {
-                    mSatelliteModemInterface.requestSatelliteCapabilities(onCompleted);
-                    break;
-                }
-                Phone phone = request.phone;
-                if (phone != null) {
-                    phone.getSatelliteCapabilities(onCompleted);
-                } else {
-                    loge("getSatelliteCapabilities: No phone object");
-                    ((ResultReceiver) request.argument).send(
-                            SatelliteManager.SATELLITE_RESULT_INVALID_TELEPHONY_STATE, null);
-                }
+                mSatelliteModemInterface.requestSatelliteCapabilities(onCompleted);
                 break;
             }
 
@@ -927,7 +875,7 @@
                 int error =  SatelliteServiceUtils.getSatelliteError(ar,
                         "getSatelliteCapabilities");
                 Bundle bundle = new Bundle();
-                if (error == SatelliteManager.SATELLITE_RESULT_SUCCESS) {
+                if (error == SATELLITE_RESULT_SUCCESS) {
                     if (ar.result == null) {
                         loge("getSatelliteCapabilities: result is null");
                         error = SatelliteManager.SATELLITE_RESULT_INVALID_TELEPHONY_STATE;
@@ -952,20 +900,8 @@
                 request = (SatelliteControllerHandlerRequest) msg.obj;
                 onCompleted =
                         obtainMessage(EVENT_IS_SATELLITE_COMMUNICATION_ALLOWED_DONE, request);
-                if (mSatelliteModemInterface.isSatelliteServiceSupported()) {
-                    mSatelliteModemInterface
-                            .requestIsSatelliteCommunicationAllowedForCurrentLocation(
-                                    onCompleted);
-                    break;
-                }
-                Phone phone = request.phone;
-                if (phone != null) {
-                    phone.isSatelliteCommunicationAllowedForCurrentLocation(onCompleted);
-                } else {
-                    loge("isSatelliteCommunicationAllowedForCurrentLocation: No phone object");
-                    ((ResultReceiver) request.argument).send(
-                            SatelliteManager.SATELLITE_RESULT_INVALID_TELEPHONY_STATE, null);
-                }
+                mSatelliteModemInterface
+                        .requestIsSatelliteCommunicationAllowedForCurrentLocation(onCompleted);
                 break;
             }
 
@@ -975,7 +911,7 @@
                 int error =  SatelliteServiceUtils.getSatelliteError(ar,
                         "isSatelliteCommunicationAllowedForCurrentLocation");
                 Bundle bundle = new Bundle();
-                if (error == SatelliteManager.SATELLITE_RESULT_SUCCESS) {
+                if (error == SATELLITE_RESULT_SUCCESS) {
                     if (ar.result == null) {
                         loge("isSatelliteCommunicationAllowedForCurrentLocation: result is null");
                         error = SatelliteManager.SATELLITE_RESULT_INVALID_TELEPHONY_STATE;
@@ -997,19 +933,7 @@
                 request = (SatelliteControllerHandlerRequest) msg.obj;
                 onCompleted = obtainMessage(EVENT_GET_TIME_SATELLITE_NEXT_VISIBLE_DONE,
                         request);
-                if (mSatelliteModemInterface.isSatelliteServiceSupported()) {
-                    mSatelliteModemInterface
-                            .requestTimeForNextSatelliteVisibility(onCompleted);
-                    break;
-                }
-                Phone phone = request.phone;
-                if (phone != null) {
-                    phone.requestTimeForNextSatelliteVisibility(onCompleted);
-                } else {
-                    loge("requestTimeForNextSatelliteVisibility: No phone object");
-                    ((ResultReceiver) request.argument).send(
-                            SatelliteManager.SATELLITE_RESULT_INVALID_TELEPHONY_STATE, null);
-                }
+                mSatelliteModemInterface.requestTimeForNextSatelliteVisibility(onCompleted);
                 break;
             }
 
@@ -1019,7 +943,7 @@
                 int error = SatelliteServiceUtils.getSatelliteError(ar,
                         "requestTimeForNextSatelliteVisibility");
                 Bundle bundle = new Bundle();
-                if (error == SatelliteManager.SATELLITE_RESULT_SUCCESS) {
+                if (error == SATELLITE_RESULT_SUCCESS) {
                     if (ar.result == null) {
                         loge("requestTimeForNextSatelliteVisibility: result is null");
                         error = SatelliteManager.SATELLITE_RESULT_INVALID_TELEPHONY_STATE;
@@ -1063,18 +987,7 @@
             case CMD_IS_SATELLITE_PROVISIONED: {
                 request = (SatelliteControllerHandlerRequest) msg.obj;
                 onCompleted = obtainMessage(EVENT_IS_SATELLITE_PROVISIONED_DONE, request);
-                if (mSatelliteModemInterface.isSatelliteServiceSupported()) {
-                    mSatelliteModemInterface.requestIsSatelliteProvisioned(onCompleted);
-                    break;
-                }
-                Phone phone = request.phone;
-                if (phone != null) {
-                    phone.isSatelliteProvisioned(onCompleted);
-                } else {
-                    loge("isSatelliteProvisioned: No phone object");
-                    ((ResultReceiver) request.argument).send(
-                            SatelliteManager.SATELLITE_RESULT_INVALID_TELEPHONY_STATE, null);
-                }
+                mSatelliteModemInterface.requestIsSatelliteProvisioned(onCompleted);
                 break;
             }
 
@@ -1084,7 +997,7 @@
                 int error =  SatelliteServiceUtils.getSatelliteError(ar,
                         "isSatelliteProvisioned");
                 Bundle bundle = new Bundle();
-                if (error == SatelliteManager.SATELLITE_RESULT_SUCCESS) {
+                if (error == SATELLITE_RESULT_SUCCESS) {
                     if (ar.result == null) {
                         loge("isSatelliteProvisioned: result is null");
                         error = SatelliteManager.SATELLITE_RESULT_INVALID_TELEPHONY_STATE;
@@ -1153,7 +1066,7 @@
                         "requestSetSatelliteEnabledForCarrier");
 
                 synchronized (mIsSatelliteEnabledLock) {
-                    if (error == SatelliteManager.SATELLITE_RESULT_SUCCESS) {
+                    if (error == SATELLITE_RESULT_SUCCESS) {
                         boolean enableSatellite = mSatelliteAttachRestrictionForCarrierArray
                                 .getOrDefault(argument.subId, Collections.emptySet()).isEmpty();
                         mIsSatelliteAttachEnabledForCarrierArrayPerSub.put(subId, enableSatellite);
@@ -1166,6 +1079,91 @@
                 break;
             }
 
+            case CMD_REQUEST_NTN_SIGNAL_STRENGTH: {
+                logd("CMD_REQUEST_NTN_SIGNAL_STRENGTH");
+                request = (SatelliteControllerHandlerRequest) msg.obj;
+                onCompleted = obtainMessage(EVENT_REQUEST_NTN_SIGNAL_STRENGTH_DONE, request);
+                mSatelliteModemInterface.requestNtnSignalStrength(onCompleted);
+                break;
+            }
+
+            case EVENT_REQUEST_NTN_SIGNAL_STRENGTH_DONE: {
+                ar = (AsyncResult) msg.obj;
+                request = (SatelliteControllerHandlerRequest) ar.userObj;
+                ResultReceiver result = (ResultReceiver) request.argument;
+                int errorCode =  SatelliteServiceUtils.getSatelliteError(ar,
+                        "requestNtnSignalStrength");
+                if (errorCode == SATELLITE_RESULT_SUCCESS) {
+                    NtnSignalStrength ntnSignalStrength = (NtnSignalStrength) ar.result;
+                    if (ntnSignalStrength != null) {
+                        synchronized (mNtnSignalsStrengthLock) {
+                            mNtnSignalStrength = ntnSignalStrength;
+                        }
+                        Bundle bundle = new Bundle();
+                        bundle.putParcelable(KEY_NTN_SIGNAL_STRENGTH, ntnSignalStrength);
+                        result.send(SATELLITE_RESULT_SUCCESS, bundle);
+                    } else {
+                        synchronized (mNtnSignalsStrengthLock) {
+                            if (mNtnSignalStrength.getLevel() != NTN_SIGNAL_STRENGTH_NONE) {
+                                mNtnSignalStrength = new NtnSignalStrength(
+                                        NTN_SIGNAL_STRENGTH_NONE);
+                            }
+                        }
+                        loge("EVENT_REQUEST_NTN_SIGNAL_STRENGTH_DONE: ntnSignalStrength is null");
+                        result.send(SatelliteManager.SATELLITE_RESULT_REQUEST_FAILED, null);
+                    }
+                } else {
+                    synchronized (mNtnSignalsStrengthLock) {
+                        if (mNtnSignalStrength.getLevel() != NTN_SIGNAL_STRENGTH_NONE) {
+                            mNtnSignalStrength = new NtnSignalStrength(NTN_SIGNAL_STRENGTH_NONE);
+                        }
+                    }
+                    result.send(errorCode, null);
+                }
+                break;
+            }
+
+            case EVENT_NTN_SIGNAL_STRENGTH_CHANGED: {
+                ar = (AsyncResult) msg.obj;
+                if (ar.result == null) {
+                    loge("EVENT_NTN_SIGNAL_STRENGTH_CHANGED: result is null");
+                } else {
+                    handleEventNtnSignalStrengthChanged((NtnSignalStrength) ar.result);
+                }
+                break;
+            }
+
+            case CMD_START_SENDING_NTN_SIGNAL_STRENGTH: {
+                ar = (AsyncResult) msg.obj;
+                boolean shouldReport = (boolean) ar.result;
+                logd("CMD_START_SENDING_NTN_SIGNAL_STRENGTH: shouldReport=" + shouldReport);
+                request = new SatelliteControllerHandlerRequest(shouldReport,
+                        SatelliteServiceUtils.getPhone());
+                if (SATELLITE_RESULT_SUCCESS != evaluateOemSatelliteRequestAllowed(true)) {
+                    return;
+                }
+                onCompleted = obtainMessage(EVENT_UPDATE_SIGNAL_STRENGTH_REPORTING,
+                        request);
+                if (shouldReport) {
+                    mSatelliteModemInterface.startSendingNtnSignalStrength(onCompleted);
+                } else {
+                    mSatelliteModemInterface.stopSendingNtnSignalStrength(onCompleted);
+                }
+                break;
+            }
+
+            case EVENT_UPDATE_SIGNAL_STRENGTH_REPORTING: {
+                ar = (AsyncResult) msg.obj;
+                request = (SatelliteControllerHandlerRequest) ar.userObj;
+                int errorCode =  SatelliteServiceUtils.getSatelliteError(ar,
+                        "EVENT_UPDATE_SIGNAL_STRENGTH_REPORTING");
+                if (errorCode != SATELLITE_RESULT_SUCCESS) {
+                    loge(((boolean) request.argument ? "startSendingNtnSignalStrength"
+                            : "stopSendingNtnSignalStrength") + "returns " + errorCode);
+                }
+                break;
+            }
+
             default:
                 Log.w(TAG, "SatelliteControllerHandler: unexpected message code: " +
                         msg.what);
@@ -1195,28 +1193,9 @@
         logd("requestSatelliteEnabled subId: " + subId + " enableSatellite: " + enableSatellite
                 + " enableDemoMode: " + enableDemoMode);
         Consumer<Integer> result = FunctionalUtils.ignoreRemoteException(callback::accept);
-        if (!mFeatureFlags.oemEnabledSatelliteFlag()) {
-            result.accept(SatelliteManager.SATELLITE_RESULT_NOT_SUPPORTED);
-            return;
-        }
-
-        Boolean satelliteSupported = isSatelliteSupportedInternal();
-        if (satelliteSupported == null) {
-            result.accept(SatelliteManager.SATELLITE_RESULT_INVALID_TELEPHONY_STATE);
-            return;
-        }
-        if (!satelliteSupported) {
-            result.accept(SatelliteManager.SATELLITE_RESULT_NOT_SUPPORTED);
-            return;
-        }
-
-        Boolean satelliteProvisioned = isSatelliteProvisioned();
-        if (satelliteProvisioned == null) {
-            result.accept(SatelliteManager.SATELLITE_RESULT_INVALID_TELEPHONY_STATE);
-            return;
-        }
-        if (!satelliteProvisioned) {
-            result.accept(SatelliteManager.SATELLITE_RESULT_SERVICE_NOT_PROVISIONED);
+        int error = evaluateOemSatelliteRequestAllowed(true);
+        if (error != SATELLITE_RESULT_SUCCESS) {
+            result.accept(error);
             return;
         }
 
@@ -1242,7 +1221,7 @@
                     } else {
                         logd("Enable request matches with current state"
                                 + " enableSatellite = " + enableSatellite);
-                        result.accept(SatelliteManager.SATELLITE_RESULT_SUCCESS);
+                        result.accept(SATELLITE_RESULT_SUCCESS);
                         return;
                     }
                 }
@@ -1278,7 +1257,7 @@
             }
         }
 
-        sendRequestAsync(CMD_SET_SATELLITE_ENABLED, request, SatelliteServiceUtils.getPhone());
+        sendRequestAsync(CMD_SET_SATELLITE_ENABLED, request, null);
     }
 
     /**
@@ -1289,17 +1268,9 @@
      *               if the request is successful or an error code if the request failed.
      */
     public void requestIsSatelliteEnabled(int subId, @NonNull ResultReceiver result) {
-        if (!mFeatureFlags.oemEnabledSatelliteFlag()) {
-            result.send(SatelliteManager.SATELLITE_RESULT_NOT_SUPPORTED, null);
-            return;
-        }
-        Boolean satelliteSupported = isSatelliteSupportedInternal();
-        if (satelliteSupported == null) {
-            result.send(SatelliteManager.SATELLITE_RESULT_INVALID_TELEPHONY_STATE, null);
-            return;
-        }
-        if (!satelliteSupported) {
-            result.send(SatelliteManager.SATELLITE_RESULT_NOT_SUPPORTED, null);
+        int error = evaluateOemSatelliteRequestAllowed(false);
+        if (error != SATELLITE_RESULT_SUCCESS) {
+            result.send(error, null);
             return;
         }
 
@@ -1308,12 +1279,12 @@
                 /* We have already successfully queried the satellite modem. */
                 Bundle bundle = new Bundle();
                 bundle.putBoolean(SatelliteManager.KEY_SATELLITE_ENABLED, mIsSatelliteEnabled);
-                result.send(SatelliteManager.SATELLITE_RESULT_SUCCESS, bundle);
+                result.send(SATELLITE_RESULT_SUCCESS, bundle);
                 return;
             }
         }
 
-        sendRequestAsync(CMD_IS_SATELLITE_ENABLED, result, SatelliteServiceUtils.getPhone());
+        sendRequestAsync(CMD_IS_SATELLITE_ENABLED, result, null);
     }
 
     /**
@@ -1339,33 +1310,15 @@
      *               if the request is successful or an error code if the request failed.
      */
     public void requestIsDemoModeEnabled(int subId, @NonNull ResultReceiver result) {
-        if (!mFeatureFlags.oemEnabledSatelliteFlag()) {
-            result.send(SatelliteManager.SATELLITE_RESULT_NOT_SUPPORTED, null);
-            return;
-        }
-        Boolean satelliteSupported = isSatelliteSupportedInternal();
-        if (satelliteSupported == null) {
-            result.send(SatelliteManager.SATELLITE_RESULT_INVALID_TELEPHONY_STATE, null);
-            return;
-        }
-        if (!satelliteSupported) {
-            result.send(SatelliteManager.SATELLITE_RESULT_NOT_SUPPORTED, null);
-            return;
-        }
-
-        Boolean satelliteProvisioned = isSatelliteProvisioned();
-        if (satelliteProvisioned == null) {
-            result.send(SatelliteManager.SATELLITE_RESULT_INVALID_TELEPHONY_STATE, null);
-            return;
-        }
-        if (!satelliteProvisioned) {
-            result.send(SatelliteManager.SATELLITE_RESULT_SERVICE_NOT_PROVISIONED, null);
+        int error = evaluateOemSatelliteRequestAllowed(true);
+        if (error != SATELLITE_RESULT_SUCCESS) {
+            result.send(error, null);
             return;
         }
 
         final Bundle bundle = new Bundle();
         bundle.putBoolean(SatelliteManager.KEY_DEMO_MODE_ENABLED, mIsDemoModeEnabled);
-        result.send(SatelliteManager.SATELLITE_RESULT_SUCCESS, bundle);
+        result.send(SATELLITE_RESULT_SUCCESS, bundle);
     }
 
     /**
@@ -1397,12 +1350,12 @@
                 /* We have already successfully queried the satellite modem. */
                 Bundle bundle = new Bundle();
                 bundle.putBoolean(SatelliteManager.KEY_SATELLITE_SUPPORTED, mIsSatelliteSupported);
-                result.send(SatelliteManager.SATELLITE_RESULT_SUCCESS, bundle);
+                result.send(SATELLITE_RESULT_SUCCESS, bundle);
                 return;
             }
         }
 
-        sendRequestAsync(CMD_IS_SATELLITE_SUPPORTED, result, SatelliteServiceUtils.getPhone());
+        sendRequestAsync(CMD_IS_SATELLITE_SUPPORTED, result, null);
     }
 
     /**
@@ -1413,17 +1366,9 @@
      *               if the request is successful or an error code if the request failed.
      */
     public void requestSatelliteCapabilities(int subId, @NonNull ResultReceiver result) {
-        if (!mFeatureFlags.oemEnabledSatelliteFlag()) {
-            result.send(SatelliteManager.SATELLITE_RESULT_NOT_SUPPORTED, null);
-            return;
-        }
-        Boolean satelliteSupported = isSatelliteSupportedInternal();
-        if (satelliteSupported == null) {
-            result.send(SatelliteManager.SATELLITE_RESULT_INVALID_TELEPHONY_STATE, null);
-            return;
-        }
-        if (!satelliteSupported) {
-            result.send(SatelliteManager.SATELLITE_RESULT_NOT_SUPPORTED, null);
+        int error = evaluateOemSatelliteRequestAllowed(false);
+        if (error != SATELLITE_RESULT_SUCCESS) {
+            result.send(error, null);
             return;
         }
 
@@ -1432,12 +1377,12 @@
                 Bundle bundle = new Bundle();
                 bundle.putParcelable(SatelliteManager.KEY_SATELLITE_CAPABILITIES,
                         mSatelliteCapabilities);
-                result.send(SatelliteManager.SATELLITE_RESULT_SUCCESS, bundle);
+                result.send(SATELLITE_RESULT_SUCCESS, bundle);
                 return;
             }
         }
 
-        sendRequestAsync(CMD_GET_SATELLITE_CAPABILITIES, result, SatelliteServiceUtils.getPhone());
+        sendRequestAsync(CMD_GET_SATELLITE_CAPABILITIES, result, null);
     }
 
     /**
@@ -1453,35 +1398,16 @@
             @NonNull IIntegerConsumer errorCallback,
             @NonNull ISatelliteTransmissionUpdateCallback callback) {
         Consumer<Integer> result = FunctionalUtils.ignoreRemoteException(errorCallback::accept);
-        if (!mFeatureFlags.oemEnabledSatelliteFlag()) {
-            result.accept(SatelliteManager.SATELLITE_RESULT_NOT_SUPPORTED);
-            return;
-        }
-        Boolean satelliteSupported = isSatelliteSupportedInternal();
-        if (satelliteSupported == null) {
-            result.accept(SatelliteManager.SATELLITE_RESULT_INVALID_TELEPHONY_STATE);
-            return;
-        }
-        if (!satelliteSupported) {
-            result.accept(SatelliteManager.SATELLITE_RESULT_NOT_SUPPORTED);
+        int error = evaluateOemSatelliteRequestAllowed(true);
+        if (error != SATELLITE_RESULT_SUCCESS) {
+            result.accept(error);
             return;
         }
 
-        Boolean satelliteProvisioned = isSatelliteProvisioned();
-        if (satelliteProvisioned == null) {
-            result.accept(SatelliteManager.SATELLITE_RESULT_INVALID_TELEPHONY_STATE);
-            return;
-        }
-        if (!satelliteProvisioned) {
-            result.accept(SatelliteManager.SATELLITE_RESULT_SERVICE_NOT_PROVISIONED);
-            return;
-        }
-
-        Phone phone = SatelliteServiceUtils.getPhone();
         final int validSubId = SatelliteServiceUtils.getValidSatelliteSubId(subId, mContext);
-        mPointingAppController.registerForSatelliteTransmissionUpdates(validSubId, callback, phone);
+        mPointingAppController.registerForSatelliteTransmissionUpdates(validSubId, callback);
         sendRequestAsync(CMD_START_SATELLITE_TRANSMISSION_UPDATES,
-                new SatelliteTransmissionUpdateArgument(result, callback, validSubId), phone);
+                new SatelliteTransmissionUpdateArgument(result, callback, validSubId), null);
     }
 
     /**
@@ -1496,39 +1422,20 @@
     public void stopSatelliteTransmissionUpdates(int subId, @NonNull IIntegerConsumer errorCallback,
             @NonNull ISatelliteTransmissionUpdateCallback callback) {
         Consumer<Integer> result = FunctionalUtils.ignoreRemoteException(errorCallback::accept);
-        if (!mFeatureFlags.oemEnabledSatelliteFlag()) {
-            result.accept(SatelliteManager.SATELLITE_RESULT_NOT_SUPPORTED);
-            return;
-        }
-        Boolean satelliteSupported = isSatelliteSupportedInternal();
-        if (satelliteSupported == null) {
-            result.accept(SatelliteManager.SATELLITE_RESULT_INVALID_TELEPHONY_STATE);
-            return;
-        }
-        if (!satelliteSupported) {
-            result.accept(SatelliteManager.SATELLITE_RESULT_NOT_SUPPORTED);
+        int error = evaluateOemSatelliteRequestAllowed(true);
+        if (error != SATELLITE_RESULT_SUCCESS) {
+            result.accept(error);
             return;
         }
 
-        Boolean satelliteProvisioned = isSatelliteProvisioned();
-        if (satelliteProvisioned == null) {
-            result.accept(SatelliteManager.SATELLITE_RESULT_INVALID_TELEPHONY_STATE);
-            return;
-        }
-        if (!satelliteProvisioned) {
-            result.accept(SatelliteManager.SATELLITE_RESULT_SERVICE_NOT_PROVISIONED);
-            return;
-        }
-
-        Phone phone = SatelliteServiceUtils.getPhone();
         final int validSubId = SatelliteServiceUtils.getValidSatelliteSubId(subId, mContext);
         mPointingAppController.unregisterForSatelliteTransmissionUpdates(
-                validSubId, result, callback, phone);
+                validSubId, result, callback);
 
         // Even if handler is null - which means there are no listeners, the modem command to stop
         // satellite transmission updates might have failed. The callers might want to retry
         // sending the command. Thus, we always need to send this command to the modem.
-        sendRequestAsync(CMD_STOP_SATELLITE_TRANSMISSION_UPDATES, result, phone);
+        sendRequestAsync(CMD_STOP_SATELLITE_TRANSMISSION_UPDATES, result, null);
     }
 
     /**
@@ -1548,17 +1455,9 @@
             @NonNull String token, @NonNull byte[] provisionData,
             @NonNull IIntegerConsumer callback) {
         Consumer<Integer> result = FunctionalUtils.ignoreRemoteException(callback::accept);
-        if (!mFeatureFlags.oemEnabledSatelliteFlag()) {
-            result.accept(SatelliteManager.SATELLITE_RESULT_NOT_SUPPORTED);
-            return null;
-        }
-        Boolean satelliteSupported = isSatelliteSupportedInternal();
-        if (satelliteSupported == null) {
-            result.accept(SatelliteManager.SATELLITE_RESULT_INVALID_TELEPHONY_STATE);
-            return null;
-        }
-        if (!satelliteSupported) {
-            result.accept(SatelliteManager.SATELLITE_RESULT_NOT_SUPPORTED);
+        int error = evaluateOemSatelliteRequestAllowed(false);
+        if (error != SATELLITE_RESULT_SUCCESS) {
+            result.accept(error);
             return null;
         }
 
@@ -1570,20 +1469,19 @@
 
         Boolean satelliteProvisioned = isSatelliteProvisioned();
         if (satelliteProvisioned != null && satelliteProvisioned) {
-            result.accept(SatelliteManager.SATELLITE_RESULT_SUCCESS);
+            result.accept(SATELLITE_RESULT_SUCCESS);
             return null;
         }
 
-        Phone phone = SatelliteServiceUtils.getPhone();
         sendRequestAsync(CMD_PROVISION_SATELLITE_SERVICE,
                 new ProvisionSatelliteServiceArgument(token, provisionData, result, validSubId),
-                phone);
+                null);
 
         ICancellationSignal cancelTransport = CancellationSignal.createTransport();
         CancellationSignal.fromTransport(cancelTransport).setOnCancelListener(() -> {
             sendRequestAsync(CMD_DEPROVISION_SATELLITE_SERVICE,
                     new ProvisionSatelliteServiceArgument(token, provisionData, null,
-                            validSubId), phone);
+                            validSubId), null);
             mProvisionMetricsStats.setIsCanceled(true);
         });
         return cancelTransport;
@@ -1603,17 +1501,9 @@
     public void deprovisionSatelliteService(int subId,
             @NonNull String token, @NonNull IIntegerConsumer callback) {
         Consumer<Integer> result = FunctionalUtils.ignoreRemoteException(callback::accept);
-        if (!mFeatureFlags.oemEnabledSatelliteFlag()) {
-            result.accept(SatelliteManager.SATELLITE_RESULT_NOT_SUPPORTED);
-            return;
-        }
-        Boolean satelliteSupported = isSatelliteSupportedInternal();
-        if (satelliteSupported == null) {
-            result.accept(SatelliteManager.SATELLITE_RESULT_INVALID_TELEPHONY_STATE);
-            return;
-        }
-        if (!satelliteSupported) {
-            result.accept(SatelliteManager.SATELLITE_RESULT_NOT_SUPPORTED);
+        int error = evaluateOemSatelliteRequestAllowed(false);
+        if (error != SATELLITE_RESULT_SUCCESS) {
+            result.accept(error);
             return;
         }
 
@@ -1623,15 +1513,14 @@
             return;
         }
         if (!satelliteProvisioned) {
-            result.accept(SatelliteManager.SATELLITE_RESULT_SUCCESS);
+            result.accept(SATELLITE_RESULT_SUCCESS);
             return;
         }
 
-        Phone phone = SatelliteServiceUtils.getPhone();
         final int validSubId = SatelliteServiceUtils.getValidSatelliteSubId(subId, mContext);
         sendRequestAsync(CMD_DEPROVISION_SATELLITE_SERVICE,
                 new ProvisionSatelliteServiceArgument(token, null, result, validSubId),
-                phone);
+                null);
     }
 
     /**
@@ -1644,19 +1533,13 @@
      */
     @SatelliteManager.SatelliteResult public int registerForSatelliteProvisionStateChanged(
             int subId, @NonNull ISatelliteProvisionStateCallback callback) {
-        if (!mFeatureFlags.oemEnabledSatelliteFlag()) {
-            return SatelliteManager.SATELLITE_RESULT_NOT_SUPPORTED;
-        }
-        Boolean satelliteSupported = isSatelliteSupportedInternal();
-        if (satelliteSupported == null) {
-            return SatelliteManager.SATELLITE_RESULT_INVALID_TELEPHONY_STATE;
-        }
-        if (!satelliteSupported) {
-            return SatelliteManager.SATELLITE_RESULT_NOT_SUPPORTED;
+        int error = evaluateOemSatelliteRequestAllowed(false);
+        if (error != SATELLITE_RESULT_SUCCESS) {
+            return error;
         }
 
         mSatelliteProvisionStateChangedListeners.put(callback.asBinder(), callback);
-        return SatelliteManager.SATELLITE_RESULT_SUCCESS;
+        return SATELLITE_RESULT_SUCCESS;
     }
 
     /**
@@ -1684,17 +1567,9 @@
      *               request failed.
      */
     public void requestIsSatelliteProvisioned(int subId, @NonNull ResultReceiver result) {
-        if (!mFeatureFlags.oemEnabledSatelliteFlag()) {
-            result.send(SatelliteManager.SATELLITE_RESULT_NOT_SUPPORTED, null);
-            return;
-        }
-        Boolean satelliteSupported = isSatelliteSupportedInternal();
-        if (satelliteSupported == null) {
-            result.send(SatelliteManager.SATELLITE_RESULT_INVALID_TELEPHONY_STATE, null);
-            return;
-        }
-        if (!satelliteSupported) {
-            result.send(SatelliteManager.SATELLITE_RESULT_NOT_SUPPORTED, null);
+        int error = evaluateOemSatelliteRequestAllowed(false);
+        if (error != SATELLITE_RESULT_SUCCESS) {
+            result.send(error, null);
             return;
         }
 
@@ -1703,12 +1578,12 @@
                 Bundle bundle = new Bundle();
                 bundle.putBoolean(SatelliteManager.KEY_SATELLITE_PROVISIONED,
                         mIsSatelliteProvisioned);
-                result.send(SatelliteManager.SATELLITE_RESULT_SUCCESS, bundle);
+                result.send(SATELLITE_RESULT_SUCCESS, bundle);
                 return;
             }
         }
 
-        sendRequestAsync(CMD_IS_SATELLITE_PROVISIONED, result, SatelliteServiceUtils.getPhone());
+        sendRequestAsync(CMD_IS_SATELLITE_PROVISIONED, result, null);
     }
 
     /**
@@ -1731,7 +1606,7 @@
                     + " is not initialized yet");
             return SatelliteManager.SATELLITE_RESULT_INVALID_TELEPHONY_STATE;
         }
-        return SatelliteManager.SATELLITE_RESULT_SUCCESS;
+        return SATELLITE_RESULT_SUCCESS;
     }
 
     /**
@@ -1768,6 +1643,9 @@
         if (!mFeatureFlags.oemEnabledSatelliteFlag()) {
             return SatelliteManager.SATELLITE_RESULT_NOT_SUPPORTED;
         }
+        if (!mSatelliteModemInterface.isSatelliteServiceSupported()) {
+            return SatelliteManager.SATELLITE_RESULT_NOT_SUPPORTED;
+        }
         return mDatagramController.registerForSatelliteDatagram(subId, callback);
     }
 
@@ -1784,6 +1662,9 @@
         if (!mFeatureFlags.oemEnabledSatelliteFlag()) {
             return;
         }
+        if (!mSatelliteModemInterface.isSatelliteServiceSupported()) {
+            return;
+        }
         mDatagramController.unregisterForSatelliteDatagram(subId, callback);
     }
 
@@ -1800,18 +1681,9 @@
      */
     public void pollPendingSatelliteDatagrams(int subId, @NonNull IIntegerConsumer callback) {
         Consumer<Integer> result = FunctionalUtils.ignoreRemoteException(callback::accept);
-        if (!mFeatureFlags.oemEnabledSatelliteFlag()) {
-            result.accept(SatelliteManager.SATELLITE_RESULT_NOT_SUPPORTED);
-            return;
-        }
-
-        Boolean satelliteProvisioned = isSatelliteProvisioned();
-        if (satelliteProvisioned == null) {
-            result.accept(SatelliteManager.SATELLITE_RESULT_INVALID_TELEPHONY_STATE);
-            return;
-        }
-        if (!satelliteProvisioned) {
-            result.accept(SatelliteManager.SATELLITE_RESULT_SERVICE_NOT_PROVISIONED);
+        int error = evaluateOemSatelliteRequestAllowed(true);
+        if (error != SATELLITE_RESULT_SUCCESS) {
+            result.accept(error);
             return;
         }
 
@@ -1839,18 +1711,9 @@
             SatelliteDatagram datagram, boolean needFullScreenPointingUI,
             @NonNull IIntegerConsumer callback) {
         Consumer<Integer> result = FunctionalUtils.ignoreRemoteException(callback::accept);
-        if (!mFeatureFlags.oemEnabledSatelliteFlag()) {
-            result.accept(SatelliteManager.SATELLITE_RESULT_NOT_SUPPORTED);
-            return;
-        }
-
-        Boolean satelliteProvisioned = isSatelliteProvisioned();
-        if (satelliteProvisioned == null) {
-            result.accept(SatelliteManager.SATELLITE_RESULT_INVALID_TELEPHONY_STATE);
-            return;
-        }
-        if (!satelliteProvisioned) {
-            result.accept(SatelliteManager.SATELLITE_RESULT_SERVICE_NOT_PROVISIONED);
+        int error = evaluateOemSatelliteRequestAllowed(true);
+        if (error != SATELLITE_RESULT_SUCCESS) {
+            result.accept(error);
             return;
         }
 
@@ -1877,22 +1740,13 @@
      */
     public void requestIsSatelliteCommunicationAllowedForCurrentLocation(int subId,
             @NonNull ResultReceiver result) {
-        if (!mFeatureFlags.oemEnabledSatelliteFlag()) {
-            result.send(SatelliteManager.SATELLITE_RESULT_NOT_SUPPORTED, null);
-            return;
-        }
-        Boolean satelliteSupported = isSatelliteSupportedInternal();
-        if (satelliteSupported == null) {
-            result.send(SatelliteManager.SATELLITE_RESULT_INVALID_TELEPHONY_STATE, null);
-            return;
-        }
-        if (!satelliteSupported) {
-            result.send(SatelliteManager.SATELLITE_RESULT_NOT_SUPPORTED, null);
+        int error = evaluateOemSatelliteRequestAllowed(false);
+        if (error != SATELLITE_RESULT_SUCCESS) {
+            result.send(error, null);
             return;
         }
 
-        sendRequestAsync(
-                CMD_IS_SATELLITE_COMMUNICATION_ALLOWED, result, SatelliteServiceUtils.getPhone());
+        sendRequestAsync(CMD_IS_SATELLITE_COMMUNICATION_ALLOWED, result, null);
     }
 
     /**
@@ -1903,32 +1757,13 @@
      *               be visible if the request is successful or an error code if the request failed.
      */
     public void requestTimeForNextSatelliteVisibility(int subId, @NonNull ResultReceiver result) {
-        if (!mFeatureFlags.oemEnabledSatelliteFlag()) {
-            result.send(SatelliteManager.SATELLITE_RESULT_NOT_SUPPORTED, null);
-            return;
-        }
-        Boolean satelliteSupported = isSatelliteSupportedInternal();
-        if (satelliteSupported == null) {
-            result.send(SatelliteManager.SATELLITE_RESULT_INVALID_TELEPHONY_STATE, null);
-            return;
-        }
-        if (!satelliteSupported) {
-            result.send(SatelliteManager.SATELLITE_RESULT_NOT_SUPPORTED, null);
+        int error = evaluateOemSatelliteRequestAllowed(true);
+        if (error != SATELLITE_RESULT_SUCCESS) {
+            result.send(error, null);
             return;
         }
 
-        Boolean satelliteProvisioned = isSatelliteProvisioned();
-        if (satelliteProvisioned == null) {
-            result.send(SatelliteManager.SATELLITE_RESULT_INVALID_TELEPHONY_STATE, null);
-            return;
-        }
-        if (!satelliteProvisioned) {
-            result.send(SatelliteManager.SATELLITE_RESULT_SERVICE_NOT_PROVISIONED, null);
-            return;
-        }
-
-        Phone phone = SatelliteServiceUtils.getPhone();
-        sendRequestAsync(CMD_GET_TIME_SATELLITE_NEXT_VISIBLE, result, phone);
+        sendRequestAsync(CMD_GET_TIME_SATELLITE_NEXT_VISIBLE, result, null);
     }
 
     /**
@@ -1961,6 +1796,8 @@
         Consumer<Integer> result = FunctionalUtils.ignoreRemoteException(callback::accept);
         if (!mFeatureFlags.carrierEnabledSatelliteFlag()) {
             result.accept(SatelliteManager.SATELLITE_RESULT_REQUEST_NOT_SUPPORTED);
+            logd("addSatelliteAttachRestrictionForCarrier: carrierEnabledSatelliteFlag is "
+                    + "disabled");
             return;
         }
 
@@ -1969,7 +1806,7 @@
                     subId, Collections.emptySet()).isEmpty()) {
                 mSatelliteAttachRestrictionForCarrierArray.put(subId, new HashSet<>());
             } else if (mSatelliteAttachRestrictionForCarrierArray.get(subId).contains(reason)) {
-                result.accept(SatelliteManager.SATELLITE_RESULT_SUCCESS);
+                result.accept(SATELLITE_RESULT_SUCCESS);
                 return;
             }
             mSatelliteAttachRestrictionForCarrierArray.get(subId).add(reason);
@@ -1998,6 +1835,8 @@
         Consumer<Integer> result = FunctionalUtils.ignoreRemoteException(callback::accept);
         if (!mFeatureFlags.carrierEnabledSatelliteFlag()) {
             result.accept(SatelliteManager.SATELLITE_RESULT_REQUEST_NOT_SUPPORTED);
+            logd("removeSatelliteAttachRestrictionForCarrier: carrierEnabledSatelliteFlag is "
+                    + "disabled");
             return;
         }
 
@@ -2005,7 +1844,7 @@
             if (mSatelliteAttachRestrictionForCarrierArray.getOrDefault(
                     subId, Collections.emptySet()).isEmpty()
                     || !mSatelliteAttachRestrictionForCarrierArray.get(subId).contains(reason)) {
-                result.accept(SatelliteManager.SATELLITE_RESULT_SUCCESS);
+                result.accept(SATELLITE_RESULT_SUCCESS);
                 return;
             }
             mSatelliteAttachRestrictionForCarrierArray.get(subId).remove(reason);
@@ -2040,6 +1879,75 @@
     }
 
     /**
+     * Request to get the signal strength of the satellite connection.
+     *
+     * @param subId The subId of the subscription to request for.
+     * @param result Result receiver to get the error code of the request and the current signal
+     * strength of the satellite connection.
+     */
+    public void requestNtnSignalStrength(int subId, @NonNull ResultReceiver result) {
+        if (DBG) logd("requestNtnSignalStrength()");
+
+        int error = evaluateOemSatelliteRequestAllowed(true);
+        if (error != SATELLITE_RESULT_SUCCESS) {
+            result.send(error, null);
+            return;
+        }
+
+        /* In case cache is available, it is not needed to request non-terrestrial signal strength
+        to modem */
+        synchronized (mNtnSignalsStrengthLock) {
+            if (mNtnSignalStrength.getLevel() != NTN_SIGNAL_STRENGTH_NONE) {
+                Bundle bundle = new Bundle();
+                bundle.putParcelable(KEY_NTN_SIGNAL_STRENGTH, mNtnSignalStrength);
+                result.send(SATELLITE_RESULT_SUCCESS, bundle);
+                return;
+            }
+        }
+
+        Phone phone = SatelliteServiceUtils.getPhone();
+        sendRequestAsync(CMD_REQUEST_NTN_SIGNAL_STRENGTH, result, phone);
+    }
+
+    /**
+     * Registers for NTN signal strength changed from satellite modem.
+     *
+     * @param subId The subId of the subscription to request for.
+     * @param callback The callback to handle the non-terrestrial network signal strength changed
+     * event.
+     *
+     * @return The {@link SatelliteManager.SatelliteResult} result of the operation.
+     */
+    @SatelliteManager.SatelliteResult public int registerForNtnSignalStrengthChanged(
+            int subId, @NonNull INtnSignalStrengthCallback callback) {
+        if (DBG) logd("registerForNtnSignalStrengthChanged()");
+
+        int error = evaluateOemSatelliteRequestAllowed(true);
+        if (error != SATELLITE_RESULT_SUCCESS) return error;
+
+        mNtnSignalStrengthChangedListeners.put(callback.asBinder(), callback);
+        return SATELLITE_RESULT_SUCCESS;
+    }
+
+    /**
+     * Unregisters for NTN signal strength changed from satellite modem.
+     * If callback was not registered before, the request will be ignored.
+     *
+     * @param subId The subId of the subscription to unregister for provision state changed.
+     * @param callback The callback that was passed to
+     * {@link #registerForNtnSignalStrengthChanged(int, INtnSignalStrengthCallback)}
+     */
+    public void unregisterForNtnSignalStrengthChanged(
+            int subId, @NonNull INtnSignalStrengthCallback callback) {
+        if (DBG) logd("unregisterForNtnSignalStrengthChanged()");
+
+        int error = evaluateOemSatelliteRequestAllowed(true);
+        if (error == SATELLITE_RESULT_SUCCESS) {
+            mNtnSignalStrengthChangedListeners.remove(callback.asBinder());
+        }
+    }
+
+    /**
      * This API can be used by only CTS to update satellite vendor service package name.
      *
      * @param servicePackageName The package name of the satellite vendor service.
@@ -2182,6 +2090,7 @@
      */
     public void onCellularRadioPowerOffRequested() {
         if (!mFeatureFlags.oemEnabledSatelliteFlag()) {
+            logd("onCellularRadioPowerOffRequested: oemEnabledSatelliteFlag is disabled");
             return;
         }
 
@@ -2262,6 +2171,7 @@
      */
     public boolean isSatelliteAttachRequired() {
         if (!mFeatureFlags.oemEnabledSatelliteFlag()) {
+            logd("isSatelliteAttachRequired: oemEnabledSatelliteFlag is disabled");
             return false;
         }
 
@@ -2351,12 +2261,12 @@
                 "handleStartSatelliteTransmissionUpdatesDone");
         arg.errorCallback.accept(errorCode);
 
-        if (errorCode != SatelliteManager.SATELLITE_RESULT_SUCCESS) {
+        if (errorCode != SATELLITE_RESULT_SUCCESS) {
             mPointingAppController.setStartedSatelliteTransmissionUpdates(false);
             // We need to remove the callback from our listener list since the caller might not call
             // stopSatelliteTransmissionUpdates to unregister the callback in case of failure.
             mPointingAppController.unregisterForSatelliteTransmissionUpdates(arg.subId,
-                    arg.errorCallback, arg.callback, request.phone);
+                    arg.errorCallback, arg.callback);
         } else {
             mPointingAppController.setStartedSatelliteTransmissionUpdates(true);
         }
@@ -2433,10 +2343,7 @@
     private void handleSatelliteEnabled(SatelliteControllerHandlerRequest request) {
         RequestSatelliteEnabledArgument argument =
                 (RequestSatelliteEnabledArgument) request.argument;
-        Phone phone = request.phone;
-
-        if (!argument.enableSatellite && (mSatelliteModemInterface.isSatelliteServiceSupported()
-                || phone != null)) {
+        if (!argument.enableSatellite && mSatelliteModemInterface.isSatelliteServiceSupported()) {
             synchronized (mIsSatelliteEnabledLock) {
                 mWaitingForDisableSatelliteModemResponse = true;
                 mWaitingForSatelliteModemOff = true;
@@ -2444,18 +2351,8 @@
         }
 
         Message onCompleted = obtainMessage(EVENT_SET_SATELLITE_ENABLED_DONE, request);
-        if (mSatelliteModemInterface.isSatelliteServiceSupported()) {
-            mSatelliteModemInterface.requestSatelliteEnabled(argument.enableSatellite,
-                    argument.enableDemoMode, onCompleted);
-            return;
-        }
-
-        if (phone != null) {
-            phone.setSatellitePower(onCompleted, argument.enableSatellite);
-        } else {
-            loge("requestSatelliteEnabled: No phone object");
-            argument.callback.accept(SatelliteManager.SATELLITE_RESULT_INVALID_TELEPHONY_STATE);
-        }
+        mSatelliteModemInterface.requestSatelliteEnabled(argument.enableSatellite,
+                argument.enableDemoMode, onCompleted);
     }
 
     private void handleRequestSatelliteAttachRestrictionForCarrierCmd(
@@ -2483,6 +2380,7 @@
             registerForSatelliteProvisionStateChanged();
             registerForPendingDatagramCount();
             registerForSatelliteModemStateChanged();
+            registerForNtnSignalStrengthChanged();
 
             requestIsSatelliteProvisioned(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID,
                     new ResultReceiver(this) {
@@ -2528,15 +2426,6 @@
                         this, EVENT_SATELLITE_PROVISION_STATE_CHANGED, null);
                 mRegisteredForProvisionStateChangedWithSatelliteService.set(true);
             }
-        } else {
-            Phone phone = SatelliteServiceUtils.getPhone();
-            if (phone == null) {
-                loge("registerForSatelliteProvisionStateChanged: phone is null");
-            } else if (!mRegisteredForProvisionStateChangedWithPhone.get()) {
-                phone.registerForSatelliteProvisionStateChanged(
-                        this, EVENT_SATELLITE_PROVISION_STATE_CHANGED, null);
-                mRegisteredForProvisionStateChangedWithPhone.set(true);
-            }
         }
     }
 
@@ -2547,15 +2436,6 @@
                         this, EVENT_PENDING_DATAGRAMS, null);
                 mRegisteredForPendingDatagramCountWithSatelliteService.set(true);
             }
-        } else {
-            Phone phone = SatelliteServiceUtils.getPhone();
-            if (phone == null) {
-                loge("registerForPendingDatagramCount: satellite phone is "
-                        + "not initialized yet");
-            } else if (!mRegisteredForPendingDatagramCountWithPhone.get()) {
-                phone.registerForPendingDatagramCount(this, EVENT_PENDING_DATAGRAMS, null);
-                mRegisteredForPendingDatagramCountWithPhone.set(true);
-            }
         }
     }
 
@@ -2566,15 +2446,20 @@
                         this, EVENT_SATELLITE_MODEM_STATE_CHANGED, null);
                 mRegisteredForSatelliteModemStateChangedWithSatelliteService.set(true);
             }
-        } else {
-            Phone phone = SatelliteServiceUtils.getPhone();
-            if (phone == null) {
-                loge("registerForSatelliteModemStateChanged: satellite phone is "
-                        + "not initialized yet");
-            } else if (!mRegisteredForSatelliteModemStateChangedWithPhone.get()) {
-                phone.registerForSatelliteModemStateChanged(
-                        this, EVENT_SATELLITE_MODEM_STATE_CHANGED, null);
-                mRegisteredForSatelliteModemStateChangedWithPhone.set(true);
+        }
+    }
+
+    private void registerForNtnSignalStrengthChanged() {
+        if (!mFeatureFlags.oemEnabledSatelliteFlag()) {
+            logd("registerForNtnSignalStrengthChanged: oemEnabledSatelliteFlag is disabled");
+            return;
+        }
+
+        if (mSatelliteModemInterface.isSatelliteServiceSupported()) {
+            if (!mRegisteredForNtnSignalStrengthChanged.get()) {
+                mSatelliteModemInterface.registerForNtnSignalStrengthChanged(
+                        this, EVENT_NTN_SIGNAL_STRENGTH_CHANGED, null);
+                mRegisteredForNtnSignalStrengthChanged.set(true);
             }
         }
     }
@@ -2586,16 +2471,16 @@
             mIsSatelliteProvisioned = provisioned;
         }
 
-        List<ISatelliteProvisionStateCallback> toBeRemoved = new ArrayList<>();
+        List<ISatelliteProvisionStateCallback> deadCallersList = new ArrayList<>();
         mSatelliteProvisionStateChangedListeners.values().forEach(listener -> {
             try {
                 listener.onSatelliteProvisionStateChanged(provisioned);
             } catch (RemoteException e) {
                 logd("handleSatelliteProvisionStateChangedEvent RemoteException: " + e);
-                toBeRemoved.add(listener);
+                deadCallersList.add(listener);
             }
         });
-        toBeRemoved.forEach(listener -> {
+        deadCallersList.forEach(listener -> {
             mSatelliteProvisionStateChangedListeners.remove(listener.asBinder());
         });
     }
@@ -2610,7 +2495,7 @@
                         || ((mIsSatelliteEnabled == null || isSatelliteEnabled())
                         && !mWaitingForDisableSatelliteModemResponse)) {
                     int error = (state == SatelliteManager.SATELLITE_MODEM_STATE_OFF)
-                            ? SatelliteManager.SATELLITE_RESULT_SUCCESS
+                            ? SATELLITE_RESULT_SUCCESS
                             : SatelliteManager.SATELLITE_RESULT_INVALID_MODEM_STATE;
                     Consumer<Integer> callback = null;
                     synchronized (mSatelliteEnabledRequestLock) {
@@ -2636,6 +2521,31 @@
         }
     }
 
+    private void handleEventNtnSignalStrengthChanged(NtnSignalStrength ntnSignalStrength) {
+        logd("handleEventNtnSignalStrengthChanged: ntnSignalStrength=" + ntnSignalStrength);
+        if (!mFeatureFlags.oemEnabledSatelliteFlag()) {
+            logd("handleEventNtnSignalStrengthChanged: oemEnabledSatelliteFlag is disabled");
+            return;
+        }
+
+        synchronized (mNtnSignalsStrengthLock) {
+            mNtnSignalStrength = ntnSignalStrength;
+        }
+
+        List<INtnSignalStrengthCallback> deadCallersList = new ArrayList<>();
+        mNtnSignalStrengthChangedListeners.values().forEach(listener -> {
+            try {
+                listener.onNtnSignalStrengthChanged(ntnSignalStrength);
+            } catch (RemoteException e) {
+                logd("handleEventNtnSignalStrengthChanged RemoteException: " + e);
+                deadCallersList.add(listener);
+            }
+        });
+        deadCallersList.forEach(listener -> {
+            mNtnSignalStrengthChangedListeners.remove(listener.asBinder());
+        });
+    }
+
     @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE)
     protected void setSettingsKeyForSatelliteMode(int val) {
         logd("setSettingsKeyForSatelliteMode val: " + val);
@@ -2668,7 +2578,7 @@
                 synchronized (mIsSatelliteEnabledLock) {
                     mIsSatelliteEnabled = mSatelliteEnabledRequest.enableSatellite;
                 }
-                mSatelliteEnabledRequest.callback.accept(SatelliteManager.SATELLITE_RESULT_SUCCESS);
+                mSatelliteEnabledRequest.callback.accept(SATELLITE_RESULT_SUCCESS);
                 updateSatelliteEnabledState(
                         mSatelliteEnabledRequest.enableSatellite,
                         "EVENT_SET_SATELLITE_ENABLED_DONE");
@@ -2712,6 +2622,7 @@
     private void configureSatellitePlmnForCarrier(int subId) {
         logd("configureSatellitePlmnForCarrier");
         if (!mFeatureFlags.carrierEnabledSatelliteFlag()) {
+            logd("configureSatellitePlmnForCarrier: carrierEnabledSatelliteFlag is disabled");
             return;
         }
         synchronized (mSupportedSatelliteServicesLock) {
@@ -2737,6 +2648,8 @@
 
     private void updateSupportedSatelliteServicesForActiveSubscriptions() {
         if (!mFeatureFlags.carrierEnabledSatelliteFlag()) {
+            logd("updateSupportedSatelliteServicesForActiveSubscriptions: "
+                    + "carrierEnabledSatelliteFlag is disabled");
             return;
         }
 
@@ -2764,6 +2677,7 @@
     @NonNull
     private List<String> readSatellitePlmnsFromOverlayConfig() {
         if (!mFeatureFlags.carrierEnabledSatelliteFlag()) {
+            logd("readSatellitePlmnsFromOverlayConfig: carrierEnabledSatelliteFlag is disabled");
             return new ArrayList<>();
         }
 
@@ -3010,7 +2924,7 @@
 
         if (!isSatelliteSupportedForCarrier(subId)) {
             logd("Satellite for carrier is not supported. Only user setting is stored");
-            callback.accept(SatelliteManager.SATELLITE_RESULT_SUCCESS);
+            callback.accept(SATELLITE_RESULT_SUCCESS);
             return;
         }
 
@@ -3034,10 +2948,41 @@
                 callback.accept(SatelliteManager.SATELLITE_RESULT_INVALID_TELEPHONY_STATE);
             }
         } else {
-            callback.accept(SatelliteManager.SATELLITE_RESULT_SUCCESS);
+            callback.accept(SATELLITE_RESULT_SUCCESS);
         }
     }
 
+    @SatelliteManager.SatelliteResult private int evaluateOemSatelliteRequestAllowed(
+            boolean isProvisionRequired) {
+        if (!mFeatureFlags.oemEnabledSatelliteFlag()) {
+            logd("oemEnabledSatelliteFlag is disabled");
+            return SatelliteManager.SATELLITE_RESULT_REQUEST_NOT_SUPPORTED;
+        }
+        if (!mSatelliteModemInterface.isSatelliteServiceSupported()) {
+            return SatelliteManager.SATELLITE_RESULT_REQUEST_NOT_SUPPORTED;
+        }
+
+        Boolean satelliteSupported = isSatelliteSupportedInternal();
+        if (satelliteSupported == null) {
+            return SatelliteManager.SATELLITE_RESULT_INVALID_TELEPHONY_STATE;
+        }
+        if (!satelliteSupported) {
+            return SatelliteManager.SATELLITE_RESULT_NOT_SUPPORTED;
+        }
+
+        if (isProvisionRequired) {
+            Boolean satelliteProvisioned = isSatelliteProvisioned();
+            if (satelliteProvisioned == null) {
+                return SatelliteManager.SATELLITE_RESULT_INVALID_TELEPHONY_STATE;
+            }
+            if (!satelliteProvisioned) {
+                return SatelliteManager.SATELLITE_RESULT_SERVICE_NOT_PROVISIONED;
+            }
+        }
+
+        return SATELLITE_RESULT_SUCCESS;
+    }
+
     private static void logd(@NonNull String log) {
         Rlog.d(TAG, log);
     }
diff --git a/src/java/com/android/internal/telephony/satellite/SatelliteModemInterface.java b/src/java/com/android/internal/telephony/satellite/SatelliteModemInterface.java
index 6ecb642..62f7371 100644
--- a/src/java/com/android/internal/telephony/satellite/SatelliteModemInterface.java
+++ b/src/java/com/android/internal/telephony/satellite/SatelliteModemInterface.java
@@ -31,10 +31,12 @@
 import android.os.RegistrantList;
 import android.os.RemoteException;
 import android.telephony.Rlog;
+import android.telephony.satellite.NtnSignalStrength;
 import android.telephony.satellite.SatelliteCapabilities;
 import android.telephony.satellite.SatelliteDatagram;
 import android.telephony.satellite.SatelliteManager;
 import android.telephony.satellite.SatelliteManager.SatelliteException;
+import android.telephony.satellite.stub.INtnSignalStrengthConsumer;
 import android.telephony.satellite.stub.ISatellite;
 import android.telephony.satellite.stub.ISatelliteCapabilitiesConsumer;
 import android.telephony.satellite.stub.ISatelliteListener;
@@ -87,6 +89,8 @@
     @NonNull private final RegistrantList mPendingDatagramsRegistrants = new RegistrantList();
     @NonNull private final RegistrantList mSatelliteDatagramsReceivedRegistrants =
             new RegistrantList();
+    @NonNull private final RegistrantList mNtnSignalStrengthChangedRegistrants =
+            new RegistrantList();
 
     @NonNull private final ISatelliteListener mListener = new ISatelliteListener.Stub() {
         @Override
@@ -136,6 +140,13 @@
             }
             mDatagramTransferStateChangedRegistrants.notifyResult(datagramTransferState);
         }
+
+        @Override
+        public void onNtnSignalStrengthChanged(
+                android.telephony.satellite.stub.NtnSignalStrength ntnSignalStrength) {
+            mNtnSignalStrengthChangedRegistrants.notifyResult(
+                    SatelliteServiceUtils.fromModemInterface(ntnSignalStrength));
+        }
     };
 
     /**
@@ -441,6 +452,27 @@
     }
 
     /**
+     * Registers for non-terrestrial signal strength level changed.
+     *
+     * @param h Handler for notification message.
+     * @param what User-defined message code.
+     * @param obj User object.
+     */
+    public void registerForNtnSignalStrengthChanged(
+            @NonNull Handler h, int what, @Nullable Object obj) {
+        mNtnSignalStrengthChangedRegistrants.add(h, what, obj);
+    }
+
+    /**
+     * Unregisters for non-terrestrial signal strength level changed.
+     *
+     * @param h Handler to be removed from the registrant list.
+     */
+    public void unregisterForNtnSignalStrengthChanged(@NonNull Handler h) {
+        mNtnSignalStrengthChangedRegistrants.remove(h);
+    }
+
+    /**
      * Request to enable or disable the satellite service listening mode.
      * Listening mode allows the satellite service to listen for incoming pages.
      *
@@ -1153,6 +1185,102 @@
         }
     }
 
+    /**
+     * Request to get the signal strength of the satellite connection.
+     *
+     * @param message The Message to send to result of the operation to.
+     */
+    public void requestNtnSignalStrength(@NonNull Message message) {
+        if (mSatelliteService != null) {
+            try {
+                mSatelliteService.requestSignalStrength(
+                        new IIntegerConsumer.Stub() {
+                            @Override
+                            public void accept(int result) {
+                                int error = SatelliteServiceUtils.fromSatelliteError(result);
+                                logd("requestNtnSignalStrength: " + error);
+                                Binder.withCleanCallingIdentity(() ->
+                                        sendMessageWithResult(message, null, error));
+                            }
+                        }, new INtnSignalStrengthConsumer.Stub() {
+                            @Override
+                            public void accept(NtnSignalStrength result) {
+                                logd("requestNtnSignalStrength: " + result);
+                                Binder.withCleanCallingIdentity(() -> sendMessageWithResult(
+                                        message, result,
+                                        SatelliteManager.SATELLITE_RESULT_SUCCESS));
+                            }
+                        });
+            } catch (RemoteException e) {
+                loge("requestNtnSignalStrength: RemoteException " + e);
+                sendMessageWithResult(message, null,
+                        SatelliteManager.SATELLITE_RESULT_SERVICE_ERROR);
+            }
+        } else {
+            loge("requestNtnSignalStrength: Satellite service is unavailable.");
+            sendMessageWithResult(message, null,
+                    SatelliteManager.SATELLITE_RESULT_RADIO_NOT_AVAILABLE);
+        }
+    }
+
+    /**
+     * The satellite service should report the NTN signal strength via
+     * ISatelliteListener#onNtnSignalStrengthChanged when the NTN signal strength changes.
+     *
+     * @param message The Message to send to result of the operation to.
+     */
+    public void startSendingNtnSignalStrength(@NonNull Message message) {
+        if (mSatelliteService != null) {
+            try {
+                mSatelliteService.startSendingNtnSignalStrength(new IIntegerConsumer.Stub() {
+                    @Override
+                    public void accept(int result) {
+                        int error = SatelliteServiceUtils.fromSatelliteError(result);
+                        logd("startSendingNtnSignalStrength: " + error);
+                        Binder.withCleanCallingIdentity(() ->
+                                sendMessageWithResult(message, null, error));
+                    }
+                });
+            } catch (RemoteException e) {
+                loge("startSendingNtnSignalStrength: RemoteException " + e);
+                sendMessageWithResult(message, null,
+                        SatelliteManager.SATELLITE_RESULT_SERVICE_ERROR);
+            }
+        } else {
+            loge("startSendingNtnSignalStrength: Satellite service is unavailable.");
+            sendMessageWithResult(message, null,
+                    SatelliteManager.SATELLITE_RESULT_RADIO_NOT_AVAILABLE);
+        }
+    }
+
+    /**
+     * The satellite service should stop reporting NTN signal strength to the framework.
+     *
+     * @param message The Message to send to result of the operation to.
+     */
+    public void stopSendingNtnSignalStrength(@NonNull Message message) {
+        if (mSatelliteService != null) {
+            try {
+                mSatelliteService.stopSendingNtnSignalStrength(new IIntegerConsumer.Stub() {
+                    @Override
+                    public void accept(int result) {
+                        int error = SatelliteServiceUtils.fromSatelliteError(result);
+                        logd("stopSendingNtnSignalStrength: " + error);
+                        Binder.withCleanCallingIdentity(() ->
+                                sendMessageWithResult(message, null, error));
+                    }
+                });
+            } catch (RemoteException e) {
+                loge("stopSendingNtnSignalStrength: RemoteException " + e);
+                sendMessageWithResult(message, null,
+                        SatelliteManager.SATELLITE_RESULT_SERVICE_ERROR);
+            }
+        } else {
+            loge("stopSendingNtnSignalStrength: Satellite service is unavailable.");
+            sendMessageWithResult(message, null,
+                    SatelliteManager.SATELLITE_RESULT_RADIO_NOT_AVAILABLE);
+        }
+    }
 
     public boolean isSatelliteServiceSupported() {
         return mIsSatelliteServiceSupported;
diff --git a/src/java/com/android/internal/telephony/satellite/SatelliteServiceUtils.java b/src/java/com/android/internal/telephony/satellite/SatelliteServiceUtils.java
index cad9bfb..b42c7d4 100644
--- a/src/java/com/android/internal/telephony/satellite/SatelliteServiceUtils.java
+++ b/src/java/com/android/internal/telephony/satellite/SatelliteServiceUtils.java
@@ -31,6 +31,7 @@
 import android.telephony.Rlog;
 import android.telephony.SubscriptionManager;
 import android.telephony.satellite.AntennaPosition;
+import android.telephony.satellite.NtnSignalStrength;
 import android.telephony.satellite.PointingInfo;
 import android.telephony.satellite.SatelliteCapabilities;
 import android.telephony.satellite.SatelliteDatagram;
@@ -39,10 +40,8 @@
 import android.telephony.satellite.stub.SatelliteModemState;
 import android.telephony.satellite.stub.SatelliteResult;
 
-import com.android.internal.telephony.CommandException;
 import com.android.internal.telephony.Phone;
 import com.android.internal.telephony.PhoneFactory;
-import com.android.internal.telephony.RILUtils;
 import com.android.internal.telephony.subscription.SubscriptionManagerService;
 
 import java.util.Arrays;
@@ -214,6 +213,16 @@
     }
 
     /**
+     * Convert non-terrestrial signal strength from service definition to framework definition.
+     * @param ntnSignalStrength The non-terrestrial signal strength from the satellite service.
+     * @return The converted non-terrestrial signal strength for the framework.
+     */
+    @Nullable public static NtnSignalStrength fromModemInterface(
+            android.telephony.satellite.stub.NtnSignalStrength ntnSignalStrength) {
+        return new NtnSignalStrength(ntnSignalStrength.signalStrengthLevel);
+    }
+
+    /**
      * Convert SatelliteDatagram from framework definition to service definition.
      * @param datagram The SatelliteDatagram from the framework.
      * @return The converted SatelliteDatagram for the satellite service.
@@ -241,11 +250,7 @@
             errorCode = SatelliteManager.SATELLITE_RESULT_SUCCESS;
         } else {
             errorCode = SatelliteManager.SATELLITE_RESULT_ERROR;
-            if (ar.exception instanceof CommandException) {
-                CommandException.Error error = ((CommandException) ar.exception).getCommandError();
-                errorCode = RILUtils.convertToSatelliteError(error);
-                loge(caller + " CommandException: " + ar.exception);
-            } else if (ar.exception instanceof SatelliteManager.SatelliteException) {
+            if (ar.exception instanceof SatelliteManager.SatelliteException) {
                 errorCode = ((SatelliteManager.SatelliteException) ar.exception).getErrorCode();
                 loge(caller + " SatelliteException: " + ar.exception);
             } else {
diff --git a/tests/telephonytests/src/com/android/internal/telephony/CarrierKeyDownloadMgrTest.java b/tests/telephonytests/src/com/android/internal/telephony/CarrierKeyDownloadMgrTest.java
index 40e1821..9fd89ff 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/CarrierKeyDownloadMgrTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/CarrierKeyDownloadMgrTest.java
@@ -94,7 +94,7 @@
         super.setUp(getClass().getSimpleName());
         mBundle = mContextFixture.getCarrierConfigBundle();
         when(mCarrierConfigManager.getConfigForSubId(anyInt(), any())).thenReturn(mBundle);
-
+        when(mUserManager.isUserUnlocked()).thenReturn(true);
         // Capture listener to emulate the carrier config change notification used later
         ArgumentCaptor<CarrierConfigManager.CarrierConfigChangeListener> listenerArgumentCaptor =
                 ArgumentCaptor.forClass(CarrierConfigManager.CarrierConfigChangeListener.class);
@@ -342,7 +342,7 @@
      **/
     @Test
     @SmallTest
-    public void testCarrierConfigChanged() {
+    public void testCarrierConfigChangedWithUserUnlocked() {
         CarrierConfigManager carrierConfigManager = (CarrierConfigManager)
                 mContext.getSystemService(Context.CARRIER_CONFIG_SERVICE);
         int slotId = mPhone.getPhoneId();
@@ -360,6 +360,57 @@
         assertEquals(1, mCarrierKeyDM.mCarrierId);
     }
 
+    @Test
+    @SmallTest
+    public void testCarrierConfigChangedWithUserLocked() {
+        when(mUserManager.isUserUnlocked()).thenReturn(false);
+        CarrierConfigManager carrierConfigManager = (CarrierConfigManager)
+                mContext.getSystemService(Context.CARRIER_CONFIG_SERVICE);
+        int slotId = mPhone.getPhoneId();
+        PersistableBundle bundle = carrierConfigManager.getConfigForSubId(slotId);
+        bundle.putInt(CarrierConfigManager.IMSI_KEY_AVAILABILITY_INT, 3);
+        bundle.putString(CarrierConfigManager.IMSI_KEY_DOWNLOAD_URL_STRING, mURL);
+
+        when(mTelephonyManager.getSimOperator(anyInt())).thenReturn("310260");
+        when(mTelephonyManager.getSimCarrierId()).thenReturn(1);
+        mCarrierConfigChangeListener.onCarrierConfigChanged(0 /* slotIndex */,
+                SubscriptionManager.INVALID_SUBSCRIPTION_ID,
+                TelephonyManager.UNKNOWN_CARRIER_ID, TelephonyManager.UNKNOWN_CARRIER_ID);
+        processAllMessages();
+        assertNull(mCarrierKeyDM.mMccMncForDownload);
+        assertEquals(0, mCarrierKeyDM.mCarrierId);
+    }
+
+    @Test
+    @SmallTest
+    public void testUserLockedAfterCarrierConfigChanged() {
+        // User is locked at beginning
+        when(mUserManager.isUserUnlocked()).thenReturn(false);
+        CarrierConfigManager carrierConfigManager = (CarrierConfigManager)
+                mContext.getSystemService(Context.CARRIER_CONFIG_SERVICE);
+        int slotId = mPhone.getPhoneId();
+        PersistableBundle bundle = carrierConfigManager.getConfigForSubId(slotId);
+        bundle.putInt(CarrierConfigManager.IMSI_KEY_AVAILABILITY_INT, 3);
+        bundle.putString(CarrierConfigManager.IMSI_KEY_DOWNLOAD_URL_STRING, mURL);
+
+        // Carrier config change received
+        when(mTelephonyManager.getSimOperator(anyInt())).thenReturn("310260");
+        when(mTelephonyManager.getSimCarrierId()).thenReturn(1);
+        mCarrierConfigChangeListener.onCarrierConfigChanged(0 /* slotIndex */,
+                SubscriptionManager.INVALID_SUBSCRIPTION_ID,
+                TelephonyManager.UNKNOWN_CARRIER_ID, TelephonyManager.UNKNOWN_CARRIER_ID);
+        processAllMessages();
+
+        // User unlocked event received
+        Intent mIntent = new Intent(Intent.ACTION_USER_UNLOCKED);
+        mContext.sendBroadcast(mIntent);
+        when(mUserManager.isUserUnlocked()).thenReturn(true);
+        processAllMessages();
+
+        assertEquals("310260", mCarrierKeyDM.mMccMncForDownload);
+        assertEquals(1, mCarrierKeyDM.mCarrierId);
+    }
+
     /**
      * Tests notifying carrier config change from listener with an empty key.
      * Verify that the carrier keys are removed if IMSI_KEY_DOWNLOAD_URL_STRING is null.
diff --git a/tests/telephonytests/src/com/android/internal/telephony/ContextFixture.java b/tests/telephonytests/src/com/android/internal/telephony/ContextFixture.java
index ea19b62..3c8db99 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/ContextFixture.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/ContextFixture.java
@@ -783,7 +783,7 @@
         doReturn(mBundle).when(mCarrierConfigManager).getConfigForSubId(anyInt(), anyString());
         doAnswer(invocation -> mNetworkId++).when(mNetwork).getNetId();
         doReturn(mNetwork).when(mConnectivityManager).registerNetworkAgent(
-                any(), any(), any(), any(), any(), any(), anyInt());
+                any(), any(), any(), any(), any(), any(), any(), anyInt());
 
         doReturn(true).when(mEuiccManager).isEnabled();
 
diff --git a/tests/telephonytests/src/com/android/internal/telephony/DeviceStateMonitorTest.java b/tests/telephonytests/src/com/android/internal/telephony/DeviceStateMonitorTest.java
index 28a37f7..018759a 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/DeviceStateMonitorTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/DeviceStateMonitorTest.java
@@ -20,7 +20,9 @@
 import static android.hardware.radio.V1_0.DeviceStateType.POWER_SAVE_MODE;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertTrue;
 import static org.mockito.Matchers.anyBoolean;
 import static org.mockito.Matchers.anyInt;
 import static org.mockito.Matchers.eq;
@@ -30,6 +32,7 @@
 import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.reset;
 import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
 
 import static java.util.Arrays.asList;
 
@@ -40,22 +43,31 @@
 import android.hardware.radio.V1_5.IndicationFilter;
 import android.net.ConnectivityManager;
 import android.net.TetheringManager;
+import android.os.AsyncResult;
 import android.os.BatteryManager;
+import android.os.Handler;
+import android.os.Looper;
 import android.os.Message;
 import android.test.suitebuilder.annotation.MediumTest;
 import android.testing.AndroidTestingRunner;
 import android.testing.TestableLooper;
 
+import com.android.internal.telephony.flags.FeatureFlags;
+
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.ArgumentCaptor;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
 
 import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 import java.util.ArrayList;
 import java.util.Map;
+import java.util.concurrent.Semaphore;
+import java.util.concurrent.TimeUnit;
 
 @RunWith(AndroidTestingRunner.class)
 @TestableLooper.RunWithLooper
@@ -114,6 +126,7 @@
 
     private static final int STATE_OFF = 0;
     private static final int STATE_ON = 1;
+    private static final long TIMEOUT = 500;
 
     // The keys are the single IndicationFilter flags,
     // The values are the array of states, when one state turn on, the corresponding
@@ -135,6 +148,9 @@
     UiModeManager mUiModeManager;
 
     private DeviceStateMonitor mDSM;
+    private TestSatelliteController mSatelliteControllerUT;
+
+    @Mock private FeatureFlags mFeatureFlags;
 
     // Given a stateType, return the event type that can change the state
     private int state2Event(@StateType int stateType) {
@@ -162,11 +178,12 @@
     @Before
     public void setUp() throws Exception {
         super.setUp(getClass().getSimpleName());
+        MockitoAnnotations.initMocks(this);
         mUiModeManager = mock(UiModeManager.class);
         mContextFixture.setSystemService(Context.UI_MODE_SERVICE, mUiModeManager);
         // We don't even need a mock executor, we just need to not throw.
         doReturn(null).when(mContextFixture.getTestDouble()).getMainExecutor();
-        mDSM = new DeviceStateMonitor(mPhone);
+        mDSM = new DeviceStateMonitor(mPhone, mFeatureFlags);
 
         // Initialize with ALL states off
         updateAllStatesToOff();
@@ -177,6 +194,7 @@
 
     @After
     public void tearDown() throws Exception {
+        mSatelliteControllerUT = null;
         mDSM = null;
         super.tearDown();
     }
@@ -453,4 +471,160 @@
         verify(mSimulatedCommandsVerifier).setUnsolResponseFilter(
                 eq(INDICATION_FILTERS_MINIMUM), nullable(Message.class));
     }
+
+    @Test
+    public void testRegisterForSignalStrengthReportDecisionWithFeatureEnabled() {
+        logd("testRegisterForSignalStrengthReportDecisionWithFeatureEnabled()");
+        when(mFeatureFlags.oemEnabledSatelliteFlag()).thenReturn(true);
+        mSatelliteControllerUT = new TestSatelliteController(Looper.myLooper(), mDSM);
+
+        updateState(STATE_TYPE_RADIO_OFF_OR_NOT_AVAILABLE, 0);
+        updateState(STATE_TYPE_SCREEN, STATE_OFF);
+        mSatelliteControllerUT.resetCount();
+        sEventDeviceStatusChanged.drainPermits();
+
+        updateState(STATE_TYPE_SCREEN, STATE_ON);
+        assertTrue(waitForEventDeviceStatusChanged());
+        assertEquals(0, mSatelliteControllerUT.getStartEventCount());
+        assertEquals(1, mSatelliteControllerUT.getStopEventCount());
+        mSatelliteControllerUT.resetCount();
+
+        mSatelliteControllerUT.resetCount();
+        updateState(STATE_TYPE_SCREEN, STATE_OFF);
+        assertTrue(waitForEventDeviceStatusChanged());
+        assertEquals(0, mSatelliteControllerUT.getStartEventCount());
+        assertEquals(1, mSatelliteControllerUT.getStopEventCount());
+        mSatelliteControllerUT.resetCount();
+
+        updateState(STATE_TYPE_RADIO_ON, 0);
+        assertTrue(waitForEventDeviceStatusChanged());
+        assertEquals(0, mSatelliteControllerUT.getStartEventCount());
+        assertEquals(1, mSatelliteControllerUT.getStopEventCount());
+        mSatelliteControllerUT.resetCount();
+
+        updateState(STATE_TYPE_SCREEN, STATE_ON);
+        assertTrue(waitForEventDeviceStatusChanged());
+        assertEquals(1, mSatelliteControllerUT.getStartEventCount());
+        assertEquals(0, mSatelliteControllerUT.getStopEventCount());
+        mSatelliteControllerUT.resetCount();
+
+        updateState(STATE_TYPE_RADIO_OFF_OR_NOT_AVAILABLE, 0);
+        assertTrue(waitForEventDeviceStatusChanged());
+        assertEquals(0, mSatelliteControllerUT.getStartEventCount());
+        assertEquals(1, mSatelliteControllerUT.getStopEventCount());
+    }
+
+    @Test
+    public void testRegisterForSignalStrengthReportDecisionWithFeatureDisabled() {
+        logd("testRegisterForSignalStrengthReportDecisionWithFeatureDisabled()");
+        when(mFeatureFlags.oemEnabledSatelliteFlag()).thenReturn(false);
+        mSatelliteControllerUT = new TestSatelliteController(Looper.myLooper(), mDSM);
+
+        updateState(STATE_TYPE_RADIO_OFF_OR_NOT_AVAILABLE, 0);
+        updateState(STATE_TYPE_SCREEN, STATE_OFF);
+        mSatelliteControllerUT.resetCount();
+        sEventDeviceStatusChanged.drainPermits();
+
+
+        /* Sending stop ntn signal strength as radio is off */
+        updateState(STATE_TYPE_SCREEN, STATE_ON);
+        assertFalse(waitForEventDeviceStatusChanged());
+        assertEquals(0, mSatelliteControllerUT.getStartEventCount());
+        assertEquals(0, mSatelliteControllerUT.getStopEventCount());
+
+        updateState(STATE_TYPE_SCREEN, STATE_OFF);
+        assertFalse(waitForEventDeviceStatusChanged());
+        assertEquals(0, mSatelliteControllerUT.getStartEventCount());
+        assertEquals(0, mSatelliteControllerUT.getStopEventCount());
+
+        updateState(STATE_TYPE_RADIO_ON, 0);
+        assertFalse(waitForEventDeviceStatusChanged());
+        assertEquals(0, mSatelliteControllerUT.getStartEventCount());
+        assertEquals(0, mSatelliteControllerUT.getStopEventCount());
+
+        updateState(STATE_TYPE_SCREEN, STATE_ON);
+        assertFalse(waitForEventDeviceStatusChanged());
+        assertEquals(0, mSatelliteControllerUT.getStartEventCount());
+        assertEquals(0, mSatelliteControllerUT.getStopEventCount());
+
+        updateState(STATE_TYPE_RADIO_OFF_OR_NOT_AVAILABLE, 0);
+        assertFalse(waitForEventDeviceStatusChanged());
+        assertEquals(0, mSatelliteControllerUT.getStartEventCount());
+        assertEquals(0, mSatelliteControllerUT.getStopEventCount());
+    }
+
+    private static Semaphore sEventDeviceStatusChanged = new Semaphore(0);
+    private boolean waitForEventDeviceStatusChanged() {
+        try {
+            if (!sEventDeviceStatusChanged.tryAcquire(TIMEOUT, TimeUnit.MILLISECONDS)) {
+                logd("Time out to receive EVENT_DEVICE_STATUS_CHANGED");
+                return false;
+            }
+        } catch (Exception ex) {
+            logd("waitForEventDeviceStatusChanged: ex=" + ex);
+            return false;
+        }
+        return true;
+    }
+
+    private static class TestSatelliteController extends Handler {
+        public static final int EVENT_DEVICE_STATUS_CHANGED = 35;
+        private final DeviceStateMonitor mDsm;
+        private int mStartEventCount;
+        private int mStopEventCount;
+
+        TestSatelliteController(Looper looper, DeviceStateMonitor dsm) {
+            super(looper);
+            mDsm = dsm;
+            mDsm.registerForSignalStrengthReportDecision(this, EVENT_DEVICE_STATUS_CHANGED, null);
+        }
+
+        /**
+         * Resets the count of occurred events.
+         */
+        public void resetCount() {
+            mStartEventCount = 0;
+            mStopEventCount = 0;
+        }
+
+        public int getStartEventCount() {
+            return mStartEventCount;
+        }
+
+        public int getStopEventCount() {
+            return mStopEventCount;
+        }
+
+        @Override
+        public void handleMessage(Message msg) {
+            switch(msg.what) {
+                case EVENT_DEVICE_STATUS_CHANGED: {
+                    logd("EVENT_DEVICE_STATUS_CHANGED");
+                    AsyncResult ar = (AsyncResult) msg.obj;
+                    boolean shouldReport = (boolean) ar.result;
+                    if (shouldReport) {
+                        startSendingNtnSignalStrength();
+                    } else {
+                        stopSendingNtnSignalStrength();
+                    }
+                    try {
+                        sEventDeviceStatusChanged.release();
+                    } catch (Exception ex) {
+                        logd("waitForEventDeviceStatusChanged: ex=" + ex);
+                    }
+                    break;
+                }
+                default:
+                    break;
+            }
+        }
+
+        private void startSendingNtnSignalStrength() {
+            mStartEventCount++;
+        }
+
+        private void stopSendingNtnSignalStrength() {
+            mStopEventCount++;
+        }
+    }
 }
diff --git a/tests/telephonytests/src/com/android/internal/telephony/DisplayInfoControllerTest.java b/tests/telephonytests/src/com/android/internal/telephony/DisplayInfoControllerTest.java
index f729b80..8dd350f 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/DisplayInfoControllerTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/DisplayInfoControllerTest.java
@@ -42,11 +42,14 @@
 import android.testing.TestableLooper;
 import android.text.TextUtils;
 
+import com.android.internal.telephony.flags.FeatureFlags;
+
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.ArgumentCaptor;
+import org.mockito.Mockito;
 
 import java.util.Collections;
 import java.util.concurrent.Executor;
@@ -54,17 +57,18 @@
 @RunWith(AndroidTestingRunner.class)
 @TestableLooper.RunWithLooper
 public class DisplayInfoControllerTest extends TelephonyTest {
-
     private static final int PHONE_ID = 0;
     private static final String MCC = "600";
     private static final String MNC = "01";
     private static final String NUMERIC = MCC + MNC;
     private static final String NETWORK = "TestNet";
 
+    // Mocked classes
+    private FeatureFlags mFeatureFlags;
+
     private DisplayInfoController mDic;
     private ServiceStateTracker mSst;
     private ServiceStateTrackerTestHandler mSstHandler;
-    private SignalStrengthController mSsc;
     private PersistableBundle mBundle;
     private CarrierConfigManager.CarrierConfigChangeListener mCarrierConfigChangeListener;
 
@@ -75,8 +79,8 @@
 
         @Override
         public void onLooperPrepared() {
-            mSsc = new SignalStrengthController(mPhone);
-            doReturn(mSsc).when(mPhone).getSignalStrengthController();
+            SignalStrengthController ssc = new SignalStrengthController(mPhone);
+            doReturn(ssc).when(mPhone).getSignalStrengthController();
             doReturn(new ServiceState()).when(mPhone).getServiceState();
             doReturn(NUMERIC).when(mTelephonyManager).getSimOperatorNumericForPhone(eq(PHONE_ID));
             doReturn(NETWORK).when(mTelephonyManager).getSimOperatorNameForPhone(eq(PHONE_ID));
@@ -101,6 +105,7 @@
         logd("DisplayInfoControllerTest setup!");
         super.setUp(getClass().getSimpleName());
 
+        mFeatureFlags = Mockito.mock(FeatureFlags.class);
         doReturn((Executor) Runnable::run).when(mContext).getMainExecutor();
         mBundle = mContextFixture.getCarrierConfigBundle();
         mSstHandler = new ServiceStateTrackerTestHandler(getClass().getSimpleName());
@@ -191,7 +196,7 @@
         assertFalse(ss.getRoaming()); // home
 
         doReturn(mSst).when(mPhone).getServiceStateTracker();
-        mDic = new DisplayInfoController(mPhone);
+        mDic = new DisplayInfoController(mPhone, mFeatureFlags);
         mDic.updateTelephonyDisplayInfo();
         TelephonyDisplayInfo tdi = mDic.getTelephonyDisplayInfo();
 
@@ -211,7 +216,7 @@
         assertFalse(ss.getRoaming()); // home
 
         doReturn(mSst).when(mPhone).getServiceStateTracker();
-        mDic = new DisplayInfoController(mPhone);
+        mDic = new DisplayInfoController(mPhone, mFeatureFlags);
         mDic.updateTelephonyDisplayInfo();
         TelephonyDisplayInfo tdi = mDic.getTelephonyDisplayInfo();
 
@@ -232,7 +237,7 @@
         assertTrue(ss1.getRoaming()); // roam
 
         doReturn(mSst).when(mPhone).getServiceStateTracker();
-        mDic = new DisplayInfoController(mPhone);
+        mDic = new DisplayInfoController(mPhone, mFeatureFlags);
         mDic.updateTelephonyDisplayInfo();
         TelephonyDisplayInfo tdi = mDic.getTelephonyDisplayInfo();
 
@@ -254,7 +259,7 @@
         assertFalse(ss.getRoaming()); // home
 
         doReturn(mSst).when(mPhone).getServiceStateTracker();
-        mDic = new DisplayInfoController(mPhone);
+        mDic = new DisplayInfoController(mPhone, mFeatureFlags);
         mDic.updateTelephonyDisplayInfo();
         TelephonyDisplayInfo tdi = mDic.getTelephonyDisplayInfo();
 
@@ -275,10 +280,32 @@
         assertTrue(ss1.getRoaming()); // roam
 
         doReturn(mSst).when(mPhone).getServiceStateTracker();
-        mDic = new DisplayInfoController(mPhone);
+        mDic = new DisplayInfoController(mPhone, mFeatureFlags);
         mDic.updateTelephonyDisplayInfo();
         TelephonyDisplayInfo tdi = mDic.getTelephonyDisplayInfo();
 
         assertTrue(tdi.isRoaming());
     }
+
+    @Test
+    public void testIsRoamingOverride_HideRoamingIndicator() {
+        doReturn(true).when(mPhone).isPhoneTypeGsm();
+        mBundle.putStringArray(
+                CarrierConfigManager.KEY_GSM_ROAMING_NETWORKS_STRING_ARRAY, new String[] {NUMERIC});
+        mBundle.putBoolean(CarrierConfigManager.KEY_SHOW_ROAMING_INDICATOR_BOOL, false);
+        doReturn(true).when(mFeatureFlags).hideRoamingIcon();
+        sendCarrierConfigUpdate();
+
+        changeRegState(NetworkRegistrationInfo.REGISTRATION_STATE_HOME);
+        ServiceState ss1 = mSst.getServiceState();
+
+        assertTrue(ss1.getRoaming()); // roam
+
+        doReturn(mSst).when(mPhone).getServiceStateTracker();
+        mDic = new DisplayInfoController(mPhone, mFeatureFlags);
+        mDic.updateTelephonyDisplayInfo();
+        TelephonyDisplayInfo tdi = mDic.getTelephonyDisplayInfo();
+
+        assertFalse(tdi.isRoaming()); // display override
+    }
 }
diff --git a/tests/telephonytests/src/com/android/internal/telephony/SmsDispatchersControllerTest.java b/tests/telephonytests/src/com/android/internal/telephony/SmsDispatchersControllerTest.java
index b073cd4..dc63932 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/SmsDispatchersControllerTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/SmsDispatchersControllerTest.java
@@ -23,10 +23,12 @@
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.anyBoolean;
 import static org.mockito.Matchers.any;
 import static org.mockito.Matchers.anyString;
 import static org.mockito.Matchers.isNull;
 import static org.mockito.Mockito.anyInt;
+import static org.mockito.Mockito.doNothing;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.eq;
 import static org.mockito.Mockito.mock;
@@ -59,6 +61,8 @@
 import com.android.internal.telephony.domainselection.DomainSelectionConnection;
 import com.android.internal.telephony.domainselection.EmergencySmsDomainSelectionConnection;
 import com.android.internal.telephony.domainselection.SmsDomainSelectionConnection;
+import com.android.internal.telephony.emergency.EmergencyStateTracker;
+import com.android.internal.telephony.flags.FeatureFlags;
 import com.android.internal.telephony.uicc.IccUtils;
 
 import org.junit.After;
@@ -80,8 +84,8 @@
      */
     private static class TestSmsDispatchersController extends SmsDispatchersController {
         TestSmsDispatchersController(Phone phone, SmsStorageMonitor storageMonitor,
-                SmsUsageMonitor usageMonitor, Looper looper) {
-            super(phone, storageMonitor, usageMonitor, looper);
+                SmsUsageMonitor usageMonitor, Looper looper, FeatureFlags featureFlags) {
+            super(phone, storageMonitor, usageMonitor, looper, featureFlags);
         }
 
         public DomainSelectionConnectionHolder testGetDomainSelectionConnectionHolder(
@@ -104,6 +108,15 @@
             sendMultipartText(destAddr, scAddr, parts, sentIntents, deliveryIntents, messageUri,
                     callingPkg, persistMessage, priority, expectMore, validityPeriod, messageId);
         }
+
+        public void testNotifySmsSentToEmergencyStateTracker(String destAddr, long messageId) {
+            notifySmsSentToEmergencyStateTracker(destAddr, messageId);
+        }
+
+        public void testNotifySmsSentFailedToEmergencyStateTracker(String destAddr,
+                long messageId) {
+            notifySmsSentFailedToEmergencyStateTracker(destAddr, messageId);
+        }
     }
 
     /**
@@ -158,6 +171,7 @@
     private static final String ACTION_TEST_SMS_SENT = "TEST_SMS_SENT";
 
     // Mocked classes
+    private FeatureFlags mFeatureFlags;
     private SMSDispatcher.SmsTracker mTracker;
     private PendingIntent mSentIntent;
     private TestImsSmsDispatcher mImsSmsDispatcher;
@@ -165,6 +179,8 @@
     private TestSmsDispatcher mCdmaSmsDispatcher;
     private SmsDomainSelectionConnection mSmsDsc;
     private EmergencySmsDomainSelectionConnection mEmergencySmsDsc;
+    private EmergencyStateTracker mEmergencyStateTracker;
+    private CompletableFuture<Integer> mEmergencySmsFuture;
 
     private TestSmsDispatchersController mSmsDispatchersController;
     private boolean mInjectionCallbackTriggered = false;
@@ -174,10 +190,10 @@
     public void setUp() throws Exception {
         super.setUp(getClass().getSimpleName());
         mTracker = mock(SMSDispatcher.SmsTracker.class);
+        mFeatureFlags = mock(FeatureFlags.class);
         setupMockPackagePermissionChecks();
         mSmsDispatchersController = new TestSmsDispatchersController(mPhone, mSmsStorageMonitor,
-            mSmsUsageMonitor, mTestableLooper.getLooper());
-        setUpDomainSelectionConnectionAsNotSupported();
+            mSmsUsageMonitor, mTestableLooper.getLooper(), mFeatureFlags);
         processAllMessages();
     }
 
@@ -191,6 +207,7 @@
         mDscFuture = null;
         mSmsDispatchersController.dispose();
         mSmsDispatchersController = null;
+        mFeatureFlags = null;
         super.tearDown();
     }
 
@@ -436,9 +453,11 @@
     public void testSendEmergencyTextWhenDomainPs() throws Exception {
         setUpDomainSelectionConnection();
         setUpSmsDispatchers();
+        setUpEmergencyStateTracker(DisconnectCause.NOT_DISCONNECTED);
 
         mSmsDispatchersController.sendText("911", "2222", "text", mSentIntent, null, null,
                 "test-app", false, 0, false, 10, false, 1L, false);
+        processAllMessages();
 
         SmsDispatchersController.DomainSelectionConnectionHolder holder =
                 mSmsDispatchersController.testGetDomainSelectionConnectionHolder(true);
@@ -463,12 +482,92 @@
 
     @Test
     @SmallTest
-    public void testNotifyDomainSelectionTerminated() throws Exception {
+    public void testSendEmergencyTextWhenEmergencyStateTrackerReturnsFailure() throws Exception {
         setUpDomainSelectionConnection();
         setUpSmsDispatchers();
+        setUpEmergencyStateTracker(DisconnectCause.OUT_OF_SERVICE);
+
+        mSmsDispatchersController.sendText("911", "2222", "text", mSentIntent, null, null,
+                "test-app", false, 0, false, 10, false, 1L, false);
+        processAllMessages();
+
+        // Verify the domain selection requested regardless of the result of EmergencyStateTracker.
+        verify(mEmergencySmsDsc).requestDomainSelection(any(), any());
+    }
+
+    @Test
+    @SmallTest
+    public void testNotifySmsSentToEmergencyStateTracker() throws Exception {
+        setUpDomainSelectionEnabled(true);
+        setUpEmergencyStateTracker(DisconnectCause.NOT_DISCONNECTED);
+
+        mSmsDispatchersController.testNotifySmsSentToEmergencyStateTracker("911", 1L);
+        processAllMessages();
+
+        verify(mTelephonyManager).isEmergencyNumber(eq("911"));
+        verify(mEmergencyStateTracker).endSms(eq("1"), eq(true));
+    }
+
+    @Test
+    @SmallTest
+    public void testNotifySmsSentToEmergencyStateTrackerWithNonEmergencyNumber() throws Exception {
+        setUpDomainSelectionEnabled(true);
+        setUpEmergencyStateTracker(DisconnectCause.NOT_DISCONNECTED);
+
+        mSmsDispatchersController.testNotifySmsSentToEmergencyStateTracker("1234", 1L);
+        processAllMessages();
+
+        verify(mTelephonyManager).isEmergencyNumber(eq("1234"));
+        verify(mEmergencyStateTracker, never()).endSms(anyString(), anyBoolean());
+    }
+
+    @Test
+    @SmallTest
+    public void testNotifySmsSentToEmergencyStateTrackerWithoutEmergencyStateTracker()
+            throws Exception {
+        setUpDomainSelectionEnabled(true);
+        mSmsDispatchersController.testNotifySmsSentToEmergencyStateTracker("911", 1L);
+
+        verify(mTelephonyManager, never()).isEmergencyNumber(anyString());
+    }
+
+    @Test
+    @SmallTest
+    public void testNotifySmsSentFailedToEmergencyStateTracker() throws Exception {
+        setUpDomainSelectionEnabled(true);
+        setUpEmergencyStateTracker(DisconnectCause.NOT_DISCONNECTED);
+
+        mSmsDispatchersController.testNotifySmsSentFailedToEmergencyStateTracker("911", 1L);
+        processAllMessages();
+
+        verify(mTelephonyManager).isEmergencyNumber(eq("911"));
+        verify(mEmergencyStateTracker).endSms(eq("1"), eq(false));
+    }
+
+    @Test
+    @SmallTest
+    public void testNotifySmsSentFailedToEmergencyStateTrackerWithNonEmergencyNumber()
+            throws Exception {
+        setUpDomainSelectionEnabled(true);
+        setUpEmergencyStateTracker(DisconnectCause.NOT_DISCONNECTED);
+
+        mSmsDispatchersController.testNotifySmsSentFailedToEmergencyStateTracker("1234", 1L);
+        processAllMessages();
+
+        verify(mTelephonyManager).isEmergencyNumber(eq("1234"));
+        verify(mEmergencyStateTracker, never()).endSms(anyString(), anyBoolean());
+    }
+
+    @Test
+    @SmallTest
+    public void testNotifyDomainSelectionTerminatedWhenImsAvailableAndNormalSms() throws Exception {
+        setUpDomainSelectionConnection();
+        setUpSmsDispatchers();
+        when(mImsSmsDispatcher.isAvailable()).thenReturn(true);
 
         mSmsDispatchersController.sendText("1111", "2222", "text", mSentIntent, null, null,
                 "test-app", false, 0, false, 10, false, 1L, false);
+        processAllMessages();
 
         SmsDispatchersController.DomainSelectionConnectionHolder holder =
                 mSmsDispatchersController.testGetDomainSelectionConnectionHolder(false);
@@ -483,10 +582,7 @@
 
         DomainSelectionConnection.DomainSelectionConnectionCallback callback = captor.getValue();
         assertNotNull(callback);
-
-        mSmsDispatchersController.post(() -> {
-            callback.onSelectionTerminated(DisconnectCause.LOCAL);
-        });
+        callback.onSelectionTerminated(DisconnectCause.LOCAL);
         processAllMessages();
 
         verify(mSmsDsc, never()).finishSelection();
@@ -494,13 +590,49 @@
         assertFalse(holder.isDomainSelectionRequested());
         assertEquals(0, holder.getPendingRequests().size());
 
-        // We can use the IntentReceiver for receiving the sent result, but it can be reported as
-        // a flaky test since sometimes broadcasts can take a long time if the system is under load.
-        // At this point, we couldn't use the PendingIntent as a mock because it's a final class
-        // so this test checks the method in the IActivityManager when the PendingIntent#send(int)
-        // is called.
-        verify(mIActivityManager).sendIntentSender(any(), any(), any(),
-                eq(SmsManager.RESULT_ERROR_GENERIC_FAILURE), any(), any(), any(), any(), any());
+        verify(mImsSmsDispatcher).sendText(eq("1111"), eq("2222"), eq("text"), eq(mSentIntent),
+                any(), any(), eq("test-app"), eq(false), eq(0), eq(false), eq(10), eq(false),
+                eq(1L), eq(false));
+    }
+
+    @Test
+    @SmallTest
+    public void testNotifyDomainSelectionTerminatedWhenImsNotAvailableAndEmergencySms()
+            throws Exception {
+        setUpDomainSelectionConnection();
+        setUpSmsDispatchers();
+        setUpEmergencyStateTracker(DisconnectCause.NOT_DISCONNECTED);
+        when(mImsSmsDispatcher.isAvailable()).thenReturn(false);
+        when(mImsSmsDispatcher.isEmergencySmsSupport(anyString())).thenReturn(true);
+
+        mSmsDispatchersController.sendText("911", "2222", "text", mSentIntent, null, null,
+                "test-app", false, 0, false, 10, false, 1L, false);
+        processAllMessages();
+
+        SmsDispatchersController.DomainSelectionConnectionHolder holder =
+                mSmsDispatchersController.testGetDomainSelectionConnectionHolder(true);
+        ArgumentCaptor<DomainSelectionConnection.DomainSelectionConnectionCallback> captor =
+                ArgumentCaptor.forClass(
+                        DomainSelectionConnection.DomainSelectionConnectionCallback.class);
+        verify(mEmergencySmsDsc).requestDomainSelection(any(), captor.capture());
+        assertNotNull(holder);
+        assertNotNull(holder.getConnection());
+        assertTrue(holder.isDomainSelectionRequested());
+        assertEquals(1, holder.getPendingRequests().size());
+
+        DomainSelectionConnection.DomainSelectionConnectionCallback callback = captor.getValue();
+        assertNotNull(callback);
+        callback.onSelectionTerminated(DisconnectCause.LOCAL);
+        processAllMessages();
+
+        verify(mEmergencySmsDsc, never()).finishSelection();
+        assertNull(holder.getConnection());
+        assertFalse(holder.isDomainSelectionRequested());
+        assertEquals(0, holder.getPendingRequests().size());
+
+        verify(mImsSmsDispatcher).sendText(eq("911"), eq("2222"), eq("text"), eq(mSentIntent),
+                any(), any(), eq("test-app"), eq(false), eq(0), eq(false), eq(10), eq(false),
+                eq(1L), eq(false));
     }
 
     @Test
@@ -511,6 +643,7 @@
 
         mSmsDispatchersController.sendText("1111", "2222", "text", mSentIntent, null, null,
                 "test-app", false, 0, false, 10, false, 1L, false);
+        processAllMessages();
 
         SmsDispatchersController.DomainSelectionConnectionHolder holder =
                 mSmsDispatchersController.testGetDomainSelectionConnectionHolder(false);
@@ -521,6 +654,7 @@
 
         mSmsDispatchersController.sendText("1111", "2222", "text", mSentIntent, null, null,
                 "test-app", false, 0, false, 10, false, 1L, false);
+        processAllMessages();
 
         verify(mSmsDsc).requestDomainSelection(any(), any());
         assertNotNull(holder.getConnection());
@@ -539,6 +673,23 @@
         assertEquals(0, holder.getPendingRequests().size());
     }
 
+    @Test
+    @SmallTest
+    public void testSendTextWhenFeatureFlagDisabledForSmsDomainSelection() throws Exception {
+        setUpDomainSelectionConnection();
+        setUpSmsDispatchers();
+        when(mFeatureFlags.smsDomainSelectionEnabled()).thenReturn(false);
+
+        mSmsDispatchersController.sendText("1111", "2222", "text", mSentIntent, null, null,
+                "test-app", false, 0, false, 10, false, 1L, false);
+        processAllMessages();
+
+        // Expect that the domain selection logic will not be executed.
+        SmsDispatchersController.DomainSelectionConnectionHolder holder =
+                mSmsDispatchersController.testGetDomainSelectionConnectionHolder(false);
+        assertNull(holder);
+    }
+
     private void switchImsSmsFormat(int phoneType) {
         mSimulatedCommands.setImsRegistrationState(new int[]{1, phoneType});
         mSimulatedCommands.notifyImsNetworkStateChanged();
@@ -553,7 +704,7 @@
         assertTrue(mSmsDispatchersController.setImsManager(imsManager));
     }
 
-    private void setUpDomainSelectionConnectionAsNotSupported() {
+    private void setUpDomainSelectionEnabled(boolean enabled) {
         mSmsDispatchersController.setDomainSelectionResolverProxy(
                 new SmsDispatchersController.DomainSelectionResolverProxy() {
                     @Override
@@ -566,9 +717,10 @@
 
                     @Override
                     public boolean isDomainSelectionSupported() {
-                        return false;
+                        return true;
                     }
                 });
+        when(mFeatureFlags.smsDomainSelectionEnabled()).thenReturn(enabled);
     }
 
     private void setUpDomainSelectionConnection()  {
@@ -589,6 +741,7 @@
                         return true;
                     }
                 });
+        when(mFeatureFlags.smsDomainSelectionEnabled()).thenReturn(true);
 
         mDscFuture = new CompletableFuture<>();
         when(mSmsDsc.requestDomainSelection(
@@ -620,6 +773,18 @@
                         | PendingIntent.FLAG_ALLOW_UNSAFE_IMPLICIT_INTENT);
     }
 
+    private void setUpEmergencyStateTracker(int result) throws Exception {
+        mEmergencySmsFuture = new CompletableFuture<Integer>();
+        mEmergencyStateTracker = Mockito.mock(EmergencyStateTracker.class);
+        replaceInstance(SmsDispatchersController.class, "mEmergencyStateTracker",
+                mSmsDispatchersController, mEmergencyStateTracker);
+        when(mEmergencyStateTracker.startEmergencySms(any(Phone.class), anyString(), anyBoolean()))
+                .thenReturn(mEmergencySmsFuture);
+        doNothing().when(mEmergencyStateTracker).endSms(anyString(), anyBoolean());
+        mEmergencySmsFuture.complete(result);
+        when(mTelephonyManager.isEmergencyNumber(eq("911"))).thenReturn(true);
+    }
+
     private void sendDataWithDomainSelection(@NetworkRegistrationInfo.Domain int domain,
             boolean isCdmaMo) throws Exception {
         setUpDomainSelectionConnection();
@@ -628,6 +793,7 @@
         byte[] data = new byte[] { 0x01 };
         mSmsDispatchersController.testSendData(
                 "test-app", "1111", "2222", 8080, data, mSentIntent, null, false);
+        processAllMessages();
 
         SmsDispatchersController.DomainSelectionConnectionHolder holder =
                 mSmsDispatchersController.testGetDomainSelectionConnectionHolder(false);
@@ -663,6 +829,7 @@
 
         mSmsDispatchersController.sendText("1111", "2222", "text", mSentIntent, null, null,
                 "test-app", false, 0, false, 10, false, 1L, false);
+        processAllMessages();
 
         SmsDispatchersController.DomainSelectionConnectionHolder holder =
                 mSmsDispatchersController.testGetDomainSelectionConnectionHolder(false);
@@ -704,6 +871,7 @@
         ArrayList<PendingIntent> deliveryIntents = new ArrayList<>();
         mSmsDispatchersController.testSendMultipartText("1111", "2222", parts, sentIntents,
                 deliveryIntents, null, "test-app", false, 0, false, 10, 1L);
+        processAllMessages();
 
         SmsDispatchersController.DomainSelectionConnectionHolder holder =
                 mSmsDispatchersController.testGetDomainSelectionConnectionHolder(false);
@@ -746,6 +914,7 @@
         replaceInstance(SMSDispatcher.SmsTracker.class, "mFormat", mTracker, smsFormat);
 
         mSmsDispatchersController.sendRetrySms(mTracker);
+        processAllMessages();
 
         SmsDispatchersController.DomainSelectionConnectionHolder holder =
                 mSmsDispatchersController.testGetDomainSelectionConnectionHolder(false);
@@ -782,6 +951,7 @@
         mTracker.mUsesImsServiceForIms = true;
 
         mSmsDispatchersController.sendRetrySms(mTracker);
+        processAllMessages();
 
         verify(mSmsDsc, never()).requestDomainSelection(any(), any());
 
diff --git a/tests/telephonytests/src/com/android/internal/telephony/TelephonyTest.java b/tests/telephonytests/src/com/android/internal/telephony/TelephonyTest.java
index d304f5c..435763b 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/TelephonyTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/TelephonyTest.java
@@ -108,6 +108,7 @@
 import com.android.internal.telephony.data.LinkBandwidthEstimator;
 import com.android.internal.telephony.data.PhoneSwitcher;
 import com.android.internal.telephony.emergency.EmergencyNumberTracker;
+import com.android.internal.telephony.flags.FeatureFlags;
 import com.android.internal.telephony.imsphone.ImsExternalCallTracker;
 import com.android.internal.telephony.imsphone.ImsNrSaModeHandler;
 import com.android.internal.telephony.imsphone.ImsPhone;
@@ -183,6 +184,7 @@
     }
 
     // Mocked classes
+    protected FeatureFlags mFeatureFlags;
     protected GsmCdmaPhone mPhone;
     protected GsmCdmaPhone mPhone2;
     protected ImsPhone mImsPhone;
@@ -421,6 +423,7 @@
     protected void setUp(String tag) throws Exception {
         TAG = tag;
         enableStrictMode();
+        mFeatureFlags = Mockito.mock(FeatureFlags.class);
         mPhone = Mockito.mock(GsmCdmaPhone.class);
         mPhone2 = Mockito.mock(GsmCdmaPhone.class);
         mImsPhone = Mockito.mock(ImsPhone.class);
@@ -590,7 +593,7 @@
         doReturn(mIccPhoneBookIntManager).when(mTelephonyComponentFactory)
                 .makeIccPhoneBookInterfaceManager(nullable(Phone.class));
         doReturn(mDisplayInfoController).when(mTelephonyComponentFactory)
-                .makeDisplayInfoController(nullable(Phone.class));
+                .makeDisplayInfoController(nullable(Phone.class), any(FeatureFlags.class));
         doReturn(mWspTypeDecoder).when(mTelephonyComponentFactory)
                 .makeWspTypeDecoder(nullable(byte[].class));
         doReturn(mImsCT).when(mTelephonyComponentFactory)
@@ -610,7 +613,7 @@
         doReturn(mCarrierActionAgent).when(mTelephonyComponentFactory)
                 .makeCarrierActionAgent(nullable(Phone.class));
         doReturn(mDeviceStateMonitor).when(mTelephonyComponentFactory)
-                .makeDeviceStateMonitor(nullable(Phone.class));
+                .makeDeviceStateMonitor(nullable(Phone.class), any(FeatureFlags.class));
         doReturn(mAccessNetworksManager).when(mTelephonyComponentFactory)
                 .makeAccessNetworksManager(nullable(Phone.class), any(Looper.class));
         doReturn(mNitzStateMachine).when(mTelephonyComponentFactory)
@@ -625,6 +628,7 @@
         doReturn(mDataProfileManager).when(mTelephonyComponentFactory)
                 .makeDataProfileManager(any(Phone.class), any(DataNetworkController.class),
                         any(DataServiceManager.class), any(Looper.class),
+                        any(FeatureFlags.class),
                         any(DataProfileManager.DataProfileManagerCallback.class));
 
         //mPhone
diff --git a/tests/telephonytests/src/com/android/internal/telephony/data/ApnSettingTest.java b/tests/telephonytests/src/com/android/internal/telephony/data/ApnSettingTest.java
index b6d77e9..98d3ce5 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/data/ApnSettingTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/data/ApnSettingTest.java
@@ -154,6 +154,9 @@
         assertTrue(createApnSetting(
                 ApnSetting.TYPE_DEFAULT | ApnSetting.TYPE_MMS | ApnSetting.TYPE_EMERGENCY)
                 .canHandleType(ApnSetting.TYPE_EMERGENCY));
+        assertTrue(createApnSetting(
+                ApnSetting.TYPE_DEFAULT | ApnSetting.TYPE_RCS | ApnSetting.TYPE_EMERGENCY)
+                .canHandleType(ApnSetting.TYPE_RCS));
         assertFalse(createApnSetting(ApnSetting.TYPE_ALL)
                 .canHandleType(ApnSetting.TYPE_MCX));
         assertTrue(createApnSetting(
diff --git a/tests/telephonytests/src/com/android/internal/telephony/data/DataConfigManagerTest.java b/tests/telephonytests/src/com/android/internal/telephony/data/DataConfigManagerTest.java
index 3cc6a8b..4fcf620 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/data/DataConfigManagerTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/data/DataConfigManagerTest.java
@@ -52,7 +52,7 @@
         super.setUp(getClass().getSimpleName());
         mBundle = mContextFixture.getCarrierConfigBundle();
         when(mCarrierConfigManager.getConfigForSubId(anyInt(), any())).thenReturn(mBundle);
-        mDataConfigManagerUT = new DataConfigManager(mPhone, Looper.myLooper());
+        mDataConfigManagerUT = new DataConfigManager(mPhone, Looper.myLooper(), mFeatureFlags);
         logd("DataConfigManagerTest -Setup!");
     }
 
diff --git a/tests/telephonytests/src/com/android/internal/telephony/data/DataNetworkControllerTest.java b/tests/telephonytests/src/com/android/internal/telephony/data/DataNetworkControllerTest.java
index 5e7213b..a09994b 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/data/DataNetworkControllerTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/data/DataNetworkControllerTest.java
@@ -150,6 +150,7 @@
     // Events
     private static final int EVENT_SIM_STATE_CHANGED = 9;
     private static final int EVENT_REEVALUATE_EXISTING_DATA_NETWORKS = 16;
+    private static final int EVENT_SERVICE_STATE_CHANGED = 17;
     private static final int EVENT_VOICE_CALL_ENDED = 18;
     private static final int EVENT_SUBSCRIPTION_OVERRIDE = 23;
 
@@ -209,6 +210,8 @@
                     .setMaxConns(321)
                     .setWaitTime(456)
                     .setMaxConnsTime(789)
+                    .setInfrastructureBitmask(ApnSetting.INFRASTRUCTURE_SATELLITE
+                            | ApnSetting.INFRASTRUCTURE_CELLULAR)
                     .build())
             .setPreferred(false)
             .build();
@@ -401,6 +404,17 @@
             .setPreferred(false)
             .build();
 
+    private final DataProfile mNtnDataProfile = new DataProfile.Builder()
+            .setApnSetting(new ApnSetting.Builder()
+                    .setEntryName("ntn")
+                    .setApnName("ntn")
+                    .setApnTypeBitmask(ApnSetting.TYPE_RCS)
+                    .setCarrierEnabled(true)
+                    .setInfrastructureBitmask(ApnSetting.INFRASTRUCTURE_SATELLITE)
+                    .build())
+            .setPreferred(false)
+            .build();
+
     /** Data call response map. The first key is the transport type, the second key is the cid. */
     private final Map<Integer, Map<Integer, DataCallResponse>> mDataCallResponses = new HashMap<>();
 
@@ -599,7 +613,7 @@
         doReturn(ss).when(mSST).getServiceState();
         doReturn(ss).when(mPhone).getServiceState();
 
-        mDataNetworkControllerUT.obtainMessage(17/*EVENT_SERVICE_STATE_CHANGED*/).sendToTarget();
+        mDataNetworkControllerUT.obtainMessage(EVENT_SERVICE_STATE_CHANGED).sendToTarget();
         processAllMessages();
     }
 
@@ -904,7 +918,8 @@
         List<DataProfile> profiles = List.of(mGeneralPurposeDataProfile,
                 mGeneralPurposeDataProfileAlternative, mImsCellularDataProfile,
                 mImsIwlanDataProfile, mEmergencyDataProfile, mFotaDataProfile,
-                mTetheringDataProfile);
+                mTetheringDataProfile, mMmsOnWlanDataProfile, mLowLatencyDataProfile,
+                mNtnDataProfile);
 
         doAnswer(invocation -> {
             DataProfile dp = (DataProfile) invocation.getArguments()[0];
@@ -935,23 +950,30 @@
             TelephonyNetworkRequest networkRequest =
                     (TelephonyNetworkRequest) invocation.getArguments()[0];
             int networkType = (int) invocation.getArguments()[1];
-            boolean ignorePermanentFailure = (boolean) invocation.getArguments()[2];
+            boolean isNtn = (boolean) invocation.getArguments()[2];
+            boolean ignorePermanentFailure = (boolean) invocation.getArguments()[3];
 
             for (DataProfile dataProfile : profiles) {
-                if (dataProfile.canSatisfy(networkRequest.getCapabilities())
-                        && (dataProfile.getApnSetting().getNetworkTypeBitmask() == 0
-                        || (dataProfile.getApnSetting().getNetworkTypeBitmask()
+                ApnSetting apnSetting = dataProfile.getApnSetting();
+                if (apnSetting != null
+                        && dataProfile.canSatisfy(networkRequest.getCapabilities())
+                        && (apnSetting.getNetworkTypeBitmask() == 0
+                        || (apnSetting.getNetworkTypeBitmask()
                         & ServiceState.getBitmaskForTech(networkType)) != 0)
-                        && (ignorePermanentFailure || (dataProfile.getApnSetting() != null
-                        && !dataProfile.getApnSetting().getPermanentFailed()))) {
+                        && ((isNtn && apnSetting.isForInfrastructure(
+                                ApnSetting.INFRASTRUCTURE_SATELLITE))
+                        || ((!isNtn && apnSetting.isForInfrastructure(
+                                ApnSetting.INFRASTRUCTURE_CELLULAR))))
+                        && (ignorePermanentFailure || !apnSetting.getPermanentFailed())) {
                     return dataProfile;
                 }
             }
             logd("Cannot find data profile to satisfy " + networkRequest + ", network type="
-                    + TelephonyManager.getNetworkTypeName(networkType));
+                    + TelephonyManager.getNetworkTypeName(networkType) + ", ignorePermanentFailure="
+                    + ignorePermanentFailure + ", isNtn=" + isNtn);
             return null;
         }).when(mDataProfileManager).getDataProfileForNetworkRequest(
-                any(TelephonyNetworkRequest.class), anyInt(), anyBoolean());
+                any(TelephonyNetworkRequest.class), anyInt(), anyBoolean(), anyBoolean());
 
         doReturn(AccessNetworkConstants.TRANSPORT_TYPE_WWAN).when(mAccessNetworksManager)
                 .getPreferredTransportByNetworkCapability(anyInt());
@@ -1233,7 +1255,7 @@
                     + TelephonyManager.getNetworkTypeName(networkType));
             return null;
         }).when(mDataProfileManager).getDataProfileForNetworkRequest(
-                any(TelephonyNetworkRequest.class), anyInt(), anyBoolean());
+                any(TelephonyNetworkRequest.class), anyInt(), anyBoolean(), anyBoolean());
 
         // verify the network still connects
         verify(mMockedDataNetworkControllerCallback).onConnectedInternetDataNetworksChanged(any());
@@ -1278,7 +1300,7 @@
                 createDataCallResponse(1, DataCallResponse.LINK_STATUS_ACTIVE, tdList));
         doReturn(mEnterpriseDataProfile).when(mDataProfileManager)
                 .getDataProfileForNetworkRequest(any(TelephonyNetworkRequest.class), anyInt(),
-                        anyBoolean());
+                        anyBoolean(), anyBoolean());
 
         NetworkCapabilities netCaps = new NetworkCapabilities();
         netCaps.addCapability(NetworkCapabilities.NET_CAPABILITY_ENTERPRISE);
@@ -1493,7 +1515,7 @@
         // Now RAT changes from UMTS to GSM
         doReturn(null).when(mDataProfileManager).getDataProfileForNetworkRequest(
                 any(TelephonyNetworkRequest.class), eq(TelephonyManager.NETWORK_TYPE_GSM),
-                anyBoolean());
+                anyBoolean(), anyBoolean());
         serviceStateChanged(TelephonyManager.NETWORK_TYPE_GSM,
                 NetworkRegistrationInfo.REGISTRATION_STATE_HOME);
         verifyAllDataDisconnected();
@@ -1507,14 +1529,14 @@
         // Now RAT changes from GSM to UMTS
         doReturn(null).when(mDataProfileManager).getDataProfileForNetworkRequest(
                 any(TelephonyNetworkRequest.class), eq(TelephonyManager.NETWORK_TYPE_UMTS),
-                anyBoolean());
+                anyBoolean(), anyBoolean());
         serviceStateChanged(TelephonyManager.NETWORK_TYPE_UMTS,
                 NetworkRegistrationInfo.REGISTRATION_STATE_HOME);
         verifyNoConnectedNetworkHasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET);
 
         doReturn(mGeneralPurposeDataProfile).when(mDataProfileManager)
                 .getDataProfileForNetworkRequest(any(TelephonyNetworkRequest.class), anyInt(),
-                        anyBoolean());
+                        anyBoolean(), anyBoolean());
         // Now RAT changes from UMTS to LTE
         serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE,
                 NetworkRegistrationInfo.REGISTRATION_STATE_HOME);
@@ -3509,7 +3531,7 @@
                 createDataCallResponse(1, DataCallResponse.LINK_STATUS_ACTIVE, tdList));
         doReturn(mEnterpriseDataProfile).when(mDataProfileManager)
                 .getDataProfileForNetworkRequest(any(TelephonyNetworkRequest.class), anyInt(),
-                        anyBoolean());
+                        anyBoolean(), anyBoolean());
 
         NetworkCapabilities netCaps = new NetworkCapabilities();
         netCaps.addCapability(NetworkCapabilities.NET_CAPABILITY_ENTERPRISE);
@@ -3553,8 +3575,12 @@
 
     @Test
     public void testNonVoPStoVoPSImsSetup() throws Exception {
-        // Even allow lingering when NoVops, should have no effect on NoVops -> Vops
-        mCarrierConfig.putBoolean(CarrierConfigManager.Ims.KEY_KEEP_PDN_UP_IN_NO_VOPS_BOOL, true);
+        doReturn(true).when(mFeatureFlags).allowMmtelInNonVops();
+        mDataNetworkControllerUT.getDataSettingsManager().setDataRoamingEnabled(true);
+        // Config that allows non-vops bring up when Roaming
+        mCarrierConfig.putIntArray(CarrierConfigManager.Ims
+                .KEY_IMS_PDN_ENABLED_IN_NO_VOPS_SUPPORT_INT_ARRAY, new int[]
+                {CarrierConfigManager.Ims.NETWORK_TYPE_ROAMING});
         carrierConfigChanged();
 
         // VOPS not supported
@@ -3574,6 +3600,30 @@
         processAllMessages();
         verifyNoConnectedNetworkHasCapability(NetworkCapabilities.NET_CAPABILITY_IMS);
 
+        // Verify bring up in Home is not allowed.
+        serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE,
+                NetworkRegistrationInfo.REGISTRATION_STATE_HOME, dsri);
+        processAllMessages();
+        verifyNoConnectedNetworkHasCapability(NetworkCapabilities.NET_CAPABILITY_IMS);
+
+        // Verify bring up in Roaming is allowed.
+        serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE,
+                NetworkRegistrationInfo.REGISTRATION_STATE_ROAMING, dsri);
+        processAllMessages();
+        verifyConnectedNetworkHasCapabilities(NetworkCapabilities.NET_CAPABILITY_IMS,
+                NetworkCapabilities.NET_CAPABILITY_MMTEL);
+
+        // Verify the roaming network survives network re-evaluation.
+        mDataNetworkControllerUT.obtainMessage(EVENT_REEVALUATE_EXISTING_DATA_NETWORKS)
+                .sendToTarget();
+        processAllMessages();
+
+        // Service state changed to Home, non-vops area is no longer allowed
+        serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE,
+                NetworkRegistrationInfo.REGISTRATION_STATE_HOME, dsri);
+        processAllMessages();
+        verifyNoConnectedNetworkHasCapability(NetworkCapabilities.NET_CAPABILITY_IMS);
+
         // VoPS supported
         dsri = new DataSpecificRegistrationInfo.Builder(8)
                 .setNrAvailable(true)
@@ -4149,8 +4199,6 @@
 
     @Test
     public void testHandoverDataNetworkNonVops() throws Exception {
-        ServiceState ss = new ServiceState();
-
         DataSpecificRegistrationInfo dsri = new DataSpecificRegistrationInfo.Builder(8)
                 .setNrAvailable(true)
                 .setEnDcAvailable(true)
@@ -4158,36 +4206,13 @@
                         LteVopsSupportInfo.LTE_STATUS_NOT_SUPPORTED,
                         LteVopsSupportInfo.LTE_STATUS_NOT_SUPPORTED))
                 .build();
-
-        ss.addNetworkRegistrationInfo(new NetworkRegistrationInfo.Builder()
-                .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
-                .setAccessNetworkTechnology(TelephonyManager.NETWORK_TYPE_LTE)
-                .setRegistrationState(NetworkRegistrationInfo.REGISTRATION_STATE_HOME)
-                .setDomain(NetworkRegistrationInfo.DOMAIN_PS)
-                .setDataSpecificInfo(dsri)
-                .build());
-
-        ss.addNetworkRegistrationInfo(new NetworkRegistrationInfo.Builder()
-                .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WLAN)
-                .setAccessNetworkTechnology(TelephonyManager.NETWORK_TYPE_IWLAN)
-                .setRegistrationState(NetworkRegistrationInfo.REGISTRATION_STATE_HOME)
-                .setDomain(NetworkRegistrationInfo.DOMAIN_PS)
-                .build());
-
-        ss.addNetworkRegistrationInfo(new NetworkRegistrationInfo.Builder()
-                .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
-                .setAccessNetworkTechnology(TelephonyManager.NETWORK_TYPE_LTE)
-                .setRegistrationState(NetworkRegistrationInfo.REGISTRATION_STATE_HOME)
-                .setDomain(NetworkRegistrationInfo.DOMAIN_CS)
-                .build());
-        processServiceStateRegStateForTest(ss);
-        doReturn(ss).when(mSST).getServiceState();
-        doReturn(ss).when(mPhone).getServiceState();
+        serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE,
+                NetworkRegistrationInfo.REGISTRATION_STATE_HOME, dsri);
 
         doReturn(AccessNetworkConstants.TRANSPORT_TYPE_WLAN).when(mAccessNetworksManager)
                 .getPreferredTransportByNetworkCapability(NetworkCapabilities.NET_CAPABILITY_IMS);
 
-        mDataNetworkControllerUT.obtainMessage(17/*EVENT_SERVICE_STATE_CHANGED*/).sendToTarget();
+        mDataNetworkControllerUT.obtainMessage(EVENT_SERVICE_STATE_CHANGED).sendToTarget();
         processAllMessages();
 
         mDataNetworkControllerUT.addNetworkRequest(
@@ -4216,8 +4241,6 @@
         mCarrierConfig.putBoolean(CarrierConfigManager.Ims.KEY_KEEP_PDN_UP_IN_NO_VOPS_BOOL, true);
         carrierConfigChanged();
 
-        ServiceState ss = new ServiceState();
-
         DataSpecificRegistrationInfo dsri = new DataSpecificRegistrationInfo.Builder(8)
                 .setNrAvailable(true)
                 .setEnDcAvailable(true)
@@ -4225,36 +4248,13 @@
                         LteVopsSupportInfo.LTE_STATUS_NOT_SUPPORTED,
                         LteVopsSupportInfo.LTE_STATUS_NOT_SUPPORTED))
                 .build();
-
-        ss.addNetworkRegistrationInfo(new NetworkRegistrationInfo.Builder()
-                .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
-                .setAccessNetworkTechnology(TelephonyManager.NETWORK_TYPE_LTE)
-                .setRegistrationState(NetworkRegistrationInfo.REGISTRATION_STATE_HOME)
-                .setDomain(NetworkRegistrationInfo.DOMAIN_PS)
-                .setDataSpecificInfo(dsri)
-                .build());
-
-        ss.addNetworkRegistrationInfo(new NetworkRegistrationInfo.Builder()
-                .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WLAN)
-                .setAccessNetworkTechnology(TelephonyManager.NETWORK_TYPE_IWLAN)
-                .setRegistrationState(NetworkRegistrationInfo.REGISTRATION_STATE_HOME)
-                .setDomain(NetworkRegistrationInfo.DOMAIN_PS)
-                .build());
-
-        ss.addNetworkRegistrationInfo(new NetworkRegistrationInfo.Builder()
-                .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
-                .setAccessNetworkTechnology(TelephonyManager.NETWORK_TYPE_LTE)
-                .setRegistrationState(NetworkRegistrationInfo.REGISTRATION_STATE_HOME)
-                .setDomain(NetworkRegistrationInfo.DOMAIN_CS)
-                .build());
-        processServiceStateRegStateForTest(ss);
-        doReturn(ss).when(mSST).getServiceState();
-        doReturn(ss).when(mPhone).getServiceState();
+        serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE,
+                NetworkRegistrationInfo.REGISTRATION_STATE_HOME, dsri);
 
         doReturn(AccessNetworkConstants.TRANSPORT_TYPE_WLAN).when(mAccessNetworksManager)
                 .getPreferredTransportByNetworkCapability(NetworkCapabilities.NET_CAPABILITY_IMS);
 
-        mDataNetworkControllerUT.obtainMessage(17/*EVENT_SERVICE_STATE_CHANGED*/).sendToTarget();
+        mDataNetworkControllerUT.obtainMessage(EVENT_SERVICE_STATE_CHANGED).sendToTarget();
         processAllMessages();
 
         mDataNetworkControllerUT.addNetworkRequest(
@@ -4280,8 +4280,6 @@
 
     @Test
     public void testNonMmtelImsHandoverDataNetworkNonVops() throws Exception {
-        ServiceState ss = new ServiceState();
-
         DataSpecificRegistrationInfo dsri = new DataSpecificRegistrationInfo.Builder(8)
                 .setNrAvailable(true)
                 .setEnDcAvailable(true)
@@ -4290,35 +4288,13 @@
                         LteVopsSupportInfo.LTE_STATUS_NOT_SUPPORTED))
                 .build();
 
-        ss.addNetworkRegistrationInfo(new NetworkRegistrationInfo.Builder()
-                .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
-                .setAccessNetworkTechnology(TelephonyManager.NETWORK_TYPE_LTE)
-                .setRegistrationState(NetworkRegistrationInfo.REGISTRATION_STATE_HOME)
-                .setDomain(NetworkRegistrationInfo.DOMAIN_PS)
-                .setDataSpecificInfo(dsri)
-                .build());
-
-        ss.addNetworkRegistrationInfo(new NetworkRegistrationInfo.Builder()
-                .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WLAN)
-                .setAccessNetworkTechnology(TelephonyManager.NETWORK_TYPE_IWLAN)
-                .setRegistrationState(NetworkRegistrationInfo.REGISTRATION_STATE_HOME)
-                .setDomain(NetworkRegistrationInfo.DOMAIN_PS)
-                .build());
-
-        ss.addNetworkRegistrationInfo(new NetworkRegistrationInfo.Builder()
-                .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
-                .setAccessNetworkTechnology(TelephonyManager.NETWORK_TYPE_LTE)
-                .setRegistrationState(NetworkRegistrationInfo.REGISTRATION_STATE_HOME)
-                .setDomain(NetworkRegistrationInfo.DOMAIN_CS)
-                .build());
-        processServiceStateRegStateForTest(ss);
-        doReturn(ss).when(mSST).getServiceState();
-        doReturn(ss).when(mPhone).getServiceState();
+        serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE,
+                NetworkRegistrationInfo.REGISTRATION_STATE_HOME, dsri);
 
         doReturn(AccessNetworkConstants.TRANSPORT_TYPE_WLAN).when(mAccessNetworksManager)
                 .getPreferredTransportByNetworkCapability(NetworkCapabilities.NET_CAPABILITY_IMS);
 
-        mDataNetworkControllerUT.obtainMessage(17/*EVENT_SERVICE_STATE_CHANGED*/).sendToTarget();
+        mDataNetworkControllerUT.obtainMessage(EVENT_SERVICE_STATE_CHANGED).sendToTarget();
         processAllMessages();
 
         // Bring up the IMS network that does not require MMTEL
@@ -4326,7 +4302,7 @@
                 createNetworkRequest(NetworkCapabilities.NET_CAPABILITY_IMS));
         processAllMessages();
 
-        // Even though the network request does not have MMTEL, but the network support it, so
+        // Even though the network request does not have MMTEL, the WLAN network support it, so
         // the network capabilities should still have MMTEL.
         verifyConnectedNetworkHasCapabilities(NetworkCapabilities.NET_CAPABILITY_IMS,
                 NetworkCapabilities.NET_CAPABILITY_MMTEL);
@@ -4340,9 +4316,9 @@
                 any(DataProfile.class), anyBoolean(), anyBoolean(), anyInt(), any(), anyInt(),
                 any(), any(), anyBoolean(), any(Message.class));
 
-        // The IMS network should still have IMS and MMTEL.
+        // The IMS network should still have IMS, but MMTEL is removed.
         verifyConnectedNetworkHasCapabilities(NetworkCapabilities.NET_CAPABILITY_IMS);
-        verifyConnectedNetworkHasCapabilities(NetworkCapabilities.NET_CAPABILITY_MMTEL);
+        verifyNoConnectedNetworkHasCapability(NetworkCapabilities.NET_CAPABILITY_MMTEL);
     }
 
     @Test
@@ -4351,8 +4327,6 @@
         mCarrierConfig.putBoolean(CarrierConfigManager.Ims.KEY_KEEP_PDN_UP_IN_NO_VOPS_BOOL, true);
         carrierConfigChanged();
 
-        ServiceState ss = new ServiceState();
-
         // VoPS network
         DataSpecificRegistrationInfo dsri = new DataSpecificRegistrationInfo.Builder(8)
                 .setNrAvailable(true)
@@ -4362,35 +4336,13 @@
                         LteVopsSupportInfo.LTE_STATUS_SUPPORTED))
                 .build();
 
-        ss.addNetworkRegistrationInfo(new NetworkRegistrationInfo.Builder()
-                .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
-                .setAccessNetworkTechnology(TelephonyManager.NETWORK_TYPE_LTE)
-                .setRegistrationState(NetworkRegistrationInfo.REGISTRATION_STATE_HOME)
-                .setDomain(NetworkRegistrationInfo.DOMAIN_PS)
-                .setDataSpecificInfo(dsri)
-                .build());
-
-        ss.addNetworkRegistrationInfo(new NetworkRegistrationInfo.Builder()
-                .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WLAN)
-                .setAccessNetworkTechnology(TelephonyManager.NETWORK_TYPE_IWLAN)
-                .setRegistrationState(NetworkRegistrationInfo.REGISTRATION_STATE_HOME)
-                .setDomain(NetworkRegistrationInfo.DOMAIN_PS)
-                .build());
-
-        ss.addNetworkRegistrationInfo(new NetworkRegistrationInfo.Builder()
-                .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
-                .setAccessNetworkTechnology(TelephonyManager.NETWORK_TYPE_LTE)
-                .setRegistrationState(NetworkRegistrationInfo.REGISTRATION_STATE_HOME)
-                .setDomain(NetworkRegistrationInfo.DOMAIN_CS)
-                .build());
-        processServiceStateRegStateForTest(ss);
-        doReturn(ss).when(mSST).getServiceState();
-        doReturn(ss).when(mPhone).getServiceState();
+        serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE,
+                NetworkRegistrationInfo.REGISTRATION_STATE_HOME, dsri);
 
         doReturn(AccessNetworkConstants.TRANSPORT_TYPE_WWAN).when(mAccessNetworksManager)
                 .getPreferredTransportByNetworkCapability(NetworkCapabilities.NET_CAPABILITY_IMS);
 
-        mDataNetworkControllerUT.obtainMessage(17/*EVENT_SERVICE_STATE_CHANGED*/).sendToTarget();
+        mDataNetworkControllerUT.obtainMessage(EVENT_SERVICE_STATE_CHANGED).sendToTarget();
         processAllMessages();
 
         // Bring up the IMS network that does require MMTEL
@@ -4403,7 +4355,6 @@
         verifyConnectedNetworkHasCapabilities(NetworkCapabilities.NET_CAPABILITY_IMS,
                 NetworkCapabilities.NET_CAPABILITY_MMTEL);
 
-        ss = new ServiceState();
         // Non VoPS network
         dsri = new DataSpecificRegistrationInfo.Builder(8)
                 .setNrAvailable(true)
@@ -4413,32 +4364,10 @@
                         LteVopsSupportInfo.LTE_STATUS_NOT_SUPPORTED))
                 .build();
 
-        ss.addNetworkRegistrationInfo(new NetworkRegistrationInfo.Builder()
-                .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
-                .setAccessNetworkTechnology(TelephonyManager.NETWORK_TYPE_LTE)
-                .setRegistrationState(NetworkRegistrationInfo.REGISTRATION_STATE_HOME)
-                .setDomain(NetworkRegistrationInfo.DOMAIN_PS)
-                .setDataSpecificInfo(dsri)
-                .build());
+        serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE,
+                NetworkRegistrationInfo.REGISTRATION_STATE_HOME, dsri);
 
-        ss.addNetworkRegistrationInfo(new NetworkRegistrationInfo.Builder()
-                .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WLAN)
-                .setAccessNetworkTechnology(TelephonyManager.NETWORK_TYPE_IWLAN)
-                .setRegistrationState(NetworkRegistrationInfo.REGISTRATION_STATE_HOME)
-                .setDomain(NetworkRegistrationInfo.DOMAIN_PS)
-                .build());
-
-        ss.addNetworkRegistrationInfo(new NetworkRegistrationInfo.Builder()
-                .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
-                .setAccessNetworkTechnology(TelephonyManager.NETWORK_TYPE_LTE)
-                .setRegistrationState(NetworkRegistrationInfo.REGISTRATION_STATE_HOME)
-                .setDomain(NetworkRegistrationInfo.DOMAIN_CS)
-                .build());
-        processServiceStateRegStateForTest(ss);
-        doReturn(ss).when(mSST).getServiceState();
-        doReturn(ss).when(mPhone).getServiceState();
-
-        mDataNetworkControllerUT.obtainMessage(17/*EVENT_SERVICE_STATE_CHANGED*/).sendToTarget();
+        mDataNetworkControllerUT.obtainMessage(EVENT_SERVICE_STATE_CHANGED).sendToTarget();
         processAllMessages();
 
         // The IMS network is alive due to KEY_KEEP_PDN_UP_IN_NO_VOPS_BOOL = true
@@ -4642,7 +4571,7 @@
                 NetworkRegistrationInfo.REGISTRATION_STATE_HOME,
                 NetworkRegistrationInfo.REGISTRATION_STATE_NOT_REGISTERED_OR_SEARCHING, null);
         doReturn(ss).when(mSST).getServiceState();
-        mDataNetworkControllerUT.obtainMessage(17/*EVENT_SERVICE_STATE_CHANGED*/).sendToTarget();
+        mDataNetworkControllerUT.obtainMessage(EVENT_SERVICE_STATE_CHANGED).sendToTarget();
         mDataNetworkControllerUT.removeNetworkRequest(request);
         mDataNetworkControllerUT.addNetworkRequest(request);
         processAllMessages();
@@ -4664,7 +4593,7 @@
                 createDataCallResponse(1, DataCallResponse.LINK_STATUS_ACTIVE, tdList));
         doReturn(mEnterpriseDataProfile).when(mDataProfileManager)
                 .getDataProfileForNetworkRequest(any(TelephonyNetworkRequest.class), anyInt(),
-                        anyBoolean());
+                        anyBoolean(), anyBoolean());
         mDataNetworkControllerUT.addNetworkRequest(new TelephonyNetworkRequest(
                 new NetworkRequest.Builder()
                         .addCapability(NetworkCapabilities.NET_CAPABILITY_ENTERPRISE)
@@ -4702,7 +4631,7 @@
                 createDataCallResponse(2, DataCallResponse.LINK_STATUS_ACTIVE, tdList));
         doReturn(mLowLatencyDataProfile).when(mDataProfileManager)
                 .getDataProfileForNetworkRequest(any(TelephonyNetworkRequest.class), anyInt(),
-                        anyBoolean());
+                        anyBoolean(), anyBoolean());
         processAllFutureMessages();
 
         dataNetworkList = getDataNetworks();
@@ -4731,12 +4660,11 @@
                 createNetworkRequest(NetworkCapabilities.NET_CAPABILITY_IMS));
         processAllMessages();
         verifyConnectedNetworkHasDataProfile(mGeneralPurposeDataProfile);
-        verifyConnectedNetworkHasDataProfile(mGeneralPurposeDataProfile);
 
         // Mock the designated MMS profile when WLAN is preferred
         doReturn(mMmsOnWlanDataProfile).when(mDataProfileManager).getDataProfileForNetworkRequest(
                 any(TelephonyNetworkRequest.class), eq(TelephonyManager.NETWORK_TYPE_IWLAN),
-                anyBoolean());
+                anyBoolean(), anyBoolean());
         setSuccessfulSetupDataResponse(mMockedWlanDataServiceManager,
                 createDataCallResponse(2, DataCallResponse.LINK_STATUS_ACTIVE));
 
@@ -4746,4 +4674,16 @@
         processAllMessages();
         verifyConnectedNetworkHasDataProfile(mMmsOnWlanDataProfile);
     }
+
+    @Test
+    public void testNonTerrestrialNetwork() throws Exception {
+        when(mFeatureFlags.carrierEnabledSatelliteFlag()).thenReturn(true);
+        mIsNonTerrestrialNetwork = true;
+        serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE,
+                NetworkRegistrationInfo.REGISTRATION_STATE_HOME);
+        mDataNetworkControllerUT.addNetworkRequest(
+                createNetworkRequest(NetworkCapabilities.NET_CAPABILITY_RCS));
+        processAllMessages();
+        verifyConnectedNetworkHasDataProfile(mNtnDataProfile);
+    }
 }
diff --git a/tests/telephonytests/src/com/android/internal/telephony/data/DataNetworkTest.java b/tests/telephonytests/src/com/android/internal/telephony/data/DataNetworkTest.java
index 9235e46..a75a699 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/data/DataNetworkTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/data/DataNetworkTest.java
@@ -96,7 +96,6 @@
 import java.util.List;
 import java.util.Set;
 import java.util.concurrent.Executor;
-
 @RunWith(AndroidTestingRunner.class)
 @TestableLooper.RunWithLooper
 public class DataNetworkTest extends TelephonyTest {
@@ -428,8 +427,8 @@
         setSuccessfulSetupDataResponse(
                 mMockedWwanDataServiceManager, 123, Collections.emptyList(), mDefaultQos);
 
-        mDataNetworkUT = new DataNetwork(mPhone, Looper.myLooper(), mDataServiceManagers,
-                mInternetDataProfile, networkRequestList,
+        mDataNetworkUT = new DataNetwork(mPhone, mFeatureFlags, Looper.myLooper(),
+                mDataServiceManagers, mInternetDataProfile, networkRequestList,
                 AccessNetworkConstants.TRANSPORT_TYPE_WWAN,
                 DataAllowedReason.NORMAL, mDataNetworkCallback);
         replaceInstance(DataNetwork.class, "mDataCallSessionStats",
@@ -443,7 +442,7 @@
 
         verify(mConnectivityManager).registerNetworkAgent(any(), any(NetworkInfo.class),
                 linkPropertiesCaptor.capture(), networkCapabilitiesCaptor.capture(), any(), any(),
-                anyInt());
+                any(), anyInt());
         // The very first link properties from telephony is an empty link properties. It will be
         // updated later.
         assertThat(linkPropertiesCaptor.getValue()).isEqualTo(new LinkProperties());
@@ -537,8 +536,8 @@
 
         setSuccessfulSetupDataResponse(mMockedWwanDataServiceManager, 123);
 
-        mDataNetworkUT = new DataNetwork(mPhone, Looper.myLooper(), mDataServiceManagers,
-                mInternetDataProfile, networkRequestList,
+        mDataNetworkUT = new DataNetwork(mPhone, mFeatureFlags, Looper.myLooper(),
+                mDataServiceManagers, mInternetDataProfile, networkRequestList,
                 AccessNetworkConstants.TRANSPORT_TYPE_WWAN,
                 DataAllowedReason.NORMAL, mDataNetworkCallback);
         replaceInstance(DataNetwork.class, "mDataCallSessionStats",
@@ -550,7 +549,7 @@
 
         verify(mConnectivityManager).registerNetworkAgent(any(), any(NetworkInfo.class),
                 any(LinkProperties.class), networkCapabilitiesCaptor.capture(), any(), any(),
-                anyInt());
+                any(), anyInt());
 
         // Make sure the initial network capability has NOT_SUSPENDED
         assertThat(networkCapabilitiesCaptor.getValue().hasCapability(
@@ -614,7 +613,7 @@
         // Agent re-created, so register should be called twice.
         verify(mConnectivityManager, times(2)).registerNetworkAgent(any(), any(NetworkInfo.class),
                 any(LinkProperties.class), networkCapabilitiesCaptor.capture(), any(), any(),
-                anyInt());
+                any(), anyInt());
 
         // Make sure the 2nd network agent was created with NOT_SUSPENDED.
         assertThat(networkCapabilitiesCaptor.getValue().hasCapability(
@@ -633,8 +632,8 @@
                 .build(), mPhone));
         setSuccessfulSetupDataResponse(mMockedWwanDataServiceManager, 123);
 
-        mDataNetworkUT = new DataNetwork(mPhone, Looper.myLooper(), mDataServiceManagers,
-                mInternetDataProfile, networkRequestList,
+        mDataNetworkUT = new DataNetwork(mPhone, mFeatureFlags, Looper.myLooper(),
+                mDataServiceManagers, mInternetDataProfile, networkRequestList,
                 AccessNetworkConstants.TRANSPORT_TYPE_WWAN,
                 DataAllowedReason.NORMAL, mDataNetworkCallback);
         processAllMessages();
@@ -652,20 +651,7 @@
 
     @Test
     public void testCreateImsDataNetwork() throws Exception {
-        NetworkRequestList networkRequestList = new NetworkRequestList();
-        networkRequestList.add(new TelephonyNetworkRequest(new NetworkRequest.Builder()
-                .addCapability(NetworkCapabilities.NET_CAPABILITY_IMS)
-                .build(), mPhone));
-
-        setSuccessfulSetupDataResponse(mMockedWwanDataServiceManager, 123);
-
-        mDataNetworkUT = new DataNetwork(mPhone, Looper.myLooper(), mDataServiceManagers,
-                mImsDataProfile, networkRequestList,
-                AccessNetworkConstants.TRANSPORT_TYPE_WWAN,
-                DataAllowedReason.NORMAL, mDataNetworkCallback);
-        replaceInstance(DataNetwork.class, "mDataCallSessionStats",
-                mDataNetworkUT, mDataCallSessionStats);
-        processAllMessages();
+        createImsDataNetwork(true/*isMmtel*/);
 
         ArgumentCaptor<LinkProperties> linkPropertiesCaptor =
                 ArgumentCaptor.forClass(LinkProperties.class);
@@ -674,7 +660,7 @@
 
         verify(mConnectivityManager).registerNetworkAgent(any(), any(NetworkInfo.class),
                 linkPropertiesCaptor.capture(), networkCapabilitiesCaptor.capture(), any(), any(),
-                anyInt());
+                any(), anyInt());
         // The very first link properties from telephony is an empty link properties. It will be
         // updated later.
         assertThat(linkPropertiesCaptor.getValue()).isEqualTo(new LinkProperties());
@@ -686,7 +672,7 @@
                 eq(DataCallResponse.PDU_SESSION_ID_NOT_SET), nullable(NetworkSliceInfo.class),
                 any(TrafficDescriptor.class), eq(true), any(Message.class));
         assertThat(mDataNetworkUT.getId()).isEqualTo(123);
-        assertThat(networkRequestList.get(0).getState())
+        assertThat(mDataNetworkUT.getAttachedNetworkRequestList().get(0).getState())
                 .isEqualTo(TelephonyNetworkRequest.REQUEST_STATE_SATISFIED);
         LinkProperties lp = mDataNetworkUT.getLinkProperties();
         assertThat(lp.getAddresses()).containsExactly(
@@ -742,8 +728,8 @@
         );
         setSuccessfulSetupDataResponse(mMockedWwanDataServiceManager, 123, tds);
 
-        mDataNetworkUT = new DataNetwork(mPhone, Looper.myLooper(), mDataServiceManagers,
-                mEnterpriseDataProfile, networkRequestList,
+        mDataNetworkUT = new DataNetwork(mPhone, mFeatureFlags, Looper.myLooper(),
+                mDataServiceManagers, mEnterpriseDataProfile, networkRequestList,
                 AccessNetworkConstants.TRANSPORT_TYPE_WWAN, DataAllowedReason.NORMAL,
                 mDataNetworkCallback);
         replaceInstance(DataNetwork.class, "mDataCallSessionStats",
@@ -776,8 +762,8 @@
         );
         setSuccessfulSetupDataResponse(mMockedWwanDataServiceManager, 123, tds);
 
-        mDataNetworkUT = new DataNetwork(mPhone, Looper.myLooper(), mDataServiceManagers,
-                mUrlccDataProfile, networkRequestList,
+        mDataNetworkUT = new DataNetwork(mPhone, mFeatureFlags, Looper.myLooper(),
+                mDataServiceManagers, mUrlccDataProfile, networkRequestList,
                 AccessNetworkConstants.TRANSPORT_TYPE_WWAN, DataAllowedReason.NORMAL,
                 mDataNetworkCallback);
         replaceInstance(DataNetwork.class, "mDataCallSessionStats",
@@ -809,8 +795,8 @@
         );
         setSuccessfulSetupDataResponse(mMockedWwanDataServiceManager, 123, tds);
 
-        mDataNetworkUT = new DataNetwork(mPhone, Looper.myLooper(), mDataServiceManagers,
-                mEmbbDataProfile, networkRequestList,
+        mDataNetworkUT = new DataNetwork(mPhone, mFeatureFlags, Looper.myLooper(),
+                mDataServiceManagers, mEmbbDataProfile, networkRequestList,
                 AccessNetworkConstants.TRANSPORT_TYPE_WWAN, DataAllowedReason.NORMAL,
                 mDataNetworkCallback);
         replaceInstance(DataNetwork.class, "mDataCallSessionStats",
@@ -843,8 +829,8 @@
 
         setSuccessfulSetupDataResponse(mMockedWwanDataServiceManager, 123, tds);
 
-        mDataNetworkUT = new DataNetwork(mPhone, Looper.myLooper(), mDataServiceManagers,
-                mCbsDataProfile, networkRequestList,
+        mDataNetworkUT = new DataNetwork(mPhone, mFeatureFlags, Looper.myLooper(),
+                mDataServiceManagers, mCbsDataProfile, networkRequestList,
                 AccessNetworkConstants.TRANSPORT_TYPE_WWAN, DataAllowedReason.NORMAL,
                 mDataNetworkCallback);
         replaceInstance(DataNetwork.class, "mDataCallSessionStats",
@@ -875,8 +861,8 @@
                         .getBytes())
         );
 
-        mDataNetworkUT = new DataNetwork(mPhone, Looper.myLooper(), mDataServiceManagers,
-                mCbsDataProfile, networkRequestList,
+        mDataNetworkUT = new DataNetwork(mPhone, mFeatureFlags, Looper.myLooper(),
+                mDataServiceManagers, mCbsDataProfile, networkRequestList,
                 AccessNetworkConstants.TRANSPORT_TYPE_WWAN, DataAllowedReason.NORMAL,
                 mDataNetworkCallback);
         replaceInstance(DataNetwork.class, "mDataCallSessionStats",
@@ -957,9 +943,10 @@
 
         setSuccessfulSetupDataResponse(mMockedWlanDataServiceManager, 123);
 
-        mDataNetworkUT = new DataNetwork(mPhone, Looper.myLooper(), mDataServiceManagers,
-                mImsDataProfile, networkRequestList, AccessNetworkConstants.TRANSPORT_TYPE_WLAN,
-                DataAllowedReason.NORMAL, mDataNetworkCallback);
+        mDataNetworkUT = new DataNetwork(mPhone, mFeatureFlags, Looper.myLooper(),
+                mDataServiceManagers, mImsDataProfile, networkRequestList,
+                AccessNetworkConstants.TRANSPORT_TYPE_WLAN, DataAllowedReason.NORMAL,
+                mDataNetworkCallback);
         replaceInstance(DataNetwork.class, "mDataCallSessionStats",
                 mDataNetworkUT, mDataCallSessionStats);
         processAllMessages();
@@ -1179,8 +1166,8 @@
 
         setSuccessfulSetupDataResponse(mMockedWwanDataServiceManager, 123);
 
-        mDataNetworkUT = new DataNetwork(mPhone, Looper.myLooper(), mDataServiceManagers,
-                mInternetDataProfile, networkRequestList,
+        mDataNetworkUT = new DataNetwork(mPhone, mFeatureFlags, Looper.myLooper(),
+                mDataServiceManagers, mInternetDataProfile, networkRequestList,
                 AccessNetworkConstants.TRANSPORT_TYPE_WWAN,
                 DataAllowedReason.NORMAL, mDataNetworkCallback);
         replaceInstance(DataNetwork.class, "mDataCallSessionStats",
@@ -1278,8 +1265,8 @@
         doReturn(false).when(mDataSettingsManager).isDataEnabled();
         setSuccessfulSetupDataResponse(mMockedWwanDataServiceManager, 123);
 
-        mDataNetworkUT = new DataNetwork(mPhone, Looper.myLooper(), mDataServiceManagers,
-                mInternetDataProfile, networkRequestList,
+        mDataNetworkUT = new DataNetwork(mPhone, mFeatureFlags, Looper.myLooper(),
+                mDataServiceManagers, mInternetDataProfile, networkRequestList,
                 AccessNetworkConstants.TRANSPORT_TYPE_WWAN,
                 DataAllowedReason.RESTRICTED_REQUEST, mDataNetworkCallback);
         replaceInstance(DataNetwork.class, "mDataCallSessionStats",
@@ -1321,8 +1308,8 @@
         doReturn(false).when(mDataSettingsManager).isDataRoamingEnabled();
         setSuccessfulSetupDataResponse(mMockedWwanDataServiceManager, 123);
 
-        mDataNetworkUT = new DataNetwork(mPhone, Looper.myLooper(), mDataServiceManagers,
-                mInternetDataProfile, networkRequestList,
+        mDataNetworkUT = new DataNetwork(mPhone, mFeatureFlags, Looper.myLooper(),
+                mDataServiceManagers, mInternetDataProfile, networkRequestList,
                 AccessNetworkConstants.TRANSPORT_TYPE_WWAN,
                 DataAllowedReason.RESTRICTED_REQUEST, mDataNetworkCallback);
         replaceInstance(DataNetwork.class, "mDataCallSessionStats",
@@ -1428,14 +1415,14 @@
 
     @Test
     public void testNetworkAgentConfig() throws Exception {
-        testCreateImsDataNetwork();
+        createImsDataNetwork(false/*IsMmtel*/);
 
         ArgumentCaptor<NetworkAgentConfig> captor = ArgumentCaptor
                 .forClass(NetworkAgentConfig.class);
 
         verify(mConnectivityManager).registerNetworkAgent(any(), any(NetworkInfo.class),
-                any(LinkProperties.class), any(NetworkCapabilities.class), any(), captor.capture(),
-                anyInt());
+                any(LinkProperties.class), any(NetworkCapabilities.class), any(), any(),
+                captor.capture(), anyInt());
 
         NetworkAgentConfig networkAgentConfig = captor.getValue();
 
@@ -1454,8 +1441,8 @@
         networkRequestList.add(new TelephonyNetworkRequest(new NetworkRequest.Builder()
                 .addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
                 .build(), mPhone));
-        mDataNetworkUT = new DataNetwork(mPhone, Looper.myLooper(), mDataServiceManagers,
-                mInternetDataProfile, networkRequestList,
+        mDataNetworkUT = new DataNetwork(mPhone, mFeatureFlags, Looper.myLooper(),
+                mDataServiceManagers, mInternetDataProfile, networkRequestList,
                 AccessNetworkConstants.TRANSPORT_TYPE_WWAN,
                 DataAllowedReason.NORMAL, mDataNetworkCallback);
         NetworkCapabilities caps = mDataNetworkUT.getNetworkCapabilities();
@@ -1518,7 +1505,7 @@
         // Agent re-created, so register should be called twice.
         verify(mConnectivityManager, times(2)).registerNetworkAgent(any(), any(NetworkInfo.class),
                 any(LinkProperties.class), any(NetworkCapabilities.class), any(), any(),
-                anyInt());
+                any(), anyInt());
 
         assertThat(mDataNetworkUT.getNetworkCapabilities().hasCapability(
                 NetworkCapabilities.NET_CAPABILITY_ENTERPRISE)).isTrue();
@@ -1540,14 +1527,15 @@
         // Agent not re-created, so register should be called once.
         verify(mConnectivityManager, times(1)).registerNetworkAgent(any(), any(NetworkInfo.class),
                 any(LinkProperties.class), any(NetworkCapabilities.class), any(), any(),
-                anyInt());
+                any(), anyInt());
 
         assertThat(mDataNetworkUT.getNetworkCapabilities().hasCapability(
                 NetworkCapabilities.NET_CAPABILITY_TEMPORARILY_NOT_METERED)).isTrue();
     }
 
     @Test
-    public void testMovingToNonVops() throws Exception {
+    public void testMovingToNonVopsRequestedMmtel() throws Exception {
+        createImsDataNetwork(true/*isMmtel*/);
         DataSpecificRegistrationInfo dsri = new DataSpecificRegistrationInfo.Builder(8)
                 .setNrAvailable(true)
                 .setEnDcAvailable(true)
@@ -1557,7 +1545,6 @@
                 .build();
         serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE,
                 NetworkRegistrationInfo.REGISTRATION_STATE_HOME, dsri);
-        testCreateImsDataNetwork();
 
         assertThat(mDataNetworkUT.getNetworkCapabilities().hasCapability(
                 NetworkCapabilities.NET_CAPABILITY_MMTEL)).isTrue();
@@ -1578,6 +1565,37 @@
     }
 
     @Test
+    public void testNonMmtelImsMovingToNonVops() throws Exception {
+        createImsDataNetwork(false/*isMmtel*/);
+        DataSpecificRegistrationInfo dsri = new DataSpecificRegistrationInfo.Builder(8)
+                .setNrAvailable(true)
+                .setEnDcAvailable(true)
+                .setVopsSupportInfo(new LteVopsSupportInfo(
+                        LteVopsSupportInfo.LTE_STATUS_SUPPORTED,
+                        LteVopsSupportInfo.LTE_STATUS_SUPPORTED))
+                .build();
+        serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE,
+                NetworkRegistrationInfo.REGISTRATION_STATE_HOME, dsri);
+
+        assertThat(mDataNetworkUT.getNetworkCapabilities().hasCapability(
+                NetworkCapabilities.NET_CAPABILITY_MMTEL)).isTrue();
+
+        dsri = new DataSpecificRegistrationInfo.Builder(8)
+                .setNrAvailable(true)
+                .setEnDcAvailable(true)
+                .setVopsSupportInfo(new LteVopsSupportInfo(
+                        LteVopsSupportInfo.LTE_STATUS_NOT_SUPPORTED,
+                        LteVopsSupportInfo.LTE_STATUS_NOT_SUPPORTED))
+                .build();
+        logd("Trigger non VoPS");
+        serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE,
+                NetworkRegistrationInfo.REGISTRATION_STATE_HOME, dsri);
+        // MMTEL should be removed to reflect the actual Vops status.
+        assertThat(mDataNetworkUT.getNetworkCapabilities().hasCapability(
+                NetworkCapabilities.NET_CAPABILITY_MMTEL)).isFalse();
+    }
+
+    @Test
     public void testCssIndicatorChanged() throws Exception {
         setupDataNetwork();
 
@@ -1709,7 +1727,7 @@
         // Agent re-created, so register should be called twice.
         verify(mConnectivityManager, times(2)).registerNetworkAgent(any(), any(NetworkInfo.class),
                 linkPropertiesCaptor.capture(), any(NetworkCapabilities.class), any(), any(),
-                anyInt());
+                any(), anyInt());
         // The new agent should have the new IP address.
         assertThat(linkPropertiesCaptor.getValue().getAllAddresses()).containsExactly(
                 InetAddresses.parseNumericAddress(IPV4_ADDRESS1),
@@ -1758,7 +1776,7 @@
         // Agent re-created, so register should be called twice.
         verify(mConnectivityManager, times(2)).registerNetworkAgent(any(), any(NetworkInfo.class),
                 linkPropertiesCaptor.capture(), any(NetworkCapabilities.class), any(), any(),
-                anyInt());
+                any(), anyInt());
         // The new agent should have the new IP address.
         assertThat(linkPropertiesCaptor.getValue().getAllAddresses()).containsExactly(
                 InetAddresses.parseNumericAddress(IPV6_ADDRESS1));
@@ -1808,8 +1826,8 @@
                 .addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
                 .build(), mPhone));
 
-        mDataNetworkUT = new DataNetwork(mPhone, Looper.myLooper(), mDataServiceManagers,
-                mInternetDataProfile, networkRequestList,
+        mDataNetworkUT = new DataNetwork(mPhone, mFeatureFlags, Looper.myLooper(),
+                mDataServiceManagers, mInternetDataProfile, networkRequestList,
                 AccessNetworkConstants.TRANSPORT_TYPE_WWAN,
                 DataAllowedReason.NORMAL, mDataNetworkCallback);
         replaceInstance(DataNetwork.class, "mDataCallSessionStats",
@@ -1849,7 +1867,7 @@
         // Agent should not be re-created, so register should be called ony once.
         verify(mConnectivityManager, times(1)).registerNetworkAgent(any(), any(NetworkInfo.class),
                 any(LinkProperties.class), any(NetworkCapabilities.class), any(), any(),
-                anyInt());
+                any(), anyInt());
 
         // The network should have IPv6 address now
         assertThat(mDataNetworkUT.getLinkProperties().getAllAddresses()).containsExactly(
@@ -1893,7 +1911,7 @@
         // Agent should not be re-created, so register should be called ony once.
         verify(mConnectivityManager, times(1)).registerNetworkAgent(any(), any(NetworkInfo.class),
                 any(LinkProperties.class), any(NetworkCapabilities.class), any(), any(),
-                anyInt());
+                any(), anyInt());
 
         // The network should have IPv6 address now
         assertThat(mDataNetworkUT.getLinkProperties().getAllAddresses()).containsExactly(
@@ -1938,7 +1956,7 @@
         // Agent should not be re-created, so register should be called ony once.
         verify(mConnectivityManager, times(1)).registerNetworkAgent(any(), any(NetworkInfo.class),
                 any(LinkProperties.class), any(NetworkCapabilities.class), any(), any(),
-                anyInt());
+                any(), anyInt());
 
         // The network should have IPv6 address now
         assertThat(mDataNetworkUT.getLinkProperties().getAllAddresses()).containsExactly(
@@ -1951,8 +1969,8 @@
         networkRequestList.add(new TelephonyNetworkRequest(new NetworkRequest.Builder()
                 .addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
                 .build(), mPhone));
-        mDataNetworkUT = new DataNetwork(mPhone, Looper.myLooper(), mDataServiceManagers,
-                m5gDataProfile, networkRequestList,
+        mDataNetworkUT = new DataNetwork(mPhone, mFeatureFlags, Looper.myLooper(),
+                mDataServiceManagers, m5gDataProfile, networkRequestList,
                 AccessNetworkConstants.TRANSPORT_TYPE_WWAN, DataAllowedReason.NORMAL,
                 mDataNetworkCallback);
         replaceInstance(DataNetwork.class, "mDataCallSessionStats",
@@ -1998,4 +2016,22 @@
         verify(mDataNetworkCallback).onLinkStatusChanged(eq(mDataNetworkUT),
                 eq(DataCallResponse.LINK_STATUS_INACTIVE));
     }
+
+    private void createImsDataNetwork(boolean isMmtel) throws Exception {
+        NetworkRequestList networkRequestList = new NetworkRequestList();
+        NetworkRequest.Builder builder = new NetworkRequest.Builder()
+                .addCapability(NetworkCapabilities.NET_CAPABILITY_IMS);
+        if (isMmtel) builder.addCapability(NetworkCapabilities.NET_CAPABILITY_MMTEL);
+        networkRequestList.add(new TelephonyNetworkRequest(builder.build(), mPhone));
+
+        setSuccessfulSetupDataResponse(mMockedWwanDataServiceManager, 123);
+
+        mDataNetworkUT = new DataNetwork(mPhone, mFeatureFlags, Looper.myLooper(),
+                mDataServiceManagers, mImsDataProfile, networkRequestList,
+                AccessNetworkConstants.TRANSPORT_TYPE_WWAN,
+                DataAllowedReason.NORMAL, mDataNetworkCallback);
+        replaceInstance(DataNetwork.class, "mDataCallSessionStats",
+                mDataNetworkUT, mDataCallSessionStats);
+        processAllMessages();
+    }
 }
diff --git a/tests/telephonytests/src/com/android/internal/telephony/data/DataProfileManagerTest.java b/tests/telephonytests/src/com/android/internal/telephony/data/DataProfileManagerTest.java
index 5c7e3ec..f9a11be 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/data/DataProfileManagerTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/data/DataProfileManagerTest.java
@@ -24,6 +24,7 @@
 import static org.mockito.Mockito.doAnswer;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
 
 import android.annotation.NonNull;
 import android.content.ContentValues;
@@ -53,6 +54,7 @@
 import com.android.internal.telephony.data.DataConfigManager.DataConfigManagerCallback;
 import com.android.internal.telephony.data.DataNetworkController.DataNetworkControllerCallback;
 import com.android.internal.telephony.data.DataProfileManager.DataProfileManagerCallback;
+import com.android.internal.telephony.flags.FeatureFlags;
 
 import org.junit.After;
 import org.junit.Before;
@@ -81,6 +83,7 @@
     private static final String IMS_APN = "IMS_APN";
     private static final String TETHERING_APN = "DUN_APN";
     private static final String APN_SET_ID_1_APN = "APN_SET_ID_1_APN";
+    private static final String RCS_APN = "RCS_APN";
     private static final String APN_SET_ID_1_TETHERING_APN = "APN_SET_ID_1_TETHERING_APN";
     private static final String MATCH_ALL_APN_SET_ID_IMS_APN = "MATCH_ALL_APN_SET_ID_IMS_APN";
     private static final String PLMN = "330123";
@@ -93,6 +96,8 @@
 
     private DataProfileManager mDataProfileManagerUT;
 
+    private FeatureFlags mFeatureFlags;
+
     private final ApnSettingContentProvider mApnSettingContentProvider =
             new ApnSettingContentProvider();
 
@@ -132,6 +137,7 @@
                 Telephony.Carriers.CARRIER_ID,
                 Telephony.Carriers.SKIP_464XLAT,
                 Telephony.Carriers.ALWAYS_ON,
+                Telephony.Carriers.INFRASTRUCTURE_BITMASK
         };
 
         private int mPreferredApnSet = 0;
@@ -170,7 +176,8 @@
                         DEFAULT_APN_SET_ID,     // apn_set_id
                         -1,                     // carrier_id
                         -1,                     // skip_464xlat
-                        0                       // always_on
+                        0,                      // always_on
+                        1                       // INFRASTRUCTURE_CELLULAR
                 },
                 // default internet data profile for RAT CDMA, to test update preferred data profile
                 new Object[]{
@@ -205,7 +212,8 @@
                         DEFAULT_APN_SET_ID,     // apn_set_id
                         -1,                     // carrier_id
                         -1,                     // skip_464xlat
-                        0                       // always_on
+                        0,                      // always_on
+                        1                       // INFRASTRUCTURE_CELLULAR
                 },
                 new Object[]{
                         2,                      // id
@@ -239,7 +247,8 @@
                         DEFAULT_APN_SET_ID,     // apn_set_id
                         -1,                     // carrier_id
                         -1,                     // skip_464xlat
-                        0                       // always_on
+                        0,                      // always_on
+                        1                       // INFRASTRUCTURE_CELLULAR
                 },
                 new Object[]{
                         3,                      // id
@@ -273,7 +282,8 @@
                         DEFAULT_APN_SET_ID,     // apn_set_id
                         -1,                     // carrier_id
                         -1,                     // skip_464xlat
-                        0                       // alwys_on
+                        0,                      // always_on
+                        1                       // INFRASTRUCTURE_CELLULAR
                 },
                 new Object[]{
                         4,                      // id
@@ -308,7 +318,8 @@
                         DEFAULT_APN_SET_ID,     // apn_set_id
                         -1,                     // carrier_id
                         -1,                     // skip_464xlat
-                        0                       // always_on
+                        0,                      // always_on
+                        1                       // INFRASTRUCTURE_CELLULAR
                 },
                 // This APN entry is created to test de-duping.
                 new Object[]{
@@ -344,7 +355,8 @@
                         DEFAULT_APN_SET_ID,     // apn_set_id
                         -1,                     // carrier_id
                         -1,                     // skip_464xlat
-                        0                       // always_on
+                        0,                      // always_on
+                        1                       // INFRASTRUCTURE_CELLULAR
                 },
                 new Object[]{
                         6,                      // id
@@ -379,7 +391,8 @@
                         APN_SET_ID_1,           // apn_set_id
                         -1,                     // carrier_id
                         -1,                     // skip_464xlat
-                        0                       // always_on
+                        0,                      // always_on
+                        1                       // INFRASTRUCTURE_CELLULAR
                 },
                 new Object[]{
                         7,                      // id
@@ -414,7 +427,8 @@
                         APN_SET_ID_1,           // apn_set_id
                         -1,                     // carrier_id
                         -1,                     // skip_464xlat
-                        0                       // always_on
+                        0,                      // always_on
+                        1                       // INFRASTRUCTURE_CELLULAR
                 },
                 new Object[]{
                         8,                      // id
@@ -449,7 +463,44 @@
                         MATCH_ALL_APN_SET_ID,   // apn_set_id
                         -1,                     // carrier_id
                         -1,                     // skip_464xlat
-                        0                       // always_on
+                        0,                      // always_on
+                        1                       // INFRASTRUCTURE_CELLULAR
+                },
+                new Object[]{
+                        9,                      // id
+                        PLMN,                   // numeric
+                        RCS_APN,                // name
+                        RCS_APN,                // apn
+                        "",                     // proxy
+                        "",                     // port
+                        "",                     // mmsc
+                        "",                     // mmsproxy
+                        "",                     // mmsport
+                        "",                     // user
+                        "",                     // password
+                        -1,                     // authtype
+                        "rcs",                  // types
+                        "IPV4V6",               // protocol
+                        "IPV4V6",               // roaming_protocol
+                        1,                      // carrier_enabled
+                        0,                      // profile_id
+                        1,                      // modem_cognitive
+                        0,                      // max_conns
+                        0,                      // wait_time
+                        0,                      // max_conns_time
+                        0,                      // mtu
+                        1280,                   // mtu_v4
+                        1280,                   // mtu_v6
+                        "",                     // mvno_type
+                        "",                     // mnvo_match_data
+                        TelephonyManager.NETWORK_TYPE_BITMASK_LTE
+                                | TelephonyManager.NETWORK_TYPE_BITMASK_NR, // network_type_bitmask
+                        0,                      // lingering_network_type_bitmask
+                        DEFAULT_APN_SET_ID,     // apn_set_id
+                        -1,                     // carrier_id
+                        -1,                     // skip_464xlat
+                        0,                      // always_on
+                        2                       // INFRASTRUCTURE_SATELLITE
                 }
         );
 
@@ -621,6 +672,7 @@
         logd("DataProfileManagerTest +Setup!");
         super.setUp(getClass().getSimpleName());
         mDataProfileManagerCallback = Mockito.mock(DataProfileManagerCallback.class);
+        mFeatureFlags = Mockito.mock(FeatureFlags.class);
         ((MockContentResolver) mContext.getContentResolver()).addProvider(
                 Telephony.Carriers.CONTENT_URI.getAuthority(), mApnSettingContentProvider);
 
@@ -632,7 +684,8 @@
             return null;
         }).when(mDataProfileManagerCallback).invokeFromExecutor(any(Runnable.class));
         mDataProfileManagerUT = new DataProfileManager(mPhone, mDataNetworkController,
-                mMockedWwanDataServiceManager, Looper.myLooper(), mDataProfileManagerCallback);
+                mMockedWwanDataServiceManager, Looper.myLooper(), mFeatureFlags,
+                mDataProfileManagerCallback);
         ArgumentCaptor<DataNetworkControllerCallback> dataNetworkControllerCallbackCaptor =
                 ArgumentCaptor.forClass(DataNetworkControllerCallback.class);
         verify(mDataNetworkController).registerDataNetworkControllerCallback(
@@ -663,7 +716,7 @@
                 .build();
         TelephonyNetworkRequest tnr = new TelephonyNetworkRequest(request, mPhone);
         DataProfile dp = mDataProfileManagerUT.getDataProfileForNetworkRequest(tnr,
-                TelephonyManager.NETWORK_TYPE_LTE, false);
+                TelephonyManager.NETWORK_TYPE_LTE, false, false);
 
         assertThat(dp.canSatisfy(tnr.getCapabilities())).isTrue();
         assertThat(dp.getApnSetting().getApnName()).isEqualTo(GENERAL_PURPOSE_APN);
@@ -674,7 +727,7 @@
                 .build();
         tnr = new TelephonyNetworkRequest(request, mPhone);
         dp = mDataProfileManagerUT.getDataProfileForNetworkRequest(tnr,
-                TelephonyManager.NETWORK_TYPE_LTE, false);
+                TelephonyManager.NETWORK_TYPE_LTE, false, false);
 
         assertThat(dp.canSatisfy(tnr.getCapabilities())).isTrue();
         assertThat(dp.getApnSetting().getApnName()).isEqualTo(GENERAL_PURPOSE_APN);
@@ -684,7 +737,7 @@
                 .build();
         tnr = new TelephonyNetworkRequest(request, mPhone);
         dp = mDataProfileManagerUT.getDataProfileForNetworkRequest(tnr,
-                TelephonyManager.NETWORK_TYPE_LTE, false);
+                TelephonyManager.NETWORK_TYPE_LTE, false, false);
         assertThat(dp.canSatisfy(tnr.getCapabilities())).isTrue();
         assertThat(dp.getApnSetting().getApnName()).isEqualTo(IMS_APN);
 
@@ -693,7 +746,7 @@
                 .build();
         tnr = new TelephonyNetworkRequest(request, mPhone);
         dp = mDataProfileManagerUT.getDataProfileForNetworkRequest(tnr,
-                TelephonyManager.NETWORK_TYPE_LTE, false);
+                TelephonyManager.NETWORK_TYPE_LTE, false, false);
         assertThat(dp).isNull();
 
         doReturn(new NetworkRegistrationInfo.Builder()
@@ -706,7 +759,7 @@
                 .build();
         tnr = new TelephonyNetworkRequest(request, mPhone);
         dp = mDataProfileManagerUT.getDataProfileForNetworkRequest(tnr,
-                TelephonyManager.NETWORK_TYPE_NR, false);
+                TelephonyManager.NETWORK_TYPE_NR, false, false);
         assertThat(dp.canSatisfy(tnr.getCapabilities())).isTrue();
         assertThat(dp.getApnSetting().getApnName()).isEqualTo(TETHERING_APN);
     }
@@ -718,7 +771,7 @@
                 .build();
         TelephonyNetworkRequest tnr = new TelephonyNetworkRequest(request, mPhone);
         DataProfile dp = mDataProfileManagerUT.getDataProfileForNetworkRequest(tnr,
-                TelephonyManager.NETWORK_TYPE_GSM, false);
+                TelephonyManager.NETWORK_TYPE_GSM, false, false);
         // Should not find data profile due to RAT incompatible.
         assertThat(dp).isNull();
     }
@@ -730,14 +783,14 @@
                         .addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
                         .build(), mPhone);
         DataProfile dataProfile = mDataProfileManagerUT.getDataProfileForNetworkRequest(
-                tnr, TelephonyManager.NETWORK_TYPE_LTE, false);
+                tnr, TelephonyManager.NETWORK_TYPE_LTE, false, false);
         assertThat(dataProfile.getApnSetting().getApnName()).isEqualTo(GENERAL_PURPOSE_APN);
         logd("Set setLastSetupTimestamp on " + dataProfile);
         dataProfile.setLastSetupTimestamp(SystemClock.elapsedRealtime());
 
         // See if another one can be returned.
         dataProfile = mDataProfileManagerUT.getDataProfileForNetworkRequest(
-                tnr, TelephonyManager.NETWORK_TYPE_LTE, false);
+                tnr, TelephonyManager.NETWORK_TYPE_LTE, false, false);
         assertThat(dataProfile.getApnSetting().getApnName()).isEqualTo(GENERAL_PURPOSE_APN1);
     }
 
@@ -748,7 +801,7 @@
                         .addCapability(NetworkCapabilities.NET_CAPABILITY_ENTERPRISE)
                         .build(), mPhone);
         DataProfile dataProfile = mDataProfileManagerUT.getDataProfileForNetworkRequest(
-                tnr, TelephonyManager.NETWORK_TYPE_LTE, false);
+                tnr, TelephonyManager.NETWORK_TYPE_LTE, false, false);
         assertThat(dataProfile.getApnSetting()).isNull();
         OsAppId osAppId = new OsAppId(dataProfile.getTrafficDescriptor().getOsAppId());
 
@@ -761,7 +814,7 @@
                 .addEnterpriseId(2), ConnectivityManager.TYPE_NONE,
                 0, NetworkRequest.Type.REQUEST), mPhone);
         dataProfile = mDataProfileManagerUT.getDataProfileForNetworkRequest(
-                tnr, TelephonyManager.NETWORK_TYPE_LTE, false);
+                tnr, TelephonyManager.NETWORK_TYPE_LTE, false, false);
         assertThat(dataProfile.getApnSetting()).isNull();
         osAppId = new OsAppId(dataProfile.getTrafficDescriptor().getOsAppId());
 
@@ -777,7 +830,7 @@
                         .addCapability(NetworkCapabilities.NET_CAPABILITY_PRIORITIZE_LATENCY)
                         .build(), mPhone);
         DataProfile dataProfile = mDataProfileManagerUT.getDataProfileForNetworkRequest(
-                tnr, TelephonyManager.NETWORK_TYPE_LTE, false);
+                tnr, TelephonyManager.NETWORK_TYPE_LTE, false, false);
         assertThat(dataProfile.getApnSetting()).isNull();
         OsAppId osAppId = new OsAppId(dataProfile.getTrafficDescriptor().getOsAppId());
 
@@ -793,7 +846,7 @@
                         .addCapability(NetworkCapabilities.NET_CAPABILITY_PRIORITIZE_BANDWIDTH)
                         .build(), mPhone);
         DataProfile dataProfile = mDataProfileManagerUT.getDataProfileForNetworkRequest(
-                tnr, TelephonyManager.NETWORK_TYPE_LTE, false);
+                tnr, TelephonyManager.NETWORK_TYPE_LTE, false, false);
         assertThat(dataProfile.getApnSetting()).isNull();
         OsAppId osAppId = new OsAppId(dataProfile.getTrafficDescriptor().getOsAppId());
 
@@ -803,13 +856,28 @@
     }
 
     @Test
+    public void testGetDataProfileForSatellite() {
+        when(mFeatureFlags.carrierEnabledSatelliteFlag()).thenReturn(true);
+
+        NetworkRequest request = new NetworkRequest.Builder()
+                .addCapability(NetworkCapabilities.NET_CAPABILITY_RCS)
+                .build();
+        TelephonyNetworkRequest tnr = new TelephonyNetworkRequest(request, mPhone);
+        DataProfile dp = mDataProfileManagerUT.getDataProfileForNetworkRequest(tnr,
+                TelephonyManager.NETWORK_TYPE_LTE, true, false);
+
+        assertThat(dp.canSatisfy(tnr.getCapabilities())).isTrue();
+        assertThat(dp.getApnSetting().getApnName()).isEqualTo(RCS_APN);
+    }
+
+    @Test
     public void testSetPreferredDataProfile() {
         TelephonyNetworkRequest tnr = new TelephonyNetworkRequest(
                 new NetworkRequest.Builder()
                         .addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
                         .build(), mPhone);
         DataProfile dataProfile = mDataProfileManagerUT.getDataProfileForNetworkRequest(
-                tnr, TelephonyManager.NETWORK_TYPE_LTE, false);
+                tnr, TelephonyManager.NETWORK_TYPE_LTE, false, false);
         assertThat(dataProfile.getApnSetting().getApnName()).isEqualTo(GENERAL_PURPOSE_APN);
         dataProfile.setLastSetupTimestamp(SystemClock.elapsedRealtime());
         dataProfile.setPreferred(true);
@@ -823,14 +891,14 @@
 
         // Test See if the same one can be returned.
         dataProfile = mDataProfileManagerUT.getDataProfileForNetworkRequest(
-                tnr, TelephonyManager.NETWORK_TYPE_LTE, false);
+                tnr, TelephonyManager.NETWORK_TYPE_LTE, false, false);
         assertThat(dataProfile.getApnSetting().getApnName()).isEqualTo(GENERAL_PURPOSE_APN);
         assertThat(mDataProfileManagerUT.isDataProfilePreferred(dataProfile)).isTrue();
 
         // Test Another default internet network connected due to RAT changed. Verify the preferred
         // data profile is updated.
         DataProfile legacyRatDataProfile = mDataProfileManagerUT.getDataProfileForNetworkRequest(
-                tnr, TelephonyManager.NETWORK_TYPE_CDMA, false);
+                tnr, TelephonyManager.NETWORK_TYPE_CDMA, false, false);
         DataNetwork legacyRatInternetNetwork = Mockito.mock(DataNetwork.class);
         doReturn(legacyRatDataProfile).when(legacyRatInternetNetwork).getDataProfile();
         doReturn(new DataNetworkController.NetworkRequestList(List.of(tnr)))
@@ -849,7 +917,7 @@
                         .addCapability(NetworkCapabilities.NET_CAPABILITY_DUN)
                         .build(), mPhone);
         DataProfile dunDataProfile = mDataProfileManagerUT.getDataProfileForNetworkRequest(
-                dunTnr, TelephonyManager.NETWORK_TYPE_LTE, false);
+                dunTnr, TelephonyManager.NETWORK_TYPE_LTE, false, false);
         DataNetwork dunInternetNetwork = Mockito.mock(DataNetwork.class);
         doReturn(dunDataProfile).when(dunInternetNetwork).getDataProfile();
         doReturn(new DataNetworkController.NetworkRequestList(List.of(dunTnr)))
@@ -948,7 +1016,7 @@
                         .addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
                         .build(), mPhone);
         DataProfile dataProfile = mDataProfileManagerUT.getDataProfileForNetworkRequest(
-                tnr, TelephonyManager.NETWORK_TYPE_LTE, false);
+                tnr, TelephonyManager.NETWORK_TYPE_LTE, false, false);
         assertThat(dataProfile).isNull();
 
         // expect default EIMS when SIM absent
@@ -957,7 +1025,7 @@
                         .addCapability(NetworkCapabilities.NET_CAPABILITY_EIMS)
                         .build(), mPhone);
         dataProfile = mDataProfileManagerUT.getDataProfileForNetworkRequest(
-                tnr, TelephonyManager.NETWORK_TYPE_LTE, false);
+                tnr, TelephonyManager.NETWORK_TYPE_LTE, false, false);
         assertThat(dataProfile.getApnSetting().getApnName()).isEqualTo("sos");
 
         // expect no default IMS when SIM absent
@@ -966,7 +1034,7 @@
                         .addCapability(NetworkCapabilities.NET_CAPABILITY_IMS)
                         .build(), mPhone);
         dataProfile = mDataProfileManagerUT.getDataProfileForNetworkRequest(
-                tnr, TelephonyManager.NETWORK_TYPE_LTE, false);
+                tnr, TelephonyManager.NETWORK_TYPE_LTE, false, false);
         assertThat(dataProfile).isEqualTo(null);
 
         // Verify null as initial attached data profile is sent to modem
@@ -996,7 +1064,7 @@
                         .addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
                         .build(), mPhone);
         DataProfile dataProfile = mDataProfileManagerUT.getDataProfileForNetworkRequest(
-                tnr, TelephonyManager.NETWORK_TYPE_LTE, false);
+                tnr, TelephonyManager.NETWORK_TYPE_LTE, false, false);
         assertThat(dataProfile).isNull();
 
         // expect default EIMS when SIM absent
@@ -1005,7 +1073,7 @@
                         .addCapability(NetworkCapabilities.NET_CAPABILITY_EIMS)
                         .build(), mPhone);
         dataProfile = mDataProfileManagerUT.getDataProfileForNetworkRequest(
-                tnr, TelephonyManager.NETWORK_TYPE_LTE, false);
+                tnr, TelephonyManager.NETWORK_TYPE_LTE, false, false);
         assertThat(dataProfile.getApnSetting().getApnName()).isEqualTo("sos");
 
         // expect no default IMS when SIM absent
@@ -1014,7 +1082,7 @@
                         .addCapability(NetworkCapabilities.NET_CAPABILITY_IMS)
                         .build(), mPhone);
         dataProfile = mDataProfileManagerUT.getDataProfileForNetworkRequest(
-                tnr, TelephonyManager.NETWORK_TYPE_LTE, false);
+                tnr, TelephonyManager.NETWORK_TYPE_LTE, false, false);
         assertThat(dataProfile).isEqualTo(null);
 
         // Verify in legacy mode, null IA should NOT be sent to modem
@@ -1049,7 +1117,7 @@
                 new TelephonyNetworkRequest(new NetworkRequest.Builder()
                         .addCapability(NetworkCapabilities.NET_CAPABILITY_IMS)
                         .build(), mPhone),
-                TelephonyManager.NETWORK_TYPE_LTE, false);
+                TelephonyManager.NETWORK_TYPE_LTE, false, false);
         assertThat(dataProfile.getApnSetting().getApnName()).isEqualTo(IMS_APN);
     }
 
@@ -1061,7 +1129,7 @@
         TelephonyNetworkRequest tnr = new TelephonyNetworkRequest(request, mPhone);
         // This should get the merged data profile after deduping.
         DataProfile dp = mDataProfileManagerUT.getDataProfileForNetworkRequest(tnr,
-                TelephonyManager.NETWORK_TYPE_LTE, false);
+                TelephonyManager.NETWORK_TYPE_LTE, false, false);
         assertThat(dp.canSatisfy(NetworkCapabilities.NET_CAPABILITY_INTERNET)).isTrue();
     }
 
@@ -1198,7 +1266,7 @@
                 .addCapability(NetworkCapabilities.NET_CAPABILITY_EIMS)
                 .build(), mPhone);
         DataProfile dataProfile = mDataProfileManagerUT.getDataProfileForNetworkRequest(
-                tnr, TelephonyManager.NETWORK_TYPE_LTE, false);
+                tnr, TelephonyManager.NETWORK_TYPE_LTE, false, false);
 
         assertThat(dataProfile.getApn()).isEqualTo("sos");
         assertThat(dataProfile.getTrafficDescriptor().getDataNetworkName()).isEqualTo("sos");
@@ -1215,7 +1283,7 @@
                         .addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
                         .build(), mPhone);
         DataProfile dataProfile = mDataProfileManagerUT.getDataProfileForNetworkRequest(
-                tnr, TelephonyManager.NETWORK_TYPE_LTE, false);
+                tnr, TelephonyManager.NETWORK_TYPE_LTE, false, false);
         assertThat(dataProfile.getApnSetting().getApnName()).isEqualTo(GENERAL_PURPOSE_APN);
         dataProfile.setLastSetupTimestamp(SystemClock.elapsedRealtime());
         DataNetwork internetNetwork = Mockito.mock(DataNetwork.class);
@@ -1286,7 +1354,7 @@
 
         // The carrier configured data profile should be the preferred APN after APN reset
         DataProfile dataProfile = mDataProfileManagerUT.getDataProfileForNetworkRequest(
-                tnr, TelephonyManager.NETWORK_TYPE_LTE, false);
+                tnr, TelephonyManager.NETWORK_TYPE_LTE, false, false);
 
         assertThat(dataProfile.getApnSetting().getApnName()).isEqualTo(GENERAL_PURPOSE_APN1);
         assertThat(mDataProfileManagerUT.isDataProfilePreferred(dataProfile)).isTrue();
@@ -1299,7 +1367,7 @@
 
         // The carrier configured data profile should be the preferred APN after APN reset
         dataProfile = mDataProfileManagerUT.getDataProfileForNetworkRequest(
-                tnr, TelephonyManager.NETWORK_TYPE_LTE, false);
+                tnr, TelephonyManager.NETWORK_TYPE_LTE, false, false);
         assertThat(dataProfile.getApnSetting().getApnName()).isEqualTo(GENERAL_PURPOSE_APN1);
         assertThat(mDataProfileManagerUT.isDataProfilePreferred(dataProfile)).isTrue();
     }
@@ -1580,7 +1648,7 @@
                 .build();
         TelephonyNetworkRequest tnr = new TelephonyNetworkRequest(request, mPhone);
         DataProfile dp = mDataProfileManagerUT.getDataProfileForNetworkRequest(tnr,
-                TelephonyManager.NETWORK_TYPE_LTE, false);
+                TelephonyManager.NETWORK_TYPE_LTE, false, false);
 
         // Mark the APN as permanent failed.
         dp.getApnSetting().setPermanentFailed(true);
@@ -1588,7 +1656,7 @@
         // Data profile manager should return a different data profile for setup as the previous
         // data profile has been marked as permanent failed.
         assertThat(mDataProfileManagerUT.getDataProfileForNetworkRequest(tnr,
-                TelephonyManager.NETWORK_TYPE_LTE, false)).isNotEqualTo(dp);
+                TelephonyManager.NETWORK_TYPE_LTE, false, false)).isNotEqualTo(dp);
     }
 
     @Test
@@ -1603,7 +1671,7 @@
                 .build();
         TelephonyNetworkRequest tnr = new TelephonyNetworkRequest(request, mPhone);
         DataProfile dp = mDataProfileManagerUT.getDataProfileForNetworkRequest(tnr,
-                TelephonyManager.NETWORK_TYPE_LTE, false);
+                TelephonyManager.NETWORK_TYPE_LTE, false, false);
 
         // Mark the APN as permanent failed.
         dp.getApnSetting().setPermanentFailed(true);
@@ -1611,7 +1679,7 @@
         // Since preferred APN is already set, and that data profile was marked as permanent failed,
         // so this should result in getting nothing.
         assertThat(mDataProfileManagerUT.getDataProfileForNetworkRequest(tnr,
-                TelephonyManager.NETWORK_TYPE_LTE, false)).isNull();
+                TelephonyManager.NETWORK_TYPE_LTE, false, false)).isNull();
     }
 
     private void changeSimStateTo(@TelephonyManager.SimState int simState) {
@@ -1632,6 +1700,6 @@
         // Verify the we can get the previously permanent failed data profile again.
         assertThat(mDataProfileManagerUT.getDataProfileForNetworkRequest(
                 new TelephonyNetworkRequest(request, mPhone),
-                TelephonyManager.NETWORK_TYPE_LTE, false)).isNotNull();
+                TelephonyManager.NETWORK_TYPE_LTE, false, false)).isNotNull();
     }
 }
diff --git a/tests/telephonytests/src/com/android/internal/telephony/data/DataProfileTest.java b/tests/telephonytests/src/com/android/internal/telephony/data/DataProfileTest.java
index 4a2eb38..f5981f7 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/data/DataProfileTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/data/DataProfileTest.java
@@ -179,6 +179,7 @@
         assertThat(dp.canSatisfy(NetworkCapabilities.NET_CAPABILITY_MMS)).isFalse();
         assertThat(dp.canSatisfy(new int[]{NetworkCapabilities.NET_CAPABILITY_INTERNET,
                 NetworkCapabilities.NET_CAPABILITY_MMS})).isFalse();
+        assertThat(dp.canSatisfy(new int[]{NetworkCapabilities.NET_CAPABILITY_RCS})).isFalse();
     }
 
     @Test
diff --git a/tests/telephonytests/src/com/android/internal/telephony/data/DataRetryManagerTest.java b/tests/telephonytests/src/com/android/internal/telephony/data/DataRetryManagerTest.java
index 8372d8f..dd95ff0 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/data/DataRetryManagerTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/data/DataRetryManagerTest.java
@@ -158,7 +158,8 @@
         mockedDataServiceManagers.put(AccessNetworkConstants.TRANSPORT_TYPE_WLAN,
                 mMockedWlanDataServiceManager);
         mDataRetryManagerUT = new DataRetryManager(mPhone, mDataNetworkController,
-                mockedDataServiceManagers, Looper.myLooper(), mDataRetryManagerCallbackMock);
+                mockedDataServiceManagers, Looper.myLooper(), mFeatureFlags,
+                mDataRetryManagerCallbackMock);
 
         ArgumentCaptor<DataConfigManagerCallback> dataConfigManagerCallbackCaptor =
                 ArgumentCaptor.forClass(DataConfigManagerCallback.class);
@@ -340,29 +341,30 @@
 
     @Test
     public void testDataSetupUnthrottling() throws Exception {
-        testDataSetupRetryNetworkSuggestedNeverRetry();
+        doReturn(true).when(mFeatureFlags).unthrottleCheckTransport();
+        NetworkRequest request = new NetworkRequest.Builder()
+                .addCapability(NetworkCapabilities.NET_CAPABILITY_IMS)
+                .build();
+        TelephonyNetworkRequest tnr = new TelephonyNetworkRequest(request, mPhone);
+        DataNetworkController.NetworkRequestList
+                networkRequestList = new DataNetworkController.NetworkRequestList(tnr);
+        mDataRetryManagerUT.evaluateDataSetupRetry(mDataProfile3,
+                AccessNetworkConstants.TRANSPORT_TYPE_WWAN, networkRequestList, 123,
+                456);
+        mDataRetryManagerUT.evaluateDataSetupRetry(mDataProfile3,
+                AccessNetworkConstants.TRANSPORT_TYPE_WLAN, networkRequestList, 123,
+                456);
+        processAllFutureMessages();
         Mockito.clearInvocations(mDataRetryManagerCallbackMock);
+
         DataNetworkController.NetworkRequestList mockNrl = Mockito.mock(
                 DataNetworkController.NetworkRequestList.class);
         Field field = DataRetryManager.class.getDeclaredField("mDataRetryEntries");
         field.setAccessible(true);
         List<DataRetryEntry> mDataRetryEntries =
                 (List<DataRetryEntry>) field.get(mDataRetryManagerUT);
+        assertThat(mDataRetryEntries.size()).isEqualTo(2);
 
-        // schedule 2 setup retries
-        DataSetupRetryEntry scheduledRetry1 = new DataSetupRetryEntry.Builder<>()
-                .setDataProfile(mDataProfile3)
-                .setNetworkRequestList(mockNrl)
-                .setTransport(AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
-                .setSetupRetryType(1)
-                .build();
-        DataSetupRetryEntry scheduledRetry2 = new DataSetupRetryEntry.Builder<>()
-                .setNetworkRequestList(mockNrl)
-                .setDataProfile(mDataProfile3)
-                .setTransport(AccessNetworkConstants.TRANSPORT_TYPE_WLAN)
-                .setSetupRetryType(1)
-                .build();
-        mDataRetryEntries.addAll(List.of(scheduledRetry1, scheduledRetry2));
         // Suppose we set the data profile as permanently failed.
         mDataProfile3.getApnSetting().setPermanentFailed(true);
 
@@ -408,8 +410,21 @@
         assertThat(entry.transport).isEqualTo(AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
 
         // check mDataProfile3-WWAN retry is cancelled, but not the WLAN
-        assertThat(scheduledRetry1.getState()).isEqualTo(DataRetryEntry.RETRY_STATE_CANCELLED);
-        assertThat(scheduledRetry2.getState()).isEqualTo(DataRetryEntry.RETRY_STATE_NOT_RETRIED);
+        assertThat(mDataRetryEntries.size()).isEqualTo(3);
+        for (DataRetryEntry retry : mDataRetryEntries) {
+            DataSetupRetryEntry setupRetry = (DataSetupRetryEntry) retry;
+            if (setupRetry.transport == AccessNetworkConstants.TRANSPORT_TYPE_WWAN) {
+                if (setupRetry.retryDelayMillis == 0) {
+                    assertThat(setupRetry.getState())
+                            .isEqualTo(DataRetryEntry.RETRY_STATE_NOT_RETRIED);
+                } else {
+                    assertThat(setupRetry.getState())
+                            .isEqualTo(DataRetryEntry.RETRY_STATE_CANCELLED);
+                }
+            } else {
+                assertThat(setupRetry.getState()).isEqualTo(DataRetryEntry.RETRY_STATE_NOT_RETRIED);
+            }
+        }
     }
 
     @Test
diff --git a/tests/telephonytests/src/com/android/internal/telephony/data/PhoneSwitcherTest.java b/tests/telephonytests/src/com/android/internal/telephony/data/PhoneSwitcherTest.java
index 9e78afd..94fd934 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/data/PhoneSwitcherTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/data/PhoneSwitcherTest.java
@@ -679,6 +679,37 @@
     }
 
     @Test
+    public void testSetAutoSelectedValidationFeatureNotSupported() throws Exception {
+        doReturn(false).when(mCellularNetworkValidator).isValidationFeatureSupported();
+        initialize();
+
+        // Phone 0 has sub 1, phone 1 has sub 2.
+        // Sub 1 is default data sub.
+        // Both are active subscriptions are active sub, as they are in both active slots.
+        setSlotIndexToSubId(0, 1);
+        setSlotIndexToSubId(1, 2);
+        setDefaultDataSubId(1);
+
+        doReturn(new SubscriptionInfoInternal.Builder(mSubscriptionManagerService
+                .getSubscriptionInfoInternal(2)).setOpportunistic(1).build())
+                .when(mSubscriptionManagerService).getSubscriptionInfoInternal(2);
+
+        mPhoneSwitcherUT.trySetOpportunisticDataSubscription(2, false, mSetOpptDataCallback1);
+        processAllMessages();
+        mPhoneSwitcherUT.mValidationCallback.onNetworkAvailable(null, 2);
+        processAllMessages();
+        assertEquals(2, mPhoneSwitcherUT.getAutoSelectedDataSubId());
+
+        // Switch to the default sub, verify AutoSelectedDataSubId is the default value.
+        clearInvocations(mSetOpptDataCallback1);
+        mPhoneSwitcherUT.trySetOpportunisticDataSubscription(SubscriptionManager
+                .DEFAULT_SUBSCRIPTION_ID, true, mSetOpptDataCallback1);
+        processAllMessages();
+        assertEquals(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID,
+                mPhoneSwitcherUT.getAutoSelectedDataSubId());
+    }
+
+    @Test
     @SmallTest
     public void testSetPreferredDataModemCommand() throws Exception {
         doReturn(true).when(mMockRadioConfig).isSetPreferredDataCommandSupported();
@@ -1357,7 +1388,7 @@
                 .when(mSubscriptionManagerService).getSubscriptionInfoInternal(2);
 
         // Switch to primary before a primary is selected/inactive.
-        setDefaultDataSubId(-1);
+        setDefaultDataSubId(SubscriptionManager.INVALID_SUBSCRIPTION_ID);
         mPhoneSwitcherUT.trySetOpportunisticDataSubscription(
                 SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, false, mSetOpptDataCallback1);
         processAllMessages();
@@ -1992,7 +2023,7 @@
         doReturn(true).when(mDataConfigManager).isPingTestBeforeAutoDataSwitchRequired();
     }
 
-    private void setDefaultDataSubId(int defaultDataSub) throws Exception {
+    private void setDefaultDataSubId(int defaultDataSub) {
         mDefaultDataSub = defaultDataSub;
         doReturn(mDefaultDataSub).when(mSubscriptionManagerService).getDefaultDataSubId();
         for (Phone phone : mPhones) {
diff --git a/tests/telephonytests/src/com/android/internal/telephony/data/TelephonyNetworkRequestTest.java b/tests/telephonytests/src/com/android/internal/telephony/data/TelephonyNetworkRequestTest.java
index 9752885..26a9fde 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/data/TelephonyNetworkRequestTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/data/TelephonyNetworkRequestTest.java
@@ -87,6 +87,24 @@
             .setMaxConnsTime(789)
             .build();
 
+    private static final ApnSetting RCS_APN_SETTING = new ApnSetting.Builder()
+            .setId(2165)
+            .setOperatorNumeric("12345")
+            .setEntryName("rcs")
+            .setApnName("rcs")
+            .setUser("user")
+            .setPassword("passwd")
+            .setApnTypeBitmask(ApnSetting.TYPE_RCS)
+            .setProtocol(ApnSetting.PROTOCOL_IPV6)
+            .setRoamingProtocol(ApnSetting.PROTOCOL_IP)
+            .setCarrierEnabled(true)
+            .setNetworkTypeBitmask(0)
+            .setProfileId(1234)
+            .setMaxConns(321)
+            .setWaitTime(456)
+            .setMaxConnsTime(789)
+            .build();
+
     @Before
     public void setUp() throws Exception {
         logd("TelephonyNetworkRequestTest +Setup!");
@@ -211,6 +229,20 @@
                 .addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VCN_MANAGED)
                 .build();
         assertThat(internetRequest.canBeSatisfiedBy(caps)).isTrue();
+
+        TelephonyNetworkRequest rcsRequest = new TelephonyNetworkRequest(
+                new NetworkRequest.Builder()
+                        .addCapability(NetworkCapabilities.NET_CAPABILITY_RCS)
+                        .build(), mPhone);
+        caps = new NetworkCapabilities.Builder()
+                .addCapability(NetworkCapabilities.NET_CAPABILITY_RCS)
+                .addCapability(NetworkCapabilities.NET_CAPABILITY_MMS)
+                .addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED)
+                .addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VPN)
+                .addCapability(NetworkCapabilities.NET_CAPABILITY_TRUSTED)
+                .addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VCN_MANAGED)
+                .build();
+        assertThat(rcsRequest.canBeSatisfiedBy(caps)).isTrue();
     }
 
     @Test
@@ -223,17 +255,25 @@
                 new NetworkRequest.Builder()
                         .addCapability(NetworkCapabilities.NET_CAPABILITY_MMS)
                         .build(), mPhone);
+        TelephonyNetworkRequest rcsRequest = new TelephonyNetworkRequest(
+                new NetworkRequest.Builder()
+                        .addCapability(NetworkCapabilities.NET_CAPABILITY_RCS)
+                        .build(), mPhone);
         DataProfile internetDataProfile = new DataProfile.Builder()
                 .setApnSetting(INTERNET_APN_SETTING)
                 .build();
         DataProfile mmsDataProfile = new DataProfile.Builder()
                 .setApnSetting(MMS_APN_SETTING)
                 .build();
+        DataProfile rcsDataProfile = new DataProfile.Builder()
+                .setApnSetting(RCS_APN_SETTING)
+                .build();
 
         assertThat(internetRequest.canBeSatisfiedBy(internetDataProfile)).isTrue();
         assertThat(internetRequest.canBeSatisfiedBy(mmsDataProfile)).isFalse();
         assertThat(mmsRequest.canBeSatisfiedBy(internetDataProfile)).isFalse();
         assertThat(mmsRequest.canBeSatisfiedBy(mmsDataProfile)).isTrue();
+        assertThat(rcsRequest.canBeSatisfiedBy(rcsDataProfile)).isTrue();
     }
 
     @Test
diff --git a/tests/telephonytests/src/com/android/internal/telephony/domainselection/DomainSelectionConnectionTest.java b/tests/telephonytests/src/com/android/internal/telephony/domainselection/DomainSelectionConnectionTest.java
index ce59cc6..a2a55ee 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/domainselection/DomainSelectionConnectionTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/domainselection/DomainSelectionConnectionTest.java
@@ -131,19 +131,16 @@
     public void testWwanSelectorCallbackAsync() throws Exception {
         mDsc = new DomainSelectionConnection(mPhone, SELECTOR_TYPE_CALLING, true,
                 mDomainSelectionController);
-        replaceInstance(DomainSelectionConnection.class, "mWwanSelectedExecutor",
-                mDsc, new Executor() {
-                    public void execute(Runnable command) {
-                        command.run();
-                    }
-                });
 
         TransportSelectorCallback transportCallback = mDsc.getTransportSelectorCallback();
 
         assertNotNull(transportCallback);
 
+        replaceInstance(DomainSelectionConnection.class, "mLooper",
+                mDsc, mTestableLooper.getLooper());
         Consumer<WwanSelectorCallback> consumer = Mockito.mock(Consumer.class);
         transportCallback.onWwanSelected(consumer);
+        processAllMessages();
 
         verify(consumer).accept(any());
     }
@@ -171,6 +168,7 @@
         Consumer<EmergencyRegResult> consumer = Mockito.mock(Consumer.class);
 
         wwanCallback.onRequestEmergencyNetworkScan(preferredNetworks, scanType, null, consumer);
+        processAllMessages();
 
         ArgumentCaptor<Handler> handlerCaptor = ArgumentCaptor.forClass(Handler.class);
         ArgumentCaptor<Integer> eventCaptor = ArgumentCaptor.forClass(Integer.class);
@@ -220,11 +218,13 @@
         CancellationSignal signal = new CancellationSignal();
         wwanCallback.onRequestEmergencyNetworkScan(new ArrayList<>(),
                 SCAN_TYPE_NO_PREFERENCE, signal, Mockito.mock(Consumer.class));
+        processAllMessages();
 
         verify(mPhone).registerForEmergencyNetworkScan(any(), anyInt(), any());
         verify(mPhone).triggerEmergencyNetworkScan(any(), anyInt(), any());
 
         signal.cancel();
+        processAllMessages();
 
         verify(mPhone).cancelEmergencyNetworkScan(eq(false), any());
     }
diff --git a/tests/telephonytests/src/com/android/internal/telephony/emergency/EmergencyStateTrackerTest.java b/tests/telephonytests/src/com/android/internal/telephony/emergency/EmergencyStateTrackerTest.java
index 7c1ac2c..0be1927 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/emergency/EmergencyStateTrackerTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/emergency/EmergencyStateTrackerTest.java
@@ -869,7 +869,7 @@
         assertEquals(future.getNow(DisconnectCause.ERROR_UNSPECIFIED),
                 Integer.valueOf(DisconnectCause.NOT_DISCONNECTED));
 
-        emergencyStateTracker.endSms(TEST_SMS_ID, getTestEmergencyNumber());
+        emergencyStateTracker.endSms(TEST_SMS_ID, true);
 
         verify(phone0).exitEmergencyMode(any(Message.class));
         assertFalse(emergencyStateTracker.isInEmergencyMode());
@@ -1316,7 +1316,7 @@
 
         assertTrue(emergencyStateTracker.isInEmergencyMode());
 
-        emergencyStateTracker.endSms(TEST_SMS_ID, getTestEmergencyNumber());
+        emergencyStateTracker.endSms(TEST_SMS_ID, true);
         processAllMessages();
 
         assertFalse(emergencyStateTracker.isInEmergencyMode());
@@ -1353,7 +1353,7 @@
         assertEquals(future.getNow(DisconnectCause.ERROR_UNSPECIFIED),
                 Integer.valueOf(DisconnectCause.NOT_DISCONNECTED));
 
-        emergencyStateTracker.endSms(TEST_SMS_ID, getTestEmergencyNumber());
+        emergencyStateTracker.endSms(TEST_SMS_ID, true);
 
         assertTrue(emergencyStateTracker.isInEmergencyMode());
 
@@ -1400,7 +1400,7 @@
         assertTrue(emergencyStateTracker.isInEcm());
         assertFalse(emergencyStateTracker.isInEmergencyCall());
 
-        emergencyStateTracker.endSms(TEST_SMS_ID, getTestEmergencyNumber());
+        emergencyStateTracker.endSms(TEST_SMS_ID, true);
         processAllMessages();
 
         verify(phone0).setEmergencyMode(eq(MODE_EMERGENCY_CALLBACK), any(Message.class));
@@ -1455,7 +1455,7 @@
 
         emergencyStateTracker.onEmergencyTransportChanged(
                 EmergencyStateTracker.EMERGENCY_TYPE_SMS, MODE_EMERGENCY_WWAN);
-        emergencyStateTracker.endSms(TEST_SMS_ID, getTestEmergencyNumber());
+        emergencyStateTracker.endSms(TEST_SMS_ID, true);
         processAllMessages();
 
         // Enter emergency callback mode and emergency mode changed by SMS end.
@@ -1502,7 +1502,7 @@
         assertEquals(future.getNow(DisconnectCause.ERROR_UNSPECIFIED),
                 Integer.valueOf(DisconnectCause.NOT_DISCONNECTED));
 
-        emergencyStateTracker.endSms(TEST_SMS_ID, getTestEmergencyNumber());
+        emergencyStateTracker.endSms(TEST_SMS_ID, true);
 
         assertTrue(emergencyStateTracker.isInEmergencyMode());
 
diff --git a/tests/telephonytests/src/com/android/internal/telephony/metrics/ImsStatsTest.java b/tests/telephonytests/src/com/android/internal/telephony/metrics/ImsStatsTest.java
index 504782b..7c7c5b2 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/metrics/ImsStatsTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/metrics/ImsStatsTest.java
@@ -308,12 +308,73 @@
         mImsStats.onImsCapabilitiesChanged(
                 REGISTRATION_TECH_LTE, new MmTelCapabilities(CAPABILITY_TYPE_ALL));
 
+        mImsStats.onImsUnregistered(
+                new ImsReasonInfo(ImsReasonInfo.CODE_REGISTRATION_ERROR, 999, "Timeout"));
+
         mImsStats.incTimeMillis(2000L);
         mImsStats.conclude();
 
-        // No atom should be generated
+        ArgumentCaptor<ImsRegistrationTermination> terminationCaptor =
+                ArgumentCaptor.forClass(ImsRegistrationTermination.class);
+        verify(mPersistAtomsStorage).addImsRegistrationTermination(terminationCaptor.capture());
+        ImsRegistrationTermination termination = terminationCaptor.getValue();
+        assertEquals(CARRIER1_ID, termination.carrierId);
+        assertFalse(termination.isMultiSim);
+        assertEquals(TelephonyManager.NETWORK_TYPE_LTE, termination.ratAtEnd);
+        assertTrue(termination.setupFailed);
+        assertEquals(ImsReasonInfo.CODE_REGISTRATION_ERROR, termination.reasonCode);
+        assertEquals(999, termination.extraCode);
+        assertEquals("Timeout", termination.extraMessage);
+
+        // Registering duration should be counted
+        ArgumentCaptor<ImsRegistrationStats> statsCaptor =
+                ArgumentCaptor.forClass(ImsRegistrationStats.class);
+        verify(mPersistAtomsStorage).addImsRegistrationStats(statsCaptor.capture());
+        ImsRegistrationStats stats = statsCaptor.getValue();
+        assertEquals(CARRIER1_ID, stats.carrierId);
+        assertEquals(0, stats.simSlotIndex);
+        assertEquals(TelephonyManager.NETWORK_TYPE_UNKNOWN, stats.rat);
+        assertEquals(2000L, stats.unregisteredMillis);
+        verifyNoMoreInteractions(mPersistAtomsStorage);
+    }
+
+    @Test
+    @SmallTest
+    public void conclude_registering() throws Exception {
+        // IMS over LTE
+        mImsStats.onSetFeatureResponse(
+                CAPABILITY_TYPE_VOICE,
+                REGISTRATION_TECH_LTE,
+                ProvisioningManager.PROVISIONING_VALUE_ENABLED);
+        mImsStats.onSetFeatureResponse(
+                CAPABILITY_TYPE_VIDEO,
+                REGISTRATION_TECH_LTE,
+                ProvisioningManager.PROVISIONING_VALUE_ENABLED);
+        mImsStats.onSetFeatureResponse(
+                CAPABILITY_TYPE_UT,
+                REGISTRATION_TECH_LTE,
+                ProvisioningManager.PROVISIONING_VALUE_ENABLED);
+        mImsStats.onSetFeatureResponse(
+                CAPABILITY_TYPE_SMS,
+                REGISTRATION_TECH_LTE,
+                ProvisioningManager.PROVISIONING_VALUE_ENABLED);
+        mImsStats.onImsCapabilitiesChanged(
+                REGISTRATION_TECH_LTE, new MmTelCapabilities(CAPABILITY_TYPE_ALL));
+
+        mImsStats.onImsRegistering(TRANSPORT_TYPE_WLAN);
+
+        mImsStats.incTimeMillis(2000L);
+        mImsStats.conclude();
+
+        // Registering duration should be counted
         ArgumentCaptor<ImsRegistrationStats> captor =
                 ArgumentCaptor.forClass(ImsRegistrationStats.class);
+        verify(mPersistAtomsStorage).addImsRegistrationStats(captor.capture());
+        ImsRegistrationStats stats = captor.getValue();
+        assertEquals(CARRIER1_ID, stats.carrierId);
+        assertEquals(0, stats.simSlotIndex);
+        assertEquals(TelephonyManager.NETWORK_TYPE_IWLAN, stats.rat);
+        assertEquals(2000L, stats.registeringMillis);
         verifyNoMoreInteractions(mPersistAtomsStorage);
     }
 
@@ -510,6 +571,57 @@
 
     @Test
     @SmallTest
+    public void onImsRegistered_afterImsRegistering() throws Exception {
+        mImsStats.onImsRegistering(TRANSPORT_TYPE_WWAN);
+        mImsStats.incTimeMillis(2000L);
+        mImsStats.onImsRegistered(TRANSPORT_TYPE_WWAN);
+
+        // Registering duration should be counted
+        ArgumentCaptor<ImsRegistrationStats> captor =
+                ArgumentCaptor.forClass(ImsRegistrationStats.class);
+        verify(mPersistAtomsStorage).addImsRegistrationStats(captor.capture());
+        ImsRegistrationStats stats = captor.getValue();
+        assertEquals(CARRIER1_ID, stats.carrierId);
+        assertEquals(0, stats.simSlotIndex);
+        assertEquals(TelephonyManager.NETWORK_TYPE_LTE, stats.rat);
+        assertEquals(0L, stats.registeredMillis);
+        assertEquals(2000L, stats.registeringMillis);
+    }
+
+    @Test
+    @SmallTest
+    public void onImsRegistering_afterImsUnregistered() throws Exception {
+        mImsStats.onImsUnregistered(
+                new ImsReasonInfo(ImsReasonInfo.CODE_REGISTRATION_ERROR, 999, "Timeout"));
+        mImsStats.incTimeMillis(2000L);
+        mImsStats.onImsRegistering(TRANSPORT_TYPE_WWAN);
+
+        // Atom with termination info should be generated
+        ArgumentCaptor<ImsRegistrationTermination> terminationCaptor =
+                ArgumentCaptor.forClass(ImsRegistrationTermination.class);
+        verify(mPersistAtomsStorage).addImsRegistrationTermination(terminationCaptor.capture());
+        ImsRegistrationTermination termination = terminationCaptor.getValue();
+        assertEquals(CARRIER1_ID, termination.carrierId);
+        assertFalse(termination.isMultiSim);
+        assertEquals(TelephonyManager.NETWORK_TYPE_LTE, termination.ratAtEnd);
+        assertTrue(termination.setupFailed);
+        assertEquals(ImsReasonInfo.CODE_REGISTRATION_ERROR, termination.reasonCode);
+        assertEquals(999, termination.extraCode);
+        assertEquals("Timeout", termination.extraMessage);
+
+        ArgumentCaptor<ImsRegistrationStats> statsCaptor =
+                ArgumentCaptor.forClass(ImsRegistrationStats.class);
+        verify(mPersistAtomsStorage).addImsRegistrationStats(statsCaptor.capture());
+        ImsRegistrationStats stats = statsCaptor.getValue();
+        assertEquals(CARRIER1_ID, stats.carrierId);
+        assertEquals(0, stats.simSlotIndex);
+        assertEquals(TelephonyManager.NETWORK_TYPE_UNKNOWN, stats.rat);
+        assertEquals(2000L, stats.unregisteredMillis);
+        verifyNoMoreInteractions(mPersistAtomsStorage);
+    }
+
+    @Test
+    @SmallTest
     public void onImsUnregistered_setupFailure() throws Exception {
         mImsStats.onImsUnregistered(
                 new ImsReasonInfo(ImsReasonInfo.CODE_REGISTRATION_ERROR, 999, "Timeout"));
@@ -521,7 +633,7 @@
         ImsRegistrationTermination termination = captor.getValue();
         assertEquals(CARRIER1_ID, termination.carrierId);
         assertFalse(termination.isMultiSim);
-        assertEquals(TelephonyManager.NETWORK_TYPE_UNKNOWN, termination.ratAtEnd);
+        assertEquals(TelephonyManager.NETWORK_TYPE_LTE, termination.ratAtEnd);
         assertTrue(termination.setupFailed);
         assertEquals(ImsReasonInfo.CODE_REGISTRATION_ERROR, termination.reasonCode);
         assertEquals(999, termination.extraCode);
@@ -532,16 +644,26 @@
     @Test
     @SmallTest
     public void onImsUnregistered_setupFailureWithProgress() throws Exception {
-        mImsStats.onImsRegistering(REGISTRATION_TECH_LTE);
+        mImsStats.onImsRegistering(TRANSPORT_TYPE_WWAN);
         mImsStats.incTimeMillis(2000L);
         mImsStats.onImsUnregistered(
                 new ImsReasonInfo(ImsReasonInfo.CODE_REGISTRATION_ERROR, 999, "Timeout"));
 
         // Atom with termination info should be generated
-        ArgumentCaptor<ImsRegistrationTermination> captor =
+        ArgumentCaptor<ImsRegistrationStats> statsCaptor =
+                ArgumentCaptor.forClass(ImsRegistrationStats.class);
+        verify(mPersistAtomsStorage).addImsRegistrationStats(statsCaptor.capture());
+        ImsRegistrationStats stats = statsCaptor.getValue();
+        assertEquals(CARRIER1_ID, stats.carrierId);
+        assertEquals(0, stats.simSlotIndex);
+        assertEquals(TelephonyManager.NETWORK_TYPE_LTE, stats.rat);
+        assertEquals(0L, stats.registeredMillis);
+        assertEquals(2000L, stats.registeringMillis);
+
+        ArgumentCaptor<ImsRegistrationTermination> terminationCaptor =
                 ArgumentCaptor.forClass(ImsRegistrationTermination.class);
-        verify(mPersistAtomsStorage).addImsRegistrationTermination(captor.capture());
-        ImsRegistrationTermination termination = captor.getValue();
+        verify(mPersistAtomsStorage).addImsRegistrationTermination(terminationCaptor.capture());
+        ImsRegistrationTermination termination = terminationCaptor.getValue();
         assertEquals(CARRIER1_ID, termination.carrierId);
         assertFalse(termination.isMultiSim);
         assertEquals(TelephonyManager.NETWORK_TYPE_LTE, termination.ratAtEnd);
@@ -604,7 +726,7 @@
         ImsRegistrationTermination termination = captor.getValue();
         assertEquals(CARRIER1_ID, termination.carrierId);
         assertFalse(termination.isMultiSim);
-        assertEquals(TelephonyManager.NETWORK_TYPE_UNKNOWN, termination.ratAtEnd);
+        assertEquals(TelephonyManager.NETWORK_TYPE_LTE, termination.ratAtEnd);
         assertTrue(termination.setupFailed);
         assertEquals(ImsReasonInfo.CODE_REGISTRATION_ERROR, termination.reasonCode);
         assertEquals(0, termination.extraCode);
@@ -630,7 +752,7 @@
         ImsRegistrationTermination termination = captor.getValue();
         assertEquals(CARRIER1_ID, termination.carrierId);
         assertFalse(termination.isMultiSim);
-        assertEquals(TelephonyManager.NETWORK_TYPE_UNKNOWN, termination.ratAtEnd);
+        assertEquals(TelephonyManager.NETWORK_TYPE_LTE, termination.ratAtEnd);
         assertTrue(termination.setupFailed);
         assertEquals(ImsReasonInfo.CODE_REGISTRATION_ERROR, termination.reasonCode);
         assertEquals(0, termination.extraCode);
diff --git a/tests/telephonytests/src/com/android/internal/telephony/satellite/DatagramDispatcherTest.java b/tests/telephonytests/src/com/android/internal/telephony/satellite/DatagramDispatcherTest.java
index e80978d..0b8d658 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/satellite/DatagramDispatcherTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/satellite/DatagramDispatcherTest.java
@@ -130,7 +130,6 @@
 
     @Test
     public void testSendSatelliteDatagram_usingSatelliteModemInterface_success() throws  Exception {
-        doReturn(true).when(mMockSatelliteModemInterface).isSatelliteServiceSupported();
         doAnswer(invocation -> {
             Message message = (Message) invocation.getArguments()[3];
 
@@ -243,7 +242,6 @@
 
     @Test
     public void testSendSatelliteDatagram_usingSatelliteModemInterface_failure() throws  Exception {
-        doReturn(true).when(mMockSatelliteModemInterface).isSatelliteServiceSupported();
         doAnswer(invocation -> {
             Message message = (Message) invocation.getArguments()[3];
 
@@ -282,129 +280,17 @@
     }
 
     @Test
-    public void testSendSatelliteDatagram_usingCommandsInterface_phoneNull() throws Exception {
-        doReturn(false).when(mMockSatelliteModemInterface).isSatelliteServiceSupported();
-        replaceInstance(PhoneFactory.class, "sPhones", null, new Phone[] {null});
-
-        mDatagramDispatcherUT.sendSatelliteDatagram(SUB_ID, DATAGRAM_TYPE1, mDatagram,
-                true, mResultListener::offer);
-
-        processAllMessages();
-
-        mInOrder.verify(mMockDatagramController).needsWaitingForSatelliteConnected();
-        mInOrder.verify(mMockDatagramController).isPollingInIdleState();
-        mInOrder.verify(mMockDatagramController)
-                .updateSendStatus(eq(SUB_ID),
-                        eq(SatelliteManager.SATELLITE_DATAGRAM_TRANSFER_STATE_SENDING), eq(1),
-                        eq(SatelliteManager.SATELLITE_RESULT_SUCCESS));
-        mInOrder.verify(mMockDatagramController)
-                .updateSendStatus(eq(SUB_ID),
-                        eq(SatelliteManager.SATELLITE_DATAGRAM_TRANSFER_STATE_SEND_FAILED), eq(0),
-                        eq(SatelliteManager.SATELLITE_RESULT_INVALID_TELEPHONY_STATE));
-        mInOrder.verify(mMockDatagramController)
-                .updateSendStatus(eq(SUB_ID),
-                        eq(SatelliteManager.SATELLITE_DATAGRAM_TRANSFER_STATE_IDLE), eq(0),
-                        eq(SatelliteManager.SATELLITE_RESULT_SUCCESS));
-        verifyNoMoreInteractions(mMockDatagramController);
-
-        assertThat(mResultListener.peek())
-                .isEqualTo(SatelliteManager.SATELLITE_RESULT_INVALID_TELEPHONY_STATE);
-    }
-
-    @Test
-    public void testSendSatelliteDatagram_usingCommandsInterface_success() throws  Exception {
-        doReturn(false).when(mMockSatelliteModemInterface).isSatelliteServiceSupported();
-        replaceInstance(PhoneFactory.class, "sPhones", null, new Phone[] {mPhone});
+    public void testSendSatelliteDatagram_DemoMode_Align_Success() throws Exception {
         doAnswer(invocation -> {
-            Message message = (Message) invocation.getArguments()[0];
-
-            mDatagramDispatcherUT.obtainMessage(2 /*EVENT_SEND_SATELLITE_DATAGRAM_DONE*/,
+            Message message = (Message) invocation.getArguments()[3];
+            mTestDemoModeDatagramDispatcher.obtainMessage(2 /*EVENT_SEND_SATELLITE_DATAGRAM_DONE*/,
                             new AsyncResult(message.obj, null, null))
                     .sendToTarget();
             return null;
-        }).when(mPhone).sendSatelliteDatagram(any(Message.class), any(SatelliteDatagram.class),
-                anyBoolean());
-
-        mDatagramDispatcherUT.sendSatelliteDatagram(SUB_ID, DATAGRAM_TYPE2, mDatagram,
-                true, mResultListener::offer);
-
-        processAllMessages();
-
-        mInOrder.verify(mMockDatagramController).needsWaitingForSatelliteConnected();
-        mInOrder.verify(mMockDatagramController).isPollingInIdleState();
-        mInOrder.verify(mMockDatagramController)
-                .updateSendStatus(eq(SUB_ID),
-                        eq(SatelliteManager.SATELLITE_DATAGRAM_TRANSFER_STATE_SENDING), eq(1),
-                        eq(SatelliteManager.SATELLITE_RESULT_SUCCESS));
-        mInOrder.verify(mMockDatagramController)
-                .updateSendStatus(eq(SUB_ID),
-                        eq(SatelliteManager.SATELLITE_DATAGRAM_TRANSFER_STATE_SEND_SUCCESS), eq(0),
-                        eq(SatelliteManager.SATELLITE_RESULT_SUCCESS));
-        mInOrder.verify(mMockDatagramController)
-                .updateSendStatus(eq(SUB_ID),
-                        eq(SatelliteManager.SATELLITE_DATAGRAM_TRANSFER_STATE_IDLE), eq(0),
-                        eq(SatelliteManager.SATELLITE_RESULT_SUCCESS));
-        verifyNoMoreInteractions(mMockDatagramController);
-
-        assertThat(mResultListener.peek()).isEqualTo(SatelliteManager.SATELLITE_RESULT_SUCCESS);
-    }
-
-    @Test
-    public void testSendSatelliteDatagram_usingCommandsInterface_failure() throws  Exception {
-        doReturn(false).when(mMockSatelliteModemInterface).isSatelliteServiceSupported();
-        replaceInstance(PhoneFactory.class, "sPhones", null, new Phone[] {mPhone});
-        doAnswer(invocation -> {
-            Message message = (Message) invocation.getArguments()[0];
-
-            mDatagramDispatcherUT.obtainMessage(2 /*EVENT_SEND_SATELLITE_DATAGRAM_DONE*/,
-                            new AsyncResult(message.obj, null,
-                                    new SatelliteManager.SatelliteException(
-                                            SatelliteManager.SATELLITE_RESULT_SERVICE_ERROR)))
-                    .sendToTarget();
-            return null;
-        }).when(mPhone).sendSatelliteDatagram(any(Message.class), any(SatelliteDatagram.class),
-                anyBoolean());
-
-        mDatagramDispatcherUT.sendSatelliteDatagram(SUB_ID, DATAGRAM_TYPE1, mDatagram,
-                true, mResultListener::offer);
-
-        processAllMessages();
-
-        mInOrder.verify(mMockDatagramController).needsWaitingForSatelliteConnected();
-        mInOrder.verify(mMockDatagramController).isPollingInIdleState();
-        mInOrder.verify(mMockDatagramController)
-                .updateSendStatus(eq(SUB_ID),
-                        eq(SatelliteManager.SATELLITE_DATAGRAM_TRANSFER_STATE_SENDING), eq(1),
-                        eq(SatelliteManager.SATELLITE_RESULT_SUCCESS));
-        mInOrder.verify(mMockDatagramController)
-                .updateSendStatus(eq(SUB_ID),
-                        eq(SatelliteManager.SATELLITE_DATAGRAM_TRANSFER_STATE_SEND_FAILED), eq(0),
-                        eq(SatelliteManager.SATELLITE_RESULT_SERVICE_ERROR));
-        mInOrder.verify(mMockDatagramController)
-                .updateSendStatus(eq(SUB_ID),
-                        eq(SatelliteManager.SATELLITE_DATAGRAM_TRANSFER_STATE_IDLE), eq(0),
-                        eq(SatelliteManager.SATELLITE_RESULT_SUCCESS));
-        verifyNoMoreInteractions(mMockDatagramController);
-
-        assertThat(mResultListener.peek()).isEqualTo(
-                SatelliteManager.SATELLITE_RESULT_SERVICE_ERROR);
-    }
-
-    @Test
-    public void testSendSatelliteDatagram_DemoMode_Align_Success() throws Exception {
+        }).when(mMockSatelliteModemInterface).sendSatelliteDatagram(any(SatelliteDatagram.class),
+                anyBoolean(), anyBoolean(), any(Message.class));
         mTestDemoModeDatagramDispatcher.setDemoMode(true);
         mTestDemoModeDatagramDispatcher.setDeviceAlignedWithSatellite(true);
-        doReturn(false).when(mMockSatelliteModemInterface).isSatelliteServiceSupported();
-        replaceInstance(PhoneFactory.class, "sPhones", null, new Phone[] {mPhone});
-        doAnswer(invocation -> {
-            Message message = (Message) invocation.getArguments()[0];
-
-            mDatagramDispatcherUT.obtainMessage(2 /*EVENT_SEND_SATELLITE_DATAGRAM_DONE*/,
-                            new AsyncResult(message.obj, null, null))
-                    .sendToTarget();
-            return null;
-        }).when(mPhone).sendSatelliteDatagram(any(Message.class), any(SatelliteDatagram.class),
-                anyBoolean());
 
         mTestDemoModeDatagramDispatcher.sendSatelliteDatagram(SUB_ID, DATAGRAM_TYPE1, mDatagram,
                 true, mResultListener::offer);
@@ -430,22 +316,19 @@
 
     @Test
     public void testSendSatelliteDatagram_DemoMode_Align_failed() throws Exception {
-        long previousTimer = mTestDemoModeDatagramDispatcher.getSatelliteAlignedTimeoutDuration();
-        mTestDemoModeDatagramDispatcher.setDemoMode(true);
-        mTestDemoModeDatagramDispatcher.setDuration(TEST_EXPIRE_TIMER_SATELLITE_ALIGN);
-        mTestDemoModeDatagramDispatcher.setDeviceAlignedWithSatellite(false);
-
-        doReturn(false).when(mMockSatelliteModemInterface).isSatelliteServiceSupported();
-        replaceInstance(PhoneFactory.class, "sPhones", null, new Phone[] {mPhone});
         doAnswer(invocation -> {
-            Message message = (Message) invocation.getArguments()[0];
-
+            Message message = (Message) invocation.getArguments()[3];
             mTestDemoModeDatagramDispatcher.obtainMessage(2 /*EVENT_SEND_SATELLITE_DATAGRAM_DONE*/,
                             new AsyncResult(message.obj, null, null))
                     .sendToTarget();
             return null;
-        }).when(mPhone).sendSatelliteDatagram(any(Message.class), any(SatelliteDatagram.class),
-                anyBoolean());
+        }).when(mMockSatelliteModemInterface).sendSatelliteDatagram(any(SatelliteDatagram.class),
+                anyBoolean(), anyBoolean(), any(Message.class));
+
+        long previousTimer = mTestDemoModeDatagramDispatcher.getSatelliteAlignedTimeoutDuration();
+        mTestDemoModeDatagramDispatcher.setDemoMode(true);
+        mTestDemoModeDatagramDispatcher.setDuration(TEST_EXPIRE_TIMER_SATELLITE_ALIGN);
+        mTestDemoModeDatagramDispatcher.setDeviceAlignedWithSatellite(false);
 
         mTestDemoModeDatagramDispatcher.sendSatelliteDatagram(SUB_ID, DATAGRAM_TYPE1, mDatagram,
                 true, mResultListener::offer);
@@ -472,18 +355,16 @@
 
     @Test
     public void testSendSatelliteDatagram_DemoMode_data_type_location_sharing() throws Exception {
-        mTestDemoModeDatagramDispatcher.setDemoMode(true);
-        doReturn(false).when(mMockSatelliteModemInterface).isSatelliteServiceSupported();
-        replaceInstance(PhoneFactory.class, "sPhones", null, new Phone[] {mPhone});
         doAnswer(invocation -> {
-            Message message = (Message) invocation.getArguments()[0];
-
+            Message message = (Message) invocation.getArguments()[3];
             mDatagramDispatcherUT.obtainMessage(2 /*EVENT_SEND_SATELLITE_DATAGRAM_DONE*/,
                             new AsyncResult(message.obj, null, null))
                     .sendToTarget();
             return null;
-        }).when(mPhone).sendSatelliteDatagram(any(Message.class), any(SatelliteDatagram.class),
-                anyBoolean());
+        }).when(mMockSatelliteModemInterface).sendSatelliteDatagram(any(SatelliteDatagram.class),
+                anyBoolean(), anyBoolean(), any(Message.class));
+        mTestDemoModeDatagramDispatcher.setDemoMode(true);
+        replaceInstance(PhoneFactory.class, "sPhones", null, new Phone[] {mPhone});
 
         mTestDemoModeDatagramDispatcher.sendSatelliteDatagram(SUB_ID, DATAGRAM_TYPE2, mDatagram,
                 true, mResultListener::offer);
diff --git a/tests/telephonytests/src/com/android/internal/telephony/satellite/DatagramReceiverTest.java b/tests/telephonytests/src/com/android/internal/telephony/satellite/DatagramReceiverTest.java
index 9fe85ef..3578707 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/satellite/DatagramReceiverTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/satellite/DatagramReceiverTest.java
@@ -54,8 +54,6 @@
 import android.util.Pair;
 
 import com.android.internal.telephony.IVoidConsumer;
-import com.android.internal.telephony.Phone;
-import com.android.internal.telephony.PhoneFactory;
 import com.android.internal.telephony.TelephonyTest;
 import com.android.internal.telephony.satellite.metrics.ControllerMetricsStats;
 
@@ -255,92 +253,6 @@
     }
 
     @Test
-    public void testPollPendingSatelliteDatagrams_usingCommandsInterface_phoneNull()
-            throws Exception {
-        doReturn(false).when(mMockSatelliteModemInterface).isSatelliteServiceSupported();
-        replaceInstance(PhoneFactory.class, "sPhones", null, new Phone[] {null});
-
-        mDatagramReceiverUT.pollPendingSatelliteDatagrams(SUB_ID, mResultListener::offer);
-
-        processAllMessages();
-
-        mInOrder.verify(mMockDatagramController)
-                .updateReceiveStatus(eq(SUB_ID),
-                        eq(SatelliteManager.SATELLITE_DATAGRAM_TRANSFER_STATE_RECEIVING), eq(0),
-                        eq(SatelliteManager.SATELLITE_RESULT_SUCCESS));
-        mInOrder.verify(mMockDatagramController)
-                .updateReceiveStatus(eq(SUB_ID),
-                        eq(SatelliteManager.SATELLITE_DATAGRAM_TRANSFER_STATE_RECEIVE_FAILED),
-                        eq(0), eq(SatelliteManager.SATELLITE_RESULT_INVALID_TELEPHONY_STATE));
-        mInOrder.verify(mMockDatagramController)
-                .updateReceiveStatus(eq(SUB_ID),
-                        eq(SatelliteManager.SATELLITE_DATAGRAM_TRANSFER_STATE_IDLE),
-                        eq(0), eq(SatelliteManager.SATELLITE_RESULT_SUCCESS));
-
-        assertThat(mResultListener.peek())
-                .isEqualTo(SatelliteManager.SATELLITE_RESULT_INVALID_TELEPHONY_STATE);
-    }
-
-    @Test
-    public void testPollPendingSatelliteDatagrams_usingCommandsInterface_success()
-            throws Exception {
-        doReturn(false).when(mMockSatelliteModemInterface).isSatelliteServiceSupported();
-        replaceInstance(PhoneFactory.class, "sPhones", null, new Phone[] {mPhone});
-        doAnswer(invocation -> {
-            Message message = (Message) invocation.getArguments()[0];
-
-            mDatagramReceiverUT.obtainMessage(2 /*EVENT_POLL_PENDING_SATELLITE_DATAGRAMS_DONE*/,
-                            new AsyncResult(message.obj, null, null))
-                    .sendToTarget();
-            return null;
-        }).when(mPhone).pollPendingSatelliteDatagrams(any(Message.class));
-
-        mDatagramReceiverUT.pollPendingSatelliteDatagrams(SUB_ID, mResultListener::offer);
-
-        processAllMessages();
-
-        mInOrder.verify(mMockDatagramController)
-                .updateReceiveStatus(eq(SUB_ID),
-                        eq(SatelliteManager.SATELLITE_DATAGRAM_TRANSFER_STATE_RECEIVING), eq(0),
-                        eq(SatelliteManager.SATELLITE_RESULT_SUCCESS));
-
-        assertThat(mResultListener.peek()).isEqualTo(SatelliteManager.SATELLITE_RESULT_SUCCESS);
-    }
-
-    @Test
-    public void testPollPendingSatelliteDatagrams_usingCommandsInterface_failure()
-            throws Exception {
-        doReturn(false).when(mMockSatelliteModemInterface).isSatelliteServiceSupported();
-        replaceInstance(PhoneFactory.class, "sPhones", null, new Phone[] {mPhone});
-        doAnswer(invocation -> {
-            Message message = (Message) invocation.getArguments()[0];
-
-            mDatagramReceiverUT.obtainMessage(2 /*EVENT_POLL_PENDING_SATELLITE_DATAGRAMS_DONE*/,
-                            new AsyncResult(message.obj, null,
-                                    new SatelliteManager.SatelliteException(
-                                            SatelliteManager.SATELLITE_RESULT_SERVICE_ERROR)))
-                    .sendToTarget();
-            return null;
-        }).when(mPhone).pollPendingSatelliteDatagrams(any(Message.class));
-
-        mDatagramReceiverUT.pollPendingSatelliteDatagrams(SUB_ID, mResultListener::offer);
-
-        processAllMessages();
-
-        mInOrder.verify(mMockDatagramController)
-                .updateReceiveStatus(eq(SUB_ID),
-                        eq(SatelliteManager.SATELLITE_DATAGRAM_TRANSFER_STATE_RECEIVING), eq(0),
-                        eq(SatelliteManager.SATELLITE_RESULT_SUCCESS));
-        mInOrder.verify(mMockDatagramController)
-                .updateReceiveStatus(eq(SUB_ID),
-                        eq(SatelliteManager.SATELLITE_DATAGRAM_TRANSFER_STATE_RECEIVE_FAILED),
-                        eq(0), eq(SatelliteManager.SATELLITE_RESULT_SERVICE_ERROR));
-
-        assertThat(mResultListener.peek()).isEqualTo(
-                SatelliteManager.SATELLITE_RESULT_SERVICE_ERROR);
-    }
-
-    @Test
     public void testSatelliteDatagramReceived_receiveNone() {
         mSatelliteDatagramListenerHandler.obtainMessage(1 /*EVENT_SATELLITE_DATAGRAM_RECEIVED*/,
                 new AsyncResult(null, new Pair<>(null, 0), null))
diff --git a/tests/telephonytests/src/com/android/internal/telephony/satellite/PointingAppControllerTest.java b/tests/telephonytests/src/com/android/internal/telephony/satellite/PointingAppControllerTest.java
index 96dcd85..3917a32 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/satellite/PointingAppControllerTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/satellite/PointingAppControllerTest.java
@@ -251,13 +251,6 @@
             AsyncResult.forMessage(message, null, exception);
             message.sendToTarget();
             return null;
-        }).when(mPhone).startSatellitePositionUpdates(any(Message.class));
-
-        doAnswer(invocation -> {
-            Message message = (Message) invocation.getArguments()[0];
-            AsyncResult.forMessage(message, null, exception);
-            message.sendToTarget();
-            return null;
         }).when(mMockSatelliteModemInterface).startSendingSatellitePointingInfo(any(Message.class));
     }
 
@@ -270,54 +263,21 @@
             AsyncResult.forMessage(message, null, exception);
             message.sendToTarget();
             return null;
-        }).when(mPhone).stopSatellitePositionUpdates(any(Message.class));
-
-        doAnswer(invocation -> {
-            Message message = (Message) invocation.getArguments()[0];
-            AsyncResult.forMessage(message, null, exception);
-            message.sendToTarget();
-            return null;
         }).when(mMockSatelliteModemInterface).stopSendingSatellitePointingInfo(any(Message.class));
     }
 
     @Test
-    public void testStartSatelliteTransmissionUpdates_CommandInterface()
-            throws Exception {
-        doReturn(false).when(mMockSatelliteModemInterface).isSatelliteServiceSupported();
-        Message testMessage = mTestSatelliteControllerHandler
-                .obtainMessage(EVENT_START_SATELLITE_TRANSMISSION_UPDATES_DONE, null);
-        setUpResponseForStartTransmissionUpdates(SatelliteManager.SATELLITE_RESULT_SUCCESS);
-        mPointingAppController.startSatelliteTransmissionUpdates(testMessage, mPhone);
-
-        processAllMessages();
-
-        verify(mMockSatelliteModemInterface, never())
-                .startSendingSatellitePointingInfo(eq(testMessage));
-
-        verify(mPhone)
-                .startSatellitePositionUpdates(eq(testMessage));
-
-        assertEquals(SatelliteManager.SATELLITE_RESULT_SUCCESS, mResultCode);
-
-        assertTrue(mPointingAppController.getStartedSatelliteTransmissionUpdates());
-    }
-
-    @Test
     public void testStartSatelliteTransmissionUpdates_success()
             throws Exception {
-        doReturn(true).when(mMockSatelliteModemInterface).isSatelliteServiceSupported();
         mPointingAppController.setStartedSatelliteTransmissionUpdates(false);
         Message testMessage = mTestSatelliteControllerHandler
                 .obtainMessage(EVENT_START_SATELLITE_TRANSMISSION_UPDATES_DONE, null);
         setUpResponseForStartTransmissionUpdates(SatelliteManager.SATELLITE_RESULT_SUCCESS);
-        mPointingAppController.startSatelliteTransmissionUpdates(testMessage, mPhone);
+        mPointingAppController.startSatelliteTransmissionUpdates(testMessage);
 
         verify(mMockSatelliteModemInterface)
                 .startSendingSatellitePointingInfo(eq(testMessage));
 
-        verify(mPhone, never())
-                .startSatellitePositionUpdates(eq(testMessage));
-
         processAllMessages();
 
 
@@ -326,90 +286,24 @@
     }
 
     @Test
-    public void testStartSatelliteTransmissionUpdates_phoneNull()
-            throws Exception {
-        doReturn(false).when(mMockSatelliteModemInterface).isSatelliteServiceSupported();
-        mPointingAppController.setStartedSatelliteTransmissionUpdates(false);
-        Message testMessage = mTestSatelliteControllerHandler
-                .obtainMessage(EVENT_START_SATELLITE_TRANSMISSION_UPDATES_DONE, null);
-
-        mPointingAppController.startSatelliteTransmissionUpdates(testMessage, null);
-        processAllMessages();
-        verify(mMockSatelliteModemInterface, never())
-                .startSendingSatellitePointingInfo(eq(testMessage));
-
-        verify(mPhone, never())
-                .startSatellitePositionUpdates(eq(testMessage));
-
-        assertFalse(mPointingAppController.getStartedSatelliteTransmissionUpdates());
-
-        assertEquals(SatelliteManager.SATELLITE_RESULT_INVALID_TELEPHONY_STATE, mResultCode);
-    }
-
-    @Test
-    public void testStopSatelliteTransmissionUpdates_CommandInterface()
-            throws Exception {
-        doReturn(false).when(mMockSatelliteModemInterface).isSatelliteServiceSupported();
-        setUpResponseForStopTransmissionUpdates(SatelliteManager.SATELLITE_RESULT_SUCCESS);
-        Message testMessage = mTestSatelliteControllerHandler
-                .obtainMessage(EVENT_STOP_SATELLITE_TRANSMISSION_UPDATES_DONE, null);
-        mPointingAppController.stopSatelliteTransmissionUpdates(testMessage, mPhone);
-
-        processAllMessages();
-
-        verify(mMockSatelliteModemInterface, never())
-                .stopSendingSatellitePointingInfo(eq(testMessage));
-
-        verify(mPhone)
-                .stopSatellitePositionUpdates(eq(testMessage));
-
-        assertFalse(mPointingAppController.getStartedSatelliteTransmissionUpdates());
-
-        assertEquals(SatelliteManager.SATELLITE_RESULT_SUCCESS, mResultCode);
-    }
-
-    @Test
     public void testStopSatelliteTransmissionUpdates_success()
             throws Exception {
         doReturn(true).when(mMockSatelliteModemInterface).isSatelliteServiceSupported();
         setUpResponseForStopTransmissionUpdates(SatelliteManager.SATELLITE_RESULT_SUCCESS);
         Message testMessage = mTestSatelliteControllerHandler
                 .obtainMessage(EVENT_STOP_SATELLITE_TRANSMISSION_UPDATES_DONE, null);
-        mPointingAppController.stopSatelliteTransmissionUpdates(testMessage, mPhone);
+        mPointingAppController.stopSatelliteTransmissionUpdates(testMessage);
 
         processAllMessages();
 
         verify(mMockSatelliteModemInterface)
                 .stopSendingSatellitePointingInfo(eq(testMessage));
 
-        verify(mPhone, never())
-                .stopSatellitePositionUpdates(eq(testMessage));
-
         assertFalse(mPointingAppController.getStartedSatelliteTransmissionUpdates());
         assertEquals(SatelliteManager.SATELLITE_RESULT_SUCCESS, mResultCode);
     }
 
     @Test
-    public void testStopSatellitePointingInfo_phoneNull()
-            throws Exception {
-        doReturn(false).when(mMockSatelliteModemInterface).isSatelliteServiceSupported();
-        Message testMessage = mTestSatelliteControllerHandler
-                .obtainMessage(EVENT_STOP_SATELLITE_TRANSMISSION_UPDATES_DONE, null);
-        mPointingAppController.stopSatelliteTransmissionUpdates(testMessage, null);
-
-        processAllMessages();
-
-        verify(mMockSatelliteModemInterface, never())
-                .stopSendingSatellitePointingInfo(eq(testMessage));
-
-        verify(mPhone, never())
-                .stopSatellitePositionUpdates(eq(testMessage));
-
-        assertEquals(SatelliteManager.SATELLITE_RESULT_INVALID_TELEPHONY_STATE, mResultCode);
-
-    }
-
-    @Test
     public void testStartPointingUI() throws Exception {
         ArgumentCaptor<Intent> startedIntentCaptor = ArgumentCaptor.forClass(Intent.class);
         mPointingAppController.startPointingUI(true);
@@ -451,7 +345,7 @@
     @Test
     public void testUpdateSendDatagramTransferState() throws Exception {
         mPointingAppController.registerForSatelliteTransmissionUpdates(SUB_ID,
-                mSatelliteTransmissionUpdateCallback, mPhone);
+                mSatelliteTransmissionUpdateCallback);
         mPointingAppController.updateSendDatagramTransferState(SUB_ID,
                 SatelliteManager.SATELLITE_DATAGRAM_TRANSFER_STATE_SEND_SUCCESS, 1,
                 SatelliteManager.SATELLITE_RESULT_SUCCESS);
@@ -463,14 +357,14 @@
                 mSatelliteTransmissionUpdateCallback.getErrorCode());
         assertTrue(mSatelliteTransmissionUpdateCallback.inSendDatagramStateCallback);
         mPointingAppController.unregisterForSatelliteTransmissionUpdates(SUB_ID,
-                    mResultListener::offer, mSatelliteTransmissionUpdateCallback, mPhone);
+                    mResultListener::offer, mSatelliteTransmissionUpdateCallback);
         mResultListener.clear();
     }
 
     @Test
     public void testUpdateReceiveDatagramTransferState() throws Exception {
         mPointingAppController.registerForSatelliteTransmissionUpdates(SUB_ID,
-                mSatelliteTransmissionUpdateCallback, mPhone);
+                mSatelliteTransmissionUpdateCallback);
         mPointingAppController.updateReceiveDatagramTransferState(SUB_ID,
                 SatelliteManager.SATELLITE_DATAGRAM_TRANSFER_STATE_RECEIVE_SUCCESS, 2,
                 SatelliteManager.SATELLITE_RESULT_SUCCESS);
@@ -482,62 +376,11 @@
                 mSatelliteTransmissionUpdateCallback.getErrorCode());
         assertTrue(mSatelliteTransmissionUpdateCallback.inReceiveDatagramStateCallback);
         mPointingAppController.unregisterForSatelliteTransmissionUpdates(SUB_ID,
-                    mResultListener::offer, mSatelliteTransmissionUpdateCallback, mPhone);
+                    mResultListener::offer, mSatelliteTransmissionUpdateCallback);
         mResultListener.clear();
     }
 
     @Test
-    public void testRegisterForSatelliteTransmissionUpdates_CommandInterface() throws Exception {
-        mResultListener.clear();
-        mInOrder = inOrder(mPhone);
-        TestSatelliteTransmissionUpdateCallback callback1 = new
-                TestSatelliteTransmissionUpdateCallback();
-        TestSatelliteTransmissionUpdateCallback callback2 = new
-                TestSatelliteTransmissionUpdateCallback();
-        int subId1 = 1;
-        int subId2 = 2;
-        mPointingAppController.registerForSatelliteTransmissionUpdates(subId1,
-                callback1, mPhone);
-        mInOrder.verify(mPhone).registerForSatellitePositionInfoChanged(any(),
-                eq(1), eq(null));
-        mPointingAppController.registerForSatelliteTransmissionUpdates(subId1,
-                callback2, mPhone);
-        mInOrder.verify(mPhone, never()).registerForSatellitePositionInfoChanged(any(),
-                eq(1), eq(null));
-        mPointingAppController.registerForSatelliteTransmissionUpdates(subId2,
-                callback1, mPhone);
-        mInOrder.verify(mPhone).registerForSatellitePositionInfoChanged(any(),
-                eq(1), eq(null));
-        mPointingAppController.registerForSatelliteTransmissionUpdates(subId2,
-                callback2, mPhone);
-        mInOrder.verify(mPhone, never()).registerForSatellitePositionInfoChanged(any(),
-                eq(1), eq(null));
-        mPointingAppController.unregisterForSatelliteTransmissionUpdates(subId1,
-                mResultListener::offer, callback1, mPhone);
-        processAllMessages();
-        //since there are 2 callbacks registered for this sub_id, Handler is not unregistered
-        assertThat(mResultListener.peek()).isEqualTo(SatelliteManager.SATELLITE_RESULT_SUCCESS);
-        mResultListener.remove();
-        mPointingAppController.unregisterForSatelliteTransmissionUpdates(subId1,
-                mResultListener::offer, callback2, mPhone);
-        mInOrder.verify(mPhone).unregisterForSatellitePositionInfoChanged(any(Handler.class));
-        mPointingAppController.unregisterForSatelliteTransmissionUpdates(subId2,
-                mResultListener::offer, callback1, mPhone);
-        processAllMessages();
-        assertThat(mResultListener.peek()).isEqualTo(SatelliteManager.SATELLITE_RESULT_SUCCESS);
-        mResultListener.remove();
-        mInOrder.verify(mPhone, never()).unregisterForSatellitePositionInfoChanged(
-                any(Handler.class));
-        mPointingAppController.unregisterForSatelliteTransmissionUpdates(subId2,
-                mResultListener::offer, callback2, null);
-        processAllMessages();
-        assertThat(mResultListener.peek())
-                .isEqualTo(SatelliteManager.SATELLITE_RESULT_INVALID_TELEPHONY_STATE);
-        mResultListener.remove();
-        mInOrder = null;
-    }
-
-    @Test
     public void testRegisterForSatelliteTransmissionUpdates() throws Exception {
         mResultListener.clear();
         doReturn(true).when(mMockSatelliteModemInterface).isSatelliteServiceSupported();
@@ -548,44 +391,40 @@
                 TestSatelliteTransmissionUpdateCallback();
         int subId1 = 3;
         int subId2 = 4;
-        mPointingAppController.registerForSatelliteTransmissionUpdates(subId1,
-                callback1, mPhone);
+        mPointingAppController.registerForSatelliteTransmissionUpdates(subId1, callback1);
         mInOrder.verify(mMockSatelliteModemInterface).registerForSatellitePositionInfoChanged(any(),
                 eq(1), eq(null));
         mInOrder.verify(mMockSatelliteModemInterface).registerForDatagramTransferStateChanged(any(),
                 eq(4), eq(null));
-        mPointingAppController.registerForSatelliteTransmissionUpdates(subId1,
-                callback2, mPhone);
+        mPointingAppController.registerForSatelliteTransmissionUpdates(subId1, callback2);
         mInOrder.verify(mMockSatelliteModemInterface, never())
                 .registerForSatellitePositionInfoChanged(any(), eq(1), eq(null));
         mInOrder.verify(mMockSatelliteModemInterface, never())
                 .registerForDatagramTransferStateChanged(any(), eq(4), eq(null));
-        mPointingAppController.registerForSatelliteTransmissionUpdates(subId2,
-                callback1, mPhone);
+        mPointingAppController.registerForSatelliteTransmissionUpdates(subId2, callback1);
         mInOrder.verify(mMockSatelliteModemInterface).registerForSatellitePositionInfoChanged(any(),
                 eq(1), eq(null));
         mInOrder.verify(mMockSatelliteModemInterface).registerForDatagramTransferStateChanged(any(),
                 eq(4), eq(null));
-        mPointingAppController.registerForSatelliteTransmissionUpdates(subId2,
-                callback2, mPhone);
+        mPointingAppController.registerForSatelliteTransmissionUpdates(subId2, callback2);
         mInOrder.verify(mMockSatelliteModemInterface, never())
                 .registerForSatellitePositionInfoChanged(any(), eq(1), eq(null));
         mInOrder.verify(mMockSatelliteModemInterface, never())
                 .registerForDatagramTransferStateChanged(any(), eq(4), eq(null));
         mPointingAppController.unregisterForSatelliteTransmissionUpdates(subId1,
-                mResultListener::offer, callback1, mPhone);
+                mResultListener::offer, callback1);
         processAllMessages();
         //since there are 2 callbacks registered for this sub_id, Handler is not unregistered
         assertThat(mResultListener.peek()).isEqualTo(SatelliteManager.SATELLITE_RESULT_SUCCESS);
         mResultListener.remove();
         mPointingAppController.unregisterForSatelliteTransmissionUpdates(subId1,
-                mResultListener::offer, callback2, mPhone);
+                mResultListener::offer, callback2);
         mInOrder.verify(mMockSatelliteModemInterface).unregisterForSatellitePositionInfoChanged(
                 any(Handler.class));
         mInOrder.verify(mMockSatelliteModemInterface).unregisterForDatagramTransferStateChanged(
                 any(Handler.class));
         mPointingAppController.unregisterForSatelliteTransmissionUpdates(subId2,
-                mResultListener::offer, callback1, mPhone);
+                mResultListener::offer, callback1);
         processAllMessages();
         assertThat(mResultListener.peek()).isEqualTo(SatelliteManager.SATELLITE_RESULT_SUCCESS);
         mResultListener.remove();
@@ -594,7 +433,7 @@
         mInOrder.verify(mMockSatelliteModemInterface, never())
                 .unregisterForDatagramTransferStateChanged(any(Handler.class));
         mPointingAppController.unregisterForSatelliteTransmissionUpdates(subId2,
-                mResultListener::offer, callback2, null);
+                mResultListener::offer, callback2);
         processAllMessages();
         mInOrder.verify(mMockSatelliteModemInterface).unregisterForSatellitePositionInfoChanged(
                 any(Handler.class));
diff --git a/tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteControllerTest.java b/tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteControllerTest.java
index 3fc935e..2feb34d 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteControllerTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteControllerTest.java
@@ -16,7 +16,12 @@
 
 package com.android.internal.telephony.satellite;
 
+import static android.telephony.satellite.NtnSignalStrength.NTN_SIGNAL_STRENGTH_GOOD;
+import static android.telephony.satellite.NtnSignalStrength.NTN_SIGNAL_STRENGTH_GREAT;
+import static android.telephony.satellite.NtnSignalStrength.NTN_SIGNAL_STRENGTH_NONE;
+import static android.telephony.satellite.NtnSignalStrength.NTN_SIGNAL_STRENGTH_POOR;
 import static android.telephony.satellite.SatelliteManager.KEY_DEMO_MODE_ENABLED;
+import static android.telephony.satellite.SatelliteManager.KEY_NTN_SIGNAL_STRENGTH;
 import static android.telephony.satellite.SatelliteManager.KEY_SATELLITE_CAPABILITIES;
 import static android.telephony.satellite.SatelliteManager.KEY_SATELLITE_COMMUNICATION_ALLOWED;
 import static android.telephony.satellite.SatelliteManager.KEY_SATELLITE_ENABLED;
@@ -87,10 +92,12 @@
 import android.os.ResultReceiver;
 import android.telephony.CarrierConfigManager;
 import android.telephony.Rlog;
+import android.telephony.satellite.INtnSignalStrengthCallback;
 import android.telephony.satellite.ISatelliteDatagramCallback;
 import android.telephony.satellite.ISatelliteProvisionStateCallback;
 import android.telephony.satellite.ISatelliteStateCallback;
 import android.telephony.satellite.ISatelliteTransmissionUpdateCallback;
+import android.telephony.satellite.NtnSignalStrength;
 import android.telephony.satellite.SatelliteCapabilities;
 import android.telephony.satellite.SatelliteDatagram;
 import android.telephony.satellite.SatelliteManager;
@@ -102,7 +109,6 @@
 import com.android.internal.R;
 import com.android.internal.telephony.IIntegerConsumer;
 import com.android.internal.telephony.IVoidConsumer;
-import com.android.internal.telephony.Phone;
 import com.android.internal.telephony.TelephonyTest;
 import com.android.internal.telephony.flags.FeatureFlags;
 import com.android.internal.telephony.satellite.metrics.ControllerMetricsStats;
@@ -336,7 +342,7 @@
                     mQueriedSatelliteAllowed = false;
                 }
             } else {
-                logd("mSatelliteSupportReceiver: resultCode=" + resultCode);
+                logd("mSatelliteAllowedReceiver: resultCode=" + resultCode);
                 mQueriedSatelliteAllowed = false;
             }
             try {
@@ -375,6 +381,36 @@
         }
     };
 
+    private @NtnSignalStrength.NtnSignalStrengthLevel int mQueriedNtnSignalStrengthLevel =
+            NTN_SIGNAL_STRENGTH_NONE;
+    private int mQueriedNtnSignalStrengthResultCode = SATELLITE_RESULT_SUCCESS;
+    private Semaphore mRequestNtnSignalStrengthSemaphore = new Semaphore(0);
+    private ResultReceiver mRequestNtnSignalStrengthReceiver = new ResultReceiver(null) {
+        @Override
+        protected void onReceiveResult(int resultCode, Bundle resultData) {
+            mQueriedNtnSignalStrengthResultCode = resultCode;
+            if (resultCode == SATELLITE_RESULT_SUCCESS) {
+                if (resultData.containsKey(KEY_NTN_SIGNAL_STRENGTH)) {
+                    NtnSignalStrength result = resultData.getParcelable(KEY_NTN_SIGNAL_STRENGTH);
+                    logd("result.getLevel()=" + result.getLevel());
+                    mQueriedNtnSignalStrengthLevel = result.getLevel();
+                } else {
+                    loge("KEY_NTN_SIGNAL_STRENGTH does not exist.");
+                    mQueriedNtnSignalStrengthLevel = NTN_SIGNAL_STRENGTH_NONE;
+                }
+            } else {
+                logd("KEY_NTN_SIGNAL_STRENGTH: resultCode=" + resultCode);
+                mQueriedNtnSignalStrengthLevel = NTN_SIGNAL_STRENGTH_NONE;
+            }
+            try {
+                mRequestNtnSignalStrengthSemaphore.release();
+            } catch (Exception ex) {
+                loge("mRequestNtnSignalStrengthReceiver: Got exception in releasing semaphore, ex="
+                        + ex);
+            }
+        }
+    };
+
     @Before
     public void setUp() throws Exception {
         super.setUp(getClass().getSimpleName());
@@ -961,12 +997,11 @@
         mSatelliteControllerUT.startSatelliteTransmissionUpdates(SUB_ID, mIIntegerConsumer,
                 mStartTransmissionUpdateCallback);
         verify(mMockPointingAppController).registerForSatelliteTransmissionUpdates(anyInt(),
-                eq(mStartTransmissionUpdateCallback), any());
+                eq(mStartTransmissionUpdateCallback));
         processAllMessages();
         assertTrue(waitForIIntegerConsumerResult(1));
         assertEquals(SATELLITE_RESULT_SUCCESS, (long) mIIntegerConsumerResults.get(0));
-        verify(mMockPointingAppController).startSatelliteTransmissionUpdates(any(Message.class),
-                any(Phone.class));
+        verify(mMockPointingAppController).startSatelliteTransmissionUpdates(any(Message.class));
         verify(mMockPointingAppController).setStartedSatelliteTransmissionUpdates(eq(true));
 
         resetSatelliteControllerUT();
@@ -983,7 +1018,7 @@
         assertEquals(SATELLITE_RESULT_INVALID_TELEPHONY_STATE,
                 (long) mIIntegerConsumerResults.get(0));
         verify(mMockPointingAppController).unregisterForSatelliteTransmissionUpdates(anyInt(),
-                any(),  eq(mStartTransmissionUpdateCallback), any(Phone.class));
+                any(),  eq(mStartTransmissionUpdateCallback));
         verify(mMockPointingAppController).setStartedSatelliteTransmissionUpdates(eq(false));
     }
 
@@ -1042,12 +1077,11 @@
         mSatelliteControllerUT.stopSatelliteTransmissionUpdates(SUB_ID, mIIntegerConsumer,
                 mStopTransmissionUpdateCallback);
         verify(mMockPointingAppController).unregisterForSatelliteTransmissionUpdates(anyInt(),
-                any(),  eq(mStopTransmissionUpdateCallback), any(Phone.class));
+                any(),  eq(mStopTransmissionUpdateCallback));
         processAllMessages();
         assertTrue(waitForIIntegerConsumerResult(1));
         assertEquals(SATELLITE_RESULT_SUCCESS, (long) mIIntegerConsumerResults.get(0));
-        verify(mMockPointingAppController).stopSatelliteTransmissionUpdates(any(Message.class),
-                any(Phone.class));
+        verify(mMockPointingAppController).stopSatelliteTransmissionUpdates(any(Message.class));
 
         resetSatelliteControllerUT();
         mIIntegerConsumerResults.clear();
@@ -2005,6 +2039,276 @@
                 SATELLITE_MODEM_STATE_CONNECTED);
     }
 
+    @Test
+    public void testRequestNtnSignalStrengthWithFeatureFlagEnabled() {
+        when(mFeatureFlags.oemEnabledSatelliteFlag()).thenReturn(true);
+
+        resetSatelliteControllerUT();
+
+        mRequestNtnSignalStrengthSemaphore.drainPermits();
+        setUpResponseForRequestIsSatelliteSupported(false, SATELLITE_RESULT_SUCCESS);
+        verifySatelliteSupported(false, SATELLITE_RESULT_SUCCESS);
+
+        @NtnSignalStrength.NtnSignalStrengthLevel int expectedLevel = NTN_SIGNAL_STRENGTH_GREAT;
+        setUpResponseForRequestNtnSignalStrength(expectedLevel, SATELLITE_RESULT_SUCCESS);
+        /* In case request is not successful, result should be NTN_SIGNAL_STRENGTH_NONE */
+        verifyRequestNtnSignalStrength(NTN_SIGNAL_STRENGTH_NONE, SATELLITE_RESULT_NOT_SUPPORTED);
+
+        resetSatelliteControllerUT();
+        setUpResponseForRequestIsSatelliteProvisioned(true, SATELLITE_RESULT_SUCCESS);
+        setUpResponseForRequestIsSatelliteSupported(true, SATELLITE_RESULT_SUCCESS);
+        verifySatelliteSupported(true, SATELLITE_RESULT_SUCCESS);
+
+        doReturn(false).when(mMockSatelliteModemInterface).isSatelliteServiceSupported();
+        setUpResponseForRequestNtnSignalStrength(expectedLevel, SATELLITE_RESULT_SUCCESS);
+        verifyRequestNtnSignalStrength(NTN_SIGNAL_STRENGTH_NONE,
+                SATELLITE_RESULT_REQUEST_NOT_SUPPORTED);
+
+        doReturn(true).when(mMockSatelliteModemInterface).isSatelliteServiceSupported();
+        setUpResponseForRequestNtnSignalStrength(expectedLevel, SATELLITE_RESULT_SUCCESS);
+        verifyRequestNtnSignalStrength(expectedLevel, SATELLITE_RESULT_SUCCESS);
+
+        resetSatelliteControllerUT();
+        setUpResponseForRequestIsSatelliteSupported(true, SATELLITE_RESULT_SUCCESS);
+        verifySatelliteSupported(true, SATELLITE_RESULT_SUCCESS);
+        doReturn(true).when(mMockSatelliteModemInterface).isSatelliteServiceSupported();
+        // reset cache to NTN_SIGNAL_STRENGTH_NONE
+        sendNtnSignalStrengthChangedEvent(NTN_SIGNAL_STRENGTH_NONE, null);
+        processAllMessages();
+        expectedLevel = NTN_SIGNAL_STRENGTH_POOR;
+        setUpResponseForRequestNtnSignalStrength(expectedLevel, SATELLITE_RESULT_SUCCESS);
+        verifyRequestNtnSignalStrength(expectedLevel, SATELLITE_RESULT_SUCCESS);
+    }
+
+    @Test
+    public void testRequestNtnSignalStrengthWithFeatureFlagDisabled() {
+        when(mFeatureFlags.oemEnabledSatelliteFlag()).thenReturn(false);
+
+        resetSatelliteControllerUT();
+        mRequestNtnSignalStrengthSemaphore.drainPermits();
+        doReturn(false).when(mMockSatelliteModemInterface).isSatelliteServiceSupported();
+
+        @NtnSignalStrength.NtnSignalStrengthLevel int expectedLevel = NTN_SIGNAL_STRENGTH_GREAT;
+        setUpResponseForRequestNtnSignalStrength(expectedLevel, SATELLITE_RESULT_SUCCESS);
+        verifyRequestNtnSignalStrength(NTN_SIGNAL_STRENGTH_NONE,
+                SATELLITE_RESULT_REQUEST_NOT_SUPPORTED);
+
+        doReturn(true).when(mMockSatelliteModemInterface).isSatelliteServiceSupported();
+        setUpResponseForRequestNtnSignalStrength(expectedLevel, SATELLITE_RESULT_SUCCESS);
+        verifyRequestNtnSignalStrength(NTN_SIGNAL_STRENGTH_NONE,
+                SATELLITE_RESULT_REQUEST_NOT_SUPPORTED);
+
+        expectedLevel = NTN_SIGNAL_STRENGTH_POOR;
+        doReturn(true).when(mMockSatelliteModemInterface).isSatelliteServiceSupported();
+        setUpResponseForRequestNtnSignalStrength(expectedLevel, SATELLITE_RESULT_SUCCESS);
+        verifyRequestNtnSignalStrength(NTN_SIGNAL_STRENGTH_NONE,
+                SATELLITE_RESULT_REQUEST_NOT_SUPPORTED);
+
+        doReturn(true).when(mMockSatelliteModemInterface).isSatelliteServiceSupported();
+        setUpResponseForRequestNtnSignalStrength(expectedLevel, SATELLITE_RESULT_MODEM_ERROR);
+        verifyRequestNtnSignalStrength(NTN_SIGNAL_STRENGTH_NONE,
+                SATELLITE_RESULT_REQUEST_NOT_SUPPORTED);
+    }
+
+    @Test
+    public void testRegisterForNtnSignalStrengthChangedWithFeatureFlagEnabled() {
+        when(mFeatureFlags.oemEnabledSatelliteFlag()).thenReturn(true);
+
+        Semaphore semaphore = new Semaphore(0);
+        final NtnSignalStrength[] signalStrength = new NtnSignalStrength[1];
+        INtnSignalStrengthCallback callback =
+                new INtnSignalStrengthCallback.Stub() {
+                    @Override
+                    public void onNtnSignalStrengthChanged(NtnSignalStrength ntnSignalStrength) {
+                        logd("onNtnSignalStrengthChanged: ntnSignalStrength="
+                                + ntnSignalStrength);
+                        try {
+                            signalStrength[0] = ntnSignalStrength;
+                            semaphore.release();
+                        } catch (Exception ex) {
+                            loge("onNtnSignalStrengthChanged: Got exception in releasing "
+                                    + "semaphore, ex=" + ex);
+                        }
+                    }
+                };
+
+        int errorCode = mSatelliteControllerUT.registerForNtnSignalStrengthChanged(SUB_ID,
+                callback);
+        assertEquals(SATELLITE_RESULT_INVALID_TELEPHONY_STATE, errorCode);
+        @NtnSignalStrength.NtnSignalStrengthLevel int expectedLevel = NTN_SIGNAL_STRENGTH_NONE;
+
+        setUpResponseForRequestIsSatelliteSupported(false,
+                SATELLITE_RESULT_SUCCESS);
+        verifySatelliteSupported(false, SATELLITE_RESULT_SUCCESS);
+        errorCode = mSatelliteControllerUT.registerForNtnSignalStrengthChanged(SUB_ID, callback);
+        assertEquals(SATELLITE_RESULT_NOT_SUPPORTED, errorCode);
+        verifyRequestNtnSignalStrength(expectedLevel, SATELLITE_RESULT_NOT_SUPPORTED);
+
+        resetSatelliteControllerUT();
+        setUpResponseForRequestIsSatelliteProvisioned(true, SATELLITE_RESULT_SUCCESS);
+        setUpResponseForRequestIsSatelliteSupported(true, SATELLITE_RESULT_SUCCESS);
+        setUpResponseForRequestNtnSignalStrength(expectedLevel, SATELLITE_RESULT_SUCCESS);
+        verifySatelliteSupported(true, SATELLITE_RESULT_SUCCESS);
+        errorCode = mSatelliteControllerUT.registerForNtnSignalStrengthChanged(SUB_ID, callback);
+        assertEquals(SATELLITE_RESULT_SUCCESS, errorCode);
+        verifyRequestNtnSignalStrength(expectedLevel, SATELLITE_RESULT_SUCCESS);
+
+        expectedLevel = NTN_SIGNAL_STRENGTH_GOOD;
+        sendNtnSignalStrengthChangedEvent(expectedLevel, null);
+        processAllMessages();
+        assertTrue(waitForForEvents(
+                semaphore, 1, "testRegisterForNtnSignalStrengthChanged"));
+        assertEquals(expectedLevel, signalStrength[0].getLevel());
+        verifyRequestNtnSignalStrength(NTN_SIGNAL_STRENGTH_GOOD, SATELLITE_RESULT_SUCCESS);
+
+        expectedLevel = NTN_SIGNAL_STRENGTH_POOR;
+        sendNtnSignalStrengthChangedEvent(expectedLevel, null);
+        processAllMessages();
+        assertTrue(waitForForEvents(
+                semaphore, 1, "testRegisterForNtnSignalStrengthChanged"));
+        assertEquals(expectedLevel, signalStrength[0].getLevel());
+        verifyRequestNtnSignalStrength(NTN_SIGNAL_STRENGTH_POOR, SATELLITE_RESULT_SUCCESS);
+
+        mSatelliteControllerUT.unregisterForNtnSignalStrengthChanged(SUB_ID, callback);
+        sendNtnSignalStrengthChangedEvent(NTN_SIGNAL_STRENGTH_GREAT, null);
+        processAllMessages();
+        assertFalse(waitForForEvents(
+                semaphore, 1, "testRegisterForNtnSignalStrengthChanged"));
+        /* Even if all listeners are unregistered, the cache is updated with the latest value when a
+         new value event occurs. */
+        verifyRequestNtnSignalStrength(NTN_SIGNAL_STRENGTH_GREAT, SATELLITE_RESULT_SUCCESS);
+    }
+
+    @Test
+    public void testRegisterForNtnSignalStrengthChangedWithFeatureFlagDisabled() {
+        when(mFeatureFlags.oemEnabledSatelliteFlag()).thenReturn(false);
+
+        Semaphore semaphore = new Semaphore(0);
+        final NtnSignalStrength[] signalStrength = new NtnSignalStrength[1];
+        INtnSignalStrengthCallback callback =
+                new INtnSignalStrengthCallback.Stub() {
+                    @Override
+                    public void onNtnSignalStrengthChanged(NtnSignalStrength ntnSignalStrength) {
+                        logd("onNtnSignalStrengthChanged: ntnSignalStrength="
+                                + ntnSignalStrength);
+                        try {
+                            signalStrength[0] = ntnSignalStrength;
+                            semaphore.release();
+                        } catch (Exception ex) {
+                            loge("onNtnSignalStrengthChanged: Got exception in releasing "
+                                    + "semaphore, ex=" + ex);
+                        }
+                    }
+                };
+
+        int errorCode = mSatelliteControllerUT.registerForNtnSignalStrengthChanged(SUB_ID,
+                callback);
+        assertEquals(SATELLITE_RESULT_REQUEST_NOT_SUPPORTED, errorCode);
+
+        setUpResponseForRequestIsSatelliteSupported(false,
+                SATELLITE_RESULT_SUCCESS);
+        verifySatelliteSupported(false, SATELLITE_RESULT_NOT_SUPPORTED);
+        errorCode = mSatelliteControllerUT.registerForNtnSignalStrengthChanged(SUB_ID, callback);
+        assertEquals(SATELLITE_RESULT_REQUEST_NOT_SUPPORTED, errorCode);
+        setUpResponseForRequestNtnSignalStrength(NTN_SIGNAL_STRENGTH_NONE,
+                SATELLITE_RESULT_SUCCESS);
+        verifyRequestNtnSignalStrength(NTN_SIGNAL_STRENGTH_NONE,
+                SATELLITE_RESULT_REQUEST_NOT_SUPPORTED);
+
+        resetSatelliteControllerUT();
+        setUpResponseForRequestIsSatelliteSupported(true, SATELLITE_RESULT_SUCCESS);
+        verifySatelliteSupported(false, SATELLITE_RESULT_NOT_SUPPORTED);
+        errorCode = mSatelliteControllerUT.registerForNtnSignalStrengthChanged(SUB_ID, callback);
+        assertEquals(SATELLITE_RESULT_REQUEST_NOT_SUPPORTED, errorCode);
+        verifyRequestNtnSignalStrength(NTN_SIGNAL_STRENGTH_NONE,
+                SATELLITE_RESULT_REQUEST_NOT_SUPPORTED);
+
+        @NtnSignalStrength.NtnSignalStrengthLevel int expectedNtnSignalStrengthLevel =
+                NTN_SIGNAL_STRENGTH_GOOD;
+        sendNtnSignalStrengthChangedEvent(expectedNtnSignalStrengthLevel, null);
+        processAllMessages();
+        assertTrue(waitForForEvents(
+                semaphore, 0, "testRegisterForNtnSignalStrengthChanged"));
+    }
+
+    @Test
+    public void testSendingNtnSignalStrengthWithFeatureEnabled() {
+        when(mFeatureFlags.oemEnabledSatelliteFlag()).thenReturn(true);
+
+        int expectedResult = SATELLITE_RESULT_SUCCESS;
+        // startSendingNtnSignalStrength() is requested when screen on event comes.
+        reset(mMockSatelliteModemInterface);
+        doReturn(true).when(mMockSatelliteModemInterface).isSatelliteServiceSupported();
+        setUpResponseForRequestIsSatelliteSupported(true, expectedResult);
+        setUpResponseForRequestIsSatelliteProvisioned(true, expectedResult);
+        verifySatelliteSupported(true, expectedResult);
+        verifySatelliteProvisioned(true, expectedResult);
+        setUpResponseForStartSendingNtnSignalStrength(expectedResult);
+        sendCmdStartSendingNtnSignalStrengthChangedEvent(true);
+        processAllMessages();
+        verify(mMockSatelliteModemInterface, times(1))
+                .startSendingNtnSignalStrength(any(Message.class));
+
+        // stopSendingNtnSignalStrength() is requested when screen off event comes.
+        reset(mMockSatelliteModemInterface);
+        setUpResponseForRequestIsSatelliteProvisioned(true, SATELLITE_RESULT_SUCCESS);
+        setUpResponseForRequestIsSatelliteSupported(true, SATELLITE_RESULT_SUCCESS);
+        doReturn(true).when(mMockSatelliteModemInterface).isSatelliteServiceSupported();
+        setUpResponseForStopSendingNtnSignalStrength(expectedResult);
+        sendCmdStartSendingNtnSignalStrengthChangedEvent(false);
+        processAllMessages();
+        verify(mMockSatelliteModemInterface, times(1))
+                .stopSendingNtnSignalStrength(any(Message.class));
+
+        // startSendingNtnSignalStrength() is requested but received fail from the service.
+        reset(mMockSatelliteModemInterface);
+        doReturn(true).when(mMockSatelliteModemInterface).isSatelliteServiceSupported();
+        setUpResponseForStartSendingNtnSignalStrength(SATELLITE_RESULT_INVALID_MODEM_STATE);
+        sendCmdStartSendingNtnSignalStrengthChangedEvent(true);
+        processAllMessages();
+        verify(mMockSatelliteModemInterface, times(1))
+                .startSendingNtnSignalStrength(any(Message.class));
+
+        // stopSendingNtnSignalStrength() is requested but received fail from the service.
+        reset(mMockSatelliteModemInterface);
+        doReturn(true).when(mMockSatelliteModemInterface).isSatelliteServiceSupported();
+        setUpResponseForStopSendingNtnSignalStrength(SATELLITE_RESULT_NO_RESOURCES);
+        sendCmdStartSendingNtnSignalStrengthChangedEvent(false);
+        processAllMessages();
+        verify(mMockSatelliteModemInterface, times(1))
+                .stopSendingNtnSignalStrength(any(Message.class));
+    }
+
+    @Test
+    public void testSendingNtnSignalStrengthWithFeatureDisabled() {
+        when(mFeatureFlags.oemEnabledSatelliteFlag()).thenReturn(false);
+
+        int expectedResult = SATELLITE_RESULT_SUCCESS;
+        // startSendingNtnSignalStrength() is requested when screen on event comes.
+        reset(mMockSatelliteModemInterface);
+        doReturn(true).when(mMockSatelliteModemInterface).isSatelliteServiceSupported();
+        setUpResponseForRequestIsSatelliteSupported(true, expectedResult);
+        setUpResponseForRequestIsSatelliteProvisioned(true, expectedResult);
+        verifySatelliteSupported(false, SATELLITE_RESULT_NOT_SUPPORTED);
+        verifySatelliteProvisioned(false, SATELLITE_RESULT_REQUEST_NOT_SUPPORTED);
+        setUpResponseForStartSendingNtnSignalStrength(expectedResult);
+        sendCmdStartSendingNtnSignalStrengthChangedEvent(true);
+        processAllMessages();
+        verify(mMockSatelliteModemInterface, never())
+                .startSendingNtnSignalStrength(any(Message.class));
+
+        // stopSendingNtnSignalStrength() is requested when screen off event comes.
+        reset(mMockSatelliteModemInterface);
+        setUpResponseForRequestIsSatelliteProvisioned(true, SATELLITE_RESULT_SUCCESS);
+        setUpResponseForRequestIsSatelliteSupported(true, SATELLITE_RESULT_SUCCESS);
+        doReturn(true).when(mMockSatelliteModemInterface).isSatelliteServiceSupported();
+        setUpResponseForStopSendingNtnSignalStrength(expectedResult);
+        sendCmdStartSendingNtnSignalStrengthChangedEvent(false);
+        processAllMessages();
+        verify(mMockSatelliteModemInterface, never())
+                .stopSendingNtnSignalStrength(any(Message.class));
+    }
+
     private void resetSatelliteControllerUTEnabledState() {
         logd("resetSatelliteControllerUTEnabledState");
         setUpResponseForRequestIsSatelliteSupported(false, SATELLITE_RESULT_RADIO_NOT_AVAILABLE);
@@ -2232,6 +2536,20 @@
         }).when(mMockSatelliteModemInterface).requestSatelliteCapabilities(any(Message.class));
     }
 
+    private void setUpResponseForRequestNtnSignalStrength(
+            @NtnSignalStrength.NtnSignalStrengthLevel int ntnSignalStrengthLevel,
+            @SatelliteManager.SatelliteResult int error) {
+        SatelliteException exception = (error == SATELLITE_RESULT_SUCCESS)
+                ? null : new SatelliteException(error);
+        doAnswer(invocation -> {
+            Message message = (Message) invocation.getArguments()[0];
+            AsyncResult.forMessage(message, new NtnSignalStrength(ntnSignalStrengthLevel),
+                    exception);
+            message.sendToTarget();
+            return null;
+        }).when(mMockSatelliteModemInterface).requestNtnSignalStrength(any(Message.class));
+    }
+
     private boolean waitForForEvents(
             Semaphore semaphore, int expectedNumberOfEvents, String caller) {
         for (int i = 0; i < expectedNumberOfEvents; i++) {
@@ -2269,8 +2587,7 @@
             AsyncResult.forMessage(message, null, exception);
             message.sendToTarget();
             return null;
-        }).when(mMockPointingAppController).startSatelliteTransmissionUpdates(any(Message.class),
-                any());
+        }).when(mMockPointingAppController).startSatelliteTransmissionUpdates(any(Message.class));
     }
 
     private void setUpResponseForStopSatelliteTransmissionUpdates(
@@ -2282,8 +2599,31 @@
             AsyncResult.forMessage(message, null, exception);
             message.sendToTarget();
             return null;
-        }).when(mMockPointingAppController).stopSatelliteTransmissionUpdates(any(Message.class),
-                any());
+        }).when(mMockPointingAppController).stopSatelliteTransmissionUpdates(any(Message.class));
+    }
+
+    private void setUpResponseForStartSendingNtnSignalStrength(
+            @SatelliteManager.SatelliteResult int error) {
+        SatelliteException exception = (error == SATELLITE_RESULT_SUCCESS)
+                ? null : new SatelliteException(error);
+        doAnswer(invocation -> {
+            Message message = (Message) invocation.getArguments()[0];
+            AsyncResult.forMessage(message, null, exception);
+            message.sendToTarget();
+            return null;
+        }).when(mMockSatelliteModemInterface).startSendingNtnSignalStrength(any(Message.class));
+    }
+
+    private void setUpResponseForStopSendingNtnSignalStrength(
+            @SatelliteManager.SatelliteResult int error) {
+        SatelliteException exception = (error == SATELLITE_RESULT_SUCCESS)
+                ? null : new SatelliteException(error);
+        doAnswer(invocation -> {
+            Message message = (Message) invocation.getArguments()[0];
+            AsyncResult.forMessage(message, null, exception);
+            message.sendToTarget();
+            return null;
+        }).when(mMockSatelliteModemInterface).stopSendingNtnSignalStrength(any(Message.class));
     }
 
     private boolean waitForRequestIsSatelliteSupportedResult(int expectedNumberOfEvents) {
@@ -2396,6 +2736,22 @@
         return true;
     }
 
+    private boolean waitForRequestNtnSignalStrengthResult(int expectedNumberOfEvents) {
+        for (int i = 0; i < expectedNumberOfEvents; i++) {
+            try {
+                if (!mRequestNtnSignalStrengthSemaphore.tryAcquire(TIMEOUT,
+                        TimeUnit.MILLISECONDS)) {
+                    loge("Timeout to receive requestNtnSignalStrength() callback");
+                    return false;
+                }
+            } catch (Exception ex) {
+                loge("requestNtnSignalStrength: Got exception=" + ex);
+                return false;
+            }
+        }
+        return true;
+    }
+
     private boolean waitForIIntegerConsumerResult(int expectedNumberOfEvents) {
         for (int i = 0; i < expectedNumberOfEvents; i++) {
             try {
@@ -2439,6 +2795,17 @@
         assertEquals(provisioned, mQueriedIsSatelliteProvisioned);
     }
 
+    private void verifyRequestNtnSignalStrength(
+            @NtnSignalStrength.NtnSignalStrengthLevel int signalStrengthLevel,
+            int expectedErrorCode) {
+        mRequestNtnSignalStrengthSemaphore.drainPermits();
+        mSatelliteControllerUT.requestNtnSignalStrength(SUB_ID, mRequestNtnSignalStrengthReceiver);
+        processAllMessages();
+        assertTrue(waitForRequestNtnSignalStrengthResult(1));
+        assertEquals(expectedErrorCode, mQueriedNtnSignalStrengthResultCode);
+        assertEquals(signalStrengthLevel, mQueriedNtnSignalStrengthLevel);
+    }
+
     private void sendProvisionedStateChangedEvent(boolean provisioned, Throwable exception) {
         Message msg = mSatelliteControllerUT.obtainMessage(
                 26 /* EVENT_SATELLITE_PROVISION_STATE_CHANGED */);
@@ -2453,6 +2820,33 @@
         msg.sendToTarget();
     }
 
+    private void sendNtnSignalStrengthChangedEvent(
+            @NtnSignalStrength.NtnSignalStrengthLevel int ntnSignalStrengthLevel,
+            Throwable exception) {
+        Message msg = mSatelliteControllerUT.obtainMessage(
+                34 /* EVENT_NTN_SIGNAL_STRENGTH_CHANGED */);
+        msg.obj = new AsyncResult(null, new NtnSignalStrength(ntnSignalStrengthLevel),
+                exception);
+        msg.sendToTarget();
+    }
+
+    private void sendCmdStartSendingNtnSignalStrengthChangedEvent(boolean shouldReport) {
+        Message msg = mSatelliteControllerUT.obtainMessage(
+                35 /* CMD_START_SENDING_NTN_SIGNAL_STRENGTH */);
+        msg.obj = new AsyncResult(null, shouldReport, null);
+        msg.sendToTarget();
+    }
+
+    private void sendStartSendingNtnSignalStrengthChangedEvent(
+            @NtnSignalStrength.NtnSignalStrengthLevel int ntnSignalStrengthLevel,
+            Throwable exception) {
+        Message msg = mSatelliteControllerUT.obtainMessage(
+                36 /* EVENT_START_SENDING_NTN_SIGNAL_STRENGTH_DONE */);
+        msg.obj = new AsyncResult(null, new NtnSignalStrength(ntnSignalStrengthLevel),
+                exception);
+        msg.sendToTarget();
+    }
+
     private void setRadioPower(boolean on) {
         mSimulatedCommands.setRadioPower(on, false, false, null);
     }
