mirror of
https://github.com/oxen-io/session-android.git
synced 2025-01-11 16:33:39 +00:00
Fix more leaked service connections
PassphraseRequiredMixin might check for a bound service at a time where the bind has been requested but the service connection has not been established yet, and therefore fail to call unbindService, leading to a leaked service connection. This fixes #1518.
This commit is contained in:
parent
0d35e2bfa9
commit
1ad54e7b88
@ -87,7 +87,7 @@ public class PassphraseRequiredMixin {
|
||||
}
|
||||
|
||||
private void removeServiceConnection(Context context) {
|
||||
if (this.serviceConnection != null && this.serviceConnection.isBound()) {
|
||||
if (this.serviceConnection != null) {
|
||||
context.unbindService(this.serviceConnection);
|
||||
}
|
||||
}
|
||||
@ -95,18 +95,14 @@ public class PassphraseRequiredMixin {
|
||||
private static class KeyCachingServiceConnection implements ServiceConnection {
|
||||
private final PassphraseRequiredActivity activity;
|
||||
|
||||
private boolean isBound;
|
||||
|
||||
public KeyCachingServiceConnection(PassphraseRequiredActivity activity) {
|
||||
this.activity = activity;
|
||||
this.isBound = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onServiceConnected(ComponentName name, IBinder service) {
|
||||
KeyCachingService keyCachingService = ((KeyCachingService.KeyCachingBinder)service).getService();
|
||||
MasterSecret masterSecret = keyCachingService.getMasterSecret();
|
||||
this.isBound = true;
|
||||
|
||||
if (masterSecret == null) {
|
||||
activity.onMasterSecretCleared();
|
||||
@ -117,12 +113,8 @@ public class PassphraseRequiredMixin {
|
||||
|
||||
@Override
|
||||
public void onServiceDisconnected(ComponentName name) {
|
||||
this.isBound = false;
|
||||
}
|
||||
|
||||
public boolean isBound() {
|
||||
return this.isBound;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package org.thoughtcrime.securesms.util;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Build;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import java.util.Locale;
|
||||
@ -21,15 +20,11 @@ public class DynamicLanguage {
|
||||
|
||||
public void onResume(Activity activity) {
|
||||
if (!currentLocale.equals(getSelectedLocale(activity))) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
|
||||
activity.recreate();
|
||||
} else {
|
||||
Intent intent = activity.getIntent();
|
||||
activity.finish();
|
||||
OverridePendingTransition.invoke(activity);
|
||||
activity.startActivity(intent);
|
||||
OverridePendingTransition.invoke(activity);
|
||||
}
|
||||
Intent intent = activity.getIntent();
|
||||
activity.finish();
|
||||
OverridePendingTransition.invoke(activity);
|
||||
activity.startActivity(intent);
|
||||
OverridePendingTransition.invoke(activity);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,6 @@ package org.thoughtcrime.securesms.util;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
import org.thoughtcrime.securesms.ApplicationPreferencesActivity;
|
||||
@ -21,15 +20,11 @@ public class DynamicTheme {
|
||||
|
||||
public void onResume(Activity activity) {
|
||||
if (currentTheme != getSelectedTheme(activity)) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
|
||||
activity.recreate();
|
||||
} else {
|
||||
Intent intent = activity.getIntent();
|
||||
activity.finish();
|
||||
OverridePendingTransition.invoke(activity);
|
||||
activity.startActivity(intent);
|
||||
OverridePendingTransition.invoke(activity);
|
||||
}
|
||||
Intent intent = activity.getIntent();
|
||||
activity.finish();
|
||||
OverridePendingTransition.invoke(activity);
|
||||
activity.startActivity(intent);
|
||||
OverridePendingTransition.invoke(activity);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user