[Satellite] added Demo mode esos questionnaire button

Test: manual
Bug: b/359897259
Flag: EXEMPT test only

Change-Id: Ief417d7ba5990920732b87f9affe345870a724b1
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index b6171fc..d7ad451 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -181,6 +181,8 @@
 
     <!-- Needed because the DISPLAY_EMERGENCY_MESSAGE ConnectionEvent contains a PendingIntent to activate the satellite feature. -->
     <uses-permission android:name="com.google.android.apps.stargate.permission.SEND_EMERGENCY_INTENTS"/>
+    <!-- Needed to start demo session -->
+    <uses-permission android:name="com.google.android.apps.stargate.permission.SEND_NON_EMERGENCY_INTENTS"/>
 
     <application android:name="PhoneApp"
             android:persistent="true"
diff --git a/res/layout/radio_info.xml b/res/layout/radio_info.xml
index 24590bc..9ab8157 100644
--- a/res/layout/radio_info.xml
+++ b/res/layout/radio_info.xml
@@ -283,6 +283,16 @@
             android:textAllCaps="false"
             android:text="@string/satellite_enable_non_emergency_mode_string" />
 
+        <!-- Demo ESOS -->
+        <Button android:id="@+id/demo_esos_questionnaire"
+                android:textSize="14sp"
+                android:layout_marginTop="8dip"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:textAllCaps="false"
+                android:text="@string/demo_esos_satellite_string"
+        />
+
         <!-- VoLTE provisioned -->
         <Switch android:id="@+id/volte_provisioned_switch"
                 android:textSize="14sp"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 305f7cb..f3bff1b 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -2037,6 +2037,8 @@
     <string name="esos_satellite_string">Test real satellite eSOS mode (Debug Build only)</string>
     <!-- Title for enable real satellite non-emergency mode. -->
     <string name="satellite_enable_non_emergency_mode_string">Test real satellite non-eSOS mode (Debug Build only)</string>
+    <!-- Title for trigger demo satellite eSOS. -->
+    <string name="demo_esos_satellite_string">Test demo satellite eSOS mode (Debug Build only)</string>
 
     <!-- Phone Info screen. Menu item label.  Used for diagnostic info screens, precise translation isn't needed -->
     <string name="radioInfo_menu_viewADN">View SIM Address Book</string>
diff --git a/src/com/android/phone/settings/RadioInfo.java b/src/com/android/phone/settings/RadioInfo.java
index 6be15f3..005c0fa 100644
--- a/src/com/android/phone/settings/RadioInfo.java
+++ b/src/com/android/phone/settings/RadioInfo.java
@@ -135,9 +135,6 @@
 
     private static final boolean IS_USER_BUILD = "user".equals(Build.TYPE);
 
-    private static final String ACTION_ESOS_TEST =
-            "com.google.android.apps.stargate.ACTION_ESOS_QUESTIONNAIRE";
-
     private static final String[] PREFERRED_NETWORK_LABELS = {
             "GSM/WCDMA preferred",
             "GSM only",
@@ -317,6 +314,7 @@
     private Button mTriggerCarrierProvisioningButton;
     private Button mEsosButton;
     private Button mSatelliteEnableNonEmergencyModeButton;
+    private Button mEsosDemoButton;
     private Switch mImsVolteProvisionedSwitch;
     private Switch mImsVtProvisionedSwitch;
     private Switch mImsWfcProvisionedSwitch;
@@ -361,6 +359,9 @@
     private int mCellInfoRefreshRateIndex;
     private int mSelectedPhoneIndex;
 
+    private String mActionEsos;
+    private String mActionEsosDemo;
+
     private final NetworkRequest mDefaultNetworkRequest = new NetworkRequest.Builder()
             .addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR)
             .addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
@@ -568,6 +569,16 @@
 
         log("Started onCreate");
 
+        Resources r = getResources();
+        mActionEsos =
+            r.getString(
+                    com.android.internal.R.string
+                            .config_satellite_emergency_handover_intent_action);
+
+        mActionEsosDemo =
+            r.getString(
+                    com.android.internal.R.string.config_satellite_demo_mode_sos_intent_action);
+
         mQueuedWork = new ThreadPoolExecutor(1, 1, RUNNABLE_TIMEOUT_MS, TimeUnit.MICROSECONDS,
                 new LinkedBlockingDeque<Runnable>());
         mConnectivityManager = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);
@@ -754,6 +765,7 @@
         }
 
         mEsosButton = (Button) findViewById(R.id.esos_questionnaire);
+        mEsosDemoButton  = (Button) findViewById(R.id.demo_esos_questionnaire);
         mSatelliteEnableNonEmergencyModeButton = (Button) findViewById(
                 R.id.satellite_enable_non_emergency_mode);
         CarrierConfigManager cm = mPhone.getContext().getSystemService(CarrierConfigManager.class);
@@ -763,14 +775,25 @@
             mSatelliteEnableNonEmergencyModeButton.setVisibility(View.GONE);
         }
         if (!TelephonyUtils.IS_DEBUGGABLE) {
-            mEsosButton.setVisibility(View.GONE);
+            if (!TextUtils.isEmpty(mActionEsos)) {
+                mEsosButton.setVisibility(View.GONE);
+            }
+            if (!TextUtils.isEmpty(mActionEsosDemo)) {
+                mEsosDemoButton.setVisibility(View.GONE);
+            }
             mSatelliteEnableNonEmergencyModeButton.setVisibility(View.GONE);
         } else {
             mEsosButton.setOnClickListener(v ->
                     mPhone.getContext().startActivity(
-                        new Intent(ACTION_ESOS_TEST)
+                        new Intent(mActionEsos)
                         .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK))
             );
+            mEsosDemoButton.setOnClickListener(v ->
+                    mPhone.getContext().startActivity(
+                            new Intent(mActionEsosDemo)
+                                    .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
+                                            | Intent.FLAG_ACTIVITY_CLEAR_TASK))
+            );
             mSatelliteEnableNonEmergencyModeButton.setOnClickListener(v ->
                     enableSatelliteNonEmergencyMode());
         }