[HTC 10 Themes, Apps, and Mods] Sivat:
Hey everyone. I got sick of not having double tap to wake enabled when using the asop lockscreen and created this xposed module to fix that and change all of the other functions to control media.

After you install double check the motion launch settings are on by going into settings -> Display, gestures & buttons -> Motion Launch gestures.

Swiping up will pull google play music up (I use this in conjunction with quick access which lets it draw over the lock screen)

Swiping Down is play/pause music

Swiping Right is next

Swiping left is previous

Double tap is wake device

I was originally going to try and do more with this, but I'm gonna shift focus to modifying the kernel to see if it's possible to add even more custom gestures. However if you run into any issues let me know and I'll try to figure out what's going on.

Here's the source code, do what you want:

import android.content.Context;
import android.content.Intent;
import android.os.PowerManager;
import android.view.KeyEvent;
import java.lang.Object;
import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.XposedHelpers;
import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam;
import de.robv.android.xposed.XC_MethodReplacement;

public class XposedMod implements IXposedHookLoadPackage {
Context context;
XC_MethodHook.MethodHookParam temp;
@Override
public void handleLoadPackage(LoadPackageParam lpparam) throws Throwable {
if (!lpparam.packageName.equals("com.htc.sense.easyaccessservice"))
return;
Class<?> EasyAction =
XposedHelpers.findClass("com.htc.sense.easyaccessservice.easy.sense81.EasySensorAction81", lpparam.classLoader);

XposedHelpers.findAndHookMethod(EasyAction, "triggerMotionAction", int.class, new XC_MethodReplacement() {
@Override
protected Object replaceHookedMethod(MethodHookParam param) throws Throwable {
XposedBridge.log("BEFORE EXECUTE!");
temp = param;
context = (Context) XposedHelpers.getObjectField(param.thisObject, "mContext");
int gesture = (Integer) param.args[0];
XposedBridge.log(String.format("%1$d",gesture));
performAction(gesture, context);
param.setResult(null);
return null;
}
});
}
private void performAction(int action, Context context) {
switch(action){
case GestureType.SWIPE_LEFT:
sendMediaButton(context, KeyEvent.KEYCODE_MEDIA_PREVIOUS);
XposedHelpers.callMethod(temp.thisObject, "doOnResetAction");
XposedBridge.log("LEFT");
break;
case GestureType.SWIPE_RIGHT:
sendMediaButton(context, KeyEvent.KEYCODE_MEDIA_NEXT);
XposedHelpers.callMethod(temp.thisObject, "doOnResetAction");
XposedBridge.log("RIGHT");
break;
case GestureType.CAMERA_ACTION:
sendMediaButton(context, KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE);
XposedHelpers.callMethod(temp.thisObject, "doOnResetAction");
break;
case GestureType.SWIPE_UP:
Context ctx=context;
try {
Intent i = ctx.getPackageManager().getLaunchIntentForPackage("com.google.android.music");
ctx.startActivity(i);
} catch (Exception e) {
XposedBridge.log(e);
}
wakeUpDevice();
break;
case GestureType.DOUBLE_TAP_ACTION:
wakeUpDevice();
break;
default: break;
}
}
private void wakeUpDevice() {
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
PowerManager.WakeLock wakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP
| PowerManager.ON_AFTER_RELEASE, "MyWakeLock");
wakeLock.acquire();
wakeLock.release();
XposedBridge.log("WTFISGOINGON");
}

private void sendMediaButton(Context context, int keyCode) {
KeyEvent keyEvent = new KeyEvent(KeyEvent.ACTION_DOWN, keyCode);
Intent intent = new Intent(Intent.ACTION_MEDIA_BUTTON);
intent.putExtra(Intent.EXTRA_KEY_EVENT, keyEvent);
context.sendOrderedBroadcast(intent, null);
keyEvent = new KeyEvent(KeyEvent.ACTION_UP, keyCode);
intent = new Intent(Intent.ACTION_MEDIA_BUTTON);
intent.putExtra(Intent.EXTRA_KEY_EVENT, keyEvent);
context.sendOrderedBroadcast(intent, null);
}

public class GestureType {
public static final int SWIPE_LEFT = 3;
public static final int SWIPE_RIGHT = 2;
public static final int SWIPE_UP = 1;
public static final int CAMERA_ACTION = 6;
public static final int DOUBLE_TAP_ACTION = 5;
}
}