Merge "Allow setting password during provisioning if FRP is not supported" into rvc-dev
This commit is contained in:
@@ -297,7 +297,8 @@ public class ChooseLockGeneric extends SettingsActivity {
|
|||||||
getSystemService(Context.PERSISTENT_DATA_BLOCK_SERVICE);
|
getSystemService(Context.PERSISTENT_DATA_BLOCK_SERVICE);
|
||||||
|
|
||||||
// Can only run during setup if factory reset protection has already been cleared
|
// 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() {
|
protected Class<? extends ChooseLockGeneric.InternalActivity> getInternalActivityClass() {
|
||||||
|
@@ -34,6 +34,7 @@ import static org.robolectric.Shadows.shadowOf;
|
|||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.admin.DevicePolicyManager;
|
import android.app.admin.DevicePolicyManager;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.provider.Settings.Global;
|
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.password.ChooseLockGeneric.ChooseLockGenericFragment;
|
||||||
import com.android.settings.search.SearchFeatureProvider;
|
import com.android.settings.search.SearchFeatureProvider;
|
||||||
import com.android.settings.testutils.shadow.ShadowLockPatternUtils;
|
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.ShadowStorageManager;
|
||||||
import com.android.settings.testutils.shadow.ShadowUserManager;
|
import com.android.settings.testutils.shadow.ShadowUserManager;
|
||||||
import com.android.settings.testutils.shadow.ShadowUtils;
|
import com.android.settings.testutils.shadow.ShadowUtils;
|
||||||
@@ -62,6 +62,8 @@ import org.junit.runner.RunWith;
|
|||||||
import org.robolectric.Robolectric;
|
import org.robolectric.Robolectric;
|
||||||
import org.robolectric.RobolectricTestRunner;
|
import org.robolectric.RobolectricTestRunner;
|
||||||
import org.robolectric.annotation.Config;
|
import org.robolectric.annotation.Config;
|
||||||
|
import org.robolectric.shadows.ShadowApplication;
|
||||||
|
import org.robolectric.shadows.ShadowPersistentDataBlockManager;
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
@Config(
|
@Config(
|
||||||
@@ -99,6 +101,17 @@ public class ChooseLockGenericTest {
|
|||||||
assertThat(mActivity.isFinishing()).isTrue();
|
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
|
@Test
|
||||||
public void onActivityResult_nullIntentData_shouldNotCrash() {
|
public void onActivityResult_nullIntentData_shouldNotCrash() {
|
||||||
initActivity(null);
|
initActivity(null);
|
||||||
|
@@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
Reference in New Issue
Block a user