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

Commit bd96f655 authored by Jakob Schneider's avatar Jakob Schneider
Browse files

Add OEM compatability options for archiving.

These options will be used by launchers to disable certain archiving
functions. See Section 6 in go/android-archiving

Bug: 302114748
Test: ArchiveTest, PackageInstallerArchiveTest

Change-Id: I108b3e31d7deeca128603ecc85ca54553b75dc78
parent 5eba0763
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -12316,6 +12316,7 @@ package android.content.pm {
    method public void registerCallback(android.content.pm.LauncherApps.Callback, android.os.Handler);
    method public void registerPackageInstallerSessionCallback(@NonNull java.util.concurrent.Executor, @NonNull android.content.pm.PackageInstaller.SessionCallback);
    method public android.content.pm.LauncherActivityInfo resolveActivity(android.content.Intent, android.os.UserHandle);
    method @FlaggedApi("android.content.pm.archiving") public void setArchiveCompatibilityOptions(boolean, boolean);
    method public boolean shouldHideFromSuggestions(@NonNull String, @NonNull android.os.UserHandle);
    method public void startAppDetailsActivity(android.content.ComponentName, android.os.UserHandle, android.graphics.Rect, android.os.Bundle);
    method public void startMainActivity(android.content.ComponentName, android.os.UserHandle, android.graphics.Rect, android.os.Bundle);
+41 −2
Original line number Diff line number Diff line
@@ -1547,9 +1547,24 @@ public class AppOpsManager {
    public static final int OP_READ_SYSTEM_GRAMMATICAL_GENDER =
            AppProtoEnums.APP_OP_READ_SYSTEM_GRAMMATICAL_GENDER;

    /**
     * Whether the app has enabled to receive the icon overlay for fetching archived apps.
     *
     * @hide
     */
    public static final int OP_ARCHIVE_ICON_OVERLAY = AppProtoEnums.APP_OP_ARCHIVE_ICON_OVERLAY;

    /**
     * Whether the app has enabled compatibility support for unarchival.
     *
     * @hide
     */
    public static final int OP_UNARCHIVAL_CONFIRMATION =
            AppProtoEnums.APP_OP_UNARCHIVAL_CONFIRMATION;

    /** @hide */
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
    public static final int _NUM_OP = 144;
    public static final int _NUM_OP = 146;

    /**
     * All app ops represented as strings.
@@ -1699,6 +1714,8 @@ public class AppOpsManager {
            OPSTR_ENABLE_MOBILE_DATA_BY_USER,
            OPSTR_RESERVED_FOR_TESTING,
            OPSTR_RAPID_CLEAR_NOTIFICATIONS_BY_LISTENER,
            OPSTR_ARCHIVE_ICON_OVERLAY,
            OPSTR_UNARCHIVAL_CONFIRMATION,
    })
    public @interface AppOpString {}

@@ -2038,6 +2055,20 @@ public class AppOpsManager {
    @FlaggedApi(Flags.FLAG_ENABLE_PRIVILEGED_ROUTING_FOR_MEDIA_ROUTING_CONTROL)
    public static final String OPSTR_MEDIA_ROUTING_CONTROL = "android:media_routing_control";

    /**
     * Whether the app has enabled to receive the icon overlay for fetching archived apps.
     *
     * @hide
     */
    public static final String OPSTR_ARCHIVE_ICON_OVERLAY = "android:archive_icon_overlay";

    /**
     * Whether the app has enabled compatibility support for unarchival.
     *
     * @hide
     */
    public static final String OPSTR_UNARCHIVAL_CONFIRMATION = "android:unarchival_support";

    /**
     * AppOp granted to apps that we are started via {@code am instrument -e --no-isolated-storage}
     *
@@ -2502,6 +2533,8 @@ public class AppOpsManager {
            OP_RECEIVE_SANDBOXED_DETECTION_TRAINING_DATA,
            OP_MEDIA_ROUTING_CONTROL,
            OP_READ_SYSTEM_GRAMMATICAL_GENDER,
            OP_ARCHIVE_ICON_OVERLAY,
            OP_UNARCHIVAL_CONFIRMATION,
    };

    static final AppOpInfo[] sAppOpInfos = new AppOpInfo[]{
@@ -2958,6 +2991,12 @@ public class AppOpsManager {
                OPSTR_READ_SYSTEM_GRAMMATICAL_GENDER, "READ_SYSTEM_GRAMMATICAL_GENDER")
                .setPermission(Manifest.permission.READ_SYSTEM_GRAMMATICAL_GENDER)
                .build(),
        new AppOpInfo.Builder(OP_ARCHIVE_ICON_OVERLAY, OPSTR_ARCHIVE_ICON_OVERLAY,
                "ARCHIVE_ICON_OVERLAY")
                .setDefaultMode(MODE_ALLOWED).build(),
        new AppOpInfo.Builder(OP_UNARCHIVAL_CONFIRMATION, OPSTR_UNARCHIVAL_CONFIRMATION,
                "UNARCHIVAL_CONFIRMATION")
                .setDefaultMode(MODE_ALLOWED).build(),
    };

    // The number of longs needed to form a full bitmask of app ops
@@ -3092,7 +3131,7 @@ public class AppOpsManager {

    /**
     * Retrieve the permission associated with an operation, or null if there is not one.
     *

     * @param op The operation name.
     *
     * @hide
+2 −1
Original line number Diff line number Diff line
@@ -4032,7 +4032,8 @@ public class ApplicationPackageManager extends PackageManager {
    private Drawable getArchivedAppIcon(String packageName) {
        try {
            return new BitmapDrawable(null,
                    mPM.getArchivedAppIcon(packageName, new UserHandle(getUserId())));
                    mPM.getArchivedAppIcon(packageName, new UserHandle(getUserId()),
                            mContext.getPackageName()));
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
+2 −0
Original line number Diff line number Diff line
@@ -128,4 +128,6 @@ interface ILauncherApps {

    /** Unregister a callback, so that it won't be called when LauncherApps dumps. */
    void unRegisterDumpCallback(IDumpCallback cb);

    void setArchiveCompatibilityOptions(boolean enableIconOverlay, boolean enableUnarchivalConfirmation);
}
+1 −1
Original line number Diff line number Diff line
@@ -840,7 +840,7 @@ interface IPackageManager {

    ArchivedPackageParcel getArchivedPackage(in String packageName, int userId);

    Bitmap getArchivedAppIcon(String packageName, in UserHandle user);
    Bitmap getArchivedAppIcon(String packageName, in UserHandle user, String callingPackageName);

    boolean isAppArchivable(String packageName, in UserHandle user);
}
Loading