Skip to content

Commit 2071cfb

Browse files
committed
Don't load Xposed for minimal framework
When the device is encrypted and a password has to be entered on boot, a tmpfs is mounted on /data, i.e. the real /data partition isn't available. Therefore, it doesn't make much sense to load Xposed as we wouldn't be able to load the modules anyway.
1 parent 537332f commit 2071cfb

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

app_main2.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,9 @@ int main(int argc, char* const argv[])
238238
}
239239
}
240240

241-
if (xposed::handleOptions(argc, argv))
242-
return 0;
241+
if (xposed::handleOptions(argc, argv)) {
242+
return 0;
243+
}
243244

244245
AppRuntime runtime(argv[0], computeArgBlockSize(argc, argv));
245246
// Process command line arguments

xposed.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ bool initialize(bool zygote, bool startSystemServer, const char* className, int
7979
return false;
8080
#endif
8181

82+
if (isMinimalFramework()) {
83+
ALOGI("Not loading Xposed for minimal framework (encrypted device)");
84+
return false;
85+
}
86+
8287
xposed->zygote = zygote;
8388
xposed->startSystemServer = startSystemServer;
8489
xposed->startClassName = className;
@@ -430,4 +435,18 @@ void dropCapabilities(int8_t keep[]) {
430435
capset(&header, &cap[0]);
431436
}
432437

438+
/**
439+
* Checks whether the system is booting into a minimal Android framework.
440+
* This is the case when the device is encrypted with a password that
441+
* has to be entered on boot. /data is a tmpfs in that case, so we
442+
* can't load any modules anyway.
443+
* The system will reboot later with the full framework.
444+
*/
445+
bool isMinimalFramework() {
446+
char voldDecrypt[PROPERTY_VALUE_MAX];
447+
property_get("vold.decrypt", voldDecrypt, "");
448+
return ((strcmp(voldDecrypt, "trigger_restart_min_framework") == 0) ||
449+
(strcmp(voldDecrypt, "1") == 0));
450+
}
451+
433452
} // namespace xposed

xposed.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ namespace xposed {
4747
void onVmCreated(JNIEnv* env);
4848
void setProcessName(const char* name);
4949
void dropCapabilities(int8_t keep[] = NULL);
50+
bool isMinimalFramework();
5051

5152
} // namespace xposed
5253

0 commit comments

Comments
 (0)