39 Commits

Author SHA1 Message Date
Jeff Sharkey
d01571e6d4 Isolate calls to each remote DocumentsProvider.
All background work is going through AsyncTasks, which uses a shared
thread pool.  Even with the new ContentProviderClient logic to detect
ANRs, the UI can still appear to be unresponsive for 20 seconds, even
if the user attempted to switch to a different backend.  In the worst
case, a backlog of thumbnail requests would end up wedging Loaders
for a long time, since they all share the same THREAD_POOL_EXECUTOR.

This change isolates calls to each provider onto their own thread,
which they're free to wedge and recover from over time.

It also means we no longer need a dedicated thread pool for recents
loading, and can use a simpler Semaphore instead.

Disables thumbnails in recents on svelte devices.

Bug: 10993301, 11014856
Change-Id: I7f8a5bbb5f64437e006cb2c48b7e854136d5c38c
2013-10-02 08:54:02 -07:00
Jeff Sharkey
7aa7601c09 Detect wedged ContentProviders, treat as ANR.
All ContentProvider calls are currently blocking, making it hard for
an app to recover when a remote provider is wedged.  This change adds
hidden support to ContentProviderClient to timeout remote calls,
treating them as ANRs.  This behavior is disabled by default.

Update DocumentsUI to use a 20 second timeout whenever interacting
with a storage provider.

Bug: 10993301, 10819461, 10852518
Change-Id: I10fa3c425c6a7225fff9cb7a0a07659028230cd3
2013-10-01 09:50:41 -07:00
Jeff Sharkey
6efba22ce5 New roots UX, async, performance, docs.
Yet another iteration from UX on how roots should be ordered.  Since
we no longer categorize by type, remove from public API.  Updated
asset drop with new dividers.

Update public API docs to be explicit about required columns.  Hide
flags and columns that aren't required for third-party apps.

Move remainder of potentially blocking work to AsyncTasks, including
creating directories, picked root resolution, and creation of new
documents once picked.

Improve performance of layouts by removing baseline alignment and
reduce hierarchy depth.  Set alpha on ImageViews directly to avoid
offscreen rendering hit.

Limit returned recents to 45 days.  Show load in recents when still
waiting for backends.  Show empty message when no recents stacks to
create from.  Use unique key when saving recent stacks.

Bug: 10941423, 10819454, 10964412, 10960718
Change-Id: I08cf589dcda7e203acf67928f4d30322ae36ee94
2013-09-27 17:13:13 -07:00
Jeff Sharkey
2a030b05a9 Directories are always enabled; update assets.
Fix bug where item enabled state depended on FLAG_SUPPORTS_WRITE;
directories are now always enabled.  Also unifies enabled testing.

Bug: 10903210, 10946731
Change-Id: I241533d273dfe4a2146bb322a8bd93066bf4ef55
2013-09-26 10:54:19 -07:00
Jeff Sharkey
5e1a5e5bad Merge "Create unique files, root ordering, UI bugs." into klp-dev 2013-09-22 19:55:19 +00:00
Jeff Sharkey
5545f56f75 Create unique files, root ordering, UI bugs.
When a file already exists on disk, try adding a counter suffix to
make a unique name.  Move services near top of roots list, just below
recents.  Remove "Documents" root.

Increase number of recents allowed from single provider, and add more
logging to diagnose wedged loaders.

When launching GET_CONTENT apps, wait for successful result before
relaying result; canceled requests now return to DocumentsUI.

Add CloseGuard to ContentProviderClients, since leaked instances can
keep the remote process alive.

Fix UI bug around trailing breadcrumbs.  Fix bug that dropped Recents
from roots list.  Add up action to Settings activity.  Give our
activity a default icon while waiting for async roots to load.

Bug: 10818683, 10819461, 10819461, 10819196, 10860199
Change-Id: I7b9e26b1cf8353dd3175458b23da2b4bda6c5831
2013-09-21 14:07:16 -07:00
Adam Lesinski
d473ebb7c4 Merge "Surfaces ParcelFileDescriptor#parseMode() as API" into klp-dev 2013-09-20 22:59:12 +00:00
Adam Lesinski
eb8c3f93ed Surfaces ParcelFileDescriptor#parseMode() as API
Moves ContentResolver#modeToMode() to ParcelFileDescriptor#parseMode()

bug:10711271
Change-Id: I28a5de4ca70adfbec4caf739863b77f0fd7fd9a4
2013-09-20 14:59:34 -07:00
Jeff Sharkey
a9ce049db8 Load RootInfo in background, invalidation.
Move all RootInfo queries to background threads to avoid janking
the UI.  Update passes happen on spawed task, which swaps out updated
cache results when finished.  Support partial updates when only a
single package/authority has changed.  Watch for change notifications
for roots, since flags can change over time.

