Audio V4: bitfield enum now use the bitfield class

The audio HAL has lots of enums were each value is a specific bit
pattern (usually a single bit) and are expected to be used as a
combination of value (kind of like a bitfield).

Nevertheless the 2.0 methods only had the enums themselves in their
signatures which leads the HIDL API checkers to warn that invalid values
were passed.

Currently, there are no way to express a value which is a combination
of enum values. The closest thing is the bitfield type.

Thus transition all enums combination to bitfield.

Note that AudioDevice as NOT been transition systematically
as both the enums and the combination are meaningful:
 - the enum is one device
 - the combination is a list of device.

Test: none
Bug: 38184704
Change-Id: I155cf7bc5d88fc5cf8954903d55aa8d7ca458a4b
Signed-off-by: Kevin Rocard <krocard@google.com>
diff --git a/audio/4.0/IDevice.hal b/audio/4.0/IDevice.hal
index 23cf9fb..2f121c1 100644
--- a/audio/4.0/IDevice.hal
+++ b/audio/4.0/IDevice.hal
@@ -117,7 +117,7 @@
             AudioIoHandle ioHandle,
             DeviceAddress device,
             AudioConfig config,
-            AudioOutputFlag flags) generates (
+            bitfield<AudioOutputFlag> flags) generates (
                     Result retval,
                     IStreamOut outStream,
                     AudioConfig suggestedConfig);
@@ -140,7 +140,7 @@
             AudioIoHandle ioHandle,
             DeviceAddress device,
             AudioConfig config,
-            AudioInputFlag flags,
+            bitfield<AudioInputFlag> flags,
             AudioSource source) generates (
                     Result retval,
                     IStreamIn inStream,
diff --git a/audio/4.0/IStream.hal b/audio/4.0/IStream.hal
index 62b8d03..306152b 100644
--- a/audio/4.0/IStream.hal
+++ b/audio/4.0/IStream.hal
@@ -88,7 +88,7 @@
      *
      * @return mask channel mask.
      */
-    getChannelMask() generates (AudioChannelMask mask);
+    getChannelMask() generates (bitfield<AudioChannelMask> mask);
 
     /**
      * Return supported channel masks of the stream. Calling this method is
@@ -101,7 +101,7 @@
      * @return masks supported audio masks.
      */
     getSupportedChannelMasks(AudioFormat format)
-            generates (Result retval, vec<AudioChannelMask> masks);
+            generates (Result retval, vec<bitfield<AudioChannelMask>> masks);
 
     /**
      * Sets the channel mask of the stream. Calling this method is equivalent to
@@ -111,7 +111,7 @@
      * @param format audio format.
      * @return retval operation completion status.
      */
-    setChannelMask(AudioChannelMask mask) generates (Result retval);
+    setChannelMask(bitfield<AudioChannelMask> mask) generates (Result retval);
 
     /**
      * Return the audio format of the stream.
@@ -148,7 +148,7 @@
      * @return format audio format.
      */
     getAudioProperties() generates (
-            uint32_t sampleRateHz, AudioChannelMask mask, AudioFormat format);
+            uint32_t sampleRateHz, bitfield<AudioChannelMask> mask, AudioFormat format);
 
     /**
      * Applies audio effect to the stream.
@@ -183,7 +183,7 @@
      * @return retval operation completion status: OK or NOT_SUPPORTED.
      * @return device set of device(s) which this stream is connected to.
      */
