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