1.概述
在开发12.0的产品时,对于低电量提醒也是个很好的体验,由于产品要求在低电量的时候增加个弹窗提醒用户电量低及时充电,所以就开发了这个功能
2.SystemUI中实现低电量弹窗功能分析
在12.0的SystemUI中,PowerUI是SystemUI控制电量提醒的模块,包括低电量提醒、危急电量关机提醒、高温关机提醒、省电模式等功能,实现低电量弹窗功能就是在这里实现
3.SystemUI中实现低电量弹窗功能代码分析
3.1 SystemUI启动PowerUI的相关主要代码分析
public class SystemUIService extends Service {
@Override
public void onCreate() {
super.onCreate();
((SystemUIApplication) getApplication()).startServicesIfNeeded();
// For debugging RescueParty
if (Build.IS_DEBUGGABLE && SystemProperties.getBoolean("debug.crash_sysui", false)) {
throw new RuntimeException();
}
if (Build.IS_DEBUGGABLE) {
// b/71353150 - looking for leaked binder proxies
BinderInternal.nSetBinderProxyCountEnabled(true);
Binder