vendor/mediatek/proprietary/hardware/liblights/lights.c
490 static void
491 handle_speaker_battery_locked(struct light_device_t* dev)
492 {
493 if (is_lit(&g_battery)) { // 电池灯亮,notification灯就不亮
494 set_speaker_light_locked(dev, &g_battery);
495 } else {
496 set_speaker_light_locked(dev, &g_battery); /*Turkey workaround: notification and Low battery case, IPO bootup, NLED cannot blink*/
497 set_speaker_light_locked(dev, &g_notification);
498 }
499 }
500
501 static int
502 set_light_battery(struct light_device_t* dev,
503 struct light_state_t const* state)
504 {
505 pthread_mutex_lock(&g_lock);
506 g_battery = *state;
507 if (g_haveTrackballLight) {
508 set_speaker_light_locked(dev, state);
509 }
510 handle_speaker_battery_locked(dev);
511 pthread_mutex_unlock(&g_lock);
512 return 0;
513 }
本文介绍了在特定设备上实现电池指示灯控制的代码逻辑。当电池灯亮起时,通知灯将关闭;反之,则开启通知灯。同时,文章还涉及了互斥锁的使用以确保线程安全。
759

被折叠的 条评论
为什么被折叠?



