Merge "Allow setting password during provisioning if FRP is not supported" into rvc-dev

This commit is contained in:
Rubin Xu
2020-05-29 10:44:18 +00:00
committed by Android (Google) Code Review
3 changed files with 16 additions and 44 deletions

View File

@@ -297,7 +297,8 @@ public class ChooseLockGeneric extends SettingsActivity {
getSystemService(Context.PERSISTENT_DATA_BLOCK_SERVICE);
// Can only run during setup if factory reset protection has already been cleared
return (pdbm != null && pdbm.getDataBlockSize() == 0);
// or if the device does not support FRP.
return (pdbm == null || pdbm.getDataBlockSize() == 0);
}
protected Class<? extends ChooseLockGeneric.InternalActivity> getInternalActivityClass() {

View File

@@ -34,6 +34,7 @@ import static org.robolectric.Shadows.shadowOf;
import android.app.Activity;
import android.app.admin.DevicePolicyManager;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.provider.Settings.Global;
@@ -48,7 +49,6 @@ import com.android.settings.biometrics.BiometricEnrollBase;
import com.android.settings.password.ChooseLockGeneric.ChooseLockGenericFragment;
import com.android.settings.search.SearchFeatureProvider;
import com.android.settings.testutils.shadow.ShadowLockPatternUtils;
import com.android.settings.testutils.shadow.ShadowPersistentDataBlockManager;
import com.android.settings.testutils.shadow.ShadowStorageManager;
import com.android.settings.testutils.shadow.ShadowUserManager;
import com.android.settings.testutils.shadow.ShadowUtils;
@@ -62,6 +62,8 @@ import org.junit.runner.RunWith;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowApplication;
import org.robolectric.shadows.ShadowPersistentDataBlockManager;
@RunWith(RobolectricTestRunner.class)
@Config(
@@ -99,6 +101,17 @@ public class ChooseLockGenericTest {
assertThat(mActivity.isFinishing()).isTrue();
}
@Test
public void onCreate_deviceNotProvisioned_persistentDataServiceNotAvailable_shouldNotFinish() {
Global.putInt(application.getContentResolver(), Global.DEVICE_PROVISIONED, 0);
ShadowPersistentDataBlockManager.setDataBlockSize(1000);
ShadowApplication.getInstance().setSystemService(Context.PERSISTENT_DATA_BLOCK_SERVICE,
null);
initActivity(null);
assertThat(mActivity.isFinishing()).isFalse();
}
@Test
public void onActivityResult_nullIntentData_shouldNotCrash() {
initActivity(null);

View File

@@ -1,42 +0,0 @@
/*
* Copyright (C) 2020 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.testutils.shadow;
import android.service.persistentdata.PersistentDataBlockManager;
import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;
import org.robolectric.annotation.Resetter;
@Implements(PersistentDataBlockManager.class)
public class ShadowPersistentDataBlockManager {
private static int sDataBlockSize = 0;
@Resetter
public static void reset() {
sDataBlockSize = 0;
}
@Implementation
protected int getDataBlockSize() {
return sDataBlockSize;
}
public static void setDataBlockSize(int dataBlockSize) {
sDataBlockSize = dataBlockSize;
}
}