summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--BoardConfig-common.mk8
-rw-r--r--device.mk4
-rw-r--r--init.hardware.rc24
-rw-r--r--recovery/Android.bp1
-rw-r--r--recovery/recovery_ui.cpp30
5 files changed, 61 insertions, 6 deletions
diff --git a/BoardConfig-common.mk b/BoardConfig-common.mk
index 202d2f3d..878aa2f4 100644
--- a/BoardConfig-common.mk
+++ b/BoardConfig-common.mk
@@ -81,9 +81,11 @@ TARGET_RECOVERY_WIPE := device/google/bonito/recovery.wipe
TARGET_RECOVERY_FSTAB := device/google/bonito/fstab.hardware
TARGET_RECOVERY_PIXEL_FORMAT := RGBX_8888
TARGET_RECOVERY_UI_LIB := \
- librecovery_ui_bonito \
- libnos_citadel_for_recovery \
- libnos_for_recovery
+ librecovery_ui_bonito \
+ libnos_citadel_for_recovery \
+ libnos_for_recovery \
+ libbootloader_message \
+ libfstab
# system.img
BOARD_SYSTEMIMAGE_JOURNAL_SIZE := 0
diff --git a/device.mk b/device.mk
index 042d87f1..cc9a9ff3 100644
--- a/device.mk
+++ b/device.mk
@@ -184,6 +184,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 6139b4bc..6684d862 100644
--- a/init.hardware.rc
+++ b/init.hardware.rc
@@ -893,3 +893,27 @@ on property:sys.boot_completed=1
on property:vendor.fps.init.succeed=true && property:init.svc.vendor.fps_hal=stopped
start init-fingerprint-sh
+
+# 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
+ 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
+ disabled
+ oneshot
+
+# Set dark boot flag on dark mode (UiModeManager.MODE_NIGHT_YES == 2).
+on property:persist.sys.theme=2
+ start vendor.theme_set
+
+# Clear the dark boot flag on light mode (UiModeManager.MODE_NIGHT_NO == 1) or auto mode
+# (UiModeManager.MODE_NIGHT_AUTO == 0).
+on property:persist.sys.theme=1
+ start vendor.theme_clear
+
+on property:persist.sys.theme=0
+ start vendor.theme_clear
diff --git a/recovery/Android.bp b/recovery/Android.bp
index 239eee73..f87dc95c 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 55909d0b..e3f16f20 100644
--- a/recovery/recovery_ui.cpp
+++ b/recovery/recovery_ui.cpp
@@ -14,13 +14,19 @@
* 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 +63,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 BonitoDevice : public ::Device
@@ -75,6 +95,10 @@ public:
totalSuccess = false;
}
+ if (!WipeProvisionedFlag()) {
+ totalSuccess = false;
+ }
+
// Extendable to wipe other components
return totalSuccess;