summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSvetoslav Ganov <svetoslavganov@google.com>2011-11-10 17:54:24 -0800
committerSvetoslav Ganov <svetoslavganov@google.com>2011-11-11 10:43:13 -0800
commitc350f1604f348dceec28ba0d7e4cfc293333f797 (patch)
tree518e9cb20fe9ff3cb2c32df34eadfcdb7932c765
parent03466e35f2996fd3330452e38984f0012239305e (diff)
downloadframeworks_base-c350f1604f348dceec28ba0d7e4cfc293333f797.zip
frameworks_base-c350f1604f348dceec28ba0d7e4cfc293333f797.tar.gz
frameworks_base-c350f1604f348dceec28ba0d7e4cfc293333f797.tar.bz2
Instrumentation sendStringSync(String) may try to inject obsolete events.
KeyEvents returned by KeyCharacterMap.getEvents() have the same time stamp and the system rejects too old events. Hence, it is possible for an event to become stale before it is injected if it takes too long to inject the preceding ones. Now the time of the event is set just before injecting it. Change-Id: I72b60d261f8bda857b331d0f1b1bd97f9f15def3
-rw-r--r--core/java/android/app/Instrumentation.java17
1 files changed, 8 insertions, 9 deletions
diff --git a/core/java/android/app/Instrumentation.java b/core/java/android/app/Instrumentation.java
index d7f5c55..b607daf 100644
--- a/core/java/android/app/Instrumentation.java
+++ b/core/java/android/app/Instrumentation.java
@@ -24,14 +24,14 @@ import android.content.IntentFilter;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.os.Bundle;
-import android.os.PerformanceCollector;
-import android.os.RemoteException;
import android.os.Debug;
import android.os.IBinder;
import android.os.MessageQueue;
+import android.os.PerformanceCollector;
import android.os.Process;
-import android.os.SystemClock;
+import android.os.RemoteException;
import android.os.ServiceManager;
+import android.os.SystemClock;
import android.util.AndroidRuntimeException;
import android.util.Log;
import android.view.IWindowManager;
@@ -40,7 +40,6 @@ import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.ViewConfiguration;
import android.view.Window;
-import android.view.inputmethod.InputMethodManager;
import java.io.File;
import java.util.ArrayList;
@@ -834,16 +833,16 @@ public class Instrumentation {
return;
}
KeyCharacterMap keyCharacterMap = KeyCharacterMap.load(KeyCharacterMap.VIRTUAL_KEYBOARD);
-
+
KeyEvent[] events = keyCharacterMap.getEvents(text.toCharArray());
-
+
if (events != null) {
for (int i = 0; i < events.length; i++) {
- sendKeySync(events[i]);
+ sendKeySync(KeyEvent.changeTimeRepeat(events[i], SystemClock.uptimeMillis(), 0));
}
- }
+ }
}
-
+
/**
* Send a key event to the currently focused window/view and wait for it to
* be processed. Finished at some point after the recipient has returned