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

}

}

}

相关推荐
solo_991 小时前
用 LSPosed 模拟录屏音频编码器卡顿:从思路到落地
android
zzq77972 小时前
别把大模型 API Key 写进 APK:移动 AI 应用接口防盗刷实践
android·人工智能·安全·app加固·御盾安全·安卓加固
xiaopang4 小时前
RK3568 AOSP 编译与快速部署实战
android
码农coding5 小时前
android12 SystemUI之通知
android
summerkissyou19875 小时前
android - 性能 - Perfetto - cpu 分析教程及例子
android·性能
AFinalStone7 小时前
Android 7系统休眠唤醒(七)内核层—wakelock与autosleep机制
android·休眠唤醒
starvapour7 小时前
在关机键损坏的情况下让手机关机
android·adb·手机
AFinalStone7 小时前
Android 7系统休眠唤醒(八)内核层—Alarm定时唤醒与硬件唤醒源
android·电源管理·休眠唤醒
AFinalStone8 小时前
Android 7系统休眠唤醒(五)休眠全链路
android·电源管理·休眠唤醒