Snap for 7956453 from 1df187a439
to sc-v2-release
Change-Id: Ib48d9be03464533806eb58c7fd1847e84b149bb7
This commit is contained in:
@@ -32,6 +32,7 @@ import android.hardware.biometrics.BiometricAuthenticator;
|
||||
import android.hardware.biometrics.BiometricManager;
|
||||
import android.hardware.biometrics.BiometricManager.Authenticators;
|
||||
import android.hardware.biometrics.BiometricManager.BiometricError;
|
||||
import android.hardware.biometrics.SensorProperties;
|
||||
import android.hardware.face.FaceManager;
|
||||
import android.hardware.face.FaceSensorPropertiesInternal;
|
||||
import android.hardware.fingerprint.FingerprintManager;
|
||||
@@ -175,8 +176,22 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
|
||||
mHasFeatureFingerprint = pm.hasSystemFeature(PackageManager.FEATURE_FINGERPRINT);
|
||||
mHasFeatureFace = pm.hasSystemFeature(PackageManager.FEATURE_FACE);
|
||||
|
||||
// Default behavior is to enroll BIOMETRIC_WEAK or above. See ACTION_BIOMETRIC_ENROLL.
|
||||
final int authenticators = getIntent().getIntExtra(
|
||||
EXTRA_BIOMETRIC_AUTHENTICATORS_ALLOWED, Authenticators.BIOMETRIC_WEAK);
|
||||
Log.d(TAG, "Authenticators: " + authenticators);
|
||||
|
||||
mParentalOptionsRequired = intent.getBooleanExtra(EXTRA_REQUIRE_PARENTAL_CONSENT, false);
|
||||
mSkipReturnToParent = intent.getBooleanExtra(EXTRA_SKIP_RETURN_TO_PARENT, false);
|
||||
|
||||
// determine what can be enrolled
|
||||
final boolean isSetupWizard = WizardManagerHelper.isAnySetupWizard(getIntent());
|
||||
final boolean isMultiSensor = mHasFeatureFace && mHasFeatureFingerprint;
|
||||
|
||||
Log.d(TAG, "parentalOptionsRequired: " + mParentalOptionsRequired
|
||||
+ ", skipReturnToParent: " + mSkipReturnToParent
|
||||
+ ", isSetupWizard: " + isSetupWizard
|
||||
+ ", isMultiSensor: " + isMultiSensor);
|
||||
|
||||
if (mHasFeatureFace) {
|
||||
final FaceManager faceManager = getSystemService(FaceManager.class);
|
||||
@@ -185,11 +200,23 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
|
||||
final int maxFacesEnrollableIfSUW = getApplicationContext().getResources()
|
||||
.getInteger(R.integer.suw_max_faces_enrollable);
|
||||
if (!faceProperties.isEmpty()) {
|
||||
final FaceSensorPropertiesInternal props = faceProperties.get(0);
|
||||
final int maxEnrolls =
|
||||
isSetupWizard ? maxFacesEnrollableIfSUW
|
||||
: faceProperties.get(0).maxEnrollmentsPerUser;
|
||||
isSetupWizard ? maxFacesEnrollableIfSUW : props.maxEnrollmentsPerUser;
|
||||
mIsFaceEnrollable =
|
||||
faceManager.getEnrolledFaces(mUserId).size() < maxEnrolls;
|
||||
|
||||
// exclude face enrollment from setup wizard if configured as a convenience
|
||||
// isSetupWizard is always false for unicorn enrollment, so if consent is
|
||||
// required check if setup has completed instead.
|
||||
final boolean isSettingUp = isSetupWizard || (mParentalOptionsRequired
|
||||
&& !WizardManagerHelper.isUserSetupComplete(this));
|
||||
if (isSettingUp && isMultiSensor && mIsFaceEnrollable) {
|
||||
if (props.sensorStrength == SensorProperties.STRENGTH_CONVENIENCE) {
|
||||
Log.i(TAG, "Excluding face from SuW enrollment (STRENGTH_CONVENIENCE)");
|
||||
mIsFaceEnrollable = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mHasFeatureFingerprint) {
|
||||
@@ -207,13 +234,6 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
|
||||
}
|
||||
}
|
||||
|
||||
mParentalOptionsRequired = intent.getBooleanExtra(EXTRA_REQUIRE_PARENTAL_CONSENT, false);
|
||||
mSkipReturnToParent = intent.getBooleanExtra(EXTRA_SKIP_RETURN_TO_PARENT, false);
|
||||
|
||||
Log.d(TAG, "parentalOptionsRequired: " + mParentalOptionsRequired
|
||||
+ ", skipReturnToParent: " + mSkipReturnToParent
|
||||
+ ", isSetupWizard: " + isSetupWizard);
|
||||
|
||||
// TODO(b/195128094): remove this restriction
|
||||
// Consent can only be recorded when this activity is launched directly from the kids
|
||||
// module. This can be removed when there is a way to notify consent status out of band.
|
||||
@@ -247,19 +267,10 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
|
||||
setOrConfirmCredentialsNow();
|
||||
} else {
|
||||
// Start enrollment process if we haven't bailed out yet
|
||||
startEnroll();
|
||||
startEnrollWith(authenticators, isSetupWizard);
|
||||
}
|
||||
}
|
||||
|
||||
private void startEnroll() {
|
||||
// Default behavior is to enroll BIOMETRIC_WEAK or above. See ACTION_BIOMETRIC_ENROLL.
|
||||
final int authenticators = getIntent().getIntExtra(
|
||||
EXTRA_BIOMETRIC_AUTHENTICATORS_ALLOWED, Authenticators.BIOMETRIC_WEAK);
|
||||
Log.d(TAG, "Authenticators: " + authenticators);
|
||||
|
||||
startEnrollWith(authenticators, WizardManagerHelper.isAnySetupWizard(getIntent()));
|
||||
}
|
||||
|
||||
private void startEnrollWith(@Authenticators.Types int authenticators, boolean setupWizard) {
|
||||
// If the caller is not setup wizard, and the user has something enrolled, finish.
|
||||
// Allow parental consent flow to skip this check, since one modality could be consented
|
||||
@@ -339,7 +350,9 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
|
||||
final boolean fpConsentRequired = ParentalControlsUtils
|
||||
.parentConsentRequired(this, BiometricAuthenticator.TYPE_FINGERPRINT) != null;
|
||||
|
||||
final boolean requestFaceConsent = faceConsentRequired && mHasFeatureFace;
|
||||
final boolean requestFaceConsent = faceConsentRequired
|
||||
&& mHasFeatureFace
|
||||
&& mIsFaceEnrollable;
|
||||
final boolean requestFpConsent = fpConsentRequired && mHasFeatureFingerprint;
|
||||
|
||||
Log.d(TAG, "faceConsentRequired: " + faceConsentRequired
|
||||
|
@@ -94,6 +94,7 @@ public class SubscriptionsPreferenceController extends AbstractPreferenceControl
|
||||
private SignalStrengthListener mSignalStrengthListener;
|
||||
private TelephonyDisplayInfoListener mTelephonyDisplayInfoListener;
|
||||
private WifiPickerTrackerHelper mWifiPickerTrackerHelper;
|
||||
private final WifiManager mWifiManager;
|
||||
|
||||
@VisibleForTesting
|
||||
final BroadcastReceiver mConnectionChangeReceiver = new BroadcastReceiver() {
|
||||
@@ -150,6 +151,7 @@ public class SubscriptionsPreferenceController extends AbstractPreferenceControl
|
||||
mStartOrder = startOrder;
|
||||
mTelephonyManager = context.getSystemService(TelephonyManager.class);
|
||||
mSubscriptionManager = context.getSystemService(SubscriptionManager.class);
|
||||
mWifiManager = context.getSystemService(WifiManager.class);
|
||||
mSubscriptionPreferences = new ArrayMap<>();
|
||||
mSubscriptionsListener = new SubscriptionsChangeListener(context, this);
|
||||
mDataEnabledListener = new MobileDataEnabledListener(context, this);
|
||||
@@ -271,9 +273,7 @@ public class SubscriptionsPreferenceController extends AbstractPreferenceControl
|
||||
final boolean isDataInService = (regInfo == null)
|
||||
? false
|
||||
: regInfo.isRegistered();
|
||||
final boolean isCarrierNetworkActive =
|
||||
(mWifiPickerTrackerHelper != null)
|
||||
&& mWifiPickerTrackerHelper.isCarrierNetworkActive();
|
||||
final boolean isCarrierNetworkActive = isCarrierNetworkActive();
|
||||
String result = mSubsPrefCtrlInjector.getNetworkType(
|
||||
mContext, mConfig, mTelephonyDisplayInfo, subId, isCarrierNetworkActive);
|
||||
if (mSubsPrefCtrlInjector.isActiveCellularNetwork(mContext) || isCarrierNetworkActive) {
|
||||
@@ -291,20 +291,15 @@ public class SubscriptionsPreferenceController extends AbstractPreferenceControl
|
||||
final SignalStrength strength = tmForSubId.getSignalStrength();
|
||||
int level = (strength == null) ? 0 : strength.getLevel();
|
||||
int numLevels = SignalStrength.NUM_SIGNAL_STRENGTH_BINS;
|
||||
if (shouldInflateSignalStrength(subId)) {
|
||||
level += 1;
|
||||
boolean isCarrierNetworkActive = isCarrierNetworkActive();
|
||||
if (shouldInflateSignalStrength(subId) || isCarrierNetworkActive) {
|
||||
level = isCarrierNetworkActive
|
||||
? SignalStrength.NUM_SIGNAL_STRENGTH_BINS
|
||||
: (level + 1);
|
||||
numLevels += 1;
|
||||
}
|
||||
|
||||
Drawable icon = mSubsPrefCtrlInjector.getIcon(mContext, level, numLevels,
|
||||
!mTelephonyManager.isDataEnabled());
|
||||
final boolean isActiveCellularNetwork =
|
||||
mSubsPrefCtrlInjector.isActiveCellularNetwork(mContext);
|
||||
if (isActiveCellularNetwork || (mWifiPickerTrackerHelper != null)
|
||||
&& mWifiPickerTrackerHelper.isCarrierNetworkActive()) {
|
||||
icon.setTint(Utils.getColorAccentDefaultColor(mContext));
|
||||
return icon;
|
||||
}
|
||||
Drawable icon = mContext.getDrawable(R.drawable.ic_signal_strength_zero_bar_no_internet);
|
||||
|
||||
final ServiceState serviceState = tmForSubId.getServiceState();
|
||||
final NetworkRegistrationInfo regInfo = (serviceState == null)
|
||||
@@ -319,11 +314,17 @@ public class SubscriptionsPreferenceController extends AbstractPreferenceControl
|
||||
final boolean isVoiceInService = (serviceState == null)
|
||||
? false
|
||||
: (serviceState.getState() == ServiceState.STATE_IN_SERVICE);
|
||||
if (isDataInService || isVoiceInService) {
|
||||
return icon;
|
||||
if (isDataInService || isVoiceInService || isCarrierNetworkActive) {
|
||||
icon = mSubsPrefCtrlInjector.getIcon(mContext, level, numLevels,
|
||||
!mTelephonyManager.isDataEnabled());
|
||||
}
|
||||
|
||||
final boolean isActiveCellularNetwork =
|
||||
mSubsPrefCtrlInjector.isActiveCellularNetwork(mContext);
|
||||
if (isActiveCellularNetwork || isCarrierNetworkActive) {
|
||||
icon.setTint(Utils.getColorAccentDefaultColor(mContext));
|
||||
}
|
||||
|
||||
icon = mContext.getDrawable(R.drawable.ic_signal_strength_zero_bar_no_internet);
|
||||
return icon;
|
||||
}
|
||||
|
||||
@@ -417,7 +418,8 @@ public class SubscriptionsPreferenceController extends AbstractPreferenceControl
|
||||
*/
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
if (mSubscriptionsListener.isAirplaneModeOn()) {
|
||||
if (mSubscriptionsListener.isAirplaneModeOn()
|
||||
&& (!mWifiManager.isWifiEnabled() || !isCarrierNetworkActive())) {
|
||||
return false;
|
||||
}
|
||||
List<SubscriptionInfo> subInfoList =
|
||||
@@ -425,6 +427,7 @@ public class SubscriptionsPreferenceController extends AbstractPreferenceControl
|
||||
if (subInfoList == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return subInfoList.stream()
|
||||
// Avoid from showing subscription(SIM)s which has been marked as hidden
|
||||
// For example, only one subscription will be shown when there're multiple
|
||||
@@ -495,6 +498,11 @@ public class SubscriptionsPreferenceController extends AbstractPreferenceControl
|
||||
return new SubsPrefCtrlInjector();
|
||||
}
|
||||
|
||||
boolean isCarrierNetworkActive() {
|
||||
return mWifiPickerTrackerHelper != null
|
||||
&& mWifiPickerTrackerHelper.isCarrierNetworkActive();
|
||||
}
|
||||
|
||||
/**
|
||||
* To inject necessary data from each static api.
|
||||
*/
|
||||
|
@@ -39,6 +39,7 @@ import android.graphics.drawable.Drawable;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.Network;
|
||||
import android.net.NetworkCapabilities;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.Looper;
|
||||
import android.os.UserManager;
|
||||
import android.provider.Settings;
|
||||
@@ -102,6 +103,8 @@ public class SubscriptionsPreferenceControllerTest {
|
||||
private LifecycleOwner mLifecycleOwner;
|
||||
@Mock
|
||||
private WifiPickerTrackerHelper mWifiPickerTrackerHelper;
|
||||
@Mock
|
||||
private WifiManager mWifiManager;
|
||||
|
||||
private LifecycleRegistry mLifecycleRegistry;
|
||||
private int mOnChildUpdatedCount;
|
||||
@@ -132,6 +135,7 @@ public class SubscriptionsPreferenceControllerTest {
|
||||
when(mConnectivityManager.getNetworkCapabilities(mActiveNetwork))
|
||||
.thenReturn(mNetworkCapabilities);
|
||||
when(mUserManager.isAdminUser()).thenReturn(true);
|
||||
when(mContext.getSystemService(WifiManager.class)).thenReturn(mWifiManager);
|
||||
when(mLifecycleOwner.getLifecycle()).thenReturn(mLifecycleRegistry);
|
||||
|
||||
mPreferenceManager = new PreferenceManager(mContext);
|
||||
@@ -171,16 +175,55 @@ public class SubscriptionsPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isAvailable_airplaneModeOn_availableFalse() {
|
||||
public void isAvailable_airplaneModeOnWifiOff_availableFalse() {
|
||||
setupMockSubscriptions(2);
|
||||
|
||||
assertThat(mController.isAvailable()).isTrue();
|
||||
when(mWifiManager.isWifiEnabled()).thenReturn(false);
|
||||
|
||||
Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON, 1);
|
||||
|
||||
assertThat(mController.isAvailable()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isAvailable_airplaneModeOnWifiOnWithNoCarrierNetwork_availableFalse() {
|
||||
setupMockSubscriptions(2);
|
||||
|
||||
assertThat(mController.isAvailable()).isTrue();
|
||||
when(mWifiManager.isWifiEnabled()).thenReturn(true);
|
||||
doReturn(false).when(mWifiPickerTrackerHelper).isCarrierNetworkActive();
|
||||
|
||||
Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON, 1);
|
||||
|
||||
assertThat(mController.isAvailable()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isAvailable_airplaneModeOnWifiOffWithCarrierNetwork_availableTrue() {
|
||||
setupMockSubscriptions(1);
|
||||
|
||||
when(mWifiManager.isWifiEnabled()).thenReturn(false);
|
||||
doReturn(true).when(mWifiPickerTrackerHelper).isCarrierNetworkActive();
|
||||
|
||||
Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON, 1);
|
||||
|
||||
assertThat(mController.isAvailable()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isAvailable_airplaneModeOff_availableFalse() {
|
||||
setupMockSubscriptions(2);
|
||||
|
||||
assertThat(mController.isAvailable()).isTrue();
|
||||
when(mWifiManager.isWifiEnabled()).thenReturn(true);
|
||||
doReturn(true).when(mWifiPickerTrackerHelper).isCarrierNetworkActive();
|
||||
|
||||
Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON, 0);
|
||||
|
||||
assertThat(mController.isAvailable()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThreadTest
|
||||
public void displayPreference_providerAndHasSim_showPreference() {
|
||||
|
Reference in New Issue
Block a user