首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >AOSP中的Ota更新

AOSP中的Ota更新
EN

Stack Overflow用户
提问于 2016-06-09 12:48:11
回答 3查看 3.8K关注 0票数 3

我一直在尝试做一个自定义ROM在android。到目前为止,我已经成功地在Nexus 4中进行了修改和闪现。但我的主要目标是向我的ROM提供太田章男的更新。现在,我可以使用亚行副业用update.zip更新设备,现在我希望它通过一个系统应用程序自动完成。为此,我制作了一个系统应用程序,可以从我的服务器下载update.zip。我没有取得任何进展就浏览了这个链接:Android开发RecoverySystem.installPackage()不能写入/缓存/恢复/命令权限被拒绝

我在Asynctask中使用了以下代码来安装更新:

代码语言:javascript
运行
复制
    File update = new File("/data/update.zip");
    try {
        RecoverySystem.installPackage(mContext, update);
    } catch (IOException e) {
        e.printStackTrace();
    }

但我得到了以下错误:

代码语言:javascript
运行
复制
    W/RecoverySystem( 3900): !!! REBOOTING TO INSTALL /data/update.zip !!!
    W/System.err( 3900): java.io.FileNotFoundException: /cache/recovery/command: open failed: ENOENT (No such file or directory)
    W/System.err( 3900):    at libcore.io.IoBridge.open(IoBridge.java:456)
    W/System.err( 3900):    at java.io.FileOutputStream.<init>(FileOutputStream.java:87)
    W/System.err( 3900):    at java.io.FileOutputStream.<init>(FileOutputStream.java:72)
    W/System.err( 3900):    at java.io.FileWriter.<init>(FileWriter.java:42)
    W/System.err( 3900):    at android.os.RecoverySystem.bootCommand(RecoverySystem.java:454)
    W/com.test.ota( 3966): type=1400 audit(0.0:8): avc: denied { write } for comm=4173796E635461736B202331 name="/" dev="mmcblk0p22" ino=2 scontext=u:r:system_app:s0 tcontext=u:object_r:cache_file:s0 tclass=dir

让我困惑的是,当我下载时,我能够访问数据目录(这是普通应用程序无法访问的),但是我无法访问/cache。

在访问/cache时,我应该如何处理才能不被拒绝系统应用程序的许可?

我的清单文件是:

代码语言:javascript
运行
复制
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:sharedUserId="android.uid.system"
xmlns:tools="http://schemas.android.com/tools"
package="com.test.ota">

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.ACCESS_SUPERUSER" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission
    android:name="android.permission.ACCESS_CACHE_FILESYSTEM"
    tools:ignore="ProtectedPermissions"/>
<uses-permission
    android:name="android.permission.DELETE_CACHE_FILES"
    tools:ignore="ProtectedPermissions"/>
<uses-permission
    android:name="android.permission.REBOOT"
    tools:ignore="ProtectedPermissions" />
<uses-permission android:name="android.permission.RECOVERY" />

顺便说一下,我的构建分支是android-5.1.1_r19

更新1:使用full_mako构建的。所以,我在亚行有需要的时候就有苏了。在亚行shell中,当我尝试在su之后创建cache/recovery/command时,它允许我创建文件。但是通过app,它不允许我在cache/recovery/中创建文件,即使它的系统应用程序。我不希望用户仅仅为了安装ota更新而将手机作为根根。仍然有同样的问题。

EN

Stack Overflow用户

发布于 2016-11-04 20:07:32

尽管您可以以系统用户的身份读取对缓存文件系统的访问权限,但您需要修改Linux,以便系统用户可以对/cache分区进行写入访问。

将以下内容添加到external/sepolicy/system_app.te文件中

代码语言:javascript
运行
复制
allow system_app cache_file:dir create_dir_perms;
allow system_app cache_file:file create_file_perms;

然后重新构建,您就不应该再次出现此错误:)

票数 7
EN
查看全部 3 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37726455

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档