RK356X android13 预安装第三方apk失败比如chrome浏览器

刚接触13,客户需求出厂时要内置指定的APK到系统中,按照之前android11的方法内置,一直失败,我编译的是userdebug模式,也没有错误提示,没有相关avc权限缺失。

后面我编译了eng模式,才发现问题所在,13有预安装配置策略,不是所有的用户都可以预安装上。eng模式下log输出

06-17 07:45:06.077 W/PackageManager(  496): Skipping preparing app data for com.android.sdksandbox
06-17 07:45:06.090 W/UserSystemPackageInstaller(  496): checkWhitelistedSystemPackages(mode=d) has 52 warnings:
06-17 07:45:06.090 W/UserSystemPackageInstaller(  496): com.android.theme.color.amethyst is allowlisted but not present.
06-17 07:45:06.091 W/UserSystemPackageInstaller(  496): com.android.theme.icon.pebble is allowlisted but not present.
06-17 07:45:06.091 W/UserSystemPackageInstaller(  496): com.android.theme.color.sand is allowlisted but not present.
06-17 07:45:06.091 W/UserSystemPackageInstaller(  496): com.android.theme.icon.vessel is allowlisted but not present.
06-17 07:45:06.091 W/UserSystemPackageInstaller(  496): com.android.theme.color.cinnamon is allowlisted but not present.
06-17 07:45:06.091 W/UserSystemPackageInstaller(  496): com.android.theme.icon_pack.victor.settings is allowlisted but not present.
06-17 07:45:06.092 W/UserSystemPackageInstaller(  496): com.android.theme.icon_pack.rounded.systemui is allowlisted but not present.
06-17 07:45:06.092 W/UserSystemPackageInstaller(  496): com.android.theme.icon.taperedrect is allowlisted but not present.
06-17 07:45:06.092 W/UserSystemPackageInstaller(  496): com.android.theme.icon_pack.rounded.android is allowlisted but not present.
06-17 07:45:06.092 W/UserSystemPackageInstaller(  496): com.android.internal.systemui.onehanded.gestural is allowlisted but not present.
06-17 07:45:06.092 W/UserSystemPackageInstaller(  496): com.android.theme.icon_pack.victor.systemui is allowlisted but not present.
06-17 07:45:06.092 W/UserSystemPackageInstaller(  496): com.android.theme.icon_pack.circular.themepicker is allowlisted but not present.
06-17 07:45:06.093 W/UserSystemPackageInstaller(  496): com.android.theme.color.tangerine is allowlisted but not present.
06-17 07:45:06.093 W/UserSystemPackageInstaller(  496): com.android.theme.color.aquamarine is allowlisted but not present.
06-17 07:45:06.093 W/UserSystemPackageInstaller(  496): com.android.theme.color.black is allowlisted but not present.
06-17 07:45:06.093 W/UserSystemPackageInstaller(  496): com.android.theme.color.green is allowlisted but not present.
06-17 07:45:06.093 W/UserSystemPackageInstaller(  496): com.android.theme.color.ocean is allowlisted but not present.
06-17 07:45:06.093 W/UserSystemPackageInstaller(  496): com.android.theme.color.space is allowlisted but not present.
06-17 07:45:06.093 W/UserSystemPackageInstaller(  496): com.android.theme.icon_pack.rounded.launcher is allowlisted but not present.
06-17 07:45:06.094 W/UserSystemPackageInstaller(  496): com.android.theme.icon_pack.kai.settings is allowlisted but not present.
06-17 07:45:06.094 W/UserSystemPackageInstaller(  496): com.android.internal.systemui.navbar.twobutton is allowlisted but not present.
06-17 07:45:06.094 W/UserSystemPackageInstaller(  496): com.android.theme.icon_pack.sam.settings is allowlisted but not present.
06-17 07:45:06.094 W/UserSystemPackageInstaller(  496): com.android.theme.icon_pack.kai.themepicker is allowlisted but not present.
06-17 07:45:06.094 W/UserSystemPackageInstaller(  496): com.android.theme.icon_pack.victor.launcher is allowlisted but not present.
06-17 07:45:06.095 W/UserSystemPackageInstaller(  496): com.android.theme.icon_pack.filled.settings is allowlisted but not present.
06-17 07:45:06.095 W/UserSystemPackageInstaller(  496): com.android.theme.icon_pack.kai.systemui is allowlisted but not present.
06-17 07:45:06.095 W/UserSystemPackageInstaller(  496): com.android.theme.icon_pack.circular.settings is allowlisted but not present.
06-17 07:45:06.095 W/UserSystemPackageInstaller(  496): com.android.theme.icon_pack.sam.systemui is allowlisted but not present.
06-17 07:45:06.096 W/UserSystemPackageInstaller(  496): com.android.theme.icon.teardrop is allowlisted but not present.
06-17 07:45:06.097 W/UserSystemPackageInstaller(  496): com.android.theme.icon_pack.rounded.themepicker is allowlisted but not present.
06-17 07:45:06.097 W/UserSystemPackageInstaller(  496): com.android.theme.icon_pack.filled.systemui is allowlisted but not present.
06-17 07:45:06.097 W/UserSystemPackageInstaller(  496): com.android.theme.icon_pack.sam.android is allowlisted but not present.
06-17 07:45:06.097 W/UserSystemPackageInstaller(  496): com.android.theme.icon_pack.filled.android is allowlisted but not present.
06-17 07:45:06.097 W/UserSystemPackageInstaller(  496): com.android.theme.icon_pack.circular.systemui is allowlisted but not present.
06-17 07:45:06.097 W/UserSystemPackageInstaller(  496): com.android.theme.icon_pack.kai.android is allowlisted but not present.
06-17 07:45:06.097 W/UserSystemPackageInstaller(  496): com.android.theme.icon_pack.kai.launcher is allowlisted but not present.
06-17 07:45:06.097 W/UserSystemPackageInstaller(  496): com.android.wallpaper.livepicker is allowlisted but not present.
06-17 07:45:06.097 W/UserSystemPackageInstaller(  496): com.android.theme.icon_pack.sam.launcher is allowlisted but not present.
06-17 07:45:06.098 W/UserSystemPackageInstaller(  496): com.android.theme.icon.squircle is allowlisted but not present.
06-17 07:45:06.098 W/UserSystemPackageInstaller(  496): com.android.theme.icon_pack.victor.android is allowlisted but not present.
06-17 07:45:06.098 W/UserSystemPackageInstaller(  496): com.android.theme.color.palette is allowlisted but not present.
06-17 07:45:06.098 W/UserSystemPackageInstaller(  496): com.android.theme.icon_pack.filled.launcher is allowlisted but not present.
06-17 07:45:06.099 W/UserSystemPackageInstaller(  496): com.android.theme.color.carbon is allowlisted but not present.
06-17 07:45:06.099 W/UserSystemPackageInstaller(  496): com.android.theme.icon_pack.circular.launcher is allowlisted but not present.
06-17 07:45:06.099 W/UserSystemPackageInstaller(  496): com.android.theme.icon_pack.filled.themepicker is allowlisted but not present.
06-17 07:45:06.099 W/UserSystemPackageInstaller(  496): com.android.theme.icon_pack.victor.themepicker is allowlisted but not present.
06-17 07:45:06.099 W/UserSystemPackageInstaller(  496): com.android.theme.color.orchid is allowlisted but not present.
06-17 07:45:06.099 W/UserSystemPackageInstaller(  496): com.android.theme.color.purple is allowlisted but not present.
06-17 07:45:06.100 W/UserSystemPackageInstaller(  496): com.android.theme.icon_pack.sam.themepicker is allowlisted but not present.
06-17 07:45:06.100 W/UserSystemPackageInstaller(  496): com.android.theme.icon.roundedrect is allowlisted but not present.
06-17 07:45:06.100 W/UserSystemPackageInstaller(  496): com.android.theme.icon_pack.rounded.settings is allowlisted but not present.
06-17 07:45:06.100 W/UserSystemPackageInstaller(  496): com.android.theme.icon_pack.circular.android is allowlisted but not present.
06-17 07:45:06.100 I/UserSystemPackageInstaller(  496): Reviewing whitelisted packages due to [firstBoot]
06-17 07:45:06.107 I/UserSystemPackageInstallerCommitDebug(  496): Uninstalled XXXXX for user 0

