Skip to content

Commit

Permalink
HomeButtonService fleshed out
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy Adshead authored and Andy Adshead committed Jul 26, 2017
1 parent 2970927 commit 2dec194
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
3 changes: 2 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.baronkiko.launcherhijack">
<uses-permission android:name="android.permission.BIND_ACCESSIBILITY_SERVICE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"></uses-permission>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>

<application
android:allowBackup="true"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
package com.baronkiko.launcherhijack;

import android.app.PendingIntent;
import android.app.Service;
import android.content.Intent;
import android.graphics.PixelFormat;
import android.os.IBinder;
import android.util.Log;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.WindowManager;
import android.widget.LinearLayout;

public class HomeButtonService extends Service {
private LinearLayout layout;
private WindowManager wm;

@Override
public IBinder onBind(Intent intent) {
Expand All @@ -15,7 +23,33 @@ public IBinder onBind(Intent intent) {
@Override
public void onCreate() {
super.onCreate();
Log.d("A", "X");

layout = new LinearLayout(getApplicationContext()) {
//home or recent button
public void onCloseSystemDialogs(String reason) {
if (reason.contains("homekey"))
HomePress.Perform(getApplicationContext());
}

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
return false;
}
};

layout.setFocusable(false);

wm = (WindowManager) getSystemService(WINDOW_SERVICE);
WindowManager.LayoutParams params = new WindowManager.LayoutParams(
0,
0,
WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
| WindowManager.LayoutParams.FLAG_FULLSCREEN
| WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN,
PixelFormat.TRANSLUCENT);
params.gravity = Gravity.LEFT | Gravity.CENTER_VERTICAL;
wm.addView(layout, params);
}

@Override
Expand All @@ -28,6 +62,9 @@ public int onStartCommand(Intent intent, int flags, int startId) {
public void onDestroy() {
super.onDestroy();
Log.i("EXIT", "ondestroy!");

wm.removeView(layout);;

ServiceMan.Stop(getApplicationContext());
ServiceMan.StartSlow(getApplicationContext());
}
Expand Down

0 comments on commit 2dec194

Please sign in to comment.