Commit Graph

288 Commits

Author SHA1 Message Date
Zim
1ea98d4449 Block SAF directory access to /sdcard/Android
This works for target R+ apps, but need to come up with a better story
for target <R. The enforcement in DocumentsUI is target SDK based
and those apps bypass the block_tree flag.

Bug: 157320644
Test: atest DocumentsTest
Change-Id: I93aea7cd5d3b7befea1f78e1cf3f31f8250f1d33
(cherry picked from commit 9d508579ae)
Merged-In: I93aea7cd5d3b7befea1f78e1cf3f31f8250f1d33
2021-06-02 14:14:18 +00:00
Ivan Chiang
2c80a71789 Revoke the uri permission when the file is deleted
When the file is deleted, renamed or moved, revoke all uri
permissions with the file

Bug: 157474195
Test: manual test with DocumentsUI
Test: atest DocumentsTest#testAfterMoveDocumentInStorage_revokeUriPermission
Change-Id: I4ffb183630aadb2d87b0965e8cecf88af15f4534
Merged-In: I4ffb183630aadb2d87b0965e8cecf88af15f4534
(cherry picked from commit 9efd606f43)
2020-08-26 06:40:54 +00:00
TreeHugger Robot
b3967b656d Merge "Remove getFreeBytes() to fasten queryRoots call." into rvc-dev 2020-06-11 14:57:18 +00:00
Abhijeet Kaur
ad9cbfbc80 Remove getFreeBytes() to fasten queryRoots call.
This change fastens the first call to DocumentsUI after reboot.

Bug: 155819706
Test: builds (fastens the first call to DocumentsUI by 600-800ms)
Change-Id: Id8396e36ed8aa1ded79d93a2f1ed140bf903184b
2020-06-10 16:53:06 +01:00
Diksha Gohlyan
e808f96a9c Use visiblePath instead of path for findDocumentPath
Test: atest DocumentsUIGoogleTests
Bug: 158142289

Change-Id: Id46ac014ad87af052b684e21b9242f762d7db80a
2020-06-09 16:42:32 -07:00
Abhijeet Kaur
553625de0a Add manage mode workflow for ExternalStorageProvider
In Scoped Storage world, access to "Android/data" style directories are
hidden for privacy reasons. Allow ExternalStorageProvider to show these
hidden files when in manage mode.

Bug: 150366834
Test: Android/data and Android/obb is visible from Files App, but are
hidden in Picker view from StorageTestApp and Gmail (GMAIL > Compose >
Attach > Go to Pixel > Android)

Change-Id: I58b4fc23d9b479df4fc0480ae55f1f2070d0cb7c
2020-05-11 11:39:40 +01:00
Zimuzo Ezeozue
cdb1ce47f9 Merge "Update ExternalStorageProvider volumes with StorageEventListener" into rvc-dev 2020-05-02 09:52:43 +00:00
Zim
5631b6e63a Update ExternalStorageProvider volumes with StorageEventListener
We were listening to volume state changes in the
ExternalStorageProvider with the VOLUME_STATE_CHANGED broadcast in the
MountReceiver.

This broadcast can be severly delayed especially on user startup so we
also listen with the StorageEventListener which is more performant.

Test: Manual
Bug: 154332660
Change-Id: I93c43f3b53c0a71cd6aa7cf594fe6988f4bc3f6e
2020-05-01 19:40:09 +01:00
Diksha Gohlyan
f555b7b814 Use visible path for search documents
Test: atest DocumentsUIGoogleTests
Bug: 155139904

Change-Id: I5454c1cc48e2d4489218b5795c98bd0f9526c6ab
2020-04-29 14:59:31 -07:00
Diksha Gohlyan
0d1313aaef Prefer visiblePath if available
Test: atest DocumentsUIGoogleTests

Bug: 154502439, 151981237

