Remove duplicates in Security Settings
Duplicates: - Location - Scanning - Encryption and Credentials - Screen Pinning - Device Admin Apps Merge for ag/2247508 Bug: 33701673 Test: make RunSettingsRoboTests Change-Id: I91566b8fb7fdb3b39c8833a6fa8e52bbbf6507b6
This commit is contained in:
@@ -15,7 +15,8 @@
|
||||
-->
|
||||
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:title="@string/encryption_and_credential_settings_title">
|
||||
android:title="@string/encryption_and_credential_settings_title"
|
||||
android:key="encryption_and_credentials_screen">
|
||||
|
||||
<PreferenceCategory android:key="credentials_management"
|
||||
android:title="@string/credentials_title"
|
||||
|
@@ -15,7 +15,8 @@
|
||||
-->
|
||||
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:title="@string/location_scanning_screen_title">
|
||||
android:title="@string/location_scanning_screen_title"
|
||||
android:key="scanning_screen">
|
||||
|
||||
<SwitchPreference
|
||||
android:title="@string/location_scanning_wifi_always_scanning_title"
|
||||
|
@@ -106,6 +106,9 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
||||
private static final String KEY_UNIFICATION = "unification";
|
||||
@VisibleForTesting
|
||||
static final String KEY_LOCKSCREEN_PREFERENCES = "lockscreen_preferences";
|
||||
private static final String KEY_ENCRYPTION_AND_CREDENTIALS = "encryption_and_credential";
|
||||
private static final String KEY_LOCATION_SCANNING = "location_scanning";
|
||||
private static final String KEY_LOCATION = "location";
|
||||
|
||||
private static final int SET_OR_CHANGE_LOCK_METHOD_REQUEST = 123;
|
||||
private static final int CHANGE_TRUST_AGENT_SETTINGS = 126;
|
||||
@@ -939,7 +942,7 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
||||
|
||||
@Override
|
||||
public List<String> getNonIndexableKeys(Context context) {
|
||||
final List<String> keys = new ArrayList<String>();
|
||||
final List<String> keys = super.getNonIndexableKeys(context);
|
||||
|
||||
LockPatternUtils lockPatternUtils = new LockPatternUtils(context);
|
||||
|
||||
@@ -961,6 +964,14 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
||||
keys.add(KEY_ENTERPRISE_PRIVACY);
|
||||
}
|
||||
|
||||
// Duplicate in special app access
|
||||
keys.add(KEY_MANAGE_DEVICE_ADMIN);
|
||||
// Duplicates between parent-child
|
||||
keys.add(KEY_LOCATION);
|
||||
keys.add(KEY_ENCRYPTION_AND_CREDENTIALS);
|
||||
keys.add(KEY_SCREEN_PINNING);
|
||||
keys.add(KEY_LOCATION_SCANNING);
|
||||
|
||||
return keys;
|
||||
}
|
||||
}
|
||||
|
@@ -21,8 +21,7 @@ import android.content.Context;
|
||||
import android.content.IContentProvider;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.hardware.fingerprint.FingerprintManager;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.os.UserManager;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceGroup;
|
||||
import android.support.v7.preference.PreferenceScreen;
|
||||
@@ -31,33 +30,30 @@ import com.android.internal.widget.LockPatternUtils;
|
||||
import com.android.settings.dashboard.SummaryLoader;
|
||||
import com.android.settings.notification.LockScreenNotificationPreferenceController;
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
import com.android.settings.testutils.shadow.ShadowSecureSettings;
|
||||
import com.android.settings.testutils.XmlTestUtils;
|
||||
import com.android.settings.testutils.shadow.ShadowLockPatternUtils;
|
||||
import com.android.settingslib.drawer.DashboardCategory;
|
||||
import com.android.settingslib.drawer.Tile;
|
||||
import com.android.settingslib.drawer.TileUtils;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Answers;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.robolectric.annotation.Implementation;
|
||||
import org.robolectric.annotation.Implements;
|
||||
import org.robolectric.shadows.ShadowApplication;
|
||||
import org.robolectric.util.ReflectionHelpers;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.robolectric.util.ReflectionHelpers;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyInt;
|
||||
import static org.mockito.Matchers.isNull;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||
import static org.mockito.Mockito.when;
|
||||
@@ -182,4 +178,26 @@ public class SecuritySettingsTest {
|
||||
securitySettings.setLockscreenPreferencesSummary(group);
|
||||
verify(preference).setSummary(1234);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Config (shadows = {
|
||||
ShadowLockPatternUtils.class,
|
||||
})
|
||||
public void testNonIndexableKeys_existInXmlLayout() {
|
||||
final Context context = spy(RuntimeEnvironment.application);
|
||||
UserManager manager = mock(UserManager.class);
|
||||
when(manager.isAdminUser()).thenReturn(false);
|
||||
doReturn(manager).when(context).getSystemService(Context.USER_SERVICE);
|
||||
final List<String> niks = SecuritySettings.SEARCH_INDEX_DATA_PROVIDER
|
||||
.getNonIndexableKeys(context);
|
||||
|
||||
final List<String> keys = XmlTestUtils.getKeysFromPreferenceXml(context,
|
||||
R.xml.security_settings_misc);
|
||||
keys.addAll(XmlTestUtils.getKeysFromPreferenceXml(context,
|
||||
R.xml.location_settings));
|
||||
keys.addAll(XmlTestUtils.getKeysFromPreferenceXml(context,
|
||||
R.xml.encryption_and_credential));
|
||||
|
||||
assertThat(keys).containsAllIn(niks);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (C) 2017 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 com.android.internal.widget.LockPatternUtils;
|
||||
import org.robolectric.annotation.Implementation;
|
||||
import org.robolectric.annotation.Implements;
|
||||
|
||||
@Implements(LockPatternUtils.class)
|
||||
public class ShadowLockPatternUtils {
|
||||
|
||||
@Implementation
|
||||
public boolean isSecure(int id) {
|
||||
return true;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user