diff options
author | Xin Li <delphij@google.com> | 2019-08-14 12:04:02 -0700 |
---|---|---|
committer | Xin Li <delphij@google.com> | 2019-08-14 12:04:02 -0700 |
commit | 1dbdfa22e6982fef684497eb9dbadb09130ed82b (patch) | |
tree | 41e7c09969933958de53e5828cd9ff26a8c48ae9 | |
parent | b296f909cb6abdd246677030848412a98580aecb (diff) | |
parent | bfd640036b0404d8f7a94cac66b31c7e10dd04e8 (diff) | |
download | marlin-1dbdfa22e6982fef684497eb9dbadb09130ed82b.tar.gz |
DO NOT MERGE - Merge qt-dev-plus-aosp-without-vendor (5713463) into stage-aosp-master
Bug: 134405016
Change-Id: Ie43ec00f9a89d4fae00d43f98af2c5c6c704c246
-rw-r--r-- | device-common.mk | 3 | ||||
-rw-r--r-- | init.common.rc | 24 | ||||
-rw-r--r-- | marlin/BoardConfig.mk | 3 | ||||
-rw-r--r-- | recovery/nanohub/Android.mk | 6 | ||||
-rw-r--r-- | recovery/nanohub/nanohub_recovery_ui.cpp | 46 | ||||
-rw-r--r-- | sailfish/BoardConfig.mk | 3 |
6 files changed, 66 insertions, 19 deletions
diff --git a/device-common.mk b/device-common.mk index 7b7d3b19..46e9838c 100644 --- a/device-common.mk +++ b/device-common.mk @@ -641,3 +641,6 @@ PRODUCT_PACKAGES += \ # a_sns_test for sensor testing PRODUCT_PACKAGES_DEBUG += a_sns_test +# Write flags to the vendor space in /misc partition. +PRODUCT_PACKAGES += \ + misc_writer diff --git a/init.common.rc b/init.common.rc index ec470912..46f697b8 100644 --- a/init.common.rc +++ b/init.common.rc @@ -886,3 +886,27 @@ on property:sys.vdso=64 on property:sys.vdso=32 write /sys/module/vdso/parameters/enable_64 0 + +# Write the dark theme magic (`theme-dark`, or 0x7468656d652d6461726b in hex string) to /misc +# partition. Offset 10814 in vendor space is effectively offset 12862 in /misc partition. +service vendor.darkboot /vendor/bin/misc_writer --vendor-space-offset 10814 --hex-string 0x7468656d652d6461726b + disabled + oneshot + +# Clear the 10-byte dark theme magic in /misc partition. Offset 10814 in vendor space is effectively +# offset 12862 in /misc partition. +service vendor.darkboot_clear /vendor/bin/misc_writer --vendor-space-offset 10814 --hex-string 0x00000000000000000000 + disabled + oneshot + +# Set the dark boot flag on dark mode (UiModeManager.MODE_NIGHT_YES == 2). +on property:persist.sys.theme=2 + start vendor.darkboot + +# Clear the dark theme 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.darkboot_clear + +on property:persist.sys.theme=0 + start vendor.darkboot_clear diff --git a/marlin/BoardConfig.mk b/marlin/BoardConfig.mk index 693a650b..b4278cfd 100644 --- a/marlin/BoardConfig.mk +++ b/marlin/BoardConfig.mk @@ -168,7 +168,8 @@ PROTOBUF_SUPPORTED := false #Add NON-HLOS files for ota upgrade ADD_RADIO_FILES := true -TARGET_RECOVERY_UI_LIB := librecovery_ui_nanohub + +TARGET_RECOVERY_UI_LIB := librecovery_ui_nanohub libbootloader_message libfstab #Add support for firmare upgrade on 8996 HAVE_SYNAPTICS_DSX_FW_UPGRADE := true diff --git a/recovery/nanohub/Android.mk b/recovery/nanohub/Android.mk index 70ccb376..29bf1717 100644 --- a/recovery/nanohub/Android.mk +++ b/recovery/nanohub/Android.mk @@ -14,7 +14,7 @@ # limitations under the License. # -ifeq ($(TARGET_RECOVERY_UI_LIB),librecovery_ui_nanohub) +ifneq (,$(filter librecovery_ui_nanohub,$(TARGET_RECOVERY_UI_LIB))) LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) @@ -24,7 +24,9 @@ LOCAL_MODULE_TAGS := optional LOCAL_SRC_FILES := nanohub_recovery_ui.cpp -LOCAL_SHARED_LIBRARIES := librecovery_ui +LOCAL_SHARED_LIBRARIES := libbase librecovery_ui + +LOCAL_STATIC_LIBRARIES := libbootloader_message include $(BUILD_STATIC_LIBRARY) endif diff --git a/recovery/nanohub/nanohub_recovery_ui.cpp b/recovery/nanohub/nanohub_recovery_ui.cpp index 9298c059..6f175305 100644 --- a/recovery/nanohub/nanohub_recovery_ui.cpp +++ b/recovery/nanohub/nanohub_recovery_ui.cpp @@ -20,38 +20,54 @@ #include <unistd.h> #include <errno.h> -#include "recovery_ui/device.h" -#include "recovery_ui/screen_ui.h" +#include <string> -class Nanohub_Device : public Device -{ -public: +#include <android-base/logging.h> +#include <bootloader_message/bootloader_message.h> +#include <recovery_ui/device.h> +#include <recovery_ui/screen_ui.h> + +// Wipes the dark theme flag as part of data wipe. +static bool WipeDarkThemeFlag() { + // Must be consistent with the one in init.hardware.rc (10-byte `theme-dark`). The magic is at + // 10814 in vendor space, or (2048 + 10814) since the start of /misc. + const std::string wipe_str(10, '\x00'); + constexpr size_t kDarkThemeFlagOffsetInVendorSpace = 10814; + if (std::string err; !WriteMiscPartitionVendorSpace( + wipe_str.data(), wipe_str.size(), kDarkThemeFlagOffsetInVendorSpace, &err)) { + LOG(ERROR) << "Failed to write wipe string: " << err; + return false; + } + LOG(INFO) << "Dark theme flag wiped successfully"; + return true; +} + +class Nanohub_Device : public Device { + public: Nanohub_Device(ScreenRecoveryUI* ui) : Device(ui) {} bool PostWipeData(); }; -bool Nanohub_Device::PostWipeData() -{ - int fd; - - fd = open("/sys/class/nanohub/nanohub/erase_shared", O_WRONLY); +bool Nanohub_Device::PostWipeData() { + int fd = open("/sys/class/nanohub/nanohub/erase_shared", O_WRONLY); if (fd < 0) { - printf("error: open erase_shared failed: %s\n", strerror(errno)); + PLOG(ERROR) << "open erase_shared failed"; } else { if (write(fd, "1\n", 2) != 2) { - printf("error: write to erase_shared failed: %s\n", strerror(errno)); + PLOG(ERROR) << "write to erase_shared failed"; } else { - printf("Successfully erased nanoapps.\n"); + LOG(INFO) << "Successfully erased nanoapps"; } close(fd); } + WipeDarkThemeFlag(); + // open/write failure caused by permissions issues would persist across // reboots, so always return true to prevent a factory reset failure loop. return true; } -Device *make_device() -{ +Device* make_device() { return new Nanohub_Device(new ScreenRecoveryUI); } diff --git a/sailfish/BoardConfig.mk b/sailfish/BoardConfig.mk index e65ad4ed..5b9632bf 100644 --- a/sailfish/BoardConfig.mk +++ b/sailfish/BoardConfig.mk @@ -167,7 +167,8 @@ PROTOBUF_SUPPORTED := false #Add NON-HLOS files for ota upgrade ADD_RADIO_FILES := true -TARGET_RECOVERY_UI_LIB := librecovery_ui_nanohub + +TARGET_RECOVERY_UI_LIB := librecovery_ui_nanohub libbootloader_message libfstab #Add support for firmare upgrade on 8996 HAVE_SYNAPTICS_DSX_FW_UPGRADE := true |