diff options
24 files changed, 730 insertions, 187 deletions
diff --git a/core/java/android/view/BatchedInputEventReceiver.java b/core/java/android/view/BatchedInputEventReceiver.java new file mode 100644 index 000000000000..b1d28e000bc8 --- /dev/null +++ b/core/java/android/view/BatchedInputEventReceiver.java @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2015 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 android.view; + +import android.os.Looper; + +/** + * Similar to {@link InputEventReceiver}, but batches events to vsync boundaries when possible. + * @hide + */ +public class BatchedInputEventReceiver extends InputEventReceiver { + Choreographer mChoreographer; + private boolean mBatchedInputScheduled; + + public BatchedInputEventReceiver( + InputChannel inputChannel, Looper looper, Choreographer choreographer) { + super(inputChannel, looper); + mChoreographer = choreographer; + } + + @Override + public void onBatchedInputEventPending() { + scheduleBatchedInput(); + } + + @Override + public void dispose() { + unscheduleBatchedInput(); + super.dispose(); + } + + void doConsumeBatchedInput(long frameTimeNanos) { + if (mBatchedInputScheduled) { + mBatchedInputScheduled = false; + if (consumeBatchedInputEvents(frameTimeNanos) && frameTimeNanos != -1) { + // If we consumed a batch here, we want to go ahead and schedule the + // consumption of batched input events on the next frame. Otherwise, we would + // wait until we have more input events pending and might get starved by other + // things occurring in the process. If the frame time is -1, however, then + // we're in a non-batching mode, so there's no need to schedule this. + scheduleBatchedInput(); + } + } + } + + private void scheduleBatchedInput() { + if (!mBatchedInputScheduled) { + mBatchedInputScheduled = true; + mChoreographer.postCallback(Choreographer.CALLBACK_INPUT, mBatchedInputRunnable, null); + } + } + + private void unscheduleBatchedInput() { + if (mBatchedInputScheduled) { + mBatchedInputScheduled = false; + mChoreographer.removeCallbacks( + Choreographer.CALLBACK_INPUT, mBatchedInputRunnable, null); + } + } + + private final class BatchedInputRunnable implements Runnable { + @Override + public void run() { + doConsumeBatchedInput(mChoreographer.getFrameTimeNanos()); + } + } + private final BatchedInputRunnable mBatchedInputRunnable = new BatchedInputRunnable(); +} diff --git a/core/tests/coretests/src/android/widget/TextViewActivityTest.java b/core/tests/coretests/src/android/widget/TextViewActivityTest.java index b37688f0e212..ce9ae02c9cec 100644 --- a/core/tests/coretests/src/android/widget/TextViewActivityTest.java +++ b/core/tests/coretests/src/android/widget/TextViewActivityTest.java @@ -17,6 +17,9 @@ package android.widget; import static android.widget.espresso.TextViewActions.clickOnTextAtIndex; +import static android.widget.espresso.TextViewActions.doubleTapAndDragOnText; +import static android.widget.espresso.TextViewActions.longPressAndDragOnText; +import static android.widget.espresso.TextViewAssertions.hasSelection; import static android.support.test.espresso.Espresso.onView; import static android.support.test.espresso.action.ViewActions.click; import static android.support.test.espresso.action.ViewActions.pressKey; @@ -63,4 +66,28 @@ public class TextViewActivityTest extends ActivityInstrumentationTestCase2<TextV onView(withId(R.id.textview)).perform(pressKey(KeyEvent.KEYCODE_FORWARD_DEL)); onView(withId(R.id.textview)).check(matches(withText("Hello orld!"))); } + + @SmallTest + public void testLongPressAndDragToSelect() throws Exception { + getActivity(); + + final String helloWorld = "Hello little handsome boy!"; + onView(withId(R.id.textview)).perform(typeTextIntoFocusedView(helloWorld)); + onView(withId(R.id.textview)).perform( + longPressAndDragOnText(helloWorld.indexOf("little"), helloWorld.indexOf(" boy!"))); + + onView(withId(R.id.textview)).check(hasSelection("little handsome")); + } + + @SmallTest + public void testDoubleTapAndDragToSelect() throws Exception { + getActivity(); + + final String helloWorld = "Hello young beautiful girl!"; + onView(withId(R.id.textview)).perform(typeTextIntoFocusedView(helloWorld)); + onView(withId(R.id.textview)).perform( + doubleTapAndDragOnText(helloWorld.indexOf("young"), helloWorld.indexOf(" girl!"))); + + onView(withId(R.id.textview)).check(hasSelection("young beautiful")); + } } diff --git a/core/tests/coretests/src/android/widget/espresso/DragOnTextViewActions.java b/core/tests/coretests/src/android/widget/espresso/DragOnTextViewActions.java new file mode 100644 index 000000000000..a0cd848a53f5 --- /dev/null +++ b/core/tests/coretests/src/android/widget/espresso/DragOnTextViewActions.java @@ -0,0 +1,281 @@ +/* + * Copyright (C) 2015 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 android.widget.espresso; + +import static android.support.test.espresso.matcher.ViewMatchers.isAssignableFrom; +import static android.support.test.espresso.matcher.ViewMatchers.isCompletelyDisplayed; +import static com.android.internal.util.Preconditions.checkNotNull; +import static org.hamcrest.Matchers.allOf; + +import android.annotation.Nullable; +import android.os.SystemClock; +import android.support.test.espresso.UiController; +import android.support.test.espresso.PerformException; +import android.support.test.espresso.ViewAction; +import android.support.test.espresso.action.CoordinatesProvider; +import android.support.test.espresso.action.GeneralClickAction; +import android.support.test.espresso.action.MotionEvents; +import android.support.test.espresso.action.PrecisionDescriber; +import android.support.test.espresso.action.Press; +import android.support.test.espresso.action.Swiper; +import android.support.test.espresso.action.Tap; +import android.support.test.espresso.util.HumanReadables; +import android.util.Log; +import android.view.MotionEvent; +import android.view.View; +import android.view.ViewConfiguration; +import android.widget.TextView; +import org.hamcrest.Matcher; + + +/** + * Drags on text in a TextView using touch events.<br> + * <br> + * View constraints: + * <ul> + * <li>must be a TextView displayed on screen + * <ul> + */ +public final class DragOnTextViewActions implements ViewAction { + + /** + * Executes different "drag on text" types to given positions. + */ + public enum Drag implements Swiper { + + /** + * Starts a drag with a long-press. + */ + LONG_PRESS { + private DownMotionPerformer downMotion = new DownMotionPerformer() { + @Override + public MotionEvent perform( + UiController uiController, float[] coordinates, float[] precision) { + MotionEvent downEvent = MotionEvents.sendDown( + uiController, coordinates, precision) + .down; + // Duration before a press turns into a long press. + // Factor 1.5 is needed, otherwise a long press is not safely detected. + // See android.test.TouchUtils longClickView + long longPressTimeout = (long) (ViewConfiguration.getLongPressTimeout() * 1.5f); + uiController.loopMainThreadForAtLeast(longPressTimeout); + return downEvent; + } + }; + + @Override + public Status sendSwipe( + UiController uiController, + float[] startCoordinates, float[] endCoordinates, float[] precision) { + return sendLinearDrag( + uiController, downMotion, startCoordinates, endCoordinates, precision); + } + + @Override + public String toString() { + return "long press and drag to select"; + } + }, + + /** + * Starts a drag with a double-tap. + */ + DOUBLE_TAP { + private DownMotionPerformer downMotion = new DownMotionPerformer() { + @Override + @Nullable + public MotionEvent perform( + UiController uiController, float[] coordinates, float[] precision) { + MotionEvent downEvent = MotionEvents.sendDown( + uiController, coordinates, precision) + .down; + try { + if (!MotionEvents.sendUp(uiController, downEvent)) { + String logMessage = "Injection of up event as part of the double tap " + + "failed. Sending cancel event."; + Log.d(TAG, logMessage); + MotionEvents.sendCancel(uiController, downEvent); + return null; + } + + long doubleTapMinimumTimeout = ViewConfiguration.getDoubleTapMinTime(); + uiController.loopMainThreadForAtLeast(doubleTapMinimumTimeout); + + return MotionEvents.sendDown(uiController, coordinates, precision).down; + } finally { + downEvent.recycle(); + } + } + }; + + @Override + public Status sendSwipe( + UiController uiController, + float[] startCoordinates, float[] endCoordinates, float[] precision) { + return sendLinearDrag( + uiController, downMotion, startCoordinates, endCoordinates, precision); + } + + @Override + public String toString() { + return "double-tap and drag to select"; + } + }; + + private static final String TAG = Drag.class.getSimpleName(); + + /** The number of move events to send for each drag. */ + private static final int DRAG_STEP_COUNT = 10; + + /** Length of time a drag should last for, in milliseconds. */ + private static final int DRAG_DURATION = 1500; + + private static Status sendLinearDrag( + UiController uiController, DownMotionPerformer downMotion, + float[] startCoordinates, float[] endCoordinates, float[] precision) { + float[][] steps = interpolate(startCoordinates, endCoordinates); + final int delayBetweenMovements = DRAG_DURATION / steps.length; + + MotionEvent downEvent = downMotion.perform(uiController, startCoordinates, precision); + if (downEvent == null) { + return Status.FAILURE; + } + + try { + for (int i = 0; i < steps.length; i++) { + if (!MotionEvents.sendMovement(uiController, downEvent, steps[i])) { + String logMessage = "Injection of move event as part of the drag failed. " + + "Sending cancel event."; + Log.e(TAG, logMessage); + MotionEvents.sendCancel(uiController, downEvent); + return Status.FAILURE; + } + + long desiredTime = downEvent.getDownTime() + delayBetweenMovements * i; + long timeUntilDesired = desiredTime - SystemClock.uptimeMillis(); + if (timeUntilDesired > 10) { + // If the wait time until the next event isn't long enough, skip the wait + // and execute the next event. + uiController.loopMainThreadForAtLeast(timeUntilDesired); + } + } + + if (!MotionEvents.sendUp(uiController, downEvent, endCoordinates)) { + String logMessage = "Injection of up event as part of the drag failed. " + + "Sending cancel event."; + Log.e(TAG, logMessage); + MotionEvents.sendCancel(uiController, downEvent); + return Status.FAILURE; + } + } finally { + downEvent.recycle(); + } + return Status.SUCCESS; + } + + private static float[][] interpolate(float[] start, float[] end) { + float[][] res = new float[DRAG_STEP_COUNT][2]; + + for (int i = 1; i < DRAG_STEP_COUNT + 1; i++) { + res[i - 1][0] = start[0] + (end[0] - start[0]) * i / (DRAG_STEP_COUNT + 2f); + res[i - 1][1] = start[1] + (end[1] - start[1]) * i / (DRAG_STEP_COUNT + 2f); + } + + return res; + } + } + + /** + * Interface to implement different "down motion" types. + */ + private interface DownMotionPerformer { + /** + * Performs and returns a down motion. + * + * @param uiController a UiController to use to send MotionEvents to the screen. + * @param coordinates a float[] with x and y values of center of the tap. + * @param precision a float[] with x and y values of precision of the tap. + * @return the down motion event or null if the down motion event failed. + */ + @Nullable + MotionEvent perform(UiController uiController, float[] coordinates, float[] precision); + } + + private final Swiper mDragger; + private final CoordinatesProvider mStartCoordinatesProvider; + private final CoordinatesProvider mEndCoordinatesProvider; + private final PrecisionDescriber mPrecisionDescriber; + + public DragOnTextViewActions( + Swiper dragger, + CoordinatesProvider startCoordinatesProvider, + CoordinatesProvider endCoordinatesProvider, + PrecisionDescriber precisionDescriber) { + mDragger = checkNotNull(dragger); + mStartCoordinatesProvider = checkNotNull(startCoordinatesProvider); + mEndCoordinatesProvider = checkNotNull(endCoordinatesProvider); + mPrecisionDescriber = checkNotNull(precisionDescriber); + } + + @Override + @SuppressWarnings("unchecked") + public Matcher<View> getConstraints() { + return allOf(isCompletelyDisplayed(), isAssignableFrom(TextView.class)); + } + + @Override + public void perform(UiController uiController, View view) { + checkNotNull(uiController); + checkNotNull(view); + + float[] startCoordinates = mStartCoordinatesProvider.calculateCoordinates(view); + float[] endCoordinates = mEndCoordinatesProvider.calculateCoordinates(view); + float[] precision = mPrecisionDescriber.describePrecision(); + + Swiper.Status status; + + try { + status = mDragger.sendSwipe( + uiController, startCoordinates, endCoordinates, precision); + } catch (RuntimeException re) { + throw new PerformException.Builder() + .withActionDescription(this.getDescription()) + .withViewDescription(HumanReadables.describe(view)) + .withCause(re) + .build(); + } + + int duration = ViewConfiguration.getPressedStateDuration(); + // ensures that all work enqueued to process the swipe has been run. + if (duration > 0) { + uiController.loopMainThreadForAtLeast(duration); + } + + if (status == Swiper.Status.FAILURE) { + throw new PerformException.Builder() + .withActionDescription(getDescription()) + .withViewDescription(HumanReadables.describe(view)) + .withCause(new RuntimeException(getDescription() + " failed")) + .build(); + } + } + + @Override + public String getDescription() { + return mDragger.toString(); + } +} diff --git a/core/tests/coretests/src/android/widget/espresso/TextViewActions.java b/core/tests/coretests/src/android/widget/espresso/TextViewActions.java index 425dccdf4936..7e4735b298fe 100644 --- a/core/tests/coretests/src/android/widget/espresso/TextViewActions.java +++ b/core/tests/coretests/src/android/widget/espresso/TextViewActions.java @@ -18,7 +18,6 @@ package android.widget.espresso; import static android.support.test.espresso.action.ViewActions.actionWithAssertions; -import android.content.res.Resources; import android.support.test.espresso.PerformException; import android.support.test.espresso.ViewAction; import android.support.test.espresso.action.CoordinatesProvider; @@ -27,8 +26,6 @@ import android.support.test.espresso.action.Press; import android.support.test.espresso.action.Tap; import android.support.test.espresso.util.HumanReadables; import android.text.Layout; -import android.util.DisplayMetrics; -import android.util.TypedValue; import android.view.View; import android.widget.TextView; @@ -40,12 +37,14 @@ public final class TextViewActions { private TextViewActions() {} /** - * Returns an action that clicks on text at an index on the text view.<br> + * Returns an action that clicks on text at an index on the TextView.<br> * <br> * View constraints: * <ul> - * <li>must be a text view displayed on screen + * <li>must be a TextView displayed on screen * <ul> + * + * @param index The index of the TextView's text to click on. */ public static ViewAction clickOnTextAtIndex(int index) { return actionWithAssertions( @@ -53,6 +52,48 @@ public final class TextViewActions { } /** + * Returns an action that long presses then drags on text from startIndex to endIndex on the + * TextView.<br> + * <br> + * View constraints: + * <ul> + * <li>must be a TextView displayed on screen + * <ul> + * + * @param startIndex The index of the TextView's text to start a drag from + * @param endIndex The index of the TextView's text to end the drag at + */ + public static ViewAction longPressAndDragOnText(int startIndex, int endIndex) { + return actionWithAssertions( + new DragOnTextViewActions( + DragOnTextViewActions.Drag.LONG_PRESS, + new TextCoordinates(startIndex), + new TextCoordinates(endIndex), + Press.FINGER)); + } + + /** + * Returns an action that double taps then drags on text from startIndex to endIndex on the + * TextView.<br> + * <br> + * View constraints: + * <ul> + * <li>must be a TextView displayed on screen + * <ul> + * + * @param startIndex The index of the TextView's text to start a drag from + * @param endIndex The index of the TextView's text to end the drag at + */ + public static ViewAction doubleTapAndDragOnText(int startIndex, int endIndex) { + return actionWithAssertions( + new DragOnTextViewActions( + DragOnTextViewActions.Drag.DOUBLE_TAP, + new TextCoordinates(startIndex), + new TextCoordinates(endIndex), + Press.FINGER)); + } + + /** * A provider of the x, y coordinates of the text at the specified index in a text view. */ private static final class TextCoordinates implements CoordinatesProvider { diff --git a/core/tests/coretests/src/android/widget/espresso/TextViewAssertions.java b/core/tests/coretests/src/android/widget/espresso/TextViewAssertions.java new file mode 100644 index 000000000000..dce3182693a6 --- /dev/null +++ b/core/tests/coretests/src/android/widget/espresso/TextViewAssertions.java @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2015 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 android.widget.espresso; + +import static android.support.test.espresso.matcher.ViewMatchers.assertThat; +import static com.android.internal.util.Preconditions.checkNotNull; +import static org.hamcrest.Matchers.is; + +import android.support.test.espresso.NoMatchingViewException; +import android.support.test.espresso.ViewAssertion; +import android.view.View; +import android.widget.TextView; + +import junit.framework.AssertionFailedError; +import org.hamcrest.Matcher; + +/** + * A collection of assertions on a {@link android.widget.TextView}. + */ +public final class TextViewAssertions { + + private TextViewAssertions() {} + + /** + * Returns a {@link ViewAssertion} that asserts that the text view has a specified + * selection.<br> + * <br> + * View constraints: + * <ul> + * <li>must be a text view displayed on screen + * <ul> + * + * @param selection The expected selection. + */ + public static ViewAssertion hasSelection(String selection) { + return new TextSelectionAssertion(is(selection)); + } + + /** + * Returns a {@link ViewAssertion} that asserts that the text view has a specified + * selection.<br> + * <br> + * View constraints: + * <ul> + * <li>must be a text view displayed on screen + * <ul> + * + * @param selection A matcher representing the expected selection. + */ + public static ViewAssertion hasSelection(Matcher<String> selection) { + return new TextSelectionAssertion(selection); + } + + /** + * A {@link ViewAssertion} to check the selected text in a {@link TextView}. + */ + private static final class TextSelectionAssertion implements ViewAssertion { + + private final Matcher<String> mSelection; + + public TextSelectionAssertion(Matcher<String> selection) { + mSelection = checkNotNull(selection); + } + + @Override + public void check(View view, NoMatchingViewException exception) { + if (view instanceof TextView) { + TextView textView = (TextView) view; + int selectionStart = textView.getSelectionStart(); + int selectionEnd = textView.getSelectionEnd(); + try { + String selectedText = textView.getText() + .subSequence(selectionStart, selectionEnd) + .toString(); + assertThat(selectedText, mSelection); + } catch (IndexOutOfBoundsException e) { + throw new AssertionFailedError(e.getMessage()); + } + } else { + throw new AssertionFailedError("TextView not found"); + } + } + } +} diff --git a/packages/DocumentsUI/src/com/android/documentsui/BaseActivity.java b/packages/DocumentsUI/src/com/android/documentsui/BaseActivity.java index 1585908e5639..c8ec4dc2c510 100644 --- a/packages/DocumentsUI/src/com/android/documentsui/BaseActivity.java +++ b/packages/DocumentsUI/src/com/android/documentsui/BaseActivity.java @@ -33,14 +33,11 @@ import android.database.Cursor; import android.net.Uri; import android.os.AsyncTask; import android.os.Bundle; -import android.os.Parcel; -import android.os.Parcelable; import android.provider.DocumentsContract; import android.provider.DocumentsContract.Root; import android.support.annotation.LayoutRes; import android.support.annotation.Nullable; import android.util.Log; -import android.util.SparseArray; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; @@ -67,7 +64,6 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.util.ArrayList; import java.util.Collection; -import java.util.HashMap; import java.util.List; import java.util.concurrent.Executor; @@ -367,129 +363,6 @@ abstract class BaseActivity extends Activity { public static String EXTRA_DIRECTORY_COPY = "com.android.documentsui.DIRECTORY_COPY"; } - public static class State implements android.os.Parcelable { - public int action; - public String[] acceptMimes; - - /** Explicit user choice */ - public int userMode = MODE_UNKNOWN; - /** Derived after loader */ - public int derivedMode = MODE_LIST; - - /** Explicit user choice */ - public int userSortOrder = SORT_ORDER_UNKNOWN; - /** Derived after loader */ - public int derivedSortOrder = SORT_ORDER_DISPLAY_NAME; - - public boolean allowMultiple; - public boolean forceSize ; - public boolean showSize; - public boolean localOnly ; - public boolean forceAdvanced ; - public boolean showAdvanced ; - public boolean stackTouched ; - public boolean restored ; - public boolean directoryCopy ; - /** Transfer mode for file copy/move operations. */ - public int transferMode; - - /** Current user navigation stack; empty implies recents. */ - public DocumentStack stack = new DocumentStack(); - /** Currently active search, overriding any stack. */ - public String currentSearch; - - /** Instance state for every shown directory */ - public HashMap<String, SparseArray<Parcelable>> dirState = new HashMap<>(); - - /** Currently copying file */ - public List<DocumentInfo> selectedDocumentsForCopy = new ArrayList<DocumentInfo>(); - - /** Name of the package that started DocsUI */ - public List<String> excludedAuthorities = new ArrayList<>(); - - public static final int ACTION_OPEN = 1; - public static final int ACTION_CREATE = 2; - public static final int ACTION_GET_CONTENT = 3; - public static final int ACTION_OPEN_TREE = 4; - public static final int ACTION_MANAGE = 5; - public static final int ACTION_BROWSE = 6; - public static final int ACTION_OPEN_COPY_DESTINATION = 8; - - public static final int MODE_UNKNOWN = 0; - public static final int MODE_LIST = 1; - public static final int MODE_GRID = 2; - - public static final int SORT_ORDER_UNKNOWN = 0; - public static final int SORT_ORDER_DISPLAY_NAME = 1; - public static final int SORT_ORDER_LAST_MODIFIED = 2; - public static final int SORT_ORDER_SIZE = 3; - - public void initAcceptMimes(Intent intent) { - if (intent.hasExtra(Intent.EXTRA_MIME_TYPES)) { - acceptMimes = intent.getStringArrayExtra(Intent.EXTRA_MIME_TYPES); - } else { - String glob = intent.getType(); - acceptMimes = new String[] { glob != null ? glob : "*/*" }; - } - } - - @Override - public int describeContents() { - return 0; - } - - @Override - public void writeToParcel(Parcel out, int flags) { - out.writeInt(action); - out.writeInt(userMode); - out.writeStringArray(acceptMimes); - out.writeInt(userSortOrder); - out.writeInt(allowMultiple ? 1 : 0); - out.writeInt(forceSize ? 1 : 0); - out.writeInt(showSize ? 1 : 0); - out.writeInt(localOnly ? 1 : 0); - out.writeInt(forceAdvanced ? 1 : 0); - out.writeInt(showAdvanced ? 1 : 0); - out.writeInt(stackTouched ? 1 : 0); - out.writeInt(restored ? 1 : 0); - DurableUtils.writeToParcel(out, stack); - out.writeString(currentSearch); - out.writeMap(dirState); - out.writeList(selectedDocumentsForCopy); - out.writeList(excludedAuthorities); - } - - public static final Creator<State> CREATOR = new Creator<State>() { - @Override - public State createFromParcel(Parcel in) { - final State state = new State(); - state.action = in.readInt(); - state.userMode = in.readInt(); - state.acceptMimes = in.readStringArray(); - state.userSortOrder = in.readInt(); - state.allowMultiple = in.readInt() != 0; - state.forceSize = in.readInt() != 0; - state.showSize = in.readInt() != 0; - state.localOnly = in.readInt() != 0; - state.forceAdvanced = in.readInt() != 0; - state.showAdvanced = in.readInt() != 0; - state.stackTouched = in.readInt() != 0; - state.restored = in.readInt() != 0; - DurableUtils.readFromParcel(in, state.stack); - state.currentSearch = in.readString(); - in.readMap(state.dirState, null); - in.readList(state.selectedDocumentsForCopy, null); - in.readList(state.excludedAuthorities, null); - return state; - } - - @Override - public State[] newArray(int size) { - return new State[size]; - } - }; - } - void setDisplayAdvancedDevices(boolean display) { State state = getDisplayState(); LocalPreferences.setDisplayAdvancedDevices(this, display); diff --git a/packages/DocumentsUI/src/com/android/documentsui/CopyService.java b/packages/DocumentsUI/src/com/android/documentsui/CopyService.java index f8ec8f114313..f1492dc7b185 100644 --- a/packages/DocumentsUI/src/com/android/documentsui/CopyService.java +++ b/packages/DocumentsUI/src/com/android/documentsui/CopyService.java @@ -16,6 +16,7 @@ package com.android.documentsui; +import static com.android.documentsui.Shared.DEBUG; import static com.android.documentsui.model.DocumentInfo.getCursorLong; import static com.android.documentsui.model.DocumentInfo.getCursorString; @@ -56,7 +57,6 @@ import java.util.Objects; public class CopyService extends IntentService { public static final String TAG = "CopyService"; - public static final boolean DEBUG = false; private static final String EXTRA_CANCEL = "com.android.documentsui.CANCEL"; public static final String EXTRA_SRC_LIST = "com.android.documentsui.SRC_LIST"; diff --git a/packages/DocumentsUI/src/com/android/documentsui/DirectoryFragment.java b/packages/DocumentsUI/src/com/android/documentsui/DirectoryFragment.java index 407601b3ee66..5eacf2132a3c 100644 --- a/packages/DocumentsUI/src/com/android/documentsui/DirectoryFragment.java +++ b/packages/DocumentsUI/src/com/android/documentsui/DirectoryFragment.java @@ -16,14 +16,15 @@ package com.android.documentsui; -import static com.android.documentsui.BaseActivity.State.ACTION_BROWSE; -import static com.android.documentsui.BaseActivity.State.ACTION_CREATE; -import static com.android.documentsui.BaseActivity.State.ACTION_MANAGE; -import static com.android.documentsui.BaseActivity.State.MODE_GRID; -import static com.android.documentsui.BaseActivity.State.MODE_LIST; -import static com.android.documentsui.BaseActivity.State.MODE_UNKNOWN; -import static com.android.documentsui.BaseActivity.State.SORT_ORDER_UNKNOWN; +import static com.android.documentsui.Shared.DEBUG; import static com.android.documentsui.Shared.TAG; +import static com.android.documentsui.State.ACTION_BROWSE; +import static com.android.documentsui.State.ACTION_CREATE; +import static com.android.documentsui.State.ACTION_MANAGE; +import static com.android.documentsui.State.MODE_GRID; +import static com.android.documentsui.State.MODE_LIST; +import static com.android.documentsui.State.MODE_UNKNOWN; +import static com.android.documentsui.State.SORT_ORDER_UNKNOWN; import static com.android.documentsui.model.DocumentInfo.getCursorInt; import static com.android.documentsui.model.DocumentInfo.getCursorLong; import static com.android.documentsui.model.DocumentInfo.getCursorString; @@ -93,7 +94,6 @@ import android.widget.TextView; import android.widget.Toast; import com.android.documentsui.BaseActivity.DocumentContext; -import com.android.documentsui.BaseActivity.State; import com.android.documentsui.MultiSelectManager.Selection; import com.android.documentsui.ProviderExecutor.Preemptable; import com.android.documentsui.RecentsProvider.StateColumns; @@ -124,7 +124,6 @@ public class DirectoryFragment extends Fragment { public static final int REQUEST_COPY_DESTINATION = 1; private static final int LOADER_ID = 42; - private static final boolean DEBUG = false; private static final boolean DEBUG_ENABLE_DND = false; private static final String EXTRA_TYPE = "type"; diff --git a/packages/DocumentsUI/src/com/android/documentsui/DirectoryLoader.java b/packages/DocumentsUI/src/com/android/documentsui/DirectoryLoader.java index 0edb2413b0ca..bb82b386aa12 100644 --- a/packages/DocumentsUI/src/com/android/documentsui/DirectoryLoader.java +++ b/packages/DocumentsUI/src/com/android/documentsui/DirectoryLoader.java @@ -16,12 +16,12 @@ package com.android.documentsui; -import static com.android.documentsui.BaseActivity.State.MODE_UNKNOWN; -import static com.android.documentsui.BaseActivity.State.SORT_ORDER_DISPLAY_NAME; -import static com.android.documentsui.BaseActivity.State.SORT_ORDER_LAST_MODIFIED; -import static com.android.documentsui.BaseActivity.State.SORT_ORDER_SIZE; -import static com.android.documentsui.BaseActivity.State.SORT_ORDER_UNKNOWN; import static com.android.documentsui.Shared.TAG; +import static com.android.documentsui.State.MODE_UNKNOWN; +import static com.android.documentsui.State.SORT_ORDER_DISPLAY_NAME; +import static com.android.documentsui.State.SORT_ORDER_LAST_MODIFIED; +import static com.android.documentsui.State.SORT_ORDER_SIZE; +import static com.android.documentsui.State.SORT_ORDER_UNKNOWN; import static com.android.documentsui.model.DocumentInfo.getCursorInt; import android.content.AsyncTaskLoader; @@ -37,7 +37,6 @@ import android.provider.DocumentsContract; import android.provider.DocumentsContract.Document; import android.util.Log; -import com.android.documentsui.BaseActivity.State; import com.android.documentsui.RecentsProvider.StateColumns; import com.android.documentsui.model.DocumentInfo; import com.android.documentsui.model.RootInfo; diff --git a/packages/DocumentsUI/src/com/android/documentsui/DocumentsActivity.java b/packages/DocumentsUI/src/com/android/documentsui/DocumentsActivity.java index dbfcf407e6bd..4658fe366bd8 100644 --- a/packages/DocumentsUI/src/com/android/documentsui/DocumentsActivity.java +++ b/packages/DocumentsUI/src/com/android/documentsui/DocumentsActivity.java @@ -16,13 +16,12 @@ package com.android.documentsui; -import static com.android.documentsui.BaseActivity.State.ACTION_CREATE; -import static com.android.documentsui.BaseActivity.State.ACTION_GET_CONTENT; -import static com.android.documentsui.BaseActivity.State.ACTION_OPEN; -import static com.android.documentsui.BaseActivity.State.ACTION_OPEN_COPY_DESTINATION; -import static com.android.documentsui.BaseActivity.State.ACTION_OPEN_TREE; -import static com.android.documentsui.DirectoryFragment.ANIM_DOWN; import static com.android.documentsui.DirectoryFragment.ANIM_NONE; +import static com.android.documentsui.State.ACTION_CREATE; +import static com.android.documentsui.State.ACTION_GET_CONTENT; +import static com.android.documentsui.State.ACTION_OPEN; +import static com.android.documentsui.State.ACTION_OPEN_COPY_DESTINATION; +import static com.android.documentsui.State.ACTION_OPEN_TREE; import android.app.Activity; import android.app.Fragment; diff --git a/packages/DocumentsUI/src/com/android/documentsui/IconUtils.java b/packages/DocumentsUI/src/com/android/documentsui/IconUtils.java index ec1cb1de5c57..a1213d210b50 100644 --- a/packages/DocumentsUI/src/com/android/documentsui/IconUtils.java +++ b/packages/DocumentsUI/src/com/android/documentsui/IconUtils.java @@ -222,7 +222,7 @@ public class IconUtils { return context.getDrawable(R.drawable.ic_doc_album); } - if (mode == BaseActivity.State.MODE_GRID) { + if (mode == State.MODE_GRID) { return context.getDrawable(R.drawable.ic_grid_folder); } else { return context.getDrawable(R.drawable.ic_doc_folder); diff --git a/packages/DocumentsUI/src/com/android/documentsui/ManageRootActivity.java b/packages/DocumentsUI/src/com/android/documentsui/ManageRootActivity.java index f5b1d8e67dd4..4754899b95cc 100644 --- a/packages/DocumentsUI/src/com/android/documentsui/ManageRootActivity.java +++ b/packages/DocumentsUI/src/com/android/documentsui/ManageRootActivity.java @@ -16,9 +16,8 @@ package com.android.documentsui; -import static com.android.documentsui.BaseActivity.State.ACTION_MANAGE; -import static com.android.documentsui.DirectoryFragment.ANIM_DOWN; import static com.android.documentsui.DirectoryFragment.ANIM_NONE; +import static com.android.documentsui.State.ACTION_MANAGE; import android.app.Activity; import android.app.Fragment; diff --git a/packages/DocumentsUI/src/com/android/documentsui/PickFragment.java b/packages/DocumentsUI/src/com/android/documentsui/PickFragment.java index 5f6a5e90e2c7..48e28dcfdd5c 100644 --- a/packages/DocumentsUI/src/com/android/documentsui/PickFragment.java +++ b/packages/DocumentsUI/src/com/android/documentsui/PickFragment.java @@ -21,7 +21,6 @@ import android.app.Fragment; import android.app.FragmentManager; import android.app.FragmentTransaction; import android.os.Bundle; -import android.text.TextUtils; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -29,8 +28,6 @@ import android.widget.Button; import com.android.documentsui.model.DocumentInfo; -import java.util.Locale; - /** * Display pick confirmation bar, usually for selecting a directory. */ @@ -93,7 +90,7 @@ public class PickFragment extends Fragment { }; /** - * @param action Which action defined in BaseActivity.State is the picker shown for. + * @param action Which action defined in State is the picker shown for. */ public void setPickTarget(int action, int transferMode, DocumentInfo pickTarget) { mAction = action; @@ -109,11 +106,11 @@ public class PickFragment extends Fragment { */ private void updateView() { switch (mAction) { - case BaseActivity.State.ACTION_OPEN_TREE: + case State.ACTION_OPEN_TREE: mPick.setText(R.string.button_select); mCancel.setVisibility(View.GONE); break; - case BaseActivity.State.ACTION_OPEN_COPY_DESTINATION: + case State.ACTION_OPEN_COPY_DESTINATION: mPick.setText(R.string.button_copy); mCancel.setVisibility(View.VISIBLE); break; @@ -123,7 +120,7 @@ public class PickFragment extends Fragment { } if (mPickTarget != null && ( - mAction == BaseActivity.State.ACTION_OPEN_TREE || + mAction == State.ACTION_OPEN_TREE || mPickTarget.isCreateSupported())) { mContainer.setVisibility(View.VISIBLE); } else { diff --git a/packages/DocumentsUI/src/com/android/documentsui/QuickViewIntentBuilder.java b/packages/DocumentsUI/src/com/android/documentsui/QuickViewIntentBuilder.java index 4685c41fc2b6..607cb951bf3f 100644 --- a/packages/DocumentsUI/src/com/android/documentsui/QuickViewIntentBuilder.java +++ b/packages/DocumentsUI/src/com/android/documentsui/QuickViewIntentBuilder.java @@ -16,6 +16,8 @@ package com.android.documentsui; +import static com.android.documentsui.Shared.DEBUG; +import static com.android.documentsui.Shared.TAG; import static com.android.documentsui.model.DocumentInfo.getCursorString; import android.content.ClipData; @@ -38,9 +40,6 @@ import com.android.documentsui.model.DocumentInfo; */ final class QuickViewIntentBuilder { - private static final String TAG = "QvIntentBuilder"; - private static final boolean DEBUG = false; - private final DocumentInfo mDocument; private final DocumentContext mContext; diff --git a/packages/DocumentsUI/src/com/android/documentsui/RecentLoader.java b/packages/DocumentsUI/src/com/android/documentsui/RecentLoader.java index 1a7095a054c3..c2b64fb4317e 100644 --- a/packages/DocumentsUI/src/com/android/documentsui/RecentLoader.java +++ b/packages/DocumentsUI/src/com/android/documentsui/RecentLoader.java @@ -16,8 +16,9 @@ package com.android.documentsui; -import static com.android.documentsui.BaseActivity.State.SORT_ORDER_LAST_MODIFIED; +import static com.android.documentsui.Shared.DEBUG; import static com.android.documentsui.Shared.TAG; +import static com.android.documentsui.State.SORT_ORDER_LAST_MODIFIED; import android.app.ActivityManager; import android.content.AsyncTaskLoader; @@ -34,7 +35,6 @@ import android.provider.DocumentsContract.Root; import android.text.format.DateUtils; import android.util.Log; -import com.android.documentsui.BaseActivity.State; import com.android.documentsui.model.RootInfo; import com.google.common.util.concurrent.AbstractFuture; @@ -53,8 +53,6 @@ import java.util.concurrent.Semaphore; import java.util.concurrent.TimeUnit; public class RecentLoader extends AsyncTaskLoader<DirectoryResult> { - private static final boolean DEBUG = false; - // TODO: clean up cursor ownership so background thread doesn't traverse // previously returned cursors for filtering/sorting; this currently races // with the UI thread. diff --git a/packages/DocumentsUI/src/com/android/documentsui/RecentsCreateFragment.java b/packages/DocumentsUI/src/com/android/documentsui/RecentsCreateFragment.java index 681133156dca..cf682fa508fc 100644 --- a/packages/DocumentsUI/src/com/android/documentsui/RecentsCreateFragment.java +++ b/packages/DocumentsUI/src/com/android/documentsui/RecentsCreateFragment.java @@ -45,7 +45,6 @@ import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; -import com.android.documentsui.BaseActivity.State; import com.android.documentsui.RecentsProvider.RecentColumns; import com.android.documentsui.model.DocumentStack; import com.android.documentsui.model.DurableUtils; diff --git a/packages/DocumentsUI/src/com/android/documentsui/RecentsProvider.java b/packages/DocumentsUI/src/com/android/documentsui/RecentsProvider.java index f6e434966a8a..82eb732002bb 100644 --- a/packages/DocumentsUI/src/com/android/documentsui/RecentsProvider.java +++ b/packages/DocumentsUI/src/com/android/documentsui/RecentsProvider.java @@ -39,6 +39,7 @@ import android.util.Log; import com.android.documentsui.model.DocumentStack; import com.android.documentsui.model.DurableUtils; import com.android.internal.util.Predicate; + import com.google.android.collect.Sets; import libcore.io.IoUtils; diff --git a/packages/DocumentsUI/src/com/android/documentsui/RootsCache.java b/packages/DocumentsUI/src/com/android/documentsui/RootsCache.java index cf715f15dfd2..de35cef6ddb6 100644 --- a/packages/DocumentsUI/src/com/android/documentsui/RootsCache.java +++ b/packages/DocumentsUI/src/com/android/documentsui/RootsCache.java @@ -16,8 +16,8 @@ package com.android.documentsui; -import static com.android.documentsui.Shared.TAG; import static com.android.documentsui.Shared.DEBUG; +import static com.android.documentsui.Shared.TAG; import android.content.ContentProviderClient; import android.content.ContentResolver; @@ -35,12 +35,11 @@ import android.os.Handler; import android.os.SystemClock; import android.provider.DocumentsContract; import android.provider.DocumentsContract.Root; +import android.support.annotation.VisibleForTesting; import android.util.Log; -import com.android.documentsui.BaseActivity.State; import com.android.documentsui.model.RootInfo; import com.android.internal.annotations.GuardedBy; -import android.support.annotation.VisibleForTesting; import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.Multimap; diff --git a/packages/DocumentsUI/src/com/android/documentsui/RootsFragment.java b/packages/DocumentsUI/src/com/android/documentsui/RootsFragment.java index c02184b72b2f..c98da471cd88 100644 --- a/packages/DocumentsUI/src/com/android/documentsui/RootsFragment.java +++ b/packages/DocumentsUI/src/com/android/documentsui/RootsFragment.java @@ -41,7 +41,6 @@ import android.widget.ImageView; import android.widget.ListView; import android.widget.TextView; -import com.android.documentsui.BaseActivity.State; import com.android.documentsui.model.DocumentInfo; import com.android.documentsui.model.RootInfo; diff --git a/packages/DocumentsUI/src/com/android/documentsui/RootsLoader.java b/packages/DocumentsUI/src/com/android/documentsui/RootsLoader.java index 49651b4dc50b..c81377a19aa2 100644 --- a/packages/DocumentsUI/src/com/android/documentsui/RootsLoader.java +++ b/packages/DocumentsUI/src/com/android/documentsui/RootsLoader.java @@ -19,7 +19,6 @@ package com.android.documentsui; import android.content.AsyncTaskLoader; import android.content.Context; -import com.android.documentsui.BaseActivity.State; import com.android.documentsui.model.RootInfo; import java.util.Collection; diff --git a/packages/DocumentsUI/src/com/android/documentsui/SortingCursorWrapper.java b/packages/DocumentsUI/src/com/android/documentsui/SortingCursorWrapper.java index 3ec3d1c01062..6698ff159f25 100644 --- a/packages/DocumentsUI/src/com/android/documentsui/SortingCursorWrapper.java +++ b/packages/DocumentsUI/src/com/android/documentsui/SortingCursorWrapper.java @@ -16,9 +16,9 @@ package com.android.documentsui; -import static com.android.documentsui.BaseActivity.State.SORT_ORDER_DISPLAY_NAME; -import static com.android.documentsui.BaseActivity.State.SORT_ORDER_LAST_MODIFIED; -import static com.android.documentsui.BaseActivity.State.SORT_ORDER_SIZE; +import static com.android.documentsui.State.SORT_ORDER_DISPLAY_NAME; +import static com.android.documentsui.State.SORT_ORDER_LAST_MODIFIED; +import static com.android.documentsui.State.SORT_ORDER_SIZE; import static com.android.documentsui.model.DocumentInfo.getCursorLong; import static com.android.documentsui.model.DocumentInfo.getCursorString; diff --git a/packages/DocumentsUI/src/com/android/documentsui/State.java b/packages/DocumentsUI/src/com/android/documentsui/State.java new file mode 100644 index 000000000000..bbffad326dff --- /dev/null +++ b/packages/DocumentsUI/src/com/android/documentsui/State.java @@ -0,0 +1,153 @@ +/* + * Copyright (C) 2013 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.Intent; +import android.os.Parcel; +import android.os.Parcelable; +import android.util.SparseArray; + +import com.android.documentsui.model.DocumentInfo; +import com.android.documentsui.model.DocumentStack; +import com.android.documentsui.model.DurableUtils; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +public class State implements android.os.Parcelable { + public int action; + public String[] acceptMimes; + + /** Explicit user choice */ + public int userMode = MODE_UNKNOWN; + /** Derived after loader */ + public int derivedMode = MODE_LIST; + + /** Explicit user choice */ + public int userSortOrder = SORT_ORDER_UNKNOWN; + /** Derived after loader */ + public int derivedSortOrder = SORT_ORDER_DISPLAY_NAME; + + public boolean allowMultiple; + public boolean forceSize ; + public boolean showSize; + public boolean localOnly ; + public boolean forceAdvanced ; + public boolean showAdvanced ; + public boolean stackTouched ; + public boolean restored ; + public boolean directoryCopy ; + /** Transfer mode for file copy/move operations. */ + public int transferMode; + + /** Current user navigation stack; empty implies recents. */ + public DocumentStack stack = new DocumentStack(); + /** Currently active search, overriding any stack. */ + public String currentSearch; + + /** Instance state for every shown directory */ + public HashMap<String, SparseArray<Parcelable>> dirState = new HashMap<>(); + + /** Currently copying file */ + public List<DocumentInfo> selectedDocumentsForCopy = new ArrayList<DocumentInfo>(); + + /** Name of the package that started DocsUI */ + public List<String> excludedAuthorities = new ArrayList<>(); + + public static final int ACTION_OPEN = 1; + public static final int ACTION_CREATE = 2; + public static final int ACTION_GET_CONTENT = 3; + public static final int ACTION_OPEN_TREE = 4; + public static final int ACTION_MANAGE = 5; + public static final int ACTION_BROWSE = 6; + public static final int ACTION_OPEN_COPY_DESTINATION = 8; + + public static final int MODE_UNKNOWN = 0; + public static final int MODE_LIST = 1; + public static final int MODE_GRID = 2; + + public static final int SORT_ORDER_UNKNOWN = 0; + public static final int SORT_ORDER_DISPLAY_NAME = 1; + public static final int SORT_ORDER_LAST_MODIFIED = 2; + public static final int SORT_ORDER_SIZE = 3; + + public void initAcceptMimes(Intent intent) { + if (intent.hasExtra(Intent.EXTRA_MIME_TYPES)) { + acceptMimes = intent.getStringArrayExtra(Intent.EXTRA_MIME_TYPES); + } else { + String glob = intent.getType(); + acceptMimes = new String[] { glob != null ? glob : "*/*" }; + } + } + + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(Parcel out, int flags) { + out.writeInt(action); + out.writeInt(userMode); + out.writeStringArray(acceptMimes); + out.writeInt(userSortOrder); + out.writeInt(allowMultiple ? 1 : 0); + out.writeInt(forceSize ? 1 : 0); + out.writeInt(showSize ? 1 : 0); + out.writeInt(localOnly ? 1 : 0); + out.writeInt(forceAdvanced ? 1 : 0); + out.writeInt(showAdvanced ? 1 : 0); + out.writeInt(stackTouched ? 1 : 0); + out.writeInt(restored ? 1 : 0); + DurableUtils.writeToParcel(out, stack); + out.writeString(currentSearch); + out.writeMap(dirState); + out.writeList(selectedDocumentsForCopy); + out.writeList(excludedAuthorities); + } + + public static final Creator<State> CREATOR = new Creator<State>() { + @Override + public State createFromParcel(Parcel in) { + final State state = new State(); + state.action = in.readInt(); + state.userMode = in.readInt(); + state.acceptMimes = in.readStringArray(); + state.userSortOrder = in.readInt(); + state.allowMultiple = in.readInt() != 0; + state.forceSize = in.readInt() != 0; + state.showSize = in.readInt() != 0; + state.localOnly = in.readInt() != 0; + state.forceAdvanced = in.readInt() != 0; + state.showAdvanced = in.readInt() != 0; + state.stackTouched = in.readInt() != 0; + state.restored = in.readInt() != 0; + DurableUtils.readFromParcel(in, state.stack); + state.currentSearch = in.readString(); + in.readMap(state.dirState, null); + in.readList(state.selectedDocumentsForCopy, null); + in.readList(state.excludedAuthorities, null); + return state; + } + + @Override + public State[] newArray(int size) { + return new State[size]; + } + }; +}
\ No newline at end of file diff --git a/packages/DocumentsUI/tests/src/com/android/documentsui/RootsCacheTest.java b/packages/DocumentsUI/tests/src/com/android/documentsui/RootsCacheTest.java index 132570674b48..7d3498e4e079 100644 --- a/packages/DocumentsUI/tests/src/com/android/documentsui/RootsCacheTest.java +++ b/packages/DocumentsUI/tests/src/com/android/documentsui/RootsCacheTest.java @@ -19,7 +19,6 @@ package com.android.documentsui; import android.test.AndroidTestCase; import android.test.suitebuilder.annotation.SmallTest; -import com.android.documentsui.BaseActivity.State; import com.android.documentsui.model.RootInfo; import com.google.common.collect.Lists; diff --git a/services/core/java/com/android/server/wm/TaskPositioner.java b/services/core/java/com/android/server/wm/TaskPositioner.java index 9557d121830d..d1904d80ebc5 100644 --- a/services/core/java/com/android/server/wm/TaskPositioner.java +++ b/services/core/java/com/android/server/wm/TaskPositioner.java @@ -35,12 +35,13 @@ import android.os.Process; import android.os.RemoteException; import android.util.DisplayMetrics; import android.util.Slog; +import android.view.Choreographer; import android.view.Display; import android.view.DisplayInfo; import android.view.InputChannel; import android.view.InputDevice; import android.view.InputEvent; -import android.view.InputEventReceiver; +import android.view.BatchedInputEventReceiver; import android.view.MotionEvent; import android.view.SurfaceControl; import android.view.WindowManager; @@ -103,9 +104,10 @@ class TaskPositioner implements DimLayer.DimLayerUser { InputApplicationHandle mDragApplicationHandle; InputWindowHandle mDragWindowHandle; - private final class WindowPositionerEventReceiver extends InputEventReceiver { - public WindowPositionerEventReceiver(InputChannel inputChannel, Looper looper) { - super(inputChannel, looper); + private final class WindowPositionerEventReceiver extends BatchedInputEventReceiver { + public WindowPositionerEventReceiver( + InputChannel inputChannel, Looper looper, Choreographer choreographer) { + super(inputChannel, looper, choreographer); } @Override @@ -222,8 +224,8 @@ class TaskPositioner implements DimLayer.DimLayerUser { mClientChannel = channels[1]; mService.mInputManager.registerInputChannel(mServerChannel, null); - mInputEventReceiver = new WindowPositionerEventReceiver(mClientChannel, - mService.mH.getLooper()); + mInputEventReceiver = new WindowPositionerEventReceiver( + mClientChannel, mService.mH.getLooper(), mService.mChoreographer); mDragApplicationHandle = new InputApplicationHandle(null); mDragApplicationHandle.name = TAG; |