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

Commit 8b717e7a authored by Jorim Jaggi's avatar Jorim Jaggi
Browse files

Make all calls go through mExecutor

So we don't run into race conditions when both the main thread and
the executor thread are calling into window manager.

Bug: 25591212

Change-Id: I6d02170f6b105c9b7b861b6dfc4b76452632d562
parent 4310241a
Loading
Loading
Loading
Loading
+36 −18
Original line number Diff line number Diff line
@@ -49,44 +49,62 @@ public class WindowManagerProxy {
                mTmpRect.set(mResizeRect);
            }
            try {
                ActivityManagerNative.getDefault().resizeStack(DOCKED_STACK_ID,
                        mTmpRect, true);
                ActivityManagerNative.getDefault().resizeStack(DOCKED_STACK_ID, mTmpRect, true);
            } catch (RemoteException e) {
                Log.w(TAG, "Failed to resize stack: " + e);
            }
        }
    };

    public void resizeDockedStack(Rect rect) {
        synchronized (mResizeRect) {
            mResizeRect.set(rect);
        }
        mExecutor.execute(mResizeRunnable);
    }

    public void dismissDockedStack() {
    private final Runnable mDismissRunnable = new Runnable() {
        @Override
        public void run() {
            try {
                ActivityManagerNative.getDefault().removeStack(DOCKED_STACK_ID);
            } catch (RemoteException e) {
                Log.w(TAG, "Failed to remove stack: " + e);
            }
        }
    };

    public void maximizeDockedStack() {
    private final Runnable mMaximizeRunnable = new Runnable() {
        @Override
        public void run() {
            try {
                ActivityManagerNative.getDefault().resizeStack(DOCKED_STACK_ID, null, true);
            } catch (RemoteException e) {
                Log.w(TAG, "Failed to resize stack: " + e);
            }
        }
    };

    public void setResizing(boolean resizing) {
    public void resizeDockedStack(Rect rect) {
        synchronized (mResizeRect) {
            mResizeRect.set(rect);
        }
        mExecutor.execute(mResizeRunnable);
    }

    public void dismissDockedStack() {
        mExecutor.execute(mDismissRunnable);
    }

    public void maximizeDockedStack() {
        mExecutor.execute(mMaximizeRunnable);
    }

    public void setResizing(final boolean resizing) {
        mExecutor.execute(new Runnable() {
            @Override
            public void run() {
                try {
                    WindowManagerGlobal.getWindowManagerService().setDockedStackResizing(resizing);
                } catch (RemoteException e) {
                    Log.w(TAG, "Error calling setDockedStackResizing: " + e);
                }
            }
        });
    }

    public int getDockSide() {
        try {