MTK Android Q修改关机充电动画

1.关机充电动画的图片

修改 vendor/mediatek/proprietary/bootable/bootloader/lk/dev/logo/fwvgaplus/ 下的图片
具体对应的文件夹可以查看 ProjectConfig.mk 中配置的宏 BOOT_LOGO = fwvgaplus

修改完图片之后只需要 make lk 就可以生效,大大节省了编译时间

source build/envsetup.sh
lunch xxx
make -j16 clean-lk
make -j16 lk

然后用 flashtool 直接 download logo.bin/logo-sign.bin 就可以了

2.关机充电动画的显示代码

vendor/mediatek/proprietary/external/libshowlogo/show_animation_common.c

//根据对应的屏幕宽高找到对应的 BC2 代码如下,下面是修改过后的坐标,这个坐标要和UI做好的图片上的坐标相对应
else if(lcm_width==480 && lcm_height==960) {
      SLOGD("[show_animation_common: %s %d]Inside 480*960 \n",__FUNCTION__,__LINE__);
      // 电量柱
      charg_anim_ui_dimen.cap_left=189;
      charg_anim_ui_dimen.cap_top=385;
      charg_anim_ui_dimen.cap_right=291;
      charg_anim_ui_dimen.cap_bottom=551;
      // 电量百分比数字
      charg_anim_ui_dimen.num_left=205;
      charg_anim_ui_dimen.num_top=310;
      charg_anim_ui_dimen.num_right=225;
      charg_anim_ui_dimen.num_bottom=338;
      // 百分号
      charg_anim_ui_dimen.percent_left=248;
      charg_anim_ui_dimen.percent_top=310;
      charg_anim_ui_dimen.percent_right=272;
      charg_anim_ui_dimen.percent_bottom=338;
      // 充电动画
      charg_anim_ui_dimen.top_anim_left=189;
      charg_anim_ui_dimen.top_anim_top=100;
      charg_anim_ui_dimen.top_anim_right=291;
      charg_anim_ui_dimen.top_anim_bottom=118;
      // ??
      charg_anim_ui_dimen.bar_left=184;
      charg_anim_ui_dimen.bar_top=227;
      charg_anim_ui_dimen.bar_right=294;
      charg_anim_ui_dimen.bar_bottom=437;
}
...

void fill_animation_battery_new(int capacity, void *fill_addr, void * dec_logo_addr, void * logo_addr, LCM_SCREEN_T phical_screen)
{
    if (MTK_LOG_ENABLE == 1) {
        SLOGD("[show_animation_common: %s %d]capacity : %d\n",__FUNCTION__,__LINE__, capacity);
    }
    if (percent_pic_addr==NULL) {
        percent_pic_addr=(unsigned short*)malloc(((charg_anim_ui_dimen.percent_right - charg_anim_ui_dimen.percent_left)*(charg_anim_ui_dimen.percent_bottom - charg_anim_ui_dimen.percent_top)*4)*sizeof(unsigned short));
        memset(percent_pic_addr,0,(((charg_anim_ui_dimen.percent_right - charg_anim_ui_dimen.percent_left)*(charg_anim_ui_dimen.percent_bottom - charg_anim_ui_dimen.percent_top)*4)*sizeof(unsigned short)));
    }
    if (top_animation_addr==NULL) {
        top_animation_addr=(unsigned short*)malloc(((charg_anim_ui_dimen.top_anim_right - charg_anim_ui_dimen.top_anim_left)*(charg_anim_ui_dimen.top_anim_bottom - charg_anim_ui_dimen.top_anim_top)*4)*sizeof(unsigned short));
        memset(top_animation_addr,0,(((charg_anim_ui_dimen.top_anim_right - charg_anim_ui_dimen.top_anim_left)*(charg_anim_ui_dimen.top_anim_bottom - charg_anim_ui_dimen.top_anim_top)*4)*sizeof(unsigned short)));
    }
    RECT_REGION_T percent_location_rect = {charg_anim_ui_dimen.percent_left,charg_anim_ui_dimen.percent_top,charg_anim_ui_dimen.percent_right,charg_anim_ui_dimen.percent_bottom};

    if (capacity >= 100) {
        //show_logo(37); // battery 100
        fill_animation_logo(FULL_BATTERY_INDEX, fill_addr, dec_logo_addr, logo_addr,phical_screen);

    } else if (capacity < 10) {
        if (MTK_LOG_ENABLE == 1) {
            SLOGD("[show_animation_common: %s %d]charging_low_index = %d\n",__FUNCTION__,__LINE__, charging_low_index);
        }
        charging_low_index ++ ;

        fill_animation_logo(LOW_BAT_ANIM_START_0 + charging_low_index, fill_addr, dec_logo_addr, logo_addr,phical_screen);
        fill_animation_number(NUMBER_PIC_START_0 + capacity, 1, fill_addr, logo_addr, phical_screen);
        fill_animation_dynamic(NUMBER_PIC_PERCENT, percent_location_rect, fill_addr, percent_pic_addr, logo_addr, phical_screen);

        if (charging_low_index >= 9) charging_low_index = 0;

    } else {

        unsigned int capacity_grids = 0;
        //static RECT_REGION_T battery_rect = {CAPACITY_LEFT,CAPACITY_TOP,CAPACITY_RIGHT,CAPACITY_BOTTOM};
        capacity_grids = charg_anim_ui_dimen.cap_bottom - (charg_anim_ui_dimen.cap_bottom - charg_anim_ui_dimen.cap_top) * (capacity - 10) / 90; 
        if (MTK_LOG_ENABLE == 1) {
            SLOGD("[show_animation_common: %s %d]capacity_grids : %d,charging_animation_index = %d\n"
                     ,__FUNCTION__,__LINE__, capacity_grids,charging_animation_index);
        }

        //background
        fill_animation_logo(ANIM_V1_BACKGROUND_INDEX, fill_addr, dec_logo_addr, logo_addr,phical_screen);

        fill_animation_line(ANIM_LINE_INDEX, capacity_grids, fill_addr,  logo_addr, phical_screen);
        fill_animation_number(NUMBER_PIC_START_0 + (capacity/10), 0, fill_addr, logo_addr, phical_screen);
        fill_animation_number(NUMBER_PIC_START_0 + (capacity%10), 1, fill_addr, logo_addr, phical_screen);
        fill_animation_dynamic(NUMBER_PIC_PERCENT, percent_location_rect, fill_addr, percent_pic_addr, logo_addr, phical_screen);

         if (capacity <= 90)
         {
            RECT_REGION_T top_animation_rect = {charg_anim_ui_dimen.top_anim_left, capacity_grids - (charg_anim_ui_dimen.top_anim_bottom - charg_anim_ui_dimen.top_anim_top), charg_anim_ui_dimen.top_anim_right, capacity_grids};
            //top_animation_rect.bottom = capacity_grids;
            //top_animation_rect.top = capacity_grids - top_animation_height;
            charging_animation_index++;
            //show_animation_dynamic(15 + charging_animation_index, top_animation_rect, top_animation_addr);
            fill_animation_dynamic(BAT_ANIM_START_0 + charging_animation_index, top_animation_rect, fill_addr,
                            top_animation_addr, logo_addr, phical_screen);

            if (charging_animation_index >= 9) charging_animation_index = 0;
         }
    }
}

