Skip to content

Commit

Permalink
修复: 隐藏手势提示线部分场景异常的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
HChenX committed Jun 11, 2024
1 parent d81a239 commit 0af75f1
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 115 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,81 +18,64 @@
*/
package com.sevtinge.hyperceiler.module.hook.home.navigation;

import android.content.res.Configuration;
import android.provider.Settings;
import android.view.MotionEvent;
import android.view.View;

import com.sevtinge.hyperceiler.module.base.BaseHook;
import com.hchen.hooktool.callback.IAction;
import com.hchen.hooktool.tool.ParamTool;
import com.sevtinge.hyperceiler.module.base.BaseTool;

import de.robv.android.xposed.XposedHelpers;

public class HideNavigationBar extends BaseHook {
public class HideNavigationBar extends BaseTool {
@Override
public void init() {
/*横屏隐藏*/
findAndHookMethod("com.miui.home.recents.views.RecentsContainer",
"showLandscapeOverviewGestureView",
boolean.class,
new MethodHook() {
public void doHook() {
hcHook.findClass("rc", "com.miui.home.recents.views.RecentsContainer")
.getMethod("showLandscapeOverviewGestureView", boolean.class)
.hook(new IAction() {
@Override
protected void before(MethodHookParam param) {
param.args[0] = false;
public void before(ParamTool param) {
param.first(false);
}
}
);
});

/*锁定返回*/
findAndHookMethod("com.miui.home.recents.NavStubView",
"isMistakeTouch",
new MethodHook() {
hcHook.findClass("nsv", "com.miui.home.recents.NavStubView")
.getMethod("isMistakeTouch")
.hook(new IAction() {
@Override
protected void before(MethodHookParam param) {
// boolean mIsShowStatusBar = (boolean) XposedHelpers.callMethod(param.thisObject, "isImmersive");
/*boolean mIsShowNavBar = XposedHelpers.getBooleanField(param.thisObject, "mIsShowNavBar");
boolean mHideGestureLine = XposedHelpers.getBooleanField(param.thisObject, "mHideGestureLine");
boolean mIsShowStatusBar = XposedHelpers.getBooleanField(param.thisObject, "mIsShowStatusBar");
logE(TAG, "mIsShowNavBar: " + mIsShowNavBar);
logE(TAG, "mHideGestureLine: " + mHideGestureLine);
logE(TAG, "mIsShowStatusBar: " + mIsShowStatusBar);*/
// 按道理仅横屏时显示也是可以的,不知道为什么小米要判断这么多。
View navView = (View) param.thisObject;
public void before(ParamTool param) {
View navView = param.thisObject();
boolean setting = Settings.Global.getInt(navView.getContext().getContentResolver(), "show_mistake_touch_toast", 1) == 1;
boolean misTouch = (boolean) XposedHelpers.callMethod(param.thisObject, "isLandScapeActually");
boolean misTouch = param.callMethod("isLandScapeActually");
param.setResult(misTouch && setting);
}
}
);

/*横屏设置状态*/
findAndHookMethod("com.miui.home.recents.NavStubView", "onPointerEvent",
MotionEvent.class,
new MethodHook() {
})
.getMethod("onPointerEvent", MotionEvent.class)
.hook(new IAction() {
@Override
protected void before(MethodHookParam param) {
boolean mIsInFsMode = XposedHelpers.getBooleanField(param.thisObject, "mIsInFsMode");
MotionEvent motionEvent = (MotionEvent) param.args[0];
public void before(ParamTool param) {
boolean mIsInFsMode = param.getField("mIsInFsMode");
MotionEvent motionEvent = param.first();
if (!mIsInFsMode) {
if (motionEvent.getAction() == 0) {
XposedHelpers.setObjectField(param.thisObject, "mHideGestureLine", true);
// XposedHelpers.setObjectField(param.thisObject, "mIsShowNavBar", true);
// XposedHelpers.setObjectField(param.thisObject, "mIsShowStatusBar", true);
param.setField("mHideGestureLine", true);
}
}
}
}
);

/*恢复状态*/
findAndHookMethod("com.miui.home.recents.NavStubView", "updateScreenSize",
new MethodHook() {
})
.getMethod("updateScreenSize")
.hook(new IAction() {
@Override
protected void before(MethodHookParam param) {
XposedHelpers.setObjectField(param.thisObject, "mHideGestureLine", false);
// XposedHelpers.setObjectField(param.thisObject, "mIsShowNavBar", true);
// XposedHelpers.setObjectField(param.thisObject, "mIsShowStatusBar", true);
public void before(ParamTool param) {
param.setField("mHideGestureLine", false);
}
}
);

})
.getMethod("onConfigurationChanged", Configuration.class)
.hook(new IAction() {
@Override
public void before(ParamTool param) {
param.setField("mHideGestureLine", false);
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,49 +28,26 @@

import androidx.annotation.Nullable;

import com.hchen.hooktool.callback.IAction;
import com.hchen.hooktool.tool.ParamTool;
import com.sevtinge.hyperceiler.R;
import com.sevtinge.hyperceiler.module.base.BaseHook;
import com.sevtinge.hyperceiler.module.base.BaseTool;

import de.robv.android.xposed.XposedHelpers;

public class HideNavigationBar extends BaseHook {
public class HideNavigationBar extends BaseTool {
boolean run = false;

@Override
public void init() {
/*启用隐藏 旧实现*/
/*if (isAndroidVersion(34)) {
hookAllConstructors("com.android.systemui.statusbar.phone.NavigationModeControllerExt", new MethodHook() {
@Override
protected void after(MethodHookParam param) throws Throwable {
super.after(param);
XposedHelpers.setStaticBooleanField(findClassIfExists("com.android.systemui.statusbar.phone.NavigationModeControllerExt"),
"mHideGestureLine", true);
}
});
} else {
findAndHookMethod("com.android.systemui.statusbar.phone.NavigationModeControllerExt",
"hideNavigationBar",
new MethodHook() {
@Override
protected void after(MethodHookParam param) {
// param.setResult(true);
}
}
);
}*/

// 不隐藏时创建手势条
hookAllMethods("com.android.systemui.navigationbar.NavigationBarController",
"createNavigationBar",
new MethodHook() {
public void doHook() {
hcHook.findClass("nbc", "com.android.systemui.navigationbar.NavigationBarController")
.getAnyMethod("createNavigationBar")
.hook(new IAction() {
@Override
protected void after(MethodHookParam param) {
if (param.args.length >= 3) {
Display display = (Display) param.args[0];
public void after(ParamTool param) {
if (param.size() >= 3) {
Display display = param.first();
int id = display.getDisplayId();
XposedHelpers.callMethod(param.thisObject, "removeNavigationBar", id);
Context mContext = (Context) XposedHelpers.getObjectField(param.thisObject, "mContext");
param.callMethod("removeNavigationBar", id);
Context mContext = param.getField("mContext");
ContentObserver(mContext);
try {
int state = Settings.Global.getInt(mContext.getContentResolver(), "hide_gesture_line");
Expand All @@ -82,35 +59,21 @@ protected void after(MethodHookParam param) {
}
}
}

}
);

/*findAndHookMethod("com.android.systemui.navigationbar.NavigationBar", "onInit",
new MethodHook() {
@Override
protected void after(MethodHookParam param) {
// XposedHelpers.callMethod(param.thisObject, "destroyView");
}
}
);*/

/*状态更改设置*/
findAndHookMethod("com.android.systemui.statusbar.phone.MiuiDockIndicatorService",
"onNavigationModeChanged", int.class,
new MethodHook() {
})
.findClass("mdis", "com.android.systemui.statusbar.phone.MiuiDockIndicatorService")
.getMethod("onNavigationModeChanged", int.class)
.hook(new IAction() {
@Override
protected void before(MethodHookParam param) {
XposedHelpers.setObjectField(param.thisObject, "mNavMode", param.args[0]);
if (XposedHelpers.getObjectField(param.thisObject, "mNavigationBarView") != null) {
XposedHelpers.callMethod(param.thisObject, "setNavigationBarView", (Object) null);
public void before(ParamTool param) {
param.setField("mNavMode", param.first());
if (param.getField("mNavigationBarView") != null) {
param.callMethod("setNavigationBarView", null);
} else {
XposedHelpers.callMethod(param.thisObject, "checkAndApplyNavigationMode");
param.callMethod("checkAndApplyNavigationMode");
}
param.setResult(null);
}
}
);
});
}

/*防呆专用*/
Expand All @@ -120,6 +83,7 @@ public void ContentObserver(Context context) {
ContentObserver contentObserver = new ContentObserver(new Handler(context.getMainLooper())) {
@Override
public void onChange(boolean selfChange, @Nullable Uri uri) {
if (selfChange) return;
if (Settings.Global.getUriFor("hide_gesture_line").toString().equals(uri.toString())) {
Settings.Global.putInt(context.getContentResolver(), "hide_gesture_line", 0);
Toast.makeText(context, R.string.system_ui_hide_navigation_bar_toast_2, Toast.LENGTH_SHORT).show();
Expand Down

0 comments on commit 0af75f1

Please sign in to comment.