Add generic logging to Settings switch bar
Same usage/format as the shared preference logging.
Bug: 27043208
Change-Id: I7a7a5c0a9c92ec6cef50df58313016218cf2f2f7
diff --git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java
index b6ac0c0..b875823 100644
--- a/src/com/android/settings/SettingsActivity.java
+++ b/src/com/android/settings/SettingsActivity.java
@@ -460,18 +460,22 @@
@Override
public SharedPreferences getSharedPreferences(String name, int mode) {
if (name.equals(getPackageName() + "_preferences")) {
- String tag = getClass().getName();
- if (getIntent() != null && getIntent().hasExtra(EXTRA_SHOW_FRAGMENT)) {
- tag = getIntent().getStringExtra(EXTRA_SHOW_FRAGMENT);
- }
- if (tag.startsWith("com.android.settings.")) {
- tag = tag.replace("com.android.settings.", "");
- }
- return new SharedPreferencesLogger(this, tag);
+ return new SharedPreferencesLogger(this, getMetricsTag());
}
return super.getSharedPreferences(name, mode);
}
+ private String getMetricsTag() {
+ String tag = getClass().getName();
+ if (getIntent() != null && getIntent().hasExtra(EXTRA_SHOW_FRAGMENT)) {
+ tag = getIntent().getStringExtra(EXTRA_SHOW_FRAGMENT);
+ }
+ if (tag.startsWith("com.android.settings.")) {
+ tag = tag.replace("com.android.settings.", "");
+ }
+ return tag;
+ }
+
private static boolean isShortCutIntent(final Intent intent) {
Set<String> categories = intent.getCategories();
return (categories != null) && categories.contains("com.android.settings.SHORTCUT");
@@ -610,6 +614,9 @@
mActionBar.setHomeButtonEnabled(mDisplayHomeAsUpEnabled);
}
mSwitchBar = (SwitchBar) findViewById(R.id.switch_bar);
+ if (mSwitchBar != null) {
+ mSwitchBar.setMetricsTag(getMetricsTag());
+ }
// see if we should show Back/Next buttons
if (intent.getBooleanExtra(EXTRA_PREFS_SHOW_BUTTON_BAR, false)) {