Merge "Fix: crash when running am.jar without parameters"
This commit is contained in:
@@ -41,6 +41,10 @@ public class Am extends BaseCommand {
|
|||||||
private IActivityManager mAm;
|
private IActivityManager mAm;
|
||||||
private IPackageManager mPm;
|
private IPackageManager mPm;
|
||||||
|
|
||||||
|
Am() {
|
||||||
|
svcInit();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Command-line entry point.
|
* Command-line entry point.
|
||||||
*
|
*
|
||||||
@@ -50,6 +54,20 @@ public class Am extends BaseCommand {
|
|||||||
(new Am()).run(args);
|
(new Am()).run(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void svcInit() {
|
||||||
|
mAm = ActivityManager.getService();
|
||||||
|
if (mAm == null) {
|
||||||
|
System.err.println(NO_SYSTEM_ERROR_CODE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
mPm = IPackageManager.Stub.asInterface(ServiceManager.getService("package"));
|
||||||
|
if (mPm == null) {
|
||||||
|
System.err.println(NO_SYSTEM_ERROR_CODE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onShowUsage(PrintStream out) {
|
public void onShowUsage(PrintStream out) {
|
||||||
try {
|
try {
|
||||||
@@ -61,19 +79,6 @@ public class Am extends BaseCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRun() throws Exception {
|
public void onRun() throws Exception {
|
||||||
|
|
||||||
mAm = ActivityManager.getService();
|
|
||||||
if (mAm == null) {
|
|
||||||
System.err.println(NO_SYSTEM_ERROR_CODE);
|
|
||||||
throw new AndroidException("Can't connect to activity manager; is the system running?");
|
|
||||||
}
|
|
||||||
|
|
||||||
mPm = IPackageManager.Stub.asInterface(ServiceManager.getService("package"));
|
|
||||||
if (mPm == null) {
|
|
||||||
System.err.println(NO_SYSTEM_ERROR_CODE);
|
|
||||||
throw new AndroidException("Can't connect to package manager; is the system running?");
|
|
||||||
}
|
|
||||||
|
|
||||||
String op = nextArgRequired();
|
String op = nextArgRequired();
|
||||||
|
|
||||||
if (op.equals("instrument")) {
|
if (op.equals("instrument")) {
|
||||||
|
|||||||
Reference in New Issue
Block a user