diff options
author | Tao Bao <tbao@google.com> | 2019-05-24 09:21:21 -0700 |
---|---|---|
committer | Tao Bao <tbao@google.com> | 2019-05-28 08:44:47 -0700 |
commit | bbae0b532a921269288283bbbd828ac3aaa21eea (patch) | |
tree | 5097b24bbee5f485d556ea05af1f14efb43ce095 | |
parent | 41b57b2f2a128e9b3f49fd6f2e74dc1d45b58caf (diff) | |
download | crosshatch-bbae0b532a921269288283bbbd828ac3aaa21eea.tar.gz |
Set / clear device provisioned flag in /misc.
Bug: 113028175
Test: Build and flash crosshatch with the matching bootloader change.
Check serial log regarding the start of darkboot service. Also
read the value via `dd bs=1 skip=2048 if=/dev/block/sda2 count=32
| xxd` to confirm the change.
Test: Trigger a factory reset via Settings. Check the value in /misc
after the reset.
Change-Id: I20ec3efd1762b339827d5b1afdd01ff022e6d23f
-rw-r--r-- | BoardConfig-common.mk | 8 | ||||
-rw-r--r-- | device.mk | 4 | ||||
-rw-r--r-- | init.hardware.rc | 9 | ||||
-rw-r--r-- | recovery/Android.bp | 1 | ||||
-rw-r--r-- | recovery/recovery_ui.cpp | 29 |
5 files changed, 46 insertions, 5 deletions
diff --git a/BoardConfig-common.mk b/BoardConfig-common.mk index 4d633230..c5838819 100644 --- a/BoardConfig-common.mk +++ b/BoardConfig-common.mk @@ -72,9 +72,11 @@ TARGET_RECOVERY_FSTAB := device/google/crosshatch/fstab.hardware endif TARGET_RECOVERY_PIXEL_FORMAT := RGBX_8888 TARGET_RECOVERY_UI_LIB := \ - librecovery_ui_crosshatch \ - libnos_citadel_for_recovery \ - libnos_for_recovery + librecovery_ui_crosshatch \ + libnos_citadel_for_recovery \ + libnos_for_recovery \ + libbootloader_message \ + libfstab ifneq ($(filter %_mainline,$(TARGET_PRODUCT)),) BOARD_AVB_VBMETA_SYSTEM := system product_services @@ -193,6 +193,10 @@ PRODUCT_PACKAGES_DEBUG += \ bootctl \ update_engine_client +# Write flags to the vendor space in /misc partition. +PRODUCT_PACKAGES += \ + misc_writer + PRODUCT_COPY_FILES += \ frameworks/native/data/etc/android.hardware.camera.flash-autofocus.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.camera.flash-autofocus.xml \ frameworks/native/data/etc/android.hardware.camera.front.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.camera.front.xml \ diff --git a/init.hardware.rc b/init.hardware.rc index e20eb2fe..6ece1e1f 100644 --- a/init.hardware.rc +++ b/init.hardware.rc @@ -990,3 +990,12 @@ on boot && property:persist.radio.multisim.config=dsds && property:persist.vendo on boot && property:persist.radio.multisim.config=dsds && property:persist.vendor.radio.multisim_switch_support=false setprop persist.radio.multisim.config "" stop vendor.qcrild2 + +# Write the dark theme magic (`theme-dark`, or 0x7468656d652d6461726b in hex string) to /misc +# partition. Offset 0 in vendor space is effectively offset 2048 in /misc partition. +service vendor.darkboot /vendor/bin/misc_writer --vendor-space-offset 0 --hex-string 0x7468656d652d6461726b + disabled + oneshot + +on property:persist.sys.device_provisioned=1 + start vendor.darkboot diff --git a/recovery/Android.bp b/recovery/Android.bp index 0ff76298..9cda7f8b 100644 --- a/recovery/Android.bp +++ b/recovery/Android.bp @@ -29,6 +29,7 @@ cc_library_static { static_libs: [ "libbase", + "libbootloader_message", "libnos_for_recovery", "libnos_citadel_for_recovery", ], diff --git a/recovery/recovery_ui.cpp b/recovery/recovery_ui.cpp index 6a20579b..c3df373d 100644 --- a/recovery/recovery_ui.cpp +++ b/recovery/recovery_ui.cpp @@ -14,13 +14,20 @@ * limitations under the License. */ +#include <stdint.h> +#include <string.h> + +#include <string> +#include <string_view> +#include <vector> + #include <android-base/endian.h> #include <android-base/logging.h> #include <app_nugget.h> -#include <nos/debug.h> +#include <bootloader_message/bootloader_message.h> #include <nos/NuggetClient.h> - +#include <nos/debug.h> #include <recovery_ui/device.h> #include <recovery_ui/screen_ui.h> @@ -57,6 +64,20 @@ bool WipeTitanM() { return true; } +// Wipes the provisioned flag as part of data wipe. +bool WipeProvisionedFlag() { + // Must be consistent with the one in init.hardware.rc (10-byte `theme-dark`). + const std::string wipe_str(10, '\x00'); + constexpr size_t kProvisionedFlagOffsetInVendorSpace = 0; + if (std::string err; !WriteMiscPartitionVendorSpace( + wipe_str.data(), wipe_str.size(), kProvisionedFlagOffsetInVendorSpace, &err)) { + LOG(ERROR) << "Failed to write wipe string: " << err; + return false; + } + LOG(INFO) << "Provisioned flag wiped successful"; + return true; +} + } // namespace class CrosshatchDevice : public ::Device @@ -75,6 +96,10 @@ public: totalSuccess = false; } + if (!WipeProvisionedFlag()) { + totalSuccess = false; + } + // Extendable to wipe other components return totalSuccess; |