Ignore stopped packages when in background, but query them for roots
when launching any picker UI.

Optimize management launches by treating as one-shot requests that
don't need to wait for all RootInfo.

Bug: 10600454, 10745490
Change-Id: Ibc7b15688ef6b41bd7e9dd0d7564b501e60e49a9
2013-09-19 19:53:32 -07:00
Baligh Uddin
59db60e498 Import translations. DO NOT MERGE
Change-Id: I0da9befa56ba6e4a599b5796182898cc7093043d
Auto-generated-cl: translation import
2013-09-18 23:42:59 -07:00
Baligh Uddin
72e8643fdd Import translations. DO NOT MERGE
Change-Id: Icd16c449ff68a89ecd4a36856764d24f5894c9e5
Auto-generated-cl: translation import
2013-09-16 09:47:04 -07:00
Baligh Uddin
31ceae5629 Import translations. DO NOT MERGE
Change-Id: I68895c16a26ecc9554bfc53e9d9346fe29412fec
Auto-generated-cl: translation import
2013-09-14 20:27:22 -07:00
Baligh Uddin
162e88759c Import translations. DO NOT MERGE
Change-Id: Idfb9ef96c1c4ea6fc1ca836114a8eb09be18f8f4
Auto-generated-cl: translation import
2013-09-13 21:47:27 -07:00
Jeff Sharkey
3e1189b359 Move search to roots; Documents root; hide empty.
Documents searches now happen root-wide, instead of only under a
subdirectory.  Updates abstract class and flags to match.  Add flag
for a root to indicate it's empty, and hide empty roots in UI unless
creating.

Define "Documents" public directory and storage backend to contain
files.

Bug: 10712057, 10710865, 10710758
Change-Id: I8716367568969f9cb1d83927b2bf5a7013809350
2013-09-13 11:35:04 -07:00
Jeff Sharkey
de2b22fbc6 Handle pipe thumbnails, acquire unstable refs.
Support decoding thumbnails delivered over pipes by wrapping in a
buffered stream.  Also switch to using unstable provider references
to avoid crashing DocumentsUI.

Bug: 10516148, 10510851
Change-Id: I85f6eeaca70c97742bf79656d1d0c6da381fdd47
2013-09-11 17:33:52 -07:00
Jeff Sharkey
4ec973925f More UX work for thumbnails, search, management.
Hide non-finished downloads from normal picker UI, but keep them
around in management mode.  Uses a Uri query parameter and a hidden
API on DocumentsProvider.

Scale thumbnails to fit viewport, always show MIME icon while waiting
on thumbnails, and crossfade between them.  Cancel thumbnail tasks
when views are recycled.

Filter directories out of search results for now.  Also leave sort
ordering from backend intact, since it's custom ranking.  Fix
SearchView interaction to dismiss properly and restore across
orientation and drawer state changes.

Hide most actions when drawer is open.  Invalidate RootInfo cache
when locale changes.  Apply sort ordering when showing recent create
directories.  Hide recent summary string when icon is enough for user
to disambiguate.

Bug: 10667184, 10665663
Change-Id: I331d3272a08c497f88dc659d9e112231cb35aa69
2013-09-10 16:40:36 -07:00
Jeff Sharkey
b7757a6b32 Rename offer() to add(), remove/hide some APIs.
Change MatrixCursor offer() to add() based on review feedback.  Remove
some now-unused XML metadata.  Hide document creation, since it's not
supported in initial version.

Bug: 10577809, 10461706, 10678563
Change-Id: I7b3f4c6899c28f633471ef816bee22bf032aa0d2
2013-09-09 17:55:10 -07:00
Jeff Sharkey
3f4c205fd3 Disabled states, more UX work, bug fixes.
Fix drawable state to correctly show dimmed disabled state.  Update
disabled state for all children to grey out text.

Block multi-selection of documents not matching MIME filter.  Load
thumbnails in parallel.  Show thumbnails in list mode based on MIME
type to match spec.

Give each footer a unique view type to avoid recycler crashes.

Show breadcrumb icons in recent create paths.  Fix timestamp bug when
querying/updating recent paths.

Make ContentProviderClient.closeQuietly() really be quiet.

Bug: 10668364, 10510022, 10668701, 10534224, 10667726
Change-Id: I3c705412fb211519f15ad41a273a7533b878e9e5
2013-09-09 16:55:35 -07:00
Jeff Sharkey
6d97d3c1a2 Another asset drop, provider icons, tests.
Latest asset update, including provider icons which are treated as
special cases for now instead of checking into separate apps.  Add
tests for MIME type matching of roots.  Remove unused XML.

