mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-11 11:35:07 -05:00
Callback for OpenPgpServiceConnection
This commit is contained in:
parent
0657f9289a
commit
97e0b8d0c3
@ -25,16 +25,46 @@ import android.content.ServiceConnection;
|
|||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
|
|
||||||
public class OpenPgpServiceConnection {
|
public class OpenPgpServiceConnection {
|
||||||
|
|
||||||
|
// interface to create callbacks for onServiceConnected
|
||||||
|
public interface OnBound {
|
||||||
|
public void onBound(IOpenPgpService service);
|
||||||
|
}
|
||||||
|
|
||||||
private Context mApplicationContext;
|
private Context mApplicationContext;
|
||||||
|
|
||||||
private IOpenPgpService mService;
|
private IOpenPgpService mService;
|
||||||
private String mProviderPackageName;
|
private String mProviderPackageName;
|
||||||
|
|
||||||
|
private OnBound mOnBoundListener;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create new OpenPgpServiceConnection
|
||||||
|
*
|
||||||
|
* @param context
|
||||||
|
* @param providerPackageName specify package name of OpenPGP provider,
|
||||||
|
* e.g., "org.sufficientlysecure.keychain"
|
||||||
|
*/
|
||||||
public OpenPgpServiceConnection(Context context, String providerPackageName) {
|
public OpenPgpServiceConnection(Context context, String providerPackageName) {
|
||||||
this.mApplicationContext = context.getApplicationContext();
|
this.mApplicationContext = context.getApplicationContext();
|
||||||
this.mProviderPackageName = providerPackageName;
|
this.mProviderPackageName = providerPackageName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create new OpenPgpServiceConnection
|
||||||
|
*
|
||||||
|
* @param context
|
||||||
|
* @param providerPackageName specify package name of OpenPGP provider,
|
||||||
|
* e.g., "org.sufficientlysecure.keychain"
|
||||||
|
* @param onBoundListener callback, executed when connection to service has been established
|
||||||
|
*/
|
||||||
|
public OpenPgpServiceConnection(Context context, String providerPackageName,
|
||||||
|
OnBound onBoundListener) {
|
||||||
|
this.mApplicationContext = context.getApplicationContext();
|
||||||
|
this.mProviderPackageName = providerPackageName;
|
||||||
|
this.mOnBoundListener = onBoundListener;
|
||||||
|
}
|
||||||
|
|
||||||
public IOpenPgpService getService() {
|
public IOpenPgpService getService() {
|
||||||
return mService;
|
return mService;
|
||||||
}
|
}
|
||||||
@ -46,6 +76,9 @@ public class OpenPgpServiceConnection {
|
|||||||
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);
|
||||||
|
if (mOnBoundListener != null) {
|
||||||
|
mOnBoundListener.onBound(mService);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onServiceDisconnected(ComponentName name) {
|
public void onServiceDisconnected(ComponentName name) {
|
||||||
|
Loading…
Reference in New Issue
Block a user