Don't offer "None" lock type for work profiles.
"None" doesn't make sense for work profiles because it makes profile insecure even if primary user is secure. If the user wants to get rid of separate challenge, it will be offered in previous Settings page, "Use one lock", so this shouldn't cause any confusion. Test: atest tests/robotests/src/com/android/settings/password/ChooseLockGenericControllerTest.java Test: manual, tried setting personal an work challenges from Settings and via Intent. Bug: 33656033 Change-Id: I830b3e372c1fe200fc4e02d59e3c3805bac5f9bb
This commit is contained in:
@@ -72,13 +72,14 @@ public class ChooseLockGenericController {
|
|||||||
* Whether the given screen lock type should be visible in the given context.
|
* Whether the given screen lock type should be visible in the given context.
|
||||||
*/
|
*/
|
||||||
public boolean isScreenLockVisible(ScreenLockType type) {
|
public boolean isScreenLockVisible(ScreenLockType type) {
|
||||||
|
final boolean managedProfile = mUserId != UserHandle.myUserId();
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case NONE:
|
case NONE:
|
||||||
return !mContext.getResources().getBoolean(R.bool.config_hide_none_security_option);
|
return !mContext.getResources().getBoolean(R.bool.config_hide_none_security_option)
|
||||||
|
&& !managedProfile; // Profiles should use unified challenge instead.
|
||||||
case SWIPE:
|
case SWIPE:
|
||||||
return !mContext.getResources().getBoolean(R.bool.config_hide_swipe_security_option)
|
return !mContext.getResources().getBoolean(R.bool.config_hide_swipe_security_option)
|
||||||
// Swipe doesn't make sense for profiles.
|
&& !managedProfile; // Swipe doesn't make sense for profiles.
|
||||||
&& mUserId == UserHandle.myUserId();
|
|
||||||
case MANAGED:
|
case MANAGED:
|
||||||
return mManagedPasswordProvider.isManagedPasswordChoosable();
|
return mManagedPasswordProvider.isManagedPasswordChoosable();
|
||||||
}
|
}
|
||||||
|
@@ -88,10 +88,12 @@ public class ChooseLockGenericControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isScreenLockVisible_notCurrentUser_shouldHideSwipe() {
|
public void isScreenLockVisible_notCurrentUser_shouldHideInsecure() {
|
||||||
mController = new ChooseLockGenericController(application, 1 /* userId */);
|
mController = new ChooseLockGenericController(application, 1 /* userId */);
|
||||||
assertThat(mController.isScreenLockVisible(ScreenLockType.SWIPE)).named("SWIPE visible")
|
assertThat(mController.isScreenLockVisible(ScreenLockType.SWIPE)).named("SWIPE visible")
|
||||||
.isFalse();
|
.isFalse();
|
||||||
|
assertThat(mController.isScreenLockVisible(ScreenLockType.NONE)).named("NONE visible")
|
||||||
|
.isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Reference in New Issue
Block a user