blob: 8bc903b96bcfc5475f39d56d1c7725e9f80d9340 [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
2 * Copyright (C) 2007 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.os;
18
Dianne Hackborneb94fa72014-06-03 17:48:12 -070019import android.annotation.SdkConstant;
Jeff Brown0a571122014-08-21 21:50:43 -070020import android.annotation.SystemApi;
Jeff Brown96307042012-07-27 15:51:34 -070021import android.content.Context;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080022import android.util.Log;
23
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080024/**
Jeff Brown1244cda2012-06-19 16:44:46 -070025 * This class gives you control of the power state of the device.
26 *
27 * <p>
28 * <b>Device battery life will be significantly affected by the use of this API.</b>
29 * Do not acquire {@link WakeLock}s unless you really need them, use the minimum levels
30 * possible, and be sure to release them as soon as possible.
31 * </p><p>
32 * You can obtain an instance of this class by calling
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080033 * {@link android.content.Context#getSystemService(java.lang.String) Context.getSystemService()}.
Jeff Brown1244cda2012-06-19 16:44:46 -070034 * </p><p>
35 * The primary API you'll use is {@link #newWakeLock(int, String) newWakeLock()}.
36 * This will create a {@link PowerManager.WakeLock} object. You can then use methods
37 * on the wake lock object to control the power state of the device.
38 * </p><p>
39 * In practice it's quite simple:
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080040 * {@samplecode
41 * PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
42 * PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "My Tag");
43 * wl.acquire();
44 * ..screen will stay on during this section..
45 * wl.release();
46 * }
Jeff Brown1244cda2012-06-19 16:44:46 -070047 * </p><p>
Jeff Brown96307042012-07-27 15:51:34 -070048 * The following wake lock levels are defined, with varying effects on system power.
49 * <i>These levels are mutually exclusive - you may only specify one of them.</i>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080050 *
Dirk Dougherty7b9a2882012-10-28 12:07:08 -070051 * <table>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080052 * <tr><th>Flag Value</th>
53 * <th>CPU</th> <th>Screen</th> <th>Keyboard</th></tr>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080054 *
Dirk Dougherty7b9a2882012-10-28 12:07:08 -070055 * <tr><td>{@link #PARTIAL_WAKE_LOCK}</td>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080056 * <td>On*</td> <td>Off</td> <td>Off</td>
57 * </tr>
58 *
Dirk Dougherty7b9a2882012-10-28 12:07:08 -070059 * <tr><td>{@link #SCREEN_DIM_WAKE_LOCK}</td>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080060 * <td>On</td> <td>Dim</td> <td>Off</td>
61 * </tr>
62 *
Dirk Dougherty7b9a2882012-10-28 12:07:08 -070063 * <tr><td>{@link #SCREEN_BRIGHT_WAKE_LOCK}</td>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080064 * <td>On</td> <td>Bright</td> <td>Off</td>
65 * </tr>
66 *
Dirk Dougherty7b9a2882012-10-28 12:07:08 -070067 * <tr><td>{@link #FULL_WAKE_LOCK}</td>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080068 * <td>On</td> <td>Bright</td> <td>Bright</td>
69 * </tr>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080070 * </table>
Jeff Brown1244cda2012-06-19 16:44:46 -070071 * </p><p>
72 * *<i>If you hold a partial wake lock, the CPU will continue to run, regardless of any
73 * display timeouts or the state of the screen and even after the user presses the power button.
74 * In all other wake locks, the CPU will run, but the user can still put the device to sleep
75 * using the power button.</i>
76 * </p><p>
77 * In addition, you can add two more flags, which affect behavior of the screen only.
Dirk Dougherty7b9a2882012-10-28 12:07:08 -070078 * <i>These flags have no effect when combined with a {@link #PARTIAL_WAKE_LOCK}.</i></p>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080079 *
Dirk Dougherty7b9a2882012-10-28 12:07:08 -070080 * <table>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080081 * <tr><th>Flag Value</th> <th>Description</th></tr>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080082 *
Dirk Dougherty7b9a2882012-10-28 12:07:08 -070083 * <tr><td>{@link #ACQUIRE_CAUSES_WAKEUP}</td>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080084 * <td>Normal wake locks don't actually turn on the illumination. Instead, they cause
85 * the illumination to remain on once it turns on (e.g. from user activity). This flag
86 * will force the screen and/or keyboard to turn on immediately, when the WakeLock is
87 * acquired. A typical use would be for notifications which are important for the user to
88 * see immediately.</td>
89 * </tr>
90 *
Dirk Dougherty7b9a2882012-10-28 12:07:08 -070091 * <tr><td>{@link #ON_AFTER_RELEASE}</td>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080092 * <td>If this flag is set, the user activity timer will be reset when the WakeLock is
93 * released, causing the illumination to remain on a bit longer. This can be used to
94 * reduce flicker if you are cycling between wake lock conditions.</td>
95 * </tr>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080096 * </table>
Dirk Dougherty7b9a2882012-10-28 12:07:08 -070097 * <p>
Kenny Rootd710fb52011-03-15 17:39:45 -070098 * Any application using a WakeLock must request the {@code android.permission.WAKE_LOCK}
Neil Fuller71fbb812015-11-30 09:51:33 +000099 * permission in an {@code <uses-permission>} element of the application's manifest.
Jeff Brown1244cda2012-06-19 16:44:46 -0700100 * </p>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800101 */
Jeff Brown1244cda2012-06-19 16:44:46 -0700102public final class PowerManager {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800103 private static final String TAG = "PowerManager";
Jeff Brown1244cda2012-06-19 16:44:46 -0700104
Jeff Brown155fc702012-07-27 12:12:15 -0700105 /* NOTE: Wake lock levels were previously defined as a bit field, except that only a few
106 * combinations were actually supported so the bit field was removed. This explains
107 * why the numbering scheme is so odd. If adding a new wake lock level, any unused
108 * value can be used.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800109 */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800110
111 /**
Jeff Brown1244cda2012-06-19 16:44:46 -0700112 * Wake lock level: Ensures that the CPU is running; the screen and keyboard
113 * backlight will be allowed to go off.
Jeff Brown155fc702012-07-27 12:12:15 -0700114 * <p>
115 * If the user presses the power button, then the screen will be turned off
116 * but the CPU will be kept on until all partial wake locks have been released.
Jeff Brown1244cda2012-06-19 16:44:46 -0700117 * </p>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800118 */
Jeff Brown155fc702012-07-27 12:12:15 -0700119 public static final int PARTIAL_WAKE_LOCK = 0x00000001;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800120
121 /**
Jeff Brown155fc702012-07-27 12:12:15 -0700122 * Wake lock level: Ensures that the screen is on (but may be dimmed);
Jeff Brown1244cda2012-06-19 16:44:46 -0700123 * the keyboard backlight will be allowed to go off.
Jeff Brown155fc702012-07-27 12:12:15 -0700124 * <p>
125 * If the user presses the power button, then the {@link #SCREEN_DIM_WAKE_LOCK} will be
126 * implicitly released by the system, causing both the screen and the CPU to be turned off.
127 * Contrast with {@link #PARTIAL_WAKE_LOCK}.
128 * </p>
Jeff Brown1244cda2012-06-19 16:44:46 -0700129 *
Dianne Hackborn9567a662011-04-19 18:44:03 -0700130 * @deprecated Most applications should use
131 * {@link android.view.WindowManager.LayoutParams#FLAG_KEEP_SCREEN_ON} instead
132 * of this type of wake lock, as it will be correctly managed by the platform
133 * as the user moves between applications and doesn't require a special permission.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800134 */
Dianne Hackborn9567a662011-04-19 18:44:03 -0700135 @Deprecated
Jeff Brown155fc702012-07-27 12:12:15 -0700136 public static final int SCREEN_DIM_WAKE_LOCK = 0x00000006;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800137
138 /**
Jeff Brown155fc702012-07-27 12:12:15 -0700139 * Wake lock level: Ensures that the screen is on at full brightness;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800140 * the keyboard backlight will be allowed to go off.
Jeff Brown155fc702012-07-27 12:12:15 -0700141 * <p>
142 * If the user presses the power button, then the {@link #SCREEN_BRIGHT_WAKE_LOCK} will be
143 * implicitly released by the system, causing both the screen and the CPU to be turned off.
144 * Contrast with {@link #PARTIAL_WAKE_LOCK}.
145 * </p>
146 *
147 * @deprecated Most applications should use
148 * {@link android.view.WindowManager.LayoutParams#FLAG_KEEP_SCREEN_ON} instead
149 * of this type of wake lock, as it will be correctly managed by the platform
150 * as the user moves between applications and doesn't require a special permission.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800151 */
Jeff Brown155fc702012-07-27 12:12:15 -0700152 @Deprecated
153 public static final int SCREEN_BRIGHT_WAKE_LOCK = 0x0000000a;
154
155 /**
156 * Wake lock level: Ensures that the screen and keyboard backlight are on at
157 * full brightness.
158 * <p>
159 * If the user presses the power button, then the {@link #FULL_WAKE_LOCK} will be
160 * implicitly released by the system, causing both the screen and the CPU to be turned off.
161 * Contrast with {@link #PARTIAL_WAKE_LOCK}.
162 * </p>
163 *
164 * @deprecated Most applications should use
165 * {@link android.view.WindowManager.LayoutParams#FLAG_KEEP_SCREEN_ON} instead
166 * of this type of wake lock, as it will be correctly managed by the platform
167 * as the user moves between applications and doesn't require a special permission.
168 */
169 @Deprecated
170 public static final int FULL_WAKE_LOCK = 0x0000001a;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800171
172 /**
Jeff Brown1244cda2012-06-19 16:44:46 -0700173 * Wake lock level: Turns the screen off when the proximity sensor activates.
174 * <p>
Jeff Brown93cbbb22012-10-04 13:18:36 -0700175 * If the proximity sensor detects that an object is nearby, the screen turns off
176 * immediately. Shortly after the object moves away, the screen turns on again.
177 * </p><p>
178 * A proximity wake lock does not prevent the device from falling asleep
179 * unlike {@link #FULL_WAKE_LOCK}, {@link #SCREEN_BRIGHT_WAKE_LOCK} and
180 * {@link #SCREEN_DIM_WAKE_LOCK}. If there is no user activity and no other
181 * wake locks are held, then the device will fall asleep (and lock) as usual.
182 * However, the device will not fall asleep while the screen has been turned off
183 * by the proximity sensor because it effectively counts as ongoing user activity.
184 * </p><p>
Jeff Brown96307042012-07-27 15:51:34 -0700185 * Since not all devices have proximity sensors, use {@link #isWakeLockLevelSupported}
Jeff Brown1244cda2012-06-19 16:44:46 -0700186 * to determine whether this wake lock level is supported.
Craig Mautner6edb6db2012-11-20 18:21:12 -0800187 * </p><p>
188 * Cannot be used with {@link #ACQUIRE_CAUSES_WAKEUP}.
Jeff Brown1244cda2012-06-19 16:44:46 -0700189 * </p>
Mike Lockwoodbc706a02009-07-27 13:50:57 -0700190 */
Jeff Brown155fc702012-07-27 12:12:15 -0700191 public static final int PROXIMITY_SCREEN_OFF_WAKE_LOCK = 0x00000020;
Mike Lockwoodbc706a02009-07-27 13:50:57 -0700192
193 /**
Jeff Brown26875502014-01-30 21:47:47 -0800194 * Wake lock level: Put the screen in a low power state and allow the CPU to suspend
195 * if no other wake locks are held.
196 * <p>
197 * This is used by the dream manager to implement doze mode. It currently
198 * has no effect unless the power manager is in the dozing state.
Jeff Brown72671fb2014-08-21 21:41:09 -0700199 * </p><p>
200 * Requires the {@link android.Manifest.permission#DEVICE_POWER} permission.
Jeff Brown26875502014-01-30 21:47:47 -0800201 * </p>
202 *
203 * {@hide}
204 */
205 public static final int DOZE_WAKE_LOCK = 0x00000040;
206
207 /**
Jeff Brownc2932a12014-11-20 18:04:05 -0800208 * Wake lock level: Keep the device awake enough to allow drawing to occur.
209 * <p>
210 * This is used by the window manager to allow applications to draw while the
211 * system is dozing. It currently has no effect unless the power manager is in
212 * the dozing state.
213 * </p><p>
214 * Requires the {@link android.Manifest.permission#DEVICE_POWER} permission.
215 * </p>
216 *
217 * {@hide}
218 */
219 public static final int DRAW_WAKE_LOCK = 0x00000080;
220
221 /**
Ruchi Kandoi0abc0012016-01-12 14:39:24 -0800222 * Wake lock level: Enables Sustained Performance Mode.
223 * <p>
224 * This is used by Gaming and VR applications to ensure the device provides
225 * will provide consistent performance over a large amount of time.
226 * </p>
Ruchi Kandoi302710d2016-02-25 16:22:54 -0800227 *
228 * {@hide}
Ruchi Kandoi0abc0012016-01-12 14:39:24 -0800229 */
230 public static final int SUSTAINED_PERFORMANCE_WAKE_LOCK = 0x00000100;
231
232 /**
Jeff Brown155fc702012-07-27 12:12:15 -0700233 * Mask for the wake lock level component of a combined wake lock level and flags integer.
Mike Lockwood0e39ea82009-11-18 15:37:10 -0500234 *
Jeff Brown155fc702012-07-27 12:12:15 -0700235 * @hide
Mike Lockwood0e39ea82009-11-18 15:37:10 -0500236 */
Jeff Brown155fc702012-07-27 12:12:15 -0700237 public static final int WAKE_LOCK_LEVEL_MASK = 0x0000ffff;
Mike Lockwood0e39ea82009-11-18 15:37:10 -0500238
239 /**
Jeff Brown1244cda2012-06-19 16:44:46 -0700240 * Wake lock flag: Turn the screen on when the wake lock is acquired.
241 * <p>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800242 * Normally wake locks don't actually wake the device, they just cause
Jeff Brown1244cda2012-06-19 16:44:46 -0700243 * the screen to remain on once it's already on. Think of the video player
244 * application as the normal behavior. Notifications that pop up and want
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800245 * the device to be on are the exception; use this flag to be like them.
Jeff Brown1244cda2012-06-19 16:44:46 -0700246 * </p><p>
247 * Cannot be used with {@link #PARTIAL_WAKE_LOCK}.
248 * </p>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800249 */
Jeff Brown155fc702012-07-27 12:12:15 -0700250 public static final int ACQUIRE_CAUSES_WAKEUP = 0x10000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800251
252 /**
Jeff Brown1244cda2012-06-19 16:44:46 -0700253 * Wake lock flag: When this wake lock is released, poke the user activity timer
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800254 * so the screen stays on for a little longer.
255 * <p>
Jeff Brown1244cda2012-06-19 16:44:46 -0700256 * Will not turn the screen on if it is not already on.
257 * See {@link #ACQUIRE_CAUSES_WAKEUP} if you want that.
258 * </p><p>
259 * Cannot be used with {@link #PARTIAL_WAKE_LOCK}.
260 * </p>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800261 */
Jeff Brown155fc702012-07-27 12:12:15 -0700262 public static final int ON_AFTER_RELEASE = 0x20000000;
263
264 /**
Dianne Hackborn3d658bf2014-02-05 13:38:56 -0800265 * Wake lock flag: This wake lock is not important for logging events. If a later
266 * wake lock is acquired that is important, it will be considered the one to log.
267 * @hide
268 */
269 public static final int UNIMPORTANT_FOR_LOGGING = 0x40000000;
270
271 /**
Jeff Browna71f03c2014-08-21 18:01:51 -0700272 * Flag for {@link WakeLock#release WakeLock.release(int)}: Defer releasing a
273 * {@link #PROXIMITY_SCREEN_OFF_WAKE_LOCK} wake lock until the proximity sensor
274 * indicates that an object is not in close proximity.
Jeff Brown155fc702012-07-27 12:12:15 -0700275 */
Michael Wright1208e272014-09-08 19:57:50 -0700276 public static final int RELEASE_FLAG_WAIT_FOR_NO_PROXIMITY = 1;
Jeff Brown7304c342012-05-11 18:42:42 -0700277
278 /**
Jeff Brown7304c342012-05-11 18:42:42 -0700279 * Brightness value for fully on.
280 * @hide
281 */
282 public static final int BRIGHTNESS_ON = 255;
283
284 /**
Jeff Brown7304c342012-05-11 18:42:42 -0700285 * Brightness value for fully off.
286 * @hide
287 */
288 public static final int BRIGHTNESS_OFF = 0;
289
Jeff Brown970d4132014-07-19 11:33:47 -0700290 /**
291 * Brightness value for default policy handling by the system.
292 * @hide
293 */
294 public static final int BRIGHTNESS_DEFAULT = -1;
295
Jeff Brownb696de52012-07-27 15:38:50 -0700296 // Note: Be sure to update android.os.BatteryStats and PowerManager.h
297 // if adding or modifying user activity event constants.
298
299 /**
300 * User activity event type: Unspecified event type.
301 * @hide
302 */
Jeff Brown0a571122014-08-21 21:50:43 -0700303 @SystemApi
Jeff Brownb696de52012-07-27 15:38:50 -0700304 public static final int USER_ACTIVITY_EVENT_OTHER = 0;
305
306 /**
307 * User activity event type: Button or key pressed or released.
308 * @hide
309 */
Jeff Brown0a571122014-08-21 21:50:43 -0700310 @SystemApi
Jeff Brownb696de52012-07-27 15:38:50 -0700311 public static final int USER_ACTIVITY_EVENT_BUTTON = 1;
312
313 /**
314 * User activity event type: Touch down, move or up.
315 * @hide
316 */
Jeff Brown0a571122014-08-21 21:50:43 -0700317 @SystemApi
Jeff Brownb696de52012-07-27 15:38:50 -0700318 public static final int USER_ACTIVITY_EVENT_TOUCH = 2;
319
Jeff Brown96307042012-07-27 15:51:34 -0700320 /**
Phil Weaverda80d672016-03-15 16:25:46 -0700321 * User activity event type: Accessibility taking action on behalf of user.
322 * @hide
323 */
324 @SystemApi
325 public static final int USER_ACTIVITY_EVENT_ACCESSIBILITY = 3;
326
327 /**
Jeff Brown0a571122014-08-21 21:50:43 -0700328 * User activity flag: If already dimmed, extend the dim timeout
329 * but do not brighten. This flag is useful for keeping the screen on
330 * a little longer without causing a visible change such as when
331 * the power key is pressed.
Jeff Brown96307042012-07-27 15:51:34 -0700332 * @hide
333 */
Jeff Brown0a571122014-08-21 21:50:43 -0700334 @SystemApi
Jeff Brown96307042012-07-27 15:51:34 -0700335 public static final int USER_ACTIVITY_FLAG_NO_CHANGE_LIGHTS = 1 << 0;
336
337 /**
Jeff Brown0a571122014-08-21 21:50:43 -0700338 * User activity flag: Note the user activity as usual but do not
339 * reset the user activity timeout. This flag is useful for applying
340 * user activity power hints when interacting with the device indirectly
341 * on a secondary screen while allowing the primary screen to go to sleep.
342 * @hide
343 */
344 @SystemApi
345 public static final int USER_ACTIVITY_FLAG_INDIRECT = 1 << 1;
346
347 /**
Jeff Brownc12035c2014-08-13 18:52:25 -0700348 * Go to sleep reason code: Going to sleep due by application request.
Jeff Brown96307042012-07-27 15:51:34 -0700349 * @hide
350 */
Jeff Brownc12035c2014-08-13 18:52:25 -0700351 public static final int GO_TO_SLEEP_REASON_APPLICATION = 0;
Jeff Brown96307042012-07-27 15:51:34 -0700352
353 /**
354 * Go to sleep reason code: Going to sleep due by request of the
355 * device administration policy.
356 * @hide
357 */
358 public static final int GO_TO_SLEEP_REASON_DEVICE_ADMIN = 1;
359
360 /**
361 * Go to sleep reason code: Going to sleep due to a screen timeout.
362 * @hide
363 */
364 public static final int GO_TO_SLEEP_REASON_TIMEOUT = 2;
365
Doug Zongker3b0218b2014-01-14 12:29:06 -0800366 /**
Jeff Brownc12035c2014-08-13 18:52:25 -0700367 * Go to sleep reason code: Going to sleep due to the lid switch being closed.
368 * @hide
369 */
370 public static final int GO_TO_SLEEP_REASON_LID_SWITCH = 3;
371
372 /**
373 * Go to sleep reason code: Going to sleep due to the power button being pressed.
374 * @hide
375 */
376 public static final int GO_TO_SLEEP_REASON_POWER_BUTTON = 4;
377
378 /**
379 * Go to sleep reason code: Going to sleep due to HDMI.
380 * @hide
381 */
382 public static final int GO_TO_SLEEP_REASON_HDMI = 5;
383
384 /**
Filip Gruszczynski9779e122015-03-13 17:39:31 -0700385 * Go to sleep reason code: Going to sleep due to the sleep button being pressed.
386 * @hide
387 */
388 public static final int GO_TO_SLEEP_REASON_SLEEP_BUTTON = 6;
389
390 /**
Jeff Brown72671fb2014-08-21 21:41:09 -0700391 * Go to sleep flag: Skip dozing state and directly go to full sleep.
392 * @hide
393 */
394 public static final int GO_TO_SLEEP_FLAG_NO_DOZE = 1 << 0;
395
396 /**
Tao Baoe8a403d2015-12-31 07:44:55 -0800397 * The value to pass as the 'reason' argument to reboot() to reboot into
398 * recovery mode for tasks other than applying system updates, such as
399 * doing factory resets.
Doug Zongker3b0218b2014-01-14 12:29:06 -0800400 * <p>
401 * Requires the {@link android.Manifest.permission#RECOVERY}
402 * permission (in addition to
403 * {@link android.Manifest.permission#REBOOT}).
404 * </p>
Doug Zongker183415e2014-08-12 10:18:40 -0700405 * @hide
Doug Zongker3b0218b2014-01-14 12:29:06 -0800406 */
407 public static final String REBOOT_RECOVERY = "recovery";
Yusuke Sato705ffd12015-07-21 15:52:11 -0700408
409 /**
Tao Baoe8a403d2015-12-31 07:44:55 -0800410 * The value to pass as the 'reason' argument to reboot() to reboot into
411 * recovery mode for applying system updates.
412 * <p>
413 * Requires the {@link android.Manifest.permission#RECOVERY}
414 * permission (in addition to
415 * {@link android.Manifest.permission#REBOOT}).
416 * </p>
417 * @hide
418 */
419 public static final String REBOOT_RECOVERY_UPDATE = "recovery-update";
420
421 /**
Mahaver Chopra1ce53bc2015-12-14 13:35:14 +0000422 * The value to pass as the 'reason' argument to reboot() when device owner requests a reboot on
423 * the device.
424 * @hide
425 */
426 public static final String REBOOT_REQUESTED_BY_DEVICE_OWNER = "deviceowner";
427
428 /**
Tony Mantlerb8009fd2016-03-14 15:55:35 -0700429 * The 'reason' value used when rebooting in safe mode
430 * @hide
431 */
432 public static final String REBOOT_SAFE_MODE = "safemode";
433
434 /**
Yusuke Sato705ffd12015-07-21 15:52:11 -0700435 * The value to pass as the 'reason' argument to android_reboot().
436 * @hide
437 */
438 public static final String SHUTDOWN_USER_REQUESTED = "userrequested";
439
Jeff Brown96307042012-07-27 15:51:34 -0700440 final Context mContext;
Jeff Brown1244cda2012-06-19 16:44:46 -0700441 final IPowerManager mService;
442 final Handler mHandler;
443
Dianne Hackborn1958e5e2015-06-12 18:11:41 -0700444 IDeviceIdleController mIDeviceIdleController;
445
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800446 /**
Jeff Brown1244cda2012-06-19 16:44:46 -0700447 * {@hide}
448 */
Jeff Brown96307042012-07-27 15:51:34 -0700449 public PowerManager(Context context, IPowerManager service, Handler handler) {
450 mContext = context;
Jeff Brown1244cda2012-06-19 16:44:46 -0700451 mService = service;
452 mHandler = handler;
453 }
454
455 /**
Jeff Brown96307042012-07-27 15:51:34 -0700456 * Gets the minimum supported screen brightness setting.
457 * The screen may be allowed to become dimmer than this value but
458 * this is the minimum value that can be set by the user.
459 * @hide
460 */
461 public int getMinimumScreenBrightnessSetting() {
462 return mContext.getResources().getInteger(
Jeff Brownf9bba132012-08-21 22:04:02 -0700463 com.android.internal.R.integer.config_screenBrightnessSettingMinimum);
Jeff Brown96307042012-07-27 15:51:34 -0700464 }
465
466 /**
467 * Gets the maximum supported screen brightness setting.
468 * The screen may be allowed to become dimmer than this value but
469 * this is the maximum value that can be set by the user.
470 * @hide
471 */
472 public int getMaximumScreenBrightnessSetting() {
Jeff Brownf9bba132012-08-21 22:04:02 -0700473 return mContext.getResources().getInteger(
474 com.android.internal.R.integer.config_screenBrightnessSettingMaximum);
Jeff Brown96307042012-07-27 15:51:34 -0700475 }
476
477 /**
478 * Gets the default screen brightness setting.
479 * @hide
480 */
481 public int getDefaultScreenBrightnessSetting() {
Jeff Brownf9bba132012-08-21 22:04:02 -0700482 return mContext.getResources().getInteger(
483 com.android.internal.R.integer.config_screenBrightnessSettingDefault);
Jeff Brown96307042012-07-27 15:51:34 -0700484 }
485
486 /**
Jeff Browndb212842012-10-01 14:33:09 -0700487 * Returns true if the twilight service should be used to adjust screen brightness
488 * policy. This setting is experimental and disabled by default.
489 * @hide
490 */
491 public static boolean useTwilightAdjustmentFeature() {
492 return SystemProperties.getBoolean("persist.power.usetwilightadj", false);
493 }
494
495 /**
Jeff Brown1244cda2012-06-19 16:44:46 -0700496 * Creates a new wake lock with the specified level and flags.
Kenny Rootd710fb52011-03-15 17:39:45 -0700497 * <p>
Jeff Brown1244cda2012-06-19 16:44:46 -0700498 * The {@code levelAndFlags} parameter specifies a wake lock level and optional flags
499 * combined using the logical OR operator.
500 * </p><p>
501 * The wake lock levels are: {@link #PARTIAL_WAKE_LOCK},
502 * {@link #FULL_WAKE_LOCK}, {@link #SCREEN_DIM_WAKE_LOCK}
503 * and {@link #SCREEN_BRIGHT_WAKE_LOCK}. Exactly one wake lock level must be
504 * specified as part of the {@code levelAndFlags} parameter.
505 * </p><p>
506 * The wake lock flags are: {@link #ACQUIRE_CAUSES_WAKEUP}
507 * and {@link #ON_AFTER_RELEASE}. Multiple flags can be combined as part of the
508 * {@code levelAndFlags} parameters.
509 * </p><p>
510 * Call {@link WakeLock#acquire() acquire()} on the object to acquire the
511 * wake lock, and {@link WakeLock#release release()} when you are done.
512 * </p><p>
513 * {@samplecode
514 * PowerManager pm = (PowerManager)mContext.getSystemService(
515 * Context.POWER_SERVICE);
516 * PowerManager.WakeLock wl = pm.newWakeLock(
517 * PowerManager.SCREEN_DIM_WAKE_LOCK
518 * | PowerManager.ON_AFTER_RELEASE,
519 * TAG);
520 * wl.acquire();
521 * // ... do work...
522 * wl.release();
523 * }
524 * </p><p>
525 * Although a wake lock can be created without special permissions,
526 * the {@link android.Manifest.permission#WAKE_LOCK} permission is
527 * required to actually acquire or release the wake lock that is returned.
528 * </p><p class="note">
529 * If using this to keep the screen on, you should strongly consider using
530 * {@link android.view.WindowManager.LayoutParams#FLAG_KEEP_SCREEN_ON} instead.
531 * This window flag will be correctly managed by the platform
532 * as the user moves between applications and doesn't require a special permission.
533 * </p>
534 *
535 * @param levelAndFlags Combination of wake lock level and flag values defining
536 * the requested behavior of the WakeLock.
537 * @param tag Your class name (or other tag) for debugging purposes.
538 *
539 * @see WakeLock#acquire()
540 * @see WakeLock#release()
541 * @see #PARTIAL_WAKE_LOCK
542 * @see #FULL_WAKE_LOCK
543 * @see #SCREEN_DIM_WAKE_LOCK
544 * @see #SCREEN_BRIGHT_WAKE_LOCK
Jeff Browna71f03c2014-08-21 18:01:51 -0700545 * @see #PROXIMITY_SCREEN_OFF_WAKE_LOCK
Jeff Brown1244cda2012-06-19 16:44:46 -0700546 * @see #ACQUIRE_CAUSES_WAKEUP
547 * @see #ON_AFTER_RELEASE
548 */
549 public WakeLock newWakeLock(int levelAndFlags, String tag) {
Jeff Brown155fc702012-07-27 12:12:15 -0700550 validateWakeLockParameters(levelAndFlags, tag);
Dianne Hackborn95d78532013-09-11 09:51:14 -0700551 return new WakeLock(levelAndFlags, tag, mContext.getOpPackageName());
Jeff Brown155fc702012-07-27 12:12:15 -0700552 }
553
554 /** @hide */
555 public static void validateWakeLockParameters(int levelAndFlags, String tag) {
556 switch (levelAndFlags & WAKE_LOCK_LEVEL_MASK) {
557 case PARTIAL_WAKE_LOCK:
558 case SCREEN_DIM_WAKE_LOCK:
559 case SCREEN_BRIGHT_WAKE_LOCK:
560 case FULL_WAKE_LOCK:
561 case PROXIMITY_SCREEN_OFF_WAKE_LOCK:
Jeff Brown26875502014-01-30 21:47:47 -0800562 case DOZE_WAKE_LOCK:
Jeff Brownc2932a12014-11-20 18:04:05 -0800563 case DRAW_WAKE_LOCK:
Ruchi Kandoi0abc0012016-01-12 14:39:24 -0800564 case SUSTAINED_PERFORMANCE_WAKE_LOCK:
Jeff Brown155fc702012-07-27 12:12:15 -0700565 break;
566 default:
567 throw new IllegalArgumentException("Must specify a valid wake lock level.");
Jeff Brown1244cda2012-06-19 16:44:46 -0700568 }
569 if (tag == null) {
570 throw new IllegalArgumentException("The tag must not be null.");
571 }
Jeff Brown1244cda2012-06-19 16:44:46 -0700572 }
573
574 /**
575 * Notifies the power manager that user activity happened.
576 * <p>
Jeff Brown96307042012-07-27 15:51:34 -0700577 * Resets the auto-off timer and brightens the screen if the device
578 * is not asleep. This is what happens normally when a key or the touch
579 * screen is pressed or when some other user activity occurs.
580 * This method does not wake up the device if it has been put to sleep.
Jeff Brown1244cda2012-06-19 16:44:46 -0700581 * </p><p>
582 * Requires the {@link android.Manifest.permission#DEVICE_POWER} permission.
583 * </p>
584 *
585 * @param when The time of the user activity, in the {@link SystemClock#uptimeMillis()}
Jeff Brown62c82e42012-09-26 01:30:41 -0700586 * time base. This timestamp is used to correctly order the user activity request with
Jeff Brown1244cda2012-06-19 16:44:46 -0700587 * other power management functions. It should be set
588 * to the timestamp of the input event that caused the user activity.
589 * @param noChangeLights If true, does not cause the keyboard backlight to turn on
590 * because of this event. This is set when the power key is pressed.
591 * We want the device to stay on while the button is down, but we're about
592 * to turn off the screen so we don't want the keyboard backlight to turn on again.
593 * Otherwise the lights flash on and then off and it looks weird.
Jeff Brown96307042012-07-27 15:51:34 -0700594 *
595 * @see #wakeUp
596 * @see #goToSleep
Jeff Brown7d827512014-08-21 21:56:02 -0700597 *
598 * @removed Requires signature or system permission.
599 * @deprecated Use {@link #userActivity(long, int, int)}.
Jeff Brown1244cda2012-06-19 16:44:46 -0700600 */
Jeff Brown7d827512014-08-21 21:56:02 -0700601 @Deprecated
Jeff Brown1244cda2012-06-19 16:44:46 -0700602 public void userActivity(long when, boolean noChangeLights) {
Jeff Brown0a571122014-08-21 21:50:43 -0700603 userActivity(when, USER_ACTIVITY_EVENT_OTHER,
604 noChangeLights ? USER_ACTIVITY_FLAG_NO_CHANGE_LIGHTS : 0);
605 }
606
607 /**
608 * Notifies the power manager that user activity happened.
609 * <p>
610 * Resets the auto-off timer and brightens the screen if the device
611 * is not asleep. This is what happens normally when a key or the touch
612 * screen is pressed or when some other user activity occurs.
613 * This method does not wake up the device if it has been put to sleep.
614 * </p><p>
615 * Requires the {@link android.Manifest.permission#DEVICE_POWER} or
616 * {@link android.Manifest.permission#USER_ACTIVITY} permission.
617 * </p>
618 *
619 * @param when The time of the user activity, in the {@link SystemClock#uptimeMillis()}
620 * time base. This timestamp is used to correctly order the user activity request with
621 * other power management functions. It should be set
622 * to the timestamp of the input event that caused the user activity.
623 * @param event The user activity event.
624 * @param flags Optional user activity flags.
625 *
626 * @see #wakeUp
627 * @see #goToSleep
628 *
629 * @hide Requires signature or system permission.
630 */
631 @SystemApi
632 public void userActivity(long when, int event, int flags) {
Jeff Brown1244cda2012-06-19 16:44:46 -0700633 try {
Jeff Brown0a571122014-08-21 21:50:43 -0700634 mService.userActivity(when, event, flags);
Jeff Brown1244cda2012-06-19 16:44:46 -0700635 } catch (RemoteException e) {
Jeff Sharkeyc53962d2016-03-01 19:27:23 -0700636 throw e.rethrowFromSystemServer();
Jeff Brown1244cda2012-06-19 16:44:46 -0700637 }
638 }
639
640 /**
641 * Forces the device to go to sleep.
642 * <p>
Jeff Brown96307042012-07-27 15:51:34 -0700643 * Overrides all the wake locks that are held.
644 * This is what happens when the power key is pressed to turn off the screen.
Jeff Brown1244cda2012-06-19 16:44:46 -0700645 * </p><p>
646 * Requires the {@link android.Manifest.permission#DEVICE_POWER} permission.
647 * </p>
648 *
649 * @param time The time when the request to go to sleep was issued, in the
650 * {@link SystemClock#uptimeMillis()} time base. This timestamp is used to correctly
Jeff Brown62c82e42012-09-26 01:30:41 -0700651 * order the go to sleep request with other power management functions. It should be set
Jeff Brown1244cda2012-06-19 16:44:46 -0700652 * to the timestamp of the input event that caused the request to go to sleep.
Jeff Brown96307042012-07-27 15:51:34 -0700653 *
654 * @see #userActivity
655 * @see #wakeUp
Jeff Brown7d827512014-08-21 21:56:02 -0700656 *
657 * @removed Requires signature permission.
Jeff Brown1244cda2012-06-19 16:44:46 -0700658 */
659 public void goToSleep(long time) {
Jeff Brownc12035c2014-08-13 18:52:25 -0700660 goToSleep(time, GO_TO_SLEEP_REASON_APPLICATION, 0);
Jeff Brown6d8fd272014-05-20 21:24:38 -0700661 }
662
663 /**
Jeff Brown7d827512014-08-21 21:56:02 -0700664 * Forces the device to go to sleep.
665 * <p>
666 * Overrides all the wake locks that are held.
667 * This is what happens when the power key is pressed to turn off the screen.
668 * </p><p>
669 * Requires the {@link android.Manifest.permission#DEVICE_POWER} permission.
670 * </p>
671 *
672 * @param time The time when the request to go to sleep was issued, in the
673 * {@link SystemClock#uptimeMillis()} time base. This timestamp is used to correctly
674 * order the go to sleep request with other power management functions. It should be set
675 * to the timestamp of the input event that caused the request to go to sleep.
676 * @param reason The reason the device is going to sleep.
677 * @param flags Optional flags to apply when going to sleep.
678 *
679 * @see #userActivity
680 * @see #wakeUp
681 *
682 * @hide Requires signature permission.
Jeff Brown6d8fd272014-05-20 21:24:38 -0700683 */
684 public void goToSleep(long time, int reason, int flags) {
Jeff Brown1244cda2012-06-19 16:44:46 -0700685 try {
Jeff Brown6d8fd272014-05-20 21:24:38 -0700686 mService.goToSleep(time, reason, flags);
Jeff Brown96307042012-07-27 15:51:34 -0700687 } catch (RemoteException e) {
Jeff Sharkeyc53962d2016-03-01 19:27:23 -0700688 throw e.rethrowFromSystemServer();
Jeff Brown96307042012-07-27 15:51:34 -0700689 }
690 }
691
692 /**
693 * Forces the device to wake up from sleep.
694 * <p>
695 * If the device is currently asleep, wakes it up, otherwise does nothing.
696 * This is what happens when the power key is pressed to turn on the screen.
697 * </p><p>
698 * Requires the {@link android.Manifest.permission#DEVICE_POWER} permission.
699 * </p>
700 *
701 * @param time The time when the request to wake up was issued, in the
702 * {@link SystemClock#uptimeMillis()} time base. This timestamp is used to correctly
Jeff Brown62c82e42012-09-26 01:30:41 -0700703 * order the wake up request with other power management functions. It should be set
Jeff Brown96307042012-07-27 15:51:34 -0700704 * to the timestamp of the input event that caused the request to wake up.
705 *
706 * @see #userActivity
707 * @see #goToSleep
Jeff Brown7d827512014-08-21 21:56:02 -0700708 *
709 * @removed Requires signature permission.
Jeff Brown96307042012-07-27 15:51:34 -0700710 */
711 public void wakeUp(long time) {
712 try {
Dianne Hackborn280a64e2015-07-13 14:48:08 -0700713 mService.wakeUp(time, "wakeUp", mContext.getOpPackageName());
714 } catch (RemoteException e) {
Jeff Sharkeyc53962d2016-03-01 19:27:23 -0700715 throw e.rethrowFromSystemServer();
Dianne Hackborn280a64e2015-07-13 14:48:08 -0700716 }
717 }
718
719 /**
720 * @hide
721 */
722 public void wakeUp(long time, String reason) {
723 try {
724 mService.wakeUp(time, reason, mContext.getOpPackageName());
Jeff Brown1244cda2012-06-19 16:44:46 -0700725 } catch (RemoteException e) {
Jeff Sharkeyc53962d2016-03-01 19:27:23 -0700726 throw e.rethrowFromSystemServer();
Jeff Brown1244cda2012-06-19 16:44:46 -0700727 }
728 }
729
730 /**
Jeff Brown62c82e42012-09-26 01:30:41 -0700731 * Forces the device to start napping.
732 * <p>
733 * If the device is currently awake, starts dreaming, otherwise does nothing.
734 * When the dream ends or if the dream cannot be started, the device will
735 * either wake up or go to sleep depending on whether there has been recent
736 * user activity.
737 * </p><p>
738 * Requires the {@link android.Manifest.permission#DEVICE_POWER} permission.
739 * </p>
740 *
741 * @param time The time when the request to nap was issued, in the
742 * {@link SystemClock#uptimeMillis()} time base. This timestamp is used to correctly
743 * order the nap request with other power management functions. It should be set
744 * to the timestamp of the input event that caused the request to nap.
745 *
746 * @see #wakeUp
747 * @see #goToSleep
748 *
Jeff Brown7d827512014-08-21 21:56:02 -0700749 * @hide Requires signature permission.
Jeff Brown62c82e42012-09-26 01:30:41 -0700750 */
751 public void nap(long time) {
752 try {
753 mService.nap(time);
754 } catch (RemoteException e) {
Jeff Sharkeyc53962d2016-03-01 19:27:23 -0700755 throw e.rethrowFromSystemServer();
Jeff Brown62c82e42012-09-26 01:30:41 -0700756 }
757 }
758
759 /**
Jeff Browne333e672014-10-28 13:48:55 -0700760 * Boosts the brightness of the screen to maximum for a predetermined
761 * period of time. This is used to make the screen more readable in bright
762 * daylight for a short duration.
763 * <p>
764 * Requires the {@link android.Manifest.permission#DEVICE_POWER} permission.
765 * </p>
766 *
767 * @param time The time when the request to boost was issued, in the
768 * {@link SystemClock#uptimeMillis()} time base. This timestamp is used to correctly
769 * order the boost request with other power management functions. It should be set
770 * to the timestamp of the input event that caused the request to boost.
771 *
772 * @hide Requires signature permission.
773 */
774 public void boostScreenBrightness(long time) {
775 try {
776 mService.boostScreenBrightness(time);
777 } catch (RemoteException e) {
Jeff Sharkeyc53962d2016-03-01 19:27:23 -0700778 throw e.rethrowFromSystemServer();
Jeff Browne333e672014-10-28 13:48:55 -0700779 }
780 }
781
782 /**
Bryce Lee84d6c0f2015-03-17 10:43:08 -0700783 * Returns whether the screen brightness is currently boosted to maximum, caused by a call
784 * to {@link #boostScreenBrightness(long)}.
785 * @return {@code True} if the screen brightness is currently boosted. {@code False} otherwise.
786 *
787 * @hide
788 */
789 @SystemApi
790 public boolean isScreenBrightnessBoosted() {
791 try {
792 return mService.isScreenBrightnessBoosted();
793 } catch (RemoteException e) {
Jeff Sharkeyc53962d2016-03-01 19:27:23 -0700794 throw e.rethrowFromSystemServer();
Bryce Lee84d6c0f2015-03-17 10:43:08 -0700795 }
796 }
797
798 /**
Jeff Brown1244cda2012-06-19 16:44:46 -0700799 * Sets the brightness of the backlights (screen, keyboard, button).
800 * <p>
801 * Requires the {@link android.Manifest.permission#DEVICE_POWER} permission.
802 * </p>
803 *
804 * @param brightness The brightness value from 0 to 255.
805 *
Jeff Brown7d827512014-08-21 21:56:02 -0700806 * @hide Requires signature permission.
Jeff Brown1244cda2012-06-19 16:44:46 -0700807 */
808 public void setBacklightBrightness(int brightness) {
809 try {
Jeff Brown96307042012-07-27 15:51:34 -0700810 mService.setTemporaryScreenBrightnessSettingOverride(brightness);
Jeff Brown1244cda2012-06-19 16:44:46 -0700811 } catch (RemoteException e) {
Jeff Sharkeyc53962d2016-03-01 19:27:23 -0700812 throw e.rethrowFromSystemServer();
Jeff Brown1244cda2012-06-19 16:44:46 -0700813 }
814 }
815
816 /**
Jeff Brown96307042012-07-27 15:51:34 -0700817 * Returns true if the specified wake lock level is supported.
Jeff Brown1244cda2012-06-19 16:44:46 -0700818 *
Jeff Brown96307042012-07-27 15:51:34 -0700819 * @param level The wake lock level to check.
820 * @return True if the specified wake lock level is supported.
Jeff Brown1244cda2012-06-19 16:44:46 -0700821 */
Jeff Brown96307042012-07-27 15:51:34 -0700822 public boolean isWakeLockLevelSupported(int level) {
Jeff Brown1244cda2012-06-19 16:44:46 -0700823 try {
Jeff Brown96307042012-07-27 15:51:34 -0700824 return mService.isWakeLockLevelSupported(level);
Jeff Brown1244cda2012-06-19 16:44:46 -0700825 } catch (RemoteException e) {
Jeff Sharkeyc53962d2016-03-01 19:27:23 -0700826 throw e.rethrowFromSystemServer();
Jeff Brown1244cda2012-06-19 16:44:46 -0700827 }
828 }
829
830 /**
Jeff Brown037c33e2014-04-09 00:31:55 -0700831 * Returns true if the device is in an interactive state.
Jeff Brown1244cda2012-06-19 16:44:46 -0700832 * <p>
Jeff Brown037c33e2014-04-09 00:31:55 -0700833 * For historical reasons, the name of this method refers to the power state of
834 * the screen but it actually describes the overall interactive state of
835 * the device. This method has been replaced by {@link #isInteractive}.
Jeff Brown1244cda2012-06-19 16:44:46 -0700836 * </p><p>
Jeff Brown037c33e2014-04-09 00:31:55 -0700837 * The value returned by this method only indicates whether the device is
838 * in an interactive state which may have nothing to do with the screen being
839 * on or off. To determine the actual state of the screen,
840 * use {@link android.view.Display#getState}.
Jeff Brown1244cda2012-06-19 16:44:46 -0700841 * </p>
842 *
Jeff Brown037c33e2014-04-09 00:31:55 -0700843 * @return True if the device is in an interactive state.
844 *
845 * @deprecated Use {@link #isInteractive} instead.
Jeff Brown1244cda2012-06-19 16:44:46 -0700846 */
Jeff Brown037c33e2014-04-09 00:31:55 -0700847 @Deprecated
Jeff Brown1244cda2012-06-19 16:44:46 -0700848 public boolean isScreenOn() {
Jeff Brown037c33e2014-04-09 00:31:55 -0700849 return isInteractive();
850 }
851
852 /**
853 * Returns true if the device is in an interactive state.
854 * <p>
855 * When this method returns true, the device is awake and ready to interact
856 * with the user (although this is not a guarantee that the user is actively
857 * interacting with the device just this moment). The main screen is usually
858 * turned on while in this state. Certain features, such as the proximity
859 * sensor, may temporarily turn off the screen while still leaving the device in an
860 * interactive state. Note in particular that the device is still considered
861 * to be interactive while dreaming (since dreams can be interactive) but not
862 * when it is dozing or asleep.
863 * </p><p>
864 * When this method returns false, the device is dozing or asleep and must
865 * be awoken before it will become ready to interact with the user again. The
866 * main screen is usually turned off while in this state. Certain features,
867 * such as "ambient mode" may cause the main screen to remain on (albeit in a
868 * low power state) to display system-provided content while the device dozes.
869 * </p><p>
870 * The system will send a {@link android.content.Intent#ACTION_SCREEN_ON screen on}
871 * or {@link android.content.Intent#ACTION_SCREEN_OFF screen off} broadcast
872 * whenever the interactive state of the device changes. For historical reasons,
873 * the names of these broadcasts refer to the power state of the screen
874 * but they are actually sent in response to changes in the overall interactive
875 * state of the device, as described by this method.
876 * </p><p>
877 * Services may use the non-interactive state as a hint to conserve power
878 * since the user is not present.
879 * </p>
880 *
881 * @return True if the device is in an interactive state.
882 *
883 * @see android.content.Intent#ACTION_SCREEN_ON
884 * @see android.content.Intent#ACTION_SCREEN_OFF
885 */
886 public boolean isInteractive() {
Jeff Brown1244cda2012-06-19 16:44:46 -0700887 try {
Jeff Brown037c33e2014-04-09 00:31:55 -0700888 return mService.isInteractive();
Jeff Brown1244cda2012-06-19 16:44:46 -0700889 } catch (RemoteException e) {
Jeff Sharkeyc53962d2016-03-01 19:27:23 -0700890 throw e.rethrowFromSystemServer();
Jeff Brown1244cda2012-06-19 16:44:46 -0700891 }
892 }
893
894 /**
895 * Reboot the device. Will not return if the reboot is successful.
896 * <p>
897 * Requires the {@link android.Manifest.permission#REBOOT} permission.
898 * </p>
899 *
900 * @param reason code to pass to the kernel (e.g., "recovery") to
901 * request special boot modes, or null.
902 */
903 public void reboot(String reason) {
904 try {
Dianne Hackbornc428aae2012-10-03 16:38:22 -0700905 mService.reboot(false, reason, true);
Jeff Brown1244cda2012-06-19 16:44:46 -0700906 } catch (RemoteException e) {
Jeff Sharkeyc53962d2016-03-01 19:27:23 -0700907 throw e.rethrowFromSystemServer();
Jeff Brown1244cda2012-06-19 16:44:46 -0700908 }
909 }
910
911 /**
Tony Mantlerb8009fd2016-03-14 15:55:35 -0700912 * Reboot the device. Will not return if the reboot is successful.
913 * <p>
914 * Requires the {@link android.Manifest.permission#REBOOT} permission.
915 * </p>
916 * @hide
917 */
918 public void rebootSafeMode() {
919 try {
920 mService.rebootSafeMode(false, true);
921 } catch (RemoteException e) {
922 throw e.rethrowFromSystemServer();
923 }
924 }
925
926 /**
Dianne Hackborneb94fa72014-06-03 17:48:12 -0700927 * Returns true if the device is currently in power save mode. When in this mode,
928 * applications should reduce their functionality in order to conserve battery as
929 * much as possible. You can monitor for changes to this state with
930 * {@link #ACTION_POWER_SAVE_MODE_CHANGED}.
931 *
932 * @return Returns true if currently in low power mode, else false.
933 */
934 public boolean isPowerSaveMode() {
935 try {
936 return mService.isPowerSaveMode();
937 } catch (RemoteException e) {
Jeff Sharkeyc53962d2016-03-01 19:27:23 -0700938 throw e.rethrowFromSystemServer();
Dianne Hackborneb94fa72014-06-03 17:48:12 -0700939 }
940 }
941
942 /**
John Spurlock8d4e6cb2014-09-14 11:10:22 -0400943 * Set the current power save mode.
944 *
945 * @return True if the set was allowed.
946 *
947 * @see #isPowerSaveMode()
948 *
949 * @hide
950 */
951 public boolean setPowerSaveMode(boolean mode) {
952 try {
953 return mService.setPowerSaveMode(mode);
954 } catch (RemoteException e) {
Jeff Sharkeyc53962d2016-03-01 19:27:23 -0700955 throw e.rethrowFromSystemServer();
John Spurlock8d4e6cb2014-09-14 11:10:22 -0400956 }
957 }
958
959 /**
Dianne Hackborn88e98df2015-03-23 13:29:14 -0700960 * Returns true if the device is currently in idle mode. This happens when a device
961 * has been sitting unused and unmoving for a sufficiently long period of time, so that
962 * it decides to go into a lower power-use state. This may involve things like turning
963 * off network access to apps. You can monitor for changes to this state with
964 * {@link #ACTION_DEVICE_IDLE_MODE_CHANGED}.
965 *
Dianne Hackbornece0f4f2015-06-11 13:29:01 -0700966 * @return Returns true if currently in active device idle mode, else false. This is
967 * when idle mode restrictions are being actively applied; it will return false if the
968 * device is in a long-term idle mode but currently running a maintenance window where
969 * restrictions have been lifted.
Dianne Hackborn88e98df2015-03-23 13:29:14 -0700970 */
971 public boolean isDeviceIdleMode() {
972 try {
973 return mService.isDeviceIdleMode();
974 } catch (RemoteException e) {
Jeff Sharkeyc53962d2016-03-01 19:27:23 -0700975 throw e.rethrowFromSystemServer();
Dianne Hackborn88e98df2015-03-23 13:29:14 -0700976 }
977 }
978
979 /**
Dianne Hackborn08c47a52015-10-15 12:38:14 -0700980 * Returns true if the device is currently in light idle mode. This happens when a device
981 * has had its screen off for a short time, switching it into a batching mode where we
982 * execute jobs, syncs, networking on a batching schedule. You can monitor for changes to
983 * this state with {@link #ACTION_LIGHT_DEVICE_IDLE_MODE_CHANGED}.
984 *
985 * @return Returns true if currently in active light device idle mode, else false. This is
986 * when light idle mode restrictions are being actively applied; it will return false if the
987 * device is in a long-term idle mode but currently running a maintenance window where
988 * restrictions have been lifted.
989 * @hide
990 */
991 public boolean isLightDeviceIdleMode() {
992 try {
993 return mService.isLightDeviceIdleMode();
994 } catch (RemoteException e) {
Jeff Sharkeyc53962d2016-03-01 19:27:23 -0700995 throw e.rethrowFromSystemServer();
Dianne Hackborn08c47a52015-10-15 12:38:14 -0700996 }
997 }
998
999 /**
Dianne Hackborn1958e5e2015-06-12 18:11:41 -07001000 * Return whether the given application package name is on the device's power whitelist.
1001 * Apps can be placed on the whitelist through the settings UI invoked by
1002 * {@link android.provider.Settings#ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS}.
1003 */
1004 public boolean isIgnoringBatteryOptimizations(String packageName) {
1005 synchronized (this) {
1006 if (mIDeviceIdleController == null) {
1007 mIDeviceIdleController = IDeviceIdleController.Stub.asInterface(
1008 ServiceManager.getService(Context.DEVICE_IDLE_CONTROLLER));
1009 }
1010 }
1011 try {
1012 return mIDeviceIdleController.isPowerSaveWhitelistApp(packageName);
1013 } catch (RemoteException e) {
Jeff Sharkeyc53962d2016-03-01 19:27:23 -07001014 throw e.rethrowFromSystemServer();
Dianne Hackborn1958e5e2015-06-12 18:11:41 -07001015 }
1016 }
1017
1018 /**
Filip Gruszczynskid05af862015-02-04 09:48:47 -08001019 * Turn off the device.
1020 *
1021 * @param confirm If true, shows a shutdown confirmation dialog.
Yusuke Sato705ffd12015-07-21 15:52:11 -07001022 * @param reason code to pass to android_reboot() (e.g. "userrequested"), or null.
Filip Gruszczynskid05af862015-02-04 09:48:47 -08001023 * @param wait If true, this call waits for the shutdown to complete and does not return.
1024 *
1025 * @hide
1026 */
Yusuke Sato705ffd12015-07-21 15:52:11 -07001027 public void shutdown(boolean confirm, String reason, boolean wait) {
Filip Gruszczynskid05af862015-02-04 09:48:47 -08001028 try {
Yusuke Sato705ffd12015-07-21 15:52:11 -07001029 mService.shutdown(confirm, reason, wait);
Filip Gruszczynskid05af862015-02-04 09:48:47 -08001030 } catch (RemoteException e) {
Jeff Sharkeyc53962d2016-03-01 19:27:23 -07001031 throw e.rethrowFromSystemServer();
Filip Gruszczynskid05af862015-02-04 09:48:47 -08001032 }
1033 }
1034
1035 /**
Dianne Hackborneb94fa72014-06-03 17:48:12 -07001036 * Intent that is broadcast when the state of {@link #isPowerSaveMode()} changes.
1037 * This broadcast is only sent to registered receivers.
1038 */
1039 @SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION)
1040 public static final String ACTION_POWER_SAVE_MODE_CHANGED
1041 = "android.os.action.POWER_SAVE_MODE_CHANGED";
1042
1043 /**
Jason Monkafae4bd2015-12-15 14:20:06 -05001044 * Intent that is broadcast when the state of {@link #isPowerSaveMode()} changes.
1045 * @hide
1046 */
1047 @SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION)
1048 public static final String ACTION_POWER_SAVE_MODE_CHANGED_INTERNAL
1049 = "android.os.action.POWER_SAVE_MODE_CHANGED_INTERNAL";
1050
1051 /**
Dianne Hackborn88e98df2015-03-23 13:29:14 -07001052 * Intent that is broadcast when the state of {@link #isDeviceIdleMode()} changes.
1053 * This broadcast is only sent to registered receivers.
1054 */
1055 @SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION)
1056 public static final String ACTION_DEVICE_IDLE_MODE_CHANGED
1057 = "android.os.action.DEVICE_IDLE_MODE_CHANGED";
1058
1059 /**
Dianne Hackborn08c47a52015-10-15 12:38:14 -07001060 * Intent that is broadcast when the state of {@link #isLightDeviceIdleMode()} changes.
1061 * This broadcast is only sent to registered receivers.
1062 * @hide
1063 */
1064 @SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION)
1065 public static final String ACTION_LIGHT_DEVICE_IDLE_MODE_CHANGED
1066 = "android.os.action.LIGHT_DEVICE_IDLE_MODE_CHANGED";
1067
1068 /**
Dianne Hackborn0b4daca2015-04-27 09:47:32 -07001069 * @hide Intent that is broadcast when the set of power save whitelist apps has changed.
1070 * This broadcast is only sent to registered receivers.
1071 */
1072 @SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION)
1073 public static final String ACTION_POWER_SAVE_WHITELIST_CHANGED
1074 = "android.os.action.POWER_SAVE_WHITELIST_CHANGED";
1075
1076 /**
Amith Yamasaniaf575b92015-05-29 15:35:26 -07001077 * @hide Intent that is broadcast when the set of temporarily whitelisted apps has changed.
1078 * This broadcast is only sent to registered receivers.
1079 */
1080 @SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION)
1081 public static final String ACTION_POWER_SAVE_TEMP_WHITELIST_CHANGED
1082 = "android.os.action.POWER_SAVE_TEMP_WHITELIST_CHANGED";
1083
1084 /**
John Spurlock1bb480a2014-08-02 17:12:43 -04001085 * Intent that is broadcast when the state of {@link #isPowerSaveMode()} is about to change.
1086 * This broadcast is only sent to registered receivers.
1087 *
1088 * @hide
1089 */
1090 @SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION)
1091 public static final String ACTION_POWER_SAVE_MODE_CHANGING
1092 = "android.os.action.POWER_SAVE_MODE_CHANGING";
1093
1094 /** @hide */
1095 public static final String EXTRA_POWER_SAVE_MODE = "mode";
1096
1097 /**
Bryce Lee84d6c0f2015-03-17 10:43:08 -07001098 * Intent that is broadcast when the state of {@link #isScreenBrightnessBoosted()} has changed.
1099 * This broadcast is only sent to registered receivers.
1100 *
1101 * @hide
1102 **/
1103 @SystemApi
1104 public static final String ACTION_SCREEN_BRIGHTNESS_BOOST_CHANGED
1105 = "android.os.action.SCREEN_BRIGHTNESS_BOOST_CHANGED";
1106
1107 /**
Jeff Brown1244cda2012-06-19 16:44:46 -07001108 * A wake lock is a mechanism to indicate that your application needs
1109 * to have the device stay on.
Kenny Rootd710fb52011-03-15 17:39:45 -07001110 * <p>
1111 * Any application using a WakeLock must request the {@code android.permission.WAKE_LOCK}
Neil Fuller71fbb812015-11-30 09:51:33 +00001112 * permission in an {@code <uses-permission>} element of the application's manifest.
Jeff Brown1244cda2012-06-19 16:44:46 -07001113 * Obtain a wake lock by calling {@link PowerManager#newWakeLock(int, String)}.
1114 * </p><p>
1115 * Call {@link #acquire()} to acquire the wake lock and force the device to stay
1116 * on at the level that was requested when the wake lock was created.
1117 * </p><p>
1118 * Call {@link #release()} when you are done and don't need the lock anymore.
1119 * It is very important to do this as soon as possible to avoid running down the
1120 * device's battery excessively.
1121 * </p>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001122 */
Jeff Brown1244cda2012-06-19 16:44:46 -07001123 public final class WakeLock {
Dianne Hackborn3d658bf2014-02-05 13:38:56 -08001124 private int mFlags;
1125 private String mTag;
Dianne Hackborn713df152013-05-17 11:27:57 -07001126 private final String mPackageName;
Jeff Brown1244cda2012-06-19 16:44:46 -07001127 private final IBinder mToken;
1128 private int mCount;
1129 private boolean mRefCounted = true;
1130 private boolean mHeld;
1131 private WorkSource mWorkSource;
Dianne Hackborna1f1a3c2014-02-24 18:12:28 -08001132 private String mHistoryTag;
Jeff Brown3edf5272014-08-14 19:25:14 -07001133 private final String mTraceName;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001134
Jeff Brown1244cda2012-06-19 16:44:46 -07001135 private final Runnable mReleaser = new Runnable() {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001136 public void run() {
1137 release();
1138 }
1139 };
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001140
Dianne Hackborn713df152013-05-17 11:27:57 -07001141 WakeLock(int flags, String tag, String packageName) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001142 mFlags = flags;
1143 mTag = tag;
Dianne Hackborn713df152013-05-17 11:27:57 -07001144 mPackageName = packageName;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001145 mToken = new Binder();
Jeff Brown3edf5272014-08-14 19:25:14 -07001146 mTraceName = "WakeLock (" + mTag + ")";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001147 }
1148
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001149 @Override
Jeff Brown1244cda2012-06-19 16:44:46 -07001150 protected void finalize() throws Throwable {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001151 synchronized (mToken) {
1152 if (mHeld) {
Dan Egnor60d87622009-12-16 16:32:58 -08001153 Log.wtf(TAG, "WakeLock finalized while still held: " + mTag);
Jeff Brown3edf5272014-08-14 19:25:14 -07001154 Trace.asyncTraceEnd(Trace.TRACE_TAG_POWER, mTraceName, 0);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001155 try {
Mike Lockwood0e39ea82009-11-18 15:37:10 -05001156 mService.releaseWakeLock(mToken, 0);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001157 } catch (RemoteException e) {
Jeff Sharkeyc53962d2016-03-01 19:27:23 -07001158 throw e.rethrowFromSystemServer();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001159 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001160 }
1161 }
1162 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001163
Jeff Brown1244cda2012-06-19 16:44:46 -07001164 /**
1165 * Sets whether this WakeLock is reference counted.
1166 * <p>
1167 * Wake locks are reference counted by default. If a wake lock is
1168 * reference counted, then each call to {@link #acquire()} must be
1169 * balanced by an equal number of calls to {@link #release()}. If a wake
1170 * lock is not reference counted, then one call to {@link #release()} is
1171 * sufficient to undo the effect of all previous calls to {@link #acquire()}.
1172 * </p>
1173 *
1174 * @param value True to make the wake lock reference counted, false to
1175 * make the wake lock non-reference counted.
1176 */
1177 public void setReferenceCounted(boolean value) {
1178 synchronized (mToken) {
1179 mRefCounted = value;
1180 }
Mike Lockwoodf5bd0922010-03-22 17:10:15 -04001181 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001182
Jeff Brown1244cda2012-06-19 16:44:46 -07001183 /**
1184 * Acquires the wake lock.
1185 * <p>
1186 * Ensures that the device is on at the level requested when
1187 * the wake lock was created.
1188 * </p>
1189 */
1190 public void acquire() {
1191 synchronized (mToken) {
1192 acquireLocked();
1193 }
1194 }
1195
1196 /**
1197 * Acquires the wake lock with a timeout.
1198 * <p>
1199 * Ensures that the device is on at the level requested when
1200 * the wake lock was created. The lock will be released after the given timeout
1201 * expires.
1202 * </p>
1203 *
1204 * @param timeout The timeout after which to release the wake lock, in milliseconds.
1205 */
1206 public void acquire(long timeout) {
1207 synchronized (mToken) {
1208 acquireLocked();
1209 mHandler.postDelayed(mReleaser, timeout);
1210 }
1211 }
1212
1213 private void acquireLocked() {
1214 if (!mRefCounted || mCount++ == 0) {
Jeff Brownff1baef2012-07-19 15:01:17 -07001215 // Do this even if the wake lock is already thought to be held (mHeld == true)
1216 // because non-reference counted wake locks are not always properly released.
1217 // For example, the keyguard's wake lock might be forcibly released by the
1218 // power manager without the keyguard knowing. A subsequent call to acquire
1219 // should immediately acquire the wake lock once again despite never having
1220 // been explicitly released by the keyguard.
Jeff Brown1244cda2012-06-19 16:44:46 -07001221 mHandler.removeCallbacks(mReleaser);
Jeff Brown3edf5272014-08-14 19:25:14 -07001222 Trace.asyncTraceBegin(Trace.TRACE_TAG_POWER, mTraceName, 0);
Jeff Brownff1baef2012-07-19 15:01:17 -07001223 try {
Dianne Hackborna1f1a3c2014-02-24 18:12:28 -08001224 mService.acquireWakeLock(mToken, mFlags, mTag, mPackageName, mWorkSource,
1225 mHistoryTag);
Jeff Brownff1baef2012-07-19 15:01:17 -07001226 } catch (RemoteException e) {
Jeff Sharkeyc53962d2016-03-01 19:27:23 -07001227 throw e.rethrowFromSystemServer();
Jeff Brown1244cda2012-06-19 16:44:46 -07001228 }
Jeff Brownff1baef2012-07-19 15:01:17 -07001229 mHeld = true;
Jeff Brown1244cda2012-06-19 16:44:46 -07001230 }
1231 }
1232
1233 /**
1234 * Releases the wake lock.
1235 * <p>
1236 * This method releases your claim to the CPU or screen being on.
1237 * The screen may turn off shortly after you release the wake lock, or it may
1238 * not if there are other wake locks still held.
1239 * </p>
1240 */
1241 public void release() {
1242 release(0);
1243 }
1244
1245 /**
1246 * Releases the wake lock with flags to modify the release behavior.
1247 * <p>
1248 * This method releases your claim to the CPU or screen being on.
1249 * The screen may turn off shortly after you release the wake lock, or it may
1250 * not if there are other wake locks still held.
1251 * </p>
1252 *
1253 * @param flags Combination of flag values to modify the release behavior.
Michael Wright1208e272014-09-08 19:57:50 -07001254 * Currently only {@link #RELEASE_FLAG_WAIT_FOR_NO_PROXIMITY} is supported.
1255 * Passing 0 is equivalent to calling {@link #release()}.
Jeff Brown1244cda2012-06-19 16:44:46 -07001256 */
1257 public void release(int flags) {
1258 synchronized (mToken) {
1259 if (!mRefCounted || --mCount == 0) {
1260 mHandler.removeCallbacks(mReleaser);
1261 if (mHeld) {
Jeff Brown3edf5272014-08-14 19:25:14 -07001262 Trace.asyncTraceEnd(Trace.TRACE_TAG_POWER, mTraceName, 0);
Jeff Brown1244cda2012-06-19 16:44:46 -07001263 try {
1264 mService.releaseWakeLock(mToken, flags);
1265 } catch (RemoteException e) {
Jeff Sharkeyc53962d2016-03-01 19:27:23 -07001266 throw e.rethrowFromSystemServer();
Jeff Brown1244cda2012-06-19 16:44:46 -07001267 }
1268 mHeld = false;
1269 }
1270 }
1271 if (mCount < 0) {
1272 throw new RuntimeException("WakeLock under-locked " + mTag);
1273 }
1274 }
1275 }
1276
1277 /**
1278 * Returns true if the wake lock has been acquired but not yet released.
1279 *
1280 * @return True if the wake lock is held.
1281 */
1282 public boolean isHeld() {
1283 synchronized (mToken) {
1284 return mHeld;
1285 }
1286 }
1287
1288 /**
1289 * Sets the work source associated with the wake lock.
1290 * <p>
1291 * The work source is used to determine on behalf of which application
1292 * the wake lock is being held. This is useful in the case where a
1293 * service is performing work on behalf of an application so that the
1294 * cost of that work can be accounted to the application.
1295 * </p>
1296 *
1297 * @param ws The work source, or null if none.
1298 */
1299 public void setWorkSource(WorkSource ws) {
1300 synchronized (mToken) {
1301 if (ws != null && ws.size() == 0) {
1302 ws = null;
1303 }
1304
1305 final boolean changed;
1306 if (ws == null) {
1307 changed = mWorkSource != null;
1308 mWorkSource = null;
1309 } else if (mWorkSource == null) {
1310 changed = true;
1311 mWorkSource = new WorkSource(ws);
1312 } else {
1313 changed = mWorkSource.diff(ws);
1314 if (changed) {
1315 mWorkSource.set(ws);
1316 }
1317 }
1318
1319 if (changed && mHeld) {
1320 try {
Dianne Hackborn4590e522014-03-24 13:36:46 -07001321 mService.updateWakeLockWorkSource(mToken, mWorkSource, mHistoryTag);
Jeff Brown1244cda2012-06-19 16:44:46 -07001322 } catch (RemoteException e) {
Jeff Sharkeyc53962d2016-03-01 19:27:23 -07001323 throw e.rethrowFromSystemServer();
Jeff Brown1244cda2012-06-19 16:44:46 -07001324 }
1325 }
1326 }
1327 }
1328
Dianne Hackborn3d658bf2014-02-05 13:38:56 -08001329 /** @hide */
1330 public void setTag(String tag) {
1331 mTag = tag;
1332 }
1333
1334 /** @hide */
Dianne Hackborna1f1a3c2014-02-24 18:12:28 -08001335 public void setHistoryTag(String tag) {
1336 mHistoryTag = tag;
1337 }
1338
1339 /** @hide */
Dianne Hackborn3d658bf2014-02-05 13:38:56 -08001340 public void setUnimportantForLogging(boolean state) {
1341 if (state) mFlags |= UNIMPORTANT_FOR_LOGGING;
1342 else mFlags &= ~UNIMPORTANT_FOR_LOGGING;
1343 }
1344
Jeff Brown1244cda2012-06-19 16:44:46 -07001345 @Override
1346 public String toString() {
1347 synchronized (mToken) {
1348 return "WakeLock{"
1349 + Integer.toHexString(System.identityHashCode(this))
1350 + " held=" + mHeld + ", refCount=" + mCount + "}";
1351 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001352 }
1353 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001354}