Feature #1779: Implement setting that allows to permanently disable the modem
Find and document a way to reliably disable the modem via shell commands.
In order to implement what's required in #1779, some docs are needed about how to achieve modem disabling under the hood.
#1 Updated by Jeremy Rand 4 months ago
Wolfgang posted some relevant info for the S3 i9300 here: https://redmine.replicant.us/boards/39/topics/13996?r=14001#message-14001
Quoting his instructions:
adb root adb remount adb shell mv /system/lib/libsamsung-ril.so /system/lib/libsamsung-ril.so.disabled
I haven't tried the instructions myself, but NS von H says they worked.
#2 Updated by Fil Bergamo 4 months ago
makes me suspect that this isn't doable from inside the phone, and needs a host computer.
But, from my understanding, what it actually does is remount the /system partition in RW mode.
So, maybe just issuing a shell command from inside the phone would do the same:
mount -o rw,remount /system
gotta give it a try...
#3 Updated by Wolfgang Wiedmeyer 4 months ago
Thanks for looking into this!
Indeed, it's possible to remount the system partition like this. Apps like AdAway do this. But this is a hack and shouldn't be done during regular operation of the device. The system partition should stay untouched if possible. It's also problematic because all changes are reverted after installing an update zip.
Moving libsamsung-ril leads to the RIL daemon not finding the vendor RIL and thus not initializing the radio. This only works on Samsung devices where libsamsung-ril is used. To have a more future-proof solution, it would be better to implement this in a way that is device-independent.Settings should be stored in the data partition if they should be permanent. I don't know if it's possible to use the settings storage that the settings app uses and make this accessible by system daemons. I guess that all of this could be implemented like this:
- Add a new setting to the settings app that says something like "Disable modem initialization"
- If the setting is selected, a file like
- When the RIL daemon is started, before loading a vendor RIL like libsamsung-ril, it checks if this file exists and exits immediately if it does.
If you choose to implement it this way, then there are more things to watch out for, but it's not important to do this right away. It's probably not possible to disable the RIL daemon and make sure that it is not started by any other process. So making changes directly to the RIL daemon like I suggested above is necessary. However, it needs to be checked if the daemon is then started over and over again and if this can be prevented somehow.
The file that stores the setting in the data partition needs to be protected. At least it needs to have a proper SELinux context and in general, it should be ensured that it can only be removed by the settings app (and root of course).
#4 Updated by Jeremy Rand 2 months ago
I have a working PoC: https://git.replicant.us/replicant/user-scripts/merge_requests/1
It's not as clean a solution as what Wolfgang suggested, but maybe it'll suffice until someone more competent than I am has time to implement Wolfgang's suggested method.
#5 Updated by Jeremy Rand about 2 months ago
Patch attached for the user-scripts repo.
#7 Updated by Wolfgang Wiedmeyer about 1 month ago
Jeremy, thanks for the patch!
Could you change the commit title to something more general to reflect that this works not only on the i9300 but all devices that use Samsung-RIL?
I'm not sure if it's necessary to include the license in a separate file. The other scripts don't have it and it could be confusing then. But this is no blocker to me.
It would be good to document the scripts in the wiki. I gave you wiki access.