Skip to content
This repository has been archived by the owner on Jan 2, 2025. It is now read-only.

Commit

Permalink
新增: 系统框架-显示-强开高级材质
Browse files Browse the repository at this point in the history
  • Loading branch information
HChenX committed Apr 10, 2024
1 parent 498847b commit 3926bd6
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 6 deletions.
6 changes: 0 additions & 6 deletions app/src/main/java/com/sevtinge/hyperceiler/XposedInit.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,16 @@
import com.github.kyuubiran.ezxhelper.EzXHelper;
import com.sevtinge.hyperceiler.module.app.SystemFrameworkForCorePatch;
import com.sevtinge.hyperceiler.module.base.BaseXposedInit;
import com.sevtinge.hyperceiler.module.hook.home.other.AllowShareApk;
import com.sevtinge.hyperceiler.module.hook.home.title.EnableIconMonetColor;
import com.sevtinge.hyperceiler.module.hook.securitycenter.SidebarLineCustom;
import com.sevtinge.hyperceiler.module.hook.systemframework.AllowManageAllNotifications;
import com.sevtinge.hyperceiler.module.hook.systemframework.AllowUninstall;
import com.sevtinge.hyperceiler.module.hook.systemframework.BackgroundBlurDrawable;
import com.sevtinge.hyperceiler.module.hook.systemframework.CleanOpenMenu;
import com.sevtinge.hyperceiler.module.hook.systemframework.CleanShareMenu;
import com.sevtinge.hyperceiler.module.hook.systemframework.ScreenRotation;
import com.sevtinge.hyperceiler.module.hook.systemsettings.VolumeSeparateControlForSettings;
import com.sevtinge.hyperceiler.module.hook.tsmclient.AutoNfc;

import de.robv.android.xposed.IXposedHookInitPackageResources;
import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.IXposedHookZygoteInit;
import de.robv.android.xposed.callbacks.XC_InitPackageResources;
import de.robv.android.xposed.callbacks.XC_LoadPackage;

