diff options
author | Michal Karpinski <mkarpinski@google.com> | 2015-12-11 18:16:30 +0000 |
---|---|---|
committer | Michal Karpinski <mkarpinski@google.com> | 2016-01-08 17:50:16 +0000 |
commit | 3da5c97460d859ec6d9e5fffb3902a3242d32bf4 (patch) | |
tree | 8d5d252c69471913ab40a01f01c086a370e848af | |
parent | 2e8bafc38bd514668eddc223420fd879fb4b37f5 (diff) |
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
-rw-r--r-- | api/current.txt | 3 | ||||
-rw-r--r-- | api/system-current.txt | 3 | ||||
-rw-r--r-- | api/test-current.txt | 3 | ||||
-rw-r--r-- | cmds/am/src/com/android/commands/am/Am.java | 6 | ||||
-rw-r--r-- | core/java/android/app/ActivityManager.java | 33 | ||||
-rw-r--r-- | core/java/android/app/ActivityManagerNative.java | 9 | ||||
-rw-r--r-- | core/java/android/app/IActivityManager.java | 2 | ||||
-rw-r--r-- | services/core/java/com/android/server/am/ActivityManagerService.java | 19 | ||||
-rw-r--r-- | services/core/java/com/android/server/policy/GlobalActions.java | 6 |
9 files changed, 72 insertions, 12 deletions
diff --git a/api/current.txt b/api/current.txt index f6b4d6105c00..55cccdabf524 100644 --- a/api/current.txt +++ b/api/current.txt @@ -3638,6 +3638,9 @@ package android.app { 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 bf4fc5004b16..e65cbacf3f28 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -3749,6 +3749,9 @@ package android.app { 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 8ff46c2ef267..b408ad736cbe 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -3638,6 +3638,9 @@ package android.app { 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 6302d7418cd0..72e8c3b61027 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 @@ public class Am extends BaseCommand { 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 8637dde109d7..ffa45641e9b8 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.FileDescriptor; 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 @@ public class ActivityManager { 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 4bea11277e48..b38a18b4426e 100644 --- a/core/java/android/app/ActivityManagerNative.java +++ b/core/java/android/app/ActivityManagerNative.java @@ -2286,8 +2286,8 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM 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 @@ class ActivityManagerProxy implements IActivityManager 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 8804c8bd4b14..2e65b5ebcbfa 100644 --- a/core/java/android/app/IActivityManager.java +++ b/core/java/android/app/IActivityManager.java @@ -464,7 +464,7 @@ public interface IActivityManager extends IInterface { 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 f6f9f9d0a687..6ef9852d5bc9 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 final class ActivityManagerService extends ActivityManagerNative } } - 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 3eae7fcb6fe5..a0f20aa0f5b1 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 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac 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 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac } try { // Take a "full" bugreport. - ActivityManagerNative.getDefault().requestBugReport(false); + ActivityManagerNative.getDefault().requestBugReport( + ActivityManager.BUGREPORT_OPTION_FULL); } catch (RemoteException e) { } return false; |