Commit Graph

56 Commits

Author SHA1 Message Date
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
Makoto Onuki 968be441b4 Don't store arbitrary Context in singletons, which causes memory leak.
We have singletons that store a Context passed to getInstance().
The problem is that when we call them, we casually pass any Context at hand.
If it's an activity (which is often the case), it'll never be GCed.

This CL make them store the application context insteaed.

Change-Id: I1abcc2c08d3f8201416d6c14720f041693823b4e
2010-05-20 16:21:06 -07:00
Andrew Stadler a87f8d8bbc Changes to improve security policy setup
* SecurityPolicy:  Fix bug that prevents any notifications after the
    user hits "cancel all" from the notification pane.
* AccountSecurity: If the user cancels the device admin acceptance
    activity, repost the notification.
* MesageList:  Catch security hold condition when entering a mailbox, and
    launch security setup activity.

Bug: 2585159
Change-Id: I60d5d8c693cc5f00fe98a9cc69265802f5bee813
2010-04-13 02:15:37 -07:00
Andrew Stadler 856e09d76a Properly reset security policy when device admin revoked
* Simplify the logic in the onDisabled() receiver.  Make sure
  security policy keys are *always* disabled.
* Eliminate unused variable and unused receiver.

Bug: 2576145
Change-Id: I3665a1d300edfb77e02737c08aee22bc977f4968
2010-04-06 22:56:26 -07:00
Andrew Stadler a843d40ba1 Improve handling of unsupported security policies
* If the server asks for more than we can support, don't throw
  and error from PolicySet creation.  Let isSupported() do that.
* Overlong password lengths cannot be supported and isSupported is false.
* Overlong timeouts & max wipes can be reduced to supported
  amount (this actually increases security) and isSupported is true.
* Clean up an obsolete comment
* Unit tests

Bug: 2567804
Change-Id: I2d664a7f2a315b9f9bdcb867fe2cd98f74de6f66
2010-04-02 22:05:12 -07:00
Jim Shuma 9e2ddca59d Add "vibrate when silent" mode to notifications
* Add "vibrate when silent" choice in UI
* Add storage for it in Email's provider.  Existing accounts default to
  their current settings (always vibrate / never vibrate).
* Respect new mode when notifications are posted
* Updated existing unit tests

Bug: 2457183
Change-Id: I5c933ac39dbef8b2028255f330e0b084a445421a
2010-03-18 13:57:25 -07:00
Dianne Hackborn 6d0016229a Move DeviceAdmin APIs to android.app.admin. 2010-02-26 23:31:37 -08:00
Dianne Hackborn 4ae83c58b3 Fix issue #2420412: API review: DeviceAdmin API changes 2010-02-17 10:30:25 -08:00
Andrew Stadler af55e3e436 Respond to loss of device admin status
If the user revokes device admin status, reset our internal state and
the state of any accounts that might have been depending on it.  This
halts syncing immediately and rewinds the security/provisioning state
of any such accounts to a known state (as if the account had just been
created.)

Bug: 2387961
2010-02-16 14:33:08 -08:00
Andrew Stadler d71d0b223a Force security activation after new account create
On new accounts, we can accelerate the process of setting up security
by explicitly checking (at the end of the security process).  The user
is not required to "answer" the asynchronous notification.

This is an imperfect solution, as a slow initial sync could leave the
user in a non-synced Inbox (with a notification waiting for them), but
we can come back to this after we evaluate real-world performance.

Bug: 2387961
2010-02-09 17:24:55 -08:00
Andrew Stadler 50d1610c43 Relax device admin policies when accounts deleted
If an account is deleted, immediately recompute the aggregate
security policy, and apply it immediately.

When applying policies, handle "no policy" case by releasing device admin
status entirely.
2010-02-09 11:01:01 -08:00