public class XposedInit extends BaseXposedInit implements IXposedHookZygoteInit, IXposedHookLoadPackage {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.sevtinge.hyperceiler.module.hook.systemframework.AllowUntrustedTouch;
import com.sevtinge.hyperceiler.module.hook.systemframework.AllowUntrustedTouchForU;
import com.sevtinge.hyperceiler.module.hook.systemframework.AppLinkVerify;
import com.sevtinge.hyperceiler.module.hook.systemframework.BackgroundBlur;
import com.sevtinge.hyperceiler.module.hook.systemframework.CleanOpenMenu;
import com.sevtinge.hyperceiler.module.hook.systemframework.CleanShareMenu;
import com.sevtinge.hyperceiler.module.hook.systemframework.ClipboardWhitelist;
Expand Down Expand Up @@ -125,6 +126,7 @@ public void handleLoadPackage() {
initHook(new ClipboardWhitelist(), mPrefsMap.getBoolean("system_framework_clipboard_whitelist"));

// 显示
initHook(new BackgroundBlur(), mPrefsMap.getBoolean("system_framework_background_blur_supported"));
initHook(DisplayCutout.INSTANCE, mPrefsMap.getBoolean("system_ui_display_hide_cutout_enable"));
initHook(UseAOSPScreenShot.INSTANCE, mPrefsMap.getBoolean("system_ui_display_use_aosp_screenshot_enable"));
initHook(new ToastTime(), mPrefsMap.getBoolean("system_ui_display_toast_times_enable"));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
package com.sevtinge.hyperceiler.module.hook.systemframework;

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

import java.lang.reflect.Method;

import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.XposedHelpers;

public class BackgroundBlur extends BaseHook {
private final static String TAG = "MYBackgroundBlur";
private final static String mode = "persist.sys.background_blur_mode";
private final static String supported = "persist.sys.background_blur_supported";
private final static String version = "persist.sys.background_blur_version";
private Class<?> SystemProperties = null;
private boolean done = false;

@Override
public void init() throws NoSuchMethodException {
SystemProperties = findClassIfExists("android.os.SystemProperties");
if (SystemProperties == null) return;
Method[] methods = SystemProperties.getDeclaredMethods();
for (Method method : methods) {
switch (method.getName()) {
case "get", "getInt", "getBoolean" -> {
hookProp(method);
}
}
}
}

XC_MethodHook xcMethodHook = new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) {
if (done) return;
Object def = null;
Object result = param.getResult();
String key = (String) param.args[0];
if (param.args.length > 1) {
def = param.args[1];
}
Object get = isBlurProp(key);
// logE(TAG, "key: " + key + " def: " + def + " result: " + result + " get: " + get);
if (get != null) {
if ("get".equals(param.method.getName())) {
param.setResult(String.valueOf(get));
} else param.setResult(get);
}
if (supported.equals(key)) {
try {
XposedHelpers.callStaticMethod(SystemProperties, "set", supported, String.valueOf(true));
XposedHelpers.callStaticMethod(SystemProperties, "set", mode, String.valueOf(0));
XposedHelpers.callStaticMethod(SystemProperties, "set", version, String.valueOf(2));
done = true;
// logE(TAG, "key: " + key + " set: " + String.valueOf(get));
} catch (Throwable e) {
done = false;
// logE(TAG, "key: " + key + " e: " + e);
}
}
}
};

private void hookProp(Method method) {
XposedBridge.hookMethod(method, xcMethodHook);
}

private Object isBlurProp(String key) {
switch (key) {
case supported -> {
return true;
}
case mode -> {
return 0;
}
case version -> {
return 2;
}
// case "persist.sys.background_blur_status_default" -> {
// return false;
// }
default -> {
return null;
}
}
}
}
2 changes: 2 additions & 0 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,8 @@
<string name="system_framework_disable_72h_verify">禁用每 72 小时验证锁屏密码</string>
<string name="system_framework_disable_verify_can_ve_disabled">禁用是否允许禁用 APP 校验</string>
<string name="system_framework_allow_all_dark_mode">允许所有 APP 使用深色模式</string>
<string name="system_framework_background_blur_supported">强开高级材质</string>
<string name="system_framework_background_blur_supported_more">开启此功能后请在系统设置中控制高级材质开关</string>
<string name="system_framework_disablt_miuilite_check">禁用 MIUI Lite 检查</string>
<string name="system_framework_allow_manage_all_notifications">允许管理所有通知</string>
<string name="system_framework_quick_screenshot">秒截图</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,8 @@
<string name="system_framework_disable_72h_verify">Disable lock screen verify when per 72 hours</string>
<string name="system_framework_disable_verify_can_ve_disabled">Disable to verify can be disabled</string>
<string name="system_framework_allow_all_dark_mode">Allow all apps to use dark mode</string>
<string name="system_framework_background_blur_supported">Strong open high-grade material</string>
<string name="system_framework_background_blur_supported_more">When this feature is turned on, control the Advanced Materials switch in the system settings</string>
<string name="system_framework_disablt_miuilite_check">Disable MIUI Lite Check</string>
<string name="system_framework_allow_manage_all_notifications">Allow to manage all notifications</string>
<string name="system_framework_quick_screenshot">Quick screenshot</string>
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/xml/framework_display.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
app:myLocation="@string/system_framework_display_title">
<PreferenceCategory>
<SwitchPreference
android:defaultValue="false"
android:title="@string/system_framework_background_blur_supported"
android:key="prefs_key_system_framework_background_blur_supported"
android:summary="@string/system_framework_background_blur_supported_more" />

<SwitchPreference
android:defaultValue="false"
android:title="@string/system_framework_allow_all_dark_mode"
Expand Down

0 comments on commit 3926bd6

Please sign in to comment.