Merge changes from topic 'hidl-light-hal'
* changes:
Adding android.hardware.light@2.0 service.
Light 2.0 hal default implementation.
Add lights 2.0 hal.
diff --git a/Android.bp b/Android.bp
index efcb9d5..7188e91 100644
--- a/Android.bp
+++ b/Android.bp
@@ -9,6 +9,8 @@
"nfc/1.0",
"nfc/1.0/default",
"radio/1.0",
+ "power/1.0",
+ "power/1.0/default",
"tests/bar/1.0",
"tests/baz/1.0",
"tests/expression/1.0",
diff --git a/audio/common/2.0/types.hal b/audio/common/2.0/types.hal
index dd75706..a5ec68d 100644
--- a/audio/common/2.0/types.hal
+++ b/audio/common/2.0/types.hal
@@ -85,90 +85,88 @@
/*
* Audio stream type describing the intented use case of a stream.
*/
-@export(name="audio_stream_type_t")
+@export(name="audio_stream_type_t", value_prefix="AUDIO_STREAM_")
enum AudioStreamType : int32_t {
// These values must kept in sync with
// frameworks/base/media/java/android/media/AudioSystem.java
// TODO: Synchronization should be done automatically by tools
- AUDIO_STREAM_DEFAULT = -1,
- AUDIO_STREAM_MIN = 0,
- AUDIO_STREAM_VOICE_CALL = 0,
- AUDIO_STREAM_SYSTEM = 1,
- AUDIO_STREAM_RING = 2,
- AUDIO_STREAM_MUSIC = 3,
- AUDIO_STREAM_ALARM = 4,
- AUDIO_STREAM_NOTIFICATION = 5,
- AUDIO_STREAM_BLUETOOTH_SCO = 6,
- AUDIO_STREAM_ENFORCED_AUDIBLE = 7, // Sounds that cannot be muted by user
- // and must be routed to speaker
- AUDIO_STREAM_DTMF = 8,
- AUDIO_STREAM_TTS = 9, // Transmitted Through Speaker
- // Plays over speaker only, silent
- // on other devices
- AUDIO_STREAM_ACCESSIBILITY = 10, // For accessibility talk back prompts
- AUDIO_STREAM_REROUTING = 11, // For dynamic policy output mixes
- AUDIO_STREAM_PATCH = 12, // For internal audio flinger tracks.
- // Fixed volume
- AUDIO_STREAM_PUBLIC_CNT = AUDIO_STREAM_TTS + 1,
+ DEFAULT = -1,
+ MIN = 0,
+ VOICE_CALL = 0,
+ SYSTEM = 1,
+ RING = 2,
+ MUSIC = 3,
+ ALARM = 4,
+ NOTIFICATION = 5,
+ BLUETOOTH_SCO = 6,
+ ENFORCED_AUDIBLE = 7, // Sounds that cannot be muted by user and must be
+ // routed to speaker
+ DTMF = 8,
+ TTS = 9, // Transmitted Through Speaker. Plays over speaker
+ // only, silent on other devices
+ ACCESSIBILITY = 10, // For accessibility talk back prompts
+ REROUTING = 11, // For dynamic policy output mixes
+ PATCH = 12, // For internal audio flinger tracks. Fixed volume
+ PUBLIC_CNT = TTS + 1,
// Number of streams considered by audio policy for volume and routing
- AUDIO_STREAM_FOR_POLICY_CNT = AUDIO_STREAM_PATCH,
- AUDIO_STREAM_CNT = AUDIO_STREAM_PATCH + 1
+ FOR_POLICY_CNT = PATCH,
+ CNT = PATCH + 1
};
-@export(name="audio_source_t")
+@export(name="audio_source_t", value_prefix="AUDIO_SOURCE_")
enum AudioSource {
// These values must kept in sync with
// frameworks/base/media/java/android/media/MediaRecorder.java,
// frameworks/av/services/audiopolicy/AudioPolicyService.cpp,
// system/media/audio_effects/include/audio_effects/audio_effects_conf.h
- AUDIO_SOURCE_DEFAULT = 0,
- AUDIO_SOURCE_MIC = 1,
- AUDIO_SOURCE_VOICE_UPLINK = 2,
- AUDIO_SOURCE_VOICE_DOWNLINK = 3,
- AUDIO_SOURCE_VOICE_CALL = 4,
- AUDIO_SOURCE_CAMCORDER = 5,
- AUDIO_SOURCE_VOICE_RECOGNITION = 6,
- AUDIO_SOURCE_VOICE_COMMUNICATION = 7,
+ DEFAULT = 0,
+ MIC = 1,
+ VOICE_UPLINK = 2,
+ VOICE_DOWNLINK = 3,
+ VOICE_CALL = 4,
+ CAMCORDER = 5,
+ VOICE_RECOGNITION = 6,
+ VOICE_COMMUNICATION = 7,
/*
* Source for the mix to be presented remotely. An example of remote
* presentation is Wifi Display where a dongle attached to a TV can be used
* to play the mix captured by this audio source.
*/
- AUDIO_SOURCE_REMOTE_SUBMIX = 8,
+ REMOTE_SUBMIX = 8,
/*
* Source for unprocessed sound. Usage examples include level measurement
* and raw signal analysis.
*/
- AUDIO_SOURCE_UNPROCESSED = 9,
+ UNPROCESSED = 9,
- AUDIO_SOURCE_CNT,
- AUDIO_SOURCE_MAX = AUDIO_SOURCE_CNT - 1,
- AUDIO_SOURCE_FM_TUNER = 1998,
+ CNT,
+ MAX = CNT - 1,
+ FM_TUNER = 1998,
/*
* A low-priority, preemptible audio source for for background software
- * hotword detection. Same tuning as AUDIO_SOURCE_VOICE_RECOGNITION.
- * Used only internally to the framework.
+ * hotword detection. Same tuning as VOICE_RECOGNITION. Used only
+ * internally by the framework.
*/
- AUDIO_SOURCE_HOTWORD = 1999
+ HOTWORD = 1999
};
typedef int32_t AudioSession;
/*
* Special audio session values.
*/
-@export(name="audio_session_t")
+@export(name="audio_session_t", value_prefix="AUDIO_SESSION_")
enum AudioSessionConsts : int32_t {
/*
* Session for effects attached to a particular output stream
* (value must be less than 0)
*/
- AUDIO_SESSION_OUTPUT_STAGE = -1,
+ OUTPUT_STAGE = -1,
/*
* Session for effects applied to output mix. These effects can
* be moved by audio policy manager to another output stream
* (value must be 0)
*/
- AUDIO_SESSION_OUTPUT_MIX = 0,
+ OUTPUT_MIX = 0,
/*
* Application does not specify an explicit session ID to be used, and
* requests a new session ID to be allocated TODO use unique values for
@@ -177,13 +175,13 @@
* Corresponds to AudioManager.AUDIO_SESSION_ID_GENERATE and
* AudioSystem.AUDIO_SESSION_ALLOCATE.
*/
- AUDIO_SESSION_ALLOCATE = 0,
+ ALLOCATE = 0,
/*
* For use with AudioRecord::start(), this indicates no trigger session.
* It is also used with output tracks and patch tracks, which never have a
* session.
*/
- AUDIO_SESSION_NONE = 0
+ NONE = 0
};
/*
@@ -197,91 +195,73 @@
* also be used for certain formats to give informations not present in the
* encoded audio stream (e.g. octet alignement for AMR).
*/
-@export(name="audio_format_t")
+@export(name="audio_format_t", value_prefix="AUDIO_FORMAT_")
enum AudioFormat : uint32_t {
- AUDIO_FORMAT_INVALID = 0xFFFFFFFFUL,
- AUDIO_FORMAT_DEFAULT = 0,
- AUDIO_FORMAT_PCM = 0x00000000UL, /* DO NOT CHANGE */
- AUDIO_FORMAT_MP3 = 0x01000000UL,
- AUDIO_FORMAT_AMR_NB = 0x02000000UL,
- AUDIO_FORMAT_AMR_WB = 0x03000000UL,
- AUDIO_FORMAT_AAC = 0x04000000UL,
- /* Deprecated, Use AUDIO_FORMAT_AAC_HE_V1*/
- AUDIO_FORMAT_HE_AAC_V1 = 0x05000000UL,
- /* Deprecated, Use AUDIO_FORMAT_AAC_HE_V2*/
- AUDIO_FORMAT_HE_AAC_V2 = 0x06000000UL,
- AUDIO_FORMAT_VORBIS = 0x07000000UL,
- AUDIO_FORMAT_OPUS = 0x08000000UL,
- AUDIO_FORMAT_AC3 = 0x09000000UL,
- AUDIO_FORMAT_E_AC3 = 0x0A000000UL,
- AUDIO_FORMAT_DTS = 0x0B000000UL,
- AUDIO_FORMAT_DTS_HD = 0x0C000000UL,
+ INVALID = 0xFFFFFFFFUL,
+ DEFAULT = 0,
+ PCM = 0x00000000UL, /* DO NOT CHANGE */
+ MP3 = 0x01000000UL,
+ AMR_NB = 0x02000000UL,
+ AMR_WB = 0x03000000UL,
+ AAC = 0x04000000UL,
+ HE_AAC_V1 = 0x05000000UL, /* Deprecated, Use AAC_HE_V1*/
+ HE_AAC_V2 = 0x06000000UL, /* Deprecated, Use AAC_HE_V2*/
+ VORBIS = 0x07000000UL,
+ OPUS = 0x08000000UL,
+ AC3 = 0x09000000UL,
+ E_AC3 = 0x0A000000UL,
+ DTS = 0x0B000000UL,
+ DTS_HD = 0x0C000000UL,
// IEC61937 is encoded audio wrapped in 16-bit PCM.
- AUDIO_FORMAT_IEC61937 = 0x0D000000UL,
- AUDIO_FORMAT_DOLBY_TRUEHD = 0x0E000000UL,
- AUDIO_FORMAT_MAIN_MASK = 0xFF000000UL, /* Deprecated */
- AUDIO_FORMAT_SUB_MASK = 0x00FFFFFFUL,
+ IEC61937 = 0x0D000000UL,
+ DOLBY_TRUEHD = 0x0E000000UL,
+ MAIN_MASK = 0xFF000000UL, /* Deprecated */
+ SUB_MASK = 0x00FFFFFFUL,
/* Subformats */
- AUDIO_FORMAT_PCM_SUB_16_BIT = 0x1, // PCM signed 16 bits
- AUDIO_FORMAT_PCM_SUB_8_BIT = 0x2, // PCM unsigned 8 bits
- AUDIO_FORMAT_PCM_SUB_32_BIT = 0x3, // PCM signed .31 fixed point
- AUDIO_FORMAT_PCM_SUB_8_24_BIT = 0x4, // PCM signed 8.23 fixed point
- AUDIO_FORMAT_PCM_SUB_FLOAT = 0x5, // PCM single-precision float pt
- AUDIO_FORMAT_PCM_SUB_24_BIT_PACKED = 0x6, // PCM signed .23 fix pt (3 bytes)
+ PCM_SUB_16_BIT = 0x1, // PCM signed 16 bits
+ PCM_SUB_8_BIT = 0x2, // PCM unsigned 8 bits
+ PCM_SUB_32_BIT = 0x3, // PCM signed .31 fixed point
+ PCM_SUB_8_24_BIT = 0x4, // PCM signed 8.23 fixed point
+ PCM_SUB_FLOAT = 0x5, // PCM single-precision float pt
+ PCM_SUB_24_BIT_PACKED = 0x6, // PCM signed .23 fix pt (3 bytes)
- AUDIO_FORMAT_MP3_SUB_NONE = 0x0,
+ MP3_SUB_NONE = 0x0,
- AUDIO_FORMAT_AMR_SUB_NONE = 0x0,
+ AMR_SUB_NONE = 0x0,
- AUDIO_FORMAT_AAC_SUB_MAIN = 0x1,
- AUDIO_FORMAT_AAC_SUB_LC = 0x2,
- AUDIO_FORMAT_AAC_SUB_SSR = 0x4,
- AUDIO_FORMAT_AAC_SUB_LTP = 0x8,
- AUDIO_FORMAT_AAC_SUB_HE_V1 = 0x10,
- AUDIO_FORMAT_AAC_SUB_SCALABLE = 0x20,
- AUDIO_FORMAT_AAC_SUB_ERLC = 0x40,
- AUDIO_FORMAT_AAC_SUB_LD = 0x80,
- AUDIO_FORMAT_AAC_SUB_HE_V2 = 0x100,
- AUDIO_FORMAT_AAC_SUB_ELD = 0x200,
+ AAC_SUB_MAIN = 0x1,
+ AAC_SUB_LC = 0x2,
+ AAC_SUB_SSR = 0x4,
+ AAC_SUB_LTP = 0x8,
+ AAC_SUB_HE_V1 = 0x10,
+ AAC_SUB_SCALABLE = 0x20,
+ AAC_SUB_ERLC = 0x40,
+ AAC_SUB_LD = 0x80,
+ AAC_SUB_HE_V2 = 0x100,
+ AAC_SUB_ELD = 0x200,
- AUDIO_FORMAT_VORBIS_SUB_NONE = 0x0,
+ VORBIS_SUB_NONE = 0x0,
/* Aliases */
/* note != AudioFormat.ENCODING_PCM_16BIT */
- AUDIO_FORMAT_PCM_16_BIT = (AUDIO_FORMAT_PCM |
- AUDIO_FORMAT_PCM_SUB_16_BIT),
+ PCM_16_BIT = (PCM | PCM_SUB_16_BIT),
/* note != AudioFormat.ENCODING_PCM_8BIT */
- AUDIO_FORMAT_PCM_8_BIT = (AUDIO_FORMAT_PCM |
- AUDIO_FORMAT_PCM_SUB_8_BIT),
- AUDIO_FORMAT_PCM_32_BIT = (AUDIO_FORMAT_PCM |
- AUDIO_FORMAT_PCM_SUB_32_BIT),
- AUDIO_FORMAT_PCM_8_24_BIT = (AUDIO_FORMAT_PCM |
- AUDIO_FORMAT_PCM_SUB_8_24_BIT),
- AUDIO_FORMAT_PCM_FLOAT = (AUDIO_FORMAT_PCM |
- AUDIO_FORMAT_PCM_SUB_FLOAT),
- AUDIO_FORMAT_PCM_24_BIT_PACKED = (AUDIO_FORMAT_PCM |
- AUDIO_FORMAT_PCM_SUB_24_BIT_PACKED),
- AUDIO_FORMAT_AAC_MAIN = (AUDIO_FORMAT_AAC |
- AUDIO_FORMAT_AAC_SUB_MAIN),
- AUDIO_FORMAT_AAC_LC = (AUDIO_FORMAT_AAC |
- AUDIO_FORMAT_AAC_SUB_LC),
- AUDIO_FORMAT_AAC_SSR = (AUDIO_FORMAT_AAC |
- AUDIO_FORMAT_AAC_SUB_SSR),
- AUDIO_FORMAT_AAC_LTP = (AUDIO_FORMAT_AAC |
- AUDIO_FORMAT_AAC_SUB_LTP),
- AUDIO_FORMAT_AAC_HE_V1 = (AUDIO_FORMAT_AAC |
- AUDIO_FORMAT_AAC_SUB_HE_V1),
- AUDIO_FORMAT_AAC_SCALABLE = (AUDIO_FORMAT_AAC |
- AUDIO_FORMAT_AAC_SUB_SCALABLE),
- AUDIO_FORMAT_AAC_ERLC = (AUDIO_FORMAT_AAC |
- AUDIO_FORMAT_AAC_SUB_ERLC),
- AUDIO_FORMAT_AAC_LD = (AUDIO_FORMAT_AAC |
- AUDIO_FORMAT_AAC_SUB_LD),
- AUDIO_FORMAT_AAC_HE_V2 = (AUDIO_FORMAT_AAC |
- AUDIO_FORMAT_AAC_SUB_HE_V2),
- AUDIO_FORMAT_AAC_ELD = (AUDIO_FORMAT_AAC |
- AUDIO_FORMAT_AAC_SUB_ELD)
+ PCM_8_BIT = (PCM | PCM_SUB_8_BIT),
+ PCM_32_BIT = (PCM | PCM_SUB_32_BIT),
+ PCM_8_24_BIT = (PCM | PCM_SUB_8_24_BIT),
+ PCM_FLOAT = (PCM | PCM_SUB_FLOAT),
+ PCM_24_BIT_PACKED = (PCM | PCM_SUB_24_BIT_PACKED),
+ AAC_MAIN = (AAC | AAC_SUB_MAIN),
+ AAC_LC = (AAC | AAC_SUB_LC),
+ AAC_SSR = (AAC | AAC_SUB_SSR),
+ AAC_LTP = (AAC | AAC_SUB_LTP),
+ AAC_HE_V1 = (AAC | AAC_SUB_HE_V1),
+ AAC_SCALABLE = (AAC | AAC_SUB_SCALABLE),
+ AAC_ERLC = (AAC | AAC_SUB_ERLC),
+ AAC_LD = (AAC | AAC_SUB_LD),
+ AAC_HE_V2 = (AAC | AAC_SUB_HE_V2),
+ AAC_ELD = (AAC | AAC_SUB_ELD)
};
/*
@@ -304,15 +284,15 @@
*
* These are the current representations:
*
- * AUDIO_CHANNEL_REPRESENTATION_POSITION
+ * REPRESENTATION_POSITION
* is a channel mask representation for position assignment. Each low-order
* bit corresponds to the spatial position of a transducer (output), or
* interpretation of channel (input). The user of a channel mask needs to
* know the context of whether it is for output or input. The constants
- * AUDIO_CHANNEL_OUT_* or AUDIO_CHANNEL_IN_* apply to the bits portion. It
- * is not permitted for no bits to be set.
+ * OUT_* or IN_* apply to the bits portion. It is not permitted for no bits
+ * to be set.
*
- * AUDIO_CHANNEL_REPRESENTATION_INDEX
+ * REPRESENTATION_INDEX
* is a channel mask representation for index assignment. Each low-order
* bit corresponds to a selected channel. There is no platform
* interpretation of the various bits. There is no concept of output or
@@ -326,314 +306,282 @@
* checking the channel mask, the implementer should look for ways to fix it
* with additional information outside of the mask.
*/
-@export(name="")
+@export(name="", value_prefix="AUDIO_CHANNEL_")
enum AudioChannelMask : uint32_t {
- AUDIO_CHANNEL_REPRESENTATION_POSITION = 0, /* must be 0 for compatibility */
+ REPRESENTATION_POSITION = 0, /* must be 0 for compatibility */
/* 1 is reserved for future use */
- AUDIO_CHANNEL_REPRESENTATION_INDEX = 2,
+ REPRESENTATION_INDEX = 2,
/* 3 is reserved for future use */
/* These can be a complete value of AudioChannelMask */
- AUDIO_CHANNEL_NONE = 0x0,
- AUDIO_CHANNEL_INVALID = 0xC0000000,
+ NONE = 0x0,
+ INVALID = 0xC0000000,
/*
* These can be the bits portion of an AudioChannelMask
- * with representation AUDIO_CHANNEL_REPRESENTATION_POSITION.
+ * with representation REPRESENTATION_POSITION.
*/
/* output channels */
- AUDIO_CHANNEL_OUT_FRONT_LEFT = 0x1,
- AUDIO_CHANNEL_OUT_FRONT_RIGHT = 0x2,
- AUDIO_CHANNEL_OUT_FRONT_CENTER = 0x4,
- AUDIO_CHANNEL_OUT_LOW_FREQUENCY = 0x8,
- AUDIO_CHANNEL_OUT_BACK_LEFT = 0x10,
- AUDIO_CHANNEL_OUT_BACK_RIGHT = 0x20,
- AUDIO_CHANNEL_OUT_FRONT_LEFT_OF_CENTER = 0x40,
- AUDIO_CHANNEL_OUT_FRONT_RIGHT_OF_CENTER = 0x80,
- AUDIO_CHANNEL_OUT_BACK_CENTER = 0x100,
- AUDIO_CHANNEL_OUT_SIDE_LEFT = 0x200,
- AUDIO_CHANNEL_OUT_SIDE_RIGHT = 0x400,
- AUDIO_CHANNEL_OUT_TOP_CENTER = 0x800,
- AUDIO_CHANNEL_OUT_TOP_FRONT_LEFT = 0x1000,
- AUDIO_CHANNEL_OUT_TOP_FRONT_CENTER = 0x2000,
- AUDIO_CHANNEL_OUT_TOP_FRONT_RIGHT = 0x4000,
- AUDIO_CHANNEL_OUT_TOP_BACK_LEFT = 0x8000,
- AUDIO_CHANNEL_OUT_TOP_BACK_CENTER = 0x10000,
- AUDIO_CHANNEL_OUT_TOP_BACK_RIGHT = 0x20000,
+ OUT_FRONT_LEFT = 0x1,
+ OUT_FRONT_RIGHT = 0x2,
+ OUT_FRONT_CENTER = 0x4,
+ OUT_LOW_FREQUENCY = 0x8,
+ OUT_BACK_LEFT = 0x10,
+ OUT_BACK_RIGHT = 0x20,
+ OUT_FRONT_LEFT_OF_CENTER = 0x40,
+ OUT_FRONT_RIGHT_OF_CENTER = 0x80,
+ OUT_BACK_CENTER = 0x100,
+ OUT_SIDE_LEFT = 0x200,
+ OUT_SIDE_RIGHT = 0x400,
+ OUT_TOP_CENTER = 0x800,
+ OUT_TOP_FRONT_LEFT = 0x1000,
+ OUT_TOP_FRONT_CENTER = 0x2000,
+ OUT_TOP_FRONT_RIGHT = 0x4000,
+ OUT_TOP_BACK_LEFT = 0x8000,
+ OUT_TOP_BACK_CENTER = 0x10000,
+ OUT_TOP_BACK_RIGHT = 0x20000,
- AUDIO_CHANNEL_OUT_MONO = AUDIO_CHANNEL_OUT_FRONT_LEFT,
- AUDIO_CHANNEL_OUT_STEREO = (AUDIO_CHANNEL_OUT_FRONT_LEFT |
- AUDIO_CHANNEL_OUT_FRONT_RIGHT),
- AUDIO_CHANNEL_OUT_QUAD = (AUDIO_CHANNEL_OUT_FRONT_LEFT |
- AUDIO_CHANNEL_OUT_FRONT_RIGHT |
- AUDIO_CHANNEL_OUT_BACK_LEFT |
- AUDIO_CHANNEL_OUT_BACK_RIGHT),
- AUDIO_CHANNEL_OUT_QUAD_BACK = AUDIO_CHANNEL_OUT_QUAD,
- /* like AUDIO_CHANNEL_OUT_QUAD_BACK with *_SIDE_* instead of *_BACK_* */
- AUDIO_CHANNEL_OUT_QUAD_SIDE = (AUDIO_CHANNEL_OUT_FRONT_LEFT |
- AUDIO_CHANNEL_OUT_FRONT_RIGHT |
- AUDIO_CHANNEL_OUT_SIDE_LEFT |
- AUDIO_CHANNEL_OUT_SIDE_RIGHT),
- AUDIO_CHANNEL_OUT_5POINT1 = (AUDIO_CHANNEL_OUT_FRONT_LEFT |
- AUDIO_CHANNEL_OUT_FRONT_RIGHT |
- AUDIO_CHANNEL_OUT_FRONT_CENTER |
- AUDIO_CHANNEL_OUT_LOW_FREQUENCY |
- AUDIO_CHANNEL_OUT_BACK_LEFT |
- AUDIO_CHANNEL_OUT_BACK_RIGHT),
- AUDIO_CHANNEL_OUT_5POINT1_BACK = AUDIO_CHANNEL_OUT_5POINT1,
- /* like AUDIO_CHANNEL_OUT_5POINT1_BACK with *_SIDE_* instead of *_BACK_* */
- AUDIO_CHANNEL_OUT_5POINT1_SIDE = (AUDIO_CHANNEL_OUT_FRONT_LEFT |
- AUDIO_CHANNEL_OUT_FRONT_RIGHT |
- AUDIO_CHANNEL_OUT_FRONT_CENTER |
- AUDIO_CHANNEL_OUT_LOW_FREQUENCY |
- AUDIO_CHANNEL_OUT_SIDE_LEFT |
- AUDIO_CHANNEL_OUT_SIDE_RIGHT),
+ OUT_MONO = OUT_FRONT_LEFT,
+ OUT_STEREO = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT),
+ OUT_QUAD = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT |
+ OUT_BACK_LEFT | OUT_BACK_RIGHT),
+ OUT_QUAD_BACK = OUT_QUAD,
+ /* like OUT_QUAD_BACK with *_SIDE_* instead of *_BACK_* */
+ OUT_QUAD_SIDE = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT |
+ OUT_SIDE_LEFT | OUT_SIDE_RIGHT),
+ OUT_5POINT1 = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT |
+ OUT_FRONT_CENTER | OUT_LOW_FREQUENCY |
+ OUT_BACK_LEFT | OUT_BACK_RIGHT),
+ OUT_5POINT1_BACK = OUT_5POINT1,
+ /* like OUT_5POINT1_BACK with *_SIDE_* instead of *_BACK_* */
+ OUT_5POINT1_SIDE = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT |
+ OUT_FRONT_CENTER | OUT_LOW_FREQUENCY |
+ OUT_SIDE_LEFT | OUT_SIDE_RIGHT),
/* matches the correct AudioFormat.CHANNEL_OUT_7POINT1_SURROUND */
- AUDIO_CHANNEL_OUT_7POINT1 = (AUDIO_CHANNEL_OUT_FRONT_LEFT |
- AUDIO_CHANNEL_OUT_FRONT_RIGHT |
- AUDIO_CHANNEL_OUT_FRONT_CENTER |
- AUDIO_CHANNEL_OUT_LOW_FREQUENCY |
- AUDIO_CHANNEL_OUT_BACK_LEFT |
- AUDIO_CHANNEL_OUT_BACK_RIGHT |
- AUDIO_CHANNEL_OUT_SIDE_LEFT |
- AUDIO_CHANNEL_OUT_SIDE_RIGHT),
- AUDIO_CHANNEL_OUT_ALL = (AUDIO_CHANNEL_OUT_FRONT_LEFT |
- AUDIO_CHANNEL_OUT_FRONT_RIGHT |
- AUDIO_CHANNEL_OUT_FRONT_CENTER |
- AUDIO_CHANNEL_OUT_LOW_FREQUENCY |
- AUDIO_CHANNEL_OUT_BACK_LEFT |
- AUDIO_CHANNEL_OUT_BACK_RIGHT |
- AUDIO_CHANNEL_OUT_FRONT_LEFT_OF_CENTER |
- AUDIO_CHANNEL_OUT_FRONT_RIGHT_OF_CENTER |
- AUDIO_CHANNEL_OUT_BACK_CENTER|
- AUDIO_CHANNEL_OUT_SIDE_LEFT|
- AUDIO_CHANNEL_OUT_SIDE_RIGHT|
- AUDIO_CHANNEL_OUT_TOP_CENTER|
- AUDIO_CHANNEL_OUT_TOP_FRONT_LEFT|
- AUDIO_CHANNEL_OUT_TOP_FRONT_CENTER|
- AUDIO_CHANNEL_OUT_TOP_FRONT_RIGHT|
- AUDIO_CHANNEL_OUT_TOP_BACK_LEFT|
- AUDIO_CHANNEL_OUT_TOP_BACK_CENTER|
- AUDIO_CHANNEL_OUT_TOP_BACK_RIGHT),
+ OUT_7POINT1 = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT |
+ OUT_FRONT_CENTER | OUT_LOW_FREQUENCY |
+ OUT_BACK_LEFT | OUT_BACK_RIGHT |
+ OUT_SIDE_LEFT | OUT_SIDE_RIGHT),
+ OUT_ALL = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT |
+ OUT_FRONT_CENTER | OUT_LOW_FREQUENCY |
+ OUT_BACK_LEFT | OUT_BACK_RIGHT |
+ OUT_FRONT_LEFT_OF_CENTER | OUT_FRONT_RIGHT_OF_CENTER |
+ OUT_BACK_CENTER |
+ OUT_SIDE_LEFT | OUT_SIDE_RIGHT |
+ OUT_TOP_CENTER |
+ OUT_TOP_FRONT_LEFT | OUT_TOP_FRONT_CENTER | OUT_TOP_FRONT_RIGHT |
+ OUT_TOP_BACK_LEFT | OUT_TOP_BACK_CENTER | OUT_TOP_BACK_RIGHT),
/* These are bits only, not complete values */
/* input channels */
- AUDIO_CHANNEL_IN_LEFT = 0x4,
- AUDIO_CHANNEL_IN_RIGHT = 0x8,
- AUDIO_CHANNEL_IN_FRONT = 0x10,
- AUDIO_CHANNEL_IN_BACK = 0x20,
- AUDIO_CHANNEL_IN_LEFT_PROCESSED = 0x40,
- AUDIO_CHANNEL_IN_RIGHT_PROCESSED = 0x80,
- AUDIO_CHANNEL_IN_FRONT_PROCESSED = 0x100,
- AUDIO_CHANNEL_IN_BACK_PROCESSED = 0x200,
- AUDIO_CHANNEL_IN_PRESSURE = 0x400,
- AUDIO_CHANNEL_IN_X_AXIS = 0x800,
- AUDIO_CHANNEL_IN_Y_AXIS = 0x1000,
- AUDIO_CHANNEL_IN_Z_AXIS = 0x2000,
- AUDIO_CHANNEL_IN_VOICE_UPLINK = 0x4000,
- AUDIO_CHANNEL_IN_VOICE_DNLINK = 0x8000,
+ IN_LEFT = 0x4,
+ IN_RIGHT = 0x8,
+ IN_FRONT = 0x10,
+ IN_BACK = 0x20,
+ IN_LEFT_PROCESSED = 0x40,
+ IN_RIGHT_PROCESSED = 0x80,
+ IN_FRONT_PROCESSED = 0x100,
+ IN_BACK_PROCESSED = 0x200,
+ IN_PRESSURE = 0x400,
+ IN_X_AXIS = 0x800,
+ IN_Y_AXIS = 0x1000,
+ IN_Z_AXIS = 0x2000,
+ IN_VOICE_UPLINK = 0x4000,
+ IN_VOICE_DNLINK = 0x8000,
- AUDIO_CHANNEL_IN_MONO = AUDIO_CHANNEL_IN_FRONT,
- AUDIO_CHANNEL_IN_STEREO = (AUDIO_CHANNEL_IN_LEFT | AUDIO_CHANNEL_IN_RIGHT),
- AUDIO_CHANNEL_IN_FRONT_BACK = (AUDIO_CHANNEL_IN_FRONT |
- AUDIO_CHANNEL_IN_BACK),
- AUDIO_CHANNEL_IN_ALL = (AUDIO_CHANNEL_IN_LEFT |
- AUDIO_CHANNEL_IN_RIGHT |
- AUDIO_CHANNEL_IN_FRONT |
- AUDIO_CHANNEL_IN_BACK|
- AUDIO_CHANNEL_IN_LEFT_PROCESSED |
- AUDIO_CHANNEL_IN_RIGHT_PROCESSED |
- AUDIO_CHANNEL_IN_FRONT_PROCESSED |
- AUDIO_CHANNEL_IN_BACK_PROCESSED|
- AUDIO_CHANNEL_IN_PRESSURE |
- AUDIO_CHANNEL_IN_X_AXIS |
- AUDIO_CHANNEL_IN_Y_AXIS |
- AUDIO_CHANNEL_IN_Z_AXIS |
- AUDIO_CHANNEL_IN_VOICE_UPLINK |
- AUDIO_CHANNEL_IN_VOICE_DNLINK),
+ IN_MONO = IN_FRONT,
+ IN_STEREO = (IN_LEFT | IN_RIGHT),
+ IN_FRONT_BACK = (IN_FRONT | IN_BACK),
+ IN_ALL = (IN_LEFT | IN_RIGHT | IN_FRONT | IN_BACK|
+ IN_LEFT_PROCESSED | IN_RIGHT_PROCESSED |
+ IN_FRONT_PROCESSED | IN_BACK_PROCESSED|
+ IN_PRESSURE |
+ IN_X_AXIS | IN_Y_AXIS | IN_Z_AXIS |
+ IN_VOICE_UPLINK | IN_VOICE_DNLINK),
- /*
- * Expresses the convention when stereo audio samples are stored interleaved
- * in an array. This should improve readability by allowing code to use
- * symbolic indices instead of hard-coded [0] and [1].
- *
- * For multi-channel beyond stereo, the platform convention is that channels
- * are interleaved in order from least significant channel mask bit to most
- * significant channel mask bit, with unused bits skipped. Any exceptions
- * to this convention will be noted at the appropriate API.
- */
- AUDIO_INTERLEAVE_LEFT = 0,
- AUDIO_INTERLEAVE_RIGHT = 1,
+ COUNT_MAX = 30,
+ INDEX_HDR = REPRESENTATION_INDEX << COUNT_MAX,
+ INDEX_MASK_1 = INDEX_HDR | ((1 << 1) - 1),
+ INDEX_MASK_2 = INDEX_HDR | ((1 << 2) - 1),
+ INDEX_MASK_3 = INDEX_HDR | ((1 << 3) - 1),
+ INDEX_MASK_4 = INDEX_HDR | ((1 << 4) - 1),
+ INDEX_MASK_5 = INDEX_HDR | ((1 << 5) - 1),
+ INDEX_MASK_6 = INDEX_HDR | ((1 << 6) - 1),
+ INDEX_MASK_7 = INDEX_HDR | ((1 << 7) - 1),
+ INDEX_MASK_8 = INDEX_HDR | ((1 << 8) - 1)
+};
- AUDIO_CHANNEL_COUNT_MAX = 30,
- AUDIO_CHANNEL_INDEX_HDR =
- AUDIO_CHANNEL_REPRESENTATION_INDEX << AUDIO_CHANNEL_COUNT_MAX,
- AUDIO_CHANNEL_INDEX_MASK_1 = AUDIO_CHANNEL_INDEX_HDR | ((1 << 1) - 1),
- AUDIO_CHANNEL_INDEX_MASK_2 = AUDIO_CHANNEL_INDEX_HDR | ((1 << 2) - 1),
- AUDIO_CHANNEL_INDEX_MASK_3 = AUDIO_CHANNEL_INDEX_HDR | ((1 << 3) - 1),
- AUDIO_CHANNEL_INDEX_MASK_4 = AUDIO_CHANNEL_INDEX_HDR | ((1 << 4) - 1),
- AUDIO_CHANNEL_INDEX_MASK_5 = AUDIO_CHANNEL_INDEX_HDR | ((1 << 5) - 1),
- AUDIO_CHANNEL_INDEX_MASK_6 = AUDIO_CHANNEL_INDEX_HDR | ((1 << 6) - 1),
- AUDIO_CHANNEL_INDEX_MASK_7 = AUDIO_CHANNEL_INDEX_HDR | ((1 << 7) - 1),
- AUDIO_CHANNEL_INDEX_MASK_8 = AUDIO_CHANNEL_INDEX_HDR | ((1 << 8) - 1)
+
+/*
+ * Expresses the convention when stereo audio samples are stored interleaved
+ * in an array. This should improve readability by allowing code to use
+ * symbolic indices instead of hard-coded [0] and [1].
+ *
+ * For multi-channel beyond stereo, the platform convention is that channels
+ * are interleaved in order from least significant channel mask bit to most
+ * significant channel mask bit, with unused bits skipped. Any exceptions
+ * to this convention will be noted at the appropriate API.
+ */
+@export(name="", value_prefix="AUDIO_INTERLEAVE_")
+enum AudioInterleave {
+ LEFT = 0,
+ RIGHT = 1,
};
/*
* Major modes for a mobile device. The current mode setting affects audio
* routing.
*/
-@export(name="audio_mode_t")
+@export(name="audio_mode_t", value_prefix="AUDIO_MODE_")
enum AudioMode {
- AUDIO_MODE_INVALID = -2,
- AUDIO_MODE_CURRENT = -1,
- AUDIO_MODE_NORMAL = 0,
- AUDIO_MODE_RINGTONE = 1,
- AUDIO_MODE_IN_CALL = 2,
- AUDIO_MODE_IN_COMMUNICATION = 3,
+ INVALID = -2,
+ CURRENT = -1,
+ NORMAL = 0,
+ RINGTONE = 1,
+ IN_CALL = 2,
+ IN_COMMUNICATION = 3,
- AUDIO_MODE_CNT,
- AUDIO_MODE_MAX = AUDIO_MODE_CNT - 1,
+ CNT,
+ MAX = CNT - 1,
};
-@export(name="")
+@export(name="", value_prefix="AUDIO_DEVICE_")
enum AudioDevice : uint32_t {
- AUDIO_DEVICE_NONE = 0x0,
+ NONE = 0x0,
/* reserved bits */
- AUDIO_DEVICE_BIT_IN = 0x80000000,
- AUDIO_DEVICE_BIT_DEFAULT = 0x40000000,
+ BIT_IN = 0x80000000,
+ BIT_DEFAULT = 0x40000000,
/* output devices */
- AUDIO_DEVICE_OUT_EARPIECE = 0x1,
- AUDIO_DEVICE_OUT_SPEAKER = 0x2,
- AUDIO_DEVICE_OUT_WIRED_HEADSET = 0x4,
- AUDIO_DEVICE_OUT_WIRED_HEADPHONE = 0x8,
- AUDIO_DEVICE_OUT_BLUETOOTH_SCO = 0x10,
- AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET = 0x20,
- AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT = 0x40,
- AUDIO_DEVICE_OUT_BLUETOOTH_A2DP = 0x80,
- AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES = 0x100,
- AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER = 0x200,
- AUDIO_DEVICE_OUT_AUX_DIGITAL = 0x400,
- AUDIO_DEVICE_OUT_HDMI = AUDIO_DEVICE_OUT_AUX_DIGITAL,
+ OUT_EARPIECE = 0x1,
+ OUT_SPEAKER = 0x2,
+ OUT_WIRED_HEADSET = 0x4,
+ OUT_WIRED_HEADPHONE = 0x8,
+ OUT_BLUETOOTH_SCO = 0x10,
+ OUT_BLUETOOTH_SCO_HEADSET = 0x20,
+ OUT_BLUETOOTH_SCO_CARKIT = 0x40,
+ OUT_BLUETOOTH_A2DP = 0x80,
+ OUT_BLUETOOTH_A2DP_HEADPHONES = 0x100,
+ OUT_BLUETOOTH_A2DP_SPEAKER = 0x200,
+ OUT_AUX_DIGITAL = 0x400,
+ OUT_HDMI = OUT_AUX_DIGITAL,
/* uses an analog connection (multiplexed over the USB pins for instance) */
- AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET = 0x800,
- AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET = 0x1000,
+ OUT_ANLG_DOCK_HEADSET = 0x800,
+ OUT_DGTL_DOCK_HEADSET = 0x1000,
/* USB accessory mode: Android device is USB device and dock is USB host */
- AUDIO_DEVICE_OUT_USB_ACCESSORY = 0x2000,
+ OUT_USB_ACCESSORY = 0x2000,
/* USB host mode: Android device is USB host and dock is USB device */
- AUDIO_DEVICE_OUT_USB_DEVICE = 0x4000,
- AUDIO_DEVICE_OUT_REMOTE_SUBMIX = 0x8000,
+ OUT_USB_DEVICE = 0x4000,
+ OUT_REMOTE_SUBMIX = 0x8000,
/* Telephony voice TX path */
- AUDIO_DEVICE_OUT_TELEPHONY_TX = 0x10000,
+ OUT_TELEPHONY_TX = 0x10000,
/* Analog jack with line impedance detected */
- AUDIO_DEVICE_OUT_LINE = 0x20000,
+ OUT_LINE = 0x20000,
/* HDMI Audio Return Channel */
- AUDIO_DEVICE_OUT_HDMI_ARC = 0x40000,
+ OUT_HDMI_ARC = 0x40000,
/* S/PDIF out */
- AUDIO_DEVICE_OUT_SPDIF = 0x80000,
+ OUT_SPDIF = 0x80000,
/* FM transmitter out */
- AUDIO_DEVICE_OUT_FM = 0x100000,
+ OUT_FM = 0x100000,
/* Line out for av devices */
- AUDIO_DEVICE_OUT_AUX_LINE = 0x200000,
+ OUT_AUX_LINE = 0x200000,
/* limited-output speaker device for acoustic safety */
- AUDIO_DEVICE_OUT_SPEAKER_SAFE = 0x400000,
- AUDIO_DEVICE_OUT_IP = 0x800000,
+ OUT_SPEAKER_SAFE = 0x400000,
+ OUT_IP = 0x800000,
/* audio bus implemented by the audio system (e.g an MOST stereo channel) */
- AUDIO_DEVICE_OUT_BUS = 0x1000000,
- AUDIO_DEVICE_OUT_DEFAULT = AUDIO_DEVICE_BIT_DEFAULT,
- AUDIO_DEVICE_OUT_ALL = (AUDIO_DEVICE_OUT_EARPIECE |
- AUDIO_DEVICE_OUT_SPEAKER |
- AUDIO_DEVICE_OUT_WIRED_HEADSET |
- AUDIO_DEVICE_OUT_WIRED_HEADPHONE |
- AUDIO_DEVICE_OUT_BLUETOOTH_SCO |
- AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET |
- AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT |
- AUDIO_DEVICE_OUT_BLUETOOTH_A2DP |
- AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES |
- AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER |
- AUDIO_DEVICE_OUT_HDMI |
- AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET |
- AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET |
- AUDIO_DEVICE_OUT_USB_ACCESSORY |
- AUDIO_DEVICE_OUT_USB_DEVICE |
- AUDIO_DEVICE_OUT_REMOTE_SUBMIX |
- AUDIO_DEVICE_OUT_TELEPHONY_TX |
- AUDIO_DEVICE_OUT_LINE |
- AUDIO_DEVICE_OUT_HDMI_ARC |
- AUDIO_DEVICE_OUT_SPDIF |
- AUDIO_DEVICE_OUT_FM |
- AUDIO_DEVICE_OUT_AUX_LINE |
- AUDIO_DEVICE_OUT_SPEAKER_SAFE |
- AUDIO_DEVICE_OUT_IP |
- AUDIO_DEVICE_OUT_BUS |
- AUDIO_DEVICE_OUT_DEFAULT),
- AUDIO_DEVICE_OUT_ALL_A2DP = (AUDIO_DEVICE_OUT_BLUETOOTH_A2DP |
- AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES |
- AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER),
- AUDIO_DEVICE_OUT_ALL_SCO = (AUDIO_DEVICE_OUT_BLUETOOTH_SCO |
- AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET |
- AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT),
- AUDIO_DEVICE_OUT_ALL_USB = (AUDIO_DEVICE_OUT_USB_ACCESSORY |
- AUDIO_DEVICE_OUT_USB_DEVICE),
+ OUT_BUS = 0x1000000,
+ OUT_DEFAULT = BIT_DEFAULT,
+ OUT_ALL = (OUT_EARPIECE |
+ OUT_SPEAKER |
+ OUT_WIRED_HEADSET |
+ OUT_WIRED_HEADPHONE |
+ OUT_BLUETOOTH_SCO |
+ OUT_BLUETOOTH_SCO_HEADSET |
+ OUT_BLUETOOTH_SCO_CARKIT |
+ OUT_BLUETOOTH_A2DP |
+ OUT_BLUETOOTH_A2DP_HEADPHONES |
+ OUT_BLUETOOTH_A2DP_SPEAKER |
+ OUT_HDMI |
+ OUT_ANLG_DOCK_HEADSET |
+ OUT_DGTL_DOCK_HEADSET |
+ OUT_USB_ACCESSORY |
+ OUT_USB_DEVICE |
+ OUT_REMOTE_SUBMIX |
+ OUT_TELEPHONY_TX |
+ OUT_LINE |
+ OUT_HDMI_ARC |
+ OUT_SPDIF |
+ OUT_FM |
+ OUT_AUX_LINE |
+ OUT_SPEAKER_SAFE |
+ OUT_IP |
+ OUT_BUS |
+ OUT_DEFAULT),
+ OUT_ALL_A2DP = (OUT_BLUETOOTH_A2DP |
+ OUT_BLUETOOTH_A2DP_HEADPHONES |
+ OUT_BLUETOOTH_A2DP_SPEAKER),
+ OUT_ALL_SCO = (OUT_BLUETOOTH_SCO |
+ OUT_BLUETOOTH_SCO_HEADSET |
+ OUT_BLUETOOTH_SCO_CARKIT),
+ OUT_ALL_USB = (OUT_USB_ACCESSORY | OUT_USB_DEVICE),
/* input devices */
- AUDIO_DEVICE_IN_COMMUNICATION = AUDIO_DEVICE_BIT_IN | 0x1,
- AUDIO_DEVICE_IN_AMBIENT = AUDIO_DEVICE_BIT_IN | 0x2,
- AUDIO_DEVICE_IN_BUILTIN_MIC = AUDIO_DEVICE_BIT_IN | 0x4,
- AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET = AUDIO_DEVICE_BIT_IN | 0x8,
- AUDIO_DEVICE_IN_WIRED_HEADSET = AUDIO_DEVICE_BIT_IN | 0x10,
- AUDIO_DEVICE_IN_AUX_DIGITAL = AUDIO_DEVICE_BIT_IN | 0x20,
- AUDIO_DEVICE_IN_HDMI = AUDIO_DEVICE_IN_AUX_DIGITAL,
+ IN_COMMUNICATION = BIT_IN | 0x1,
+ IN_AMBIENT = BIT_IN | 0x2,
+ IN_BUILTIN_MIC = BIT_IN | 0x4,
+ IN_BLUETOOTH_SCO_HEADSET = BIT_IN | 0x8,
+ IN_WIRED_HEADSET = BIT_IN | 0x10,
+ IN_AUX_DIGITAL = BIT_IN | 0x20,
+ IN_HDMI = IN_AUX_DIGITAL,
/* Telephony voice RX path */
- AUDIO_DEVICE_IN_VOICE_CALL = AUDIO_DEVICE_BIT_IN | 0x40,
- AUDIO_DEVICE_IN_TELEPHONY_RX = AUDIO_DEVICE_IN_VOICE_CALL,
- AUDIO_DEVICE_IN_BACK_MIC = AUDIO_DEVICE_BIT_IN | 0x80,
- AUDIO_DEVICE_IN_REMOTE_SUBMIX = AUDIO_DEVICE_BIT_IN | 0x100,
- AUDIO_DEVICE_IN_ANLG_DOCK_HEADSET = AUDIO_DEVICE_BIT_IN | 0x200,
- AUDIO_DEVICE_IN_DGTL_DOCK_HEADSET = AUDIO_DEVICE_BIT_IN | 0x400,
- AUDIO_DEVICE_IN_USB_ACCESSORY = AUDIO_DEVICE_BIT_IN | 0x800,
- AUDIO_DEVICE_IN_USB_DEVICE = AUDIO_DEVICE_BIT_IN | 0x1000,
+ IN_VOICE_CALL = BIT_IN | 0x40,
+ IN_TELEPHONY_RX = IN_VOICE_CALL,
+ IN_BACK_MIC = BIT_IN | 0x80,
+ IN_REMOTE_SUBMIX = BIT_IN | 0x100,
+ IN_ANLG_DOCK_HEADSET = BIT_IN | 0x200,
+ IN_DGTL_DOCK_HEADSET = BIT_IN | 0x400,
+ IN_USB_ACCESSORY = BIT_IN | 0x800,
+ IN_USB_DEVICE = BIT_IN | 0x1000,
/* FM tuner input */
- AUDIO_DEVICE_IN_FM_TUNER = AUDIO_DEVICE_BIT_IN | 0x2000,
+ IN_FM_TUNER = BIT_IN | 0x2000,
/* TV tuner input */
- AUDIO_DEVICE_IN_TV_TUNER = AUDIO_DEVICE_BIT_IN | 0x4000,
+ IN_TV_TUNER = BIT_IN | 0x4000,
/* Analog jack with line impedance detected */
- AUDIO_DEVICE_IN_LINE = AUDIO_DEVICE_BIT_IN | 0x8000,
+ IN_LINE = BIT_IN | 0x8000,
/* S/PDIF in */
- AUDIO_DEVICE_IN_SPDIF = AUDIO_DEVICE_BIT_IN | 0x10000,
- AUDIO_DEVICE_IN_BLUETOOTH_A2DP = AUDIO_DEVICE_BIT_IN | 0x20000,
- AUDIO_DEVICE_IN_LOOPBACK = AUDIO_DEVICE_BIT_IN | 0x40000,
- AUDIO_DEVICE_IN_IP = AUDIO_DEVICE_BIT_IN | 0x80000,
+ IN_SPDIF = BIT_IN | 0x10000,
+ IN_BLUETOOTH_A2DP = BIT_IN | 0x20000,
+ IN_LOOPBACK = BIT_IN | 0x40000,
+ IN_IP = BIT_IN | 0x80000,
/* audio bus implemented by the audio system (e.g an MOST stereo channel) */
- AUDIO_DEVICE_IN_BUS = AUDIO_DEVICE_BIT_IN | 0x100000,
- AUDIO_DEVICE_IN_DEFAULT = AUDIO_DEVICE_BIT_IN |
- AUDIO_DEVICE_BIT_DEFAULT,
+ IN_BUS = BIT_IN | 0x100000,
+ IN_DEFAULT = BIT_IN |
+ BIT_DEFAULT,
- AUDIO_DEVICE_IN_ALL = (AUDIO_DEVICE_IN_COMMUNICATION |
- AUDIO_DEVICE_IN_AMBIENT |
- AUDIO_DEVICE_IN_BUILTIN_MIC |
- AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET |
- AUDIO_DEVICE_IN_WIRED_HEADSET |
- AUDIO_DEVICE_IN_HDMI |
- AUDIO_DEVICE_IN_TELEPHONY_RX |
- AUDIO_DEVICE_IN_BACK_MIC |
- AUDIO_DEVICE_IN_REMOTE_SUBMIX |
- AUDIO_DEVICE_IN_ANLG_DOCK_HEADSET |
- AUDIO_DEVICE_IN_DGTL_DOCK_HEADSET |
- AUDIO_DEVICE_IN_USB_ACCESSORY |
- AUDIO_DEVICE_IN_USB_DEVICE |
- AUDIO_DEVICE_IN_FM_TUNER |
- AUDIO_DEVICE_IN_TV_TUNER |
- AUDIO_DEVICE_IN_LINE |
- AUDIO_DEVICE_IN_SPDIF |
- AUDIO_DEVICE_IN_BLUETOOTH_A2DP |
- AUDIO_DEVICE_IN_LOOPBACK |
- AUDIO_DEVICE_IN_IP |
- AUDIO_DEVICE_IN_BUS |
- AUDIO_DEVICE_IN_DEFAULT),
- AUDIO_DEVICE_IN_ALL_SCO = AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET,
- AUDIO_DEVICE_IN_ALL_USB = (AUDIO_DEVICE_IN_USB_ACCESSORY |
- AUDIO_DEVICE_IN_USB_DEVICE),
+ IN_ALL = (IN_COMMUNICATION |
+ IN_AMBIENT |
+ IN_BUILTIN_MIC |
+ IN_BLUETOOTH_SCO_HEADSET |
+ IN_WIRED_HEADSET |
+ IN_HDMI |
+ IN_TELEPHONY_RX |
+ IN_BACK_MIC |
+ IN_REMOTE_SUBMIX |
+ IN_ANLG_DOCK_HEADSET |
+ IN_DGTL_DOCK_HEADSET |
+ IN_USB_ACCESSORY |
+ IN_USB_DEVICE |
+ IN_FM_TUNER |
+ IN_TV_TUNER |
+ IN_LINE |
+ IN_SPDIF |
+ IN_BLUETOOTH_A2DP |
+ IN_LOOPBACK |
+ IN_IP |
+ IN_BUS |
+ IN_DEFAULT),
+ IN_ALL_SCO = IN_BLUETOOTH_SCO_HEADSET,
+ IN_ALL_USB = (IN_USB_ACCESSORY | IN_USB_DEVICE),
};
/*
@@ -649,31 +597,28 @@
* The audio policy manager will try to match the flags in the request
* (when getOuput() is called) to an available output stream.
*/
-@export(name="audio_output_flags_t")
+@export(name="audio_output_flags_t", value_prefix="AUDIO_OUTPUT_FLAG_")
enum AudioOutputFlag {
- AUDIO_OUTPUT_FLAG_NONE = 0x0, // no attributes
- AUDIO_OUTPUT_FLAG_DIRECT = 0x1, // this output directly connects a track
- // to one output stream: no software mixer
- AUDIO_OUTPUT_FLAG_PRIMARY = 0x2, // this output is the primary output of
- // the device. It is unique and must be
- // present. It is opened by default and
- // receives routing, audio mode and volume
- // controls related to voice calls.
- AUDIO_OUTPUT_FLAG_FAST = 0x4, // output supports "fast tracks",
- // defined elsewhere
- AUDIO_OUTPUT_FLAG_DEEP_BUFFER = 0x8, // use deep audio buffers
- AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD = 0x10, // offload playback of compressed
- // streams to hardware codec
- AUDIO_OUTPUT_FLAG_NON_BLOCKING = 0x20, // use non-blocking write
- AUDIO_OUTPUT_FLAG_HW_AV_SYNC = 0x40, // output uses a hardware A/V sync
- AUDIO_OUTPUT_FLAG_TTS = 0x80, // output for streams transmitted through
- // speaker at a sample rate high enough
- // to accommodate lower-range ultrasonic p/b
- AUDIO_OUTPUT_FLAG_RAW = 0x100, // minimize signal processing
- AUDIO_OUTPUT_FLAG_SYNC = 0x200, // synchronize I/O streams
- AUDIO_OUTPUT_FLAG_IEC958_NONAUDIO = 0x400, // Audio stream contains
- // compressed audio in
- // SPDIF data bursts, not PCM.
+ NONE = 0x0, // no attributes
+ DIRECT = 0x1, // this output directly connects a track
+ // to one output stream: no software mixer
+ PRIMARY = 0x2, // this output is the primary output of the device. It is
+ // unique and must be present. It is opened by default and
+ // receives routing, audio mode and volume controls related
+ // to voice calls.
+ FAST = 0x4, // output supports "fast tracks", defined elsewhere
+ DEEP_BUFFER = 0x8, // use deep audio buffers
+ COMPRESS_OFFLOAD = 0x10, // offload playback of compressed streams to
+ // hardware codec
+ NON_BLOCKING = 0x20, // use non-blocking write
+ HW_AV_SYNC = 0x40, // output uses a hardware A/V sync
+ TTS = 0x80, // output for streams transmitted through speaker at a
+ // sample rate high enough to accommodate lower-range
+ // ultrasonic p/b
+ RAW = 0x100, // minimize signal processing
+ SYNC = 0x200, // synchronize I/O streams
+ IEC958_NONAUDIO = 0x400, // Audio stream contains compressed audio in SPDIF
+ // data bursts, not PCM.
};
/*
@@ -682,15 +627,13 @@
* to indicate a preference to be connected to an input stream with
* attributes corresponding to the specified flags.
*/
-@export(name="audio_input_flags_t")
-enum AudioInputFlags {
- AUDIO_INPUT_FLAG_NONE = 0x0, // no attributes
- AUDIO_INPUT_FLAG_FAST = 0x1, // prefer an input that supports
- // "fast tracks"
- AUDIO_INPUT_FLAG_HW_HOTWORD = 0x2, // prefer an input that captures from
- // hw hotword source
- AUDIO_INPUT_FLAG_RAW = 0x4, // minimize signal processing
- AUDIO_INPUT_FLAG_SYNC = 0x8, // synchronize I/O streams
+@export(name="audio_input_flags_t", value_prefix="AUDIO_INPUT_FLAG_")
+enum AudioInputFlag {
+ NONE = 0x0, // no attributes
+ FAST = 0x1, // prefer an input that supports "fast tracks"
+ HW_HOTWORD = 0x2, // prefer an input that captures from hw hotword source
+ RAW = 0x4, // minimize signal processing
+ SYNC = 0x8, // synchronize I/O streams
};
/*
@@ -728,11 +671,11 @@
/*
* Type of gain control exposed by an audio port.
*/
-@export(name="")
+@export(name="", value_prefix="AUDIO_GAIN_MODE_")
enum AudioGainMode : uint32_t {
- AUDIO_GAIN_MODE_JOINT = 0x1, // supports joint channel gain control
- AUDIO_GAIN_MODE_CHANNELS = 0x2, // supports separate channel gain control
- AUDIO_GAIN_MODE_RAMP = 0x4 // supports gain ramps
+ JOINT = 0x1, // supports joint channel gain control
+ CHANNELS = 0x2, // supports separate channel gain control
+ RAMP = 0x4 // supports gain ramps
};
/*
@@ -785,24 +728,23 @@
*/
/* Audio port role: either source or sink */
-@export(name="audio_port_role_t")
+@export(name="audio_port_role_t", value_prefix="AUDIO_PORT_ROLE_")
enum AudioPortRole {
- AUDIO_PORT_ROLE_NONE,
- AUDIO_PORT_ROLE_SOURCE,
- AUDIO_PORT_ROLE_SINK,
+ NONE,
+ SOURCE,
+ SINK,
};
/*
- * Audio port type indicates if it is a session (e.g AudioTrack),
- * a mix (e.g PlaybackThread output) or a physical device
- * (e.g AUDIO_DEVICE_OUT_SPEAKER)
+ * Audio port type indicates if it is a session (e.g AudioTrack), a mix (e.g
+ * PlaybackThread output) or a physical device (e.g OUT_SPEAKER)
*/
-@export(name="audio_port_type_t")
+@export(name="audio_port_type_t", value_prefix="AUDIO_PORT_TYPE_")
enum AudioPortType {
- AUDIO_PORT_TYPE_NONE,
- AUDIO_PORT_TYPE_DEVICE,
- AUDIO_PORT_TYPE_MIX,
- AUDIO_PORT_TYPE_SESSION,
+ NONE,
+ DEVICE,
+ MIX,
+ SESSION,
};
/*
@@ -811,7 +753,7 @@
*/
struct AudioPortConfigDeviceExt {
AudioModuleHandle hwModule; // module the device is attached to
- AudioDevice type; // device type (e.g AUDIO_DEVICE_OUT_SPEAKER)
+ AudioDevice type; // device type (e.g OUT_SPEAKER)
uint8_t[32] address; // device address. "" if N/A
};
@@ -826,16 +768,13 @@
/*
* Flags indicating which fields are to be considered in AudioPortConfig.
*/
-@export(name="")
+@export(name="", value_prefix="AUDIO_PORT_CONFIG_")
enum AudioPortConfigMask : uint32_t {
- AUDIO_PORT_CONFIG_SAMPLE_RATE = 0x1,
- AUDIO_PORT_CONFIG_CHANNEL_MASK = 0x2,
- AUDIO_PORT_CONFIG_FORMAT = 0x4,
- AUDIO_PORT_CONFIG_GAIN = 0x8,
- AUDIO_PORT_CONFIG_ALL = AUDIO_PORT_CONFIG_SAMPLE_RATE |
- AUDIO_PORT_CONFIG_CHANNEL_MASK |
- AUDIO_PORT_CONFIG_FORMAT |
- AUDIO_PORT_CONFIG_GAIN
+ SAMPLE_RATE = 0x1,
+ CHANNEL_MASK = 0x2,
+ FORMAT = 0x4,
+ GAIN = 0x8,
+ ALL = SAMPLE_RATE | CHANNEL_MASK | FORMAT | GAIN
};
/*
@@ -877,10 +816,10 @@
/*
* Latency class of the audio mix.
*/
-@export(name="audio_mix_latency_class_t")
+@export(name="audio_mix_latency_class_t", value_prefix="AUDIO_LATENCY_")
enum AudioMixLatencyClass {
- AUDIO_LATENCY_LOW,
- AUDIO_LATENCY_NORMAL
+ LOW,
+ NORMAL
} ;
struct AudioPortMixExt {
diff --git a/audio/effect/2.0/types.hal b/audio/effect/2.0/types.hal
index 3560382..82f6766 100644
--- a/audio/effect/2.0/types.hal
+++ b/audio/effect/2.0/types.hal
@@ -108,109 +108,90 @@
* | | | have to implement a process function.
* +----------------+--------+--------------------------------------------------
*/
-// TODO(mnaganov): Consider if "EFFECT_FLAG_" prefix can be dropped.
+@export(name="", value_prefix="EFFECT_FLAG_")
enum EffectFlags {
// Insert mode
- EFFECT_FLAG_TYPE_SHIFT = 0,
- EFFECT_FLAG_TYPE_SIZE = 3,
- EFFECT_FLAG_TYPE_MASK =
- ((1 << EFFECT_FLAG_TYPE_SIZE) -1) << EFFECT_FLAG_TYPE_SHIFT,
- EFFECT_FLAG_TYPE_INSERT = 0 << EFFECT_FLAG_TYPE_SHIFT,
- EFFECT_FLAG_TYPE_AUXILIARY = 1 << EFFECT_FLAG_TYPE_SHIFT,
- EFFECT_FLAG_TYPE_REPLACE = 2 << EFFECT_FLAG_TYPE_SHIFT,
- EFFECT_FLAG_TYPE_PRE_PROC = 3 << EFFECT_FLAG_TYPE_SHIFT,
- EFFECT_FLAG_TYPE_POST_PROC = 4 << EFFECT_FLAG_TYPE_SHIFT,
+ TYPE_SHIFT = 0,
+ TYPE_SIZE = 3,
+ TYPE_MASK = ((1 << TYPE_SIZE) -1) << TYPE_SHIFT,
+ TYPE_INSERT = 0 << TYPE_SHIFT,
+ TYPE_AUXILIARY = 1 << TYPE_SHIFT,
+ TYPE_REPLACE = 2 << TYPE_SHIFT,
+ TYPE_PRE_PROC = 3 << TYPE_SHIFT,
+ TYPE_POST_PROC = 4 << TYPE_SHIFT,
// Insert preference
- EFFECT_FLAG_INSERT_SHIFT = EFFECT_FLAG_TYPE_SHIFT + EFFECT_FLAG_TYPE_SIZE,
- EFFECT_FLAG_INSERT_SIZE = 3,
- EFFECT_FLAG_INSERT_MASK =
- ((1 << EFFECT_FLAG_INSERT_SIZE) -1) << EFFECT_FLAG_INSERT_SHIFT,
- EFFECT_FLAG_INSERT_ANY = 0 << EFFECT_FLAG_INSERT_SHIFT,
- EFFECT_FLAG_INSERT_FIRST = 1 << EFFECT_FLAG_INSERT_SHIFT,
- EFFECT_FLAG_INSERT_LAST = 2 << EFFECT_FLAG_INSERT_SHIFT,
- EFFECT_FLAG_INSERT_EXCLUSIVE = 3 << EFFECT_FLAG_INSERT_SHIFT,
+ INSERT_SHIFT = TYPE_SHIFT + TYPE_SIZE,
+ INSERT_SIZE = 3,
+ INSERT_MASK = ((1 << INSERT_SIZE) -1) << INSERT_SHIFT,
+ INSERT_ANY = 0 << INSERT_SHIFT,
+ INSERT_FIRST = 1 << INSERT_SHIFT,
+ INSERT_LAST = 2 << INSERT_SHIFT,
+ INSERT_EXCLUSIVE = 3 << INSERT_SHIFT,
// Volume control
- EFFECT_FLAG_VOLUME_SHIFT =
- EFFECT_FLAG_INSERT_SHIFT + EFFECT_FLAG_INSERT_SIZE,
- EFFECT_FLAG_VOLUME_SIZE = 3,
- EFFECT_FLAG_VOLUME_MASK =
- ((1 << EFFECT_FLAG_VOLUME_SIZE) -1) << EFFECT_FLAG_VOLUME_SHIFT,
- EFFECT_FLAG_VOLUME_CTRL = 1 << EFFECT_FLAG_VOLUME_SHIFT,
- EFFECT_FLAG_VOLUME_IND = 2 << EFFECT_FLAG_VOLUME_SHIFT,
- EFFECT_FLAG_VOLUME_NONE = 0 << EFFECT_FLAG_VOLUME_SHIFT,
+ VOLUME_SHIFT = INSERT_SHIFT + INSERT_SIZE,
+ VOLUME_SIZE = 3,
+ VOLUME_MASK = ((1 << VOLUME_SIZE) -1) << VOLUME_SHIFT,
+ VOLUME_CTRL = 1 << VOLUME_SHIFT,
+ VOLUME_IND = 2 << VOLUME_SHIFT,
+ VOLUME_NONE = 0 << VOLUME_SHIFT,
// Device indication
- EFFECT_FLAG_DEVICE_SHIFT =
- EFFECT_FLAG_VOLUME_SHIFT + EFFECT_FLAG_VOLUME_SIZE,
- EFFECT_FLAG_DEVICE_SIZE = 3,
- EFFECT_FLAG_DEVICE_MASK =
- ((1 << EFFECT_FLAG_DEVICE_SIZE) -1) << EFFECT_FLAG_DEVICE_SHIFT,
- EFFECT_FLAG_DEVICE_IND = 1 << EFFECT_FLAG_DEVICE_SHIFT,
- EFFECT_FLAG_DEVICE_NONE = 0 << EFFECT_FLAG_DEVICE_SHIFT,
+ DEVICE_SHIFT = VOLUME_SHIFT + VOLUME_SIZE,
+ DEVICE_SIZE = 3,
+ DEVICE_MASK = ((1 << DEVICE_SIZE) -1) << DEVICE_SHIFT,
+ DEVICE_IND = 1 << DEVICE_SHIFT,
+ DEVICE_NONE = 0 << DEVICE_SHIFT,
// Sample input modes
- EFFECT_FLAG_INPUT_SHIFT =
- EFFECT_FLAG_DEVICE_SHIFT + EFFECT_FLAG_DEVICE_SIZE,
- EFFECT_FLAG_INPUT_SIZE = 2,
- EFFECT_FLAG_INPUT_MASK =
- ((1 << EFFECT_FLAG_INPUT_SIZE) -1) << EFFECT_FLAG_INPUT_SHIFT,
- EFFECT_FLAG_INPUT_DIRECT = 1 << EFFECT_FLAG_INPUT_SHIFT,
- EFFECT_FLAG_INPUT_PROVIDER = 2 << EFFECT_FLAG_INPUT_SHIFT,
- EFFECT_FLAG_INPUT_BOTH = 3 << EFFECT_FLAG_INPUT_SHIFT,
+ INPUT_SHIFT = DEVICE_SHIFT + DEVICE_SIZE,
+ INPUT_SIZE = 2,
+ INPUT_MASK = ((1 << INPUT_SIZE) -1) << INPUT_SHIFT,
+ INPUT_DIRECT = 1 << INPUT_SHIFT,
+ INPUT_PROVIDER = 2 << INPUT_SHIFT,
+ INPUT_BOTH = 3 << INPUT_SHIFT,
// Sample output modes
- EFFECT_FLAG_OUTPUT_SHIFT = EFFECT_FLAG_INPUT_SHIFT + EFFECT_FLAG_INPUT_SIZE,
- EFFECT_FLAG_OUTPUT_SIZE = 2,
- EFFECT_FLAG_OUTPUT_MASK =
- ((1 << EFFECT_FLAG_OUTPUT_SIZE) -1) << EFFECT_FLAG_OUTPUT_SHIFT,
- EFFECT_FLAG_OUTPUT_DIRECT = 1 << EFFECT_FLAG_OUTPUT_SHIFT,
- EFFECT_FLAG_OUTPUT_PROVIDER = 2 << EFFECT_FLAG_OUTPUT_SHIFT,
- EFFECT_FLAG_OUTPUT_BOTH = 3 << EFFECT_FLAG_OUTPUT_SHIFT,
+ OUTPUT_SHIFT = INPUT_SHIFT + INPUT_SIZE,
+ OUTPUT_SIZE = 2,
+ OUTPUT_MASK = ((1 << OUTPUT_SIZE) -1) << OUTPUT_SHIFT,
+ OUTPUT_DIRECT = 1 << OUTPUT_SHIFT,
+ OUTPUT_PROVIDER = 2 << OUTPUT_SHIFT,
+ OUTPUT_BOTH = 3 << OUTPUT_SHIFT,
// Hardware acceleration mode
- EFFECT_FLAG_HW_ACC_SHIFT =
- EFFECT_FLAG_OUTPUT_SHIFT + EFFECT_FLAG_OUTPUT_SIZE,
- EFFECT_FLAG_HW_ACC_SIZE = 2,
- EFFECT_FLAG_HW_ACC_MASK =
- ((1 << EFFECT_FLAG_HW_ACC_SIZE) -1) << EFFECT_FLAG_HW_ACC_SHIFT,
- EFFECT_FLAG_HW_ACC_SIMPLE = 1 << EFFECT_FLAG_HW_ACC_SHIFT,
- EFFECT_FLAG_HW_ACC_TUNNEL = 2 << EFFECT_FLAG_HW_ACC_SHIFT,
+ HW_ACC_SHIFT = OUTPUT_SHIFT + OUTPUT_SIZE,
+ HW_ACC_SIZE = 2,
+ HW_ACC_MASK = ((1 << HW_ACC_SIZE) -1) << HW_ACC_SHIFT,
+ HW_ACC_SIMPLE = 1 << HW_ACC_SHIFT,
+ HW_ACC_TUNNEL = 2 << HW_ACC_SHIFT,
// Audio mode indication
- EFFECT_FLAG_AUDIO_MODE_SHIFT =
- EFFECT_FLAG_HW_ACC_SHIFT + EFFECT_FLAG_HW_ACC_SIZE,
- EFFECT_FLAG_AUDIO_MODE_SIZE = 2,
- EFFECT_FLAG_AUDIO_MODE_MASK =
- ((1 << EFFECT_FLAG_AUDIO_MODE_SIZE) -1) << EFFECT_FLAG_AUDIO_MODE_SHIFT,
- EFFECT_FLAG_AUDIO_MODE_IND = 1 << EFFECT_FLAG_AUDIO_MODE_SHIFT,
- EFFECT_FLAG_AUDIO_MODE_NONE = 0 << EFFECT_FLAG_AUDIO_MODE_SHIFT,
+ AUDIO_MODE_SHIFT = HW_ACC_SHIFT + HW_ACC_SIZE,
+ AUDIO_MODE_SIZE = 2,
+ AUDIO_MODE_MASK = ((1 << AUDIO_MODE_SIZE) -1) << AUDIO_MODE_SHIFT,
+ AUDIO_MODE_IND = 1 << AUDIO_MODE_SHIFT,
+ AUDIO_MODE_NONE = 0 << AUDIO_MODE_SHIFT,
// Audio source indication
- EFFECT_FLAG_AUDIO_SOURCE_SHIFT =
- EFFECT_FLAG_AUDIO_MODE_SHIFT + EFFECT_FLAG_AUDIO_MODE_SIZE,
- EFFECT_FLAG_AUDIO_SOURCE_SIZE = 2,
- EFFECT_FLAG_AUDIO_SOURCE_MASK = ((1 << EFFECT_FLAG_AUDIO_SOURCE_SIZE) -1)
- << EFFECT_FLAG_AUDIO_SOURCE_SHIFT,
- EFFECT_FLAG_AUDIO_SOURCE_IND = 1 << EFFECT_FLAG_AUDIO_SOURCE_SHIFT,
- EFFECT_FLAG_AUDIO_SOURCE_NONE = 0 << EFFECT_FLAG_AUDIO_SOURCE_SHIFT,
+ AUDIO_SOURCE_SHIFT = AUDIO_MODE_SHIFT + AUDIO_MODE_SIZE,
+ AUDIO_SOURCE_SIZE = 2,
+ AUDIO_SOURCE_MASK = ((1 << AUDIO_SOURCE_SIZE) -1) << AUDIO_SOURCE_SHIFT,
+ AUDIO_SOURCE_IND = 1 << AUDIO_SOURCE_SHIFT,
+ AUDIO_SOURCE_NONE = 0 << AUDIO_SOURCE_SHIFT,
// Effect offload indication
- EFFECT_FLAG_OFFLOAD_SHIFT =
- EFFECT_FLAG_AUDIO_SOURCE_SHIFT + EFFECT_FLAG_AUDIO_SOURCE_SIZE,
- EFFECT_FLAG_OFFLOAD_SIZE = 1,
- EFFECT_FLAG_OFFLOAD_MASK =
- ((1 << EFFECT_FLAG_OFFLOAD_SIZE) -1) << EFFECT_FLAG_OFFLOAD_SHIFT,
- EFFECT_FLAG_OFFLOAD_SUPPORTED = 1 << EFFECT_FLAG_OFFLOAD_SHIFT,
+ OFFLOAD_SHIFT = AUDIO_SOURCE_SHIFT + AUDIO_SOURCE_SIZE,
+ OFFLOAD_SIZE = 1,
+ OFFLOAD_MASK = ((1 << OFFLOAD_SIZE) -1) << OFFLOAD_SHIFT,
+ OFFLOAD_SUPPORTED = 1 << OFFLOAD_SHIFT,
// Effect has no process indication
- EFFECT_FLAG_NO_PROCESS_SHIFT =
- EFFECT_FLAG_OFFLOAD_SHIFT + EFFECT_FLAG_OFFLOAD_SIZE,
- EFFECT_FLAG_NO_PROCESS_SIZE = 1,
- EFFECT_FLAG_NO_PROCESS_MASK =
- ((1 << EFFECT_FLAG_NO_PROCESS_SIZE) -1) << EFFECT_FLAG_NO_PROCESS_SHIFT,
- EFFECT_FLAG_NO_PROCESS = 1 << EFFECT_FLAG_NO_PROCESS_SHIFT
+ NO_PROCESS_SHIFT = OFFLOAD_SHIFT + OFFLOAD_SIZE,
+ NO_PROCESS_SIZE = 1,
+ NO_PROCESS_MASK = ((1 << NO_PROCESS_SIZE) -1) << NO_PROCESS_SHIFT,
+ NO_PROCESS = 1 << NO_PROCESS_SHIFT
};
/*
@@ -246,24 +227,24 @@
vec<uint8_t> data;
};
+@export(name="effect_buffer_access_e", value_prefix="EFFECT_BUFFER_")
enum EffectBufferAccess {
- EFFECT_BUFFER_ACCESS_WRITE,
- EFFECT_BUFFER_ACCESS_READ,
- EFFECT_BUFFER_ACCESS_ACCUMULATE
+ ACCESS_WRITE,
+ ACCESS_READ,
+ ACCESS_ACCUMULATE
};
/*
* Determines what fields of EffectBufferConfig need to be considered.
*/
+@export(name="", value_prefix="EFFECT_CONFIG_")
enum EffectConfigParameters {
- EFFECT_CONFIG_BUFFER = 0x0001, // buffer field
- EFFECT_CONFIG_SMP_RATE = 0x0002, // samplingRate
- EFFECT_CONFIG_CHANNELS = 0x0004, // channels
- EFFECT_CONFIG_FORMAT = 0x0008, // format
- EFFECT_CONFIG_ACC_MODE = 0x0010, // accessMode
- EFFECT_CONFIG_ALL = EFFECT_CONFIG_BUFFER | EFFECT_CONFIG_SMP_RATE |
- EFFECT_CONFIG_CHANNELS | EFFECT_CONFIG_FORMAT |
- EFFECT_CONFIG_ACC_MODE
+ BUFFER = 0x0001, // buffer field
+ SMP_RATE = 0x0002, // samplingRate
+ CHANNELS = 0x0004, // channels
+ FORMAT = 0x0008, // format
+ ACC_MODE = 0x0010, // accessMode
+ ALL = BUFFER | SMP_RATE | CHANNELS | FORMAT | ACC_MODE
};
/*
@@ -284,10 +265,11 @@
EffectBufferConfig outputCfg;
};
+@export(name="effect_feature_e", value_prefix="EFFECT_FEATURE_")
enum EffectFeature {
- EFFECT_FEATURE_AUX_CHANNELS, // supports auxiliary channels
- // (e.g. dual mic noise suppressor)
- EFFECT_FEATURE_CNT
+ AUX_CHANNELS, // supports auxiliary channels
+ // (e.g. dual mic noise suppressor)
+ CNT
};
struct EffectFeatureConfig {
diff --git a/power/1.0/Android.bp b/power/1.0/Android.bp
new file mode 100644
index 0000000..9b4d81e
--- /dev/null
+++ b/power/1.0/Android.bp
@@ -0,0 +1,46 @@
+// This file is autogenerated by hidl-gen. Do not edit manually.
+
+genrule {
+ name: "android.hardware.power@1.0_genc++",
+ tool: "hidl-gen",
+ cmd: "$tool -o $genDir -Lc++ -randroid.hardware:hardware/interfaces android.hardware.power@1.0",
+ srcs: [
+ "types.hal",
+ "IPower.hal",
+ ],
+ out: [
+ "android/hardware/power/1.0/types.cpp",
+ "android/hardware/power/1.0/PowerAll.cpp",
+ ],
+}
+
+genrule {
+ name: "android.hardware.power@1.0_genc++_headers",
+ tool: "hidl-gen",
+ cmd: "$tool -o $genDir -Lc++ -randroid.hardware:hardware/interfaces android.hardware.power@1.0",
+ srcs: [
+ "types.hal",
+ "IPower.hal",
+ ],
+ out: [
+ "android/hardware/power/1.0/types.h",
+ "android/hardware/power/1.0/IPower.h",
+ "android/hardware/power/1.0/IHwPower.h",
+ "android/hardware/power/1.0/BnPower.h",
+ "android/hardware/power/1.0/BpPower.h",
+ "android/hardware/power/1.0/BsPower.h",
+ ],
+}
+
+cc_library_shared {
+ name: "android.hardware.power@1.0",
+ generated_sources: ["android.hardware.power@1.0_genc++"],
+ generated_headers: ["android.hardware.power@1.0_genc++_headers"],
+ export_generated_headers: ["android.hardware.power@1.0_genc++_headers"],
+ shared_libs: [
+ "libhidl",
+ "libhwbinder",
+ "libutils",
+ "libcutils",
+ ],
+}
diff --git a/power/1.0/Android.mk b/power/1.0/Android.mk
new file mode 100644
index 0000000..5f1260b
--- /dev/null
+++ b/power/1.0/Android.mk
@@ -0,0 +1,238 @@
+# This file is autogenerated by hidl-gen. Do not edit manually.
+
+LOCAL_PATH := $(call my-dir)
+
+################################################################################
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := android.hardware.power@1.0-java
+LOCAL_MODULE_CLASS := JAVA_LIBRARIES
+
+intermediates := $(local-generated-sources-dir)
+
+HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
+
+#
+# Build types.hal (Feature)
+#
+GEN := $(intermediates)/android/hardware/power/1.0/Feature.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava -randroid.hardware:hardware/interfaces \
+ android.hardware.power@1.0::types.Feature
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (PowerHint)
+#
+GEN := $(intermediates)/android/hardware/power/1.0/PowerHint.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava -randroid.hardware:hardware/interfaces \
+ android.hardware.power@1.0::types.PowerHint
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (PowerStatePlatformSleepState)
+#
+GEN := $(intermediates)/android/hardware/power/1.0/PowerStatePlatformSleepState.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava -randroid.hardware:hardware/interfaces \
+ android.hardware.power@1.0::types.PowerStatePlatformSleepState
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (PowerStateVoter)
+#
+GEN := $(intermediates)/android/hardware/power/1.0/PowerStateVoter.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava -randroid.hardware:hardware/interfaces \
+ android.hardware.power@1.0::types.PowerStateVoter
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (Status)
+#
+GEN := $(intermediates)/android/hardware/power/1.0/Status.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava -randroid.hardware:hardware/interfaces \
+ android.hardware.power@1.0::types.Status
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build IPower.hal
+#
+GEN := $(intermediates)/android/hardware/power/1.0/IPower.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IPower.hal
+$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/types.hal
+$(GEN): $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava -randroid.hardware:hardware/interfaces \
+ android.hardware.power@1.0::IPower
+
+$(GEN): $(LOCAL_PATH)/IPower.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+include $(BUILD_JAVA_LIBRARY)
+
+
+################################################################################
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := android.hardware.power@1.0-java-static
+LOCAL_MODULE_CLASS := JAVA_LIBRARIES
+
+intermediates := $(local-generated-sources-dir)
+
+HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
+
+#
+# Build types.hal (Feature)
+#
+GEN := $(intermediates)/android/hardware/power/1.0/Feature.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava -randroid.hardware:hardware/interfaces \
+ android.hardware.power@1.0::types.Feature
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (PowerHint)
+#
+GEN := $(intermediates)/android/hardware/power/1.0/PowerHint.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava -randroid.hardware:hardware/interfaces \
+ android.hardware.power@1.0::types.PowerHint
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (PowerStatePlatformSleepState)
+#
+GEN := $(intermediates)/android/hardware/power/1.0/PowerStatePlatformSleepState.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava -randroid.hardware:hardware/interfaces \
+ android.hardware.power@1.0::types.PowerStatePlatformSleepState
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (PowerStateVoter)
+#
+GEN := $(intermediates)/android/hardware/power/1.0/PowerStateVoter.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava -randroid.hardware:hardware/interfaces \
+ android.hardware.power@1.0::types.PowerStateVoter
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (Status)
+#
+GEN := $(intermediates)/android/hardware/power/1.0/Status.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava -randroid.hardware:hardware/interfaces \
+ android.hardware.power@1.0::types.Status
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build IPower.hal
+#
+GEN := $(intermediates)/android/hardware/power/1.0/IPower.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IPower.hal
+$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/types.hal
+$(GEN): $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava -randroid.hardware:hardware/interfaces \
+ android.hardware.power@1.0::IPower
+
+$(GEN): $(LOCAL_PATH)/IPower.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+include $(BUILD_STATIC_JAVA_LIBRARY)
+
+
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/power/1.0/IPower.hal b/power/1.0/IPower.hal
new file mode 100644
index 0000000..6cba42a
--- /dev/null
+++ b/power/1.0/IPower.hal
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.hardware.power@1.0;
+
+/*
+ * Constructor for the interface performs power management setup actions at
+ * runtime startup, such as to set default cpufreq parameters.
+ */
+interface IPower {
+ /*
+ * setInteractive() performs power management actions upon the
+ * system entering interactive state (that is, the system is awake
+ * and ready for interaction, often with UI devices such as
+ * display and touchscreen enabled) or non-interactive state (the
+ * system appears asleep, display usually turned off). The
+ * non-interactive state may be entered after a period of
+ * inactivity in order to conserve battery power during
+ * such inactive periods.
+ *
+ * Typical actions are to turn on or off devices and adjust
+ * cpufreq parameters. This function may also call the
+ * appropriate interfaces to allow the kernel to suspend the
+ * system to low-power sleep state when entering non-interactive
+ * state, and to disallow low-power suspend when the system is in
+ * interactive state. When low-power suspend state is allowed, the
+ * kernel may suspend the system whenever no wakelocks are held.
+ *
+ * For example,
+ * This function can be called to enter non-interactive state after
+ * turning off the screen (if present) and called to enter
+ * interactive state prior to turning on the screen.
+ *
+ * @param interactive is true when the system is transitioning to an
+ * interactive state and false when transitioning to a
+ * non-interactive state.
+ */
+ setInteractive(bool interactive);
+
+ /*
+ * powerHint() is called to pass hints on power requirements which
+ * may result in adjustment of power/performance parameters of the
+ * cpufreq governor and other controls.
+ *
+ * A particular platform may choose to ignore any hint.
+ *
+ * @param hint PowerHint which is passed
+ * @param data contains additional information about the hint
+ * and is described along with the comments for each of the hints.
+ */
+ powerHint(PowerHint hint, int32_t data);
+
+ /*
+ * setFeature() is called to turn on or off a particular feature
+ * depending on the state parameter.
+ *
+ * @param feature Feature which needs to be set
+ * @param activate true/false to enable/disable the feature
+ */
+ setFeature(Feature feature, bool activate);
+
+ /*
+ * Platform-level sleep state stats:
+ * Report cumulative info on the statistics on platform-level sleep states
+ * since boot.
+ *
+ * Higher the index in the returned <states> vector deeper the state is
+ * i.e. lesser steady-state power is consumed by the platform to be
+ * resident in that state.
+ *
+ * @return states of power states the device supports
+ * @return retval SUCCESS on success or FILESYSTEM_ERROR on filesystem
+ * nodes access error.
+ */
+ getPlatformLowPowerStats()
+ generates (vec<PowerStatePlatformSleepState> states, Status retval);
+};
diff --git a/power/1.0/default/Android.bp b/power/1.0/default/Android.bp
new file mode 100644
index 0000000..4c31c6f
--- /dev/null
+++ b/power/1.0/default/Android.bp
@@ -0,0 +1,46 @@
+// Copyright (C) 2016 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+cc_library_shared {
+ name: "android.hardware.power@1.0-impl",
+ relative_install_path: "hw",
+ srcs: ["Power.cpp"],
+
+ shared_libs: [
+ "liblog",
+ "libhardware",
+ "libhidl",
+ "libhwbinder",
+ "libutils",
+ "android.hardware.power@1.0",
+ ],
+
+}
+
+cc_binary {
+ relative_install_path: "hw",
+ name: "android.hardware.power@1.0-service",
+ srcs: ["service.cpp"],
+
+ shared_libs: [
+ "liblog",
+ "libdl",
+ "libutils",
+ "libhardware",
+ "libhidl",
+ "libhwbinder",
+ "android.hardware.power@1.0",
+ ],
+
+}
diff --git a/power/1.0/default/Power.cpp b/power/1.0/default/Power.cpp
new file mode 100644
index 0000000..5d0593b
--- /dev/null
+++ b/power/1.0/default/Power.cpp
@@ -0,0 +1,159 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "android.hardware.power@1.0-impl"
+#include <hardware/hardware.h>
+#include <hardware/power.h>
+#include "Power.h"
+
+namespace android {
+namespace hardware {
+namespace power {
+namespace V1_0 {
+namespace implementation {
+
+Power::Power(power_module_t *module) : mModule(module) {
+ if (mModule)
+ mModule->init(mModule);
+}
+
+Power::~Power() {
+ delete(mModule);
+}
+
+// Methods from ::android::hardware::power::V1_0::IPower follow.
+Return<void> Power::setInteractive(bool interactive) {
+ if (mModule->setInteractive > 0)
+ mModule->setInteractive(mModule, interactive ? 1 : 0);
+ return Void();
+}
+
+Return<void> Power::powerHint(PowerHint hint, int32_t data) {
+ int32_t param = data;
+ if (mModule->powerHint > 0)
+ mModule->powerHint(mModule, static_cast<power_hint_t>(hint), ¶m);
+ return Void();
+}
+
+Return<void> Power::setFeature(Feature feature, bool activate) {
+ if (mModule->setFeature > 0)
+ mModule->setFeature(mModule, static_cast<feature_t>(feature),
+ activate ? 1 : 0);
+ return Void();
+}
+
+Return<void> Power::getPlatformLowPowerStats(getPlatformLowPowerStats_cb _hidl_cb) {
+ hidl_vec<PowerStatePlatformSleepState> states;
+ ssize_t number_platform_modes;
+ size_t *voters = nullptr;
+ power_state_platform_sleep_state_t *legacy_states = nullptr;
+ int ret;
+
+ if (mModule->get_number_of_platform_modes == nullptr ||
+ mModule->get_voter_list == nullptr ||
+ mModule->get_platform_low_power_stats == nullptr)
+ {
+ _hidl_cb(states, Status::SUCCESS);
+ return Void();
+ }
+
+ number_platform_modes = mModule->get_number_of_platform_modes(mModule);
+ if (number_platform_modes > 0)
+ {
+ voters = new size_t [number_platform_modes];
+ if (voters == nullptr)
+ goto done;
+
+ ret = mModule->get_voter_list(mModule, voters);
+ if (ret != 0)
+ goto done;
+
+ legacy_states = new power_state_platform_sleep_state_t [number_platform_modes];
+ if (legacy_states == nullptr)
+ goto done;
+
+ for (int i = 0; i < number_platform_modes; i++)
+ {
+ legacy_states[i].voters = nullptr;
+ legacy_states[i].voters = new power_state_voter_t [voters[i]];
+ if (legacy_states[i].voters == nullptr)
+ goto done;
+ }
+
+ ret = mModule->get_platform_low_power_stats(mModule, legacy_states);
+ if (ret != 0)
+ goto done;
+
+ states.resize(number_platform_modes);
+ for (int i = 0; i < number_platform_modes; i++)
+ {
+ power_state_platform_sleep_state_t& legacy_state = legacy_states[i];
+ PowerStatePlatformSleepState& state = states[i];
+ state.name = legacy_state.name;
+ state.residencyInMsecSinceBoot = legacy_state.residency_in_msec_since_boot;
+ state.totalTransitions = legacy_state.total_transitions;
+ state.supportedOnlyInSuspend = legacy_state.supported_only_in_suspend;
+ state.voters.resize(voters[i]);
+ for(size_t j = 0; j < voters[i]; j++)
+ {
+ state.voters[j].name = legacy_state.voters[j].name;
+ state.voters[j].totalTimeInMsecVotedForSinceBoot = legacy_state.voters[j].total_time_in_msec_voted_for_since_boot;
+ state.voters[j].totalNumberOfTimesVotedSinceBoot = legacy_state.voters[j].total_number_of_times_voted_since_boot;
+ }
+ }
+ }
+done:
+ if (legacy_states)
+ {
+ for (int i = 0; i < number_platform_modes; i++)
+ {
+ if(legacy_states[i].voters)
+ delete(legacy_states[i].voters);
+ }
+ }
+ delete[] legacy_states;
+ delete[] voters;
+ _hidl_cb(states, Status::SUCCESS);
+ return Void();
+}
+
+IPower* HIDL_FETCH_IPower(const char* name) {
+ int ret = 0;
+ const hw_module_t* hw_module = NULL;
+ power_module_t *power_module;
+ ret = hw_get_module(name, &hw_module);
+ if (ret == 0 && hw_module->methods->open > 0) {
+ ret = hw_module->methods->open(hw_module, name,
+ reinterpret_cast<hw_device_t**>(&power_module));
+ if (ret == 0) {
+ return new Power(power_module);
+ }
+ else {
+ ALOGE("Passthrough failed to load legacy HAL.");
+ return nullptr;
+ }
+ }
+ else {
+ ALOGE ("hw_get_module %s failed: %d", name, ret);
+ return nullptr;
+ }
+}
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace power
+} // namespace hardware
+} // namespace android
diff --git a/power/1.0/default/Power.h b/power/1.0/default/Power.h
new file mode 100644
index 0000000..a0495be
--- /dev/null
+++ b/power/1.0/default/Power.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef HIDL_GENERATED_android_hardware_power_V1_0_Power_H_
+#define HIDL_GENERATED_android_hardware_power_V1_0_Power_H_
+
+#include <android/hardware/power/1.0/IPower.h>
+#include <hidl/Status.h>
+
+#include <hidl/MQDescriptor.h>
+namespace android {
+namespace hardware {
+namespace power {
+namespace V1_0 {
+namespace implementation {
+
+using ::android::hardware::power::V1_0::Feature;
+using ::android::hardware::power::V1_0::IPower;
+using ::android::hardware::power::V1_0::PowerHint;
+using ::android::hardware::power::V1_0::PowerStatePlatformSleepState;
+using ::android::hardware::power::V1_0::Status;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+using ::android::hardware::hidl_vec;
+using ::android::hardware::hidl_string;
+using ::android::sp;
+
+struct Power : public IPower {
+ Power(power_module_t* module);
+ ~Power();
+ Return<void> setInteractive(bool interactive) override;
+ Return<void> powerHint(PowerHint hint, int32_t data) override;
+ Return<void> setFeature(Feature feature, bool activate) override;
+ Return<void> getPlatformLowPowerStats(getPlatformLowPowerStats_cb _hidl_cb) override;
+
+ private:
+ power_module_t* mModule;
+};
+
+extern "C" IPower* HIDL_FETCH_IPower(const char* name);
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace power
+} // namespace hardware
+} // namespace android
+
+#endif // HIDL_GENERATED_android_hardware_power_V1_0_Power_H_
diff --git a/power/1.0/default/service.cpp b/power/1.0/default/service.cpp
new file mode 100644
index 0000000..bad1adf
--- /dev/null
+++ b/power/1.0/default/service.cpp
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "android.hardware.power@1.0-service"
+#include <utils/Log.h>
+
+#include <iostream>
+#include <unistd.h>
+
+#include <android/hardware/power/1.0/IPower.h>
+
+#include <hidl/IServiceManager.h>
+#include <hwbinder/IPCThreadState.h>
+#include <hwbinder/ProcessState.h>
+#include <utils/Errors.h>
+#include <utils/StrongPointer.h>
+
+using android::sp;
+
+using android::hardware::IPCThreadState;
+using android::hardware::ProcessState;
+
+using android::hardware::power::V1_0::IPower;
+
+int main() {
+ const char instance[] = "power";
+ android::sp<IPower> service = IPower::getService(instance, true);
+ if (service.get() == nullptr) {
+ ALOGE("IPower::getService returned NULL, exiting");
+ return -1;
+ }
+ LOG_FATAL_IF(service->isRemote(), "Implementation is REMOTE!");
+ service->registerAsService(instance);
+
+ ProcessState::self()->setThreadPoolMaxThreadCount(0);
+ ProcessState::self()->startThreadPool();
+ IPCThreadState::self()->joinThreadPool();
+}
diff --git a/power/1.0/types.hal b/power/1.0/types.hal
new file mode 100644
index 0000000..c27242e
--- /dev/null
+++ b/power/1.0/types.hal
@@ -0,0 +1,168 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.hardware.power@1.0;
+
+/* Power hint identifiers passed to powerHint() */
+enum PowerHint : uint32_t {
+ /*
+ * Foreground app has started or stopped requesting a VSYNC pulse
+ * from SurfaceFlinger. If the app has started requesting VSYNC
+ * then CPU and GPU load is expected soon, and it may be appropriate
+ * to raise speeds of CPU, memory bus, etc. The data parameter is
+ * non-zero to indicate VSYNC pulse is now requested, or zero for
+ * VSYNC pulse no longer requested.
+ */
+ VSYNC = 0x00000001,
+
+
+ /*
+ * User is interacting with the device, for example, touchscreen
+ * events are incoming. CPU and GPU load may be expected soon,
+ * and it may be appropriate to raise speeds of CPU, memory bus,
+ * etc. The data parameter is the estimated length of the interaction
+ * in milliseconds, or 0 if unknown.
+ */
+ INTERACTION = 0x00000002,
+
+
+ /* DO NOT USE VIDEO_ENCODE/_DECODE! They will be removed in
+ * KLP.
+ */
+ VIDEO_ENCODE = 0x00000003,
+ VIDEO_DECODE = 0x00000004,
+
+ /*
+ * Low power mode is activated or deactivated. Low power mode
+ * is intended to save battery at the cost of performance. The data
+ * parameter is non-zero when low power mode is activated, and zero
+ * when deactivated.
+ */
+ LOW_POWER = 0x00000005,
+
+ /*
+ * Sustained Performance mode is actived or deactivated. Sustained
+ * performance mode is intended to provide a consistent level of
+ * performance for a prolonged amount of time. The data parameter is
+ * non-zero when sustained performance mode is activated, and zero
+ * when deactivated.
+ */
+ SUSTAINED_PERFORMANCE = 0x00000006,
+
+ /*
+ * VR Mode is activated or deactivated. VR mode is intended to
+ * provide minimum guarantee for performance for the amount of time the
+ * device can sustain it. The data parameter is non-zero when the mode
+ * is activated and zero when deactivated.
+ */
+ VR_MODE = 0x00000007,
+
+ /*
+ * This hint indicates that an application has been launched. Can be used
+ * for device specific optimizations during application launch. The data
+ * parameter is non-zero when the application starts to launch and zero when
+ * it has been launched.
+ */
+ LAUNCH = 0x00000008,
+
+ /*
+ * When device enters some special modes, e.g. theater mode in Android
+ * Wear, there is no touch interaction expected between device and user.
+ * Touch controller could be disabled in those modes to save power.
+ * The data parameter is non-zero when touch could be disabled, and zero
+ * when touch needs to be re-enabled.
+ */
+ DISABLE_TOUCH = 0x00000009
+};
+
+enum Feature : uint32_t {
+ /*
+ * Enabling/Disabling this feature will allow/disallow the system
+ * to wake up by tapping the screen twice.
+ */
+ POWER_FEATURE_DOUBLE_TAP_TO_WAKE = 0x00000001
+};
+
+enum Status : uint32_t {
+ SUCCESS = 0,
+ FILESYSTEM_ERROR = 1
+};
+/*
+ * Platform-level sleep state stats:
+ * PowerStateVoter struct is useful for describing the individual voters
+ * when a Platform-level sleep state is chosen by aggregation of votes from
+ * multiple clients/system conditions.
+ *
+ * This helps in attirbuting what in the device is blocking the device from
+ * entering the lowest Platform-level sleep state.
+ */
+struct PowerStateVoter {
+ /*
+ * Name of the voter.
+ */
+ string name;
+
+ /*
+ * Total time in msec the voter voted for the platform sleep state since
+ * boot.
+ */
+ uint64_t totalTimeInMsecVotedForSinceBoot;
+
+ /*
+ * Number of times the voter voted for the platform sleep state since boot.
+ */
+ uint64_t totalNumberOfTimesVotedSinceBoot;
+};
+
+/*
+ * Platform-level sleep state stats:
+ * PowerStatePlatformSleepState represents the Platform-level sleep state
+ * the device is capable of getting into.
+ *
+ * SoCs usually have more than one Platform-level sleep state.
+ */
+struct PowerStatePlatformSleepState {
+ /*
+ * Platform-level Sleep state name.
+ */
+ string name;
+
+ /*
+ * Time spent in msec at this platform-level sleep state since boot.
+ */
+ uint64_t residencyInMsecSinceBoot;
+
+ /*
+ * Total number of times system entered this state.
+ */
+ uint64_t totalTransitions;
+
+ /*
+ * This platform-level sleep state can only be reached during system suspend
+ */
+ bool supportedOnlyInSuspend;
+
+ /*
+ * voters is useful if the Platform-level sleep state
+ * is chosen by aggregation votes from multiple clients/system conditions.
+ * All the voters have to say yes or all the system conditions need to be
+ * met to enter a platform-level sleep state.
+ *
+ * Vector of size zero implies either the info is not available
+ * or the system does not follow a voting mechanism to choose this
+ * Platform-level sleep state.
+ */
+ vec<PowerStateVoter> voters;
+};
diff --git a/tests/foo/1.0/IFoo.hal b/tests/foo/1.0/IFoo.hal
index 3d82353..614f1e4 100644
--- a/tests/foo/1.0/IFoo.hal
+++ b/tests/foo/1.0/IFoo.hal
@@ -80,6 +80,7 @@
};
doThis(float param);
+ doThis(uint32_t param);
doThatAndReturnSomething(int64_t param) generates (int32_t result);
doQuiteABit(int32_t a, int64_t b, float c, double d) generates (double something);
doSomethingElse(int32_t[15] param) generates (int32_t[32] something);
diff --git a/vibrator/1.0/default/Android.bp b/vibrator/1.0/default/Android.bp
new file mode 100644
index 0000000..6d82a19
--- /dev/null
+++ b/vibrator/1.0/default/Android.bp
@@ -0,0 +1,26 @@
+//
+// Copyright (C) 2016 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+cc_library_shared {
+ name: "android.hardware.vibrator@1.0-impl",
+ relative_install_path: "hw",
+ srcs: ["Vibrator.cpp"],
+ shared_libs: [
+ "libhidl",
+ "liblog",
+ "libhwbinder",
+ "libutils",
+ "libhardware",
+ "android.hardware.vibrator@1.0",
+ ],
diff --git a/vibrator/1.0/default/Android.mk b/vibrator/1.0/default/Android.mk
index 3bb6f79..2b168bb 100644
--- a/vibrator/1.0/default/Android.mk
+++ b/vibrator/1.0/default/Android.mk
@@ -17,10 +17,11 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.vibrator@1.0-impl
+LOCAL_MODULE := android.hardware.vibrator@1.0-service
+LOCAL_INIT_RC := android.hardware.vibrator@1.0-service.rc
LOCAL_MODULE_RELATIVE_PATH := hw
LOCAL_SRC_FILES := \
- Vibrator.cpp \
+ service.cpp \
LOCAL_SHARED_LIBRARIES := \
libhidl \
@@ -30,4 +31,4 @@
libhardware \
android.hardware.vibrator@1.0
-include $(BUILD_SHARED_LIBRARY)
+include $(BUILD_EXECUTABLE)
diff --git a/vibrator/1.0/default/android.hardware.vibrator@1.0-service.rc b/vibrator/1.0/default/android.hardware.vibrator@1.0-service.rc
new file mode 100644
index 0000000..a7836b3
--- /dev/null
+++ b/vibrator/1.0/default/android.hardware.vibrator@1.0-service.rc
@@ -0,0 +1,4 @@
+service vibrator-1-0 /system/bin/hw/android.hardware.vibrator@1.0-service
+ class hal
+ user system
+ group system readproc
diff --git a/vibrator/1.0/default/service.cpp b/vibrator/1.0/default/service.cpp
new file mode 100644
index 0000000..a4a7132
--- /dev/null
+++ b/vibrator/1.0/default/service.cpp
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#define LOG_TAG "android.hardware.vibrator@1.0-service"
+#include <utils/Log.h>
+
+#include <iostream>
+#include <unistd.h>
+
+#include <android/hardware/vibrator/1.0/IVibrator.h>
+
+#include <hidl/IServiceManager.h>
+#include <hwbinder/IPCThreadState.h>
+#include <hwbinder/ProcessState.h>
+#include <utils/Errors.h>
+#include <utils/StrongPointer.h>
+
+using android::sp;
+
+// libhwbinder:
+using android::hardware::IPCThreadState;
+using android::hardware::ProcessState;
+
+// Generated HIDL files
+using android::hardware::vibrator::V1_0::IVibrator;
+
+int main() {
+ ALOGI("Service is starting.");
+ const char instance[] = "vibrator";
+ ALOGI("Retrieving default implementation of instance %s.",
+ instance);
+ android::sp<IVibrator> service = IVibrator::getService(instance, true);
+ if (service.get() == nullptr) {
+ ALOGE("IVibrator::getService returned NULL, exiting");
+ return -1;
+ }
+ ALOGI("Default implementation using %s is %s",
+ instance, (service->isRemote() ? "REMOTE" : "LOCAL"));
+ LOG_FATAL_IF(service->isRemote(), "Implementation is REMOTE!");
+ ALOGI("Registering instance %s.", instance);
+ service->registerAsService(instance);
+ ALOGI("Ready.");
+
+ ProcessState::self()->setThreadPoolMaxThreadCount(0);
+ ProcessState::self()->startThreadPool();
+ IPCThreadState::self()->joinThreadPool();
+}
diff --git a/wifi/1.0/Android.bp b/wifi/1.0/Android.bp
index 07e17ef..59ad2c5 100644
--- a/wifi/1.0/Android.bp
+++ b/wifi/1.0/Android.bp
@@ -7,16 +7,28 @@
srcs: [
"types.hal",
"IWifi.hal",
+ "IWifiApIface.hal",
"IWifiChip.hal",
"IWifiChipEventCallback.hal",
"IWifiEventCallback.hal",
+ "IWifiIface.hal",
+ "IWifiNanIface.hal",
+ "IWifiP2pIface.hal",
+ "IWifiRttController.hal",
+ "IWifiStaIface.hal",
],
out: [
"android/hardware/wifi/1.0/types.cpp",
"android/hardware/wifi/1.0/WifiAll.cpp",
+ "android/hardware/wifi/1.0/WifiApIfaceAll.cpp",
"android/hardware/wifi/1.0/WifiChipAll.cpp",
"android/hardware/wifi/1.0/WifiChipEventCallbackAll.cpp",
"android/hardware/wifi/1.0/WifiEventCallbackAll.cpp",
+ "android/hardware/wifi/1.0/WifiIfaceAll.cpp",
+ "android/hardware/wifi/1.0/WifiNanIfaceAll.cpp",
+ "android/hardware/wifi/1.0/WifiP2pIfaceAll.cpp",
+ "android/hardware/wifi/1.0/WifiRttControllerAll.cpp",
+ "android/hardware/wifi/1.0/WifiStaIfaceAll.cpp",
],
}
@@ -27,9 +39,15 @@
srcs: [
"types.hal",
"IWifi.hal",
+ "IWifiApIface.hal",
"IWifiChip.hal",
"IWifiChipEventCallback.hal",
"IWifiEventCallback.hal",
+ "IWifiIface.hal",
+ "IWifiNanIface.hal",
+ "IWifiP2pIface.hal",
+ "IWifiRttController.hal",
+ "IWifiStaIface.hal",
],
out: [
"android/hardware/wifi/1.0/types.h",
@@ -38,6 +56,11 @@
"android/hardware/wifi/1.0/BnWifi.h",
"android/hardware/wifi/1.0/BpWifi.h",
"android/hardware/wifi/1.0/BsWifi.h",
+ "android/hardware/wifi/1.0/IWifiApIface.h",
+ "android/hardware/wifi/1.0/IHwWifiApIface.h",
+ "android/hardware/wifi/1.0/BnWifiApIface.h",
+ "android/hardware/wifi/1.0/BpWifiApIface.h",
+ "android/hardware/wifi/1.0/BsWifiApIface.h",
"android/hardware/wifi/1.0/IWifiChip.h",
"android/hardware/wifi/1.0/IHwWifiChip.h",
"android/hardware/wifi/1.0/BnWifiChip.h",
@@ -53,6 +76,31 @@
"android/hardware/wifi/1.0/BnWifiEventCallback.h",
"android/hardware/wifi/1.0/BpWifiEventCallback.h",
"android/hardware/wifi/1.0/BsWifiEventCallback.h",
+ "android/hardware/wifi/1.0/IWifiIface.h",
+ "android/hardware/wifi/1.0/IHwWifiIface.h",
+ "android/hardware/wifi/1.0/BnWifiIface.h",
+ "android/hardware/wifi/1.0/BpWifiIface.h",
+ "android/hardware/wifi/1.0/BsWifiIface.h",
+ "android/hardware/wifi/1.0/IWifiNanIface.h",
+ "android/hardware/wifi/1.0/IHwWifiNanIface.h",
+ "android/hardware/wifi/1.0/BnWifiNanIface.h",
+ "android/hardware/wifi/1.0/BpWifiNanIface.h",
+ "android/hardware/wifi/1.0/BsWifiNanIface.h",
+ "android/hardware/wifi/1.0/IWifiP2pIface.h",
+ "android/hardware/wifi/1.0/IHwWifiP2pIface.h",
+ "android/hardware/wifi/1.0/BnWifiP2pIface.h",
+ "android/hardware/wifi/1.0/BpWifiP2pIface.h",
+ "android/hardware/wifi/1.0/BsWifiP2pIface.h",
+ "android/hardware/wifi/1.0/IWifiRttController.h",
+ "android/hardware/wifi/1.0/IHwWifiRttController.h",
+ "android/hardware/wifi/1.0/BnWifiRttController.h",
+ "android/hardware/wifi/1.0/BpWifiRttController.h",
+ "android/hardware/wifi/1.0/BsWifiRttController.h",
+ "android/hardware/wifi/1.0/IWifiStaIface.h",
+ "android/hardware/wifi/1.0/IHwWifiStaIface.h",
+ "android/hardware/wifi/1.0/BnWifiStaIface.h",
+ "android/hardware/wifi/1.0/BpWifiStaIface.h",
+ "android/hardware/wifi/1.0/BsWifiStaIface.h",
],
}
diff --git a/wifi/1.0/Android.mk b/wifi/1.0/Android.mk
index e211ca8..58c487b 100644
--- a/wifi/1.0/Android.mk
+++ b/wifi/1.0/Android.mk
@@ -47,6 +47,23 @@
LOCAL_GENERATED_SOURCES += $(GEN)
#
+# Build types.hal (IfaceType)
+#
+GEN := $(intermediates)/android/hardware/wifi/1.0/IfaceType.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava -randroid.hardware:hardware/interfaces \
+ android.hardware.wifi@1.0::types.IfaceType
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
# Build IWifi.hal
#
GEN := $(intermediates)/android/hardware/wifi/1.0/IWifi.java
@@ -57,6 +74,8 @@
$(GEN): $(LOCAL_PATH)/IWifiChip.hal
$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/IWifiEventCallback.hal
$(GEN): $(LOCAL_PATH)/IWifiEventCallback.hal
+$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/types.hal
+$(GEN): $(LOCAL_PATH)/types.hal
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
$(GEN): PRIVATE_CUSTOM_TOOL = \
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
@@ -68,14 +87,45 @@
LOCAL_GENERATED_SOURCES += $(GEN)
#
+# Build IWifiApIface.hal
+#
+GEN := $(intermediates)/android/hardware/wifi/1.0/IWifiApIface.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IWifiApIface.hal
+$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/IWifiIface.hal
+$(GEN): $(LOCAL_PATH)/IWifiIface.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava -randroid.hardware:hardware/interfaces \
+ android.hardware.wifi@1.0::IWifiApIface
+
+$(GEN): $(LOCAL_PATH)/IWifiApIface.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
# Build IWifiChip.hal
#
GEN := $(intermediates)/android/hardware/wifi/1.0/IWifiChip.java
$(GEN): $(HIDL)
$(GEN): PRIVATE_HIDL := $(HIDL)
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IWifiChip.hal
+$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/IWifiApIface.hal
+$(GEN): $(LOCAL_PATH)/IWifiApIface.hal
$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/IWifiChipEventCallback.hal
$(GEN): $(LOCAL_PATH)/IWifiChipEventCallback.hal
+$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/IWifiIface.hal
+$(GEN): $(LOCAL_PATH)/IWifiIface.hal
+$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/IWifiNanIface.hal
+$(GEN): $(LOCAL_PATH)/IWifiNanIface.hal
+$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/IWifiP2pIface.hal
+$(GEN): $(LOCAL_PATH)/IWifiP2pIface.hal
+$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/IWifiRttController.hal
+$(GEN): $(LOCAL_PATH)/IWifiRttController.hal
+$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/IWifiStaIface.hal
+$(GEN): $(LOCAL_PATH)/IWifiStaIface.hal
$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/types.hal
$(GEN): $(LOCAL_PATH)/types.hal
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
@@ -125,6 +175,101 @@
$(GEN): $(LOCAL_PATH)/IWifiEventCallback.hal
$(transform-generated-source)
LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build IWifiIface.hal
+#
+GEN := $(intermediates)/android/hardware/wifi/1.0/IWifiIface.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IWifiIface.hal
+$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/types.hal
+$(GEN): $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava -randroid.hardware:hardware/interfaces \
+ android.hardware.wifi@1.0::IWifiIface
+
+$(GEN): $(LOCAL_PATH)/IWifiIface.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build IWifiNanIface.hal
+#
+GEN := $(intermediates)/android/hardware/wifi/1.0/IWifiNanIface.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IWifiNanIface.hal
+$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/IWifiIface.hal
+$(GEN): $(LOCAL_PATH)/IWifiIface.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava -randroid.hardware:hardware/interfaces \
+ android.hardware.wifi@1.0::IWifiNanIface
+
+$(GEN): $(LOCAL_PATH)/IWifiNanIface.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build IWifiP2pIface.hal
+#
+GEN := $(intermediates)/android/hardware/wifi/1.0/IWifiP2pIface.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IWifiP2pIface.hal
+$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/IWifiIface.hal
+$(GEN): $(LOCAL_PATH)/IWifiIface.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava -randroid.hardware:hardware/interfaces \
+ android.hardware.wifi@1.0::IWifiP2pIface
+
+$(GEN): $(LOCAL_PATH)/IWifiP2pIface.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build IWifiRttController.hal
+#
+GEN := $(intermediates)/android/hardware/wifi/1.0/IWifiRttController.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IWifiRttController.hal
+$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/IWifiIface.hal
+$(GEN): $(LOCAL_PATH)/IWifiIface.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava -randroid.hardware:hardware/interfaces \
+ android.hardware.wifi@1.0::IWifiRttController
+
+$(GEN): $(LOCAL_PATH)/IWifiRttController.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build IWifiStaIface.hal
+#
+GEN := $(intermediates)/android/hardware/wifi/1.0/IWifiStaIface.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IWifiStaIface.hal
+$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/IWifiIface.hal
+$(GEN): $(LOCAL_PATH)/IWifiIface.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava -randroid.hardware:hardware/interfaces \
+ android.hardware.wifi@1.0::IWifiStaIface
+
+$(GEN): $(LOCAL_PATH)/IWifiStaIface.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
include $(BUILD_JAVA_LIBRARY)
@@ -173,6 +318,23 @@
LOCAL_GENERATED_SOURCES += $(GEN)
#
+# Build types.hal (IfaceType)
+#
+GEN := $(intermediates)/android/hardware/wifi/1.0/IfaceType.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava -randroid.hardware:hardware/interfaces \
+ android.hardware.wifi@1.0::types.IfaceType
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
# Build IWifi.hal
#
GEN := $(intermediates)/android/hardware/wifi/1.0/IWifi.java
@@ -183,6 +345,8 @@
$(GEN): $(LOCAL_PATH)/IWifiChip.hal
$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/IWifiEventCallback.hal
$(GEN): $(LOCAL_PATH)/IWifiEventCallback.hal
+$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/types.hal
+$(GEN): $(LOCAL_PATH)/types.hal
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
$(GEN): PRIVATE_CUSTOM_TOOL = \
$(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
@@ -194,14 +358,45 @@
LOCAL_GENERATED_SOURCES += $(GEN)
#
+# Build IWifiApIface.hal
+#
+GEN := $(intermediates)/android/hardware/wifi/1.0/IWifiApIface.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IWifiApIface.hal
+$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/IWifiIface.hal
+$(GEN): $(LOCAL_PATH)/IWifiIface.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava -randroid.hardware:hardware/interfaces \
+ android.hardware.wifi@1.0::IWifiApIface
+
+$(GEN): $(LOCAL_PATH)/IWifiApIface.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
# Build IWifiChip.hal
#
GEN := $(intermediates)/android/hardware/wifi/1.0/IWifiChip.java
$(GEN): $(HIDL)
$(GEN): PRIVATE_HIDL := $(HIDL)
$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IWifiChip.hal
+$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/IWifiApIface.hal
+$(GEN): $(LOCAL_PATH)/IWifiApIface.hal
$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/IWifiChipEventCallback.hal
$(GEN): $(LOCAL_PATH)/IWifiChipEventCallback.hal
+$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/IWifiIface.hal
+$(GEN): $(LOCAL_PATH)/IWifiIface.hal
+$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/IWifiNanIface.hal
+$(GEN): $(LOCAL_PATH)/IWifiNanIface.hal
+$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/IWifiP2pIface.hal
+$(GEN): $(LOCAL_PATH)/IWifiP2pIface.hal
+$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/IWifiRttController.hal
+$(GEN): $(LOCAL_PATH)/IWifiRttController.hal
+$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/IWifiStaIface.hal
+$(GEN): $(LOCAL_PATH)/IWifiStaIface.hal
$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/types.hal
$(GEN): $(LOCAL_PATH)/types.hal
$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
@@ -251,6 +446,101 @@
$(GEN): $(LOCAL_PATH)/IWifiEventCallback.hal
$(transform-generated-source)
LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build IWifiIface.hal
+#
+GEN := $(intermediates)/android/hardware/wifi/1.0/IWifiIface.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IWifiIface.hal
+$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/types.hal
+$(GEN): $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava -randroid.hardware:hardware/interfaces \
+ android.hardware.wifi@1.0::IWifiIface
+
+$(GEN): $(LOCAL_PATH)/IWifiIface.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build IWifiNanIface.hal
+#
+GEN := $(intermediates)/android/hardware/wifi/1.0/IWifiNanIface.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IWifiNanIface.hal
+$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/IWifiIface.hal
+$(GEN): $(LOCAL_PATH)/IWifiIface.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava -randroid.hardware:hardware/interfaces \
+ android.hardware.wifi@1.0::IWifiNanIface
+
+$(GEN): $(LOCAL_PATH)/IWifiNanIface.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build IWifiP2pIface.hal
+#
+GEN := $(intermediates)/android/hardware/wifi/1.0/IWifiP2pIface.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IWifiP2pIface.hal
+$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/IWifiIface.hal
+$(GEN): $(LOCAL_PATH)/IWifiIface.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava -randroid.hardware:hardware/interfaces \
+ android.hardware.wifi@1.0::IWifiP2pIface
+
+$(GEN): $(LOCAL_PATH)/IWifiP2pIface.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build IWifiRttController.hal
+#
+GEN := $(intermediates)/android/hardware/wifi/1.0/IWifiRttController.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IWifiRttController.hal
+$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/IWifiIface.hal
+$(GEN): $(LOCAL_PATH)/IWifiIface.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava -randroid.hardware:hardware/interfaces \
+ android.hardware.wifi@1.0::IWifiRttController
+
+$(GEN): $(LOCAL_PATH)/IWifiRttController.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build IWifiStaIface.hal
+#
+GEN := $(intermediates)/android/hardware/wifi/1.0/IWifiStaIface.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IWifiStaIface.hal
+$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/IWifiIface.hal
+$(GEN): $(LOCAL_PATH)/IWifiIface.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava -randroid.hardware:hardware/interfaces \
+ android.hardware.wifi@1.0::IWifiStaIface
+
+$(GEN): $(LOCAL_PATH)/IWifiStaIface.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
include $(BUILD_STATIC_JAVA_LIBRARY)
diff --git a/wifi/1.0/IWifi.hal b/wifi/1.0/IWifi.hal
index d1311f5..9e09348 100644
--- a/wifi/1.0/IWifi.hal
+++ b/wifi/1.0/IWifi.hal
@@ -70,10 +70,22 @@
@callflow(next={"registerEventCallback", "start", "stop"})
oneway stop();
- // TODO(b/30570663) return vec<IWifiChip> instead
/**
- * Get the configurable chip on the device.
+ * Retrieve the list of all chip Id's on the device.
+ * The corresponding |IWifiChip| object for any chip can be
+ * retrieved using |getChip| method.
+ *
+ * @return chipIds List of all chip Id's on the device.
*/
@callflow(next={"*"})
- getChip() generates (IWifiChip chip);
+ getChipIds() generates (vec<ChipId> chipIds);
+
+ /**
+ * Gets a HIDL interface object for the chip corresponding to the
+ * provided chipId.
+ *
+ * @return chip HIDL interface object representing the chip.
+ */
+ @callflow(next={"*"})
+ getChip(ChipId chipId) generates (IWifiChip chip);
};
diff --git a/wifi/1.0/IWifiApIface.hal b/wifi/1.0/IWifiApIface.hal
new file mode 100644
index 0000000..6bc3580
--- /dev/null
+++ b/wifi/1.0/IWifiApIface.hal
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.wifi@1.0;
+
+import IWifiIface;
+
+/**
+ * Interface used to represent a single AP iface.
+ */
+interface IWifiApIface extends IWifiIface {
+ /** TODO(rpius): Add methods to the interface. */
+};
diff --git a/wifi/1.0/IWifiChip.hal b/wifi/1.0/IWifiChip.hal
index 7a41ddf..cd4b219 100644
--- a/wifi/1.0/IWifiChip.hal
+++ b/wifi/1.0/IWifiChip.hal
@@ -17,6 +17,12 @@
package android.hardware.wifi@1.0;
import IWifiChipEventCallback;
+import IWifiIface;
+import IWifiApIface;
+import IWifiNanIface;
+import IWifiP2pIface;
+import IWifiStaIface;
+import IWifiRttController;
/**
* Interface that represents a chip that must be configured as a single unit.
@@ -24,15 +30,6 @@
* to perform operations like NAN, RTT, etc.
*/
interface IWifiChip {
- enum IfaceType : uint32_t {
- STA, AP, P2P,
- /**
- * NAN control interface. Datapath support may be queried and created
- * through this interface.
- */
- NAN,
- };
-
/**
* Set of interface types with the maximum number of interfaces that can have
* one of the specified type for a given ChipIfaceCombination. See
@@ -122,6 +119,13 @@
};
/**
+ * Get the id assigned to this chip.
+ *
+ * @return id Assigned chip Id.
+ */
+ getId() generates (ChipId id);
+
+ /**
* Requests notifications of significant events on this chip. Multiple calls
* to this will register multiple callbacks each of which will receive all
* events.
@@ -176,4 +180,142 @@
* success, or |IWifiChipEventCallback.onFirmwareDebugDumpFailure| on failure.
*/
oneway requestFirmwareDebugDump();
+
+ /**
+ * Create an AP iface on the chip.
+ *
+ * Depending on the mode the chip is configured in, the interface creation
+ * may fail if we've already reached the maximum allowed
+ * (specified in |ChipIfaceCombination|) number of ifaces of the AP type.
+ *
+ * @return iface HIDL interface object representing the iface if
+ * successful, null otherwise.
+ */
+ createApIface() generates (IWifiApIface iface);
+
+ /**
+ * List all the AP iface names configured on the chip.
+ * The corresponding |IWifiApIface| object for any iface are
+ * retrieved using |getApIface| method.
+ *
+ * @return ifnames List of all AP iface names on the chip.
+ */
+ getApIfaceNames() generates (vec<string> ifnames);
+
+ /**
+ * Gets a HIDL interface object for the AP Iface corresponding
+ * to the provided ifname.
+ *
+ * @param ifname Name of the iface.
+ * @return iface HIDL interface object representing the iface if
+ * it exists, null otherwise.
+ */
+ getApIface(string ifname) generates (IWifiApIface iface);
+
+ /**
+ * Create a NAN iface on the chip.
+ *
+ * Depending on the mode the chip is configured in, the interface creation
+ * may fail if we've already reached the maximum allowed
+ * (specified in |ChipIfaceCombination|) number of ifaces of the NAN type.
+ *
+ * @return iface HIDL interface object representing the iface if
+ * successful, null otherwise.
+ */
+ createNanIface() generates (IWifiNanIface iface);
+
+ /**
+ * List all the NAN iface names configured on the chip.
+ * The corresponding |IWifiNanIface| object for any iface are
+ * retrieved using |getNanIface| method.
+ *
+ * @return ifnames List of all NAN iface names on the chip.
+ */
+ getNanIfaceNames() generates (vec<string> ifnames);
+
+ /**
+ * Gets a HIDL interface object for the NAN Iface corresponding
+ * to the provided ifname.
+ *
+ * @param ifname Name of the iface.
+ * @return iface HIDL interface object representing the iface if
+ * it exists, null otherwise.
+ */
+ getNanIface(string ifname) generates (IWifiNanIface iface);
+
+ /**
+ * Create a P2P iface on the chip.
+ *
+ * Depending on the mode the chip is configured in, the interface creation
+ * may fail if we've already reached the maximum allowed
+ * (specified in |ChipIfaceCombination|) number of ifaces of the P2P type.
+ *
+ * @return iface HIDL interface object representing the iface if
+ * successful, null otherwise.
+ */
+ createP2pIface() generates (IWifiP2pIface iface);
+
+ /**
+ * List all the P2P iface names configured on the chip.
+ * The corresponding |IWifiP2pIface| object for any iface are
+ * retrieved using |getP2pIface| method.
+ *
+ * @return ifnames List of all P2P iface names on the chip.
+ */
+ getP2pIfaceNames() generates (vec<string> ifnames);
+
+ /**
+ * Gets a HIDL interface object for the P2P Iface corresponding
+ * to the provided ifname.
+ *
+ * @param ifname Name of the iface.
+ * @return iface HIDL interface object representing the iface if
+ * it exists, null otherwise.
+ */
+ getP2pIface(string ifname) generates (IWifiP2pIface iface);
+
+ /**
+ * Create an STA iface on the chip.
+ *
+ * Depending on the mode the chip is configured in, the interface creation
+ * may fail if we've already reached the maximum allowed
+ * (specified in |ChipIfaceCombination|) number of ifaces of the STA type.
+ *
+ * @return iface HIDL interface object representing the iface if
+ * successful, null otherwise.
+ */
+ createStaIface() generates (IWifiStaIface iface);
+
+ /**
+ * List all the STA iface names configured on the chip.
+ * The corresponding |IWifiStaIface| object for any iface are
+ * retrieved using |getStaIface| method.
+ *
+ * @return ifnames List of all STA iface names on the chip.
+ */
+ getStaIfaceNames() generates (vec<string> ifnames);
+
+ /**
+ * Gets a HIDL interface object for the STA Iface corresponding
+ * to the provided ifname.
+ *
+ * @param ifname Name of the iface.
+ * @return iface HIDL interface object representing the iface if
+ * it exists, null otherwise.
+ */
+ getStaIface(string ifname) generates (IWifiStaIface iface);
+
+ /**
+ * Create a RTTController instance.
+ *
+ * RTT controller can be either:
+ * a) Bound to a specific iface by passing in the corresponding |IWifiIface|
+ * object in |iface| param, OR
+ * b) Let the implementation decide the iface to use for RTT operations by
+ * passing null in |iface| param.
+ *
+ * @param boundIface HIDL interface object representing the iface if
+ * the responder must be bound to a specific iface, null otherwise.
+ */
+ createRttController(IWifiIface boundIface) generates (IWifiRttController rtt);
};
diff --git a/wifi/1.0/IWifiIface.hal b/wifi/1.0/IWifiIface.hal
new file mode 100644
index 0000000..f4150e7
--- /dev/null
+++ b/wifi/1.0/IWifiIface.hal
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.wifi@1.0;
+
+/**
+ * Interface used to represent a single iface.
+ */
+interface IWifiIface {
+ /**
+ * Get the type of this iface.
+ *
+ * @return type One of the supported iface types.
+ */
+ getType() generates (IfaceType type);
+
+ /**
+ * Get the name of this iface.
+ *
+ * @return name Name of the iface.
+ */
+ getName() generates (string name);
+};
diff --git a/wifi/1.0/IWifiNanIface.hal b/wifi/1.0/IWifiNanIface.hal
new file mode 100644
index 0000000..dade94c
--- /dev/null
+++ b/wifi/1.0/IWifiNanIface.hal
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.wifi@1.0;
+
+import IWifiIface;
+
+/**
+ * Interface used to represent a single NAN iface.
+ */
+interface IWifiNanIface extends IWifiIface {
+ /** TODO(rpius): Add methods to the interface. */
+};
diff --git a/wifi/1.0/IWifiP2pIface.hal b/wifi/1.0/IWifiP2pIface.hal
new file mode 100644
index 0000000..243748f
--- /dev/null
+++ b/wifi/1.0/IWifiP2pIface.hal
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.wifi@1.0;
+
+import IWifiIface;
+
+/**
+ * Interface used to represent a single NAN iface.
+ */
+interface IWifiP2pIface extends IWifiIface {
+ /** TODO(rpius): Add methods to the interface. */
+};
diff --git a/wifi/1.0/IWifiRttController.hal b/wifi/1.0/IWifiRttController.hal
new file mode 100644
index 0000000..d735da7
--- /dev/null
+++ b/wifi/1.0/IWifiRttController.hal
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.wifi@1.0;
+
+import IWifiIface;
+
+/**
+ * Interface used to perform RTT operations.
+ */
+interface IWifiRttController {
+ /**
+ * Get the iface on which the RTT operations will be performed.
+ *
+ * @return boundIface HIDL interface object representing the iface if bound
+ * to a specific iface, null otherwise
+ */
+ getBoundIface() generates (IWifiIface boundIface);
+};
diff --git a/wifi/1.0/IWifiStaIface.hal b/wifi/1.0/IWifiStaIface.hal
new file mode 100644
index 0000000..5234c71
--- /dev/null
+++ b/wifi/1.0/IWifiStaIface.hal
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.wifi@1.0;
+
+import IWifiIface;
+
+/**
+ * Interface used to represent a single STA iface.
+ */
+interface IWifiStaIface extends IWifiIface {
+ /** TODO(rpius): Add methods to the interface. */
+};
diff --git a/wifi/1.0/default/Android.mk b/wifi/1.0/default/Android.mk
index 07865a5..3fd5fba 100644
--- a/wifi/1.0/default/Android.mk
+++ b/wifi/1.0/default/Android.mk
@@ -19,9 +19,14 @@
LOCAL_CPPFLAGS := -std=c++11 -Wall -Wno-unused-parameter -Werror -Wextra
LOCAL_SRC_FILES := \
failure_reason_util.cpp \
- wifi_chip.cpp \
wifi.cpp \
- wifi_legacy_hal.cpp
+ wifi_ap_iface.cpp \
+ wifi_chip.cpp \
+ wifi_legacy_hal.cpp \
+ wifi_nan_iface.cpp \
+ wifi_p2p_iface.cpp \
+ wifi_rtt_controller.cpp \
+ wifi_sta_iface.cpp
LOCAL_SHARED_LIBRARIES := \
android.hardware.wifi@1.0 \
libbase \
diff --git a/wifi/1.0/default/wifi.cpp b/wifi/1.0/default/wifi.cpp
index d5b69b8..ff2eb4c 100644
--- a/wifi/1.0/default/wifi.cpp
+++ b/wifi/1.0/default/wifi.cpp
@@ -21,6 +21,11 @@
#include "failure_reason_util.h"
#include "wifi_chip.h"
+namespace {
+// Chip ID to use for the only supported chip.
+static constexpr android::hardware::wifi::V1_0::ChipId kChipId = 0;
+} // namespace
+
namespace android {
namespace hardware {
namespace wifi {
@@ -33,7 +38,7 @@
Return<void> Wifi::registerEventCallback(
const sp<IWifiEventCallback>& callback) {
// TODO(b/31632518): remove the callback when the client is destroyed
- callbacks_.insert(callback);
+ callbacks_.emplace_back(callback);
return Void();
}
@@ -67,7 +72,7 @@
}
// Create the chip instance once the HAL is started.
- chip_ = new WifiChip(legacy_hal_);
+ chip_ = new WifiChip(kChipId, legacy_hal_);
run_state_ = RunState::STARTED;
for (const auto& callback : callbacks_) {
callback->onStart();
@@ -108,8 +113,23 @@
return Void();
}
-Return<void> Wifi::getChip(getChip_cb cb) {
- cb(chip_);
+Return<void> Wifi::getChipIds(getChipIds_cb cb) {
+ std::vector<ChipId> chip_ids;
+ if (chip_.get()) {
+ chip_ids.emplace_back(kChipId);
+ }
+ hidl_vec<ChipId> hidl_data;
+ hidl_data.setToExternal(chip_ids.data(), chip_ids.size());
+ cb(hidl_data);
+ return Void();
+}
+
+Return<void> Wifi::getChip(ChipId chip_id, getChip_cb cb) {
+ if (chip_.get() && chip_id == kChipId) {
+ cb(chip_);
+ } else {
+ cb(nullptr);
+ }
return Void();
}
diff --git a/wifi/1.0/default/wifi.h b/wifi/1.0/default/wifi.h
index e6cf1ac..55ba12b 100644
--- a/wifi/1.0/default/wifi.h
+++ b/wifi/1.0/default/wifi.h
@@ -18,7 +18,6 @@
#define WIFI_H_
#include <functional>
-#include <set>
#include <android-base/macros.h>
#include <android/hardware/wifi/1.0/IWifi.h>
@@ -46,7 +45,8 @@
Return<bool> isStarted() override;
Return<void> start() override;
Return<void> stop() override;
- Return<void> getChip(getChip_cb cb) override;
+ Return<void> getChipIds(getChipIds_cb cb) override;
+ Return<void> getChip(ChipId chip_id, getChip_cb cb) override;
private:
enum class RunState { STOPPED, STARTED, STOPPING };
@@ -55,7 +55,7 @@
// and shared with all the child HIDL interface objects.
std::shared_ptr<WifiLegacyHal> legacy_hal_;
RunState run_state_;
- std::set<sp<IWifiEventCallback>> callbacks_;
+ std::vector<sp<IWifiEventCallback>> callbacks_;
sp<WifiChip> chip_;
DISALLOW_COPY_AND_ASSIGN(Wifi);
diff --git a/wifi/1.0/default/wifi_ap_iface.cpp b/wifi/1.0/default/wifi_ap_iface.cpp
new file mode 100644
index 0000000..aded04d
--- /dev/null
+++ b/wifi/1.0/default/wifi_ap_iface.cpp
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "wifi_ap_iface.h"
+
+#include <android-base/logging.h>
+
+#include "failure_reason_util.h"
+
+namespace android {
+namespace hardware {
+namespace wifi {
+namespace V1_0 {
+namespace implementation {
+
+WifiApIface::WifiApIface(const std::string& ifname,
+ const std::weak_ptr<WifiLegacyHal> legacy_hal)
+ : ifname_(ifname), legacy_hal_(legacy_hal), is_valid_(true) {}
+
+void WifiApIface::invalidate() {
+ legacy_hal_.reset();
+ is_valid_ = false;
+}
+
+Return<void> WifiApIface::getName(getName_cb cb) {
+ hidl_string hidl_ifname;
+ hidl_ifname.setToExternal(ifname_.c_str(), ifname_.size());
+ cb(hidl_ifname);
+ return Void();
+}
+
+Return<IfaceType> WifiApIface::getType() {
+ return IfaceType::AP;
+}
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace wifi
+} // namespace hardware
+} // namespace android
diff --git a/wifi/1.0/default/wifi_ap_iface.h b/wifi/1.0/default/wifi_ap_iface.h
new file mode 100644
index 0000000..b95a3d8
--- /dev/null
+++ b/wifi/1.0/default/wifi_ap_iface.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef WIFI_AP_IFACE_H_
+#define WIFI_AP_IFACE_H_
+
+#include <android-base/macros.h>
+#include <android/hardware/wifi/1.0/IWifiApIface.h>
+
+#include "wifi_legacy_hal.h"
+
+namespace android {
+namespace hardware {
+namespace wifi {
+namespace V1_0 {
+namespace implementation {
+
+/**
+ * HIDL interface object used to control a AP Iface instance.
+ */
+class WifiApIface : public IWifiApIface {
+ public:
+ WifiApIface(const std::string& ifname,
+ const std::weak_ptr<WifiLegacyHal> legacy_hal);
+ // Refer to |WifiChip::invalidate()|.
+ void invalidate();
+
+ // HIDL methods exposed.
+ Return<void> getName(getName_cb cb) override;
+ Return<IfaceType> getType() override;
+
+ private:
+ std::string ifname_;
+ std::weak_ptr<WifiLegacyHal> legacy_hal_;
+ bool is_valid_;
+
+ DISALLOW_COPY_AND_ASSIGN(WifiApIface);
+};
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace wifi
+} // namespace hardware
+} // namespace android
+
+#endif // WIFI_AP_IFACE_H_
diff --git a/wifi/1.0/default/wifi_chip.cpp b/wifi/1.0/default/wifi_chip.cpp
index df321e2..4dd020b 100644
--- a/wifi/1.0/default/wifi_chip.cpp
+++ b/wifi/1.0/default/wifi_chip.cpp
@@ -20,31 +20,64 @@
#include "failure_reason_util.h"
+namespace {
+using android::sp;
+using android::hardware::hidl_vec;
+using android::hardware::hidl_string;
+
+hidl_vec<hidl_string> createHidlVecOfIfaceNames(const std::string& ifname) {
+ std::vector<hidl_string> ifnames;
+ if (!ifname.empty()) {
+ hidl_string hidl_ifname;
+ hidl_ifname = ifname.c_str();
+ ifnames.emplace_back(hidl_ifname);
+ }
+ hidl_vec<hidl_string> hidl_ifnames;
+ hidl_ifnames.setToExternal(ifnames.data(), ifnames.size());
+ return hidl_ifnames;
+}
+
+template <typename Iface>
+void invalidateAndClear(sp<Iface>& iface) {
+ if (iface.get()) {
+ iface->invalidate();
+ iface.clear();
+ }
+}
+} // namepsace
+
namespace android {
namespace hardware {
namespace wifi {
namespace V1_0 {
namespace implementation {
-WifiChip::WifiChip(std::weak_ptr<WifiLegacyHal> legacy_hal)
- : legacy_hal_(legacy_hal) {}
+WifiChip::WifiChip(ChipId chip_id,
+ const std::weak_ptr<WifiLegacyHal> legacy_hal)
+ : chip_id_(chip_id), legacy_hal_(legacy_hal), is_valid_(true) {}
void WifiChip::invalidate() {
+ invalidateAndRemoveAllIfaces();
legacy_hal_.reset();
callbacks_.clear();
+ is_valid_ = false;
+}
+
+Return<ChipId> WifiChip::getId() {
+ return chip_id_;
}
Return<void> WifiChip::registerEventCallback(
const sp<IWifiChipEventCallback>& callback) {
- if (!legacy_hal_.lock())
+ if (!is_valid_)
return Void();
// TODO(b/31632518): remove the callback when the client is destroyed
- callbacks_.insert(callback);
+ callbacks_.emplace_back(callback);
return Void();
}
Return<void> WifiChip::getAvailableModes(getAvailableModes_cb cb) {
- if (!legacy_hal_.lock()) {
+ if (!is_valid_) {
cb(hidl_vec<ChipMode>());
return Void();
} else {
@@ -54,38 +87,50 @@
}
Return<void> WifiChip::configureChip(uint32_t /*mode_id*/) {
- if (!legacy_hal_.lock())
+ if (!is_valid_)
return Void();
+
+ invalidateAndRemoveAllIfaces();
// TODO add implementation
return Void();
}
Return<uint32_t> WifiChip::getMode() {
- if (!legacy_hal_.lock())
+ if (!is_valid_)
return 0;
// TODO add implementation
return 0;
}
Return<void> WifiChip::requestChipDebugInfo() {
- if (!legacy_hal_.lock())
+ if (!is_valid_)
return Void();
IWifiChipEventCallback::ChipDebugInfo result;
std::pair<wifi_error, std::string> ret =
- legacy_hal_.lock()->getWlanDriverVersion();
+ legacy_hal_.lock()->getDriverVersion();
if (ret.first != WIFI_SUCCESS) {
LOG(ERROR) << "Failed to get driver version: "
<< LegacyErrorToString(ret.first);
+ FailureReason reason = CreateFailureReasonLegacyError(
+ ret.first, " failed to get driver version");
+ for (const auto& callback : callbacks_) {
+ callback->onChipDebugInfoFailure(reason);
+ }
return Void();
}
result.driverDescription = ret.second.c_str();
- ret = legacy_hal_.lock()->getWlanFirmwareVersion();
+ ret = legacy_hal_.lock()->getFirmwareVersion();
if (ret.first != WIFI_SUCCESS) {
LOG(ERROR) << "Failed to get firmware version: "
<< LegacyErrorToString(ret.first);
+ FailureReason reason = CreateFailureReasonLegacyError(
+ ret.first, " failed to get firmware version");
+ for (const auto& callback : callbacks_) {
+ callback->onChipDebugInfoFailure(reason);
+ }
return Void();
}
result.firmwareDescription = ret.second.c_str();
@@ -97,14 +142,18 @@
}
Return<void> WifiChip::requestDriverDebugDump() {
- if (!legacy_hal_.lock())
+ if (!is_valid_)
return Void();
std::pair<wifi_error, std::vector<char>> ret =
- legacy_hal_.lock()->requestWlanDriverMemoryDump();
+ legacy_hal_.lock()->requestDriverMemoryDump();
if (ret.first != WIFI_SUCCESS) {
LOG(ERROR) << "Failed to get driver debug dump: "
<< LegacyErrorToString(ret.first);
+ FailureReason reason = CreateFailureReasonLegacyError(ret.first, "");
+ for (const auto& callback : callbacks_) {
+ callback->onDriverDebugDumpFailure(reason);
+ }
return Void();
}
@@ -119,14 +168,18 @@
}
Return<void> WifiChip::requestFirmwareDebugDump() {
- if (!legacy_hal_.lock())
+ if (!is_valid_)
return Void();
std::pair<wifi_error, std::vector<char>> ret =
- legacy_hal_.lock()->requestWlanFirmwareMemoryDump();
+ legacy_hal_.lock()->requestFirmwareMemoryDump();
if (ret.first != WIFI_SUCCESS) {
LOG(ERROR) << "Failed to get firmware debug dump: "
<< LegacyErrorToString(ret.first);
+ FailureReason reason = CreateFailureReasonLegacyError(ret.first, "");
+ for (const auto& callback : callbacks_) {
+ callback->onFirmwareDebugDumpFailure(reason);
+ }
return Void();
}
@@ -140,6 +193,203 @@
return Void();
}
+Return<void> WifiChip::createApIface(createApIface_cb cb) {
+ if (!is_valid_) {
+ cb(nullptr);
+ return Void();
+ }
+
+ // TODO(b/31997422): Disallow this based on the chip combination.
+ std::string ifname = legacy_hal_.lock()->getApIfaceName();
+ ap_iface_ = new WifiApIface(ifname, legacy_hal_);
+ cb(ap_iface_);
+ return Void();
+}
+
+Return<void> WifiChip::getApIfaceNames(getApIfaceNames_cb cb) {
+ if (!is_valid_) {
+ cb(hidl_vec<hidl_string>());
+ return Void();
+ }
+
+ std::string ifname;
+ if (ap_iface_.get()) {
+ ifname = legacy_hal_.lock()->getApIfaceName().c_str();
+ }
+ cb(createHidlVecOfIfaceNames(ifname));
+ return Void();
+}
+
+Return<void> WifiChip::getApIface(const hidl_string& ifname, getApIface_cb cb) {
+ if (!is_valid_) {
+ cb(nullptr);
+ return Void();
+ }
+
+ if (ap_iface_.get() &&
+ (ifname.c_str() == legacy_hal_.lock()->getApIfaceName())) {
+ cb(ap_iface_);
+ } else {
+ cb(nullptr);
+ }
+ return Void();
+}
+
+Return<void> WifiChip::createNanIface(createNanIface_cb cb) {
+ if (!is_valid_) {
+ cb(nullptr);
+ return Void();
+ }
+
+ // TODO(b/31997422): Disallow this based on the chip combination.
+ std::string ifname = legacy_hal_.lock()->getNanIfaceName();
+ nan_iface_ = new WifiNanIface(ifname, legacy_hal_);
+ cb(nan_iface_);
+ return Void();
+}
+
+Return<void> WifiChip::getNanIfaceNames(getNanIfaceNames_cb cb) {
+ if (!is_valid_) {
+ cb(hidl_vec<hidl_string>());
+ return Void();
+ }
+
+ std::string ifname;
+ if (nan_iface_.get()) {
+ ifname = legacy_hal_.lock()->getNanIfaceName().c_str();
+ }
+ cb(createHidlVecOfIfaceNames(ifname));
+ return Void();
+}
+
+Return<void> WifiChip::getNanIface(const hidl_string& ifname,
+ getNanIface_cb cb) {
+ if (!is_valid_) {
+ cb(nullptr);
+ return Void();
+ }
+
+ if (nan_iface_.get() &&
+ (ifname.c_str() == legacy_hal_.lock()->getNanIfaceName())) {
+ cb(nan_iface_);
+ } else {
+ cb(nullptr);
+ }
+ return Void();
+}
+
+Return<void> WifiChip::createP2pIface(createP2pIface_cb cb) {
+ if (!is_valid_) {
+ cb(nullptr);
+ return Void();
+ }
+
+ // TODO(b/31997422): Disallow this based on the chip combination.
+ std::string ifname = legacy_hal_.lock()->getP2pIfaceName();
+ p2p_iface_ = new WifiP2pIface(ifname, legacy_hal_);
+ cb(p2p_iface_);
+ return Void();
+}
+
+Return<void> WifiChip::getP2pIfaceNames(getP2pIfaceNames_cb cb) {
+ if (!is_valid_) {
+ cb(hidl_vec<hidl_string>());
+ return Void();
+ }
+
+ std::string ifname;
+ if (p2p_iface_.get()) {
+ ifname = legacy_hal_.lock()->getP2pIfaceName().c_str();
+ }
+ cb(createHidlVecOfIfaceNames(ifname));
+ return Void();
+}
+
+Return<void> WifiChip::getP2pIface(const hidl_string& ifname,
+ getP2pIface_cb cb) {
+ if (!is_valid_) {
+ cb(nullptr);
+ return Void();
+ }
+
+ if (p2p_iface_.get() &&
+ (ifname.c_str() == legacy_hal_.lock()->getP2pIfaceName())) {
+ cb(p2p_iface_);
+ } else {
+ cb(nullptr);
+ }
+ return Void();
+}
+
+Return<void> WifiChip::createStaIface(createStaIface_cb cb) {
+ if (!is_valid_) {
+ cb(nullptr);
+ return Void();
+ }
+
+ // TODO(b/31997422): Disallow this based on the chip combination.
+ std::string ifname = legacy_hal_.lock()->getStaIfaceName();
+ sta_iface_ = new WifiStaIface(ifname, legacy_hal_);
+ cb(sta_iface_);
+ return Void();
+}
+
+Return<void> WifiChip::getStaIfaceNames(getStaIfaceNames_cb cb) {
+ if (!is_valid_) {
+ cb(hidl_vec<hidl_string>());
+ return Void();
+ }
+
+ std::string ifname;
+ if (sta_iface_.get()) {
+ ifname = legacy_hal_.lock()->getStaIfaceName().c_str();
+ }
+ cb(createHidlVecOfIfaceNames(ifname));
+ return Void();
+}
+
+Return<void> WifiChip::getStaIface(const hidl_string& ifname,
+ getStaIface_cb cb) {
+ if (!is_valid_) {
+ cb(nullptr);
+ return Void();
+ }
+
+ if (sta_iface_.get() &&
+ (ifname.c_str() == legacy_hal_.lock()->getStaIfaceName())) {
+ cb(sta_iface_);
+ } else {
+ cb(nullptr);
+ }
+ return Void();
+}
+
+Return<void> WifiChip::createRttController(const sp<IWifiIface>& bound_iface,
+ createRttController_cb cb) {
+ if (!is_valid_) {
+ cb(nullptr);
+ return Void();
+ }
+
+ sp<WifiRttController> rtt = new WifiRttController(bound_iface, legacy_hal_);
+ rtt_controllers_.emplace_back(rtt);
+ cb(rtt);
+ return Void();
+}
+
+void WifiChip::invalidateAndRemoveAllIfaces() {
+ invalidateAndClear(ap_iface_);
+ invalidateAndClear(nan_iface_);
+ invalidateAndClear(p2p_iface_);
+ invalidateAndClear(sta_iface_);
+ // Since all the ifaces are invalid now, all RTT controller objects
+ // using those ifaces also need to be invalidated.
+ for (const auto& rtt : rtt_controllers_) {
+ rtt->invalidate();
+ }
+ rtt_controllers_.clear();
+}
+
} // namespace implementation
} // namespace V1_0
} // namespace wifi
diff --git a/wifi/1.0/default/wifi_chip.h b/wifi/1.0/default/wifi_chip.h
index 95fabe4..94ffa63 100644
--- a/wifi/1.0/default/wifi_chip.h
+++ b/wifi/1.0/default/wifi_chip.h
@@ -17,12 +17,17 @@
#ifndef WIFI_CHIP_H_
#define WIFI_CHIP_H_
-#include <set>
+#include <map>
#include <android-base/macros.h>
#include <android/hardware/wifi/1.0/IWifiChip.h>
+#include "wifi_ap_iface.h"
#include "wifi_legacy_hal.h"
+#include "wifi_nan_iface.h"
+#include "wifi_p2p_iface.h"
+#include "wifi_rtt_controller.h"
+#include "wifi_sta_iface.h"
namespace android {
namespace hardware {
@@ -37,11 +42,24 @@
*/
class WifiChip : public IWifiChip {
public:
- WifiChip(std::weak_ptr<WifiLegacyHal> legacy_hal);
- // Invalidate this instance once the HAL is stopped.
+ WifiChip(ChipId chip_id, const std::weak_ptr<WifiLegacyHal> legacy_hal);
+ // HIDL does not provide a built-in mechanism to let the server invalidate
+ // a HIDL interface object after creation. If any client process holds onto
+ // a reference to the object in their context, any method calls on that
+ // reference will continue to be directed to the server.
+ //
+ // However Wifi HAL needs to control the lifetime of these objects. So, add
+ // a public |invalidate| method to |WifiChip| and it's child objects. This
+ // will be used to mark an object invalid when either:
+ // a) Wifi HAL is stopped, or
+ // b) Wifi Chip is reconfigured.
+ //
+ // All HIDL method implementations should check if the object is still marked
+ // valid before processing them.
void invalidate();
// HIDL methods exposed.
+ Return<ChipId> getId() override;
Return<void> registerEventCallback(
const sp<IWifiChipEventCallback>& callback) override;
Return<void> getAvailableModes(getAvailableModes_cb cb) override;
@@ -50,10 +68,36 @@
Return<void> requestChipDebugInfo() override;
Return<void> requestDriverDebugDump() override;
Return<void> requestFirmwareDebugDump() override;
+ Return<void> createApIface(createApIface_cb cb) override;
+ Return<void> getApIfaceNames(getApIfaceNames_cb cb) override;
+ Return<void> getApIface(const hidl_string& ifname, getApIface_cb cb) override;
+ Return<void> createNanIface(createNanIface_cb cb) override;
+ Return<void> getNanIfaceNames(getNanIfaceNames_cb cb) override;
+ Return<void> getNanIface(const hidl_string& ifname,
+ getNanIface_cb cb) override;
+ Return<void> createP2pIface(createP2pIface_cb cb) override;
+ Return<void> getP2pIfaceNames(getP2pIfaceNames_cb cb) override;
+ Return<void> getP2pIface(const hidl_string& ifname,
+ getP2pIface_cb cb) override;
+ Return<void> createStaIface(createStaIface_cb cb) override;
+ Return<void> getStaIfaceNames(getStaIfaceNames_cb cb) override;
+ Return<void> getStaIface(const hidl_string& ifname,
+ getStaIface_cb cb) override;
+ Return<void> createRttController(const sp<IWifiIface>& bound_iface,
+ createRttController_cb cb) override;
private:
+ void invalidateAndRemoveAllIfaces();
+
+ ChipId chip_id_;
std::weak_ptr<WifiLegacyHal> legacy_hal_;
- std::set<sp<IWifiChipEventCallback>> callbacks_;
+ std::vector<sp<IWifiChipEventCallback>> callbacks_;
+ sp<WifiApIface> ap_iface_;
+ sp<WifiNanIface> nan_iface_;
+ sp<WifiP2pIface> p2p_iface_;
+ sp<WifiStaIface> sta_iface_;
+ std::vector<sp<WifiRttController>> rtt_controllers_;
+ bool is_valid_;
DISALLOW_COPY_AND_ASSIGN(WifiChip);
};
diff --git a/wifi/1.0/default/wifi_legacy_hal.cpp b/wifi/1.0/default/wifi_legacy_hal.cpp
index a6df996..553a058 100644
--- a/wifi/1.0/default/wifi_legacy_hal.cpp
+++ b/wifi/1.0/default/wifi_legacy_hal.cpp
@@ -25,12 +25,6 @@
#include <wifi_system/interface_tool.h>
namespace {
-std::string getWlanInterfaceName() {
- char buffer[PROPERTY_VALUE_MAX];
- property_get("wifi.interface", buffer, "wlan0");
- return buffer;
-}
-
// Legacy HAL functions accept "C" style function pointers, so use global
// functions to pass to the legacy HAL function and store the corresponding
// std::function methods to be invoked.
@@ -120,7 +114,31 @@
return WIFI_SUCCESS;
}
-std::pair<wifi_error, std::string> WifiLegacyHal::getWlanDriverVersion() {
+std::string WifiLegacyHal::getApIfaceName() {
+ // Fake name. This interface does not exist in legacy HAL
+ // API's.
+ return "ap0";
+}
+
+std::string WifiLegacyHal::getNanIfaceName() {
+ // Fake name. This interface does not exist in legacy HAL
+ // API's.
+ return "nan0";
+}
+
+std::string WifiLegacyHal::getP2pIfaceName() {
+ std::array<char, PROPERTY_VALUE_MAX> buffer;
+ property_get("wifi.direct.interface", buffer.data(), "p2p0");
+ return buffer.data();
+}
+
+std::string WifiLegacyHal::getStaIfaceName() {
+ std::array<char, PROPERTY_VALUE_MAX> buffer;
+ property_get("wifi.interface", buffer.data(), "wlan0");
+ return buffer.data();
+}
+
+std::pair<wifi_error, std::string> WifiLegacyHal::getDriverVersion() {
std::array<char, kMaxVersionStringLength> buffer;
buffer.fill(0);
wifi_error status = global_func_table_.wifi_get_driver_version(
@@ -128,7 +146,7 @@
return std::make_pair(status, buffer.data());
}
-std::pair<wifi_error, std::string> WifiLegacyHal::getWlanFirmwareVersion() {
+std::pair<wifi_error, std::string> WifiLegacyHal::getFirmwareVersion() {
std::array<char, kMaxVersionStringLength> buffer;
buffer.fill(0);
wifi_error status = global_func_table_.wifi_get_firmware_version(
@@ -137,7 +155,7 @@
}
std::pair<wifi_error, std::vector<char>>
-WifiLegacyHal::requestWlanDriverMemoryDump() {
+WifiLegacyHal::requestDriverMemoryDump() {
std::vector<char> driver_dump;
on_driver_memory_dump_internal_callback = [&driver_dump](char* buffer,
int buffer_size) {
@@ -150,7 +168,7 @@
}
std::pair<wifi_error, std::vector<char>>
-WifiLegacyHal::requestWlanFirmwareMemoryDump() {
+WifiLegacyHal::requestFirmwareMemoryDump() {
std::vector<char> firmware_dump;
on_firmware_memory_dump_internal_callback = [&firmware_dump](
char* buffer, int buffer_size) {
@@ -163,8 +181,7 @@
}
wifi_error WifiLegacyHal::retrieveWlanInterfaceHandle() {
- const std::string& ifname_to_find = getWlanInterfaceName();
-
+ const std::string& ifname_to_find = getStaIfaceName();
wifi_interface_handle* iface_handles = nullptr;
int num_iface_handles = 0;
wifi_error status = global_func_table_.wifi_get_ifaces(
diff --git a/wifi/1.0/default/wifi_legacy_hal.h b/wifi/1.0/default/wifi_legacy_hal.h
index f691b9b..3585975 100644
--- a/wifi/1.0/default/wifi_legacy_hal.h
+++ b/wifi/1.0/default/wifi_legacy_hal.h
@@ -35,15 +35,21 @@
class WifiLegacyHal {
public:
WifiLegacyHal();
+ // Names to use for the different types of iface.
+ std::string getApIfaceName();
+ std::string getNanIfaceName();
+ std::string getP2pIfaceName();
+ std::string getStaIfaceName();
+
// Initialize the legacy HAL and start the event looper thread.
wifi_error start();
// Deinitialize the legacy HAL and stop the event looper thread.
wifi_error stop(const std::function<void()>& on_complete_callback);
// Wrappers for all the functions in the legacy HAL function table.
- std::pair<wifi_error, std::string> getWlanDriverVersion();
- std::pair<wifi_error, std::string> getWlanFirmwareVersion();
- std::pair<wifi_error, std::vector<char>> requestWlanDriverMemoryDump();
- std::pair<wifi_error, std::vector<char>> requestWlanFirmwareMemoryDump();
+ std::pair<wifi_error, std::string> getDriverVersion();
+ std::pair<wifi_error, std::string> getFirmwareVersion();
+ std::pair<wifi_error, std::vector<char>> requestDriverMemoryDump();
+ std::pair<wifi_error, std::vector<char>> requestFirmwareMemoryDump();
private:
static const uint32_t kMaxVersionStringLength;
diff --git a/wifi/1.0/default/wifi_nan_iface.cpp b/wifi/1.0/default/wifi_nan_iface.cpp
new file mode 100644
index 0000000..3c7ae4b
--- /dev/null
+++ b/wifi/1.0/default/wifi_nan_iface.cpp
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "wifi_nan_iface.h"
+
+#include <android-base/logging.h>
+
+#include "failure_reason_util.h"
+
+namespace android {
+namespace hardware {
+namespace wifi {
+namespace V1_0 {
+namespace implementation {
+
+WifiNanIface::WifiNanIface(const std::string& ifname,
+ const std::weak_ptr<WifiLegacyHal> legacy_hal)
+ : ifname_(ifname), legacy_hal_(legacy_hal), is_valid_(true) {}
+
+void WifiNanIface::invalidate() {
+ legacy_hal_.reset();
+ is_valid_ = false;
+}
+
+Return<void> WifiNanIface::getName(getName_cb cb) {
+ hidl_string hidl_ifname;
+ hidl_ifname.setToExternal(ifname_.c_str(), ifname_.size());
+ cb(hidl_ifname);
+ return Void();
+}
+
+Return<IfaceType> WifiNanIface::getType() {
+ return IfaceType::NAN;
+}
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace wifi
+} // namespace hardware
+} // namespace android
diff --git a/wifi/1.0/default/wifi_nan_iface.h b/wifi/1.0/default/wifi_nan_iface.h
new file mode 100644
index 0000000..93e2e77
--- /dev/null
+++ b/wifi/1.0/default/wifi_nan_iface.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef WIFI_NAN_IFACE_H_
+#define WIFI_NAN_IFACE_H_
+
+#include <android-base/macros.h>
+#include <android/hardware/wifi/1.0/IWifiNanIface.h>
+
+#include "wifi_legacy_hal.h"
+
+namespace android {
+namespace hardware {
+namespace wifi {
+namespace V1_0 {
+namespace implementation {
+
+/**
+ * HIDL interface object used to control a NAN Iface instance.
+ */
+class WifiNanIface : public IWifiNanIface {
+ public:
+ WifiNanIface(const std::string& ifname,
+ const std::weak_ptr<WifiLegacyHal> legacy_hal);
+ // Refer to |WifiChip::invalidate()|.
+ void invalidate();
+
+ // HIDL methods exposed.
+ Return<void> getName(getName_cb cb) override;
+ Return<IfaceType> getType() override;
+
+ private:
+ std::string ifname_;
+ std::weak_ptr<WifiLegacyHal> legacy_hal_;
+ bool is_valid_;
+
+ DISALLOW_COPY_AND_ASSIGN(WifiNanIface);
+};
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace wifi
+} // namespace hardware
+} // namespace android
+
+#endif // WIFI_NAN_IFACE_H_
diff --git a/wifi/1.0/default/wifi_p2p_iface.cpp b/wifi/1.0/default/wifi_p2p_iface.cpp
new file mode 100644
index 0000000..349a158
--- /dev/null
+++ b/wifi/1.0/default/wifi_p2p_iface.cpp
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "wifi_p2p_iface.h"
+
+#include <android-base/logging.h>
+
+#include "failure_reason_util.h"
+
+namespace android {
+namespace hardware {
+namespace wifi {
+namespace V1_0 {
+namespace implementation {
+
+WifiP2pIface::WifiP2pIface(const std::string& ifname,
+ const std::weak_ptr<WifiLegacyHal> legacy_hal)
+ : ifname_(ifname), legacy_hal_(legacy_hal), is_valid_(true) {}
+
+void WifiP2pIface::invalidate() {
+ legacy_hal_.reset();
+ is_valid_ = false;
+}
+
+Return<void> WifiP2pIface::getName(getName_cb cb) {
+ hidl_string hidl_ifname;
+ hidl_ifname.setToExternal(ifname_.c_str(), ifname_.size());
+ cb(hidl_ifname);
+ return Void();
+}
+
+Return<IfaceType> WifiP2pIface::getType() {
+ return IfaceType::P2P;
+}
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace wifi
+} // namespace hardware
+} // namespace android
diff --git a/wifi/1.0/default/wifi_p2p_iface.h b/wifi/1.0/default/wifi_p2p_iface.h
new file mode 100644
index 0000000..d70415d
--- /dev/null
+++ b/wifi/1.0/default/wifi_p2p_iface.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef WIFI_P2P_IFACE_H_
+#define WIFI_P2P_IFACE_H_
+
+#include <android-base/macros.h>
+#include <android/hardware/wifi/1.0/IWifiP2pIface.h>
+
+#include "wifi_legacy_hal.h"
+
+namespace android {
+namespace hardware {
+namespace wifi {
+namespace V1_0 {
+namespace implementation {
+
+/**
+ * HIDL interface object used to control a P2P Iface instance.
+ */
+class WifiP2pIface : public IWifiP2pIface {
+ public:
+ WifiP2pIface(const std::string& ifname,
+ const std::weak_ptr<WifiLegacyHal> legacy_hal);
+ // Refer to |WifiChip::invalidate()|.
+ void invalidate();
+
+ // HIDL methods exposed.
+ Return<void> getName(getName_cb cb) override;
+ Return<IfaceType> getType() override;
+
+ private:
+ std::string ifname_;
+ std::weak_ptr<WifiLegacyHal> legacy_hal_;
+ bool is_valid_;
+
+ DISALLOW_COPY_AND_ASSIGN(WifiP2pIface);
+};
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace wifi
+} // namespace hardware
+} // namespace android
+
+#endif // WIFI_P2P_IFACE_H_
diff --git a/wifi/1.0/default/wifi_rtt_controller.cpp b/wifi/1.0/default/wifi_rtt_controller.cpp
new file mode 100644
index 0000000..e2df1a8
--- /dev/null
+++ b/wifi/1.0/default/wifi_rtt_controller.cpp
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "wifi_rtt_controller.h"
+
+#include <android-base/logging.h>
+
+#include "failure_reason_util.h"
+
+namespace android {
+namespace hardware {
+namespace wifi {
+namespace V1_0 {
+namespace implementation {
+
+WifiRttController::WifiRttController(
+ const sp<IWifiIface>& bound_iface,
+ const std::weak_ptr<WifiLegacyHal> legacy_hal)
+ : bound_iface_(bound_iface), legacy_hal_(legacy_hal), is_valid_(true) {}
+
+void WifiRttController::invalidate() {
+ legacy_hal_.reset();
+ is_valid_ = false;
+}
+
+Return<void> WifiRttController::getBoundIface(getBoundIface_cb cb) {
+ cb(bound_iface_);
+ return Void();
+}
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace wifi
+} // namespace hardware
+} // namespace android
diff --git a/wifi/1.0/default/wifi_rtt_controller.h b/wifi/1.0/default/wifi_rtt_controller.h
new file mode 100644
index 0000000..8d78b93
--- /dev/null
+++ b/wifi/1.0/default/wifi_rtt_controller.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef WIFI_RTT_CONTROLLER_H_
+#define WIFI_RTT_CONTROLLER_H_
+
+#include <android-base/macros.h>
+#include <android/hardware/wifi/1.0/IWifiIface.h>
+#include <android/hardware/wifi/1.0/IWifiRttController.h>
+
+#include "wifi_legacy_hal.h"
+
+namespace android {
+namespace hardware {
+namespace wifi {
+namespace V1_0 {
+namespace implementation {
+
+/**
+ * HIDL interface object used to control all RTT operations.
+ */
+class WifiRttController : public IWifiRttController {
+ public:
+ WifiRttController(const sp<IWifiIface>& bound_iface,
+ const std::weak_ptr<WifiLegacyHal> legacy_hal);
+ // Refer to |WifiChip::invalidate()|.
+ void invalidate();
+
+ // HIDL methods exposed.
+ Return<void> getBoundIface(getBoundIface_cb cb) override;
+
+ private:
+ sp<IWifiIface> bound_iface_;
+ std::weak_ptr<WifiLegacyHal> legacy_hal_;
+ bool is_valid_;
+
+ DISALLOW_COPY_AND_ASSIGN(WifiRttController);
+};
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace wifi
+} // namespace hardware
+} // namespace android
+
+#endif // WIFI_RTT_CONTROLLER_H_
diff --git a/wifi/1.0/default/wifi_sta_iface.cpp b/wifi/1.0/default/wifi_sta_iface.cpp
new file mode 100644
index 0000000..225cec4
--- /dev/null
+++ b/wifi/1.0/default/wifi_sta_iface.cpp
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "wifi_sta_iface.h"
+
+#include <android-base/logging.h>
+
+#include "failure_reason_util.h"
+
+namespace android {
+namespace hardware {
+namespace wifi {
+namespace V1_0 {
+namespace implementation {
+
+WifiStaIface::WifiStaIface(const std::string& ifname,
+ const std::weak_ptr<WifiLegacyHal> legacy_hal)
+ : ifname_(ifname), legacy_hal_(legacy_hal), is_valid_(true) {}
+
+void WifiStaIface::invalidate() {
+ legacy_hal_.reset();
+ is_valid_ = false;
+}
+
+Return<void> WifiStaIface::getName(getName_cb cb) {
+ hidl_string hidl_ifname;
+ hidl_ifname.setToExternal(ifname_.c_str(), ifname_.size());
+ cb(hidl_ifname);
+ return Void();
+}
+
+Return<IfaceType> WifiStaIface::getType() {
+ return IfaceType::STA;
+}
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace wifi
+} // namespace hardware
+} // namespace android
diff --git a/wifi/1.0/default/wifi_sta_iface.h b/wifi/1.0/default/wifi_sta_iface.h
new file mode 100644
index 0000000..fc5efec
--- /dev/null
+++ b/wifi/1.0/default/wifi_sta_iface.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef WIFI_STA_IFACE_H_
+#define WIFI_STA_IFACE_H_
+
+#include <android-base/macros.h>
+#include <android/hardware/wifi/1.0/IWifiStaIface.h>
+
+#include "wifi_legacy_hal.h"
+
+namespace android {
+namespace hardware {
+namespace wifi {
+namespace V1_0 {
+namespace implementation {
+
+/**
+ * HIDL interface object used to control a STA Iface instance.
+ */
+class WifiStaIface : public IWifiStaIface {
+ public:
+ WifiStaIface(const std::string& ifname,
+ const std::weak_ptr<WifiLegacyHal> legacy_hal);
+ // Refer to |WifiChip::invalidate()|.
+ void invalidate();
+
+ // HIDL methods exposed.
+ Return<void> getName(getName_cb cb) override;
+ Return<IfaceType> getType() override;
+
+ private:
+ std::string ifname_;
+ std::weak_ptr<WifiLegacyHal> legacy_hal_;
+ bool is_valid_;
+
+ DISALLOW_COPY_AND_ASSIGN(WifiStaIface);
+};
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace wifi
+} // namespace hardware
+} // namespace android
+
+#endif // WIFI_STA_IFACE_H_
diff --git a/wifi/1.0/types.hal b/wifi/1.0/types.hal
index 49849ea..d9abaef 100644
--- a/wifi/1.0/types.hal
+++ b/wifi/1.0/types.hal
@@ -16,6 +16,9 @@
package android.hardware.wifi@1.0;
+/**
+ * List of failure reasons returned.
+ */
enum CommandFailureReason : uint32_t {
UNKNOWN,
DUPLICATE_COMMAND_ID,
@@ -41,6 +44,25 @@
};
/**
+ * List of Iface types supported.
+ */
+enum IfaceType : uint32_t {
+ STA,
+ AP,
+ P2P,
+ /**
+ * NAN control interface. Datapath support may be queried and created
+ * through this interface.
+ */
+ NAN,
+};
+
+/**
+ * An identifier assigned to every chip on the device.
+ */
+typedef uint32_t ChipId;
+
+/**
* An identifier for a mode that the chip can be put in.
*/
typedef uint32_t ChipModeId;