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

Commit 8aca6ab5 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Minor improvements on BugreportProgressService." into main

parents 167a1547 d02623bf
Loading
Loading
Loading
Loading
+23 −9
Original line number Diff line number Diff line
@@ -136,7 +136,7 @@ import java.util.zip.ZipOutputStream;
 * bugreport artifacts.
 * </ol>
 */
public class BugreportProgressService extends Service {
public final class BugreportProgressService extends Service {
    private static final String TAG = "BugreportProgressService";
    private static final boolean DEBUG = false;
    private static final String WRITE_AND_APPEND_MODE = "wa";
@@ -217,8 +217,6 @@ public class BugreportProgressService extends Service {
    /** System property where dumpstate stores last triggered bugreport id */
    static final String PROPERTY_LAST_ID = "dumpstate.last_id";

    private static final String BUGREPORT_SERVICE = "bugreport";

    /**
     * Directory on Shell's data storage where screenshots will be stored.
     * <p>
@@ -937,7 +935,7 @@ public class BugreportProgressService extends Service {
    private void sendForegroundabledNotification(int id, Notification notification) {
        if (mForegroundId >= 0) {
            if (DEBUG) Log.d(TAG, "Already running as foreground service");
            NotificationManager.from(mContext).notify(id, notification);
            sendNotification(id, notification);
        } else {
            mForegroundId = id;
            Log.d(TAG, "Start running as foreground service on id " + mForegroundId);
@@ -990,7 +988,7 @@ public class BugreportProgressService extends Service {


        Log.d(TAG, "stopProgress(" + id + "): cancel notification");
        NotificationManager.from(mContext).cancel(id);
        cancelNotification(id);

        stopSelfWhenDoneLocked();
    }
@@ -1031,7 +1029,7 @@ public class BugreportProgressService extends Service {
            Log.w(TAG, "launchBugreportInfoDialog(): canceling notification because id " + id
                    + " was not found");
            // TODO: add test case to make sure notification is canceled.
            NotificationManager.from(mContext).cancel(id);
            cancelNotification(id);
            return;
        }

@@ -1068,7 +1066,7 @@ public class BugreportProgressService extends Service {
            Log.w(TAG, "takeScreenshot(): canceling notification because id " + id
                    + " was not found");
            // TODO: add test case to make sure notification is canceled.
            NotificationManager.from(mContext).cancel(id);
            cancelNotification(id);
            return;
        }
        setTakingScreenshot(true);
@@ -1364,7 +1362,7 @@ public class BugreportProgressService extends Service {
            warningIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            mContext.startActivity(warningIntent);
        }
        NotificationManager.from(mContext).cancel(id);
        cancelNotification(id);
    }

    /**
@@ -1513,7 +1511,7 @@ public class BugreportProgressService extends Service {
        }

        Log.d(TAG, "Sending 'Share' notification for ID " + info.id + ": " + title);
        NotificationManager.from(mContext).notify(info.id, builder.build());
        sendNotification(info.id, builder.build());
    }

    /**
@@ -1531,6 +1529,22 @@ public class BugreportProgressService extends Service {
        sendForegroundabledNotification(id, builder.build());
    }

    private void cancelNotification(int id) {
        if (DEBUG) {
            Log.v(TAG, "Calling NotificationManager.cancel(" + id + ") on user "
                    + mContext.getUser());
        }
        NotificationManager.from(mContext).cancel(id);
    }

    private void sendNotification(int id, Notification notification) {
        if (DEBUG) {
            Log.v(TAG, "Calling NotificationManager.notify(" + id + ", " + notification
                    + ") on user " + mContext.getUser());
        }
        NotificationManager.from(mContext).notify(id, notification);
    }

    private static Notification.Builder newBaseNotification(Context context) {
        synchronized (sNotificationBundle) {
            if (sNotificationBundle.isEmpty()) {
+64 −68

File changed.

Preview size limit exceeded, changes collapsed.