Android 开关机(重启)时让充电指示灯一直亮起,不灭

frameworks/base/services/core/java/com/android/server/notification/NotificationManagerService.java

首先排查这个类,但发现没有去关闭充电指示灯的操作和代码逻辑。

于是想着其他地方会不会有关闭充电指示灯的地方。

除了充电灯,闪灯,那就是通知灯了,果然,皇天不负有心人

frameworks/base/services/core/java/com/android/server/notification/NotificationManagerService.java

判断为开机默认正常使用灯光,

//*add, charging light stays on when power on or restart phone
private boolean isFirstOff = true;
//*/

@GuardedBy("mNotificationLock")

void updateLightsLocked()

{

if (mNotificationLight == null) {

return;

}

// handle notification lights

NotificationRecord ledNotification = null;

while (ledNotification == null && !mLights.isEmpty()) {

final String owner = mLights.get(mLights.size() - 1);

ledNotification = mNotificationsByKey.get(owner);

if (ledNotification == null) {

Slog.wtfStack(TAG, "LED Notification does not exist: " + owner);

mLights.remove(owner);

}

}

// Don't flash while we are in a call or screen is on

if (ledNotification == null || isInCall() || mScreenOn) { //res:Notification Light turnOff mBatteryLight

mNotificationLight.turnOff();//当通知为空或亮屏时关掉的通知灯 == 充电灯

//*/add,charging light stays on when power on or restart phone
if (isFirstOff) {
isFirstOff = false;
BatteryService.updateNotificationLights(true);
}
BatteryService.updateNotificationLights(false);
//*/

} else {

NotificationRecord.Light light = ledNotification.getLight();

if (light != null && mNotificationPulseEnabled) {

// pulse repeatedly

mNotificationLight.setFlashing(light.color, LogicalLight.LIGHT_FLASH_TIMED,

light.onMs, light.offMs);

}

}

}

相关推荐
阿亮爱学代码20 分钟前
初识Android界面布局
android·xml·view·viewgroup
zopple1 小时前
Laravel 9.x核心特性全解析
android
黑牛儿1 小时前
PHP 8.3性能暴涨实测|对比8.2,接口响应提速30%,配置无需大幅修改
android·开发语言·后端·php
被开发耽误的大厨2 小时前
2、基本类型和引用类型的执行存储流程是怎样的?
android·哈希算法
程序员陆业聪2 小时前
启动瓶颈定位实战:Perfetto + Macrobenchmark 一套组合拳
android
洞见前行2 小时前
Android第三代加固技术原理详解(附源码)
android
Kapaseker3 小时前
Android 开发快 3 倍!Google 说的
android
黄林晴3 小时前
Android 17 Beta4发布:四大行为变更,不改上线就崩
android
恋猫de小郭3 小时前
Flutter 3.41.7 ,小版本但 iOS 大修复,看完只想说:这是人能写出来的 bug ?
android·前端·flutter
麦芽糖02194 小时前
python进阶六 正则表达式
android·python·正则表达式