Add setting to disable keyguard widgets

This allows disabling keyguard widgets through Settings.
On new devices, the setting is turned off by default.  If the
user currently has widgets in keyguard, then we keep them
and re-enable the setting.

Change-Id: I25f0756ac72227e13dcb491694b3ec3c2bf1d293
This commit is contained in:
Jim Miller
2013-08-20 19:03:30 -07:00
parent 55fe056d96
commit ef3e701b78
8 changed files with 52 additions and 0 deletions

View File

@@ -682,6 +682,10 @@
<string name="show_owner_info_on_lockscreen_label">Show owner info on lock screen</string>
<!-- Text shown for title of owner info setting [CHAR LIMIT=20]-->
<string name="owner_info_settings_title">Owner info</string>
<!-- Text shown for title of settings checkbox to disable widgets [CHAR LIMIT=20]-->
<string name="security_enable_widgets_title">Enable widgets</string>
<!-- Summary for settings checkbox to disable widgets when the setting has been disabled by an installed device admin [CHAR LIMIT=50] -->
<string name="security_enable_widgets_disabled_summary">Disabled by administrator</string>
<!-- Text shown for summary of owner info setting [CHAR LIMIT=40]-->
<string name="owner_info_settings_summary"></string>
<!-- Hint text shown in owner info edit text [CHAR LIMIT=50] -->

View File

@@ -51,6 +51,10 @@
android:key="power_button_instantly_locks"
android:title="@string/lockpattern_settings_enable_power_button_instantly_locks"/>
<CheckBoxPreference
android:key="keyguard_enable_widgets"
android:title="@string/security_enable_widgets_title"/>
<PreferenceScreen
android:fragment="com.android.settings.OwnerInfoSettings"
android:key="owner_info_settings"

View File

@@ -26,6 +26,10 @@
android:summary="@string/unlock_set_unlock_mode_none"
android:persistent="false"/>
<CheckBoxPreference
android:key="keyguard_enable_widgets"
android:title="@string/security_enable_widgets_title"/>
<PreferenceScreen
android:fragment="com.android.settings.OwnerInfoSettings"
android:key="owner_info_settings"

View File

@@ -25,6 +25,11 @@
android:title="@string/unlock_set_unlock_launch_picker_title"
android:summary="@string/unlock_set_unlock_mode_off"
android:persistent="false"/>
<CheckBoxPreference
android:key="keyguard_enable_widgets"
android:title="@string/security_enable_widgets_title"/>
<PreferenceScreen
android:fragment="com.android.settings.OwnerInfoSettings"
android:key="owner_info_settings"

View File

@@ -38,6 +38,10 @@
android:key="power_button_instantly_locks"
android:title="@string/lockpattern_settings_enable_power_button_instantly_locks"/>
<CheckBoxPreference
android:key="keyguard_enable_widgets"
android:title="@string/security_enable_widgets_title"/>
<PreferenceScreen
android:fragment="com.android.settings.OwnerInfoSettings"
android:key="owner_info_settings"

View File

@@ -42,6 +42,10 @@
android:key="power_button_instantly_locks"
android:title="@string/lockpattern_settings_enable_power_button_instantly_locks"/>
<CheckBoxPreference
android:key="keyguard_enable_widgets"
android:title="@string/security_enable_widgets_title"/>
<PreferenceScreen
android:fragment="com.android.settings.OwnerInfoSettings"
android:key="owner_info_settings"

View File

@@ -38,6 +38,10 @@
android:key="power_button_instantly_locks"
android:title="@string/lockpattern_settings_enable_power_button_instantly_locks"/>
<CheckBoxPreference
android:key="keyguard_enable_widgets"
android:title="@string/security_enable_widgets_title"/>
<PreferenceScreen
android:fragment="com.android.settings.OwnerInfoSettings"
android:key="owner_info_settings"

View File

@@ -65,6 +65,8 @@ public class SecuritySettings extends RestrictedSettingsFragment
private static final String KEY_DEVICE_ADMIN_CATEGORY = "device_admin_category";
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_ENABLE_WIDGETS = "keyguard_enable_widgets";
private static final int SET_OR_CHANGE_LOCK_METHOD_REQUEST = 123;
private static final int CONFIRM_EXISTING_FOR_BIOMETRIC_WEAK_IMPROVE_REQUEST = 124;
private static final int CONFIRM_EXISTING_FOR_BIOMETRIC_WEAK_LIVELINESS_OFF = 125;
@@ -101,6 +103,7 @@ public class SecuritySettings extends RestrictedSettingsFragment
private DialogInterface mWarnInstallApps;
private CheckBoxPreference mToggleVerifyApps;
private CheckBoxPreference mPowerButtonInstantlyLocks;
private CheckBoxPreference mEnableKeyguardWidgets;
private Preference mNotificationAccess;
@@ -241,6 +244,20 @@ public class SecuritySettings extends RestrictedSettingsFragment
}
}
// Enable or disable keyguard widget checkbox based on DPM state
mEnableKeyguardWidgets = (CheckBoxPreference) root.findPreference(KEY_ENABLE_WIDGETS);
if (mEnableKeyguardWidgets != null) {
final boolean disabled = (0 != (mDPM.getKeyguardDisabledFeatures(null)
& DevicePolicyManager.KEYGUARD_DISABLE_WIDGETS_ALL));
if (disabled) {
mEnableKeyguardWidgets.setSummary(
R.string.security_enable_widgets_disabled_summary);
} else {
mEnableKeyguardWidgets.setSummary("");
}
mEnableKeyguardWidgets.setEnabled(!disabled);
}
// Show password
mShowPassword = (CheckBoxPreference) root.findPreference(KEY_SHOW_PASSWORD);
mResetCredentials = root.findPreference(KEY_RESET_CREDENTIALS);
@@ -477,6 +494,10 @@ public class SecuritySettings extends RestrictedSettingsFragment
if (mResetCredentials != null) {
mResetCredentials.setEnabled(!mKeyStore.isEmpty());
}
if (mEnableKeyguardWidgets != null) {
mEnableKeyguardWidgets.setChecked(lockPatternUtils.getWidgetsEnabled());
}
}
@Override
@@ -527,6 +548,8 @@ public class SecuritySettings extends RestrictedSettingsFragment
lockPatternUtils.setVisiblePatternEnabled(isToggled(preference));
} else if (KEY_POWER_INSTANTLY_LOCKS.equals(key)) {
lockPatternUtils.setPowerButtonInstantlyLocks(isToggled(preference));
} else if (KEY_ENABLE_WIDGETS.equals(key)) {
lockPatternUtils.setWidgetsEnabled(mEnableKeyguardWidgets.isChecked());
} else if (preference == mShowPassword) {
Settings.System.putInt(getContentResolver(), Settings.System.TEXT_SHOW_PASSWORD,
mShowPassword.isChecked() ? 1 : 0);