Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 36d9d5bc authored by Wesley.CW Wang's avatar Wesley.CW Wang Committed by Leo Hsu
Browse files

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

Bug: 112168722
Bug: 80376488

Change-Id: If359662a4d60dbe0ded89c3afe35db91dca4c445
Merged-In: I9c920e31433c0ac23165f917d8dd2befaaa4938d
Merged-In: If359662a4d60dbe0ded89c3afe35db91dca4c445
parent d6301096
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -11235,6 +11235,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
+2 −0
Original line number Diff line number Diff line
@@ -2613,6 +2613,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
         -->
@@ -2622,6 +2623,7 @@
        <item>lockdown</item>
        <item>logout</item>
        <item>bugreport</item>
        <item>emergency</item>
        <item>screenshot</item>
    </string-array>

+1 −0
Original line number Diff line number Diff line
@@ -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,
+33 −0
Original line number Diff line number Diff line
@@ -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);