[TUT] Implementing EPRJ RIL in Custom Roms by Yourself

Search This thread

Flying_Bear

Senior Member
Jan 16, 2011
1,874
799
actually I tried both methods last night, so when I tried to add it to ROM and flashed it, the ROM worked well but airplan mod is still bugy so I tried to include the telephony framework from Adam's OmniROM and flashed the ROM but phone process kept crashing !! don't know what to say! in Adam's ROM airplane mod was just perfect so was connection.

unfortunately, i don't know the solution :(

perhaps @Adam77Root can help us with this?
 
  • Like
Reactions: QuGhZx and ssefrgr

Coolneng

Senior Member
Mar 28, 2013
160
41
Yugoslavia
Does anyone have the problem that all calls are automatically on speaker mode (external speaker, the one meant for media)? Because I can't switch it. I have Paranoid Android and I also tried this RIL in Omni (an old 4.3 build and I had the same problem)

Sent from my LG-P880 using Tapatalk
 

Flying_Bear

Senior Member
Jan 16, 2011
1,874
799
Usually you can't replace the whole framework from one rom to another. You could try X3RIL from Omni.

what about roms that don't have x3ril.smali in them?

Does anyone have the problem that all calls are automatically on speaker mode (external speaker, the one meant for media)? Because I can't switch it. I have Paranoid Android and I also tried this RIL in Omni (an old 4.3 build and I had the same problem)

Sent from my LG-P880 using Tapatalk

havent had this issue tbh, did you do a full reset and test?
 

Adam77Root

Inactive Recognized Developer
Jul 3, 2012
2,521
11,117
what about roms that don't have x3ril.smali in them?

There could be roms that don't have the custom RIL inclusion merged. If our device didn't work with default RIL, these roms wouldn't work. These roms probably don't have supported devices that use this method.

Sent from my OmniROM-powered LG Optimus 4X HD
 

Flying_Bear

Senior Member
Jan 16, 2011
1,874
799
There could be roms that don't have the custom RIL inclusion merged. If our device didn't work with default RIL, these roms wouldn't work. These roms probably don't have supported devices that use this method.

Sent from my OmniROM-powered LG Optimus 4X HD

that means that roms without x3ril.smali can't have eprj ril implemented, right?

also, beanstalk build, the first build had x3ril.smali in telephony-common.jar, while the newest build doesn't. would it be possible to use whole telephony-common.jar from first build in the second build, since it's the same rom?
 

QuGhZx

Senior Member
Nov 10, 2013
112
25
There could be roms that don't have the custom RIL inclusion merged. If our device didn't work with default RIL, these roms wouldn't work. These roms probably don't have supported devices that use this method.

Sent from my OmniROM-powered LG Optimus 4X HD

Hi @Adam77Root :D
do you have any idea why Airplane mod is bugy in CM11 and all it's based ROM's
when I enable Airplane mod to cut my network connect it works well but when I re-disable it it doesn't restore mobile network connection so I have to reboot and retype my PIN again to restore network connection or do it manually by going to Settings> in WIRELESS & NETWORKS "More..."> Mobile Networks> Network Operators> wait till the search is finished (takes 3 to 5 min's) and choose my network to restore connection back!!
that is one hell of an annoying problem :(
I didn't face it in your OmniROM (Which was absolutely awesome :D) but I switched to CM11 and it's based ROM's because of theme's feature :p currently I'm running Vanir 4.4.2 (vanir_P880_4.4.2.011814.zip) and this bug still exists. :(
if you know something about it please help :eek:
 
Last edited:

Adam77Root

Inactive Recognized Developer
Jul 3, 2012
2,521
11,117
that means that roms without x3ril.smali can't have eprj ril implemented, right?

also, beanstalk build, the first build had x3ril.smali in telephony-common.jar, while the newest build doesn't. would it be possible to use whole telephony-common.jar from first build in the second build, since it's the same rom?

Maybe yes, maybe not. Only sources can tell. It can also happen that they have the supporting commit, but sth is derped in the device tree so it doesn't get included. However, even if the inclusion commit isn't there, the custom RIL class usage is. It must be, because all main devices use some custom RIL. So putting EPRJ RIL and setting the property would suffice.

You can always try, but in general replacing any apk or jar is a bad idea. Even if it works for daily use you might encounter rare crashes. For example you don't everyday get cell broadcasts, but imagine what would happen if you get one in emergency (e.g. tornado) and the RIL crashes because of an unhandled exception that's caused by incompatibilities. Of course this is exaggeration, but depicts the issue fairly well. :)

