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

Commit 3ff19833 authored by Alex Buynytskyy's avatar Alex Buynytskyy Committed by Android (Google) Code Review
Browse files

Merge changes from topics "activity info", "archive state" into main

* changes:
  Provide archive state for archived installation.
  Add archived activity info for archive package install.
parents 1e6ce457 1e9cecac
Loading
Loading
Loading
Loading
+25 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.content.pm;

/** @hide */
parcelable ArchivedActivityParcel {
    String title;
    // PNG compressed bitmaps.
    byte[] iconBitmap;
    byte[] monochromeIconBitmap;
}
+2 −2
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.content.pm;

import android.content.pm.ArchivedActivityParcel;
import android.content.pm.SigningDetails;

/**
@@ -29,9 +30,8 @@ parcelable ArchivedPackageParcel {
    int versionCode;
    int versionCodeMajor;
    int targetSdkVersion;
    String backupAllowed;
    String defaultToDeviceProtectedStorage;
    String requestLegacyExternalStorage;
    String userDataFragile;
    String clearUserDataOnFailedRestoreAllowed;
    ArchivedActivityParcel[] archivedActivities;
}
+1 −1
Original line number Diff line number Diff line
@@ -832,5 +832,5 @@ interface IPackageManager {

    void unregisterPackageMonitorCallback(IRemoteCallback callback);

    ArchivedPackageParcel getArchivedPackage(in String apkPath);
    ArchivedPackageParcel getArchivedPackage(in String packageName, int userId);
}
+10 −86
Original line number Diff line number Diff line
@@ -23,11 +23,9 @@ import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.SigningDetails;
import android.content.pm.VerifierInfo;
import android.os.Build;

import com.android.internal.util.CollectionUtils;
import com.android.internal.util.DataClass;
import com.android.internal.util.XmlUtils;

import java.util.List;
import java.util.Set;
@@ -142,32 +140,9 @@ public class ApkLite {
    private final boolean mIsSdkLibrary;

    /**
     *  Set to <code>false</code> if the application does not wish to permit any OS-driven
     *  backups of its data; <code>true</code> otherwise.
     * Archival install info.
     */
    private final boolean mBackupAllowed;

    /**
     * When set, the default data storage directory for this app is pointed at
     * the device-protected location.
     */
    private final boolean mDefaultToDeviceProtectedStorage;

    /**
     * If {@code true} this app requests full external storage access.
     */
    private final boolean mRequestLegacyExternalStorage;

    /**
     * Indicates whether this application has declared its user data as fragile, causing the
     * system to prompt the user on whether to keep the user data on uninstall.
     */
    private final boolean mUserDataFragile;

    /**
     * Indicates whether this application's data will be cleared on a failed restore.
     */
    private final boolean mClearUserDataOnFailedRestoreAllowed;
    private final @Nullable ArchivedPackageParcel mArchivedPackage;

    public ApkLite(String path, String packageName, String splitName, boolean isFeatureSplit,
            String configForSplit, String usesSplitName, boolean isSplitRequired, int versionCode,
@@ -179,10 +154,7 @@ public class ApkLite {
            String requiredSystemPropertyName, String requiredSystemPropertyValue,
            int minSdkVersion, int targetSdkVersion, int rollbackDataPolicy,
            Set<String> requiredSplitTypes, Set<String> splitTypes,
            boolean hasDeviceAdminReceiver, boolean isSdkLibrary, boolean clearUserDataAllowed,
            boolean backupAllowed, boolean defaultToDeviceProtectedStorage,
            boolean requestLegacyExternalStorage, boolean userDataFragile,
            boolean clearUserDataOnFailedRestoreAllowed) {
            boolean hasDeviceAdminReceiver, boolean isSdkLibrary) {
        mPath = path;
        mPackageName = packageName;
        mSplitName = splitName;
@@ -216,11 +188,7 @@ public class ApkLite {
        mRollbackDataPolicy = rollbackDataPolicy;
        mHasDeviceAdminReceiver = hasDeviceAdminReceiver;
        mIsSdkLibrary = isSdkLibrary;
        mBackupAllowed = backupAllowed;
        mDefaultToDeviceProtectedStorage = defaultToDeviceProtectedStorage;
        mRequestLegacyExternalStorage = requestLegacyExternalStorage;
        mUserDataFragile = userDataFragile;
        mClearUserDataOnFailedRestoreAllowed = clearUserDataOnFailedRestoreAllowed;
        mArchivedPackage = null;
    }

    public ApkLite(String path, ArchivedPackageParcel archivedPackage) {
@@ -257,16 +225,7 @@ public class ApkLite {
        mRollbackDataPolicy = 0;
        mHasDeviceAdminReceiver = false;
        mIsSdkLibrary = false;
        // @see ParsingPackageUtils#parseBaseAppBasicFlags
        mBackupAllowed = XmlUtils.convertValueToBoolean(archivedPackage.backupAllowed, true);
        mDefaultToDeviceProtectedStorage = XmlUtils.convertValueToBoolean(
                archivedPackage.defaultToDeviceProtectedStorage, false);
        mRequestLegacyExternalStorage = XmlUtils.convertValueToBoolean(
                archivedPackage.requestLegacyExternalStorage,
                mTargetSdkVersion < Build.VERSION_CODES.Q);
        mUserDataFragile = XmlUtils.convertValueToBoolean(archivedPackage.userDataFragile, false);
        mClearUserDataOnFailedRestoreAllowed = XmlUtils.convertValueToBoolean(
                archivedPackage.clearUserDataOnFailedRestoreAllowed, true);
        mArchivedPackage = archivedPackage;
    }

    /**
@@ -576,53 +535,18 @@ public class ApkLite {
    }

    /**
     *  Set to <code>false</code> if the application does not wish to permit any OS-driven
     *  backups of its data; <code>true</code> otherwise.
     */
    @DataClass.Generated.Member
    public boolean isBackupAllowed() {
        return mBackupAllowed;
    }

    /**
     * When set, the default data storage directory for this app is pointed at
     * the device-protected location.
     */
    @DataClass.Generated.Member
    public boolean isDefaultToDeviceProtectedStorage() {
        return mDefaultToDeviceProtectedStorage;
    }

    /**
     * If {@code true} this app requests full external storage access.
     */
    @DataClass.Generated.Member
    public boolean isRequestLegacyExternalStorage() {
        return mRequestLegacyExternalStorage;
    }

    /**
     * Indicates whether this application has declared its user data as fragile, causing the
     * system to prompt the user on whether to keep the user data on uninstall.
     */
    @DataClass.Generated.Member
    public boolean isUserDataFragile() {
        return mUserDataFragile;
    }

    /**
     * Indicates whether this application's data will be cleared on a failed restore.
     * Archival install info.
     */
    @DataClass.Generated.Member
    public boolean isClearUserDataOnFailedRestoreAllowed() {
        return mClearUserDataOnFailedRestoreAllowed;
    public @Nullable ArchivedPackageParcel getArchivedPackage() {
        return mArchivedPackage;
    }

    @DataClass.Generated(
            time = 1693513509013L,
            time = 1694792109463L,
            codegenVersion = "1.0.23",
            sourceFile = "frameworks/base/core/java/android/content/pm/parsing/ApkLite.java",
            inputSignatures = "private final @android.annotation.NonNull java.lang.String mPackageName\nprivate final @android.annotation.NonNull java.lang.String mPath\nprivate final @android.annotation.Nullable java.lang.String mSplitName\nprivate final @android.annotation.Nullable java.lang.String mUsesSplitName\nprivate final @android.annotation.Nullable java.lang.String mConfigForSplit\nprivate final @android.annotation.Nullable java.util.Set<java.lang.String> mRequiredSplitTypes\nprivate final @android.annotation.Nullable java.util.Set<java.lang.String> mSplitTypes\nprivate final  int mVersionCodeMajor\nprivate final  int mVersionCode\nprivate final  int mRevisionCode\nprivate final  int mInstallLocation\nprivate final  int mMinSdkVersion\nprivate final  int mTargetSdkVersion\nprivate final @android.annotation.NonNull android.content.pm.VerifierInfo[] mVerifiers\nprivate final @android.annotation.NonNull android.content.pm.SigningDetails mSigningDetails\nprivate final  boolean mFeatureSplit\nprivate final  boolean mIsolatedSplits\nprivate final  boolean mSplitRequired\nprivate final  boolean mCoreApp\nprivate final  boolean mDebuggable\nprivate final  boolean mProfileableByShell\nprivate final  boolean mMultiArch\nprivate final  boolean mUse32bitAbi\nprivate final  boolean mExtractNativeLibs\nprivate final  boolean mUseEmbeddedDex\nprivate final @android.annotation.Nullable java.lang.String mTargetPackageName\nprivate final  boolean mOverlayIsStatic\nprivate final  int mOverlayPriority\nprivate final @android.annotation.Nullable java.lang.String mRequiredSystemPropertyName\nprivate final @android.annotation.Nullable java.lang.String mRequiredSystemPropertyValue\nprivate final  int mRollbackDataPolicy\nprivate final  boolean mHasDeviceAdminReceiver\nprivate final  boolean mIsSdkLibrary\nprivate final  boolean mBackupAllowed\nprivate final  boolean mDefaultToDeviceProtectedStorage\nprivate final  boolean mRequestLegacyExternalStorage\nprivate final  boolean mUserDataFragile\nprivate final  boolean mClearUserDataOnFailedRestoreAllowed\npublic  long getLongVersionCode()\nprivate  boolean hasAnyRequiredSplitTypes()\nclass ApkLite extends java.lang.Object implements []\n@com.android.internal.util.DataClass(genConstructor=false, genConstDefs=false)")
            inputSignatures = "private final @android.annotation.NonNull java.lang.String mPackageName\nprivate final @android.annotation.NonNull java.lang.String mPath\nprivate final @android.annotation.Nullable java.lang.String mSplitName\nprivate final @android.annotation.Nullable java.lang.String mUsesSplitName\nprivate final @android.annotation.Nullable java.lang.String mConfigForSplit\nprivate final @android.annotation.Nullable java.util.Set<java.lang.String> mRequiredSplitTypes\nprivate final @android.annotation.Nullable java.util.Set<java.lang.String> mSplitTypes\nprivate final  int mVersionCodeMajor\nprivate final  int mVersionCode\nprivate final  int mRevisionCode\nprivate final  int mInstallLocation\nprivate final  int mMinSdkVersion\nprivate final  int mTargetSdkVersion\nprivate final @android.annotation.NonNull android.content.pm.VerifierInfo[] mVerifiers\nprivate final @android.annotation.NonNull android.content.pm.SigningDetails mSigningDetails\nprivate final  boolean mFeatureSplit\nprivate final  boolean mIsolatedSplits\nprivate final  boolean mSplitRequired\nprivate final  boolean mCoreApp\nprivate final  boolean mDebuggable\nprivate final  boolean mProfileableByShell\nprivate final  boolean mMultiArch\nprivate final  boolean mUse32bitAbi\nprivate final  boolean mExtractNativeLibs\nprivate final  boolean mUseEmbeddedDex\nprivate final @android.annotation.Nullable java.lang.String mTargetPackageName\nprivate final  boolean mOverlayIsStatic\nprivate final  int mOverlayPriority\nprivate final @android.annotation.Nullable java.lang.String mRequiredSystemPropertyName\nprivate final @android.annotation.Nullable java.lang.String mRequiredSystemPropertyValue\nprivate final  int mRollbackDataPolicy\nprivate final  boolean mHasDeviceAdminReceiver\nprivate final  boolean mIsSdkLibrary\nprivate final @android.annotation.Nullable android.content.pm.ArchivedPackageParcel mArchivedPackage\npublic  long getLongVersionCode()\nprivate  boolean hasAnyRequiredSplitTypes()\nclass ApkLite extends java.lang.Object implements []\n@com.android.internal.util.DataClass(genConstructor=false, genConstDefs=false)")
    @Deprecated
    private void __metadata() {}

+1 −30
Original line number Diff line number Diff line
@@ -40,7 +40,6 @@ import android.util.Pair;
import android.util.Slog;

import com.android.internal.util.ArrayUtils;
import com.android.internal.util.XmlUtils;

import libcore.io.IoUtils;

@@ -447,13 +446,6 @@ public class ApkLiteParseUtils {
        int overlayPriority = 0;
        int rollbackDataPolicy = 0;

        boolean clearUserDataAllowed = true;
        boolean backupAllowed = true;
        boolean defaultToDeviceProtectedStorage = false;
        String requestLegacyExternalStorage = null;
        boolean userDataFragile = false;
        boolean clearUserDataOnFailedRestoreAllowed = true;

        String requiredSystemPropertyName = null;
        String requiredSystemPropertyValue = null;

@@ -493,22 +485,6 @@ public class ApkLiteParseUtils {
                useEmbeddedDex = parser.getAttributeBooleanValue(ANDROID_RES_NAMESPACE,
                        "useEmbeddedDex", false);

                clearUserDataAllowed = parser.getAttributeBooleanValue(ANDROID_RES_NAMESPACE,
                        "allowClearUserDataOnFailedRestore", true);
                backupAllowed = parser.getAttributeBooleanValue(ANDROID_RES_NAMESPACE,
                        "allowBackup", true);
                defaultToDeviceProtectedStorage = parser.getAttributeBooleanValue(
                        ANDROID_RES_NAMESPACE,
                        "defaultToDeviceProtectedStorage", false);
                userDataFragile = parser.getAttributeBooleanValue(ANDROID_RES_NAMESPACE,
                        "hasFragileUserData", false);
                clearUserDataOnFailedRestoreAllowed = parser.getAttributeBooleanValue(
                        ANDROID_RES_NAMESPACE,
                        "allowClearUserDataOnFailedRestore", true);

                requestLegacyExternalStorage = parser.getAttributeValue(ANDROID_RES_NAMESPACE,
                        "requestLegacyExternalStorage");

                rollbackDataPolicy = parser.getAttributeIntValue(ANDROID_RES_NAMESPACE,
                        "rollbackDataPolicy", 0);
                String permission = parser.getAttributeValue(ANDROID_RES_NAMESPACE,
@@ -629,9 +605,6 @@ public class ApkLiteParseUtils {
            return input.skip(message);
        }

        boolean isRequestLegacyExternalStorage = XmlUtils.convertValueToBoolean(
                requestLegacyExternalStorage, targetSdkVersion < Build.VERSION_CODES.Q);

        return input.success(
                new ApkLite(codePath, packageSplit.first, packageSplit.second, isFeatureSplit,
                        configForSplit, usesSplitName, isSplitRequired, versionCode,
@@ -641,9 +614,7 @@ public class ApkLiteParseUtils {
                        overlayIsStatic, overlayPriority, requiredSystemPropertyName,
                        requiredSystemPropertyValue, minSdkVersion, targetSdkVersion,
                        rollbackDataPolicy, requiredSplitTypes.first, requiredSplitTypes.second,
                        hasDeviceAdminReceiver, isSdkLibrary, clearUserDataAllowed, backupAllowed,
                        defaultToDeviceProtectedStorage, isRequestLegacyExternalStorage,
                        userDataFragile, clearUserDataOnFailedRestoreAllowed));
                        hasDeviceAdminReceiver, isSdkLibrary));
    }

    private static boolean isDeviceAdminReceiver(
Loading