Change-Id: I85b673d31b2353cf4c65917bb44ef270f2c53128
2020-04-23 16:14:12 +00:00
Ivan Chiang
d207d81bd5 Remove legacy code for Home root
We add new Documents root in MediaDocumentsProvider.
Remove unused Documents root in ExternalStorageProvider.

Bug: 148043686
Test: manual with DocumentsUI
Change-Id: I4278aa79cb1a9e22007b2946f8196d2a070be2c8
2020-02-07 03:02:09 +00:00
Stephen Hughes
2aecf81330 Merge "Allow access to all USB directories through SAF." 2020-02-01 23:41:23 +00:00
Zim
4e416c8868 Request MANAGE_EXTERNAL_STORAGE permission
This permission will allow it access unreliable USB OTG volumes and
also service other SAF requests on the external storage.

Test: m
Bug: 144914977
Change-Id: I92f046a06852d5ba842764d8348a498b2b6ad0b7
2020-01-24 22:33:46 +00:00
Stephen Hughes
4827cdf3de Allow access to all USB directories through SAF.
Test: Manual
Bug: 147755862
Change-Id: I3b9c386a8015a8254ec4ee0b1dc9b18546971891
2020-01-15 13:03:56 -08:00
Zim
2dca320fbb Fix volumes registered in ExternalStorageProvider
Now that emulated volumes are per user, ESP should not register
any volume that does not match it's running user.

Bug: 144936488
Test: On device with secondary user, Files > Show internal storage
displays "internal storage"

Change-Id: If4820c684a0a8ef52cc97ae9087b1a0884f9cee7
2020-01-08 19:39:55 +00:00
Jeff Sharkey
40182833f7 Move MediaStore.java inside APEX boundary.
Recent work has paved the way to get MediaStore.java building against
"core_platform", and this change is actually shifting MediaStore.java
inside the MediaProvider APEX boundary.

This involves defining a new "updatable-mediaprovider" library JAR
and ensuring that it's spliced into classpaths where needed to keep
everything building and working.

Note that the MediaProvider APK itself is still bundled, so we're
manually including the MediaStore.java when building that APK so that
we can continue referencing @hide symbols, but there's a STOPSHIP
comment to remove that once we get the APK building against
"system_current".

Bug: 144247087
Test: atest --test-mapping packages/providers/MediaProvider
Change-Id: I27ed3fde40751d9ac136a31710c62004b1b8962f
2019-12-19 22:16:00 +00:00
Ivan Chiang
698340fd5c Parse relative path from docId
Remove the logic of using file path directly.
Parse the docId to get the relative path.

Test: atest ExternalStorageProviderTest
Change-Id: Ic218813acc73e247ee5593ed9e8e7688760e6780
Fix: 144467519
2019-11-26 17:11:02 +08:00
Zim
17be6f999b Fix multi-user and multi-storage with FUSE
Up until now, the FUSE mount logic has made two assumptions:
1. The primary external volume is an emulated volume on /data/media
2. Only the primary user is running, as user zero

With this change, we are able to handle the following cases:
1. Mount new external storage volumes as as portable storage
(PublicVolume) managed by FUSE. The PublicVolume originally mounted on
/mnt/media_rw/<uuid> is availabe on /storage/<uuid> as a FUSE mount

2. Mount new external storage volumes as adoptable storage
(PrivateVolume) with a stacked EmulatedVolume managed by FUSE. The
EmulatedVolume orignally mounted on /mnt/expand/<uuid>/media will be
available on /storage/emulated if set as the primary storage

3. Run the MediaProvider as a secondary user handling requests on
/mnt/user/<userid>/<volid>

Test: atest AdoptableHostTest
Bug: 135341433
Bug: 140120303

Change-Id: I5fb48616b4143277ea14c6846037e2fd176e16db
2019-11-12 16:40:39 +00:00
Bill Yi
57e4d5b80a Import translations. DO NOT MERGE
Change-Id: I7a8a9b598689bb9ad2e18d27de05e8334ee7b41e
Auto-generated-cl: translation import
2019-11-06 14:29:56 -08:00
Philip P. Moltmann
128b70364e Note with featureId from ContentProvider
This takes the Context#getFeatureId from the calling context and pipes
it all way through to the noteOp calls done by the content provider.

