Skip to content

Commit 11ddf53

Browse files
committed
Disable desk dock apps.
When a device is attached to a desk dock, the CATEGORY_DESK_DOCK intent will no longer be fired. As a side effect, the "dock home" behavior (which captures the home key for the dock app as long as the device is docked) is now disabled for desk docks. Car docks are unchanged. Bug: 5591015 Change-Id: I7884f655913c31cf53b88cb2e2b371987be27f64
1 parent c224f76 commit 11ddf53

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;
@@ -3500,21 +3505,35 @@ void updateRotation(boolean alwaysSendConfiguration) {
35003505
}
35013506

35023507
/**
3503-
* Return an Intent to launch the currently active dock as home. Returns
3504-
* null if the standard home should be launched.
3508+
* Return an Intent to launch the currently active dock app as home. Returns
3509+
* null if the standard home should be launched, which is the case if any of the following is
3510+
* true:
3511+
* <ul>
3512+
* <li>The device is not in either car mode or desk mode
3513+
* <li>The device is in car mode but ENABLE_CAR_DOCK_HOME_CAPTURE is false
3514+
* <li>The device is in desk mode but ENABLE_DESK_DOCK_HOME_CAPTURE is false
3515+
* <li>The device is in car mode but there's no CAR_DOCK app with METADATA_DOCK_HOME
3516+
* <li>The device is in desk mode but there's no DESK_DOCK app with METADATA_DOCK_HOME
3517+
* </ul>
35053518
* @return
35063519
*/
35073520
Intent createHomeDockIntent() {
3508-
Intent intent;
3521+
Intent intent = null;
35093522

35103523
// What home does is based on the mode, not the dock state. That
35113524
// is, when in car mode you should be taken to car home regardless
35123525
// of whether we are actually in a car dock.
35133526
if (mUiMode == Configuration.UI_MODE_TYPE_CAR) {
3514-
intent = mCarDockIntent;
3527+
if (ENABLE_CAR_DOCK_HOME_CAPTURE) {
3528+
intent = mCarDockIntent;
3529+
}
35153530
} else if (mUiMode == Configuration.UI_MODE_TYPE_DESK) {
3516-
intent = mDeskDockIntent;
3517-
} else {
3531+
if (ENABLE_DESK_DOCK_HOME_CAPTURE) {
3532+
intent = mDeskDockIntent;
3533+
}
3534+
}
3535+
3536+
if (intent == null) {
35183537
return null;
35193538
}
35203539

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)