说明
android 恢复出厂设置的处理逻辑是RecoverySystem.java中的rebootWipeUserData,源码在recovery.cpp中的main中,前面有想过在recovery的wipe_data方法执行完后设置persist系统属性,但是恢复出厂设置重启后会被置为空,所以只能在/ system/core/bootstat/bootstat.cpp重启原因*(sys.boot.reason)的位置加,
diff --git a/packages/services/Car/service/src/com/android/car/tbox/cartboxservice/tbox/CarTBoxServiceBinder.java b/packages/servic
index d973cfc..9b126c4 100755
--- a/packages/services/Car/service/src/com/android/car/tbox/cartboxservice/tbox/CarTBoxServiceBinder.java
+++ b/packages/services/Car/service/src/com/android/car/tbox/cartboxservice/tbox/CarTBoxServiceBinder.java
@@ -672,9 +672,15 @@ public class CarTBoxServiceBinder extends ITboxInterface.Stub {
case CarCabinManager.ID_IP_LANGUAGE_SWITCH_SET:
try {
- int launguage_switch = (int) carPropertyValue.getValue();
- Log.d(TAG, "launguage_switch = " + launguage_switch);
- if (1 == launguage_switch) {
+ int language_switch = (int) carPropertyValue.getValue();
+ String flag = SystemProperties.get("persist.sys.reboot_wipe_data", "0");
+ if (flag.equals("1")) {
+ language_switch = 0;
+ SystemProperties.set("persist.sys.reboot_wipe_data", "0");
+ Log.d(TAG, "reboot_wipe_data");
+ }
+ Log.d(TAG, "language_switch = " + language_switch);
+ if (1 == language_switch) {
LocalePicker.updateLocale(Locale.ENGLISH);
} else {
LocalePicker.updateLocale(Locale.CHINESE);
diff --git a/system/core/bootstat/bootstat.cpp b/system/core/bootstat/bootstat.cpp
old mode 100644
new mode 100755
index 7a67894..4e728e3
--- a/system/core/bootstat/bootstat.cpp
+++ b/system/core/bootstat/bootstat.cpp
@@ -527,6 +527,7 @@ void transformReason(std::string& reason) {
}
const char system_reboot_reason_property[] = "sys.boot.reason";
+const char system_reboot_wipe_data[] = "persist.sys.reboot_wipe_data";
const char last_reboot_reason_property[] = LAST_REBOOT_REASON_PROPERTY;
const char bootloader_reboot_reason_property[] = "ro.boot.bootreason";
@@ -831,6 +832,7 @@ std::string CalculateBootCompletePrefix() {
boot_event_store.AddBootEventWithValue(kBuildDateKey, build_date);
LOG(INFO) << "Canonical boot reason: reboot,factory_reset";
SetProperty(system_reboot_reason_property, "reboot,factory_reset");
+ SetProperty(system_reboot_wipe_data, "1");
} else if (build_date != record.second) {
boot_complete_prefix = "ota_" + boot_complete_prefix;
boot_event_store.AddBootEventWithValue(kBuildDateKey, build_date);
@@ -956,6 +958,10 @@ void SetSystemBootReason() {
const std::string system_boot_reason(BootReasonStrToReason(bootloader_boot_reason));
// Record the scrubbed system_boot_reason to the property
SetProperty(system_reboot_reason_property, system_boot_reason);
+ if(system_boot_reason.compare("reboot,factory_reset") == 0) {
+ SetProperty(system_reboot_wipe_data, "1");
+ LOG(DEBUG) << "zjy factory reset";
+ }
}
// Gets the boot time offset. This is useful when Android is running in a
(END)