Skip to content
This repository has been archived by the owner on Feb 22, 2024. It is now read-only.

Add Filesystem package #35

Merged
merged 34 commits into from Jul 15, 2021
Merged

Add Filesystem package #35

merged 34 commits into from Jul 15, 2021

Conversation

yrezgui
Copy link
Collaborator

@yrezgui yrezgui commented Jul 2, 2021

  • Add filesystem demo
  • Upgrade sample project dependencies
  • Add POM details for filesystem package
  • Enable KDOC for filesystem package
  • Figure out how to avoid minSdk to API 26 in the build.gradle
  • Fix API docs output directory

@nic0lette Actual changes since your PR got merged: https://github.com/google/modernstorage/pull/35/files/3b7106c574606bd97f32eb777a06f0ddc49e0fb9..a13cd3a030e8d4c7fc8d80c18a842f5da0fd4254

nic0lette and others added 21 commits June 30, 2021 20:37
A proof-of-concept java.nio.file.spi.FileSystemProvider implementation
for working with `content://` scheme URIs.

The very basic implementation supports use of `Files.walk()` and the
`Path` objects returned can be passed directly to `okio` methods.

The implementation includes a token set of tests due to the way
content:// uri access is usually granted (via the system file picker).
Currently working on how to write more useful cases.
Adds scaffolding for a demo of the filesystem library.
Delegate the `isTree` method to `ContentPath`.
Adds a pair of test cases for a single document Path. Creating a Uri
that's used with DocumentsContract to connect to a test DocumentProvider
and return content.
Add a check for a Root.MIME_TYPE_ITEM for deciding if a document is a
directory or not.
- Builds a DocumentsProvider for testing the filesystem code with
  ContentResolver.
- Built a small DSL to allow creating a document tree for test cases
  that doesn't rely on creating files.
Builds up the TestDocumentProvider to support operations needed for
walking a tree.
This changes the implementation to extract all the Android specific
calls from the main FileSystem classes so that we'll be able to
write host side unit tests that run without Android/Robolectric.

NOTE: Technically there are a couple of methods left, but they're more
difficult to extract in a clean way at the moment, so I've left them.

In ExternalStoragePath:
- android.os.Environment#getExternalStorageDirectory()
- android.os.Process#myPid()
First set of host side tests for ContentFileSystemProvider et al.
Switch copyright from AOSP to Google LLC (to match the rest of
ModernStorage).
Register URIs when an instance of a ContentFileSystem is created, and
allow retrieving them with `ContentFileSystem.getRootDirectories()`
Refactors some of the provider specific methods to the FileSystem level
(which are backed by individual providers already), and changes the test
init method from `installContentFileSystem` to `initialize` to more
closely match app code.
Adds generic & ExternalStorageProvider specific implementations for
"ContentPath#getParent()", along with host side tests.

It would be nice to have instrumentation tests, but I haven't been able
to grant access to any ExternalStorageProvider APIs in a test. I could
implement it for TestDocumentProvider but that would also require a bit
more work.
Test: Existing tests pass
Add API metadata
Unify build.gradle for both libraries
* Import proof-of-concept ContentFileSystemProvider

A proof-of-concept java.nio.file.spi.FileSystemProvider implementation
for working with `content://` scheme URIs.

The very basic implementation supports use of `Files.walk()` and the
`Path` objects returned can be passed directly to `okio` methods.

The implementation includes a token set of tests due to the way
content:// uri access is usually granted (via the system file picker).
Currently working on how to write more useful cases.

* Sample scaffolding

Adds scaffolding for a demo of the filesystem library.

* Minor update for ExternalStoragePath

Delegate the `isTree` method to `ContentPath`.

* Add test case for single document

Adds a pair of test cases for a single document Path. Creating a Uri
that's used with DocumentsContract to connect to a test DocumentProvider
and return content.

* Add check for "root"

Add a check for a Root.MIME_TYPE_ITEM for deciding if a document is a
directory or not.

* Improve test cases

- Builds a DocumentsProvider for testing the filesystem code with
  ContentResolver.
- Built a small DSL to allow creating a document tree for test cases
  that doesn't rely on creating files.

* Add basic test for Files.walk

Builds up the TestDocumentProvider to support operations needed for
walking a tree.

* Extract Android classes

This changes the implementation to extract all the Android specific
calls from the main FileSystem classes so that we'll be able to
write host side unit tests that run without Android/Robolectric.

NOTE: Technically there are a couple of methods left, but they're more
difficult to extract in a clean way at the moment, so I've left them.

In ExternalStoragePath:
- android.os.Environment#getExternalStorageDirectory()
- android.os.Process#myPid()

* Host side tests

First set of host side tests for ContentFileSystemProvider et al.

* Update copyright

Switch copyright from AOSP to Google LLC (to match the rest of
ModernStorage).

* Remove debug log statements

* Register FileSystem "roots"

Register URIs when an instance of a ContentFileSystem is created, and
allow retrieving them with `ContentFileSystem.getRootDirectories()`

* Minor update to test code

* Refactoring

Refactors some of the provider specific methods to the FileSystem level
(which are backed by individual providers already), and changes the test
init method from `installContentFileSystem` to `initialize` to more
closely match app code.

* Fix license header

* Add "getParent" implementation

Adds generic & ExternalStorageProvider specific implementations for
"ContentPath#getParent()", along with host side tests.

It would be nice to have instrumentation tests, but I haven't been able
to grant access to any ExternalStorageProvider APIs in a test. I could
implement it for TestDocumentProvider but that would also require a bit
more work.

* Apply Spotless

Test: Existing tests pass

* Address PR comments.
@yrezgui yrezgui added this to In Progress in Roadmap Jul 5, 2021
@yrezgui yrezgui marked this pull request as ready for review July 12, 2021 23:13
nic0lette and others added 4 commits July 13, 2021 00:14
This adds a few files from the .idea directory to the repo, based on the
.gitignore (and some settings) from AndroidX.
@yrezgui yrezgui requested a review from nic0lette July 12, 2021 23:14
Copy link
Collaborator

@nic0lette nic0lette left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First pass is mostly good. Thinking about the minSdkVersion thing :)

@yrezgui yrezgui merged commit 0b10c10 into main Jul 15, 2021
Roadmap automation moved this from In Progress to Done Jul 15, 2021
@yrezgui yrezgui deleted the filesystem branch July 15, 2021 09:30
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

None yet

2 participants