Pass emergency session information to modem

Bug: 331710063
Test: atest SatelliteControllerTest, RadioOnStateListenerTest
Test: manual - using SatelliteTestApp
click the enableSatellite, verify the isEmergency set as true.
click the disableSatellite , verify the isEmergency set as false.

Change-Id: I45ab5a6b72deaf098fdb1b90bb405124cf41a586
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index c382a44..4c8c836 100644
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -13020,7 +13020,7 @@
                     }
                     if (isAllowed) {
                         mSatelliteController.requestSatelliteEnabled(
-                                subId, enableSatellite, enableDemoMode, callback);
+                                subId, enableSatellite, enableDemoMode, isEmergency, callback);
                     } else {
                         result.accept(SATELLITE_RESULT_ACCESS_BARRED);
                     }
@@ -13031,7 +13031,7 @@
         } else {
             // No need to check if satellite is allowed at current location when disabling satellite
             mSatelliteController.requestSatelliteEnabled(
-                    subId, enableSatellite, enableDemoMode, callback);
+                    subId, enableSatellite, enableDemoMode, isEmergency, callback);
         }
     }
 
diff --git a/testapps/TestSatelliteApp/res/layout/activity_SatelliteControl.xml b/testapps/TestSatelliteApp/res/layout/activity_SatelliteControl.xml
index 6a79412..6aec1da 100644
--- a/testapps/TestSatelliteApp/res/layout/activity_SatelliteControl.xml
+++ b/testapps/TestSatelliteApp/res/layout/activity_SatelliteControl.xml
@@ -119,6 +119,12 @@
             android:layout_height="wrap_content"
             android:paddingRight="4dp"
             android:text="@string/isRequestIsSatelliteEnabledForCarrier"/>
+        <Button
+            android:id="@+id/getIsEmergency"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:paddingRight="4dp"
+            android:text="@string/getIsEmergency"/>
          <Button
             android:id="@+id/Back"
             android:onClick="Back"
diff --git a/testapps/TestSatelliteApp/res/values/donottranslate_strings.xml b/testapps/TestSatelliteApp/res/values/donottranslate_strings.xml
index 20f5ca8..8ddfee1 100644
--- a/testapps/TestSatelliteApp/res/values/donottranslate_strings.xml
+++ b/testapps/TestSatelliteApp/res/values/donottranslate_strings.xml
@@ -30,6 +30,7 @@
     <string name="requestSatelliteCapabilities">requestSatelliteCapabilities</string>
     <string name="requestIsSatelliteCommunicationAllowedForCurrentLocation">requestIsSatelliteCommunicationAllowedForCurrentLocation</string>
     <string name="requestTimeForNextSatelliteVisibility">requestTimeForNextSatelliteVisibility</string>
+    <string name="getIsEmergency">getIsEmergency</string>
 
     <string name="pollPendingSatelliteDatagrams">pollPendingSatelliteDatagrams</string>
     <string name="sendSatelliteDatagram">sendSatelliteDatagram</string>
diff --git a/testapps/TestSatelliteApp/src/com/android/phone/testapps/satellitetestapp/SatelliteControl.java b/testapps/TestSatelliteApp/src/com/android/phone/testapps/satellitetestapp/SatelliteControl.java
index dd7b825..a03f04e 100644
--- a/testapps/TestSatelliteApp/src/com/android/phone/testapps/satellitetestapp/SatelliteControl.java
+++ b/testapps/TestSatelliteApp/src/com/android/phone/testapps/satellitetestapp/SatelliteControl.java
@@ -81,6 +81,8 @@
                 .setOnClickListener(this::isSatelliteEnabledForCarrierApp);
         findViewById(R.id.isRequestIsSatelliteEnabledForCarrier)
                 .setOnClickListener(this::isRequestIsSatelliteEnabledForCarrierApp);
+        findViewById(R.id.getIsEmergency)
+                .setOnClickListener(this::getIsEmergencyApp);
         findViewById(R.id.Back).setOnClickListener(new OnClickListener() {
             @Override
             public void onClick(View view) {
@@ -92,8 +94,8 @@
     private void enableSatelliteApp(View view) {
         LinkedBlockingQueue<Integer> error = new LinkedBlockingQueue<>(1);
         mSatelliteManager.requestEnabled(
-                new EnableRequestAttributes.Builder(true).setDemoMode(true).build(),
-                Runnable::run, error::offer);
+                new EnableRequestAttributes.Builder(true).setDemoMode(true).setEmergencyMode(true)
+                        .build(), Runnable::run, error::offer);
         TextView textView = findViewById(R.id.text_id);
         try {
             Integer value = error.poll(TIMEOUT, TimeUnit.MILLISECONDS);
@@ -374,4 +376,11 @@
                 + SatelliteTestApp.getTestSatelliteService()
                 .isRequestIsSatelliteEnabledForCarrier());
     }
+
+    private void getIsEmergencyApp(View view) {
+        TextView textView = findViewById(R.id.text_id);
+        textView.setText("[SatelliteService] getIsEmergencyApp= "
+                + SatelliteTestApp.getTestSatelliteService()
+                .getIsEmergency());
+    }
 }
diff --git a/testapps/TestSatelliteApp/src/com/android/phone/testapps/satellitetestapp/TestSatelliteService.java b/testapps/TestSatelliteApp/src/com/android/phone/testapps/satellitetestapp/TestSatelliteService.java
index ed9fa10..afa20bc 100644
--- a/testapps/TestSatelliteApp/src/com/android/phone/testapps/satellitetestapp/TestSatelliteService.java
+++ b/testapps/TestSatelliteApp/src/com/android/phone/testapps/satellitetestapp/TestSatelliteService.java
@@ -100,6 +100,7 @@
     private List<String> mAllPlmnList = new ArrayList<>();
     private boolean mIsSatelliteEnabledForCarrier;
     private boolean mIsRequestIsSatelliteEnabledForCarrier;
+    private boolean mIsEmergnecy;
 
     /**
      * Create TestSatelliteService using the Executor specified for methods being called from
@@ -117,6 +118,7 @@
         mIsCellularModemEnabledMode = false;
         mIsSatelliteEnabledForCarrier = false;
         mIsRequestIsSatelliteEnabledForCarrier = false;
+        mIsEmergnecy = false;
     }
 
     /**
@@ -184,8 +186,9 @@
 
     @Override
     public void requestSatelliteEnabled(boolean enableSatellite, boolean enableDemoMode,
-            @NonNull IIntegerConsumer errorCallback) {
-        logd("requestSatelliteEnabled: mErrorCode=" + mErrorCode + " enable = " + enableSatellite);
+            boolean isEmergency, @NonNull IIntegerConsumer errorCallback) {
+        logd("requestSatelliteEnabled: mErrorCode=" + mErrorCode + " enable = " + enableSatellite
+                + " isEmergency=" + isEmergency);
         if (mErrorCode != SatelliteResult.SATELLITE_RESULT_SUCCESS) {
             runWithExecutor(() -> errorCallback.accept(mErrorCode));
             return;
@@ -196,6 +199,7 @@
         } else {
             disableSatellite(errorCallback);
         }
+        mIsEmergnecy = isEmergency;
     }
 
     private void enableSatellite(@NonNull IIntegerConsumer errorCallback) {
@@ -565,6 +569,10 @@
         return mIsRequestIsSatelliteEnabledForCarrier;
     }
 
+    public boolean getIsEmergency() {
+        return mIsEmergnecy;
+    }
+
     /**
      * Log the message to the radio buffer with {@code DEBUG} priority.
      *