Merge "Log cleanup: remove unnecessary logging for suggestions"
This commit is contained in:
committed by
Android (Google) Code Review
commit
aa410eba1d
@@ -31,7 +31,6 @@ import android.support.v7.widget.RecyclerView;
|
||||
import android.text.TextUtils;
|
||||
import android.util.ArrayMap;
|
||||
import android.util.Log;
|
||||
import android.util.Pair;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -47,11 +46,9 @@ import com.android.settings.dashboard.DashboardData.SuggestionConditionHeaderDat
|
||||
import com.android.settings.dashboard.conditional.Condition;
|
||||
import com.android.settings.dashboard.conditional.ConditionAdapter;
|
||||
import com.android.settings.dashboard.suggestions.SuggestionAdapter;
|
||||
import com.android.settings.dashboard.suggestions.SuggestionController;
|
||||
import com.android.settings.dashboard.suggestions.SuggestionControllerMixin;
|
||||
import com.android.settings.dashboard.suggestions.SuggestionDismissController;
|
||||
import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider;
|
||||
import com.android.settings.dashboard.suggestions.SuggestionLogHelper;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settingslib.Utils;
|
||||
import com.android.settingslib.drawer.DashboardCategory;
|
||||
@@ -164,24 +161,6 @@ public class DashboardAdapter extends RecyclerView.Adapter<DashboardAdapter.Dash
|
||||
.setCategory(category)
|
||||
.build();
|
||||
notifyDashboardDataChanged(prevData);
|
||||
List<Tile> shownSuggestions = null;
|
||||
final int mode = mDashboardData.getSuggestionConditionMode();
|
||||
if (mode == DashboardData.HEADER_MODE_DEFAULT) {
|
||||
shownSuggestions = suggestions.subList(0,
|
||||
Math.min(suggestions.size(), DashboardData.DEFAULT_SUGGESTION_COUNT));
|
||||
} else if (mode != DashboardData.HEADER_MODE_COLLAPSED) {
|
||||
shownSuggestions = suggestions;
|
||||
}
|
||||
if (shownSuggestions != null) {
|
||||
for (Tile suggestion : shownSuggestions) {
|
||||
final String identifier = mSuggestionFeatureProvider.getSuggestionIdentifier(
|
||||
mContext, suggestion);
|
||||
mMetricsFeatureProvider.action(
|
||||
mContext, MetricsEvent.ACTION_SHOW_SETTINGS_SUGGESTION, identifier,
|
||||
getSuggestionTaggedData());
|
||||
mSuggestionsShownLogged.add(identifier);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setSuggestionsV2(List<Suggestion> data) {
|
||||
@@ -191,7 +170,6 @@ public class DashboardAdapter extends RecyclerView.Adapter<DashboardAdapter.Dash
|
||||
.setSuggestionsV2(data)
|
||||
.build();
|
||||
notifyDashboardDataChanged(prevData);
|
||||
// TODO: Replicate the metrics logging from setCategoriesAndSuggestions()
|
||||
}
|
||||
|
||||
public void setCategory(DashboardCategory category) {
|
||||
@@ -331,22 +309,6 @@ public class DashboardAdapter extends RecyclerView.Adapter<DashboardAdapter.Dash
|
||||
mRecyclerView = recyclerView;
|
||||
}
|
||||
|
||||
public void onPause() {
|
||||
if (mDashboardData.getSuggestions() == null) {
|
||||
return;
|
||||
}
|
||||
for (Tile suggestion : mDashboardData.getSuggestions()) {
|
||||
String suggestionId = mSuggestionFeatureProvider.getSuggestionIdentifier(
|
||||
mContext, suggestion);
|
||||
if (mSuggestionsShownLogged.contains(suggestionId)) {
|
||||
mMetricsFeatureProvider.action(
|
||||
mContext, MetricsEvent.ACTION_HIDE_SETTINGS_SUGGESTION, suggestionId,
|
||||
getSuggestionTaggedData());
|
||||
}
|
||||
}
|
||||
mSuggestionsShownLogged.clear();
|
||||
}
|
||||
|
||||
public Object getItem(long itemId) {
|
||||
return mDashboardData.getItemEntityById(itemId);
|
||||
}
|
||||
@@ -375,23 +337,6 @@ public class DashboardAdapter extends RecyclerView.Adapter<DashboardAdapter.Dash
|
||||
}
|
||||
}
|
||||
|
||||
private void logSuggestions() {
|
||||
final List<Tile> suggestions = mDashboardData.getSuggestions();
|
||||
if (suggestions == null) {
|
||||
return;
|
||||
}
|
||||
for (Tile suggestion : suggestions) {
|
||||
final String suggestionId = mSuggestionFeatureProvider.getSuggestionIdentifier(
|
||||
mContext, suggestion);
|
||||
if (!mSuggestionsShownLogged.contains(suggestionId)) {
|
||||
mMetricsFeatureProvider.action(
|
||||
mContext, MetricsEvent.ACTION_SHOW_SETTINGS_SUGGESTION, suggestionId,
|
||||
getSuggestionTaggedData());
|
||||
mSuggestionsShownLogged.add(suggestionId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void onBindSuggestionConditionHeader(final SuggestionAndConditionHeaderHolder holder,
|
||||
SuggestionConditionHeaderData data) {
|
||||
@@ -460,9 +405,7 @@ public class DashboardAdapter extends RecyclerView.Adapter<DashboardAdapter.Dash
|
||||
holder.itemView.setPadding(0, padding, 0, padding);
|
||||
|
||||
holder.itemView.setOnClickListener(v -> {
|
||||
if (moreSuggestions) {
|
||||
logSuggestions();
|
||||
} else if (hasConditions) {
|
||||
if (hasConditions) {
|
||||
mMetricsFeatureProvider.action(mContext,
|
||||
MetricsEvent.ACTION_SETTINGS_CONDITION_EXPAND, true);
|
||||
}
|
||||
@@ -587,11 +530,6 @@ public class DashboardAdapter extends RecyclerView.Adapter<DashboardAdapter.Dash
|
||||
parent.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
private Pair<Integer, Object>[] getSuggestionTaggedData() {
|
||||
return SuggestionLogHelper.getSuggestionTaggedData(
|
||||
mSuggestionFeatureProvider.isSmartSuggestionEnabled(mContext));
|
||||
}
|
||||
|
||||
public static class IconCache {
|
||||
private final Context mContext;
|
||||
private final ArrayMap<Icon, Drawable> mMap = new ArrayMap<>();
|
||||
|
||||
@@ -152,9 +152,6 @@ public class DashboardSummary extends InstrumentedFragment
|
||||
mMetricsFeatureProvider.hidden(getContext(), c.getMetricsConstant());
|
||||
}
|
||||
}
|
||||
if (!getActivity().isChangingConfigurations()) {
|
||||
mAdapter.onPause();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -21,7 +21,6 @@ import android.service.settings.suggestions.Suggestion;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.util.Pair;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -131,7 +130,7 @@ public class SuggestionAdapter extends RecyclerView.Adapter<DashboardItemHolder>
|
||||
if (!mSuggestionsShownLogged.contains(suggestionId)) {
|
||||
mMetricsFeatureProvider.action(
|
||||
mContext, MetricsEvent.ACTION_SHOW_SETTINGS_SUGGESTION, suggestionId,
|
||||
getSuggestionTaggedData());
|
||||
mSuggestionFeatureProvider.getLoggingTaggedData(mContext));
|
||||
mSuggestionsShownLogged.add(suggestionId);
|
||||
}
|
||||
if (suggestion.remoteViews != null) {
|
||||
@@ -165,7 +164,7 @@ public class SuggestionAdapter extends RecyclerView.Adapter<DashboardItemHolder>
|
||||
clickHandler.setOnClickListener(v -> {
|
||||
mMetricsFeatureProvider.action(mContext,
|
||||
MetricsEvent.ACTION_SETTINGS_SUGGESTION, suggestionId,
|
||||
getSuggestionTaggedData());
|
||||
mSuggestionFeatureProvider.getLoggingTaggedData(mContext));
|
||||
((SettingsActivity) mContext).startSuggestion(suggestion.intent);
|
||||
});
|
||||
}
|
||||
@@ -237,11 +236,6 @@ public class SuggestionAdapter extends RecyclerView.Adapter<DashboardItemHolder>
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
private Pair<Integer, Object>[] getSuggestionTaggedData() {
|
||||
return SuggestionLogHelper.getSuggestionTaggedData(
|
||||
mSuggestionFeatureProvider.isSmartSuggestionEnabled(mContext));
|
||||
}
|
||||
|
||||
public void removeSuggestion(Suggestion suggestion) {
|
||||
mSuggestionsV2.remove(suggestion);
|
||||
notifyDataSetChanged();
|
||||
|
||||
@@ -21,6 +21,7 @@ import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.service.settings.suggestions.Suggestion;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.util.Pair;
|
||||
|
||||
import com.android.settingslib.drawer.Tile;
|
||||
import com.android.settingslib.suggestions.SuggestionParser;
|
||||
@@ -93,6 +94,14 @@ public interface SuggestionFeatureProvider {
|
||||
|
||||
/**
|
||||
* Returns an identifier for the suggestion
|
||||
*
|
||||
* @deprecated in favor or {@link Suggestion#getId()}
|
||||
*/
|
||||
@Deprecated
|
||||
String getSuggestionIdentifier(Context context, Tile suggestion);
|
||||
|
||||
/**
|
||||
* Returns common tagged data for suggestion logging.
|
||||
*/
|
||||
Pair<Integer, Object>[] getLoggingTaggedData(Context context);
|
||||
}
|
||||
|
||||
@@ -170,8 +170,7 @@ public class SuggestionFeatureProviderImpl implements SuggestionFeatureProvider
|
||||
if (parser == null || suggestion == null || context == null) {
|
||||
return;
|
||||
}
|
||||
final Pair<Integer, Object>[] taggedData =
|
||||
SuggestionLogHelper.getSuggestionTaggedData(isSmartSuggestionEnabled(context));
|
||||
final Pair<Integer, Object>[] taggedData = getLoggingTaggedData(context);
|
||||
|
||||
mMetricsFeatureProvider.action(
|
||||
context, MetricsEvent.ACTION_SETTINGS_DISMISS_SUGGESTION,
|
||||
@@ -213,6 +212,14 @@ public class SuggestionFeatureProviderImpl implements SuggestionFeatureProvider
|
||||
return packageName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<Integer, Object>[] getLoggingTaggedData(Context context) {
|
||||
final boolean isSmartSuggestionEnabled = isSmartSuggestionEnabled(context);
|
||||
return new Pair[]{Pair.create(
|
||||
MetricsEvent.FIELD_SETTINGS_SMART_SUGGESTIONS_ENABLED,
|
||||
isSmartSuggestionEnabled ? 1 : 0)};
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
boolean hasUsedNightDisplay(Context context) {
|
||||
final ContentResolver cr = context.getContentResolver();
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017 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.settings.dashboard.suggestions;
|
||||
|
||||
import android.util.Pair;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
|
||||
public class SuggestionLogHelper {
|
||||
|
||||
public static Pair<Integer, Object>[] getSuggestionTaggedData(boolean enabled) {
|
||||
return new Pair[]{
|
||||
Pair.create(
|
||||
MetricsEvent.FIELD_SETTINGS_SMART_SUGGESTIONS_ENABLED, enabled ? 1 : 0)};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user