From 2b2b3448ec200f3d649e5f57309908d28ce3bfc7 Mon Sep 17 00:00:00 2001 From: Marc Blank Date: Mon, 2 Aug 2010 13:47:23 -0700 Subject: [PATCH] Handle inactivity timeout > maximum allowed properly * In a recent change, we mistakenly removed the logic for handling too-long inactivity timeouts; we should just fall back to the maximum since this is stricter than what we're being asked to enforce * Restore this logic and update the unit test * The regression was caused by change Ida5663a9, to wit: Backport: Handle "Allow non-provisionable devices" properly Bug: 2886746 Change-Id: I99cf9a37441b80477cc1c2c7ec2a78f8a14a83da --- src/com/android/email/SecurityPolicy.java | 3 --- .../com/android/email/SecurityPolicyTests.java | 17 ++++++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/com/android/email/SecurityPolicy.java b/src/com/android/email/SecurityPolicy.java index 076949b82..bacb39b53 100644 --- a/src/com/android/email/SecurityPolicy.java +++ b/src/com/android/email/SecurityPolicy.java @@ -461,9 +461,6 @@ public class SecurityPolicy { if (passwordMode < PASSWORD_MODE_NONE || passwordMode > PASSWORD_MODE_STRONG) { throw new IllegalArgumentException("password mode"); } - if (maxScreenLockTime > SCREEN_LOCK_TIME_MAX) { - throw new IllegalArgumentException("screen lock time"); - } // This value can be reduced (which actually increases security) if necessary if (maxPasswordFails > PASSWORD_MAX_FAILS_MAX) { maxPasswordFails = PASSWORD_MAX_FAILS_MAX; diff --git a/tests/src/com/android/email/SecurityPolicyTests.java b/tests/src/com/android/email/SecurityPolicyTests.java index 7d6a8ee2f..1e25050ca 100644 --- a/tests/src/com/android/email/SecurityPolicyTests.java +++ b/tests/src/com/android/email/SecurityPolicyTests.java @@ -33,7 +33,10 @@ import android.test.suitebuilder.annotation.SmallTest; /** * This is a series of unit tests for backup/restore of the SecurityPolicy class. - */ + * + * You can run this entire test case with: + * runtest -c com.android.email.SecurityPolicyTests email +*/ @MediumTest public class SecurityPolicyTests extends ProviderTestCase2 { @@ -101,12 +104,12 @@ public class SecurityPolicyTests extends ProviderTestCase2 { fail("Illegal password mode allowed"); } catch (IllegalArgumentException e) { } - try { - new PolicySet(0, PolicySet.PASSWORD_MODE_NONE, 0, - PolicySet.SCREEN_LOCK_TIME_MAX + 1, false); - fail("Too-long screen lock time allowed"); - } catch (IllegalArgumentException e) { - } + PolicySet ps = new PolicySet(0, PolicySet.PASSWORD_MODE_NONE, 0, + PolicySet.SCREEN_LOCK_TIME_MAX + 1, false); + assertEquals(PolicySet.SCREEN_LOCK_TIME_MAX, ps.getMaxScreenLockTime()); + ps = new PolicySet(0, PolicySet.PASSWORD_MODE_NONE, + PolicySet.PASSWORD_MAX_FAILS_MAX + 1, 0, false); + assertEquals(PolicySet.PASSWORD_MAX_FAILS_MAX, ps.getMaxPasswordFails()); } /**