Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 10234269 authored by Joanne Chung's avatar Joanne Chung
Browse files

Fix SdkSandboxStorageHostTest

When the feature is enabled, the system doesn’t give app id if the
installed package is a sdk library. The Settings writePackageLPr()
will write the appIds to xml, it will read these appIds when booting.
The system will ignore appid -1 to create packageSetting that causes
the app dependent on this sdk-library be removed. The permission
service is also NPE because this app is removed.

Try to write a flag to help indentify if the system needs to create
PackageSettungs for sdk library.

Bug: 314772888
Test: atest SdkSandboxStorageHostTest
Change-Id: Ib53e775db123d0008948f1c2a1702bdaa0a47b76
parent 70ce23b0
Loading
Loading
Loading
Loading
+9 −1
Original line number Original line Diff line number Diff line
@@ -41,6 +41,7 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.content.IntentFilter;
import android.content.pm.ActivityInfo;
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.Flags;
import android.content.pm.IntentFilterVerificationInfo;
import android.content.pm.IntentFilterVerificationInfo;
import android.content.pm.PackageInstaller;
import android.content.pm.PackageInstaller;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager;
@@ -62,6 +63,7 @@ import android.os.Handler;
import android.os.Message;
import android.os.Message;
import android.os.PatternMatcher;
import android.os.PatternMatcher;
import android.os.PersistableBundle;
import android.os.PersistableBundle;
import android.os.Process;
import android.os.SELinux;
import android.os.SELinux;
import android.os.SystemClock;
import android.os.SystemClock;
import android.os.Trace;
import android.os.Trace;
@@ -3168,6 +3170,9 @@ public final class Settings implements Watchable, Snappable, ResilientAtomicFile
            pkg.isScannedAsStoppedSystemApp());
            pkg.isScannedAsStoppedSystemApp());
        if (!pkg.hasSharedUser()) {
        if (!pkg.hasSharedUser()) {
            serializer.attributeInt(null, "userId", pkg.getAppId());
            serializer.attributeInt(null, "userId", pkg.getAppId());

            serializer.attributeBoolean(null, "isSdkLibrary",
                    pkg.getAndroidPackage() != null && pkg.getAndroidPackage().isSdkLibrary());
        } else {
        } else {
            serializer.attributeInt(null, "sharedUserId", pkg.getAppId());
            serializer.attributeInt(null, "sharedUserId", pkg.getAppId());
        }
        }
@@ -4018,10 +4023,12 @@ public final class Settings implements Watchable, Snappable, ResilientAtomicFile
        int targetSdkVersion = 0;
        int targetSdkVersion = 0;
        byte[] restrictUpdateHash = null;
        byte[] restrictUpdateHash = null;
        boolean isScannedAsStoppedSystemApp = false;
        boolean isScannedAsStoppedSystemApp = false;
        boolean isSdkLibrary = false;
        try {
        try {
            name = parser.getAttributeValue(null, ATTR_NAME);
            name = parser.getAttributeValue(null, ATTR_NAME);
            realName = parser.getAttributeValue(null, "realName");
            realName = parser.getAttributeValue(null, "realName");
            appId = parseAppId(parser);
            appId = parseAppId(parser);
            isSdkLibrary = parser.getAttributeBoolean(null, "isSdkLibrary", false);
            sharedUserAppId = parseSharedUserAppId(parser);
            sharedUserAppId = parseSharedUserAppId(parser);
            codePathStr = parser.getAttributeValue(null, "codePath");
            codePathStr = parser.getAttributeValue(null, "codePath");


@@ -4136,7 +4143,8 @@ public final class Settings implements Watchable, Snappable, ResilientAtomicFile
                PackageManagerService.reportSettingsProblem(Log.WARN,
                PackageManagerService.reportSettingsProblem(Log.WARN,
                        "Error in package manager settings: <package> has no codePath at "
                        "Error in package manager settings: <package> has no codePath at "
                                + parser.getPositionDescription());
                                + parser.getPositionDescription());
            } else if (appId > 0) {
            } else if (appId > 0 || (appId == Process.INVALID_UID && isSdkLibrary
                    && Flags.disallowSdkLibsToBeApps())) {
                packageSetting = addPackageLPw(name.intern(), realName, new File(codePathStr),
                packageSetting = addPackageLPw(name.intern(), realName, new File(codePathStr),
                        appId, pkgFlags, pkgPrivateFlags, domainSetId);
                        appId, pkgFlags, pkgPrivateFlags, domainSetId);
                if (PackageManagerService.DEBUG_SETTINGS)
                if (PackageManagerService.DEBUG_SETTINGS)