Skip to content

Commit

Permalink
Improved reliability and speed
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyAdshead committed Mar 21, 2017
1 parent 71c3b85 commit 51c1ed5
Showing 1 changed file with 15 additions and 18 deletions.
33 changes: 15 additions & 18 deletions app/src/main/java/com/baronkiko/launcherhijack/AccServ.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,22 @@ public Intent GetDesiredIntent()
return new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME).setPackage(s).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS|Intent.FLAG_ACTIVITY_CLEAR_TOP|Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
}

private void PerformHomePress()
{
performGlobalAction(AccessibilityService.GLOBAL_ACTION_RECENTS);
try {
Thread.sleep(100);
} catch (InterruptedException e) {
Log.wtf(TAG,e);
}
performGlobalAction(AccessibilityService.GLOBAL_ACTION_BACK);
startActivity(GetDesiredIntent());
}

@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
if(event.getPackageName().equals("com.amazon.firelauncher")) {
performGlobalAction(AccessibilityService.GLOBAL_ACTION_RECENTS);
try {
Thread.sleep(200);
} catch (InterruptedException e) {
Log.wtf(TAG,e);
}
performGlobalAction(AccessibilityService.GLOBAL_ACTION_RECENTS);
startActivity(GetDesiredIntent());
}
if(event.getPackageName().equals("com.amazon.firelauncher"))
PerformHomePress();
}

@Override
Expand All @@ -47,14 +51,7 @@ protected void onServiceConnected() {
info.feedbackType = AccessibilityServiceInfo.FEEDBACK_GENERIC;
info.packageNames = new String[]{"com.amazon.firelauncher"};
setServiceInfo(info);
performGlobalAction(AccessibilityService.GLOBAL_ACTION_RECENTS);
try {
Thread.sleep(200);
} catch (InterruptedException e) {
Log.wtf(TAG,e);
}
performGlobalAction(AccessibilityService.GLOBAL_ACTION_RECENTS);
startActivity(GetDesiredIntent());
PerformHomePress();
}

}

0 comments on commit 51c1ed5

Please sign in to comment.