Skip to content

Commit 786546e

Browse files
author
John Spurlock
committed
Check the ACTIVATE_ON_DOCK setting in DockObserver.
Otherwise docking the device will always launch a Dream. Change-Id: I2e74ca62f80d7e386d11c00920a75a5a6e78926c
1 parent 85b1041 commit 786546e

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

services/java/com/android/server/DockObserver.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package com.android.server;
1818

19+
import static android.provider.Settings.Secure.SCREENSAVER_ACTIVATE_ON_DOCK;
20+
1921
import com.android.server.power.PowerManagerService;
2022

2123
import android.bluetooth.BluetoothAdapter;
@@ -51,6 +53,8 @@ class DockObserver extends UEventObserver {
5153
private static final String DOCK_UEVENT_MATCH = "DEVPATH=/devices/virtual/switch/dock";
5254
private static final String DOCK_STATE_PATH = "/sys/class/switch/dock/state";
5355

56+
private static final int DEFAULT_DOCK = 1;
57+
5458
private static final int MSG_DOCK_STATE = 0;
5559

5660
private int mDockState = Intent.EXTRA_DOCK_STATE_UNDOCKED;
@@ -131,6 +135,11 @@ private final void update() {
131135
mHandler.sendEmptyMessage(MSG_DOCK_STATE);
132136
}
133137

138+
private static boolean isScreenSaverActivatedOnDock(Context context) {
139+
return 0 != Settings.Secure.getInt(
140+
context.getContentResolver(), SCREENSAVER_ACTIVATE_ON_DOCK, DEFAULT_DOCK);
141+
}
142+
134143
private final Handler mHandler = new Handler() {
135144
@Override
136145
public void handleMessage(Message msg) {
@@ -210,10 +219,12 @@ public void handleMessage(Message msg) {
210219
Slog.w(TAG, "Unable to awaken!", e);
211220
}
212221
} else {
213-
try {
214-
mgr.dream();
215-
} catch (RemoteException e) {
216-
Slog.w(TAG, "Unable to dream!", e);
222+
if (isScreenSaverActivatedOnDock(mContext)) {
223+
try {
224+
mgr.dream();
225+
} catch (RemoteException e) {
226+
Slog.w(TAG, "Unable to dream!", e);
227+
}
217228
}
218229
}
219230
} else {

0 commit comments

Comments
 (0)