Skip to content

Fix/rewrite onyx sdk lights controller#586

Open
Tukks wants to merge 6 commits intokoreader:masterfrom
Tukks:fix/RewriteOnyxSdkLightsController
Open

Fix/rewrite onyx sdk lights controller#586
Tukks wants to merge 6 commits intokoreader:masterfrom
Tukks:fix/RewriteOnyxSdkLightsController

Conversation

@Tukks
Copy link
Copy Markdown
Contributor

@Tukks Tukks commented Mar 5, 2026

This PR addresses several issues encountered with frontlight and warmth (CTM) control on the Onyx Boox Go 7 when using ADB Mode.

I extracted and decompiled the APK from my device and tried to reproduce the logic here.
In the APK, we can see that different kinds of devices are handled: frontlight-only devices, devices with warmth, etc.

The following device types are handled:

  • IMX6Device
  • RK31XXDevice
  • IMX7Device
  • RK32XXDevice
  • RK33XXDevice
  • RK3026Device

Here are the decompiled classes in a zip file (only the relevant ones):
extracted.zip

Testing & Verification

Tested on Boox Go 7.

There are 4 modes available in the Boox UX: Off mode, Custom mode, Soft mode, and Bright mode.

  • Off Mode: No slider is active in the Boox UX. KOReader can enable the frontlight, but a bug immediately sets the value to 20 instead of the value provided. It is impossible to make warmth work in this mode.

  • Custom Mode: Only the frontlight slider is active in the UX, but KOReader can also control warmth. We override the system behavior.

  • Soft Mode and Bright Mode: Both the warmth and frontlight sliders are active in the UX. KOReader can control the frontlight and warmth normally.

The minimum and maximum values are correctly retrieved. (Before it was 0 to 255, now 32 on the Go 7)

Remarks

If needed, I can create a new controller class instead of overriding what already appears to work.
This would allow users to test the driver through the developer options before replacing the current implementation.

Implementation Notes

An LLM was used as an assistance tool while analyzing the decompiled APK and reproducing the logic.
The final implementation was reviewed and adjusted manually.


This change is Reviewable

@Tukks Tukks force-pushed the fix/RewriteOnyxSdkLightsController branch from 0eeee95 to 757539a Compare March 5, 2026 21:11
@Tukks Tukks marked this pull request as draft March 5, 2026 21:35
@Tukks Tukks force-pushed the fix/RewriteOnyxSdkLightsController branch 3 times, most recently from 9fe42e0 to 878d142 Compare March 5, 2026 21:53
@Tukks Tukks marked this pull request as ready for review March 5, 2026 21:55
Tukks added 2 commits March 5, 2026 23:01
…pes and streamline SDK bridging

Move ONYX_GO7 to use the SDK
@Tukks Tukks force-pushed the fix/RewriteOnyxSdkLightsController branch 2 times, most recently from 5f53e5f to 42756ce Compare March 6, 2026 11:41
… streamline light control, and encapsulate SDK bridging
@Tukks Tukks force-pushed the fix/RewriteOnyxSdkLightsController branch from 42756ce to 8be9ad4 Compare March 6, 2026 11:41
@Tukks
Copy link
Copy Markdown
Contributor Author

Tukks commented Mar 6, 2026

I think this PR is ready for review.

I tested it extensively on my Boox Go 7 and everything works smoothly (brightness, warmth, and frontlight control).

For reference, I also attached a decompiled framework.jar, which contains additional information compared to the KCB one:

framework-out.zip

Codacy reports Complexity +65, but this mainly comes from reproducing the same behaviour as the Onyx framework.
The logic is required to correctly support the different brightness modes (FL, WARM/COLD, CTM) and to mirror how DeviceController handles frontlight control internally.

Additional note:

It might be possible to exit the Off mode (where the bug appears) by sending the following broadcast:

private const val TOGGLE_BRIGHTNESS_STYLE_REQUEST_ACTION = "com.onyx.TOGGLE_BRIGHTNESS_STYLE_REQUEST"
private const val ARGS_TYPE = "type" // verify this constant name in BroadcastHelper

fun setCustomLightStyle(context: Context) {
    val intent = Intent(TOGGLE_BRIGHTNESS_STYLE_REQUEST_ACTION).apply {
        putExtra(ARGS_TYPE, "style_type_custom")
        addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES)
    }
    context.sendBroadcast(intent)
    Log.d(TAG, "sendBroadcast → style_type_custom")
}

However, this introduces inconsistent behaviour: the device briefly switches to Light mode and then sometimes returns to Off mode after a short time. In some cases it remains in Light mode as expected.

My guess is that the system service responsible for frontlight management resets the mode in certain situations.

Because of this behaviour, I did not include this approach in the implementation for now.

If someone wants to explore this further, everything seems to be handled by LightStyleConfig, which loads a configuration file and writes updates to it. The available styles appear to be:

  • style_type_custom
  • style_type_bright
  • style_type_soft
  • style_type_auto_brightness (if supported by the device, not the case for the Boox Go 7)
  • style_type_close_brightness (the Off mode)

Example log output:

LightStyleConfig save {"currentStyle":"style_type_close_brightness","lightStyle":{"style_type_auto_brightness":{"autoLightBrightnessEnable":false,"autoTemperatureBrightnessEnable":false,"lightBrightness":0,"styleType":"style_type_auto_brightness","temperatureBrightness":0},"style_type_bright":{"autoLightBrightnessEnable":false,"autoTemperatureBrightnessEnable":false,"lightBrightness":20,"styleType":"style_type_bright","temperatureBrightness":0},"style_type_close_brightness":{"autoLightBrightnessEnable":false,"autoTemperatureBrightnessEnable":false,"lightBrightness":0,"styleType":"style_type_custom","temperatureBrightness":0},"style_type_custom":{"autoLightBrightnessEnable":false,"autoTemperatureBrightnessEnable":false,"lightBrightness":0,"styleType":"style_type_custom","temperatureBrightness":0},"style_type_soft":{"autoLightBrightnessEnable":false,"autoTemperatureBrightnessEnable":false,"lightBrightness":7,"styleType":"style_type_soft","temperatureBrightness":12}},"supportAutoBrightness":false,"versionCode":4}

@hugleo hugleo self-requested a review March 6, 2026 12:52
@Frenzie
Copy link
Copy Markdown
Member

Frenzie commented Mar 6, 2026

Codacy reports Complexity +65, but this mainly comes from reproducing the same behaviour as the Onyx framework.

That particular metric is mostly quite useless as far as I'm concerned.

I think there might be some minor conflict with #585 so we'll have to check which to merge first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants