audio policy: fix combo device parsing

When parsing a device type entry in audio_policy.conf, do not
load device combos (e.g AUDIO_DEVICE_OUT_ALL_A2DP) in a single
DeviceDescriptor but create one descriptor for each device type
in the combo.

Bug: 24113912.
Change-Id: I3a7f43c7fc9cf516506bb3255dd2ed86564b7cd6
diff --git a/services/audiopolicy/common/managerdefinitions/src/ConfigParsingUtils.cpp b/services/audiopolicy/common/managerdefinitions/src/ConfigParsingUtils.cpp
index e3ff9ae..a3536e5 100644
--- a/services/audiopolicy/common/managerdefinitions/src/ConfigParsingUtils.cpp
+++ b/services/audiopolicy/common/managerdefinitions/src/ConfigParsingUtils.cpp
@@ -294,8 +294,15 @@
         if (strlen(devTag) != 0) {
             audio_devices_t type;
             if (DeviceConverter::fromString(devTag, type)) {
-                sp<DeviceDescriptor> dev = new DeviceDescriptor(type);
-                devices.add(dev);
+                uint32_t inBit = type & AUDIO_DEVICE_BIT_IN;
+                type &= ~AUDIO_DEVICE_BIT_IN;
+                while (type) {
+                  audio_devices_t singleType =
+                        inBit | (1 << (31 - __builtin_clz(type)));
+                    type &= ~singleType;
+                    sp<DeviceDescriptor> dev = new DeviceDescriptor(singleType);
+                    devices.add(dev);
+                }
             } else {
                 sp<DeviceDescriptor> deviceDesc =
                         declaredDevices.getDeviceFromTagName(String8(devTag));