Skip to content

Commit 9dbb1aa

Browse files
authored
新增: 1.禁用无极缩放(平板) 2.小窗-记住状态 改为 记住状态及位置 (#709)
* feat: disable infinitymode gesture for pad * feat: freeform - Remember state function adds remember location * refactor: hide "disable infinitymode gesture" switch on phone
1 parent 7daee7a commit 9dbb1aa

8 files changed

Lines changed: 279 additions & 39 deletions

File tree

app/src/main/java/com/sevtinge/hyperceiler/module/app/SystemUI/Phone/SystemUIT.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import com.sevtinge.hyperceiler.module.hook.systemui.BrightnessPct;
3232
import com.sevtinge.hyperceiler.module.hook.systemui.ChargeAnimationStyle;
3333
import com.sevtinge.hyperceiler.module.hook.systemui.DisableBottomBar;
34+
import com.sevtinge.hyperceiler.module.hook.systemui.DisableInfinitymodeGesture;
3435
import com.sevtinge.hyperceiler.module.hook.systemui.DisableMiuiMultiWinSwitch;
3536
import com.sevtinge.hyperceiler.module.hook.systemui.DisableTransparent;
3637
import com.sevtinge.hyperceiler.module.hook.systemui.MediaButton;
@@ -42,6 +43,7 @@
4243
import com.sevtinge.hyperceiler.module.hook.systemui.RemoveMiuiMultiWinSwitch;
4344
import com.sevtinge.hyperceiler.module.hook.systemui.SquigglyProgress;
4445
import com.sevtinge.hyperceiler.module.hook.systemui.StatusBarActions;
46+
import com.sevtinge.hyperceiler.module.hook.systemui.StickyFloatingWindowsForSystemUI;
4547
import com.sevtinge.hyperceiler.module.hook.systemui.UiLockApp;
4648
import com.sevtinge.hyperceiler.module.hook.systemui.UnimportantNotification;
4749
import com.sevtinge.hyperceiler.module.hook.systemui.UnlockClipboard;
@@ -183,6 +185,7 @@ public void handleLoadPackage() {
183185
initHook(StatusBarSimIcon.INSTANCE, isHideSim);
184186
initHook(HideVoWiFiIcon.INSTANCE, mPrefsMap.getBoolean("system_ui_status_bar_icon_vowifi") || mPrefsMap.getBoolean("system_ui_status_bar_icon_volte"));
185187
initHook(UseNewHD.INSTANCE, mPrefsMap.getBoolean("system_ui_status_bar_use_new_hd"));
188+
initHook(new StickyFloatingWindowsForSystemUI(), mPrefsMap.getBoolean("system_framework_freeform_sticky"));
186189

187190
// 移动网络图标
188191
boolean isEnableMobilePublic = mPrefsMap.getBoolean("system_ui_status_bar_icon_mobile_network_hide_card_1") ||
@@ -333,6 +336,7 @@ public void handleLoadPackage() {
333336
initHook(new BrightnessPct(), mPrefsMap.getBoolean("system_showpct_title"));
334337
initHook(DisableMiuiMultiWinSwitch.INSTANCE, mPrefsMap.getBoolean("system_ui_disable_miui_multi_win_switch"));
335338
initHook(RemoveMiuiMultiWinSwitch.INSTANCE, mPrefsMap.getBoolean("system_ui_remove_miui_multi_win_switch"));
339+
initHook(DisableInfinitymodeGesture.INSTANCE, mPrefsMap.getBoolean("system_ui_disable_infinitymode_gesture"));
336340
initHook(DisableBottomBar.INSTANCE, mPrefsMap.getBoolean("system_ui_disable_bottombar"));
337341
initHook(UnlockClipboard.INSTANCE, mPrefsMap.getBoolean("system_ui_unlock_clipboard"));
338342

app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemframework/StickyFloatingWindows.java

Lines changed: 74 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
/*
2-
* This file is part of HyperCeiler.
2+
* This file is part of HyperCeiler.
33
4-
* HyperCeiler is free software: you can redistribute it and/or modify
5-
* it under the terms of the GNU Affero General Public License as
6-
* published by the Free Software Foundation, either version 3 of the
7-
* License.
4+
* HyperCeiler is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU Affero General Public License as
6+
* published by the Free Software Foundation, either version 3 of the
7+
* License.
88
9-
* This program is distributed in the hope that it will be useful,
10-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12-
* GNU Affero General Public License for more details.
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU Affero General Public License for more details.
1313
14-
* You should have received a copy of the GNU Affero General Public License
15-
* along with this program. If not, see <https://www.gnu.org/licenses/>.
14+
* You should have received a copy of the GNU Affero General Public License
15+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
1616
17-
* Copyright (C) 2023-2024 HyperCeiler Contributions
18-
*/
17+
* Copyright (C) 2023-2024 HyperCeiler Contributions
18+
*/
1919
package com.sevtinge.hyperceiler.module.hook.systemframework;
2020

2121
import android.annotation.SuppressLint;
@@ -44,7 +44,6 @@ public class StickyFloatingWindows extends BaseHook {
4444

4545
@Override
4646
public void init() {
47-
4847
final List<String> fwBlackList = new ArrayList<>();
4948
fwBlackList.add("com.miui.securitycenter");
5049
fwBlackList.add("com.miui.home");
@@ -54,9 +53,16 @@ public void init() {
5453
protected void after(MethodHookParam param) {
5554
if (param.args.length != 8) return;
5655
Intent intent = (Intent) param.args[5];
56+
Object activityRecord = param.args[7];
57+
Intent recordIntent = (Intent) XposedHelpers.getObjectField(activityRecord, "intent");
58+
String recordPackageName = recordIntent.getComponent().getPackageName();
59+
String packageName = intent.getComponent().getPackageName();
60+
if (recordPackageName.equals(packageName)) {
61+
// 如果是相同应用跳转就忽略,防止出现全屏应用跳转页面之后变成小窗的情况
62+
return;
63+
}
5764
if (intent == null || intent.getComponent() == null) return;
5865
ActivityOptions options = (ActivityOptions) param.getResult();
59-
int windowingMode = options == null ? -1 : (int) XposedHelpers.callMethod(options, "getLaunchWindowingMode");
6066
String pkgName = intent.getComponent().getPackageName();
6167
if (fwBlackList.contains(pkgName)) return;
6268
Context mContext;
@@ -65,7 +71,7 @@ protected void after(MethodHookParam param) {
6571
} catch (Throwable ignore) {
6672
mContext = (Context) XposedHelpers.getObjectField(XposedHelpers.getObjectField(param.args[0], "mService"), "mContext");
6773
}
68-
if (windowingMode != 5 && fwApps.containsKey(pkgName)) {
74+
if (fwApps.containsKey(pkgName)) {
6975
try {
7076
if (MiuiMultiWindowUtils == null) {
7177
logE(TAG, StickyFloatingWindows.this.lpparam.packageName, "Cannot find MiuiMultiWindowUtils class");
@@ -76,36 +82,19 @@ protected void after(MethodHookParam param) {
7682
} catch (Throwable t) {
7783
logW(TAG, "", t);
7884
}
79-
} else if (windowingMode == 5 && !fwApps.containsKey(pkgName)) {
80-
fwApps.put(pkgName, new Pair<>(0f, null));
81-
storeFwAppsInSetting(mContext);
8285
}
8386
}
8487
});
8588

8689
hookAllMethods("com.android.server.wm.ActivityTaskSupervisor", "startActivityFromRecents", new MethodHook() {
87-
@Override
88-
protected void after(MethodHookParam param) {
89-
Object safeOptions = param.args[3];
90-
ActivityOptions options = (ActivityOptions) XposedHelpers.callMethod(safeOptions, "getOptions", param.thisObject);
91-
int windowingMode = options == null ? -1 : (int) XposedHelpers.callMethod(options, "getLaunchWindowingMode");
92-
String pkgName = getTaskPackageName(param.thisObject, (int) param.args[2], options);
93-
if (fwBlackList.contains(pkgName)) return;
94-
if (windowingMode == 5 && pkgName != null) {
95-
fwApps.put(pkgName, new Pair<>(0f, null));
96-
Context mContext = (Context) XposedHelpers.getObjectField(XposedHelpers.getObjectField(param.thisObject, "mService"), "mContext");
97-
storeFwAppsInSetting(mContext);
98-
}
99-
}
10090

10191
@Override
10292
protected void before(MethodHookParam param) {
10393
Object safeOptions = param.args[3];
10494
ActivityOptions options = (ActivityOptions) XposedHelpers.callMethod(safeOptions, "getOptions", param.thisObject);
105-
int windowingMode = options == null ? -1 : (int) XposedHelpers.callMethod(options, "getLaunchWindowingMode");
10695
String pkgName = getTaskPackageName(param.thisObject, (int) param.args[2], options);
10796
if (fwBlackList.contains(pkgName)) return;
108-
if (windowingMode != 5 && fwApps.containsKey(pkgName)) {
97+
if (fwApps.containsKey(pkgName)) {
10998
Context mContext = (Context) XposedHelpers.getObjectField(XposedHelpers.getObjectField(param.thisObject, "mService"), "mContext");
11099
options = patchActivityOptions(mContext, options, pkgName, MiuiMultiWindowUtils);
111100
XposedHelpers.setObjectField(safeOptions, "mOriginalOptions", options);
@@ -184,6 +173,47 @@ public void onReceive(Context context, Intent intent) {
184173
}
185174
}
186175
}, new IntentFilter("miui.intent.action_launch_fullscreen_from_freeform"));
176+
177+
IntentFilter mFilter = new IntentFilter();
178+
mFilter.addAction(ACTION_PREFIX + "updateFwApps");
179+
mFilter.addAction(ACTION_PREFIX + "getFwApps");
180+
mFilter.addAction(ACTION_PREFIX + "removeFwApps");
181+
mContext.registerReceiver(new BroadcastReceiver() {
182+
@Override
183+
public void onReceive(Context context, Intent intent) {
184+
String pkgName = intent.getStringExtra("package");
185+
switch (intent.getAction()) {
186+
case ACTION_PREFIX + "updateFwApps":
187+
float scale = intent.getFloatExtra("scale", 0f);
188+
Rect rect = intent.getParcelableExtra("rect");
189+
if (!fwApps.containsKey(pkgName)) {
190+
fwApps.put(pkgName, new Pair<>(scale, rect));
191+
storeFwAppsInSetting(context);
192+
return;
193+
}
194+
Pair<Float, Rect> oldPair = fwApps.get(pkgName);
195+
if (scale == 0f) {
196+
scale = oldPair.first;
197+
}
198+
if (rect == null) {
199+
rect = oldPair.second;
200+
}
201+
fwApps.put(pkgName, new Pair<>(scale, rect));
202+
storeFwAppsInSetting(context);
203+
break;
204+
case ACTION_PREFIX + "getFwApps":
205+
syncFwApps(context);
206+
break;
207+
case ACTION_PREFIX + "removeFwApps":
208+
if (pkgName != null && fwApps.remove(pkgName) != null) {
209+
storeFwAppsInSetting(context);
210+
}
211+
break;
212+
default:
213+
break;
214+
}
215+
}
216+
}, mFilter);
187217
}
188218
});
189219

@@ -228,8 +258,8 @@ public static String getTaskPackageName(Object thisObject, int taskId, boolean w
228258
Object mRootWindowContainer = XposedHelpers.getObjectField(thisObject, "mRootWindowContainer");
229259
if (mRootWindowContainer == null) return null;
230260
Object task = withOptions ?
231-
XposedHelpers.callMethod(mRootWindowContainer, "anyTaskForId", taskId, 2, options, true) :
232-
XposedHelpers.callMethod(mRootWindowContainer, "anyTaskForId", taskId, 0);
261+
XposedHelpers.callMethod(mRootWindowContainer, "anyTaskForId", taskId, 2, options, true) :
262+
XposedHelpers.callMethod(mRootWindowContainer, "anyTaskForId", taskId, 0);
233263
if (task == null) return null;
234264
Intent intent = (Intent) XposedHelpers.getObjectField(task, "intent");
235265
return intent == null ? null : intent.getComponent().getPackageName();
@@ -260,7 +290,15 @@ public static void unserializeFwApps(String data) {
260290
}
261291
}
262292

293+
public static void syncFwApps(Context context) {
294+
if (context == null) return;
295+
Intent intent = new Intent(ACTION_PREFIX + "syncFwApps");
296+
intent.putExtra("fwApps", serializeFwApps());
297+
context.sendBroadcast(intent);
298+
}
299+
263300
public static void storeFwAppsInSetting(Context context) {
301+
syncFwApps(context);
264302
Settings.Global.putString(context.getContentResolver(), ProjectApi.mAppModulePkg + ".fw.apps", serializeFwApps());
265303
}
266304

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.sevtinge.hyperceiler.module.hook.systemui
2+
3+
import com.github.kyuubiran.ezxhelper.ClassUtils.loadClass
4+
import com.github.kyuubiran.ezxhelper.HookFactory.`-Static`.createHook
5+
import com.github.kyuubiran.ezxhelper.finders.MethodFinder.`-Static`.methodFinder
6+
import com.sevtinge.hyperceiler.module.base.*
7+
8+
9+
object DisableInfinitymodeGesture : BaseHook() {
10+
override fun init() {
11+
loadClass(
12+
"com.android.wm.shell.miuifreeform.MiuiInfinityModeSizesPolicy",
13+
).methodFinder().filterByName("isForbiddenWindow").single().createHook {
14+
returnConstant(true)
15+
}
16+
}
17+
}

0 commit comments

Comments
 (0)