Merge "Log search result click and its rank."
This commit is contained in:
committed by
Android (Google) Code Review
commit
5985ff098d
@@ -18,6 +18,7 @@ package com.android.settings.core.instrumentation;
|
||||
|
||||
import android.content.Context;
|
||||
import android.metrics.LogMaker;
|
||||
import android.util.Pair;
|
||||
|
||||
import com.android.internal.logging.MetricsLogger;
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
@@ -59,8 +60,19 @@ public class EventLogWriter implements LogWriter {
|
||||
MetricsLogger.action(context, category, Boolean.toString(value));
|
||||
}
|
||||
|
||||
public void action(Context context, int category, String pkg) {
|
||||
MetricsLogger.action(context, category, pkg);
|
||||
public void action(Context context, int category, String pkg,
|
||||
Pair<Integer, Object>... taggedData) {
|
||||
if (taggedData == null || taggedData.length == 0) {
|
||||
MetricsLogger.action(context, category, pkg);
|
||||
} else {
|
||||
final LogMaker logMaker = new LogMaker(category)
|
||||
.setType(MetricsProto.MetricsEvent.TYPE_ACTION)
|
||||
.setPackageName(pkg);
|
||||
for (Pair<Integer, Object> pair : taggedData) {
|
||||
logMaker.addTaggedData(pair.first, pair.second);
|
||||
}
|
||||
MetricsLogger.action(logMaker);
|
||||
}
|
||||
}
|
||||
|
||||
public void count(Context context, String name, int value) {
|
||||
|
@@ -16,6 +16,7 @@
|
||||
package com.android.settings.core.instrumentation;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Pair;
|
||||
|
||||
/**
|
||||
* Generic log writer interface.
|
||||
@@ -55,7 +56,7 @@ public interface LogWriter {
|
||||
/**
|
||||
* Logs an user action.
|
||||
*/
|
||||
void action(Context context, int category, String pkg);
|
||||
void action(Context context, int category, String pkg, Pair<Integer, Object>... taggedData);
|
||||
|
||||
/**
|
||||
* Logs a count.
|
||||
|
@@ -16,6 +16,7 @@
|
||||
package com.android.settings.core.instrumentation;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Pair;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
|
||||
@@ -74,9 +75,10 @@ public class MetricsFeatureProvider {
|
||||
}
|
||||
}
|
||||
|
||||
public void action(Context context, int category, String pkg) {
|
||||
public void action(Context context, int category, String pkg,
|
||||
Pair<Integer, Object>... taggedData) {
|
||||
for (LogWriter writer : mLoggerWriters) {
|
||||
writer.action(context, category, pkg);
|
||||
writer.action(context, category, pkg, taggedData);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -18,6 +18,7 @@ package com.android.settings.core.instrumentation;
|
||||
|
||||
import android.content.Context;
|
||||
import android.metrics.LogMaker;
|
||||
import android.util.Pair;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.internal.logging.MetricsLogger;
|
||||
@@ -55,7 +56,8 @@ public class SettingSuggestionsLogWriter implements LogWriter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void action(Context context, int category, String pkg) {
|
||||
public void action(Context context, int category, String pkg,
|
||||
Pair<Integer, Object>... taggedData) {
|
||||
if (mEventStore == null) {
|
||||
mEventStore = new EventStore(context);
|
||||
}
|
||||
|
@@ -28,7 +28,9 @@ import android.os.UserManager;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.applications.ManageApplications;
|
||||
import com.android.settings.applications.PackageManagerWrapper;
|
||||
import com.android.settings.dashboard.SiteMapManager;
|
||||
@@ -87,7 +89,9 @@ public class InstalledAppResultLoader extends AsyncLoader<List<? extends SearchR
|
||||
}
|
||||
final Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
|
||||
.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
|
||||
.setData(Uri.fromParts("package", info.packageName, null));
|
||||
.setData(Uri.fromParts("package", info.packageName, null))
|
||||
.putExtra(SettingsActivity.EXTRA_SOURCE_METRICS_CATEGORY,
|
||||
MetricsProto.MetricsEvent.DASHBOARD_SEARCH_RESULTS);
|
||||
|
||||
final AppSearchResult.Builder builder = new AppSearchResult.Builder();
|
||||
builder.setAppInfo(info)
|
||||
|
@@ -15,28 +15,49 @@
|
||||
*/
|
||||
package com.android.settings.search2;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Intent;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Pair;
|
||||
import android.view.View;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.core.instrumentation.MetricsFeatureProvider;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
|
||||
/**
|
||||
* ViewHolder for intent based search results.
|
||||
* The DatabaseResultLoader is the primary use case for this ViewHolder.
|
||||
*/
|
||||
public class IntentSearchViewHolder extends SearchViewHolder {
|
||||
|
||||
private final MetricsFeatureProvider mMetricsFeatureProvider;
|
||||
|
||||
public IntentSearchViewHolder(View view) {
|
||||
super(view);
|
||||
mMetricsFeatureProvider = FeatureFactory.getFactory(view.getContext())
|
||||
.getMetricsFeatureProvider();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBind(final SearchFragment fragment, final SearchResult result) {
|
||||
super.onBind(fragment, result);
|
||||
|
||||
itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
fragment.onSearchResultClicked();
|
||||
fragment.startActivity(((IntentPayload) result.payload).intent);
|
||||
itemView.setOnClickListener(v -> {
|
||||
fragment.onSearchResultClicked();
|
||||
final Intent intent = ((IntentPayload) result.payload).intent;
|
||||
final ComponentName cn = intent.getComponent();
|
||||
final Pair<Integer, Object> rank = Pair.create(
|
||||
MetricsEvent.FIELD_SETTINGS_SERACH_RESULT_RANK, getAdapterPosition());
|
||||
String resultName = intent.getStringExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT);
|
||||
if (TextUtils.isEmpty(resultName) && cn != null) {
|
||||
resultName = cn.flattenToString();
|
||||
}
|
||||
mMetricsFeatureProvider.action(v.getContext(),
|
||||
MetricsEvent.ACTION_CLICK_SETTINGS_SEARCH_RESULT,
|
||||
resultName, rank);
|
||||
fragment.startActivity(intent);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user