Skip to content

Commit d5decdc

Browse files
dsandlerAndroid (Google) Code Review
authored andcommitted
Merge "Disable desk dock apps." into ics-mr1
2 parents 8fc3540 + 11ddf53 commit d5decdc

File tree

2 files changed

+37
-10
lines changed

2 files changed

+37
-10
lines changed

policy/src/com/android/internal/policy/impl/PhoneWindowManager.java

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,11 @@ public class PhoneWindowManager implements WindowManagerPolicy {
157157
static final boolean SHOW_STARTING_ANIMATIONS = true;
158158
static final boolean SHOW_PROCESSES_ON_ALT_MENU = false;
159159

160+
// Whether to allow dock apps with METADATA_DOCK_HOME to temporarily take over the Home key.
161+
// No longer recommended for desk docks; still useful in car docks.
162+
static final boolean ENABLE_CAR_DOCK_HOME_CAPTURE = true;
163+
static final boolean ENABLE_DESK_DOCK_HOME_CAPTURE = false;
164+
160165
static final int LONG_PRESS_POWER_NOTHING = 0;
161166
static final int LONG_PRESS_POWER_GLOBAL_ACTIONS = 1;
162167
static final int LONG_PRESS_POWER_SHUT_OFF = 2;
@@ -3511,21 +3516,35 @@ void updateRotation(boolean alwaysSendConfiguration) {
35113516
}
35123517

35133518
/**
3514-
* Return an Intent to launch the currently active dock as home. Returns
3515-
* null if the standard home should be launched.
3519+
* Return an Intent to launch the currently active dock app as home. Returns
3520+
* null if the standard home should be launched, which is the case if any of the following is
3521+
* true:
3522+
* <ul>
3523+
* <li>The device is not in either car mode or desk mode
3524+
* <li>The device is in car mode but ENABLE_CAR_DOCK_HOME_CAPTURE is false
3525+
* <li>The device is in desk mode but ENABLE_DESK_DOCK_HOME_CAPTURE is false
3526+
* <li>The device is in car mode but there's no CAR_DOCK app with METADATA_DOCK_HOME
3527+
* <li>The device is in desk mode but there's no DESK_DOCK app with METADATA_DOCK_HOME
3528+
* </ul>
35163529
* @return
35173530
*/
35183531
Intent createHomeDockIntent() {
3519-
Intent intent;
3532+
Intent intent = null;
35203533

35213534
// What home does is based on the mode, not the dock state. That
35223535
// is, when in car mode you should be taken to car home regardless
35233536
// of whether we are actually in a car dock.
35243537
if (mUiMode == Configuration.UI_MODE_TYPE_CAR) {
3525-
intent = mCarDockIntent;
3538+
if (ENABLE_CAR_DOCK_HOME_CAPTURE) {
3539+
intent = mCarDockIntent;
3540+
}
35263541
} else if (mUiMode == Configuration.UI_MODE_TYPE_DESK) {
3527-
intent = mDeskDockIntent;
3528-
} else {
3542+
if (ENABLE_DESK_DOCK_HOME_CAPTURE) {
3543+
intent = mDeskDockIntent;
3544+
}
3545+
}
3546+
3547+
if (intent == null) {
35293548
return null;
35303549
}
35313550

services/java/com/android/server/UiModeManagerService.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ class UiModeManagerService extends IUiModeManager.Stub {
6363

6464
private static final String KEY_LAST_UPDATE_INTERVAL = "LAST_UPDATE_INTERVAL";
6565

66+
// Enable launching of applications when entering the dock.
67+
private static final boolean ENABLE_LAUNCH_CAR_DOCK_APP = true;
68+
private static final boolean ENABLE_LAUNCH_DESK_DOCK_APP = false;
69+
6670
private static final int MSG_UPDATE_TWILIGHT = 0;
6771
private static final int MSG_ENABLE_LOCATION_UPDATES = 1;
6872
private static final int MSG_GET_NEW_LOCATION_UPDATE = 2;
@@ -139,14 +143,16 @@ public void onReceive(Context context, Intent intent) {
139143
if (UiModeManager.ACTION_ENTER_CAR_MODE.equals(intent.getAction())) {
140144
// Only launch car home when car mode is enabled and the caller
141145
// has asked us to switch to it.
142-
if ((enableFlags&UiModeManager.ENABLE_CAR_MODE_GO_CAR_HOME) != 0) {
146+
if (ENABLE_LAUNCH_CAR_DOCK_APP
147+
&& (enableFlags&UiModeManager.ENABLE_CAR_MODE_GO_CAR_HOME) != 0) {
143148
category = Intent.CATEGORY_CAR_DOCK;
144149
}
145150
} else if (UiModeManager.ACTION_ENTER_DESK_MODE.equals(intent.getAction())) {
146151
// Only launch car home when desk mode is enabled and the caller
147152
// has asked us to switch to it. Currently re-using the car
148153
// mode flag since we don't have a formal API for "desk mode".
149-
if ((enableFlags&UiModeManager.ENABLE_CAR_MODE_GO_CAR_HOME) != 0) {
154+
if (ENABLE_LAUNCH_DESK_DOCK_APP
155+
&& (enableFlags&UiModeManager.ENABLE_CAR_MODE_GO_CAR_HOME) != 0) {
150156
category = Intent.CATEGORY_DESK_DOCK;
151157
}
152158
} else {
@@ -550,11 +556,13 @@ final void updateLocked(int enableFlags, int disableFlags) {
550556
} else {
551557
Intent homeIntent = null;
552558
if (mCarModeEnabled) {
553-
if ((enableFlags&UiModeManager.ENABLE_CAR_MODE_GO_CAR_HOME) != 0) {
559+
if (ENABLE_LAUNCH_CAR_DOCK_APP
560+
&& (enableFlags&UiModeManager.ENABLE_CAR_MODE_GO_CAR_HOME) != 0) {
554561
homeIntent = buildHomeIntent(Intent.CATEGORY_CAR_DOCK);
555562
}
556563
} else if (isDeskDockState(mDockState)) {
557-
if ((enableFlags&UiModeManager.ENABLE_CAR_MODE_GO_CAR_HOME) != 0) {
564+
if (ENABLE_LAUNCH_DESK_DOCK_APP
565+
&& (enableFlags&UiModeManager.ENABLE_CAR_MODE_GO_CAR_HOME) != 0) {
558566
homeIntent = buildHomeIntent(Intent.CATEGORY_DESK_DOCK);
559567
}
560568
} else {

0 commit comments

Comments
 (0)