Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Restart radio programmatically

Every now and then, the radio of my android phone silently dies because of some network related issues. On the Nexus 4, it shows the empty triangle as if there where no service available in this area. On other phones it does not even do that. It looks like signal is fine.

Anyway, after the radio died silently no phone call / text message / data is going through in any direction. The only hint I get from the System is the android.net.conn.CONNECTIVITY_CHANGE broadcast fired when the signal dies and wifi is not connected.

The only thing, that fixes the problem is restarting the phone.

Finally my question:

Does anybody know how to restart the radio completely by code?

I mean, it is a separate image running on a separate CPU. There must be a way to reboot it without rebooting the phone. Maybe there is something, I can path into the Android ROM. I'm running CM here and be happy to patch it (again).

I tried fixing it by launching a system app by pressing *#*#4636#*#* on the dailer and stopping the radio and starting it again. But it did not help at all.

I recently made an app that checks the radio every time the connection changes. It shows a simple notification that tells me, I should reboot my phone. [1]

Issues reproduced on:

  • LG Nexus 4
  • Samsung ACE 2
  • multiple Apple iPhone 4*

Issues not reproduced on:

  • Apple iPhone 5

All phones running in the Dialog.lk network.

[1] https://github.com/felixb/network-checker

like image 841
flx Avatar asked Sep 06 '13 03:09

flx


2 Answers

On a rooted device, one can issue the pkill command for all processes running as the user radio. I tested this on a Oneplus 3. The system seems to immediately restart the service:

pkill -u radio

like image 175
Joel G Mathew Avatar answered Nov 05 '22 12:11

Joel G Mathew


Yes it is possible, but it will be difficult to perform on device without a deep understanding of the modem communications code of which multiple versions exist and even that will be dependent on if the system will permit you to even perform the communications on device.

The only one I am aware of that you can fully manipulate on device at this time is Qualcomm's (Qualcomm is standard in the majority of devices, but Samsung has used VIA in some cases which is a whole different monster, and even still another chipset or two exist), but to even be able to perform what your asking with Qualcomm's chipset, the following must be true:

  1. The device must be rooted.
  2. The application must have root access.
  3. The system ROM must have the ability to place the cellular radio into modem diagnostics mode.
  4. The device must have the appropriate permissions to permit the access.

At this point most people would connect their computer to their device and manipulate the cellular radio using QPST, CDMAWare, or QXDM. Options available to those users include everything from manipulating cellular subscriber data to restarting the cellular modem.

But, this is where things get tricky, you need to be be able to access this from the device side, which depending on the device, the operating system, and the configuration of it...may very well not be possible.

Also your application must be able to communicate with the cellular radio using the special protocol that the applications above use to do their communications which will require you becoming intimately familiar with that specification. The whitepaper for the Qualcomm diagnostics protocol is floating around on the web if you look hard enough for it.

Also on the not so cool side, if your application has access to the radio...so does any other rooted application (or even non-rooted, if you don't set the device permissions correctly) thus enabling rouge applications the ability to change your radio's configuration data potentially even bricking your device (which I have seen people do using the applications named above).

So my answer is Yes, you can do it, although:

  • Depending on your device you may not be able to, you should be well prepared to study and develop the needed tools to perform what you are wanting to do
  • No quick-start guide exist to be followed
  • Remember that you do so in the knowledge that your device could potentially be bricked either by a mistake in your coding or by a rouge application.
  • Rebooting the radio, as you have done in the device menus, may not help your problem, you may still require a device reboot

My advice is to use a much easier method and include a timer with automatic reboot in your current application, it is much safer, won't brick your device, and you won't have to become a cellular engineer to figure out how to accomplish it.

Your timer could begin counting down when the radio dies, and provide you an option to stop the reboot if your doing something important, otherwise it would restart your device and all would be ready when you reached for it to make a call or check your email.

Hopefully I was able to help, even though I know this is not the answer that you wanted.

Side note, if you could hijack Android's system configuration menus from an outside application you could potentially manipulate the radio state using the same methods used in Android...but you already discovered that restarting the radio in this method does not help your situation. Plus Android is designed to prevent such manipulation to prevent malicious applications from overtaking the UI of other apps and the system.

like image 1
Joshua Briefman Avatar answered Nov 05 '22 14:11

Joshua Briefman