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

Commit 6de97650 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Pass user to InstantAppResolverService methods."

parents 3f927ab7 bfa4f909
Loading
Loading
Loading
Loading
+4 −2
Original line number Original line Diff line number Diff line
@@ -371,9 +371,11 @@ package android.app {
    method public final void attachBaseContext(android.content.Context);
    method public final void attachBaseContext(android.content.Context);
    method public final android.os.IBinder onBind(android.content.Intent);
    method public final android.os.IBinder onBind(android.content.Intent);
    method public deprecated void onGetInstantAppIntentFilter(int[], java.lang.String, android.app.InstantAppResolverService.InstantAppResolutionCallback);
    method public deprecated void onGetInstantAppIntentFilter(int[], java.lang.String, android.app.InstantAppResolverService.InstantAppResolutionCallback);
    method public void onGetInstantAppIntentFilter(android.content.Intent, int[], java.lang.String, android.app.InstantAppResolverService.InstantAppResolutionCallback);
    method public deprecated void onGetInstantAppIntentFilter(android.content.Intent, int[], java.lang.String, android.app.InstantAppResolverService.InstantAppResolutionCallback);
    method public void onGetInstantAppIntentFilter(android.content.Intent, int[], android.os.UserHandle, java.lang.String, android.app.InstantAppResolverService.InstantAppResolutionCallback);
    method public deprecated void onGetInstantAppResolveInfo(int[], java.lang.String, android.app.InstantAppResolverService.InstantAppResolutionCallback);
    method public deprecated void onGetInstantAppResolveInfo(int[], java.lang.String, android.app.InstantAppResolverService.InstantAppResolutionCallback);
    method public void onGetInstantAppResolveInfo(android.content.Intent, int[], java.lang.String, android.app.InstantAppResolverService.InstantAppResolutionCallback);
    method public deprecated void onGetInstantAppResolveInfo(android.content.Intent, int[], java.lang.String, android.app.InstantAppResolverService.InstantAppResolutionCallback);
    method public void onGetInstantAppResolveInfo(android.content.Intent, int[], android.os.UserHandle, java.lang.String, android.app.InstantAppResolverService.InstantAppResolutionCallback);
  }
  }


  public static final class InstantAppResolverService.InstantAppResolutionCallback {
  public static final class InstantAppResolverService.InstantAppResolutionCallback {
+2 −2
Original line number Original line Diff line number Diff line
@@ -22,9 +22,9 @@ import android.os.IRemoteCallback;
/** @hide */
/** @hide */
oneway interface IInstantAppResolver {
oneway interface IInstantAppResolver {
    void getInstantAppResolveInfoList(in Intent sanitizedIntent, in int[] hostDigestPrefix,
    void getInstantAppResolveInfoList(in Intent sanitizedIntent, in int[] hostDigestPrefix,
            String token, int sequence, IRemoteCallback callback);
            int userId, String token, int sequence, IRemoteCallback callback);


    void getInstantAppIntentFilterList(in Intent sanitizedIntent, in int[] hostDigestPrefix,
    void getInstantAppIntentFilterList(in Intent sanitizedIntent, in int[] hostDigestPrefix,
            String token, IRemoteCallback callback);
            int userId, String token, IRemoteCallback callback);


}
}
+83 −20
Original line number Original line Diff line number Diff line
@@ -28,6 +28,7 @@ import android.os.IRemoteCallback;
import android.os.Looper;
import android.os.Looper;
import android.os.Message;
import android.os.Message;
import android.os.RemoteException;
import android.os.RemoteException;
import android.os.UserHandle;
import android.util.Log;
import android.util.Log;
import android.util.Slog;
import android.util.Slog;


@@ -56,8 +57,8 @@ public abstract class InstantAppResolverService extends Service {
     * Called to retrieve resolve info for instant applications immediately.
     * Called to retrieve resolve info for instant applications immediately.
     *
     *
     * @param digestPrefix The hash prefix of the instant app's domain.
     * @param digestPrefix The hash prefix of the instant app's domain.
     * @deprecated should implement {@link #onGetInstantAppResolveInfo(Intent, int[], String,
     * @deprecated Should implement {@link #onGetInstantAppResolveInfo(Intent, int[], UserHandle,
     *             InstantAppResolutionCallback)}
     *             String, InstantAppResolutionCallback)}.
     */
     */
    @Deprecated
    @Deprecated
    public void onGetInstantAppResolveInfo(
    public void onGetInstantAppResolveInfo(
@@ -70,8 +71,8 @@ public abstract class InstantAppResolverService extends Service {
     * sources.
     * sources.
     *
     *
     * @param digestPrefix The hash prefix of the instant app's domain.
     * @param digestPrefix The hash prefix of the instant app's domain.
     * @deprecated should implement {@link #onGetInstantAppIntentFilter(Intent, int[], String,
     * @deprecated Should implement {@link #onGetInstantAppIntentFilter(Intent, int[], UserHandle,
     *             InstantAppResolutionCallback)}
     *             String, InstantAppResolutionCallback)}.
     */
     */
    @Deprecated
    @Deprecated
    public void onGetInstantAppIntentFilter(
    public void onGetInstantAppIntentFilter(
@@ -86,7 +87,6 @@ public abstract class InstantAppResolverService extends Service {
     * result in a subsequent call to
     * result in a subsequent call to
     * {@link #onGetInstantAppIntentFilter(Intent, int[], String, InstantAppResolutionCallback)}
     * {@link #onGetInstantAppIntentFilter(Intent, int[], String, InstantAppResolutionCallback)}
     *
     *
     *
     * @param sanitizedIntent The sanitized {@link Intent} used for resolution. A sanitized Intent
     * @param sanitizedIntent The sanitized {@link Intent} used for resolution. A sanitized Intent
     *                        is an intent with potential PII removed from the original intent.
     *                        is an intent with potential PII removed from the original intent.
     *                        Fields removed include extras and the host + path of the data, if
     *                        Fields removed include extras and the host + path of the data, if
@@ -100,7 +100,11 @@ public abstract class InstantAppResolverService extends Service {
     * @param callback The {@link InstantAppResolutionCallback} to provide results to.
     * @param callback The {@link InstantAppResolutionCallback} to provide results to.
     *
     *
     * @see InstantAppResolveInfo
     * @see InstantAppResolveInfo
     *
     * @deprecated Should implement {@link #onGetInstantAppResolveInfo(Intent, int[], UserHandle,
     *             String, InstantAppResolutionCallback)}.
     */
     */
    @Deprecated
    public void onGetInstantAppResolveInfo(Intent sanitizedIntent, int[] hostDigestPrefix,
    public void onGetInstantAppResolveInfo(Intent sanitizedIntent, int[] hostDigestPrefix,
            String token, InstantAppResolutionCallback callback) {
            String token, InstantAppResolutionCallback callback) {
        // if not overridden, forward to old methods and filter out non-web intents
        // if not overridden, forward to old methods and filter out non-web intents
@@ -125,8 +129,12 @@ public abstract class InstantAppResolverService extends Service {
     *              InstantAppResolutionCallback)}
     *              InstantAppResolutionCallback)}
     *              and provided to the currently visible installer via
     *              and provided to the currently visible installer via
     *              {@link Intent#EXTRA_INSTANT_APP_TOKEN}.
     *              {@link Intent#EXTRA_INSTANT_APP_TOKEN}.
     * @param callback The {@link InstantAppResolutionCallback} to provide results to
     * @param callback The {@link InstantAppResolutionCallback} to provide results to.
     *
     * @deprecated Should implement {@link #onGetInstantAppIntentFilter(Intent, int[], UserHandle,
     *             String, InstantAppResolutionCallback)}.
     */
     */
    @Deprecated
    public void onGetInstantAppIntentFilter(Intent sanitizedIntent, int[] hostDigestPrefix,
    public void onGetInstantAppIntentFilter(Intent sanitizedIntent, int[] hostDigestPrefix,
            String token, InstantAppResolutionCallback callback) {
            String token, InstantAppResolutionCallback callback) {
        Log.e(TAG, "New onGetInstantAppIntentFilter is not overridden");
        Log.e(TAG, "New onGetInstantAppIntentFilter is not overridden");
@@ -138,6 +146,55 @@ public abstract class InstantAppResolverService extends Service {
        }
        }
    }
    }


    /**
     * 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[], UserHandle,
     * String, InstantAppResolutionCallback)}
     *
     * @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 userHandle The user for which to resolve the instant app.
     * @param token A unique identifier that will be provided in calls to {@link
     *              #onGetInstantAppIntentFilter(Intent, int[], UserHandle, 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,
            UserHandle userHandle, String token, InstantAppResolutionCallback callback) {
        // If not overridden, forward to the old method.
        onGetInstantAppResolveInfo(sanitizedIntent, hostDigestPrefix, token, callback);
    }

    /**
     * Called to retrieve intent filters for potentially matching instant applications. Unlike
     * {@link #onGetInstantAppResolveInfo(Intent, int[], UserHandle, 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 userHandle The user for which to resolve the instant app.
     * @param token A unique identifier that was provided in {@link #onGetInstantAppResolveInfo(
     *              Intent, int[], UserHandle, 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,
            UserHandle userHandle, String token, InstantAppResolutionCallback callback) {
        // If not overridden, forward to the old method.
        onGetInstantAppIntentFilter(sanitizedIntent, hostDigestPrefix, token, callback);
    }

    /**
    /**
     * Returns a {@link Looper} to perform service operations on.
     * Returns a {@link Looper} to perform service operations on.
     */
     */
@@ -156,30 +213,32 @@ public abstract class InstantAppResolverService extends Service {
        return new IInstantAppResolver.Stub() {
        return new IInstantAppResolver.Stub() {
            @Override
            @Override
            public void getInstantAppResolveInfoList(Intent sanitizedIntent, int[] digestPrefix,
            public void getInstantAppResolveInfoList(Intent sanitizedIntent, int[] digestPrefix,
                    String token, int sequence, IRemoteCallback callback) {
                    int userId, String token, int sequence, IRemoteCallback callback) {
                if (DEBUG_INSTANT) {
                if (DEBUG_INSTANT) {
                    Slog.v(TAG, "[" + token + "] Phase1 called; posting");
                    Slog.v(TAG, "[" + token + "] Phase1 called; posting");
                }
                }
                final SomeArgs args = SomeArgs.obtain();
                final SomeArgs args = SomeArgs.obtain();
                args.arg1 = callback;
                args.arg1 = callback;
                args.arg2 = digestPrefix;
                args.arg2 = digestPrefix;
                args.arg3 = token;
                args.arg3 = userId;
                args.arg4 = sanitizedIntent;
                args.arg4 = token;
                args.arg5 = sanitizedIntent;
                mHandler.obtainMessage(ServiceHandler.MSG_GET_INSTANT_APP_RESOLVE_INFO,
                mHandler.obtainMessage(ServiceHandler.MSG_GET_INSTANT_APP_RESOLVE_INFO,
                        sequence, 0, args).sendToTarget();
                        sequence, 0, args).sendToTarget();
            }
            }


            @Override
            @Override
            public void getInstantAppIntentFilterList(Intent sanitizedIntent,
            public void getInstantAppIntentFilterList(Intent sanitizedIntent,
                    int[] digestPrefix, String token, IRemoteCallback callback) {
                    int[] digestPrefix, int userId, String token, IRemoteCallback callback) {
                if (DEBUG_INSTANT) {
                if (DEBUG_INSTANT) {
                    Slog.v(TAG, "[" + token + "] Phase2 called; posting");
                    Slog.v(TAG, "[" + token + "] Phase2 called; posting");
                }
                }
                final SomeArgs args = SomeArgs.obtain();
                final SomeArgs args = SomeArgs.obtain();
                args.arg1 = callback;
                args.arg1 = callback;
                args.arg2 = digestPrefix;
                args.arg2 = digestPrefix;
                args.arg3 = token;
                args.arg3 = userId;
                args.arg4 = sanitizedIntent;
                args.arg4 = token;
                args.arg5 = sanitizedIntent;
                mHandler.obtainMessage(ServiceHandler.MSG_GET_INSTANT_APP_INTENT_FILTER,
                mHandler.obtainMessage(ServiceHandler.MSG_GET_INSTANT_APP_INTENT_FILTER,
                        callback).sendToTarget();
                        callback).sendToTarget();
            }
            }
@@ -224,14 +283,16 @@ public abstract class InstantAppResolverService extends Service {
                    final SomeArgs args = (SomeArgs) message.obj;
                    final SomeArgs args = (SomeArgs) message.obj;
                    final IRemoteCallback callback = (IRemoteCallback) args.arg1;
                    final IRemoteCallback callback = (IRemoteCallback) args.arg1;
                    final int[] digestPrefix = (int[]) args.arg2;
                    final int[] digestPrefix = (int[]) args.arg2;
                    final String token = (String) args.arg3;
                    final int userId = (int) args.arg3;
                    final Intent intent = (Intent) args.arg4;
                    final String token = (String) args.arg4;
                    final Intent intent = (Intent) args.arg5;
                    final int sequence = message.arg1;
                    final int sequence = message.arg1;
                    if (DEBUG_INSTANT) {
                    if (DEBUG_INSTANT) {
                        Slog.d(TAG, "[" + token + "] Phase1 request;"
                        Slog.d(TAG, "[" + token + "] Phase1 request;"
                                + " prefix: " + Arrays.toString(digestPrefix));
                                + " prefix: " + Arrays.toString(digestPrefix)
                                + ", userId: " + userId);
                    }
                    }
                    onGetInstantAppResolveInfo(intent, digestPrefix, token,
                    onGetInstantAppResolveInfo(intent, digestPrefix, UserHandle.of(userId), token,
                            new InstantAppResolutionCallback(sequence, callback));
                            new InstantAppResolutionCallback(sequence, callback));
                } break;
                } break;


@@ -239,13 +300,15 @@ public abstract class InstantAppResolverService extends Service {
                    final SomeArgs args = (SomeArgs) message.obj;
                    final SomeArgs args = (SomeArgs) message.obj;
                    final IRemoteCallback callback = (IRemoteCallback) args.arg1;
                    final IRemoteCallback callback = (IRemoteCallback) args.arg1;
                    final int[] digestPrefix = (int[]) args.arg2;
                    final int[] digestPrefix = (int[]) args.arg2;
                    final String token = (String) args.arg3;
                    final int userId = (int) args.arg3;
                    final Intent intent = (Intent) args.arg4;
                    final String token = (String) args.arg4;
                    final Intent intent = (Intent) args.arg5;
                    if (DEBUG_INSTANT) {
                    if (DEBUG_INSTANT) {
                        Slog.d(TAG, "[" + token + "] Phase2 request;"
                        Slog.d(TAG, "[" + token + "] Phase2 request;"
                                + " prefix: " + Arrays.toString(digestPrefix));
                                + " prefix: " + Arrays.toString(digestPrefix)
                                + ", userId: " + userId);
                    }
                    }
                    onGetInstantAppIntentFilter(intent, digestPrefix, token,
                    onGetInstantAppIntentFilter(intent, digestPrefix, UserHandle.of(userId), token,
                            new InstantAppResolutionCallback(-1 /*sequence*/, callback));
                            new InstantAppResolutionCallback(-1 /*sequence*/, callback));
                } break;
                } break;


+3 −3
Original line number Original line Diff line number Diff line
@@ -132,7 +132,7 @@ public abstract class InstantAppResolver {
        try {
        try {
            final List<InstantAppResolveInfo> instantAppResolveInfoList =
            final List<InstantAppResolveInfo> instantAppResolveInfoList =
                    connection.getInstantAppResolveInfoList(sanitizedIntent,
                    connection.getInstantAppResolveInfoList(sanitizedIntent,
                            requestObj.digest.getDigestPrefixSecure(), token);
                            requestObj.digest.getDigestPrefixSecure(), requestObj.userId, token);
            if (instantAppResolveInfoList != null && instantAppResolveInfoList.size() > 0) {
            if (instantAppResolveInfoList != null && instantAppResolveInfoList.size() > 0) {
                resolveInfo = InstantAppResolver.filterInstantAppIntent(
                resolveInfo = InstantAppResolver.filterInstantAppIntent(
                        instantAppResolveInfoList, origIntent, requestObj.resolvedType,
                        instantAppResolveInfoList, origIntent, requestObj.resolvedType,
@@ -224,8 +224,8 @@ public abstract class InstantAppResolver {
        };
        };
        try {
        try {
            connection.getInstantAppIntentFilterList(sanitizedIntent,
            connection.getInstantAppIntentFilterList(sanitizedIntent,
                    requestObj.digest.getDigestPrefixSecure(), token, callback, callbackHandler,
                    requestObj.digest.getDigestPrefixSecure(), requestObj.userId, token, callback,
                    startTime);
                    callbackHandler, startTime);
        } catch (ConnectionException e) {
        } catch (ConnectionException e) {
            @ResolutionStatus int resolutionStatus = RESOLUTION_FAILURE;
            @ResolutionStatus int resolutionStatus = RESOLUTION_FAILURE;
            if (e.failure == ConnectionException.FAILURE_BIND) {
            if (e.failure == ConnectionException.FAILURE_BIND) {
+10 −9
Original line number Original line Diff line number Diff line
@@ -85,8 +85,8 @@ final class InstantAppResolverConnection implements DeathRecipient {
        mBgHandler = BackgroundThread.getHandler();
        mBgHandler = BackgroundThread.getHandler();
    }
    }


    public final List<InstantAppResolveInfo> getInstantAppResolveInfoList(Intent sanitizedIntent,
    public List<InstantAppResolveInfo> getInstantAppResolveInfoList(Intent sanitizedIntent,
            int hashPrefix[], String token) throws ConnectionException {
            int[] hashPrefix, int userId, String token) throws ConnectionException {
        throwIfCalledOnMainThread();
        throwIfCalledOnMainThread();
        IInstantAppResolver target = null;
        IInstantAppResolver target = null;
        try {
        try {
@@ -99,7 +99,8 @@ final class InstantAppResolverConnection implements DeathRecipient {
            }
            }
            try {
            try {
                return mGetInstantAppResolveInfoCaller
                return mGetInstantAppResolveInfoCaller
                        .getInstantAppResolveInfoList(target, sanitizedIntent, hashPrefix, token);
                        .getInstantAppResolveInfoList(target, sanitizedIntent, hashPrefix, userId,
                                token);
            } catch (TimeoutException e) {
            } catch (TimeoutException e) {
                throw new ConnectionException(ConnectionException.FAILURE_CALL);
                throw new ConnectionException(ConnectionException.FAILURE_CALL);
            } catch (RemoteException ignore) {
            } catch (RemoteException ignore) {
@@ -112,7 +113,7 @@ final class InstantAppResolverConnection implements DeathRecipient {
        return null;
        return null;
    }
    }


    public final void getInstantAppIntentFilterList(Intent sanitizedIntent, int hashPrefix[],
    public void getInstantAppIntentFilterList(Intent sanitizedIntent, int[] hashPrefix, int userId,
            String token, PhaseTwoCallback callback, Handler callbackHandler, final long startTime)
            String token, PhaseTwoCallback callback, Handler callbackHandler, final long startTime)
            throws ConnectionException {
            throws ConnectionException {
        final IRemoteCallback remoteCallback = new IRemoteCallback.Stub() {
        final IRemoteCallback remoteCallback = new IRemoteCallback.Stub() {
@@ -126,7 +127,7 @@ final class InstantAppResolverConnection implements DeathRecipient {
        };
        };
        try {
        try {
            getRemoteInstanceLazy(token)
            getRemoteInstanceLazy(token)
                    .getInstantAppIntentFilterList(sanitizedIntent, hashPrefix, token,
                    .getInstantAppIntentFilterList(sanitizedIntent, hashPrefix, userId, token,
                            remoteCallback);
                            remoteCallback);
        } catch (TimeoutException e) {
        } catch (TimeoutException e) {
            throw new ConnectionException(ConnectionException.FAILURE_BIND);
            throw new ConnectionException(ConnectionException.FAILURE_BIND);
@@ -352,11 +353,11 @@ final class InstantAppResolverConnection implements DeathRecipient {
        }
        }


        public List<InstantAppResolveInfo> getInstantAppResolveInfoList(
        public List<InstantAppResolveInfo> getInstantAppResolveInfoList(
                IInstantAppResolver target, Intent sanitizedIntent,  int hashPrefix[], String token)
                IInstantAppResolver target, Intent sanitizedIntent, int[] hashPrefix, int userId,
                        throws RemoteException, TimeoutException {
                String token) throws RemoteException, TimeoutException {
            final int sequence = onBeforeRemoteCall();
            final int sequence = onBeforeRemoteCall();
            target.getInstantAppResolveInfoList(sanitizedIntent, hashPrefix, token, sequence,
            target.getInstantAppResolveInfoList(sanitizedIntent, hashPrefix, userId, token,
                    mCallback);
                    sequence, mCallback);
            return getResultTimed(sequence);
            return getResultTimed(sequence);
        }
        }
    }
    }