From 2c821a8c0a4fbaa6c7061282e5fc8b5b53e9b45a Mon Sep 17 00:00:00 2001 From: nijel8 Date: Sat, 29 Dec 2018 04:56:41 -0500 Subject: vold_decrypt: Add android 9.0 support * build modified vdc_pie binary with 'checkpw' command support if building with Android 9.0 platform. That command and others we don't care about, are removed from Pie vdc. Our vdc_pie will run if system sdk version is > 27, otherwise system vdc is used. Code adapted from Android 9.0 system/vold/vdc. * include prebuilt vdc_pie(arm, arm64) binary if building with lower than Android 9.0 platform - vdc_pie cannot be build from source with those platforms without additional imports from Android 9.0 * skip vdc "getpwtype" command for Pie - vds communicates with vold directly, no need for connection retries first * add /system/bin/servicemanager to required services * mount per-devive additional partitions needed for decryption listed with device BoardConfig.mk TW_CRYPTO_SYSTEM_VOLD_MOUNT flag like(space separated): TW_CRYPTO_SYSTEM_VOLD_MOUNT := vendor cust odm * add function to backup crypto footer before running vdc commands and restore it after - on Xiaomi Mi Max 3 both Oreo and Pie stock roms vold alters cripto footer when decrypting data in recovery which causes system to ask for crypto password at next reboot although password stays unchanged. Crypto footer backup/restore added as workaround for systems whit ro.build.version.sdk > 25. Also to preserve crypto footer integrity decryption attempts are skipped if footer backup fails to ensure no data loss. Code adapted from https://gerrit.omnirom.org/#/c/android_bootable_recovery/+/31206/ Change-Id: I0a383f3843578fa55595cfea3b7c9c4431646a1a --- prebuilt/Android.mk | 15 +++++++++++++++ prebuilt/vdc_pie-arm | Bin 0 -> 46588 bytes prebuilt/vdc_pie-arm64 | Bin 0 -> 69824 bytes 3 files changed, 15 insertions(+) create mode 100755 prebuilt/vdc_pie-arm create mode 100755 prebuilt/vdc_pie-arm64 (limited to 'prebuilt') diff --git a/prebuilt/Android.mk b/prebuilt/Android.mk index 235b77c86..27bcd5f41 100644 --- a/prebuilt/Android.mk +++ b/prebuilt/Android.mk @@ -499,3 +499,18 @@ LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin LOCAL_SRC_FILES := $(LOCAL_MODULE) include $(BUILD_PREBUILT) + +ifeq ($(TW_INCLUDE_CRYPTO), true) + ifneq ($(TW_CRYPTO_USE_SYSTEM_VOLD),) + ifneq ($(shell test $(PLATFORM_SDK_VERSION) -ge 28; echo $$?),0) + # Prebuilt vdc_pie for pre-Pie SDK Platforms + include $(CLEAR_VARS) + LOCAL_MODULE := vdc_pie + LOCAL_MODULE_TAGS := eng + LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES + LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin + LOCAL_SRC_FILES := vdc_pie-$(TARGET_ARCH) + include $(BUILD_PREBUILT) + endif + endif +endif diff --git a/prebuilt/vdc_pie-arm b/prebuilt/vdc_pie-arm new file mode 100755 index 000000000..cf05cad53 Binary files /dev/null and b/prebuilt/vdc_pie-arm differ diff --git a/prebuilt/vdc_pie-arm64 b/prebuilt/vdc_pie-arm64 new file mode 100755 index 000000000..46231402f Binary files /dev/null and b/prebuilt/vdc_pie-arm64 differ -- cgit v1.2.3