Log source with visibility change
- Add a method in VisibilityLoggerMixin to log visible event using LogMaker, which allows logging additional FIELD_CONTEXT field. - In Utils.startFragment, add current page's metricsCategory as an extra to next page. - In next page's onResume(), extract the previous page's metricsCategory and send it to VisibilityLoggerMixin.visible() - Update all caller with additional paramters Change-Id: I8e1f2597fa465b7d3aa16fa1d21c052a3219694a Fix: 35359289 Test: RunSettingsRoboTests
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
package com.android.settings.dashboard;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Fragment;
|
||||
import android.content.Context;
|
||||
import android.support.v7.preference.Preference;
|
||||
|
||||
@@ -44,26 +45,21 @@ public interface DashboardFeatureProvider {
|
||||
*
|
||||
* @param activity Activity hosting the preference
|
||||
* @param context UI context to inflate preference
|
||||
* @param sourceMetricsCategory The context (source) from which an action is performed
|
||||
* @param key Value from CategoryKey
|
||||
* @deprecated Pages implementing {@code DashboardFragment} should use
|
||||
* {@link #getTilesForCategory(String)} instead. Using this method will not get the benefit
|
||||
* of auto-ordering, progressive disclosure, auto-refreshing summary text etc.
|
||||
*/
|
||||
@Deprecated
|
||||
List<Preference> getPreferencesForCategory(Activity activity, Context context, String key);
|
||||
List<Preference> getPreferencesForCategory(Activity activity, Context context,
|
||||
int sourceMetricsCategory, String key);
|
||||
|
||||
/**
|
||||
* Get all tiles, grouped by category.
|
||||
*/
|
||||
List<DashboardCategory> getAllCategories();
|
||||
|
||||
/**
|
||||
* Returns a priority group for tile. priority level is grouped into hundreds. tiles with
|
||||
* priority 100 - 199 belongs to priority level 100, tiles with priority 200 - 299 is in
|
||||
* group 200, and so on.
|
||||
*/
|
||||
int getPriorityGroup(Preference preference);
|
||||
|
||||
/**
|
||||
* Returns an unique string key for the tile.
|
||||
*/
|
||||
@@ -73,14 +69,15 @@ public interface DashboardFeatureProvider {
|
||||
* Binds preference to data provided by tile.
|
||||
*
|
||||
* @param activity If tile contains intent to launch, it will be launched from this activity
|
||||
* @param sourceMetricsCategory The context (source) from which an action is performed
|
||||
* @param pref The preference to bind data
|
||||
* @param tile The binding data
|
||||
* @param key They key for preference. If null, we will generate one from tile data
|
||||
* @param baseOrder The order offset value. When binding, pref's order is determined by
|
||||
* both this value and tile's own priority.
|
||||
*/
|
||||
void bindPreferenceToTile(Activity activity, Preference pref, Tile tile, String key,
|
||||
int baseOrder);
|
||||
void bindPreferenceToTile(Activity activity, int sourceMetricsCategory, Preference pref,
|
||||
Tile tile, String key, int baseOrder);
|
||||
|
||||
/**
|
||||
* Returns a {@link ProgressiveDisclosureMixin} for specified fragment.
|
||||
|
||||
@@ -80,7 +80,7 @@ public class DashboardFeatureProviderImpl implements DashboardFeatureProvider {
|
||||
|
||||
@Override
|
||||
public List<Preference> getPreferencesForCategory(Activity activity, Context context,
|
||||
String key) {
|
||||
int sourceMetricsCategory, String key) {
|
||||
if (!isEnabled()) {
|
||||
return null;
|
||||
}
|
||||
@@ -97,7 +97,7 @@ public class DashboardFeatureProviderImpl implements DashboardFeatureProvider {
|
||||
final List<Preference> preferences = new ArrayList<>();
|
||||
for (Tile tile : tiles) {
|
||||
final Preference pref = new Preference(context);
|
||||
bindPreferenceToTile(activity, pref, tile, null /* key */,
|
||||
bindPreferenceToTile(activity, sourceMetricsCategory, pref, tile, null /* key */,
|
||||
Preference.DEFAULT_ORDER /* baseOrder */);
|
||||
preferences.add(pref);
|
||||
}
|
||||
@@ -109,11 +109,6 @@ public class DashboardFeatureProviderImpl implements DashboardFeatureProvider {
|
||||
return mCategoryManager.getCategories(mContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPriorityGroup(Preference preference) {
|
||||
return preference.getOrder() / 100;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDashboardKeyForTile(Tile tile) {
|
||||
if (tile == null || tile.intent == null) {
|
||||
@@ -129,8 +124,8 @@ public class DashboardFeatureProviderImpl implements DashboardFeatureProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindPreferenceToTile(Activity activity, Preference pref, Tile tile, String key,
|
||||
int baseOrder) {
|
||||
public void bindPreferenceToTile(Activity activity, int sourceMetricsCategory, Preference pref,
|
||||
Tile tile, String key, int baseOrder) {
|
||||
pref.setTitle(tile.title);
|
||||
if (!TextUtils.isEmpty(key)) {
|
||||
pref.setKey(key);
|
||||
@@ -152,6 +147,7 @@ public class DashboardFeatureProviderImpl implements DashboardFeatureProvider {
|
||||
pref.setFragment(clsName);
|
||||
} else if (tile.intent != null) {
|
||||
final Intent intent = new Intent(tile.intent);
|
||||
intent.putExtra(SettingsActivity.EXTRA_SOURCE_METRICS_CATEGORY, sourceMetricsCategory);
|
||||
if (action != null) {
|
||||
intent.setAction(action);
|
||||
}
|
||||
|
||||
@@ -330,13 +330,13 @@ public abstract class DashboardFragment extends SettingsPreferenceFragment
|
||||
// Have the key already, will rebind.
|
||||
final Preference preference = mProgressiveDisclosureMixin.findPreference(
|
||||
screen, key);
|
||||
mDashboardFeatureProvider.bindPreferenceToTile(getActivity(), preference, tile, key,
|
||||
mPlaceholderPreferenceController.getOrder());
|
||||
mDashboardFeatureProvider.bindPreferenceToTile(getActivity(), getMetricsCategory(),
|
||||
preference, tile, key, mPlaceholderPreferenceController.getOrder());
|
||||
} else {
|
||||
// Don't have this key, add it.
|
||||
final Preference pref = new Preference(getPrefContext());
|
||||
mDashboardFeatureProvider.bindPreferenceToTile(getActivity(), pref, tile, key,
|
||||
mPlaceholderPreferenceController.getOrder());
|
||||
mDashboardFeatureProvider.bindPreferenceToTile(getActivity(), getMetricsCategory(),
|
||||
pref, tile, key, mPlaceholderPreferenceController.getOrder());
|
||||
mProgressiveDisclosureMixin.addPreference(screen, pref);
|
||||
mDashboardTilePrefKeys.add(key);
|
||||
}
|
||||
|
||||
@@ -134,9 +134,11 @@ public class DashboardSummary extends InstrumentedFragment
|
||||
|
||||
((SettingsDrawerActivity) getActivity()).addCategoryListener(this);
|
||||
mSummaryLoader.setListening(true);
|
||||
final int metricsCategory = getMetricsCategory();
|
||||
for (Condition c : mConditionManager.getConditions()) {
|
||||
if (c.shouldShow()) {
|
||||
mMetricsFeatureProvider.visible(getContext(), c.getMetricsConstant());
|
||||
mMetricsFeatureProvider.visible(getContext(), metricsCategory,
|
||||
c.getMetricsConstant());
|
||||
}
|
||||
}
|
||||
if (DEBUG_TIMING) {
|
||||
|
||||
@@ -194,7 +194,8 @@ public class SearchResultsSummary extends InstrumentedPreferenceFragment {
|
||||
Bundle args = new Bundle();
|
||||
args.putString(SettingsActivity.EXTRA_FRAGMENT_ARG_KEY, key);
|
||||
|
||||
Utils.startWithFragment(sa, className, args, null, 0, -1, screenTitle);
|
||||
Utils.startWithFragment(sa, className, args, null, 0, -1, screenTitle,
|
||||
getMetricsCategory());
|
||||
} else {
|
||||
final Intent intent = new Intent(action);
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ public class BatterySaverCondition extends Condition {
|
||||
@Override
|
||||
public void onPrimaryClick() {
|
||||
Utils.startWithFragment(mManager.getContext(), BatterySaverSettings.class.getName(), null,
|
||||
null, 0, R.string.battery_saver, null);
|
||||
null, 0, R.string.battery_saver, null, MetricsEvent.DASHBOARD_SUMMARY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -91,7 +91,7 @@ public class HotspotCondition extends Condition {
|
||||
@Override
|
||||
public void onPrimaryClick() {
|
||||
Utils.startWithFragment(mManager.getContext(), TetherSettings.class.getName(), null, null,
|
||||
0, R.string.tether_settings_title_all, null);
|
||||
0, R.string.tether_settings_title_all, null, MetricsEvent.DASHBOARD_SUMMARY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -63,7 +63,7 @@ public final class NightDisplayCondition extends Condition
|
||||
@Override
|
||||
public void onPrimaryClick() {
|
||||
Utils.startWithFragment(mManager.getContext(), NightDisplaySettings.class.getName(), null,
|
||||
null, 0, R.string.night_display_title, null);
|
||||
null, 0, R.string.night_display_title, null, MetricsEvent.DASHBOARD_SUMMARY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user