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

Commit ed5e51db authored by Felipe Leme's avatar Felipe Leme Committed by Nandana Dutt
Browse files

Synchronize access to sNotificationBundle.

Otherwise Shell can crash due to ConcurrentModificationException

Test: atest BugreportReceiverTest
Test: manual verification

Fixes:116280360

Change-Id: I138acd43b313d2a7a9d945fb44a9d63e1ad798eb
Merged-In: I138acd43b313d2a7a9d945fb44a9d63e1ad798eb
(cherry picked from commit ee72fa19)
parent 6ef0182f
Loading
Loading
Loading
Loading
+8 −4
Original line number Original line Diff line number Diff line
@@ -42,6 +42,7 @@ import java.util.zip.ZipOutputStream;


import libcore.io.Streams;
import libcore.io.Streams;


import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.app.ChooserActivity;
import com.android.internal.app.ChooserActivity;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.MetricsLogger;
@@ -232,6 +233,7 @@ public class BugreportProgressService extends Service {
     */
     */
    private boolean mTakingScreenshot;
    private boolean mTakingScreenshot;


    @GuardedBy("sNotificationBundle")
    private static final Bundle sNotificationBundle = new Bundle();
    private static final Bundle sNotificationBundle = new Bundle();


    private boolean mIsWatch;
    private boolean mIsWatch;
@@ -1053,11 +1055,13 @@ public class BugreportProgressService extends Service {
    }
    }


    private static Notification.Builder newBaseNotification(Context context) {
    private static Notification.Builder newBaseNotification(Context context) {
        synchronized (sNotificationBundle) {
            if (sNotificationBundle.isEmpty()) {
            if (sNotificationBundle.isEmpty()) {
                // Rename notifcations from "Shell" to "Android System"
                // Rename notifcations from "Shell" to "Android System"
                sNotificationBundle.putString(Notification.EXTRA_SUBSTITUTE_APP_NAME,
                sNotificationBundle.putString(Notification.EXTRA_SUBSTITUTE_APP_NAME,
                        context.getString(com.android.internal.R.string.android_system_label));
                        context.getString(com.android.internal.R.string.android_system_label));
            }
            }
        }
        return new Notification.Builder(context, NOTIFICATION_CHANNEL_ID)
        return new Notification.Builder(context, NOTIFICATION_CHANNEL_ID)
                .addExtras(sNotificationBundle)
                .addExtras(sNotificationBundle)
                .setSmallIcon(
                .setSmallIcon(