diff --git a/hooks.h b/hooks.h
index 09dd885..94a6b47 100644
--- a/hooks.h
+++ b/hooks.h
@@ -41,6 +41,11 @@ void mrom_hook_fixup_bootimg_cmdline(char *bootimg_cmdline, size_t bootimg_cmdli
int mrom_hook_has_kexec(void);
#endif
+#if MR_DEVICE_HOOKS >= 6
+void tramp_hook_encryption_setup(void);
+void tramp_hook_encryption_cleanup(void);
+#endif
+
#endif /* MR_DEVICE_HOOKS */
#endif /* MR_DEVICE_HOOKS_H */
diff --git a/install_zip/Android.mk b/install_zip/Android.mk
index b270625..e52fc18 100644
--- a/install_zip/Android.mk
+++ b/install_zip/Android.mk
@@ -14,7 +14,7 @@ endif
multirom_extra_dep :=
ifeq ($(MR_ENCRYPTION),true)
- multirom_extra_dep += trampoline_encmnt linker
+ multirom_extra_dep += trampoline_encmnt linker libmultirom_fake_properties
else
MR_ENCRYPTION := false
endif
@@ -59,6 +59,7 @@ $(MULTIROM_ZIP_TARGET): multirom trampoline signapk bbootimg mrom_kexec_static m
cp -a $(TARGET_OUT_SHARED_LIBRARIES)/libm.so $(MULTIROM_INST_DIR)/multirom/enc/; \
cp -a $(TARGET_OUT_SHARED_LIBRARIES)/libstdc++.so $(MULTIROM_INST_DIR)/multirom/enc/; \
cp -a $(TARGET_OUT_SHARED_LIBRARIES)/libc++.so $(MULTIROM_INST_DIR)/multirom/enc/; \
+ cp -a $(TARGET_OUT_SHARED_LIBRARIES)/libmultirom_fake_properties.so $(MULTIROM_INST_DIR)/multirom/enc/; \
if [ -n "$(MR_ENCRYPTION_SETUP_SCRIPT)" ]; then sh "$(ANDROID_BUILD_TOP)/$(MR_ENCRYPTION_SETUP_SCRIPT)" "$(ANDROID_BUILD_TOP)" "$(MULTIROM_INST_DIR)/multirom/enc"; fi; \
fi
diff --git a/trampoline/Android.mk b/trampoline/Android.mk
index a29709c..c372568 100644
--- a/trampoline/Android.mk
+++ b/trampoline/Android.mk
@@ -40,4 +40,8 @@ ifeq ($(MR_ENCRYPTION),true)
LOCAL_SRC_FILES += encryption.c
endif
+ifeq ($(MR_ENCRYPTION_FAKE_PROPERTIES),true)
+ LOCAL_CFLAGS += -DMR_ENCRYPTION_FAKE_PROPERTIES
+endif
+
include $(BUILD_EXECUTABLE)
diff --git a/trampoline/encryption.c b/trampoline/encryption.c
index 4f11e77..948b3b3 100644
--- a/trampoline/encryption.c
+++ b/trampoline/encryption.c
@@ -30,12 +30,23 @@
#include "../lib/log.h"
#include "encryption.h"
#include "../trampoline_encmnt/encmnt_defines.h"
+#include "../hooks.h"
static char encmnt_cmd_arg[64] = { 0 };
static char *const encmnt_cmd[] = { "/mrom_enc/trampoline_encmnt", encmnt_cmd_arg, NULL };
+#ifdef MR_ENCRYPTION_FAKE_PROPERTIES
+static char *const encmnt_envp[] = { "LD_LIBRARY_PATH=/mrom_enc/", "LD_PRELOAD=/mrom_enc/libmultirom_fake_properties.so", NULL };
+#else
static char *const encmnt_envp[] = { "LD_LIBRARY_PATH=/mrom_enc/", NULL };
+#endif
static int g_decrypted = 0;
+#ifdef __LP64__
+#define LINKER_PATH "/system/bin/linker64"
+#else
+#define LINKER_PATH "/system/bin/linker"
+#endif
+
int encryption_before_mount(struct fstab *fstab)
{
int exit_code = -1;
@@ -43,10 +54,13 @@ int encryption_before_mount(struct fstab *fstab)
int res = ENC_RES_ERR;
mkdir_recursive("/system/bin", 0755);
- remove("/system/bin/linker");
- symlink("/mrom_enc/linker", "/system/bin/linker");
+ remove(LINKER_PATH);
+ symlink("/mrom_enc/linker", LINKER_PATH);
chmod("/mrom_enc/linker", 0775);
chmod("/mrom_enc/trampoline_encmnt", 0775);
+ // some fonts not in ramdisk to save space, so use regular instead
+ symlink("/mrom_enc/res/Roboto-Regular.ttf", "/mrom_enc/res/Roboto-Italic.ttf");
+ symlink("/mrom_enc/res/Roboto-Regular.ttf", "/mrom_enc/res/Roboto-Medium.ttf");
remove("/vendor");
symlink("/mrom_enc/vendor", "/vendor");
@@ -59,6 +73,10 @@ int encryption_before_mount(struct fstab *fstab)
ERROR("Mounting /firmware for encryption failed with %s\n", strerror(errno));
}
+#if MR_DEVICE_HOOKS >= 6
+ tramp_hook_encryption_setup();
+#endif
+
INFO("Running trampoline_encmnt\n");
strcpy(encmnt_cmd_arg, "decrypt");
@@ -122,12 +140,15 @@ void encryption_destroy(void)
}
// Make sure we're removing our symlink and not ROM's linker
- if(lstat("/system/bin/linker", &info) >= 0 && S_ISLNK(info.st_mode))
- remove("/system/bin/linker");
+ if(lstat(LINKER_PATH, &info) >= 0 && S_ISLNK(info.st_mode))
+ remove(LINKER_PATH);
}
int encryption_cleanup(void)
{
+#if MR_DEVICE_HOOKS >= 6
+ tramp_hook_encryption_cleanup();
+#endif
remove("/vendor");
if(access("/firmware", R_OK) >= 0 && umount("/firmware") < 0)
diff --git a/trampoline_encmnt/Android.mk b/trampoline_encmnt/Android.mk
index f879f82..8dd4f84 100644
--- a/trampoline_encmnt/Android.mk
+++ b/trampoline_encmnt/Android.mk
@@ -27,3 +27,14 @@ LOCAL_SRC_FILES := \
include $(multirom_local_path)/device_defines.mk
include $(BUILD_EXECUTABLE)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := libmultirom_fake_properties
+LOCAL_MODULE_TAGS := eng
+LOCAL_C_INCLUDES += $(multirom_local_path)
+
+LOCAL_SRC_FILES := fake_properties.c
+
+include $(multirom_local_path)/device_defines.mk
+include $(BUILD_SHARED_LIBRARY)
diff --git a/trampoline_encmnt/fake_properties.c b/trampoline_encmnt/fake_properties.c
new file mode 100644
index 0000000..41a560b
--- /dev/null
+++ b/trampoline_encmnt/fake_properties.c
@@ -0,0 +1,33 @@
+/*
+ * This file is part of MultiROM.
+ *
+ * MultiROM is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * MultiROM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with MultiROM. If not, see .
+ */
+#include
+#include
+#include
+
+/* MultiROM doesn't initialize the property service,
+ * but decryption on Nexus 6P waits for one property to become true
+ * so we hardcode it here
+ */
+
+int property_get(const char *key, char *value, const char *default_value)
+{
+ if (!strcmp(key, "sys.listeners.registered"))
+ default_value = "true";
+ if (default_value)
+ strncpy(value, default_value, PROP_VALUE_MAX);
+ return strlen(value);
+}