Bug: 10510022
Change-Id: Id567a9e06ba241f60ac011823e550253c6c797fb
2013-09-06 10:46:54 -07:00
Jeff Sharkey
954be02326 Show loading, error, and info messages as footers.
A provider can include extras in their Cursors to indicate that
loading is ongoing, or include an error or informational message,
which are now shown in footer views.

Fix registration to always get change notifications.

Test provider that verifies common provider behavior of holding
a reference to "cloud" resources that are released by GC when the
remote Cursor is closed.  Also used to validate Recents behavior
for slow providers.

Bug: 10599268
Change-Id: I331c31058dbb80261e7d279b851197c65ac87e32
2013-09-03 17:02:47 -07:00
Jeff Sharkey
118cb0353f Merge "Filter roots based on incoming request." into klp-dev 2013-09-03 03:50:56 +00:00
Jeff Sharkey
348ad6866b Filter roots based on incoming request.
When incoming request is for local-only content, or for ACTION_CREATE,
only include roots advertise those features.

Filters roots based on the allowed MIME types and the supported types
advertised by each root.  This supports displaying Images and Audio
roots only when requesting those content types.  Applies the same
filter when deciding which roots to query for recents.

Fixes advanced filtering instead of limiting to just devices. Update
sorting so that Recent always appears first. Add testing support for
LOCAL_ONLY.

Bug: 10597317, 10526535
Change-Id: Ic5ccf475c4fe93fd52b29388d369d7f6915c0c42
2013-09-02 17:43:14 -07:00
Jeff Sharkey
cd6d7deec8 Merge "Refactoring of DocumentsContract." into klp-dev 2013-09-03 00:07:17 +00:00
Jeff Sharkey
ae9b51bfa3 Refactoring of DocumentsContract.
Combines related columns and constants onto the same class so they
are easier to discover.  Move back to surfacing roots with columns
so they are consistent with documents.

Advanced roots are represented with a flag instead of distinct
types.  Flags to indicate supporting of well-known media types,
instead of arbitrary an MIME filter.  Reintroduce well-formed rootId
to support recents.

Always use the expanded version of "documents" in constants, methods,
and argument names.

Refactor DocumentProvider method names to clearly distinguish if
a single item or multiple could be returned, and of which type.  Add
documentation to clearly define which methods have already been
overridden.

Bug: 10567506, 10567557
Change-Id: I981f26ab82f2b520a19aa1ce66f659de50d7fac0
2013-08-31 16:58:28 -07:00
Jeff Sharkey
9fd81a9008 Merge "Stronger DocumentsProvider contract." into klp-dev 2013-08-29 04:27:02 +00:00
Jeff Sharkey
aeb16e2435 Stronger DocumentsProvider contract.
Using a contract class requires that a provider implement it exactly
with little help. This change introduces a DocumentsProvider abstract
class that provides a client-side implementation of the contract that
greatly reduces developer burden, and improves correctness.

This also moves to first-class DocumentRoot objects, and moves calls
with complex side effects to be ContentProvider.call() invocations,
offering more granular permission control over Uri operations that
shouldn't be available through Uri grants.

This new design also relaxes the requirement that root information be
burned into every Uri.  Migrate ExternalDocumentsProvider and
DocumentsUI to adopt new API.

Bug: 10497206
Change-Id: I6f2b3f519bfd62a9d693223ea5628a971ce2e743
2013-08-28 20:49:42 -07:00
Baligh Uddin
dc6c5a9950 Import translations. DO NOT MERGE
Change-Id: I90a32d22c5c97408ef96635be46c069c22fddca7
Auto-generated-cl: translation import
2013-08-26 09:45:01 -07:00
Jeff Sharkey
365768fd35 Merge "Return EXIF thumbnails when available." into klp-dev 2013-08-23 23:18:11 +00:00
Jeff Sharkey
6398343e83 Return EXIF thumbnails when available.
Adds new ExifInterface method to extract the thumbnail range from
a larger image file, and use that to return an AssetFileDescriptor.

When decoding an AssetFileDescriptor thumbnail with offsets, read out
the raw data entirely, since Skia uses lseek() aggressively.

Bug: 10412208
Change-Id: I7906cdf82c0c3794cec7043c801a86f66efeb143
2013-08-23 12:19:19 -07:00
Baligh Uddin
7e361bcf7f Import translations. DO NOT MERGE
Change-Id: I7cb875bb18871021fb9972b427713440c8e95be6
Auto-generated-cl: translation import
2013-08-23 10:09:45 -07:00
Jeff Sharkey
b448660a22 Request more documents when EXTRA_HAS_MORE.
Implement EXTRA_HAS_MORE and EXTRA_REQUEST_MORE contract with
document providers.  Providers can include EXTRA_HAS_MORE when
additional data is available with additional cost, such as a network
request.

Listen to content changes based on returned cursor instead of
original Uri.  Include a test backend to exercise.  UX still under
development.

