Merge "Follow up for disabling creating archives in resources." into arc-apps
diff --git a/src/com/android/documentsui/BaseActivity.java b/src/com/android/documentsui/BaseActivity.java
index 305e0d7..1480e25 100644
--- a/src/com/android/documentsui/BaseActivity.java
+++ b/src/com/android/documentsui/BaseActivity.java
@@ -368,8 +368,7 @@
return cwd != null
&& cwd.isCreateSupported()
&& !mSearchManager.isSearching()
- && !root.isRecents()
- && !root.isDownloads();
+ && !root.isRecents();
}
// TODO: make navigator listen to state
diff --git a/src/com/android/documentsui/DirectoryLoader.java b/src/com/android/documentsui/DirectoryLoader.java
index 8720701..5c93f76 100644
--- a/src/com/android/documentsui/DirectoryLoader.java
+++ b/src/com/android/documentsui/DirectoryLoader.java
@@ -23,6 +23,7 @@
import android.database.ContentObserver;
import android.database.Cursor;
import android.net.Uri;
+import android.os.Bundle;
import android.os.CancellationSignal;
import android.os.Handler;
import android.os.OperationCanceledException;
@@ -31,6 +32,7 @@
import android.util.Log;
import com.android.documentsui.archives.ArchivesProvider;
+import com.android.documentsui.base.DebugFlags;
import com.android.documentsui.base.DocumentInfo;
import com.android.documentsui.base.FilteringCursorWrapper;
import com.android.documentsui.base.RootInfo;
@@ -97,8 +99,21 @@
ArchivesProvider.acquireArchive(client, mUri);
}
result.client = client;
- cursor = client.query(
- mUri, null, null, null, mModel.getDocumentSortQuery(), mSignal);
+
+ if (Shared.ENABLE_OMC_API_FEATURES) {
+ Bundle queryArgs = new Bundle();
+ mModel.addQuerySortArgs(queryArgs);
+
+ // TODO: At some point we don't want forced flags to override real paging...
+ // and that point is when we have real paging.
+ DebugFlags.addForcedPagingArgs(queryArgs);
+
+ cursor = client.query(mUri, null, queryArgs, mSignal);
+ } else {
+ cursor = client.query(
+ mUri, null, null, null, mModel.getDocumentSortQuery(), mSignal);
+ }
+
if (cursor == null) {
throw new RemoteException("Provider returned null");
}
diff --git a/src/com/android/documentsui/RecentsLoader.java b/src/com/android/documentsui/RecentsLoader.java
index c3ccbba..ead5e8f 100644
--- a/src/com/android/documentsui/RecentsLoader.java
+++ b/src/com/android/documentsui/RecentsLoader.java
@@ -35,15 +35,16 @@
import com.android.documentsui.base.FilteringCursorWrapper;
import com.android.documentsui.base.RootInfo;
+import com.android.documentsui.base.Shared;
import com.android.documentsui.base.State;
import com.android.documentsui.roots.RootCursorWrapper;
import com.android.documentsui.roots.RootsAccess;
import com.android.internal.annotations.GuardedBy;
-import libcore.io.IoUtils;
-
import com.google.common.util.concurrent.AbstractFuture;
+import libcore.io.IoUtils;
+
import java.io.Closeable;
import java.io.IOException;
import java.util.ArrayList;
@@ -326,11 +327,17 @@
final Cursor[] res = new Cursor[rootIds.size()];
mCursors = new Cursor[rootIds.size()];
for (int i = 0; i < rootIds.size(); i++) {
- final Uri uri = DocumentsContract.buildRecentDocumentsUri(authority,
- rootIds.get(i));
+ final Uri uri =
+ DocumentsContract.buildRecentDocumentsUri(authority, rootIds.get(i));
try {
- res[i] = client.query(
- uri, null, null, null, mState.sortModel.getDocumentSortQuery());
+ if (Shared.ENABLE_OMC_API_FEATURES) {
+ final Bundle queryArgs = new Bundle();
+ mState.sortModel.addQuerySortArgs(queryArgs);
+ res[i] = client.query(uri, null, queryArgs, null);
+ } else {
+ res[i] = client.query(
+ uri, null, null, null, mState.sortModel.getDocumentSortQuery());
+ }
mCursors[i] = new RootCursorWrapper(authority, rootIds.get(i), res[i],
MAX_DOCS_FROM_ROOT);
} catch (Exception e) {
diff --git a/src/com/android/documentsui/archives/ArchivesProvider.java b/src/com/android/documentsui/archives/ArchivesProvider.java
index cbc8a02..8f0e399 100644
--- a/src/com/android/documentsui/archives/ArchivesProvider.java
+++ b/src/com/android/documentsui/archives/ArchivesProvider.java
@@ -31,6 +31,7 @@
import android.os.CancellationSignal;
import android.os.ParcelFileDescriptor;
import android.provider.DocumentsContract.Document;
+import android.provider.DocumentsContract.Root;
import android.provider.DocumentsContract;
import android.provider.DocumentsProvider;
import android.support.annotation.Nullable;
@@ -59,6 +60,9 @@
public class ArchivesProvider extends DocumentsProvider {
public static final String AUTHORITY = "com.android.documentsui.archives";
+ private static final String[] DEFAULT_ROOTS_PROJECTION = new String[] {
+ Root.COLUMN_ROOT_ID, Root.COLUMN_DOCUMENT_ID, Root.COLUMN_TITLE, Root.COLUMN_FLAGS,
+ Root.COLUMN_ICON };
private static final String TAG = "ArchivesProvider";
private static final String METHOD_ACQUIRE_ARCHIVE = "acquireArchive";
private static final String METHOD_RELEASE_ARCHIVE = "releaseArchive";
@@ -91,7 +95,8 @@
@Override
public Cursor queryRoots(String[] projection) {
- throw new UnsupportedOperationException();
+ // No roots provided.
+ return new MatrixCursor(projection != null ? projection : DEFAULT_ROOTS_PROJECTION);
}
@Override
diff --git a/src/com/android/documentsui/base/DebugFlags.java b/src/com/android/documentsui/base/DebugFlags.java
index 09638bb..e131d8e 100644
--- a/src/com/android/documentsui/base/DebugFlags.java
+++ b/src/com/android/documentsui/base/DebugFlags.java
@@ -15,6 +15,11 @@
*/
package com.android.documentsui.base;
+import android.content.ContentResolver;
+import android.os.Bundle;
+
+import com.android.documentsui.queries.DebugCommandProcessor;
+
import javax.annotation.Nullable;
/**
@@ -27,6 +32,8 @@
private static String mQvPackage;
private static boolean sGestureScaleEnabled;
private static boolean sDocumentDetailsEnabled;
+ private static int sForcedPageOffset = -1;
+ private static int sForcedPageLimit = -1;
public static void setQuickViewer(@Nullable String qvPackage) {
mQvPackage = qvPackage;
@@ -51,4 +58,23 @@
public static boolean getGestureScaleEnabled() {
return sGestureScaleEnabled;
}
+
+ public static void setForcedPaging(int offset, int limit) {
+ sForcedPageOffset = offset;
+ sForcedPageLimit = limit;
+ }
+
+ public static boolean addForcedPagingArgs(Bundle queryArgs) {
+ assert(Shared.ENABLE_OMC_API_FEATURES);
+ boolean flagsAdded = false;
+ if (sForcedPageOffset >= 0) {
+ queryArgs.putInt(ContentResolver.QUERY_ARG_OFFSET, sForcedPageOffset);
+ flagsAdded |= true;
+ }
+ if (sForcedPageLimit >= 0) {
+ queryArgs.putInt(ContentResolver.QUERY_ARG_LIMIT, sForcedPageLimit);
+ flagsAdded |= true;
+ }
+ return flagsAdded;
+ }
}
diff --git a/src/com/android/documentsui/queries/DebugCommandProcessor.java b/src/com/android/documentsui/queries/DebugCommandProcessor.java
index 727d72e..ff62526 100644
--- a/src/com/android/documentsui/queries/DebugCommandProcessor.java
+++ b/src/com/android/documentsui/queries/DebugCommandProcessor.java
@@ -24,6 +24,7 @@
import com.android.documentsui.DocumentsApplication;
import com.android.documentsui.base.DebugFlags;
import com.android.documentsui.base.EventHandler;
+import com.android.documentsui.base.Shared;
import java.util.ArrayList;
import java.util.List;
@@ -42,6 +43,7 @@
mCommands.add(DebugCommandProcessor::quickViewer);
mCommands.add(DebugCommandProcessor::gestureScale);
mCommands.add(DebugCommandProcessor::docDetails);
+ mCommands.add(DebugCommandProcessor::forcePaging);
}
}
@@ -108,6 +110,36 @@
return false;
}
+ private static boolean forcePaging(String[] tokens) {
+ if (!Shared.ENABLE_OMC_API_FEATURES) {
+ Log.i(TAG, "Paging is disabled.");
+ return false;
+ }
+
+ if ("page".equals(tokens[0])) {
+ if (tokens.length >= 2) {
+ try {
+ int offset = Integer.parseInt(tokens[1]);
+ int limit = (tokens.length == 3) ? Integer.parseInt(tokens[2]) : -1;
+ DebugFlags.setForcedPaging(offset, limit);
+ Log.i(TAG, "Set forced paging to offset: " + offset + ", limit: " + limit);
+ return true;
+ } catch (NumberFormatException e) {
+ Log.w(TAG, "Command input does not contain valid numbers: "
+ + TextUtils.join(" ", tokens));
+ return false;
+ }
+ } else {
+ Log.w(TAG, "Invalid command structure: " + TextUtils.join(" ", tokens));
+ }
+ } else if ("deqv".equals(tokens[0])) {
+ Log.i(TAG, "Unset quick viewer");
+ DebugFlags.setQuickViewer(null);
+ return true;
+ }
+ return false;
+ }
+
private static final boolean asBool(String val) {
if (val == null || val.equals("0")) {
return false;
diff --git a/src/com/android/documentsui/roots/RootsCache.java b/src/com/android/documentsui/roots/RootsCache.java
index 0727bda..111a42d 100644
--- a/src/com/android/documentsui/roots/RootsCache.java
+++ b/src/com/android/documentsui/roots/RootsCache.java
@@ -42,6 +42,7 @@
import com.android.documentsui.DocumentsApplication;
import com.android.documentsui.R;
+import com.android.documentsui.archives.ArchivesProvider;
import com.android.documentsui.base.Providers;
import com.android.documentsui.base.RootInfo;
import com.android.documentsui.base.State;
@@ -73,6 +74,8 @@
private static final List<String> PERMIT_EMPTY_CACHE = new ArrayList<String>() {{
// MTP provider commonly returns no roots (if no devices are attached).
add(Providers.AUTHORITY_MTP);
+ // ArchivesProvider doesn't support any roots.
+ add(ArchivesProvider.AUTHORITY);
}};
private final Context mContext;
diff --git a/src/com/android/documentsui/sorting/SortModel.java b/src/com/android/documentsui/sorting/SortModel.java
index a5c8459..e3eb1e9 100644
--- a/src/com/android/documentsui/sorting/SortModel.java
+++ b/src/com/android/documentsui/sorting/SortModel.java
@@ -17,10 +17,14 @@
package com.android.documentsui.sorting;
import static com.android.documentsui.base.Shared.DEBUG;
+import static com.android.documentsui.base.Shared.ENABLE_OMC_API_FEATURES;
+import static com.android.documentsui.base.Shared.VERBOSE;
import android.annotation.IntDef;
import android.annotation.Nullable;
+import android.content.ContentResolver;
import android.database.Cursor;
+import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
import android.provider.DocumentsContract.Document;
@@ -29,6 +33,7 @@
import android.view.View;
import com.android.documentsui.R;
+import com.android.documentsui.base.Shared;
import com.android.documentsui.sorting.SortDimension.SortDirection;
import java.lang.annotation.Retention;
@@ -220,6 +225,15 @@
}
public Cursor sortCursor(Cursor cursor) {
+ if (ENABLE_OMC_API_FEATURES
+ && cursor.getExtras().containsKey(ContentResolver.QUERY_ARG_SORT_COLUMNS)) {
+ if (VERBOSE) Log.i(TAG, "Cursor is pre-sorted by provider. Skipping sort. Booya!");
+
+ // TODO: assert that the contents of QUERY_ARG_SORT_COLUMNS
+ // matches the sort dimension...once we're returning any pre-sorted results.
+ return cursor;
+ }
+
if (mSortedDimension != null) {
return new SortingCursorWrapper(cursor, mSortedDimension);
} else {
@@ -227,7 +241,54 @@
}
}
+ public void addQuerySortArgs(Bundle queryArgs) {
+ assert(Shared.ENABLE_OMC_API_FEATURES);
+
+ final int id = getSortedDimensionId();
+ switch (id) {
+ case SORT_DIMENSION_ID_UNKNOWN:
+ return;
+ case SortModel.SORT_DIMENSION_ID_TITLE:
+ queryArgs.putStringArray(
+ ContentResolver.QUERY_ARG_SORT_COLUMNS,
+ new String[]{ Document.COLUMN_DISPLAY_NAME });
+ break;
+ case SortModel.SORT_DIMENSION_ID_DATE:
+ queryArgs.putStringArray(
+ ContentResolver.QUERY_ARG_SORT_COLUMNS,
+ new String[]{ Document.COLUMN_LAST_MODIFIED });
+ break;
+ case SortModel.SORT_DIMENSION_ID_SIZE:
+ queryArgs.putStringArray(
+ ContentResolver.QUERY_ARG_SORT_COLUMNS,
+ new String[]{ Document.COLUMN_SIZE });
+ break;
+ default:
+ throw new IllegalStateException(
+ "Unexpected sort dimension id: " + id);
+ }
+
+ final SortDimension dimension = getDimensionById(id);
+ switch (dimension.getSortDirection()) {
+ case SortDimension.SORT_DIRECTION_ASCENDING:
+ queryArgs.putInt(
+ ContentResolver.QUERY_ARG_SORT_DIRECTION,
+ ContentResolver.QUERY_SORT_DIRECTION_ASCENDING);
+ break;
+ case SortDimension.SORT_DIRECTION_DESCENDING:
+ queryArgs.putInt(
+ ContentResolver.QUERY_ARG_SORT_DIRECTION,
+ ContentResolver.QUERY_SORT_DIRECTION_DESCENDING);
+ break;
+ default:
+ throw new IllegalStateException(
+ "Unexpected sort direction: " + dimension.getSortDirection());
+ }
+ }
+
public @Nullable String getDocumentSortQuery() {
+ assert(!Shared.ENABLE_OMC_API_FEATURES);
+
final int id = getSortedDimensionId();
final String columnName;
switch (id) {
diff --git a/tests/AndroidManifest.xml b/tests/AndroidManifest.xml
index 6f4e78b..bdc0125 100644
--- a/tests/AndroidManifest.xml
+++ b/tests/AndroidManifest.xml
@@ -17,6 +17,7 @@
<action android:name="android.content.action.DOCUMENTS_PROVIDER" />
</intent-filter>
</provider>
+
<!-- Provider that demostrates some features, like display of INFO and ERROR messages. -->
<provider
android:name="com.android.documentsui.DemoProvider"
@@ -29,6 +30,7 @@
<action android:name="android.content.action.DOCUMENTS_PROVIDER" />
</intent-filter>
</provider>
+
<!-- Provider for testing archives. -->
<provider
android:name="com.android.documentsui.archives.ResourcesProvider"
@@ -41,6 +43,19 @@
<action android:name="android.content.action.DOCUMENTS_PROVIDER" />
</intent-filter>
</provider>
+
+ <!-- Provider with support for paging. -->
+ <provider
+ android:name="com.android.documentsui.PagingProvider"
+ android:authorities="com.android.documentsui.pagingprovider"
+ android:exported="true"
+ android:grantUriPermissions="true"
+ android:permission="android.permission.MANAGE_DOCUMENTS"
+ android:enabled="true">
+ <intent-filter>
+ <action android:name="android.content.action.DOCUMENTS_PROVIDER" />
+ </intent-filter>
+ </provider>
</application>
<instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
diff --git a/tests/common/com/android/documentsui/PagingProvider.java b/tests/common/com/android/documentsui/PagingProvider.java
new file mode 100644
index 0000000..e05cec5
--- /dev/null
+++ b/tests/common/com/android/documentsui/PagingProvider.java
@@ -0,0 +1,97 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.documentsui;
+
+import android.content.ContentResolver;
+import android.database.Cursor;
+import android.database.MatrixCursor;
+import android.os.Bundle;
+import android.provider.DocumentsContract.Root;
+
+import java.io.FileNotFoundException;
+
+/**
+ * Test provider w/ support for paging, and various sub-scenarios of paging.
+ */
+public class PagingProvider extends TestRootProvider {
+
+ /**
+ * Pass test result size to inform the provider of the result size. Defaults to 1k.
+ */
+ private static final String TEST_RECORDSET_SIZE = "test-recordset-size";
+ private static final int DEFAULT_RECORDSET_SIZE = 100;
+ private static final int UNDETERMINED_RECORDSET_SIZE = -1;
+
+ private static final String ROOT_ID = "paging-root";
+ private static final String ROOT_DOC_ID = "root0";
+ private static final int ROOT_FLAGS = Root.FLAG_SUPPORTS_SEARCH | Root.FLAG_SUPPORTS_IS_CHILD;
+
+ public PagingProvider() {
+ super("Paging Root", ROOT_ID, ROOT_FLAGS, ROOT_DOC_ID);
+ }
+
+ @Override
+ public Cursor queryDocument(String documentId, String[] projection)
+ throws FileNotFoundException {
+ MatrixCursor c = createDocCursor(projection);
+ addFolder(c, documentId);
+ return c;
+ }
+
+ @Override
+ public Cursor queryChildDocuments(
+ String parentDocumentId, String[] projection, String sortOrder)
+ throws FileNotFoundException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Cursor queryChildDocuments(
+ String parentDocumentId, String[] projection, Bundle queryArgs)
+ throws FileNotFoundException {
+
+ // TODO: Content notification.
+
+ MatrixCursor c = createDocCursor(projection);
+ Bundle extras = c.getExtras();
+
+ int offset = queryArgs.getInt(ContentResolver.QUERY_ARG_OFFSET, 0);
+ int limit = queryArgs.getInt(ContentResolver.QUERY_ARG_LIMIT, Integer.MIN_VALUE);
+ int recordsetSize = queryArgs.getInt(TEST_RECORDSET_SIZE, DEFAULT_RECORDSET_SIZE);
+
+ // Can be -1 (magic unknown), or 0 or more, but not less than -1.
+ assert(recordsetSize > -2);
+
+ // Client may force override the recordset size to -1 which is MAGIC unknown value.
+ // Even if, we still need some finite number against to work.
+ int size = (recordsetSize == UNDETERMINED_RECORDSET_SIZE)
+ ? DEFAULT_RECORDSET_SIZE
+ : recordsetSize;
+
+ // Calculate the number of items to include in the cursor.
+ int numItems = (limit >= 0)
+ ? Math.min(limit, size - offset)
+ : size - offset;
+
+ assert(offset >= 0);
+ assert(numItems >= 0);
+ for (int i = 0; i < numItems; i++) {
+ addFile(c, String.format("%05d", offset + i));
+ }
+ extras.putInt(ContentResolver.QUERY_RESULT_SIZE, recordsetSize);
+ return c;
+ }
+}
diff --git a/tests/common/com/android/documentsui/bots/Bots.java b/tests/common/com/android/documentsui/bots/Bots.java
index bfa7743..57f5cfa 100644
--- a/tests/common/com/android/documentsui/bots/Bots.java
+++ b/tests/common/com/android/documentsui/bots/Bots.java
@@ -53,7 +53,7 @@
sortHeader = new SortHeaderBot(device, context, TIMEOUT);
keyboard = new KeyboardBot(device, context, TIMEOUT);
search = new SearchBot(device, context, TIMEOUT);
- gesture = new GestureBot(device, context, TIMEOUT);
+ gesture = new GestureBot(device, automation, context, TIMEOUT);
menu = new MenuBot(device, context, TIMEOUT);
}
diff --git a/tests/common/com/android/documentsui/bots/GestureBot.java b/tests/common/com/android/documentsui/bots/GestureBot.java
index a6f3b77..e0ca8b6 100644
--- a/tests/common/com/android/documentsui/bots/GestureBot.java
+++ b/tests/common/com/android/documentsui/bots/GestureBot.java
@@ -16,15 +16,20 @@
package com.android.documentsui.bots;
+import android.app.UiAutomation;
import android.content.Context;
import android.graphics.Point;
import android.graphics.Rect;
+import android.os.SystemClock;
import android.support.test.uiautomator.Configurator;
import android.support.test.uiautomator.UiDevice;
import android.support.test.uiautomator.UiObject;
import android.support.test.uiautomator.UiObjectNotFoundException;
import android.support.test.uiautomator.UiSelector;
+import android.view.InputDevice;
import android.view.MotionEvent;
+import android.view.MotionEvent.PointerCoords;
+import android.view.MotionEvent.PointerProperties;
/**
* A test helper class that provides support for controlling directory list
@@ -37,9 +42,14 @@
private static final int TRAVELING_STEPS = 20;
private static final int BAND_SELECTION_DEFAULT_STEPS = 100;
private static final int STEPS_INBETWEEN_POINTS = 2;
+ // Inserted after each motion event injection.
+ private static final int MOTION_EVENT_INJECTION_DELAY_MILLIS = 5;
+ private final UiAutomation mAutomation;
+ private long mDownTime = 0;
- public GestureBot(UiDevice device, Context context, int timeout) {
+ public GestureBot(UiDevice device, UiAutomation automation, Context context, int timeout) {
super(device, context, timeout);
+ mAutomation = automation;
}
public void gestureSelectFiles(String startLabel, String endLabel) throws Exception {
@@ -73,7 +83,7 @@
public void bandSelection(Point start, Point end, int steps) throws Exception {
int toolType = Configurator.getInstance().getToolType();
Configurator.getInstance().setToolType(MotionEvent.TOOL_TYPE_MOUSE);
- mDevice.swipe(start.x, start.y, end.x, end.y, steps);
+ swipe(start.x, start.y, end.x, end.y, steps, MotionEvent.BUTTON_PRIMARY);
Configurator.getInstance().setToolType(toolType);
}
@@ -87,4 +97,69 @@
return mDevice.findObject(docList.childSelector(new UiSelector().text(label)));
}
+
+ private void swipe(int downX, int downY, int upX, int upY, int steps, int button) {
+ int swipeSteps = steps;
+ double xStep = 0;
+ double yStep = 0;
+
+ // avoid a divide by zero
+ if(swipeSteps == 0)
+ swipeSteps = 1;
+
+ xStep = ((double)(upX - downX)) / swipeSteps;
+ yStep = ((double)(upY - downY)) / swipeSteps;
+
+ // first touch starts exactly at the point requested
+ touchDown(downX, downY, button);
+ for(int i = 1; i < swipeSteps; i++) {
+ touchMove(downX + (int)(xStep * i), downY + (int)(yStep * i), button);
+ // set some known constant delay between steps as without it this
+ // become completely dependent on the speed of the system and results
+ // may vary on different devices. This guarantees at minimum we have
+ // a preset delay.
+ SystemClock.sleep(MOTION_EVENT_INJECTION_DELAY_MILLIS);
+ }
+ touchUp(upX, upY);
+ }
+
+ private boolean touchDown(int x, int y, int button) {
+ long mDownTime = SystemClock.uptimeMillis();
+ MotionEvent event = getMotionEvent(mDownTime, mDownTime, MotionEvent.ACTION_DOWN, button, x,
+ y);
+ return mAutomation.injectInputEvent(event, true);
+ }
+
+ private boolean touchUp(int x, int y) {
+ final long eventTime = SystemClock.uptimeMillis();
+ MotionEvent event = getMotionEvent(mDownTime, eventTime, MotionEvent.ACTION_UP, 0, x, y);
+ mDownTime = 0;
+ return mAutomation.injectInputEvent(event, true);
+ }
+
+ private boolean touchMove(int x, int y, int button) {
+ final long eventTime = SystemClock.uptimeMillis();
+ MotionEvent event = getMotionEvent(mDownTime, eventTime, MotionEvent.ACTION_MOVE, button, x,
+ y);
+ return mAutomation.injectInputEvent(event, true);
+ }
+
+ /** Helper function to obtain a MotionEvent. */
+ private static MotionEvent getMotionEvent(long downTime, long eventTime, int action, int button,
+ float x, float y) {
+
+ PointerProperties properties = new PointerProperties();
+ properties.id = 0;
+ properties.toolType = Configurator.getInstance().getToolType();
+
+ PointerCoords coords = new PointerCoords();
+ coords.pressure = 1;
+ coords.size = 1;
+ coords.x = x;
+ coords.y = y;
+
+ return MotionEvent.obtain(downTime, eventTime, action, 1,
+ new PointerProperties[] { properties }, new PointerCoords[] { coords },
+ 0, button, 1.0f, 1.0f, 0, 0, InputDevice.SOURCE_TOUCHSCREEN, 0);
+ }
}
diff --git a/tests/unit/com/android/documentsui/archives/ArchivesProviderTest.java b/tests/unit/com/android/documentsui/archives/ArchivesProviderTest.java
index 7bf2aca..4bbb896 100644
--- a/tests/unit/com/android/documentsui/archives/ArchivesProviderTest.java
+++ b/tests/unit/com/android/documentsui/archives/ArchivesProviderTest.java
@@ -68,6 +68,17 @@
super.tearDown();
}
+ public void testQueryRoots() throws InterruptedException {
+ final ContentResolver resolver = getContext().getContentResolver();
+ final Uri rootsUri = DocumentsContract.buildRootsUri(ArchivesProvider.AUTHORITY);
+ try (final ContentProviderClient client = resolver.acquireUnstableContentProviderClient(
+ rootsUri)) {
+ final Cursor cursor = resolver.query(rootsUri, null, null, null, null, null);
+ assertNotNull("Cursor must not be null.", cursor);
+ assertEquals(0, cursor.getCount());
+ }
+ }
+
public void testOpen_Success() throws InterruptedException {
final Uri sourceUri = DocumentsContract.buildDocumentUri(
ResourcesProvider.AUTHORITY, "archive.zip");