diff options
Diffstat (limited to 'services/java/com/android/server/UiModeManagerService.java')
| -rw-r--r-- | services/java/com/android/server/UiModeManagerService.java | 61 |
1 files changed, 51 insertions, 10 deletions
diff --git a/services/java/com/android/server/UiModeManagerService.java b/services/java/com/android/server/UiModeManagerService.java index 431cc39..e6392d7 100644 --- a/services/java/com/android/server/UiModeManagerService.java +++ b/services/java/com/android/server/UiModeManagerService.java @@ -63,6 +63,10 @@ class UiModeManagerService extends IUiModeManager.Stub { private static final String KEY_LAST_UPDATE_INTERVAL = "LAST_UPDATE_INTERVAL"; + // Enable launching of applications when entering the dock. + private static final boolean ENABLE_LAUNCH_CAR_DOCK_APP = true; + private static final boolean ENABLE_LAUNCH_DESK_DOCK_APP = false; + private static final int MSG_UPDATE_TWILIGHT = 0; private static final int MSG_ENABLE_LOCATION_UPDATES = 1; private static final int MSG_GET_NEW_LOCATION_UPDATE = 2; @@ -123,6 +127,10 @@ class UiModeManagerService extends IUiModeManager.Stub { @Override public void onReceive(Context context, Intent intent) { if (getResultCode() != Activity.RESULT_OK) { + if (LOG) { + Slog.v(TAG, "Handling broadcast result for action " + intent.getAction() + + ": canceled: " + getResultCode()); + } return; } @@ -135,14 +143,16 @@ class UiModeManagerService extends IUiModeManager.Stub { if (UiModeManager.ACTION_ENTER_CAR_MODE.equals(intent.getAction())) { // Only launch car home when car mode is enabled and the caller // has asked us to switch to it. - if ((enableFlags&UiModeManager.ENABLE_CAR_MODE_GO_CAR_HOME) != 0) { + if (ENABLE_LAUNCH_CAR_DOCK_APP + && (enableFlags&UiModeManager.ENABLE_CAR_MODE_GO_CAR_HOME) != 0) { category = Intent.CATEGORY_CAR_DOCK; } } else if (UiModeManager.ACTION_ENTER_DESK_MODE.equals(intent.getAction())) { // Only launch car home when desk mode is enabled and the caller // has asked us to switch to it. Currently re-using the car // mode flag since we don't have a formal API for "desk mode". - if ((enableFlags&UiModeManager.ENABLE_CAR_MODE_GO_CAR_HOME) != 0) { + if (ENABLE_LAUNCH_DESK_DOCK_APP + && (enableFlags&UiModeManager.ENABLE_CAR_MODE_GO_CAR_HOME) != 0) { category = Intent.CATEGORY_DESK_DOCK; } } else { @@ -151,6 +161,12 @@ class UiModeManagerService extends IUiModeManager.Stub { category = Intent.CATEGORY_HOME; } } + + if (LOG) { + Slog.v(TAG, String.format( + "Handling broadcast result for action %s: enable=0x%08x disable=0x%08x category=%s", + intent.getAction(), enableFlags, disableFlags, category)); + } if (category != null) { // This is the new activity that will serve as home while @@ -424,11 +440,22 @@ class UiModeManagerService extends IUiModeManager.Stub { } } + final static boolean isDeskDockState(int state) { + switch (state) { + case Intent.EXTRA_DOCK_STATE_DESK: + case Intent.EXTRA_DOCK_STATE_LE_DESK: + case Intent.EXTRA_DOCK_STATE_HE_DESK: + return true; + default: + return false; + } + } + final void updateConfigurationLocked(boolean sendIt) { int uiMode = Configuration.UI_MODE_TYPE_NORMAL; if (mCarModeEnabled) { uiMode = Configuration.UI_MODE_TYPE_CAR; - } else if (mDockState == Intent.EXTRA_DOCK_STATE_DESK) { + } else if (isDeskDockState(mDockState)) { uiMode = Configuration.UI_MODE_TYPE_DESK; } if (mCarModeEnabled) { @@ -477,7 +504,7 @@ class UiModeManagerService extends IUiModeManager.Stub { if (mLastBroadcastState == Intent.EXTRA_DOCK_STATE_CAR) { adjustStatusBarCarModeLocked(); oldAction = UiModeManager.ACTION_EXIT_CAR_MODE; - } else if (mLastBroadcastState == Intent.EXTRA_DOCK_STATE_DESK) { + } else if (isDeskDockState(mLastBroadcastState)) { oldAction = UiModeManager.ACTION_EXIT_DESK_MODE; } @@ -491,12 +518,12 @@ class UiModeManagerService extends IUiModeManager.Stub { mLastBroadcastState = Intent.EXTRA_DOCK_STATE_CAR; action = UiModeManager.ACTION_ENTER_CAR_MODE; } - } else if (mDockState == Intent.EXTRA_DOCK_STATE_DESK) { - if (mLastBroadcastState != Intent.EXTRA_DOCK_STATE_DESK) { + } else if (isDeskDockState(mDockState)) { + if (!isDeskDockState(mLastBroadcastState)) { if (oldAction != null) { mContext.sendBroadcast(new Intent(oldAction)); } - mLastBroadcastState = Intent.EXTRA_DOCK_STATE_DESK; + mLastBroadcastState = mDockState; action = UiModeManager.ACTION_ENTER_DESK_MODE; } } else { @@ -505,6 +532,12 @@ class UiModeManagerService extends IUiModeManager.Stub { } if (action != null) { + if (LOG) { + Slog.v(TAG, String.format( + "updateLocked: preparing broadcast: action=%s enable=0x%08x disable=0x%08x", + action, enableFlags, disableFlags)); + } + // Send the ordered broadcast; the result receiver will receive after all // broadcasts have been sent. If any broadcast receiver changes the result // code from the initial value of RESULT_OK, then the result receiver will @@ -523,11 +556,13 @@ class UiModeManagerService extends IUiModeManager.Stub { } else { Intent homeIntent = null; if (mCarModeEnabled) { - if ((enableFlags&UiModeManager.ENABLE_CAR_MODE_GO_CAR_HOME) != 0) { + if (ENABLE_LAUNCH_CAR_DOCK_APP + && (enableFlags&UiModeManager.ENABLE_CAR_MODE_GO_CAR_HOME) != 0) { homeIntent = buildHomeIntent(Intent.CATEGORY_CAR_DOCK); } - } else if (mDockState == Intent.EXTRA_DOCK_STATE_DESK) { - if ((enableFlags&UiModeManager.ENABLE_CAR_MODE_GO_CAR_HOME) != 0) { + } else if (isDeskDockState(mDockState)) { + if (ENABLE_LAUNCH_DESK_DOCK_APP + && (enableFlags&UiModeManager.ENABLE_CAR_MODE_GO_CAR_HOME) != 0) { homeIntent = buildHomeIntent(Intent.CATEGORY_DESK_DOCK); } } else { @@ -535,6 +570,12 @@ class UiModeManagerService extends IUiModeManager.Stub { homeIntent = buildHomeIntent(Intent.CATEGORY_HOME); } } + + if (LOG) { + Slog.v(TAG, "updateLocked: null action, mDockState=" + + mDockState +", firing homeIntent: " + homeIntent); + } + if (homeIntent != null) { try { mContext.startActivity(homeIntent); |
