Merge "Add new policies to Policy and associated data structures"
This commit is contained in:
commit
c96cd4a848
|
@ -3026,5 +3026,19 @@ public abstract class EmailContent {
|
|||
public static final String REQUIRE_REMOTE_WIPE = "requireRemoteWipe";
|
||||
public static final String REQUIRE_ENCRYPTION = "requireEncryption";
|
||||
public static final String REQUIRE_ENCRYPTION_EXTERNAL = "requireEncryptionExternal";
|
||||
// ICS additions
|
||||
// Note: the appearance of these columns does not imply that we support these features; only
|
||||
// that we store them in the Policy structure
|
||||
public static final String REQUIRE_MANUAL_SYNC_WHEN_ROAMING = "requireManualSyncRoaming";
|
||||
public static final String DONT_ALLOW_CAMERA = "dontAllowCamera";
|
||||
public static final String DONT_ALLOW_ATTACHMENTS = "dontAllowAttachments";
|
||||
public static final String DONT_ALLOW_HTML = "dontAllowHtml";
|
||||
public static final String MAX_ATTACHMENT_SIZE = "maxAttachmentSize";
|
||||
public static final String MAX_TEXT_TRUNCATION_SIZE = "maxTextTruncationSize";
|
||||
public static final String MAX_HTML_TRUNCATION_SIZE = "maxHTMLTruncationSize";
|
||||
public static final String MAX_EMAIL_LOOKBACK = "maxEmailLookback";
|
||||
public static final String MAX_CALENDAR_LOOKBACK = "maxCalendarLookback";
|
||||
// Indicates that the server allows password recovery, not that we support it
|
||||
public static final String PASSWORD_RECOVERY_ENABLED = "passwordRecoveryEnabled";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,6 +65,16 @@ public final class Policy extends EmailContent implements EmailContent.PolicyCol
|
|||
public boolean mRequireRemoteWipe;
|
||||
public boolean mRequireEncryption;
|
||||
public boolean mRequireEncryptionExternal;
|
||||
public boolean mRequireManualSyncWhenRoaming;
|
||||
public boolean mDontAllowCamera;
|
||||
public boolean mDontAllowAttachments;
|
||||
public boolean mDontAllowHtml;
|
||||
public int mMaxAttachmentSize;
|
||||
public int mMaxTextTruncationSize;
|
||||
public int mMaxHtmlTruncationSize;
|
||||
public int mMaxEmailLookback;
|
||||
public int mMaxCalendarLookback;
|
||||
public boolean mPasswordRecoveryEnabled;
|
||||
|
||||
public static final int CONTENT_ID_COLUMN = 0;
|
||||
public static final int CONTENT_PASSWORD_MODE_COLUMN = 1;
|
||||
|
@ -77,13 +87,28 @@ public final class Policy extends EmailContent implements EmailContent.PolicyCol
|
|||
public static final int CONTENT_REQUIRE_REMOTE_WIPE_COLUMN = 8;
|
||||
public static final int CONTENT_REQUIRE_ENCRYPTION_COLUMN = 9;
|
||||
public static final int CONTENT_REQUIRE_ENCRYPTION_EXTERNAL_COLUMN = 10;
|
||||
public static final int CONTENT_REQUIRE_MANUAL_SYNC_WHEN_ROAMING = 11;
|
||||
public static final int CONTENT_DONT_ALLOW_CAMERA_COLUMN = 12;
|
||||
public static final int CONTENT_DONT_ALLOW_ATTACHMENTS_COLUMN = 13;
|
||||
public static final int CONTENT_DONT_ALLOW_HTML_COLUMN = 14;
|
||||
public static final int CONTENT_MAX_ATTACHMENT_SIZE_COLUMN = 15;
|
||||
public static final int CONTENT_MAX_TEXT_TRUNCATION_SIZE_COLUMN = 16;
|
||||
public static final int CONTENT_MAX_HTML_TRUNCATION_SIZE_COLUMN = 17;
|
||||
public static final int CONTENT_MAX_EMAIL_LOOKBACK_COLUMN = 18;
|
||||
public static final int CONTENT_MAX_CALENDAR_LOOKBACK_COLUMN = 19;
|
||||
public static final int CONTENT_PASSWORD_RECOVERY_ENABLED_COLUMN = 20;
|
||||
|
||||
public static final String[] CONTENT_PROJECTION = new String[] {RECORD_ID,
|
||||
PolicyColumns.PASSWORD_MODE, PolicyColumns.PASSWORD_MIN_LENGTH,
|
||||
PolicyColumns.PASSWORD_EXPIRATION_DAYS, PolicyColumns.PASSWORD_HISTORY,
|
||||
PolicyColumns.PASSWORD_COMPLEX_CHARS, PolicyColumns.PASSWORD_MAX_FAILS,
|
||||
PolicyColumns.MAX_SCREEN_LOCK_TIME, PolicyColumns.REQUIRE_REMOTE_WIPE,
|
||||
PolicyColumns.REQUIRE_ENCRYPTION, PolicyColumns.REQUIRE_ENCRYPTION_EXTERNAL
|
||||
PolicyColumns.REQUIRE_ENCRYPTION, PolicyColumns.REQUIRE_ENCRYPTION_EXTERNAL,
|
||||
PolicyColumns.REQUIRE_MANUAL_SYNC_WHEN_ROAMING, PolicyColumns.DONT_ALLOW_CAMERA,
|
||||
PolicyColumns.DONT_ALLOW_ATTACHMENTS, PolicyColumns.DONT_ALLOW_HTML,
|
||||
PolicyColumns.MAX_ATTACHMENT_SIZE, PolicyColumns.MAX_TEXT_TRUNCATION_SIZE,
|
||||
PolicyColumns.MAX_HTML_TRUNCATION_SIZE, PolicyColumns.MAX_EMAIL_LOOKBACK,
|
||||
PolicyColumns.MAX_CALENDAR_LOOKBACK, PolicyColumns.PASSWORD_RECOVERY_ENABLED
|
||||
};
|
||||
|
||||
public static final Policy NO_POLICY = new Policy();
|
||||
|
@ -222,6 +247,18 @@ public final class Policy extends EmailContent implements EmailContent.PolicyCol
|
|||
if (mPasswordMaxFails != otherPolicy.mPasswordMaxFails) return false;
|
||||
if (mPasswordMinLength != otherPolicy.mPasswordMinLength) return false;
|
||||
if (mPasswordMode != otherPolicy.mPasswordMode) return false;
|
||||
if (mRequireManualSyncWhenRoaming != otherPolicy.mRequireManualSyncWhenRoaming) {
|
||||
return false;
|
||||
}
|
||||
if (mDontAllowCamera != otherPolicy.mDontAllowCamera) return false;
|
||||
if (mDontAllowAttachments != otherPolicy.mDontAllowAttachments) return false;
|
||||
if (mDontAllowHtml != otherPolicy.mDontAllowHtml) return false;
|
||||
if (mMaxAttachmentSize != otherPolicy.mMaxAttachmentSize) return false;
|
||||
if (mMaxTextTruncationSize != otherPolicy.mMaxTextTruncationSize) return false;
|
||||
if (mMaxHtmlTruncationSize != otherPolicy.mMaxHtmlTruncationSize) return false;
|
||||
if (mMaxEmailLookback != otherPolicy.mMaxEmailLookback) return false;
|
||||
if (mMaxCalendarLookback != otherPolicy.mMaxCalendarLookback) return false;
|
||||
if (mPasswordRecoveryEnabled != otherPolicy.mPasswordRecoveryEnabled) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -237,6 +274,7 @@ public final class Policy extends EmailContent implements EmailContent.PolicyCol
|
|||
code += (mPasswordMaxFails << 18);
|
||||
code += (mPasswordMinLength << 22);
|
||||
code += (mPasswordMode << 26);
|
||||
// Don't need to include the other fields
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -255,6 +293,17 @@ public final class Policy extends EmailContent implements EmailContent.PolicyCol
|
|||
mRequireEncryption = cursor.getInt(CONTENT_REQUIRE_ENCRYPTION_COLUMN) == 1;
|
||||
mRequireEncryptionExternal =
|
||||
cursor.getInt(CONTENT_REQUIRE_ENCRYPTION_EXTERNAL_COLUMN) == 1;
|
||||
mRequireManualSyncWhenRoaming =
|
||||
cursor.getInt(CONTENT_REQUIRE_MANUAL_SYNC_WHEN_ROAMING) == 1;
|
||||
mDontAllowCamera = cursor.getInt(CONTENT_DONT_ALLOW_CAMERA_COLUMN) == 1;
|
||||
mDontAllowAttachments = cursor.getInt(CONTENT_DONT_ALLOW_ATTACHMENTS_COLUMN) == 1;
|
||||
mDontAllowHtml = cursor.getInt(CONTENT_DONT_ALLOW_HTML_COLUMN) == 1;
|
||||
mMaxAttachmentSize = cursor.getInt(CONTENT_MAX_ATTACHMENT_SIZE_COLUMN);
|
||||
mMaxTextTruncationSize = cursor.getInt(CONTENT_MAX_TEXT_TRUNCATION_SIZE_COLUMN);
|
||||
mMaxHtmlTruncationSize = cursor.getInt(CONTENT_MAX_HTML_TRUNCATION_SIZE_COLUMN);
|
||||
mMaxEmailLookback = cursor.getInt(CONTENT_MAX_EMAIL_LOOKBACK_COLUMN);
|
||||
mMaxCalendarLookback = cursor.getInt(CONTENT_MAX_CALENDAR_LOOKBACK_COLUMN);
|
||||
mPasswordRecoveryEnabled = cursor.getInt(CONTENT_PASSWORD_RECOVERY_ENABLED_COLUMN) == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -270,6 +319,16 @@ public final class Policy extends EmailContent implements EmailContent.PolicyCol
|
|||
values.put(PolicyColumns.REQUIRE_REMOTE_WIPE, mRequireRemoteWipe);
|
||||
values.put(PolicyColumns.REQUIRE_ENCRYPTION, mRequireEncryption);
|
||||
values.put(PolicyColumns.REQUIRE_ENCRYPTION_EXTERNAL, mRequireEncryptionExternal);
|
||||
values.put(PolicyColumns.REQUIRE_MANUAL_SYNC_WHEN_ROAMING, mRequireManualSyncWhenRoaming);
|
||||
values.put(PolicyColumns.DONT_ALLOW_CAMERA, mDontAllowCamera);
|
||||
values.put(PolicyColumns.DONT_ALLOW_ATTACHMENTS, mDontAllowAttachments);
|
||||
values.put(PolicyColumns.DONT_ALLOW_HTML, mDontAllowHtml);
|
||||
values.put(PolicyColumns.MAX_ATTACHMENT_SIZE, mMaxAttachmentSize);
|
||||
values.put(PolicyColumns.MAX_TEXT_TRUNCATION_SIZE, mMaxTextTruncationSize);
|
||||
values.put(PolicyColumns.MAX_HTML_TRUNCATION_SIZE, mMaxHtmlTruncationSize);
|
||||
values.put(PolicyColumns.MAX_EMAIL_LOOKBACK, mMaxEmailLookback);
|
||||
values.put(PolicyColumns.MAX_CALENDAR_LOOKBACK, mMaxCalendarLookback);
|
||||
values.put(PolicyColumns.PASSWORD_RECOVERY_ENABLED, mPasswordRecoveryEnabled);
|
||||
return values;
|
||||
}
|
||||
|
||||
|
@ -373,6 +432,16 @@ public final class Policy extends EmailContent implements EmailContent.PolicyCol
|
|||
dest.writeInt(mRequireRemoteWipe ? 1 : 0);
|
||||
dest.writeInt(mRequireEncryption ? 1 : 0);
|
||||
dest.writeInt(mRequireEncryptionExternal ? 1 : 0);
|
||||
dest.writeInt(mRequireManualSyncWhenRoaming ? 1 : 0);
|
||||
dest.writeInt(mDontAllowCamera ? 1 : 0);
|
||||
dest.writeInt(mDontAllowAttachments ? 1 : 0);
|
||||
dest.writeInt(mDontAllowHtml ? 1 : 0);
|
||||
dest.writeInt(mMaxAttachmentSize);
|
||||
dest.writeInt(mMaxTextTruncationSize);
|
||||
dest.writeInt(mMaxHtmlTruncationSize);
|
||||
dest.writeInt(mMaxEmailLookback);
|
||||
dest.writeInt(mMaxCalendarLookback);
|
||||
dest.writeInt(mPasswordRecoveryEnabled ? 1 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -391,5 +460,15 @@ public final class Policy extends EmailContent implements EmailContent.PolicyCol
|
|||
mRequireRemoteWipe = in.readInt() == 1;
|
||||
mRequireEncryption = in.readInt() == 1;
|
||||
mRequireEncryptionExternal = in.readInt() == 1;
|
||||
mRequireManualSyncWhenRoaming = in.readInt() == 1;
|
||||
mDontAllowCamera = in.readInt() == 1;
|
||||
mDontAllowAttachments = in.readInt() == 1;
|
||||
mDontAllowHtml = in.readInt() == 1;
|
||||
mMaxAttachmentSize = in.readInt();
|
||||
mMaxTextTruncationSize = in.readInt();
|
||||
mMaxHtmlTruncationSize = in.readInt();
|
||||
mMaxEmailLookback = in.readInt();
|
||||
mMaxCalendarLookback = in.readInt();
|
||||
mPasswordRecoveryEnabled = in.readInt() == 1;
|
||||
}
|
||||
}
|
|
@ -121,7 +121,8 @@ public class EmailProvider extends ContentProvider {
|
|||
// Column Mailbox.serverId is used for the server-side pathname of a mailbox.
|
||||
// Version 19: Add Policy table; add policyKey to Account table and trigger to delete an
|
||||
// Account's policy when the Account is deleted
|
||||
public static final int DATABASE_VERSION = 19;
|
||||
// Version 20: Add new policies to Policy table
|
||||
public static final int DATABASE_VERSION = 20;
|
||||
|
||||
// Any changes to the database format *must* include update-in-place code.
|
||||
// Original version: 2
|
||||
|
@ -561,7 +562,17 @@ public class EmailProvider extends ContentProvider {
|
|||
+ PolicyColumns.MAX_SCREEN_LOCK_TIME + " integer, "
|
||||
+ PolicyColumns.REQUIRE_REMOTE_WIPE + " integer, "
|
||||
+ PolicyColumns.REQUIRE_ENCRYPTION + " integer, "
|
||||
+ PolicyColumns.REQUIRE_ENCRYPTION_EXTERNAL + " integer"
|
||||
+ PolicyColumns.REQUIRE_ENCRYPTION_EXTERNAL + " integer, "
|
||||
+ PolicyColumns.REQUIRE_MANUAL_SYNC_WHEN_ROAMING + " integer, "
|
||||
+ PolicyColumns.DONT_ALLOW_CAMERA + " integer, "
|
||||
+ PolicyColumns.DONT_ALLOW_ATTACHMENTS + " integer, "
|
||||
+ PolicyColumns.DONT_ALLOW_HTML + " integer, "
|
||||
+ PolicyColumns.MAX_ATTACHMENT_SIZE + " integer, "
|
||||
+ PolicyColumns.MAX_TEXT_TRUNCATION_SIZE + " integer, "
|
||||
+ PolicyColumns.MAX_HTML_TRUNCATION_SIZE + " integer, "
|
||||
+ PolicyColumns.MAX_EMAIL_LOOKBACK + " integer, "
|
||||
+ PolicyColumns.MAX_CALENDAR_LOOKBACK + " integer, "
|
||||
+ PolicyColumns.PASSWORD_RECOVERY_ENABLED + " integer"
|
||||
+ ");";
|
||||
db.execSQL("create table " + Policy.TABLE_NAME + s);
|
||||
}
|
||||
|
@ -1005,6 +1016,38 @@ public class EmailProvider extends ContentProvider {
|
|||
}
|
||||
oldVersion = 19;
|
||||
}
|
||||
if (oldVersion == 19) {
|
||||
try {
|
||||
db.execSQL("alter table " + Policy.TABLE_NAME
|
||||
+ " add column " + PolicyColumns.REQUIRE_MANUAL_SYNC_WHEN_ROAMING +
|
||||
" integer;");
|
||||
db.execSQL("alter table " + Policy.TABLE_NAME
|
||||
+ " add column " + PolicyColumns.DONT_ALLOW_CAMERA + " integer;");
|
||||
db.execSQL("alter table " + Policy.TABLE_NAME
|
||||
+ " add column " + PolicyColumns.DONT_ALLOW_ATTACHMENTS + " integer;");
|
||||
db.execSQL("alter table " + Policy.TABLE_NAME
|
||||
+ " add column " + PolicyColumns.DONT_ALLOW_HTML + " integer;");
|
||||
db.execSQL("alter table " + Policy.TABLE_NAME
|
||||
+ " add column " + PolicyColumns.MAX_ATTACHMENT_SIZE + " integer;");
|
||||
db.execSQL("alter table " + Policy.TABLE_NAME
|
||||
+ " add column " + PolicyColumns.MAX_TEXT_TRUNCATION_SIZE +
|
||||
" integer;");
|
||||
db.execSQL("alter table " + Policy.TABLE_NAME
|
||||
+ " add column " + PolicyColumns.MAX_HTML_TRUNCATION_SIZE +
|
||||
" integer;");
|
||||
db.execSQL("alter table " + Policy.TABLE_NAME
|
||||
+ " add column " + PolicyColumns.MAX_EMAIL_LOOKBACK + " integer;");
|
||||
db.execSQL("alter table " + Policy.TABLE_NAME
|
||||
+ " add column " + PolicyColumns.MAX_CALENDAR_LOOKBACK + " integer;");
|
||||
db.execSQL("alter table " + Policy.TABLE_NAME
|
||||
+ " add column " + PolicyColumns.PASSWORD_RECOVERY_ENABLED +
|
||||
" integer;");
|
||||
} catch (SQLException e) {
|
||||
// Shouldn't be needed unless we're debugging and interrupt the process
|
||||
Log.w(TAG, "Exception upgrading EmailProvider.db from 19 to 2 " + e);
|
||||
}
|
||||
oldVersion = 20;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -116,6 +116,16 @@ public class PolicyTests extends ProviderTestCase2<EmailProvider> {
|
|||
policy.mRequireRemoteWipe = true;
|
||||
policy.mRequireEncryption = true;
|
||||
policy.mRequireEncryptionExternal = true;
|
||||
policy.mRequireManualSyncWhenRoaming = true;
|
||||
policy.mDontAllowCamera = false;
|
||||
policy.mDontAllowAttachments = true;
|
||||
policy.mDontAllowHtml = false;
|
||||
policy.mMaxAttachmentSize = 22222;
|
||||
policy.mMaxTextTruncationSize = 33333;
|
||||
policy.mMaxHtmlTruncationSize = 44444;
|
||||
policy.mMaxEmailLookback = 5;
|
||||
policy.mMaxCalendarLookback = 6;
|
||||
policy.mPasswordRecoveryEnabled = true;
|
||||
Parcel parcel = Parcel.obtain();
|
||||
policy.writeToParcel(parcel, 0);
|
||||
parcel.setDataPosition(0);
|
||||
|
|
Loading…
Reference in New Issue