Loading src/com/android/documentsui/CreateDirectoryFragment.java +2 −1 Original line number Diff line number Diff line Loading @@ -141,7 +141,8 @@ public class CreateDirectoryFragment extends DialogFragment { resolver, mCwd.derivedUri.getAuthority()); final Uri childUri = DocumentsContract.createDocument( client, mCwd.derivedUri, Document.MIME_TYPE_DIR, mDisplayName); return DocumentInfo.fromUri(resolver, childUri); DocumentInfo doc = DocumentInfo.fromUri(resolver, childUri); return doc.isDirectory() ? doc : null; } catch (Exception e) { Log.w(TAG, "Failed to create directory", e); return null; Loading tests/AndroidManifest.xml +9 −0 Original line number Diff line number Diff line Loading @@ -124,6 +124,15 @@ <action android:name="android.content.action.DOCUMENTS_PROVIDER" /> </intent-filter> </provider> <service android:name="com.android.documentsui.services.TestNotificationService" android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE" android:process="com.android.documentsui"> <intent-filter> <action android:name="android.service.notification.NotificationListenerService" /> </intent-filter> </service> </application> <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner" Loading tests/common/com/android/documentsui/DocumentsProviderHelper.java +9 −0 Original line number Diff line number Diff line Loading @@ -144,6 +144,15 @@ public class DocumentsProviderHelper { waitForWrite(); } public void writeAppendDocument(Uri documentUri, byte[] contents) throws RemoteException, IOException { ParcelFileDescriptor file = mClient.openFile(documentUri, "wa", null); try (AutoCloseOutputStream out = new AutoCloseOutputStream(file)) { out.write(contents); } waitForWrite(); } public void waitForWrite() throws RemoteException { mClient.call("waitForWrite", null, null); } Loading tests/common/com/android/documentsui/StubProvider.java +11 −2 Original line number Diff line number Diff line Loading @@ -74,7 +74,7 @@ public class StubProvider extends DocumentsProvider { private static final String TAG = "StubProvider"; private static final String STORAGE_SIZE_KEY = "documentsui.stubprovider.size"; private static int DEFAULT_ROOT_SIZE = 1024 * 1024 * 100; // 100 MB. private static int DEFAULT_ROOT_SIZE = 1024 * 1024 * 500; // 500 MB. private static final String[] DEFAULT_ROOT_PROJECTION = new String[] { Root.COLUMN_ROOT_ID, Root.COLUMN_FLAGS, Root.COLUMN_TITLE, Root.COLUMN_DOCUMENT_ID, Loading Loading @@ -357,6 +357,10 @@ public class StubProvider extends DocumentsProvider { if ("w".equals(mode)) { return startWrite(document); } if ("wa".equals(mode)) { return startWrite(document, true); } throw new FileNotFoundException(); } Loading Loading @@ -423,6 +427,11 @@ public class StubProvider extends DocumentsProvider { private ParcelFileDescriptor startWrite(final StubDocument document) throws FileNotFoundException { return startWrite(document, false); } private ParcelFileDescriptor startWrite(final StubDocument document, boolean append) throws FileNotFoundException { ParcelFileDescriptor[] pipe; try { pipe = ParcelFileDescriptor.createReliablePipe(); Loading @@ -438,7 +447,7 @@ public class StubProvider extends DocumentsProvider { try { Log.d(TAG, "Opening write stream on file " + document.documentId); inputStream = new ParcelFileDescriptor.AutoCloseInputStream(readPipe); outputStream = new FileOutputStream(document.file); outputStream = new FileOutputStream(document.file, append); byte[] buffer = new byte[32 * 1024]; int bytesToRead; int bytesRead = 0; Loading tests/common/com/android/documentsui/bots/UiBot.java +1 −1 Original line number Diff line number Diff line Loading @@ -237,7 +237,7 @@ public class UiBot extends Bots.BaseBot { onView(withId(android.R.id.button2)).perform(click()); } UiObject findMenuLabelWithName(String label) { public UiObject findMenuLabelWithName(String label) { UiSelector selector = new UiSelector().text(label); return mDevice.findObject(selector); } Loading Loading
src/com/android/documentsui/CreateDirectoryFragment.java +2 −1 Original line number Diff line number Diff line Loading @@ -141,7 +141,8 @@ public class CreateDirectoryFragment extends DialogFragment { resolver, mCwd.derivedUri.getAuthority()); final Uri childUri = DocumentsContract.createDocument( client, mCwd.derivedUri, Document.MIME_TYPE_DIR, mDisplayName); return DocumentInfo.fromUri(resolver, childUri); DocumentInfo doc = DocumentInfo.fromUri(resolver, childUri); return doc.isDirectory() ? doc : null; } catch (Exception e) { Log.w(TAG, "Failed to create directory", e); return null; Loading
tests/AndroidManifest.xml +9 −0 Original line number Diff line number Diff line Loading @@ -124,6 +124,15 @@ <action android:name="android.content.action.DOCUMENTS_PROVIDER" /> </intent-filter> </provider> <service android:name="com.android.documentsui.services.TestNotificationService" android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE" android:process="com.android.documentsui"> <intent-filter> <action android:name="android.service.notification.NotificationListenerService" /> </intent-filter> </service> </application> <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner" Loading
tests/common/com/android/documentsui/DocumentsProviderHelper.java +9 −0 Original line number Diff line number Diff line Loading @@ -144,6 +144,15 @@ public class DocumentsProviderHelper { waitForWrite(); } public void writeAppendDocument(Uri documentUri, byte[] contents) throws RemoteException, IOException { ParcelFileDescriptor file = mClient.openFile(documentUri, "wa", null); try (AutoCloseOutputStream out = new AutoCloseOutputStream(file)) { out.write(contents); } waitForWrite(); } public void waitForWrite() throws RemoteException { mClient.call("waitForWrite", null, null); } Loading
tests/common/com/android/documentsui/StubProvider.java +11 −2 Original line number Diff line number Diff line Loading @@ -74,7 +74,7 @@ public class StubProvider extends DocumentsProvider { private static final String TAG = "StubProvider"; private static final String STORAGE_SIZE_KEY = "documentsui.stubprovider.size"; private static int DEFAULT_ROOT_SIZE = 1024 * 1024 * 100; // 100 MB. private static int DEFAULT_ROOT_SIZE = 1024 * 1024 * 500; // 500 MB. private static final String[] DEFAULT_ROOT_PROJECTION = new String[] { Root.COLUMN_ROOT_ID, Root.COLUMN_FLAGS, Root.COLUMN_TITLE, Root.COLUMN_DOCUMENT_ID, Loading Loading @@ -357,6 +357,10 @@ public class StubProvider extends DocumentsProvider { if ("w".equals(mode)) { return startWrite(document); } if ("wa".equals(mode)) { return startWrite(document, true); } throw new FileNotFoundException(); } Loading Loading @@ -423,6 +427,11 @@ public class StubProvider extends DocumentsProvider { private ParcelFileDescriptor startWrite(final StubDocument document) throws FileNotFoundException { return startWrite(document, false); } private ParcelFileDescriptor startWrite(final StubDocument document, boolean append) throws FileNotFoundException { ParcelFileDescriptor[] pipe; try { pipe = ParcelFileDescriptor.createReliablePipe(); Loading @@ -438,7 +447,7 @@ public class StubProvider extends DocumentsProvider { try { Log.d(TAG, "Opening write stream on file " + document.documentId); inputStream = new ParcelFileDescriptor.AutoCloseInputStream(readPipe); outputStream = new FileOutputStream(document.file); outputStream = new FileOutputStream(document.file, append); byte[] buffer = new byte[32 * 1024]; int bytesToRead; int bytesRead = 0; Loading
tests/common/com/android/documentsui/bots/UiBot.java +1 −1 Original line number Diff line number Diff line Loading @@ -237,7 +237,7 @@ public class UiBot extends Bots.BaseBot { onView(withId(android.R.id.button2)).perform(click()); } UiObject findMenuLabelWithName(String label) { public UiObject findMenuLabelWithName(String label) { UiSelector selector = new UiSelector().text(label); return mDevice.findObject(selector); } Loading