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

Commit 5aeb0853 authored by Chad Brubaker's avatar Chad Brubaker Committed by Gerrit Code Review
Browse files

Merge "Enforce tag types in KeymasterArgument classes"

parents 7506f499 534bf9c2
Loading
Loading
Loading
Loading
+7 −0
Original line number Original line Diff line number Diff line
@@ -27,6 +27,13 @@ class KeymasterBlobArgument extends KeymasterArgument {


    public KeymasterBlobArgument(int tag, byte[] blob) {
    public KeymasterBlobArgument(int tag, byte[] blob) {
        super(tag);
        super(tag);
        switch (KeymasterDefs.getTagType(tag)) {
            case KeymasterDefs.KM_BIGNUM:
            case KeymasterDefs.KM_BYTES:
                break; // OK.
            default:
                throw new IllegalArgumentException("Bad blob tag " + tag);
        }
        this.blob = blob;
        this.blob = blob;
    }
    }


+6 −0
Original line number Original line Diff line number Diff line
@@ -29,6 +29,12 @@ class KeymasterBooleanArgument extends KeymasterArgument {


    public KeymasterBooleanArgument(int tag) {
    public KeymasterBooleanArgument(int tag) {
        super(tag);
        super(tag);
        switch (KeymasterDefs.getTagType(tag)) {
            case KeymasterDefs.KM_BOOL:
                break; // OK.
            default:
                throw new IllegalArgumentException("Bad bool tag " + tag);
        }
    }
    }


    public KeymasterBooleanArgument(int tag, Parcel in) {
    public KeymasterBooleanArgument(int tag, Parcel in) {
+6 −0
Original line number Original line Diff line number Diff line
@@ -29,6 +29,12 @@ class KeymasterDateArgument extends KeymasterArgument {


    public KeymasterDateArgument(int tag, Date date) {
    public KeymasterDateArgument(int tag, Date date) {
        super(tag);
        super(tag);
        switch (KeymasterDefs.getTagType(tag)) {
            case KeymasterDefs.KM_DATE:
                break; // OK.
            default:
                throw new IllegalArgumentException("Bad date tag " + tag);
        }
        this.date = date;
        this.date = date;
    }
    }


+9 −0
Original line number Original line Diff line number Diff line
@@ -27,6 +27,15 @@ class KeymasterIntArgument extends KeymasterArgument {


    public KeymasterIntArgument(int tag, int value) {
    public KeymasterIntArgument(int tag, int value) {
        super(tag);
        super(tag);
        switch (KeymasterDefs.getTagType(tag)) {
            case KeymasterDefs.KM_INT:
            case KeymasterDefs.KM_INT_REP:
            case KeymasterDefs.KM_ENUM:
            case KeymasterDefs.KM_ENUM_REP:
                break; // OK.
            default:
                throw new IllegalArgumentException("Bad int tag " + tag);
        }
        this.value = value;
        this.value = value;
    }
    }


+6 −0
Original line number Original line Diff line number Diff line
@@ -27,6 +27,12 @@ class KeymasterLongArgument extends KeymasterArgument {


    public KeymasterLongArgument(int tag, long value) {
    public KeymasterLongArgument(int tag, long value) {
        super(tag);
        super(tag);
        switch (KeymasterDefs.getTagType(tag)) {
            case KeymasterDefs.KM_LONG:
                break; // OK.
            default:
                throw new IllegalArgumentException("Bad long tag " + tag);
        }
        this.value = value;
        this.value = value;
    }
    }