Skip to content

Commit

Permalink
Intent wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyAdshead committed Feb 21, 2017
1 parent 3bf8b09 commit df77d13
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions app/src/main/java/com/baronkiko/launcherhijack/AccServ.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,22 @@
import android.accessibilityservice.AccessibilityService;
import android.accessibilityservice.AccessibilityServiceInfo;
import android.content.Intent;
import android.content.SharedPreferences;
import android.util.Log;
import android.view.accessibility.AccessibilityEvent;

public class AccServ extends AccessibilityService {

static final String TAG = "AccServ";

Intent intent = new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME).setPackage("com.teslacoilsw.launcher").addFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS|Intent.FLAG_ACTIVITY_CLEAR_TOP|Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
public Intent GetIntent()
{
SharedPreferences settings = getSharedPreferences("LauncherHijack", 0);
String s = settings.getString("ChosenLauncher", null);
if (s == null)
s = "com.teslacoilsw.launcher";
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);
}

@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
Expand All @@ -22,7 +30,7 @@ public void onAccessibilityEvent(AccessibilityEvent event) {
Log.wtf(TAG,e);
}
performGlobalAction(AccessibilityService.GLOBAL_ACTION_RECENTS);
startActivity(intent);
startActivity(GetIntent());

}
}
Expand All @@ -49,7 +57,7 @@ protected void onServiceConnected() {
Log.wtf(TAG,e);
}
performGlobalAction(AccessibilityService.GLOBAL_ACTION_RECENTS);
startActivity(intent);
startActivity(GetIntent());
}

}

0 comments on commit df77d13

Please sign in to comment.