Adjusting AMN#requestBugReport() to be able to invoke 3 types
of bugreport services
ActivityManagerNative#requestBugReport() now can accept 3 types:
FULL, INTERACTIVE AND REMOTE.
Bug: 26152603
Change-Id: Ife9bbef4691e172fb56b72b256880f0d4ad4d198
diff --git a/api/current.txt b/api/current.txt
index f6b4d61..55cccda 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -3638,6 +3638,9 @@
method public void startActivity(android.content.Context, android.content.Intent, android.os.Bundle);
}
+ public static abstract class ActivityManager.BugreportMode implements java.lang.annotation.Annotation {
+ }
+
public static class ActivityManager.MemoryInfo implements android.os.Parcelable {
ctor public ActivityManager.MemoryInfo();
method public int describeContents();
diff --git a/api/system-current.txt b/api/system-current.txt
index bf4fc50..e65cbac 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -3749,6 +3749,9 @@
method public void startActivity(android.content.Context, android.content.Intent, android.os.Bundle);
}
+ public static abstract class ActivityManager.BugreportMode implements java.lang.annotation.Annotation {
+ }
+
public static class ActivityManager.MemoryInfo implements android.os.Parcelable {
ctor public ActivityManager.MemoryInfo();
method public int describeContents();
diff --git a/api/test-current.txt b/api/test-current.txt
index 8ff46c2..b408ad73 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -3638,6 +3638,9 @@
method public void startActivity(android.content.Context, android.content.Intent, android.os.Bundle);
}
+ public static abstract class ActivityManager.BugreportMode implements java.lang.annotation.Annotation {
+ }
+
public static class ActivityManager.MemoryInfo implements android.os.Parcelable {
ctor public ActivityManager.MemoryInfo();
method public int describeContents();
diff --git a/cmds/am/src/com/android/commands/am/Am.java b/cmds/am/src/com/android/commands/am/Am.java
index 6302d74..72e8c3b 100644
--- a/cmds/am/src/com/android/commands/am/Am.java
+++ b/cmds/am/src/com/android/commands/am/Am.java
@@ -1080,16 +1080,16 @@
private void runBugReport() throws Exception {
String opt;
- boolean progress = false;
+ int bugreportType = ActivityManager.BUGREPORT_OPTION_FULL;
while ((opt=nextOption()) != null) {
if (opt.equals("--progress")) {
- progress = true;
+ bugreportType = ActivityManager.BUGREPORT_OPTION_INTERACTIVE;
} else {
System.err.println("Error: Unknown option: " + opt);
return;
}
}
- mAm.requestBugReport(progress);
+ mAm.requestBugReport(bugreportType);
System.out.println("Your lovely bug report is being created; please be patient.");
}
diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java
index 8637dde..ffa4564 100644
--- a/core/java/android/app/ActivityManager.java
+++ b/core/java/android/app/ActivityManager.java
@@ -17,6 +17,7 @@
package android.app;
import android.Manifest;
+import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.RequiresPermission;
@@ -65,6 +66,8 @@
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.List;
@@ -79,6 +82,36 @@
private final Context mContext;
private final Handler mHandler;
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef({
+ BUGREPORT_OPTION_FULL,
+ BUGREPORT_OPTION_INTERACTIVE,
+ BUGREPORT_OPTION_REMOTE
+ })
+ /**
+ * Defines acceptable types of bugreports.
+ * @hide
+ */
+ public @interface BugreportMode {}
+ /**
+ * Takes a bugreport without user interference (and hence causing less
+ * interference to the system), but includes all sections.
+ * @hide
+ */
+ public static final int BUGREPORT_OPTION_FULL = 0;
+ /**
+ * Allows user to monitor progress and enter additional data; might not include all
+ * sections.
+ * @hide
+ */
+ public static final int BUGREPORT_OPTION_INTERACTIVE = 1;
+ /**
+ * Takes a bugreport requested remotely by administrator of the Device Owner app,
+ * not the device's user.
+ * @hide
+ */
+ public static final int BUGREPORT_OPTION_REMOTE = 2;
+
/**
* <a href="{@docRoot}guide/topics/manifest/meta-data-element.html">{@code
* <meta-data>}</a> name for a 'home' Activity that declares a package that is to be
diff --git a/core/java/android/app/ActivityManagerNative.java b/core/java/android/app/ActivityManagerNative.java
index 4bea112..b38a18b 100644
--- a/core/java/android/app/ActivityManagerNative.java
+++ b/core/java/android/app/ActivityManagerNative.java
@@ -2286,8 +2286,8 @@
case REQUEST_BUG_REPORT_TRANSACTION: {
data.enforceInterface(IActivityManager.descriptor);
- boolean progress = data.readInt() != 0;
- requestBugReport(progress);
+ int bugreportType = data.readInt();
+ requestBugReport(bugreportType);
reply.writeNoException();
return true;
}
@@ -5768,11 +5768,12 @@
reply.recycle();
}
- public void requestBugReport(boolean progress) throws RemoteException {
+ public void requestBugReport(@ActivityManager.BugreportMode int bugreportType)
+ throws RemoteException {
Parcel data = Parcel.obtain();
Parcel reply = Parcel.obtain();
data.writeInterfaceToken(IActivityManager.descriptor);
- data.writeInt(progress ? 1 : 0);
+ data.writeInt(bugreportType);
mRemote.transact(REQUEST_BUG_REPORT_TRANSACTION, data, reply, 0);
reply.readException();
data.recycle();
diff --git a/core/java/android/app/IActivityManager.java b/core/java/android/app/IActivityManager.java
index 8804c8b..2e65b5e 100644
--- a/core/java/android/app/IActivityManager.java
+++ b/core/java/android/app/IActivityManager.java
@@ -464,7 +464,7 @@
public void registerUserSwitchObserver(IUserSwitchObserver observer) throws RemoteException;
public void unregisterUserSwitchObserver(IUserSwitchObserver observer) throws RemoteException;
- public void requestBugReport(boolean progress) throws RemoteException;
+ public void requestBugReport(int bugreportType) throws RemoteException;
public long inputDispatchingTimedOut(int pid, boolean aboveSystem, String reason)
throws RemoteException;
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index f6f9f9d..6ef9852 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -11377,8 +11377,23 @@
}
}
- public void requestBugReport(boolean progress) {
- final String service = progress ? "bugreportplus" : "bugreport";
+ public void requestBugReport(int bugreportType) {
+ String service = null;
+ switch (bugreportType) {
+ case ActivityManager.BUGREPORT_OPTION_FULL:
+ service = "bugreport";
+ break;
+ case ActivityManager.BUGREPORT_OPTION_INTERACTIVE:
+ service = "bugreportplus";
+ break;
+ case ActivityManager.BUGREPORT_OPTION_REMOTE:
+ service = "bugreportremote";
+ break;
+ }
+ if (service == null) {
+ throw new IllegalArgumentException("Provided bugreport type is not correct, value: "
+ + bugreportType);
+ }
enforceCallingPermission(android.Manifest.permission.DUMP, "requestBugReport");
SystemProperties.set("ctl.start", service);
}
diff --git a/services/core/java/com/android/server/policy/GlobalActions.java b/services/core/java/com/android/server/policy/GlobalActions.java
index 3eae7fc..a0f20aa 100644
--- a/services/core/java/com/android/server/policy/GlobalActions.java
+++ b/services/core/java/com/android/server/policy/GlobalActions.java
@@ -388,7 +388,8 @@
public void run() {
try {
// Take an "interactive" bugreport.
- ActivityManagerNative.getDefault().requestBugReport(true);
+ ActivityManagerNative.getDefault().requestBugReport(
+ ActivityManager.BUGREPORT_OPTION_INTERACTIVE);
} catch (RemoteException e) {
}
}
@@ -404,7 +405,8 @@
}
try {
// Take a "full" bugreport.
- ActivityManagerNative.getDefault().requestBugReport(false);
+ ActivityManagerNative.getDefault().requestBugReport(
+ ActivityManager.BUGREPORT_OPTION_FULL);
} catch (RemoteException e) {
}
return false;