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

Commit e3c22e22 authored by Hongguang Chen's avatar Hongguang Chen
Browse files

Skip devices with multiple bits set.

aosp/1399204 added AUDIO_DEVICE_OUT_BLE_SPEAKER whose value is
0x20000001. The buildCommonTypesStructureFile.py didn't cover that kind
of values and it caused audioserver crashed.

This CL skips that kind of devices. A general solution (b/168065706)
should be addressed in the configurable audio policy and parameter
framework.

BUG: 167745916
Test: Check PolicySubsystem-CommonTypes.xml and boot up device.
Change-Id: Id802d37c18c4fd152a84a5a1579390b464c505f1
parent 8028dfb9
Loading
Loading
Loading
Loading
+14 −6
Original line number Diff line number Diff line
@@ -52,13 +52,19 @@ def parseArgs():
def findBitPos(decimal):
    pos = 0
    i = 1
    while i != decimal:
    while i < decimal:
        i = i << 1
        pos = pos + 1
        if pos == 32:
            return -1
    return pos

    # TODO: b/168065706. This is just to fix the build. That the problem of devices with
    # multiple bits set must be addressed more generally in the configurable audio policy
    # and parameter framework.
    if i > decimal:
        logging.info("Device:{} which has multiple bits set is skipped. b/168065706".format(decimal))
        return -2
    return pos

def generateXmlStructureFile(componentTypeDict, structureTypesFile, outputFile):

@@ -74,10 +80,12 @@ def generateXmlStructureFile(componentTypeDict, structureTypesFile, outputFile):
                if bitparameters_node is not None:
                    ordered_values = OrderedDict(sorted(values_dict.items(), key=lambda x: x[1]))
                    for key, value in ordered_values.items():
                        pos = findBitPos(value)
                        if pos >= 0:
                            value_node = ET.SubElement(bitparameters_node, "BitParameter")
                            value_node.set('Name', key)
                            value_node.set('Size', "1")
                        value_node.set('Pos', str(findBitPos(value)))
                            value_node.set('Pos', str(pos))

                enum_parameter_node = component_type.find("EnumParameter")
                if enum_parameter_node is not None: