Android:以编程方式将apk复制到/ system/app

Cha*_*nya 7 android root su android-install-apk

我正在尝试从我的java代码安装系统应用程序,到目前为止,我还没有取得任何成功.

以下是我到目前为止所做的事情:

  1. 我的设备扎根了.
  2. 我的"安装程序"应用程序安装为系统应用程序.(手动将其复制到/ system/app)
  3. 我用平台密钥签署了安装程序apk,我android:sharedUserId="android.uid.system"在Manifest中.
  4. 我一直在努力(尝试,然后再尝试一些)Runtime.getRuntime.exec("su").我打算挂载系统分区rw,cat为apk 做一个,然后进行系统分区ro.以下是命令列表:

    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.
    
    Run Code Online (Sandbox Code Playgroud)
  5. 我已要求INSTALL_PACKAGES清单中的许可.

我尝试了许多exec("")格式的变体,包括使用'su -c'每个命令.我得到了Broken Pipe异常和安全异常.有时,我没有得到异常,但文件未被复制.


请让我知道我在这里缺少什么.有人有这个工作吗?

谢谢!

Cha*_*nya 4

我继续挖掘,结果如下:

  • Android 在 su.c 中有此检查:[“android 源的根目录”/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;
}
Run Code Online (Sandbox Code Playgroud)

ChainsDD(超级用户)和cyanogen mod通过实现自己的su.c来解决这个问题:https://github.com/CyanogenMod/android_system_su/blob/master/su.c

我现在接受这个答案。