Merge "Remove LockdownButtonPreferenceController from java"
This commit is contained in:
committed by
Android (Google) Code Review
commit
2bc391bb09
@@ -19,8 +19,6 @@ package com.android.settings.security;
|
||||
import android.content.Context;
|
||||
import android.os.UserHandle;
|
||||
import android.provider.Settings;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.TwoStatePreference;
|
||||
|
||||
import com.android.internal.widget.LockPatternUtils;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
@@ -28,12 +26,10 @@ import com.android.settings.core.TogglePreferenceController;
|
||||
|
||||
public class LockdownButtonPreferenceController extends TogglePreferenceController {
|
||||
|
||||
private static final String KEY_LOCKDOWN_ENALBED = "security_setting_lockdown_enabled";
|
||||
|
||||
private final LockPatternUtils mLockPatternUtils;
|
||||
|
||||
public LockdownButtonPreferenceController(Context context) {
|
||||
super(context, KEY_LOCKDOWN_ENALBED);
|
||||
public LockdownButtonPreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
mLockPatternUtils = new LockPatternUtils(context);
|
||||
}
|
||||
|
||||
|
@@ -93,7 +93,6 @@ public class LockscreenDashboardFragment extends DashboardFragment
|
||||
mOwnerInfoPreferenceController =
|
||||
new OwnerInfoPreferenceController(context, this, lifecycle);
|
||||
controllers.add(mOwnerInfoPreferenceController);
|
||||
controllers.add(new LockdownButtonPreferenceController(context));
|
||||
|
||||
return controllers;
|
||||
}
|
||||
@@ -124,7 +123,6 @@ public class LockscreenDashboardFragment extends DashboardFragment
|
||||
KEY_ADD_USER_FROM_LOCK_SCREEN, null /* lifecycle */));
|
||||
controllers.add(new OwnerInfoPreferenceController(
|
||||
context, null /* fragment */, null /* lifecycle */));
|
||||
controllers.add(new LockdownButtonPreferenceController(context));
|
||||
return controllers;
|
||||
}
|
||||
|
||||
|
@@ -51,24 +51,24 @@ public class LockdownButtonPreferenceControllerTest {
|
||||
mContext = RuntimeEnvironment.application;
|
||||
mPreference = new SwitchPreference(mContext);
|
||||
|
||||
mController = spy(new LockdownButtonPreferenceController(mContext));
|
||||
mController = spy(new LockdownButtonPreferenceController(mContext, "TestKey"));
|
||||
ReflectionHelpers.setField(mController, "mLockPatternUtils", mLockPatternUtils);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isAvailable_lockSet_shouldReturnTrue() throws Exception {
|
||||
public void isAvailable_lockSet_shouldReturnTrue() {
|
||||
when(mLockPatternUtils.isSecure(anyInt())).thenReturn(true);
|
||||
assertThat(mController.isAvailable()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isAvailable_lockUnset_shouldReturnFalse() throws Exception {
|
||||
public void isAvailable_lockUnset_shouldReturnFalse() {
|
||||
when(mLockPatternUtils.isSecure(anyInt())).thenReturn(false);
|
||||
assertThat(mController.isAvailable()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onPreferenceChange_settingIsUpdated() throws Exception {
|
||||
public void onPreferenceChange_settingIsUpdated() {
|
||||
boolean state = Settings.Secure.getInt(mContext.getContentResolver(),
|
||||
Settings.Secure.LOCKDOWN_IN_POWER_MENU, 0) != 0;
|
||||
assertThat(mController.onPreferenceChange(mPreference, !state)).isTrue();
|
||||
@@ -78,7 +78,7 @@ public class LockdownButtonPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onSettingChange_preferenceIsUpdated() throws Exception {
|
||||
public void onSettingChange_preferenceIsUpdated() {
|
||||
boolean state = Settings.Secure.getInt(mContext.getContentResolver(),
|
||||
Settings.Secure.LOCKDOWN_IN_POWER_MENU, 0) != 0;
|
||||
mController.updateState(mPreference);
|
||||
|
Reference in New Issue
Block a user