[APP] [XPOSED] [MIUI 8] Bring back read mode on custom kernels

S0bes

Senior Member
Jan 1, 2012
867
967
0
Hi, xda!
I use read (paper) mode every day at the night time and got used to it pretty much. And I never tried to flash different kernel cause I knew there would be the lack of that feature. Even though you can adjust screen temperature in the Kernel Adiutor it still seems to me like not convenient way to go with.

So, here I present xposed module with no preferences of any kind. You just install it, check, reboot and you got working read mode back.

Requirements:
  1. Xposed
  2. Root
  3. Miui 8 based on 6.0.1 (I tested it on MM, Don't know will it work for LP or N).
  4. Kernel with KCAL suport (if you're able to adjust screen temperature in Kernel Adiutor the kernel you're using supports KCAL). If not, ask developer to include that feature.

Download:
v.1.0.0 - View attachment PMBack.apk

Please, comment if it works for you or not including device, miui and android version, kernel.

P.S
I don't quite remember but the module should require root access for the first time. It will show SU dialog for com.android.systemui. Grant it.


In the section bellow I just list some of kernel developers for rn3pro to get their attention so they could update their posts if they wish to include that useful (?) information.
@Umang96, @psndna88, @KabirKalsi, @flar2, @GreekDragon, @khan_frd2002, @GuneetAtwal

162b896f-2007-43e6-b44b-0e0e16466bf4.jpg
 
Last edited:

Doublewise01

Member
Jun 28, 2016
27
4
0
Hi, xda!
I use read (paper) mode every day at the night time and got used to it pretty much. And I never tried to flash different kernel cause I knew there would be the lack of that feature. Even though you can adjust screen temperature in the Kernel Adiutor it still seems to me like not convenient way to go with.

So, here I present xposed module with no preferences of any kind. You just install it, check, reboot and you got working read mode back.

Requirements:
  1. Xposed
  2. Root
  3. Miui 8 based on 6.0.1 (I tested it on MM, Don't know will it work for LP or N).
  4. Kernel with KCAL suport (if you're able to adjust screen temperature in Kernel Adiutor the kernel you're using supports KCAL). If not, ask developer to include that feature.

Download:
v.1.0.0 - View attachment 4226556

Please, comment if it works for you or not including device, miui and android version, kernel.

P.S
I don't quite remember but the module should require root access for the first time. It will show SU dialog for com.android.systemui. Grant it.


In the section bellow I just list some of kernel developers for rn3pro to get their attention so they could update their posts if they wish to include that useful (?) information.
@Umang96, @psndna88, @KabirKalsi, @flar2, @GreekDragon, @khan_frd2002, @GuneetAtwal

View attachment 4226517
It's work, thank you.

Sent from my Redmi Note 3 using Tapatalk
 

Doublewise01

Member
Jun 28, 2016
27
4
0
Frequently it accessing root even right after screen on. Is it normal? I think it just access when reading mode on only.

Sent from my Redmi Note 3 using Tapatalk
 

S0bes

Senior Member
Jan 1, 2012
867
967
0
Frequently it accessing root even right after screen on. Is it normal? I think it just access when reading mode on only.

Sent from my Redmi Note 3 using Tapatalk
Well, yeah it should not be normally . But the OS itself during some cases can call for a function which is responsible for read mode on/off and that's is when my code (including su request is executed). So, the module does not force anything. It just follows OS requests.
You can go to SU settings and disable notifications for needed apps. Or even better, check Trust system user
 
  • Like
Reactions: bravonova

bravonova

Senior Member
Mar 6, 2015
2,253
1,685
0
Pune
Working properly on Redmi Note 3 (Kenzo) on MIUI 8 with Radon Kernel 5.3 and AGNi Kernel 9.8.

---------- Post added at 07:35 PM ---------- Previous post was at 07:34 PM ----------

Frequently it accessing root even right after screen on. Is it normal? I think it just access when reading mode on only.
It asked SU right only once for me. After granting permission it didn't ask again.
 

S0bes

Senior Member
Jan 1, 2012
867
967
0
For Sure Reading Mode is closed part of the kernel source, maybe we could just Reverse-Engineer MIUI Frameworks and get the sysfs node for Reading Mode, and we can use KCAL To Store Color in that node! @Umang96 @MOVZX Do you think its possible?
I don't know what is it I need to search for but here I list bellow some information that might be useful.

Every time we press on read mode toggle the method setEyeCare(int Mode) is executed from miui.hareware.display.DisplayFeatureManager. Where parameter Mode is in range from 0 to 8. 0 - disable RM. 1-8 - depends on "adjust" seekbar position in RM settings.
Then inside the function setActiveMode(service, 0, Mode) and setDefaultMode(service, 0, Mode) are also executed.
As I understand these functions are trying to transmit the data to IColorService (com.qti.snapdragon.sdk.display.IColorService)
Then from IcolorService all it goes to com.qti.service.colorservice.ColorServiceApp where it checks for libsd_sdk_display.so and libmm-disp-apis.so and native_setActiveMode(int i, int i2) method is executed from these libraries. I disassembled libsd_sdk_display.so and there accembler code which I understand only a little and can not figure out what files are used next to perform change color display action.

Code:
EXPORT Java_com_qti_service_colorservice_IColorServiceImpl_native_1setActiveMode
Java_com_qti_service_colorservice_IColorServiceImpl_native_1setActiveMode

var_18= -0x18

PUSH            {R0-R2,R4,R5,LR}
MOV             R4, R2
STR             R2, [SP,#0x18+var_18]
MOVS            R0, #3
LDR             R1, =(aIcolorservicei - 0x1EFE)
MOV             R5, R3
LDR             R2, =(aJniPassingMode - 0x1F00)
ADD             R1, PC  ; "IColorServiceImpl"
ADD             R2, PC  ; "JNI: Passing modeId %d for display %d"
BLX             __android_log_print
MOV             R0, R4
MOV             R1, R5
ADD             SP, SP, #0xC
POP.W           {R4,R5,LR}
B.W             j_j_disp_api_set_active_display_mode
; End of function Java_com_qti_service_colorservice_IColorServiceImpl_native_1setActiveMode
And again
@Umang96, @psndna88, @KabirKalsi, @flar2, @GreekDragon, @khan_frd2002, @GuneetAtwal
take a look, may be you could help

All the files (java and .so) I attached here
 

Attachments

Last edited:
  • Like
Reactions: psndna88

MOVZX

Senior Member
Jan 26, 2012
761
388
63
For Sure Reading Mode is closed part of the kernel source, maybe we could just Reverse-Engineer MIUI Frameworks and get the sysfs node for Reading Mode, and we can use KCAL To Store Color in that node! @[email protected] Do you think its possible?
sysfs for MIUI Reading Mode is msm_fb_eyecare, maybe we can redirect that to KCAL. But why though?
 

S0bes

Senior Member
Jan 1, 2012
867
967
0
Why has no answer! :p, if we can we should! :D

---------- Post added at 07:26 AM ---------- Previous post was at 07:24 AM ----------


By the way which tool you used to disassemble Libraries?
Found that video https://youtu.be/qQRF1aPXhgw
I even don't know where to find and is it possible at all msm_fb_eyecare file. I flashed stock kernel for now cause radon freezes my phone randomly even though I just used all recommended settings
 

S0bes

Senior Member
Jan 1, 2012
867
967
0
IDA i knew it, Don't know how to use! :p

I'm not sure we might make a blank sysfs node for mdss_fb_eyecare in custom kernels, which can be used to store Reading Mode values, then can apply values via kcal, using select case(), because as far as i know that Reading Mode slider isn't free, it has specific steps!
As i told, slider has 8 steps from 1 to 8