Android:以编程方式将apk复制到/system/app [英] Android : programmatically copying apk to /system/app

查看:237
本文介绍了Android:以编程方式将apk复制到/system/app的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

到目前为止,我所做的是:

I am trying to install a system app from my java code, and so far, I haven't had any success.

Following is what I have done so far:

  1. 我的设备已植根.
  2. 我的安装程序"应用安装为系统应用.(将其手动复制到/system/app)
  3. 我已经使用平台密钥对安装程序apk进行了签名,并且清单中具有 android:sharedUserId ="android.uid.system" .
  4. 我一直在尝试(然后再尝试) Runtime.getRuntime.exec("su").我打算将系统分区安装为 rw ,对apk做 cat ,然后将系统分区设置为 ro .以下是命令列表:

  1. My device is rooted.
  2. My "installer" app is installed as a system app. (copied it manually to /system/app)
  3. I have signed the installer apk with platform key, and I have android:sharedUserId="android.uid.system" in the Manifest.
  4. I have been trying (and trying, and then some more) for Runtime.getRuntime.exec("su"). I intend to mount the system partition as rw, do a cat for the apk, and then make system partition ro. Following is the 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.

  • 我已请求清单中的 INSTALL_PACKAGES 权限.
  • 我尝试了exec(")格式的多种变体,包括对每个命令使用'su -c'.我得到了管道破裂"异常和安全性"异常.有时候,我没有例外,但是文件没有被复制.

    I have tried a number of variations of the exec("") format, including using 'su -c' with every command. I have gotten the Broken Pipe exception and Security exception. Sometimes, I don't get an exception, but the file isn't copied.


    请让我知道我在这里想念的东西.有人有这个工作吗?

    谢谢!


    Please let me know what I am missing here. Has anyone got this working?

    Thanks!

    推荐答案

    我一直在挖掘,结果如下:

    I kept on digging, and here are the results:

    • 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;
    }
    

    ChainsDD(SuperUser)和cyanogen mod通过实现自己的su.c来解决此问题:

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

    • What's special about /system/app? It seems that it is the fact that the partition is read-only on non-rooted devices, preventing modification/uninstall of applications put there. https://android.stackexchange.com/questions/17871/what-are-the-differences-between-a-system-app-and-user-app

    使用平台密钥和 sharedUserId = system 签名的应用程序对于我来说已经足够好了,我不必专门将其复制到/system/app.p>

    An app signed with platform key and with sharedUserId = system is 'good enough' for my purposes, I don't specifically have to copy it to /system/app.

    我现在接受这个作为答案.

    I am accepting this as answer for now.

    这篇关于Android:以编程方式将apk复制到/system/app的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