Lines Matching refs:Policy
33 import com.android.emailcommon.provider.Policy;
53 private static final Policy EMPTY_POLICY = new Policy();
104 * Create a Policy using the arguments formerly used to create a PolicySet; this minimizes the
107 private Policy setupPolicy(int minPasswordLength, int passwordMode, int maxPasswordFails,
112 Policy policy = new Policy();
113 policy.mPasswordMinLength = minPasswordLength;
114 policy.mPasswordMode = passwordMode;
115 policy.mPasswordMaxFails = maxPasswordFails;
116 policy.mMaxScreenLockTime = maxScreenLockTime;
117 policy.mRequireRemoteWipe = requireRemoteWipe;
118 policy.mPasswordExpirationDays = passwordExpirationDays;
119 policy.mPasswordHistory = passwordHistory;
120 policy.mPasswordComplexChars = passwordComplexChars;
121 policy.mRequireEncryption = requireEncryption;
122 policy.mDontAllowCamera = dontAllowCamera;
123 return policy;
143 Policy p3ain = setupPolicy(10, Policy.PASSWORD_MODE_SIMPLE, 0, 0, false, 0, 0, 0,
145 Policy.setAccountPolicy(mMockContext, a3, p3ain, null);
146 Policy p3aout = mSecurityPolicy.computeAggregatePolicy();
151 Policy p3bin = setupPolicy(10, Policy.PASSWORD_MODE_SIMPLE, 15, 16, false, 6, 2, 3,
153 Policy.setAccountPolicy(mMockContext, a3, p3bin, null);
154 Policy p3bout = mSecurityPolicy.computeAggregatePolicy();
166 Policy p4in = setupPolicy(20, Policy.PASSWORD_MODE_STRONG, 25, 26, false, 0, 5, 7,
169 Policy.setAccountPolicy(mMockContext, a4, p4in, null);
170 Policy p4out = mSecurityPolicy.computeAggregatePolicy();
173 assertEquals(Policy.PASSWORD_MODE_STRONG, p4out.mPasswordMode);
192 Policy p5in = setupPolicy(4, Policy.PASSWORD_MODE_SIMPLE, 5, 6, true, 1, 0, 0,
195 Policy.setAccountPolicy(mMockContext, a5, p5in, null);
196 Policy p5out = mSecurityPolicy.computeAggregatePolicy();
199 assertEquals(Policy.PASSWORD_MODE_STRONG, p5out.mPasswordMode);
216 // Found a policy. Ensure it matches.
217 Policy policy = Policy.restorePolicyWithId(mMockContext, policyKey);
218 assertNotNull(policy);
219 assertEquals(account.mPolicyKey, policy.mId);
222 Policy.getAccountIdWithPolicyKey(mMockContext, policy.mId));
226 assertNull("old policy not cleaned up",
227 Policy.restorePolicyWithId(mMockContext, oldKey));
237 Policy initial = setupPolicy(10, Policy.PASSWORD_MODE_SIMPLE, 0, 0, false, 0, 0, 0,
239 Policy.setAccountPolicy(mMockContext, accountId, initial, null);
243 Policy updated = setupPolicy(10, Policy.PASSWORD_MODE_SIMPLE, 0, 0, false, 0, 0, 0,
245 Policy.setAccountPolicy(mMockContext, accountId, updated, null);
248 // Remove the policy
249 Policy.clearAccountPolicy(
251 assertNull("old policy not cleaned up",
252 Policy.restorePolicyWithId(mMockContext, oldKey));
261 Policy p1 =
262 setupPolicy(1, Policy.PASSWORD_MODE_STRONG, 3, 4, true, 7, 8, 9, false, false);
263 Policy p2 =
264 setupPolicy(1, Policy.PASSWORD_MODE_STRONG, 3, 4, true, 7, 8, 9, false, false);
265 Policy p3 =
266 setupPolicy(2, Policy.PASSWORD_MODE_SIMPLE, 5, 6, true, 7, 8, 9, false, false);
267 Policy p4 =
268 setupPolicy(1, Policy.PASSWORD_MODE_STRONG, 3, 4, true, 7, 8, 9, false, true);
275 * Test the API to set/clear policy hold flags in an account
307 Policy p1 = setupPolicy(10, Policy.PASSWORD_MODE_SIMPLE, 0, 0, false, 0, 0, 0,
309 Policy.setAccountPolicy(mMockContext, a1, p1, "security-sync-key-1");
312 Policy p2 = setupPolicy(20, Policy.PASSWORD_MODE_STRONG, 25, 26, false, 0, 0, 0,
314 Policy.setAccountPolicy(mMockContext, a2, p2, "security-sync-key-2");
317 Policy.clearAccountPolicy(mMockContext, a3);
321 // Confirm that "enabling" device admin does not change security status (policy & sync key)
322 Policy before = mSecurityPolicy.getAggregatePolicy();
324 Policy after1 = mSecurityPolicy.getAggregatePolicy();
337 Policy after2 = mSecurityPolicy.getAggregatePolicy();
360 Policy p2 = setupPolicy(20, Policy.PASSWORD_MODE_STRONG, 25, 26, false, 30, 0, 0,
362 Policy.setAccountPolicy(mMockContext, a2, p2, null);
370 PolicyPolicy.PASSWORD_MODE_STRONG, 25, 26, false, 60, 0, 0,
372 Policy.setAccountPolicy(mMockContext, a3, p3, null);
380 Policy p4 = setupPolicy(20, Policy.PASSWORD_MODE_STRONG, 25, 26, false, 15, 0, 0,
382 Policy.setAccountPolicy(mMockContext, a4, p4, null);
410 Policy p2 = setupPolicy(20, Policy.PASSWORD_MODE_STRONG, 25, 26, false, 0, 0, 0,
412 Policy.setAccountPolicy(mMockContext, a2, p2, null);
436 Policy p3 = setupPolicy(20, Policy.PASSWORD_MODE_STRONG, 25, 26, false, 30, 0, 0,
438 Policy.setAccountPolicy(mMockContext, a3, p3, null);
474 Policy p1 =
475 setupPolicy(1, Policy.PASSWORD_MODE_STRONG, 3, 4, true, 7, 8, 9, false, false);
476 Policy p2 =
477 setupPolicy(1, Policy.PASSWORD_MODE_STRONG, 3, 4, true, 7, 8, 9, true, false);
484 Policy p1Result = mSecurityPolicy.clearUnsupportedPolicies(p1);
485 Policy p2Result = mSecurityPolicy.clearUnsupportedPolicies(p2);
493 // If encryption is unsupported, encryption policy bits are cleared
494 Policy policyExpect =
495 setupPolicy(1, Policy.PASSWORD_MODE_STRONG, 3, 4, true, 7, 8, 9, false,
505 // Policy.PASSWORD_MODE_NONE -> DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED
506 Policy p1 = setupPolicy(0, Policy.PASSWORD_MODE_NONE,
512 Policy p2 = setupPolicy(4, Policy.PASSWORD_MODE_SIMPLE,
518 Policy p3 = setupPolicy(4, Policy.PASSWORD_MODE_STRONG,
524 Policy p4 = setupPolicy(4, Policy.PASSWORD_MODE_STRONG,
530 private boolean policySetEqualsPolicy(PolicySet ps, Policy policy) {
531 if ((ps.mPasswordMode >> LegacyPolicySet.PASSWORD_MODE_SHIFT) != policy.mPasswordMode) {
534 if (ps.mMinPasswordLength != policy.mPasswordMinLength) return false;
535 if (ps.mPasswordComplexChars != policy.mPasswordComplexChars) return false;
536 if (ps.mPasswordHistory != policy.mPasswordHistory) return false;
537 if (ps.mPasswordExpirationDays != policy.mPasswordExpirationDays) return false;
538 if (ps.mMaxPasswordFails != policy.mPasswordMaxFails) return false;
539 if (ps.mMaxScreenLockTime != policy.mMaxScreenLockTime) return false;
540 if (ps.mRequireRemoteWipe != policy.mRequireRemoteWipe) return false;
541 if (ps.mRequireEncryption != policy.mRequireEncryption) return false;
542 if (ps.mRequireEncryptionExternal != policy.mRequireEncryptionExternal) return false;
547 // Policy flags; the three sets included here correspond to policies for three test
551 Policy policy = LegacyPolicySet.flagsToPolicy(flags);
552 assertTrue(policySetEqualsPolicy(ps, policy));
555 policy = LegacyPolicySet.flagsToPolicy(flags);
556 assertTrue(policySetEqualsPolicy(ps, policy));
559 policy = LegacyPolicySet.flagsToPolicy(flags);
560 assertTrue(policySetEqualsPolicy(ps, policy));
565 * new Policy table scheme