Skip to content

Commit

Permalink
Revert "test2"
Browse files Browse the repository at this point in the history
This reverts commit 0491664.
  • Loading branch information
parrotgeek1 committed Jul 4, 2016
1 parent aa2be1c commit 9707cd6
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 29 deletions.
Binary file modified app/app-release.apk
Binary file not shown.
10 changes: 10 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.parrotgeek.launcherhijack">
<uses-permission android:name="android.permission.BIND_ACCESSIBILITY_SERVICE" />

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
Expand All @@ -10,8 +12,16 @@
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name=".AccServ"
android:label="To detect home button press"
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE">
<intent-filter>
<action android:name="android.accessibilityservice.AccessibilityService" />
</intent-filter>
</service>
</application>
</manifest>
47 changes: 47 additions & 0 deletions app/src/main/java/com/parrotgeek/launcherhijack/AccServ.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.parrotgeek.launcherhijack;

import android.accessibilityservice.AccessibilityService;
import android.accessibilityservice.AccessibilityServiceInfo;
import android.content.Intent;
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);

@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(intent);

}
}

@Override
public void onInterrupt() {
Log.v(TAG, "onInterrupt");
}

@Override
protected void onServiceConnected() {
super.onServiceConnected();
Log.v(TAG, "onServiceConnected");
AccessibilityServiceInfo info = new AccessibilityServiceInfo();
info.flags = AccessibilityServiceInfo.DEFAULT;
info.eventTypes = AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED;
info.feedbackType = AccessibilityServiceInfo.FEEDBACK_GENERIC;
info.packageNames = new String[]{"com.amazon.firelauncher"};
setServiceInfo(info);
}

}
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package com.parrotgeek.launcherhijack;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;

public class MainActivity extends AppCompatActivity {

Expand All @@ -12,10 +10,4 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}

private void chooser(View view){
Intent choose = new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME).setClassName("android","com.android.internal.app.ResolverActivity");
startActivity(choose);
}

}
22 changes: 1 addition & 21 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,5 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView"
android:text="Tap the button to force reset the default launcher. (You will need to pick the launcher a second time when you press Home due to a Fire OS bug.)"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Clear Default Launcher"
android:id="@+id/button"
android:layout_below="@+id/textView"
android:layout_centerHorizontal="true"
android:onClick="chooser" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="by parrotgeek1 on XDA"
android:id="@+id/textView2"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
android:text="Hello World!" />
</RelativeLayout>

0 comments on commit 9707cd6

Please sign in to comment.