MTK Android 11.0:充电低电指示灯会被未读消息信号灯灭掉,无优先级控制。

MTK Android 11.0:充电低电指示灯会被未读消息信号灯灭掉,无优先级控制:

1、电池充电、低电状态提示(红绿双色)。(LIGHT_ID_BATTERY)

        小于15%时:

                A 正在充电 亮红灯。

                B 未充电 红灯闪烁 灭2秒 亮0.5秒。

        大于15%,小于90%时:

                A 正在充电 亮红灯。

                B 未充电 灭灯。

        大于90%时:

                A  正在充电 亮绿灯。

                B  未充电 灭灯。

2、未读消息通知灯。(LIGHT_ID_NOTIFICATIONS)

    public static final int LIGHT_ID_BACKLIGHT = Type.BACKLIGHT;
    public static final int LIGHT_ID_KEYBOARD = Type.KEYBOARD;
    public static final int LIGHT_ID_BUTTONS = Type.BUTTONS;
    public static final int LIGHT_ID_BATTERY = Type.BATTERY;
    public static final int LIGHT_ID_NOTIFICATIONS = Type.NOTIFICATIONS;
    public static final int LIGHT_ID_ATTENTION = Type.ATTENTION;
    public static final int LIGHT_ID_BLUETOOTH = Type.BLUETOOTH;
    public static final int LIGHT_ID_WIFI = Type.WIFI;

3、优先级:

       电池充电/低电的优先级    大于  未读消息通知灯。

4、异常现象:在MTK Android 11.0平台上,充电/低电指示灯亮起后,会被后面的未读消息信号灯灭掉,无优先级控制。

5、解决办法:

修改文件:/vendor/mediatek/proprietary/hardware/liblights/aidl/default/Lights.cpp

static int blink_red(int level, int onMS, int offMS)
{
    static int preStatus = 0; // 0: off, 1: blink, 2: no blink
    int nowStatus;
    int i = 0;
    int ret = 0;

    if(level == 0)
    {
        nowStatus = 0;
    }
    else if(onMS && offMS)
    {
        nowStatus = 1;
    }
    else
    {
        nowStatus = 2;
    }

    if(preStatus == nowStatus)
    {
        return 0;
    }

#ifdef LIGHTS_DBG_ON
    ALOGD("blink_red, level=%d, onMS=%d, offMS=%d\n", level, onMS, offMS);
#endif

#if  0 /* Modified start by Eli at 2022-06-14 09:57  */
    if(nowStatus == 0)
    {
        ret = write_int(RED_LED_FILE, 0);
    }
    else if(nowStatus == 1)
    {
        //write_int(RED_LED_FILE, level); // default full brightness
        ret = write_str(RED_TRIGGER_FILE, "timer");

        while(((access(RED_DELAY_OFF_FILE, F_OK) == -1) || (access(RED_DELAY_OFF_FILE, R_OK | W_OK) == -1)) && i < 10)
        {
            ALOGD("RED_DELAY_OFF_FILE doesn't exist or cannot write!!\n");
            led_wait_delay(5);//sleep 5ms for wait kernel LED class create led delay_off/delay_on node of fs
            i++;
        }

        ret = write_int(RED_DELAY_OFF_FILE, offMS);
        ret = write_int(RED_DELAY_ON_FILE, onMS);
    }
    else
    {
        ret = write_str(RED_TRIGGER_FILE, "none");
        ret = write_int(RED_LED_FILE, 255); // default full brightness
    }
#else
    if(onMS>600)
    {
    	onMS = (onMS-600)/LED_BREATH_MODE_TON_SETP_TIME;
    }
    else
    {
    	onMS = 0;
    }
    
    offMS = offMS/LED_BREATH_MODE_TOFF_SETP_TIME;
    
    if (nowStatus == 0)
    {
        ret = write_str(RED_TRIGGER_FILE, LED_TRIGGER_CC_MODE);
        ret = write_int(RED_LED_FILE, LED_BL_LEVEL_0);
    }
    else if (nowStatus == 1)
    {
        ret = write_str(RED_TRIGGER_FILE, LED_TRIGGER_BREATH_MODE);
        while (((access(RED_DELAY_OFF_FILE, F_OK) == -1) || (access(RED_DELAY_OFF_FILE, R_OK | W_OK) == -1)) && i < 10)
        {
            ALOGD("RED_DELAY_OFF_FILE doesn't exist or cannot write!!\n");
            led_wait_delay(5);//sleep 5ms for wait kernel LED class create led toff/ton node of fs
            i++;
        }
        
        //ret = write_int(RED_LED_FILE, LED_BL_LEVEL_4);//delete batteryLed closed by NoticeLed
        ret = write_int(RED_DELAY_OFF_FILE, offMS);
        ret = write_int(RED_DELAY_ON_FILE, onMS);
        ret = write_int(RED_LED_FILE, LED_BL_LEVEL_4);//add batteryLed closed by NoticeLed
    }
    else
    {
        ret = write_str(RED_TRIGGER_FILE, LED_TRIGGER_CC_MODE);
        ret = write_int(RED_LED_FILE, LED_BL_LEVEL_4); // default full brightness
    }
#endif /* #if 0 */

    preStatus = nowStatus;
    return ret;
}

核心修改如下:

static int handle_speaker_battery_locked(__attribute__((__unused__)) HwLight const *light,
    const HwLightState *state)
{
    int ret = 0;
//start batteryLed closed by NoticeLed
    if(is_lit(&g_battery_state/*state*/))
    {
        ret = set_speaker_light_locked(light, &g_battery_state/*state*/);
    }
//end batteryLed closed by NoticeLed
    else
    {
        /*Turkey workaround: notification and Low battery case, IPO bootup, NLED cannot blink*/
        ret = set_speaker_light_locked(&g_battery, &g_battery_state);
        ret = set_speaker_light_locked(&g_notification, &g_notification_state);
    }

    return ret;
}

经过上面这段代码修改后,电池充电/低电的指示灯  不会被 未读消息通知灯灭掉。

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

灵魂剑客

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值