Merge "Signal dream end to overlay in finish()." into tm-qpr-dev am: b9446e1ece
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/21131403 Change-Id: Id67209c5ac21c30a217fa7868ce2a19399ec7edd Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -1064,6 +1064,24 @@ public class DreamService extends Service implements Window.Callback {
|
|||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
public final void finish() {
|
public final void finish() {
|
||||||
|
// If there is an active overlay connection, signal that the dream is ending before
|
||||||
|
// continuing. Note that the overlay cannot rely on the unbound state, since another dream
|
||||||
|
// might have bound to it in the meantime.
|
||||||
|
if (mOverlayConnection != null) {
|
||||||
|
mOverlayConnection.addConsumer(overlay -> {
|
||||||
|
try {
|
||||||
|
overlay.endDream();
|
||||||
|
mOverlayConnection.unbind();
|
||||||
|
mOverlayConnection = null;
|
||||||
|
finish();
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
Log.e(mTag, "could not inform overlay of dream end:" + e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
mOverlayConnection.clearConsumers();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (mDebug) Slog.v(mTag, "finish(): mFinished=" + mFinished);
|
if (mDebug) Slog.v(mTag, "finish(): mFinished=" + mFinished);
|
||||||
|
|
||||||
Activity activity = mActivity;
|
Activity activity = mActivity;
|
||||||
@@ -1080,10 +1098,6 @@ public class DreamService extends Service implements Window.Callback {
|
|||||||
}
|
}
|
||||||
mFinished = true;
|
mFinished = true;
|
||||||
|
|
||||||
if (mOverlayConnection != null) {
|
|
||||||
mOverlayConnection.unbind();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mDreamToken == null) {
|
if (mDreamToken == null) {
|
||||||
if (mDebug) Slog.v(mTag, "finish() called when not attached.");
|
if (mDebug) Slog.v(mTag, "finish() called when not attached.");
|
||||||
stopSelf();
|
stopSelf();
|
||||||
@@ -1403,17 +1417,6 @@ public class DreamService extends Service implements Window.Callback {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onViewDetachedFromWindow(View v) {
|
public void onViewDetachedFromWindow(View v) {
|
||||||
if (mOverlayConnection != null) {
|
|
||||||
mOverlayConnection.addConsumer(overlay -> {
|
|
||||||
try {
|
|
||||||
overlay.endDream();
|
|
||||||
} catch (RemoteException e) {
|
|
||||||
Log.e(mTag, "could not inform overlay of dream end:" + e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
mOverlayConnection.clearConsumers();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mActivity == null || !mActivity.isChangingConfigurations()) {
|
if (mActivity == null || !mActivity.isChangingConfigurations()) {
|
||||||
// Only stop the dream if the view is not detached by relaunching
|
// Only stop the dream if the view is not detached by relaunching
|
||||||
// activity for configuration changes. It is important to also clear
|
// activity for configuration changes. It is important to also clear
|
||||||
@@ -1422,6 +1425,10 @@ public class DreamService extends Service implements Window.Callback {
|
|||||||
mActivity = null;
|
mActivity = null;
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mOverlayConnection != null && mDreamStartOverlayConsumer != null) {
|
||||||
|
mOverlayConnection.removeConsumer(mDreamStartOverlayConsumer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user