修改上述代码之后模块编译 push libshowlogo 模块之后 reboot 即可生效,下面是用ninja来模块编译,非常快速,几乎秒编,大大提高编译效率

prebuilts/build-tools/linux-x86/bin/ninja -f out/combined-full_k80hd_bsp_fwv_512m.ninja libshowlogo 2>&1 | tee logo.log
adb push out/target/product/k80hd_bsp_fwv_512m/system/lib/libshowlogo.so /system/lib/

3.关机充电动画测试代码

vendor/mediatek/proprietary/external/libshowlogo/libshowlogoTest/animation_test.c

// 修改后的测试代码如下,意思是测试从100%的电量开始每次减少1%的电量,观察效果即可,这样就不需要每次充放电来测试,可以大大提高调试效率
void test_charging_animation(int charging_item)
{
    int capacity=100;
    while(capacity >= 0) {
        if (charging_item == 2) {
            show_fast_charging(capacity);
        } else {
            show_battery_capacity(capacity);
        }
        capacity--;
        sleep(1);
    }
}

修改之后模块编译+push

./mk -ud xxx mm vendor/mediatek/proprietary/external/libshowlogo/libshowlogoTest/
adb push out/target/product/k80hd_bsp_fwv_512m/system/bin/libshowlogotest /system/bin/

libshowlogotest 的使用方法

adb shell libshowlogotest charging sf new

libshowlogotest 的详细使用方法如下

printf("[logo_test %s %d]libshowlogo Test ...\n",__FUNCTION__,__LINE__);
printf("***************     libshowlogo Test       ********************\n");
printf("*******     Testlibshowlogo  introduce...               *******\n");
printf("It can test boot logo, kernel logo and charging animation using \n framebuffer or surface flinger with different parameters\n"); 
printf("***************************************************************\n");
printf(" ---> para 1:boot kernel charging ut\n");
printf("    boot: boot logo\n");
printf("    kernel: kernel logo \n");
printf("    charging: charging animation\n");
printf("    ut: test all\n");
printf(" ---> para 2: fb sf \n");
printf("    fb: framebuffer\n");
printf("    sf: surface flinger\n");
printf(" ---> para 3: new fast wireless \n");
printf("    new: new version\n");
printf("    fast: fast Charging\n");
printf("    wireless: wireless Charging\n");
printf("\n ---> Example (Default):libshowlogoTest boot  sf\n");
printf("**************************************************************\n");

参考资料:
https://blog.csdn.net/yangfan1571397878/article/details/95636067 Android P修改关机充电动画

下面这种方式还验证是否可行??

mmm -B vendor/mediatek/proprietary/bootable/bootloader/preloader:pl -j16
mmm -B vendor/mediatek/proprietary/bootable/bootloader/lk:lk -j16

关机充电log可能需要抓UART串口log

猜你喜欢

转载自blog.csdn.net/zhangqi6627/article/details/107705899