Merge "Add the support for the alarmManager and force the device to wake up." into froyo
This commit is contained in:
committed by
Android (Google) Code Review
commit
34ca4b646b
@@ -19,23 +19,32 @@ package com.android.commands.monkey;
|
|||||||
import android.app.IActivityManager;
|
import android.app.IActivityManager;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.view.IWindowManager;
|
import android.view.IWindowManager;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* monkey activity event
|
* monkey activity event
|
||||||
*/
|
*/
|
||||||
public class MonkeyActivityEvent extends MonkeyEvent {
|
public class MonkeyActivityEvent extends MonkeyEvent {
|
||||||
private ComponentName mApp;
|
private ComponentName mApp;
|
||||||
|
String mAlarmTime;
|
||||||
|
|
||||||
public MonkeyActivityEvent(ComponentName app) {
|
public MonkeyActivityEvent(ComponentName app) {
|
||||||
super(EVENT_TYPE_ACTIVITY);
|
super(EVENT_TYPE_ACTIVITY);
|
||||||
mApp = app;
|
mApp = app;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public MonkeyActivityEvent(ComponentName app, String arg) {
|
||||||
|
super(EVENT_TYPE_ACTIVITY);
|
||||||
|
mApp = app;
|
||||||
|
mAlarmTime = arg;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
* @return Intent for the new activity
|
* @return Intent for the new activity
|
||||||
*/
|
*/
|
||||||
private Intent getEvent() {
|
private Intent getEvent() {
|
||||||
Intent intent = new Intent(Intent.ACTION_MAIN);
|
Intent intent = new Intent(Intent.ACTION_MAIN);
|
||||||
intent.addCategory(Intent.CATEGORY_LAUNCHER);
|
intent.addCategory(Intent.CATEGORY_LAUNCHER);
|
||||||
@@ -50,6 +59,13 @@ public class MonkeyActivityEvent extends MonkeyEvent {
|
|||||||
if (verbose > 0) {
|
if (verbose > 0) {
|
||||||
System.out.println(":Switch: " + intent.toURI());
|
System.out.println(":Switch: " + intent.toURI());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mAlarmTime != null){
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
args.putString("alarmTime", mAlarmTime);
|
||||||
|
intent.putExtras(args);
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
iam.startActivity(null, intent, null, null, 0, null, null, 0,
|
iam.startActivity(null, intent, null, null, 0, null, null, 0,
|
||||||
false, false);
|
false, false);
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import java.io.IOException;
|
|||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* monkey event queue. It takes a script to produce events sample script format:
|
* monkey event queue. It takes a script to produce events sample script format:
|
||||||
@@ -271,12 +272,24 @@ public class MonkeySourceScript implements MonkeyEventSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Handle launch events
|
// Handle launch events
|
||||||
if (s.indexOf(EVENT_KEYWORD_ACTIVITY) >= 0 && args.length == 2) {
|
if (s.indexOf(EVENT_KEYWORD_ACTIVITY) >= 0 && args.length >= 2) {
|
||||||
String pkg_name = args[0];
|
String pkg_name = args[0];
|
||||||
String cl_name = args[1];
|
String cl_name = args[1];
|
||||||
|
String alarmTime = null;
|
||||||
|
|
||||||
ComponentName mApp = new ComponentName(pkg_name, cl_name);
|
ComponentName mApp = new ComponentName(pkg_name, cl_name);
|
||||||
MonkeyActivityEvent e = new MonkeyActivityEvent(mApp);
|
|
||||||
mQ.addLast(e);
|
if (args.length > 2) {
|
||||||
|
alarmTime = args[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.length == 2) {
|
||||||
|
MonkeyActivityEvent e = new MonkeyActivityEvent(mApp);
|
||||||
|
mQ.addLast(e);
|
||||||
|
} else {
|
||||||
|
MonkeyActivityEvent e = new MonkeyActivityEvent(mApp, alarmTime);
|
||||||
|
mQ.addLast(e);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user