安卓 : programmatically copying apk to/system/app

标签 android root android-install-apk su

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

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

  1. 我的设备已获得 root 权限。
  2. 我的“安装程序”应用程序作为系统应用程序安装。 (手动复制到/system/app)
  3. 我已经使用平台 key 签署了安装程序 apk,并且我在 list 中有 android:sharedUserId="android.uid.system"
  4. 我一直在为 Runtime.getRuntime.exec("su") 尝试(一直在尝试,然后更多)。我打算将系统分区挂载为rw,为apk做一个cat,然后制作系统分区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.
    
  5. 我已在 list 中请求 INSTALL_PACKAGES 权限。

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


请让我知道我在这里缺少什么。有人成功了吗?

谢谢!

最佳答案

我继续挖掘,结果如下:

  • Android 在 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( super 用户)和 cyanogen mod 通过实现他们自己的 su.c 来解决这个问题:https://github.com/CyanogenMod/android_system_su/blob/master/su.c

我暂时接受这个作为答案。

关于安卓 : programmatically copying apk to/system/app,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10691485/

相关文章:

android - getSize() 给我错误

android - 无法将 Android 应用程序安装为模拟器上的系统应用程序以通过 WRITE_APN_SETTINGS 的 SecurityException

java - 将数据从java发送到php文件

android - ImageView 宽度在 Nexus 4 上缩放不正确?

Python 作为根目录和/home 文件夹运行脚本

android - 尝试以编程方式从 Android 应用程序安装 APK 时出现解析错误

Android:在安装过程中设置共享首选项?

android - 安装.apk

android - 禁用/覆盖 Cordova 3.5 中的 Android 后退按钮

mysql - 如何在单表mysql中选择叶子的根