tags:

views:

575

answers:

3

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?

+1  A: 

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

omermuhammed
+3  A: 

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.

Brutall
So no way to change the setting without root...
Lorenzo
I think no. These things are system internals.
Brutall
Even if the program uses the native C interface?
Amigable Clark Kant
What's the difference? This is about permissions, not missing APIs. You can't do that using unprivileged UID.
Brutall
A: 

Hi Why it's not possible? In fact in my HTC Hero with A Villain ROM it's working... Regards

Vlax