Add metrics for biometric onboarding & education
Log the stats for the new changed buttons Bug: 370940762 Test: atest FaceSettingsAppsPreferenceControllerTest FaceSettingsKeyguardUnlockPreferenceControllerTest FingerprintSettingsAppsPreferenceControllerTest FingerprintSettingsKeyguardUnlockPreferenceControllerTest Flag: com.android.settings.flags.biometrics_onboarding_education Change-Id: Ic14ffc43457a71f1f70ace0479410b7449dcc539
This commit is contained in:
@@ -18,6 +18,7 @@ package com.android.settings.biometrics.face;
|
||||
|
||||
import static android.provider.Settings.Secure.FACE_APP_ENABLED;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.hardware.face.FaceManager;
|
||||
import android.provider.Settings;
|
||||
@@ -49,6 +50,8 @@ public class FaceSettingsAppsPreferenceController extends
|
||||
|
||||
@Override
|
||||
public boolean setChecked(boolean isChecked) {
|
||||
mMetricsFeatureProvider.action(mContext,
|
||||
SettingsEnums.ACTION_FACE_ENABLED_FOR_APP, isChecked);
|
||||
return Settings.Secure.putIntForUser(mContext.getContentResolver(), FACE_APP_ENABLED,
|
||||
isChecked ? ON : OFF, getUserId());
|
||||
}
|
||||
|
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.settings.biometrics.face;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.hardware.face.FaceManager;
|
||||
import android.provider.Settings;
|
||||
@@ -122,6 +123,8 @@ public class FaceSettingsAttentionPreferenceController extends FaceSettingsPrefe
|
||||
|
||||
@Override
|
||||
public boolean setChecked(boolean isChecked) {
|
||||
mMetricsFeatureProvider.action(mContext,
|
||||
SettingsEnums.ACTION_FACE_REQUIRE_ATTENTION_SETTINGS, isChecked);
|
||||
// Optimistically update state and set to disabled until we know it succeeded.
|
||||
mPreference.setEnabled(false);
|
||||
mPreference.setChecked(isChecked);
|
||||
|
@@ -18,6 +18,7 @@ package com.android.settings.biometrics.face;
|
||||
|
||||
import static android.provider.Settings.Secure.FACE_KEYGUARD_ENABLED;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.hardware.face.FaceManager;
|
||||
import android.provider.Settings;
|
||||
@@ -50,6 +51,8 @@ public class FaceSettingsKeyguardUnlockPreferenceController extends
|
||||
|
||||
@Override
|
||||
public boolean setChecked(boolean isChecked) {
|
||||
mMetricsFeatureProvider.action(mContext,
|
||||
SettingsEnums.ACTION_FACE_ENABLED_ON_KEYGUARD, isChecked);
|
||||
return Settings.Secure.putIntForUser(mContext.getContentResolver(),
|
||||
FACE_KEYGUARD_ENABLED, isChecked ? ON : OFF, getUserId());
|
||||
}
|
||||
|
@@ -20,8 +20,10 @@ import android.app.admin.DevicePolicyManager;
|
||||
import android.content.Context;
|
||||
|
||||
import com.android.settings.core.TogglePreferenceController;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
|
||||
import com.android.settingslib.RestrictedLockUtilsInternal;
|
||||
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||
|
||||
/**
|
||||
* Abstract base class for all face settings toggles.
|
||||
@@ -29,9 +31,11 @@ import com.android.settingslib.RestrictedLockUtilsInternal;
|
||||
public abstract class FaceSettingsPreferenceController extends TogglePreferenceController {
|
||||
|
||||
private int mUserId;
|
||||
protected MetricsFeatureProvider mMetricsFeatureProvider;
|
||||
|
||||
public FaceSettingsPreferenceController(Context context, String preferenceKey) {
|
||||
super(context, preferenceKey);
|
||||
mMetricsFeatureProvider = FeatureFactory.getFeatureFactory().getMetricsFeatureProvider();
|
||||
}
|
||||
|
||||
public void setUserId(int userId) {
|
||||
|
@@ -1716,6 +1716,10 @@ public class FingerprintSettings extends SubSettings {
|
||||
@Override
|
||||
public void onAuthenticationError(
|
||||
int errorCode, @NonNull CharSequence errString) {
|
||||
mMetricsFeatureProvider.action(
|
||||
getContext(),
|
||||
SettingsEnums.ACTION_CHECK_FINGERPRINT,
|
||||
false);
|
||||
dialog.dismiss();
|
||||
}
|
||||
|
||||
@@ -1726,6 +1730,10 @@ public class FingerprintSettings extends SubSettings {
|
||||
FingerprintSettingsFragment parent =
|
||||
(FingerprintSettingsFragment) getTargetFragment();
|
||||
parent.highlightFingerprintItem(fingerId);
|
||||
mMetricsFeatureProvider.action(
|
||||
getContext(),
|
||||
SettingsEnums.ACTION_CHECK_FINGERPRINT,
|
||||
true);
|
||||
dialog.dismiss();
|
||||
}
|
||||
|
||||
|
@@ -18,6 +18,7 @@ package com.android.settings.biometrics.fingerprint;
|
||||
|
||||
import static android.provider.Settings.Secure.FINGERPRINT_APP_ENABLED;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.hardware.fingerprint.FingerprintManager;
|
||||
import android.provider.Settings;
|
||||
@@ -50,6 +51,8 @@ public class FingerprintSettingsAppsPreferenceController
|
||||
|
||||
@Override
|
||||
public boolean setChecked(boolean isChecked) {
|
||||
mMetricsFeatureProvider.action(mContext,
|
||||
SettingsEnums.ACTION_FINGERPRINT_ENABLED_FOR_APP, isChecked);
|
||||
return Settings.Secure.putIntForUser(mContext.getContentResolver(), FINGERPRINT_APP_ENABLED,
|
||||
isChecked ? ON : OFF, getUserId());
|
||||
}
|
||||
|
@@ -18,6 +18,7 @@ package com.android.settings.biometrics.fingerprint;
|
||||
|
||||
import static android.provider.Settings.Secure.FINGERPRINT_KEYGUARD_ENABLED;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.hardware.fingerprint.FingerprintManager;
|
||||
import android.provider.Settings;
|
||||
@@ -51,6 +52,8 @@ public class FingerprintSettingsKeyguardUnlockPreferenceController
|
||||
|
||||
@Override
|
||||
public boolean setChecked(boolean isChecked) {
|
||||
mMetricsFeatureProvider.action(mContext,
|
||||
SettingsEnums.ACTION_FINGERPRINT_ENABLED_ON_KEYGUARD, isChecked);
|
||||
return Settings.Secure.putIntForUser(mContext.getContentResolver(),
|
||||
FINGERPRINT_KEYGUARD_ENABLED, isChecked ? ON : OFF, getUserId());
|
||||
}
|
||||
|
@@ -20,8 +20,10 @@ import android.app.admin.DevicePolicyManager;
|
||||
import android.content.Context;
|
||||
|
||||
import com.android.settings.core.TogglePreferenceController;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
|
||||
import com.android.settingslib.RestrictedLockUtilsInternal;
|
||||
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||
|
||||
/**
|
||||
* Abstract base class for all fingerprint settings toggles.
|
||||
@@ -29,9 +31,11 @@ import com.android.settingslib.RestrictedLockUtilsInternal;
|
||||
public abstract class FingerprintSettingsPreferenceController extends TogglePreferenceController {
|
||||
|
||||
private int mUserId;
|
||||
protected MetricsFeatureProvider mMetricsFeatureProvider;
|
||||
|
||||
public FingerprintSettingsPreferenceController(Context context, String preferenceKey) {
|
||||
super(context, preferenceKey);
|
||||
mMetricsFeatureProvider = FeatureFactory.getFeatureFactory().getMetricsFeatureProvider();
|
||||
}
|
||||
|
||||
public void setUserId(int userId) {
|
||||
|
@@ -18,11 +18,18 @@ package com.android.settings.biometrics.face;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -31,10 +38,12 @@ import org.junit.runner.RunWith;
|
||||
public class FaceSettingsAppsPreferenceControllerTest {
|
||||
private Context mContext;
|
||||
private FaceSettingsAppsPreferenceController mController;
|
||||
private FakeFeatureFactory mFeatureFactory;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
mContext = ApplicationProvider.getApplicationContext();
|
||||
mFeatureFactory = FakeFeatureFactory.setupForTest();
|
||||
mController = new FaceSettingsAppsPreferenceController(
|
||||
mContext, "biometric_settings_face_app");
|
||||
}
|
||||
@@ -43,4 +52,18 @@ public class FaceSettingsAppsPreferenceControllerTest {
|
||||
public void isSliceable_returnFalse() {
|
||||
assertThat(mController.isSliceable()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setChecked_checked_updateMetrics() {
|
||||
mController.setChecked(true);
|
||||
verify(mFeatureFactory.metricsFeatureProvider).action(any(),
|
||||
eq(SettingsEnums.ACTION_FACE_ENABLED_FOR_APP), eq(true));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setChecked_unchecked_updateMetrics() {
|
||||
mController.setChecked(false);
|
||||
verify(mFeatureFactory.metricsFeatureProvider).action(any(),
|
||||
eq(SettingsEnums.ACTION_FACE_ENABLED_FOR_APP), eq(false));
|
||||
}
|
||||
}
|
||||
|
@@ -18,11 +18,18 @@ package com.android.settings.biometrics.face;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -31,10 +38,12 @@ import org.junit.runner.RunWith;
|
||||
public class FaceSettingsKeyguardUnlockPreferenceControllerTest {
|
||||
private Context mContext;
|
||||
private FaceSettingsKeyguardUnlockPreferenceController mController;
|
||||
private FakeFeatureFactory mFeatureFactory;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
mContext = ApplicationProvider.getApplicationContext();
|
||||
mFeatureFactory = FakeFeatureFactory.setupForTest();
|
||||
mController = new FaceSettingsKeyguardUnlockPreferenceController(
|
||||
mContext, "biometric_settings_face_keyguard");
|
||||
}
|
||||
@@ -43,4 +52,18 @@ public class FaceSettingsKeyguardUnlockPreferenceControllerTest {
|
||||
public void isSliceable_returnFalse() {
|
||||
assertThat(mController.isSliceable()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setChecked_checked_updateMetrics() {
|
||||
mController.setChecked(true);
|
||||
verify(mFeatureFactory.metricsFeatureProvider).action(any(),
|
||||
eq(SettingsEnums.ACTION_FACE_ENABLED_ON_KEYGUARD), eq(true));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setChecked_unchecked_updateMetrics() {
|
||||
mController.setChecked(false);
|
||||
verify(mFeatureFactory.metricsFeatureProvider).action(any(),
|
||||
eq(SettingsEnums.ACTION_FACE_ENABLED_ON_KEYGUARD), eq(false));
|
||||
}
|
||||
}
|
||||
|
@@ -18,11 +18,18 @@ package com.android.settings.biometrics.fingerprint;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -31,10 +38,12 @@ import org.junit.runner.RunWith;
|
||||
public class FingerprintSettingsAppsPreferenceControllerTest {
|
||||
private Context mContext;
|
||||
private FingerprintSettingsAppsPreferenceController mController;
|
||||
private FakeFeatureFactory mFeatureFactory;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
mContext = ApplicationProvider.getApplicationContext();
|
||||
mFeatureFactory = FakeFeatureFactory.setupForTest();
|
||||
mController = new FingerprintSettingsAppsPreferenceController(
|
||||
mContext, "biometric_settings_fingerprint_app");
|
||||
}
|
||||
@@ -43,4 +52,18 @@ public class FingerprintSettingsAppsPreferenceControllerTest {
|
||||
public void isSliceable_returnFalse() {
|
||||
assertThat(mController.isSliceable()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setChecked_checked_updateMetrics() {
|
||||
mController.setChecked(true);
|
||||
verify(mFeatureFactory.metricsFeatureProvider).action(any(),
|
||||
eq(SettingsEnums.ACTION_FINGERPRINT_ENABLED_FOR_APP), eq(true));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setChecked_unchecked_updateMetrics() {
|
||||
mController.setChecked(false);
|
||||
verify(mFeatureFactory.metricsFeatureProvider).action(any(),
|
||||
eq(SettingsEnums.ACTION_FINGERPRINT_ENABLED_FOR_APP), eq(false));
|
||||
}
|
||||
}
|
||||
|
@@ -18,11 +18,18 @@ package com.android.settings.biometrics.fingerprint;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -31,10 +38,12 @@ import org.junit.runner.RunWith;
|
||||
public class FingerprintSettingsKeyguardUnlockPreferenceControllerTest {
|
||||
private Context mContext;
|
||||
private FingerprintSettingsKeyguardUnlockPreferenceController mController;
|
||||
private FakeFeatureFactory mFeatureFactory;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
mContext = ApplicationProvider.getApplicationContext();
|
||||
mFeatureFactory = FakeFeatureFactory.setupForTest();
|
||||
mController = new FingerprintSettingsKeyguardUnlockPreferenceController(
|
||||
mContext, "biometric_settings_fingerprint_keyguard");
|
||||
}
|
||||
@@ -43,4 +52,18 @@ public class FingerprintSettingsKeyguardUnlockPreferenceControllerTest {
|
||||
public void isSliceable_returnFalse() {
|
||||
assertThat(mController.isSliceable()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setChecked_checked_updateMetrics() {
|
||||
mController.setChecked(true);
|
||||
verify(mFeatureFactory.metricsFeatureProvider).action(any(),
|
||||
eq(SettingsEnums.ACTION_FINGERPRINT_ENABLED_ON_KEYGUARD), eq(true));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setChecked_unchecked_updateMetrics() {
|
||||
mController.setChecked(false);
|
||||
verify(mFeatureFactory.metricsFeatureProvider).action(any(),
|
||||
eq(SettingsEnums.ACTION_FINGERPRINT_ENABLED_ON_KEYGUARD), eq(false));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user