Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1306966
  • 博文数量: 478
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 4833
  • 用 户 组: 普通用户
  • 注册时间: 2014-06-28 11:12
文章分类

全部博文(478)

文章存档

2019年(1)

2018年(27)

2017年(21)

2016年(171)

2015年(258)

我的朋友

分类: Android平台

2015-08-22 22:19:57

以拷贝/data区数据到SD卡为例子:
第一:
alps/bootable/recovery/default_device.cpp中


static const char* ITEMS[] =  {"reboot system now",
                               "apply update from ADB",
                               "wipe data/factory reset",
                               "wipe cache partition",
                               "reboot to bootloader",
                               "power down",
                               "view recovery logs",
                               /*SPRD:update from cache partiton,external and internal storage @{*/
                               "update from cache",
                               "update from external storage",
#ifdef ENABLE_INTERNAL_STORAGE
                               "update from internal storage",
#endif
                               "delete /data/dalvik-cache/",
                               /*@}*/
                               NULL };
第二:
在此结构体指针中添加一行菜单,此菜单就会更新到Recovery界面中,并且依然在此文件中,有其相应的函数,并且也要在此
函数中添加一个case与static const char* ITEMS[]相对应:
    BuiltinAction InvokeMenuItem(int menu_position) {
        switch (menu_position) {
          case 0: return REBOOT;
          case 1: return APPLY_ADB_SIDELOAD;
          case 2: return WIPE_DATA;
          case 3: return WIPE_CACHE;
          case 4: return REBOOT_BOOTLOADER;
          case 5: return SHUTDOWN;
          case 6: return READ_RECOVERY_LASTLOG;
          /*SPRD:update from cache partiton,external and internal storage @{*/
          case 7: return APPLY_CACHE;
          case 8: return APPLY_EXT;
#ifdef ENABLE_INTERNAL_STORAGE
          case 9: return APPLY_INT;
#endif




          case 10: return COPY_USERDATA_TO_SDCARD;
          /*@}*/
          default: return NO_ACTION;
        }
    }


第三:
在alps/bootable/recovery/device.h中,添加参数COPY_USERDATA_TO_SDCARD:


    enum BuiltinAction { NO_ACTION, REBOOT, APPLY_EXT,
                         // SPRD:update from cache partiton,external and internal storage
                         APPLY_INT,
                         APPLY_CACHE,   // APPLY_CACHE is deprecated; has no effect
                         APPLY_ADB_SIDELOAD, WIPE_DATA, WIPE_CACHE,
                         REBOOT_BOOTLOADER, SHUTDOWN, READ_RECOVERY_LASTLOG, COPY_USERDATA_TO_SDCARD };


第四:
alps/bootable/recovery/recovery.cpp中的函数
static Device::BuiltinAction prompt_and_wait(Device* device, int status);
            case Device::COPY_USERDATA_TO_SDCARD:
            ensure_path_mounted("/data");
            ensure_path_mounted("/system");
                 //ensure_path_mounted(SDCARD_ROOT);
                 ui->Print("\n Delete /data/dalvik-cache/ Start \n");
        //system("/system/bin/toolbox mkdir /storage/sdcard0/dump_user");
        //system("/system/bin/toolbox cp -r /data/system/dropbox/* /storage/sdcard0/dump_user/");
        system("/system/bin/toolbox rm -r /data/dalvik-cache/*");
                 ui->Print("\n Delete /data/dalvik-cache/ End!\n"); 
                 break;


            case Device::APPLY_ADB_SIDELOAD:
                status = apply_from_adb(ui, &wipe_cache, TEMPORARY_INSTALL_FILE);
                if (status >= 0) {
                    if (status != INSTALL_SUCCESS) {
                        ui->SetBackground(RecoveryUI::ERROR);  
                        ui->Print("Installation aborted.\n");
                        copy_logs();
                    } else if (!ui->IsTextVisible()) {
                        return Device::NO_ACTION;  // reboot if logs aren't visible
                    } else {
                        ui->Print("\nInstall from ADB complete.\n");
                    }
                }
                break;


备注:
展讯平台的default_device.cpp使用的是此目录下的default_device.cpp:
alps/vendor/sprd/open-source/libs/librecovery_ui_sp8830/default_device.cpp
若在alps/bootable/recovery/default_device.cpp修改后发现编译未起效,可在此目录下查找并修改方可
至此,添加菜单和功能完毕.




阅读(1855) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~