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

Commit 88273f1f authored by Khaled Abdelmohsen's avatar Khaled Abdelmohsen
Browse files

Handle atomic formula max value size

Bug: 143697198
Test: atest FrameworksServicesTests:RuleBinaryParserTest
Test: atest FrameworksServicesTests:RuleBinarySerializerTest
Change-Id: I6455e0c3a9964cec7618cd666bcda7599e92668e
parent 5382338e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@ public class BitOutputStream {
        int offset = 1 << (numOfBits - 1);
        while (numOfBits-- > 0) {
            mBitSet.set(mIndex, (value & offset) != 0);
            offset >>= 1;
            offset >>>= 1;
            mIndex++;
        }
    }
+1 −1
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@ public final class ComponentBitSize {
    public static final int OPERATOR_BITS = 3;
    public static final int CONNECTOR_BITS = 2;
    public static final int SEPARATOR_BITS = 2;
    public static final int VALUE_SIZE_BITS = 5;
    public static final int VALUE_SIZE_BITS = 6;
    public static final int IS_HASHED_BITS = 1;

    public static final int ATOMIC_FORMULA_START = 0;
+3 −0
Original line number Diff line number Diff line
@@ -179,6 +179,9 @@ public class RuleBinarySerializer implements RuleSerializer {

    private void serializeStringValue(
            String value, boolean isHashedValue, BitOutputStream bitOutputStream) {
        if (value == null) {
            throw new IllegalArgumentException("String value can not be null.");
        }
        byte[] valueBytes = getBytesForString(value, isHashedValue);

        bitOutputStream.setNext(isHashedValue);
+1 −1
Original line number Diff line number Diff line
@@ -305,7 +305,7 @@ public class RuleBinaryParserTest {

    @Test
    public void testBinaryString_validAtomicFormula_hashedValue() throws Exception {
        String appCertificate = "test_cert";
        String appCertificate = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
        String ruleBits =
                START_BIT
                        + ATOMIC_FORMULA_START_BITS
+1 −1
Original line number Diff line number Diff line
@@ -334,7 +334,7 @@ public class RuleBinarySerializerTest {

    @Test
    public void testBinaryString_serializeValidAtomicFormula_hashedValue() throws Exception {
        String appCertificate = "test_cert";
        String appCertificate = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
        Rule rule =
                new Rule(
                        new AtomicFormula.StringAtomicFormula(