1 /* 2 * Copyright (C) 2008 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 /** 20 * The BatteryManager class contains strings and constants used for values 21 * in the {@link android.content.Intent#ACTION_BATTERY_CHANGED} Intent. 22 */ 23 public class BatteryManager { 24 /** 25 * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}: 26 * integer containing the current status constant. 27 */ 28 public static final String EXTRA_STATUS = "status"; 29 30 /** 31 * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}: 32 * integer containing the current health constant. 33 */ 34 public static final String EXTRA_HEALTH = "health"; 35 36 /** 37 * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}: 38 * boolean indicating whether a battery is present. 39 */ 40 public static final String EXTRA_PRESENT = "present"; 41 42 /** 43 * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}: 44 * integer field containing the current battery level, from 0 to 45 * {@link #EXTRA_SCALE}. 46 */ 47 public static final String EXTRA_LEVEL = "level"; 48 49 /** 50 * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}: 51 * integer containing the maximum battery level. 52 */ 53 public static final String EXTRA_SCALE = "scale"; 54 55 /** 56 * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}: 57 * integer containing the resource ID of a small status bar icon 58 * indicating the current battery state. 59 */ 60 public static final String EXTRA_ICON_SMALL = "icon-small"; 61 62 /** 63 * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}: 64 * integer indicating whether the device is plugged in to a power 65 * source; 0 means it is on battery, other constants are different 66 * types of power sources. 67 */ 68 public static final String EXTRA_PLUGGED = "plugged"; 69 70 /** 71 * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}: 72 * integer containing the current battery voltage level. 73 */ 74 public static final String EXTRA_VOLTAGE = "voltage"; 75 76 /** 77 * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}: 78 * integer containing the current battery temperature. 79 */ 80 public static final String EXTRA_TEMPERATURE = "temperature"; 81 82 /** 83 * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}: 84 * String describing the technology of the current battery. 85 */ 86 public static final String EXTRA_TECHNOLOGY = "technology"; 87 88 /** 89 * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}: 90 * Int value set to nonzero if an unsupported charger is attached 91 * to the device. 92 * {@hide} 93 */ 94 public static final String EXTRA_INVALID_CHARGER = "invalid_charger"; 95 96 // values for "status" field in the ACTION_BATTERY_CHANGED Intent 97 public static final int BATTERY_STATUS_UNKNOWN = 1; 98 public static final int BATTERY_STATUS_CHARGING = 2; 99 public static final int BATTERY_STATUS_DISCHARGING = 3; 100 public static final int BATTERY_STATUS_NOT_CHARGING = 4; 101 public static final int BATTERY_STATUS_FULL = 5; 102 103 // values for "health" field in the ACTION_BATTERY_CHANGED Intent 104 public static final int BATTERY_HEALTH_UNKNOWN = 1; 105 public static final int BATTERY_HEALTH_GOOD = 2; 106 public static final int BATTERY_HEALTH_OVERHEAT = 3; 107 public static final int BATTERY_HEALTH_DEAD = 4; 108 public static final int BATTERY_HEALTH_OVER_VOLTAGE = 5; 109 public static final int BATTERY_HEALTH_UNSPECIFIED_FAILURE = 6; 110 public static final int BATTERY_HEALTH_COLD = 7; 111 112 // values of the "plugged" field in the ACTION_BATTERY_CHANGED intent. 113 // These must be powers of 2. 114 /** Power source is an AC charger. */ 115 public static final int BATTERY_PLUGGED_AC = 1; 116 /** Power source is a USB port. */ 117 public static final int BATTERY_PLUGGED_USB = 2; 118 /** Power source is wireless. */ 119 public static final int BATTERY_PLUGGED_WIRELESS = 4; 120 121 /** @hide */ 122 public static final int BATTERY_PLUGGED_ANY = 123 BATTERY_PLUGGED_AC | BATTERY_PLUGGED_USB | BATTERY_PLUGGED_WIRELESS; 124 } 125