Skip to content

Commit 51c1ed5

Browse files
committed
Improved reliability and speed
1 parent 71c3b85 commit 51c1ed5

File tree

1 file changed

+15
-18
lines changed

1 file changed

+15
-18
lines changed

app/src/main/java/com/baronkiko/launcherhijack/AccServ.java

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,22 @@ public Intent GetDesiredIntent()
1818
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);
1919
}
2020

21+
private void PerformHomePress()
22+
{
23+
performGlobalAction(AccessibilityService.GLOBAL_ACTION_RECENTS);
24+
try {
25+
Thread.sleep(100);
26+
} catch (InterruptedException e) {
27+
Log.wtf(TAG,e);
28+
}
29+
performGlobalAction(AccessibilityService.GLOBAL_ACTION_BACK);
30+
startActivity(GetDesiredIntent());
31+
}
32+
2133
@Override
2234
public void onAccessibilityEvent(AccessibilityEvent event) {
23-
if(event.getPackageName().equals("com.amazon.firelauncher")) {
24-
performGlobalAction(AccessibilityService.GLOBAL_ACTION_RECENTS);
25-
try {
26-
Thread.sleep(200);
27-
} catch (InterruptedException e) {
28-
Log.wtf(TAG,e);
29-
}
30-
performGlobalAction(AccessibilityService.GLOBAL_ACTION_RECENTS);
31-
startActivity(GetDesiredIntent());
32-
}
35+
if(event.getPackageName().equals("com.amazon.firelauncher"))
36+
PerformHomePress();
3337
}
3438

3539
@Override
@@ -47,14 +51,7 @@ protected void onServiceConnected() {
4751
info.feedbackType = AccessibilityServiceInfo.FEEDBACK_GENERIC;
4852
info.packageNames = new String[]{"com.amazon.firelauncher"};
4953
setServiceInfo(info);
50-
performGlobalAction(AccessibilityService.GLOBAL_ACTION_RECENTS);
51-
try {
52-
Thread.sleep(200);
53-
} catch (InterruptedException e) {
54-
Log.wtf(TAG,e);
55-
}
56-
performGlobalAction(AccessibilityService.GLOBAL_ACTION_RECENTS);
57-
startActivity(GetDesiredIntent());
54+
PerformHomePress();
5855
}
5956

6057
}

0 commit comments

Comments
 (0)