diff options
| author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-09-24 05:16:00 +0000 |
|---|---|---|
| committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-09-24 05:16:00 +0000 |
| commit | cfe00f41fa388e98c577bf3bd727dc47d3e49ef5 (patch) | |
| tree | ff10a7991dc6d686d2fa240a6a210b1582a675d2 /core/java/android | |
| parent | 3bb8d8b8a985178e798b5b19d3336b536493c1db (diff) | |
| parent | b2689e0350009e5c1edbf46c0b33da540f2335b6 (diff) | |
Snap for 9101843 from b2689e0350009e5c1edbf46c0b33da540f2335b6 to tm-qpr1-release
Change-Id: Ifdeeaa82d370f1407f296d46826984cf96d17105
Diffstat (limited to 'core/java/android')
16 files changed, 132 insertions, 630 deletions
diff --git a/core/java/android/app/SystemServiceRegistry.java b/core/java/android/app/SystemServiceRegistry.java index 6615374f71ec..b6189692107e 100644 --- a/core/java/android/app/SystemServiceRegistry.java +++ b/core/java/android/app/SystemServiceRegistry.java @@ -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; @@ -230,8 +228,6 @@ import android.view.contentcapture.ContentCaptureManager; import android.view.contentcapture.IContentCaptureManager; import android.view.displayhash.DisplayHashManager; import android.view.inputmethod.InputMethodManager; -import android.view.selectiontoolbar.ISelectionToolbarManager; -import android.view.selectiontoolbar.SelectionToolbarManager; import android.view.textclassifier.TextClassificationManager; import android.view.textservice.TextServicesManager; import android.view.translation.ITranslationManager; @@ -365,15 +361,6 @@ public final class SystemServiceRegistry { return new TextClassificationManager(ctx); }}); - registerService(Context.SELECTION_TOOLBAR_SERVICE, SelectionToolbarManager.class, - new CachedServiceFetcher<SelectionToolbarManager>() { - @Override - public SelectionToolbarManager createService(ContextImpl ctx) { - IBinder b = ServiceManager.getService(Context.SELECTION_TOOLBAR_SERVICE); - return new SelectionToolbarManager(ctx.getOuterContext(), - ISelectionToolbarManager.Stub.asInterface(b)); - }}); - registerService(Context.FONT_SERVICE, FontManager.class, new CachedServiceFetcher<FontManager>() { @Override @@ -1231,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 diff --git a/core/java/android/app/cloudsearch/CloudSearchManager.java b/core/java/android/app/cloudsearch/CloudSearchManager.java index 471e423db458..b7bbf4712842 100644 --- a/core/java/android/app/cloudsearch/CloudSearchManager.java +++ b/core/java/android/app/cloudsearch/CloudSearchManager.java @@ -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. * @@ -41,7 +39,7 @@ public class CloudSearchManager { /** * Invoked by receiving app with the result of the search. * - * @param request original request for the search. + * @param request original request for the search. * @param response search result. */ void onSearchSucceeded(@NonNull SearchRequest request, @NonNull SearchResponse response); @@ -51,17 +49,15 @@ public class CloudSearchManager { * Each failure is recorded. The client may receive a failure from one provider and * subsequently receive successful searches from other providers * - * @param request original request for the search. + * @param request original request for the search. * @param response search result. */ void onSearchFailed(@NonNull SearchRequest request, @NonNull SearchResponse response); } - private final ICloudSearchManager mService; - /** @hide **/ - public CloudSearchManager(@NonNull ICloudSearchManager service) { - mService = service; + public CloudSearchManager() { + } /** @@ -69,10 +65,9 @@ public class CloudSearchManager { * to the designated cloud lookup services. After the lookup is done, the given * callback will be invoked by the system with the result or lack thereof. * - * @param request request to be searched. + * @param request request to be searched. * @param callbackExecutor where the callback is invoked. - * @param callback invoked when the result is available. - * + * @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())); } } diff --git a/core/java/android/app/cloudsearch/ICloudSearchManager.aidl b/core/java/android/app/cloudsearch/ICloudSearchManager.aidl deleted file mode 100644 index 18f8fc476191..000000000000 --- a/core/java/android/app/cloudsearch/ICloudSearchManager.aidl +++ /dev/null @@ -1,33 +0,0 @@ -/** - * 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); -} diff --git a/core/java/android/app/cloudsearch/ICloudSearchManagerCallback.aidl b/core/java/android/app/cloudsearch/ICloudSearchManagerCallback.aidl deleted file mode 100644 index 84771dd4a19b..000000000000 --- a/core/java/android/app/cloudsearch/ICloudSearchManagerCallback.aidl +++ /dev/null @@ -1,31 +0,0 @@ -/** - * 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); -} diff --git a/core/java/android/app/cloudsearch/SearchRequest.aidl b/core/java/android/app/cloudsearch/SearchRequest.aidl deleted file mode 100644 index 9f2cdb888bdf..000000000000 --- a/core/java/android/app/cloudsearch/SearchRequest.aidl +++ /dev/null @@ -1,19 +0,0 @@ -/** - * 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; diff --git a/core/java/android/app/cloudsearch/SearchRequest.java b/core/java/android/app/cloudsearch/SearchRequest.java index bf783255b3d9..3725b36a1c7f 100644 --- a/core/java/android/app/cloudsearch/SearchRequest.java +++ b/core/java/android/app/cloudsearch/SearchRequest.java @@ -15,8 +15,6 @@ */ package android.app.cloudsearch; -import static java.util.Objects.requireNonNull; - import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.StringDef; @@ -28,7 +26,6 @@ import android.os.Parcelable; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; -import java.util.Objects; /** * A {@link SearchRequest} is the data class having all the information passed to search providers. @@ -39,36 +36,6 @@ import java.util.Objects; public final class SearchRequest implements Parcelable { /** - * Query for search. - */ - @NonNull - private final String mQuery; - - /** - * Expected result offset for pagination. - * - * The default value is 0. - */ - private final int mResultOffset; - - /** - * Expected search result number. - * - * The default value is 10. - */ - private final int mResultNumber; - - /** - * The max acceptable latency. - * - * The default value is 200 milliseconds. - */ - private final float mMaxLatencyMillis; - - @Nullable - private String mId = null; - - /** * List of public static KEYS for the Bundle to mSearchConstraints. mSearchConstraints * contains various constraints specifying the search intent. * @@ -76,121 +43,83 @@ public final class SearchRequest implements Parcelable { */ @Retention(RetentionPolicy.SOURCE) @StringDef(prefix = {"CONSTRAINT_"}, - value = {CONSTRAINT_IS_PRESUBMIT_SUGGESTION, - CONSTRAINT_SEARCH_PROVIDER_FILTER}) - public @interface SearchConstraintKey {} - /** If this is a presubmit suggestion, Boolean value expected. - * presubmit is the input before the user finishes the entire query, i.e. push "ENTER" or - * "SEARCH" button. After the user finishes the entire query, the behavior is postsubmit. + value = {CONSTRAINT_IS_PRESUBMIT_SUGGESTION, + CONSTRAINT_SEARCH_PROVIDER_FILTER}) + public @interface SearchConstraintKey { + } + + /** + * If this is a presubmit suggestion, Boolean value expected. + * presubmit is the input before the user finishes the entire query, i.e. push "ENTER" or + * "SEARCH" button. After the user finishes the entire query, the behavior is postsubmit. */ public static final String CONSTRAINT_IS_PRESUBMIT_SUGGESTION = "android.app.cloudsearch.IS_PRESUBMIT_SUGGESTION"; - /** The target search provider list of package names(separated by ;), String value expected. + /** + * The target search provider list of package names(separated by ;), String value expected. * If this is not provided or its value is empty, then no filter will be applied. */ public static final String CONSTRAINT_SEARCH_PROVIDER_FILTER = "android.app.cloudsearch.SEARCH_PROVIDER_FILTER"; - @NonNull - private Bundle mSearchConstraints; - - /** Auto set by system servier, and the caller cannot set it. - * - * The caller's package name. - * - */ - @NonNull - private String mCallerPackageName; - - private SearchRequest(Parcel in) { - this.mQuery = in.readString(); - this.mResultOffset = in.readInt(); - this.mResultNumber = in.readInt(); - this.mMaxLatencyMillis = in.readFloat(); - this.mSearchConstraints = in.readBundle(); - this.mId = in.readString(); - this.mCallerPackageName = in.readString(); - } - - private SearchRequest(String query, int resultOffset, int resultNumber, float maxLatencyMillis, - Bundle searchConstraints, String callerPackageName) { - mQuery = query; - mResultOffset = resultOffset; - mResultNumber = resultNumber; - mMaxLatencyMillis = maxLatencyMillis; - mSearchConstraints = searchConstraints; - mCallerPackageName = callerPackageName; + private SearchRequest() { } /** Returns the original query. */ @NonNull public String getQuery() { - return mQuery; + return ""; } /** Returns the result offset. */ public int getResultOffset() { - return mResultOffset; + return 0; } /** Returns the expected number of search results. */ public int getResultNumber() { - return mResultNumber; + return 0; } /** Returns the maximum latency requirement. */ public float getMaxLatencyMillis() { - return mMaxLatencyMillis; + return 0; } /** Returns the search constraints. */ @NonNull public Bundle getSearchConstraints() { - return mSearchConstraints; + return Bundle.EMPTY; } /** Gets the caller's package name. */ @NonNull public String getCallerPackageName() { - return mCallerPackageName; + return ""; } /** Returns the search request id, which is used to identify the request. */ @NonNull public String getRequestId() { - if (mId == null || mId.length() == 0) { - mId = String.valueOf(toString().hashCode()); - } - - return mId; + return ""; } - /** Sets the caller, and this will be set by the system server. + /** + * Sets the caller, and this will be set by the system server. * * @hide */ public void setCallerPackageName(@NonNull String callerPackageName) { - this.mCallerPackageName = callerPackageName; - } - - private SearchRequest(Builder b) { - mQuery = requireNonNull(b.mQuery); - mResultOffset = b.mResultOffset; - mResultNumber = b.mResultNumber; - mMaxLatencyMillis = b.mMaxLatencyMillis; - mSearchConstraints = requireNonNull(b.mSearchConstraints); - mCallerPackageName = requireNonNull(b.mCallerPackageName); } /** * @see Creator - * */ @NonNull public static final Creator<SearchRequest> CREATOR = new Creator<SearchRequest>() { @Override public SearchRequest createFromParcel(Parcel p) { - return new SearchRequest(p); + return new SearchRequest(); } @Override @@ -201,13 +130,6 @@ public final class SearchRequest implements Parcelable { @Override public void writeToParcel(@NonNull Parcel dest, int flags) { - dest.writeString(this.mQuery); - dest.writeInt(this.mResultOffset); - dest.writeInt(this.mResultNumber); - dest.writeFloat(this.mMaxLatencyMillis); - dest.writeBundle(this.mSearchConstraints); - dest.writeString(getRequestId()); - dest.writeString(this.mCallerPackageName); } @Override @@ -217,44 +139,17 @@ public final class SearchRequest implements Parcelable { @Override public boolean equals(Object obj) { - if (this == obj) { - return true; - } - - if (obj == null || getClass() != obj.getClass()) { - return false; - } - - SearchRequest that = (SearchRequest) obj; - return Objects.equals(mQuery, that.mQuery) - && mResultOffset == that.mResultOffset - && mResultNumber == that.mResultNumber - && mMaxLatencyMillis == that.mMaxLatencyMillis - && Objects.equals(mSearchConstraints, that.mSearchConstraints) - && Objects.equals(mCallerPackageName, that.mCallerPackageName); + return false; } @Override public String toString() { - boolean isPresubmit = - mSearchConstraints.containsKey(CONSTRAINT_IS_PRESUBMIT_SUGGESTION) - && mSearchConstraints.getBoolean(CONSTRAINT_IS_PRESUBMIT_SUGGESTION); - - String searchProvider = "EMPTY"; - if (mSearchConstraints.containsKey(CONSTRAINT_SEARCH_PROVIDER_FILTER)) { - searchProvider = mSearchConstraints.getString(CONSTRAINT_SEARCH_PROVIDER_FILTER); - } - - return String.format("SearchRequest: {query:%s,offset:%d;number:%d;max_latency:%f;" - + "is_presubmit:%b;search_provider:%s;callerPackageName:%s}", mQuery, - mResultOffset, mResultNumber, mMaxLatencyMillis, isPresubmit, searchProvider, - mCallerPackageName); + return ""; } @Override public int hashCode() { - return Objects.hash(mQuery, mResultOffset, mResultNumber, mMaxLatencyMillis, - mSearchConstraints, mCallerPackageName); + return 0; } /** @@ -264,87 +159,62 @@ public final class SearchRequest implements Parcelable { */ @SystemApi public static final class Builder { - private String mQuery; - private int mResultOffset; - private int mResultNumber; - private float mMaxLatencyMillis; - private Bundle mSearchConstraints; - private String mCallerPackageName; - /** - * * @param query the query for search. - * * @hide */ @SystemApi public Builder(@NonNull String query) { - mQuery = query; - - mResultOffset = 0; - mResultNumber = 10; - mMaxLatencyMillis = 200; - mSearchConstraints = Bundle.EMPTY; - mCallerPackageName = "DEFAULT_CALLER"; } /** Sets the input query. */ @NonNull public Builder setQuery(@NonNull String query) { - this.mQuery = query; return this; } /** Sets the search result offset. */ @NonNull public Builder setResultOffset(int resultOffset) { - this.mResultOffset = resultOffset; return this; } /** Sets the expected number of search result. */ @NonNull public Builder setResultNumber(int resultNumber) { - this.mResultNumber = resultNumber; return this; } /** Sets the maximum acceptable search latency. */ @NonNull public Builder setMaxLatencyMillis(float maxLatencyMillis) { - this.mMaxLatencyMillis = maxLatencyMillis; return this; } - /** Sets the search constraints, such as the user location, the search type(presubmit or - * postsubmit), and the target search providers. */ + /** + * Sets the search constraints, such as the user location, the search type(presubmit or + * postsubmit), and the target search providers. + */ @NonNull public Builder setSearchConstraints(@Nullable Bundle searchConstraints) { - this.mSearchConstraints = searchConstraints; return this; } - /** Sets the caller, and this will be set by the system server. + /** + * Sets the caller, and this will be set by the system server. * * @hide */ @NonNull @TestApi public Builder setCallerPackageName(@NonNull String callerPackageName) { - this.mCallerPackageName = callerPackageName; return this; } /** Builds a SearchRequest based-on the given params. */ @NonNull public SearchRequest build() { - if (mQuery == null || mResultOffset < 0 || mResultNumber < 1 || mMaxLatencyMillis < 0 - || mSearchConstraints == null) { - throw new IllegalStateException("Please make sure all required args are valid."); - } - - return new SearchRequest(mQuery, mResultOffset, mResultNumber, mMaxLatencyMillis, - mSearchConstraints, mCallerPackageName); + return new SearchRequest(); } } } diff --git a/core/java/android/app/cloudsearch/SearchResponse.aidl b/core/java/android/app/cloudsearch/SearchResponse.aidl deleted file mode 100644 index 2064d112c6b9..000000000000 --- a/core/java/android/app/cloudsearch/SearchResponse.aidl +++ /dev/null @@ -1,19 +0,0 @@ -/** - * 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 SearchResponse;
\ No newline at end of file diff --git a/core/java/android/app/cloudsearch/SearchResponse.java b/core/java/android/app/cloudsearch/SearchResponse.java index 607bd561d331..c86142e0d22d 100644 --- a/core/java/android/app/cloudsearch/SearchResponse.java +++ b/core/java/android/app/cloudsearch/SearchResponse.java @@ -15,8 +15,6 @@ */ package android.app.cloudsearch; -import static java.util.Objects.requireNonNull; - import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.SystemApi; @@ -25,7 +23,6 @@ import android.os.Parcelable; import java.util.ArrayList; import java.util.List; -import java.util.Objects; /** * A {@link SearchResponse} includes search results and associated meta information. @@ -37,77 +34,53 @@ public final class SearchResponse implements Parcelable { /** @hide */ @IntDef(prefix = {"SEARCH_STATUS_"}, value = {SEARCH_STATUS_UNKNOWN, - SEARCH_STATUS_OK, - SEARCH_STATUS_TIME_OUT, - SEARCH_STATUS_NO_INTERNET}) - public @interface SearchStatusCode {} + SEARCH_STATUS_OK, + SEARCH_STATUS_TIME_OUT, + SEARCH_STATUS_NO_INTERNET}) + public @interface SearchStatusCode { + } + public static final int SEARCH_STATUS_UNKNOWN = -1; public static final int SEARCH_STATUS_OK = 0; public static final int SEARCH_STATUS_TIME_OUT = 1; public static final int SEARCH_STATUS_NO_INTERNET = 2; - private final int mStatusCode; - - /** Auto set by system servier, and the provider cannot set it. */ - @NonNull - private String mSource; - - @NonNull - private final List<SearchResult> mSearchResults; - - private SearchResponse(Parcel in) { - this.mStatusCode = in.readInt(); - this.mSource = in.readString(); - this.mSearchResults = in.createTypedArrayList(SearchResult.CREATOR); - } - - private SearchResponse(@SearchStatusCode int statusCode, String source, - List<SearchResult> searchResults) { - mStatusCode = statusCode; - mSource = source; - mSearchResults = searchResults; + private SearchResponse() { } /** Gets the search status code. */ public int getStatusCode() { - return mStatusCode; + return SEARCH_STATUS_UNKNOWN; } /** Gets the search provider package name. */ @NonNull public String getSource() { - return mSource; + return ""; } /** Gets the search results, which can be empty. */ @NonNull public List<SearchResult> getSearchResults() { - return mSearchResults; + return new ArrayList<SearchResult>(); } - /** Sets the search provider, and this will be set by the system server. + /** + * Sets the search provider, and this will be set by the system server. * * @hide */ public void setSource(@NonNull String source) { - this.mSource = source; - } - - private SearchResponse(Builder b) { - mStatusCode = b.mStatusCode; - mSource = requireNonNull(b.mSource); - mSearchResults = requireNonNull(b.mSearchResults); } /** - * * @see Creator - * */ - @NonNull public static final Creator<SearchResponse> CREATOR = new Creator<SearchResponse>() { + @NonNull + public static final Creator<SearchResponse> CREATOR = new Creator<SearchResponse>() { @Override public SearchResponse createFromParcel(Parcel p) { - return new SearchResponse(p); + return new SearchResponse(); } @Override @@ -118,9 +91,6 @@ public final class SearchResponse implements Parcelable { @Override public void writeToParcel(@NonNull Parcel dest, int flags) { - dest.writeInt(this.mStatusCode); - dest.writeString(this.mSource); - dest.writeTypedList(this.mSearchResults); } @Override @@ -130,23 +100,12 @@ public final class SearchResponse implements Parcelable { @Override public boolean equals(Object obj) { - if (this == obj) { - return true; - } - - if (obj == null || getClass() != obj.getClass()) { - return false; - } - - SearchResponse that = (SearchResponse) obj; - return mStatusCode == that.mStatusCode - && Objects.equals(mSource, that.mSource) - && Objects.equals(mSearchResults, that.mSearchResults); + return false; } @Override public int hashCode() { - return Objects.hash(mStatusCode, mSource, mSearchResults); + return 0; } /** @@ -156,59 +115,40 @@ public final class SearchResponse implements Parcelable { */ @SystemApi public static final class Builder { - private int mStatusCode; - private String mSource; - private List<SearchResult> mSearchResults; - /** - * * @param statusCode the search status code. - * * @hide */ @SystemApi public Builder(@SearchStatusCode int statusCode) { - mStatusCode = statusCode; - - /** Init with a default value. */ - mSource = "DEFAULT"; - - mSearchResults = new ArrayList<SearchResult>(); } /** Sets the search status code. */ @NonNull public Builder setStatusCode(@SearchStatusCode int statusCode) { - this.mStatusCode = statusCode; return this; } - /** Sets the search provider, and this will be set by the system server. + /** + * Sets the search provider, and this will be set by the system server. * * @hide */ @NonNull public Builder setSource(@NonNull String source) { - this.mSource = source; return this; } /** Sets the search results. */ @NonNull public Builder setSearchResults(@NonNull List<SearchResult> searchResults) { - this.mSearchResults = searchResults; return this; } /** Builds a SearchResponse based-on the given parameters. */ @NonNull public SearchResponse build() { - if (mStatusCode < SEARCH_STATUS_UNKNOWN || mStatusCode > SEARCH_STATUS_NO_INTERNET - || mSearchResults == null) { - throw new IllegalStateException("Please make sure all @NonNull args are assigned."); - } - - return new SearchResponse(mStatusCode, mSource, mSearchResults); + return new SearchResponse(); } } } diff --git a/core/java/android/app/cloudsearch/SearchResult.aidl b/core/java/android/app/cloudsearch/SearchResult.aidl deleted file mode 100644 index daebfbf3307f..000000000000 --- a/core/java/android/app/cloudsearch/SearchResult.aidl +++ /dev/null @@ -1,19 +0,0 @@ -/** - * 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 SearchResult;
\ No newline at end of file diff --git a/core/java/android/app/cloudsearch/SearchResult.java b/core/java/android/app/cloudsearch/SearchResult.java index c6583b65f9c2..123c3a2a5f48 100644 --- a/core/java/android/app/cloudsearch/SearchResult.java +++ b/core/java/android/app/cloudsearch/SearchResult.java @@ -15,8 +15,6 @@ */ package android.app.cloudsearch; -import static java.util.Objects.requireNonNull; - import android.annotation.NonNull; import android.annotation.StringDef; import android.annotation.SuppressLint; @@ -27,7 +25,6 @@ import android.os.Parcelable; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; -import java.util.Objects; /** * A {@link SearchResult} includes all the information for one result item. @@ -37,17 +34,6 @@ import java.util.Objects; @SystemApi public final class SearchResult implements Parcelable { - /** Short content best describing the result item. */ - @NonNull - private final String mTitle; - - /** Matched contents in the result item. */ - @NonNull - private final String mSnippet; - - /** Ranking Score provided by the search provider. */ - private final float mScore; - /** * List of public static KEYS for Bundles in mExtraInfos. * mExtraInfos contains various information specified for different data types. @@ -56,28 +42,30 @@ public final class SearchResult implements Parcelable { */ @Retention(RetentionPolicy.SOURCE) @StringDef(prefix = {"EXTRAINFO_"}, - value = {EXTRAINFO_APP_DOMAIN_URL, - EXTRAINFO_APP_ICON, - EXTRAINFO_APP_DEVELOPER_NAME, - EXTRAINFO_APP_SIZE_BYTES, - EXTRAINFO_APP_STAR_RATING, - EXTRAINFO_APP_IARC, - EXTRAINFO_APP_REVIEW_COUNT, - EXTRAINFO_APP_CONTAINS_ADS_DISCLAIMER, - EXTRAINFO_APP_CONTAINS_IAP_DISCLAIMER, - EXTRAINFO_SHORT_DESCRIPTION, - EXTRAINFO_LONG_DESCRIPTION, - EXTRAINFO_SCREENSHOTS, - EXTRAINFO_APP_BADGES, - EXTRAINFO_ACTION_BUTTON_TEXT_PREREGISTERING, - EXTRAINFO_ACTION_BUTTON_IMAGE_PREREGISTERING, - EXTRAINFO_ACTION_APP_CARD, - EXTRAINFO_ACTION_INSTALL_BUTTON, - EXTRAINFO_APP_PACKAGE_NAME, - EXTRAINFO_APP_INSTALL_COUNT, - EXTRAINFO_WEB_URL, - EXTRAINFO_WEB_ICON}) - public @interface SearchResultExtraInfoKey {} + value = {EXTRAINFO_APP_DOMAIN_URL, + EXTRAINFO_APP_ICON, + EXTRAINFO_APP_DEVELOPER_NAME, + EXTRAINFO_APP_SIZE_BYTES, + EXTRAINFO_APP_STAR_RATING, + EXTRAINFO_APP_IARC, + EXTRAINFO_APP_REVIEW_COUNT, + EXTRAINFO_APP_CONTAINS_ADS_DISCLAIMER, + EXTRAINFO_APP_CONTAINS_IAP_DISCLAIMER, + EXTRAINFO_SHORT_DESCRIPTION, + EXTRAINFO_LONG_DESCRIPTION, + EXTRAINFO_SCREENSHOTS, + EXTRAINFO_APP_BADGES, + EXTRAINFO_ACTION_BUTTON_TEXT_PREREGISTERING, + EXTRAINFO_ACTION_BUTTON_IMAGE_PREREGISTERING, + EXTRAINFO_ACTION_APP_CARD, + EXTRAINFO_ACTION_INSTALL_BUTTON, + EXTRAINFO_APP_PACKAGE_NAME, + EXTRAINFO_APP_INSTALL_COUNT, + EXTRAINFO_WEB_URL, + EXTRAINFO_WEB_ICON}) + public @interface SearchResultExtraInfoKey { + } + /** This App developer website's domain URL, String value expected. */ public static final String EXTRAINFO_APP_DOMAIN_URL = "android.app.cloudsearch.APP_DOMAIN_URL"; /** This App icon, android.graphics.drawable.Icon expected. */ @@ -90,7 +78,8 @@ public final class SearchResult implements Parcelable { /** This App developer's name, Double value expected. */ public static final String EXTRAINFO_APP_STAR_RATING = "android.app.cloudsearch.APP_STAR_RATING"; - /** This App's IARC rating, String value expected. + /** + * This App's IARC rating, String value expected. * IARC (International Age Rating Coalition) is partnered globally with major * content rating organizations to provide a centralized and one-stop-shop for * rating content on a global scale. @@ -142,62 +131,40 @@ public final class SearchResult implements Parcelable { /** Web content's domain icon, android.graphics.drawable.Icon expected. */ public static final String EXTRAINFO_WEB_ICON = "android.app.cloudsearch.WEB_ICON"; - @NonNull - private Bundle mExtraInfos; - - private SearchResult(Parcel in) { - this.mTitle = in.readString(); - this.mSnippet = in.readString(); - this.mScore = in.readFloat(); - this.mExtraInfos = in.readBundle(); - } - - private SearchResult(String title, String snippet, float score, Bundle extraInfos) { - mTitle = title; - mSnippet = snippet; - mScore = score; - mExtraInfos = extraInfos; + private SearchResult() { } /** Gets the search result title. */ @NonNull public String getTitle() { - return mTitle; + return ""; } /** Gets the search result snippet. */ @NonNull public String getSnippet() { - return mSnippet; + return ""; } /** Gets the ranking score provided by the original search provider. */ public float getScore() { - return mScore; + return 0; } /** Gets the extra information associated with the search result. */ @NonNull public Bundle getExtraInfos() { - return mExtraInfos; - } - - private SearchResult(Builder b) { - mTitle = requireNonNull(b.mTitle); - mSnippet = requireNonNull(b.mSnippet); - mScore = b.mScore; - mExtraInfos = requireNonNull(b.mExtraInfos); + return Bundle.EMPTY; } /** - * * @see Creator - * */ - @NonNull public static final Creator<SearchResult> CREATOR = new Creator<SearchResult>() { + @NonNull + public static final Creator<SearchResult> CREATOR = new Creator<SearchResult>() { @Override public SearchResult createFromParcel(Parcel p) { - return new SearchResult(p); + return new SearchResult(); } @Override @@ -208,10 +175,6 @@ public final class SearchResult implements Parcelable { @Override public void writeToParcel(@NonNull Parcel dest, int flags) { - dest.writeString(this.mTitle); - dest.writeString(this.mSnippet); - dest.writeFloat(this.mScore); - dest.writeBundle(this.mExtraInfos); } @Override @@ -221,24 +184,12 @@ public final class SearchResult implements Parcelable { @Override public boolean equals(Object obj) { - if (this == obj) { - return true; - } - - if (obj == null || getClass() != obj.getClass()) { - return false; - } - - SearchResult that = (SearchResult) obj; - return Objects.equals(mTitle, that.mTitle) - && Objects.equals(mSnippet, that.mSnippet) - && mScore == that.mScore - && Objects.equals(mExtraInfos, that.mExtraInfos); + return false; } @Override public int hashCode() { - return Objects.hash(mTitle, mSnippet, mScore, mExtraInfos); + return 0; } /** @@ -248,63 +199,43 @@ public final class SearchResult implements Parcelable { */ @SystemApi public static final class Builder { - private String mTitle; - private String mSnippet; - private float mScore; - private Bundle mExtraInfos; - /** - * - * @param title the title to the search result. + * @param title the title to the search result. * @param extraInfos the extra infos associated with the search result. - * * @hide */ @SystemApi public Builder(@NonNull String title, @NonNull Bundle extraInfos) { - mTitle = title; - mExtraInfos = extraInfos; - - mSnippet = ""; - mScore = 0; } /** Sets the title to the search result. */ @NonNull public Builder setTitle(@NonNull String title) { - this.mTitle = title; return this; } /** Sets the snippet to the search result. */ @NonNull public Builder setSnippet(@NonNull String snippet) { - this.mSnippet = snippet; return this; } /** Sets the ranking score to the search result. */ @NonNull public Builder setScore(float score) { - this.mScore = score; return this; } /** Adds extra information to the search result for rendering in the UI. */ @NonNull public Builder setExtraInfos(@NonNull Bundle extraInfos) { - this.mExtraInfos = extraInfos; return this; } /** Builds a SearchResult based-on the given parameters. */ @NonNull public SearchResult build() { - if (mTitle == null || mExtraInfos == null || mSnippet == null) { - throw new IllegalStateException("Please make sure all required args are assigned."); - } - - return new SearchResult(mTitle, mSnippet, mScore, mExtraInfos); + return new SearchResult(); } } } diff --git a/core/java/android/service/cloudsearch/CloudSearchService.java b/core/java/android/service/cloudsearch/CloudSearchService.java index 5efa1acf8ffa..0ce968939e02 100644 --- a/core/java/android/service/cloudsearch/CloudSearchService.java +++ b/core/java/android/service/cloudsearch/CloudSearchService.java @@ -15,25 +15,14 @@ */ package android.service.cloudsearch; -import static com.android.internal.util.function.pooled.PooledLambda.obtainMessage; - import android.annotation.CallSuper; import android.annotation.NonNull; import android.annotation.SystemApi; import android.app.Service; -import android.app.cloudsearch.ICloudSearchManager; import android.app.cloudsearch.SearchRequest; import android.app.cloudsearch.SearchResponse; -import android.content.Context; import android.content.Intent; -import android.os.Handler; import android.os.IBinder; -import android.os.Looper; -import android.os.RemoteException; -import android.os.ServiceManager; -import android.service.cloudsearch.ICloudSearchService.Stub; -import android.util.Log; -import android.util.Slog; /** * A service for returning search results from cloud services in response to an on device query. @@ -72,39 +61,18 @@ public abstract class CloudSearchService extends Service { */ public static final String SERVICE_INTERFACE = "android.service.cloudsearch.CloudSearchService"; - private static final boolean DEBUG = false; - private static final String TAG = "CloudSearchService"; - private Handler mHandler; - private ICloudSearchManager mService; - - private final android.service.cloudsearch.ICloudSearchService mInterface = new Stub() { - @Override - public void onSearch(SearchRequest request) { - mHandler.sendMessage( - obtainMessage(CloudSearchService::onSearch, - CloudSearchService.this, request)); - } - }; @CallSuper @Override public void onCreate() { super.onCreate(); - if (DEBUG) { - Log.d(TAG, "onCreate CloudSearchService"); - } - mHandler = new Handler(Looper.getMainLooper(), null, true); - - IBinder b = ServiceManager.getService(Context.CLOUDSEARCH_SERVICE); - mService = android.app.cloudsearch.ICloudSearchManager.Stub.asInterface(b); } /** * onSearch receives the input request, retrievals the search provider's own * corpus and returns the search response through returnResults below. * - *@param request the search request passed from the client. - * + * @param request the search request passed from the client. */ public abstract void onSearch(@NonNull SearchRequest request); @@ -112,30 +80,16 @@ public abstract class CloudSearchService extends Service { * returnResults returnes the response and its associated requestId, where * requestIs is generated by request through getRequestId(). * - *@param requestId the request ID got from request.getRequestId(). - *@param response the search response returned from the search provider. - * + * @param requestId the request ID got from request.getRequestId(). + * @param response the search response returned from the search provider. */ public final void returnResults(@NonNull String requestId, - @NonNull SearchResponse response) { - try { - mService.returnResults(mInterface.asBinder(), requestId, response); - } catch (RemoteException e) { - throw e.rethrowFromSystemServer(); - } + @NonNull SearchResponse response) { } @Override @NonNull public final IBinder onBind(@NonNull Intent intent) { - if (DEBUG) { - Log.d(TAG, "onBind CloudSearchService"); - } - if (SERVICE_INTERFACE.equals(intent.getAction())) { - return mInterface.asBinder(); - } - Slog.w(TAG, "Tried to bind to wrong intent (should be " - + SERVICE_INTERFACE + ": " + intent); return null; } } diff --git a/core/java/android/service/cloudsearch/ICloudSearchService.aidl b/core/java/android/service/cloudsearch/ICloudSearchService.aidl deleted file mode 100644 index 104bf99f1537..000000000000 --- a/core/java/android/service/cloudsearch/ICloudSearchService.aidl +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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.service.cloudsearch; - -import android.app.cloudsearch.SearchRequest; - -/** - * Interface from the system to CloudSearch service. - * - * @hide - */ -oneway interface ICloudSearchService { - void onSearch(in SearchRequest request); -} diff --git a/core/java/android/service/dreams/DreamOverlayService.java b/core/java/android/service/dreams/DreamOverlayService.java index 163d6ed4b18b..432444211bce 100644 --- a/core/java/android/service/dreams/DreamOverlayService.java +++ b/core/java/android/service/dreams/DreamOverlayService.java @@ -20,6 +20,7 @@ import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.TestApi; import android.app.Service; +import android.content.ComponentName; import android.content.Intent; import android.os.IBinder; import android.os.RemoteException; @@ -36,6 +37,7 @@ public abstract class DreamOverlayService extends Service { private static final String TAG = "DreamOverlayService"; private static final boolean DEBUG = false; private boolean mShowComplications; + private ComponentName mDreamComponent; private IDreamOverlay mDreamOverlay = new IDreamOverlay.Stub() { @Override @@ -56,6 +58,8 @@ public abstract class DreamOverlayService extends Service { public final IBinder onBind(@NonNull Intent intent) { mShowComplications = intent.getBooleanExtra(DreamService.EXTRA_SHOW_COMPLICATIONS, DreamService.DEFAULT_SHOW_COMPLICATIONS); + mDreamComponent = intent.getParcelableExtra(DreamService.EXTRA_DREAM_COMPONENT, + ComponentName.class); return mDreamOverlay.asBinder(); } @@ -84,4 +88,12 @@ public abstract class DreamOverlayService extends Service { public final boolean shouldShowComplications() { return mShowComplications; } + + /** + * Returns the active dream component. + * @hide + */ + public final ComponentName getDreamComponent() { + return mDreamComponent; + } } diff --git a/core/java/android/service/dreams/DreamService.java b/core/java/android/service/dreams/DreamService.java index 75155383855b..d066ee773006 100644 --- a/core/java/android/service/dreams/DreamService.java +++ b/core/java/android/service/dreams/DreamService.java @@ -218,6 +218,12 @@ public class DreamService extends Service implements Window.Callback { "android.service.dreams.SHOW_COMPLICATIONS"; /** + * Extra containing the component name for the active dream. + * @hide + */ + public static final String EXTRA_DREAM_COMPONENT = "android.service.dreams.DREAM_COMPONENT"; + + /** * The default value for whether to show complications on the overlay. * @hide */ @@ -271,6 +277,7 @@ public class DreamService extends Service implements Window.Callback { overlayIntent.setComponent(overlayService); overlayIntent.putExtra(EXTRA_SHOW_COMPLICATIONS, fetchShouldShowComplications(context, serviceInfo)); + overlayIntent.putExtra(EXTRA_DREAM_COMPONENT, dreamService); context.bindService(overlayIntent, this, Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE); diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index b0d465769deb..a78af04995d3 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -8207,7 +8207,14 @@ public class View implements Drawable.Callback, KeyEvent.Callback, // We have not been laid out yet, hence cannot evaluate // whether this view is visible to the user, we will do // the evaluation once layout is complete. - if (!isLaidOut()) { + // Sometimes, views are already laid out, but it's still + // not visible to the user, we also do the evaluation once + // the view is visible. ex: There is a fade-in animation + // for the activity, the view will be laid out when the + // animation beginning. On the time, the view is not visible + // to the user. And then as the animation progresses, the view + // becomes visible to the user. + if (!isLaidOut() || !isVisibleToUser()) { mPrivateFlags3 |= PFLAG3_NOTIFY_AUTOFILL_ENTER_ON_LAYOUT; } else if (isVisibleToUser()) { if (isFocused()) { diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index a78d10aaf1ad..e4caa385bc9b 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -284,7 +284,7 @@ public final class ViewRootImpl implements ViewParent, * @hide */ public static final boolean LOCAL_LAYOUT = - SystemProperties.getBoolean("persist.debug.local_layout", true); + SystemProperties.getBoolean("persist.debug.local_layout", false); /** * Set this system property to true to force the view hierarchy to render |
