Commit Graph

66 Commits

Author SHA1 Message Date
Marc Blank f419287f22 DO NOT MERGE: Move emailcommon2 sources to emailcommon
Change-Id: I06df7e467cd2e0117df8b8db3ddc6ff9da13f1c7
2012-06-28 11:15:06 -07:00
Marc Blank 03cd72805d Revert to old Email app
* These are the last sources in the ICS-MR1 tree

Change-Id: Ida4651bddd92a06a518d00f3e1f275ab3a80c8ae
2012-04-25 13:58:23 -07:00
Marc Blank ebb79619e8 Move account delete logic to EmailProvider
* This functionality had to move away from Controller

Change-Id: I557918a325eab8c83a9728fa1ce33dde8b86158f
2012-03-09 12:59:21 -08:00
Marc Blank fd81e19779 Don't save Policy with Account
Change-Id: Ib3601daee8780640a07db573f623e99279c9f9b1
2011-11-21 13:04:26 -08:00
Marc Blank 2736c1a11c Rewrite of security policy handling and service code
* Remove PolicyService APIs policiesRequired, policiesUpdated,
  isSupported, clearUnsupportedPolicies, and isActiveAdmin
* Add PolicyService API setAccountPolicy, which is the sole
  method by which security policies are promulgated
* Add protocolPoliciesEnabled and protocolPoliciesUnsupported
  to the Policy class; these are packed, localized strings
  indicating policies that the protocol itself have enabled
  and/or cannot support (i.e. these are policies that are
  unknown to the DPM, e.g. don't load attachments)
* Differentiate in security notifications between three kinds
  of policy changes - changes that don't require user
  intervention (e.g. reducing requirements), changes that
  require user intervention (the legacy notification), and
  changes that make the account unsyncable (e.g. the server
  adding an unsupportable policy). Handle all possible policy
  changes cleanly.
* Make security notifications per account (with multiple
  accounts, notifications would get arbitrarily munged)
* Expose ALL enforced policies via the account settings
  screen in two categories: policies enforced (including
  both policies enforced by the DPM and policies enforced
  by the protocol) and policies unsupported (note that these
  can only be seen if policies are changed after an account
  is created; we do not allow the creation of an account
  when any required policies are unsupported).  Add a
  button that forces a sync attempt, for accounts that
  are locked out, but whose policies have changed on
  the server (this would otherwise require a reboot).
* Updated unit tests

Bug: 5398682
Bug: 5393724
Bug: 5379682
Change-Id: I4a3df823913a809874ed959d228177f0fc799281
2011-10-25 10:32:34 -07:00
Marc Blank c82c1caf01 Include external storage in remote wipe
* Apparently, this is required via Microsoft specifications, though
  there had been an earlier decision not to do this

Bug: 5384246
Change-Id: I05b6c2d21d3b295ad696f26a7a13cba6f1974e83
2011-09-28 09:41:44 -07:00
Marc Blank e86d8af163 Password history changes do NOT require user intervention
* A change in history requirement is not intended to force a new
  password immediately; we just tell the DPM what the new
  requirement is...
* This is one cause of the below-referenced bug

Bug: 5221119
Change-Id: I890b42d4eab4fbd9d34665fbea138f179d5d3215
2011-08-28 16:34:28 -07:00
Marc Blank ce582527bb Fix dont-allow-camera in Email DPM
* We weren't checking for it in determining whether our policies
  were active; because of this, we never actually SET the policy
  in the DPM

Bug: 5193399
Change-Id: I276901be21be681f66891f5374ec58cf1ea7b4be
2011-08-21 21:06:54 -07:00
Marc Blank c6df1d605f Prevent NPE's in AccountSecurity
* This CL fixes the referenced bug, but it does NOT explain how
  mAccount; best guess is that the process was killed and then
  restarted when the result from DPM was available.
* Assuming this is the case, we remove the background task loading
  mAccount, avoiding a possible race.
* Also, it's not clear why clearNotifications didn't use the
  account id argument; what if there's more than one account that
  uses security?  Filing a bug about this.

Bug: 5048912
Change-Id: I734834337ab6e409d77624e7c7370350de76becb
2011-07-19 14:38:29 -07:00
Ben Komalo e76962b1b9 Revert "Enable SD card encryption policy when emulated"
This is a manual cherry-pick of c379ebe372
This reverts commit 7fd14be804

The introduction of proper SD cards breaks the invariant that "external"
storage can be encrypted. Unfortunately, this means that accounts with
that policy bit set will have to be removed for now.

Accounts with the security policy set will be forced to go through
security provisioning on the next sync, using the regular mechanisms of
showing a notification with "Security update required", and then having
it fail. :(

Bug: 4466311
Change-Id: I68119b14f8d198779c2073296e228bc6772136ee
2011-07-04 16:16:07 -07:00
Ben Komalo aa0a355397 Handle upgrade from existing device admins
This ensures old admins that can't control the camera doesn't try to do
so

Bug: 4686257
Change-Id: Ia2bb8bf2ccf9fb3d1d45ce1ba0affd2ccc9822a9
2011-06-16 14:40:15 -07:00
Ben Komalo d09cff0888 Make "don't allow camera" a supported policy.
This sends the bit to the DPM. Separate changes have been/will be made
to change the provision parser and support it in the DPM.

Bug: 4185316
Change-Id: I44872ceb095a28539b047a0641cc499c7186a9b3
2011-06-16 10:44:48 -07:00
Marc Blank f5418f1f93 Move Account into its own top-level class
Change-Id: Ide7c991b7d4d418dbe17164421425bf898ba64ee
2011-06-13 15:37:22 -07:00
Marc Blank 67fefe21b6 Remove change made to workaround DPM issue
Change-Id: I88a9663d513e13ecca5957c61e2e817a8bd847d5
2011-05-26 12:06:28 -07:00
Marc Blank 28b48acab0 resolved conflicts for merge of 7c270c50 to master
Change-Id: Id1694449a8a270429cf32b2ecd70da7afa3447a1
2011-05-25 09:34:37 -07:00
Marc Blank 4f5d4e29a8 Always set policies in DPM before checking whether they are active
* Since DPM can erroneously report a password failure (specifically,
  isActivePasswordSufficient() can return false when, in fact, the
  active password is just fine)
* This is the proximate cause of the referenced bug; we just weren't
  prepared to have the DPM mislead us...

Bug: 4464610
Change-Id: Ifcb85c0729e9a1884fbcf7b4180eb332bbfef1b5
2011-05-23 16:48:14 -07:00
Marc Blank 6d9d71683a Workaround bug in DPM related to initialization of our admin
Bug: 4436285

Change-Id: If6f0ccaa9e1479fae0dbd1853a462eaf7948ccfc
2011-05-17 13:27:02 -07:00
Marc Blank aeee10e57e Rework of security policy storage
* Replace crazy (and soon to be "full") bit fields stored in an account's
  securityFlags with a row in a newly created Policy table (thus, fully
  expandable)
* Update code from database version 17 to 18; adds Policy table, a
  policyKey row in Account, and a revised trigger that deletes Policy
  information for deleted Accounts
* Update old PolicySet unit tests to work against the new Policy class
* Add test for the conversion of securityFlags to Policy
* Tested in a variety of scenarios; appears to be functionally equivalent

Change-Id: I1505ee75230d6a0d3c2b62a46326f39c2c7f9eb5
2011-05-03 11:11:47 -07:00
Makoto Onuki 308ce92847 Better fix for the PendingIntent issue.
Refactor the changes introduced in Ib02842bb.

- Now Welcome and AccountSettingsXL accept intents with URLs of the following
style, and get IDs from query params, rather than extras.

Welcome:
content://ui.email.android.com/view/mailbox?ACCOUNT_ID=1&MAILBOX_ID=2&MESSAGE_ID=3

AccountSettingsXL:
content://ui.email.android.com/settings?ACCOUNT_ID=1

- Now the "new message" and "login failed" notifications use these new style
intents, so the system wouldn't merge PendingIntents for different accounts.

Also:
- Moved all notification creation logic to NotificationController.
  (Except the one in CalendarSyncEnabler; which is used only to support
  upgrading from pre-froyo and I don't think it's worth refactoring.)

- Note the "password expired/expiring" and "security needed" notifications
aren't changed; they still use extras to store account IDs.  This is okay
because these notifications are not per-account.

Bug 4065269

Change-Id: I70737438d2e7c45fd7488a5b0a7105c8568e02f7
2011-03-23 14:49:38 -07:00
Andy Stadler 22759bacd9 Handle complex chars policy correctly
* We needed to set DevicePolicyMnager.PASSWORD_QUALITY_COMPLEX
* Setting this, we also need to clear some of the defaults for complex
  mode that are not correct for Exchange's definition of "complex".
* Unit tests

Bug: 4092218
Change-Id: Iea7bd05d48f1aa9406222c1db5937cfd7f2662b8
2011-03-16 09:48:08 -07:00
Andy Stadler 7fd14be804 Enable SD card encryption policy when emulated
* This is is a minimal implementation that only supports the external
  encryption policy when there is no physical/removable storage, and
  the emulated external storage is located within an encrypted backing
  store.

Bug: 3351426
Change-Id: Id96e9277f810beeebf816a914acd3d733eb713ea
2011-03-02 16:41:19 -08:00
Andy Stadler f489413142 Add contextual dialogs after notifications
* When security settings notification is clicked, inform user that
  they need to change settings (before dumping them in security
  settings.)
* On an authentication failure, present a dialog to the user explaining
  that the username or password may be incorrect.
* When the device pin/password is expiring or expired, present a dialog
  to the user explaining that it needs to be updated.

Bug: 3238657
Change-Id: I8fca446fa3c1bf87a95938553dbdc362c3df220e
2011-02-18 18:23:18 -08:00
Andy Stadler c6d344ad2a Refresh email notifications (part I)
* Use strings that fit properly in new notifications
* General cleanups & rewrites from Roy
* Remove showWarningNotification() and use postAccountNotification()

This is part I.  Part II will add dialogs triggered by some of these
notifications, to provide more explanation to the user of what's wrong
and how to fix it.

Bug: 3238657
Change-Id: Ib51bcb4412f8a09a6f97653f0b5f8642efe2ac1e
2011-02-16 16:38:18 -08:00
Marc Blank 31d9acbf06 Email split, part huit: Refactor constants, clean emailcommon
* There are three pieces to this CL (sorry):
  1) Move and/or rename some constants into emailcommon
  2) Move Utility to emailcommon, moving the few UI
     related utilities back into Email (FolderProperties
     and UiUtilities)
  3) Remove all references to resources from emailcommon
