Pass Window to DreamOverlayService when attached.

Previously, the DreamService would send the window
attributes to the DreamOverlayService. However, it is
possible that the Window isn't fully associated with
a token at this stage.

This change ensures the Window is only passed when
the token is ready, tracked by when the DecorView
is attached.

Bug: 204605351
Test: atest DreamOverlayTest
Change-Id: Ib1d25ba55edb648739aca22d861e9522102d0668
This commit is contained in:
Bryce Lee
2021-10-29 17:04:15 -07:00
parent 74e50739dd
commit bfc555ea4a

View File

@@ -1173,6 +1173,16 @@ public class DreamService extends Service implements Window.Callback {
@Override
public void onViewAttachedToWindow(View v) {
mDispatchAfterOnAttachedToWindow.run();
// Request the DreamOverlay be told to dream with dream's window parameters
// once the window has been attached.
mOverlayConnection.request(overlay -> {
try {
overlay.startDream(mWindow.getAttributes(), mOverlayCallback);
} catch (RemoteException e) {
Log.e(TAG, "could not send window attributes:" + e);
}
});
}
@Override
@@ -1185,16 +1195,6 @@ public class DreamService extends Service implements Window.Callback {
}
}
});
// Request the DreamOverlay be told to dream with dream's window parameters once the service
// has connected.
mOverlayConnection.request(overlay -> {
try {
overlay.startDream(mWindow.getAttributes(), mOverlayCallback);
} catch (RemoteException e) {
Log.e(TAG, "could not send window attributes:" + e);
}
});
}
private boolean getWindowFlagValue(int flag, boolean defaultValue) {