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

Commit 340c8770 authored by Joanne Chung's avatar Joanne Chung Committed by Android (Google) Code Review
Browse files

Merge "Add API to support ASL-in-APK" into main

parents aa332e3c fa564402
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -3991,6 +3991,7 @@ package android.content.pm {
    method @NonNull public boolean canUserUninstall(@NonNull String, @NonNull android.os.UserHandle);
    method @NonNull public abstract java.util.List<android.content.IntentFilter> getAllIntentFilters(@NonNull String);
    method @NonNull @RequiresPermission(android.Manifest.permission.GET_APP_METADATA) public android.os.PersistableBundle getAppMetadata(@NonNull String) throws android.content.pm.PackageManager.NameNotFoundException;
    method @FlaggedApi("android.content.pm.asl_in_apk_app_metadata_source") @RequiresPermission(android.Manifest.permission.GET_APP_METADATA) public int getAppMetadataSource(@NonNull String) throws android.content.pm.PackageManager.NameNotFoundException;
    method @NonNull @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) public android.content.pm.ApplicationInfo getApplicationInfoAsUser(@NonNull String, int, @NonNull android.os.UserHandle) throws android.content.pm.PackageManager.NameNotFoundException;
    method @NonNull @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) public android.content.pm.ApplicationInfo getApplicationInfoAsUser(@NonNull String, @NonNull android.content.pm.PackageManager.ApplicationInfoFlags, @NonNull android.os.UserHandle) throws android.content.pm.PackageManager.NameNotFoundException;
    method @NonNull public android.content.pm.dex.ArtManager getArtManager();