Bug: 10350207
Change-Id: Iaa8954df55a1a1c0aa96eb8a4fd288e12c2fbb01
2013-08-18 22:32:02 -07:00
Jeff Sharkey
9d0843df7e Resized thumbnails; async; extend MatrixCursor.
When requesting thumbnails, check if their dimensions are larger
than requested, and downscale to avoid memory pressure.  Load them
async and with LruCache.

Extend MatrixCursor so that RowBuilder can offer() columns without
requiring they know the projection map.  This makes it easier to
respond to query() calls, where the remote side controls the
projection map.  Use it to handle custom projections in external
storage backend.

Update date/time formatting to match spec.

Bug: 10333418, 10331689
Change-Id: I7e947a8e8068af8a39b55e6766b3241de4f3fc16
2013-08-17 19:05:07 -07:00
Jeff Sharkey
a5599ef636 Documents management mode; API adjustment.
Create documents manage mode to support Downloads and transient
storage devices.  Locks user into requested backend root, and forces
file sizes on and sorting by last modified.

Separate API constants for Documents versus Roots, and give concrete
MIME types for roots.

Treat null sizes as unknown.  Documents are always enabled in list
so that divider is drawn.  Mark external storage file as writable.

Bug: 10329983, 10332993, 10332952
Change-Id: I05f4fdf5b04041a38e1ba7fb30202a3b0c615bf6
2013-08-15 16:25:30 -07:00
Jeff Sharkey
dc2963aeca Track and persist directory stacks; recents work.
Move to manual tracking of directory navigation stack so we have Uri
data to persist, instead of opaque fragment backstack.  Remember
directory stacks across launches on a per-app basis.

Start recording recently opened and created files.  Uniform Uri
parameter extraction utility methods in contract.

Change-Id: I79ed30ee10272bf7c53d339e797639c993f649bb
2013-08-02 17:39:38 -07:00
Jeff Sharkey
92d7e697a8 Reference docs by ROOT_ID and DOC_ID; recents.
The same document may be present with different sematics under
multiple storage roots, so always reference using both ROOT_ID and
DOC_ID.  This enables backends to revoke permissions for an entire
root, such as when an account is removed.

Start building provider to remember recently accessed documents.

Change-Id: I75befa2e61393dec12fcc7fd27f631fcddae46fa
2013-08-02 11:05:11 -07:00
Jeff Sharkey
7e258b31e7 XML metadata for storage backend; custom icons.
Introduce XML metadata for storage backends, used to indicate if
custom roots should be queried, and provide any custom MIME type
icons inside that backend.

Parse metadata and resolve custom icons in UI.

Change-Id: Iec026c0b10845edff7a345d9389691ddf2c87a0e
2013-08-01 11:34:56 -07:00
Jeff Sharkey
20d96d8aff Define storage roots, external GUIDs, creation.
Allow storage backends to publish multiple roots into the UI, which
are defined by a directory GUID, type, and label details.  Update
external provider to surface a primary external storage root, and
switch to burning file path into the returned GUIDs so they remain
durable.

Added insert, update, and delete support to external provider. Adds
file extensions to display names when needed to match MIME type.

Add flags for searching and deletion, and extras for Cursor
pagination. Add directory creation dialog to UI. Opening a document
always gives write access.

Change-Id: I9bea1aa0dcde909a5ab86aefeece7451ab920cf1
2013-07-30 22:55:23 -07:00
Christopher Tate
ccbf84f44c Some system apps are more system than others
"signatureOrSystem" permissions are no longer available to all apps
residing en the /system partition.  Instead, there is a new /system/priv-app
directory, and only apps whose APKs are in that directory are allowed
to use signatureOrSystem permissions without sharing the platform cert.
This will reduce the surface area for possible exploits of system-
bundled applications to try to gain access to permission-guarded
operations.

The ApplicationInfo.FLAG_SYSTEM flag continues to mean what it is
says in the documentation: it indicates that the application apk was
bundled on the /system partition.  A new hidden flag FLAG_PRIVILEGED
has been introduced that reflects the actual right to access these
permissions.

At some point the "system" permission category will be
renamed to "privileged".

Bug 8765951

Change-Id: I6f0fd9cdb9170e076dfc66d83ecea76f8dd7335d
2013-06-17 12:47:35 -07:00
Jeff Sharkey
9e0036ed7d External storage provider, document picker UI.
Continuing to flesh out storage backends by adding an external
storage document backend.  Still rough, but it can traverse files
and directories.

Early pass at OPEN/CREATE_DOC picker UI, which offers to traverse
any known storage backends.  Supports opening subdirectories and
returning a picked file.

Change-Id: Idc3554036b3816a93d9b465ee8a620746859d2ae
2013-05-01 17:44:42 -07:00