Skip to content

Commit

Permalink
New logic for safemode detection, based on a single key being pressed…
Browse files Browse the repository at this point in the history
… 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.
  • Loading branch information
Tungstwenty committed Jan 14, 2014
1 parent 4675cc2 commit 0a83ff9
Show file tree
Hide file tree
Showing 5 changed files with 177 additions and 108 deletions.
4 changes: 2 additions & 2 deletions app_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ int main(int argc, char* const argv[])
if (argc == 2 && strcmp(argv[1], "--xposedtestsafemode") == 0) {
printf("Testing Xposed safemode trigger\n");

if (xposed::detectSafemodeTrigger()) {
if (xposed::detectSafemodeTrigger(xposedSkipSafemodeDelay())) {
printf("Safemode triggered\n");
} else {
printf("Safemode not triggered\n");
Expand Down Expand Up @@ -264,7 +264,7 @@ int main(int argc, char* const argv[])
}

if (zygote) {
if (xposed::detectSafemodeTrigger())
if (xposed::detectSafemodeTrigger(xposedSkipSafemodeDelay()))
disableXposed();
}

Expand Down
9 changes: 9 additions & 0 deletions xposed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,15 @@ bool isXposedDisabled() {
return false;
}

bool xposedSkipSafemodeDelay() {
// is the flag file present?
if (access(XPOSED_SAFEMODE_NODELAY, F_OK) == 0)
return true;
else
return false;
}


// ignore the broadcasts by various Superuser implementations to avoid spamming the Xposed log
bool xposedShouldIgnoreCommand(const char* className, int argc, const char* const argv[]) {
if (className == NULL || argc < 4 || strcmp(className, "com.android.commands.am.Am") != 0)
Expand Down
2 changes: 2 additions & 0 deletions xposed.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace android {
#define XPOSED_JAR XPOSED_DIR "bin/XposedBridge.jar"
#define XPOSED_JAR_NEWVERSION XPOSED_DIR "bin/XposedBridge.jar.newversion"
#define XPOSED_LOAD_BLOCKER XPOSED_DIR "conf/disabled"
#define XPOSED_SAFEMODE_NODELAY XPOSED_DIR "conf/safemode_nodelay"
#define XPOSED_CLASS "de/robv/android/xposed/XposedBridge"
#define XPOSED_CLASS_DOTS "de.robv.android.xposed.XposedBridge"
#define XRESOURCES_CLASS "android/content/res/XResources"
Expand Down Expand Up @@ -43,6 +44,7 @@ void xposedInfo();
void xposedEnforceDalvik();
void disableXposed();
bool isXposedDisabled();
bool xposedSkipSafemodeDelay();
bool xposedShouldIgnoreCommand(const char* className, int argc, const char* const argv[]);
bool addXposedToClasspath(bool zygote);
bool xposedOnVmCreated(JNIEnv* env, const char* className);
Expand Down
Loading

0 comments on commit 0a83ff9

Please sign in to comment.