Merge "Change preference value changed metrics log format"
This commit is contained in:
@@ -24,6 +24,7 @@ import static com.android.settings.applications.appinfo.AppButtonsPreferenceCont
|
||||
|
||||
import android.app.ActionBar;
|
||||
import android.app.ActivityManager;
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.ComponentName;
|
||||
@@ -230,25 +231,44 @@ public class SettingsActivity extends SettingsBaseActivity
|
||||
|
||||
@Override
|
||||
public SharedPreferences getSharedPreferences(String name, int mode) {
|
||||
if (name.equals(getPackageName() + "_preferences")) {
|
||||
return new SharedPreferencesLogger(this, getMetricsTag(),
|
||||
FeatureFactory.getFactory(this).getMetricsFeatureProvider());
|
||||
}
|
||||
if (!TextUtils.equals(name, getPackageName() + "_preferences")) {
|
||||
return super.getSharedPreferences(name, mode);
|
||||
}
|
||||
|
||||
String tag = getMetricsTag();
|
||||
|
||||
return new SharedPreferencesLogger(this, tag,
|
||||
FeatureFactory.getFactory(this).getMetricsFeatureProvider(),
|
||||
lookupMetricsCategory());
|
||||
}
|
||||
|
||||
private int lookupMetricsCategory() {
|
||||
int category = SettingsEnums.PAGE_UNKNOWN;
|
||||
Bundle args = null;
|
||||
if (getIntent() != null) {
|
||||
args = getIntent().getBundleExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS);
|
||||
}
|
||||
|
||||
Fragment fragment = Utils.getTargetFragment(this, getMetricsTag(), args);
|
||||
|
||||
if (fragment instanceof Instrumentable) {
|
||||
category = ((Instrumentable) fragment).getMetricsCategory();
|
||||
}
|
||||
Log.d(LOG_TAG, "MetricsCategory is " + category);
|
||||
|
||||
return category;
|
||||
}
|
||||
|
||||
private String getMetricsTag() {
|
||||
String tag = null;
|
||||
if (getIntent() != null && getIntent().hasExtra(EXTRA_SHOW_FRAGMENT)) {
|
||||
tag = getInitialFragmentName(getIntent());
|
||||
}
|
||||
|
||||
if (TextUtils.isEmpty(tag)) {
|
||||
Log.w(LOG_TAG, "MetricsTag is invalid " + tag);
|
||||
tag = getClass().getName();
|
||||
}
|
||||
if (tag.startsWith("com.android.settings.")) {
|
||||
tag = tag.replace("com.android.settings.", "");
|
||||
}
|
||||
return tag;
|
||||
}
|
||||
|
||||
@@ -320,7 +340,7 @@ public class SettingsActivity extends SettingsBaseActivity
|
||||
}
|
||||
mMainSwitch = findViewById(R.id.switch_bar);
|
||||
if (mMainSwitch != null) {
|
||||
mMainSwitch.setMetricsTag(getMetricsTag());
|
||||
mMainSwitch.setMetricsCategory(lookupMetricsCategory());
|
||||
mMainSwitch.setTranslationZ(findViewById(R.id.main_content).getTranslationZ() + 1);
|
||||
}
|
||||
|
||||
|
@@ -40,6 +40,22 @@ public class SettingsEventLogWriter extends EventLogWriter {
|
||||
super.hidden(context, category, visibleTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clicked(int sourceCategory, String key) {
|
||||
if (shouldDisableGenericEventLogging()) {
|
||||
return;
|
||||
}
|
||||
super.clicked(sourceCategory, key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changed(int category, String key, int value) {
|
||||
if (shouldDisableGenericEventLogging()) {
|
||||
return;
|
||||
}
|
||||
super.changed(category, key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void action(Context context, int category, String pkg) {
|
||||
if (shouldDisableGenericEventLogging()) {
|
||||
|
@@ -84,6 +84,10 @@ public class SettingsIntelligenceLogWriter implements LogWriter {
|
||||
public void clicked(int sourceCategory, String key) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changed(int category, String key, int value) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void action(Context context, int action, Pair<Integer, Object>... taggedData) {
|
||||
action(SettingsEnums.PAGE_UNKNOWN /* attribution */,
|
||||
|
@@ -54,6 +54,16 @@ public class StatsLogWriter implements LogWriter {
|
||||
0 /* changedPreferenceIntValue */);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changed(int sourceCategory, String key, int value) {
|
||||
SettingsStatsLog.write(SettingsStatsLog.SETTINGS_UI_CHANGED /* Atom name */,
|
||||
sourceCategory /* attribution */,
|
||||
SettingsEnums.ACTION_SETTINGS_PREFERENCE_CHANGE /* action */,
|
||||
SettingsEnums.PAGE_UNKNOWN /* pageId */,
|
||||
key /* changedPreferenceKey */,
|
||||
value /* changedPreferenceIntValue */);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void action(Context context, int action, Pair<Integer, Object>... taggedData) {
|
||||
action(SettingsEnums.PAGE_UNKNOWN /* attribution */,
|
||||
|
@@ -18,7 +18,6 @@ package com.android.settings.widget;
|
||||
|
||||
import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
@@ -55,7 +54,7 @@ public class SettingsMainSwitchBar extends MainSwitchBar {
|
||||
private final MetricsFeatureProvider mMetricsFeatureProvider;
|
||||
private OnBeforeCheckedChangeListener mOnBeforeListener;
|
||||
|
||||
private String mMetricsTag;
|
||||
private int mMetricsCategory;
|
||||
|
||||
public SettingsMainSwitchBar(Context context) {
|
||||
this(context, null);
|
||||
@@ -125,12 +124,7 @@ public class SettingsMainSwitchBar extends MainSwitchBar {
|
||||
}
|
||||
|
||||
protected void onRestrictedIconClick() {
|
||||
mMetricsFeatureProvider.action(
|
||||
SettingsEnums.PAGE_UNKNOWN,
|
||||
SettingsEnums.ACTION_SETTINGS_PREFERENCE_CHANGE,
|
||||
SettingsEnums.PAGE_UNKNOWN,
|
||||
mMetricsTag + "/switch_bar|restricted",
|
||||
1);
|
||||
mMetricsFeatureProvider.clicked(mMetricsCategory, "switch_bar|restricted");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -159,8 +153,8 @@ public class SettingsMainSwitchBar extends MainSwitchBar {
|
||||
/**
|
||||
* Set the metrics tag.
|
||||
*/
|
||||
public void setMetricsTag(String tag) {
|
||||
mMetricsTag = tag;
|
||||
public void setMetricsCategory(int category) {
|
||||
mMetricsCategory = category;
|
||||
}
|
||||
|
||||
private View getDelegatingView() {
|
||||
@@ -168,11 +162,6 @@ public class SettingsMainSwitchBar extends MainSwitchBar {
|
||||
}
|
||||
|
||||
private void logMetrics(boolean isChecked) {
|
||||
mMetricsFeatureProvider.action(
|
||||
SettingsEnums.PAGE_UNKNOWN,
|
||||
SettingsEnums.ACTION_SETTINGS_PREFERENCE_CHANGE,
|
||||
SettingsEnums.PAGE_UNKNOWN,
|
||||
mMetricsTag + "/switch_bar",
|
||||
isChecked ? 1 : 0);
|
||||
mMetricsFeatureProvider.changed(mMetricsCategory, "switch_bar", isChecked ? 1 : 0);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user