这两天遇到个奇怪的问题,手机电量低于15%的时候,只会弹出低电量的提示框,低电量指示灯并没有闪烁。
查看log
- :: D lights : set_led_state colorRGB=FFFF0000, onMS=, offMS=
- :: D lights : blink_red, level=, onMS=, offMS=
- :: D lights : write timer to /sys/class/leds/red/trigger
- :: D lights : write_str open fd=
- :: D lights : write timer to /sys/class/leds/red/trigger amt =
- :: D lights : RED_DELAY_OFF_FILE doesn't exist or cannot write!!
- :: D lights : RED_DELAY_OFF_FILE doesn't exist or cannot write!!
- :: D lights : RED_DELAY_OFF_FILE doesn't exist or cannot write!!
- :: D lights : RED_DELAY_OFF_FILE doesn't exist or cannot write!!
- :: D lights : RED_DELAY_OFF_FILE doesn't exist or cannot write!!
- :: D lights : RED_DELAY_OFF_FILE doesn't exist or cannot write!!
- :: D lights : RED_DELAY_OFF_FILE doesn't exist or cannot write!!
- :: D lights : RED_DELAY_OFF_FILE doesn't exist or cannot write!!
- :: D lights : RED_DELAY_OFF_FILE doesn't exist or cannot write!!
- :: D lights : RED_DELAY_OFF_FILE doesn't exist or cannot write!!
- :: D lights : RED_DELAY_OFF_FILE doesn't exist or cannot write!! i=
- :: D lights : write_int open fd=-
- :: D lights : write_int open fd=-
可以看到是因为write_str(RED_TRIGGER_FILE, “timer”); 之后,并没有生成delay_on和delay_off两个文件。
手动用echo测试
先echo timer >> /sys/class/leds/red/trigger 测试,可以生成 delay_on和delay_off两个文件,然后
echo 200 >> /sys/class/leds/red/delay_off
echo 200 >> /sys/class/leds/red/delay_on 这样设置一下时间,指示灯就可以闪烁。
write_int open fd=-1 返回-1 ,意味着没有权限,这两个文件是动态注册权限的,所以看ueventd.mt6735.rc文件,找到下面两句
/sys/devices/platform/leds-mt65xx/leds/red delay_on system system
/sys/devices/platform/leds-mt65xx/leds/red delay_off system system
通过adb连接设备,发现leds-mt65xx的路径不对,实际上在
/sys/devices/leds-mt65xx,尝试修改上面两句为
/sys/devices/leds-mt65xx/leds/red delay_on system system
/sys/devices/leds-mt65xx/leds/red delay_off system system
重新编译下载,问题解决。