Android 11 recovery恢复出厂设置保留某些文件
1.Android 11 -- 强制清理app后台,关于权限引发的问题2.Android 11 (MTK)状态栏图标反色-->跟随当前应用变化代码流程3.Android 11 --关于Toast的异常4.Android 11 -- 关于dialog和悬浮窗导致SystemUI状态栏下拉频繁闪烁(窗口焦点问题)5.Android 11 下拉菜单长按WiFi图标SystemUI ANR6.Android 11 sim卡来电不弹出悬浮通知,默认来电默认全屏7.Android Bluetooth 蓝牙开发/蓝牙协议 小结8.Android11 —— 自定义添加一个System Services9.Android系统——AOSP相关-->随记10.Android11 , Launcher3 切换阿拉伯语,最近应用(后台)不能滑动11.Android 底层问题日志记录12.Android 11 -- app 服务保活13.Android11 - 添加自定义服务注意事项14.Android 11 导航栏添加一个虚拟按钮--问题合集15.Android 11--设置第三方Launcher并默认 与 如何预置apk16.Android11 系统修改 AOSP输入法的默认输入键盘布局17.Settings里面切换不同Launcher的代码流程18.关于Android`系统默认屏保`19.关于Android 11 Settings添加新的选项界面的细节20.Android 11 自由窗口模式 || 全屏模式启动app21.强制app横屏显示或者竖屏显示(动态)22.Android 11 禁止从SD卡上安装第三方应用23.实体物理音量键替换为home键24.AMS- kill Launcher进程的代码流程
25.Android 11 recovery恢复出厂设置保留某些文件
26.Android 11 禁用 adb root (userdebug版本)27.Android11 应用默认获取通知使用权限(可以获取系统所有通知信息)28.Android 11 UsbDebug 关于adb RSA 认证29.Android 11 NavigationBar && Status Bar 如果改变背景颜色30.Anroid 11 关于NotificationManager && NotificationManagerService -- 衍生到权限管理31.Android13 控制设置界面 双栏显示或单栏显示32.Android 13 大屏显示时关于SystemUI和Launcher3问题33.Android 系统适配无源码app34.Android 11 关于app的权限重置35.Android 11.0 关于app进程保活36.Android 11 关于按键拦截/按键事件处理分享37.Android R Settings关于屏保/PowerManagerService欺骗系统不让其进入休眠状态38.Android13 关于SystemUI更新/Nav Bar add volume button&&other button39.Android 13 移植EthernetSettings/Ethernet更新40.Anrdoir 13 关于设置静态IP后,突然断电,在上电开机卡动画41.Android T(13) The app is granted permissions by default42.Android T 关于屏幕旋转 (一)43.Android T about screen rotation(二)44.Android 13 about launcher3 (1)45.Android T don't abort background activity starts46.Android T adout replace bootanimation47.Launcher start App WINDOWING_MODE_FREEFORM48.Android 11 About SleepToken / (Settings)Screen timeout49.Settings.System数据监听/prop&SystemProperties数据监听/bootable/recovery/recovery.cpp
recovery的注释,流程解释!
/*
* The recovery tool communicates with the main system through /cache files.
* /cache/recovery/command - INPUT - command line for tool, one arg per line
* /cache/recovery/log - OUTPUT - combined log file from recovery run(s)
*
* The arguments which may be supplied in the recovery.command file:
* --update_package=path - verify install an OTA package file
* --install_with_fuse - install the update package with FUSE. This allows installation of large
* packages on LP32 builds. Since the mmap will otherwise fail due to out of memory.
* --wipe_data - erase user data (and cache), then reboot
* --prompt_and_wipe_data - prompt the user that data is corrupt, with their consent erase user
* data (and cache), then reboot
* --wipe_cache - wipe cache (but not user data), then reboot
* --show_text - show the recovery text menu, used by some bootloader (e.g. http://b/36872519).
* --set_encrypted_filesystem=on|off - enables / diasables encrypted fs
* --just_exit - do nothing; exit and reboot
*
* After completing, we remove /cache/recovery/command and reboot.
* Arguments may also be supplied in the bootloader control block (BCB).
* These important scenarios must be safely restartable at any point:
*
* FACTORY RESET
* 1. user selects "factory reset"
* 2. main system writes "--wipe_data" to /cache/recovery/command
* 3. main system reboots into recovery
* 4. get_args() writes BCB with "boot-recovery" and "--wipe_data"
* -- after this, rebooting will restart the erase --
* 5. erase_volume() reformats /data
* 6. erase_volume() reformats /cache
* 7. FinishRecovery() erases BCB
* -- after this, rebooting will restart the main system --
* 8. main() calls reboot() to boot main system
*
* OTA INSTALL
* 1. main system downloads OTA package to /cache/some-filename.zip
* 2. main system writes "--update_package=/cache/some-filename.zip"
* 3. main system reboots into recovery
* 4. get_args() writes BCB with "boot-recovery" and "--update_package=..."
* -- after this, rebooting will attempt to reinstall the update --
* 5. InstallPackage() attempts to install the update
* NOTE: the package install must itself be restartable from any point
* 6. FinishRecovery() erases BCB
* -- after this, rebooting will (try to) restart the main system --
* 7. ** if install failed **
* 7a. PromptAndWait() shows an error icon and waits for the user
* 7b. the user reboots (pulling the battery, etc) into the main system
*/
RK3228H开发之Rockchip Recovery及android系统升级详解
5.1 RK Log 重定向 Log re-direct
- 功能说明:Log 可以输出到串口、SD卡、/cache/recovery/、三个地方。
Function description: Log can be output to serial port, SD card, or /cache/recovery/. - 打开方式:
(1)<Android 10
bootable/recovery/Android.mk:
Enable method: modify bootable/recovery/Android.mk file:
REDIRECT_LOG_TO := UART 将日志输出到串口
REDIRECT_LOG_TO := UART output the log to serial port
REDIRECT_LOG_TO := CACHE 将日志输出到/cache/recovery/目录下
REDIRECT_LOG_TO := CACHE output the log to /cache/recovery/ directory
REDIRECT_LOG_TO := SDCARD 将日志输出到SD卡中recovery.log
REDIRECT_LOG_TO := SDCARD output the log to SD card recovery.log
(2)>=Android 10
bootable/recovery/Android.bp:
-DLogToSerial 将日志输出到串口
-DLogToSerial output the log to serial port
-DLogToCache 将日志输出到/cache/recovery/目录下
-DLogToCache output the log to /cache/recovery/ directory
-DLogToSDCard 将日志输出到SD卡中recovery.log
-DLogToSDCard output the log to SD card recovery.log
恢复出厂设置不擦除某个数据
1.创建一个新的文件分区,类似于system/(它只可读),但是可读可写,恢复出厂设置不清理
2.不新建分区,恢复出厂设置,通过代码保留某个数据
Android recovery 清除数据,跟随源码看,它自己会保留某个文件不被清理!
其实也就是保留了/cache/下的部分文件!(如果不格式化刷机,保留的东西就不会被清理掉)
bootable/recovery/install/wipe_data.cpp
//清理函数入口
bool WipeData(Device* device, bool convert_fbe) {
RecoveryUI* ui = device->GetUI();
ui->Print("\n-- Wiping data...\n");
if (!FinishPendingSnapshotMerges(device)) {
ui->Print("Unable to check update status or complete merge, cannot wipe partitions.\n");
return false;
}
bool success = device->PreWipeData();
if (success) {
success &= EraseVolume(DATA_ROOT, ui, convert_fbe);//erase_volume()重点
bool has_cache = volume_for_mount_point("/cache") != nullptr;
if (has_cache) {
success &= EraseVolume(CACHE_ROOT, ui, false);
}
if (volume_for_mount_point(METADATA_ROOT) != nullptr) {
success &= EraseVolume(METADATA_ROOT, ui, false);
}
}
if (success) {
success &= device->PostWipeData();
}
erase_baseparameter();
ui->Print("Data wipe %s.\n", success ? "complete" : "failed");
return success;
}
static bool EraseVolume(const char* volume, RecoveryUI* ui, bool convert_fbe) {
bool is_cache = (strcmp(volume, CACHE_ROOT) == 0);
bool is_data = (strcmp(volume, DATA_ROOT) == 0);
ui->SetBackground(RecoveryUI::ERASING);
ui->SetProgressType(RecoveryUI::INDETERMINATE);
std::vector<saved_log_file> log_files;
if (is_cache) {
// If we're reformatting /cache, we load any past logs (i.e. "/cache/recovery/last_*") and the
// current log ("/cache/recovery/log") into memory, so we can restore them after the reformat.
log_files = ReadLogFilesToMemory();//保存("/cache/recovery/log")到内存,不清理掉
}
ui->Print("Formatting %s...\n", volume);
...
}
--- a/bootable/recovery/recovery_utils/logging.cpp
+++ b/bootable/recovery/recovery_utils/logging.cpp
@@ -270,7 +270,8 @@ std::vector<saved_log_file> ReadLogFilesToMemory() {
std::vector<saved_log_file> log_files;
while ((de = readdir(d.get())) != nullptr) {
- if (strncmp(de->d_name, "last_", 5) == 0 || strcmp(de->d_name, "log") == 0 || strncmp(de->d_name, "Recovery_", 9) == 0) {
+ if (strncmp(de->d_name, "last_", 5) == 0 || strcmp(de->d_name, "log") == 0 || strncmp(de->d_name, "Recovery_", 9) == 0
+ || strcmp(de->d_name, "bootanimation") == 0) {
std::string path = android::base::StringPrintf("%s/%s", CACHE_LOG_DIR, de->d_name);
struct stat sb;
diff --git a/frameworks/base/core/java/android/os/RecoverySystem.java b/frameworks/base/core/java/android/os/RecoverySystem.java
index 769f1d34d4..224a0f19a6 100755
--- a/frameworks/base/core/java/android/os/RecoverySystem.java
+++ b/frameworks/base/core/java/android/os/RecoverySystem.java
@@ -1213,6 +1213,7 @@ public class RecoverySystem {
public static String handleAftermath(Context context) {
if (names[i].equals(RECOVERY_TEST_STATE)) continue;
if (reservePackage && names[i].equals(BLOCK_MAP_FILE.getName())) continue;
if (reservePackage && names[i].equals(UNCRYPT_PACKAGE_FILE.getName())) continue;
+ if (names[i].equals("bootanimation.zip")) continue;
Log.i(TAG,"names[i]:" + names[i]);//开机完成后,如果不是上面判断的东西,就都清理掉 TAG = RecoverySystem
recursiveDelete(new File(RECOVERY_DIR, names[i]));
Android7.x 通过Recovery保留特定文件实现恢复出厂设置后保留系统语言设置
分类:
Android
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· 实操Deepseek接入个人知识库
· CSnakes vs Python.NET:高效嵌入与灵活互通的跨语言方案对比
· 【.NET】调用本地 Deepseek 模型
· Plotly.NET 一个为 .NET 打造的强大开源交互式图表库