Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Commit 0a83ff9

Browse files
committed
New logic for safemode detection, based on a single key being pressed multiple times.
Upon startup, one of the physical keys must be pressed during the first 2 seconds (or already held down upfront). After that, the same key must be pressed again within 5 seconds, until 5 total presses are reached. Two short vibrations are issued when the initial key is detected, and an additional short vibration for every subsequent key press. If the trigger is successful, a long vibration is issued.
1 parent 4675cc2 commit 0a83ff9

File tree

5 files changed

+177
-108
lines changed

5 files changed

+177
-108
lines changed

app_main.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ int main(int argc, char* const argv[])
176176
if (argc == 2 && strcmp(argv[1], "--xposedtestsafemode") == 0) {
177177
printf("Testing Xposed safemode trigger\n");
178178

179-
if (xposed::detectSafemodeTrigger()) {
179+
if (xposed::detectSafemodeTrigger(xposedSkipSafemodeDelay())) {
180180
printf("Safemode triggered\n");
181181
} else {
182182
printf("Safemode not triggered\n");
@@ -264,7 +264,7 @@ int main(int argc, char* const argv[])
264264
}
265265

266266
if (zygote) {
267-
if (xposed::detectSafemodeTrigger())
267+
if (xposed::detectSafemodeTrigger(xposedSkipSafemodeDelay()))
268268
disableXposed();
269269
}
270270

xposed.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,15 @@ bool isXposedDisabled() {
9999
return false;
100100
}
101101

102+
bool xposedSkipSafemodeDelay() {
103+
// is the flag file present?
104+
if (access(XPOSED_SAFEMODE_NODELAY, F_OK) == 0)
105+
return true;
106+
else
107+
return false;
108+
}
109+
110+
102111
// ignore the broadcasts by various Superuser implementations to avoid spamming the Xposed log
103112
bool xposedShouldIgnoreCommand(const char* className, int argc, const char* const argv[]) {
104113
if (className == NULL || argc < 4 || strcmp(className, "com.android.commands.am.Am") != 0)

xposed.h

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ namespace android {
1111
#define XPOSED_JAR XPOSED_DIR "bin/XposedBridge.jar"
1212
#define XPOSED_JAR_NEWVERSION XPOSED_DIR "bin/XposedBridge.jar.newversion"
1313
#define XPOSED_LOAD_BLOCKER XPOSED_DIR "conf/disabled"
14+
#define XPOSED_SAFEMODE_NODELAY XPOSED_DIR "conf/safemode_nodelay"
1415
#define XPOSED_CLASS "de/robv/android/xposed/XposedBridge"
1516
#define XPOSED_CLASS_DOTS "de.robv.android.xposed.XposedBridge"
1617
#define XRESOURCES_CLASS "android/content/res/XResources"
@@ -43,6 +44,7 @@ void xposedInfo();
4344
void xposedEnforceDalvik();
4445
void disableXposed();
4546
bool isXposedDisabled();
47+
bool xposedSkipSafemodeDelay();
4648
bool xposedShouldIgnoreCommand(const char* className, int argc, const char* const argv[]);
4749
bool addXposedToClasspath(bool zygote);
4850
bool xposedOnVmCreated(JNIEnv* env, const char* className);

0 commit comments

Comments
 (0)