diff options
| author | 2018-05-28 16:39:27 +0800 | |
|---|---|---|
| committer | 2018-06-14 15:06:20 +0800 | |
| commit | 8d07276f23c4d5c4f25ff8d157d0b668bf67664c (patch) | |
| tree | 2fed89a7e0c015bb1ed67882b98b524f0a70552e | |
| parent | eae063ebe7c7c2cc69a3f8c1556ebbf9cf1a3594 (diff) | |
Add emergency dialer option on power menu
Add a button on power menu to launch emergency dialer.
Add FASTER_EMERGENCY_PHONE_CALL_ENABLED to SettingsBackupTest blacklist.
Test: Manually
Change-Id: I9c920e31433c0ac23165f917d8dd2befaaa4938d
Bug: 80376488
4 files changed, 44 insertions, 0 deletions
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index 67778d3911e5..54d0950f319d 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -11253,6 +11253,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 b0ecb3ecf11d..4a993422169d 100644 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -2555,6 +2555,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 --> @@ -2564,6 +2565,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 3d9e7d2ed7ed..7f2cd19dc89e 100644 --- a/core/tests/coretests/src/android/provider/SettingsBackupTest.java +++ b/core/tests/coretests/src/android/provider/SettingsBackupTest.java @@ -237,6 +237,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); |