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();
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();
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();
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.");
}
package android.app;
import android.Manifest;
+import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.RequiresPermission;
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;
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
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;
}
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();
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;
}
}
- 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);
}
public void run() {
try {
// Take an "interactive" bugreport.
- ActivityManagerNative.getDefault().requestBugReport(true);
+ ActivityManagerNative.getDefault().requestBugReport(
+ ActivityManager.BUGREPORT_OPTION_INTERACTIVE);
} catch (RemoteException e) {
}
}
}
try {
// Take a "full" bugreport.
- ActivityManagerNative.getDefault().requestBugReport(false);
+ ActivityManagerNative.getDefault().requestBugReport(
+ ActivityManager.BUGREPORT_OPTION_FULL);
} catch (RemoteException e) {
}
return false;