List of usage examples for android.app.admin DevicePolicyManager installCaCert
public boolean installCaCert(@Nullable ComponentName admin, byte[] certBuffer)
From source file:com.afwsamples.testdpc.common.Util.java
/** * @return If the certificate was successfully installed. */// w w w . j a v a 2 s. c o m public static boolean installCaCertificate(InputStream certificateInputStream, DevicePolicyManager dpm, ComponentName admin) { try { if (certificateInputStream != null) { ByteArrayOutputStream byteBuffer = new ByteArrayOutputStream(); byte[] buffer = new byte[DEFAULT_BUFFER_SIZE]; int len = 0; while ((len = certificateInputStream.read(buffer)) > 0) { byteBuffer.write(buffer, 0, len); } return dpm.installCaCert(admin, byteBuffer.toByteArray()); } } catch (IOException e) { Log.e(TAG, "installCaCertificate: ", e); } return false; }