diff options
author | Brian Carlstrom <bdc@google.com> | 2011-05-17 16:21:05 -0700 |
---|---|---|
committer | Brian Carlstrom <bdc@google.com> | 2011-05-17 16:21:05 -0700 |
commit | ead4057af45c80af262613d93abd85c49ef98db2 (patch) | |
tree | 7604e2fed4a84558a105944cc6ad1659ba16bd7c /src | |
parent | 30389d0148993679892385e007596a56ed46b6ac (diff) | |
download | android_packages_apps_CertInstaller-ead4057af45c80af262613d93abd85c49ef98db2.tar.gz android_packages_apps_CertInstaller-ead4057af45c80af262613d93abd85c49ef98db2.tar.bz2 android_packages_apps_CertInstaller-ead4057af45c80af262613d93abd85c49ef98db2.zip |
Move to KeyChain.bind
Change-Id: I7040a855705b72fcf5d7477db279affa6009bc72
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/certinstaller/CertInstaller.java | 31 |
1 files changed, 8 insertions, 23 deletions
diff --git a/src/com/android/certinstaller/CertInstaller.java b/src/com/android/certinstaller/CertInstaller.java index eb78b73..b537677 100644 --- a/src/com/android/certinstaller/CertInstaller.java +++ b/src/com/android/certinstaller/CertInstaller.java @@ -31,6 +31,8 @@ import android.os.Bundle; import android.os.IBinder; import android.security.Credentials; import android.security.KeyStore; +import android.security.KeyChain; +import android.security.KeyChain.KeyChainConnection; import android.security.IKeyChainService; import android.text.TextUtils; import android.util.Log; @@ -200,33 +202,16 @@ public class CertInstaller extends Activity private class InstallCaCertsToKeyChainTask extends AsyncTask<Void, Void, Boolean> { @Override protected Boolean doInBackground(Void... unused) { - final BlockingQueue<IKeyChainService> q = new LinkedBlockingQueue<IKeyChainService>(1); - ServiceConnection keyChainServiceConnection = new ServiceConnection() { - @Override public void onServiceConnected(ComponentName name, IBinder service) { - try { - q.put(IKeyChainService.Stub.asInterface(service)); - } catch (InterruptedException e) { - throw new AssertionError(e); - } - } - @Override public void onServiceDisconnected(ComponentName name) {} - }; - boolean isBound = bindService(new Intent(IKeyChainService.class.getName()), - keyChainServiceConnection, - Context.BIND_AUTO_CREATE); - if (!isBound) { - Log.w(TAG, "could not bind to KeyChainService"); - return false; - } - IKeyChainService keyChainService; try { - keyChainService = q.take(); - return mCredentials.installCaCertsToKeyChain(keyChainService); + KeyChainConnection keyChainConnection = KeyChain.bind(CertInstaller.this); + try { + return mCredentials.installCaCertsToKeyChain(keyChainConnection.getService()); + } finally { + keyChainConnection.close(); + } } catch (InterruptedException e) { Thread.currentThread().interrupt(); return false; - } finally { - unbindService(keyChainServiceConnection); } } |