Merge "Add the HAL support for getCachedScanResult." into main
diff --git a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Flags.aidl b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Flags.aidl
index bcbf870..046c220 100644
--- a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Flags.aidl
+++ b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Flags.aidl
@@ -43,6 +43,8 @@
boolean audioModeIndication;
boolean audioSourceIndication;
boolean bypass;
+ boolean sinkMetadataIndication;
+ boolean sourceMetadataIndication;
@Backing(type="byte") @VintfStability
enum Type {
INSERT = 0,
diff --git a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Parameter.aidl b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Parameter.aidl
index 7313b57..ff33c42 100644
--- a/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Parameter.aidl
+++ b/audio/aidl/aidl_api/android.hardware.audio.effect/current/android/hardware/audio/effect/Parameter.aidl
@@ -41,6 +41,8 @@
boolean offload;
android.hardware.audio.effect.Parameter.VolumeStereo volumeStereo;
android.hardware.audio.effect.Parameter.Specific specific;
+ android.hardware.audio.common.SinkMetadata sinkMetadata;
+ android.hardware.audio.common.SourceMetadata sourceMetadata;
@VintfStability
union Id {
android.hardware.audio.effect.VendorExtension vendorEffectTag;
diff --git a/audio/aidl/android/hardware/audio/effect/Flags.aidl b/audio/aidl/android/hardware/audio/effect/Flags.aidl
index 28685c3..70668a3 100644
--- a/audio/aidl/android/hardware/audio/effect/Flags.aidl
+++ b/audio/aidl/android/hardware/audio/effect/Flags.aidl
@@ -144,4 +144,18 @@
* Set to true if the effect instance bypass audio data (no processing).
*/
boolean bypass;
+
+ /**
+ * Effect instance sets this flag to true if it requires record AudioTrack metadata update. In
+ * this case the framework must call IEffect.setParameter to notify effect instance when there
+ * is a change in sinkMetadata.
+ */
+ boolean sinkMetadataIndication;
+
+ /**
+ * Effect instance sets this flag to true if it requires playback AudioTrack metadata update. In
+ * this case the framework must call IEffect.setParameter to notify effect instance when there
+ * is a change in sourceMetadata.
+ */
+ boolean sourceMetadataIndication;
}
diff --git a/audio/aidl/android/hardware/audio/effect/Parameter.aidl b/audio/aidl/android/hardware/audio/effect/Parameter.aidl
index 6ec7226..6fd9161 100644
--- a/audio/aidl/android/hardware/audio/effect/Parameter.aidl
+++ b/audio/aidl/android/hardware/audio/effect/Parameter.aidl
@@ -16,6 +16,8 @@
package android.hardware.audio.effect;
+import android.hardware.audio.common.SinkMetadata;
+import android.hardware.audio.common.SourceMetadata;
import android.hardware.audio.effect.AcousticEchoCanceler;
import android.hardware.audio.effect.AutomaticGainControlV1;
import android.hardware.audio.effect.AutomaticGainControlV2;
@@ -198,4 +200,20 @@
Spatializer spatializer;
}
Specific specific;
+
+ /**
+ * SinkMetadata defines the metadata of record AudioTracks which the effect instance associate
+ * with.
+ * The effect engine is required to set Flags.sinkMetadataIndication to true if it wants to
+ * receive sinkMetadata update from the audio framework.
+ */
+ SinkMetadata sinkMetadata;
+
+ /**
+ * SourceMetadata defines the metadata of playback AudioTracks which the effect instance
+ * associate with.
+ * The effect engine is required to set Flags.sourceMetadataIndication to true if it wants to
+ * receive sourceMetadata update from the audio framework.
+ */
+ SourceMetadata sourceMetadata;
}
diff --git a/audio/aidl/default/Android.bp b/audio/aidl/default/Android.bp
index 11bd7d3..7cd0545 100644
--- a/audio/aidl/default/Android.bp
+++ b/audio/aidl/default/Android.bp
@@ -94,6 +94,7 @@
"audio_policy_engine_configuration_aidl_default",
],
shared_libs: [
+ "android.hardware.bluetooth.audio-impl",
"libaudio_aidl_conversion_common_ndk",
"libaudioutils",
"libbluetooth_audio_session_aidl",
@@ -130,6 +131,7 @@
"libaudioserviceexampleimpl",
],
shared_libs: [
+ "android.hardware.bluetooth.audio-impl",
"libaudio_aidl_conversion_common_ndk",
"libbluetooth_audio_session_aidl",
"liblog",
diff --git a/audio/aidl/default/Configuration.cpp b/audio/aidl/default/Configuration.cpp
index 254eb46..d63e353 100644
--- a/audio/aidl/default/Configuration.cpp
+++ b/audio/aidl/default/Configuration.cpp
@@ -320,9 +320,9 @@
// - no profiles specified
//
// Mix ports:
-// * "r_submix output", maximum 20 opened streams, maximum 10 active streams
+// * "r_submix output", maximum 10 opened streams, maximum 10 active streams
// - profile PCM 16-bit; MONO, STEREO; 8000, 11025, 16000, 32000, 44100, 48000
-// * "r_submix input", maximum 20 opened streams, maximum 10 active streams
+// * "r_submix input", maximum 10 opened streams, maximum 10 active streams
// - profile PCM 16-bit; MONO, STEREO; 8000, 11025, 16000, 32000, 44100, 48000
//
// Routes:
@@ -355,12 +355,12 @@
// Mix ports
AudioPort rsubmixOutMix =
- createPort(c.nextPortId++, "r_submix output", 0, false, createPortMixExt(20, 10));
+ createPort(c.nextPortId++, "r_submix output", 0, false, createPortMixExt(10, 10));
rsubmixOutMix.profiles = remoteSubmixPcmAudioProfiles;
c.ports.push_back(rsubmixOutMix);
AudioPort rsubmixInMix =
- createPort(c.nextPortId++, "r_submix input", 0, true, createPortMixExt(20, 10));
+ createPort(c.nextPortId++, "r_submix input", 0, true, createPortMixExt(10, 10));
rsubmixInMix.profiles = remoteSubmixPcmAudioProfiles;
c.ports.push_back(rsubmixInMix);
diff --git a/audio/aidl/default/Stream.cpp b/audio/aidl/default/Stream.cpp
index e8c1693..a805b87 100644
--- a/audio/aidl/default/Stream.cpp
+++ b/audio/aidl/default/Stream.cpp
@@ -582,7 +582,7 @@
const size_t frameSize = mContext->getFrameSize();
bool fatal = false;
int32_t latency = mContext->getNominalLatencyMs();
- if (bool success = readByteCount > 0 ? dataMQ->read(&mDataBuffer[0], readByteCount) : true) {
+ if (readByteCount > 0 ? dataMQ->read(&mDataBuffer[0], readByteCount) : true) {
const bool isConnected = mIsConnected;
LOG(VERBOSE) << __func__ << ": reading of " << readByteCount << " bytes from data MQ"
<< " succeeded; connected? " << isConnected;
diff --git a/audio/aidl/default/XsdcConversion.cpp b/audio/aidl/default/XsdcConversion.cpp
index 9e30347..1720949 100644
--- a/audio/aidl/default/XsdcConversion.cpp
+++ b/audio/aidl/default/XsdcConversion.cpp
@@ -205,24 +205,28 @@
ConversionResult<AudioIoFlags> convertIoFlagsToAidl(
const std::vector<ap_xsd::AudioInOutFlag>& flags, const ap_xsd::Role role,
bool flagsForMixPort) {
- int flagMask = 0;
+ int legacyFlagMask = 0;
if ((role == ap_xsd::Role::sink && flagsForMixPort) ||
(role == ap_xsd::Role::source && !flagsForMixPort)) {
for (const ap_xsd::AudioInOutFlag& flag : flags) {
audio_input_flags_t legacyFlag;
if (::android::InputFlagConverter::fromString(ap_xsd::toString(flag), legacyFlag)) {
- flagMask |= static_cast<int>(legacyFlag);
+ legacyFlagMask |= static_cast<int>(legacyFlag);
}
}
- return AudioIoFlags::make<AudioIoFlags::Tag::input>(flagMask);
+ return AudioIoFlags::make<AudioIoFlags::Tag::input>(
+ VALUE_OR_FATAL(legacy2aidl_audio_input_flags_t_int32_t_mask(
+ static_cast<audio_input_flags_t>(legacyFlagMask))));
} else {
for (const ap_xsd::AudioInOutFlag& flag : flags) {
audio_output_flags_t legacyFlag;
if (::android::OutputFlagConverter::fromString(ap_xsd::toString(flag), legacyFlag)) {
- flagMask |= static_cast<int>(legacyFlag);
+ legacyFlagMask |= static_cast<int>(legacyFlag);
}
}
- return AudioIoFlags::make<AudioIoFlags::Tag::output>(flagMask);
+ return AudioIoFlags::make<AudioIoFlags::Tag::output>(
+ VALUE_OR_FATAL(legacy2aidl_audio_output_flags_t_int32_t_mask(
+ static_cast<audio_output_flags_t>(legacyFlagMask))));
}
}
diff --git a/audio/aidl/default/bluetooth/ModuleBluetooth.cpp b/audio/aidl/default/bluetooth/ModuleBluetooth.cpp
index 502b153..8a1cbbf 100644
--- a/audio/aidl/default/bluetooth/ModuleBluetooth.cpp
+++ b/audio/aidl/default/bluetooth/ModuleBluetooth.cpp
@@ -33,8 +33,23 @@
using android::bluetooth::audio::aidl::BluetoothAudioPortAidl;
using android::bluetooth::audio::aidl::BluetoothAudioPortAidlOut;
+// TODO(b/312265159) bluetooth audio should be in its own process
+// Remove this and the shared_libs when that happens
+extern "C" binder_status_t createIBluetoothAudioProviderFactory();
+
namespace aidl::android::hardware::audio::core {
+ModuleBluetooth::ModuleBluetooth(std::unique_ptr<Module::Configuration>&& config)
+ : Module(Type::BLUETOOTH, std::move(config)) {
+ // TODO(b/312265159) bluetooth audio should be in its own process
+ // Remove this and the shared_libs when that happens
+ binder_status_t status = createIBluetoothAudioProviderFactory();
+ if (status != STATUS_OK) {
+ LOG(ERROR) << "Failed to create bluetooth audio provider factory. Status: "
+ << ::android::statusToString(status);
+ }
+}
+
ndk::ScopedAStatus ModuleBluetooth::getBluetoothA2dp(
std::shared_ptr<IBluetoothA2dp>* _aidl_return) {
*_aidl_return = getBtA2dp().getInstance();
diff --git a/audio/aidl/default/include/core-impl/ModuleBluetooth.h b/audio/aidl/default/include/core-impl/ModuleBluetooth.h
index a58798b..631b088 100644
--- a/audio/aidl/default/include/core-impl/ModuleBluetooth.h
+++ b/audio/aidl/default/include/core-impl/ModuleBluetooth.h
@@ -28,8 +28,7 @@
std::weak_ptr<IBluetoothLe>>
BtProfileHandles;
- ModuleBluetooth(std::unique_ptr<Configuration>&& config)
- : Module(Type::BLUETOOTH, std::move(config)) {}
+ ModuleBluetooth(std::unique_ptr<Configuration>&& config);
private:
ChildInterface<BluetoothA2dp>& getBtA2dp();
diff --git a/audio/aidl/default/include/core-impl/StreamPrimary.h b/audio/aidl/default/include/core-impl/StreamPrimary.h
index abc119c..145c3c4 100644
--- a/audio/aidl/default/include/core-impl/StreamPrimary.h
+++ b/audio/aidl/default/include/core-impl/StreamPrimary.h
@@ -27,13 +27,18 @@
public:
StreamPrimary(StreamContext* context, const Metadata& metadata);
+ ::android::status_t start() override;
::android::status_t transfer(void* buffer, size_t frameCount, size_t* actualFrameCount,
int32_t* latencyMs) override;
+ ::android::status_t refinePosition(StreamDescriptor::Position* position) override;
protected:
std::vector<alsa::DeviceProfile> getDeviceProfiles() override;
const bool mIsAsynchronous;
+ long mStartTimeNs = 0;
+ long mFramesSinceStart = 0;
+ bool mSkipNextTransfer = false;
};
class StreamInPrimary final : public StreamIn, public StreamSwitcher, public StreamInHwGainHelper {
diff --git a/audio/aidl/default/include/core-impl/StreamRemoteSubmix.h b/audio/aidl/default/include/core-impl/StreamRemoteSubmix.h
index 21592b3..ee10abf 100644
--- a/audio/aidl/default/include/core-impl/StreamRemoteSubmix.h
+++ b/audio/aidl/default/include/core-impl/StreamRemoteSubmix.h
@@ -71,6 +71,10 @@
static constexpr int kMaxReadFailureAttempts = 3;
// 5ms between two read attempts when pipe is empty
static constexpr int kReadAttemptSleepUs = 5000;
+
+ long mStartTimeNs = 0;
+ long mFramesSinceStart = 0;
+ int mReadErrorCount = 0;
};
class StreamInRemoteSubmix final : public StreamIn, public StreamSwitcher {
diff --git a/audio/aidl/default/primary/StreamPrimary.cpp b/audio/aidl/default/primary/StreamPrimary.cpp
index 7e3bdd4..7325a91 100644
--- a/audio/aidl/default/primary/StreamPrimary.cpp
+++ b/audio/aidl/default/primary/StreamPrimary.cpp
@@ -14,12 +14,11 @@
* limitations under the License.
*/
-#include <chrono>
-
#define LOG_TAG "AHAL_StreamPrimary"
#include <android-base/logging.h>
#include <android-base/properties.h>
#include <audio_utils/clock.h>
+#include <error/Result.h>
#include <error/expected_utils.h>
#include "PrimaryMixer.h"
@@ -43,26 +42,52 @@
context->startStreamDataProcessor();
}
+::android::status_t StreamPrimary::start() {
+ RETURN_STATUS_IF_ERROR(StreamAlsa::start());
+ mStartTimeNs = ::android::uptimeNanos();
+ mFramesSinceStart = 0;
+ mSkipNextTransfer = false;
+ return ::android::OK;
+}
+
::android::status_t StreamPrimary::transfer(void* buffer, size_t frameCount,
size_t* actualFrameCount, int32_t* latencyMs) {
- auto start = std::chrono::steady_clock::now();
- if (auto status = StreamAlsa::transfer(buffer, frameCount, actualFrameCount, latencyMs);
- status != ::android::OK) {
- return status;
- }
// This is a workaround for the emulator implementation which has a host-side buffer
- // and this can result in reading faster than real time.
- if (mIsInput && !mIsAsynchronous) {
- auto recordDurationUs = std::chrono::duration_cast<std::chrono::microseconds>(
- std::chrono::steady_clock::now() - start);
- const long projectedVsObservedOffsetUs =
- *actualFrameCount * MICROS_PER_SECOND / mContext.getSampleRate() -
- recordDurationUs.count();
- if (projectedVsObservedOffsetUs > 0) {
- LOG(VERBOSE) << __func__ << ": sleeping for " << projectedVsObservedOffsetUs << " us";
- usleep(projectedVsObservedOffsetUs);
- }
+ // and is not being able to achieve real-time behavior similar to ADSPs (b/302587331).
+ if (!mSkipNextTransfer) {
+ RETURN_STATUS_IF_ERROR(
+ StreamAlsa::transfer(buffer, frameCount, actualFrameCount, latencyMs));
+ } else {
+ LOG(DEBUG) << __func__ << ": skipping transfer (" << frameCount << " frames)";
+ *actualFrameCount = frameCount;
+ if (mIsInput) memset(buffer, 0, frameCount * mFrameSizeBytes);
+ mSkipNextTransfer = false;
}
+ if (!mIsAsynchronous) {
+ const long bufferDurationUs =
+ (*actualFrameCount) * MICROS_PER_SECOND / mContext.getSampleRate();
+ const auto totalDurationUs =
+ (::android::uptimeNanos() - mStartTimeNs) / NANOS_PER_MICROSECOND;
+ mFramesSinceStart += *actualFrameCount;
+ const long totalOffsetUs =
+ mFramesSinceStart * MICROS_PER_SECOND / mContext.getSampleRate() - totalDurationUs;
+ LOG(VERBOSE) << __func__ << ": totalOffsetUs " << totalOffsetUs;
+ if (totalOffsetUs > 0) {
+ const long sleepTimeUs = std::min(totalOffsetUs, bufferDurationUs);
+ LOG(VERBOSE) << __func__ << ": sleeping for " << sleepTimeUs << " us";
+ usleep(sleepTimeUs);
+ } else {
+ mSkipNextTransfer = true;
+ }
+ } else {
+ LOG(VERBOSE) << __func__ << ": asynchronous transfer";
+ }
+ return ::android::OK;
+}
+
+::android::status_t StreamPrimary::refinePosition(StreamDescriptor::Position*) {
+ // Since not all data is actually sent to the HAL, use the position maintained by Stream class
+ // which accounts for all frames passed from / to the client.
return ::android::OK;
}
@@ -91,8 +116,8 @@
GetBoolProperty("ro.boot.audio.tinyalsa.simulate_input", false);
return kSimulateInput || device.type.type == AudioDeviceType::IN_TELEPHONY_RX ||
device.type.type == AudioDeviceType::IN_FM_TUNER ||
- device.type.connection == AudioDeviceDescription::CONNECTION_BUS ||
- (device.type.type == AudioDeviceType::IN_DEVICE && device.type.connection.empty());
+ device.type.connection == AudioDeviceDescription::CONNECTION_BUS /*deprecated */ ||
+ (device.type.type == AudioDeviceType::IN_BUS && device.type.connection.empty());
}
StreamSwitcher::DeviceSwitchBehavior StreamInPrimary::switchCurrentStream(
@@ -163,8 +188,8 @@
static const bool kSimulateOutput =
GetBoolProperty("ro.boot.audio.tinyalsa.ignore_output", false);
return kSimulateOutput || device.type.type == AudioDeviceType::OUT_TELEPHONY_TX ||
- device.type.connection == AudioDeviceDescription::CONNECTION_BUS ||
- (device.type.type == AudioDeviceType::OUT_DEVICE && device.type.connection.empty());
+ device.type.connection == AudioDeviceDescription::CONNECTION_BUS /*deprecated*/ ||
+ (device.type.type == AudioDeviceType::OUT_BUS && device.type.connection.empty());
}
StreamSwitcher::DeviceSwitchBehavior StreamOutPrimary::switchCurrentStream(
diff --git a/audio/aidl/default/r_submix/StreamRemoteSubmix.cpp b/audio/aidl/default/r_submix/StreamRemoteSubmix.cpp
index fc61dcb..6258c93 100644
--- a/audio/aidl/default/r_submix/StreamRemoteSubmix.cpp
+++ b/audio/aidl/default/r_submix/StreamRemoteSubmix.cpp
@@ -16,6 +16,9 @@
#define LOG_TAG "AHAL_StreamRemoteSubmix"
#include <android-base/logging.h>
+#include <audio_utils/clock.h>
+#include <error/Result.h>
+#include <error/expected_utils.h>
#include "core-impl/StreamRemoteSubmix.h"
@@ -50,37 +53,33 @@
if (routeItr != sSubmixRoutes.end()) {
mCurrentRoute = routeItr->second;
}
- }
- // If route is not available for this port, add it.
- if (mCurrentRoute == nullptr) {
- // Initialize the pipe.
- mCurrentRoute = std::make_shared<SubmixRoute>();
- if (::android::OK != mCurrentRoute->createPipe(mStreamConfig)) {
- LOG(ERROR) << __func__ << ": create pipe failed";
- return ::android::NO_INIT;
- }
- {
- std::lock_guard guard(sSubmixRoutesLock);
- sSubmixRoutes.emplace(mDeviceAddress, mCurrentRoute);
- }
- } else {
- if (!mCurrentRoute->isStreamConfigValid(mIsInput, mStreamConfig)) {
- LOG(ERROR) << __func__ << ": invalid stream config";
- return ::android::NO_INIT;
- }
- sp<MonoPipe> sink = mCurrentRoute->getSink();
- if (sink == nullptr) {
- LOG(ERROR) << __func__ << ": nullptr sink when opening stream";
- return ::android::NO_INIT;
- }
- // If the sink has been shutdown or pipe recreation is forced, delete the pipe and
- // recreate it.
- if (sink->isShutdown()) {
- LOG(DEBUG) << __func__ << ": Non-nullptr shut down sink when opening stream";
- if (::android::OK != mCurrentRoute->resetPipe()) {
- LOG(ERROR) << __func__ << ": reset pipe failed";
+ // If route is not available for this port, add it.
+ if (mCurrentRoute == nullptr) {
+ // Initialize the pipe.
+ mCurrentRoute = std::make_shared<SubmixRoute>();
+ if (::android::OK != mCurrentRoute->createPipe(mStreamConfig)) {
+ LOG(ERROR) << __func__ << ": create pipe failed";
return ::android::NO_INIT;
}
+ sSubmixRoutes.emplace(mDeviceAddress, mCurrentRoute);
+ }
+ }
+ if (!mCurrentRoute->isStreamConfigValid(mIsInput, mStreamConfig)) {
+ LOG(ERROR) << __func__ << ": invalid stream config";
+ return ::android::NO_INIT;
+ }
+ sp<MonoPipe> sink = mCurrentRoute->getSink();
+ if (sink == nullptr) {
+ LOG(ERROR) << __func__ << ": nullptr sink when opening stream";
+ return ::android::NO_INIT;
+ }
+ // If the sink has been shutdown or pipe recreation is forced, delete the pipe and
+ // recreate it.
+ if (sink->isShutdown()) {
+ LOG(DEBUG) << __func__ << ": Non-nullptr shut down sink when opening stream";
+ if (::android::OK != mCurrentRoute->resetPipe()) {
+ LOG(ERROR) << __func__ << ": reset pipe failed";
+ return ::android::NO_INIT;
}
}
@@ -110,6 +109,8 @@
::android::status_t StreamRemoteSubmix::start() {
mCurrentRoute->exitStandby(mIsInput);
+ mStartTimeNs = ::android::uptimeNanos();
+ mFramesSinceStart = 0;
return ::android::OK;
}
@@ -161,8 +162,21 @@
*latencyMs = getDelayInUsForFrameCount(getStreamPipeSizeInFrames()) / 1000;
LOG(VERBOSE) << __func__ << ": Latency " << *latencyMs << "ms";
mCurrentRoute->exitStandby(mIsInput);
- return (mIsInput ? inRead(buffer, frameCount, actualFrameCount)
- : outWrite(buffer, frameCount, actualFrameCount));
+ RETURN_STATUS_IF_ERROR(mIsInput ? inRead(buffer, frameCount, actualFrameCount)
+ : outWrite(buffer, frameCount, actualFrameCount));
+ const long bufferDurationUs =
+ (*actualFrameCount) * MICROS_PER_SECOND / mContext.getSampleRate();
+ const long totalDurationUs = (::android::uptimeNanos() - mStartTimeNs) / NANOS_PER_MICROSECOND;
+ mFramesSinceStart += *actualFrameCount;
+ const long totalOffsetUs =
+ mFramesSinceStart * MICROS_PER_SECOND / mContext.getSampleRate() - totalDurationUs;
+ LOG(VERBOSE) << __func__ << ": totalOffsetUs " << totalOffsetUs;
+ if (totalOffsetUs > 0) {
+ const long sleepTimeUs = std::min(totalOffsetUs, bufferDurationUs);
+ LOG(VERBOSE) << __func__ << ": sleeping for " << sleepTimeUs << " us";
+ usleep(sleepTimeUs);
+ }
+ return ::android::OK;
}
::android::status_t StreamRemoteSubmix::refinePosition(StreamDescriptor::Position* position) {
@@ -200,12 +214,7 @@
if (sink != nullptr) {
if (sink->isShutdown()) {
sink.clear();
- const auto delayUs = getDelayInUsForFrameCount(frameCount);
- LOG(DEBUG) << __func__ << ": pipe shutdown, ignoring the write, sleeping for "
- << delayUs << " us";
- // the pipe has already been shutdown, this buffer will be lost but we must
- // simulate timing so we don't drain the output faster than realtime
- usleep(delayUs);
+ LOG(DEBUG) << __func__ << ": pipe shutdown, ignoring the write";
*actualFrameCount = frameCount;
return ::android::OK;
}
@@ -214,6 +223,9 @@
return ::android::UNKNOWN_ERROR;
}
+ LOG(VERBOSE) << __func__ << ": " << mDeviceAddress.toString() << ", " << frameCount
+ << " frames";
+
const bool shouldBlockWrite = mCurrentRoute->shouldBlockWrite();
size_t availableToWrite = sink->availableToWrite();
// NOTE: sink has been checked above and sink and source life cycles are synchronized
@@ -236,6 +248,8 @@
availableToWrite = sink->availableToWrite();
if (!shouldBlockWrite && frameCount > availableToWrite) {
+ LOG(WARNING) << __func__ << ": writing " << availableToWrite << " vs. requested "
+ << frameCount;
// Truncate the request to avoid blocking.
frameCount = availableToWrite;
}
@@ -258,92 +272,59 @@
*actualFrameCount = 0;
return ::android::UNKNOWN_ERROR;
}
- LOG(VERBOSE) << __func__ << ": wrote " << writtenFrames << "frames";
+ if (writtenFrames > 0 && frameCount > (size_t)writtenFrames) {
+ LOG(WARNING) << __func__ << ": wrote " << writtenFrames << " vs. requested " << frameCount;
+ }
*actualFrameCount = writtenFrames;
return ::android::OK;
}
::android::status_t StreamRemoteSubmix::inRead(void* buffer, size_t frameCount,
size_t* actualFrameCount) {
+ // in any case, it is emulated that data for the entire buffer was available
+ memset(buffer, 0, mStreamConfig.frameSize * frameCount);
+ *actualFrameCount = frameCount;
+
// about to read from audio source
sp<MonoPipeReader> source = mCurrentRoute->getSource();
if (source == nullptr) {
- int readErrorCount = mCurrentRoute->notifyReadError();
- if (readErrorCount < kMaxReadErrorLogs) {
+ if (++mReadErrorCount < kMaxReadErrorLogs) {
LOG(ERROR) << __func__
<< ": no audio pipe yet we're trying to read! (not all errors will be "
"logged)";
- } else {
- LOG(ERROR) << __func__ << ": Read errors " << readErrorCount;
}
- const auto delayUs = getDelayInUsForFrameCount(frameCount);
- LOG(DEBUG) << __func__ << ": no source, ignoring the read, sleeping for " << delayUs
- << " us";
- usleep(delayUs);
- memset(buffer, 0, mStreamConfig.frameSize * frameCount);
- *actualFrameCount = frameCount;
return ::android::OK;
}
+ LOG(VERBOSE) << __func__ << ": " << mDeviceAddress.toString() << ", " << frameCount
+ << " frames";
// read the data from the pipe
- int attempts = 0;
- const long delayUs = kReadAttemptSleepUs;
char* buff = (char*)buffer;
- size_t remainingFrames = frameCount;
- int availableToRead = source->availableToRead();
-
- while ((remainingFrames > 0) && (availableToRead > 0) && (attempts < kMaxReadFailureAttempts)) {
- LOG(VERBOSE) << __func__ << ": frames available to read " << availableToRead;
-
+ size_t actuallyRead = 0;
+ long remainingFrames = frameCount;
+ const long deadlineTimeNs = ::android::uptimeNanos() +
+ getDelayInUsForFrameCount(frameCount) * NANOS_PER_MICROSECOND;
+ while (remainingFrames > 0) {
ssize_t framesRead = source->read(buff, remainingFrames);
-
LOG(VERBOSE) << __func__ << ": frames read " << framesRead;
-
if (framesRead > 0) {
remainingFrames -= framesRead;
buff += framesRead * mStreamConfig.frameSize;
- availableToRead -= framesRead;
- LOG(VERBOSE) << __func__ << ": (attempts = " << attempts << ") got " << framesRead
+ LOG(VERBOSE) << __func__ << ": got " << framesRead
<< " frames, remaining =" << remainingFrames;
- } else {
- attempts++;
- LOG(WARNING) << __func__ << ": read returned " << framesRead
- << " , read failure attempts = " << attempts << ", sleeping for "
- << delayUs << " us";
- usleep(delayUs);
+ actuallyRead += framesRead;
+ }
+ if (::android::uptimeNanos() >= deadlineTimeNs) break;
+ if (framesRead <= 0) {
+ LOG(VERBOSE) << __func__ << ": read returned " << framesRead
+ << ", read failure, sleeping for " << kReadAttemptSleepUs << " us";
+ usleep(kReadAttemptSleepUs);
}
}
- // done using the source
- source.clear();
-
- if (remainingFrames > 0) {
- const size_t remainingBytes = remainingFrames * mStreamConfig.frameSize;
- LOG(VERBOSE) << __func__ << ": clearing remaining_frames = " << remainingFrames;
- memset(((char*)buffer) + (mStreamConfig.frameSize * frameCount) - remainingBytes, 0,
- remainingBytes);
+ if (actuallyRead < frameCount) {
+ LOG(WARNING) << __func__ << ": read " << actuallyRead << " vs. requested " << frameCount;
}
-
- long readCounterFrames = mCurrentRoute->updateReadCounterFrames(frameCount);
- *actualFrameCount = frameCount;
-
- // compute how much we need to sleep after reading the data by comparing the wall clock with
- // the projected time at which we should return.
- // wall clock after reading from the pipe
- auto recordDurationUs = std::chrono::duration_cast<std::chrono::microseconds>(
- std::chrono::steady_clock::now() - mCurrentRoute->getRecordStartTime());
-
- // readCounterFrames contains the number of frames that have been read since the beginning of
- // recording (including this call): it's converted to usec and compared to how long we've been
- // recording for, which gives us how long we must wait to sync the projected recording time, and
- // the observed recording time.
- const long projectedVsObservedOffsetUs =
- getDelayInUsForFrameCount(readCounterFrames) - recordDurationUs.count();
-
- LOG(VERBOSE) << __func__ << ": record duration " << recordDurationUs.count()
- << " us, will wait: " << projectedVsObservedOffsetUs << " us";
- if (projectedVsObservedOffsetUs > 0) {
- usleep(projectedVsObservedOffsetUs);
- }
+ mCurrentRoute->updateReadCounterFrames(*actualFrameCount);
return ::android::OK;
}
diff --git a/audio/aidl/default/r_submix/SubmixRoute.cpp b/audio/aidl/default/r_submix/SubmixRoute.cpp
index ddac64d..f04e607 100644
--- a/audio/aidl/default/r_submix/SubmixRoute.cpp
+++ b/audio/aidl/default/r_submix/SubmixRoute.cpp
@@ -81,11 +81,6 @@
return (mStreamInOpen || (mStreamInStandby && (mReadCounterFrames != 0)));
}
-int SubmixRoute::notifyReadError() {
- std::lock_guard guard(mLock);
- return ++mReadErrorCount;
-}
-
long SubmixRoute::updateReadCounterFrames(size_t frameCount) {
std::lock_guard guard(mLock);
mReadCounterFrames += frameCount;
@@ -103,7 +98,6 @@
}
mStreamInStandby = true;
mReadCounterFrames = 0;
- mReadErrorCount = 0;
} else {
mStreamOutOpen = true;
}
@@ -214,9 +208,6 @@
if (mStreamInStandby || mStreamOutStandbyTransition) {
mStreamInStandby = false;
mStreamOutStandbyTransition = false;
- // keep track of when we exit input standby (== first read == start "real recording")
- // or when we start recording silence, and reset projected time
- mRecordStartTime = std::chrono::steady_clock::now();
mReadCounterFrames = 0;
}
} else {
diff --git a/audio/aidl/default/r_submix/SubmixRoute.h b/audio/aidl/default/r_submix/SubmixRoute.h
index 92b95e9..252b1c9 100644
--- a/audio/aidl/default/r_submix/SubmixRoute.h
+++ b/audio/aidl/default/r_submix/SubmixRoute.h
@@ -16,7 +16,6 @@
#pragma once
-#include <chrono>
#include <mutex>
#include <android-base/thread_annotations.h>
@@ -83,14 +82,6 @@
std::lock_guard guard(mLock);
return mReadCounterFrames;
}
- int getReadErrorCount() {
- std::lock_guard guard(mLock);
- return mReadErrorCount;
- }
- std::chrono::time_point<std::chrono::steady_clock> getRecordStartTime() {
- std::lock_guard guard(mLock);
- return mRecordStartTime;
- }
sp<MonoPipe> getSink() {
std::lock_guard guard(mLock);
return mSink;
@@ -126,9 +117,6 @@
bool mStreamOutStandby GUARDED_BY(mLock) = true;
// how many frames have been requested to be read since standby
long mReadCounterFrames GUARDED_BY(mLock) = 0;
- int mReadErrorCount GUARDED_BY(mLock) = 0;
- // wall clock when recording starts
- std::chrono::time_point<std::chrono::steady_clock> mRecordStartTime GUARDED_BY(mLock);
// Pipe variables: they handle the ring buffer that "pipes" audio:
// - from the submix virtual audio output == what needs to be played
diff --git a/audio/aidl/vts/Android.bp b/audio/aidl/vts/Android.bp
index ad816c7..191f928 100644
--- a/audio/aidl/vts/Android.bp
+++ b/audio/aidl/vts/Android.bp
@@ -86,6 +86,9 @@
name: "VtsHalDownmixTargetTest",
defaults: ["VtsHalAudioTargetTestDefaults"],
srcs: ["VtsHalDownmixTargetTest.cpp"],
+ shared_libs: [
+ "libaudioutils",
+ ],
}
cc_test {
diff --git a/audio/aidl/vts/EffectHelper.h b/audio/aidl/vts/EffectHelper.h
index 2c8edf2..d813554 100644
--- a/audio/aidl/vts/EffectHelper.h
+++ b/audio/aidl/vts/EffectHelper.h
@@ -283,4 +283,32 @@
}
return functor(result);
}
+
+ static void processAndWriteToOutput(std::vector<float>& inputBuffer,
+ std::vector<float>& outputBuffer,
+ const std::shared_ptr<IEffect>& mEffect,
+ IEffect::OpenEffectReturn* mOpenEffectReturn) {
+ // Initialize AidlMessagequeues
+ auto statusMQ = std::make_unique<EffectHelper::StatusMQ>(mOpenEffectReturn->statusMQ);
+ ASSERT_TRUE(statusMQ->isValid());
+ auto inputMQ = std::make_unique<EffectHelper::DataMQ>(mOpenEffectReturn->inputDataMQ);
+ ASSERT_TRUE(inputMQ->isValid());
+ auto outputMQ = std::make_unique<EffectHelper::DataMQ>(mOpenEffectReturn->outputDataMQ);
+ ASSERT_TRUE(outputMQ->isValid());
+
+ // Enabling the process
+ ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START));
+ ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING));
+
+ // Write from buffer to message queues and calling process
+ EXPECT_NO_FATAL_FAILURE(EffectHelper::writeToFmq(statusMQ, inputMQ, inputBuffer));
+
+ // Read the updated message queues into buffer
+ EXPECT_NO_FATAL_FAILURE(EffectHelper::readFromFmq(statusMQ, 1, outputMQ,
+ outputBuffer.size(), outputBuffer));
+
+ // Disable the process
+ ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::RESET));
+ ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
+ }
};
diff --git a/audio/aidl/vts/VtsHalDownmixTargetTest.cpp b/audio/aidl/vts/VtsHalDownmixTargetTest.cpp
index c01a9a2..d7db567 100644
--- a/audio/aidl/vts/VtsHalDownmixTargetTest.cpp
+++ b/audio/aidl/vts/VtsHalDownmixTargetTest.cpp
@@ -18,88 +18,114 @@
#define LOG_TAG "VtsHalDownmixTargetTest"
#include <android-base/logging.h>
+#include <audio_utils/ChannelMix.h>
#include "EffectHelper.h"
using namespace android;
+using aidl::android::hardware::audio::common::getChannelCount;
using aidl::android::hardware::audio::effect::Descriptor;
using aidl::android::hardware::audio::effect::Downmix;
using aidl::android::hardware::audio::effect::getEffectTypeUuidDownmix;
using aidl::android::hardware::audio::effect::IEffect;
using aidl::android::hardware::audio::effect::IFactory;
using aidl::android::hardware::audio::effect::Parameter;
+using android::audio_utils::channels::ChannelMix;
using android::hardware::audio::common::testing::detail::TestExecutionTracer;
-/**
- * Here we focus on specific parameter checking, general IEffect interfaces testing performed in
- * VtsAudioEffectTargetTest.
- */
-enum ParamName { PARAM_INSTANCE_NAME, PARAM_TYPE };
-using DownmixParamTestParam =
- std::tuple<std::pair<std::shared_ptr<IFactory>, Descriptor>, Downmix::Type>;
// Testing for enum values
-const std::vector<Downmix::Type> kTypeValues = {Downmix::Type::STRIP, Downmix::Type::FOLD};
+static const std::vector<Downmix::Type> kTypeValues = {ndk::enum_range<Downmix::Type>().begin(),
+ ndk::enum_range<Downmix::Type>().end()};
-class DownmixParamTest : public ::testing::TestWithParam<DownmixParamTestParam>,
- public EffectHelper {
+// Testing for supported layouts from AudioChannelLayout.h
+static const std::vector<int32_t> kLayoutValues = {
+ AudioChannelLayout::LAYOUT_STEREO, AudioChannelLayout::LAYOUT_2POINT1,
+ AudioChannelLayout::LAYOUT_TRI, AudioChannelLayout::LAYOUT_TRI_BACK,
+ AudioChannelLayout::LAYOUT_3POINT1, AudioChannelLayout::LAYOUT_2POINT0POINT2,
+ AudioChannelLayout::LAYOUT_2POINT1POINT2, AudioChannelLayout::LAYOUT_3POINT0POINT2,
+ AudioChannelLayout::LAYOUT_3POINT1POINT2, AudioChannelLayout::LAYOUT_QUAD,
+ AudioChannelLayout::LAYOUT_QUAD_SIDE, AudioChannelLayout::LAYOUT_SURROUND,
+ AudioChannelLayout::LAYOUT_PENTA, AudioChannelLayout::LAYOUT_5POINT1,
+ AudioChannelLayout::LAYOUT_5POINT1_SIDE, AudioChannelLayout::LAYOUT_5POINT1POINT2,
+ AudioChannelLayout::LAYOUT_5POINT1POINT4, AudioChannelLayout::LAYOUT_6POINT1,
+ AudioChannelLayout::LAYOUT_7POINT1, AudioChannelLayout::LAYOUT_7POINT1POINT2,
+ AudioChannelLayout::LAYOUT_7POINT1POINT4, AudioChannelLayout::LAYOUT_9POINT1POINT4,
+ AudioChannelLayout::LAYOUT_9POINT1POINT6, AudioChannelLayout::LAYOUT_13POINT_360RA,
+ AudioChannelLayout::LAYOUT_22POINT2};
+
+static const std::vector<int32_t> kChannels = {
+ AudioChannelLayout::CHANNEL_FRONT_LEFT,
+ AudioChannelLayout::CHANNEL_FRONT_RIGHT,
+ AudioChannelLayout::CHANNEL_FRONT_CENTER,
+ AudioChannelLayout::CHANNEL_LOW_FREQUENCY,
+ AudioChannelLayout::CHANNEL_BACK_LEFT,
+ AudioChannelLayout::CHANNEL_BACK_RIGHT,
+ AudioChannelLayout::CHANNEL_BACK_CENTER,
+ AudioChannelLayout::CHANNEL_SIDE_LEFT,
+ AudioChannelLayout::CHANNEL_SIDE_RIGHT,
+ AudioChannelLayout::CHANNEL_FRONT_LEFT_OF_CENTER,
+ AudioChannelLayout::CHANNEL_FRONT_RIGHT_OF_CENTER,
+ AudioChannelLayout::CHANNEL_TOP_CENTER,
+ AudioChannelLayout::CHANNEL_TOP_FRONT_LEFT,
+ AudioChannelLayout::CHANNEL_TOP_FRONT_CENTER,
+ AudioChannelLayout::CHANNEL_TOP_FRONT_RIGHT,
+ AudioChannelLayout::CHANNEL_TOP_BACK_LEFT,
+ AudioChannelLayout::CHANNEL_TOP_BACK_CENTER,
+ AudioChannelLayout::CHANNEL_TOP_BACK_RIGHT,
+ AudioChannelLayout::CHANNEL_TOP_SIDE_LEFT,
+ AudioChannelLayout::CHANNEL_TOP_SIDE_RIGHT,
+ AudioChannelLayout::CHANNEL_BOTTOM_FRONT_LEFT,
+ AudioChannelLayout::CHANNEL_BOTTOM_FRONT_CENTER,
+ AudioChannelLayout::CHANNEL_BOTTOM_FRONT_RIGHT,
+ AudioChannelLayout::CHANNEL_LOW_FREQUENCY_2,
+ AudioChannelLayout::CHANNEL_FRONT_WIDE_LEFT,
+ AudioChannelLayout::CHANNEL_FRONT_WIDE_RIGHT,
+};
+
+class DownmixEffectHelper : public EffectHelper {
public:
- DownmixParamTest() : mParamType(std::get<PARAM_TYPE>(GetParam())) {
- std::tie(mFactory, mDescriptor) = std::get<PARAM_INSTANCE_NAME>(GetParam());
- }
-
- void SetUp() override {
+ void SetUpDownmix(int32_t inputBufferLayout = AudioChannelLayout::LAYOUT_STEREO) {
ASSERT_NE(nullptr, mFactory);
ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
+ AudioChannelLayout inputChannelLayout =
+ AudioChannelLayout::make<AudioChannelLayout::layoutMask>(inputBufferLayout);
+
Parameter::Specific specific = getDefaultParamSpecific();
Parameter::Common common = EffectHelper::createParamCommon(
0 /* session */, 1 /* ioHandle */, 44100 /* iSampleRate */, 44100 /* oSampleRate */,
- kInputFrameCount /* iFrameCount */, kOutputFrameCount /* oFrameCount */);
- IEffect::OpenEffectReturn ret;
- ASSERT_NO_FATAL_FAILURE(open(mEffect, common, specific, &ret, EX_NONE));
+ kInputFrameCount /* iFrameCount */, kOutputFrameCount /* oFrameCount */,
+ inputChannelLayout);
+ ASSERT_NO_FATAL_FAILURE(open(mEffect, common, specific, &mOpenEffectReturn, EX_NONE));
ASSERT_NE(nullptr, mEffect);
}
- void TearDown() override {
+ void TearDownDownmix() {
ASSERT_NO_FATAL_FAILURE(close(mEffect));
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
+ mOpenEffectReturn = IEffect::OpenEffectReturn{};
}
- static const long kInputFrameCount = 0x100, kOutputFrameCount = 0x100;
- std::shared_ptr<IFactory> mFactory;
- std::shared_ptr<IEffect> mEffect;
- Descriptor mDescriptor;
- Downmix::Type mParamType = Downmix::Type::STRIP;
-
- void SetAndGetDownmixParameters() {
- for (auto& it : mTags) {
- auto& tag = it.first;
- auto& dm = it.second;
-
- // set parameter
- Parameter expectParam;
- Parameter::Specific specific;
- specific.set<Parameter::Specific::downmix>(dm);
- expectParam.set<Parameter::specific>(specific);
- // All values are valid, set parameter should succeed
- EXPECT_STATUS(EX_NONE, mEffect->setParameter(expectParam)) << expectParam.toString();
-
- // get parameter
- Parameter getParam;
- Parameter::Id id;
- Downmix::Id dmId;
- dmId.set<Downmix::Id::commonTag>(tag);
- id.set<Parameter::Id::downmixTag>(dmId);
- EXPECT_STATUS(EX_NONE, mEffect->getParameter(id, &getParam));
-
- EXPECT_EQ(expectParam, getParam);
- }
+ Parameter createDownmixParam(Downmix::Type type) {
+ return Parameter::make<Parameter::specific>(
+ Parameter::Specific::make<Parameter::Specific::downmix>(
+ Downmix::make<Downmix::type>(type)));
+ }
+ void setParameters(Downmix::Type type) {
+ // set parameter
+ auto param = createDownmixParam(type);
+ EXPECT_STATUS(EX_NONE, mEffect->setParameter(param)) << param.toString();
}
- void addTypeParam(Downmix::Type type) {
- Downmix dm;
- dm.set<Downmix::type>(type);
- mTags.push_back({Downmix::type, dm});
+ void validateParameters(Downmix::Type type) {
+ auto leId = Downmix::Id::make<Downmix::Id::commonTag>(Downmix::Tag(Downmix::type));
+ auto id = Parameter::Id::make<Parameter::Id::downmixTag>(leId);
+ // get parameter
+ Parameter getParam;
+ EXPECT_STATUS(EX_NONE, mEffect->getParameter(id, &getParam));
+ auto expectedParam = createDownmixParam(type);
+ EXPECT_EQ(expectedParam, getParam) << "\nexpectedParam:" << expectedParam.toString()
+ << "\ngetParam:" << getParam.toString();
}
Parameter::Specific getDefaultParamSpecific() {
@@ -108,14 +134,281 @@
return specific;
}
- private:
- std::vector<std::pair<Downmix::Tag, Downmix>> mTags;
- void CleanUp() { mTags.clear(); }
+ void setDataTestParams(int32_t layoutType) {
+ mInputBuffer.resize(kBufferSize);
+ mOutputBuffer.resize(kBufferSize);
+
+ // Get the number of channels used
+ mInputChannelCount = getChannelCount(
+ AudioChannelLayout::make<AudioChannelLayout::layoutMask>(layoutType));
+
+ // In case of downmix, output is always configured to stereo layout.
+ mOutputBufferSize = (mInputBuffer.size() / mInputChannelCount) * kOutputChannelCount;
+ }
+
+ // Generate mInputBuffer values between -kMaxDownmixSample to kMaxDownmixSample
+ void generateInputBuffer(size_t position, bool isStrip) {
+ size_t increment;
+ if (isStrip)
+ // Fill input at all the channels
+ increment = 1;
+ else
+ // Fill input at only one channel
+ increment = mInputChannelCount;
+
+ for (size_t i = position; i < mInputBuffer.size(); i += increment) {
+ mInputBuffer[i] =
+ ((static_cast<float>(std::rand()) / RAND_MAX) * 2 - 1) * kMaxDownmixSample;
+ }
+ }
+
+ bool isLayoutValid(int32_t inputLayout) {
+ if (inputLayout & kMaxChannelMask) {
+ return false;
+ }
+ return true;
+ }
+
+ static constexpr long kInputFrameCount = 100, kOutputFrameCount = 100;
+ std::shared_ptr<IFactory> mFactory;
+ Descriptor mDescriptor;
+ std::shared_ptr<IEffect> mEffect;
+ IEffect::OpenEffectReturn mOpenEffectReturn;
+
+ std::vector<float> mInputBuffer;
+ std::vector<float> mOutputBuffer;
+ size_t mInputChannelCount;
+ size_t mOutputBufferSize;
+ static constexpr size_t kBufferSize = 128;
+ static constexpr float kMaxDownmixSample = 1;
+ static constexpr int kOutputChannelCount = 2;
+ // Mask for layouts greater than MAX_INPUT_CHANNELS_SUPPORTED
+ static constexpr int32_t kMaxChannelMask =
+ ~((1 << ChannelMix<AUDIO_CHANNEL_OUT_STEREO>::MAX_INPUT_CHANNELS_SUPPORTED) - 1);
+};
+
+/**
+ * Here we focus on specific parameter checking, general IEffect interfaces testing performed in
+ * VtsAudioEffectTargetTest.
+ */
+enum ParamName { PARAM_INSTANCE_NAME, PARAM_TYPE };
+
+using DownmixParamTestParam =
+ std::tuple<std::pair<std::shared_ptr<IFactory>, Descriptor>, Downmix::Type>;
+
+class DownmixParamTest : public ::testing::TestWithParam<DownmixParamTestParam>,
+ public DownmixEffectHelper {
+ public:
+ DownmixParamTest() : mParamType(std::get<PARAM_TYPE>(GetParam())) {
+ std::tie(mFactory, mDescriptor) = std::get<PARAM_INSTANCE_NAME>(GetParam());
+ }
+
+ void SetUp() override { SetUpDownmix(); }
+
+ void TearDown() override { TearDownDownmix(); }
+
+ const Downmix::Type mParamType;
};
TEST_P(DownmixParamTest, SetAndGetType) {
- EXPECT_NO_FATAL_FAILURE(addTypeParam(mParamType));
- SetAndGetDownmixParameters();
+ ASSERT_NO_FATAL_FAILURE(setParameters(mParamType));
+ ASSERT_NO_FATAL_FAILURE(validateParameters(mParamType));
+}
+
+enum FoldParamName { FOLD_INSTANCE_NAME, FOLD_INPUT_LAYOUT, FOLD_TEST_CHANNEL };
+
+using DownmixDataTestParamFold =
+ std::tuple<std::pair<std::shared_ptr<IFactory>, Descriptor>, int32_t>;
+
+class DownmixFoldDataTest : public ::testing::TestWithParam<DownmixDataTestParamFold>,
+ public DownmixEffectHelper {
+ public:
+ DownmixFoldDataTest() : mInputChannelLayout(std::get<FOLD_INPUT_LAYOUT>(GetParam())) {
+ std::tie(mFactory, mDescriptor) = std::get<FOLD_INSTANCE_NAME>(GetParam());
+ }
+
+ void SetUp() override {
+ SetUpDownmix(mInputChannelLayout);
+ if (!isLayoutValid(mInputChannelLayout)) {
+ GTEST_SKIP() << "Layout not supported \n";
+ }
+ setDataTestParams(mInputChannelLayout);
+ }
+
+ void TearDown() override { TearDownDownmix(); }
+
+ void checkAtLeft(int32_t position) {
+ for (size_t i = 0, j = position; i < mOutputBufferSize;
+ i += kOutputChannelCount, j += mInputChannelCount) {
+ // Validate Left channel has audio
+ if (mInputBuffer[j] != 0) {
+ ASSERT_NE(mOutputBuffer[i], 0);
+ } else {
+ // No change in output when input is 0
+ ASSERT_EQ(mOutputBuffer[i], mInputBuffer[j]);
+ }
+ // Validate Right channel has no audio
+ ASSERT_EQ(mOutputBuffer[i + 1], 0);
+ }
+ }
+
+ void checkAtRight(int32_t position) {
+ for (size_t i = 0, j = position; i < mOutputBufferSize;
+ i += kOutputChannelCount, j += mInputChannelCount) {
+ // Validate Left channel has no audio
+ ASSERT_EQ(mOutputBuffer[i], 0);
+ // Validate Right channel has audio
+ if (mInputBuffer[j] != 0) {
+ ASSERT_NE(mOutputBuffer[i + 1], 0);
+ } else {
+ // No change in output when input is 0
+ ASSERT_EQ(mOutputBuffer[i + 1], mInputBuffer[j]);
+ }
+ }
+ }
+
+ void checkAtCenter(size_t position) {
+ for (size_t i = 0, j = position; i < mOutputBufferSize;
+ i += kOutputChannelCount, j += mInputChannelCount) {
+ // Validate both channels have audio
+ if (mInputBuffer[j] != 0) {
+ ASSERT_NE(mOutputBuffer[i], 0);
+ ASSERT_NE(mOutputBuffer[i + 1], 0);
+
+ } else {
+ // No change in output when input is 0
+ ASSERT_EQ(mOutputBuffer[i], mInputBuffer[j]);
+ ASSERT_EQ(mOutputBuffer[i + 1], mInputBuffer[j]);
+ }
+ }
+ }
+
+ void validateOutput(int32_t channel, size_t position) {
+ switch (channel) {
+ case AudioChannelLayout::CHANNEL_FRONT_LEFT:
+ case AudioChannelLayout::CHANNEL_BACK_LEFT:
+ case AudioChannelLayout::CHANNEL_SIDE_LEFT:
+ case AudioChannelLayout::CHANNEL_TOP_FRONT_LEFT:
+ case AudioChannelLayout::CHANNEL_BOTTOM_FRONT_LEFT:
+ case AudioChannelLayout::CHANNEL_TOP_BACK_LEFT:
+ case AudioChannelLayout::CHANNEL_FRONT_WIDE_LEFT:
+ case AudioChannelLayout::CHANNEL_TOP_SIDE_LEFT:
+ checkAtLeft(position);
+ break;
+
+ case AudioChannelLayout::CHANNEL_FRONT_RIGHT:
+ case AudioChannelLayout::CHANNEL_BACK_RIGHT:
+ case AudioChannelLayout::CHANNEL_SIDE_RIGHT:
+ case AudioChannelLayout::CHANNEL_TOP_FRONT_RIGHT:
+ case AudioChannelLayout::CHANNEL_BOTTOM_FRONT_RIGHT:
+ case AudioChannelLayout::CHANNEL_TOP_BACK_RIGHT:
+ case AudioChannelLayout::CHANNEL_FRONT_WIDE_RIGHT:
+ case AudioChannelLayout::CHANNEL_TOP_SIDE_RIGHT:
+ case AudioChannelLayout::CHANNEL_LOW_FREQUENCY_2:
+ checkAtRight(position);
+ break;
+
+ case AudioChannelLayout::CHANNEL_FRONT_CENTER:
+ case AudioChannelLayout::CHANNEL_BACK_CENTER:
+ case AudioChannelLayout::CHANNEL_TOP_FRONT_CENTER:
+ case AudioChannelLayout::CHANNEL_BOTTOM_FRONT_CENTER:
+ case AudioChannelLayout::CHANNEL_FRONT_LEFT_OF_CENTER:
+ case AudioChannelLayout::CHANNEL_FRONT_RIGHT_OF_CENTER:
+ case AudioChannelLayout::CHANNEL_TOP_CENTER:
+ case AudioChannelLayout::CHANNEL_TOP_BACK_CENTER:
+ checkAtCenter(position);
+ break;
+
+ case AudioChannelLayout::CHANNEL_LOW_FREQUENCY:
+ // If CHANNEL_LOW_FREQUENCY_2 is supported
+ if (mInputChannelLayout & AudioChannelLayout::CHANNEL_LOW_FREQUENCY_2) {
+ // Validate that only Left channel has audio
+ checkAtLeft(position);
+ } else {
+ // Validate that both channels have audio
+ checkAtCenter(position);
+ }
+ break;
+ }
+ }
+
+ std::set<int32_t> getInputChannelLayouts() {
+ std::set<int32_t> supportedChannels;
+ for (int32_t channel : kChannels) {
+ if ((mInputChannelLayout & channel) == channel) {
+ supportedChannels.insert(channel);
+ }
+ }
+ return supportedChannels;
+ }
+
+ int32_t mInputChannelLayout;
+};
+
+TEST_P(DownmixFoldDataTest, DownmixProcessData) {
+ // Set FOLD type parameter
+ ASSERT_NO_FATAL_FAILURE(setParameters(Downmix::Type::FOLD));
+
+ // Get all the channels from input layout
+ std::set<int32_t> supportedChannels = getInputChannelLayouts();
+
+ for (int32_t channel : supportedChannels) {
+ size_t position = std::distance(supportedChannels.begin(), supportedChannels.find(channel));
+ generateInputBuffer(position, false /*isStripe*/);
+ ASSERT_NO_FATAL_FAILURE(
+ processAndWriteToOutput(mInputBuffer, mOutputBuffer, mEffect, &mOpenEffectReturn));
+ validateOutput(channel, position);
+ std::fill(mInputBuffer.begin(), mInputBuffer.end(), 0);
+ }
+}
+
+enum StripParamName { STRIP_INSTANCE_NAME, STRIP_INPUT_LAYOUT };
+
+using DownmixStripDataTestParam =
+ std::tuple<std::pair<std::shared_ptr<IFactory>, Descriptor>, int32_t>;
+
+class DownmixStripDataTest : public ::testing::TestWithParam<DownmixStripDataTestParam>,
+ public DownmixEffectHelper {
+ public:
+ DownmixStripDataTest() : mInputChannelLayout(std::get<STRIP_INPUT_LAYOUT>(GetParam())) {
+ std::tie(mFactory, mDescriptor) = std::get<STRIP_INSTANCE_NAME>(GetParam());
+ }
+
+ void SetUp() override {
+ SetUpDownmix(mInputChannelLayout);
+ if (!isLayoutValid(mInputChannelLayout)) {
+ GTEST_SKIP() << "Layout not supported \n";
+ }
+ setDataTestParams(mInputChannelLayout);
+ }
+
+ void TearDown() override { TearDownDownmix(); }
+
+ void validateOutput() {
+ ASSERT_EQ(kBufferSize, mInputBuffer.size());
+ ASSERT_GE(kBufferSize, mOutputBufferSize);
+ for (size_t i = 0, j = 0; i < kBufferSize && j < mOutputBufferSize;
+ i += mInputChannelCount, j += kOutputChannelCount) {
+ ASSERT_EQ(mOutputBuffer[j], mInputBuffer[i]);
+ ASSERT_EQ(mOutputBuffer[j + 1], mInputBuffer[i + 1]);
+ }
+ for (size_t i = mOutputBufferSize; i < kBufferSize; i++) {
+ ASSERT_EQ(mOutputBuffer[i], mInputBuffer[i]);
+ }
+ }
+
+ int32_t mInputChannelLayout;
+};
+
+TEST_P(DownmixStripDataTest, DownmixProcessData) {
+ // Set STRIP type parameter
+ ASSERT_NO_FATAL_FAILURE(setParameters(Downmix::Type::STRIP));
+
+ // Generate input buffer, call process and compare outputs
+ generateInputBuffer(0 /*position*/, true /*isStripe*/);
+ ASSERT_NO_FATAL_FAILURE(
+ processAndWriteToOutput(mInputBuffer, mOutputBuffer, mEffect, &mOpenEffectReturn));
+ validateOutput();
}
INSTANTIATE_TEST_SUITE_P(
@@ -134,6 +427,39 @@
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(DownmixParamTest);
+INSTANTIATE_TEST_SUITE_P(
+ DownmixTest, DownmixFoldDataTest,
+ ::testing::Combine(testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(
+ IFactory::descriptor, getEffectTypeUuidDownmix())),
+ testing::ValuesIn(kLayoutValues)),
+ [](const testing::TestParamInfo<DownmixFoldDataTest::ParamType>& info) {
+ auto descriptor = std::get<FOLD_INSTANCE_NAME>(info.param).second;
+ std::string layout = std::to_string(std::get<FOLD_INPUT_LAYOUT>(info.param));
+ std::string name = getPrefix(descriptor) + "_fold" + "_layout" + layout;
+ std::replace_if(
+ name.begin(), name.end(), [](const char c) { return !std::isalnum(c); }, '_');
+ return name;
+ });
+
+GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(DownmixFoldDataTest);
+
+INSTANTIATE_TEST_SUITE_P(
+ DownmixTest, DownmixStripDataTest,
+ ::testing::Combine(testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(
+ IFactory::descriptor, getEffectTypeUuidDownmix())),
+ testing::ValuesIn(kLayoutValues)),
+ [](const testing::TestParamInfo<DownmixStripDataTest::ParamType>& info) {
+ auto descriptor = std::get<STRIP_INSTANCE_NAME>(info.param).second;
+ std::string layout =
+ std::to_string(static_cast<int>(std::get<STRIP_INPUT_LAYOUT>(info.param)));
+ std::string name = getPrefix(descriptor) + "_strip" + "_layout" + layout;
+ std::replace_if(
+ name.begin(), name.end(), [](const char c) { return !std::isalnum(c); }, '_');
+ return name;
+ });
+
+GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(DownmixStripDataTest);
+
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
::testing::UnitTest::GetInstance()->listeners().Append(new TestExecutionTracer());
diff --git a/audio/effect/4.0/xml/Android.bp b/audio/effect/4.0/xml/Android.bp
index 8c03a35..bdffe60 100644
--- a/audio/effect/4.0/xml/Android.bp
+++ b/audio/effect/4.0/xml/Android.bp
@@ -9,9 +9,9 @@
genrule {
name: "audio_effects_conf_V4_0",
- srcs: ["audio_effects_conf.xsd"],
+ srcs: [":audio_effects_conf_V2_0"],
out: [
"audio_effects_conf_V4_0.xsd",
],
- cmd: "cp -f $(in) $(genDir)/audio_effects_conf_V4_0.xsd",
+ cmd: "cp -f $(in) $(out)",
}
diff --git a/audio/effect/4.0/xml/audio_effects_conf.xsd b/audio/effect/4.0/xml/audio_effects_conf.xsd
deleted file mode 120000
index 9d85fa7..0000000
--- a/audio/effect/4.0/xml/audio_effects_conf.xsd
+++ /dev/null
@@ -1 +0,0 @@
-../../2.0/xml/audio_effects_conf.xsd
\ No newline at end of file
diff --git a/audio/effect/5.0/xml/Android.bp b/audio/effect/5.0/xml/Android.bp
index 7982e2a..ed12e38 100644
--- a/audio/effect/5.0/xml/Android.bp
+++ b/audio/effect/5.0/xml/Android.bp
@@ -9,6 +9,6 @@
xsd_config {
name: "audio_effects_conf_V5_0",
- srcs: ["audio_effects_conf.xsd"],
+ srcs: [":audio_effects_conf_V2_0"],
package_name: "audio.effects.V5_0",
}
diff --git a/audio/effect/5.0/xml/audio_effects_conf.xsd b/audio/effect/5.0/xml/audio_effects_conf.xsd
deleted file mode 120000
index 9d85fa7..0000000
--- a/audio/effect/5.0/xml/audio_effects_conf.xsd
+++ /dev/null
@@ -1 +0,0 @@
-../../2.0/xml/audio_effects_conf.xsd
\ No newline at end of file
diff --git a/automotive/can/1.0/default/libnetdevice/libnetdevice.cpp b/automotive/can/1.0/default/libnetdevice/libnetdevice.cpp
index aad07de..fe749f6 100644
--- a/automotive/can/1.0/default/libnetdevice/libnetdevice.cpp
+++ b/automotive/can/1.0/default/libnetdevice/libnetdevice.cpp
@@ -102,7 +102,7 @@
static bool hasIpv4(std::string ifname) {
auto ifr = ifreqs::fromName(ifname);
- switch (const auto status = ifreqs::trySend(SIOCGIFADDR, ifr)) {
+ switch (ifreqs::trySend(SIOCGIFADDR, ifr)) {
case 0:
return true;
case EADDRNOTAVAIL:
diff --git a/automotive/vehicle/2.0/default/common/include/vhal_v2_0/VehiclePropertyStore.h b/automotive/vehicle/2.0/default/common/include/vhal_v2_0/VehiclePropertyStore.h
index 6a02cf3..abbcd35 100644
--- a/automotive/vehicle/2.0/default/common/include/vhal_v2_0/VehiclePropertyStore.h
+++ b/automotive/vehicle/2.0/default/common/include/vhal_v2_0/VehiclePropertyStore.h
@@ -70,6 +70,16 @@
* example wasn't registered. */
bool writeValue(const VehiclePropValue& propValue, bool updateStatus);
+ /*
+ * Stores provided value. Returns true if value was written returns false if config for
+ * example wasn't registered.
+ *
+ * The property value's timestamp will be set to the current ElapsedRealTimeNano.
+ */
+ bool writeValueWithCurrentTimestamp(VehiclePropValue* propValuePtr, bool updateStatus);
+
+ std::unique_ptr<VehiclePropValue> refreshTimestamp(int32_t propId, int32_t areaId);
+
void removeValue(const VehiclePropValue& propValue);
void removeValuesForProperty(int32_t propId);
@@ -94,6 +104,8 @@
std::unordered_map<int32_t /* VehicleProperty */, RecordConfig> mConfigs;
PropertyMap mPropertyValues; // Sorted map of RecordId : VehiclePropValue.
+
+ bool writeValueLocked(const VehiclePropValue& propValue, bool updateStatus);
};
} // namespace V2_0
diff --git a/automotive/vehicle/2.0/default/common/src/VehiclePropertyStore.cpp b/automotive/vehicle/2.0/default/common/src/VehiclePropertyStore.cpp
index 6087bfa..c12904e 100644
--- a/automotive/vehicle/2.0/default/common/src/VehiclePropertyStore.cpp
+++ b/automotive/vehicle/2.0/default/common/src/VehiclePropertyStore.cpp
@@ -15,6 +15,7 @@
*/
#define LOG_TAG "VehiclePropertyStore"
#include <log/log.h>
+#include <utils/SystemClock.h>
#include <common/include/vhal_v2_0/VehicleUtils.h>
#include "VehiclePropertyStore.h"
@@ -41,9 +42,7 @@
mConfigs.insert({ config.prop, RecordConfig { config, tokenFunc } });
}
-bool VehiclePropertyStore::writeValue(const VehiclePropValue& propValue,
- bool updateStatus) {
- MuxGuard g(mLock);
+bool VehiclePropertyStore::writeValueLocked(const VehiclePropValue& propValue, bool updateStatus) {
if (!mConfigs.count(propValue.prop)) return false;
RecordId recId = getRecordIdLocked(propValue);
@@ -68,6 +67,36 @@
return true;
}
+bool VehiclePropertyStore::writeValue(const VehiclePropValue& propValue, bool updateStatus) {
+ MuxGuard g(mLock);
+
+ return writeValueLocked(propValue, updateStatus);
+}
+
+bool VehiclePropertyStore::writeValueWithCurrentTimestamp(VehiclePropValue* propValuePtr,
+ bool updateStatus) {
+ MuxGuard g(mLock);
+
+ propValuePtr->timestamp = elapsedRealtimeNano();
+ return writeValueLocked(*propValuePtr, updateStatus);
+}
+
+std::unique_ptr<VehiclePropValue> VehiclePropertyStore::refreshTimestamp(int32_t propId,
+ int32_t areaId) {
+ MuxGuard g(mLock);
+ RecordId recId = getRecordIdLocked(VehiclePropValue{
+ .prop = propId,
+ .areaId = areaId,
+ });
+ auto it = mPropertyValues.find(recId);
+ if (it == mPropertyValues.end()) {
+ return nullptr;
+ }
+
+ it->second.timestamp = elapsedRealtimeNano();
+ return std::make_unique<VehiclePropValue>(it->second);
+}
+
void VehiclePropertyStore::removeValue(const VehiclePropValue& propValue) {
MuxGuard g(mLock);
RecordId recId = getRecordIdLocked(propValue);
diff --git a/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultVehicleHal.cpp b/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultVehicleHal.cpp
index 318e9dd..b56a190 100644
--- a/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultVehicleHal.cpp
+++ b/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultVehicleHal.cpp
@@ -57,12 +57,6 @@
return nullptr;
}
-VehicleHal::VehiclePropValuePtr addTimestamp(VehicleHal::VehiclePropValuePtr v) {
- if (v.get()) {
- v->timestamp = elapsedRealtimeNano();
- }
- return v;
-}
} // namespace
VehicleHal::VehiclePropValuePtr DefaultVehicleHal::createVhalHeartBeatProp() {
@@ -102,7 +96,7 @@
*outStatus = StatusCode::INTERNAL_ERROR;
}
}
- return addTimestamp(std::move(v));
+ return v;
}
VehicleHal::VehiclePropValuePtr DefaultVehicleHal::get(const VehiclePropValue& requestedPropValue,
@@ -118,13 +112,13 @@
if (propId == OBD2_FREEZE_FRAME) {
v = getValuePool()->obtainComplex();
*outStatus = fillObd2FreezeFrame(mPropStore, requestedPropValue, v.get());
- return addTimestamp(std::move(v));
+ return v;
}
if (propId == OBD2_FREEZE_FRAME_INFO) {
v = getValuePool()->obtainComplex();
*outStatus = fillObd2DtcInfo(mPropStore, v.get());
- return addTimestamp(std::move(v));
+ return v;
}
auto internalPropValue = mPropStore->readValueOrNull(requestedPropValue);
@@ -139,7 +133,7 @@
} else {
*outStatus = StatusCode::TRY_AGAIN;
}
- return addTimestamp(std::move(v));
+ return v;
}
std::vector<VehiclePropConfig> DefaultVehicleHal::listProperties() {
@@ -486,26 +480,42 @@
void DefaultVehicleHal::onContinuousPropertyTimer(const std::vector<int32_t>& properties) {
auto& pool = *getValuePool();
-
for (int32_t property : properties) {
- VehiclePropValuePtr v;
+ std::vector<VehiclePropValuePtr> events;
if (isContinuousProperty(property)) {
- auto internalPropValue = mPropStore->readValueOrNull(property);
- if (internalPropValue != nullptr) {
- v = pool.obtain(*internalPropValue);
+ const VehiclePropConfig* config = mPropStore->getConfigOrNull(property);
+ std::vector<int32_t> areaIds;
+ if (isGlobalProp(property)) {
+ areaIds.push_back(0);
+ } else {
+ for (auto& c : config->areaConfigs) {
+ areaIds.push_back(c.areaId);
+ }
+ }
+
+ for (int areaId : areaIds) {
+ auto v = pool.obtain(*mPropStore->refreshTimestamp(property, areaId));
+ if (v.get()) {
+ events.push_back(std::move(v));
+ }
}
} else if (property == static_cast<int32_t>(VehicleProperty::VHAL_HEARTBEAT)) {
// VHAL_HEARTBEAT is not a continuous value, but it needs to be updated periodically.
// So, the update is done through onContinuousPropertyTimer.
- v = doInternalHealthCheck();
+ auto v = doInternalHealthCheck();
+ if (!v.get()) {
+ // Internal health check failed.
+ continue;
+ }
+ mPropStore->writeValueWithCurrentTimestamp(v.get(), /*updateStatus=*/true);
+ events.push_back(std::move(v));
} else {
ALOGE("Unexpected onContinuousPropertyTimer for property: 0x%x", property);
continue;
}
- if (v.get()) {
- v->timestamp = elapsedRealtimeNano();
- doHalEvent(std::move(v));
+ for (VehiclePropValuePtr& event : events) {
+ doHalEvent(std::move(event));
}
}
}
@@ -556,7 +566,7 @@
void DefaultVehicleHal::onPropertyValue(const VehiclePropValue& value, bool updateStatus) {
VehiclePropValuePtr updatedPropValue = getValuePool()->obtain(value);
- if (mPropStore->writeValue(*updatedPropValue, updateStatus)) {
+ if (mPropStore->writeValueWithCurrentTimestamp(updatedPropValue.get(), updateStatus)) {
doHalEvent(std::move(updatedPropValue));
}
}
diff --git a/automotive/vehicle/2.0/default/impl/vhal_v2_0/tests/DefaultVhalImpl_test.cpp b/automotive/vehicle/2.0/default/impl/vhal_v2_0/tests/DefaultVhalImpl_test.cpp
index edd4484..c876836 100644
--- a/automotive/vehicle/2.0/default/impl/vhal_v2_0/tests/DefaultVhalImpl_test.cpp
+++ b/automotive/vehicle/2.0/default/impl/vhal_v2_0/tests/DefaultVhalImpl_test.cpp
@@ -81,8 +81,13 @@
using ::android::hardware::automotive::vehicle::V2_0::impl::OBD2_FREEZE_FRAME_CLEAR;
using ::android::hardware::automotive::vehicle::V2_0::impl::OBD2_FREEZE_FRAME_INFO;
using ::android::hardware::automotive::vehicle::V2_0::impl::OBD2_LIVE_FRAME;
+using ::android::hardware::automotive::vehicle::V2_0::impl::WHEEL_FRONT_LEFT;
+using ::android::hardware::automotive::vehicle::V2_0::impl::WHEEL_FRONT_RIGHT;
+using ::android::hardware::automotive::vehicle::V2_0::impl::WHEEL_REAR_LEFT;
+using ::android::hardware::automotive::vehicle::V2_0::impl::WHEEL_REAR_RIGHT;
using ::testing::HasSubstr;
+using ::testing::UnorderedElementsAre;
using VehiclePropValuePtr = recyclable_ptr<VehiclePropValue>;
@@ -152,7 +157,7 @@
TEST_F(DefaultVhalImplTest, testListProperties) {
std::vector<VehiclePropConfig> configs = mHal->listProperties();
- EXPECT_EQ((size_t)124, configs.size());
+ EXPECT_EQ((size_t)125, configs.size());
}
TEST_F(DefaultVhalImplTest, testGetDefaultPropertyFloat) {
@@ -346,6 +351,38 @@
EXPECT_EQ(1.0f, lastEvent->value.floatValues[0]);
}
+TEST_F(DefaultVhalImplTest, testSubscribeContinuous_withMultipleAreaIds) {
+ // Clear existing events.
+ mEventQueue.flush();
+ int propId = toInt(VehicleProperty::TIRE_PRESSURE);
+
+ auto status = mHal->subscribe(propId, 1);
+
+ ASSERT_EQ(StatusCode::OK, status);
+
+ std::vector<VehiclePropValuePtr> receivedEvents;
+ // Wait for 2 updates, each for 4 area IDs.
+ waitForEvents(&receivedEvents, 4 * 2);
+
+ std::vector<int> areasForUpdate1;
+ std::vector<int> areasForUpdate2;
+
+ for (size_t i = 0; i < receivedEvents.size(); i++) {
+ ASSERT_EQ(receivedEvents[i]->prop, propId);
+
+ if (i < 4) {
+ areasForUpdate1.push_back(receivedEvents[i]->areaId);
+ } else {
+ areasForUpdate2.push_back(receivedEvents[i]->areaId);
+ }
+ }
+
+ ASSERT_THAT(areasForUpdate1, UnorderedElementsAre(WHEEL_FRONT_LEFT, WHEEL_FRONT_RIGHT,
+ WHEEL_REAR_LEFT, WHEEL_REAR_RIGHT));
+ ASSERT_THAT(areasForUpdate2, UnorderedElementsAre(WHEEL_FRONT_LEFT, WHEEL_FRONT_RIGHT,
+ WHEEL_REAR_LEFT, WHEEL_REAR_RIGHT));
+}
+
TEST_F(DefaultVhalImplTest, testSubscribeInvalidProp) {
EXPECT_EQ(StatusCode::INVALID_ARG, mHal->subscribe(toInt(VehicleProperty::INFO_MAKE), 10));
}
@@ -1318,7 +1355,6 @@
ASSERT_EQ((size_t)1, events.size());
ASSERT_EQ((size_t)1, events[0]->value.int32Values.size());
EXPECT_EQ(2022, events[0]->value.int32Values[0]);
- EXPECT_EQ(1000, events[0]->timestamp);
VehiclePropValue value;
StatusCode status;
@@ -1352,7 +1388,6 @@
ASSERT_EQ((size_t)1, events.size());
EXPECT_EQ(0, events[0]->value.int32Values[0]);
EXPECT_EQ(DOOR_1_LEFT, events[0]->areaId);
- EXPECT_EQ(1000, events[0]->timestamp);
VehiclePropValue value;
StatusCode status;
@@ -1391,7 +1426,6 @@
ASSERT_EQ((size_t)1, events.size());
ASSERT_EQ((size_t)1, events[0]->value.floatValues.size());
EXPECT_EQ(10.5, events[0]->value.floatValues[0]);
- EXPECT_EQ(1000, events[0]->timestamp);
VehiclePropValue value;
StatusCode status;
diff --git a/automotive/vehicle/aidl/generated_lib/cpp/AccessForVehicleProperty.h b/automotive/vehicle/aidl/generated_lib/cpp/AccessForVehicleProperty.h
index c4e2c64..84aef2e 100644
--- a/automotive/vehicle/aidl/generated_lib/cpp/AccessForVehicleProperty.h
+++ b/automotive/vehicle/aidl/generated_lib/cpp/AccessForVehicleProperty.h
@@ -273,6 +273,9 @@
{VehicleProperty::HANDS_ON_DETECTION_ENABLED, VehiclePropertyAccess::READ_WRITE},
{VehicleProperty::HANDS_ON_DETECTION_DRIVER_STATE, VehiclePropertyAccess::READ},
{VehicleProperty::HANDS_ON_DETECTION_WARNING, VehiclePropertyAccess::READ},
+ {VehicleProperty::DRIVER_DROWSINESS_ATTENTION_SYSTEM_ENABLED, VehiclePropertyAccess::READ_WRITE},
+ {VehicleProperty::DRIVER_DROWSINESS_ATTENTION_STATE, VehiclePropertyAccess::READ},
+ {VehicleProperty::DRIVER_DROWSINESS_ATTENTION_WARNING_ENABLED, VehiclePropertyAccess::READ_WRITE},
};
} // namespace vehicle
diff --git a/automotive/vehicle/aidl/generated_lib/cpp/ChangeModeForVehicleProperty.h b/automotive/vehicle/aidl/generated_lib/cpp/ChangeModeForVehicleProperty.h
index bd6c705..e259a4d 100644
--- a/automotive/vehicle/aidl/generated_lib/cpp/ChangeModeForVehicleProperty.h
+++ b/automotive/vehicle/aidl/generated_lib/cpp/ChangeModeForVehicleProperty.h
@@ -273,6 +273,9 @@
{VehicleProperty::HANDS_ON_DETECTION_ENABLED, VehiclePropertyChangeMode::ON_CHANGE},
{VehicleProperty::HANDS_ON_DETECTION_DRIVER_STATE, VehiclePropertyChangeMode::ON_CHANGE},
{VehicleProperty::HANDS_ON_DETECTION_WARNING, VehiclePropertyChangeMode::ON_CHANGE},
+ {VehicleProperty::DRIVER_DROWSINESS_ATTENTION_SYSTEM_ENABLED, VehiclePropertyChangeMode::ON_CHANGE},
+ {VehicleProperty::DRIVER_DROWSINESS_ATTENTION_STATE, VehiclePropertyChangeMode::ON_CHANGE},
+ {VehicleProperty::DRIVER_DROWSINESS_ATTENTION_WARNING_ENABLED, VehiclePropertyChangeMode::ON_CHANGE},
};
} // namespace vehicle
diff --git a/automotive/vehicle/aidl/generated_lib/java/AccessForVehicleProperty.java b/automotive/vehicle/aidl/generated_lib/java/AccessForVehicleProperty.java
index 6e66632..1d18560 100644
--- a/automotive/vehicle/aidl/generated_lib/java/AccessForVehicleProperty.java
+++ b/automotive/vehicle/aidl/generated_lib/java/AccessForVehicleProperty.java
@@ -264,7 +264,10 @@
Map.entry(VehicleProperty.ADAPTIVE_CRUISE_CONTROL_LEAD_VEHICLE_MEASURED_DISTANCE, VehiclePropertyAccess.READ),
Map.entry(VehicleProperty.HANDS_ON_DETECTION_ENABLED, VehiclePropertyAccess.READ_WRITE),
Map.entry(VehicleProperty.HANDS_ON_DETECTION_DRIVER_STATE, VehiclePropertyAccess.READ),
- Map.entry(VehicleProperty.HANDS_ON_DETECTION_WARNING, VehiclePropertyAccess.READ)
+ Map.entry(VehicleProperty.HANDS_ON_DETECTION_WARNING, VehiclePropertyAccess.READ),
+ Map.entry(VehicleProperty.DRIVER_DROWSINESS_ATTENTION_SYSTEM_ENABLED, VehiclePropertyAccess.READ_WRITE),
+ Map.entry(VehicleProperty.DRIVER_DROWSINESS_ATTENTION_STATE, VehiclePropertyAccess.READ),
+ Map.entry(VehicleProperty.DRIVER_DROWSINESS_ATTENTION_WARNING_ENABLED, VehiclePropertyAccess.READ_WRITE)
);
}
diff --git a/automotive/vehicle/aidl/generated_lib/java/ChangeModeForVehicleProperty.java b/automotive/vehicle/aidl/generated_lib/java/ChangeModeForVehicleProperty.java
index 522c82f..6d0be78 100644
--- a/automotive/vehicle/aidl/generated_lib/java/ChangeModeForVehicleProperty.java
+++ b/automotive/vehicle/aidl/generated_lib/java/ChangeModeForVehicleProperty.java
@@ -264,7 +264,10 @@
Map.entry(VehicleProperty.ADAPTIVE_CRUISE_CONTROL_LEAD_VEHICLE_MEASURED_DISTANCE, VehiclePropertyChangeMode.CONTINUOUS),
Map.entry(VehicleProperty.HANDS_ON_DETECTION_ENABLED, VehiclePropertyChangeMode.ON_CHANGE),
Map.entry(VehicleProperty.HANDS_ON_DETECTION_DRIVER_STATE, VehiclePropertyChangeMode.ON_CHANGE),
- Map.entry(VehicleProperty.HANDS_ON_DETECTION_WARNING, VehiclePropertyChangeMode.ON_CHANGE)
+ Map.entry(VehicleProperty.HANDS_ON_DETECTION_WARNING, VehiclePropertyChangeMode.ON_CHANGE),
+ Map.entry(VehicleProperty.DRIVER_DROWSINESS_ATTENTION_SYSTEM_ENABLED, VehiclePropertyChangeMode.ON_CHANGE),
+ Map.entry(VehicleProperty.DRIVER_DROWSINESS_ATTENTION_STATE, VehiclePropertyChangeMode.ON_CHANGE),
+ Map.entry(VehicleProperty.DRIVER_DROWSINESS_ATTENTION_WARNING_ENABLED, VehiclePropertyChangeMode.ON_CHANGE)
);
}
diff --git a/automotive/vehicle/aidl/generated_lib/java/EnumForVehicleProperty.java b/automotive/vehicle/aidl/generated_lib/java/EnumForVehicleProperty.java
index 144d0e1..2e8e6fd 100644
--- a/automotive/vehicle/aidl/generated_lib/java/EnumForVehicleProperty.java
+++ b/automotive/vehicle/aidl/generated_lib/java/EnumForVehicleProperty.java
@@ -93,7 +93,8 @@
Map.entry(VehicleProperty.CRUISE_CONTROL_STATE, List.of(CruiseControlState.class, ErrorState.class)),
Map.entry(VehicleProperty.CRUISE_CONTROL_COMMAND, List.of(CruiseControlCommand.class)),
Map.entry(VehicleProperty.HANDS_ON_DETECTION_DRIVER_STATE, List.of(HandsOnDetectionDriverState.class, ErrorState.class)),
- Map.entry(VehicleProperty.HANDS_ON_DETECTION_WARNING, List.of(HandsOnDetectionWarning.class, ErrorState.class))
+ Map.entry(VehicleProperty.HANDS_ON_DETECTION_WARNING, List.of(HandsOnDetectionWarning.class, ErrorState.class)),
+ Map.entry(VehicleProperty.DRIVER_DROWSINESS_ATTENTION_STATE, List.of(DriverDrowsinessAttentionState.class, ErrorState.class))
);
}
diff --git a/automotive/vehicle/aidl/impl/default_config/JsonConfigLoader/src/JsonConfigLoader.cpp b/automotive/vehicle/aidl/impl/default_config/JsonConfigLoader/src/JsonConfigLoader.cpp
index 82dc8a6..1638f3c 100644
--- a/automotive/vehicle/aidl/impl/default_config/JsonConfigLoader/src/JsonConfigLoader.cpp
+++ b/automotive/vehicle/aidl/impl/default_config/JsonConfigLoader/src/JsonConfigLoader.cpp
@@ -41,6 +41,7 @@
using ::aidl::android::hardware::automotive::vehicle::CruiseControlCommand;
using ::aidl::android::hardware::automotive::vehicle::CruiseControlState;
using ::aidl::android::hardware::automotive::vehicle::CruiseControlType;
+using ::aidl::android::hardware::automotive::vehicle::DriverDrowsinessAttentionState;
using ::aidl::android::hardware::automotive::vehicle::EmergencyLaneKeepAssistState;
using ::aidl::android::hardware::automotive::vehicle::ErrorState;
using ::aidl::android::hardware::automotive::vehicle::EvConnectorType;
@@ -252,6 +253,8 @@
std::make_unique<ConstantParser<HandsOnDetectionDriverState>>();
mConstantParsersByType["HandsOnDetectionWarning"] =
std::make_unique<ConstantParser<HandsOnDetectionWarning>>();
+ mConstantParsersByType["DriverDrowsinessAttentionState"] =
+ std::make_unique<ConstantParser<DriverDrowsinessAttentionState>>();
mConstantParsersByType["ErrorState"] = std::make_unique<ConstantParser<ErrorState>>();
mConstantParsersByType["AutomaticEmergencyBrakingState"] =
std::make_unique<ConstantParser<AutomaticEmergencyBrakingState>>();
diff --git a/automotive/vehicle/aidl/impl/default_config/config/DefaultProperties.json b/automotive/vehicle/aidl/impl/default_config/config/DefaultProperties.json
index d3bb60c..af3d34e 100644
--- a/automotive/vehicle/aidl/impl/default_config/config/DefaultProperties.json
+++ b/automotive/vehicle/aidl/impl/default_config/config/DefaultProperties.json
@@ -3546,6 +3546,47 @@
]
},
{
+ "property": "VehicleProperty::DRIVER_DROWSINESS_ATTENTION_SYSTEM_ENABLED",
+ "defaultValue": {
+ "int32Values": [
+ 1
+ ]
+ }
+ },
+ {
+ "property": "VehicleProperty::DRIVER_DROWSINESS_ATTENTION_STATE",
+ "defaultValue": {
+ "int32Values": [
+ "DriverDrowsinessAttentionState::KSS_RATING_3_ALERT"
+ ]
+ },
+ "areas": [
+ {
+ "areaId": 0,
+ "supportedEnumValues": [
+ "ErrorState::NOT_AVAILABLE_DISABLED",
+ "DriverDrowsinessAttentionState::KSS_RATING_1_EXTREMELY_ALERT",
+ "DriverDrowsinessAttentionState::KSS_RATING_2_VERY_ALERT",
+ "DriverDrowsinessAttentionState::KSS_RATING_3_ALERT",
+ "DriverDrowsinessAttentionState::KSS_RATING_4_RATHER_ALERT",
+ "DriverDrowsinessAttentionState::KSS_RATING_5_NEITHER_ALERT_NOR_SLEEPY",
+ "DriverDrowsinessAttentionState::KSS_RATING_6_SOME_SLEEPINESS",
+ "DriverDrowsinessAttentionState::KSS_RATING_7_SLEEPY_NO_EFFORT",
+ "DriverDrowsinessAttentionState::KSS_RATING_8_SLEEPY_SOME_EFFORT",
+ "DriverDrowsinessAttentionState::KSS_RATING_9_VERY_SLEEPY"
+ ]
+ }
+ ]
+ },
+ {
+ "property": "VehicleProperty::DRIVER_DROWSINESS_ATTENTION_WARNING_ENABLED",
+ "defaultValue": {
+ "int32Values": [
+ 1
+ ]
+ }
+ },
+ {
"property": "VehicleProperty::INITIAL_USER_INFO"
},
{
diff --git a/automotive/vehicle/aidl/impl/fake_impl/hardware/src/FakeVehicleHardware.cpp b/automotive/vehicle/aidl/impl/fake_impl/hardware/src/FakeVehicleHardware.cpp
index cc4fae1..7a3be08 100644
--- a/automotive/vehicle/aidl/impl/fake_impl/hardware/src/FakeVehicleHardware.cpp
+++ b/automotive/vehicle/aidl/impl/fake_impl/hardware/src/FakeVehicleHardware.cpp
@@ -53,6 +53,7 @@
using ::aidl::android::hardware::automotive::vehicle::CruiseControlCommand;
using ::aidl::android::hardware::automotive::vehicle::CruiseControlType;
+using ::aidl::android::hardware::automotive::vehicle::DriverDrowsinessAttentionState;
using ::aidl::android::hardware::automotive::vehicle::ErrorState;
using ::aidl::android::hardware::automotive::vehicle::GetValueRequest;
using ::aidl::android::hardware::automotive::vehicle::GetValueResult;
@@ -192,6 +193,13 @@
toInt(VehicleProperty::HANDS_ON_DETECTION_WARNING),
},
},
+ // Driver Drowsiness and Attention
+ {
+ toInt(VehicleProperty::DRIVER_DROWSINESS_ATTENTION_SYSTEM_ENABLED),
+ {
+ toInt(VehicleProperty::DRIVER_DROWSINESS_ATTENTION_STATE),
+ },
+ },
};
} // namespace
@@ -2078,25 +2086,10 @@
enableVariableUpdateRate) {
eventMode = VehiclePropertyStore::EventMode::ON_VALUE_CHANGE;
}
- auto action = std::make_shared<RecurrentTimer::Callback>([this, propId, areaId,
- eventMode] {
- // Refresh the property value. In real implementation, this should poll the latest
- // value from vehicle bus. Here, we are just refreshing the existing value with a
- // new timestamp.
- auto result = getValue(VehiclePropValue{
- .areaId = areaId,
- .prop = propId,
- .value = {},
- });
- if (!result.ok()) {
- // Failed to read current value, skip refreshing.
- return;
- }
-
- mServerSidePropStore->writeValue(std::move(result.value()),
- /*updateStatus=*/true, eventMode,
- /*useCurrentTimestamp=*/true);
- });
+ auto action =
+ std::make_shared<RecurrentTimer::Callback>([this, propId, areaId, eventMode] {
+ mServerSidePropStore->refreshTimestamp(propId, areaId, eventMode);
+ });
mRecurrentTimer->registerTimerCallback(intervalInNanos, action);
mRecurrentActions[propIdAreaId] = action;
return StatusCode::OK;
diff --git a/automotive/vehicle/aidl/impl/grpc/utils/proto_message_converter/src/ProtoMessageConverter.cpp b/automotive/vehicle/aidl/impl/grpc/utils/proto_message_converter/src/ProtoMessageConverter.cpp
index 491aa10..1ea0df4 100644
--- a/automotive/vehicle/aidl/impl/grpc/utils/proto_message_converter/src/ProtoMessageConverter.cpp
+++ b/automotive/vehicle/aidl/impl/grpc/utils/proto_message_converter/src/ProtoMessageConverter.cpp
@@ -67,6 +67,7 @@
for (auto& areaConfig : in.areaConfigs) {
auto* protoACfg = out->add_area_configs();
protoACfg->set_area_id(areaConfig.areaId);
+ protoACfg->set_access(static_cast<proto::VehiclePropertyAccess>(toInt(areaConfig.access)));
protoACfg->set_min_int64_value(areaConfig.minInt64Value);
protoACfg->set_max_int64_value(areaConfig.maxInt64Value);
protoACfg->set_min_float_value(areaConfig.minFloatValue);
@@ -95,6 +96,7 @@
auto cast_to_acfg = [](const proto::VehicleAreaConfig& protoAcfg) {
auto vehicleAreaConfig = aidl_vehicle::VehicleAreaConfig{
.areaId = protoAcfg.area_id(),
+ .access = static_cast<aidl_vehicle::VehiclePropertyAccess>(protoAcfg.access()),
.minInt32Value = protoAcfg.min_int32_value(),
.maxInt32Value = protoAcfg.max_int32_value(),
.minInt64Value = protoAcfg.min_int64_value(),
diff --git a/automotive/vehicle/aidl/impl/proto/android/hardware/automotive/vehicle/VehicleAreaConfig.proto b/automotive/vehicle/aidl/impl/proto/android/hardware/automotive/vehicle/VehicleAreaConfig.proto
index 8093658..7ea8540 100644
--- a/automotive/vehicle/aidl/impl/proto/android/hardware/automotive/vehicle/VehicleAreaConfig.proto
+++ b/automotive/vehicle/aidl/impl/proto/android/hardware/automotive/vehicle/VehicleAreaConfig.proto
@@ -18,6 +18,8 @@
package android.hardware.automotive.vehicle.proto;
+import "android/hardware/automotive/vehicle/VehiclePropertyAccess.proto";
+
/* Must be in sync with VehicleAreaConfig.aidl. */
message VehicleAreaConfig {
/* Area id is ignored for VehiclePropertyGroup:GLOBAL properties. */
@@ -43,6 +45,6 @@
* assumed all @data_enum values are supported unless specified through another mechanism.
*/
repeated int64 supported_enum_values = 8;
- int32 access = 9;
+ VehiclePropertyAccess access = 9;
bool support_variable_update_rate = 10;
};
diff --git a/automotive/vehicle/aidl/impl/utils/common/include/RecurrentTimer.h b/automotive/vehicle/aidl/impl/utils/common/include/RecurrentTimer.h
index cd2b727..712359a 100644
--- a/automotive/vehicle/aidl/impl/utils/common/include/RecurrentTimer.h
+++ b/automotive/vehicle/aidl/impl/utils/common/include/RecurrentTimer.h
@@ -19,6 +19,8 @@
#include <android-base/thread_annotations.h>
+#include <utils/Looper.h>
+#include <atomic>
#include <memory>
#include <mutex>
#include <queue>
@@ -31,6 +33,9 @@
namespace automotive {
namespace vehicle {
+// Forward declaration
+class RecurrentMessageHandler;
+
// A thread-safe recurrent timer.
class RecurrentTimer final {
public:
@@ -43,49 +48,44 @@
// Registers a recurrent callback for a given interval.
// Registering the same callback twice will override the interval provided before.
- void registerTimerCallback(int64_t intervalInNano, std::shared_ptr<Callback> callback);
+ void registerTimerCallback(int64_t intervalInNanos, std::shared_ptr<Callback> callback);
// Unregisters a previously registered recurrent callback.
void unregisterTimerCallback(std::shared_ptr<Callback> callback);
private:
- // friend class for unit testing.
+ friend class RecurrentMessageHandler;
+
+ // For unit test
friend class RecurrentTimerTest;
struct CallbackInfo {
std::shared_ptr<Callback> callback;
- int64_t interval;
- int64_t nextTime;
- // A flag to indicate whether this CallbackInfo is already outdated and should be ignored.
- // The reason we need this flag is because we cannot easily remove an element from a heap.
- bool outdated = false;
-
- static bool cmp(const std::unique_ptr<CallbackInfo>& lhs,
- const std::unique_ptr<CallbackInfo>& rhs);
+ int64_t intervalInNanos;
+ int64_t nextTimeInNanos;
};
+ android::sp<Looper> mLooper;
+ android::sp<RecurrentMessageHandler> mHandler;
+
+ std::atomic<bool> mStopRequested = false;
+ std::atomic<int> mCallbackId = 0;
std::mutex mLock;
std::thread mThread;
- std::condition_variable mCond;
- bool mStopRequested GUARDED_BY(mLock) = false;
- // A map to map each callback to its current active CallbackInfo in the mCallbackQueue.
- std::unordered_map<std::shared_ptr<Callback>, CallbackInfo*> mCallbacks GUARDED_BY(mLock);
- // A min-heap sorted by nextTime. Note that because we cannot remove arbitrary element from the
- // heap, a single Callback can have multiple entries in this queue, all but one should be valid.
- // The rest should be mark as outdated. The valid one is one stored in mCallbacks.
- std::vector<std::unique_ptr<CallbackInfo>> mCallbackQueue GUARDED_BY(mLock);
+ std::unordered_map<std::shared_ptr<Callback>, int> mIdByCallback GUARDED_BY(mLock);
+ std::unordered_map<int, std::unique_ptr<CallbackInfo>> mCallbackInfoById GUARDED_BY(mLock);
- void loop();
+ void handleMessage(const android::Message& message) EXCLUDES(mLock);
+ int getCallbackIdLocked(std::shared_ptr<Callback> callback) REQUIRES(mLock);
+};
- // Mark the callbackInfo as outdated and should be ignored when popped from the heap.
- void markOutdatedLocked(CallbackInfo* callback) REQUIRES(mLock);
- // Remove all outdated callbackInfos from the top of the heap. This function must be called
- // each time we might introduce outdated elements to the top. We must make sure the heap is
- // always valid from the top.
- void removeInvalidCallbackLocked() REQUIRES(mLock);
- // Gets the next calblack to run (must be valid) from the heap, update its nextTime and put
- // it back to the heap.
- std::shared_ptr<Callback> getNextCallbackLocked(int64_t now) REQUIRES(mLock);
+class RecurrentMessageHandler final : public android::MessageHandler {
+ public:
+ RecurrentMessageHandler(RecurrentTimer* timer) { mTimer = timer; }
+ void handleMessage(const android::Message& message) override;
+
+ private:
+ RecurrentTimer* mTimer;
};
} // namespace vehicle
diff --git a/automotive/vehicle/aidl/impl/utils/common/include/VehicleHalTypes.h b/automotive/vehicle/aidl/impl/utils/common/include/VehicleHalTypes.h
index e6d657d..d4180a3 100644
--- a/automotive/vehicle/aidl/impl/utils/common/include/VehicleHalTypes.h
+++ b/automotive/vehicle/aidl/impl/utils/common/include/VehicleHalTypes.h
@@ -24,6 +24,7 @@
#include <aidl/android/hardware/automotive/vehicle/CruiseControlType.h>
#include <aidl/android/hardware/automotive/vehicle/DiagnosticFloatSensorIndex.h>
#include <aidl/android/hardware/automotive/vehicle/DiagnosticIntegerSensorIndex.h>
+#include <aidl/android/hardware/automotive/vehicle/DriverDrowsinessAttentionState.h>
#include <aidl/android/hardware/automotive/vehicle/EmergencyLaneKeepAssistState.h>
#include <aidl/android/hardware/automotive/vehicle/ErrorState.h>
#include <aidl/android/hardware/automotive/vehicle/EvConnectorType.h>
diff --git a/automotive/vehicle/aidl/impl/utils/common/include/VehiclePropertyStore.h b/automotive/vehicle/aidl/impl/utils/common/include/VehiclePropertyStore.h
index 2812c3b..ef36532 100644
--- a/automotive/vehicle/aidl/impl/utils/common/include/VehiclePropertyStore.h
+++ b/automotive/vehicle/aidl/impl/utils/common/include/VehiclePropertyStore.h
@@ -106,6 +106,11 @@
EventMode mode = EventMode::ON_VALUE_CHANGE,
bool useCurrentTimestamp = false) EXCLUDES(mLock);
+ // Refresh the timestamp for the stored property value for [propId, areaId]. If eventMode is
+ // always, generates the property update event, otherwise, only update the stored timestamp
+ // without generating event. This operation is atomic with other writeValue operations.
+ void refreshTimestamp(int32_t propId, int32_t areaId, EventMode eventMode) EXCLUDES(mLock);
+
// Remove a given property value from the property store. The 'propValue' would be used to
// generate the key for the value to remove.
void removeValue(
diff --git a/automotive/vehicle/aidl/impl/utils/common/src/RecurrentTimer.cpp b/automotive/vehicle/aidl/impl/utils/common/src/RecurrentTimer.cpp
index c6d3687..8dec695 100644
--- a/automotive/vehicle/aidl/impl/utils/common/src/RecurrentTimer.cpp
+++ b/automotive/vehicle/aidl/impl/utils/common/src/RecurrentTimer.cpp
@@ -17,6 +17,7 @@
#include "RecurrentTimer.h"
#include <utils/Log.h>
+#include <utils/Looper.h>
#include <utils/SystemClock.h>
#include <inttypes.h>
@@ -27,153 +28,119 @@
namespace automotive {
namespace vehicle {
+namespace {
+
using ::android::base::ScopedLockAssertion;
+constexpr int INVALID_ID = -1;
+
+} // namespace
+
RecurrentTimer::RecurrentTimer() {
- mThread = std::thread(&RecurrentTimer::loop, this);
+ mHandler = sp<RecurrentMessageHandler>::make(this);
+ mLooper = sp<Looper>::make(/*allowNonCallbacks=*/false);
+ mThread = std::thread([this] {
+ Looper::setForThread(mLooper);
+
+ while (!mStopRequested) {
+ mLooper->pollOnce(/*timeoutMillis=*/-1);
+ }
+ });
}
RecurrentTimer::~RecurrentTimer() {
- {
- std::scoped_lock<std::mutex> lockGuard(mLock);
- mStopRequested = true;
- }
- mCond.notify_one();
+ mStopRequested = true;
+ mLooper->removeMessages(mHandler);
+ mLooper->wake();
if (mThread.joinable()) {
mThread.join();
}
}
-void RecurrentTimer::registerTimerCallback(int64_t intervalInNano,
+int RecurrentTimer::getCallbackIdLocked(std::shared_ptr<RecurrentTimer::Callback> callback) {
+ const auto& it = mIdByCallback.find(callback);
+ if (it != mIdByCallback.end()) {
+ return it->second;
+ }
+ return INVALID_ID;
+}
+
+void RecurrentTimer::registerTimerCallback(int64_t intervalInNanos,
std::shared_ptr<RecurrentTimer::Callback> callback) {
{
std::scoped_lock<std::mutex> lockGuard(mLock);
+ int callbackId = getCallbackIdLocked(callback);
+
+ if (callbackId == INVALID_ID) {
+ callbackId = mCallbackId++;
+ mIdByCallback.insert({callback, callbackId});
+ } else {
+ ALOGI("Replacing an existing timer callback with a new interval, current: %" PRId64
+ " ns, new: %" PRId64 " ns",
+ mCallbackInfoById[callbackId]->intervalInNanos, intervalInNanos);
+ mLooper->removeMessages(mHandler, callbackId);
+ }
+
// Aligns the nextTime to multiply of interval.
- int64_t nextTime = ceil(uptimeNanos() / intervalInNano) * intervalInNano;
+ int64_t nextTimeInNanos = ceil(uptimeNanos() / intervalInNanos) * intervalInNanos;
std::unique_ptr<CallbackInfo> info = std::make_unique<CallbackInfo>();
info->callback = callback;
- info->interval = intervalInNano;
- info->nextTime = nextTime;
+ info->intervalInNanos = intervalInNanos;
+ info->nextTimeInNanos = nextTimeInNanos;
+ mCallbackInfoById.insert({callbackId, std::move(info)});
- auto it = mCallbacks.find(callback);
- if (it != mCallbacks.end()) {
- ALOGI("Replacing an existing timer callback with a new interval, current: %" PRId64
- " ns, new: %" PRId64 " ns",
- it->second->interval, intervalInNano);
- markOutdatedLocked(it->second);
- }
- mCallbacks[callback] = info.get();
- mCallbackQueue.push_back(std::move(info));
- // Insert the last element into the heap.
- std::push_heap(mCallbackQueue.begin(), mCallbackQueue.end(), CallbackInfo::cmp);
+ mLooper->sendMessageAtTime(nextTimeInNanos, mHandler, Message(callbackId));
}
- mCond.notify_one();
}
void RecurrentTimer::unregisterTimerCallback(std::shared_ptr<RecurrentTimer::Callback> callback) {
{
std::scoped_lock<std::mutex> lockGuard(mLock);
- auto it = mCallbacks.find(callback);
- if (it == mCallbacks.end()) {
+ int callbackId = getCallbackIdLocked(callback);
+
+ if (callbackId == INVALID_ID) {
ALOGE("No event found to unregister");
return;
}
- markOutdatedLocked(it->second);
- mCallbacks.erase(it);
- }
-
- mCond.notify_one();
-}
-
-void RecurrentTimer::markOutdatedLocked(RecurrentTimer::CallbackInfo* info) {
- info->outdated = true;
- info->callback = nullptr;
- // Make sure the first element is always valid.
- removeInvalidCallbackLocked();
-}
-
-void RecurrentTimer::removeInvalidCallbackLocked() {
- while (mCallbackQueue.size() != 0 && mCallbackQueue[0]->outdated) {
- std::pop_heap(mCallbackQueue.begin(), mCallbackQueue.end(), CallbackInfo::cmp);
- mCallbackQueue.pop_back();
+ mLooper->removeMessages(mHandler, callbackId);
+ mCallbackInfoById.erase(callbackId);
+ mIdByCallback.erase(callback);
}
}
-std::shared_ptr<RecurrentTimer::Callback> RecurrentTimer::getNextCallbackLocked(int64_t now) {
- std::pop_heap(mCallbackQueue.begin(), mCallbackQueue.end(), CallbackInfo::cmp);
- auto& callbackInfo = mCallbackQueue[mCallbackQueue.size() - 1];
- auto nextCallback = callbackInfo->callback;
- // intervalCount is the number of interval we have to advance until we pass now.
- size_t intervalCount = (now - callbackInfo->nextTime) / callbackInfo->interval + 1;
- callbackInfo->nextTime += intervalCount * callbackInfo->interval;
- std::push_heap(mCallbackQueue.begin(), mCallbackQueue.end(), CallbackInfo::cmp);
+void RecurrentTimer::handleMessage(const Message& message) {
+ std::shared_ptr<RecurrentTimer::Callback> callback;
+ {
+ std::scoped_lock<std::mutex> lockGuard(mLock);
- // Make sure the first element is always valid.
- removeInvalidCallbackLocked();
+ int callbackId = message.what;
- return nextCallback;
-}
-
-void RecurrentTimer::loop() {
- std::vector<std::shared_ptr<Callback>> callbacksToRun;
- while (true) {
- {
- std::unique_lock<std::mutex> uniqueLock(mLock);
- ScopedLockAssertion lockAssertion(mLock);
- // Wait until the timer exits or we have at least one recurrent callback.
- mCond.wait(uniqueLock, [this] {
- ScopedLockAssertion lockAssertion(mLock);
- return mStopRequested || mCallbackQueue.size() != 0;
- });
-
- int64_t interval;
- if (mStopRequested) {
- return;
- }
- // The first element is the nearest next event.
- int64_t nextTime = mCallbackQueue[0]->nextTime;
- int64_t now = uptimeNanos();
-
- if (nextTime > now) {
- interval = nextTime - now;
- } else {
- interval = 0;
- }
-
- // Wait for the next event or the timer exits.
- if (mCond.wait_for(uniqueLock, std::chrono::nanoseconds(interval), [this] {
- ScopedLockAssertion lockAssertion(mLock);
- return mStopRequested;
- })) {
- return;
- }
-
- now = uptimeNanos();
- callbacksToRun.clear();
- while (mCallbackQueue.size() > 0) {
- int64_t nextTime = mCallbackQueue[0]->nextTime;
- if (nextTime > now) {
- break;
- }
-
- callbacksToRun.push_back(getNextCallbackLocked(now));
- }
+ auto it = mCallbackInfoById.find(callbackId);
+ if (it == mCallbackInfoById.end()) {
+ ALOGW("The event for callback ID: %d is outdated, ignore", callbackId);
+ return;
}
- // Do not execute the callback while holding the lock.
- for (size_t i = 0; i < callbacksToRun.size(); i++) {
- (*callbacksToRun[i])();
- }
+ CallbackInfo* callbackInfo = it->second.get();
+ callback = callbackInfo->callback;
+ int64_t nowNanos = uptimeNanos();
+ // intervalCount is the number of interval we have to advance until we pass now.
+ size_t intervalCount =
+ (nowNanos - callbackInfo->nextTimeInNanos) / callbackInfo->intervalInNanos + 1;
+ callbackInfo->nextTimeInNanos += intervalCount * callbackInfo->intervalInNanos;
+
+ mLooper->sendMessageAtTime(callbackInfo->nextTimeInNanos, mHandler, Message(callbackId));
}
+
+ (*callback)();
}
-bool RecurrentTimer::CallbackInfo::cmp(const std::unique_ptr<RecurrentTimer::CallbackInfo>& lhs,
- const std::unique_ptr<RecurrentTimer::CallbackInfo>& rhs) {
- return lhs->nextTime > rhs->nextTime;
+void RecurrentMessageHandler::handleMessage(const Message& message) {
+ mTimer->handleMessage(message);
}
} // namespace vehicle
diff --git a/automotive/vehicle/aidl/impl/utils/common/src/VehiclePropertyStore.cpp b/automotive/vehicle/aidl/impl/utils/common/src/VehiclePropertyStore.cpp
index b879850..7d9d8b7 100644
--- a/automotive/vehicle/aidl/impl/utils/common/src/VehiclePropertyStore.cpp
+++ b/automotive/vehicle/aidl/impl/utils/common/src/VehiclePropertyStore.cpp
@@ -176,6 +176,42 @@
return {};
}
+void VehiclePropertyStore::refreshTimestamp(int32_t propId, int32_t areaId, EventMode eventMode) {
+ VehiclePropValue updatedValue;
+ OnValueChangeCallback onValueChangeCallback = nullptr;
+ {
+ std::scoped_lock<std::mutex> g(mLock);
+
+ VehiclePropertyStore::Record* record = getRecordLocked(propId);
+ if (record == nullptr) {
+ return;
+ }
+
+ VehiclePropValue propValue = {
+ .areaId = areaId,
+ .prop = propId,
+ .value = {},
+ };
+
+ VehiclePropertyStore::RecordId recId = getRecordIdLocked(propValue, *record);
+ if (auto it = record->values.find(recId); it != record->values.end()) {
+ it->second->timestamp = elapsedRealtimeNano();
+ updatedValue = *(it->second);
+ } else {
+ return;
+ }
+ if (!mOnValueChangeCallback) {
+ return;
+ }
+ onValueChangeCallback = mOnValueChangeCallback;
+ }
+
+ // Invoke the callback outside the lock to prevent dead-lock.
+ if (eventMode == EventMode::ALWAYS) {
+ onValueChangeCallback(updatedValue);
+ }
+}
+
void VehiclePropertyStore::removeValue(const VehiclePropValue& propValue) {
std::scoped_lock<std::mutex> g(mLock);
diff --git a/automotive/vehicle/aidl/impl/utils/common/test/RecurrentTimerTest.cpp b/automotive/vehicle/aidl/impl/utils/common/test/RecurrentTimerTest.cpp
index 62046f3..e8ac2a5 100644
--- a/automotive/vehicle/aidl/impl/utils/common/test/RecurrentTimerTest.cpp
+++ b/automotive/vehicle/aidl/impl/utils/common/test/RecurrentTimerTest.cpp
@@ -60,9 +60,14 @@
mCallbacks.clear();
}
- size_t countTimerCallbackQueue(RecurrentTimer* timer) {
+ size_t countCallbackInfoById(RecurrentTimer* timer) {
std::scoped_lock<std::mutex> lockGuard(timer->mLock);
- return timer->mCallbackQueue.size();
+ return timer->mCallbackInfoById.size();
+ }
+
+ size_t countIdByCallback(RecurrentTimer* timer) {
+ std::scoped_lock<std::mutex> lockGuard(timer->mLock);
+ return timer->mIdByCallback.size();
}
private:
@@ -109,6 +114,9 @@
<< "Not enough callbacks called before timeout";
timer.unregisterTimerCallback(action);
+
+ ASSERT_EQ(countCallbackInfoById(&timer), 0u);
+ ASSERT_EQ(countIdByCallback(&timer), 0u);
}
TEST_F(RecurrentTimerTest, testDestroyTimerWithCallback) {
@@ -198,8 +206,8 @@
timer.unregisterTimerCallback(action);
- // Make sure there is no item in the callback queue.
- ASSERT_EQ(countTimerCallbackQueue(&timer), static_cast<size_t>(0));
+ ASSERT_EQ(countCallbackInfoById(&timer), 0u);
+ ASSERT_EQ(countIdByCallback(&timer), 0u);
}
TEST_F(RecurrentTimerTest, testRegisterCallbackMultipleTimesNoDeadLock) {
diff --git a/automotive/vehicle/aidl/impl/vhal/test/DefaultVehicleHalTest.cpp b/automotive/vehicle/aidl/impl/vhal/test/DefaultVehicleHalTest.cpp
index 63964ef..a63cb84 100644
--- a/automotive/vehicle/aidl/impl/vhal/test/DefaultVehicleHalTest.cpp
+++ b/automotive/vehicle/aidl/impl/vhal/test/DefaultVehicleHalTest.cpp
@@ -59,6 +59,7 @@
using ::aidl::android::hardware::automotive::vehicle::SetValueResults;
using ::aidl::android::hardware::automotive::vehicle::StatusCode;
using ::aidl::android::hardware::automotive::vehicle::SubscribeOptions;
+using ::aidl::android::hardware::automotive::vehicle::VehicleAreaConfig;
using ::aidl::android::hardware::automotive::vehicle::VehicleAreaWindow;
using ::aidl::android::hardware::automotive::vehicle::VehiclePropConfig;
using ::aidl::android::hardware::automotive::vehicle::VehiclePropConfigs;
diff --git a/automotive/vehicle/aidl_property/aidl_api/android.hardware.automotive.vehicle.property/current/android/hardware/automotive/vehicle/DriverDrowsinessAttentionState.aidl b/automotive/vehicle/aidl_property/aidl_api/android.hardware.automotive.vehicle.property/current/android/hardware/automotive/vehicle/DriverDrowsinessAttentionState.aidl
new file mode 100644
index 0000000..22a90f3
--- /dev/null
+++ b/automotive/vehicle/aidl_property/aidl_api/android.hardware.automotive.vehicle.property/current/android/hardware/automotive/vehicle/DriverDrowsinessAttentionState.aidl
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2023 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.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+// the interface (from the latest frozen version), the build system will
+// prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.hardware.automotive.vehicle;
+@Backing(type="int") @VintfStability
+enum DriverDrowsinessAttentionState {
+ OTHER = 0,
+ KSS_RATING_1_EXTREMELY_ALERT = 1,
+ KSS_RATING_2_VERY_ALERT = 2,
+ KSS_RATING_3_ALERT = 3,
+ KSS_RATING_4_RATHER_ALERT = 4,
+ KSS_RATING_5_NEITHER_ALERT_NOR_SLEEPY = 5,
+ KSS_RATING_6_SOME_SLEEPINESS = 6,
+ KSS_RATING_7_SLEEPY_NO_EFFORT = 7,
+ KSS_RATING_8_SLEEPY_SOME_EFFORT = 8,
+ KSS_RATING_9_VERY_SLEEPY = 9,
+}
diff --git a/automotive/vehicle/aidl_property/aidl_api/android.hardware.automotive.vehicle.property/current/android/hardware/automotive/vehicle/VehicleProperty.aidl b/automotive/vehicle/aidl_property/aidl_api/android.hardware.automotive.vehicle.property/current/android/hardware/automotive/vehicle/VehicleProperty.aidl
index 231186f..4a82d81 100644
--- a/automotive/vehicle/aidl_property/aidl_api/android.hardware.automotive.vehicle.property/current/android/hardware/automotive/vehicle/VehicleProperty.aidl
+++ b/automotive/vehicle/aidl_property/aidl_api/android.hardware.automotive.vehicle.property/current/android/hardware/automotive/vehicle/VehicleProperty.aidl
@@ -271,4 +271,7 @@
HANDS_ON_DETECTION_ENABLED = (((0x1016 + android.hardware.automotive.vehicle.VehiclePropertyGroup.SYSTEM) + android.hardware.automotive.vehicle.VehicleArea.GLOBAL) + android.hardware.automotive.vehicle.VehiclePropertyType.BOOLEAN) /* 287313942 */,
HANDS_ON_DETECTION_DRIVER_STATE = (((0x1017 + android.hardware.automotive.vehicle.VehiclePropertyGroup.SYSTEM) + android.hardware.automotive.vehicle.VehicleArea.GLOBAL) + android.hardware.automotive.vehicle.VehiclePropertyType.INT32) /* 289411095 */,
HANDS_ON_DETECTION_WARNING = (((0x1018 + android.hardware.automotive.vehicle.VehiclePropertyGroup.SYSTEM) + android.hardware.automotive.vehicle.VehicleArea.GLOBAL) + android.hardware.automotive.vehicle.VehiclePropertyType.INT32) /* 289411096 */,
+ DRIVER_DROWSINESS_ATTENTION_SYSTEM_ENABLED = (((0x1019 + android.hardware.automotive.vehicle.VehiclePropertyGroup.SYSTEM) + android.hardware.automotive.vehicle.VehicleArea.GLOBAL) + android.hardware.automotive.vehicle.VehiclePropertyType.BOOLEAN) /* 287313945 */,
+ DRIVER_DROWSINESS_ATTENTION_STATE = (((0x101A + android.hardware.automotive.vehicle.VehiclePropertyGroup.SYSTEM) + android.hardware.automotive.vehicle.VehicleArea.GLOBAL) + android.hardware.automotive.vehicle.VehiclePropertyType.INT32) /* 289411098 */,
+ DRIVER_DROWSINESS_ATTENTION_WARNING_ENABLED = (((0x101B + android.hardware.automotive.vehicle.VehiclePropertyGroup.SYSTEM) + android.hardware.automotive.vehicle.VehicleArea.GLOBAL) + android.hardware.automotive.vehicle.VehiclePropertyType.BOOLEAN) /* 287313947 */,
}
diff --git a/automotive/vehicle/aidl_property/android/hardware/automotive/vehicle/DriverDrowsinessAttentionState.aidl b/automotive/vehicle/aidl_property/android/hardware/automotive/vehicle/DriverDrowsinessAttentionState.aidl
new file mode 100644
index 0000000..d2aec1f
--- /dev/null
+++ b/automotive/vehicle/aidl_property/android/hardware/automotive/vehicle/DriverDrowsinessAttentionState.aidl
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2023 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.automotive.vehicle;
+
+/**
+ * Used to enumerate the current state of driver drowsiness and attention monitoring.
+ *
+ * This enum could be extended in future releases to include additional feature states.
+ */
+@VintfStability
+@Backing(type="int")
+enum DriverDrowsinessAttentionState {
+ /**
+ * This state is used as an alternative for any DriverDrowsinessAttentionState value that is not
+ * defined in the platform. Ideally, implementations of
+ * VehicleProperty#DRIVER_DROWSINESS_ATTENTION_STATE should not use this state. The framework
+ * can use this field to remain backwards compatible if DriverDrowsinessAttentionState is
+ * extended to include additional states.
+ */
+ OTHER = 0,
+ /**
+ * Karolinska Sleepiness Scale Rating 1 described as extermely alert.
+ */
+ KSS_RATING_1_EXTREMELY_ALERT = 1,
+ /**
+ * Karolinska Sleepiness Scale Rating 2 described as very alert.
+ */
+ KSS_RATING_2_VERY_ALERT = 2,
+ /**
+ * Karolinska Sleepiness Scale Rating 3 described as alert.
+ */
+ KSS_RATING_3_ALERT = 3,
+ /**
+ * Karolinska Sleepiness Scale Rating 4 described as rather alert.
+ */
+ KSS_RATING_4_RATHER_ALERT = 4,
+ /**
+ * Karolinska Sleepiness Scale Rating 5 described as neither alert nor sleepy.
+ */
+ KSS_RATING_5_NEITHER_ALERT_NOR_SLEEPY = 5,
+ /**
+ * Karolinska Sleepiness Scale Rating 6 described as some signs of sleepiness.
+ */
+ KSS_RATING_6_SOME_SLEEPINESS = 6,
+ /**
+ * Karolinska Sleepiness Scale Rating 7 described as sleepy with no effort to
+ * keep awake.
+ */
+ KSS_RATING_7_SLEEPY_NO_EFFORT = 7,
+ /**
+ * Karolinska Sleepiness Scale Rating 8 described as sleepy with some effort to
+ * keep awake.
+ */
+ KSS_RATING_8_SLEEPY_SOME_EFFORT = 8,
+ /**
+ * Karolinska Sleepiness Scale Rating 9 described as very sleepy, with great
+ * effort to keep away, and fighthing sleep.
+ */
+ KSS_RATING_9_VERY_SLEEPY = 9,
+}
diff --git a/automotive/vehicle/aidl_property/android/hardware/automotive/vehicle/VehicleProperty.aidl b/automotive/vehicle/aidl_property/android/hardware/automotive/vehicle/VehicleProperty.aidl
index af2e903..ce311fb 100644
--- a/automotive/vehicle/aidl_property/android/hardware/automotive/vehicle/VehicleProperty.aidl
+++ b/automotive/vehicle/aidl_property/android/hardware/automotive/vehicle/VehicleProperty.aidl
@@ -5087,6 +5087,78 @@
HANDS_ON_DETECTION_WARNING =
0x1018 + VehiclePropertyGroup.SYSTEM + VehicleArea.GLOBAL + VehiclePropertyType.INT32,
+ /**
+ * Enable or disable driver drowsiness and attention monitoring.
+ *
+ * Set true to enable driver drowsiness and attention monitoring and false to disable driver
+ * drowsiness and attention monitoring. When driver drowsiness and attention monitoring is
+ * enabled, a system inside the vehicle should be monitoring the drowsiness and attention level
+ * of the driver and warn the driver if needed.
+ *
+ * In general, DRIVER_DROWSINESS_ATTENTION_SYSTEM_ENABLED should always return true or false.
+ * If the feature is not available due to some temporary state, that information must be
+ * conveyed through the ErrorState values in the DRIVER_DROWSINESS_ATTENTION_STATE property.
+ *
+ * This property is defined as VehiclePropertyAccess.READ_WRITE, but OEMs have the option to
+ * implement it as VehiclePropertyAccess.READ only.
+ *
+ * @change_mode VehiclePropertyChangeMode.ON_CHANGE
+ * @access VehiclePropertyAccess.READ_WRITE
+ * @access VehiclePropertyAccess.READ
+ */
+ DRIVER_DROWSINESS_ATTENTION_SYSTEM_ENABLED =
+ 0x1019 + VehiclePropertyGroup.SYSTEM + VehicleArea.GLOBAL + VehiclePropertyType.BOOLEAN,
+
+ /**
+ * Driver drowsiness and attention level state.
+ *
+ * Returns the current detected state of driver drowiness and attention level based on the
+ * Karolinska Sleepiness scale. If alternative measurement methods are used, the value should be
+ * translated to the Karolinska Sleepiness Scale equivalent.
+ *
+ * Generally, this property should return a valid state defined in the
+ * DriverDrowsinessAttentionState or ErrorState. For example, if the feature is not available
+ * due to some temporary state, that information should be conveyed through ErrorState.
+ *
+ * If the vehicle is sending a warning to the user because the driver is too drowsy, the warning
+ * should be surfaced through {@link #DRIVER_DROWSINESS_ATTENTION_WARNING}.
+ *
+ * For the global area ID (0), the VehicleAreaConfig#supportedEnumValues array must be defined
+ * unless all states of both DriverDrowsinessAttentionState (including OTHER, which is not
+ * recommended) and ErrorState are supported.
+ *
+ * @change_mode VehiclePropertyChangeMode.ON_CHANGE
+ * @access VehiclePropertyAccess.READ
+ * @data_enum DriverDrowsinessAttentionState
+ * @data_enum ErrorState
+ */
+ DRIVER_DROWSINESS_ATTENTION_STATE =
+ 0x101A + VehiclePropertyGroup.SYSTEM + VehicleArea.GLOBAL + VehiclePropertyType.INT32,
+
+ /**
+ * Enable or disable driver drowsiness and attention warnings.
+ *
+ * Set true to enable driver drowsiness and attention warnings and false to disable driver
+ * drowsiness and attention warnings.
+ *
+ * When driver drowsiness and attention warnings are enabled, the driver drowsiness and
+ * attention monitoring system inside the vehicle should warn the driver when it detects the
+ * driver is drowsy or not attentive.
+ *
+ * In general, DRIVER_DROWSINESS_ATTENTION_WARNING_ENABLED should always return true or false.
+ * If the feature is not available due to some temporary state, that information must be
+ * conveyed through the ErrorState values in the DRIVER_DROWSINESS_ATTENTION_WARNING property.
+ *
+ * This property is defined as VehiclePropertyAccess.READ_WRITE, but OEMs have the option to
+ * implement it as VehiclePropertyAccess.READ only.
+ *
+ * @change_mode VehiclePropertyChangeMode.ON_CHANGE
+ * @access VehiclePropertyAccess.READ_WRITE
+ * @access VehiclePropertyAccess.READ
+ */
+ DRIVER_DROWSINESS_ATTENTION_WARNING_ENABLED =
+ 0x101B + VehiclePropertyGroup.SYSTEM + VehicleArea.GLOBAL + VehiclePropertyType.BOOLEAN,
+
/***************************************************************************
* End of ADAS Properties
**************************************************************************/
diff --git a/automotive/vehicle/tools/translate_aidl_enums.py b/automotive/vehicle/tools/translate_aidl_enums.py
new file mode 100644
index 0000000..d224f6f
--- /dev/null
+++ b/automotive/vehicle/tools/translate_aidl_enums.py
@@ -0,0 +1,231 @@
+#!/usr/bin/python3
+
+# Copyright (C) 2023 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.
+#
+"""A script to generate ENUM_NAME.java file and test files using ENUM_NAME.aidl file.
+
+ Need ANDROID_BUILD_TOP environmental variable to be set. This script will update ENUM_NAME.java
+ under packages/services/Car/car-lib/src/android/car/hardware/property, as well as the
+ ENUM_NAMETest.java files in cts/tests/tests/car/src/android/car/cts and
+ packages/services/Car/tests/android_car_api_test/src/android/car/apitest
+
+ Usage:
+ $ python translate_aidl_enums.py ENUM_NAME.aidl
+"""
+import os
+import sys
+
+LICENSE = """/*
+ * Copyright (C) 2023 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.
+ */
+"""
+
+class EnumParser:
+ def __init__(self, file_path, file_name):
+ self.filePath = file_path
+ self.fileName = file_name
+ self.lowerFileName = self.fileName[0].lower() + self.fileName[1:]
+ self.enums = []
+ self.outputMsg = []
+ self.outputMsg.append(LICENSE)
+ self.outputMsg.append("\npackage android.car.hardware.property;\n")
+ self.outputMsg.append("""
+import android.annotation.IntDef;
+import android.annotation.NonNull;
+
+import com.android.car.internal.util.ConstantDebugUtils;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+""")
+
+ with open(self.filePath, 'r') as f:
+ for line in f.readlines()[16:]:
+ if line in ["package android.hardware.automotive.vehicle;\n",
+ "@VintfStability\n",
+ '@Backing(type="int")\n']:
+ continue
+
+ msg = line
+ msgSplit = msg.strip().split()
+ if len(msgSplit) > 0 and msgSplit[0] == "enum":
+ msgSplit[0] = "public final class"
+ msg = " ".join(msgSplit) + "\n"
+ elif len(msgSplit) > 1 and msgSplit[1] == '=':
+ msgSplit.insert(0, " public static final int")
+ self.enums.append(msgSplit[1])
+ msgSplit[-1] = msgSplit[-1][:-1] + ";\n"
+ msg = " ".join(msgSplit)
+ elif msg == "}\n":
+ self.outputMsg.append("""
+ private {2}() {{}}
+
+ /**
+ * Returns a user-friendly representation of {{@code {2}}}.
+ */
+ @NonNull
+ public static String toString(@{2}Int int {0}) {{
+ String {0}String = ConstantDebugUtils.toName(
+ {2}.class, {0});
+ return ({0}String != null)
+ ? {0}String
+ : "0x" + Integer.toHexString({0});
+ }}
+
+ /** @hide */
+ @IntDef({1})
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface {2}Int {{}}\n""".format(self.lowerFileName, "{" + ", ".join(self.enums) + "}",
+ self.fileName))
+ self.outputMsg.append(msg)
+ self.outputMsg.append("TODO: delete this line and manually update this file with app-facing documentation and necessary tags.\n")
+
+ self.outputMsgApiTest = []
+ self.outputMsgApiTest.append(LICENSE)
+ self.outputMsgApiTest.append("""package android.car.apitest;
+
+import static com.google.common.truth.Truth.assertWithMessage;
+
+import android.test.suitebuilder.annotation.SmallTest;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+@SmallTest
+@RunWith(Parameterized.class)
+public class {0}Test {{
+ private final int mJavaConstantValue;
+ private final int mHalConstantValue;
+
+ public {0}Test(int javaConstantValue, int halConstantValue) {{
+ mJavaConstantValue = javaConstantValue;
+ mHalConstantValue = halConstantValue;
+ }}
+
+ @Parameterized.Parameters
+ public static Collection constantValues() {{
+ return Arrays.asList(
+ new Object[][] {{""".format(self.fileName))
+ for enum in self.enums:
+ self.outputMsgApiTest.append("""
+ {{
+ android.car.hardware.property.{0}.{1},
+ android.hardware.automotive.vehicle.{0}.{1}
+ }},""".format(self.fileName, enum))
+ self.outputMsgApiTest.append("""
+ });
+ }
+
+ @Test
+ public void testMatchWithVehicleHal() {
+ assertWithMessage("Java constant")
+ .that(mJavaConstantValue)
+ .isEqualTo(mHalConstantValue);
+ }
+}
+""")
+
+ self.outputMsgCtsTest = []
+ self.outputMsgCtsTest.append(LICENSE)
+ self.outputMsgCtsTest.append("""
+package android.car.cts;
+
+import static com.google.common.truth.Truth.assertThat;
+import static com.google.common.truth.Truth.assertWithMessage;
+
+import android.car.cts.utils.VehiclePropertyUtils;
+import android.car.hardware.property.{0};
+
+import org.junit.Test;
+
+import java.util.List;
+
+public class {0}Test {{
+
+ @Test
+ public void testToString() {{""".format(self.fileName))
+ for enum in self.enums:
+ self.outputMsgCtsTest.append("""
+ assertThat({0}.toString(
+ {0}.{1}))
+ .isEqualTo("{1}");""".format(self.fileName, enum))
+ self.outputMsgCtsTest.append("""
+ assertThat({0}.toString({1})).isEqualTo("{2}");
+ assertThat({0}.toString(12)).isEqualTo("0xc");
+ }}
+
+ @Test
+ public void testAll{0}sAreMappedInToString() {{
+ List<Integer> {3}s =
+ VehiclePropertyUtils.getIntegersFromDataEnums({0}.class);
+ for (Integer {3} : {3}s) {{
+ String {3}String = {0}.toString(
+ {3});
+ assertWithMessage("%s starts with 0x", {3}String).that(
+ {3}String.startsWith("0x")).isFalse();
+ }}
+ }}
+}}
+""".format(self.fileName, len(self.enums), hex(len(self.enums)), self.lowerFileName))
+
+def main():
+ if len(sys.argv) != 2:
+ print("Usage: {} enum_aidl_file".format(sys.argv[0]))
+ sys.exit(1)
+ print("WARNING: This file only generates the base enum values in the framework layer. The "
+ + "generated files must be reviewed by you and edited if any additional changes are "
+ + "required. The java enum file should be updated with app-developer facing "
+ + "documentation, the @FlaggedApi tag for the new API, and with the @SystemApi tag if "
+ + "the new property is system API")
+ file_path = sys.argv[1]
+ file_name = file_path.split('/')[-1][:-5]
+ parser = EnumParser(file_path, file_name)
+
+ android_top = os.environ['ANDROID_BUILD_TOP']
+ if not android_top:
+ print('ANDROID_BUILD_TOP is not in environmental variable, please run source and lunch '
+ + 'at the android root')
+
+ with open(android_top + "/packages/services/Car/car-lib/src/android/car/hardware/property/"
+ + file_name + ".java", 'w') as f:
+ f.write("".join(parser.outputMsg))
+
+ with open(android_top
+ + "/packages/services/Car/tests/android_car_api_test/src/android/car/apitest/"
+ + file_name + "Test.java", 'w') as f:
+ f.write("".join(parser.outputMsgApiTest))
+
+ with open(android_top + "/cts/tests/tests/car/src/android/car/cts/" + file_name + "Test.java",
+ 'w') as f:
+ f.write("".join(parser.outputMsgCtsTest))
+
+if __name__ == "__main__":
+ main()
\ No newline at end of file
diff --git a/automotive/vehicle/vts/src/VtsHalAutomotiveVehicle_TargetTest.cpp b/automotive/vehicle/vts/src/VtsHalAutomotiveVehicle_TargetTest.cpp
index 3dca0ae..8aed881 100644
--- a/automotive/vehicle/vts/src/VtsHalAutomotiveVehicle_TargetTest.cpp
+++ b/automotive/vehicle/vts/src/VtsHalAutomotiveVehicle_TargetTest.cpp
@@ -621,6 +621,24 @@
VehicleArea::GLOBAL, VehiclePropertyType::INT32);
}
+TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyDriverDrowsinessAttentionSystemEnabledConfig) {
+ verifyProperty(VehicleProperty::DRIVER_DROWSINESS_ATTENTION_SYSTEM_ENABLED,
+ VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,
+ VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
+}
+
+TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyDriverDrowsinessAttentionStateConfig) {
+ verifyProperty(VehicleProperty::DRIVER_DROWSINESS_ATTENTION_STATE, VehiclePropertyAccess::READ,
+ VehiclePropertyChangeMode::ON_CHANGE, VehiclePropertyGroup::SYSTEM,
+ VehicleArea::GLOBAL, VehiclePropertyType::INT32);
+}
+
+TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyDriverDrowsinessAttentionWarningEnabledConfig) {
+ verifyProperty(VehicleProperty::DRIVER_DROWSINESS_ATTENTION_WARNING_ENABLED,
+ VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,
+ VehiclePropertyGroup::SYSTEM, VehicleArea::GLOBAL, VehiclePropertyType::BOOLEAN);
+}
+
TEST_P(VtsHalAutomotiveVehicleTargetTest, verifyEvBrakeRegenerationLevelConfig) {
verifyProperty(VehicleProperty::EV_BRAKE_REGENERATION_LEVEL,
VehiclePropertyAccess::READ_WRITE, VehiclePropertyChangeMode::ON_CHANGE,
diff --git a/biometrics/common/aidl/Android.bp b/biometrics/common/aidl/Android.bp
index b41a937..8502a82 100644
--- a/biometrics/common/aidl/Android.bp
+++ b/biometrics/common/aidl/Android.bp
@@ -13,7 +13,7 @@
srcs: [
"android/hardware/biometrics/common/*.aidl",
],
- frozen: true,
+ frozen: false,
stability: "vintf",
backend: {
java: {
diff --git a/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/AcquiredInfo.aidl b/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/AcquiredInfo.aidl
index 5312ca1..1420cdc 100644
--- a/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/AcquiredInfo.aidl
+++ b/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/AcquiredInfo.aidl
@@ -32,6 +32,7 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.biometrics.face;
+/* @hide */
@Backing(type="byte") @VintfStability
enum AcquiredInfo {
UNKNOWN,
diff --git a/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/AuthenticationFrame.aidl b/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/AuthenticationFrame.aidl
index 20bc767..bbaca12 100644
--- a/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/AuthenticationFrame.aidl
+++ b/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/AuthenticationFrame.aidl
@@ -32,6 +32,7 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.biometrics.face;
+/* @hide */
@VintfStability
parcelable AuthenticationFrame {
android.hardware.biometrics.face.BaseFrame data;
diff --git a/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/BaseFrame.aidl b/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/BaseFrame.aidl
index 67b5cf4..1dd0a9c 100644
--- a/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/BaseFrame.aidl
+++ b/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/BaseFrame.aidl
@@ -32,6 +32,7 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.biometrics.face;
+/* @hide */
@VintfStability
parcelable BaseFrame {
android.hardware.biometrics.face.AcquiredInfo acquiredInfo = android.hardware.biometrics.face.AcquiredInfo.UNKNOWN;
diff --git a/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/Cell.aidl b/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/Cell.aidl
index 6be8c8e..d423a69 100644
--- a/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/Cell.aidl
+++ b/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/Cell.aidl
@@ -32,6 +32,7 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.biometrics.face;
+/* @hide */
@VintfStability
parcelable Cell {
int x;
diff --git a/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/EnrollmentFrame.aidl b/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/EnrollmentFrame.aidl
index 0ea10d6..90be5d0 100644
--- a/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/EnrollmentFrame.aidl
+++ b/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/EnrollmentFrame.aidl
@@ -32,6 +32,7 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.biometrics.face;
+/* @hide */
@VintfStability
parcelable EnrollmentFrame {
@nullable android.hardware.biometrics.face.Cell cell;
diff --git a/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/EnrollmentStage.aidl b/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/EnrollmentStage.aidl
index a203dbe..89b06ca 100644
--- a/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/EnrollmentStage.aidl
+++ b/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/EnrollmentStage.aidl
@@ -32,6 +32,7 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.biometrics.face;
+/* @hide */
@Backing(type="byte") @VintfStability
enum EnrollmentStage {
UNKNOWN,
diff --git a/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/EnrollmentStageConfig.aidl b/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/EnrollmentStageConfig.aidl
index 48db2cf..ee1c01a 100644
--- a/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/EnrollmentStageConfig.aidl
+++ b/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/EnrollmentStageConfig.aidl
@@ -32,6 +32,7 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.biometrics.face;
+/* @hide */
@VintfStability
parcelable EnrollmentStageConfig {
android.hardware.biometrics.face.EnrollmentStage stage = android.hardware.biometrics.face.EnrollmentStage.UNKNOWN;
diff --git a/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/EnrollmentType.aidl b/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/EnrollmentType.aidl
index da1e8a3..180ea5d 100644
--- a/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/EnrollmentType.aidl
+++ b/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/EnrollmentType.aidl
@@ -32,6 +32,7 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.biometrics.face;
+/* @hide */
@Backing(type="byte") @VintfStability
enum EnrollmentType {
DEFAULT,
diff --git a/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/Error.aidl b/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/Error.aidl
index 28eb420..5761e31 100644
--- a/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/Error.aidl
+++ b/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/Error.aidl
@@ -32,6 +32,7 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.biometrics.face;
+/* @hide */
@Backing(type="byte") @VintfStability
enum Error {
UNKNOWN,
diff --git a/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/FaceEnrollOptions.aidl b/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/FaceEnrollOptions.aidl
index 23fa147..c961531 100644
--- a/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/FaceEnrollOptions.aidl
+++ b/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/FaceEnrollOptions.aidl
@@ -32,6 +32,7 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.biometrics.face;
+/* @hide */
@VintfStability
parcelable FaceEnrollOptions {
android.hardware.keymaster.HardwareAuthToken hardwareAuthToken;
diff --git a/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/FaceSensorType.aidl b/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/FaceSensorType.aidl
index bf1677c..ec03733 100644
--- a/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/FaceSensorType.aidl
+++ b/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/FaceSensorType.aidl
@@ -32,6 +32,7 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.biometrics.face;
+/* @hide */
@Backing(type="byte") @VintfStability
enum FaceSensorType {
UNKNOWN,
diff --git a/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/Feature.aidl b/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/Feature.aidl
index 924e6af..3337df8 100644
--- a/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/Feature.aidl
+++ b/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/Feature.aidl
@@ -32,6 +32,7 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.biometrics.face;
+/* @hide */
@Backing(type="byte") @VintfStability
enum Feature {
REQUIRE_ATTENTION,
diff --git a/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/IFace.aidl b/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/IFace.aidl
index fc4a4d0..1ae76de 100644
--- a/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/IFace.aidl
+++ b/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/IFace.aidl
@@ -32,6 +32,7 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.biometrics.face;
+/* @hide */
@VintfStability
interface IFace {
android.hardware.biometrics.face.SensorProps[] getSensorProps();
diff --git a/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/ISession.aidl b/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/ISession.aidl
index 4d99f5a..b655d5f 100644
--- a/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/ISession.aidl
+++ b/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/ISession.aidl
@@ -32,6 +32,7 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.biometrics.face;
+/* @hide */
@VintfStability
interface ISession {
void generateChallenge();
diff --git a/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/ISessionCallback.aidl b/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/ISessionCallback.aidl
index bbace29..c6c035b 100644
--- a/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/ISessionCallback.aidl
+++ b/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/ISessionCallback.aidl
@@ -32,6 +32,7 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.biometrics.face;
+/* @hide */
@VintfStability
interface ISessionCallback {
void onChallengeGenerated(in long challenge);
diff --git a/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/SensorProps.aidl b/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/SensorProps.aidl
index 8b3c51b..918332b 100644
--- a/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/SensorProps.aidl
+++ b/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/SensorProps.aidl
@@ -32,6 +32,7 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.biometrics.face;
+/* @hide */
@VintfStability
parcelable SensorProps {
android.hardware.biometrics.common.CommonProps commonProps;
diff --git a/biometrics/face/aidl/android/hardware/biometrics/face/AcquiredInfo.aidl b/biometrics/face/aidl/android/hardware/biometrics/face/AcquiredInfo.aidl
index cf68421..48b3e8c 100644
--- a/biometrics/face/aidl/android/hardware/biometrics/face/AcquiredInfo.aidl
+++ b/biometrics/face/aidl/android/hardware/biometrics/face/AcquiredInfo.aidl
@@ -15,7 +15,9 @@
*/
package android.hardware.biometrics.face;
-
+/**
+ * @hide
+ */
@VintfStability
@Backing(type="byte")
enum AcquiredInfo {
diff --git a/biometrics/face/aidl/android/hardware/biometrics/face/AuthenticationFrame.aidl b/biometrics/face/aidl/android/hardware/biometrics/face/AuthenticationFrame.aidl
index be61a20..08ef973 100644
--- a/biometrics/face/aidl/android/hardware/biometrics/face/AuthenticationFrame.aidl
+++ b/biometrics/face/aidl/android/hardware/biometrics/face/AuthenticationFrame.aidl
@@ -20,6 +20,7 @@
/**
* Describes an individual frame captured during authentication.
+ * @hide
*/
@VintfStability
parcelable AuthenticationFrame {
diff --git a/biometrics/face/aidl/android/hardware/biometrics/face/BaseFrame.aidl b/biometrics/face/aidl/android/hardware/biometrics/face/BaseFrame.aidl
index 58ad01a..e407d91 100644
--- a/biometrics/face/aidl/android/hardware/biometrics/face/BaseFrame.aidl
+++ b/biometrics/face/aidl/android/hardware/biometrics/face/BaseFrame.aidl
@@ -22,6 +22,7 @@
* Metadata of an individual frame. Can be used by the framework to provide user feedback.
* This parcelable is part of AuthenticationFrame and EnrollmentFrame, and shouldn't be used
* independently of those parcelables.
+ * @hide
*/
@VintfStability
parcelable BaseFrame {
diff --git a/biometrics/face/aidl/android/hardware/biometrics/face/Cell.aidl b/biometrics/face/aidl/android/hardware/biometrics/face/Cell.aidl
index 77f33b9..8960d57 100644
--- a/biometrics/face/aidl/android/hardware/biometrics/face/Cell.aidl
+++ b/biometrics/face/aidl/android/hardware/biometrics/face/Cell.aidl
@@ -18,6 +18,7 @@
/**
* Coordinates of an enrollment UI cell in a vendor-defined coordinate system.
+ * @hide
*/
@VintfStability
parcelable Cell {
diff --git a/biometrics/face/aidl/android/hardware/biometrics/face/EnrollmentFrame.aidl b/biometrics/face/aidl/android/hardware/biometrics/face/EnrollmentFrame.aidl
index ecb0e79..15f019c 100644
--- a/biometrics/face/aidl/android/hardware/biometrics/face/EnrollmentFrame.aidl
+++ b/biometrics/face/aidl/android/hardware/biometrics/face/EnrollmentFrame.aidl
@@ -22,6 +22,7 @@
/**
* Describes an individual frame captured during enrollment.
+ * @hide
*/
@VintfStability
parcelable EnrollmentFrame {
diff --git a/biometrics/face/aidl/android/hardware/biometrics/face/EnrollmentStage.aidl b/biometrics/face/aidl/android/hardware/biometrics/face/EnrollmentStage.aidl
index 5974838..1a3c029 100644
--- a/biometrics/face/aidl/android/hardware/biometrics/face/EnrollmentStage.aidl
+++ b/biometrics/face/aidl/android/hardware/biometrics/face/EnrollmentStage.aidl
@@ -18,6 +18,7 @@
/**
* Enrollment stages that can be mapped to the enrollment UI actions in the framework.
+ * @hide
*/
@VintfStability
@Backing(type="byte")
diff --git a/biometrics/face/aidl/android/hardware/biometrics/face/EnrollmentStageConfig.aidl b/biometrics/face/aidl/android/hardware/biometrics/face/EnrollmentStageConfig.aidl
index a8fa9ab..362d752 100644
--- a/biometrics/face/aidl/android/hardware/biometrics/face/EnrollmentStageConfig.aidl
+++ b/biometrics/face/aidl/android/hardware/biometrics/face/EnrollmentStageConfig.aidl
@@ -19,6 +19,9 @@
import android.hardware.biometrics.face.Cell;
import android.hardware.biometrics.face.EnrollmentStage;
+/**
+ * @hide
+ */
@VintfStability
parcelable EnrollmentStageConfig {
/**
diff --git a/biometrics/face/aidl/android/hardware/biometrics/face/EnrollmentType.aidl b/biometrics/face/aidl/android/hardware/biometrics/face/EnrollmentType.aidl
index c960933..5d92087 100644
--- a/biometrics/face/aidl/android/hardware/biometrics/face/EnrollmentType.aidl
+++ b/biometrics/face/aidl/android/hardware/biometrics/face/EnrollmentType.aidl
@@ -16,6 +16,9 @@
package android.hardware.biometrics.face;
+/**
+ * @hide
+ */
@VintfStability
@Backing(type="byte")
enum EnrollmentType {
diff --git a/biometrics/face/aidl/android/hardware/biometrics/face/Error.aidl b/biometrics/face/aidl/android/hardware/biometrics/face/Error.aidl
index e99415a..77d4717 100644
--- a/biometrics/face/aidl/android/hardware/biometrics/face/Error.aidl
+++ b/biometrics/face/aidl/android/hardware/biometrics/face/Error.aidl
@@ -15,7 +15,9 @@
*/
package android.hardware.biometrics.face;
-
+/**
+ * @hide
+ */
@VintfStability
@Backing(type="byte")
enum Error {
diff --git a/biometrics/face/aidl/android/hardware/biometrics/face/FaceEnrollOptions.aidl b/biometrics/face/aidl/android/hardware/biometrics/face/FaceEnrollOptions.aidl
index 75e3978..c57fb55 100644
--- a/biometrics/face/aidl/android/hardware/biometrics/face/FaceEnrollOptions.aidl
+++ b/biometrics/face/aidl/android/hardware/biometrics/face/FaceEnrollOptions.aidl
@@ -26,6 +26,7 @@
/**
* Enroll options used to pass information to the HAL when requesting an enroll operation.
+ * @hide
*/
@VintfStability
parcelable FaceEnrollOptions {
diff --git a/biometrics/face/aidl/android/hardware/biometrics/face/FaceSensorType.aidl b/biometrics/face/aidl/android/hardware/biometrics/face/FaceSensorType.aidl
index a5ed2e8..bf315a5 100644
--- a/biometrics/face/aidl/android/hardware/biometrics/face/FaceSensorType.aidl
+++ b/biometrics/face/aidl/android/hardware/biometrics/face/FaceSensorType.aidl
@@ -16,6 +16,9 @@
package android.hardware.biometrics.face;
+/**
+ * @hide
+ */
@VintfStability
@Backing(type="byte")
enum FaceSensorType {
diff --git a/biometrics/face/aidl/android/hardware/biometrics/face/Feature.aidl b/biometrics/face/aidl/android/hardware/biometrics/face/Feature.aidl
index bff1a02..9cbab55 100644
--- a/biometrics/face/aidl/android/hardware/biometrics/face/Feature.aidl
+++ b/biometrics/face/aidl/android/hardware/biometrics/face/Feature.aidl
@@ -16,6 +16,9 @@
package android.hardware.biometrics.face;
+/**
+ * @hide
+ */
@VintfStability
@Backing(type="byte")
enum Feature {
diff --git a/biometrics/face/aidl/android/hardware/biometrics/face/IFace.aidl b/biometrics/face/aidl/android/hardware/biometrics/face/IFace.aidl
index 65c589f..0ead435 100644
--- a/biometrics/face/aidl/android/hardware/biometrics/face/IFace.aidl
+++ b/biometrics/face/aidl/android/hardware/biometrics/face/IFace.aidl
@@ -20,6 +20,9 @@
import android.hardware.biometrics.face.ISessionCallback;
import android.hardware.biometrics.face.SensorProps;
+/**
+ * @hide
+ */
@VintfStability
interface IFace {
/**
diff --git a/biometrics/face/aidl/android/hardware/biometrics/face/ISession.aidl b/biometrics/face/aidl/android/hardware/biometrics/face/ISession.aidl
index 825af0c..26cb361 100644
--- a/biometrics/face/aidl/android/hardware/biometrics/face/ISession.aidl
+++ b/biometrics/face/aidl/android/hardware/biometrics/face/ISession.aidl
@@ -42,6 +42,7 @@
* ISession only supports execution of one operation at a time, regardless of whether it's
* cancellable or not. The framework must wait for a corresponding callback indicating the end of
* the current operation before a new operation can be started.
+ * @hide
*/
@VintfStability
diff --git a/biometrics/face/aidl/android/hardware/biometrics/face/ISessionCallback.aidl b/biometrics/face/aidl/android/hardware/biometrics/face/ISessionCallback.aidl
index 9eb575c..b38e366 100644
--- a/biometrics/face/aidl/android/hardware/biometrics/face/ISessionCallback.aidl
+++ b/biometrics/face/aidl/android/hardware/biometrics/face/ISessionCallback.aidl
@@ -23,6 +23,9 @@
import android.hardware.biometrics.face.Feature;
import android.hardware.keymaster.HardwareAuthToken;
+/**
+ * @hide
+ */
@VintfStability
interface ISessionCallback {
/**
diff --git a/biometrics/face/aidl/android/hardware/biometrics/face/SensorProps.aidl b/biometrics/face/aidl/android/hardware/biometrics/face/SensorProps.aidl
index 5f881ca..09fd9e5 100644
--- a/biometrics/face/aidl/android/hardware/biometrics/face/SensorProps.aidl
+++ b/biometrics/face/aidl/android/hardware/biometrics/face/SensorProps.aidl
@@ -19,6 +19,9 @@
import android.hardware.biometrics.common.CommonProps;
import android.hardware.biometrics.face.FaceSensorType;
+/**
+ * @hide
+ */
@VintfStability
parcelable SensorProps {
/**
diff --git a/biometrics/face/aidl/default/FakeFaceEngine.cpp b/biometrics/face/aidl/default/FakeFaceEngine.cpp
index 578231d..dc524bb 100644
--- a/biometrics/face/aidl/default/FakeFaceEngine.cpp
+++ b/biometrics/face/aidl/default/FakeFaceEngine.cpp
@@ -53,15 +53,6 @@
const std::vector<Feature>& /*features*/,
const std::future<void>& cancel) {
BEGIN_OP(FaceHalProperties::operation_start_enroll_latency().value_or(0));
- // format is "<id>,<bucket_id>:<delay>:<succeeds>,<bucket_id>:<delay>:<succeeds>...
- auto nextEnroll = FaceHalProperties::next_enrollment().value_or("");
- // Erase the next enrollment
- FaceHalProperties::next_enrollment({});
-
- AuthenticationFrame frame;
- frame.data.acquiredInfo = AcquiredInfo::START;
- frame.data.vendorCode = 0;
- cb->onAuthenticationFrame(frame);
// Do proper HAT verification in the real implementation.
if (hat.mac.empty()) {
@@ -70,66 +61,81 @@
return;
}
- if (FaceHalProperties::operation_enroll_fails().value_or(false)) {
- LOG(ERROR) << "Fail: operation_enroll_fails";
+ // Format: <id>:<progress_ms-[acquiredInfo,...],...:<success>
+ // ------:-----------------------------------------:--------------
+ // | | |--->enrollment success (true/false)
+ // | |--> progress_steps
+ // |
+ // |-->enrollment id
+ //
+ //
+ // progress_steps
+ // <progress_duration>-[acquiredInfo,...]+
+ // ---------------------------- ---------------------
+ // | |-> sequence of acquiredInfo code
+ // | --> time duration of the step in ms
+ //
+ // E.g. 1:2000-[21,1108,5,6,1],1000-[1113,4,1]:true
+ // A success enrollement of id 1 by 2 steps
+ // 1st step lasts 2000ms with acquiredInfo codes (21,1108,5,6,1)
+ // 2nd step lasts 1000ms with acquiredInfo codes (1113,4,1)
+ //
+ std::string defaultNextEnrollment =
+ "1:1000-[21,7,1,1103],1500-[1108,1],2000-[1113,1],2500-[1118,1]:true";
+ auto nextEnroll = FaceHalProperties::next_enrollment().value_or(defaultNextEnrollment);
+ auto parts = Util::split(nextEnroll, ":");
+ if (parts.size() != 3) {
+ LOG(ERROR) << "Fail: invalid next_enrollment:" << nextEnroll;
cb->onError(Error::VENDOR, 0 /* vendorError */);
return;
}
-
- auto parts = Util::split(nextEnroll, ",");
- if (parts.size() < 2) {
- LOG(ERROR) << "Fail: invalid next_enrollment for : " << nextEnroll;
- cb->onError(Error::VENDOR, 0 /* vendorError */);
- return;
- }
-
auto enrollmentId = std::stoi(parts[0]);
- const int numBuckets = parts.size() - 1;
- for (size_t i = 1; i < parts.size(); i++) {
- auto enrollHit = Util::split(parts[i], ":");
- if (enrollHit.size() != 3) {
- LOG(ERROR) << "Error when unpacking enrollment hit: " << parts[i];
- cb->onError(Error::VENDOR, 0 /* vendorError */);
- }
- std::string bucket = enrollHit[0];
- std::string delay = enrollHit[1];
- std::string succeeds = enrollHit[2];
+ auto progress = Util::parseEnrollmentCapture(parts[1]);
+ for (size_t i = 0; i < progress.size(); i += 2) {
+ auto left = (progress.size() - i) / 2 - 1;
+ auto duration = progress[i][0];
+ auto acquired = progress[i + 1];
+ auto N = acquired.size();
- SLEEP_MS(std::stoi(delay));
+ for (int j = 0; j < N; j++) {
+ SLEEP_MS(duration / N);
- if (shouldCancel(cancel)) {
- LOG(ERROR) << "Fail: cancel";
- cb->onError(Error::CANCELED, 0 /* vendorCode */);
- return;
+ if (shouldCancel(cancel)) {
+ LOG(ERROR) << "Fail: cancel";
+ cb->onError(Error::CANCELED, 0 /* vendorCode */);
+ return;
+ }
+ EnrollmentFrame frame = {};
+ auto ac = convertAcquiredInfo(acquired[j]);
+ frame.data.acquiredInfo = ac.first;
+ frame.data.vendorCode = ac.second;
+ frame.stage = (i == 0 && j == 0) ? EnrollmentStage::FIRST_FRAME_RECEIVED
+ : (i == progress.size() - 2 && j == N - 1)
+ ? EnrollmentStage::ENROLLMENT_FINISHED
+ : EnrollmentStage::WAITING_FOR_CENTERING;
+ cb->onEnrollmentFrame(frame);
}
- if (!IS_TRUE(succeeds)) { // end and failed
- LOG(ERROR) << "Fail: requested by caller: " << parts[i];
+ if (left == 0 && !IS_TRUE(parts[2])) { // end and failed
+ LOG(ERROR) << "Fail: requested by caller: " << nextEnroll;
+ FaceHalProperties::next_enrollment({});
cb->onError(Error::UNABLE_TO_PROCESS, 0 /* vendorCode */);
- return;
- }
-
- EnrollmentFrame frame;
-
- frame.data.acquiredInfo = AcquiredInfo::GOOD;
- frame.data.vendorCode = 0;
- cb->onEnrollmentFrame(frame);
-
- frame.data.acquiredInfo = AcquiredInfo::VENDOR;
- frame.data.vendorCode = std::stoi(bucket);
- cb->onEnrollmentFrame(frame);
-
- int remainingBuckets = numBuckets - i;
- if (remainingBuckets > 0) {
- cb->onEnrollmentProgress(enrollmentId, remainingBuckets);
+ } else { // progress and update props if last time
+ LOG(INFO) << "onEnroll: " << enrollmentId << " left: " << left;
+ if (left == 0) {
+ auto enrollments = FaceHalProperties::enrollments();
+ enrollments.emplace_back(enrollmentId);
+ FaceHalProperties::enrollments(enrollments);
+ FaceHalProperties::next_enrollment({});
+ // change authenticatorId after new enrollment
+ auto id = FaceHalProperties::authenticator_id().value_or(0);
+ auto newId = id + 1;
+ FaceHalProperties::authenticator_id(newId);
+ LOG(INFO) << "Enrolled: " << enrollmentId;
+ }
+ cb->onEnrollmentProgress(enrollmentId, left);
}
}
-
- auto enrollments = FaceHalProperties::enrollments();
- enrollments.push_back(enrollmentId);
- FaceHalProperties::enrollments(enrollments);
- LOG(INFO) << "enrolled : " << enrollmentId;
- cb->onEnrollmentProgress(enrollmentId, 0);
}
void FakeFaceEngine::authenticateImpl(ISessionCallback* cb, int64_t /*operationId*/,
diff --git a/biometrics/face/aidl/default/README.md b/biometrics/face/aidl/default/README.md
index 516a7aa..9225258 100644
--- a/biometrics/face/aidl/default/README.md
+++ b/biometrics/face/aidl/default/README.md
@@ -1,30 +1,35 @@
# Face Virtual HAL (VHAL)
-This is a virtual HAL implementation that is backed by system properties
-instead of actual hardware. It's intended for testing and UI development
-on debuggable builds to allow devices to masquerade as alternative device
-types and for emulators.
-Note: The virtual face HAL feature development will be done in phases. Refer to this doc often for
-the latest supported features
+This is a virtual HAL implementation that is backed by system properties instead
+of actual hardware. It's intended for testing and UI development on debuggable
+builds to allow devices to masquerade as alternative device types and for
+emulators. Note: The virtual face HAL feature development will be done in
+phases. Refer to this doc often for the latest supported features
## Supported Devices
-The face virtual hal is automatically built in in all debug builds (userdebug and eng) for the latest pixel devices and CF.
-The instructions in this doc applies to all
+The face virtual hal is automatically built in in all debug builds (userdebug<br/>
+and eng) for the latest pixel devices and CF. The instructions in this doc<br/>
+applies to all
## Enabling Face Virtual HAL
-On pixel devicse (non-CF), by default (after manufacture reset), Face VHAL is not enabled. Therefore real Face HAL is used.
-Face VHAL enabling is gated by the following two AND conditions:
-1. The Face VHAL feature flag (as part of Trunk-development strategy) must be tured until the flags life-cycle ends.
-2. The Face VHAL must be enabled via sysprop
-See adb commands below
+On pixel devicse (non-CF), by default (after manufacture reset), Face VHAL is <br/>
+not enabled. Therefore real Face HAL is used. Face VHAL enabling is gated by the<br/>
+following two AND conditions:<br/>
+1. The Face VHAL feature flag (as part ofTrunk-development strategy) must be<br/>
+ turned on until the flags life-cycle ends.
+2. The Face VHAL must be enabled via sysprop.
-##Getting Stared
+See the adb commands below
-A basic use case for a successful authentication via Face VHAL is given as an exmple below.
+## Getting Stared
+
+A basic use case for a successful authentication via Face VHAL is given as an
+exmple below.
### Enabling VHAL
+
```shell
$ adb root
$ adb shell device_config put biometrics_framework com.android.server.biometrics.face_vhal_feature true
@@ -35,6 +40,7 @@
```
### Direct Enrollment
+
```shell
$ adb shell locksettings set-pin 0000
$ adb shell setprop persist.vendor.face.virtual.enrollments 1
@@ -42,22 +48,47 @@
```
## Authenticating
-To authenticate successfully, the captured (hit) must match the enrollment id set above. To trigger
-authentication failure, set the hit id to a different value.
+
+To authenticate successfully, the captured (hit) must match the enrollment id<br/>
+set above. To trigger authentication failure, set the hit id to a different value.
```shell
$ adb shell setprop vendor.face.virtual.operation_authenticate_duration 800
$ adb shell setprop vendor.face.virtual.enrollment_hit 1
```
-Refer to face.sysprop for full supported features of authentication, such as error and acquiredInfo insertion
+
+### AcquiredInfo
+AcquiredInfo codes can be sent during authentication by specifying the sysprop.<br/>
+The codes is sent in sequence and in the interval of operation_authentication_duration/numberOfAcquiredInfoCode
+```shell
+$ adb shell setprop vendor.face.virtual.operation_authenticate_acquired 6,9,1013
+```
+Refer to [AcquiredInfo.aidl](https://source.corp.google.com/h/googleplex-android/platform/superproject/main/+/main:hardware/interfaces/biometrics/face/aidl/android/hardware/biometrics/face/AcquiredInfo.aidl) for full face acquiredInfo codes.
+Note: For vendor specific acquired info, acquiredInfo = 1000 + vendorCode.
+
+### Error Insertion
+Error can be inserted during authentction by specifying the authenticate_error sysprop.
+```shell
+$ adb shell setprop vendor.face.virtual.operation_authenticate_error 4
+```
+Refer to [Error.aidl](https://source.corp.google.com/h/googleplex-android/platform/superproject/main/+/main:hardware/interfaces/biometrics/face/aidl/android/hardware/biometrics/face/Error.aidl) for full face error codes
-## Enrollment via Setup
+## Enrollment via Settings
+
+Enrollment process is specified by sysprop `next_enrollment` in the following format
```shell
-# authenticar_id,bucket_id:duration:(true|false)....
-$ adb shell setprop vendor.face.virtual.next_enrollment 1,0:500:true,5:250:true,10:150:true,15:500:true
-$ walk thru the manual enrollment process by following screen instructions
+Format: <id>:<progress_ms-[acquiredInfo,...],...:<success>
+ ----:-----------------------------------:---------
+ | | |--->sucess (true/false)
+ | |--> progress_step(s)
+ |
+ |-->enrollment_id
-# If you would like to get rid of the enrollment, run the follwoing command
-$ adb shell setprop persist.vendor.face.virtual.enrollments \"\"
+E.g.
+$ adb shell setprop vendor.face.virtual.next_enrollment 1:6000-[21,8,1,1108,1,10,1113,1,1118,1124]:true
```
+If next_enrollment prop is not set, the following default value is used:<br/>
+ defaultNextEnrollment="1:1000-[21,7,1,1103],1500-[1108,1],2000-[1113,1],2500-[1118,1]:true"<br/>
+Note: Enrollment data and configuration can be supported upon request in case of needs
+
diff --git a/biometrics/face/aidl/default/tests/FakeFaceEngineTest.cpp b/biometrics/face/aidl/default/tests/FakeFaceEngineTest.cpp
index 6897dc4..69c9bf4 100644
--- a/biometrics/face/aidl/default/tests/FakeFaceEngineTest.cpp
+++ b/biometrics/face/aidl/default/tests/FakeFaceEngineTest.cpp
@@ -45,6 +45,7 @@
};
::ndk::ScopedAStatus onEnrollmentProgress(int32_t enrollmentId, int32_t remaining) override {
if (remaining == 0) mLastEnrolled = enrollmentId;
+ mRemaining = remaining;
return ndk::ScopedAStatus::ok();
};
@@ -128,6 +129,7 @@
bool mAuthenticatorIdInvalidated = false;
bool mLockoutPermanent = false;
int mInteractionDetectedCount = 0;
+ int mRemaining = -1;
};
class FakeFaceEngineTest : public ::testing::Test {
@@ -193,7 +195,7 @@
}
TEST_F(FakeFaceEngineTest, Enroll) {
- FaceHalProperties::next_enrollment("1,0:30:true,1:0:true,2:0:true,3:0:true,4:0:true");
+ FaceHalProperties::next_enrollment("1,0:1000-[21,5,6,7,1],1100-[1118,1108,1]:true");
keymaster::HardwareAuthToken hat{.mac = {2, 4}};
mEngine.enrollImpl(mCallback.get(), hat, {} /*enrollmentType*/, {} /*features*/,
mCancel.get_future());
@@ -201,10 +203,11 @@
ASSERT_EQ(1, FaceHalProperties::enrollments().size());
ASSERT_EQ(1, FaceHalProperties::enrollments()[0].value());
ASSERT_EQ(1, mCallback->mLastEnrolled);
+ ASSERT_EQ(0, mCallback->mRemaining);
}
TEST_F(FakeFaceEngineTest, EnrollFails) {
- FaceHalProperties::next_enrollment("1,0:30:true,1:0:true,2:0:true,3:0:true,4:0:false");
+ FaceHalProperties::next_enrollment("1,0:1000-[21,5,6,7,1],1100-[1118,1108,1]:false");
keymaster::HardwareAuthToken hat{.mac = {2, 4}};
mEngine.enrollImpl(mCallback.get(), hat, {} /*enrollmentType*/, {} /*features*/,
mCancel.get_future());
@@ -213,7 +216,7 @@
}
TEST_F(FakeFaceEngineTest, EnrollCancel) {
- FaceHalProperties::next_enrollment("1,0:30:true,1:0:true,2:0:true,3:0:true,4:0:false");
+ FaceHalProperties::next_enrollment("1:2000-[21,8,9],300:false");
keymaster::HardwareAuthToken hat{.mac = {2, 4}};
mCancel.set_value();
mEngine.enrollImpl(mCallback.get(), hat, {} /*enrollmentType*/, {} /*features*/,
@@ -221,7 +224,7 @@
ASSERT_EQ(Error::CANCELED, mCallback->mError);
ASSERT_EQ(-1, mCallback->mLastEnrolled);
ASSERT_EQ(0, FaceHalProperties::enrollments().size());
- ASSERT_FALSE(FaceHalProperties::next_enrollment().has_value());
+ ASSERT_TRUE(FaceHalProperties::next_enrollment().has_value());
}
TEST_F(FakeFaceEngineTest, Authenticate) {
diff --git a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AacObjectType.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AacObjectType.aidl
index 2148244..418dd7a 100644
--- a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AacObjectType.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AacObjectType.aidl
@@ -34,8 +34,8 @@
package android.hardware.bluetooth.audio;
@Backing(type="byte") @VintfStability
enum AacObjectType {
- MPEG2_LC = 0,
- MPEG4_LC = 1,
- MPEG4_LTP = 2,
- MPEG4_SCALABLE = 3,
+ MPEG2_LC,
+ MPEG4_LC,
+ MPEG4_LTP,
+ MPEG4_SCALABLE,
}
diff --git a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AptxAdaptiveChannelMode.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AptxAdaptiveChannelMode.aidl
index 0499b70..675f9f2 100644
--- a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AptxAdaptiveChannelMode.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AptxAdaptiveChannelMode.aidl
@@ -38,5 +38,5 @@
MONO = 1,
DUAL_MONO = 2,
TWS_STEREO = 4,
- UNKNOWN = 255,
+ UNKNOWN = 0xFF,
}
diff --git a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AptxAdaptiveInputMode.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AptxAdaptiveInputMode.aidl
index f702939..a18303e 100644
--- a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AptxAdaptiveInputMode.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AptxAdaptiveInputMode.aidl
@@ -34,6 +34,6 @@
package android.hardware.bluetooth.audio;
@Backing(type="int") @VintfStability
enum AptxAdaptiveInputMode {
- STEREO = 0,
- DUAL_MONO = 1,
+ STEREO = 0x00,
+ DUAL_MONO = 0x01,
}
diff --git a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AptxMode.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AptxMode.aidl
index d5dd9d9..dd8cf08 100644
--- a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AptxMode.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AptxMode.aidl
@@ -34,8 +34,8 @@
package android.hardware.bluetooth.audio;
@Backing(type="int") @VintfStability
enum AptxMode {
- UNKNOWN = 0,
- HIGH_QUALITY = 4096,
- LOW_LATENCY = 8192,
- ULTRA_LOW_LATENCY = 16384,
+ UNKNOWN = 0x00,
+ HIGH_QUALITY = 0x1000,
+ LOW_LATENCY = 0x2000,
+ ULTRA_LOW_LATENCY = 0x4000,
}
diff --git a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AudioConfiguration.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AudioConfiguration.aidl
index 3abfb31..edb9ee2 100644
--- a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AudioConfiguration.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AudioConfiguration.aidl
@@ -38,4 +38,5 @@
android.hardware.bluetooth.audio.CodecConfiguration a2dpConfig;
android.hardware.bluetooth.audio.LeAudioConfiguration leAudioConfig;
android.hardware.bluetooth.audio.LeAudioBroadcastConfiguration leAudioBroadcastConfig;
+ android.hardware.bluetooth.audio.HfpConfiguration hfpConfig;
}
diff --git a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AudioContext.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AudioContext.aidl
new file mode 100644
index 0000000..5aafeb7
--- /dev/null
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AudioContext.aidl
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2023 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.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+// the interface (from the latest frozen version), the build system will
+// prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.hardware.bluetooth.audio;
+@VintfStability
+parcelable AudioContext {
+ int bitmask;
+ const int UNSPECIFIED = 0x0001;
+ const int CONVERSATIONAL = 0x0002;
+ const int MEDIA = 0x0004;
+ const int GAME = 0x0008;
+ const int INSTRUCTIONAL = 0x0010;
+ const int VOICE_ASSISTANTS = 0x0020;
+ const int LIVE_AUDIO = 0x0040;
+ const int SOUND_EFFECTS = 0x0080;
+ const int NOTIFICATIONS = 0x0100;
+ const int RINGTONE_ALERTS = 0x0200;
+ const int ALERTS = 0x0400;
+ const int EMERGENCY_ALARM = 0x0800;
+}
diff --git a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AudioLocation.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AudioLocation.aidl
index 319a5e2..941344c 100644
--- a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AudioLocation.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AudioLocation.aidl
@@ -35,6 +35,6 @@
@Backing(type="int") @VintfStability
enum AudioLocation {
UNKNOWN = 1,
- FRONT_LEFT = 2,
- FRONT_RIGHT = 4,
+ FRONT_LEFT = (1 << 1) /* 2 */,
+ FRONT_RIGHT = (1 << 2) /* 4 */,
}
diff --git a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/ChannelMode.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/ChannelMode.aidl
index feacb80..2bb5cd8 100644
--- a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/ChannelMode.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/ChannelMode.aidl
@@ -34,8 +34,8 @@
package android.hardware.bluetooth.audio;
@Backing(type="byte") @VintfStability
enum ChannelMode {
- UNKNOWN = 0,
- MONO = 1,
- STEREO = 2,
- DUALMONO = 3,
+ UNKNOWN,
+ MONO,
+ STEREO,
+ DUALMONO,
}
diff --git a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/CodecId.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/CodecId.aidl
new file mode 100644
index 0000000..f3b4102
--- /dev/null
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/CodecId.aidl
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2023 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.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+// the interface (from the latest frozen version), the build system will
+// prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.hardware.bluetooth.audio;
+@VintfStability
+union CodecId {
+ android.hardware.bluetooth.audio.CodecId.A2dp a2dp = android.hardware.bluetooth.audio.CodecId.A2dp.SBC;
+ android.hardware.bluetooth.audio.CodecId.Core core;
+ android.hardware.bluetooth.audio.CodecId.Vendor vendor;
+ enum A2dp {
+ SBC = 0,
+ AAC = 2,
+ }
+ enum Core {
+ CVSD = 2,
+ MSBC = 5,
+ LC3 = 6,
+ }
+ parcelable Vendor {
+ int id;
+ int codecId;
+ }
+}
diff --git a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/CodecInfo.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/CodecInfo.aidl
new file mode 100644
index 0000000..2ca9d96
--- /dev/null
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/CodecInfo.aidl
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2023 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.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+// the interface (from the latest frozen version), the build system will
+// prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.hardware.bluetooth.audio;
+@VintfStability
+parcelable CodecInfo {
+ android.hardware.bluetooth.audio.CodecId id;
+ String name;
+ android.hardware.bluetooth.audio.CodecInfo.Transport transport;
+ parcelable A2dp {
+ byte[] capabilities;
+ android.hardware.bluetooth.audio.ChannelMode[] channelMode;
+ int[] samplingFrequencyHz;
+ int[] bitdepth;
+ boolean lossless;
+ }
+ parcelable Hfp {
+ int inputDataPath = 1;
+ int outputDataPath = 1;
+ boolean useControllerCodec = true;
+ }
+ union Transport {
+ android.hardware.bluetooth.audio.CodecInfo.A2dp a2dp;
+ android.hardware.bluetooth.audio.CodecInfo.Hfp hfp;
+ }
+}
diff --git a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/CodecType.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/CodecType.aidl
index 3e204f9..d4f205e 100644
--- a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/CodecType.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/CodecType.aidl
@@ -34,16 +34,16 @@
package android.hardware.bluetooth.audio;
@Backing(type="int") @VintfStability
enum CodecType {
- UNKNOWN = 0,
- SBC = 1,
- AAC = 2,
- APTX = 3,
- APTX_HD = 4,
- LDAC = 5,
- LC3 = 6,
- VENDOR = 7,
- APTX_ADAPTIVE = 8,
- OPUS = 9,
- APTX_ADAPTIVE_LE = 10,
- APTX_ADAPTIVE_LEX = 11,
+ UNKNOWN,
+ SBC,
+ AAC,
+ APTX,
+ APTX_HD,
+ LDAC,
+ LC3,
+ VENDOR,
+ APTX_ADAPTIVE,
+ OPUS,
+ APTX_ADAPTIVE_LE,
+ APTX_ADAPTIVE_LEX,
}
diff --git a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/HfpConfiguration.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/HfpConfiguration.aidl
new file mode 100644
index 0000000..490a05d
--- /dev/null
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/HfpConfiguration.aidl
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2023 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.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+// the interface (from the latest frozen version), the build system will
+// prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.hardware.bluetooth.audio;
+@VintfStability
+parcelable HfpConfiguration {
+ android.hardware.bluetooth.audio.CodecId codecId;
+ int connectionHandle;
+ boolean nrec;
+ boolean controllerCodec;
+}
diff --git a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/IBluetoothAudioProviderFactory.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/IBluetoothAudioProviderFactory.aidl
index 5e33deb..c806b0a 100644
--- a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/IBluetoothAudioProviderFactory.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/IBluetoothAudioProviderFactory.aidl
@@ -36,4 +36,10 @@
interface IBluetoothAudioProviderFactory {
android.hardware.bluetooth.audio.AudioCapabilities[] getProviderCapabilities(in android.hardware.bluetooth.audio.SessionType sessionType);
android.hardware.bluetooth.audio.IBluetoothAudioProvider openProvider(in android.hardware.bluetooth.audio.SessionType sessionType);
+ @nullable android.hardware.bluetooth.audio.IBluetoothAudioProviderFactory.ProviderInfo getProviderInfo(in android.hardware.bluetooth.audio.SessionType sessionType);
+ @VintfStability
+ parcelable ProviderInfo {
+ String name;
+ android.hardware.bluetooth.audio.CodecInfo[] codecInfos;
+ }
}
diff --git a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LdacChannelMode.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LdacChannelMode.aidl
index 88d6faf..3d80c4b 100644
--- a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LdacChannelMode.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LdacChannelMode.aidl
@@ -34,8 +34,8 @@
package android.hardware.bluetooth.audio;
@Backing(type="byte") @VintfStability
enum LdacChannelMode {
- UNKNOWN = 0,
- STEREO = 1,
- DUAL = 2,
- MONO = 3,
+ UNKNOWN,
+ STEREO,
+ DUAL,
+ MONO,
}
diff --git a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LdacQualityIndex.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LdacQualityIndex.aidl
index 35e4358..a332dc5 100644
--- a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LdacQualityIndex.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LdacQualityIndex.aidl
@@ -34,8 +34,8 @@
package android.hardware.bluetooth.audio;
@Backing(type="byte") @VintfStability
enum LdacQualityIndex {
- HIGH = 0,
- MID = 1,
- LOW = 2,
- ABR = 3,
+ HIGH,
+ MID,
+ LOW,
+ ABR,
}
diff --git a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/SbcAllocMethod.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/SbcAllocMethod.aidl
index 091f6d7..9cf65d5 100644
--- a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/SbcAllocMethod.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/SbcAllocMethod.aidl
@@ -34,6 +34,6 @@
package android.hardware.bluetooth.audio;
@Backing(type="byte") @VintfStability
enum SbcAllocMethod {
- ALLOC_MD_S = 0,
- ALLOC_MD_L = 1,
+ ALLOC_MD_S,
+ ALLOC_MD_L,
}
diff --git a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/SbcChannelMode.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/SbcChannelMode.aidl
index 6441a99..7779aa0 100644
--- a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/SbcChannelMode.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/SbcChannelMode.aidl
@@ -34,9 +34,9 @@
package android.hardware.bluetooth.audio;
@Backing(type="byte") @VintfStability
enum SbcChannelMode {
- UNKNOWN = 0,
- JOINT_STEREO = 1,
- STEREO = 2,
- DUAL = 3,
- MONO = 4,
+ UNKNOWN,
+ JOINT_STEREO,
+ STEREO,
+ DUAL,
+ MONO,
}
diff --git a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/SessionType.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/SessionType.aidl
index 33a3187..71cca53 100644
--- a/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/SessionType.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/SessionType.aidl
@@ -34,16 +34,19 @@
package android.hardware.bluetooth.audio;
@Backing(type="byte") @VintfStability
enum SessionType {
- UNKNOWN = 0,
- A2DP_SOFTWARE_ENCODING_DATAPATH = 1,
- A2DP_HARDWARE_OFFLOAD_ENCODING_DATAPATH = 2,
- HEARING_AID_SOFTWARE_ENCODING_DATAPATH = 3,
- LE_AUDIO_SOFTWARE_ENCODING_DATAPATH = 4,
- LE_AUDIO_SOFTWARE_DECODING_DATAPATH = 5,
- LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH = 6,
- LE_AUDIO_HARDWARE_OFFLOAD_DECODING_DATAPATH = 7,
- LE_AUDIO_BROADCAST_SOFTWARE_ENCODING_DATAPATH = 8,
- LE_AUDIO_BROADCAST_HARDWARE_OFFLOAD_ENCODING_DATAPATH = 9,
- A2DP_SOFTWARE_DECODING_DATAPATH = 10,
- A2DP_HARDWARE_OFFLOAD_DECODING_DATAPATH = 11,
+ UNKNOWN,
+ A2DP_SOFTWARE_ENCODING_DATAPATH,
+ A2DP_HARDWARE_OFFLOAD_ENCODING_DATAPATH,
+ HEARING_AID_SOFTWARE_ENCODING_DATAPATH,
+ LE_AUDIO_SOFTWARE_ENCODING_DATAPATH,
+ LE_AUDIO_SOFTWARE_DECODING_DATAPATH,
+ LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH,
+ LE_AUDIO_HARDWARE_OFFLOAD_DECODING_DATAPATH,
+ LE_AUDIO_BROADCAST_SOFTWARE_ENCODING_DATAPATH,
+ LE_AUDIO_BROADCAST_HARDWARE_OFFLOAD_ENCODING_DATAPATH,
+ A2DP_SOFTWARE_DECODING_DATAPATH,
+ A2DP_HARDWARE_OFFLOAD_DECODING_DATAPATH,
+ HFP_SOFTWARE_ENCODING_DATAPATH,
+ HFP_SOFTWARE_DECODING_DATAPATH,
+ HFP_HARDWARE_OFFLOAD_DATAPATH,
}
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AudioConfiguration.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AudioConfiguration.aidl
index a06337e..b7f7f29 100644
--- a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AudioConfiguration.aidl
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AudioConfiguration.aidl
@@ -17,6 +17,7 @@
package android.hardware.bluetooth.audio;
import android.hardware.bluetooth.audio.CodecConfiguration;
+import android.hardware.bluetooth.audio.HfpConfiguration;
import android.hardware.bluetooth.audio.LeAudioBroadcastConfiguration;
import android.hardware.bluetooth.audio.LeAudioConfiguration;
import android.hardware.bluetooth.audio.PcmConfiguration;
@@ -30,4 +31,5 @@
CodecConfiguration a2dpConfig;
LeAudioConfiguration leAudioConfig;
LeAudioBroadcastConfiguration leAudioBroadcastConfig;
+ HfpConfiguration hfpConfig;
}
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AudioContext.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AudioContext.aidl
new file mode 100644
index 0000000..306e897
--- /dev/null
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AudioContext.aidl
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2023 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.bluetooth.audio;
+
+/**
+ * Context of the audio configuration.
+ * Defined by PACS (Le Audio) and used either by A2DP or LE Audio.
+ * The `bitmask` is any combination of BT Sig standardized values
+ * [Assigned Numbers - 6.12.3], defined in this scope.
+ */
+@VintfStability
+parcelable AudioContext {
+ const int UNSPECIFIED = 0x0001;
+ const int CONVERSATIONAL = 0x0002;
+ const int MEDIA = 0x0004;
+ const int GAME = 0x0008;
+ const int INSTRUCTIONAL = 0x0010;
+ const int VOICE_ASSISTANTS = 0x0020;
+ const int LIVE_AUDIO = 0x0040;
+ const int SOUND_EFFECTS = 0x0080;
+ const int NOTIFICATIONS = 0x0100;
+ const int RINGTONE_ALERTS = 0x0200;
+ const int ALERTS = 0x0400;
+ const int EMERGENCY_ALARM = 0x0800;
+
+ int bitmask;
+}
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/CodecId.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/CodecId.aidl
new file mode 100644
index 0000000..896a712
--- /dev/null
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/CodecId.aidl
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2023 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.bluetooth.audio;
+
+@VintfStability
+union CodecId {
+ /**
+ * Codec Identifier defined for A2DP
+ * The values are assigned by BT Sig [Assigned Numbers - 6.5.1]
+ */
+ enum A2dp { SBC = 0, AAC = 2 }
+
+ /**
+ * Codec Identifier defined for the Bluetooth Core Specification
+ * The values are assigned by BT Sig [Assigned Numbers - 2.11]
+ */
+ enum Core { CVSD = 2, MSBC = 5, LC3 = 6 }
+
+ /**
+ * Vendor Codec:
+ * id 16 bits - Assigned by BT Sig
+ * codecId 16 bits - Assigned by the vendor
+ */
+ parcelable Vendor {
+ int id;
+ int codecId;
+ }
+
+ /**
+ * Standard (A2DP or Core numbering space) or vendor
+ */
+ A2dp a2dp = A2dp.SBC;
+ Core core;
+ Vendor vendor;
+}
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/CodecInfo.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/CodecInfo.aidl
new file mode 100644
index 0000000..127cd7c
--- /dev/null
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/CodecInfo.aidl
@@ -0,0 +1,99 @@
+/*
+ * Copyright 2023 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.bluetooth.audio;
+
+import android.hardware.bluetooth.audio.ChannelMode;
+import android.hardware.bluetooth.audio.CodecId;
+
+/**
+ * General information about a Codec
+ */
+@VintfStability
+parcelable CodecInfo {
+ /**
+ * Codec identifier and human readable name
+ */
+ CodecId id;
+ String name;
+
+ /**
+ * A2DP Context
+ */
+ parcelable A2dp {
+ /**
+ * The capabilities as defined by A2DP for codec interoperability
+ * requirements. With `id.a2dp`, the format is given by the `Codec
+ * Specific Information Elements` [A2DP - 4.3-6.2], and with `id.vendor`,
+ * by `Vendor Specific Value` [A2DP - 4.7.2].
+ */
+ byte[] capabilities;
+
+ /**
+ * PCM characteristics:
+ * - Mono, Dual-Mono or Stereo
+ * - Supported sampling frequencies, in Hz.
+ * - Fixed point resolution, basically 16, 24 or 32 bits by samples.
+ * The value 32 should be used for floating point representation.
+ *
+ * When the bitdepth is not an encoding/decoding parameter (don't take part
+ * in the interoperability), the `bitdepth` list shall have a single element
+ * indicating the bitdepth selected for the platform.
+ */
+ ChannelMode[] channelMode;
+ int[] samplingFrequencyHz;
+ int[] bitdepth;
+
+ /**
+ * Lossless capable characteristic
+ */
+ boolean lossless;
+ }
+
+ /**
+ * HFP Context
+ */
+ parcelable Hfp {
+ /**
+ * Vendor-specific identifiers of stream data paths, set in the
+ * HCI Command Enhanced Setup Synchronous Connection [Core - 4.E.7.1.45],
+ * in the command parameters respectively `Input_Data_Path` and
+ * `Output_Data_Path`. The value range from 0x01 to 0xFE.
+ * The stack operates as a pass-through; the client SHALL NOT
+ * interpret the values.
+ */
+ int inputDataPath = 1;
+ int outputDataPath = 1;
+
+ /**
+ * Whether the audio stream is encoded and decoded in the controller or
+ * locally; enable the controller transparent mode when the audio
+ * stream is locally processed.
+ */
+ boolean useControllerCodec = true;
+ }
+
+ /**
+ * Specific informations,
+ * depending on transport.
+ */
+ union Transport {
+ A2dp a2dp;
+ Hfp hfp;
+ }
+
+ Transport transport;
+}
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/HfpConfiguration.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/HfpConfiguration.aidl
new file mode 100644
index 0000000..9494bb9
--- /dev/null
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/HfpConfiguration.aidl
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2023 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.bluetooth.audio;
+
+import android.hardware.bluetooth.audio.CodecId;
+
+@VintfStability
+parcelable HfpConfiguration {
+ /**
+ * Codec identifier.
+ */
+ CodecId codecId;
+
+ /**
+ * The connection handle used for SCO connection.
+ * Range: 0x0000 to 0x0EFF.
+ */
+ int connectionHandle;
+
+ /**
+ * Echo canceling and noise reduction functions resident in the AG.
+ */
+ boolean nrec;
+
+ /**
+ * Indicate whether the codec is encoded and decoded in the controller.
+ * If the codec is inside the DSP, then it would be transparent mode.
+ */
+ boolean controllerCodec;
+}
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/IBluetoothAudioProvider.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/IBluetoothAudioProvider.aidl
index d5c051e..558173e 100644
--- a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/IBluetoothAudioProvider.aidl
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/IBluetoothAudioProvider.aidl
@@ -59,9 +59,8 @@
* audioConfig.pcmConfig parameter. Invalid if streaming is offloaded
* from/to hardware or on failure
*/
- MQDescriptor<byte, SynchronizedReadWrite> startSession(
- in IBluetoothAudioPort hostIf, in AudioConfiguration audioConfig,
- in LatencyMode[] supportedLatencyModes);
+ MQDescriptor<byte, SynchronizedReadWrite> startSession(in IBluetoothAudioPort hostIf,
+ in AudioConfiguration audioConfig, in LatencyMode[] supportedLatencyModes);
/**
* Callback for IBluetoothAudioPort.startStream()
*
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/IBluetoothAudioProviderFactory.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/IBluetoothAudioProviderFactory.aidl
index 3cde22c..b9cec2d 100644
--- a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/IBluetoothAudioProviderFactory.aidl
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/IBluetoothAudioProviderFactory.aidl
@@ -17,8 +17,10 @@
package android.hardware.bluetooth.audio;
import android.hardware.bluetooth.audio.AudioCapabilities;
+import android.hardware.bluetooth.audio.CodecInfo;
import android.hardware.bluetooth.audio.IBluetoothAudioProvider;
import android.hardware.bluetooth.audio.SessionType;
+
/**
* This factory allows a HAL implementation to be split into multiple
* independent providers.
@@ -62,4 +64,24 @@
* @return provider The provider of the specified session type
*/
IBluetoothAudioProvider openProvider(in SessionType sessionType);
+
+ /**
+ * General information relative to a provider
+ * - An optional name
+ * - A list of codec information
+ */
+ @VintfStability
+ parcelable ProviderInfo {
+ String name;
+ CodecInfo[] codecInfos;
+ }
+
+ /**
+ * Get general information relative to a provider.
+ *
+ * @param sessionType Hardware Offload provider (*_HARDWARE_OFFLOAD_*)
+ * @return General information relative to the provider.
+ * The `null` value can be returned when the provider is not available
+ */
+ @nullable ProviderInfo getProviderInfo(in SessionType sessionType);
}
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/SessionType.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/SessionType.aidl
index 7acb5c6..35292a1 100644
--- a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/SessionType.aidl
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/SessionType.aidl
@@ -70,4 +70,17 @@
* The decoding of AVDTP media is done by HW and there is control only
*/
A2DP_HARDWARE_OFFLOAD_DECODING_DATAPATH,
+ /**
+ * Used when audio is encoded by Bluetooth Stack and is streaming to HFP device.
+ */
+ HFP_SOFTWARE_ENCODING_DATAPATH,
+ /**
+ * Used when audio is decoded by Bluetooth Stack and is streaming to HFP device.
+ */
+ HFP_SOFTWARE_DECODING_DATAPATH,
+ /**
+ * Used when encoded and decoded by hardware offload and is streamed to HFP device.
+ * This is a control path only.
+ */
+ HFP_HARDWARE_OFFLOAD_DATAPATH,
}
diff --git a/bluetooth/audio/aidl/default/Android.bp b/bluetooth/audio/aidl/default/Android.bp
index 40aea32..ad4d8ce 100644
--- a/bluetooth/audio/aidl/default/Android.bp
+++ b/bluetooth/audio/aidl/default/Android.bp
@@ -20,6 +20,8 @@
"A2dpOffloadAudioProvider.cpp",
"A2dpSoftwareAudioProvider.cpp",
"HearingAidAudioProvider.cpp",
+ "HfpOffloadAudioProvider.cpp",
+ "HfpSoftwareAudioProvider.cpp",
"LeAudioOffloadAudioProvider.cpp",
"LeAudioSoftwareAudioProvider.cpp",
"service.cpp",
diff --git a/bluetooth/audio/aidl/default/BluetoothAudioProvider.cpp b/bluetooth/audio/aidl/default/BluetoothAudioProvider.cpp
index 9c72e19..f9b18f8 100644
--- a/bluetooth/audio/aidl/default/BluetoothAudioProvider.cpp
+++ b/bluetooth/audio/aidl/default/BluetoothAudioProvider.cpp
@@ -168,4 +168,4 @@
} // namespace bluetooth
} // namespace hardware
} // namespace android
-} // namespace aidl
\ No newline at end of file
+} // namespace aidl
diff --git a/bluetooth/audio/aidl/default/BluetoothAudioProviderFactory.cpp b/bluetooth/audio/aidl/default/BluetoothAudioProviderFactory.cpp
index 91731d4..8c6421d 100644
--- a/bluetooth/audio/aidl/default/BluetoothAudioProviderFactory.cpp
+++ b/bluetooth/audio/aidl/default/BluetoothAudioProviderFactory.cpp
@@ -25,6 +25,8 @@
#include "A2dpSoftwareAudioProvider.h"
#include "BluetoothAudioProvider.h"
#include "HearingAidAudioProvider.h"
+#include "HfpOffloadAudioProvider.h"
+#include "HfpSoftwareAudioProvider.h"
#include "LeAudioOffloadAudioProvider.h"
#include "LeAudioSoftwareAudioProvider.h"
@@ -78,6 +80,15 @@
case SessionType::A2DP_HARDWARE_OFFLOAD_DECODING_DATAPATH:
provider = ndk::SharedRefBase::make<A2dpOffloadDecodingAudioProvider>();
break;
+ case SessionType::HFP_SOFTWARE_ENCODING_DATAPATH:
+ provider = ndk::SharedRefBase::make<HfpSoftwareOutputAudioProvider>();
+ break;
+ case SessionType::HFP_SOFTWARE_DECODING_DATAPATH:
+ provider = ndk::SharedRefBase::make<HfpSoftwareInputAudioProvider>();
+ break;
+ case SessionType::HFP_HARDWARE_OFFLOAD_DATAPATH:
+ provider = ndk::SharedRefBase::make<HfpOffloadAudioProvider>();
+ break;
default:
provider = nullptr;
break;
@@ -135,8 +146,17 @@
return ndk::ScopedAStatus::ok();
}
+ndk::ScopedAStatus BluetoothAudioProviderFactory::getProviderInfo(
+ SessionType session_type, std::optional<ProviderInfo>* _aidl_return) {
+ *_aidl_return = std::nullopt;
+
+ (void)session_type;
+
+ return ndk::ScopedAStatus::ok();
+}
+
} // namespace audio
} // namespace bluetooth
} // namespace hardware
} // namespace android
-} // namespace aidl
\ No newline at end of file
+} // namespace aidl
diff --git a/bluetooth/audio/aidl/default/BluetoothAudioProviderFactory.h b/bluetooth/audio/aidl/default/BluetoothAudioProviderFactory.h
index b38cfd2..1afae64 100644
--- a/bluetooth/audio/aidl/default/BluetoothAudioProviderFactory.h
+++ b/bluetooth/audio/aidl/default/BluetoothAudioProviderFactory.h
@@ -35,6 +35,10 @@
ndk::ScopedAStatus getProviderCapabilities(
const SessionType session_type,
std::vector<AudioCapabilities>* _aidl_return) override;
+
+ ndk::ScopedAStatus getProviderInfo(
+ SessionType in_sessionType,
+ std::optional<ProviderInfo>* _aidl_return) override;
};
} // namespace audio
diff --git a/bluetooth/audio/aidl/default/HfpOffloadAudioProvider.cpp b/bluetooth/audio/aidl/default/HfpOffloadAudioProvider.cpp
new file mode 100644
index 0000000..7196bb6
--- /dev/null
+++ b/bluetooth/audio/aidl/default/HfpOffloadAudioProvider.cpp
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2023 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 "BTAudioProviderHfpHW"
+
+#include "HfpOffloadAudioProvider.h"
+
+#include <BluetoothAudioCodecs.h>
+#include <BluetoothAudioSessionReport.h>
+#include <android-base/logging.h>
+
+namespace aidl {
+namespace android {
+namespace hardware {
+namespace bluetooth {
+namespace audio {
+
+HfpOffloadAudioProvider::HfpOffloadAudioProvider() {
+ session_type_ = SessionType::HFP_HARDWARE_OFFLOAD_DATAPATH;
+}
+
+bool HfpOffloadAudioProvider::isValid(const SessionType& session_type) {
+ return (session_type == session_type_);
+}
+
+ndk::ScopedAStatus HfpOffloadAudioProvider::startSession(
+ const std::shared_ptr<IBluetoothAudioPort>& host_if,
+ const AudioConfiguration& audio_config,
+ const std::vector<LatencyMode>& latency_modes, DataMQDesc* _aidl_return) {
+ if (audio_config.getTag() != AudioConfiguration::hfpConfig) {
+ LOG(WARNING) << __func__ << " - Invalid Audio Configuration="
+ << audio_config.toString();
+ *_aidl_return = DataMQDesc();
+ return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
+ }
+ return BluetoothAudioProvider::startSession(host_if, audio_config,
+ latency_modes, _aidl_return);
+}
+
+ndk::ScopedAStatus HfpOffloadAudioProvider::onSessionReady(
+ DataMQDesc* _aidl_return) {
+ *_aidl_return = DataMQDesc();
+ BluetoothAudioSessionReport::OnSessionStarted(
+ session_type_, stack_iface_, nullptr, *audio_config_, latency_modes_);
+ return ndk::ScopedAStatus::ok();
+}
+
+} // namespace audio
+} // namespace bluetooth
+} // namespace hardware
+} // namespace android
+} // namespace aidl
diff --git a/bluetooth/audio/aidl/default/HfpOffloadAudioProvider.h b/bluetooth/audio/aidl/default/HfpOffloadAudioProvider.h
new file mode 100644
index 0000000..5526b46
--- /dev/null
+++ b/bluetooth/audio/aidl/default/HfpOffloadAudioProvider.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2023 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.
+ */
+
+#pragma once
+
+#include "BluetoothAudioProvider.h"
+
+namespace aidl {
+namespace android {
+namespace hardware {
+namespace bluetooth {
+namespace audio {
+
+class HfpOffloadAudioProvider : public BluetoothAudioProvider {
+ public:
+ HfpOffloadAudioProvider();
+
+ bool isValid(const SessionType& sessionType) override;
+
+ ndk::ScopedAStatus startSession(
+ const std::shared_ptr<IBluetoothAudioPort>& host_if,
+ const AudioConfiguration& audio_config,
+ const std::vector<LatencyMode>& latency_modes, DataMQDesc* _aidl_return);
+
+ private:
+ ndk::ScopedAStatus onSessionReady(DataMQDesc* _aidl_return) override;
+};
+
+} // namespace audio
+} // namespace bluetooth
+} // namespace hardware
+} // namespace android
+} // namespace aidl
diff --git a/bluetooth/audio/aidl/default/HfpSoftwareAudioProvider.cpp b/bluetooth/audio/aidl/default/HfpSoftwareAudioProvider.cpp
new file mode 100644
index 0000000..0f96046
--- /dev/null
+++ b/bluetooth/audio/aidl/default/HfpSoftwareAudioProvider.cpp
@@ -0,0 +1,140 @@
+/*
+ * Copyright (C) 2023 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 "BTAudioProviderHfpSW"
+
+#include "HfpSoftwareAudioProvider.h"
+
+#include <BluetoothAudioCodecs.h>
+#include <BluetoothAudioSessionReport.h>
+#include <android-base/logging.h>
+
+namespace aidl {
+namespace android {
+namespace hardware {
+namespace bluetooth {
+namespace audio {
+
+static constexpr uint32_t kBufferCount = 2; // two frame buffer
+
+HfpSoftwareOutputAudioProvider::HfpSoftwareOutputAudioProvider()
+ : HfpSoftwareAudioProvider() {
+ session_type_ = SessionType::HFP_SOFTWARE_ENCODING_DATAPATH;
+}
+
+HfpSoftwareInputAudioProvider::HfpSoftwareInputAudioProvider()
+ : HfpSoftwareAudioProvider() {
+ session_type_ = SessionType::HFP_SOFTWARE_DECODING_DATAPATH;
+}
+
+HfpSoftwareAudioProvider::HfpSoftwareAudioProvider()
+ : BluetoothAudioProvider(), data_mq_(nullptr) {
+}
+
+bool HfpSoftwareAudioProvider::isValid(const SessionType& sessionType) {
+ return (sessionType == session_type_);
+}
+
+ndk::ScopedAStatus HfpSoftwareAudioProvider::startSession(
+ const std::shared_ptr<IBluetoothAudioPort>& host_if,
+ const AudioConfiguration& audio_config,
+ const std::vector<LatencyMode>& latency_modes, DataMQDesc* _aidl_return) {
+ if (audio_config.getTag() != AudioConfiguration::pcmConfig) {
+ LOG(WARNING) << __func__ << " - Invalid Audio Configuration="
+ << audio_config.toString();
+ *_aidl_return = DataMQDesc();
+ return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
+ }
+ const PcmConfiguration& pcm_config =
+ audio_config.get<AudioConfiguration::pcmConfig>();
+ if (!BluetoothAudioCodecs::IsSoftwarePcmConfigurationValid(pcm_config)) {
+ LOG(WARNING) << __func__ << " - Unsupported PCM Configuration="
+ << pcm_config.toString();
+ *_aidl_return = DataMQDesc();
+ return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
+ }
+
+ bool isValidConfig = true;
+
+ if (pcm_config.bitsPerSample != 16) {
+ isValidConfig = false;
+ }
+
+ if (pcm_config.sampleRateHz != 8000 && pcm_config.sampleRateHz != 16000 &&
+ pcm_config.sampleRateHz != 32000) {
+ isValidConfig = false;
+ }
+
+ if (pcm_config.channelMode != ChannelMode::MONO) {
+ isValidConfig = false;
+ }
+
+ if (pcm_config.dataIntervalUs != 7500) {
+ isValidConfig = false;
+ }
+
+ int bytes_per_sample = pcm_config.bitsPerSample / 8;
+
+ uint32_t data_mq_size = kBufferCount * bytes_per_sample *
+ (pcm_config.sampleRateHz / 1000) *
+ pcm_config.dataIntervalUs / 1000;
+ if (!isValidConfig) {
+ LOG(ERROR) << __func__ << "Unexpected audio buffer size: " << data_mq_size
+ << ", SampleRateHz: " << pcm_config.sampleRateHz
+ << ", ChannelMode: " << toString(pcm_config.channelMode)
+ << ", BitsPerSample: "
+ << static_cast<int>(pcm_config.bitsPerSample)
+ << ", BytesPerSample: " << bytes_per_sample
+ << ", DataIntervalUs: " << pcm_config.dataIntervalUs
+ << ", SessionType: " << toString(session_type_);
+ return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
+ }
+
+ LOG(INFO) << __func__ << " - size of audio buffer " << data_mq_size
+ << " byte(s)";
+
+ std::unique_ptr<DataMQ> temp_data_mq(
+ new DataMQ(data_mq_size, /* EventFlag */ true));
+ if (temp_data_mq == nullptr || !temp_data_mq->isValid()) {
+ ALOGE_IF(!temp_data_mq, "failed to allocate data MQ");
+ ALOGE_IF(temp_data_mq && !temp_data_mq->isValid(), "data MQ is invalid");
+ *_aidl_return = DataMQDesc();
+ return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
+ }
+ data_mq_ = std::move(temp_data_mq);
+
+ return BluetoothAudioProvider::startSession(host_if, audio_config,
+ latency_modes, _aidl_return);
+}
+
+ndk::ScopedAStatus HfpSoftwareAudioProvider::onSessionReady(
+ DataMQDesc* _aidl_return) {
+ if (data_mq_ == nullptr || !data_mq_->isValid()) {
+ *_aidl_return = DataMQDesc();
+ return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
+ }
+ *_aidl_return = data_mq_->dupeDesc();
+ auto desc = data_mq_->dupeDesc();
+ BluetoothAudioSessionReport::OnSessionStarted(
+ session_type_, stack_iface_, &desc, *audio_config_, latency_modes_);
+ return ndk::ScopedAStatus::ok();
+}
+
+} // namespace audio
+} // namespace bluetooth
+} // namespace hardware
+} // namespace android
+} // namespace aidl
diff --git a/bluetooth/audio/aidl/default/HfpSoftwareAudioProvider.h b/bluetooth/audio/aidl/default/HfpSoftwareAudioProvider.h
new file mode 100644
index 0000000..ef51065
--- /dev/null
+++ b/bluetooth/audio/aidl/default/HfpSoftwareAudioProvider.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2023 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.
+ */
+
+#pragma once
+
+#include "BluetoothAudioProvider.h"
+
+namespace aidl {
+namespace android {
+namespace hardware {
+namespace bluetooth {
+namespace audio {
+
+class HfpSoftwareAudioProvider : public BluetoothAudioProvider {
+ public:
+ HfpSoftwareAudioProvider();
+
+ bool isValid(const SessionType& sessionType) override;
+
+ ndk::ScopedAStatus startSession(
+ const std::shared_ptr<IBluetoothAudioPort>& host_if,
+ const AudioConfiguration& audio_config,
+ const std::vector<LatencyMode>& latency_modes, DataMQDesc* _aidl_return);
+
+ private:
+ // audio data queue for software encoding
+ std::unique_ptr<DataMQ> data_mq_;
+
+ ndk::ScopedAStatus onSessionReady(DataMQDesc* _aidl_return) override;
+};
+
+class HfpSoftwareOutputAudioProvider : public HfpSoftwareAudioProvider {
+ public:
+ HfpSoftwareOutputAudioProvider();
+};
+
+class HfpSoftwareInputAudioProvider : public HfpSoftwareAudioProvider {
+ public:
+ HfpSoftwareInputAudioProvider();
+};
+
+} // namespace audio
+} // namespace bluetooth
+} // namespace hardware
+} // namespace android
+} // namespace aidl
diff --git a/bluetooth/audio/aidl/vts/VtsHalBluetoothAudioTargetTest.cpp b/bluetooth/audio/aidl/vts/VtsHalBluetoothAudioTargetTest.cpp
index 858fa38..c1a1b7a 100644
--- a/bluetooth/audio/aidl/vts/VtsHalBluetoothAudioTargetTest.cpp
+++ b/bluetooth/audio/aidl/vts/VtsHalBluetoothAudioTargetTest.cpp
@@ -46,7 +46,10 @@
using aidl::android::hardware::bluetooth::audio::ChannelMode;
using aidl::android::hardware::bluetooth::audio::CodecCapabilities;
using aidl::android::hardware::bluetooth::audio::CodecConfiguration;
+using aidl::android::hardware::bluetooth::audio::CodecId;
+using aidl::android::hardware::bluetooth::audio::CodecInfo;
using aidl::android::hardware::bluetooth::audio::CodecType;
+using aidl::android::hardware::bluetooth::audio::HfpConfiguration;
using aidl::android::hardware::bluetooth::audio::IBluetoothAudioPort;
using aidl::android::hardware::bluetooth::audio::IBluetoothAudioProvider;
using aidl::android::hardware::bluetooth::audio::IBluetoothAudioProviderFactory;
@@ -90,6 +93,13 @@
static constexpr ChannelMode a2dp_channel_modes[] = {
ChannelMode::UNKNOWN, ChannelMode::MONO, ChannelMode::STEREO};
static std::vector<LatencyMode> latency_modes = {LatencyMode::FREE};
+
+// Some valid configs for HFP PCM configuration (software sessions)
+static constexpr int32_t hfp_sample_rates_[] = {8000, 16000, 32000};
+static constexpr int8_t hfp_bits_per_samples_[] = {16};
+static constexpr ChannelMode hfp_channel_modes_[] = {ChannelMode::MONO};
+static constexpr int32_t hfp_data_interval_us_[] = {7500};
+
// Helpers
template <typename T>
@@ -195,7 +205,8 @@
case SessionType::HEARING_AID_SOFTWARE_ENCODING_DATAPATH:
case SessionType::LE_AUDIO_SOFTWARE_ENCODING_DATAPATH:
case SessionType::LE_AUDIO_SOFTWARE_DECODING_DATAPATH:
- case SessionType::LE_AUDIO_BROADCAST_SOFTWARE_ENCODING_DATAPATH: {
+ case SessionType::LE_AUDIO_BROADCAST_SOFTWARE_ENCODING_DATAPATH:
+ case SessionType::HFP_SOFTWARE_ENCODING_DATAPATH: {
// All software paths are mandatory and must have exact 1
// "PcmParameters"
ASSERT_EQ(temp_provider_capabilities_.size(), 1);
@@ -256,7 +267,8 @@
AudioCapabilities::leAudioCapabilities);
}
} break;
- case SessionType::A2DP_SOFTWARE_DECODING_DATAPATH: {
+ case SessionType::A2DP_SOFTWARE_DECODING_DATAPATH:
+ case SessionType::HFP_SOFTWARE_DECODING_DATAPATH: {
if (!temp_provider_capabilities_.empty()) {
ASSERT_EQ(temp_provider_capabilities_.size(), 1);
ASSERT_EQ(temp_provider_capabilities_[0].getTag(),
@@ -296,7 +308,10 @@
LE_AUDIO_BROADCAST_HARDWARE_OFFLOAD_ENCODING_DATAPATH ||
session_type ==
SessionType::A2DP_HARDWARE_OFFLOAD_DECODING_DATAPATH ||
- session_type == SessionType::A2DP_SOFTWARE_DECODING_DATAPATH);
+ session_type == SessionType::A2DP_SOFTWARE_DECODING_DATAPATH ||
+ session_type == SessionType::HFP_HARDWARE_OFFLOAD_DATAPATH ||
+ session_type == SessionType::HFP_SOFTWARE_DECODING_DATAPATH ||
+ session_type == SessionType::HFP_SOFTWARE_ENCODING_DATAPATH);
ASSERT_EQ(audio_provider_, nullptr);
}
}
@@ -573,6 +588,8 @@
SessionType::LE_AUDIO_BROADCAST_HARDWARE_OFFLOAD_ENCODING_DATAPATH,
SessionType::A2DP_SOFTWARE_DECODING_DATAPATH,
SessionType::A2DP_HARDWARE_OFFLOAD_DECODING_DATAPATH,
+ SessionType::HFP_SOFTWARE_ENCODING_DATAPATH,
+ SessionType::HFP_SOFTWARE_DECODING_DATAPATH,
};
};
@@ -598,6 +615,99 @@
}
/**
+ * Test that getProviderInfo, when implemented,
+ * returns empty information for session types for
+ * software data paths.
+ */
+TEST_P(BluetoothAudioProviderFactoryAidl, getProviderInfo_invalidSessionTypes) {
+ static constexpr SessionType kInvalidSessionTypes[]{
+ SessionType::UNKNOWN,
+ SessionType::A2DP_SOFTWARE_ENCODING_DATAPATH,
+ SessionType::HEARING_AID_SOFTWARE_ENCODING_DATAPATH,
+ SessionType::LE_AUDIO_SOFTWARE_ENCODING_DATAPATH,
+ SessionType::LE_AUDIO_SOFTWARE_DECODING_DATAPATH,
+ SessionType::LE_AUDIO_BROADCAST_SOFTWARE_ENCODING_DATAPATH,
+ SessionType::A2DP_SOFTWARE_DECODING_DATAPATH,
+ };
+
+ for (auto session_type : kInvalidSessionTypes) {
+ std::optional<IBluetoothAudioProviderFactory::ProviderInfo> provider_info =
+ std::nullopt;
+ auto aidl_retval =
+ provider_factory_->getProviderInfo(session_type, &provider_info);
+ if (!aidl_retval.isOk()) {
+ continue;
+ }
+
+ // If getProviderInfo is supported, the provider info
+ // must be empty for software session types.
+ ASSERT_FALSE(provider_info.has_value());
+ }
+}
+
+/**
+ * Test that getProviderInfo, when implemented,
+ * returns valid information for session types for
+ * a2dp hardware data paths.
+ */
+TEST_P(BluetoothAudioProviderFactoryAidl, getProviderInfo_a2dpSessionTypes) {
+ static constexpr SessionType kA2dpSessionTypes[]{
+ SessionType::A2DP_HARDWARE_OFFLOAD_ENCODING_DATAPATH,
+ SessionType::A2DP_HARDWARE_OFFLOAD_DECODING_DATAPATH,
+ };
+
+ for (auto session_type : kA2dpSessionTypes) {
+ std::optional<IBluetoothAudioProviderFactory::ProviderInfo> provider_info =
+ std::nullopt;
+ auto aidl_retval =
+ provider_factory_->getProviderInfo(session_type, &provider_info);
+ if (!aidl_retval.isOk() || !provider_info.has_value()) {
+ continue;
+ }
+
+ for (auto const& codec_info : provider_info->codecInfos) {
+ // The codec id must not be core.
+ ASSERT_NE(codec_info.id.getTag(), CodecId::core);
+ // The codec info must contain the information
+ // for a2dp transport.
+ ASSERT_EQ(codec_info.transport.getTag(), CodecInfo::Transport::a2dp);
+ }
+ }
+}
+
+/**
+ * Test that getProviderInfo, when implemented,
+ * returns valid information for session types for
+ * le audio hardware data paths.
+ */
+TEST_P(BluetoothAudioProviderFactoryAidl, getProviderInfo_leAudioSessionTypes) {
+ static constexpr SessionType kLeAudioSessionTypes[]{
+ SessionType::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH,
+ SessionType::LE_AUDIO_HARDWARE_OFFLOAD_DECODING_DATAPATH,
+ SessionType::LE_AUDIO_BROADCAST_HARDWARE_OFFLOAD_ENCODING_DATAPATH,
+ };
+
+ for (auto session_type : kLeAudioSessionTypes) {
+ std::optional<IBluetoothAudioProviderFactory::ProviderInfo> provider_info =
+ std::nullopt;
+ auto aidl_retval =
+ provider_factory_->getProviderInfo(session_type, &provider_info);
+ if (!aidl_retval.isOk() || !provider_info.has_value()) {
+ continue;
+ }
+
+ for (auto const& codec_info : provider_info->codecInfos) {
+ // The codec id must not be a2dp.
+ ASSERT_NE(codec_info.id.getTag(), CodecId::a2dp);
+ // The codec info must contain the information
+ // for le audio transport.
+ // ASSERT_EQ(codec_info.transport.getTag(),
+ // CodecInfo::Transport::le_audio);
+ }
+ }
+}
+
+/**
* openProvider A2DP_SOFTWARE_ENCODING_DATAPATH
*/
class BluetoothAudioProviderA2dpEncodingSoftwareAidl
@@ -656,6 +766,137 @@
}
/**
+ * openProvider HFP_SOFTWARE_ENCODING_DATAPATH
+ */
+class BluetoothAudioProviderHfpSoftwareEncodingAidl
+ : public BluetoothAudioProviderFactoryAidl {
+ public:
+ virtual void SetUp() override {
+ BluetoothAudioProviderFactoryAidl::SetUp();
+ GetProviderCapabilitiesHelper(SessionType::HFP_SOFTWARE_ENCODING_DATAPATH);
+ OpenProviderHelper(SessionType::HFP_SOFTWARE_ENCODING_DATAPATH);
+ ASSERT_NE(audio_provider_, nullptr);
+ }
+
+ virtual void TearDown() override {
+ audio_port_ = nullptr;
+ audio_provider_ = nullptr;
+ BluetoothAudioProviderFactoryAidl::TearDown();
+ }
+
+ bool OpenSession(int32_t sample_rate, int8_t bits_per_sample,
+ ChannelMode channel_mode, int32_t data_interval_us) {
+ PcmConfiguration pcm_config{
+ .sampleRateHz = sample_rate,
+ .channelMode = channel_mode,
+ .bitsPerSample = bits_per_sample,
+ .dataIntervalUs = data_interval_us,
+ };
+ // Checking against provider capability from getProviderCapabilities
+ // For HFP software, it's
+ // BluetoothAudioCodecs::GetSoftwarePcmCapabilities();
+ DataMQDesc mq_desc;
+ auto aidl_retval = audio_provider_->startSession(
+ audio_port_, AudioConfiguration(pcm_config), latency_modes, &mq_desc);
+ DataMQ data_mq(mq_desc);
+
+ if (!aidl_retval.isOk()) return false;
+ if (!data_mq.isValid()) return false;
+ return true;
+ }
+};
+
+/**
+ * Test whether we can open a provider of type
+ */
+TEST_P(BluetoothAudioProviderHfpSoftwareEncodingAidl,
+ OpenHfpSoftwareEncodingProvider) {}
+
+/**
+ * Test whether each provider of type
+ * SessionType::HFP_SOFTWARE_ENCODING_DATAPATH can be started and stopped with
+ * different PCM config
+ */
+TEST_P(BluetoothAudioProviderHfpSoftwareEncodingAidl,
+ StartAndEndHfpEncodingSoftwareSessionWithPossiblePcmConfig) {
+ for (auto sample_rate : hfp_sample_rates_) {
+ for (auto bits_per_sample : hfp_bits_per_samples_) {
+ for (auto channel_mode : hfp_channel_modes_) {
+ for (auto data_interval_us: hfp_data_interval_us_) {
+ EXPECT_TRUE(OpenSession(sample_rate, bits_per_sample,
+ channel_mode, data_interval_us));
+ EXPECT_TRUE(audio_provider_->endSession().isOk());
+ }
+ }
+ }
+ }
+}
+
+/**
+ * openProvider HFP_SOFTWARE_DECODING_DATAPATH
+ */
+class BluetoothAudioProviderHfpSoftwareDecodingAidl
+ : public BluetoothAudioProviderFactoryAidl {
+ public:
+ virtual void SetUp() override {
+ BluetoothAudioProviderFactoryAidl::SetUp();
+ GetProviderCapabilitiesHelper(SessionType::HFP_SOFTWARE_DECODING_DATAPATH);
+ OpenProviderHelper(SessionType::HFP_SOFTWARE_DECODING_DATAPATH);
+ ASSERT_NE(audio_provider_, nullptr);
+ }
+
+ virtual void TearDown() override {
+ audio_port_ = nullptr;
+ audio_provider_ = nullptr;
+ BluetoothAudioProviderFactoryAidl::TearDown();
+ }
+
+ bool OpenSession(int32_t sample_rate, int8_t bits_per_sample,
+ ChannelMode channel_mode, int32_t data_interval_us) {
+ PcmConfiguration pcm_config{
+ .sampleRateHz = sample_rate,
+ .channelMode = channel_mode,
+ .bitsPerSample = bits_per_sample,
+ .dataIntervalUs = data_interval_us,
+ };
+ DataMQDesc mq_desc;
+ auto aidl_retval = audio_provider_->startSession(
+ audio_port_, AudioConfiguration(pcm_config), latency_modes, &mq_desc);
+ DataMQ data_mq(mq_desc);
+
+ if (!aidl_retval.isOk()) return false;
+ if (!data_mq.isValid()) return false;
+ return true;
+ }
+};
+
+/**
+ * Test whether we can open a provider of type
+ */
+TEST_P(BluetoothAudioProviderHfpSoftwareDecodingAidl,
+ OpenHfpSoftwareDecodingProvider) {}
+
+/**
+ * Test whether each provider of type
+ * SessionType::HFP_SOFTWARE_DECODING_DATAPATH can be started and stopped with
+ * different PCM config
+ */
+TEST_P(BluetoothAudioProviderHfpSoftwareDecodingAidl,
+ StartAndEndHfpDecodingSoftwareSessionWithPossiblePcmConfig) {
+ for (auto sample_rate : hfp_sample_rates_) {
+ for (auto bits_per_sample : hfp_bits_per_samples_) {
+ for (auto channel_mode : hfp_channel_modes_) {
+ for (auto data_interval_us: hfp_data_interval_us_) {
+ EXPECT_TRUE(OpenSession(sample_rate, bits_per_sample,
+ channel_mode, data_interval_us));
+ EXPECT_TRUE(audio_provider_->endSession().isOk());
+ }
+ }
+ }
+ }
+}
+
+/**
* openProvider A2DP_HARDWARE_OFFLOAD_ENCODING_DATAPATH
*/
class BluetoothAudioProviderA2dpEncodingHardwareAidl
@@ -908,6 +1149,62 @@
}
/**
+ * openProvider HFP_HARDWARE_OFFLOAD_DATAPATH
+ */
+class BluetoothAudioProviderHfpHardwareAidl
+ : public BluetoothAudioProviderFactoryAidl {
+ public:
+ virtual void SetUp() override {
+ BluetoothAudioProviderFactoryAidl::SetUp();
+ OpenProviderHelper(SessionType::HFP_HARDWARE_OFFLOAD_DATAPATH);
+ // Can open or empty capability
+ ASSERT_TRUE(temp_provider_capabilities_.empty() ||
+ audio_provider_ != nullptr);
+ }
+
+ virtual void TearDown() override {
+ audio_port_ = nullptr;
+ audio_provider_ = nullptr;
+ BluetoothAudioProviderFactoryAidl::TearDown();
+ }
+
+ bool OpenSession(CodecId codec_id, int connection_handle, bool nrec,
+ bool controller_codec) {
+ // Check if can open session with a Hfp configuration
+ HfpConfiguration hfp_configuration{
+ .codecId = codec_id,
+ .connectionHandle = connection_handle,
+ .nrec = nrec,
+ .controllerCodec = controller_codec,
+ };
+ DataMQDesc mq_desc;
+ auto aidl_retval = audio_provider_->startSession(
+ audio_port_, AudioConfiguration(hfp_configuration), latency_modes,
+ &mq_desc);
+
+ // Only check if aidl is ok to start session.
+ return aidl_retval.isOk();
+ }
+};
+
+/**
+ * Test whether we can open a provider of type
+ */
+TEST_P(BluetoothAudioProviderHfpHardwareAidl, OpenHfpHardwareProvider) {}
+
+/**
+ * Test whether each provider of type
+ * SessionType::HFP_SOFTWARE_DECODING_DATAPATH can be started and stopped with
+ * different HFP config
+ */
+TEST_P(BluetoothAudioProviderHfpHardwareAidl,
+ StartAndEndHfpHardwareSessionWithPossiblePcmConfig) {
+ // Try to open with a sample configuration
+ EXPECT_TRUE(OpenSession(CodecId::Core::CVSD, 6, false, true));
+ EXPECT_TRUE(audio_provider_->endSession().isOk());
+}
+
+/**
* openProvider HEARING_AID_SOFTWARE_ENCODING_DATAPATH
*/
class BluetoothAudioProviderHearingAidSoftwareAidl
@@ -2184,6 +2481,29 @@
IBluetoothAudioProviderFactory::descriptor)),
android::PrintInstanceNameToString);
+GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(
+ BluetoothAudioProviderHfpHardwareAidl);
+INSTANTIATE_TEST_SUITE_P(PerInstance, BluetoothAudioProviderHfpHardwareAidl,
+ testing::ValuesIn(android::getAidlHalInstanceNames(
+ IBluetoothAudioProviderFactory::descriptor)),
+ android::PrintInstanceNameToString);
+
+GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(
+ BluetoothAudioProviderHfpSoftwareDecodingAidl);
+INSTANTIATE_TEST_SUITE_P(PerInstance,
+ BluetoothAudioProviderHfpSoftwareDecodingAidl,
+ testing::ValuesIn(android::getAidlHalInstanceNames(
+ IBluetoothAudioProviderFactory::descriptor)),
+ android::PrintInstanceNameToString);
+
+GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(
+ BluetoothAudioProviderHfpSoftwareEncodingAidl);
+INSTANTIATE_TEST_SUITE_P(PerInstance,
+ BluetoothAudioProviderHfpSoftwareEncodingAidl,
+ testing::ValuesIn(android::getAidlHalInstanceNames(
+ IBluetoothAudioProviderFactory::descriptor)),
+ android::PrintInstanceNameToString);
+
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
ABinderProcess_setThreadPoolMaxThreadCount(1);
diff --git a/bluetooth/audio/utils/Android.bp b/bluetooth/audio/utils/Android.bp
index 75081d6..e7659a4 100644
--- a/bluetooth/audio/utils/Android.bp
+++ b/bluetooth/audio/utils/Android.bp
@@ -78,7 +78,7 @@
shared_libs: [
"libbase",
"libbinder_ndk",
- "android.hardware.bluetooth.audio-V3-ndk",
+ "android.hardware.bluetooth.audio-V4-ndk",
"libxml2",
],
test_suites: [
diff --git a/bluetooth/audio/utils/aidl_session/BluetoothAudioCodecs.cpp b/bluetooth/audio/utils/aidl_session/BluetoothAudioCodecs.cpp
index b4cba49..6e15b3b 100644
--- a/bluetooth/audio/utils/aidl_session/BluetoothAudioCodecs.cpp
+++ b/bluetooth/audio/utils/aidl_session/BluetoothAudioCodecs.cpp
@@ -41,7 +41,7 @@
namespace audio {
static const PcmCapabilities kDefaultSoftwarePcmCapabilities = {
- .sampleRateHz = {16000, 24000, 32000, 44100, 48000, 88200, 96000},
+ .sampleRateHz = {8000, 16000, 24000, 32000, 44100, 48000, 88200, 96000},
.channelMode = {ChannelMode::MONO, ChannelMode::STEREO},
.bitsPerSample = {16, 24, 32},
.dataIntervalUs = {},
diff --git a/bluetooth/audio/utils/aidl_session/BluetoothAudioSession.cpp b/bluetooth/audio/utils/aidl_session/BluetoothAudioSession.cpp
index c283148..9dcfc13 100644
--- a/bluetooth/audio/utils/aidl_session/BluetoothAudioSession.cpp
+++ b/bluetooth/audio/utils/aidl_session/BluetoothAudioSession.cpp
@@ -95,6 +95,8 @@
case SessionType::A2DP_HARDWARE_OFFLOAD_ENCODING_DATAPATH:
case SessionType::A2DP_HARDWARE_OFFLOAD_DECODING_DATAPATH:
return AudioConfiguration(CodecConfiguration{});
+ case SessionType::HFP_HARDWARE_OFFLOAD_DATAPATH:
+ return AudioConfiguration(HfpConfiguration{});
case SessionType::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH:
case SessionType::LE_AUDIO_HARDWARE_OFFLOAD_DECODING_DATAPATH:
return AudioConfiguration(LeAudioConfiguration{});
@@ -154,6 +156,7 @@
session_type_ ==
SessionType::LE_AUDIO_BROADCAST_HARDWARE_OFFLOAD_ENCODING_DATAPATH ||
session_type_ == SessionType::A2DP_HARDWARE_OFFLOAD_DECODING_DATAPATH ||
+ session_type_ == SessionType::HFP_HARDWARE_OFFLOAD_DATAPATH ||
(data_mq_ != nullptr && data_mq_->isValid()));
return stack_iface_ != nullptr && is_mq_valid && audio_config_ != nullptr;
}
@@ -275,6 +278,8 @@
bool is_software_session =
(session_type_ == SessionType::A2DP_SOFTWARE_ENCODING_DATAPATH ||
session_type_ == SessionType::HEARING_AID_SOFTWARE_ENCODING_DATAPATH ||
+ session_type_ == SessionType::HFP_SOFTWARE_ENCODING_DATAPATH ||
+ session_type_ == SessionType::HFP_SOFTWARE_DECODING_DATAPATH ||
session_type_ == SessionType::LE_AUDIO_SOFTWARE_DECODING_DATAPATH ||
session_type_ == SessionType::LE_AUDIO_SOFTWARE_ENCODING_DATAPATH ||
session_type_ ==
@@ -283,6 +288,8 @@
bool is_offload_a2dp_session =
(session_type_ == SessionType::A2DP_HARDWARE_OFFLOAD_ENCODING_DATAPATH ||
session_type_ == SessionType::A2DP_HARDWARE_OFFLOAD_DECODING_DATAPATH);
+ bool is_offload_hfp_session =
+ session_type_ == SessionType::HFP_HARDWARE_OFFLOAD_DATAPATH;
bool is_offload_le_audio_unicast_session =
(session_type_ ==
SessionType::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH ||
@@ -298,6 +305,9 @@
bool is_a2dp_offload_audio_config =
(is_offload_a2dp_session &&
audio_config_tag == AudioConfiguration::a2dpConfig);
+ bool is_hfp_offload_audio_config =
+ (is_offload_hfp_session &&
+ audio_config_tag == AudioConfiguration::hfpConfig);
bool is_le_audio_offload_unicast_audio_config =
(is_offload_le_audio_unicast_session &&
audio_config_tag == AudioConfiguration::leAudioConfig);
@@ -305,6 +315,7 @@
(is_offload_le_audio_broadcast_session &&
audio_config_tag == AudioConfiguration::leAudioBroadcastConfig);
if (!is_software_audio_config && !is_a2dp_offload_audio_config &&
+ !is_hfp_offload_audio_config &&
!is_le_audio_offload_unicast_audio_config &&
!is_le_audio_offload_broadcast_audio_config) {
return false;
diff --git a/bluetooth/audio/utils/aidl_session/BluetoothAudioSessionControl.h b/bluetooth/audio/utils/aidl_session/BluetoothAudioSessionControl.h
index 7ae0353..5263222 100644
--- a/bluetooth/audio/utils/aidl_session/BluetoothAudioSessionControl.h
+++ b/bluetooth/audio/utils/aidl_session/BluetoothAudioSessionControl.h
@@ -84,6 +84,8 @@
case SessionType::A2DP_HARDWARE_OFFLOAD_ENCODING_DATAPATH:
case SessionType::A2DP_HARDWARE_OFFLOAD_DECODING_DATAPATH:
return AudioConfiguration(CodecConfiguration{});
+ case SessionType::HFP_HARDWARE_OFFLOAD_DATAPATH:
+ return AudioConfiguration(HfpConfiguration{});
case SessionType::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH:
case SessionType::LE_AUDIO_HARDWARE_OFFLOAD_DECODING_DATAPATH:
return AudioConfiguration(LeAudioConfiguration{});
diff --git a/bluetooth/audio/utils/aidl_session/HidlToAidlMiddleware.cpp b/bluetooth/audio/utils/aidl_session/HidlToAidlMiddleware.cpp
index 3d92ee7..a2a5bcb 100644
--- a/bluetooth/audio/utils/aidl_session/HidlToAidlMiddleware.cpp
+++ b/bluetooth/audio/utils/aidl_session/HidlToAidlMiddleware.cpp
@@ -475,6 +475,8 @@
hidl_audio_config.leAudioCodecConfig(to_hidl_leaudio_broadcast_config_2_1(
audio_config.get<AudioConfiguration::leAudioBroadcastConfig>()));
break;
+ default:
+ LOG(FATAL) << __func__ << ": unexpected AudioConfiguration";
}
return hidl_audio_config;
}
diff --git a/bluetooth/finder/aidl/Android.bp b/bluetooth/finder/aidl/Android.bp
new file mode 100644
index 0000000..e606d2d
--- /dev/null
+++ b/bluetooth/finder/aidl/Android.bp
@@ -0,0 +1,34 @@
+// Copyright (C) 2023 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 {
+ default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
+aidl_interface {
+ name: "android.hardware.bluetooth.finder",
+ vendor_available: true,
+ srcs: ["android/hardware/bluetooth/finder/*.aidl"],
+ stability: "vintf",
+
+ backend: {
+ ndk: {
+ enabled: true,
+ },
+ java: {
+ enabled: true,
+ platform_apis: true,
+ },
+ },
+}
diff --git a/bluetooth/finder/aidl/aidl_api/android.hardware.bluetooth.finder/current/android/hardware/bluetooth/finder/Eid.aidl b/bluetooth/finder/aidl/aidl_api/android.hardware.bluetooth.finder/current/android/hardware/bluetooth/finder/Eid.aidl
new file mode 100644
index 0000000..42461c5
--- /dev/null
+++ b/bluetooth/finder/aidl/aidl_api/android.hardware.bluetooth.finder/current/android/hardware/bluetooth/finder/Eid.aidl
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2023 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.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+// the interface (from the latest frozen version), the build system will
+// prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.hardware.bluetooth.finder;
+@VintfStability
+parcelable Eid {
+ byte[20] bytes;
+}
diff --git a/bluetooth/finder/aidl/aidl_api/android.hardware.bluetooth.finder/current/android/hardware/bluetooth/finder/IBluetoothFinder.aidl b/bluetooth/finder/aidl/aidl_api/android.hardware.bluetooth.finder/current/android/hardware/bluetooth/finder/IBluetoothFinder.aidl
new file mode 100644
index 0000000..4bc9041
--- /dev/null
+++ b/bluetooth/finder/aidl/aidl_api/android.hardware.bluetooth.finder/current/android/hardware/bluetooth/finder/IBluetoothFinder.aidl
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2023 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.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+// the interface (from the latest frozen version), the build system will
+// prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.hardware.bluetooth.finder;
+@VintfStability
+interface IBluetoothFinder {
+ void sendEids(in android.hardware.bluetooth.finder.Eid[] eids);
+ void setPoweredOffFinderMode(in boolean enable);
+ boolean getPoweredOffFinderMode();
+}
diff --git a/bluetooth/finder/aidl/android/hardware/bluetooth/finder/Eid.aidl b/bluetooth/finder/aidl/android/hardware/bluetooth/finder/Eid.aidl
new file mode 100644
index 0000000..ae9b159
--- /dev/null
+++ b/bluetooth/finder/aidl/android/hardware/bluetooth/finder/Eid.aidl
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2023 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.bluetooth.finder;
+
+/**
+ * Ephemeral Identifier
+ */
+@VintfStability
+parcelable Eid {
+ byte[20] bytes;
+}
diff --git a/bluetooth/finder/aidl/android/hardware/bluetooth/finder/IBluetoothFinder.aidl b/bluetooth/finder/aidl/android/hardware/bluetooth/finder/IBluetoothFinder.aidl
new file mode 100644
index 0000000..615739b
--- /dev/null
+++ b/bluetooth/finder/aidl/android/hardware/bluetooth/finder/IBluetoothFinder.aidl
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2023 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.bluetooth.finder;
+
+import android.hardware.bluetooth.finder.Eid;
+
+@VintfStability
+interface IBluetoothFinder {
+ /**
+ * API to set the EIDs to the Bluetooth Controller
+ *
+ * @param eids array of 20 bytes EID to the Bluetooth
+ * controller
+ */
+ void sendEids(in Eid[] eids);
+
+ /**
+ * API to enable the powered-off finder feature, which allows the Bluetooth controller to send
+ * beacons after the device is powered off.
+ *
+ * @param enable true to enable; false to disable
+ */
+ void setPoweredOffFinderMode(in boolean enable);
+
+ /**
+ * API for retrieving feature enablement status
+ *
+ * @return the value last set by setPoweredOffFinderMode, false if setPoweredOffFinderMode was
+ * never been invoked since boot.
+ */
+ boolean getPoweredOffFinderMode();
+}
diff --git a/bluetooth/finder/aidl/default/Android.bp b/bluetooth/finder/aidl/default/Android.bp
new file mode 100644
index 0000000..b364ae1
--- /dev/null
+++ b/bluetooth/finder/aidl/default/Android.bp
@@ -0,0 +1,42 @@
+// Copyright (C) 2023 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 {
+ default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
+cc_binary {
+ name: "android.hardware.bluetooth.finder-service.default",
+ relative_install_path: "hw",
+ init_rc: ["bluetooth-finder-service-default.rc"],
+ vintf_fragments: [":manifest_android.hardware.bluetooth.finder-service.default.xml"],
+ vendor: true,
+ srcs: [
+ "BluetoothFinder.cpp",
+ "service.cpp",
+ ],
+ shared_libs: [
+ "android.hardware.bluetooth.finder-V1-ndk",
+ "libbase",
+ "libbinder_ndk",
+ "libhidlbase",
+ "libutils",
+ "liblog",
+ ],
+}
+
+filegroup {
+ name: "manifest_android.hardware.bluetooth.finder-service.default.xml",
+ srcs: ["bluetooth-finder-service-default.xml"],
+}
diff --git a/bluetooth/finder/aidl/default/BluetoothFinder.cpp b/bluetooth/finder/aidl/default/BluetoothFinder.cpp
new file mode 100644
index 0000000..236a1f8
--- /dev/null
+++ b/bluetooth/finder/aidl/default/BluetoothFinder.cpp
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2023 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 "BluetoothFinder.h"
+
+namespace aidl::android::hardware::bluetooth::finder::impl {
+
+::ndk::ScopedAStatus BluetoothFinder::sendEids(const ::std::vector<Eid>& keys) {
+ keys_.insert(keys_.end(), keys.begin(), keys.end());
+ return ::ndk::ScopedAStatus::ok();
+}
+
+::ndk::ScopedAStatus BluetoothFinder::setPoweredOffFinderMode(bool enable) {
+ pof_enabled_ = enable;
+ return ::ndk::ScopedAStatus::ok();
+}
+
+::ndk::ScopedAStatus BluetoothFinder::getPoweredOffFinderMode(
+ bool* _aidl_return) {
+ *_aidl_return = pof_enabled_;
+ return ::ndk::ScopedAStatus::ok();
+}
+
+} // namespace aidl::android::hardware::bluetooth::finder::impl
diff --git a/bluetooth/finder/aidl/default/BluetoothFinder.h b/bluetooth/finder/aidl/default/BluetoothFinder.h
new file mode 100644
index 0000000..16110f6
--- /dev/null
+++ b/bluetooth/finder/aidl/default/BluetoothFinder.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2023 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 <aidl/android/hardware/bluetooth/finder/BnBluetoothFinder.h>
+
+#include <vector>
+
+namespace aidl::android::hardware::bluetooth::finder::impl {
+
+using ::aidl::android::hardware::bluetooth::finder::BnBluetoothFinder;
+using ::aidl::android::hardware::bluetooth::finder::Eid;
+
+class BluetoothFinder : public BnBluetoothFinder {
+ public:
+ BluetoothFinder() = default;
+
+ ::ndk::ScopedAStatus sendEids(const ::std::vector<Eid>& keys) override;
+ ::ndk::ScopedAStatus setPoweredOffFinderMode(bool enable) override;
+ ::ndk::ScopedAStatus getPoweredOffFinderMode(bool* _aidl_return) override;
+
+ private:
+ bool pof_enabled_;
+ std::vector<Eid> keys_;
+};
+
+} // namespace aidl::android::hardware::bluetooth::finder::impl
diff --git a/bluetooth/finder/aidl/default/bluetooth-finder-service-default.rc b/bluetooth/finder/aidl/default/bluetooth-finder-service-default.rc
new file mode 100644
index 0000000..64bbf09
--- /dev/null
+++ b/bluetooth/finder/aidl/default/bluetooth-finder-service-default.rc
@@ -0,0 +1,6 @@
+service vendor.bluetooth.finder-default /vendor/bin/hw/android.hardware.bluetooth.finder-service.default
+ class hal
+ capabilities BLOCK_SUSPEND NET_ADMIN SYS_NICE
+ user bluetooth
+ group bluetooth
+ task_profiles ServicePerformance
diff --git a/bluetooth/finder/aidl/default/bluetooth-finder-service-default.xml b/bluetooth/finder/aidl/default/bluetooth-finder-service-default.xml
new file mode 100644
index 0000000..be7c00d
--- /dev/null
+++ b/bluetooth/finder/aidl/default/bluetooth-finder-service-default.xml
@@ -0,0 +1,7 @@
+<manifest version="1.0" type="device">
+ <hal format="aidl">
+ <name>android.hardware.bluetooth.finder</name>
+ <version>1</version>
+ <fqname>IBluetoothFinder/default</fqname>
+ </hal>
+</manifest>
diff --git a/bluetooth/finder/aidl/default/service.cpp b/bluetooth/finder/aidl/default/service.cpp
new file mode 100644
index 0000000..a117df8
--- /dev/null
+++ b/bluetooth/finder/aidl/default/service.cpp
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2023 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 "aidl.android.hardware.bluetooth.finder.default"
+
+#include <android/binder_manager.h>
+#include <android/binder_process.h>
+#include <utils/Log.h>
+
+#include "BluetoothFinder.h"
+
+using ::aidl::android::hardware::bluetooth::finder::impl::BluetoothFinder;
+
+int main(int /* argc */, char** /* argv */) {
+ ALOGI("Bluetooth Finder HAL registering");
+ if (!ABinderProcess_setThreadPoolMaxThreadCount(0)) {
+ ALOGE("failed to set thread pool max thread count");
+ return 1;
+ }
+
+ std::shared_ptr<BluetoothFinder> service =
+ ndk::SharedRefBase::make<BluetoothFinder>();
+ std::string instance =
+ std::string() + BluetoothFinder::descriptor + "/default";
+ auto result =
+ AServiceManager_addService(service->asBinder().get(), instance.c_str());
+ if (result == STATUS_OK) {
+ ABinderProcess_joinThreadPool();
+ } else {
+ ALOGE("Could not register as a service!");
+ }
+ return 0;
+}
diff --git a/bluetooth/finder/aidl/vts/Android.bp b/bluetooth/finder/aidl/vts/Android.bp
new file mode 100644
index 0000000..6b0285e
--- /dev/null
+++ b/bluetooth/finder/aidl/vts/Android.bp
@@ -0,0 +1,41 @@
+// Copyright (C) 2023 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 {
+ default_applicable_licenses: ["hardware_interfaces_license"],
+}
+
+cc_test {
+ name: "VtsHalBluetoothFinderTargetTest",
+ defaults: [
+ "use_libaidlvintf_gtest_helper_static",
+ ],
+ srcs: ["VtsHalBluetoothFinderTargetTest.cpp"],
+ shared_libs: [
+ "libbase",
+ "libcutils",
+ "libbinder_ndk",
+ "liblog",
+ "libutils",
+ ],
+ static_libs: [
+ "android.hardware.bluetooth.finder-V1-ndk",
+ "libbluetooth-types",
+ ],
+ test_config: "VtsHalBluetoothFinderTargetTest.xml",
+ test_suites: [
+ "general-tests",
+ "vts",
+ ],
+}
diff --git a/bluetooth/finder/aidl/vts/VtsHalBluetoothFinderTargetTest.cpp b/bluetooth/finder/aidl/vts/VtsHalBluetoothFinderTargetTest.cpp
new file mode 100644
index 0000000..be07a7d
--- /dev/null
+++ b/bluetooth/finder/aidl/vts/VtsHalBluetoothFinderTargetTest.cpp
@@ -0,0 +1,114 @@
+/*
+ * Copyright (C) 2023 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 <aidl/Gtest.h>
+#include <aidl/Vintf.h>
+#include <aidl/android/hardware/bluetooth/finder/IBluetoothFinder.h>
+#include <android-base/logging.h>
+#include <android/binder_manager.h>
+#include <android/binder_process.h>
+#include <binder/IServiceManager.h>
+#include <utils/Log.h>
+
+#include <array>
+#include <vector>
+
+using ::aidl::android::hardware::bluetooth::finder::Eid;
+using ::aidl::android::hardware::bluetooth::finder::IBluetoothFinder;
+using ::ndk::ScopedAStatus;
+
+class BluetoothFinderTest : public ::testing::TestWithParam<std::string> {
+ public:
+ virtual void SetUp() override {
+ ALOGI("SetUp Finder Test");
+ bluetooth_finder = IBluetoothFinder::fromBinder(
+ ndk::SpAIBinder(AServiceManager_waitForService(GetParam().c_str())));
+ ASSERT_NE(bluetooth_finder, nullptr);
+ }
+
+ virtual void TearDown() override {
+ ALOGI("TearDown Finder Test");
+ bluetooth_finder = nullptr;
+ ASSERT_EQ(bluetooth_finder, nullptr);
+ }
+
+ ScopedAStatus sendEids(uint8_t num);
+ ScopedAStatus setPoweredOffFinderMode(bool enable);
+ ScopedAStatus getPoweredOffFinderMode(bool* status);
+
+ private:
+ std::shared_ptr<IBluetoothFinder> bluetooth_finder;
+};
+
+ScopedAStatus BluetoothFinderTest::sendEids(uint8_t numKeys) {
+ std::vector<Eid> keys(numKeys);
+ for (uint_t i = 0; i < numKeys; i++) {
+ std::array<uint8_t, 20> key;
+ key.fill(i + 1);
+ keys[i].bytes = key;
+ }
+ return bluetooth_finder->sendEids(keys);
+}
+
+ScopedAStatus BluetoothFinderTest::setPoweredOffFinderMode(bool enable) {
+ return bluetooth_finder->setPoweredOffFinderMode(enable);
+}
+
+ScopedAStatus BluetoothFinderTest::getPoweredOffFinderMode(bool* status) {
+ return bluetooth_finder->getPoweredOffFinderMode(status);
+}
+
+TEST_P(BluetoothFinderTest, SendEidsSingle) {
+ ScopedAStatus status = sendEids(1);
+ ASSERT_TRUE(status.isOk());
+}
+
+TEST_P(BluetoothFinderTest, Send255Eids) {
+ ScopedAStatus status = sendEids(255);
+ ASSERT_TRUE(status.isOk());
+}
+
+TEST_P(BluetoothFinderTest, setAndGetPoweredOffFinderModeEnable) {
+ ScopedAStatus status = setPoweredOffFinderMode(true);
+ ASSERT_TRUE(status.isOk());
+ bool pof_status;
+ status = getPoweredOffFinderMode(&pof_status);
+ ASSERT_TRUE(status.isOk());
+ ASSERT_TRUE(pof_status);
+}
+
+TEST_P(BluetoothFinderTest, setAndGetPoweredOffFinderModeDisable) {
+ ScopedAStatus status = setPoweredOffFinderMode(false);
+ ASSERT_TRUE(status.isOk());
+ bool pof_status;
+ status = getPoweredOffFinderMode(&pof_status);
+ ASSERT_TRUE(status.isOk());
+ ASSERT_TRUE(!pof_status);
+}
+
+GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(BluetoothFinderTest);
+INSTANTIATE_TEST_SUITE_P(PerInstance, BluetoothFinderTest,
+ testing::ValuesIn(android::getAidlHalInstanceNames(
+ IBluetoothFinder::descriptor)),
+ android::PrintInstanceNameToString);
+
+int main(int argc, char** argv) {
+ ::testing::InitGoogleTest(&argc, argv);
+ ABinderProcess_startThreadPool();
+ int status = RUN_ALL_TESTS();
+ ALOGI("Test result = %d", status);
+ return status;
+}
diff --git a/bluetooth/finder/aidl/vts/VtsHalBluetoothFinderTargetTest.xml b/bluetooth/finder/aidl/vts/VtsHalBluetoothFinderTargetTest.xml
new file mode 100644
index 0000000..46053dd
--- /dev/null
+++ b/bluetooth/finder/aidl/vts/VtsHalBluetoothFinderTargetTest.xml
@@ -0,0 +1,33 @@
+<!--
+ Copyright (C) 2023 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.
+-->
+
+<configuration description="Runs VtsHalBluetoothFinderTargetTest.">
+ <option name="test-suite-tag" value="apct" />
+ <option name="test-suite-tag" value="apct-native" />
+
+ <target_preparer class="com.android.tradefed.targetprep.RootTargetPreparer">
+ </target_preparer>
+
+ <target_preparer class="com.android.tradefed.targetprep.PushFilePreparer">
+ <option name="cleanup" value="true" />
+ <option name="push" value="VtsHalBluetoothFinderTargetTest->/data/local/tmp/VtsHalBluetoothFinderTargetTest" />
+ </target_preparer>
+
+ <test class="com.android.tradefed.testtype.GTest" >
+ <option name="native-test-device-path" value="/data/local/tmp" />
+ <option name="module-name" value="VtsHalBluetoothFinderTargetTest" />
+ </test>
+</configuration>
diff --git a/broadcastradio/aidl/default/BroadcastRadio.cpp b/broadcastradio/aidl/default/BroadcastRadio.cpp
index 63073d7..4d6d81d 100644
--- a/broadcastradio/aidl/default/BroadcastRadio.cpp
+++ b/broadcastradio/aidl/default/BroadcastRadio.cpp
@@ -48,6 +48,8 @@
inline constexpr std::chrono::seconds kListDelayTimeS = 1s;
// clang-format off
+const AmFmBandRange kFmFullBandRange = {65000, 108000, 10, 0};
+const AmFmBandRange kAmFullBandRange = {150, 30000, 1, 0};
const AmFmRegionConfig kDefaultAmFmConfig = {
{
{87500, 108000, 100, 100}, // FM
@@ -64,12 +66,7 @@
prop.maker = "Android";
prop.product = virtualRadio.getName();
- prop.supportedIdentifierTypes = vector<IdentifierType>({
- IdentifierType::AMFM_FREQUENCY_KHZ,
- IdentifierType::RDS_PI,
- IdentifierType::HD_STATION_ID_EXT,
- IdentifierType::DAB_SID_EXT,
- });
+ prop.supportedIdentifierTypes = virtualRadio.getSupportedIdentifierTypes();
prop.vendorInfo = vector<VendorKeyValue>({
{"com.android.sample", "sample"},
});
@@ -77,14 +74,71 @@
return prop;
}
+bool isDigitalProgramAllowed(const ProgramSelector& sel, bool forceAnalogFm, bool forceAnalogAm) {
+ if (sel.primaryId.type != IdentifierType::HD_STATION_ID_EXT) {
+ return true;
+ }
+ int32_t freq = static_cast<int32_t>(utils::getAmFmFrequency(sel));
+ bool isFm = freq >= kFmFullBandRange.lowerBound && freq <= kFmFullBandRange.upperBound;
+ return isFm ? !forceAnalogFm : !forceAnalogAm;
+}
+
+/**
+ * Checks whether a program selector is in the current band.
+ *
+ * <p>For an AM/FM program, this method checks whether it is in the current AM/FM band. For a
+ * program selector is also an HD program, it is also checked whether HD radio is enabled in the
+ * current AM/FM band. For a non-AM/FM program, the method will returns {@code true} directly.
+ * @param sel Program selector to be checked
+ * @param currentAmFmBandRange the current AM/FM band
+ * @param forceAnalogFm whether FM band is forced to be analog
+ * @param forceAnalogAm whether AM band is forced to be analog
+ * @return whether the program selector is in the current band if it is an AM/FM (including HD)
+ * selector, {@code true} otherwise
+ */
+bool isProgramInBand(const ProgramSelector& sel,
+ const std::optional<AmFmBandRange>& currentAmFmBandRange, bool forceAnalogFm,
+ bool forceAnalogAm) {
+ if (!utils::hasAmFmFrequency(sel)) {
+ return true;
+ }
+ if (!currentAmFmBandRange.has_value()) {
+ return false;
+ }
+ int32_t freq = static_cast<int32_t>(utils::getAmFmFrequency(sel));
+ if (freq < currentAmFmBandRange->lowerBound || freq > currentAmFmBandRange->upperBound) {
+ return false;
+ }
+ return isDigitalProgramAllowed(sel, forceAnalogFm, forceAnalogAm);
+}
+
// Makes ProgramInfo that does not point to any particular program
ProgramInfo makeSampleProgramInfo(const ProgramSelector& selector) {
ProgramInfo info = {};
info.selector = selector;
- info.logicallyTunedTo =
- utils::makeIdentifier(IdentifierType::AMFM_FREQUENCY_KHZ,
- utils::getId(selector, IdentifierType::AMFM_FREQUENCY_KHZ));
- info.physicallyTunedTo = info.logicallyTunedTo;
+ switch (info.selector.primaryId.type) {
+ case IdentifierType::AMFM_FREQUENCY_KHZ:
+ info.logicallyTunedTo = utils::makeIdentifier(
+ IdentifierType::AMFM_FREQUENCY_KHZ,
+ utils::getId(selector, IdentifierType::AMFM_FREQUENCY_KHZ));
+ info.physicallyTunedTo = info.logicallyTunedTo;
+ break;
+ case IdentifierType::HD_STATION_ID_EXT:
+ info.logicallyTunedTo = utils::makeIdentifier(IdentifierType::AMFM_FREQUENCY_KHZ,
+ utils::getAmFmFrequency(info.selector));
+ info.physicallyTunedTo = info.logicallyTunedTo;
+ break;
+ case IdentifierType::DAB_SID_EXT:
+ info.logicallyTunedTo = info.selector.primaryId;
+ info.physicallyTunedTo = utils::makeIdentifier(
+ IdentifierType::DAB_FREQUENCY_KHZ,
+ utils::getId(selector, IdentifierType::DAB_FREQUENCY_KHZ));
+ break;
+ default:
+ info.logicallyTunedTo = info.selector.primaryId;
+ info.physicallyTunedTo = info.logicallyTunedTo;
+ break;
+ }
return info;
}
@@ -112,6 +166,7 @@
} else {
mCurrentProgram = sel;
}
+ adjustAmFmRangeLocked();
}
}
@@ -124,8 +179,8 @@
if (full) {
*returnConfigs = {};
returnConfigs->ranges = vector<AmFmBandRange>({
- {65000, 108000, 10, 0}, // FM
- {150, 30000, 1, 0}, // AM
+ kFmFullBandRange,
+ kAmFullBandRange,
});
returnConfigs->fmDeemphasis =
AmFmRegionConfig::DEEMPHASIS_D50 | AmFmRegionConfig::DEEMPHASIS_D75;
@@ -171,14 +226,27 @@
VirtualProgram virtualProgram = {};
ProgramInfo programInfo;
- if (mVirtualRadio.getProgram(sel, &virtualProgram)) {
+ bool isProgramAllowed =
+ isDigitalProgramAllowed(sel, isConfigFlagSetLocked(ConfigFlag::FORCE_ANALOG_FM),
+ isConfigFlagSetLocked(ConfigFlag::FORCE_ANALOG_AM));
+ if (isProgramAllowed && mVirtualRadio.getProgram(sel, &virtualProgram)) {
mCurrentProgram = virtualProgram.selector;
programInfo = virtualProgram;
} else {
- mCurrentProgram = sel;
+ if (!isProgramAllowed) {
+ mCurrentProgram = utils::makeSelectorAmfm(utils::getAmFmFrequency(sel));
+ } else {
+ mCurrentProgram = sel;
+ }
programInfo = makeSampleProgramInfo(sel);
}
- mIsTuneCompleted = true;
+ programInfo.infoFlags |= ProgramInfo::FLAG_SIGNAL_ACQUISITION;
+ if (programInfo.selector.primaryId.type != IdentifierType::HD_STATION_ID_EXT) {
+ mIsTuneCompleted = true;
+ }
+ if (adjustAmFmRangeLocked()) {
+ startProgramListUpdatesLocked({});
+ }
return programInfo;
}
@@ -206,6 +274,32 @@
return ScopedAStatus::ok();
}
+void BroadcastRadio::handleProgramInfoUpdateRadioCallback(
+ ProgramInfo programInfo, const std::shared_ptr<ITunerCallback>& callback) {
+ callback->onCurrentProgramInfoChanged(programInfo);
+ if (programInfo.selector.primaryId.type != IdentifierType::HD_STATION_ID_EXT) {
+ return;
+ }
+ ProgramSelector sel = programInfo.selector;
+ auto cancelTask = [sel, callback]() { callback->onTuneFailed(Result::CANCELED, sel); };
+ programInfo.infoFlags |= ProgramInfo::FLAG_HD_SIS_ACQUISITION;
+ auto sisAcquiredTask = [this, callback, programInfo, cancelTask]() {
+ callback->onCurrentProgramInfoChanged(programInfo);
+ auto audioAcquiredTask = [this, callback, programInfo]() {
+ ProgramInfo hdProgramInfoWithAudio = programInfo;
+ hdProgramInfoWithAudio.infoFlags |= ProgramInfo::FLAG_HD_AUDIO_ACQUISITION;
+ callback->onCurrentProgramInfoChanged(hdProgramInfoWithAudio);
+ lock_guard<mutex> lk(mMutex);
+ mIsTuneCompleted = true;
+ };
+ lock_guard<mutex> lk(mMutex);
+ mTuningThread->schedule(audioAcquiredTask, cancelTask, kTuneDelayTimeMs);
+ };
+
+ lock_guard<mutex> lk(mMutex);
+ mTuningThread->schedule(sisAcquiredTask, cancelTask, kTuneDelayTimeMs);
+}
+
ScopedAStatus BroadcastRadio::tune(const ProgramSelector& program) {
LOG(DEBUG) << __func__ << ": tune to " << program.toString() << "...";
@@ -238,7 +332,7 @@
lock_guard<mutex> lk(mMutex);
programInfo = tuneInternalLocked(program);
}
- callback->onCurrentProgramInfoChanged(programInfo);
+ handleProgramInfoUpdateRadioCallback(programInfo, callback);
};
auto cancelTask = [program, callback]() { callback->onTuneFailed(Result::CANCELED, program); };
mTuningThread->schedule(task, cancelTask, kTuneDelayTimeMs);
@@ -246,6 +340,122 @@
return ScopedAStatus::ok();
}
+bool BroadcastRadio::findNextLocked(const ProgramSelector& current, bool directionUp,
+ bool skipSubChannel, VirtualProgram* nextProgram) const {
+ if (mProgramList.empty()) {
+ return false;
+ }
+ // The list is not sorted here since it has already stored in VirtualRadio.
+ bool hasAmFmFrequency = utils::hasAmFmFrequency(current);
+ bool hasDabSId = utils::hasId(current, IdentifierType::DAB_SID_EXT);
+ uint32_t currentChannel =
+ hasAmFmFrequency ? utils::getAmFmFrequency(current) : utils::getDabSId(current);
+ auto found =
+ std::lower_bound(mProgramList.begin(), mProgramList.end(), VirtualProgram({current}));
+ if (directionUp) {
+ if (found < mProgramList.end() - 1) {
+ // When seeking up, tuner will jump to the first selector which is main program service
+ // greater than and of the same band as the current program selector in the program
+ // list (if not exist, jump to the first selector in the same band) for skipping
+ // sub-channels case or AM/FM without HD radio enabled case. Otherwise, the tuner will
+ // jump to the first selector which is greater than and of the same band as the current
+ // program selector.
+ if (utils::tunesTo(current, found->selector)) found++;
+ if (skipSubChannel) {
+ if (hasAmFmFrequency || hasDabSId) {
+ auto firstFound = found;
+ while ((hasAmFmFrequency &&
+ utils::getAmFmFrequency(found->selector) == currentChannel) ||
+ (hasDabSId && utils::getDabSId(found->selector) == currentChannel)) {
+ if (found < mProgramList.end() - 1) {
+ found++;
+ } else {
+ found = mProgramList.begin();
+ }
+ if (found == firstFound) {
+ // Only one main channel exists in the program list, the tuner cannot
+ // skip sub-channel to the next program selector.
+ return false;
+ }
+ }
+ }
+ }
+ } else {
+ // If the selector of current program is no less than all selectors of the same band or
+ // not found in the program list, seeking up should wrap the tuner to the first program
+ // selector of the same band in the program list.
+ found = mProgramList.begin();
+ }
+ } else {
+ if (found > mProgramList.begin() && found != mProgramList.end()) {
+ // When seeking down, tuner will jump to the first selector which is main program
+ // service less than and of the same band as the current program selector in the
+ // program list (if not exist, jump to the last main program service selector of the
+ // same band) for skipping sub-channels case or AM/FM without HD radio enabled case.
+ // Otherwise, the tuner will jump to the first selector less than and of the same band
+ // as the current program selector.
+ found--;
+ if ((hasAmFmFrequency && utils::hasAmFmFrequency(found->selector)) ||
+ (hasDabSId && utils::hasId(found->selector, IdentifierType::DAB_SID_EXT))) {
+ uint32_t nextChannel = hasAmFmFrequency ? utils::getAmFmFrequency(found->selector)
+ : utils::getDabSId(found->selector);
+ if (nextChannel != currentChannel) {
+ jumpToFirstSubChannelLocked(found);
+ } else if (skipSubChannel) {
+ jumpToFirstSubChannelLocked(found);
+ auto firstFound = found;
+ if (found > mProgramList.begin()) {
+ found--;
+ } else {
+ found = mProgramList.end() - 1;
+ }
+ jumpToFirstSubChannelLocked(found);
+ if (found == firstFound) {
+ // Only one main channel exists in the program list, the tuner cannot skip
+ // sub-channel to the next program selector.
+ return false;
+ }
+ }
+ }
+ } else {
+ // If the selector of current program is no greater than all selectors of the same band
+ // or not found in the program list, seeking down should wrap the tuner to the last
+ // selector of the same band in the program list. If the last program selector in the
+ // program list is sub-channel and skipping sub-channels is needed, the tuner will jump
+ // to the last main program service of the same band in the program list.
+ found = mProgramList.end() - 1;
+ jumpToFirstSubChannelLocked(found);
+ }
+ }
+ *nextProgram = *found;
+ return true;
+}
+
+void BroadcastRadio::jumpToFirstSubChannelLocked(vector<VirtualProgram>::const_iterator& it) const {
+ if (it == mProgramList.begin()) {
+ return;
+ }
+ bool hasAmFmFrequency = utils::hasAmFmFrequency(it->selector);
+ bool hasDabSId = utils::hasId(it->selector, IdentifierType::DAB_SID_EXT);
+ if (hasAmFmFrequency || hasDabSId) {
+ uint32_t currentChannel = hasAmFmFrequency ? utils::getAmFmFrequency(it->selector)
+ : utils::getDabSId(it->selector);
+ it--;
+ while (it != mProgramList.begin()) {
+ if (hasAmFmFrequency && utils::hasAmFmFrequency(it->selector) &&
+ utils::getAmFmFrequency(it->selector) == currentChannel) {
+ it--;
+ } else if (hasDabSId && utils::hasId(it->selector, IdentifierType::DAB_SID_EXT) &&
+ utils::getDabSId(it->selector) == currentChannel) {
+ it--;
+ } else {
+ break;
+ }
+ }
+ it++;
+ }
+}
+
ScopedAStatus BroadcastRadio::seek(bool directionUp, bool skipSubChannel) {
LOG(DEBUG) << __func__ << ": seek " << (directionUp ? "up" : "down") << " with skipSubChannel? "
<< (skipSubChannel ? "yes" : "no") << "...";
@@ -259,11 +469,21 @@
cancelLocked();
+ auto filterCb = [this](const VirtualProgram& program) {
+ return isProgramInBand(program.selector, mCurrentAmFmBandRange,
+ isConfigFlagSetLocked(ConfigFlag::FORCE_ANALOG_FM),
+ isConfigFlagSetLocked(ConfigFlag::FORCE_ANALOG_AM));
+ };
const auto& list = mVirtualRadio.getProgramList();
+ mProgramList.clear();
+ std::copy_if(list.begin(), list.end(), std::back_inserter(mProgramList), filterCb);
std::shared_ptr<ITunerCallback> callback = mCallback;
auto cancelTask = [callback]() { callback->onTuneFailed(Result::CANCELED, {}); };
- if (list.empty()) {
- mIsTuneCompleted = false;
+
+ VirtualProgram nextProgram = {};
+ bool foundNext = findNextLocked(mCurrentProgram, directionUp, skipSubChannel, &nextProgram);
+ mIsTuneCompleted = false;
+ if (!foundNext) {
auto task = [callback]() {
LOG(DEBUG) << "seek: program list is empty, seek couldn't stop";
@@ -274,33 +494,13 @@
return ScopedAStatus::ok();
}
- // The list is not sorted here since it has already stored in VirtualRadio.
- // If the list is not sorted in advance, it should be sorted here.
- const auto& current = mCurrentProgram;
- auto found = std::lower_bound(list.begin(), list.end(), VirtualProgram({current}));
- if (directionUp) {
- if (found < list.end() - 1) {
- if (tunesTo(current, found->selector)) found++;
- } else {
- found = list.begin();
- }
- } else {
- if (found > list.begin() && found != list.end()) {
- found--;
- } else {
- found = list.end() - 1;
- }
- }
- const ProgramSelector tuneTo = found->selector;
-
- mIsTuneCompleted = false;
- auto task = [this, tuneTo, callback]() {
+ auto task = [this, nextProgram, callback]() {
ProgramInfo programInfo = {};
{
lock_guard<mutex> lk(mMutex);
- programInfo = tuneInternalLocked(tuneTo);
+ programInfo = tuneInternalLocked(nextProgram.selector);
}
- callback->onCurrentProgramInfoChanged(programInfo);
+ handleProgramInfoUpdateRadioCallback(programInfo, callback);
};
mTuningThread->schedule(task, cancelTask, kSeekDelayTimeMs);
@@ -319,31 +519,33 @@
cancelLocked();
- if (!utils::hasId(mCurrentProgram, IdentifierType::AMFM_FREQUENCY_KHZ)) {
+ int64_t stepTo;
+ if (utils::hasId(mCurrentProgram, IdentifierType::AMFM_FREQUENCY_KHZ)) {
+ stepTo = utils::getId(mCurrentProgram, IdentifierType::AMFM_FREQUENCY_KHZ);
+ } else if (mCurrentProgram.primaryId.type == IdentifierType::HD_STATION_ID_EXT) {
+ stepTo = utils::getHdFrequency(mCurrentProgram);
+ } else {
LOG(WARNING) << __func__ << ": can't step in anything else than AM/FM";
return ScopedAStatus::fromServiceSpecificErrorWithMessage(
resultToInt(Result::NOT_SUPPORTED), "cannot step in anything else than AM/FM");
}
- int64_t stepTo = utils::getId(mCurrentProgram, IdentifierType::AMFM_FREQUENCY_KHZ);
- std::optional<AmFmBandRange> range = getAmFmRangeLocked();
- if (!range) {
- LOG(ERROR) << __func__ << ": can't find current band or tune operation is in process";
+ if (!mCurrentAmFmBandRange.has_value()) {
+ LOG(ERROR) << __func__ << ": can't find current band";
return ScopedAStatus::fromServiceSpecificErrorWithMessage(
- resultToInt(Result::INTERNAL_ERROR),
- "can't find current band or tune operation is in process");
+ resultToInt(Result::INTERNAL_ERROR), "can't find current band");
}
if (directionUp) {
- stepTo += range->spacing;
+ stepTo += mCurrentAmFmBandRange->spacing;
} else {
- stepTo -= range->spacing;
+ stepTo -= mCurrentAmFmBandRange->spacing;
}
- if (stepTo > range->upperBound) {
- stepTo = range->lowerBound;
+ if (stepTo > mCurrentAmFmBandRange->upperBound) {
+ stepTo = mCurrentAmFmBandRange->lowerBound;
}
- if (stepTo < range->lowerBound) {
- stepTo = range->upperBound;
+ if (stepTo < mCurrentAmFmBandRange->lowerBound) {
+ stepTo = mCurrentAmFmBandRange->upperBound;
}
mIsTuneCompleted = false;
@@ -354,7 +556,7 @@
lock_guard<mutex> lk(mMutex);
programInfo = tuneInternalLocked(utils::makeSelectorAmfm(stepTo));
}
- callback->onCurrentProgramInfoChanged(programInfo);
+ handleProgramInfoUpdateRadioCallback(programInfo, callback);
};
auto cancelTask = [callback]() { callback->onTuneFailed(Result::CANCELED, {}); };
mTuningThread->schedule(task, cancelTask, kStepDelayTimeMs);
@@ -380,16 +582,14 @@
return ScopedAStatus::ok();
}
-ScopedAStatus BroadcastRadio::startProgramListUpdates(const ProgramFilter& filter) {
- LOG(DEBUG) << __func__ << ": requested program list updates, filter = " << filter.toString()
- << "...";
-
- auto filterCb = [&filter](const VirtualProgram& program) {
- return utils::satisfies(filter, program.selector);
+void BroadcastRadio::startProgramListUpdatesLocked(const ProgramFilter& filter) {
+ auto filterCb = [&filter, this](const VirtualProgram& program) {
+ return utils::satisfies(filter, program.selector) &&
+ isProgramInBand(program.selector, mCurrentAmFmBandRange,
+ isConfigFlagSetLocked(ConfigFlag::FORCE_ANALOG_FM),
+ isConfigFlagSetLocked(ConfigFlag::FORCE_ANALOG_AM));
};
- lock_guard<mutex> lk(mMutex);
-
cancelProgramListUpdateLocked();
const auto& list = mVirtualRadio.getProgramList();
@@ -415,6 +615,15 @@
callback->onProgramListUpdated(chunk);
};
mProgramListThread->schedule(task, kListDelayTimeS);
+}
+
+ScopedAStatus BroadcastRadio::startProgramListUpdates(const ProgramFilter& filter) {
+ LOG(DEBUG) << __func__ << ": requested program list updates, filter = " << filter.toString()
+ << "...";
+
+ lock_guard<mutex> lk(mMutex);
+
+ startProgramListUpdatesLocked(filter);
return ScopedAStatus::ok();
}
@@ -431,18 +640,28 @@
return ScopedAStatus::ok();
}
+bool BroadcastRadio::isConfigFlagSetLocked(ConfigFlag flag) const {
+ int flagBit = static_cast<int>(flag);
+ return ((mConfigFlagValues >> flagBit) & 1) == 1;
+}
+
ScopedAStatus BroadcastRadio::isConfigFlagSet(ConfigFlag flag, bool* returnIsSet) {
LOG(DEBUG) << __func__ << ": flag = " << toString(flag);
- int flagBit = static_cast<int>(flag);
+ if (flag == ConfigFlag::FORCE_ANALOG) {
+ flag = ConfigFlag::FORCE_ANALOG_FM;
+ }
lock_guard<mutex> lk(mMutex);
- *returnIsSet = ((mConfigFlagValues >> flagBit) & 1) == 1;
+ *returnIsSet = isConfigFlagSetLocked(flag);
return ScopedAStatus::ok();
}
ScopedAStatus BroadcastRadio::setConfigFlag(ConfigFlag flag, bool value) {
LOG(DEBUG) << __func__ << ": flag = " << toString(flag) << ", value = " << value;
+ if (flag == ConfigFlag::FORCE_ANALOG) {
+ flag = ConfigFlag::FORCE_ANALOG_FM;
+ }
int flagBitMask = 1 << (static_cast<int>(flag));
lock_guard<mutex> lk(mMutex);
if (value) {
@@ -450,6 +669,9 @@
} else {
mConfigFlagValues &= ~flagBitMask;
}
+ if (flag == ConfigFlag::FORCE_ANALOG_AM || flag == ConfigFlag::FORCE_ANALOG_FM) {
+ startProgramListUpdatesLocked({});
+ }
return ScopedAStatus::ok();
}
@@ -468,24 +690,25 @@
return ScopedAStatus::ok();
}
-std::optional<AmFmBandRange> BroadcastRadio::getAmFmRangeLocked() const {
- if (!mIsTuneCompleted) {
- LOG(WARNING) << __func__ << ": tune operation is in process";
- return {};
- }
- if (!utils::hasId(mCurrentProgram, IdentifierType::AMFM_FREQUENCY_KHZ)) {
+bool BroadcastRadio::adjustAmFmRangeLocked() {
+ bool hasBandBefore = mCurrentAmFmBandRange.has_value();
+ if (!utils::hasAmFmFrequency(mCurrentProgram)) {
LOG(WARNING) << __func__ << ": current program does not has AMFM_FREQUENCY_KHZ identifier";
- return {};
+ mCurrentAmFmBandRange.reset();
+ return hasBandBefore;
}
- int64_t freq = utils::getId(mCurrentProgram, IdentifierType::AMFM_FREQUENCY_KHZ);
+ int32_t freq = static_cast<int32_t>(utils::getAmFmFrequency(mCurrentProgram));
for (const auto& range : mAmFmConfig.ranges) {
if (range.lowerBound <= freq && range.upperBound >= freq) {
- return range;
+ bool isBandChanged = hasBandBefore ? *mCurrentAmFmBandRange != range : true;
+ mCurrentAmFmBandRange = range;
+ return isBandChanged;
}
}
- return {};
+ mCurrentAmFmBandRange.reset();
+ return !hasBandBefore;
}
ScopedAStatus BroadcastRadio::registerAnnouncementListener(
diff --git a/broadcastradio/aidl/default/BroadcastRadio.h b/broadcastradio/aidl/default/BroadcastRadio.h
index 0f818ce..60ea907 100644
--- a/broadcastradio/aidl/default/BroadcastRadio.h
+++ b/broadcastradio/aidl/default/BroadcastRadio.h
@@ -39,21 +39,25 @@
public:
explicit BroadcastRadio(const VirtualRadio& virtualRadio);
~BroadcastRadio();
- ndk::ScopedAStatus getAmFmRegionConfig(bool full, AmFmRegionConfig* returnConfigs) override;
+ ndk::ScopedAStatus getAmFmRegionConfig(bool full, AmFmRegionConfig* returnConfigs)
+ EXCLUDES(mMutex) override;
ndk::ScopedAStatus getDabRegionConfig(std::vector<DabTableEntry>* returnConfigs) override;
ndk::ScopedAStatus getImage(int32_t id, std::vector<uint8_t>* returnImage) override;
- ndk::ScopedAStatus getProperties(Properties* returnProperties) override;
+ ndk::ScopedAStatus getProperties(Properties* returnProperties) EXCLUDES(mMutex) override;
- ndk::ScopedAStatus setTunerCallback(const std::shared_ptr<ITunerCallback>& callback) override;
- ndk::ScopedAStatus unsetTunerCallback() override;
- ndk::ScopedAStatus tune(const ProgramSelector& program) override;
- ndk::ScopedAStatus seek(bool directionUp, bool skipSubChannel) override;
- ndk::ScopedAStatus step(bool directionUp) override;
- ndk::ScopedAStatus cancel() override;
- ndk::ScopedAStatus startProgramListUpdates(const ProgramFilter& filter) override;
- ndk::ScopedAStatus stopProgramListUpdates() override;
- ndk::ScopedAStatus isConfigFlagSet(ConfigFlag flag, bool* returnIsSet) override;
- ndk::ScopedAStatus setConfigFlag(ConfigFlag flag, bool in_value) override;
+ ndk::ScopedAStatus setTunerCallback(const std::shared_ptr<ITunerCallback>& callback)
+ EXCLUDES(mMutex) override;
+ ndk::ScopedAStatus unsetTunerCallback() EXCLUDES(mMutex) override;
+ ndk::ScopedAStatus tune(const ProgramSelector& program) EXCLUDES(mMutex) override;
+ ndk::ScopedAStatus seek(bool directionUp, bool skipSubChannel) EXCLUDES(mMutex) override;
+ ndk::ScopedAStatus step(bool directionUp) EXCLUDES(mMutex) override;
+ ndk::ScopedAStatus cancel() EXCLUDES(mMutex) override;
+ ndk::ScopedAStatus startProgramListUpdates(const ProgramFilter& filter)
+ EXCLUDES(mMutex) override;
+ ndk::ScopedAStatus stopProgramListUpdates() EXCLUDES(mMutex) override;
+ ndk::ScopedAStatus isConfigFlagSet(ConfigFlag flag, bool* returnIsSet)
+ EXCLUDES(mMutex) override;
+ ndk::ScopedAStatus setConfigFlag(ConfigFlag flag, bool in_value) EXCLUDES(mMutex) override;
ndk::ScopedAStatus setParameters(const std::vector<VendorKeyValue>& parameters,
std::vector<VendorKeyValue>* returnParameters) override;
ndk::ScopedAStatus getParameters(const std::vector<std::string>& keys,
@@ -62,7 +66,7 @@
const std::shared_ptr<IAnnouncementListener>& listener,
const std::vector<AnnouncementType>& enabled,
std::shared_ptr<ICloseHandle>* returnCloseHandle) override;
- binder_status_t dump(int fd, const char** args, uint32_t numArgs) override;
+ binder_status_t dump(int fd, const char** args, uint32_t numArgs) EXCLUDES(mMutex) override;
private:
const VirtualRadio& mVirtualRadio;
@@ -75,15 +79,26 @@
bool mIsTuneCompleted GUARDED_BY(mMutex) = true;
Properties mProperties GUARDED_BY(mMutex);
ProgramSelector mCurrentProgram GUARDED_BY(mMutex) = {};
+ std::vector<VirtualProgram> mProgramList GUARDED_BY(mMutex) = {};
+ std::optional<AmFmBandRange> mCurrentAmFmBandRange GUARDED_BY(mMutex);
std::shared_ptr<ITunerCallback> mCallback GUARDED_BY(mMutex);
// Bitmap for all ConfigFlag values
int mConfigFlagValues GUARDED_BY(mMutex) = 0;
- std::optional<AmFmBandRange> getAmFmRangeLocked() const;
- void cancelLocked();
- ProgramInfo tuneInternalLocked(const ProgramSelector& sel);
- void cancelProgramListUpdateLocked();
+ bool adjustAmFmRangeLocked() REQUIRES(mMutex);
+ void cancelLocked() REQUIRES(mMutex);
+ ProgramInfo tuneInternalLocked(const ProgramSelector& sel) REQUIRES(mMutex);
+ void startProgramListUpdatesLocked(const ProgramFilter& filter) REQUIRES(mMutex);
+ void cancelProgramListUpdateLocked() REQUIRES(mMutex);
+ void handleProgramInfoUpdateRadioCallback(ProgramInfo programInfo,
+ const std::shared_ptr<ITunerCallback>& callback)
+ EXCLUDES(mMutex);
+ bool findNextLocked(const ProgramSelector& current, bool directionUp, bool skipSubChannel,
+ VirtualProgram* nextProgram) const REQUIRES(mMutex);
+ void jumpToFirstSubChannelLocked(std::vector<VirtualProgram>::const_iterator& it) const
+ REQUIRES(mMutex);
+ bool isConfigFlagSetLocked(ConfigFlag flag) const REQUIRES(mMutex);
binder_status_t cmdHelp(int fd) const;
binder_status_t cmdTune(int fd, const char** args, uint32_t numArgs);
@@ -93,7 +108,7 @@
binder_status_t cmdStartProgramListUpdates(int fd, const char** args, uint32_t numArgs);
binder_status_t cmdStopProgramListUpdates(int fd, uint32_t numArgs);
- binder_status_t dumpsys(int fd);
+ binder_status_t dumpsys(int fd) EXCLUDES(mMutex);
};
} // namespace aidl::android::hardware::broadcastradio
diff --git a/broadcastradio/aidl/default/VirtualProgram.cpp b/broadcastradio/aidl/default/VirtualProgram.cpp
index 4fe6567..dca431d 100644
--- a/broadcastradio/aidl/default/VirtualProgram.cpp
+++ b/broadcastradio/aidl/default/VirtualProgram.cpp
@@ -49,7 +49,12 @@
break;
case IdentifierType::HD_STATION_ID_EXT:
info.logicallyTunedTo = selectId(IdentifierType::HD_STATION_ID_EXT);
- info.physicallyTunedTo = selectId(IdentifierType::AMFM_FREQUENCY_KHZ);
+ if (utils::hasId(info.selector, IdentifierType::AMFM_FREQUENCY_KHZ)) {
+ info.physicallyTunedTo = selectId(IdentifierType::AMFM_FREQUENCY_KHZ);
+ } else {
+ info.physicallyTunedTo = utils::makeIdentifier(
+ IdentifierType::AMFM_FREQUENCY_KHZ, utils::getHdFrequency(info.selector));
+ }
break;
case IdentifierType::DAB_SID_EXT:
info.logicallyTunedTo = selectId(IdentifierType::DAB_SID_EXT);
@@ -91,9 +96,45 @@
auto& l = lhs.selector;
auto& r = rhs.selector;
- // Two programs with the same primaryId are considered the same.
- if (l.primaryId.type != r.primaryId.type) return l.primaryId.type < r.primaryId.type;
+ if ((utils::hasId(l, IdentifierType::AMFM_FREQUENCY_KHZ) ||
+ l.primaryId.type == IdentifierType::HD_STATION_ID_EXT) &&
+ (utils::hasId(r, IdentifierType::AMFM_FREQUENCY_KHZ) ||
+ r.primaryId.type == IdentifierType::HD_STATION_ID_EXT)) {
+ uint32_t freq1 = utils::getAmFmFrequency(l);
+ int subChannel1 = l.primaryId.type == IdentifierType::HD_STATION_ID_EXT
+ ? utils::getHdSubchannel(l)
+ : 0;
+ uint32_t freq2 = utils::getAmFmFrequency(r);
+ int subChannel2 = r.primaryId.type == IdentifierType::HD_STATION_ID_EXT
+ ? utils::getHdSubchannel(r)
+ : 0;
+ return freq1 < freq2 || (freq1 == freq2 && (l.primaryId.type < r.primaryId.type ||
+ subChannel1 < subChannel2));
+ } else if (l.primaryId.type == IdentifierType::DAB_SID_EXT &&
+ r.primaryId.type == IdentifierType::DAB_SID_EXT) {
+ uint64_t dabFreq1 = utils::getId(l, IdentifierType::DAB_FREQUENCY_KHZ);
+ uint64_t dabFreq2 = utils::getId(r, IdentifierType::DAB_FREQUENCY_KHZ);
+ if (dabFreq1 != dabFreq2) {
+ return dabFreq1 < dabFreq2;
+ }
+ uint32_t ecc1 = utils::getDabEccCode(l);
+ uint32_t ecc2 = utils::getDabEccCode(r);
+ if (ecc1 != ecc2) {
+ return ecc1 < ecc2;
+ }
+ uint64_t dabEnsemble1 = utils::getId(l, IdentifierType::DAB_ENSEMBLE);
+ uint64_t dabEnsemble2 = utils::getId(r, IdentifierType::DAB_ENSEMBLE);
+ if (dabEnsemble1 != dabEnsemble2) {
+ return dabEnsemble1 < dabEnsemble2;
+ }
+ uint32_t sId1 = utils::getDabSId(l);
+ uint32_t sId2 = utils::getDabSId(r);
+ return sId1 < sId2 || (sId1 == sId2 && utils::getDabSCIdS(l) < utils::getDabSCIdS(r));
+ }
+ if (l.primaryId.type != r.primaryId.type) {
+ return l.primaryId.type < r.primaryId.type;
+ }
return l.primaryId.value < r.primaryId.value;
}
diff --git a/broadcastradio/aidl/default/VirtualRadio.cpp b/broadcastradio/aidl/default/VirtualRadio.cpp
index 86c5a96..d6e58cd 100644
--- a/broadcastradio/aidl/default/VirtualRadio.cpp
+++ b/broadcastradio/aidl/default/VirtualRadio.cpp
@@ -16,12 +16,15 @@
#include "VirtualRadio.h"
#include <broadcastradio-utils-aidl/Utils.h>
+#include <unordered_set>
namespace aidl::android::hardware::broadcastradio {
using ::aidl::android::hardware::broadcastradio::utils::makeSelectorAmfm;
using ::aidl::android::hardware::broadcastradio::utils::makeSelectorDab;
+using ::aidl::android::hardware::broadcastradio::utils::makeSelectorHd;
using ::std::string;
+using ::std::unordered_set;
using ::std::vector;
VirtualRadio::VirtualRadio(const string& name, const vector<VirtualProgram>& initialList)
@@ -38,15 +41,43 @@
}
bool VirtualRadio::getProgram(const ProgramSelector& selector, VirtualProgram* programOut) const {
- for (const auto& program : mPrograms) {
- if (utils::tunesTo(selector, program.selector)) {
- *programOut = program;
- return true;
+ for (auto it = mPrograms.begin(); it != mPrograms.end(); it++) {
+ if (!utils::tunesTo(selector, it->selector)) {
+ continue;
}
+ auto firstMatchIt = it;
+ if (utils::hasAmFmFrequency(it->selector)) {
+ uint32_t channelFreq = utils::getAmFmFrequency(it->selector);
+ it++;
+ while (it != mPrograms.end() && utils::hasAmFmFrequency(it->selector) &&
+ utils::getAmFmFrequency(it->selector) == channelFreq) {
+ if (it->selector == selector) {
+ *programOut = *it;
+ return true;
+ }
+ it++;
+ }
+ }
+ *programOut = *firstMatchIt;
+ return true;
}
return false;
}
+vector<IdentifierType> VirtualRadio::getSupportedIdentifierTypes() const {
+ unordered_set<IdentifierType> supportedIdentifierTypeSet;
+ for (const auto& program : mPrograms) {
+ IdentifierType type = program.selector.primaryId.type;
+ if (supportedIdentifierTypeSet.count(type)) {
+ continue;
+ }
+ supportedIdentifierTypeSet.insert(type);
+ }
+ vector<IdentifierType> supportedIdentifierTypes(supportedIdentifierTypeSet.begin(),
+ supportedIdentifierTypeSet.end());
+ return supportedIdentifierTypes;
+}
+
// get singleton of AMFM Virtual Radio
const VirtualRadio& VirtualRadio::getAmFmRadio() {
// clang-format off
@@ -56,15 +87,27 @@
{makeSelectorAmfm(/* frequency= */ 94900u), "Wild 94.9", "Drake ft. Rihanna",
"Too Good"},
{makeSelectorAmfm(/* frequency= */ 96500u), "KOIT", "Celine Dion", "All By Myself"},
- {makeSelectorAmfm(/* frequency= */ 97300u), "Alice@97.3", "Drops of Jupiter", "Train"},
- {makeSelectorAmfm(/* frequency= */ 99700u), "99.7 Now!", "The Chainsmokers", "Closer"},
{makeSelectorAmfm(/* frequency= */ 101300u), "101-3 KISS-FM", "Justin Timberlake",
"Rock Your Body"},
{makeSelectorAmfm(/* frequency= */ 103700u), "iHeart80s @ 103.7", "Michael Jackson",
"Billie Jean"},
{makeSelectorAmfm(/* frequency= */ 106100u), "106 KMEL", "Drake", "Marvins Room"},
- {makeSelectorAmfm(/* frequency= */ 700u), "700 AM", "Artist700", "Title700"},
- {makeSelectorAmfm(/* frequency= */ 1700u), "1700 AM", "Artist1700", "Title1700"},
+ {makeSelectorAmfm(/* frequency= */ 560u), "Talk Radio 560 KSFO", "Artist560", "Title560"},
+ {makeSelectorAmfm(/* frequency= */ 680u), "KNBR 680", "Artist680", "Title680"},
+ {makeSelectorAmfm(/* frequency= */ 97300u), "Alice@97.3", "Drops of Jupiter", "Train"},
+ {makeSelectorAmfm(/* frequency= */ 99700u), "99.7 Now!", "The Chainsmokers", "Closer"},
+ {makeSelectorHd(/* stationId= */ 0xA0000001u, /* subChannel= */ 0u, /* frequency= */ 97700u),
+ "K-LOVE", "ArtistHd0", "TitleHd0"},
+ {makeSelectorHd(/* stationId= */ 0xA0000001u, /* subChannel= */ 1u, /* frequency= */ 97700u),
+ "Air1", "ArtistHd1", "TitleHd1"},
+ {makeSelectorHd(/* stationId= */ 0xA0000001u, /* subChannel= */ 2u, /* frequency= */ 97700u),
+ "K-LOVE Classics", "ArtistHd2", "TitleHd2"},
+ {makeSelectorHd(/* stationId= */ 0xA0000001u, /* subChannel= */ 0u, /* frequency= */ 98500u),
+ "98.5-1 South Bay's Classic Rock", "ArtistHd0", "TitleHd0"},
+ {makeSelectorHd(/* stationId= */ 0xA0000001u, /* subChannel= */ 1u, /* frequency= */ 98500u),
+ "Highway 1 - Different", "ArtistHd1", "TitleHd1"},
+ {makeSelectorHd(/* stationId= */ 0xB0000001u, /* subChannel= */ 0u, /* frequency= */ 1170u),
+ "KLOK", "ArtistHd1", "TitleHd1"},
});
// clang-format on
return amFmRadioMock;
@@ -76,14 +119,24 @@
static VirtualRadio dabRadioMock(
"DAB radio mock",
{
- {makeSelectorDab(/* sidExt= */ 0xA000000001u, /* ensemble= */ 0x0001u,
+ {makeSelectorDab(/* sidExt= */ 0x0E10000C221u, /* ensemble= */ 0xCE15u,
/* freq= */ 225648u), "BBC Radio 1", "Khalid", "Talk"},
- {makeSelectorDab(/* sidExt= */ 0xB000000001u, /* ensemble= */ 0x1001u,
+ {makeSelectorDab(/* sidExt= */ 0x0E10000C222u, /* ensemble= */ 0xCE15u,
+ /* freq= */ 225648u), "BBC Radio 2", "Khalid", "Talk"},
+ {makeSelectorDab(/* sidExt= */ 0xE10000C224u, /* ensemble= */ 0xCE15u,
+ /* freq= */ 225648u), "BBC Radio 4", "ArtistBBC1", "TitleCountry1"},
+ {makeSelectorDab(/* sidExt= */ 0x1E10000C224u, /* ensemble= */ 0xCE15u,
+ /* freq= */ 225648u), "BBC Radio 4 LW", "ArtistBBC2", "TitleCountry2"},
+ {makeSelectorDab(/* sidExt= */ 0x0E10000C21Au, /* ensemble= */ 0xC181u,
/* freq= */ 222064u), "Classic FM", "Jean Sibelius", "Andante Festivo"},
- {makeSelectorDab(/* sidExt= */ 0xB000000002u, /* ensemble= */ 0x1002u,
- /* freq= */ 227360u), "Absolute Radio", "Coldplay", "Clocks"},
- {makeSelectorDab(/* sidExt= */ 0xB000000002u, /* ensemble= */ 0x1002u,
+ {makeSelectorDab(/* sidExt= */ 0x0E10000C1C0u, /* ensemble= */ 0xC181u,
+ /* freq= */ 223936u), "Absolute Radio", "Coldplay", "Clocks"},
+ {makeSelectorDab(/* sidExt= */ 0x0E10000C1C0u, /* ensemble= */ 0xC181u,
/* freq= */ 222064u), "Absolute Radio", "Coldplay", "Clocks"},
+ {makeSelectorDab(/* sidExt= */ 0x0E10000CCE7u, /* ensemble= */ 0xC19Du,
+ /* freq= */ 218640u), "Absolute Radio Country", "ArtistCountry1", "TitleCountry1"},
+ {makeSelectorDab(/* sidExt= */ 0x0E10000CCE7u, /* ensemble= */ 0xC1A0u,
+ /* freq= */ 218640u), "Absolute Radio Country", "ArtistCountry2", "TitleCountry2"},
});
// clang-format on
return dabRadioMock;
diff --git a/broadcastradio/aidl/default/VirtualRadio.h b/broadcastradio/aidl/default/VirtualRadio.h
index ae039c4..0d70aef 100644
--- a/broadcastradio/aidl/default/VirtualRadio.h
+++ b/broadcastradio/aidl/default/VirtualRadio.h
@@ -36,6 +36,7 @@
std::string getName() const;
const std::vector<VirtualProgram>& getProgramList() const;
bool getProgram(const ProgramSelector& selector, VirtualProgram* program) const;
+ std::vector<IdentifierType> getSupportedIdentifierTypes() const;
static const VirtualRadio& getAmFmRadio();
static const VirtualRadio& getDabRadio();
diff --git a/broadcastradio/common/utilsaidl/include/broadcastradio-utils-aidl/Utils.h b/broadcastradio/common/utilsaidl/include/broadcastradio-utils-aidl/Utils.h
index b6fb33f..bb43903 100644
--- a/broadcastradio/common/utilsaidl/include/broadcastradio-utils-aidl/Utils.h
+++ b/broadcastradio/common/utilsaidl/include/broadcastradio-utils-aidl/Utils.h
@@ -139,6 +139,7 @@
ProgramSelector makeSelectorAmfm(uint32_t frequency);
ProgramSelector makeSelectorDab(uint64_t sidExt);
ProgramSelector makeSelectorDab(uint64_t sidExt, uint32_t ensemble, uint64_t freq);
+ProgramSelector makeSelectorHd(uint64_t stationId, uint64_t subChannel, uint64_t frequency);
bool satisfies(const ProgramFilter& filter, const ProgramSelector& sel);
@@ -158,6 +159,20 @@
ProgramIdentifier makeHdRadioStationName(const std::string& name);
+uint32_t getHdFrequency(const ProgramSelector& sel);
+
+int getHdSubchannel(const ProgramSelector& sel);
+
+uint32_t getDabSId(const ProgramSelector& sel);
+
+int getDabEccCode(const ProgramSelector& sel);
+
+int getDabSCIdS(const ProgramSelector& sel);
+
+bool hasAmFmFrequency(const ProgramSelector& sel);
+
+uint32_t getAmFmFrequency(const ProgramSelector& sel);
+
template <typename aidl_type>
inline std::string vectorToString(const std::vector<aidl_type>& in_values) {
return std::accumulate(std::begin(in_values), std::end(in_values), std::string{},
diff --git a/broadcastradio/common/utilsaidl/src/Utils.cpp b/broadcastradio/common/utilsaidl/src/Utils.cpp
index 2875318..76c3c6a 100644
--- a/broadcastradio/common/utilsaidl/src/Utils.cpp
+++ b/broadcastradio/common/utilsaidl/src/Utils.cpp
@@ -49,12 +49,6 @@
return getId(a, type) == getId(b, type);
}
-int getHdSubchannel(const ProgramSelector& sel) {
- int64_t hdSidExt = getId(sel, IdentifierType::HD_STATION_ID_EXT, /* defaultValue */ 0);
- hdSidExt >>= 32; // Station ID number
- return hdSidExt & 0xF; // HD Radio subchannel
-}
-
bool maybeGetId(const ProgramSelector& sel, const IdentifierType& type, int64_t* val) {
// iterate through primaryId and secondaryIds
for (auto it = begin(sel); it != end(sel); it++) {
@@ -132,8 +126,13 @@
case IdentifierType::AMFM_FREQUENCY_KHZ:
if (haveEqualIds(a, b, IdentifierType::HD_STATION_ID_EXT)) return true;
if (haveEqualIds(a, b, IdentifierType::RDS_PI)) return true;
- return getHdSubchannel(b) == 0 &&
- haveEqualIds(a, b, IdentifierType::AMFM_FREQUENCY_KHZ);
+ if (getHdSubchannel(b) != 0) { // supplemental program services
+ return false;
+ }
+ return haveEqualIds(a, b, IdentifierType::AMFM_FREQUENCY_KHZ) ||
+ (b.primaryId.type == IdentifierType::HD_STATION_ID_EXT &&
+ static_cast<uint32_t>(getId(a, IdentifierType::AMFM_FREQUENCY_KHZ)) ==
+ getAmFmFrequency(b));
case IdentifierType::DAB_SID_EXT:
if (!haveEqualIds(a, b, IdentifierType::DAB_SID_EXT)) {
return false;
@@ -316,6 +315,13 @@
return sel;
}
+ProgramSelector makeSelectorHd(uint64_t stationId, uint64_t subChannel, uint64_t frequency) {
+ ProgramSelector sel = {};
+ uint64_t sidExt = stationId | (subChannel << 32) | (frequency << 36);
+ sel.primaryId = makeIdentifier(IdentifierType::HD_STATION_ID_EXT, sidExt);
+ return sel;
+}
+
ProgramSelector makeSelectorDab(uint64_t sidExt, uint32_t ensemble, uint64_t freq) {
ProgramSelector sel = {};
sel.primaryId = makeIdentifier(IdentifierType::DAB_SID_EXT, sidExt);
@@ -483,6 +489,47 @@
return static_cast<IdentifierType>(typeAsInt);
}
+uint32_t getDabSId(const ProgramSelector& sel) {
+ int64_t dabSidExt = getId(sel, IdentifierType::DAB_SID_EXT, /* defaultValue */ 0);
+ return static_cast<uint32_t>(dabSidExt & 0xFFFFFFFF);
+}
+
+int getDabEccCode(const ProgramSelector& sel) {
+ int64_t dabSidExt = getId(sel, IdentifierType::DAB_SID_EXT, /* defaultValue */ 0);
+ return static_cast<uint32_t>((dabSidExt >> 32) & 0xFF);
+}
+
+int getDabSCIdS(const ProgramSelector& sel) {
+ int64_t dabSidExt = getId(sel, IdentifierType::DAB_SID_EXT, /* defaultValue */ 0);
+ return static_cast<uint32_t>((dabSidExt >> 40) & 0xF);
+}
+
+int getHdSubchannel(const ProgramSelector& sel) {
+ int64_t hdSidExt = getId(sel, IdentifierType::HD_STATION_ID_EXT, kValueForNotFoundIdentifier);
+ hdSidExt >>= 32; // Station ID number
+ return hdSidExt & 0xF; // HD Radio subchannel
+}
+
+uint32_t getHdFrequency(const ProgramSelector& sel) {
+ int64_t hdSidExt = getId(sel, IdentifierType::HD_STATION_ID_EXT, kValueForNotFoundIdentifier);
+ if (hdSidExt == kValueForNotFoundIdentifier) {
+ return kValueForNotFoundIdentifier;
+ }
+ return static_cast<uint32_t>((hdSidExt >> 36) & 0x3FFFF); // HD Radio subchannel
+}
+
+bool hasAmFmFrequency(const ProgramSelector& sel) {
+ return hasId(sel, IdentifierType::AMFM_FREQUENCY_KHZ) ||
+ sel.primaryId.type == IdentifierType::HD_STATION_ID_EXT;
+}
+
+uint32_t getAmFmFrequency(const ProgramSelector& sel) {
+ if (hasId(sel, IdentifierType::AMFM_FREQUENCY_KHZ)) {
+ return static_cast<uint32_t>(getId(sel, IdentifierType::AMFM_FREQUENCY_KHZ));
+ }
+ return getHdFrequency(sel);
+}
+
bool parseArgInt(const std::string& s, int* out) {
return ::android::base::ParseInt(s, out);
}
diff --git a/camera/device/aidl/Android.bp b/camera/device/aidl/Android.bp
index 1a665fb..4115c65 100644
--- a/camera/device/aidl/Android.bp
+++ b/camera/device/aidl/Android.bp
@@ -11,7 +11,7 @@
name: "android.hardware.camera.device",
vendor_available: true,
srcs: ["android/hardware/camera/device/*.aidl"],
- frozen: true,
+ frozen: false,
stability: "vintf",
imports: [
"android.hardware.common-V2",
diff --git a/camera/device/aidl/aidl_api/android.hardware.camera.device/current/android/hardware/camera/device/ConfigureStreamsRet.aidl b/camera/device/aidl/aidl_api/android.hardware.camera.device/current/android/hardware/camera/device/ConfigureStreamsRet.aidl
new file mode 100644
index 0000000..5535a30
--- /dev/null
+++ b/camera/device/aidl/aidl_api/android.hardware.camera.device/current/android/hardware/camera/device/ConfigureStreamsRet.aidl
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2023 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.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+// the interface (from the latest frozen version), the build system will
+// prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.hardware.camera.device;
+@VintfStability
+parcelable ConfigureStreamsRet {
+ android.hardware.camera.device.HalStream[] halStreams;
+ boolean enableHalBufferManager = false;
+}
diff --git a/camera/device/aidl/aidl_api/android.hardware.camera.device/current/android/hardware/camera/device/ICameraDevice.aidl b/camera/device/aidl/aidl_api/android.hardware.camera.device/current/android/hardware/camera/device/ICameraDevice.aidl
index 51c6067..f73483a 100644
--- a/camera/device/aidl/aidl_api/android.hardware.camera.device/current/android/hardware/camera/device/ICameraDevice.aidl
+++ b/camera/device/aidl/aidl_api/android.hardware.camera.device/current/android/hardware/camera/device/ICameraDevice.aidl
@@ -43,4 +43,7 @@
void setTorchMode(boolean on);
void turnOnTorchWithStrengthLevel(int torchStrength);
int getTorchStrengthLevel();
+ android.hardware.camera.device.CameraMetadata constructDefaultRequestSettings(in android.hardware.camera.device.RequestTemplate type);
+ boolean isStreamCombinationWithSettingsSupported(in android.hardware.camera.device.StreamConfiguration streams);
+ android.hardware.camera.device.CameraMetadata getSessionCharacteristics(in android.hardware.camera.device.StreamConfiguration sessionConfig);
}
diff --git a/camera/device/aidl/aidl_api/android.hardware.camera.device/current/android/hardware/camera/device/ICameraDeviceSession.aidl b/camera/device/aidl/aidl_api/android.hardware.camera.device/current/android/hardware/camera/device/ICameraDeviceSession.aidl
index 2196d37..b6ae734 100644
--- a/camera/device/aidl/aidl_api/android.hardware.camera.device/current/android/hardware/camera/device/ICameraDeviceSession.aidl
+++ b/camera/device/aidl/aidl_api/android.hardware.camera.device/current/android/hardware/camera/device/ICameraDeviceSession.aidl
@@ -45,4 +45,5 @@
oneway void signalStreamFlush(in int[] streamIds, in int streamConfigCounter);
android.hardware.camera.device.ICameraOfflineSession switchToOffline(in int[] streamsToKeep, out android.hardware.camera.device.CameraOfflineSessionInfo offlineSessionInfo);
void repeatingRequestEnd(in int frameNumber, in int[] streamIds);
+ android.hardware.camera.device.ConfigureStreamsRet configureStreamsV2(in android.hardware.camera.device.StreamConfiguration requestedConfiguration);
}
diff --git a/camera/device/aidl/android/hardware/camera/device/ConfigureStreamsRet.aidl b/camera/device/aidl/android/hardware/camera/device/ConfigureStreamsRet.aidl
new file mode 100644
index 0000000..8f462ec
--- /dev/null
+++ b/camera/device/aidl/android/hardware/camera/device/ConfigureStreamsRet.aidl
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2023 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.camera.device;
+
+import android.hardware.camera.device.HalStream;
+
+/**
+ * ConfigureStreamsRet.
+ *
+ * Parcelable returned by the 'configureStreamsV2' call.
+ * This contains information which informs the camera framework
+ * about properties of each stream configured and also whether the
+ * the hal buffer manager must be used for the session configured.
+ */
+@VintfStability
+parcelable ConfigureStreamsRet {
+ /**
+ * A vector of HalStream Parcelables, which contain information
+ * about the stream parameters desired by the HAL such as usage flags,
+ * overridden format, maximum buffers etc.
+ */
+ HalStream[] halStreams;
+ /**
+ * A boolean informing the camera framework whether the HAL buffer manager
+ * must be used for the session configured.
+ */
+ boolean enableHalBufferManager = false;
+}
diff --git a/camera/device/aidl/android/hardware/camera/device/ICameraDevice.aidl b/camera/device/aidl/android/hardware/camera/device/ICameraDevice.aidl
index f940000..3a1d762 100644
--- a/camera/device/aidl/android/hardware/camera/device/ICameraDevice.aidl
+++ b/camera/device/aidl/android/hardware/camera/device/ICameraDevice.aidl
@@ -21,6 +21,7 @@
import android.hardware.camera.device.ICameraDeviceCallback;
import android.hardware.camera.device.ICameraDeviceSession;
import android.hardware.camera.device.ICameraInjectionSession;
+import android.hardware.camera.device.RequestTemplate;
import android.hardware.camera.device.StreamConfiguration;
import android.os.ParcelFileDescriptor;
@@ -346,4 +347,122 @@
*
*/
int getTorchStrengthLevel();
+
+ /**
+ * constructDefaultRequestSettings:
+ *
+ * This is the same as ICameraDeviceSession.constructDefaultRequestSettings, with
+ * the exception that it can be called before the ICameraDevice.open call.
+ *
+ * @param type The requested template CaptureRequest type to create the default settings for.
+ *
+ * @return capture settings for the requested use case.
+ *
+ */
+ CameraMetadata constructDefaultRequestSettings(in RequestTemplate type);
+
+ /**
+ * isStreamCombinationWithSettingsSupported:
+ *
+ * This is the same as isStreamCombinationSupported with below exceptions:
+ *
+ * 1. The input StreamConfiguration parameter may contain session parameters
+ * supported by this camera device. When checking if the particular StreamConfiguration
+ * is supported, the camera HAL must take the session parameters into consideration.
+ *
+ * 2. For version 3 of this interface, the camera compliance test will verify that
+ * isStreamCombinationWithSettingsSupported behaves properly for all combinations of
+ * below features. This function must return true for all supported combinations,
+ * and return false for non-supported feature combinations. The list of features
+ * required may grow in future versions.
+ *
+ * - Stream Combinations (a subset of LEGACY device mandatory stream combinations):
+ * {
+ * // 4:3 16:9
+ * // S1440P: 1920 x 1440 2560 x 1440
+ * // S1080P: 1440 x 1080 1920 x 1080
+ * // S720P: 960 x 720 1280 x 720
+ *
+ * // Simple preview, GPU video processing, or no-preview video recording
+ * {PRIV, MAXIMUM},
+ * {PRIV, PREVIEW},
+ * {PRIV, S1440P},
+ * {PRIV, S1080P},
+ * {PRIV, S720P},
+ * // In-application video/image processing
+ * {YUV, MAXIMUM},
+ * {YUV, PREVIEW},
+ * {YUV, S1440P},
+ * {YUV, S1080P},
+ * {YUV, S720P},
+ * // Standard still imaging.
+ * {PRIV, PREVIEW, JPEG, MAXIMUM},
+ * {PRIV, S1440P, JPEG, MAXIMUM},
+ * {PRIV, S1080P, JPEG, MAXIMUM},
+ * {PRIV, S720P, JPEG, MAXIMUM},
+ * {PRIV, S1440P, JPEG, S1440P},
+ * {PRIV, S1080P, JPEG, S1080P},
+ * {PRIV, S720P, JPEG, S1080P},
+ * // In-app processing plus still capture.
+ * {YUV, PREVIEW, JPEG, MAXIMUM},
+ * {YUV, S1440P, JPEG, MAXIMUM},
+ * {YUV, S1080P, JPEG, MAXIMUM},
+ * {YUV, S720P, JPEG, MAXIMUM},
+ * // Standard recording.
+ * {PRIV, PREVIEW, PRIV, PREVIEW},
+ * {PRIV, S1440P, PRIV, S1440P},
+ * {PRIV, S1080P, PRIV, S1080P},
+ * {PRIV, S720P, PRIV, S720P},
+ * // Preview plus in-app processing.
+ * {PRIV, PREVIEW, YUV, PREVIEW},
+ * {PRIV, S1440P, YUV, S1440P},
+ * {PRIV, S1080P, YUV, S1080P},
+ * {PRIV, S720P, YUV, S720P},
+ * }
+ * - VIDEO_STABILIZATION_MODES: {OFF, PREVIEW}
+ * - AE_TARGET_FPS_RANGE: {{*, 30}, {*, 60}}
+ * - DYNAMIC_RANGE_PROFILE: {STANDARD, HLG10}
+ *
+ * Note: If a combination contains a S1440P, S1080P, or S720P stream,
+ * both 4:3 and 16:9 aspect ratio will be considered. For example, for the
+ * stream combination of {PRIV, S1440P, JPEG, MAXIMUM}, and if MAXIMUM ==
+ * 4032 x 3024, the camera compliance test will verify both
+ * {PRIV, 1920 x 1440, JPEG, 4032 x 3024} and {PRIV, 2560 x 1440, JPEG, 4032 x 2268}.
+ *
+ * @param streams The StreamConfiguration to be tested, with optional session parameters.
+ *
+ * @return true in case the stream combination is supported, false otherwise.
+ *
+ */
+ boolean isStreamCombinationWithSettingsSupported(in StreamConfiguration streams);
+
+ /**
+ * getSessionCharacteristics
+ *
+ * Gets the session characteristics associated with a particular session
+ * configuration by the CameraDevice.
+ *
+ * For Android 15, the characteristics which need to be set are:
+ * - ANDROID_CONTROL_ZOOM_RATIO_RANGE
+ *
+ * A service specific error will be returned on the following conditions
+ * INTERNAL_ERROR:
+ * The camera device cannot be opened due to an internal
+ * error.
+ * CAMERA_DISCONNECTED:
+ * An external camera device has been disconnected, and is no longer
+ * available. This camera device interface is now stale, and a new
+ * instance must be acquired if the device is reconnected. All
+ * subsequent calls on this interface must return
+ * CAMERA_DISCONNECTED.
+ * ILLEGAL_ARGUMENT:
+ * If the given session configuration is not supported.
+ *
+ * @param sessionConfig: The session configuration for which the
+ * characteristics are being fetched.
+ *
+ * @return The static metadata for this particular session config, or an
+ * empty metadata structure if a service specific error is returned.
+ */
+ CameraMetadata getSessionCharacteristics(in StreamConfiguration sessionConfig);
}
diff --git a/camera/device/aidl/android/hardware/camera/device/ICameraDeviceSession.aidl b/camera/device/aidl/android/hardware/camera/device/ICameraDeviceSession.aidl
index 885c71a..ffc1a11 100644
--- a/camera/device/aidl/android/hardware/camera/device/ICameraDeviceSession.aidl
+++ b/camera/device/aidl/android/hardware/camera/device/ICameraDeviceSession.aidl
@@ -20,6 +20,7 @@
import android.hardware.camera.device.CameraMetadata;
import android.hardware.camera.device.CameraOfflineSessionInfo;
import android.hardware.camera.device.CaptureRequest;
+import android.hardware.camera.device.ConfigureStreamsRet;
import android.hardware.camera.device.HalStream;
import android.hardware.camera.device.ICameraOfflineSession;
import android.hardware.camera.device.RequestTemplate;
@@ -88,6 +89,13 @@
* with processCaptureResult (and its respective releaseFence has been
* signaled) the framework may free or reuse it at any time.
*
+ * This method wil only be called by the framework if
+ * ANDROID_INFO_SUPPORTED_BUFFER_MANAGEMENT_VERSION is either not advertised or is
+ * ANDROID_INFO_SUPPORTED_BUFFER_MANAGEMENT_VERSION_AIDL. If the value of
+ * ANDROID_INFO_SUPPORTED_BUFFER_MANAGEMENT_VERSION is
+ * ANDROID_INFO_SUPPORTED_BUFFER_MANAGEMENT_VERSION_SESSION_CONFIGURABLE, configureStreamsV2
+ * will be called instead.
+ *
* ------------------------------------------------------------------------
*
* Preconditions:
@@ -386,8 +394,8 @@
* error.
* @return true in case the stream reconfiguration is required, false otherwise.
*/
- boolean isReconfigurationRequired(in CameraMetadata oldSessionParams,
- in CameraMetadata newSessionParams);
+ boolean isReconfigurationRequired(
+ in CameraMetadata oldSessionParams, in CameraMetadata newSessionParams);
/**
* processCaptureRequest:
@@ -576,4 +584,29 @@
*/
void repeatingRequestEnd(in int frameNumber, in int[] streamIds);
+ /**
+ *
+ * configureStreamsV2:
+ *
+ * Performs the same function as 'configureStreams'. This function returns a
+ * 'ConfigureStreamsRet' Parcelable. This tells the framework about the desired stream
+ * parameters such as usage flags, maximum buffers, overridden format etc. It also informs
+ * camera framework whether the HAL will use the HAL buffer manager APIs 'requestStreamBuffers'
+ * and 'returnStreamBuffers' to request and return buffers to the framework.
+ *
+ * This method is only supported if
+ * ANDROID_INFO_SUPPORTED_BUFFER_MANAGEMENT_VERSION is
+ * ANDROID_INFO_SUPPORTED_BUFFER_MANAGEMENT_VERSION_SESSION_CONFIGURABLE. It must not be
+ * called by the camera framework if it isn't supported. That is, the framework will only
+ * ever call one of 'configureStreams' or 'configureStreamsV2' depending on the value of
+ * ANDROID_INFO_SUPPORTED_BUFFER_MANAGEMENT_VERSION.
+ *
+ * @param requestedConfiguration The stream configuration requested by the camera framework to
+ * be configured by the camera HAL.
+ * @return A ConfigureStreamsRet Parcelable containing a vector of HalStreams and a boolean
+ * specifying whether the HAL buffer manager must be used for this session
+ * configuration.
+ *
+ */
+ ConfigureStreamsRet configureStreamsV2(in StreamConfiguration requestedConfiguration);
}
diff --git a/camera/metadata/aidl/aidl_api/android.hardware.camera.metadata/current/android/hardware/camera/metadata/CameraMetadataTag.aidl b/camera/metadata/aidl/aidl_api/android.hardware.camera.metadata/current/android/hardware/camera/metadata/CameraMetadataTag.aidl
index 0290aef..b04e486 100644
--- a/camera/metadata/aidl/aidl_api/android.hardware.camera.metadata/current/android/hardware/camera/metadata/CameraMetadataTag.aidl
+++ b/camera/metadata/aidl/aidl_api/android.hardware.camera.metadata/current/android/hardware/camera/metadata/CameraMetadataTag.aidl
@@ -283,6 +283,8 @@
ANDROID_STATISTICS_OIS_TIMESTAMPS,
ANDROID_STATISTICS_OIS_X_SHIFTS,
ANDROID_STATISTICS_OIS_Y_SHIFTS,
+ ANDROID_STATISTICS_LENS_INTRINSIC_TIMESTAMPS,
+ ANDROID_STATISTICS_LENS_INTRINSIC_SAMPLES,
ANDROID_STATISTICS_INFO_AVAILABLE_FACE_DETECT_MODES = android.hardware.camera.metadata.CameraMetadataSectionStart.ANDROID_STATISTICS_INFO_START /* 1179648 */,
ANDROID_STATISTICS_INFO_HISTOGRAM_BUCKET_COUNT,
ANDROID_STATISTICS_INFO_MAX_FACE_COUNT,
@@ -329,6 +331,7 @@
ANDROID_LOGICAL_MULTI_CAMERA_PHYSICAL_IDS = android.hardware.camera.metadata.CameraMetadataSectionStart.ANDROID_LOGICAL_MULTI_CAMERA_START /* 1703936 */,
ANDROID_LOGICAL_MULTI_CAMERA_SENSOR_SYNC_TYPE,
ANDROID_LOGICAL_MULTI_CAMERA_ACTIVE_PHYSICAL_ID,
+ ANDROID_LOGICAL_MULTI_CAMERA_ACTIVE_PHYSICAL_SENSOR_CROP_REGION,
ANDROID_DISTORTION_CORRECTION_MODE = android.hardware.camera.metadata.CameraMetadataSectionStart.ANDROID_DISTORTION_CORRECTION_START /* 1769472 */,
ANDROID_DISTORTION_CORRECTION_AVAILABLE_MODES,
ANDROID_HEIC_AVAILABLE_HEIC_STREAM_CONFIGURATIONS = android.hardware.camera.metadata.CameraMetadataSectionStart.ANDROID_HEIC_START /* 1835008 */,
diff --git a/camera/metadata/aidl/aidl_api/android.hardware.camera.metadata/current/android/hardware/camera/metadata/InfoSupportedBufferManagementVersion.aidl b/camera/metadata/aidl/aidl_api/android.hardware.camera.metadata/current/android/hardware/camera/metadata/InfoSupportedBufferManagementVersion.aidl
index 7303ff5..2c31cff 100644
--- a/camera/metadata/aidl/aidl_api/android.hardware.camera.metadata/current/android/hardware/camera/metadata/InfoSupportedBufferManagementVersion.aidl
+++ b/camera/metadata/aidl/aidl_api/android.hardware.camera.metadata/current/android/hardware/camera/metadata/InfoSupportedBufferManagementVersion.aidl
@@ -39,4 +39,5 @@
@Backing(type="int") @VintfStability
enum InfoSupportedBufferManagementVersion {
ANDROID_INFO_SUPPORTED_BUFFER_MANAGEMENT_VERSION_AIDL_DEVICE,
+ ANDROID_INFO_SUPPORTED_BUFFER_MANAGEMENT_VERSION_SESSION_CONFIGURABLE,
}
diff --git a/camera/metadata/aidl/android/hardware/camera/metadata/CameraMetadataTag.aidl b/camera/metadata/aidl/android/hardware/camera/metadata/CameraMetadataTag.aidl
index cfc9907..2fefce0 100644
--- a/camera/metadata/aidl/android/hardware/camera/metadata/CameraMetadataTag.aidl
+++ b/camera/metadata/aidl/android/hardware/camera/metadata/CameraMetadataTag.aidl
@@ -1868,6 +1868,18 @@
*/
ANDROID_STATISTICS_OIS_Y_SHIFTS,
/**
+ * android.statistics.lensIntrinsicTimestamps [dynamic, int64[], ndk_public]
+ *
+ * <p>An array of timestamps of lens intrinsics samples, in nanoseconds.</p>
+ */
+ ANDROID_STATISTICS_LENS_INTRINSIC_TIMESTAMPS,
+ /**
+ * android.statistics.lensIntrinsicSamples [dynamic, float[], ndk_public]
+ *
+ * <p>An array of intra-frame lens intrinsics.</p>
+ */
+ ANDROID_STATISTICS_LENS_INTRINSIC_SAMPLES,
+ /**
* android.statistics.info.availableFaceDetectModes [static, byte[], public]
*
* <p>List of face detection modes for ANDROID_STATISTICS_FACE_DETECT_MODE that are
@@ -2241,6 +2253,13 @@
*/
ANDROID_LOGICAL_MULTI_CAMERA_ACTIVE_PHYSICAL_ID,
/**
+ * android.logicalMultiCamera.activePhysicalSensorCropRegion [dynamic, int32[], public]
+ *
+ * <p>The current region of the active physical sensor that will be read out for this
+ * capture.</p>
+ */
+ ANDROID_LOGICAL_MULTI_CAMERA_ACTIVE_PHYSICAL_SENSOR_CROP_REGION,
+ /**
* android.distortionCorrection.mode [dynamic, enum, public]
*
* <p>Mode of operation for the lens distortion correction block.</p>
diff --git a/camera/metadata/aidl/android/hardware/camera/metadata/InfoSupportedBufferManagementVersion.aidl b/camera/metadata/aidl/android/hardware/camera/metadata/InfoSupportedBufferManagementVersion.aidl
index 9522377..964d079 100644
--- a/camera/metadata/aidl/android/hardware/camera/metadata/InfoSupportedBufferManagementVersion.aidl
+++ b/camera/metadata/aidl/android/hardware/camera/metadata/InfoSupportedBufferManagementVersion.aidl
@@ -30,4 +30,5 @@
@Backing(type="int")
enum InfoSupportedBufferManagementVersion {
ANDROID_INFO_SUPPORTED_BUFFER_MANAGEMENT_VERSION_AIDL_DEVICE,
+ ANDROID_INFO_SUPPORTED_BUFFER_MANAGEMENT_VERSION_SESSION_CONFIGURABLE,
}
diff --git a/camera/provider/aidl/Android.bp b/camera/provider/aidl/Android.bp
index 35ec976..f6b00a1 100644
--- a/camera/provider/aidl/Android.bp
+++ b/camera/provider/aidl/Android.bp
@@ -14,10 +14,10 @@
"android/hardware/camera/provider/*.aidl",
],
imports: [
- "android.hardware.camera.device-V2",
+ "android.hardware.camera.device-V3",
"android.hardware.camera.common-V1",
],
- frozen: true,
+ frozen: false,
stability: "vintf",
backend: {
java: {
diff --git a/camera/provider/aidl/vts/Android.bp b/camera/provider/aidl/vts/Android.bp
index cfcaec5..f9305bb 100644
--- a/camera/provider/aidl/vts/Android.bp
+++ b/camera/provider/aidl/vts/Android.bp
@@ -60,9 +60,9 @@
static_libs: [
"android.hardware.camera.common@1.0-helper",
"android.hardware.camera.common-V1-ndk",
- "android.hardware.camera.device-V2-ndk",
+ "android.hardware.camera.device-V3-ndk",
"android.hardware.camera.metadata-V2-ndk",
- "android.hardware.camera.provider-V2-ndk",
+ "android.hardware.camera.provider-V3-ndk",
"android.hidl.allocator@1.0",
"libgrallocusage",
"libhidlmemory",
diff --git a/camera/provider/aidl/vts/VtsAidlHalCameraProvider_TargetTest.cpp b/camera/provider/aidl/vts/VtsAidlHalCameraProvider_TargetTest.cpp
index def6233..e335853 100644
--- a/camera/provider/aidl/vts/VtsAidlHalCameraProvider_TargetTest.cpp
+++ b/camera/provider/aidl/vts/VtsAidlHalCameraProvider_TargetTest.cpp
@@ -500,6 +500,12 @@
ASSERT_TRUE(ret.isOk());
ASSERT_NE(device, nullptr);
+ int32_t interfaceVersion;
+ ret = device->getInterfaceVersion(&interfaceVersion);
+ ASSERT_TRUE(ret.isOk());
+ bool supportFeatureCombinationQuery =
+ (interfaceVersion >= CAMERA_DEVICE_API_MINOR_VERSION_3);
+
std::shared_ptr<EmptyDeviceCb> cb = ndk::SharedRefBase::make<EmptyDeviceCb>();
ret = device->open(cb, &mSession);
ALOGI("device::open returns status:%d:%d", ret.getExceptionCode(),
@@ -533,6 +539,34 @@
} else {
ASSERT_EQ(0u, rawMetadata.metadata.size());
}
+
+ if (flags::feature_combination_query()) {
+ if (supportFeatureCombinationQuery) {
+ CameraMetadata rawMetadata2;
+ ndk::ScopedAStatus ret2 =
+ device->constructDefaultRequestSettings(reqTemplate, &rawMetadata2);
+
+ // TODO: Do not allow OPERATION_NOT_SUPPORTED once HAL
+ // implementation is in place.
+ if (static_cast<Status>(ret2.getServiceSpecificError()) !=
+ Status::OPERATION_NOT_SUPPORTED) {
+ ASSERT_EQ(ret.isOk(), ret2.isOk());
+ ASSERT_EQ(ret.getStatus(), ret2.getStatus());
+
+ ASSERT_EQ(rawMetadata.metadata.size(), rawMetadata2.metadata.size());
+ if (ret2.isOk()) {
+ const camera_metadata_t* metadata =
+ (camera_metadata_t*)rawMetadata2.metadata.data();
+ size_t expectedSize = rawMetadata2.metadata.size();
+ int result =
+ validate_camera_metadata_structure(metadata, &expectedSize);
+ ASSERT_TRUE((result == 0) ||
+ (result == CAMERA_METADATA_VALIDATION_SHIFTED));
+ verifyRequestTemplate(metadata, reqTemplate);
+ }
+ }
+ }
+ }
}
ret = mSession->close();
mSession = nullptr;
@@ -588,8 +622,7 @@
createStreamConfiguration(streams, StreamConfigurationMode::NORMAL_MODE, &config,
jpegBufferSize);
- bool expectStreamCombQuery = (isLogicalMultiCamera(staticMeta) == Status::OK);
- verifyStreamCombination(device, config, /*expectedStatus*/ true, expectStreamCombQuery);
+ verifyStreamCombination(device, config, /*expectedStatus*/ true);
config.streamConfigCounter = streamConfigCounter++;
std::vector<HalStream> halConfigs;
@@ -687,11 +720,7 @@
// Test the stream can actually be configured
for (auto& cti : cameraTestInfos) {
if (cti.session != nullptr) {
- camera_metadata_t* staticMeta =
- reinterpret_cast<camera_metadata_t*>(cti.staticMeta.metadata.data());
- bool expectStreamCombQuery = (isLogicalMultiCamera(staticMeta) == Status::OK);
- verifyStreamCombination(cti.cameraDevice, cti.config, /*expectedStatus*/ true,
- expectStreamCombQuery);
+ verifyStreamCombination(cti.cameraDevice, cti.config, /*expectedStatus*/ true);
}
if (cti.session != nullptr) {
@@ -752,8 +781,7 @@
createStreamConfiguration(streams, StreamConfigurationMode::NORMAL_MODE, &config,
jpegBufferSize);
- verifyStreamCombination(cameraDevice, config, /*expectedStatus*/ false,
- /*expectStreamCombQuery*/ false);
+ verifyStreamCombination(cameraDevice, config, /*expectedStatus*/ false);
config.streamConfigCounter = streamConfigCounter++;
std::vector<HalStream> halConfigs;
@@ -972,8 +1000,7 @@
createStreamConfiguration(streams, StreamConfigurationMode::NORMAL_MODE, &config,
jpegBufferSize);
- verifyStreamCombination(cameraDevice, config, /*expectedStatus*/ true,
- /*expectStreamCombQuery*/ false);
+ verifyStreamCombination(cameraDevice, config, /*expectedStatus*/ true);
config.streamConfigCounter = streamConfigCounter++;
std::vector<HalStream> halConfigs;
@@ -1191,8 +1218,7 @@
createStreamConfiguration(streams, StreamConfigurationMode::NORMAL_MODE, &config,
jpegBufferSize);
config.streamConfigCounter = streamConfigCounter++;
- verifyStreamCombination(cameraDevice, config, /*expectedStatus*/ true,
- /*expectStreamCombQuery*/ false);
+ verifyStreamCombination(cameraDevice, config, /*expectedStatus*/ true);
std::vector<HalStream> halConfigs;
ndk::ScopedAStatus ret = mSession->configureStreams(config, &halConfigs);
@@ -1256,8 +1282,7 @@
createStreamConfiguration(streams, StreamConfigurationMode::CONSTRAINED_HIGH_SPEED_MODE,
&config);
- verifyStreamCombination(cameraDevice, config, /*expectedStatus*/ true,
- /*expectStreamCombQuery*/ false);
+ verifyStreamCombination(cameraDevice, config, /*expectedStatus*/ true);
config.streamConfigCounter = streamConfigCounter++;
std::vector<HalStream> halConfigs;
@@ -1429,8 +1454,7 @@
createStreamConfiguration(streams, StreamConfigurationMode::NORMAL_MODE, &config,
jpegBufferSize);
- verifyStreamCombination(cameraDevice, config, /*expectedStatus*/ true,
- /*expectStreamCombQuery*/ false);
+ verifyStreamCombination(cameraDevice, config, /*expectedStatus*/ true);
config.streamConfigCounter = streamConfigCounter++;
std::vector<HalStream> halConfigs;
diff --git a/camera/provider/aidl/vts/camera_aidl_test.cpp b/camera/provider/aidl/vts/camera_aidl_test.cpp
index e5bf637..8e72b3f 100644
--- a/camera/provider/aidl/vts/camera_aidl_test.cpp
+++ b/camera/provider/aidl/vts/camera_aidl_test.cpp
@@ -30,6 +30,7 @@
#include <aidlcommonsupport/NativeHandle.h>
#include <android/binder_manager.h>
#include <android/binder_process.h>
+#include <com_android_internal_camera_flags.h>
#include <device_cb.h>
#include <empty_device_cb.h>
#include <grallocusage/GrallocUsageConversion.h>
@@ -39,6 +40,7 @@
#include <ui/GraphicBufferAllocator.h>
#include <regex>
#include <typeinfo>
+#include "utils/Errors.h"
using ::aidl::android::hardware::camera::common::CameraDeviceStatus;
using ::aidl::android::hardware::camera::common::TorchModeStatus;
@@ -56,6 +58,8 @@
using ::ndk::SpAIBinder;
namespace {
+namespace flags = com::android::internal::camera::flags;
+
bool parseProviderName(const std::string& serviceDescriptor, std::string* type /*out*/,
uint32_t* id /*out*/) {
if (!type || !id) {
@@ -101,6 +105,8 @@
return true;
}
+namespace flags = com::android::internal::camera::flags;
+
const std::vector<int64_t> kMandatoryUseCases = {
ANDROID_SCALER_AVAILABLE_STREAM_USE_CASES_DEFAULT,
ANDROID_SCALER_AVAILABLE_STREAM_USE_CASES_PREVIEW,
@@ -478,6 +484,38 @@
} else {
ADD_FAILURE() << "Get LOGICAL_MULTI_CAMERA_ACTIVE_PHYSICAL_ID failed!";
}
+
+ if (flags::concert_mode()) {
+ auto ret = find_camera_metadata_ro_entry(
+ metadata, ANDROID_LOGICAL_MULTI_CAMERA_ACTIVE_PHYSICAL_SENSOR_CROP_REGION, &entry);
+ if ((ret == android::OK) && (entry.count > 0)) {
+ ASSERT_TRUE(entry.count == 4);
+ ASSERT_GE(entry.data.i32[0], 0); // Top must be non-negative
+ ASSERT_GE(entry.data.i32[1], 0); // Left must be non-negative
+ ASSERT_GT(entry.data.i32[2], 0); // Width must be positive
+ ASSERT_GT(entry.data.i32[3], 0); // Height must be positive
+ }
+ }
+}
+
+void CameraAidlTest::verifyLensIntrinsicsResult(const std::vector<uint8_t>& resultMetadata) {
+ if (flags::concert_mode()) {
+ camera_metadata_t* metadata = (camera_metadata_t*)resultMetadata.data();
+
+ camera_metadata_ro_entry timestampsEntry, intrinsicsEntry;
+ auto tsRet = find_camera_metadata_ro_entry(
+ metadata, ANDROID_STATISTICS_LENS_INTRINSIC_TIMESTAMPS, ×tampsEntry);
+ auto inRet = find_camera_metadata_ro_entry(
+ metadata, ANDROID_STATISTICS_LENS_INTRINSIC_SAMPLES, &intrinsicsEntry);
+ ASSERT_EQ(tsRet, inRet);
+ ASSERT_TRUE((intrinsicsEntry.count % 5) == 0);
+ ASSERT_EQ(timestampsEntry.count, intrinsicsEntry.count / 5);
+ if (timestampsEntry.count > 0) {
+ for (size_t i = 0; i < timestampsEntry.count - 1; i++) {
+ ASSERT_GE(timestampsEntry.data.i64[i + 1], timestampsEntry.data.i64[i]);
+ }
+ }
+ }
}
Status CameraAidlTest::getPhysicalCameraIds(const camera_metadata_t* staticMeta,
@@ -1350,13 +1388,17 @@
bool hasHalBufferManager =
(0 == retcode && 1 == entry.count &&
entry.data.i32[0] == ANDROID_INFO_SUPPORTED_BUFFER_MANAGEMENT_VERSION_HIDL_DEVICE_3_5);
+ bool sessionHalBufferManager =
+ (0 == retcode && 1 == entry.count &&
+ entry.data.i32[0] ==
+ ANDROID_INFO_SUPPORTED_BUFFER_MANAGEMENT_VERSION_SESSION_CONFIGURABLE);
retcode = find_camera_metadata_ro_entry(
metadata, ANDROID_SCALER_MULTI_RESOLUTION_STREAM_SUPPORTED, &entry);
bool multiResolutionStreamSupported =
(0 == retcode && 1 == entry.count &&
entry.data.u8[0] == ANDROID_SCALER_MULTI_RESOLUTION_STREAM_SUPPORTED_TRUE);
if (multiResolutionStreamSupported) {
- ASSERT_TRUE(hasHalBufferManager);
+ ASSERT_TRUE(hasHalBufferManager || sessionHalBufferManager);
}
std::string version, cameraId;
@@ -1859,17 +1901,32 @@
}
void CameraAidlTest::verifyStreamCombination(const std::shared_ptr<ICameraDevice>& device,
- const StreamConfiguration& config, bool expectedStatus,
- bool expectStreamCombQuery) {
+ const StreamConfiguration& config,
+ bool expectedStatus) {
if (device != nullptr) {
bool streamCombinationSupported;
ScopedAStatus ret =
device->isStreamCombinationSupported(config, &streamCombinationSupported);
- // TODO: Check is unsupported operation is correct.
- ASSERT_TRUE(ret.isOk() ||
- (expectStreamCombQuery && ret.getExceptionCode() == EX_UNSUPPORTED_OPERATION));
- if (ret.isOk()) {
- ASSERT_EQ(expectedStatus, streamCombinationSupported);
+ ASSERT_TRUE(ret.isOk());
+ ASSERT_EQ(expectedStatus, streamCombinationSupported);
+
+ if (flags::feature_combination_query()) {
+ int32_t interfaceVersion;
+ ret = device->getInterfaceVersion(&interfaceVersion);
+ ASSERT_TRUE(ret.isOk());
+ bool supportFeatureCombinationQuery =
+ (interfaceVersion >= CAMERA_DEVICE_API_MINOR_VERSION_3);
+ if (supportFeatureCombinationQuery) {
+ ret = device->isStreamCombinationWithSettingsSupported(config,
+ &streamCombinationSupported);
+ // TODO: Do not allow OPERATION_NOT_SUPPORTED once HAL
+ // implementation is in place.
+ ASSERT_TRUE(ret.isOk() || static_cast<Status>(ret.getServiceSpecificError()) ==
+ Status::OPERATION_NOT_SUPPORTED);
+ if (ret.isOk()) {
+ ASSERT_EQ(expectedStatus, streamCombinationSupported);
+ }
+ }
}
}
}
@@ -2440,6 +2497,28 @@
}
+ndk::ScopedAStatus CameraAidlTest::configureStreams(std::shared_ptr<ICameraDeviceSession>& session,
+ const StreamConfiguration& config,
+ bool sessionHalBufferManager,
+ bool* useHalBufManager,
+ std::vector<HalStream>* halStreams) {
+ auto ret = ndk::ScopedAStatus::ok();
+ ConfigureStreamsRet aidl_return;
+ if (sessionHalBufferManager) {
+ ret = session->configureStreamsV2(config, &aidl_return);
+ } else {
+ ret = session->configureStreams(config, halStreams);
+ }
+ if (!ret.isOk()) {
+ return ret;
+ }
+ if (sessionHalBufferManager) {
+ *useHalBufManager = aidl_return.enableHalBufferManager;
+ *halStreams = std::move(aidl_return.halStreams);
+ }
+ return ndk::ScopedAStatus::ok();
+}
+
void CameraAidlTest::configureSingleStream(
const std::string& name, const std::shared_ptr<ICameraProvider>& provider,
const AvailableStream* previewThreshold, uint64_t bufferUsage, RequestTemplate reqTemplate,
@@ -2494,11 +2573,15 @@
ASSERT_NE(*session, nullptr);
*useHalBufManager = false;
+ bool sessionHalBufferManager = false;
status = find_camera_metadata_ro_entry(
staticMeta, ANDROID_INFO_SUPPORTED_BUFFER_MANAGEMENT_VERSION, &entry);
if ((0 == status) && (entry.count == 1)) {
*useHalBufManager = (entry.data.u8[0] ==
ANDROID_INFO_SUPPORTED_BUFFER_MANAGEMENT_VERSION_HIDL_DEVICE_3_5);
+ sessionHalBufferManager =
+ (entry.data.u8[0] ==
+ ANDROID_INFO_SUPPORTED_BUFFER_MANAGEMENT_VERSION_SESSION_CONFIGURABLE);
}
outputPreviewStreams.clear();
@@ -2557,7 +2640,8 @@
ASSERT_EQ(supported, true);
std::vector<HalStream> halConfigs;
- ret = (*session)->configureStreams(config, &halConfigs);
+ ret = configureStreams(*session, config, sessionHalBufferManager, useHalBufManager,
+ &halConfigs);
ALOGI("configureStreams returns status: %d:%d", ret.getExceptionCode(),
ret.getServiceSpecificError());
ASSERT_TRUE(ret.isOk());
@@ -2853,11 +2937,15 @@
ASSERT_NE(*session, nullptr);
*useHalBufManager = false;
+ bool sessionHalBufferManager = false;
status = find_camera_metadata_ro_entry(
staticMeta, ANDROID_INFO_SUPPORTED_BUFFER_MANAGEMENT_VERSION, &entry);
if ((0 == status) && (entry.count == 1)) {
*useHalBufManager = (entry.data.u8[0] ==
ANDROID_INFO_SUPPORTED_BUFFER_MANAGEMENT_VERSION_HIDL_DEVICE_3_5);
+ sessionHalBufferManager =
+ (entry.data.u8[0] ==
+ ANDROID_INFO_SUPPORTED_BUFFER_MANAGEMENT_VERSION_SESSION_CONFIGURABLE);
}
outputPreviewStreams.clear();
@@ -2912,7 +3000,9 @@
config.streamConfigCounter = streamConfigCounter;
std::vector<HalStream> halConfigs;
- ret = (*session)->configureStreams(config, &halConfigs);
+ ret = configureStreams(*session, config, sessionHalBufferManager, useHalBufManager,
+ &halConfigs);
+
ASSERT_TRUE(ret.isOk());
ASSERT_EQ(physicalIds.size(), halConfigs.size());
*halStreams = halConfigs;
@@ -2992,11 +3082,15 @@
ASSERT_NE(*session, nullptr);
*useHalBufManager = false;
+ bool sessionHalBufferManager = false;
status = find_camera_metadata_ro_entry(
staticMeta, ANDROID_INFO_SUPPORTED_BUFFER_MANAGEMENT_VERSION, &entry);
if ((0 == status) && (entry.count == 1)) {
*useHalBufManager = (entry.data.u8[0] ==
ANDROID_INFO_SUPPORTED_BUFFER_MANAGEMENT_VERSION_HIDL_DEVICE_3_5);
+ sessionHalBufferManager =
+ (entry.data.u8[0] ==
+ ANDROID_INFO_SUPPORTED_BUFFER_MANAGEMENT_VERSION_SESSION_CONFIGURABLE);
}
outputStreams.clear();
@@ -3050,7 +3144,8 @@
ASSERT_TRUE(ret.isOk());
ASSERT_EQ(supported, true);
- ret = (*session)->configureStreams(config, halStreams);
+ ret = configureStreams(*session, config, sessionHalBufferManager, useHalBufManager, halStreams);
+
ASSERT_TRUE(ret.isOk());
if (*useHalBufManager) {
@@ -3434,11 +3529,15 @@
}
*useHalBufManager = false;
+ bool sessionHalBufferManager = false;
status = find_camera_metadata_ro_entry(
staticMeta, ANDROID_INFO_SUPPORTED_BUFFER_MANAGEMENT_VERSION, &entry);
if ((0 == status) && (entry.count == 1)) {
*useHalBufManager = (entry.data.u8[0] ==
ANDROID_INFO_SUPPORTED_BUFFER_MANAGEMENT_VERSION_HIDL_DEVICE_3_5);
+ sessionHalBufferManager =
+ (entry.data.u8[0] ==
+ ANDROID_INFO_SUPPORTED_BUFFER_MANAGEMENT_VERSION_SESSION_CONFIGURABLE);
}
auto st = getJpegBufferSize(staticMeta, jpegBufferSize);
@@ -3491,7 +3590,8 @@
StreamConfiguration config = {streams, StreamConfigurationMode::NORMAL_MODE, CameraMetadata()};
- (*session)->configureStreams(config, halStreams);
+ ret = configureStreams(*session, config, sessionHalBufferManager, useHalBufManager, halStreams);
+
ASSERT_TRUE(ret.isOk());
if (*useHalBufManager) {
diff --git a/camera/provider/aidl/vts/camera_aidl_test.h b/camera/provider/aidl/vts/camera_aidl_test.h
index 0ebd4ef..b51544f 100644
--- a/camera/provider/aidl/vts/camera_aidl_test.h
+++ b/camera/provider/aidl/vts/camera_aidl_test.h
@@ -64,6 +64,7 @@
using ::aidl::android::hardware::camera::device::BufferRequestStatus;
using ::aidl::android::hardware::camera::device::CameraMetadata;
using ::aidl::android::hardware::camera::device::CaptureResult;
+using ::aidl::android::hardware::camera::device::ConfigureStreamsRet;
using ::aidl::android::hardware::camera::device::ErrorCode;
using ::aidl::android::hardware::camera::device::HalStream;
using ::aidl::android::hardware::camera::device::ICameraDevice;
@@ -201,6 +202,11 @@
int32_t* partialResultCount /*out*/, std::shared_ptr<DeviceCb>* outCb /*out*/,
int32_t* jpegBufferSize /*out*/, bool* useHalBufManager /*out*/);
+ ndk::ScopedAStatus configureStreams(std::shared_ptr<ICameraDeviceSession>& session,
+ const StreamConfiguration& config,
+ bool sessionHalBufferManager, bool* useHalBufManager,
+ std::vector<HalStream>* halStreams);
+
void configureStreams(
const std::string& name, const std::shared_ptr<ICameraProvider>& provider,
PixelFormat format, std::shared_ptr<ICameraDeviceSession>* session /*out*/,
@@ -273,12 +279,13 @@
static void verifySettingsOverrideCharacteristics(const camera_metadata_t* metadata);
static void verifyStreamCombination(const std::shared_ptr<ICameraDevice>& device,
- const StreamConfiguration& config, bool expectedStatus,
- bool expectStreamCombQuery);
+ const StreamConfiguration& config, bool expectedStatus);
static void verifyLogicalCameraResult(const camera_metadata_t* staticMetadata,
const std::vector<uint8_t>& resultMetadata);
+ static void verifyLensIntrinsicsResult(const std::vector<uint8_t>& resultMetadata);
+
static void verifyBuffersReturned(const std::shared_ptr<ICameraDeviceSession>& session,
int32_t streamId, const std::shared_ptr<DeviceCb>& cb,
uint32_t streamConfigCounter = 0);
@@ -617,6 +624,7 @@
// device@<major>.<minor>/<type>/id
const char* kDeviceNameRE = "device@([0-9]+\\.[0-9]+)/\\s+/(.+)";
const std::string CAMERA_DEVICE_API_VERSION_1 = "1.1";
+const int32_t CAMERA_DEVICE_API_MINOR_VERSION_3 = 3;
const int32_t kMaxVideoWidth = 4096;
const int32_t kMaxVideoHeight = 2160;
diff --git a/camera/provider/aidl/vts/device_cb.cpp b/camera/provider/aidl/vts/device_cb.cpp
index 7e0969a..2c11d3f 100644
--- a/camera/provider/aidl/vts/device_cb.cpp
+++ b/camera/provider/aidl/vts/device_cb.cpp
@@ -388,15 +388,16 @@
// Verify logical camera result metadata
bool isLogicalCamera =
Status::OK == CameraAidlTest::isLogicalMultiCamera(staticMetadataBuffer);
+ camera_metadata_t* collectedMetadata =
+ const_cast<camera_metadata_t*>(request->collectedResult.getAndLock());
+ uint8_t* rawMetadata = reinterpret_cast<uint8_t*>(collectedMetadata);
+ std::vector metadata =
+ std::vector(rawMetadata, rawMetadata + get_camera_metadata_size(collectedMetadata));
if (isLogicalCamera) {
- camera_metadata_t* collectedMetadata =
- const_cast<camera_metadata_t*>(request->collectedResult.getAndLock());
- uint8_t* rawMetadata = reinterpret_cast<uint8_t*>(collectedMetadata);
- std::vector metadata = std::vector(
- rawMetadata, rawMetadata + get_camera_metadata_size(collectedMetadata));
CameraAidlTest::verifyLogicalCameraResult(staticMetadataBuffer, metadata);
- request->collectedResult.unlock(collectedMetadata);
}
+ CameraAidlTest::verifyLensIntrinsicsResult(metadata);
+ request->collectedResult.unlock(collectedMetadata);
}
uint32_t numBuffersReturned = results.outputBuffers.size();
diff --git a/compatibility_matrices/Android.bp b/compatibility_matrices/Android.bp
index 712f28a..9bee3b9 100644
--- a/compatibility_matrices/Android.bp
+++ b/compatibility_matrices/Android.bp
@@ -31,7 +31,6 @@
"kernel_config_q_4.14",
"kernel_config_q_4.19",
],
- core_hals: "only",
}
vintf_compatibility_matrix {
@@ -45,7 +44,6 @@
"kernel_config_r_4.19",
"kernel_config_r_5.4",
],
- core_hals: "only",
}
vintf_compatibility_matrix {
@@ -59,7 +57,6 @@
"kernel_config_s_5.4",
"kernel_config_s_5.10",
],
- core_hals: "only",
}
vintf_compatibility_matrix {
@@ -72,7 +69,6 @@
"kernel_config_t_5.10",
"kernel_config_t_5.15",
],
- core_hals: "only",
}
vintf_compatibility_matrix {
@@ -85,7 +81,6 @@
"kernel_config_u_5.15",
"kernel_config_u_6.1",
],
- core_hals: "only",
}
vintf_compatibility_matrix {
@@ -95,8 +90,7 @@
"compatibility_matrix.9.xml",
],
kernel_configs: [
- "kernel_config_v_5.15",
"kernel_config_v_6.1",
+ "kernel_config_v_6.6",
],
- core_hals: "only",
}
diff --git a/compatibility_matrices/build/vintf_compatibility_matrix.go b/compatibility_matrices/build/vintf_compatibility_matrix.go
index 4f342b2..c72cbde 100644
--- a/compatibility_matrices/build/vintf_compatibility_matrix.go
+++ b/compatibility_matrices/build/vintf_compatibility_matrix.go
@@ -35,10 +35,10 @@
pctx = android.NewPackageContext("android/vintf")
assembleVintfRule = pctx.AndroidStaticRule("assemble_vintf", blueprint.RuleParams{
- Command: `${assembleVintfCmd} -i ${inputs} -o ${out} ${extraParams}`,
+ Command: `${assembleVintfCmd} -i ${inputs} -o ${out}`,
CommandDeps: []string{"${assembleVintfCmd}"},
Description: "assemble_vintf -i ${inputs}",
- }, "inputs", "extraParams")
+ }, "inputs")
xmllintXsd = pctx.AndroidStaticRule("xmllint-xsd", blueprint.RuleParams{
Command: `$XmlLintCmd --quiet --schema $xsd $in > /dev/null && touch -a $out`,
@@ -64,13 +64,6 @@
// list of kernel_config modules to be combined to final output
Kernel_configs []string
-
- // Default is "default" for compatibility matrices on /vendor
- // and /odm, and "disallow" for compatibility matrices on /system,
- // /product, and /system_ext.
- // If value is "only", only android.* HALs are allowed. If value
- // is "disallow", none of android.* HALs are allowed.
- Core_hals *string
}
type vintfCompatibilityMatrixRule struct {
@@ -173,8 +166,7 @@
Implicits: inputPaths,
Output: g.genFile,
Args: map[string]string{
- "inputs": strings.Join(inputPaths.Strings(), ":"),
- "extraParams": strings.Join(g.getExtraParams(), " "),
+ "inputs": strings.Join(inputPaths.Strings(), ":"),
},
})
g.generateValidateBuildAction(ctx, g.genFile, schema.Path())
@@ -199,23 +191,3 @@
},
}
}
-
-// Return extra parameters to assemble_vintf.
-func (g *vintfCompatibilityMatrixRule) getExtraParams() []string {
- var extraParams []string
-
- coreHalsStrategy := proptools.StringDefault(
- g.properties.Core_hals,
- g.defaultCoreHalsStrategy(),
- )
- extraParams = append(extraParams, "--core-hals", proptools.ShellEscape(coreHalsStrategy))
- return extraParams
-}
-
-func (g *vintfCompatibilityMatrixRule) defaultCoreHalsStrategy() string {
- // TODO(b/290408770): default to "disallow" for FCMs
-
- // For Device (vendor, odm) compatibility matrix, default is
- // to not check anything.
- return "default"
-}
diff --git a/compatibility_matrices/compatibility_matrix.9.xml b/compatibility_matrices/compatibility_matrix.9.xml
index 2f33a28..33e5a7d 100644
--- a/compatibility_matrices/compatibility_matrix.9.xml
+++ b/compatibility_matrices/compatibility_matrix.9.xml
@@ -157,6 +157,14 @@
</interface>
</hal>
<hal format="aidl" optional="true">
+ <name>android.hardware.bluetooth.finder</name>
+ <version>1</version>
+ <interface>
+ <name>IBluetoothFinder</name>
+ <instance>default</instance>
+ </interface>
+ </hal>
+ <hal format="aidl" optional="true">
<name>android.hardware.boot</name>
<interface>
<name>IBootControl</name>
@@ -173,7 +181,7 @@
</hal>
<hal format="aidl" optional="true" updatable-via-apex="true">
<name>android.hardware.camera.provider</name>
- <version>1-2</version>
+ <version>1-3</version>
<interface>
<name>ICameraProvider</name>
<regex-instance>[^/]+/[0-9]+</regex-instance>
diff --git a/graphics/common/aidl/aidl_api/android.hardware.graphics.common/current/android/hardware/graphics/common/DisplayHotplugEvent.aidl b/graphics/common/aidl/aidl_api/android.hardware.graphics.common/current/android/hardware/graphics/common/DisplayHotplugEvent.aidl
new file mode 100644
index 0000000..63dca0a
--- /dev/null
+++ b/graphics/common/aidl/aidl_api/android.hardware.graphics.common/current/android/hardware/graphics/common/DisplayHotplugEvent.aidl
@@ -0,0 +1,42 @@
+/**
+ * Copyright (c) 2023, 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.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+// the interface (from the latest frozen version), the build system will
+// prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.hardware.graphics.common;
+@Backing(type="int") @VintfStability
+enum DisplayHotplugEvent {
+ CONNECTED = 0,
+ DISCONNECTED = 1,
+ ERROR_UNKNOWN = (-1) /* -1 */,
+ ERROR_INCOMPATIBLE_CABLE = (-2) /* -2 */,
+ ERROR_TOO_MANY_DISPLAYS = (-3) /* -3 */,
+}
diff --git a/graphics/common/aidl/android/hardware/graphics/common/DisplayHotplugEvent.aidl b/graphics/common/aidl/android/hardware/graphics/common/DisplayHotplugEvent.aidl
new file mode 100644
index 0000000..b35ada5
--- /dev/null
+++ b/graphics/common/aidl/android/hardware/graphics/common/DisplayHotplugEvent.aidl
@@ -0,0 +1,46 @@
+/**
+ * Copyright (c) 2023, 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.graphics.common;
+
+/**
+ * Display hotplug events through onHotplugEvent callback.
+ */
+@VintfStability
+@Backing(type="int")
+enum DisplayHotplugEvent {
+ /**
+ * Display is successfully connected.
+ * Connected may be called more than once and the behavior of subsequent
+ * calls is that SurfaceFlinger queries the display properties again.
+ */
+ CONNECTED = 0,
+
+ /** Display is successfully disconnected */
+ DISCONNECTED = 1,
+
+ /** Display is plugged in, but an unknown error occurred */
+ ERROR_UNKNOWN = -1,
+
+ /** Display is plugged in, but incompatible cable error detected */
+ ERROR_INCOMPATIBLE_CABLE = -2,
+
+ /**
+ * Display is plugged in, but exceeds the max number of
+ * displays that can be simultaneously connected
+ */
+ ERROR_TOO_MANY_DISPLAYS = -3,
+}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ClientTarget.aidl b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ClientTarget.aidl
index 7632707..06ed922 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ClientTarget.aidl
+++ b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ClientTarget.aidl
@@ -37,4 +37,5 @@
android.hardware.graphics.composer3.Buffer buffer;
android.hardware.graphics.common.Dataspace dataspace;
android.hardware.graphics.common.Rect[] damage;
+ float hdrSdrRatio = 1.0f;
}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/DisplayRequest.aidl b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/DisplayRequest.aidl
index 00598eb..e6db116 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/DisplayRequest.aidl
+++ b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/DisplayRequest.aidl
@@ -37,12 +37,12 @@
long display;
int mask;
android.hardware.graphics.composer3.DisplayRequest.LayerRequest[] layerRequests;
- const int FLIP_CLIENT_TARGET = (1 << 0);
- const int WRITE_CLIENT_TARGET_TO_OUTPUT = (1 << 1);
+ const int FLIP_CLIENT_TARGET = (1 << 0) /* 1 */;
+ const int WRITE_CLIENT_TARGET_TO_OUTPUT = (1 << 1) /* 2 */;
@VintfStability
parcelable LayerRequest {
long layer;
int mask;
- const int CLEAR_CLIENT_TARGET = (1 << 0);
+ const int CLEAR_CLIENT_TARGET = (1 << 0) /* 1 */;
}
}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/FormatColorComponent.aidl b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/FormatColorComponent.aidl
index 1990350..89dae83 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/FormatColorComponent.aidl
+++ b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/FormatColorComponent.aidl
@@ -34,8 +34,8 @@
package android.hardware.graphics.composer3;
@Backing(type="byte") @VintfStability
enum FormatColorComponent {
- FORMAT_COMPONENT_0 = (1 << 0),
- FORMAT_COMPONENT_1 = (1 << 1),
- FORMAT_COMPONENT_2 = (1 << 2),
- FORMAT_COMPONENT_3 = (1 << 3),
+ FORMAT_COMPONENT_0 = (1 << 0) /* 1 */,
+ FORMAT_COMPONENT_1 = (1 << 1) /* 2 */,
+ FORMAT_COMPONENT_2 = (1 << 2) /* 4 */,
+ FORMAT_COMPONENT_3 = (1 << 3) /* 8 */,
}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/IComposerCallback.aidl b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/IComposerCallback.aidl
index 2c08cbe..e64bd52 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/IComposerCallback.aidl
+++ b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/IComposerCallback.aidl
@@ -34,6 +34,9 @@
package android.hardware.graphics.composer3;
@VintfStability
interface IComposerCallback {
+ /**
+ * @deprecated : Use instead onHotplugEvent
+ */
void onHotplug(long display, boolean connected);
oneway void onRefresh(long display);
oneway void onSeamlessPossible(long display);
@@ -41,4 +44,5 @@
oneway void onVsyncPeriodTimingChanged(long display, in android.hardware.graphics.composer3.VsyncPeriodChangeTimeline updatedTimeline);
oneway void onVsyncIdle(long display);
oneway void onRefreshRateChangedDebug(in android.hardware.graphics.composer3.RefreshRateChangedDebugData data);
+ void onHotplugEvent(long display, android.hardware.graphics.common.DisplayHotplugEvent event);
}
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/ClientTarget.aidl b/graphics/composer/aidl/android/hardware/graphics/composer3/ClientTarget.aidl
index 56488d5..bc9f63a 100644
--- a/graphics/composer/aidl/android/hardware/graphics/composer3/ClientTarget.aidl
+++ b/graphics/composer/aidl/android/hardware/graphics/composer3/ClientTarget.aidl
@@ -36,4 +36,14 @@
* The surface damage regions.
*/
Rect[] damage;
+
+ /**
+ * The HDR/SDR ratio.
+ * Only meaningful for extended_range client targets to communicate the amount of HDR heaedroom
+ * inside the client target. For floating point client targets, this means that for each color
+ * channel the maximum SDR luminance is 1.0, and the maximum display relative luminance is
+ * the hdrSdrRatio.
+ * Note that this ratio is meant to be >= 1.0.
+ */
+ float hdrSdrRatio = 1.0f;
}
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/IComposerCallback.aidl b/graphics/composer/aidl/android/hardware/graphics/composer3/IComposerCallback.aidl
index f4384b7..96eccd7 100644
--- a/graphics/composer/aidl/android/hardware/graphics/composer3/IComposerCallback.aidl
+++ b/graphics/composer/aidl/android/hardware/graphics/composer3/IComposerCallback.aidl
@@ -16,6 +16,7 @@
package android.hardware.graphics.composer3;
+import android.hardware.graphics.common.DisplayHotplugEvent;
import android.hardware.graphics.composer3.RefreshRateChangedDebugData;
import android.hardware.graphics.composer3.VsyncPeriodChangeTimeline;
@@ -38,6 +39,7 @@
* @param display is the display that triggers the hotplug event.
* @param connected indicates whether the display is connected or
* disconnected.
+ * @deprecated: Use instead onHotplugEvent
*/
void onHotplug(long display, boolean connected);
@@ -118,4 +120,23 @@
* @param data is the data for the callback when refresh rate changed.
*/
oneway void onRefreshRateChangedDebug(in RefreshRateChangedDebugData data);
+
+ /**
+ * Notifies the client that a DisplayHotplugEvent has occurred for the
+ * given display. Every active display (even a built-in physical display)
+ * must trigger at least one hotplug notification, even if it only occurs
+ * immediately after callback registration.
+ *
+ * Displays which have been connected are assumed to be in PowerMode.OFF,
+ * and the onVsync callback should not be called for a display until vsync
+ * has been enabled with setVsyncEnabled.
+ *
+ * The client may call back into the device while the callback is in
+ * progress. The device must serialize calls to this callback such that
+ * only one thread is calling it at a time.
+ *
+ * @param display is the display that triggers the hotplug event.
+ * @param event is the type of event that occurred.
+ */
+ void onHotplugEvent(long display, DisplayHotplugEvent event);
}
diff --git a/graphics/composer/aidl/include/android/hardware/graphics/composer3/ComposerClientWriter.h b/graphics/composer/aidl/include/android/hardware/graphics/composer3/ComposerClientWriter.h
index 92ed6d3..c7bd5e0 100644
--- a/graphics/composer/aidl/include/android/hardware/graphics/composer3/ComposerClientWriter.h
+++ b/graphics/composer/aidl/include/android/hardware/graphics/composer3/ComposerClientWriter.h
@@ -83,11 +83,13 @@
}
void setClientTarget(int64_t display, uint32_t slot, const native_handle_t* target,
- int acquireFence, Dataspace dataspace, const std::vector<Rect>& damage) {
+ int acquireFence, Dataspace dataspace, const std::vector<Rect>& damage,
+ float hdrSdrRatio) {
ClientTarget clientTargetCommand;
clientTargetCommand.buffer = getBufferCommand(slot, target, acquireFence);
clientTargetCommand.dataspace = dataspace;
clientTargetCommand.damage.assign(damage.begin(), damage.end());
+ clientTargetCommand.hdrSdrRatio = hdrSdrRatio;
getDisplayCommand(display).clientTarget.emplace(std::move(clientTargetCommand));
}
diff --git a/graphics/composer/aidl/vts/GraphicsComposerCallback.cpp b/graphics/composer/aidl/vts/GraphicsComposerCallback.cpp
index 7b3a2b4..544f692 100644
--- a/graphics/composer/aidl/vts/GraphicsComposerCallback.cpp
+++ b/graphics/composer/aidl/vts/GraphicsComposerCallback.cpp
@@ -17,6 +17,7 @@
#include "GraphicsComposerCallback.h"
#include <log/log_main.h>
#include <utils/Timers.h>
+#include <cinttypes>
#pragma push_macro("LOG_TAG")
#undef LOG_TAG
@@ -193,4 +194,18 @@
return ::ndk::ScopedAStatus::ok();
}
+::ndk::ScopedAStatus GraphicsComposerCallback::onHotplugEvent(int64_t in_display,
+ common::DisplayHotplugEvent event) {
+ switch (event) {
+ case common::DisplayHotplugEvent::CONNECTED:
+ return onHotplug(in_display, true);
+ case common::DisplayHotplugEvent::DISCONNECTED:
+ return onHotplug(in_display, false);
+ default:
+ ALOGE("%s(): display:%" PRIu64 ", event:%d", __func__, in_display,
+ static_cast<int32_t>(event));
+ return ::ndk::ScopedAStatus::ok();
+ }
+}
+
} // namespace aidl::android::hardware::graphics::composer3::vts
diff --git a/graphics/composer/aidl/vts/GraphicsComposerCallback.h b/graphics/composer/aidl/vts/GraphicsComposerCallback.h
index 13e992a..7a8d4a3 100644
--- a/graphics/composer/aidl/vts/GraphicsComposerCallback.h
+++ b/graphics/composer/aidl/vts/GraphicsComposerCallback.h
@@ -63,6 +63,8 @@
virtual ::ndk::ScopedAStatus onVsyncIdle(int64_t in_display) override;
virtual ::ndk::ScopedAStatus onRefreshRateChangedDebug(
const RefreshRateChangedDebugData&) override;
+ virtual ::ndk::ScopedAStatus onHotplugEvent(int64_t in_display,
+ common::DisplayHotplugEvent) override;
mutable std::mutex mMutex;
// the set of all currently connected displays
diff --git a/graphics/composer/aidl/vts/VtsHalGraphicsComposer3_ReadbackTest.cpp b/graphics/composer/aidl/vts/VtsHalGraphicsComposer3_ReadbackTest.cpp
index 58eca6e..2e3f4df 100644
--- a/graphics/composer/aidl/vts/VtsHalGraphicsComposer3_ReadbackTest.cpp
+++ b/graphics/composer/aidl/vts/VtsHalGraphicsComposer3_ReadbackTest.cpp
@@ -500,7 +500,7 @@
const auto unlockStatus = graphicBuffer->unlockAsync(&clientFence);
ASSERT_EQ(::android::OK, unlockStatus);
mWriter->setClientTarget(getPrimaryDisplayId(), /*slot*/ 0, buffer, clientFence,
- clientDataspace, std::vector<common::Rect>(1, damage));
+ clientDataspace, std::vector<common::Rect>(1, damage), 1.f);
layer->setToClientComposition(*mWriter);
mWriter->validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp,
VtsComposerClient::kNoFrameIntervalNs);
@@ -608,7 +608,7 @@
const auto unlockStatus = graphicBuffer->unlockAsync(&clientFence);
ASSERT_EQ(::android::OK, unlockStatus);
mWriter->setClientTarget(getPrimaryDisplayId(), /*slot*/ 0, buffer, clientFence,
- clientDataspace, std::vector<common::Rect>(1, clientFrame));
+ clientDataspace, std::vector<common::Rect>(1, clientFrame), 1.f);
clientLayer->setToClientComposition(*mWriter);
mWriter->validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp,
VtsComposerClient::kNoFrameIntervalNs);
diff --git a/graphics/composer/aidl/vts/VtsHalGraphicsComposer3_TargetTest.cpp b/graphics/composer/aidl/vts/VtsHalGraphicsComposer3_TargetTest.cpp
index c135298..ca1b6d8 100644
--- a/graphics/composer/aidl/vts/VtsHalGraphicsComposer3_TargetTest.cpp
+++ b/graphics/composer/aidl/vts/VtsHalGraphicsComposer3_TargetTest.cpp
@@ -1828,7 +1828,7 @@
auto& writer = getWriter(getPrimaryDisplayId());
writer.setClientTarget(getPrimaryDisplayId(), /*slot*/ 0, nullptr, /*acquireFence*/ -1,
- Dataspace::UNKNOWN, std::vector<Rect>());
+ Dataspace::UNKNOWN, std::vector<Rect>(), 1.0f);
execute();
}
diff --git a/media/c2/aidl/aidl_api/android.hardware.media.c2/current/android/hardware/media/c2/IGraphicBufferAllocator.aidl b/media/c2/aidl/aidl_api/android.hardware.media.c2/current/android/hardware/media/c2/IGraphicBufferAllocator.aidl
index 3e460dd..e13ba1f 100644
--- a/media/c2/aidl/aidl_api/android.hardware.media.c2/current/android/hardware/media/c2/IGraphicBufferAllocator.aidl
+++ b/media/c2/aidl/aidl_api/android.hardware.media.c2/current/android/hardware/media/c2/IGraphicBufferAllocator.aidl
@@ -39,7 +39,7 @@
ParcelFileDescriptor getWaitableFd();
parcelable Allocation {
android.hardware.HardwareBuffer buffer;
- ParcelFileDescriptor fence;
+ @nullable ParcelFileDescriptor fence;
}
parcelable Description {
int width;
diff --git a/media/c2/aidl/android/hardware/media/c2/IGraphicBufferAllocator.aidl b/media/c2/aidl/android/hardware/media/c2/IGraphicBufferAllocator.aidl
index 49c4ea4..1710242 100644
--- a/media/c2/aidl/android/hardware/media/c2/IGraphicBufferAllocator.aidl
+++ b/media/c2/aidl/android/hardware/media/c2/IGraphicBufferAllocator.aidl
@@ -35,7 +35,7 @@
*/
parcelable Allocation {
HardwareBuffer buffer;
- ParcelFileDescriptor fence;
+ @nullable ParcelFileDescriptor fence;
}
/**
diff --git a/power/aidl/aidl_api/android.hardware.power/current/android/hardware/power/Mode.aidl b/power/aidl/aidl_api/android.hardware.power/current/android/hardware/power/Mode.aidl
index b8a0710..46eca69 100644
--- a/power/aidl/aidl_api/android.hardware.power/current/android/hardware/power/Mode.aidl
+++ b/power/aidl/aidl_api/android.hardware.power/current/android/hardware/power/Mode.aidl
@@ -52,4 +52,5 @@
GAME,
GAME_LOADING,
DISPLAY_CHANGE,
+ AUTOMOTIVE_PROJECTION,
}
diff --git a/power/aidl/aidl_api/android.hardware.power/current/android/hardware/power/WorkDuration.aidl b/power/aidl/aidl_api/android.hardware.power/current/android/hardware/power/WorkDuration.aidl
index e86cd40..45013dd 100644
--- a/power/aidl/aidl_api/android.hardware.power/current/android/hardware/power/WorkDuration.aidl
+++ b/power/aidl/aidl_api/android.hardware.power/current/android/hardware/power/WorkDuration.aidl
@@ -36,4 +36,7 @@
parcelable WorkDuration {
long timeStampNanos;
long durationNanos;
+ long workPeriodStartTimestampNanos;
+ long cpuDurationNanos;
+ long gpuDurationNanos;
}
diff --git a/power/aidl/android/hardware/power/Mode.aidl b/power/aidl/android/hardware/power/Mode.aidl
index 78f0363..a8fba72 100644
--- a/power/aidl/android/hardware/power/Mode.aidl
+++ b/power/aidl/android/hardware/power/Mode.aidl
@@ -173,4 +173,10 @@
* or switching between inner and outer panels.
*/
DISPLAY_CHANGE,
+
+ /**
+ * This mode indicates that the device is rendering to a remote display in
+ * a vehicle (such as Android Auto projection screen).
+ */
+ AUTOMOTIVE_PROJECTION,
}
diff --git a/power/aidl/android/hardware/power/WorkDuration.aidl b/power/aidl/android/hardware/power/WorkDuration.aidl
index a06a058..fcd638b 100644
--- a/power/aidl/android/hardware/power/WorkDuration.aidl
+++ b/power/aidl/android/hardware/power/WorkDuration.aidl
@@ -23,8 +23,30 @@
* sample was measured.
*/
long timeStampNanos;
+
/**
- * Work duration in nanoseconds.
+ * Total work duration in nanoseconds.
*/
long durationNanos;
+
+ /**
+ * Timestamp in nanoseconds based on CLOCK_MONOTONIC when the work starts.
+ * The work period start timestamp could be zero if the call is from
+ * the legacy SDK/NDK reportActualWorkDuration API.
+ */
+ long workPeriodStartTimestampNanos;
+
+ /**
+ * CPU work duration in nanoseconds.
+ * The CPU work duration could be the same as the total work duration if
+ * the call is from the legacy SDK/NDK reportActualWorkDuration API.
+ */
+ long cpuDurationNanos;
+
+ /**
+ * GPU work duration in nanoseconds.
+ * The GPU work duration could be zero if the call is from the legacy
+ * SDK/NDK reportActualWorkDuration API.
+ */
+ long gpuDurationNanos;
}
diff --git a/radio/aidl/aidl_api/android.hardware.radio.network/current/android/hardware/radio/network/ConnectionEvent.aidl b/radio/aidl/aidl_api/android.hardware.radio.network/current/android/hardware/radio/network/ConnectionEvent.aidl
index 3161322..eedb8ed 100644
--- a/radio/aidl/aidl_api/android.hardware.radio.network/current/android/hardware/radio/network/ConnectionEvent.aidl
+++ b/radio/aidl/aidl_api/android.hardware.radio.network/current/android/hardware/radio/network/ConnectionEvent.aidl
@@ -35,18 +35,16 @@
/* @hide */
@Backing(type="int") @JavaDerive(toString=true) @VintfStability
enum ConnectionEvent {
- CS_SERVICE_GSM = 0,
- SIGNALLING_GSM = 1,
- PS_SERVICE_GPRS = 2,
- SIGNALLING_GPRS = 3,
- PS_SERVICE_3G = 4,
- SIGNALLING_3G = 5,
- NAS_SIGNALLING_LTE = 6,
- AS_SIGNALLING_LTE = 7,
- VOLTE_SIP = 8,
- VOLTE_RTP = 9,
- NAS_SIGNALLING_5G = 10,
- AS_SIGNALLING_5G = 11,
- VONR_SIP = 12,
- VONR_RTP = 13,
+ CS_SIGNALLING_GSM = 0,
+ PS_SIGNALLING_GPRS = 1,
+ CS_SIGNALLING_3G = 2,
+ PS_SIGNALLING_3G = 3,
+ NAS_SIGNALLING_LTE = 4,
+ AS_SIGNALLING_LTE = 5,
+ VOLTE_SIP = 6,
+ VOLTE_RTP = 7,
+ NAS_SIGNALLING_5G = 8,
+ AS_SIGNALLING_5G = 9,
+ VONR_SIP = 10,
+ VONR_RTP = 11,
}
diff --git a/radio/aidl/aidl_api/android.hardware.radio.network/current/android/hardware/radio/network/NasProtocolMessage.aidl b/radio/aidl/aidl_api/android.hardware.radio.network/current/android/hardware/radio/network/NasProtocolMessage.aidl
index 9f852cc..4fbc802 100644
--- a/radio/aidl/aidl_api/android.hardware.radio.network/current/android/hardware/radio/network/NasProtocolMessage.aidl
+++ b/radio/aidl/aidl_api/android.hardware.radio.network/current/android/hardware/radio/network/NasProtocolMessage.aidl
@@ -44,4 +44,7 @@
AUTHENTICATION_AND_CIPHERING_RESPONSE = 6,
REGISTRATION_REQUEST = 7,
DEREGISTRATION_REQUEST = 8,
+ CM_REESTABLISHMENT_REQUEST = 9,
+ CM_SERVICE_REQUEST = 10,
+ IMSI_DETACH_INDICATION = 11,
}
diff --git a/radio/aidl/aidl_api/android.hardware.radio.network/current/android/hardware/radio/network/SecurityAlgorithm.aidl b/radio/aidl/aidl_api/android.hardware.radio.network/current/android/hardware/radio/network/SecurityAlgorithm.aidl
index 97ce004..1664501 100644
--- a/radio/aidl/aidl_api/android.hardware.radio.network/current/android/hardware/radio/network/SecurityAlgorithm.aidl
+++ b/radio/aidl/aidl_api/android.hardware.radio.network/current/android/hardware/radio/network/SecurityAlgorithm.aidl
@@ -53,7 +53,6 @@
EEA1 = 42,
EEA2 = 43,
EEA3 = 44,
- EEA4_ZUC = 45,
NEA0 = 55,
NEA1 = 56,
NEA2 = 57,
diff --git a/radio/aidl/android/hardware/radio/network/ConnectionEvent.aidl b/radio/aidl/android/hardware/radio/network/ConnectionEvent.aidl
index 639ba89..2e39ebf 100644
--- a/radio/aidl/android/hardware/radio/network/ConnectionEvent.aidl
+++ b/radio/aidl/android/hardware/radio/network/ConnectionEvent.aidl
@@ -25,31 +25,31 @@
@Backing(type="int")
@JavaDerive(toString=true)
enum ConnectionEvent {
- // 2G GSM
- CS_SERVICE_GSM = 0,
- SIGNALLING_GSM = 1,
+ // 2G GSM circuit switched
+ CS_SIGNALLING_GSM = 0,
// 2G GPRS packet services
- PS_SERVICE_GPRS = 2,
- SIGNALLING_GPRS = 3,
+ PS_SIGNALLING_GPRS = 1,
- // 3G packet services
- PS_SERVICE_3G = 4,
- SIGNALLING_3G = 5,
+ // 3G circuit switched
+ CS_SIGNALLING_3G = 2,
+
+ // 3G packet switched
+ PS_SIGNALLING_3G = 3,
// 4G LTE packet services
- NAS_SIGNALLING_LTE = 6,
- AS_SIGNALLING_LTE = 7,
+ NAS_SIGNALLING_LTE = 4,
+ AS_SIGNALLING_LTE = 5,
// VoLTE
- VOLTE_SIP = 8,
- VOLTE_RTP = 9,
+ VOLTE_SIP = 6,
+ VOLTE_RTP = 7,
// 5G packet services
- NAS_SIGNALLING_5G = 10,
- AS_SIGNALLING_5G = 11,
+ NAS_SIGNALLING_5G = 8,
+ AS_SIGNALLING_5G = 9,
// VoNR
- VONR_SIP = 12,
- VONR_RTP = 13,
+ VONR_SIP = 10,
+ VONR_RTP = 11,
}
diff --git a/radio/aidl/android/hardware/radio/network/IRadioNetwork.aidl b/radio/aidl/android/hardware/radio/network/IRadioNetwork.aidl
index 32890ec..e2df8dd 100644
--- a/radio/aidl/android/hardware/radio/network/IRadioNetwork.aidl
+++ b/radio/aidl/android/hardware/radio/network/IRadioNetwork.aidl
@@ -669,7 +669,7 @@
* Note: Cellular identifiers disclosed in uplink messages covered under a NAS Security Context
* as well as identifiers disclosed in downlink messages are out of scope.
*
- * This feature applies to 2g, 3g, 4g, and 5g (SA and NSA) messages sent before a NAS security
+ * This feature applies to 2g, 3g, 4g, and 5g (SA and NSA) messages sent before a security
* context is established. In scope message definitions and their associated spec references can
* be found in NasProtocolMessage.
*
@@ -678,8 +678,6 @@
* re-enables this functionality. The modem may choose to stop tracking cellular identifiers in
* the clear during this time.
*
- * Note: The default value of enabled shall be true.
- *
* @param serial Serial number of request
* @param enabled Whether or not to enable sending indications for cellular identifiers in the
* clear
@@ -694,8 +692,6 @@
* Enables or disables security algorithm update reports via indication API
* {@link IRadioNetworkIndication.securityAlgorithmsUpdated()}.
*
- * Note: The default value shall be enabled.
- *
* @param serial Serial number of request.
* @param enable {@code true} to enable security algorithm update reports, {@code false} to
* disable.
diff --git a/radio/aidl/android/hardware/radio/network/NasProtocolMessage.aidl b/radio/aidl/android/hardware/radio/network/NasProtocolMessage.aidl
index e8d8047..1225c41 100644
--- a/radio/aidl/android/hardware/radio/network/NasProtocolMessage.aidl
+++ b/radio/aidl/android/hardware/radio/network/NasProtocolMessage.aidl
@@ -54,5 +54,14 @@
REGISTRATION_REQUEST = 7,
// Reference: 3GPP TS 24.501 8.2.12
// Applies to 5g networks
- DEREGISTRATION_REQUEST = 8
+ DEREGISTRATION_REQUEST = 8,
+ // Reference: 3GPP TS 24.008 9.2.4
+ // Applies to 2g and 3g networks
+ CM_REESTABLISHMENT_REQUEST = 9,
+ // Reference: 3GPP TS 24.008 9.2.9
+ // Applies to 2g and 3g networks
+ CM_SERVICE_REQUEST = 10,
+ // Reference: 3GPP TS 24.008 9.2.14
+ // Applies to 2g and 3g networks. Used for circuit-switched detach.
+ IMSI_DETACH_INDICATION = 11
}
diff --git a/radio/aidl/android/hardware/radio/network/SecurityAlgorithm.aidl b/radio/aidl/android/hardware/radio/network/SecurityAlgorithm.aidl
index 6d2c018..71c654c 100644
--- a/radio/aidl/android/hardware/radio/network/SecurityAlgorithm.aidl
+++ b/radio/aidl/android/hardware/radio/network/SecurityAlgorithm.aidl
@@ -52,7 +52,6 @@
EEA1 = 42,
EEA2 = 43,
EEA3 = 44,
- EEA4_ZUC = 45,
// 5G PS services (3GPP TS 33.401 for 5G NSA and 3GPP TS 33.501 for 5G SA)
NEA0 = 55,
diff --git a/radio/aidl/vts/radio_network_test.cpp b/radio/aidl/vts/radio_network_test.cpp
index c893553..a6ee2a6 100644
--- a/radio/aidl/vts/radio_network_test.cpp
+++ b/radio/aidl/vts/radio_network_test.cpp
@@ -2372,9 +2372,16 @@
EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
- ASSERT_TRUE(CheckAnyOfErrors(
- radioRsp_network->rspInfo.error,
- {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE, RadioError::MODEM_ERR}));
+ if (aidl_version >= 3 && deviceSupportsFeature(FEATURE_TELEPHONY_RADIO_ACCESS)) {
+ ASSERT_TRUE(CheckAnyOfErrors(
+ radioRsp_network->rspInfo.error,
+ {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE, RadioError::MODEM_ERR}));
+ } else {
+ // For aidl_version 2, API is optional
+ ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error,
+ {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE,
+ RadioError::MODEM_ERR, RadioError::REQUEST_NOT_SUPPORTED}));
+ }
}
/**
@@ -2406,9 +2413,16 @@
EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
- ASSERT_TRUE(CheckAnyOfErrors(
- radioRsp_network->rspInfo.error,
- {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE, RadioError::MODEM_ERR}));
+ if (aidl_version >= 3 && deviceSupportsFeature(FEATURE_TELEPHONY_RADIO_ACCESS)) {
+ ASSERT_TRUE(CheckAnyOfErrors(
+ radioRsp_network->rspInfo.error,
+ {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE, RadioError::MODEM_ERR}));
+ } else {
+ // For aidl_version 2, API is optional
+ ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error,
+ {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE,
+ RadioError::MODEM_ERR, RadioError::REQUEST_NOT_SUPPORTED}));
+ }
}
TEST_P(RadioNetworkTest, isCellularIdentifierTransparencyEnabled) {
@@ -2433,10 +2447,6 @@
ASSERT_TRUE(CheckAnyOfErrors(
radioRsp_network->rspInfo.error,
{RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE, RadioError::MODEM_ERR}));
-
- // the default value should be true if we have not called the setter
- EXPECT_TRUE(radioRsp_network->isCellularIdentifierTransparencyEnabled);
-
}
TEST_P(RadioNetworkTest, setCellularIdentifierTransparencyEnabled) {
@@ -2567,7 +2577,4 @@
ASSERT_TRUE(CheckAnyOfErrors(
radioRsp_network->rspInfo.error,
{RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE, RadioError::MODEM_ERR}));
-
- // the default value should be true if we have not called the setter
- EXPECT_TRUE(radioRsp_network->isSecurityAlgorithmsUpdatedEnabled);
}
diff --git a/renderscript/1.0/default/Android.bp b/renderscript/1.0/default/Android.bp
index c68e370..23fa252 100644
--- a/renderscript/1.0/default/Android.bp
+++ b/renderscript/1.0/default/Android.bp
@@ -27,6 +27,12 @@
"android.hardware.renderscript@1.0",
],
+ runtime_libs: [
+ "libRS_internal",
+ //TODO(b/313564579) Install libRSDriver as dependency of libRS_internal
+ "libRSDriver",
+ ],
+
product_variables: {
override_rs_driver: {
cflags: ["-DOVERRIDE_RS_DRIVER=%s"],
diff --git a/security/authgraph/aidl/Android.bp b/security/authgraph/aidl/Android.bp
index d94f640..f3d1281 100644
--- a/security/authgraph/aidl/Android.bp
+++ b/security/authgraph/aidl/Android.bp
@@ -34,7 +34,7 @@
platform_apis: true,
},
ndk: {
- apps_enabled: false,
+ enabled: true,
},
rust: {
enabled: true,
diff --git a/security/authgraph/aidl/vts/functional/lib.rs b/security/authgraph/aidl/vts/functional/lib.rs
index da3fa1c..f4c1da9 100644
--- a/security/authgraph/aidl/vts/functional/lib.rs
+++ b/security/authgraph/aidl/vts/functional/lib.rs
@@ -26,6 +26,7 @@
use authgraph_boringssl as boring;
use authgraph_core::{error::Error as AgError, keyexchange as ke};
use coset::CborSerializable;
+use std::{cell::RefCell, rc::Rc};
pub mod sink;
pub mod source;
@@ -34,7 +35,7 @@
pub fn test_ag_participant() -> Result<ke::AuthGraphParticipant, AgError> {
Ok(ke::AuthGraphParticipant::new(
boring::crypto_trait_impls(),
- Box::<boring::test_device::AgDevice>::default(),
+ Rc::new(RefCell::new(boring::test_device::AgDevice::default())),
ke::MAX_OPENED_SESSIONS,
)?)
}
diff --git a/security/authgraph/default/src/fuzzer.rs b/security/authgraph/default/src/fuzzer.rs
index d401777..387d72f 100644
--- a/security/authgraph/default/src/fuzzer.rs
+++ b/security/authgraph/default/src/fuzzer.rs
@@ -22,10 +22,9 @@
use authgraph_nonsecure::LocalTa;
use binder_random_parcel_rs::fuzz_service;
use libfuzzer_sys::fuzz_target;
-use std::sync::{Arc, Mutex};
fuzz_target!(|data: &[u8]| {
let local_ta = LocalTa::new().expect("Failed to create an AuthGraph local TA.");
- let service = AuthGraphService::new_as_binder(Arc::new(Mutex::new(local_ta)));
+ let service = AuthGraphService::new_as_binder(local_ta);
fuzz_service(&mut service.as_binder(), data);
});
diff --git a/security/authgraph/default/src/lib.rs b/security/authgraph/default/src/lib.rs
index 43d037c..1f851b2 100644
--- a/security/authgraph/default/src/lib.rs
+++ b/security/authgraph/default/src/lib.rs
@@ -18,67 +18,66 @@
use authgraph_boringssl as boring;
use authgraph_core::{
- error,
- key::MillisecondsSinceEpoch,
- keyexchange,
+ error, keyexchange,
ta::{AuthGraphTa, Role},
- traits,
};
use authgraph_hal::channel::SerializedChannel;
-use std::sync::{Arc, Mutex};
-use std::time::Instant;
-
-/// Monotonic clock with an epoch that starts at the point of construction.
-/// (This makes it unsuitable for use outside of testing, because the epoch
-/// will not match that of any other component.)
-pub struct StdClock(Instant);
-
-impl Default for StdClock {
- fn default() -> Self {
- Self(Instant::now())
- }
-}
-
-impl traits::MonotonicClock for StdClock {
- fn now(&self) -> MillisecondsSinceEpoch {
- let millis: i64 = self
- .0
- .elapsed()
- .as_millis()
- .try_into()
- .expect("failed to fit timestamp in i64");
- MillisecondsSinceEpoch(millis)
- }
-}
+use std::cell::RefCell;
+use std::rc::Rc;
+use std::sync::{mpsc, Mutex};
/// Implementation of the AuthGraph TA that runs locally in-process (and which is therefore
/// insecure).
pub struct LocalTa {
- ta: Arc<Mutex<AuthGraphTa>>,
+ channels: Mutex<Channels>,
+}
+
+struct Channels {
+ in_tx: mpsc::Sender<Vec<u8>>,
+ out_rx: mpsc::Receiver<Vec<u8>>,
}
impl LocalTa {
/// Create a new instance.
pub fn new() -> Result<Self, error::Error> {
- Ok(Self {
- ta: Arc::new(Mutex::new(AuthGraphTa::new(
+ // Create a pair of channels to communicate with the TA thread.
+ let (in_tx, in_rx) = mpsc::channel();
+ let (out_tx, out_rx) = mpsc::channel();
+
+ // The TA code expects to run single threaded, so spawn a thread to run it in.
+ std::thread::spawn(move || {
+ let mut ta = AuthGraphTa::new(
keyexchange::AuthGraphParticipant::new(
boring::crypto_trait_impls(),
- Box::<boring::test_device::AgDevice>::default(),
+ Rc::new(RefCell::new(boring::test_device::AgDevice::default())),
keyexchange::MAX_OPENED_SESSIONS,
- )?,
+ )
+ .expect("failed to create AG participant"),
Role::Both,
- ))),
+ );
+ // Loop forever processing request messages.
+ loop {
+ let req_data: Vec<u8> = in_rx.recv().expect("failed to receive next req");
+ let rsp_data = ta.process(&req_data);
+ out_tx.send(rsp_data).expect("failed to send out rsp");
+ }
+ });
+ Ok(Self {
+ channels: Mutex::new(Channels { in_tx, out_rx }),
})
}
}
-/// Pretend to be a serialized channel to the TA, but actually just directly invoke the TA with
-/// incoming requests.
impl SerializedChannel for LocalTa {
const MAX_SIZE: usize = usize::MAX;
- fn execute(&mut self, req_data: &[u8]) -> binder::Result<Vec<u8>> {
- Ok(self.ta.lock().unwrap().process(req_data))
+ fn execute(&self, req_data: &[u8]) -> binder::Result<Vec<u8>> {
+ // Serialize across both request and response.
+ let channels = self.channels.lock().unwrap();
+ channels
+ .in_tx
+ .send(req_data.to_vec())
+ .expect("failed to send in request");
+ Ok(channels.out_rx.recv().expect("failed to receive response"))
}
}
diff --git a/security/authgraph/default/src/main.rs b/security/authgraph/default/src/main.rs
index 81f2dd6..ced7567 100644
--- a/security/authgraph/default/src/main.rs
+++ b/security/authgraph/default/src/main.rs
@@ -25,7 +25,6 @@
use authgraph_hal::service;
use authgraph_nonsecure::LocalTa;
use log::{error, info};
-use std::sync::{Arc, Mutex};
static SERVICE_NAME: &str = "android.hardware.security.authgraph.IAuthGraphKeyExchange";
static SERVICE_INSTANCE: &str = "nonsecure";
@@ -65,9 +64,8 @@
binder::ProcessState::start_thread_pool();
// Register the service
- let local_ta =
- LocalTa::new().map_err(|e| format!("Failed to create the TA because: {e:?}"))?;
- let service = service::AuthGraphService::new_as_binder(Arc::new(Mutex::new(local_ta)));
+ let local_ta = LocalTa::new().map_err(|e| format!("Failed to create the TA because: {e:?}"))?;
+ let service = service::AuthGraphService::new_as_binder(local_ta);
let service_name = format!("{}/{}", SERVICE_NAME, SERVICE_INSTANCE);
binder::add_service(&service_name, service.as_binder()).map_err(|e| {
format!(
diff --git a/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp b/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp
index 822770d..d3f6ae3 100644
--- a/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp
+++ b/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp
@@ -1792,6 +1792,12 @@
std::string empty_boot_key(32, '\0');
std::string verified_boot_key_str((const char*)verified_boot_key.data(),
verified_boot_key.size());
+ if (get_vsr_api_level() >= __ANDROID_API_V__) {
+ // The attestation should contain the SHA-256 hash of the verified boot
+ // key. However, this was not checked for earlier versions of the KeyMint
+ // HAL so only be strict for VSR-V and above.
+ EXPECT_LE(verified_boot_key.size(), 32);
+ }
EXPECT_NE(property_get("ro.boot.verifiedbootstate", property_value, ""), 0);
if (!strcmp(property_value, "green")) {
EXPECT_EQ(verified_boot_state, VerifiedBoot::VERIFIED);
diff --git a/security/keymint/aidl/vts/functional/SecureElementProvisioningTest.cpp b/security/keymint/aidl/vts/functional/SecureElementProvisioningTest.cpp
index c9a156d..9f7322a 100644
--- a/security/keymint/aidl/vts/functional/SecureElementProvisioningTest.cpp
+++ b/security/keymint/aidl/vts/functional/SecureElementProvisioningTest.cpp
@@ -114,6 +114,12 @@
const auto& vbKey = rot->asArray()->get(pos++);
ASSERT_TRUE(vbKey);
ASSERT_TRUE(vbKey->asBstr());
+ if (get_vsr_api_level() >= __ANDROID_API_V__) {
+ // The attestation should contain the SHA-256 hash of the verified boot
+ // key. However, this not was checked for earlier versions of the KeyMint
+ // HAL so only be strict for VSR-V and above.
+ ASSERT_LE(vbKey->asBstr()->value().size(), 32);
+ }
const auto& deviceLocked = rot->asArray()->get(pos++);
ASSERT_TRUE(deviceLocked);
diff --git a/security/keymint/support/include/remote_prov/remote_prov_utils.h b/security/keymint/support/include/remote_prov/remote_prov_utils.h
index 79189a1..3b02fad 100644
--- a/security/keymint/support/include/remote_prov/remote_prov_utils.h
+++ b/security/keymint/support/include/remote_prov/remote_prov_utils.h
@@ -130,7 +130,7 @@
* }
*/
JsonOutput jsonEncodeCsrWithBuild(const std::string instance_name,
- const cppbor::Array& csr);
+ const cppbor::Array& csr, const std::string serialno_prop);
/**
* Parses a DeviceInfo structure from the given CBOR data. The parsed data is then validated to
diff --git a/security/keymint/support/remote_prov_utils.cpp b/security/keymint/support/remote_prov_utils.cpp
index 6edbfc1..bd1e557 100644
--- a/security/keymint/support/remote_prov_utils.cpp
+++ b/security/keymint/support/remote_prov_utils.cpp
@@ -337,9 +337,9 @@
return result;
}
-JsonOutput jsonEncodeCsrWithBuild(const std::string instance_name, const cppbor::Array& csr) {
+JsonOutput jsonEncodeCsrWithBuild(const std::string instance_name, const cppbor::Array& csr,
+ const std::string serialno_prop) {
const std::string kFingerprintProp = "ro.build.fingerprint";
- const std::string kSerialNoProp = "ro.serialno";
if (!::android::base::WaitForPropertyCreation(kFingerprintProp)) {
return JsonOutput::Error("Unable to read build fingerprint");
@@ -364,7 +364,7 @@
Json::Value json(Json::objectValue);
json["name"] = instance_name;
json["build_fingerprint"] = ::android::base::GetProperty(kFingerprintProp, /*default=*/"");
- json["serialno"] = ::android::base::GetProperty(kSerialNoProp, /*default=*/"");
+ json["serialno"] = ::android::base::GetProperty(serialno_prop, /*default=*/"");
json["csr"] = base64.data(); // Boring writes a NUL-terminated c-string
Json::StreamWriterBuilder factory;
diff --git a/security/keymint/support/remote_prov_utils_test.cpp b/security/keymint/support/remote_prov_utils_test.cpp
index eaaba45..630f7bb 100644
--- a/security/keymint/support/remote_prov_utils_test.cpp
+++ b/security/keymint/support/remote_prov_utils_test.cpp
@@ -182,10 +182,11 @@
}
TEST(RemoteProvUtilsTest, JsonEncodeCsr) {
+ const std::string kSerialNoProp = "ro.serialno";
cppbor::Array array;
array.add(1);
- auto [json, error] = jsonEncodeCsrWithBuild(std::string("test"), array);
+ auto [json, error] = jsonEncodeCsrWithBuild(std::string("test"), array, kSerialNoProp);
ASSERT_TRUE(error.empty()) << error;
diff --git a/security/rkp/README.md b/security/rkp/README.md
index 15ea817..2180d0f 100644
--- a/security/rkp/README.md
+++ b/security/rkp/README.md
@@ -190,3 +190,30 @@
* [RpcHardwareInfo](https://cs.android.com/android/platform/superproject/+/master:hardware/interfaces/security/rkp/aidl/android/hardware/security/keymint/RpcHardwareInfo.aidl)
* [DeviceInfo](https://cs.android.com/android/platform/superproject/+/master:hardware/interfaces/security/rkp/aidl/android/hardware/security/keymint/DeviceInfo.aidl)
+### Support for Android Virtualization Framework
+
+The Android Virtualization Framwork (AVF) relies on RKP to provision keys for VMs. A
+privileged vm, the RKP VM, is reponsible for generating and managing the keys for client
+VMs that run virtualized workloads. See the following for more background information on the
+RKP VM:
+* [rkp-vm](https://android.googlesource.com/platform/packages/modules/Virtualization/+/main/service_vm/README.md#rkp-vm-remote-key-provisioning-virtual-machine)
+* [rkp-service](https://source.android.com/docs/core/ota/modular-system/remote-key-provisioning#stack-architecture)
+
+It is important to distinquish the RKP VM from other components, such as KeyMint. An
+[RKP VM marker](https://pigweed.googlesource.com/open-dice/+/HEAD/docs/android.md#configuration-descriptor)
+(key `-70006) is used for this purpose. The existence or absence of this marker is used to
+identify the type of component decribed by a given DICE chain.
+
+The following describes which certificate types may be request based on the RKP VM marker:
+1. "rkp-vm": If a DICE chain has zero or more certificates without the RKP VM
+ marker followed by one or more certificates with the marker, then that chain
+ describes an RKP VM. If there are further certificates without the RKP VM
+ marker, then the chain does not describe an RKP VM.
+
+ Implementations must include the first RPK VM marker as early as possible
+ after the point of divergence between TEE and non-TEE components in the DICE
+ chain, prior to loading the Android Bootloader (ABL).
+2. "widevine" or "keymint": If there are no certificates with the RKP VM
+ marker then it describes a TEE component.
+3. None: Any component described by a DICE chain that does not match the above
+ two categories.
\ No newline at end of file
diff --git a/security/rkp/aidl/android/hardware/security/keymint/generateCertificateRequestV2.cddl b/security/rkp/aidl/android/hardware/security/keymint/generateCertificateRequestV2.cddl
index 61404d4..3c43238 100644
--- a/security/rkp/aidl/android/hardware/security/keymint/generateCertificateRequestV2.cddl
+++ b/security/rkp/aidl/android/hardware/security/keymint/generateCertificateRequestV2.cddl
@@ -14,8 +14,9 @@
; be extended without requiring a version bump of the HAL. Custom certificate types may
; be used, but the provisioning server may reject the request for an unknown certificate
; type. The currently defined certificate types are:
-; - "widevine"
-; - "keymint"
+; * "widevine" -- Widevine content protection system
+; * "keymint" -- KeyMint HAL
+; * "rkp-vm" -- See "Support for Android Virtualization Framework" in the README.md file.
CertificateType = tstr
KeysToSign = [ * PublicKey ] ; Please see PublicKey.cddl for the PublicKey definition.
@@ -112,6 +113,7 @@
? -70003 : int / tstr, ; Component version
? -70004 : null, ; Resettable
? -70005 : uint, ; Security version
+ ? -70006 : null, ; RKP VM marker
}
; Each entry in the DICE chain is a DiceChainEntryPayload signed by the key from the previous
diff --git a/security/secretkeeper/aidl/Android.bp b/security/secretkeeper/aidl/Android.bp
index c77d299..ac923ca 100644
--- a/security/secretkeeper/aidl/Android.bp
+++ b/security/secretkeeper/aidl/Android.bp
@@ -20,8 +20,15 @@
name: "android.hardware.security.secretkeeper",
vendor_available: true,
srcs: ["android/hardware/security/secretkeeper/*.aidl"],
+ imports: [
+ "android.hardware.security.authgraph-V1",
+ ],
stability: "vintf",
+ frozen: false,
backend: {
+ java: {
+ enabled: false,
+ },
ndk: {
enabled: true,
},
@@ -34,3 +41,44 @@
},
},
}
+
+// cc_defaults that includes the latest Secretkeeper AIDL library.
+// Modules that depend on Secretkeeper directly can include this cc_defaults to avoid
+// managing dependency versions explicitly.
+cc_defaults {
+ name: "secretkeeper_use_latest_hal_aidl_ndk_static",
+ static_libs: [
+ "android.hardware.security.secretkeeper-V1-ndk",
+ ],
+}
+
+cc_defaults {
+ name: "secretkeeper_use_latest_hal_aidl_ndk_shared",
+ shared_libs: [
+ "android.hardware.security.secretkeeper-V1-ndk",
+ ],
+}
+
+cc_defaults {
+ name: "secretkeeper_use_latest_hal_aidl_cpp_static",
+ static_libs: [
+ "android.hardware.security.secretkeeper-V1-cpp",
+ ],
+}
+
+cc_defaults {
+ name: "secretkeeper_use_latest_hal_aidl_cpp_shared",
+ shared_libs: [
+ "android.hardware.security.secretkeeper-V1-cpp",
+ ],
+}
+
+// A rust_defaults that includes the latest Secretkeeper AIDL library.
+// Modules that depend on Secretkeeper directly can include this rust_defaults to avoid
+// managing dependency versions explicitly.
+rust_defaults {
+ name: "secretkeeper_use_latest_hal_aidl_rust",
+ rustlibs: [
+ "android.hardware.security.secretkeeper-V1-rust",
+ ],
+}
diff --git a/security/secretkeeper/aidl/aidl_api/android.hardware.security.secretkeeper/current/android/hardware/security/secretkeeper/ISecretkeeper.aidl b/security/secretkeeper/aidl/aidl_api/android.hardware.security.secretkeeper/current/android/hardware/security/secretkeeper/ISecretkeeper.aidl
index 2eb33c5..023fc8f 100644
--- a/security/secretkeeper/aidl/aidl_api/android.hardware.security.secretkeeper/current/android/hardware/security/secretkeeper/ISecretkeeper.aidl
+++ b/security/secretkeeper/aidl/aidl_api/android.hardware.security.secretkeeper/current/android/hardware/security/secretkeeper/ISecretkeeper.aidl
@@ -34,5 +34,6 @@
package android.hardware.security.secretkeeper;
@VintfStability
interface ISecretkeeper {
+ android.hardware.security.authgraph.IAuthGraphKeyExchange getAuthGraphKe();
byte[] processSecretManagementRequest(in byte[] request);
}
diff --git a/security/secretkeeper/aidl/android/hardware/security/secretkeeper/ISecretkeeper.aidl b/security/secretkeeper/aidl/android/hardware/security/secretkeeper/ISecretkeeper.aidl
index af715a9..1f4768a 100644
--- a/security/secretkeeper/aidl/android/hardware/security/secretkeeper/ISecretkeeper.aidl
+++ b/security/secretkeeper/aidl/android/hardware/security/secretkeeper/ISecretkeeper.aidl
@@ -16,6 +16,8 @@
package android.hardware.security.secretkeeper;
+import android.hardware.security.authgraph.IAuthGraphKeyExchange;
+
@VintfStability
/**
* Secretkeeper service definition.
@@ -29,17 +31,22 @@
* - A completely separate, purpose-built and certified secure CPU.
*
* TODO(b/291224769): Extend the HAL interface to include:
- * 1. Session setup api: This is used to perform cryptographic operations that allow shared keys to
- * be exchanged between session participants, typically (but not necessarily) a pVM instance and
- * Secretkeeper. This session setup is based on public key cryptography.
- * 2. Dice policy operation - These allow sealing of the secrets with a class of Dice chains.
+ * 1. Dice policy operation - These allow sealing of the secrets with a class of Dice chains.
* Typical operations are (securely) updating the dice policy sealing the Secrets above. These
* operations are core to AntiRollback protected secrets - ie, ensuring secrets of a pVM are only
* accessible to same or higher versions of the images.
- * 3. Maintenance api: This is required for removing the Secretkeeper entries for obsolete pvMs.
+ * 2. Maintenance api: This is required for removing the Secretkeeper entries for obsolete pvMs.
*/
interface ISecretkeeper {
/**
+ * Retrieve the instance of the `IAuthGraphKeyExchange` HAL that should be used for shared
+ * session key establishment. These keys are used to perform encryption of messages as
+ * described in SecretManagement.cddl, allowing the client and Secretkeeper to have a
+ * cryptographically secure channel.
+ */
+ IAuthGraphKeyExchange getAuthGraphKe();
+
+ /**
* processSecretManagementRequest method is used for interacting with the Secret Management API
*
* Secret Management API: The clients can use this API to store (& get) 32 bytes of data.
diff --git a/security/secretkeeper/aidl/vts/Android.bp b/security/secretkeeper/aidl/vts/Android.bp
index 6818298..fac16f6 100644
--- a/security/secretkeeper/aidl/vts/Android.bp
+++ b/security/secretkeeper/aidl/vts/Android.bp
@@ -28,6 +28,8 @@
rustlibs: [
"libsecretkeeper_comm_nostd",
"android.hardware.security.secretkeeper-V1-rust",
+ "libauthgraph_core",
+ "libauthgraph_vts_test",
"libbinder_rs",
"liblog_rust",
],
diff --git a/security/secretkeeper/aidl/vts/secretkeeper_test_client.rs b/security/secretkeeper/aidl/vts/secretkeeper_test_client.rs
index 28923f7..70f5da6 100644
--- a/security/secretkeeper/aidl/vts/secretkeeper_test_client.rs
+++ b/security/secretkeeper/aidl/vts/secretkeeper_test_client.rs
@@ -25,6 +25,8 @@
use secretkeeper_comm::data_types::response::Response;
use secretkeeper_comm::data_types::packet::{ResponsePacket, ResponseType};
use android_hardware_security_secretkeeper::aidl::android::hardware::security::secretkeeper::ISecretkeeper::ISecretkeeper;
+use authgraph_vts_test as ag_vts;
+use authgraph_core::key;
const SECRETKEEPER_IDENTIFIER: &str =
"android.hardware.security.secretkeeper.ISecretkeeper/nonsecure";
@@ -42,6 +44,57 @@
}
}
}
+fn authgraph_key_exchange(sk: binder::Strong<dyn ISecretkeeper>) -> [key::AesKey; 2] {
+ let sink = sk.getAuthGraphKe().expect("failed to get AuthGraph");
+ let mut source = ag_vts::test_ag_participant().expect("failed to create a local source");
+ ag_vts::sink::test_mainline(&mut source, sink)
+}
+
+/// Test that the AuthGraph instance returned by SecretKeeper correctly performs
+/// mainline key exchange against a local source implementation.
+#[test]
+fn authgraph_mainline() {
+ let sk = match get_connection() {
+ Some(sk) => sk,
+ None => {
+ warn!("Secretkeeper HAL is unavailable, skipping test");
+ return;
+ }
+ };
+ let _aes_keys = authgraph_key_exchange(sk);
+}
+
+/// Test that the AuthGraph instance returned by SecretKeeper correctly rejects
+/// a corrupted session ID signature.
+#[test]
+fn authgraph_corrupt_sig() {
+ let sk = match get_connection() {
+ Some(sk) => sk,
+ None => {
+ warn!("Secretkeeper HAL is unavailable, skipping test");
+ return;
+ }
+ };
+ let sink = sk.getAuthGraphKe().expect("failed to get AuthGraph");
+ let mut source = ag_vts::test_ag_participant().expect("failed to create a local source");
+ ag_vts::sink::test_corrupt_sig(&mut source, sink);
+}
+
+/// Test that the AuthGraph instance returned by SecretKeeper correctly detects
+/// when corrupted keys are returned to it.
+#[test]
+fn authgraph_corrupt_keys() {
+ let sk = match get_connection() {
+ Some(sk) => sk,
+ None => {
+ warn!("Secretkeeper HAL is unavailable, skipping test");
+ return;
+ }
+ };
+ let sink = sk.getAuthGraphKe().expect("failed to get AuthGraph");
+ let mut source = ag_vts::test_ag_participant().expect("failed to create a local source");
+ ag_vts::sink::test_corrupt_keys(&mut source, sink);
+}
// TODO(b/2797757): Add tests that match different HAL defined objects (like request/response)
// with expected bytes.
diff --git a/security/secretkeeper/default/Android.bp b/security/secretkeeper/default/Android.bp
index 1c39fa6..a920c6e 100644
--- a/security/secretkeeper/default/Android.bp
+++ b/security/secretkeeper/default/Android.bp
@@ -22,16 +22,54 @@
name: "android.hardware.security.secretkeeper-service.nonsecure",
relative_install_path: "hw",
vendor: true,
- init_rc: ["secretkeeper.rc"],
- vintf_fragments: ["secretkeeper.xml"],
+ installable: false, // install APEX
+ prefer_rlib: true,
+ defaults: [
+ "authgraph_use_latest_hal_aidl_rust",
+ ],
rustlibs: [
"android.hardware.security.secretkeeper-V1-rust",
"libandroid_logger",
+ "libauthgraph_boringssl",
+ "libauthgraph_core",
+ "libauthgraph_hal",
"libbinder_rs",
"liblog_rust",
"libsecretkeeper_comm_nostd",
+ "libsecretkeeper_hal",
],
srcs: [
"src/main.rs",
],
}
+
+prebuilt_etc {
+ name: "secretkeeper.rc",
+ src: "secretkeeper.rc",
+ installable: false,
+}
+
+prebuilt_etc {
+ name: "secretkeeper.xml",
+ src: "secretkeeper.xml",
+ sub_dir: "vintf",
+ installable: false,
+}
+
+apex {
+ name: "com.android.hardware.security.secretkeeper",
+ manifest: "apex_manifest.json",
+ file_contexts: "apex_file_contexts",
+ key: "com.android.hardware.key",
+ certificate: ":com.android.hardware.certificate",
+ vendor: true,
+ updatable: false,
+
+ binaries: [
+ "android.hardware.security.secretkeeper-service.nonsecure",
+ ],
+ prebuilts: [
+ "secretkeeper.rc",
+ "secretkeeper.xml",
+ ],
+}
diff --git a/security/secretkeeper/default/apex_file_contexts b/security/secretkeeper/default/apex_file_contexts
new file mode 100644
index 0000000..71369a8
--- /dev/null
+++ b/security/secretkeeper/default/apex_file_contexts
@@ -0,0 +1,3 @@
+(/.*)? u:object_r:vendor_file:s0
+/etc(/.*)? u:object_r:vendor_configs_file:s0
+/bin/hw/android\.hardware\.security\.secretkeeper-service\.nonsecure u:object_r:hal_secretkeeper_default_exec:s0
diff --git a/security/secretkeeper/default/apex_manifest.json b/security/secretkeeper/default/apex_manifest.json
new file mode 100644
index 0000000..7287095
--- /dev/null
+++ b/security/secretkeeper/default/apex_manifest.json
@@ -0,0 +1,4 @@
+{
+ "name": "com.android.hardware.security.secretkeeper",
+ "version": 1
+}
\ No newline at end of file
diff --git a/security/secretkeeper/default/secretkeeper.rc b/security/secretkeeper/default/secretkeeper.rc
index f39f9b7..38ee50d 100644
--- a/security/secretkeeper/default/secretkeeper.rc
+++ b/security/secretkeeper/default/secretkeeper.rc
@@ -1,4 +1,4 @@
-service vendor.secretkeeper /vendor/bin/hw/android.hardware.security.secretkeeper-service.nonsecure
+service vendor.secretkeeper /apex/com.android.hardware.security.secretkeeper/bin/hw/android.hardware.security.secretkeeper-service.nonsecure
interface aidl android.hardware.security.secretkeeper.ISecretkeeper/nonsecure
class hal
user nobody
diff --git a/security/secretkeeper/default/src/main.rs b/security/secretkeeper/default/src/main.rs
index 2d367c5..4f9302d 100644
--- a/security/secretkeeper/default/src/main.rs
+++ b/security/secretkeeper/default/src/main.rs
@@ -14,80 +14,106 @@
* limitations under the License.
*/
-use binder::{BinderFeatures, Interface};
+//! Non-secure implementation of the Secretkeeper HAL.
+
use log::{error, info, Level};
-use secretkeeper_comm::data_types::error::SecretkeeperError;
-use secretkeeper_comm::data_types::packet::{RequestPacket, ResponsePacket};
-use secretkeeper_comm::data_types::request::Request;
-use secretkeeper_comm::data_types::request_response_impl::{
- GetVersionRequest, GetVersionResponse, Opcode,
-};
-use secretkeeper_comm::data_types::response::Response;
-
+use std::sync::{Arc, Mutex};
+use authgraph_boringssl as boring;
+use authgraph_core::ta::{Role, AuthGraphTa};
+use authgraph_core::keyexchange::{MAX_OPENED_SESSIONS, AuthGraphParticipant};
+use secretkeeper_comm::ta::SecretkeeperTa;
+use secretkeeper_hal::SecretkeeperService;
+use authgraph_hal::channel::SerializedChannel;
use android_hardware_security_secretkeeper::aidl::android::hardware::security::secretkeeper::ISecretkeeper::{
- BnSecretkeeper, BpSecretkeeper, ISecretkeeper,
+ ISecretkeeper, BpSecretkeeper,
};
+use std::cell::RefCell;
+use std::rc::Rc;
+use std::sync::mpsc;
-const CURRENT_VERSION: u64 = 1;
+/// Implementation of the Secrekeeper TA that runs locally in-process (and which is therefore
+/// insecure).
+pub struct LocalTa {
+ in_tx: mpsc::Sender<Vec<u8>>,
+ out_rx: mpsc::Receiver<Vec<u8>>,
+}
-#[derive(Debug, Default)]
-pub struct NonSecureSecretkeeper;
+/// Prefix byte for messages intended for the AuthGraph TA.
+const AG_MESSAGE_PREFIX: u8 = 0x00;
+/// Prefix byte for messages intended for the Secretkeeper TA.
+const SK_MESSAGE_PREFIX: u8 = 0x01;
-impl Interface for NonSecureSecretkeeper {}
+impl LocalTa {
+ /// Create a new instance.
+ pub fn new() -> Self {
+ // Create a pair of channels to communicate with the TA thread.
+ let (in_tx, in_rx) = mpsc::channel();
+ let (out_tx, out_rx) = mpsc::channel();
-impl ISecretkeeper for NonSecureSecretkeeper {
- fn processSecretManagementRequest(&self, request: &[u8]) -> binder::Result<Vec<u8>> {
- Ok(self.process_opaque_request(request))
+ // The TA code expects to run single threaded, so spawn a thread to run it in.
+ std::thread::spawn(move || {
+ let mut crypto_impls = boring::crypto_trait_impls();
+ let sk_ta = Rc::new(RefCell::new(
+ SecretkeeperTa::new(&mut crypto_impls)
+ .expect("Failed to create local Secretkeeper TA"),
+ ));
+ let mut ag_ta = AuthGraphTa::new(
+ AuthGraphParticipant::new(crypto_impls, sk_ta.clone(), MAX_OPENED_SESSIONS)
+ .expect("Failed to create local AuthGraph TA"),
+ Role::Sink,
+ );
+
+ // Loop forever processing request messages.
+ loop {
+ let req_data: Vec<u8> = in_rx.recv().expect("failed to receive next req");
+ let rsp_data = match req_data[0] {
+ AG_MESSAGE_PREFIX => ag_ta.process(&req_data[1..]),
+ SK_MESSAGE_PREFIX => {
+ // It's safe to `borrow_mut()` because this code is not a callback
+ // from AuthGraph (the only other holder of an `Rc`), and so there
+ // can be no live `borrow()`s in this (single) thread.
+ sk_ta.borrow_mut().process(&req_data[1..])
+ }
+ prefix => panic!("unexpected messageprefix {prefix}!"),
+ };
+ out_tx.send(rsp_data).expect("failed to send out rsp");
+ }
+ });
+ Self { in_tx, out_rx }
+ }
+
+ fn execute_for(&mut self, prefix: u8, req_data: &[u8]) -> Vec<u8> {
+ let mut prefixed_req = Vec::with_capacity(req_data.len() + 1);
+ prefixed_req.push(prefix);
+ prefixed_req.extend_from_slice(req_data);
+ self.in_tx
+ .send(prefixed_req)
+ .expect("failed to send in request");
+ self.out_rx.recv().expect("failed to receive response")
}
}
-impl NonSecureSecretkeeper {
- // A set of requests to Secretkeeper are 'opaque' - encrypted bytes with inner structure
- // described by CDDL. They need to be decrypted, deserialized and processed accordingly.
- fn process_opaque_request(&self, request: &[u8]) -> Vec<u8> {
- // TODO(b/291224769) The request will need to be decrypted & response need to be encrypted
- // with key & related artifacts pre-shared via Authgraph Key Exchange HAL.
- self.process_opaque_request_unhandled_error(request)
- .unwrap_or_else(
- // SecretkeeperError is also a valid 'Response', serialize to a response packet.
- |sk_err| {
- Response::serialize_to_packet(&sk_err)
- .into_bytes()
- .expect("Panicking due to serialization failing")
- },
- )
+pub struct AuthGraphChannel(Arc<Mutex<LocalTa>>);
+impl SerializedChannel for AuthGraphChannel {
+ const MAX_SIZE: usize = usize::MAX;
+ fn execute(&self, req_data: &[u8]) -> binder::Result<Vec<u8>> {
+ Ok(self
+ .0
+ .lock()
+ .unwrap()
+ .execute_for(AG_MESSAGE_PREFIX, req_data))
}
+}
- fn process_opaque_request_unhandled_error(
- &self,
- request: &[u8],
- ) -> Result<Vec<u8>, SecretkeeperError> {
- let request_packet = RequestPacket::from_bytes(request).map_err(|e| {
- error!("Failed to get Request packet from bytes: {:?}", e);
- SecretkeeperError::RequestMalformed
- })?;
- let response_packet = match request_packet
- .opcode()
- .map_err(|_| SecretkeeperError::RequestMalformed)?
- {
- Opcode::GetVersion => Self::process_get_version_request(request_packet)?,
- _ => todo!("TODO(b/291224769): Unimplemented operations"),
- };
-
- response_packet
- .into_bytes()
- .map_err(|_| SecretkeeperError::UnexpectedServerError)
- }
-
- fn process_get_version_request(
- request: RequestPacket,
- ) -> Result<ResponsePacket, SecretkeeperError> {
- // Deserialization really just verifies the structural integrity of the request such
- // as args being empty.
- let _request = GetVersionRequest::deserialize_from_packet(request)
- .map_err(|_| SecretkeeperError::RequestMalformed)?;
- let response = GetVersionResponse::new(CURRENT_VERSION);
- Ok(response.serialize_to_packet())
+pub struct SecretkeeperChannel(Arc<Mutex<LocalTa>>);
+impl SerializedChannel for SecretkeeperChannel {
+ const MAX_SIZE: usize = usize::MAX;
+ fn execute(&self, req_data: &[u8]) -> binder::Result<Vec<u8>> {
+ Ok(self
+ .0
+ .lock()
+ .unwrap()
+ .execute_for(SK_MESSAGE_PREFIX, req_data))
}
}
@@ -104,17 +130,17 @@
error!("{}", panic_info);
}));
- let service = NonSecureSecretkeeper::default();
- let service_binder = BnSecretkeeper::new_binder(service, BinderFeatures::default());
+ let ta = Arc::new(Mutex::new(LocalTa::new()));
+ let ag_channel = AuthGraphChannel(ta.clone());
+ let sk_channel = SecretkeeperChannel(ta.clone());
+
+ let service = SecretkeeperService::new_as_binder(sk_channel, ag_channel);
let service_name = format!(
"{}/nonsecure",
<BpSecretkeeper as ISecretkeeper>::get_descriptor()
);
- binder::add_service(&service_name, service_binder.as_binder()).unwrap_or_else(|e| {
- panic!(
- "Failed to register service {} because of {:?}.",
- service_name, e
- );
+ binder::add_service(&service_name, service.as_binder()).unwrap_or_else(|e| {
+ panic!("Failed to register service {service_name} because of {e:?}.",);
});
info!("Registered Binder service, joining threadpool.");
binder::ProcessState::join_thread_pool();
diff --git a/tv/hdmi/cec/aidl/default/HdmiCecMock.cpp b/tv/hdmi/cec/aidl/default/HdmiCecMock.cpp
index 0212e7e..8a3c6f0 100644
--- a/tv/hdmi/cec/aidl/default/HdmiCecMock.cpp
+++ b/tv/hdmi/cec/aidl/default/HdmiCecMock.cpp
@@ -36,6 +36,7 @@
ALOGE("HdmiCecMock died");
auto hdmiCecMock = static_cast<HdmiCecMock*>(cookie);
hdmiCecMock->mCecThreadRun = false;
+ pthread_join(hdmiCecMock->mThreadId, NULL);
}
ScopedAStatus HdmiCecMock::addLogicalAddress(CecLogicalAddress addr, Result* _aidl_return) {
@@ -89,7 +90,9 @@
mCallback = callback;
if (callback != nullptr) {
- AIBinder_linkToDeath(this->asBinder().get(), mDeathRecipient.get(), 0 /* cookie */);
+ mDeathRecipient =
+ ndk::ScopedAIBinder_DeathRecipient(AIBinder_DeathRecipient_new(serviceDied));
+ AIBinder_linkToDeath(callback->asBinder().get(), mDeathRecipient.get(), this /* cookie */);
mInputFile = open(CEC_MSG_IN_FIFO, O_RDWR | O_CLOEXEC);
mOutputFile = open(CEC_MSG_OUT_FIFO, O_RDWR | O_CLOEXEC);
@@ -220,7 +223,7 @@
int r = -1;
// Open the input pipe
- while (mInputFile < 0) {
+ while (mCecThreadRun && mInputFile < 0) {
usleep(1000 * 1000);
mInputFile = open(CEC_MSG_IN_FIFO, O_RDONLY | O_CLOEXEC);
}
@@ -257,7 +260,15 @@
HdmiCecMock::HdmiCecMock() {
ALOGE("[halimp_aidl] Opening a virtual CEC HAL for testing and virtual machine.");
mCallback = nullptr;
- mDeathRecipient = ndk::ScopedAIBinder_DeathRecipient(AIBinder_DeathRecipient_new(serviceDied));
+ mDeathRecipient = ndk::ScopedAIBinder_DeathRecipient(nullptr);
+}
+
+HdmiCecMock::~HdmiCecMock() {
+ ALOGE("[halimp_aidl] HdmiCecMock shutting down.");
+ mCallback = nullptr;
+ mDeathRecipient = ndk::ScopedAIBinder_DeathRecipient(nullptr);
+ mCecThreadRun = false;
+ pthread_join(mThreadId, NULL);
}
} // namespace implementation
diff --git a/tv/hdmi/cec/aidl/default/HdmiCecMock.h b/tv/hdmi/cec/aidl/default/HdmiCecMock.h
index aca0581..e78b1cf 100644
--- a/tv/hdmi/cec/aidl/default/HdmiCecMock.h
+++ b/tv/hdmi/cec/aidl/default/HdmiCecMock.h
@@ -40,6 +40,7 @@
struct HdmiCecMock : public BnHdmiCec {
HdmiCecMock();
+ ~HdmiCecMock();
::ndk::ScopedAStatus addLogicalAddress(CecLogicalAddress addr, Result* _aidl_return) override;
::ndk::ScopedAStatus clearLogicalAddress() override;
::ndk::ScopedAStatus enableAudioReturnChannel(int32_t portId, bool enable) override;
diff --git a/wifi/aidl/aidl_api/android.hardware.wifi/current/android/hardware/wifi/IWifiChip.aidl b/wifi/aidl/aidl_api/android.hardware.wifi/current/android/hardware/wifi/IWifiChip.aidl
index 2d7fe03..db82a6e 100644
--- a/wifi/aidl/aidl_api/android.hardware.wifi/current/android/hardware/wifi/IWifiChip.aidl
+++ b/wifi/aidl/aidl_api/android.hardware.wifi/current/android/hardware/wifi/IWifiChip.aidl
@@ -84,6 +84,7 @@
void enableStaChannelForPeerNetwork(in int channelCategoryEnableFlag);
void setMloMode(in android.hardware.wifi.IWifiChip.ChipMloMode mode);
@PropagateAllowBlocking android.hardware.wifi.IWifiApIface createApOrBridgedApIface(in android.hardware.wifi.IfaceConcurrencyType iface, in android.hardware.wifi.common.OuiKeyedData[] vendorData);
+ void setVoipMode(in android.hardware.wifi.IWifiChip.VoipMode mode);
const int NO_POWER_CAP_CONSTANT = 0x7FFFFFFF;
@Backing(type="int") @VintfStability
enum FeatureSetMask {
@@ -162,6 +163,11 @@
NAN_INSTANT_MODE = (1 << 2) /* 4 */,
}
@Backing(type="int") @VintfStability
+ enum VoipMode {
+ OFF = 0,
+ VOICE = 1,
+ }
+ @Backing(type="int") @VintfStability
enum ChannelCategoryMask {
INDOOR_CHANNEL = (1 << 0) /* 1 */,
DFS_CHANNEL = (1 << 1) /* 2 */,
diff --git a/wifi/aidl/aidl_api/android.hardware.wifi/current/android/hardware/wifi/IWifiStaIface.aidl b/wifi/aidl/aidl_api/android.hardware.wifi/current/android/hardware/wifi/IWifiStaIface.aidl
index b557cc2..f838413 100644
--- a/wifi/aidl/aidl_api/android.hardware.wifi/current/android/hardware/wifi/IWifiStaIface.aidl
+++ b/wifi/aidl/aidl_api/android.hardware.wifi/current/android/hardware/wifi/IWifiStaIface.aidl
@@ -78,5 +78,6 @@
TDLS_OFFCHANNEL = (1 << 11) /* 2048 */,
ND_OFFLOAD = (1 << 12) /* 4096 */,
KEEP_ALIVE = (1 << 13) /* 8192 */,
+ ROAMING_MODE_CONTROL = (1 << 14) /* 16384 */,
}
}
diff --git a/wifi/aidl/aidl_api/android.hardware.wifi/current/android/hardware/wifi/NanDataPathSecurityConfig.aidl b/wifi/aidl/aidl_api/android.hardware.wifi/current/android/hardware/wifi/NanDataPathSecurityConfig.aidl
index 635dbce..48e9501 100644
--- a/wifi/aidl/aidl_api/android.hardware.wifi/current/android/hardware/wifi/NanDataPathSecurityConfig.aidl
+++ b/wifi/aidl/aidl_api/android.hardware.wifi/current/android/hardware/wifi/NanDataPathSecurityConfig.aidl
@@ -39,4 +39,10 @@
byte[32] pmk;
byte[] passphrase;
byte[16] scid;
+ boolean enable16ReplyCountersForTksa;
+ boolean enable16ReplyCountersForGtksa;
+ boolean supportGtkAndIgtk;
+ boolean supportBigtksa;
+ boolean enableNcsBip256;
+ boolean requiresEnhancedFrameProtection;
}
diff --git a/wifi/aidl/aidl_api/android.hardware.wifi/current/android/hardware/wifi/StaRoamingState.aidl b/wifi/aidl/aidl_api/android.hardware.wifi/current/android/hardware/wifi/StaRoamingState.aidl
index 1f3d91f..fd7d567 100644
--- a/wifi/aidl/aidl_api/android.hardware.wifi/current/android/hardware/wifi/StaRoamingState.aidl
+++ b/wifi/aidl/aidl_api/android.hardware.wifi/current/android/hardware/wifi/StaRoamingState.aidl
@@ -36,4 +36,5 @@
enum StaRoamingState {
DISABLED = 0,
ENABLED = 1,
+ AGGRESSIVE = 2,
}
diff --git a/wifi/aidl/android/hardware/wifi/IWifiChip.aidl b/wifi/aidl/android/hardware/wifi/IWifiChip.aidl
index 733ff62..cf4c884 100644
--- a/wifi/aidl/android/hardware/wifi/IWifiChip.aidl
+++ b/wifi/aidl/android/hardware/wifi/IWifiChip.aidl
@@ -385,6 +385,16 @@
}
/**
+ * This enum represents the different VoIP mode that can be set through |setVoipMode|.
+ */
+ @VintfStability
+ @Backing(type="int")
+ enum VoipMode {
+ OFF = 0,
+ VOICE = 1,
+ }
+
+ /**
* Configure the Chip.
* This may NOT be called to reconfigure a chip due to an internal
* limitation. Calling this when chip is already configured in a different
@@ -1173,4 +1183,23 @@
@PropagateAllowBlocking
IWifiApIface createApOrBridgedApIface(
in IfaceConcurrencyType iface, in OuiKeyedData[] vendorData);
+
+ /**
+ * API to set the wifi VoIP mode.
+ *
+ * The VoIP mode is a hint to the HAL to enable or disable Wi-Fi VoIP
+ * optimization. The optimization should be enabled if the mode is NOT set to |OFF|.
+ * Furthermore, HAL should implement relevant optimization techniques based on the
+ * current operational mode.
+ *
+ * Note: Wi-Fi VoIP optimization may trade-off power against Wi-Fi
+ * performance but it provides better voice quility.
+ *
+ * @param mode Voip mode as defined by the enum |VoipMode|
+ * @throws ServiceSpecificException with one of the following values:
+ * |WifiStatusCode.ERROR_WIFI_CHIP_INVALID|,
+ * |WifiStatusCode.ERROR_INVALID_ARGS|,
+ * |WifiStatusCode.ERROR_UNKNOWN|
+ */
+ void setVoipMode(in VoipMode mode);
}
diff --git a/wifi/aidl/android/hardware/wifi/IWifiStaIface.aidl b/wifi/aidl/android/hardware/wifi/IWifiStaIface.aidl
index fd59564..3c8b55f 100644
--- a/wifi/aidl/android/hardware/wifi/IWifiStaIface.aidl
+++ b/wifi/aidl/android/hardware/wifi/IWifiStaIface.aidl
@@ -100,6 +100,10 @@
* Support for keep alive packet offload.
*/
KEEP_ALIVE = 1 << 13,
+ /**
+ * Support for configuring roaming mode.
+ */
+ ROAMING_MODE_CONTROL = 1 << 14,
}
/**
diff --git a/wifi/aidl/android/hardware/wifi/NanDataPathSecurityConfig.aidl b/wifi/aidl/android/hardware/wifi/NanDataPathSecurityConfig.aidl
index 9a2013b..b6c5eef 100644
--- a/wifi/aidl/android/hardware/wifi/NanDataPathSecurityConfig.aidl
+++ b/wifi/aidl/android/hardware/wifi/NanDataPathSecurityConfig.aidl
@@ -58,4 +58,49 @@
* setting up the Secure Data Path.
*/
byte[16] scid;
+
+ /**
+ * Enables the 16 replay counter for ND-TKSA(NAN Data Pairwise Security Association) and
+ * NM-TKSA(NAN managerment Pairwise Security Association), if set to false will use 4 replay
+ * counter as default
+ * Wi-Fi Aware spec 4.0: 9.5.21.2 Cipher Suite Information attribute
+ */
+ boolean enable16ReplyCountersForTksa;
+
+ /**
+ * Enables the 16 replay counter for GTKSA(Group Transient Key security associations), if set to
+ * false will use 4 replay counter as default.
+ * Wi-Fi Aware spec 4.0: 9.5.21.2 Cipher Suite Information attribute
+ */
+ boolean enable16ReplyCountersForGtksa;
+
+ /**
+ * GTK(Group Transient Key) used to protect group addressed data frames,
+ * IGTK(Integrity Group Transient Key) used to protect multicast management frames, set to true
+ * if supported.
+ * Wi-Fi Aware spec 4.0: 9.5.21.2 Cipher Suite Information attribute
+ */
+ boolean supportGtkAndIgtk;
+
+ /**
+ * BIGTK(Beacon Integrity Group Transient Key) used to protect Beacon frames, set to true if
+ * supported.
+ * Ref: Wi-Fi Aware spec 4.0: 9.5.21.2 Cipher Suite Information attribute
+ */
+ boolean supportBigtksa;
+
+ /**
+ * Enables NCS-BIP-256 for IGTKSA(Integrity Group Transient Key security associations)
+ * and BIGTK(Beacon Integrity Group Transient Key security associations), if set to false will
+ * use NCS-BIP-128 as default
+ * Wi-Fi Aware spec 4.0: 9.5.21.2 Cipher Suite Information attribute
+ */
+ boolean enableNcsBip256;
+
+ /**
+ * Require enhanced frame protection if supported, which includes multicast management frame
+ * protection, group addressed data protection and beacon frame protection.
+ * Wi-Fi Aware spec 4.0: 7.3 frame protection
+ */
+ boolean requiresEnhancedFrameProtection;
}
diff --git a/wifi/aidl/android/hardware/wifi/StaRoamingState.aidl b/wifi/aidl/android/hardware/wifi/StaRoamingState.aidl
index d75d323..6872a17 100644
--- a/wifi/aidl/android/hardware/wifi/StaRoamingState.aidl
+++ b/wifi/aidl/android/hardware/wifi/StaRoamingState.aidl
@@ -32,4 +32,9 @@
* the |StaRoamingConfig| parameters set using |configureRoaming|.
*/
ENABLED = 1,
+ /**
+ * Driver/Firmware is allowed to roam more aggressively. For instance,
+ * roaming can be triggered at higher RSSI thresholds than normal.
+ */
+ AGGRESSIVE = 2,
}
diff --git a/wifi/aidl/default/aidl_struct_util.cpp b/wifi/aidl/default/aidl_struct_util.cpp
index b39ccba..ba92149 100644
--- a/wifi/aidl/default/aidl_struct_util.cpp
+++ b/wifi/aidl/default/aidl_struct_util.cpp
@@ -92,6 +92,8 @@
return IWifiStaIface::FeatureSetMask::ND_OFFLOAD;
case WIFI_FEATURE_MKEEP_ALIVE:
return IWifiStaIface::FeatureSetMask::KEEP_ALIVE;
+ case WIFI_FEATURE_ROAMING_MODE_CONTROL:
+ return IWifiStaIface::FeatureSetMask::ROAMING_MODE_CONTROL;
};
CHECK(false) << "Unknown legacy feature: " << feature;
return {};
@@ -457,7 +459,8 @@
{WIFI_FEATURE_GSCAN, WIFI_FEATURE_LINK_LAYER_STATS, WIFI_FEATURE_RSSI_MONITOR,
WIFI_FEATURE_CONTROL_ROAMING, WIFI_FEATURE_IE_WHITELIST, WIFI_FEATURE_SCAN_RAND,
WIFI_FEATURE_INFRA_5G, WIFI_FEATURE_HOTSPOT, WIFI_FEATURE_PNO, WIFI_FEATURE_TDLS,
- WIFI_FEATURE_TDLS_OFFCHANNEL, WIFI_FEATURE_CONFIG_NDO, WIFI_FEATURE_MKEEP_ALIVE}) {
+ WIFI_FEATURE_TDLS_OFFCHANNEL, WIFI_FEATURE_CONFIG_NDO, WIFI_FEATURE_MKEEP_ALIVE,
+ WIFI_FEATURE_ROAMING_MODE_CONTROL}) {
if (feature & legacy_feature_set) {
*aidl_feature_set |= static_cast<uint32_t>(convertLegacyStaIfaceFeatureToAidl(feature));
}
@@ -1147,6 +1150,8 @@
return legacy_hal::ROAMING_ENABLE;
case StaRoamingState::DISABLED:
return legacy_hal::ROAMING_DISABLE;
+ case StaRoamingState::AGGRESSIVE:
+ return legacy_hal::ROAMING_AGGRESSIVE;
};
CHECK(false);
}
@@ -2088,6 +2093,17 @@
memcpy(legacy_request->scid, aidl_request.securityConfig.scid.data(), legacy_request->scid_len);
legacy_request->publish_subscribe_id = static_cast<uint8_t>(aidl_request.discoverySessionId);
+ legacy_request->csia_capabilities |=
+ aidl_request.securityConfig.enable16ReplyCountersForTksa ? 0x1 : 0x0;
+ legacy_request->csia_capabilities |=
+ aidl_request.securityConfig.enable16ReplyCountersForGtksa ? 0x8 : 0x0;
+ if (aidl_request.securityConfig.supportGtkAndIgtk) {
+ legacy_request->csia_capabilities |= aidl_request.securityConfig.supportBigtksa ? 0x4 : 0x2;
+ }
+ legacy_request->csia_capabilities |= aidl_request.securityConfig.enableNcsBip256 ? 0x16 : 0x0;
+ legacy_request->gtk_protection =
+ aidl_request.securityConfig.requiresEnhancedFrameProtection ? 1 : 0;
+
return true;
}
@@ -2170,6 +2186,17 @@
memcpy(legacy_request->scid, aidl_request.securityConfig.scid.data(), legacy_request->scid_len);
legacy_request->publish_subscribe_id = static_cast<uint8_t>(aidl_request.discoverySessionId);
+ legacy_request->csia_capabilities |=
+ aidl_request.securityConfig.enable16ReplyCountersForTksa ? 0x1 : 0x0;
+ legacy_request->csia_capabilities |=
+ aidl_request.securityConfig.enable16ReplyCountersForGtksa ? 0x8 : 0x0;
+ if (aidl_request.securityConfig.supportGtkAndIgtk) {
+ legacy_request->csia_capabilities |= aidl_request.securityConfig.supportBigtksa ? 0x4 : 0x2;
+ }
+ legacy_request->csia_capabilities |= aidl_request.securityConfig.enableNcsBip256 ? 0x16 : 0x0;
+ legacy_request->gtk_protection =
+ aidl_request.securityConfig.requiresEnhancedFrameProtection ? 1 : 0;
+
return true;
}
diff --git a/wifi/aidl/default/wifi_chip.cpp b/wifi/aidl/default/wifi_chip.cpp
index d72775c..2db3b4a 100644
--- a/wifi/aidl/default/wifi_chip.cpp
+++ b/wifi/aidl/default/wifi_chip.cpp
@@ -20,6 +20,7 @@
#include <android-base/unique_fd.h>
#include <cutils/properties.h>
#include <fcntl.h>
+#include <hardware_legacy/wifi_hal.h>
#include <net/if.h>
#include <sys/stat.h>
#include <sys/sysmacros.h>
@@ -605,6 +606,11 @@
&WifiChip::setMloModeInternal, in_mode);
}
+ndk::ScopedAStatus WifiChip::setVoipMode(const VoipMode in_mode) {
+ return validateAndCall(this, WifiStatusCode::ERROR_WIFI_CHIP_INVALID,
+ &WifiChip::setVoipModeInternal, in_mode);
+}
+
void WifiChip::invalidateAndRemoveAllIfaces() {
invalidateAndClearBridgedApAll();
invalidateAndClearAll(ap_ifaces_);
@@ -1913,6 +1919,23 @@
return createWifiStatusFromLegacyError(legacy_hal_.lock()->setMloMode(mode));
}
+ndk::ScopedAStatus WifiChip::setVoipModeInternal(const WifiChip::VoipMode in_mode) {
+ const auto ifname = getFirstActiveWlanIfaceName();
+ wifi_voip_mode mode;
+ switch (in_mode) {
+ case WifiChip::VoipMode::VOICE:
+ mode = wifi_voip_mode::WIFI_VOIP_MODE_ON;
+ break;
+ case WifiChip::VoipMode::OFF:
+ mode = wifi_voip_mode::WIFI_VOIP_MODE_OFF;
+ break;
+ default:
+ PLOG(ERROR) << "Error: invalid mode: " << toString(in_mode);
+ return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS);
+ }
+ return createWifiStatusFromLegacyError(legacy_hal_.lock()->setVoipMode(ifname, mode));
+}
+
} // namespace wifi
} // namespace hardware
} // namespace android
diff --git a/wifi/aidl/default/wifi_chip.h b/wifi/aidl/default/wifi_chip.h
index c6517db..ffd507f 100644
--- a/wifi/aidl/default/wifi_chip.h
+++ b/wifi/aidl/default/wifi_chip.h
@@ -158,6 +158,7 @@
int32_t in_channelCategoryEnableFlag) override;
binder_status_t dump(int fd, const char** args, uint32_t numArgs) override;
ndk::ScopedAStatus setMloMode(const ChipMloMode in_mode) override;
+ ndk::ScopedAStatus setVoipMode(const VoipMode in_mode) override;
private:
void invalidateAndRemoveAllIfaces();
@@ -269,6 +270,7 @@
getSupportedRadioCombinationsInternal();
std::pair<WifiChipCapabilities, ndk::ScopedAStatus> getWifiChipCapabilitiesInternal();
ndk::ScopedAStatus setMloModeInternal(const ChipMloMode in_mode);
+ ndk::ScopedAStatus setVoipModeInternal(const VoipMode in_mode);
void retrieveDynamicIfaceCombination();
void setWeakPtr(std::weak_ptr<WifiChip> ptr);
diff --git a/wifi/aidl/default/wifi_legacy_hal.h b/wifi/aidl/default/wifi_legacy_hal.h
index 8e7c1b8..4dd0d62 100644
--- a/wifi/aidl/default/wifi_legacy_hal.h
+++ b/wifi/aidl/default/wifi_legacy_hal.h
@@ -186,6 +186,7 @@
using ::NanTxType;
using ::NpkSecurityAssociation;
using ::PASN;
+using ::ROAMING_AGGRESSIVE;
using ::ROAMING_DISABLE;
using ::ROAMING_ENABLE;
using ::RTT_PEER_AP;
diff --git a/wifi/hostapd/aidl/aidl_api/android.hardware.wifi.hostapd/current/android/hardware/wifi/hostapd/ApInfo.aidl b/wifi/hostapd/aidl/aidl_api/android.hardware.wifi.hostapd/current/android/hardware/wifi/hostapd/ApInfo.aidl
index ca20f37..1a66105 100644
--- a/wifi/hostapd/aidl/aidl_api/android.hardware.wifi.hostapd/current/android/hardware/wifi/hostapd/ApInfo.aidl
+++ b/wifi/hostapd/aidl/aidl_api/android.hardware.wifi.hostapd/current/android/hardware/wifi/hostapd/ApInfo.aidl
@@ -40,4 +40,5 @@
android.hardware.wifi.hostapd.ChannelBandwidth channelBandwidth;
android.hardware.wifi.hostapd.Generation generation;
byte[] apIfaceInstanceMacAddress;
+ @nullable android.hardware.wifi.common.OuiKeyedData[] vendorData;
}
diff --git a/wifi/hostapd/aidl/android/hardware/wifi/hostapd/ApInfo.aidl b/wifi/hostapd/aidl/android/hardware/wifi/hostapd/ApInfo.aidl
index a6fe63b..f2b2ee6 100644
--- a/wifi/hostapd/aidl/android/hardware/wifi/hostapd/ApInfo.aidl
+++ b/wifi/hostapd/aidl/android/hardware/wifi/hostapd/ApInfo.aidl
@@ -16,6 +16,7 @@
package android.hardware.wifi.hostapd;
+import android.hardware.wifi.common.OuiKeyedData;
import android.hardware.wifi.hostapd.ChannelBandwidth;
import android.hardware.wifi.hostapd.Generation;
@@ -57,4 +58,9 @@
* MAC Address of the apIfaceInstance.
*/
byte[] apIfaceInstanceMacAddress;
+
+ /**
+ * Optional vendor-specific information.
+ */
+ @nullable OuiKeyedData[] vendorData;
}
diff --git a/wifi/supplicant/aidl/Android.bp b/wifi/supplicant/aidl/Android.bp
index 76b0902..632927d 100644
--- a/wifi/supplicant/aidl/Android.bp
+++ b/wifi/supplicant/aidl/Android.bp
@@ -27,6 +27,9 @@
srcs: [
"android/hardware/wifi/supplicant/*.aidl",
],
+ imports: [
+ "android.hardware.wifi.common-V1",
+ ],
stability: "vintf",
backend: {
java: {
@@ -45,6 +48,9 @@
ndk: {
gen_trace: true,
},
+ cpp: {
+ enabled: false,
+ },
},
versions_with_info: [
{
@@ -58,5 +64,4 @@
],
frozen: false,
-
}
diff --git a/wifi/supplicant/aidl/aidl_api/android.hardware.wifi.supplicant/current/android/hardware/wifi/supplicant/ConnectionCapabilities.aidl b/wifi/supplicant/aidl/aidl_api/android.hardware.wifi.supplicant/current/android/hardware/wifi/supplicant/ConnectionCapabilities.aidl
index 553cbc8..a0dd32f 100644
--- a/wifi/supplicant/aidl/aidl_api/android.hardware.wifi.supplicant/current/android/hardware/wifi/supplicant/ConnectionCapabilities.aidl
+++ b/wifi/supplicant/aidl/aidl_api/android.hardware.wifi.supplicant/current/android/hardware/wifi/supplicant/ConnectionCapabilities.aidl
@@ -40,4 +40,5 @@
int maxNumberRxSpatialStreams;
android.hardware.wifi.supplicant.LegacyMode legacyMode;
boolean apTidToLinkMapNegotiationSupported;
+ @nullable android.hardware.wifi.common.OuiKeyedData[] vendorData;
}
diff --git a/wifi/supplicant/aidl/aidl_api/android.hardware.wifi.supplicant/current/android/hardware/wifi/supplicant/ISupplicantP2pIfaceCallback.aidl b/wifi/supplicant/aidl/aidl_api/android.hardware.wifi.supplicant/current/android/hardware/wifi/supplicant/ISupplicantP2pIfaceCallback.aidl
index 8aa593f..851e851 100644
--- a/wifi/supplicant/aidl/aidl_api/android.hardware.wifi.supplicant/current/android/hardware/wifi/supplicant/ISupplicantP2pIfaceCallback.aidl
+++ b/wifi/supplicant/aidl/aidl_api/android.hardware.wifi.supplicant/current/android/hardware/wifi/supplicant/ISupplicantP2pIfaceCallback.aidl
@@ -34,6 +34,9 @@
package android.hardware.wifi.supplicant;
@VintfStability
interface ISupplicantP2pIfaceCallback {
+ /**
+ * @deprecated This callback is deprecated from AIDL v2, newer HAL should call onDeviceFoundWithParams.
+ */
oneway void onDeviceFound(in byte[] srcAddress, in byte[] p2pDeviceAddress, in byte[] primaryDeviceType, in String deviceName, in android.hardware.wifi.supplicant.WpsConfigMethods configMethods, in byte deviceCapabilities, in android.hardware.wifi.supplicant.P2pGroupCapabilityMask groupCapabilities, in byte[] wfdDeviceInfo);
oneway void onDeviceLost(in byte[] p2pDeviceAddress);
oneway void onFindStopped();
@@ -60,9 +63,13 @@
*/
oneway void onStaDeauthorized(in byte[] srcAddress, in byte[] p2pDeviceAddress);
oneway void onGroupFrequencyChanged(in String groupIfname, in int frequency);
+ /**
+ * @deprecated This callback is deprecated from AIDL v3, newer HAL should call onDeviceFoundWithParams.
+ */
oneway void onDeviceFoundWithVendorElements(in byte[] srcAddress, in byte[] p2pDeviceAddress, in byte[] primaryDeviceType, in String deviceName, in android.hardware.wifi.supplicant.WpsConfigMethods configMethods, in byte deviceCapabilities, in android.hardware.wifi.supplicant.P2pGroupCapabilityMask groupCapabilities, in byte[] wfdDeviceInfo, in byte[] wfdR2DeviceInfo, in byte[] vendorElemBytes);
oneway void onGroupStartedWithParams(in android.hardware.wifi.supplicant.P2pGroupStartedEventParams groupStartedEventParams);
oneway void onPeerClientJoined(in android.hardware.wifi.supplicant.P2pPeerClientJoinedEventParams clientJoinedEventParams);
oneway void onPeerClientDisconnected(in android.hardware.wifi.supplicant.P2pPeerClientDisconnectedEventParams clientDisconnectedEventParams);
oneway void onProvisionDiscoveryCompletedEvent(in android.hardware.wifi.supplicant.P2pProvisionDiscoveryCompletedEventParams provisionDiscoveryCompletedEventParams);
+ oneway void onDeviceFoundWithParams(in android.hardware.wifi.supplicant.P2pDeviceFoundEventParams deviceFoundEventParams);
}
diff --git a/wifi/supplicant/aidl/aidl_api/android.hardware.wifi.supplicant/current/android/hardware/wifi/supplicant/ISupplicantStaIface.aidl b/wifi/supplicant/aidl/aidl_api/android.hardware.wifi.supplicant/current/android/hardware/wifi/supplicant/ISupplicantStaIface.aidl
index 1616b26..1f3aa48 100644
--- a/wifi/supplicant/aidl/aidl_api/android.hardware.wifi.supplicant/current/android/hardware/wifi/supplicant/ISupplicantStaIface.aidl
+++ b/wifi/supplicant/aidl/aidl_api/android.hardware.wifi.supplicant/current/android/hardware/wifi/supplicant/ISupplicantStaIface.aidl
@@ -54,6 +54,9 @@
android.hardware.wifi.supplicant.IfaceType getType();
android.hardware.wifi.supplicant.WpaDriverCapabilitiesMask getWpaDriverCapabilities();
void initiateAnqpQuery(in byte[] macAddress, in android.hardware.wifi.supplicant.AnqpInfoId[] infoElements, in android.hardware.wifi.supplicant.Hs20AnqpSubtypes[] subTypes);
+ /**
+ * @deprecated No longer in use.
+ */
void initiateHs20IconQuery(in byte[] macAddress, in String fileName);
void initiateTdlsDiscover(in byte[] macAddress);
void initiateTdlsSetup(in byte[] macAddress);
diff --git a/wifi/supplicant/aidl/aidl_api/android.hardware.wifi.supplicant/current/android/hardware/wifi/supplicant/ISupplicantStaIfaceCallback.aidl b/wifi/supplicant/aidl/aidl_api/android.hardware.wifi.supplicant/current/android/hardware/wifi/supplicant/ISupplicantStaIfaceCallback.aidl
index 1c23223..898c2d4 100644
--- a/wifi/supplicant/aidl/aidl_api/android.hardware.wifi.supplicant/current/android/hardware/wifi/supplicant/ISupplicantStaIfaceCallback.aidl
+++ b/wifi/supplicant/aidl/aidl_api/android.hardware.wifi.supplicant/current/android/hardware/wifi/supplicant/ISupplicantStaIfaceCallback.aidl
@@ -53,6 +53,9 @@
oneway void onExtRadioWorkStart(in int id);
oneway void onExtRadioWorkTimeout(in int id);
oneway void onHs20DeauthImminentNotice(in byte[] bssid, in int reasonCode, in int reAuthDelayInSec, in String url);
+ /**
+ * @deprecated No longer in use.
+ */
oneway void onHs20IconQueryDone(in byte[] bssid, in String fileName, in byte[] data);
oneway void onHs20SubscriptionRemediation(in byte[] bssid, in android.hardware.wifi.supplicant.OsuMethod osuMethod, in String url);
oneway void onHs20TermsAndConditionsAcceptanceRequestedNotification(in byte[] bssid, in String url);
diff --git a/wifi/supplicant/aidl/aidl_api/android.hardware.wifi.supplicant/current/android/hardware/wifi/supplicant/ISupplicantStaNetwork.aidl b/wifi/supplicant/aidl/aidl_api/android.hardware.wifi.supplicant/current/android/hardware/wifi/supplicant/ISupplicantStaNetwork.aidl
index bfc05a4..488037f 100644
--- a/wifi/supplicant/aidl/aidl_api/android.hardware.wifi.supplicant/current/android/hardware/wifi/supplicant/ISupplicantStaNetwork.aidl
+++ b/wifi/supplicant/aidl/aidl_api/android.hardware.wifi.supplicant/current/android/hardware/wifi/supplicant/ISupplicantStaNetwork.aidl
@@ -129,6 +129,8 @@
void setRoamingConsortiumSelection(in byte[] selectedRcoi);
void setMinimumTlsVersionEapPhase1Param(android.hardware.wifi.supplicant.TlsVersion tlsVersion);
void setStrictConservativePeerMode(in boolean enable);
+ void disableEht();
+ void setVendorData(in android.hardware.wifi.common.OuiKeyedData[] vendorData);
const int SSID_MAX_LEN_IN_BYTES = 32;
const int PSK_PASSPHRASE_MIN_LEN_IN_BYTES = 8;
const int PSK_PASSPHRASE_MAX_LEN_IN_BYTES = 63;
diff --git a/wifi/supplicant/aidl/aidl_api/android.hardware.wifi.supplicant/current/android/hardware/wifi/supplicant/P2pDeviceFoundEventParams.aidl b/wifi/supplicant/aidl/aidl_api/android.hardware.wifi.supplicant/current/android/hardware/wifi/supplicant/P2pDeviceFoundEventParams.aidl
new file mode 100644
index 0000000..ee8e6dc
--- /dev/null
+++ b/wifi/supplicant/aidl/aidl_api/android.hardware.wifi.supplicant/current/android/hardware/wifi/supplicant/P2pDeviceFoundEventParams.aidl
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2023 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.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+// the interface (from the latest frozen version), the build system will
+// prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.hardware.wifi.supplicant;
+@VintfStability
+parcelable P2pDeviceFoundEventParams {
+ byte[6] srcAddress;
+ byte[6] p2pDeviceAddress;
+ byte[] primaryDeviceType;
+ String deviceName;
+ int configMethods;
+ byte deviceCapabilities;
+ int groupCapabilities;
+ byte[] wfdDeviceInfo;
+ byte[] wfdR2DeviceInfo;
+ byte[] vendorElemBytes;
+ @nullable android.hardware.wifi.common.OuiKeyedData[] vendorData;
+}
diff --git a/wifi/supplicant/aidl/android/hardware/wifi/supplicant/ConnectionCapabilities.aidl b/wifi/supplicant/aidl/android/hardware/wifi/supplicant/ConnectionCapabilities.aidl
index 4921a67..64a515f 100644
--- a/wifi/supplicant/aidl/android/hardware/wifi/supplicant/ConnectionCapabilities.aidl
+++ b/wifi/supplicant/aidl/android/hardware/wifi/supplicant/ConnectionCapabilities.aidl
@@ -16,6 +16,7 @@
package android.hardware.wifi.supplicant;
+import android.hardware.wifi.common.OuiKeyedData;
import android.hardware.wifi.supplicant.LegacyMode;
import android.hardware.wifi.supplicant.WifiTechnology;
@@ -48,4 +49,9 @@
* Indicates the AP support for TID-to-link mapping negotiation.
*/
boolean apTidToLinkMapNegotiationSupported;
+ /**
+ * Additional vendor-specific data. Null value indicates
+ * that no vendor data is provided.
+ */
+ @nullable OuiKeyedData[] vendorData;
}
diff --git a/wifi/supplicant/aidl/android/hardware/wifi/supplicant/ISupplicantP2pIfaceCallback.aidl b/wifi/supplicant/aidl/android/hardware/wifi/supplicant/ISupplicantP2pIfaceCallback.aidl
index 8befc0d..11cd867 100644
--- a/wifi/supplicant/aidl/android/hardware/wifi/supplicant/ISupplicantP2pIfaceCallback.aidl
+++ b/wifi/supplicant/aidl/android/hardware/wifi/supplicant/ISupplicantP2pIfaceCallback.aidl
@@ -16,6 +16,7 @@
package android.hardware.wifi.supplicant;
+import android.hardware.wifi.supplicant.P2pDeviceFoundEventParams;
import android.hardware.wifi.supplicant.P2pGroupCapabilityMask;
import android.hardware.wifi.supplicant.P2pGroupStartedEventParams;
import android.hardware.wifi.supplicant.P2pPeerClientDisconnectedEventParams;
@@ -38,6 +39,9 @@
oneway interface ISupplicantP2pIfaceCallback {
/**
* Used to indicate that a P2P device has been found.
+ * <p>
+ * @deprecated This callback is deprecated from AIDL v2, newer HAL should call
+ * onDeviceFoundWithParams.
*
* @param srcAddress MAC address of the device found. This must either
* be the P2P device address or the P2P interface address.
@@ -228,6 +232,9 @@
/**
* Used to indicate that a P2P device has been found.
+ * <p>
+ * @deprecated This callback is deprecated from AIDL v3, newer HAL should call
+ * onDeviceFoundWithParams.
*
* @param srcAddress MAC address of the device found. This must either
* be the P2P device address for a peer which is not in a group,
@@ -288,4 +295,11 @@
*/
void onProvisionDiscoveryCompletedEvent(
in P2pProvisionDiscoveryCompletedEventParams provisionDiscoveryCompletedEventParams);
+
+ /**
+ * Used to indicate that a P2P device has been found.
+ *
+ * @param deviceFoundEventParams Parameters associated with the device found event.
+ */
+ void onDeviceFoundWithParams(in P2pDeviceFoundEventParams deviceFoundEventParams);
}
diff --git a/wifi/supplicant/aidl/android/hardware/wifi/supplicant/ISupplicantStaIface.aidl b/wifi/supplicant/aidl/android/hardware/wifi/supplicant/ISupplicantStaIface.aidl
index 06ab8fb..d7b4e62 100644
--- a/wifi/supplicant/aidl/android/hardware/wifi/supplicant/ISupplicantStaIface.aidl
+++ b/wifi/supplicant/aidl/android/hardware/wifi/supplicant/ISupplicantStaIface.aidl
@@ -304,6 +304,8 @@
* The icon data fetched must be returned in the
* |ISupplicantStaIfaceCallback.onHs20IconQueryDone| callback.
*
+ * @deprecated No longer in use.
+ *
* @param macAddress MAC address of the access point.
* @param fileName Name of the file to request from the access point.
* @throws ServiceSpecificException with one of the following values:
diff --git a/wifi/supplicant/aidl/android/hardware/wifi/supplicant/ISupplicantStaIfaceCallback.aidl b/wifi/supplicant/aidl/android/hardware/wifi/supplicant/ISupplicantStaIfaceCallback.aidl
index 17a220d..58893eb 100644
--- a/wifi/supplicant/aidl/android/hardware/wifi/supplicant/ISupplicantStaIfaceCallback.aidl
+++ b/wifi/supplicant/aidl/android/hardware/wifi/supplicant/ISupplicantStaIfaceCallback.aidl
@@ -198,6 +198,8 @@
/**
* Used to indicate the result of Hotspot 2.0 Icon query.
*
+ * @deprecated No longer in use.
+ *
* @param bssid BSSID of the access point.
* @param fileName Name of the file that was requested.
* @param data Icon data fetched from the access point.
diff --git a/wifi/supplicant/aidl/android/hardware/wifi/supplicant/ISupplicantStaNetwork.aidl b/wifi/supplicant/aidl/android/hardware/wifi/supplicant/ISupplicantStaNetwork.aidl
index 750cf72..fc7babf 100644
--- a/wifi/supplicant/aidl/android/hardware/wifi/supplicant/ISupplicantStaNetwork.aidl
+++ b/wifi/supplicant/aidl/android/hardware/wifi/supplicant/ISupplicantStaNetwork.aidl
@@ -16,6 +16,7 @@
package android.hardware.wifi.supplicant;
+import android.hardware.wifi.common.OuiKeyedData;
import android.hardware.wifi.supplicant.AuthAlgMask;
import android.hardware.wifi.supplicant.DppConnectionKeys;
import android.hardware.wifi.supplicant.EapMethod;
@@ -1141,4 +1142,27 @@
* |SupplicantStatusCode.FAILURE_NETWORK_INVALID|
*/
void setStrictConservativePeerMode(in boolean enable);
+
+ /**
+ * Disables Extremely High Throughput (EHT) mode, aka Wi-Fi 7 support, for the network. When
+ * EHT is disabled, the device ceases to transmit EHT related Information Elements (IEs),
+ * including multi-link IEs and EHT capability, in subsequent messages such as (Re)Association
+ * requests to the Access Point (AP).
+ *
+ * @throws ServiceSpecificException with one of the following values:
+ * |SupplicantStatusCode.FAILURE_UNKNOWN|,
+ * |SupplicantStatusCode.FAILURE_NETWORK_INVALID|
+ */
+ void disableEht();
+
+ /**
+ * Set additional vendor-provided configuration data.
+ *
+ * @param vendorData List of |OuiKeyedData| containing the vendor-provided
+ * configuration data.
+ * @throws ServiceSpecificException with one of the following values:
+ * |SupplicantStatusCode.FAILURE_UNKNOWN|,
+ * |SupplicantStatusCode.FAILURE_NETWORK_INVALID|
+ */
+ void setVendorData(in OuiKeyedData[] vendorData);
}
diff --git a/wifi/supplicant/aidl/android/hardware/wifi/supplicant/P2pDeviceFoundEventParams.aidl b/wifi/supplicant/aidl/android/hardware/wifi/supplicant/P2pDeviceFoundEventParams.aidl
new file mode 100644
index 0000000..15917b6
--- /dev/null
+++ b/wifi/supplicant/aidl/android/hardware/wifi/supplicant/P2pDeviceFoundEventParams.aidl
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.wifi.supplicant;
+
+import android.hardware.wifi.common.OuiKeyedData;
+
+/**
+ * Parameters passed as a part of a P2P Device found event.
+ */
+@VintfStability
+parcelable P2pDeviceFoundEventParams {
+ /**
+ * MAC address of the device found. This must either be the P2P device address
+ * for a peer which is not in a group, or the P2P interface address for
+ * a peer which is a Group Owner.
+ */
+ byte[6] srcAddress;
+
+ /**
+ * P2P device address.
+ */
+ byte[6] p2pDeviceAddress;
+
+ /**
+ * Type of device. Refer to section B.1 of the Wifi P2P Technical
+ * specification v1.2.
+ */
+ byte[] primaryDeviceType;
+
+ /**
+ * Name of the device.
+ */
+ String deviceName;
+
+ /**
+ * Mask of |WpsConfigMethods| indicating the WPS configuration methods
+ * supported by the device.
+ */
+ int configMethods;
+
+ /**
+ * Refer to section 4.1.4 of the Wifi P2P Technical specification v1.2.
+ */
+ byte deviceCapabilities;
+
+ /**
+ * Mask of |P2pGroupCapabilityMask| indicating the group capabilities.
+ * Refer to section 4.1.4 of the Wifi P2P Technical specification v1.2.
+ */
+ int groupCapabilities;
+
+ /**
+ * WFD device info as described in section 5.1.2 of the WFD technical
+ * specification v1.0.0.
+ */
+ byte[] wfdDeviceInfo;
+
+ /**
+ * WFD R2 device info as described in section 5.1.12 of WFD technical
+ * specification v2.1.
+ */
+ byte[] wfdR2DeviceInfo;
+
+ /**
+ * Vendor-specific information element bytes. The format of an
+ * information element is EID (1 byte) + Length (1 Byte) + Payload which is
+ * defined in Section 9.4.4 TLV encodings of 802.11-2016 IEEE Standard for
+ * Information technology. The length indicates the size of the payload.
+ * Multiple information elements may be appended within the byte array.
+ */
+ byte[] vendorElemBytes;
+
+ /**
+ * Optional vendor-specific data.
+ * Null value indicates that no vendor data is provided.
+ */
+ @nullable OuiKeyedData[] vendorData;
+}
diff --git a/wifi/supplicant/aidl/vts/functional/Android.bp b/wifi/supplicant/aidl/vts/functional/Android.bp
index 4eec180..b2356a0 100644
--- a/wifi/supplicant/aidl/vts/functional/Android.bp
+++ b/wifi/supplicant/aidl/vts/functional/Android.bp
@@ -42,6 +42,7 @@
"android.hardware.wifi@1.3",
"android.hardware.wifi@1.4",
"android.hardware.wifi@1.5",
+ "android.hardware.wifi.common-V1-ndk",
"android.hardware.wifi.supplicant@1.0",
"android.hardware.wifi.supplicant@1.1",
"android.hardware.wifi.supplicant-V3-ndk",
@@ -78,6 +79,7 @@
"android.hardware.wifi@1.3",
"android.hardware.wifi@1.4",
"android.hardware.wifi@1.5",
+ "android.hardware.wifi.common-V1-ndk",
"android.hardware.wifi.supplicant@1.0",
"android.hardware.wifi.supplicant@1.1",
"android.hardware.wifi.supplicant-V3-ndk",
@@ -114,6 +116,7 @@
"android.hardware.wifi@1.3",
"android.hardware.wifi@1.4",
"android.hardware.wifi@1.5",
+ "android.hardware.wifi.common-V1-ndk",
"android.hardware.wifi.supplicant@1.0",
"android.hardware.wifi.supplicant@1.1",
"android.hardware.wifi.supplicant-V3-ndk",
diff --git a/wifi/supplicant/aidl/vts/functional/supplicant_p2p_iface_aidl_test.cpp b/wifi/supplicant/aidl/vts/functional/supplicant_p2p_iface_aidl_test.cpp
index 0db1653..3f96414 100644
--- a/wifi/supplicant/aidl/vts/functional/supplicant_p2p_iface_aidl_test.cpp
+++ b/wifi/supplicant/aidl/vts/functional/supplicant_p2p_iface_aidl_test.cpp
@@ -35,6 +35,7 @@
using aidl::android::hardware::wifi::supplicant::ISupplicant;
using aidl::android::hardware::wifi::supplicant::ISupplicantP2pIface;
using aidl::android::hardware::wifi::supplicant::MiracastMode;
+using aidl::android::hardware::wifi::supplicant::P2pDeviceFoundEventParams;
using aidl::android::hardware::wifi::supplicant::P2pFrameTypeMask;
using aidl::android::hardware::wifi::supplicant::P2pGroupCapabilityMask;
using aidl::android::hardware::wifi::supplicant::P2pGroupStartedEventParams;
@@ -199,6 +200,10 @@
/* provisionDiscoveryCompletedEventParams */) override {
return ndk::ScopedAStatus::ok();
}
+ ::ndk::ScopedAStatus onDeviceFoundWithParams(
+ const P2pDeviceFoundEventParams& /* deviceFoundEventParams */) override {
+ return ndk::ScopedAStatus::ok();
+ }
};
class SupplicantP2pIfaceAidlTest : public testing::TestWithParam<std::string> {
diff --git a/wifi/supplicant/aidl/vts/functional/supplicant_sta_network_aidl_test.cpp b/wifi/supplicant/aidl/vts/functional/supplicant_sta_network_aidl_test.cpp
index 973b56a..7574141 100644
--- a/wifi/supplicant/aidl/vts/functional/supplicant_sta_network_aidl_test.cpp
+++ b/wifi/supplicant/aidl/vts/functional/supplicant_sta_network_aidl_test.cpp
@@ -822,6 +822,13 @@
tlsV13Supported);
}
+/*
+ * disableEht
+ */
+TEST_P(SupplicantStaNetworkAidlTest, DisableEht) {
+ EXPECT_TRUE(sta_network_->disableEht().isOk());
+}
+
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(SupplicantStaNetworkAidlTest);
INSTANTIATE_TEST_SUITE_P(Supplicant, SupplicantStaNetworkAidlTest,
testing::ValuesIn(android::getAidlHalInstanceNames(