Android13预装APP到data分区

修改步骤与Android11是差不多的,只是有部分代码所在位置不一样。
Android 11®内置APP到data/app
Android 8(O)预置APP到data/app

默认内置应用到data会出错

1970-01-01 08:03:54.499 1177-1177/system_process I/PackageManager: /data/app/xx changed; collecting certs

1970-01-01 08:03:54.547 1177-1177/system_process W/PackageManager: Failed to scan /data/app/xx: Application package com.benew.ntt.cloud not found; ignoring.

1970-01-01 08:03:54.547 1177-1177/system_process W/PackageManager: Deleting invalid package at /data/app/xx

userdata.img只有几十k的问题

往data中加了几百M大小的app,在out/xx/data/app中也看到编译出来了,

但是编译后却发现userdata.img只有90k,是空的分区,

在.mk中修改userdata分区大小,.mk里面默认是64M, 改成512M解决了。

patch 复制代码
diff --git a/device/sprd/mpool/module/generic/partition/main.mk b/device/sprd/mpool/module/generic/partition/main.mk
index 37b0b79d0e9..d2f2322d6b3 100755
--- a/device/sprd/mpool/module/generic/partition/main.mk
+++ b/device/sprd/mpool/module/generic/partition/main.mk
@@ -25,8 +25,8 @@ endif
 $(call md-set, BOARD_BOOTIMAGE_PARTITION_SIZE, 67108864)
 $(call md-set, BOARD_CACHEIMAGE_PARTITION_SIZE, 67108864)
 
-# default value is 64M, using resize to adapter real size
-BOARD_USERDATAIMAGE_PARTITION_SIZE ?= 67108864
+# default value is 512M, using resize to adapter real size
+BOARD_USERDATAIMAGE_PARTITION_SIZE ?= 536870912

实现

Android11中修改的是

frameworks/base/services/core/java/com/android/server/pm/PackageManagerService.java

Android 13不同,需要修改

frameworks/base/services/core/java/com/android/server/pm/InstallPackageHelper.java

注释掉

else {
                        throw new PackageManagerException(INSTALL_FAILED_INVALID_INSTALL_LOCATION,
                                "Application package " + pkg.getPackageName()
                                        + " not found; ignoring.");
                    }

完整代码如下

java 复制代码
            if ((scanFlags & SCAN_REQUIRE_KNOWN) != 0) {
                if (mPm.isExpectingBetter(pkg.getPackageName())) {
                    Slog.w(TAG, "Relax SCAN_REQUIRE_KNOWN requirement for package "
                            + pkg.getPackageName());
                } else {
                    PackageSetting known = mPm.mSettings.getPackageLPr(pkg.getPackageName());
                    if (known != null) {
                        if (DEBUG_PACKAGE_SCANNING) {
                            Log.d(TAG, "Examining " + pkg.getPath()
                                    + " and requiring known path " + known.getPathString());
                        }
                        if (!pkg.getPath().equals(known.getPathString())) {
                            throw new PackageManagerException(INSTALL_FAILED_PACKAGE_CHANGED,
                                    "Application package " + pkg.getPackageName()
                                            + " found at " + pkg.getPath()
                                            + " but expected at " + known.getPathString()
                                            + "; ignoring.");
                        }
                    } /*else {
                        throw new PackageManagerException(INSTALL_FAILED_INVALID_INSTALL_LOCATION,
                                "Application package " + pkg.getPackageName()
                                        + " not found; ignoring.");
                    }*/
                }
            }
patch 复制代码
diff --git a/system/core/init/util.cpp b/system/core/init/util.cpp
index d1e518b5795..bee7a8bb70d 100644
--- a/system/core/init/util.cpp
+++ b/system/core/init/util.cpp
@@ -485,7 +485,7 @@ static FscryptAction FscryptInferAction(const std::string& dir) {
     std::vector<std::string> directories_to_exclude = {
             "lost+found", "system_ce", "system_de", "misc_ce",     "misc_de",
             "vendor_ce",  "vendor_de", "media",     "data",        "user",
-            "user_de",    "apex",      "preloads",  "app-staging", "gsi",
+            "user_de",    "apex",      "preloads",  "app-staging", "gsi", "app",
     };
     for (const auto& d : directories_to_exclude) {
         if ((prefix + d) == dir) {
diff --git a/system/core/rootdir/init.rc b/system/core/rootdir/init.rc
index 405667cf8df..1a8bc1215eb 100644
--- a/system/core/rootdir/init.rc
+++ b/system/core/rootdir/init.rc
@@ -853,7 +853,7 @@ on post-fs-data
     mkdir /data/app-ephemeral 0771 system system encryption=Require
     mkdir /data/app-asec 0700 root root encryption=Require
     mkdir /data/app-lib 0771 system system encryption=Require
-    mkdir /data/app 0771 system system encryption=Require
+    mkdir /data/app 0771 system system encryption=None
     mkdir /data/property 0700 root root encryption=Require
 
     # create directory for updated font files.

作者:帅得不敢出门 原创文件谢绝转载收录

相关推荐
B.-1 小时前
Flutter 应用在真机上调试的流程
android·flutter·ios·xcode·android-studio
有趣的杰克1 小时前
Flutter【04】高性能表单架构设计
android·flutter·dart
大耳猫7 小时前
主动测量View的宽高
android·ui
帅次9 小时前
Android CoordinatorLayout:打造高效交互界面的利器
android·gradle·android studio·rxjava·android jetpack·androidx·appcompat
枯骨成佛10 小时前
Android中Crash Debug技巧
android
kim565915 小时前
android studio 更改gradle版本方法(备忘)
android·ide·gradle·android studio
咸芝麻鱼15 小时前
Android Studio | 最新版本配置要求高,JDK运行环境不适配,导致无法启动App
android·ide·android studio
无所谓จุ๊บ15 小时前
Android Studio使用c++编写
android·c++
csucoderlee16 小时前
Android Studio的新界面New UI,怎么切换回老界面
android·ui·android studio
kim565916 小时前
各版本android studio下载地址
android·ide·android studio