Bug: 136595429
Test: atest CtsAppOpsTestCases (new test added to capture this case)
            TelecomUnitTests:CallLogManagerTest
	    ContentProviderClientTest
	    TelecomUnitTests:MissedCallNotifierImplTest
	    TelecomUnitTests:BasicCallTests
	    MediaInserterTest
	    PreferencesHelperTest
	    RankingHelperTest
	    PinnedSliceStateTest
	    FrameworksCoreTests:ContentResolverTest
Change-Id: I53b1035626229c920b353509a5bece157b52fb51
2019-10-29 15:41:28 -07:00
Ivan Chiang
730b3a3a45 Allow providers block folders in ACTION_OPEN_DOCUMENT_TREE
DocumentsContract
- Add new flag FLAG_DIR_BLOCKS_TREE in Document

ExternalStorageProvider
- Add flag into DocumentInfo for blocking folder

Change-Id: Ib557fe99d330788a3bd968bffd43b6658761514f
Bug: 32370759
Test: atest DocumentsTest
2019-10-02 06:01:36 +00:00
Bill Yi
7ceb4c6aba Import translations. DO NOT MERGE
Change-Id: Iab86bc7039dc430d19c6c8003ab1fd30a76e380c
Auto-generated-cl: translation import
2019-07-11 09:56:52 -07:00
Jeff Sharkey
601c3c63d0 Fix getMediaUri() bug on secondary devices.
We need to return visible paths for MediaProvider to work with,
instead of internal paths.

Bug: 133730441
Test: atest android.providerui.cts.MediaStoreUiTest
Change-Id: If06dc635b22032761626cf54b37b7bc15ace7b2e
2019-05-29 12:55:07 -06:00
Bill Yi
b871bd62a3 Import translations. DO NOT MERGE
Change-Id: I5d9ed79b13c8a2af09d6909473ae42a95d8452ad
Auto-generated-cl: translation import
2019-02-02 08:21:02 -08:00
Ivan Chiang
c26d3c28c2 Add new column into Root to get the supported query args
DocumentsContract:
- Add @Public column Root#COLUMN_QUERY_ARGS
- Update java doc

DocumentsProvider:
- Update java doc

FileSystemProvider & ExternalStorageProvider
- Add supported query args into Roots

Bug: 121234248
Test: manual
Change-Id: Ia944200ee1a44d75c9ad683564218e3d0dcef885
2019-01-21 15:44:53 +08:00
TreeHugger Robot
6634ae2cf3 Merge "Migrate frameworks/base/packages/ExternalStorageProvider/tests to androidx.test" 2018-12-20 23:53:33 +00:00
KOUSHIK PANUGANTI
2d6c5fc3bf Migrate frameworks/base/packages/ExternalStorageProvider/tests to androidx.test
See go/jetpack-test-android-migration

Test: make checkbuild
Change-Id: I20090d9bd41f91d239181e42754452d46ec2f3ff
2018-12-18 12:37:14 -08:00
Amin Shaikh
305e87e6d9 Add StorageVolume#createOpenDocumentTreeIntent
Change-Id: I6894bad24fa7757dee1028a31ba0b07701baa7b3
Fixes: 119519300
Test: manually using ApiDemos Content > Storage > Documents
2018-12-18 11:44:13 -05:00
Jeff Sharkey
efd355c1c3 Merge "Hide eject icon of removable media when it's emulated volume" am: 7f656092df am: 0fe81d7320
am: 29ce4d5fda

Change-Id: I815654df758200596b949943738608cd42ecdc40
2018-12-05 08:48:12 -08:00
Jeff Sharkey
29ce4d5fda Merge "Hide eject icon of removable media when it's emulated volume" am: 7f656092df
am: 0fe81d7320

