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

Commit 7db0d77d authored by Jakob Schneider's avatar Jakob Schneider Committed by Android (Google) Code Review
Browse files

Merge "Add the external ArchiveManager and AIDL interface. So far only the...

Merge "Add the external ArchiveManager and AIDL interface. So far only the archiveApp() API is implement in its most basic form." into main
parents 7c119c64 84b2cdc7
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -3793,6 +3793,10 @@ package android.content.pm {
    field @RequiresPermission(android.Manifest.permission.ACCESS_SHORTCUTS) public static final int FLAG_GET_PERSONS_DATA = 2048; // 0x800
  }
  public class PackageArchiver {
    method @RequiresPermission(anyOf={android.Manifest.permission.DELETE_PACKAGES, android.Manifest.permission.REQUEST_DELETE_PACKAGES}) public void requestArchive(@NonNull String, @NonNull android.content.IntentSender) throws android.content.pm.PackageManager.NameNotFoundException;
  }
  public class PackageInstaller {
    method @NonNull public android.content.pm.PackageInstaller.InstallInfo readInstallInfo(@NonNull java.io.File, int) throws android.content.pm.PackageInstaller.PackageParsingException;
    method @NonNull public android.content.pm.PackageInstaller.InstallInfo readInstallInfo(@NonNull android.os.ParcelFileDescriptor, @Nullable String, int) throws android.content.pm.PackageInstaller.PackageParsingException;
@@ -3890,6 +3894,7 @@ package android.content.pm {
    method @NonNull @RequiresPermission(android.Manifest.permission.ACCESS_INSTANT_APPS) public abstract java.util.List<android.content.pm.InstantAppInfo> getInstantApps();
    method @Deprecated @NonNull public abstract java.util.List<android.content.pm.IntentFilterVerificationInfo> getIntentFilterVerifications(@NonNull String);
    method @Deprecated @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL) public abstract int getIntentVerificationStatusAsUser(@NonNull String, int);
    method @NonNull public android.content.pm.PackageArchiver getPackageArchiver();
    method @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL) public int getPackageUidAsUser(@NonNull String, @NonNull android.content.pm.PackageManager.PackageInfoFlags, int) throws android.content.pm.PackageManager.NameNotFoundException;
    method @android.content.pm.PackageManager.PermissionFlags @RequiresPermission(anyOf={android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS, android.Manifest.permission.REVOKE_RUNTIME_PERMISSIONS, android.Manifest.permission.GET_RUNTIME_PERMISSIONS}) public abstract int getPermissionFlags(@NonNull String, @NonNull String, @NonNull android.os.UserHandle);
    method @NonNull @RequiresPermission(android.Manifest.permission.SUSPEND_APPS) public String[] getUnsuspendablePackages(@NonNull String[]);
+14 −0
Original line number Diff line number Diff line
@@ -64,6 +64,7 @@ import android.content.pm.InstrumentationInfo;
import android.content.pm.IntentFilterVerificationInfo;
import android.content.pm.KeySet;
import android.content.pm.ModuleInfo;
import android.content.pm.PackageArchiver;
import android.content.pm.PackageInfo;
import android.content.pm.PackageInstaller;
import android.content.pm.PackageItemInfo;
@@ -172,6 +173,7 @@ public class ApplicationPackageManager extends PackageManager {
    private volatile UserManager mUserManager;
    private volatile PermissionManager mPermissionManager;
    private volatile PackageInstaller mInstaller;
    private volatile PackageArchiver mPackageArchiver;
    private volatile ArtManager mArtManager;
    private volatile DevicePolicyManager mDevicePolicyManager;
    private volatile String mPermissionsControllerPackageName;
@@ -3281,6 +3283,18 @@ public class ApplicationPackageManager extends PackageManager {
        return mInstaller;
    }

    @Override
    public PackageArchiver getPackageArchiver() {
        if (mPackageArchiver == null) {
            try {
                mPackageArchiver = new PackageArchiver(mContext, mPM.getPackageArchiverService());
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
            }
        }
        return mPackageArchiver;
    }

    @Override
    public boolean isPackageAvailable(String packageName) {
        try {
+26 −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;

import android.content.IntentSender;
import android.os.UserHandle;

/** {@hide} */
interface IPackageArchiverService {

    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(anyOf={android.Manifest.permission.DELETE_PACKAGES,android.Manifest.permission.REQUEST_DELETE_PACKAGES})")
    void requestArchive(String packageName, String callerPackageName, in IntentSender statusReceiver, in UserHandle userHandle);
}
 No newline at end of file
+3 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.content.pm.ApplicationInfo;
import android.content.pm.ChangedPackages;
import android.content.pm.InstantAppInfo;
import android.content.pm.FeatureInfo;
import android.content.pm.IPackageArchiverService;
import android.content.pm.IDexModuleRegisterCallback;
import android.content.pm.InstallSourceInfo;
import android.content.pm.IOnChecksumsReadyListener;
@@ -650,6 +651,8 @@ interface IPackageManager {
    @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
    IPackageInstaller getPackageInstaller();

    IPackageArchiverService getPackageArchiverService();

    @EnforcePermission("DELETE_PACKAGES")
    boolean setBlockUninstallForUser(String packageName, boolean blockUninstall, int userId);
    @UnsupportedAppUsage
+79 −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;

import android.Manifest;
import android.annotation.NonNull;
import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
import android.content.Context;
import android.content.IntentSender;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.ParcelableException;
import android.os.RemoteException;

/**
 * {@code ArchiveManager} is used to archive apps. During the archival process, the apps APKs and
 * cache are removed from the device while the user data is kept. Through the
 * {@code requestUnarchive()} call, apps can be restored again through their responsible app store.
 *
 * <p> Archived apps are returned as displayable apps through the {@link LauncherApps} APIs and
 * will be displayed to users with UI treatment to highlight that said apps are archived. If
 * a user taps on an archived app, the app will be unarchived and the restoration process is
 * communicated.
 *
 * @hide
 */
// TODO(b/278560219) Improve public documentation.
@SystemApi
public class PackageArchiver {

    private final Context mContext;
    private final IPackageArchiverService mService;

    /**
     * @hide
     */
    public PackageArchiver(Context context, IPackageArchiverService service) {
        mContext = context;
        mService = service;
    }

    /**
     * Requests to archive a package which is currently installed.
     *
     * @param statusReceiver Callback used to notify when the operation is completed.
     * @throws NameNotFoundException If {@code packageName} isn't found or not available to the
     *                               caller.
     * @hide
     */
    @RequiresPermission(anyOf = {
            Manifest.permission.DELETE_PACKAGES,
            Manifest.permission.REQUEST_DELETE_PACKAGES})
    @SystemApi
    public void requestArchive(@NonNull String packageName, @NonNull IntentSender statusReceiver)
            throws NameNotFoundException {
        try {
            mService.requestArchive(packageName, mContext.getPackageName(), statusReceiver,
                    mContext.getUser());
        } catch (ParcelableException e) {
            e.maybeRethrow(NameNotFoundException.class);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }
}
Loading