Fix/rewrite onyx sdk lights controller#586
Conversation
0eeee95 to
757539a
Compare
9fe42e0 to
878d142
Compare
…pes and streamline SDK bridging Move ONYX_GO7 to use the SDK
5f53e5f to
42756ce
Compare
… streamline light control, and encapsulate SDK bridging
42756ce to
8be9ad4
Compare
…ng redundant brightness detection logic
|
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 Codacy reports Complexity +65, but this mainly comes from reproducing the same behaviour as the Onyx framework. 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
Example log output: |
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. |
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:
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