diff options
| author | 2019-10-15 17:42:41 +0100 | |
|---|---|---|
| committer | 2019-10-17 17:35:36 +0100 | |
| commit | 8cd863bf7e6a5cd653d82c835901ecd65bd74ed3 (patch) | |
| tree | ec488af3b48a309ff0c0c0323f75c8f369da9629 | |
| parent | f6fb7063a4578be4407408ee791b7b63de4caf62 (diff) | |
Remove legacy bugreport flow code
* Remove USE_BUGREPORT_API check that enabled us to switch between
legacy bugreport flow and API workflow.
* Undeprecate requestBugReport flavors as these will not be deprecated.
Initially it was aimed to remove these methods and use the API
directly. But now these methods have all been migrated to
use bugreport API.
* Add @BugreportParams annotation for requestBugReport function.
* Title and Description are communicated via the broadcast instead of
setting system properties.
* Description is not a system property anymore, so add a check on its
length by defining MAX_BUGREPORT_DESCRIPTION_SIZE.
Bug: 137825297
Test: Takes interactive and full bugreport as expected
Change-Id: Ib96ad774f5e21491c0dad82cb2292960aa45d6d0
| -rw-r--r-- | core/java/android/app/IActivityManager.aidl | 11 | ||||
| -rw-r--r-- | services/core/java/com/android/server/am/ActivityManagerService.java | 89 |
2 files changed, 35 insertions, 65 deletions
diff --git a/core/java/android/app/IActivityManager.aidl b/core/java/android/app/IActivityManager.aidl index dca00a2bbd83..31a29d4a5c86 100644 --- a/core/java/android/app/IActivityManager.aidl +++ b/core/java/android/app/IActivityManager.aidl @@ -351,10 +351,6 @@ interface IActivityManager { // Request a heap dump for the system server. void requestSystemServerHeapDump(); - // Deprecated - This method is only used by a few internal components and it will soon start - // using bug report API (which will be restricted to a few, pre-defined apps). - // No new code should be calling it. - @UnsupportedAppUsage void requestBugReport(int bugreportType); void requestBugReportWithDescription(in @nullable String shareTitle, in @nullable String shareDescription, int bugreportType); @@ -364,7 +360,7 @@ interface IActivityManager { * that are passed to this API as parameters * * @param shareTitle should be a valid legible string less than 50 chars long - * @param shareDescription should be less than 91 bytes when encoded into UTF-8 format + * @param shareDescription should be less than 150 chars long * * @throws IllegalArgumentException if shareTitle or shareDescription is too big or if the * paremeters cannot be encoding to an UTF-8 charset. @@ -372,13 +368,12 @@ interface IActivityManager { void requestTelephonyBugReport(in String shareTitle, in String shareDescription); /** - * Deprecated - This method is only used by Wifi, and it will soon start using - * bug report API. + * This method is only used by Wifi. * * Takes a minimal bugreport of Wifi-related state. * * @param shareTitle should be a valid legible string less than 50 chars long - * @param shareDescription should be less than 91 bytes when encoded into UTF-8 format + * @param shareDescription should be less than 150 chars long * * @throws IllegalArgumentException if shareTitle or shareDescription is too big or if the * parameters cannot be encoding to an UTF-8 charset. diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index 55cd9339e68c..b1df26bf4d40 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -283,7 +283,6 @@ import android.util.ArrayMap; import android.util.ArraySet; import android.util.DebugUtils; import android.util.EventLog; -import android.util.FeatureFlagUtils; import android.util.Log; import android.util.Pair; import android.util.PrintWriterPrinter; @@ -381,7 +380,6 @@ import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.io.StringWriter; -import java.nio.charset.StandardCharsets; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; @@ -555,6 +553,7 @@ public class ActivityManagerService extends IActivityManager.Stub // Max character limit for a notification title. If the notification title is larger than this // the notification will not be legible to the user. private static final int MAX_BUGREPORT_TITLE_SIZE = 50; + private static final int MAX_BUGREPORT_DESCRIPTION_SIZE = 150; private static final int NATIVE_DUMP_TIMEOUT_MS = 2000; // 2 seconds; private static final int JAVA_DUMP_MINIMUM_SIZE = 100; // 100 bytes. @@ -8251,24 +8250,18 @@ public class ActivityManagerService extends IActivityManager.Stub } /** - * @deprecated This method is only used by a few internal components and it will soon start - * using bug report API (which will be restricted to a few, pre-defined apps). - * No new code should be calling it. + * Takes a bugreport using bug report API ({@code BugreportManager}) with no pre-set + * title and description */ - // TODO(b/137825297): Remove deprecated annotation and rephrase comments for all - // requestBugreport functions below. - @Deprecated @Override - public void requestBugReport(int bugreportType) { + public void requestBugReport(@BugreportParams.BugreportMode int bugreportType) { requestBugReportWithDescription(null, null, bugreportType); } /** - * @deprecated This method is only used by a few internal components and it will soon start - * using bug report API (which will be restricted to a few, pre-defined apps). - * No new code should be calling it. + * Takes a bugreport using bug report API ({@code BugreportManager}) which gets + * triggered by sending a broadcast to Shell. */ - @Deprecated @Override public void requestBugReportWithDescription(@Nullable String shareTitle, @Nullable String shareDescription, int bugreportType) { @@ -8303,60 +8296,45 @@ public class ActivityManagerService extends IActivityManager.Stub if (!TextUtils.isEmpty(shareTitle)) { if (shareTitle.length() > MAX_BUGREPORT_TITLE_SIZE) { - String errorStr = "shareTitle should be less than " + - MAX_BUGREPORT_TITLE_SIZE + " characters"; + String errorStr = "shareTitle should be less than " + + MAX_BUGREPORT_TITLE_SIZE + " characters"; throw new IllegalArgumentException(errorStr); } if (!TextUtils.isEmpty(shareDescription)) { - int length = shareDescription.getBytes(StandardCharsets.UTF_8).length; - if (length > SystemProperties.PROP_VALUE_MAX) { - String errorStr = "shareTitle should be less than " + - SystemProperties.PROP_VALUE_MAX + " bytes"; + if (shareDescription.length() > MAX_BUGREPORT_DESCRIPTION_SIZE) { + String errorStr = "shareDescription should be less than " + + MAX_BUGREPORT_DESCRIPTION_SIZE + " characters"; throw new IllegalArgumentException(errorStr); - } else { - SystemProperties.set("dumpstate.options.description", shareDescription); } } - SystemProperties.set("dumpstate.options.title", shareTitle); Slog.d(TAG, "Bugreport notification title " + shareTitle + " description " + shareDescription); } - final boolean useApi = FeatureFlagUtils.isEnabled(mContext, - FeatureFlagUtils.USE_BUGREPORT_API); - - if (useApi) { - // Create intent to trigger Bugreport API via Shell - Intent triggerShellBugreport = new Intent(); - triggerShellBugreport.setAction(INTENT_BUGREPORT_REQUESTED); - triggerShellBugreport.setPackage(SHELL_APP_PACKAGE); - triggerShellBugreport.putExtra(EXTRA_BUGREPORT_TYPE, bugreportType); - triggerShellBugreport.addFlags(Intent.FLAG_RECEIVER_FOREGROUND); - triggerShellBugreport.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND); - if (shareTitle != null) { - triggerShellBugreport.putExtra(EXTRA_TITLE, shareTitle); - } - if (shareDescription != null) { - triggerShellBugreport.putExtra(EXTRA_DESCRIPTION, shareDescription); - } - final long identity = Binder.clearCallingIdentity(); - try { - // Send broadcast to shell to trigger bugreport using Bugreport API - mContext.sendBroadcast(triggerShellBugreport); - } finally { - Binder.restoreCallingIdentity(identity); - } - } else { - SystemProperties.set("dumpstate.options", type); - SystemProperties.set("ctl.start", "bugreport"); + // Create intent to trigger Bugreport API via Shell + Intent triggerShellBugreport = new Intent(); + triggerShellBugreport.setAction(INTENT_BUGREPORT_REQUESTED); + triggerShellBugreport.setPackage(SHELL_APP_PACKAGE); + triggerShellBugreport.putExtra(EXTRA_BUGREPORT_TYPE, bugreportType); + triggerShellBugreport.addFlags(Intent.FLAG_RECEIVER_FOREGROUND); + triggerShellBugreport.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND); + if (shareTitle != null) { + triggerShellBugreport.putExtra(EXTRA_TITLE, shareTitle); + } + if (shareDescription != null) { + triggerShellBugreport.putExtra(EXTRA_DESCRIPTION, shareDescription); + } + final long identity = Binder.clearCallingIdentity(); + try { + // Send broadcast to shell to trigger bugreport using Bugreport API + mContext.sendBroadcast(triggerShellBugreport); + } finally { + Binder.restoreCallingIdentity(identity); } } /** - * @deprecated This method is only used by a few internal components and it will soon start - * using bug report API (which will be restricted to a few, pre-defined apps). - * No new code should be calling it. + * Takes a telephony bugreport with title and description */ - @Deprecated @Override public void requestTelephonyBugReport(String shareTitle, String shareDescription) { requestBugReportWithDescription(shareTitle, shareDescription, @@ -8364,11 +8342,8 @@ public class ActivityManagerService extends IActivityManager.Stub } /** - * @deprecated This method is only used by a few internal components and it will soon start - * using bug report API (which will be restricted to a few, pre-defined apps). - * No new code should be calling it. + * Takes a minimal bugreport of Wifi-related state with pre-set title and description */ - @Deprecated @Override public void requestWifiBugReport(String shareTitle, String shareDescription) { requestBugReportWithDescription(shareTitle, shareDescription, |