diff options
| author | Wale Ogunwale <ogunwale@google.com> | 2018-11-13 15:04:59 +0000 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2018-11-13 15:04:59 +0000 |
| commit | 99b5308dcaa7ba65116b74bfb10fabea4ef939b4 (patch) | |
| tree | ef73a61a74cca9254eaf83f295a5f2fe1b9fcb91 /core/java/android | |
| parent | 6cf46ea6fe5f0d350f0da32b6d93e6491faf94b5 (diff) | |
| parent | fc2184596eecc814e6807716d85d3680d4fff46b (diff) | |
Merge "Expose display ID related APIs for use by CTS"
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/app/Activity.java | 2 | ||||
| -rw-r--r-- | core/java/android/app/Instrumentation.java | 17 | ||||
| -rw-r--r-- | core/java/android/view/KeyEvent.java | 25 |
3 files changed, 33 insertions, 11 deletions
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java index fade5742dc83..553acc8dcbd3 100644 --- a/core/java/android/app/Activity.java +++ b/core/java/android/app/Activity.java @@ -31,6 +31,7 @@ import android.annotation.Nullable; import android.annotation.RequiresPermission; import android.annotation.StyleRes; import android.annotation.SystemApi; +import android.annotation.TestApi; import android.annotation.UnsupportedAppUsage; import android.app.VoiceInteractor.Request; import android.app.admin.DevicePolicyManager; @@ -2346,6 +2347,7 @@ public class Activity extends ContextThemeWrapper * @see View#onMovedToDisplay(int, Configuration) * @hide */ + @TestApi public void onMovedToDisplay(int displayId, Configuration config) { } diff --git a/core/java/android/app/Instrumentation.java b/core/java/android/app/Instrumentation.java index ac164428abf8..015bc6c4bb07 100644 --- a/core/java/android/app/Instrumentation.java +++ b/core/java/android/app/Instrumentation.java @@ -1009,7 +1009,7 @@ public class Instrumentation { * from its event processing, though it may <em>not</em> have completely * finished reacting from the event -- for example, if it needs to update * its display as a result, it may still be in the process of doing that. - * + * * @param event The event to send to the current focus. */ public void sendKeySync(KeyEvent event) { @@ -1017,14 +1017,7 @@ public class Instrumentation { long downTime = event.getDownTime(); long eventTime = event.getEventTime(); - int action = event.getAction(); - int code = event.getKeyCode(); - int repeatCount = event.getRepeatCount(); - int metaState = event.getMetaState(); - int deviceId = event.getDeviceId(); - int scancode = event.getScanCode(); int source = event.getSource(); - int flags = event.getFlags(); if (source == InputDevice.SOURCE_UNKNOWN) { source = InputDevice.SOURCE_KEYBOARD; } @@ -1034,12 +1027,14 @@ public class Instrumentation { if (downTime == 0) { downTime = eventTime; } - KeyEvent newEvent = new KeyEvent(downTime, eventTime, action, code, repeatCount, metaState, - deviceId, scancode, flags | KeyEvent.FLAG_FROM_SYSTEM, source); + KeyEvent newEvent = new KeyEvent(event); + newEvent.setTime(downTime, eventTime); + newEvent.setSource(source); + newEvent.setFlags(event.getFlags() | KeyEvent.FLAG_FROM_SYSTEM); InputManager.getInstance().injectInputEvent(newEvent, InputManager.INJECT_INPUT_EVENT_MODE_WAIT_FOR_FINISH); } - + /** * Sends an up and down key event sync to the currently focused window. * diff --git a/core/java/android/view/KeyEvent.java b/core/java/android/view/KeyEvent.java index 907f38535842..0739516e4e96 100644 --- a/core/java/android/view/KeyEvent.java +++ b/core/java/android/view/KeyEvent.java @@ -1978,6 +1978,7 @@ public class KeyEvent extends InputEvent implements Parcelable { } /** @hide */ + @TestApi @Override public final void setDisplayId(int displayId) { mDisplayId = displayId; @@ -2042,6 +2043,16 @@ public class KeyEvent extends InputEvent implements Parcelable { } /** + * Modifies the flags of the event. + * + * @param newFlags New flags for the event, replacing the entire value. + * @hide + */ + public final void setFlags(int newFlags) { + mFlags = newFlags; + } + + /** * Returns the flags for this key event. * * @see #FLAG_WOKE_HERE @@ -2542,6 +2553,20 @@ public class KeyEvent extends InputEvent implements Parcelable { } /** + * Modifies the down time and the event time of the event. + * + * @param downTime The new down time (in {@link android.os.SystemClock#uptimeMillis}) of the + * event. + * @param eventTime The new event time (in {@link android.os.SystemClock#uptimeMillis}) of the + * event. + * @hide + */ + public final void setTime(long downTime, long eventTime) { + mDownTime = downTime; + mEventTime = eventTime; + } + + /** * Retrieve the time of the most recent key down event, * in the {@link android.os.SystemClock#uptimeMillis} time base. If this * is a down event, this will be the same as {@link #getEventTime()}. |
