diff options
| author | 2014-07-28 13:12:50 -0700 | |
|---|---|---|
| committer | 2014-07-30 14:12:34 -0700 | |
| commit | 1d0a7ccd007e7ce62588212f76db09d2e593b742 (patch) | |
| tree | e7182018a73ef9993a5509ea3b74a3b42a5e1f3b | |
| parent | 0bc94550b46a9eef515e395fb7975781ed5b95e6 (diff) | |
add UiModeManager.ENABLE_CAR_MODE_NO_WAKE_LOCK flag for enableCarMode
- When this flag is set, system no longer keeps the display on while in car mode.
bug: 15472822
Change-Id: I277368be5227eaf96213684598f278c39e4c34db
| -rw-r--r-- | api/current.txt | 1 | ||||
| -rw-r--r-- | core/java/android/app/UiModeManager.java | 13 | ||||
| -rw-r--r-- | services/core/java/com/android/server/UiModeManagerService.java | 16 |
3 files changed, 23 insertions, 7 deletions
diff --git a/api/current.txt b/api/current.txt index a3a99c76a4b6..32c22bde1dba 100644 --- a/api/current.txt +++ b/api/current.txt @@ -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 diff --git a/core/java/android/app/UiModeManager.java b/core/java/android/app/UiModeManager.java index c6731c9df423..f79eb04af0f2 100644 --- a/core/java/android/app/UiModeManager.java +++ b/core/java/android/app/UiModeManager.java @@ -123,7 +123,18 @@ public class UiModeManager { * will switch to the car home activity even if we are already in car mode. */ 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 diff --git a/services/core/java/com/android/server/UiModeManagerService.java b/services/core/java/com/android/server/UiModeManagerService.java index f59edc7f83e3..4c6b772ee8ab 100644 --- a/services/core/java/com/android/server/UiModeManagerService.java +++ b/services/core/java/com/android/server/UiModeManagerService.java @@ -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) { |