Skip to content

Commit

Permalink
feat: camera - Force Maximum Brightness When Using Camera
Browse files Browse the repository at this point in the history
圣小熊提供方案
  • Loading branch information
Sevtinge committed May 17, 2024
1 parent cf9710f commit c5c4060
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.sevtinge.hyperceiler.module.base.HookExpand;
import com.sevtinge.hyperceiler.module.hook.camera.CustomWatermark;
import com.sevtinge.hyperceiler.module.hook.camera.EnableLabOptions;
import com.sevtinge.hyperceiler.module.hook.camera.MaxScreenBrightness;
import com.sevtinge.hyperceiler.module.hook.camera.Unlock120Fps;
import com.sevtinge.hyperceiler.module.hook.camera.Unlock60Fps;
import com.sevtinge.hyperceiler.module.hook.camera.UnlockAiEnhance;
Expand Down Expand Up @@ -129,5 +130,7 @@ public void handleLoadPackage() {
initHook(new UnlockMenMakeup(), mPrefsMap.getBoolean("camera_settings_men_makeup"));
initHook(new EnableLabOptions(), mPrefsMap.getBoolean("camera_settings_lab_options"));
initHook(new UnlockTrackEyes(), mPrefsMap.getBoolean("camera_settings_track_eyes"));

initHook(new MaxScreenBrightness(), mPrefsMap.getBoolean("camera_max_brightness"));
}
}
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);

}

}
1 change: 1 addition & 0 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,7 @@
<string name="camera_settings_men_makeup">解锁男性妆容适配</string>
<string name="camera_settings_lab_options">启用实验室选项</string>
<string name="camera_settings_track_eyes">解锁人眼追焦</string>
<string name="camera_max_brightness">使用相机时使屏幕亮度最大</string>
<!--日历-->
<string name="calendar">日历</string>
<string name="calendar_unlock_subscription">解锁订阅服务</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,7 @@
<string name="camera_settings_men_makeup">Unlock Adjust makeup effects for men</string>
<string name="camera_settings_lab_options">Enable Lab options</string>
<string name="camera_settings_track_eyes">Unlock Track eyes</string>
<string name="camera_max_brightness">Force Maximum Brightness When Using Camera</string>
<!--Calendar-->
<string name="calendar">Calendar</string>
<string name="calendar_unlock_subscription">Unlock Subscription</string>
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/xml/camera.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
app:myLocation="@string/camera">

<SwitchPreference
android:title="@string/camera_max_brightness"
android:key="prefs_key_camera_max_brightness"
android:defaultValue="false" />

<PreferenceCategory android:title="@string/shot">

<SwitchPreference
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/xml/camera_new.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@

<PreferenceCategory>

<SwitchPreference
android:title="@string/camera_max_brightness"
android:key="prefs_key_camera_max_brightness"
android:defaultValue="false" />

<SwitchPreference
android:title="@string/camera_custom_watermark"
android:key="prefs_key_camera_custom_watermark"
Expand Down

0 comments on commit c5c4060

Please sign in to comment.