Merge "Disable keyguard widgets on low memory devices" into klp-dev

This commit is contained in:
Jim Miller
2013-09-30 20:38:09 +00:00
committed by Android (Google) Code Review

View File

@@ -20,6 +20,7 @@ package com.android.settings;
import static android.provider.Settings.System.SCREEN_OFF_TIMEOUT;
import android.app.Activity;
import android.app.ActivityManager;
import android.app.AlertDialog;
import android.app.admin.DevicePolicyManager;
import android.content.Context;
@@ -244,6 +245,15 @@ 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) {
if (ActivityManager.isLowRamDeviceStatic()) {
// Widgets take a lot of RAM, so disable them on low-memory devices
PreferenceGroup securityCategory
= (PreferenceGroup) root.findPreference(KEY_SECURITY_CATEGORY);
if (securityCategory != null) {
securityCategory.removePreference(root.findPreference(KEY_ENABLE_WIDGETS));
mEnableKeyguardWidgets = null;
}
} else {
final boolean disabled = (0 != (mDPM.getKeyguardDisabledFeatures(null)
& DevicePolicyManager.KEYGUARD_DISABLE_WIDGETS_ALL));
if (disabled) {
@@ -254,6 +264,7 @@ public class SecuritySettings extends RestrictedSettingsFragment
}
mEnableKeyguardWidgets.setEnabled(!disabled);
}
}
// Show password
mShowPassword = (CheckBoxPreference) root.findPreference(KEY_SHOW_PASSWORD);