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

}

}

}

相关推荐
Chenpip136 分钟前
安卓 14/15 上装不上:四层原因与三行检查
android·app分发·应用分发·海哈游分发·内测
TT哇1 小时前
【Android 之旅】Android 通俗易懂记
android·gitee
雨白1 小时前
工厂设计模式实战:从简单工厂到抽象工厂的演进之路
android
Digitally2 小时前
7 种主流安卓设备备份与恢复方法
android
恋猫de小郭2 小时前
Flutter HC 旋转 ANR,而且还和之前的 HCPP 问题类似
android·前端·flutter
Digitally2 小时前
如何在安卓设备上备份和恢复通话记录:完整指南
android
StarsGreen2 小时前
Android 的graphicsstats 服务讲解
android
_祝你今天愉快2 小时前
Android 高级绘制:[六] 基于PathMeasure源码分析path测量问题
android
FungLeo2 小时前
FengCMS · PHP+MySQL 升级实录· PHP Session 锁:什么时候释放能救活并发
android·mysql·php·session·fengcms
墨狂之逸才3 小时前
扫码总是听到"已入库"?一次广播撞车的排查记录
android