Publish DevicePolicyManager CA certificate APIs

Exposes these methods:
 - hasCaCertInstalled
 - hasAnyCaCertsInstalled
 - installCaCert
 - uninstallCaCert

Allows device and profile owners to perform some certificate management
including querying for and enabling/disabling specific CA certificates.

Change-Id: I4aa8a1a8601b234e30acde99dfa382e04cb62495
This commit is contained in:
Robin Lee
2014-06-11 16:19:43 +01:00
parent 1b8aef2be7
commit 837304f6f6
5 changed files with 74 additions and 51 deletions

View File

@ -23,7 +23,9 @@ import android.content.Intent;
import android.content.ServiceConnection;
import android.os.IBinder;
import android.os.Looper;
import android.os.Process;
import android.os.RemoteException;
import android.os.UserHandle;
import java.io.ByteArrayInputStream;
import java.io.Closeable;
import java.security.InvalidKeyException;
@ -437,6 +439,14 @@ public final class KeyChain {
* Caller should call unbindService on the result when finished.
*/
public static KeyChainConnection bind(Context context) throws InterruptedException {
return bindAsUser(context, Process.myUserHandle());
}
/**
* @hide
*/
public static KeyChainConnection bindAsUser(Context context, UserHandle user)
throws InterruptedException {
if (context == null) {
throw new NullPointerException("context == null");
}
@ -459,9 +469,10 @@ public final class KeyChain {
Intent intent = new Intent(IKeyChainService.class.getName());
ComponentName comp = intent.resolveSystemService(context.getPackageManager(), 0);
intent.setComponent(comp);
boolean isBound = context.bindService(intent,
keyChainServiceConnection,
Context.BIND_AUTO_CREATE);
boolean isBound = context.bindServiceAsUser(intent,
keyChainServiceConnection,
Context.BIND_AUTO_CREATE,
user);
if (!isBound) {
throw new AssertionError("could not bind to KeyChainService");
}