Refine metrics log in infrastructure

- Add interfaces to set/get metrics category in BasePreferenceController
  for descendants having a chance to get it.
- Set metrics category in DashboardFragment
- Automatically log metrics in onPreferenceChange of
  TogglePreferenceController
- Add support for TwoStateButtonPreference in TogglePreferenceController
  to make the preference generic

Bug: 137559984
Test: robotest
Change-Id: Ia7e0d24a3db1991b18e0286d9894570fa71247a3
This commit is contained in:
Jason Chiu
2020-04-01 15:40:47 +08:00
parent 9266fe32f7
commit 819abf7f87
10 changed files with 53 additions and 38 deletions

View File

@@ -17,7 +17,6 @@
package com.android.settings.applications;
import android.app.Application;
import android.app.settings.SettingsEnums;
import android.app.usage.UsageStats;
import android.content.Context;
import android.icu.text.RelativeDateTimeFormatter;
@@ -98,12 +97,12 @@ public class RecentAppsPreferenceController extends BasePreferenceController
.setHeaderTitleRes(R.string.recent_app_category_title)
.setHeaderDetailsClickListener((View v) -> {
mMetricsFeatureProvider.logClickedPreference(mRecentAppsPreference,
SettingsEnums.SETTINGS_APP_NOTIF_CATEGORY);
getMetricsCategory());
new SubSettingLauncher(mContext)
.setDestination(ManageApplications.class.getName())
.setArguments(null /* arguments */)
.setTitleRes(R.string.application_info_label)
.setSourceMetricsCategory(SettingsEnums.SETTINGS_APP_NOTIF_CATEGORY)
.setSourceMetricsCategory(getMetricsCategory())
.launch();
});
}
@@ -166,11 +165,10 @@ public class RecentAppsPreferenceController extends BasePreferenceController
RelativeDateTimeFormatter.Style.SHORT))
.setOnClickListener(v -> {
mMetricsFeatureProvider.logClickedPreference(mRecentAppsPreference,
SettingsEnums.SETTINGS_APP_NOTIF_CATEGORY);
getMetricsCategory());
AppInfoBase.startAppInfoFragment(AppInfoDashboardFragment.class,
R.string.application_info_label, pkgName, appEntry.info.uid,
mHost, 1001 /*RequestCode*/,
SettingsEnums.SETTINGS_APP_NOTIF_CATEGORY);
mHost, 1001 /*RequestCode*/, getMetricsCategory());
})
.build();
}