• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 import static android.os.Flags.FLAG_STATE_OF_HEALTH_PUBLIC;
20 import static android.os.Flags.FLAG_BATTERY_PART_STATUS_API;
21 
22 import android.Manifest.permission;
23 import android.annotation.FlaggedApi;
24 import android.annotation.Nullable;
25 import android.annotation.RequiresPermission;
26 import android.annotation.SuppressLint;
27 import android.annotation.SystemApi;
28 import android.annotation.SystemService;
29 import android.annotation.TestApi;
30 import android.compat.annotation.UnsupportedAppUsage;
31 import android.content.Context;
32 import android.content.Intent;
33 import android.hardware.health.V1_0.Constants;
34 
35 import com.android.internal.app.IBatteryStats;
36 
37 /**
38  * The BatteryManager class contains strings and constants used for values
39  * in the {@link android.content.Intent#ACTION_BATTERY_CHANGED} Intent, and
40  * provides a method for querying battery and charging properties.
41  */
42 @SystemService(Context.BATTERY_SERVICE)
43 public class BatteryManager {
44     /**
45      * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
46      * integer containing the current status constant.
47      */
48     public static final String EXTRA_STATUS = "status";
49 
50     /**
51      * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
52      * integer containing the current health constant.
53      */
54     public static final String EXTRA_HEALTH = "health";
55 
56     /**
57      * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
58      * boolean indicating whether a battery is present.
59      */
60     public static final String EXTRA_PRESENT = "present";
61 
62     /**
63      * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
64      * integer field containing the current battery level, from 0 to
65      * {@link #EXTRA_SCALE}.
66      */
67     public static final String EXTRA_LEVEL = "level";
68 
69     /**
70      * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
71      * Boolean field indicating whether the battery is currently considered to be
72      * low, that is whether a {@link Intent#ACTION_BATTERY_LOW} broadcast
73      * has been sent.
74      */
75     public static final String EXTRA_BATTERY_LOW = "battery_low";
76 
77     /**
78      * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
79      * integer containing the maximum battery level.
80      */
81     public static final String EXTRA_SCALE = "scale";
82 
83     /**
84      * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
85      * integer containing the resource ID of a small status bar icon
86      * indicating the current battery state.
87      */
88     public static final String EXTRA_ICON_SMALL = "icon-small";
89 
90     /**
91      * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
92      * integer indicating whether the device is plugged in to a power
93      * source; 0 means it is on battery, other constants are different
94      * types of power sources.
95      */
96     public static final String EXTRA_PLUGGED = "plugged";
97 
98     /**
99      * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
100      * integer containing the current battery voltage level.
101      */
102     public static final String EXTRA_VOLTAGE = "voltage";
103 
104     /**
105      * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
106      * integer containing the current battery temperature.
107      */
108     public static final String EXTRA_TEMPERATURE = "temperature";
109 
110     /**
111      * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
112      * String describing the technology of the current battery.
113      */
114     public static final String EXTRA_TECHNOLOGY = "technology";
115 
116     /**
117      * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
118      * Int value set to nonzero if an unsupported charger is attached
119      * to the device.
120      * {@hide}
121      */
122     @UnsupportedAppUsage
123     public static final String EXTRA_INVALID_CHARGER = "invalid_charger";
124 
125     /**
126      * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
127      * Int value set to the maximum charging current supported by the charger in micro amperes.
128      * {@hide}
129      */
130     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
131     public static final String EXTRA_MAX_CHARGING_CURRENT = "max_charging_current";
132 
133     /**
134      * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
135      * Int value set to the maximum charging voltage supported by the charger in micro volts.
136      * {@hide}
137      */
138     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
139     public static final String EXTRA_MAX_CHARGING_VOLTAGE = "max_charging_voltage";
140 
141     /**
142      * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
143      * integer containing the charge counter present in the battery.
144      * {@hide}
145      */
146      @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
147      public static final String EXTRA_CHARGE_COUNTER = "charge_counter";
148 
149     /**
150      * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
151      * Current int sequence number of the update.
152      * {@hide}
153      */
154     public static final String EXTRA_SEQUENCE = "seq";
155 
156     /**
157      * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
158      * Int value representing the battery charging cycle count.
159      */
160     public static final String EXTRA_CYCLE_COUNT = "android.os.extra.CYCLE_COUNT";
161 
162     /**
163      * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
164      * Int value representing the battery charging status.
165      */
166     public static final String EXTRA_CHARGING_STATUS = "android.os.extra.CHARGING_STATUS";
167 
168     /**
169      * Extra for {@link android.content.Intent#ACTION_BATTERY_LEVEL_CHANGED}:
170      * Contains list of Bundles representing battery events
171      * @hide
172      */
173     @SystemApi
174     public static final String EXTRA_EVENTS = "android.os.extra.EVENTS";
175 
176     /**
177      * Extra for event in {@link android.content.Intent#ACTION_BATTERY_LEVEL_CHANGED}:
178      * Long value representing time when event occurred as returned by
179      * {@link android.os.SystemClock#elapsedRealtime()}
180      * @hide
181      */
182     @SystemApi
183     public static final String EXTRA_EVENT_TIMESTAMP = "android.os.extra.EVENT_TIMESTAMP";
184 
185     // values for "status" field in the ACTION_BATTERY_CHANGED Intent
186     public static final int BATTERY_STATUS_UNKNOWN = Constants.BATTERY_STATUS_UNKNOWN;
187     public static final int BATTERY_STATUS_CHARGING = Constants.BATTERY_STATUS_CHARGING;
188     public static final int BATTERY_STATUS_DISCHARGING = Constants.BATTERY_STATUS_DISCHARGING;
189     public static final int BATTERY_STATUS_NOT_CHARGING = Constants.BATTERY_STATUS_NOT_CHARGING;
190     public static final int BATTERY_STATUS_FULL = Constants.BATTERY_STATUS_FULL;
191 
192     // values for "health" field in the ACTION_BATTERY_CHANGED Intent
193     public static final int BATTERY_HEALTH_UNKNOWN = Constants.BATTERY_HEALTH_UNKNOWN;
194     public static final int BATTERY_HEALTH_GOOD = Constants.BATTERY_HEALTH_GOOD;
195     public static final int BATTERY_HEALTH_OVERHEAT = Constants.BATTERY_HEALTH_OVERHEAT;
196     public static final int BATTERY_HEALTH_DEAD = Constants.BATTERY_HEALTH_DEAD;
197     public static final int BATTERY_HEALTH_OVER_VOLTAGE = Constants.BATTERY_HEALTH_OVER_VOLTAGE;
198     public static final int BATTERY_HEALTH_UNSPECIFIED_FAILURE = Constants.BATTERY_HEALTH_UNSPECIFIED_FAILURE;
199     public static final int BATTERY_HEALTH_COLD = Constants.BATTERY_HEALTH_COLD;
200 
201     // values of the "plugged" field in the ACTION_BATTERY_CHANGED intent.
202     // These must be powers of 2.
203     /** Power source is an AC charger. */
204     public static final int BATTERY_PLUGGED_AC = OsProtoEnums.BATTERY_PLUGGED_AC; // = 1
205     /** Power source is a USB port. */
206     public static final int BATTERY_PLUGGED_USB = OsProtoEnums.BATTERY_PLUGGED_USB; // = 2
207     /** Power source is wireless. */
208     public static final int BATTERY_PLUGGED_WIRELESS = OsProtoEnums.BATTERY_PLUGGED_WIRELESS; // = 4
209     /** Power source is dock. */
210     public static final int BATTERY_PLUGGED_DOCK = OsProtoEnums.BATTERY_PLUGGED_DOCK; // = 8
211 
212     // values for "charge policy" property
213     /**
214      * Default policy (e.g. normal).
215      * @hide
216      */
217     @SystemApi
218     public static final int CHARGING_POLICY_DEFAULT = OsProtoEnums.CHARGING_POLICY_DEFAULT; // = 1
219     /**
220      * Optimized for battery health using static thresholds (e.g stop at 80%).
221      * @hide
222      */
223     @SystemApi
224     public static final int CHARGING_POLICY_ADAPTIVE_AON =
225                                             OsProtoEnums.CHARGING_POLICY_ADAPTIVE_AON; // = 2
226     /**
227      * Optimized for battery health using adaptive thresholds.
228      * @hide
229      */
230     @SystemApi
231     public static final int CHARGING_POLICY_ADAPTIVE_AC =
232                                             OsProtoEnums.CHARGING_POLICY_ADAPTIVE_AC; // = 3
233     /**
234      * Optimized for battery health, devices always connected to power.
235      * @hide
236      */
237     @SystemApi
238     public static final int CHARGING_POLICY_ADAPTIVE_LONGLIFE =
239                                             OsProtoEnums.CHARGING_POLICY_ADAPTIVE_LONGLIFE; // = 4
240 
241     /**
242      * Returns true if the policy is some type of adaptive charging policy.
243      * @hide
244      */
isAdaptiveChargingPolicy(int policy)245     public static boolean isAdaptiveChargingPolicy(int policy) {
246         return policy == CHARGING_POLICY_ADAPTIVE_AC
247                 || policy == CHARGING_POLICY_ADAPTIVE_AON
248                 || policy == CHARGING_POLICY_ADAPTIVE_LONGLIFE;
249     }
250 
251     // values for "battery part status" property
252     /**
253      * Battery part status is not supported.
254      * @hide
255      */
256     @SystemApi
257     @FlaggedApi(FLAG_BATTERY_PART_STATUS_API)
258     public static final int PART_STATUS_UNSUPPORTED = 0;
259 
260     /**
261      * Battery is the original device battery.
262      * @hide
263      */
264     @SystemApi
265     @FlaggedApi(FLAG_BATTERY_PART_STATUS_API)
266     public static final int PART_STATUS_ORIGINAL = 1;
267 
268     /**
269      * Battery has been replaced.
270      * @hide
271      */
272     @SystemApi
273     @FlaggedApi(FLAG_BATTERY_PART_STATUS_API)
274     public static final int PART_STATUS_REPLACED = 2;
275 
276     /** @hide */
277     @SuppressLint("UnflaggedApi") // TestApi without associated feature.
278     @TestApi
279     public static final int BATTERY_PLUGGED_ANY =
280             BATTERY_PLUGGED_AC | BATTERY_PLUGGED_USB | BATTERY_PLUGGED_WIRELESS
281                     | BATTERY_PLUGGED_DOCK;
282 
283     /**
284      * Sent when the device's battery has started charging (or has reached full charge
285      * and the device is on power).  This is a good time to do work that you would like to
286      * avoid doing while on battery (that is to avoid draining the user's battery due to
287      * things they don't care enough about).
288      *
289      * This is paired with {@link #ACTION_DISCHARGING}.  The current state can always
290      * be retrieved with {@link #isCharging()}.
291      */
292     public static final String ACTION_CHARGING = "android.os.action.CHARGING";
293 
294     /**
295      * Sent when the device's battery may be discharging, so apps should avoid doing
296      * extraneous work that would cause it to discharge faster.
297      *
298      * This is paired with {@link #ACTION_CHARGING}.  The current state can always
299      * be retrieved with {@link #isCharging()}.
300      */
301     public static final String ACTION_DISCHARGING = "android.os.action.DISCHARGING";
302 
303     /*
304      * Battery property identifiers.  These must match the values in
305      * frameworks/native/include/batteryservice/BatteryService.h
306      */
307     /** Battery capacity in microampere-hours, as an integer. */
308     public static final int BATTERY_PROPERTY_CHARGE_COUNTER = 1;
309 
310     /**
311      * Instantaneous battery current in microamperes, as an integer.  Positive
312      * values indicate net current entering the battery from a charge source,
313      * negative values indicate net current discharging from the battery.
314      */
315     public static final int BATTERY_PROPERTY_CURRENT_NOW = 2;
316 
317     /**
318      * Average battery current in microamperes, as an integer.  Positive
319      * values indicate net current entering the battery from a charge source,
320      * negative values indicate net current discharging from the battery.
321      * The time period over which the average is computed may depend on the
322      * fuel gauge hardware and its configuration.
323      */
324     public static final int BATTERY_PROPERTY_CURRENT_AVERAGE = 3;
325 
326     /**
327      * Remaining battery capacity as an integer percentage of total capacity
328      * (with no fractional part).
329      */
330     public static final int BATTERY_PROPERTY_CAPACITY = 4;
331 
332     /**
333      * Battery remaining energy in nanowatt-hours, as a long integer.
334      */
335     public static final int BATTERY_PROPERTY_ENERGY_COUNTER = 5;
336 
337     /**
338      * Battery charge status, from a BATTERY_STATUS_* value.
339      */
340     public static final int BATTERY_PROPERTY_STATUS = 6;
341 
342     /**
343      * Battery manufacturing date is reported in epoch. The 0 timepoint
344      * begins at midnight Coordinated Universal Time (UTC) on January 1, 1970.
345      * It is a long integer in seconds.
346      *
347      * <p class="note">
348      * The sender must hold the {@link android.Manifest.permission#BATTERY_STATS} permission.
349      *
350      * Example: <code>
351      *  // The value returned from the API can be used to create a Date, used
352      *  // to set the time on a calendar and coverted to a string.
353      *  import java.util.Date;
354      *
355      *  mBatteryManager = mContext.getSystemService(BatteryManager.class);
356      *  final long manufacturingDate =
357      *      mBatteryManager.getLongProperty(BatteryManager.BATTERY_PROPERTY_MANUFACTURING_DATE);
358      *  Date date = new Date(manufacturingDate);
359      *  Calendar calendar = Calendar.getInstance();
360      *  calendar.setTime(date);
361      * // Convert to yyyy-MM-dd HH:mm:ss format string
362      *  SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
363      *  String dateString = sdf.format(date);
364      * </code>
365      * @hide
366      */
367     @RequiresPermission(permission.BATTERY_STATS)
368     @SystemApi
369     public static final int BATTERY_PROPERTY_MANUFACTURING_DATE = 7;
370 
371     /**
372      * The date of first usage is reported in epoch. The 0 timepoint
373      * begins at midnight Coordinated Universal Time (UTC) on January 1, 1970.
374      * It is a long integer in seconds.
375      *
376      * <p class="note">
377      * The sender must hold the {@link android.Manifest.permission#BATTERY_STATS} permission.
378      *
379      * {@link BATTERY_PROPERTY_MANUFACTURING_DATE for sample code}
380      * @hide
381      */
382     @RequiresPermission(permission.BATTERY_STATS)
383     @SystemApi
384     public static final int BATTERY_PROPERTY_FIRST_USAGE_DATE = 8;
385 
386     /**
387      * Battery charging policy from a CHARGING_POLICY_* value..
388      *
389      * <p class="note">
390      * The sender must hold the {@link android.Manifest.permission#BATTERY_STATS} permission.
391      *
392      * @hide
393      */
394     @RequiresPermission(permission.BATTERY_STATS)
395     @SystemApi
396     public static final int BATTERY_PROPERTY_CHARGING_POLICY = 9;
397 
398     /**
399      * Percentage representing the measured battery state of health.
400      * This is the remaining estimated full charge capacity relative
401      * to the rated capacity in %.
402      */
403     @FlaggedApi(FLAG_STATE_OF_HEALTH_PUBLIC)
404     public static final int BATTERY_PROPERTY_STATE_OF_HEALTH = 10;
405 
406     /**
407      * Battery part serial number.
408      *
409      * <p class="note">
410      * The sender must hold the {@link android.Manifest.permission#BATTERY_STATS} permission.
411      *
412      * @hide
413      */
414     @RequiresPermission(permission.BATTERY_STATS)
415     @SystemApi
416     @FlaggedApi(FLAG_BATTERY_PART_STATUS_API)
417     public static final int BATTERY_PROPERTY_SERIAL_NUMBER = 11;
418 
419     /**
420      * Battery part status from a BATTERY_PART_STATUS_* value.
421      *
422      * <p class="note">
423      * The sender must hold the {@link android.Manifest.permission#BATTERY_STATS} permission.
424      *
425      * @hide
426      */
427     @RequiresPermission(permission.BATTERY_STATS)
428     @SystemApi
429     @FlaggedApi(FLAG_BATTERY_PART_STATUS_API)
430     public static final int BATTERY_PROPERTY_PART_STATUS = 12;
431 
432     private final Context mContext;
433     private final IBatteryStats mBatteryStats;
434     private final IBatteryPropertiesRegistrar mBatteryPropertiesRegistrar;
435 
436     /**
437      * @removed Was previously made visible by accident.
438      */
BatteryManager()439     public BatteryManager() {
440         mContext = null;
441         mBatteryStats = IBatteryStats.Stub.asInterface(
442                 ServiceManager.getService(BatteryStats.SERVICE_NAME));
443         mBatteryPropertiesRegistrar = IBatteryPropertiesRegistrar.Stub.asInterface(
444                 ServiceManager.getService("batteryproperties"));
445     }
446 
447     /** {@hide} */
BatteryManager(Context context, IBatteryStats batteryStats, IBatteryPropertiesRegistrar batteryPropertiesRegistrar)448     public BatteryManager(Context context,
449             IBatteryStats batteryStats,
450             IBatteryPropertiesRegistrar batteryPropertiesRegistrar) {
451         mContext = context;
452         mBatteryStats = batteryStats;
453         mBatteryPropertiesRegistrar = batteryPropertiesRegistrar;
454     }
455 
456     /**
457      * Return true if the battery is currently considered to be charging.  This means that
458      * the device is plugged in and is supplying sufficient power that the battery level is
459      * going up (or the battery is fully charged).  Changes in this state are matched by
460      * broadcasts of {@link #ACTION_CHARGING} and {@link #ACTION_DISCHARGING}.
461      */
isCharging()462     public boolean isCharging() {
463         try {
464             return mBatteryStats.isCharging();
465         } catch (RemoteException e) {
466             throw e.rethrowFromSystemServer();
467         }
468     }
469 
470     /**
471      * Query a battery property from the batteryproperties service.
472      *
473      * Returns the requested value, or Long.MIN_VALUE if property not
474      * supported on this system or on other error.
475      */
queryProperty(int id)476     private long queryProperty(int id) {
477         long ret;
478 
479         if (mBatteryPropertiesRegistrar == null) {
480             return Long.MIN_VALUE;
481         }
482 
483         try {
484             BatteryProperty prop = new BatteryProperty();
485             if (mBatteryPropertiesRegistrar.getProperty(id, prop) == 0)
486                 ret = prop.getLong();
487             else
488                 ret = Long.MIN_VALUE;
489         } catch (RemoteException e) {
490             throw e.rethrowFromSystemServer();
491         }
492 
493         return ret;
494     }
495 
496     /**
497      * Same as queryProperty, but for strings.
498      */
queryStringProperty(int id)499     private String queryStringProperty(int id) {
500         if (mBatteryPropertiesRegistrar == null) {
501             return null;
502         }
503 
504         try {
505             BatteryProperty prop = new BatteryProperty();
506             if (mBatteryPropertiesRegistrar.getProperty(id, prop) == 0) {
507                 return prop.getString();
508             }
509             return null;
510         } catch (RemoteException e) {
511             throw e.rethrowFromSystemServer();
512         }
513     }
514 
515     /**
516      * Return the value of a battery property of integer type.
517      *
518      * @param id identifier of the requested property
519      *
520      * @return the property value. If the property is not supported or there is any other error,
521      *    return (a) 0 if {@code targetSdkVersion < VERSION_CODES.P} or (b) Integer.MIN_VALUE
522      *    if {@code targetSdkVersion >= VERSION_CODES.P}.
523      */
getIntProperty(int id)524     public int getIntProperty(int id) {
525         long value = queryProperty(id);
526         if (value == Long.MIN_VALUE && mContext != null
527                 && mContext.getApplicationInfo().targetSdkVersion
528                     >= android.os.Build.VERSION_CODES.P) {
529             return Integer.MIN_VALUE;
530         }
531 
532         return (int) value;
533     }
534 
535     /**
536      * Return the value of a battery property of long type If the
537      * platform does not provide the property queried, this value will
538      * be Long.MIN_VALUE.
539      *
540      * @param id identifier of the requested property
541      *
542      * @return the property value, or Long.MIN_VALUE if not supported.
543      */
getLongProperty(int id)544     public long getLongProperty(int id) {
545         return queryProperty(id);
546     }
547 
548     /**
549      * Return the value of a battery property of String type. If the
550      * platform does not provide the property queried, this value will
551      * be null.
552      *
553      * @param id identifier of the requested property.
554      *
555      * @return the property value, or null if not supported.
556      */
557     @Nullable
558     @FlaggedApi(FLAG_BATTERY_PART_STATUS_API)
getStringProperty(int id)559     public String getStringProperty(int id) {
560         return queryStringProperty(id);
561     }
562 
563     /**
564      * Return true if the plugType given is wired
565      * @param plugType {@link #BATTERY_PLUGGED_AC}, {@link #BATTERY_PLUGGED_USB},
566      *        or {@link #BATTERY_PLUGGED_WIRELESS}
567      *
568      * @return true if plugType is wired
569      * @hide
570      */
isPlugWired(int plugType)571     public static boolean isPlugWired(int plugType) {
572         return plugType == BATTERY_PLUGGED_USB || plugType == BATTERY_PLUGGED_AC;
573     }
574 
575     /**
576      * Compute an approximation for how much time (in milliseconds) remains until the battery is
577      * fully charged. Returns -1 if no time can be computed: either there is not enough current
578      * data to make a decision or the battery is currently discharging.
579      *
580      * @return how much time is left, in milliseconds, until the battery is fully charged or -1 if
581      *         the computation fails
582      */
computeChargeTimeRemaining()583     public long computeChargeTimeRemaining() {
584         try {
585             return mBatteryStats.computeChargeTimeRemaining();
586         } catch (RemoteException e) {
587             throw e.rethrowFromSystemServer();
588         }
589     }
590 
591     /**
592      * Sets the delay for reporting battery state as charging after device is plugged in.
593      * This allows machine-learning or heuristics to delay the reporting and the corresponding
594      * broadcast, based on battery level, charging rate, and/or other parameters.
595      *
596      * @param delayMillis the delay in milliseconds, negative value to reset.
597      *
598      * @return True if the delay was set successfully.
599      *
600      * @see ACTION_CHARGING
601      * @hide
602      */
603     @RequiresPermission(permission.POWER_SAVER)
604     @SystemApi
setChargingStateUpdateDelayMillis(int delayMillis)605     public boolean setChargingStateUpdateDelayMillis(int delayMillis) {
606         try {
607             return mBatteryStats.setChargingStateUpdateDelayMillis(delayMillis);
608         } catch (RemoteException e) {
609             throw e.rethrowFromSystemServer();
610         }
611     }
612 }
613