Snap for 7620055 from 336d3e5501
to sc-release
Change-Id: I0b356dd36f14a87b93015aac6036a413d03091a1
This commit is contained in:
@@ -284,7 +284,7 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
|
|||||||
launchCredentialOnlyEnroll();
|
launchCredentialOnlyEnroll();
|
||||||
finish();
|
finish();
|
||||||
} else if (canUseFace && canUseFingerprint) {
|
} else if (canUseFace && canUseFingerprint) {
|
||||||
if (mParentalOptionsRequired && mGkPwHandle != null) {
|
if (mGkPwHandle != null) {
|
||||||
launchFaceAndFingerprintEnroll();
|
launchFaceAndFingerprintEnroll();
|
||||||
} else {
|
} else {
|
||||||
setOrConfirmCredentialsNow();
|
setOrConfirmCredentialsNow();
|
||||||
|
@@ -90,16 +90,15 @@ public class SubscriptionAnnotation {
|
|||||||
|
|
||||||
mOrderWithinList = subInfoIndex;
|
mOrderWithinList = subInfoIndex;
|
||||||
mType = mSubInfo.isEmbedded() ? TYPE_ESIM : TYPE_PSIM;
|
mType = mSubInfo.isEmbedded() ? TYPE_ESIM : TYPE_PSIM;
|
||||||
|
mIsExisted = true;
|
||||||
if (mType == TYPE_ESIM) {
|
if (mType == TYPE_ESIM) {
|
||||||
int cardId = mSubInfo.getCardId();
|
int cardId = mSubInfo.getCardId();
|
||||||
mIsExisted = eSimCardId.contains(cardId);
|
|
||||||
mIsActive = activeSimSlotIndexList.contains(mSubInfo.getSimSlotIndex());
|
mIsActive = activeSimSlotIndexList.contains(mSubInfo.getSimSlotIndex());
|
||||||
mIsAllowToDisplay = (cardId < 0) // always allow when eSIM not in slot
|
mIsAllowToDisplay = (cardId < 0) // always allow when eSIM not in slot
|
||||||
|| isDisplayAllowed(context);
|
|| isDisplayAllowed(context);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mIsExisted = true;
|
|
||||||
mIsActive = (mSubInfo.getSimSlotIndex() > SubscriptionManager.INVALID_SIM_SLOT_INDEX)
|
mIsActive = (mSubInfo.getSimSlotIndex() > SubscriptionManager.INVALID_SIM_SLOT_INDEX)
|
||||||
&& activeSimSlotIndexList.contains(mSubInfo.getSimSlotIndex());
|
&& activeSimSlotIndexList.contains(mSubInfo.getSimSlotIndex());
|
||||||
mIsAllowToDisplay = isDisplayAllowed(context);
|
mIsAllowToDisplay = isDisplayAllowed(context);
|
||||||
|
@@ -16,6 +16,7 @@
|
|||||||
package com.android.settings.network.helper;
|
package com.android.settings.network.helper;
|
||||||
|
|
||||||
import android.os.ParcelUuid;
|
import android.os.ParcelUuid;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import androidx.annotation.Keep;
|
import androidx.annotation.Keep;
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
@@ -44,9 +45,12 @@ import java.util.stream.Collectors;
|
|||||||
*/
|
*/
|
||||||
public class SubscriptionGrouping
|
public class SubscriptionGrouping
|
||||||
implements UnaryOperator<List<SubscriptionAnnotation>> {
|
implements UnaryOperator<List<SubscriptionAnnotation>> {
|
||||||
|
private static final String LOG_TAG = "SubscriptionGrouping";
|
||||||
|
|
||||||
// implementation of UnaryOperator
|
// implementation of UnaryOperator
|
||||||
public List<SubscriptionAnnotation> apply(List<SubscriptionAnnotation> listOfSubscriptions) {
|
public List<SubscriptionAnnotation> apply(List<SubscriptionAnnotation> listOfSubscriptions) {
|
||||||
|
Log.d(LOG_TAG, "Grouping " + listOfSubscriptions);
|
||||||
|
|
||||||
// group by GUID
|
// group by GUID
|
||||||
Map<ParcelUuid, List<SubscriptionAnnotation>> groupedSubInfoList =
|
Map<ParcelUuid, List<SubscriptionAnnotation>> groupedSubInfoList =
|
||||||
listOfSubscriptions.stream()
|
listOfSubscriptions.stream()
|
||||||
@@ -89,8 +93,8 @@ public class SubscriptionGrouping
|
|||||||
annoSelector = annoSelector
|
annoSelector = annoSelector
|
||||||
// eSIM in front of pSIM
|
// eSIM in front of pSIM
|
||||||
.thenComparingInt(anno -> -anno.getType())
|
.thenComparingInt(anno -> -anno.getType())
|
||||||
// subscription ID in reverse order
|
// maintain the ordering given within constructor
|
||||||
.thenComparingInt(anno -> -anno.getSubscriptionId());
|
.thenComparingInt(anno -> annoList.indexOf(anno));
|
||||||
return annoList.stream().sorted(annoSelector).findFirst().orElse(null);
|
return annoList.stream().sorted(annoSelector).findFirst().orElse(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -21,6 +21,8 @@ android_test {
|
|||||||
static_libs: [
|
static_libs: [
|
||||||
"truth-prebuilt",
|
"truth-prebuilt",
|
||||||
"androidx.test.core",
|
"androidx.test.core",
|
||||||
|
"androidx.test.espresso.core",
|
||||||
|
"androidx.test.espresso.intents-nodeps",
|
||||||
"androidx.test.runner",
|
"androidx.test.runner",
|
||||||
"androidx.test.rules",
|
"androidx.test.rules",
|
||||||
"androidx.test.ext.junit",
|
"androidx.test.ext.junit",
|
||||||
|
@@ -0,0 +1,137 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2021 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.biometrics;
|
||||||
|
|
||||||
|
import static android.provider.Settings.ACTION_BIOMETRIC_ENROLL;
|
||||||
|
|
||||||
|
import static androidx.test.espresso.intent.Intents.intended;
|
||||||
|
import static androidx.test.espresso.intent.matcher.IntentMatchers.hasComponent;
|
||||||
|
|
||||||
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
|
import static org.junit.Assume.assumeTrue;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.os.UserHandle;
|
||||||
|
|
||||||
|
import androidx.test.core.app.ActivityScenario;
|
||||||
|
import androidx.test.core.app.ApplicationProvider;
|
||||||
|
import androidx.test.espresso.intent.Intents;
|
||||||
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
|
import androidx.test.filters.MediumTest;
|
||||||
|
|
||||||
|
import com.android.internal.widget.LockPatternChecker;
|
||||||
|
import com.android.internal.widget.LockPatternUtils;
|
||||||
|
import com.android.internal.widget.LockscreenCredential;
|
||||||
|
import com.android.settings.biometrics.face.FaceEnrollIntroduction;
|
||||||
|
import com.android.settings.biometrics.fingerprint.FingerprintEnrollIntroduction;
|
||||||
|
import com.android.settings.password.ChooseLockGeneric;
|
||||||
|
import com.android.settings.password.ChooseLockSettingsHelper;
|
||||||
|
import com.android.settings.password.ConfirmLockPassword;
|
||||||
|
import com.android.settings.testutils.AdbUtils;
|
||||||
|
|
||||||
|
import org.junit.After;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
|
@RunWith(AndroidJUnit4.class)
|
||||||
|
@MediumTest
|
||||||
|
public class BiometricEnrollActivityTest {
|
||||||
|
|
||||||
|
private static final String TAG = "BiometricEnrollActivityTest";
|
||||||
|
private static final int ADB_TIMEOUT_MS = 5000;
|
||||||
|
private static final String TEST_PIN = "1234";
|
||||||
|
|
||||||
|
private final Context mContext = ApplicationProvider.getApplicationContext();
|
||||||
|
private boolean mHasFace;
|
||||||
|
private boolean mHasFingerprint;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setup() {
|
||||||
|
Intents.init();
|
||||||
|
final PackageManager pm = mContext.getPackageManager();
|
||||||
|
mHasFingerprint = pm.hasSystemFeature(PackageManager.FEATURE_FINGERPRINT);
|
||||||
|
mHasFace = pm.hasSystemFeature(PackageManager.FEATURE_FACE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
public void teardown() throws Exception {
|
||||||
|
Intents.release();
|
||||||
|
AdbUtils.checkStringInAdbCommandOutput(TAG, "locksettings clear --old " + TEST_PIN,
|
||||||
|
"", "", ADB_TIMEOUT_MS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void launchWithoutPin_setsPin() {
|
||||||
|
try (ActivityScenario<BiometricEnrollActivity> scenario =
|
||||||
|
ActivityScenario.launch(getIntent())) {
|
||||||
|
intended(hasComponent(ChooseLockGeneric.class.getName()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void launchWithPin_confirmsPin() throws Exception {
|
||||||
|
setPin();
|
||||||
|
try (ActivityScenario<BiometricEnrollActivity> scenario =
|
||||||
|
ActivityScenario.launch(getIntent())) {
|
||||||
|
intended(hasComponent(ConfirmLockPassword.InternalActivity.class.getName()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void launchWithPinAndPwHandle_confirmsPin() throws Exception {
|
||||||
|
assumeTrue(mHasFace || mHasFingerprint);
|
||||||
|
|
||||||
|
setPin();
|
||||||
|
final Intent intent = getIntent(true /* useInternal */);
|
||||||
|
LockPatternChecker.verifyCredential(new LockPatternUtils(mContext),
|
||||||
|
LockscreenCredential.createPin(TEST_PIN), UserHandle.myUserId(),
|
||||||
|
LockPatternUtils.VERIFY_FLAG_REQUEST_GK_PW_HANDLE, (response, timeoutMs) -> {
|
||||||
|
assertThat(response.containsGatekeeperPasswordHandle()).isTrue();
|
||||||
|
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_GK_PW_HANDLE,
|
||||||
|
response.getGatekeeperPasswordHandle());
|
||||||
|
}).get();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
try (ActivityScenario<BiometricEnrollActivity> scenario =
|
||||||
|
ActivityScenario.launch(intent)) {
|
||||||
|
intended(hasComponent(mHasFace
|
||||||
|
? FaceEnrollIntroduction.class.getName()
|
||||||
|
: FingerprintEnrollIntroduction.class.getName()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Intent getIntent() {
|
||||||
|
return getIntent(false /* useInternal */);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Intent getIntent(boolean useInternal) {
|
||||||
|
final Intent intent = new Intent(mContext, useInternal
|
||||||
|
? BiometricEnrollActivity.InternalActivity.class : BiometricEnrollActivity.class);
|
||||||
|
intent.setAction(ACTION_BIOMETRIC_ENROLL);
|
||||||
|
return intent;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void setPin() throws Exception {
|
||||||
|
assertThat(AdbUtils.checkStringInAdbCommandOutput(TAG, "locksettings set-pin " + TEST_PIN,
|
||||||
|
"Pin set to ", "'" + TEST_PIN + "'", ADB_TIMEOUT_MS)).isTrue();
|
||||||
|
}
|
||||||
|
}
|
@@ -68,7 +68,7 @@ public class SubscriptionGroupingTest {
|
|||||||
List<SubscriptionAnnotation> result = mTarget
|
List<SubscriptionAnnotation> result = mTarget
|
||||||
.apply(Arrays.asList(subAnno2, subAnno1, subAnno3));
|
.apply(Arrays.asList(subAnno2, subAnno1, subAnno3));
|
||||||
assertThat(result.size()).isEqualTo(1);
|
assertThat(result.size()).isEqualTo(1);
|
||||||
assertThat(result.get(0)).isEqualTo(subAnno3);
|
assertThat(result.get(0)).isEqualTo(subAnno1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Reference in New Issue
Block a user