Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions AntiBrightnessChange/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# AntiBrightnessChange

This module prevents selected apps from overwriting the screen brightness.

If applied to System Framework (`android`)
it will prevent every app from changing the screen brightness.
19 changes: 19 additions & 0 deletions AntiBrightnessChange/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
plugins {
id("com.android.application")
}

android {
val packageName = "com.programminghoch10.AntiBrightnessChange"
namespace = packageName

defaultConfig {
applicationId = packageName
minSdk = 33
targetSdk = 33
compileSdk = 33
versionCode = 1
versionName = "1.0"
}
}

dependencies {}
29 changes: 29 additions & 0 deletions AntiBrightnessChange/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
>

<application
android:label="AntiBrightnessChange"
tools:ignore="MissingApplicationIcon"
>
<meta-data
android:name="xposedmodule"
android:value="true"
/>
<meta-data
android:name="xposeddescription"
android:value="Prevent apps from changing display brightness."
/>
<meta-data
android:name="xposedminversion"
android:value="82"
/>
<meta-data
android:name="xposedscope"
android:resource="@array/scope"
/>
</application>

</manifest>
1 change: 1 addition & 0 deletions AntiBrightnessChange/src/main/assets/xposed_init
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
com.programminghoch10.AntiBrightnessChange.Hook
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.programminghoch10.AntiBrightnessChange;

import static android.view.WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_NONE;

import android.view.WindowManager;

import androidx.annotation.Keep;

import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedHelpers;
import de.robv.android.xposed.callbacks.XC_LoadPackage;

@Keep
public class Hook implements IXposedHookLoadPackage {
@Override
public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) {
if (lpparam.packageName.equals("android")) {
XposedHelpers.findAndHookMethod("com.android.server.wm.RootWindowContainer", lpparam.classLoader, "handleNotObscuredLocked",
"com.android.server.wm.WindowState", boolean.class, boolean.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) {
XposedHelpers.setFloatField(param.thisObject, "mScreenBrightnessOverride", Float.NaN);
}
});
return;
}

XposedHelpers.findAndHookMethod(WindowManager.LayoutParams.class, "copyFrom", WindowManager.LayoutParams.class, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) {
WindowManager.LayoutParams layoutParams = (WindowManager.LayoutParams) param.args[0];
layoutParams.screenBrightness = BRIGHTNESS_OVERRIDE_NONE;
layoutParams.buttonBrightness = BRIGHTNESS_OVERRIDE_NONE;
}
});
}
}
5 changes: 5 additions & 0 deletions AntiBrightnessChange/src/main/res/values/arrays.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="scope">
</string-array>
</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
This module prevents selected apps from overwriting the screen brightness.

If applied to System Framework (`android`)
it will prevent every app from changing the screen brightness.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Prevents selected apps from overwriting the screen brightness.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Anti Brightness Change
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ dependencyResolutionManagement {
}

rootProject.name = "XposedModulets"
include(":AntiBrightnessChange")
include(":AutomaticAdvancedSettingsExpander")
include(":BetterVerboseWiFiLogging")
include(":BetterBluetoothDeviceSort")
Expand Down