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

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

Merge "Support KM_LONG_REP"

parents 499126c4 b543b393
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ abstract class KeymasterArgument implements Parcelable {
                        case KeymasterDefs.KM_INT_REP:
                            return new KeymasterIntArgument(tag, in);
                        case KeymasterDefs.KM_LONG:
                        case KeymasterDefs.KM_LONG_REP:
                            return new KeymasterLongArgument(tag, in);
                        case KeymasterDefs.KM_DATE:
                            return new KeymasterDateArgument(tag, in);
+26 −2
Original line number Diff line number Diff line
@@ -63,6 +63,12 @@ public class KeymasterArguments implements Parcelable {
        }
    }

    public void addLongs(int tag, long... values) {
        for (long value : values) {
            addLong(tag, value);
        }
    }

    public void addBoolean(int tag) {
        mArguments.add(new KeymasterBooleanArgument(tag));
    }
@@ -111,7 +117,12 @@ public class KeymasterArguments implements Parcelable {
    }

    public long getLong(int tag, long defaultValue) {
        if (KeymasterDefs.getTagType(tag) != KeymasterDefs.KM_LONG) {
        switch (KeymasterDefs.getTagType(tag)) {
            case KeymasterDefs.KM_LONG:
                break; // Accepted type
            case KeymasterDefs.KM_LONG_REP:
                throw new IllegalArgumentException("Repeatable tags must use getLongs: " + tag);
            default:
                throw new IllegalArgumentException("Tag is not a long type: " + tag);
        }
        KeymasterArgument arg = getArgumentByTag(tag);
@@ -175,6 +186,19 @@ public class KeymasterArguments implements Parcelable {
        return values;
    }

    public List<Long> getLongs(int tag) {
        if (KeymasterDefs.getTagType(tag) != KeymasterDefs.KM_LONG_REP) {
            throw new IllegalArgumentException("Tag is not a repeating long: " + tag);
        }
        List<Long> values = new ArrayList<Long>();
        for (KeymasterArgument arg : mArguments) {
            if (arg.tag == tag) {
                values.add(((KeymasterLongArgument) arg).value);
            }
        }
        return values;
    }

    public int size() {
        return mArguments.size();
    }
+1 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ class KeymasterLongArgument extends KeymasterArgument {
        super(tag);
        switch (KeymasterDefs.getTagType(tag)) {
            case KeymasterDefs.KM_LONG:
            case KeymasterDefs.KM_LONG_REP:
                break; // OK.
            default:
                throw new IllegalArgumentException("Bad long tag " + tag);