Change-Id: Ia2b865c56a92265151444b4b7310b61c51a9a952
2018-12-05 08:38:43 -08:00
Takamasa Kuramitsu
f5f03fc083 Hide eject icon of removable media when it's emulated volume
Hide eject icon of removable media on the root list of Files app when
primary shared storage is in adopted media due to the following reasons.

- Primary shared storage should not be easily ejected because that
causes the situation that there's no primary shared storage

- To align with the Storage settings (Settings > Storage), eject icon
is disabled in this menu when the removable media is adopted

- Eject action from Files app can only unmount primary shared storage

Bug: 117252468
Test: manual
Change-Id: Idd76229fb10db621a817afd60295787c761345b1
2018-11-29 03:08:07 +00:00
Ivan Chiang
a972d0449a Extend DocumentsContract search to accept mime types
1. Add the key of query arguments and match method
   in DocumentsContract.
2. Implement new querySearchDocuments method in
   DocumentsProvider, ExternalStoragProvider and
   FileSystemProvider.

Bug: 111786939
Test: Manual Test
Change-Id: I04e9f2be971f10ac1e9584a3486c948aaddea0a4
2018-11-14 15:06:35 +08:00
Risan
f8771d362c Merge "Introducing StubVolume in StorageManager" am: b499af866c am: eb871cc916
am: ee32e0d473

Change-Id: I4098132df9833b7cbac0db9bdadac297d324a822
2018-11-13 12:12:23 -08:00
Risan
ee32e0d473 Merge "Introducing StubVolume in StorageManager" am: b499af866c
am: eb871cc916

Change-Id: I69240d32659b511aec0e1e029fb6c6f1ab455c9c
2018-11-13 11:57:12 -08:00
Risan
05c41e6a0a Introducing StubVolume in StorageManager
Bug: 110380403
Test: Tested in ARC++ (with Settings and vold changes in separate CLS)
- able to see the external storage under StorageSettings. Also tested
the sm command to print stubvolumes.

Change-Id: I7517260a40399bd9800424bb394512601f6af617
2018-11-08 21:48:35 +00:00
Jeff Sharkey
643e99ef06 Reroute Uri conversions though MediaProvider.
Upcoming changes will prevent apps from reading "_data" columns
directly, which is required to convert between DocumentsProvider and
MediaProvider Uris.  To solve this, delegate the call() through
MediaProvider, where it can perform the "_data" lookup on behalf
of the caller.

Also add new getMediaUri() call to offer symmetry.

Bug: 111960973, 117627072, 110961701
Test: atest android.provider.cts.MediaStoreUiTest
Change-Id: I53c640704d86047d7a4bf1702aca027873395abf
2018-10-24 19:34:09 -06:00
felkachang
593d07b991 To add the Android.bp of ExternalStorageProvider
ExternalStorageProvider doesn't have any tests yet.
1. Convert Android.mk to Android.bp
2. Add init testcase
3. formatted by bpfmt -s -w Android.bp

Fixes: 117812397
Test: atest ExternalStorageProviderTests

Change-Id: I74235832f453110742de0b15cb14fac7514ecf0e
2018-10-24 06:11:06 +00:00
Andreas Gampe
b58893078b Frameworks: Annotate trivial @GuardedBy in packages
Add @GuardedBy for simple functions that require locks and have a name in
one of the frameworks naming styles for locks ("^.*(Locked|LPw|LPr|L[a-zA-Z]|UL|AL|NL)$").

Derived by errorprone.

