Fixed PGP test memory leak

pull/207/head
M66B 3 years ago
parent a04025b8d0
commit 5909df693c

@ -79,7 +79,8 @@ import java.util.Collections;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.List; import java.util.List;
public class FragmentOptionsEncryption extends FragmentBase implements SharedPreferences.OnSharedPreferenceChangeListener { public class FragmentOptionsEncryption extends FragmentBase
implements SharedPreferences.OnSharedPreferenceChangeListener, OpenPgpServiceConnection.OnBound {
private ImageButton ibInfo; private ImageButton ibInfo;
private SwitchCompat swSign; private SwitchCompat swSign;
private SwitchCompat swEncrypt; private SwitchCompat swEncrypt;
@ -613,14 +614,21 @@ public class FragmentOptionsEncryption extends FragmentBase implements SharedPre
if (pgpService != null && pgpService.isBound()) if (pgpService != null && pgpService.isBound())
pgpService.unbindFromService(); pgpService.unbindFromService();
tvOpenPgpStatus.setText("Connecting to " + pkg); tvOpenPgpStatus.setText("Connecting");
pgpService = new OpenPgpServiceConnection(getContext(), pkg, new OpenPgpServiceConnection.OnBound() { pgpService = new OpenPgpServiceConnection(getContext(), pkg, this);
pgpService.bindToService();
} catch (Throwable ex) {
Log.e(ex);
tvOpenPgpStatus.setText(Log.formatThrowable(ex, false));
}
}
@Override @Override
public void onBound(IOpenPgpService2 service) { public void onBound(IOpenPgpService2 service) {
if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED))
return; return;
tvOpenPgpStatus.setText("Connected to " + pkg); tvOpenPgpStatus.setText("Connected");
} }
@Override @Override
@ -635,10 +643,4 @@ public class FragmentOptionsEncryption extends FragmentBase implements SharedPre
tvOpenPgpStatus.setText(ex.toString()); tvOpenPgpStatus.setText(ex.toString());
} }
} }
});
pgpService.bindToService();
} catch (Throwable ex) {
Log.e(ex);
}
}
} }

Loading…
Cancel
Save