Update text when Active Unlock is enabled.

Update the security summary, intro, and unlock your phone summary when
Active Unlock is enabled and enrolled on the device.

Test: make RunSettingsRoboTests
Test: manually flip flags, confirm combined page has updated strings
Bug: 264812018
Change-Id: I2843e9f3aa0f38a9f2ebb18d60fed6293f9ce36e
This commit is contained in:
Derek Jedral
2023-01-24 22:00:01 -08:00
parent 334e48f4ff
commit 9134f24f31
7 changed files with 288 additions and 5 deletions

View File

@@ -17,8 +17,15 @@ package com.android.settings.biometrics.combination;
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.os.Bundle;
import androidx.annotation.Nullable;
import androidx.preference.Preference;
import com.android.settings.R;
import com.android.settings.biometrics.activeunlock.ActiveUnlockContentListener.OnContentChangedListener;
import com.android.settings.biometrics.activeunlock.ActiveUnlockDeviceNameListener;
import com.android.settings.biometrics.activeunlock.ActiveUnlockStatusUtils;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settingslib.search.SearchIndexable;
@@ -32,6 +39,10 @@ public class CombinedBiometricSettings extends BiometricsSettingsBase {
private static final String KEY_FINGERPRINT_SETTINGS = "biometric_fingerprint_settings";
private static final String KEY_UNLOCK_PHONE = "biometric_settings_biometric_keyguard";
private static final String KEY_USE_IN_APPS = "biometric_settings_biometric_app";
private static final String KEY_INTRO_PREFERENCE = "biometric_intro";
private ActiveUnlockStatusUtils mActiveUnlockStatusUtils;
@Nullable private ActiveUnlockDeviceNameListener mActiveUnlockDeviceNameListener;
@Override
public void onAttach(Context context) {
@@ -40,6 +51,41 @@ public class CombinedBiometricSettings extends BiometricsSettingsBase {
use(BiometricSettingsAppPreferenceController.class).setUserId(mUserId);
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mActiveUnlockStatusUtils = new ActiveUnlockStatusUtils(getActivity());
if (mActiveUnlockStatusUtils.isAvailable()) {
updateUiForActiveUnlock();
}
}
private void updateUiForActiveUnlock() {
OnContentChangedListener listener = new OnContentChangedListener() {
@Override
public void onContentChanged(String newValue) {
updateUnlockPhonePreferenceSummary();
}
};
mActiveUnlockDeviceNameListener =
new ActiveUnlockDeviceNameListener(getActivity(), listener);
mActiveUnlockDeviceNameListener.subscribe();
final Preference introPreference = findPreference(KEY_INTRO_PREFERENCE);
if (introPreference != null) {
introPreference.setTitle(mActiveUnlockStatusUtils.getIntroForActiveUnlock());
}
getActivity().setTitle(mActiveUnlockStatusUtils.getTitleForActiveUnlock());
}
@Override
public void onDestroy() {
if (mActiveUnlockDeviceNameListener != null) {
mActiveUnlockDeviceNameListener.unsubscribe();
}
super.onDestroy();
}
@Override
protected int getPreferenceScreenResId() {
return R.xml.security_settings_combined_biometric;
@@ -75,6 +121,16 @@ public class CombinedBiometricSettings extends BiometricsSettingsBase {
return SettingsEnums.COMBINED_BIOMETRIC;
}
@Override
protected String getUseAnyBiometricSummary() {
// either Active Unlock is not enabled or no device is enrolled.
if (mActiveUnlockDeviceNameListener == null
|| !mActiveUnlockDeviceNameListener.hasEnrolled()) {
return super.getUseAnyBiometricSummary();
}
return mActiveUnlockStatusUtils.getUnlockDeviceSummaryForActiveUnlock();
}
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new CombinedBiometricSearchIndexProvider(R.xml.security_settings_combined_biometric);
}