Monkey updates for new keyboard features.
Add the new volume mute key as a system key.
Use virtual keyboard during injection.
Also fixed a deprecation warning for using an old Intent API.
Bug: 2912307
Bug: 3221301
Change-Id: I056844509112727aa3541223f090cc500c55fc41
diff --git a/cmds/monkey/src/com/android/commands/monkey/MonkeyActivityEvent.java b/cmds/monkey/src/com/android/commands/monkey/MonkeyActivityEvent.java
index 262377a..4661d8c 100644
--- a/cmds/monkey/src/com/android/commands/monkey/MonkeyActivityEvent.java
+++ b/cmds/monkey/src/com/android/commands/monkey/MonkeyActivityEvent.java
@@ -22,7 +22,6 @@
import android.os.Bundle;
import android.os.RemoteException;
import android.view.IWindowManager;
-import android.util.Log;
/**
* monkey activity event
@@ -57,7 +56,7 @@
public int injectEvent(IWindowManager iwm, IActivityManager iam, int verbose) {
Intent intent = getEvent();
if (verbose > 0) {
- System.out.println(":Switch: " + intent.toURI());
+ System.out.println(":Switch: " + intent.toUri(0));
}
if (mAlarmTime != 0){
@@ -75,7 +74,7 @@
} catch (SecurityException e) {
if (verbose > 0) {
System.out.println("** Permissions error starting activity "
- + intent.toURI());
+ + intent.toUri(0));
}
return MonkeyEvent.INJECT_ERROR_SECURITY_EXCEPTION;
}
diff --git a/cmds/monkey/src/com/android/commands/monkey/MonkeySourceNetwork.java b/cmds/monkey/src/com/android/commands/monkey/MonkeySourceNetwork.java
index a9a1db4..dbd616a 100644
--- a/cmds/monkey/src/com/android/commands/monkey/MonkeySourceNetwork.java
+++ b/cmds/monkey/src/com/android/commands/monkey/MonkeySourceNetwork.java
@@ -294,7 +294,7 @@
// Convert the string to an array of KeyEvent's for
// the built in keymap.
KeyCharacterMap keyCharacterMap = KeyCharacterMap.
- load(KeyCharacterMap.BUILT_IN_KEYBOARD);
+ load(KeyCharacterMap.VIRTUAL_KEYBOARD);
KeyEvent[] events = keyCharacterMap.getEvents(chars);
// enqueue all the events we just got.
diff --git a/cmds/monkey/src/com/android/commands/monkey/MonkeySourceRandom.java b/cmds/monkey/src/com/android/commands/monkey/MonkeySourceRandom.java
index a2fa732..ab78563 100644
--- a/cmds/monkey/src/com/android/commands/monkey/MonkeySourceRandom.java
+++ b/cmds/monkey/src/com/android/commands/monkey/MonkeySourceRandom.java
@@ -48,7 +48,7 @@
private static final int[] SYS_KEYS = {
KeyEvent.KEYCODE_HOME, KeyEvent.KEYCODE_BACK,
KeyEvent.KEYCODE_CALL, KeyEvent.KEYCODE_ENDCALL,
- KeyEvent.KEYCODE_VOLUME_UP, KeyEvent.KEYCODE_VOLUME_DOWN,
+ KeyEvent.KEYCODE_VOLUME_UP, KeyEvent.KEYCODE_VOLUME_DOWN, KeyEvent.KEYCODE_VOLUME_MUTE,
KeyEvent.KEYCODE_MUTE,
};
/** If a physical key exists? */