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

}

}

}

相关推荐
游戏开发爱好者83 小时前
日常开发与测试的 App 测试方法、查看设备状态、实时日志、应用数据
android·ios·小程序·https·uni-app·iphone·webview
王码码20353 小时前
Flutter for OpenHarmony 实战之基础组件:第三十一篇 Chip 系列组件 — 灵活的标签化交互
android·flutter·交互·harmonyos
黑码哥3 小时前
ViewHolder设计模式深度剖析:iOS开发者掌握Android列表性能优化的实战指南
android·ios·性能优化·跨平台开发·viewholder
亓才孓3 小时前
[JDBC]元数据
android
独行soc3 小时前
2026年渗透测试面试题总结-17(题目+回答)
android·网络·安全·web安全·渗透测试·安全狮
金融RPA机器人丨实在智能3 小时前
Android Studio开发App项目进入AI深水区:实在智能Agent引领无代码交互革命
android·人工智能·ai·android studio
科技块儿3 小时前
利用IP查询在智慧城市交通信号系统中的应用探索
android·tcp/ip·智慧城市
独行soc4 小时前
2026年渗透测试面试题总结-18(题目+回答)
android·网络·安全·web安全·渗透测试·安全狮
王码码20354 小时前
Flutter for OpenHarmony 实战之基础组件:第二十七篇 BottomSheet — 动态底部弹窗与底部栏菜单
android·flutter·harmonyos
2501_915106324 小时前
app 上架过程,安装包准备、证书与描述文件管理、安装测试、上传
android·ios·小程序·https·uni-app·iphone·webview