Merge changes from topic "SuggestedResultAttribute"
* changes:
[OneSearch] Add direct_match to SearchAttributes.
[OneSearch] Deprecate CorrectedDeviceSearchResultContainer with SearchAttributes.
diff --git a/quickstep/protos_overrides/launcher_atom_extension.proto b/quickstep/protos_overrides/launcher_atom_extension.proto
index d2dc0cb..ff050ea 100644
--- a/quickstep/protos_overrides/launcher_atom_extension.proto
+++ b/quickstep/protos_overrides/launcher_atom_extension.proto
@@ -23,20 +23,24 @@
// Message name should match with launcher_atom_extension.proto message at
// the AOSP level.
message ExtendedContainers {
+ reserved 2; // Deleted fields
oneof Container{
DeviceSearchResultContainer device_search_result_container = 1;
- CorrectedDeviceSearchResultContainer corrected_device_search_result_container = 2;
}
}
// Represents on-device search result container.
message DeviceSearchResultContainer{
optional int32 query_length = 1;
-}
+ optional SearchAttributes search_attributes = 2;
-// Represents on-device search result container with results from spell-corrected query.
-message CorrectedDeviceSearchResultContainer{
- optional int32 query_length = 1;
-}
+ message SearchAttributes{
+ // True if results are based on spell corrected query
+ optional bool corrected_query = 1;
+
+ // True if the item's title/content is a direct match to the search query, false otherwise.
+ optional bool direct_match = 2;
+ }
+}
diff --git a/quickstep/src/com/android/launcher3/model/AppEventProducer.java b/quickstep/src/com/android/launcher3/model/AppEventProducer.java
index 7c29c5b..d4bbfa2 100644
--- a/quickstep/src/com/android/launcher3/model/AppEventProducer.java
+++ b/quickstep/src/com/android/launcher3/model/AppEventProducer.java
@@ -23,6 +23,7 @@
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_HOTSEAT_PREDICTION;
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_PREDICTION;
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_WIDGETS_PREDICTION;
+import static com.android.launcher3.logger.LauncherAtomExtensions.ExtendedContainers.ContainerCase.DEVICE_SEARCH_RESULT_CONTAINER;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_APP_LAUNCH_TAP;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_FOLDER_CONVERTED_TO_ICON;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_HOTSEAT_PREDICTION_PINNED;
@@ -293,10 +294,9 @@
case SEARCH_RESULT_CONTAINER:
return "search-results";
case EXTENDED_CONTAINERS: {
- switch(ci.getExtendedContainers().getContainerCase()) {
- case DEVICE_SEARCH_RESULT_CONTAINER:
- case CORRECTED_DEVICE_SEARCH_RESULT_CONTAINER:
- return "search-results";
+ if (ci.getExtendedContainers().getContainerCase()
+ == DEVICE_SEARCH_RESULT_CONTAINER) {
+ return "search-results";
}
}
default: // fall out
diff --git a/quickstep/src/com/android/quickstep/logging/StatsLogCompatManager.java b/quickstep/src/com/android/quickstep/logging/StatsLogCompatManager.java
index 676161e..ad52a66 100644
--- a/quickstep/src/com/android/quickstep/logging/StatsLogCompatManager.java
+++ b/quickstep/src/com/android/quickstep/logging/StatsLogCompatManager.java
@@ -48,6 +48,7 @@
import com.android.launcher3.logger.LauncherAtom.FromState;
import com.android.launcher3.logger.LauncherAtom.ToState;
import com.android.launcher3.logger.LauncherAtomExtensions.DeviceSearchResultContainer;
+import com.android.launcher3.logger.LauncherAtomExtensions.DeviceSearchResultContainer.SearchAttributes;
import com.android.launcher3.logger.LauncherAtomExtensions.ExtendedContainers;
import com.android.launcher3.logging.InstanceId;
import com.android.launcher3.logging.StatsLogManager;
@@ -89,6 +90,12 @@
private static final int EXTENDED_CONTAINERS_HIERARCHY_OFFSET = 300;
private static final int ATTRIBUTE_MULTIPLIER = 100;
+ /**
+ * Flags for converting SearchAttribute to integer value.
+ */
+ private static final int SEARCH_ATTRIBUTES_CORRECTED_QUERY = 1;
+ private static final int SEARCH_ATTRIBUTES_DIRECT_MATCH = 1 << 1;
+
public static final CopyOnWriteArrayList<StatsLogConsumer> LOGS_CONSUMER =
new CopyOnWriteArrayList<>();
@@ -405,7 +412,10 @@
atomInfo.getFolderIcon().getToLabelState().getNumber() /* toState */,
atomInfo.getFolderIcon().getLabelInfo() /* edittext */,
getCardinality(atomInfo) /* cardinality */,
- getFeatures(atomInfo) /* features */);
+ getFeatures(atomInfo) /* features */
+ // TODO(b/217753033) : Add SearchAttributes field after necessary approval
+ // getSearchAttributes(atomInfo) /* searchAttributes */
+ );
}
}
@@ -561,6 +571,25 @@
return 0;
}
+ private static int getSearchAttributes(LauncherAtom.ItemInfo info) {
+ if (info.getContainerInfo().getExtendedContainers().getDeviceSearchResultContainer()
+ .hasSearchAttributes()) {
+ return searchAttributesToInt(info.getContainerInfo().getExtendedContainers()
+ .getDeviceSearchResultContainer().getSearchAttributes());
+ }
+ return 0;
+ }
+
+ private static int searchAttributesToInt(SearchAttributes searchAttributes) {
+ int response = 0;
+ if (searchAttributes.getCorrectedQuery()) {
+ response = response | SEARCH_ATTRIBUTES_CORRECTED_QUERY;
+ }
+ if (searchAttributes.getDirectMatch()) {
+ response = response | SEARCH_ATTRIBUTES_DIRECT_MATCH;
+ }
+ return response;
+ }
/**
* Interface to get stats log while it is dispatched to the system