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

Commit 3abf547d authored by Patrick Baumann's avatar Patrick Baumann
Browse files

Addresses API feedback for Intent Discovery change

* Clarifies purpose and effects of resolver methods
* Adds javadocs to non-obvious constructors and constants

Test: none - no functional changes
Bug: 73950163
Change-Id: Id668b890a8c97da74502698f71b16cc213eda6c6
parent b1d5004c
Loading
Loading
Loading
Loading
+29 −5
Original line number Diff line number Diff line
@@ -62,7 +62,7 @@ public abstract class InstantAppResolverService extends Service {
    @Deprecated
    public void onGetInstantAppResolveInfo(
            int digestPrefix[], String token, InstantAppResolutionCallback callback) {
        throw new IllegalStateException("Must define");
        throw new IllegalStateException("Must define onGetInstantAppResolveInfo");
    }

    /**
@@ -80,10 +80,26 @@ public abstract class InstantAppResolverService extends Service {
    }

    /**
     * Called to retrieve resolve info for instant applications immediately.
     * Called to retrieve resolve info for instant applications immediately. The response will be
     * ignored if not provided within a reasonable time. {@link InstantAppResolveInfo}s provided
     * in response to this method may be partial to request a second phase of resolution which will
     * result in a subsequent call to
     * {@link #onGetInstantAppIntentFilter(Intent, int[], String, InstantAppResolutionCallback)}
     *
     * @param sanitizedIntent The sanitized {@link Intent} used for resolution.
     *
     * @param sanitizedIntent The sanitized {@link Intent} used for resolution. A sanitized Intent
     *                        is an intent with potential PII removed from the original intent.
     *                        Fields removed include extras and the host + path of the data, if
     *                        defined.
     * @param hostDigestPrefix The hash prefix of the instant app's domain.
     * @param token A unique identifier that will be provided in calls to
     *              {@link #onGetInstantAppIntentFilter(Intent, int[], String,
     *              InstantAppResolutionCallback)}
     *              and provided to the installer via {@link Intent#EXTRA_INSTANT_APP_TOKEN} to
     *              tie a single launch together.
     * @param callback The {@link InstantAppResolutionCallback} to provide results to.
     *
     * @see InstantAppResolveInfo
     */
    public void onGetInstantAppResolveInfo(Intent sanitizedIntent, int[] hostDigestPrefix,
            String token, InstantAppResolutionCallback callback) {
@@ -96,12 +112,20 @@ public abstract class InstantAppResolverService extends Service {
    }

    /**
     * Called to retrieve intent filters for instant applications from potentially expensive
     * sources.
     * Called to retrieve intent filters for potentially matching instant applications. Unlike
     * {@link #onGetInstantAppResolveInfo(Intent, int[], String, InstantAppResolutionCallback)},
     * the response may take as long as necessary to respond. All {@link InstantAppResolveInfo}s
     * provided in response to this method must be completely populated.
     *
     * @param sanitizedIntent The sanitized {@link Intent} used for resolution.
     * @param hostDigestPrefix The hash prefix of the instant app's domain or null if no host is
     *                         defined.
     * @param token A unique identifier that was provided in
     *              {@link #onGetInstantAppResolveInfo(Intent, int[], String,
     *              InstantAppResolutionCallback)}
     *              and provided to the currently visible installer via
     *              {@link Intent#EXTRA_INSTANT_APP_TOKEN}.
     * @param callback The {@link InstantAppResolutionCallback} to provide results to
     */
    public void onGetInstantAppIntentFilter(Intent sanitizedIntent, int[] hostDigestPrefix,
            String token, InstantAppResolutionCallback callback) {
+26 −19
Original line number Diff line number Diff line
@@ -78,8 +78,7 @@ public final class InstantAppResolveInfo implements Parcelable {
    private final Bundle mExtras;
    /**
     * A flag that indicates that the resolver is aware that an app may match, but would prefer
     * that the installer get the sanitized intent to decide. This should not be used for
     * resolutions that include a host and will be ignored in such cases.
     * that the installer get the sanitized intent to decide.
     */
    private final boolean mShouldLetInstallerDecide;

@@ -96,7 +95,21 @@ public final class InstantAppResolveInfo implements Parcelable {
        this(digest, packageName, filters, versionCode, extras, false);
    }

    /** Constructor for intent-based InstantApp resolution results with extras. */
    /** Constructor for intent-based InstantApp resolution results by hostname. */
    public InstantAppResolveInfo(@NonNull String hostName, @Nullable String packageName,
            @Nullable List<InstantAppIntentFilter> filters) {
        this(new InstantAppDigest(hostName), packageName, filters, -1 /*versionCode*/,
                null /* extras */);
    }

    /**
     * Constructor that indicates that resolution could be delegated to the installer when the
     * sanitized intent contains enough information to resolve completely.
     */
    public InstantAppResolveInfo(@Nullable Bundle extras) {
        this(InstantAppDigest.UNDEFINED, null, null, -1, extras, true);
    }

    private InstantAppResolveInfo(@NonNull InstantAppDigest digest, @Nullable String packageName,
            @Nullable List<InstantAppIntentFilter> filters, long versionCode,
            @Nullable Bundle extras, boolean shouldLetInstallerDecide) {
@@ -118,21 +131,6 @@ public final class InstantAppResolveInfo implements Parcelable {
        mShouldLetInstallerDecide = shouldLetInstallerDecide;
    }

    /** Constructor for intent-based InstantApp resolution results by hostname. */
    public InstantAppResolveInfo(@NonNull String hostName, @Nullable String packageName,
            @Nullable List<InstantAppIntentFilter> filters) {
        this(new InstantAppDigest(hostName), packageName, filters, -1 /*versionCode*/,
                null /* extras */);
    }

    /**
     * Constructor that creates a "let the installer decide" response with optional included
     * extras.
     */
    public InstantAppResolveInfo(@Nullable Bundle extras) {
        this(InstantAppDigest.UNDEFINED, null, null, -1, extras, true);
    }

    InstantAppResolveInfo(Parcel in) {
        mShouldLetInstallerDecide = in.readBoolean();
        mExtras = in.readBundle();
@@ -150,7 +148,11 @@ public final class InstantAppResolveInfo implements Parcelable {
        }
    }

    /** Returns true if the installer should be notified that it should query for packages. */
    /**
     * Returns true if the resolver is aware that an app may match, but would prefer
     * that the installer get the sanitized intent to decide. This should not be true for
     * resolutions that include a host and will be ignored in such cases.
     */
    public boolean shouldLetInstallerDecide() {
        return mShouldLetInstallerDecide;
    }
@@ -231,6 +233,11 @@ public final class InstantAppResolveInfo implements Parcelable {
    @SystemApi
    public static final class InstantAppDigest implements Parcelable {
        static final int DIGEST_MASK = 0xfffff000;

        /**
         * A special instance that represents and undefined digest used for cases that a host was
         * not provided or is irrelevant to the response.
         */
        public static final InstantAppDigest UNDEFINED =
                new InstantAppDigest(new byte[][]{}, new int[]{});