summaryrefslogtreecommitdiff
path: root/core/java/android/os/FileUtils.java
Commit message (Collapse)AuthorAgeFilesLines
* Correction in logic of roundend size calculation of SD cardChetan Gurjar2022-10-211-1/+3
| | | | | | | | | | | | API FileUtils.roundStorageSize() rounded up the Storage size incorrectly and caused the storage total size to be displayed twice the actual capacity in storage Settings application. Modifications done to appropriately roundup the storage size in the multiple of power of 2 by making the loop iterations to be controlled by 1024 instead of 1000. Test: Verified with the particular SD card with which bug reported. Change-Id: I8f92248a457d6ac507d092df46e1cb0daaa55134
* Remove spammy convertToModernFd logZim2021-08-061-1/+1
| | | | | | | | | It is a common source of confusion that something went wrong while triaging bugs. Bug: 195587219 Test: m Change-Id: Ieca96a2774f08367b05147b49fcea56dd4f2bfda
* Fix fd leak while bypassing transcoding in media APIsZim2021-07-291-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | | To call the media service while bypassing transcoding there are 4 file descriptors involved: A: The original file descriptor the app owns and is responsible for closing B: Dupe of A, to pass into the MediaStore API as an input to receive a non-transoding fd C: The output from the MediaStore API D: Final fd owned by the media service, after C gets duped over binder as part of setDataSource We were leaking (B) and (C). Now we close them appropriately. See I0124ec8fbd0471237e99bab321f903544f8fe1f8 for another 2 fd leak fix in MediaProvider Test: atest TranscodeTest Test: Manual with 'adb shell lsof | grep <filename>' Bug: 194828489 Bug: 179804072 Change-Id: I978257bbc4a8f6813b6e6a5ce22124257204f432 Merged-In: I978257bbc4a8f6813b6e6a5ce22124257204f432
* Reduce log severity for transcode fd conversion failureZim2021-05-041-1/+1
| | | | | | | | | | | Converting a transcode fd to the original fd might fail for the more common reason that the fd is already original. Now, we log as DEBUG instead of WARNING Test: m Bug: 186672282 Change-Id: Ifd0b3cef901ae1c2f467ace06dca590dff8ffb04
* Fix FileUtils#copy to fallback on userspace copy if sendfile failsZim2021-04-121-1/+15
| | | | | | | | | | | | | | | | | As per the manpage, sendfile(2) might fail for the following reasons: 1. input fd doesn't support mmap 2. output was opened with O_APPEND If sendfile(2) fails with EINVAL or ENOSYS, we fallback to userspace copy Fixed failing FileUtilsTest#convertToModernFd test since I7d6ecf4549e8ed5134d20977c2089240be804827 that stoped matching valid files to convert to modernfd with regex Test: atest FileUtilsTest Bug: 184236915 Change-Id: I0955fe2a7dfb40ac1f78bde4a325eb624a34f28b
* Refactor FileUtils#convertToModernFdBiswarup Pal2021-03-311-34/+7
| | | | | | | | | | Replace implementation of FileUtils#convertToModernFd with MediaStore#getOriginalMediaFormatFileDescriptor. Fix fd leak by returning ParcelFileDescriptor instead of FileDescriptor. Test: atest CtsProviderTestCases Bug: 170488060 Change-Id: I7d6ecf4549e8ed5134d20977c2089240be804827
* Merge "Make FileUtils#createDir threadsafe" am: 5232082243 am: bc1b11029b ↵Jeff Sharkey2021-03-111-5/+15
|\ | | | | | | | | | | | | | | | | | | am: 5c1ad2c60d Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1623101 MUST ONLY BE SUBMITTED BY AUTOMERGER Change-Id: I89d4a57963e75c0a6000f1f1a9a266b22e28be94
| * Make FileUtils#createDir threadsafeJacob Abrams2021-03-081-5/+15
| | | | | | | | | | | | | | | | Prior to this change the createDir method would return false if invoked around the same time on two different threads for the same directory. Test: manual Change-Id: I34ba4f645a034f47917054af4b299f916a9cfa67
| * Add maxTargetSdk restriction to unused APIs.Mathew Inwood2020-11-041-5/+5
| | | | | | | | | | | | | | | | | | | | | | These are APIs that have @UnsupportedAppUsage but for which we don't have any evidence of them currently being used, so should be safe to remove from the unsupported list. Bug: 170729553 Test: Treehugger Merged-In: I626caf7c1fe46c5ab1f39c2895b42a34319f771a Change-Id: I54e5ecd11e76ca1de3c5893e3a98b0108e735413
| * Merge Android R (rvc-dev-plus-aosp-without-vendor@6692709)Xin Li2020-08-311-0/+4
| |\ | | | | | | | | | | | | | | | Bug: 166295507 Merged-In: I3d92a6de21a938f6b352ec26dc23420c0fe02b27 Change-Id: Ifdb80563ef042738778ebb8a7581a97c4e3d96e2
* | | Fix convertToModernFd to support /mnt/user pathsZim2021-01-191-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since I72f39d3e35b975f0a386c055cbb10b4d21c21c86, the MediaProvider now always opens FUSE paths when transcoding is required. Those paths start with /mnt/user/ but apps can't access those paths directly so we make the following changes: 1. Call readlink(2) directly (without stat as ParcelFileDescriptor#getFile currently does). 2. Replace /mnt/user/<userid> with /storage paths and use the new /storage path for scanning This also fixes some failing CTS Test: Apps don't ANR when calling MediaMetadataRetriever#setDataSource Test: atest android.appsecurity.cts.ExternalStorageHostTest#testMediaNone29 Bug: 174655855 Fixes: 177860000 Change-Id: Iec48dcb714a47b147e16eae39df783de748960f4
* | | Use accept_original_media_format constantZim2021-01-081-2/+1
| | | | | | | | | | | | | | | | | | Bug: 158465539 Test: m Change-Id: I82b9f3b740d295cfa927987783e5fe1bab562070
* | | Fix screenshot failure with transcodingManish Singh2020-12-171-4/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We currently attempt to convert transcode fds to original fds inside the platform media players. This causes screenshot failures in ExifInterface. To mitigate, we only match published videos in DCIM/Camera. Bug: 173543930 Bug: 175831095 Test: atest FileUtilsTest#testConvertToModernFd Test: Manual, tested by both taking a screenshot and video transcoding. Change-Id: I4abba3d9d36e83c5a019b32793bd38fee81d5f75
* | | Fix transcode_optimize flagsZim2020-12-141-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The optimize flag depended on transcode_enabled (sysprop only, ignoring device_config) flag to take effect. Now, we removed the 'optimize' flag and rely on a new non-persistent sysprop that says if transcode was enabled on the current boot. This means that a reboot is required for 'optimizations' to take effect, right after enabling/disabling transcode. This is anyways a better trade-off than ignoring the device_config transcode_enabled flag entirely. Test: Manual Bug: 170488060 Change-Id: I77bbc30f9fae2cfc0085c32028859fdbbc9aaed7
* | | Introduce new preference indicating user control.Manish Singh2020-12-061-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If the user enables this, then that means that we will respect user's choices for all the preferences, i.e. we will not update the preferences based on the updates from server. On the other hand, if it's disabled, then the rest of the preferences would not be considered. And we'd decide their values based on the values from the DeviceConfig (which in turn come from the server). Also, renaming the set prop key for enabling-transcode to match the one in DeviceConfig - transcode_enabled. Also, the "transcode_enable_all" controller now enables (instead of disabling) the global level transcoding. BUG:169327180 Test: manual testing. Change-Id: I183b3b5496b647943be377c02c8c9e2a0df71752
* | | Revise seamless transcoding optimization flagsZim2020-11-121-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These flags determine if we bypass transcoding in several platform media classes. We previously, had non-perssitent, default-false flags for each framework class. Now, we have one persistent default-true 'optimize' flag: persist.sys.fuse.transcode_optimize. Of course, if the global transcode flag, persist.sys.fuse.transcode is off, the code is a no-op. Bug: 158465539 Test: Manual Change-Id: Ie1442213d0744888bac45b43ad8a07f0ebf55066
* | | Add maxTargetSdk restriction to unused APIs.Mathew Inwood2020-10-291-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These are APIs that have @UnsupportedAppUsage but for which we don't have any evidence of them currently being used, so should be safe to remove from the unsupported list. This is a resubmit of ag/12929664 with some APIs excluded that caused test failures; see bugs 171886397, 171888296, 171864568. APIs excluded: Landroid/bluetooth/le/ScanRecord;->parseFromBytes([B)Landroid/bluetooth/le/ScanRecord; Landroid/os/Process;->myPpid()I Landroid/os/SharedMemory;->getFd()I Landroid/hardware/input/InputManager;->INJECT_INPUT_EVENT_MODE_WAIT_FOR_FINISH:I Bug: 170729553 Test: Treehugger Change-Id: I8285daa8530260251ecad6f3f38f98e263629ca7
* | | Revert "Add maxTargetSdk restriction to unused APIs."Hongwei Wang2020-10-281-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 72f07d6a8a32db4a0dedd7682a0b3385be2b9cd6. Reason for revert: Droidcop-triggered revert due to breakage https://android-build.googleplex.com/builds/quarterdeck?testMethod=testAppZygotePreload&testClass=android.app.cts.ServiceTest&atpConfigName=suite%2Ftest-mapping-presubmit-retry_cloud-tf&testModule=CtsAppTestCases&fkbb=6936597&lkbb=6936969&lkgb=6936551&testResults=true&branch=git_master&target=cf_x86_phone-userdebug>, bug b/171886397 Bug: 171886397 Change-Id: Ibe0f0430a3451477c1ee8ef56a596e91ea1e7672
* | | Add maxTargetSdk restriction to unused APIs.Mathew Inwood2020-10-271-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These are APIs that have @UnsupportedAppUsage but for which we don't have any evidence of them currently being used, so should be safe to remove from the unsupported list. Bug: 170729553 Test: Treehugger Change-Id: I4c8fd0006f950de9955242e93968fb0996ceb372
* | | Avoid transcoding in MediaPlayersZim2020-10-201-0/+56
| | | | | | | | | | | | | | | | | | Test: Manual Bug: 158466177 Change-Id: I71776e1e81002b1505f5094c92fdd10706d1268e
* | | Merge "Update language to comply with Android's inclusive language guidance" ↵Treehugger Robot2020-07-311-1/+1
|\| | | |/ |/| | | | | | | | | | | am: e2d9b14b60 am: 6f22d2c310 Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1382541 Change-Id: I94da777e46e45795d01708f3ba52ce81f61aec87
| * Update language to comply with Android's inclusive language guidanceLais Andrade2020-07-311-1/+1
| | | | | | | | | | | | | | | | | | See https://source.android.com/setup/contribute/respectful-code for reference BUG=162536543 Change-Id: Iea1f8c3d2a253cad5a6a429389bbe3fc5fd4bc6b
| * Use new UnsupportedAppUsage annotation.Artur Satayev2020-01-131-1/+1
| | | | | | | | | | | | | | | | | | Existing annotations in libcore/ and frameworks/ will deleted after the migration. This also means that any java library that compiles @UnsupportedAppUsage requires a direct dependency on "unsupportedappusage" java_library. Bug: 145132366 Test: m && diff unsupportedappusage_index.csv Change-Id: I534e3fd1305e2f4af076986770033478448a665c Merged-In: I534e3fd1305e2f4af076986770033478448a665c
* | Update BlobStoreMS to augment storage stats with blobs data.Sudheer Shanka2020-02-191-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Any pending sessions data is attributed to the apps which contributed them. - Any commited blobs data is attributed to the app which has a lease on it. If multiple apps have lease on a blob, don't attribute the blob to those apps for now. - Remove StorageStatsAugmenter.augmentStatsForUser as it is not used for anything currently. - Fix an issue in how we override existing committers and leasees. Bug: 148694869 Test: atest cts/tests/BlobStore/src/com/android/cts/blob/BlobStoreManagerTest.java Test: atest tests/tests/os/src/android/os/storage/cts/StorageStatsManagerTest.java Test: atest hostsidetests/appsecurity/src/android/appsecurity/cts/StorageHostTest.java Test: manual Change-Id: Ia4af0a2549c75db66741f2d1979de95d2d150bc8
* | Use new UnsupportedAppUsage annotation.Artur Satayev2019-12-181-1/+1
|/ | | | | | | | Existing annotations in libcore/ and frameworks/ will deleted after the migration. This also means that any java library that compiles @UnsupportedAppUsage requires a direct dependency on "unsupportedappusage" java_library. Bug: 145132366 Test: m && diff unsupportedappusage_index.csv Change-Id: I534e3fd1305e2f4af076986770033478448a665c
* Deprecate FileUtils.closeQuietlyCharles Munger2019-11-151-0/+12
| | | | | | | | | | This API encourages swallowing errors, and the code to implement it is trivial if apps still want to do it themselves. Guava's reasoning on deprecating their version of this API: https://github.com/google/guava/issues/1118 Test: No behavior changes Bug: 144042891 Change-Id: Ic4cfb7366c65d49c355479f420d9ba4fc1b3f053
* Add @UnsupportedAppUsage annotationsAndrei Onea2019-03-151-0/+15
| | | | | | | | | | | | | | | | For packages: android.os This is an automatically generated CL. See go/UnsupportedAppUsage for more details. Exempted-From-Owner-Approval: Mechanical changes to the codebase which have been approved by Android API council and announced on android-eng@ Bug: 110868826 Test: m Change-Id: I4ece0a3f37f88fc2508cb965092aed7cabc61819
* Respond to various API council feedback.Jeff Sharkey2019-02-191-1/+3
| | | | | | | | | | | | Handle many simple, smaller changes in a single CL. Hide CPC.closeQuietly(), now that it implements AutoCloseable. Add more details to CR.set/getCache() docs. Add many @Nullable/@NonNull annotations. Bug: 124507578, 124447751, 124302519, 123697622 Bug: 123661322, 122887179, 122528742, 122527812, 116224797 Test: manual Change-Id: Icee556a6ed76bbdf4c8e42b59d69d5580d461b95
* Allow update() to move files on disk.Jeff Sharkey2019-02-111-0/+6
| | | | | | | | | | | | | | | | There are a set of columns available through insert() and query() which influence placement of files on disk, so it makes sense to expand update() to allow movement of underlying files, as long as the changes respect any rules that would have been applied to a brand new insert(). When a caller updates any placement columns, blend them together with any current values, and generate the path that would have been used for an insert. Bug: 123967243 Test: atest cts/tests/tests/provider/src/android/provider/cts/MediaStore* Change-Id: I440a3edc5faaebac30e5bfa4c992157be39c8ee1
* Get CtsProviderTestCases building against API.Jeff Sharkey2019-01-271-0/+2
| | | | | | | | | | | | To help confirm that we're actually testing developer-visible behaviors, we need to build against public APIs, since there have been plenty of examples in this suite of "testing" hidden API behaviors, which are then misleading to developers. Bug: 120429729 Test: atest cts/tests/tests/provider/ Exempt-From-Owner-Approval: Trivial API annotations Change-Id: I07fe33e54f611a6060217f0706fb99b809961f4d
* Sanity check raw paths against requested volume.Jeff Sharkey2019-01-221-0/+11
| | | | | | | | | | | | | | | | | | | | | | | When callers are inserting or updating raw "_data" paths, we need to sanity check them to make sure they're not "crossing the streams" between storage devices. For example, it would be really broken to insert a file on the SD card into the "internal" storage volume. This also enforces that callers don't "cross the streams" between multiple storage volumes on devices that support them, since otherwise they'd end up with very confusing behavior, such as the same underlying file being inserted into multiple databases. Also, the "internal" storage volume should really only be used for common media (such as ringtones), and it shouldn't be allowed to point into private app data directories, since MODE_WORLD_READABLE has been deprecated for many years now. Bug: 117932814 Test: atest MediaProviderTests Test: atest cts/tests/tests/media/src/android/media/cts/MediaScanner* Test: atest cts/tests/tests/provider/src/android/provider/cts/MediaStore* Change-Id: I267eacd45bbd270b8ce9b28de9d6e209f780f31a
* Make security warning on contains() more obvious.Alan Stokes2019-01-181-1/+10
| | | | | | | | | The dire warning about canonicalising paths before calling FileUtils#contains was present on two overloads but not the third. Added it there to try to make it harder to miss. Test: Builds. Change-Id: I983fe86e57ff3f7052f4f5d55f2bbd9e5740429a
* FileUtils.java: Don't treat open access modes as flagsNick Kralevich2018-12-171-19/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | O_RDONLY, O_WRONLY, and O_RDWR are not flags. Rather, they are the integer values 0, 1, and 2, respectively. #define O_RDONLY 00000000 #define O_WRONLY 00000001 #define O_RDWR 00000002 Quoting "man 2 open" * File access mode * Unlike the other values that can be specified in flags, the access mode values O_RDONLY, O_WRONLY, and O_RDWR do not specify individual bits. Rather, they define the low order two bits of flags, and are defined respectively as 0, 1, and 2. In other words, the combination O_RDONLY | O_WRONLY is a logical error, and certainly does not have the same meaning as O_RDWR. Linux reserves the special, nonstandard access mode 3 (binary 11) in flags to mean: check for read and write permission on the file and return a file descriptor that can't be used for reading or writing. This nonstandard access mode is used by some Linux drivers to return a file descriptor that is to be used only for device-specific ioctl(2) operations. Rather than treat these values like flags, use O_ACCMODE to extract the values and then perform the comparisons. Introduced in 63280e06fc64672ab36d14f852b13df2274cc328. Test: android compiles and boots. Change-Id: I4d3185e835615ffba3a7854d3d58351e124599d0
* Local and remote isolated storage feature flags.Jeff Sharkey2018-12-151-23/+7
| | | | | | | | | | | | | | | | | | | Moving forward as we start enabling isolated storage in various dogfood groups, we'll need to maintain separate values for the feature flag for both "local" and "remote" opinions. Any strongly expressed local opinion will always take precidence over any remote opinion. Any changes to these feature flags means that we need to invalidate any PackageManager parsed APKs, since PackageParser changes it's output depending on the flag state. Since other feature flags are likely to need this type of invalidation in the future, define the PackageManager cache using a SHA-1 hash of a collection of values that should invalidate the cache. Bug: 112545973 Test: atest android.os.SystemPropertiesTest Change-Id: Ifafcdf15e40e694eb4126e06981aeb82df51da33
* Calculate MediaColumns.HASH when demanded.Jeff Sharkey2018-12-111-0/+54
| | | | | | | | | | | | | We'll come back in a future change to wire up automatic hashing in onIdleMaintenance(), but we'll hold off on that until we've implemented our optimized in-kernel hashing. For now, generate the has when demanded via canonicalize(), and clear any hash whenever the file is edited. Tests to verify sanity. Bug: 120782363 Test: atest android.provider.cts.MediaStoreTest Change-Id: I287f7a204655b37e4efd519579b12084ee4fb8e3
* resolve merge conflicts of 6c9537dc7f86c6af3204ed57cee644a8e51a365b to masterRisan2018-11-141-0/+1
|\ | | | | | | | | | | Bug: None Test: I solemnly swear I tested this conflict resolution (presubmit). Change-Id: Ic8bf52c913caa7ed6bd91aa7dfb95a4cc2032249
| * Add FileUtils.translateModePfdToPosixRisan2018-11-131-0/+37
| | | | | | | | | | | | | | Bug: 72017414, 110379912 Test: manual with appfuse Change-Id: I92b2f8995c1e011ff3fbc5c5a55d8c5793e2b5cf Merged-In: I94373055468d279e6553d4a038267732b9b53745
* | Add sm set-isolated-storage [true|false]Sudheer Shanka2018-11-081-2/+7
| | | | | | | | | | | | Bug: 119038726 Test: manual Change-Id: I29eeec7872584f1173e9b6d31434b36487515d9e
* | Magic to keep "_data" paths working.Jeff Sharkey2018-10-261-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As part of the storage changes in Q, we're removing the ability for apps to directly access storage devices like /sdcard/. (Instead, they'll need to go through ContentResolver.openFileDescriptor() to gain access.) However, in several places we're returning raw filesystem paths in the "_data" column. An initial attempt to simply redact these with "/dev/null" shows that many popular apps are depending on these paths, and become non-functional. So we need to somehow return "_data" paths that apps can manually open. We explored tricks like /proc/self/fd/ and FUSE, but neither of those are feasible. Instead, we've created a cursor that returns paths of this form: /mnt/content/media/audio/12 And we then hook Libcore.os to intercept open() syscalls made by Java code and redirect these to CR.openFileDescriptor() with Uris like this: content://media/audio/12 This appears to be enough to keep most popular apps working! Note that it doesn't support apps that try opening the returned paths from native code, which we'll hopefully be solving via direct developer outreach. Since this feature is a bit risky, it's guarded with a feature flag that's disabled by default; a future CL will actually enable it, offering a simple CL to revert in the case of trouble. Bug: 111268862, 111960973 Test: atest cts/tests/tests/provider/src/android/provider/cts/MediaStore* Change-Id: Ied15e62b46852aef73725f63d7648da390c4e03e
* | Catch more invalid file modes.Jeff Sharkey2018-10-171-0/+13
| | | | | | | | | | | | Bug: 117440225 Test: atest android.os.FileUtilsTest Change-Id: Id5e8c0869182b6391994dd9266a455dd3152e653
* | Utilities for content:// Uris and file modes.Jeff Sharkey2018-09-121-2/+109
| | | | | | | | | | | | | | Bug: 111268862, 111960973 Test: atest cts/tests/tests/content/src/android/content/cts/ContentUrisTest.java Test: atest frameworks/base/core/tests/coretests/src/android/os/FileUtilsTest.java Change-Id: I94373055468d279e6553d4a038267732b9b53745
* | More robust MTP-to-MIME-type mappings.Jeff Sharkey2018-08-281-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Recently in I830717428e72ac37c5ecd1f23d915aa878ef3744, we greatly improved the underlying file-extension-to-MIME-type mappings defined in libcore and used across the OS. Instead of maintaining divergent mappings here in MediaFile, this change delegates all file extension logic down to libcore, and standardizes all MediaScanner internals on using MIME types. To register new file types in the future: 1. Add the MIME-to-extension registration in libcore. 2. Add the MIME-to-MTP mapping here in MediaFile. This change also ensures that unknown MIME types are surfaced across MTP, using constants like FORMAT_UNDEFINED_AUDIO for audio/* until an explicit format is defined. We now surface WMA/WMV file formats, even if the device can't natively play them back, since we still want to offer the ability for users to copy them around, and the user may have a third-party app capable of playing them. Keeps @UnsupportedAppUsage intact for now. Bug: 111268862, 112162449 Test: atest frameworks/base/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/MediaFileTest.java Test: atest cts/tests/tests/provider/src/android/provider/cts/MediaStore* Change-Id: I2f6a5411bc215f776f00e0f9a4b7d825b10b377d
* | Make ENABLE_COPY_OPTIMIZATIONS non final.Brett Chabot2018-07-121-3/+4
| | | | | | | | | | Test: make -j56 Run_robolectric_robolectric_tests Change-Id: I6ef235fef5a2daf55fab059b4d1b3a9afce09c8d
* | Utility methods useful for working with files.Jeff Sharkey2018-07-111-64/+192
|/ | | | | | | | Part of getting DocumentsUI ready for building against public API. Test: builds Bug: 110959821 Change-Id: I7cc0acd5ac3bcc89790cb49f34291ae523e44019
* Report final progress when finished copying.Jeff Sharkey2018-03-261-0/+9
| | | | | | Test: none Bug: 74120182 Change-Id: I984d38505545b5f18dd3dd9a3c6f714a9ea86edd
* Move more folks to FileUtils.copy().Jeff Sharkey2018-02-011-30/+124
| | | | | | | | | | | | Also extend API to accept a "count" argument of exactly how many bytes to copy, and return the actual number of copied bytes. Improve docs. Test: bit FrameworksCoreTests:android.os.FileUtilsTest Test: vogar --mode app_process --benchmark frameworks/base/core/tests/benchmarks/src/android/os/FileUtilsBenchmark.java Bug: 71932978 Change-Id: I8d255e4f97462838c02a8ecb6d2d221188c4eff0
* Enable sendfile() and splice() optimizations.Jeff Sharkey2018-01-311-1/+1
| | | | | | | | | This can easily be reverted if we uncover any trouble. Test: bit FrameworksCoreTests:android.os.FileUtilsTest Test: vogar --mode app_process --benchmark frameworks/base/core/tests/benchmarks/src/android/os/FileUtilsBenchmark.java Bug: 71932978 Change-Id: Iac97c342948074c4f373e5f2ae70e563b308a11e
* Use sendfile() and splice() to speed up copying.Jeff Sharkey2018-01-311-17/+231
| | | | | | | | | | | | | | | | | | | | | | | | | There are several places across the OS where Java code is simply copying data between two points, which requires bringing that data out into userspace before going back into the kernel. (That's pretty lame.) The patches for the recent Meltdown/Spectre security issues have made this overhead even worse, so it's finally time to move this copying directly into the kernel. This change adds a couple new FileUtils.copy() methods which inspect the given streams/FDs, and attempt to do as much optimization as possible before falling back to a slower userspace-based copy. Benchmarks are showing typical improvements of 44% for 32KB files, 50% for 32MB files, and 35% for 32MB pipes. Plenty of tests are included, and there's a simple kill-switch that can be used to enable/disable the feature if it starts causing any trouble. (A future CL will enable the optimizations.) Test: bit FrameworksCoreTests:android.os.FileUtilsTest Test: vogar --mode app_process --benchmark frameworks/base/core/tests/benchmarks/src/android/os/FileUtilsBenchmark.java Bug: 71932978 Change-Id: I52518d529da5d961610998b9f61399064d8025cd
* Narrower StrictMode defaults.Jeff Sharkey2017-11-031-2/+11
| | | | | | | | | | | | | | | | | | | | | | | | | Until now, userdebug and eng builds have tracked StrictMode violations on all system apps, including prebuilts that we have no control over, which results in a lot of unactionable noise. This CL narrows the set of enabled apps to only "bundled" system apps, which gives us a much higher chance of burning these violations down to 0 and keeping them there. We don't have a good proxy for an app being "bundled", so we detect it based on being in the "android." or "com.android." package namespace. Clean up the entire flow of applying StrictMode defaults to make it much more human-readable. This resulted in us fixing a bug where StrictMode was never actually enabled for jank-sensitive threads in system_server! Relax I/O checks in a few places where we know we're interacting with procfs or sysfs. Add internal "allow" methods that avoid object allocation by returning raw mask. Test: cts-tradefed run commandAndExit cts-dev -m CtsOsTestCases -t android.os.cts.StrictModeTest Bug: 68662870 Change-Id: I536e8934fbcdec14915fcb10995fc9704ea98b29
* Log sync details to rotating log files (userdebug/eng only)Makoto Onuki2017-06-231-5/+5
| | | | | | | Bug 62052247 Test: Manual test with setting debug.synclog to 0 and 1. Change-Id: I553dc8d3457ae99cbca5bf6a74303b8a8d8817e7