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

Commit c03127e8 authored by Makoto Onuki's avatar Makoto Onuki
Browse files

Don't trigger strict mode for shortcut manager bitmap compression

Bug 65179362
Test: manual

Change-Id: Ic4540e96959244a932142b978681cd2750aae6f1
parent d5ad2ff5
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(