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

Commit 1ad63a31 authored by Rhed Jao's avatar Rhed Jao
Browse files

Add an api to query the visibility list of target packages

Bug: 261792320
Test: atest AppEnumerationTests
Change-Id: Id70510efa989297735a796fc8c1ccca7d5d34e44
parent c307a592
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -3601,6 +3601,7 @@ package android.content.pm {
  public abstract class PackageManager {
    method @RequiresPermission("android.permission.OBSERVE_GRANT_REVOKE_PERMISSIONS") public abstract void addOnPermissionsChangeListener(@NonNull android.content.pm.PackageManager.OnPermissionsChangedListener);
    method public abstract boolean arePermissionsIndividuallyControlled();
    method @NonNull public boolean[] canPackageQuery(@NonNull String, @NonNull String[]) throws android.content.pm.PackageManager.NameNotFoundException;
    method @NonNull public abstract java.util.List<android.content.IntentFilter> getAllIntentFilters(@NonNull String);
    method @Deprecated @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;
+10 −1
Original line number Diff line number Diff line
@@ -3816,8 +3816,17 @@ public class ApplicationPackageManager extends PackageManager {
            @NonNull String targetPackageName) throws NameNotFoundException {
        Objects.requireNonNull(sourcePackageName);
        Objects.requireNonNull(targetPackageName);
        return canPackageQuery(sourcePackageName, new String[]{targetPackageName})[0];
    }

    @Override
    @NonNull
    public boolean[] canPackageQuery(@NonNull String sourcePackageName,
            @NonNull String[] targetPackageNames) throws NameNotFoundException {
        Objects.requireNonNull(sourcePackageName);
        Objects.requireNonNull(targetPackageNames);
        try {
            return mPM.canPackageQuery(sourcePackageName, targetPackageName, getUserId());
            return mPM.canPackageQuery(sourcePackageName, targetPackageNames, getUserId());
        } catch (ParcelableException e) {
            e.maybeRethrow(PackageManager.NameNotFoundException.class);
            throw new RuntimeException(e);
+1 −1
Original line number Diff line number Diff line
@@ -797,5 +797,5 @@ interface IPackageManager {

    void setKeepUninstalledPackages(in List<String> packageList);

    boolean canPackageQuery(String sourcePackageName, String targetPackageName, int userId);
    boolean[] canPackageQuery(String sourcePackageName, in String[] targetPackageNames, int userId);
}
+24 −0
Original line number Diff line number Diff line
@@ -10387,6 +10387,30 @@ public abstract class PackageManager {
                "canPackageQuery not implemented in subclass");
    }

    /**
     * Same as {@link #canPackageQuery(String, String)} but accepts an array of target packages to
     * be queried.
     *
     * @param sourcePackageName The source package that would receive details about the
     *                          target package.
     * @param targetPackageNames An array of target packages whose details would be shared with the
     *                           source package.
     * @return An array of booleans where each member specifies whether the source package is able
     * to query for details about the target package given by the corresponding value at the same
     * index in the array of target packages.
     * @throws NameNotFoundException if either a given package can not be found on the
     * system, or if the caller is not able to query for details about the source or
     * target packages.
     * @hide
     */
    @SystemApi
    @NonNull
    public boolean[] canPackageQuery(@NonNull String sourcePackageName,
            @NonNull String[] targetPackageNames) throws NameNotFoundException {
        throw new UnsupportedOperationException(
                "canPackageQuery not implemented in subclass");
    }

    /**
     * Makes a package that provides an authority {@code visibleAuthority} become visible to the
     * application {@code recipientUid}.
+3 −2
Original line number Diff line number Diff line
@@ -567,8 +567,9 @@ public interface Computer extends PackageDataSnapshot {
    @PackageManager.InstallReason
    int getInstallReason(@NonNull String packageName, @UserIdInt int userId);

    boolean canPackageQuery(@NonNull String sourcePackageName, @NonNull String targetPackageName,
            @UserIdInt int userId);
    @NonNull
    boolean[] canPackageQuery(@NonNull String sourcePackageName,
            @NonNull String[] targetPackageNames, @UserIdInt int userId);

    boolean canForwardTo(@NonNull Intent intent, @Nullable String resolvedType,
            @UserIdInt int sourceUserId, @UserIdInt int targetUserId);
Loading