Add a new logger for StatsLog
Bug: 117860032 Test: robotests Change-Id: I4f3f5b1fb47df9427140a22f1e78126ad391ff68
This commit is contained in:
@@ -0,0 +1,27 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2018 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.settings.core.instrumentation;
|
||||||
|
|
||||||
|
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||||
|
|
||||||
|
public class SettingsMetricsFeatureProvider extends MetricsFeatureProvider {
|
||||||
|
@Override
|
||||||
|
protected void installLogWriters() {
|
||||||
|
super.installLogWriters();
|
||||||
|
mLoggerWriters.add(new StatsLogWriter());
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,118 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2018 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.settings.core.instrumentation;
|
||||||
|
|
||||||
|
import android.app.settings.SettingsEnums;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.util.Pair;
|
||||||
|
import android.util.StatsLog;
|
||||||
|
|
||||||
|
import com.android.settingslib.core.instrumentation.LogWriter;
|
||||||
|
|
||||||
|
public class StatsLogWriter implements LogWriter {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void visible(Context context, int attribution, int pageId) {
|
||||||
|
StatsLog.write(StatsLog.SETTINGS_UI_CHANGED /* Atom name */,
|
||||||
|
attribution,
|
||||||
|
SettingsEnums.PAGE_VISIBLE /* action */,
|
||||||
|
pageId,
|
||||||
|
null /* changedPreferenceKey */,
|
||||||
|
0 /* changedPreferenceIntValue */);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void hidden(Context context, int pageId) {
|
||||||
|
StatsLog.write(StatsLog.SETTINGS_UI_CHANGED /* Atom name */,
|
||||||
|
SettingsEnums.PAGE_UNKNOWN /* attribution */,
|
||||||
|
SettingsEnums.PAGE_HIDE /* action */,
|
||||||
|
pageId,
|
||||||
|
null /* changedPreferenceKey */,
|
||||||
|
0 /* changedPreferenceIntValue */);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void action(int category, int value, Pair<Integer, Object>... taggedData) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void action(int category, boolean value, Pair<Integer, Object>... taggedData) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void action(Context context, int action, Pair<Integer, Object>... taggedData) {
|
||||||
|
action(SettingsEnums.PAGE_UNKNOWN /* attribution */,
|
||||||
|
action,
|
||||||
|
SettingsEnums.PAGE_UNKNOWN /* pageId */,
|
||||||
|
null /* changedPreferenceKey */,
|
||||||
|
0 /* changedPreferenceIntValue */);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionWithSource(Context context, int pageId, int action) {
|
||||||
|
action(SettingsEnums.PAGE_UNKNOWN /* attribution */,
|
||||||
|
action,
|
||||||
|
pageId /* pageId */,
|
||||||
|
null /* changedPreferenceKey */,
|
||||||
|
0 /* changedPreferenceIntValue */);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void action(Context context, int action, int value) {
|
||||||
|
action(SettingsEnums.PAGE_UNKNOWN /* attribution */,
|
||||||
|
action,
|
||||||
|
SettingsEnums.PAGE_UNKNOWN /* pageId */,
|
||||||
|
null /* changedPreferenceKey */,
|
||||||
|
value /* changedPreferenceIntValue */);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void action(Context context, int action, boolean value) {
|
||||||
|
action(SettingsEnums.PAGE_UNKNOWN /* attribution */,
|
||||||
|
action,
|
||||||
|
SettingsEnums.PAGE_UNKNOWN /* pageId */,
|
||||||
|
null /* changedPreferenceKey */,
|
||||||
|
value ? 1 : 0 /* changedPreferenceIntValue */);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void action(Context context, int action, String pkg,
|
||||||
|
Pair<Integer, Object>... taggedData) {
|
||||||
|
action(SettingsEnums.PAGE_UNKNOWN /* attribution */,
|
||||||
|
action,
|
||||||
|
SettingsEnums.PAGE_UNKNOWN /* pageId */,
|
||||||
|
pkg /* changedPreferenceKey */,
|
||||||
|
1 /* changedPreferenceIntValue */);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void count(Context context, String name, int value) {
|
||||||
|
// No-op
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void action(int attribution, int action, int pageId, String key, int value) {
|
||||||
|
StatsLog.write(StatsLog.SETTINGS_UI_CHANGED /* atomName */,
|
||||||
|
attribution,
|
||||||
|
action,
|
||||||
|
pageId,
|
||||||
|
key,
|
||||||
|
value);
|
||||||
|
}
|
||||||
|
}
|
@@ -16,16 +16,12 @@
|
|||||||
|
|
||||||
package com.android.settings.gestures;
|
package com.android.settings.gestures;
|
||||||
|
|
||||||
|
import android.app.settings.SettingsEnums;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.provider.SearchIndexableResource;
|
import android.provider.SearchIndexableResource;
|
||||||
|
|
||||||
import com.android.internal.hardware.AmbientDisplayConfiguration;
|
|
||||||
import com.android.internal.logging.nano.MetricsProto;
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.dashboard.DashboardFragment;
|
import com.android.settings.dashboard.DashboardFragment;
|
||||||
import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider;
|
|
||||||
import com.android.settings.overlay.FeatureFactory;
|
|
||||||
import com.android.settings.search.BaseSearchIndexProvider;
|
import com.android.settings.search.BaseSearchIndexProvider;
|
||||||
import com.android.settingslib.search.SearchIndexable;
|
import com.android.settingslib.search.SearchIndexable;
|
||||||
|
|
||||||
@@ -42,7 +38,7 @@ public class WakeScreenGestureSettings extends DashboardFragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMetricsCategory() {
|
public int getMetricsCategory() {
|
||||||
return MetricsProto.MetricsEvent.SETTINGS_GESTURE_WAKE_SCREEN;
|
return SettingsEnums.SETTINGS_GESTURE_WAKE_SCREEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -18,6 +18,7 @@ package com.android.settings.homepage.contextualcards;
|
|||||||
|
|
||||||
import static com.android.settings.homepage.contextualcards.ContextualCardsAdapter.SPAN_COUNT;
|
import static com.android.settings.homepage.contextualcards.ContextualCardsAdapter.SPAN_COUNT;
|
||||||
|
|
||||||
|
import android.app.settings.SettingsEnums;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@@ -26,7 +27,6 @@ import android.view.ViewGroup;
|
|||||||
import androidx.recyclerview.widget.GridLayoutManager;
|
import androidx.recyclerview.widget.GridLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.core.InstrumentedFragment;
|
import com.android.settings.core.InstrumentedFragment;
|
||||||
|
|
||||||
@@ -69,6 +69,6 @@ public class ContextualCardsFragment extends InstrumentedFragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMetricsCategory() {
|
public int getMetricsCategory() {
|
||||||
return MetricsEvent.SETTINGS_HOMEPAGE;
|
return SettingsEnums.SETTINGS_HOMEPAGE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -17,6 +17,7 @@
|
|||||||
package com.android.settings.network.telephony;
|
package com.android.settings.network.telephony;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.app.settings.SettingsEnums;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@@ -31,7 +32,6 @@ import android.util.Log;
|
|||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
|
|
||||||
import com.android.internal.logging.nano.MetricsProto;
|
|
||||||
import com.android.internal.telephony.TelephonyIntents;
|
import com.android.internal.telephony.TelephonyIntents;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.dashboard.RestrictedDashboardFragment;
|
import com.android.settings.dashboard.RestrictedDashboardFragment;
|
||||||
@@ -75,7 +75,7 @@ public class MobileNetworkSettings extends RestrictedDashboardFragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMetricsCategory() {
|
public int getMetricsCategory() {
|
||||||
return MetricsProto.MetricsEvent.MOBILE_NETWORK;
|
return SettingsEnums.MOBILE_NETWORK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -15,9 +15,8 @@
|
|||||||
*/
|
*/
|
||||||
package com.android.settings.network.telephony;
|
package com.android.settings.network.telephony;
|
||||||
|
|
||||||
import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.MOBILE_NETWORK_SELECT;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.app.settings.SettingsEnums;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
@@ -203,7 +202,7 @@ public class NetworkSelectSettings extends DashboardFragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMetricsCategory() {
|
public int getMetricsCategory() {
|
||||||
return MOBILE_NETWORK_SELECT;
|
return SettingsEnums.MOBILE_NETWORK_SELECT;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Handler mHandler = new Handler() {
|
private final Handler mHandler = new Handler() {
|
||||||
|
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package com.android.settings.network.telephony.gsm;
|
package com.android.settings.network.telephony.gsm;
|
||||||
|
|
||||||
|
import android.app.settings.SettingsEnums;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.PersistableBundle;
|
import android.os.PersistableBundle;
|
||||||
@@ -26,7 +27,6 @@ import android.telephony.TelephonyManager;
|
|||||||
|
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
|
|
||||||
import com.android.internal.logging.nano.MetricsProto;
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.core.SubSettingLauncher;
|
import com.android.settings.core.SubSettingLauncher;
|
||||||
import com.android.settings.core.TogglePreferenceController;
|
import com.android.settings.core.TogglePreferenceController;
|
||||||
@@ -100,7 +100,7 @@ public class AutoSelectPreferenceController extends TogglePreferenceController {
|
|||||||
bundle.putInt(Settings.EXTRA_SUB_ID, mSubId);
|
bundle.putInt(Settings.EXTRA_SUB_ID, mSubId);
|
||||||
new SubSettingLauncher(mContext)
|
new SubSettingLauncher(mContext)
|
||||||
.setDestination(NetworkSelectSettings.class.getName())
|
.setDestination(NetworkSelectSettings.class.getName())
|
||||||
.setSourceMetricsCategory(MetricsProto.MetricsEvent.MOBILE_NETWORK_SELECT)
|
.setSourceMetricsCategory(SettingsEnums.MOBILE_NETWORK_SELECT)
|
||||||
.setTitleRes(R.string.choose_network_title)
|
.setTitleRes(R.string.choose_network_title)
|
||||||
.setArguments(bundle)
|
.setArguments(bundle)
|
||||||
.launch();
|
.launch();
|
||||||
|
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package com.android.settings.network.telephony.gsm;
|
package com.android.settings.network.telephony.gsm;
|
||||||
|
|
||||||
|
import android.app.settings.SettingsEnums;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
@@ -27,7 +28,6 @@ import android.text.TextUtils;
|
|||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
import com.android.internal.logging.nano.MetricsProto;
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.core.BasePreferenceController;
|
import com.android.settings.core.BasePreferenceController;
|
||||||
import com.android.settings.core.SubSettingLauncher;
|
import com.android.settings.core.SubSettingLauncher;
|
||||||
@@ -88,7 +88,7 @@ public class OpenNetworkSelectPagePreferenceController extends BasePreferenceCon
|
|||||||
bundle.putInt(Settings.EXTRA_SUB_ID, mSubId);
|
bundle.putInt(Settings.EXTRA_SUB_ID, mSubId);
|
||||||
new SubSettingLauncher(mContext)
|
new SubSettingLauncher(mContext)
|
||||||
.setDestination(NetworkSelectSettings.class.getName())
|
.setDestination(NetworkSelectSettings.class.getName())
|
||||||
.setSourceMetricsCategory(MetricsProto.MetricsEvent.MOBILE_NETWORK_SELECT)
|
.setSourceMetricsCategory(SettingsEnums.MOBILE_NETWORK_SELECT)
|
||||||
.setTitleRes(R.string.choose_network_title)
|
.setTitleRes(R.string.choose_network_title)
|
||||||
.setArguments(bundle)
|
.setArguments(bundle)
|
||||||
.launch();
|
.launch();
|
||||||
|
@@ -29,6 +29,7 @@ import com.android.settings.accounts.AccountFeatureProviderImpl;
|
|||||||
import com.android.settings.applications.ApplicationFeatureProvider;
|
import com.android.settings.applications.ApplicationFeatureProvider;
|
||||||
import com.android.settings.applications.ApplicationFeatureProviderImpl;
|
import com.android.settings.applications.ApplicationFeatureProviderImpl;
|
||||||
import com.android.settings.connecteddevice.dock.DockUpdaterFeatureProviderImpl;
|
import com.android.settings.connecteddevice.dock.DockUpdaterFeatureProviderImpl;
|
||||||
|
import com.android.settings.core.instrumentation.SettingsMetricsFeatureProvider;
|
||||||
import com.android.settings.dashboard.DashboardFeatureProvider;
|
import com.android.settings.dashboard.DashboardFeatureProvider;
|
||||||
import com.android.settings.dashboard.DashboardFeatureProviderImpl;
|
import com.android.settings.dashboard.DashboardFeatureProviderImpl;
|
||||||
import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider;
|
import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider;
|
||||||
@@ -80,7 +81,7 @@ public class FeatureFactoryImpl extends FeatureFactory {
|
|||||||
@Override
|
@Override
|
||||||
public MetricsFeatureProvider getMetricsFeatureProvider() {
|
public MetricsFeatureProvider getMetricsFeatureProvider() {
|
||||||
if (mMetricsFeatureProvider == null) {
|
if (mMetricsFeatureProvider == null) {
|
||||||
mMetricsFeatureProvider = new MetricsFeatureProvider();
|
mMetricsFeatureProvider = new SettingsMetricsFeatureProvider();
|
||||||
}
|
}
|
||||||
return mMetricsFeatureProvider;
|
return mMetricsFeatureProvider;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user