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

Commit 2749ee76 authored by Hui Wu's avatar Hui Wu Committed by Android (Google) Code Review
Browse files

Merge "Merge "Remove impl of cloudsearch api" into tm-qpr-dev am: aa0ffaee am: 9af4e0bd"

parents 028f9665 8ad644d5
Loading
Loading
Loading
Loading
+0 −13
Original line number Diff line number Diff line
@@ -29,8 +29,6 @@ import android.app.ambientcontext.AmbientContextManager;
import android.app.ambientcontext.IAmbientContextManager;
import android.app.appsearch.AppSearchManagerFrameworkInitializer;
import android.app.blob.BlobStoreManagerFrameworkInitializer;
import android.app.cloudsearch.CloudSearchManager;
import android.app.cloudsearch.ICloudSearchManager;
import android.app.contentsuggestions.ContentSuggestionsManager;
import android.app.contentsuggestions.IContentSuggestionsManager;
import android.app.job.JobSchedulerFrameworkInitializer;
@@ -1220,17 +1218,6 @@ public final class SystemServiceRegistry {
                }
            });

        registerService(Context.CLOUDSEARCH_SERVICE, CloudSearchManager.class,
            new CachedServiceFetcher<CloudSearchManager>() {
                @Override
                public CloudSearchManager createService(ContextImpl ctx)
                    throws ServiceNotFoundException {
                    IBinder b = ServiceManager.getService(Context.CLOUDSEARCH_SERVICE);
                    return b == null ? null :
                        new CloudSearchManager(ICloudSearchManager.Stub.asInterface(b));
                }
            });

        registerService(Context.APP_PREDICTION_SERVICE, AppPredictionManager.class,
                new CachedServiceFetcher<AppPredictionManager>() {
            @Override
+10 −56
Original line number Diff line number Diff line
@@ -15,17 +15,15 @@
 */
package android.app.cloudsearch;

import static java.util.Objects.requireNonNull;

import android.annotation.CallbackExecutor;
import android.annotation.NonNull;
import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
import android.annotation.SystemService;
import android.content.Context;
import android.os.RemoteException;

import java.util.concurrent.Executor;

/**
 * A {@link CloudSearchManager} is the  class having all the information passed to search providers.
 *
@@ -57,11 +55,9 @@ public class CloudSearchManager {
        void onSearchFailed(@NonNull SearchRequest request, @NonNull SearchResponse response);
    }

    private final ICloudSearchManager mService;

    /** @hide **/
    public CloudSearchManager(@NonNull ICloudSearchManager service) {
        mService = service;
    public CloudSearchManager() {

    }

    /**
@@ -72,7 +68,6 @@ public class CloudSearchManager {
     * @param request          request to be searched.
     * @param callbackExecutor where the callback is invoked.
     * @param callback         invoked when the result is available.
     *
     * @hide
     */
    @SystemApi
@@ -80,49 +75,8 @@ public class CloudSearchManager {
    public void search(@NonNull SearchRequest request,
            @NonNull @CallbackExecutor Executor callbackExecutor,
            @NonNull CallBack callback) {
        try {
            mService.search(
                    requireNonNull(request),
                    new CallBackWrapper(
                        requireNonNull(request),
                        requireNonNull(callback),
                        requireNonNull(callbackExecutor)));
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    private final class CallBackWrapper extends
            ICloudSearchManagerCallback.Stub {
        @NonNull
        private final SearchRequest mSearchRequest;

        @NonNull
        private final CallBack mCallback;

        @NonNull
        private final Executor mCallbackExecutor;

        CallBackWrapper(
                SearchRequest searchRequest,
                CallBack callback,
                Executor callbackExecutor) {
            mSearchRequest = searchRequest;
            mCallback = callback;
            mCallbackExecutor = callbackExecutor;
        }


        @Override
        public void onSearchSucceeded(SearchResponse searchResponse) {
            mCallbackExecutor.execute(
                    () -> mCallback.onSearchSucceeded(mSearchRequest, searchResponse));
        }

        @Override
        public void onSearchFailed(SearchResponse searchResponse) {
            mCallbackExecutor.execute(
                    () -> mCallback.onSearchFailed(mSearchRequest, searchResponse));
        }
        callbackExecutor.execute(
                () -> callback.onSearchFailed(request,
                        new SearchResponse.Builder(SearchResponse.SEARCH_STATUS_UNKNOWN).build()));
    }
}
+0 −33
Original line number Diff line number Diff line
/**
 * Copyright (c) 2022, The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.app.cloudsearch;

import android.app.cloudsearch.SearchRequest;
import android.app.cloudsearch.SearchResponse;
import android.app.cloudsearch.ICloudSearchManagerCallback;

/**
 * Used by {@link CloudSearchManager} to tell system server to do search.
 *
 * @hide
 */
oneway interface ICloudSearchManager {
  void search(in SearchRequest request, in ICloudSearchManagerCallback callBack);

  void returnResults(in IBinder token, in String requestId,
                     in SearchResponse response);
}
+0 −31
Original line number Diff line number Diff line
/**
 * Copyright (c) 2022, The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.app.cloudsearch;

import android.app.cloudsearch.SearchResponse;


/**
 * Callback used by system server to notify invoker of {@link CloudSearchManager} of the result
 *
 * @hide
 */
oneway interface ICloudSearchManagerCallback {
  void onSearchSucceeded(in SearchResponse response);

  void onSearchFailed(in SearchResponse response);
}
+0 −19
Original line number Diff line number Diff line
/**
 * Copyright (c) 2022, The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.app.cloudsearch;

parcelable SearchRequest;
Loading