Update deviceId from server process when activity is destroyed am: c75f33a2bc

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/21469447

Change-Id: I5ccf4233a511792a9b18497fd90a7fa98befe5c6
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Marco Loaiza
2023-03-01 14:58:39 +00:00
committed by Automerger Merge Worker

View File

@@ -210,7 +210,7 @@ public class WindowProcessController extends ConfigurationContainer<Configuratio
/** Whether {@link #mLastReportedConfiguration} is deferred by the cached state. */ /** Whether {@link #mLastReportedConfiguration} is deferred by the cached state. */
private volatile boolean mHasCachedConfiguration; private volatile boolean mHasCachedConfiguration;
private int mTopActivityDeviceId = Context.DEVICE_ID_DEFAULT; private int mLastTopActivityDeviceId = Context.DEVICE_ID_DEFAULT;
/** /**
* Registered {@link DisplayArea} as a listener to override config changes. {@code null} if not * Registered {@link DisplayArea} as a listener to override config changes. {@code null} if not
* registered. * registered.
@@ -1411,8 +1411,9 @@ public class WindowProcessController extends ConfigurationContainer<Configuratio
// If deviceId for the top-activity changed, schedule passing it to the app process. // If deviceId for the top-activity changed, schedule passing it to the app process.
boolean topActivityDeviceChanged = false; boolean topActivityDeviceChanged = false;
int deviceId = getTopActivityDeviceId(); int deviceId = getTopActivityDeviceId();
if (deviceId != mTopActivityDeviceId) { if (deviceId != mLastTopActivityDeviceId) {
topActivityDeviceChanged = true; topActivityDeviceChanged = true;
mLastTopActivityDeviceId = deviceId;
} }
final Configuration config = getConfiguration(); final Configuration config = getConfiguration();
@@ -1431,15 +1432,13 @@ public class WindowProcessController extends ConfigurationContainer<Configuratio
return; return;
} }
// TODO(b/263402938): Add tests that capture the deviceId dispatch to the client. dispatchConfiguration(config, topActivityDeviceChanged ? mLastTopActivityDeviceId
mTopActivityDeviceId = deviceId;
dispatchConfiguration(config, topActivityDeviceChanged ? mTopActivityDeviceId
: Context.DEVICE_ID_INVALID); : Context.DEVICE_ID_INVALID);
} }
private int getTopActivityDeviceId() { private int getTopActivityDeviceId() {
ActivityRecord topActivity = getTopNonFinishingActivity(); ActivityRecord topActivity = getTopNonFinishingActivity();
int updatedDeviceId = mTopActivityDeviceId; int updatedDeviceId = Context.DEVICE_ID_DEFAULT;
if (topActivity != null && topActivity.mDisplayContent != null) { if (topActivity != null && topActivity.mDisplayContent != null) {
updatedDeviceId = mAtm.mTaskSupervisor.getDeviceIdForDisplayId( updatedDeviceId = mAtm.mTaskSupervisor.getDeviceIdForDisplayId(
topActivity.mDisplayContent.mDisplayId); topActivity.mDisplayContent.mDisplayId);