summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/SecuritySettings.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/settings/SecuritySettings.java')
-rw-r--r--src/com/android/settings/SecuritySettings.java492
1 files changed, 312 insertions, 180 deletions
diff --git a/src/com/android/settings/SecuritySettings.java b/src/com/android/settings/SecuritySettings.java
index 892d61f..8f2db6b 100644
--- a/src/com/android/settings/SecuritySettings.java
+++ b/src/com/android/settings/SecuritySettings.java
@@ -53,7 +53,9 @@ import android.util.Log;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.widget.LockPatternUtils;
+import com.android.settings.Settings.LockScreenSettingsActivity;
import com.android.settings.TrustAgentUtils.TrustAgentComponentInfo;
+import com.android.settings.cyanogenmod.LiveLockScreenSettings;
import com.android.settings.fingerprint.FingerprintEnrollIntroduction;
import com.android.settings.fingerprint.FingerprintSettings;
import com.android.settings.search.BaseSearchIndexProvider;
@@ -61,6 +63,10 @@ import com.android.settings.search.Index;
import com.android.settings.search.Indexable;
import com.android.settings.search.SearchIndexableRaw;
+import org.cyanogenmod.internal.util.CmLockPatternUtils;
+
+import cyanogenmod.providers.CMSettings;
+
import java.util.ArrayList;
import java.util.List;
@@ -77,9 +83,18 @@ public class SecuritySettings extends SettingsPreferenceFragment
private static final Intent TRUST_AGENT_INTENT =
new Intent(TrustAgentService.SERVICE_INTERFACE);
+ // Fitler types for this panel
+ protected static final String FILTER_TYPE_EXTRA = "filter_type";
+ protected static final int TYPE_LOCKSCREEN_EXTRA = 0;
+ private static final int TYPE_SECURITY_EXTRA = 1;
+ private static final int TYPE_EXTERNAL_RESOLUTION = 2;
+
// Lock Settings
private static final String KEY_UNLOCK_SET_OR_CHANGE = "unlock_set_or_change";
+ private static final String KEY_DIRECTLY_SHOW = "directlyshow";
private static final String KEY_VISIBLE_PATTERN = "visiblepattern";
+ private static final String KEY_VISIBLE_ERROR_PATTERN = "visible_error_pattern";
+ private static final String KEY_VISIBLE_DOTS = "visibledots";
private static final String KEY_SECURITY_CATEGORY = "security_category";
private static final String KEY_DEVICE_ADMIN_CATEGORY = "device_admin_category";
private static final String KEY_LOCK_AFTER_TIMEOUT = "lock_after_timeout";
@@ -88,11 +103,14 @@ public class SecuritySettings extends SettingsPreferenceFragment
private static final String KEY_MANAGE_TRUST_AGENTS = "manage_trust_agents";
private static final String KEY_FINGERPRINT_SETTINGS = "fingerprint_settings";
+ private static final String KEY_LOCKSCREEN_ENABLED_INTERNAL = "lockscreen_enabled_internally";
+
private static final int SET_OR_CHANGE_LOCK_METHOD_REQUEST = 123;
private static final int CHANGE_TRUST_AGENT_SETTINGS = 126;
// Misc Settings
private static final String KEY_SIM_LOCK = "sim_lock";
+ private static final String KEY_SIM_LOCK_SETTINGS = "sim_lock_settings";
private static final String KEY_SHOW_PASSWORD = "show_password";
private static final String KEY_CREDENTIAL_STORAGE_TYPE = "credential_storage_type";
private static final String KEY_RESET_CREDENTIALS = "credentials_reset";
@@ -103,17 +121,23 @@ public class SecuritySettings extends SettingsPreferenceFragment
private static final String PACKAGE_MIME_TYPE = "application/vnd.android.package-archive";
private static final String KEY_TRUST_AGENT = "trust_agent";
private static final String KEY_SCREEN_PINNING = "screen_pinning_settings";
+ private static final String KEY_SMS_SECURITY_CHECK_PREF = "sms_security_check_limit";
+ private static final String KEY_GENERAL_CATEGORY = "general_category";
+ private static final String KEY_LIVE_LOCK_SCREEN = "live_lock_screen";
// These switch preferences need special handling since they're not all stored in Settings.
private static final String SWITCH_PREFERENCE_KEYS[] = { KEY_LOCK_AFTER_TIMEOUT,
- KEY_VISIBLE_PATTERN, KEY_POWER_INSTANTLY_LOCKS, KEY_SHOW_PASSWORD,
- KEY_TOGGLE_INSTALL_APPLICATIONS };
+ KEY_VISIBLE_PATTERN, KEY_VISIBLE_ERROR_PATTERN, KEY_VISIBLE_DOTS, KEY_DIRECTLY_SHOW,
+ KEY_POWER_INSTANTLY_LOCKS, KEY_SHOW_PASSWORD, KEY_TOGGLE_INSTALL_APPLICATIONS };
// Only allow one trust agent on the platform.
private static final boolean ONLY_ONE_TRUST_AGENT = true;
- private static final int MY_USER_ID = UserHandle.myUserId();
+ protected static final int MY_USER_ID = UserHandle.myUserId();
+
+ protected static final String LIVE_LOCK_SCREEN_FEATURE = "org.cyanogenmod.livelockscreen";
+ private PackageManager mPM;
private DevicePolicyManager mDPM;
private SubscriptionManager mSubscriptionManager;
@@ -121,7 +145,10 @@ public class SecuritySettings extends SettingsPreferenceFragment
private LockPatternUtils mLockPatternUtils;
private ListPreference mLockAfter;
+ private SwitchPreference mDirectlyShow;
private SwitchPreference mVisiblePattern;
+ private SwitchPreference mVisibleErrorPattern;
+ private SwitchPreference mVisibleDots;
private SwitchPreference mShowPassword;
@@ -132,10 +159,16 @@ public class SecuritySettings extends SettingsPreferenceFragment
private DialogInterface mWarnInstallApps;
private SwitchPreference mPowerButtonInstantlyLocks;
+ private ListPreference mSmsSecurityCheck;
+
private boolean mIsPrimary;
private Intent mTrustAgentClickIntent;
+
private Preference mOwnerInfoPref;
+ private int mFilterType = TYPE_SECURITY_EXTRA;
+
+ private Preference mLockscreenDisabledPreference;
@Override
protected int getMetricsCategory() {
@@ -146,6 +179,26 @@ public class SecuritySettings extends SettingsPreferenceFragment
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ // Ugly hack for legacy shortcuts :'(
+ Intent intent = getActivity().getIntent();
+ ComponentName componentName = intent.getComponent();
+ if (componentName.getClassName().equals(
+ LockScreenSettingsActivity.class.getName())) {
+ mFilterType = TYPE_LOCKSCREEN_EXTRA;
+ } else {
+ Bundle bundle = getArguments();
+ if (bundle != null) {
+ mFilterType = bundle.getInt(FILTER_TYPE_EXTRA, TYPE_SECURITY_EXTRA);
+ }
+ }
+
+ Bundle extras = getActivity().getIntent().getExtras();
+ // Even uglier hack to make cts verifier expectations make sense.
+ if (extras.get(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS) != null &&
+ extras.get(SettingsActivity.EXTRA_SHOW_FRAGMENT_AS_SHORTCUT) == null) {
+ mFilterType = TYPE_EXTERNAL_RESOLUTION;
+ }
+
mSubscriptionManager = SubscriptionManager.from(getActivity());
mLockPatternUtils = new LockPatternUtils(getActivity());
@@ -160,7 +213,7 @@ public class SecuritySettings extends SettingsPreferenceFragment
}
}
- private static int getResIdForLockUnlockScreen(Context context,
+ protected static int getResIdForLockUnlockScreen(Context context,
LockPatternUtils lockPatternUtils) {
int resid = 0;
if (!lockPatternUtils.isSecure(MY_USER_ID)) {
@@ -202,25 +255,45 @@ public class SecuritySettings extends SettingsPreferenceFragment
addPreferencesFromResource(R.xml.security_settings);
root = getPreferenceScreen();
- // Add options for lock/unlock screen
- final int resid = getResIdForLockUnlockScreen(getActivity(), mLockPatternUtils);
- addPreferencesFromResource(resid);
+ // Add package manager to check if features are available
+ PackageManager pm = getPackageManager();
// Add options for device encryption
mIsPrimary = MY_USER_ID == UserHandle.USER_OWNER;
- mOwnerInfoPref = findPreference(KEY_OWNER_INFO_SETTINGS);
- if (mOwnerInfoPref != null) {
- mOwnerInfoPref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
- @Override
- public boolean onPreferenceClick(Preference preference) {
- OwnerInfoSettings.show(SecuritySettings.this);
- return true;
- }
- });
+ if (CMSettings.Secure.getIntForUser(getContentResolver(),
+ CMSettings.Secure.LOCKSCREEN_INTERNALLY_ENABLED, 1, UserHandle.USER_OWNER) != 1) {
+ // lock screen is disabled by quick settings tile, let the user know!~
+ mLockscreenDisabledPreference = new Preference(getActivity());
+ mLockscreenDisabledPreference.setKey(KEY_LOCKSCREEN_ENABLED_INTERNAL);
+ mLockscreenDisabledPreference.setTitle(R.string.lockscreen_disabled_by_qs_tile_title);
+ mLockscreenDisabledPreference.setSummary(R.string.lockscreen_disabled_by_qs_tile_summary);
+ root.addPreference(mLockscreenDisabledPreference);
}
- if (mIsPrimary) {
+ final boolean securityOrExternal = mFilterType == TYPE_SECURITY_EXTRA
+ || mFilterType == TYPE_EXTERNAL_RESOLUTION;
+ final boolean lockscreenOrExternal = mFilterType == TYPE_LOCKSCREEN_EXTRA
+ || mFilterType == TYPE_EXTERNAL_RESOLUTION;
+
+ if (lockscreenOrExternal) {
+ // Add options for lock/unlock screen
+ final int resid = getResIdForLockUnlockScreen(getActivity(), mLockPatternUtils);
+ addPreferencesFromResource(resid);
+
+ mOwnerInfoPref = findPreference(KEY_OWNER_INFO_SETTINGS);
+ if (mOwnerInfoPref != null) {
+ mOwnerInfoPref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
+ @Override
+ public boolean onPreferenceClick(Preference preference) {
+ OwnerInfoSettings.show(SecuritySettings.this);
+ return true;
+ }
+ });
+ }
+ }
+
+ if (mIsPrimary && securityOrExternal) {
if (LockPatternUtils.isDeviceEncryptionEnabled()) {
// The device is currently encrypted.
addPreferencesFromResource(R.xml.security_settings_encrypted);
@@ -230,114 +303,197 @@ public class SecuritySettings extends SettingsPreferenceFragment
}
}
- // Fingerprint and trust agents
- PreferenceGroup securityCategory = (PreferenceGroup)
- root.findPreference(KEY_SECURITY_CATEGORY);
- if (securityCategory != null) {
- maybeAddFingerprintPreference(securityCategory);
- addTrustAgentSettings(securityCategory);
- }
+ if (lockscreenOrExternal) {
+ // Fingerprint and trust agents
+ PreferenceGroup securityCategory = (PreferenceGroup)
+ root.findPreference(KEY_SECURITY_CATEGORY);
+ if (securityCategory != null) {
+ maybeAddFingerprintPreference(securityCategory);
+ addTrustAgentSettings(securityCategory);
+ }
- // lock after preference
- mLockAfter = (ListPreference) root.findPreference(KEY_LOCK_AFTER_TIMEOUT);
- if (mLockAfter != null) {
- setupLockAfterPreference();
- updateLockAfterPreferenceSummary();
- }
+ // lock after preference
+ mLockAfter = (ListPreference) root.findPreference(KEY_LOCK_AFTER_TIMEOUT);
+ if (mLockAfter != null) {
+ setupLockAfterPreference();
+ updateLockAfterPreferenceSummary();
+ }
- // visible pattern
- mVisiblePattern = (SwitchPreference) root.findPreference(KEY_VISIBLE_PATTERN);
-
- // lock instantly on power key press
- mPowerButtonInstantlyLocks = (SwitchPreference) root.findPreference(
- KEY_POWER_INSTANTLY_LOCKS);
- Preference trustAgentPreference = root.findPreference(KEY_TRUST_AGENT);
- if (mPowerButtonInstantlyLocks != null &&
- trustAgentPreference != null &&
- trustAgentPreference.getTitle().length() > 0) {
- mPowerButtonInstantlyLocks.setSummary(getString(
- R.string.lockpattern_settings_power_button_instantly_locks_summary,
- trustAgentPreference.getTitle()));
- }
-
- // 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 (!mIsPrimary || !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));
+ // directly show
+ mDirectlyShow = (SwitchPreference) root.findPreference(KEY_DIRECTLY_SHOW);
+
+ // visible pattern
+ mVisiblePattern = (SwitchPreference) root.findPreference(KEY_VISIBLE_PATTERN);
+
+ // visible error pattern
+ mVisibleErrorPattern = (SwitchPreference) root.findPreference(
+ KEY_VISIBLE_ERROR_PATTERN);
+
+ // visible dots
+ mVisibleDots = (SwitchPreference) root.findPreference(KEY_VISIBLE_DOTS);
+
+ // lock instantly on power key press
+ mPowerButtonInstantlyLocks = (SwitchPreference) root.findPreference(
+ KEY_POWER_INSTANTLY_LOCKS);
+ Preference trustAgentPreference = root.findPreference(KEY_TRUST_AGENT);
+ if (mPowerButtonInstantlyLocks != null &&
+ trustAgentPreference != null &&
+ trustAgentPreference.getTitle().length() > 0) {
+ mPowerButtonInstantlyLocks.setSummary(getString(
+ R.string.lockpattern_settings_power_button_instantly_locks_summary,
+ trustAgentPreference.getTitle()));
+ }
+
+ // Add live lock screen preference if supported
+ PreferenceGroup generalCategory = (PreferenceGroup)
+ root.findPreference(KEY_GENERAL_CATEGORY);
+ if (pm.hasSystemFeature(LIVE_LOCK_SCREEN_FEATURE) && generalCategory != null) {
+ Preference liveLockPreference = new Preference(getContext(), null);
+ liveLockPreference.setFragment(LiveLockScreenSettings.class.getCanonicalName());
+ liveLockPreference.setOrder(0);
+ liveLockPreference.setTitle(R.string.live_lock_screen_title);
+ liveLockPreference.setSummary(R.string.live_lock_screen_summary);
+ generalCategory.addPreference(liveLockPreference);
+ }
}
- // Show password
- mShowPassword = (SwitchPreference) root.findPreference(KEY_SHOW_PASSWORD);
- mResetCredentials = root.findPreference(KEY_RESET_CREDENTIALS);
+ if (securityOrExternal) {
+ // Append the rest of the settings
+ addPreferencesFromResource(R.xml.security_settings_misc);
- // Credential storage
- final UserManager um = (UserManager) getActivity().getSystemService(Context.USER_SERVICE);
- mKeyStore = KeyStore.getInstance(); // needs to be initialized for onResume()
- if (!um.hasUserRestriction(UserManager.DISALLOW_CONFIG_CREDENTIALS)) {
- Preference credentialStorageType = root.findPreference(KEY_CREDENTIAL_STORAGE_TYPE);
-
- final int storageSummaryRes =
- mKeyStore.isHardwareBacked() ? R.string.credential_storage_type_hardware
- : R.string.credential_storage_type_software;
- credentialStorageType.setSummary(storageSummaryRes);
- } else {
- PreferenceGroup credentialsManager = (PreferenceGroup)
- root.findPreference(KEY_CREDENTIALS_MANAGER);
- credentialsManager.removePreference(root.findPreference(KEY_RESET_CREDENTIALS));
- credentialsManager.removePreference(root.findPreference(KEY_CREDENTIALS_INSTALL));
- credentialsManager.removePreference(root.findPreference(KEY_CREDENTIAL_STORAGE_TYPE));
- }
-
- // Application install
- PreferenceGroup deviceAdminCategory = (PreferenceGroup)
- root.findPreference(KEY_DEVICE_ADMIN_CATEGORY);
- mToggleAppInstallation = (SwitchPreference) findPreference(
- KEY_TOGGLE_INSTALL_APPLICATIONS);
- mToggleAppInstallation.setChecked(isNonMarketAppsAllowed());
- // Side loading of apps.
- // Disable for restricted profiles. For others, check if policy disallows it.
- mToggleAppInstallation.setEnabled(!um.getUserInfo(MY_USER_ID).isRestricted());
- if (um.hasUserRestriction(UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES)
- || um.hasUserRestriction(UserManager.DISALLOW_INSTALL_APPS)) {
- mToggleAppInstallation.setEnabled(false);
- }
-
- // Advanced Security features
- PreferenceGroup advancedCategory =
- (PreferenceGroup)root.findPreference(KEY_ADVANCED_SECURITY);
- if (advancedCategory != null) {
- Preference manageAgents = advancedCategory.findPreference(KEY_MANAGE_TRUST_AGENTS);
- if (manageAgents != null && !mLockPatternUtils.isSecure(MY_USER_ID)) {
- manageAgents.setEnabled(false);
- manageAgents.setSummary(R.string.disabled_because_no_backup_security);
- }
- }
-
- // The above preferences come and go based on security state, so we need to update
- // the index. This call is expected to be fairly cheap, but we may want to do something
- // smarter in the future.
- Index.getInstance(getActivity())
- .updateFromClassNameResource(SecuritySettings.class.getName(), true, true);
+ // Do not display SIM lock for devices without an Icc card
+ CarrierConfigManager cfgMgr = (CarrierConfigManager)
+ getActivity().getSystemService(Context.CARRIER_CONFIG_SERVICE);
+ PersistableBundle b = cfgMgr.getConfig();
+ PreferenceGroup iccLockGroup = (PreferenceGroup) root.findPreference(KEY_SIM_LOCK);
+ Preference iccLock = root.findPreference(KEY_SIM_LOCK_SETTINGS);
+
+ if (!mIsPrimary
+ || b.getBoolean(CarrierConfigManager.KEY_HIDE_SIM_LOCK_SETTINGS_BOOL)) {
+ root.removePreference(iccLockGroup);
+ } else {
+ SubscriptionManager subMgr = SubscriptionManager.from(getActivity());
+ TelephonyManager tm = TelephonyManager.getDefault();
+ int numPhones = tm.getPhoneCount();
+ boolean hasAnySim = false;
+
+ for (int i = 0; i < numPhones; i++) {
+ final Preference pref;
+
+ if (numPhones > 1) {
+ SubscriptionInfo sir = subMgr.getActiveSubscriptionInfoForSimSlotIndex(i);
+ if (sir == null) {
+ continue;
+ }
+
+ pref = new Preference(getActivity());
+ pref.setOrder(iccLock.getOrder());
+ pref.setTitle(getString(R.string.sim_card_lock_settings_title, i + 1));
+ pref.setSummary(sir.getDisplayName());
+
+ Intent intent = new Intent(getActivity(), IccLockSettings.class);
+ intent.putExtra(IccLockSettings.EXTRA_SUB_ID, sir.getSubscriptionId());
+ intent.putExtra(IccLockSettings.EXTRA_SUB_DISPLAY_NAME,
+ sir.getDisplayName());
+ pref.setIntent(intent);
+
+ iccLockGroup.addPreference(pref);
+ } else {
+ pref = iccLock;
+ }
+
+ // Do not display SIM lock for devices without an Icc card
+ hasAnySim |= tm.hasIccCard(i);
+
+ int simState = tm.getSimState(i);
+ boolean simPresent = simState != TelephonyManager.SIM_STATE_ABSENT
+ && simState != TelephonyManager.SIM_STATE_UNKNOWN
+ && simState != TelephonyManager.SIM_STATE_CARD_IO_ERROR;
+ if (!simPresent) {
+ pref.setEnabled(false);
+ }
+ }
+
+ if (!hasAnySim) {
+ root.removePreference(iccLockGroup);
+ } else if (numPhones > 1) {
+ iccLockGroup.removePreference(iccLock);
+ }
+ }
+ 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));
+ }
+
+ // SMS rate limit security check
+ boolean isTelephony = pm.hasSystemFeature(PackageManager.FEATURE_TELEPHONY);
+ if (isTelephony) {
+ mSmsSecurityCheck = (ListPreference) root.findPreference(KEY_SMS_SECURITY_CHECK_PREF);
+ mSmsSecurityCheck.setOnPreferenceChangeListener(this);
+ int smsSecurityCheck = Integer.valueOf(mSmsSecurityCheck.getValue());
+ updateSmsSecuritySummary(smsSecurityCheck);
+ }
+
+ // Show password
+ mShowPassword = (SwitchPreference) root.findPreference(KEY_SHOW_PASSWORD);
+ mResetCredentials = root.findPreference(KEY_RESET_CREDENTIALS);
+
+ // Credential storage
+ final UserManager um = (UserManager) getActivity().getSystemService(Context.USER_SERVICE);
+ mKeyStore = KeyStore.getInstance(); // needs to be initialized for onResume()
+ if (!um.hasUserRestriction(UserManager.DISALLOW_CONFIG_CREDENTIALS)) {
+ Preference credentialStorageType = root.findPreference(KEY_CREDENTIAL_STORAGE_TYPE);
+
+ final int storageSummaryRes =
+ mKeyStore.isHardwareBacked() ? R.string.credential_storage_type_hardware
+ : R.string.credential_storage_type_software;
+ credentialStorageType.setSummary(storageSummaryRes);
+ } else {
+ PreferenceGroup credentialsManager = (PreferenceGroup)
+ root.findPreference(KEY_CREDENTIALS_MANAGER);
+ credentialsManager.removePreference(root.findPreference(KEY_RESET_CREDENTIALS));
+ credentialsManager.removePreference(root.findPreference(KEY_CREDENTIALS_INSTALL));
+ credentialsManager.removePreference(root.findPreference(KEY_CREDENTIAL_STORAGE_TYPE));
+ }
+
+ // Application install
+ PreferenceGroup deviceAdminCategory = (PreferenceGroup)
+ root.findPreference(KEY_DEVICE_ADMIN_CATEGORY);
+ mToggleAppInstallation = (SwitchPreference) findPreference(
+ KEY_TOGGLE_INSTALL_APPLICATIONS);
+ mToggleAppInstallation.setChecked(isNonMarketAppsAllowed());
+ // Side loading of apps.
+ // Disable for restricted profiles. For others, check if policy disallows it.
+ mToggleAppInstallation.setEnabled(!um.getUserInfo(MY_USER_ID).isRestricted());
+ if (um.hasUserRestriction(UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES)
+ || um.hasUserRestriction(UserManager.DISALLOW_INSTALL_APPS)) {
+ mToggleAppInstallation.setEnabled(false);
+ }
+
+ // Advanced Security features
+ PreferenceGroup advancedCategory =
+ (PreferenceGroup)root.findPreference(KEY_ADVANCED_SECURITY);
+ if (advancedCategory != null) {
+ Preference manageAgents = advancedCategory.findPreference(KEY_MANAGE_TRUST_AGENTS);
+ if (manageAgents != null && !mLockPatternUtils.isSecure(MY_USER_ID)) {
+ manageAgents.setEnabled(false);
+ manageAgents.setSummary(R.string.disabled_because_no_backup_security);
+ }
+ }
+
+ // The above preferences come and go based on security state, so we need to update
+ // the index. This call is expected to be fairly cheap, but we may want to do something
+ // smarter in the future.
+ Index.getInstance(getActivity())
+ .updateFromClassNameResource(SecuritySettings.class.getName(), true, true);
+ }
for (int i = 0; i < SWITCH_PREFERENCE_KEYS.length; i++) {
final Preference pref = findPreference(SWITCH_PREFERENCE_KEYS[i]);
if (pref != null) pref.setOnPreferenceChangeListener(this);
}
+
return root;
}
@@ -399,44 +555,7 @@ public class SecuritySettings extends SettingsPreferenceFragment
}
}
- /* 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;
- }
-
- private static ArrayList<TrustAgentComponentInfo> getActiveTrustAgents(
+ protected static ArrayList<TrustAgentComponentInfo> getActiveTrustAgents(
PackageManager pm, LockPatternUtils utils, DevicePolicyManager dpm) {
ArrayList<TrustAgentComponentInfo> result = new ArrayList<TrustAgentComponentInfo>();
List<ResolveInfo> resolveInfos = pm.queryIntentServices(TRUST_AGENT_INTENT,
@@ -513,6 +632,13 @@ public class SecuritySettings extends SettingsPreferenceFragment
}
}
+ private void updateSmsSecuritySummary(int selection) {
+ String message = selection > 0
+ ? getString(R.string.sms_security_check_limit_summary, selection)
+ : getString(R.string.sms_security_check_limit_summary_none);
+ mSmsSecurityCheck.setSummary(message);
+ }
+
private void setupLockAfterPreference() {
// Compatible with pre-Froyo
long currentTimeout = Settings.Secure.getLong(getContentResolver(),
@@ -604,9 +730,18 @@ public class SecuritySettings extends SettingsPreferenceFragment
createPreferenceHierarchy();
final LockPatternUtils lockPatternUtils = mChooseLockSettingsHelper.utils();
+ final CmLockPatternUtils cmLockPatternUtils = mChooseLockSettingsHelper.cmUtils();
+ if (mDirectlyShow != null) {
+ mDirectlyShow.setChecked(cmLockPatternUtils.shouldPassToSecurityView(MY_USER_ID));
+ }
if (mVisiblePattern != null) {
- mVisiblePattern.setChecked(lockPatternUtils.isVisiblePatternEnabled(
- MY_USER_ID));
+ mVisiblePattern.setChecked(lockPatternUtils.isVisiblePatternEnabled(MY_USER_ID));
+ }
+ if (mVisibleErrorPattern != null) {
+ mVisibleErrorPattern.setChecked(lockPatternUtils.isShowErrorPath(MY_USER_ID));
+ }
+ if (mVisibleDots != null) {
+ mVisibleDots.setChecked(lockPatternUtils.isVisibleDotsEnabled(MY_USER_ID));
}
if (mPowerButtonInstantlyLocks != null) {
mPowerButtonInstantlyLocks.setChecked(lockPatternUtils.getPowerButtonInstantlyLocks(
@@ -645,11 +780,18 @@ public class SecuritySettings extends SettingsPreferenceFragment
mTrustAgentClickIntent = preference.getIntent();
boolean confirmationLaunched = helper.launchConfirmationActivity(
CHANGE_TRUST_AGENT_SETTINGS, preference.getTitle());
- if (!confirmationLaunched&& mTrustAgentClickIntent != null) {
+ if (!confirmationLaunched && mTrustAgentClickIntent != null) {
// If this returns false, it means no password confirmation is required.
startActivity(mTrustAgentClickIntent);
mTrustAgentClickIntent = null;
}
+ } else if (KEY_LOCKSCREEN_ENABLED_INTERNAL.equals(key)) {
+ CMSettings.Secure.putIntForUser(getActivity().getContentResolver(),
+ CMSettings.Secure.LOCKSCREEN_INTERNALLY_ENABLED,
+ 1, UserHandle.USER_CURRENT);
+ mLockscreenDisabledPreference.setEnabled(false);
+ mLockscreenDisabledPreference.setSummary(
+ R.string.lockscreen_disabled_by_qs_tile_summary_enabled);
} else {
// If we didn't handle it, let preferences handle it.
return super.onPreferenceTreeClick(preferenceScreen, preference);
@@ -678,6 +820,7 @@ public class SecuritySettings extends SettingsPreferenceFragment
boolean result = true;
final String key = preference.getKey();
final LockPatternUtils lockPatternUtils = mChooseLockSettingsHelper.utils();
+ final CmLockPatternUtils cmLockPatternUtils = mChooseLockSettingsHelper.cmUtils();
if (KEY_LOCK_AFTER_TIMEOUT.equals(key)) {
int timeout = Integer.parseInt((String) value);
try {
@@ -687,8 +830,14 @@ public class SecuritySettings extends SettingsPreferenceFragment
Log.e("SecuritySettings", "could not persist lockAfter timeout setting", e);
}
updateLockAfterPreferenceSummary();
+ } else if (KEY_DIRECTLY_SHOW.equals(key)) {
+ cmLockPatternUtils.setPassToSecurityView((Boolean) value, MY_USER_ID);
} else if (KEY_VISIBLE_PATTERN.equals(key)) {
lockPatternUtils.setVisiblePatternEnabled((Boolean) value, MY_USER_ID);
+ } else if (KEY_VISIBLE_ERROR_PATTERN.equals(key)) {
+ lockPatternUtils.setShowErrorPath((Boolean) value, MY_USER_ID);
+ } else if (KEY_VISIBLE_DOTS.equals(key)) {
+ lockPatternUtils.setVisibleDotsEnabled((Boolean) value, MY_USER_ID);
} else if (KEY_POWER_INSTANTLY_LOCKS.equals(key)) {
mLockPatternUtils.setPowerButtonInstantlyLocks((Boolean) value, MY_USER_ID);
} else if (KEY_SHOW_PASSWORD.equals(key)) {
@@ -704,6 +853,11 @@ public class SecuritySettings extends SettingsPreferenceFragment
} else {
setNonMarketAppsAllowed(false);
}
+ } else if (KEY_SMS_SECURITY_CHECK_PREF.equals(key)) {
+ int smsSecurityCheck = Integer.valueOf((String) value);
+ Settings.Global.putInt(getContentResolver(), Settings.Global.SMS_OUTGOING_CHECK_MAX_COUNT,
+ smsSecurityCheck);
+ updateSmsSecuritySummary(smsSecurityCheck);
}
return result;
}
@@ -735,14 +889,8 @@ public class SecuritySettings extends SettingsPreferenceFragment
List<SearchIndexableResource> result = new ArrayList<SearchIndexableResource>();
- LockPatternUtils lockPatternUtils = new LockPatternUtils(context);
- // Add options for lock/unlock screen
- int resId = getResIdForLockUnlockScreen(context, lockPatternUtils);
-
- SearchIndexableResource sir = new SearchIndexableResource(context);
- sir.xmlResId = resId;
- result.add(sir);
-
+ int resId = 0;
+ SearchIndexableResource sir;
if (mIsPrimary) {
DevicePolicyManager dpm = (DevicePolicyManager)
context.getSystemService(Context.DEVICE_POLICY_SERVICE);
@@ -793,22 +941,6 @@ public class SecuritySettings extends SettingsPreferenceFragment
result.add(data);
}
- // Fingerprint
- FingerprintManager fpm =
- (FingerprintManager) context.getSystemService(Context.FINGERPRINT_SERVICE);
- if (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.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.screenTitle = screenTitle;
- result.add(data);
- }
-
// Credential storage
final UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE);