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

Commit c5df6569 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Don't trigger strict mode for shortcut manager bitmap compression"

parents 3c1fd909 c03127e8
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -21,6 +21,8 @@ import android.content.pm.ShortcutInfo;
import android.graphics.Bitmap;
import android.graphics.Bitmap.CompressFormat;
import android.graphics.drawable.Icon;
import android.os.StrictMode;
import android.os.StrictMode.ThreadPolicy;
import android.os.SystemClock;
import android.util.Log;
import android.util.Slog;
@@ -165,7 +167,13 @@ public class ShortcutBitmapSaver {

        // Compress it and enqueue to the requests.
        final byte[] bytes;
        final StrictMode.ThreadPolicy oldPolicy = StrictMode.getThreadPolicy();
        try {
            // compress() triggers a slow call, but in this case it's needed to save RAM and also
            // the target bitmap is of an icon size, so let's just permit it.
            StrictMode.setThreadPolicy(new ThreadPolicy.Builder(oldPolicy)
                    .permitCustomSlowCalls()
                    .build());
            final Bitmap shrunk = mService.shrinkBitmap(original, maxDimension);
            try {
                try (final ByteArrayOutputStream out = new ByteArrayOutputStream(64 * 1024)) {
@@ -184,6 +192,8 @@ public class ShortcutBitmapSaver {
        } catch (IOException | RuntimeException | OutOfMemoryError e) {
            Slog.wtf(ShortcutService.TAG, "Unable to write bitmap to file", e);
            return;
        } finally {
            StrictMode.setThreadPolicy(oldPolicy);
        }

        shortcut.addFlags(