The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package android.os; |
| 18 | |
| 19 | import java.io.IOException; |
| 20 | |
| 21 | /** |
| 22 | * Class that provides access to some of the power management functions. |
| 23 | * |
| 24 | * {@hide} |
| 25 | */ |
| 26 | public class Power |
| 27 | { |
| 28 | // can't instantiate this class |
| 29 | private Power() |
| 30 | { |
| 31 | } |
| 32 | |
| 33 | /** |
| 34 | * Wake lock that ensures that the CPU is running. The screen might |
| 35 | * not be on. |
| 36 | */ |
| 37 | public static final int PARTIAL_WAKE_LOCK = 1; |
| 38 | |
| 39 | /** |
| 40 | * Wake lock that ensures that the screen is on. |
| 41 | */ |
| 42 | public static final int FULL_WAKE_LOCK = 2; |
| 43 | |
| 44 | public static native void acquireWakeLock(int lock, String id); |
| 45 | public static native void releaseWakeLock(String id); |
| 46 | |
| 47 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 48 | * Brightness value for fully off |
| 49 | */ |
| 50 | public static final int BRIGHTNESS_OFF = 0; |
| 51 | |
| 52 | /** |
| 53 | * Brightness value for dim backlight |
| 54 | */ |
| 55 | public static final int BRIGHTNESS_DIM = 20; |
| 56 | |
| 57 | /** |
| 58 | * Brightness value for fully on |
| 59 | */ |
| 60 | public static final int BRIGHTNESS_ON = 255; |
| 61 | |
| 62 | /** |
| 63 | * Brightness value to use when battery is low |
| 64 | */ |
| 65 | public static final int BRIGHTNESS_LOW_BATTERY = 10; |
| 66 | |
| 67 | /** |
| 68 | * Threshold for BRIGHTNESS_LOW_BATTERY (percentage) |
| 69 | * Screen will stay dim if battery level is <= LOW_BATTERY_THRESHOLD |
| 70 | */ |
| 71 | public static final int LOW_BATTERY_THRESHOLD = 10; |
| 72 | |
| 73 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 74 | * Turn the screen on or off |
| 75 | * |
| 76 | * @param on Whether you want the screen on or off |
| 77 | */ |
| 78 | public static native int setScreenState(boolean on); |
| 79 | |
| 80 | public static native int setLastUserActivityTimeout(long ms); |
| 81 | |
| 82 | /** |
Dianne Hackborn | 55280a9 | 2009-05-07 15:53:46 -0700 | [diff] [blame] | 83 | * Low-level function turn the device off immediately, without trying |
| 84 | * to be clean. Most people should use |
| 85 | * {@link android.internal.app.ShutdownThread} for a clean shutdown. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 86 | * |
| 87 | * @deprecated |
| 88 | * @hide |
| 89 | */ |
| 90 | @Deprecated |
| 91 | public static native void shutdown(); |
| 92 | |
| 93 | /** |
| 94 | * Reboot the device. |
| 95 | * @param reason code to pass to the kernel (e.g. "recovery"), or null. |
| 96 | * |
| 97 | * @throws IOException if reboot fails for some reason (eg, lack of |
| 98 | * permission) |
| 99 | */ |
| 100 | public static native void reboot(String reason) throws IOException; |
| 101 | } |