OSDN Git Service

Make all calls go through mExecutor
authorJorim Jaggi <jjaggi@google.com>
Wed, 11 Nov 2015 15:25:50 +0000 (16:25 +0100)
committerJorim Jaggi <jjaggi@google.com>
Wed, 11 Nov 2015 17:06:09 +0000 (17:06 +0000)
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

packages/SystemUI/src/com/android/systemui/stackdivider/WindowManagerProxy.java

index 94809bc..0d3f803 100644 (file)
@@ -49,8 +49,29 @@ 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);
+            }
+        }
+    };
+
+    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);
+            }
+        }
+    };
+
+    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);
             }
@@ -65,27 +86,24 @@ public class WindowManagerProxy {
     }
 
     public void dismissDockedStack() {
-        try {
-            ActivityManagerNative.getDefault().removeStack(DOCKED_STACK_ID);
-        } catch (RemoteException e) {
-            Log.w(TAG, "Failed to remove stack: " + e);
-        }
+        mExecutor.execute(mDismissRunnable);
     }
 
     public void maximizeDockedStack() {
-        try {
-            ActivityManagerNative.getDefault().resizeStack(DOCKED_STACK_ID, null, true);
-        } catch (RemoteException e) {
-            Log.w(TAG, "Failed to resize stack: " + e);
-        }
+        mExecutor.execute(mMaximizeRunnable);
     }
 
-    public void setResizing(boolean resizing) {
-        try {
-            WindowManagerGlobal.getWindowManagerService().setDockedStackResizing(resizing);
-        } catch (RemoteException e) {
-            Log.w(TAG, "Error calling setDockedStackResizing: " + e);
-        }
+    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() {