Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detecting and changing programmatically data connection (GPRS/UMTS) on Android

Tags:

android

gprs

I know that unfortunately detecting and changing programmatically data connection (GPRS/UMTS) on vanilla Android is not possible, and the common workaround is to edit APN settings. This is hardly a nice solution.

However on my device (Xperia X10) I have an additional setting near "data roaming", that allows to enable or disable MMS and data. I suppose that this is a personalization made by Sony Ericsson, and maybe even other vendors have something like this. Is there a way to access this setting?

like image 433
lornova Avatar asked Jun 14 '10 09:06

lornova


2 Answers

I don't have SE phone, but I've looked into its system dump and:

  • In AOSP sources there are two internal methods in com.android.internal.telephony interface: enableDataConnectivity() and disableDataConnectivity(). This interface and its implementation is a part of the system.
  • There are also two methods with same names as above in com.android.phone.PhoneInterfaceManager which is a part of Phone.apk app. These methods just call above/system ones.
  • Sony modified com.android.phone.PhoneInterfaceManager.enableDataConnectivity(), so it does additional check for boolean stored in sharedPreferences. If it's false, then enableDataConnectivity() method always calls disableDataConnectivity() of com.android.internal.telephony .
  • Of course this boolean is controlled through preferences screen: "MMS & data". It's stored in "com.android.phone_preferences" preferences container and pref key is: "data_service_key". Additionally when you switch this checkbox, settings activity automatically calls methods from com.android.internal.telephony to switch data state immediately.

If you want to add data connection widget or something like that to your rom, then:

  • You need root.
  • You need "android.uid.phone" sharedUserId to access above settings.

I think it would be best to modify Phone.apk, so it will catch special intent to enable/disable data. It would set data_service_key boolean and call one of methods from com.android.internal.telephony. This should be quite easy thing to do and then you will be able to create widgets, apps and other stuff very easily - they would use that special intent.

like image 187
broot Avatar answered Oct 30 '22 21:10

broot


Have you looked at SE developer zone? I found it to be pretty useful.

like image 1
omermuhammed Avatar answered Oct 30 '22 20:10

omermuhammed