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

Commit f98a5efb authored by Cassie Wang's avatar Cassie Wang Committed by Android (Google) Code Review
Browse files

Merge "Prevent instant apps from using AppSearch." into sc-dev

parents 5d85d8f3 8417a0f2
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -90,6 +90,7 @@ public final class AppSearchSession implements Closeable {
            @NonNull Consumer<AppSearchResult<AppSearchSession>> callback) {
        try {
            mService.initialize(
                    mPackageName,
                    mUserHandle,
                    /*binderCallStartTimeMillis=*/ SystemClock.elapsedRealtime(),
                    new IAppSearchResultCallback.Stub() {
@@ -685,7 +686,9 @@ public final class AppSearchSession implements Closeable {
        if (mIsMutated && !mIsClosed) {
            try {
                mService.persistToDisk(
                        mUserHandle, /*binderCallStartTimeMillis=*/ SystemClock.elapsedRealtime());
                        mPackageName,
                        mUserHandle,
                        /*binderCallStartTimeMillis=*/ SystemClock.elapsedRealtime());
                mIsClosed = true;
            } catch (RemoteException e) {
                Log.e(TAG, "Unable to close the AppSearchSession", e);
+4 −1
Original line number Diff line number Diff line
@@ -73,6 +73,7 @@ public class GlobalSearchSession implements Closeable {
            @NonNull Consumer<AppSearchResult<GlobalSearchSession>> callback) {
        try {
            mService.initialize(
                    mPackageName,
                    mUserHandle,
                    /*binderCallStartTimeMillis=*/ SystemClock.elapsedRealtime(),
                    new IAppSearchResultCallback.Stub() {
@@ -187,7 +188,9 @@ public class GlobalSearchSession implements Closeable {
        if (mIsMutated && !mIsClosed) {
            try {
                mService.persistToDisk(
                        mUserHandle, /*binderCallStartTimeMillis=*/ SystemClock.elapsedRealtime());
                        mPackageName,
                        mUserHandle,
                        /*binderCallStartTimeMillis=*/ SystemClock.elapsedRealtime());
                mIsClosed = true;
            } catch (RemoteException e) {
                Log.e(TAG, "Unable to close the GlobalSearchSession", e);
+3 −2
Original line number Diff line number Diff line
@@ -124,7 +124,8 @@ public class SearchResults implements Closeable {
                            wrapCallback(executor, callback));
                }
            } else {
                mService.getNextPage(mNextPageToken, mUserHandle, wrapCallback(executor, callback));
                mService.getNextPage(mPackageName, mNextPageToken, mUserHandle,
                        wrapCallback(executor, callback));
            }
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
@@ -135,7 +136,7 @@ public class SearchResults implements Closeable {
    public void close() {
        if (!mIsClosed) {
            try {
                mService.invalidateNextPageToken(mNextPageToken, mUserHandle);
                mService.invalidateNextPageToken(mPackageName, mNextPageToken, mUserHandle);
                mIsClosed = true;
            } catch (RemoteException e) {
                Log.e(TAG, "Unable to close the SearchResults", e);
+18 −3
Original line number Diff line number Diff line
@@ -181,21 +181,30 @@ interface IAppSearchManager {
     * Fetches the next page of results of a previously executed query. Results can be empty if
     * next-page token is invalid or all pages have been returned.
     *
     * @param packageName The name of the package to persist to disk for.
     * @param nextPageToken The token of pre-loaded results of previously executed query.
     * @param userHandle Handle of the calling user
     * @param callback {@link AppSearchResult}&lt;{@link Bundle}&gt; of performing this
     *                  operation.
     */
    void getNextPage(in long nextPageToken, in UserHandle userHandle, in IAppSearchResultCallback callback);
    void getNextPage(
        in String packageName,
        in long nextPageToken,
        in UserHandle userHandle,
        in IAppSearchResultCallback callback);

    /**
     * Invalidates the next-page token so that no more results of the related query can be returned.
     *
     * @param packageName The name of the package to persist to disk for.
     * @param nextPageToken The token of pre-loaded results of previously executed query to be
     *                      Invalidated.
     * @param userHandle Handle of the calling user
     */
    void invalidateNextPageToken(in long nextPageToken, in UserHandle userHandle);
    void invalidateNextPageToken(
        in String packageName,
        in long nextPageToken,
        in UserHandle userHandle);

    /**
    * Searches a document based on a given specifications.
@@ -336,20 +345,26 @@ interface IAppSearchManager {
    /**
     * Persists all update/delete requests to the disk.
     *
     * @param packageName The name of the package to persist to disk for.
     * @param userHandle Handle of the calling user
     * @param binderCallStartTimeMillis start timestamp of binder call in Millis
     */
    void persistToDisk(in UserHandle userHandle, in long binderCallStartTimeMillis);
    void persistToDisk(
        in String packageName,
        in UserHandle userHandle,
        in long binderCallStartTimeMillis);

    /**
     * Creates and initializes AppSearchImpl for the calling app.
     *
     * @param packageName The name of the package to initialize for.
     * @param userHandle Handle of the calling user
     * @param binderCallStartTimeMillis start timestamp of binder call in Millis
     * @param callback {@link IAppSearchResultCallback#onResult} will be called with an
     *     {@link AppSearchResult}&lt;{@link Void}&gt;.
     */
    void initialize(
        in String packageName,
        in UserHandle userHandle,
        in long binderCallStartTimeMillis,
        in IAppSearchResultCallback callback);
+2 −0
Original line number Diff line number Diff line
@@ -239,6 +239,8 @@ public final class AppSearchResult<ValueType> {
            resultCode = AppSearchResult.RESULT_INVALID_ARGUMENT;
        } else if (t instanceof IOException) {
            resultCode = AppSearchResult.RESULT_IO_ERROR;
        } else if (t instanceof SecurityException) {
            resultCode = AppSearchResult.RESULT_SECURITY_ERROR;
        } else {
            resultCode = AppSearchResult.RESULT_UNKNOWN_ERROR;
        }
Loading