Hi @Adam77Root :D
do you have any idea why Airplane mod is bugy in CM11 and all it's based ROM's
when I enable Airplane mod to cut my network connect it works well but when I re-disable it it doesn't restore mobile network connection so I have to reboot and retype my PIN again to restore network connection or do it manually by going to Settings> in WIRELESS & NETWORKS "More..."> Mobile Networks> Network Operators> wait till the search is finished (takes 3 to 5 min's) and choose my network to restore connection back!!
that is one hell of an annoying problem :(
I didn't face it in your OmniROM (Which was absolutely awesome :D) but I switched to CM11 and it's based ROM's because of theme's feature :p currently I'm running Vanir 4.4.2 (vanir_P880_4.4.2.011814.zip) and this bug still exists. :(
if you know something about it please help :eek:

It's hard to tell this way. You could try one thing: Repack Omni's X3RIL following this tutorial and report.
 

Flying_Bear

Senior Member
Jan 16, 2011
1,874
799
ok, i have found a semi-solution in case your rom, for some reason, doesn't have x3ril.smali in it's telephony-common.jar; search for previous builds of that rom which do have x3ril.smali, mod it, end replace the whole telephony-common file from old rom into new. it's not a perfect solution, but it seems to be working for me on beanstalk. i'll add this to the OP too
 
  • Like
Reactions: QuGhZx

donkanmcklaus

Senior Member
Jan 9, 2013
448
62
Santiago
i don't know why but in recent CM11 nightlies are facing issues with RIL more continues than early nightlies, I tried this tutorial to implement EPJRIL but the behavior of the signal is unstable for me, i don't know why, I will try to port Omni's telephony or RIL and test to see what happens, i'm really tired of CM based Rom for this reason, some are great other not so much, but the main issue for me is unstable signal, and to have to reboot the phone continously
 
  • Like
Reactions: Flying_Bear

donkanmcklaus

Senior Member
Jan 9, 2013
448
62
Santiago
I give up, I tried everything, from implement EPRJ RIL into a variety of ROM, to implement different x3ril.smali from other ROMs, and always have the same problem, now I'm rolling back to a stock based ROM, and let the phone die peacefully, thanks for the support

Sent from my LG-P880 using xda app-developers app
 

Flying_Bear

Senior Member
Jan 16, 2011
1,874
799
I give up, I tried everything, from implement EPRJ RIL into a variety of ROM, to implement different x3ril.smali from other ROMs, and always have the same problem, now I'm rolling back to a stock based ROM, and let the phone die peacefully, thanks for the support

Sent from my LG-P880 using xda app-developers app

i'm sad to hear that :( did you try p.a. by dcos by any chance?


also, i've added a fix to the op for roms which don't have x3ril.smali in them by default, all credits go to @gerciolisz
 
  • Like
Reactions: gerciolisz

donkanmcklaus

Senior Member
Jan 9, 2013
448
62
Santiago
@Flying_Bear please can you tell me what can I do to modify EPRJ RIL to try to solve my problem? There's something wrong that losing signal continues happening

Sent from my LG-P880 using xda app-developers app
 

Top Liked Posts

  • There are no posts matching your filters.
  • 28
    A. Why change RIL?

    Hey, everyone.

    As a user that's been using custom roms since our bootloader was unlocked, I'm aware that some of us have some issue with telephony & mobile data (in short, RIL) - occasionally IMEI wouldn't be read on boot, which would lead to device not being registred on network. Sometimes, the network would "die" in a way - you'd get an error when trying to dial a number, and when someone would call you, they'll hear the ringing tone while your cell phone would not ring at all.

    The cause of the problem seems to be some lazy coding by official CM developers/maintainers for our device. This was picked up by a developer named kholk, so he did his best to recode it properly, however it was never included into official CM device tree for reasons unknown to me (more info about the issue can be found here: http://review.cyanogenmod.org/#/c/47980/).

    Kholk did include his own custom RIL into his EPRJ roms, but the roms are kinda old and have iffy baseband (which seems to be kernel issue, as he's using his own, 3.4 kernel instead of CM's 3.1 kernel in other custom roms).

    So, with the help of Adam77Root, I've learned a way on how to implement EPRJ RIL into other custom roms (since I still had RIL issue with default CM RIL in 4.3 roms even) - so far I've tested it with Vanir 4.3, Carbon 4.3, Carbon 4.3.1, and few 4.2.2 roms, and I havent had ANY issues I had in CM RIL.

    So, this is a tutorial to show you how you can import EPRJ RIL to any custom rom you'd like, in case you have issues with cell connection.


    -this should work on any kernel and any custom rom (4.2.2+)! Tested so far, as far as kernel goes, are iodak 8/8.5, WWJB8/8b, Optimus Prime several versions, Optimus Play! 2.53.
    -KK roms tested are P.A. by @dcos which has eprj ril by default, official CM nightlies and several others

    -some KK roms, for some reason, don't have x3ril.smali file in their telephony-common.jar. To implement EPRJ RIL in these roms, follow the tutorial up to point 5, and skip that one, since you don't have anything to delete. After point 13, you need to do one additional thing - you need to edit ROM's build.prop settings, look for this line: "#ro.telephony.ril_class=X3RIL", and delete "#" so this line would be included in build.prop. After that, you're ready to flash. Thanks goes to @gerciolisz for the tip on the build.prop settings.
    -/As of 24.01.2014. i've added another zip file which contains x3ril.smali taken from P.A. port by dcos - i'd recommend using this one for 4.4.2 roms/
    -as of 11.06.2014., I've added x3ril.smali (it's in omni-v1.rar) made by adam, which is based on omni's RIL but has eprj RIL recovery. if you're on 4.4.3 kitkat rom and have issues, i suggest you give this file a try first before others


    B. What's needed?


    First off, you'll need a few things:

    - Android Multitool from http://xdaforums.com/showthread.php?t=2326604, many thanks to @Flextrick
    - Read the linked topic - it's the instruction on how to use it, and in case you encounter any errors, that's the place to search for solutions
    - Attached is a RAR with two files in it, X3RIL_old.smali and X3RIL_new.smali. You need only one of those - but more info about them will be in the other steps.
    - Custom ROM you want to edit
    - Common sense
    - WinRAR & JAVA



    C. How to change RIL?

    Steps:



    1. First step is to open the .zip of your custom ROM you want to edit, and search for system/framework/telephony-common.jar

    2. Extract it to AndroidMultitool/Files, and after extract is done, delete it from .zip

    3. Open Android Multitool, under Decompiling select .jar, then select telephony-common.jar in AndroidMultitool/Files, click "decompile"

    4. After you're done, check if there were any errors in the Log, in AndroidMultitool main window



    5. Head over to AndroidMultitool/Decompiled_jar/telephony-common/com/android/internal/telephony and look for X3RIL.smali. This is CM's RIL implemented in custom roms, which we dont need anymore, so delete it

    6. Now, you need to decide wether to use X3RIL_old.smali, which is RIL from EPRJ CM10.2 built on 20130813, or X3RIL_new.smali which is RIL from EPRJ CM10.2 built on 20131007. I'm using 20131007 atm, and it's working without issues

    7. When you've decided, move it back into AndroidMultitool/Decompiled_jar/telephony-common/com/android/internal/telephony and rename it to X3RIL.smali

    8. Back in AndroidMultitool, under Compilin, select jar, and for folder select AndroidMultitool/Decompiled_jar/telephony-common, press "compile", and check for errors in Log

    9. Output should be classes.dex file under AndroidMultitool/Compiled_jar



    10. Open telephony-common.jar in AndroidMultitool/Files with WinRar - you should see META-INF folder, with classes.dex file

    11. Delete classes.dex file in WinRAR

    12. Move classes.dex file from AndroidMultitool/Compiled_jar to telephony-common.jar opened in WinRAR

    13. Paste telephony-common.jar into system/framework inside the custom rom .zip file

    14. You now have modified ROM ready to flash on our device!




    D. Thank You's

    Thank you's go out to @kholk for his RIL programming, @dcos for first implementing EPRJ RIL into a rom (his P.A. unofficial port for our device) different than EPRJCM10.2, @Adam77Root for his tutorial that I basically beutified and made sure is easier to understand & his modification of x3ril.smali from omni, @gerciolisz for the tip about build.prop settings, @Flextrick for his Multitool with neat GUI to extract .jar files, and all the other devs of p880 making our device worth every dime I've spent on it.
    6
    Possible solution

    There have been lots of updates to the CM-11 kernel branch in the past week.

    In short this latest build has better CP Crash recovery - which doesn't eliminate the drop outs completely but is able to recover - whereas in the builds before this update, the only way to get signal back was to reboot the phone.

    Details:

    In the P880 kernel, there is a cpwatcher.c module which its job is to monitor the failure of the CP (Communication Processor), and hook onto an interrupt trigger when this happens. In the latest check-ins bugs that prevented proper power cycling the baseband (CP) has been fixed - in addition it actually attempts to reset the CP usb mode a few times before power cycling. Note that the code explicitly switch on key back-light when CP Crashes, so if you key's backlight switches on for no reason you know CP has crashed and recovery has kicked off.

    See:
    h_t_t_p_s://github.com/CyanogenMod/lge-kernel-p880/commit/c98a8b280a28b32576a14a84eab8d71e50df4ad2#diff-913e77ec04749a4e4e086bb6bf5006dc

    With my own testing, my phone had a complete drop-out this morning when I was on a fast moving train, but after around 30 seconds the 3G signal was back and I didn't have to reboot. I checked the dmseg.log immediately and it appears it successfully power-cycled the baseband after resetting CP USB mode has failed 4 times.

    Try the latest CM11 nightly people, if you are suffering from 3G signal dropouts and only recoverable by rebooting.
    5
    Hello,
    I am running the Liquidsmooth version 3.2-2014-07-21, mourta kernel 3.1.10-cm+ september 2 2014 and I have this issue. Im loosing network signal in "3G only" mode and it doesnt recovers (it frezes). If i use device in "2G only mode" the signal does not crash, and signal almost never goes down(2 times in week).
    Devs any solution on this? RIL issue?
    Regards and sorry for bad english.

    I have your problem and after months of investigation I think I understand what the problem is - however there won't be any fix in software.

    Basically what is happening is the modem part of your P880 is crashing at random when running in 3G - if you drill down the source in the kernel you see a cpwatcher.c module, its sole purpose is to monitor the CP (communication processor - aka baseband or modem) crashing and react to it. This source initially came directly from LG and funny that I cannot find this module in newer LG models. Nevertheless, the module will go and restart the baseband when this happens, but as far as I can see this is a dodgy fix for unstable hardware.

    If you are running stock roms and tries to dial while baseband is restarting, you would see an interesting "Reorganizing internal processes" message - which is not only seen on P880 but others like the optimus 3D and L9 etc. Just Google and you'll find a lot of similar issues. You can also force this by killing the radio process of your phone (kill -9 <pid>) - you would see exactly the same thing.

    Note that this only happens in 3G mode. In 2G the phone is quite stable. The fact that LG included a cpwatcher module in the kernel tells us something - they knew there is a problem which occasionally causes the baseband to crash but they didn't bother to fix it via hardware / firmware - instead they just implemented something to restart the baseband. The bad thing about this approach is restarting the baseband can take up to 30 seconds or more and obviously your call / data connection would have been reset in the process.

    Some P880 appeared to have not affected by this problem, it could be down to the revision of the baseband (including different hardware chipset or firmware) - however many of us do and there is nothing you can do at the moment - you can try the latest CM11 where they have done a few tweaks for RIL and cpwatcher.c although I doubt anyone can fix this completely. The only hope I see is if LG releases an updated firmware that can potentially workaround the faulty hardware that prevents the baseband from crashing in the first place, this is not likely though.
    5
    In the last few days I've spent some time looking at what the EPRJ patched X3RIL is supposed to do.
    My current understanding is:

    The X3RIL patch described in this thread may actually improve or make matter worse when patched manually. I heard you ask: why is that?

    1. The EPRJ patch utilizes EPRJ specific system properties when running baseband recovery (which is what we are concerned with) - the code is a bit dodgy, it assumes the property is always there, which isn't the case in non-EPRJ based roms. However this bug is only triggered when the baseband event RIL_UNSOL_LGE_RESTART_RILD (1055) is handled. (when lgeRestartRild() is called)

    2. Comparing to the original CM10.2 code, it has better handling when RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED event is received, in particular if the Radio State has actually gone to RADIO_UNAVAILABLE, then it attempts to unload module rawip and also power-cycle the radio.

    Hence, if your original problem is (2) where the radio has gone to unavailable temporarily - then you may see improvement because it power cycles the radio and tries to recover.

    But, if your problem is baseband initiating RIL daemon restart (RIL_UNSOL_LGE_RESTART_RILD) - basically this code will fail on non EPRJ roms - it simply won't do it - worse than the original CM10.2 the patch was intended for.

    I am planning to modify the code and build a version that is compatible with CM 11 (since X3RIL has drifted since 10.2) - hopefully this will solve the radio problem that many of us are still having.
    3
    that means that roms without x3ril.smali can't have eprj ril implemented, right?

    also, beanstalk build, the first build had x3ril.smali in telephony-common.jar, while the newest build doesn't. would it be possible to use whole telephony-common.jar from first build in the second build, since it's the same rom?

    Maybe yes, maybe not. Only sources can tell. It can also happen that they have the supporting commit, but sth is derped in the device tree so it doesn't get included. However, even if the inclusion commit isn't there, the custom RIL class usage is. It must be, because all main devices use some custom RIL. So putting EPRJ RIL and setting the property would suffice.

    You can always try, but in general replacing any apk or jar is a bad idea. Even if it works for daily use you might encounter rare crashes. For example you don't everyday get cell broadcasts, but imagine what would happen if you get one in emergency (e.g. tornado) and the RIL crashes because of an unhandled exception that's caused by incompatibilities. Of course this is exaggeration, but depicts the issue fairly well. :)

    Hi @Adam77Root :D
    do you have any idea why Airplane mod is bugy in CM11 and all it's based ROM's
    when I enable Airplane mod to cut my network connect it works well but when I re-disable it it doesn't restore mobile network connection so I have to reboot and retype my PIN again to restore network connection or do it manually by going to Settings> in WIRELESS & NETWORKS "More..."> Mobile Networks> Network Operators> wait till the search is finished (takes 3 to 5 min's) and choose my network to restore connection back!!
    that is one hell of an annoying problem :(
    I didn't face it in your OmniROM (Which was absolutely awesome :D) but I switched to CM11 and it's based ROM's because of theme's feature :p currently I'm running Vanir 4.4.2 (vanir_P880_4.4.2.011814.zip) and this bug still exists. :(
    if you know something about it please help :eek:

    It's hard to tell this way. You could try one thing: Repack Omni's X3RIL following this tutorial and report.