diff options
4 files changed, 44 insertions, 0 deletions
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index a6487a2651ec..00180a8a86bb 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -11272,6 +11272,14 @@ public final class Settings { public static final String EMERGENCY_AFFORDANCE_NEEDED = "emergency_affordance_needed"; /** + * Enable faster emergency phone call feature. + * The value is a boolean (1 or 0). + * @hide + */ + public static final String FASTER_EMERGENCY_PHONE_CALL_ENABLED = + "faster_emergency_phone_call_enabled"; + + /** * See RIL_PreferredNetworkType in ril.h * @hide */ diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index bf16f73e6071..1c8b60da575f 100644 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -2576,6 +2576,7 @@ "silent" = silent mode "users" = list of users "restart" = restart device + "emergency" = Launch emergency dialer "lockdown" = Lock down device until the user authenticates "logout" = Logout the current user --> @@ -2585,6 +2586,7 @@ <item>lockdown</item> <item>logout</item> <item>bugreport</item> + <item>emergency</item> <item>screenshot</item> </string-array> diff --git a/core/tests/coretests/src/android/provider/SettingsBackupTest.java b/core/tests/coretests/src/android/provider/SettingsBackupTest.java index 7428b1264348..b7460ac213ab 100644 --- a/core/tests/coretests/src/android/provider/SettingsBackupTest.java +++ b/core/tests/coretests/src/android/provider/SettingsBackupTest.java @@ -236,6 +236,7 @@ public class SettingsBackupTest { Settings.Global.EUICC_SUPPORTED_COUNTRIES, Settings.Global.EUICC_FACTORY_RESET_TIMEOUT_MILLIS, Settings.Global.FANCY_IME_ANIMATIONS, + Settings.Global.FASTER_EMERGENCY_PHONE_CALL_ENABLED, Settings.Global.FORCE_ALLOW_ON_EXTERNAL, Settings.Global.FORCED_APP_STANDBY_ENABLED, Settings.Global.FORCED_APP_STANDBY_FOR_SMALL_BATTERY_ENABLED, diff --git a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java index d232108ded40..92674d456bcd 100644 --- a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java +++ b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java @@ -127,6 +127,7 @@ class GlobalActionsDialog implements DialogInterface.OnDismissListener, private static final String GLOBAL_ACTION_KEY_ASSIST = "assist"; private static final String GLOBAL_ACTION_KEY_RESTART = "restart"; private static final String GLOBAL_ACTION_KEY_LOGOUT = "logout"; + private static final String GLOBAL_ACTION_KEY_EMERGENCY = "emergency"; private static final String GLOBAL_ACTION_KEY_SCREENSHOT = "screenshot"; private final Context mContext; @@ -357,6 +358,12 @@ class GlobalActionsDialog implements DialogInterface.OnDismissListener, mItems.add(getAssistAction()); } else if (GLOBAL_ACTION_KEY_RESTART.equals(actionKey)) { mItems.add(new RestartAction()); + } else if (GLOBAL_ACTION_KEY_EMERGENCY.equals(actionKey)) { + if (Settings.Global.getInt(mContext.getContentResolver(), + Settings.Global.FASTER_EMERGENCY_PHONE_CALL_ENABLED, 0) != 0 + && !mEmergencyAffordanceManager.needsEmergencyAffordance()) { + mItems.add(new EmergencyAction()); + } } else if (GLOBAL_ACTION_KEY_SCREENSHOT.equals(actionKey)) { mItems.add(new ScreenshotAction()); } else if (GLOBAL_ACTION_KEY_LOGOUT.equals(actionKey)) { @@ -441,6 +448,32 @@ class GlobalActionsDialog implements DialogInterface.OnDismissListener, } } + private class EmergencyAction extends SinglePressAction { + private static final String ACTION_EMERGENCY_DIALER_DIAL = + "com.android.phone.EmergencyDialer.DIAL"; + + private EmergencyAction() { + super(R.drawable.emergency_icon, R.string.global_action_emergency); + } + + @Override + public void onPress() { + Intent intent = new Intent(ACTION_EMERGENCY_DIALER_DIAL); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); + mContext.startActivityAsUser(intent, UserHandle.CURRENT); + } + + @Override + public boolean showDuringKeyguard() { + return true; + } + + @Override + public boolean showBeforeProvisioning() { + return true; + } + } + private final class RestartAction extends SinglePressAction implements LongPressAction { private RestartAction() { super(R.drawable.ic_restart, R.string.global_action_restart); |