Merge "Report satellite communication is allowed for current location satus" into 24D1-dev
diff --git a/res/layout/radio_info.xml b/res/layout/radio_info.xml
index 0c04800..972996f 100644
--- a/res/layout/radio_info.xml
+++ b/res/layout/radio_info.xml
@@ -234,6 +234,16 @@
                 android:layout_height="wrap_content"
                 android:text="@string/mock_carrier_roaming_satellite_string"/>
 
+        <!-- ESOS -->
+        <Button android:id="@+id/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/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 bb0d3de..31791a6 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -2023,6 +2023,8 @@
 
     <!-- Title for simulating SIM capable of satellite. -->
     <string name="mock_carrier_roaming_satellite_string">Mock Carrier Satellite Mode (Debug Build only)</string>
+    <!-- Title for trigger real satellite eSOS. -->
+    <string name="esos_satellite_string">Test real 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/satellite/accesscontrol/SatelliteAccessController.java b/src/com/android/phone/satellite/accesscontrol/SatelliteAccessController.java
index e5ea105..46fdd20 100644
--- a/src/com/android/phone/satellite/accesscontrol/SatelliteAccessController.java
+++ b/src/com/android/phone/satellite/accesscontrol/SatelliteAccessController.java
@@ -1013,11 +1013,17 @@
         synchronized (mLock) {
             stopWaitForCurrentLocationTimer();
             mLocationRequestCancellationSignal = null;
+            Bundle bundle = new Bundle();
             if (location != null) {
+                if (location.isMock() && !isMockModemAllowed()) {
+                    logd("location is mock");
+                    bundle.putBoolean(KEY_SATELLITE_COMMUNICATION_ALLOWED, false);
+                    sendSatelliteAllowResultToReceivers(SATELLITE_RESULT_SUCCESS, bundle, false);
+                    return;
+                }
                 checkSatelliteAccessRestrictionForLocation(location);
             } else {
                 logd("current location is not available");
-                Bundle bundle = new Bundle();
                 if (isCommunicationAllowedCacheValid()) {
                     logd("onCurrentLocationAvailable: 24Hr cache is still valid, using it");
                     bundle.putBoolean(KEY_SATELLITE_COMMUNICATION_ALLOWED,
@@ -1189,7 +1195,12 @@
                 result = location;
             }
         }
-        return result;
+
+        if (result == null || isMockModemAllowed()) {
+            return result;
+        }
+
+        return result.isMock() ? null : result;
     }
 
     private void initSharedPreferences(@NonNull Context context) {
diff --git a/src/com/android/phone/settings/RadioInfo.java b/src/com/android/phone/settings/RadioInfo.java
index 62ca3b3..d136b9c 100644
--- a/src/com/android/phone/settings/RadioInfo.java
+++ b/src/com/android/phone/settings/RadioInfo.java
@@ -129,6 +129,9 @@
 
     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",
@@ -274,6 +277,7 @@
     private Button mOemInfoButton;
     private Button mCarrierProvisioningButton;
     private Button mTriggerCarrierProvisioningButton;
+    private Button mEsosButton;
     private Switch mImsVolteProvisionedSwitch;
     private Switch mImsVtProvisionedSwitch;
     private Switch mImsWfcProvisionedSwitch;
@@ -672,6 +676,17 @@
             mTriggerCarrierProvisioningButton.setEnabled(false);
         }
 
+        mEsosButton = (Button) findViewById(R.id.esos_questionnaire);
+        if (!TelephonyUtils.IS_DEBUGGABLE) {
+            mEsosButton.setVisibility(View.GONE);
+        } else {
+            mEsosButton.setOnClickListener(v ->
+                    mPhone.getContext().startActivity(
+                        new Intent(ACTION_ESOS_TEST)
+                        .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK))
+            );
+        }
+
         mOemInfoButton = (Button) findViewById(R.id.oem_info);
         mOemInfoButton.setOnClickListener(mOemInfoButtonHandler);
         PackageManager pm = getPackageManager();