-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: camera - Force Maximum Brightness When Using Camera
圣小熊提供方案
- Loading branch information
Showing
6 changed files
with
107 additions
and
0 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
92 changes: 92 additions & 0 deletions
92
app/src/main/java/com/sevtinge/hyperceiler/module/hook/camera/MaxScreenBrightness.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,92 @@ | ||
package com.sevtinge.hyperceiler.module.hook.camera; | ||
|
||
import android.app.Activity; | ||
import android.os.Bundle; | ||
import android.view.Window; | ||
import android.view.WindowManager; | ||
|
||
import com.sevtinge.hyperceiler.module.base.BaseHook; | ||
import com.sevtinge.hyperceiler.module.base.dexkit.DexKit; | ||
|
||
import org.luckypray.dexkit.query.FindMethod; | ||
import org.luckypray.dexkit.query.matchers.MethodMatcher; | ||
import org.luckypray.dexkit.result.MethodData; | ||
|
||
import java.lang.reflect.Method; | ||
|
||
import de.robv.android.xposed.XposedHelpers; | ||
|
||
public class MaxScreenBrightness extends BaseHook { | ||
|
||
@Override | ||
public void init() throws NoSuchMethodException { | ||
|
||
MethodData methodData = DexKit.getDexKitBridge().findMethod(FindMethod.create() | ||
.matcher(MethodMatcher.create() | ||
.usingNumbers(0, 8208, -1.0f, 256, 204) | ||
) | ||
).singleOrThrow(() -> new IllegalStateException("MaxScreenBrightness: Cannot found getHaloBrightness()")); | ||
Method method = methodData.getMethodInstance(lpparam.classLoader); | ||
logD(TAG, lpparam.packageName, "getHaloBrightness() method is " + method); | ||
hookMethod(method, new MethodHook() { | ||
@Override | ||
protected void after(MethodHookParam param) throws Throwable { | ||
Activity activity = (Activity) XposedHelpers.callMethod(param.thisObject, "getActivity"); | ||
setScreenBrightnessToMax(activity); | ||
} | ||
|
||
}); | ||
|
||
findAndHookMethod(Window.class, "setAttributes", WindowManager.LayoutParams.class, new MethodHook() { | ||
@Override | ||
protected void before(MethodHookParam param) throws Throwable { | ||
WindowManager.LayoutParams layoutParams = (WindowManager.LayoutParams) param.args[0]; | ||
layoutParams.screenBrightness = 1.0f; | ||
param.args[0] = layoutParams; | ||
} | ||
}); | ||
|
||
|
||
findAndHookMethod("com.android.camera.ActivityBase", "onCreate", Bundle.class, new MethodHook() { | ||
@Override | ||
protected void after(MethodHookParam param) throws Throwable { | ||
Activity activity = (Activity) param.thisObject; | ||
setScreenBrightnessToMax(activity); | ||
} | ||
}); | ||
|
||
findAndHookMethod("com.android.camera.ActivityBase", "onStart", new MethodHook() { | ||
@Override | ||
protected void after(MethodHookParam param) throws Throwable { | ||
Activity activity = (Activity) param.thisObject; | ||
setScreenBrightnessToMax(activity); | ||
} | ||
}); | ||
|
||
findAndHookMethod("com.android.camera.ActivityBase", "onRestart", new MethodHook() { | ||
@Override | ||
protected void after(MethodHookParam param) throws Throwable { | ||
Activity activity = (Activity) param.thisObject; | ||
setScreenBrightnessToMax(activity); | ||
} | ||
}); | ||
|
||
findAndHookMethod("com.android.camera.ActivityBase", "onResume", new MethodHook() { | ||
@Override | ||
protected void after(MethodHookParam param) throws Throwable { | ||
Activity activity = (Activity) param.thisObject; | ||
setScreenBrightnessToMax(activity); | ||
} | ||
}); | ||
|
||
} | ||
|
||
private void setScreenBrightnessToMax(Activity activity) { | ||
Window window = activity.getWindow(); | ||
WindowManager.LayoutParams layoutParams = window.getAttributes(); | ||
layoutParams.screenBrightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_FULL; | ||
window.setAttributes(layoutParams); | ||
|
||
} | ||
|
||
} |
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
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