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

Commit cd6a9ef5 authored by Winson Chung's avatar Winson Chung
Browse files

Clearing screenshot bitmap references and recycling bitmap data immediately...

Clearing screenshot bitmap references and recycling bitmap data immediately after saving. (Bug 7974275)

Change-Id: Icb71d28eb80105757026d7fac530db936b327500
parent 35654b61
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -217,13 +217,21 @@ class SaveImageInBackgroundTask extends AsyncTask<SaveImageInBackgroundData, Voi
            resolver.update(uri, values, null, null);

            params[0].imageUri = uri;
            params[0].image = null;
            params[0].result = 0;
        } catch (Exception e) {
            // IOException/UnsupportedOperationException may be thrown if external storage is not
            // mounted
            params[0].imageUri = null;
            params[0].image = null;
            params[0].result = 1;
        }

        // Recycle the bitmap data
        if (image != null) {
            image.recycle();
        }

        return params[0];
    }

@@ -458,6 +466,10 @@ class GlobalScreenshot {
                // Save the screenshot once we have a bit of time now
                saveScreenshotInWorkerThread(finisher);
                mWindowManager.removeView(mScreenshotLayout);

                // Clear any references to the bitmap
                mScreenBitmap = null;
                mScreenshotView.setImageBitmap(null);
            }
        });
        mScreenshotLayout.post(new Runnable() {