* The three pieces relate in that, between them, they allow
  the emailcommon static library to compile cleanly

Bug: 3442973

Change-Id: Ic5e3abaa2a1b36999e0b6653c6c2134ea1bd544f
2011-02-14 12:18:10 -08:00
Marc Blank a7bc0319a7 Email split, part six: EmailContent
* Moved EmailContent to emailcommon

Change-Id: Ib3db1bfcfe74554c0e5afd3cfce6d72f26e9aeb9
2011-02-10 19:44:29 -08:00
Marc Blank 9ba506c4dd Email split, part deux: PolicyService
* Split PolicySet from SecurityPolicy and move to emailcommon
* Define PolicyService that sync adapter services can use to
  interact with the Email DPM administrator
* Implement PolicyServiceProxy for exchange
* Implement PolicyService in email
* Modify imports, references, etc. as required

Bug: 3442973

Change-Id: I92015e21f780a68754b318da89fbb33570f334a2
2011-02-10 13:53:37 -08:00
Marc Blank 844b14f851 Fix NPE in SecurityPolicy.policiesRequired
* Add check for null Account, as this method can be called from a
  background thread, and the Account might have been deleted by the
  time we're called

Bug: 3396365
Change-Id: Ie125ed714c73d51beaedc818b6b731cea941666f
2011-01-26 18:18:45 -08:00
Andy Stadler a0d080558f Properly handle unsupported encryption policy
* This fixes the case of:
  * a device that does *not* support device encryption
  * connecting to an account that *does* require device encryption
  * but also supports "non-provisioned devices" (making the encryption
    requirement optional.)
