Previously, the VirtualDisplayDevice delegated its cleanup to the
parent VirtualDisplayAdapter. The adapter looked up the device
from an AppToken mapping. It is possible for this mapping to not
include the token, leading to the device not being destroyed.
This changelist has the VirtualDisplayDevice take care of calling
destroy on itself. It still informs the adapter of this event for
bookkeeping/cleanup purposes.
Fixes:
26221019
Test: Verified through adb shell dumpsys activity activities that the
virtual displays were removed upon app kill after the
MediaProjection for these displays ended.
Change-Id: I500fdc87618632184f5d3c9821ccf1979f460595
}
private void handleBinderDiedLocked(IBinder appToken) {
- VirtualDisplayDevice device = mVirtualDisplayDevices.remove(appToken);
- if (device != null) {
- Slog.i(TAG, "Virtual display device released because application token died: "
- + device.mOwnerPackageName);
- device.destroyLocked(false);
- sendDisplayDeviceEventLocked(device, DISPLAY_DEVICE_EVENT_REMOVED);
- }
+ mVirtualDisplayDevices.remove(appToken);
}
private void handleMediaProjectionStoppedLocked(IBinder appToken) {
public void binderDied() {
synchronized (getSyncRoot()) {
handleBinderDiedLocked(mAppToken);
+ Slog.i(TAG, "Virtual display device released because application token died: "
+ + mOwnerPackageName);
+ destroyLocked(false);
+ sendDisplayDeviceEventLocked(this, DISPLAY_DEVICE_EVENT_REMOVED);
}
}