0

I need to open android device's data connection in my app. My phone is rooted, and its system is android 2.3.5. Unfortunately, the following fails:

// open data connection
Class telephonyManagerClz=TelephonyManager.class;
Method mGetITelephony=telephonyManagerClz
        .getDeclaredMethod("getITelephony");
mGetITelephony.setAccessible(true);
Object iTelephony = mGetITelephony.invoke(tm);
Method mEnableDataConn=iTelephony.getClass()
        .getDeclaredMethod("enableDataConnectivity");
mEnableDataConn.setAccessible(true);
mEnableDataConn.invoke(iTelephony);

This is the exception displayed in logcat: enter image description here

It seems that I don't have the MODIFY_PHONE_STATE permission, but I've added it into Manifest.xml yet. What could be the problem?

Paul Lammertsma
  • 37,593
  • 16
  • 136
  • 187
monk
  • 228
  • 2
  • 10

2 Answers2

0

android.permission.MODIFY_PHONE_STATE is a reserved permission. You can only use system permissions if your application is signed with the system certificate.

During the installation of your app you should see a warning from the PackageManager that the permission was revoked.

Although I'm not entirely familiar with overriding permission restrictions on rooted devices, if you haven't built your system from source, it's unlikely that you have the certificate and the system will simply continue to revoke your permission. I believe it's simply not possible to sign your app to use it.

Paul Lammertsma
  • 37,593
  • 16
  • 136
  • 187
0

I've found the best solution Visit http://my.oschina.net/u/578360/blog/198466

monk
  • 228
  • 2
  • 10