Android: software copy apk to / system / app

I am trying to install a system application from my java code, and so far I have not had any success.

Below is what I have done so far:

  • My device is rooted.
  • The installer application is installed as a system application. (copied it manually to / system / app)
  • I signed the apk installer with the platform key, and I have android:sharedUserId="android.uid.system" in the manifest.
  • I tried (and tried, and then again) for Runtime.getRuntime.exec("su") . I intend to set the system partition as rw , make cat for apk, and then make the system partition ro . The following is a list of commands:

     mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system<br> cat /sdcard/application.apk > /system/app/application.apk<br> mount -o remount,ro -t yaffs2 /dev/block/mtdblock3 /system<br><br>The application.apk here is the app being installed from the installer app. This app is also signed with platform key, and has the sharedUserId configured. 
  • I requested INSTALL_PACKAGES permission in the manifest.

I tried several options for the exec ("") format, including using 'su -c' with each command. I got a Broken Pipe exception and a security exception. Sometimes I do not get an exception, but the file is not copied.


Please let me know what I'm missing here. Has anyone got this job?

Thanks!

+7
source share
1 answer

I continued to dig, and here are the results:

  • Android has this check in su.c: ["root of android source" /system/extras/su/su.c]
 /* Until we have something better, only root and the shell can use su.*/ myuid = getuid(); if (myuid != AID_ROOT && myuid != AID_SHELL) { fprintf(stderr,"su: uid %d not allowed to su\n", myuid); return 1; } 

ChainsDD (SuperUser) and cyanogen mod will do this by implementing their own su.c: https://github.com/CyanogenMod/android_system_su/blob/master/su.c

I accept this as an answer for now.

+4
source

All Articles