Merge "Fix leak of RemoteAccessibilityController through SurfacePackage." into tm-qpr-dev am: b2ba1a1b28
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/19154172 Change-Id: Ie61e1294f95c9dbb07b367b3b00d198f252f0b7e Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -24,6 +24,8 @@ import android.os.RemoteException;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.accessibility.IAccessibilityEmbeddedConnection;
|
import android.view.accessibility.IAccessibilityEmbeddedConnection;
|
||||||
|
|
||||||
|
import java.lang.ref.WeakReference;
|
||||||
|
|
||||||
class RemoteAccessibilityController {
|
class RemoteAccessibilityController {
|
||||||
private static final String TAG = "RemoteAccessibilityController";
|
private static final String TAG = "RemoteAccessibilityController";
|
||||||
private int mHostId;
|
private int mHostId;
|
||||||
@@ -80,12 +82,17 @@ class RemoteAccessibilityController {
|
|||||||
/**
|
/**
|
||||||
* Wrapper of accessibility embedded connection for embedded view hierarchy.
|
* Wrapper of accessibility embedded connection for embedded view hierarchy.
|
||||||
*/
|
*/
|
||||||
private final class RemoteAccessibilityEmbeddedConnection implements IBinder.DeathRecipient {
|
private static final class RemoteAccessibilityEmbeddedConnection
|
||||||
|
implements IBinder.DeathRecipient {
|
||||||
|
private final WeakReference<RemoteAccessibilityController> mController;
|
||||||
private final IAccessibilityEmbeddedConnection mConnection;
|
private final IAccessibilityEmbeddedConnection mConnection;
|
||||||
private final IBinder mLeashToken;
|
private final IBinder mLeashToken;
|
||||||
|
|
||||||
RemoteAccessibilityEmbeddedConnection(IAccessibilityEmbeddedConnection connection,
|
RemoteAccessibilityEmbeddedConnection(
|
||||||
|
RemoteAccessibilityController controller,
|
||||||
|
IAccessibilityEmbeddedConnection connection,
|
||||||
IBinder leashToken) {
|
IBinder leashToken) {
|
||||||
|
mController = new WeakReference<>(controller);
|
||||||
mConnection = connection;
|
mConnection = connection;
|
||||||
mLeashToken = leashToken;
|
mLeashToken = leashToken;
|
||||||
}
|
}
|
||||||
@@ -109,9 +116,13 @@ class RemoteAccessibilityController {
|
|||||||
@Override
|
@Override
|
||||||
public void binderDied() {
|
public void binderDied() {
|
||||||
unlinkToDeath();
|
unlinkToDeath();
|
||||||
runOnUiThread(() -> {
|
RemoteAccessibilityController controller = mController.get();
|
||||||
if (mConnectionWrapper == this) {
|
if (controller == null) {
|
||||||
mConnectionWrapper = null;
|
return;
|
||||||
|
}
|
||||||
|
controller.runOnUiThread(() -> {
|
||||||
|
if (controller.mConnectionWrapper == this) {
|
||||||
|
controller.mConnectionWrapper = null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -128,7 +139,7 @@ class RemoteAccessibilityController {
|
|||||||
}
|
}
|
||||||
if (connection != null && leashToken != null) {
|
if (connection != null && leashToken != null) {
|
||||||
mConnectionWrapper =
|
mConnectionWrapper =
|
||||||
new RemoteAccessibilityEmbeddedConnection(connection, leashToken);
|
new RemoteAccessibilityEmbeddedConnection(this, connection, leashToken);
|
||||||
mConnectionWrapper.linkToDeath();
|
mConnectionWrapper.linkToDeath();
|
||||||
}
|
}
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user