Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d9e1df58 authored by mukesh agrawal's avatar mukesh agrawal
Browse files

ActivityManager: add API for wifi bug report

Under certain (limited) conditions, we would like to
automatically trigger a bug report to help diagnose
Wifi problems.

The regular bugreport can't be used for this purpose,
as it takes a long time to generate. To support
lightweight auto-bug generation, add a Wifi-specific
bugreport.

Bug: 69934148
Test: manual

Manual test
-----------
- boot walleye
- enable wifi
- connect to googleguest
$ adb root
$ adb shell pkill -f 'wifi@'
- notice "Bug report #1 captured" notification
$ adb pull '/data/user_de/0/com.android.shell/files/bugreports
$ unzip bugreports/*.zip
$ grep "was the duration of 'DUMPSTATE'" bugreport*.txt
->  ------ 1.548s was the duration of 'DUMPSTATE' ------

Change-Id: If657eb8f61b16cefe717c977663438c28f515bd7
parent 2bdb9af0
Loading
Loading
Loading
Loading
+8 −1
Original line number Original line Diff line number Diff line
@@ -181,7 +181,8 @@ public class ActivityManager {
            BUGREPORT_OPTION_INTERACTIVE,
            BUGREPORT_OPTION_INTERACTIVE,
            BUGREPORT_OPTION_REMOTE,
            BUGREPORT_OPTION_REMOTE,
            BUGREPORT_OPTION_WEAR,
            BUGREPORT_OPTION_WEAR,
            BUGREPORT_OPTION_TELEPHONY
            BUGREPORT_OPTION_TELEPHONY,
            BUGREPORT_OPTION_WIFI
    })
    })
    public @interface BugreportMode {}
    public @interface BugreportMode {}
    /**
    /**
@@ -215,6 +216,12 @@ public class ActivityManager {
     */
     */
    public static final int BUGREPORT_OPTION_TELEPHONY = 4;
    public static final int BUGREPORT_OPTION_TELEPHONY = 4;


    /**
     * Takes a lightweight bugreport that only includes a few sections related to Wifi.
     * @hide
     */
    public static final int BUGREPORT_OPTION_WIFI = 5;

    /**
    /**
     * <a href="{@docRoot}guide/topics/manifest/meta-data-element.html">{@code
     * <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
     * <meta-data>}</a> name for a 'home' Activity that declares a package that is to be
+14 −0
Original line number Original line Diff line number Diff line
@@ -357,6 +357,20 @@ interface IActivityManager {
     */
     */
    void requestTelephonyBugReport(in String shareTitle, in String shareDescription);
    void requestTelephonyBugReport(in String shareTitle, in String shareDescription);


    /**
     *  Deprecated - This method is only used by Wifi, and it will soon be replaced by a proper
     *  bug report API.
     *
     *  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
     *
     *  @throws IllegalArgumentException if shareTitle or shareDescription is too big or if the
     *          parameters cannot be encoding to an UTF-8 charset.
     */
    void requestWifiBugReport(in String shareTitle, in String shareDescription);

    long inputDispatchingTimedOut(int pid, boolean aboveSystem, in String reason);
    long inputDispatchingTimedOut(int pid, boolean aboveSystem, in String reason);
    void clearPendingBackup();
    void clearPendingBackup();
    Intent getIntentForIntentSender(in IIntentSender sender);
    Intent getIntentForIntentSender(in IIntentSender sender);
+31 −4
Original line number Original line Diff line number Diff line
@@ -13088,6 +13088,9 @@ public class ActivityManagerService extends IActivityManager.Stub
            case ActivityManager.BUGREPORT_OPTION_TELEPHONY:
            case ActivityManager.BUGREPORT_OPTION_TELEPHONY:
                extraOptions = "bugreporttelephony";
                extraOptions = "bugreporttelephony";
                break;
                break;
            case ActivityManager.BUGREPORT_OPTION_WIFI:
                extraOptions = "bugreportwifi";
                break;
            default:
            default:
                throw new IllegalArgumentException("Provided bugreport type is not correct, value: "
                throw new IllegalArgumentException("Provided bugreport type is not correct, value: "
                        + bugreportType);
                        + bugreportType);
@@ -13109,9 +13112,8 @@ public class ActivityManagerService extends IActivityManager.Stub
     * No new code should be calling it.
     * No new code should be calling it.
     */
     */
    @Deprecated
    @Deprecated
    @Override
    private void requestBugReportWithDescription(String shareTitle, String shareDescription,
    public void requestTelephonyBugReport(String shareTitle, String shareDescription) {
                                                 int bugreportType) {
        if (!TextUtils.isEmpty(shareTitle)) {
        if (!TextUtils.isEmpty(shareTitle)) {
            if (shareTitle.length() > MAX_BUGREPORT_TITLE_SIZE) {
            if (shareTitle.length() > MAX_BUGREPORT_TITLE_SIZE) {
                String errorStr = "shareTitle should be less than " +
                String errorStr = "shareTitle should be less than " +
@@ -13140,9 +13142,34 @@ public class ActivityManagerService extends IActivityManager.Stub
        Slog.d(TAG, "Bugreport notification title " + shareTitle
        Slog.d(TAG, "Bugreport notification title " + shareTitle
                + " description " + shareDescription);
                + " description " + shareDescription);
        requestBugReport(ActivityManager.BUGREPORT_OPTION_TELEPHONY);
        requestBugReport(bugreportType);
    }
    /**
     * @deprecated This method is only used by a few internal components and it will soon be
     * replaced by a proper bug report API (which will be restricted to a few, pre-defined apps).
     * No new code should be calling it.
     */
    @Deprecated
    @Override
    public void requestTelephonyBugReport(String shareTitle, String shareDescription) {
        requestBugReportWithDescription(shareTitle, shareDescription,
                ActivityManager.BUGREPORT_OPTION_TELEPHONY);
    }
    /**
     * @deprecated This method is only used by a few internal components and it will soon be
     * replaced by a proper bug report API (which will be restricted to a few, pre-defined apps).
     * No new code should be calling it.
     */
    @Deprecated
    @Override
    public void requestWifiBugReport(String shareTitle, String shareDescription) {
        requestBugReportWithDescription(shareTitle, shareDescription,
                ActivityManager.BUGREPORT_OPTION_WIFI);
    }
    }
    public static long getInputDispatchingTimeoutLocked(ActivityRecord r) {
    public static long getInputDispatchingTimeoutLocked(ActivityRecord r) {
        return r != null ? getInputDispatchingTimeoutLocked(r.app) : KEY_DISPATCHING_TIMEOUT;
        return r != null ? getInputDispatchingTimeoutLocked(r.app) : KEY_DISPATCHING_TIMEOUT;
    }
    }