Debian Codegraph @

core/java/android/app/cloudsearch/CloudSearchManager.java

raw symbols SCIP
1 /*
2 * Copyright (C) 2022 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package android.app.cloudsearch;
17
18 import android.annotation.CallbackExecutor;
19 import android.annotation.NonNull;
20 import android.annotation.RequiresPermission;
21 import android.annotation.SystemApi;
22 import android.annotation.SystemService;
23 import android.content.Context;
24
25 import java.util.concurrent.Executor;
26
27 /**
28 * A {@link CloudSearchManager} is the class having all the information passed to search providers.
29 *
30 * @hide
31 */
32 @SystemApi
33 @SystemService(Context.CLOUDSEARCH_SERVICE)
34 public class CloudSearchManager {
35 /**
36 * CallBack Interface for this API.
37 */
38 public interface CallBack {
39 /**
40 * Invoked by receiving app with the result of the search.
41 *
42 * @param request original request for the search.
43 * @param response search result.
44 */
45 void onSearchSucceeded(@NonNull SearchRequest request, @NonNull SearchResponse response);
46
47 /**
48 * Invoked when the search is not successful.
49 * Each failure is recorded. The client may receive a failure from one provider and
50 * subsequently receive successful searches from other providers
51 *
52 * @param request original request for the search.
53 * @param response search result.
54 */
55 void onSearchFailed(@NonNull SearchRequest request, @NonNull SearchResponse response);
56 }
57
58 /** @hide **/
59 public CloudSearchManager() {
60
61 }
62
63 /**
64 * Execute an {@link android.app.cloudsearch.SearchRequest} from the given parameters
65 * to the designated cloud lookup services. After the lookup is done, the given
66 * callback will be invoked by the system with the result or lack thereof.
67 *
68 * @param request request to be searched.
69 * @param callbackExecutor where the callback is invoked.
70 * @param callback invoked when the result is available.
71 * @hide
72 */
73 @SystemApi
74 @RequiresPermission(android.Manifest.permission.MANAGE_CLOUDSEARCH)
75 public void search(@NonNull SearchRequest request,
76 @NonNull @CallbackExecutor Executor callbackExecutor,
77 @NonNull CallBack callback) {
78 callbackExecutor.execute(
79 () -> callback.onSearchFailed(request,
80 new SearchResponse.Builder(SearchResponse.SEARCH_STATUS_UNKNOWN).build()));
81 }
82 }