Skip to content

Commit 34ca4b6

Browse files
Yu Shan Emily LauAndroid (Google) Code Review
authored andcommitted
Merge "Add the support for the alarmManager and force the device to wake up." into froyo
2 parents e46d051 + 52bbaa3 commit 34ca4b6

File tree

2 files changed

+35
-6
lines changed

2 files changed

+35
-6
lines changed

cmds/monkey/src/com/android/commands/monkey/MonkeyActivityEvent.java

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,32 @@
1919
import android.app.IActivityManager;
2020
import android.content.ComponentName;
2121
import android.content.Intent;
22+
import android.os.Bundle;
2223
import android.os.RemoteException;
2324
import android.view.IWindowManager;
25+
import android.util.Log;
2426

2527
/**
2628
* monkey activity event
2729
*/
2830
public class MonkeyActivityEvent extends MonkeyEvent {
2931
private ComponentName mApp;
32+
String mAlarmTime;
3033

3134
public MonkeyActivityEvent(ComponentName app) {
3235
super(EVENT_TYPE_ACTIVITY);
3336
mApp = app;
3437
}
35-
36-
/**
38+
39+
public MonkeyActivityEvent(ComponentName app, String arg) {
40+
super(EVENT_TYPE_ACTIVITY);
41+
mApp = app;
42+
mAlarmTime = arg;
43+
}
44+
45+
/**
3746
* @return Intent for the new activity
38-
*/
47+
*/
3948
private Intent getEvent() {
4049
Intent intent = new Intent(Intent.ACTION_MAIN);
4150
intent.addCategory(Intent.CATEGORY_LAUNCHER);
@@ -50,6 +59,13 @@ public int injectEvent(IWindowManager iwm, IActivityManager iam, int verbose) {
5059
if (verbose > 0) {
5160
System.out.println(":Switch: " + intent.toURI());
5261
}
62+
63+
if (mAlarmTime != null){
64+
Bundle args = new Bundle();
65+
args.putString("alarmTime", mAlarmTime);
66+
intent.putExtras(args);
67+
}
68+
5369
try {
5470
iam.startActivity(null, intent, null, null, 0, null, null, 0,
5571
false, false);

cmds/monkey/src/com/android/commands/monkey/MonkeySourceScript.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import java.io.InputStreamReader;
2828
import java.util.NoSuchElementException;
2929
import java.util.Random;
30+
import android.util.Log;
3031

3132
/**
3233
* monkey event queue. It takes a script to produce events sample script format:
@@ -271,12 +272,24 @@ private void handleEvent(String s, String[] args) {
271272
}
272273

273274
// Handle launch events
274-
if (s.indexOf(EVENT_KEYWORD_ACTIVITY) >= 0 && args.length == 2) {
275+
if (s.indexOf(EVENT_KEYWORD_ACTIVITY) >= 0 && args.length >= 2) {
275276
String pkg_name = args[0];
276277
String cl_name = args[1];
278+
String alarmTime = null;
279+
277280
ComponentName mApp = new ComponentName(pkg_name, cl_name);
278-
MonkeyActivityEvent e = new MonkeyActivityEvent(mApp);
279-
mQ.addLast(e);
281+
282+
if (args.length > 2) {
283+
alarmTime = args[2];
284+
}
285+
286+
if (args.length == 2) {
287+
MonkeyActivityEvent e = new MonkeyActivityEvent(mApp);
288+
mQ.addLast(e);
289+
} else {
290+
MonkeyActivityEvent e = new MonkeyActivityEvent(mApp, alarmTime);
291+
mQ.addLast(e);
292+
}
280293
return;
281294
}
282295

0 commit comments

Comments
 (0)