Skip to content

Commit

Permalink
fix fix fix
Browse files Browse the repository at this point in the history
  • Loading branch information
AsyJAIZ committed Mar 19, 2023
1 parent 6c95cef commit 0de84c6
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 20 deletions.
15 changes: 4 additions & 11 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,30 @@ plugins {
}

android {
signingConfigs {
release {
storeFile file('C:\\Users\\2007a\\OneDrive\\Рабочий стол\\lsposed.jks')
storePassword 'LSPosed'
keyAlias 'LSPosed'
keyPassword 'LSPosed'
}
}
compileSdk 31

defaultConfig {
applicationId "com.asyjaiz.A12blur"
minSdk 31
targetSdk 31
versionCode 2
versionName "1.2N"
versionCode 4
versionName "1.31N"

archivesBaseName = "NST"
//testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
namespace 'com.asyjaiz.A12blur'
}

dependencies {
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.asyjaiz.A12blur">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<application
android:label="@string/app_name">
Expand Down
70 changes: 65 additions & 5 deletions app/src/main/java/com/asyjaiz/A12blur/Replace.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public class Replace implements IXposedHookLoadPackage, IXposedHookInitPackageRe
boolean lowRam;
boolean disableBlur;

Object[] parameterTypesAndCallback;

public static Boolean read(String propName) {
Process process = null;
BufferedReader bufferedReader = null;
Expand All @@ -35,9 +37,13 @@ public static Boolean read(String propName) {
process = new ProcessBuilder().command("/system/bin/getprop", propName).start();
bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line = bufferedReader.readLine();
return line.contains("true") || line.contains("1");
boolean contains = line.contains("true") || line.contains("1");
if (BuildConfig.DEBUG) XposedBridge.log("Check for " + propName + " returned " +
line +
(contains ? " and contains a success value" : " and doesn't contain a success value"));
return contains;
} catch (Exception e) {
XposedBridge.log(e);
XposedBridge.log("Something went wrong: " + e + "\nMake a new issue on a Github page.");
return false;
} finally {
if (bufferedReader != null){
Expand All @@ -51,6 +57,41 @@ public static Boolean read(String propName) {
}
}

/* public static Boolean lowPower() {
Process process = null;
BufferedReader bufferedReader = null;
try {
process = new ProcessBuilder().command("/system/bin/settings", "get global low_power").start();
bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line = bufferedReader.readLine();
XposedBridge.log("Power Saving Mode check returned " + line);
return line.contains("true") || line.contains("1");
} catch (Exception e) {
XposedBridge.log("Power Saving Mode check returned an exception. Returning fail by default");
return false;
} finally {
if (bufferedReader != null){
try {
bufferedReader.close();
} catch (IOException ignored) {}
}
if (process != null){
process.destroy();
}
}
} */

/* public static float alpha(boolean capable) {
float defaultA = 0.85f;
float supportedA = 0.54f;
if (capable) {
if (false)
return defaultA;
else return supportedA;
} else return defaultA;
} */

@Override
public void handleInitPackageResources(XC_InitPackageResources.InitPackageResourcesParam resParam) throws Throwable {
XModuleResources modRes = XModuleResources.createInstance(rootPackagePath, null);
Expand All @@ -62,13 +103,20 @@ public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpParam) throws Th
if (!lpParam.packageName.equals(rootPackage))
return;

if (BuildConfig.DEBUG) {
XposedBridge.log("Debug and diagnostics.");
}

rootPackagePath = lpParam.appInfo.sourceDir;

supportsBlur = read("ro.surface_flinger.supports_background_blur");
avoidAccel2 = read("ro.config.avoid_gfx_accel");
lowRam = read("ro.config.low_ram");
disableBlur = read("persist.sysui.disableBlur");
boolean capable = supportsBlur && !avoidAccel1 && !avoidAccel2 && !lowRam && !disableBlur;
if (BuildConfig.DEBUG) XposedBridge.log(capable ?
"Your device is capable of handling blur. Using a corresponding alpha value" :
"Your device is not capable of handling blur. Using a default alpha value");
float alpha = capable ? 0.54f : 0.85f;

final Class<?> ScrimController = XposedHelpers.findClass(rootPackage + ".statusbar.phone.ScrimController", lpParam.classLoader);
Expand All @@ -80,7 +128,6 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
}
};

Object[] parameterTypesAndCallback;
if (Build.VERSION.SDK_INT >= 33) { parameterTypesAndCallback = new Object [] {
rootPackage + ".statusbar.phone.LightBarController",
rootPackage + ".statusbar.phone.DozeParameters",
Expand All @@ -93,11 +140,10 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
rootPackage + ".statusbar.policy.ConfigurationController",
"java.util.concurrent.Executor",
rootPackage + ".statusbar.phone.ScreenOffAnimationController",
rootPackage + ".statusbar.phone.panelstate.PanelExpansionStateManager",
rootPackage + ".keyguard.KeyguardUnlockAnimationController",
rootPackage + ".statusbar.phone.StatusBarKeyguardViewManager",
xcMethodHook};}
else { parameterTypesAndCallback = new Object [] {
else if (Build.VERSION.SDK_INT == 32) { parameterTypesAndCallback = new Object [] {
rootPackage + ".statusbar.phone.LightBarController",
rootPackage + ".statusbar.phone.DozeParameters",
"android.app.AlarmManager",
Expand All @@ -111,7 +157,21 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
rootPackage + ".statusbar.phone.UnlockedScreenOffAnimationController",
rootPackage + ".statusbar.phone.panelstate.PanelExpansionStateManager",
xcMethodHook};}
else if (Build.VERSION.SDK_INT == 31) { parameterTypesAndCallback = new Object [] {
rootPackage + ".statusbar.phone.LightBarController",
rootPackage + ".statusbar.phone.DozeParameters",
"android.app.AlarmManager",
rootPackage + ".statusbar.policy.KeyguardStateController",
rootPackage + ".util.wakelock.DelayedWakeLock.Builder",
"android.os.Handler",
"com.android.keyguard.KeyguardUpdateMonitor",
rootPackage + ".dock.DockManager",
rootPackage + ".statusbar.policy.ConfigurationController",
"java.util.concurrent.Executor",
rootPackage + ".statusbar.phone.UnlockedScreenOffAnimationController",
xcMethodHook};}

if (BuildConfig.DEBUG) XposedBridge.log("Trying to hook a ScrimController constructor.");
findAndHookConstructor(ScrimController, parameterTypesAndCallback);
}
}
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.3.0' apply false
id 'com.android.library' version '7.3.0' apply false
id 'com.android.application' version '7.3.1' apply false
id 'com.android.library' version '7.3.1' apply false
}

task clean(type: Delete) {
Expand Down

0 comments on commit 0de84c6

Please sign in to comment.