Loading packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayService.java +38 −34 Original line number Diff line number Diff line Loading @@ -71,7 +71,7 @@ public class DreamOverlayService extends android.service.dreams.DreamOverlayServ // The service listens to view changes in order to declare that input occurring in areas outside // the overlay should be passed through to the dream underneath. private View.OnAttachStateChangeListener mRootViewAttachListener = private final View.OnAttachStateChangeListener mRootViewAttachListener = new View.OnAttachStateChangeListener() { @Override public void onViewAttachedToWindow(View v) { Loading @@ -82,13 +82,15 @@ public class DreamOverlayService extends android.service.dreams.DreamOverlayServ @Override public void onViewDetachedFromWindow(View v) { v.getViewTreeObserver() .removeOnComputeInternalInsetsListener(mOnComputeInternalInsetsListener); .removeOnComputeInternalInsetsListener( mOnComputeInternalInsetsListener); } }; // A hook into the internal inset calculation where we declare the overlays as the only // touchable regions. private ViewTreeObserver.OnComputeInternalInsetsListener mOnComputeInternalInsetsListener = private final ViewTreeObserver.OnComputeInternalInsetsListener mOnComputeInternalInsetsListener = new ViewTreeObserver.OnComputeInternalInsetsListener() { @Override public void onComputeInternalInsets(ViewTreeObserver.InternalInsetsInfo inoutInfo) { Loading Loading @@ -163,7 +165,9 @@ public class DreamOverlayService extends android.service.dreams.DreamOverlayServ } window.setContentView(mDreamOverlayComponent.getDreamOverlayContainerView()); mDreamOverlayContentView = mDreamOverlayComponent.getDreamOverlayContentView(); mDreamOverlayContentView.addOnAttachStateChangeListener(mRootViewAttachListener); mDreamOverlayComponent.getDreamOverlayStatusBarViewController().init(); Loading packages/SystemUI/tests/src/com/android/systemui/dreams/DreamOverlayServiceTest.java +16 −0 Original line number Diff line number Diff line Loading @@ -191,4 +191,20 @@ public class DreamOverlayServiceTest extends SysuiTestCase { verify(mDreamOverlayStatusBarViewController).init(); } @Test public void testRootViewAttachListenerIsAddedToDreamOverlayContentView() throws Exception { final DreamOverlayService service = new DreamOverlayService(mContext, mMainExecutor, mDreamOverlayStateController, mDreamOverlayStatusBarViewComponentFactory); final IBinder proxy = service.onBind(new Intent()); final IDreamOverlay overlay = IDreamOverlay.Stub.asInterface(proxy); // Inform the overlay service of dream starting. overlay.startDream(mWindowParams, mDreamOverlayCallback); mMainExecutor.runAllReady(); verify(mDreamOverlayContentView).addOnAttachStateChangeListener( any(View.OnAttachStateChangeListener.class)); } } Loading
packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayService.java +38 −34 Original line number Diff line number Diff line Loading @@ -71,7 +71,7 @@ public class DreamOverlayService extends android.service.dreams.DreamOverlayServ // The service listens to view changes in order to declare that input occurring in areas outside // the overlay should be passed through to the dream underneath. private View.OnAttachStateChangeListener mRootViewAttachListener = private final View.OnAttachStateChangeListener mRootViewAttachListener = new View.OnAttachStateChangeListener() { @Override public void onViewAttachedToWindow(View v) { Loading @@ -82,13 +82,15 @@ public class DreamOverlayService extends android.service.dreams.DreamOverlayServ @Override public void onViewDetachedFromWindow(View v) { v.getViewTreeObserver() .removeOnComputeInternalInsetsListener(mOnComputeInternalInsetsListener); .removeOnComputeInternalInsetsListener( mOnComputeInternalInsetsListener); } }; // A hook into the internal inset calculation where we declare the overlays as the only // touchable regions. private ViewTreeObserver.OnComputeInternalInsetsListener mOnComputeInternalInsetsListener = private final ViewTreeObserver.OnComputeInternalInsetsListener mOnComputeInternalInsetsListener = new ViewTreeObserver.OnComputeInternalInsetsListener() { @Override public void onComputeInternalInsets(ViewTreeObserver.InternalInsetsInfo inoutInfo) { Loading Loading @@ -163,7 +165,9 @@ public class DreamOverlayService extends android.service.dreams.DreamOverlayServ } window.setContentView(mDreamOverlayComponent.getDreamOverlayContainerView()); mDreamOverlayContentView = mDreamOverlayComponent.getDreamOverlayContentView(); mDreamOverlayContentView.addOnAttachStateChangeListener(mRootViewAttachListener); mDreamOverlayComponent.getDreamOverlayStatusBarViewController().init(); Loading
packages/SystemUI/tests/src/com/android/systemui/dreams/DreamOverlayServiceTest.java +16 −0 Original line number Diff line number Diff line Loading @@ -191,4 +191,20 @@ public class DreamOverlayServiceTest extends SysuiTestCase { verify(mDreamOverlayStatusBarViewController).init(); } @Test public void testRootViewAttachListenerIsAddedToDreamOverlayContentView() throws Exception { final DreamOverlayService service = new DreamOverlayService(mContext, mMainExecutor, mDreamOverlayStateController, mDreamOverlayStatusBarViewComponentFactory); final IBinder proxy = service.onBind(new Intent()); final IDreamOverlay overlay = IDreamOverlay.Stub.asInterface(proxy); // Inform the overlay service of dream starting. overlay.startDream(mWindowParams, mDreamOverlayCallback); mMainExecutor.runAllReady(); verify(mDreamOverlayContentView).addOnAttachStateChangeListener( any(View.OnAttachStateChangeListener.class)); } }