Move searchuilib from `frameworks/libs` to `vendor/unbundled_google/libaries`
Bug: 271175753
Flag: No flag
Test: Compiled with soong and studiow
Change-Id: I3ec980241946aa725429ebc737df7597e3078b8b
diff --git a/searchuilib/.gitignore b/searchuilib/.gitignore
deleted file mode 100644
index 6213826..0000000
--- a/searchuilib/.gitignore
+++ /dev/null
@@ -1,13 +0,0 @@
-*.iml
-.project
-.classpath
-.project.properties
-gen/
-bin/
-.idea/
-.gradle/
-local.properties
-gradle/
-build/
-gradlew*
-.DS_Store
diff --git a/searchuilib/Android.bp b/searchuilib/Android.bp
deleted file mode 100644
index f7b0b83..0000000
--- a/searchuilib/Android.bp
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright (C) 2020 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 {
- default_applicable_licenses: ["Android-Apache-2.0"],
-}
-
-android_library {
- name: "search_ui",
-
- sdk_version: "system_current",
-
- static_libs: [
- "androidx.annotation_annotation",
- ],
- srcs: [
- "src/**/*.java",
- ],
-}
diff --git a/searchuilib/AndroidManifest.xml b/searchuilib/AndroidManifest.xml
deleted file mode 100644
index 6c6c5f6..0000000
--- a/searchuilib/AndroidManifest.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2020 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.
--->
-
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.android.app.search">
-</manifest>
diff --git a/searchuilib/build.gradle b/searchuilib/build.gradle
deleted file mode 100644
index 02a63c2..0000000
--- a/searchuilib/build.gradle
+++ /dev/null
@@ -1,26 +0,0 @@
-plugins {
- id 'com.android.library'
-}
-
-android {
- namespace = "com.android.app.search"
-
- sourceSets {
- main {
- java.srcDirs = ['src']
- manifest.srcFile 'AndroidManifest.xml'
- }
- }
-
- tasks.withType(JavaCompile) {
- options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
- }
-
- lint {
- abortOnError false
- }
-}
-
-dependencies {
- implementation "androidx.core:core:+"
-}
diff --git a/searchuilib/src/com/android/app/search/LayoutType.java b/searchuilib/src/com/android/app/search/LayoutType.java
deleted file mode 100644
index f7d2aa0..0000000
--- a/searchuilib/src/com/android/app/search/LayoutType.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Copyright (C) 2020 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 com.android.app.search;
-
-/**
- * Constants to be used with {@link SearchTarget}.
- */
-public class LayoutType {
-
- // ------
- // | icon |
- // ------
- // text
- public static final String ICON_SINGLE_VERTICAL_TEXT = "icon";
-
- // Below three layouts (to be deprecated) and two layouts render
- // {@link SearchTarget}s in following layout.
- // ------ ------ ------
- // | | title |(opt)| |(opt)|
- // | icon | subtitle (optional) | icon| | icon|
- // ------ ------ ------
- @Deprecated
- public static final String ICON_SINGLE_HORIZONTAL_TEXT = "icon_text_row";
- @Deprecated
- public static final String ICON_DOUBLE_HORIZONTAL_TEXT = "icon_texts_row";
- @Deprecated
- public static final String ICON_DOUBLE_HORIZONTAL_TEXT_BUTTON = "icon_texts_button";
-
- // will replace ICON_DOUBLE_* ICON_SINGLE_* layouts
- public static final String ICON_HORIZONTAL_TEXT = "icon_row";
- public static final String HORIZONTAL_MEDIUM_TEXT = "icon_row_medium";
- public static final String EXTRA_TALL_ICON_ROW = "extra_tall_icon_row";
- public static final String SMALL_ICON_HORIZONTAL_TEXT = "short_icon_row";
- public static final String SMALL_ICON_HORIZONTAL_TEXT_THUMBNAIL = "short_icon_row_thumbnail";
-
- // This layout contains a series of icon results (currently up to 4 per row).
- // The container does not support stretching for its children, and can only contain
- // {@link #ICON_SINGLE_VERTICAL_TEXT} layout types.
- public static final String ICON_CONTAINER = "icon_container";
-
- // This layout contains a series of thumbnails (currently up to 3 per row).
- // The container supports stretching for its children, and can only contain {@link #THUMBNAIL}
- // layout types.
- public static final String THUMBNAIL_CONTAINER = "thumbnail_container";
-
- // This layout creates a container for people grouping
- // Only available above version code 2
- public static final String BIG_ICON_MEDIUM_HEIGHT_ROW = "big_icon_medium_row";
-
- // This layout creates square thumbnail image (currently 3 column)
- public static final String THUMBNAIL = "thumbnail";
-
- // This layout contains an icon and slice
- public static final String ICON_SLICE = "slice";
-
- // Widget bitmap preview
- public static final String WIDGET_PREVIEW = "widget_preview";
-
- // Live widget search result
- public static final String WIDGET_LIVE = "widget_live";
-
- // Layout type used to display people tiles using shortcut info
- public static final String PEOPLE_TILE = "people_tile";
-
- // Deprecated
- // text based header to group various layouts in low confidence section of the results.
- public static final String TEXT_HEADER = "header";
-
- // horizontal bar to be inserted between fallback search results and low confidence section
- public static final String EMPTY_DIVIDER = "empty_divider";
-
- // layout representing quick calculations
- public static final String CALCULATOR = "calculator";
-
- // From version code 4, if TEXT_HEADER_ROW is used, no need to insert this on-device
- // section header.
- public static final String SECTION_HEADER = "section_header";
-
- // layout for a tall card with header and image, and no icon.
- public static final String TALL_CARD_WITH_IMAGE_NO_ICON = "tall_card_with_image_no_icon";
-
- // Layout for a text header
- // Available for SearchUiManager proxy service to use above version code 3
- public static final String TEXT_HEADER_ROW = "text_header_row";
-
- // Layout for a quick settings tile
- public static final String QS_TILE = "qs_tile";
-
- // Layout for a quick settings tile container
- public static final String QS_TILE_CONTAINER = "qs_tile_container";
-
- // Placeholder for web suggest.
- public static final String PLACEHOLDER = "placeholder";
-
- // Placeholder for rich answer cards.
- // Only available on or above version code 3.
- public static final String RICHANSWER_PLACEHOLDER = "richanswer_placeholder";
-
- // Play placeholder
- public static final String PLAY_PLACEHOLDER = "play_placeholder";
-
- // Only available on or above version code 8 (UP1A)
- // This layout is for educard.
- public static final String EDUCARD = "educard";
-}
diff --git a/searchuilib/src/com/android/app/search/QueryExtras.java b/searchuilib/src/com/android/app/search/QueryExtras.java
deleted file mode 100644
index fcb2592..0000000
--- a/searchuilib/src/com/android/app/search/QueryExtras.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2023 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 com.android.app.search;
-
-import android.app.search.Query;
-
-/**
- * Utility class used to define implicit contract between aiai and launcher regarding
- * what constant string key should be used to pass sub session information inside
- * the {@link Query} object.
- *
- * This decorated query object is passed to aiai using two method calls:
- * <ul>
- * <ol>android.app.search.SearchSession.query()</ol>
- * <ol>android.app.search.SearchSession.notifyEvent()</ol>
- * </ul>
- */
-public class QueryExtras {
-
- // Can be either 1 (ALLAPPS), 2 (QSB), or 3 (OVERVIEW)
- public static final String EXTRAS_KEY_ENTRY = "entry";
-
- // This value overrides the timeout that is defined inside {@link SearchContext#getTimeout}
- public static final String EXTRAS_KEY_TIMEOUT_OVERRIDE = "timeout";
-
- // Used to know which target is deleted.
- public static final String EXTRAS_BUNDLE_DELETED_TARGET_ID = "deleted_target_id";
-
- // Contains "educard dismissed" which is used to know if educard is dismissed.
- public static final String EXTRAS_BUNDLE_EDUCARD_DISMISSED = "educard_dismissed";
-}
diff --git a/searchuilib/src/com/android/app/search/ResultType.java b/searchuilib/src/com/android/app/search/ResultType.java
deleted file mode 100644
index a00c2a6..0000000
--- a/searchuilib/src/com/android/app/search/ResultType.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (C) 2020 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 com.android.app.search;
-
-/**
- * Constants to be used with {@link android.app.search.SearchContext} and
- * {@link android.app.search.SearchTarget}.
- *
- * Note, a result type could be a of two types.
- * For example, unpublished settings result type could be in slices:
- * <code> resultType = SETTING | SLICE </code>
- */
-public class ResultType {
-
- // published corpus by 3rd party app, supported by SystemService
- public static final int APPLICATION = 1 << 0;
- public static final int SHORTCUT = 1 << 1;
- public static final int SLICE = 1 << 6;
- public static final int WIDGETS = 1 << 7;
-
- // Not extracted from any of the SystemService
- public static final int PEOPLE = 1 << 2;
- public static final int ACTION = 1 << 3;
- public static final int SETTING = 1 << 4;
- public static final int IMAGE = 1 << 5;
- public static final int PLAY = 1 << 8;
- public static final int SUGGEST = 1 << 9;
- public static final int ASSISTANT = 1 << 10;
- public static final int CHROMETAB = 1 << 11;
- public static final int SESSION_INFO = 1 << 12;
- public static final int TIPS = 1 << 13;
- public static final int PEOPLE_TILE = 1 << 14;
- public static final int LEGACY_SHORTCUT = 1 << 15;
- public static final int MEMORY = 1 << 16;
- public static final int WEB_SUGGEST = 1 << 17;
- public static final int NO_FULFILLMENT = 1 << 18;
- public static final int EDUCARD = 1 << 19;
- public static final int SYSTEM_POINTER = 1 << 20;
- public static final int VIDEO = 1 << 21;
- public static final int LOCATION = 1 << 22;
-
- public static final int PUBLIC_DATA_TYPE = APPLICATION | SETTING | PLAY | WEB_SUGGEST;
- public static final int PRIMITIVE_TYPE = APPLICATION | SLICE | SHORTCUT | WIDGETS | ACTION |
- LEGACY_SHORTCUT;
- public static final int CORPUS_TYPE =
- PEOPLE | SETTING | IMAGE | PLAY | SUGGEST | ASSISTANT | CHROMETAB | TIPS
- | PEOPLE_TILE | MEMORY | WEB_SUGGEST | VIDEO | LOCATION;
- public static final int RANK_TYPE = SYSTEM_POINTER;
- public static final int UI_TYPE = EDUCARD | NO_FULFILLMENT;
-
- public static boolean isSlice(int resultType) {
- return (resultType & SLICE) != 0;
- }
-
- public static boolean isSystemPointer(int resultType) {
- return (resultType & SYSTEM_POINTER) != 0;
- }
-
- /**
- * Returns result type integer where only {@code #CORPUS_TYPE} bit will turned on.
- */
- public static int getCorpusType(int resultType) {
- return (resultType & CORPUS_TYPE);
- }
-
- /**
- * Returns result type integer where only {@code #PRIMITIVE_TYPE} bit will be turned on.
- */
- public static int getPrimitiveType(int resultType) {
- return (resultType & PRIMITIVE_TYPE);
- }
-
- /**
- * Returns whether the given result type is privacy safe or not.
- */
- public static boolean isPrivacySafe(int resultType) {
- return (resultType & PUBLIC_DATA_TYPE) != 0;
- }
-}
diff --git a/searchuilib/src/com/android/app/search/SearchActionExtras.java b/searchuilib/src/com/android/app/search/SearchActionExtras.java
deleted file mode 100644
index 2f33d5d..0000000
--- a/searchuilib/src/com/android/app/search/SearchActionExtras.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2023 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 com.android.app.search;
-
-import android.app.search.SearchAction;
-
-/**
- * Helper class that defines key string value for {@link SearchAction#getExtras()}
- */
-public class SearchActionExtras {
- public static final String BUNDLE_EXTRA_HIDE_SUBTITLE = "hide_subtitle";
- public static final String BUNDLE_EXTRA_HIDE_ICON = "hide_icon";
- public static final String BUNDLE_EXTRA_ALLOW_PINNING = "allow_pinning";
- public static final String BUNDLE_EXTRA_BADGE_WITH_PACKAGE = "badge_with_package";
- public static final String BUNDLE_EXTRA_PRIMARY_ICON_FROM_TITLE = "primary_icon_from_title";
- public static final String BUNDLE_EXTRA_IS_SEARCH_IN_APP = "is_search_in_app";
- public static final String BUNDLE_EXTRA_BADGE_WITH_COMPONENT_NAME = "badge_with_component_name";
- public static final String BUNDLE_EXTRA_ICON_CACHE_KEY = "icon_cache_key";
- public static final String BUNDLE_EXTRA_ICON_TOKEN_INTEGER = "icon_integer";
- public static final String BUNDLE_EXTRA_SHOULD_START = "should_start";
- public static final String BUNDLE_EXTRA_SHOULD_START_FOR_RESULT = "should_start_for_result";
- public static final String BUNDLE_EXTRA_SUGGESTION_ACTION_TEXT = "suggestion_action_text";
- public static final String BUNDLE_EXTRA_SUGGESTION_ACTION_RPC = "suggestion_action_rpc";
- public static final String BUNDLE_EXTRA_SKIP_LOGGING_IN_TARGET_HANDLER =
- "skip_logging_in_target_handler";
-}
diff --git a/searchuilib/src/com/android/app/search/SearchTargetConverter.java b/searchuilib/src/com/android/app/search/SearchTargetConverter.java
deleted file mode 100644
index 2080966..0000000
--- a/searchuilib/src/com/android/app/search/SearchTargetConverter.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (C) 2023 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 com.android.app.search;
-
-import static com.android.app.search.LayoutType.SMALL_ICON_HORIZONTAL_TEXT;
-import static com.android.app.search.SearchActionExtras.BUNDLE_EXTRA_HIDE_ICON;
-import static com.android.app.search.SearchActionExtras.BUNDLE_EXTRA_HIDE_SUBTITLE;
-import static com.android.app.search.SearchTargetExtras.BUNDLE_EXTRA_CLASS;
-import static com.android.app.search.SearchTargetExtras.BUNDLE_EXTRA_SUBTITLE_OVERRIDE;
-import static com.android.app.search.SearchTargetExtras.BUNDLE_EXTRA_SUPPORT_QUERY_BUILDER;
-import static com.android.app.search.SearchTargetExtras.EXTRAS_RECENT_BLOCK_TARGET;
-
-import android.app.search.SearchAction;
-import android.app.search.SearchTarget;
-import android.content.pm.ShortcutInfo;
-import android.os.Bundle;
-
-public class SearchTargetConverter {
- /**
- * Generate a searchTarget that uses {@link LayoutType#SMALL_ICON_HORIZONTAL_TEXT} from a
- * searchTarget where original layout type may not have been SMALL_ICON_HORIZONTAL_TEXT. Only
- * possible if the given SearchTarget contains a searchAction or shortcutInfo, otherwise the
- * original searchTarget will be returned.
- */
- public static SearchTarget convertLayoutTypeToSmallIconHorizontalText(
- SearchTarget searchTarget) {
- SearchAction searchTargetAction = searchTarget.getSearchAction();
- ShortcutInfo shortcutInfo = searchTarget.getShortcutInfo();
- int resultType = searchTarget.getResultType();
- String subtitle = "";
-
- Bundle searchTargetBundle = searchTarget.getExtras();
- searchTargetBundle.putString(BUNDLE_EXTRA_CLASS,
- searchTargetBundle.getString(BUNDLE_EXTRA_CLASS));
- searchTargetBundle.putBoolean(BUNDLE_EXTRA_SUPPORT_QUERY_BUILDER, true);
- searchTargetBundle.putBoolean(BUNDLE_EXTRA_HIDE_SUBTITLE, false);
- searchTargetBundle.putString(BUNDLE_EXTRA_SUBTITLE_OVERRIDE, subtitle);
- searchTargetBundle.putBoolean(BUNDLE_EXTRA_HIDE_ICON, false);
- searchTargetBundle.putBoolean(EXTRAS_RECENT_BLOCK_TARGET, true);
-
- SearchTarget.Builder builder = new SearchTarget.Builder(resultType,
- SMALL_ICON_HORIZONTAL_TEXT, searchTarget.getId())
- .setPackageName(searchTarget.getPackageName())
- .setExtras(searchTargetBundle)
- .setUserHandle(searchTarget.getUserHandle());
- if (searchTargetAction != null) {
- builder.setSearchAction(searchTargetAction);
- } else if (shortcutInfo != null) {
- builder.setShortcutInfo(shortcutInfo);
- } else {
- return searchTarget;
- }
- return builder.build();
- }
-}
diff --git a/searchuilib/src/com/android/app/search/SearchTargetEventHelper.java b/searchuilib/src/com/android/app/search/SearchTargetEventHelper.java
deleted file mode 100644
index 389a216..0000000
--- a/searchuilib/src/com/android/app/search/SearchTargetEventHelper.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Copyright (C) 2023 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 com.android.app.search;
-
-import static com.android.app.search.SearchTargetExtras.isRichAnswer;
-
-import android.app.search.SearchTarget;
-import android.content.ComponentName;
-import android.os.Process;
-import android.os.UserHandle;
-
-import androidx.annotation.Nullable;
-
-/**
- * Helper class that defines helper methods for {@link android.app.search.SearchTargetEvent} to
- * define the contract between Launcher and AiAi for notifyEvent.
- */
-
-public class SearchTargetEventHelper {
-
- public static final String PKG_NAME_AGSA = "com.google.android.googlequicksearchbox";
-
- /**
- * Generate web target id similar to AiAi targetId for logging search button tap and Launcher
- * sends raw query to AGA.
- * AiAi target id is of format "resultType:userId:packageName:extraInfo"
- *
- * @return string webTargetId
- * Example webTargetId for
- * web suggestion - WEB_SUGGEST:0:com.google.android.googlequicksearchbox:SUGGESTION
- */
- public static String generateWebTargetIdForRawQuery() {
- // For raw query, there is no search target, so we pass null.
- return generateWebTargetIdForLogging(null);
- }
-
- /**
- * Generate web target id similar to AiAi targetId for logging both 0-state and n-state.
- * AiAi target id is of format "resultType:userId:packageName:extraInfo"
- *
- * @return string webTargetId
- * Example webTargetId for
- * web suggestion - WEB_SUGGEST:0:com.google.android.googlequicksearchbox:SUGGESTION
- * rich answer - WEB_SUGGEST:0:com.google.android.googlequicksearchbox:RICH_ANSWER
- */
- public static String generateWebTargetIdForLogging(@Nullable SearchTarget webTarget) {
- StringBuilder webTargetId = new StringBuilder(
- "WEB_SUGGEST" + ":" + Process.myUserHandle().getIdentifier() + ":");
- if (webTarget == null) {
- webTargetId.append(PKG_NAME_AGSA + ":SUGGESTION");
- return webTargetId.toString();
- }
- webTargetId.append(webTarget.getPackageName());
- if (isRichAnswer(webTarget)) {
- webTargetId.append(":RICH_ANSWER");
- } else {
- webTargetId.append(":SUGGESTION");
- }
- return webTargetId.toString();
- }
-
- /**
- * Generate application target id that matches the AiAi targetId for only 0-state.
- * For n-state, AiAi already populates the target id in right format and it's unnecessary for
- * Launcher to generate it itself.
- * AiAi target id is of format "resultType:userHandle.Id:packageName:extraInfo"
- *
- * When the apps from AiAi's AppPredictionService are converted to {@link SearchTarget},
- * we need to construct the targetId using {@link ComponentName} and {@link UserHandle}.
- * Both are required to create a unique id for the SearchTarget.
- *
- * @return string appTargetId
- * Example appTargetId for
- * maps - APPLICATION:0:com.google.android.apps.maps:com.google.android.maps.MapsActivity
- * clock - APPLICATION:0:com.google.android.deskclock:com.android.deskclock.DeskClock
- */
- public static String generateAppTargetId(@Nullable ComponentName appComponentName,
- UserHandle userHandle) {
- StringBuilder appTargetId = new StringBuilder(
- "APPLICATION" + ":" + userHandle.getIdentifier() + ":");
- if (appComponentName == null) return appTargetId.append(" : ").toString();
- return appTargetId + appComponentName.getPackageName() + ":"
- + appComponentName.getClassName();
- }
-
- /**
- * Generate gms play target id similar to AiAi targetId for logging only n-state.
- * AiAi target id is of format "resultType:userId:packageName:extraInfo"
- *
- * @return string playTargetId
- * Example playTargetId for Candy Crush
- * PLAY:0:com.king.candycrushsaga:Gms
- */
- public static String generatePlayTargetIdForLogging(String appPackage) {
- return "PLAY" + ":" + Process.myUserHandle().getIdentifier() + ":" + appPackage + ":Gms";
- }
-
- /**
- * Generate target id similar to AiAi targetId for logging Toast session based on surface
- * visible and invisible.
- * AiAi target id is of format "resultType:userId:packageName:extraInfo"
- *
- * @return string TargetId for Toast session
- * Example of Toast session target Id
- * targetId=SESSION_INFO:0:toast:SURFACE_VISIBLE
- * targetId=SESSION_INFO:0:toast:SURFACE_INVISIBLE
- */
- public static String generateToastSessionTargetIdForLogging(String surfaceVisibility) {
- return "SESSION_INFO:" + Process.myUserHandle().getIdentifier()
- + ":toast:" + surfaceVisibility;
- }
-
- /**
- * Generate target id similar to AiAi targetId for logging Educard when educard is dismissed.
- * AiAi target id is of format "resultType:userId:packageName:extraInfo"
- *
- * @return string TargetId for Educard
- * Example of Educard target Id
- * targetId=EDUCARD:0:toast:EDUCARD
- */
- public static String generateEducardTargetIdForLogging() {
- return "EDUCARD" + ":" + Process.myUserHandle().getIdentifier() + ":toast:EDUCARD";
- }
-}
diff --git a/searchuilib/src/com/android/app/search/SearchTargetExtras.java b/searchuilib/src/com/android/app/search/SearchTargetExtras.java
deleted file mode 100644
index e207d12..0000000
--- a/searchuilib/src/com/android/app/search/SearchTargetExtras.java
+++ /dev/null
@@ -1,272 +0,0 @@
-/*
- * Copyright (C) 2023 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 com.android.app.search;
-
-import static com.android.app.search.LayoutType.TALL_CARD_WITH_IMAGE_NO_ICON;
-
-import android.app.blob.BlobHandle;
-import android.app.search.SearchAction;
-import android.app.search.SearchTarget;
-import android.os.Bundle;
-import android.text.TextUtils;
-
-import androidx.annotation.Nullable;
-
-import java.util.Arrays;
-
-/**
- * Helper class that defines key string value for {@link SearchTarget#getExtras()}
- * and also defines helper methods
- */
-public class SearchTargetExtras {
-
- /** on device data related extras and helper methods */
- // Used to extra component name.
- public static final String BUNDLE_EXTRA_CLASS = "class";
-
- // Used for UI treatment. Labels whether search target should support quick launch.
- public static final String BUNDLE_EXTRA_QUICK_LAUNCH = "quick_launch";
- // Used for UI treatment. Targets grouped with same group id are decorated together.
- public static final String BUNDLE_EXTRA_GROUP_ID = "group_id";
- public static final String BUNDLE_EXTRA_GROUP_DECORATE_TOGETHER = "decorate_together";
- // Used if slice title should be rendered else where outside of slice (e.g., edit text).
- public static final String BUNDLE_EXTRA_SLICE_TITLE = "slice_title";
- // Used if slice view should be rendered using full height mode.
- public static final String BUNDLE_EXTRA_USE_FULL_HEIGHT = "use_full_height";
- public static final String BUNDLE_EXTRA_IS_NON_TAPPABLE = "is_non_tappable";
- public static final String BUNDLE_EXTRA_TITLE_OVERWRITE = "title_overwrite";
- // Used if subtitle view should be overridden to string that is not natively defined by the
- // search target.
- public static final String BUNDLE_EXTRA_SUBTITLE_OVERRIDE = "subtitle_override";
- // Used to override icon with the package name defined in SearchTarget.
- public static final String BUNDLE_EXTRA_ICON_OVERRIDE = "icon_override";
-
- // Used for logging. Returns whether spelling correction was applied.
- public static final String BUNDLE_EXTRA_IS_QUERY_CORRECTED = "is_query_corrected";
- // Used for logging. Returns whether the result matched block title or the inline item.
- public static final String BUNDLE_EXTRA_RESULT_MATCH_USER_TYPED = "result_match_user_typed";
- // Used for logging. Returns the timestamp when system service received the data.
- public static final String BUNDLE_EXTRA_START_TIMESTAMP = "start_timestamp";
- // Indicates the search result app location column.
- public static final String BUNDLE_EXTRA_RESULT_APP_GRIDX = "app_gridx";
-
- // Used for thumbnail loading. Contains handle to retrieve Blobstore asset.
- public static final String BUNDLE_EXTRA_BLOBSTORE_HANDLE = "blobstore_handle_key";
-
- // Used to denote this searchTarget is for recent block in 0-state.
- public static final String EXTRAS_RECENT_BLOCK_TARGET = "recent_block_target";
-
- // Indicates the result source of this SearchTarget.
- public static final String BUNDLE_EXTRA_DATA_DONATED_SOURCE = "data_donated_source";
-
- public enum ResultSource {
- AIAI_SEARCH_ROOT("aiai_search_root"),
- APPSEARCH_APP_PREVIEW("appsearch_app_preview"),
- APPSEARCH_APP_SRP_PREVIEW("appsearch_app_srp_preview");
-
- private final String mDataSource;
-
- ResultSource(String dataSource) {
- mDataSource = dataSource;
- }
-
- public String getDataSource() {
- return mDataSource;
- }
-
- public static ResultSource valueOfResultSource(String source)
- throws IllegalArgumentException {
- ResultSource resultSource = Arrays.stream(ResultSource.values())
- .filter(val -> val.getDataSource().equals(source))
- .findFirst()
- .orElseThrow(() -> new IllegalArgumentException(
- "Unable to resolve source: " + source));
-
- return resultSource;
- }
- }
-
- public static final int GROUPING = 1 << 1;
-
- @Nullable
- public static String getDecoratorId(@Nullable SearchTarget target) {
- return isTargetOrExtrasNull(target) ? null :
- target.getExtras().getString(BUNDLE_EXTRA_GROUP_ID);
- }
-
- public static int getDecoratorType(@Nullable SearchTarget target) {
- int type = 0;
- if (isTargetOrExtrasNull(target)) {
- return type;
- }
- if (!TextUtils.isEmpty(target.getExtras().getString(BUNDLE_EXTRA_GROUP_ID))) {
- type |= GROUPING;
- }
- return type;
- }
-
- /** Whether or not the SearchTarget's Extras contains a blobstore image. */
- public static boolean isSearchTargetBlobstoreAsset(@Nullable SearchTarget target) {
- if (isTargetOrExtrasNull(target)) {
- return false;
- }
- return target.getExtras().getParcelable(
- BUNDLE_EXTRA_BLOBSTORE_HANDLE) instanceof BlobHandle;
- }
-
- /** Check if SearchTarget contains information to tell if this target is from recent block. */
- public static boolean isSearchTargetRecentItem(@Nullable SearchTarget target) {
- if (isTargetOrExtrasNull(target)) {
- return false;
- }
- return target.getExtras().getBoolean(EXTRAS_RECENT_BLOCK_TARGET, false);
- }
-
- private static boolean isTargetOrExtrasNull(@Nullable SearchTarget target) {
- return target == null || target.getExtras() == null;
- }
-
- /** Web data related extras and helper methods */
- public static final String BUNDLE_EXTRA_PROXY_WEB_ITEM = "proxy_web_item";
- public static final String BUNDLE_EXTRA_ENTITY = "is_entity";
- public static final String BUNDLE_EXTRA_ANSWER = "is_answer";
- public static final String BUNDLE_EXTRA_RESPONSE_ID = "response_id";
- public static final String BUNDLE_EXTRA_LEARN_MORE_URL = "learn_more_url";
- public static final String BUNDLE_EXTRA_PERSONAL = "is_personal";
- public static final String BUNDLE_EXTRA_SUGGESTION_TYPE = "suggestion_type";
- public static final String BUNDLE_EXTRA_SUGGEST_RENDER_TEXT = "suggest_render_text";
- public static final String BUNDLE_EXTRA_ZERO_STATE_CACHE = "zero_state_cache";
- public static final String BUNDLE_EXTRA_TALL_CARD_HEADER = "tall_card_header";
- public static final String BUNDLE_EXTRA_TALL_CARD_IMAGE_DESCRIPTION =
- "tall_card_image_description";
- public static final String BUNDLE_EXTRA_BITMAP_URL = "bitmap_url";
-
- // Used for web suggestions count in n-state for both AA+ and QSB entry point.
- // Returns the number of web suggestions to be shown.
- public static final String BUNDLE_EXTRA_NSTATE_WEB_SUG_COUNT = "web_sug_count";
-
- // Used for web suggestions count in 0-state for QSB entry point.
- public static final String BUNDLE_EXTRA_ZERO_STATE_QSB_WEB_SUGGEST_COUNT =
- "zero_state_qsb_web_suggest_count";
- // Used for web suggestions count in 0-state for AA+ entry point.
- public static final String BUNDLE_EXTRA_ZERO_STATE_ALL_APPS_WEB_SUGGEST_COUNT =
- "zero_state_all_apps_web_suggest_count";
-
- /**
- * Replaced with thumbnail crop type
- *
- * Flag to control whether thumbnail(s) should fill the thumbnail container's width or not.
- * When this flag is true, when there are less than the maximum number of thumbnails in the
- * container, the thumbnails will stretch to fill the container's width.
- * When this flag is false, thumbnails will always be cropped to a square ratio even if
- * there aren't enough thumbnails to fill the container.
- *
- * Only relevant in {@link LayoutType#THUMBNAIL_CONTAINER} and {@link LayoutType#THUMBNAIL}.
- */
- @Deprecated
- public static final String BUNDLE_EXTRA_SHOULD_FILL_CONTAINER_WIDTH =
- "should_fill_container_width";
-
- /**
- * Flag to control thumbnail container's crop mode, controlling the layout
- *
- * <ul>
- * <li>SQUARE: Thumbnail(s) will be cropped to a square aspect ratio around the center.</li>
- * <li>FILL_WIDTH: Thumbnail(s) should collectively fill the thumbnail container's width.
- * When there are less than the maximum number of thumbnails in the container, the
- * layouts' width will stretch to fit the container, the images will fill the width
- * and then the top/bottom cropped to fit.</li>
- * <li>FILL_HEIGHT: Thumbnail(s) should fill height and be cropped to fit in the width
- * based on {@link BUNDLE_EXTRA_THUMBNAIL_MAX_COUNT} as the column count. When the image
- * width is larger than the width / column, both sides will be cropped while maintaining
- * the center.
- * When there are less thumbnails than the max count, the layout will be constrained to
- * equally divide the width of the container. If there are more thumbnails than the max
- * count, the excessive thumbnails will be ignored.</li>
- * </ul>
- *
- * Only relevant in {@link LayoutType#THUMBNAIL_CONTAINER} and {@link LayoutType#THUMBNAIL}.
- */
- public static final String BUNDLE_EXTRA_THUMBNAIL_CROP_TYPE = "thumbnail_crop_type";
- public enum ThumbnailCropType {
- DEFAULT(0), // defaults to SQUARE behavior by {@link LayoutType#THUMBNAIL_CONTAINER}.
- SQUARE(1),
- FILL_WIDTH(2),
- FILL_HEIGHT(3);
-
- private final int mTypeId;
-
- ThumbnailCropType(int typeId) {
- mTypeId = typeId;
- }
-
- public int toTypeId() {
- return mTypeId;
- }
- };
-
- /**
- * How many grid spaces for the thumbnail container should be reserved.
- * Only relevant for {@link ThumbnailCropType#FILL_HEIGHT} crop type.
- */
- public static final String BUNDLE_EXTRA_THUMBNAIL_MAX_COUNT = "thumbnail_max_count";
-
- /**
- * Flag to control whether the SearchTarget's label should be hidden.
- * When this flag is true, label will be hidden.
- * When this flag is false (or omitted), {@link SearchAction#mTitle} will be shown.
- */
- public static final String BUNDLE_EXTRA_HIDE_LABEL =
- "hide_label";
- public static final String BUNDLE_EXTRA_SUGGESTION_ACTION_TEXT = "suggestion_action_text";
- public static final String BUNDLE_EXTRA_SUGGESTION_ACTION_RPC = "suggestion_action_rpc";
- public static final String BUNDLE_EXTRA_SUPPORT_QUERY_BUILDER = "support_query_builder";
- public static final String BUNDLE_EXTRA_SUGGEST_RAW_TEXT = "suggest_raw_text";
- public static final String BUNDLE_EXTRA_SUGGEST_TRUNCATE_START = "suggest_truncate_start";
-
- /** Score threshold boosting the target. */
- public static final String BUNDLE_EXTRA_SCORE_THRESHOLD = "score_threshold";
-
- /** Web data related helper methods */
- public static boolean isEntity(@Nullable SearchTarget target) {
- return target != null && target.getExtras() != null
- && target.getExtras().getBoolean(BUNDLE_EXTRA_ENTITY);
- }
-
- public static boolean isAnswer(@Nullable SearchTarget target) {
- return target != null && target.getExtras() != null
- && target.getExtras().getBoolean(BUNDLE_EXTRA_ANSWER);
- }
-
- /** Whether the search target is a rich answer web result. */
- public static boolean isRichAnswer(@Nullable SearchTarget target) {
- return target != null && isAnswer(target)
- && target.getLayoutType().equals(TALL_CARD_WITH_IMAGE_NO_ICON);
- }
-
- /** Get the crop type thumbnails should use. Returns DEFAULT if not specified. */
- public static ThumbnailCropType getThumbnailCropType(@Nullable SearchTarget target)
- throws ArrayIndexOutOfBoundsException {
- Bundle extras = target == null ? Bundle.EMPTY : target.getExtras();
- if (extras.isEmpty()) {
- return ThumbnailCropType.DEFAULT;
- }
- ThumbnailCropType cropType = ThumbnailCropType.values()[extras.getInt(
- BUNDLE_EXTRA_THUMBNAIL_CROP_TYPE)];
- return cropType != null ? cropType : ThumbnailCropType.DEFAULT;
- }
-}
diff --git a/searchuilib/src/com/android/app/search/SearchTargetGenerator.java b/searchuilib/src/com/android/app/search/SearchTargetGenerator.java
deleted file mode 100644
index 22e5a86..0000000
--- a/searchuilib/src/com/android/app/search/SearchTargetGenerator.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2023 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 com.android.app.search;
-
-import static com.android.app.search.LayoutType.EMPTY_DIVIDER;
-import static com.android.app.search.LayoutType.SECTION_HEADER;
-import static com.android.app.search.ResultType.NO_FULFILLMENT;
-
-import android.app.search.SearchTarget;
-import android.os.Bundle;
-import android.os.Process;
-import android.os.UserHandle;
-
-public class SearchTargetGenerator {
- private static final UserHandle USERHANDLE = Process.myUserHandle();
-
- public static SearchTarget EMPTY_DIVIDER_TARGET =
- new SearchTarget.Builder(NO_FULFILLMENT, EMPTY_DIVIDER, "divider")
- .setPackageName("") /* required but not used*/
- .setUserHandle(USERHANDLE) /* required */
- .setExtras(new Bundle())
- .build();
-
- public static SearchTarget SECTION_HEADER_TARGET =
- new SearchTarget.Builder(NO_FULFILLMENT, SECTION_HEADER, "section_header")
- .setPackageName("") /* required but not used*/
- .setUserHandle(USERHANDLE) /* required */
- .setExtras(new Bundle())
- .build();
-}