@@ -4043,6 +4044,10 @@ package android.content.pm {
    method @Deprecated @RequiresPermission(android.Manifest.permission.INTENT_FILTER_VERIFICATION_AGENT) public abstract void verifyIntentFilter(int, int, @NonNull java.util.List<java.lang.String>);
    field public static final String ACTION_REQUEST_PERMISSIONS = "android.content.pm.action.REQUEST_PERMISSIONS";
    field public static final String ACTION_REQUEST_PERMISSIONS_FOR_OTHER = "android.content.pm.action.REQUEST_PERMISSIONS_FOR_OTHER";
    field @FlaggedApi("android.content.pm.asl_in_apk_app_metadata_source") public static final int APP_METADATA_SOURCE_APK = 1; // 0x1
    field @FlaggedApi("android.content.pm.asl_in_apk_app_metadata_source") public static final int APP_METADATA_SOURCE_INSTALLER = 2; // 0x2
    field @FlaggedApi("android.content.pm.asl_in_apk_app_metadata_source") public static final int APP_METADATA_SOURCE_SYSTEM_IMAGE = 3; // 0x3
    field @FlaggedApi("android.content.pm.asl_in_apk_app_metadata_source") public static final int APP_METADATA_SOURCE_UNKNOWN = 0; // 0x0
    field public static final int DELETE_ALL_USERS = 2; // 0x2
    field public static final int DELETE_FAILED_ABORTED = -5; // 0xfffffffb
    field public static final int DELETE_FAILED_DEVICE_POLICY_MANAGER = -2; // 0xfffffffe
+16 −0
Original line number Diff line number Diff line
@@ -1269,6 +1269,22 @@ public class ApplicationPackageManager extends PackageManager {
        return appMetadata != null ? appMetadata : new PersistableBundle();
    }

    @Override
    public @AppMetadataSource int getAppMetadataSource(@NonNull String packageName)
            throws NameNotFoundException {
        Objects.requireNonNull(packageName, "packageName cannot be null");
        int source = PackageManager.APP_METADATA_SOURCE_UNKNOWN;
        try {
            source = mPM.getAppMetadataSource(packageName, getUserId());
        } catch (ParcelableException e) {
            e.maybeRethrow(NameNotFoundException.class);
            throw new RuntimeException(e);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
        return source;
    }

    @SuppressWarnings("unchecked")
    @Override
    public List<PackageInfo> getPackagesHoldingPermissions(String[] permissions, int flags) {
+3 −0
Original line number Diff line number Diff line
@@ -843,4 +843,7 @@ interface IPackageManager {
    Bitmap getArchivedAppIcon(String packageName, in UserHandle user, String callingPackageName);

    boolean isAppArchivable(String packageName, in UserHandle user);

    @EnforcePermission("GET_APP_METADATA")
    int getAppMetadataSource(String packageName, int userId);
}
+63 −0
Original line number Diff line number Diff line
@@ -2992,6 +2992,46 @@ public abstract class PackageManager {
    @SystemApi
    public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS_ASK = 4;


    /**
     * Indicates that the app metadata does not exist or its source is unknown.
     * @hide
     */
    @FlaggedApi(android.content.pm.Flags.FLAG_ASL_IN_APK_APP_METADATA_SOURCE)
    @SystemApi
    public static final int APP_METADATA_SOURCE_UNKNOWN = 0;
    /**
     * Indicates that the app metadata is provided by the APK itself.
     * @hide
     */
    @FlaggedApi(android.content.pm.Flags.FLAG_ASL_IN_APK_APP_METADATA_SOURCE)
    @SystemApi
    public static final int APP_METADATA_SOURCE_APK = 1;
    /**
     * Indicates that the app metadata is provided by the installer that installed the app.
     * @hide
     */
    @FlaggedApi(android.content.pm.Flags.FLAG_ASL_IN_APK_APP_METADATA_SOURCE)
    @SystemApi
    public static final int APP_METADATA_SOURCE_INSTALLER = 2;
    /**
     * Indicates that the app metadata is provided as part of the system image.
     * @hide
     */
    @FlaggedApi(android.content.pm.Flags.FLAG_ASL_IN_APK_APP_METADATA_SOURCE)
    @SystemApi
    public static final int APP_METADATA_SOURCE_SYSTEM_IMAGE = 3;

    /** @hide */
    @IntDef(flag = true, prefix = { "APP_METADATA_SOURCE_" }, value = {
            APP_METADATA_SOURCE_UNKNOWN,
            APP_METADATA_SOURCE_APK,
            APP_METADATA_SOURCE_INSTALLER,
            APP_METADATA_SOURCE_SYSTEM_IMAGE,
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface AppMetadataSource {}

    /**
     * Can be used as the {@code millisecondsToDelay} argument for
     * {@link PackageManager#extendVerificationTimeout}. This is the
@@ -6309,6 +6349,29 @@ public abstract class PackageManager {
        throw new UnsupportedOperationException("getAppMetadata not implemented in subclass");
    }


    /**
     * Returns the source of the app metadata that is currently associated with the given package.
     * The value can be {@link #APP_METADATA_SOURCE_UNKNOWN}, {@link #APP_METADATA_SOURCE_APK},
     * {@link #APP_METADATA_SOURCE_INSTALLER} or {@link #APP_METADATA_SOURCE_SYSTEM_IMAGE}.
     *
     * Note: an app can have the app metadata included in the APK, but if the installer also
     * provides an app metadata during the installation, the one provided by the installer will
     * take precedence.
     *
     * @param packageName The package name for which to get the app metadata source.
     * @throws NameNotFoundException if no such package is available to the caller.
     * @throws SecurityException if the caller doesn't have the required permission.
     * @hide
     */
    @FlaggedApi(android.content.pm.Flags.FLAG_ASL_IN_APK_APP_METADATA_SOURCE)
    @SystemApi
    @RequiresPermission(Manifest.permission.GET_APP_METADATA)
    public @AppMetadataSource int getAppMetadataSource(@NonNull String packageName)
            throws NameNotFoundException {
        throw new UnsupportedOperationException("getAppMetadataSource not implemented in subclass");
    }

    /**
     * Return a List of all installed packages that are currently holding any of
     * the given permissions.
+3 −0
Original line number Diff line number Diff line
@@ -2204,6 +2204,9 @@ final class InstallPackageHelper {
                File appMetadataFile = new File(ps.getPath(), APP_METADATA_FILE_NAME);
                if (appMetadataFile.exists()) {
                    ps.setAppMetadataFilePath(appMetadataFile.getAbsolutePath());
                    if (Flags.aslInApkAppMetadataSource()) {
                        ps.setAppMetadataSource(PackageManager.APP_METADATA_SOURCE_INSTALLER);
                    }
                } else {
                    ps.setAppMetadataFilePath(null);
                }
Loading