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

Commit c2141fe6 authored by Miranda Kephart's avatar Miranda Kephart Committed by Android (Google) Code Review
Browse files

Merge "Release screenshot WindowContext when process ends"

parents 40449d81 f7e9cd57
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ import android.app.ActivityOptions;
import android.app.ExitTransitionCoordinator;
import android.app.ExitTransitionCoordinator.ExitTransitionCallbacks;
import android.app.Notification;
import android.app.WindowContext;
import android.content.ComponentName;
import android.content.Context;
import android.content.pm.ActivityInfo;
@@ -165,7 +166,7 @@ public class ScreenshotController {
    // From WizardManagerHelper.java
    private static final String SETTINGS_SECURE_USER_SETUP_COMPLETE = "user_setup_complete";

    private final Context mContext;
    private final WindowContext mContext;
    private final ScreenshotNotificationsController mNotificationsController;
    private final ScreenshotSmartActions mScreenshotSmartActions;
    private final UiEventLogger mUiEventLogger;
@@ -240,7 +241,7 @@ public class ScreenshotController {
        final DisplayManager dm = requireNonNull(context.getSystemService(DisplayManager.class));
        final Display display = dm.getDisplay(DEFAULT_DISPLAY);
        final Context displayContext = context.createDisplayContext(display);
        mContext = displayContext.createWindowContext(TYPE_SCREENSHOT, null);
        mContext = (WindowContext) displayContext.createWindowContext(TYPE_SCREENSHOT, null);
        mWindowManager = mContext.getSystemService(WindowManager.class);

        mAccessibilityManager = AccessibilityManager.getInstance(mContext);
@@ -351,6 +352,13 @@ public class ScreenshotController {
        }
    }

    /**
     * Release the constructed window context.
     */
    void releaseContext() {
        mContext.release();
    }

    /**
     * Update resources on configuration change. Reinflate for theme/color changes.
     */
+3 −0
Original line number Diff line number Diff line
@@ -123,6 +123,9 @@ public class TakeScreenshotService extends Service {
    @Override
    public void onDestroy() {
        super.onDestroy();
        if (mScreenshot != null) {
            mScreenshot.releaseContext();
        }
        if (DEBUG_SERVICE) {
            Log.d(TAG, "onDestroy");
        }