Project

General

Profile

Feature #1806

Feature #1779: Implement setting that allows to permanently disable the modem

Find and document a way to reliably disable the modem via shell commands.

Added by Fil Bergamo 6 months ago. Updated about 1 month ago.

Status:
New
Priority:
Normal
Assignee:
Category:
Telephony and mobile data
Target version:
Start date:
05/20/2017
Due date:
% Done:

0%

Resolution:
Device:

Description

In order to implement what's required in #1779, some docs are needed about how to achieve modem disabling under the hood.

0001-Added-scripts-for-disabling-and-enabling-the-i9300-m.patch View (39.6 KB) Jeremy Rand, 07/22/2017 04:09 PM

6.0-modem-v2.patch View (146 KB) Jeremy Rand, 08/20/2017 04:51 PM


Related issues

Related to Feature #1820: Do some testing on femtocells New 07/04/2017

History

#1 Updated by Jeremy Rand 6 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 6 months ago

That instruction

adb remount

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 6 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 /data/.disable_modem_boot is generated
  • 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 4 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.

Cheers!

#5 Updated by Jeremy Rand 4 months ago

Patch attached for the user-scripts repo.

#6 Updated by Fil Bergamo 4 months ago

#7 Updated by Wolfgang Wiedmeyer 3 months 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.

#8 Updated by Wolfgang Wiedmeyer 3 months ago

I just noticed that for the wifi scripts, the license is also included. It looks like everything on the replicant-6.0 branch is then GPLv3+, so the license could be moved to the root folder.

#9 Updated by Jeremy Rand 3 months ago

#10 Updated by Jeremy Rand 3 months ago

Thanks for the review Wolfgang! I've added a new patch that I think addresses your feedback.

#11 Updated by Wolfgang Wiedmeyer 3 months ago

Thanks Jeremy, pushed :)

#12 Updated by Jeremy Rand about 2 months ago

Wolfgang Wiedmeyer wrote:

It would be good to document the scripts in the wiki. I gave you wiki access.

https://redmine.replicant.us/projects/replicant/wiki/ModemDisable

Hopefully everything there is acceptable. If you think it's all okay, feel free to link to it from https://redmine.replicant.us/projects/replicant/wiki#Replicant-usage (I don't have edit privileges for that page).

#13 Updated by Wolfgang Wiedmeyer about 1 month ago

Jeremy Rand wrote:

Hopefully everything there is acceptable. If you think it's all okay, feel free to link to it from https://redmine.replicant.us/projects/replicant/wiki#Replicant-usage (I don't have edit privileges for that page).

Done. Looks good, thanks for adding the documentation!

Also available in: Atom PDF