XXX unistalled for user 0,UserSystemPackageInstaller 在看这个log输出,应该是有配置的地方才能内置。查看Google文档有了答案

预安装系统软件包  |  Android 开源项目  |  Android Open Source Project

Android 支持在一台设备上添加多个用户。由于并非所有系统软件包都适用于所有类型的 Android 用户,因此您可以使用许可名单指定应为每种类型的用户预安装哪些系统软件包。避免预安装不必要的系统软件包,这样就可以优化用户创建次数、启动次数和内存用量。

解决方案

1、可以把许可名单配置功能关闭

<integer name="config_userTypePackageWhitelistMode">0</integer>

2、根据规则配置需要内置apk的权限

frameworks/base/data/etc/preinstalled-packages-platform-overlays.xml添加

<install-in-user-type package="com.android.example">
    <install-in user-Type="SYSTEM" />
    <install-in user-type="FULL" />
    <install-in user-type="PROFILE" />
</install-in-user-type>
#增加了之后发现log提示
com.android.chrome is allowlisted and present but not a system package

apk还是没有安装上去

查看代码UserSystemPackageInstaller.java
@Nullable Set<String> getInstallablePackagesForUserType(String userType) {
        final int mode = getWhitelistMode();
        if (!isEnforceMode(mode)) {
            return null;
        }
        final boolean implicitlyWhitelist = isImplicitWhitelistMode(mode)
                || (isImplicitWhitelistSystemMode(mode) && mUm.isUserTypeSubtypeOfSystem(userType));
        final Set<String> whitelistedPackages = getWhitelistedPackagesForUserType(userType);

        final Set<String> installPackages = new ArraySet<>();
        final PackageManagerInternal pmInt = LocalServices.getService(PackageManagerInternal.class);
        pmInt.forEachPackage(pkg -> {
            if (!pkg.isSystem()) { # 此处判断系统app才可以安装
               return;
            }
            if (shouldInstallPackage(pkg, mWhitelistedPackagesForUserTypes,
                    whitelistedPackages, implicitlyWhitelist)) {
                // Although the allowlist uses manifest names, this function returns packageNames.
                installPackages.add(pkg.getPackageName());
            }
        });
        return installPackages;
    }


把UserSystemPackageInstaller.java 里面isSystem() 限制去掉就可以了。

有时间就需要多看看google的官方文档,要不然都不清楚是被哪里限制了。

  • 3
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

开开心心everyday

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值