Merge "Fix crash if trying to erase the FRP data." into main
This commit is contained in:
@@ -89,8 +89,7 @@ public class MainClearConfirm extends InstrumentedFragment {
|
|||||||
final PersistentDataBlockManager pdbManager;
|
final PersistentDataBlockManager pdbManager;
|
||||||
// pre-flight check hardware support PersistentDataBlockManager
|
// pre-flight check hardware support PersistentDataBlockManager
|
||||||
if (!SystemProperties.get(PERSISTENT_DATA_BLOCK_PROP).equals("")) {
|
if (!SystemProperties.get(PERSISTENT_DATA_BLOCK_PROP).equals("")) {
|
||||||
pdbManager = (PersistentDataBlockManager)
|
pdbManager = getActivity().getSystemService(PersistentDataBlockManager.class);
|
||||||
getActivity().getSystemService(Context.PERSISTENT_DATA_BLOCK_SERVICE);
|
|
||||||
} else {
|
} else {
|
||||||
pdbManager = null;
|
pdbManager = null;
|
||||||
}
|
}
|
||||||
@@ -152,6 +151,11 @@ public class MainClearConfirm extends InstrumentedFragment {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Do not try to erase factory reset protection data if the protection is alive.
|
||||||
|
if (pdbManager.isFactoryResetProtectionActive()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// The persistent data block will persist if the device is still being provisioned.
|
// The persistent data block will persist if the device is still being provisioned.
|
||||||
if (isDeviceStillBeingProvisioned()) {
|
if (isDeviceStillBeingProvisioned()) {
|
||||||
return false;
|
return false;
|
||||||
|
@@ -77,6 +77,7 @@ public class MainClearConfirmTest {
|
|||||||
|
|
||||||
when(mMockActivity.getSystemService(Context.DEVICE_POLICY_SERVICE))
|
when(mMockActivity.getSystemService(Context.DEVICE_POLICY_SERVICE))
|
||||||
.thenReturn(mDevicePolicyManager);
|
.thenReturn(mDevicePolicyManager);
|
||||||
|
when(mPersistentDataBlockManager.isFactoryResetProtectionActive()).thenReturn(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -112,6 +113,13 @@ public class MainClearConfirmTest {
|
|||||||
assertThat(mMainClearConfirm.shouldWipePersistentDataBlock(null)).isFalse();
|
assertThat(mMainClearConfirm.shouldWipePersistentDataBlock(null)).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void shouldWipePersistentDataBlock_frpIsAlive_shouldReturnFalse() {
|
||||||
|
when(mPersistentDataBlockManager.isFactoryResetProtectionActive()).thenReturn(true);
|
||||||
|
assertThat(mMainClearConfirm.shouldWipePersistentDataBlock(mPersistentDataBlockManager))
|
||||||
|
.isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shouldWipePersistentDataBlock_deviceIsStillBeingProvisioned_shouldReturnFalse() {
|
public void shouldWipePersistentDataBlock_deviceIsStillBeingProvisioned_shouldReturnFalse() {
|
||||||
doReturn(true).when(mMainClearConfirm).isDeviceStillBeingProvisioned();
|
doReturn(true).when(mMainClearConfirm).isDeviceStillBeingProvisioned();
|
||||||
|
Reference in New Issue
Block a user