|
16 | 16 |
|
17 | 17 | package com.android.commands.svc; |
18 | 18 |
|
19 | | -import android.os.Binder; |
20 | | -import android.os.IBinder; |
| 19 | +import android.content.Context; |
| 20 | +import android.os.BatteryManager; |
21 | 21 | import android.os.IPowerManager; |
22 | | -import android.os.PowerManager; |
23 | | -import android.os.ServiceManager; |
24 | 22 | import android.os.RemoteException; |
25 | | -import android.os.BatteryManager; |
26 | | -import android.content.Context; |
| 23 | +import android.os.ServiceManager; |
| 24 | +import android.os.SystemClock; |
27 | 25 |
|
28 | 26 | public class PowerCommand extends Svc.Command { |
29 | 27 | public PowerCommand() { |
@@ -65,10 +63,12 @@ else if ("false".equals(args[2])) { |
65 | 63 | IPowerManager pm |
66 | 64 | = IPowerManager.Stub.asInterface(ServiceManager.getService(Context.POWER_SERVICE)); |
67 | 65 | try { |
68 | | - IBinder lock = new Binder(); |
69 | | - pm.acquireWakeLock(lock, PowerManager.FULL_WAKE_LOCK, "svc power", null); |
| 66 | + if (val != 0) { |
| 67 | + // if the request is not to set it to false, wake up the screen so that |
| 68 | + // it can stay on as requested |
| 69 | + pm.wakeUp(SystemClock.uptimeMillis()); |
| 70 | + } |
70 | 71 | pm.setStayOnSetting(val); |
71 | | - pm.releaseWakeLock(lock, 0); |
72 | 72 | } |
73 | 73 | catch (RemoteException e) { |
74 | 74 | System.err.println("Faild to set setting: " + e); |
|
0 commit comments