diff options
6 files changed, 32 insertions, 24 deletions
diff --git a/core/java/android/hardware/LegacySensorManager.java b/core/java/android/hardware/LegacySensorManager.java index f95909385fb9..f5cf3f74bc38 100644 --- a/core/java/android/hardware/LegacySensorManager.java +++ b/core/java/android/hardware/LegacySensorManager.java @@ -16,6 +16,8 @@ package android.hardware; +import static android.view.Display.DEFAULT_DISPLAY; + import android.os.RemoteException; import android.os.ServiceManager; import android.view.IRotationWatcher; @@ -57,8 +59,7 @@ final class LegacySensorManager { public void onRotationChanged(int rotation) { LegacySensorManager.onRotationChanged(rotation); } - } - ); + }, DEFAULT_DISPLAY); } catch (RemoteException e) { } } diff --git a/core/java/android/view/IWindowManager.aidl b/core/java/android/view/IWindowManager.aidl index 27c6d08d91b5..586b3b225fef 100644 --- a/core/java/android/view/IWindowManager.aidl +++ b/core/java/android/view/IWindowManager.aidl @@ -209,10 +209,10 @@ interface IWindowManager int getDefaultDisplayRotation(); /** - * Watch the rotation of the screen. Returns the current rotation, + * Watch the rotation of the specified screen. Returns the current rotation, * calls back when it changes. */ - int watchRotation(IRotationWatcher watcher); + int watchRotation(IRotationWatcher watcher, int displayId); /** * Remove a rotation watcher set using watchRotation. diff --git a/core/java/com/android/internal/policy/PhoneWindow.java b/core/java/com/android/internal/policy/PhoneWindow.java index 804bd29da796..6c9280a1ea25 100644 --- a/core/java/com/android/internal/policy/PhoneWindow.java +++ b/core/java/com/android/internal/policy/PhoneWindow.java @@ -3585,7 +3585,8 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { synchronized (mWindows) { if (!mIsWatching) { try { - WindowManagerHolder.sWindowManager.watchRotation(this); + WindowManagerHolder.sWindowManager.watchRotation(this, + phoneWindow.getContext().getDisplay().getDisplayId()); mHandler = new Handler(); mIsWatching = true; } catch (RemoteException ex) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java index 99f8aafafdf5..8a3c4e3b7d76 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java @@ -142,7 +142,7 @@ public class NavigationBarFragment extends Fragment implements Callbacks { try { WindowManagerGlobal.getWindowManagerService() - .watchRotation(mRotationWatcher); + .watchRotation(mRotationWatcher, getContext().getDisplay().getDisplayId()); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index b3414aeb1df0..f9c4efd17fc1 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -533,13 +533,17 @@ public class WindowManagerService extends IWindowManager.Stub } class RotationWatcher { - IRotationWatcher watcher; - IBinder.DeathRecipient deathRecipient; - RotationWatcher(IRotationWatcher w, IBinder.DeathRecipient d) { - watcher = w; - deathRecipient = d; + IRotationWatcher mWatcher; + IBinder.DeathRecipient mDeathRecipient; + int mDisplayId; + RotationWatcher(IRotationWatcher watcher, IBinder.DeathRecipient deathRecipient, + int displayId) { + mWatcher = watcher; + mDeathRecipient = deathRecipient; + mDisplayId = displayId; } } + ArrayList<RotationWatcher> mRotationWatchers = new ArrayList<>(); int mDeferredRotationPauseCount; @@ -4075,10 +4079,13 @@ public class WindowManagerService extends IWindowManager.Stub mH.sendEmptyMessageDelayed(H.SEAMLESS_ROTATION_TIMEOUT, SEAMLESS_ROTATION_TIMEOUT_DURATION); } - for (int i=mRotationWatchers.size()-1; i>=0; i--) { - try { - mRotationWatchers.get(i).watcher.onRotationChanged(rotation); - } catch (RemoteException e) { + for (int i = mRotationWatchers.size() - 1; i >= 0; i--) { + final RotationWatcher rotationWatcher = mRotationWatchers.get(i); + if (rotationWatcher.mDisplayId == displayId) { + try { + rotationWatcher.mWatcher.onRotationChanged(rotation); + } catch (RemoteException e) { + } } } @@ -4106,16 +4113,16 @@ public class WindowManagerService extends IWindowManager.Stub } @Override - public int watchRotation(IRotationWatcher watcher) { + public int watchRotation(IRotationWatcher watcher, int displayId) { final IBinder watcherBinder = watcher.asBinder(); IBinder.DeathRecipient dr = new IBinder.DeathRecipient() { @Override public void binderDied() { synchronized (mWindowMap) { for (int i=0; i<mRotationWatchers.size(); i++) { - if (watcherBinder == mRotationWatchers.get(i).watcher.asBinder()) { + if (watcherBinder == mRotationWatchers.get(i).mWatcher.asBinder()) { RotationWatcher removed = mRotationWatchers.remove(i); - IBinder binder = removed.watcher.asBinder(); + IBinder binder = removed.mWatcher.asBinder(); if (binder != null) { binder.unlinkToDeath(this, 0); } @@ -4129,12 +4136,11 @@ public class WindowManagerService extends IWindowManager.Stub synchronized (mWindowMap) { try { watcher.asBinder().linkToDeath(dr, 0); - mRotationWatchers.add(new RotationWatcher(watcher, dr)); + mRotationWatchers.add(new RotationWatcher(watcher, dr, displayId)); } catch (RemoteException e) { // Client died, no cleanup needed. } - // TODO(multi-display): Modify rotation watchers to include display id. return getDefaultDisplayRotation(); } } @@ -4145,11 +4151,11 @@ public class WindowManagerService extends IWindowManager.Stub synchronized (mWindowMap) { for (int i=0; i<mRotationWatchers.size(); i++) { RotationWatcher rotationWatcher = mRotationWatchers.get(i); - if (watcherBinder == rotationWatcher.watcher.asBinder()) { + if (watcherBinder == rotationWatcher.mWatcher.asBinder()) { RotationWatcher removed = mRotationWatchers.remove(i); - IBinder binder = removed.watcher.asBinder(); + IBinder binder = removed.mWatcher.asBinder(); if (binder != null) { - binder.unlinkToDeath(removed.deathRecipient, 0); + binder.unlinkToDeath(removed.mDeathRecipient, 0); } i--; } diff --git a/tools/layoutlib/bridge/src/android/view/IWindowManagerImpl.java b/tools/layoutlib/bridge/src/android/view/IWindowManagerImpl.java index fb90ce0b6285..1282349dc40f 100644 --- a/tools/layoutlib/bridge/src/android/view/IWindowManagerImpl.java +++ b/tools/layoutlib/bridge/src/android/view/IWindowManagerImpl.java @@ -399,7 +399,7 @@ public class IWindowManagerImpl implements IWindowManager { } @Override - public int watchRotation(IRotationWatcher arg0) throws RemoteException { + public int watchRotation(IRotationWatcher arg0, int arg1) throws RemoteException { // TODO Auto-generated method stub return 0; } |