* Added unit test

Bug: 3367191
Change-Id: I894e68c4119a102dad02d2e0815fccdae1e87189
2011-01-19 11:40:48 -08:00
Andy Stadler c2e638351c Updates to follow DPM api changes
* Use getStorageEncryptionStatus() to check device status
* Also, check granted policy on USES_ENCRYPTED_STORAGE

Bug: 3346641

Change-Id: I9e9a45a6d1d3cf4714e27b69cdb5952c841c640d
2011-01-17 12:54:40 -08:00
Andy Stadler 469f2987dc Add encryption to SecurityPolicy
* Add encrypted-storage to uses-policies
* Add new field to PolicySet
* Add "false" to all constructor callers
* Add unit tests (including fixing some existing unit tests)
* Add new logic to AccountSecurity activity t0 dispatch both password
  and encryption requests.

Bug: 3346641
Change-Id: I54f39bc9b6fbe21c033a05b36b83081e5c78a296
2011-01-13 13:12:55 -08:00
Andy Stadler a2269e84c6 Remove disk access from DeviceAdminReceiver callbacks
* DeviceAdminReceiver is actually a BroadcastReceiver, must follow
  guidelines to prevent ANR or early process kill.
* Remove all uses of AsyncTask from DeviceAdminReceiver
* Pass all calls through EmailBroadcastProcessorService
* Minor restructuring of EmailBroadcastProcessorService to support
  this use.

