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);

}

}

}

相关推荐
大王派来巡山的小旋风1 小时前
Kotlin基本用法之集合(一)
android·程序员·kotlin
用户2018792831671 小时前
智能广播系统(RemoteCallbackList)的诞生
android
用户2018792831672 小时前
Binder 同应用内(本地)通信是否存在 1MB 大小限制?
android
一条上岸小咸鱼2 小时前
Kotlin 基本数据类型(四):String
android·前端·kotlin
Onion_993 小时前
学习下Github上的Android CICD吧
android·github
来来走走4 小时前
Flutter Form组件的基本使用
android·flutter
顾林海4 小时前
Android MMKV 深度解析:原理、实践与源码剖析
android·面试·源码阅读
雨白5 小时前
TCP/IP 核心概念详解:从网络分层到连接管理
android
Wgllss6 小时前
雷电雨效果:Kotlin+Compose+协程+Flow 实现天气UI
android·架构·android jetpack
用户207038619498 小时前
Compose 可点击文本:ClickableText Compose 中的 ClickableSpan
android