Bug: 73000847
Test: m
Change-Id: Id14322b0a6206152cd2933c968e0a6f470fcee09
2018-09-05 17:05:26 -07:00
Bill Yi
ffa6905ddf Import translations. DO NOT MERGE
Change-Id: I629ba4be0e89af2cc8c760cfe8d5a3e3ac5443f8
Auto-generated-cl: translation import
2018-08-04 00:29:32 -07:00
Bill Yi
6d98c3e49c Import translations. DO NOT MERGE
Change-Id: I5fdad685a6bfd04b78a1ad1fb9586efc2924bb8a
Auto-generated-cl: translation import
2018-06-01 07:24:11 -07:00
Jeff Sharkey
cbfdfa90ad Merge "Return to modifying raw /mnt/media_rw paths." into pi-dev am: f7d3e028ae
am: 1394fd25ca

Change-Id: If6904b6dc431dab74e326b75f37b58ee3c99feef
2018-05-02 18:10:07 -07:00
Jeff Sharkey
1394fd25ca Merge "Return to modifying raw /mnt/media_rw paths." into pi-dev
am: f7d3e028ae

Change-Id: I61692ebdc49233923863ce773bb42a07498551b0
2018-05-02 14:29:10 -07:00
Jeff Sharkey
b00d5ea59a Return to modifying raw /mnt/media_rw paths.
We thought we could push everyone through sdcardfs, but secondary
devices mounted in a stable location don't give full write access to
apps holding WRITE_EXTERNAL_STORAGE, so system internals still need
to reach behind sdcardfs.

To keep sdcardfs in the loop about changes that we make behind its
back, we issue access(2) calls which should be enough for it to
invalidate any cached details.

Bug: 74132243
Test: manual
Change-Id: I727cd179a5a825b16ec4df6e2f41a079758d41c5
2018-05-01 10:03:18 -06:00
Bill Yi
d7c370022f Import translations. DO NOT MERGE
Auto-generated-cl: translation import

Bug: 64712476
Change-Id: Ib6847dd09539560b2c186a527a44294c86f211b2
2018-03-31 08:23:18 -07:00
Bill Yi
e89b7d01a9 Import translations. DO NOT MERGE
Change-Id: I78df3676b8f5fb027826ca835c9964446c3a1b70
Auto-generated-cl: translation import
2018-03-16 21:39:38 -07:00
Anton Hansson
ab6ec61251 frameworks/base: Set LOCAL_SDK_VERSION where possible.
This change sets LOCAL_SDK_VERSION for all packages where
this is possible without breaking the build, and
LOCAL_PRIVATE_PLATFORM_APIS := true otherwise.

Setting one of these two will be made required soon, and this
is a change in preparation for that. Not setting LOCAL_SDK_VERSION
makes the app implicitly depend on the bootclasspath, which is
often not required. This change effectively makes depending on
private apis opt-in rather than opt-out.

Test: make relevant packages
Bug: 73535841
Change-Id: I4233b9091d9066c4fa69f3d24aaf367ea500f760
2018-02-28 15:13:23 +00:00
Bill Yi
13ad8519fb Import translations. DO NOT MERGE
Change-Id: I30b4cf6c9fc5ca3f785ddb332a37311604947f8a
Auto-generated-cl: translation import
2018-02-26 14:29:07 -08:00
Bill Yi
696be5e21f Import translations. DO NOT MERGE
Change-Id: I9f7b9fb49d574b567ae8afae7ff089513ead3672
Auto-generated-cl: translation import
2018-02-22 02:27:16 -08:00
Jeff Sharkey
b78b754dc0 Enforce file transfer restrictions for shell.
If we have a policy that says DISALLOW_USB_FILE_TRANSFER, then block
file transfers for that user through common ContentProviders.

Test: builds, boots
Bug: 64672411
Change-Id: I502b10c2c229727bc6b421f9db6d2d9e2e03845c
2018-01-04 15:07:41 -07:00
Bill Yi
bd3fc330af Import translations. DO NOT MERGE
Change-Id: I37739ceeebaf645509f3a5b13d9d16af0f4cffbf
Auto-generated-cl: translation import
Exempt-From-Owner-Approval: translation import
2017-09-05 23:14:11 -07:00