Remove security settings v1 code
Change-Id: I958ed1588009b91f64cd8ecb98208e72a891903e
Fixes: 32953042
Test: robotests
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 2e51108..0ddaa06 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -1279,7 +1279,7 @@
android:value="true" />
</activity>
- <activity android:name="Settings$SecuritySettingsActivity"
+ <activity android:name=".Settings$SecurityDashboardActivity"
android:label="@string/security_settings_title"
android:icon="@drawable/ic_homepage_security"
android:configChanges="orientation|keyboardHidden|screenSize"
@@ -1306,28 +1306,6 @@
android:value="true" />
</activity>
- <!-- TODO(32953042) Merge with Settings$SecuritySettingsActivity -->
- <activity android:name="Settings$SecuritySettingsActivityV2"
- android:label="@string/security_settings_title"
- android:icon="@drawable/ic_homepage_security"
- android:enabled="false"
- android:configChanges="orientation|keyboardHidden|screenSize"
- android:taskAffinity=""
- android:parentActivityName="Settings">
- <intent-filter android:priority="-1">
- <action android:name="android.settings.SECURITY_SETTINGS" />
- <action android:name="android.credentials.UNLOCK" />
- <category android:name="android.intent.category.DEFAULT" />
- </intent-filter>
- <intent-filter android:priority="4">
- <action android:name="com.android.settings.action.SETTINGS" />
- </intent-filter>
- <meta-data android:name="com.android.settings.category"
- android:value="com.android.settings.category.ia.homepage" />
- <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
- android:value="com.android.settings.security.SecuritySettingsV2" />
- </activity>
-
<activity android:name="MonitoringCertInfoActivity"
android:label=""
android:theme="@style/Transparent"
@@ -1358,16 +1336,6 @@
android:value="true" />
</activity>
- <!-- Keep compatibility with old shortcuts. -->
- <activity-alias android:name="SecuritySettings"
- android:label="@string/security_settings_title"
- android:configChanges="orientation|keyboardHidden|screenSize"
- android:exported="true"
- android:targetActivity="Settings$SecuritySettingsActivity">
- <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
- android:value="com.android.settings.security.SecuritySettings" />
- </activity-alias>
-
<activity android:name="Settings$PrivacySettingsActivity"
android:label="@string/privacy_settings_title"
android:icon="@drawable/ic_settings_backup"
@@ -1405,7 +1373,7 @@
<activity android:name="Settings$DeviceAdminSettingsActivity"
android:label="@string/device_admin_settings_title"
android:taskAffinity="com.android.settings"
- android:parentActivityName="Settings$SecuritySettingsActivity">
+ android:parentActivityName=".Settings$SecurityDashboardActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
@@ -1436,7 +1404,7 @@
<activity android:name="Settings$UsageAccessSettingsActivity"
android:label="@string/usage_access_title"
android:taskAffinity="com.android.settings"
- android:parentActivityName="Settings$SecuritySettingsActivity">
+ android:parentActivityName=".Settings$SecurityDashboardActivity">
<intent-filter android:priority="1">
<action android:name="android.settings.USAGE_ACCESS_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
@@ -1574,7 +1542,7 @@
<activity android:name="Settings$EnterprisePrivacySettingsActivity"
android:label="@string/enterprise_privacy_settings"
android:taskAffinity="com.android.settings"
- android:parentActivityName="Settings$SecuritySettingsActivity">
+ android:parentActivityName=".Settings$SecurityDashboardActivity">
<intent-filter>
<action android:name="android.settings.ENTERPRISE_PRIVACY_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
diff --git a/res/xml/security_settings_v2.xml b/res/xml/security_dashboard_settings.xml
similarity index 100%
rename from res/xml/security_settings_v2.xml
rename to res/xml/security_dashboard_settings.xml
diff --git a/res/xml/security_settings.xml b/res/xml/security_settings.xml
deleted file mode 100644
index 31f2334..0000000
--- a/res/xml/security_settings.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2008 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.
--->
-
-<PreferenceScreen
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="security_dashboard_page"
- android:title="@string/security_settings_title"
- settings:initialExpandedChildrenCount="9">
-
-</PreferenceScreen>
diff --git a/res/xml/security_settings_chooser.xml b/res/xml/security_settings_chooser.xml
deleted file mode 100644
index 360e620..0000000
--- a/res/xml/security_settings_chooser.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2010 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.
--->
-
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="security_settings_chooser_screen"
- android:title="@string/security_settings_title">
-
- <PreferenceCategory
- android:key="security_category"
- android:title="@string/lock_settings_title">
-
- <com.android.settings.widget.GearPreference
- android:key="unlock_set_or_change"
- android:title="@string/unlock_set_unlock_launch_picker_title"
- android:summary="@string/unlock_set_unlock_mode_none"
- settings:keywords="@string/keywords_lockscreen"
- android:persistent="false"/>
-
- <Preference android:key="lockscreen_preferences"
- android:title="@string/lockscreen_settings_title"
- android:fragment="com.android.settings.security.LockscreenDashboardFragment"/>
-
- </PreferenceCategory>
-
-</PreferenceScreen>
diff --git a/res/xml/security_settings_lockscreen.xml b/res/xml/security_settings_lockscreen.xml
deleted file mode 100644
index 56410fb..0000000
--- a/res/xml/security_settings_lockscreen.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2010 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.
--->
-
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="security_settings_lockscreen_screen"
- android:title="@string/security_settings_title">
-
- <PreferenceCategory
- android:key="security_category"
- android:title="@string/lock_settings_title">
-
- <com.android.settingslib.RestrictedPreference
- android:key="unlock_set_or_change"
- android:title="@string/unlock_set_unlock_launch_picker_title"
- android:summary="@string/unlock_set_unlock_mode_off"
- settings:keywords="@string/keywords_lockscreen"
- android:persistent="false"/>
-
- </PreferenceCategory>
-
-</PreferenceScreen>
diff --git a/res/xml/security_settings_lockscreen_profile.xml b/res/xml/security_settings_lockscreen_profile.xml
deleted file mode 100644
index a0c3f02..0000000
--- a/res/xml/security_settings_lockscreen_profile.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2016 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.
--->
-
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="security_settings_lockscreen_profile_screen"
- android:title="@string/security_settings_title">
-
- <com.android.settingslib.RestrictedPreference
- android:key="unlock_set_or_change_profile"
- android:title="@string/unlock_set_unlock_launch_picker_title_profile"
- android:summary="@string/unlock_set_unlock_mode_off"
- settings:keywords="@string/keywords_lockscreen"
- android:persistent="false"/>
-
-</PreferenceScreen>
diff --git a/res/xml/security_settings_misc.xml b/res/xml/security_settings_misc.xml
deleted file mode 100644
index 730686c..0000000
--- a/res/xml/security_settings_misc.xml
+++ /dev/null
@@ -1,88 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2011 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.
--->
-
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
- android:key="security_settings_misc_screen"
- android:title="@string/security_settings_title">
-
- <PreferenceCategory
- android:key="security_settings_misc_category"
- android:title="@string/security_passwords_title">
-
- <Preference
- android:key="location"
- android:title="@string/location_settings_title"
- android:fragment="com.android.settings.location.LocationSettings">
- </Preference>
-
- <SwitchPreference
- android:key="show_password"
- android:title="@string/show_password"
- android:summary="@string/show_password_summary"/>
-
- </PreferenceCategory>
-
- <PreferenceCategory
- android:key="security_settings_device_admin_category">
-
- <Preference android:key="manage_device_admin"
- android:title="@string/manage_device_admin"
- android:persistent="false"
- android:fragment="com.android.settings.DeviceAdminSettings"/>
-
- <Preference android:key="enterprise_privacy"
- android:title="@string/enterprise_privacy_settings"
- android:persistent="false"
- android:fragment="com.android.settings.enterprise.EnterprisePrivacySettings"/>
-
- </PreferenceCategory>
-
- <Preference android:key="sim_lock_settings"
- android:title="@string/sim_lock_settings_category"
- android:persistent="false">
-
- <intent android:action="android.intent.action.MAIN"
- android:targetPackage="com.android.settings"
- android:targetClass="com.android.settings.Settings$IccLockSettingsActivity"/>
-
- </Preference>
-
- <Preference
- android:key="encryption_and_credential"
- android:title="@string/encryption_and_credential_settings_title"
- android:summary="@string/encryption_and_credential_settings_summary"
- android:fragment="com.android.settings.security.EncryptionAndCredential"/>
-
- <Preference android:key="manage_trust_agents"
- android:title="@string/manage_trust_agents"
- android:persistent="false"
- android:fragment="com.android.settings.security.trustagent.TrustAgentSettings"/>
-
- <Preference
- android:key="screen_pinning_settings"
- android:title="@string/screen_pinning_title"
- android:summary="@string/switch_off_text"
- android:fragment="com.android.settings.security.ScreenPinningSettings"/>
-
- <Preference android:key="security_misc_usage_access"
- android:title="@string/usage_access_title"
- android:fragment="com.android.settings.applications.manageapplications.ManageApplications">
- <extra
- android:name="classname"
- android:value="com.android.settings.Settings$UsageAccessSettingsActivity" />
- </Preference>
-
-</PreferenceScreen>
diff --git a/res/xml/security_settings_password.xml b/res/xml/security_settings_password.xml
deleted file mode 100644
index 26077c7..0000000
--- a/res/xml/security_settings_password.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2010 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.
--->
-
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="security_settings_password_screen"
- android:title="@string/lock_settings_picker_title">
-
- <PreferenceCategory
- android:key="security_category"
- android:title="@string/lock_settings_title">
-
- <com.android.settings.widget.GearPreference
- android:key="unlock_set_or_change"
- android:title="@string/unlock_set_unlock_launch_picker_title"
- android:summary="@string/unlock_set_unlock_mode_password"
- settings:keywords="@string/keywords_lockscreen" />
-
- <Preference android:key="lockscreen_preferences"
- android:title="@string/lockscreen_settings_title"
- android:fragment="com.android.settings.security.LockscreenDashboardFragment"/>
-
- </PreferenceCategory>
-
-</PreferenceScreen>
diff --git a/res/xml/security_settings_password_profile.xml b/res/xml/security_settings_password_profile.xml
deleted file mode 100644
index 257b234..0000000
--- a/res/xml/security_settings_password_profile.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2016 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.
--->
-
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="security_settings_password_profile_screen"
- android:title="@string/security_settings_title">
-
- <com.android.settingslib.RestrictedPreference
- android:key="unlock_set_or_change_profile"
- android:title="@string/unlock_set_unlock_launch_picker_title_profile"
- android:summary="@string/unlock_set_unlock_mode_password"
- settings:keywords="@string/keywords_lockscreen"
- android:persistent="false"/>
-
-</PreferenceScreen>
diff --git a/res/xml/security_settings_pattern.xml b/res/xml/security_settings_pattern.xml
deleted file mode 100644
index 9b7482f..0000000
--- a/res/xml/security_settings_pattern.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2010 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.
--->
-
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="security_settings_pattern_screen"
- android:title="@string/lock_settings_picker_title">
-
- <PreferenceCategory
- android:key="security_category"
- android:title="@string/lock_settings_title">
-
- <com.android.settings.widget.GearPreference
- android:key="unlock_set_or_change"
- android:title="@string/unlock_set_unlock_launch_picker_title"
- android:summary="@string/unlock_set_unlock_mode_pattern"
- settings:keywords="@string/keywords_lockscreen" />
-
- <Preference android:key="lockscreen_preferences"
- android:title="@string/lockscreen_settings_title"
- android:fragment="com.android.settings.security.LockscreenDashboardFragment"/>
-
- </PreferenceCategory>
-
-</PreferenceScreen>
diff --git a/res/xml/security_settings_pattern_profile.xml b/res/xml/security_settings_pattern_profile.xml
deleted file mode 100644
index e095486..0000000
--- a/res/xml/security_settings_pattern_profile.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2016 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.
--->
-
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="security_settings_pattern_profile_screen"
- android:title="@string/security_settings_title">
-
- <com.android.settingslib.RestrictedPreference
- android:key="unlock_set_or_change_profile"
- android:title="@string/unlock_set_unlock_launch_picker_title_profile"
- android:summary="@string/unlock_set_unlock_mode_pattern"
- settings:keywords="@string/keywords_lockscreen"
- android:persistent="false"/>
-
- <SwitchPreference
- android:key="visiblepattern_profile"
- android:title="@string/lockpattern_settings_enable_visible_pattern_title_profile"/>
-
-</PreferenceScreen>
diff --git a/res/xml/security_settings_pin.xml b/res/xml/security_settings_pin.xml
deleted file mode 100644
index 780ca19..0000000
--- a/res/xml/security_settings_pin.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2010 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.
--->
-
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:title="@string/lock_settings_picker_title">
-
- <PreferenceCategory
- android:key="security_category"
- android:title="@string/lock_settings_title">
-
- <com.android.settings.widget.GearPreference
- android:key="unlock_set_or_change"
- android:title="@string/unlock_set_unlock_launch_picker_title"
- android:summary="@string/unlock_set_unlock_mode_pin"
- settings:keywords="@string/keywords_lockscreen" />
-
- <Preference android:key="lockscreen_preferences"
- android:title="@string/lockscreen_settings_title"
- android:fragment="com.android.settings.security.LockscreenDashboardFragment"/>
-
- </PreferenceCategory>
-
-</PreferenceScreen>
diff --git a/res/xml/security_settings_pin_profile.xml b/res/xml/security_settings_pin_profile.xml
deleted file mode 100644
index 071b2f5..0000000
--- a/res/xml/security_settings_pin_profile.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2016 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.
--->
-
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="security_settings_pin_profile_screen"
- android:title="@string/security_settings_title">
-
- <com.android.settingslib.RestrictedPreference
- android:key="unlock_set_or_change_profile"
- android:title="@string/unlock_set_unlock_launch_picker_title_profile"
- android:summary="@string/unlock_set_unlock_mode_pin"
- settings:keywords="@string/keywords_lockscreen"
- android:persistent="false"/>
-
-</PreferenceScreen>
diff --git a/res/xml/security_settings_profile.xml b/res/xml/security_settings_profile.xml
deleted file mode 100644
index 9870e30..0000000
--- a/res/xml/security_settings_profile.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2016 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.
--->
-
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:title="@string/lock_settings_picker_title">
-
- <PreferenceCategory
- android:key="security_category_profile"
- android:title="@string/lock_settings_profile_title">
-
- </PreferenceCategory>
-
-</PreferenceScreen>
diff --git a/res/xml/security_settings_status.xml b/res/xml/security_settings_status.xml
deleted file mode 100644
index 06930f9..0000000
--- a/res/xml/security_settings_status.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- 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.
--->
-
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
- android:title="@string/security_settings_title">
-
- <PreferenceCategory
- android:key="security_status"
- android:title="@string/security_status_title"/>
-
-</PreferenceScreen>
diff --git a/res/xml/security_settings_unification.xml b/res/xml/security_settings_unification.xml
deleted file mode 100644
index b9c59e5..0000000
--- a/res/xml/security_settings_unification.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2016 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.
--->
-
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:title="@string/security_settings_title">
-
- <com.android.settingslib.RestrictedSwitchPreference
- android:key="unification"
- android:title="@string/lock_settings_profile_unification_title"
- android:summary="@string/lock_settings_profile_unification_summary"
- settings:keywords="@string/keywords_unification"/>
-
-</PreferenceScreen>
diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java
index 0b6fe89..b4908dd 100644
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -67,8 +67,7 @@
public static class AccessibilityInversionSettingsActivity extends SettingsActivity { /* empty */ }
public static class AccessibilityContrastSettingsActivity extends SettingsActivity { /* empty */ }
public static class AccessibilityDaltonizerSettingsActivity extends SettingsActivity { /* empty */ }
- public static class SecuritySettingsActivity extends SettingsActivity { /* empty */ }
- public static class SecuritySettingsActivityV2 extends SettingsActivity { /* empty */ }
+ public static class SecurityDashboardActivity extends SettingsActivity { /* empty */ }
public static class UsageAccessSettingsActivity extends SettingsActivity { /* empty */ }
public static class LocationSettingsActivity extends SettingsActivity { /* empty */ }
public static class PrivacySettingsActivity extends SettingsActivity { /* empty */ }
diff --git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java
index d4584b7..3c18efb 100644
--- a/src/com/android/settings/SettingsActivity.java
+++ b/src/com/android/settings/SettingsActivity.java
@@ -802,20 +802,6 @@
!isConnectedDeviceV2Enabled && !UserManager.isDeviceInDemoMode(this) /* enabled */,
isAdmin) || somethingChanged;
- final boolean isSecurityV2Enabled = featureFactory.getSecurityFeatureProvider()
- .isSecuritySettingsV2Enabled(this);
-
- // Enable new security page if v2 enabled
- somethingChanged = setTileEnabled(
- new ComponentName(packageName,Settings.SecuritySettingsActivityV2.class.getName()),
- isSecurityV2Enabled,
- isAdmin) || somethingChanged;
- // Enable old security page if v2 disabled
- somethingChanged = setTileEnabled(
- new ComponentName(packageName,Settings.SecuritySettingsActivity.class.getName()),
- !isSecurityV2Enabled,
- isAdmin) || somethingChanged;
-
somethingChanged = setTileEnabled(new ComponentName(packageName,
Settings.SimSettingsActivity.class.getName()),
Utils.showSimCardTile(this), isAdmin)
diff --git a/src/com/android/settings/core/FeatureFlags.java b/src/com/android/settings/core/FeatureFlags.java
index e1636b4..7505876 100644
--- a/src/com/android/settings/core/FeatureFlags.java
+++ b/src/com/android/settings/core/FeatureFlags.java
@@ -24,7 +24,6 @@
public static final String CONNECTED_DEVICE_V2 = "settings_connected_device_v2";
public static final String BATTERY_SETTINGS_V2 = "settings_battery_v2";
public static final String BATTERY_DISPLAY_APP_LIST = "settings_battery_display_app_list";
- public static final String SECURITY_SETTINGS_V2 = "settings_security_settings_v2";
public static final String ZONE_PICKER_V2 = "settings_zone_picker_v2";
public static final String SUGGESTION_UI_V2 = "settings_suggestion_ui_v2";
public static final String ABOUT_PHONE_V2 = "settings_about_phone_v2";
diff --git a/src/com/android/settings/core/gateway/SettingsGateway.java b/src/com/android/settings/core/gateway/SettingsGateway.java
index ecf0584..b07cf84 100644
--- a/src/com/android/settings/core/gateway/SettingsGateway.java
+++ b/src/com/android/settings/core/gateway/SettingsGateway.java
@@ -116,7 +116,6 @@
import com.android.settings.security.CryptKeeperSettings;
import com.android.settings.security.LockscreenDashboardFragment;
import com.android.settings.security.SecuritySettings;
-import com.android.settings.security.SecuritySettingsV2;
import com.android.settings.sim.SimSettings;
import com.android.settings.support.SupportDashboardActivity;
import com.android.settings.system.ResetDashboardFragment;
@@ -165,7 +164,6 @@
NotificationStation.class.getName(),
LocationSettings.class.getName(),
SecuritySettings.class.getName(),
- SecuritySettingsV2.class.getName(),
UsageAccessDetails.class.getName(),
PrivacySettings.class.getName(),
DeviceAdminSettings.class.getName(),
@@ -271,8 +269,7 @@
Settings.PowerUsageSummaryActivity.class.getName(),
Settings.PowerUsageSummaryLegacyActivity.class.getName(),
Settings.AccountDashboardActivity.class.getName(),
- Settings.SecuritySettingsActivity.class.getName(),
- Settings.SecuritySettingsActivityV2.class.getName(),
+ Settings.SecurityDashboardActivity.class.getName(),
Settings.AccessibilitySettingsActivity.class.getName(),
Settings.SystemDashboardActivity.class.getName(),
SupportDashboardActivity.class.getName(),
diff --git a/src/com/android/settings/dashboard/DashboardFragmentRegistry.java b/src/com/android/settings/dashboard/DashboardFragmentRegistry.java
index bb575ea..275af3d 100644
--- a/src/com/android/settings/dashboard/DashboardFragmentRegistry.java
+++ b/src/com/android/settings/dashboard/DashboardFragmentRegistry.java
@@ -33,7 +33,7 @@
import com.android.settings.notification.ConfigureNotificationSettings;
import com.android.settings.notification.SoundSettings;
import com.android.settings.security.LockscreenDashboardFragment;
-import com.android.settings.security.SecuritySettingsV2;
+import com.android.settings.security.SecuritySettings;
import com.android.settings.system.SystemDashboardFragment;
import com.android.settingslib.drawer.CategoryKey;
@@ -77,7 +77,7 @@
CategoryKey.CATEGORY_SOUND);
PARENT_TO_CATEGORY_KEY_MAP.put(StorageDashboardFragment.class.getName(),
CategoryKey.CATEGORY_STORAGE);
- PARENT_TO_CATEGORY_KEY_MAP.put(SecuritySettingsV2.class.getName(),
+ PARENT_TO_CATEGORY_KEY_MAP.put(SecuritySettings.class.getName(),
CategoryKey.CATEGORY_SECURITY);
PARENT_TO_CATEGORY_KEY_MAP.put(AccountDetailDashboardFragment.class.getName(),
CategoryKey.CATEGORY_ACCOUNT_DETAIL);
diff --git a/src/com/android/settings/fingerprint/FingerprintSettings.java b/src/com/android/settings/fingerprint/FingerprintSettings.java
index de7187c..caad988 100644
--- a/src/com/android/settings/fingerprint/FingerprintSettings.java
+++ b/src/com/android/settings/fingerprint/FingerprintSettings.java
@@ -35,7 +35,6 @@
import android.support.annotation.VisibleForTesting;
import android.support.v7.preference.Preference;
import android.support.v7.preference.Preference.OnPreferenceChangeListener;
-import android.support.v7.preference.Preference.OnPreferenceClickListener;
import android.support.v7.preference.PreferenceGroup;
import android.support.v7.preference.PreferenceScreen;
import android.support.v7.preference.PreferenceViewHolder;
@@ -921,49 +920,4 @@
});
}
}
-
- /**
- * @deprecated in favor of new SecuritySettings.
- */
- @Deprecated
- public static Preference getFingerprintPreferenceForUser(Context context, final int userId) {
- final FingerprintManager fpm = Utils.getFingerprintManagerOrNull(context);
- if (fpm == null || !fpm.isHardwareDetected()) {
- Log.v(TAG, "No fingerprint hardware detected!!");
- return null;
- }
- Preference fingerprintPreference = new Preference(context);
- fingerprintPreference.setKey(KEY_FINGERPRINT_SETTINGS);
- fingerprintPreference.setTitle(R.string.security_settings_fingerprint_preference_title);
- final List<Fingerprint> items = fpm.getEnrolledFingerprints(userId);
- final int fingerprintCount = items != null ? items.size() : 0;
- final String clazz;
- if (fingerprintCount > 0) {
- fingerprintPreference.setSummary(context.getResources().getQuantityString(
- R.plurals.security_settings_fingerprint_preference_summary,
- fingerprintCount, fingerprintCount));
- clazz = FingerprintSettings.class.getName();
- } else {
- fingerprintPreference.setSummary(
- R.string.security_settings_fingerprint_preference_summary_none);
- clazz = FingerprintEnrollIntroduction.class.getName();
- }
- fingerprintPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
- @Override
- public boolean onPreferenceClick(Preference preference) {
- final Context context = preference.getContext();
- final UserManager userManager = UserManager.get(context);
- if (Utils.startQuietModeDialogIfNecessary(context, userManager,
- userId)) {
- return false;
- }
- Intent intent = new Intent();
- intent.setClassName("com.android.settings", clazz);
- intent.putExtra(Intent.EXTRA_USER_ID, userId);
- context.startActivity(intent);
- return true;
- }
- });
- return fingerprintPreference;
- }
}
diff --git a/src/com/android/settings/password/ManagedLockPasswordProvider.java b/src/com/android/settings/password/ManagedLockPasswordProvider.java
index 82135cf..5786a5a 100644
--- a/src/com/android/settings/password/ManagedLockPasswordProvider.java
+++ b/src/com/android/settings/password/ManagedLockPasswordProvider.java
@@ -55,17 +55,6 @@
CharSequence getPickerOptionTitle(boolean forFingerprint) { return ""; }
/**
- * Gets resource id of the lock screen preference that should be displayed in security settings
- * if the current password quality is set to
- * {@link android.app.admin.DevicePolicyManager#PASSWORD_QUALITY_MANAGED}.
- * @param forProfile Whether the settings are shown for a user profile rather than a user.
- */
- public int getResIdForLockUnlockScreen(boolean forProfile) {
- return forProfile ? R.xml.security_settings_password_profile
- : R.xml.security_settings_password;
- }
-
- /**
* Creates intent that should be launched when user chooses managed password in the lock
* settings picker.
* @param requirePasswordToDecrypt Whether a password is needed to decrypt the user.
diff --git a/src/com/android/settings/search/SearchIndexableResourcesImpl.java b/src/com/android/settings/search/SearchIndexableResourcesImpl.java
index faa4b8c..38dc15d 100644
--- a/src/com/android/settings/search/SearchIndexableResourcesImpl.java
+++ b/src/com/android/settings/search/SearchIndexableResourcesImpl.java
@@ -21,7 +21,6 @@
import com.android.settings.DateTimeSettings;
import com.android.settings.DisplaySettings;
import com.android.settings.LegalSettings;
-import com.android.settings.deviceinfo.aboutphone.MyDeviceInfoFragment;
import com.android.settings.accessibility.AccessibilitySettings;
import com.android.settings.accessibility.AccessibilityShortcutPreferenceFragment;
import com.android.settings.accessibility.MagnificationPreferenceFragment;
@@ -42,6 +41,7 @@
import com.android.settings.deviceinfo.DeviceInfoSettings;
import com.android.settings.deviceinfo.StorageDashboardFragment;
import com.android.settings.deviceinfo.StorageSettings;
+import com.android.settings.deviceinfo.aboutphone.MyDeviceInfoFragment;
import com.android.settings.display.AmbientDisplaySettings;
import com.android.settings.display.NightDisplaySettings;
import com.android.settings.display.ScreenZoomSettings;
@@ -75,7 +75,7 @@
import com.android.settings.security.EncryptionAndCredential;
import com.android.settings.security.LockscreenDashboardFragment;
import com.android.settings.security.ScreenPinningSettings;
-import com.android.settings.security.SecuritySettingsV2;
+import com.android.settings.security.SecuritySettings;
import com.android.settings.security.screenlock.ScreenLockSettings;
import com.android.settings.sim.SimSettings;
import com.android.settings.support.SupportDashboardActivity;
@@ -132,7 +132,7 @@
addIndex(LanguageAndInputSettings.class);
addIndex(LocationSettings.class);
addIndex(ScanningSettings.class);
- addIndex(SecuritySettingsV2.class);
+ addIndex(SecuritySettings.class);
addIndex(ScreenLockSettings.class);
addIndex(EncryptionAndCredential.class);
addIndex(ScreenPinningSettings.class);
diff --git a/src/com/android/settings/security/ChangeProfileScreenLockPreferenceController.java b/src/com/android/settings/security/ChangeProfileScreenLockPreferenceController.java
index 9a33ec3..91c4410 100644
--- a/src/com/android/settings/security/ChangeProfileScreenLockPreferenceController.java
+++ b/src/com/android/settings/security/ChangeProfileScreenLockPreferenceController.java
@@ -16,8 +16,7 @@
package com.android.settings.security;
-import static com.android.settings.security
- .SecuritySettingsV2.SET_OR_CHANGE_LOCK_METHOD_REQUEST_PROFILE;
+import static com.android.settings.security.SecuritySettings.SET_OR_CHANGE_LOCK_METHOD_REQUEST_PROFILE;
import android.app.admin.DevicePolicyManager;
import android.content.Context;
@@ -37,7 +36,7 @@
private static final String KEY_UNLOCK_SET_OR_CHANGE_PROFILE = "unlock_set_or_change_profile";
public ChangeProfileScreenLockPreferenceController(Context context,
- SecuritySettingsV2 host) {
+ SecuritySettings host) {
super(context, host);
}
diff --git a/src/com/android/settings/security/ChangeScreenLockPreferenceController.java b/src/com/android/settings/security/ChangeScreenLockPreferenceController.java
index fdb9349..10143d2 100644
--- a/src/com/android/settings/security/ChangeScreenLockPreferenceController.java
+++ b/src/com/android/settings/security/ChangeScreenLockPreferenceController.java
@@ -16,7 +16,7 @@
package com.android.settings.security;
-import static com.android.settings.security.SecuritySettingsV2.SET_OR_CHANGE_LOCK_METHOD_REQUEST;
+import static com.android.settings.security.SecuritySettings.SET_OR_CHANGE_LOCK_METHOD_REQUEST;
import android.app.admin.DevicePolicyManager;
import android.content.Context;
@@ -45,7 +45,7 @@
private static final String KEY_UNLOCK_SET_OR_CHANGE = "unlock_set_or_change";
protected final DevicePolicyManager mDPM;
- protected final SecuritySettingsV2 mHost;
+ protected final SecuritySettings mHost;
protected final UserManager mUm;
protected final LockPatternUtils mLockPatternUtils;
@@ -54,7 +54,7 @@
protected RestrictedPreference mPreference;
- public ChangeScreenLockPreferenceController(Context context, SecuritySettingsV2 host) {
+ public ChangeScreenLockPreferenceController(Context context, SecuritySettings host) {
super(context);
mUm = (UserManager) context.getSystemService(Context.USER_SERVICE);
mDPM = (DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE);
diff --git a/src/com/android/settings/security/LockUnificationPreferenceController.java b/src/com/android/settings/security/LockUnificationPreferenceController.java
index 5486e29..abbf2f4 100644
--- a/src/com/android/settings/security/LockUnificationPreferenceController.java
+++ b/src/com/android/settings/security/LockUnificationPreferenceController.java
@@ -16,11 +16,10 @@
package com.android.settings.security;
-import static com.android.settings.security
- .SecuritySettingsV2.SET_OR_CHANGE_LOCK_METHOD_REQUEST_PROFILE;
-import static com.android.settings.security.SecuritySettingsV2.UNIFY_LOCK_CONFIRM_DEVICE_REQUEST;
-import static com.android.settings.security.SecuritySettingsV2.UNIFY_LOCK_CONFIRM_PROFILE_REQUEST;
-import static com.android.settings.security.SecuritySettingsV2.UNUNIFY_LOCK_CONFIRM_DEVICE_REQUEST;
+import static com.android.settings.security.SecuritySettings.SET_OR_CHANGE_LOCK_METHOD_REQUEST_PROFILE;
+import static com.android.settings.security.SecuritySettings.UNIFY_LOCK_CONFIRM_DEVICE_REQUEST;
+import static com.android.settings.security.SecuritySettings.UNIFY_LOCK_CONFIRM_PROFILE_REQUEST;
+import static com.android.settings.security.SecuritySettings.UNUNIFY_LOCK_CONFIRM_DEVICE_REQUEST;
import android.app.Activity;
import android.app.admin.DevicePolicyManager;
@@ -53,7 +52,7 @@
private final UserManager mUm;
private final LockPatternUtils mLockPatternUtils;
private final int mProfileChallengeUserId;
- private final SecuritySettingsV2 mHost;
+ private final SecuritySettings mHost;
private RestrictedSwitchPreference mUnifyProfile;
@@ -67,7 +66,7 @@
mUnifyProfile = (RestrictedSwitchPreference) screen.findPreference(KEY_UNIFICATION);
}
- public LockUnificationPreferenceController(Context context, SecuritySettingsV2 host) {
+ public LockUnificationPreferenceController(Context context, SecuritySettings host) {
super(context);
mHost = host;
mUm = (UserManager) context.getSystemService(Context.USER_SERVICE);
@@ -212,7 +211,7 @@
mCurrentProfilePassword);
mHost.startFragment(mHost, ChooseLockGeneric.ChooseLockGenericFragment.class.getName(),
R.string.lock_settings_picker_title,
- SecuritySettingsV2.SET_OR_CHANGE_LOCK_METHOD_REQUEST, null);
+ SecuritySettings.SET_OR_CHANGE_LOCK_METHOD_REQUEST, null);
}
}
diff --git a/src/com/android/settings/security/SecurityFeatureProvider.java b/src/com/android/settings/security/SecurityFeatureProvider.java
index 35ff586..d533d1e 100644
--- a/src/com/android/settings/security/SecurityFeatureProvider.java
+++ b/src/com/android/settings/security/SecurityFeatureProvider.java
@@ -17,26 +17,14 @@
package com.android.settings.security;
import android.content.Context;
-import android.support.v7.preference.PreferenceScreen;
-import android.util.FeatureFlagUtils;
import com.android.internal.widget.LockPatternUtils;
-import com.android.settings.core.FeatureFlags;
import com.android.settings.security.trustagent.TrustAgentManager;
-import com.android.settingslib.drawer.DashboardCategory;
/** FeatureProvider for security. */
public interface SecurityFeatureProvider {
- default boolean isSecuritySettingsV2Enabled(Context context) {
- return FeatureFlagUtils.isEnabled(context, FeatureFlags.SECURITY_SETTINGS_V2);
- }
-
- /** Update preferences with data from associated tiles. */
- void updatePreferences(Context context, PreferenceScreen preferenceScreen,
- DashboardCategory dashboardCategory);
-
/** Returns the {@link TrustAgentManager} bound to this {@link SecurityFeatureProvider}. */
TrustAgentManager getTrustAgentManager();
diff --git a/src/com/android/settings/security/SecurityFeatureProviderImpl.java b/src/com/android/settings/security/SecurityFeatureProviderImpl.java
index 70b1ec1..56a0884 100644
--- a/src/com/android/settings/security/SecurityFeatureProviderImpl.java
+++ b/src/com/android/settings/security/SecurityFeatureProviderImpl.java
@@ -17,28 +17,9 @@
package com.android.settings.security;
import android.content.Context;
-import android.content.IContentProvider;
-import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.content.res.Resources;
-import android.graphics.drawable.Drawable;
-import android.support.annotation.VisibleForTesting;
-import android.support.v7.preference.Preference;
-import android.support.v7.preference.PreferenceScreen;
-import android.text.TextUtils;
-import android.util.ArrayMap;
-import android.util.Pair;
import com.android.internal.widget.LockPatternUtils;
-import com.android.settings.R;
import com.android.settings.security.trustagent.TrustAgentManager;
-import com.android.settingslib.drawer.DashboardCategory;
-import com.android.settingslib.drawer.Tile;
-import com.android.settingslib.drawer.TileUtils;
-import com.android.settingslib.utils.ThreadUtils;
-
-import java.util.Map;
-import java.util.TreeMap;
/** Implementation for {@code SecurityFeatureProvider}. */
public class SecurityFeatureProviderImpl implements SecurityFeatureProvider {
@@ -46,150 +27,6 @@
private TrustAgentManager mTrustAgentManager;
private LockPatternUtils mLockPatternUtils;
- @VisibleForTesting
- static final Drawable DEFAULT_ICON = null;
-
- @VisibleForTesting
- static Map<String, Pair<String, Integer>> sIconCache = new TreeMap<>();
-
- @VisibleForTesting
- static Map<String, String> sSummaryCache = new TreeMap<>();
-
- /** Update preferences with data from associated tiles. */
- public void updatePreferences(final Context context, final PreferenceScreen preferenceScreen,
- final DashboardCategory dashboardCategory) {
- if (preferenceScreen == null) {
- return;
- }
- int tilesCount = (dashboardCategory != null) ? dashboardCategory.getTilesCount() : 0;
- if (tilesCount == 0) {
- return;
- }
-
- initPreferences(context, preferenceScreen, dashboardCategory);
-
- // Fetching the summary and icon from the provider introduces latency, so do this on a
- // separate thread.
- ThreadUtils.postOnBackgroundThread(() ->
- updatePreferencesToRunOnWorkerThread(context, preferenceScreen, dashboardCategory));
- }
-
- @VisibleForTesting
- static void initPreferences(Context context, PreferenceScreen preferenceScreen,
- DashboardCategory dashboardCategory) {
- int tilesCount = (dashboardCategory != null) ? dashboardCategory.getTilesCount() : 0;
- for (int i = 0; i < tilesCount; i++) {
- Tile tile = dashboardCategory.getTile(i);
- // If the tile does not have a key or appropriate meta data, skip it.
- if (TextUtils.isEmpty(tile.key) || (tile.metaData == null)) {
- continue;
- }
- Preference matchingPref = preferenceScreen.findPreference(tile.key);
- // If the tile does not have a matching preference, skip it.
- if (matchingPref == null) {
- continue;
- }
- // Either remove an icon by replacing them with nothing, or use the cached one since
- // there is a delay in fetching the injected icon, and we don't want an inappropriate
- // icon to be displayed while waiting for the injected icon.
- final String iconUri =
- tile.metaData.getString(TileUtils.META_DATA_PREFERENCE_ICON_URI, null);
- Drawable drawable = DEFAULT_ICON;
- if ((iconUri != null) && sIconCache.containsKey(iconUri)) {
- Pair<String, Integer> icon = sIconCache.get(iconUri);
- try {
- drawable = context.getPackageManager()
- .getResourcesForApplication(icon.first /* package name */)
- .getDrawable(icon.second /* res id */,
- context.getTheme());
- } catch (PackageManager.NameNotFoundException e) {
- // Ignore and just load the default icon.
- }
- }
- matchingPref.setIcon(drawable);
- // Either reserve room for the summary or load the cached one. This prevents the title
- // from shifting when the final summary is injected.
- final String summaryUri =
- tile.metaData.getString(TileUtils.META_DATA_PREFERENCE_SUMMARY_URI, null);
- String summary = context.getString(R.string.summary_placeholder);
- if ((summaryUri != null) && sSummaryCache.containsKey(summaryUri)) {
- summary = sSummaryCache.get(summaryUri);
- }
- matchingPref.setSummary(summary);
- }
- }
-
- @VisibleForTesting
- void updatePreferencesToRunOnWorkerThread(Context context, PreferenceScreen preferenceScreen,
- DashboardCategory dashboardCategory) {
-
- int tilesCount = (dashboardCategory != null) ? dashboardCategory.getTilesCount() : 0;
- Map<String, IContentProvider> providerMap = new ArrayMap<>();
- for (int i = 0; i < tilesCount; i++) {
- Tile tile = dashboardCategory.getTile(i);
- // If the tile does not have a key or appropriate meta data, skip it.
- if (TextUtils.isEmpty(tile.key) || (tile.metaData == null)) {
- continue;
- }
- Preference matchingPref = preferenceScreen.findPreference(tile.key);
- // If the tile does not have a matching preference, skip it.
- if (matchingPref == null) {
- continue;
- }
- // Check if the tile has content providers for dynamically updatable content.
- final String iconUri =
- tile.metaData.getString(TileUtils.META_DATA_PREFERENCE_ICON_URI, null);
- final String summaryUri =
- tile.metaData.getString(TileUtils.META_DATA_PREFERENCE_SUMMARY_URI, null);
- if (!TextUtils.isEmpty(iconUri)) {
- String packageName = null;
- if (tile.intent != null) {
- Intent intent = tile.intent;
- if (!TextUtils.isEmpty(intent.getPackage())) {
- packageName = intent.getPackage();
- } else if (intent.getComponent() != null) {
- packageName = intent.getComponent().getPackageName();
- }
- }
- Pair<String, Integer> icon =
- TileUtils.getIconFromUri(context, packageName, iconUri, providerMap);
- if (icon != null) {
- sIconCache.put(iconUri, icon);
- // Icon is only returned if the icon belongs to Settings or the target app.
- // setIcon must be called on the UI thread.
- ThreadUtils.postOnMainThread(() -> {
- try {
- matchingPref.setIcon(context.getPackageManager()
- .getResourcesForApplication(icon.first /* package name */)
- .getDrawable(icon.second /* res id */,
- context.getTheme()));
- } catch (PackageManager.NameNotFoundException
- | Resources.NotFoundException e) {
- // Intentionally ignored. If icon resources cannot be found, do not
- // update.
- }
- });
- }
- }
- if (!TextUtils.isEmpty(summaryUri)) {
- String summary = TileUtils.getTextFromUri(context, summaryUri, providerMap,
- TileUtils.META_DATA_PREFERENCE_SUMMARY);
- sSummaryCache.put(summaryUri, summary);
- // setSummary must be called on UI thread.
- ThreadUtils.postOnMainThread(() -> {
- // Only update the summary if it has actually changed.
- if (summary == null) {
- if (matchingPref.getSummary() != null) {
- matchingPref.setSummary(summary);
- }
- } else if (!summary.equals(matchingPref.getSummary())) {
- matchingPref.setSummary(summary);
- }
- });
- }
- }
- }
-
@Override
public TrustAgentManager getTrustAgentManager() {
if (mTrustAgentManager == null) {
diff --git a/src/com/android/settings/security/SecuritySettings.java b/src/com/android/settings/security/SecuritySettings.java
index f099b44..df3b455 100644
--- a/src/com/android/settings/security/SecuritySettings.java
+++ b/src/com/android/settings/security/SecuritySettings.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007 The Android Open Source Project
+ * Copyright (C) 2018 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.
@@ -13,744 +13,62 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.android.settings.security;
-import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
+import static com.android.settings.security.EncryptionStatusPreferenceController
+ .PREF_KEY_ENCRYPTION_SECURITY_PAGE;
import android.app.Activity;
-import android.app.AlertDialog;
-import android.app.Dialog;
-import android.app.FragmentManager;
-import android.app.admin.DevicePolicyManager;
import android.content.Context;
-import android.content.DialogInterface;
import android.content.Intent;
-import android.content.res.Resources;
import android.hardware.fingerprint.FingerprintManager;
-import android.os.Bundle;
-import android.os.PersistableBundle;
-import android.os.UserHandle;
-import android.os.UserManager;
-import android.os.storage.StorageManager;
import android.provider.SearchIndexableResource;
-import android.provider.Settings;
-import android.support.annotation.VisibleForTesting;
-import android.support.v14.preference.SwitchPreference;
-import android.support.v7.preference.Preference;
-import android.support.v7.preference.Preference.OnPreferenceChangeListener;
-import android.support.v7.preference.PreferenceGroup;
-import android.support.v7.preference.PreferenceScreen;
-import android.telephony.CarrierConfigManager;
-import android.telephony.SubscriptionInfo;
-import android.telephony.SubscriptionManager;
-import android.telephony.TelephonyManager;
-import android.text.TextUtils;
-import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
-import com.android.internal.widget.LockPatternUtils;
+import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
-import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.Utils;
-import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
-import com.android.settings.dashboard.DashboardFeatureProvider;
+import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.dashboard.SummaryLoader;
import com.android.settings.enterprise.EnterprisePrivacyPreferenceController;
import com.android.settings.enterprise.ManageDeviceAdminPreferenceController;
-import com.android.settings.fingerprint.FingerprintSettings;
+import com.android.settings.fingerprint.FingerprintProfileStatusPreferenceController;
+import com.android.settings.fingerprint.FingerprintStatusPreferenceController;
import com.android.settings.location.LocationPreferenceController;
-import com.android.settings.notification.LockScreenNotificationPreferenceController;
-import com.android.settings.overlay.FeatureFactory;
-import com.android.settings.password.ChooseLockGeneric.ChooseLockGenericFragment;
-import com.android.settings.password.ChooseLockSettingsHelper;
-import com.android.settings.password.ManagedLockPasswordProvider;
import com.android.settings.search.BaseSearchIndexProvider;
-import com.android.settings.search.Indexable;
-import com.android.settings.search.SearchIndexableRaw;
-import com.android.settings.security.screenlock.ScreenLockSettings;
-import com.android.settings.security.trustagent.TrustAgentManager;
-import com.android.settings.security.trustagent.TrustAgentManager.TrustAgentComponentInfo;
-import com.android.settings.widget.GearPreference;
-import com.android.settingslib.RestrictedLockUtils;
-import com.android.settingslib.RestrictedPreference;
-import com.android.settingslib.RestrictedSwitchPreference;
-import com.android.settingslib.drawer.CategoryKey;
+import com.android.settings.security.screenlock.LockScreenPreferenceController;
+import com.android.settings.security.trustagent.ManageTrustAgentsPreferenceController;
+import com.android.settings.security.trustagent.TrustAgentListPreferenceController;
+import com.android.settings.widget.PreferenceCategoryController;
+import com.android.settingslib.core.AbstractPreferenceController;
+import com.android.settingslib.core.lifecycle.Lifecycle;
import java.util.ArrayList;
import java.util.List;
-/**
- * Gesture lock pattern settings.
- */
-public class SecuritySettings extends SettingsPreferenceFragment
- implements OnPreferenceChangeListener, Indexable,
- GearPreference.OnGearClickListener {
+public class SecuritySettings extends DashboardFragment {
private static final String TAG = "SecuritySettings";
- private static final String TRUST_AGENT_CLICK_INTENT = "trust_agent_click_intent";
-
- // Lock Settings
- private static final String KEY_UNLOCK_SET_OR_CHANGE = "unlock_set_or_change";
- private static final String KEY_UNLOCK_SET_OR_CHANGE_PROFILE = "unlock_set_or_change_profile";
- private static final String KEY_VISIBLE_PATTERN_PROFILE = "visiblepattern_profile";
- private static final String KEY_SECURITY_CATEGORY = "security_category";
- @VisibleForTesting
- static final String KEY_MANAGE_TRUST_AGENTS = "manage_trust_agents";
- 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;
- private static final int SET_OR_CHANGE_LOCK_METHOD_REQUEST_PROFILE = 127;
- private static final int UNIFY_LOCK_CONFIRM_DEVICE_REQUEST = 128;
- private static final int UNIFY_LOCK_CONFIRM_PROFILE_REQUEST = 129;
- private static final int UNUNIFY_LOCK_CONFIRM_DEVICE_REQUEST = 130;
- private static final String TAG_UNIFICATION_DIALOG = "unification_dialog";
-
- // Misc Settings
- private static final String KEY_SIM_LOCK = "sim_lock_settings";
- private static final String KEY_SHOW_PASSWORD = "show_password";
- private static final String KEY_TRUST_AGENT = "trust_agent";
- private static final String KEY_SCREEN_PINNING = "screen_pinning_settings";
-
- // Security status
- private static final String KEY_SECURITY_STATUS = "security_status";
- private static final String SECURITY_STATUS_KEY_PREFIX = "security_status_";
-
- // Device management settings
- private static final String KEY_ENTERPRISE_PRIVACY = "enterprise_privacy";
- private static final String KEY_MANAGE_DEVICE_ADMIN = "manage_device_admin";
-
- // These switch preferences need special handling since they're not all stored in Settings.
- private static final String SWITCH_PREFERENCE_KEYS[] = {
- KEY_SHOW_PASSWORD, KEY_UNIFICATION, KEY_VISIBLE_PATTERN_PROFILE
- };
-
- private static final int MY_USER_ID = UserHandle.myUserId();
-
- private DashboardFeatureProvider mDashboardFeatureProvider;
- private DevicePolicyManager mDPM;
- private SecurityFeatureProvider mSecurityFeatureProvider;
- private TrustAgentManager mTrustAgentManager;
- private SubscriptionManager mSubscriptionManager;
- private UserManager mUm;
-
- private ChooseLockSettingsHelper mChooseLockSettingsHelper;
- private LockPatternUtils mLockPatternUtils;
- private ManagedLockPasswordProvider mManagedPasswordProvider;
-
- private SwitchPreference mVisiblePatternProfile;
- private RestrictedSwitchPreference mUnifyProfile;
-
- private SwitchPreference mShowPassword;
-
- private boolean mIsAdmin;
-
- private Intent mTrustAgentClickIntent;
-
- private int mProfileChallengeUserId;
-
- private String mCurrentDevicePassword;
- private String mCurrentProfilePassword;
-
- private LocationPreferenceController mLocationcontroller;
- private ManageDeviceAdminPreferenceController mManageDeviceAdminPreferenceController;
- private EnterprisePrivacyPreferenceController mEnterprisePrivacyPreferenceController;
+ public static final int SET_OR_CHANGE_LOCK_METHOD_REQUEST = 123;
+ public static final int CHANGE_TRUST_AGENT_SETTINGS = 126;
+ public static final int SET_OR_CHANGE_LOCK_METHOD_REQUEST_PROFILE = 127;
+ public static final int UNIFY_LOCK_CONFIRM_DEVICE_REQUEST = 128;
+ public static final int UNIFY_LOCK_CONFIRM_PROFILE_REQUEST = 129;
+ public static final int UNUNIFY_LOCK_CONFIRM_DEVICE_REQUEST = 130;
@Override
public int getMetricsCategory() {
- return MetricsEvent.SECURITY;
+ return MetricsProto.MetricsEvent.SECURITY;
}
@Override
- public void onAttach(Context context) {
- super.onAttach(context);
- mLocationcontroller = new LocationPreferenceController(context, getLifecycle());
+ protected int getPreferenceScreenResId() {
+ return R.xml.security_dashboard_settings;
}
@Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- final Activity activity = getActivity();
-
- mSubscriptionManager = SubscriptionManager.from(activity);
-
- mLockPatternUtils = new LockPatternUtils(activity);
-
- mManagedPasswordProvider = ManagedLockPasswordProvider.get(activity, MY_USER_ID);
-
- mDPM = (DevicePolicyManager)getSystemService(Context.DEVICE_POLICY_SERVICE);
-
- mUm = UserManager.get(activity);
-
- mChooseLockSettingsHelper = new ChooseLockSettingsHelper(activity);
-
- mDashboardFeatureProvider = FeatureFactory.getFactory(activity)
- .getDashboardFeatureProvider(activity);
-
- mSecurityFeatureProvider = FeatureFactory.getFactory(activity).getSecurityFeatureProvider();
-
- mTrustAgentManager = mSecurityFeatureProvider.getTrustAgentManager();
-
- if (savedInstanceState != null
- && savedInstanceState.containsKey(TRUST_AGENT_CLICK_INTENT)) {
- mTrustAgentClickIntent = savedInstanceState.getParcelable(TRUST_AGENT_CLICK_INTENT);
- }
-
- mManageDeviceAdminPreferenceController
- = new ManageDeviceAdminPreferenceController(activity);
- mEnterprisePrivacyPreferenceController
- = new EnterprisePrivacyPreferenceController(activity);
- }
-
- private static int getResIdForLockUnlockScreen(LockPatternUtils lockPatternUtils,
- ManagedLockPasswordProvider managedPasswordProvider, int userId) {
- final boolean isMyUser = userId == MY_USER_ID;
- int resid = 0;
- if (!lockPatternUtils.isSecure(userId)) {
- if (!isMyUser) {
- resid = R.xml.security_settings_lockscreen_profile;
- } else if (lockPatternUtils.isLockScreenDisabled(userId)) {
- resid = R.xml.security_settings_lockscreen;
- } else {
- resid = R.xml.security_settings_chooser;
- }
- } else {
- switch (lockPatternUtils.getKeyguardStoredPasswordQuality(userId)) {
- case DevicePolicyManager.PASSWORD_QUALITY_SOMETHING:
- resid = isMyUser ? R.xml.security_settings_pattern
- : R.xml.security_settings_pattern_profile;
- break;
- case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC:
- case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC_COMPLEX:
- resid = isMyUser ? R.xml.security_settings_pin
- : R.xml.security_settings_pin_profile;
- break;
- case DevicePolicyManager.PASSWORD_QUALITY_ALPHABETIC:
- case DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC:
- case DevicePolicyManager.PASSWORD_QUALITY_COMPLEX:
- resid = isMyUser ? R.xml.security_settings_password
- : R.xml.security_settings_password_profile;
- break;
- case DevicePolicyManager.PASSWORD_QUALITY_MANAGED:
- resid = managedPasswordProvider.getResIdForLockUnlockScreen(!isMyUser);
- break;
- }
- }
- return resid;
- }
-
- /**
- * Important!
- *
- * Don't forget to update the SecuritySearchIndexProvider if you are doing any change in the
- * logic or adding/removing preferences here.
- */
- private PreferenceScreen createPreferenceHierarchy() {
- PreferenceScreen root = getPreferenceScreen();
- if (root != null) {
- root.removeAll();
- }
- addPreferencesFromResource(R.xml.security_settings);
- root = getPreferenceScreen();
-
- // Add category for security status
- addPreferencesFromResource(R.xml.security_settings_status);
-
- // Add options for lock/unlock screen
- final int resid = getResIdForLockUnlockScreen(mLockPatternUtils,
- mManagedPasswordProvider, MY_USER_ID);
- addPreferencesFromResource(resid);
-
- // DO or PO installed in the user may disallow to change password.
- disableIfPasswordQualityManaged(KEY_UNLOCK_SET_OR_CHANGE, MY_USER_ID);
-
- mProfileChallengeUserId = Utils.getManagedProfileId(mUm, MY_USER_ID);
- if (mProfileChallengeUserId != UserHandle.USER_NULL
- && mLockPatternUtils.isSeparateProfileChallengeAllowed(mProfileChallengeUserId)) {
- addPreferencesFromResource(R.xml.security_settings_profile);
- addPreferencesFromResource(R.xml.security_settings_unification);
- final int profileResid = getResIdForLockUnlockScreen(mLockPatternUtils,
- mManagedPasswordProvider, mProfileChallengeUserId);
- addPreferencesFromResource(profileResid);
- maybeAddFingerprintPreference(root, mProfileChallengeUserId);
- if (!mLockPatternUtils.isSeparateProfileChallengeEnabled(mProfileChallengeUserId)) {
- final Preference lockPreference =
- root.findPreference(KEY_UNLOCK_SET_OR_CHANGE_PROFILE);
- final String summary = getContext().getString(
- R.string.lock_settings_profile_unified_summary);
- lockPreference.setSummary(summary);
- lockPreference.setEnabled(false);
- // PO may disallow to change password for the profile, but screen lock and managed
- // profile's lock is the same. Disable main "Screen lock" menu.
- disableIfPasswordQualityManaged(KEY_UNLOCK_SET_OR_CHANGE, mProfileChallengeUserId);
- } else {
- // PO may disallow to change profile password, and the profile's password is
- // separated from screen lock password. Disable profile specific "Screen lock" menu.
- disableIfPasswordQualityManaged(KEY_UNLOCK_SET_OR_CHANGE_PROFILE,
- mProfileChallengeUserId);
- }
- }
-
- Preference unlockSetOrChange = findPreference(KEY_UNLOCK_SET_OR_CHANGE);
- if (unlockSetOrChange instanceof GearPreference) {
- ((GearPreference) unlockSetOrChange).setOnGearClickListener(this);
- }
-
- mIsAdmin = mUm.isAdminUser();
-
- // Fingerprint and trust agents
- int numberOfTrustAgent = 0;
- PreferenceGroup securityCategory = (PreferenceGroup)
- root.findPreference(KEY_SECURITY_CATEGORY);
- if (securityCategory != null) {
- maybeAddFingerprintPreference(securityCategory, UserHandle.myUserId());
- numberOfTrustAgent = addTrustAgentSettings(securityCategory);
- setLockscreenPreferencesSummary(securityCategory);
- }
-
- mVisiblePatternProfile =
- (SwitchPreference) root.findPreference(KEY_VISIBLE_PATTERN_PROFILE);
- mUnifyProfile = (RestrictedSwitchPreference) root.findPreference(KEY_UNIFICATION);
-
- // Append the rest of the settings
- addPreferencesFromResource(R.xml.security_settings_misc);
-
- // Do not display SIM lock for devices without an Icc card
- TelephonyManager tm = TelephonyManager.getDefault();
- CarrierConfigManager cfgMgr = (CarrierConfigManager)
- getActivity().getSystemService(Context.CARRIER_CONFIG_SERVICE);
- PersistableBundle b = cfgMgr.getConfig();
- if (!mIsAdmin || !isSimIccReady() ||
- b.getBoolean(CarrierConfigManager.KEY_HIDE_SIM_LOCK_SETTINGS_BOOL)) {
- root.removePreference(root.findPreference(KEY_SIM_LOCK));
- } else {
- // Disable SIM lock if there is no ready SIM card.
- root.findPreference(KEY_SIM_LOCK).setEnabled(isSimReady());
- }
- if (Settings.System.getInt(getContentResolver(),
- Settings.System.LOCK_TO_APP_ENABLED, 0) != 0) {
- root.findPreference(KEY_SCREEN_PINNING).setSummary(
- getResources().getString(R.string.switch_on_text));
- }
-
- // Encryption status of device
- if (LockPatternUtils.isDeviceEncryptionEnabled()) {
- root.findPreference(KEY_ENCRYPTION_AND_CREDENTIALS).setSummary(
- R.string.encryption_and_credential_settings_summary);
- } else {
- root.findPreference(KEY_ENCRYPTION_AND_CREDENTIALS).setSummary(
- R.string.summary_placeholder);
- }
-
- // Show password
- mShowPassword = (SwitchPreference) root.findPreference(KEY_SHOW_PASSWORD);
-
- // Credential storage
- final UserManager um = (UserManager) getActivity().getSystemService(Context.USER_SERVICE);
-
- // Advanced Security features
- initTrustAgentPreference(root, numberOfTrustAgent);
-
- PreferenceGroup securityStatusPreferenceGroup =
- (PreferenceGroup) root.findPreference(KEY_SECURITY_STATUS);
- final List<Preference> tilePrefs = mDashboardFeatureProvider.getPreferencesForCategory(
- getActivity(), getPrefContext(), getMetricsCategory(),
- CategoryKey.CATEGORY_SECURITY);
- int numSecurityStatusPrefs = 0;
- if (tilePrefs != null && !tilePrefs.isEmpty()) {
- for (Preference preference : tilePrefs) {
- if (!TextUtils.isEmpty(preference.getKey())
- && preference.getKey().startsWith(SECURITY_STATUS_KEY_PREFIX)) {
- // Injected security status settings are placed under the Security status
- // category.
- securityStatusPreferenceGroup.addPreference(preference);
- numSecurityStatusPrefs++;
- } else {
- // Other injected settings are placed under the Security preference screen.
- root.addPreference(preference);
- }
- }
- }
-
- if (numSecurityStatusPrefs == 0) {
- root.removePreference(securityStatusPreferenceGroup);
- } else if (numSecurityStatusPrefs > 0) {
- // Update preference data with tile data. Security feature provider only updates the
- // data if it actually needs to be changed.
- mSecurityFeatureProvider.updatePreferences(getActivity(), root,
- mDashboardFeatureProvider.getTilesForCategory(
- CategoryKey.CATEGORY_SECURITY));
- }
-
- for (int i = 0; i < SWITCH_PREFERENCE_KEYS.length; i++) {
- final Preference pref = findPreference(SWITCH_PREFERENCE_KEYS[i]);
- if (pref != null) pref.setOnPreferenceChangeListener(this);
- }
-
- mLocationcontroller.displayPreference(root);
- mManageDeviceAdminPreferenceController.updateState(
- root.findPreference(KEY_MANAGE_DEVICE_ADMIN));
- mEnterprisePrivacyPreferenceController.displayPreference(root);
- final Preference enterprisePrivacyPreference = root.findPreference(
- mEnterprisePrivacyPreferenceController.getPreferenceKey());
- mEnterprisePrivacyPreferenceController.updateState(enterprisePrivacyPreference);
-
- return root;
- }
-
- @VisibleForTesting
- void initTrustAgentPreference(PreferenceScreen root, int numberOfTrustAgent) {
- Preference manageAgents = root.findPreference(KEY_MANAGE_TRUST_AGENTS);
- if (manageAgents != null) {
- if (!mLockPatternUtils.isSecure(MY_USER_ID)) {
- manageAgents.setEnabled(false);
- manageAgents.setSummary(R.string.disabled_because_no_backup_security);
- } else if (numberOfTrustAgent > 0) {
- manageAgents.setSummary(getActivity().getResources().getQuantityString(
- R.plurals.manage_trust_agents_summary_on,
- numberOfTrustAgent, numberOfTrustAgent));
- } else {
- manageAgents.setSummary(R.string.manage_trust_agents_summary);
- }
- }
- }
-
- @VisibleForTesting
- void setLockscreenPreferencesSummary(PreferenceGroup group) {
- final Preference lockscreenPreferences = group.findPreference(KEY_LOCKSCREEN_PREFERENCES);
- if (lockscreenPreferences != null) {
- lockscreenPreferences.setSummary(
- LockScreenNotificationPreferenceController.getSummaryResource(getContext()));
- }
- }
-
- /*
- * Sets the preference as disabled by admin if PASSWORD_QUALITY_MANAGED is set.
- * The preference must be a RestrictedPreference.
- */
- private void disableIfPasswordQualityManaged(String preferenceKey, int userId) {
- final EnforcedAdmin admin = RestrictedLockUtils.checkIfPasswordQualityIsSet(
- getActivity(), userId);
- if (admin != null && mDPM.getPasswordQuality(admin.component, userId) ==
- DevicePolicyManager.PASSWORD_QUALITY_MANAGED) {
- final RestrictedPreference pref =
- (RestrictedPreference) getPreferenceScreen().findPreference(preferenceKey);
- pref.setDisabledByAdmin(admin);
- }
- }
-
- private void maybeAddFingerprintPreference(PreferenceGroup securityCategory, int userId) {
- Preference fingerprintPreference =
- FingerprintSettings.getFingerprintPreferenceForUser(
- securityCategory.getContext(), userId);
- if (fingerprintPreference != null) {
- securityCategory.addPreference(fingerprintPreference);
- }
- }
-
- // Return the number of trust agents being added
- private int addTrustAgentSettings(PreferenceGroup securityCategory) {
- final boolean hasSecurity = mLockPatternUtils.isSecure(MY_USER_ID);
- final List<TrustAgentComponentInfo> agents = mTrustAgentManager.getActiveTrustAgents(
- getActivity(), mLockPatternUtils);
- for (TrustAgentComponentInfo agent : agents) {
- final RestrictedPreference trustAgentPreference =
- new RestrictedPreference(securityCategory.getContext());
- trustAgentPreference.setKey(KEY_TRUST_AGENT);
- trustAgentPreference.setTitle(agent.title);
- trustAgentPreference.setSummary(agent.summary);
- // Create intent for this preference.
- Intent intent = new Intent();
- intent.setComponent(agent.componentName);
- intent.setAction(Intent.ACTION_MAIN);
- trustAgentPreference.setIntent(intent);
- // Add preference to the settings menu.
- securityCategory.addPreference(trustAgentPreference);
-
- trustAgentPreference.setDisabledByAdmin(agent.admin);
- if (!trustAgentPreference.isDisabledByAdmin() && !hasSecurity) {
- trustAgentPreference.setEnabled(false);
- trustAgentPreference.setSummary(R.string.disabled_because_no_backup_security);
- }
- }
- return agents.size();
- }
-
- /* Return true if a there is a Slot that has Icc.
- */
- private boolean isSimIccReady() {
- TelephonyManager tm = TelephonyManager.getDefault();
- final List<SubscriptionInfo> subInfoList =
- mSubscriptionManager.getActiveSubscriptionInfoList();
-
- if (subInfoList != null) {
- for (SubscriptionInfo subInfo : subInfoList) {
- if (tm.hasIccCard(subInfo.getSimSlotIndex())) {
- return true;
- }
- }
- }
-
- return false;
- }
-
- /* Return true if a SIM is ready for locking.
- * TODO: consider adding to TelephonyManager or SubscritpionManasger.
- */
- private boolean isSimReady() {
- int simState = TelephonyManager.SIM_STATE_UNKNOWN;
- final List<SubscriptionInfo> subInfoList =
- mSubscriptionManager.getActiveSubscriptionInfoList();
- if (subInfoList != null) {
- for (SubscriptionInfo subInfo : subInfoList) {
- simState = TelephonyManager.getDefault().getSimState(subInfo.getSimSlotIndex());
- if((simState != TelephonyManager.SIM_STATE_ABSENT) &&
- (simState != TelephonyManager.SIM_STATE_UNKNOWN)){
- return true;
- }
- }
- }
- return false;
- }
-
- @Override
- public void onGearClick(GearPreference p) {
- if (KEY_UNLOCK_SET_OR_CHANGE.equals(p.getKey())) {
- startFragment(this, ScreenLockSettings.class.getName(), 0, 0, null);
- }
- }
-
- @Override
- public void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- if (mTrustAgentClickIntent != null) {
- outState.putParcelable(TRUST_AGENT_CLICK_INTENT, mTrustAgentClickIntent);
- }
- }
-
- @Override
- public void onResume() {
- super.onResume();
-
- // Make sure we reload the preference hierarchy since some of these settings
- // depend on others...
- createPreferenceHierarchy();
-
- if (mVisiblePatternProfile != null) {
- mVisiblePatternProfile.setChecked(mLockPatternUtils.isVisiblePatternEnabled(
- mProfileChallengeUserId));
- }
-
- updateUnificationPreference();
-
- if (mShowPassword != null) {
- mShowPassword.setChecked(Settings.System.getInt(getContentResolver(),
- Settings.System.TEXT_SHOW_PASSWORD, 1) != 0);
- }
-
- mLocationcontroller.updateSummary();
- }
-
- @VisibleForTesting
- void updateUnificationPreference() {
- if (mUnifyProfile != null) {
- final boolean separate =
- mLockPatternUtils.isSeparateProfileChallengeEnabled(mProfileChallengeUserId);
- mUnifyProfile.setChecked(!separate);
- if (separate) {
- mUnifyProfile.setDisabledByAdmin(RestrictedLockUtils.checkIfRestrictionEnforced(
- getContext(), UserManager.DISALLOW_UNIFIED_PASSWORD,
- mProfileChallengeUserId));
- }
- }
- }
-
- @Override
- public boolean onPreferenceTreeClick(Preference preference) {
- final String key = preference.getKey();
- if (KEY_UNLOCK_SET_OR_CHANGE.equals(key)) {
- // TODO(b/35930129): Remove once existing password can be passed into vold directly.
- // Currently we need this logic to ensure that the QUIET_MODE is off for any work
- // profile with unified challenge on FBE-enabled devices. Otherwise, vold would not be
- // able to complete the operation due to the lack of (old) encryption key.
- if (mProfileChallengeUserId != UserHandle.USER_NULL
- && !mLockPatternUtils.isSeparateProfileChallengeEnabled(mProfileChallengeUserId)
- && StorageManager.isFileEncryptedNativeOnly()) {
- if (Utils.startQuietModeDialogIfNecessary(this.getActivity(), mUm,
- mProfileChallengeUserId)) {
- return false;
- }
- }
- startFragment(this, ChooseLockGenericFragment.class.getName(),
- R.string.lock_settings_picker_title, SET_OR_CHANGE_LOCK_METHOD_REQUEST, null);
- } else if (KEY_UNLOCK_SET_OR_CHANGE_PROFILE.equals(key)) {
- if (Utils.startQuietModeDialogIfNecessary(this.getActivity(), mUm,
- mProfileChallengeUserId)) {
- return false;
- }
- Bundle extras = new Bundle();
- extras.putInt(Intent.EXTRA_USER_ID, mProfileChallengeUserId);
- startFragment(this, ChooseLockGenericFragment.class.getName(),
- R.string.lock_settings_picker_title_profile,
- SET_OR_CHANGE_LOCK_METHOD_REQUEST_PROFILE, extras);
- } else if (KEY_TRUST_AGENT.equals(key)) {
- ChooseLockSettingsHelper helper =
- new ChooseLockSettingsHelper(this.getActivity(), this);
- mTrustAgentClickIntent = preference.getIntent();
- boolean confirmationLaunched = helper.launchConfirmationActivity(
- CHANGE_TRUST_AGENT_SETTINGS, preference.getTitle());
- if (!confirmationLaunched&& mTrustAgentClickIntent != null) {
- // If this returns false, it means no password confirmation is required.
- startActivity(mTrustAgentClickIntent);
- mTrustAgentClickIntent = null;
- }
- } else {
- // If we didn't handle it, let preferences handle it.
- return super.onPreferenceTreeClick(preference);
- }
- return true;
- }
-
- /**
- * see confirmPatternThenDisableAndClear
- */
- @Override
- public void onActivityResult(int requestCode, int resultCode, Intent data) {
- super.onActivityResult(requestCode, resultCode, data);
- if (requestCode == CHANGE_TRUST_AGENT_SETTINGS && resultCode == Activity.RESULT_OK) {
- if (mTrustAgentClickIntent != null) {
- startActivity(mTrustAgentClickIntent);
- mTrustAgentClickIntent = null;
- }
- return;
- } else if (requestCode == UNIFY_LOCK_CONFIRM_DEVICE_REQUEST
- && resultCode == Activity.RESULT_OK) {
- mCurrentDevicePassword =
- data.getStringExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
- launchConfirmProfileLockForUnification();
- return;
- } else if (requestCode == UNIFY_LOCK_CONFIRM_PROFILE_REQUEST
- && resultCode == Activity.RESULT_OK) {
- mCurrentProfilePassword =
- data.getStringExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
- unifyLocks();
- return;
- } else if (requestCode == UNUNIFY_LOCK_CONFIRM_DEVICE_REQUEST
- && resultCode == Activity.RESULT_OK) {
- ununifyLocks();
- return;
- }
- createPreferenceHierarchy();
- }
-
- private void launchConfirmDeviceLockForUnification() {
- final String title = getActivity().getString(
- R.string.unlock_set_unlock_launch_picker_title);
- final ChooseLockSettingsHelper helper =
- new ChooseLockSettingsHelper(getActivity(), this);
- if (!helper.launchConfirmationActivity(
- UNIFY_LOCK_CONFIRM_DEVICE_REQUEST, title, true, MY_USER_ID)) {
- launchConfirmProfileLockForUnification();
- }
- }
-
- private void launchConfirmProfileLockForUnification() {
- final String title = getActivity().getString(
- R.string.unlock_set_unlock_launch_picker_title_profile);
- final ChooseLockSettingsHelper helper =
- new ChooseLockSettingsHelper(getActivity(), this);
- if (!helper.launchConfirmationActivity(
- UNIFY_LOCK_CONFIRM_PROFILE_REQUEST, title, true, mProfileChallengeUserId)) {
- unifyLocks();
- createPreferenceHierarchy();
- }
- }
-
- private void unifyLocks() {
- int profileQuality =
- mLockPatternUtils.getKeyguardStoredPasswordQuality(mProfileChallengeUserId);
- if (profileQuality == DevicePolicyManager.PASSWORD_QUALITY_SOMETHING) {
- mLockPatternUtils.saveLockPattern(
- LockPatternUtils.stringToPattern(mCurrentProfilePassword),
- mCurrentDevicePassword, MY_USER_ID);
- } else {
- mLockPatternUtils.saveLockPassword(
- mCurrentProfilePassword, mCurrentDevicePassword,
- profileQuality, MY_USER_ID);
- }
- mLockPatternUtils.setSeparateProfileChallengeEnabled(mProfileChallengeUserId, false,
- mCurrentProfilePassword);
- final boolean profilePatternVisibility =
- mLockPatternUtils.isVisiblePatternEnabled(mProfileChallengeUserId);
- mLockPatternUtils.setVisiblePatternEnabled(profilePatternVisibility, MY_USER_ID);
- mCurrentDevicePassword = null;
- mCurrentProfilePassword = null;
- }
-
- private void unifyUncompliantLocks() {
- mLockPatternUtils.setSeparateProfileChallengeEnabled(mProfileChallengeUserId, false,
- mCurrentProfilePassword);
- startFragment(this, ChooseLockGenericFragment.class.getName(),
- R.string.lock_settings_picker_title, SET_OR_CHANGE_LOCK_METHOD_REQUEST, null);
- }
-
- private void ununifyLocks() {
- Bundle extras = new Bundle();
- extras.putInt(Intent.EXTRA_USER_ID, mProfileChallengeUserId);
- startFragment(this,
- ChooseLockGenericFragment.class.getName(),
- R.string.lock_settings_picker_title_profile,
- SET_OR_CHANGE_LOCK_METHOD_REQUEST_PROFILE, extras);
- }
-
- @Override
- public boolean onPreferenceChange(Preference preference, Object value) {
- boolean result = true;
- final String key = preference.getKey();
- final LockPatternUtils lockPatternUtils = mChooseLockSettingsHelper.utils();
- if (KEY_VISIBLE_PATTERN_PROFILE.equals(key)) {
- if (Utils.startQuietModeDialogIfNecessary(this.getActivity(), mUm,
- mProfileChallengeUserId)) {
- return false;
- }
- lockPatternUtils.setVisiblePatternEnabled((Boolean) value, mProfileChallengeUserId);
- } else if (KEY_UNIFICATION.equals(key)) {
- if (Utils.startQuietModeDialogIfNecessary(this.getActivity(), mUm,
- mProfileChallengeUserId)) {
- return false;
- }
- if ((Boolean) value) {
- final boolean compliantForDevice =
- (mLockPatternUtils.getKeyguardStoredPasswordQuality(mProfileChallengeUserId)
- >= DevicePolicyManager.PASSWORD_QUALITY_SOMETHING
- && mLockPatternUtils.isSeparateProfileChallengeAllowedToUnify(
- mProfileChallengeUserId));
- UnificationConfirmationDialog dialog =
- UnificationConfirmationDialog.newIntance(compliantForDevice);
- dialog.show(getChildFragmentManager(), TAG_UNIFICATION_DIALOG);
- } else {
- final String title = getActivity().getString(
- R.string.unlock_set_unlock_launch_picker_title);
- final ChooseLockSettingsHelper helper =
- new ChooseLockSettingsHelper(getActivity(), this);
- if(!helper.launchConfirmationActivity(
- UNUNIFY_LOCK_CONFIRM_DEVICE_REQUEST, title, true, MY_USER_ID)) {
- ununifyLocks();
- }
- }
- } else if (KEY_SHOW_PASSWORD.equals(key)) {
- Settings.System.putInt(getContentResolver(), Settings.System.TEXT_SHOW_PASSWORD,
- ((Boolean) value) ? 1 : 0);
- lockPatternUtils.setVisiblePasswordEnabled((Boolean) value, MY_USER_ID);
- }
- return result;
+ protected String getLogTag() {
+ return TAG;
}
@Override
@@ -758,206 +76,95 @@
return R.string.help_url_security;
}
+ @Override
+ protected List<AbstractPreferenceController> getPreferenceControllers(Context context) {
+ return buildPreferenceControllers(context, getLifecycle(), this /* host*/);
+ }
+
+ /**
+ * see confirmPatternThenDisableAndClear
+ */
+ @Override
+ public void onActivityResult(int requestCode, int resultCode, Intent data) {
+ if (getPreferenceController(TrustAgentListPreferenceController.class)
+ .handleActivityResult(requestCode, resultCode)) {
+ return;
+ }
+ if (getPreferenceController(LockUnificationPreferenceController.class)
+ .handleActivityResult(requestCode, resultCode, data)) {
+ return;
+ }
+ super.onActivityResult(requestCode, resultCode, data);
+ }
+
+ void launchConfirmDeviceLockForUnification() {
+ getPreferenceController(LockUnificationPreferenceController.class)
+ .launchConfirmDeviceLockForUnification();
+ }
+
+ void unifyUncompliantLocks() {
+ getPreferenceController(LockUnificationPreferenceController.class).unifyUncompliantLocks();
+ }
+
+ void updateUnificationPreference() {
+ getPreferenceController(LockUnificationPreferenceController.class).updateState(null);
+ }
+
+ private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
+ Lifecycle lifecycle, SecuritySettings host) {
+ final List<AbstractPreferenceController> controllers = new ArrayList<>();
+ controllers.add(new LocationPreferenceController(context, lifecycle));
+ controllers.add(new ManageDeviceAdminPreferenceController(context));
+ controllers.add(new EnterprisePrivacyPreferenceController(context));
+ controllers.add(new ManageTrustAgentsPreferenceController(context));
+ controllers.add(new ScreenPinningPreferenceController(context));
+ controllers.add(new SimLockPreferenceController(context));
+ controllers.add(new ShowPasswordPreferenceController(context));
+ controllers.add(new FingerprintStatusPreferenceController(context));
+ controllers.add(new EncryptionStatusPreferenceController(context,
+ PREF_KEY_ENCRYPTION_SECURITY_PAGE));
+ controllers.add(new TrustAgentListPreferenceController(context, host, lifecycle));
+ controllers.add(new LockScreenPreferenceController(context, lifecycle));
+ controllers.add(new ChangeScreenLockPreferenceController(context, host));
+
+ final List<AbstractPreferenceController> profileSecurityControllers = new ArrayList<>();
+ profileSecurityControllers.add(new ChangeProfileScreenLockPreferenceController(
+ context, host));
+ profileSecurityControllers.add(new LockUnificationPreferenceController(context, host));
+ profileSecurityControllers.add(new VisiblePatternProfilePreferenceController(
+ context, lifecycle));
+ profileSecurityControllers.add(new FingerprintProfileStatusPreferenceController(context));
+ controllers.add(new PreferenceCategoryController(context, "security_category_profile",
+ profileSecurityControllers));
+ controllers.addAll(profileSecurityControllers);
+
+ return controllers;
+ }
+
/**
* For Search. Please keep it in sync when updating "createPreferenceHierarchy()"
*/
public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
- new SecuritySearchIndexProvider();
+ new BaseSearchIndexProvider() {
- private static class SecuritySearchIndexProvider extends BaseSearchIndexProvider {
-
- // TODO (b/68001777) Refactor indexing to include all XML and block other settings.
-
- @Override
- public List<SearchIndexableResource> getXmlResourcesToIndex(
- Context context, boolean enabled) {
- final List<SearchIndexableResource> index = new ArrayList<>();
-
- final LockPatternUtils lockPatternUtils = new LockPatternUtils(context);
- final ManagedLockPasswordProvider managedPasswordProvider =
- ManagedLockPasswordProvider.get(context, MY_USER_ID);
- final DevicePolicyManager dpm = (DevicePolicyManager)
- context.getSystemService(Context.DEVICE_POLICY_SERVICE);
- final UserManager um = UserManager.get(context);
- final int profileUserId = Utils.getManagedProfileId(um, MY_USER_ID);
-
- // To add option for unlock screen, user's password must not be managed and
- // must not be unified with managed profile, whose password is managed.
- if (!isPasswordManaged(MY_USER_ID, context, dpm)
- && (profileUserId == UserHandle.USER_NULL
- || lockPatternUtils.isSeparateProfileChallengeAllowed(profileUserId)
- || !isPasswordManaged(profileUserId, context, dpm))) {
- // Add options for lock/unlock screen
- final int resId = getResIdForLockUnlockScreen(lockPatternUtils,
- managedPasswordProvider, MY_USER_ID);
- index.add(getSearchResource(context, resId));
- }
-
- if (profileUserId != UserHandle.USER_NULL
- && lockPatternUtils.isSeparateProfileChallengeAllowed(profileUserId)
- && !isPasswordManaged(profileUserId, context, dpm)) {
- index.add(getSearchResource(context, getResIdForLockUnlockScreen(
- lockPatternUtils, managedPasswordProvider, profileUserId)));
- }
-
- // Append the rest of the settings
- index.add(getSearchResource(context, R.xml.security_settings_misc));
-
- return index;
- }
-
- private SearchIndexableResource getSearchResource(Context context, int xmlResId) {
- final SearchIndexableResource sir = new SearchIndexableResource(context);
- sir.xmlResId = xmlResId;
- return sir;
- }
-
- private boolean isPasswordManaged(int userId, Context context, DevicePolicyManager dpm) {
- final EnforcedAdmin admin = RestrictedLockUtils.checkIfPasswordQualityIsSet(
- context, userId);
- return admin != null && dpm.getPasswordQuality(admin.component, userId) ==
- DevicePolicyManager.PASSWORD_QUALITY_MANAGED;
- }
-
- @Override
- public List<SearchIndexableRaw> getRawDataToIndex(Context context, boolean enabled) {
- final List<SearchIndexableRaw> result = new ArrayList<SearchIndexableRaw>();
- final Resources res = context.getResources();
-
- final String screenTitle = res.getString(R.string.security_settings_title);
-
- SearchIndexableRaw data = new SearchIndexableRaw(context);
- data.title = screenTitle;
- data.key = "security_settings_screen";
- data.screenTitle = screenTitle;
- result.add(data);
-
- final UserManager um = UserManager.get(context);
-
- // Fingerprint
- final FingerprintManager fpm = Utils.getFingerprintManagerOrNull(context);
- if (fpm != null && fpm.isHardwareDetected()) {
- // This catches the title which can be overloaded in an overlay
- data = new SearchIndexableRaw(context);
- data.title = res.getString(R.string.security_settings_fingerprint_preference_title);
- data.key = "security_fingerprint";
- data.screenTitle = screenTitle;
- result.add(data);
- // Fallback for when the above doesn't contain "fingerprint"
- data = new SearchIndexableRaw(context);
- data.title = res.getString(R.string.fingerprint_manage_category_title);
- data.key = "security_managed_fingerprint";
- data.screenTitle = screenTitle;
- result.add(data);
- }
-
- final LockPatternUtils lockPatternUtils = new LockPatternUtils(context);
- final int profileUserId = Utils.getManagedProfileId(um, MY_USER_ID);
- if (profileUserId != UserHandle.USER_NULL
- && lockPatternUtils.isSeparateProfileChallengeAllowed(profileUserId)) {
- if (lockPatternUtils.getKeyguardStoredPasswordQuality(profileUserId)
- >= DevicePolicyManager.PASSWORD_QUALITY_SOMETHING
- && lockPatternUtils.isSeparateProfileChallengeAllowedToUnify(
- profileUserId)) {
- data = new SearchIndexableRaw(context);
- data.title = res.getString(R.string.lock_settings_profile_unification_title);
- data.key = "security_use_one_lock";
- data.screenTitle = screenTitle;
- result.add(data);
+ @Override
+ public List<SearchIndexableResource> getXmlResourcesToIndex(
+ Context context, boolean enabled) {
+ final List<SearchIndexableResource> index = new ArrayList<>();
+ // Append the rest of the settings
+ final SearchIndexableResource sir = new SearchIndexableResource(context);
+ sir.xmlResId = R.xml.security_dashboard_settings;
+ index.add(sir);
+ return index;
}
- }
- return result;
- }
- @Override
- public List<String> getNonIndexableKeys(Context context) {
- final List<String> keys = super.getNonIndexableKeys(context);
-
- LockPatternUtils lockPatternUtils = new LockPatternUtils(context);
-
- // Do not display SIM lock for devices without an Icc card
- final UserManager um = UserManager.get(context);
- final TelephonyManager tm = TelephonyManager.from(context);
- if (!um.isAdminUser() || !tm.hasIccCard()) {
- keys.add(KEY_SIM_LOCK);
- }
-
- // TrustAgent settings disappear when the user has no primary security.
- if (!lockPatternUtils.isSecure(MY_USER_ID)) {
- keys.add(KEY_TRUST_AGENT);
- keys.add(KEY_MANAGE_TRUST_AGENTS);
- }
-
- if (!(new EnterprisePrivacyPreferenceController(context))
- .isAvailable()) {
- 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;
- }
- }
-
- public static class UnificationConfirmationDialog extends InstrumentedDialogFragment {
- private static final String EXTRA_COMPLIANT = "compliant";
-
- public static UnificationConfirmationDialog newIntance(boolean compliant) {
- UnificationConfirmationDialog dialog = new UnificationConfirmationDialog();
- Bundle args = new Bundle();
- args.putBoolean(EXTRA_COMPLIANT, compliant);
- dialog.setArguments(args);
- return dialog;
- }
-
- @Override
- public void show(FragmentManager manager, String tag) {
- if (manager.findFragmentByTag(tag) == null) {
- // Prevent opening multiple dialogs if tapped on button quickly
- super.show(manager, tag);
- }
- }
-
- @Override
- public Dialog onCreateDialog(Bundle savedInstanceState) {
- final SecuritySettings parentFragment = ((SecuritySettings) getParentFragment());
- final boolean compliant = getArguments().getBoolean(EXTRA_COMPLIANT);
- return new AlertDialog.Builder(getActivity())
- .setTitle(R.string.lock_settings_profile_unification_dialog_title)
- .setMessage(compliant ? R.string.lock_settings_profile_unification_dialog_body
- : R.string.lock_settings_profile_unification_dialog_uncompliant_body)
- .setPositiveButton(
- compliant ? R.string.lock_settings_profile_unification_dialog_confirm
- : R.string.lock_settings_profile_unification_dialog_uncompliant_confirm,
- (dialog, whichButton) -> {
- if (compliant) {
- parentFragment.launchConfirmDeviceLockForUnification();
- } else {
- parentFragment.unifyUncompliantLocks();
- }
- }
- )
- .setNegativeButton(R.string.cancel, null)
- .create();
- }
-
- @Override
- public void onDismiss(DialogInterface dialog) {
- super.onDismiss(dialog);
- ((SecuritySettings) getParentFragment()).updateUnificationPreference();
- }
-
- @Override
- public int getMetricsCategory() {
- return MetricsEvent.DIALOG_UNIFICATION_CONFIRMATION;
- }
- }
+ @Override
+ public List<AbstractPreferenceController> getPreferenceControllers(Context
+ context) {
+ return buildPreferenceControllers(context, null /* lifecycle */,
+ null /* host*/);
+ }
+ };
static class SummaryProvider implements SummaryLoader.SummaryProvider {
@@ -973,13 +180,13 @@
public void setListening(boolean listening) {
if (listening) {
final FingerprintManager fpm =
- Utils.getFingerprintManagerOrNull(mContext);
+ Utils.getFingerprintManagerOrNull(mContext);
if (fpm != null && fpm.isHardwareDetected()) {
mSummaryLoader.setSummary(this,
- mContext.getString(R.string.security_dashboard_summary));
+ mContext.getString(R.string.security_dashboard_summary));
} else {
mSummaryLoader.setSummary(this, mContext.getString(
- R.string.security_dashboard_summary_no_fingerprint));
+ R.string.security_dashboard_summary_no_fingerprint));
}
}
}
@@ -987,11 +194,10 @@
public static final SummaryLoader.SummaryProviderFactory SUMMARY_PROVIDER_FACTORY =
new SummaryLoader.SummaryProviderFactory() {
- @Override
- public SummaryLoader.SummaryProvider createSummaryProvider(Activity activity,
- SummaryLoader summaryLoader) {
- return new SummaryProvider(activity, summaryLoader);
- }
- };
-
+ @Override
+ public SummaryLoader.SummaryProvider createSummaryProvider(Activity activity,
+ SummaryLoader summaryLoader) {
+ return new SummaryProvider(activity, summaryLoader);
+ }
+ };
}
diff --git a/src/com/android/settings/security/SecuritySettingsV2.java b/src/com/android/settings/security/SecuritySettingsV2.java
deleted file mode 100644
index 323c0f4..0000000
--- a/src/com/android/settings/security/SecuritySettingsV2.java
+++ /dev/null
@@ -1,188 +0,0 @@
-package com.android.settings.security;
-
-import static com.android.settings.security.EncryptionStatusPreferenceController
- .PREF_KEY_ENCRYPTION_SECURITY_PAGE;
-
-import android.app.Activity;
-import android.content.Context;
-import android.content.Intent;
-import android.hardware.fingerprint.FingerprintManager;
-import android.provider.SearchIndexableResource;
-
-import com.android.internal.logging.nano.MetricsProto;
-import com.android.settings.R;
-import com.android.settings.Utils;
-import com.android.settings.dashboard.DashboardFragment;
-import com.android.settings.dashboard.SummaryLoader;
-import com.android.settings.enterprise.EnterprisePrivacyPreferenceController;
-import com.android.settings.enterprise.ManageDeviceAdminPreferenceController;
-import com.android.settings.fingerprint.FingerprintProfileStatusPreferenceController;
-import com.android.settings.fingerprint.FingerprintStatusPreferenceController;
-import com.android.settings.location.LocationPreferenceController;
-import com.android.settings.search.BaseSearchIndexProvider;
-import com.android.settings.security.screenlock.LockScreenPreferenceController;
-import com.android.settings.security.trustagent.ManageTrustAgentsPreferenceController;
-import com.android.settings.security.trustagent.TrustAgentListPreferenceController;
-import com.android.settings.widget.PreferenceCategoryController;
-import com.android.settingslib.core.AbstractPreferenceController;
-import com.android.settingslib.core.lifecycle.Lifecycle;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class SecuritySettingsV2 extends DashboardFragment {
-
- private static final String TAG = "SecuritySettingsV2";
-
- public static final int SET_OR_CHANGE_LOCK_METHOD_REQUEST = 123;
- public static final int CHANGE_TRUST_AGENT_SETTINGS = 126;
- public static final int SET_OR_CHANGE_LOCK_METHOD_REQUEST_PROFILE = 127;
- public static final int UNIFY_LOCK_CONFIRM_DEVICE_REQUEST = 128;
- public static final int UNIFY_LOCK_CONFIRM_PROFILE_REQUEST = 129;
- public static final int UNUNIFY_LOCK_CONFIRM_DEVICE_REQUEST = 130;
-
- @Override
- public int getMetricsCategory() {
- return MetricsProto.MetricsEvent.SECURITY;
- }
-
- @Override
- protected int getPreferenceScreenResId() {
- return R.xml.security_settings_v2;
- }
-
- @Override
- protected String getLogTag() {
- return TAG;
- }
-
- @Override
- public int getHelpResource() {
- return R.string.help_url_security;
- }
-
- @Override
- protected List<AbstractPreferenceController> getPreferenceControllers(Context context) {
- return buildPreferenceControllers(context, getLifecycle(), this /* host*/);
- }
-
- /**
- * see confirmPatternThenDisableAndClear
- */
- @Override
- public void onActivityResult(int requestCode, int resultCode, Intent data) {
- if (getPreferenceController(TrustAgentListPreferenceController.class)
- .handleActivityResult(requestCode, resultCode)) {
- return;
- }
- if (getPreferenceController(LockUnificationPreferenceController.class)
- .handleActivityResult(requestCode, resultCode, data)) {
- return;
- }
- super.onActivityResult(requestCode, resultCode, data);
- }
-
- void launchConfirmDeviceLockForUnification() {
- getPreferenceController(LockUnificationPreferenceController.class)
- .launchConfirmDeviceLockForUnification();
- }
-
- void unifyUncompliantLocks() {
- getPreferenceController(LockUnificationPreferenceController.class).unifyUncompliantLocks();
- }
-
- void updateUnificationPreference() {
- getPreferenceController(LockUnificationPreferenceController.class).updateState(null);
- }
-
- private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
- Lifecycle lifecycle, SecuritySettingsV2 host) {
- final List<AbstractPreferenceController> controllers = new ArrayList<>();
- controllers.add(new LocationPreferenceController(context, lifecycle));
- controllers.add(new ManageDeviceAdminPreferenceController(context));
- controllers.add(new EnterprisePrivacyPreferenceController(context));
- controllers.add(new ManageTrustAgentsPreferenceController(context));
- controllers.add(new ScreenPinningPreferenceController(context));
- controllers.add(new SimLockPreferenceController(context));
- controllers.add(new ShowPasswordPreferenceController(context));
- controllers.add(new FingerprintStatusPreferenceController(context));
- controllers.add(new EncryptionStatusPreferenceController(context,
- PREF_KEY_ENCRYPTION_SECURITY_PAGE));
- controllers.add(new TrustAgentListPreferenceController(context, host, lifecycle));
- controllers.add(new LockScreenPreferenceController(context, lifecycle));
- controllers.add(new ChangeScreenLockPreferenceController(context, host));
-
- final List<AbstractPreferenceController> profileSecurityControllers = new ArrayList<>();
- profileSecurityControllers.add(new ChangeProfileScreenLockPreferenceController(
- context, host));
- profileSecurityControllers.add(new LockUnificationPreferenceController(context, host));
- profileSecurityControllers.add(new VisiblePatternProfilePreferenceController(
- context, lifecycle));
- profileSecurityControllers.add(new FingerprintProfileStatusPreferenceController(context));
- controllers.add(new PreferenceCategoryController(context, "security_category_profile",
- profileSecurityControllers));
- controllers.addAll(profileSecurityControllers);
-
- return controllers;
- }
-
- /**
- * For Search. Please keep it in sync when updating "createPreferenceHierarchy()"
- */
- public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
- new BaseSearchIndexProvider() {
-
- @Override
- public List<SearchIndexableResource> getXmlResourcesToIndex(
- Context context, boolean enabled) {
- final List<SearchIndexableResource> index = new ArrayList<>();
- // Append the rest of the settings
- final SearchIndexableResource sir = new SearchIndexableResource(context);
- sir.xmlResId = R.xml.security_settings_v2;
- index.add(sir);
- return index;
- }
-
- @Override
- public List<AbstractPreferenceController> getPreferenceControllers(Context
- context) {
- return buildPreferenceControllers(context, null /* lifecycle */,
- null /* host*/);
- }
- };
-
- static class SummaryProvider implements SummaryLoader.SummaryProvider {
-
- private final Context mContext;
- private final SummaryLoader mSummaryLoader;
-
- public SummaryProvider(Context context, SummaryLoader summaryLoader) {
- mContext = context;
- mSummaryLoader = summaryLoader;
- }
-
- @Override
- public void setListening(boolean listening) {
- if (listening) {
- final FingerprintManager fpm =
- Utils.getFingerprintManagerOrNull(mContext);
- if (fpm != null && fpm.isHardwareDetected()) {
- mSummaryLoader.setSummary(this,
- mContext.getString(R.string.security_dashboard_summary));
- } else {
- mSummaryLoader.setSummary(this, mContext.getString(
- R.string.security_dashboard_summary_no_fingerprint));
- }
- }
- }
- }
-
- public static final SummaryLoader.SummaryProviderFactory SUMMARY_PROVIDER_FACTORY =
- new SummaryLoader.SummaryProviderFactory() {
- @Override
- public SummaryLoader.SummaryProvider createSummaryProvider(Activity activity,
- SummaryLoader summaryLoader) {
- return new SummaryProvider(activity, summaryLoader);
- }
- };
-}
diff --git a/src/com/android/settings/security/UnificationConfirmationDialog.java b/src/com/android/settings/security/UnificationConfirmationDialog.java
index 482e268..029e64f 100644
--- a/src/com/android/settings/security/UnificationConfirmationDialog.java
+++ b/src/com/android/settings/security/UnificationConfirmationDialog.java
@@ -40,7 +40,7 @@
return dialog;
}
- public void show(SecuritySettingsV2 host) {
+ public void show(SecuritySettings host) {
final FragmentManager manager = host.getChildFragmentManager();
if (manager.findFragmentByTag(TAG_UNIFICATION_DIALOG) == null) {
// Prevent opening multiple dialogs if tapped on button quickly
@@ -50,7 +50,7 @@
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
- final SecuritySettingsV2 parentFragment = ((SecuritySettingsV2) getParentFragment());
+ final SecuritySettings parentFragment = ((SecuritySettings) getParentFragment());
final boolean compliant = getArguments().getBoolean(EXTRA_COMPLIANT);
return new AlertDialog.Builder(getActivity())
.setTitle(R.string.lock_settings_profile_unification_dialog_title)
@@ -75,7 +75,7 @@
@Override
public void onDismiss(DialogInterface dialog) {
super.onDismiss(dialog);
- ((SecuritySettingsV2) getParentFragment()).updateUnificationPreference();
+ ((SecuritySettings) getParentFragment()).updateUnificationPreference();
}
@Override
diff --git a/src/com/android/settings/security/trustagent/TrustAgentListPreferenceController.java b/src/com/android/settings/security/trustagent/TrustAgentListPreferenceController.java
index 0c591ed..ec81aad 100644
--- a/src/com/android/settings/security/trustagent/TrustAgentListPreferenceController.java
+++ b/src/com/android/settings/security/trustagent/TrustAgentListPreferenceController.java
@@ -16,7 +16,7 @@
package com.android.settings.security.trustagent;
-import static com.android.settings.security.SecuritySettingsV2.CHANGE_TRUST_AGENT_SETTINGS;
+import static com.android.settings.security.SecuritySettings.CHANGE_TRUST_AGENT_SETTINGS;
import android.app.Activity;
import android.content.Context;
@@ -35,7 +35,7 @@
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.password.ChooseLockSettingsHelper;
import com.android.settings.security.SecurityFeatureProvider;
-import com.android.settings.security.SecuritySettingsV2;
+import com.android.settings.security.SecuritySettings;
import com.android.settingslib.RestrictedPreference;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.core.lifecycle.Lifecycle;
@@ -59,12 +59,12 @@
private final LockPatternUtils mLockPatternUtils;
private final TrustAgentManager mTrustAgentManager;
- private final SecuritySettingsV2 mHost;
+ private final SecuritySettings mHost;
private Intent mTrustAgentClickIntent;
private PreferenceCategory mSecurityCategory;
- public TrustAgentListPreferenceController(Context context, SecuritySettingsV2 host,
+ public TrustAgentListPreferenceController(Context context, SecuritySettings host,
Lifecycle lifecycle) {
super(context);
final SecurityFeatureProvider provider = FeatureFactory.getFactory(context)
diff --git a/tests/robotests/assets/grandfather_not_in_search_index_provider_registry b/tests/robotests/assets/grandfather_not_in_search_index_provider_registry
index 6a831b0..666b224 100644
--- a/tests/robotests/assets/grandfather_not_in_search_index_provider_registry
+++ b/tests/robotests/assets/grandfather_not_in_search_index_provider_registry
@@ -1,3 +1,2 @@
com.android.settings.display.ScreenZoomPreferenceFragmentForSetupWizard
-com.android.settings.search.indexing.FakeSettingsFragment
-com.android.settings.security.SecuritySettings
\ No newline at end of file
+com.android.settings.search.indexing.FakeSettingsFragment
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/core/XmlControllerAttributeTest.java b/tests/robotests/src/com/android/settings/core/XmlControllerAttributeTest.java
index e6ca59b..e69b97e 100644
--- a/tests/robotests/src/com/android/settings/core/XmlControllerAttributeTest.java
+++ b/tests/robotests/src/com/android/settings/core/XmlControllerAttributeTest.java
@@ -19,7 +19,6 @@
import com.android.settings.search.SearchFeatureProviderImpl;
import com.android.settings.search.XmlParserUtils;
import com.android.settings.security.SecuritySettings;
-import com.android.settings.security.SecuritySettingsV2;
import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
@@ -32,7 +31,6 @@
import org.xmlpull.v1.XmlPullParser;
import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -47,25 +45,13 @@
// List of classes that are too hard to mock in order to retrieve xml information.
private final List<Class> illegalClasses = new ArrayList<>(
Arrays.asList(
- SecuritySettings.class,
- SecuritySettingsV2.class
+ SecuritySettings.class
));
// List of XML that could be retrieved from the illegalClasses list.
private final List<Integer> whitelistXml = new ArrayList<>(
Arrays.asList(
- R.xml.security_settings_misc,
- R.xml.security_settings_lockscreen_profile,
- R.xml.security_settings_lockscreen,
- R.xml.security_settings_chooser,
- R.xml.security_settings_pattern_profile,
- R.xml.security_settings_pin_profile,
- R.xml.security_settings_password_profile,
- R.xml.security_settings_pattern,
- R.xml.security_settings_pin,
- R.xml.security_settings_password,
- R.xml.security_settings,
- R.xml.security_settings_status
+ R.xml.security_dashboard_settings
));
private static final String NO_VALID_CONSTRUCTOR_ERROR =
diff --git a/tests/robotests/src/com/android/settings/security/LockUnificationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/security/LockUnificationPreferenceControllerTest.java
index 7a5a9fa..2b612e1 100644
--- a/tests/robotests/src/com/android/settings/security/LockUnificationPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/security/LockUnificationPreferenceControllerTest.java
@@ -55,7 +55,7 @@
@Mock
private PreferenceScreen mScreen;
@Mock
- private SecuritySettingsV2 mHost;
+ private SecuritySettings mHost;
private FakeFeatureFactory mFeatureFactory;
private Context mContext;
diff --git a/tests/robotests/src/com/android/settings/security/SecurityFeatureProviderImplTest.java b/tests/robotests/src/com/android/settings/security/SecurityFeatureProviderImplTest.java
index 627ecf5..86ba40f 100644
--- a/tests/robotests/src/com/android/settings/security/SecurityFeatureProviderImplTest.java
+++ b/tests/robotests/src/com/android/settings/security/SecurityFeatureProviderImplTest.java
@@ -16,192 +16,51 @@
package com.android.settings.security;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyInt;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyNoMoreInteractions;
-import static org.mockito.Mockito.when;
+import static com.google.common.truth.Truth.assertThat;
import android.content.Context;
-import android.content.Intent;
import android.content.pm.PackageManager;
-import android.content.res.Resources;
-import android.graphics.drawable.Drawable;
-import android.os.Bundle;
-import android.support.v7.preference.Preference;
-import android.support.v7.preference.PreferenceScreen;
-import com.android.settings.R;
+import com.android.internal.widget.LockPatternUtils;
import com.android.settings.TestConfig;
+import com.android.settings.security.trustagent.TrustAgentManager;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settings.testutils.shadow.ShadowTileUtils;
-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.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
-import org.robolectric.shadows.ShadowLooper;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
public class SecurityFeatureProviderImplTest {
- private static final String MOCK_KEY = "key";
- private static final String MOCK_SUMMARY = "summary";
- private static final String URI_GET_SUMMARY = "content://package/text/summary";
- private static final String URI_GET_ICON = "content://package/icon/my_icon";
-
- @Mock
- private Drawable mMockDrawable;
- @Mock
private Context mContext;
- @Mock
- private PackageManager mPackageManager;
- @Mock
- private Resources mResources;
-
private SecurityFeatureProviderImpl mImpl;
@Before
public void setUp() throws PackageManager.NameNotFoundException {
MockitoAnnotations.initMocks(this);
- mContext = spy(RuntimeEnvironment.application);
+ mContext = RuntimeEnvironment.application;
mImpl = new SecurityFeatureProviderImpl();
- when(mContext.getPackageManager()).thenReturn(mPackageManager);
- when(mPackageManager.getResourcesForApplication(anyString())).thenReturn(mResources);
- when(mResources.getDrawable(anyInt(), any())).thenReturn(mMockDrawable);
}
@Test
- public void updateTilesData_shouldNotProcessEmptyScreenOrTiles() {
- mImpl.updatePreferencesToRunOnWorkerThread(mContext, null, null);
- ShadowLooper.runUiThreadTasks();
- mImpl.updatePreferencesToRunOnWorkerThread(
- mContext, new PreferenceScreen(mContext, null), null);
- ShadowLooper.runUiThreadTasks();
- verifyNoMoreInteractions(mPackageManager);
+ public void getTrustAgentManager_shouldReturnCache() {
+ final TrustAgentManager m1 = mImpl.getTrustAgentManager();
+ final TrustAgentManager m2 = mImpl.getTrustAgentManager();
+
+ assertThat(m1).isSameAs(m2);
}
@Test
- public void updateTilesData_shouldNotProcessNonMatchingPreference() {
- DashboardCategory dashboardCategory = new DashboardCategory();
- dashboardCategory.addTile(new Tile());
- mImpl.updatePreferencesToRunOnWorkerThread(
- mContext, getPreferenceScreen(), dashboardCategory);
- ShadowLooper.runUiThreadTasks();
- verifyNoMoreInteractions(mPackageManager);
+ public void getLockPatternUtils_shouldReturnCache() {
+ final LockPatternUtils l1 = mImpl.getLockPatternUtils(mContext);
+ final LockPatternUtils l2 = mImpl.getLockPatternUtils(mContext);
+
+ assertThat(l1).isSameAs(l2);
}
- @Test
- public void updateTilesData_shouldNotProcessMatchingPreferenceWithNoData() {
- mImpl.updatePreferencesToRunOnWorkerThread(
- mContext, getPreferenceScreen(), getDashboardCategory());
- ShadowLooper.runUiThreadTasks();
- verifyNoMoreInteractions(mPackageManager);
- }
-
- @Test
- @Config(shadows = {
- ShadowTileUtils.class,
- })
- public void updateTilesData_shouldUpdateMatchingPreference() {
- Bundle bundle = new Bundle();
- bundle.putString(TileUtils.META_DATA_PREFERENCE_ICON_URI, URI_GET_ICON);
- bundle.putString(TileUtils.META_DATA_PREFERENCE_SUMMARY_URI, URI_GET_SUMMARY);
-
- PreferenceScreen screen = getPreferenceScreen();
- DashboardCategory dashboardCategory = getDashboardCategory();
- dashboardCategory.getTile(0).intent = new Intent().setPackage("package");
- dashboardCategory.getTile(0).metaData = bundle;
-
- mImpl.updatePreferencesToRunOnWorkerThread(mContext, screen, dashboardCategory);
- ShadowLooper.runUiThreadTasks();
- verify(screen.findPreference(MOCK_KEY)).setIcon(mMockDrawable);
- verify(screen.findPreference(MOCK_KEY)).setSummary(MOCK_SUMMARY);
- }
-
- @Test
- @Config(shadows = {
- ShadowTileUtils.class,
- })
- public void updateTilesData_shouldNotUpdateAlreadyUpdatedPreference() {
- Bundle bundle = new Bundle();
- bundle.putString(TileUtils.META_DATA_PREFERENCE_ICON_URI, URI_GET_ICON);
- bundle.putString(TileUtils.META_DATA_PREFERENCE_SUMMARY_URI, URI_GET_SUMMARY);
-
- PreferenceScreen screen = getPreferenceScreen();
- when(screen.findPreference(MOCK_KEY).getSummary()).thenReturn(MOCK_SUMMARY);
- when(screen.findPreference(MOCK_KEY).getIcon()).thenReturn(mMockDrawable);
-
- DashboardCategory dashboardCategory = getDashboardCategory();
- dashboardCategory.getTile(0).intent = new Intent().setPackage("package");
- dashboardCategory.getTile(0).metaData = bundle;
-
- mImpl.updatePreferencesToRunOnWorkerThread(mContext, screen, dashboardCategory);
- ShadowLooper.runUiThreadTasks();
- verify(screen.findPreference(MOCK_KEY), never()).setSummary(anyString());
- }
-
- @Test
- public void initPreferences_shouldLoadDefaults() {
- PreferenceScreen screen = getPreferenceScreen();
- DashboardCategory dashboardCategory = getDashboardCategory();
- dashboardCategory.getTile(0).metaData = new Bundle();
-
- mImpl.initPreferences(mContext, screen, dashboardCategory);
- verify(screen.findPreference(MOCK_KEY)).setIcon(SecurityFeatureProviderImpl.DEFAULT_ICON);
- verify(screen.findPreference(MOCK_KEY))
- .setSummary(mContext.getString(R.string.summary_placeholder));
- }
-
- @Test
- @Config(shadows = {
- ShadowTileUtils.class,
- })
- public void initPreferences_shouldLoadCached() {
- Bundle bundle = new Bundle();
- bundle.putString(TileUtils.META_DATA_PREFERENCE_ICON_URI, URI_GET_ICON);
- bundle.putString(TileUtils.META_DATA_PREFERENCE_SUMMARY_URI, URI_GET_SUMMARY);
-
- PreferenceScreen screen = getPreferenceScreen();
- DashboardCategory dashboardCategory = getDashboardCategory();
- dashboardCategory.getTile(0).metaData = bundle;
-
- SecurityFeatureProviderImpl.sIconCache.put(
- URI_GET_ICON,
- ShadowTileUtils.getIconFromUri(null, null, null, null));
- SecurityFeatureProviderImpl.sSummaryCache.put(
- URI_GET_SUMMARY,
- MOCK_SUMMARY);
-
- mImpl.initPreferences(mContext, screen, dashboardCategory);
- verify(screen.findPreference(MOCK_KEY)).setIcon(mMockDrawable);
- verify(screen.findPreference(MOCK_KEY)).setSummary(MOCK_SUMMARY);
- }
-
- private PreferenceScreen getPreferenceScreen() {
- final PreferenceScreen screen = mock(PreferenceScreen.class);
- final Preference pref = mock(Preference.class);
- when(screen.findPreference(MOCK_KEY)).thenReturn(pref);
- when(pref.getKey()).thenReturn(MOCK_KEY);
- return screen;
- }
-
- private static DashboardCategory getDashboardCategory() {
- DashboardCategory dashboardCategory = new DashboardCategory();
- Tile tile = new Tile();
- tile.key = MOCK_KEY;
- dashboardCategory.addTile(tile);
- return dashboardCategory;
- }
}
diff --git a/tests/robotests/src/com/android/settings/security/SecuritySettingsTest.java b/tests/robotests/src/com/android/settings/security/SecuritySettingsTest.java
index 3171c3d..421efe8 100644
--- a/tests/robotests/src/com/android/settings/security/SecuritySettingsTest.java
+++ b/tests/robotests/src/com/android/settings/security/SecuritySettingsTest.java
@@ -16,34 +16,18 @@
package com.android.settings.security;
-import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Matchers.anyInt;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.reset;
-import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
-import android.app.Activity;
import android.content.Context;
-import android.os.UserHandle;
-import android.os.UserManager;
-import android.os.UserManager.EnforcingUser;
-import android.support.v7.preference.Preference;
-import android.support.v7.preference.PreferenceScreen;
+import android.content.pm.PackageManager;
+import android.hardware.fingerprint.FingerprintManager;
-import com.android.internal.widget.LockPatternUtils;
import com.android.settings.R;
import com.android.settings.TestConfig;
import com.android.settings.dashboard.SummaryLoader;
-import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settings.testutils.XmlTestUtils;
-import com.android.settings.testutils.shadow.ShadowLockPatternUtils;
-import com.android.settings.testutils.shadow.ShadowUserManager;
-import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
-import com.android.settingslib.RestrictedSwitchPreference;
import org.junit.Before;
import org.junit.Test;
@@ -51,123 +35,65 @@
import org.mockito.Answers;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
-import org.robolectric.shadows.ShadowApplication;
-import org.robolectric.util.ReflectionHelpers;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
- shadows = {
- ShadowLockPatternUtils.class,
- ShadowUserManager.class,
- })
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
public class SecuritySettingsTest {
-
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private Context mContext;
@Mock
private SummaryLoader mSummaryLoader;
-
+ @Mock
+ private FingerprintManager mFingerprintManager;
private SecuritySettings.SummaryProvider mSummaryProvider;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- FakeFeatureFactory.setupForTest();
+ when(mContext.getSystemService(Context.FINGERPRINT_SERVICE))
+ .thenReturn(mFingerprintManager);
+
mSummaryProvider = new SecuritySettings.SummaryProvider(mContext, mSummaryLoader);
}
@Test
- public void testInitTrustAgentPreference_secure_shouldSetSummaryToNumberOfTrustAgent() {
- final Preference preference = mock(Preference.class);
- final PreferenceScreen screen = mock(PreferenceScreen.class);
- when(screen.findPreference(SecuritySettings.KEY_MANAGE_TRUST_AGENTS))
- .thenReturn(preference);
- final LockPatternUtils utils = mock(LockPatternUtils.class);
- when(utils.isSecure(anyInt())).thenReturn(true);
- final Context context = ShadowApplication.getInstance().getApplicationContext();
- final Activity activity = mock(Activity.class);
- when(activity.getResources()).thenReturn(context.getResources());
- final SecuritySettings securitySettings = spy(new SecuritySettings());
- when(securitySettings.getActivity()).thenReturn(activity);
+ public void testSummaryProvider_notListening() {
+ mSummaryProvider.setListening(false);
- ReflectionHelpers.setField(securitySettings, "mLockPatternUtils", utils);
-
- securitySettings.initTrustAgentPreference(screen, 0);
- verify(preference).setSummary(R.string.manage_trust_agents_summary);
-
- securitySettings.initTrustAgentPreference(screen, 2);
- verify(preference).setSummary(context.getResources().getQuantityString(
- R.plurals.manage_trust_agents_summary_on, 2, 2));
+ verifyNoMoreInteractions(mSummaryLoader);
}
@Test
- 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);
+ public void testSummaryProvider_hasFingerPrint_hasStaticSummary() {
+ when(mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FINGERPRINT))
+ .thenReturn(true);
+ when(mFingerprintManager.isHardwareDetected()).thenReturn(true);
- 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));
+ mSummaryProvider.setListening(true);
- assertThat(keys).containsAllIn(niks);
+ verify(mContext).getString(R.string.security_dashboard_summary);
}
@Test
- public void testUnifyLockRestriction() {
- // Set up instance under test.
- final Context context = spy(RuntimeEnvironment.application);
- final SecuritySettings securitySettings = spy(new SecuritySettings());
- when(securitySettings.getContext()).thenReturn(context);
+ public void testSummaryProvider_noFpFeature_shouldSetSummaryWithNoFingerprint() {
+ when(mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FINGERPRINT))
+ .thenReturn(false);
- final int userId = 123;
- ReflectionHelpers.setField(securitySettings, "mProfileChallengeUserId", userId);
+ mSummaryProvider.setListening(true);
- final LockPatternUtils utils = mock(LockPatternUtils.class);
- when(utils.isSeparateProfileChallengeEnabled(userId)).thenReturn(true);
- ReflectionHelpers.setField(securitySettings, "mLockPatternUtils", utils);
+ verify(mContext).getString(R.string.security_dashboard_summary_no_fingerprint);
+ }
- final RestrictedSwitchPreference unifyProfile = mock(RestrictedSwitchPreference.class);
- ReflectionHelpers.setField(securitySettings, "mUnifyProfile", unifyProfile);
+ @Test
+ public void testSummaryProvider_noFpHardware_shouldSetSummaryWithNoFingerprint() {
+ when(mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FINGERPRINT))
+ .thenReturn(true);
+ when(mFingerprintManager.isHardwareDetected()).thenReturn(false);
- // Pretend that no admins enforce the restriction.
- ShadowUserManager.getShadow().setUserRestrictionSources(
- UserManager.DISALLOW_UNIFIED_PASSWORD,
- UserHandle.of(userId),
- Collections.emptyList());
+ mSummaryProvider.setListening(true);
- securitySettings.updateUnificationPreference();
-
- verify(unifyProfile).setDisabledByAdmin(null);
-
- reset(unifyProfile);
-
- // Pretend that the restriction is enforced by several admins. Having just one would
- // require more mocking of implementation details.
- final EnforcingUser enforcer1 = new EnforcingUser(
- userId, UserManager.RESTRICTION_SOURCE_PROFILE_OWNER);
- final EnforcingUser enforcer2 = new EnforcingUser(
- UserHandle.USER_SYSTEM, UserManager.RESTRICTION_SOURCE_DEVICE_OWNER);
- ShadowUserManager.getShadow().setUserRestrictionSources(
- UserManager.DISALLOW_UNIFIED_PASSWORD,
- UserHandle.of(userId),
- Arrays.asList(enforcer1, enforcer2));
-
- securitySettings.updateUnificationPreference();
-
- verify(unifyProfile).setDisabledByAdmin(EnforcedAdmin.MULTIPLE_ENFORCED_ADMIN);
+ verify(mContext).getString(R.string.security_dashboard_summary_no_fingerprint);
}
}
diff --git a/tests/robotests/src/com/android/settings/security/SecuritySettingsV2Test.java b/tests/robotests/src/com/android/settings/security/SecuritySettingsV2Test.java
deleted file mode 100644
index f77903b..0000000
--- a/tests/robotests/src/com/android/settings/security/SecuritySettingsV2Test.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright (C) 2018 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.security;
-
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyNoMoreInteractions;
-import static org.mockito.Mockito.when;
-
-import android.content.Context;
-import android.content.pm.PackageManager;
-import android.hardware.fingerprint.FingerprintManager;
-
-import com.android.settings.R;
-import com.android.settings.TestConfig;
-import com.android.settings.dashboard.SummaryLoader;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-
-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.annotation.Config;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
-public class SecuritySettingsV2Test {
-
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private Context mContext;
- @Mock
- private SummaryLoader mSummaryLoader;
- @Mock
- private FingerprintManager mFingerprintManager;
- private SecuritySettings.SummaryProvider mSummaryProvider;
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
- when(mContext.getSystemService(Context.FINGERPRINT_SERVICE))
- .thenReturn(mFingerprintManager);
-
- mSummaryProvider = new SecuritySettings.SummaryProvider(mContext, mSummaryLoader);
- }
-
- @Test
- public void testSummaryProvider_notListening() {
- mSummaryProvider.setListening(false);
-
- verifyNoMoreInteractions(mSummaryLoader);
- }
-
- @Test
- public void testSummaryProvider_hasFingerPrint_hasStaticSummary() {
- when(mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FINGERPRINT))
- .thenReturn(true);
- when(mFingerprintManager.isHardwareDetected()).thenReturn(true);
-
- mSummaryProvider.setListening(true);
-
- verify(mContext).getString(R.string.security_dashboard_summary);
- }
-
- @Test
- public void testSummaryProvider_noFpFeature_shouldSetSummaryWithNoFingerprint() {
- when(mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FINGERPRINT))
- .thenReturn(false);
-
- mSummaryProvider.setListening(true);
-
- verify(mContext).getString(R.string.security_dashboard_summary_no_fingerprint);
- }
-
- @Test
- public void testSummaryProvider_noFpHardware_shouldSetSummaryWithNoFingerprint() {
- when(mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FINGERPRINT))
- .thenReturn(true);
- when(mFingerprintManager.isHardwareDetected()).thenReturn(false);
-
- mSummaryProvider.setListening(true);
-
- verify(mContext).getString(R.string.security_dashboard_summary_no_fingerprint);
- }
-}
diff --git a/tests/robotests/src/com/android/settings/security/trustagent/TrustAgentListPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/security/trustagent/TrustAgentListPreferenceControllerTest.java
index 7dd04c6..258833e 100644
--- a/tests/robotests/src/com/android/settings/security/trustagent/TrustAgentListPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/security/trustagent/TrustAgentListPreferenceControllerTest.java
@@ -40,7 +40,7 @@
import com.android.internal.widget.LockPatternUtils;
import com.android.settings.TestConfig;
import com.android.settings.core.PreferenceControllerMixin;
-import com.android.settings.security.SecuritySettingsV2;
+import com.android.settings.security.SecuritySettings;
import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settingslib.core.lifecycle.Lifecycle;
@@ -69,7 +69,7 @@
@Mock
private PreferenceCategory mCategory;
@Mock
- private SecuritySettingsV2 mFragment;
+ private SecuritySettings mFragment;
private Lifecycle mLifecycle;
private LifecycleOwner mLifecycleOwner;
diff --git a/tests/uitests/src/com/android/settings/ui/SecuritySettingsLaunchTest.java b/tests/uitests/src/com/android/settings/ui/SecuritySettingsLaunchTest.java
index b730690..6803c7e 100644
--- a/tests/uitests/src/com/android/settings/ui/SecuritySettingsLaunchTest.java
+++ b/tests/uitests/src/com/android/settings/ui/SecuritySettingsLaunchTest.java
@@ -66,7 +66,7 @@
public void launchSecuritySettings() throws Exception {
// Launch Settings
SettingsHelper.launchSettingsPage(
- InstrumentationRegistry.getContext(), Settings.ACTION_SECURITY_SETTINGS);
+ InstrumentationRegistry.getTargetContext(), Settings.ACTION_SECURITY_SETTINGS);
mHelper.scrollVert(false);
for (String category : CATEGORIES) {
SettingsTestUtils.assertTitleMatch(mDevice, category);