Change-Id: Ic6257ea5eff1bd466a736e0f93cb89b1cf8aa73e
2010-12-30 00:16:55 -08:00
Andy Stadler e7f4d3ebfc Handle upgrade path for adding DPM policies
* All active admin checks now go through common method
* Common code check both isAdminActive and the new (upgrade) policies

Bug: 3253179
Change-Id: Ie81f35906c164051f38c1f1f637d0c04b37eef16
2010-12-09 10:09:58 -08:00
Andy Stadler 1ca111c19c Add password expiration plumbing
* Set aggregated expiration values with DPM
* Fix min/max logic when aggregating, and fix unit test
* Add expiration tests when checking if policies are active
* Add expire-password to uses-policies set
* Handle password refresh (clear notifications and sec. holds)
* Handle password expiration (warning and/or wipe synced data)
* Unit tests for provider-level methods
* Refactor common security notification logic
* Placeholder notification strings (need final)

Bug: 3197935
Change-Id: Idf1975edd81dd7f55729156dc6b1002b7d09841f
2010-12-01 12:58:36 -08:00
Marc Blank 02d59d2194 Delete secured accounts if device admin is disabled
* Update unit test

Bug: 2817683
Change-Id: Ia7117c34e7bbba13ac4f2ff375d19b3ef94ef49c
2010-10-27 09:03:21 -07:00
Makoto Onuki 899c5b8661 Switch to tablet style notification
- Now we show separate notification for each account
- New notification has sender photo, sender name, and subject
  of the latest email
- Added the NotificationController class, which is intended to manage
  all notifications besides "new message" eventually.

The framework doesn't seem to be 100% ready, and it's not clear how to
add the 3rd line in the expanded notification at this point.  Need to
revisit it later to verify UI details.

Change-Id: I40193ee372cb6b2b7245c1588890f238b2469699
2010-09-29 18:35:17 -07:00
Andrew Stadler 0813c7051f resolved conflicts for merge of 0d9ed341 to master
Change-Id: I198f760ef1734cf4a64c875236a2352859dc1a72
2010-09-22 14:37:44 -07:00
Andy Stadler 6278dcdeaf Fix test failures
Methods were used by tests only and being stripped by PG.

Bug: 2894378
Change-Id: Ieb1dd0daa8bd380c66a7b1e6151c5e5b22cbe38c
2010-09-22 12:06:41 -07:00
Marc Blank 61911d4ff7 Fix another inconsistent set of PolicySet values
* EAS can send both "simple password" and a non-zero number of
  required complex characters; we're supposed to ignore the
  complex character requirement in this case
* Force complex characters to zero if password is "simple"
* Update constructor test to check the fix

Bug: 2903349
Change-Id: I3d42bd3c8f3667d8f3027da9e91e0dd18722d9bf
2010-08-30 20:18:16 -07:00
Andrew Stadler a30631da1c Clear password related policies in PolicySet when p/w not required
Merge from master of c263810b08

Bug: 2883736
Change-Id: Iec4ed0e320d67aee8a89092ac650c0960540057b
2010-08-12 14:56:32 -07:00
Marc Blank c263810b08 Clear password related policies in PolicySet when p/w not required
Bug: 2883736
Change-Id: I2c9c573aea9a4fef1699ff6339e8ef628d7f2269
2010-08-07 17:27:16 -07:00
Marc Blank b91eea0119 resolved conflicts for merge of fbf501fe to master
Change-Id: Ic68cbf2de1877ab06744287f57c1c33c4e0e573a
2010-08-04 10:28:40 -07:00
Marc Blank 2b2b3448ec 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
2010-08-02 19:39:09 -07:00
Makoto Onuki bcf32320e2 Move isSecurityHold/clearAccountHoldFlags to Account
- Added unit tests
- I see the "open a cursor, move to the first row, read a column" pattern over
  and over.  Added a utility method for this.  (Let's try not to bloat the
  binary by copying code around!)
