diff options
author | Ben Kwa <kenobi@google.com> | 2015-05-29 15:40:31 -0700 |
---|---|---|
committer | Ben Kwa <kenobi@google.com> | 2015-06-10 11:24:55 -0700 |
commit | 77797400ec103b1691e1c3fa602c329b49ac18ca (patch) | |
tree | bc9ea8cd42536ddeaf4fb2a50cdb05d8af38d6b8 /packages/DocumentsUI/tests | |
parent | 327c364113c18c9d5a05df0c912b65788461da41 (diff) | |
download | frameworks_base-77797400ec103b1691e1c3fa602c329b49ac18ca.zip frameworks_base-77797400ec103b1691e1c3fa602c329b49ac18ca.tar.gz frameworks_base-77797400ec103b1691e1c3fa602c329b49ac18ca.tar.bz2 |
Enable apps to exclude their own roots from the DocumentsUI roots list.
- Add DocumentsContract.EXTRA_EXCLUDE_SELF (boolean extra)
- Add code to DocumentsActivity to cache the providers of the calling
app if EXTRA_EXCLUDE_SELF is set on incoming Intents.
- Add code to RootsCache to exclude roots from the calling app.
- Add code to allow only system apps to use EXTRA_PACKAGE_NAME.
Change-Id: Ia7cc2a1a297676c7b26f6e583042a4607d8c9a4e
Diffstat (limited to 'packages/DocumentsUI/tests')
-rw-r--r-- | packages/DocumentsUI/tests/src/com/android/documentsui/RootsCacheTest.java | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/packages/DocumentsUI/tests/src/com/android/documentsui/RootsCacheTest.java b/packages/DocumentsUI/tests/src/com/android/documentsui/RootsCacheTest.java index 7faa3ce..8c5bac1 100644 --- a/packages/DocumentsUI/tests/src/com/android/documentsui/RootsCacheTest.java +++ b/packages/DocumentsUI/tests/src/com/android/documentsui/RootsCacheTest.java @@ -114,6 +114,31 @@ public class RootsCacheTest extends AndroidTestCase { RootsCache.getMatchingRoots(mRoots, mState)); } + public void testExcludedAuthorities() throws Exception { + final List<RootInfo> roots = Lists.newArrayList(); + + // Set up some roots + for (int i = 0; i < 5; ++i) { + RootInfo root = new RootInfo(); + root.authority = "authority" + i; + roots.add(root); + } + // Make some allowed authorities + List<RootInfo> allowedRoots = Lists.newArrayList( + roots.get(0), roots.get(2), roots.get(4)); + // Set up the excluded authority list + for (RootInfo root: roots) { + if (!allowedRoots.contains(root)) { + mState.excludedAuthorities.add(root.authority); + } + } + mState.acceptMimes = new String[] { "*/*" }; + + assertContainsExactly( + allowedRoots, + RootsCache.getMatchingRoots(roots, mState)); + } + private static void assertContainsExactly(List<?> expected, List<?> actual) { assertEquals(expected.size(), actual.size()); for (Object o : expected) { |