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

}

}

}

相关推荐
程思扬33 分钟前
Android Room 数据库跨版本升级闪退问题根治方案
android·数据库·oracle
w1wi40 分钟前
Jadx MCP/Skill
android·ai
千里马学框架43 分钟前
深入剖析安卓布局uiautomator抓取工具原理
android·智能手机·性能优化·perfetto·view·安卓framework开发·布局抓取
小镇敲码人1 小时前
MySQL事务介绍
android·数据库·mysql·adb
awu的Android笔记1 小时前
IP/TCP/UDP 解析器:一次搞懂网络包结构
android
2601_957418801 小时前
Android相机有线连接全链路优化:PTP/MTP协议栈实现与商业级性能调优
android·数码相机·智能手机·架构
plainGeekDev1 小时前
Fragment 手动跳转 → Navigation 组件
android·java·kotlin
plainGeekDev2 小时前
XML 主题 → Compose Material3 主题
android·java·kotlin
__Witheart__2 小时前
HW-T3568 安卓固件编译指南
android
邪修king2 小时前
C++map_set封装 : 红黑树底层迭代器以及仿函数的运用
android·c语言·数据结构·c++·b树