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

Commit bd1819d8 authored by Roman Birg's avatar Roman Birg Committed by Steve Kondik
Browse files

frameworks: add ongoing notification while collecting bug report



Change-Id: I644da7046b3cbbd0ec601f0e35dfbad6adf4dcf5
Signed-off-by: default avatarRoman Birg <roman@cyngn.com>
parent a9ef5111
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -142,6 +142,7 @@
            android:name=".BugreportReceiver"
            android:permission="android.permission.DUMP">
            <intent-filter>
                <action android:name="android.intent.action.BUGREPORT_STARTED" />
                <action android:name="android.intent.action.BUGREPORT_FINISHED" />
            </intent-filter>
        </receiver>
+20 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2014 The CyanogenMod Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->
<resources>
    <!-- Text to let user know a bug report is currently being collected -->
    <string name="notification_bug_report_active_title">Collecting bug report\u2026</string>
    <string name="notification_bug_report_active_text">Please wait a few minutes</string>
</resources>
+15 −0
Original line number Diff line number Diff line
@@ -65,6 +65,8 @@ public class BugreportReceiver extends BroadcastReceiver {
    private static final String EXTRA_BUGREPORT = "android.intent.extra.BUGREPORT";
    private static final String EXTRA_SCREENSHOT = "android.intent.extra.SCREENSHOT";

    public static final String ACTION_BUGREPORT_STARTED = "android.intent.action.BUGREPORT_STARTED";

    /**
     * Always keep the newest 8 bugreport files; 4 reports and 4 screenshots are
     * roughly 17MB of disk space.
@@ -79,6 +81,19 @@ public class BugreportReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        final Configuration conf = context.getResources().getConfiguration();
        if (ACTION_BUGREPORT_STARTED.equals(intent.getAction())) {
            Notification.Builder builder = new Notification.Builder(context)
                    .setSmallIcon(com.android.internal.R.drawable.stat_sys_adb)
                    .setOngoing(true)
                    .setProgress(0, 0, true)
                    .setContentTitle(context
                            .getString(R.string.notification_bug_report_active_title))
                    .setContentText(context
                            .getString(R.string.notification_bug_report_active_text));
            NotificationManager.from(context).notify(TAG, 0, builder.build());
            return;
        }

        final File bugreportFile = getFileExtra(intent, EXTRA_BUGREPORT);
        final File screenshotFile = getFileExtra(intent, EXTRA_SCREENSHOT);

+1 −0
Original line number Diff line number Diff line
@@ -10721,6 +10721,7 @@ public final class ActivityManagerService extends ActivityManagerNative
    public void requestBugReport() {
        enforceCallingPermission(android.Manifest.permission.DUMP, "requestBugReport");
        mContext.sendBroadcast(new Intent("android.intent.action.BUGREPORT_STARTED"));
        SystemProperties.set("ctl.start", "bugreport");
    }