3

I'm trying to write an app that can turn my mobile data connection on and off. Already got the source and built my own sdk, where I removed the @hide statements so I can use the relevant function

cm = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);
cm.setMobileDataEnabled(true);

Also found out which permissions I need, in particular WRITE_SECURE_SETTINGS, which is only available to system apps. I read adamk's comment and now need to know how to do what he suggested (add the app to system or sign it with the platform key).

At first I would like to do that on the emulator only, and then on my phone (which is rooted and using a custom ROM). I tried pushing it to the system directory on the emulator:

adb remount
adb push app.apk /system/app/
adb sync

which did not work, the app was not found and installed.

What did I forget? How is the proper way to do this?

Community
  • 1
  • 1
sheepd
  • 61
  • 1
  • 7

1 Answers1

3

So, I finally found the problem and solved it. I was actually quite close:

adb remount
adb push app.apk /system/app/

This is the correct way to do it on the emulator (no adb sync needed). I watched the logcat, and found out that you need to sign your .apk file so the system does not reject it, even if that does not add any validity in this case. If you push a signed .apk this way, it will get the needed permissions and work as expected — in my case, turning the mobile data connection on and off. For the phone part (using ClockworkMod): Boot into recovery mode, mount the /system folder and enable USB storage. Then proceed in the same way as with the emulator, reboot the phone, and you are good to go. Hope this helps someone who encounters the same problem.

sheepd
  • 61
  • 1
  • 7