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

Commit e8f083d3 authored by Alex Buynytskyy's avatar Alex Buynytskyy
Browse files

Install archived package.

This is barebones implementation of install archived API.
Despite name "archived" it's missing the archival part, e.g. main
activities.

Bug: 297916136
Test: atest PackageManagerTest#testInstallArchived

Change-Id: I2fa156967a1fd6d4fccf5151afe10a81fdc8ce15
parent 723e9f1b
Loading
Loading
Loading
Loading
+38 −0
Original line number Original line 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;

import android.content.pm.SigningDetails;

/**
 * Contains fields required for archived package installation,
 * i.e. installation without an APK.
 * @hide
 */
parcelable ArchivedPackageParcel {
    String packageName;
    SigningDetails signingDetails;
    int versionCode;
    int versionCodeMajor;
    int targetSdkVersion;
    boolean clearUserDataAllowed;
    boolean backupAllowed;
    boolean defaultToDeviceProtectedStorage;
    boolean requestLegacyExternalStorage;
    boolean userDataFragile;
    boolean clearUserDataOnFailedRestoreAllowed;
}
+3 −0
Original line number Original line Diff line number Diff line
@@ -22,6 +22,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.ArchivedPackageParcel;
import android.content.pm.ChangedPackages;
import android.content.pm.ChangedPackages;
import android.content.pm.InstantAppInfo;
import android.content.pm.InstantAppInfo;
import android.content.pm.FeatureInfo;
import android.content.pm.FeatureInfo;
@@ -833,4 +834,6 @@ interface IPackageManager {
    void registerPackageMonitorCallback(IRemoteCallback callback, int userId);
    void registerPackageMonitorCallback(IRemoteCallback callback, int userId);


    void unregisterPackageMonitorCallback(IRemoteCallback callback);
    void unregisterPackageMonitorCallback(IRemoteCallback callback);

    ArchivedPackageParcel getArchivedPackage(in String apkPath);
}
}
+7 −0
Original line number Original line Diff line number Diff line
@@ -1681,6 +1681,13 @@ public abstract class PackageManager {
     */
     */
    public static final int INSTALL_FROM_MANAGED_USER_OR_PROFILE = 1 << 26;
    public static final int INSTALL_FROM_MANAGED_USER_OR_PROFILE = 1 << 26;


    /**
     * Flag parameter for {@link PackageInstaller.SessionParams} to indicate that this
     * session is for archived package installation.
     * @hide
     */
    public static final int INSTALL_ARCHIVED = 1 << 27;

    /**
    /**
     * Flag parameter for {@link #installPackage} to force a non-staged update of an APEX. This is
     * Flag parameter for {@link #installPackage} to force a non-staged update of an APEX. This is
     * a development-only feature and should not be used on end user devices.
     * a development-only feature and should not be used on end user devices.
+18 −0
Original line number Original line 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;

parcelable SigningDetails;
+37 −0
Original line number Original line Diff line number Diff line
@@ -18,6 +18,7 @@ package android.content.pm.parsing;


import android.annotation.NonNull;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.Nullable;
import android.content.pm.ArchivedPackageParcel;
import android.content.pm.PackageInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager;
import android.content.pm.SigningDetails;
import android.content.pm.SigningDetails;
@@ -184,6 +185,42 @@ public class ApkLite {
        mIsSdkLibrary = isSdkLibrary;
        mIsSdkLibrary = isSdkLibrary;
    }
    }


    public ApkLite(String path, ArchivedPackageParcel archivedPackage) {
        mPath = path;
        mPackageName = archivedPackage.packageName;
        mSplitName = null; // base.apk
        mSplitTypes = null;
        mFeatureSplit = false;
        mConfigForSplit = null;
        mUsesSplitName = null;
        mRequiredSplitTypes = null;
        mSplitRequired = hasAnyRequiredSplitTypes();
        mVersionCode = archivedPackage.versionCode;
        mVersionCodeMajor = archivedPackage.versionCodeMajor;
        mRevisionCode = 0;
        mInstallLocation = PackageInfo.INSTALL_LOCATION_UNSPECIFIED;
        mVerifiers = new VerifierInfo[]{};
        mSigningDetails = archivedPackage.signingDetails;
        mCoreApp = false;
        mDebuggable = false;
        mProfileableByShell = false;
        mMultiArch = false;
        mUse32bitAbi = false;
        mUseEmbeddedDex = false;
        mExtractNativeLibs = false;
        mIsolatedSplits = false;
        mTargetPackageName = null;
        mOverlayIsStatic = false;
        mOverlayPriority = 0;
        mRequiredSystemPropertyName = null;
        mRequiredSystemPropertyValue = null;
        mMinSdkVersion = ApkLiteParseUtils.DEFAULT_MIN_SDK_VERSION;
        mTargetSdkVersion = archivedPackage.targetSdkVersion;
        mRollbackDataPolicy = 0;
        mHasDeviceAdminReceiver = false;
        mIsSdkLibrary = false;
    }

    /**
    /**
     * Return {@link #mVersionCode} and {@link #mVersionCodeMajor} combined together as a
     * Return {@link #mVersionCode} and {@link #mVersionCodeMajor} combined together as a
     * single long value. The {@link #mVersionCodeMajor} is placed in the upper 32 bits.
     * single long value. The {@link #mVersionCodeMajor} is placed in the upper 32 bits.
Loading