Use more specific option to set dark mode

We have switch misc_writer to use more specific flags to set the dark mode.
Modify the caller as well.

Bug: 131775112
Test: set dark mode, check device boots with dark mode
Change-Id: Ic79a83f58c3b0ca09dd530f28e93da234ae4463a
This commit is contained in:
Tianjie Xu
2019-11-11 15:34:04 -08:00
parent 4016d8d585
commit 06ff813fcc
4 changed files with 13 additions and 14 deletions

View File

@@ -91,7 +91,6 @@ TARGET_RECOVERY_UI_MARGIN_HEIGHT := 105
TARGET_RECOVERY_UI_LIB := \
librecovery_ui_taimen \
libbootloader_message \
libfstab
# VTS DTBO Verification. This kernel cmdline parameter should be added by the bootloader

View File

@@ -53,15 +53,13 @@ on late-init && property:ro.boot.revision=rev_a
on late-init && property:ro.boot.revision=rev_b
setprop vendor.thermal.config thermal_info_config_evt.json
# 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.theme_set /vendor/bin/misc_writer --vendor-space-offset 0 --hex-string 0x7468656d652d6461726b
# Write the dark theme magic to /misc partition.
service vendor.theme_set /vendor/bin/misc_writer --set-dark-theme
disabled
oneshot
# Clear the 10-byte dark theme magic in /misc partition. Offset 0 in vendor space is effectively
# offset 2048 in /misc partition.
service vendor.theme_clear /vendor/bin/misc_writer --vendor-space-offset 0 --hex-string 0x00000000000000000000
# Clear the dark theme magic in /misc partition.
service vendor.theme_clear /vendor/bin/misc_writer --clear-dark-theme
disabled
oneshot

View File

@@ -27,7 +27,8 @@ cc_library_static {
"recovery_ui.cpp",
],
static_libs: [
whole_static_libs: [
"libmisc_writer",
"libbootloader_message",
],

View File

@@ -18,17 +18,18 @@
#include <android-base/logging.h>
#include <bootloader_message/bootloader_message.h>
#include <misc_writer/misc_writer.h>
#include <recovery_ui/device.h>
#include <recovery_ui/screen_ui.h>
using android::hardware::google::pixel::MiscWriter;
using android::hardware::google::pixel::MiscWriterActions;
// Wipes the provisioned flag as part of data wipe.
static 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;
MiscWriter misc_writer(MiscWriterActions::kClearDarkThemeFlag);
if (!misc_writer.PerformAction()) {
LOG(ERROR) << "Failed to clear the dark theme flag";
return false;
}
LOG(INFO) << "Provisioned flag wiped successful";