am 010bb273: Merge changes I0da0f04f,I93197665 into ics-mr1

* commit '010bb273a58444f907bb82f62f8d7274f9637b49':
  Offer the user an option to launch Dreams when docked.
  Teach UiModeMgr about high-end and low-end desk docks.
This commit is contained in:
Daniel Sandler
2011-11-07 18:13:20 +00:00
committed by Android Git Automerger
4 changed files with 91 additions and 6 deletions

View File

@@ -123,6 +123,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;
}
@@ -151,6 +155,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 +434,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 +498,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 +512,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 +526,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
@@ -526,7 +553,7 @@ class UiModeManagerService extends IUiModeManager.Stub {
if ((enableFlags&UiModeManager.ENABLE_CAR_MODE_GO_CAR_HOME) != 0) {
homeIntent = buildHomeIntent(Intent.CATEGORY_CAR_DOCK);
}
} else if (mDockState == Intent.EXTRA_DOCK_STATE_DESK) {
} else if (isDeskDockState(mDockState)) {
if ((enableFlags&UiModeManager.ENABLE_CAR_MODE_GO_CAR_HOME) != 0) {
homeIntent = buildHomeIntent(Intent.CATEGORY_DESK_DOCK);
}
@@ -535,6 +562,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);