The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2006 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 com.android.server; |
| 18 | |
| 19 | import com.android.internal.app.IBatteryStats; |
| 20 | import com.android.server.am.BatteryStatsService; |
| 21 | |
| 22 | import android.app.ActivityManagerNative; |
| 23 | import android.content.ContentResolver; |
| 24 | import android.content.Context; |
| 25 | import android.content.Intent; |
| 26 | import android.content.pm.PackageManager; |
| 27 | import android.os.BatteryManager; |
| 28 | import android.os.Binder; |
Dianne Hackborn | 8bdf593 | 2010-10-15 12:54:40 -0700 | [diff] [blame] | 29 | import android.os.FileUtils; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 30 | import android.os.IBinder; |
Dan Egnor | 18e9396 | 2010-02-10 19:27:58 -0800 | [diff] [blame] | 31 | import android.os.DropBoxManager; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 32 | import android.os.RemoteException; |
| 33 | import android.os.ServiceManager; |
| 34 | import android.os.SystemClock; |
| 35 | import android.os.UEventObserver; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 36 | import android.provider.Settings; |
| 37 | import android.util.EventLog; |
Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 38 | import android.util.Slog; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 39 | |
| 40 | import java.io.File; |
| 41 | import java.io.FileDescriptor; |
| 42 | import java.io.FileInputStream; |
| 43 | import java.io.FileOutputStream; |
| 44 | import java.io.IOException; |
| 45 | import java.io.PrintWriter; |
Joe Onorato | 4ca7f1e | 2010-10-27 15:32:23 -0700 | [diff] [blame] | 46 | import java.util.Arrays; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 47 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 48 | |
| 49 | /** |
| 50 | * <p>BatteryService monitors the charging status, and charge level of the device |
| 51 | * battery. When these values change this service broadcasts the new values |
| 52 | * to all {@link android.content.BroadcastReceiver IntentReceivers} that are |
| 53 | * watching the {@link android.content.Intent#ACTION_BATTERY_CHANGED |
| 54 | * BATTERY_CHANGED} action.</p> |
| 55 | * <p>The new values are stored in the Intent data and can be retrieved by |
| 56 | * calling {@link android.content.Intent#getExtra Intent.getExtra} with the |
| 57 | * following keys:</p> |
| 58 | * <p>"scale" - int, the maximum value for the charge level</p> |
| 59 | * <p>"level" - int, charge level, from 0 through "scale" inclusive</p> |
| 60 | * <p>"status" - String, the current charging status.<br /> |
| 61 | * <p>"health" - String, the current battery health.<br /> |
| 62 | * <p>"present" - boolean, true if the battery is present<br /> |
| 63 | * <p>"icon-small" - int, suggested small icon to use for this state</p> |
| 64 | * <p>"plugged" - int, 0 if the device is not plugged in; 1 if plugged |
| 65 | * into an AC power adapter; 2 if plugged in via USB.</p> |
| 66 | * <p>"voltage" - int, current battery voltage in millivolts</p> |
| 67 | * <p>"temperature" - int, current battery temperature in tenths of |
| 68 | * a degree Centigrade</p> |
| 69 | * <p>"technology" - String, the type of battery installed, e.g. "Li-ion"</p> |
| 70 | */ |
| 71 | class BatteryService extends Binder { |
| 72 | private static final String TAG = BatteryService.class.getSimpleName(); |
Doug Zongker | ab5c49c | 2009-12-04 10:31:43 -0800 | [diff] [blame] | 73 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 74 | private static final boolean LOCAL_LOGV = false; |
Doug Zongker | ab5c49c | 2009-12-04 10:31:43 -0800 | [diff] [blame] | 75 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 76 | static final int BATTERY_SCALE = 100; // battery capacity is a percentage |
| 77 | |
| 78 | // Used locally for determining when to make a last ditch effort to log |
| 79 | // discharge stats before the device dies. |
Joe Onorato | 4ca7f1e | 2010-10-27 15:32:23 -0700 | [diff] [blame] | 80 | private int mCriticalBatteryLevel; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 81 | |
| 82 | private static final int DUMP_MAX_LENGTH = 24 * 1024; |
Dianne Hackborn | 6447ca3 | 2009-04-07 19:50:08 -0700 | [diff] [blame] | 83 | private static final String[] DUMPSYS_ARGS = new String[] { "--checkin", "-u" }; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 84 | private static final String BATTERY_STATS_SERVICE_NAME = "batteryinfo"; |
Doug Zongker | ab5c49c | 2009-12-04 10:31:43 -0800 | [diff] [blame] | 85 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 86 | private static final String DUMPSYS_DATA_PATH = "/data/system/"; |
| 87 | |
| 88 | // This should probably be exposed in the API, though it's not critical |
| 89 | private static final int BATTERY_PLUGGED_NONE = 0; |
| 90 | |
| 91 | private final Context mContext; |
| 92 | private final IBatteryStats mBatteryStats; |
Doug Zongker | ab5c49c | 2009-12-04 10:31:43 -0800 | [diff] [blame] | 93 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 94 | private boolean mAcOnline; |
| 95 | private boolean mUsbOnline; |
| 96 | private int mBatteryStatus; |
| 97 | private int mBatteryHealth; |
| 98 | private boolean mBatteryPresent; |
| 99 | private int mBatteryLevel; |
| 100 | private int mBatteryVoltage; |
| 101 | private int mBatteryTemperature; |
| 102 | private String mBatteryTechnology; |
| 103 | private boolean mBatteryLevelCritical; |
Joe Onorato | 4ca7f1e | 2010-10-27 15:32:23 -0700 | [diff] [blame] | 104 | private int mInvalidCharger; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 105 | |
| 106 | private int mLastBatteryStatus; |
| 107 | private int mLastBatteryHealth; |
| 108 | private boolean mLastBatteryPresent; |
| 109 | private int mLastBatteryLevel; |
| 110 | private int mLastBatteryVoltage; |
| 111 | private int mLastBatteryTemperature; |
| 112 | private boolean mLastBatteryLevelCritical; |
Joe Onorato | 4ca7f1e | 2010-10-27 15:32:23 -0700 | [diff] [blame] | 113 | private int mLastInvalidCharger; |
Mike Lockwood | d81b1f4 | 2009-09-25 09:32:19 -0400 | [diff] [blame] | 114 | |
| 115 | private int mLowBatteryWarningLevel; |
| 116 | private int mLowBatteryCloseWarningLevel; |
| 117 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 118 | private int mPlugType; |
| 119 | private int mLastPlugType = -1; // Extra state so we can detect first run |
Doug Zongker | ab5c49c | 2009-12-04 10:31:43 -0800 | [diff] [blame] | 120 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 121 | private long mDischargeStartTime; |
| 122 | private int mDischargeStartLevel; |
Doug Zongker | ab5c49c | 2009-12-04 10:31:43 -0800 | [diff] [blame] | 123 | |
Joe Onorato | de1b359 | 2010-10-25 20:36:47 -0700 | [diff] [blame] | 124 | private Led mLed; |
| 125 | |
Dianne Hackborn | 8ec5b83 | 2009-07-01 21:19:35 -0700 | [diff] [blame] | 126 | private boolean mSentLowBatteryBroadcast = false; |
Doug Zongker | ab5c49c | 2009-12-04 10:31:43 -0800 | [diff] [blame] | 127 | |
Joe Onorato | de1b359 | 2010-10-25 20:36:47 -0700 | [diff] [blame] | 128 | public BatteryService(Context context, LightsService lights) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 129 | mContext = context; |
Joe Onorato | de1b359 | 2010-10-25 20:36:47 -0700 | [diff] [blame] | 130 | mLed = new Led(context, lights); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 131 | mBatteryStats = BatteryStatsService.getService(); |
| 132 | |
Joe Onorato | 4ca7f1e | 2010-10-27 15:32:23 -0700 | [diff] [blame] | 133 | mCriticalBatteryLevel = mContext.getResources().getInteger( |
| 134 | com.android.internal.R.integer.config_criticalBatteryWarningLevel); |
Mike Lockwood | d81b1f4 | 2009-09-25 09:32:19 -0400 | [diff] [blame] | 135 | mLowBatteryWarningLevel = mContext.getResources().getInteger( |
| 136 | com.android.internal.R.integer.config_lowBatteryWarningLevel); |
| 137 | mLowBatteryCloseWarningLevel = mContext.getResources().getInteger( |
| 138 | com.android.internal.R.integer.config_lowBatteryCloseWarningLevel); |
| 139 | |
Mike Lockwood | deff9c8 | 2010-09-04 10:29:17 -0400 | [diff] [blame] | 140 | mPowerSupplyObserver.startObserving("SUBSYSTEM=power_supply"); |
| 141 | |
| 142 | // watch for invalid charger messages if the invalid_charger switch exists |
| 143 | if (new File("/sys/devices/virtual/switch/invalid_charger/state").exists()) { |
| 144 | mInvalidChargerObserver.startObserving("DEVPATH=/devices/virtual/switch/invalid_charger"); |
| 145 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 146 | |
| 147 | // set initial status |
| 148 | update(); |
| 149 | } |
| 150 | |
| 151 | final boolean isPowered() { |
| 152 | // assume we are powered if battery state is unknown so the "stay on while plugged in" option will work. |
Jean-Baptiste Queru | d3e803a | 2010-08-31 12:29:16 -0700 | [diff] [blame] | 153 | return (mAcOnline || mUsbOnline || mBatteryStatus == BatteryManager.BATTERY_STATUS_UNKNOWN); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 154 | } |
| 155 | |
| 156 | final boolean isPowered(int plugTypeSet) { |
| 157 | // assume we are powered if battery state is unknown so |
| 158 | // the "stay on while plugged in" option will work. |
| 159 | if (mBatteryStatus == BatteryManager.BATTERY_STATUS_UNKNOWN) { |
| 160 | return true; |
| 161 | } |
| 162 | if (plugTypeSet == 0) { |
| 163 | return false; |
| 164 | } |
| 165 | int plugTypeBit = 0; |
Jean-Baptiste Queru | d3e803a | 2010-08-31 12:29:16 -0700 | [diff] [blame] | 166 | if (mAcOnline) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 167 | plugTypeBit |= BatteryManager.BATTERY_PLUGGED_AC; |
| 168 | } |
Jean-Baptiste Queru | d3e803a | 2010-08-31 12:29:16 -0700 | [diff] [blame] | 169 | if (mUsbOnline) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 170 | plugTypeBit |= BatteryManager.BATTERY_PLUGGED_USB; |
| 171 | } |
| 172 | return (plugTypeSet & plugTypeBit) != 0; |
| 173 | } |
| 174 | |
| 175 | final int getPlugType() { |
| 176 | return mPlugType; |
| 177 | } |
| 178 | |
Mike Lockwood | deff9c8 | 2010-09-04 10:29:17 -0400 | [diff] [blame] | 179 | private UEventObserver mPowerSupplyObserver = new UEventObserver() { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 180 | @Override |
| 181 | public void onUEvent(UEventObserver.UEvent event) { |
| 182 | update(); |
| 183 | } |
| 184 | }; |
| 185 | |
Mike Lockwood | deff9c8 | 2010-09-04 10:29:17 -0400 | [diff] [blame] | 186 | private UEventObserver mInvalidChargerObserver = new UEventObserver() { |
| 187 | @Override |
| 188 | public void onUEvent(UEventObserver.UEvent event) { |
Joe Onorato | 4ca7f1e | 2010-10-27 15:32:23 -0700 | [diff] [blame] | 189 | int invalidCharger = "1".equals(event.get("SWITCH_STATE")) ? 1 : 0; |
Mike Lockwood | deff9c8 | 2010-09-04 10:29:17 -0400 | [diff] [blame] | 190 | if (mInvalidCharger != invalidCharger) { |
| 191 | mInvalidCharger = invalidCharger; |
| 192 | update(); |
| 193 | } |
| 194 | } |
| 195 | }; |
| 196 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 197 | // returns battery level as a percentage |
| 198 | final int getBatteryLevel() { |
| 199 | return mBatteryLevel; |
| 200 | } |
| 201 | |
Mike Lockwood | 07a500f | 2009-08-12 09:56:44 -0400 | [diff] [blame] | 202 | void systemReady() { |
| 203 | // check our power situation now that it is safe to display the shutdown dialog. |
| 204 | shutdownIfNoPower(); |
Eric Olsen | 6a362a9 | 2010-03-26 15:38:41 -0700 | [diff] [blame] | 205 | shutdownIfOverTemp(); |
Mike Lockwood | 07a500f | 2009-08-12 09:56:44 -0400 | [diff] [blame] | 206 | } |
| 207 | |
| 208 | private final void shutdownIfNoPower() { |
| 209 | // shut down gracefully if our battery is critically low and we are not powered. |
| 210 | // wait until the system has booted before attempting to display the shutdown dialog. |
Jean-Baptiste Queru | d3e803a | 2010-08-31 12:29:16 -0700 | [diff] [blame] | 211 | if (mBatteryLevel == 0 && !isPowered() && ActivityManagerNative.isSystemReady()) { |
Mike Lockwood | 07a500f | 2009-08-12 09:56:44 -0400 | [diff] [blame] | 212 | Intent intent = new Intent(Intent.ACTION_REQUEST_SHUTDOWN); |
| 213 | intent.putExtra(Intent.EXTRA_KEY_CONFIRM, false); |
| 214 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| 215 | mContext.startActivity(intent); |
| 216 | } |
| 217 | } |
| 218 | |
Eric Olsen | 6a362a9 | 2010-03-26 15:38:41 -0700 | [diff] [blame] | 219 | private final void shutdownIfOverTemp() { |
| 220 | // shut down gracefully if temperature is too high (> 68.0C) |
| 221 | // wait until the system has booted before attempting to display the shutdown dialog. |
| 222 | if (mBatteryTemperature > 680 && ActivityManagerNative.isSystemReady()) { |
| 223 | Intent intent = new Intent(Intent.ACTION_REQUEST_SHUTDOWN); |
| 224 | intent.putExtra(Intent.EXTRA_KEY_CONFIRM, false); |
| 225 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| 226 | mContext.startActivity(intent); |
| 227 | } |
| 228 | } |
| 229 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 230 | private native void native_update(); |
| 231 | |
| 232 | private synchronized final void update() { |
| 233 | native_update(); |
Joe Onorato | 4ca7f1e | 2010-10-27 15:32:23 -0700 | [diff] [blame] | 234 | processValues(); |
| 235 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 236 | |
Joe Onorato | 4ca7f1e | 2010-10-27 15:32:23 -0700 | [diff] [blame] | 237 | private void processValues() { |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 238 | boolean logOutlier = false; |
| 239 | long dischargeDuration = 0; |
Joe Onorato | a7e4cf9b | 2009-07-28 18:18:20 -0700 | [diff] [blame] | 240 | |
Joe Onorato | 4ca7f1e | 2010-10-27 15:32:23 -0700 | [diff] [blame] | 241 | mBatteryLevelCritical = mBatteryLevel <= mCriticalBatteryLevel; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 242 | if (mAcOnline) { |
| 243 | mPlugType = BatteryManager.BATTERY_PLUGGED_AC; |
| 244 | } else if (mUsbOnline) { |
| 245 | mPlugType = BatteryManager.BATTERY_PLUGGED_USB; |
| 246 | } else { |
| 247 | mPlugType = BATTERY_PLUGGED_NONE; |
| 248 | } |
Dianne Hackborn | 6b7b484 | 2010-06-14 17:17:44 -0700 | [diff] [blame] | 249 | |
| 250 | // Let the battery stats keep track of the current level. |
| 251 | try { |
| 252 | mBatteryStats.setBatteryState(mBatteryStatus, mBatteryHealth, |
| 253 | mPlugType, mBatteryLevel, mBatteryTemperature, |
| 254 | mBatteryVoltage); |
| 255 | } catch (RemoteException e) { |
| 256 | // Should never happen. |
| 257 | } |
| 258 | |
| 259 | shutdownIfNoPower(); |
| 260 | shutdownIfOverTemp(); |
| 261 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 262 | if (mBatteryStatus != mLastBatteryStatus || |
| 263 | mBatteryHealth != mLastBatteryHealth || |
| 264 | mBatteryPresent != mLastBatteryPresent || |
| 265 | mBatteryLevel != mLastBatteryLevel || |
| 266 | mPlugType != mLastPlugType || |
| 267 | mBatteryVoltage != mLastBatteryVoltage || |
Mike Lockwood | deff9c8 | 2010-09-04 10:29:17 -0400 | [diff] [blame] | 268 | mBatteryTemperature != mLastBatteryTemperature || |
| 269 | mInvalidCharger != mLastInvalidCharger) { |
Doug Zongker | ab5c49c | 2009-12-04 10:31:43 -0800 | [diff] [blame] | 270 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 271 | if (mPlugType != mLastPlugType) { |
| 272 | if (mLastPlugType == BATTERY_PLUGGED_NONE) { |
| 273 | // discharging -> charging |
Doug Zongker | ab5c49c | 2009-12-04 10:31:43 -0800 | [diff] [blame] | 274 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 275 | // There's no value in this data unless we've discharged at least once and the |
| 276 | // battery level has changed; so don't log until it does. |
| 277 | if (mDischargeStartTime != 0 && mDischargeStartLevel != mBatteryLevel) { |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 278 | dischargeDuration = SystemClock.elapsedRealtime() - mDischargeStartTime; |
| 279 | logOutlier = true; |
Doug Zongker | ab5c49c | 2009-12-04 10:31:43 -0800 | [diff] [blame] | 280 | EventLog.writeEvent(EventLogTags.BATTERY_DISCHARGE, dischargeDuration, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 281 | mDischargeStartLevel, mBatteryLevel); |
| 282 | // make sure we see a discharge event before logging again |
Doug Zongker | ab5c49c | 2009-12-04 10:31:43 -0800 | [diff] [blame] | 283 | mDischargeStartTime = 0; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 284 | } |
| 285 | } else if (mPlugType == BATTERY_PLUGGED_NONE) { |
| 286 | // charging -> discharging or we just powered up |
| 287 | mDischargeStartTime = SystemClock.elapsedRealtime(); |
| 288 | mDischargeStartLevel = mBatteryLevel; |
| 289 | } |
| 290 | } |
| 291 | if (mBatteryStatus != mLastBatteryStatus || |
| 292 | mBatteryHealth != mLastBatteryHealth || |
| 293 | mBatteryPresent != mLastBatteryPresent || |
| 294 | mPlugType != mLastPlugType) { |
Doug Zongker | ab5c49c | 2009-12-04 10:31:43 -0800 | [diff] [blame] | 295 | EventLog.writeEvent(EventLogTags.BATTERY_STATUS, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 296 | mBatteryStatus, mBatteryHealth, mBatteryPresent ? 1 : 0, |
| 297 | mPlugType, mBatteryTechnology); |
| 298 | } |
| 299 | if (mBatteryLevel != mLastBatteryLevel || |
| 300 | mBatteryVoltage != mLastBatteryVoltage || |
| 301 | mBatteryTemperature != mLastBatteryTemperature) { |
Doug Zongker | ab5c49c | 2009-12-04 10:31:43 -0800 | [diff] [blame] | 302 | EventLog.writeEvent(EventLogTags.BATTERY_LEVEL, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 303 | mBatteryLevel, mBatteryVoltage, mBatteryTemperature); |
| 304 | } |
| 305 | if (mBatteryLevelCritical && !mLastBatteryLevelCritical && |
| 306 | mPlugType == BATTERY_PLUGGED_NONE) { |
| 307 | // We want to make sure we log discharge cycle outliers |
| 308 | // if the battery is about to die. |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 309 | dischargeDuration = SystemClock.elapsedRealtime() - mDischargeStartTime; |
| 310 | logOutlier = true; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 311 | } |
Doug Zongker | ab5c49c | 2009-12-04 10:31:43 -0800 | [diff] [blame] | 312 | |
Dianne Hackborn | 99f7eb45 | 2009-09-22 17:27:53 -0700 | [diff] [blame] | 313 | final boolean plugged = mPlugType != BATTERY_PLUGGED_NONE; |
| 314 | final boolean oldPlugged = mLastPlugType != BATTERY_PLUGGED_NONE; |
| 315 | |
| 316 | /* The ACTION_BATTERY_LOW broadcast is sent in these situations: |
Mike Lockwood | d81b1f4 | 2009-09-25 09:32:19 -0400 | [diff] [blame] | 317 | * - is just un-plugged (previously was plugged) and battery level is |
| 318 | * less than or equal to WARNING, or |
| 319 | * - is not plugged and battery level falls to WARNING boundary |
| 320 | * (becomes <= mLowBatteryWarningLevel). |
Dianne Hackborn | 99f7eb45 | 2009-09-22 17:27:53 -0700 | [diff] [blame] | 321 | */ |
| 322 | final boolean sendBatteryLow = !plugged |
Joe Onorato | de1b359 | 2010-10-25 20:36:47 -0700 | [diff] [blame] | 323 | && mBatteryStatus != BatteryManager.BATTERY_STATUS_UNKNOWN |
| 324 | && mBatteryLevel <= mLowBatteryWarningLevel |
| 325 | && (oldPlugged || mLastBatteryLevel > mLowBatteryWarningLevel); |
Doug Zongker | ab5c49c | 2009-12-04 10:31:43 -0800 | [diff] [blame] | 326 | |
Dianne Hackborn | 99f7eb45 | 2009-09-22 17:27:53 -0700 | [diff] [blame] | 327 | sendIntent(); |
Doug Zongker | ab5c49c | 2009-12-04 10:31:43 -0800 | [diff] [blame] | 328 | |
Christopher Tate | 06ba554 | 2009-04-09 16:03:56 -0700 | [diff] [blame] | 329 | // Separate broadcast is sent for power connected / not connected |
| 330 | // since the standard intent will not wake any applications and some |
| 331 | // applications may want to have smart behavior based on this. |
Christopher Tate | 93dc9fe | 2009-07-16 13:25:49 -0700 | [diff] [blame] | 332 | Intent statusIntent = new Intent(); |
| 333 | statusIntent.setFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT); |
Christopher Tate | 06ba554 | 2009-04-09 16:03:56 -0700 | [diff] [blame] | 334 | if (mPlugType != 0 && mLastPlugType == 0) { |
Christopher Tate | 93dc9fe | 2009-07-16 13:25:49 -0700 | [diff] [blame] | 335 | statusIntent.setAction(Intent.ACTION_POWER_CONNECTED); |
| 336 | mContext.sendBroadcast(statusIntent); |
Christopher Tate | 06ba554 | 2009-04-09 16:03:56 -0700 | [diff] [blame] | 337 | } |
| 338 | else if (mPlugType == 0 && mLastPlugType != 0) { |
Christopher Tate | 93dc9fe | 2009-07-16 13:25:49 -0700 | [diff] [blame] | 339 | statusIntent.setAction(Intent.ACTION_POWER_DISCONNECTED); |
| 340 | mContext.sendBroadcast(statusIntent); |
Christopher Tate | 06ba554 | 2009-04-09 16:03:56 -0700 | [diff] [blame] | 341 | } |
Mihai Preda | a82842f | 2009-04-29 15:05:56 +0200 | [diff] [blame] | 342 | |
Mihai Preda | a82842f | 2009-04-29 15:05:56 +0200 | [diff] [blame] | 343 | if (sendBatteryLow) { |
Dianne Hackborn | 8ec5b83 | 2009-07-01 21:19:35 -0700 | [diff] [blame] | 344 | mSentLowBatteryBroadcast = true; |
Christopher Tate | 93dc9fe | 2009-07-16 13:25:49 -0700 | [diff] [blame] | 345 | statusIntent.setAction(Intent.ACTION_BATTERY_LOW); |
| 346 | mContext.sendBroadcast(statusIntent); |
Mike Lockwood | d81b1f4 | 2009-09-25 09:32:19 -0400 | [diff] [blame] | 347 | } else if (mSentLowBatteryBroadcast && mLastBatteryLevel >= mLowBatteryCloseWarningLevel) { |
Dianne Hackborn | 8ec5b83 | 2009-07-01 21:19:35 -0700 | [diff] [blame] | 348 | mSentLowBatteryBroadcast = false; |
Christopher Tate | 93dc9fe | 2009-07-16 13:25:49 -0700 | [diff] [blame] | 349 | statusIntent.setAction(Intent.ACTION_BATTERY_OKAY); |
| 350 | mContext.sendBroadcast(statusIntent); |
Mihai Preda | a82842f | 2009-04-29 15:05:56 +0200 | [diff] [blame] | 351 | } |
Doug Zongker | ab5c49c | 2009-12-04 10:31:43 -0800 | [diff] [blame] | 352 | |
Joe Onorato | de1b359 | 2010-10-25 20:36:47 -0700 | [diff] [blame] | 353 | // Update the battery LED |
| 354 | mLed.updateLightsLocked(); |
| 355 | |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 356 | // This needs to be done after sendIntent() so that we get the lastest battery stats. |
| 357 | if (logOutlier && dischargeDuration != 0) { |
| 358 | logOutlier(dischargeDuration); |
| 359 | } |
Doug Zongker | ab5c49c | 2009-12-04 10:31:43 -0800 | [diff] [blame] | 360 | |
Dianne Hackborn | 99f7eb45 | 2009-09-22 17:27:53 -0700 | [diff] [blame] | 361 | mLastBatteryStatus = mBatteryStatus; |
| 362 | mLastBatteryHealth = mBatteryHealth; |
| 363 | mLastBatteryPresent = mBatteryPresent; |
| 364 | mLastBatteryLevel = mBatteryLevel; |
| 365 | mLastPlugType = mPlugType; |
| 366 | mLastBatteryVoltage = mBatteryVoltage; |
| 367 | mLastBatteryTemperature = mBatteryTemperature; |
| 368 | mLastBatteryLevelCritical = mBatteryLevelCritical; |
Mike Lockwood | deff9c8 | 2010-09-04 10:29:17 -0400 | [diff] [blame] | 369 | mLastInvalidCharger = mInvalidCharger; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 370 | } |
| 371 | } |
| 372 | |
| 373 | private final void sendIntent() { |
| 374 | // Pack up the values and broadcast them to everyone |
| 375 | Intent intent = new Intent(Intent.ACTION_BATTERY_CHANGED); |
Dianne Hackborn | 1c633fc | 2009-12-08 19:45:14 -0800 | [diff] [blame] | 376 | intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY |
| 377 | | Intent.FLAG_RECEIVER_REPLACE_PENDING); |
Doug Zongker | ab5c49c | 2009-12-04 10:31:43 -0800 | [diff] [blame] | 378 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 379 | int icon = getIcon(mBatteryLevel); |
| 380 | |
Dianne Hackborn | edd9316 | 2009-09-19 14:03:05 -0700 | [diff] [blame] | 381 | intent.putExtra(BatteryManager.EXTRA_STATUS, mBatteryStatus); |
| 382 | intent.putExtra(BatteryManager.EXTRA_HEALTH, mBatteryHealth); |
| 383 | intent.putExtra(BatteryManager.EXTRA_PRESENT, mBatteryPresent); |
| 384 | intent.putExtra(BatteryManager.EXTRA_LEVEL, mBatteryLevel); |
| 385 | intent.putExtra(BatteryManager.EXTRA_SCALE, BATTERY_SCALE); |
| 386 | intent.putExtra(BatteryManager.EXTRA_ICON_SMALL, icon); |
| 387 | intent.putExtra(BatteryManager.EXTRA_PLUGGED, mPlugType); |
| 388 | intent.putExtra(BatteryManager.EXTRA_VOLTAGE, mBatteryVoltage); |
| 389 | intent.putExtra(BatteryManager.EXTRA_TEMPERATURE, mBatteryTemperature); |
| 390 | intent.putExtra(BatteryManager.EXTRA_TECHNOLOGY, mBatteryTechnology); |
Mike Lockwood | deff9c8 | 2010-09-04 10:29:17 -0400 | [diff] [blame] | 391 | intent.putExtra(BatteryManager.EXTRA_INVALID_CHARGER, mInvalidCharger); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 392 | |
Joe Onorato | 5385974 | 2011-04-06 18:27:43 -0700 | [diff] [blame] | 393 | if (false) { |
Joe Onorato | 4ca7f1e | 2010-10-27 15:32:23 -0700 | [diff] [blame] | 394 | Slog.d(TAG, "level:" + mBatteryLevel + |
Doug Zongker | ab5c49c | 2009-12-04 10:31:43 -0800 | [diff] [blame] | 395 | " scale:" + BATTERY_SCALE + " status:" + mBatteryStatus + |
| 396 | " health:" + mBatteryHealth + " present:" + mBatteryPresent + |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 397 | " voltage: " + mBatteryVoltage + |
| 398 | " temperature: " + mBatteryTemperature + |
| 399 | " technology: " + mBatteryTechnology + |
| 400 | " AC powered:" + mAcOnline + " USB powered:" + mUsbOnline + |
Mike Lockwood | deff9c8 | 2010-09-04 10:29:17 -0400 | [diff] [blame] | 401 | " icon:" + icon + " invalid charger:" + mInvalidCharger); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 402 | } |
| 403 | |
| 404 | ActivityManagerNative.broadcastStickyIntent(intent, null); |
| 405 | } |
| 406 | |
| 407 | private final void logBatteryStats() { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 408 | IBinder batteryInfoService = ServiceManager.getService(BATTERY_STATS_SERVICE_NAME); |
Dan Egnor | 18e9396 | 2010-02-10 19:27:58 -0800 | [diff] [blame] | 409 | if (batteryInfoService == null) return; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 410 | |
Dan Egnor | 18e9396 | 2010-02-10 19:27:58 -0800 | [diff] [blame] | 411 | DropBoxManager db = (DropBoxManager) mContext.getSystemService(Context.DROPBOX_SERVICE); |
| 412 | if (db == null || !db.isTagEnabled("BATTERY_DISCHARGE_INFO")) return; |
| 413 | |
| 414 | File dumpFile = null; |
| 415 | FileOutputStream dumpStream = null; |
| 416 | try { |
| 417 | // dump the service to a file |
| 418 | dumpFile = new File(DUMPSYS_DATA_PATH + BATTERY_STATS_SERVICE_NAME + ".dump"); |
| 419 | dumpStream = new FileOutputStream(dumpFile); |
| 420 | batteryInfoService.dump(dumpStream.getFD(), DUMPSYS_ARGS); |
Dianne Hackborn | 8bdf593 | 2010-10-15 12:54:40 -0700 | [diff] [blame] | 421 | FileUtils.sync(dumpStream); |
Dan Egnor | 18e9396 | 2010-02-10 19:27:58 -0800 | [diff] [blame] | 422 | |
| 423 | // add dump file to drop box |
| 424 | db.addFile("BATTERY_DISCHARGE_INFO", dumpFile, DropBoxManager.IS_TEXT); |
| 425 | } catch (RemoteException e) { |
Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 426 | Slog.e(TAG, "failed to dump battery service", e); |
Dan Egnor | 18e9396 | 2010-02-10 19:27:58 -0800 | [diff] [blame] | 427 | } catch (IOException e) { |
Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 428 | Slog.e(TAG, "failed to write dumpsys file", e); |
Dan Egnor | 18e9396 | 2010-02-10 19:27:58 -0800 | [diff] [blame] | 429 | } finally { |
| 430 | // make sure we clean up |
| 431 | if (dumpStream != null) { |
| 432 | try { |
| 433 | dumpStream.close(); |
| 434 | } catch (IOException e) { |
Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 435 | Slog.e(TAG, "failed to close dumpsys output stream"); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 436 | } |
Dan Egnor | 18e9396 | 2010-02-10 19:27:58 -0800 | [diff] [blame] | 437 | } |
| 438 | if (dumpFile != null && !dumpFile.delete()) { |
Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 439 | Slog.e(TAG, "failed to delete temporary dumpsys file: " |
Dan Egnor | 18e9396 | 2010-02-10 19:27:58 -0800 | [diff] [blame] | 440 | + dumpFile.getAbsolutePath()); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 441 | } |
| 442 | } |
| 443 | } |
Doug Zongker | ab5c49c | 2009-12-04 10:31:43 -0800 | [diff] [blame] | 444 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 445 | private final void logOutlier(long duration) { |
| 446 | ContentResolver cr = mContext.getContentResolver(); |
Doug Zongker | 43866e0 | 2010-01-07 12:09:54 -0800 | [diff] [blame] | 447 | String dischargeThresholdString = Settings.Secure.getString(cr, |
| 448 | Settings.Secure.BATTERY_DISCHARGE_THRESHOLD); |
| 449 | String durationThresholdString = Settings.Secure.getString(cr, |
| 450 | Settings.Secure.BATTERY_DISCHARGE_DURATION_THRESHOLD); |
Doug Zongker | ab5c49c | 2009-12-04 10:31:43 -0800 | [diff] [blame] | 451 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 452 | if (dischargeThresholdString != null && durationThresholdString != null) { |
| 453 | try { |
| 454 | long durationThreshold = Long.parseLong(durationThresholdString); |
| 455 | int dischargeThreshold = Integer.parseInt(dischargeThresholdString); |
Doug Zongker | ab5c49c | 2009-12-04 10:31:43 -0800 | [diff] [blame] | 456 | if (duration <= durationThreshold && |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 457 | mDischargeStartLevel - mBatteryLevel >= dischargeThreshold) { |
| 458 | // If the discharge cycle is bad enough we want to know about it. |
| 459 | logBatteryStats(); |
| 460 | } |
Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 461 | if (LOCAL_LOGV) Slog.v(TAG, "duration threshold: " + durationThreshold + |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 462 | " discharge threshold: " + dischargeThreshold); |
Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 463 | if (LOCAL_LOGV) Slog.v(TAG, "duration: " + duration + " discharge: " + |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 464 | (mDischargeStartLevel - mBatteryLevel)); |
| 465 | } catch (NumberFormatException e) { |
Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 466 | Slog.e(TAG, "Invalid DischargeThresholds GService string: " + |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 467 | durationThresholdString + " or " + dischargeThresholdString); |
| 468 | return; |
| 469 | } |
| 470 | } |
| 471 | } |
| 472 | |
| 473 | private final int getIcon(int level) { |
| 474 | if (mBatteryStatus == BatteryManager.BATTERY_STATUS_CHARGING) { |
| 475 | return com.android.internal.R.drawable.stat_sys_battery_charge; |
Joe Onorato | 794be40 | 2010-11-21 19:22:25 -0800 | [diff] [blame] | 476 | } else if (mBatteryStatus == BatteryManager.BATTERY_STATUS_DISCHARGING) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 477 | return com.android.internal.R.drawable.stat_sys_battery; |
Joe Onorato | 794be40 | 2010-11-21 19:22:25 -0800 | [diff] [blame] | 478 | } else if (mBatteryStatus == BatteryManager.BATTERY_STATUS_NOT_CHARGING |
| 479 | || mBatteryStatus == BatteryManager.BATTERY_STATUS_FULL) { |
| 480 | if (isPowered() && mBatteryLevel >= 100) { |
| 481 | return com.android.internal.R.drawable.stat_sys_battery_charge; |
| 482 | } else { |
| 483 | return com.android.internal.R.drawable.stat_sys_battery; |
| 484 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 485 | } else { |
| 486 | return com.android.internal.R.drawable.stat_sys_battery_unknown; |
| 487 | } |
| 488 | } |
| 489 | |
| 490 | @Override |
| 491 | protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) { |
| 492 | if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP) |
| 493 | != PackageManager.PERMISSION_GRANTED) { |
Doug Zongker | ab5c49c | 2009-12-04 10:31:43 -0800 | [diff] [blame] | 494 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 495 | pw.println("Permission Denial: can't dump Battery service from from pid=" |
| 496 | + Binder.getCallingPid() |
| 497 | + ", uid=" + Binder.getCallingUid()); |
| 498 | return; |
| 499 | } |
| 500 | |
Mike Lockwood | e817404 | 2011-08-16 12:53:43 -0700 | [diff] [blame] | 501 | if (args == null || args.length == 0 || "-a".equals(args[0])) { |
Joe Onorato | 4ca7f1e | 2010-10-27 15:32:23 -0700 | [diff] [blame] | 502 | synchronized (this) { |
| 503 | pw.println("Current Battery Service state:"); |
| 504 | pw.println(" AC powered: " + mAcOnline); |
| 505 | pw.println(" USB powered: " + mUsbOnline); |
| 506 | pw.println(" status: " + mBatteryStatus); |
| 507 | pw.println(" health: " + mBatteryHealth); |
| 508 | pw.println(" present: " + mBatteryPresent); |
| 509 | pw.println(" level: " + mBatteryLevel); |
| 510 | pw.println(" scale: " + BATTERY_SCALE); |
| 511 | pw.println(" voltage:" + mBatteryVoltage); |
| 512 | pw.println(" temperature: " + mBatteryTemperature); |
| 513 | pw.println(" technology: " + mBatteryTechnology); |
| 514 | } |
| 515 | } else if (false) { |
| 516 | // DO NOT SUBMIT WITH THIS TURNED ON |
| 517 | if (args.length == 3 && "set".equals(args[0])) { |
| 518 | String key = args[1]; |
| 519 | String value = args[2]; |
| 520 | try { |
| 521 | boolean update = true; |
| 522 | if ("ac".equals(key)) { |
| 523 | mAcOnline = Integer.parseInt(value) != 0; |
| 524 | } else if ("usb".equals(key)) { |
| 525 | mUsbOnline = Integer.parseInt(value) != 0; |
| 526 | } else if ("status".equals(key)) { |
| 527 | mBatteryStatus = Integer.parseInt(value); |
| 528 | } else if ("level".equals(key)) { |
| 529 | mBatteryLevel = Integer.parseInt(value); |
| 530 | } else if ("invalid".equals(key)) { |
| 531 | mInvalidCharger = Integer.parseInt(value); |
| 532 | } else { |
| 533 | update = false; |
| 534 | } |
| 535 | if (update) { |
| 536 | processValues(); |
| 537 | } |
| 538 | } catch (NumberFormatException ex) { |
| 539 | pw.println("Bad value: " + value); |
| 540 | } |
| 541 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 542 | } |
| 543 | } |
Joe Onorato | de1b359 | 2010-10-25 20:36:47 -0700 | [diff] [blame] | 544 | |
| 545 | class Led { |
| 546 | private LightsService mLightsService; |
| 547 | private LightsService.Light mBatteryLight; |
| 548 | |
| 549 | private int mBatteryLowARGB; |
| 550 | private int mBatteryMediumARGB; |
| 551 | private int mBatteryFullARGB; |
| 552 | private int mBatteryLedOn; |
| 553 | private int mBatteryLedOff; |
| 554 | |
| 555 | private boolean mBatteryCharging; |
| 556 | private boolean mBatteryLow; |
| 557 | private boolean mBatteryFull; |
| 558 | |
| 559 | Led(Context context, LightsService lights) { |
| 560 | mLightsService = lights; |
| 561 | mBatteryLight = lights.getLight(LightsService.LIGHT_ID_BATTERY); |
| 562 | |
| 563 | mBatteryLowARGB = mContext.getResources().getInteger( |
| 564 | com.android.internal.R.integer.config_notificationsBatteryLowARGB); |
| 565 | mBatteryMediumARGB = mContext.getResources().getInteger( |
| 566 | com.android.internal.R.integer.config_notificationsBatteryMediumARGB); |
| 567 | mBatteryFullARGB = mContext.getResources().getInteger( |
| 568 | com.android.internal.R.integer.config_notificationsBatteryFullARGB); |
| 569 | mBatteryLedOn = mContext.getResources().getInteger( |
| 570 | com.android.internal.R.integer.config_notificationsBatteryLedOn); |
| 571 | mBatteryLedOff = mContext.getResources().getInteger( |
| 572 | com.android.internal.R.integer.config_notificationsBatteryLedOff); |
| 573 | } |
| 574 | |
| 575 | /** |
| 576 | * Synchronize on BatteryService. |
| 577 | */ |
| 578 | void updateLightsLocked() { |
| 579 | final int level = mBatteryLevel; |
| 580 | final int status = mBatteryStatus; |
| 581 | if (level < mLowBatteryWarningLevel) { |
| 582 | if (status == BatteryManager.BATTERY_STATUS_CHARGING) { |
| 583 | // Solid red when battery is charging |
| 584 | mBatteryLight.setColor(mBatteryLowARGB); |
| 585 | } else { |
| 586 | // Flash red when battery is low and not charging |
| 587 | mBatteryLight.setFlashing(mBatteryLowARGB, LightsService.LIGHT_FLASH_TIMED, |
| 588 | mBatteryLedOn, mBatteryLedOff); |
| 589 | } |
| 590 | } else if (status == BatteryManager.BATTERY_STATUS_CHARGING |
| 591 | || status == BatteryManager.BATTERY_STATUS_FULL) { |
| 592 | if (status == BatteryManager.BATTERY_STATUS_FULL || level >= 90) { |
| 593 | // Solid green when full or charging and nearly full |
| 594 | mBatteryLight.setColor(mBatteryFullARGB); |
| 595 | } else { |
| 596 | // Solid orange when charging and halfway full |
| 597 | mBatteryLight.setColor(mBatteryMediumARGB); |
| 598 | } |
| 599 | } else { |
| 600 | // No lights if not charging and not low |
| 601 | mBatteryLight.turnOff(); |
| 602 | } |
| 603 | } |
| 604 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 605 | } |
Joe Onorato | de1b359 | 2010-10-25 20:36:47 -0700 | [diff] [blame] | 606 | |