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

Commit 31d9e8a3 authored by mavishsu's avatar mavishsu Committed by Riddle Hsu
Browse files

Shall clear calling identity to avoid destroying GraphicBuffer unexpectedly.

This changed apply to three APIs:
setShouldShowSystemDecors()
setShouldShowIme()
setShouldShowWithInsecureKeyguard()

Bug: 144750952
Test: by manual

Change-Id: I5061fd93d4b356d41089b1a6a0887679b36d8b20
(cherry picked from commit 3fae5b3fd17d94c52b4a4010bf17f0ddc748fef5)
parent 58ea0c96
Loading
Loading
Loading
Loading
+51 −40
Original line number Diff line number Diff line
@@ -6795,12 +6795,13 @@ public class WindowManagerService extends IWindowManager.Stub
                "setShouldShowWithInsecureKeyguard()")) {
            throw new SecurityException("Requires INTERNAL_SYSTEM_WINDOW permission");
        }

        final long origId = Binder.clearCallingIdentity();
        try {
            synchronized (mGlobalLock) {
                final DisplayContent displayContent = getDisplayContentOrCreate(displayId, null);
                if (displayContent == null) {
                ProtoLog.w(WM_ERROR, "Attempted to set flag to a display that does not exist: %d",
                        displayId);
                    ProtoLog.w(WM_ERROR, "Attempted to set flag to a display that does not exist: "
                            + "%d", displayId);
                    return;
                }

@@ -6809,6 +6810,9 @@ public class WindowManagerService extends IWindowManager.Stub

                displayContent.reconfigureDisplayLocked();
            }
        } finally {
            Binder.restoreCallingIdentity(origId);
        }
    }

    @Override
@@ -6836,23 +6840,27 @@ public class WindowManagerService extends IWindowManager.Stub
        if (!checkCallingPermission(INTERNAL_SYSTEM_WINDOW, "setShouldShowSystemDecors()")) {
            throw new SecurityException("Requires INTERNAL_SYSTEM_WINDOW permission");
        }

        final long origId = Binder.clearCallingIdentity();
        try {
            synchronized (mGlobalLock) {
                final DisplayContent displayContent = getDisplayContentOrCreate(displayId, null);
                if (displayContent == null) {
                ProtoLog.w(WM_ERROR, "Attempted to set system decors flag to a display that does "
                        + "not exist: %d", displayId);
                    ProtoLog.w(WM_ERROR, "Attempted to set system decors flag to a display that "
                            + "does not exist: %d", displayId);
                    return;
                }
                if (displayContent.isUntrustedVirtualDisplay()) {
                throw new SecurityException("Attempted to set system decors flag to an untrusted "
                        + "virtual display: " + displayId);
                    throw new SecurityException("Attempted to set system decors flag to an "
                            + "untrusted virtual display: " + displayId);
                }

                mDisplayWindowSettings.setShouldShowSystemDecorsLocked(displayContent, shouldShow);

                displayContent.reconfigureDisplayLocked();
            }
        } finally {
            Binder.restoreCallingIdentity(origId);
        }
    }

    @Override
@@ -6882,13 +6890,13 @@ public class WindowManagerService extends IWindowManager.Stub
        if (!checkCallingPermission(INTERNAL_SYSTEM_WINDOW, "setShouldShowIme()")) {
            throw new SecurityException("Requires INTERNAL_SYSTEM_WINDOW permission");
        }

        final long origId = Binder.clearCallingIdentity();
        try {
            synchronized (mGlobalLock) {
                final DisplayContent displayContent = getDisplayContentOrCreate(displayId, null);
                if (displayContent == null) {
                ProtoLog.w(WM_ERROR,
                        "Attempted to set IME flag to a display that does not exist: %d",
                        displayId);
                    ProtoLog.w(WM_ERROR, "Attempted to set IME flag to a display that does not "
                            + "exist: %d", displayId);
                    return;
                }
                if (displayContent.isUntrustedVirtualDisplay()) {
@@ -6900,6 +6908,9 @@ public class WindowManagerService extends IWindowManager.Stub

                displayContent.reconfigureDisplayLocked();
            }
        } finally {
            Binder.restoreCallingIdentity(origId);
        }
    }

    @Override