Merge "Refactor DefaultAppPicker to a general radio button picker"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 50ac95f..bc3679c 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -744,6 +744,10 @@
<string name="security_settings_title">Security & screen lock</string>
<!-- Security Settings screen setting option title for the item to take you to the encryption and credential screen -->
<string name="encryption_and_credential_settings_title">Encryption & credentials</string>
+ <!-- Security Settings screen setting option title for the item to take you to the lock screen preference screen [CHAR LIMIT=60] -->
+ <string name="lockscreen_settings_title">Lock screen preferences</string>
+ <!-- Security Settings screen setting option summary for the item to take you to the lock screen preference screen -->
+ <string name="lockscreen_settings_summary">Access settings in lock screen</string>
<!-- Main Settings screen setting option summary text for the item tot ake you to the security and location screen -->
<string name="security_settings_summary">Set My Location, screen unlock, SIM card lock, credential storage lock</string>
@@ -1593,11 +1597,11 @@
<!-- Checkbox title for option to notify user when open networks are nearby -->
<string name="wifi_notify_open_networks">Open network notification</string>
<!-- Checkbox summary for option to notify user when open networks are nearby-->
- <string name="wifi_notify_open_networks_summary">Notify when a high\u2011quality open network is available that may require sign\u2011in</string>
+ <string name="wifi_notify_open_networks_summary">Notify when a high\u2011quality public network is available</string>
<!-- Checkbox title for option to enable Wi-Fi when saved networks are nearby -->
- <string name="wifi_wakeup">Turn Wi\u2011Fi back on</string>
+ <string name="wifi_wakeup">Turn on Wi\u2011Fi automatically</string>
<!-- Checkbox summary for option to enable Wi-Fi when high quality saved networks are nearby-->
- <string name="wifi_wakeup_summary">Automatically turn on Wi\u2011Fi near high\u2011quality saved networks</string>
+ <string name="wifi_wakeup_summary">Wi\u2011Fi will turn back on near high\u2011quality saved networks, like your home network</string>
<!-- Checkbox title for option to toggle poor network detection -->
<string name="wifi_poor_network_detection">Avoid poor connections</string>
<!-- Checkbox summary for option to toggle poor network detection -->
@@ -1607,7 +1611,7 @@
<!-- Checkbox title for option to connect to open Wi-Fi automatically [CHAR LIMIT=40] -->
<string name="use_open_wifi_automatically_title">Connect to open networks</string>
<!-- Checkbox summary for option to connect to open Wi-Fi automatically [CHAR LIMIT=100] -->
- <string name="use_open_wifi_automatically_summary">Automatically connect to high\u2011quality open networks </string>
+ <string name="use_open_wifi_automatically_summary">Automatically connect to high\u2011quality public networks</string>
<!-- Preference title for option to install certificates -->
<string name="wifi_install_credentials">Install certificates</string>
<!-- Message to describe "Wi-Fi scan always available feature" when Wi-Fi is off. The
@@ -1643,6 +1647,10 @@
<string name="wifi_add_network">Add network</string>
<!-- Action bar title to open additional Wi-Fi settings-->
<string name="wifi_configure_settings_preference_title">Wi\u2011Fi preferences</string>
+ <!-- Summary for Wi-Fi Preferences that explains that Wi-Fi will be enabled when high quality saved networks are nearby-->
+ <string name="wifi_configure_settings_preference_summary_wakeup_on">Wi\u2011Fi turns back on automatically</string>
+ <!-- Summary for Wi-Fi Preferences that explains that Wi-Fi will not automatically be enabled when high quality saved networks are nearby-->
+ <string name="wifi_configure_settings_preference_summary_wakeup_off">Wi\u2011Fi doesn\u0027t turn back on automatically</string>
<!-- Header for the list of wifi networks-->
<string name="wifi_access_points">Wi\u2011Fi networks</string>
<!-- Menu option to do WPS Push Button [CHAR LIMIT=25]-->
@@ -1828,6 +1836,11 @@
<!-- Wi-Fi Advanced Settings --> <skip />
<!-- Wi-Fi settings screen, Saved networks, settings section. This is a header shown above Saved networks wifi settings. [CHAR LIMIT=30] -->
<string name="wifi_saved_access_points_titlebar">Saved networks</string>
+ <!-- Wi-Fi settings screen, Saved networks summary. This shows below the "Saved networks" item and indicates the number of networks a user has saved. -->
+ <plurals name="wifi_saved_access_points_summary">
+ <item quantity="one">1 network</item>
+ <item quantity="other">%d networks</item>
+ </plurals>
<!-- Wi-Fi settings screen, advanced, settings section. This is a header shown above advanced wifi settings. [CHAR LIMIT=30] -->
<string name="wifi_advanced_titlebar">Advanced Wi\u2011Fi</string>
<!-- Wi-Fi settings screen, configure, settings section. This is a header shown above configure wifi settings. [CHAR LIMIT=30] -->
@@ -2704,7 +2717,7 @@
\n\nTo see the visible contents of this <xliff:g id="name" example="SD card">^1</xliff:g>, tap Explore.</string>
<!-- Body of dialog informing user about the storage used by the Android System [CHAR LIMIT=NONE]-->
- <string name="storage_detail_dialog_system">System includes files that Android can\u2019t display individually.</string>
+ <string name="storage_detail_dialog_system">System includes files used to run Android version <xliff:g id="version" example="8.0">%s</xliff:g></string>
<!-- Body of dialog informing user about other users on a storage device [CHAR LIMIT=NONE]-->
<string name="storage_detail_dialog_user"><xliff:g id="user" example="Guest user">^1</xliff:g> may have saved photos, music, apps, or other data, using <xliff:g id="size" example="1.2 GB">^2</xliff:g> of storage.
@@ -3044,7 +3057,7 @@
<string name="sms_change_default_no_previous_dialog_text" translatable="true">Use <xliff:g id="new_app">%s</xliff:g> as your SMS app?</string>
<!-- Network Scorer Picker title [CHAR LIMIT=40]-->
- <string name="network_scorer_picker_title">Network Rating Provider</string>
+ <string name="network_scorer_picker_title">Network rating provider</string>
<string name="network_scorer_picker_none_preference">None</string>
<!-- Wifi Assistant change wi-fi assistant title. [CHAR LIMIT=40] -->
@@ -6288,28 +6301,34 @@
<string name="work_use_personal_sounds_title">Use personal profile sounds</string>
<!-- Work Sound: Summary for the switch that enables syncing of personal ringtones to work profile. [CHAR LIMIT=160] -->
- <string name="work_use_personal_sounds_summary">Work profile sounds are the same as personal profile</string>
+ <string name="work_use_personal_sounds_summary">Sounds are the same for work and personal profiles</string>
<!-- Work Sounds: Title for the option defining the work phone ringtone. [CHAR LIMIT=60] -->
<string name="work_ringtone_title">Work phone ringtone</string>
<!-- Work Sounds: Title for the option defining the default work notification ringtone. [CHAR LIMIT=60] -->
- <string name="work_notification_ringtone_title">Default work notification tone</string>
+ <string name="work_notification_ringtone_title">Default work notification sound</string>
<!-- Work Sound: Title for the option defining the default work alarm ringtone. [CHAR LIMIT=60] -->
- <string name="work_alarm_ringtone_title">Default work alarm ringtone</string>
+ <string name="work_alarm_ringtone_title">Default work alarm sound</string>
<!-- Work Sound: Summary for sounds when sync with personal sounds is active [CHAR LIMIT=60] -->
<string name="work_sound_same_as_personal">Same as personal profile</string>
<!-- Work Sound: Title for dialog shown when enabling sync with personal sounds. [CHAR LIMIT=60] -->
- <string name="work_sync_dialog_title">Use personal profile sounds?</string>
+ <string name="work_sync_dialog_title">Replace sounds?</string>
<!-- Work Sound: Confirm action text for dialog shown when overriding work notification sounds with personal sounds. [CHAR LIMIT=30] -->
<string name="work_sync_dialog_yes">Replace</string>
<!-- Work Sound: Message for dialog shown when using the same sounds for work events as for personal events (notifications / ringtones / alarms). [CHAR LIMIT=none] -->
- <string name="work_sync_dialog_message">Your personal profile sounds will be used instead of your current work profile sounds</string>
+ <string name="work_sync_dialog_message">Your personal profile sounds will be used for your work profile</string>
+
+ <!-- Sound installation: Title for the dialog to confirm that a new sound will be installed to the Ringtones, Notifications, or Alarms folder. [CHAR LIMIT=50] -->
+ <string name="ringtones_install_custom_sound_title">Add custom sound?</string>
+
+ <!-- Sound installation: Message for the dialog to confirm that a new sound will be installed to the Ringtones, Notifications, or Alarms folder. [CHAR LIMIT=none] -->
+ <string name="ringtones_install_custom_sound_content">This file will be copied to the <xliff:g id="folder_name" example="Ringtones">%s</xliff:g> folder</string>
<!-- Ringtones preference category: Title for the Ringotnes preference categories. [CHAR LIMIT=none] -->
<string name="ringtones_category_preference_title">Ringtones</string>
@@ -8226,16 +8245,6 @@
<string name="enterprise_privacy_enterprise_data">Data associated with your work account, such as email and calendar</string>
<!-- Label explaining that the admin can see apps installed on the device. [CHAR LIMIT=NONE] -->
<string name="enterprise_privacy_installed_packages">List of apps on your device</string>
- <!-- Summary indicating the number of apps that a label (e.g. installed apps or apps granted a particular permission) refers to. [CHAR LIMIT=NONE] -->
- <plurals name="enterprise_privacy_number_packages">
- <item quantity="one"><xliff:g id="count">%d</xliff:g> app</item>
- <item quantity="other"><xliff:g id="count">%d</xliff:g> apps</item>
- </plurals>
- <!-- Summary indicating the number of apps that a label (e.g. installed apps or apps granted a particular permission) refers to. [CHAR LIMIT=NONE] -->
- <plurals name="enterprise_privacy_number_packages_actionable">
- <item quantity="one"><xliff:g id="count">%d</xliff:g> app. Tap to view.</item>
- <item quantity="other"><xliff:g id="count">%d</xliff:g> apps. Tap to view.</item>
- </plurals>
<!-- Label explaining that the admin can see app usage statistics. [CHAR LIMIT=NONE] -->
<string name="enterprise_privacy_usage_stats">Time and data spent in each app on your device</string>
<!-- Label explaining that the admin can retrieve network logs on the device. [CHAR LIMIT=NONE] -->
@@ -8248,6 +8257,11 @@
<string name="enterprise_privacy_none">None</string>
<!-- Label indicating that the admin installed one or more apps on the device. -->
<string name="enterprise_privacy_enterprise_installed_packages">Apps installed</string>
+ <!-- Summary indicating the number of apps that a label (e.g. installed apps or apps granted a particular permission) refers to. The number shown is a minimum as there may be additional apps we do not know about. [CHAR LIMIT=NONE] -->
+ <plurals name="enterprise_privacy_number_packages_lower_bound">
+ <item quantity="one">Minimum <xliff:g id="count">%d</xliff:g> app</item>
+ <item quantity="other">Minimum <xliff:g id="count">%d</xliff:g> apps</item>
+ </plurals>
<!-- Label indicating that the admin granted one or more apps access to the device's location. [CHAR LIMIT=NONE] -->
<string name="enterprise_privacy_location_access">Location permissions</string>
<!-- Label indicating that the admin granted one or more apps access to the microphone. [CHAR LIMIT=NONE] -->
@@ -8256,6 +8270,11 @@
<string name="enterprise_privacy_camera_access">Camera permissions</string>
<!-- Label indicating that the admin set one or more apps as defaults for common actions (e.g. open browser, send e-mail). [CHAR LIMIT=NONE] -->
<string name="enterprise_privacy_enterprise_set_default_apps">Default apps</string>
+ <!-- Summary indicating the number of apps that a label (e.g. installed apps or apps granted a particular permission) refers to. [CHAR LIMIT=NONE] -->
+ <plurals name="enterprise_privacy_number_packages">
+ <item quantity="one"><xliff:g id="count">%d</xliff:g> app</item>
+ <item quantity="other"><xliff:g id="count">%d</xliff:g> apps</item>
+ </plurals>
<!-- Label explaining that the current input method was set by the admin. [CHAR LIMIT=NONE] -->
<string name="enterprise_privacy_input_method">Default keyboard</string>
<!-- Summary indicating the input method set by the admin. [CHAR LIMIT=NONE] -->
@@ -8270,15 +8289,10 @@
<string name="enterprise_privacy_global_http_proxy">Global HTTP proxy set</string>
<!-- Label explaining that the admin installed trusted CA certificates. [CHAR LIMIT=NONE] -->
<string name="enterprise_privacy_ca_certs">Trusted credentials</string>
- <!-- Summary indicating the number of trusted CA certificates installed by the admin. [CHAR LIMIT=NONE] -->
+ <!-- Summary indicating the number of trusted CA certificates installed by the admin. The number shown is a minimum as there may be additional CA certificates we do not know about. [CHAR LIMIT=NONE] -->
<plurals name="enterprise_privacy_number_ca_certs">
- <item quantity="one"><xliff:g id="count">%d</xliff:g> CA certificate</item>
- <item quantity="other"><xliff:g id="count">%d</xliff:g> CA certificates</item>
- </plurals>
- <!-- Summary indicating the number of trusted CA certificates installed by the admin. [CHAR LIMIT=NONE] -->
- <plurals name="enterprise_privacy_number_ca_certs_actionable">
- <item quantity="one"><xliff:g id="count">%d</xliff:g> CA certificate. Tap to view.</item>
- <item quantity="other"><xliff:g id="count">%d</xliff:g> CA certificates. Tap to view.</item>
+ <item quantity="one">Minimum <xliff:g id="count">%d</xliff:g> CA certificate</item>
+ <item quantity="other">Minimum <xliff:g id="count">%d</xliff:g> CA certificates</item>
</plurals>
<!-- Label explaining that the admin can lock the device and change the user's password. [CHAR LIMIT=NONE] -->
<string name="enterprise_privacy_lock_device">Admin can lock the device and reset password</string>
diff --git a/res/xml/security_lockscreen_settings.xml b/res/xml/security_lockscreen_settings.xml
new file mode 100644
index 0000000..e151b2b
--- /dev/null
+++ b/res/xml/security_lockscreen_settings.xml
@@ -0,0 +1,35 @@
+<?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/lockscreen_settings_title">
+
+ <com.android.settings.notification.RestrictedDropDownPreference
+ android:key="lock_screen_notifications"
+ android:title="@string/lock_screen_notifications_title"
+ android:summary="%s"/>
+
+ <com.android.settingslib.RestrictedSwitchPreference
+ android:key="add_users_when_locked"
+ android:title="@string/user_add_on_lockscreen_menu"/>
+
+ <com.android.settingslib.RestrictedPreference
+ android:key="owner_info_settings"
+ android:title="@string/owner_info_settings_title"
+ android:summary="@string/owner_info_settings_summary"/>
+
+</PreferenceScreen>
diff --git a/res/xml/security_settings_chooser.xml b/res/xml/security_settings_chooser.xml
index 6438771..dc6e727 100644
--- a/res/xml/security_settings_chooser.xml
+++ b/res/xml/security_settings_chooser.xml
@@ -29,6 +29,11 @@
settings:keywords="@string/keywords_lockscreen"
android:persistent="false"/>
+ <Preference android:key="lockscreen_preferences"
+ android:title="@string/lockscreen_settings_title"
+ android:summary="@string/lockscreen_settings_summary"
+ android:fragment="com.android.settings.security.LockscreenDashboardFragment"/>
+
</PreferenceCategory>
</PreferenceScreen>
diff --git a/res/xml/security_settings_password.xml b/res/xml/security_settings_password.xml
index 57f19eb..e3a5dfd 100644
--- a/res/xml/security_settings_password.xml
+++ b/res/xml/security_settings_password.xml
@@ -28,6 +28,11 @@
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:summary="@string/lockscreen_settings_summary"
+ android:fragment="com.android.settings.security.LockscreenDashboardFragment"/>
+
</PreferenceCategory>
</PreferenceScreen>
diff --git a/res/xml/security_settings_pattern.xml b/res/xml/security_settings_pattern.xml
index ad57e82..295e896 100644
--- a/res/xml/security_settings_pattern.xml
+++ b/res/xml/security_settings_pattern.xml
@@ -28,6 +28,11 @@
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:summary="@string/lockscreen_settings_summary"
+ android:fragment="com.android.settings.security.LockscreenDashboardFragment"/>
+
</PreferenceCategory>
</PreferenceScreen>
diff --git a/res/xml/security_settings_pin.xml b/res/xml/security_settings_pin.xml
index 31a57a2..5613177 100644
--- a/res/xml/security_settings_pin.xml
+++ b/res/xml/security_settings_pin.xml
@@ -28,6 +28,11 @@
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:summary="@string/lockscreen_settings_summary"
+ android:fragment="com.android.settings.security.LockscreenDashboardFragment"/>
+
</PreferenceCategory>
</PreferenceScreen>
diff --git a/src/com/android/settings/OwnerInfoSettings.java b/src/com/android/settings/OwnerInfoSettings.java
index 7314da3..18cfb8e 100644
--- a/src/com/android/settings/OwnerInfoSettings.java
+++ b/src/com/android/settings/OwnerInfoSettings.java
@@ -31,6 +31,7 @@
import com.android.internal.logging.nano.MetricsProto;
import com.android.internal.widget.LockPatternUtils;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
+import com.android.settings.security.OwnerInfoPreferenceController.OwnerInfoCallback;
public class OwnerInfoSettings extends InstrumentedDialogFragment implements OnClickListener {
@@ -76,8 +77,8 @@
mLockPatternUtils.setOwnerInfoEnabled(!TextUtils.isEmpty(info), mUserId);
mLockPatternUtils.setOwnerInfo(info, mUserId);
- if (getTargetFragment() instanceof SecuritySettings.SecuritySubSettings) {
- ((SecuritySettings.SecuritySubSettings) getTargetFragment()).updateOwnerInfo();
+ if (getTargetFragment() instanceof OwnerInfoCallback) {
+ ((OwnerInfoCallback) getTargetFragment()).onOwnerInfoUpdated();
}
}
}
diff --git a/src/com/android/settings/SecuritySettings.java b/src/com/android/settings/SecuritySettings.java
index 1cb763b..37022f0 100644
--- a/src/com/android/settings/SecuritySettings.java
+++ b/src/com/android/settings/SecuritySettings.java
@@ -16,7 +16,6 @@
package com.android.settings;
-
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
@@ -67,6 +66,7 @@
import com.android.settings.search.Indexable;
import com.android.settings.search.SearchIndexableRaw;
import com.android.settings.search2.SearchFeatureProvider;
+import com.android.settings.security.OwnerInfoPreferenceController;
import com.android.settings.security.SecurityFeatureProvider;
import com.android.settings.trustagent.TrustAgentManager;
import com.android.settings.widget.GearPreference;
@@ -917,11 +917,10 @@
}
public static class SecuritySubSettings extends SettingsPreferenceFragment
- implements OnPreferenceChangeListener {
+ implements OnPreferenceChangeListener, OwnerInfoPreferenceController.OwnerInfoCallback {
private static final String KEY_VISIBLE_PATTERN = "visiblepattern";
private static final String KEY_LOCK_AFTER_TIMEOUT = "lock_after_timeout";
- private static final String KEY_OWNER_INFO_SETTINGS = "owner_info_settings";
private static final String KEY_POWER_INSTANTLY_LOCKS = "power_button_instantly_locks";
// These switch preferences need special handling since they're not all stored in Settings.
@@ -931,11 +930,11 @@
private TimeoutListPreference mLockAfter;
private SwitchPreference mVisiblePattern;
private SwitchPreference mPowerButtonInstantlyLocks;
- private RestrictedPreference mOwnerInfoPref;
private TrustAgentManager mTrustAgentManager;
private LockPatternUtils mLockPatternUtils;
private DevicePolicyManager mDPM;
+ private OwnerInfoPreferenceController mOwnerInfoPreferenceController;
@Override
public int getMetricsCategory() {
@@ -950,6 +949,8 @@
mTrustAgentManager = securityFeatureProvider.getTrustAgentManager();
mLockPatternUtils = new LockPatternUtils(getContext());
mDPM = getContext().getSystemService(DevicePolicyManager.class);
+ mOwnerInfoPreferenceController =
+ new OwnerInfoPreferenceController(getContext(), this, null /* lifecycle */);
createPreferenceHierarchy();
}
@@ -968,7 +969,7 @@
mLockPatternUtils.getPowerButtonInstantlyLocks(MY_USER_ID));
}
- updateOwnerInfo();
+ mOwnerInfoPreferenceController.updateSummary();
}
@Override
@@ -1010,26 +1011,8 @@
trustAgentLabel));
}
- mOwnerInfoPref = (RestrictedPreference) findPreference(KEY_OWNER_INFO_SETTINGS);
- if (mOwnerInfoPref != null) {
- if (mLockPatternUtils.isDeviceOwnerInfoEnabled()) {
- EnforcedAdmin admin = RestrictedLockUtils.getDeviceOwner(getActivity());
- mOwnerInfoPref.setDisabledByAdmin(admin);
- } else {
- mOwnerInfoPref.setDisabledByAdmin(null);
- mOwnerInfoPref.setEnabled(!mLockPatternUtils.isLockScreenDisabled(MY_USER_ID));
- if (mOwnerInfoPref.isEnabled()) {
- mOwnerInfoPref.setOnPreferenceClickListener(
- new OnPreferenceClickListener() {
- @Override
- public boolean onPreferenceClick(Preference preference) {
- OwnerInfoSettings.show(SecuritySubSettings.this);
- return true;
- }
- });
- }
- }
- }
+ mOwnerInfoPreferenceController.displayPreference(getPreferenceScreen());
+ mOwnerInfoPreferenceController.updateEnableState();
for (int i = 0; i < SWITCH_PREFERENCE_KEYS.length; i++) {
final Preference pref = findPreference(SWITCH_PREFERENCE_KEYS[i]);
@@ -1093,17 +1076,9 @@
mLockAfter.setSummary(summary);
}
- public void updateOwnerInfo() {
- if (mOwnerInfoPref != null) {
- if (mLockPatternUtils.isDeviceOwnerInfoEnabled()) {
- mOwnerInfoPref.setSummary(
- mLockPatternUtils.getDeviceOwnerInfo());
- } else {
- mOwnerInfoPref.setSummary(mLockPatternUtils.isOwnerInfoEnabled(MY_USER_ID)
- ? mLockPatternUtils.getOwnerInfo(MY_USER_ID)
- : getString(R.string.owner_info_settings_summary));
- }
- }
+ @Override
+ public void onOwnerInfoUpdated() {
+ mOwnerInfoPreferenceController.updateSummary();
}
private static int getResIdForLockUnlockSubScreen(Context context,
diff --git a/src/com/android/settings/core/gateway/SettingsGateway.java b/src/com/android/settings/core/gateway/SettingsGateway.java
index 467b848..59cedf8 100644
--- a/src/com/android/settings/core/gateway/SettingsGateway.java
+++ b/src/com/android/settings/core/gateway/SettingsGateway.java
@@ -111,6 +111,7 @@
import com.android.settings.notification.ZenModeVisualInterruptionSettings;
import com.android.settings.print.PrintJobSettingsFragment;
import com.android.settings.print.PrintSettingsFragment;
+import com.android.settings.security.LockscreenDashboardFragment;
import com.android.settings.sim.SimSettings;
import com.android.settings.system.SystemDashboardFragment;
import com.android.settings.tts.TextToSpeechSettings;
@@ -242,6 +243,7 @@
UserAndAccountDashboardFragment.class.getName(),
EnterprisePrivacySettings.class.getName(),
WebViewAppPicker.class.getName(),
+ LockscreenDashboardFragment.class.getName(),
};
public static final String[] SETTINGS_FOR_RESTRICTED = {
diff --git a/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java b/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java
index 076ec05..9ddf7b7 100644
--- a/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java
+++ b/src/com/android/settings/deviceinfo/PrivateVolumeSettings.java
@@ -27,6 +27,7 @@
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.UserInfo;
+import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.UserHandle;
@@ -759,7 +760,8 @@
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
return new AlertDialog.Builder(getActivity())
- .setMessage(R.string.storage_detail_dialog_system)
+ .setMessage(getContext().getString(R.string.storage_detail_dialog_system,
+ Build.VERSION.RELEASE))
.setPositiveButton(android.R.string.ok, null)
.create();
}
diff --git a/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java b/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java
index eec9487..e22aa24 100644
--- a/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java
@@ -35,6 +35,7 @@
import com.android.settings.applications.ManageApplications;
import com.android.settings.core.PreferenceController;
import com.android.settings.core.instrumentation.MetricsFeatureProvider;
+import com.android.settings.deviceinfo.PrivateVolumeSettings.SystemInfoFragment;
import com.android.settings.deviceinfo.StorageItemPreference;
import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.deviceinfo.StorageMeasurement;
@@ -52,6 +53,7 @@
private static final String TAG = "StorageItemPreference";
private static final String IMAGE_MIME_TYPE = "image/*";
+ private static final String SYSTEM_FRAGMENT_TAG = "SystemInfo";
@VisibleForTesting
static final String PHOTO_KEY = "pref_photos_videos";
@@ -104,8 +106,6 @@
return false;
}
- // TODO: Currently, this reflects the existing behavior for these toggles.
- // After the intermediate views are built, swap them in.
Intent intent = null;
if (preference.getKey() == null) {
return false;
@@ -133,6 +133,11 @@
FeatureFactory.getFactory(mContext).getMetricsFeatureProvider().action(
mContext, MetricsEvent.STORAGE_FILES);
break;
+ case SYSTEM_KEY:
+ final SystemInfoFragment dialog = new SystemInfoFragment();
+ dialog.setTargetFragment(mFragment, 0);
+ dialog.show(mFragment.getFragmentManager(), SYSTEM_FRAGMENT_TAG);
+ return true;
}
if (intent != null) {
diff --git a/src/com/android/settings/enterprise/AdminGrantedPermissionsPreferenceControllerBase.java b/src/com/android/settings/enterprise/AdminGrantedPermissionsPreferenceControllerBase.java
index c60d7e0..0db9e15 100644
--- a/src/com/android/settings/enterprise/AdminGrantedPermissionsPreferenceControllerBase.java
+++ b/src/com/android/settings/enterprise/AdminGrantedPermissionsPreferenceControllerBase.java
@@ -53,7 +53,8 @@
} else {
preference.setVisible(true);
preference.setSummary(mContext.getResources().getQuantityString(
- R.plurals.enterprise_privacy_number_packages_actionable, num, num));
+ R.plurals.enterprise_privacy_number_packages_lower_bound,
+ num, num));
}
});
}
diff --git a/src/com/android/settings/enterprise/EnterpriseInstalledPackagesPreferenceController.java b/src/com/android/settings/enterprise/EnterpriseInstalledPackagesPreferenceController.java
index 93c1909..e70396d 100644
--- a/src/com/android/settings/enterprise/EnterpriseInstalledPackagesPreferenceController.java
+++ b/src/com/android/settings/enterprise/EnterpriseInstalledPackagesPreferenceController.java
@@ -50,7 +50,8 @@
} else {
preference.setVisible(true);
preference.setSummary(mContext.getResources().getQuantityString(
- R.plurals.enterprise_privacy_number_packages, num, num));
+ R.plurals.enterprise_privacy_number_packages_lower_bound, num,
+ num));
}
});
}
diff --git a/src/com/android/settings/search/SearchIndexableResources.java b/src/com/android/settings/search/SearchIndexableResources.java
index dd59e86..f88d830 100644
--- a/src/com/android/settings/search/SearchIndexableResources.java
+++ b/src/com/android/settings/search/SearchIndexableResources.java
@@ -70,6 +70,7 @@
import com.android.settings.notification.ZenModeSettings;
import com.android.settings.notification.ZenModeVisualInterruptionSettings;
import com.android.settings.print.PrintSettingsFragment;
+import com.android.settings.security.LockscreenDashboardFragment;
import com.android.settings.sim.SimSettings;
import com.android.settings.system.SystemDashboardFragment;
import com.android.settings.tts.TtsEnginePreferenceFragment;
@@ -170,6 +171,8 @@
addIndex(PaymentSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_nfc_payment);
addIndex(
TtsEnginePreferenceFragment.class, NO_DATA_RES_ID, R.drawable.ic_settings_language);
+ addIndex(LockscreenDashboardFragment.class, R.xml.security_lockscreen_settings,
+ R.drawable.ic_settings_security);
}
private SearchIndexableResources() {
diff --git a/src/com/android/settings/security/LockscreenDashboardFragment.java b/src/com/android/settings/security/LockscreenDashboardFragment.java
new file mode 100644
index 0000000..b781fbb
--- /dev/null
+++ b/src/com/android/settings/security/LockscreenDashboardFragment.java
@@ -0,0 +1,103 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.security;
+
+import android.content.Context;
+import android.provider.SearchIndexableResource;
+import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
+import com.android.settings.R;
+import com.android.settings.accounts.AddUserWhenLockedPreferenceController;
+import com.android.settings.core.PreferenceController;
+import com.android.settings.core.lifecycle.Lifecycle;
+import com.android.settings.dashboard.DashboardFragment;
+import com.android.settings.notification.LockScreenNotificationPreferenceController;
+import com.android.settings.search.BaseSearchIndexProvider;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * Settings screen for lock screen preference
+ */
+public class LockscreenDashboardFragment extends DashboardFragment
+ implements OwnerInfoPreferenceController.OwnerInfoCallback {
+
+ private static final String TAG = "LockscreenDashboardFragment";
+
+ private OwnerInfoPreferenceController mOwnerInfoPreferenceController;
+
+ @Override
+ public int getMetricsCategory() {
+ return MetricsEvent.SETTINGS_LOCK_SCREEN_PREFERENCES;
+ }
+
+ @Override
+ protected String getLogTag() {
+ return TAG;
+ }
+
+ @Override
+ protected int getPreferenceScreenResId() {
+ return R.xml.security_lockscreen_settings;
+ }
+
+ @Override
+ protected List<PreferenceController> getPreferenceControllers(Context context) {
+ final List<PreferenceController> controllers = new ArrayList<>();
+ final Lifecycle lifecycle = getLifecycle();
+ final LockScreenNotificationPreferenceController notificationController =
+ new LockScreenNotificationPreferenceController(context);
+ lifecycle.addObserver(notificationController);
+ controllers.add(notificationController);
+ final AddUserWhenLockedPreferenceController addUserWhenLockedController =
+ new AddUserWhenLockedPreferenceController(context);
+ lifecycle.addObserver(addUserWhenLockedController);
+ controllers.add(addUserWhenLockedController);
+ mOwnerInfoPreferenceController =
+ new OwnerInfoPreferenceController(context, this, lifecycle);
+ controllers.add(mOwnerInfoPreferenceController);
+ return controllers;
+ }
+
+ @Override
+ public void onOwnerInfoUpdated() {
+ if (mOwnerInfoPreferenceController != null) {
+ mOwnerInfoPreferenceController.updateSummary();
+ }
+ }
+
+ public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+ new BaseSearchIndexProvider() {
+ @Override
+ public List<SearchIndexableResource> getXmlResourcesToIndex(
+ Context context, boolean enabled) {
+ final SearchIndexableResource sir = new SearchIndexableResource(context);
+ sir.xmlResId = R.xml.security_lockscreen_settings;
+ return Arrays.asList(sir);
+ }
+
+ @Override
+ public List<PreferenceController> getPreferenceControllers(Context context) {
+ final List<PreferenceController> controllers = new ArrayList<>();
+ controllers.add(new LockScreenNotificationPreferenceController(context));
+ controllers.add(new AddUserWhenLockedPreferenceController(context));
+ controllers.add(new OwnerInfoPreferenceController(
+ context, null /* fragment */, null /* lifecycle */));
+ return controllers;
+ }
+ };
+}
diff --git a/src/com/android/settings/security/OwnerInfoPreferenceController.java b/src/com/android/settings/security/OwnerInfoPreferenceController.java
new file mode 100644
index 0000000..259ef12
--- /dev/null
+++ b/src/com/android/settings/security/OwnerInfoPreferenceController.java
@@ -0,0 +1,142 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.settings.security;
+
+import android.app.Fragment;
+import android.content.Context;
+import android.os.UserHandle;
+import android.support.annotation.VisibleForTesting;
+import android.support.v7.preference.Preference;
+import android.support.v7.preference.Preference.OnPreferenceClickListener;
+import android.support.v7.preference.PreferenceScreen;
+import com.android.internal.widget.LockPatternUtils;
+import com.android.settings.OwnerInfoSettings;
+import com.android.settings.core.PreferenceController;
+import com.android.settings.core.lifecycle.Lifecycle;
+import com.android.settings.core.lifecycle.LifecycleObserver;
+import com.android.settings.core.lifecycle.events.OnResume;
+import com.android.settingslib.RestrictedLockUtils;
+import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
+import com.android.settingslib.RestrictedPreference;
+
+public class OwnerInfoPreferenceController extends PreferenceController
+ implements LifecycleObserver, OnResume {
+
+ private static final String KEY_OWNER_INFO = "owner_info_settings";
+ private static final int MY_USER_ID = UserHandle.myUserId();
+
+ private final LockPatternUtils mLockPatternUtils;
+ private final Fragment mParent;
+ private RestrictedPreference mOwnerInfoPref;
+
+ // Container fragment should implement this in order to show the correct summary
+ public interface OwnerInfoCallback {
+ public void onOwnerInfoUpdated();
+ }
+
+ public OwnerInfoPreferenceController(Context context, Fragment parent, Lifecycle lifecycle ) {
+ super(context);
+ mParent = parent;
+ mLockPatternUtils = new LockPatternUtils(context);
+ if (lifecycle != null) {
+ lifecycle.addObserver(this);
+ }
+ }
+
+ @Override
+ public void displayPreference(PreferenceScreen screen) {
+ mOwnerInfoPref = (RestrictedPreference) screen.findPreference(KEY_OWNER_INFO);
+ }
+
+ @Override
+ public void onResume() {
+ updateEnableState();
+ updateSummary();
+ }
+
+ @Override
+ public boolean isAvailable() {
+ return true;
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return KEY_OWNER_INFO;
+ }
+
+ public void updateEnableState() {
+ if (mOwnerInfoPref == null) {
+ return;
+ }
+ if (isDeviceOwnerInfoEnabled()) {
+ EnforcedAdmin admin = getDeviceOwner();
+ mOwnerInfoPref.setDisabledByAdmin(admin);
+ } else {
+ mOwnerInfoPref.setDisabledByAdmin(null);
+ mOwnerInfoPref.setEnabled(!mLockPatternUtils.isLockScreenDisabled(MY_USER_ID));
+ if (mOwnerInfoPref.isEnabled()) {
+ mOwnerInfoPref.setOnPreferenceClickListener(
+ new OnPreferenceClickListener() {
+ @Override
+ public boolean onPreferenceClick(Preference preference) {
+ OwnerInfoSettings.show(mParent);
+ return true;
+ }
+ });
+ }
+ }
+ }
+
+ public void updateSummary() {
+ if (mOwnerInfoPref != null) {
+ if (isDeviceOwnerInfoEnabled()) {
+ mOwnerInfoPref.setSummary(
+ getDeviceOwnerInfo());
+ } else {
+ mOwnerInfoPref.setSummary(isOwnerInfoEnabled()
+ ? getOwnerInfo()
+ : mContext.getString(
+ com.android.settings.R.string.owner_info_settings_summary));
+ }
+ }
+ }
+
+ // Wrapper methods to allow testing
+ @VisibleForTesting
+ boolean isDeviceOwnerInfoEnabled() {
+ return mLockPatternUtils.isDeviceOwnerInfoEnabled();
+ }
+
+ @VisibleForTesting
+ String getDeviceOwnerInfo() {
+ return mLockPatternUtils.getDeviceOwnerInfo();
+ }
+
+ @VisibleForTesting
+ boolean isOwnerInfoEnabled() {
+ return mLockPatternUtils.isOwnerInfoEnabled(MY_USER_ID);
+ }
+
+ @VisibleForTesting
+ String getOwnerInfo() {
+ return mLockPatternUtils.getOwnerInfo(MY_USER_ID);
+ }
+
+ @VisibleForTesting
+ EnforcedAdmin getDeviceOwner() {
+ return RestrictedLockUtils.getDeviceOwner(mContext);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceControllerTest.java
index 387bc43..18b0c82 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceControllerTest.java
@@ -20,6 +20,7 @@
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
@@ -45,6 +46,7 @@
import com.android.settings.TestConfig;
import com.android.settings.applications.ManageApplications;
import com.android.settings.core.instrumentation.MetricsFeatureProvider;
+import com.android.settings.deviceinfo.PrivateVolumeSettings;
import com.android.settings.deviceinfo.StorageItemPreference;
import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settingslib.applications.StorageStatsSource;
@@ -187,6 +189,15 @@
}
@Test
+ public void testClickSystem() {
+ mPreference.setKey("pref_system");
+ assertThat(mController.handlePreferenceTreeClick(mPreference)).isTrue();
+
+ verify(mFragment.getFragmentManager().beginTransaction()).add(
+ any(PrivateVolumeSettings.SystemInfoFragment.class), anyString());
+ }
+
+ @Test
public void testMeasurementCompletedUpdatesPreferences() {
StorageItemPreference audio = new StorageItemPreference(mContext);
StorageItemPreference image = new StorageItemPreference(mContext);
diff --git a/tests/robotests/src/com/android/settings/enterprise/AdminGrantedPermissionsPreferenceControllerTestBase.java b/tests/robotests/src/com/android/settings/enterprise/AdminGrantedPermissionsPreferenceControllerTestBase.java
index 69e6237..f001bd1 100644
--- a/tests/robotests/src/com/android/settings/enterprise/AdminGrantedPermissionsPreferenceControllerTestBase.java
+++ b/tests/robotests/src/com/android/settings/enterprise/AdminGrantedPermissionsPreferenceControllerTestBase.java
@@ -93,10 +93,10 @@
setNumberOfPackagesWithAdminGrantedPermissions(20, true /* async */);
when(mContext.getResources().getQuantityString(
- R.plurals.enterprise_privacy_number_packages_actionable,20, 20))
- .thenReturn("20 packages");
+ R.plurals.enterprise_privacy_number_packages_lower_bound, 20, 20))
+ .thenReturn("minimum 20 apps");
mController.updateState(preference);
- assertThat(preference.getSummary()).isEqualTo("20 packages");
+ assertThat(preference.getSummary()).isEqualTo("minimum 20 apps");
assertThat(preference.isVisible()).isTrue();
}
diff --git a/tests/robotests/src/com/android/settings/enterprise/EnterpriseInstalledPackagesPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/EnterpriseInstalledPackagesPreferenceControllerTest.java
index 98d0fa6..ff884e4 100644
--- a/tests/robotests/src/com/android/settings/enterprise/EnterpriseInstalledPackagesPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/EnterpriseInstalledPackagesPreferenceControllerTest.java
@@ -87,10 +87,11 @@
assertThat(preference.isVisible()).isFalse();
setNumberOfEnterpriseInstalledPackages(20, true /* async */);
- when(mContext.getResources().getQuantityString(R.plurals.enterprise_privacy_number_packages,
- 20, 20)).thenReturn("20 packages");
+ when(mContext.getResources().getQuantityString(
+ R.plurals.enterprise_privacy_number_packages_lower_bound, 20, 20))
+ .thenReturn("minimum 20 apps");
mController.updateState(preference);
- assertThat(preference.getSummary()).isEqualTo("20 packages");
+ assertThat(preference.getSummary()).isEqualTo("minimum 20 apps");
assertThat(preference.isVisible()).isTrue();
}
diff --git a/tests/robotests/src/com/android/settings/security/OwnerInfoPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/security/OwnerInfoPreferenceControllerTest.java
new file mode 100644
index 0000000..d81768a
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/security/OwnerInfoPreferenceControllerTest.java
@@ -0,0 +1,197 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.settings.security;
+
+import android.app.FragmentManager;
+import android.app.FragmentTransaction;
+import android.content.Context;
+import android.support.v7.preference.PreferenceScreen;
+import android.support.v14.preference.PreferenceFragment;
+
+import com.android.internal.widget.LockPatternUtils;
+import com.android.settings.OwnerInfoSettings;
+import com.android.settings.R;
+import com.android.settings.SettingsRobolectricTestRunner;
+import com.android.settings.TestConfig;
+import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
+import com.android.settingslib.RestrictedPreference;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.annotation.Config;
+import org.robolectric.shadows.ShadowApplication;
+import org.robolectric.util.ReflectionHelpers;
+
+import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Answers.RETURNS_DEEP_STUBS;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class OwnerInfoPreferenceControllerTest {
+
+ @Mock(answer = RETURNS_DEEP_STUBS)
+ private PreferenceFragment mFragment;
+ @Mock
+ private PreferenceScreen mScreen;
+ @Mock
+ private FragmentManager mFragmentManager;
+ @Mock
+ private FragmentTransaction mFragmentTransaction;
+ @Mock
+ private RestrictedPreference mPreference;
+ @Mock
+ private LockPatternUtils mLockPatternUtils;
+
+ private Context mContext;
+ private OwnerInfoPreferenceController mController;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ ShadowApplication shadowContext = ShadowApplication.getInstance();
+ mContext = spy(shadowContext.getApplicationContext());
+
+ when(mFragment.isAdded()).thenReturn(true);
+ when(mFragment.getPreferenceScreen()).thenReturn(mScreen);
+ when(mFragment.getPreferenceManager().getContext()).thenReturn(mContext);
+ when(mFragment.getFragmentManager()).thenReturn(mFragmentManager);
+ when(mFragmentManager.beginTransaction()).thenReturn(mFragmentTransaction);
+
+ mController = spy(new OwnerInfoPreferenceController(mContext, mFragment, null));
+ when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
+ ReflectionHelpers.setField(mController, "mLockPatternUtils", mLockPatternUtils);
+ }
+
+ @Test
+ public void isAvailable_shouldReturnTrue() {
+ assertThat(mController.isAvailable()).isTrue();
+ }
+
+ @Test
+ public void onResume_shouldUpdateEnableState() {
+ mController.onResume();
+
+ verify(mController).updateEnableState();
+ }
+
+ @Test
+ public void onResume_shouldUpdateSummary() {
+ mController.onResume();
+
+ verify(mController).updateSummary();
+ }
+
+ @Test
+ public void updateSummary_deviceOwnerInfoEnabled_shouldSetDeviceOwnerInfoSummary() {
+ final String deviceOwnerInfo = "Test Device Owner Info";
+ doReturn(true).when(mController).isDeviceOwnerInfoEnabled();
+ doReturn(deviceOwnerInfo).when(mController).getDeviceOwnerInfo();
+ mController.displayPreference(mScreen);
+
+ mController.updateSummary();
+
+ verify(mPreference).setSummary(deviceOwnerInfo);
+ }
+
+ @Test
+ public void updateSummary_ownerInfoEnabled_shouldSetOwnerInfoSummary() {
+ final String ownerInfo = "Test Owner Info";
+ doReturn(false).when(mController).isDeviceOwnerInfoEnabled();
+ doReturn(true).when(mController).isOwnerInfoEnabled();
+ doReturn(ownerInfo).when(mController).getOwnerInfo();
+ mController.displayPreference(mScreen);
+
+ mController.updateSummary();
+
+ verify(mPreference).setSummary(ownerInfo);
+ }
+
+ @Test
+ public void updateSummary_ownerInfoDisabled_shouldSetDefaultSummary() {
+ doReturn(false).when(mController).isDeviceOwnerInfoEnabled();
+ doReturn(false).when(mController).isOwnerInfoEnabled();
+ mController.displayPreference(mScreen);
+
+ mController.updateSummary();
+
+ verify(mPreference).setSummary(mContext.getString(
+ com.android.settings.R.string.owner_info_settings_summary));
+ }
+
+ @Test
+ public void updateEnableState_deviceOwnerInfoEnabled_shouldSetDisabledByAdmin() {
+ doReturn(true).when(mController).isDeviceOwnerInfoEnabled();
+ doReturn(mock(EnforcedAdmin.class)).when(mController).getDeviceOwner();
+ mController.displayPreference(mScreen);
+
+ mController.updateEnableState();
+
+ verify(mPreference).setDisabledByAdmin(any(EnforcedAdmin.class));
+ }
+
+ @Test
+ public void updateEnableState_lockScreenDisabled_shouldDisablePreference() {
+ doReturn(false).when(mController).isDeviceOwnerInfoEnabled();
+ doReturn(true).when(mLockPatternUtils).isLockScreenDisabled(anyInt());
+ mController.displayPreference(mScreen);
+
+ mController.updateEnableState();
+
+ verify(mPreference).setEnabled(false);
+ }
+
+ @Test
+ public void updateEnableState_lockScreenEnabled_shouldEnablePreference() {
+ doReturn(false).when(mController).isDeviceOwnerInfoEnabled();
+ doReturn(false).when(mLockPatternUtils).isLockScreenDisabled(anyInt());
+ mController.displayPreference(mScreen);
+
+ mController.updateEnableState();
+
+ verify(mPreference).setEnabled(true);
+ }
+
+ @Test
+ public void performClick_shouldLaunchOwnerInfoSettings() {
+ final ShadowApplication application = ShadowApplication.getInstance();
+ final RestrictedPreference preference =
+ new RestrictedPreference(application.getApplicationContext());
+ when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(preference);
+ doReturn(false).when(mController).isDeviceOwnerInfoEnabled();
+ doReturn(false).when(mLockPatternUtils).isLockScreenDisabled(anyInt());
+ mController.displayPreference(mScreen);
+ mController.updateEnableState();
+
+ preference.performClick();
+
+ verify(mFragment).getFragmentManager();
+ verify(mFragment.getFragmentManager().beginTransaction())
+ .add(any(OwnerInfoSettings.class), anyString());
+ }
+
+}
\ No newline at end of file