摘抄源码记录下
http://androidxref.com/9.0.0_r3/xref/frameworks/native/include/batteryservice/BatteryServiceConstants.h

// This file is autogenerated by hidl-gen. Do not edit manually.
2
3#ifndef HIDL_GENERATED_android_hardware_health_V1_0_EXPORTED_CONSTANTS_H_
4#define HIDL_GENERATED_android_hardware_health_V1_0_EXPORTED_CONSTANTS_H_
5
6#ifdef __cplusplus
7extern “C” {
8#endif
9
10enum {
11 BATTERY_STATUS_UNKNOWN = 1,
12 BATTERY_STATUS_CHARGING = 2,
13 BATTERY_STATUS_DISCHARGING = 3,
14 BATTERY_STATUS_NOT_CHARGING = 4,
15 BATTERY_STATUS_FULL = 5,
16};
17
18enum {
19 BATTERY_HEALTH_UNKNOWN = 1,
20 BATTERY_HEALTH_GOOD = 2,
21 BATTERY_HEALTH_OVERHEAT = 3,
22 BATTERY_HEALTH_DEAD = 4,
23 BATTERY_HEALTH_OVER_VOLTAGE = 5,
24 BATTERY_HEALTH_UNSPECIFIED_FAILURE = 6,
25 BATTERY_HEALTH_COLD = 7,
26};
27
28#ifdef _cplusplus
29}
30#endif
31
32#endif // HIDL_GENERATED_android_hardware_health_V1_0_EXPORTED_CONSTANTS_H

33