-    getDevice() generates (Result retval, AudioDevice device);
+    getDevice() generates (Result retval, bitfield<AudioDevice> device);
 
     /**
      * Connects the stream to the device.
diff --git a/audio/common/4.0/types.hal b/audio/common/4.0/types.hal
index ab4bce8..5212dcd 100644
--- a/audio/common/4.0/types.hal
+++ b/audio/common/4.0/types.hal
@@ -678,7 +678,7 @@
  */
 struct AudioOffloadInfo {
     uint32_t sampleRateHz;
-    AudioChannelMask channelMask;
+    bitfield<AudioChannelMask> channelMask;
     AudioFormat format;
     AudioStreamType streamType;
     uint32_t bitRatePerSecond;
@@ -695,7 +695,7 @@
  */
 struct AudioConfig {
     uint32_t sampleRateHz;
-    AudioChannelMask channelMask;
+    bitfield<AudioChannelMask> channelMask;
     AudioFormat format;
     AudioOffloadInfo offloadInfo;
     uint64_t frameCount;
@@ -723,8 +723,8 @@
  * A gain stage is always attached to an audio port.
  */
 struct AudioGain {
-    AudioGainMode mode;
-    AudioChannelMask channelMask; // channels which gain an be controlled
+    bitfield<AudioGainMode> mode;
+    bitfield<AudioChannelMask> channelMask; // channels which gain an be controlled
     int32_t minValue;     // minimum gain value in millibels
     int32_t maxValue;     // maximum gain value in millibels
     int32_t defaultValue; // default gain value in millibels
@@ -822,9 +822,9 @@
  */
 struct AudioPortConfig {
     AudioPortHandle id;
-    AudioPortConfigMask configMask;
+    bitfield<AudioPortConfigMask> configMask;
     uint32_t sampleRateHz;
-    AudioChannelMask channelMask;
+    bitfield<AudioChannelMask> channelMask;
     AudioFormat format;
     AudioGainConfig gain;
     AudioPortType type;  // type is used as a discriminator for Ext union
@@ -879,7 +879,7 @@
     AudioPortRole role;
     string name;
     vec<uint32_t> sampleRates;
-    vec<AudioChannelMask> channelMasks;
+    vec<bitfield<AudioChannelMask>> channelMasks;
     vec<AudioFormat> formats;
     vec<AudioGain> gains;
     AudioPortConfig activeConfig; // current audio port configuration
diff --git a/audio/effect/4.0/IEffect.hal b/audio/effect/4.0/IEffect.hal
index a1bfd43..afc0237 100644
--- a/audio/effect/4.0/IEffect.hal
+++ b/audio/effect/4.0/IEffect.hal
@@ -82,7 +82,7 @@
      * @return retval operation completion status.
      */
     @callflow(next={"*"})
-    setDevice(AudioDevice device) generates (Result retval);
+    setDevice(bitfield<AudioDevice> device) generates (Result retval);
 
     /**
      * Set and get volume. Used by audio framework to delegate volume control to
@@ -155,7 +155,7 @@
      * @return retval operation completion status.
      */
     @callflow(next={"*"})
-    setInputDevice(AudioDevice device) generates (Result retval);
+    setInputDevice(bitfield<AudioDevice> device) generates (Result retval);
 
     /**
      * Read audio parameters configurations for input and output buffers.
diff --git a/audio/effect/4.0/IVirtualizerEffect.hal b/audio/effect/4.0/IVirtualizerEffect.hal
index b98ad3f..52038ca 100644
--- a/audio/effect/4.0/IVirtualizerEffect.hal
+++ b/audio/effect/4.0/IVirtualizerEffect.hal
@@ -47,7 +47,8 @@
     getStrength() generates (Result retval, uint16_t strength);
 
     struct SpeakerAngle {
-        AudioChannelMask mask; // speaker channel mask (1 bit set).
+        /** Speaker channel mask */
+        bitfield<AudioChannelMask> mask;
         // all angles are expressed in degrees and
         // are relative to the listener.
         int16_t azimuth; // 0 is the direction the listener faces
@@ -60,7 +61,7 @@
      * Retrieves virtual speaker angles for the given channel mask on the
      * specified device.
      */
-    getVirtualSpeakerAngles(AudioChannelMask mask, AudioDevice device)
+    getVirtualSpeakerAngles(bitfield<AudioChannelMask> mask, AudioDevice device)
             generates (Result retval, vec<SpeakerAngle> speakerAngles);
 
     /**
diff --git a/audio/effect/4.0/types.hal b/audio/effect/4.0/types.hal
index 80d627e..57f96e3 100644
--- a/audio/effect/4.0/types.hal
+++ b/audio/effect/4.0/types.hal
@@ -255,7 +255,7 @@
 struct EffectBufferConfig {
     AudioBuffer buffer;
     uint32_t samplingRateHz;
-    AudioChannelMask channels;
+    bitfield<AudioChannelMask> channels;
     AudioFormat format;
     EffectBufferAccess accessMode;
     EffectConfigParameters mask;
@@ -274,8 +274,8 @@
 };
 
 struct EffectAuxChannelsConfig {
-    AudioChannelMask mainChannels;  // channel mask for main channels
-    AudioChannelMask auxChannels;   // channel mask for auxiliary channels
+    bitfield<AudioChannelMask> mainChannels;  // channel mask for main channels
+    bitfield<AudioChannelMask> auxChannels;   // channel mask for auxiliary channels
 };
 
 struct EffectOffloadParameter {