From b3bd37514e556ce477692e1450000864638f88ee Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 28 May 2022 20:39:53 +0200 Subject: [PATCH] Fixed PGP service leak --- app/src/main/java/eu/faircode/email/PgpHelper.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/PgpHelper.java b/app/src/main/java/eu/faircode/email/PgpHelper.java index b50ab9d1a6..d7f4fc48f9 100644 --- a/app/src/main/java/eu/faircode/email/PgpHelper.java +++ b/app/src/main/java/eu/faircode/email/PgpHelper.java @@ -119,7 +119,7 @@ public class PgpHelper { Log.i("PGP binding to " + pkg + " timeout=" + timeout); CountDownLatch latch = new CountDownLatch(1); - OpenPgpServiceConnection pgpService = new OpenPgpServiceConnection(context.getApplicationContext(), pkg, + OpenPgpServiceConnection pgpService = new OpenPgpServiceConnection(context, pkg, new OpenPgpServiceConnection.OnBound() { @Override public void onBound(IOpenPgpService2 service) { @@ -142,8 +142,14 @@ public class PgpHelper { } Log.i("PGP bound=" + pgpService.isBound()); - if (!pgpService.isBound()) + if (!pgpService.isBound()) { + try { + pgpService.unbindFromService(); + } catch (Throwable ex) { + Log.e(ex); + } throw new OperationCanceledException(); + } return pgpService; }