Merge pull request #1201 from emakar/fix-android-leak

[Android] fix leaking `MethodChannel` through anonymous class
This commit is contained in:
Lorenzo Pichilli 2022-10-13 15:36:18 +02:00 committed by GitHub
commit f573f8afe5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 7 deletions

View File

@ -168,13 +168,7 @@ public class ServiceWorkerManager implements MethodChannel.MethodCallHandler {
}
private ServiceWorkerClientCompat dummyServiceWorkerClientCompat() {
return new ServiceWorkerClientCompat() {
@Nullable
@Override
public WebResourceResponse shouldInterceptRequest(@NonNull WebResourceRequest request) {
return null;
}
};
return DummyServiceWorkerClientCompat.INSTANCE;
}
public void dispose() {
@ -185,4 +179,14 @@ public class ServiceWorkerManager implements MethodChannel.MethodCallHandler {
}
plugin = null;
}
private static final class DummyServiceWorkerClientCompat extends ServiceWorkerClientCompat {
static final ServiceWorkerClientCompat INSTANCE = new DummyServiceWorkerClientCompat();
@Nullable
@Override
public WebResourceResponse shouldInterceptRequest(@NonNull WebResourceRequest request) {
return null;
}
}
}