[Settings] Add preference click metric log

- Move the log point of onPreferenceTreeClick from DashboardFragment to
  it's super class InstrumentedPreferenceFragment for better coverage.
- Write the preference click metric log in PreferenceController handling
  case in DashboardFragment which will skip super class's log point.

Bug: 137559984
Test: robotest
Change-Id: I67178f613c74f755e20fc9dc41319974cb02e83c
This commit is contained in:
Jason Chiu
2019-12-12 17:31:28 +08:00
parent e7e4dd905a
commit 1281e595e4
4 changed files with 18 additions and 12 deletions

View File

@@ -201,16 +201,15 @@ public abstract class DashboardFragment extends SettingsPreferenceFragment
@Override
public boolean onPreferenceTreeClick(Preference preference) {
Collection<List<AbstractPreferenceController>> controllers =
final Collection<List<AbstractPreferenceController>> controllers =
mPreferenceControllers.values();
// If preference contains intent, log it before handling.
mMetricsFeatureProvider.logDashboardStartIntent(
getContext(), preference.getIntent(), getMetricsCategory());
// Give all controllers a chance to handle click.
preference.getExtras().putInt(CATEGORY, getMetricsCategory());
for (List<AbstractPreferenceController> controllerList : controllers) {
for (AbstractPreferenceController controller : controllerList) {
if (controller.handlePreferenceTreeClick(preference)) {
// log here since calling super.onPreferenceTreeClick will be skipped
writePreferenceClickMetric(preference);
return true;
}
}