Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0d1f40b4 authored by Ricki Hirner's avatar Ricki Hirner
Browse files

Use RPC/AIDL instead of Messenger

parent 38a5c2a0
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -47,8 +47,8 @@ android {
dependencies {
    compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"

    compile 'com.android.support:appcompat-v7:27.0.0'
    compile 'com.android.support:cardview-v7:27.0.0'
    compile 'com.android.support:appcompat-v7:27.0.1'
    compile 'com.android.support:cardview-v7:27.0.1'

    //noinspection GradleDynamicVersion
    androidTestCompile 'com.android.support.test:runner:+'
+11 −12
Original line number Diff line number Diff line
@@ -46,11 +46,11 @@ public class CustomCertManagerTest {

    Messenger service;

    static X509Certificate[] siteCerts;
    private static X509Certificate[] siteCerts;
    static {
        try {
            siteCerts = getSiteCertificates(new URL("https://davdroid.bitfire.at"));
        } catch(IOException e) {
            siteCerts = getSiteCertificates(new URL("https://www.davdroid.com"));
        } catch(IOException ignored) {
        }
        assertNotNull(siteCerts);
    }
@@ -62,15 +62,14 @@ public class CustomCertManagerTest {
        // loop required because of https://code.google.com/p/android/issues/detail?id=180396
        IBinder binder = bindService(CustomCertService.class);
        assertNotNull(binder);
        service = new Messenger(binder);

        certManager = new CustomCertManager(getContext(), true, service);
        CustomCertManager.resetCertificates(getContext());

        certManager = new CustomCertManager(getContext(), false);
        assertNotNull(certManager);
        certManager.resetCertificates(getContext());

        paranoidCertManager = new CustomCertManager(getContext(), false, service);
        paranoidCertManager = new CustomCertManager(getContext(), false, false);
        assertNotNull(paranoidCertManager);
        paranoidCertManager.resetCertificates(getContext());
    }

    @After
@@ -101,7 +100,7 @@ public class CustomCertManagerTest {
        paranoidCertManager.checkServerTrusted(siteCerts, "RSA");
    }

    // fails randomly (in about 1 of 3 cases) for unknown reason:
    // fails randomly for unknown reason:
    @Test(expected = CertificateException.class)
    public void testRemoveCustomCertificate() throws CertificateException, TimeoutException, InterruptedException {
        addCustomCertificate();
@@ -110,17 +109,17 @@ public class CustomCertManagerTest {
        // should now be rejected for the whole session, i.e. no timeout anymore
        Intent intent = new Intent(getContext(), CustomCertService.class);
        intent.setAction(CustomCertService.CMD_CERTIFICATION_DECISION);
        intent.putExtra(CustomCertService.EXTRA_CERTIFICATE, siteCerts[0]);
        intent.putExtra(CustomCertService.EXTRA_CERTIFICATE, siteCerts[0].getEncoded());
        intent.putExtra(CustomCertService.EXTRA_TRUSTED, false);
        startService(intent, CustomCertService.class);
        paranoidCertManager.checkServerTrusted(siteCerts, "RSA");
    }

    private void addCustomCertificate() throws TimeoutException, InterruptedException {
    private void addCustomCertificate() throws CertificateException, TimeoutException, InterruptedException {
        // add certificate and check again
        Intent intent = new Intent(getContext(), CustomCertService.class);
        intent.setAction(CustomCertService.CMD_CERTIFICATION_DECISION);
        intent.putExtra(CustomCertService.EXTRA_CERTIFICATE, siteCerts[0]);
        intent.putExtra(CustomCertService.EXTRA_CERTIFICATE, siteCerts[0].getEncoded());
        intent.putExtra(CustomCertService.EXTRA_TRUSTED, true);
        startService(intent, CustomCertService.class);
    }
+10 −0
Original line number Diff line number Diff line
package at.bitfire.cert4android;

import at.bitfire.cert4android.IOnCertificateDecision;

interface ICustomCertService {

    void checkTrusted(in byte[] cert, boolean interactive, boolean foreground, IOnCertificateDecision callback);
    void abortCheck(IOnCertificateDecision callback);

}
+8 −0
Original line number Diff line number Diff line
package at.bitfire.cert4android;

interface IOnCertificateDecision {

    void accept();
    void reject();

}
+1 −1
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@ import java.util.logging.Logger

object Constants {

    private val TAG = "cert4android"
    val TAG = "cert4android"

    @JvmField
    var log: Logger = Logger.getLogger(TAG)
Loading