Merge "Camera: HIDLized camera HALs, first set"
diff --git a/audio/2.0/IDevice.hal b/audio/2.0/IDevice.hal
index 38bfe21..630a32c 100644
--- a/audio/2.0/IDevice.hal
+++ b/audio/2.0/IDevice.hal
@@ -102,6 +102,8 @@
/*
* This method creates and opens the audio hardware output stream.
+ * If the stream can not be opened with the proposed audio config,
+ * HAL must provide suggested values for the audio config.
*
* @param ioHandle handle assigned by AudioFlinger.
* @param device device type and (if needed) address.
@@ -109,15 +111,21 @@
* @param flags additional flags.
* @return retval operation completion status.
* @return outStream created output stream.
+ * @return suggestedConfig in case of invalid parameters, suggested config.
*/
openOutputStream(
AudioIoHandle ioHandle,
DeviceAddress device,
AudioConfig config,
- AudioOutputFlag flags) generates (Result retval, IStreamOut outStream);
+ AudioOutputFlag flags) generates (
+ Result retval,
+ IStreamOut outStream,
+ AudioConfig suggestedConfig);
/*
* This method creates and opens the audio hardware input stream.
+ * If the stream can not be opened with the proposed audio config,
+ * HAL must provide suggested values for the audio config.
*
* @param ioHandle handle assigned by AudioFlinger.
* @param device device type and (if needed) address.
@@ -125,14 +133,25 @@
* @param flags additional flags.
* @param source source specification.
* @return retval operation completion status.
- * @return inStream created input stream.
+ * @return inStream in case of success, created input stream.
+ * @return suggestedConfig in case of invalid parameters, suggested config.
*/
openInputStream(
AudioIoHandle ioHandle,
DeviceAddress device,
AudioConfig config,
AudioInputFlag flags,
- AudioSource source) generates (Result retval, IStreamIn inStream);
+ AudioSource source) generates (
+ Result retval,
+ IStreamIn inStream,
+ AudioConfig suggestedConfig);
+
+ /*
+ * Returns whether HAL supports audio patches.
+ *
+ * @return supports true if audio patches are supported.
+ */
+ supportsAudioPatches() generates (bool supports);
/*
* Creates an audio patch between several source and sink ports. The handle
diff --git a/audio/2.0/IStreamOut.hal b/audio/2.0/IStreamOut.hal
index 55a852d..4ba3b2f 100644
--- a/audio/2.0/IStreamOut.hal
+++ b/audio/2.0/IStreamOut.hal
@@ -90,11 +90,25 @@
* Calling this function implies that all future 'write' and 'drain'
* must be non-blocking and use the callback to signal completion.
*
+ * 'clearCallback' method needs to be called in order to release the local
+ * callback proxy on the server side and thus dereference the callback
+ * implementation on the client side.
+ *
* @return retval operation completion status.
*/
setCallback(IStreamOutCallback callback) generates (Result retval);
/*
+ * Clears the callback previously set via 'setCallback' method.
+ *
+ * Warning: failure to call this method results in callback implementation
+ * on the client side being held until the HAL server termination.
+ *
+ * @return retval operation completion status: OK or NOT_SUPPORTED.
+ */
+ clearCallback() generates (Result retval);
+
+ /*
* Returns whether HAL supports pausing and resuming of streams.
*
* @return supportsPause true if pausing is supported.
diff --git a/audio/2.0/default/Conversions.cpp b/audio/2.0/default/Conversions.cpp
index 1ba16e1..e669185 100644
--- a/audio/2.0/default/Conversions.cpp
+++ b/audio/2.0/default/Conversions.cpp
@@ -29,27 +29,31 @@
char halAddress[AUDIO_DEVICE_MAX_ADDRESS_LEN];
memset(halAddress, 0, sizeof(halAddress));
uint32_t halDevice = static_cast<uint32_t>(address.device);
- if ((halDevice & AUDIO_DEVICE_OUT_ALL_A2DP) != 0
- || (halDevice & AUDIO_DEVICE_IN_BLUETOOTH_A2DP) != 0) {
+ const bool isInput = (halDevice & AUDIO_DEVICE_BIT_IN) != 0;
+ if (isInput) halDevice &= ~AUDIO_DEVICE_BIT_IN;
+ if ((!isInput && (halDevice & AUDIO_DEVICE_OUT_ALL_A2DP) != 0)
+ || (isInput && (halDevice & AUDIO_DEVICE_IN_BLUETOOTH_A2DP) != 0)) {
snprintf(halAddress, sizeof(halAddress),
"%02X:%02X:%02X:%02X:%02X:%02X",
address.address.mac[0], address.address.mac[1], address.address.mac[2],
address.address.mac[3], address.address.mac[4], address.address.mac[5]);
- } else if ((halDevice & AUDIO_DEVICE_OUT_IP) != 0 || (halDevice & AUDIO_DEVICE_IN_IP) != 0) {
+ } else if ((!isInput && (halDevice & AUDIO_DEVICE_OUT_IP) != 0)
+ || (isInput && (halDevice & AUDIO_DEVICE_IN_IP) != 0)) {
snprintf(halAddress, sizeof(halAddress),
"%d.%d.%d.%d",
address.address.ipv4[0], address.address.ipv4[1],
address.address.ipv4[2], address.address.ipv4[3]);
- } else if ((halDevice & AUDIO_DEVICE_OUT_ALL_USB) != 0
- || (halDevice & AUDIO_DEVICE_IN_ALL_USB) != 0) {
+ } else if ((!isInput && (halDevice & AUDIO_DEVICE_OUT_ALL_USB) != 0)
+ || (isInput && (halDevice & AUDIO_DEVICE_IN_ALL_USB) != 0)) {
snprintf(halAddress, sizeof(halAddress),
"card=%d;device=%d",
address.address.alsa.card, address.address.alsa.device);
- } else if ((halDevice & AUDIO_DEVICE_OUT_BUS) != 0 || (halDevice & AUDIO_DEVICE_IN_BUS) != 0) {
+ } else if ((!isInput && (halDevice & AUDIO_DEVICE_OUT_BUS) != 0)
+ || (isInput && (halDevice & AUDIO_DEVICE_IN_BUS) != 0)) {
snprintf(halAddress, sizeof(halAddress),
"%s", address.busAddress.c_str());
- } else if ((halDevice & AUDIO_DEVICE_OUT_REMOTE_SUBMIX) != 0
- || (halDevice & AUDIO_DEVICE_IN_REMOTE_SUBMIX) != 0) {
+ } else if ((!isInput && (halDevice & AUDIO_DEVICE_OUT_REMOTE_SUBMIX)) != 0
+ || (isInput && (halDevice & AUDIO_DEVICE_IN_REMOTE_SUBMIX) != 0)) {
snprintf(halAddress, sizeof(halAddress),
"%s", address.rSubmixAddress.c_str());
}
diff --git a/audio/2.0/default/Device.cpp b/audio/2.0/default/Device.cpp
index 339f371..8a51cd7 100644
--- a/audio/2.0/default/Device.cpp
+++ b/audio/2.0/default/Device.cpp
@@ -15,15 +15,17 @@
*/
#define LOG_TAG "DeviceHAL"
+//#define LOG_NDEBUG 0
#include <algorithm>
#include <memory.h>
#include <string.h>
-#include <utils/Log.h>
+#include <android/log.h>
#include "Conversions.h"
#include "Device.h"
+#include "HidlUtils.h"
#include "StreamIn.h"
#include "StreamOut.h"
@@ -43,267 +45,6 @@
mDevice = nullptr;
}
-// static
-void Device::audioConfigToHal(const AudioConfig& config, audio_config_t* halConfig) {
- memset(halConfig, 0, sizeof(audio_config_t));
- halConfig->sample_rate = config.sampleRateHz;
- halConfig->channel_mask = static_cast<audio_channel_mask_t>(config.channelMask);
- halConfig->format = static_cast<audio_format_t>(config.format);
- audioOffloadInfoToHal(config.offloadInfo, &halConfig->offload_info);
- halConfig->frame_count = config.frameCount;
-}
-
-// static
-void Device::audioGainConfigFromHal(
- const struct audio_gain_config& halConfig, AudioGainConfig* config) {
- config->index = halConfig.index;
- config->mode = AudioGainMode(halConfig.mode);
- config->channelMask = AudioChannelMask(halConfig.channel_mask);
- for (size_t i = 0; i < sizeof(audio_channel_mask_t) * 8; ++i) {
- config->values[i] = halConfig.values[i];
- }
- config->rampDurationMs = halConfig.ramp_duration_ms;
-}
-
-// static
-void Device::audioGainConfigToHal(
- const AudioGainConfig& config, struct audio_gain_config* halConfig) {
- halConfig->index = config.index;
- halConfig->mode = static_cast<audio_gain_mode_t>(config.mode);
- halConfig->channel_mask = static_cast<audio_channel_mask_t>(config.channelMask);
- memset(halConfig->values, 0, sizeof(halConfig->values));
- for (size_t i = 0; i < sizeof(audio_channel_mask_t) * 8; ++i) {
- halConfig->values[i] = config.values[i];
- }
- halConfig->ramp_duration_ms = config.rampDurationMs;
-}
-
-// static
-void Device::audioGainFromHal(const struct audio_gain& halGain, AudioGain* gain) {
- gain->mode = AudioGainMode(halGain.mode);
- gain->channelMask = AudioChannelMask(halGain.channel_mask);
- gain->minValue = halGain.min_value;
- gain->maxValue = halGain.max_value;
- gain->defaultValue = halGain.default_value;
- gain->stepValue = halGain.step_value;
- gain->minRampMs = halGain.min_ramp_ms;
- gain->maxRampMs = halGain.max_ramp_ms;
-}
-
-// static
-void Device::audioGainToHal(const AudioGain& gain, struct audio_gain* halGain) {
- halGain->mode = static_cast<audio_gain_mode_t>(gain.mode);
- halGain->channel_mask = static_cast<audio_channel_mask_t>(gain.channelMask);
- halGain->min_value = gain.minValue;
- halGain->max_value = gain.maxValue;
- halGain->default_value = gain.defaultValue;
- halGain->step_value = gain.stepValue;
- halGain->min_ramp_ms = gain.minRampMs;
- halGain->max_ramp_ms = gain.maxRampMs;
-}
-
-// static
-void Device::audioOffloadInfoToHal(
- const AudioOffloadInfo& offload, audio_offload_info_t* halOffload) {
- *halOffload = AUDIO_INFO_INITIALIZER;
- halOffload->sample_rate = offload.sampleRateHz;
- halOffload->channel_mask = static_cast<audio_channel_mask_t>(offload.channelMask);
- halOffload->stream_type = static_cast<audio_stream_type_t>(offload.streamType);
- halOffload->bit_rate = offload.bitRatePerSecond;
- halOffload->duration_us = offload.durationMicroseconds;
- halOffload->has_video = offload.hasVideo;
- halOffload->is_streaming = offload.isStreaming;
-}
-
-// static
-void Device::audioPortConfigFromHal(
- const struct audio_port_config& halConfig, AudioPortConfig* config) {
- config->id = halConfig.id;
- config->role = AudioPortRole(halConfig.role);
- config->type = AudioPortType(halConfig.type);
- config->configMask = AudioPortConfigMask(halConfig.config_mask);
- config->sampleRateHz = halConfig.sample_rate;
- config->channelMask = AudioChannelMask(halConfig.channel_mask);
- config->format = AudioFormat(halConfig.format);
- audioGainConfigFromHal(halConfig.gain, &config->gain);
- switch (halConfig.type) {
- case AUDIO_PORT_TYPE_NONE: break;
- case AUDIO_PORT_TYPE_DEVICE: {
- config->ext.device.hwModule = halConfig.ext.device.hw_module;
- config->ext.device.type = AudioDevice(halConfig.ext.device.type);
- memcpy(config->ext.device.address.data(),
- halConfig.ext.device.address,
- AUDIO_DEVICE_MAX_ADDRESS_LEN);
- break;
- }
- case AUDIO_PORT_TYPE_MIX: {
- config->ext.mix.hwModule = halConfig.ext.mix.hw_module;
- config->ext.mix.ioHandle = halConfig.ext.mix.handle;
- if (halConfig.role == AUDIO_PORT_ROLE_SOURCE) {
- config->ext.mix.useCase.source = AudioSource(halConfig.ext.mix.usecase.source);
- } else if (halConfig.role == AUDIO_PORT_ROLE_SINK) {
- config->ext.mix.useCase.stream = AudioStreamType(halConfig.ext.mix.usecase.stream);
- }
- break;
- }
- case AUDIO_PORT_TYPE_SESSION: {
- config->ext.session.session = halConfig.ext.session.session;
- break;
- }
- }
-}
-
-// static
-void Device::audioPortConfigToHal(
- const AudioPortConfig& config, struct audio_port_config* halConfig) {
- memset(halConfig, 0, sizeof(audio_port_config));
- halConfig->id = config.id;
- halConfig->role = static_cast<audio_port_role_t>(config.role);
- halConfig->type = static_cast<audio_port_type_t>(config.type);
- halConfig->config_mask = static_cast<unsigned int>(config.configMask);
- halConfig->sample_rate = config.sampleRateHz;
- halConfig->channel_mask = static_cast<audio_channel_mask_t>(config.channelMask);
- halConfig->format = static_cast<audio_format_t>(config.format);
- audioGainConfigToHal(config.gain, &halConfig->gain);
- switch (config.type) {
- case AudioPortType::NONE: break;
- case AudioPortType::DEVICE: {
- halConfig->ext.device.hw_module = config.ext.device.hwModule;
- halConfig->ext.device.type = static_cast<audio_devices_t>(config.ext.device.type);
- memcpy(halConfig->ext.device.address,
- config.ext.device.address.data(),
- AUDIO_DEVICE_MAX_ADDRESS_LEN);
- break;
- }
- case AudioPortType::MIX: {
- halConfig->ext.mix.hw_module = config.ext.mix.hwModule;
- halConfig->ext.mix.handle = config.ext.mix.ioHandle;
- if (config.role == AudioPortRole::SOURCE) {
- halConfig->ext.mix.usecase.source =
- static_cast<audio_source_t>(config.ext.mix.useCase.source);
- } else if (config.role == AudioPortRole::SINK) {
- halConfig->ext.mix.usecase.stream =
- static_cast<audio_stream_type_t>(config.ext.mix.useCase.stream);
- }
- break;
- }
- case AudioPortType::SESSION: {
- halConfig->ext.session.session =
- static_cast<audio_session_t>(config.ext.session.session);
- break;
- }
- }
-}
-
-// static
-std::unique_ptr<audio_port_config[]> Device::audioPortConfigsToHal(
- const hidl_vec<AudioPortConfig>& configs) {
- std::unique_ptr<audio_port_config[]> halConfigs(new audio_port_config[configs.size()]);
- for (size_t i = 0; i < configs.size(); ++i) {
- audioPortConfigToHal(configs[i], &halConfigs[i]);
- }
- return halConfigs;
-}
-
-// static
-void Device::audioPortFromHal(const struct audio_port& halPort, AudioPort* port) {
- port->id = halPort.id;
- port->role = AudioPortRole(halPort.role);
- port->type = AudioPortType(halPort.type);
- port->name.setToExternal(halPort.name, strlen(halPort.name));
- port->sampleRates.resize(halPort.num_sample_rates);
- for (size_t i = 0; i < halPort.num_sample_rates; ++i) {
- port->sampleRates[i] = halPort.sample_rates[i];
- }
- port->channelMasks.resize(halPort.num_channel_masks);
- for (size_t i = 0; i < halPort.num_channel_masks; ++i) {
- port->channelMasks[i] = AudioChannelMask(halPort.channel_masks[i]);
- }
- port->formats.resize(halPort.num_formats);
- for (size_t i = 0; i < halPort.num_formats; ++i) {
- port->formats[i] = AudioFormat(halPort.formats[i]);
- }
- port->gains.resize(halPort.num_gains);
- for (size_t i = 0; i < halPort.num_gains; ++i) {
- audioGainFromHal(halPort.gains[i], &port->gains[i]);
- }
- audioPortConfigFromHal(halPort.active_config, &port->activeConfig);
- switch (halPort.type) {
- case AUDIO_PORT_TYPE_NONE: break;
- case AUDIO_PORT_TYPE_DEVICE: {
- port->ext.device.hwModule = halPort.ext.device.hw_module;
- port->ext.device.type = AudioDevice(halPort.ext.device.type);
- memcpy(port->ext.device.address.data(),
- halPort.ext.device.address,
- AUDIO_DEVICE_MAX_ADDRESS_LEN);
- break;
- }
- case AUDIO_PORT_TYPE_MIX: {
- port->ext.mix.hwModule = halPort.ext.mix.hw_module;
- port->ext.mix.ioHandle = halPort.ext.mix.handle;
- port->ext.mix.latencyClass = AudioMixLatencyClass(halPort.ext.mix.latency_class);
- break;
- }
- case AUDIO_PORT_TYPE_SESSION: {
- port->ext.session.session = halPort.ext.session.session;
- break;
- }
- }
-}
-
-// static
-void Device::audioPortToHal(const AudioPort& port, struct audio_port* halPort) {
- memset(halPort, 0, sizeof(audio_port));
- halPort->id = port.id;
- halPort->role = static_cast<audio_port_role_t>(port.role);
- halPort->type = static_cast<audio_port_type_t>(port.type);
- memcpy(halPort->name,
- port.name.c_str(),
- std::min(port.name.size(), static_cast<size_t>(AUDIO_PORT_MAX_NAME_LEN)));
- halPort->num_sample_rates =
- std::min(port.sampleRates.size(), static_cast<size_t>(AUDIO_PORT_MAX_SAMPLING_RATES));
- for (size_t i = 0; i < halPort->num_sample_rates; ++i) {
- halPort->sample_rates[i] = port.sampleRates[i];
- }
- halPort->num_channel_masks =
- std::min(port.channelMasks.size(), static_cast<size_t>(AUDIO_PORT_MAX_CHANNEL_MASKS));
- for (size_t i = 0; i < halPort->num_channel_masks; ++i) {
- halPort->channel_masks[i] = static_cast<audio_channel_mask_t>(port.channelMasks[i]);
- }
- halPort->num_formats =
- std::min(port.formats.size(), static_cast<size_t>(AUDIO_PORT_MAX_FORMATS));
- for (size_t i = 0; i < halPort->num_formats; ++i) {
- halPort->formats[i] = static_cast<audio_format_t>(port.formats[i]);
- }
- halPort->num_gains = std::min(port.gains.size(), static_cast<size_t>(AUDIO_PORT_MAX_GAINS));
- for (size_t i = 0; i < halPort->num_gains; ++i) {
- audioGainToHal(port.gains[i], &halPort->gains[i]);
- }
- audioPortConfigToHal(port.activeConfig, &halPort->active_config);
- switch (port.type) {
- case AudioPortType::NONE: break;
- case AudioPortType::DEVICE: {
- halPort->ext.device.hw_module = port.ext.device.hwModule;
- halPort->ext.device.type = static_cast<audio_devices_t>(port.ext.device.type);
- memcpy(halPort->ext.device.address,
- port.ext.device.address.data(),
- AUDIO_DEVICE_MAX_ADDRESS_LEN);
- break;
- }
- case AudioPortType::MIX: {
- halPort->ext.mix.hw_module = port.ext.mix.hwModule;
- halPort->ext.mix.handle = port.ext.mix.ioHandle;
- halPort->ext.mix.latency_class =
- static_cast<audio_mix_latency_class_t>(port.ext.mix.latencyClass);
- break;
- }
- case AudioPortType::SESSION: {
- halPort->ext.session.session = static_cast<audio_session_t>(port.ext.session.session);
- break;
- }
- }
-}
-
Result Device::analyzeStatus(const char* funcName, int status) {
if (status != 0) {
ALOGW("Device %p %s: %s", mDevice, funcName, strerror(-status));
@@ -381,7 +122,7 @@
Return<void> Device::getInputBufferSize(
const AudioConfig& config, getInputBufferSize_cb _hidl_cb) {
audio_config_t halConfig;
- audioConfigToHal(config, &halConfig);
+ HidlUtils::audioConfigToHal(config, &halConfig);
size_t halBufferSize = mDevice->get_input_buffer_size(mDevice, &halConfig);
Result retval(Result::INVALID_ARGUMENTS);
uint64_t bufferSize = 0;
@@ -400,8 +141,14 @@
AudioOutputFlag flags,
openOutputStream_cb _hidl_cb) {
audio_config_t halConfig;
- audioConfigToHal(config, &halConfig);
+ HidlUtils::audioConfigToHal(config, &halConfig);
audio_stream_out_t *halStream;
+ ALOGV("open_output_stream handle: %d devices: %x flags: %#x "
+ "srate: %d format %#x channels %x address %s",
+ ioHandle,
+ static_cast<audio_devices_t>(device.device), static_cast<audio_output_flags_t>(flags),
+ halConfig.sample_rate, halConfig.format, halConfig.channel_mask,
+ deviceAddressToHal(device).c_str());
int status = mDevice->open_output_stream(
mDevice,
ioHandle,
@@ -410,11 +157,14 @@
&halConfig,
&halStream,
deviceAddressToHal(device).c_str());
+ ALOGV("open_output_stream status %d stream %p", status, halStream);
sp<IStreamOut> streamOut;
if (status == OK) {
streamOut = new StreamOut(mDevice, halStream);
}
- _hidl_cb(analyzeStatus("open_output_stream", status), streamOut);
+ AudioConfig suggestedConfig;
+ HidlUtils::audioConfigFromHal(halConfig, &suggestedConfig);
+ _hidl_cb(analyzeStatus("open_output_stream", status), streamOut, suggestedConfig);
return Void();
}
@@ -426,8 +176,14 @@
AudioSource source,
openInputStream_cb _hidl_cb) {
audio_config_t halConfig;
- audioConfigToHal(config, &halConfig);
+ HidlUtils::audioConfigToHal(config, &halConfig);
audio_stream_in_t *halStream;
+ ALOGV("open_input_stream handle: %d devices: %x flags: %#x "
+ "srate: %d format %#x channels %x address %s source %d",
+ ioHandle,
+ static_cast<audio_devices_t>(device.device), static_cast<audio_input_flags_t>(flags),
+ halConfig.sample_rate, halConfig.format, halConfig.channel_mask,
+ deviceAddressToHal(device).c_str(), static_cast<audio_source_t>(source));
int status = mDevice->open_input_stream(
mDevice,
ioHandle,
@@ -437,14 +193,21 @@
static_cast<audio_input_flags_t>(flags),
deviceAddressToHal(device).c_str(),
static_cast<audio_source_t>(source));
+ ALOGV("open_input_stream status %d stream %p", status, halStream);
sp<IStreamIn> streamIn;
if (status == OK) {
streamIn = new StreamIn(mDevice, halStream);
}
- _hidl_cb(analyzeStatus("open_input_stream", status), streamIn);
+ AudioConfig suggestedConfig;
+ HidlUtils::audioConfigFromHal(halConfig, &suggestedConfig);
+ _hidl_cb(analyzeStatus("open_input_stream", status), streamIn, suggestedConfig);
return Void();
}
+Return<bool> Device::supportsAudioPatches() {
+ return version() >= AUDIO_DEVICE_API_VERSION_3_0;
+}
+
Return<void> Device::createAudioPatch(
const hidl_vec<AudioPortConfig>& sources,
const hidl_vec<AudioPortConfig>& sinks,
@@ -452,8 +215,8 @@
Result retval(Result::NOT_SUPPORTED);
AudioPatchHandle patch = 0;
if (version() >= AUDIO_DEVICE_API_VERSION_3_0) {
- std::unique_ptr<audio_port_config[]> halSources(audioPortConfigsToHal(sources));
- std::unique_ptr<audio_port_config[]> halSinks(audioPortConfigsToHal(sinks));
+ std::unique_ptr<audio_port_config[]> halSources(HidlUtils::audioPortConfigsToHal(sources));
+ std::unique_ptr<audio_port_config[]> halSinks(HidlUtils::audioPortConfigsToHal(sinks));
audio_patch_handle_t halPatch;
retval = analyzeStatus(
"create_audio_patch",
@@ -481,11 +244,11 @@
Return<void> Device::getAudioPort(const AudioPort& port, getAudioPort_cb _hidl_cb) {
audio_port halPort;
- audioPortToHal(port, &halPort);
+ HidlUtils::audioPortToHal(port, &halPort);
Result retval = analyzeStatus("get_audio_port", mDevice->get_audio_port(mDevice, &halPort));
AudioPort resultPort = port;
if (retval == Result::OK) {
- audioPortFromHal(halPort, &resultPort);
+ HidlUtils::audioPortFromHal(halPort, &resultPort);
}
_hidl_cb(retval, resultPort);
return Void();
@@ -494,7 +257,7 @@
Return<Result> Device::setAudioPortConfig(const AudioPortConfig& config) {
if (version() >= AUDIO_DEVICE_API_VERSION_3_0) {
struct audio_port_config halPortConfig;
- audioPortConfigToHal(config, &halPortConfig);
+ HidlUtils::audioPortConfigToHal(config, &halPortConfig);
return analyzeStatus(
"set_audio_port_config", mDevice->set_audio_port_config(mDevice, &halPortConfig));
}
diff --git a/audio/2.0/default/Device.h b/audio/2.0/default/Device.h
index 49d6b2c..46177fc 100644
--- a/audio/2.0/default/Device.h
+++ b/audio/2.0/default/Device.h
@@ -36,22 +36,13 @@
namespace implementation {
using ::android::hardware::audio::common::V2_0::AudioConfig;
-using ::android::hardware::audio::common::V2_0::AudioGain;
-using ::android::hardware::audio::common::V2_0::AudioGainConfig;
-using ::android::hardware::audio::common::V2_0::AudioGainMode;
using ::android::hardware::audio::common::V2_0::AudioHwSync;
using ::android::hardware::audio::common::V2_0::AudioInputFlag;
-using ::android::hardware::audio::common::V2_0::AudioMixLatencyClass;
-using ::android::hardware::audio::common::V2_0::AudioOffloadInfo;
using ::android::hardware::audio::common::V2_0::AudioOutputFlag;
using ::android::hardware::audio::common::V2_0::AudioPatchHandle;
using ::android::hardware::audio::common::V2_0::AudioPort;
using ::android::hardware::audio::common::V2_0::AudioPortConfig;
-using ::android::hardware::audio::common::V2_0::AudioPortConfigMask;
-using ::android::hardware::audio::common::V2_0::AudioPortRole;
-using ::android::hardware::audio::common::V2_0::AudioPortType;
using ::android::hardware::audio::common::V2_0::AudioSource;
-using ::android::hardware::audio::common::V2_0::AudioStreamType;
using ::android::hardware::audio::V2_0::DeviceAddress;
using ::android::hardware::audio::V2_0::IDevice;
using ::android::hardware::audio::V2_0::IStreamIn;
@@ -90,6 +81,7 @@
AudioInputFlag flags,
AudioSource source,
openInputStream_cb _hidl_cb) override;
+ Return<bool> supportsAudioPatches() override;
Return<void> createAudioPatch(
const hidl_vec<AudioPortConfig>& sources,
const hidl_vec<AudioPortConfig>& sinks,
@@ -111,24 +103,6 @@
private:
audio_hw_device_t *mDevice;
- static void audioConfigToHal(const AudioConfig& config, audio_config_t* halConfig);
- static void audioGainConfigFromHal(
- const struct audio_gain_config& halConfig, AudioGainConfig* config);
- static void audioGainConfigToHal(
- const AudioGainConfig& config, struct audio_gain_config* halConfig);
- static void audioGainFromHal(const struct audio_gain& halGain, AudioGain* gain);
- static void audioGainToHal(const AudioGain& gain, struct audio_gain* halGain);
- static void audioOffloadInfoToHal(
- const AudioOffloadInfo& offload, audio_offload_info_t* halOffload);
- static void audioPortConfigFromHal(
- const struct audio_port_config& halConfig, AudioPortConfig* config);
- static void audioPortConfigToHal(
- const AudioPortConfig& config, struct audio_port_config* halConfig);
- static std::unique_ptr<audio_port_config[]> audioPortConfigsToHal(
- const hidl_vec<AudioPortConfig>& configs);
- static void audioPortFromHal(const struct audio_port& halPort, AudioPort* port);
- static void audioPortToHal(const AudioPort& port, struct audio_port* halPort);
-
virtual ~Device();
// Methods from ParametersUtil.
diff --git a/audio/2.0/default/DevicesFactory.cpp b/audio/2.0/default/DevicesFactory.cpp
index 1e087f2..12ef2c8 100644
--- a/audio/2.0/default/DevicesFactory.cpp
+++ b/audio/2.0/default/DevicesFactory.cpp
@@ -18,7 +18,7 @@
#include <string.h>
-#include <utils/Log.h>
+#include <android/log.h>
#include "Device.h"
#include "DevicesFactory.h"
diff --git a/audio/2.0/default/PrimaryDevice.cpp b/audio/2.0/default/PrimaryDevice.cpp
index a8aa5ec..905203b 100644
--- a/audio/2.0/default/PrimaryDevice.cpp
+++ b/audio/2.0/default/PrimaryDevice.cpp
@@ -83,6 +83,10 @@
return mDevice->openInputStream(ioHandle, device, config, flags, source, _hidl_cb);
}
+Return<bool> PrimaryDevice::supportsAudioPatches() {
+ return mDevice->supportsAudioPatches();
+}
+
Return<void> PrimaryDevice::createAudioPatch(
const hidl_vec<AudioPortConfig>& sources,
const hidl_vec<AudioPortConfig>& sinks,
diff --git a/audio/2.0/default/PrimaryDevice.h b/audio/2.0/default/PrimaryDevice.h
index 8177b68..d95511b 100644
--- a/audio/2.0/default/PrimaryDevice.h
+++ b/audio/2.0/default/PrimaryDevice.h
@@ -76,6 +76,7 @@
AudioInputFlag flags,
AudioSource source,
openInputStream_cb _hidl_cb) override;
+ Return<bool> supportsAudioPatches() override;
Return<void> createAudioPatch(
const hidl_vec<AudioPortConfig>& sources,
const hidl_vec<AudioPortConfig>& sinks,
diff --git a/audio/2.0/default/Stream.cpp b/audio/2.0/default/Stream.cpp
index 6d68f55..1b6d593 100644
--- a/audio/2.0/default/Stream.cpp
+++ b/audio/2.0/default/Stream.cpp
@@ -21,7 +21,7 @@
#include <hardware/audio.h>
#include <hardware/audio_effect.h>
#include <media/TypeConverter.h>
-#include <utils/Log.h>
+#include <android/log.h>
#include <utils/SortedVector.h>
#include <utils/Vector.h>
diff --git a/audio/2.0/default/StreamIn.cpp b/audio/2.0/default/StreamIn.cpp
index 791e519..1bc9dfb 100644
--- a/audio/2.0/default/StreamIn.cpp
+++ b/audio/2.0/default/StreamIn.cpp
@@ -17,7 +17,7 @@
#define LOG_TAG "StreamInHAL"
#include <hardware/audio.h>
-#include <utils/Log.h>
+#include <android/log.h>
#include "StreamIn.h"
diff --git a/audio/2.0/default/StreamOut.cpp b/audio/2.0/default/StreamOut.cpp
index 2106256..546b264 100644
--- a/audio/2.0/default/StreamOut.cpp
+++ b/audio/2.0/default/StreamOut.cpp
@@ -17,7 +17,7 @@
#define LOG_TAG "StreamOutHAL"
#include <hardware/audio.h>
-#include <utils/Log.h>
+#include <android/log.h>
#include "StreamOut.h"
@@ -191,23 +191,27 @@
return mStreamCommon->analyzeStatus("set_callback", result);
}
+Return<Result> StreamOut::clearCallback() {
+ if (mStream->set_callback == NULL) return Result::NOT_SUPPORTED;
+ mCallback.clear();
+ return Result::OK;
+}
+
// static
int StreamOut::asyncCallback(stream_callback_event_t event, void*, void *cookie) {
wp<StreamOut> weakSelf(reinterpret_cast<StreamOut*>(cookie));
sp<StreamOut> self = weakSelf.promote();
- if (self == 0) return 0;
- sp<IStreamOutCallback> callback = self->mCallback.promote();
- if (callback == 0) return 0;
+ if (self == nullptr || self->mCallback == nullptr) return 0;
ALOGV("asyncCallback() event %d", event);
switch (event) {
case STREAM_CBK_EVENT_WRITE_READY:
- callback->onWriteReady();
+ self->mCallback->onWriteReady();
break;
case STREAM_CBK_EVENT_DRAIN_READY:
- callback->onDrainReady();
+ self->mCallback->onDrainReady();
break;
case STREAM_CBK_EVENT_ERROR:
- callback->onError();
+ self->mCallback->onError();
break;
default:
ALOGW("asyncCallback() unknown event %d", event);
diff --git a/audio/2.0/default/StreamOut.h b/audio/2.0/default/StreamOut.h
index d51fc66..dc9a604 100644
--- a/audio/2.0/default/StreamOut.h
+++ b/audio/2.0/default/StreamOut.h
@@ -83,6 +83,7 @@
Return<void> getRenderPosition(getRenderPosition_cb _hidl_cb) override;
Return<void> getNextWriteTimestamp(getNextWriteTimestamp_cb _hidl_cb) override;
Return<Result> setCallback(const sp<IStreamOutCallback>& callback) override;
+ Return<Result> clearCallback() override;
Return<void> supportsPauseAndResume(supportsPauseAndResume_cb _hidl_cb) override;
Return<Result> pause() override;
Return<Result> resume() override;
@@ -95,9 +96,7 @@
audio_hw_device_t *mDevice;
audio_stream_out_t *mStream;
sp<Stream> mStreamCommon;
- // Do not store sp<> to avoid creating a reference loop if the entity that holds
- // onto the output stream owns or implements the callback.
- wp<IStreamOutCallback> mCallback;
+ sp<IStreamOutCallback> mCallback;
virtual ~StreamOut();
diff --git a/audio/common/2.0/default/Android.mk b/audio/common/2.0/default/Android.mk
index aa60eb2..8e2fed4 100644
--- a/audio/common/2.0/default/Android.mk
+++ b/audio/common/2.0/default/Android.mk
@@ -20,10 +20,13 @@
LOCAL_MODULE := android.hardware.audio.common@2.0-util
LOCAL_SRC_FILES := \
EffectMap.cpp \
+ HidlUtils.cpp \
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)
LOCAL_SHARED_LIBRARIES := \
libutils \
+ libhidlbase \
+ android.hardware.audio.common@2.0 \
include $(BUILD_SHARED_LIBRARY)
diff --git a/audio/common/2.0/default/HidlUtils.cpp b/audio/common/2.0/default/HidlUtils.cpp
new file mode 100644
index 0000000..f25fc5c
--- /dev/null
+++ b/audio/common/2.0/default/HidlUtils.cpp
@@ -0,0 +1,328 @@
+/*
+ * 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 <string.h>
+
+#include "HidlUtils.h"
+
+using ::android::hardware::audio::common::V2_0::AudioChannelMask;
+using ::android::hardware::audio::common::V2_0::AudioDevice;
+using ::android::hardware::audio::common::V2_0::AudioFormat;
+using ::android::hardware::audio::common::V2_0::AudioGainMode;
+using ::android::hardware::audio::common::V2_0::AudioMixLatencyClass;
+using ::android::hardware::audio::common::V2_0::AudioPortConfigMask;
+using ::android::hardware::audio::common::V2_0::AudioPortRole;
+using ::android::hardware::audio::common::V2_0::AudioPortType;
+using ::android::hardware::audio::common::V2_0::AudioSource;
+using ::android::hardware::audio::common::V2_0::AudioStreamType;
+
+namespace android {
+
+void HidlUtils::audioConfigFromHal(const audio_config_t& halConfig, AudioConfig* config) {
+ config->sampleRateHz = halConfig.sample_rate;
+ config->channelMask = AudioChannelMask(halConfig.channel_mask);
+ config->format = AudioFormat(halConfig.format);
+ audioOffloadInfoFromHal(halConfig.offload_info, &config->offloadInfo);
+ config->frameCount = halConfig.frame_count;
+}
+
+void HidlUtils::audioConfigToHal(const AudioConfig& config, audio_config_t* halConfig) {
+ memset(halConfig, 0, sizeof(audio_config_t));
+ halConfig->sample_rate = config.sampleRateHz;
+ halConfig->channel_mask = static_cast<audio_channel_mask_t>(config.channelMask);
+ halConfig->format = static_cast<audio_format_t>(config.format);
+ audioOffloadInfoToHal(config.offloadInfo, &halConfig->offload_info);
+ halConfig->frame_count = config.frameCount;
+}
+
+void HidlUtils::audioGainConfigFromHal(
+ const struct audio_gain_config& halConfig, AudioGainConfig* config) {
+ config->index = halConfig.index;
+ config->mode = AudioGainMode(halConfig.mode);
+ config->channelMask = AudioChannelMask(halConfig.channel_mask);
+ for (size_t i = 0; i < sizeof(audio_channel_mask_t) * 8; ++i) {
+ config->values[i] = halConfig.values[i];
+ }
+ config->rampDurationMs = halConfig.ramp_duration_ms;
+}
+
+void HidlUtils::audioGainConfigToHal(
+ const AudioGainConfig& config, struct audio_gain_config* halConfig) {
+ halConfig->index = config.index;
+ halConfig->mode = static_cast<audio_gain_mode_t>(config.mode);
+ halConfig->channel_mask = static_cast<audio_channel_mask_t>(config.channelMask);
+ memset(halConfig->values, 0, sizeof(halConfig->values));
+ for (size_t i = 0; i < sizeof(audio_channel_mask_t) * 8; ++i) {
+ halConfig->values[i] = config.values[i];
+ }
+ halConfig->ramp_duration_ms = config.rampDurationMs;
+}
+
+void HidlUtils::audioGainFromHal(const struct audio_gain& halGain, AudioGain* gain) {
+ gain->mode = AudioGainMode(halGain.mode);
+ gain->channelMask = AudioChannelMask(halGain.channel_mask);
+ gain->minValue = halGain.min_value;
+ gain->maxValue = halGain.max_value;
+ gain->defaultValue = halGain.default_value;
+ gain->stepValue = halGain.step_value;
+ gain->minRampMs = halGain.min_ramp_ms;
+ gain->maxRampMs = halGain.max_ramp_ms;
+}
+
+void HidlUtils::audioGainToHal(const AudioGain& gain, struct audio_gain* halGain) {
+ halGain->mode = static_cast<audio_gain_mode_t>(gain.mode);
+ halGain->channel_mask = static_cast<audio_channel_mask_t>(gain.channelMask);
+ halGain->min_value = gain.minValue;
+ halGain->max_value = gain.maxValue;
+ halGain->default_value = gain.defaultValue;
+ halGain->step_value = gain.stepValue;
+ halGain->min_ramp_ms = gain.minRampMs;
+ halGain->max_ramp_ms = gain.maxRampMs;
+}
+
+void HidlUtils::audioOffloadInfoFromHal(
+ const audio_offload_info_t& halOffload, AudioOffloadInfo* offload) {
+ offload->sampleRateHz = halOffload.sample_rate;
+ offload->channelMask = AudioChannelMask(halOffload.channel_mask);
+ offload->streamType = AudioStreamType(halOffload.stream_type);
+ offload->bitRatePerSecond = halOffload.bit_rate;
+ offload->durationMicroseconds = halOffload.duration_us;
+ offload->hasVideo = halOffload.has_video;
+ offload->isStreaming = halOffload.is_streaming;
+}
+
+void HidlUtils::audioOffloadInfoToHal(
+ const AudioOffloadInfo& offload, audio_offload_info_t* halOffload) {
+ *halOffload = AUDIO_INFO_INITIALIZER;
+ halOffload->sample_rate = offload.sampleRateHz;
+ halOffload->channel_mask = static_cast<audio_channel_mask_t>(offload.channelMask);
+ halOffload->stream_type = static_cast<audio_stream_type_t>(offload.streamType);
+ halOffload->bit_rate = offload.bitRatePerSecond;
+ halOffload->duration_us = offload.durationMicroseconds;
+ halOffload->has_video = offload.hasVideo;
+ halOffload->is_streaming = offload.isStreaming;
+}
+
+void HidlUtils::audioPortConfigFromHal(
+ const struct audio_port_config& halConfig, AudioPortConfig* config) {
+ config->id = halConfig.id;
+ config->role = AudioPortRole(halConfig.role);
+ config->type = AudioPortType(halConfig.type);
+ config->configMask = AudioPortConfigMask(halConfig.config_mask);
+ config->sampleRateHz = halConfig.sample_rate;
+ config->channelMask = AudioChannelMask(halConfig.channel_mask);
+ config->format = AudioFormat(halConfig.format);
+ audioGainConfigFromHal(halConfig.gain, &config->gain);
+ switch (halConfig.type) {
+ case AUDIO_PORT_TYPE_NONE: break;
+ case AUDIO_PORT_TYPE_DEVICE: {
+ config->ext.device.hwModule = halConfig.ext.device.hw_module;
+ config->ext.device.type = AudioDevice(halConfig.ext.device.type);
+ memcpy(config->ext.device.address.data(),
+ halConfig.ext.device.address,
+ AUDIO_DEVICE_MAX_ADDRESS_LEN);
+ break;
+ }
+ case AUDIO_PORT_TYPE_MIX: {
+ config->ext.mix.hwModule = halConfig.ext.mix.hw_module;
+ config->ext.mix.ioHandle = halConfig.ext.mix.handle;
+ if (halConfig.role == AUDIO_PORT_ROLE_SOURCE) {
+ config->ext.mix.useCase.source = AudioSource(halConfig.ext.mix.usecase.source);
+ } else if (halConfig.role == AUDIO_PORT_ROLE_SINK) {
+ config->ext.mix.useCase.stream = AudioStreamType(halConfig.ext.mix.usecase.stream);
+ }
+ break;
+ }
+ case AUDIO_PORT_TYPE_SESSION: {
+ config->ext.session.session = halConfig.ext.session.session;
+ break;
+ }
+ }
+}
+
+void HidlUtils::audioPortConfigToHal(
+ const AudioPortConfig& config, struct audio_port_config* halConfig) {
+ memset(halConfig, 0, sizeof(audio_port_config));
+ halConfig->id = config.id;
+ halConfig->role = static_cast<audio_port_role_t>(config.role);
+ halConfig->type = static_cast<audio_port_type_t>(config.type);
+ halConfig->config_mask = static_cast<unsigned int>(config.configMask);
+ halConfig->sample_rate = config.sampleRateHz;
+ halConfig->channel_mask = static_cast<audio_channel_mask_t>(config.channelMask);
+ halConfig->format = static_cast<audio_format_t>(config.format);
+ audioGainConfigToHal(config.gain, &halConfig->gain);
+ switch (config.type) {
+ case AudioPortType::NONE: break;
+ case AudioPortType::DEVICE: {
+ halConfig->ext.device.hw_module = config.ext.device.hwModule;
+ halConfig->ext.device.type = static_cast<audio_devices_t>(config.ext.device.type);
+ memcpy(halConfig->ext.device.address,
+ config.ext.device.address.data(),
+ AUDIO_DEVICE_MAX_ADDRESS_LEN);
+ break;
+ }
+ case AudioPortType::MIX: {
+ halConfig->ext.mix.hw_module = config.ext.mix.hwModule;
+ halConfig->ext.mix.handle = config.ext.mix.ioHandle;
+ if (config.role == AudioPortRole::SOURCE) {
+ halConfig->ext.mix.usecase.source =
+ static_cast<audio_source_t>(config.ext.mix.useCase.source);
+ } else if (config.role == AudioPortRole::SINK) {
+ halConfig->ext.mix.usecase.stream =
+ static_cast<audio_stream_type_t>(config.ext.mix.useCase.stream);
+ }
+ break;
+ }
+ case AudioPortType::SESSION: {
+ halConfig->ext.session.session =
+ static_cast<audio_session_t>(config.ext.session.session);
+ break;
+ }
+ }
+}
+
+void HidlUtils::audioPortConfigsFromHal(
+ unsigned int numHalConfigs, const struct audio_port_config *halConfigs,
+ hidl_vec<AudioPortConfig> *configs) {
+ configs->resize(numHalConfigs);
+ for (unsigned int i = 0; i < numHalConfigs; ++i) {
+ audioPortConfigFromHal(halConfigs[i], &(*configs)[i]);
+ }
+}
+
+std::unique_ptr<audio_port_config[]> HidlUtils::audioPortConfigsToHal(
+ const hidl_vec<AudioPortConfig>& configs) {
+ std::unique_ptr<audio_port_config[]> halConfigs(new audio_port_config[configs.size()]);
+ for (size_t i = 0; i < configs.size(); ++i) {
+ audioPortConfigToHal(configs[i], &halConfigs[i]);
+ }
+ return halConfigs;
+}
+
+void HidlUtils::audioPortFromHal(const struct audio_port& halPort, AudioPort* port) {
+ port->id = halPort.id;
+ port->role = AudioPortRole(halPort.role);
+ port->type = AudioPortType(halPort.type);
+ port->name.setToExternal(halPort.name, strlen(halPort.name));
+ port->sampleRates.resize(halPort.num_sample_rates);
+ for (size_t i = 0; i < halPort.num_sample_rates; ++i) {
+ port->sampleRates[i] = halPort.sample_rates[i];
+ }
+ port->channelMasks.resize(halPort.num_channel_masks);
+ for (size_t i = 0; i < halPort.num_channel_masks; ++i) {
+ port->channelMasks[i] = AudioChannelMask(halPort.channel_masks[i]);
+ }
+ port->formats.resize(halPort.num_formats);
+ for (size_t i = 0; i < halPort.num_formats; ++i) {
+ port->formats[i] = AudioFormat(halPort.formats[i]);
+ }
+ port->gains.resize(halPort.num_gains);
+ for (size_t i = 0; i < halPort.num_gains; ++i) {
+ audioGainFromHal(halPort.gains[i], &port->gains[i]);
+ }
+ audioPortConfigFromHal(halPort.active_config, &port->activeConfig);
+ switch (halPort.type) {
+ case AUDIO_PORT_TYPE_NONE: break;
+ case AUDIO_PORT_TYPE_DEVICE: {
+ port->ext.device.hwModule = halPort.ext.device.hw_module;
+ port->ext.device.type = AudioDevice(halPort.ext.device.type);
+ memcpy(port->ext.device.address.data(),
+ halPort.ext.device.address,
+ AUDIO_DEVICE_MAX_ADDRESS_LEN);
+ break;
+ }
+ case AUDIO_PORT_TYPE_MIX: {
+ port->ext.mix.hwModule = halPort.ext.mix.hw_module;
+ port->ext.mix.ioHandle = halPort.ext.mix.handle;
+ port->ext.mix.latencyClass = AudioMixLatencyClass(halPort.ext.mix.latency_class);
+ break;
+ }
+ case AUDIO_PORT_TYPE_SESSION: {
+ port->ext.session.session = halPort.ext.session.session;
+ break;
+ }
+ }
+}
+
+void HidlUtils::audioPortToHal(const AudioPort& port, struct audio_port* halPort) {
+ memset(halPort, 0, sizeof(audio_port));
+ halPort->id = port.id;
+ halPort->role = static_cast<audio_port_role_t>(port.role);
+ halPort->type = static_cast<audio_port_type_t>(port.type);
+ memcpy(halPort->name,
+ port.name.c_str(),
+ std::min(port.name.size(), static_cast<size_t>(AUDIO_PORT_MAX_NAME_LEN)));
+ halPort->num_sample_rates =
+ std::min(port.sampleRates.size(), static_cast<size_t>(AUDIO_PORT_MAX_SAMPLING_RATES));
+ for (size_t i = 0; i < halPort->num_sample_rates; ++i) {
+ halPort->sample_rates[i] = port.sampleRates[i];
+ }
+ halPort->num_channel_masks =
+ std::min(port.channelMasks.size(), static_cast<size_t>(AUDIO_PORT_MAX_CHANNEL_MASKS));
+ for (size_t i = 0; i < halPort->num_channel_masks; ++i) {
+ halPort->channel_masks[i] = static_cast<audio_channel_mask_t>(port.channelMasks[i]);
+ }
+ halPort->num_formats =
+ std::min(port.formats.size(), static_cast<size_t>(AUDIO_PORT_MAX_FORMATS));
+ for (size_t i = 0; i < halPort->num_formats; ++i) {
+ halPort->formats[i] = static_cast<audio_format_t>(port.formats[i]);
+ }
+ halPort->num_gains = std::min(port.gains.size(), static_cast<size_t>(AUDIO_PORT_MAX_GAINS));
+ for (size_t i = 0; i < halPort->num_gains; ++i) {
+ audioGainToHal(port.gains[i], &halPort->gains[i]);
+ }
+ audioPortConfigToHal(port.activeConfig, &halPort->active_config);
+ switch (port.type) {
+ case AudioPortType::NONE: break;
+ case AudioPortType::DEVICE: {
+ halPort->ext.device.hw_module = port.ext.device.hwModule;
+ halPort->ext.device.type = static_cast<audio_devices_t>(port.ext.device.type);
+ memcpy(halPort->ext.device.address,
+ port.ext.device.address.data(),
+ AUDIO_DEVICE_MAX_ADDRESS_LEN);
+ break;
+ }
+ case AudioPortType::MIX: {
+ halPort->ext.mix.hw_module = port.ext.mix.hwModule;
+ halPort->ext.mix.handle = port.ext.mix.ioHandle;
+ halPort->ext.mix.latency_class =
+ static_cast<audio_mix_latency_class_t>(port.ext.mix.latencyClass);
+ break;
+ }
+ case AudioPortType::SESSION: {
+ halPort->ext.session.session = static_cast<audio_session_t>(port.ext.session.session);
+ break;
+ }
+ }
+}
+
+void HidlUtils::uuidFromHal(const audio_uuid_t& halUuid, Uuid* uuid) {
+ uuid->timeLow = halUuid.timeLow;
+ uuid->timeMid = halUuid.timeMid;
+ uuid->versionAndTimeHigh = halUuid.timeHiAndVersion;
+ uuid->variantAndClockSeqHigh = halUuid.clockSeq;
+ memcpy(uuid->node.data(), halUuid.node, uuid->node.size());
+}
+
+void HidlUtils::uuidToHal(const Uuid& uuid, audio_uuid_t* halUuid) {
+ halUuid->timeLow = uuid.timeLow;
+ halUuid->timeMid = uuid.timeMid;
+ halUuid->timeHiAndVersion = uuid.versionAndTimeHigh;
+ halUuid->clockSeq = uuid.variantAndClockSeqHigh;
+ memcpy(halUuid->node, uuid.node.data(), uuid.node.size());
+}
+
+} // namespace android
diff --git a/audio/common/2.0/default/HidlUtils.h b/audio/common/2.0/default/HidlUtils.h
new file mode 100644
index 0000000..3fde4d7
--- /dev/null
+++ b/audio/common/2.0/default/HidlUtils.h
@@ -0,0 +1,67 @@
+/*
+ * 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 android_hardware_audio_V2_0_Hidl_Utils_H_
+#define android_hardware_audio_V2_0_Hidl_Utils_H_
+
+#include <memory>
+
+#include <android/hardware/audio/common/2.0/types.h>
+#include <system/audio.h>
+
+using ::android::hardware::audio::common::V2_0::AudioConfig;
+using ::android::hardware::audio::common::V2_0::AudioGain;
+using ::android::hardware::audio::common::V2_0::AudioGainConfig;
+using ::android::hardware::audio::common::V2_0::AudioOffloadInfo;
+using ::android::hardware::audio::common::V2_0::AudioPort;
+using ::android::hardware::audio::common::V2_0::AudioPortConfig;
+using ::android::hardware::audio::common::V2_0::Uuid;
+using ::android::hardware::hidl_vec;
+
+namespace android {
+
+class HidlUtils {
+ public:
+ static void audioConfigFromHal(const audio_config_t& halConfig, AudioConfig* config);
+ static void audioConfigToHal(const AudioConfig& config, audio_config_t* halConfig);
+ static void audioGainConfigFromHal(
+ const struct audio_gain_config& halConfig, AudioGainConfig* config);
+ static void audioGainConfigToHal(
+ const AudioGainConfig& config, struct audio_gain_config* halConfig);
+ static void audioGainFromHal(const struct audio_gain& halGain, AudioGain* gain);
+ static void audioGainToHal(const AudioGain& gain, struct audio_gain* halGain);
+ static void audioOffloadInfoFromHal(
+ const audio_offload_info_t& halOffload, AudioOffloadInfo* offload);
+ static void audioOffloadInfoToHal(
+ const AudioOffloadInfo& offload, audio_offload_info_t* halOffload);
+ static void audioPortConfigFromHal(
+ const struct audio_port_config& halConfig, AudioPortConfig* config);
+ static void audioPortConfigToHal(
+ const AudioPortConfig& config, struct audio_port_config* halConfig);
+ static void audioPortConfigsFromHal(
+ unsigned int numHalConfigs, const struct audio_port_config *halConfigs,
+ hidl_vec<AudioPortConfig> *configs);
+ static std::unique_ptr<audio_port_config[]> audioPortConfigsToHal(
+ const hidl_vec<AudioPortConfig>& configs);
+ static void audioPortFromHal(const struct audio_port& halPort, AudioPort* port);
+ static void audioPortToHal(const AudioPort& port, struct audio_port* halPort);
+ static void uuidFromHal(const audio_uuid_t& halUuid, Uuid* uuid);
+ static void uuidToHal(const Uuid& uuid, audio_uuid_t* halUuid);
+};
+
+} // namespace android
+
+#endif // android_hardware_audio_V2_0_Hidl_Utils_H_
diff --git a/audio/effect/2.0/default/AcousticEchoCancelerEffect.cpp b/audio/effect/2.0/default/AcousticEchoCancelerEffect.cpp
index c2f50f9..341466f 100644
--- a/audio/effect/2.0/default/AcousticEchoCancelerEffect.cpp
+++ b/audio/effect/2.0/default/AcousticEchoCancelerEffect.cpp
@@ -16,7 +16,7 @@
#define LOG_TAG "AEC_Effect_HAL"
#include <system/audio_effects/effect_aec.h>
-#include <utils/Log.h>
+#include <android/log.h>
#include "AcousticEchoCancelerEffect.h"
diff --git a/audio/effect/2.0/default/AutomaticGainControlEffect.cpp b/audio/effect/2.0/default/AutomaticGainControlEffect.cpp
index 34cbe97..6ebfb3c 100644
--- a/audio/effect/2.0/default/AutomaticGainControlEffect.cpp
+++ b/audio/effect/2.0/default/AutomaticGainControlEffect.cpp
@@ -15,7 +15,7 @@
*/
#define LOG_TAG "AGC_Effect_HAL"
-#include <utils/Log.h>
+#include <android/log.h>
#include "AutomaticGainControlEffect.h"
diff --git a/audio/effect/2.0/default/BassBoostEffect.cpp b/audio/effect/2.0/default/BassBoostEffect.cpp
index 1b12f76..8a64806 100644
--- a/audio/effect/2.0/default/BassBoostEffect.cpp
+++ b/audio/effect/2.0/default/BassBoostEffect.cpp
@@ -16,7 +16,7 @@
#define LOG_TAG "BassBoost_HAL"
#include <system/audio_effects/effect_bassboost.h>
-#include <utils/Log.h>
+#include <android/log.h>
#include "BassBoostEffect.h"
diff --git a/audio/effect/2.0/default/Conversions.cpp b/audio/effect/2.0/default/Conversions.cpp
index ef2374c..e7d4c46 100644
--- a/audio/effect/2.0/default/Conversions.cpp
+++ b/audio/effect/2.0/default/Conversions.cpp
@@ -18,6 +18,7 @@
#include <stdio.h>
#include "Conversions.h"
+#include "HidlUtils.h"
namespace android {
namespace hardware {
@@ -28,8 +29,8 @@
void effectDescriptorFromHal(
const effect_descriptor_t& halDescriptor, EffectDescriptor* descriptor) {
- uuidFromHal(halDescriptor.type, &descriptor->type);
- uuidFromHal(halDescriptor.uuid, &descriptor->uuid);
+ HidlUtils::uuidFromHal(halDescriptor.type, &descriptor->type);
+ HidlUtils::uuidFromHal(halDescriptor.uuid, &descriptor->uuid);
descriptor->flags = EffectFlags(halDescriptor.flags);
descriptor->cpuLoad = halDescriptor.cpuLoad;
descriptor->memoryUsage = halDescriptor.memoryUsage;
@@ -38,22 +39,6 @@
halDescriptor.implementor, descriptor->implementor.size());
}
-void uuidFromHal(const effect_uuid_t& halUuid, Uuid* uuid) {
- uuid->timeLow = halUuid.timeLow;
- uuid->timeMid = halUuid.timeMid;
- uuid->versionAndTimeHigh = halUuid.timeHiAndVersion;
- uuid->variantAndClockSeqHigh = halUuid.clockSeq;
- memcpy(uuid->node.data(), halUuid.node, uuid->node.size());
-}
-
-void uuidToHal(const Uuid& uuid, effect_uuid_t* halUuid) {
- halUuid->timeLow = uuid.timeLow;
- halUuid->timeMid = uuid.timeMid;
- halUuid->timeHiAndVersion = uuid.versionAndTimeHigh;
- halUuid->clockSeq = uuid.variantAndClockSeqHigh;
- memcpy(halUuid->node, uuid.node.data(), uuid.node.size());
-}
-
std::string uuidToString(const effect_uuid_t& halUuid) {
char str[64];
snprintf(str, sizeof(str), "%08x-%04x-%04x-%04x-%02x%02x%02x%02x%02x%02x",
diff --git a/audio/effect/2.0/default/Conversions.h b/audio/effect/2.0/default/Conversions.h
index 5348ae6..7cef362 100644
--- a/audio/effect/2.0/default/Conversions.h
+++ b/audio/effect/2.0/default/Conversions.h
@@ -29,13 +29,10 @@
namespace V2_0 {
namespace implementation {
-using ::android::hardware::audio::common::V2_0::Uuid;
using ::android::hardware::audio::effect::V2_0::EffectDescriptor;
void effectDescriptorFromHal(
const effect_descriptor_t& halDescriptor, EffectDescriptor* descriptor);
-void uuidFromHal(const effect_uuid_t& halUuid, Uuid* uuid);
-void uuidToHal(const Uuid& uuid, effect_uuid_t* halUuid);
std::string uuidToString(const effect_uuid_t& halUuid);
} // namespace implementation
diff --git a/audio/effect/2.0/default/DownmixEffect.cpp b/audio/effect/2.0/default/DownmixEffect.cpp
index 4c0a0bf..40bb5ec 100644
--- a/audio/effect/2.0/default/DownmixEffect.cpp
+++ b/audio/effect/2.0/default/DownmixEffect.cpp
@@ -16,7 +16,7 @@
#define LOG_TAG "Downmix_HAL"
#include <system/audio_effects/effect_downmix.h>
-#include <utils/Log.h>
+#include <android/log.h>
#include "DownmixEffect.h"
diff --git a/audio/effect/2.0/default/Effect.cpp b/audio/effect/2.0/default/Effect.cpp
index 82d0292..1a7ea9c 100644
--- a/audio/effect/2.0/default/Effect.cpp
+++ b/audio/effect/2.0/default/Effect.cpp
@@ -14,12 +14,11 @@
* limitations under the License.
*/
-#include <memory>
#include <memory.h>
#define LOG_TAG "EffectHAL"
#include <media/EffectsFactoryApi.h>
-#include <utils/Log.h>
+#include <android/log.h>
#include "Conversions.h"
#include "Effect.h"
@@ -56,10 +55,15 @@
}
// static
-template<typename T> void Effect::hidlVecToHal(
- const hidl_vec<T>& vec, uint32_t* halDataSize, void** halData) {
- *halDataSize = static_cast<T>(vec.size() * sizeof(T));
- *halData = static_cast<void*>(const_cast<T*>(&vec[0]));
+template<typename T> std::unique_ptr<uint8_t[]> Effect::hidlVecToHal(
+ const hidl_vec<T>& vec, uint32_t* halDataSize) {
+ // Due to bugs in HAL, they may attempt to write into the provided
+ // input buffer. The original binder buffer is r/o, thus it is needed
+ // to create a r/w version.
+ *halDataSize = vec.size() * sizeof(T);
+ std::unique_ptr<uint8_t[]> halData(new uint8_t[*halDataSize]);
+ memcpy(&halData[0], &vec[0], *halDataSize);
+ return halData;
}
// static
@@ -393,12 +397,13 @@
Return<void> Effect::setAndGetVolume(
const hidl_vec<uint32_t>& volumes, setAndGetVolume_cb _hidl_cb) {
uint32_t halDataSize;
- void *halData;
- hidlVecToHal(volumes, &halDataSize, &halData);
+ std::unique_ptr<uint8_t[]> halData = hidlVecToHal(volumes, &halDataSize);
uint32_t halResultSize = halDataSize;
uint32_t halResult[volumes.size()];
Result retval = sendCommandReturningData(
- EFFECT_CMD_SET_VOLUME, "SET_VOLUME", halDataSize, halData, &halResultSize, halResult);
+ EFFECT_CMD_SET_VOLUME, "SET_VOLUME",
+ halDataSize, &halData[0],
+ &halResultSize, halResult);
hidl_vec<uint32_t> result;
if (retval == Result::OK) {
result.setToExternal(&halResult[0], halResultSize);
@@ -528,13 +533,12 @@
uint32_t resultMaxSize,
command_cb _hidl_cb) {
uint32_t halDataSize;
- void *halData;
- hidlVecToHal(data, &halDataSize, &halData);
+ std::unique_ptr<uint8_t[]> halData = hidlVecToHal(data, &halDataSize);
uint32_t halResultSize = resultMaxSize;
std::unique_ptr<uint8_t[]> halResult(new uint8_t[halResultSize]);
memset(&halResult[0], 0, halResultSize);
status_t status = (*mHandle)->command(
- mHandle, commandId, halDataSize, halData, &halResultSize, &halResult[0]);
+ mHandle, commandId, halDataSize, &halData[0], &halResultSize, &halResult[0]);
hidl_vec<uint8_t> result;
if (status == OK) {
result.setToExternal(&halResult[0], halResultSize);
diff --git a/audio/effect/2.0/default/Effect.h b/audio/effect/2.0/default/Effect.h
index 82eb1f2..61d0121 100644
--- a/audio/effect/2.0/default/Effect.h
+++ b/audio/effect/2.0/default/Effect.h
@@ -17,6 +17,7 @@
#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_EFFECT_H
#define ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_EFFECT_H
+#include <memory>
#include <vector>
#include <android/hardware/audio/effect/2.0/IEffect.h>
@@ -180,8 +181,8 @@
virtual ~Effect();
template<typename T> static size_t alignedSizeIn(size_t s);
- template<typename T> static void hidlVecToHal(
- const hidl_vec<T>& vec, uint32_t* halDataSize, void** halData);
+ template<typename T> std::unique_ptr<uint8_t[]> hidlVecToHal(
+ const hidl_vec<T>& vec, uint32_t* halDataSize);
static void effectAuxChannelsConfigFromHal(
const channel_config_t& halConfig, EffectAuxChannelsConfig* config);
static void effectAuxChannelsConfigToHal(
diff --git a/audio/effect/2.0/default/EffectsFactory.cpp b/audio/effect/2.0/default/EffectsFactory.cpp
index 2b5d70b..572a428 100644
--- a/audio/effect/2.0/default/EffectsFactory.cpp
+++ b/audio/effect/2.0/default/EffectsFactory.cpp
@@ -27,14 +27,15 @@
#include <system/audio_effects/effect_presetreverb.h>
#include <system/audio_effects/effect_virtualizer.h>
#include <system/audio_effects/effect_visualizer.h>
-#include <utils/Log.h>
+#include <android/log.h>
#include "AcousticEchoCancelerEffect.h"
#include "AutomaticGainControlEffect.h"
#include "BassBoostEffect.h"
#include "Conversions.h"
-#include "EffectsFactory.h"
#include "DownmixEffect.h"
+#include "EffectsFactory.h"
+#include "HidlUtils.h"
#include "Effect.h"
#include "EffectMap.h"
#include "EnvironmentalReverbEffect.h"
@@ -131,7 +132,7 @@
Return<void> EffectsFactory::getDescriptor(const Uuid& uid, getDescriptor_cb _hidl_cb) {
effect_uuid_t halUuid;
- uuidToHal(uid, &halUuid);
+ HidlUtils::uuidToHal(uid, &halUuid);
effect_descriptor_t halDescriptor;
status_t status = EffectGetDescriptor(&halUuid, &halDescriptor);
EffectDescriptor descriptor;
@@ -153,7 +154,7 @@
Return<void> EffectsFactory::createEffect(
const Uuid& uid, int32_t session, int32_t ioHandle, createEffect_cb _hidl_cb) {
effect_uuid_t halUuid;
- uuidToHal(uid, &halUuid);
+ HidlUtils::uuidToHal(uid, &halUuid);
effect_handle_t handle;
Result retval(Result::OK);
status_t status = EffectCreate(&halUuid, session, ioHandle, &handle);
diff --git a/audio/effect/2.0/default/EnvironmentalReverbEffect.cpp b/audio/effect/2.0/default/EnvironmentalReverbEffect.cpp
index 4485be4..db1ad51 100644
--- a/audio/effect/2.0/default/EnvironmentalReverbEffect.cpp
+++ b/audio/effect/2.0/default/EnvironmentalReverbEffect.cpp
@@ -15,7 +15,7 @@
*/
#define LOG_TAG "EnvReverb_HAL"
-#include <utils/Log.h>
+#include <android/log.h>
#include "EnvironmentalReverbEffect.h"
diff --git a/audio/effect/2.0/default/EqualizerEffect.cpp b/audio/effect/2.0/default/EqualizerEffect.cpp
index 9e20b8a..490a300 100644
--- a/audio/effect/2.0/default/EqualizerEffect.cpp
+++ b/audio/effect/2.0/default/EqualizerEffect.cpp
@@ -17,7 +17,7 @@
#include <memory.h>
#define LOG_TAG "Equalizer_HAL"
-#include <utils/Log.h>
+#include <android/log.h>
#include "EqualizerEffect.h"
diff --git a/audio/effect/2.0/default/LoudnessEnhancerEffect.cpp b/audio/effect/2.0/default/LoudnessEnhancerEffect.cpp
index 1e724e0..a49019c 100644
--- a/audio/effect/2.0/default/LoudnessEnhancerEffect.cpp
+++ b/audio/effect/2.0/default/LoudnessEnhancerEffect.cpp
@@ -18,7 +18,7 @@
#define LOG_TAG "LoudnessEnhancer_HAL"
#include <system/audio_effects/effect_aec.h>
-#include <utils/Log.h>
+#include <android/log.h>
#include "LoudnessEnhancerEffect.h"
diff --git a/audio/effect/2.0/default/NoiseSuppressionEffect.cpp b/audio/effect/2.0/default/NoiseSuppressionEffect.cpp
index 5c392df..69a1226 100644
--- a/audio/effect/2.0/default/NoiseSuppressionEffect.cpp
+++ b/audio/effect/2.0/default/NoiseSuppressionEffect.cpp
@@ -15,7 +15,7 @@
*/
#define LOG_TAG "NS_Effect_HAL"
-#include <utils/Log.h>
+#include <android/log.h>
#include "NoiseSuppressionEffect.h"
diff --git a/audio/effect/2.0/default/PresetReverbEffect.cpp b/audio/effect/2.0/default/PresetReverbEffect.cpp
index 988bc51..0e6d1b8 100644
--- a/audio/effect/2.0/default/PresetReverbEffect.cpp
+++ b/audio/effect/2.0/default/PresetReverbEffect.cpp
@@ -16,7 +16,7 @@
#define LOG_TAG "PresetReverb_HAL"
#include <system/audio_effects/effect_presetreverb.h>
-#include <utils/Log.h>
+#include <android/log.h>
#include "PresetReverbEffect.h"
diff --git a/audio/effect/2.0/default/VirtualizerEffect.cpp b/audio/effect/2.0/default/VirtualizerEffect.cpp
index af5252b..313674d 100644
--- a/audio/effect/2.0/default/VirtualizerEffect.cpp
+++ b/audio/effect/2.0/default/VirtualizerEffect.cpp
@@ -18,7 +18,7 @@
#define LOG_TAG "Virtualizer_HAL"
#include <system/audio_effects/effect_virtualizer.h>
-#include <utils/Log.h>
+#include <android/log.h>
#include "VirtualizerEffect.h"
diff --git a/audio/effect/2.0/default/VisualizerEffect.cpp b/audio/effect/2.0/default/VisualizerEffect.cpp
index a1f92a6..a53eabc 100644
--- a/audio/effect/2.0/default/VisualizerEffect.cpp
+++ b/audio/effect/2.0/default/VisualizerEffect.cpp
@@ -16,7 +16,7 @@
#define LOG_TAG "Visualizer_HAL"
#include <system/audio_effects/effect_visualizer.h>
-#include <utils/Log.h>
+#include <android/log.h>
#include "VisualizerEffect.h"
diff --git a/audio/effect/2.0/vts/functional/audio_effect_hidl_hal_test.cpp b/audio/effect/2.0/vts/functional/audio_effect_hidl_hal_test.cpp
index c7878d5..ef70215 100644
--- a/audio/effect/2.0/vts/functional/audio_effect_hidl_hal_test.cpp
+++ b/audio/effect/2.0/vts/functional/audio_effect_hidl_hal_test.cpp
@@ -164,6 +164,6 @@
::testing::AddGlobalTestEnvironment(new AudioEffectHidlEnvironment);
::testing::InitGoogleTest(&argc, argv);
int status = RUN_ALL_TESTS();
- ALOGI("Test result = %d", status);
+ LOG(INFO) << "Test result = " << status;
return status;
}
diff --git a/biometrics/fingerprint/2.1/default/BiometricsFingerprint.h b/biometrics/fingerprint/2.1/default/BiometricsFingerprint.h
index de8727b..0a8a22c 100644
--- a/biometrics/fingerprint/2.1/default/BiometricsFingerprint.h
+++ b/biometrics/fingerprint/2.1/default/BiometricsFingerprint.h
@@ -17,7 +17,7 @@
#ifndef ANDROID_HARDWARE_BIOMETRICS_FINGERPRINT_V2_1_BIOMETRICSFINGERPRINT_H
#define ANDROID_HARDWARE_BIOMETRICS_FINGERPRINT_V2_1_BIOMETRICSFINGERPRINT_H
-#include <utils/Log.h>
+#include <android/log.h>
#include <hidl/MQDescriptor.h>
#include <android/hardware/biometrics/fingerprint/2.1/IBiometricsFingerprint.h>
#include <hidl/Status.h>
diff --git a/boot/1.0/default/BootControl.cpp b/boot/1.0/default/BootControl.cpp
index 56d7b33..54c1928 100644
--- a/boot/1.0/default/BootControl.cpp
+++ b/boot/1.0/default/BootControl.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
#define LOG_TAG "android.hardware.boot@1.0-impl"
-#include <utils/Log.h>
+#include <android/log.h>
#include <hardware/hardware.h>
#include <hardware/boot_control.h>
diff --git a/broadcastradio/1.0/default/BroadcastRadio.cpp b/broadcastradio/1.0/default/BroadcastRadio.cpp
index b97b609..32331ce 100644
--- a/broadcastradio/1.0/default/BroadcastRadio.cpp
+++ b/broadcastradio/1.0/default/BroadcastRadio.cpp
@@ -16,7 +16,7 @@
#define LOG_TAG "BroadcastRadio"
//#define LOG_NDEBUG 0
-#include <utils/Log.h>
+#include <android/log.h>
#include <hardware/radio.h>
#include "BroadcastRadio.h"
diff --git a/broadcastradio/1.0/default/Tuner.cpp b/broadcastradio/1.0/default/Tuner.cpp
index 0c1d8ab..27b298b 100644
--- a/broadcastradio/1.0/default/Tuner.cpp
+++ b/broadcastradio/1.0/default/Tuner.cpp
@@ -17,7 +17,7 @@
#define LOG_TAG "Tuner"
//#define LOG_NDEBUG 0
-#include <utils/Log.h>
+#include <android/log.h>
#include "BroadcastRadio.h"
#include "Tuner.h"
diff --git a/broadcastradio/1.0/default/Utils.cpp b/broadcastradio/1.0/default/Utils.cpp
index bdaae00..c2c2ff3 100644
--- a/broadcastradio/1.0/default/Utils.cpp
+++ b/broadcastradio/1.0/default/Utils.cpp
@@ -16,7 +16,7 @@
#define LOG_TAG "BroadcastRadioHalUtils"
//#define LOG_NDEBUG 0
-#include <utils/Log.h>
+#include <android/log.h>
#include <utils/misc.h>
#include <system/radio_metadata.h>
diff --git a/example/extension/light/2.0/default/service.cpp b/example/extension/light/2.0/default/service.cpp
index ae00506..3eb7bdf 100644
--- a/example/extension/light/2.0/default/service.cpp
+++ b/example/extension/light/2.0/default/service.cpp
@@ -15,7 +15,7 @@
*/
#define LOG_TAG "android.hardware.light@2.0-service"
-#include <utils/Log.h>
+#include <android/log.h>
#include "Light.h"
diff --git a/gatekeeper/1.0/default/Gatekeeper.cpp b/gatekeeper/1.0/default/Gatekeeper.cpp
index 35b8c02..36e044c 100644
--- a/gatekeeper/1.0/default/Gatekeeper.cpp
+++ b/gatekeeper/1.0/default/Gatekeeper.cpp
@@ -15,7 +15,7 @@
*/
#define LOG_TAG "android.hardware.gatekeeper@1.0-service"
-#include <utils/Log.h>
+#include <android/log.h>
#include <dlfcn.h>
#include "Gatekeeper.h"
diff --git a/gatekeeper/1.0/vts/functional/gatekeeper_hidl_hal_test.cpp b/gatekeeper/1.0/vts/functional/gatekeeper_hidl_hal_test.cpp
index 4dd9294..e919b48 100644
--- a/gatekeeper/1.0/vts/functional/gatekeeper_hidl_hal_test.cpp
+++ b/gatekeeper/1.0/vts/functional/gatekeeper_hidl_hal_test.cpp
@@ -26,7 +26,7 @@
#include <hardware/hw_auth_token.h>
-#include <android-base/logging.h>
+#include <android/log.h>
#include <android/hardware/gatekeeper/1.0/IGatekeeper.h>
#include <android/hardware/gatekeeper/1.0/types.h>
diff --git a/gnss/1.0/Android.bp b/gnss/1.0/Android.bp
index adac05f..f8d3926 100644
--- a/gnss/1.0/Android.bp
+++ b/gnss/1.0/Android.bp
@@ -12,6 +12,7 @@
"IAGnssRilCallback.hal",
"IGnss.hal",
"IGnssCallback.hal",
+ "IGnssConfiguration.hal",
"IGnssDebug.hal",
"IGnssGeofenceCallback.hal",
"IGnssGeofencing.hal",
@@ -32,6 +33,7 @@
"android/hardware/gnss/1.0/AGnssRilCallbackAll.cpp",
"android/hardware/gnss/1.0/GnssAll.cpp",
"android/hardware/gnss/1.0/GnssCallbackAll.cpp",
+ "android/hardware/gnss/1.0/GnssConfigurationAll.cpp",
"android/hardware/gnss/1.0/GnssDebugAll.cpp",
"android/hardware/gnss/1.0/GnssGeofenceCallbackAll.cpp",
"android/hardware/gnss/1.0/GnssGeofencingAll.cpp",
@@ -58,6 +60,7 @@
"IAGnssRilCallback.hal",
"IGnss.hal",
"IGnssCallback.hal",
+ "IGnssConfiguration.hal",
"IGnssDebug.hal",
"IGnssGeofenceCallback.hal",
"IGnssGeofencing.hal",
@@ -102,6 +105,11 @@
"android/hardware/gnss/1.0/BnGnssCallback.h",
"android/hardware/gnss/1.0/BpGnssCallback.h",
"android/hardware/gnss/1.0/BsGnssCallback.h",
+ "android/hardware/gnss/1.0/IGnssConfiguration.h",
+ "android/hardware/gnss/1.0/IHwGnssConfiguration.h",
+ "android/hardware/gnss/1.0/BnGnssConfiguration.h",
+ "android/hardware/gnss/1.0/BpGnssConfiguration.h",
+ "android/hardware/gnss/1.0/BsGnssConfiguration.h",
"android/hardware/gnss/1.0/IGnssDebug.h",
"android/hardware/gnss/1.0/IHwGnssDebug.h",
"android/hardware/gnss/1.0/BnGnssDebug.h",
diff --git a/gnss/1.0/IAGnss.hal b/gnss/1.0/IAGnss.hal
index a3172f3..2cce519 100644
--- a/gnss/1.0/IAGnss.hal
+++ b/gnss/1.0/IAGnss.hal
@@ -22,7 +22,7 @@
* Extended interface for AGNSS support.
*/
interface IAGnss {
- enum ApnIpType : uint16_t {
+ enum ApnIpType : uint8_t {
INVALID = 0,
IPV4 = 1,
IPV6 = 2,
@@ -72,6 +72,6 @@
*
* @return success True if the operation is successful.
*/
- dataConnOpenWithApnIpType(string apn, ApnIpType apnIpType)
+ dataConnOpen(string apn, ApnIpType apnIpType)
generates (bool success);
};
diff --git a/gnss/1.0/IAGnssCallback.hal b/gnss/1.0/IAGnssCallback.hal
index 46641be..1984725 100644
--- a/gnss/1.0/IAGnssCallback.hal
+++ b/gnss/1.0/IAGnssCallback.hal
@@ -19,12 +19,12 @@
/** Callback structure for the AGNSS interface. */
interface IAGnssCallback {
/** AGNSS type **/
- enum AGnssType : uint16_t {
+ enum AGnssType : uint8_t {
TYPE_SUPL = 1,
TYPE_C2K = 2
};
- enum AGnssStatusValue : uint16_t {
+ enum AGnssStatusValue : uint8_t {
/** GNSS requests data connection for AGNSS. */
REQUEST_AGNSS_DATA_CONN = 1,
/** GNSS releases the AGNSS data connection. */
diff --git a/gnss/1.0/IAGnssRil.hal b/gnss/1.0/IAGnssRil.hal
index 7363d46..499b874 100644
--- a/gnss/1.0/IAGnssRil.hal
+++ b/gnss/1.0/IAGnssRil.hal
@@ -25,13 +25,13 @@
* location, unique subscriber ID, phone number string and network availability changes.
*/
interface IAGnssRil {
- enum SetIDType : uint16_t {
+ enum SetIDType : uint8_t {
NONE = 0,
IMSI = 1,
MSISDM = 2
};
- enum NetworkType : int32_t {
+ enum NetworkType : uint8_t {
MOBILE = 0,
WIFI = 1,
MMS = 2,
@@ -41,10 +41,9 @@
WIMAX = 6,
};
- enum AGnssRefLocationType : int32_t {
+ enum AGnssRefLocationType : uint8_t {
GSM_CELLID = 1,
UMTS_CELLID = 2,
- MAC = 3,
LTE_CELLID = 4,
};
@@ -75,20 +74,11 @@
uint16_t pcid;
};
- struct AGnssRefLocationMac {
- uint8_t[6] mac;
- };
-
/* Represents ref locations */
struct AGnssRefLocation {
AGnssRefLocationType type;
- union RefLoc {
- AGnssRefLocationCellID cellID;
- AGnssRefLocationMac mac;
- };
-
- RefLoc refLocVal;
+ AGnssRefLocationCellID cellID;
};
/*
@@ -102,7 +92,7 @@
/*
* Sets the reference location.
*
- * @param agnssReflocation AGNSS reference location CellID/MAC.
+ * @param agnssReflocation AGNSS reference location CellID.
*/
setRefLocation(AGnssRefLocation agnssReflocation);
diff --git a/gnss/1.0/IAGnssRilCallback.hal b/gnss/1.0/IAGnssRilCallback.hal
index 6f29820..17122b2 100644
--- a/gnss/1.0/IAGnssRilCallback.hal
+++ b/gnss/1.0/IAGnssRilCallback.hal
@@ -27,12 +27,6 @@
MSISDN = 1 << 1L,
};
- /* Kinds of reference location that can be requested. */
- enum RefLoc : uint32_t {
- CELLID = 1 << 0L,
- MAC = 1 << 1L
- };
-
/*
* The Hal uses this API to request a SET ID.
*
@@ -43,9 +37,7 @@
/*
* The Hal uses this API to request a reference location.
*
- * @param refLocflag Specifies the kind of reference location that is required
- * by the HAL.
*/
- requestRefLocCb(RefLoc refLocflag);
+ requestRefLocCb();
};
diff --git a/gnss/1.0/IGnss.hal b/gnss/1.0/IGnss.hal
index bc19e78..cc19ef8 100644
--- a/gnss/1.0/IGnss.hal
+++ b/gnss/1.0/IGnss.hal
@@ -19,6 +19,7 @@
import IAGnss;
import IAGnssRil;
import IGnssCallback;
+import IGnssConfiguration;
import IGnssDebug;
import IGnssMeasurement;
import IGnssNavigationMessage;
@@ -29,7 +30,7 @@
/* Represents the standard GNSS interface. */
interface IGnss {
/* Requested operational mode for GNSS operation. */
- enum GnssPositionMode : uint32_t {
+ enum GnssPositionMode : uint8_t {
/** Mode for running GNSS standalone (no assistance). */
STANDALONE = 0,
/** AGNSS MS-Based mode. */
@@ -110,7 +111,7 @@
* time. Represented in milliseconds.
*
* @return success Returns true if the operation is successful.
- *
+ */
injectTime(GnssUtcTime timeMs, int64_t timeReferenceMs, int32_t uncertaintyMs)
generates (bool success);
@@ -137,6 +138,9 @@
deleteAidingData(GnssAidingData aidingDataFlags);
/*
+ * Sets the GnssPositionMode parameter,its associated recurrence value,
+ * the time between fixes,requested fix accuracy and time to first fix.
+ *
* @param mode Parameter must be one of MS_BASED or STANDALONE.
* It is allowed by the platform (and it is recommended) to fallback to
* MS_BASED if MS_ASSISTED is passed in, and MS_BASED is supported.
@@ -155,56 +159,63 @@
/*
* This method returns the IAGnssRil Interface.
*
- * @return infc Handle to the IAGnssRil interface.
+ * @return aGnssRilIface Handle to the IAGnssRil interface.
*/
- getExtensionAGnssRil() generates (IAGnssRil infc);
+ getExtensionAGnssRil() generates (IAGnssRil aGnssRilIface);
/*
* This method returns the IGnssGeofencing Interface.
*
- * @return infc Handle to the IGnssGeofencing interface.
+ * @return gnssGeofencingIface Handle to the IGnssGeofencing interface.
*/
- getExtensionGnssGeofencing() generates(IGnssGeofencing infc);
+ getExtensionGnssGeofencing() generates(IGnssGeofencing gnssGeofencingIface);
/*
* This method returns the IAGnss Interface.
*
- * @return infc Handle to the IAGnss interface.
+ * @return aGnssIface Handle to the IAGnss interface.
*/
- getExtensionAGnss() generates (IAGnss infc);
+ getExtensionAGnss() generates (IAGnss aGnssIface);
/*
* This method returns the IGnssNi interface.
*
- * @return infc Handle to the IGnssNi interface.
+ * @return gnssNiIface Handle to the IGnssNi interface.
*/
- getExtensionGnssNi() generates (IGnssNi infc);
+ getExtensionGnssNi() generates (IGnssNi gnssNiIface);
/*
* This method returns the IGnssMeasurement interface.
*
- * @return infc Handle to the IGnssMeasurement interface.
+ * @return gnssMeasurementIface Handle to the IGnssMeasurement interface.
*/
- getExtensionGnssMeasurement() generates (IGnssMeasurement infc);
+ getExtensionGnssMeasurement() generates (IGnssMeasurement gnssMeasurementIface);
/*
* This method returns the IGnssNavigationMessage interface.
*
- * @return infc Handle to the IGnssNavigationMessage interface.
+ * @return gnssNavigationIface gnssNavigationIface to the IGnssNavigationMessage interface.
*/
- getExtensionGnssNavigationMessage() generates (IGnssNavigationMessage infc);
+ getExtensionGnssNavigationMessage() generates (IGnssNavigationMessage gnssNavigationIface);
/*
* This method returns the IGnssXtra interface.
*
- * @return infc Handle to the IGnssXtra interface.
+ * @return xtraIface Handle to the IGnssXtra interface.
*/
- getExtensionXtra() generates (IGnssXtra infc);
+ getExtensionXtra() generates (IGnssXtra xtraIface);
+
+ /*
+ * This method returns the IGnssConfiguration interface.
+ *
+ * @return gnssConfigIface Handle to the IGnssConfiguration interface.
+ */
+ getExtensionGnssConfiguration() generates (IGnssConfiguration gnssConfigIface);
/*
* This method returns the IGnssDebug interface.
*
- * @return infc Handle to the IGnssDebug interface.
+ * @return debugIface Handle to the IGnssDebug interface.
*/
- getExtensionGnssDebug() generates (IGnssDebug infc);
+ getExtensionGnssDebug() generates (IGnssDebug debugIface);
};
diff --git a/gnss/1.0/IGnssCallback.hal b/gnss/1.0/IGnssCallback.hal
index 5234688..041f949 100644
--- a/gnss/1.0/IGnssCallback.hal
+++ b/gnss/1.0/IGnssCallback.hal
@@ -47,9 +47,9 @@
};
/* GNSS status event values. */
- enum GnssStatusValue : uint16_t {
+ enum GnssStatusValue : uint8_t {
/** GNSS status unknown. */
- STATUS_NONE = 0,
+ NONE = 0,
/** GNSS has begun navigating. */
SESSION_BEGIN = 1,
/** GNSS has stopped navigating. */
@@ -64,7 +64,7 @@
* Flags that indicate information about the satellite
*/
enum GnssSvFlags : uint8_t {
- FLAGS_NONE = 0,
+ NONE = 0,
HAS_EPHEMERIS_DATA = 1 << 0,
HAS_ALMANAC_DATA = 1 << 1,
USED_IN_FIX = 1 << 2
@@ -121,13 +121,13 @@
/*
* Number of GNSS SVs currently visible, refers to the SVs stored in sv_list
*/
- int32_t numSvs;
+ uint32_t numSvs;
/*
* Pointer to an array of SVs information for all GNSS constellations,
* except GNSS, which is reported using svList
*/
- GnssSvInfo[ConstS32:GNSS_MAX_SVS] gnssSvList;
+ GnssSvInfo[GnssMax:SVS_COUNT] gnssSvList;
};
diff --git a/gnss/1.0/IGnssConfiguration.hal b/gnss/1.0/IGnssConfiguration.hal
new file mode 100644
index 0000000..f8856b0
--- /dev/null
+++ b/gnss/1.0/IGnssConfiguration.hal
@@ -0,0 +1,149 @@
+/*
+ * 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.gnss@1.0;
+
+/*
+ * Interface for passing GNSS configuration info from platform to HAL.
+ */
+interface IGnssConfiguration {
+ /*
+ * Enum which holds the bit masks for SUPL_MODE configuration parameter.
+ */
+ enum SuplMode : uint8_t {
+ /* Mobile Station Based */
+ MSB = 0x01,
+
+ /* Mobile Station Assisted */
+ MSA = 0x02
+ };
+
+ /*
+ * Enum which holds the bit masks for GPS_LOCK configuration parameter.
+ */
+ enum GpsLock : uint8_t {
+ /* Lock Mobile Originated GPS functionalitues. */
+ MO = 0x01,
+
+ /* Lock Network initiated GPS functionalities. */
+ NI = 0x02
+ };
+
+ /*
+ * Enum that hold the bit masks for various LTE Positioning Profile settings (LPP_PROFILE
+ * configuration parameter). If none of the bits in the enum are set, the default setting is
+ * Radio Resource Location Protocol(RRLP).
+ */
+ enum LppProfile : uint8_t {
+ /* Enable LTE Positioning Protocol user plane */
+ USER_PLANE = 0x01,
+
+ /* Enable LTE Positioning Protocol Control plane */
+ CONTROL_PLANE = 0x02
+ };
+
+ /*
+ * Enum which holds the bit masks for A_GLONASS_POS_PROTOCOL_SELECT
+ * configuration parameter.
+ */
+ enum GlonassPosProtocol : uint8_t {
+ /* Radio Resource Control(RRC) control-plane. */
+ RRC_CPLANE = 0x01,
+
+ /* Radio Resource Location user-plane. */
+ RRLP_CPLANE = 0x02,
+
+ /* LTE Positioning Protocol User plane */
+ LPP_UPLANE = 0x04
+ };
+
+ /*
+ * IMPORTANT: GNSS HAL must expect the below methods to be called multiple
+ * times. They can be called even when GnssLocationProvider is already
+ * constructed and enabled. GNSS HAL must maintain the existing requests
+ * for various callbacks regardless the change in configuration data.
+ */
+
+ /*
+ * This method enables or disables emergency SUPL.
+ *
+ * @param enabled True if emergency SUPL is to be enabled.
+ *
+ * @return success True if operation was successful.
+ */
+ setSuplEs(bool enabled) generates (bool success);
+
+ /*
+ * This method sets the SUPL version requested by Carrier. The GNSS HAL
+ * must use this version of the SUPL protocol if supported.
+ *
+ * @param version SUPL version requested by carrier. This is a bit mask
+ * with bits 0:7 representing a service indicator field, bits 8:15
+ * representing the minor version and bits 16:23 representing the
+ * major version.
+ *
+ * @return success True if operation was successful.
+ */
+ setSuplVersion(uint32_t version) generates (bool success);
+
+ /*
+ * This method sets the SUPL mode.
+ *
+ * @param mode Bit mask that specifies the SUPL mode which is set with the SuplMode enum.
+ *
+ * @return success True if operation was successful.
+ */
+ setSuplMode(uint8_t mode) generates (bool success);
+
+ /*
+ * This setting configures how GPS functionalities should be locked when
+ * user turns off GPS On setting.
+ *
+ * @param lock Bitmask that specifies the GPS functionalities to be be
+ * locked as per the GpsLock enum.
+ *
+ * @return success True if operation was successful.
+ */
+ setGpsLock(uint8_t lock) generates (bool success);
+
+ /*
+ * This method sets the LTE Positioning Profile configuration.
+ *
+ * @param lppProfile Bitmask that specifies the LTE Positioning Profile
+ * configuration to be set as per the LppProfile enum.
+ *
+ * @return success True if operation was successful.
+ */
+ setLppProfile(uint8_t lppProfile) generates (bool success);
+
+ /*
+ * This method selects positioning protocol on A-Glonass system.
+ *
+ * @param protocol Bitmask that specifies the positioning protocol to be
+ * set as per GlonassPositioningProtocol enum.
+ *
+ * @return success True if operation was successful.
+ */
+ setGlonassPositioningProtocol(uint8_t protocol) generates (bool success);
+
+ /*
+ * This method configures which PDN to use.
+ *
+ * @param enable Use emergency PDN if true and regular PDN if false.
+ * @return success True if operation was successful.
+ */
+ setEmergencySuplPdn(bool enable) generates (bool success);
+};
diff --git a/gnss/1.0/IGnssDebug.hal b/gnss/1.0/IGnssDebug.hal
index b0ac69d..ff9ea9f 100644
--- a/gnss/1.0/IGnssDebug.hal
+++ b/gnss/1.0/IGnssDebug.hal
@@ -2,7 +2,7 @@
/* Extended interface for DEBUG support. */
interface IGnssDebug {
- enum SatelliteEphemerisType : uint32_t {
+ enum SatelliteEphemerisType : uint8_t {
/* no information is known to the gnss hardware, about this satellite */
UNKNOWN,
/* this satellite is known to exist */
@@ -37,14 +37,14 @@
/*
* Validity of the data in this struct. False only if no
* latitude/longitude information is known.
- * /
+ */
bool valid;
/* Latitude expressed in degrees */
double latitudeDegrees;
/* Longitude expressed in degrees */
double longitudeDegrees;
/* Altitude above ellipsoid expressed in meters */
- float altitudeDegrees;
+ float altitudeMeters;
/*
* estimated horizontal accuracy of position expressed in meters, radial,
* 68% confidence.
diff --git a/gnss/1.0/IGnssGeofenceCallback.hal b/gnss/1.0/IGnssGeofenceCallback.hal
index 06eb62a..5c70c5e 100644
--- a/gnss/1.0/IGnssGeofenceCallback.hal
+++ b/gnss/1.0/IGnssGeofenceCallback.hal
@@ -69,7 +69,7 @@
* addGeofenceArea method.
*
* Even though the diagram and explanation talks about states and transitions,
- * the callee is only interested in the transistions. The states are mentioned
+ * the callee is only interested in the transitions. The states are mentioned
* here for illustrative purposes.
*
* Startup Scenario: When the device boots up, if an application adds geofences,
diff --git a/gnss/1.0/IGnssGeofencing.hal b/gnss/1.0/IGnssGeofencing.hal
index 89301f4..8417333 100644
--- a/gnss/1.0/IGnssGeofencing.hal
+++ b/gnss/1.0/IGnssGeofencing.hal
@@ -53,7 +53,7 @@
* @param unknownTimerMs - The time limit after which the UNCERTAIN transition
* must be triggered. This parameter is defined in milliseconds.
*/
- addGeofenceArea(int32_t geofenceId, double latitudeDegrees, double longitudeDegrees,
+ addGeofence(int32_t geofenceId, double latitudeDegrees, double longitudeDegrees,
double radiusMeters, GeofenceTransition lastTransition,
int32_t monitorTransitions, uint32_t notificationResponsivenessMs,
uint32_t unknownTimerMs);
@@ -82,5 +82,5 @@
*
* @param geofenceId The id of the geofence.
*/
- removeGeofenceArea(int32_t geofenceId);
+ removeGeofence(int32_t geofenceId);
};
diff --git a/gnss/1.0/IGnssMeasurement.hal b/gnss/1.0/IGnssMeasurement.hal
index 5156b32..5174273 100644
--- a/gnss/1.0/IGnssMeasurement.hal
+++ b/gnss/1.0/IGnssMeasurement.hal
@@ -43,7 +43,7 @@
* Returns ERROR_GENERIC for any other error. The HAL must
* not generate any other updates upon returning this error code.
*/
- setCallback(IGnssMeasurementCallback callback) generates (int32_t initRet);
+ setCallback(IGnssMeasurementCallback callback) generates (GnssMeasurementStatus initRet);
/*
* Stops updates from the HAL, and unregisters the callback routines.
diff --git a/gnss/1.0/IGnssMeasurementCallback.hal b/gnss/1.0/IGnssMeasurementCallback.hal
index 3650892..cc34c91 100644
--- a/gnss/1.0/IGnssMeasurementCallback.hal
+++ b/gnss/1.0/IGnssMeasurementCallback.hal
@@ -539,7 +539,7 @@
uint32_t measurementCount;
/* The array of measurements. */
- GnssMeasurement[ConstS32:GNSS_MAX_MEASUREMENT] measurements;
+ GnssMeasurement[GnssMax:SVS_COUNT] measurements;
/** The GNSS clock time reading. */
GnssClock clock;
diff --git a/gnss/1.0/IGnssNavigationMessage.hal b/gnss/1.0/IGnssNavigationMessage.hal
index d59b538..11f2096 100644
--- a/gnss/1.0/IGnssNavigationMessage.hal
+++ b/gnss/1.0/IGnssNavigationMessage.hal
@@ -42,7 +42,7 @@
* expected that the HAL will not generate any updates upon returning
* this error code.
*/
- setCallback(IGnssNavigationMessageCallback callback) generates (int32_t initRet);
+ setCallback(IGnssNavigationMessageCallback callback) generates (GnssNavigationMessageStatus initRet);
/*
* Stops updates from the HAL, and unregisters the callback routines.
diff --git a/gnss/1.0/IGnssNavigationMessageCallback.hal b/gnss/1.0/IGnssNavigationMessageCallback.hal
index a714fd7..6988c9a 100644
--- a/gnss/1.0/IGnssNavigationMessageCallback.hal
+++ b/gnss/1.0/IGnssNavigationMessageCallback.hal
@@ -26,7 +26,7 @@
* is typically transmitted.
*/
enum GnssNavigationMessageType : int16_t {
- TYPE_UNKNOWN = 0,
+ UNKNOWN = 0,
/** GNSS L1 C/A message contained in the structure. */
GNSS_L1CA = 0x0101,
/** GNSS L2-CNAV message contained in the structure. */
@@ -59,7 +59,7 @@
enum NavigationMessageStatus : uint16_t {
PARITY_PASSED = (1 << 0),
PARITY_REBUILT = (1 << 1),
- STATUS_UNKOWN = 0
+ UNKNOWN = 0
};
struct GnssNavigationMessage {
diff --git a/gnss/1.0/IGnssNiCallback.hal b/gnss/1.0/IGnssNiCallback.hal
index c696a92..f23b354 100644
--- a/gnss/1.0/IGnssNiCallback.hal
+++ b/gnss/1.0/IGnssNiCallback.hal
@@ -21,7 +21,7 @@
/*
* GnssNiType constants
*/
- enum GnssNiType : uint32_t {
+ enum GnssNiType : uint8_t {
VOICE = 1,
UMTS_SUPL = 2,
UMTS_CTRL_PLANE = 3
@@ -43,7 +43,7 @@
* GNSS NI responses, used to define the response in
* NI structures
*/
- enum GnssUserResponseType : int32_t {
+ enum GnssUserResponseType : uint8_t {
RESPONSE_ACCEPT = 1,
RESPONSE_DENY = 2,
RESPONSE_NORESP = 3,
diff --git a/gnss/1.0/default/AGnss.cpp b/gnss/1.0/default/AGnss.cpp
new file mode 100644
index 0000000..52fdc26
--- /dev/null
+++ b/gnss/1.0/default/AGnss.cpp
@@ -0,0 +1,188 @@
+/*
+ * 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 "GnssHAL_AGnssInterface"
+
+#include "AGnss.h"
+
+namespace android {
+namespace hardware {
+namespace gnss {
+namespace V1_0 {
+namespace implementation {
+
+std::vector<std::unique_ptr<ThreadFuncArgs>> AGnss::sThreadFuncArgsList;
+sp<IAGnssCallback> AGnss::sAGnssCbIface = nullptr;
+bool AGnss::sInterfaceExists = false;
+
+AGpsCallbacks AGnss::sAGnssCb = {
+ .status_cb = statusCb,
+ .create_thread_cb = createThreadCb
+};
+
+AGnss::AGnss(const AGpsInterface* aGpsIface) : mAGnssIface(aGpsIface) {
+ /* Error out if an instance of the interface already exists. */
+ LOG_ALWAYS_FATAL_IF(sInterfaceExists);
+ sInterfaceExists = true;
+}
+
+AGnss::~AGnss() {
+ sThreadFuncArgsList.clear();
+}
+
+void AGnss::statusCb(AGpsStatus* status) {
+ if (sAGnssCbIface == nullptr) {
+ ALOGE("%s: AGNSS Callback Interface configured incorrectly", __func__);
+ return;
+ }
+
+ if (status == nullptr) {
+ ALOGE("AGNSS status is invalid");
+ return;
+ }
+
+ /*
+ * Logic based on AGnssStatus processing by GnssLocationProvider. Size of
+ * AGpsStatus is checked for backward compatibility since some devices may
+ * be sending out an older version of AGpsStatus that only supports IPv4.
+ */
+ size_t statusSize = status->size;
+ if (status->size == sizeof(AGpsStatus)) {
+ switch (status->addr.ss_family)
+ {
+ case AF_INET:
+ {
+ /*
+ * ss_family indicates IPv4.
+ */
+ struct sockaddr_in* in = reinterpret_cast<struct sockaddr_in*>(&(status->addr));
+ IAGnssCallback::AGnssStatusIpV4 aGnssStatusIpV4 = {
+ .type = static_cast<IAGnssCallback::AGnssType>(status->type),
+ .status = static_cast<IAGnssCallback::AGnssStatusValue>(status->status),
+ .ipV4Addr = in->sin_addr.s_addr,
+ };
+
+ /*
+ * Callback to client with agnssStatusIpV4Cb.
+ */
+ sAGnssCbIface->agnssStatusIpV4Cb(aGnssStatusIpV4);
+ break;
+ }
+ case AF_INET6:
+ {
+ /*
+ * ss_family indicates IPv6. Callback to client with agnssStatusIpV6Cb.
+ */
+ IAGnssCallback::AGnssStatusIpV6 aGnssStatusIpV6;
+
+ aGnssStatusIpV6.type = static_cast<IAGnssCallback::AGnssType>(status->type);
+ aGnssStatusIpV6.status = static_cast<IAGnssCallback::AGnssStatusValue>(
+ status->status);
+
+ struct sockaddr_in6* in6 = reinterpret_cast<struct sockaddr_in6 *>(
+ &(status->addr));
+ memcpy(&(aGnssStatusIpV6.ipV6Addr[0]), in6->sin6_addr.s6_addr,
+ aGnssStatusIpV6.ipV6Addr.size());
+ sAGnssCbIface->agnssStatusIpV6Cb(aGnssStatusIpV6);
+ break;
+ }
+ default:
+ ALOGE("Invalid ss_family found: %d", status->addr.ss_family);
+ }
+ } else if (statusSize >= sizeof(AGpsStatus_v2)) {
+ AGpsStatus_v2* statusV2 = reinterpret_cast<AGpsStatus_v2*>(status);
+ uint32_t ipV4Addr = statusV2->ipaddr;
+ IAGnssCallback::AGnssStatusIpV4 aGnssStatusIpV4 = {
+ .type = static_cast<IAGnssCallback::AGnssType>(AF_INET),
+ .status = static_cast<IAGnssCallback::AGnssStatusValue>(status->status),
+ /*
+ * For older versions of AGpsStatus, change IP addr to net order. This
+ * was earlier being done in GnssLocationProvider.
+ */
+ .ipV4Addr = htonl(ipV4Addr)
+ };
+ /*
+ * Callback to client with agnssStatusIpV4Cb.
+ */
+ sAGnssCbIface->agnssStatusIpV4Cb(aGnssStatusIpV4);
+ } else {
+ ALOGE("%s: Invalid size for AGPS Status", __func__);
+ }
+}
+
+pthread_t AGnss::createThreadCb(const char* name, void (*start)(void*), void* arg) {
+ return createPthread(name, start, arg, &sThreadFuncArgsList);
+}
+
+/*
+ * Implementation of methods from ::android::hardware::gnss::V1_0::IAGnss follow.
+ */
+Return<void> AGnss::setCallback(const sp<IAGnssCallback>& callback) {
+ if (mAGnssIface == nullptr) {
+ ALOGE("%s: AGnss interface is unavailable", __func__);
+ return Void();
+ }
+
+ sAGnssCbIface = callback;
+
+ mAGnssIface->init(&sAGnssCb);
+ return Void();
+}
+
+Return<bool> AGnss::dataConnClosed() {
+ if (mAGnssIface == nullptr) {
+ ALOGE("%s: AGnss interface is unavailable", __func__);
+ return false;
+ }
+
+ return (mAGnssIface->data_conn_closed() == 0);
+}
+
+Return<bool> AGnss::dataConnFailed() {
+ if (mAGnssIface == nullptr) {
+ ALOGE("%s: AGnss interface is unavailable", __func__);
+ return false;
+ }
+
+ return (mAGnssIface->data_conn_failed() == 0);
+}
+
+Return<bool> AGnss::setServer(IAGnssCallback::AGnssType type,
+ const hidl_string& hostname,
+ int32_t port) {
+ if (mAGnssIface == nullptr) {
+ ALOGE("%s: AGnss interface is unavailable", __func__);
+ return false;
+ }
+
+ return (mAGnssIface->set_server(static_cast<AGpsType>(type), hostname.c_str(), port) == 0);
+}
+
+Return<bool> AGnss::dataConnOpen(const hidl_string& apn, IAGnss::ApnIpType apnIpType) {
+ if (mAGnssIface == nullptr) {
+ ALOGE("%s: AGnss interface is unavailable", __func__);
+ return false;
+ }
+
+ return (mAGnssIface->data_conn_open_with_apn_ip_type(apn.c_str(),
+ static_cast<uint16_t>(apnIpType)) == 0);
+}
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace gnss
+} // namespace hardware
+} // namespace android
diff --git a/gnss/1.0/default/AGnss.h b/gnss/1.0/default/AGnss.h
new file mode 100644
index 0000000..2a8eed0
--- /dev/null
+++ b/gnss/1.0/default/AGnss.h
@@ -0,0 +1,85 @@
+/*
+ * 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 android_hardware_gnss_V1_0_AGnss_H_
+#define android_hardware_gnss_V1_0_AGnss_H_
+
+#include <ThreadCreationWrapper.h>
+#include <android/hardware/gnss/1.0/IAGnss.h>
+#include <hardware/gps_internal.h>
+#include <hidl/Status.h>
+#include <netinet/in.h>
+
+namespace android {
+namespace hardware {
+namespace gnss {
+namespace V1_0 {
+namespace implementation {
+
+using ::android::hardware::gnss::V1_0::IAGnss;
+using ::android::hardware::gnss::V1_0::IAGnssCallback;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+using ::android::hardware::hidl_vec;
+using ::android::hardware::hidl_string;
+using ::android::sp;
+
+/*
+ * Extended interface for AGNSS support. Also contains wrapper methods to allow
+ * methods from IAGnssCallback interface to be passed into the conventional
+ * implementation of the GNSS HAL.
+ */
+struct AGnss : public IAGnss {
+ AGnss(const AGpsInterface* agpsIface);
+ ~AGnss();
+ /*
+ * Methods from ::android::hardware::gnss::V1_0::IAGnss interface follow.
+ * These declarations were generated from IAGnss.hal.
+ */
+ Return<void> setCallback(const sp<IAGnssCallback>& callback) override;
+ Return<bool> dataConnClosed() override;
+ Return<bool> dataConnFailed() override;
+ Return<bool> setServer(IAGnssCallback::AGnssType type,
+ const hidl_string& hostname, int32_t port) override;
+ Return<bool> dataConnOpen(const hidl_string& apn,
+ IAGnss::ApnIpType apnIpType) override;
+
+ /*
+ * Callback methods to be passed into the conventional GNSS HAL by the default
+ * implementation. These methods are not part of the IAGnss base class.
+ */
+ static pthread_t createThreadCb(const char* name, void (*start)(void*), void* arg);
+ static void statusCb(AGpsStatus* status);
+
+ /*
+ * Holds function pointers to the callback methods.
+ */
+ static AGpsCallbacks sAGnssCb;
+
+ private:
+ const AGpsInterface* mAGnssIface = nullptr;
+ static sp<IAGnssCallback> sAGnssCbIface;
+ static std::vector<std::unique_ptr<ThreadFuncArgs>> sThreadFuncArgsList;
+ static bool sInterfaceExists;
+};
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace gnss
+} // namespace hardware
+} // namespace android
+
+#endif // android_hardware_gnss_V1_0_AGnss_H_
diff --git a/gnss/1.0/default/AGnssRil.cpp b/gnss/1.0/default/AGnssRil.cpp
new file mode 100644
index 0000000..87abad7
--- /dev/null
+++ b/gnss/1.0/default/AGnssRil.cpp
@@ -0,0 +1,145 @@
+/*
+ * 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 "GnssHAL_AGnssRilInterface"
+
+#include "AGnssRil.h"
+
+namespace android {
+namespace hardware {
+namespace gnss {
+namespace V1_0 {
+namespace implementation {
+
+std::vector<std::unique_ptr<ThreadFuncArgs>> AGnssRil::sThreadFuncArgsList;
+sp<IAGnssRilCallback> AGnssRil::sAGnssRilCbIface = nullptr;
+bool AGnssRil::sInterfaceExists = false;
+
+AGpsRilCallbacks AGnssRil::sAGnssRilCb = {
+ .request_setid = AGnssRil::requestSetId,
+ .request_refloc = AGnssRil::requestRefLoc,
+ .create_thread_cb = AGnssRil::createThreadCb
+};
+
+AGnssRil::AGnssRil(const AGpsRilInterface* aGpsRilIface) : mAGnssRilIface(aGpsRilIface) {
+ /* Error out if an instance of the interface already exists. */
+ LOG_ALWAYS_FATAL_IF(sInterfaceExists);
+ sInterfaceExists = true;
+}
+
+AGnssRil::~AGnssRil() {
+ sThreadFuncArgsList.clear();
+}
+
+void AGnssRil::requestSetId(uint32_t flags) {
+ if (sAGnssRilCbIface == nullptr) {
+ ALOGE("%s: AGNSSRil Callback Interface configured incorrectly", __func__);
+ return;
+ }
+
+ sAGnssRilCbIface->requestSetIdCb(static_cast<IAGnssRilCallback::ID>(flags));
+}
+
+void AGnssRil::requestRefLoc(uint32_t /*flags*/) {
+ if (sAGnssRilCbIface == nullptr) {
+ ALOGE("%s: AGNSSRil Callback Interface configured incorrectly", __func__);
+ return;
+ }
+
+ sAGnssRilCbIface->requestRefLocCb();
+}
+
+pthread_t AGnssRil::createThreadCb(const char* name, void (*start)(void*), void* arg) {
+ return createPthread(name, start, arg, &sThreadFuncArgsList);
+}
+
+// Methods from ::android::hardware::gnss::V1_0::IAGnssRil follow.
+Return<void> AGnssRil::setCallback(const sp<IAGnssRilCallback>& callback) {
+ if (mAGnssRilIface == nullptr) {
+ ALOGE("%s: AGnssRil interface is unavailable", __func__);
+ return Void();
+ }
+
+ sAGnssRilCbIface = callback;
+
+ mAGnssRilIface->init(&sAGnssRilCb);
+ return Void();
+}
+
+Return<void> AGnssRil::setRefLocation(const IAGnssRil::AGnssRefLocation& aGnssRefLocation) {
+ if (mAGnssRilIface == nullptr) {
+ ALOGE("%s: AGnssRil interface is unavailable", __func__);
+ return Void();
+ }
+
+ AGpsRefLocation aGnssRefloc;
+ aGnssRefloc.type = static_cast<uint16_t>(aGnssRefLocation.type);
+
+ auto& cellID = aGnssRefLocation.cellID;
+ aGnssRefloc.u.cellID = {
+ .type = static_cast<uint16_t>(cellID.type),
+ .mcc = cellID.mcc,
+ .mnc = cellID.mnc,
+ .lac = cellID.lac,
+ .cid = cellID.cid,
+ .tac = cellID.tac,
+ .pcid = cellID.pcid
+ };
+
+ mAGnssRilIface->set_ref_location(&aGnssRefloc, sizeof(aGnssRefloc));
+ return Void();
+}
+
+Return<bool> AGnssRil::setSetId(IAGnssRil::SetIDType type, const hidl_string& setid) {
+ if (mAGnssRilIface == nullptr) {
+ ALOGE("%s: AGnssRil interface is unavailable", __func__);
+ return false;
+ }
+
+ mAGnssRilIface->set_set_id(static_cast<uint16_t>(type), setid.c_str());
+ return true;
+}
+
+Return<bool> AGnssRil::updateNetworkState(bool connected,
+ IAGnssRil::NetworkType type,
+ bool roaming) {
+ if (mAGnssRilIface == nullptr) {
+ ALOGE("%s: AGnssRil interface is unavailable", __func__);
+ return false;
+ }
+
+ mAGnssRilIface->update_network_state(connected,
+ static_cast<int>(type),
+ roaming,
+ nullptr /* extra_info */);
+ return true;
+}
+
+Return<bool> AGnssRil::updateNetworkAvailability(bool available, const hidl_string& apn) {
+ if (mAGnssRilIface == nullptr) {
+ ALOGE("%s: AGnssRil interface is unavailable", __func__);
+ return false;
+ }
+
+ mAGnssRilIface->update_network_availability(available, apn.c_str());
+ return true;
+}
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace gnss
+} // namespace hardware
+} // namespace android
diff --git a/gnss/1.0/default/AGnssRil.h b/gnss/1.0/default/AGnssRil.h
new file mode 100644
index 0000000..6215a9e
--- /dev/null
+++ b/gnss/1.0/default/AGnssRil.h
@@ -0,0 +1,88 @@
+/*
+ * 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 android_hardware_gnss_V1_0_AGnssRil_H_
+#define android_hardware_gnss_V1_0_AGnssRil_H_
+
+#include <ThreadCreationWrapper.h>
+#include <android/hardware/gnss/1.0/IAGnssRil.h>
+#include <hardware/gps.h>
+#include <hidl/Status.h>
+
+namespace android {
+namespace hardware {
+namespace gnss {
+namespace V1_0 {
+namespace implementation {
+
+using ::android::hardware::gnss::V1_0::IAGnssRil;
+using ::android::hardware::gnss::V1_0::IAGnssRilCallback;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+using ::android::hardware::hidl_vec;
+using ::android::hardware::hidl_string;
+using ::android::sp;
+
+/*
+ * Extended interface for AGNSS RIL support. An Assisted GNSS Radio Interface Layer interface
+ * allows the GNSS chipset to request radio interface layer information from Android platform.
+ * Examples of such information are reference location, unique subscriber ID, phone number string
+ * and network availability changes. Also contains wrapper methods to allow methods from
+ * IAGnssiRilCallback interface to be passed into the conventional implementation of the GNSS HAL.
+ */
+struct AGnssRil : public IAGnssRil {
+ AGnssRil(const AGpsRilInterface* aGpsRilIface);
+ ~AGnssRil();
+
+ /*
+ * Methods from ::android::hardware::gnss::V1_0::IAGnssRil follow.
+ * These declarations were generated from IAGnssRil.hal.
+ */
+ Return<void> setCallback(const sp<IAGnssRilCallback>& callback) override;
+ Return<void> setRefLocation(const IAGnssRil::AGnssRefLocation& agnssReflocation) override;
+ Return<bool> setSetId(IAGnssRil::SetIDType type, const hidl_string& setid) override;
+ Return<bool> updateNetworkState(bool connected,
+ IAGnssRil::NetworkType type,
+ bool roaming) override;
+ Return<bool> updateNetworkAvailability(bool available, const hidl_string& apn) override;
+ static void requestSetId(uint32_t flags);
+ static void requestRefLoc(uint32_t flags);
+
+ /*
+ * Callback method to be passed into the conventional GNSS HAL by the default
+ * implementation. This method is not part of the IAGnssRil base class.
+ */
+ static pthread_t createThreadCb(const char* name, void (*start)(void*), void* arg);
+
+ /*
+ * Holds function pointers to the callback methods.
+ */
+ static AGpsRilCallbacks sAGnssRilCb;
+
+ private:
+ const AGpsRilInterface* mAGnssRilIface = nullptr;
+ static sp<IAGnssRilCallback> sAGnssRilCbIface;
+ static std::vector<std::unique_ptr<ThreadFuncArgs>> sThreadFuncArgsList;
+ static bool sInterfaceExists;
+};
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace gnss
+} // namespace hardware
+} // namespace android
+
+#endif // android_hardware_gnss_V1_0_AGnssRil_H_
diff --git a/gnss/1.0/default/Android.mk b/gnss/1.0/default/Android.mk
new file mode 100644
index 0000000..06ef331
--- /dev/null
+++ b/gnss/1.0/default/Android.mk
@@ -0,0 +1,29 @@
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := android.hardware.gnss@1.0-impl
+LOCAL_MODULE_RELATIVE_PATH := hw
+LOCAL_SRC_FILES := \
+ ThreadCreationWrapper.cpp \
+ AGnss.cpp \
+ AGnssRil.cpp \
+ Gnss.cpp \
+ GnssDebug.cpp \
+ GnssGeofencing.cpp \
+ GnssMeasurement.cpp \
+ GnssNavigationMessage.cpp \
+ GnssNi.cpp \
+ GnssXtra.cpp \
+ GnssConfiguration.cpp \
+ GnssUtils.cpp
+
+LOCAL_SHARED_LIBRARIES := \
+ liblog \
+ libhidlbase \
+ libhidltransport \
+ libhwbinder \
+ libutils \
+ android.hardware.gnss@1.0 \
+ libhardware
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/gnss/1.0/default/Gnss.cpp b/gnss/1.0/default/Gnss.cpp
new file mode 100644
index 0000000..37810be
--- /dev/null
+++ b/gnss/1.0/default/Gnss.cpp
@@ -0,0 +1,569 @@
+/*
+ * 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 "GnssHAL_GnssInterface"
+
+#include "Gnss.h"
+#include <GnssUtils.h>
+
+namespace android {
+namespace hardware {
+namespace gnss {
+namespace V1_0 {
+namespace implementation {
+
+std::vector<std::unique_ptr<ThreadFuncArgs>> Gnss::sThreadFuncArgsList;
+sp<IGnssCallback> Gnss::sGnssCbIface = nullptr;
+bool Gnss::sInterfaceExists = false;
+
+GpsCallbacks Gnss::sGnssCb = {
+ .size = sizeof(GpsCallbacks),
+ .location_cb = locationCb,
+ .status_cb = statusCb,
+ .sv_status_cb = gpsSvStatusCb,
+ .nmea_cb = nmeaCb,
+ .set_capabilities_cb = setCapabilitiesCb,
+ .acquire_wakelock_cb = acquireWakelockCb,
+ .release_wakelock_cb = releaseWakelockCb,
+ .create_thread_cb = createThreadCb,
+ .request_utc_time_cb = requestUtcTimeCb,
+ .set_system_info_cb = setSystemInfoCb,
+ .gnss_sv_status_cb = gnssSvStatusCb,
+};
+
+Gnss::Gnss(gps_device_t* gnssDevice) {
+ /* Error out if an instance of the interface already exists. */
+ LOG_ALWAYS_FATAL_IF(sInterfaceExists);
+ sInterfaceExists = true;
+
+ if (gnssDevice == nullptr) {
+ ALOGE("%s: Invalid device_t handle", __func__);
+ return;
+ }
+
+ mGnssIface = gnssDevice->get_gps_interface(gnssDevice);
+}
+
+Gnss::~Gnss() {
+ sThreadFuncArgsList.clear();
+}
+
+void Gnss::locationCb(GpsLocation* location) {
+ if (sGnssCbIface == nullptr) {
+ ALOGE("%s: GNSS Callback Interface configured incorrectly", __func__);
+ return;
+ }
+
+ if (location == nullptr) {
+ ALOGE("%s: Invalid location from GNSS HAL", __func__);
+ return;
+ }
+
+ android::hardware::gnss::V1_0::GnssLocation gnssLocation = convertToGnssLocation(location);
+ sGnssCbIface->gnssLocationCb(gnssLocation);
+}
+
+void Gnss::statusCb(GpsStatus* gnssStatus) {
+ if (sGnssCbIface == nullptr) {
+ ALOGE("%s: GNSS Callback Interface configured incorrectly", __func__);
+ return;
+ }
+
+ if (gnssStatus == nullptr) {
+ ALOGE("%s: Invalid GpsStatus from GNSS HAL", __func__);
+ return;
+ }
+
+ IGnssCallback::GnssStatusValue status =
+ static_cast<IGnssCallback::GnssStatusValue>(gnssStatus->status);
+
+ sGnssCbIface->gnssStatusCb(status);
+}
+
+void Gnss::gnssSvStatusCb(GnssSvStatus* status) {
+ if (sGnssCbIface == nullptr) {
+ ALOGE("%s: GNSS Callback Interface configured incorrectly", __func__);
+ return;
+ }
+
+ if (status == nullptr) {
+ ALOGE("Invalid status from GNSS HAL %s", __func__);
+ return;
+ }
+
+ IGnssCallback::GnssSvStatus svStatus;
+ svStatus.numSvs = status->num_svs;
+
+ if (svStatus.numSvs > static_cast<uint32_t>(GnssMax::SVS_COUNT)) {
+ ALOGW("Too many satellites %zd. Clamps to %d.", svStatus.numSvs, GnssMax::SVS_COUNT);
+ svStatus.numSvs = static_cast<uint32_t>(GnssMax::SVS_COUNT);
+ }
+
+ for (size_t i = 0; i < svStatus.numSvs; i++) {
+ auto svInfo = status->gnss_sv_list[i];
+ IGnssCallback::GnssSvInfo gnssSvInfo = {
+ .svid = svInfo.svid,
+ .constellation = static_cast<android::hardware::gnss::V1_0::GnssConstellationType>(
+ svInfo.constellation),
+ .cN0Dbhz = svInfo.c_n0_dbhz,
+ .elevationDegrees = svInfo.elevation,
+ .azimuthDegrees = svInfo.azimuth,
+ .svFlag = static_cast<IGnssCallback::GnssSvFlags>(svInfo.flags)
+ };
+ svStatus.gnssSvList[i] = gnssSvInfo;
+ }
+
+ sGnssCbIface->gnssSvStatusCb(svStatus);
+}
+
+/*
+ * This enum is used by gpsSvStatusCb() method below to convert GpsSvStatus
+ * to GnssSvStatus for backward compatibility. It is only used by the default
+ * implementation and is not part of the GNSS interface.
+ */
+enum SvidValues : uint16_t {
+ GLONASS_SVID_OFFSET = 64,
+ GLONASS_SVID_COUNT = 24,
+ BEIDOU_SVID_OFFSET = 200,
+ BEIDOU_SVID_COUNT = 35,
+ SBAS_SVID_MIN = 33,
+ SBAS_SVID_MAX = 64,
+ SBAS_SVID_ADD = 87,
+ QZSS_SVID_MIN = 193,
+ QZSS_SVID_MAX = 200
+};
+
+/*
+ * The following code that converts GpsSvStatus to GnssSvStatus is moved here from
+ * GnssLocationProvider. GnssLocationProvider does not require it anymore since GpsSvStatus is
+ * being deprecated and is no longer part of the GNSS interface.
+ */
+void Gnss::gpsSvStatusCb(GpsSvStatus* svInfo) {
+ if (sGnssCbIface == nullptr) {
+ ALOGE("%s: GNSS Callback Interface configured incorrectly", __func__);
+ return;
+ }
+
+ if (svInfo == nullptr) {
+ ALOGE("Invalid status from GNSS HAL %s", __func__);
+ return;
+ }
+
+ IGnssCallback::GnssSvStatus svStatus;
+ svStatus.numSvs = svInfo->num_svs;
+ /*
+ * Clamp the list size since GnssSvStatus can support a maximum of
+ * GnssMax::SVS_COUNT entries.
+ */
+ if (svStatus.numSvs > static_cast<uint32_t>(GnssMax::SVS_COUNT)) {
+ ALOGW("Too many satellites %zd. Clamps to %d.", svStatus.numSvs, GnssMax::SVS_COUNT);
+ svStatus.numSvs = static_cast<uint32_t>(GnssMax::SVS_COUNT);
+ }
+
+ uint32_t ephemerisMask = svInfo->ephemeris_mask;
+ uint32_t almanacMask = svInfo->almanac_mask;
+ uint32_t usedInFixMask = svInfo->used_in_fix_mask;
+ /*
+ * Conversion from GpsSvInfo to IGnssCallback::GnssSvInfo happens below.
+ */
+ for (size_t i = 0; i < svStatus.numSvs; i++) {
+ IGnssCallback::GnssSvInfo& info = svStatus.gnssSvList[i];
+ info.svid = svInfo->sv_list[i].prn;
+ if (info.svid >= 1 && info.svid <= 32) {
+ info.constellation = GnssConstellationType::GPS;
+ } else if (info.svid > GLONASS_SVID_OFFSET &&
+ info.svid <= GLONASS_SVID_OFFSET + GLONASS_SVID_COUNT) {
+ info.constellation = GnssConstellationType::GLONASS;
+ info.svid -= GLONASS_SVID_OFFSET;
+ } else if (info.svid > BEIDOU_SVID_OFFSET &&
+ info.svid <= BEIDOU_SVID_OFFSET + BEIDOU_SVID_COUNT) {
+ info.constellation = GnssConstellationType::BEIDOU;
+ info.svid -= BEIDOU_SVID_OFFSET;
+ } else if (info.svid >= SBAS_SVID_MIN && info.svid <= SBAS_SVID_MAX) {
+ info.constellation = GnssConstellationType::SBAS;
+ info.svid += SBAS_SVID_ADD;
+ } else if (info.svid >= QZSS_SVID_MIN && info.svid <= QZSS_SVID_MAX) {
+ info.constellation = GnssConstellationType::QZSS;
+ } else {
+ ALOGD("Unknown constellation type with Svid = %d.", info.svid);
+ info.constellation = GnssConstellationType::UNKNOWN;
+ }
+
+ info.cN0Dbhz = svInfo->sv_list[i].snr;
+ info.elevationDegrees = svInfo->sv_list[i].elevation;
+ info.azimuthDegrees = svInfo->sv_list[i].azimuth;
+ info.svFlag = IGnssCallback::GnssSvFlags::NONE;
+
+ /*
+ * Only GPS info is valid for these fields, as these masks are just 32
+ * bits, by GPS prn.
+ */
+ if (info.constellation == GnssConstellationType::GPS) {
+ int32_t svidMask = (1 << (info.svid - 1));
+ if ((ephemerisMask & svidMask) != 0) {
+ info.svFlag |= IGnssCallback::GnssSvFlags::HAS_EPHEMERIS_DATA;
+ }
+ if ((almanacMask & svidMask) != 0) {
+ info.svFlag |= IGnssCallback::GnssSvFlags::HAS_ALMANAC_DATA;
+ }
+ if ((usedInFixMask & svidMask) != 0) {
+ info.svFlag |= IGnssCallback::GnssSvFlags::USED_IN_FIX;
+ }
+ }
+ }
+
+ sGnssCbIface->gnssSvStatusCb(svStatus);
+}
+
+void Gnss::nmeaCb(GpsUtcTime timestamp, const char* nmea, int length) {
+ if (sGnssCbIface == nullptr) {
+ ALOGE("%s: GNSS Callback Interface configured incorrectly", __func__);
+ return;
+ }
+
+ android::hardware::hidl_string nmeaString;
+ nmeaString.setToExternal(nmea, length);
+ sGnssCbIface->gnssNmeaCb(timestamp, nmeaString);
+}
+
+void Gnss::setCapabilitiesCb(uint32_t capabilities) {
+ if (sGnssCbIface == nullptr) {
+ ALOGE("%s: GNSS Callback Interface configured incorrectly", __func__);
+ return;
+ }
+
+ sGnssCbIface->gnssSetCapabilitesCb(capabilities);
+}
+
+void Gnss::acquireWakelockCb() {
+ if (sGnssCbIface == nullptr) {
+ ALOGE("%s: GNSS Callback Interface configured incorrectly", __func__);
+ return;
+ }
+
+ sGnssCbIface->gnssAcquireWakelockCb();
+}
+
+void Gnss::releaseWakelockCb() {
+ if (sGnssCbIface == nullptr) {
+ ALOGE("%s: GNSS Callback Interface configured incorrectly", __func__);
+ return;
+ }
+
+ sGnssCbIface->gnssReleaseWakelockCb();
+}
+
+void Gnss::requestUtcTimeCb() {
+ if (sGnssCbIface == nullptr) {
+ ALOGE("%s: GNSS Callback Interface configured incorrectly", __func__);
+ return;
+ }
+
+ sGnssCbIface->gnssRequestTimeCb();
+}
+
+pthread_t Gnss::createThreadCb(const char* name, void (*start)(void*), void* arg) {
+ return createPthread(name, start, arg, &sThreadFuncArgsList);
+}
+
+void Gnss::setSystemInfoCb(const LegacyGnssSystemInfo* info) {
+ if (sGnssCbIface == nullptr) {
+ ALOGE("%s: GNSS Callback Interface configured incorrectly", __func__);
+ return;
+ }
+
+ if (info == nullptr) {
+ ALOGE("Invalid GnssSystemInfo from GNSS HAL %s", __func__);
+ return;
+ }
+
+ IGnssCallback::GnssSystemInfo gnssInfo = {
+ .yearOfHw = info->year_of_hw
+ };
+
+ sGnssCbIface->gnssSetSystemInfoCb(gnssInfo);
+}
+
+
+// Methods from ::android::hardware::gnss::V1_0::IGnss follow.
+Return<bool> Gnss::setCallback(const sp<IGnssCallback>& callback) {
+ if (mGnssIface == nullptr) {
+ ALOGE("%s: Gnss interface is unavailable", __func__);
+ return false;
+ }
+
+ sGnssCbIface = callback;
+
+ return (mGnssIface->init(&sGnssCb) == 0);
+}
+
+Return<bool> Gnss::start() {
+ if (mGnssIface == nullptr) {
+ ALOGE("%s: Gnss interface is unavailable", __func__);
+ return false;
+ }
+
+ return (mGnssIface->start() == 0);
+}
+
+Return<bool> Gnss::stop() {
+ if (mGnssIface == nullptr) {
+ ALOGE("%s: Gnss interface is unavailable", __func__);
+ return false;
+ }
+
+ return (mGnssIface->stop() == 0);
+}
+
+Return<void> Gnss::cleanup() {
+ if (mGnssIface == nullptr) {
+ ALOGE("%s: Gnss interface is unavailable", __func__);
+ } else {
+ mGnssIface->cleanup();
+ }
+ return Void();
+}
+
+Return<bool> Gnss::injectLocation(double latitudeDegrees,
+ double longitudeDegrees,
+ float accuracyMeters) {
+ if (mGnssIface == nullptr) {
+ ALOGE("%s: Gnss interface is unavailable", __func__);
+ return false;
+ }
+
+ return (mGnssIface->inject_location(latitudeDegrees, longitudeDegrees, accuracyMeters) == 0);
+}
+
+Return<bool> Gnss::injectTime(int64_t timeMs, int64_t timeReferenceMs,
+ int32_t uncertaintyMs) {
+ if (mGnssIface == nullptr) {
+ ALOGE("%s: Gnss interface is unavailable", __func__);
+ return false;
+ }
+
+ return (mGnssIface->inject_time(timeMs, timeReferenceMs, uncertaintyMs) == 0);
+}
+
+Return<void> Gnss::deleteAidingData(IGnss::GnssAidingData aidingDataFlags) {
+ if (mGnssIface == nullptr) {
+ ALOGE("%s: Gnss interface is unavailable", __func__);
+ } else {
+ mGnssIface->delete_aiding_data(static_cast<GpsAidingData>(aidingDataFlags));
+ }
+ return Void();
+}
+
+Return<bool> Gnss::setPositionMode(IGnss::GnssPositionMode mode,
+ IGnss::GnssPositionRecurrence recurrence,
+ uint32_t minIntervalMs,
+ uint32_t preferredAccuracyMeters,
+ uint32_t preferredTimeMs) {
+ if (mGnssIface == nullptr) {
+ ALOGE("%s: Gnss interface is unavailable", __func__);
+ return false;
+ }
+
+ return (mGnssIface->set_position_mode(static_cast<GpsPositionMode>(mode),
+ static_cast<GpsPositionRecurrence>(recurrence),
+ minIntervalMs,
+ preferredAccuracyMeters,
+ preferredTimeMs) == 0);
+}
+
+Return<void> Gnss::getExtensionAGnssRil(getExtensionAGnssRil_cb _hidl_cb) {
+ if (mGnssIface == nullptr) {
+ ALOGE("%s: Gnss interface is unavailable", __func__);
+ } else {
+ const AGpsRilInterface* agpsRilIface = static_cast<const AGpsRilInterface*>(
+ mGnssIface->get_extension(AGPS_RIL_INTERFACE));
+ if (agpsRilIface == nullptr) {
+ ALOGE("%s GnssRil interface not implemented by GNSS HAL", __func__);
+ } else {
+ mGnssRil = new AGnssRil(agpsRilIface);
+ }
+ }
+ _hidl_cb(mGnssRil);
+ return Void();
+}
+
+Return<void> Gnss::getExtensionGnssConfiguration(getExtensionGnssConfiguration_cb _hidl_cb) {
+ if (mGnssIface == nullptr) {
+ ALOGE("%s: Gnss interface is unavailable", __func__);
+ } else {
+ const GnssConfigurationInterface* gnssConfigIface =
+ static_cast<const GnssConfigurationInterface*>(
+ mGnssIface->get_extension(GNSS_CONFIGURATION_INTERFACE));
+
+ if (gnssConfigIface == nullptr) {
+ ALOGE("%s GnssConfiguration interface not implemented by GNSS HAL", __func__);
+ } else {
+ mGnssConfig = new GnssConfiguration(gnssConfigIface);
+ }
+ }
+ _hidl_cb(mGnssConfig);
+ return Void();
+}
+Return<void> Gnss::getExtensionGnssGeofencing(getExtensionGnssGeofencing_cb _hidl_cb) {
+ if (mGnssIface == nullptr) {
+ ALOGE("%s: Gnss interface is unavailable", __func__);
+ } else {
+ const GpsGeofencingInterface* gpsGeofencingIface =
+ static_cast<const GpsGeofencingInterface*>(
+ mGnssIface->get_extension(GPS_GEOFENCING_INTERFACE));
+
+ if (gpsGeofencingIface == nullptr) {
+ ALOGE("%s GnssGeofencing interface not implemented by GNSS HAL", __func__);
+ } else {
+ mGnssGeofencingIface = new GnssGeofencing(gpsGeofencingIface);
+ }
+ }
+
+ _hidl_cb(mGnssGeofencingIface);
+ return Void();
+}
+
+Return<void> Gnss::getExtensionAGnss(getExtensionAGnss_cb _hidl_cb) {
+ if (mGnssIface == nullptr) {
+ ALOGE("%s: Gnss interface is unavailable", __func__);
+ } else {
+ const AGpsInterface* agpsIface = static_cast<const AGpsInterface*>(
+ mGnssIface->get_extension(AGPS_INTERFACE));
+ if (agpsIface == nullptr) {
+ ALOGE("%s AGnss interface not implemented by GNSS HAL", __func__);
+ } else {
+ mAGnssIface = new AGnss(agpsIface);
+ }
+ }
+ _hidl_cb(mAGnssIface);
+ return Void();
+}
+
+Return<void> Gnss::getExtensionGnssNi(getExtensionGnssNi_cb _hidl_cb) {
+ if (mGnssIface == nullptr) {
+ ALOGE("%s: Gnss interface is unavailable", __func__);
+ } else {
+ const GpsNiInterface* gpsNiIface = static_cast<const GpsNiInterface*>(
+ mGnssIface->get_extension(GPS_NI_INTERFACE));
+ if (gpsNiIface == nullptr) {
+ ALOGE("%s GnssNi interface not implemented by GNSS HAL", __func__);
+ } else {
+ mGnssNi = new GnssNi(gpsNiIface);
+ }
+ }
+ _hidl_cb(mGnssNi);
+ return Void();
+}
+
+Return<void> Gnss::getExtensionGnssMeasurement(getExtensionGnssMeasurement_cb _hidl_cb) {
+ if (mGnssIface == nullptr) {
+ ALOGE("%s: Gnss interface is unavailable", __func__);
+ } else {
+ const GpsMeasurementInterface* gpsMeasurementIface =
+ static_cast<const GpsMeasurementInterface*>(
+ mGnssIface->get_extension(GPS_MEASUREMENT_INTERFACE));
+
+ if (gpsMeasurementIface == nullptr) {
+ ALOGE("%s GnssMeasurement interface not implemented by GNSS HAL", __func__);
+ } else {
+ mGnssMeasurement = new GnssMeasurement(gpsMeasurementIface);
+ }
+ }
+ _hidl_cb(mGnssMeasurement);
+ return Void();
+}
+
+Return<void> Gnss::getExtensionGnssNavigationMessage(
+ getExtensionGnssNavigationMessage_cb _hidl_cb) {
+ if (mGnssIface == nullptr) {
+ ALOGE("%s: Gnss interface is unavailable", __func__);
+ } else {
+ const GpsNavigationMessageInterface* gpsNavigationMessageIface =
+ static_cast<const GpsNavigationMessageInterface*>(
+ mGnssIface->get_extension(GPS_NAVIGATION_MESSAGE_INTERFACE));
+
+ if (gpsNavigationMessageIface == nullptr) {
+ ALOGE("%s GnssNavigationMessage interface not implemented by GNSS HAL",
+ __func__);
+ } else {
+ mGnssNavigationMessage = new GnssNavigationMessage(gpsNavigationMessageIface);
+ }
+ }
+
+ _hidl_cb(mGnssNavigationMessage);
+ return Void();
+}
+
+Return<void> Gnss::getExtensionXtra(getExtensionXtra_cb _hidl_cb) {
+ if (mGnssIface == nullptr) {
+ ALOGE("%s: Gnss interface is unavailable", __func__);
+ } else {
+ const GpsXtraInterface* gpsXtraIface = static_cast<const GpsXtraInterface*>(
+ mGnssIface->get_extension(GPS_XTRA_INTERFACE));
+
+ if (gpsXtraIface == nullptr) {
+ ALOGE("%s GnssXtra interface not implemented by HAL", __func__);
+ } else {
+ mGnssXtraIface = new GnssXtra(gpsXtraIface);
+ }
+ }
+
+ _hidl_cb(mGnssXtraIface);
+ return Void();
+}
+
+Return<void> Gnss::getExtensionGnssDebug(getExtensionGnssDebug_cb _hidl_cb) {
+ if (mGnssIface == nullptr) {
+ ALOGE("%s: Gnss interface is unavailable", __func__);
+ } else {
+ const GpsDebugInterface* gpsDebugIface = static_cast<const GpsDebugInterface*>(
+ mGnssIface->get_extension(GPS_DEBUG_INTERFACE));
+
+ if (gpsDebugIface == nullptr) {
+ ALOGE("%s: GnssDebug interface is not implemented by HAL", __func__);
+ } else {
+ mGnssDebug = new GnssDebug(gpsDebugIface);
+ }
+ }
+
+ _hidl_cb(mGnssDebug);
+ return Void();
+}
+
+IGnss* HIDL_FETCH_IGnss(const char* hal) {
+ hw_module_t* module;
+ IGnss* iface = nullptr;
+ int err = hw_get_module(GPS_HARDWARE_MODULE_ID, (hw_module_t const**)&module);
+
+ if (err == 0) {
+ hw_device_t* device;
+ err = module->methods->open(module, GPS_HARDWARE_MODULE_ID, &device);
+ if (err == 0) {
+ iface = new Gnss(reinterpret_cast<gps_device_t*>(device));
+ } else {
+ ALOGE("gnssDevice open %s failed: %d", hal, err);
+ }
+ } else {
+ ALOGE("gnss hw_get_module %s failed: %d", hal, err);
+ }
+ return iface;
+}
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace gnss
+} // namespace hardware
+} // namespace android
diff --git a/gnss/1.0/default/Gnss.h b/gnss/1.0/default/Gnss.h
new file mode 100644
index 0000000..a2c8676
--- /dev/null
+++ b/gnss/1.0/default/Gnss.h
@@ -0,0 +1,137 @@
+/*
+ * 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 android_hardware_gnss_V1_0_Gnss_H_
+#define android_hardware_gnss_V1_0_Gnss_H_
+
+#include <AGnss.h>
+#include <AGnssRil.h>
+#include <GnssConfiguration.h>
+#include <GnssDebug.h>
+#include <GnssGeofencing.h>
+#include <GnssMeasurement.h>
+#include <GnssNavigationMessage.h>
+#include <GnssNi.h>
+#include <GnssXtra.h>
+
+#include <ThreadCreationWrapper.h>
+#include <android/hardware/gnss/1.0/IGnss.h>
+#include <hardware/gps.h>
+#include <hidl/Status.h>
+
+namespace android {
+namespace hardware {
+namespace gnss {
+namespace V1_0 {
+namespace implementation {
+
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+using ::android::hardware::hidl_vec;
+using ::android::hardware::hidl_string;
+using ::android::sp;
+
+using LegacyGnssSystemInfo = ::GnssSystemInfo;
+
+/*
+ * Represents the standard GNSS interface. Also contains wrapper methods to allow methods from
+ * IGnssCallback interface to be passed into the conventional implementation of the GNSS HAL.
+ */
+struct Gnss : public IGnss {
+ Gnss(gps_device_t* gnss_device);
+ ~Gnss();
+
+ /*
+ * Methods from ::android::hardware::gnss::V1_0::IGnss follow.
+ * These declarations were generated from Gnss.hal.
+ */
+ Return<bool> setCallback(const sp<IGnssCallback>& callback) override;
+ Return<bool> start() override;
+ Return<bool> stop() override;
+ Return<void> cleanup() override;
+ Return<bool> injectLocation(double latitudeDegrees,
+ double longitudeDegrees,
+ float accuracyMeters) override;
+ Return<bool> injectTime(int64_t timeMs,
+ int64_t timeReferenceMs,
+ int32_t uncertaintyMs) override;
+ Return<void> deleteAidingData(IGnss::GnssAidingData aidingDataFlags) override;
+ Return<bool> setPositionMode(IGnss::GnssPositionMode mode,
+ IGnss::GnssPositionRecurrence recurrence,
+ uint32_t minIntervalMs,
+ uint32_t preferredAccuracyMeters,
+ uint32_t preferredTimeMs) override;
+ Return<void> getExtensionAGnssRil(getExtensionAGnssRil_cb _hidl_cb) override;
+ Return<void> getExtensionGnssGeofencing(getExtensionGnssGeofencing_cb _hidl_cb) override;
+ Return<void> getExtensionAGnss(getExtensionAGnss_cb _hidl_cb) override;
+ Return<void> getExtensionGnssNi(getExtensionGnssNi_cb _hidl_cb) override;
+ Return<void> getExtensionGnssMeasurement(getExtensionGnssMeasurement_cb _hidl_cb) override;
+ Return<void> getExtensionGnssNavigationMessage(
+ getExtensionGnssNavigationMessage_cb _hidl_cb) override;
+ Return<void> getExtensionXtra(getExtensionXtra_cb _hidl_cb) override;
+ Return<void> getExtensionGnssDebug(getExtensionGnssDebug_cb _hidl_cb) override;
+ Return<void> getExtensionGnssConfiguration(getExtensionGnssConfiguration_cb _hidl_cb) override;
+
+ /*
+ * Callback methods to be passed into the conventional GNSS HAL by the default
+ * implementation. These methods are not part of the IGnss base class.
+ */
+ static void locationCb(GpsLocation* location);
+ static void statusCb(GpsStatus* gnss_status);
+ static void nmeaCb(GpsUtcTime timestamp, const char* nmea, int length);
+ static void setCapabilitiesCb(uint32_t capabilities);
+ static void acquireWakelockCb();
+ static void releaseWakelockCb();
+ static void requestUtcTimeCb();
+ static pthread_t createThreadCb(const char* name, void (*start)(void*), void* arg);
+ static void gnssSvStatusCb(GnssSvStatus* status);
+ /*
+ * Deprecated callback added for backward compatibility to devices that do
+ * not support GnssSvStatus.
+ */
+ static void gpsSvStatusCb(GpsSvStatus* status);
+ static void setSystemInfoCb(const LegacyGnssSystemInfo* info);
+
+ /*
+ * Holds function pointers to the callback methods.
+ */
+ static GpsCallbacks sGnssCb;
+
+ private:
+ sp<GnssXtra> mGnssXtraIface = nullptr;
+ sp<AGnssRil> mGnssRil = nullptr;
+ sp<GnssGeofencing> mGnssGeofencingIface = nullptr;
+ sp<AGnss> mAGnssIface = nullptr;
+ sp<GnssNi> mGnssNi = nullptr;
+ sp<GnssMeasurement> mGnssMeasurement = nullptr;
+ sp<GnssNavigationMessage> mGnssNavigationMessage = nullptr;
+ sp<GnssDebug> mGnssDebug = nullptr;
+ sp<GnssConfiguration> mGnssConfig = nullptr;
+ const GpsInterface* mGnssIface = nullptr;
+ static sp<IGnssCallback> sGnssCbIface;
+ static std::vector<std::unique_ptr<ThreadFuncArgs>> sThreadFuncArgsList;
+ static bool sInterfaceExists;
+};
+
+extern "C" IGnss* HIDL_FETCH_IGnss(const char* name);
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace gnss
+} // namespace hardware
+} // namespace android
+
+#endif // android_hardware_gnss_V1_0_Gnss_H_
diff --git a/gnss/1.0/default/GnssConfiguration.cpp b/gnss/1.0/default/GnssConfiguration.cpp
new file mode 100644
index 0000000..9031c06
--- /dev/null
+++ b/gnss/1.0/default/GnssConfiguration.cpp
@@ -0,0 +1,115 @@
+/*
+ * 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 "GnssHAL_GnssConfigurationInterface"
+
+#include "GnssConfiguration.h"
+
+namespace android {
+namespace hardware {
+namespace gnss {
+namespace V1_0 {
+namespace implementation {
+
+GnssConfiguration::GnssConfiguration(const GnssConfigurationInterface* gnssConfigInfc)
+ : mGnssConfigIface(gnssConfigInfc) {}
+
+// Methods from ::android::hardware::gps::V1_0::IGnssConfiguration follow.
+Return<bool> GnssConfiguration::setSuplEs(bool enabled) {
+ if (mGnssConfigIface == nullptr) {
+ ALOGE("%s: GNSS Configuration interface is not available.", __func__);
+ return false;
+ }
+
+ std::string config = "SUPL_ES=" + std::to_string(enabled ? 1 : 0) + "\n";
+ mGnssConfigIface->configuration_update(config.c_str(), config.size());
+ return true;
+}
+
+Return<bool> GnssConfiguration::setSuplVersion(uint32_t version) {
+ if (mGnssConfigIface == nullptr) {
+ ALOGE("%s: GNSS Configuration interface is not available.", __func__);
+ return false;
+ }
+
+ std::string config = "SUPL_VER=" + std::to_string(version) + "\n";
+ mGnssConfigIface->configuration_update(config.c_str(), config.size());
+
+ return true;
+}
+
+Return<bool> GnssConfiguration::setSuplMode(uint8_t mode) {
+ if (mGnssConfigIface == nullptr) {
+ ALOGE("%s: GNSS Configuration interface is not available.", __func__);
+ return false;
+ }
+
+ std::string config = "SUPL_MODE=" + std::to_string(mode) + "\n";
+ mGnssConfigIface->configuration_update(config.c_str(), config.size());
+ return true;
+}
+
+Return<bool> GnssConfiguration::setLppProfile(uint8_t lppProfile) {
+ if (mGnssConfigIface == nullptr) {
+ ALOGE("%s: GNSS Configuration interface is not available.", __func__);
+ return false;
+ }
+
+ std::string config = "LPP_PROFILE=" + std::to_string(lppProfile) + "\n";
+ mGnssConfigIface->configuration_update(config.c_str(), config.size());
+ return true;
+}
+
+Return<bool> GnssConfiguration::setGlonassPositioningProtocol(uint8_t protocol) {
+ if (mGnssConfigIface == nullptr) {
+ ALOGE("%s: GNSS Configuration interface is not available.", __func__);
+ return false;
+ }
+
+ std::string config = "A_GLONASS_POS_PROTOCOL_SELECT=" +
+ std::to_string(protocol) + "\n";
+ mGnssConfigIface->configuration_update(config.c_str(), config.size());
+ return true;
+}
+
+Return<bool> GnssConfiguration::setGpsLock(uint8_t lock) {
+ if (mGnssConfigIface == nullptr) {
+ ALOGE("%s: GNSS Configuration interface is not available.", __func__);
+ return false;
+ }
+
+ std::string config = "GPS_LOCK=" + std::to_string(lock) + "\n";
+ mGnssConfigIface->configuration_update(config.c_str(), config.size());
+ return true;
+}
+
+Return<bool> GnssConfiguration::setEmergencySuplPdn(bool enabled) {
+ if (mGnssConfigIface == nullptr) {
+ ALOGE("%s: GNSS Configuration interface is not available.", __func__);
+ return false;
+ }
+
+ std::string config = "USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL=" + std::to_string(enabled ? 1 : 0)
+ + "\n";
+ mGnssConfigIface->configuration_update(config.c_str(), config.size());
+ return true;
+}
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace gnss
+} // namespace hardware
+} // namespace android
diff --git a/gnss/1.0/default/GnssConfiguration.h b/gnss/1.0/default/GnssConfiguration.h
new file mode 100644
index 0000000..a6eca88
--- /dev/null
+++ b/gnss/1.0/default/GnssConfiguration.h
@@ -0,0 +1,66 @@
+/*
+ * 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 android_hardware_gnss_V1_0_GnssConfiguration_H_
+#define android_hardware_gnss_V1_0_GnssConfiguration_H_
+
+#include <android/hardware/gnss/1.0/IGnssConfiguration.h>
+#include <hardware/gps.h>
+#include <hidl/Status.h>
+
+namespace android {
+namespace hardware {
+namespace gnss {
+namespace V1_0 {
+namespace implementation {
+
+using ::android::hardware::gnss::V1_0::IGnssConfiguration;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+using ::android::hardware::hidl_vec;
+using ::android::hardware::hidl_string;
+using ::android::sp;
+
+/*
+ * Interface for passing GNSS configuration info from platform to HAL.
+ */
+struct GnssConfiguration : public IGnssConfiguration {
+ GnssConfiguration(const GnssConfigurationInterface* gnssConfigIface);
+
+ /*
+ * Methods from ::android::hardware::gnss::V1_0::IGnssConfiguration follow.
+ * These declarations were generated from IGnssConfiguration.hal.
+ */
+ Return<bool> setSuplVersion(uint32_t version) override;
+ Return<bool> setSuplMode(uint8_t mode) override;
+ Return<bool> setSuplEs(bool enabled) override;
+ Return<bool> setLppProfile(uint8_t lppProfile) override;
+ Return<bool> setGlonassPositioningProtocol(uint8_t protocol) override;
+ Return<bool> setEmergencySuplPdn(bool enable) override;
+ Return<bool> setGpsLock(uint8_t lock) override;
+
+ private:
+ const GnssConfigurationInterface* mGnssConfigIface = nullptr;
+};
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace gnss
+} // namespace hardware
+} // namespace android
+
+#endif // android_hardware_gnss_V1_0_GnssConfiguration_H_
diff --git a/gnss/1.0/default/GnssDebug.cpp b/gnss/1.0/default/GnssDebug.cpp
new file mode 100644
index 0000000..e227e17
--- /dev/null
+++ b/gnss/1.0/default/GnssDebug.cpp
@@ -0,0 +1,57 @@
+/*
+ * 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 "GnssHAL_GnssDebugInterface"
+
+#include "GnssDebug.h"
+
+namespace android {
+namespace hardware {
+namespace gnss {
+namespace V1_0 {
+namespace implementation {
+
+GnssDebug::GnssDebug(const GpsDebugInterface* gpsDebugIface) : mGnssDebugIface(gpsDebugIface) {}
+
+// Methods from ::android::hardware::gnss::V1_0::IGnssDebug follow.
+Return<void> GnssDebug::getDebugData(getDebugData_cb _hidl_cb) {
+ /*
+ * This is a new interface and hence there is no way to retrieve the
+ * debug data from the HAL.
+ */
+ DebugData data = {};
+
+ _hidl_cb(data);
+
+ /*
+ * Log the debug data sent from the conventional Gnss HAL. This code is
+ * moved here from GnssLocationProvider.
+ */
+ if (mGnssDebugIface) {
+ char buffer[kMaxDebugStrLen + 1];
+ size_t length = mGnssDebugIface->get_internal_state(buffer, kMaxDebugStrLen);
+ length = std::max(length, kMaxDebugStrLen);
+ buffer[length] = '\0';
+ ALOGD("Gnss Debug Data: %s", buffer);
+ }
+ return Void();
+}
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace gnss
+} // namespace hardware
+} // namespace android
diff --git a/gnss/1.0/default/GnssDebug.h b/gnss/1.0/default/GnssDebug.h
new file mode 100644
index 0000000..9a17dde
--- /dev/null
+++ b/gnss/1.0/default/GnssDebug.h
@@ -0,0 +1,62 @@
+/*
+ * 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 android_hardware_gnss_V1_0_GnssDebug_H_
+#define android_hardware_gnss_V1_0_GnssDebug_H_
+
+#include <android/hardware/gnss/1.0/IGnssDebug.h>
+#include <hidl/Status.h>
+#include <hardware/gps.h>
+
+namespace android {
+namespace hardware {
+namespace gnss {
+namespace V1_0 {
+namespace implementation {
+
+using ::android::hardware::gnss::V1_0::IGnssDebug;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+using ::android::hardware::hidl_vec;
+using ::android::hardware::hidl_string;
+using ::android::sp;
+
+/* Interface for GNSS Debug support. */
+struct GnssDebug : public IGnssDebug {
+ GnssDebug(const GpsDebugInterface* gpsDebugIface);
+
+ /*
+ * Methods from ::android::hardware::gnss::V1_0::IGnssDebug follow.
+ * These declarations were generated from IGnssDebug.hal.
+ */
+ Return<void> getDebugData(getDebugData_cb _hidl_cb) override;
+
+ private:
+ /*
+ * Constant added for backward compatibility to conventional GPS Hals which
+ * returned a debug string.
+ */
+ const size_t kMaxDebugStrLen = 2047;
+ const GpsDebugInterface* mGnssDebugIface = nullptr;
+};
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace gnss
+} // namespace hardware
+} // namespace android
+
+#endif // android_hardware_gnss_V1_0_GnssDebug_H_
diff --git a/gnss/1.0/default/GnssGeofencing.cpp b/gnss/1.0/default/GnssGeofencing.cpp
new file mode 100644
index 0000000..f42de42
--- /dev/null
+++ b/gnss/1.0/default/GnssGeofencing.cpp
@@ -0,0 +1,206 @@
+/*
+ * 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 "GnssHal_GnssGeofencing"
+
+#include "GnssGeofencing.h"
+#include <GnssUtils.h>
+
+namespace android {
+namespace hardware {
+namespace gnss {
+namespace V1_0 {
+namespace implementation {
+
+std::vector<std::unique_ptr<ThreadFuncArgs>> GnssGeofencing::sThreadFuncArgsList;
+sp<IGnssGeofenceCallback> GnssGeofencing::mGnssGeofencingCbIface = nullptr;
+bool GnssGeofencing::sInterfaceExists = false;
+
+GpsGeofenceCallbacks GnssGeofencing::sGnssGfCb = {
+ .geofence_transition_callback = gnssGfTransitionCb,
+ .geofence_status_callback = gnssGfStatusCb,
+ .geofence_add_callback = gnssGfAddCb,
+ .geofence_remove_callback = gnssGfRemoveCb,
+ .geofence_pause_callback = gnssGfPauseCb,
+ .geofence_resume_callback = gnssGfResumeCb,
+ .create_thread_cb = createThreadCb
+};
+
+GnssGeofencing::GnssGeofencing(const GpsGeofencingInterface* gpsGeofencingIface)
+ : mGnssGeofencingIface(gpsGeofencingIface) {
+ /* Error out if an instance of the interface already exists. */
+ LOG_ALWAYS_FATAL_IF(sInterfaceExists);
+ sInterfaceExists = true;
+}
+
+GnssGeofencing::~GnssGeofencing() {
+ sThreadFuncArgsList.clear();
+}
+void GnssGeofencing::gnssGfTransitionCb(int32_t geofenceId,
+ GpsLocation* location,
+ int32_t transition,
+ GpsUtcTime timestamp) {
+ if (mGnssGeofencingCbIface == nullptr) {
+ ALOGE("%s: GNSS Geofence Callback Interface configured incorrectly", __func__);
+ return;
+ }
+
+ if (location == nullptr) {
+ ALOGE("%s : Invalid location from GNSS HAL", __func__);
+ return;
+ }
+
+ GnssLocation gnssLocation = convertToGnssLocation(location);
+ mGnssGeofencingCbIface->gnssGeofenceTransitionCb(
+ geofenceId,
+ gnssLocation,
+ static_cast<IGnssGeofenceCallback::GeofenceTransition>(transition),
+ timestamp);
+}
+
+void GnssGeofencing::gnssGfStatusCb(int32_t status, GpsLocation* location) {
+ if (mGnssGeofencingCbIface == nullptr) {
+ ALOGE("%s: GNSS Geofence Callback Interface configured incorrectly", __func__);
+ return;
+ }
+
+ GnssLocation gnssLocation;
+
+ if (location != nullptr) {
+ gnssLocation = convertToGnssLocation(location);
+ } else {
+ gnssLocation = {};
+ }
+
+ mGnssGeofencingCbIface->gnssGeofenceStatusCb(
+ static_cast<IGnssGeofenceCallback::GeofenceAvailability>(status), gnssLocation);
+}
+
+void GnssGeofencing::gnssGfAddCb(int32_t geofenceId, int32_t status) {
+ if (mGnssGeofencingCbIface == nullptr) {
+ ALOGE("%s: GNSS Geofence Callback Interface configured incorrectly", __func__);
+ return;
+ }
+
+ mGnssGeofencingCbIface->gnssGeofenceAddCb(
+ geofenceId, static_cast<IGnssGeofenceCallback::GeofenceStatus>(status));
+}
+
+void GnssGeofencing::gnssGfRemoveCb(int32_t geofenceId, int32_t status) {
+ if (mGnssGeofencingCbIface == nullptr) {
+ ALOGE("%s: GNSS Geofence Callback Interface configured incorrectly", __func__);
+ return;
+ }
+
+ mGnssGeofencingCbIface->gnssGeofenceRemoveCb(
+ geofenceId, static_cast<IGnssGeofenceCallback::GeofenceStatus>(status));
+}
+
+void GnssGeofencing::gnssGfPauseCb(int32_t geofenceId, int32_t status) {
+ if (mGnssGeofencingCbIface == nullptr) {
+ ALOGE("%s: GNSS Geofence Callback Interface configured incorrectly", __func__);
+ return;
+ }
+
+ mGnssGeofencingCbIface->gnssGeofencePauseCb(
+ geofenceId, static_cast<IGnssGeofenceCallback::GeofenceStatus>(status));
+}
+
+void GnssGeofencing::gnssGfResumeCb(int32_t geofenceId, int32_t status) {
+ if (mGnssGeofencingCbIface == nullptr) {
+ ALOGE("%s: GNSS Geofence Callback Interface configured incorrectly", __func__);
+ return;
+ }
+
+ mGnssGeofencingCbIface->gnssGeofenceResumeCb(
+ geofenceId, static_cast<IGnssGeofenceCallback::GeofenceStatus>(status));
+}
+
+pthread_t GnssGeofencing::createThreadCb(const char* name, void (*start)(void*), void* arg) {
+ return createPthread(name, start, arg, &sThreadFuncArgsList);
+}
+
+// Methods from ::android::hardware::gnss::V1_0::IGnssGeofencing follow.
+Return<void> GnssGeofencing::setCallback(const sp<IGnssGeofenceCallback>& callback) {
+ mGnssGeofencingCbIface = callback;
+
+ if (mGnssGeofencingIface == nullptr) {
+ ALOGE("%s: GnssGeofencing interface is not available", __func__);
+ } else {
+ mGnssGeofencingIface->init(&sGnssGfCb);
+ }
+
+ return Void();
+}
+
+Return<void> GnssGeofencing::addGeofence(
+ int32_t geofenceId,
+ double latitudeDegrees,
+ double longitudeDegrees,
+ double radiusMeters,
+ IGnssGeofenceCallback::GeofenceTransition lastTransition,
+ int32_t monitorTransitions,
+ uint32_t notificationResponsivenessMs,
+ uint32_t unknownTimerMs) {
+ if (mGnssGeofencingIface == nullptr) {
+ ALOGE("%s: GnssGeofencing interface is not available", __func__);
+ return Void();
+ } else {
+ mGnssGeofencingIface->add_geofence_area(
+ geofenceId,
+ latitudeDegrees,
+ longitudeDegrees,
+ radiusMeters,
+ static_cast<int32_t>(lastTransition),
+ monitorTransitions,
+ notificationResponsivenessMs,
+ unknownTimerMs);
+ }
+ return Void();
+}
+
+Return<void> GnssGeofencing::pauseGeofence(int32_t geofenceId) {
+ if (mGnssGeofencingIface == nullptr) {
+ ALOGE("%s: GnssGeofencing interface is not available", __func__);
+ } else {
+ mGnssGeofencingIface->pause_geofence(geofenceId);
+ }
+ return Void();
+}
+
+Return<void> GnssGeofencing::resumeGeofence(int32_t geofenceId, int32_t monitorTransitions) {
+ if (mGnssGeofencingIface == nullptr) {
+ ALOGE("%s: GnssGeofencing interface is not available", __func__);
+ } else {
+ mGnssGeofencingIface->resume_geofence(geofenceId, monitorTransitions);
+ }
+ return Void();
+}
+
+Return<void> GnssGeofencing::removeGeofence(int32_t geofenceId) {
+ if (mGnssGeofencingIface == nullptr) {
+ ALOGE("%s: GnssGeofencing interface is not available", __func__);
+ } else {
+ mGnssGeofencingIface->remove_geofence_area(geofenceId);
+ }
+ return Void();
+}
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace gnss
+} // namespace hardware
+} // namespace android
diff --git a/gnss/1.0/default/GnssGeofencing.h b/gnss/1.0/default/GnssGeofencing.h
new file mode 100644
index 0000000..124b893
--- /dev/null
+++ b/gnss/1.0/default/GnssGeofencing.h
@@ -0,0 +1,97 @@
+/*
+ * 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 android_hardware_gnss_V1_0_GnssGeofencing_H_
+#define android_hardware_gnss_V1_0_GnssGeofencing_H_
+
+#include <ThreadCreationWrapper.h>
+#include <android/hardware/gnss/1.0/IGnssGeofencing.h>
+#include <hidl/Status.h>
+#include <hardware/gps.h>
+
+namespace android {
+namespace hardware {
+namespace gnss {
+namespace V1_0 {
+namespace implementation {
+
+using ::android::hardware::gnss::V1_0::IGnssGeofenceCallback;
+using ::android::hardware::gnss::V1_0::IGnssGeofencing;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+using ::android::hardware::hidl_vec;
+using ::android::hardware::hidl_string;
+using ::android::sp;
+
+/*
+ * Interface for GNSS Geofencing support. It also contains wrapper methods to allow
+ * methods from IGnssGeofenceCallback interface to be passed into the
+ * conventional implementation of the GNSS HAL.
+ */
+struct GnssGeofencing : public IGnssGeofencing {
+ GnssGeofencing(const GpsGeofencingInterface* gpsGeofencingIface);
+ ~GnssGeofencing();
+
+ /*
+ * Methods from ::android::hardware::gnss::V1_0::IGnssGeofencing follow.
+ * These declarations were generated from IGnssGeofencing.hal.
+ */
+ Return<void> setCallback(const sp<IGnssGeofenceCallback>& callback) override;
+ Return<void> addGeofence(int32_t geofenceId,
+ double latitudeDegrees,
+ double longitudeDegrees,
+ double radiusMeters,
+ IGnssGeofenceCallback::GeofenceTransition lastTransition,
+ int32_t monitorTransitions,
+ uint32_t notificationResponsivenessMs,
+ uint32_t unknownTimerMs) override;
+
+ Return<void> pauseGeofence(int32_t geofenceId) override;
+ Return<void> resumeGeofence(int32_t geofenceId, int32_t monitorTransitions) override;
+ Return<void> removeGeofence(int32_t geofenceId) override;
+
+ /*
+ * Callback methods to be passed into the conventional GNSS HAL by the default
+ * implementation. These methods are not part of the IGnssGeofencing base class.
+ */
+ static void gnssGfTransitionCb(int32_t geofence_id, GpsLocation* location,
+ int32_t transition, GpsUtcTime timestamp);
+ static void gnssGfStatusCb(int32_t status, GpsLocation* last_location);
+ static void gnssGfAddCb(int32_t geofence_id, int32_t status);
+ static void gnssGfRemoveCb(int32_t geofence_id, int32_t status);
+ static void gnssGfPauseCb(int32_t geofence_id, int32_t status);
+ static void gnssGfResumeCb(int32_t geofence_id, int32_t status);
+ static pthread_t createThreadCb(const char* name, void (*start)(void*), void* arg);
+
+ /*
+ * Holds function pointers to the callback methods.
+ */
+ static GpsGeofenceCallbacks sGnssGfCb;
+
+ private:
+ static std::vector<std::unique_ptr<ThreadFuncArgs>> sThreadFuncArgsList;
+ static sp<IGnssGeofenceCallback> mGnssGeofencingCbIface;
+ const GpsGeofencingInterface* mGnssGeofencingIface = nullptr;
+ static bool sInterfaceExists;
+};
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace gnss
+} // namespace hardware
+} // namespace android
+
+#endif // android_hardware_gnss_V1_0_GnssGeofencing_H_
diff --git a/gnss/1.0/default/GnssMeasurement.cpp b/gnss/1.0/default/GnssMeasurement.cpp
new file mode 100644
index 0000000..9f8d7b5
--- /dev/null
+++ b/gnss/1.0/default/GnssMeasurement.cpp
@@ -0,0 +1,255 @@
+/*
+ * 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 "GnssHAL_GnssMeasurementInterface"
+
+#include "GnssMeasurement.h"
+
+namespace android {
+namespace hardware {
+namespace gnss {
+namespace V1_0 {
+namespace implementation {
+
+sp<IGnssMeasurementCallback> GnssMeasurement::sGnssMeasureCbIface = nullptr;
+GpsMeasurementCallbacks GnssMeasurement::sGnssMeasurementCbs = {
+ .size = sizeof(GpsMeasurementCallbacks),
+ .measurement_callback = gpsMeasurementCb,
+ .gnss_measurement_callback = gnssMeasurementCb
+};
+
+GnssMeasurement::GnssMeasurement(const GpsMeasurementInterface* gpsMeasurementIface)
+ : mGnssMeasureIface(gpsMeasurementIface) {}
+
+void GnssMeasurement::gnssMeasurementCb(LegacyGnssData* legacyGnssData) {
+ if (sGnssMeasureCbIface == nullptr) {
+ ALOGE("%s: GNSSMeasurement Callback Interface configured incorrectly", __func__);
+ return;
+ }
+
+ if (legacyGnssData == nullptr) {
+ ALOGE("%s: Invalid GnssData from GNSS HAL", __func__);
+ return;
+ }
+
+ IGnssMeasurementCallback::GnssData gnssData;
+ gnssData.measurementCount = std::min(legacyGnssData->measurement_count,
+ static_cast<size_t>(GnssMax::SVS_COUNT));
+
+ for (size_t i = 0; i < gnssData.measurementCount; i++) {
+ auto entry = legacyGnssData->measurements[i];
+ gnssData.measurements[i] = {
+ .flags = static_cast<IGnssMeasurementCallback::GnssMeasurementFlags>(entry.flags),
+ .svid = entry.svid,
+ .constellation = static_cast<GnssConstellationType>(entry.constellation),
+ .timeOffsetNs = entry.time_offset_ns,
+ .state = static_cast<IGnssMeasurementCallback::GnssMeasurementState>(entry.state),
+ .receivedSvTimeInNs = entry.received_sv_time_in_ns,
+ .receivedSvTimeUncertaintyInNs = entry.received_sv_time_uncertainty_in_ns,
+ .cN0DbHz = entry.c_n0_dbhz,
+ .pseudorangeRateMps = entry.pseudorange_rate_mps,
+ .pseudorangeRateUncertaintyMps = entry.pseudorange_rate_uncertainty_mps,
+ .accumulatedDeltaRangeState = static_cast<IGnssMeasurementCallback::GnssAccumulatedDeltaRangeState>(
+ entry.accumulated_delta_range_state),
+ .accumulatedDeltaRangeM = entry.accumulated_delta_range_m,
+ .accumulatedDeltaRangeUncertaintyM = entry.accumulated_delta_range_uncertainty_m,
+ .carrierFrequencyHz = entry.carrier_frequency_hz,
+ .carrierCycles = entry.carrier_cycles,
+ .carrierPhase = entry.carrier_phase,
+ .carrierPhaseUncertainty = entry.carrier_phase_uncertainty,
+ .multipathIndicator = static_cast<IGnssMeasurementCallback::GnssMultipathIndicator>(
+ entry.multipath_indicator),
+ .snrDb = entry.snr_db
+ };
+ }
+
+ auto clockVal = legacyGnssData->clock;
+ gnssData.clock = {
+ .gnssClockFlags = static_cast<IGnssMeasurementCallback::GnssClockFlags>(clockVal.flags),
+ .leapSecond = clockVal.leap_second,
+ .timeNs = clockVal.time_ns,
+ .timeUncertaintyNs = clockVal.time_uncertainty_ns,
+ .fullBiasNs = clockVal.full_bias_ns,
+ .biasNs = clockVal.bias_ns,
+ .biasUncertaintyNs = clockVal.bias_uncertainty_ns,
+ .driftNsps = clockVal.drift_nsps,
+ .driftUncertaintyNsps = clockVal.drift_uncertainty_nsps,
+ .hwClockDiscontinuityCount = clockVal.hw_clock_discontinuity_count
+ };
+
+ sGnssMeasureCbIface->GnssMeasurementCb(gnssData);
+}
+
+/*
+ * The code in the following method has been moved here from GnssLocationProvider.
+ * It converts GpsData to GnssData. This code is no longer required in
+ * GnssLocationProvider since GpsData is deprecated and no longer part of the
+ * GNSS interface.
+ */
+void GnssMeasurement::gpsMeasurementCb(GpsData* gpsData) {
+ if (sGnssMeasureCbIface == nullptr) {
+ ALOGE("%s: GNSSMeasurement Callback Interface configured incorrectly", __func__);
+ return;
+ }
+
+ if (gpsData == nullptr) {
+ ALOGE("%s: Invalid GpsData from GNSS HAL", __func__);
+ return;
+ }
+
+ IGnssMeasurementCallback::GnssData gnssData;
+ gnssData.measurementCount = std::min(gpsData->measurement_count,
+ static_cast<size_t>(GnssMax::SVS_COUNT));
+
+
+ for (size_t i = 0; i < gnssData.measurementCount; i++) {
+ auto entry = gpsData->measurements[i];
+ gnssData.measurements[i].flags =
+ static_cast<IGnssMeasurementCallback::GnssMeasurementFlags>(
+ entry.flags);
+ gnssData.measurements[i].svid = static_cast<int32_t>(entry.prn);
+ if (entry.prn >= 1 && entry.prn <= 32) {
+ gnssData.measurements[i].constellation = GnssConstellationType::GPS;
+ } else {
+ gnssData.measurements[i].constellation =
+ GnssConstellationType::UNKNOWN;
+ }
+
+ gnssData.measurements[i].timeOffsetNs = entry.time_offset_ns;
+ gnssData.measurements[i].state =
+ static_cast<IGnssMeasurementCallback::GnssMeasurementState>(
+ entry.state);
+ gnssData.measurements[i].receivedSvTimeInNs = entry.received_gps_tow_ns;
+ gnssData.measurements[i].receivedSvTimeUncertaintyInNs =
+ entry.received_gps_tow_uncertainty_ns;
+ gnssData.measurements[i].cN0DbHz = entry.c_n0_dbhz;
+ gnssData.measurements[i].pseudorangeRateMps = entry.pseudorange_rate_mps;
+ gnssData.measurements[i].pseudorangeRateUncertaintyMps =
+ entry.pseudorange_rate_uncertainty_mps;
+ gnssData.measurements[i].accumulatedDeltaRangeState =
+ static_cast<IGnssMeasurementCallback::GnssAccumulatedDeltaRangeState>(
+ entry.accumulated_delta_range_state);
+ gnssData.measurements[i].accumulatedDeltaRangeM =
+ entry.accumulated_delta_range_m;
+ gnssData.measurements[i].accumulatedDeltaRangeUncertaintyM =
+ entry.accumulated_delta_range_uncertainty_m;
+
+ if (entry.flags & GNSS_MEASUREMENT_HAS_CARRIER_FREQUENCY) {
+ gnssData.measurements[i].carrierFrequencyHz = entry.carrier_frequency_hz;
+ } else {
+ gnssData.measurements[i].carrierFrequencyHz = 0;
+ }
+
+ if (entry.flags & GNSS_MEASUREMENT_HAS_CARRIER_PHASE) {
+ gnssData.measurements[i].carrierPhase = entry.carrier_phase;
+ } else {
+ gnssData.measurements[i].carrierPhase = 0;
+ }
+
+ if (entry.flags & GNSS_MEASUREMENT_HAS_CARRIER_PHASE_UNCERTAINTY) {
+ gnssData.measurements[i].carrierPhaseUncertainty = entry.carrier_phase_uncertainty;
+ } else {
+ gnssData.measurements[i].carrierPhaseUncertainty = 0;
+ }
+
+ gnssData.measurements[i].multipathIndicator =
+ static_cast<IGnssMeasurementCallback::GnssMultipathIndicator>(
+ entry.multipath_indicator);
+
+ if (entry.flags & GNSS_MEASUREMENT_HAS_SNR) {
+ gnssData.measurements[i].snrDb = entry.snr_db;
+ } else {
+ gnssData.measurements[i].snrDb = 0;
+ }
+ }
+
+ auto clockVal = gpsData->clock;
+ static uint32_t discontinuity_count_to_handle_old_clock_type = 0;
+ auto flags = clockVal.flags;
+
+ gnssData.clock.leapSecond = clockVal.leap_second;
+ /*
+ * GnssClock only supports the more effective HW_CLOCK type, so type
+ * handling and documentation complexity has been removed. To convert the
+ * old GPS_CLOCK types (active only in a limited number of older devices),
+ * the GPS time information is handled as an always discontinuous HW clock,
+ * with the GPS time information put into the full_bias_ns instead - so that
+ * time_ns - full_bias_ns = local estimate of GPS time. Additionally, the
+ * sign of full_bias_ns and bias_ns has flipped between GpsClock &
+ * GnssClock, so that is also handled below.
+ */
+ switch (clockVal.type) {
+ case GPS_CLOCK_TYPE_UNKNOWN:
+ // Clock type unsupported.
+ ALOGE("Unknown clock type provided.");
+ break;
+ case GPS_CLOCK_TYPE_LOCAL_HW_TIME:
+ // Already local hardware time. No need to do anything.
+ break;
+ case GPS_CLOCK_TYPE_GPS_TIME:
+ // GPS time, need to convert.
+ flags |= GPS_CLOCK_HAS_FULL_BIAS;
+ clockVal.full_bias_ns = clockVal.time_ns;
+ clockVal.time_ns = 0;
+ gnssData.clock.hwClockDiscontinuityCount =
+ discontinuity_count_to_handle_old_clock_type++;
+ break;
+ }
+
+ gnssData.clock.timeNs = clockVal.time_ns;
+ gnssData.clock.timeUncertaintyNs = clockVal.time_uncertainty_ns;
+ /*
+ * Definition of sign for full_bias_ns & bias_ns has been changed since N,
+ * so flip signs here.
+ */
+ gnssData.clock.fullBiasNs = -(clockVal.full_bias_ns);
+ gnssData.clock.biasNs = -(clockVal.bias_ns);
+ gnssData.clock.biasUncertaintyNs = clockVal.bias_uncertainty_ns;
+ gnssData.clock.driftNsps = clockVal.drift_nsps;
+ gnssData.clock.driftUncertaintyNsps = clockVal.drift_uncertainty_nsps;
+ gnssData.clock.gnssClockFlags =
+ static_cast<IGnssMeasurementCallback::GnssClockFlags>(clockVal.flags);
+
+ sGnssMeasureCbIface->GnssMeasurementCb(gnssData);
+}
+
+// Methods from ::android::hardware::gnss::V1_0::IGnssMeasurement follow.
+Return<GnssMeasurement::GnssMeasurementStatus> GnssMeasurement::setCallback(
+ const sp<IGnssMeasurementCallback>& callback) {
+ if (mGnssMeasureIface == nullptr) {
+ ALOGE("%s: GnssMeasure interface is unavailable", __func__);
+ return GnssMeasurementStatus::ERROR_GENERIC;
+ }
+ sGnssMeasureCbIface = callback;
+
+ return static_cast<GnssMeasurement::GnssMeasurementStatus>(
+ mGnssMeasureIface->init(&sGnssMeasurementCbs));
+}
+
+Return<void> GnssMeasurement::close() {
+ if (mGnssMeasureIface == nullptr) {
+ ALOGE("%s: GnssMeasure interface is unavailable", __func__);
+ } else {
+ mGnssMeasureIface->close();
+ }
+ return Void();
+}
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace gnss
+} // namespace hardware
+} // namespace android
diff --git a/gnss/1.0/default/GnssMeasurement.h b/gnss/1.0/default/GnssMeasurement.h
new file mode 100644
index 0000000..9ff1435
--- /dev/null
+++ b/gnss/1.0/default/GnssMeasurement.h
@@ -0,0 +1,84 @@
+/*
+ * 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 android_hardware_gnss_V1_0_GnssMeasurement_H_
+#define android_hardware_gnss_V1_0_GnssMeasurement_H_
+
+#include <ThreadCreationWrapper.h>
+#include <android/hardware/gnss/1.0/IGnssMeasurement.h>
+#include <hidl/Status.h>
+#include <hardware/gps.h>
+
+namespace android {
+namespace hardware {
+namespace gnss {
+namespace V1_0 {
+namespace implementation {
+
+using ::android::hardware::gnss::V1_0::IGnssMeasurement;
+using ::android::hardware::gnss::V1_0::IGnssMeasurementCallback;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+using ::android::hardware::hidl_vec;
+using ::android::hardware::hidl_string;
+using ::android::sp;
+
+using LegacyGnssData = ::GnssData;
+
+/*
+ * Extended interface for GNSS Measurements support. Also contains wrapper methods to allow methods
+ * from IGnssMeasurementCallback interface to be passed into the conventional implementation of the
+ * GNSS HAL.
+ */
+struct GnssMeasurement : public IGnssMeasurement {
+ GnssMeasurement(const GpsMeasurementInterface* gpsMeasurementIface);
+
+ /*
+ * Methods from ::android::hardware::gnss::V1_0::IGnssMeasurement follow.
+ * These declarations were generated from IGnssMeasurement.hal.
+ */
+ Return<GnssMeasurementStatus> setCallback(
+ const sp<IGnssMeasurementCallback>& callback) override;
+ Return<void> close() override;
+
+ /*
+ * Callback methods to be passed into the conventional GNSS HAL by the default
+ * implementation. These methods are not part of the IGnssMeasurement base class.
+ */
+ static void gnssMeasurementCb(LegacyGnssData* data);
+ /*
+ * Deprecated callback added for backward compatibity for devices that do
+ * not support GnssData measurements.
+ */
+ static void gpsMeasurementCb(GpsData* data);
+
+ /*
+ * Holds function pointers to the callback methods.
+ */
+ static GpsMeasurementCallbacks sGnssMeasurementCbs;
+
+ private:
+ const GpsMeasurementInterface* mGnssMeasureIface = nullptr;
+ static sp<IGnssMeasurementCallback> sGnssMeasureCbIface;
+};
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace gnss
+} // namespace hardware
+} // namespace android
+
+#endif // android_hardware_gnss_V1_0_GnssMeasurement_H_
diff --git a/gnss/1.0/default/GnssNavigationMessage.cpp b/gnss/1.0/default/GnssNavigationMessage.cpp
new file mode 100644
index 0000000..edae938
--- /dev/null
+++ b/gnss/1.0/default/GnssNavigationMessage.cpp
@@ -0,0 +1,91 @@
+/*
+ * 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 "GnssHAL_GnssNavigationMessageInterface"
+
+#include "GnssNavigationMessage.h"
+
+namespace android {
+namespace hardware {
+namespace gnss {
+namespace V1_0 {
+namespace implementation {
+
+sp<IGnssNavigationMessageCallback> GnssNavigationMessage::sGnssNavigationMsgCbIface = nullptr;
+
+GpsNavigationMessageCallbacks GnssNavigationMessage::sGnssNavigationMessageCb = {
+ .size = sizeof(GpsNavigationMessageCallbacks),
+ .navigation_message_callback = nullptr,
+ .gnss_navigation_message_callback = gnssNavigationMessageCb
+};
+
+GnssNavigationMessage::GnssNavigationMessage(
+ const GpsNavigationMessageInterface* gpsNavigationMessageIface) :
+ mGnssNavigationMessageIface(gpsNavigationMessageIface) {}
+
+void GnssNavigationMessage::gnssNavigationMessageCb(LegacyGnssNavigationMessage* message) {
+ if (sGnssNavigationMsgCbIface == nullptr) {
+ ALOGE("%s: GnssNavigation Message Callback Interface configured incorrectly", __func__);
+ return;
+ }
+
+ if (message == nullptr) {
+ ALOGE("%s, received invalid GnssNavigationMessage from GNSS HAL", __func__);
+ return;
+ }
+
+ IGnssNavigationMessageCallback::GnssNavigationMessage navigationMsg;
+
+ navigationMsg.svid = message->svid;
+ navigationMsg.type =
+ static_cast<IGnssNavigationMessageCallback::GnssNavigationMessageType>(message->type);
+ navigationMsg.status =
+ static_cast<IGnssNavigationMessageCallback::NavigationMessageStatus>(message->status);
+ navigationMsg.messageId = message->message_id;
+ navigationMsg.submessageId = message->submessage_id;
+ navigationMsg.data.setToExternal(message->data, message->data_length);
+
+ sGnssNavigationMsgCbIface->gnssNavigationMessageCb(navigationMsg);
+}
+
+// Methods from ::android::hardware::gnss::V1_0::IGnssNavigationMessage follow.
+Return<GnssNavigationMessage::GnssNavigationMessageStatus> GnssNavigationMessage::setCallback(
+ const sp<IGnssNavigationMessageCallback>& callback) {
+ if (mGnssNavigationMessageIface == nullptr) {
+ ALOGE("%s: GnssNavigationMessage not available", __func__);
+ return GnssNavigationMessageStatus::ERROR_GENERIC;
+ }
+
+ sGnssNavigationMsgCbIface = callback;
+
+ return static_cast<GnssNavigationMessage::GnssNavigationMessageStatus>(
+ mGnssNavigationMessageIface->init(&sGnssNavigationMessageCb));
+}
+
+Return<void> GnssNavigationMessage::close() {
+ if (mGnssNavigationMessageIface == nullptr) {
+ ALOGE("%s: GnssNavigationMessage not available", __func__);
+ } else {
+ mGnssNavigationMessageIface->close();
+ }
+ return Void();
+}
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace gnss
+} // namespace hardware
+} // namespace android
diff --git a/gnss/1.0/default/GnssNavigationMessage.h b/gnss/1.0/default/GnssNavigationMessage.h
new file mode 100644
index 0000000..882854b
--- /dev/null
+++ b/gnss/1.0/default/GnssNavigationMessage.h
@@ -0,0 +1,77 @@
+/*
+ * 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 android_hardware_gnss_V1_0_GnssNavigationMessage_H_
+#define android_hardware_gnss_V1_0_GnssNavigationMessage_H_
+
+#include <android/hardware/gnss/1.0/IGnssNavigationMessage.h>
+#include <hidl/Status.h>
+#include <hardware/gps.h>
+
+namespace android {
+namespace hardware {
+namespace gnss {
+namespace V1_0 {
+namespace implementation {
+
+using ::android::hardware::gnss::V1_0::IGnssNavigationMessage;
+using ::android::hardware::gnss::V1_0::IGnssNavigationMessageCallback;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+using ::android::hardware::hidl_vec;
+using ::android::hardware::hidl_string;
+using ::android::sp;
+
+using LegacyGnssNavigationMessage = ::GnssNavigationMessage;
+
+/*
+ * Extended interface for GNSS navigation message reporting support. Also contains wrapper methods
+ * to allow methods from IGnssNavigationMessageCallback interface to be passed into the conventional
+ * implementation of the GNSS HAL.
+ */
+struct GnssNavigationMessage : public IGnssNavigationMessage {
+ GnssNavigationMessage(const GpsNavigationMessageInterface* gpsNavigationMessageIface);
+
+ /*
+ * Methods from ::android::hardware::gnss::V1_0::IGnssNavigationMessage follow.
+ * These declarations were generated from IGnssNavigationMessage.hal.
+ */
+ Return<GnssNavigationMessageStatus> setCallback(
+ const sp<IGnssNavigationMessageCallback>& callback) override;
+ Return<void> close() override;
+
+ /*
+ * Callback methods to be passed into the conventional GNSS HAL by the default implementation.
+ * These methods are not part of the IGnssNavigationMessage base class.
+ */
+ static void gnssNavigationMessageCb(LegacyGnssNavigationMessage* message);
+
+ /*
+ * Holds function pointers to the callback methods.
+ */
+ static GpsNavigationMessageCallbacks sGnssNavigationMessageCb;
+ private:
+ const GpsNavigationMessageInterface* mGnssNavigationMessageIface = nullptr;
+ static sp<IGnssNavigationMessageCallback> sGnssNavigationMsgCbIface;
+};
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace gnss
+} // namespace hardware
+} // namespace android
+
+#endif // android_hardware_gnss_V1_0_GnssNavigationMessage_H_
diff --git a/gnss/1.0/default/GnssNi.cpp b/gnss/1.0/default/GnssNi.cpp
new file mode 100644
index 0000000..10af1f4
--- /dev/null
+++ b/gnss/1.0/default/GnssNi.cpp
@@ -0,0 +1,106 @@
+/*
+ * 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 "GnssHAL_GnssNiInterface"
+
+#include "GnssNi.h"
+
+namespace android {
+namespace hardware {
+namespace gnss {
+namespace V1_0 {
+namespace implementation {
+
+std::vector<std::unique_ptr<ThreadFuncArgs>> GnssNi::sThreadFuncArgsList;
+sp<IGnssNiCallback> GnssNi::sGnssNiCbIface = nullptr;
+bool GnssNi::sInterfaceExists = false;
+
+GpsNiCallbacks GnssNi::sGnssNiCb = {
+ .notify_cb = niNotifyCb,
+ .create_thread_cb = createThreadCb
+};
+
+GnssNi::GnssNi(const GpsNiInterface* gpsNiIface) : mGnssNiIface(gpsNiIface) {
+ /* Error out if an instance of the interface already exists. */
+ LOG_ALWAYS_FATAL_IF(sInterfaceExists);
+ sInterfaceExists = true;
+}
+
+GnssNi::~GnssNi() {
+ sThreadFuncArgsList.clear();
+}
+
+pthread_t GnssNi::createThreadCb(const char* name, void (*start)(void*), void* arg) {
+ return createPthread(name, start, arg, &sThreadFuncArgsList);
+}
+
+void GnssNi::niNotifyCb(GpsNiNotification* notification) {
+ if (sGnssNiCbIface == nullptr) {
+ ALOGE("%s: GNSS NI Callback Interface configured incorrectly", __func__);
+ return;
+ }
+
+ if (notification == nullptr) {
+ ALOGE("%s: Invalid GpsNotification callback from GNSS HAL", __func__);
+ return;
+ }
+
+ IGnssNiCallback::GnssNiNotification notificationGnss = {
+ .notificationId = notification->notification_id,
+ .niType = static_cast<IGnssNiCallback::GnssNiType>(notification->ni_type),
+ .notifyFlags =
+ static_cast<IGnssNiCallback::GnssNiNotifyFlags>(notification->notify_flags),
+ .timeoutSec = static_cast<uint32_t>(notification->timeout),
+ .defaultResponse =
+ static_cast<IGnssNiCallback::GnssUserResponseType>(notification->default_response),
+ .requestorId = notification->requestor_id,
+ .notificationMessage = notification->text,
+ .requestorIdEncoding =
+ static_cast<IGnssNiCallback::GnssNiEncodingType>(notification->requestor_id_encoding),
+ .notificationIdEncoding =
+ static_cast<IGnssNiCallback::GnssNiEncodingType>(notification->text_encoding)
+ };
+
+ sGnssNiCbIface->niNotifyCb(notificationGnss);
+}
+
+// Methods from ::android::hardware::gnss::V1_0::IGnssNi follow.
+Return<void> GnssNi::setCallback(const sp<IGnssNiCallback>& callback) {
+ if (mGnssNiIface == nullptr) {
+ ALOGE("%s: GnssNi interface is unavailable", __func__);
+ return Void();
+ }
+
+ sGnssNiCbIface = callback;
+
+ mGnssNiIface->init(&sGnssNiCb);
+ return Void();
+}
+
+Return<void> GnssNi::respond(int32_t notifId, IGnssNiCallback::GnssUserResponseType userResponse) {
+ if (mGnssNiIface == nullptr) {
+ ALOGE("%s: GnssNi interface is unavailable", __func__);
+ } else {
+ mGnssNiIface->respond(notifId, static_cast<GpsUserResponseType>(userResponse));
+ }
+ return Void();
+}
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace gnss
+} // namespace hardware
+} // namespace android
diff --git a/gnss/1.0/default/GnssNi.h b/gnss/1.0/default/GnssNi.h
new file mode 100644
index 0000000..fe850b1
--- /dev/null
+++ b/gnss/1.0/default/GnssNi.h
@@ -0,0 +1,81 @@
+/*
+ * 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 android_hardware_gnss_V1_0_GnssNi_H_
+#define android_hardware_gnss_V1_0_GnssNi_H_
+
+#include <ThreadCreationWrapper.h>
+#include <android/hardware/gnss/1.0/IGnssNi.h>
+#include <hidl/Status.h>
+#include <hardware/gps.h>
+
+namespace android {
+namespace hardware {
+namespace gnss {
+namespace V1_0 {
+namespace implementation {
+
+using ::android::hardware::gnss::V1_0::IGnssNi;
+using ::android::hardware::gnss::V1_0::IGnssNiCallback;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+using ::android::hardware::hidl_vec;
+using ::android::hardware::hidl_string;
+using ::android::sp;
+
+/*
+ * Extended interface for Network-initiated (NI) support. This interface is used to respond to
+ * NI notifications originating from the HAL. Also contains wrapper methods to allow methods from
+ * IGnssNiCallback interface to be passed into the conventional implementation of the GNSS HAL.
+ */
+struct GnssNi : public IGnssNi {
+ GnssNi(const GpsNiInterface* gpsNiIface);
+ ~GnssNi();
+
+ /*
+ * Methods from ::android::hardware::gnss::V1_0::IGnssNi follow.
+ * These declarations were generated from IGnssNi.hal.
+ */
+ Return<void> setCallback(const sp<IGnssNiCallback>& callback) override;
+ Return<void> respond(int32_t notifId,
+ IGnssNiCallback::GnssUserResponseType userResponse) override;
+
+ /*
+ * Callback methods to be passed into the conventional GNSS HAL by the default
+ * implementation. These methods are not part of the IGnssNi base class.
+ */
+ static pthread_t createThreadCb(const char* name, void (*start)(void*), void* arg);
+ static void niNotifyCb(GpsNiNotification* notification);
+
+ /*
+ * Holds function pointers to the callback methods.
+ */
+ static GpsNiCallbacks sGnssNiCb;
+
+ private:
+ const GpsNiInterface* mGnssNiIface = nullptr;
+ static sp<IGnssNiCallback> sGnssNiCbIface;
+ static std::vector<std::unique_ptr<ThreadFuncArgs>> sThreadFuncArgsList;
+ static bool sInterfaceExists;
+};
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace gnss
+} // namespace hardware
+} // namespace android
+
+#endif // android_hardware_gnss_V1_0_GnssNi_H_
diff --git a/gnss/1.0/default/GnssUtils.cpp b/gnss/1.0/default/GnssUtils.cpp
new file mode 100644
index 0000000..9f7e356
--- /dev/null
+++ b/gnss/1.0/default/GnssUtils.cpp
@@ -0,0 +1,49 @@
+/*
+ * 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 "GnssUtils.h"
+
+namespace android {
+namespace hardware {
+namespace gnss {
+namespace V1_0 {
+namespace implementation {
+
+using android::hardware::gnss::V1_0::GnssLocation;
+
+GnssLocation convertToGnssLocation(GpsLocation* location) {
+ GnssLocation gnssLocation = {};
+ if (location != nullptr) {
+ gnssLocation = {
+ .gnssLocationFlags = location->flags,
+ .latitudeDegrees = location->latitude,
+ .longitudeDegrees = location->longitude,
+ .altitudeMeters = location->altitude,
+ .speedMetersPerSec = location->speed,
+ .bearingDegrees = location->bearing,
+ .accuracyMeters = location->accuracy,
+ .timestamp = location->timestamp
+ };
+ }
+
+ return gnssLocation;
+}
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace gnss
+} // namespace hardware
+} // namespace android
diff --git a/gnss/1.0/default/GnssUtils.h b/gnss/1.0/default/GnssUtils.h
new file mode 100644
index 0000000..fc2f547
--- /dev/null
+++ b/gnss/1.0/default/GnssUtils.h
@@ -0,0 +1,40 @@
+/*
+ * 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 android_hardware_gnss_V1_0_GnssUtil_H_
+#define android_hardware_gnss_V1_0_GnssUtil_H_
+
+#include <hardware/gps.h>
+#include <android/hardware/gnss/1.0/types.h>
+
+namespace android {
+namespace hardware {
+namespace gnss {
+namespace V1_0 {
+namespace implementation {
+
+/*
+ * This method converts a GpsLocation struct to a GnssLocation
+ * struct.
+ */
+GnssLocation convertToGnssLocation(GpsLocation* location);
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace gnss
+} // namespace hardware
+} // namespace android
+
+#endif
diff --git a/gnss/1.0/default/GnssXtra.cpp b/gnss/1.0/default/GnssXtra.cpp
new file mode 100644
index 0000000..065bb33
--- /dev/null
+++ b/gnss/1.0/default/GnssXtra.cpp
@@ -0,0 +1,91 @@
+/*
+ * 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 "GnssHAL_GnssXtraInterface"
+
+#include "GnssXtra.h"
+
+namespace android {
+namespace hardware {
+namespace gnss {
+namespace V1_0 {
+namespace implementation {
+
+std::vector<std::unique_ptr<ThreadFuncArgs>> GnssXtra::sThreadFuncArgsList;
+sp<IGnssXtraCallback> GnssXtra::sGnssXtraCbIface = nullptr;
+bool GnssXtra::sInterfaceExists = false;
+
+GpsXtraCallbacks GnssXtra::sGnssXtraCb = {
+ .download_request_cb = gnssXtraDownloadRequestCb,
+ .create_thread_cb = createThreadCb,
+};
+
+GnssXtra::~GnssXtra() {
+ sThreadFuncArgsList.clear();
+}
+
+pthread_t GnssXtra::createThreadCb(const char* name, void (*start)(void*), void* arg) {
+ return createPthread(name, start, arg, &sThreadFuncArgsList);
+}
+
+GnssXtra::GnssXtra(const GpsXtraInterface* xtraIface) : mGnssXtraIface(xtraIface) {
+ /* Error out if an instance of the interface already exists. */
+ LOG_ALWAYS_FATAL_IF(sInterfaceExists);
+ sInterfaceExists = true;
+}
+
+void GnssXtra::gnssXtraDownloadRequestCb() {
+ if (sGnssXtraCbIface == nullptr) {
+ ALOGE("%s: GNSS Callback Interface configured incorrectly", __func__);
+ return;
+ }
+
+ sGnssXtraCbIface->downloadRequestCb();
+}
+
+// Methods from ::android::hardware::gnss::V1_0::IGnssXtra follow.
+Return<bool> GnssXtra::setCallback(const sp<IGnssXtraCallback>& callback) {
+ if (mGnssXtraIface == nullptr) {
+ ALOGE("%s: Gnss Xtra interface is unavailable", __func__);
+ return false;
+ }
+
+ sGnssXtraCbIface = callback;
+
+ return (mGnssXtraIface->init(&sGnssXtraCb) == 0);
+}
+
+Return<bool> GnssXtra::injectXtraData(const hidl_string& xtraData) {
+ if (mGnssXtraIface == nullptr) {
+ ALOGE("%s: Gnss Xtra interface is unavailable", __func__);
+ return false;
+ }
+
+ char* buf = new char[xtraData.size()];
+ const char* data = xtraData.c_str();
+
+ memcpy(buf, data, xtraData.size());
+
+ int ret = mGnssXtraIface->inject_xtra_data(buf, xtraData.size());
+ delete[] buf;
+ return (ret == 0);
+}
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace gnss
+} // namespace hardware
+} // namespace android
diff --git a/gnss/1.0/default/GnssXtra.h b/gnss/1.0/default/GnssXtra.h
new file mode 100644
index 0000000..7a0733a
--- /dev/null
+++ b/gnss/1.0/default/GnssXtra.h
@@ -0,0 +1,80 @@
+/*
+ * 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 android_hardware_gnss_V1_0_GnssXtra_H_
+#define android_hardware_gnss_V1_0_GnssXtra_H_
+
+#include <ThreadCreationWrapper.h>
+#include <android/hardware/gnss/1.0/IGnssXtra.h>
+#include <hardware/gps.h>
+#include <hidl/Status.h>
+
+namespace android {
+namespace hardware {
+namespace gnss {
+namespace V1_0 {
+namespace implementation {
+
+using ::android::hardware::gnss::V1_0::IGnssXtra;
+using ::android::hardware::gnss::V1_0::IGnssXtraCallback;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+using ::android::hardware::hidl_vec;
+using ::android::hardware::hidl_string;
+using ::android::sp;
+
+/*
+ * This interface is used by the GNSS HAL to request the framework to download XTRA data.
+ * Also contains wrapper methods to allow methods from IGnssXtraCallback interface to be passed
+ * into the conventional implementation of the GNSS HAL.
+ */
+struct GnssXtra : public IGnssXtra {
+ GnssXtra(const GpsXtraInterface* xtraIface);
+ ~GnssXtra();
+
+ /*
+ * Methods from ::android::hardware::gnss::V1_0::IGnssXtra follow.
+ * These declarations were generated from IGnssXtra.hal.
+ */
+ Return<bool> setCallback(const sp<IGnssXtraCallback>& callback) override;
+ Return<bool> injectXtraData(const hidl_string& xtraData) override;
+
+ /*
+ * Callback methods to be passed into the conventional GNSS HAL by the default implementation.
+ * These methods are not part of the IGnssXtra base class.
+ */
+ static pthread_t createThreadCb(const char* name, void (*start)(void*), void* arg);
+ static void gnssXtraDownloadRequestCb();
+
+ /*
+ * Holds function pointers to the callback methods.
+ */
+ static GpsXtraCallbacks sGnssXtraCb;
+
+ private:
+ const GpsXtraInterface* mGnssXtraIface = nullptr;
+ static sp<IGnssXtraCallback> sGnssXtraCbIface;
+ static std::vector<std::unique_ptr<ThreadFuncArgs>> sThreadFuncArgsList;
+ static bool sInterfaceExists;
+};
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace gnss
+} // namespace hardware
+} // namespace android
+
+#endif // android_hardware_gnss_V1_0_GnssXtra_H_
diff --git a/gnss/1.0/default/ThreadCreationWrapper.cpp b/gnss/1.0/default/ThreadCreationWrapper.cpp
new file mode 100644
index 0000000..2a5638f
--- /dev/null
+++ b/gnss/1.0/default/ThreadCreationWrapper.cpp
@@ -0,0 +1,42 @@
+/*
+ * 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 <ThreadCreationWrapper.h>
+
+void* threadFunc(void* arg) {
+ ThreadFuncArgs* threadArgs = reinterpret_cast<ThreadFuncArgs*>(arg);
+ threadArgs->fptr(threadArgs->args);
+ return nullptr;
+}
+
+pthread_t createPthread(const char* name,
+ void (*start)(void*),
+ void* arg, std::vector<std::unique_ptr<ThreadFuncArgs>> * listArgs) {
+ pthread_t threadId;
+ auto threadArgs = new ThreadFuncArgs(start, arg);
+ auto argPtr = std::unique_ptr<ThreadFuncArgs>(threadArgs);
+
+ listArgs->push_back(std::move(argPtr));
+
+ int ret = pthread_create(&threadId, nullptr, threadFunc, reinterpret_cast<void*>(
+ threadArgs));
+ if (ret != 0) {
+ ALOGE("pthread creation unsuccessful");
+ } else {
+ pthread_setname_np(threadId, name);
+ }
+ return threadId;
+}
diff --git a/gnss/1.0/default/ThreadCreationWrapper.h b/gnss/1.0/default/ThreadCreationWrapper.h
new file mode 100644
index 0000000..df0a9e4
--- /dev/null
+++ b/gnss/1.0/default/ThreadCreationWrapper.h
@@ -0,0 +1,58 @@
+/*
+ * 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 ANDROID_HARDWARE_GNSS_THREADCREATIONWRAPPER_H
+#define ANDROID_HARDWARE_GNSS_THREADCREATIONWRAPPER_H
+
+#include <pthread.h>
+#include <vector>
+#include <cutils/log.h>
+
+typedef void (*threadEntryFunc)(void* ret);
+
+/*
+ * This class facilitates createThreadCb methods in various GNSS interfaces to wrap
+ * pthread_create() from libc since its function signature differs from what is required by the
+ * conventional GNSS HAL. The arguments passed to pthread_create() need to be on heap and not on
+ * the stack of createThreadCb.
+ */
+struct ThreadFuncArgs {
+ ThreadFuncArgs(void (*start)(void*), void* arg) : fptr(start), args(arg) {}
+
+ /* pointer to the function of type void()(void*) that needs to be wrapped */
+ threadEntryFunc fptr;
+ /* argument for fptr to be called with */
+ void* args;
+};
+
+/*
+ * This method is simply a wrapper. It is required since pthread_create() requires an entry
+ * function pointer of type void*()(void*) and the GNSS hal requires as input a function pointer of
+ * type void()(void*).
+ */
+void* threadFunc(void* arg);
+
+/*
+ * This method is called by createThreadCb with a pointer to the vector that
+ * holds the pointers to the thread arguments. The arg and start parameters are
+ * first used to create a ThreadFuncArgs object which is then saved in the
+ * listArgs parameters. The created ThreadFuncArgs object is then used to invoke
+ * threadFunc() method which in-turn invokes pthread_create.
+ */
+pthread_t createPthread(const char* name, void (*start)(void*), void* arg,
+ std::vector<std::unique_ptr<ThreadFuncArgs>> * listArgs);
+
+#endif
diff --git a/gnss/1.0/types.hal b/gnss/1.0/types.hal
index 3120648..ee35ca4 100644
--- a/gnss/1.0/types.hal
+++ b/gnss/1.0/types.hal
@@ -16,12 +16,9 @@
package android.hardware.gnss@1.0;
-enum ConstS32 : int32_t {
+enum GnssMax : uint32_t {
/** Maximum number of SVs for gnssSvStatusCb(). */
- GNSS_MAX_SVS = 64,
-
-/* Maximum number of Measurements in gnssMeasurementCb(). */
- GNSS_MAX_MEASUREMENT = 64,
+ SVS_COUNT = 64,
};
/* Milliseconds since January 1, 1970 */
@@ -32,7 +29,7 @@
*/
enum GnssConstellationType : uint8_t {
UNKNOWN = 0,
- GNSS = 1,
+ GPS = 1,
SBAS = 2,
GLONASS = 3,
QZSS = 4,
@@ -46,18 +43,18 @@
uint16_t gnssLocationFlags;
/* Represents latitude in degrees. */
- double latitude;
+ double latitudeDegrees;
/* Represents longitude in degrees. */
- double longitude;
+ double longitudeDegrees;
/*
* Represents altitude in meters above the WGS 84 reference ellipsoid.
*/
- double altitude;
+ double altitudeMeters;
/* Represents speed in meters per second. */
- float speedMetersperSec;
+ float speedMetersPerSec;
/* Represents heading in degrees. */
float bearingDegrees;
diff --git a/graphics/allocator/2.0/vts/functional/graphics_allocator_hidl_hal_test.cpp b/graphics/allocator/2.0/vts/functional/graphics_allocator_hidl_hal_test.cpp
index bd846c4..22131ee 100644
--- a/graphics/allocator/2.0/vts/functional/graphics_allocator_hidl_hal_test.cpp
+++ b/graphics/allocator/2.0/vts/functional/graphics_allocator_hidl_hal_test.cpp
@@ -307,7 +307,7 @@
::testing::InitGoogleTest(&argc, argv);
int status = RUN_ALL_TESTS();
- ALOGI("Test result = %d", status);
+ LOG(INFO) << "Test result = " << status;
return status;
}
diff --git a/light/2.0/default/Light.cpp b/light/2.0/default/Light.cpp
index eb1f559..f52c6af 100644
--- a/light/2.0/default/Light.cpp
+++ b/light/2.0/default/Light.cpp
@@ -13,6 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
+#define LOG_TAG "light"
+#include <android/log.h>
+
#include "Light.h"
namespace android {
diff --git a/light/2.0/vts/functional/Android.bp b/light/2.0/vts/functional/Android.bp
index c3475a6..b290b59 100644
--- a/light/2.0/vts/functional/Android.bp
+++ b/light/2.0/vts/functional/Android.bp
@@ -19,6 +19,7 @@
gtest: true,
srcs: ["light_hidl_hal_test.cpp"],
shared_libs: [
+ "libbase",
"liblog",
"libutils",
"android.hardware.light@2.0",
diff --git a/light/2.0/vts/functional/light_hidl_hal_test.cpp b/light/2.0/vts/functional/light_hidl_hal_test.cpp
index db67467..7c081e9 100644
--- a/light/2.0/vts/functional/light_hidl_hal_test.cpp
+++ b/light/2.0/vts/functional/light_hidl_hal_test.cpp
@@ -44,7 +44,7 @@
light = ILight::getService(LIGHT_SERVICE_NAME);
ASSERT_NE(light, nullptr);
- ALOGI("Test is remote: %d", light->isRemote());
+ LOG(INFO) << "Test is remote " << light->isRemote();
}
virtual void TearDown() override {}
@@ -98,6 +98,6 @@
::testing::AddGlobalTestEnvironment(new LightHidlEnvironment);
::testing::InitGoogleTest(&argc, argv);
int status = RUN_ALL_TESTS();
- ALOGI("Test result = %d", status);
+ LOG(INFO) << "Test result = " << status;
return status;
}
diff --git a/media/1.0/types.hal b/media/1.0/types.hal
index 25931f8..98dfe14 100644
--- a/media/1.0/types.hal
+++ b/media/1.0/types.hal
@@ -23,7 +23,6 @@
*/
typedef handle FileDescriptor; // This must have no more than one fd.
typedef FileDescriptor Fence;
-typedef int32_t Status; // TODO: convert to an enum
typedef vec<uint8_t> Bytes;
/**
diff --git a/media/omx/1.0/types.hal b/media/omx/1.0/types.hal
index 5918b59..79c3a44 100644
--- a/media/omx/1.0/types.hal
+++ b/media/omx/1.0/types.hal
@@ -22,6 +22,23 @@
typedef uint32_t BufferId;
/**
+ * Ref: system/core/include/utils/Errors.h
+ * Ref: bionic/libc/kernel/uapi/asm-generic/errno-base.h
+ * Ref: bionic/libc/kernel/uapi/asm-generic/errno.h
+ * Ref: frameworks/av/include/media/stagefright/MediaError.h
+ * Ref: frameworks/av/media/libstagefright/omx/OMXUtils.cpp: StatusFromOMXError
+ */
+enum Status : int32_t {
+ OK = 0,
+ NO_ERROR = 0,
+
+ NAME_NOT_FOUND = -2,
+ NO_MEMORY = -12,
+ ERROR_UNSUPPORTED = -1010,
+ UNKNOWN_ERROR = -2147483648,
+};
+
+/**
* Ref: frameworks/av/include/media/IOMX.h: omx_message
*
* Data structure for an OMX message. This is essentially a union of different
diff --git a/memtrack/1.0/default/Memtrack.cpp b/memtrack/1.0/default/Memtrack.cpp
index b953e7c..b93227f 100644
--- a/memtrack/1.0/default/Memtrack.cpp
+++ b/memtrack/1.0/default/Memtrack.cpp
@@ -17,6 +17,7 @@
#define LOG_TAG "android.hardware.memtrack@1.0-impl"
#include <hardware/hardware.h>
#include <hardware/memtrack.h>
+#include <android/log.h>
#include "Memtrack.h"
namespace android {
diff --git a/nfc/1.0/default/Nfc.cpp b/nfc/1.0/default/Nfc.cpp
index bee374d..44c8e42 100644
--- a/nfc/1.0/default/Nfc.cpp
+++ b/nfc/1.0/default/Nfc.cpp
@@ -1,5 +1,5 @@
#define LOG_TAG "android.hardware.nfc@1.0-impl"
-#include <utils/Log.h>
+#include <android/log.h>
#include <hardware/hardware.h>
#include <hardware/nfc.h>
diff --git a/nfc/1.0/vts/functional/nfc_hidl_hal_test.cpp b/nfc/1.0/vts/functional/nfc_hidl_hal_test.cpp
index 4d7c557..3e40a9c 100644
--- a/nfc/1.0/vts/functional/nfc_hidl_hal_test.cpp
+++ b/nfc/1.0/vts/functional/nfc_hidl_hal_test.cpp
@@ -356,7 +356,7 @@
sleep(5);
int status = RUN_ALL_TESTS();
- ALOGI("Test result = %d", status);
+ LOG(INFO) << "Test result = " << status;
std::system("svc nfc enable"); /* Turn on NFC */
sleep(5);
diff --git a/nfc/1.0/vts/functional/vts/testcases/hal/nfc/hidl/host/passthrough/NfcHidlPassthroughBasicTest.config b/nfc/1.0/vts/functional/vts/testcases/hal/nfc/hidl/host/passthrough/NfcHidlPassthroughBasicTest.config
index 3e957e3..9300c6f 100644
--- a/nfc/1.0/vts/functional/vts/testcases/hal/nfc/hidl/host/passthrough/NfcHidlPassthroughBasicTest.config
+++ b/nfc/1.0/vts/functional/vts/testcases/hal/nfc/hidl/host/passthrough/NfcHidlPassthroughBasicTest.config
@@ -1,6 +1,11 @@
{
"passthrough_mode": True,
- "modules": ["system/lib64/hw/nfc_nci.bullhead"],
- "git_project_path": "system/nfc",
- "git_project_name": "platform/system/nfc"
+ "coverage": True,
+ "modules": [{
+ "module_name": "system/lib64/hw/nfc_nci.bullhead",
+ "git_project": {
+ "name": "platform/system/nfc",
+ "path": "system/nfc"
+ }
+ }]
}
diff --git a/nfc/1.0/vts/functional/vts/testcases/hal/nfc/hidl/target/HalNfcHidlTargetBasicTest.config b/nfc/1.0/vts/functional/vts/testcases/hal/nfc/hidl/target/HalNfcHidlTargetBasicTest.config
index 60623b1..2574bda 100644
--- a/nfc/1.0/vts/functional/vts/testcases/hal/nfc/hidl/target/HalNfcHidlTargetBasicTest.config
+++ b/nfc/1.0/vts/functional/vts/testcases/hal/nfc/hidl/target/HalNfcHidlTargetBasicTest.config
@@ -1,5 +1,10 @@
{
- "modules": ["system/lib64/hw/nfc_nci.bullhead"],
- "git_project_path": "system/nfc",
- "git_project_name": "platform/system/nfc"
+ "coverage": True,
+ "modules": [{
+ "module_name": "system/lib64/hw/nfc_nci.bullhead",
+ "git_project": {
+ "name": "platform/system/nfc",
+ "path": "system/nfc"
+ }
+ }]
}
diff --git a/power/1.0/default/Power.cpp b/power/1.0/default/Power.cpp
index 5d0593b..6453f33 100644
--- a/power/1.0/default/Power.cpp
+++ b/power/1.0/default/Power.cpp
@@ -17,6 +17,7 @@
#define LOG_TAG "android.hardware.power@1.0-impl"
#include <hardware/hardware.h>
#include <hardware/power.h>
+#include <android/log.h>
#include "Power.h"
namespace android {
diff --git a/power/1.0/vts/functional/power_hidl_hal_test.cpp b/power/1.0/vts/functional/power_hidl_hal_test.cpp
index ac56f1a..af6eb86 100644
--- a/power/1.0/vts/functional/power_hidl_hal_test.cpp
+++ b/power/1.0/vts/functional/power_hidl_hal_test.cpp
@@ -103,6 +103,6 @@
int main(int argc, char **argv) {
::testing::InitGoogleTest(&argc, argv);
int status = RUN_ALL_TESTS();
- ALOGI("Test result = %d", status);
+ LOG(INFO) << "Test result = " << status;
return status;
}
diff --git a/soundtrigger/2.0/default/SoundTriggerHalImpl.cpp b/soundtrigger/2.0/default/SoundTriggerHalImpl.cpp
index 1ae996a..73066e6 100644
--- a/soundtrigger/2.0/default/SoundTriggerHalImpl.cpp
+++ b/soundtrigger/2.0/default/SoundTriggerHalImpl.cpp
@@ -17,7 +17,7 @@
#define LOG_TAG "SoundTriggerHalImpl"
//#define LOG_NDEBUG 0
-#include <utils/Log.h>
+#include <android/log.h>
#include "SoundTriggerHalImpl.h"
diff --git a/soundtrigger/2.0/vts/functional/soundtrigger_hidl_hal_test.cpp b/soundtrigger/2.0/vts/functional/soundtrigger_hidl_hal_test.cpp
index cbd8128..e5bf086 100644
--- a/soundtrigger/2.0/vts/functional/soundtrigger_hidl_hal_test.cpp
+++ b/soundtrigger/2.0/vts/functional/soundtrigger_hidl_hal_test.cpp
@@ -15,7 +15,7 @@
*/
#define LOG_TAG "SoundTriggerHidlHalTest"
-#include <android-base/logging.h>
+#include <android/log.h>
#include <cutils/native_handle.h>
#include <android/hardware/audio/common/2.0/types.h>
diff --git a/tests/Android.bp b/tests/Android.bp
index 030576d..8b3e8b1 100644
--- a/tests/Android.bp
+++ b/tests/Android.bp
@@ -11,6 +11,8 @@
"inheritance/1.0/default",
"libhwbinder/1.0",
"libhwbinder/1.0/default",
+ "memory/1.0",
+ "memory/1.0/default",
"msgq/1.0",
"pointer/1.0",
"pointer/1.0/default",
diff --git a/tests/memory/1.0/Android.bp b/tests/memory/1.0/Android.bp
new file mode 100644
index 0000000..9a400a3
--- /dev/null
+++ b/tests/memory/1.0/Android.bp
@@ -0,0 +1,50 @@
+// This file is autogenerated by hidl-gen. Do not edit manually.
+
+genrule {
+ name: "android.hardware.tests.memory@1.0_genc++",
+ tools: ["hidl-gen"],
+ cmd: "$(location hidl-gen) -o $(genDir) -Lc++ -randroid.hardware:hardware/interfaces android.hardware.tests.memory@1.0",
+ srcs: [
+ "IMemoryTest.hal",
+ ],
+ out: [
+ "android/hardware/tests/memory/1.0/MemoryTestAll.cpp",
+ ],
+}
+
+genrule {
+ name: "android.hardware.tests.memory@1.0_genc++_headers",
+ tools: ["hidl-gen"],
+ cmd: "$(location hidl-gen) -o $(genDir) -Lc++ -randroid.hardware:hardware/interfaces android.hardware.tests.memory@1.0",
+ srcs: [
+ "IMemoryTest.hal",
+ ],
+ out: [
+ "android/hardware/tests/memory/1.0/IMemoryTest.h",
+ "android/hardware/tests/memory/1.0/IHwMemoryTest.h",
+ "android/hardware/tests/memory/1.0/BnMemoryTest.h",
+ "android/hardware/tests/memory/1.0/BpMemoryTest.h",
+ "android/hardware/tests/memory/1.0/BsMemoryTest.h",
+ ],
+}
+
+cc_library_shared {
+ name: "android.hardware.tests.memory@1.0",
+ generated_sources: ["android.hardware.tests.memory@1.0_genc++"],
+ generated_headers: ["android.hardware.tests.memory@1.0_genc++_headers"],
+ export_generated_headers: ["android.hardware.tests.memory@1.0_genc++_headers"],
+ shared_libs: [
+ "libhidlbase",
+ "libhidltransport",
+ "libhwbinder",
+ "liblog",
+ "libutils",
+ "libcutils",
+ ],
+ export_shared_lib_headers: [
+ "libhidlbase",
+ "libhidltransport",
+ "libhwbinder",
+ "libutils",
+ ],
+}
diff --git a/tests/memory/1.0/IMemoryTest.hal b/tests/memory/1.0/IMemoryTest.hal
new file mode 100644
index 0000000..c20c536
--- /dev/null
+++ b/tests/memory/1.0/IMemoryTest.hal
@@ -0,0 +1,21 @@
+/*
+ * 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.tests.memory@1.0;
+
+interface IMemoryTest {
+ fillMemory(memory memory_in, uint8_t filler);
+};
diff --git a/tests/memory/1.0/default/Android.bp b/tests/memory/1.0/default/Android.bp
new file mode 100644
index 0000000..bde7c03
--- /dev/null
+++ b/tests/memory/1.0/default/Android.bp
@@ -0,0 +1,31 @@
+// 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.tests.memory@1.0-impl",
+ relative_install_path: "hw",
+ srcs: [
+ "MemoryTest.cpp",
+ ],
+ shared_libs: [
+ "libhidlbase",
+ "libhidltransport",
+ "libhwbinder",
+ "libhidlmemory",
+ "liblog",
+ "libutils",
+ "android.hardware.tests.memory@1.0",
+ "android.hidl.memory@1.0",
+ ],
+}
\ No newline at end of file
diff --git a/tests/memory/1.0/default/MemoryTest.cpp b/tests/memory/1.0/default/MemoryTest.cpp
new file mode 100644
index 0000000..ed65410
--- /dev/null
+++ b/tests/memory/1.0/default/MemoryTest.cpp
@@ -0,0 +1,66 @@
+/*
+ * 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.tests.memory@1.0"
+
+#include "MemoryTest.h"
+
+#include <hidlmemory/mapping.h>
+
+#include <android/hidl/memory/1.0/IMemory.h>
+
+using android::hidl::memory::V1_0::IMemory;
+
+namespace android {
+namespace hardware {
+namespace tests {
+namespace memory {
+namespace V1_0 {
+namespace implementation {
+
+// Methods from ::android::hardware::tests::memory::V1_0::IMemoryTest follow.
+Return<void> Memory::fillMemory(const hidl_memory& memory_in, uint8_t filler) {
+ sp<IMemory> memory = mapMemory(memory_in);
+
+ if (memory == nullptr) {
+ ALOGE("Could not map hidl_memory");
+ return Void();
+ }
+
+ uint8_t* data = static_cast<uint8_t*>(static_cast<void*>(memory->getPointer()));
+
+ memory->update();
+
+ for (size_t i = 0; i < memory->getSize(); i++) {
+ data[i] = filler;
+ }
+
+ memory->commit();
+
+ return Void();
+}
+
+
+IMemoryTest* HIDL_FETCH_IMemoryTest(const char* /* name */) {
+ return new Memory();
+}
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace memory
+} // namespace tests
+} // namespace hardware
+} // namespace android
diff --git a/tests/memory/1.0/default/MemoryTest.h b/tests/memory/1.0/default/MemoryTest.h
new file mode 100644
index 0000000..5cab494
--- /dev/null
+++ b/tests/memory/1.0/default/MemoryTest.h
@@ -0,0 +1,55 @@
+/*
+ * 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 ANDROID_HARDWARE_TESTS_MEMORY_V1_0_MEMORY_TEST_H
+#define ANDROID_HARDWARE_TESTS_MEMORY_V1_0_MEMORY_TEST_H
+
+#include <android/hardware/tests/memory/1.0/IMemoryTest.h>
+#include <hidl/MQDescriptor.h>
+#include <hidl/Status.h>
+
+namespace android {
+namespace hardware {
+namespace tests {
+namespace memory {
+namespace V1_0 {
+namespace implementation {
+
+using ::android::hardware::tests::memory::V1_0::IMemoryTest;
+using ::android::hardware::hidl_array;
+using ::android::hardware::hidl_memory;
+using ::android::hardware::hidl_string;
+using ::android::hardware::hidl_vec;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+using ::android::sp;
+
+struct Memory : public IMemoryTest {
+ // Methods from ::android::hardware::tests::memory::V1_0::IMemoryTest follow.
+ Return<void> fillMemory(const hidl_memory& memory_in, uint8_t filler) override;
+
+};
+
+extern "C" IMemoryTest* HIDL_FETCH_IMemoryTest(const char* name);
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace memory
+} // namespace tests
+} // namespace hardware
+} // namespace android
+
+#endif // ANDROID_HARDWARE_TESTS_MEMORY_V1_0_MEMORY_TEST_H
diff --git a/thermal/1.0/default/Thermal.cpp b/thermal/1.0/default/Thermal.cpp
index 6c2111f..580b540 100644
--- a/thermal/1.0/default/Thermal.cpp
+++ b/thermal/1.0/default/Thermal.cpp
@@ -15,7 +15,7 @@
*/
#define LOG_TAG "android.hardware.thermal@1.0-impl"
-#include <utils/Log.h>
+#include <android/log.h>
#include <errno.h>
#include <hardware/hardware.h>
diff --git a/thermal/1.0/vts/functional/thermal_hidl_hal_test.cpp b/thermal/1.0/vts/functional/thermal_hidl_hal_test.cpp
index e3b00ab..8a5ea2c 100644
--- a/thermal/1.0/vts/functional/thermal_hidl_hal_test.cpp
+++ b/thermal/1.0/vts/functional/thermal_hidl_hal_test.cpp
@@ -214,6 +214,6 @@
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
int status = RUN_ALL_TESTS();
- ALOGI("Test result = %d", status);
+ LOG(INFO) << "Test result = " << status;
return status;
}
diff --git a/vehicle/2.0/default/VehicleService.cpp b/vehicle/2.0/default/VehicleService.cpp
index e21dcd9..651a2ad 100644
--- a/vehicle/2.0/default/VehicleService.cpp
+++ b/vehicle/2.0/default/VehicleService.cpp
@@ -15,7 +15,7 @@
*/
#define LOG_TAG "android.hardware.vehicle@2.0-service"
-#include <utils/Log.h>
+#include <android/log.h>
#include <iostream>
diff --git a/vehicle/2.0/default/impl/DefaultVehicleHal.cpp b/vehicle/2.0/default/impl/DefaultVehicleHal.cpp
index 5054cfe..4e27bdc 100644
--- a/vehicle/2.0/default/impl/DefaultVehicleHal.cpp
+++ b/vehicle/2.0/default/impl/DefaultVehicleHal.cpp
@@ -16,6 +16,9 @@
#include "DefaultVehicleHal.h"
+#define LOG_TAG "default_vehicle"
+#include <android/log.h>
+
namespace android {
namespace hardware {
namespace vehicle {
diff --git a/vehicle/2.0/default/vehicle_hal_manager/SubscriptionManager.h b/vehicle/2.0/default/vehicle_hal_manager/SubscriptionManager.h
index 903bde5..9f2ed8d 100644
--- a/vehicle/2.0/default/vehicle_hal_manager/SubscriptionManager.h
+++ b/vehicle/2.0/default/vehicle_hal_manager/SubscriptionManager.h
@@ -22,7 +22,7 @@
#include <set>
#include <list>
-#include <utils/Log.h>
+#include <android/log.h>
#include <hwbinder/IPCThreadState.h>
#include <android/hardware/vehicle/2.0/IVehicle.h>
diff --git a/vehicle/2.0/default/vehicle_hal_manager/VehicleHalManager.cpp b/vehicle/2.0/default/vehicle_hal_manager/VehicleHalManager.cpp
index a84f991..1260f20 100644
--- a/vehicle/2.0/default/vehicle_hal_manager/VehicleHalManager.cpp
+++ b/vehicle/2.0/default/vehicle_hal_manager/VehicleHalManager.cpp
@@ -18,7 +18,7 @@
#include <cmath>
#include <utils/Errors.h>
-#include <utils/Log.h>
+#include <android/log.h>
#include <hidl/Status.h>
#include <future>
#include <bitset>
diff --git a/vehicle/2.0/default/vehicle_hal_manager/VehicleObjectPool.h b/vehicle/2.0/default/vehicle_hal_manager/VehicleObjectPool.h
index b4a4b3e..0029380 100644
--- a/vehicle/2.0/default/vehicle_hal_manager/VehicleObjectPool.h
+++ b/vehicle/2.0/default/vehicle_hal_manager/VehicleObjectPool.h
@@ -14,9 +14,12 @@
* limitations under the License.
*/
+
#ifndef android_hardware_vehicle_V2_0_VehicleObjectPool_H_
#define android_hardware_vehicle_V2_0_VehicleObjectPool_H_
+#include "VehicleUtils.h" // defines LOG_TAG and includes <android/log.h>
+
#include <iostream>
#include <memory>
#include <deque>
@@ -24,10 +27,12 @@
#include <map>
#include <mutex>
+#ifndef LOG_TAG
+#define LOG_TAG "android.hardware.vehicle@2.0-impl"
+#endif
+#include <android/log.h>
#include <android/hardware/vehicle/2.0/types.h>
-#include "VehicleUtils.h"
-
namespace android {
namespace hardware {
namespace vehicle {
diff --git a/vehicle/2.0/default/vehicle_hal_manager/VehicleUtils.h b/vehicle/2.0/default/vehicle_hal_manager/VehicleUtils.h
index 5751eb1..f06e97e 100644
--- a/vehicle/2.0/default/vehicle_hal_manager/VehicleUtils.h
+++ b/vehicle/2.0/default/vehicle_hal_manager/VehicleUtils.h
@@ -17,6 +17,11 @@
#ifndef android_hardware_vehicle_V2_0_VehicleUtils_H_
#define android_hardware_vehicle_V2_0_VehicleUtils_H_
+#ifndef LOG_TAG
+#define LOG_TAG "android.hardware.vehicle@2.0-impl"
+#endif
+#include <android/log.h>
+
#include <memory>
#include <hidl/HidlSupport.h>
diff --git a/vibrator/1.0/default/Vibrator.cpp b/vibrator/1.0/default/Vibrator.cpp
index 4cd3b30..ee3a458 100644
--- a/vibrator/1.0/default/Vibrator.cpp
+++ b/vibrator/1.0/default/Vibrator.cpp
@@ -15,9 +15,9 @@
*/
#define LOG_TAG "VibratorService"
-
#include <hardware/hardware.h>
#include <hardware/vibrator.h>
+#include <android/log.h>
#include "Vibrator.h"
namespace android {
diff --git a/vibrator/1.0/vts/functional/Android.bp b/vibrator/1.0/vts/functional/Android.bp
index 22b7536..e893ec6 100644
--- a/vibrator/1.0/vts/functional/Android.bp
+++ b/vibrator/1.0/vts/functional/Android.bp
@@ -19,6 +19,7 @@
gtest: true,
srcs: ["vibrator_hidl_hal_test.cpp"],
shared_libs: [
+ "libbase",
"liblog",
"libutils",
"android.hardware.vibrator@1.0",
diff --git a/vibrator/1.0/vts/functional/vibrator_hidl_hal_test.cpp b/vibrator/1.0/vts/functional/vibrator_hidl_hal_test.cpp
index 659508d..ec8db3a 100644
--- a/vibrator/1.0/vts/functional/vibrator_hidl_hal_test.cpp
+++ b/vibrator/1.0/vts/functional/vibrator_hidl_hal_test.cpp
@@ -62,6 +62,6 @@
::testing::AddGlobalTestEnvironment(new VibratorHidlEnvironment);
::testing::InitGoogleTest(&argc, argv);
int status = RUN_ALL_TESTS();
- ALOGI("Test result = %d", status);
+ LOG(INFO) << "Test result = " << status;
return status;
}
diff --git a/vr/1.0/default/Vr.cpp b/vr/1.0/default/Vr.cpp
index 4b2c603..2b2372b 100644
--- a/vr/1.0/default/Vr.cpp
+++ b/vr/1.0/default/Vr.cpp
@@ -18,6 +18,7 @@
#include <hardware/hardware.h>
#include <hardware/vr.h>
+#include <android/log.h>
#include "Vr.h"
namespace android {
diff --git a/wifi/1.0/default/Android.mk b/wifi/1.0/default/Android.mk
index 62d2e0b..931a314 100644
--- a/wifi/1.0/default/Android.mk
+++ b/wifi/1.0/default/Android.mk
@@ -18,6 +18,7 @@
LOCAL_MODULE_RELATIVE_PATH := hw
LOCAL_CPPFLAGS := -Wall -Wno-unused-parameter -Werror -Wextra
LOCAL_SRC_FILES := \
+ hidl_struct_util.cpp \
service.cpp \
wifi.cpp \
wifi_ap_iface.cpp \
diff --git a/wifi/1.0/default/hidl_struct_util.cpp b/wifi/1.0/default/hidl_struct_util.cpp
new file mode 100644
index 0000000..b4dcc0a
--- /dev/null
+++ b/wifi/1.0/default/hidl_struct_util.cpp
@@ -0,0 +1,259 @@
+/*
+ * 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 <android-base/logging.h>
+#include <utils/SystemClock.h>
+
+#include "hidl_struct_util.h"
+
+namespace android {
+namespace hardware {
+namespace wifi {
+namespace V1_0 {
+namespace implementation {
+namespace hidl_struct_util {
+
+uint8_t ConvertHidlReportEventFlagToLegacy(
+ StaBackgroundScanBucketEventReportSchemeMask hidl_flag) {
+ using HidlFlag = StaBackgroundScanBucketEventReportSchemeMask;
+ switch (hidl_flag) {
+ case HidlFlag::EACH_SCAN:
+ return REPORT_EVENTS_EACH_SCAN;
+ case HidlFlag::FULL_RESULTS:
+ return REPORT_EVENTS_FULL_RESULTS;
+ case HidlFlag::NO_BATCH:
+ return REPORT_EVENTS_NO_BATCH;
+ };
+}
+
+bool convertHidlScanParamsToLegacy(
+ const StaBackgroundScanParameters& hidl_scan_params,
+ legacy_hal::wifi_scan_cmd_params* legacy_scan_params) {
+ if (!legacy_scan_params) {
+ return false;
+ }
+ legacy_scan_params->base_period = hidl_scan_params.basePeriodInMs;
+ legacy_scan_params->max_ap_per_scan = hidl_scan_params.maxApPerScan;
+ legacy_scan_params->report_threshold_percent =
+ hidl_scan_params.reportThresholdPercent;
+ legacy_scan_params->report_threshold_num_scans =
+ hidl_scan_params.reportThresholdNumScans;
+ // TODO(b/33194311): Expose these max limits in the HIDL interface.
+ if (hidl_scan_params.buckets.size() > MAX_BUCKETS) {
+ return false;
+ }
+ legacy_scan_params->num_buckets = hidl_scan_params.buckets.size();
+ for (uint32_t bucket_idx = 0; bucket_idx < hidl_scan_params.buckets.size();
+ bucket_idx++) {
+ const StaBackgroundScanBucketParameters& hidl_bucket_spec =
+ hidl_scan_params.buckets[bucket_idx];
+ legacy_hal::wifi_scan_bucket_spec& legacy_bucket_spec =
+ legacy_scan_params->buckets[bucket_idx];
+ legacy_bucket_spec.bucket = bucket_idx;
+ legacy_bucket_spec.band =
+ static_cast<legacy_hal::wifi_band>(hidl_bucket_spec.band);
+ legacy_bucket_spec.period = hidl_bucket_spec.periodInMs;
+ legacy_bucket_spec.max_period = hidl_bucket_spec.exponentialMaxPeriodInMs;
+ legacy_bucket_spec.base = hidl_bucket_spec.exponentialBase;
+ legacy_bucket_spec.step_count = hidl_bucket_spec.exponentialStepCount;
+ legacy_bucket_spec.report_events = 0;
+ using HidlFlag = StaBackgroundScanBucketEventReportSchemeMask;
+ for (const auto flag :
+ {HidlFlag::EACH_SCAN, HidlFlag::FULL_RESULTS, HidlFlag::NO_BATCH}) {
+ if (hidl_bucket_spec.eventReportScheme &
+ static_cast<std::underlying_type<HidlFlag>::type>(flag)) {
+ legacy_bucket_spec.report_events |=
+ ConvertHidlReportEventFlagToLegacy(flag);
+ }
+ }
+ // TODO(b/33194311): Expose these max limits in the HIDL interface.
+ if (hidl_bucket_spec.frequencies.size() > MAX_CHANNELS) {
+ return false;
+ }
+ legacy_bucket_spec.num_channels = hidl_bucket_spec.frequencies.size();
+ for (uint32_t freq_idx = 0; freq_idx < hidl_bucket_spec.frequencies.size();
+ freq_idx++) {
+ legacy_bucket_spec.channels[freq_idx].channel =
+ hidl_bucket_spec.frequencies[freq_idx];
+ }
+ }
+ return true;
+}
+
+bool convertLegacyIeBlobToHidl(const uint8_t* ie_blob,
+ uint32_t ie_blob_len,
+ std::vector<WifiInformationElement>* hidl_ies) {
+ if (!ie_blob || !hidl_ies) {
+ return false;
+ }
+ const uint8_t* ies_begin = ie_blob;
+ const uint8_t* ies_end = ie_blob + ie_blob_len;
+ const uint8_t* next_ie = ies_begin;
+ using wifi_ie = legacy_hal::wifi_information_element;
+ constexpr size_t kIeHeaderLen = sizeof(wifi_ie);
+ // Each IE should atleast have the header (i.e |id| & |len| fields).
+ while (next_ie + kIeHeaderLen <= ies_end) {
+ const wifi_ie& legacy_ie = (*reinterpret_cast<const wifi_ie*>(next_ie));
+ uint32_t curr_ie_len = kIeHeaderLen + legacy_ie.len;
+ if (next_ie + curr_ie_len > ies_end) {
+ return false;
+ }
+ WifiInformationElement hidl_ie;
+ hidl_ie.id = legacy_ie.id;
+ hidl_ie.data =
+ std::vector<uint8_t>(legacy_ie.data, legacy_ie.data + legacy_ie.len);
+ hidl_ies->push_back(std::move(hidl_ie));
+ next_ie += curr_ie_len;
+ }
+ // Ensure that the blob has been fully consumed.
+ return (next_ie == ies_end);
+}
+
+bool convertLegacyScanResultToHidl(
+ const legacy_hal::wifi_scan_result& legacy_scan_result,
+ bool has_ie_data,
+ StaScanResult* hidl_scan_result) {
+ if (!hidl_scan_result) {
+ return false;
+ }
+ hidl_scan_result->timeStampInUs = legacy_scan_result.ts;
+ hidl_scan_result->ssid = std::vector<uint8_t>(
+ legacy_scan_result.ssid,
+ legacy_scan_result.ssid + sizeof(legacy_scan_result.ssid));
+ memcpy(hidl_scan_result->bssid.data(),
+ legacy_scan_result.bssid,
+ hidl_scan_result->bssid.size());
+ hidl_scan_result->frequency = legacy_scan_result.channel;
+ hidl_scan_result->rssi = legacy_scan_result.rssi;
+ hidl_scan_result->beaconPeriodInMs = legacy_scan_result.beacon_period;
+ hidl_scan_result->capability = legacy_scan_result.capability;
+ if (has_ie_data) {
+ std::vector<WifiInformationElement> ies;
+ if (!convertLegacyIeBlobToHidl(
+ reinterpret_cast<const uint8_t*>(legacy_scan_result.ie_data),
+ legacy_scan_result.ie_length,
+ &ies)) {
+ return false;
+ }
+ hidl_scan_result->informationElements = std::move(ies);
+ }
+ return true;
+}
+
+bool convertLegacyCachedScanResultsToHidl(
+ const legacy_hal::wifi_cached_scan_results& legacy_cached_scan_result,
+ StaScanData* hidl_scan_data) {
+ if (!hidl_scan_data) {
+ return false;
+ }
+ hidl_scan_data->flags = legacy_cached_scan_result.flags;
+ hidl_scan_data->bucketsScanned = legacy_cached_scan_result.buckets_scanned;
+
+ CHECK(legacy_cached_scan_result.num_results >= 0 &&
+ legacy_cached_scan_result.num_results <= MAX_AP_CACHE_PER_SCAN);
+ std::vector<StaScanResult> hidl_scan_results;
+ for (int32_t result_idx = 0;
+ result_idx < legacy_cached_scan_result.num_results;
+ result_idx++) {
+ StaScanResult hidl_scan_result;
+ if (!convertLegacyScanResultToHidl(
+ legacy_cached_scan_result.results[result_idx],
+ false,
+ &hidl_scan_result)) {
+ return false;
+ }
+ hidl_scan_results.push_back(hidl_scan_result);
+ }
+ hidl_scan_data->results = std::move(hidl_scan_results);
+ return true;
+}
+
+bool convertLegacyVectorOfCachedScanResultsToHidl(
+ const std::vector<legacy_hal::wifi_cached_scan_results>&
+ legacy_cached_scan_results,
+ std::vector<StaScanData>* hidl_scan_datas) {
+ if (!hidl_scan_datas) {
+ return false;
+ }
+ for (const auto& legacy_cached_scan_result : legacy_cached_scan_results) {
+ StaScanData hidl_scan_data;
+ if (!convertLegacyCachedScanResultsToHidl(legacy_cached_scan_result,
+ &hidl_scan_data)) {
+ return false;
+ }
+ hidl_scan_datas->push_back(hidl_scan_data);
+ }
+ return true;
+}
+
+bool convertLegacyLinkLayerStatsToHidl(
+ const legacy_hal::LinkLayerStats& legacy_stats,
+ StaLinkLayerStats* hidl_stats) {
+ if (!hidl_stats) {
+ return false;
+ }
+ // iface legacy_stats conversion.
+ hidl_stats->iface.beaconRx = legacy_stats.iface.beacon_rx;
+ hidl_stats->iface.avgRssiMgmt = legacy_stats.iface.rssi_mgmt;
+ hidl_stats->iface.wmeBePktStats.rxMpdu =
+ legacy_stats.iface.ac[legacy_hal::WIFI_AC_BE].rx_mpdu;
+ hidl_stats->iface.wmeBePktStats.txMpdu =
+ legacy_stats.iface.ac[legacy_hal::WIFI_AC_BE].tx_mpdu;
+ hidl_stats->iface.wmeBePktStats.lostMpdu =
+ legacy_stats.iface.ac[legacy_hal::WIFI_AC_BE].mpdu_lost;
+ hidl_stats->iface.wmeBePktStats.retries =
+ legacy_stats.iface.ac[legacy_hal::WIFI_AC_BE].retries;
+ hidl_stats->iface.wmeBkPktStats.rxMpdu =
+ legacy_stats.iface.ac[legacy_hal::WIFI_AC_BK].rx_mpdu;
+ hidl_stats->iface.wmeBkPktStats.txMpdu =
+ legacy_stats.iface.ac[legacy_hal::WIFI_AC_BK].tx_mpdu;
+ hidl_stats->iface.wmeBkPktStats.lostMpdu =
+ legacy_stats.iface.ac[legacy_hal::WIFI_AC_BK].mpdu_lost;
+ hidl_stats->iface.wmeBkPktStats.retries =
+ legacy_stats.iface.ac[legacy_hal::WIFI_AC_BK].retries;
+ hidl_stats->iface.wmeViPktStats.rxMpdu =
+ legacy_stats.iface.ac[legacy_hal::WIFI_AC_VI].rx_mpdu;
+ hidl_stats->iface.wmeViPktStats.txMpdu =
+ legacy_stats.iface.ac[legacy_hal::WIFI_AC_VI].tx_mpdu;
+ hidl_stats->iface.wmeViPktStats.lostMpdu =
+ legacy_stats.iface.ac[legacy_hal::WIFI_AC_VI].mpdu_lost;
+ hidl_stats->iface.wmeViPktStats.retries =
+ legacy_stats.iface.ac[legacy_hal::WIFI_AC_VI].retries;
+ hidl_stats->iface.wmeVoPktStats.rxMpdu =
+ legacy_stats.iface.ac[legacy_hal::WIFI_AC_VO].rx_mpdu;
+ hidl_stats->iface.wmeVoPktStats.txMpdu =
+ legacy_stats.iface.ac[legacy_hal::WIFI_AC_VO].tx_mpdu;
+ hidl_stats->iface.wmeVoPktStats.lostMpdu =
+ legacy_stats.iface.ac[legacy_hal::WIFI_AC_VO].mpdu_lost;
+ hidl_stats->iface.wmeVoPktStats.retries =
+ legacy_stats.iface.ac[legacy_hal::WIFI_AC_VO].retries;
+ // radio legacy_stats conversion.
+ hidl_stats->radio.onTimeInMs = legacy_stats.radio.on_time;
+ hidl_stats->radio.txTimeInMs = legacy_stats.radio.tx_time;
+ hidl_stats->radio.rxTimeInMs = legacy_stats.radio.rx_time;
+ hidl_stats->radio.onTimeInMsForScan = legacy_stats.radio.on_time_scan;
+ hidl_stats->radio.txTimeInMsPerLevel = legacy_stats.radio_tx_time_per_levels;
+ // Timestamp in the HAL wrapper here since it's not provided in the legacy
+ // HAL API.
+ hidl_stats->timeStampInMs = uptimeMillis();
+ return true;
+}
+} // namespace hidl_struct_util
+} // namespace implementation
+} // namespace V1_0
+} // namespace wifi
+} // namespace hardware
+} // namespace android
diff --git a/wifi/1.0/default/hidl_struct_util.h b/wifi/1.0/default/hidl_struct_util.h
new file mode 100644
index 0000000..6c91e03
--- /dev/null
+++ b/wifi/1.0/default/hidl_struct_util.h
@@ -0,0 +1,69 @@
+/*
+ * 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_STRUCT_UTIL_H_
+#define HIDL_STRUCT_UTIL_H_
+
+#include <vector>
+
+#include <android/hardware/wifi/1.0/IWifi.h>
+
+#include "wifi_legacy_hal.h"
+
+/**
+ * This file contains a bunch of functions to convert structs from the legacy
+ * HAL to HIDL and vice versa.
+ * TODO(b/32093047): Add unit tests for these conversion methods in the VTS test
+ * suite.
+ */
+namespace android {
+namespace hardware {
+namespace wifi {
+namespace V1_0 {
+namespace implementation {
+namespace hidl_struct_util {
+
+// Convert hidl gscan params to legacy gscan params.
+bool convertHidlScanParamsToLegacy(
+ const StaBackgroundScanParameters& hidl_scan_params,
+ legacy_hal::wifi_scan_cmd_params* legacy_scan_params);
+// Convert the blob of packed IE elements to vector of
+// |WifiInformationElement| structures.
+bool convertLegacyIeBlobToHidl(const uint8_t* ie_blob,
+ uint32_t ie_blob_len,
+ std::vector<WifiInformationElement>* hidl_ies);
+// |has_ie_data| indicates whether or not the wifi_scan_result includes 802.11
+// Information Elements (IEs)
+bool convertLegacyScanResultToHidl(
+ const legacy_hal::wifi_scan_result& legacy_scan_result,
+ bool has_ie_data,
+ StaScanResult* hidl_scan_result);
+// |cached_results| is assumed to not include IEs.
+bool convertLegacyVectorOfCachedScanResultsToHidl(
+ const std::vector<legacy_hal::wifi_cached_scan_results>&
+ legacy_cached_scan_results,
+ std::vector<StaScanData>* hidl_scan_datas);
+bool convertLegacyLinkLayerStatsToHidl(
+ const legacy_hal::LinkLayerStats& legacy_stats,
+ StaLinkLayerStats* hidl_stats);
+} // namespace hidl_struct_util
+} // namespace implementation
+} // namespace V1_0
+} // namespace wifi
+} // namespace hardware
+} // namespace android
+
+#endif // HIDL_STRUCT_UTIL_H_
diff --git a/wifi/1.0/default/wifi.cpp b/wifi/1.0/default/wifi.cpp
index 3475c46..19f7e53 100644
--- a/wifi/1.0/default/wifi.cpp
+++ b/wifi/1.0/default/wifi.cpp
@@ -98,8 +98,8 @@
}
LOG(INFO) << "Starting HAL";
- wifi_error legacy_status = legacy_hal_->start();
- if (legacy_status != WIFI_SUCCESS) {
+ legacy_hal::wifi_error legacy_status = legacy_hal_->start();
+ if (legacy_status != legacy_hal::WIFI_SUCCESS) {
LOG(ERROR) << "Failed to start Wifi HAL: "
<< legacyErrorToString(legacy_status);
return createWifiStatusFromLegacyError(legacy_status,
@@ -139,8 +139,9 @@
};
}
};
- wifi_error legacy_status = legacy_hal_->stop(on_complete_callback_);
- if (legacy_status != WIFI_SUCCESS) {
+ legacy_hal::wifi_error legacy_status =
+ legacy_hal_->stop(on_complete_callback_);
+ if (legacy_status != legacy_hal::WIFI_SUCCESS) {
LOG(ERROR) << "Failed to stop Wifi HAL: "
<< legacyErrorToString(legacy_status);
WifiStatus wifi_status =
diff --git a/wifi/1.0/default/wifi_chip.cpp b/wifi/1.0/default/wifi_chip.cpp
index 4d1bce5..3ab6052 100644
--- a/wifi/1.0/default/wifi_chip.cpp
+++ b/wifi/1.0/default/wifi_chip.cpp
@@ -319,10 +319,10 @@
std::pair<WifiStatus, IWifiChip::ChipDebugInfo>
WifiChip::requestChipDebugInfoInternal() {
IWifiChip::ChipDebugInfo result;
- wifi_error legacy_status;
+ legacy_hal::wifi_error legacy_status;
std::string driver_desc;
std::tie(legacy_status, driver_desc) = legacy_hal_.lock()->getDriverVersion();
- if (legacy_status != WIFI_SUCCESS) {
+ if (legacy_status != legacy_hal::WIFI_SUCCESS) {
LOG(ERROR) << "Failed to get driver version: "
<< legacyErrorToString(legacy_status);
WifiStatus status = createWifiStatusFromLegacyError(
@@ -334,7 +334,7 @@
std::string firmware_desc;
std::tie(legacy_status, firmware_desc) =
legacy_hal_.lock()->getFirmwareVersion();
- if (legacy_status != WIFI_SUCCESS) {
+ if (legacy_status != legacy_hal::WIFI_SUCCESS) {
LOG(ERROR) << "Failed to get firmware version: "
<< legacyErrorToString(legacy_status);
WifiStatus status = createWifiStatusFromLegacyError(
@@ -348,11 +348,11 @@
std::pair<WifiStatus, std::vector<uint8_t>>
WifiChip::requestDriverDebugDumpInternal() {
- wifi_error legacy_status;
+ legacy_hal::wifi_error legacy_status;
std::vector<uint8_t> driver_dump;
std::tie(legacy_status, driver_dump) =
legacy_hal_.lock()->requestDriverMemoryDump();
- if (legacy_status != WIFI_SUCCESS) {
+ if (legacy_status != legacy_hal::WIFI_SUCCESS) {
LOG(ERROR) << "Failed to get driver debug dump: "
<< legacyErrorToString(legacy_status);
return {createWifiStatusFromLegacyError(legacy_status),
@@ -363,11 +363,11 @@
std::pair<WifiStatus, std::vector<uint8_t>>
WifiChip::requestFirmwareDebugDumpInternal() {
- wifi_error legacy_status;
+ legacy_hal::wifi_error legacy_status;
std::vector<uint8_t> firmware_dump;
std::tie(legacy_status, firmware_dump) =
legacy_hal_.lock()->requestFirmwareMemoryDump();
- if (legacy_status != WIFI_SUCCESS) {
+ if (legacy_status != legacy_hal::WIFI_SUCCESS) {
LOG(ERROR) << "Failed to get firmware debug dump: "
<< legacyErrorToString(legacy_status);
return {createWifiStatusFromLegacyError(legacy_status), {}};
diff --git a/wifi/1.0/default/wifi_status_util.cpp b/wifi/1.0/default/wifi_status_util.cpp
index 34a1c1d..9a7ad0d 100644
--- a/wifi/1.0/default/wifi_status_util.cpp
+++ b/wifi/1.0/default/wifi_status_util.cpp
@@ -22,27 +22,27 @@
namespace V1_0 {
namespace implementation {
-std::string legacyErrorToString(wifi_error error) {
+std::string legacyErrorToString(legacy_hal::wifi_error error) {
switch (error) {
- case WIFI_SUCCESS:
+ case legacy_hal::WIFI_SUCCESS:
return "SUCCESS";
- case WIFI_ERROR_UNINITIALIZED:
+ case legacy_hal::WIFI_ERROR_UNINITIALIZED:
return "UNINITIALIZED";
- case WIFI_ERROR_NOT_AVAILABLE:
+ case legacy_hal::WIFI_ERROR_NOT_AVAILABLE:
return "NOT_AVAILABLE";
- case WIFI_ERROR_NOT_SUPPORTED:
+ case legacy_hal::WIFI_ERROR_NOT_SUPPORTED:
return "NOT_SUPPORTED";
- case WIFI_ERROR_INVALID_ARGS:
+ case legacy_hal::WIFI_ERROR_INVALID_ARGS:
return "INVALID_ARGS";
- case WIFI_ERROR_INVALID_REQUEST_ID:
+ case legacy_hal::WIFI_ERROR_INVALID_REQUEST_ID:
return "INVALID_REQUEST_ID";
- case WIFI_ERROR_TIMED_OUT:
+ case legacy_hal::WIFI_ERROR_TIMED_OUT:
return "TIMED_OUT";
- case WIFI_ERROR_TOO_MANY_REQUESTS:
+ case legacy_hal::WIFI_ERROR_TOO_MANY_REQUESTS:
return "TOO_MANY_REQUESTS";
- case WIFI_ERROR_OUT_OF_MEMORY:
+ case legacy_hal::WIFI_ERROR_OUT_OF_MEMORY:
return "OUT_OF_MEMORY";
- case WIFI_ERROR_UNKNOWN:
+ case legacy_hal::WIFI_ERROR_UNKNOWN:
default:
return "UNKNOWN";
}
@@ -57,42 +57,42 @@
return createWifiStatus(code, "");
}
-WifiStatus createWifiStatusFromLegacyError(wifi_error error,
+WifiStatus createWifiStatusFromLegacyError(legacy_hal::wifi_error error,
const std::string& desc) {
switch (error) {
- case WIFI_ERROR_UNINITIALIZED:
- case WIFI_ERROR_NOT_AVAILABLE:
+ case legacy_hal::WIFI_ERROR_UNINITIALIZED:
+ case legacy_hal::WIFI_ERROR_NOT_AVAILABLE:
return createWifiStatus(WifiStatusCode::ERROR_NOT_AVAILABLE, desc);
- case WIFI_ERROR_NOT_SUPPORTED:
+ case legacy_hal::WIFI_ERROR_NOT_SUPPORTED:
return createWifiStatus(WifiStatusCode::ERROR_NOT_SUPPORTED, desc);
- case WIFI_ERROR_INVALID_ARGS:
- case WIFI_ERROR_INVALID_REQUEST_ID:
+ case legacy_hal::WIFI_ERROR_INVALID_ARGS:
+ case legacy_hal::WIFI_ERROR_INVALID_REQUEST_ID:
return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS, desc);
- case WIFI_ERROR_TIMED_OUT:
+ case legacy_hal::WIFI_ERROR_TIMED_OUT:
return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN,
desc + ", timed out");
- case WIFI_ERROR_TOO_MANY_REQUESTS:
+ case legacy_hal::WIFI_ERROR_TOO_MANY_REQUESTS:
return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN,
desc + ", too many requests");
- case WIFI_ERROR_OUT_OF_MEMORY:
+ case legacy_hal::WIFI_ERROR_OUT_OF_MEMORY:
return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN,
desc + ", out of memory");
- case WIFI_ERROR_NONE:
+ case legacy_hal::WIFI_ERROR_NONE:
return createWifiStatus(WifiStatusCode::SUCCESS, desc);
- case WIFI_ERROR_UNKNOWN:
+ case legacy_hal::WIFI_ERROR_UNKNOWN:
default:
return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN, "unknown");
}
}
-WifiStatus createWifiStatusFromLegacyError(wifi_error error) {
+WifiStatus createWifiStatusFromLegacyError(legacy_hal::wifi_error error) {
return createWifiStatusFromLegacyError(error, "");
}
diff --git a/wifi/1.0/default/wifi_status_util.h b/wifi/1.0/default/wifi_status_util.h
index c988b05..7f557e0 100644
--- a/wifi/1.0/default/wifi_status_util.h
+++ b/wifi/1.0/default/wifi_status_util.h
@@ -18,7 +18,8 @@
#define WIFI_STATUS_UTIL_H_
#include <android/hardware/wifi/1.0/IWifi.h>
-#include <hardware_legacy/wifi_hal.h>
+
+#include "wifi_legacy_hal.h"
namespace android {
namespace hardware {
@@ -26,13 +27,13 @@
namespace V1_0 {
namespace implementation {
-std::string legacyErrorToString(wifi_error error);
+std::string legacyErrorToString(legacy_hal::wifi_error error);
WifiStatus createWifiStatus(WifiStatusCode code,
const std::string& description);
WifiStatus createWifiStatus(WifiStatusCode code);
-WifiStatus createWifiStatusFromLegacyError(wifi_error error,
+WifiStatus createWifiStatusFromLegacyError(legacy_hal::wifi_error error,
const std::string& description);
-WifiStatus createWifiStatusFromLegacyError(wifi_error error);
+WifiStatus createWifiStatusFromLegacyError(legacy_hal::wifi_error error);
} // namespace implementation
} // namespace V1_0