32@SystemService(Context.BATTERY_SERVICE)
33public class BatteryManager {
34 /**
35 * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
36 * integer containing the current status constant.
37 /
38 public static final String EXTRA_STATUS = “status”;
39
40 /
*
41 * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
42 * integer containing the current health constant.
43 /
44 public static final String EXTRA_HEALTH = “health”;
45
46 /
*
47 * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
48 * boolean indicating whether a battery is present.
49 /
50 public static final String EXTRA_PRESENT = “present”;
51
52 /
*
53 * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
54 * integer field containing the current battery level, from 0 to
55 * {@link #EXTRA_SCALE}.
56 /
57 public static final String EXTRA_LEVEL = “level”;
58
59 /
*
60 * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
61 * Boolean field indicating whether the battery is currently considered to be
62 * low, that is whether a {@link Intent#ACTION_BATTERY_LOW} broadcast
63 * has been sent.
64 /
65 public static final String EXTRA_BATTERY_LOW = “battery_low”;
66
67 /
*
68 * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
69 * integer containing the maximum battery level.
70 /
71 public static final String EXTRA_SCALE = “scale”;
72
73 /
*
74 * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
75 * integer containing the resource ID of a small status bar icon
76 * indicating the current battery state.
77 /
78 public static final String EXTRA_ICON_SMALL = “icon-small”;
79
80 /
*
81 * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
82 * integer indicating whether the device is plugged in to a power
83 * source; 0 means it is on battery, other constants are different
84 * types of power sources.
85 /
86 public static final String EXTRA_PLUGGED = “plugged”;
87
88 /
*
89 * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
90 * integer containing the current battery voltage level.
91 /
92 public static final String EXTRA_VOLTAGE = “voltage”;
93
94 /
*
95 * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
96 * integer containing the current battery temperature.
97 /
98 public static final String EXTRA_TEMPERATURE = “temperature”;
99
100 /
*
101 * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
102 * String describing the technology of the current battery.
103 /
104 public static final String EXTRA_TECHNOLOGY = “technology”;
105
106 /
*
107 * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
108 * Int value set to nonzero if an unsupported charger is attached
109 * to the device.
110 * {@hide}
111 /
112 public static final String EXTRA_INVALID_CHARGER = “invalid_charger”;
113
114 /
*
115 * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
116 * Int value set to the maximum charging current supported by the charger in micro amperes.
117 * {@hide}
118 /
119 public static final String EXTRA_MAX_CHARGING_CURRENT = “max_charging_current”;
120
121 /
*
122 * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
123 * Int value set to the maximum charging voltage supported by the charger in micro volts.
124 * {@hide}
125 /
126 public static final String EXTRA_MAX_CHARGING_VOLTAGE = “max_charging_voltage”;
127
128 /
*
129 * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
130 * integer containing the charge counter present in the battery.
131 * {@hide}
132 /
133 public static final String EXTRA_CHARGE_COUNTER = “charge_counter”;
134
135 /
*
136 * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
137 * Current int sequence number of the update.
138 * {@hide}
139 /
140 public static final String EXTRA_SEQUENCE = “seq”;
141
142 /
*
143 * Extra for {@link android.content.Intent#ACTION_BATTERY_LEVEL_CHANGED}:
144 * Contains list of Bundles representing battery events
145 * @hide
146 /
147 @SystemApi
148 public static final String EXTRA_EVENTS = “android.os.extra.EVENTS”;
149
150 /
*
151 * Extra for event in {@link android.content.Intent#ACTION_BATTERY_LEVEL_CHANGED}:
152 * Long value representing time when event occurred as returned by
153 * {@link android.os.SystemClock#elapsedRealtime()}
154 * @hide
155 /
156 @SystemApi
157 public static final String EXTRA_EVENT_TIMESTAMP = “android.os.extra.EVENT_TIMESTAMP”;
158
159 // values for “status” field in the ACTION_BATTERY_CHANGED Intent
160 public static final int BATTERY_STATUS_UNKNOWN = Constants.BATTERY_STATUS_UNKNOWN;
161 public static final int BATTERY_STATUS_CHARGING = Constants.BATTERY_STATUS_CHARGING;
162 public static final int BATTERY_STATUS_DISCHARGING = Constants.BATTERY_STATUS_DISCHARGING;
163 public static final int BATTERY_STATUS_NOT_CHARGING = Constants.BATTERY_STATUS_NOT_CHARGING;
164 public static final int BATTERY_STATUS_FULL = Constants.BATTERY_STATUS_FULL;
165
166 // values for “health” field in the ACTION_BATTERY_CHANGED Intent
167 public static final int BATTERY_HEALTH_UNKNOWN = Constants.BATTERY_HEALTH_UNKNOWN;
168 public static final int BATTERY_HEALTH_GOOD = Constants.BATTERY_HEALTH_GOOD;
169 public static final int BATTERY_HEALTH_OVERHEAT = Constants.BATTERY_HEALTH_OVERHEAT;
170 public static final int BATTERY_HEALTH_DEAD = Constants.BATTERY_HEALTH_DEAD;
171 public static final int BATTERY_HEALTH_OVER_VOLTAGE = Constants.BATTERY_HEALTH_OVER_VOLTAGE;
172 public static final int BATTERY_HEALTH_UNSPECIFIED_FAILURE = Constants.BATTERY_HEALTH_UNSPECIFIED_FAILURE;
173 public static final int BATTERY_HEALTH_COLD = Constants.BATTERY_HEALTH_COLD;
174
175 // values of the “plugged” field in the ACTION_BATTERY_CHANGED intent.
176 // These must be powers of 2.
177 /
* Power source is an AC charger. /
178 public static final int BATTERY_PLUGGED_AC = OsProtoEnums.BATTERY_PLUGGED_AC; // = 1
179 /
* Power source is a USB port. /
180 public static final int BATTERY_PLUGGED_USB = OsProtoEnums.BATTERY_PLUGGED_USB; // = 2
181 /
* Power source is wireless. /
182 public static final int BATTERY_PLUGGED_WIRELESS = OsProtoEnums.BATTERY_PLUGGED_WIRELESS; // = 4
183
184 /
* @hide /
185 public static final int BATTERY_PLUGGED_ANY =
186 BATTERY_PLUGGED_AC | BATTERY_PLUGGED_USB | BATTERY_PLUGGED_WIRELESS;
187
188 /
*
189 * Sent when the device’s battery has started charging (or has reached full charge
190 * and the device is on power). This is a good time to do work that you would like to
191 * avoid doing while on battery (that is to avoid draining the user’s battery due to
192 * things they don’t care enough about).
193 *
194 * This is paired with {@link #ACTION_DISCHARGING}. The current state can always
195 * be retrieved with {@link #isCharging()}.
196 /
197 public static final String ACTION_CHARGING = “android.os.action.CHARGING”;
198
199 /
*
200 * Sent when the device’s battery may be discharging, so apps should avoid doing
201 * extraneous work that would cause it to discharge faster.
202 *
203 * This is paired with {@link #ACTION_CHARGING}. The current state can always
204 * be retrieved with {@link #isCharging()}.
205 /
206 public static final String ACTION_DISCHARGING = “android.os.action.DISCHARGING”;
207
208 /

209 * Battery property identifiers. These must match the values in
210 * frameworks/native/include/batteryservice/BatteryService.h
211 /
212 /
* Battery capacity in microampere-hours, as an integer. /
213 public static final int BATTERY_PROPERTY_CHARGE_COUNTER = 1;
214
215 /
*
216 * Instantaneous battery current in microamperes, as an integer. Positive
217 * values indicate net current entering the battery from a charge source,
218 * negative values indicate net current discharging from the battery.
219 /
220 public static final int BATTERY_PROPERTY_CURRENT_NOW = 2;
221
222 /
*
223 * Average battery current in microamperes, as an integer. Positive
224 * values indicate net current entering the battery from a charge source,
225 * negative values indicate net current discharging from the battery.
226 * The time period over which the average is computed may depend on the
227 * fuel gauge hardware and its configuration.
228 /
229 public static final int BATTERY_PROPERTY_CURRENT_AVERAGE = 3;
230
231 /
*
232 * Remaining battery capacity as an integer percentage of total capacity
233 * (with no fractional part).
234 /
235 public static final int BATTERY_PROPERTY_CAPACITY = 4;
236
237 /
*
238 * Battery remaining energy in nanowatt-hours, as a long integer.
239 /
240 public static final int BATTERY_PROPERTY_ENERGY_COUNTER = 5;
241
242 /
*
243 * Battery charge status, from a BATTERY_STATUS_* value.
244 */
245 public static final int BATTERY_PROPERTY_STATUS = 6;

android 电池充电状态记录相关推荐

  1. Android 获取通话记录和短信内容

    Android 获取通话记录和短信内容 一.获取通话记录 1.权限声明,需要在Manifest.xml文件中声明权限(读取通话记录权限): <uses-permission android:na ...

  2. Android动画学习记录二(属性动画、估值器和插值器)

    Android动画学习记录二(属性动画.估值期和插值器) Android动画学习记录二(属性动画.估值期和插值器) Android动画学习记录二(属性动画.估值期和插值器) 一.补间动画缺陷 二.属性 ...

  3. Android应用开发记录-Android歌词秀(5)完善一下,像一个产品了

    原创:Android应用开发记录-Andorid歌词秀(4)完成,含源码中的播放器虽然实现了播放,歌词移动等功能,但是距离真正产品级的软件还有一段距离,为此进行了完善 增加的主要功能 1.将操作按钮改 ...

  4. Android Studio学习记录之简单的页面切换及宫格菜单

    Android Studio学习记录之简单的页面切换及宫格菜单 之前上课听老师讲的一些东西自己其实并没有消化,今天把不懂的都去网上搜了一下,有了一种恍然大悟的感觉,包括很多方方面面的东西.有些东西听说 ...

  5. Windows11 Android开发相关记录(持续更新...)

    Windows11 Android开发相关记录(持续更新-) 本章节主要记录安装好Windos系统后开发环境搭建及其心得. 以及开发常用软件和相关配置. 以下属于个人做法,仅供参考: 文章目录 Win ...

  6. Android动画学习记录一(Android动画种类、补间动画和帧动画)

    Android动画学习记录一(动画种类.补间动画和帧动画) 动画种类.补间动画和帧动画 Android动画学习记录一(动画种类.补间动画和帧动画) 一.动画种类 二.View动画 2.1 补间动画 补 ...

  7. 【Android实战】记录自学自己定义GifView过程,能同一时候支持gif和其它图片!【有用篇】...

    之前写了一篇博客.<[Android实战]记录自学自己定义GifView过程,具体解释属性那些事! [学习篇]> 关于自己定义GifView的,具体解说了学习过程及遇到的一些类的解释,然后 ...

  8. Git笔记(5) 状态记录

    Git笔记(5) 状态记录 1. 文件的状态变化周期 2. 检查当前文件状态 3. 跟踪新文件 4. 暂存已修改文件 5. 状态简览 6. 忽略文件 7. 查看已暂存和未暂存的修改 7.1. 查看未暂 ...

  9. Android Studio 使用记录

    Android Studio 使用记录 工具及教程http://www.android-studio.org/ Android Studio简单设置http://ask.android-studio. ...

最新文章

  1. 【转】Android 4.3源码的下载和编译环境的安装及编译
  2. Spring2.5注释驱动与基于注释的MVC
  3. 第一次spring,第三天。
  4. 手机蓝牙如何减少延时_如何使用车载蓝牙播放手机音乐的方法
  5. 【Xamarin 挖墙脚系列:Xamarin SDK开源了................】
  6. LiveVideoStackCon 2020上海 6月见
  7. Java show两个整数加减_怎么样用java编写界面实现两个数的加法运算
  8. 第2篇:Flowable快速工作流脚手架Jsite_配置项目
  9. 小汤学编程之JDBC(二)——dbutils框架和DataSource连接池
  10. 网站优化加速经验总结
  11. word文件怎么压缩?
  12. 计算机无法显示输入法怎么办,win7系统电脑输入法选项不见了导致无法输入中文怎么办...
  13. 小福利,python内置map函数和lambda函数运用
  14. android模拟器命令大全,玩转安卓模拟器命令行
  15. 要怎样申请抖音蓝V认证?详谈蓝V认证的步骤
  16. Linux模块(2) - 创建设备节点
  17. 高性能计算机传奇(vamei)
  18. 微信小程序生成详情页面二维码
  19. wetool个人版_wetoo群发下载wetool-咨询
  20. 【Python 百练成钢】快速上手并查集

热门文章

  1. 亚马逊收款账号相同关联?
  2. ❤️如何用Python绘制一个飞机模型??
  3. 常用温度测量技术及其接口电路
  4. QT检测电脑是否能够上网
  5. 手机浏览器,html页面自动缩放
  6. HTTP 请求方法大全| HTTP Request Method
  7. 【阿里云ECS最佳实践】ECS+RDS构建云服务器主动防御系统部署开源蜜罐系统Hfish及ECS周边功能测试
  8. vue项目关闭页面后重新登录
  9. Nginx配置跨域兼容IOS12 苹果手机请求程序报network error错误
  10. linux运维工程师的面试自我介绍应该怎么说