Skip to content

Commit

Permalink
摸个提交
Browse files Browse the repository at this point in the history
  • Loading branch information
HChenX committed Jan 23, 2024
1 parent f7441b7 commit ec2bfb7
Show file tree
Hide file tree
Showing 5 changed files with 135 additions and 87 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
package com.sevtinge.hyperceiler.module.hook.home.gesture;

import android.app.AndroidAppHelper;
import android.content.Context;
import android.os.Bundle;
import android.view.MotionEvent;

import com.sevtinge.hyperceiler.module.app.GlobalActions;
import com.sevtinge.hyperceiler.module.base.BaseHook;

import de.robv.android.xposed.XposedHelpers;

public class CornerSlide extends BaseHook {
public int inDirection = 0;

Context mContext;

@Override
public void init() throws NoSuchMethodException {
findAndHookMethod("com.android.systemui.shared.recents.system.AssistManager",
"isSupportGoogleAssist", int.class,
MethodHook.returnConstant(true));
Class<?> FsGestureAssistHelper = findClassIfExists("com.miui.home.recents.FsGestureAssistHelper");
findAndHookMethod(FsGestureAssistHelper, "canTriggerAssistantAction",
float.class, float.class, int.class,
new MethodHook() {
@Override
protected void before(MethodHookParam param) {
boolean isDisabled = (boolean) XposedHelpers.callStaticMethod(FsGestureAssistHelper,
"isAssistantGestureDisabled", param.args[2]);
if (!isDisabled) {
int mAssistantWidth = (int) XposedHelpers.getObjectField(param.thisObject, "mAssistantWidth");
float f = (float) param.args[0];
float f2 = (float) param.args[1];
if (f < mAssistantWidth || f > f2 - mAssistantWidth) {
param.setResult(true);
return;
}
}
param.setResult(false);
}
}
);

// final int[] inDirection = {0};
hookAllMethods(FsGestureAssistHelper,
"handleTouchEvent", new MethodHook() {
@Override
protected void after(MethodHookParam param) {
MotionEvent motionEvent = (MotionEvent) param.args[0];
if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
float mDownX = XposedHelpers.getFloatField(param.thisObject, "mDownX");
int mAssistantWidth = XposedHelpers.getIntField(param.thisObject, "mAssistantWidth");
inDirection = mDownX < mAssistantWidth ? 0 : 1;
}
}
}
);

findAndHookConstructor("com.miui.home.recents.NavStubView",
Context.class, new MethodHook() {
@Override
protected void after(MethodHookParam param) {
mContext = (Context) param.args[0];
}
}
);

findAndHookMethod("com.miui.home.recents.SystemUiProxyWrapper",
"startAssistant", Bundle.class,
new MethodHook() {
@Override
protected void before(MethodHookParam param) {
Bundle bundle = (Bundle) param.args[0];
if (bundle.getInt("triggered_by", 0) != 83 || bundle.getInt("invocation_type", 0) != 1) {
return;
}
String direction = inDirection == 1 ? "right" : "left";
GlobalActions.handleAction(
AndroidAppHelper.currentApplication(),
"prefs_key_home_navigation_assist_" + direction + "_slide"
);
/*logE(TAG, "bundle: " + bundle+" rig: "+direction);
if (mPrefsMap.getInt("home_navigation_assist_" + direction + "_slide_action", 0) == 10) {
ActivityManager.RunningTaskInfo runningTaskInfo = (ActivityManager.RunningTaskInfo) XposedHelpers.callMethod(
XposedHelpers.callStaticMethod(findClassIfExists("com.miui.home.recents.RecentsModel"), "getInstance",
mContext), "getRunningTaskContainHome");
LockApp.needLockApp(mContext, runningTaskInfo, lpparam);
} else {
}*/
}
}
);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,27 @@
import android.app.Application;
import android.content.Context;

import androidx.annotation.IntDef;

import com.sevtinge.hyperceiler.utils.log.AndroidLogUtils;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.reflect.Method;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

@SuppressLint({"PrivateApi", "SoonBlockedPrivateApi", "DiscouragedPrivateApi"})
public class ContextUtils {
@IntDef(value = {
FLAG_ALL,
FLAG_CURRENT_APP,
FlAG_ONLY_ANDROID
})
@Retention(RetentionPolicy.SOURCE)
public @interface Duration {
}

private static final String TAG = "[HyperCeiler]";
// 尝试全部
public static final int FLAG_ALL = 0;
Expand All @@ -20,7 +33,7 @@ public class ContextUtils {
// 获取 Android 系统
public static final int FlAG_ONLY_ANDROID = 2;

public static Context getContext(int flag) {
public static Context getContext(@Duration int flag) {
try {
return invokeMethod(flag);
} catch (Throwable e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public static synchronized Resources getModuleRes(Context context) throws Throwa
return (config == null ? moduleContext.getResources() : moduleContext.createConfigurationContext(config).getResources());
}

public static Context findContext(int flag) {
public static Context findContext(@ContextUtils.Duration int flag) {
Context context = null;
try {
switch (flag) {
Expand Down
46 changes: 23 additions & 23 deletions app/src/main/res/xml/home_multi_action.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,55 +6,55 @@
<moralnorm.preference.RadioButtonPreferenceCategory>

<moralnorm.preference.RadioButtonPreference
android:persistent="false"
android:key="prefs_key_no_action"
android:title="@string/array_global_actions_none"
android:layout="@layout/preference_radiobutton_two_state" />
android:layout="@layout/preference_radiobutton_two_state"
android:persistent="false"
android:title="@string/array_global_actions_none" />

<moralnorm.preference.RadioButtonPreference
android:key="prefs_key_open_notification_center"
android:title="@string/array_global_actions_notif"
android:layout="@layout/preference_radiobutton_two_state" />
android:layout="@layout/preference_radiobutton_two_state"
android:title="@string/array_global_actions_notif" />

<moralnorm.preference.RadioButtonPreference
android:key="prefs_key_screen_lock"
android:title="@string/array_global_actions_lock"
android:layout="@layout/preference_radiobutton_two_state" />
android:layout="@layout/preference_radiobutton_two_state"
android:title="@string/array_global_actions_lock" />

<moralnorm.preference.RadioButtonPreference
android:key="prefs_key_screen_sleep"
android:title="@string/array_global_actions_sleep"
android:layout="@layout/preference_radiobutton_two_state" />
android:layout="@layout/preference_radiobutton_two_state"
android:title="@string/array_global_actions_sleep" />

<moralnorm.preference.RadioButtonPreference
android:key="prefs_key_screen_capture"
android:title="@string/array_global_actions_screenshot"
android:layout="@layout/preference_radiobutton_two_state" />
android:layout="@layout/preference_radiobutton_two_state"
android:title="@string/array_global_actions_screenshot" />

<moralnorm.preference.RadioButtonPreference
android:key="prefs_key_clear_memory"
android:title="@string/array_global_actions_clear_memory"
android:layout="@layout/preference_radiobutton_two_state" />
android:layout="@layout/preference_radiobutton_two_state"
android:title="@string/array_global_actions_clear_memory" />

<moralnorm.preference.RadioButtonPreference
android:key="prefs_key_invert_colors"
android:title="@string/array_global_actions_invert_colors"
android:layout="@layout/preference_radiobutton_two_state" />
android:layout="@layout/preference_radiobutton_two_state"
android:title="@string/array_global_actions_invert_colors" />

<moralnorm.preference.RadioButtonPreference
android:key="prefs_key_screen_recents"
android:title="@string/array_global_actions_recents"
android:layout="@layout/preference_radiobutton_two_state" />
android:layout="@layout/preference_radiobutton_two_state"
android:title="@string/array_global_actions_recents" />

<moralnorm.preference.RadioButtonPreference
android:key="prefs_key_volume_dialog"
android:title="@string/array_global_actions_volume"
android:layout="@layout/preference_radiobutton_two_state" />
android:layout="@layout/preference_radiobutton_two_state"
android:title="@string/array_global_actions_volume" />

<moralnorm.preference.RadioButtonPreference
android:key="prefs_key_open_powermenu"
android:title="@string/array_global_actions_powermenu"
android:layout="@layout/preference_radiobutton_two_state" />
android:layout="@layout/preference_radiobutton_two_state"
android:title="@string/array_global_actions_powermenu" />

<moralnorm.preference.RadioSetPreferenceCategory>

Expand All @@ -63,9 +63,9 @@
android:title="@string/array_global_actions_launch" />

<Preference
android:dependency="prefs_key_open_app"
android:key="prefs_key_open_app_selector"
android:title="@string/array_global_actions_launch_choose"
android:dependency="prefs_key_open_app" />
android:title="@string/array_global_actions_launch_choose" />

</moralnorm.preference.RadioSetPreferenceCategory>

Expand Down

0 comments on commit ec2bfb7

Please sign in to comment.