This repository has been archived by the owner on Jan 2, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
100 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemframework/BackgroundBlur.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters