Merge "Add metrics log for special cases" into rvc-dev
diff --git a/res/xml/storage_dashboard_fragment.xml b/res/xml/storage_dashboard_fragment.xml
index 51d4935..91634fc 100644
--- a/res/xml/storage_dashboard_fragment.xml
+++ b/res/xml/storage_dashboard_fragment.xml
@@ -20,7 +20,7 @@
android:title="@string/storage_settings"
android:orderingFromXml="false">
<com.android.settings.deviceinfo.storage.StorageSummaryDonutPreference
- android:key="pref_summary"
+ android:key="storage_summary"
android:order="0"
settings:searchable="false"
settings:controller="com.android.settings.deviceinfo.storage.StorageSummaryDonutPreferenceController"/>
diff --git a/src/com/android/settings/biometrics/BiometricStatusPreferenceController.java b/src/com/android/settings/biometrics/BiometricStatusPreferenceController.java
index 62dc1cf..2a3bfb2 100644
--- a/src/com/android/settings/biometrics/BiometricStatusPreferenceController.java
+++ b/src/com/android/settings/biometrics/BiometricStatusPreferenceController.java
@@ -23,6 +23,7 @@
import android.content.Intent;
import android.os.UserHandle;
import android.os.UserManager;
+import android.text.TextUtils;
import androidx.preference.Preference;
@@ -100,29 +101,31 @@
} else {
preference.setVisible(true);
}
- final int userId = getUserId();
- final String clazz;
- if (hasEnrolledBiometrics()) {
- preference.setSummary(getSummaryTextEnrolled());
- clazz = getSettingsClassName();
- } else {
- preference.setSummary(getSummaryTextNoneEnrolled());
- clazz = getEnrollClassName();
+ preference.setSummary(hasEnrolledBiometrics() ? getSummaryTextEnrolled()
+ : getSummaryTextNoneEnrolled());
+ }
+
+ @Override
+ public boolean handlePreferenceTreeClick(Preference preference) {
+ if (!TextUtils.equals(preference.getKey(), getPreferenceKey())) {
+ return super.handlePreferenceTreeClick(preference);
}
- preference.setOnPreferenceClickListener(target -> {
- final Context context = target.getContext();
- final UserManager userManager = UserManager.get(context);
- if (Utils.startQuietModeDialogIfNecessary(context, userManager,
- userId)) {
- return false;
- }
- Intent intent = new Intent();
- intent.setClassName(SETTINGS_PACKAGE_NAME, clazz);
- intent.putExtra(Intent.EXTRA_USER_ID, userId);
- intent.putExtra(EXTRA_FROM_SETTINGS_SUMMARY, true);
- context.startActivity(intent);
- return true;
- });
+
+ final Context context = preference.getContext();
+ final UserManager userManager = UserManager.get(context);
+ final int userId = getUserId();
+ if (Utils.startQuietModeDialogIfNecessary(context, userManager, userId)) {
+ return false;
+ }
+
+ final Intent intent = new Intent();
+ final String clazz = hasEnrolledBiometrics() ? getSettingsClassName()
+ : getEnrollClassName();
+ intent.setClassName(SETTINGS_PACKAGE_NAME, clazz);
+ intent.putExtra(Intent.EXTRA_USER_ID, userId);
+ intent.putExtra(EXTRA_FROM_SETTINGS_SUMMARY, true);
+ context.startActivity(intent);
+ return true;
}
protected int getUserId() {
diff --git a/src/com/android/settings/biometrics/face/FaceSettingsRemoveButtonPreferenceController.java b/src/com/android/settings/biometrics/face/FaceSettingsRemoveButtonPreferenceController.java
index 1c1b81d..a4da759 100644
--- a/src/com/android/settings/biometrics/face/FaceSettingsRemoveButtonPreferenceController.java
+++ b/src/com/android/settings/biometrics/face/FaceSettingsRemoveButtonPreferenceController.java
@@ -35,6 +35,8 @@
import com.android.settings.SettingsActivity;
import com.android.settings.core.BasePreferenceController;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
+import com.android.settings.overlay.FeatureFactory;
+import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
import com.android.settingslib.widget.LayoutPreference;
import java.util.List;
@@ -80,12 +82,14 @@
void onRemoved();
}
+ private Preference mPreference;
private Button mButton;
private Listener mListener;
private SettingsActivity mActivity;
private int mUserId;
private boolean mRemoving;
+ private final MetricsFeatureProvider mMetricsFeatureProvider;
private final Context mContext;
private final FaceManager mFaceManager;
private final FaceManager.RemovalCallback mRemovalCallback = new FaceManager.RemovalCallback() {
@@ -141,6 +145,7 @@
super(context, preferenceKey);
mContext = context;
mFaceManager = context.getSystemService(FaceManager.class);
+ mMetricsFeatureProvider = FeatureFactory.getFactory(context).getMetricsFeatureProvider();
}
public FaceSettingsRemoveButtonPreferenceController(Context context) {
@@ -155,6 +160,7 @@
public void updateState(Preference preference) {
super.updateState(preference);
+ mPreference = preference;
mButton = ((LayoutPreference) preference)
.findViewById(R.id.security_settings_face_settings_remove_button);
mButton.setOnClickListener(this);
@@ -179,6 +185,7 @@
@Override
public void onClick(View v) {
if (v == mButton) {
+ mMetricsFeatureProvider.logClickedPreference(mPreference, getMetricsCategory());
mRemoving = true;
ConfirmRemoveDialog dialog = new ConfirmRemoveDialog();
dialog.setOnClickListener(mOnClickListener);
diff --git a/src/com/android/settings/deviceinfo/StorageDashboardFragment.java b/src/com/android/settings/deviceinfo/StorageDashboardFragment.java
index bbd87ab..10c3a43 100644
--- a/src/com/android/settings/deviceinfo/StorageDashboardFragment.java
+++ b/src/com/android/settings/deviceinfo/StorageDashboardFragment.java
@@ -63,7 +63,7 @@
implements
LoaderManager.LoaderCallbacks<SparseArray<StorageAsyncLoader.AppsStorageResult>> {
private static final String TAG = "StorageDashboardFrag";
- private static final String SUMMARY_PREF_KEY = "pref_summary";
+ private static final String SUMMARY_PREF_KEY = "storage_summary";
private static final int STORAGE_JOB_ID = 0;
private static final int ICON_JOB_ID = 1;
private static final int VOLUME_SIZE_JOB_ID = 2;
diff --git a/src/com/android/settings/deviceinfo/storage/StorageSummaryDonutPreference.java b/src/com/android/settings/deviceinfo/storage/StorageSummaryDonutPreference.java
index cf50596..caf5b4e 100644
--- a/src/com/android/settings/deviceinfo/storage/StorageSummaryDonutPreference.java
+++ b/src/com/android/settings/deviceinfo/storage/StorageSummaryDonutPreference.java
@@ -19,10 +19,7 @@
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.content.Intent;
-import android.graphics.Typeface;
import android.os.storage.StorageManager;
-import android.text.TextPaint;
-import android.text.style.StyleSpan;
import android.util.AttributeSet;
import android.view.View;
import android.widget.Button;
@@ -31,8 +28,10 @@
import androidx.preference.PreferenceViewHolder;
import com.android.settings.R;
+import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.widget.DonutView;
+import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
/**
* StorageSummaryDonutPreference is a preference which summarizes the used and remaining storage left
@@ -79,23 +78,14 @@
@Override
public void onClick(View v) {
if (v != null && R.id.deletion_helper_button == v.getId()) {
- Context context = getContext();
- FeatureFactory.getFactory(context).getMetricsFeatureProvider().action(
- context, SettingsEnums.STORAGE_FREE_UP_SPACE_NOW);
- Intent intent = new Intent(StorageManager.ACTION_MANAGE_STORAGE);
- getContext().startActivity(intent);
- }
- }
-
- private static class BoldLinkSpan extends StyleSpan {
- public BoldLinkSpan() {
- super(Typeface.BOLD);
- }
-
- @Override
- public void updateDrawState(TextPaint ds) {
- super.updateDrawState(ds);
- ds.setColor(ds.linkColor);
+ final Context context = getContext();
+ final MetricsFeatureProvider metricsFeatureProvider =
+ FeatureFactory.getFactory(context).getMetricsFeatureProvider();
+ metricsFeatureProvider.logClickedPreference(this,
+ getExtras().getInt(DashboardFragment.CATEGORY));
+ metricsFeatureProvider.action(context, SettingsEnums.STORAGE_FREE_UP_SPACE_NOW);
+ final Intent intent = new Intent(StorageManager.ACTION_MANAGE_STORAGE);
+ context.startActivity(intent);
}
}
}
diff --git a/src/com/android/settings/widget/MasterSwitchController.java b/src/com/android/settings/widget/MasterSwitchController.java
index 9159584..92e3884 100644
--- a/src/com/android/settings/widget/MasterSwitchController.java
+++ b/src/com/android/settings/widget/MasterSwitchController.java
@@ -18,7 +18,10 @@
import androidx.preference.Preference;
+import com.android.settings.dashboard.DashboardFragment;
+import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
+import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
/*
* The switch controller that is used to update the switch widget in the MasterSwitchPreference
@@ -28,9 +31,12 @@
Preference.OnPreferenceChangeListener {
private final MasterSwitchPreference mPreference;
+ private final MetricsFeatureProvider mMetricsFeatureProvider;
public MasterSwitchController(MasterSwitchPreference preference) {
mPreference = preference;
+ mMetricsFeatureProvider = FeatureFactory.getFactory(preference.getContext())
+ .getMetricsFeatureProvider();
}
@Override
@@ -65,7 +71,12 @@
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
if (mListener != null) {
- return mListener.onSwitchToggled((Boolean) newValue);
+ final boolean result = mListener.onSwitchToggled((Boolean) newValue);
+ if (result) {
+ mMetricsFeatureProvider.logClickedPreference(preference,
+ preference.getExtras().getInt(DashboardFragment.CATEGORY));
+ }
+ return result;
}
return false;
}
diff --git a/tests/robotests/src/com/android/settings/biometrics/face/FaceStatusPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/biometrics/face/FaceStatusPreferenceControllerTest.java
index ec924e5..2dfc347 100644
--- a/tests/robotests/src/com/android/settings/biometrics/face/FaceStatusPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/biometrics/face/FaceStatusPreferenceControllerTest.java
@@ -113,7 +113,6 @@
assertThat(mPreference.getSummary()).isEqualTo(
mContext.getString(R.string.security_settings_face_preference_summary_none));
assertThat(mPreference.isVisible()).isTrue();
- assertThat(mPreference.getOnPreferenceClickListener()).isNotNull();
}
@Test
@@ -129,6 +128,5 @@
assertThat(mPreference.getSummary()).isEqualTo(mContext.getResources()
.getString(R.string.security_settings_face_preference_summary));
assertThat(mPreference.isVisible()).isTrue();
- assertThat(mPreference.getOnPreferenceClickListener()).isNotNull();
}
}
diff --git a/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintStatusPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintStatusPreferenceControllerTest.java
index 18a05fd..14ca1f8 100644
--- a/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintStatusPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintStatusPreferenceControllerTest.java
@@ -115,7 +115,6 @@
assertThat(mPreference.getSummary()).isEqualTo(
mContext.getString(R.string.security_settings_fingerprint_preference_summary_none));
assertThat(mPreference.isVisible()).isTrue();
- assertThat(mPreference.getOnPreferenceClickListener()).isNotNull();
}
@Test
@@ -130,6 +129,5 @@
assertThat(mPreference.getSummary()).isEqualTo(mContext.getResources().getQuantityString(
R.plurals.security_settings_fingerprint_preference_summary, 1, 1));
assertThat(mPreference.isVisible()).isTrue();
- assertThat(mPreference.getOnPreferenceClickListener()).isNotNull();
}
}