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

Commit a627c388 authored by keunyoung's avatar keunyoung Committed by Android Git Automerger
Browse files

am 669f8f22: am 4d2751c5: Merge "add...

am 669f8f22: am 4d2751c5: Merge "add UiModeManager.ENABLE_CAR_MODE_NO_WAKE_LOCK flag for enableCarMode" into lmp-dev

* commit '669f8f22c9e1b88e151c293300345164e8dfc012':
  add UiModeManager.ENABLE_CAR_MODE_NO_WAKE_LOCK flag for enableCarMode
parents f1ed4bf4 d099c809
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -5219,6 +5219,7 @@ package android.app {
    field public static java.lang.String ACTION_EXIT_DESK_MODE;
    field public static final int DISABLE_CAR_MODE_GO_HOME = 1; // 0x1
    field public static final int ENABLE_CAR_MODE_GO_CAR_HOME = 1; // 0x1
    field public static final int ENABLE_CAR_MODE_NO_WAKE_LOCK = 2; // 0x2
    field public static final int MODE_NIGHT_AUTO = 0; // 0x0
    field public static final int MODE_NIGHT_NO = 1; // 0x1
    field public static final int MODE_NIGHT_YES = 2; // 0x2
+12 −1
Original line number Diff line number Diff line
@@ -124,6 +124,17 @@ public class UiModeManager {
     */
    public static final int ENABLE_CAR_MODE_GO_CAR_HOME = 0x0001;

    /**
     * Flag for use with {@link #enableCarMode(int)}: do not hold full wake lock
     * while in car mode. By default, when this flag is not set, the system may hold
     * a full wake lock to keep the screen turned on while in car mode.
     * Setting this flag disables such behavior and the screen may be turned off if
     * there is no other user activity and no other full wake lock held.
     * Setting this flag can be relevant for a car dock application that does not require the
     * screen kept on.
     */
    public static final int ENABLE_CAR_MODE_NO_WAKE_LOCK = 0x0002;

    /**
     * Force device into car mode, like it had been placed in the car dock.
     * This will cause the device to switch to the car home UI as part of
+10 −6
Original line number Diff line number Diff line
@@ -73,6 +73,7 @@ final class UiModeManagerService extends SystemService {
    private boolean mTelevision;
    private boolean mWatch;
    private boolean mComputedNightMode;
    private int mCarModeEnableFlags;

    int mCurUiMode = 0;
    private int mSetUiMode = 0;
@@ -193,7 +194,7 @@ final class UiModeManagerService extends SystemService {
            final long ident = Binder.clearCallingIdentity();
            try {
                synchronized (mLock) {
                    setCarModeLocked(true);
                    setCarModeLocked(true, flags);
                    if (mSystemReady) {
                        updateLocked(flags, 0);
                    }
@@ -208,7 +209,7 @@ final class UiModeManagerService extends SystemService {
            final long ident = Binder.clearCallingIdentity();
            try {
                synchronized (mLock) {
                    setCarModeLocked(false);
                    setCarModeLocked(false, 0);
                    if (mSystemReady) {
                        updateLocked(0, flags);
                    }
@@ -285,7 +286,8 @@ final class UiModeManagerService extends SystemService {
                    pw.print(" mLastBroadcastState="); pw.println(mLastBroadcastState);
            pw.print("  mNightMode="); pw.print(mNightMode);
                    pw.print(" mCarModeEnabled="); pw.print(mCarModeEnabled);
                    pw.print(" mComputedNightMode="); pw.println(mComputedNightMode);
                    pw.print(" mComputedNightMode="); pw.print(mComputedNightMode);
                    pw.print(" mCarModeEnableFlags="); pw.println(mCarModeEnableFlags);
            pw.print("  mCurUiMode=0x"); pw.print(Integer.toHexString(mCurUiMode));
                    pw.print(" mSetUiMode=0x"); pw.println(Integer.toHexString(mSetUiMode));
            pw.print("  mHoldingConfiguration="); pw.print(mHoldingConfiguration);
@@ -311,17 +313,18 @@ final class UiModeManagerService extends SystemService {
        return mCarModeEnabled || mDockState != Intent.EXTRA_DOCK_STATE_UNDOCKED;
    }

    void setCarModeLocked(boolean enabled) {
    void setCarModeLocked(boolean enabled, int flags) {
        if (mCarModeEnabled != enabled) {
            mCarModeEnabled = enabled;
        }
        mCarModeEnableFlags = flags;
    }

    private void updateDockState(int newState) {
        synchronized (mLock) {
            if (newState != mDockState) {
                mDockState = newState;
                setCarModeLocked(mDockState == Intent.EXTRA_DOCK_STATE_CAR);
                setCarModeLocked(mDockState == Intent.EXTRA_DOCK_STATE_CAR, 0);
                if (mSystemReady) {
                    updateLocked(UiModeManager.ENABLE_CAR_MODE_GO_CAR_HOME, 0);
                }
@@ -475,7 +478,8 @@ final class UiModeManagerService extends SystemService {

        // keep screen on when charging and in car mode
        boolean keepScreenOn = mCharging &&
                ((mCarModeEnabled && mCarModeKeepsScreenOn) ||
                ((mCarModeEnabled && mCarModeKeepsScreenOn &&
                  (mCarModeEnableFlags & UiModeManager.ENABLE_CAR_MODE_NO_WAKE_LOCK) == 0) ||
                 (mCurUiMode == Configuration.UI_MODE_TYPE_DESK && mDeskModeKeepsScreenOn));
        if (keepScreenOn != mWakeLock.isHeld()) {
            if (keepScreenOn) {