Disable keyguard widgets on low memory devices

Fixes bug 10784493

Change-Id: Idc1c35faf0715814fa1a257319888945c82527c6
This commit is contained in:
Jim Miller
2013-09-29 14:04:40 -07:00
parent 77165f6d4b
commit 0366d14fb8

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);