summaryrefslogtreecommitdiffstats
path: root/packages/ExternalStorageProvider/src/com
Commit message (Collapse)AuthorAgeFilesLines
* Fix ownership for files/folders created by ExternalStorageProvider on ext4/f2fsJani Lusikka2016-03-291-0/+8
| | | | | | | | By forcing ExternalStorageProvider to use the sdcard FUSE layer for access, ext4/f2fs sdcards will be treated with the correct media_rw:media_rw permissions instead of the current app permissions. Change-Id: I2cbb97727ebe5af88a879490732925406a165af5
* Clean stale entries when deleting files.Jeff Sharkey2015-09-251-1/+21
| | | | | | | | | | | When deleting files directly from external storage devices, remove any matching entries from MediaStore so we don't end up showing stale entries to clients, such as MTP/PTP. Also handles the case where an entire directory is deleted. Bug: 24045921 Change-Id: I802470fa1aa03e0bec147ea113f1a49e26a0f3f9
* Handle volumes without visible paths.Jeff Sharkey2015-07-301-1/+5
| | | | | | | | Transient volumes like USB drives are not mounted as visible, so we shouldn't be kicking off media scanner for them. Bug: 22545248 Change-Id: Ic8f2d3134f1edb8b2a12e8ff283eceeeb230f48b
* If user ejects a storage from details, take user to...Makoto Onuki2015-07-011-2/+7
| | | | | | | | | | | | | | | | | | | | ... the storage list view 1. Change to ExternalStorageProvider When available volumes have changed, it now notifies on "content://com.android.externalstorage.documents" rather than on "content://com.android.externalstorage.documents/root/", because it'll also affect "content://com.android.externalstorage.documents/document/*/children". 2. Change to DocumentUI - DirectoryLoader now won't crash when a provider returns null. - DirectoryFragment now closes itself (i.e. emulate a back press) when a load failed. - It now correctly reloads contents when a volume is ejected thanks to 1. Bug 21472170 Change-Id: Icf4bbc2ebb9067313dbbb67083cd4115b0a75c58
* Update file size formatting.Jeff Sharkey2015-06-151-9/+12
| | | | | | | | | | | | Per UX, default strings should have space between value and units resulting in "12.3 GB". Add a formatting variant that returns the various components for callers who want to build their own strings. For now there is only one mounted emulated volume at a time, and it's always the primary storage, so give it the default rootId to keep old Uris working. Change-Id: Ifcc72a91a6b397ee65dc92642153286186eb64ac
* Move extension checking code into FileUtils.Ben Kwa2015-04-231-65/+1
| | | | | | | | | | Move code for checking file extensions and MIME types from ExternalStorageProvider into android.os.FileUtils, so it can be used by other clients (e.g. DownloadsProvider). BUG=20157955 Change-Id: Ib16a16af723c21fb8d2912c8917dfd68653ea6fa
* Wire up non-visible volumes, more states.Jeff Sharkey2015-04-181-63/+90
| | | | | | | | | | | | | | | | | | Adds logic to ExternalStorageProvider to scan non-visible volumes, such as USB OTG devices. We use internal paths when surfacing these volumes, which also optimizes around the FUSE daemon for public devices. Also dumps internal state when requested. VolumeInfo now directly contains DiskInfo, which means it's snapshotted when sending events, avoiding teardown races. Switch notifications to use this DiskInfo directly. Finish wiring up new volume state, including helper methods to make it readable/writable state clearer. Handle disks and volumes with spaces in their labels. Bug: 19993667 Change-Id: I5c75e5658a6415976811477aebafee7694bde0f4
* DocumentsUI roots can have settings.Jeff Sharkey2015-04-121-0/+1
| | | | | | | | | | Roots use a flag to indicate they have settings, and DocumentsUI offers to launch towards someone who handles a new Settings intent. Slight rename of browse intent for clarity. Bug: 19993667 Change-Id: I86302ec1cfac5e435d8bc5701bdb85fb9b0dcbae
* Sanitize display names, keep extensions intact.Jeff Sharkey2014-12-011-39/+72
| | | | | | | | | | | | When creating or renaming files on external storage, sanitize the requested display names to be valid FAT filenames. This also fixes a handful of directory traversal bugs. Also relax logic around generating display names to allow any extension which maps to the requested MIME type. Tests to verify. Bug: 18512473, 18504132 Change-Id: I89e632019ee145f53d9d9d2050932f8939a756af
* Use default volume description when missing label.Jeff Sharkey2014-10-241-1/+6
| | | | | | | | Some mounted storage volumes may not have a user-defined label. In those cases, use the default description for the volume. Bug: 17781505 Change-Id: I8558ba2615c2ff2647a5d44afaec83249df466ab
* Scan after writing external storage files.Jeff Sharkey2014-08-051-1/+24
| | | | | | | Kicks off media scanner after files are written. Bug: 13557203 Change-Id: I61613f28e07b068573079cc1e362fd3fe135684e
* Refactor directory API to "opening document tree."Jeff Sharkey2014-06-091-1/+1
| | | | | | | | | Cleans up API so it consistently refers to opening or working with a subtree of documents. Also separates isChildDocument() support from the concept of directory tree selection. Bug: 15429194 Change-Id: Ice66a751ff4bd0cc4d34c44c5da13a0dc4186dc9
* Support for renaming documents.Jeff Sharkey2014-05-211-1/+25
| | | | | | | | | | | | | | DocumentsProviders can mark documents as supporting rename, and they have the opportunity to change the DOCUMENT_ID as a side effect of the rename. This supports providers that embed the display name into DOCUMENT_ID. Issues a URI permission grant to the new document, if any. Adds renaming support to platform ExternalStorageProvider. Also adds directory deletion support. Bug: 12350110 Change-Id: Ica4b1ae6769ee994f70f6b6b2402213eebd064e0
* Add directory selection to DocumentsProvider.Jeff Sharkey2014-04-221-3/+20
| | | | | | | | | | | | | | | | | | | | | | | | | Introduce new ACTION_PICK_DIRECTORY that allows users to grant access to an entire document subtree. Instead of requiring grants for each individual document, this leverages new prefix URI permission grants by defining new "via"-style URIs: content://com.example/via/12/document/24/ This references document 24 by using a prefix grant given for document 12. Internally, we use isChildDocument() to enforce that 24 is actually a descendant (child, grandchild, etc) of 12. Since this is an optional API, providers indicate support with Root.FLAG_SUPPORTS_DIR_SELECTION. Extend DocumentsUI to support picking directories. Expose createDocument() API to work with returned directories. Offer to canonicalize via-style URIs into direct URIs, generating exact permission grants along the way. Override openAssetFile() to pass through CancellationSignal. Move testing code into ApiDemos. Bug: 10607375 Change-Id: Ifffc1cff878870f8152eb6ca0199c5d014b9cb07
* Guard against missing document columns.Jeff Sharkey2013-10-291-0/+5
| | | | | | | | When filtering and sorting, guard against missing columns to avoid crashing entire app. Bug: 11377065 Change-Id: I04f035c918d743bcc84592f05e3ef9ad0ebfadce
* Use inotify to update DocumentsUI.Jeff Sharkey2013-10-251-1/+92
| | | | | | | | | | | | | While user is actively looking at a directory, subscribe to inotify events and notify of content changes to trigger requeries. Reference count the observers, since multiple cursors are regularly open during requeries. Fix leaking cursors on activity rotation; crazy loader ID generation is no longer needed. Bug: 10999396 Change-Id: Iddeb08a056fee80c93df8499874705bcd213a1e2
* Extra to always show advanced devices.Jeff Sharkey2013-10-251-2/+2
| | | | | | | | Also always lower-case extension to extract MIME type correctly, we may want to fix in MimeUtils at some point. Bug: 11354402 Change-Id: I77d0c06a663cd0c4320c41553ff1980b6f9a7778
* Show spinner while waiting for mutations.Jeff Sharkey2013-10-231-1/+10
| | | | | | | | When mutation operations are waiting for a storage backend, show a spinner in place of the save button. Bug: 11333249 Change-Id: I2b620b4532ad977a2b60d4bdc5caa55f89021456
* Treat document thumbnails as preemptable.Jeff Sharkey2013-10-231-12/+38
| | | | | | | | When a more important request comes along, preempt all outstanding thumbnail requests. Bug: 11317901 Change-Id: I164fc8d804bb9c471e6da3f8127228043b3ca482
* Include external storage devices in DocumentsUI.Jeff Sharkey2013-10-172-41/+142
| | | | | | | | | Include volume UUID in generated document IDs to uniquely identify volumes over time. Show volume label to users. Watch for mount changes to update available roots. Bug: 11175082 Change-Id: Ia151bde768587468efde0c1d97a740b5353d1582
* Add extras to AFD, send orientation metadata.Jeff Sharkey2013-10-141-13/+2
| | | | | | | | | | | | | | | | | | | | AssetFileDescriptor augments a ParcelFileDescriptor with details about how it should be interpreted, so extend it to support a Bundle of extras. Then use these extras to share thumbnail orientation metadata. The raw image data of EXIF thumbnails matches the orientation of the enclosing image, but the thumbnail data doesn't repeat the EXIF flags. This meant that receivers of openDocumentThumbnail() would get an image that needed to be transformed, but without enough context to actually transform it. Instead of transforming and recompressing the image on the fly on the provider side, send a transformation hint that the receiver side can interpret. Bug: 11205688 Change-Id: Ibc5a7ad002377a55e6ffcb5ac5c8829841002e06
* Treat dates near epoch as unknown.Jeff Sharkey2013-10-111-2/+11
| | | | | | | | Also document that rootIds need to be stable, so removable media roots should use the media serial number. Bug: 11151557 Change-Id: I1f3dcabcd0474f1bf92d2cafb0f37e82abe34e05
* Isolate calls to each remote DocumentsProvider.Jeff Sharkey2013-10-021-1/+20
| | | | | | | | | | | | | | | | | | | | 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
* Detect wedged ContentProviders, treat as ANR.Jeff Sharkey2013-10-011-8/+28
| | | | | | | | | | | | | 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
* New roots UX, async, performance, docs.Jeff Sharkey2013-09-272-8/+3
| | | | | | | | | | | | | | | | | | | | | | | | 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
* Directories are always enabled; update assets.Jeff Sharkey2013-09-261-5/+5
| | | | | | | | 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
* Merge "Create unique files, root ordering, UI bugs." into klp-devJeff Sharkey2013-09-221-33/+34
|\
| * Create unique files, root ordering, UI bugs.Jeff Sharkey2013-09-211-33/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Merge "Surfaces ParcelFileDescriptor#parseMode() as API" into klp-devAdam Lesinski2013-09-201-1/+1
|\ \ | |/ |/|
| * Surfaces ParcelFileDescriptor#parseMode() as APIAdam Lesinski2013-09-201-1/+1
| | | | | | | | | | | | | | Moves ContentResolver#modeToMode() to ParcelFileDescriptor#parseMode() bug:10711271 Change-Id: I28a5de4ca70adfbec4caf739863b77f0fd7fd9a4
* | Load RootInfo in background, invalidation.Jeff Sharkey2013-09-191-1/+31
|/ | | | | | | | | | | | | | | | | 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
* Move search to roots; Documents root; hide empty.Jeff Sharkey2013-09-131-9/+27
| | | | | | | | | | | | | 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
* Handle pipe thumbnails, acquire unstable refs.Jeff Sharkey2013-09-111-14/+66
| | | | | | | | | 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
* More UX work for thumbnails, search, management.Jeff Sharkey2013-09-101-5/+4
| | | | | | | | | | | | | | | | | | | | | | | 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
* Rename offer() to add(), remove/hide some APIs.Jeff Sharkey2013-09-092-25/+25
| | | | | | | | | 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
* Disabled states, more UX work, bug fixes.Jeff Sharkey2013-09-091-0/+5
| | | | | | | | | | | | | | | | | | | 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
* Another asset drop, provider icons, tests.Jeff Sharkey2013-09-061-1/+0
| | | | | | | | | 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
* Show loading, error, and info messages as footers.Jeff Sharkey2013-09-031-0/+244
| | | | | | | | | | | | | | | | 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
* Filter roots based on incoming request.Jeff Sharkey2013-09-021-3/+1
| | | | | | | | | | | | | | | | | 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
* Refactoring of DocumentsContract.Jeff Sharkey2013-08-311-70/+97
| | | | | | | | | | | | | | | | | | | | | | 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
* Stronger DocumentsProvider contract.Jeff Sharkey2013-08-282-540/+186
| | | | | | | | | | | | | | | | | | | 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
* Return EXIF thumbnails when available.Jeff Sharkey2013-08-231-1/+36
| | | | | | | | | | | 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
* Request more documents when EXTRA_HAS_MORE.Jeff Sharkey2013-08-181-0/+253
| | | | | | | | | | | | | | 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
* Resized thumbnails; async; extend MatrixCursor.Jeff Sharkey2013-08-171-44/+56
| | | | | | | | | | | | | | | | | 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
* Documents management mode; API adjustment.Jeff Sharkey2013-08-151-12/+21
| | | | | | | | | | | | | | | 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
* Track and persist directory stacks; recents work.Jeff Sharkey2013-08-021-20/+31
| | | | | | | | | | | 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
* Reference docs by ROOT_ID and DOC_ID; recents.Jeff Sharkey2013-08-021-74/+98
| | | | | | | | | | | 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
* Define storage roots, external GUIDs, creation.Jeff Sharkey2013-07-301-54/+192
| | | | | | | | | | | | | | | | | 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
* External storage provider, document picker UI.Jeff Sharkey2013-05-011-0/+204
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