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

Commit 441461c9 authored by Thiru Ramasamy's avatar Thiru Ramasamy
Browse files

[OneSearch] Deprecate CorrectedDeviceSearchResultContainer with SearchAttributes.

Loggin query_corrected signal as field is more scalable than separate CorrectedDeviceSearchResultContainer for future usecases.

Test: Manual - http://gpaste/6343087535161344
Bug: 199495917
Change-Id: I6b3a410f4d977db2a058f337d1684f78763acbd2
parent 529fa346
Loading
Loading
Loading
Loading
+7 −6
Original line number Diff line number Diff line
@@ -23,20 +23,21 @@ option java_outer_classname = "LauncherAtomExtensions";
// 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;
  }
}
+4 −4
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import static android.app.prediction.AppTargetEvent.ACTION_UNPIN;
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,9 +294,8 @@ public class AppEventProducer implements StatsLogConsumer {
            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:
                if (ci.getExtendedContainers().getContainerCase()
                        == DEVICE_SEARCH_RESULT_CONTAINER) {
                    return "search-results";
                }
            }
+26 −1
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ import com.android.launcher3.logger.LauncherAtom.FolderIcon;
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,11 @@ public class StatsLogCompatManager extends StatsLogManager {
    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;

    public static final CopyOnWriteArrayList<StatsLogConsumer> LOGS_CONSUMER =
            new CopyOnWriteArrayList<>();

@@ -405,7 +411,10 @@ public class StatsLogCompatManager extends StatsLogManager {
                    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 +570,22 @@ public class StatsLogCompatManager extends StatsLogManager {
        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;
        }
        return response;
    }

    /**
     * Interface to get stats log while it is dispatched to the system