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

Commit 76b1e3d4 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add a Standby option to PowerKey menu" into main

parents de2329b2 5085736f
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="24dp"
    android:height="24dp"
    android:viewportWidth="960"
    android:viewportHeight="960"
    android:tint="?attr/colorControlNormal">
  <path
      android:fillColor="@android:color/white"
      android:pathData="M480,600Q530,600 565,565Q600,530 600,480Q600,430 565,395Q530,360 480,360Q430,360 395,395Q360,430 360,480Q360,530 395,565Q430,600 480,600ZM480,880Q397,880 324,848.5Q251,817 197,763Q143,709 111.5,636Q80,563 80,480Q80,397 111.5,324Q143,251 197,197Q251,143 324,111.5Q397,80 480,80Q563,80 636,111.5Q709,143 763,197Q817,251 848.5,324Q880,397 880,480Q880,563 848.5,636Q817,709 763,763Q709,817 636,848.5Q563,880 480,880ZM480,800Q614,800 707,707Q800,614 800,480Q800,346 707,253Q614,160 480,160Q346,160 253,253Q160,346 160,480Q160,614 253,707Q346,800 480,800ZM480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Q480,480 480,480Z"/>
</vector>
+1 −0
Original line number Diff line number Diff line
@@ -3836,6 +3836,7 @@
         "lockdown" = Lock down device until the user authenticates
         "logout" =  Logout the current user
         "system_update" = Launch System Update screen
         "standby" = Bring the device to standby
         -->
    <string-array translatable="false" name="config_globalActionsList">
        <item>emergency</item>
+3 −0
Original line number Diff line number Diff line
@@ -739,6 +739,9 @@
    <!-- label for screenshot item in power menu [CHAR LIMIT=24]-->
    <string name="global_action_screenshot">Screenshot</string>
    <!-- label for standby item in power menu [CHAR LIMIT=24]-->
    <string name="global_action_standby">Standby</string>
    <!-- Take bug report menu title [CHAR LIMIT=30] -->
    <string name="bugreport_title">Bug report</string>
    <!-- Message in bugreport dialog describing what it does [CHAR LIMIT=NONE] -->
+2 −0
Original line number Diff line number Diff line
@@ -1958,6 +1958,7 @@
  <java-symbol type="string" name="global_action_voice_assist" />
  <java-symbol type="string" name="global_action_assist" />
  <java-symbol type="string" name="global_action_screenshot" />
  <java-symbol type="string" name="global_action_standby" />
  <java-symbol type="string" name="invalidPuk" />
  <java-symbol type="string" name="lockscreen_carrier_default" />
  <java-symbol type="style" name="Animation.LockScreen" />
@@ -3721,6 +3722,7 @@
  <java-symbol type="drawable" name="ic_screenshot" />
  <java-symbol type="drawable" name="ic_faster_emergency" />
  <java-symbol type="drawable" name="ic_media_seamless" />
  <java-symbol type="drawable" name="ic_standby" />
  <java-symbol type="drawable" name="emergency_icon" />

  <java-symbol type="array" name="config_convert_to_emergency_number_map" />
+43 −2
Original line number Diff line number Diff line
@@ -58,7 +58,9 @@ import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.os.PowerManager;
import android.os.RemoteException;
import android.os.SystemClock;
import android.os.SystemProperties;
import android.os.Trace;
import android.os.UserHandle;
@@ -194,6 +196,7 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene
    static final String GLOBAL_ACTION_KEY_EMERGENCY = "emergency";
    static final String GLOBAL_ACTION_KEY_SCREENSHOT = "screenshot";
    static final String GLOBAL_ACTION_KEY_SYSTEM_UPDATE = "system_update";
    static final String GLOBAL_ACTION_KEY_STANDBY = "standby";

    // See NotificationManagerService#scheduleDurationReachedLocked
    private static final long TOAST_FADE_TIME = 333;
@@ -270,6 +273,7 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene
    private final UserLogoutInteractor mLogoutInteractor;
    private final GlobalActionsInteractor mInteractor;
    private final Lazy<DisplayWindowPropertiesRepository> mDisplayWindowPropertiesRepositoryLazy;
    private final PowerManager mPowerManager;
    private final Handler mHandler;

    private final UserTracker.Callback mOnUserSwitched = new UserTracker.Callback() {
@@ -341,7 +345,10 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene
        GA_CLOSE_POWER_VOLUP(811),

        @UiEvent(doc = "System Update button was pressed.")
        GA_SYSTEM_UPDATE_PRESS(1716);
        GA_SYSTEM_UPDATE_PRESS(1716),

        @UiEvent(doc = "The global actions standby button was pressed.")
        GA_STANDBY_PRESS(2210);

        private final int mId;

@@ -396,7 +403,8 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene
            SelectedUserInteractor selectedUserInteractor,
            UserLogoutInteractor logoutInteractor,
            GlobalActionsInteractor interactor,
            Lazy<DisplayWindowPropertiesRepository> displayWindowPropertiesRepository) {
            Lazy<DisplayWindowPropertiesRepository> displayWindowPropertiesRepository,
            PowerManager powerManager) {
        mContext = context;
        mWindowManagerFuncs = windowManagerFuncs;
        mAudioManager = audioManager;
@@ -434,6 +442,7 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene
        mLogoutInteractor = logoutInteractor;
        mInteractor = interactor;
        mDisplayWindowPropertiesRepositoryLazy = displayWindowPropertiesRepository;
        mPowerManager = powerManager;

        mHandler = new Handler(mMainHandler.getLooper()) {
            public void handleMessage(Message msg) {
@@ -697,6 +706,8 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene
                }
            } else if (GLOBAL_ACTION_KEY_SYSTEM_UPDATE.equals(actionKey)) {
                addIfShouldShowAction(tempActions, new SystemUpdateAction());
            } else if (GLOBAL_ACTION_KEY_STANDBY.equals(actionKey)) {
                addIfShouldShowAction(tempActions, new StandbyAction());
            } else {
                Log.e(TAG, "Invalid global action key " + actionKey);
            }
@@ -1245,6 +1256,36 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene
        }
    }

    @VisibleForTesting
    class StandbyAction extends SinglePressAction {
        StandbyAction() {
            super(R.drawable.ic_standby, R.string.global_action_standby);
        }

        @Override
        public void onPress() {
            // Add a little delay before executing, to give the dialog a chance to go away before
            // going to sleep. Otherwise, we see screen flicker randomly.
            mHandler.postDelayed(() -> {
                mUiEventLogger.log(GlobalActionsEvent.GA_STANDBY_PRESS);
                mBackgroundExecutor.execute(() -> {
                    mPowerManager.goToSleep(SystemClock.uptimeMillis(),
                            PowerManager.GO_TO_SLEEP_REASON_POWER_BUTTON, 0);
                });
            }, mDialogPressDelay);
        }

        @Override
        public boolean showDuringKeyguard() {
            return true;
        }

        @Override
        public boolean showBeforeProvisioning() {
            return true;
        }
    }

    private Action getSettingsAction() {
        return new SinglePressAction(R.drawable.ic_settings,
                R.string.global_action_settings) {
Loading