- Added helper classes for database related tests
- Removed code dup

Change-Id: I380959215cc1661b252158f0f6e35369b499cdf8
2010-07-28 11:12:38 -07:00
Marc Blank 9444a54866 resolved conflicts for merge of 2cb5acc5 to master
Change-Id: I4b3379b7b8ebfca36eda3ae649f009659e682e87
2010-07-15 09:59:50 -07:00
Marc Blank 8b36acb10d Backport: Handle "Allow non-provisionable devices" properly
* Backport from master branch
* Send policy key of "0" when validating; this gets us the policies
  even if "Allow..." is enabled (currently, we simply don't see the
  policies)
* If we don't support all of the policies, send back the response
  code indicating support for partial support.  If we get a positive
  response back, then we're good to go - the server allows devices
  with partial support.  Otherwise, we fail as we always have - with
  the toast indicating that the device doesn't support required
  policies
* Remove PolicySet.isSupported() and ensure proper field ranges
  within the constructor
* Update tests as appropriate

Bug: 2759782
Change-Id: Ida5663a9b35c75ecc61a5f442be0bd60b433cb73
2010-07-14 22:47:47 -07:00
Marc Blank d6d874f8c6 Streamline security setup flow
* The setup flow is changed such that the user is asked to activate
  device administration before leaving the setup flow, rather than
  having to wait for the notification to appear, etc.
* Accounts requiring security are created in a security hold state
  to prevent initial sync until device administration is active

Change-Id: I7e33cf98466370ae27414b99018f7aee71e9e237
2010-06-25 09:32:11 -07:00
Marc Blank 9b4988de43 Implement support for new security policies
* Minimum complex characters
* Password history (i.e. disallow re-use of past n passwords)
* Password expiration
* Password expiration is NOT yet supported in the framework; there
  is a TODO in this CL and a trivial change will be needed when
  support arrives; for now, we report this as unsupported
* The two implemented policies are testable

Change-Id: I477adbc000577c57d1ab1788378c97a60018c10c
2010-06-23 14:51:59 -07:00
Marc Blank 1d6dab2956 Handle "Allow non-provisionable devices" properly
* Send policy key of "0" when validating; this gets us the policies
  even if "Allow..." is enabled (currently, we simply don't see the
  policies)
* If we don't support all of the policies, send back the response
  code indicating support for partial support.  If we get a positive
  response back, then we're good to go - the server allows devices
  with partial support.  Otherwise, we fail as we always have - with
  the toast indicating that the device doesn't support required
  policies
* Remove PolicySet.isSupported() and ensure proper field ranges
  within the constructor
* Update tests as appropriate

Bug: 2759782
Change-Id: I5f354a0e2d81844aff75d8a8a6de3b97f0020c1f
2010-06-16 13:14:36 -07:00
Andrew Stadler 572c06f91b DO NOT MERGE - Revert workaround for KeyguardLock problem
This reverts commit 3ee0cad5f5.

Because commit 284b62e1b8c3419bfd02c6fea5ba0a68146c06f8 fixes the underlying
conflict between DeviceAdmin policies and apps attempting to disable the
Keyguard Lock, this patch is no longer required.

Accounts with a server policy requiring a device PIN or Password will
now work properly.

Bug: 2737842
Change-Id: I533c27a01a8a331dc11a0cb84bcc78f48edf621c
2010-06-11 11:21:41 -07:00
Andrew Stadler 3ee0cad5f5 DO NOT MERGE Workaround for KeyguardLock problem
* The device policies that enforce the use of a device PIN or password
  can be sidestepped by apps that implement KeyguardManager.KeyguardLock
* This renders the policies unuseable
* To prevent this, the email app now scans for any packages holding the
  DISABLE_KEYGUARD permission.  The existence of any non-system app
  with this permission will put all security-enabled EAS accounts into
  a security hold, and post a dialog describing the problem.
* The user must uninstall any such app(s) in order to sync their EAS data.

Bug: 2737842
Change-Id: I4c96d76b12d9242b5c755dd60d7578a825fae597
2010-06-04 11:10:03 -07:00