mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-27 19:22:14 -05:00
simplify OpenPgpServiceConnection
This commit is contained in:
parent
24454b9d88
commit
0657f9289a
@ -27,7 +27,6 @@ import android.os.IBinder;
|
|||||||
public class OpenPgpServiceConnection {
|
public class OpenPgpServiceConnection {
|
||||||
private Context mApplicationContext;
|
private Context mApplicationContext;
|
||||||
|
|
||||||
private boolean mBound;
|
|
||||||
private IOpenPgpService mService;
|
private IOpenPgpService mService;
|
||||||
private String mProviderPackageName;
|
private String mProviderPackageName;
|
||||||
|
|
||||||
@ -41,18 +40,16 @@ public class OpenPgpServiceConnection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isBound() {
|
public boolean isBound() {
|
||||||
return mBound;
|
return (mService != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ServiceConnection mServiceConnection = new ServiceConnection() {
|
private ServiceConnection mServiceConnection = new ServiceConnection() {
|
||||||
public void onServiceConnected(ComponentName name, IBinder service) {
|
public void onServiceConnected(ComponentName name, IBinder service) {
|
||||||
mService = IOpenPgpService.Stub.asInterface(service);
|
mService = IOpenPgpService.Stub.asInterface(service);
|
||||||
mBound = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onServiceDisconnected(ComponentName name) {
|
public void onServiceDisconnected(ComponentName name) {
|
||||||
mService = null;
|
mService = null;
|
||||||
mBound = false;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -63,7 +60,7 @@ public class OpenPgpServiceConnection {
|
|||||||
*/
|
*/
|
||||||
public boolean bindToService() {
|
public boolean bindToService() {
|
||||||
// if not already bound...
|
// if not already bound...
|
||||||
if (mService == null && !mBound) {
|
if (mService == null) {
|
||||||
try {
|
try {
|
||||||
Intent serviceIntent = new Intent();
|
Intent serviceIntent = new Intent();
|
||||||
serviceIntent.setAction(IOpenPgpService.class.getName());
|
serviceIntent.setAction(IOpenPgpService.class.getName());
|
||||||
|
Loading…
Reference in New Issue
Block a user