diff options
| author | 2023-01-03 16:16:10 +0000 | |
|---|---|---|
| committer | 2023-01-06 08:51:46 +0000 | |
| commit | 5ffbb10f6e5a4012fcf2dfbf4c0589f3cedba3a4 (patch) | |
| tree | 2a75ed7e5af4159741a543c57adebd7e398d6dee | |
| parent | 7de5897932275af2223de287ee0b1134bf6f6991 (diff) | |
Check for valid last reported deviceId when starting service
If last reported virtual deviceId has been removed/closed since
the latest activity was started, updateDeviceId would throw an
exception due to the deviceId being invalid.
Bug: 264250568
Test: atest DeviceAssociationTest
Change-Id: I5f57c0361f76646001cc606e819969b0114946f7
| -rw-r--r-- | core/java/android/app/ActivityThread.java | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java index afd8a52d43ce..7370280add2b 100644 --- a/core/java/android/app/ActivityThread.java +++ b/core/java/android/app/ActivityThread.java @@ -4558,7 +4558,11 @@ public final class ActivityThread extends ClientTransactionHandler service.attach(context, this, data.info.name, data.token, app, ActivityManager.getService()); if (!service.isUiContext()) { // WindowProviderService is a UI Context. - service.updateDeviceId(mLastReportedDeviceId); + VirtualDeviceManager vdm = context.getSystemService(VirtualDeviceManager.class); + if (mLastReportedDeviceId == VirtualDeviceManager.DEVICE_ID_DEFAULT + || vdm.isValidVirtualDeviceId(mLastReportedDeviceId)) { + service.updateDeviceId(mLastReportedDeviceId); + } } service.onCreate(); mServicesData.put(data.token, data); |