Merge "Add new features to tuner HAL."
diff --git a/automotive/vehicle/aidl/android/hardware/automotive/vehicle/VehicleApPowerStateReq.aidl b/automotive/vehicle/aidl/android/hardware/automotive/vehicle/VehicleApPowerStateReq.aidl
index 82f98d8..1031ebb 100644
--- a/automotive/vehicle/aidl/android/hardware/automotive/vehicle/VehicleApPowerStateReq.aidl
+++ b/automotive/vehicle/aidl/android/hardware/automotive/vehicle/VehicleApPowerStateReq.aidl
@@ -23,6 +23,7 @@
* This requests Android to enter its normal operating state.
* This may be sent after the AP has reported
* VehicleApPowerStateReport#DEEP_SLEEP_EXIT,
+ * VehicleApPowerStateReport#HIBERNATION_EXIT,
* VehicleApPowerStateReport#SHUTDOWN_CANCELLED, or
* VehicleApPowerStateReport#WAIT_FOR_VHAL.
*/
@@ -31,6 +32,7 @@
* The power controller issues this request to shutdown the system.
* This may be sent after the AP has reported
* VehicleApPowerStateReport#DEEP_SLEEP_EXIT,
+ * VehicleApPowerStateReport#HIBERNATION_EXIT,
* VehicleApPowerStateReport#ON,
* VehicleApPowerStateReport#SHUTDOWN_CANCELLED,
* VehicleApPowerStateReport#SHUTDOWN_POSTPONE,
@@ -59,6 +61,7 @@
* Completes the shutdown process.
* This may be sent after the AP has reported
* VehicleApPowerStateReport#DEEP_SLEEP_ENTRY or
+ * VehicleApPowerStateReport#HIBERNATION_ENTRY or
* VehicleApPowerStateReport#SHUTDOWN_START. The AP will not report new
* state information after receiving this request.
*/
diff --git a/automotive/vehicle/aidl/impl/fake_impl/hardware/include/FakeVehicleHardware.h b/automotive/vehicle/aidl/impl/fake_impl/hardware/include/FakeVehicleHardware.h
index 46a526c..cab184b 100644
--- a/automotive/vehicle/aidl/impl/fake_impl/hardware/include/FakeVehicleHardware.h
+++ b/automotive/vehicle/aidl/impl/fake_impl/hardware/include/FakeVehicleHardware.h
@@ -39,14 +39,6 @@
class FakeVehicleHardware final : public IVehicleHardware {
public:
- using SetValuesCallback = std::function<void(
- const std::vector<::aidl::android::hardware::automotive::vehicle::SetValueResult>&)>;
- using GetValuesCallback = std::function<void(
- const std::vector<::aidl::android::hardware::automotive::vehicle::GetValueResult>&)>;
- using OnPropertyChangeCallback = std::function<void(
- const std::vector<::aidl::android::hardware::automotive::vehicle::VehiclePropValue>&)>;
- using OnPropertySetErrorCallback = std::function<void(const std::vector<SetValueErrorEvent>&)>;
-
FakeVehicleHardware();
explicit FakeVehicleHardware(std::unique_ptr<VehiclePropValuePool> valuePool);
@@ -59,7 +51,7 @@
// are sent to vehicle bus or before property set confirmation is received. The callback is
// safe to be called after the function returns and is safe to be called in a different thread.
::aidl::android::hardware::automotive::vehicle::StatusCode setValues(
- SetValuesCallback&& callback,
+ std::shared_ptr<const SetValuesCallback> callback,
const std::vector<::aidl::android::hardware::automotive::vehicle::SetValueRequest>&
requests) override;
@@ -67,7 +59,7 @@
// The callback is safe to be called after the function returns and is safe to be called in a
// different thread.
::aidl::android::hardware::automotive::vehicle::StatusCode getValues(
- GetValuesCallback&& callback,
+ std::shared_ptr<const GetValuesCallback> callback,
const std::vector<::aidl::android::hardware::automotive::vehicle::GetValueRequest>&
requests) const override;
@@ -78,11 +70,13 @@
::aidl::android::hardware::automotive::vehicle::StatusCode checkHealth() override;
// Register a callback that would be called when there is a property change event from vehicle.
- void registerOnPropertyChangeEvent(OnPropertyChangeCallback&& callback) override;
+ void registerOnPropertyChangeEvent(
+ std::unique_ptr<const PropertyChangeCallback> callback) override;
// Register a callback that would be called when there is a property set error event from
// vehicle.
- void registerOnPropertySetErrorEvent(OnPropertySetErrorCallback&& callback) override;
+ void registerOnPropertySetErrorEvent(
+ std::unique_ptr<const PropertySetErrorCallback> callback) override;
private:
// Expose private methods to unit test.
@@ -94,8 +88,10 @@
const std::unique_ptr<obd2frame::FakeObd2Frame> mFakeObd2Frame;
const std::unique_ptr<FakeUserHal> mFakeUserHal;
std::mutex mCallbackLock;
- OnPropertyChangeCallback mOnPropertyChangeCallback GUARDED_BY(mCallbackLock);
- OnPropertySetErrorCallback mOnPropertySetErrorCallback GUARDED_BY(mCallbackLock);
+ std::unique_ptr<const PropertyChangeCallback> mOnPropertyChangeCallback
+ GUARDED_BY(mCallbackLock);
+ std::unique_ptr<const PropertySetErrorCallback> mOnPropertySetErrorCallback
+ GUARDED_BY(mCallbackLock);
void init();
// Stores the initial value to property store.
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 5b2003e..e75f0e7 100644
--- a/automotive/vehicle/aidl/impl/fake_impl/hardware/src/FakeVehicleHardware.cpp
+++ b/automotive/vehicle/aidl/impl/fake_impl/hardware/src/FakeVehicleHardware.cpp
@@ -379,7 +379,7 @@
return {};
}
-StatusCode FakeVehicleHardware::setValues(FakeVehicleHardware::SetValuesCallback&& callback,
+StatusCode FakeVehicleHardware::setValues(std::shared_ptr<const SetValuesCallback> callback,
const std::vector<SetValueRequest>& requests) {
std::vector<VehiclePropValue> updatedValues;
std::vector<SetValueResult> results;
@@ -424,12 +424,12 @@
// In the real vhal, the values will be sent to Car ECU. We just pretend it is done here and
// send back the updated property values to client.
- callback(std::move(results));
+ (*callback)(std::move(results));
return StatusCode::OK;
}
-StatusCode FakeVehicleHardware::getValues(FakeVehicleHardware::GetValuesCallback&& callback,
+StatusCode FakeVehicleHardware::getValues(std::shared_ptr<const GetValuesCallback> callback,
const std::vector<GetValueRequest>& requests) const {
std::vector<GetValueResult> results;
for (auto& request : requests) {
@@ -471,7 +471,7 @@
results.push_back(std::move(getValueResult));
}
- callback(std::move(results));
+ (*callback)(std::move(results));
return StatusCode::OK;
}
@@ -487,23 +487,28 @@
return StatusCode::OK;
}
-void FakeVehicleHardware::registerOnPropertyChangeEvent(OnPropertyChangeCallback&& callback) {
+void FakeVehicleHardware::registerOnPropertyChangeEvent(
+ std::unique_ptr<const PropertyChangeCallback> callback) {
std::scoped_lock<std::mutex> lockGuard(mCallbackLock);
mOnPropertyChangeCallback = std::move(callback);
}
-void FakeVehicleHardware::registerOnPropertySetErrorEvent(OnPropertySetErrorCallback&& callback) {
+void FakeVehicleHardware::registerOnPropertySetErrorEvent(
+ std::unique_ptr<const PropertySetErrorCallback> callback) {
std::scoped_lock<std::mutex> lockGuard(mCallbackLock);
mOnPropertySetErrorCallback = std::move(callback);
}
void FakeVehicleHardware::onValueChangeCallback(const VehiclePropValue& value) {
std::scoped_lock<std::mutex> lockGuard(mCallbackLock);
- if (mOnPropertyChangeCallback != nullptr) {
- std::vector<VehiclePropValue> updatedValues;
- updatedValues.push_back(value);
- mOnPropertyChangeCallback(std::move(updatedValues));
+
+ if (mOnPropertyChangeCallback == nullptr) {
+ return;
}
+
+ std::vector<VehiclePropValue> updatedValues;
+ updatedValues.push_back(value);
+ (*mOnPropertyChangeCallback)(std::move(updatedValues));
}
void FakeVehicleHardware::maybeOverrideProperties(const char* overrideDir) {
diff --git a/automotive/vehicle/aidl/impl/fake_impl/hardware/test/FakeVehicleHardwareTest.cpp b/automotive/vehicle/aidl/impl/fake_impl/hardware/test/FakeVehicleHardwareTest.cpp
index 88834f3..f8df6e6 100644
--- a/automotive/vehicle/aidl/impl/fake_impl/hardware/test/FakeVehicleHardwareTest.cpp
+++ b/automotive/vehicle/aidl/impl/fake_impl/hardware/test/FakeVehicleHardwareTest.cpp
@@ -76,24 +76,25 @@
class FakeVehicleHardwareTest : public ::testing::Test {
protected:
void SetUp() override {
- getHardware()->registerOnPropertyChangeEvent(
+ auto callback = std::make_unique<IVehicleHardware::PropertyChangeCallback>(
[this](const std::vector<VehiclePropValue>& values) {
- return onPropertyChangeEvent(values);
+ onPropertyChangeEvent(values);
});
+ getHardware()->registerOnPropertyChangeEvent(std::move(callback));
+ mSetValuesCallback = std::make_shared<IVehicleHardware::SetValuesCallback>(
+ [this](std::vector<SetValueResult> results) { onSetValues(results); });
+ mGetValuesCallback = std::make_shared<IVehicleHardware::GetValuesCallback>(
+ [this](std::vector<GetValueResult> results) { onGetValues(results); });
}
FakeVehicleHardware* getHardware() { return &mHardware; }
StatusCode setValues(const std::vector<SetValueRequest>& requests) {
- return getHardware()->setValues(
- [this](const std::vector<SetValueResult> results) { return onSetValues(results); },
- requests);
+ return getHardware()->setValues(mSetValuesCallback, requests);
}
StatusCode getValues(const std::vector<GetValueRequest>& requests) {
- return getHardware()->getValues(
- [this](const std::vector<GetValueResult> results) { return onGetValues(results); },
- requests);
+ return getHardware()->getValues(mGetValuesCallback, requests);
}
StatusCode setValue(const VehiclePropValue& value) {
@@ -245,6 +246,8 @@
std::vector<SetValueResult> mSetValueResults;
std::vector<GetValueResult> mGetValueResults;
std::vector<VehiclePropValue> mChangedProperties;
+ std::shared_ptr<IVehicleHardware::SetValuesCallback> mSetValuesCallback;
+ std::shared_ptr<IVehicleHardware::GetValuesCallback> mGetValuesCallback;
};
TEST_F(FakeVehicleHardwareTest, testGetAllPropertyConfigs) {
@@ -367,9 +370,9 @@
TEST_F(FakeVehicleHardwareTest, testRegisterOnPropertyChangeEvent) {
// We have already registered this callback in Setup, here we are registering again.
- getHardware()->registerOnPropertyChangeEvent(std::bind(
- &FakeVehicleHardwareTest_testRegisterOnPropertyChangeEvent_Test::onPropertyChangeEvent,
- this, std::placeholders::_1));
+ auto callback = std::make_unique<IVehicleHardware::PropertyChangeCallback>(
+ [this](const std::vector<VehiclePropValue>& values) { onPropertyChangeEvent(values); });
+ getHardware()->registerOnPropertyChangeEvent(std::move(callback));
auto testValues = getTestPropValues();
std::vector<SetValueRequest> requests;
diff --git a/automotive/vehicle/aidl/impl/hardware/include/IVehicleHardware.h b/automotive/vehicle/aidl/impl/hardware/include/IVehicleHardware.h
index 2e12327..4b9de2d 100644
--- a/automotive/vehicle/aidl/impl/hardware/include/IVehicleHardware.h
+++ b/automotive/vehicle/aidl/impl/hardware/include/IVehicleHardware.h
@@ -19,6 +19,7 @@
#include <VehicleHalTypes.h>
+#include <memory>
#include <vector>
namespace android {
@@ -49,6 +50,14 @@
// with a VehicleHardware through this interface.
class IVehicleHardware {
public:
+ using SetValuesCallback = std::function<void(
+ std::vector<::aidl::android::hardware::automotive::vehicle::SetValueResult>)>;
+ using GetValuesCallback = std::function<void(
+ std::vector<::aidl::android::hardware::automotive::vehicle::GetValueResult>)>;
+ using PropertyChangeCallback = std::function<void(
+ std::vector<::aidl::android::hardware::automotive::vehicle::VehiclePropValue>)>;
+ using PropertySetErrorCallback = std::function<void(std::vector<SetValueErrorEvent>)>;
+
virtual ~IVehicleHardware() = default;
// Get all the property configs.
@@ -59,9 +68,7 @@
// are sent to vehicle bus or before property set confirmation is received. The callback is
// safe to be called after the function returns and is safe to be called in a different thread.
virtual ::aidl::android::hardware::automotive::vehicle::StatusCode setValues(
- std::function<void(const std::vector<
- ::aidl::android::hardware::automotive::vehicle::SetValueResult>&)>&&
- callback,
+ std::shared_ptr<const SetValuesCallback> callback,
const std::vector<::aidl::android::hardware::automotive::vehicle::SetValueRequest>&
requests) = 0;
@@ -69,9 +76,7 @@
// The callback is safe to be called after the function returns and is safe to be called in a
// different thread.
virtual ::aidl::android::hardware::automotive::vehicle::StatusCode getValues(
- std::function<void(const std::vector<
- ::aidl::android::hardware::automotive::vehicle::GetValueResult>&)>&&
- callback,
+ std::shared_ptr<const GetValuesCallback> callback,
const std::vector<::aidl::android::hardware::automotive::vehicle::GetValueRequest>&
requests) const = 0;
@@ -83,13 +88,12 @@
// Register a callback that would be called when there is a property change event from vehicle.
virtual void registerOnPropertyChangeEvent(
- std::function<void(const std::vector<::aidl::android::hardware::automotive::vehicle::
- VehiclePropValue>&)>&& callback) = 0;
+ std::unique_ptr<const PropertyChangeCallback> callback) = 0;
// Register a callback that would be called when there is a property set error event from
// vehicle.
virtual void registerOnPropertySetErrorEvent(
- std::function<void(const std::vector<SetValueErrorEvent>&)>&& callback) = 0;
+ std::unique_ptr<const PropertySetErrorCallback> callback) = 0;
};
} // namespace vehicle
diff --git a/automotive/vehicle/aidl/impl/vhal/Android.bp b/automotive/vehicle/aidl/impl/vhal/Android.bp
index 79d3ebd..454fea5 100644
--- a/automotive/vehicle/aidl/impl/vhal/Android.bp
+++ b/automotive/vehicle/aidl/impl/vhal/Android.bp
@@ -19,7 +19,7 @@
}
cc_binary {
- name: "android.hardware.automotive.vehicle-aidl-default-service",
+ name: "android.hardware.automotive.vehicle@V1-default-service",
vendor: true,
defaults: [
"FakeVehicleHardwareDefaults",
diff --git a/automotive/vehicle/aidl/impl/vhal/src/VehicleService.cpp b/automotive/vehicle/aidl/impl/vhal/src/VehicleService.cpp
index 14224a5..c8b5c65 100644
--- a/automotive/vehicle/aidl/impl/vhal/src/VehicleService.cpp
+++ b/automotive/vehicle/aidl/impl/vhal/src/VehicleService.cpp
@@ -32,8 +32,8 @@
::ndk::SharedRefBase::make<DefaultVehicleHal>(std::move(hardware));
ALOGI("Registering as service...");
- binder_exception_t err = AServiceManager_addService(vhal->asBinder().get(),
- "android.hardware.automotive.vehicle");
+ binder_exception_t err = AServiceManager_addService(
+ vhal->asBinder().get(), "android.hardware.automotive.vehicle.IVehicle/default");
if (err != EX_NONE) {
ALOGE("failed to register android.hardware.automotive.vehicle service, exception: %d", err);
return 1;
diff --git a/automotive/vehicle/aidl/impl/vhal/test/DefaultVehicleHalTest.cpp b/automotive/vehicle/aidl/impl/vhal/test/DefaultVehicleHalTest.cpp
index 62a7098..2b5ca70 100644
--- a/automotive/vehicle/aidl/impl/vhal/test/DefaultVehicleHalTest.cpp
+++ b/automotive/vehicle/aidl/impl/vhal/test/DefaultVehicleHalTest.cpp
@@ -19,6 +19,7 @@
#include <IVehicleHardware.h>
#include <LargeParcelableBase.h>
#include <aidl/android/hardware/automotive/vehicle/IVehicle.h>
+#include <android-base/thread_annotations.h>
#include <gmock/gmock.h>
#include <gtest/gtest.h>
@@ -53,16 +54,17 @@
class MockVehicleHardware final : public IVehicleHardware {
public:
std::vector<VehiclePropConfig> getAllPropertyConfigs() const override {
+ std::scoped_lock<std::mutex> lockGuard(mLock);
return mPropertyConfigs;
}
- StatusCode setValues(std::function<void(const std::vector<SetValueResult>&)>&&,
+ StatusCode setValues(std::shared_ptr<const SetValuesCallback>,
const std::vector<SetValueRequest>&) override {
// TODO(b/200737967): mock this.
return StatusCode::OK;
}
- StatusCode getValues(std::function<void(const std::vector<GetValueResult>&)>&&,
+ StatusCode getValues(std::shared_ptr<const GetValuesCallback>,
const std::vector<GetValueRequest>&) const override {
// TODO(b/200737967): mock this.
return StatusCode::OK;
@@ -78,23 +80,23 @@
return StatusCode::OK;
}
- void registerOnPropertyChangeEvent(
- std::function<void(const std::vector<VehiclePropValue>&)>&&) override {
+ void registerOnPropertyChangeEvent(std::unique_ptr<const PropertyChangeCallback>) override {
// TODO(b/200737967): mock this.
}
- void registerOnPropertySetErrorEvent(
- std::function<void(const std::vector<SetValueErrorEvent>&)>&&) override {
+ void registerOnPropertySetErrorEvent(std::unique_ptr<const PropertySetErrorCallback>) override {
// TODO(b/200737967): mock this.
}
// Test functions.
void setPropertyConfigs(const std::vector<VehiclePropConfig>& configs) {
+ std::scoped_lock<std::mutex> lockGuard(mLock);
mPropertyConfigs = configs;
}
private:
- std::vector<VehiclePropConfig> mPropertyConfigs;
+ mutable std::mutex mLock;
+ std::vector<VehiclePropConfig> mPropertyConfigs GUARDED_BY(mLock);
};
struct PropConfigCmp {
diff --git a/automotive/vehicle/aidl/impl/vhal/vhal-default-service.rc b/automotive/vehicle/aidl/impl/vhal/vhal-default-service.rc
index 4c8865a..19267cd 100644
--- a/automotive/vehicle/aidl/impl/vhal/vhal-default-service.rc
+++ b/automotive/vehicle/aidl/impl/vhal/vhal-default-service.rc
@@ -1,4 +1,4 @@
-service vendor.vehicle-hal-default /vendor/bin/hw/android.hardware.automotive.vehicle-aidl-default-service
+service vendor.vehicle-hal-default /vendor/bin/hw/android.hardware.automotive.vehicle@V1-default-service
class early_hal
user vehicle_network
group system inet
diff --git a/bluetooth/audio/2.2/Android.bp b/bluetooth/audio/2.2/Android.bp
index 6449c08..8d52ce9 100644
--- a/bluetooth/audio/2.2/Android.bp
+++ b/bluetooth/audio/2.2/Android.bp
@@ -14,6 +14,7 @@
root: "android.hardware",
srcs: [
"types.hal",
+ "IBluetoothAudioPort.hal",
"IBluetoothAudioProvider.hal",
"IBluetoothAudioProvidersFactory.hal",
],
diff --git a/bluetooth/audio/2.2/IBluetoothAudioPort.hal b/bluetooth/audio/2.2/IBluetoothAudioPort.hal
new file mode 100644
index 0000000..344899c
--- /dev/null
+++ b/bluetooth/audio/2.2/IBluetoothAudioPort.hal
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2021 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@2.2;
+
+import @2.0::IBluetoothAudioPort;
+import android.hardware.audio.common@5.0::SinkMetadata;
+
+interface IBluetoothAudioPort extends @2.0::IBluetoothAudioPort {
+ /**
+ * Called when the metadata of the stream's sink has been changed.
+ *
+ * @param sinkMetadata Description of the audio that is recorded by the
+ * clients.
+ */
+ updateSinkMetadata(SinkMetadata sinkMetadata);
+};
diff --git a/bluetooth/audio/2.2/IBluetoothAudioProvider.hal b/bluetooth/audio/2.2/IBluetoothAudioProvider.hal
index ad8c839..bc16b01 100644
--- a/bluetooth/audio/2.2/IBluetoothAudioProvider.hal
+++ b/bluetooth/audio/2.2/IBluetoothAudioProvider.hal
@@ -17,7 +17,7 @@
package android.hardware.bluetooth.audio@2.2;
import @2.1::IBluetoothAudioProvider;
-import @2.0::IBluetoothAudioPort;
+import @2.2::IBluetoothAudioPort;
import @2.0::Status;
/**
diff --git a/bluetooth/audio/2.2/default/A2dpOffloadAudioProvider.cpp b/bluetooth/audio/2.2/default/A2dpOffloadAudioProvider.cpp
index 126bc9e..2a6d93a 100644
--- a/bluetooth/audio/2.2/default/A2dpOffloadAudioProvider.cpp
+++ b/bluetooth/audio/2.2/default/A2dpOffloadAudioProvider.cpp
@@ -54,7 +54,7 @@
}
Return<void> A2dpOffloadAudioProvider::startSession(
- const sp<IBluetoothAudioPort>& hostIf,
+ const sp<V2_0::IBluetoothAudioPort>& hostIf,
const AudioConfiguration& audioConfig, startSession_cb _hidl_cb) {
/**
* Initialize the audio platform if audioConfiguration is supported.
diff --git a/bluetooth/audio/2.2/default/A2dpSoftwareAudioProvider.cpp b/bluetooth/audio/2.2/default/A2dpSoftwareAudioProvider.cpp
index 0d918e1..ba31d39 100644
--- a/bluetooth/audio/2.2/default/A2dpSoftwareAudioProvider.cpp
+++ b/bluetooth/audio/2.2/default/A2dpSoftwareAudioProvider.cpp
@@ -70,7 +70,7 @@
}
Return<void> A2dpSoftwareAudioProvider::startSession(
- const sp<IBluetoothAudioPort>& hostIf,
+ const sp<V2_0::IBluetoothAudioPort>& hostIf,
const AudioConfiguration& audioConfig, startSession_cb _hidl_cb) {
/**
* Initialize the audio platform if audioConfiguration is supported.
diff --git a/bluetooth/audio/2.2/default/A2dpSoftwareAudioProvider.h b/bluetooth/audio/2.2/default/A2dpSoftwareAudioProvider.h
index 3d4f0cc..ac3aece 100644
--- a/bluetooth/audio/2.2/default/A2dpSoftwareAudioProvider.h
+++ b/bluetooth/audio/2.2/default/A2dpSoftwareAudioProvider.h
@@ -40,7 +40,7 @@
bool isValid(const V2_1::SessionType& sessionType) override;
bool isValid(const V2_0::SessionType& sessionType) override;
- Return<void> startSession(const sp<IBluetoothAudioPort>& hostIf,
+ Return<void> startSession(const sp<V2_0::IBluetoothAudioPort>& hostIf,
const V2_0::AudioConfiguration& audioConfig,
startSession_cb _hidl_cb) override;
diff --git a/bluetooth/audio/2.2/default/AudioPort_2_0_to_2_2_Wrapper.h b/bluetooth/audio/2.2/default/AudioPort_2_0_to_2_2_Wrapper.h
new file mode 100644
index 0000000..c5613fb
--- /dev/null
+++ b/bluetooth/audio/2.2/default/AudioPort_2_0_to_2_2_Wrapper.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2021 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 <android/hardware/bluetooth/audio/2.2/types.h>
+
+namespace android {
+namespace hardware {
+namespace bluetooth {
+namespace audio {
+namespace V2_2 {
+namespace implementation {
+
+using ::android::sp;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+using ::android::hardware::audio::common::V5_0::SinkMetadata;
+using ::android::hardware::audio::common::V5_0::SourceMetadata;
+using ::android::hardware::bluetooth::audio::V2_2::IBluetoothAudioPort;
+
+class AudioPort_2_0_to_2_2_Wrapper : public V2_2::IBluetoothAudioPort {
+ public:
+ AudioPort_2_0_to_2_2_Wrapper(const sp<V2_0::IBluetoothAudioPort>& port) {
+ this->port = port;
+ }
+
+ Return<void> startStream() override { return port->startStream(); }
+ Return<void> suspendStream() override { return port->suspendStream(); }
+ Return<void> stopStream() override { return port->stopStream(); }
+ Return<void> getPresentationPosition(
+ getPresentationPosition_cb _hidl_cb) override {
+ return port->getPresentationPosition(_hidl_cb);
+ }
+ Return<void> updateMetadata(const SourceMetadata& sourceMetadata) override {
+ return port->updateMetadata(sourceMetadata);
+ }
+ Return<void> updateSinkMetadata(const SinkMetadata&) override {
+ // DO NOTHING, 2.0 AudioPort doesn't support sink metadata updates
+ return Void();
+ }
+
+ sp<V2_0::IBluetoothAudioPort> port;
+};
+
+} // namespace implementation
+} // namespace V2_2
+} // namespace audio
+} // namespace bluetooth
+} // namespace hardware
+} // namespace android
\ No newline at end of file
diff --git a/bluetooth/audio/2.2/default/BluetoothAudioProvider.cpp b/bluetooth/audio/2.2/default/BluetoothAudioProvider.cpp
index 3655bc0..3c0ff42 100644
--- a/bluetooth/audio/2.2/default/BluetoothAudioProvider.cpp
+++ b/bluetooth/audio/2.2/default/BluetoothAudioProvider.cpp
@@ -20,6 +20,7 @@
#include <android-base/logging.h>
+#include "AudioPort_2_0_to_2_2_Wrapper.h"
#include "BluetoothAudioSessionReport_2_2.h"
#include "BluetoothAudioSupportedCodecsDB_2_1.h"
@@ -51,7 +52,7 @@
audio_config_({}) {}
Return<void> BluetoothAudioProvider::startSession(
- const sp<IBluetoothAudioPort>& hostIf,
+ const sp<V2_0::IBluetoothAudioPort>& hostIf,
const V2_0::AudioConfiguration& audioConfig, startSession_cb _hidl_cb) {
AudioConfiguration audioConfig_2_2;
@@ -67,11 +68,13 @@
audioConfig_2_2.codecConfig(audioConfig.codecConfig());
}
- return startSession_2_2(hostIf, audioConfig_2_2, _hidl_cb);
+ sp<V2_2::IBluetoothAudioPort> hostIf_2_2 =
+ new AudioPort_2_0_to_2_2_Wrapper(hostIf);
+ return startSession_2_2(hostIf_2_2, audioConfig_2_2, _hidl_cb);
}
Return<void> BluetoothAudioProvider::startSession_2_1(
- const sp<IBluetoothAudioPort>& hostIf,
+ const sp<V2_0::IBluetoothAudioPort>& hostIf,
const V2_1::AudioConfiguration& audioConfig, startSession_cb _hidl_cb) {
AudioConfiguration audioConfig_2_2;
if (audioConfig.getDiscriminator() ==
@@ -92,11 +95,13 @@
audioConfig_2_2.codecConfig(audioConfig.codecConfig());
}
- return startSession_2_2(hostIf, audioConfig_2_2, _hidl_cb);
+ sp<V2_2::IBluetoothAudioPort> hostIf_2_2 =
+ new AudioPort_2_0_to_2_2_Wrapper(hostIf);
+ return startSession_2_2(hostIf_2_2, audioConfig_2_2, _hidl_cb);
}
Return<void> BluetoothAudioProvider::startSession_2_2(
- const sp<IBluetoothAudioPort>& hostIf,
+ const sp<V2_2::IBluetoothAudioPort>& hostIf,
const AudioConfiguration& audioConfig, startSession_cb _hidl_cb) {
if (hostIf == nullptr) {
_hidl_cb(BluetoothAudioStatus::FAILURE, DataMQ::Descriptor());
diff --git a/bluetooth/audio/2.2/default/BluetoothAudioProvider.h b/bluetooth/audio/2.2/default/BluetoothAudioProvider.h
index b7581ba..0f1f3c6 100644
--- a/bluetooth/audio/2.2/default/BluetoothAudioProvider.h
+++ b/bluetooth/audio/2.2/default/BluetoothAudioProvider.h
@@ -26,7 +26,7 @@
namespace implementation {
using ::android::sp;
-using ::android::hardware::bluetooth::audio::V2_0::IBluetoothAudioPort;
+using ::android::hardware::bluetooth::audio::V2_2::IBluetoothAudioPort;
using BluetoothAudioStatus =
::android::hardware::bluetooth::audio::V2_0::Status;
@@ -41,13 +41,13 @@
virtual bool isValid(const V2_1::SessionType& sessionType) = 0;
virtual bool isValid(const V2_0::SessionType& sessionType) = 0;
- Return<void> startSession(const sp<IBluetoothAudioPort>& hostIf,
+ Return<void> startSession(const sp<V2_0::IBluetoothAudioPort>& hostIf,
const V2_0::AudioConfiguration& audioConfig,
startSession_cb _hidl_cb) override;
- Return<void> startSession_2_1(const sp<IBluetoothAudioPort>& hostIf,
+ Return<void> startSession_2_1(const sp<V2_0::IBluetoothAudioPort>& hostIf,
const V2_1::AudioConfiguration& audioConfig,
startSession_cb _hidl_cb) override;
- Return<void> startSession_2_2(const sp<IBluetoothAudioPort>& hostIf,
+ Return<void> startSession_2_2(const sp<V2_2::IBluetoothAudioPort>& hostIf,
const AudioConfiguration& audioConfig,
startSession_cb _hidl_cb) override;
Return<void> streamStarted(BluetoothAudioStatus status) override;
@@ -59,7 +59,7 @@
V2_1::SessionType session_type_;
AudioConfiguration audio_config_;
- sp<V2_0::IBluetoothAudioPort> stack_iface_;
+ sp<V2_2::IBluetoothAudioPort> stack_iface_;
virtual Return<void> onSessionReady(startSession_cb _hidl_cb) = 0;
};
diff --git a/bluetooth/audio/2.2/default/HearingAidAudioProvider.cpp b/bluetooth/audio/2.2/default/HearingAidAudioProvider.cpp
index c79b910..9b3294f 100644
--- a/bluetooth/audio/2.2/default/HearingAidAudioProvider.cpp
+++ b/bluetooth/audio/2.2/default/HearingAidAudioProvider.cpp
@@ -66,7 +66,7 @@
}
Return<void> HearingAidAudioProvider::startSession(
- const sp<IBluetoothAudioPort>& hostIf,
+ const sp<V2_0::IBluetoothAudioPort>& hostIf,
const AudioConfiguration& audioConfig, startSession_cb _hidl_cb) {
/**
* Initialize the audio platform if audioConfiguration is supported.
diff --git a/bluetooth/audio/2.2/default/HearingAidAudioProvider.h b/bluetooth/audio/2.2/default/HearingAidAudioProvider.h
index 426c443..63290b5 100644
--- a/bluetooth/audio/2.2/default/HearingAidAudioProvider.h
+++ b/bluetooth/audio/2.2/default/HearingAidAudioProvider.h
@@ -40,7 +40,7 @@
bool isValid(const V2_1::SessionType& sessionType) override;
bool isValid(const V2_0::SessionType& sessionType) override;
- Return<void> startSession(const sp<IBluetoothAudioPort>& hostIf,
+ Return<void> startSession(const sp<V2_0::IBluetoothAudioPort>& hostIf,
const V2_0::AudioConfiguration& audioConfig,
startSession_cb _hidl_cb) override;
diff --git a/bluetooth/audio/2.2/default/LeAudioAudioProvider.cpp b/bluetooth/audio/2.2/default/LeAudioAudioProvider.cpp
index af6ec99..9ec1776 100644
--- a/bluetooth/audio/2.2/default/LeAudioAudioProvider.cpp
+++ b/bluetooth/audio/2.2/default/LeAudioAudioProvider.cpp
@@ -20,6 +20,7 @@
#include <android-base/logging.h>
+#include "AudioPort_2_0_to_2_2_Wrapper.h"
#include "BluetoothAudioSessionReport_2_2.h"
#include "BluetoothAudioSupportedCodecsDB_2_1.h"
@@ -83,11 +84,13 @@
.bitsPerSample = audioConfig.pcmConfig().bitsPerSample,
.dataIntervalUs = 0});
- return startSession_2_2(hostIf, audioConfig_2_2, _hidl_cb);
+ sp<V2_2::IBluetoothAudioPort> hostIf_2_2 =
+ new AudioPort_2_0_to_2_2_Wrapper(hostIf);
+ return startSession_2_2(hostIf_2_2, audioConfig_2_2, _hidl_cb);
}
Return<void> LeAudioAudioProvider::startSession_2_2(
- const sp<V2_0::IBluetoothAudioPort>& hostIf,
+ const sp<V2_2::IBluetoothAudioPort>& hostIf,
const AudioConfiguration& audioConfig, startSession_cb _hidl_cb) {
/**
* Initialize the audio platform if audioConfiguration is supported.
diff --git a/bluetooth/audio/2.2/default/LeAudioAudioProvider.h b/bluetooth/audio/2.2/default/LeAudioAudioProvider.h
index 40c26e0..3de1724 100644
--- a/bluetooth/audio/2.2/default/LeAudioAudioProvider.h
+++ b/bluetooth/audio/2.2/default/LeAudioAudioProvider.h
@@ -45,7 +45,7 @@
const V2_1::AudioConfiguration& audioConfig,
startSession_cb _hidl_cb) override;
- Return<void> startSession_2_2(const sp<V2_0::IBluetoothAudioPort>& hostIf,
+ Return<void> startSession_2_2(const sp<V2_2::IBluetoothAudioPort>& hostIf,
const AudioConfiguration& audioConfig,
startSession_cb _hidl_cb) override;
diff --git a/bluetooth/audio/2.2/default/LeAudioOffloadAudioProvider.cpp b/bluetooth/audio/2.2/default/LeAudioOffloadAudioProvider.cpp
index 7b70654..e3da267 100644
--- a/bluetooth/audio/2.2/default/LeAudioOffloadAudioProvider.cpp
+++ b/bluetooth/audio/2.2/default/LeAudioOffloadAudioProvider.cpp
@@ -20,6 +20,7 @@
#include <android-base/logging.h>
+#include "AudioPort_2_0_to_2_2_Wrapper.h"
#include "BluetoothAudioSessionReport_2_2.h"
#include "BluetoothAudioSupportedCodecsDB_2_1.h"
#include "BluetoothAudioSupportedCodecsDB_2_2.h"
@@ -91,11 +92,13 @@
.peerDelay = 0,
.lc3Config = audioConfig.leAudioCodecConfig().lc3Config};
- return startSession_2_2(hostIf, audioConfig_2_2, _hidl_cb);
+ sp<V2_2::IBluetoothAudioPort> hostIf_2_2 =
+ new AudioPort_2_0_to_2_2_Wrapper(hostIf);
+ return startSession_2_2(hostIf_2_2, audioConfig_2_2, _hidl_cb);
}
Return<void> LeAudioOffloadAudioProvider::startSession_2_2(
- const sp<V2_0::IBluetoothAudioPort>& hostIf,
+ const sp<V2_2::IBluetoothAudioPort>& hostIf,
const AudioConfiguration& audioConfig, startSession_cb _hidl_cb) {
/**
* Initialize the audio platform if audioConfiguration is supported.
diff --git a/bluetooth/audio/2.2/default/LeAudioOffloadAudioProvider.h b/bluetooth/audio/2.2/default/LeAudioOffloadAudioProvider.h
index 5620295..fe58de5 100644
--- a/bluetooth/audio/2.2/default/LeAudioOffloadAudioProvider.h
+++ b/bluetooth/audio/2.2/default/LeAudioOffloadAudioProvider.h
@@ -38,7 +38,7 @@
const V2_1::AudioConfiguration& audioConfig,
startSession_cb _hidl_cb) override;
- Return<void> startSession_2_2(const sp<V2_0::IBluetoothAudioPort>& hostIf,
+ Return<void> startSession_2_2(const sp<V2_2::IBluetoothAudioPort>& hostIf,
const AudioConfiguration& audioConfig,
startSession_cb _hidl_cb) override;
diff --git a/bluetooth/audio/aidl/Android.bp b/bluetooth/audio/aidl/Android.bp
new file mode 100644
index 0000000..12eed55
--- /dev/null
+++ b/bluetooth/audio/aidl/Android.bp
@@ -0,0 +1,48 @@
+// Copyright (C) 2021 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 {
+ // See: http://go/android-license-faq
+ // A large-scale-change added 'default_applicable_licenses' to import
+ // all of the 'license_kinds' from "hardware_interfaces_license"
+ // to get the below license kinds:
+ // SPDX-license-identifier-Apache-2.0
+ default_applicable_licenses: ["hardware_interfaces_license"],
+}
+
+aidl_interface {
+ name: "android.hardware.bluetooth.audio",
+ vendor_available: true,
+ srcs: ["android/hardware/bluetooth/audio/*.aidl"],
+ stability: "vintf",
+ imports: [
+ "android.hardware.common-V2",
+ "android.hardware.common.fmq-V1",
+ "android.hardware.audio.common",
+ ],
+ backend: {
+ cpp: {
+ enabled: false,
+ },
+ java: {
+ sdk_version: "module_current",
+ enabled: false,
+ },
+ ndk: {
+ vndk: {
+ enabled: true,
+ },
+ },
+ },
+}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AacCapabilities.aidl
similarity index 80%
copy from graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
copy to bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AacCapabilities.aidl
index 41a1afe..ad44c26 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AacCapabilities.aidl
@@ -1,11 +1,11 @@
-/**
- * Copyright (c) 2021, The Android Open Source Project
+/*
+ * Copyright 2021 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
+ * 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,
@@ -31,10 +31,12 @@
// 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.composer3;
+package android.hardware.bluetooth.audio;
@VintfStability
-parcelable ExecuteCommandsStatus {
- boolean queueChanged;
- int length;
- android.hardware.common.NativeHandle[] handles;
+parcelable AacCapabilities {
+ android.hardware.bluetooth.audio.AacObjectType objectType;
+ int[] sampleRateHz;
+ android.hardware.bluetooth.audio.ChannelMode channelMode;
+ boolean variableBitRateSupported;
+ byte[] bitsPerSample;
}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AacConfiguration.aidl
similarity index 80%
copy from graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
copy to bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AacConfiguration.aidl
index 41a1afe..6adef6d 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AacConfiguration.aidl
@@ -1,11 +1,11 @@
-/**
- * Copyright (c) 2021, The Android Open Source Project
+/*
+ * Copyright 2021 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
+ * 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,
@@ -31,10 +31,12 @@
// 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.composer3;
+package android.hardware.bluetooth.audio;
@VintfStability
-parcelable ExecuteCommandsStatus {
- boolean queueChanged;
- int length;
- android.hardware.common.NativeHandle[] handles;
+parcelable AacConfiguration {
+ android.hardware.bluetooth.audio.AacObjectType objectType;
+ int sampleRateHz;
+ android.hardware.bluetooth.audio.ChannelMode channelMode;
+ boolean variableBitRateEnabled;
+ byte bitsPerSample;
}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/BlendMode.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AacObjectType.aidl
similarity index 84%
copy from graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/BlendMode.aidl
copy to bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AacObjectType.aidl
index a522d53..c129c66 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/BlendMode.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AacObjectType.aidl
@@ -1,11 +1,11 @@
-/**
- * Copyright (c) 2021, The Android Open Source Project
+/*
+ * Copyright (C) 2021 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
+ * 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,
@@ -31,11 +31,11 @@
// 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.composer3;
-@Backing(type="int") @VintfStability
-enum BlendMode {
- INVALID = 0,
- NONE = 1,
- PREMULTIPLIED = 2,
- COVERAGE = 3,
+package android.hardware.bluetooth.audio;
+@Backing(type="byte") @VintfStability
+enum AacObjectType {
+ MPEG2_LC = 1,
+ MPEG4_LC = 2,
+ MPEG4_LTP = 4,
+ MPEG4_SCALABLE = 8,
}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AptxCapabilities.aidl
similarity index 84%
copy from graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
copy to bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AptxCapabilities.aidl
index 41a1afe..4767b69 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AptxCapabilities.aidl
@@ -1,11 +1,11 @@
-/**
- * Copyright (c) 2021, The Android Open Source Project
+/*
+ * Copyright 2021 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
+ * 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,
@@ -31,10 +31,10 @@
// 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.composer3;
+package android.hardware.bluetooth.audio;
@VintfStability
-parcelable ExecuteCommandsStatus {
- boolean queueChanged;
- int length;
- android.hardware.common.NativeHandle[] handles;
+parcelable AptxCapabilities {
+ int[] sampleRateHz;
+ android.hardware.bluetooth.audio.ChannelMode channelMode;
+ byte[] bitsPerSample;
}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AptxConfiguration.aidl
similarity index 84%
copy from graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
copy to bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AptxConfiguration.aidl
index 41a1afe..91e88b3 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AptxConfiguration.aidl
@@ -1,11 +1,11 @@
-/**
- * Copyright (c) 2021, The Android Open Source Project
+/*
+ * Copyright 2021 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
+ * 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,
@@ -31,10 +31,10 @@
// 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.composer3;
+package android.hardware.bluetooth.audio;
@VintfStability
-parcelable ExecuteCommandsStatus {
- boolean queueChanged;
- int length;
- android.hardware.common.NativeHandle[] handles;
+parcelable AptxConfiguration {
+ int sampleRateHz;
+ android.hardware.bluetooth.audio.ChannelMode channelMode;
+ byte bitsPerSample;
}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/BlendMode.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AudioCapabilities.aidl
similarity index 79%
copy from graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/BlendMode.aidl
copy to bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AudioCapabilities.aidl
index a522d53..20a7731 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/BlendMode.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AudioCapabilities.aidl
@@ -1,11 +1,11 @@
-/**
- * Copyright (c) 2021, The Android Open Source Project
+/*
+ * Copyright 2021 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
+ * 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,
@@ -31,11 +31,10 @@
// 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.composer3;
-@Backing(type="int") @VintfStability
-enum BlendMode {
- INVALID = 0,
- NONE = 1,
- PREMULTIPLIED = 2,
- COVERAGE = 3,
+package android.hardware.bluetooth.audio;
+@VintfStability
+union AudioCapabilities {
+ android.hardware.bluetooth.audio.PcmCapabilities pcmCapabilities;
+ android.hardware.bluetooth.audio.CodecCapabilities codecCapabilities;
+ android.hardware.bluetooth.audio.LeAudioCapabilities leAudioCapabilities;
}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AudioConfiguration.aidl
similarity index 80%
copy from graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
copy to bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AudioConfiguration.aidl
index 41a1afe..34f7837 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AudioConfiguration.aidl
@@ -1,11 +1,11 @@
-/**
- * Copyright (c) 2021, The Android Open Source Project
+/*
+ * Copyright 2021 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
+ * 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,
@@ -31,10 +31,10 @@
// 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.composer3;
+package android.hardware.bluetooth.audio;
@VintfStability
-parcelable ExecuteCommandsStatus {
- boolean queueChanged;
- int length;
- android.hardware.common.NativeHandle[] handles;
+union AudioConfiguration {
+ android.hardware.bluetooth.audio.PcmConfiguration pcmConfig;
+ android.hardware.bluetooth.audio.CodecConfiguration codecConfig;
+ android.hardware.bluetooth.audio.LeAudioConfiguration leAudioConfig;
}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/LayerRequest.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AudioLocation.aidl
similarity index 87%
copy from graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/LayerRequest.aidl
copy to bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AudioLocation.aidl
index cfafc50..319a5e2 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/LayerRequest.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/AudioLocation.aidl
@@ -1,11 +1,11 @@
-/**
- * Copyright (c) 2021, The Android Open Source Project
+/*
+ * Copyright 2021 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
+ * 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,
@@ -31,8 +31,10 @@
// 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.composer3;
+package android.hardware.bluetooth.audio;
@Backing(type="int") @VintfStability
-enum LayerRequest {
- CLEAR_CLIENT_TARGET = 1,
+enum AudioLocation {
+ UNKNOWN = 1,
+ FRONT_LEFT = 2,
+ FRONT_RIGHT = 4,
}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/BlendMode.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/BroadcastConfiguration.aidl
similarity index 76%
copy from graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/BlendMode.aidl
copy to bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/BroadcastConfiguration.aidl
index a522d53..b3aa709 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/BlendMode.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/BroadcastConfiguration.aidl
@@ -1,11 +1,11 @@
-/**
- * Copyright (c) 2021, The Android Open Source Project
+/*
+ * Copyright 2021 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
+ * 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,
@@ -31,11 +31,14 @@
// 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.composer3;
-@Backing(type="int") @VintfStability
-enum BlendMode {
- INVALID = 0,
- NONE = 1,
- PREMULTIPLIED = 2,
- COVERAGE = 3,
+package android.hardware.bluetooth.audio;
+@VintfStability
+parcelable BroadcastConfiguration {
+ android.hardware.bluetooth.audio.BroadcastConfiguration.BroadcastStreamMap[] streamMap;
+ @VintfStability
+ parcelable BroadcastStreamMap {
+ char streamHandle;
+ int audioChannelAllocation;
+ android.hardware.bluetooth.audio.LeAudioCodecConfiguration leAudioCondecConfig;
+ }
}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/LayerRequest.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/ChannelMode.aidl
similarity index 86%
copy from graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/LayerRequest.aidl
copy to bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/ChannelMode.aidl
index cfafc50..3ca93c3 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/LayerRequest.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/ChannelMode.aidl
@@ -1,11 +1,11 @@
-/**
- * Copyright (c) 2021, The Android Open Source Project
+/*
+ * Copyright 2021 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
+ * 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,
@@ -31,8 +31,10 @@
// 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.composer3;
-@Backing(type="int") @VintfStability
-enum LayerRequest {
- CLEAR_CLIENT_TARGET = 1,
+package android.hardware.bluetooth.audio;
+@Backing(type="byte") @VintfStability
+enum ChannelMode {
+ UNKNOWN = 1,
+ MONO = 2,
+ STEREO = 4,
}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/BlendMode.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/CodecCapabilities.aidl
similarity index 70%
copy from graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/BlendMode.aidl
copy to bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/CodecCapabilities.aidl
index a522d53..b451880 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/BlendMode.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/CodecCapabilities.aidl
@@ -1,11 +1,11 @@
-/**
- * Copyright (c) 2021, The Android Open Source Project
+/*
+ * Copyright 2021 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
+ * 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,
@@ -31,11 +31,16 @@
// 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.composer3;
-@Backing(type="int") @VintfStability
-enum BlendMode {
- INVALID = 0,
- NONE = 1,
- PREMULTIPLIED = 2,
- COVERAGE = 3,
+package android.hardware.bluetooth.audio;
+@VintfStability
+parcelable CodecCapabilities {
+ android.hardware.bluetooth.audio.CodecType codecType;
+ android.hardware.bluetooth.audio.CodecCapabilities.Capabilities capabilities;
+ @VintfStability
+ union Capabilities {
+ android.hardware.bluetooth.audio.SbcCapabilities sbcCapabilities;
+ android.hardware.bluetooth.audio.AacCapabilities aacCapabilities;
+ android.hardware.bluetooth.audio.LdacCapabilities ldacCapabilities;
+ android.hardware.bluetooth.audio.AptxCapabilities aptxCapabilities;
+ }
}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/CodecConfiguration.aidl
similarity index 69%
copy from graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
copy to bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/CodecConfiguration.aidl
index 41a1afe..863aee2 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/CodecConfiguration.aidl
@@ -1,11 +1,11 @@
-/**
- * Copyright (c) 2021, The Android Open Source Project
+/*
+ * Copyright 2021 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
+ * 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,
@@ -31,10 +31,19 @@
// 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.composer3;
+package android.hardware.bluetooth.audio;
@VintfStability
-parcelable ExecuteCommandsStatus {
- boolean queueChanged;
- int length;
- android.hardware.common.NativeHandle[] handles;
+parcelable CodecConfiguration {
+ android.hardware.bluetooth.audio.CodecType codecType;
+ int encodedAudioBitrate;
+ int peerMtu;
+ boolean isScmstEnabled;
+ android.hardware.bluetooth.audio.CodecConfiguration.CodecSpecific config;
+ @VintfStability
+ union CodecSpecific {
+ android.hardware.bluetooth.audio.SbcConfiguration sbcConfig;
+ android.hardware.bluetooth.audio.AacConfiguration aacConfig;
+ android.hardware.bluetooth.audio.LdacConfiguration ldacConfig;
+ android.hardware.bluetooth.audio.AptxConfiguration aptxConfig;
+ }
}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/BlendMode.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/CodecType.aidl
similarity index 86%
copy from graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/BlendMode.aidl
copy to bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/CodecType.aidl
index a522d53..44b434b 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/BlendMode.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/CodecType.aidl
@@ -1,11 +1,11 @@
-/**
- * Copyright (c) 2021, The Android Open Source Project
+/*
+ * Copyright 2021 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
+ * 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,
@@ -31,11 +31,14 @@
// 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.composer3;
+package android.hardware.bluetooth.audio;
@Backing(type="int") @VintfStability
-enum BlendMode {
- INVALID = 0,
- NONE = 1,
- PREMULTIPLIED = 2,
- COVERAGE = 3,
+enum CodecType {
+ UNKNOWN = 0,
+ SBC = 1,
+ AAC = 2,
+ APTX = 3,
+ APTX_HD = 4,
+ LDAC = 5,
+ LC3 = 6,
}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/IBluetoothAudioPort.aidl
similarity index 75%
copy from graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
copy to bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/IBluetoothAudioPort.aidl
index 41a1afe..9a1557a 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/IBluetoothAudioPort.aidl
@@ -1,11 +1,11 @@
-/**
- * Copyright (c) 2021, The Android Open Source Project
+/*
+ * Copyright 2021 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
+ * 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,
@@ -31,10 +31,13 @@
// 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.composer3;
+package android.hardware.bluetooth.audio;
@VintfStability
-parcelable ExecuteCommandsStatus {
- boolean queueChanged;
- int length;
- android.hardware.common.NativeHandle[] handles;
+interface IBluetoothAudioPort {
+ android.hardware.bluetooth.audio.PresentationPosition getPresentationPosition();
+ void startStream();
+ void stopStream();
+ void suspendStream();
+ void updateSourceMetadata(in android.hardware.audio.common.SourceMetadata sourceMetadata);
+ void updateSinkMetadata(in android.hardware.audio.common.SinkMetadata sinkMetadata);
}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/IBluetoothAudioProvider.aidl
similarity index 74%
copy from graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
copy to bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/IBluetoothAudioProvider.aidl
index 41a1afe..84bcc0c 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/IBluetoothAudioProvider.aidl
@@ -1,11 +1,11 @@
-/**
- * Copyright (c) 2021, The Android Open Source Project
+/*
+ * Copyright 2021 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
+ * 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,
@@ -31,10 +31,11 @@
// 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.composer3;
+package android.hardware.bluetooth.audio;
@VintfStability
-parcelable ExecuteCommandsStatus {
- boolean queueChanged;
- int length;
- android.hardware.common.NativeHandle[] handles;
+interface IBluetoothAudioProvider {
+ void endSession();
+ android.hardware.common.fmq.MQDescriptor<int,android.hardware.common.fmq.UnsynchronizedWrite> startSession(in android.hardware.bluetooth.audio.IBluetoothAudioPort hostIf, in android.hardware.bluetooth.audio.AudioConfiguration audioConfig);
+ void streamStarted(in boolean status);
+ void streamSuspended(in boolean status);
}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/BlendMode.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/IBluetoothAudioProviderFactory.aidl
similarity index 76%
copy from graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/BlendMode.aidl
copy to bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/IBluetoothAudioProviderFactory.aidl
index a522d53..5e33deb 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/BlendMode.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/IBluetoothAudioProviderFactory.aidl
@@ -1,11 +1,11 @@
-/**
- * Copyright (c) 2021, The Android Open Source Project
+/*
+ * Copyright 2021 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
+ * 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,
@@ -31,11 +31,9 @@
// 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.composer3;
-@Backing(type="int") @VintfStability
-enum BlendMode {
- INVALID = 0,
- NONE = 1,
- PREMULTIPLIED = 2,
- COVERAGE = 3,
+package android.hardware.bluetooth.audio;
+@VintfStability
+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);
}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/Lc3Capabilities.aidl
similarity index 83%
copy from graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
copy to bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/Lc3Capabilities.aidl
index 41a1afe..3c650da 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/Lc3Capabilities.aidl
@@ -1,11 +1,11 @@
-/**
- * Copyright (c) 2021, The Android Open Source Project
+/*
+ * Copyright 2021 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
+ * 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,
@@ -31,10 +31,12 @@
// 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.composer3;
+package android.hardware.bluetooth.audio;
@VintfStability
-parcelable ExecuteCommandsStatus {
- boolean queueChanged;
- int length;
- android.hardware.common.NativeHandle[] handles;
+parcelable Lc3Capabilities {
+ byte[] pcmBitDepth;
+ int[] samplingFrequencyHz;
+ int[] frameDurationUs;
+ int[] octetsPerFrame;
+ byte[] blocksPerSdu;
}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/Lc3Configuration.aidl
similarity index 84%
copy from graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
copy to bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/Lc3Configuration.aidl
index 41a1afe..ef77da7 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/Lc3Configuration.aidl
@@ -1,11 +1,11 @@
-/**
- * Copyright (c) 2021, The Android Open Source Project
+/*
+ * Copyright 2021 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
+ * 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,
@@ -31,10 +31,12 @@
// 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.composer3;
+package android.hardware.bluetooth.audio;
@VintfStability
-parcelable ExecuteCommandsStatus {
- boolean queueChanged;
- int length;
- android.hardware.common.NativeHandle[] handles;
+parcelable Lc3Configuration {
+ byte pcmBitDepth;
+ int samplingFrequencyHz;
+ int frameDurationUs;
+ int octetsPerFrame;
+ byte blocksPerSdu;
}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LdacCapabilities.aidl
similarity index 81%
copy from graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
copy to bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LdacCapabilities.aidl
index 41a1afe..19e041a 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LdacCapabilities.aidl
@@ -1,11 +1,11 @@
-/**
- * Copyright (c) 2021, The Android Open Source Project
+/*
+ * Copyright 2021 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
+ * 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,
@@ -31,10 +31,11 @@
// 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.composer3;
+package android.hardware.bluetooth.audio;
@VintfStability
-parcelable ExecuteCommandsStatus {
- boolean queueChanged;
- int length;
- android.hardware.common.NativeHandle[] handles;
+parcelable LdacCapabilities {
+ int[] sampleRateHz;
+ android.hardware.bluetooth.audio.LdacChannelMode channelMode;
+ android.hardware.bluetooth.audio.LdacQualityIndex qualityIndex;
+ byte[] bitsPerSample;
}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/LayerRequest.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LdacChannelMode.aidl
similarity index 85%
copy from graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/LayerRequest.aidl
copy to bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LdacChannelMode.aidl
index cfafc50..a9d6c5e 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/LayerRequest.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LdacChannelMode.aidl
@@ -1,11 +1,11 @@
-/**
- * Copyright (c) 2021, The Android Open Source Project
+/*
+ * Copyright 2021 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
+ * 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,
@@ -31,8 +31,11 @@
// 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.composer3;
-@Backing(type="int") @VintfStability
-enum LayerRequest {
- CLEAR_CLIENT_TARGET = 1,
+package android.hardware.bluetooth.audio;
+@Backing(type="byte") @VintfStability
+enum LdacChannelMode {
+ UNKNOWN = 1,
+ STEREO = 2,
+ DUAL = 4,
+ MONO = 8,
}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LdacConfiguration.aidl
similarity index 81%
copy from graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
copy to bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LdacConfiguration.aidl
index 41a1afe..8a37638 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LdacConfiguration.aidl
@@ -1,11 +1,11 @@
-/**
- * Copyright (c) 2021, The Android Open Source Project
+/*
+ * Copyright 2021 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
+ * 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,
@@ -31,10 +31,11 @@
// 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.composer3;
+package android.hardware.bluetooth.audio;
@VintfStability
-parcelable ExecuteCommandsStatus {
- boolean queueChanged;
- int length;
- android.hardware.common.NativeHandle[] handles;
+parcelable LdacConfiguration {
+ int sampleRateHz;
+ android.hardware.bluetooth.audio.LdacChannelMode channelMode;
+ android.hardware.bluetooth.audio.LdacQualityIndex qualityIndex;
+ byte bitsPerSample;
}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/BlendMode.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LdacQualityIndex.aidl
similarity index 84%
copy from graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/BlendMode.aidl
copy to bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LdacQualityIndex.aidl
index a522d53..bc0d97b 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/BlendMode.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LdacQualityIndex.aidl
@@ -1,11 +1,11 @@
-/**
- * Copyright (c) 2021, The Android Open Source Project
+/*
+ * Copyright 2021 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
+ * 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,
@@ -31,11 +31,11 @@
// 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.composer3;
-@Backing(type="int") @VintfStability
-enum BlendMode {
- INVALID = 0,
- NONE = 1,
- PREMULTIPLIED = 2,
- COVERAGE = 3,
+package android.hardware.bluetooth.audio;
+@Backing(type="byte") @VintfStability
+enum LdacQualityIndex {
+ QUALITY_HIGH = 1,
+ QUALITY_MID = 2,
+ QUALITY_LOW = 4,
+ QUALITY_ABR = 8,
}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LeAudioCapabilities.aidl
similarity index 66%
copy from graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
copy to bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LeAudioCapabilities.aidl
index 41a1afe..9efafca 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LeAudioCapabilities.aidl
@@ -1,11 +1,11 @@
-/**
- * Copyright (c) 2021, The Android Open Source Project
+/*
+ * Copyright 2021 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
+ * 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,
@@ -31,10 +31,21 @@
// 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.composer3;
+package android.hardware.bluetooth.audio;
@VintfStability
-parcelable ExecuteCommandsStatus {
- boolean queueChanged;
- int length;
- android.hardware.common.NativeHandle[] handles;
+parcelable LeAudioCapabilities {
+ android.hardware.bluetooth.audio.LeAudioMode mode;
+ android.hardware.bluetooth.audio.CodecType codecType;
+ android.hardware.bluetooth.audio.AudioLocation supportedChannel;
+ int supportedChannelCount;
+ android.hardware.bluetooth.audio.LeAudioCapabilities.LeaudioCodecCapabilities leaudioCodecCapabilities;
+ @VintfStability
+ parcelable VendorCapabilities {
+ ParcelableHolder extension;
+ }
+ @VintfStability
+ union LeaudioCodecCapabilities {
+ android.hardware.bluetooth.audio.Lc3Capabilities lc3Capabilities;
+ android.hardware.bluetooth.audio.LeAudioCapabilities.VendorCapabilities vendorCapabillities;
+ }
}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LeAudioCodecConfiguration.aidl
similarity index 78%
copy from graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
copy to bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LeAudioCodecConfiguration.aidl
index 41a1afe..bb3d7e4 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LeAudioCodecConfiguration.aidl
@@ -1,11 +1,11 @@
-/**
- * Copyright (c) 2021, The Android Open Source Project
+/*
+ * Copyright 2021 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
+ * 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,
@@ -31,10 +31,13 @@
// 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.composer3;
+package android.hardware.bluetooth.audio;
@VintfStability
-parcelable ExecuteCommandsStatus {
- boolean queueChanged;
- int length;
- android.hardware.common.NativeHandle[] handles;
+union LeAudioCodecConfiguration {
+ android.hardware.bluetooth.audio.Lc3Configuration lc3Config;
+ android.hardware.bluetooth.audio.LeAudioCodecConfiguration.VendorConfiguration vendorConfig;
+ @VintfStability
+ parcelable VendorConfiguration {
+ ParcelableHolder extension;
+ }
}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LeAudioConfiguration.aidl
similarity index 73%
copy from graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
copy to bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LeAudioConfiguration.aidl
index 41a1afe..c6cb5cb 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LeAudioConfiguration.aidl
@@ -1,11 +1,11 @@
-/**
- * Copyright (c) 2021, The Android Open Source Project
+/*
+ * Copyright 2021 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
+ * 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,
@@ -31,10 +31,15 @@
// 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.composer3;
+package android.hardware.bluetooth.audio;
@VintfStability
-parcelable ExecuteCommandsStatus {
- boolean queueChanged;
- int length;
- android.hardware.common.NativeHandle[] handles;
+parcelable LeAudioConfiguration {
+ android.hardware.bluetooth.audio.LeAudioMode mode;
+ android.hardware.bluetooth.audio.LeAudioConfiguration.LeAuioModeConfig modeConfig;
+ android.hardware.bluetooth.audio.CodecType codecType;
+ @VintfStability
+ union LeAuioModeConfig {
+ android.hardware.bluetooth.audio.UnicastConfiguration unicastConfig;
+ android.hardware.bluetooth.audio.BroadcastConfiguration broadcastConfig;
+ }
}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/LayerRequest.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LeAudioMode.aidl
similarity index 85%
copy from graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/LayerRequest.aidl
copy to bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LeAudioMode.aidl
index cfafc50..766f637 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/LayerRequest.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/LeAudioMode.aidl
@@ -1,11 +1,11 @@
-/**
- * Copyright (c) 2021, The Android Open Source Project
+/*
+ * Copyright 2021 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
+ * 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,
@@ -31,8 +31,10 @@
// 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.composer3;
-@Backing(type="int") @VintfStability
-enum LayerRequest {
- CLEAR_CLIENT_TARGET = 1,
+package android.hardware.bluetooth.audio;
+@Backing(type="byte") @VintfStability
+enum LeAudioMode {
+ UNKNOWN = 0,
+ UNICAST = 1,
+ BROADCAST = 2,
}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/PcmCapabilities.aidl
similarity index 83%
copy from graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
copy to bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/PcmCapabilities.aidl
index 41a1afe..0c2f87d 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/PcmCapabilities.aidl
@@ -1,11 +1,11 @@
-/**
- * Copyright (c) 2021, The Android Open Source Project
+/*
+ * Copyright 2021 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
+ * 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,
@@ -31,10 +31,11 @@
// 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.composer3;
+package android.hardware.bluetooth.audio;
@VintfStability
-parcelable ExecuteCommandsStatus {
- boolean queueChanged;
- int length;
- android.hardware.common.NativeHandle[] handles;
+parcelable PcmCapabilities {
+ int[] sampleRateHz;
+ android.hardware.bluetooth.audio.ChannelMode[] channelMode;
+ byte[] bitsPerSample;
+ int[] dataIntervalUs;
}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/PcmConfiguration.aidl
similarity index 83%
copy from graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
copy to bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/PcmConfiguration.aidl
index 41a1afe..93d7805 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/PcmConfiguration.aidl
@@ -1,11 +1,11 @@
-/**
- * Copyright (c) 2021, The Android Open Source Project
+/*
+ * Copyright 2021 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
+ * 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,
@@ -31,10 +31,11 @@
// 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.composer3;
+package android.hardware.bluetooth.audio;
@VintfStability
-parcelable ExecuteCommandsStatus {
- boolean queueChanged;
- int length;
- android.hardware.common.NativeHandle[] handles;
+parcelable PcmConfiguration {
+ int sampleRateHz;
+ android.hardware.bluetooth.audio.ChannelMode channelMode;
+ byte bitsPerSample;
+ int dataIntervalUs;
}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/PresentationPosition.aidl
similarity index 78%
copy from graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
copy to bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/PresentationPosition.aidl
index 41a1afe..810a9a1 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/PresentationPosition.aidl
@@ -1,11 +1,11 @@
-/**
- * Copyright (c) 2021, The Android Open Source Project
+/*
+ * Copyright (C) 2021 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
+ * 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,
@@ -31,10 +31,15 @@
// 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.composer3;
+package android.hardware.bluetooth.audio;
@VintfStability
-parcelable ExecuteCommandsStatus {
- boolean queueChanged;
- int length;
- android.hardware.common.NativeHandle[] handles;
+parcelable PresentationPosition {
+ long remoteDeviceAudioDelayNanos;
+ long transmittedOctets;
+ android.hardware.bluetooth.audio.PresentationPosition.TimeSpec transmittedOctetsTimeStamp;
+ @VintfStability
+ parcelable TimeSpec {
+ long tvSec;
+ long tvNSec;
+ }
}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/LayerRequest.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/SbcAllocMethod.aidl
similarity index 86%
copy from graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/LayerRequest.aidl
copy to bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/SbcAllocMethod.aidl
index cfafc50..5170f16 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/LayerRequest.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/SbcAllocMethod.aidl
@@ -1,11 +1,11 @@
-/**
- * Copyright (c) 2021, The Android Open Source Project
+/*
+ * Copyright 2021 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
+ * 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,
@@ -31,8 +31,9 @@
// 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.composer3;
-@Backing(type="int") @VintfStability
-enum LayerRequest {
- CLEAR_CLIENT_TARGET = 1,
+package android.hardware.bluetooth.audio;
+@Backing(type="byte") @VintfStability
+enum SbcAllocMethod {
+ ALLOC_MD_S = 1,
+ ALLOC_MD_L = 2,
}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/SbcCapabilities.aidl
similarity index 78%
copy from graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
copy to bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/SbcCapabilities.aidl
index 41a1afe..ec3aa0f 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/SbcCapabilities.aidl
@@ -1,11 +1,11 @@
-/**
- * Copyright (c) 2021, The Android Open Source Project
+/*
+ * Copyright 2021 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
+ * 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,
@@ -31,10 +31,15 @@
// 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.composer3;
+package android.hardware.bluetooth.audio;
@VintfStability
-parcelable ExecuteCommandsStatus {
- boolean queueChanged;
- int length;
- android.hardware.common.NativeHandle[] handles;
+parcelable SbcCapabilities {
+ int[] sampleRateHz;
+ android.hardware.bluetooth.audio.SbcChannelMode channelMode;
+ byte[] blockLength;
+ byte[] numSubbands;
+ android.hardware.bluetooth.audio.SbcAllocMethod allocMethod;
+ byte[] bitsPerSample;
+ int minBitpool;
+ int maxBitpool;
}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/BlendMode.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/SbcChannelMode.aidl
similarity index 84%
copy from graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/BlendMode.aidl
copy to bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/SbcChannelMode.aidl
index a522d53..88fca4a 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/BlendMode.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/SbcChannelMode.aidl
@@ -1,11 +1,11 @@
-/**
- * Copyright (c) 2021, The Android Open Source Project
+/*
+ * Copyright 2021 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
+ * 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,
@@ -31,11 +31,12 @@
// 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.composer3;
-@Backing(type="int") @VintfStability
-enum BlendMode {
- INVALID = 0,
- NONE = 1,
- PREMULTIPLIED = 2,
- COVERAGE = 3,
+package android.hardware.bluetooth.audio;
+@Backing(type="byte") @VintfStability
+enum SbcChannelMode {
+ UNKNOWN = 1,
+ JOINT_STEREO = 2,
+ STEREO = 4,
+ DUAL = 8,
+ MONO = 16,
}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/SbcConfiguration.aidl
similarity index 78%
copy from graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
copy to bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/SbcConfiguration.aidl
index 41a1afe..8eab9c3 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/SbcConfiguration.aidl
@@ -1,11 +1,11 @@
-/**
- * Copyright (c) 2021, The Android Open Source Project
+/*
+ * Copyright 2021 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
+ * 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,
@@ -31,10 +31,15 @@
// 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.composer3;
+package android.hardware.bluetooth.audio;
@VintfStability
-parcelable ExecuteCommandsStatus {
- boolean queueChanged;
- int length;
- android.hardware.common.NativeHandle[] handles;
+parcelable SbcConfiguration {
+ int sampleRateHz;
+ android.hardware.bluetooth.audio.SbcChannelMode channelMode;
+ byte blockLength;
+ byte numSubbands;
+ android.hardware.bluetooth.audio.SbcAllocMethod allocMethod;
+ byte bitsPerSample;
+ int minBitpool;
+ int maxBitpool;
}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/BlendMode.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/SessionType.aidl
similarity index 74%
copy from graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/BlendMode.aidl
copy to bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/SessionType.aidl
index a522d53..900ab31 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/BlendMode.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/SessionType.aidl
@@ -1,11 +1,11 @@
-/**
- * Copyright (c) 2021, The Android Open Source Project
+/*
+ * Copyright 2021 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
+ * 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,
@@ -31,11 +31,15 @@
// 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.composer3;
-@Backing(type="int") @VintfStability
-enum BlendMode {
- INVALID = 0,
- NONE = 1,
- PREMULTIPLIED = 2,
- COVERAGE = 3,
+package android.hardware.bluetooth.audio;
+@Backing(type="byte") @VintfStability
+enum SessionType {
+ UNKNOWN = 0,
+ A2DP_SOFTWARE_ENCODING_DATAPATH = 1,
+ A2DP_HARDWARE_OFFLOAD_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,
}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/UnicastConfiguration.aidl
similarity index 76%
copy from graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
copy to bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/UnicastConfiguration.aidl
index 41a1afe..b385763 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
+++ b/bluetooth/audio/aidl/aidl_api/android.hardware.bluetooth.audio/current/android/hardware/bluetooth/audio/UnicastConfiguration.aidl
@@ -1,11 +1,11 @@
-/**
- * Copyright (c) 2021, The Android Open Source Project
+/*
+ * Copyright 2021 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
+ * 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,
@@ -31,10 +31,15 @@
// 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.composer3;
+package android.hardware.bluetooth.audio;
@VintfStability
-parcelable ExecuteCommandsStatus {
- boolean queueChanged;
- int length;
- android.hardware.common.NativeHandle[] handles;
+parcelable UnicastConfiguration {
+ android.hardware.bluetooth.audio.UnicastConfiguration.UnicastStreamMap[] streamMap;
+ int peerDelay;
+ android.hardware.bluetooth.audio.LeAudioCodecConfiguration leAudioCodecConfig;
+ @VintfStability
+ parcelable UnicastStreamMap {
+ char streamHandle;
+ int audioChannelAllocation;
+ }
}
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AacCapabilities.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AacCapabilities.aidl
new file mode 100644
index 0000000..4303883
--- /dev/null
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AacCapabilities.aidl
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2021 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.AacObjectType;
+import android.hardware.bluetooth.audio.ChannelMode;
+
+/**
+ * Used for Hardware Encoding AAC codec capabilities
+ */
+@VintfStability
+parcelable AacCapabilities {
+ /* bitfield */
+ AacObjectType objectType;
+ int[] sampleRateHz;
+ /* bitfield */
+ ChannelMode channelMode;
+ boolean variableBitRateSupported;
+ byte[] bitsPerSample;
+}
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AacConfiguration.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AacConfiguration.aidl
new file mode 100644
index 0000000..30338e7
--- /dev/null
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AacConfiguration.aidl
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2021 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.AacObjectType;
+import android.hardware.bluetooth.audio.ChannelMode;
+
+/**
+ * Used for Hardware Encoding AAC codec configuration
+ */
+@VintfStability
+parcelable AacConfiguration {
+ AacObjectType objectType;
+ int sampleRateHz;
+ ChannelMode channelMode;
+ boolean variableBitRateEnabled;
+ byte bitsPerSample;
+}
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AacObjectType.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AacObjectType.aidl
new file mode 100644
index 0000000..480e422
--- /dev/null
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AacObjectType.aidl
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2021 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
+@Backing(type="byte")
+enum AacObjectType {
+ /**
+ * MPEG-2 Low Complexity. Support is Mandatory.
+ */
+ MPEG2_LC = 1,
+ /**
+ * MPEG-4 Low Complexity. Support is Optional.
+ */
+ MPEG4_LC = 1 << 1,
+ /**
+ * MPEG-4 Long Term Prediction. Support is Optional.
+ */
+ MPEG4_LTP = 1 << 2,
+ /**
+ * MPEG-4 Scalable. Support is Optional.
+ */
+ MPEG4_SCALABLE = 1 << 3,
+}
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AptxCapabilities.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AptxCapabilities.aidl
new file mode 100644
index 0000000..6a37fc6
--- /dev/null
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AptxCapabilities.aidl
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2021 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;
+
+/**
+ * Used for Hardware Encoding AptX and AptX-HD codec capabilities
+ */
+@VintfStability
+parcelable AptxCapabilities {
+ int[] sampleRateHz;
+ /* bitfield */
+ ChannelMode channelMode;
+ byte[] bitsPerSample;
+}
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AptxConfiguration.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AptxConfiguration.aidl
new file mode 100644
index 0000000..83b7b0c
--- /dev/null
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AptxConfiguration.aidl
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2021 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;
+
+/**
+ * Used for Hardware Encoding AptX and AptX-HD codec configuration
+ */
+@VintfStability
+parcelable AptxConfiguration {
+ int sampleRateHz;
+ ChannelMode channelMode;
+ byte bitsPerSample;
+}
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AudioCapabilities.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AudioCapabilities.aidl
new file mode 100644
index 0000000..6ed4472
--- /dev/null
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AudioCapabilities.aidl
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2021 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.CodecCapabilities;
+import android.hardware.bluetooth.audio.LeAudioCapabilities;
+import android.hardware.bluetooth.audio.PcmCapabilities;
+
+/**
+ * Used to specify the capabilities of the different session types
+ */
+@VintfStability
+union AudioCapabilities {
+ PcmCapabilities pcmCapabilities;
+ CodecCapabilities codecCapabilities;
+ LeAudioCapabilities leAudioCapabilities;
+}
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AudioConfiguration.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AudioConfiguration.aidl
new file mode 100644
index 0000000..ce515b5
--- /dev/null
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AudioConfiguration.aidl
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2021 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.CodecConfiguration;
+import android.hardware.bluetooth.audio.LeAudioConfiguration;
+import android.hardware.bluetooth.audio.PcmConfiguration;
+
+/**
+ * Used to configure either a Hardware or Software Encoding session based on session type
+ */
+@VintfStability
+union AudioConfiguration {
+ PcmConfiguration pcmConfig;
+ CodecConfiguration codecConfig;
+ LeAudioConfiguration leAudioConfig;
+}
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AudioLocation.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AudioLocation.aidl
new file mode 100644
index 0000000..dedfbf9
--- /dev/null
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/AudioLocation.aidl
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2021 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
+@Backing(type="int")
+enum AudioLocation {
+ UNKNOWN = 1,
+ FRONT_LEFT = 1 << 1,
+ FRONT_RIGHT = 1 << 2,
+}
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/BroadcastConfiguration.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/BroadcastConfiguration.aidl
new file mode 100644
index 0000000..07d05f1
--- /dev/null
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/BroadcastConfiguration.aidl
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2021 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.LeAudioCodecConfiguration;
+
+@VintfStability
+parcelable BroadcastConfiguration {
+ @VintfStability
+ parcelable BroadcastStreamMap {
+ /*
+ * The connection handle used for a unicast or a broadcast group.
+ * Range: 0x0000 to 0xEFFF
+ */
+ char streamHandle;
+ /*
+ * Audio channel allocation is a bit field, each enabled bit means that given audio
+ * direction, i.e. "left", or "right" is used. Ordering of audio channels comes from the
+ * least significant bit to the most significant bit.
+ */
+ int audioChannelAllocation;
+ LeAudioCodecConfiguration leAudioCondecConfig;
+ }
+ BroadcastStreamMap[] streamMap;
+}
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/ChannelMode.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/ChannelMode.aidl
new file mode 100644
index 0000000..2df879d
--- /dev/null
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/ChannelMode.aidl
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2021 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
+@Backing(type="byte")
+enum ChannelMode {
+ UNKNOWN = 1,
+ MONO = 1 << 1,
+ STEREO = 1 << 2,
+}
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/CodecCapabilities.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/CodecCapabilities.aidl
new file mode 100644
index 0000000..0eee8cb
--- /dev/null
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/CodecCapabilities.aidl
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2021 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.AacCapabilities;
+import android.hardware.bluetooth.audio.AptxCapabilities;
+import android.hardware.bluetooth.audio.CodecType;
+import android.hardware.bluetooth.audio.LdacCapabilities;
+import android.hardware.bluetooth.audio.SbcCapabilities;
+
+/**
+ * Used to specify the capabilities of the codecs supported by Hardware Encoding.
+ * AptX and AptX-HD both use the AptxCapabilities field.
+ */
+@VintfStability
+parcelable CodecCapabilities {
+ @VintfStability
+ union Capabilities {
+ SbcCapabilities sbcCapabilities;
+ AacCapabilities aacCapabilities;
+ LdacCapabilities ldacCapabilities;
+ AptxCapabilities aptxCapabilities;
+ }
+ CodecType codecType;
+ Capabilities capabilities;
+}
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/CodecConfiguration.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/CodecConfiguration.aidl
new file mode 100644
index 0000000..fac90f0
--- /dev/null
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/CodecConfiguration.aidl
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2021 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.AacConfiguration;
+import android.hardware.bluetooth.audio.AptxConfiguration;
+import android.hardware.bluetooth.audio.CodecType;
+import android.hardware.bluetooth.audio.LdacConfiguration;
+import android.hardware.bluetooth.audio.SbcConfiguration;
+
+/**
+ * Used to configure a Hardware Encoding session.
+ * AptX and AptX-HD both use the AptxConfiguration field.
+ */
+@VintfStability
+parcelable CodecConfiguration {
+ @VintfStability
+ union CodecSpecific {
+ SbcConfiguration sbcConfig;
+ AacConfiguration aacConfig;
+ LdacConfiguration ldacConfig;
+ AptxConfiguration aptxConfig;
+ }
+ CodecType codecType;
+ /**
+ * The encoded audio bitrate in bits / second.
+ * 0x00000000 - The audio bitrate is not specified / unused
+ * 0x00000001 - 0x00FFFFFF - Encoded audio bitrate in bits/second
+ * 0x01000000 - 0xFFFFFFFF - Reserved
+ *
+ * The HAL needs to support all legal bitrates for the selected codec.
+ */
+ int encodedAudioBitrate;
+ /**
+ * Peer MTU (in two-octets)
+ */
+ int peerMtu;
+ /**
+ * Content protection by SCMS-T
+ */
+ boolean isScmstEnabled;
+ CodecSpecific config;
+}
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/CodecType.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/CodecType.aidl
new file mode 100644
index 0000000..68c60f5
--- /dev/null
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/CodecType.aidl
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2021 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
+@Backing(type="int")
+enum CodecType {
+ UNKNOWN,
+ SBC,
+ AAC,
+ APTX,
+ APTX_HD,
+ LDAC,
+ LC3,
+}
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/IBluetoothAudioPort.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/IBluetoothAudioPort.aidl
new file mode 100644
index 0000000..827f57d
--- /dev/null
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/IBluetoothAudioPort.aidl
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2021 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.audio.common.SinkMetadata;
+import android.hardware.audio.common.SourceMetadata;
+import android.hardware.bluetooth.audio.PresentationPosition;
+
+/**
+ * HAL interface from the Audio HAL to the Bluetooth stack
+ *
+ * The Audio HAL calls methods in this interface to start, suspend, and stop
+ * an audio stream. These calls return immediately and the results, if any,
+ * are sent over the IBluetoothAudioProvider interface.
+ *
+ * Moreover, the Audio HAL can also get the presentation position of the stream
+ * and provide stream metadata.
+ *
+ */
+@VintfStability
+interface IBluetoothAudioPort {
+ /**
+ * Get the audio presentation position.
+ *
+ * @return the audio presentation position
+ *
+ */
+ PresentationPosition getPresentationPosition();
+
+ /**
+ * This indicates that the caller of this method has opened the data path
+ * and wants to start an audio stream. The caller must wait for a
+ * IBluetoothAudioProvider.streamStarted(Status) call.
+ */
+ void startStream();
+
+ /**
+ * This indicates that the caller of this method wants to stop the audio
+ * stream. The data path will be closed after this call. There is no
+ * callback from the IBluetoothAudioProvider interface even though the
+ * teardown is asynchronous.
+ */
+ void stopStream();
+
+ /**
+ * This indicates that the caller of this method wants to suspend the audio
+ * stream. The caller must wait for the Bluetooth process to call
+ * IBluetoothAudioProvider.streamSuspended(Status). The caller still keeps
+ * the data path open.
+ */
+ void suspendStream();
+
+ /**
+ * Called when the metadata of the stream's source has been changed.
+ *
+ * @param sourceMetadata Description of the audio that is played by the
+ * clients.
+ */
+ void updateSourceMetadata(in SourceMetadata sourceMetadata);
+
+ /**
+ * Called when the metadata of the stream's sink has been changed.
+ *
+ * @param sinkMetadata as passed from Audio Framework
+ */
+ void updateSinkMetadata(in SinkMetadata sinkMetadata);
+}
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/IBluetoothAudioProvider.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/IBluetoothAudioProvider.aidl
new file mode 100644
index 0000000..cebd808
--- /dev/null
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/IBluetoothAudioProvider.aidl
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2021 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.AudioConfiguration;
+import android.hardware.bluetooth.audio.IBluetoothAudioPort;
+import android.hardware.common.fmq.MQDescriptor;
+import android.hardware.common.fmq.UnsynchronizedWrite;
+
+/**
+ * HAL interface from the Bluetooth stack to the Audio HAL
+ *
+ * The Bluetooth stack calls methods in this interface to start and end audio
+ * sessions and sends callback events to the Audio HAL.
+ *
+ */
+@VintfStability
+interface IBluetoothAudioProvider {
+ /**
+ * Ends the current session and unregisters the IBluetoothAudioPort
+ * interface.
+ */
+ void endSession();
+
+ /**
+ * This method indicates that the Bluetooth stack is ready to stream audio.
+ * It registers an instance of IBluetoothAudioPort with and provides the
+ * current negotiated codec to the Audio HAL. After this method is called,
+ * the Audio HAL can invoke IBluetoothAudioPort.startStream().
+ *
+ * Note: endSession() must be called to unregister this IBluetoothAudioPort
+ *
+ * @param hostIf An instance of IBluetoothAudioPort for stream control
+ * @param audioConfig The audio configuration negotiated with the remote
+ * device. The PCM parameters are set if software based encoding,
+ * otherwise the correct codec configuration is used for hardware
+ * encoding.
+ *
+ * @return The fast message queue for audio data from/to this
+ * provider. Audio data will be in PCM format as specified by the
+ * audioConfig.pcmConfig parameter. Invalid if streaming is offloaded
+ * from/to hardware or on failure
+ */
+ MQDescriptor<int, UnsynchronizedWrite> startSession(
+ in IBluetoothAudioPort hostIf, in AudioConfiguration audioConfig);
+
+ /**
+ * Callback for IBluetoothAudioPort.startStream()
+ *
+ * @param status true for SUCCESS or false for FAILURE
+ */
+ void streamStarted(in boolean status);
+
+ /**
+ * Callback for IBluetoothAudioPort.suspendStream()
+ *
+ * @param status true for SUCCESS or false for FAILURE
+ */
+ void streamSuspended(in boolean status);
+}
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/IBluetoothAudioProviderFactory.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/IBluetoothAudioProviderFactory.aidl
new file mode 100644
index 0000000..3cde22c
--- /dev/null
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/IBluetoothAudioProviderFactory.aidl
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2021 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.AudioCapabilities;
+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.
+ *
+ * When the Bluetooth stack is ready to create an audio session, it must first
+ * obtain the IBluetoothAudioProvider for that session type by calling
+ * openProvider().
+ *
+ */
+
+@VintfStability
+interface IBluetoothAudioProviderFactory {
+ /**
+ * Gets a list of audio capabilities for a session type.
+ *
+ * For software encoding, the PCM capabilities are returned.
+ * For hardware encoding, the supported codecs and their capabilities are
+ * returned.
+ *
+ * @param sessionType The session type (e.g.
+ * A2DP_SOFTWARE_ENCODING_DATAPATH).
+ * @return A list containing all the capabilities
+ * supported by the sesson type. The capabilities is a list of
+ * available options when configuring the codec for the session.
+ * For software encoding it is the PCM data rate.
+ * For hardware encoding it is the list of supported codecs and their
+ * capabilities.
+ * If a provider isn't supported, an empty list should be returned.
+ * Note: Only one entry should exist per codec when using hardware
+ * encoding.
+ */
+ AudioCapabilities[] getProviderCapabilities(in SessionType sessionType);
+
+ /**
+ * Opens an audio provider for a session type. To close the provider, it is
+ * necessary to release references to the returned provider object.
+ *
+ * @param sessionType The session type (e.g.
+ * LE_AUDIO_SOFTWARE_ENCODING_DATAPATH).
+ *
+ * @return provider The provider of the specified session type
+ */
+ IBluetoothAudioProvider openProvider(in SessionType sessionType);
+}
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/Lc3Capabilities.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/Lc3Capabilities.aidl
new file mode 100644
index 0000000..1aedefd
--- /dev/null
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/Lc3Capabilities.aidl
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2021 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;
+
+/**
+ * Used for Hardware Encoding/Decoding LC3 codec capabilities.
+ */
+@VintfStability
+parcelable Lc3Capabilities {
+ /*
+ * PCM is Input for encoder, Output for decoder
+ */
+ byte[] pcmBitDepth;
+ /*
+ * codec-specific parameters
+ */
+ int[] samplingFrequencyHz;
+ /*
+ * FrameDuration based on microseconds.
+ */
+ int[] frameDurationUs;
+ /*
+ * length in octets of a codec frame
+ */
+ int[] octetsPerFrame;
+ /*
+ * Number of blocks of codec frames per single SDU (Service Data Unit)
+ */
+ byte[] blocksPerSdu;
+}
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/Lc3Configuration.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/Lc3Configuration.aidl
new file mode 100644
index 0000000..77c04c1
--- /dev/null
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/Lc3Configuration.aidl
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2021 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;
+
+/**
+ * Used for Hardware Encoding/Decoding LC3 codec configuration.
+ */
+@VintfStability
+parcelable Lc3Configuration {
+ /*
+ * PCM is Input for encoder, Output for decoder
+ */
+ byte pcmBitDepth;
+ /*
+ * codec-specific parameters
+ */
+ int samplingFrequencyHz;
+ /*
+ * FrameDuration based on microseconds.
+ */
+ int frameDurationUs;
+ /*
+ * length in octets of a codec frame
+ */
+ int octetsPerFrame;
+ /*
+ * Number of blocks of codec frames per single SDU (Service Data Unit)
+ */
+ byte blocksPerSdu;
+}
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LdacCapabilities.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LdacCapabilities.aidl
new file mode 100644
index 0000000..44cca7e
--- /dev/null
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LdacCapabilities.aidl
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2021 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.LdacChannelMode;
+import android.hardware.bluetooth.audio.LdacQualityIndex;
+
+/**
+ * Used for Hardware Encoding LDAC codec capabilities
+ * all qualities must be supported.
+ */
+@VintfStability
+parcelable LdacCapabilities {
+ int[] sampleRateHz;
+ /* bitfiled */
+ LdacChannelMode channelMode;
+ /* bitfiled */
+ LdacQualityIndex qualityIndex;
+ byte[] bitsPerSample;
+}
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LdacChannelMode.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LdacChannelMode.aidl
new file mode 100644
index 0000000..3acca32
--- /dev/null
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LdacChannelMode.aidl
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2021 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;
+
+/**
+ * Channel Mode: 3 bits
+ */
+@VintfStability
+@Backing(type="byte")
+enum LdacChannelMode {
+ UNKNOWN = 1,
+ STEREO = 1 << 1,
+ DUAL = 1 << 2,
+ MONO = 1 << 3,
+}
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LdacConfiguration.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LdacConfiguration.aidl
new file mode 100644
index 0000000..cc03dd0
--- /dev/null
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LdacConfiguration.aidl
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2021 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.LdacChannelMode;
+import android.hardware.bluetooth.audio.LdacQualityIndex;
+
+/**
+ * Used for Hardware Encoding LDAC codec configuration
+ * Only used when configuring the codec.
+ */
+@VintfStability
+parcelable LdacConfiguration {
+ int sampleRateHz;
+ LdacChannelMode channelMode;
+ LdacQualityIndex qualityIndex;
+ byte bitsPerSample;
+}
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LdacQualityIndex.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LdacQualityIndex.aidl
new file mode 100644
index 0000000..fc532f4
--- /dev/null
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LdacQualityIndex.aidl
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2021 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
+@Backing(type="byte")
+enum LdacQualityIndex {
+ /**
+ * 990kbps
+ */
+ QUALITY_HIGH = 1,
+ /**
+ * 660kbps
+ */
+ QUALITY_MID = 1 << 1,
+ /**
+ * 330kbps
+ */
+ QUALITY_LOW = 1 << 2,
+ /**
+ * Adaptive Bit Rate mode
+ */
+ QUALITY_ABR = 1 << 3,
+}
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LeAudioCapabilities.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LeAudioCapabilities.aidl
new file mode 100644
index 0000000..ea05820
--- /dev/null
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LeAudioCapabilities.aidl
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2021 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.AudioLocation;
+import android.hardware.bluetooth.audio.CodecType;
+import android.hardware.bluetooth.audio.Lc3Capabilities;
+import android.hardware.bluetooth.audio.LeAudioMode;
+
+/**
+ * Used to specify the capabilities of the LC3 codecs supported by Hardware Encoding.
+ */
+@VintfStability
+parcelable LeAudioCapabilities {
+ @VintfStability
+ parcelable VendorCapabilities {
+ ParcelableHolder extension;
+ }
+ @VintfStability
+ union LeaudioCodecCapabilities {
+ Lc3Capabilities lc3Capabilities;
+ VendorCapabilities vendorCapabillities;
+ }
+ LeAudioMode mode;
+ CodecType codecType;
+ /*
+ * This is bitfield, if bit N is set, HW Offloader supports N+1 channels at the same time.
+ * Example: 0x27 = 0b00100111: One, two, three or six channels supported.
+ */
+ AudioLocation supportedChannel;
+ int supportedChannelCount;
+ LeaudioCodecCapabilities leaudioCodecCapabilities;
+}
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LeAudioCodecConfiguration.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LeAudioCodecConfiguration.aidl
new file mode 100644
index 0000000..421eeb2
--- /dev/null
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LeAudioCodecConfiguration.aidl
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2021 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.Lc3Configuration;
+
+@VintfStability
+union LeAudioCodecConfiguration {
+ @VintfStability
+ parcelable VendorConfiguration {
+ ParcelableHolder extension;
+ }
+ Lc3Configuration lc3Config;
+ VendorConfiguration vendorConfig;
+}
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LeAudioConfiguration.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LeAudioConfiguration.aidl
new file mode 100644
index 0000000..a212c96
--- /dev/null
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LeAudioConfiguration.aidl
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2021 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.BroadcastConfiguration;
+import android.hardware.bluetooth.audio.CodecType;
+import android.hardware.bluetooth.audio.LeAudioMode;
+import android.hardware.bluetooth.audio.UnicastConfiguration;
+
+@VintfStability
+parcelable LeAudioConfiguration {
+ @VintfStability
+ union LeAuioModeConfig {
+ UnicastConfiguration unicastConfig;
+ BroadcastConfiguration broadcastConfig;
+ }
+ /*
+ * The mode of the LE audio
+ */
+ LeAudioMode mode;
+ LeAuioModeConfig modeConfig;
+ CodecType codecType;
+}
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LeAudioMode.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LeAudioMode.aidl
new file mode 100644
index 0000000..2cf019e
--- /dev/null
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/LeAudioMode.aidl
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2021 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
+@Backing(type="byte")
+enum LeAudioMode {
+ UNKNOWN,
+ UNICAST,
+ BROADCAST,
+}
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/PcmCapabilities.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/PcmCapabilities.aidl
new file mode 100644
index 0000000..776b777
--- /dev/null
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/PcmCapabilities.aidl
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2021 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;
+
+/**
+ * Used for Software Encoding audio feed capabilities
+ */
+@VintfStability
+parcelable PcmCapabilities {
+ int[] sampleRateHz;
+ ChannelMode[] channelMode;
+ byte[] bitsPerSample;
+ /**
+ * Data interval for data transfer
+ */
+ int[] dataIntervalUs;
+}
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/PcmConfiguration.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/PcmConfiguration.aidl
new file mode 100644
index 0000000..03aa27b
--- /dev/null
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/PcmConfiguration.aidl
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2021 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;
+
+/**
+ * Used for Software Encoding audio feed configuration
+ */
+@VintfStability
+parcelable PcmConfiguration {
+ int sampleRateHz;
+ ChannelMode channelMode;
+ byte bitsPerSample;
+ /**
+ * Data interval for data transfer
+ */
+ int dataIntervalUs;
+}
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/PresentationPosition.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/PresentationPosition.aidl
new file mode 100644
index 0000000..17e746f
--- /dev/null
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/PresentationPosition.aidl
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2021 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
+parcelable PresentationPosition {
+ @VintfStability
+ parcelable TimeSpec {
+ /**
+ * seconds
+ */
+ long tvSec;
+ /**
+ * nanoseconds
+ */
+ long tvNSec;
+ }
+ /*
+ * remoteDeviceAudioDelayNanos the audio delay from when the remote
+ * device (e.g. headset) receives audio data to when the device plays the
+ * sound. If the delay is unknown, the value is set to zero.
+ */
+ long remoteDeviceAudioDelayNanos;
+ /*
+ * transmittedOctets the number of audio data octets that were sent
+ * to a remote device. This excludes octets that have been written to the
+ * data path but have not been sent to the remote device. The count is
+ * not reset until stopStream() is called. If the software data path is
+ * unused (e.g. Hardware Offload), the value is set to 0.
+ */
+ long transmittedOctets;
+ /*
+ * transmittedOctetsTimeStamp the value of CLOCK_MONOTONIC
+ * corresponding to transmittedOctets. If the software data path is
+ * unused (e.g., for Hardware Offload), the value is set to zero.
+ */
+ TimeSpec transmittedOctetsTimeStamp;
+}
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/SbcAllocMethod.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/SbcAllocMethod.aidl
new file mode 100644
index 0000000..7047e34
--- /dev/null
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/SbcAllocMethod.aidl
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2021 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
+@Backing(type="byte")
+enum SbcAllocMethod {
+ /**
+ * SNR
+ */
+ ALLOC_MD_S = 1,
+ /**
+ * Loudness
+ */
+ ALLOC_MD_L = 1 << 1,
+}
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/SbcCapabilities.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/SbcCapabilities.aidl
new file mode 100644
index 0000000..cf62ed4
--- /dev/null
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/SbcCapabilities.aidl
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2021 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.SbcAllocMethod;
+import android.hardware.bluetooth.audio.SbcChannelMode;
+
+/**
+ * Used for Hardware Encoding SBC codec capabilities.
+ */
+@VintfStability
+parcelable SbcCapabilities {
+ int[] sampleRateHz;
+ /* bitfield */
+ SbcChannelMode channelMode;
+ byte[] blockLength;
+ byte[] numSubbands;
+ /* bitfield */
+ SbcAllocMethod allocMethod;
+ byte[] bitsPerSample;
+ /*
+ * range from 2 to 250.
+ */
+ int minBitpool;
+ /*
+ * range from 2 to 250.
+ */
+ int maxBitpool;
+}
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/SbcChannelMode.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/SbcChannelMode.aidl
new file mode 100644
index 0000000..7eb38cd
--- /dev/null
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/SbcChannelMode.aidl
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2021 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
+@Backing(type="byte")
+enum SbcChannelMode {
+ UNKNOWN = 1,
+ JOINT_STEREO = 1 << 1,
+ STEREO = 1 << 2,
+ DUAL = 1 << 3,
+ MONO = 1 << 4,
+}
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/SbcConfiguration.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/SbcConfiguration.aidl
new file mode 100644
index 0000000..054d03e
--- /dev/null
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/SbcConfiguration.aidl
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2021 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.SbcAllocMethod;
+import android.hardware.bluetooth.audio.SbcChannelMode;
+
+/**
+ * Used for Hardware Encoding SBC codec configuration.
+ */
+@VintfStability
+parcelable SbcConfiguration {
+ int sampleRateHz;
+ SbcChannelMode channelMode;
+ byte blockLength;
+ byte numSubbands;
+ SbcAllocMethod allocMethod;
+ byte bitsPerSample;
+ /*
+ * range from 2 to 250.
+ */
+ int minBitpool;
+ /*
+ * range from 2 to 250.
+ */
+ int maxBitpool;
+}
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/SessionType.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/SessionType.aidl
new file mode 100644
index 0000000..b588869
--- /dev/null
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/SessionType.aidl
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2021 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
+@Backing(type="byte")
+enum SessionType {
+ UNKNOWN,
+ /**
+ * A2DP legacy that AVDTP media is encoded by Bluetooth Stack
+ */
+ A2DP_SOFTWARE_ENCODING_DATAPATH,
+ /**
+ * The encoding of AVDTP media is done by HW and there is control only
+ */
+ A2DP_HARDWARE_OFFLOAD_DATAPATH,
+ /**
+ * Used when encoded by Bluetooth Stack and streaming to Hearing Aid
+ */
+ HEARING_AID_SOFTWARE_ENCODING_DATAPATH,
+ /**
+ * Used when encoded by Bluetooth Stack and streaming to LE Audio device
+ */
+ LE_AUDIO_SOFTWARE_ENCODING_DATAPATH,
+ /**
+ * Used when decoded by Bluetooth Stack and streaming to audio framework
+ */
+ LE_AUDIO_SOFTWARE_DECODING_DATAPATH,
+ /**
+ * Encoding is done by HW an there is control only
+ */
+ LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH,
+ /**
+ * Decoding is done by HW an there is control only
+ */
+ LE_AUDIO_HARDWARE_OFFLOAD_DECODING_DATAPATH,
+}
diff --git a/bluetooth/audio/aidl/android/hardware/bluetooth/audio/UnicastConfiguration.aidl b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/UnicastConfiguration.aidl
new file mode 100644
index 0000000..7be2c5b
--- /dev/null
+++ b/bluetooth/audio/aidl/android/hardware/bluetooth/audio/UnicastConfiguration.aidl
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2021 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.LeAudioCodecConfiguration;
+
+@VintfStability
+parcelable UnicastConfiguration {
+ @VintfStability
+ parcelable UnicastStreamMap {
+ /*
+ * The connection handle used for a unicast or a broadcast group.
+ * Range: 0x0000 to 0xEFFF
+ */
+ char streamHandle;
+ /*
+ * Audio channel allocation is a bit field, each enabled bit means that given audio
+ * direction, i.e. "left", or "right" is used. Ordering of audio channels comes from the
+ * least significant bit to the most significant bit. The valus follows the Bluetooth SIG
+ * Audio Location assigned number.
+ */
+ int audioChannelAllocation;
+ }
+ UnicastStreamMap[] streamMap;
+ int peerDelay;
+ LeAudioCodecConfiguration leAudioCodecConfig;
+}
diff --git a/bluetooth/audio/utils/Android.bp b/bluetooth/audio/utils/Android.bp
index 19d2d92..4f712bf 100644
--- a/bluetooth/audio/utils/Android.bp
+++ b/bluetooth/audio/utils/Android.bp
@@ -22,6 +22,7 @@
export_include_dirs: ["session/"],
header_libs: ["libhardware_headers"],
shared_libs: [
+ "android.hardware.audio.common@5.0",
"android.hardware.bluetooth.audio@2.0",
"android.hardware.bluetooth.audio@2.1",
"android.hardware.bluetooth.audio@2.2",
diff --git a/bluetooth/audio/utils/session/BluetoothAudioSessionControl_2_1.h b/bluetooth/audio/utils/session/BluetoothAudioSessionControl_2_1.h
index 95f7408..4d7be21 100644
--- a/bluetooth/audio/utils/session/BluetoothAudioSessionControl_2_1.h
+++ b/bluetooth/audio/utils/session/BluetoothAudioSessionControl_2_1.h
@@ -35,7 +35,7 @@
std::shared_ptr<BluetoothAudioSession_2_1> session_ptr =
BluetoothAudioSessionInstance_2_1::GetSessionInstance(session_type);
if (session_ptr != nullptr) {
- return session_ptr->IsSessionReady();
+ return session_ptr->GetAudioSession()->IsSessionReady();
}
return false;
}
diff --git a/bluetooth/audio/utils/session/BluetoothAudioSessionControl_2_2.h b/bluetooth/audio/utils/session/BluetoothAudioSessionControl_2_2.h
index e20914e..b4ba8cf 100644
--- a/bluetooth/audio/utils/session/BluetoothAudioSessionControl_2_2.h
+++ b/bluetooth/audio/utils/session/BluetoothAudioSessionControl_2_2.h
@@ -132,6 +132,15 @@
}
}
+ static void UpdateSinkMetadata(const SessionType_2_1& session_type,
+ const struct sink_metadata* sink_metadata) {
+ std::shared_ptr<BluetoothAudioSession_2_2> session_ptr =
+ BluetoothAudioSessionInstance_2_2::GetSessionInstance(session_type);
+ if (session_ptr != nullptr) {
+ session_ptr->UpdateSinkMetadata(sink_metadata);
+ }
+ }
+
// The control API writes stream to FMQ
static size_t OutWritePcmData(const SessionType_2_1& session_type,
const void* buffer, size_t bytes) {
diff --git a/bluetooth/audio/utils/session/BluetoothAudioSession_2_1.cpp b/bluetooth/audio/utils/session/BluetoothAudioSession_2_1.cpp
index c250ef1..646e225 100644
--- a/bluetooth/audio/utils/session/BluetoothAudioSession_2_1.cpp
+++ b/bluetooth/audio/utils/session/BluetoothAudioSession_2_1.cpp
@@ -60,16 +60,6 @@
}
}
-bool BluetoothAudioSession_2_1::IsSessionReady() {
- if (session_type_2_1_ !=
- SessionType_2_1::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH) {
- return audio_session->IsSessionReady();
- }
-
- std::lock_guard<std::recursive_mutex> guard(audio_session->mutex_);
- return audio_session->stack_iface_ != nullptr;
-}
-
std::shared_ptr<BluetoothAudioSession>
BluetoothAudioSession_2_1::GetAudioSession() {
return audio_session;
@@ -80,7 +70,7 @@
const ::android::hardware::bluetooth::audio::V2_1::AudioConfiguration
BluetoothAudioSession_2_1::GetAudioConfig() {
std::lock_guard<std::recursive_mutex> guard(audio_session->mutex_);
- if (IsSessionReady()) {
+ if (audio_session->IsSessionReady()) {
// If session is unknown it means it should be 2.0 type
if (session_type_2_1_ != SessionType_2_1::UNKNOWN)
return audio_config_2_1_;
@@ -122,9 +112,6 @@
SessionType_2_1::LE_AUDIO_SOFTWARE_DECODED_DATAPATH);
bool is_offload_a2dp_session =
(session_type_2_1_ == SessionType_2_1::A2DP_HARDWARE_OFFLOAD_DATAPATH);
- bool is_offload_le_audio_session =
- (session_type_2_1_ == SessionType_2_1::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH ||
- session_type_2_1_ == SessionType_2_1::LE_AUDIO_HARDWARE_OFFLOAD_DECODING_DATAPATH);
auto audio_config_discriminator = audio_config.getDiscriminator();
bool is_software_audio_config =
(is_software_session &&
@@ -136,13 +123,7 @@
audio_config_discriminator ==
::android::hardware::bluetooth::audio::V2_1::AudioConfiguration::
hidl_discriminator::codecConfig);
- bool is_le_audio_offload_audio_config =
- (is_offload_le_audio_session &&
- audio_config_discriminator ==
- ::android::hardware::bluetooth::audio::V2_1::AudioConfiguration::
- hidl_discriminator::leAudioCodecConfig);
- if (!is_software_audio_config && !is_a2dp_offload_audio_config &&
- !is_le_audio_offload_audio_config) {
+ if (!is_software_audio_config && !is_a2dp_offload_audio_config) {
return false;
}
audio_config_2_1_ = audio_config;
diff --git a/bluetooth/audio/utils/session/BluetoothAudioSession_2_1.h b/bluetooth/audio/utils/session/BluetoothAudioSession_2_1.h
index db82c73..5a35153 100644
--- a/bluetooth/audio/utils/session/BluetoothAudioSession_2_1.h
+++ b/bluetooth/audio/utils/session/BluetoothAudioSession_2_1.h
@@ -50,10 +50,6 @@
const ::android::hardware::bluetooth::audio::V2_1::SessionType&
session_type);
- // The function helps to check if this session is ready or not
- // @return: true if the Bluetooth stack has started the specified session
- bool IsSessionReady();
-
std::shared_ptr<BluetoothAudioSession> GetAudioSession();
// The report function is used to report that the Bluetooth stack has started
diff --git a/bluetooth/audio/utils/session/BluetoothAudioSession_2_2.cpp b/bluetooth/audio/utils/session/BluetoothAudioSession_2_2.cpp
index 5a6b2e7..80df5d9 100644
--- a/bluetooth/audio/utils/session/BluetoothAudioSession_2_2.cpp
+++ b/bluetooth/audio/utils/session/BluetoothAudioSession_2_2.cpp
@@ -20,10 +20,16 @@
#include <android-base/logging.h>
#include <android-base/stringprintf.h>
+#include <android/hardware/bluetooth/audio/2.2/IBluetoothAudioPort.h>
namespace android {
namespace bluetooth {
namespace audio {
+
+using ::android::hardware::audio::common::V5_0::AudioSource;
+using ::android::hardware::audio::common::V5_0::RecordTrackMetadata;
+using ::android::hardware::audio::common::V5_0::SinkMetadata;
+
using SessionType_2_1 =
::android::hardware::bluetooth::audio::V2_1::SessionType;
using SessionType_2_0 =
@@ -37,6 +43,9 @@
::android::hardware::bluetooth::audio::V2_2::AudioConfiguration
BluetoothAudioSession_2_2::invalidOffloadAudioConfiguration = {};
+using IBluetoothAudioPort_2_2 =
+ ::android::hardware::bluetooth::audio::V2_2::IBluetoothAudioPort;
+
namespace {
bool is_2_0_session_type(
const ::android::hardware::bluetooth::audio::V2_1::SessionType&
@@ -84,6 +93,54 @@
return audio_session_2_1;
}
+void BluetoothAudioSession_2_2::UpdateSinkMetadata(
+ const struct sink_metadata* sink_metadata) {
+ std::lock_guard<std::recursive_mutex> guard(audio_session->mutex_);
+ if (!IsSessionReady()) {
+ LOG(DEBUG) << __func__ << " - SessionType=" << toString(session_type_2_1_)
+ << " has NO session";
+ return;
+ }
+
+ ssize_t track_count = sink_metadata->track_count;
+ LOG(INFO) << __func__ << " - SessionType=" << toString(session_type_2_1_)
+ << ", " << track_count << " track(s)";
+ if (session_type_2_1_ == SessionType_2_1::A2DP_SOFTWARE_ENCODING_DATAPATH ||
+ session_type_2_1_ == SessionType_2_1::A2DP_HARDWARE_OFFLOAD_DATAPATH) {
+ return;
+ }
+
+ struct record_track_metadata* track = sink_metadata->tracks;
+ SinkMetadata sinkMetadata;
+ RecordTrackMetadata* halMetadata;
+
+ sinkMetadata.tracks.resize(track_count);
+ halMetadata = sinkMetadata.tracks.data();
+ while (track_count && track) {
+ halMetadata->source = static_cast<AudioSource>(track->source);
+ halMetadata->gain = track->gain;
+ // halMetadata->destination leave unspecified
+ LOG(INFO) << __func__
+ << " - SessionType=" << toString(GetAudioSession()->session_type_)
+ << ", source=" << track->source
+ << ", dest_device=" << track->dest_device
+ << ", gain=" << track->gain
+ << ", dest_device_address=" << track->dest_device_address;
+ --track_count;
+ ++track;
+ ++halMetadata;
+ }
+
+ /* This is called just for 2.2 sessions, so it's safe to do this casting*/
+ IBluetoothAudioPort_2_2* stack_iface_2_2_ =
+ static_cast<IBluetoothAudioPort_2_2*>(audio_session->stack_iface_.get());
+ auto hal_retval = stack_iface_2_2_->updateSinkMetadata(sinkMetadata);
+ if (!hal_retval.isOk()) {
+ LOG(WARNING) << __func__ << " - IBluetoothAudioPort SessionType="
+ << toString(session_type_2_1_) << " failed";
+ }
+}
+
// The control function is for the bluetooth_audio module to get the current
// AudioConfiguration
const ::android::hardware::bluetooth::audio::V2_2::AudioConfiguration
diff --git a/bluetooth/audio/utils/session/BluetoothAudioSession_2_2.h b/bluetooth/audio/utils/session/BluetoothAudioSession_2_2.h
index 7213ede..d6ae3d7 100644
--- a/bluetooth/audio/utils/session/BluetoothAudioSession_2_2.h
+++ b/bluetooth/audio/utils/session/BluetoothAudioSession_2_2.h
@@ -74,6 +74,8 @@
const ::android::hardware::bluetooth::audio::V2_2::AudioConfiguration
GetAudioConfig();
+ void UpdateSinkMetadata(const struct sink_metadata* sink_metadata);
+
static constexpr ::android::hardware::bluetooth::audio::V2_2::
AudioConfiguration& kInvalidSoftwareAudioConfiguration =
invalidSoftwareAudioConfiguration;
diff --git a/camera/device/3.8/types.hal b/camera/device/3.8/types.hal
index 6daa0e1..843d050 100644
--- a/camera/device/3.8/types.hal
+++ b/camera/device/3.8/types.hal
@@ -35,8 +35,9 @@
/**
* Timestamp for the capture readout. This must be in the same time domain
- * as v3_2.timestamp, and the value must be v3_2.timestamp + exposureTime
- * for a rolling shutter sensor.
+ * as v3_2.timestamp, and for a rolling shutter sensor, the value must be
+ * v3_2.timestamp + exposureTime + t_crop_top where t_crop_top is the exposure time
+ * skew of the cropped lines on the top.
*/
uint64_t readoutTimestamp;
};
diff --git a/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp b/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp
index ff8cd49..77974fc 100644
--- a/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp
+++ b/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp
@@ -4796,15 +4796,24 @@
ASSERT_EQ(testStream.id, inflightReq.resultOutputBuffers[0].streamId);
// For camera device 3.8 or newer, shutterReadoutTimestamp must be
- // available, and it must be shutterTimestamp + exposureTime.
+ // available, and it must be >= shutterTimestamp + exposureTime, and
+ // < shutterTimestamp + exposureTime + rollingShutterSkew / 2.
if (deviceVersion >= CAMERA_DEVICE_API_VERSION_3_8) {
ASSERT_TRUE(inflightReq.shutterReadoutTimestampValid);
ASSERT_FALSE(inflightReq.collectedResult.isEmpty());
if (inflightReq.collectedResult.exists(ANDROID_SENSOR_EXPOSURE_TIME)) {
camera_metadata_entry_t exposureTimeResult = inflightReq.collectedResult.find(
ANDROID_SENSOR_EXPOSURE_TIME);
- ASSERT_EQ(inflightReq.shutterReadoutTimestamp - inflightReq.shutterTimestamp,
- exposureTimeResult.data.i64[0]);
+ nsecs_t exposureToReadout =
+ inflightReq.shutterReadoutTimestamp - inflightReq.shutterTimestamp;
+ ASSERT_GE(exposureToReadout, exposureTimeResult.data.i64[0]);
+ if (inflightReq.collectedResult.exists(ANDROID_SENSOR_ROLLING_SHUTTER_SKEW)) {
+ camera_metadata_entry_t rollingShutterSkew =
+ inflightReq.collectedResult.find(
+ ANDROID_SENSOR_ROLLING_SHUTTER_SKEW);
+ ASSERT_LT(exposureToReadout, exposureTimeResult.data.i64[0] +
+ rollingShutterSkew.data.i64[0] / 2);
+ }
}
}
diff --git a/compatibility_matrices/compatibility_matrix.current.xml b/compatibility_matrices/compatibility_matrix.current.xml
index 74d93b3..6919b9b 100644
--- a/compatibility_matrices/compatibility_matrix.current.xml
+++ b/compatibility_matrices/compatibility_matrix.current.xml
@@ -147,6 +147,13 @@
<instance>default</instance>
</interface>
</hal>
+ <hal format="aidl" optional="true">
+ <name>android.hardware.bluetooth.audio</name>
+ <interface>
+ <name>IBluetoothAudioProviderFactory</name>
+ <instance>default</instance>
+ </interface>
+ </hal>
<hal format="hidl" optional="true">
<name>android.hardware.boot</name>
<version>1.2</version>
@@ -222,9 +229,8 @@
<regex-instance>.*</regex-instance>
</interface>
</hal>
- <hal format="hidl" optional="true">
+ <hal format="aidl" optional="true">
<name>android.hardware.dumpstate</name>
- <version>1.1</version>
<interface>
<name>IDumpstateDevice</name>
<instance>default</instance>
@@ -292,16 +298,7 @@
<instance>default</instance>
</interface>
</hal>
- <hal format="hidl" optional="false">
- <name>android.hardware.health</name>
- <version>2.1</version>
- <interface>
- <name>IHealth</name>
- <instance>default</instance>
- </interface>
- </hal>
- <!-- TODO(b/177269435): require health AIDL HAL and deprecate HIDL HAL -->
- <hal format="aidl" optional="true">
+ <hal format="aidl" optional="false">
<name>android.hardware.health</name>
<version>1</version>
<interface>
@@ -326,6 +323,13 @@
</interface>
</hal>
<hal format="aidl" optional="true">
+ <name>android.hardware.net.nlinterceptor</name>
+ <interface>
+ <name>IInterceptor</name>
+ <instance>default</instance>
+ </interface>
+ </hal>
+ <hal format="aidl" optional="true">
<name>android.hardware.oemlock</name>
<version>1</version>
<interface>
diff --git a/dumpstate/aidl/Android.bp b/dumpstate/aidl/Android.bp
new file mode 100644
index 0000000..e18eade
--- /dev/null
+++ b/dumpstate/aidl/Android.bp
@@ -0,0 +1,43 @@
+// Copyright (C) 2021 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 {
+ // See: http://go/android-license-faq
+ // A large-scale-change added 'default_applicable_licenses' to import
+ // all of the 'license_kinds' from "hardware_interfaces_license"
+ // to get the below license kinds:
+ // SPDX-license-identifier-Apache-2.0
+ default_applicable_licenses: ["hardware_interfaces_license"],
+}
+
+aidl_interface {
+ name: "android.hardware.dumpstate",
+ vendor_available: true,
+ srcs: ["android/hardware/dumpstate/*.aidl"],
+ stability: "vintf",
+ backend: {
+ cpp: {
+ enabled: false,
+ },
+ java: {
+ enabled: false,
+ },
+ ndk: {
+ separate_platform_variant: false,
+ vndk: {
+ enabled: true,
+ },
+ },
+ },
+}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl b/dumpstate/aidl/aidl_api/android.hardware.dumpstate/current/android/hardware/dumpstate/IDumpstateDevice.aidl
similarity index 69%
copy from graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
copy to dumpstate/aidl/aidl_api/android.hardware.dumpstate/current/android/hardware/dumpstate/IDumpstateDevice.aidl
index 41a1afe..4d78a4c 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
+++ b/dumpstate/aidl/aidl_api/android.hardware.dumpstate/current/android/hardware/dumpstate/IDumpstateDevice.aidl
@@ -1,11 +1,11 @@
-/**
- * Copyright (c) 2021, The Android Open Source Project
+/*
+ * Copyright (C) 2021 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
+ * 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,
@@ -31,10 +31,23 @@
// 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.composer3;
+package android.hardware.dumpstate;
@VintfStability
-parcelable ExecuteCommandsStatus {
- boolean queueChanged;
- int length;
- android.hardware.common.NativeHandle[] handles;
+interface IDumpstateDevice {
+ void dumpstateBoard(in ParcelFileDescriptor[] fd, in android.hardware.dumpstate.IDumpstateDevice.DumpstateMode mode, in long timeoutMillis);
+ boolean getVerboseLoggingEnabled();
+ void setVerboseLoggingEnabled(in boolean enable);
+ const int ERROR_UNSUPPORTED_MODE = 1;
+ const int ERROR_DEVICE_LOGGING_NOT_ENABLED = 2;
+ @Backing(type="int") @VintfStability
+ enum DumpstateMode {
+ FULL = 0,
+ INTERACTIVE = 1,
+ REMOTE = 2,
+ WEAR = 3,
+ CONNECTIVITY = 4,
+ WIFI = 5,
+ DEFAULT = 6,
+ PROTO = 7,
+ }
}
diff --git a/dumpstate/aidl/android/hardware/dumpstate/IDumpstateDevice.aidl b/dumpstate/aidl/android/hardware/dumpstate/IDumpstateDevice.aidl
new file mode 100644
index 0000000..3b42546
--- /dev/null
+++ b/dumpstate/aidl/android/hardware/dumpstate/IDumpstateDevice.aidl
@@ -0,0 +1,137 @@
+/*
+ * Copyright (C) 2021 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.dumpstate;
+
+import android.os.ParcelFileDescriptor;
+
+@VintfStability
+interface IDumpstateDevice {
+ /**
+ * Constants that define the type of bug report being taken to restrict content appropriately.
+ */
+ @VintfStability
+ @Backing(type="int")
+ enum DumpstateMode {
+ /**
+ * Takes a bug report without user interference.
+ */
+ FULL = 0,
+ /**
+ * Interactive bug report, i.e. triggered by the user.
+ */
+ INTERACTIVE = 1,
+ /**
+ * Remote bug report triggered by DevicePolicyManager, for example.
+ */
+ REMOTE = 2,
+ /**
+ * Bug report triggered on a wear device.
+ */
+ WEAR = 3,
+ /**
+ * Bug report limited to only connectivity info (cellular, wifi, and networking). Sometimes
+ * called "telephony" in legacy contexts.
+ *
+ * All reported information MUST directly relate to connectivity debugging or customer
+ * support and MUST NOT contain unrelated private information. This information MUST NOT
+ * identify user-installed packages (UIDs are OK, package names are not), and MUST NOT
+ * contain logs of user application traffic.
+ */
+ CONNECTIVITY = 4,
+ /**
+ * Bug report limited to only wifi info.
+ */
+ WIFI = 5,
+ /**
+ * Default mode, This mode MUST be supported if the
+ * dumpstate HAL is implemented.
+ */
+ DEFAULT = 6,
+ /**
+ * Takes a report in protobuf.
+ *
+ * The content, if implemented, must be a binary protobuf message written to the first file
+ * descriptor of the native handle. The protobuf schema shall be defined by the vendor.
+ */
+ PROTO = 7,
+ }
+
+ /**
+ * Returned for cases where the device doesn't support the given DumpstateMode (e.g. a phone
+ * trying to use DumpstateMode::WEAR).
+ */
+ const int ERROR_UNSUPPORTED_MODE = 1;
+ /**
+ * Returned when device logging is not enabled.
+ */
+ const int ERROR_DEVICE_LOGGING_NOT_ENABLED = 2;
+
+ /**
+ * Dump device-specific state into the given file descriptors.
+ *
+ * One file descriptor must be passed to this method but two may be passed:
+ * the first descriptor must be used to dump device-specific state in text
+ * format, the second descriptor is optional and may be used to dump
+ * device-specific state in binary format.
+ *
+ * DumpstateMode can be used to limit the information that is output.
+ * For an example of when this is relevant, consider a bug report being generated with
+ * DumpstateMode::CONNECTIVITY - there is no reason to include camera or USB logs in this type
+ * of report.
+ *
+ * When verbose logging is disabled, getVerboseLoggingEnabled returns false, and this
+ * API is called, it may still output essential information but must not include
+ * information that identifies the user.
+ *
+ * @param fd array of file descriptors, with one or two valid file descriptors. The first FD is
+ * for text output, the second (if present) is for binary output.
+ * @param mode A mode value to restrict dumped content.
+ * @param timeoutMillis An approximate "budget" for how much time this call has been allotted.
+ * If execution runs longer than this, the IDumpstateDevice service may be killed and only
+ * partial information will be included in the report.
+ * @return If error, return service specific error with code
+ * ERROR_UNSUPPORTED_MODE or ERROR_DEVICE_LOGGING_NOT_ENABLED
+ */
+ void dumpstateBoard(in ParcelFileDescriptor[] fd, in DumpstateMode mode, in long timeoutMillis);
+
+ /**
+ * Queries the current state of verbose device logging. Primarily for UI and informative
+ * purposes.
+ *
+ * Even if verbose logging has been disabled, dumpstateBoard may still be called by the
+ * dumpstate routine, and essential information that does not identify the user may be included.
+ *
+ * @return Whether or not verbose vendor logging is currently enabled.
+ */
+ boolean getVerboseLoggingEnabled();
+
+ /**
+ * Turns verbose device vendor logging on or off.
+ *
+ * The setting should be persistent across reboots. Underlying implementations may need to start
+ * vendor logging daemons, set system properties, or change logging masks, for example. Given
+ * that many vendor logs contain significant amounts of private information and may come with
+ * memory/storage/battery impacts, calling this method on a user build should only be done after
+ * user consent has been obtained, e.g. from a toggle in developer settings.
+ *
+ * Even if verbose logging has been disabled, dumpstateBoard may still be called by the
+ * dumpstate routine, and essential information that does not identify the user may be included.
+ *
+ * @param enable Whether to enable or disable verbose vendor logging.
+ */
+ void setVerboseLoggingEnabled(in boolean enable);
+}
diff --git a/dumpstate/aidl/default/Android.bp b/dumpstate/aidl/default/Android.bp
new file mode 100644
index 0000000..45fdc17
--- /dev/null
+++ b/dumpstate/aidl/default/Android.bp
@@ -0,0 +1,46 @@
+// Copyright (C) 2021 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 {
+ // See: http://go/android-license-faq
+ // A large-scale-change added 'default_applicable_licenses' to import
+ // all of the 'license_kinds' from "hardware_interfaces_license"
+ // to get the below license kinds:
+ // SPDX-license-identifier-Apache-2.0
+ default_applicable_licenses: ["hardware_interfaces_license"],
+}
+
+cc_binary {
+ name: "android.hardware.dumpstate-service.example",
+ relative_install_path: "hw",
+ init_rc: ["dumpstate-default.rc"],
+ vintf_fragments: ["dumpstate-default.xml"],
+ vendor: true,
+ shared_libs: [
+ "libbase",
+ "libbinder_ndk",
+ "libcutils",
+ "libdumpstateutil",
+ "liblog",
+ "libutils",
+ "android.hardware.dumpstate-V1-ndk",
+ ],
+ srcs: [
+ "main.cpp",
+ "Dumpstate.cpp",
+ ],
+ cflags: [
+ "-DLOG_TAG=\"android.hardware.dumpstate-service.example\"",
+ ],
+}
diff --git a/dumpstate/aidl/default/Dumpstate.cpp b/dumpstate/aidl/default/Dumpstate.cpp
new file mode 100644
index 0000000..a0730fb
--- /dev/null
+++ b/dumpstate/aidl/default/Dumpstate.cpp
@@ -0,0 +1,101 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <android-base/properties.h>
+#include <log/log.h>
+#include "DumpstateUtil.h"
+
+#include "Dumpstate.h"
+
+using android::os::dumpstate::DumpFileToFd;
+
+namespace aidl {
+namespace android {
+namespace hardware {
+namespace dumpstate {
+
+const char kVerboseLoggingProperty[] = "persist.dumpstate.verbose_logging.enabled";
+
+ndk::ScopedAStatus Dumpstate::dumpstateBoard(const std::vector<::ndk::ScopedFileDescriptor>& in_fds,
+ IDumpstateDevice::DumpstateMode in_mode,
+ int64_t in_timeoutMillis) {
+ (void)in_timeoutMillis;
+
+ if (in_fds.size() < 1) {
+ return ndk::ScopedAStatus::fromExceptionCodeWithMessage(EX_ILLEGAL_ARGUMENT,
+ "No file descriptor");
+ }
+
+ int fd = in_fds[0].get();
+ if (fd < 0) {
+ return ndk::ScopedAStatus::fromExceptionCodeWithMessage(EX_ILLEGAL_ARGUMENT,
+ "Invalid file descriptor");
+ }
+
+ switch (in_mode) {
+ case IDumpstateDevice::DumpstateMode::FULL:
+ return dumpstateBoardImpl(fd, true);
+
+ case IDumpstateDevice::DumpstateMode::DEFAULT:
+ return dumpstateBoardImpl(fd, false);
+
+ case IDumpstateDevice::DumpstateMode::INTERACTIVE:
+ case IDumpstateDevice::DumpstateMode::REMOTE:
+ case IDumpstateDevice::DumpstateMode::WEAR:
+ case IDumpstateDevice::DumpstateMode::CONNECTIVITY:
+ case IDumpstateDevice::DumpstateMode::WIFI:
+ case IDumpstateDevice::DumpstateMode::PROTO:
+ return ndk::ScopedAStatus::fromServiceSpecificErrorWithMessage(ERROR_UNSUPPORTED_MODE,
+ "Unsupported mode");
+
+ default:
+ return ndk::ScopedAStatus::fromExceptionCodeWithMessage(EX_ILLEGAL_ARGUMENT,
+ "Invalid mode");
+ }
+
+ return ndk::ScopedAStatus::ok();
+}
+
+ndk::ScopedAStatus Dumpstate::getVerboseLoggingEnabled(bool* _aidl_return) {
+ *_aidl_return = getVerboseLoggingEnabledImpl();
+ return ndk::ScopedAStatus::ok();
+}
+
+ndk::ScopedAStatus Dumpstate::setVerboseLoggingEnabled(bool in_enable) {
+ ::android::base::SetProperty(kVerboseLoggingProperty, in_enable ? "true" : "false");
+ return ndk::ScopedAStatus::ok();
+}
+
+bool Dumpstate::getVerboseLoggingEnabledImpl() {
+ return ::android::base::GetBoolProperty(kVerboseLoggingProperty, false);
+}
+
+ndk::ScopedAStatus Dumpstate::dumpstateBoardImpl(const int fd, const bool full) {
+ ALOGD("DumpstateDevice::dumpstateBoard() FD: %d\n", fd);
+
+ dprintf(fd, "verbose logging: %s\n", getVerboseLoggingEnabledImpl() ? "enabled" : "disabled");
+ dprintf(fd, "[%s] %s\n", (full ? "full" : "default"), "Hello, world!");
+
+ // Shows an example on how to use the libdumpstateutil API.
+ DumpFileToFd(fd, "cmdline", "/proc/self/cmdline");
+
+ return ndk::ScopedAStatus::ok();
+}
+
+} // namespace dumpstate
+} // namespace hardware
+} // namespace android
+} // namespace aidl
diff --git a/dumpstate/aidl/default/Dumpstate.h b/dumpstate/aidl/default/Dumpstate.h
new file mode 100644
index 0000000..0629831
--- /dev/null
+++ b/dumpstate/aidl/default/Dumpstate.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2021 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 <aidl/android/hardware/dumpstate/BnDumpstateDevice.h>
+#include <aidl/android/hardware/dumpstate/IDumpstateDevice.h>
+#include <android/binder_status.h>
+
+namespace aidl {
+namespace android {
+namespace hardware {
+namespace dumpstate {
+
+class Dumpstate : public BnDumpstateDevice {
+ private:
+ bool getVerboseLoggingEnabledImpl();
+ ::ndk::ScopedAStatus dumpstateBoardImpl(const int fd, const bool full);
+
+ public:
+ ::ndk::ScopedAStatus dumpstateBoard(const std::vector<::ndk::ScopedFileDescriptor>& in_fds,
+ IDumpstateDevice::DumpstateMode in_mode,
+ int64_t in_timeoutMillis) override;
+
+ ::ndk::ScopedAStatus getVerboseLoggingEnabled(bool* _aidl_return) override;
+
+ ::ndk::ScopedAStatus setVerboseLoggingEnabled(bool in_enable) override;
+};
+
+} // namespace dumpstate
+} // namespace hardware
+} // namespace android
+} // namespace aidl
diff --git a/dumpstate/aidl/default/dumpstate-default.rc b/dumpstate/aidl/default/dumpstate-default.rc
new file mode 100644
index 0000000..4d011dd
--- /dev/null
+++ b/dumpstate/aidl/default/dumpstate-default.rc
@@ -0,0 +1,7 @@
+service vendor.dumpstate-default /vendor/bin/hw/android.hardware.dumpstate-service.example
+ class hal
+ user nobody
+ group nobody
+ interface aidl android.hardware.dumpstate.IDumpstateDevice/default
+ oneshot
+ disabled
diff --git a/dumpstate/aidl/default/dumpstate-default.xml b/dumpstate/aidl/default/dumpstate-default.xml
new file mode 100644
index 0000000..877aeed
--- /dev/null
+++ b/dumpstate/aidl/default/dumpstate-default.xml
@@ -0,0 +1,8 @@
+<manifest version="1.0" type="device">
+ <hal format="aidl">
+ <name>android.hardware.dumpstate</name>
+ <version>1</version>
+ <fqname>IDumpstateDevice/default</fqname>
+ </hal>
+</manifest>
+
diff --git a/dumpstate/aidl/default/main.cpp b/dumpstate/aidl/default/main.cpp
new file mode 100644
index 0000000..2451752
--- /dev/null
+++ b/dumpstate/aidl/default/main.cpp
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2021 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 "Dumpstate.h"
+
+#include <android-base/logging.h>
+#include <android/binder_manager.h>
+#include <android/binder_process.h>
+
+using aidl::android::hardware::dumpstate::Dumpstate;
+
+int main() {
+ ABinderProcess_setThreadPoolMaxThreadCount(0);
+ std::shared_ptr<Dumpstate> dumpstate = ndk::SharedRefBase::make<Dumpstate>();
+
+ const std::string instance = std::string() + Dumpstate::descriptor + "/default";
+ binder_status_t status =
+ AServiceManager_registerLazyService(dumpstate->asBinder().get(), instance.c_str());
+ CHECK(status == STATUS_OK);
+
+ ABinderProcess_joinThreadPool();
+ return EXIT_FAILURE; // Unreachable
+}
diff --git a/dumpstate/aidl/vts/functional/Android.bp b/dumpstate/aidl/vts/functional/Android.bp
new file mode 100644
index 0000000..5e516cf
--- /dev/null
+++ b/dumpstate/aidl/vts/functional/Android.bp
@@ -0,0 +1,41 @@
+// Copyright (C) 2021 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 {
+ // See: http://go/android-license-faq
+ // A large-scale-change added 'default_applicable_licenses' to import
+ // all of the 'license_kinds' from "hardware_interfaces_license"
+ // to get the below license kinds:
+ // SPDX-license-identifier-Apache-2.0
+ default_applicable_licenses: ["hardware_interfaces_license"],
+}
+
+cc_test {
+ name: "VtsHalDumpstateTargetTest",
+ defaults: [
+ "VtsHalTargetTestDefaults",
+ "use_libaidlvintf_gtest_helper_static",
+ ],
+ srcs: ["VtsHalDumpstateTargetTest.cpp"],
+ shared_libs: [
+ "libbinder_ndk",
+ "libvintf",
+ ],
+ static_libs: [
+ "android.hardware.dumpstate-V1-ndk",
+ ],
+ test_suites: [
+ "vts",
+ ],
+}
diff --git a/dumpstate/aidl/vts/functional/VtsHalDumpstateTargetTest.cpp b/dumpstate/aidl/vts/functional/VtsHalDumpstateTargetTest.cpp
new file mode 100644
index 0000000..442b0b0
--- /dev/null
+++ b/dumpstate/aidl/vts/functional/VtsHalDumpstateTargetTest.cpp
@@ -0,0 +1,295 @@
+/*
+ * Copyright (C) 2021 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 <fcntl.h>
+#include <unistd.h>
+
+#include <functional>
+#include <tuple>
+#include <vector>
+
+#include <aidl/Gtest.h>
+#include <aidl/Vintf.h>
+
+#include <aidl/android/hardware/dumpstate/IDumpstateDevice.h>
+#include <android/binder_manager.h>
+#include <android/binder_process.h>
+
+using aidl::android::hardware::dumpstate::IDumpstateDevice;
+
+// Base class common to all dumpstate HAL AIDL tests.
+template <typename T>
+class DumpstateAidlTestBase : public ::testing::TestWithParam<T> {
+ protected:
+ bool CheckStatus(const ndk::ScopedAStatus& status, const binder_exception_t expected_ex_code,
+ const int32_t expected_service_specific) {
+ binder_exception_t ex_code = status.getExceptionCode();
+ if (ex_code != expected_ex_code) {
+ return false;
+ }
+ if (ex_code == EX_SERVICE_SPECIFIC) {
+ int32_t service_specific = status.getServiceSpecificError();
+ if (service_specific != expected_service_specific) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public:
+ virtual void SetUp() override { GetService(); }
+
+ virtual std::string GetInstanceName() = 0;
+
+ void GetService() {
+ const std::string instance_name = GetInstanceName();
+
+ ASSERT_TRUE(AServiceManager_isDeclared(instance_name.c_str()));
+ auto dumpstateBinder =
+ ndk::SpAIBinder(AServiceManager_waitForService(instance_name.c_str()));
+ dumpstate = IDumpstateDevice::fromBinder(dumpstateBinder);
+ ASSERT_NE(dumpstate, nullptr) << "Could not get AIDL instance " << instance_name;
+ }
+
+ void ToggleVerboseLogging(bool enable) {
+ ndk::ScopedAStatus status;
+ bool logging_enabled = false;
+
+ status = dumpstate->setVerboseLoggingEnabled(enable);
+ ASSERT_TRUE(status.isOk()) << "Status should be ok: " << status.getDescription();
+
+ status = dumpstate->getVerboseLoggingEnabled(&logging_enabled);
+ ASSERT_TRUE(status.isOk()) << "Status should be ok: " << status.getDescription();
+ ASSERT_EQ(logging_enabled, enable)
+ << "Verbose logging should now be " << (enable ? "enabled" : "disabled");
+ }
+
+ void EnableVerboseLogging() { ToggleVerboseLogging(true); }
+
+ void DisableVerboseLogging() { ToggleVerboseLogging(false); }
+
+ std::shared_ptr<IDumpstateDevice> dumpstate;
+};
+
+// Tests that don't need to iterate every single DumpstateMode value for dumpstateBoard_1_1.
+class DumpstateAidlGeneralTest : public DumpstateAidlTestBase<std::string> {
+ protected:
+ virtual std::string GetInstanceName() override { return GetParam(); }
+};
+
+// Tests that iterate every single DumpstateMode value for dumpstateBoard_1_1.
+class DumpstateAidlPerModeTest
+ : public DumpstateAidlTestBase<std::tuple<std::string, IDumpstateDevice::DumpstateMode>> {
+ protected:
+ virtual std::string GetInstanceName() override { return std::get<0>(GetParam()); }
+
+ IDumpstateDevice::DumpstateMode GetMode() { return std::get<1>(GetParam()); }
+
+ // Will only execute additional_assertions when status == expected.
+ void AssertStatusForMode(const ::ndk::ScopedAStatus& status,
+ binder_exception_t expected_ex_code, int32_t expected_service_specific,
+ std::function<void()> additional_assertions = nullptr) {
+ if (GetMode() == IDumpstateDevice::DumpstateMode::DEFAULT) {
+ ASSERT_TRUE(CheckStatus(status, expected_ex_code, expected_ex_code));
+ } else {
+ // The rest of the modes are optional to support, but they MUST return either the
+ // expected value or UNSUPPORTED_MODE.
+ ASSERT_TRUE(CheckStatus(status, expected_ex_code, expected_service_specific) ||
+ CheckStatus(status, EX_SERVICE_SPECIFIC,
+ IDumpstateDevice::ERROR_UNSUPPORTED_MODE));
+ }
+ if (CheckStatus(status, expected_ex_code, expected_service_specific) &&
+ additional_assertions != nullptr) {
+ additional_assertions();
+ }
+ }
+};
+
+constexpr uint64_t kDefaultTimeoutMillis = 30 * 1000; // 30 seconds
+
+// Negative test: make sure dumpstateBoard() doesn't crash when passed a empty file descriptor
+// array.
+TEST_P(DumpstateAidlPerModeTest, TestNullHandle) {
+ EnableVerboseLogging();
+
+ std::vector<::ndk::ScopedFileDescriptor> dumpstateFds; // empty file descriptor vector
+
+ auto status = dumpstate->dumpstateBoard(dumpstateFds, GetMode(), kDefaultTimeoutMillis);
+ AssertStatusForMode(status, EX_ILLEGAL_ARGUMENT, 0);
+}
+
+// Positive test: make sure dumpstateBoard() writes something to the FD.
+TEST_P(DumpstateAidlPerModeTest, TestOk) {
+ EnableVerboseLogging();
+
+ // Index 0 corresponds to the read end of the pipe; 1 to the write end.
+ int fds[2];
+ ASSERT_EQ(0, pipe2(fds, O_NONBLOCK)) << errno;
+
+ std::vector<::ndk::ScopedFileDescriptor> dumpstateFds;
+ dumpstateFds.emplace_back(fds[1]);
+
+ auto status = dumpstate->dumpstateBoard(dumpstateFds, GetMode(), kDefaultTimeoutMillis);
+
+ AssertStatusForMode(status, EX_NONE, 0, [&fds]() {
+ // Check that at least one byte was written.
+ char buff;
+ ASSERT_EQ(1, read(fds[0], &buff, 1)) << "Dumped nothing";
+ });
+
+ close(fds[1]);
+ close(fds[0]);
+}
+
+// Positive test: make sure dumpstateBoard() doesn't crash with two FDs.
+TEST_P(DumpstateAidlPerModeTest, TestHandleWithTwoFds) {
+ EnableVerboseLogging();
+
+ int fds1[2];
+ int fds2[2];
+ ASSERT_EQ(0, pipe2(fds1, O_NONBLOCK)) << errno;
+ ASSERT_EQ(0, pipe2(fds2, O_NONBLOCK)) << errno;
+
+ std::vector<::ndk::ScopedFileDescriptor> dumpstateFds;
+ dumpstateFds.emplace_back(fds1[1]);
+ dumpstateFds.emplace_back(fds2[1]);
+
+ auto status = dumpstate->dumpstateBoard(dumpstateFds, GetMode(), kDefaultTimeoutMillis);
+
+ AssertStatusForMode(status, EX_NONE, 0, [&fds1, &fds2]() {
+ // Check that at least one byte was written to one of the FDs.
+ char buff;
+ size_t read1 = read(fds1[0], &buff, 1);
+ size_t read2 = read(fds2[0], &buff, 1);
+ // Sometimes read returns -1, so we can't just add them together and expect >= 1.
+ ASSERT_TRUE(read1 == 1 || read2 == 1) << "Dumped nothing";
+ });
+
+ close(fds1[1]);
+ close(fds1[0]);
+ close(fds2[1]);
+ close(fds2[0]);
+}
+
+// Make sure dumpstateBoard actually validates its arguments.
+TEST_P(DumpstateAidlGeneralTest, TestInvalidModeArgument_Negative) {
+ EnableVerboseLogging();
+
+ int fds[2];
+ ASSERT_EQ(0, pipe2(fds, O_NONBLOCK)) << errno;
+
+ std::vector<::ndk::ScopedFileDescriptor> dumpstateFds;
+ dumpstateFds.emplace_back(fds[1]);
+
+ auto status = dumpstate->dumpstateBoard(dumpstateFds,
+ static_cast<IDumpstateDevice::DumpstateMode>(-100),
+ kDefaultTimeoutMillis);
+ ASSERT_TRUE(CheckStatus(status, EX_ILLEGAL_ARGUMENT, 0));
+
+ close(fds[1]);
+ close(fds[0]);
+}
+
+TEST_P(DumpstateAidlGeneralTest, TestInvalidModeArgument_Undefined) {
+ EnableVerboseLogging();
+
+ int fds[2];
+ ASSERT_EQ(0, pipe2(fds, O_NONBLOCK)) << errno;
+
+ std::vector<::ndk::ScopedFileDescriptor> dumpstateFds;
+ dumpstateFds.emplace_back(fds[1]);
+
+ auto status = dumpstate->dumpstateBoard(dumpstateFds,
+ static_cast<IDumpstateDevice::DumpstateMode>(9001),
+ kDefaultTimeoutMillis);
+ ASSERT_TRUE(CheckStatus(status, EX_ILLEGAL_ARGUMENT, 0));
+
+ close(fds[1]);
+ close(fds[0]);
+}
+
+// Make sure disabling verbose logging behaves correctly. Some info is still allowed to be emitted,
+// but it can't have privacy/storage/battery impacts.
+TEST_P(DumpstateAidlPerModeTest, TestDeviceLoggingDisabled) {
+ DisableVerboseLogging();
+
+ // Index 0 corresponds to the read end of the pipe; 1 to the write end.
+ int fds[2];
+ ASSERT_EQ(0, pipe2(fds, O_NONBLOCK)) << errno;
+
+ std::vector<::ndk::ScopedFileDescriptor> dumpstateFds;
+ dumpstateFds.emplace_back(fds[1]);
+
+ auto status = dumpstate->dumpstateBoard(dumpstateFds, GetMode(), kDefaultTimeoutMillis);
+
+ // We don't include additional assertions here about the file passed in. If verbose logging is
+ // disabled, the OEM may choose to include nothing at all, but it is allowed to include some
+ // essential information based on the mode as long as it isn't private user information.
+ AssertStatusForMode(status, EX_NONE, 0);
+
+ close(fds[1]);
+ close(fds[0]);
+}
+
+// Double-enable is perfectly valid, but the second call shouldn't do anything.
+TEST_P(DumpstateAidlGeneralTest, TestRepeatedEnable) {
+ EnableVerboseLogging();
+ EnableVerboseLogging();
+}
+
+// Double-disable is perfectly valid, but the second call shouldn't do anything.
+TEST_P(DumpstateAidlGeneralTest, TestRepeatedDisable) {
+ DisableVerboseLogging();
+ DisableVerboseLogging();
+}
+
+// Toggling in short order is perfectly valid.
+TEST_P(DumpstateAidlGeneralTest, TestRepeatedToggle) {
+ EnableVerboseLogging();
+ DisableVerboseLogging();
+ EnableVerboseLogging();
+ DisableVerboseLogging();
+}
+
+GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(DumpstateAidlGeneralTest);
+INSTANTIATE_TEST_SUITE_P(
+ PerInstance, DumpstateAidlGeneralTest,
+ testing::ValuesIn(android::getAidlHalInstanceNames(IDumpstateDevice::descriptor)),
+ android::PrintInstanceNameToString);
+
+// Includes the mode's name as part of the description string.
+static inline std::string PrintInstanceNameToStringWithMode(
+ const testing::TestParamInfo<std::tuple<std::string, IDumpstateDevice::DumpstateMode>>&
+ info) {
+ return android::PrintInstanceNameToString(
+ testing::TestParamInfo(std::get<0>(info.param), info.index)) +
+ "_" + toString(std::get<1>(info.param));
+}
+
+GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(DumpstateAidlPerModeTest);
+INSTANTIATE_TEST_SUITE_P(
+ PerInstanceAndMode, DumpstateAidlPerModeTest,
+ testing::Combine(
+ testing::ValuesIn(android::getAidlHalInstanceNames(IDumpstateDevice::descriptor)),
+ testing::ValuesIn(ndk::internal::enum_values<IDumpstateDevice::DumpstateMode>)),
+ PrintInstanceNameToStringWithMode);
+
+int main(int argc, char** argv) {
+ ::testing::InitGoogleTest(&argc, argv);
+ ABinderProcess_setThreadPoolMaxThreadCount(1);
+ ABinderProcess_startThreadPool();
+ return RUN_ALL_TESTS();
+}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/BlendMode.aidl b/gnss/aidl/aidl_api/android.hardware.gnss/current/android/hardware/gnss/IAGnss.aidl
similarity index 71%
copy from graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/BlendMode.aidl
copy to gnss/aidl/aidl_api/android.hardware.gnss/current/android/hardware/gnss/IAGnss.aidl
index a522d53..f02e08c 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/BlendMode.aidl
+++ b/gnss/aidl/aidl_api/android.hardware.gnss/current/android/hardware/gnss/IAGnss.aidl
@@ -1,11 +1,11 @@
-/**
- * Copyright (c) 2021, The Android Open Source Project
+/*
+ * Copyright (C) 2021 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
+ * 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,
@@ -31,11 +31,19 @@
// 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.composer3;
-@Backing(type="int") @VintfStability
-enum BlendMode {
- INVALID = 0,
- NONE = 1,
- PREMULTIPLIED = 2,
- COVERAGE = 3,
+package android.hardware.gnss;
+@VintfStability
+interface IAGnss {
+ void setCallback(in android.hardware.gnss.IAGnssCallback callback);
+ void dataConnClosed();
+ void dataConnFailed();
+ void setServer(in android.hardware.gnss.IAGnssCallback.AGnssType type, in String hostname, in int port);
+ void dataConnOpen(in long networkHandle, in String apn, in android.hardware.gnss.IAGnss.ApnIpType apnIpType);
+ @Backing(type="int") @VintfStability
+ enum ApnIpType {
+ INVALID = 0,
+ IPV4 = 1,
+ IPV6 = 2,
+ IPV4V6 = 3,
+ }
}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl b/gnss/aidl/aidl_api/android.hardware.gnss/current/android/hardware/gnss/IAGnssCallback.aidl
similarity index 70%
copy from graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
copy to gnss/aidl/aidl_api/android.hardware.gnss/current/android/hardware/gnss/IAGnssCallback.aidl
index 41a1afe..2a46f61 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
+++ b/gnss/aidl/aidl_api/android.hardware.gnss/current/android/hardware/gnss/IAGnssCallback.aidl
@@ -1,11 +1,11 @@
-/**
- * Copyright (c) 2021, The Android Open Source Project
+/*
+ * Copyright (C) 2021 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
+ * 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,
@@ -31,10 +31,23 @@
// 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.composer3;
+package android.hardware.gnss;
@VintfStability
-parcelable ExecuteCommandsStatus {
- boolean queueChanged;
- int length;
- android.hardware.common.NativeHandle[] handles;
+interface IAGnssCallback {
+ void agnssStatusCb(in android.hardware.gnss.IAGnssCallback.AGnssType type, in android.hardware.gnss.IAGnssCallback.AGnssStatusValue status);
+ @Backing(type="int") @VintfStability
+ enum AGnssType {
+ SUPL = 1,
+ C2K = 2,
+ SUPL_EIMS = 3,
+ SUPL_IMS = 4,
+ }
+ @Backing(type="int") @VintfStability
+ enum AGnssStatusValue {
+ REQUEST_AGNSS_DATA_CONN = 1,
+ RELEASE_AGNSS_DATA_CONN = 2,
+ AGNSS_DATA_CONNECTED = 3,
+ AGNSS_DATA_CONN_DONE = 4,
+ AGNSS_DATA_CONN_FAILED = 5,
+ }
}
diff --git a/gnss/aidl/aidl_api/android.hardware.gnss/current/android/hardware/gnss/IGnss.aidl b/gnss/aidl/aidl_api/android.hardware.gnss/current/android/hardware/gnss/IGnss.aidl
index 9bd04a0..ea98030 100644
--- a/gnss/aidl/aidl_api/android.hardware.gnss/current/android/hardware/gnss/IGnss.aidl
+++ b/gnss/aidl/aidl_api/android.hardware.gnss/current/android/hardware/gnss/IGnss.aidl
@@ -43,6 +43,7 @@
@nullable android.hardware.gnss.IGnssBatching getExtensionGnssBatching();
@nullable android.hardware.gnss.IGnssGeofence getExtensionGnssGeofence();
@nullable android.hardware.gnss.IGnssNavigationMessageInterface getExtensionGnssNavigationMessage();
+ android.hardware.gnss.IAGnss getExtensionAGnss();
const int ERROR_INVALID_ARGUMENT = 1;
const int ERROR_ALREADY_INIT = 2;
const int ERROR_GENERIC = 3;
diff --git a/gnss/aidl/android/hardware/gnss/IAGnss.aidl b/gnss/aidl/android/hardware/gnss/IAGnss.aidl
new file mode 100644
index 0000000..3e256e2
--- /dev/null
+++ b/gnss/aidl/android/hardware/gnss/IAGnss.aidl
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.gnss;
+
+import android.hardware.gnss.IAGnssCallback;
+import android.hardware.gnss.IAGnssCallback.AGnssType;
+
+/** Extended interface for Assisted GNSS support. */
+@VintfStability
+interface IAGnss {
+ /** Access point name IP type */
+ @VintfStability
+ @Backing(type="int")
+ enum ApnIpType {
+ INVALID = 0,
+ IPV4 = 1,
+ IPV6 = 2,
+ IPV4V6 = 3,
+ }
+
+ /**
+ * Opens the AGNSS interface and provides the callback routines to the
+ * implementation of this interface.
+ *
+ * If setCallback is not called, this interface will not respond to any
+ * other method calls.
+ *
+ * @param callback Handle to the AGNSS status callback interface.
+ */
+ void setCallback(in IAGnssCallback callback);
+
+ /**
+ * Notifies that the AGNSS data connection has been closed.
+ */
+ void dataConnClosed();
+
+ /**
+ * Notifies that a data connection is not available for AGNSS.
+ */
+ void dataConnFailed();
+
+ /**
+ * Sets the hostname and port for the AGNSS server.
+ *
+ * @param type Specifies if SUPL or C2K.
+ * @param hostname Hostname of the AGNSS server.
+ * @param port Port number associated with the server.
+ */
+ void setServer(in AGnssType type, in String hostname, in int port);
+
+ /**
+ * Notifies GNSS that a data connection is available and sets the network handle,
+ * name of the APN, and its IP type to be used for SUPL connections.
+ *
+ * The HAL implementation must use the network handle to set the network for the
+ * SUPL connection sockets using the android_setsocknetwork function. This will ensure
+ * that there is a network path to the SUPL server. The network handle can also be used
+ * to get the IP address of SUPL FQDN using the android_getaddrinfofornetwork() function.
+ *
+ * @param networkHandle Handle representing the network for use with the NDK API.
+ * @param apn Access Point Name (follows regular APN naming convention).
+ * @param apnIpType Specifies IP type of APN.
+ */
+ void dataConnOpen(in long networkHandle, in String apn, in ApnIpType apnIpType);
+}
diff --git a/gnss/aidl/android/hardware/gnss/IAGnssCallback.aidl b/gnss/aidl/android/hardware/gnss/IAGnssCallback.aidl
new file mode 100644
index 0000000..7c25937
--- /dev/null
+++ b/gnss/aidl/android/hardware/gnss/IAGnssCallback.aidl
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.gnss;
+
+/** Callback structure for the AGNSS interface. */
+@VintfStability
+interface IAGnssCallback {
+ /** AGNSS service type */
+ @VintfStability
+ @Backing(type="int")
+ enum AGnssType {
+ SUPL = 1,
+ C2K = 2,
+ SUPL_EIMS = 3,
+ SUPL_IMS = 4,
+ }
+
+ /** AGNSS status value */
+ @VintfStability
+ @Backing(type="int")
+ enum AGnssStatusValue {
+ /** GNSS requests data connection for AGNSS. */
+ REQUEST_AGNSS_DATA_CONN = 1,
+
+ /** GNSS releases the AGNSS data connection. */
+ RELEASE_AGNSS_DATA_CONN = 2,
+
+ /** AGNSS data connection initiated */
+ AGNSS_DATA_CONNECTED = 3,
+
+ /** AGNSS data connection completed */
+ AGNSS_DATA_CONN_DONE = 4,
+
+ /** AGNSS data connection failed */
+ AGNSS_DATA_CONN_FAILED = 5,
+ }
+
+ /**
+ * Callback with AGNSS status information.
+ *
+ * The GNSS HAL implementation must use this method to request the framework to setup
+ * network connection for the specified AGNSS service and to update the connection
+ * status so that the framework can release the resources.
+ *
+ * @param type Type of AGNSS service.
+ * @parama status Status of the data connection.
+ */
+ void agnssStatusCb(in AGnssType type, in AGnssStatusValue status);
+}
diff --git a/gnss/aidl/android/hardware/gnss/IGnss.aidl b/gnss/aidl/android/hardware/gnss/IGnss.aidl
index 42cc496..91403ca 100644
--- a/gnss/aidl/android/hardware/gnss/IGnss.aidl
+++ b/gnss/aidl/android/hardware/gnss/IGnss.aidl
@@ -16,6 +16,7 @@
package android.hardware.gnss;
+import android.hardware.gnss.IAGnss;
import android.hardware.gnss.IGnssBatching;
import android.hardware.gnss.IGnssCallback;
import android.hardware.gnss.IGnssConfiguration;
@@ -75,7 +76,7 @@
/**
* This method returns the IGnssPsds interface.
*
- * @return Handle to the IGnssPsds interface.
+ * @return The IGnssPsds interface.
*/
@nullable IGnssPsds getExtensionPsds();
@@ -84,7 +85,7 @@
*
* This method must return non-null.
*
- * @return Handle to the IGnssConfiguration interface.
+ * @return The IGnssConfiguration interface.
*/
IGnssConfiguration getExtensionGnssConfiguration();
@@ -93,7 +94,7 @@
*
* This method must return non-null.
*
- * @return Handle to the IGnssMeasurementInterface interface.
+ * @return The IGnssMeasurementInterface interface.
*/
IGnssMeasurementInterface getExtensionGnssMeasurement();
@@ -102,28 +103,35 @@
*
* This method must return non-null.
*
- * @return Handle to the IGnssPowerIndication interface.
+ * @return The IGnssPowerIndication interface.
*/
IGnssPowerIndication getExtensionGnssPowerIndication();
/**
* This method returns the IGnssBatching interface.
*
- * @return Handle to the IGnssBatching interface.
+ * @return The IGnssBatching interface.
*/
@nullable IGnssBatching getExtensionGnssBatching();
/**
* This method returns the IGnssGeofence interface.
*
- * @return Handle to the IGnssGeofence interface.
+ * @return The IGnssGeofence interface.
*/
@nullable IGnssGeofence getExtensionGnssGeofence();
/**
* This method returns the IGnssNavigationMessageInterface.
*
- * @return Handle to the IGnssNavigationMessageInterface.
+ * @return The IGnssNavigationMessageInterface.
*/
@nullable IGnssNavigationMessageInterface getExtensionGnssNavigationMessage();
+
+ /**
+ * This method returns the IAGnss interface.
+ *
+ * @return The IAGnss interface.
+ */
+ IAGnss getExtensionAGnss();
}
diff --git a/gnss/aidl/default/AGnss.cpp b/gnss/aidl/default/AGnss.cpp
new file mode 100644
index 0000000..e8d5ef7
--- /dev/null
+++ b/gnss/aidl/default/AGnss.cpp
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2021 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 "AGnssAidl"
+
+#include "AGnss.h"
+#include <inttypes.h>
+#include <log/log.h>
+
+namespace aidl::android::hardware::gnss {
+
+std::shared_ptr<IAGnssCallback> AGnss::sCallback = nullptr;
+
+ndk::ScopedAStatus AGnss::setCallback(const std::shared_ptr<IAGnssCallback>& callback) {
+ ALOGD("AGnss::setCallback");
+ std::unique_lock<std::mutex> lock(mMutex);
+ sCallback = callback;
+ return ndk::ScopedAStatus::ok();
+}
+
+ndk::ScopedAStatus AGnss::setServer(AGnssType type, const std::string& hostname, int port) {
+ ALOGD("AGnss::setServer: type: %s, hostname: %s, port: %d", toString(type).c_str(),
+ hostname.c_str(), port);
+ return ndk::ScopedAStatus::ok();
+}
+
+ndk::ScopedAStatus AGnss::dataConnOpen(int64_t networkHandle, const std::string& apn,
+ ApnIpType apnIpType) {
+ ALOGD("AGnss::dataConnOpen: networkHandle:%" PRId64 ", apn: %s, apnIpType %s", networkHandle,
+ apn.c_str(), toString(apnIpType).c_str());
+ return ndk::ScopedAStatus::ok();
+}
+
+} // namespace aidl::android::hardware::gnss
diff --git a/gnss/aidl/default/AGnss.h b/gnss/aidl/default/AGnss.h
new file mode 100644
index 0000000..cd973e1
--- /dev/null
+++ b/gnss/aidl/default/AGnss.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2021 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 <aidl/android/hardware/gnss/BnAGnss.h>
+
+namespace aidl::android::hardware::gnss {
+
+using AGnssType = IAGnssCallback::AGnssType;
+
+struct AGnss : public BnAGnss {
+ public:
+ ndk::ScopedAStatus setCallback(const std::shared_ptr<IAGnssCallback>& callback) override;
+ ndk::ScopedAStatus dataConnClosed() override { return ndk::ScopedAStatus::ok(); }
+ ndk::ScopedAStatus dataConnFailed() override { return ndk::ScopedAStatus::ok(); }
+ ndk::ScopedAStatus setServer(AGnssType type, const std::string& hostname, int port) override;
+ ndk::ScopedAStatus dataConnOpen(int64_t networkHandle, const std::string& apn,
+ ApnIpType apnIpType) override;
+
+ private:
+ // Synchronization lock for sCallback
+ mutable std::mutex mMutex;
+ // Guarded by mMutex
+ static std::shared_ptr<IAGnssCallback> sCallback;
+};
+
+} // namespace aidl::android::hardware::gnss
diff --git a/gnss/aidl/default/Android.bp b/gnss/aidl/default/Android.bp
index b6df895..1236714 100644
--- a/gnss/aidl/default/Android.bp
+++ b/gnss/aidl/default/Android.bp
@@ -55,6 +55,7 @@
"android.hardware.gnss-V2-ndk",
],
srcs: [
+ "AGnss.cpp",
"Gnss.cpp",
"GnssBatching.cpp",
"GnssGeofence.cpp",
diff --git a/gnss/aidl/default/Gnss.cpp b/gnss/aidl/default/Gnss.cpp
index 8d58a20..0e3cdd3 100644
--- a/gnss/aidl/default/Gnss.cpp
+++ b/gnss/aidl/default/Gnss.cpp
@@ -18,6 +18,7 @@
#include "Gnss.h"
#include <log/log.h>
+#include "AGnss.h"
#include "GnssBatching.h"
#include "GnssConfiguration.h"
#include "GnssGeofence.h"
@@ -56,6 +57,12 @@
return ndk::ScopedAStatus::ok();
}
+ndk::ScopedAStatus Gnss::getExtensionAGnss(std::shared_ptr<IAGnss>* iAGnss) {
+ ALOGD("Gnss::getExtensionAGnss");
+ *iAGnss = SharedRefBase::make<AGnss>();
+ return ndk::ScopedAStatus::ok();
+}
+
ndk::ScopedAStatus Gnss::getExtensionPsds(std::shared_ptr<IGnssPsds>* iGnssPsds) {
ALOGD("Gnss::getExtensionPsds");
*iGnssPsds = SharedRefBase::make<GnssPsds>();
diff --git a/gnss/aidl/default/Gnss.h b/gnss/aidl/default/Gnss.h
index 128a6c1..4feb781 100644
--- a/gnss/aidl/default/Gnss.h
+++ b/gnss/aidl/default/Gnss.h
@@ -16,6 +16,7 @@
#pragma once
+#include <aidl/android/hardware/gnss/BnAGnss.h>
#include <aidl/android/hardware/gnss/BnGnss.h>
#include <aidl/android/hardware/gnss/BnGnssBatching.h>
#include <aidl/android/hardware/gnss/BnGnssConfiguration.h>
@@ -44,6 +45,7 @@
std::shared_ptr<IGnssGeofence>* iGnssGeofence) override;
ndk::ScopedAStatus getExtensionGnssNavigationMessage(
std::shared_ptr<IGnssNavigationMessageInterface>* iGnssNavigationMessage) override;
+ ndk::ScopedAStatus getExtensionAGnss(std::shared_ptr<IAGnss>* iAGnss) override;
std::shared_ptr<GnssConfiguration> mGnssConfiguration;
std::shared_ptr<GnssPowerIndication> mGnssPowerIndication;
diff --git a/gnss/aidl/vts/AGnssCallbackAidl.cpp b/gnss/aidl/vts/AGnssCallbackAidl.cpp
new file mode 100644
index 0000000..3327835
--- /dev/null
+++ b/gnss/aidl/vts/AGnssCallbackAidl.cpp
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2021 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 "AGnssCallbackAidl.h"
+#include <log/log.h>
+
+android::binder::Status AGnssCallbackAidl::agnssStatusCb(const AGnssType type,
+ const AGnssStatusValue status) {
+ ALOGI("agnssStatusCb type %d status %d", type, status);
+ return android::binder::Status::ok();
+}
diff --git a/gnss/aidl/vts/AGnssCallbackAidl.h b/gnss/aidl/vts/AGnssCallbackAidl.h
new file mode 100644
index 0000000..6173e85
--- /dev/null
+++ b/gnss/aidl/vts/AGnssCallbackAidl.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2021 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 <android/hardware/gnss/BnAGnssCallback.h>
+
+using AGnssType = android::hardware::gnss::IAGnssCallback::AGnssType;
+using AGnssStatusValue = android::hardware::gnss::IAGnssCallback::AGnssStatusValue;
+
+/** Implementation for IAGnssCallback. */
+class AGnssCallbackAidl : public android::hardware::gnss::BnAGnssCallback {
+ public:
+ AGnssCallbackAidl(){};
+ ~AGnssCallbackAidl(){};
+ android::binder::Status agnssStatusCb(const AGnssType type,
+ const AGnssStatusValue status) override;
+};
diff --git a/gnss/aidl/vts/Android.bp b/gnss/aidl/vts/Android.bp
index 4d81519..041d579 100644
--- a/gnss/aidl/vts/Android.bp
+++ b/gnss/aidl/vts/Android.bp
@@ -30,6 +30,7 @@
srcs: [
"gnss_hal_test.cpp",
"gnss_hal_test_cases.cpp",
+ "AGnssCallbackAidl.cpp",
"GnssBatchingCallback.cpp",
"GnssCallbackAidl.cpp",
"GnssGeofenceCallback.cpp",
diff --git a/gnss/aidl/vts/gnss_hal_test_cases.cpp b/gnss/aidl/vts/gnss_hal_test_cases.cpp
index 830922c..aac59db 100644
--- a/gnss/aidl/vts/gnss_hal_test_cases.cpp
+++ b/gnss/aidl/vts/gnss_hal_test_cases.cpp
@@ -16,12 +16,14 @@
#define LOG_TAG "GnssHalTestCases"
+#include <android/hardware/gnss/IAGnss.h>
#include <android/hardware/gnss/IGnss.h>
#include <android/hardware/gnss/IGnssBatching.h>
#include <android/hardware/gnss/IGnssMeasurementCallback.h>
#include <android/hardware/gnss/IGnssMeasurementInterface.h>
#include <android/hardware/gnss/IGnssPowerIndication.h>
#include <android/hardware/gnss/IGnssPsds.h>
+#include "AGnssCallbackAidl.h"
#include "GnssBatchingCallback.h"
#include "GnssGeofenceCallback.h"
#include "GnssMeasurementCallbackAidl.h"
@@ -36,6 +38,7 @@
using android::hardware::gnss::GnssData;
using android::hardware::gnss::GnssMeasurement;
using android::hardware::gnss::GnssPowerStats;
+using android::hardware::gnss::IAGnss;
using android::hardware::gnss::IGnss;
using android::hardware::gnss::IGnssBatching;
using android::hardware::gnss::IGnssBatchingCallback;
@@ -793,3 +796,27 @@
ASSERT_TRUE(status.isOk());
}
}
+
+/*
+ * TestAGnssExtension:
+ * 1. Gets the IAGnss extension.
+ * 2. Sets AGnssCallback.
+ * 3. Sets SUPL server host/port.
+ */
+TEST_P(GnssHalTest, TestAGnssExtension) {
+ if (aidl_gnss_hal_->getInterfaceVersion() == 1) {
+ return;
+ }
+ sp<IAGnss> iAGnss;
+ auto status = aidl_gnss_hal_->getExtensionAGnss(&iAGnss);
+ ASSERT_TRUE(status.isOk());
+ ASSERT_TRUE(iAGnss != nullptr);
+
+ auto agnssCallback = sp<AGnssCallbackAidl>::make();
+ status = iAGnss->setCallback(agnssCallback);
+ ASSERT_TRUE(status.isOk());
+
+ // Set SUPL server host/port
+ status = iAGnss->setServer(AGnssType::SUPL, String16("supl.google.com"), 7275);
+ ASSERT_TRUE(status.isOk());
+}
diff --git a/graphics/common/aidl/aidl_api/android.hardware.graphics.common/current/android/hardware/graphics/common/PixelFormat.aidl b/graphics/common/aidl/aidl_api/android.hardware.graphics.common/current/android/hardware/graphics/common/PixelFormat.aidl
index 04a863b..512fecb 100644
--- a/graphics/common/aidl/aidl_api/android.hardware.graphics.common/current/android/hardware/graphics/common/PixelFormat.aidl
+++ b/graphics/common/aidl/aidl_api/android.hardware.graphics.common/current/android/hardware/graphics/common/PixelFormat.aidl
@@ -63,4 +63,5 @@
STENCIL_8 = 53,
YCBCR_P010 = 54,
HSV_888 = 55,
+ R_8 = 56,
}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/LayerRequest.aidl b/graphics/common/aidl/aidl_api/android.hardware.graphics.common/current/android/hardware/graphics/common/Point.aidl
similarity index 92%
copy from graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/LayerRequest.aidl
copy to graphics/common/aidl/aidl_api/android.hardware.graphics.common/current/android/hardware/graphics/common/Point.aidl
index cfafc50..3722803 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/LayerRequest.aidl
+++ b/graphics/common/aidl/aidl_api/android.hardware.graphics.common/current/android/hardware/graphics/common/Point.aidl
@@ -31,8 +31,9 @@
// 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.composer3;
-@Backing(type="int") @VintfStability
-enum LayerRequest {
- CLEAR_CLIENT_TARGET = 1,
+package android.hardware.graphics.common;
+@VintfStability
+parcelable Point {
+ int x;
+ int y;
}
diff --git a/graphics/common/aidl/android/hardware/graphics/common/PixelFormat.aidl b/graphics/common/aidl/android/hardware/graphics/common/PixelFormat.aidl
index eb87f8d..4e891f6 100644
--- a/graphics/common/aidl/android/hardware/graphics/common/PixelFormat.aidl
+++ b/graphics/common/aidl/android/hardware/graphics/common/PixelFormat.aidl
@@ -498,4 +498,11 @@
* interpretation is defined by the dataspace.
*/
HSV_888 = 0x37,
+
+ /**
+ * 8 bit format with a single 8-bit component.
+ *
+ * The component values are unsigned normalized to the range [0, 1].
+ */
+ R_8 = 0x38,
}
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/LayerRequest.aidl b/graphics/common/aidl/android/hardware/graphics/common/Point.aidl
similarity index 64%
copy from graphics/composer/aidl/android/hardware/graphics/composer3/LayerRequest.aidl
copy to graphics/common/aidl/android/hardware/graphics/common/Point.aidl
index 10de558..b3ede44 100644
--- a/graphics/composer/aidl/android/hardware/graphics/composer3/LayerRequest.aidl
+++ b/graphics/common/aidl/android/hardware/graphics/common/Point.aidl
@@ -14,18 +14,14 @@
* limitations under the License.
*/
-package android.hardware.graphics.composer3;
+package android.hardware.graphics.common;
/**
- * Layer requests returned from getDisplayRequests.
+ * General purpose definition of a point.
*/
+
@VintfStability
-@Backing(type="int")
-enum LayerRequest {
- /**
- * The client must clear its target with transparent pixels where
- * this layer would be. The client may ignore this request if the
- * layer must be blended.
- */
- CLEAR_CLIENT_TARGET = 1 << 0,
+parcelable Point {
+ int x;
+ int y;
}
diff --git a/graphics/composer/aidl/Android.bp b/graphics/composer/aidl/Android.bp
index e33c653..5f5b54e 100644
--- a/graphics/composer/aidl/Android.bp
+++ b/graphics/composer/aidl/Android.bp
@@ -31,12 +31,13 @@
enabled: true,
support_system_process: true,
},
- srcs: ["android/hardware/graphics/composer3/*.aidl"],
+ srcs: [
+ "android/hardware/graphics/composer3/*.aidl",
+ ],
stability: "vintf",
imports: [
"android.hardware.graphics.common-V3",
"android.hardware.common-V2",
- "android.hardware.common.fmq-V1",
],
backend: {
cpp: {
@@ -73,6 +74,7 @@
vendor_available: true,
shared_libs: [
"android.hardware.graphics.composer3-V1-ndk",
+ "android.hardware.common-V2-ndk",
"libbase",
"libfmq",
"libsync",
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/BlendMode.aidl b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/Buffer.aidl
similarity index 92%
copy from graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/BlendMode.aidl
copy to graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/Buffer.aidl
index a522d53..a33ad23 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/BlendMode.aidl
+++ b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/Buffer.aidl
@@ -32,10 +32,9 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.graphics.composer3;
-@Backing(type="int") @VintfStability
-enum BlendMode {
- INVALID = 0,
- NONE = 1,
- PREMULTIPLIED = 2,
- COVERAGE = 3,
+@VintfStability
+parcelable Buffer {
+ int slot;
+ @nullable android.hardware.common.NativeHandle handle;
+ @nullable ParcelFileDescriptor fence;
}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ChangedCompositionLayer.aidl
similarity index 93%
copy from graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
copy to graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ChangedCompositionLayer.aidl
index 41a1afe..7e47ba8 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
+++ b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ChangedCompositionLayer.aidl
@@ -33,8 +33,7 @@
package android.hardware.graphics.composer3;
@VintfStability
-parcelable ExecuteCommandsStatus {
- boolean queueChanged;
- int length;
- android.hardware.common.NativeHandle[] handles;
+parcelable ChangedCompositionLayer {
+ long layer;
+ android.hardware.graphics.composer3.Composition composition;
}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ChangedCompositionTypes.aidl
similarity index 93%
rename from graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
rename to graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ChangedCompositionTypes.aidl
index 41a1afe..9a5ca97 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
+++ b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ChangedCompositionTypes.aidl
@@ -33,8 +33,7 @@
package android.hardware.graphics.composer3;
@VintfStability
-parcelable ExecuteCommandsStatus {
- boolean queueChanged;
- int length;
- android.hardware.common.NativeHandle[] handles;
+parcelable ChangedCompositionTypes {
+ long display;
+ android.hardware.graphics.composer3.ChangedCompositionLayer[] layers;
}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ClientTarget.aidl
similarity index 90%
copy from graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
copy to graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ClientTarget.aidl
index 41a1afe..7632707 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
+++ b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ClientTarget.aidl
@@ -33,8 +33,8 @@
package android.hardware.graphics.composer3;
@VintfStability
-parcelable ExecuteCommandsStatus {
- boolean queueChanged;
- int length;
- android.hardware.common.NativeHandle[] handles;
+parcelable ClientTarget {
+ android.hardware.graphics.composer3.Buffer buffer;
+ android.hardware.graphics.common.Dataspace dataspace;
+ android.hardware.graphics.common.Rect[] damage;
}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ClientTargetPropertyWithNits.aidl
similarity index 91%
copy from graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
copy to graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ClientTargetPropertyWithNits.aidl
index 41a1afe..f0fb22e 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
+++ b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ClientTargetPropertyWithNits.aidl
@@ -33,8 +33,8 @@
package android.hardware.graphics.composer3;
@VintfStability
-parcelable ExecuteCommandsStatus {
- boolean queueChanged;
- int length;
- android.hardware.common.NativeHandle[] handles;
+parcelable ClientTargetPropertyWithNits {
+ long display;
+ android.hardware.graphics.composer3.ClientTargetProperty clientTargetProperty;
+ float whitePointNits;
}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ColorTransformPayload.aidl
similarity index 93%
copy from graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
copy to graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ColorTransformPayload.aidl
index 41a1afe..df07c9c 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
+++ b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ColorTransformPayload.aidl
@@ -33,8 +33,7 @@
package android.hardware.graphics.composer3;
@VintfStability
-parcelable ExecuteCommandsStatus {
- boolean queueChanged;
- int length;
- android.hardware.common.NativeHandle[] handles;
+parcelable ColorTransformPayload {
+ float[] matrix;
+ android.hardware.graphics.common.ColorTransform hint;
}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/Command.aidl b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/Command.aidl
deleted file mode 100644
index e19105d..0000000
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/Command.aidl
+++ /dev/null
@@ -1,76 +0,0 @@
-/**
- * Copyright (c) 2021, 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.composer3;
-@Backing(type="int") @VintfStability
-enum Command {
- LENGTH_MASK = 65535,
- OPCODE_SHIFT = 16,
- OPCODE_MASK = -65536,
- SELECT_DISPLAY = 0,
- SELECT_LAYER = 65536,
- SET_ERROR = 16777216,
- SET_CHANGED_COMPOSITION_TYPES = 16842752,
- SET_DISPLAY_REQUESTS = 16908288,
- SET_PRESENT_FENCE = 16973824,
- SET_RELEASE_FENCES = 17039360,
- SET_COLOR_TRANSFORM = 33554432,
- SET_CLIENT_TARGET = 33619968,
- SET_OUTPUT_BUFFER = 33685504,
- VALIDATE_DISPLAY = 33751040,
- ACCEPT_DISPLAY_CHANGES = 33816576,
- PRESENT_DISPLAY = 33882112,
- PRESENT_OR_VALIDATE_DISPLAY = 33947648,
- SET_LAYER_CURSOR_POSITION = 50331648,
- SET_LAYER_BUFFER = 50397184,
- SET_LAYER_SURFACE_DAMAGE = 50462720,
- SET_LAYER_BLEND_MODE = 67108864,
- SET_LAYER_COLOR = 67174400,
- SET_LAYER_COMPOSITION_TYPE = 67239936,
- SET_LAYER_DATASPACE = 67305472,
- SET_LAYER_DISPLAY_FRAME = 67371008,
- SET_LAYER_PLANE_ALPHA = 67436544,
- SET_LAYER_SIDEBAND_STREAM = 67502080,
- SET_LAYER_SOURCE_CROP = 67567616,
- SET_LAYER_TRANSFORM = 67633152,
- SET_LAYER_VISIBLE_REGION = 67698688,
- SET_LAYER_Z_ORDER = 67764224,
- SET_PRESENT_OR_VALIDATE_DISPLAY_RESULT = 67829760,
- SET_LAYER_PER_FRAME_METADATA = 50528256,
- SET_LAYER_FLOAT_COLOR = 67895296,
- SET_LAYER_COLOR_TRANSFORM = 67960832,
- SET_LAYER_PER_FRAME_METADATA_BLOBS = 50593792,
- SET_CLIENT_TARGET_PROPERTY = 17104896,
- SET_LAYER_GENERIC_METADATA = 68026368,
- SET_LAYER_WHITE_POINT_NITS = 50659328,
-}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/LayerRequest.aidl b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/CommandError.aidl
similarity index 95%
copy from graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/LayerRequest.aidl
copy to graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/CommandError.aidl
index cfafc50..103bfdc 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/LayerRequest.aidl
+++ b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/CommandError.aidl
@@ -32,7 +32,8 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.graphics.composer3;
-@Backing(type="int") @VintfStability
-enum LayerRequest {
- CLEAR_CLIENT_TARGET = 1,
+@VintfStability
+parcelable CommandError {
+ int commandIndex;
+ int errorCode;
}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/CommandResultPayload.aidl
similarity index 76%
copy from graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
copy to graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/CommandResultPayload.aidl
index 41a1afe..ebbb31e 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
+++ b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/CommandResultPayload.aidl
@@ -33,8 +33,12 @@
package android.hardware.graphics.composer3;
@VintfStability
-parcelable ExecuteCommandsStatus {
- boolean queueChanged;
- int length;
- android.hardware.common.NativeHandle[] handles;
+union CommandResultPayload {
+ android.hardware.graphics.composer3.CommandError error;
+ android.hardware.graphics.composer3.ChangedCompositionTypes changedCompositionTypes;
+ android.hardware.graphics.composer3.DisplayRequest displayRequest;
+ android.hardware.graphics.composer3.PresentFence presentFence;
+ android.hardware.graphics.composer3.ReleaseFences releaseFences;
+ android.hardware.graphics.composer3.PresentOrValidate presentOrValidateResult;
+ android.hardware.graphics.composer3.ClientTargetPropertyWithNits clientTargetProperty;
}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/DisplayCapability.aidl b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/DisplayCapability.aidl
index 0bcd870..9f5342e 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/DisplayCapability.aidl
+++ b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/DisplayCapability.aidl
@@ -40,4 +40,5 @@
BRIGHTNESS = 3,
PROTECTED_CONTENTS = 4,
AUTO_LOW_LATENCY_MODE = 5,
+ SUSPEND = 6,
}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/BlendMode.aidl b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/DisplayCommand.aidl
similarity index 78%
copy from graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/BlendMode.aidl
copy to graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/DisplayCommand.aidl
index a522d53..2f5d00f 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/BlendMode.aidl
+++ b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/DisplayCommand.aidl
@@ -32,10 +32,15 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.graphics.composer3;
-@Backing(type="int") @VintfStability
-enum BlendMode {
- INVALID = 0,
- NONE = 1,
- PREMULTIPLIED = 2,
- COVERAGE = 3,
+@VintfStability
+parcelable DisplayCommand {
+ long display;
+ android.hardware.graphics.composer3.LayerCommand[] layers;
+ @nullable android.hardware.graphics.composer3.ColorTransformPayload colorTransform;
+ @nullable android.hardware.graphics.composer3.ClientTarget clientTarget;
+ @nullable android.hardware.graphics.composer3.Buffer virtualDisplayOutputBuffer;
+ boolean validateDisplay;
+ boolean acceptDisplayChanges;
+ boolean presentDisplay;
+ boolean presentOrValidateDisplay;
}
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 26e7d97..13462ce 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
@@ -32,8 +32,17 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.graphics.composer3;
-@Backing(type="int") @VintfStability
-enum DisplayRequest {
- FLIP_CLIENT_TARGET = 1,
- WRITE_CLIENT_TARGET_TO_OUTPUT = 2,
+@VintfStability
+parcelable DisplayRequest {
+ long display;
+ int mask;
+ android.hardware.graphics.composer3.DisplayRequest.LayerRequest[] layerRequests;
+ const int FLIP_CLIENT_TARGET = 1;
+ const int WRITE_CLIENT_TARGET_TO_OUTPUT = 2;
+ @VintfStability
+ parcelable LayerRequest {
+ long layer;
+ int mask;
+ const int CLEAR_CLIENT_TARGET = 1;
+ }
}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/GenericMetadata.aidl
similarity index 93%
copy from graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
copy to graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/GenericMetadata.aidl
index 41a1afe..c18529b 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
+++ b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/GenericMetadata.aidl
@@ -33,8 +33,7 @@
package android.hardware.graphics.composer3;
@VintfStability
-parcelable ExecuteCommandsStatus {
- boolean queueChanged;
- int length;
- android.hardware.common.NativeHandle[] handles;
+parcelable GenericMetadata {
+ android.hardware.graphics.composer3.LayerGenericMetadataKey key;
+ byte[] value;
}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/IComposerClient.aidl b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/IComposerClient.aidl
index d7cab2b..2bdbc9f 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/IComposerClient.aidl
+++ b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/IComposerClient.aidl
@@ -38,12 +38,11 @@
android.hardware.graphics.composer3.VirtualDisplay createVirtualDisplay(int width, int height, android.hardware.graphics.common.PixelFormat formatHint, int outputBufferSlotCount);
void destroyLayer(long display, long layer);
void destroyVirtualDisplay(long display);
- android.hardware.graphics.composer3.ExecuteCommandsStatus executeCommands(int inLength, in android.hardware.common.NativeHandle[] inHandles);
+ android.hardware.graphics.composer3.CommandResultPayload[] executeCommands(in android.hardware.graphics.composer3.DisplayCommand[] commands);
int getActiveConfig(long display);
android.hardware.graphics.composer3.ColorMode[] getColorModes(long display);
float[] getDataspaceSaturationMatrix(android.hardware.graphics.common.Dataspace dataspace);
int getDisplayAttribute(long display, int config, android.hardware.graphics.composer3.DisplayAttribute attribute);
- boolean getDisplayBrightnessSupport(long display);
android.hardware.graphics.composer3.DisplayCapability[] getDisplayCapabilities(long display);
int[] getDisplayConfigs(long display);
android.hardware.graphics.composer3.DisplayConnectionType getDisplayConnectionType(long display);
@@ -52,11 +51,9 @@
int getDisplayVsyncPeriod(long display);
android.hardware.graphics.composer3.DisplayContentSample getDisplayedContentSample(long display, long maxFrames, long timestamp);
android.hardware.graphics.composer3.DisplayContentSamplingAttributes getDisplayedContentSamplingAttributes(long display);
- boolean getDozeSupport(long display);
android.hardware.graphics.composer3.HdrCapabilities getHdrCapabilities(long display);
android.hardware.graphics.composer3.LayerGenericMetadataKey[] getLayerGenericMetadataKeys();
int getMaxVirtualDisplayCount();
- android.hardware.common.fmq.MQDescriptor<int,android.hardware.common.fmq.SynchronizedReadWrite> getOutputCommandQueue();
android.hardware.graphics.composer3.PerFrameMetadataKey[] getPerFrameMetadataKeys(long display);
android.hardware.graphics.composer3.ReadbackBufferAttributes getReadbackBufferAttributes(long display);
ParcelFileDescriptor getReadbackBufferFence(long display);
@@ -71,7 +68,6 @@
void setContentType(long display, android.hardware.graphics.composer3.ContentType type);
void setDisplayBrightness(long display, float brightness);
void setDisplayedContentSamplingEnabled(long display, boolean enable, android.hardware.graphics.composer3.FormatColorComponent componentMask, long maxFrames);
- void setInputCommandQueue(in android.hardware.common.fmq.MQDescriptor<int,android.hardware.common.fmq.SynchronizedReadWrite> descriptor);
void setPowerMode(long display, android.hardware.graphics.composer3.PowerMode mode);
void setReadbackBuffer(long display, in android.hardware.common.NativeHandle buffer, in ParcelFileDescriptor releaseFence);
void setVsyncEnabled(long display, boolean enabled);
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/LayerCommand.aidl b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/LayerCommand.aidl
new file mode 100644
index 0000000..bad72fc
--- /dev/null
+++ b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/LayerCommand.aidl
@@ -0,0 +1,58 @@
+/**
+ * Copyright (c) 2021, 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.composer3;
+@VintfStability
+parcelable LayerCommand {
+ long layer;
+ @nullable android.hardware.graphics.common.Point cursorPosition;
+ @nullable android.hardware.graphics.composer3.Buffer buffer;
+ @nullable android.hardware.graphics.common.Rect[] damage;
+ @nullable android.hardware.graphics.composer3.ParcelableBlendMode blendMode;
+ @nullable android.hardware.graphics.composer3.Color color;
+ @nullable android.hardware.graphics.composer3.FloatColor floatColor;
+ @nullable android.hardware.graphics.composer3.ParcelableComposition composition;
+ @nullable android.hardware.graphics.composer3.ParcelableDataspace dataspace;
+ @nullable android.hardware.graphics.common.Rect displayFrame;
+ @nullable android.hardware.graphics.composer3.PlaneAlpha planeAlpha;
+ @nullable android.hardware.common.NativeHandle sidebandStream;
+ @nullable android.hardware.graphics.common.FRect sourceCrop;
+ @nullable android.hardware.graphics.composer3.ParcelableTransform transform;
+ @nullable android.hardware.graphics.common.Rect[] visibleRegion;
+ @nullable android.hardware.graphics.composer3.ZOrder z;
+ @nullable float[] colorTransform;
+ @nullable android.hardware.graphics.composer3.WhitePointNits whitePointNits;
+ @nullable android.hardware.graphics.composer3.GenericMetadata genericMetadata;
+ @nullable android.hardware.graphics.composer3.PerFrameMetadata[] perFrameMetadata;
+ @nullable android.hardware.graphics.composer3.PerFrameMetadataBlob[] perFrameMetadataBlob;
+}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/LayerRequest.aidl b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ParcelableBlendMode.aidl
similarity index 94%
copy from graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/LayerRequest.aidl
copy to graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ParcelableBlendMode.aidl
index cfafc50..f1fee5f 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/LayerRequest.aidl
+++ b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ParcelableBlendMode.aidl
@@ -32,7 +32,7 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.graphics.composer3;
-@Backing(type="int") @VintfStability
-enum LayerRequest {
- CLEAR_CLIENT_TARGET = 1,
+@VintfStability
+parcelable ParcelableBlendMode {
+ android.hardware.graphics.common.BlendMode blendMode;
}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/BlendMode.aidl b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ParcelableComposition.aidl
similarity index 93%
rename from graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/BlendMode.aidl
rename to graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ParcelableComposition.aidl
index a522d53..98fbb66 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/BlendMode.aidl
+++ b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ParcelableComposition.aidl
@@ -32,10 +32,7 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.graphics.composer3;
-@Backing(type="int") @VintfStability
-enum BlendMode {
- INVALID = 0,
- NONE = 1,
- PREMULTIPLIED = 2,
- COVERAGE = 3,
+@VintfStability
+parcelable ParcelableComposition {
+ android.hardware.graphics.composer3.Composition composition;
}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/LayerRequest.aidl b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ParcelableDataspace.aidl
similarity index 94%
copy from graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/LayerRequest.aidl
copy to graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ParcelableDataspace.aidl
index cfafc50..76ecf85 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/LayerRequest.aidl
+++ b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ParcelableDataspace.aidl
@@ -32,7 +32,7 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.graphics.composer3;
-@Backing(type="int") @VintfStability
-enum LayerRequest {
- CLEAR_CLIENT_TARGET = 1,
+@VintfStability
+parcelable ParcelableDataspace {
+ android.hardware.graphics.common.Dataspace dataspace;
}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/LayerRequest.aidl b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ParcelableTransform.aidl
similarity index 94%
copy from graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/LayerRequest.aidl
copy to graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ParcelableTransform.aidl
index cfafc50..b673656 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/LayerRequest.aidl
+++ b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ParcelableTransform.aidl
@@ -32,7 +32,7 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.graphics.composer3;
-@Backing(type="int") @VintfStability
-enum LayerRequest {
- CLEAR_CLIENT_TARGET = 1,
+@VintfStability
+parcelable ParcelableTransform {
+ android.hardware.graphics.common.Transform transform;
}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/LayerRequest.aidl b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/PlaneAlpha.aidl
similarity index 95%
rename from graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/LayerRequest.aidl
rename to graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/PlaneAlpha.aidl
index cfafc50..c48c2a8 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/LayerRequest.aidl
+++ b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/PlaneAlpha.aidl
@@ -32,7 +32,7 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.graphics.composer3;
-@Backing(type="int") @VintfStability
-enum LayerRequest {
- CLEAR_CLIENT_TARGET = 1,
+@VintfStability
+parcelable PlaneAlpha {
+ float alpha;
}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/LayerRequest.aidl b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/PresentFence.aidl
similarity index 94%
copy from graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/LayerRequest.aidl
copy to graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/PresentFence.aidl
index cfafc50..3bb09cd 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/LayerRequest.aidl
+++ b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/PresentFence.aidl
@@ -32,7 +32,8 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.graphics.composer3;
-@Backing(type="int") @VintfStability
-enum LayerRequest {
- CLEAR_CLIENT_TARGET = 1,
+@VintfStability
+parcelable PresentFence {
+ long display;
+ ParcelFileDescriptor fence;
}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/BlendMode.aidl b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/PresentOrValidate.aidl
similarity index 89%
copy from graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/BlendMode.aidl
copy to graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/PresentOrValidate.aidl
index a522d53..3514e53 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/BlendMode.aidl
+++ b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/PresentOrValidate.aidl
@@ -32,10 +32,13 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.graphics.composer3;
-@Backing(type="int") @VintfStability
-enum BlendMode {
- INVALID = 0,
- NONE = 1,
- PREMULTIPLIED = 2,
- COVERAGE = 3,
+@VintfStability
+parcelable PresentOrValidate {
+ long display;
+ android.hardware.graphics.composer3.PresentOrValidate.Result result;
+ @VintfStability
+ enum Result {
+ Presented = 0,
+ Validated = 1,
+ }
}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ReleaseFences.aidl
similarity index 89%
copy from graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
copy to graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ReleaseFences.aidl
index 41a1afe..d623661 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
+++ b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ReleaseFences.aidl
@@ -33,8 +33,12 @@
package android.hardware.graphics.composer3;
@VintfStability
-parcelable ExecuteCommandsStatus {
- boolean queueChanged;
- int length;
- android.hardware.common.NativeHandle[] handles;
+parcelable ReleaseFences {
+ long display;
+ android.hardware.graphics.composer3.ReleaseFences.Layer[] layers;
+ @VintfStability
+ parcelable Layer {
+ long layer;
+ ParcelFileDescriptor fence;
+ }
}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/LayerRequest.aidl b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/WhitePointNits.aidl
similarity index 95%
copy from graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/LayerRequest.aidl
copy to graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/WhitePointNits.aidl
index cfafc50..c3925d2 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/LayerRequest.aidl
+++ b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/WhitePointNits.aidl
@@ -32,7 +32,7 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.graphics.composer3;
-@Backing(type="int") @VintfStability
-enum LayerRequest {
- CLEAR_CLIENT_TARGET = 1,
+@VintfStability
+parcelable WhitePointNits {
+ float nits;
}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/LayerRequest.aidl b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ZOrder.aidl
similarity index 95%
copy from graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/LayerRequest.aidl
copy to graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ZOrder.aidl
index cfafc50..ea96ea3 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/LayerRequest.aidl
+++ b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ZOrder.aidl
@@ -32,7 +32,7 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.graphics.composer3;
-@Backing(type="int") @VintfStability
-enum LayerRequest {
- CLEAR_CLIENT_TARGET = 1,
+@VintfStability
+parcelable ZOrder {
+ int z;
}
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/Buffer.aidl b/graphics/composer/aidl/android/hardware/graphics/composer3/Buffer.aidl
new file mode 100644
index 0000000..415a9b6
--- /dev/null
+++ b/graphics/composer/aidl/android/hardware/graphics/composer3/Buffer.aidl
@@ -0,0 +1,44 @@
+/**
+ * Copyright (c) 2021, 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.composer3;
+
+import android.hardware.common.NativeHandle;
+
+@VintfStability
+parcelable Buffer {
+ /**
+ * Buffer slot in the range [0, bufferSlotCount) where bufferSlotCount is
+ * the parameter used when the layer was created.
+ * @see IComposer.createLayer.
+ * The slot is used as a buffer caching mechanism. When the Buffer.handle
+ * is null, the implementation uses the previous buffer associated with this
+ * slot.
+ */
+ int slot;
+
+ /**
+ * Buffer Handle. Can be null if this is the same buffer that was sent
+ * previously on this slot.
+ */
+ @nullable NativeHandle handle;
+
+ /**
+ * Buffer fence that represents when it is safe to access the buffer.
+ * A null fence indicates that the buffer can be accessed immediately.
+ */
+ @nullable ParcelFileDescriptor fence;
+}
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/LayerRequest.aidl b/graphics/composer/aidl/android/hardware/graphics/composer3/ChangedCompositionLayer.aidl
similarity index 69%
copy from graphics/composer/aidl/android/hardware/graphics/composer3/LayerRequest.aidl
copy to graphics/composer/aidl/android/hardware/graphics/composer3/ChangedCompositionLayer.aidl
index 10de558..fb25163 100644
--- a/graphics/composer/aidl/android/hardware/graphics/composer3/LayerRequest.aidl
+++ b/graphics/composer/aidl/android/hardware/graphics/composer3/ChangedCompositionLayer.aidl
@@ -16,16 +16,18 @@
package android.hardware.graphics.composer3;
-/**
- * Layer requests returned from getDisplayRequests.
- */
+import android.hardware.graphics.composer3.Composition;
+
@VintfStability
-@Backing(type="int")
-enum LayerRequest {
+parcelable ChangedCompositionLayer {
/**
- * The client must clear its target with transparent pixels where
- * this layer would be. The client may ignore this request if the
- * layer must be blended.
+ * The layer which this commands refers to.
+ * @see IComposer.createLayer
*/
- CLEAR_CLIENT_TARGET = 1 << 0,
+ long layer;
+
+ /**
+ * The new composition type.
+ */
+ Composition composition;
}
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/BlendMode.aidl b/graphics/composer/aidl/android/hardware/graphics/composer3/ChangedCompositionTypes.aidl
similarity index 66%
copy from graphics/composer/aidl/android/hardware/graphics/composer3/BlendMode.aidl
copy to graphics/composer/aidl/android/hardware/graphics/composer3/ChangedCompositionTypes.aidl
index c6fd063..ddd45b7 100644
--- a/graphics/composer/aidl/android/hardware/graphics/composer3/BlendMode.aidl
+++ b/graphics/composer/aidl/android/hardware/graphics/composer3/ChangedCompositionTypes.aidl
@@ -16,23 +16,19 @@
package android.hardware.graphics.composer3;
-/**
- * Blend modes, settable per layer.
- */
+import android.hardware.graphics.composer3.ChangedCompositionLayer;
+import android.hardware.graphics.composer3.Composition;
+
@VintfStability
-@Backing(type="int")
-enum BlendMode {
- INVALID = 0,
+parcelable ChangedCompositionTypes {
/**
- * colorOut = colorSrc
+ * The display which this commands refers to.
+ * @see IComposer.createDisplay
*/
- NONE = 1,
+ long display;
+
/**
- * colorOut = colorSrc + colorDst * (1 - alphaSrc)
+ * Indicates which layers has composition changes
*/
- PREMULTIPLIED = 2,
- /**
- * colorOut = colorSrc * alphaSrc + colorDst * (1 - alphaSrc)
- */
- COVERAGE = 3,
+ ChangedCompositionLayer[] layers;
}
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/BlendMode.aidl b/graphics/composer/aidl/android/hardware/graphics/composer3/ClientTarget.aidl
similarity index 65%
copy from graphics/composer/aidl/android/hardware/graphics/composer3/BlendMode.aidl
copy to graphics/composer/aidl/android/hardware/graphics/composer3/ClientTarget.aidl
index c6fd063..56488d5 100644
--- a/graphics/composer/aidl/android/hardware/graphics/composer3/BlendMode.aidl
+++ b/graphics/composer/aidl/android/hardware/graphics/composer3/ClientTarget.aidl
@@ -16,23 +16,24 @@
package android.hardware.graphics.composer3;
-/**
- * Blend modes, settable per layer.
- */
+import android.hardware.graphics.common.Dataspace;
+import android.hardware.graphics.common.Rect;
+import android.hardware.graphics.composer3.Buffer;
+
@VintfStability
-@Backing(type="int")
-enum BlendMode {
- INVALID = 0,
+parcelable ClientTarget {
/**
- * colorOut = colorSrc
+ * Client target Buffer
*/
- NONE = 1,
+ Buffer buffer;
+
/**
- * colorOut = colorSrc + colorDst * (1 - alphaSrc)
+ * The dataspace of the buffer, as described in LayerCommand.dataspace.
*/
- PREMULTIPLIED = 2,
+ Dataspace dataspace;
+
/**
- * colorOut = colorSrc * alphaSrc + colorDst * (1 - alphaSrc)
+ * The surface damage regions.
*/
- COVERAGE = 3,
+ Rect[] damage;
}
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl b/graphics/composer/aidl/android/hardware/graphics/composer3/ClientTargetPropertyWithNits.aidl
similarity index 64%
rename from graphics/composer/aidl/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
rename to graphics/composer/aidl/android/hardware/graphics/composer3/ClientTargetPropertyWithNits.aidl
index f67c3ce..5037651 100644
--- a/graphics/composer/aidl/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
+++ b/graphics/composer/aidl/android/hardware/graphics/composer3/ClientTargetPropertyWithNits.aidl
@@ -16,21 +16,23 @@
package android.hardware.graphics.composer3;
-/**
- * Output parameters for IComposerClient.executeCommands
- */
+import android.hardware.graphics.composer3.ClientTargetProperty;
+
@VintfStability
-parcelable ExecuteCommandsStatus {
+parcelable ClientTargetPropertyWithNits {
/**
- * Indicates whether the output command message queue has changed.
+ * The display which this commands refers to.
+ * @see IComposer.createDisplay
*/
- boolean queueChanged;
+ long display;
+
/**
- * Indicates whether the output command message queue has changed.
+ * The Client target property.
*/
- int length;
+ ClientTargetProperty clientTargetProperty;
+
/**
- * An array of handles referenced by the output commands.
+ * The white points nits as described in CommandResultPayload.clientTargetProperty
*/
- android.hardware.common.NativeHandle[] handles;
+ float whitePointNits;
}
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/BlendMode.aidl b/graphics/composer/aidl/android/hardware/graphics/composer3/ColorTransformPayload.aidl
similarity index 68%
rename from graphics/composer/aidl/android/hardware/graphics/composer3/BlendMode.aidl
rename to graphics/composer/aidl/android/hardware/graphics/composer3/ColorTransformPayload.aidl
index c6fd063..fc37dac 100644
--- a/graphics/composer/aidl/android/hardware/graphics/composer3/BlendMode.aidl
+++ b/graphics/composer/aidl/android/hardware/graphics/composer3/ColorTransformPayload.aidl
@@ -16,23 +16,18 @@
package android.hardware.graphics.composer3;
-/**
- * Blend modes, settable per layer.
- */
+import android.hardware.graphics.common.ColorTransform;
+
@VintfStability
-@Backing(type="int")
-enum BlendMode {
- INVALID = 0,
+parcelable ColorTransformPayload {
/**
- * colorOut = colorSrc
+ * 4x4 transform matrix (16 floats) as described in DisplayCommand.colorTransform.
*/
- NONE = 1,
+ float[] matrix;
+
/**
- * colorOut = colorSrc + colorDst * (1 - alphaSrc)
+ * Hint value which may be used instead of the given matrix unless it
+ * is ColorTransform.ARBITRARY.
*/
- PREMULTIPLIED = 2,
- /**
- * colorOut = colorSrc * alphaSrc + colorDst * (1 - alphaSrc)
- */
- COVERAGE = 3,
+ ColorTransform hint;
}
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/Command.aidl b/graphics/composer/aidl/android/hardware/graphics/composer3/Command.aidl
deleted file mode 100644
index 95c07ac..0000000
--- a/graphics/composer/aidl/android/hardware/graphics/composer3/Command.aidl
+++ /dev/null
@@ -1,763 +0,0 @@
-/**
- * Copyright (c) 2021, 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.composer3;
-
-import android.hardware.graphics.composer3.Command;
-
-/**
- * The command interface allows composer3 to reduce binder overhead by sending
- * atomic command stream in a command message queue. These commands are usually
- * sent on a per frame basic and contains the information that describes how the
- * display is composited. @see IComposerClient.executeCommands.
- */
-@VintfStability
-@Backing(type="int")
-enum Command {
- LENGTH_MASK = 0xffff,
- OPCODE_SHIFT = 16,
- OPCODE_MASK = 0xffff << OPCODE_SHIFT,
-
- // special commands
-
- /**
- * SELECT_DISPLAY has this pseudo prototype
- *
- * selectDisplay(long display);
- *
- * Selects the current display implied by all other commands.
- *
- * @param display is the newly selected display.
- */
- SELECT_DISPLAY = 0x000 << OPCODE_SHIFT,
-
- /**
- * SELECT_LAYER has this pseudo prototype
- *
- * selectLayer(long layer);
- *
- * Selects the current layer implied by all implicit layer commands.
- *
- * @param layer is the newly selected layer.
- */
- SELECT_LAYER = 0x001 << OPCODE_SHIFT,
-
- // value commands (for return values)
-
- /**
- * SET_ERROR has this pseudo prototype
- *
- * setError(uint32_t location, int error);
- *
- * Indicates an error generated by a command.
- *
- * @param location is the offset of the command in the input command
- * message queue.
- * @param error is the error generated by the command.
- */
- SET_ERROR = 0x100 << OPCODE_SHIFT,
-
- /**
- * SET_CHANGED_COMPOSITION_TYPES has this pseudo prototype
- *
- * setChangedCompositionTypes(long[] layers,
- * Composition[] types);
- *
- * Sets the layers for which the device requires a different composition
- * type than had been set prior to the last call to VALIDATE_DISPLAY. The
- * client must either update its state with these types and call
- * ACCEPT_DISPLAY_CHANGES, or must set new types and attempt to validate
- * the display again.
- *
- * @param layers is an array of layer handles.
- * @param types is an array of composition types, each corresponding to
- * an element of layers.
- */
- SET_CHANGED_COMPOSITION_TYPES = 0x101 << OPCODE_SHIFT,
-
- /**
- * SET_DISPLAY_REQUESTS has this pseudo prototype
- *
- * setDisplayRequests(int displayRequestMask,
- * long[] layers,
- * int[] layerRequestMasks);
- *
- * Sets the display requests and the layer requests required for the last
- * validated configuration.
- *
- * Display requests provide information about how the client must handle
- * the client target. Layer requests provide information about how the
- * client must handle an individual layer.
- *
- * @param displayRequestMask is the display requests for the current
- * validated state.
- * @param layers is an array of layers which all have at least one
- * request.
- * @param layerRequestMasks is the requests corresponding to each element
- * of layers.
- */
- SET_DISPLAY_REQUESTS = 0x102 << OPCODE_SHIFT,
-
- /**
- * SET_PRESENT_FENCE has this pseudo prototype
- *
- * setPresentFence(int presentFenceIndex);
- *
- * Sets the present fence as a result of PRESENT_DISPLAY. For physical
- * displays, this fence must be signaled at the vsync when the result
- * of composition of this frame starts to appear (for video-mode panels)
- * or starts to transfer to panel memory (for command-mode panels). For
- * virtual displays, this fence must be signaled when writes to the output
- * buffer have completed and it is safe to read from it.
- *
- * @param presentFenceIndex is an index into outHandles array.
- */
- SET_PRESENT_FENCE = 0x103 << OPCODE_SHIFT,
-
- /**
- * SET_RELEASE_FENCES has this pseudo prototype
- *
- * setReleaseFences(long[] layers,
- * int[] releaseFenceIndices);
- *
- * Sets the release fences for device layers on this display which will
- * receive new buffer contents this frame.
- *
- * A release fence is a file descriptor referring to a sync fence object
- * which must be signaled after the device has finished reading from the
- * buffer presented in the prior frame. This indicates that it is safe to
- * start writing to the buffer again. If a given layer's fence is not
- * returned from this function, it must be assumed that the buffer
- * presented on the previous frame is ready to be written.
- *
- * The fences returned by this function must be unique for each layer
- * (even if they point to the same underlying sync object).
- *
- * @param layers is an array of layer handles.
- * @param releaseFenceIndices are indices into outHandles array, each
- * corresponding to an element of layers.
- */
- SET_RELEASE_FENCES = 0x104 << OPCODE_SHIFT,
-
- // display commands
-
- /**
- * SET_COLOR_TRANSFORM has this pseudo prototype
- *
- * setColorTransform(float[16] matrix,
- * ColorTransform hint);
- *
- * Sets a color transform which will be applied after composition.
- *
- * If hint is not ColorTransform::ARBITRARY, then the device may use the
- * hint to apply the desired color transform instead of using the color
- * matrix directly.
- *
- * If the device is not capable of either using the hint or the matrix to
- * apply the desired color transform, it must force all layers to client
- * composition during VALIDATE_DISPLAY.
- *
- * If IComposer::Capability::SKIP_CLIENT_COLOR_TRANSFORM is present, then
- * the client must never apply the color transform during client
- * composition, even if all layers are being composed by the client.
- *
- * The matrix provided is an affine color transformation of the following
- * form:
- *
- * |r.r r.g r.b 0|
- * |g.r g.g g.b 0|
- * |b.r b.g b.b 0|
- * |Tr Tg Tb 1|
- *
- * This matrix must be provided in row-major form:
- *
- * {r.r, r.g, r.b, 0, g.r, ...}.
- *
- * Given a matrix of this form and an input color [R_in, G_in, B_in], the
- * output color [R_out, G_out, B_out] will be:
- *
- * R_out = R_in * r.r + G_in * g.r + B_in * b.r + Tr
- * G_out = R_in * r.g + G_in * g.g + B_in * b.g + Tg
- * B_out = R_in * r.b + G_in * g.b + B_in * b.b + Tb
- *
- * @param matrix is a 4x4 transform matrix (16 floats) as described above.
- * @param hint is a hint value which may be used instead of the given
- * matrix unless it is ColorTransform::ARBITRARY.
- */
- SET_COLOR_TRANSFORM = 0x200 << OPCODE_SHIFT,
-
- /**
- * SET_CLIENT_TARGET has this pseudo prototype
- *
- * setClientTarget(int targetSlot,
- * int targetIndex,
- * int acquireFenceIndex,
- * android.hardware.graphics.common.Dataspace dataspace,
- * Rect[] damage);
- *
- * Sets the buffer handle which will receive the output of client
- * composition. Layers marked as Composition::CLIENT must be composited
- * into this buffer prior to the call to PRESENT_DISPLAY, and layers not
- * marked as Composition::CLIENT must be composited with this buffer by
- * the device.
- *
- * The buffer handle provided may be empty if no layers are being
- * composited by the client. This must not result in an error (unless an
- * invalid display handle is also provided).
- *
- * Also provides a file descriptor referring to an acquire sync fence
- * object, which must be signaled when it is safe to read from the client
- * target buffer. If it is already safe to read from this buffer, an
- * empty handle may be passed instead.
- *
- * For more about dataspaces, see SET_LAYER_DATASPACE.
- *
- * The damage parameter describes a surface damage region as defined in
- * the description of SET_LAYER_SURFACE_DAMAGE.
- *
- * Will be called before PRESENT_DISPLAY if any of the layers are marked
- * as Composition::CLIENT. If no layers are so marked, then it is not
- * necessary to call this function. It is not necessary to call
- * validateDisplay after changing the target through this function.
- *
- * @param targetSlot is the client target buffer slot to use.
- * @param targetIndex is an index into inHandles for the new target
- * buffer.
- * @param acquireFenceIndex is an index into inHandles for a sync fence
- * file descriptor as described above.
- * @param dataspace is the dataspace of the buffer, as described in
- * setLayerDataspace.
- * @param damage is the surface damage region.
- *
- */
- SET_CLIENT_TARGET = 0x201 << OPCODE_SHIFT,
-
- /**
- * SET_OUTPUT_BUFFER has this pseudo prototype
- *
- * setOutputBuffer(int bufferSlot,
- * int bufferIndex,
- * int releaseFenceIndex);
- *
- * Sets the output buffer for a virtual display. That is, the buffer to
- * which the composition result will be written.
- *
- * Also provides a file descriptor referring to a release sync fence
- * object, which must be signaled when it is safe to write to the output
- * buffer. If it is already safe to write to the output buffer, an empty
- * handle may be passed instead.
- *
- * Must be called at least once before PRESENT_DISPLAY, but does not have
- * any interaction with layer state or display validation.
- *
- * @param bufferSlot is the new output buffer.
- * @param bufferIndex is the new output buffer.
- * @param releaseFenceIndex is a sync fence file descriptor as described
- * above.
- */
- SET_OUTPUT_BUFFER = 0x202 << OPCODE_SHIFT,
-
- /**
- * VALIDATE_DISPLAY has this pseudo prototype
- *
- * validateDisplay();
- *
- * Instructs the device to inspect all of the layer state and determine if
- * there are any composition type changes necessary before presenting the
- * display. Permitted changes are described in the definition of
- * Composition above.
- */
- VALIDATE_DISPLAY = 0x203 << OPCODE_SHIFT,
-
- /**
- * ACCEPT_DISPLAY_CHANGES has this pseudo prototype
- *
- * acceptDisplayChanges();
- *
- * Accepts the changes required by the device from the previous
- * validateDisplay call (which may be queried using
- * getChangedCompositionTypes) and revalidates the display. This function
- * is equivalent to requesting the changed types from
- * getChangedCompositionTypes, setting those types on the corresponding
- * layers, and then calling validateDisplay again.
- *
- * After this call it must be valid to present this display. Calling this
- * after validateDisplay returns 0 changes must succeed with NONE, but
- * must have no other effect.
- */
- ACCEPT_DISPLAY_CHANGES = 0x204 << OPCODE_SHIFT,
-
- /**
- * PRESENT_DISPLAY has this pseudo prototype
- *
- * presentDisplay();
- *
- * Presents the current display contents on the screen (or in the case of
- * virtual displays, into the output buffer).
- *
- * Prior to calling this function, the display must be successfully
- * validated with validateDisplay. Note that setLayerBuffer and
- * setLayerSurfaceDamage specifically do not count as layer state, so if
- * there are no other changes to the layer state (or to the buffer's
- * properties as described in setLayerBuffer), then it is safe to call
- * this function without first validating the display.
- */
- PRESENT_DISPLAY = 0x205 << OPCODE_SHIFT,
-
- /**
- * PRESENT_OR_VALIDATE_DISPLAY has this pseudo prototype
- *
- * presentOrValidateDisplay();
- *
- * Presents the current display contents on the screen (or in the case of
- * virtual displays, into the output buffer) if validate can be skipped,
- * or perform a VALIDATE_DISPLAY action instead.
- */
- PRESENT_OR_VALIDATE_DISPLAY = 0x206 << OPCODE_SHIFT,
-
- // layer commands (VALIDATE_DISPLAY not required)
-
- /**
- * SET_LAYER_CURSOR_POSITION has this pseudo prototype
- *
- * setLayerCursorPosition(int x, int y);
- *
- * Asynchronously sets the position of a cursor layer.
- *
- * Prior to validateDisplay, a layer may be marked as Composition::CURSOR.
- * If validation succeeds (i.e., the device does not request a composition
- * change for that layer), then once a buffer has been set for the layer
- * and it has been presented, its position may be set by this function at
- * any time between presentDisplay and any subsequent validateDisplay
- * calls for this display.
- *
- * Once validateDisplay is called, this function must not be called again
- * until the validate/present sequence is completed.
- *
- * May be called from any thread so long as it is not interleaved with the
- * validate/present sequence as described above.
- *
- * @param layer is the layer to which the position is set.
- * @param x is the new x coordinate (in pixels from the left of the
- * screen).
- * @param y is the new y coordinate (in pixels from the top of the
- * screen).
- */
- SET_LAYER_CURSOR_POSITION = 0x300 << OPCODE_SHIFT,
-
- /**
- * SET_LAYER_BUFFER has this pseudo prototype
- *
- * setLayerBuffer(int bufferSlot,
- * int bufferIndex,
- * int acquireFenceIndex);
- *
- * Sets the buffer handle to be displayed for this layer. If the buffer
- * properties set at allocation time (width, height, format, and usage)
- * have not changed since the previous frame, it is not necessary to call
- * validateDisplay before calling presentDisplay unless new state needs to
- * be validated in the interim.
- *
- * Also provides a file descriptor referring to an acquire sync fence
- * object, which must be signaled when it is safe to read from the given
- * buffer. If it is already safe to read from the buffer, an empty handle
- * may be passed instead.
- *
- * This function must return NONE and have no other effect if called for a
- * layer with a composition type of Composition::SOLID_COLOR (because it
- * has no buffer) or Composition::SIDEBAND or Composition::CLIENT (because
- * synchronization and buffer updates for these layers are handled
- * elsewhere).
- *
- * @param layer is the layer to which the buffer is set.
- * @param bufferSlot is the buffer slot to use.
- * @param bufferIndex is the buffer handle to set.
- * @param acquireFenceIndex is a sync fence file descriptor as described above.
- */
- SET_LAYER_BUFFER = 0x301 << OPCODE_SHIFT,
-
- /*
- * SET_LAYER_SURFACE_DAMAGE has this pseudo prototype
- *
- * setLayerSurfaceDamage(Rect[] damage);
- *
- * Provides the region of the source buffer which has been modified since
- * the last frame. This region does not need to be validated before
- * calling presentDisplay.
- *
- * Once set through this function, the damage region remains the same
- * until a subsequent call to this function.
- *
- * If damage is non-empty, then it may be assumed that any portion of the
- * source buffer not covered by one of the rects has not been modified
- * this frame. If damage is empty, then the whole source buffer must be
- * treated as if it has been modified.
- *
- * If the layer's contents are not modified relative to the prior frame,
- * damage must contain exactly one empty rect([0, 0, 0, 0]).
- *
- * The damage rects are relative to the pre-transformed buffer, and their
- * origin is the top-left corner. They must not exceed the dimensions of
- * the latched buffer.
- *
- * @param layer is the layer to which the damage region is set.
- * @param damage is the new surface damage region.
- */
- SET_LAYER_SURFACE_DAMAGE = 0x302 << OPCODE_SHIFT,
-
- // layer state commands (VALIDATE_DISPLAY required)
-
- /**
- * SET_LAYER_BLEND_MODE has this pseudo prototype
- *
- * setLayerBlendMode(android.hardware.graphics.common.BlendMode mode)
- *
- * Sets the blend mode of the given layer.
- *
- * @param mode is the new blend mode.
- */
- SET_LAYER_BLEND_MODE = 0x400 << OPCODE_SHIFT,
-
- /**
- * SET_LAYER_COLOR has this pseudo prototype
- *
- * setLayerColor(Color color);
- *
- * Sets the color of the given layer. If the composition type of the layer
- * is not Composition::SOLID_COLOR, this call must succeed and have no
- * other effect.
- *
- * @param color is the new color.
- */
- SET_LAYER_COLOR = 0x401 << OPCODE_SHIFT,
-
- /**
- * SET_LAYER_COMPOSITION_TYPE has this pseudo prototype
- *
- * setLayerCompositionType(Composition type);
- *
- * Sets the desired composition type of the given layer. During
- * validateDisplay, the device may request changes to the composition
- * types of any of the layers as described in the definition of
- * Composition above.
- *
- * @param type is the new composition type.
- */
- SET_LAYER_COMPOSITION_TYPE = 0x402 << OPCODE_SHIFT,
-
- /**
- * SET_LAYER_DATASPACE has this pseudo prototype
- *
- * setLayerDataspace(android.hardware.graphics.common.Dataspace dataspace);
- *
- * Sets the dataspace of the layer.
- *
- * The dataspace provides more information about how to interpret the buffer
- * or solid color, such as the encoding standard and color transform.
- *
- * See the values of Dataspace for more information.
- *
- * @param dataspace is the new dataspace.
- */
- SET_LAYER_DATASPACE = 0x403 << OPCODE_SHIFT,
-
- /**
- * SET_LAYER_DISPLAY_FRAME has this pseudo prototype
- *
- * setLayerDisplayFrame(Rect frame);
- *
- * Sets the display frame (the portion of the display covered by a layer)
- * of the given layer. This frame must not exceed the display dimensions.
- *
- * @param frame is the new display frame.
- */
- SET_LAYER_DISPLAY_FRAME = 0x404 << OPCODE_SHIFT,
-
- /**
- * SET_LAYER_PLANE_ALPHA has this pseudo prototype
- *
- * setLayerPlaneAlpha(float alpha);
- *
- * Sets an alpha value (a floating point value in the range [0.0, 1.0])
- * which will be applied to the whole layer. It can be conceptualized as a
- * preprocessing step which applies the following function:
- * if (blendMode == BlendMode::PREMULTIPLIED)
- * out.rgb = in.rgb * planeAlpha
- * out.a = in.a * planeAlpha
- *
- * If the device does not support this operation on a layer which is
- * marked Composition::DEVICE, it must request a composition type change
- * to Composition::CLIENT upon the next validateDisplay call.
- *
- * @param alpha is the plane alpha value to apply.
- */
- SET_LAYER_PLANE_ALPHA = 0x405 << OPCODE_SHIFT,
-
- /**
- * SET_LAYER_SIDEBAND_STREAM has this pseudo prototype
- *
- * setLayerSidebandStream(int streamIndex)
- *
- * Sets the sideband stream for this layer. If the composition type of the
- * given layer is not Composition::SIDEBAND, this call must succeed and
- * have no other effect.
- *
- * @param streamIndex is the new sideband stream.
- */
- SET_LAYER_SIDEBAND_STREAM = 0x406 << OPCODE_SHIFT,
-
- /**
- * SET_LAYER_SOURCE_CROP has this pseudo prototype
- *
- * setLayerSourceCrop(FRect crop);
- *
- * Sets the source crop (the portion of the source buffer which will fill
- * the display frame) of the given layer. This crop rectangle must not
- * exceed the dimensions of the latched buffer.
- *
- * If the device is not capable of supporting a true float source crop
- * (i.e., it will truncate or round the floats to integers), it must set
- * this layer to Composition::CLIENT when crop is non-integral for the
- * most accurate rendering.
- *
- * If the device cannot support float source crops, but still wants to
- * handle the layer, it must use the following code (or similar) to
- * convert to an integer crop:
- * intCrop.left = (int) ceilf(crop.left);
- * intCrop.top = (int) ceilf(crop.top);
- * intCrop.right = (int) floorf(crop.right);
- * intCrop.bottom = (int) floorf(crop.bottom);
- *
- * @param crop is the new source crop.
- */
- SET_LAYER_SOURCE_CROP = 0x407 << OPCODE_SHIFT,
-
- /**
- * SET_LAYER_TRANSFORM has this pseudo prototype
- *
- * Sets the transform (rotation/flip) of the given layer.
- *
- * setLayerTransform(Transform transform);
- *
- * @param transform is the new transform.
- */
- SET_LAYER_TRANSFORM = 0x408 << OPCODE_SHIFT,
-
- /**
- * SET_LAYER_VISIBLE_REGION has this pseudo prototype
- *
- * setLayerVisibleRegion(Rect[] visible);
- *
- * Specifies the portion of the layer that is visible, including portions
- * under translucent areas of other layers. The region is in screen space,
- * and must not exceed the dimensions of the screen.
- *
- * @param visible is the new visible region, in screen space.
- */
- SET_LAYER_VISIBLE_REGION = 0x409 << OPCODE_SHIFT,
-
- /**
- * SET_LAYER_Z_ORDER has this pseudo prototype
- *
- * setLayerZOrder(int z);
- *
- * Sets the desired Z order (height) of the given layer. A layer with a
- * greater Z value occludes a layer with a lesser Z value.
- *
- * @param z is the new Z order.
- */
- SET_LAYER_Z_ORDER = 0x40a << OPCODE_SHIFT,
-
- /**
- * SET_PRESENT_OR_VALIDATE_DISPLAY_RESULT has this pseudo prototype
- *
- * setPresentOrValidateDisplayResult(int state);
- *
- * Sets the state of PRESENT_OR_VALIDATE_DISPLAY command.
- * @param state is the state of present or validate
- * 1 - Present Succeeded
- * 0 - Validate succeeded
- */
- SET_PRESENT_OR_VALIDATE_DISPLAY_RESULT = 0x40b << OPCODE_SHIFT,
-
- /**
- * SET_LAYER_PER_FRAME_METADATA has this pseudo prototype
- *
- * setLayerPerFrameMetadata(long display, long layer,
- * PerFrameMetadata[] data);
- *
- * Sets the PerFrameMetadata for the display. This metadata must be used
- * by the implementation to better tone map content to that display.
- *
- * This is a method that may be called every frame. Thus it's
- * implemented using buffered transport.
- * SET_LAYER_PER_FRAME_METADATA is the command used by the buffered transport
- * mechanism.
- */
- SET_LAYER_PER_FRAME_METADATA = 0x303 << OPCODE_SHIFT,
-
- /**
- * SET_LAYER_FLOAT_COLOR has this pseudo prototype
- *
- * setLayerColor(FloatColor color);
- *
- * Sets the color of the given layer. If the composition type of the layer
- * is not Composition::SOLID_COLOR, this call must succeed and have no
- * other effect.
- *
- * @param color is the new color using float type.
- */
- SET_LAYER_FLOAT_COLOR = 0x40c << OPCODE_SHIFT,
-
- /**
- * SET_LAYER_COLOR_TRANSFORM has this pseudo prototype
- *
- * setLayerColorTransform(float[16] matrix);
- *
- * This command has the following binary layout in bytes:
- *
- * 0 - 16 * 4: matrix
- *
- * Sets a matrix for color transform which will be applied on this layer
- * before composition.
- *
- * If the device is not capable of apply the matrix on this layer, it must force
- * this layer to client composition during VALIDATE_DISPLAY.
- *
- * The matrix provided is an affine color transformation of the following
- * form:
- *
- * |r.r r.g r.b 0|
- * |g.r g.g g.b 0|
- * |b.r b.g b.b 0|
- * |Tr Tg Tb 1|
- *
- * This matrix must be provided in row-major form:
- *
- * {r.r, r.g, r.b, 0, g.r, ...}.
- *
- * Given a matrix of this form and an input color [R_in, G_in, B_in],
- * the input color must first be converted to linear space
- * [R_linear, G_linear, B_linear], then the output linear color
- * [R_out_linear, G_out_linear, B_out_linear] will be:
- *
- * R_out_linear = R_linear * r.r + G_linear * g.r + B_linear * b.r + Tr
- * G_out_linear = R_linear * r.g + G_linear * g.g + B_linear * b.g + Tg
- * B_out_linear = R_linear * r.b + G_linear * g.b + B_linear * b.b + Tb
- *
- * [R_out_linear, G_out_linear, B_out_linear] must then be converted to
- * gamma space: [R_out, G_out, B_out] before blending.
- *
- * @param matrix is a 4x4 transform matrix (16 floats) as described above.
- */
-
- SET_LAYER_COLOR_TRANSFORM = 0x40d << OPCODE_SHIFT,
- /*
- * SET_LAYER_PER_FRAME_METADATA_BLOBS has this pseudo prototype
- *
- * setLayerPerFrameMetadataBlobs(long display, long layer,
- * PerFrameMetadataBlob[] metadata);
- *
- * This command sends metadata that may be used for tone-mapping the
- * associated layer. The metadata structure follows a {key, blob}
- * format (see the PerFrameMetadataBlob struct). All keys must be
- * returned by a prior call to getPerFrameMetadataKeys and must
- * be part of the list of keys associated with blob-type metadata
- * (see PerFrameMetadataKey).
- *
- * This method may be called every frame.
- */
- SET_LAYER_PER_FRAME_METADATA_BLOBS = 0x304 << OPCODE_SHIFT,
-
- /**
- * SET_CLIENT_TARGET_PROPERTY has this pseudo prototype
- *
- * This command has the following binary layout in bytes:
- *
- * 0 - 3: clientTargetProperty.pixelFormat
- * 4 - 7: clientTargetProperty.dataspace
- * 8 - 11: whitePointNits
- *
- * The white point parameter describes the intended white point of the client target buffer.
- * When client composition blends both HDR and SDR content, the client must composite to the
- * brightness space as specified by the hardware composer. This is so that adjusting the real
- * display brightness may be applied atomically with compensating the client target output. For
- * instance, client-compositing a list of SDR layers requires dimming the brightness space of
- * the SDR buffers when an HDR layer is simultaneously device-composited.
- *
- * setClientTargetProperty(ClientTargetProperty clientTargetProperty, float whitePointNits);
- */
- SET_CLIENT_TARGET_PROPERTY = 0x105 << OPCODE_SHIFT,
-
- /**
- * SET_LAYER_GENERIC_METADATA has this pseudo prototype
- *
- * setLayerGenericMetadata(string key, bool mandatory, byte[] value);
- *
- * Sets a piece of generic metadata for the given layer. If this
- * function is called twice with the same key but different values, the
- * newer value must override the older one. Calling this function with a
- * 0-length value must reset that key's metadata as if it had not been
- * set.
- *
- * A given piece of metadata may either be mandatory or a hint
- * (non-mandatory) as indicated by the second parameter. Mandatory
- * metadata may affect the composition result, which is to say that it
- * may cause a visible change in the final image. By contrast, hints may
- * only affect the composition strategy, such as which layers are
- * composited by the client, but must not cause a visible change in the
- * final image. The value of the mandatory flag shall match the value
- * returned from getLayerGenericMetadataKeys for the given key.
- *
- * Only keys which have been returned from getLayerGenericMetadataKeys()
- * shall be accepted. Any other keys must result in an UNSUPPORTED error.
- *
- * The value passed into this function shall be the binary
- * representation of a HIDL type corresponding to the given key. For
- * example, a key of 'com.example.V1_3.Foo' shall be paired with a
- * value of type com.example@1.3::Foo, which would be defined in a
- * vendor HAL extension.
- *
- * This function will be encoded in the command buffer in this order:
- * 1) The key length, stored as a uint32_t
- * 2) The key itself, padded to a uint32_t boundary if necessary
- * 3) The mandatory flag, stored as a uint32_t
- * 4) The value length in bytes, stored as a uint32_t
- * 5) The value itself, padded to a uint32_t boundary if necessary
- *
- * @param key indicates which metadata value should be set on this layer
- * @param mandatory indicates whether this particular key represents
- * mandatory metadata or a hint (non-mandatory metadata), as
- * described above
- * @param value is a binary representation of a HIDL struct
- * corresponding to the key as described above
- */
- SET_LAYER_GENERIC_METADATA = 0x40e << OPCODE_SHIFT,
-
- /**
- * SET_LAYER_WHITE_POINT_NITS has this pseudo prototype
- *
- * setLayerWhitePointNits(float sdrWhitePointNits);
- *
- * Sets the desired white point for the layer. This is intended to be used when presenting
- * an SDR layer alongside HDR content. The HDR content will be presented at the display
- * brightness in nits, and accordingly SDR content shall be dimmed to the desired white point
- * provided.
- *
- * @param whitePointNits is the white point in nits.
- */
- SET_LAYER_WHITE_POINT_NITS = 0x305 << OPCODE_SHIFT,
-}
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/LayerRequest.aidl b/graphics/composer/aidl/android/hardware/graphics/composer3/CommandError.aidl
similarity index 69%
copy from graphics/composer/aidl/android/hardware/graphics/composer3/LayerRequest.aidl
copy to graphics/composer/aidl/android/hardware/graphics/composer3/CommandError.aidl
index 10de558..ea48600 100644
--- a/graphics/composer/aidl/android/hardware/graphics/composer3/LayerRequest.aidl
+++ b/graphics/composer/aidl/android/hardware/graphics/composer3/CommandError.aidl
@@ -16,16 +16,14 @@
package android.hardware.graphics.composer3;
-/**
- * Layer requests returned from getDisplayRequests.
- */
@VintfStability
-@Backing(type="int")
-enum LayerRequest {
+parcelable CommandError {
/**
- * The client must clear its target with transparent pixels where
- * this layer would be. The client may ignore this request if the
- * layer must be blended.
+ * The index in the command payload array.
*/
- CLEAR_CLIENT_TARGET = 1 << 0,
+ int commandIndex;
+ /**
+ * The error generated by the command. Can be one of the IComposerClient.EX_*
+ */
+ int errorCode;
}
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/CommandResultPayload.aidl b/graphics/composer/aidl/android/hardware/graphics/composer3/CommandResultPayload.aidl
new file mode 100644
index 0000000..f2de68e
--- /dev/null
+++ b/graphics/composer/aidl/android/hardware/graphics/composer3/CommandResultPayload.aidl
@@ -0,0 +1,94 @@
+/**
+ * Copyright (c) 2021, 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.composer3;
+
+import android.hardware.graphics.composer3.ChangedCompositionTypes;
+import android.hardware.graphics.composer3.ClientTargetPropertyWithNits;
+import android.hardware.graphics.composer3.CommandError;
+import android.hardware.graphics.composer3.DisplayRequest;
+import android.hardware.graphics.composer3.PresentFence;
+import android.hardware.graphics.composer3.PresentOrValidate;
+import android.hardware.graphics.composer3.ReleaseFences;
+
+@VintfStability
+union CommandResultPayload {
+ /**
+ * Indicates an error generated by a command.
+ */
+ CommandError error;
+
+ /**
+ * Sets the layers for which the device requires a different composition
+ * type than had been set prior to the last call to VALIDATE_DISPLAY. The
+ * client must either update its state with these types and call
+ * ACCEPT_DISPLAY_CHANGES, or must set new types and attempt to validate
+ * the display again.
+ */
+ ChangedCompositionTypes changedCompositionTypes;
+
+ /**
+ * Sets the display requests and the layer requests required for the last
+ * validated configuration.
+ *
+ * Display requests provide information about how the client must handle
+ * the client target. Layer requests provide information about how the
+ * client must handle an individual layer.
+ */
+ DisplayRequest displayRequest;
+
+ /**
+ * Sets the present fence as a result of PRESENT_DISPLAY. For physical
+ * displays, this fence must be signaled at the vsync when the result
+ * of composition of this frame starts to appear (for video-mode panels)
+ * or starts to transfer to panel memory (for command-mode panels). For
+ * virtual displays, this fence must be signaled when writes to the output
+ * buffer have completed and it is safe to read from it.
+ */
+ PresentFence presentFence;
+
+ /**
+ * Sets the release fences for device layers on this display which will
+ * receive new buffer contents this frame.
+ *
+ * A release fence is a file descriptor referring to a sync fence object
+ * which must be signaled after the device has finished reading from the
+ * buffer presented in the prior frame. This indicates that it is safe to
+ * start writing to the buffer again. If a given layer's fence is not
+ * returned from this function, it must be assumed that the buffer
+ * presented on the previous frame is ready to be written.
+ *
+ * The fences returned by this function must be unique for each layer
+ * (even if they point to the same underlying sync object).
+ *
+ */
+ ReleaseFences releaseFences;
+
+ /**
+ * Sets the state of PRESENT_OR_VALIDATE_DISPLAY command.
+ */
+ PresentOrValidate presentOrValidateResult;
+
+ /**
+ * The white point parameter describes the intended white point of the client target buffer.
+ * When client composition blends both HDR and SDR content, the client must composite to the
+ * brightness space as specified by the hardware composer. This is so that adjusting the real
+ * display brightness may be applied atomically with compensating the client target output. For
+ * instance, client-compositing a list of SDR layers requires dimming the brightness space of
+ * the SDR buffers when an HDR layer is simultaneously device-composited.
+ */
+ ClientTargetPropertyWithNits clientTargetProperty;
+}
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/Composition.aidl b/graphics/composer/aidl/android/hardware/graphics/composer3/Composition.aidl
index ea22af2..d1c9b30 100644
--- a/graphics/composer/aidl/android/hardware/graphics/composer3/Composition.aidl
+++ b/graphics/composer/aidl/android/hardware/graphics/composer3/Composition.aidl
@@ -66,7 +66,7 @@
/**
* The device must handle the composition of this layer, as well as
* its buffer updates and content synchronization. Only supported on
- * devices which provide Capability::SIDEBAND_STREAM.
+ * devices which provide Capability.SIDEBAND_STREAM.
*
* Upon validateDisplay, the device may request a change from this
* type to either DEVICE or CLIENT, but it is unlikely that content
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/DisplayCapability.aidl b/graphics/composer/aidl/android/hardware/graphics/composer3/DisplayCapability.aidl
index 54f09c1..eacf106 100644
--- a/graphics/composer/aidl/android/hardware/graphics/composer3/DisplayCapability.aidl
+++ b/graphics/composer/aidl/android/hardware/graphics/composer3/DisplayCapability.aidl
@@ -41,14 +41,15 @@
*/
SKIP_CLIENT_COLOR_TRANSFORM = 1,
/**
- * Indicates that the display supports PowerMode::DOZE and
- * PowerMode::DOZE_SUSPEND. DOZE_SUSPEND may not provide any benefit
+ * Indicates that the display supports PowerMode.DOZE and
+ * potentially PowerMode.DOZE_SUSPEND if DisplayCapability.SUSPEND is also
+ * supported. DOZE_SUSPEND may not provide any benefit
* over DOZE (see the definition of PowerMode for more information),
* but if both DOZE and DOZE_SUSPEND are no different from
- * PowerMode::ON, the device must not claim support.
+ * PowerMode.ON, the device must not claim support.
* Must be returned by getDisplayCapabilities when getDozeSupport
- * indicates the display supports PowerMode::DOZE and
- * PowerMode::DOZE_SUSPEND.
+ * indicates the display supports PowerMode.DOZE and
+ * PowerMode.DOZE_SUSPEND.
*/
DOZE = 2,
/**
@@ -66,4 +67,12 @@
* support a low latency mode, such as HDMI 2.1 Auto Low Latency Mode.
*/
AUTO_LOW_LATENCY_MODE = 5,
+ /**
+ * Indicates that the display supports PowerMode.ON_SUSPEND.
+ * If PowerMode.ON_SUSPEND is no different from PowerMode.ON, the device must not
+ * claim support.
+ * If the display supports DisplayCapability.DOZE and DisplayCapability.SUSPEND, then
+ * PowerMode.ON_SUSPEND and PowerMode.DOZE_SUSPEND must be supported.
+ */
+ SUSPEND = 6,
}
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/DisplayCommand.aidl b/graphics/composer/aidl/android/hardware/graphics/composer3/DisplayCommand.aidl
new file mode 100644
index 0000000..21497c4
--- /dev/null
+++ b/graphics/composer/aidl/android/hardware/graphics/composer3/DisplayCommand.aidl
@@ -0,0 +1,158 @@
+/**
+ * Copyright (c) 2021, 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.composer3;
+
+import android.hardware.graphics.composer3.Buffer;
+import android.hardware.graphics.composer3.ClientTarget;
+import android.hardware.graphics.composer3.ColorTransformPayload;
+import android.hardware.graphics.composer3.LayerCommand;
+
+@VintfStability
+parcelable DisplayCommand {
+ /**
+ * The display which this commands refers to.
+ * @see IComposer.createDisplay
+ */
+ long display;
+
+ /**
+ * Sets layer commands for this display.
+ * @see LayerCommand.
+ */
+ LayerCommand[] layers;
+
+ /**
+ * Sets a color transform which will be applied after composition.
+ *
+ * If hint is not ColorTransform.ARBITRARY, then the device may use the
+ * hint to apply the desired color transform instead of using the color
+ * matrix directly.
+ *
+ * If the device is not capable of either using the hint or the matrix to
+ * apply the desired color transform, it must force all layers to client
+ * composition during VALIDATE_DISPLAY.
+ *
+ * If Capability.SKIP_CLIENT_COLOR_TRANSFORM is present, then
+ * the client must never apply the color transform during client
+ * composition, even if all layers are being composed by the client.
+ *
+ * The matrix provided is an affine color transformation of the following
+ * form:
+ *
+ * |r.r r.g r.b 0|
+ * |g.r g.g g.b 0|
+ * |b.r b.g b.b 0|
+ * |Tr Tg Tb 1|
+ *
+ * This matrix must be provided in row-major form:
+ *
+ * {r.r, r.g, r.b, 0, g.r, ...}.
+ *
+ * Given a matrix of this form and an input color [R_in, G_in, B_in], the
+ * output color [R_out, G_out, B_out] will be:
+ *
+ * R_out = R_in * r.r + G_in * g.r + B_in * b.r + Tr
+ * G_out = R_in * r.g + G_in * g.g + B_in * b.g + Tg
+ * B_out = R_in * r.b + G_in * g.b + B_in * b.b + Tb
+ *
+ */
+ @nullable ColorTransformPayload colorTransform;
+
+ /**
+ * Sets the buffer handle which will receive the output of client
+ * composition. Layers marked as Composition.CLIENT must be composited
+ * into this buffer prior to the call to PRESENT_DISPLAY, and layers not
+ * marked as Composition.CLIENT must be composited with this buffer by
+ * the device.
+ *
+ * The buffer handle provided may be empty if no layers are being
+ * composited by the client. This must not result in an error (unless an
+ * invalid display handle is also provided).
+ *
+ * Also provides a file descriptor referring to an acquire sync fence
+ * object, which must be signaled when it is safe to read from the client
+ * target buffer. If it is already safe to read from this buffer, an
+ * empty handle may be passed instead.
+ *
+ * For more about dataspaces, see SET_LAYER_DATASPACE.
+ *
+ * The damage parameter describes a surface damage region as defined in
+ * the description of SET_LAYER_SURFACE_DAMAGE.
+ *
+ * Will be called before PRESENT_DISPLAY if any of the layers are marked
+ * as Composition.CLIENT. If no layers are so marked, then it is not
+ * necessary to call this function. It is not necessary to call
+ * validateDisplay after changing the target through this function.
+ */
+ @nullable ClientTarget clientTarget;
+
+ /**
+ * Sets the output buffer for a virtual display. That is, the buffer to
+ * which the composition result will be written.
+ *
+ * Also provides a file descriptor referring to a release sync fence
+ * object, which must be signaled when it is safe to write to the output
+ * buffer. If it is already safe to write to the output buffer, an empty
+ * handle may be passed instead.
+ *
+ * Must be called at least once before PRESENT_DISPLAY, but does not have
+ * any interaction with layer state or display validation.
+ */
+ @nullable Buffer virtualDisplayOutputBuffer;
+
+ /**
+ * Instructs the device to inspect all of the layer state and determine if
+ * there are any composition type changes necessary before presenting the
+ * display. Permitted changes are described in the definition of
+ * Composition above.
+ */
+ boolean validateDisplay;
+
+ /**
+ * Accepts the changes required by the device from the previous
+ * validateDisplay call (which may be queried using
+ * getChangedCompositionTypes) and revalidates the display. This function
+ * is equivalent to requesting the changed types from
+ * getChangedCompositionTypes, setting those types on the corresponding
+ * layers, and then calling validateDisplay again.
+ *
+ * After this call it must be valid to present this display. Calling this
+ * after validateDisplay returns 0 changes must succeed with NONE, but
+ * must have no other effect.
+ */
+ boolean acceptDisplayChanges;
+
+ /**
+ * Presents the current display contents on the screen (or in the case of
+ * virtual displays, into the output buffer).
+ *
+ * Prior to calling this function, the display must be successfully
+ * validated with validateDisplay. Note that setLayerBuffer and
+ * setLayerSurfaceDamage specifically do not count as layer state, so if
+ * there are no other changes to the layer state (or to the buffer's
+ * properties as described in setLayerBuffer), then it is safe to call
+ * this function without first validating the display.
+ */
+ boolean presentDisplay;
+
+ /**
+ * Presents the current display contents on the screen (or in the case of
+ * virtual displays, into the output buffer) if validate can be skipped,
+ * or perform a VALIDATE_DISPLAY action instead.
+ */
+ boolean presentOrValidateDisplay;
+}
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/DisplayRequest.aidl b/graphics/composer/aidl/android/hardware/graphics/composer3/DisplayRequest.aidl
index 4b3d31a..27fe1e6 100644
--- a/graphics/composer/aidl/android/hardware/graphics/composer3/DisplayRequest.aidl
+++ b/graphics/composer/aidl/android/hardware/graphics/composer3/DisplayRequest.aidl
@@ -16,22 +16,57 @@
package android.hardware.graphics.composer3;
-/**
- * Display requests returned by getDisplayRequests.
- */
@VintfStability
-@Backing(type="int")
-enum DisplayRequest {
+parcelable DisplayRequest {
/**
* Instructs the client to provide a new client target buffer, even if
* no layers are marked for client composition.
*/
- FLIP_CLIENT_TARGET = 1 << 0,
+ const int FLIP_CLIENT_TARGET = 1 << 0;
+
/**
* Instructs the client to write the result of client composition
* directly into the virtual display output buffer. If any of the
- * layers are not marked as Composition::CLIENT or the given display
+ * layers are not marked as Composition.CLIENT or the given display
* is not a virtual display, this request has no effect.
*/
- WRITE_CLIENT_TARGET_TO_OUTPUT = 1 << 1,
+ const int WRITE_CLIENT_TARGET_TO_OUTPUT = 1 << 1;
+
+ /**
+ * The display which this commands refers to.
+ * @see IComposer.createDisplay
+ */
+ long display;
+
+ /**
+ * The display requests for the current validated state. This must be a
+ * bitwise-or of the constants in `DisplayRequest`.
+ */
+ int mask;
+
+ @VintfStability
+ parcelable LayerRequest {
+ /**
+ * The client must clear its target with transparent pixels where
+ * this layer would be. The client may ignore this request if the
+ * layer must be blended.
+ */
+ const int CLEAR_CLIENT_TARGET = 1 << 0;
+
+ /**
+ * The layer which this commands refers to.
+ * @see IComposer.createLayer
+ */
+ long layer;
+ /**
+ * The layer requests for the current validated state. This must be a
+ * bitwise-or of the constants in `LayerRequest`.
+ */
+ int mask;
+ }
+
+ /**
+ * The layer requests for the current validated state.
+ */
+ LayerRequest[] layerRequests;
}
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/BlendMode.aidl b/graphics/composer/aidl/android/hardware/graphics/composer3/GenericMetadata.aidl
similarity index 66%
copy from graphics/composer/aidl/android/hardware/graphics/composer3/BlendMode.aidl
copy to graphics/composer/aidl/android/hardware/graphics/composer3/GenericMetadata.aidl
index c6fd063..d0254dd 100644
--- a/graphics/composer/aidl/android/hardware/graphics/composer3/BlendMode.aidl
+++ b/graphics/composer/aidl/android/hardware/graphics/composer3/GenericMetadata.aidl
@@ -16,23 +16,18 @@
package android.hardware.graphics.composer3;
-/**
- * Blend modes, settable per layer.
- */
+import android.hardware.graphics.composer3.LayerGenericMetadataKey;
+
@VintfStability
-@Backing(type="int")
-enum BlendMode {
- INVALID = 0,
+parcelable GenericMetadata {
/**
- * colorOut = colorSrc
+ * Indicates which metadata value should be set.
*/
- NONE = 1,
+ LayerGenericMetadataKey key;
/**
- * colorOut = colorSrc + colorDst * (1 - alphaSrc)
+ * The binary representation of a AIDL struct corresponding to
+ * the key as described above.
+ * TODO(b/209691612): revisit the use of byte[]
*/
- PREMULTIPLIED = 2,
- /**
- * colorOut = colorSrc * alphaSrc + colorDst * (1 - alphaSrc)
- */
- COVERAGE = 3,
+ byte[] value;
}
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/IComposer.aidl b/graphics/composer/aidl/android/hardware/graphics/composer3/IComposer.aidl
index a6a9f73..b8edd80 100644
--- a/graphics/composer/aidl/android/hardware/graphics/composer3/IComposer.aidl
+++ b/graphics/composer/aidl/android/hardware/graphics/composer3/IComposer.aidl
@@ -27,7 +27,7 @@
const int EX_NO_RESOURCES = 6;
/**
- * Creates a v2.4 client of the composer. Supersedes @2.3::createClient.
+ * Creates a client of the composer.
*
* @return is the newly created client.
*
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/IComposerCallback.aidl b/graphics/composer/aidl/android/hardware/graphics/composer3/IComposerCallback.aidl
index 1709e6d..ac95b41 100644
--- a/graphics/composer/aidl/android/hardware/graphics/composer3/IComposerCallback.aidl
+++ b/graphics/composer/aidl/android/hardware/graphics/composer3/IComposerCallback.aidl
@@ -26,7 +26,7 @@
* 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,
+ * 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.
*
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/IComposerClient.aidl b/graphics/composer/aidl/android/hardware/graphics/composer3/IComposerClient.aidl
index 230980d..28bdb2c 100644
--- a/graphics/composer/aidl/android/hardware/graphics/composer3/IComposerClient.aidl
+++ b/graphics/composer/aidl/android/hardware/graphics/composer3/IComposerClient.aidl
@@ -16,19 +16,17 @@
package android.hardware.graphics.composer3;
-import android.hardware.common.fmq.MQDescriptor;
-import android.hardware.common.fmq.SynchronizedReadWrite;
import android.hardware.graphics.composer3.ClientTargetProperty;
import android.hardware.graphics.composer3.ColorMode;
-import android.hardware.graphics.composer3.Command;
+import android.hardware.graphics.composer3.CommandResultPayload;
import android.hardware.graphics.composer3.ContentType;
import android.hardware.graphics.composer3.DisplayAttribute;
import android.hardware.graphics.composer3.DisplayCapability;
+import android.hardware.graphics.composer3.DisplayCommand;
import android.hardware.graphics.composer3.DisplayConnectionType;
import android.hardware.graphics.composer3.DisplayContentSample;
import android.hardware.graphics.composer3.DisplayContentSamplingAttributes;
import android.hardware.graphics.composer3.DisplayIdentification;
-import android.hardware.graphics.composer3.ExecuteCommandsStatus;
import android.hardware.graphics.composer3.FormatColorComponent;
import android.hardware.graphics.composer3.HdrCapabilities;
import android.hardware.graphics.composer3.IComposerCallback;
@@ -159,23 +157,13 @@
void destroyVirtualDisplay(long display);
/**
- * Executes commands from the input command message queue. Return values
- * generated by the input commands are written to the output command
- * message queue in the form of value commands.
+ * Executes commands.
*
- * @param inLength is the length of input commands.
- * @param inHandles is an array of handles referenced by the input
- * commands.
+ * @param commands are the commands to be processed.
*
- * @return is the status of the command.
-
- * @exception EX_BAD_PARAMETER when inLength is not equal to the length of
- * commands in the input command message queue.
- * @exception NO_RESOURCES when the output command message queue was not
- * properly drained.
+ * @return are the command statuses.
*/
- ExecuteCommandsStatus executeCommands(
- int inLength, in android.hardware.common.NativeHandle[] inHandles);
+ CommandResultPayload[] executeCommands(in DisplayCommand[] commands);
/**
* Retrieves which display configuration is currently active.
@@ -197,7 +185,7 @@
/**
* Returns the color modes supported on this display.
*
- * All devices must support at least ColorMode::NATIVE.
+ * All devices must support at least ColorMode.NATIVE.
*
* @param display is the display to query.
*
@@ -213,7 +201,7 @@
*
* When the layer dataspace is a legacy dataspace (see
* common@1.1::Dataspace) and the display render intent is
- * RenderIntent::ENHANCE, the pixel values can go through an
+ * RenderIntent.ENHANCE, the pixel values can go through an
* implementation-defined saturation transform before being mapped to the
* current color mode colorimetrically.
*
@@ -259,22 +247,6 @@
int getDisplayAttribute(long display, int config, DisplayAttribute attribute);
/**
- * Use getDisplayCapabilities instead. If brightness is supported, must return
- * DisplayCapability::BRIGHTNESS as one of the display capabilities via getDisplayCapabilities.
- * Only use getDisplayCapabilities as the source of truth to query brightness support.
- *
- * Gets whether brightness operations are supported on a display.
- *
- * @param display The display.
- *
- * @return Whether brightness operations are supported on the display.
- *
- * @exception EX_BAD_DISPLAY when the display is invalid, or
- * @exception EX_BAD_PARAMETER when the output parameter is invalid.
- */
- boolean getDisplayBrightnessSupport(long display);
-
- /**
* Provides a list of supported capabilities (as described in the
* definition of DisplayCapability above). This list must not change after
* initialization.
@@ -383,21 +355,6 @@
DisplayContentSamplingAttributes getDisplayedContentSamplingAttributes(long display);
/**
- * Returns whether the given display supports PowerMode::DOZE and
- * PowerMode::DOZE_SUSPEND. DOZE_SUSPEND may not provide any benefit over
- * DOZE (see the definition of PowerMode for more information), but if
- * both DOZE and DOZE_SUSPEND are no different from PowerMode::ON, the
- * device must not claim support.
- *
- * @param display is the display to query.
- *
- * @return is true only when the display supports doze modes.
- *
- * @exception EX_BAD_DISPLAY when an invalid display handle was passed in.
- */
- boolean getDozeSupport(long display);
-
- /**
* Returns the high dynamic range (HDR) capabilities of the given display,
* which are invariant with regard to the active configuration.
*
@@ -436,17 +393,6 @@
int getMaxVirtualDisplayCount();
/**
- * Gets the output command message queue.
- *
- * This function must only be called inside executeCommands closure.
- *
- * @return is the descriptor of the output command queue.
- *
- * @exception EX_NO_RESOURCES when failed to get the queue temporarily.
- */
- MQDescriptor<int, SynchronizedReadWrite> getOutputCommandQueue();
-
- /**
* Returns the PerFrameMetadataKeys that are supported by this device.
*
* @param display is the display on which to create the layer.
@@ -463,8 +409,8 @@
*
* The width and height of this buffer must be those of the currently-active
* display configuration, and the usage flags must consist of the following:
- * BufferUsage::CPU_READ | BufferUsage::GPU_TEXTURE |
- * BufferUsage::COMPOSER_OUTPUT
+ * BufferUsage.CPU_READ | BufferUsage.GPU_TEXTURE |
+ * BufferUsage.COMPOSER_OUTPUT
*
* The format and dataspace provided must be sufficient such that if a
* correctly-configured buffer is passed into setReadbackBuffer, filled by
@@ -539,8 +485,8 @@
* Returns the render intents supported by the specified display and color
* mode.
*
- * For SDR color modes, RenderIntent::COLORIMETRIC must be supported. For
- * HDR color modes, RenderIntent::TONE_MAP_COLORIMETRIC must be supported.
+ * For SDR color modes, RenderIntent.COLORIMETRIC must be supported. For
+ * HDR color modes, RenderIntent.TONE_MAP_COLORIMETRIC must be supported.
*
* @param display is the display to query.
* @param mode is the color mode to query.
@@ -554,11 +500,11 @@
/**
* Provides a list of all the content types supported by this display (any of
- * ContentType::{GRAPHICS, PHOTO, CINEMA, GAME}). This list must not change after
+ * ContentType.{GRAPHICS, PHOTO, CINEMA, GAME}). This list must not change after
* initialization.
*
* Content types are introduced in HDMI 1.4 and supporting them is optional. The
- * ContentType::NONE is always supported and will not be returned by this method..
+ * ContentType.NONE is always supported and will not be returned by this method..
*
* @return out is a list of supported content types.
*
@@ -625,7 +571,7 @@
* be triggered.
*
* This function should only be called if the display reports support for
- * DisplayCapability::AUTO_LOW_LATENCY_MODE from getDisplayCapabilities_2_4.
+ * DisplayCapability.AUTO_LOW_LATENCY_MODE from getDisplayCapabilities_2_4.
*
* @exception EX_BAD_DISPLAY when an invalid display handle was passed in.
* @exception EX_UNSUPPORTED when AUTO_LOW_LATENCY_MODE is not supported by the composer
@@ -649,8 +595,8 @@
* The color mode and render intent change must take effect on next
* presentDisplay.
*
- * All devices must support at least ColorMode::NATIVE and
- * RenderIntent::COLORIMETRIC, and displays are assumed to be in this mode
+ * All devices must support at least ColorMode.NATIVE and
+ * RenderIntent.COLORIMETRIC, and displays are assumed to be in this mode
* upon hotplug.
*
* @param display is the display to which the color mode is set.
@@ -732,20 +678,12 @@
long display, boolean enable, FormatColorComponent componentMask, long maxFrames);
/**
- * Sets the input command message queue.
- *
- * @param descriptor is the descriptor of the input command message queue.
- * @exception EX_NO_RESOURCES when failed to set the queue temporarily.
- */
- void setInputCommandQueue(in MQDescriptor<int, SynchronizedReadWrite> descriptor);
-
- /**
* Sets the power mode of the given display. The transition must be
* complete when this function returns. It is valid to call this function
* multiple times with the same power mode.
*
- * All displays must support PowerMode::ON and PowerMode::OFF. Whether a
- * display supports PowerMode::DOZE or PowerMode::DOZE_SUSPEND may be
+ * All displays must support PowerMode.ON and PowerMode.OFF. Whether a
+ * display supports PowerMode.DOZE or PowerMode.DOZE_SUSPEND may be
* queried using getDozeSupport.
*
* @param display is the display to which the power mode is set.
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/LayerCommand.aidl b/graphics/composer/aidl/android/hardware/graphics/composer3/LayerCommand.aidl
new file mode 100644
index 0000000..761da9a
--- /dev/null
+++ b/graphics/composer/aidl/android/hardware/graphics/composer3/LayerCommand.aidl
@@ -0,0 +1,295 @@
+/**
+ * Copyright (c) 2021, 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.composer3;
+
+import android.hardware.common.NativeHandle;
+import android.hardware.graphics.common.FRect;
+import android.hardware.graphics.common.Point;
+import android.hardware.graphics.common.Rect;
+import android.hardware.graphics.composer3.Buffer;
+import android.hardware.graphics.composer3.Color;
+import android.hardware.graphics.composer3.FloatColor;
+import android.hardware.graphics.composer3.GenericMetadata;
+import android.hardware.graphics.composer3.ParcelableBlendMode;
+import android.hardware.graphics.composer3.ParcelableComposition;
+import android.hardware.graphics.composer3.ParcelableDataspace;
+import android.hardware.graphics.composer3.ParcelableTransform;
+import android.hardware.graphics.composer3.PerFrameMetadata;
+import android.hardware.graphics.composer3.PerFrameMetadataBlob;
+import android.hardware.graphics.composer3.PlaneAlpha;
+import android.hardware.graphics.composer3.WhitePointNits;
+import android.hardware.graphics.composer3.ZOrder;
+
+@VintfStability
+parcelable LayerCommand {
+ /**
+ * The layer which this commands refers to.
+ * @see IComposer.createLayer
+ */
+ long layer;
+
+ /**
+ * Asynchronously sets the position of a cursor layer.
+ *
+ * Prior to validateDisplay, a layer may be marked as Composition.CURSOR.
+ * If validation succeeds (i.e., the device does not request a composition
+ * change for that layer), then once a buffer has been set for the layer
+ * and it has been presented, its position may be set by this function at
+ * any time between presentDisplay and any subsequent validateDisplay
+ * calls for this display.
+ *
+ * Once validateDisplay is called, this function must not be called again
+ * until the validate/present sequence is completed.
+ *
+ * May be called from any thread so long as it is not interleaved with the
+ * validate/present sequence as described above.
+ */
+ @nullable Point cursorPosition;
+
+ /**
+ * Sets the buffer handle to be displayed for this layer. If the buffer
+ * properties set at allocation time (width, height, format, and usage)
+ * have not changed since the previous frame, it is not necessary to call
+ * validateDisplay before calling presentDisplay unless new state needs to
+ * be validated in the interim.
+ *
+ * Also provides a file descriptor referring to an acquire sync fence
+ * object, which must be signaled when it is safe to read from the given
+ * buffer. If it is already safe to read from the buffer, an empty handle
+ * may be passed instead.
+ *
+ * This function must return NONE and have no other effect if called for a
+ * layer with a composition type of Composition.SOLID_COLOR (because it
+ * has no buffer) or Composition.SIDEBAND or Composition.CLIENT (because
+ * synchronization and buffer updates for these layers are handled
+ * elsewhere).
+ */
+ @nullable Buffer buffer;
+
+ /**
+ * Provides the region of the source buffer which has been modified since
+ * the last frame. This region does not need to be validated before
+ * calling presentDisplay.
+ *
+ * Once set through this function, the damage region remains the same
+ * until a subsequent call to this function.
+ *
+ * If damage is non-empty, then it may be assumed that any portion of the
+ * source buffer not covered by one of the rects has not been modified
+ * this frame. If damage is empty, then the whole source buffer must be
+ * treated as if it has been modified.
+ *
+ * If the layer's contents are not modified relative to the prior frame,
+ * damage must contain exactly one empty rect([0, 0, 0, 0]).
+ *
+ * The damage rects are relative to the pre-transformed buffer, and their
+ * origin is the top-left corner. They must not exceed the dimensions of
+ * the latched buffer.
+ */
+ @nullable Rect[] damage;
+
+ /**
+ * Sets the blend mode of the given layer.
+ */
+ @nullable ParcelableBlendMode blendMode;
+
+ /**
+ * Sets the color of the given layer. If the composition type of the layer
+ * is not Composition.SOLID_COLOR, this call must succeed and have no
+ * other effect.
+ */
+ @nullable Color color;
+
+ /**
+ * Sets the color of the given layer. If the composition type of the layer
+ * is not Composition.SOLID_COLOR, this call must succeed and have no
+ * other effect.
+ */
+ @nullable FloatColor floatColor;
+
+ /**
+ * Sets the desired composition type of the given layer. During
+ * validateDisplay, the device may request changes to the composition
+ * types of any of the layers as described in the definition of
+ * Composition above.
+ */
+ @nullable ParcelableComposition composition;
+
+ /**
+ * Sets the dataspace of the layer.
+ *
+ * The dataspace provides more information about how to interpret the buffer
+ * or solid color, such as the encoding standard and color transform.
+ *
+ * See the values of ParcelableDataspace for more information.
+ */
+ @nullable ParcelableDataspace dataspace;
+
+ /**
+ * Sets the display frame (the portion of the display covered by a layer)
+ * of the given layer. This frame must not exceed the display dimensions.
+ */
+ @nullable Rect displayFrame;
+
+ /**
+ * Sets an alpha value (a floating point value in the range [0.0, 1.0])
+ * which will be applied to the whole layer. It can be conceptualized as a
+ * preprocessing step which applies the following function:
+ * if (blendMode == BlendMode.PREMULTIPLIED)
+ * out.rgb = in.rgb * planeAlpha
+ * out.a = in.a * planeAlpha
+ *
+ * If the device does not support this operation on a layer which is
+ * marked Composition.DEVICE, it must request a composition type change
+ * to Composition.CLIENT upon the next validateDisplay call.
+ *
+ */
+ @nullable PlaneAlpha planeAlpha;
+
+ /**
+ * Sets the sideband stream for this layer. If the composition type of the
+ * given layer is not Composition.SIDEBAND, this call must succeed and
+ * have no other effect.
+ */
+ @nullable NativeHandle sidebandStream;
+
+ /**
+ * Sets the source crop (the portion of the source buffer which will fill
+ * the display frame) of the given layer. This crop rectangle must not
+ * exceed the dimensions of the latched buffer.
+ *
+ * If the device is not capable of supporting a true float source crop
+ * (i.e., it will truncate or round the floats to integers), it must set
+ * this layer to Composition.CLIENT when crop is non-integral for the
+ * most accurate rendering.
+ *
+ * If the device cannot support float source crops, but still wants to
+ * handle the layer, it must use the following code (or similar) to
+ * convert to an integer crop:
+ * intCrop.left = (int) ceilf(crop.left);
+ * intCrop.top = (int) ceilf(crop.top);
+ * intCrop.right = (int) floorf(crop.right);
+ * intCrop.bottom = (int) floorf(crop.bottom);
+ */
+ @nullable FRect sourceCrop;
+
+ /**
+ * Sets the transform (rotation/flip) of the given layer.
+ */
+ @nullable ParcelableTransform transform;
+
+ /**
+ * Specifies the portion of the layer that is visible, including portions
+ * under translucent areas of other layers. The region is in screen space,
+ * and must not exceed the dimensions of the screen.
+ */
+ @nullable Rect[] visibleRegion;
+
+ /**
+ * Sets the desired Z order (height) of the given layer. A layer with a
+ * greater Z value occludes a layer with a lesser Z value.
+ */
+ @nullable ZOrder z;
+
+ /**
+ * Sets a matrix for color transform which will be applied on this layer
+ * before composition.
+ *
+ * If the device is not capable of apply the matrix on this layer, it must force
+ * this layer to client composition during VALIDATE_DISPLAY.
+ *
+ * The matrix provided is an affine color transformation of the following
+ * form:
+ *
+ * |r.r r.g r.b 0|
+ * |g.r g.g g.b 0|
+ * |b.r b.g b.b 0|
+ * |Tr Tg Tb 1|
+ *
+ * This matrix must be provided in row-major form:
+ *
+ * {r.r, r.g, r.b, 0, g.r, ...}.
+ *
+ * Given a matrix of this form and an input color [R_in, G_in, B_in],
+ * the input color must first be converted to linear space
+ * [R_linear, G_linear, B_linear], then the output linear color
+ * [R_out_linear, G_out_linear, B_out_linear] will be:
+ *
+ * R_out_linear = R_linear * r.r + G_linear * g.r + B_linear * b.r + Tr
+ * G_out_linear = R_linear * r.g + G_linear * g.g + B_linear * b.g + Tg
+ * B_out_linear = R_linear * r.b + G_linear * g.b + B_linear * b.b + Tb
+ *
+ * [R_out_linear, G_out_linear, B_out_linear] must then be converted to
+ * gamma space: [R_out, G_out, B_out] before blending.
+ */
+ @nullable float[] colorTransform;
+
+ /**
+ * Sets the desired white point for the layer. This is intended to be used when presenting
+ * an SDR layer alongside HDR content. The HDR content will be presented at the display
+ * brightness in nits, and accordingly SDR content shall be dimmed to the desired white point
+ * provided.
+ */
+ @nullable WhitePointNits whitePointNits;
+
+ /**
+ * Sets a piece of generic metadata for the given layer. If this
+ * function is called twice with the same key but different values, the
+ * newer value must override the older one. Calling this function with a
+ * 0-length value must reset that key's metadata as if it had not been
+ * set.
+ *
+ * A given piece of metadata may either be mandatory or a hint
+ * (non-mandatory) as indicated by the second parameter. Mandatory
+ * metadata may affect the composition result, which is to say that it
+ * may cause a visible change in the final image. By contrast, hints may
+ * only affect the composition strategy, such as which layers are
+ * composited by the client, but must not cause a visible change in the
+ * final image. The value of the mandatory flag shall match the value
+ * returned from getLayerGenericMetadataKeys for the given key.
+ *
+ * Only keys which have been returned from getLayerGenericMetadataKeys()
+ * shall be accepted. Any other keys must result in an UNSUPPORTED error.
+ *
+ * The value passed into this function shall be the binary
+ * representation of a stable AIDL type corresponding to the given key. For
+ * example, a key of 'com.example.Foo-V2' shall be paired with a
+ * value of type com.exampleFoo-V2, which would be defined in a
+ * vendor HAL extension.
+ */
+ @nullable GenericMetadata genericMetadata;
+
+ /**
+ * Sets the PerFrameMetadata for the display. This metadata must be used
+ * by the implementation to better tone map content to that display.
+ *
+ * This is a command that may be called every frame.
+ */
+ @nullable PerFrameMetadata[] perFrameMetadata;
+
+ /**
+ * This command sends metadata that may be used for tone-mapping the
+ * associated layer. The metadata structure follows a {key, blob}
+ * format (see the PerFrameMetadataBlob struct). All keys must be
+ * returned by a prior call to getPerFrameMetadataKeys and must
+ * be part of the list of keys associated with blob-type metadata
+ * (see PerFrameMetadataKey).
+ *
+ * This command may be called every frame.
+ */
+ @nullable PerFrameMetadataBlob[] perFrameMetadataBlob;
+}
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/LayerRequest.aidl b/graphics/composer/aidl/android/hardware/graphics/composer3/ParcelableBlendMode.aidl
similarity index 68%
copy from graphics/composer/aidl/android/hardware/graphics/composer3/LayerRequest.aidl
copy to graphics/composer/aidl/android/hardware/graphics/composer3/ParcelableBlendMode.aidl
index 10de558..a6c016a 100644
--- a/graphics/composer/aidl/android/hardware/graphics/composer3/LayerRequest.aidl
+++ b/graphics/composer/aidl/android/hardware/graphics/composer3/ParcelableBlendMode.aidl
@@ -16,16 +16,9 @@
package android.hardware.graphics.composer3;
-/**
- * Layer requests returned from getDisplayRequests.
- */
+import android.hardware.graphics.common.BlendMode;
+
@VintfStability
-@Backing(type="int")
-enum LayerRequest {
- /**
- * The client must clear its target with transparent pixels where
- * this layer would be. The client may ignore this request if the
- * layer must be blended.
- */
- CLEAR_CLIENT_TARGET = 1 << 0,
+parcelable ParcelableBlendMode {
+ BlendMode blendMode;
}
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/LayerRequest.aidl b/graphics/composer/aidl/android/hardware/graphics/composer3/ParcelableComposition.aidl
similarity index 68%
copy from graphics/composer/aidl/android/hardware/graphics/composer3/LayerRequest.aidl
copy to graphics/composer/aidl/android/hardware/graphics/composer3/ParcelableComposition.aidl
index 10de558..0946ce7 100644
--- a/graphics/composer/aidl/android/hardware/graphics/composer3/LayerRequest.aidl
+++ b/graphics/composer/aidl/android/hardware/graphics/composer3/ParcelableComposition.aidl
@@ -16,16 +16,9 @@
package android.hardware.graphics.composer3;
-/**
- * Layer requests returned from getDisplayRequests.
- */
+import android.hardware.graphics.composer3.Composition;
+
@VintfStability
-@Backing(type="int")
-enum LayerRequest {
- /**
- * The client must clear its target with transparent pixels where
- * this layer would be. The client may ignore this request if the
- * layer must be blended.
- */
- CLEAR_CLIENT_TARGET = 1 << 0,
+parcelable ParcelableComposition {
+ Composition composition;
}
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/LayerRequest.aidl b/graphics/composer/aidl/android/hardware/graphics/composer3/ParcelableDataspace.aidl
similarity index 68%
copy from graphics/composer/aidl/android/hardware/graphics/composer3/LayerRequest.aidl
copy to graphics/composer/aidl/android/hardware/graphics/composer3/ParcelableDataspace.aidl
index 10de558..528cdf9 100644
--- a/graphics/composer/aidl/android/hardware/graphics/composer3/LayerRequest.aidl
+++ b/graphics/composer/aidl/android/hardware/graphics/composer3/ParcelableDataspace.aidl
@@ -16,16 +16,9 @@
package android.hardware.graphics.composer3;
-/**
- * Layer requests returned from getDisplayRequests.
- */
+import android.hardware.graphics.common.Dataspace;
+
@VintfStability
-@Backing(type="int")
-enum LayerRequest {
- /**
- * The client must clear its target with transparent pixels where
- * this layer would be. The client may ignore this request if the
- * layer must be blended.
- */
- CLEAR_CLIENT_TARGET = 1 << 0,
+parcelable ParcelableDataspace {
+ Dataspace dataspace;
}
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/LayerRequest.aidl b/graphics/composer/aidl/android/hardware/graphics/composer3/ParcelableTransform.aidl
similarity index 68%
copy from graphics/composer/aidl/android/hardware/graphics/composer3/LayerRequest.aidl
copy to graphics/composer/aidl/android/hardware/graphics/composer3/ParcelableTransform.aidl
index 10de558..75f9f7e 100644
--- a/graphics/composer/aidl/android/hardware/graphics/composer3/LayerRequest.aidl
+++ b/graphics/composer/aidl/android/hardware/graphics/composer3/ParcelableTransform.aidl
@@ -16,16 +16,9 @@
package android.hardware.graphics.composer3;
-/**
- * Layer requests returned from getDisplayRequests.
- */
+import android.hardware.graphics.common.Transform;
+
@VintfStability
-@Backing(type="int")
-enum LayerRequest {
- /**
- * The client must clear its target with transparent pixels where
- * this layer would be. The client may ignore this request if the
- * layer must be blended.
- */
- CLEAR_CLIENT_TARGET = 1 << 0,
+parcelable ParcelableTransform {
+ Transform transform;
}
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/PerFrameMetadataKey.aidl b/graphics/composer/aidl/android/hardware/graphics/composer3/PerFrameMetadataKey.aidl
index b666e6a..3962920 100644
--- a/graphics/composer/aidl/android/hardware/graphics/composer3/PerFrameMetadataKey.aidl
+++ b/graphics/composer/aidl/android/hardware/graphics/composer3/PerFrameMetadataKey.aidl
@@ -16,8 +16,6 @@
package android.hardware.graphics.composer3;
-import android.hardware.graphics.composer3.PerFrameMetadataKey;
-
/**
* PerFrameMetadataKey
*
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/LayerRequest.aidl b/graphics/composer/aidl/android/hardware/graphics/composer3/PlaneAlpha.aidl
similarity index 69%
copy from graphics/composer/aidl/android/hardware/graphics/composer3/LayerRequest.aidl
copy to graphics/composer/aidl/android/hardware/graphics/composer3/PlaneAlpha.aidl
index 10de558..347dc19 100644
--- a/graphics/composer/aidl/android/hardware/graphics/composer3/LayerRequest.aidl
+++ b/graphics/composer/aidl/android/hardware/graphics/composer3/PlaneAlpha.aidl
@@ -16,16 +16,12 @@
package android.hardware.graphics.composer3;
-/**
- * Layer requests returned from getDisplayRequests.
- */
@VintfStability
-@Backing(type="int")
-enum LayerRequest {
+parcelable PlaneAlpha {
/**
- * The client must clear its target with transparent pixels where
- * this layer would be. The client may ignore this request if the
- * layer must be blended.
+ * An alpha value (a floating point value in the range [0.0, 1.0])
+ * which will be applied to a whole layer.
+ * @see LayerCommand.planeAlpha
*/
- CLEAR_CLIENT_TARGET = 1 << 0,
+ float alpha;
}
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/LayerRequest.aidl b/graphics/composer/aidl/android/hardware/graphics/composer3/PresentFence.aidl
similarity index 69%
rename from graphics/composer/aidl/android/hardware/graphics/composer3/LayerRequest.aidl
rename to graphics/composer/aidl/android/hardware/graphics/composer3/PresentFence.aidl
index 10de558..244b4e5 100644
--- a/graphics/composer/aidl/android/hardware/graphics/composer3/LayerRequest.aidl
+++ b/graphics/composer/aidl/android/hardware/graphics/composer3/PresentFence.aidl
@@ -16,16 +16,16 @@
package android.hardware.graphics.composer3;
-/**
- * Layer requests returned from getDisplayRequests.
- */
@VintfStability
-@Backing(type="int")
-enum LayerRequest {
+parcelable PresentFence {
/**
- * The client must clear its target with transparent pixels where
- * this layer would be. The client may ignore this request if the
- * layer must be blended.
+ * The display which this commands refers to.
+ * @see IComposer.createDisplay
*/
- CLEAR_CLIENT_TARGET = 1 << 0,
+ long display;
+
+ /**
+ * The present fence for this display.
+ */
+ ParcelFileDescriptor fence;
}
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/LayerRequest.aidl b/graphics/composer/aidl/android/hardware/graphics/composer3/PresentOrValidate.aidl
similarity index 69%
copy from graphics/composer/aidl/android/hardware/graphics/composer3/LayerRequest.aidl
copy to graphics/composer/aidl/android/hardware/graphics/composer3/PresentOrValidate.aidl
index 10de558..f3153bd 100644
--- a/graphics/composer/aidl/android/hardware/graphics/composer3/LayerRequest.aidl
+++ b/graphics/composer/aidl/android/hardware/graphics/composer3/PresentOrValidate.aidl
@@ -16,16 +16,17 @@
package android.hardware.graphics.composer3;
-/**
- * Layer requests returned from getDisplayRequests.
- */
@VintfStability
-@Backing(type="int")
-enum LayerRequest {
+parcelable PresentOrValidate {
/**
- * The client must clear its target with transparent pixels where
- * this layer would be. The client may ignore this request if the
- * layer must be blended.
+ * The display which this commands refers to.
+ * @see IComposer.createDisplay
*/
- CLEAR_CLIENT_TARGET = 1 << 0,
+ long display;
+
+ /**
+ * Whether PresentOrValidate presented or validated the display.
+ */
+ @VintfStability enum Result { Presented, Validated }
+ Result result;
}
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/ReleaseFences.aidl b/graphics/composer/aidl/android/hardware/graphics/composer3/ReleaseFences.aidl
new file mode 100644
index 0000000..459a042
--- /dev/null
+++ b/graphics/composer/aidl/android/hardware/graphics/composer3/ReleaseFences.aidl
@@ -0,0 +1,44 @@
+/**
+ * Copyright (c) 2021, 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.composer3;
+
+@VintfStability
+parcelable ReleaseFences {
+ /**
+ * The display which this commands refers to.
+ * @see IComposer.createDisplay
+ */
+ long display;
+ @VintfStability
+ parcelable Layer {
+ /**
+ * The layer which this commands refers to.
+ * @see IComposer.createLayer
+ */
+ long layer;
+
+ /**
+ * The release fence for this layer.
+ */
+ ParcelFileDescriptor fence;
+ }
+
+ /**
+ * The layers which has release fences.
+ */
+ Layer[] layers;
+}
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/RenderIntent.aidl b/graphics/composer/aidl/android/hardware/graphics/composer3/RenderIntent.aidl
index 043b24d..debf32c 100644
--- a/graphics/composer/aidl/android/hardware/graphics/composer3/RenderIntent.aidl
+++ b/graphics/composer/aidl/android/hardware/graphics/composer3/RenderIntent.aidl
@@ -25,8 +25,8 @@
* modes should not affect the mapping.
*
* RenderIntent overrides the render intents defined for individual color
- * modes. It is ignored when the color mode is ColorMode::NATIVE, because
- * ColorMode::NATIVE colors are already display colors.
+ * modes. It is ignored when the color mode is ColorMode.NATIVE, because
+ * ColorMode.NATIVE colors are already display colors.
*/
@VintfStability
@Backing(type="int")
@@ -36,7 +36,7 @@
* gamut are hard-clipped.
*
* This implies that the display must have been calibrated unless
- * ColorMode::NATIVE is the only supported color mode.
+ * ColorMode.NATIVE is the only supported color mode.
*/
COLORIMETRIC = 0,
/**
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/LayerRequest.aidl b/graphics/composer/aidl/android/hardware/graphics/composer3/WhitePointNits.aidl
similarity index 64%
copy from graphics/composer/aidl/android/hardware/graphics/composer3/LayerRequest.aidl
copy to graphics/composer/aidl/android/hardware/graphics/composer3/WhitePointNits.aidl
index 10de558..2a1d1c6 100644
--- a/graphics/composer/aidl/android/hardware/graphics/composer3/LayerRequest.aidl
+++ b/graphics/composer/aidl/android/hardware/graphics/composer3/WhitePointNits.aidl
@@ -16,16 +16,14 @@
package android.hardware.graphics.composer3;
-/**
- * Layer requests returned from getDisplayRequests.
- */
@VintfStability
-@Backing(type="int")
-enum LayerRequest {
+parcelable WhitePointNits {
/**
- * The client must clear its target with transparent pixels where
- * this layer would be. The client may ignore this request if the
- * layer must be blended.
+ * The desired white point for the layer. This is intended to be used when presenting
+ * an SDR layer alongside HDR content. The HDR content will be presented at the display
+ * brightness in nits, and accordingly SDR content shall be dimmed to the desired white point
+ * provided.
+ * @see LayerCommand.whitePointNits.
*/
- CLEAR_CLIENT_TARGET = 1 << 0,
+ float nits;
}
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/LayerRequest.aidl b/graphics/composer/aidl/android/hardware/graphics/composer3/ZOrder.aidl
similarity index 69%
copy from graphics/composer/aidl/android/hardware/graphics/composer3/LayerRequest.aidl
copy to graphics/composer/aidl/android/hardware/graphics/composer3/ZOrder.aidl
index 10de558..56cc200 100644
--- a/graphics/composer/aidl/android/hardware/graphics/composer3/LayerRequest.aidl
+++ b/graphics/composer/aidl/android/hardware/graphics/composer3/ZOrder.aidl
@@ -16,16 +16,12 @@
package android.hardware.graphics.composer3;
-/**
- * Layer requests returned from getDisplayRequests.
- */
@VintfStability
-@Backing(type="int")
-enum LayerRequest {
+parcelable ZOrder {
/**
- * The client must clear its target with transparent pixels where
- * this layer would be. The client may ignore this request if the
- * layer must be blended.
+ * The desired Z order (height) of the given layer. A layer with a
+ * greater Z value occludes a layer with a lesser Z value.
+ * @see LayerCommand.z;
*/
- CLEAR_CLIENT_TARGET = 1 << 0,
+ int z;
}
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/translate-ndk.cpp b/graphics/composer/aidl/android/hardware/graphics/composer3/translate-ndk.cpp
index d59190d..a3c8176 100644
--- a/graphics/composer/aidl/android/hardware/graphics/composer3/translate-ndk.cpp
+++ b/graphics/composer/aidl/android/hardware/graphics/composer3/translate-ndk.cpp
@@ -74,25 +74,25 @@
static_assert(aidl::android::hardware::graphics::composer3::Capability::SKIP_VALIDATE ==
static_cast<aidl::android::hardware::graphics::composer3::Capability>(4));
-static_assert(aidl::android::hardware::graphics::composer3::LayerRequest::CLEAR_CLIENT_TARGET ==
- static_cast<aidl::android::hardware::graphics::composer3::LayerRequest>(
- ::android::hardware::graphics::composer::V2_1::IComposerClient::LayerRequest::
- CLEAR_CLIENT_TARGET));
+static_assert(aidl::android::hardware::graphics::composer3::DisplayRequest::LayerRequest::
+ CLEAR_CLIENT_TARGET ==
+ static_cast<int>(::android::hardware::graphics::composer::V2_1::IComposerClient::
+ LayerRequest::CLEAR_CLIENT_TARGET));
-static_assert(aidl::android::hardware::graphics::composer3::BlendMode::INVALID ==
- static_cast<aidl::android::hardware::graphics::composer3::BlendMode>(
+static_assert(aidl::android::hardware::graphics::common::BlendMode::INVALID ==
+ static_cast<aidl::android::hardware::graphics::common::BlendMode>(
::android::hardware::graphics::composer::V2_1::IComposerClient::BlendMode::
INVALID));
static_assert(
- aidl::android::hardware::graphics::composer3::BlendMode::NONE ==
- static_cast<aidl::android::hardware::graphics::composer3::BlendMode>(
+ aidl::android::hardware::graphics::common::BlendMode::NONE ==
+ static_cast<aidl::android::hardware::graphics::common::BlendMode>(
::android::hardware::graphics::composer::V2_1::IComposerClient::BlendMode::NONE));
-static_assert(aidl::android::hardware::graphics::composer3::BlendMode::PREMULTIPLIED ==
- static_cast<aidl::android::hardware::graphics::composer3::BlendMode>(
+static_assert(aidl::android::hardware::graphics::common::BlendMode::PREMULTIPLIED ==
+ static_cast<aidl::android::hardware::graphics::common::BlendMode>(
::android::hardware::graphics::composer::V2_1::IComposerClient::BlendMode::
PREMULTIPLIED));
-static_assert(aidl::android::hardware::graphics::composer3::BlendMode::COVERAGE ==
- static_cast<aidl::android::hardware::graphics::composer3::BlendMode>(
+static_assert(aidl::android::hardware::graphics::common::BlendMode::COVERAGE ==
+ static_cast<aidl::android::hardware::graphics::common::BlendMode>(
::android::hardware::graphics::composer::V2_1::IComposerClient::BlendMode::
COVERAGE));
@@ -122,14 +122,12 @@
SIDEBAND));
static_assert(aidl::android::hardware::graphics::composer3::DisplayRequest::FLIP_CLIENT_TARGET ==
- static_cast<aidl::android::hardware::graphics::composer3::DisplayRequest>(
- ::android::hardware::graphics::composer::V2_1::IComposerClient::
- DisplayRequest::FLIP_CLIENT_TARGET));
+ static_cast<int>(::android::hardware::graphics::composer::V2_1::IComposerClient::
+ DisplayRequest::FLIP_CLIENT_TARGET));
static_assert(aidl::android::hardware::graphics::composer3::DisplayRequest::
WRITE_CLIENT_TARGET_TO_OUTPUT ==
- static_cast<aidl::android::hardware::graphics::composer3::DisplayRequest>(
- ::android::hardware::graphics::composer::V2_1::IComposerClient::
- DisplayRequest::WRITE_CLIENT_TARGET_TO_OUTPUT));
+ static_cast<int>(::android::hardware::graphics::composer::V2_1::IComposerClient::
+ DisplayRequest::WRITE_CLIENT_TARGET_TO_OUTPUT));
static_assert(aidl::android::hardware::graphics::composer3::HandleIndex::EMPTY ==
static_cast<aidl::android::hardware::graphics::composer3::HandleIndex>(
@@ -188,162 +186,6 @@
::android::hardware::graphics::composer::V2_4::IComposerClient::DisplayCapability::
AUTO_LOW_LATENCY_MODE));
-static_assert(aidl::android::hardware::graphics::composer3::Command::LENGTH_MASK ==
- static_cast<aidl::android::hardware::graphics::composer3::Command>(
- ::android::hardware::graphics::composer::V2_4::IComposerClient::Command::
- LENGTH_MASK));
-static_assert(aidl::android::hardware::graphics::composer3::Command::OPCODE_SHIFT ==
- static_cast<aidl::android::hardware::graphics::composer3::Command>(
- ::android::hardware::graphics::composer::V2_4::IComposerClient::Command::
- OPCODE_SHIFT));
-static_assert(aidl::android::hardware::graphics::composer3::Command::OPCODE_MASK ==
- static_cast<aidl::android::hardware::graphics::composer3::Command>(
- ::android::hardware::graphics::composer::V2_4::IComposerClient::Command::
- OPCODE_MASK));
-static_assert(aidl::android::hardware::graphics::composer3::Command::SELECT_DISPLAY ==
- static_cast<aidl::android::hardware::graphics::composer3::Command>(
- ::android::hardware::graphics::composer::V2_4::IComposerClient::Command::
- SELECT_DISPLAY));
-static_assert(aidl::android::hardware::graphics::composer3::Command::SELECT_LAYER ==
- static_cast<aidl::android::hardware::graphics::composer3::Command>(
- ::android::hardware::graphics::composer::V2_4::IComposerClient::Command::
- SELECT_LAYER));
-static_assert(aidl::android::hardware::graphics::composer3::Command::SET_ERROR ==
- static_cast<aidl::android::hardware::graphics::composer3::Command>(
- ::android::hardware::graphics::composer::V2_4::IComposerClient::Command::
- SET_ERROR));
-static_assert(
- aidl::android::hardware::graphics::composer3::Command::SET_CHANGED_COMPOSITION_TYPES ==
- static_cast<aidl::android::hardware::graphics::composer3::Command>(
- ::android::hardware::graphics::composer::V2_4::IComposerClient::Command::
- SET_CHANGED_COMPOSITION_TYPES));
-static_assert(aidl::android::hardware::graphics::composer3::Command::SET_DISPLAY_REQUESTS ==
- static_cast<aidl::android::hardware::graphics::composer3::Command>(
- ::android::hardware::graphics::composer::V2_4::IComposerClient::Command::
- SET_DISPLAY_REQUESTS));
-static_assert(aidl::android::hardware::graphics::composer3::Command::SET_PRESENT_FENCE ==
- static_cast<aidl::android::hardware::graphics::composer3::Command>(
- ::android::hardware::graphics::composer::V2_4::IComposerClient::Command::
- SET_PRESENT_FENCE));
-static_assert(aidl::android::hardware::graphics::composer3::Command::SET_RELEASE_FENCES ==
- static_cast<aidl::android::hardware::graphics::composer3::Command>(
- ::android::hardware::graphics::composer::V2_4::IComposerClient::Command::
- SET_RELEASE_FENCES));
-static_assert(aidl::android::hardware::graphics::composer3::Command::SET_COLOR_TRANSFORM ==
- static_cast<aidl::android::hardware::graphics::composer3::Command>(
- ::android::hardware::graphics::composer::V2_4::IComposerClient::Command::
- SET_COLOR_TRANSFORM));
-static_assert(aidl::android::hardware::graphics::composer3::Command::SET_CLIENT_TARGET ==
- static_cast<aidl::android::hardware::graphics::composer3::Command>(
- ::android::hardware::graphics::composer::V2_4::IComposerClient::Command::
- SET_CLIENT_TARGET));
-static_assert(aidl::android::hardware::graphics::composer3::Command::SET_OUTPUT_BUFFER ==
- static_cast<aidl::android::hardware::graphics::composer3::Command>(
- ::android::hardware::graphics::composer::V2_4::IComposerClient::Command::
- SET_OUTPUT_BUFFER));
-static_assert(aidl::android::hardware::graphics::composer3::Command::VALIDATE_DISPLAY ==
- static_cast<aidl::android::hardware::graphics::composer3::Command>(
- ::android::hardware::graphics::composer::V2_4::IComposerClient::Command::
- VALIDATE_DISPLAY));
-static_assert(aidl::android::hardware::graphics::composer3::Command::ACCEPT_DISPLAY_CHANGES ==
- static_cast<aidl::android::hardware::graphics::composer3::Command>(
- ::android::hardware::graphics::composer::V2_4::IComposerClient::Command::
- ACCEPT_DISPLAY_CHANGES));
-static_assert(aidl::android::hardware::graphics::composer3::Command::PRESENT_DISPLAY ==
- static_cast<aidl::android::hardware::graphics::composer3::Command>(
- ::android::hardware::graphics::composer::V2_4::IComposerClient::Command::
- PRESENT_DISPLAY));
-static_assert(aidl::android::hardware::graphics::composer3::Command::PRESENT_OR_VALIDATE_DISPLAY ==
- static_cast<aidl::android::hardware::graphics::composer3::Command>(
- ::android::hardware::graphics::composer::V2_4::IComposerClient::Command::
- PRESENT_OR_VALIDATE_DISPLAY));
-static_assert(aidl::android::hardware::graphics::composer3::Command::SET_LAYER_CURSOR_POSITION ==
- static_cast<aidl::android::hardware::graphics::composer3::Command>(
- ::android::hardware::graphics::composer::V2_4::IComposerClient::Command::
- SET_LAYER_CURSOR_POSITION));
-static_assert(aidl::android::hardware::graphics::composer3::Command::SET_LAYER_BUFFER ==
- static_cast<aidl::android::hardware::graphics::composer3::Command>(
- ::android::hardware::graphics::composer::V2_4::IComposerClient::Command::
- SET_LAYER_BUFFER));
-static_assert(aidl::android::hardware::graphics::composer3::Command::SET_LAYER_SURFACE_DAMAGE ==
- static_cast<aidl::android::hardware::graphics::composer3::Command>(
- ::android::hardware::graphics::composer::V2_4::IComposerClient::Command::
- SET_LAYER_SURFACE_DAMAGE));
-static_assert(aidl::android::hardware::graphics::composer3::Command::SET_LAYER_BLEND_MODE ==
- static_cast<aidl::android::hardware::graphics::composer3::Command>(
- ::android::hardware::graphics::composer::V2_4::IComposerClient::Command::
- SET_LAYER_BLEND_MODE));
-static_assert(aidl::android::hardware::graphics::composer3::Command::SET_LAYER_COLOR ==
- static_cast<aidl::android::hardware::graphics::composer3::Command>(
- ::android::hardware::graphics::composer::V2_4::IComposerClient::Command::
- SET_LAYER_COLOR));
-static_assert(aidl::android::hardware::graphics::composer3::Command::SET_LAYER_COMPOSITION_TYPE ==
- static_cast<aidl::android::hardware::graphics::composer3::Command>(
- ::android::hardware::graphics::composer::V2_4::IComposerClient::Command::
- SET_LAYER_COMPOSITION_TYPE));
-static_assert(aidl::android::hardware::graphics::composer3::Command::SET_LAYER_DATASPACE ==
- static_cast<aidl::android::hardware::graphics::composer3::Command>(
- ::android::hardware::graphics::composer::V2_4::IComposerClient::Command::
- SET_LAYER_DATASPACE));
-static_assert(aidl::android::hardware::graphics::composer3::Command::SET_LAYER_DISPLAY_FRAME ==
- static_cast<aidl::android::hardware::graphics::composer3::Command>(
- ::android::hardware::graphics::composer::V2_4::IComposerClient::Command::
- SET_LAYER_DISPLAY_FRAME));
-static_assert(aidl::android::hardware::graphics::composer3::Command::SET_LAYER_PLANE_ALPHA ==
- static_cast<aidl::android::hardware::graphics::composer3::Command>(
- ::android::hardware::graphics::composer::V2_4::IComposerClient::Command::
- SET_LAYER_PLANE_ALPHA));
-static_assert(aidl::android::hardware::graphics::composer3::Command::SET_LAYER_SIDEBAND_STREAM ==
- static_cast<aidl::android::hardware::graphics::composer3::Command>(
- ::android::hardware::graphics::composer::V2_4::IComposerClient::Command::
- SET_LAYER_SIDEBAND_STREAM));
-static_assert(aidl::android::hardware::graphics::composer3::Command::SET_LAYER_SOURCE_CROP ==
- static_cast<aidl::android::hardware::graphics::composer3::Command>(
- ::android::hardware::graphics::composer::V2_4::IComposerClient::Command::
- SET_LAYER_SOURCE_CROP));
-static_assert(aidl::android::hardware::graphics::composer3::Command::SET_LAYER_TRANSFORM ==
- static_cast<aidl::android::hardware::graphics::composer3::Command>(
- ::android::hardware::graphics::composer::V2_4::IComposerClient::Command::
- SET_LAYER_TRANSFORM));
-static_assert(aidl::android::hardware::graphics::composer3::Command::SET_LAYER_VISIBLE_REGION ==
- static_cast<aidl::android::hardware::graphics::composer3::Command>(
- ::android::hardware::graphics::composer::V2_4::IComposerClient::Command::
- SET_LAYER_VISIBLE_REGION));
-static_assert(aidl::android::hardware::graphics::composer3::Command::SET_LAYER_Z_ORDER ==
- static_cast<aidl::android::hardware::graphics::composer3::Command>(
- ::android::hardware::graphics::composer::V2_4::IComposerClient::Command::
- SET_LAYER_Z_ORDER));
-static_assert(aidl::android::hardware::graphics::composer3::Command::
- SET_PRESENT_OR_VALIDATE_DISPLAY_RESULT ==
- static_cast<aidl::android::hardware::graphics::composer3::Command>(
- ::android::hardware::graphics::composer::V2_4::IComposerClient::Command::
- SET_PRESENT_OR_VALIDATE_DISPLAY_RESULT));
-static_assert(aidl::android::hardware::graphics::composer3::Command::SET_LAYER_PER_FRAME_METADATA ==
- static_cast<aidl::android::hardware::graphics::composer3::Command>(
- ::android::hardware::graphics::composer::V2_4::IComposerClient::Command::
- SET_LAYER_PER_FRAME_METADATA));
-static_assert(aidl::android::hardware::graphics::composer3::Command::SET_LAYER_FLOAT_COLOR ==
- static_cast<aidl::android::hardware::graphics::composer3::Command>(
- ::android::hardware::graphics::composer::V2_4::IComposerClient::Command::
- SET_LAYER_FLOAT_COLOR));
-static_assert(aidl::android::hardware::graphics::composer3::Command::SET_LAYER_COLOR_TRANSFORM ==
- static_cast<aidl::android::hardware::graphics::composer3::Command>(
- ::android::hardware::graphics::composer::V2_4::IComposerClient::Command::
- SET_LAYER_COLOR_TRANSFORM));
-static_assert(
- aidl::android::hardware::graphics::composer3::Command::SET_LAYER_PER_FRAME_METADATA_BLOBS ==
- static_cast<aidl::android::hardware::graphics::composer3::Command>(
- ::android::hardware::graphics::composer::V2_4::IComposerClient::Command::
- SET_LAYER_PER_FRAME_METADATA_BLOBS));
-static_assert(aidl::android::hardware::graphics::composer3::Command::SET_CLIENT_TARGET_PROPERTY ==
- static_cast<aidl::android::hardware::graphics::composer3::Command>(
- ::android::hardware::graphics::composer::V2_4::IComposerClient::Command::
- SET_CLIENT_TARGET_PROPERTY));
-static_assert(aidl::android::hardware::graphics::composer3::Command::SET_LAYER_GENERIC_METADATA ==
- static_cast<aidl::android::hardware::graphics::composer3::Command>(
- ::android::hardware::graphics::composer::V2_4::IComposerClient::Command::
- SET_LAYER_GENERIC_METADATA));
-
static_assert(aidl::android::hardware::graphics::composer3::DisplayAttribute::INVALID ==
static_cast<aidl::android::hardware::graphics::composer3::DisplayAttribute>(
::android::hardware::graphics::composer::V2_4::IComposerClient::Attribute::
@@ -612,4 +454,4 @@
return true;
}
-} // namespace android::h2a
\ No newline at end of file
+} // namespace android::h2a
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/Android.bp b/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/Android.bp
index c011f73..741572d 100644
--- a/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/Android.bp
+++ b/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/Android.bp
@@ -19,7 +19,7 @@
// A large-scale-change added 'default_applicable_licenses' to import
// all of the 'license_kinds' from "hardware_interfaces_license"
// to get the below license kinds:
- // SPDX-license-identifier-Apache-2.0
+ // SPDX-license-identifier-Apache-2.0
default_applicable_licenses: ["hardware_interfaces_license"],
}
@@ -28,20 +28,28 @@
defaults: [
"VtsHalTargetTestDefaults",
"use_libaidlvintf_gtest_helper_static",
+ // Needed for librenderengine
+ "skia_deps",
],
srcs: [
"VtsHalGraphicsComposer3_TargetTest.cpp",
+ "VtsHalGraphicsComposer3_ReadbackTest.cpp",
"composer-vts/GraphicsComposerCallback.cpp",
- "composer-vts/TestCommandReader.cpp",
],
shared_libs: [
+ "libEGL",
+ "libGLESv1_CM",
+ "libGLESv2",
"libbinder_ndk",
"libbinder",
"libfmq",
"libbase",
"libsync",
"libui",
+ "libgui",
+ "libhidlbase",
+ "libprocessgroup",
"android.hardware.graphics.mapper@2.0",
"android.hardware.graphics.mapper@2.1",
"android.hardware.graphics.mapper@3.0",
@@ -69,6 +77,10 @@
"android.hardware.graphics.mapper@3.0-vts",
"android.hardware.graphics.mapper@4.0-vts",
"libaidlcommonsupport",
+ "libgtest",
+ "librenderengine",
+ "libshaders",
+ "libtonemap",
],
cflags: [
"-Wconversion",
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/VtsHalGraphicsComposer3_ReadbackTest.cpp b/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/VtsHalGraphicsComposer3_ReadbackTest.cpp
new file mode 100644
index 0000000..8726043
--- /dev/null
+++ b/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/VtsHalGraphicsComposer3_ReadbackTest.cpp
@@ -0,0 +1,1329 @@
+/**
+ * Copyright (c) 2021, 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 "graphics_composer_aidl_hal_readback_tests@3"
+
+#include <aidl/Gtest.h>
+#include <aidl/Vintf.h>
+#include <aidl/android/hardware/graphics/common/BufferUsage.h>
+#include <android/binder_manager.h>
+#include <composer-vts/include/ReadbackVts.h>
+#include <composer-vts/include/RenderEngineVts.h>
+#include <gtest/gtest.h>
+#include <ui/GraphicBuffer.h>
+#include <ui/GraphicBufferAllocator.h>
+#include <ui/PixelFormat.h>
+#include <ui/Rect.h>
+#include "composer-vts/include/GraphicsComposerCallback.h"
+
+namespace aidl::android::hardware::graphics::composer3::vts {
+namespace {
+
+using ::android::Rect;
+using common::Dataspace;
+using common::PixelFormat;
+
+class GraphicsCompositionTestBase : public ::testing::Test {
+ protected:
+ void SetUpBase(const std::string& name) {
+ ndk::SpAIBinder binder(AServiceManager_waitForService(name.c_str()));
+ ASSERT_NE(binder, nullptr);
+ ASSERT_NO_FATAL_FAILURE(mComposer = IComposer::fromBinder(binder));
+ ASSERT_NE(mComposer, nullptr);
+ ASSERT_NO_FATAL_FAILURE(mComposer->createClient(&mComposerClient));
+ mComposerCallback = ::ndk::SharedRefBase::make<GraphicsComposerCallback>();
+ mComposerClient->registerCallback(mComposerCallback);
+
+ // assume the first display is primary and is never removed
+ mPrimaryDisplay = waitForFirstDisplay();
+
+ ASSERT_NO_FATAL_FAILURE(mInvalidDisplayId = GetInvalidDisplayId());
+
+ int32_t activeConfig;
+ EXPECT_TRUE(mComposerClient->getActiveConfig(mPrimaryDisplay, &activeConfig).isOk());
+ EXPECT_TRUE(mComposerClient
+ ->getDisplayAttribute(mPrimaryDisplay, activeConfig,
+ DisplayAttribute::WIDTH, &mDisplayWidth)
+ .isOk());
+ EXPECT_TRUE(mComposerClient
+ ->getDisplayAttribute(mPrimaryDisplay, activeConfig,
+ DisplayAttribute::HEIGHT, &mDisplayHeight)
+ .isOk());
+
+ setTestColorModes();
+
+ // explicitly disable vsync
+ EXPECT_TRUE(mComposerClient->setVsyncEnabled(mPrimaryDisplay, false).isOk());
+ mComposerCallback->setVsyncAllowed(false);
+
+ // set up gralloc
+ mGraphicBuffer = allocate();
+
+ ASSERT_NO_FATAL_FAILURE(mComposerClient->setPowerMode(mPrimaryDisplay, PowerMode::ON));
+
+ ASSERT_NO_FATAL_FAILURE(
+ mTestRenderEngine = std::unique_ptr<TestRenderEngine>(new TestRenderEngine(
+ ::android::renderengine::RenderEngineCreationArgs::Builder()
+ .setPixelFormat(static_cast<int>(common::PixelFormat::RGBA_8888))
+ .setImageCacheSize(TestRenderEngine::sMaxFrameBufferAcquireBuffers)
+ .setUseColorManagerment(true)
+ .setEnableProtectedContext(false)
+ .setPrecacheToneMapperShaderOnly(false)
+ .setContextPriority(::android::renderengine::RenderEngine::
+ ContextPriority::HIGH)
+ .build())));
+
+ ::android::renderengine::DisplaySettings clientCompositionDisplay;
+ clientCompositionDisplay.physicalDisplay = Rect(mDisplayWidth, mDisplayHeight);
+ clientCompositionDisplay.clip = clientCompositionDisplay.physicalDisplay;
+
+ mTestRenderEngine->initGraphicBuffer(
+ static_cast<uint32_t>(mDisplayWidth), static_cast<uint32_t>(mDisplayHeight), 1,
+ static_cast<uint64_t>(
+ static_cast<uint64_t>(common::BufferUsage::CPU_READ_OFTEN) |
+ static_cast<uint64_t>(common::BufferUsage::CPU_WRITE_OFTEN) |
+ static_cast<uint64_t>(common::BufferUsage::GPU_RENDER_TARGET)));
+ mTestRenderEngine->setDisplaySettings(clientCompositionDisplay);
+ }
+
+ void TearDown() override {
+ ASSERT_NO_FATAL_FAILURE(mComposerClient->setPowerMode(mPrimaryDisplay, PowerMode::OFF));
+ const auto errors = mReader.takeErrors();
+ ASSERT_TRUE(mReader.takeErrors().empty());
+
+ std::vector<int64_t> layers;
+ std::vector<Composition> types;
+ mReader.takeChangedCompositionTypes(mPrimaryDisplay, &layers, &types);
+
+ ASSERT_TRUE(layers.empty());
+ ASSERT_TRUE(types.empty());
+ if (mComposerCallback != nullptr) {
+ EXPECT_EQ(0, mComposerCallback->getInvalidHotplugCount());
+ EXPECT_EQ(0, mComposerCallback->getInvalidRefreshCount());
+ EXPECT_EQ(0, mComposerCallback->getInvalidVsyncCount());
+ }
+ }
+
+ ::android::sp<::android::GraphicBuffer> allocate() {
+ return ::android::sp<::android::GraphicBuffer>::make(
+ mDisplayWidth, mDisplayHeight, ::android::PIXEL_FORMAT_RGBA_8888,
+ /*layerCount*/ 1,
+ static_cast<uint64_t>(static_cast<int>(common::BufferUsage::CPU_WRITE_OFTEN) |
+ static_cast<int>(common::BufferUsage::CPU_READ_OFTEN)),
+ "VtsHalGraphicsComposer3_ReadbackTest");
+ }
+
+ void writeLayers(const std::vector<std::shared_ptr<TestLayer>>& layers) {
+ for (auto layer : layers) {
+ layer->write(mWriter);
+ }
+ execute();
+ }
+
+ void execute() {
+ const auto& commands = mWriter.getPendingCommands();
+ if (commands.empty()) {
+ mWriter.reset();
+ return;
+ }
+
+ std::vector<CommandResultPayload> results;
+ const auto status = mComposerClient->executeCommands(commands, &results);
+ ASSERT_TRUE(status.isOk()) << "executeCommands failed " << status.getDescription();
+
+ mReader.parse(results);
+ mWriter.reset();
+ }
+
+ bool getHasReadbackBuffer() {
+ ReadbackBufferAttributes readBackBufferAttributes;
+ const auto error = mComposerClient->getReadbackBufferAttributes(mPrimaryDisplay,
+ &readBackBufferAttributes);
+ mPixelFormat = readBackBufferAttributes.format;
+ mDataspace = readBackBufferAttributes.dataspace;
+ return error.isOk() && ReadbackHelper::readbackSupported(mPixelFormat, mDataspace);
+ }
+
+ std::shared_ptr<IComposer> mComposer;
+ std::shared_ptr<IComposerClient> mComposerClient;
+
+ std::shared_ptr<GraphicsComposerCallback> mComposerCallback;
+ // the first display and is assumed never to be removed
+ int64_t mPrimaryDisplay;
+ int64_t mInvalidDisplayId;
+ int32_t mDisplayWidth;
+ int32_t mDisplayHeight;
+ std::vector<ColorMode> mTestColorModes;
+ CommandWriterBase mWriter;
+ CommandReaderBase mReader;
+ ::android::sp<::android::GraphicBuffer> mGraphicBuffer;
+ std::unique_ptr<TestRenderEngine> mTestRenderEngine;
+
+ common::PixelFormat mPixelFormat;
+ common::Dataspace mDataspace;
+
+ static constexpr uint32_t kClientTargetSlotCount = 64;
+
+ private:
+ int64_t waitForFirstDisplay() {
+ while (true) {
+ std::vector<int64_t> displays = mComposerCallback->getDisplays();
+ if (displays.empty()) {
+ usleep(5 * 1000);
+ continue;
+ }
+ return displays[0];
+ }
+ }
+
+ void setTestColorModes() {
+ mTestColorModes.clear();
+ std::vector<ColorMode> modes;
+ EXPECT_TRUE(mComposerClient->getColorModes(mPrimaryDisplay, &modes).isOk());
+
+ for (ColorMode mode : modes) {
+ if (std::find(ReadbackHelper::colorModes.begin(), ReadbackHelper::colorModes.end(),
+ mode) != ReadbackHelper::colorModes.end()) {
+ mTestColorModes.push_back(mode);
+ }
+ }
+ }
+
+ // returns an invalid display id (one that has not been registered to a
+ // display. Currently assuming that a device will never have close to
+ // std::numeric_limit<uint64_t>::max() displays registered while running tests
+ int64_t GetInvalidDisplayId() {
+ int64_t id = std::numeric_limits<int64_t>::max();
+ std::vector<int64_t> displays = mComposerCallback->getDisplays();
+ while (id > 0) {
+ if (std::none_of(displays.begin(), displays.end(),
+ [&](const auto& display) { return id == display; })) {
+ return id;
+ }
+ id--;
+ }
+
+ // Although 0 could be an invalid display, a return value of 0
+ // from GetInvalidDisplayId means all other ids are in use, a condition which
+ // we are assuming a device will never have
+ EXPECT_NE(0, id);
+ return id;
+ }
+};
+
+class GraphicsCompositionTest : public GraphicsCompositionTestBase,
+ public testing::WithParamInterface<std::string> {
+ public:
+ void SetUp() override { SetUpBase(GetParam()); }
+};
+
+TEST_P(GraphicsCompositionTest, SingleSolidColorLayer) {
+ for (ColorMode mode : mTestColorModes) {
+ ASSERT_NO_FATAL_FAILURE(
+ mComposerClient->setColorMode(mPrimaryDisplay, mode, RenderIntent::COLORIMETRIC));
+
+ if (!getHasReadbackBuffer()) {
+ GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
+ return;
+ }
+
+ auto layer = std::make_shared<TestColorLayer>(mComposerClient, mPrimaryDisplay);
+ common::Rect coloredSquare({0, 0, mDisplayWidth, mDisplayHeight});
+ layer->setColor(BLUE);
+ layer->setDisplayFrame(coloredSquare);
+ layer->setZOrder(10);
+
+ std::vector<std::shared_ptr<TestLayer>> layers = {layer};
+
+ // expected color for each pixel
+ std::vector<Color> expectedColors(static_cast<size_t>(mDisplayWidth * mDisplayHeight));
+ ReadbackHelper::fillColorsArea(expectedColors, mDisplayWidth, coloredSquare, BLUE);
+
+ ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mGraphicBuffer,
+ mDisplayWidth, mDisplayHeight, mPixelFormat, mDataspace);
+ ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
+
+ writeLayers(layers);
+ ASSERT_TRUE(mReader.takeErrors().empty());
+ mWriter.validateDisplay(mPrimaryDisplay);
+ execute();
+ // if hwc cannot handle and asks for composition change,
+ // just succeed the test
+ std::vector<int64_t> changedCompositionLayers;
+ std::vector<Composition> changedCompositionTypes;
+ mReader.takeChangedCompositionTypes(mPrimaryDisplay, &changedCompositionLayers,
+ &changedCompositionTypes);
+ if (!changedCompositionLayers.empty()) {
+ GTEST_SUCCEED();
+ return;
+ }
+ ASSERT_TRUE(mReader.takeErrors().empty());
+ mWriter.presentDisplay(mPrimaryDisplay);
+ execute();
+ ASSERT_TRUE(mReader.takeErrors().empty());
+
+ ASSERT_NO_FATAL_FAILURE(readbackBuffer.checkReadbackBuffer(expectedColors));
+ mTestRenderEngine->setRenderLayers(layers);
+ ASSERT_NO_FATAL_FAILURE(mTestRenderEngine->drawLayers());
+ ASSERT_NO_FATAL_FAILURE(mTestRenderEngine->checkColorBuffer(expectedColors));
+ }
+}
+
+TEST_P(GraphicsCompositionTest, SetLayerBuffer) {
+ for (ColorMode mode : mTestColorModes) {
+ ASSERT_NO_FATAL_FAILURE(
+ mComposerClient->setColorMode(mPrimaryDisplay, mode, RenderIntent::COLORIMETRIC));
+
+ if (!getHasReadbackBuffer()) {
+ GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
+ return;
+ }
+
+ ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mGraphicBuffer,
+ mDisplayWidth, mDisplayHeight, mPixelFormat, mDataspace);
+ ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
+ std::vector<Color> expectedColors(static_cast<size_t>(mDisplayWidth * mDisplayHeight));
+ ReadbackHelper::fillColorsArea(expectedColors, mDisplayWidth,
+ {0, 0, mDisplayWidth, mDisplayHeight / 4}, RED);
+ ReadbackHelper::fillColorsArea(expectedColors, mDisplayWidth,
+ {0, mDisplayHeight / 4, mDisplayWidth, mDisplayHeight / 2},
+ GREEN);
+ ReadbackHelper::fillColorsArea(expectedColors, mDisplayWidth,
+ {0, mDisplayHeight / 2, mDisplayWidth, mDisplayHeight},
+ BLUE);
+
+ auto layer = std::make_shared<TestBufferLayer>(
+ mComposerClient, mGraphicBuffer, *mTestRenderEngine, mPrimaryDisplay, mDisplayWidth,
+ mDisplayHeight, common::PixelFormat::RGBA_8888);
+ layer->setDisplayFrame({0, 0, mDisplayWidth, mDisplayHeight});
+ layer->setZOrder(10);
+ layer->setDataspace(ReadbackHelper::getDataspaceForColorMode(mode), mWriter);
+ ASSERT_NO_FATAL_FAILURE(layer->setBuffer(expectedColors));
+
+ std::vector<std::shared_ptr<TestLayer>> layers = {layer};
+
+ writeLayers(layers);
+ ASSERT_TRUE(mReader.takeErrors().empty());
+ mWriter.validateDisplay(mPrimaryDisplay);
+ execute();
+
+ std::vector<int64_t> changedCompositionLayers;
+ std::vector<Composition> changedCompositionTypes;
+ mReader.takeChangedCompositionTypes(mPrimaryDisplay, &changedCompositionLayers,
+ &changedCompositionTypes);
+ if (!changedCompositionLayers.empty()) {
+ GTEST_SUCCEED();
+ return;
+ }
+ ASSERT_TRUE(mReader.takeErrors().empty());
+
+ mWriter.presentDisplay(mPrimaryDisplay);
+ execute();
+
+ ASSERT_TRUE(mReader.takeErrors().empty());
+
+ ASSERT_NO_FATAL_FAILURE(readbackBuffer.checkReadbackBuffer(expectedColors));
+ mTestRenderEngine->setRenderLayers(layers);
+ ASSERT_NO_FATAL_FAILURE(mTestRenderEngine->drawLayers());
+ ASSERT_NO_FATAL_FAILURE(mTestRenderEngine->checkColorBuffer(expectedColors));
+ }
+}
+
+TEST_P(GraphicsCompositionTest, SetLayerBufferNoEffect) {
+ for (ColorMode mode : mTestColorModes) {
+ ASSERT_NO_FATAL_FAILURE(
+ mComposerClient->setColorMode(mPrimaryDisplay, mode, RenderIntent::COLORIMETRIC));
+
+ if (!getHasReadbackBuffer()) {
+ GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
+ return;
+ }
+
+ auto layer = std::make_shared<TestColorLayer>(mComposerClient, mPrimaryDisplay);
+ common::Rect coloredSquare({0, 0, mDisplayWidth, mDisplayHeight});
+ layer->setColor(BLUE);
+ layer->setDisplayFrame(coloredSquare);
+ layer->setZOrder(10);
+ layer->write(mWriter);
+
+ // This following buffer call should have no effect
+ uint64_t usage =
+ static_cast<uint64_t>(static_cast<uint64_t>(common::BufferUsage::CPU_READ_OFTEN) |
+ static_cast<uint64_t>(common::BufferUsage::CPU_WRITE_OFTEN));
+
+ mGraphicBuffer->reallocate(static_cast<uint32_t>(mDisplayWidth),
+ static_cast<uint32_t>(mDisplayHeight), 1,
+ static_cast<uint32_t>(common::PixelFormat::RGBA_8888), usage);
+ mWriter.setLayerBuffer(mPrimaryDisplay, layer->getLayer(), 0, mGraphicBuffer->handle, -1);
+
+ // expected color for each pixel
+ std::vector<Color> expectedColors(static_cast<size_t>(mDisplayWidth * mDisplayHeight));
+ ReadbackHelper::fillColorsArea(expectedColors, mDisplayWidth, coloredSquare, BLUE);
+
+ ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mGraphicBuffer,
+ mDisplayWidth, mDisplayHeight, mPixelFormat, mDataspace);
+ ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
+
+ mWriter.validateDisplay(mPrimaryDisplay);
+ execute();
+
+ std::vector<int64_t> changedCompositionLayers;
+ std::vector<Composition> changedCompositionTypes;
+ mReader.takeChangedCompositionTypes(mPrimaryDisplay, &changedCompositionLayers,
+ &changedCompositionTypes);
+ if (!changedCompositionLayers.empty()) {
+ GTEST_SUCCEED();
+ return;
+ }
+ ASSERT_TRUE(mReader.takeErrors().empty());
+ mWriter.presentDisplay(mPrimaryDisplay);
+ execute();
+ ASSERT_TRUE(mReader.takeErrors().empty());
+
+ ASSERT_NO_FATAL_FAILURE(readbackBuffer.checkReadbackBuffer(expectedColors));
+ }
+}
+
+TEST_P(GraphicsCompositionTest, SetReadbackBuffer) {
+ if (!getHasReadbackBuffer()) {
+ GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
+ return;
+ }
+
+ ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mGraphicBuffer, mDisplayWidth,
+ mDisplayHeight, mPixelFormat, mDataspace);
+
+ ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
+}
+
+TEST_P(GraphicsCompositionTest, SetReadbackBufferBadDisplay) {
+ if (!getHasReadbackBuffer()) {
+ GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
+ return;
+ }
+
+ ASSERT_NE(nullptr, mGraphicBuffer);
+ ASSERT_EQ(::android::OK, mGraphicBuffer->initCheck());
+ aidl::android::hardware::common::NativeHandle bufferHandle =
+ ::android::dupToAidl(mGraphicBuffer->handle);
+ ::ndk::ScopedFileDescriptor fence = ::ndk::ScopedFileDescriptor(-1);
+
+ const auto error = mComposerClient->setReadbackBuffer(mInvalidDisplayId, bufferHandle, fence);
+
+ EXPECT_FALSE(error.isOk());
+ ASSERT_EQ(IComposerClient::EX_BAD_DISPLAY, error.getServiceSpecificError());
+}
+
+TEST_P(GraphicsCompositionTest, SetReadbackBufferBadParameter) {
+ if (!getHasReadbackBuffer()) {
+ GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
+ return;
+ }
+
+ aidl::android::hardware::common::NativeHandle bufferHandle = ::android::dupToAidl(nullptr);
+ ndk::ScopedFileDescriptor releaseFence = ndk::ScopedFileDescriptor(-1);
+ const auto error =
+ mComposerClient->setReadbackBuffer(mPrimaryDisplay, bufferHandle, releaseFence);
+
+ EXPECT_FALSE(error.isOk());
+ ASSERT_EQ(IComposerClient::EX_BAD_PARAMETER, error.getServiceSpecificError());
+}
+
+TEST_P(GraphicsCompositionTest, GetReadbackBufferFenceInactive) {
+ if (!getHasReadbackBuffer()) {
+ GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
+ return;
+ }
+
+ ndk::ScopedFileDescriptor releaseFence;
+ const auto error = mComposerClient->getReadbackBufferFence(mPrimaryDisplay, &releaseFence);
+
+ EXPECT_TRUE(error.isOk());
+ EXPECT_EQ(IComposerClient::EX_UNSUPPORTED, error.getServiceSpecificError());
+}
+
+TEST_P(GraphicsCompositionTest, ClientComposition) {
+ EXPECT_TRUE(mComposerClient->setClientTargetSlotCount(mPrimaryDisplay, kClientTargetSlotCount)
+ .isOk());
+
+ for (ColorMode mode : mTestColorModes) {
+ EXPECT_TRUE(mComposerClient->setColorMode(mPrimaryDisplay, mode, RenderIntent::COLORIMETRIC)
+ .isOk());
+
+ if (!getHasReadbackBuffer()) {
+ GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
+ return;
+ }
+
+ std::vector<Color> expectedColors(static_cast<size_t>(mDisplayWidth * mDisplayHeight));
+ ReadbackHelper::fillColorsArea(expectedColors, mDisplayWidth,
+ {0, 0, mDisplayWidth, mDisplayHeight / 4}, RED);
+ ReadbackHelper::fillColorsArea(expectedColors, mDisplayWidth,
+ {0, mDisplayHeight / 4, mDisplayWidth, mDisplayHeight / 2},
+ GREEN);
+ ReadbackHelper::fillColorsArea(expectedColors, mDisplayWidth,
+ {0, mDisplayHeight / 2, mDisplayWidth, mDisplayHeight},
+ BLUE);
+
+ auto layer = std::make_shared<TestBufferLayer>(
+ mComposerClient, mGraphicBuffer, *mTestRenderEngine, mPrimaryDisplay, mDisplayWidth,
+ mDisplayHeight, PixelFormat::RGBA_FP16);
+ layer->setDisplayFrame({0, 0, mDisplayWidth, mDisplayHeight});
+ layer->setZOrder(10);
+ layer->setDataspace(ReadbackHelper::getDataspaceForColorMode(mode), mWriter);
+
+ std::vector<std::shared_ptr<TestLayer>> layers = {layer};
+
+ ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mGraphicBuffer,
+ mDisplayWidth, mDisplayHeight, mPixelFormat, mDataspace);
+ ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
+ writeLayers(layers);
+ ASSERT_TRUE(mReader.takeErrors().empty());
+ mWriter.validateDisplay(mPrimaryDisplay);
+ execute();
+
+ std::vector<int64_t> changedCompositionLayers;
+ std::vector<Composition> changedCompositionTypes;
+ mReader.takeChangedCompositionTypes(mPrimaryDisplay, &changedCompositionLayers,
+ &changedCompositionTypes);
+ if (!changedCompositionLayers.empty()) {
+ ASSERT_EQ(1, changedCompositionLayers.size());
+ ASSERT_EQ(1, changedCompositionTypes.size());
+ ASSERT_EQ(Composition::CLIENT, changedCompositionTypes[0]);
+
+ PixelFormat clientFormat = PixelFormat::RGBA_8888;
+ auto clientUsage = static_cast<uint32_t>(
+ static_cast<uint32_t>(common::BufferUsage::CPU_READ_OFTEN) |
+ static_cast<uint32_t>(common::BufferUsage::CPU_WRITE_OFTEN) |
+ static_cast<uint32_t>(common::BufferUsage::COMPOSER_CLIENT_TARGET));
+ Dataspace clientDataspace = ReadbackHelper::getDataspaceForColorMode(mode);
+ common::Rect damage{0, 0, mDisplayWidth, mDisplayHeight};
+
+ // create client target buffer
+ mGraphicBuffer->reallocate(layer->getWidth(), layer->getHeight(),
+ static_cast<int32_t>(common::PixelFormat::RGBA_8888),
+ layer->getLayerCount(), clientUsage);
+
+ ASSERT_NE(nullptr, mGraphicBuffer->handle);
+
+ void* clientBufData;
+ mGraphicBuffer->lock(clientUsage, layer->getAccessRegion(), &clientBufData);
+
+ ASSERT_NO_FATAL_FAILURE(
+ ReadbackHelper::fillBuffer(layer->getWidth(), layer->getHeight(),
+ static_cast<uint32_t>(mGraphicBuffer->stride),
+ clientBufData, clientFormat, expectedColors));
+ EXPECT_EQ(::android::OK, mGraphicBuffer->unlock());
+
+ ndk::ScopedFileDescriptor fenceHandle;
+ EXPECT_TRUE(
+ mComposerClient->getReadbackBufferFence(mPrimaryDisplay, &fenceHandle).isOk());
+
+ layer->setToClientComposition(mWriter);
+ mWriter.acceptDisplayChanges(mPrimaryDisplay);
+ mWriter.setClientTarget(mPrimaryDisplay, 0, mGraphicBuffer->handle, fenceHandle.get(),
+ clientDataspace, std::vector<common::Rect>(1, damage));
+ execute();
+ mReader.takeChangedCompositionTypes(mPrimaryDisplay, &changedCompositionLayers,
+ &changedCompositionTypes);
+ ASSERT_TRUE(changedCompositionLayers.empty());
+ }
+ ASSERT_TRUE(mReader.takeErrors().empty());
+
+ mWriter.presentDisplay(mPrimaryDisplay);
+ execute();
+
+ ASSERT_TRUE(mReader.takeErrors().empty());
+
+ ASSERT_NO_FATAL_FAILURE(readbackBuffer.checkReadbackBuffer(expectedColors));
+ }
+}
+
+TEST_P(GraphicsCompositionTest, DeviceAndClientComposition) {
+ ASSERT_NO_FATAL_FAILURE(
+ mComposerClient->setClientTargetSlotCount(mPrimaryDisplay, kClientTargetSlotCount));
+
+ for (ColorMode mode : mTestColorModes) {
+ ASSERT_NO_FATAL_FAILURE(
+ mComposerClient->setColorMode(mPrimaryDisplay, mode, RenderIntent::COLORIMETRIC));
+
+ if (!getHasReadbackBuffer()) {
+ GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
+ return;
+ }
+
+ std::vector<Color> expectedColors(static_cast<size_t>(mDisplayWidth * mDisplayHeight));
+ ReadbackHelper::fillColorsArea(expectedColors, mDisplayWidth,
+ {0, 0, mDisplayWidth, mDisplayHeight / 2}, GREEN);
+ ReadbackHelper::fillColorsArea(expectedColors, mDisplayWidth,
+ {0, mDisplayHeight / 2, mDisplayWidth, mDisplayHeight}, RED);
+
+ ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mGraphicBuffer,
+ mDisplayWidth, mDisplayHeight, mPixelFormat, mDataspace);
+ ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
+
+ auto deviceLayer = std::make_shared<TestBufferLayer>(
+ mComposerClient, mGraphicBuffer, *mTestRenderEngine, mPrimaryDisplay, mDisplayWidth,
+ mDisplayHeight / 2, PixelFormat::RGBA_8888);
+ std::vector<Color> deviceColors(deviceLayer->getWidth() * deviceLayer->getHeight());
+ ReadbackHelper::fillColorsArea(deviceColors, static_cast<int32_t>(deviceLayer->getWidth()),
+ {0, 0, static_cast<int32_t>(deviceLayer->getWidth()),
+ static_cast<int32_t>(deviceLayer->getHeight())},
+ GREEN);
+ deviceLayer->setDisplayFrame({0, 0, static_cast<int32_t>(deviceLayer->getWidth()),
+ static_cast<int32_t>(deviceLayer->getHeight())});
+ deviceLayer->setZOrder(10);
+ deviceLayer->setDataspace(ReadbackHelper::getDataspaceForColorMode(mode), mWriter);
+ ASSERT_NO_FATAL_FAILURE(deviceLayer->setBuffer(deviceColors));
+ deviceLayer->write(mWriter);
+
+ PixelFormat clientFormat = PixelFormat::RGBA_8888;
+ auto clientUsage = static_cast<uint32_t>(
+ static_cast<uint64_t>(common::BufferUsage::CPU_READ_OFTEN) |
+ static_cast<uint32_t>(common::BufferUsage::CPU_WRITE_OFTEN) |
+ static_cast<uint32_t>(common::BufferUsage::COMPOSER_CLIENT_TARGET));
+ Dataspace clientDataspace = ReadbackHelper::getDataspaceForColorMode(mode);
+ int32_t clientWidth = mDisplayWidth;
+ int32_t clientHeight = mDisplayHeight / 2;
+
+ auto clientLayer = std::make_shared<TestBufferLayer>(
+ mComposerClient, mGraphicBuffer, *mTestRenderEngine, mPrimaryDisplay, clientWidth,
+ clientHeight, PixelFormat::RGBA_FP16, Composition::DEVICE);
+ common::Rect clientFrame = {0, mDisplayHeight / 2, mDisplayWidth, mDisplayHeight};
+ clientLayer->setDisplayFrame(clientFrame);
+ clientLayer->setZOrder(0);
+ clientLayer->write(mWriter);
+ mWriter.validateDisplay(mPrimaryDisplay);
+ execute();
+
+ std::vector<int64_t> changedCompositionLayers;
+ std::vector<Composition> changedCompositionTypes;
+ mReader.takeChangedCompositionTypes(mPrimaryDisplay, &changedCompositionLayers,
+ &changedCompositionTypes);
+ if (changedCompositionTypes.size() != 1) {
+ continue;
+ }
+ // create client target buffer
+ ASSERT_EQ(Composition::CLIENT, changedCompositionTypes[0]);
+ mGraphicBuffer->reallocate(static_cast<uint32_t>(mDisplayWidth),
+ static_cast<uint32_t>(mDisplayHeight),
+ static_cast<int32_t>(common::PixelFormat::RGBA_8888),
+ clientLayer->getLayerCount(), clientUsage);
+ ASSERT_NE(nullptr, mGraphicBuffer->handle);
+
+ void* clientBufData;
+ mGraphicBuffer->lock(clientUsage, {0, 0, mDisplayWidth, mDisplayHeight}, &clientBufData);
+
+ std::vector<Color> clientColors(static_cast<size_t>(mDisplayWidth * mDisplayHeight));
+ ReadbackHelper::fillColorsArea(clientColors, mDisplayWidth, clientFrame, RED);
+ ASSERT_NO_FATAL_FAILURE(ReadbackHelper::fillBuffer(
+ static_cast<uint32_t>(mDisplayWidth), static_cast<uint32_t>(mDisplayHeight),
+ mGraphicBuffer->getStride(), clientBufData, clientFormat, clientColors));
+ EXPECT_EQ(::android::OK, mGraphicBuffer->unlock());
+
+ ndk::ScopedFileDescriptor fenceHandle;
+ EXPECT_TRUE(mComposerClient->getReadbackBufferFence(mPrimaryDisplay, &fenceHandle).isOk());
+
+ clientLayer->setToClientComposition(mWriter);
+ mWriter.acceptDisplayChanges(mPrimaryDisplay);
+ mWriter.setClientTarget(mPrimaryDisplay, 0, mGraphicBuffer->handle, fenceHandle.get(),
+ clientDataspace, std::vector<common::Rect>(1, clientFrame));
+ execute();
+ mReader.takeChangedCompositionTypes(mPrimaryDisplay, &changedCompositionLayers,
+ &changedCompositionTypes);
+ ASSERT_EQ(0, changedCompositionLayers.size());
+ ASSERT_TRUE(mReader.takeErrors().empty());
+
+ mWriter.presentDisplay(mPrimaryDisplay);
+ execute();
+ ASSERT_TRUE(mReader.takeErrors().empty());
+ ASSERT_NO_FATAL_FAILURE(readbackBuffer.checkReadbackBuffer(expectedColors));
+ }
+}
+
+TEST_P(GraphicsCompositionTest, SetLayerDamage) {
+ for (ColorMode mode : mTestColorModes) {
+ ASSERT_NO_FATAL_FAILURE(
+ mComposerClient->setColorMode(mPrimaryDisplay, mode, RenderIntent::COLORIMETRIC));
+
+ if (!getHasReadbackBuffer()) {
+ GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
+ return;
+ }
+
+ common::Rect redRect = {0, 0, mDisplayWidth / 4, mDisplayHeight / 4};
+
+ std::vector<Color> expectedColors(static_cast<size_t>(mDisplayWidth * mDisplayHeight));
+ ReadbackHelper::fillColorsArea(expectedColors, mDisplayWidth, redRect, RED);
+
+ auto layer = std::make_shared<TestBufferLayer>(
+ mComposerClient, mGraphicBuffer, *mTestRenderEngine, mPrimaryDisplay, mDisplayWidth,
+ mDisplayHeight, PixelFormat::RGBA_8888);
+ layer->setDisplayFrame({0, 0, mDisplayWidth, mDisplayHeight});
+ layer->setZOrder(10);
+ layer->setDataspace(ReadbackHelper::getDataspaceForColorMode(mode), mWriter);
+ ASSERT_NO_FATAL_FAILURE(layer->setBuffer(expectedColors));
+
+ std::vector<std::shared_ptr<TestLayer>> layers = {layer};
+
+ ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mGraphicBuffer,
+ mDisplayWidth, mDisplayHeight, mPixelFormat, mDataspace);
+ ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
+
+ writeLayers(layers);
+ ASSERT_TRUE(mReader.takeErrors().empty());
+ mWriter.validateDisplay(mPrimaryDisplay);
+ execute();
+ std::vector<int64_t> changedCompositionLayers;
+ std::vector<Composition> changedCompositionTypes;
+ mReader.takeChangedCompositionTypes(mPrimaryDisplay, &changedCompositionLayers,
+ &changedCompositionTypes);
+ if (!changedCompositionLayers.empty()) {
+ GTEST_SUCCEED();
+ return;
+ }
+ ASSERT_TRUE(mReader.takeErrors().empty());
+ mWriter.presentDisplay(mPrimaryDisplay);
+ execute();
+ ASSERT_TRUE(mReader.takeErrors().empty());
+
+ ASSERT_NO_FATAL_FAILURE(readbackBuffer.checkReadbackBuffer(expectedColors));
+
+ // update surface damage and recheck
+ redRect = {mDisplayWidth / 4, mDisplayHeight / 4, mDisplayWidth / 2, mDisplayHeight / 2};
+ ReadbackHelper::clearColors(expectedColors, mDisplayWidth, mDisplayHeight, mDisplayWidth);
+ ReadbackHelper::fillColorsArea(expectedColors, mDisplayWidth, redRect, RED);
+
+ ASSERT_NO_FATAL_FAILURE(layer->fillBuffer(expectedColors));
+ layer->setSurfaceDamage(
+ std::vector<common::Rect>(1, {0, 0, mDisplayWidth / 2, mDisplayWidth / 2}));
+
+ ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
+
+ writeLayers(layers);
+ ASSERT_TRUE(mReader.takeErrors().empty());
+ mWriter.validateDisplay(mPrimaryDisplay);
+ execute();
+ ASSERT_TRUE(mReader.takeErrors().empty());
+ mReader.takeChangedCompositionTypes(mPrimaryDisplay, &changedCompositionLayers,
+ &changedCompositionTypes);
+ ASSERT_TRUE(changedCompositionLayers.empty());
+ ASSERT_TRUE(changedCompositionTypes.empty());
+ mWriter.presentDisplay(mPrimaryDisplay);
+ execute();
+ ASSERT_TRUE(mReader.takeErrors().empty());
+
+ ASSERT_NO_FATAL_FAILURE(readbackBuffer.checkReadbackBuffer(expectedColors));
+ }
+}
+
+TEST_P(GraphicsCompositionTest, SetLayerPlaneAlpha) {
+ for (ColorMode mode : mTestColorModes) {
+ ASSERT_NO_FATAL_FAILURE(
+ mComposerClient->setColorMode(mPrimaryDisplay, mode, RenderIntent::COLORIMETRIC));
+
+ if (!getHasReadbackBuffer()) {
+ GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
+ return;
+ }
+
+ auto layer = std::make_shared<TestColorLayer>(mComposerClient, mPrimaryDisplay);
+ layer->setColor(RED);
+ layer->setDisplayFrame({0, 0, mDisplayWidth, mDisplayHeight});
+ layer->setZOrder(10);
+ layer->setAlpha(0);
+ layer->setBlendMode(BlendMode::PREMULTIPLIED);
+
+ std::vector<std::shared_ptr<TestLayer>> layers = {layer};
+
+ ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mGraphicBuffer,
+ mDisplayWidth, mDisplayHeight, mPixelFormat, mDataspace);
+
+ ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
+
+ writeLayers(layers);
+ ASSERT_TRUE(mReader.takeErrors().empty());
+ mWriter.validateDisplay(mPrimaryDisplay);
+ execute();
+ std::vector<int64_t> changedCompositionLayers;
+ std::vector<Composition> changedCompositionTypes;
+ mReader.takeChangedCompositionTypes(mPrimaryDisplay, &changedCompositionLayers,
+ &changedCompositionTypes);
+ if (!changedCompositionLayers.empty()) {
+ GTEST_SUCCEED();
+ return;
+ }
+ ASSERT_TRUE(mReader.takeErrors().empty());
+
+ mWriter.presentDisplay(mPrimaryDisplay);
+ execute();
+ ASSERT_TRUE(mReader.takeErrors().empty());
+
+ std::vector<Color> expectedColors(static_cast<size_t>(mDisplayWidth * mDisplayHeight));
+
+ ASSERT_NO_FATAL_FAILURE(readbackBuffer.checkReadbackBuffer(expectedColors));
+ mTestRenderEngine->setRenderLayers(layers);
+ ASSERT_NO_FATAL_FAILURE(mTestRenderEngine->drawLayers());
+ ASSERT_NO_FATAL_FAILURE(mTestRenderEngine->checkColorBuffer(expectedColors));
+ }
+}
+
+TEST_P(GraphicsCompositionTest, SetLayerSourceCrop) {
+ for (ColorMode mode : mTestColorModes) {
+ ASSERT_NO_FATAL_FAILURE(
+ mComposerClient->setColorMode(mPrimaryDisplay, mode, RenderIntent::COLORIMETRIC));
+
+ if (!getHasReadbackBuffer()) {
+ GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
+ return;
+ }
+
+ std::vector<Color> expectedColors(static_cast<size_t>(mDisplayWidth * mDisplayHeight));
+ ReadbackHelper::fillColorsArea(expectedColors, mDisplayWidth,
+ {0, 0, mDisplayWidth, mDisplayHeight / 4}, RED);
+ ReadbackHelper::fillColorsArea(expectedColors, mDisplayWidth,
+ {0, mDisplayHeight / 2, mDisplayWidth, mDisplayHeight},
+ BLUE);
+
+ auto layer = std::make_shared<TestBufferLayer>(
+ mComposerClient, mGraphicBuffer, *mTestRenderEngine, mPrimaryDisplay, mDisplayWidth,
+ mDisplayHeight, PixelFormat::RGBA_8888);
+ layer->setDisplayFrame({0, 0, mDisplayWidth, mDisplayHeight});
+ layer->setZOrder(10);
+ layer->setDataspace(ReadbackHelper::getDataspaceForColorMode(mode), mWriter);
+ layer->setSourceCrop({0, static_cast<float>(mDisplayHeight / 2),
+ static_cast<float>(mDisplayWidth),
+ static_cast<float>(mDisplayHeight)});
+ ASSERT_NO_FATAL_FAILURE(layer->setBuffer(expectedColors));
+
+ std::vector<std::shared_ptr<TestLayer>> layers = {layer};
+
+ // update expected colors to match crop
+ ReadbackHelper::fillColorsArea(expectedColors, mDisplayWidth,
+ {0, 0, mDisplayWidth, mDisplayHeight}, BLUE);
+ ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mGraphicBuffer,
+ mDisplayWidth, mDisplayHeight, mPixelFormat, mDataspace);
+ ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
+ writeLayers(layers);
+ ASSERT_TRUE(mReader.takeErrors().empty());
+ mWriter.validateDisplay(mPrimaryDisplay);
+ execute();
+ std::vector<int64_t> changedCompositionLayers;
+ std::vector<Composition> changedCompositionTypes;
+ mReader.takeChangedCompositionTypes(mPrimaryDisplay, &changedCompositionLayers,
+ &changedCompositionTypes);
+ if (!changedCompositionLayers.empty()) {
+ GTEST_SUCCEED();
+ return;
+ }
+ ASSERT_TRUE(mReader.takeErrors().empty());
+ mWriter.presentDisplay(mPrimaryDisplay);
+ execute();
+ ASSERT_TRUE(mReader.takeErrors().empty());
+ ASSERT_NO_FATAL_FAILURE(readbackBuffer.checkReadbackBuffer(expectedColors));
+ mTestRenderEngine->setRenderLayers(layers);
+ ASSERT_NO_FATAL_FAILURE(mTestRenderEngine->drawLayers());
+ ASSERT_NO_FATAL_FAILURE(mTestRenderEngine->checkColorBuffer(expectedColors));
+ }
+}
+
+TEST_P(GraphicsCompositionTest, SetLayerZOrder) {
+ for (ColorMode mode : mTestColorModes) {
+ ASSERT_NO_FATAL_FAILURE(
+ mComposerClient->setColorMode(mPrimaryDisplay, mode, RenderIntent::COLORIMETRIC));
+
+ if (!getHasReadbackBuffer()) {
+ GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
+ return;
+ }
+
+ common::Rect redRect = {0, 0, mDisplayWidth, mDisplayHeight / 2};
+ common::Rect blueRect = {0, mDisplayHeight / 4, mDisplayWidth, mDisplayHeight};
+ auto redLayer = std::make_shared<TestColorLayer>(mComposerClient, mPrimaryDisplay);
+ redLayer->setColor(RED);
+ redLayer->setDisplayFrame(redRect);
+
+ auto blueLayer = std::make_shared<TestColorLayer>(mComposerClient, mPrimaryDisplay);
+ blueLayer->setColor(BLUE);
+ blueLayer->setDisplayFrame(blueRect);
+ blueLayer->setZOrder(5);
+
+ std::vector<std::shared_ptr<TestLayer>> layers = {redLayer, blueLayer};
+ std::vector<Color> expectedColors(static_cast<size_t>(mDisplayWidth * mDisplayHeight));
+
+ // red in front of blue
+ redLayer->setZOrder(10);
+
+ // fill blue first so that red will overwrite on overlap
+ ReadbackHelper::fillColorsArea(expectedColors, mDisplayWidth, blueRect, BLUE);
+ ReadbackHelper::fillColorsArea(expectedColors, mDisplayWidth, redRect, RED);
+
+ ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mGraphicBuffer,
+ mDisplayWidth, mDisplayHeight, mPixelFormat, mDataspace);
+ ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
+
+ writeLayers(layers);
+ ASSERT_TRUE(mReader.takeErrors().empty());
+ mWriter.validateDisplay(mPrimaryDisplay);
+ execute();
+ std::vector<int64_t> changedCompositionLayers;
+ std::vector<Composition> changedCompositionTypes;
+ mReader.takeChangedCompositionTypes(mPrimaryDisplay, &changedCompositionLayers,
+ &changedCompositionTypes);
+ if (!changedCompositionLayers.empty()) {
+ GTEST_SUCCEED();
+ return;
+ }
+ mWriter.presentDisplay(mPrimaryDisplay);
+ execute();
+ ASSERT_TRUE(mReader.takeErrors().empty());
+
+ ASSERT_NO_FATAL_FAILURE(readbackBuffer.checkReadbackBuffer(expectedColors));
+
+ redLayer->setZOrder(1);
+ ReadbackHelper::clearColors(expectedColors, mDisplayWidth, mDisplayHeight, mDisplayWidth);
+ ReadbackHelper::fillColorsArea(expectedColors, mDisplayWidth, redRect, RED);
+ ReadbackHelper::fillColorsArea(expectedColors, mDisplayWidth, blueRect, BLUE);
+
+ ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
+
+ writeLayers(layers);
+ ASSERT_TRUE(mReader.takeErrors().empty());
+ mWriter.validateDisplay(mPrimaryDisplay);
+ execute();
+ mReader.takeChangedCompositionTypes(mPrimaryDisplay, &changedCompositionLayers,
+ &changedCompositionTypes);
+ ASSERT_TRUE(changedCompositionLayers.empty());
+ ASSERT_TRUE(changedCompositionTypes.empty());
+ ASSERT_TRUE(mReader.takeErrors().empty());
+ mWriter.presentDisplay(mPrimaryDisplay);
+ execute();
+ ASSERT_TRUE(mReader.takeErrors().empty());
+
+ ASSERT_NO_FATAL_FAILURE(readbackBuffer.checkReadbackBuffer(expectedColors));
+ mTestRenderEngine->setRenderLayers(layers);
+ ASSERT_NO_FATAL_FAILURE(mTestRenderEngine->drawLayers());
+ ASSERT_NO_FATAL_FAILURE(mTestRenderEngine->checkColorBuffer(expectedColors));
+ }
+}
+
+class GraphicsBlendModeCompositionTest
+ : public GraphicsCompositionTestBase,
+ public testing::WithParamInterface<std::tuple<std::string, std::string>> {
+ public:
+ void SetUp() override {
+ SetUpBase(std::get<0>(GetParam()));
+ mBackgroundColor = BLACK;
+ mTopLayerColor = RED;
+ }
+
+ void setBackgroundColor(Color color) { mBackgroundColor = color; }
+
+ void setTopLayerColor(Color color) { mTopLayerColor = color; }
+
+ void setUpLayers(BlendMode blendMode) {
+ mLayers.clear();
+ std::vector<Color> topLayerPixelColors(static_cast<size_t>(mDisplayWidth * mDisplayHeight));
+ ReadbackHelper::fillColorsArea(topLayerPixelColors, mDisplayWidth,
+ {0, 0, mDisplayWidth, mDisplayHeight}, mTopLayerColor);
+
+ auto backgroundLayer = std::make_shared<TestColorLayer>(mComposerClient, mPrimaryDisplay);
+ backgroundLayer->setDisplayFrame({0, 0, mDisplayWidth, mDisplayHeight});
+ backgroundLayer->setZOrder(0);
+ backgroundLayer->setColor(mBackgroundColor);
+
+ auto layer = std::make_shared<TestBufferLayer>(
+ mComposerClient, mGraphicBuffer, *mTestRenderEngine, mPrimaryDisplay, mDisplayWidth,
+ mDisplayHeight, PixelFormat::RGBA_8888);
+ layer->setDisplayFrame({0, 0, mDisplayWidth, mDisplayHeight});
+ layer->setZOrder(10);
+ layer->setDataspace(Dataspace::UNKNOWN, mWriter);
+ ASSERT_NO_FATAL_FAILURE(layer->setBuffer(topLayerPixelColors));
+
+ layer->setBlendMode(blendMode);
+ layer->setAlpha(std::stof(std::get<1>(GetParam())));
+
+ mLayers.push_back(backgroundLayer);
+ mLayers.push_back(layer);
+ }
+
+ void setExpectedColors(std::vector<Color>& expectedColors) {
+ ASSERT_EQ(2, mLayers.size());
+ ReadbackHelper::clearColors(expectedColors, mDisplayWidth, mDisplayHeight, mDisplayWidth);
+
+ auto layer = mLayers[1];
+ BlendMode blendMode = layer->getBlendMode();
+ float alpha = mTopLayerColor.a / 255.0f * layer->getAlpha();
+ if (blendMode == BlendMode::NONE) {
+ for (auto& expectedColor : expectedColors) {
+ expectedColor.r = mTopLayerColor.r * static_cast<int8_t>(layer->getAlpha());
+ expectedColor.g = mTopLayerColor.g * static_cast<int8_t>(layer->getAlpha());
+ expectedColor.b = mTopLayerColor.b * static_cast<int8_t>(layer->getAlpha());
+ expectedColor.a = static_cast<int8_t>(alpha * 255.0);
+ }
+ } else if (blendMode == BlendMode::PREMULTIPLIED) {
+ for (auto& expectedColor : expectedColors) {
+ expectedColor.r = static_cast<int8_t>(
+ mTopLayerColor.r * static_cast<int8_t>(layer->getAlpha()) +
+ mBackgroundColor.r * (1.0 - alpha));
+ expectedColor.g = static_cast<int8_t>(mTopLayerColor.g * layer->getAlpha() +
+ mBackgroundColor.g * (1.0 - alpha));
+ expectedColor.b = static_cast<int8_t>(mTopLayerColor.b * layer->getAlpha() +
+ mBackgroundColor.b * (1.0 - alpha));
+ expectedColor.a = static_cast<int8_t>(alpha + mBackgroundColor.a * (1.0 - alpha));
+ }
+ } else if (blendMode == BlendMode::COVERAGE) {
+ for (auto& expectedColor : expectedColors) {
+ expectedColor.r = static_cast<int8_t>(mTopLayerColor.r * alpha +
+ mBackgroundColor.r * (1.0 - alpha));
+ expectedColor.g = static_cast<int8_t>(mTopLayerColor.g * alpha +
+ mBackgroundColor.g * (1.0 - alpha));
+ expectedColor.b = static_cast<int8_t>(mTopLayerColor.b * alpha +
+ mBackgroundColor.b * (1.0 - alpha));
+ expectedColor.a = static_cast<int8_t>(mTopLayerColor.a * alpha +
+ mBackgroundColor.a * (1.0 - alpha));
+ }
+ }
+ }
+
+ protected:
+ std::vector<std::shared_ptr<TestLayer>> mLayers;
+ Color mBackgroundColor;
+ Color mTopLayerColor;
+};
+
+TEST_P(GraphicsBlendModeCompositionTest, None) {
+ for (ColorMode mode : mTestColorModes) {
+ ASSERT_NO_FATAL_FAILURE(
+ mComposerClient->setColorMode(mPrimaryDisplay, mode, RenderIntent::COLORIMETRIC));
+
+ if (!getHasReadbackBuffer()) {
+ GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
+ return;
+ }
+
+ std::vector<Color> expectedColors(static_cast<size_t>(mDisplayWidth * mDisplayHeight));
+
+ setBackgroundColor(BLACK);
+ setTopLayerColor(TRANSLUCENT_RED);
+ setUpLayers(BlendMode::NONE);
+ setExpectedColors(expectedColors);
+
+ ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mGraphicBuffer,
+ mDisplayWidth, mDisplayHeight, mPixelFormat, mDataspace);
+ ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
+ writeLayers(mLayers);
+ ASSERT_TRUE(mReader.takeErrors().empty());
+ mWriter.validateDisplay(mPrimaryDisplay);
+ execute();
+ std::vector<int64_t> changedCompositionLayers;
+ std::vector<Composition> changedCompositionTypes;
+ mReader.takeChangedCompositionTypes(mPrimaryDisplay, &changedCompositionLayers,
+ &changedCompositionTypes);
+ if (!changedCompositionLayers.empty()) {
+ GTEST_SUCCEED();
+ return;
+ }
+ ASSERT_TRUE(mReader.takeErrors().empty());
+ mWriter.presentDisplay(mPrimaryDisplay);
+ execute();
+ ASSERT_TRUE(mReader.takeErrors().empty());
+
+ ASSERT_NO_FATAL_FAILURE(readbackBuffer.checkReadbackBuffer(expectedColors));
+ mTestRenderEngine->setRenderLayers(mLayers);
+ ASSERT_NO_FATAL_FAILURE(mTestRenderEngine->drawLayers());
+ ASSERT_NO_FATAL_FAILURE(mTestRenderEngine->checkColorBuffer(expectedColors));
+ }
+}
+
+TEST_P(GraphicsBlendModeCompositionTest, Coverage) {
+ for (ColorMode mode : mTestColorModes) {
+ ASSERT_NO_FATAL_FAILURE(
+ mComposerClient->setColorMode(mPrimaryDisplay, mode, RenderIntent::COLORIMETRIC));
+
+ if (!getHasReadbackBuffer()) {
+ GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
+ return;
+ }
+
+ std::vector<Color> expectedColors(static_cast<size_t>(mDisplayWidth * mDisplayHeight));
+
+ setBackgroundColor(BLACK);
+ setTopLayerColor(TRANSLUCENT_RED);
+
+ setUpLayers(BlendMode::COVERAGE);
+ setExpectedColors(expectedColors);
+
+ ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mGraphicBuffer,
+ mDisplayWidth, mDisplayHeight, mPixelFormat, mDataspace);
+ ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
+ writeLayers(mLayers);
+ ASSERT_TRUE(mReader.takeErrors().empty());
+ mWriter.validateDisplay(mPrimaryDisplay);
+ execute();
+ std::vector<int64_t> changedCompositionLayers;
+ std::vector<Composition> changedCompositionTypes;
+ mReader.takeChangedCompositionTypes(mPrimaryDisplay, &changedCompositionLayers,
+ &changedCompositionTypes);
+ if (!changedCompositionLayers.empty()) {
+ GTEST_SUCCEED();
+ return;
+ }
+ ASSERT_TRUE(mReader.takeErrors().empty());
+ mWriter.presentDisplay(mPrimaryDisplay);
+ execute();
+ ASSERT_TRUE(mReader.takeErrors().empty());
+ ASSERT_NO_FATAL_FAILURE(readbackBuffer.checkReadbackBuffer(expectedColors));
+ }
+}
+
+TEST_P(GraphicsBlendModeCompositionTest, Premultiplied) {
+ for (ColorMode mode : mTestColorModes) {
+ ASSERT_NO_FATAL_FAILURE(
+ mComposerClient->setColorMode(mPrimaryDisplay, mode, RenderIntent::COLORIMETRIC));
+
+ if (!getHasReadbackBuffer()) {
+ GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
+ return;
+ }
+
+ std::vector<Color> expectedColors(static_cast<size_t>(mDisplayWidth * mDisplayHeight));
+
+ setBackgroundColor(BLACK);
+ setTopLayerColor(TRANSLUCENT_RED);
+ setUpLayers(BlendMode::PREMULTIPLIED);
+ setExpectedColors(expectedColors);
+
+ ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mGraphicBuffer,
+ mDisplayWidth, mDisplayHeight, mPixelFormat, mDataspace);
+ ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
+ writeLayers(mLayers);
+ ASSERT_TRUE(mReader.takeErrors().empty());
+ mWriter.validateDisplay(mPrimaryDisplay);
+ execute();
+ std::vector<int64_t> changedCompositionLayers;
+ std::vector<Composition> changedCompositionTypes;
+ mReader.takeChangedCompositionTypes(mPrimaryDisplay, &changedCompositionLayers,
+ &changedCompositionTypes);
+ if (!changedCompositionLayers.empty()) {
+ GTEST_SUCCEED();
+ return;
+ }
+ ASSERT_TRUE(mReader.takeErrors().empty());
+ mWriter.presentDisplay(mPrimaryDisplay);
+ execute();
+ ASSERT_TRUE(mReader.takeErrors().empty());
+ ASSERT_NO_FATAL_FAILURE(readbackBuffer.checkReadbackBuffer(expectedColors));
+ mTestRenderEngine->setRenderLayers(mLayers);
+ ASSERT_NO_FATAL_FAILURE(mTestRenderEngine->drawLayers());
+ ASSERT_NO_FATAL_FAILURE(mTestRenderEngine->checkColorBuffer(expectedColors));
+ }
+}
+
+class GraphicsTransformCompositionTest : public GraphicsCompositionTest {
+ protected:
+ void SetUp() override {
+ GraphicsCompositionTest::SetUp();
+
+ auto backgroundLayer = std::make_shared<TestColorLayer>(mComposerClient, mPrimaryDisplay);
+ backgroundLayer->setColor({0, 0, 0, 0});
+ backgroundLayer->setDisplayFrame({0, 0, mDisplayWidth, mDisplayHeight});
+ backgroundLayer->setZOrder(0);
+
+ mSideLength = mDisplayWidth < mDisplayHeight ? mDisplayWidth : mDisplayHeight;
+ common::Rect redRect = {0, 0, mSideLength / 2, mSideLength / 2};
+ common::Rect blueRect = {mSideLength / 2, mSideLength / 2, mSideLength, mSideLength};
+
+ mLayer = std::make_shared<TestBufferLayer>(mComposerClient, mGraphicBuffer,
+ *mTestRenderEngine, mPrimaryDisplay, mSideLength,
+ mSideLength, PixelFormat::RGBA_8888);
+ mLayer->setDisplayFrame({0, 0, mSideLength, mSideLength});
+ mLayer->setZOrder(10);
+
+ std::vector<Color> baseColors(static_cast<size_t>(mSideLength * mSideLength));
+ ReadbackHelper::fillColorsArea(baseColors, mSideLength, redRect, RED);
+ ReadbackHelper::fillColorsArea(baseColors, mSideLength, blueRect, BLUE);
+ ASSERT_NO_FATAL_FAILURE(mLayer->setBuffer(baseColors));
+ mLayers = {backgroundLayer, mLayer};
+ }
+
+ protected:
+ std::shared_ptr<TestBufferLayer> mLayer;
+ std::vector<std::shared_ptr<TestLayer>> mLayers;
+ int mSideLength;
+};
+
+TEST_P(GraphicsTransformCompositionTest, FLIP_H) {
+ for (ColorMode mode : mTestColorModes) {
+ auto error =
+ mComposerClient->setColorMode(mPrimaryDisplay, mode, RenderIntent::COLORIMETRIC);
+ if (!error.isOk() &&
+ (error.getServiceSpecificError() == IComposerClient::EX_UNSUPPORTED ||
+ error.getServiceSpecificError() == IComposerClient::EX_BAD_PARAMETER)) {
+ SUCCEED() << "ColorMode not supported, skip test";
+ return;
+ }
+
+ if (!getHasReadbackBuffer()) {
+ GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
+ return;
+ }
+ ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mGraphicBuffer,
+ mDisplayWidth, mDisplayHeight, mPixelFormat, mDataspace);
+ ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
+ mLayer->setTransform(Transform::FLIP_H);
+ mLayer->setDataspace(ReadbackHelper::getDataspaceForColorMode(mode), mWriter);
+
+ std::vector<Color> expectedColors(static_cast<size_t>(mDisplayWidth * mDisplayHeight));
+ ReadbackHelper::fillColorsArea(expectedColors, mDisplayWidth,
+ {mSideLength / 2, 0, mSideLength, mSideLength / 2}, RED);
+ ReadbackHelper::fillColorsArea(expectedColors, mDisplayWidth,
+ {0, mSideLength / 2, mSideLength / 2, mSideLength}, BLUE);
+
+ writeLayers(mLayers);
+ ASSERT_TRUE(mReader.takeErrors().empty());
+ mWriter.validateDisplay(mPrimaryDisplay);
+ execute();
+ std::vector<int64_t> changedCompositionLayers;
+ std::vector<Composition> changedCompositionTypes;
+ mReader.takeChangedCompositionTypes(mPrimaryDisplay, &changedCompositionLayers,
+ &changedCompositionTypes);
+ if (!changedCompositionLayers.empty()) {
+ GTEST_SUCCEED();
+ return;
+ }
+ ASSERT_TRUE(mReader.takeErrors().empty());
+ mWriter.presentDisplay(mPrimaryDisplay);
+ execute();
+ ASSERT_TRUE(mReader.takeErrors().empty());
+
+ ASSERT_NO_FATAL_FAILURE(readbackBuffer.checkReadbackBuffer(expectedColors));
+ mTestRenderEngine->setRenderLayers(mLayers);
+ ASSERT_NO_FATAL_FAILURE(mTestRenderEngine->drawLayers());
+ ASSERT_NO_FATAL_FAILURE(mTestRenderEngine->checkColorBuffer(expectedColors));
+ }
+}
+
+TEST_P(GraphicsTransformCompositionTest, FLIP_V) {
+ for (ColorMode mode : mTestColorModes) {
+ ASSERT_NO_FATAL_FAILURE(
+ mComposerClient->setColorMode(mPrimaryDisplay, mode, RenderIntent::COLORIMETRIC));
+
+ if (!getHasReadbackBuffer()) {
+ GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
+ return;
+ }
+ ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mGraphicBuffer,
+ mDisplayWidth, mDisplayHeight, mPixelFormat, mDataspace);
+ ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
+
+ mLayer->setTransform(Transform::FLIP_V);
+ mLayer->setDataspace(ReadbackHelper::getDataspaceForColorMode(mode), mWriter);
+
+ std::vector<Color> expectedColors(static_cast<size_t>(mDisplayWidth * mDisplayHeight));
+ ReadbackHelper::fillColorsArea(expectedColors, mDisplayWidth,
+ {0, mSideLength / 2, mSideLength / 2, mSideLength}, RED);
+ ReadbackHelper::fillColorsArea(expectedColors, mDisplayWidth,
+ {mSideLength / 2, 0, mSideLength, mSideLength / 2}, BLUE);
+
+ writeLayers(mLayers);
+ ASSERT_TRUE(mReader.takeErrors().empty());
+ mWriter.validateDisplay(mPrimaryDisplay);
+ execute();
+ std::vector<int64_t> changedCompositionLayers;
+ std::vector<Composition> changedCompositionTypes;
+ mReader.takeChangedCompositionTypes(mPrimaryDisplay, &changedCompositionLayers,
+ &changedCompositionTypes);
+ if (!changedCompositionLayers.empty()) {
+ GTEST_SUCCEED();
+ return;
+ }
+ ASSERT_TRUE(mReader.takeErrors().empty());
+ mWriter.presentDisplay(mPrimaryDisplay);
+ execute();
+ ASSERT_TRUE(mReader.takeErrors().empty());
+ ASSERT_NO_FATAL_FAILURE(readbackBuffer.checkReadbackBuffer(expectedColors));
+ mTestRenderEngine->setRenderLayers(mLayers);
+ ASSERT_NO_FATAL_FAILURE(mTestRenderEngine->drawLayers());
+ ASSERT_NO_FATAL_FAILURE(mTestRenderEngine->checkColorBuffer(expectedColors));
+ }
+}
+
+TEST_P(GraphicsTransformCompositionTest, ROT_180) {
+ for (ColorMode mode : mTestColorModes) {
+ ASSERT_NO_FATAL_FAILURE(
+ mComposerClient->setColorMode(mPrimaryDisplay, mode, RenderIntent::COLORIMETRIC));
+
+ if (!getHasReadbackBuffer()) {
+ GTEST_SUCCEED() << "Readback not supported or unsupported pixelFormat/dataspace";
+ return;
+ }
+ ReadbackBuffer readbackBuffer(mPrimaryDisplay, mComposerClient, mGraphicBuffer,
+ mDisplayWidth, mDisplayHeight, mPixelFormat, mDataspace);
+ ASSERT_NO_FATAL_FAILURE(readbackBuffer.setReadbackBuffer());
+
+ mLayer->setTransform(Transform::ROT_180);
+ mLayer->setDataspace(ReadbackHelper::getDataspaceForColorMode(mode), mWriter);
+
+ std::vector<Color> expectedColors(static_cast<size_t>(mDisplayWidth * mDisplayHeight));
+ ReadbackHelper::fillColorsArea(expectedColors, mDisplayWidth,
+ {mSideLength / 2, mSideLength / 2, mSideLength, mSideLength},
+ RED);
+ ReadbackHelper::fillColorsArea(expectedColors, mDisplayWidth,
+ {0, 0, mSideLength / 2, mSideLength / 2}, BLUE);
+
+ writeLayers(mLayers);
+ ASSERT_TRUE(mReader.takeErrors().empty());
+ mWriter.validateDisplay(mPrimaryDisplay);
+ execute();
+ std::vector<int64_t> layers;
+ std::vector<Composition> types;
+ mReader.takeChangedCompositionTypes(mPrimaryDisplay, &layers, &types);
+ if (!layers.empty()) {
+ GTEST_SUCCEED();
+ return;
+ }
+ ASSERT_TRUE(mReader.takeErrors().empty());
+ mWriter.presentDisplay(mPrimaryDisplay);
+ execute();
+ ASSERT_TRUE(mReader.takeErrors().empty());
+ ASSERT_NO_FATAL_FAILURE(readbackBuffer.checkReadbackBuffer(expectedColors));
+ mTestRenderEngine->setRenderLayers(mLayers);
+ ASSERT_NO_FATAL_FAILURE(mTestRenderEngine->drawLayers());
+ ASSERT_NO_FATAL_FAILURE(mTestRenderEngine->checkColorBuffer(expectedColors));
+ }
+}
+
+GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(GraphicsCompositionTest);
+INSTANTIATE_TEST_SUITE_P(
+ PerInstance, GraphicsCompositionTest,
+ testing::ValuesIn(::android::getAidlHalInstanceNames(IComposer::descriptor)),
+ ::android::PrintInstanceNameToString);
+
+GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(GraphicsBlendModeCompositionTest);
+INSTANTIATE_TEST_SUITE_P(BlendMode, GraphicsBlendModeCompositionTest,
+ testing::Combine(testing::ValuesIn(::android::getAidlHalInstanceNames(
+ IComposer::descriptor)),
+ testing::Values("0.2", "1.0")));
+
+GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(GraphicsTransformCompositionTest);
+INSTANTIATE_TEST_SUITE_P(
+ PerInstance, GraphicsTransformCompositionTest,
+ testing::ValuesIn(::android::getAidlHalInstanceNames(IComposer::descriptor)),
+ ::android::PrintInstanceNameToString);
+
+} // namespace
+} // namespace aidl::android::hardware::graphics::composer3::vts
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/VtsHalGraphicsComposer3_TargetTest.cpp b/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/VtsHalGraphicsComposer3_TargetTest.cpp
index 2d23b08..20fffa9 100644
--- a/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/VtsHalGraphicsComposer3_TargetTest.cpp
+++ b/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/VtsHalGraphicsComposer3_TargetTest.cpp
@@ -4,10 +4,10 @@
#include <aidl/Gtest.h>
#include <aidl/Vintf.h>
+#include <aidl/android/hardware/graphics/common/BlendMode.h>
#include <aidl/android/hardware/graphics/common/BufferUsage.h>
#include <aidl/android/hardware/graphics/common/FRect.h>
#include <aidl/android/hardware/graphics/common/Rect.h>
-#include <aidl/android/hardware/graphics/composer3/BlendMode.h>
#include <aidl/android/hardware/graphics/composer3/Composition.h>
#include <aidl/android/hardware/graphics/composer3/IComposer.h>
#include <android-base/properties.h>
@@ -27,7 +27,6 @@
#include <unordered_set>
#include <utility>
#include "composer-vts/include/GraphicsComposerCallback.h"
-#include "composer-vts/include/TestCommandReader.h"
// TODO(b/129481165): remove the #pragma below and fix conversion issues
#pragma clang diagnostic pop // ignored "-Wconversion
@@ -40,6 +39,9 @@
using namespace std::chrono_literals;
+using ::android::GraphicBuffer;
+using ::android::sp;
+
class VtsDisplay {
public:
VtsDisplay(int64_t displayId, int32_t displayWidth, int32_t displayHeight)
@@ -73,40 +75,117 @@
ASSERT_NO_FATAL_FAILURE(mComposer = IComposer::fromBinder(binder));
ASSERT_NE(mComposer, nullptr);
ASSERT_NO_FATAL_FAILURE(mComposer->createClient(&mComposerClient));
- mInvalidDisplayId = GetInvalidDisplayId();
mComposerCallback = ::ndk::SharedRefBase::make<GraphicsComposerCallback>();
EXPECT_TRUE(mComposerClient->registerCallback(mComposerCallback).isOk());
// assume the first displays are built-in and are never removed
mDisplays = waitForDisplays();
-
mPrimaryDisplay = mDisplays[0].get();
+ ASSERT_NO_FATAL_FAILURE(mInvalidDisplayId = GetInvalidDisplayId());
+
+ int32_t activeConfig;
+ EXPECT_TRUE(mComposerClient->getActiveConfig(mPrimaryDisplay, &activeConfig).isOk());
+ EXPECT_TRUE(mComposerClient
+ ->getDisplayAttribute(mPrimaryDisplay, activeConfig,
+ DisplayAttribute::WIDTH, &mDisplayWidth)
+ .isOk());
+ EXPECT_TRUE(mComposerClient
+ ->getDisplayAttribute(mPrimaryDisplay, activeConfig,
+ DisplayAttribute::HEIGHT, &mDisplayHeight)
+ .isOk());
// explicitly disable vsync
for (const auto& display : mDisplays) {
EXPECT_TRUE(mComposerClient->setVsyncEnabled(display.get(), false).isOk());
}
mComposerCallback->setVsyncAllowed(false);
-
- mWriter = std::make_unique<CommandWriterBase>(1024);
- mReader = std::make_unique<TestCommandReader>();
}
void TearDown() override {
- ASSERT_EQ(0, mReader->mErrors.size());
- ASSERT_EQ(0, mReader->mCompositionChanges.size());
-
+ destroyAllLayers();
if (mComposerCallback != nullptr) {
EXPECT_EQ(0, mComposerCallback->getInvalidHotplugCount());
EXPECT_EQ(0, mComposerCallback->getInvalidRefreshCount());
EXPECT_EQ(0, mComposerCallback->getInvalidVsyncCount());
- EXPECT_EQ(0, mComposerCallback->getInvalidVsyncCount());
EXPECT_EQ(0, mComposerCallback->getInvalidVsyncPeriodChangeCount());
EXPECT_EQ(0, mComposerCallback->getInvalidSeamlessPossibleCount());
}
}
+ void Test_setContentTypeForDisplay(const int64_t& display,
+ const std::vector<ContentType>& capabilities,
+ const ContentType& contentType, const char* contentTypeStr) {
+ const bool contentTypeSupport = std::find(capabilities.begin(), capabilities.end(),
+ contentType) != capabilities.end();
+
+ if (!contentTypeSupport) {
+ EXPECT_EQ(IComposerClient::EX_UNSUPPORTED,
+ mComposerClient->setContentType(display, contentType)
+ .getServiceSpecificError());
+ GTEST_SUCCEED() << contentTypeStr << " content type is not supported on display "
+ << std::to_string(display) << ", skipping test";
+ return;
+ }
+
+ EXPECT_TRUE(mComposerClient->setContentType(display, contentType).isOk());
+ EXPECT_TRUE(mComposerClient->setContentType(display, ContentType::NONE).isOk());
+ }
+
+ void Test_setContentType(const ContentType& contentType, const char* contentTypeStr) {
+ for (const auto& display : mDisplays) {
+ std::vector<ContentType> supportedContentTypes;
+ const auto error = mComposerClient->getSupportedContentTypes(display.get(),
+ &supportedContentTypes);
+ EXPECT_TRUE(error.isOk());
+
+ Test_setContentTypeForDisplay(display.get(), supportedContentTypes, contentType,
+ contentTypeStr);
+ }
+ }
+
+ int64_t createLayer(const VtsDisplay& display) {
+ int64_t layer;
+ EXPECT_TRUE(mComposerClient->createLayer(display.get(), kBufferSlotCount, &layer).isOk());
+
+ auto resourceIt = mDisplayResources.find(display.get());
+ if (resourceIt == mDisplayResources.end()) {
+ resourceIt = mDisplayResources.insert({display.get(), DisplayResource(false)}).first;
+ }
+
+ EXPECT_TRUE(resourceIt->second.layers.insert(layer).second)
+ << "duplicated layer id " << layer;
+
+ return layer;
+ }
+
+ void destroyAllLayers() {
+ for (const auto& it : mDisplayResources) {
+ auto display = it.first;
+ const DisplayResource& resource = it.second;
+
+ for (auto layer : resource.layers) {
+ const auto error = mComposerClient->destroyLayer(display, layer);
+ EXPECT_TRUE(error.isOk());
+ }
+
+ if (resource.isVirtual) {
+ const auto error = mComposerClient->destroyVirtualDisplay(display);
+ EXPECT_TRUE(error.isOk());
+ }
+ }
+ mDisplayResources.clear();
+ }
+
+ void destroyLayer(const VtsDisplay& display, int64_t layer) {
+ auto const error = mComposerClient->destroyLayer(display.get(), layer);
+ ASSERT_TRUE(error.isOk()) << "failed to destroy layer " << layer;
+
+ auto resourceIt = mDisplayResources.find(display.get());
+ ASSERT_NE(mDisplayResources.end(), resourceIt);
+ resourceIt->second.layers.erase(layer);
+ }
+
// returns an invalid display id (one that has not been registered to a
// display. Currently assuming that a device will never have close to
// std::numeric_limit<uint64_t>::max() displays registered while running tests
@@ -120,7 +199,11 @@
id--;
}
- return 0;
+ // Although 0 could be an invalid display, a return value of 0
+ // from GetInvalidDisplayId means all other ids are in use, a condition which
+ // we are assuming a device will never have
+ EXPECT_NE(0, id);
+ return id;
}
std::vector<VtsDisplay> waitForDisplays() {
@@ -179,313 +262,11 @@
return error;
}
- void Test_setContentTypeForDisplay(const int64_t& display,
- const std::vector<ContentType>& capabilities,
- const ContentType& contentType, const char* contentTypeStr) {
- const bool contentTypeSupport = std::find(capabilities.begin(), capabilities.end(),
- contentType) != capabilities.end();
-
- if (!contentTypeSupport) {
- EXPECT_EQ(IComposerClient::EX_UNSUPPORTED,
- mComposerClient->setContentType(display, contentType)
- .getServiceSpecificError());
- GTEST_SUCCEED() << contentTypeStr << " content type is not supported on display "
- << std::to_string(display) << ", skipping test";
- return;
- }
-
- EXPECT_TRUE(mComposerClient->setContentType(display, contentType).isOk());
- EXPECT_TRUE(mComposerClient->setContentType(display, ContentType::NONE).isOk());
- }
-
- void Test_setContentType(const ContentType& contentType, const char* contentTypeStr) {
- for (const auto& display : mDisplays) {
- std::vector<ContentType> supportedContentTypes;
- const auto error = mComposerClient->getSupportedContentTypes(display.get(),
- &supportedContentTypes);
- EXPECT_TRUE(error.isOk());
-
- Test_setContentTypeForDisplay(display.get(), supportedContentTypes, contentType,
- contentTypeStr);
- }
- }
-
- void execute() {
- TestCommandReader* reader = mReader.get();
- CommandWriterBase* writer = mWriter.get();
- bool queueChanged = false;
- int32_t commandLength = 0;
- std::vector<NativeHandle> commandHandles;
- ASSERT_TRUE(writer->writeQueue(&queueChanged, &commandLength, &commandHandles));
-
- if (queueChanged) {
- auto ret = mComposerClient->setInputCommandQueue(writer->getMQDescriptor());
- ASSERT_TRUE(ret.isOk());
- }
-
- ExecuteCommandsStatus commandStatus;
- EXPECT_TRUE(mComposerClient->executeCommands(commandLength, commandHandles, &commandStatus)
- .isOk());
-
- if (commandStatus.queueChanged) {
- MQDescriptor<int32_t, SynchronizedReadWrite> outputCommandQueue;
- ASSERT_TRUE(mComposerClient->getOutputCommandQueue(&outputCommandQueue).isOk());
- reader->setMQDescriptor(outputCommandQueue);
- }
- ASSERT_TRUE(reader->readQueue(commandStatus.length, std::move(commandStatus.handles)));
- reader->parse();
- reader->reset();
- writer->reset();
- }
-
- ::android::sp<::android::GraphicBuffer> allocate(uint32_t width, uint32_t height) {
- ::android::sp<::android::GraphicBuffer> buffer =
- ::android::sp<::android::GraphicBuffer>::make(
- width, height, ::android::PIXEL_FORMAT_RGBA_8888,
- /*layerCount*/ 1,
- static_cast<uint64_t>(
- static_cast<int>(common::BufferUsage::CPU_WRITE_OFTEN) |
- static_cast<int>(common::BufferUsage::CPU_READ_OFTEN)),
- "VtsHalGraphicsComposer3_TargetTest");
-
- return buffer;
- }
-
struct TestParameters {
nsecs_t delayForChange;
bool refreshMiss;
};
- static inline auto toTimePoint(nsecs_t time) {
- return std::chrono::time_point<std::chrono::steady_clock>(std::chrono::nanoseconds(time));
- }
-
- int64_t createLayer(const VtsDisplay& display) {
- int64_t layer;
- EXPECT_TRUE(mComposerClient->createLayer(display.get(), kBufferSlotCount, &layer).isOk());
-
- auto resourceIt = mDisplayResources.find(display.get());
- if (resourceIt == mDisplayResources.end()) {
- resourceIt = mDisplayResources.insert({display.get(), DisplayResource(false)}).first;
- }
-
- EXPECT_TRUE(resourceIt->second.layers.insert(layer).second)
- << "duplicated layer id " << layer;
-
- return layer;
- }
-
- void destroyLayer(const VtsDisplay& display, int64_t layer) {
- auto const error = mComposerClient->destroyLayer(display.get(), layer);
- ASSERT_TRUE(error.isOk()) << "failed to destroy layer " << layer;
-
- auto resourceIt = mDisplayResources.find(display.get());
- ASSERT_NE(mDisplayResources.end(), resourceIt);
- resourceIt->second.layers.erase(layer);
- }
-
- void forEachTwoConfigs(int64_t display, std::function<void(int32_t, int32_t)> func) {
- std::vector<int32_t> displayConfigs;
- EXPECT_TRUE(mComposerClient->getDisplayConfigs(display, &displayConfigs).isOk());
- for (const int32_t config1 : displayConfigs) {
- for (const int32_t config2 : displayConfigs) {
- if (config1 != config2) {
- func(config1, config2);
- }
- }
- }
- }
-
- void setActiveConfig(VtsDisplay& display, int32_t config) {
- EXPECT_TRUE(mComposerClient->setActiveConfig(display.get(), config).isOk());
- int32_t displayWidth;
- EXPECT_TRUE(mComposerClient
- ->getDisplayAttribute(display.get(), config, DisplayAttribute::WIDTH,
- &displayWidth)
- .isOk());
- int32_t displayHeight;
- EXPECT_TRUE(mComposerClient
- ->getDisplayAttribute(display.get(), config, DisplayAttribute::HEIGHT,
- &displayHeight)
- .isOk());
- display.setDimensions(displayWidth, displayHeight);
- }
-
- void sendRefreshFrame(const VtsDisplay& display, const VsyncPeriodChangeTimeline* timeline) {
- if (timeline != nullptr) {
- // Refresh time should be before newVsyncAppliedTimeNanos
- EXPECT_LT(timeline->refreshTimeNanos, timeline->newVsyncAppliedTimeNanos);
-
- std::this_thread::sleep_until(toTimePoint(timeline->refreshTimeNanos));
- }
-
- mWriter->selectDisplay(display.get());
- EXPECT_TRUE(mComposerClient->setPowerMode(display.get(), PowerMode::ON).isOk());
- EXPECT_TRUE(
- mComposerClient
- ->setColorMode(display.get(), ColorMode::NATIVE, RenderIntent::COLORIMETRIC)
- .isOk());
-
- FRect displayCrop = display.getCrop();
- auto displayWidth = static_cast<uint32_t>(std::ceilf(displayCrop.right - displayCrop.left));
- auto displayHeight =
- static_cast<uint32_t>(std::ceilf(displayCrop.bottom - displayCrop.top));
- int64_t layer = 0;
- ASSERT_NO_FATAL_FAILURE(layer = createLayer(display));
- {
- auto buffer = allocate(displayWidth, displayHeight);
- ASSERT_NE(nullptr, buffer);
- ASSERT_EQ(::android::OK, buffer->initCheck());
- ASSERT_NE(nullptr, buffer->handle);
-
- mWriter->selectLayer(layer);
- mWriter->setLayerCompositionType(Composition::DEVICE);
- mWriter->setLayerDisplayFrame(display.getFrameRect());
- mWriter->setLayerPlaneAlpha(1);
- mWriter->setLayerSourceCrop(display.getCrop());
- mWriter->setLayerTransform(static_cast<Transform>(0));
- mWriter->setLayerVisibleRegion(std::vector<Rect>(1, display.getFrameRect()));
- mWriter->setLayerZOrder(10);
- mWriter->setLayerBlendMode(BlendMode::NONE);
- mWriter->setLayerSurfaceDamage(std::vector<Rect>(1, display.getFrameRect()));
- mWriter->setLayerBuffer(0, buffer->handle, -1);
- mWriter->setLayerDataspace(common::Dataspace::UNKNOWN);
-
- mWriter->validateDisplay();
- execute();
- ASSERT_EQ(0, mReader->mErrors.size());
- mReader->mCompositionChanges.clear();
-
- mWriter->presentDisplay();
- execute();
- ASSERT_EQ(0, mReader->mErrors.size());
- }
-
- {
- auto buffer = allocate(displayWidth, displayHeight);
- ASSERT_NE(nullptr, buffer->handle);
-
- mWriter->selectLayer(layer);
- mWriter->setLayerBuffer(0, buffer->handle, -1);
- mWriter->setLayerSurfaceDamage(std::vector<Rect>(1, {0, 0, 10, 10}));
- mWriter->validateDisplay();
- execute();
- ASSERT_EQ(0, mReader->mErrors.size());
- mReader->mCompositionChanges.clear();
-
- mWriter->presentDisplay();
- execute();
- }
-
- ASSERT_NO_FATAL_FAILURE(destroyLayer(display, layer));
- }
-
- void waitForVsyncPeriodChange(int64_t display, const VsyncPeriodChangeTimeline& timeline,
- int64_t desiredTimeNanos, int64_t oldPeriodNanos,
- int64_t newPeriodNanos) {
- const auto kChangeDeadline = toTimePoint(timeline.newVsyncAppliedTimeNanos) + 100ms;
- while (std::chrono::steady_clock::now() <= kChangeDeadline) {
- int32_t vsyncPeriodNanos;
- EXPECT_TRUE(mComposerClient->getDisplayVsyncPeriod(display, &vsyncPeriodNanos).isOk());
- if (systemTime() <= desiredTimeNanos) {
- EXPECT_EQ(vsyncPeriodNanos, oldPeriodNanos);
- } else if (vsyncPeriodNanos == newPeriodNanos) {
- break;
- }
- std::this_thread::sleep_for(std::chrono::nanoseconds(oldPeriodNanos));
- }
- }
-
- void Test_setActiveConfigWithConstraints(const TestParameters& params) {
- for (VtsDisplay& display : mDisplays) {
- forEachTwoConfigs(display.get(), [&](int32_t config1, int32_t config2) {
- setActiveConfig(display, config1);
- sendRefreshFrame(display, nullptr);
-
- int32_t vsyncPeriod1;
- EXPECT_TRUE(mComposerClient
- ->getDisplayAttribute(display.get(), config1,
- DisplayAttribute::VSYNC_PERIOD,
- &vsyncPeriod1)
- .isOk());
- int32_t configGroup1;
- EXPECT_TRUE(mComposerClient
- ->getDisplayAttribute(display.get(), config1,
- DisplayAttribute::CONFIG_GROUP,
- &configGroup1)
- .isOk());
- int32_t vsyncPeriod2;
- EXPECT_TRUE(mComposerClient
- ->getDisplayAttribute(display.get(), config2,
- DisplayAttribute::VSYNC_PERIOD,
- &vsyncPeriod2)
- .isOk());
- int32_t configGroup2;
- EXPECT_TRUE(mComposerClient
- ->getDisplayAttribute(display.get(), config2,
- DisplayAttribute::CONFIG_GROUP,
- &configGroup2)
- .isOk());
-
- if (vsyncPeriod1 == vsyncPeriod2) {
- return; // continue
- }
-
- // We don't allow delayed change when changing config groups
- if (params.delayForChange > 0 && configGroup1 != configGroup2) {
- return; // continue
- }
-
- VsyncPeriodChangeTimeline timeline;
- VsyncPeriodChangeConstraints constraints = {
- .desiredTimeNanos = systemTime() + params.delayForChange,
- .seamlessRequired = false};
- EXPECT_TRUE(setActiveConfigWithConstraints(display, config2, constraints, &timeline)
- .isOk());
-
- EXPECT_TRUE(timeline.newVsyncAppliedTimeNanos >= constraints.desiredTimeNanos);
- // Refresh rate should change within a reasonable time
- constexpr std::chrono::nanoseconds kReasonableTimeForChange = 1s; // 1 second
- EXPECT_TRUE(timeline.newVsyncAppliedTimeNanos - constraints.desiredTimeNanos <=
- kReasonableTimeForChange.count());
-
- if (timeline.refreshRequired) {
- if (params.refreshMiss) {
- // Miss the refresh frame on purpose to make sure the implementation sends a
- // callback
- std::this_thread::sleep_until(toTimePoint(timeline.refreshTimeNanos) +
- 100ms);
- }
- sendRefreshFrame(display, &timeline);
- }
- waitForVsyncPeriodChange(display.get(), timeline, constraints.desiredTimeNanos,
- vsyncPeriod1, vsyncPeriod2);
-
- // At this point the refresh rate should have changed already, however in rare
- // cases the implementation might have missed the deadline. In this case a new
- // timeline should have been provided.
- auto newTimeline = mComposerCallback->takeLastVsyncPeriodChangeTimeline();
- if (timeline.refreshRequired && params.refreshMiss) {
- EXPECT_TRUE(newTimeline.has_value());
- }
-
- if (newTimeline.has_value()) {
- if (newTimeline->refreshRequired) {
- sendRefreshFrame(display, &newTimeline.value());
- }
- waitForVsyncPeriodChange(display.get(), newTimeline.value(),
- constraints.desiredTimeNanos, vsyncPeriod1,
- vsyncPeriod2);
- }
-
- int32_t vsyncPeriodNanos;
- EXPECT_TRUE(mComposerClient->getDisplayVsyncPeriod(display.get(), &vsyncPeriodNanos)
- .isOk());
- EXPECT_EQ(vsyncPeriodNanos, vsyncPeriod2);
- });
- }
- }
-
// Keep track of all virtual displays and layers. When a test fails with
// ASSERT_*, the destructor will clean up the resources for the test.
struct DisplayResource {
@@ -501,11 +282,11 @@
int64_t mPrimaryDisplay;
std::vector<VtsDisplay> mDisplays;
std::shared_ptr<GraphicsComposerCallback> mComposerCallback;
- std::unique_ptr<CommandWriterBase> mWriter;
- std::unique_ptr<TestCommandReader> mReader;
// use the slot count usually set by SF
static constexpr uint32_t kBufferSlotCount = 64;
std::unordered_map<int64_t, DisplayResource> mDisplayResources;
+ int32_t mDisplayWidth;
+ int32_t mDisplayHeight;
};
TEST_P(GraphicsComposerAidlTest, getDisplayCapabilitiesBadDisplay) {
@@ -524,102 +305,17 @@
}
}
-TEST_P(GraphicsComposerAidlTest, getDisplayVsyncPeriod) {
- for (VtsDisplay& display : mDisplays) {
- std::vector<int32_t> configs;
- EXPECT_TRUE(mComposerClient->getDisplayConfigs(display.get(), &configs).isOk());
- for (int32_t config : configs) {
- int32_t expectedVsyncPeriodNanos = -1;
- EXPECT_TRUE(mComposerClient
- ->getDisplayAttribute(display.get(), config,
- DisplayAttribute::VSYNC_PERIOD,
- &expectedVsyncPeriodNanos)
- .isOk());
-
- VsyncPeriodChangeTimeline timeline;
- VsyncPeriodChangeConstraints constraints;
-
- constraints.desiredTimeNanos = systemTime();
- constraints.seamlessRequired = false;
- EXPECT_TRUE(mComposerClient
- ->setActiveConfigWithConstraints(display.get(), config, constraints,
- &timeline)
- .isOk());
-
- if (timeline.refreshRequired) {
- sendRefreshFrame(display, &timeline);
- }
- waitForVsyncPeriodChange(display.get(), timeline, constraints.desiredTimeNanos, 0,
- expectedVsyncPeriodNanos);
-
- int32_t vsyncPeriodNanos;
- int retryCount = 100;
- do {
- std::this_thread::sleep_for(10ms);
- vsyncPeriodNanos = 0;
- EXPECT_TRUE(mComposerClient->getDisplayVsyncPeriod(display.get(), &vsyncPeriodNanos)
- .isOk());
- --retryCount;
- } while (vsyncPeriodNanos != expectedVsyncPeriodNanos && retryCount > 0);
-
- EXPECT_EQ(vsyncPeriodNanos, expectedVsyncPeriodNanos);
-
- // Make sure that the vsync period stays the same if the active config is not
- // changed.
- auto timeout = 1ms;
- for (int i = 0; i < 10; i++) {
- std::this_thread::sleep_for(timeout);
- timeout *= 2;
- vsyncPeriodNanos = 0;
- EXPECT_TRUE(mComposerClient->getDisplayVsyncPeriod(display.get(), &vsyncPeriodNanos)
- .isOk());
- EXPECT_EQ(vsyncPeriodNanos, expectedVsyncPeriodNanos);
- }
- }
- }
+TEST_P(GraphicsComposerAidlTest, DumpDebugInfo) {
+ std::string debugInfo;
+ EXPECT_TRUE(mComposer->dumpDebugInfo(&debugInfo).isOk());
}
-TEST_P(GraphicsComposerAidlTest, setActiveConfigWithConstraints_SeamlessNotAllowed) {
- VsyncPeriodChangeTimeline timeline;
- VsyncPeriodChangeConstraints constraints;
+TEST_P(GraphicsComposerAidlTest, CreateClientSingleton) {
+ std::shared_ptr<IComposerClient> composerClient;
+ const auto error = mComposer->createClient(&composerClient);
- constraints.seamlessRequired = true;
- constraints.desiredTimeNanos = systemTime();
-
- for (VtsDisplay& display : mDisplays) {
- forEachTwoConfigs(display.get(), [&](int32_t config1, int32_t config2) {
- int32_t configGroup1;
- EXPECT_TRUE(mComposerClient
- ->getDisplayAttribute(display.get(), config1,
- DisplayAttribute::CONFIG_GROUP, &configGroup1)
- .isOk());
- int32_t configGroup2;
- EXPECT_TRUE(mComposerClient
- ->getDisplayAttribute(display.get(), config2,
- DisplayAttribute::CONFIG_GROUP, &configGroup2)
- .isOk());
- if (configGroup1 != configGroup2) {
- setActiveConfig(display, config1);
- sendRefreshFrame(display, nullptr);
- EXPECT_EQ(IComposerClient::EX_SEAMLESS_NOT_ALLOWED,
- setActiveConfigWithConstraints(display, config2, constraints, &timeline)
- .getServiceSpecificError());
- }
- });
- }
-}
-
-TEST_P(GraphicsComposerAidlTest, setActiveConfigWithConstraints) {
- Test_setActiveConfigWithConstraints({.delayForChange = 0, .refreshMiss = false});
-}
-
-TEST_P(GraphicsComposerAidlTest, setActiveConfigWithConstraints_Delayed) {
- Test_setActiveConfigWithConstraints({.delayForChange = 300'000'000, // 300ms
- .refreshMiss = false});
-}
-
-TEST_P(GraphicsComposerAidlTest, setActiveConfigWithConstraints_MissRefresh) {
- Test_setActiveConfigWithConstraints({.delayForChange = 0, .refreshMiss = true});
+ EXPECT_FALSE(error.isOk());
+ EXPECT_EQ(IComposerClient::EX_NO_RESOURCES, error.getServiceSpecificError());
}
TEST_P(GraphicsComposerAidlTest, GetDisplayIdentificationData) {
@@ -658,51 +354,6 @@
<< "data is not stable";
}
-TEST_P(GraphicsComposerAidlTest, SET_LAYER_PER_FRAME_METADATA) {
- int64_t layer;
- EXPECT_TRUE(mComposerClient->createLayer(mPrimaryDisplay, kBufferSlotCount, &layer).isOk());
-
- mWriter->selectDisplay(mPrimaryDisplay);
- mWriter->selectLayer(layer);
-
- /**
- * DISPLAY_P3 is a color space that uses the DCI_P3 primaries,
- * the D65 white point and the SRGB transfer functions.
- * Rendering Intent: Colorimetric
- * Primaries:
- * x y
- * green 0.265 0.690
- * blue 0.150 0.060
- * red 0.680 0.320
- * white (D65) 0.3127 0.3290
- */
-
- std::vector<PerFrameMetadata> aidlMetadata;
- aidlMetadata.push_back({PerFrameMetadataKey::DISPLAY_RED_PRIMARY_X, 0.680f});
- aidlMetadata.push_back({PerFrameMetadataKey::DISPLAY_RED_PRIMARY_Y, 0.320f});
- aidlMetadata.push_back({PerFrameMetadataKey::DISPLAY_GREEN_PRIMARY_X, 0.265f});
- aidlMetadata.push_back({PerFrameMetadataKey::DISPLAY_GREEN_PRIMARY_Y, 0.690f});
- aidlMetadata.push_back({PerFrameMetadataKey::DISPLAY_BLUE_PRIMARY_X, 0.150f});
- aidlMetadata.push_back({PerFrameMetadataKey::DISPLAY_BLUE_PRIMARY_Y, 0.060f});
- aidlMetadata.push_back({PerFrameMetadataKey::WHITE_POINT_X, 0.3127f});
- aidlMetadata.push_back({PerFrameMetadataKey::WHITE_POINT_Y, 0.3290f});
- aidlMetadata.push_back({PerFrameMetadataKey::MAX_LUMINANCE, 100.0f});
- aidlMetadata.push_back({PerFrameMetadataKey::MIN_LUMINANCE, 0.1f});
- aidlMetadata.push_back({PerFrameMetadataKey::MAX_CONTENT_LIGHT_LEVEL, 78.0});
- aidlMetadata.push_back({PerFrameMetadataKey::MAX_FRAME_AVERAGE_LIGHT_LEVEL, 62.0});
- mWriter->setLayerPerFrameMetadata(aidlMetadata);
- execute();
-
- if (mReader->mErrors.size() == 1 && mReader->mErrors[0].second == EX_UNSUPPORTED_OPERATION) {
- mReader->mErrors.clear();
- GTEST_SUCCEED() << "SetLayerPerFrameMetadata is not supported";
- EXPECT_TRUE(mComposerClient->destroyLayer(mPrimaryDisplay, layer).isOk());
- return;
- }
-
- EXPECT_TRUE(mComposerClient->destroyLayer(mPrimaryDisplay, layer).isOk());
-}
-
TEST_P(GraphicsComposerAidlTest, GetHdrCapabilities) {
HdrCapabilities hdrCapabilities;
const auto error = mComposerClient->getHdrCapabilities(mPrimaryDisplay, &hdrCapabilities);
@@ -816,11 +467,19 @@
}
TEST_P(GraphicsComposerAidlTest, SetColorModeBadDisplay) {
- auto const error = mComposerClient->setColorMode(mInvalidDisplayId, ColorMode::NATIVE,
- RenderIntent::COLORIMETRIC);
+ std::vector<ColorMode> colorModes;
+ EXPECT_TRUE(mComposerClient->getColorModes(mPrimaryDisplay, &colorModes).isOk());
+ for (auto mode : colorModes) {
+ std::vector<RenderIntent> intents;
+ EXPECT_TRUE(mComposerClient->getRenderIntents(mPrimaryDisplay, mode, &intents).isOk())
+ << "failed to get render intents";
+ for (auto intent : intents) {
+ auto const error = mComposerClient->setColorMode(mInvalidDisplayId, mode, intent);
- EXPECT_FALSE(error.isOk());
- ASSERT_EQ(IComposerClient::EX_BAD_DISPLAY, error.getServiceSpecificError());
+ EXPECT_FALSE(error.isOk());
+ ASSERT_EQ(IComposerClient::EX_BAD_DISPLAY, error.getServiceSpecificError());
+ }
+ }
}
TEST_P(GraphicsComposerAidlTest, SetColorModeBadParameter) {
@@ -837,31 +496,6 @@
EXPECT_EQ(IComposerClient::EX_BAD_PARAMETER, renderIntentError.getServiceSpecificError());
}
-TEST_P(GraphicsComposerAidlTest, SetLayerColorTransform) {
- int64_t layer;
- EXPECT_TRUE(mComposerClient->createLayer(mPrimaryDisplay, kBufferSlotCount, &layer).isOk());
- mWriter->selectDisplay(mPrimaryDisplay);
- mWriter->selectLayer(layer);
-
- // clang-format off
- const std::array<float, 16> matrix = {{
- 1.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, 1.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 1.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, 1.0f,
- }};
- // clang-format on
-
- mWriter->setLayerColorTransform(matrix.data());
- execute();
-
- if (mReader->mErrors.size() == 1 && mReader->mErrors[0].second == EX_UNSUPPORTED_OPERATION) {
- mReader->mErrors.clear();
- GTEST_SUCCEED() << "setLayerColorTransform is not supported";
- return;
- }
-}
-
TEST_P(GraphicsComposerAidlTest, GetDisplayedContentSamplingAttributes) {
int constexpr invalid = -1;
@@ -932,25 +566,6 @@
}
}
-TEST_P(GraphicsComposerAidlTest, getDisplayCapabilitiesBasic) {
- std::vector<DisplayCapability> capabilities;
- const auto error = mComposerClient->getDisplayCapabilities(mPrimaryDisplay, &capabilities);
- ASSERT_TRUE(error.isOk());
- const bool hasDozeSupport = std::find(capabilities.begin(), capabilities.end(),
- DisplayCapability::DOZE) != capabilities.end();
- bool isDozeSupported = false;
- EXPECT_TRUE(mComposerClient->getDozeSupport(mPrimaryDisplay, &isDozeSupported).isOk());
- EXPECT_EQ(hasDozeSupport, isDozeSupported);
-
- bool hasBrightnessSupport = std::find(capabilities.begin(), capabilities.end(),
- DisplayCapability::BRIGHTNESS) != capabilities.end();
- bool isBrightnessSupported = false;
- EXPECT_TRUE(
- mComposerClient->getDisplayBrightnessSupport(mPrimaryDisplay, &isBrightnessSupported)
- .isOk());
- EXPECT_EQ(isBrightnessSupported, hasBrightnessSupport);
-}
-
/*
* Test that if brightness operations are supported, setDisplayBrightness works as expected.
*/
@@ -1267,65 +882,241 @@
EXPECT_TRUE(mComposerClient->destroyVirtualDisplay(virtualDisplay.display).isOk());
}
+TEST_P(GraphicsComposerAidlTest, DestroyVirtualDisplayBadDisplay) {
+ int32_t maxDisplayCount = 0;
+ EXPECT_TRUE(mComposerClient->getMaxVirtualDisplayCount(&maxDisplayCount).isOk());
+ if (maxDisplayCount == 0) {
+ GTEST_SUCCEED() << "no virtual display support";
+ return;
+ }
+ const auto error = mComposerClient->destroyVirtualDisplay(mInvalidDisplayId);
+
+ EXPECT_FALSE(error.isOk());
+ ASSERT_EQ(IComposerClient::EX_BAD_DISPLAY, error.getServiceSpecificError());
+}
+
+TEST_P(GraphicsComposerAidlTest, CreateLayer) {
+ int64_t layer;
+ EXPECT_TRUE(mComposerClient->createLayer(mPrimaryDisplay, kBufferSlotCount, &layer).isOk());
+
+ EXPECT_TRUE(mComposerClient->destroyLayer(mPrimaryDisplay, layer).isOk());
+}
+
+TEST_P(GraphicsComposerAidlTest, CreateLayerBadDisplay) {
+ int64_t layer;
+ const auto error = mComposerClient->createLayer(mInvalidDisplayId, kBufferSlotCount, &layer);
+
+ EXPECT_FALSE(error.isOk());
+ ASSERT_EQ(IComposerClient::EX_BAD_DISPLAY, error.getServiceSpecificError());
+}
+
+TEST_P(GraphicsComposerAidlTest, DestroyLayerBadDisplay) {
+ int64_t layer;
+ EXPECT_TRUE(mComposerClient->createLayer(mPrimaryDisplay, kBufferSlotCount, &layer).isOk());
+
+ const auto error = mComposerClient->destroyLayer(mInvalidDisplayId, layer);
+
+ EXPECT_FALSE(error.isOk());
+ EXPECT_EQ(IComposerClient::EX_BAD_DISPLAY, error.getServiceSpecificError());
+ EXPECT_TRUE(mComposerClient->destroyLayer(mPrimaryDisplay, layer).isOk());
+}
+
+TEST_P(GraphicsComposerAidlTest, DestroyLayerBadLayerError) {
+ // We haven't created any layers yet, so any id should be invalid
+ const auto error = mComposerClient->destroyLayer(mPrimaryDisplay, 1);
+
+ EXPECT_FALSE(error.isOk());
+ EXPECT_EQ(IComposerClient::EX_BAD_LAYER, error.getServiceSpecificError());
+}
+
+TEST_P(GraphicsComposerAidlTest, GetActiveConfigBadDisplay) {
+ int32_t config;
+ const auto error = mComposerClient->getActiveConfig(mInvalidDisplayId, &config);
+
+ EXPECT_FALSE(error.isOk());
+ ASSERT_EQ(IComposerClient::EX_BAD_DISPLAY, error.getServiceSpecificError());
+}
+
+TEST_P(GraphicsComposerAidlTest, GetDisplayConfig) {
+ std::vector<int32_t> configs;
+ EXPECT_TRUE(mComposerClient->getDisplayConfigs(mPrimaryDisplay, &configs).isOk());
+}
+
+TEST_P(GraphicsComposerAidlTest, GetDisplayConfigBadDisplay) {
+ std::vector<int32_t> configs;
+ const auto error = mComposerClient->getDisplayConfigs(mInvalidDisplayId, &configs);
+
+ EXPECT_FALSE(error.isOk());
+ ASSERT_EQ(IComposerClient::EX_BAD_DISPLAY, error.getServiceSpecificError());
+}
+
+TEST_P(GraphicsComposerAidlTest, GetDisplayName) {
+ std::string displayName;
+ EXPECT_TRUE(mComposerClient->getDisplayName(mPrimaryDisplay, &displayName).isOk());
+}
+
+TEST_P(GraphicsComposerAidlTest, SetClientTargetSlotCount) {
+ EXPECT_TRUE(
+ mComposerClient->setClientTargetSlotCount(mPrimaryDisplay, kBufferSlotCount).isOk());
+}
+
+TEST_P(GraphicsComposerAidlTest, SetActiveConfig) {
+ std::vector<int32_t> configs;
+ EXPECT_TRUE(mComposerClient->getDisplayConfigs(mPrimaryDisplay, &configs).isOk());
+ for (auto config : configs) {
+ EXPECT_TRUE(mComposerClient->setActiveConfig(mPrimaryDisplay, config).isOk());
+ int32_t config1;
+ EXPECT_TRUE(mComposerClient->getActiveConfig(mPrimaryDisplay, &config1).isOk());
+ EXPECT_EQ(config, config1);
+ }
+}
+
+TEST_P(GraphicsComposerAidlTest, SetActiveConfigPowerCycle) {
+ EXPECT_TRUE(mComposerClient->setPowerMode(mPrimaryDisplay, PowerMode::OFF).isOk());
+ EXPECT_TRUE(mComposerClient->setPowerMode(mPrimaryDisplay, PowerMode::ON).isOk());
+
+ std::vector<int32_t> configs;
+ EXPECT_TRUE(mComposerClient->getDisplayConfigs(mPrimaryDisplay, &configs).isOk());
+ for (auto config : configs) {
+ EXPECT_TRUE(mComposerClient->setActiveConfig(mPrimaryDisplay, config).isOk());
+ int32_t config1;
+ EXPECT_TRUE(mComposerClient->getActiveConfig(mPrimaryDisplay, &config1).isOk());
+ EXPECT_EQ(config, config1);
+
+ EXPECT_TRUE(mComposerClient->setPowerMode(mPrimaryDisplay, PowerMode::OFF).isOk());
+ EXPECT_TRUE(mComposerClient->setPowerMode(mPrimaryDisplay, PowerMode::ON).isOk());
+ EXPECT_TRUE(mComposerClient->getActiveConfig(mPrimaryDisplay, &config1).isOk());
+ EXPECT_EQ(config, config1);
+ }
+}
+
+TEST_P(GraphicsComposerAidlTest, SetPowerModeUnsupported) {
+ std::vector<DisplayCapability> capabilities;
+ const auto error = mComposerClient->getDisplayCapabilities(mPrimaryDisplay, &capabilities);
+ ASSERT_TRUE(error.isOk());
+ const bool isDozeSupported = std::find(capabilities.begin(), capabilities.end(),
+ DisplayCapability::DOZE) != capabilities.end();
+ const bool isSuspendSupported = std::find(capabilities.begin(), capabilities.end(),
+ DisplayCapability::SUSPEND) != capabilities.end();
+ if (!isDozeSupported) {
+ auto error = mComposerClient->setPowerMode(mPrimaryDisplay, PowerMode::DOZE);
+ EXPECT_FALSE(error.isOk());
+ EXPECT_EQ(IComposerClient::EX_UNSUPPORTED, error.getServiceSpecificError());
+
+ error = mComposerClient->setPowerMode(mPrimaryDisplay, PowerMode::DOZE_SUSPEND);
+ EXPECT_FALSE(error.isOk());
+ EXPECT_EQ(IComposerClient::EX_UNSUPPORTED, error.getServiceSpecificError());
+ }
+
+ if (!isSuspendSupported) {
+ auto error = mComposerClient->setPowerMode(mPrimaryDisplay, PowerMode::ON_SUSPEND);
+ EXPECT_FALSE(error.isOk());
+ EXPECT_EQ(IComposerClient::EX_UNSUPPORTED, error.getServiceSpecificError());
+
+ error = mComposerClient->setPowerMode(mPrimaryDisplay, PowerMode::DOZE_SUSPEND);
+ EXPECT_FALSE(error.isOk());
+ EXPECT_EQ(IComposerClient::EX_UNSUPPORTED, error.getServiceSpecificError());
+ }
+}
+
+TEST_P(GraphicsComposerAidlTest, SetVsyncEnabled) {
+ mComposerCallback->setVsyncAllowed(true);
+
+ EXPECT_TRUE(mComposerClient->setVsyncEnabled(mPrimaryDisplay, true).isOk());
+ usleep(60 * 1000);
+ EXPECT_TRUE(mComposerClient->setVsyncEnabled(mPrimaryDisplay, false).isOk());
+
+ mComposerCallback->setVsyncAllowed(false);
+}
+
TEST_P(GraphicsComposerAidlTest, SetPowerMode) {
+ std::vector<DisplayCapability> capabilities;
+ const auto error = mComposerClient->getDisplayCapabilities(mPrimaryDisplay, &capabilities);
+ ASSERT_TRUE(error.isOk());
+ const bool isDozeSupported = std::find(capabilities.begin(), capabilities.end(),
+ DisplayCapability::DOZE) != capabilities.end();
+ const bool isSuspendSupported = std::find(capabilities.begin(), capabilities.end(),
+ DisplayCapability::SUSPEND) != capabilities.end();
+
std::vector<PowerMode> modes;
modes.push_back(PowerMode::OFF);
- modes.push_back(PowerMode::ON_SUSPEND);
modes.push_back(PowerMode::ON);
+ if (isSuspendSupported) {
+ modes.push_back(PowerMode::ON_SUSPEND);
+ }
+
+ if (isDozeSupported) {
+ modes.push_back(PowerMode::DOZE);
+ }
+
+ if (isSuspendSupported && isDozeSupported) {
+ modes.push_back(PowerMode::DOZE_SUSPEND);
+ }
+
for (auto mode : modes) {
EXPECT_TRUE(mComposerClient->setPowerMode(mPrimaryDisplay, mode).isOk());
}
}
TEST_P(GraphicsComposerAidlTest, SetPowerModeVariations) {
+ std::vector<DisplayCapability> capabilities;
+ const auto error = mComposerClient->getDisplayCapabilities(mPrimaryDisplay, &capabilities);
+ ASSERT_TRUE(error.isOk());
+ const bool isDozeSupported = std::find(capabilities.begin(), capabilities.end(),
+ DisplayCapability::DOZE) != capabilities.end();
+ const bool isSuspendSupported = std::find(capabilities.begin(), capabilities.end(),
+ DisplayCapability::SUSPEND) != capabilities.end();
+
std::vector<PowerMode> modes;
modes.push_back(PowerMode::OFF);
+ modes.push_back(PowerMode::ON);
modes.push_back(PowerMode::OFF);
-
for (auto mode : modes) {
EXPECT_TRUE(mComposerClient->setPowerMode(mPrimaryDisplay, mode).isOk());
}
+ modes.clear();
+ modes.push_back(PowerMode::OFF);
+ modes.push_back(PowerMode::OFF);
+ for (auto mode : modes) {
+ EXPECT_TRUE(mComposerClient->setPowerMode(mPrimaryDisplay, mode).isOk());
+ }
modes.clear();
modes.push_back(PowerMode::ON);
modes.push_back(PowerMode::ON);
-
for (auto mode : modes) {
EXPECT_TRUE(mComposerClient->setPowerMode(mPrimaryDisplay, mode).isOk());
}
-
modes.clear();
- modes.push_back(PowerMode::ON_SUSPEND);
- modes.push_back(PowerMode::ON_SUSPEND);
-
- for (auto mode : modes) {
- EXPECT_TRUE(mComposerClient->setPowerMode(mPrimaryDisplay, mode).isOk());
+ if (isSuspendSupported) {
+ modes.push_back(PowerMode::ON_SUSPEND);
+ modes.push_back(PowerMode::ON_SUSPEND);
+ for (auto mode : modes) {
+ EXPECT_TRUE(mComposerClient->setPowerMode(mPrimaryDisplay, mode).isOk());
+ }
+ modes.clear();
}
- bool isDozeSupported = false;
- ASSERT_TRUE(mComposerClient->getDozeSupport(mPrimaryDisplay, &isDozeSupported).isOk());
if (isDozeSupported) {
- modes.clear();
-
modes.push_back(PowerMode::DOZE);
modes.push_back(PowerMode::DOZE);
-
for (auto mode : modes) {
EXPECT_TRUE(mComposerClient->setPowerMode(mPrimaryDisplay, mode).isOk());
}
-
modes.clear();
+ }
+ if (isSuspendSupported && isDozeSupported) {
modes.push_back(PowerMode::DOZE_SUSPEND);
modes.push_back(PowerMode::DOZE_SUSPEND);
-
for (auto mode : modes) {
EXPECT_TRUE(mComposerClient->setPowerMode(mPrimaryDisplay, mode).isOk());
}
+ modes.clear();
}
}
@@ -1343,20 +1134,6 @@
ASSERT_EQ(IComposerClient::EX_BAD_PARAMETER, error.getServiceSpecificError());
}
-TEST_P(GraphicsComposerAidlTest, SetPowerModeUnsupported) {
- bool isDozeSupported = false;
- EXPECT_TRUE(mComposerClient->getDozeSupport(mPrimaryDisplay, &isDozeSupported).isOk());
- if (!isDozeSupported) {
- auto error = mComposerClient->setPowerMode(mPrimaryDisplay, PowerMode::DOZE);
- EXPECT_FALSE(error.isOk());
- EXPECT_EQ(IComposerClient::EX_UNSUPPORTED, error.getServiceSpecificError());
-
- error = mComposerClient->setPowerMode(mPrimaryDisplay, PowerMode::DOZE_SUSPEND);
- EXPECT_FALSE(error.isOk());
- EXPECT_EQ(IComposerClient::EX_UNSUPPORTED, error.getServiceSpecificError());
- }
-}
-
TEST_P(GraphicsComposerAidlTest, GetDataspaceSaturationMatrix) {
std::vector<float> matrix;
EXPECT_TRUE(
@@ -1379,6 +1156,796 @@
EXPECT_EQ(IComposerClient::EX_BAD_PARAMETER, error.getServiceSpecificError());
}
+// Tests for Command.
+class GraphicsComposerAidlCommandTest : public GraphicsComposerAidlTest {
+ protected:
+ void TearDown() override {
+ const auto errors = mReader.takeErrors();
+ ASSERT_TRUE(mReader.takeErrors().empty());
+
+ std::vector<int64_t> layers;
+ std::vector<Composition> types;
+ mReader.takeChangedCompositionTypes(mPrimaryDisplay, &layers, &types);
+
+ ASSERT_TRUE(layers.empty());
+ ASSERT_TRUE(types.empty());
+
+ ASSERT_NO_FATAL_FAILURE(GraphicsComposerAidlTest::TearDown());
+ }
+
+ void execute() {
+ const auto& commands = mWriter.getPendingCommands();
+ if (commands.empty()) {
+ mWriter.reset();
+ return;
+ }
+
+ std::vector<CommandResultPayload> results;
+ const auto status = mComposerClient->executeCommands(commands, &results);
+ ASSERT_TRUE(status.isOk()) << "executeCommands failed " << status.getDescription();
+
+ mReader.parse(results);
+ mWriter.reset();
+ }
+
+ static inline auto toTimePoint(nsecs_t time) {
+ return std::chrono::time_point<std::chrono::steady_clock>(std::chrono::nanoseconds(time));
+ }
+
+ void setActiveConfig(VtsDisplay& display, int32_t config) {
+ EXPECT_TRUE(mComposerClient->setActiveConfig(display.get(), config).isOk());
+ int32_t displayWidth;
+ EXPECT_TRUE(mComposerClient
+ ->getDisplayAttribute(display.get(), config, DisplayAttribute::WIDTH,
+ &displayWidth)
+ .isOk());
+ int32_t displayHeight;
+ EXPECT_TRUE(mComposerClient
+ ->getDisplayAttribute(display.get(), config, DisplayAttribute::HEIGHT,
+ &displayHeight)
+ .isOk());
+ display.setDimensions(displayWidth, displayHeight);
+ }
+
+ void forEachTwoConfigs(int64_t display, std::function<void(int32_t, int32_t)> func) {
+ std::vector<int32_t> displayConfigs;
+ EXPECT_TRUE(mComposerClient->getDisplayConfigs(display, &displayConfigs).isOk());
+ for (const int32_t config1 : displayConfigs) {
+ for (const int32_t config2 : displayConfigs) {
+ if (config1 != config2) {
+ func(config1, config2);
+ }
+ }
+ }
+ }
+
+ void waitForVsyncPeriodChange(int64_t display, const VsyncPeriodChangeTimeline& timeline,
+ int64_t desiredTimeNanos, int64_t oldPeriodNanos,
+ int64_t newPeriodNanos) {
+ const auto kChangeDeadline = toTimePoint(timeline.newVsyncAppliedTimeNanos) + 100ms;
+ while (std::chrono::steady_clock::now() <= kChangeDeadline) {
+ int32_t vsyncPeriodNanos;
+ EXPECT_TRUE(mComposerClient->getDisplayVsyncPeriod(display, &vsyncPeriodNanos).isOk());
+ if (systemTime() <= desiredTimeNanos) {
+ EXPECT_EQ(vsyncPeriodNanos, oldPeriodNanos);
+ } else if (vsyncPeriodNanos == newPeriodNanos) {
+ break;
+ }
+ std::this_thread::sleep_for(std::chrono::nanoseconds(oldPeriodNanos));
+ }
+ }
+
+ sp<GraphicBuffer> allocate() {
+ return sp<GraphicBuffer>::make(
+ static_cast<uint32_t>(mDisplayWidth), static_cast<uint32_t>(mDisplayHeight),
+ ::android::PIXEL_FORMAT_RGBA_8888,
+ /*layerCount*/ 1,
+ (static_cast<uint64_t>(common::BufferUsage::CPU_WRITE_OFTEN) |
+ static_cast<uint64_t>(common::BufferUsage::CPU_READ_OFTEN) |
+ static_cast<uint64_t>(common::BufferUsage::COMPOSER_OVERLAY)),
+ "VtsHalGraphicsComposer3_TargetTest");
+ }
+
+ void sendRefreshFrame(const VtsDisplay& display, const VsyncPeriodChangeTimeline* timeline) {
+ if (timeline != nullptr) {
+ // Refresh time should be before newVsyncAppliedTimeNanos
+ EXPECT_LT(timeline->refreshTimeNanos, timeline->newVsyncAppliedTimeNanos);
+
+ std::this_thread::sleep_until(toTimePoint(timeline->refreshTimeNanos));
+ }
+
+ EXPECT_TRUE(mComposerClient->setPowerMode(display.get(), PowerMode::ON).isOk());
+ EXPECT_TRUE(
+ mComposerClient
+ ->setColorMode(display.get(), ColorMode::NATIVE, RenderIntent::COLORIMETRIC)
+ .isOk());
+
+ int64_t layer = 0;
+ ASSERT_NO_FATAL_FAILURE(layer = createLayer(display));
+ {
+ auto buffer = allocate();
+ ASSERT_NE(nullptr, buffer);
+ ASSERT_EQ(::android::OK, buffer->initCheck());
+ ASSERT_NE(nullptr, buffer->handle);
+
+ mWriter.setLayerCompositionType(display.get(), layer, Composition::DEVICE);
+ mWriter.setLayerDisplayFrame(display.get(), layer, display.getFrameRect());
+ mWriter.setLayerPlaneAlpha(display.get(), layer, 1);
+ mWriter.setLayerSourceCrop(display.get(), layer, display.getCrop());
+ mWriter.setLayerTransform(display.get(), layer, static_cast<Transform>(0));
+ mWriter.setLayerVisibleRegion(display.get(), layer,
+ std::vector<Rect>(1, display.getFrameRect()));
+ mWriter.setLayerZOrder(display.get(), layer, 10);
+ mWriter.setLayerBlendMode(display.get(), layer, BlendMode::NONE);
+ mWriter.setLayerSurfaceDamage(display.get(), layer,
+ std::vector<Rect>(1, display.getFrameRect()));
+ mWriter.setLayerBuffer(display.get(), layer, 0, buffer->handle, -1);
+ mWriter.setLayerDataspace(display.get(), layer, common::Dataspace::UNKNOWN);
+
+ mWriter.validateDisplay(display.get());
+ execute();
+ ASSERT_TRUE(mReader.takeErrors().empty());
+
+ mWriter.presentDisplay(display.get());
+ execute();
+ ASSERT_TRUE(mReader.takeErrors().empty());
+ }
+
+ {
+ auto buffer = allocate();
+ ASSERT_NE(nullptr, buffer->handle);
+
+ mWriter.setLayerBuffer(display.get(), layer, 0, buffer->handle, -1);
+ mWriter.setLayerSurfaceDamage(display.get(), layer,
+ std::vector<Rect>(1, {0, 0, 10, 10}));
+ mWriter.validateDisplay(display.get());
+ execute();
+ ASSERT_TRUE(mReader.takeErrors().empty());
+
+ mWriter.presentDisplay(display.get());
+ execute();
+ }
+
+ ASSERT_NO_FATAL_FAILURE(destroyLayer(display, layer));
+ }
+
+ void Test_setActiveConfigWithConstraints(const TestParameters& params) {
+ for (VtsDisplay& display : mDisplays) {
+ forEachTwoConfigs(display.get(), [&](int32_t config1, int32_t config2) {
+ setActiveConfig(display, config1);
+ sendRefreshFrame(display, nullptr);
+
+ int32_t vsyncPeriod1;
+ EXPECT_TRUE(mComposerClient
+ ->getDisplayAttribute(display.get(), config1,
+ DisplayAttribute::VSYNC_PERIOD,
+ &vsyncPeriod1)
+ .isOk());
+ int32_t configGroup1;
+ EXPECT_TRUE(mComposerClient
+ ->getDisplayAttribute(display.get(), config1,
+ DisplayAttribute::CONFIG_GROUP,
+ &configGroup1)
+ .isOk());
+ int32_t vsyncPeriod2;
+ EXPECT_TRUE(mComposerClient
+ ->getDisplayAttribute(display.get(), config2,
+ DisplayAttribute::VSYNC_PERIOD,
+ &vsyncPeriod2)
+ .isOk());
+ int32_t configGroup2;
+ EXPECT_TRUE(mComposerClient
+ ->getDisplayAttribute(display.get(), config2,
+ DisplayAttribute::CONFIG_GROUP,
+ &configGroup2)
+ .isOk());
+
+ if (vsyncPeriod1 == vsyncPeriod2) {
+ return; // continue
+ }
+
+ // We don't allow delayed change when changing config groups
+ if (params.delayForChange > 0 && configGroup1 != configGroup2) {
+ return; // continue
+ }
+
+ VsyncPeriodChangeTimeline timeline;
+ VsyncPeriodChangeConstraints constraints = {
+ .desiredTimeNanos = systemTime() + params.delayForChange,
+ .seamlessRequired = false};
+ EXPECT_TRUE(setActiveConfigWithConstraints(display, config2, constraints, &timeline)
+ .isOk());
+
+ EXPECT_TRUE(timeline.newVsyncAppliedTimeNanos >= constraints.desiredTimeNanos);
+ // Refresh rate should change within a reasonable time
+ constexpr std::chrono::nanoseconds kReasonableTimeForChange = 1s; // 1 second
+ EXPECT_TRUE(timeline.newVsyncAppliedTimeNanos - constraints.desiredTimeNanos <=
+ kReasonableTimeForChange.count());
+
+ if (timeline.refreshRequired) {
+ if (params.refreshMiss) {
+ // Miss the refresh frame on purpose to make sure the implementation sends a
+ // callback
+ std::this_thread::sleep_until(toTimePoint(timeline.refreshTimeNanos) +
+ 100ms);
+ }
+ sendRefreshFrame(display, &timeline);
+ }
+ waitForVsyncPeriodChange(display.get(), timeline, constraints.desiredTimeNanos,
+ vsyncPeriod1, vsyncPeriod2);
+
+ // At this point the refresh rate should have changed already, however in rare
+ // cases the implementation might have missed the deadline. In this case a new
+ // timeline should have been provided.
+ auto newTimeline = mComposerCallback->takeLastVsyncPeriodChangeTimeline();
+ if (timeline.refreshRequired && params.refreshMiss) {
+ EXPECT_TRUE(newTimeline.has_value());
+ }
+
+ if (newTimeline.has_value()) {
+ if (newTimeline->refreshRequired) {
+ sendRefreshFrame(display, &newTimeline.value());
+ }
+ waitForVsyncPeriodChange(display.get(), newTimeline.value(),
+ constraints.desiredTimeNanos, vsyncPeriod1,
+ vsyncPeriod2);
+ }
+
+ int32_t vsyncPeriodNanos;
+ EXPECT_TRUE(mComposerClient->getDisplayVsyncPeriod(display.get(), &vsyncPeriodNanos)
+ .isOk());
+ EXPECT_EQ(vsyncPeriodNanos, vsyncPeriod2);
+ });
+ }
+ }
+
+ // clang-format off
+ const std::array<float, 16> kIdentity = {{
+ 1.0f, 0.0f, 0.0f, 0.0f,
+ 0.0f, 1.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 1.0f, 0.0f,
+ 0.0f, 0.0f, 0.0f, 1.0f,
+ }};
+ // clang-format on
+
+ CommandWriterBase mWriter;
+ CommandReaderBase mReader;
+};
+
+TEST_P(GraphicsComposerAidlCommandTest, SET_COLOR_TRANSFORM) {
+ mWriter.setColorTransform(mPrimaryDisplay, kIdentity.data(), ColorTransform::IDENTITY);
+ execute();
+}
+
+TEST_P(GraphicsComposerAidlCommandTest, SetLayerColorTransform) {
+ int64_t layer;
+ EXPECT_TRUE(mComposerClient->createLayer(mPrimaryDisplay, kBufferSlotCount, &layer).isOk());
+ mWriter.setLayerColorTransform(mPrimaryDisplay, layer, kIdentity.data());
+ execute();
+
+ const auto errors = mReader.takeErrors();
+ if (errors.size() == 1 && errors[0].errorCode == EX_UNSUPPORTED_OPERATION) {
+ GTEST_SUCCEED() << "setLayerColorTransform is not supported";
+ return;
+ }
+}
+
+TEST_P(GraphicsComposerAidlCommandTest, SET_CLIENT_TARGET) {
+ EXPECT_TRUE(
+ mComposerClient->setClientTargetSlotCount(mPrimaryDisplay, kBufferSlotCount).isOk());
+
+ mWriter.setClientTarget(mPrimaryDisplay, 0, nullptr, -1, Dataspace::UNKNOWN,
+ std::vector<Rect>());
+
+ execute();
+}
+
+TEST_P(GraphicsComposerAidlCommandTest, SET_OUTPUT_BUFFER) {
+ int32_t virtualDisplayCount;
+ EXPECT_TRUE(mComposerClient->getMaxVirtualDisplayCount(&virtualDisplayCount).isOk());
+ if (virtualDisplayCount == 0) {
+ GTEST_SUCCEED() << "no virtual display support";
+ return;
+ }
+
+ VirtualDisplay display;
+ EXPECT_TRUE(mComposerClient
+ ->createVirtualDisplay(64, 64, common::PixelFormat::IMPLEMENTATION_DEFINED,
+ kBufferSlotCount, &display)
+ .isOk());
+
+ auto handle = allocate()->handle;
+ mWriter.setOutputBuffer(display.display, 0, handle, -1);
+ execute();
+}
+
+TEST_P(GraphicsComposerAidlCommandTest, VALIDATE_DISPLAY) {
+ mWriter.validateDisplay(mPrimaryDisplay);
+ execute();
+}
+
+TEST_P(GraphicsComposerAidlCommandTest, ACCEPT_DISPLAY_CHANGES) {
+ mWriter.validateDisplay(mPrimaryDisplay);
+ mWriter.acceptDisplayChanges(mPrimaryDisplay);
+ execute();
+}
+
+// TODO(b/208441745) fix the test failure
+TEST_P(GraphicsComposerAidlCommandTest, PRESENT_DISPLAY) {
+ mWriter.validateDisplay(mPrimaryDisplay);
+ mWriter.presentDisplay(mPrimaryDisplay);
+ execute();
+}
+
+/**
+ * Test IComposerClient::Command::PRESENT_DISPLAY
+ *
+ * Test that IComposerClient::Command::PRESENT_DISPLAY works without
+ * additional call to validateDisplay when only the layer buffer handle and
+ * surface damage have been set
+ */
+// TODO(b/208441745) fix the test failure
+TEST_P(GraphicsComposerAidlCommandTest, PRESENT_DISPLAY_NO_LAYER_STATE_CHANGES) {
+ std::vector<Capability> capabilities;
+ EXPECT_TRUE(mComposer->getCapabilities(&capabilities).isOk());
+ if (none_of(capabilities.begin(), capabilities.end(),
+ [&](auto item) { return item == Capability::SKIP_VALIDATE; })) {
+ GTEST_SUCCEED() << "Device does not have skip validate capability, skipping";
+ return;
+ }
+ mComposerClient->setPowerMode(mPrimaryDisplay, PowerMode::ON);
+
+ std::vector<RenderIntent> renderIntents;
+ mComposerClient->getRenderIntents(mPrimaryDisplay, ColorMode::NATIVE, &renderIntents);
+ for (auto intent : renderIntents) {
+ mComposerClient->setColorMode(mPrimaryDisplay, ColorMode::NATIVE, intent);
+
+ auto handle = allocate()->handle;
+ ASSERT_NE(nullptr, handle);
+
+ Rect displayFrame{0, 0, mDisplayWidth, mDisplayHeight};
+
+ int64_t layer;
+ EXPECT_TRUE(mComposerClient->createLayer(mPrimaryDisplay, kBufferSlotCount, &layer).isOk());
+ mWriter.setLayerCompositionType(mPrimaryDisplay, layer, Composition::DEVICE);
+ mWriter.setLayerDisplayFrame(mPrimaryDisplay, layer, displayFrame);
+ mWriter.setLayerPlaneAlpha(mPrimaryDisplay, layer, 1);
+ mWriter.setLayerSourceCrop(mPrimaryDisplay, layer,
+ {0, 0, (float)mDisplayWidth, (float)mDisplayHeight});
+ mWriter.setLayerTransform(mPrimaryDisplay, layer, static_cast<Transform>(0));
+ mWriter.setLayerVisibleRegion(mPrimaryDisplay, layer, std::vector<Rect>(1, displayFrame));
+ mWriter.setLayerZOrder(mPrimaryDisplay, layer, 10);
+ mWriter.setLayerBlendMode(mPrimaryDisplay, layer, BlendMode::NONE);
+ mWriter.setLayerSurfaceDamage(mPrimaryDisplay, layer, std::vector<Rect>(1, displayFrame));
+ mWriter.setLayerBuffer(mPrimaryDisplay, layer, 0, handle, -1);
+ mWriter.setLayerDataspace(mPrimaryDisplay, layer, Dataspace::UNKNOWN);
+
+ mWriter.validateDisplay(mPrimaryDisplay);
+ execute();
+ std::vector<int64_t> layers;
+ std::vector<Composition> types;
+ mReader.takeChangedCompositionTypes(mPrimaryDisplay, &layers, &types);
+ if (!layers.empty()) {
+ GTEST_SUCCEED() << "Composition change requested, skipping test";
+ return;
+ }
+
+ ASSERT_TRUE(mReader.takeErrors().empty());
+ mWriter.presentDisplay(mPrimaryDisplay);
+ execute();
+ ASSERT_TRUE(mReader.takeErrors().empty());
+
+ auto handle2 = allocate()->handle;
+ ASSERT_NE(nullptr, handle2);
+ mWriter.setLayerBuffer(mPrimaryDisplay, layer, 0, handle2, -1);
+ mWriter.setLayerSurfaceDamage(mPrimaryDisplay, layer, std::vector<Rect>(1, {0, 0, 10, 10}));
+ mWriter.presentDisplay(mPrimaryDisplay);
+ execute();
+ }
+}
+
+// TODO(b/208441745) fix the test failure
+TEST_P(GraphicsComposerAidlCommandTest, SET_LAYER_CURSOR_POSITION) {
+ int64_t layer;
+ EXPECT_TRUE(mComposerClient->createLayer(mPrimaryDisplay, kBufferSlotCount, &layer).isOk());
+
+ auto handle = allocate()->handle;
+ ASSERT_NE(nullptr, handle);
+ Rect displayFrame{0, 0, mDisplayWidth, mDisplayHeight};
+
+ mWriter.setLayerBuffer(mPrimaryDisplay, layer, 0, handle, -1);
+ mWriter.setLayerCompositionType(mPrimaryDisplay, layer, Composition::CURSOR);
+ mWriter.setLayerDisplayFrame(mPrimaryDisplay, layer, displayFrame);
+ mWriter.setLayerPlaneAlpha(mPrimaryDisplay, layer, 1);
+ mWriter.setLayerSourceCrop(mPrimaryDisplay, layer,
+ {0, 0, (float)mDisplayWidth, (float)mDisplayHeight});
+ mWriter.setLayerTransform(mPrimaryDisplay, layer, static_cast<Transform>(0));
+ mWriter.setLayerVisibleRegion(mPrimaryDisplay, layer, std::vector<Rect>(1, displayFrame));
+ mWriter.setLayerZOrder(mPrimaryDisplay, layer, 10);
+ mWriter.setLayerBlendMode(mPrimaryDisplay, layer, BlendMode::NONE);
+ mWriter.setLayerSurfaceDamage(mPrimaryDisplay, layer, std::vector<Rect>(1, displayFrame));
+ mWriter.setLayerDataspace(mPrimaryDisplay, layer, Dataspace::UNKNOWN);
+ mWriter.validateDisplay(mPrimaryDisplay);
+
+ execute();
+ std::vector<int64_t> layers;
+ std::vector<Composition> types;
+ mReader.takeChangedCompositionTypes(mPrimaryDisplay, &layers, &types);
+ if (!layers.empty()) {
+ GTEST_SUCCEED() << "Composition change requested, skipping test";
+ return;
+ }
+ mWriter.presentDisplay(mPrimaryDisplay);
+ ASSERT_TRUE(mReader.takeErrors().empty());
+
+ mWriter.setLayerCursorPosition(mPrimaryDisplay, layer, 1, 1);
+ execute();
+
+ mWriter.setLayerCursorPosition(mPrimaryDisplay, layer, 0, 0);
+ mWriter.validateDisplay(mPrimaryDisplay);
+ mWriter.presentDisplay(mPrimaryDisplay);
+ execute();
+}
+
+TEST_P(GraphicsComposerAidlCommandTest, SET_LAYER_BUFFER) {
+ auto handle = allocate()->handle;
+ ASSERT_NE(nullptr, handle);
+
+ int64_t layer;
+ EXPECT_TRUE(mComposerClient->createLayer(mPrimaryDisplay, kBufferSlotCount, &layer).isOk());
+ mWriter.setLayerBuffer(mPrimaryDisplay, layer, 0, handle, -1);
+ execute();
+}
+
+TEST_P(GraphicsComposerAidlCommandTest, SET_LAYER_SURFACE_DAMAGE) {
+ int64_t layer;
+ EXPECT_TRUE(mComposerClient->createLayer(mPrimaryDisplay, kBufferSlotCount, &layer).isOk());
+
+ Rect empty{0, 0, 0, 0};
+ Rect unit{0, 0, 1, 1};
+
+ mWriter.setLayerSurfaceDamage(mPrimaryDisplay, layer, std::vector<Rect>(1, empty));
+ execute();
+ ASSERT_TRUE(mReader.takeErrors().empty());
+
+ mWriter.setLayerSurfaceDamage(mPrimaryDisplay, layer, std::vector<Rect>(1, unit));
+ execute();
+ ASSERT_TRUE(mReader.takeErrors().empty());
+
+ mWriter.setLayerSurfaceDamage(mPrimaryDisplay, layer, std::vector<Rect>());
+ execute();
+ ASSERT_TRUE(mReader.takeErrors().empty());
+}
+
+TEST_P(GraphicsComposerAidlCommandTest, SET_LAYER_BLEND_MODE) {
+ int64_t layer;
+ EXPECT_TRUE(mComposerClient->createLayer(mPrimaryDisplay, kBufferSlotCount, &layer).isOk());
+
+ mWriter.setLayerBlendMode(mPrimaryDisplay, layer, BlendMode::NONE);
+ execute();
+ ASSERT_TRUE(mReader.takeErrors().empty());
+
+ mWriter.setLayerBlendMode(mPrimaryDisplay, layer, BlendMode::PREMULTIPLIED);
+ execute();
+ ASSERT_TRUE(mReader.takeErrors().empty());
+
+ mWriter.setLayerBlendMode(mPrimaryDisplay, layer, BlendMode::COVERAGE);
+ execute();
+ ASSERT_TRUE(mReader.takeErrors().empty());
+}
+
+TEST_P(GraphicsComposerAidlCommandTest, SET_LAYER_COLOR) {
+ int64_t layer;
+ EXPECT_TRUE(mComposerClient->createLayer(mPrimaryDisplay, kBufferSlotCount, &layer).isOk());
+
+ mWriter.setLayerColor(mPrimaryDisplay, layer,
+ Color{static_cast<int8_t>(0xff), static_cast<int8_t>(0xff),
+ static_cast<int8_t>(0xff), static_cast<int8_t>(0xff)});
+ execute();
+ ASSERT_TRUE(mReader.takeErrors().empty());
+
+ mWriter.setLayerColor(mPrimaryDisplay, layer, Color{0, 0, 0, 0});
+ execute();
+ ASSERT_TRUE(mReader.takeErrors().empty());
+}
+
+TEST_P(GraphicsComposerAidlCommandTest, SET_LAYER_COMPOSITION_TYPE) {
+ int64_t layer;
+ EXPECT_TRUE(mComposerClient->createLayer(mPrimaryDisplay, kBufferSlotCount, &layer).isOk());
+
+ mWriter.setLayerCompositionType(mPrimaryDisplay, layer, Composition::CLIENT);
+ execute();
+ ASSERT_TRUE(mReader.takeErrors().empty());
+
+ mWriter.setLayerCompositionType(mPrimaryDisplay, layer, Composition::DEVICE);
+ execute();
+ ASSERT_TRUE(mReader.takeErrors().empty());
+
+ mWriter.setLayerCompositionType(mPrimaryDisplay, layer, Composition::SOLID_COLOR);
+ execute();
+ ASSERT_TRUE(mReader.takeErrors().empty());
+
+ mWriter.setLayerCompositionType(mPrimaryDisplay, layer, Composition::CURSOR);
+ execute();
+ ASSERT_TRUE(mReader.takeErrors().empty());
+}
+
+TEST_P(GraphicsComposerAidlCommandTest, SET_LAYER_DATASPACE) {
+ int64_t layer;
+ EXPECT_TRUE(mComposerClient->createLayer(mPrimaryDisplay, kBufferSlotCount, &layer).isOk());
+
+ mWriter.setLayerDataspace(mPrimaryDisplay, layer, Dataspace::UNKNOWN);
+ execute();
+}
+
+TEST_P(GraphicsComposerAidlCommandTest, SET_LAYER_DISPLAY_FRAME) {
+ int64_t layer;
+ EXPECT_TRUE(mComposerClient->createLayer(mPrimaryDisplay, kBufferSlotCount, &layer).isOk());
+
+ mWriter.setLayerDisplayFrame(mPrimaryDisplay, layer, Rect{0, 0, 1, 1});
+ execute();
+}
+
+TEST_P(GraphicsComposerAidlCommandTest, SET_LAYER_PLANE_ALPHA) {
+ int64_t layer;
+ EXPECT_TRUE(mComposerClient->createLayer(mPrimaryDisplay, kBufferSlotCount, &layer).isOk());
+
+ mWriter.setLayerPlaneAlpha(mPrimaryDisplay, layer, 0.0f);
+ execute();
+ ASSERT_TRUE(mReader.takeErrors().empty());
+
+ mWriter.setLayerPlaneAlpha(mPrimaryDisplay, layer, 1.0f);
+ execute();
+ ASSERT_TRUE(mReader.takeErrors().empty());
+}
+
+TEST_P(GraphicsComposerAidlCommandTest, SET_LAYER_SIDEBAND_STREAM) {
+ std::vector<Capability> capabilities;
+ EXPECT_TRUE(mComposer->getCapabilities(&capabilities).isOk());
+ if (none_of(capabilities.begin(), capabilities.end(),
+ [&](auto& item) { return item == Capability::SIDEBAND_STREAM; })) {
+ GTEST_SUCCEED() << "no sideband stream support";
+ return;
+ }
+
+ auto handle = allocate()->handle;
+ ASSERT_NE(nullptr, handle);
+
+ int64_t layer;
+ EXPECT_TRUE(mComposerClient->createLayer(mPrimaryDisplay, kBufferSlotCount, &layer).isOk());
+
+ mWriter.setLayerSidebandStream(mPrimaryDisplay, layer, handle);
+ execute();
+}
+
+TEST_P(GraphicsComposerAidlCommandTest, SET_LAYER_SOURCE_CROP) {
+ int64_t layer;
+ EXPECT_TRUE(mComposerClient->createLayer(mPrimaryDisplay, kBufferSlotCount, &layer).isOk());
+
+ mWriter.setLayerSourceCrop(mPrimaryDisplay, layer, FRect{0.0f, 0.0f, 1.0f, 1.0f});
+ execute();
+}
+
+TEST_P(GraphicsComposerAidlCommandTest, SET_LAYER_TRANSFORM) {
+ int64_t layer;
+ EXPECT_TRUE(mComposerClient->createLayer(mPrimaryDisplay, kBufferSlotCount, &layer).isOk());
+
+ mWriter.setLayerTransform(mPrimaryDisplay, layer, static_cast<Transform>(0));
+ execute();
+ ASSERT_TRUE(mReader.takeErrors().empty());
+
+ mWriter.setLayerTransform(mPrimaryDisplay, layer, Transform::FLIP_H);
+ execute();
+ ASSERT_TRUE(mReader.takeErrors().empty());
+
+ mWriter.setLayerTransform(mPrimaryDisplay, layer, Transform::FLIP_V);
+ execute();
+ ASSERT_TRUE(mReader.takeErrors().empty());
+
+ mWriter.setLayerTransform(mPrimaryDisplay, layer, Transform::ROT_90);
+ execute();
+ ASSERT_TRUE(mReader.takeErrors().empty());
+
+ mWriter.setLayerTransform(mPrimaryDisplay, layer, Transform::ROT_180);
+ execute();
+ ASSERT_TRUE(mReader.takeErrors().empty());
+
+ mWriter.setLayerTransform(mPrimaryDisplay, layer, Transform::ROT_270);
+ execute();
+ ASSERT_TRUE(mReader.takeErrors().empty());
+
+ mWriter.setLayerTransform(mPrimaryDisplay, layer,
+ static_cast<Transform>(static_cast<int>(Transform::FLIP_H) |
+ static_cast<int>(Transform::ROT_90)));
+ execute();
+ ASSERT_TRUE(mReader.takeErrors().empty());
+
+ mWriter.setLayerTransform(mPrimaryDisplay, layer,
+ static_cast<Transform>(static_cast<int>(Transform::FLIP_V) |
+ static_cast<int>(Transform::ROT_90)));
+ execute();
+ ASSERT_TRUE(mReader.takeErrors().empty());
+}
+
+TEST_P(GraphicsComposerAidlCommandTest, SET_LAYER_VISIBLE_REGION) {
+ int64_t layer;
+ EXPECT_TRUE(mComposerClient->createLayer(mPrimaryDisplay, kBufferSlotCount, &layer).isOk());
+
+ Rect empty{0, 0, 0, 0};
+ Rect unit{0, 0, 1, 1};
+
+ mWriter.setLayerVisibleRegion(mPrimaryDisplay, layer, std::vector<Rect>(1, empty));
+ execute();
+ ASSERT_TRUE(mReader.takeErrors().empty());
+
+ mWriter.setLayerVisibleRegion(mPrimaryDisplay, layer, std::vector<Rect>(1, unit));
+ execute();
+ ASSERT_TRUE(mReader.takeErrors().empty());
+
+ mWriter.setLayerVisibleRegion(mPrimaryDisplay, layer, std::vector<Rect>());
+ execute();
+ ASSERT_TRUE(mReader.takeErrors().empty());
+}
+
+TEST_P(GraphicsComposerAidlCommandTest, SET_LAYER_Z_ORDER) {
+ int64_t layer;
+ EXPECT_TRUE(mComposerClient->createLayer(mPrimaryDisplay, kBufferSlotCount, &layer).isOk());
+
+ mWriter.setLayerZOrder(mPrimaryDisplay, layer, 10);
+ execute();
+ ASSERT_TRUE(mReader.takeErrors().empty());
+
+ mWriter.setLayerZOrder(mPrimaryDisplay, layer, 0);
+ execute();
+ ASSERT_TRUE(mReader.takeErrors().empty());
+}
+
+TEST_P(GraphicsComposerAidlCommandTest, SET_LAYER_PER_FRAME_METADATA) {
+ int64_t layer;
+ EXPECT_TRUE(mComposerClient->createLayer(mPrimaryDisplay, kBufferSlotCount, &layer).isOk());
+
+ /**
+ * DISPLAY_P3 is a color space that uses the DCI_P3 primaries,
+ * the D65 white point and the SRGB transfer functions.
+ * Rendering Intent: Colorimetric
+ * Primaries:
+ * x y
+ * green 0.265 0.690
+ * blue 0.150 0.060
+ * red 0.680 0.320
+ * white (D65) 0.3127 0.3290
+ */
+
+ std::vector<PerFrameMetadata> aidlMetadata;
+ aidlMetadata.push_back({PerFrameMetadataKey::DISPLAY_RED_PRIMARY_X, 0.680f});
+ aidlMetadata.push_back({PerFrameMetadataKey::DISPLAY_RED_PRIMARY_Y, 0.320f});
+ aidlMetadata.push_back({PerFrameMetadataKey::DISPLAY_GREEN_PRIMARY_X, 0.265f});
+ aidlMetadata.push_back({PerFrameMetadataKey::DISPLAY_GREEN_PRIMARY_Y, 0.690f});
+ aidlMetadata.push_back({PerFrameMetadataKey::DISPLAY_BLUE_PRIMARY_X, 0.150f});
+ aidlMetadata.push_back({PerFrameMetadataKey::DISPLAY_BLUE_PRIMARY_Y, 0.060f});
+ aidlMetadata.push_back({PerFrameMetadataKey::WHITE_POINT_X, 0.3127f});
+ aidlMetadata.push_back({PerFrameMetadataKey::WHITE_POINT_Y, 0.3290f});
+ aidlMetadata.push_back({PerFrameMetadataKey::MAX_LUMINANCE, 100.0f});
+ aidlMetadata.push_back({PerFrameMetadataKey::MIN_LUMINANCE, 0.1f});
+ aidlMetadata.push_back({PerFrameMetadataKey::MAX_CONTENT_LIGHT_LEVEL, 78.0});
+ aidlMetadata.push_back({PerFrameMetadataKey::MAX_FRAME_AVERAGE_LIGHT_LEVEL, 62.0});
+ mWriter.setLayerPerFrameMetadata(mPrimaryDisplay, layer, aidlMetadata);
+ execute();
+
+ const auto errors = mReader.takeErrors();
+ if (errors.size() == 1 && errors[0].errorCode == EX_UNSUPPORTED_OPERATION) {
+ GTEST_SUCCEED() << "SetLayerPerFrameMetadata is not supported";
+ EXPECT_TRUE(mComposerClient->destroyLayer(mPrimaryDisplay, layer).isOk());
+ return;
+ }
+
+ EXPECT_TRUE(mComposerClient->destroyLayer(mPrimaryDisplay, layer).isOk());
+}
+
+TEST_P(GraphicsComposerAidlCommandTest, setActiveConfigWithConstraints) {
+ Test_setActiveConfigWithConstraints({.delayForChange = 0, .refreshMiss = false});
+}
+
+TEST_P(GraphicsComposerAidlCommandTest, setActiveConfigWithConstraints_Delayed) {
+ Test_setActiveConfigWithConstraints({.delayForChange = 300'000'000, // 300ms
+ .refreshMiss = false});
+}
+
+TEST_P(GraphicsComposerAidlCommandTest, setActiveConfigWithConstraints_MissRefresh) {
+ Test_setActiveConfigWithConstraints({.delayForChange = 0, .refreshMiss = true});
+}
+
+TEST_P(GraphicsComposerAidlCommandTest, getDisplayVsyncPeriod) {
+ for (VtsDisplay& display : mDisplays) {
+ std::vector<int32_t> configs;
+ EXPECT_TRUE(mComposerClient->getDisplayConfigs(display.get(), &configs).isOk());
+ for (int32_t config : configs) {
+ int32_t expectedVsyncPeriodNanos = -1;
+ EXPECT_TRUE(mComposerClient
+ ->getDisplayAttribute(display.get(), config,
+ DisplayAttribute::VSYNC_PERIOD,
+ &expectedVsyncPeriodNanos)
+ .isOk());
+
+ VsyncPeriodChangeTimeline timeline;
+ VsyncPeriodChangeConstraints constraints;
+
+ constraints.desiredTimeNanos = systemTime();
+ constraints.seamlessRequired = false;
+ EXPECT_TRUE(mComposerClient
+ ->setActiveConfigWithConstraints(display.get(), config, constraints,
+ &timeline)
+ .isOk());
+
+ if (timeline.refreshRequired) {
+ sendRefreshFrame(display, &timeline);
+ }
+ waitForVsyncPeriodChange(display.get(), timeline, constraints.desiredTimeNanos, 0,
+ expectedVsyncPeriodNanos);
+
+ int32_t vsyncPeriodNanos;
+ int retryCount = 100;
+ do {
+ std::this_thread::sleep_for(10ms);
+ vsyncPeriodNanos = 0;
+ EXPECT_TRUE(mComposerClient->getDisplayVsyncPeriod(display.get(), &vsyncPeriodNanos)
+ .isOk());
+ --retryCount;
+ } while (vsyncPeriodNanos != expectedVsyncPeriodNanos && retryCount > 0);
+
+ EXPECT_EQ(vsyncPeriodNanos, expectedVsyncPeriodNanos);
+
+ // Make sure that the vsync period stays the same if the active config is not
+ // changed.
+ auto timeout = 1ms;
+ for (int i = 0; i < 10; i++) {
+ std::this_thread::sleep_for(timeout);
+ timeout *= 2;
+ vsyncPeriodNanos = 0;
+ EXPECT_TRUE(mComposerClient->getDisplayVsyncPeriod(display.get(), &vsyncPeriodNanos)
+ .isOk());
+ EXPECT_EQ(vsyncPeriodNanos, expectedVsyncPeriodNanos);
+ }
+ }
+ }
+}
+
+TEST_P(GraphicsComposerAidlCommandTest, setActiveConfigWithConstraints_SeamlessNotAllowed) {
+ VsyncPeriodChangeTimeline timeline;
+ VsyncPeriodChangeConstraints constraints;
+
+ constraints.seamlessRequired = true;
+ constraints.desiredTimeNanos = systemTime();
+
+ for (VtsDisplay& display : mDisplays) {
+ forEachTwoConfigs(display.get(), [&](int32_t config1, int32_t config2) {
+ int32_t configGroup1;
+ EXPECT_TRUE(mComposerClient
+ ->getDisplayAttribute(display.get(), config1,
+ DisplayAttribute::CONFIG_GROUP, &configGroup1)
+ .isOk());
+ int32_t configGroup2;
+ EXPECT_TRUE(mComposerClient
+ ->getDisplayAttribute(display.get(), config2,
+ DisplayAttribute::CONFIG_GROUP, &configGroup2)
+ .isOk());
+ if (configGroup1 != configGroup2) {
+ setActiveConfig(display, config1);
+ sendRefreshFrame(display, nullptr);
+ EXPECT_EQ(IComposerClient::EX_SEAMLESS_NOT_ALLOWED,
+ setActiveConfigWithConstraints(display, config2, constraints, &timeline)
+ .getServiceSpecificError());
+ }
+ });
+ }
+}
+
+GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(GraphicsComposerAidlCommandTest);
+INSTANTIATE_TEST_SUITE_P(
+ PerInstance, GraphicsComposerAidlCommandTest,
+ testing::ValuesIn(::android::getAidlHalInstanceNames(IComposer::descriptor)),
+ ::android::PrintInstanceNameToString);
+
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(GraphicsComposerAidlTest);
INSTANTIATE_TEST_SUITE_P(
PerInstance, GraphicsComposerAidlTest,
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/composer-vts/Android.bp b/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/composer-vts/Android.bp
index 00ea4f3..df038db 100644
--- a/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/composer-vts/Android.bp
+++ b/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/composer-vts/Android.bp
@@ -28,7 +28,8 @@
defaults: ["hidl_defaults"],
srcs: [
"GraphicsComposerCallback.cpp",
- "TestCommandReader.cpp",
+ "ReadbackVts.cpp",
+ "RenderEngineVts.cpp",
],
header_libs: [
"android.hardware.graphics.composer3-command-buffer",
@@ -38,20 +39,32 @@
"android.hardware.graphics.common-V3-ndk",
"android.hardware.common-V2-ndk",
"android.hardware.common.fmq-V1-ndk",
+ "libarect",
"libgtest",
"libbase",
"libfmq",
"libsync",
+ "libmath",
"libaidlcommonsupport",
+ "libnativewindow",
+ "librenderengine",
+ "libshaders",
+ "libtonemap",
"android.hardware.graphics.mapper@2.0-vts",
+ "android.hardware.graphics.mapper@2.1-vts",
"android.hardware.graphics.mapper@3.0-vts",
"android.hardware.graphics.mapper@4.0-vts",
],
shared_libs: [
"libbinder_ndk",
"libhidlbase",
+ "libui",
"android.hardware.graphics.composer3-V1-ndk",
],
+ export_static_lib_headers: [
+ "android.hardware.graphics.mapper@2.1-vts",
+ "librenderengine",
+ ],
cflags: [
"-O0",
"-g",
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/composer-vts/ReadbackVts.cpp b/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/composer-vts/ReadbackVts.cpp
new file mode 100644
index 0000000..a6954b4
--- /dev/null
+++ b/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/composer-vts/ReadbackVts.cpp
@@ -0,0 +1,356 @@
+/**
+ * Copyright (c) 2021, 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.
+ */
+
+// TODO(b/129481165): remove the #pragma below and fix conversion issues
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wconversion"
+
+#include "include/ReadbackVts.h"
+#include <aidl/android/hardware/graphics/common/BufferUsage.h>
+#include "include/RenderEngineVts.h"
+#include "renderengine/ExternalTexture.h"
+
+// TODO(b/129481165): remove the #pragma below and fix conversion issues
+#pragma clang diagnostic pop // ignored "-Wconversion
+
+namespace aidl::android::hardware::graphics::composer3::vts {
+
+const std::vector<ColorMode> ReadbackHelper::colorModes = {ColorMode::SRGB, ColorMode::DISPLAY_P3};
+const std::vector<Dataspace> ReadbackHelper::dataspaces = {common::Dataspace::SRGB,
+ common::Dataspace::DISPLAY_P3};
+
+void TestLayer::write(CommandWriterBase& writer) {
+ writer.setLayerDisplayFrame(mDisplay, mLayer, mDisplayFrame);
+ writer.setLayerSourceCrop(mDisplay, mLayer, mSourceCrop);
+ writer.setLayerZOrder(mDisplay, mLayer, mZOrder);
+ writer.setLayerSurfaceDamage(mDisplay, mLayer, mSurfaceDamage);
+ writer.setLayerTransform(mDisplay, mLayer, mTransform);
+ writer.setLayerPlaneAlpha(mDisplay, mLayer, mAlpha);
+ writer.setLayerBlendMode(mDisplay, mLayer, mBlendMode);
+}
+
+std::string ReadbackHelper::getColorModeString(ColorMode mode) {
+ switch (mode) {
+ case ColorMode::SRGB:
+ return {"SRGB"};
+ case ColorMode::DISPLAY_P3:
+ return {"DISPLAY_P3"};
+ default:
+ return {"Unsupported color mode for readback"};
+ }
+}
+
+std::string ReadbackHelper::getDataspaceString(common::Dataspace dataspace) {
+ switch (dataspace) {
+ case common::Dataspace::SRGB:
+ return {"SRGB"};
+ case common::Dataspace::DISPLAY_P3:
+ return {"DISPLAY_P3"};
+ case common::Dataspace::UNKNOWN:
+ return {"UNKNOWN"};
+ default:
+ return {"Unsupported dataspace for readback"};
+ }
+}
+
+Dataspace ReadbackHelper::getDataspaceForColorMode(ColorMode mode) {
+ switch (mode) {
+ case ColorMode::DISPLAY_P3:
+ return Dataspace::DISPLAY_P3;
+ case ColorMode::SRGB:
+ default:
+ return common::Dataspace::UNKNOWN;
+ }
+}
+
+LayerSettings TestLayer::toRenderEngineLayerSettings() {
+ LayerSettings layerSettings;
+
+ layerSettings.alpha = ::android::half(mAlpha);
+ layerSettings.disableBlending = mBlendMode == BlendMode::NONE;
+ layerSettings.geometry.boundaries = ::android::FloatRect(
+ static_cast<float>(mDisplayFrame.left), static_cast<float>(mDisplayFrame.top),
+ static_cast<float>(mDisplayFrame.right), static_cast<float>(mDisplayFrame.bottom));
+
+ const ::android::mat4 translation = ::android::mat4::translate(::android::vec4(
+ (static_cast<uint64_t>(mTransform) & static_cast<uint64_t>(Transform::FLIP_H)
+ ? static_cast<float>(-mDisplayFrame.right)
+ : 0.0f),
+ (static_cast<uint64_t>(mTransform) & static_cast<uint64_t>(Transform::FLIP_V)
+ ? static_cast<float>(-mDisplayFrame.bottom)
+ : 0.0f),
+ 0.0f, 1.0f));
+
+ const ::android::mat4 scale = ::android::mat4::scale(::android::vec4(
+ static_cast<uint64_t>(mTransform) & static_cast<uint64_t>(Transform::FLIP_H) ? -1.0f
+ : 1.0f,
+ static_cast<uint64_t>(mTransform) & static_cast<uint64_t>(Transform::FLIP_V) ? -1.0f
+ : 1.0f,
+ 1.0f, 1.0f));
+
+ layerSettings.geometry.positionTransform = scale * translation;
+
+ return layerSettings;
+}
+
+int32_t ReadbackHelper::GetBytesPerPixel(common::PixelFormat pixelFormat) {
+ switch (pixelFormat) {
+ case common::PixelFormat::RGBA_8888:
+ return 4;
+ case common::PixelFormat::RGB_888:
+ return 3;
+ default:
+ return -1;
+ }
+}
+
+void ReadbackHelper::fillBuffer(uint32_t width, uint32_t height, uint32_t stride, void* bufferData,
+ common::PixelFormat pixelFormat,
+ std::vector<Color> desiredPixelColors) {
+ ASSERT_TRUE(pixelFormat == common::PixelFormat::RGB_888 ||
+ pixelFormat == common::PixelFormat::RGBA_8888);
+ int32_t bytesPerPixel = GetBytesPerPixel(pixelFormat);
+ ASSERT_NE(-1, bytesPerPixel);
+ for (int row = 0; row < height; row++) {
+ for (int col = 0; col < width; col++) {
+ auto pixel = row * static_cast<int32_t>(width) + col;
+ Color srcColor = desiredPixelColors[static_cast<size_t>(pixel)];
+
+ int offset = (row * static_cast<int32_t>(stride) + col) * bytesPerPixel;
+ uint8_t* pixelColor = (uint8_t*)bufferData + offset;
+ pixelColor[0] = static_cast<uint8_t>(srcColor.r);
+ pixelColor[1] = static_cast<uint8_t>(srcColor.g);
+ pixelColor[2] = static_cast<uint8_t>(srcColor.b);
+
+ if (bytesPerPixel == 4) {
+ pixelColor[3] = static_cast<uint8_t>(srcColor.a);
+ }
+ }
+ }
+}
+
+void ReadbackHelper::clearColors(std::vector<Color>& expectedColors, int32_t width, int32_t height,
+ int32_t displayWidth) {
+ for (int row = 0; row < height; row++) {
+ for (int col = 0; col < width; col++) {
+ int pixel = row * displayWidth + col;
+ expectedColors[static_cast<size_t>(pixel)] = BLACK;
+ }
+ }
+}
+
+void ReadbackHelper::fillColorsArea(std::vector<Color>& expectedColors, int32_t stride, Rect area,
+ Color color) {
+ for (int row = area.top; row < area.bottom; row++) {
+ for (int col = area.left; col < area.right; col++) {
+ int pixel = row * stride + col;
+ expectedColors[static_cast<size_t>(pixel)] = color;
+ }
+ }
+}
+
+bool ReadbackHelper::readbackSupported(const common::PixelFormat& pixelFormat,
+ const common::Dataspace& dataspace) {
+ if (pixelFormat != common::PixelFormat::RGB_888 &&
+ pixelFormat != common::PixelFormat::RGBA_8888) {
+ return false;
+ }
+ if (std::find(dataspaces.begin(), dataspaces.end(), dataspace) == dataspaces.end()) {
+ return false;
+ }
+ return true;
+}
+
+void ReadbackHelper::compareColorBuffers(std::vector<Color>& expectedColors, void* bufferData,
+ const int32_t stride, const uint32_t width,
+ const uint32_t height, common::PixelFormat pixelFormat) {
+ const int32_t bytesPerPixel = ReadbackHelper::GetBytesPerPixel(pixelFormat);
+ ASSERT_NE(-1, bytesPerPixel);
+ for (int row = 0; row < height; row++) {
+ for (int col = 0; col < width; col++) {
+ auto pixel = row * static_cast<int32_t>(width) + col;
+ int offset = (row * stride + col) * bytesPerPixel;
+ uint8_t* pixelColor = (uint8_t*)bufferData + offset;
+
+ ASSERT_EQ(static_cast<int8_t>(expectedColors[static_cast<size_t>(pixel)].r),
+ pixelColor[0]);
+ ASSERT_EQ(static_cast<int8_t>(expectedColors[static_cast<size_t>(pixel)].g),
+ pixelColor[1]);
+ ASSERT_EQ(static_cast<int8_t>(expectedColors[static_cast<size_t>(pixel)].b),
+ pixelColor[2]);
+ }
+ }
+}
+
+ReadbackBuffer::ReadbackBuffer(int64_t display, const std::shared_ptr<IComposerClient>& client,
+ const ::android::sp<::android::GraphicBuffer>& graphicBuffer,
+ int32_t width, int32_t height, common::PixelFormat pixelFormat,
+ common::Dataspace dataspace) {
+ mDisplay = display;
+
+ mComposerClient = client;
+ mGraphicBuffer = graphicBuffer;
+
+ mPixelFormat = pixelFormat;
+ mDataspace = dataspace;
+
+ mWidth = static_cast<uint32_t>(width);
+ mHeight = static_cast<uint32_t>(height);
+ mLayerCount = 1;
+ mUsage = static_cast<uint64_t>(static_cast<uint64_t>(common::BufferUsage::CPU_READ_OFTEN) |
+ static_cast<uint64_t>(common::BufferUsage::GPU_TEXTURE));
+
+ mAccessRegion.top = 0;
+ mAccessRegion.left = 0;
+ mAccessRegion.right = static_cast<int32_t>(width);
+ mAccessRegion.bottom = static_cast<int32_t>(height);
+}
+
+::android::sp<::android::GraphicBuffer> ReadbackBuffer::allocate() {
+ return ::android::sp<::android::GraphicBuffer>::make(
+ mWidth, mHeight, static_cast<::android::PixelFormat>(mPixelFormat), mLayerCount, mUsage,
+ "ReadbackVts");
+}
+
+void ReadbackBuffer::setReadbackBuffer() {
+ mGraphicBuffer = allocate();
+ ASSERT_NE(nullptr, mGraphicBuffer);
+ ASSERT_EQ(::android::OK, mGraphicBuffer->initCheck());
+ aidl::android::hardware::common::NativeHandle bufferHandle =
+ ::android::dupToAidl(mGraphicBuffer->handle);
+ ::ndk::ScopedFileDescriptor fence = ::ndk::ScopedFileDescriptor(-1);
+ EXPECT_TRUE(mComposerClient->setReadbackBuffer(mDisplay, bufferHandle, fence).isOk());
+}
+
+void ReadbackBuffer::checkReadbackBuffer(std::vector<Color> expectedColors) {
+ // lock buffer for reading
+ ndk::ScopedFileDescriptor fenceHandle;
+ EXPECT_TRUE(mComposerClient->getReadbackBufferFence(mDisplay, &fenceHandle).isOk());
+
+ int outBytesPerPixel;
+ int outBytesPerStride;
+ auto status = mGraphicBuffer->lockAsync(mUsage, mAccessRegion, nullptr, fenceHandle.get(),
+ &outBytesPerPixel, &outBytesPerStride);
+ EXPECT_EQ(::android::OK, status);
+ ASSERT_TRUE(mPixelFormat == PixelFormat::RGB_888 || mPixelFormat == PixelFormat::RGBA_8888);
+ ReadbackHelper::compareColorBuffers(expectedColors, mGraphicBuffer.get(),
+ static_cast<int32_t>(mStride), mWidth, mHeight,
+ mPixelFormat);
+ status = mGraphicBuffer->unlock();
+ EXPECT_EQ(::android::OK, status);
+}
+
+void TestColorLayer::write(CommandWriterBase& writer) {
+ TestLayer::write(writer);
+ writer.setLayerCompositionType(mDisplay, mLayer, Composition::SOLID_COLOR);
+ writer.setLayerColor(mDisplay, mLayer, mColor);
+}
+
+LayerSettings TestColorLayer::toRenderEngineLayerSettings() {
+ LayerSettings layerSettings = TestLayer::toRenderEngineLayerSettings();
+
+ layerSettings.source.solidColor =
+ ::android::half3(static_cast<::android::half>(mColor.r) / 255.0,
+ static_cast<::android::half>(mColor.g) / 255.0,
+ static_cast<::android::half>(mColor.b) / 255.0);
+ layerSettings.alpha =
+ mAlpha * static_cast<float>((static_cast<::android::half>(mColor.a) / 255.0));
+ return layerSettings;
+}
+
+TestBufferLayer::TestBufferLayer(const std::shared_ptr<IComposerClient>& client,
+ const ::android::sp<::android::GraphicBuffer>& graphicBuffer,
+ TestRenderEngine& renderEngine, int64_t display, uint32_t width,
+ uint32_t height, common::PixelFormat format,
+ Composition composition)
+ : TestLayer{client, display}, mRenderEngine(renderEngine) {
+ mGraphicBuffer = graphicBuffer;
+ mComposition = composition;
+ mWidth = width;
+ mHeight = height;
+ mLayerCount = 1;
+ mPixelFormat = format;
+ mUsage = (static_cast<uint64_t>(common::BufferUsage::CPU_READ_OFTEN) |
+ static_cast<uint64_t>(common::BufferUsage::CPU_WRITE_OFTEN) |
+ static_cast<uint64_t>(common::BufferUsage::COMPOSER_OVERLAY) |
+ static_cast<uint64_t>(common::BufferUsage::GPU_TEXTURE));
+
+ mAccessRegion.top = 0;
+ mAccessRegion.left = 0;
+ mAccessRegion.right = static_cast<int32_t>(width);
+ mAccessRegion.bottom = static_cast<int32_t>(height);
+
+ setSourceCrop({0, 0, (float)width, (float)height});
+}
+
+void TestBufferLayer::write(CommandWriterBase& writer) {
+ TestLayer::write(writer);
+ writer.setLayerCompositionType(mDisplay, mLayer, mComposition);
+ writer.setLayerVisibleRegion(mDisplay, mLayer, std::vector<Rect>(1, mDisplayFrame));
+ if (mGraphicBuffer->handle != nullptr)
+ writer.setLayerBuffer(mDisplay, mLayer, 0, mGraphicBuffer->handle, mFillFence);
+}
+
+LayerSettings TestBufferLayer::toRenderEngineLayerSettings() {
+ LayerSettings layerSettings = TestLayer::toRenderEngineLayerSettings();
+ layerSettings.source.buffer.buffer = std::make_shared<::android::renderengine::ExternalTexture>(
+ ::android::sp<::android::GraphicBuffer>::make(
+ mGraphicBuffer->handle, ::android::GraphicBuffer::CLONE_HANDLE, mWidth, mHeight,
+ static_cast<int32_t>(mPixelFormat), 1, mUsage, mStride),
+ mRenderEngine.getInternalRenderEngine(),
+ ::android::renderengine::ExternalTexture::Usage::READABLE);
+
+ layerSettings.source.buffer.usePremultipliedAlpha = mBlendMode == BlendMode::PREMULTIPLIED;
+
+ const float scaleX = (mSourceCrop.right - mSourceCrop.left) / (static_cast<float>(mWidth));
+ const float scaleY = (mSourceCrop.bottom - mSourceCrop.top) / (static_cast<float>(mHeight));
+ const float translateX = mSourceCrop.left / (static_cast<float>(mWidth));
+ const float translateY = mSourceCrop.top / (static_cast<float>(mHeight));
+
+ layerSettings.source.buffer.textureTransform =
+ ::android::mat4::translate(::android::vec4(translateX, translateY, 0, 1)) *
+ ::android::mat4::scale(::android::vec4(scaleX, scaleY, 1.0, 1.0));
+
+ return layerSettings;
+}
+
+void TestBufferLayer::fillBuffer(std::vector<Color>& expectedColors) {
+ void* bufData;
+ auto status = mGraphicBuffer->lock(mUsage, &bufData);
+ EXPECT_EQ(::android::OK, status);
+ ASSERT_NO_FATAL_FAILURE(ReadbackHelper::fillBuffer(mWidth, mHeight, mStride, bufData,
+ mPixelFormat, expectedColors));
+ EXPECT_EQ(::android::OK, mGraphicBuffer->unlock());
+}
+
+void TestBufferLayer::setBuffer(std::vector<Color> colors) {
+ mGraphicBuffer->reallocate(mWidth, mHeight, static_cast<::android::PixelFormat>(mPixelFormat),
+ mLayerCount, mUsage);
+ ASSERT_NE(nullptr, mGraphicBuffer);
+ ASSERT_NE(nullptr, mGraphicBuffer->handle);
+ ASSERT_NO_FATAL_FAILURE(fillBuffer(colors));
+ ASSERT_EQ(::android::OK, mGraphicBuffer->initCheck());
+}
+
+void TestBufferLayer::setDataspace(common::Dataspace dataspace, CommandWriterBase& writer) {
+ writer.setLayerDataspace(mDisplay, mLayer, dataspace);
+}
+
+void TestBufferLayer::setToClientComposition(CommandWriterBase& writer) {
+ writer.setLayerCompositionType(mDisplay, mLayer, Composition::CLIENT);
+}
+
+} // namespace aidl::android::hardware::graphics::composer3::vts
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/composer-vts/RenderEngineVts.cpp b/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/composer-vts/RenderEngineVts.cpp
new file mode 100644
index 0000000..50ce462
--- /dev/null
+++ b/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/composer-vts/RenderEngineVts.cpp
@@ -0,0 +1,89 @@
+/**
+ * Copyright (c) 2021, 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 "include/RenderEngineVts.h"
+
+namespace aidl::android::hardware::graphics::composer3::vts {
+
+using ::android::hardware::graphics::mapper::V2_1::IMapper;
+using ::android::renderengine::DisplaySettings;
+using ::android::renderengine::LayerSettings;
+using ::android::renderengine::RenderEngineCreationArgs;
+
+TestRenderEngine::TestRenderEngine(const RenderEngineCreationArgs& args) {
+ mFormat = static_cast<common::PixelFormat>(args.pixelFormat);
+ mRenderEngine = ::android::renderengine::RenderEngine::create(args);
+}
+
+TestRenderEngine::~TestRenderEngine() {
+ mRenderEngine.release();
+}
+
+void TestRenderEngine::setRenderLayers(std::vector<std::shared_ptr<TestLayer>> layers) {
+ sort(layers.begin(), layers.end(),
+ [](const std::shared_ptr<TestLayer>& lhs, const std::shared_ptr<TestLayer>& rhs) -> bool {
+ return lhs->getZOrder() < rhs->getZOrder();
+ });
+
+ if (!mCompositionLayers.empty()) {
+ mCompositionLayers.clear();
+ }
+ for (auto& layer : layers) {
+ LayerSettings settings = layer->toRenderEngineLayerSettings();
+ mCompositionLayers.push_back(settings);
+ }
+}
+
+void TestRenderEngine::initGraphicBuffer(uint32_t width, uint32_t height, uint32_t layerCount,
+ uint64_t usage) {
+ mGraphicBuffer = ::android::sp<::android::GraphicBuffer>::make(
+ width, height, static_cast<int32_t>(mFormat), layerCount, usage);
+}
+
+void TestRenderEngine::drawLayers() {
+ ::android::base::unique_fd bufferFence;
+
+ std::vector<::android::renderengine::LayerSettings> compositionLayers;
+ compositionLayers.reserve(mCompositionLayers.size());
+ std::transform(mCompositionLayers.begin(), mCompositionLayers.end(),
+ std::back_insert_iterator(compositionLayers),
+ [](::android::renderengine::LayerSettings& settings)
+ -> ::android::renderengine::LayerSettings { return settings; });
+ auto texture = std::make_shared<::android::renderengine::ExternalTexture>(
+ mGraphicBuffer, *mRenderEngine,
+ ::android::renderengine::ExternalTexture::Usage::WRITEABLE);
+ auto [status, readyFence] = mRenderEngine
+ ->drawLayers(mDisplaySettings, compositionLayers, texture,
+ true, std::move(bufferFence))
+ .get();
+ int fd = readyFence.release();
+ if (fd != -1) {
+ ASSERT_EQ(0, sync_wait(fd, -1));
+ ASSERT_EQ(0, close(fd));
+ }
+}
+
+void TestRenderEngine::checkColorBuffer(std::vector<Color>& expectedColors) {
+ void* bufferData;
+ ASSERT_EQ(0,
+ mGraphicBuffer->lock(static_cast<uint32_t>(mGraphicBuffer->getUsage()), &bufferData));
+ ReadbackHelper::compareColorBuffers(
+ expectedColors, bufferData, static_cast<int32_t>(mGraphicBuffer->getStride()),
+ mGraphicBuffer->getWidth(), mGraphicBuffer->getHeight(), mFormat);
+ ASSERT_EQ(::android::OK, mGraphicBuffer->unlock());
+}
+
+} // namespace aidl::android::hardware::graphics::composer3::vts
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/composer-vts/TestCommandReader.cpp b/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/composer-vts/TestCommandReader.cpp
deleted file mode 100644
index a5a84d9..0000000
--- a/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/composer-vts/TestCommandReader.cpp
+++ /dev/null
@@ -1,92 +0,0 @@
-/**
- * Copyright (c) 2021, 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 "include/TestCommandReader.h"
-#include <gtest/gtest.h>
-
-namespace aidl::android::hardware::graphics::composer3::vts {
-
-void TestCommandReader::parse() {
- mErrors.clear();
- mCompositionChanges.clear();
- while (!isEmpty()) {
- int32_t command;
- uint16_t length;
- ASSERT_TRUE(beginCommand(&command, &length));
-
- parseSingleCommand(command, length);
-
- endCommand();
- }
-}
-
-void TestCommandReader::parseSingleCommand(int32_t commandRaw, uint16_t length) {
- auto command = static_cast<Command>(commandRaw);
-
- switch (command) {
- case Command::SET_CLIENT_TARGET_PROPERTY: {
- ASSERT_EQ(2, length);
- read();
- close(readFence());
- } break;
- case Command::SELECT_DISPLAY: {
- ASSERT_EQ(2, length);
- read64(); // display
- } break;
- case Command::SET_ERROR: {
- ASSERT_EQ(2, length);
- auto loc = read();
- auto err = readSigned();
- std::pair<uint32_t, uint32_t> error(loc, err);
- mErrors.push_back(error);
- } break;
- case Command::SET_CHANGED_COMPOSITION_TYPES: {
- ASSERT_EQ(0, length % 3);
- for (uint16_t count = 0; count < length / 3; ++count) {
- uint64_t layerId = read64();
- uint32_t composition = read();
-
- std::pair<uint64_t, uint32_t> compositionChange(layerId, composition);
- mCompositionChanges.push_back(compositionChange);
- }
- } break;
- case Command::SET_DISPLAY_REQUESTS: {
- ASSERT_EQ(1, length % 3);
- read(); // displayRequests, ignored for now
- for (uint16_t count = 0; count < (length - 1) / 3; ++count) {
- read64(); // layer
- // silently eat requests to clear the client target, since we won't be testing
- // client composition anyway
- ASSERT_EQ(1u, read());
- }
- } break;
- case Command::SET_PRESENT_FENCE: {
- ASSERT_EQ(1, length);
- close(readFence());
- } break;
- case Command::SET_RELEASE_FENCES: {
- ASSERT_EQ(0, length % 3);
- for (uint16_t count = 0; count < length / 3; ++count) {
- read64();
- close(readFence());
- }
- } break;
- default:
- GTEST_FAIL() << "unexpected return command " << std::hex << static_cast<int>(command);
- break;
- }
-}
-} // namespace aidl::android::hardware::graphics::composer3::vts
\ No newline at end of file
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/composer-vts/include/ReadbackVts.h b/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/composer-vts/include/ReadbackVts.h
new file mode 100644
index 0000000..d40e3d2
--- /dev/null
+++ b/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/composer-vts/include/ReadbackVts.h
@@ -0,0 +1,216 @@
+/**
+ * Copyright (c) 2021, 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
+
+// TODO(b/129481165): remove the #pragma below and fix conversion issues
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wconversion"
+
+#include <GraphicsComposerCallback.h>
+#include <aidl/android/hardware/graphics/composer3/IComposerClient.h>
+#include <android-base/unique_fd.h>
+#include <android/hardware/graphics/composer3/command-buffer.h>
+#include <mapper-vts/2.1/MapperVts.h>
+#include <renderengine/RenderEngine.h>
+#include <ui/GraphicBuffer.h>
+
+#include <memory>
+
+// TODO(b/129481165): remove the #pragma below and fix conversion issues
+#pragma clang diagnostic pop // ignored "-Wconversion
+
+namespace aidl::android::hardware::graphics::composer3::vts {
+
+using ::android::renderengine::LayerSettings;
+using common::Dataspace;
+using common::PixelFormat;
+using IMapper2_1 = ::android::hardware::graphics::mapper::V2_1::IMapper;
+
+static const Color BLACK = {0, 0, 0, static_cast<int8_t>(0xff)};
+static const Color RED = {static_cast<int8_t>(0xff), 0, 0, static_cast<int8_t>(0xff)};
+static const Color TRANSLUCENT_RED = {static_cast<int8_t>(0xff), 0, 0, 0x33};
+static const Color GREEN = {0, static_cast<int8_t>(0xff), 0, static_cast<int8_t>(0xff)};
+static const Color BLUE = {0, 0, static_cast<int8_t>(0xff), static_cast<int8_t>(0xff)};
+static const Color WHITE = {static_cast<int8_t>(0xff), static_cast<int8_t>(0xff),
+ static_cast<int8_t>(0xff), static_cast<int8_t>(0xff)};
+
+class TestRenderEngine;
+
+class TestLayer {
+ public:
+ TestLayer(const std::shared_ptr<IComposerClient>& client, int64_t display)
+ : mDisplay(display), mComposerClient(client) {
+ client->createLayer(display, kBufferSlotCount, &mLayer);
+ }
+
+ // ComposerClient will take care of destroying layers, no need to explicitly
+ // call destroyLayers here
+ virtual ~TestLayer(){};
+
+ virtual void write(CommandWriterBase& writer);
+ virtual LayerSettings toRenderEngineLayerSettings();
+
+ void setDisplayFrame(Rect frame) { mDisplayFrame = frame; }
+ void setSourceCrop(FRect crop) { mSourceCrop = crop; }
+ void setZOrder(uint32_t z) { mZOrder = z; }
+
+ void setSurfaceDamage(std::vector<Rect> surfaceDamage) {
+ mSurfaceDamage = std::move(surfaceDamage);
+ }
+
+ void setTransform(Transform transform) { mTransform = transform; }
+ void setAlpha(float alpha) { mAlpha = alpha; }
+ void setBlendMode(BlendMode blendMode) { mBlendMode = blendMode; }
+
+ BlendMode getBlendMode() const { return mBlendMode; }
+
+ uint32_t getZOrder() const { return mZOrder; }
+
+ float getAlpha() const { return mAlpha; }
+
+ int64_t getLayer() const { return mLayer; }
+
+ protected:
+ int64_t mDisplay;
+ int64_t mLayer;
+ Rect mDisplayFrame = {0, 0, 0, 0};
+ std::vector<Rect> mSurfaceDamage;
+ Transform mTransform = static_cast<Transform>(0);
+ FRect mSourceCrop = {0, 0, 0, 0};
+ static constexpr uint32_t kBufferSlotCount = 64;
+ float mAlpha = 1.0;
+ BlendMode mBlendMode = BlendMode::NONE;
+ uint32_t mZOrder = 0;
+
+ private:
+ std::shared_ptr<IComposerClient> const mComposerClient;
+};
+
+class TestColorLayer : public TestLayer {
+ public:
+ TestColorLayer(const std::shared_ptr<IComposerClient>& client, int64_t display)
+ : TestLayer{client, display} {}
+
+ void write(CommandWriterBase& writer) override;
+
+ LayerSettings toRenderEngineLayerSettings() override;
+
+ void setColor(Color color) { mColor = color; }
+
+ private:
+ Color mColor = WHITE;
+};
+
+class TestBufferLayer : public TestLayer {
+ public:
+ TestBufferLayer(const std::shared_ptr<IComposerClient>& client,
+ const ::android::sp<::android::GraphicBuffer>& graphicBuffer,
+ TestRenderEngine& renderEngine, int64_t display, uint32_t width,
+ uint32_t height, common::PixelFormat format,
+ Composition composition = Composition::DEVICE);
+
+ void write(CommandWriterBase& writer) override;
+
+ LayerSettings toRenderEngineLayerSettings() override;
+
+ void fillBuffer(std::vector<Color>& expectedColors);
+
+ void setBuffer(std::vector<Color> colors);
+
+ void setDataspace(Dataspace dataspace, CommandWriterBase& writer);
+
+ void setToClientComposition(CommandWriterBase& writer);
+
+ uint32_t getWidth() const { return mWidth; }
+
+ uint32_t getHeight() const { return mHeight; }
+
+ ::android::Rect getAccessRegion() const { return mAccessRegion; }
+
+ uint32_t getLayerCount() const { return mLayerCount; }
+
+ protected:
+ Composition mComposition;
+ ::android::sp<::android::GraphicBuffer> mGraphicBuffer;
+ TestRenderEngine& mRenderEngine;
+ int32_t mFillFence;
+ uint32_t mWidth;
+ uint32_t mHeight;
+ uint32_t mLayerCount;
+ PixelFormat mPixelFormat;
+ uint32_t mUsage;
+ uint32_t mStride;
+ ::android::Rect mAccessRegion;
+};
+
+class ReadbackHelper {
+ public:
+ static std::string getColorModeString(ColorMode mode);
+
+ static std::string getDataspaceString(Dataspace dataspace);
+
+ static Dataspace getDataspaceForColorMode(ColorMode mode);
+
+ static int32_t GetBytesPerPixel(PixelFormat pixelFormat);
+
+ static void fillBuffer(uint32_t width, uint32_t height, uint32_t stride, void* bufferData,
+ PixelFormat pixelFormat, std::vector<Color> desiredPixelColors);
+
+ static void clearColors(std::vector<Color>& expectedColors, int32_t width, int32_t height,
+ int32_t displayWidth);
+
+ static void fillColorsArea(std::vector<Color>& expectedColors, int32_t stride, Rect area,
+ Color color);
+
+ static bool readbackSupported(const PixelFormat& pixelFormat, const Dataspace& dataspace);
+
+ static const std::vector<ColorMode> colorModes;
+ static const std::vector<Dataspace> dataspaces;
+
+ static void compareColorBuffers(std::vector<Color>& expectedColors, void* bufferData,
+ const int32_t stride, const uint32_t width,
+ const uint32_t height, PixelFormat pixelFormat);
+};
+
+class ReadbackBuffer {
+ public:
+ ReadbackBuffer(int64_t display, const std::shared_ptr<IComposerClient>& client,
+ const ::android::sp<::android::GraphicBuffer>& graphicBuffer, int32_t width,
+ int32_t height, common::PixelFormat pixelFormat, common::Dataspace dataspace);
+
+ void setReadbackBuffer();
+
+ void checkReadbackBuffer(std::vector<Color> expectedColors);
+
+ ::android::sp<::android::GraphicBuffer> allocate();
+
+ protected:
+ uint32_t mWidth;
+ uint32_t mHeight;
+ uint32_t mLayerCount;
+ uint32_t mUsage;
+ uint32_t mStride;
+ PixelFormat mPixelFormat;
+ Dataspace mDataspace;
+ int64_t mDisplay;
+ ::android::sp<::android::GraphicBuffer> mGraphicBuffer;
+ std::shared_ptr<IComposerClient> mComposerClient;
+ ::android::Rect mAccessRegion;
+ native_handle_t mBufferHandle;
+};
+
+} // namespace aidl::android::hardware::graphics::composer3::vts
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/composer-vts/include/RenderEngineVts.h b/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/composer-vts/include/RenderEngineVts.h
new file mode 100644
index 0000000..2798e09
--- /dev/null
+++ b/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/composer-vts/include/RenderEngineVts.h
@@ -0,0 +1,71 @@
+/**
+ * Copyright (c) 2021, 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
+
+// TODO(b/129481165): remove the #pragma below and fix conversion issues
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wconversion"
+
+#include <ReadbackVts.h>
+#include <mapper-vts/2.1/MapperVts.h>
+#include <math/half.h>
+#include <math/vec3.h>
+#include <renderengine/ExternalTexture.h>
+#include <renderengine/RenderEngine.h>
+#include <ui/GraphicBuffer.h>
+#include <ui/GraphicBufferAllocator.h>
+#include <ui/PixelFormat.h>
+#include <ui/Rect.h>
+#include <ui/Region.h>
+
+// TODO(b/129481165): remove the #pragma below and fix conversion issues
+#pragma clang diagnostic pop // ignored "-Wconversion
+
+namespace aidl::android::hardware::graphics::composer3::vts {
+
+using ::android::hardware::graphics::mapper::V2_1::IMapper;
+using ::android::renderengine::DisplaySettings;
+using ::android::renderengine::ExternalTexture;
+using ::android::renderengine::RenderEngineCreationArgs;
+
+class TestRenderEngine {
+ public:
+ static constexpr uint32_t sMaxFrameBufferAcquireBuffers = 2;
+
+ TestRenderEngine(const RenderEngineCreationArgs& args);
+ ~TestRenderEngine();
+
+ void setRenderLayers(std::vector<std::shared_ptr<TestLayer>> layers);
+ void initGraphicBuffer(uint32_t width, uint32_t height, uint32_t layerCount, uint64_t usage);
+ void setDisplaySettings(DisplaySettings& displaySettings) {
+ mDisplaySettings = displaySettings;
+ };
+ void drawLayers();
+ void checkColorBuffer(std::vector<Color>& expectedColors);
+
+ ::android::renderengine::RenderEngine& getInternalRenderEngine() { return *mRenderEngine; }
+
+ private:
+ common::PixelFormat mFormat;
+ std::vector<::android::renderengine::LayerSettings> mCompositionLayers;
+ std::unique_ptr<::android::renderengine::RenderEngine> mRenderEngine;
+ std::vector<::android::renderengine::LayerSettings> mRenderLayers;
+ ::android::sp<::android::GraphicBuffer> mGraphicBuffer;
+
+ DisplaySettings mDisplaySettings;
+};
+
+} // namespace aidl::android::hardware::graphics::composer3::vts
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/composer-vts/include/TestCommandReader.h b/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/composer-vts/include/TestCommandReader.h
deleted file mode 100644
index 852a56e..0000000
--- a/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/composer-vts/include/TestCommandReader.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * Copyright (c) 2021, 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
-
-// TODO(b/129481165): remove the #pragma below and fix conversion issues
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wconversion"
-
-#include <android/hardware/graphics/composer3/command-buffer.h>
-
-// TODO(b/129481165): remove the #pragma below and fix conversion issues
-#pragma clang diagnostic pop // ignored "-Wconversion
-
-namespace aidl::android::hardware::graphics::composer3::vts {
-
-class TestCommandReader : public CommandReaderBase {
- public:
- virtual ~TestCommandReader() = default;
-
- std::vector<std::pair<uint32_t, uint32_t>> mErrors;
- std::vector<std::pair<uint64_t, uint32_t>> mCompositionChanges;
-
- // Parse all commands in the return command queue. Call GTEST_FAIL() for
- // unexpected errors or commands.
- void parse();
- virtual void parseSingleCommand(int32_t commandRaw, uint16_t length);
-};
-} // namespace aidl::android::hardware::graphics::composer3::vts
diff --git a/graphics/composer/aidl/include/android/hardware/graphics/composer3/command-buffer.h b/graphics/composer/aidl/include/android/hardware/graphics/composer3/command-buffer.h
index d02cf9c..fcf2a34 100644
--- a/graphics/composer/aidl/include/android/hardware/graphics/composer3/command-buffer.h
+++ b/graphics/composer/aidl/include/android/hardware/graphics/composer3/command-buffer.h
@@ -19,15 +19,16 @@
#include <algorithm>
#include <limits>
#include <memory>
+#include <unordered_map>
+#include <unordered_set>
#include <vector>
#include <inttypes.h>
#include <string.h>
-#include <aidl/android/hardware/graphics/composer3/BlendMode.h>
+#include <aidl/android/hardware/graphics/common/BlendMode.h>
#include <aidl/android/hardware/graphics/composer3/ClientTargetProperty.h>
#include <aidl/android/hardware/graphics/composer3/Color.h>
-#include <aidl/android/hardware/graphics/composer3/Command.h>
#include <aidl/android/hardware/graphics/composer3/Composition.h>
#include <aidl/android/hardware/graphics/composer3/FloatColor.h>
#include <aidl/android/hardware/graphics/composer3/HandleIndex.h>
@@ -36,39 +37,29 @@
#include <aidl/android/hardware/graphics/composer3/PerFrameMetadata.h>
#include <aidl/android/hardware/graphics/composer3/PerFrameMetadataBlob.h>
+#include <aidl/android/hardware/graphics/composer3/CommandResultPayload.h>
+#include <aidl/android/hardware/graphics/composer3/DisplayCommand.h>
+
#include <aidl/android/hardware/graphics/common/ColorTransform.h>
#include <aidl/android/hardware/graphics/common/FRect.h>
#include <aidl/android/hardware/graphics/common/Rect.h>
#include <aidl/android/hardware/graphics/common/Transform.h>
-#include <fmq/AidlMessageQueue.h>
#include <log/log.h>
#include <sync/sync.h>
#include <aidlcommonsupport/NativeHandle.h>
+using aidl::android::hardware::graphics::common::BlendMode;
using aidl::android::hardware::graphics::common::ColorTransform;
using aidl::android::hardware::graphics::common::Dataspace;
using aidl::android::hardware::graphics::common::FRect;
using aidl::android::hardware::graphics::common::Rect;
using aidl::android::hardware::graphics::common::Transform;
-using aidl::android::hardware::graphics::composer3::BlendMode;
-using aidl::android::hardware::graphics::composer3::ClientTargetProperty;
-using aidl::android::hardware::graphics::composer3::Color;
-using aidl::android::hardware::graphics::composer3::Command;
-using aidl::android::hardware::graphics::composer3::Composition;
-using aidl::android::hardware::graphics::composer3::FloatColor;
-using aidl::android::hardware::graphics::composer3::HandleIndex;
-using aidl::android::hardware::graphics::composer3::PerFrameMetadata;
-using aidl::android::hardware::graphics::composer3::PerFrameMetadataBlob;
+using namespace aidl::android::hardware::graphics::composer3;
using aidl::android::hardware::common::NativeHandle;
-using aidl::android::hardware::common::fmq::SynchronizedReadWrite;
-using android::AidlMessageQueue;
-using CommandQueueType = AidlMessageQueue<int32_t, SynchronizedReadWrite>;
-using aidl::android::hardware::common::fmq::MQDescriptor;
-using DescriptorType = MQDescriptor<int32_t, SynchronizedReadWrite>;
namespace aidl::android::hardware::graphics::composer3 {
@@ -76,820 +67,548 @@
// units of uint32_t's.
class CommandWriterBase {
public:
- CommandWriterBase(uint32_t initialMaxSize) : mDataMaxSize(initialMaxSize) {
- mData = std::make_unique<int32_t[]>(mDataMaxSize);
- reset();
- }
+ CommandWriterBase() { reset(); }
virtual ~CommandWriterBase() { reset(); }
void reset() {
- mDataWritten = 0;
- mCommandEnd = 0;
-
- // handles in mDataHandles are owned by the caller
- mDataHandles.clear();
-
- // handles in mTemporaryHandles are owned by the writer
- for (auto handle : mTemporaryHandles) {
- native_handle_close(handle);
- native_handle_delete(handle);
- }
- mTemporaryHandles.clear();
+ mDisplayCommand.reset();
+ mLayerCommand.reset();
+ mCommands.clear();
+ mCommandsResults.clear();
}
- Command getCommand(uint32_t offset) {
- uint32_t val = (offset < mDataWritten) ? mData[offset] : 0;
- return static_cast<Command>(val & static_cast<uint32_t>(Command::OPCODE_MASK));
+ void setError(int32_t index, int32_t errorCode) {
+ CommandError error;
+ error.commandIndex = index;
+ error.errorCode = errorCode;
+ mCommandsResults.emplace_back(std::move(error));
}
- bool writeQueue(bool* outQueueChanged, int32_t* outCommandLength,
- std::vector<NativeHandle>* outCommandHandles) {
- if (mDataWritten == 0) {
- *outQueueChanged = false;
- *outCommandLength = 0;
- outCommandHandles->clear();
- return true;
- }
-
- // After data are written to the queue, it may not be read by the
- // remote reader when
- //
- // - the writer does not send them (because of other errors)
- // - the hwbinder transaction fails
- // - the reader does not read them (because of other errors)
- //
- // Discard the stale data here.
- size_t staleDataSize = mQueue ? mQueue->availableToRead() : 0;
- if (staleDataSize > 0) {
- ALOGW("discarding stale data from message queue");
- CommandQueueType::MemTransaction tx;
- if (mQueue->beginRead(staleDataSize, &tx)) {
- mQueue->commitRead(staleDataSize);
- }
- }
-
- // write data to queue, optionally resizing it
- if (mQueue && (mDataMaxSize <= mQueue->getQuantumCount())) {
- if (!mQueue->write(mData.get(), mDataWritten)) {
- ALOGE("failed to write commands to message queue");
- return false;
- }
-
- *outQueueChanged = false;
- } else {
- auto newQueue = std::make_unique<CommandQueueType>(mDataMaxSize);
- if (!newQueue->isValid() || !newQueue->write(mData.get(), mDataWritten)) {
- ALOGE("failed to prepare a new message queue ");
- return false;
- }
-
- mQueue = std::move(newQueue);
- *outQueueChanged = true;
- }
-
- *outCommandLength = mDataWritten;
- *outCommandHandles = std::move(mDataHandles);
-
- return true;
+ void setPresentOrValidateResult(int64_t display, PresentOrValidate::Result result) {
+ PresentOrValidate presentOrValidate;
+ presentOrValidate.display = display;
+ presentOrValidate.result = result;
+ mCommandsResults.emplace_back(std::move(presentOrValidate));
}
- DescriptorType getMQDescriptor() const {
- return (mQueue) ? mQueue->dupeDesc() : DescriptorType{};
- }
-
- static constexpr uint16_t kSelectDisplayLength = 2;
- void selectDisplay(int64_t display) {
- beginCommand(Command::SELECT_DISPLAY, kSelectDisplayLength);
- write64(display);
- endCommand();
- }
-
- static constexpr uint16_t kSelectLayerLength = 2;
- void selectLayer(int64_t layer) {
- beginCommand(Command::SELECT_LAYER, kSelectLayerLength);
- write64(layer);
- endCommand();
- }
-
- static constexpr uint16_t kSetErrorLength = 2;
- void setError(uint32_t location, int32_t error) {
- beginCommand(Command::SET_ERROR, kSetErrorLength);
- write(location);
- writeSigned(error);
- endCommand();
- }
-
- static constexpr uint32_t kPresentOrValidateDisplayResultLength = 1;
- void setPresentOrValidateResult(uint32_t state) {
- beginCommand(Command::SET_PRESENT_OR_VALIDATE_DISPLAY_RESULT,
- kPresentOrValidateDisplayResultLength);
- write(state);
- endCommand();
- }
-
- void setChangedCompositionTypes(const std::vector<int64_t>& layers,
+ void setChangedCompositionTypes(int64_t display, const std::vector<int64_t>& layers,
const std::vector<Composition>& types) {
- size_t totalLayers = std::min(layers.size(), types.size());
- size_t currentLayer = 0;
+ ChangedCompositionTypes changedCompositionTypes;
+ changedCompositionTypes.display = display;
+ changedCompositionTypes.layers.reserve(layers.size());
+ for (int i = 0; i < layers.size(); i++) {
+ auto layer = ChangedCompositionLayer{.layer = layers[i], .composition = types[i]};
+ changedCompositionTypes.layers.emplace_back(std::move(layer));
+ }
+ mCommandsResults.emplace_back(std::move(changedCompositionTypes));
+ }
- while (currentLayer < totalLayers) {
- size_t count =
- std::min(totalLayers - currentLayer, static_cast<size_t>(kMaxLength) / 3);
+ void setDisplayRequests(int64_t display, int32_t displayRequestMask,
+ const std::vector<int64_t>& layers,
+ const std::vector<int32_t>& layerRequestMasks) {
+ DisplayRequest displayRequest;
+ displayRequest.display = display;
+ displayRequest.mask = displayRequestMask;
+ displayRequest.layerRequests.reserve(layers.size());
+ for (int i = 0; i < layers.size(); i++) {
+ auto layerRequest =
+ DisplayRequest::LayerRequest{.layer = layers[i], .mask = layerRequestMasks[i]};
+ displayRequest.layerRequests.emplace_back(std::move(layerRequest));
+ }
+ mCommandsResults.emplace_back(std::move(displayRequest));
+ }
- beginCommand(Command::SET_CHANGED_COMPOSITION_TYPES, count * 3);
- for (size_t i = 0; i < count; i++) {
- write64(layers[currentLayer + i]);
- writeSigned(static_cast<int32_t>(types[currentLayer + i]));
+ void setPresentFence(int64_t display, ::ndk::ScopedFileDescriptor presentFence) {
+ if (presentFence.get() >= 0) {
+ PresentFence presentFenceCommand;
+ presentFenceCommand.fence = std::move(presentFence);
+ presentFenceCommand.display = display;
+ mCommandsResults.emplace_back(std::move(presentFenceCommand));
+ } else {
+ ALOGW("%s: invalid present fence %d", __func__, presentFence.get());
+ }
+ }
+
+ void setReleaseFences(int64_t display, const std::vector<int64_t>& layers,
+ std::vector<::ndk::ScopedFileDescriptor> releaseFences) {
+ ReleaseFences releaseFencesCommand;
+ releaseFencesCommand.display = display;
+ for (int i = 0; i < layers.size(); i++) {
+ if (releaseFences[i].get() >= 0) {
+ ReleaseFences::Layer layer;
+ layer.layer = layers[i];
+ layer.fence = std::move(releaseFences[i]);
+ releaseFencesCommand.layers.emplace_back(std::move(layer));
+ } else {
+ ALOGW("%s: invalid release fence %d", __func__, releaseFences[i].get());
}
- endCommand();
-
- currentLayer += count;
}
+ mCommandsResults.emplace_back(std::move(releaseFencesCommand));
}
- void setDisplayRequests(uint32_t displayRequestMask, const std::vector<int64_t>& layers,
- const std::vector<uint32_t>& layerRequestMasks) {
- size_t totalLayers = std::min(layers.size(), layerRequestMasks.size());
- size_t currentLayer = 0;
-
- while (currentLayer < totalLayers) {
- size_t count =
- std::min(totalLayers - currentLayer, static_cast<size_t>(kMaxLength - 1) / 3);
-
- beginCommand(Command::SET_DISPLAY_REQUESTS, 1 + count * 3);
- write(displayRequestMask);
- for (size_t i = 0; i < count; i++) {
- write64(layers[currentLayer + i]);
- write(static_cast<int32_t>(layerRequestMasks[currentLayer + i]));
- }
- endCommand();
-
- currentLayer += count;
- }
+ void setClientTargetProperty(int64_t display, const ClientTargetProperty& clientTargetProperty,
+ float whitePointNits) {
+ ClientTargetPropertyWithNits clientTargetPropertyWithNits;
+ clientTargetPropertyWithNits.display = display;
+ clientTargetPropertyWithNits.clientTargetProperty = clientTargetProperty;
+ clientTargetPropertyWithNits.whitePointNits = whitePointNits;
+ mCommandsResults.emplace_back(std::move(clientTargetPropertyWithNits));
}
- static constexpr uint16_t kSetPresentFenceLength = 1;
- void setPresentFence(int presentFence) {
- beginCommand(Command::SET_PRESENT_FENCE, kSetPresentFenceLength);
- writeFence(presentFence);
- endCommand();
+ void setColorTransform(int64_t display, const float* matrix, ColorTransform hint) {
+ ColorTransformPayload colorTransformPayload;
+ colorTransformPayload.matrix.assign(matrix, matrix + 16);
+ colorTransformPayload.hint = hint;
+ getDisplayCommand(display).colorTransform.emplace(std::move(colorTransformPayload));
}
- void setReleaseFences(const std::vector<int64_t>& layers,
- const std::vector<int>& releaseFences) {
- size_t totalLayers = std::min(layers.size(), releaseFences.size());
- size_t currentLayer = 0;
-
- while (currentLayer < totalLayers) {
- size_t count =
- std::min(totalLayers - currentLayer, static_cast<size_t>(kMaxLength) / 3);
-
- beginCommand(Command::SET_RELEASE_FENCES, count * 3);
- for (size_t i = 0; i < count; i++) {
- write64(layers[currentLayer + i]);
- writeFence(releaseFences[currentLayer + i]);
- }
- endCommand();
-
- currentLayer += count;
- }
+ void setClientTarget(int64_t display, uint32_t slot, const native_handle_t* target,
+ int acquireFence, Dataspace dataspace, const std::vector<Rect>& damage) {
+ ClientTarget clientTargetCommand;
+ clientTargetCommand.buffer = getBuffer(slot, target, acquireFence);
+ clientTargetCommand.dataspace = dataspace;
+ clientTargetCommand.damage.assign(damage.begin(), damage.end());
+ getDisplayCommand(display).clientTarget.emplace(std::move(clientTargetCommand));
}
- static constexpr uint16_t kSetColorTransformLength = 17;
- void setColorTransform(const float* matrix, ColorTransform hint) {
- beginCommand(Command::SET_COLOR_TRANSFORM, kSetColorTransformLength);
- for (int i = 0; i < 16; i++) {
- writeFloat(matrix[i]);
- }
- writeSigned(static_cast<int32_t>(hint));
- endCommand();
+ void setOutputBuffer(int64_t display, uint32_t slot, const native_handle_t* buffer,
+ int releaseFence) {
+ getDisplayCommand(display).virtualDisplayOutputBuffer.emplace(
+ getBuffer(slot, buffer, releaseFence));
}
- void setClientTarget(uint32_t slot, const native_handle_t* target, int acquireFence,
- Dataspace dataspace, const std::vector<Rect>& damage) {
- setClientTargetInternal(slot, target, acquireFence, static_cast<int32_t>(dataspace),
- damage);
+ void validateDisplay(int64_t display) { getDisplayCommand(display).validateDisplay = true; }
+
+ void presentOrvalidateDisplay(int64_t display) {
+ getDisplayCommand(display).presentOrValidateDisplay = true;
}
- static constexpr uint16_t kSetOutputBufferLength = 3;
- void setOutputBuffer(uint32_t slot, const native_handle_t* buffer, int releaseFence) {
- beginCommand(Command::SET_OUTPUT_BUFFER, kSetOutputBufferLength);
- write(slot);
- writeHandle(buffer, true);
- writeFence(releaseFence);
- endCommand();
+ void acceptDisplayChanges(int64_t display) {
+ getDisplayCommand(display).acceptDisplayChanges = true;
}
- static constexpr uint16_t kValidateDisplayLength = 0;
- void validateDisplay() {
- beginCommand(Command::VALIDATE_DISPLAY, kValidateDisplayLength);
- endCommand();
+ void presentDisplay(int64_t display) { getDisplayCommand(display).presentDisplay = true; }
+
+ void setLayerCursorPosition(int64_t display, int64_t layer, int32_t x, int32_t y) {
+ common::Point cursorPosition;
+ cursorPosition.x = x;
+ cursorPosition.y = y;
+ getLayerCommand(display, layer).cursorPosition.emplace(std::move(cursorPosition));
}
- static constexpr uint16_t kPresentOrValidateDisplayLength = 0;
- void presentOrvalidateDisplay() {
- beginCommand(Command::PRESENT_OR_VALIDATE_DISPLAY, kPresentOrValidateDisplayLength);
- endCommand();
+ void setLayerBuffer(int64_t display, int64_t layer, uint32_t slot,
+ const native_handle_t* buffer, int acquireFence) {
+ getLayerCommand(display, layer).buffer = getBuffer(slot, buffer, acquireFence);
}
- static constexpr uint16_t kAcceptDisplayChangesLength = 0;
- void acceptDisplayChanges() {
- beginCommand(Command::ACCEPT_DISPLAY_CHANGES, kAcceptDisplayChangesLength);
- endCommand();
+ void setLayerSurfaceDamage(int64_t display, int64_t layer, const std::vector<Rect>& damage) {
+ getLayerCommand(display, layer).damage.emplace(damage.begin(), damage.end());
}
- static constexpr uint16_t kPresentDisplayLength = 0;
- void presentDisplay() {
- beginCommand(Command::PRESENT_DISPLAY, kPresentDisplayLength);
- endCommand();
+ void setLayerBlendMode(int64_t display, int64_t layer, BlendMode mode) {
+ ParcelableBlendMode parcelableBlendMode;
+ parcelableBlendMode.blendMode = mode;
+ getLayerCommand(display, layer).blendMode.emplace(std::move(parcelableBlendMode));
}
- static constexpr uint16_t kSetLayerCursorPositionLength = 2;
- void setLayerCursorPosition(int32_t x, int32_t y) {
- beginCommand(Command::SET_LAYER_CURSOR_POSITION, kSetLayerCursorPositionLength);
- writeSigned(x);
- writeSigned(y);
- endCommand();
+ void setLayerColor(int64_t display, int64_t layer, Color color) {
+ getLayerCommand(display, layer).color.emplace(std::move(color));
}
- static constexpr uint16_t kSetLayerBufferLength = 3;
- void setLayerBuffer(uint32_t slot, const native_handle_t* buffer, int acquireFence) {
- beginCommand(Command::SET_LAYER_BUFFER, kSetLayerBufferLength);
- write(slot);
- writeHandle(buffer, true);
- writeFence(acquireFence);
- endCommand();
+ void setLayerCompositionType(int64_t display, int64_t layer, Composition type) {
+ ParcelableComposition compositionPayload;
+ compositionPayload.composition = type;
+ getLayerCommand(display, layer).composition.emplace(std::move(compositionPayload));
}
- void setLayerSurfaceDamage(const std::vector<Rect>& damage) {
- bool doWrite = (damage.size() <= kMaxLength / 4);
- size_t length = (doWrite) ? damage.size() * 4 : 0;
-
- beginCommand(Command::SET_LAYER_SURFACE_DAMAGE, length);
- // When there are too many rectangles in the damage region and doWrite
- // is false, we write no rectangle at all which means the entire
- // layer is damaged.
- if (doWrite) {
- writeRegion(damage);
- }
- endCommand();
+ void setLayerDataspace(int64_t display, int64_t layer, Dataspace dataspace) {
+ ParcelableDataspace dataspacePayload;
+ dataspacePayload.dataspace = dataspace;
+ getLayerCommand(display, layer).dataspace.emplace(std::move(dataspacePayload));
}
- static constexpr uint16_t kSetLayerBlendModeLength = 1;
- void setLayerBlendMode(BlendMode mode) {
- beginCommand(Command::SET_LAYER_BLEND_MODE, kSetLayerBlendModeLength);
- writeSigned(static_cast<int32_t>(mode));
- endCommand();
+ void setLayerDisplayFrame(int64_t display, int64_t layer, const Rect& frame) {
+ getLayerCommand(display, layer).displayFrame.emplace(frame);
}
- static constexpr uint16_t kSetLayerColorLength = 1;
- void setLayerColor(Color color) {
- beginCommand(Command::SET_LAYER_COLOR, kSetLayerColorLength);
- writeColor(color);
- endCommand();
+ void setLayerPlaneAlpha(int64_t display, int64_t layer, float alpha) {
+ PlaneAlpha planeAlpha;
+ planeAlpha.alpha = alpha;
+ getLayerCommand(display, layer).planeAlpha.emplace(std::move(planeAlpha));
}
- static constexpr uint16_t kSetLayerCompositionTypeLength = 1;
- void setLayerCompositionType(Composition type) {
- beginCommand(Command::SET_LAYER_COMPOSITION_TYPE, kSetLayerCompositionTypeLength);
- writeSigned(static_cast<int32_t>(type));
- endCommand();
+ void setLayerSidebandStream(int64_t display, int64_t layer, const native_handle_t* stream) {
+ NativeHandle handle;
+ if (stream) handle = ::android::dupToAidl(stream);
+ getLayerCommand(display, layer).sidebandStream.emplace(std::move(handle));
}
- static constexpr uint16_t kSetLayerDataspaceLength = 1;
- void setLayerDataspace(Dataspace dataspace) {
- setLayerDataspaceInternal(static_cast<int32_t>(dataspace));
+ void setLayerSourceCrop(int64_t display, int64_t layer, const FRect& crop) {
+ getLayerCommand(display, layer).sourceCrop.emplace(crop);
}
- static constexpr uint16_t kSetLayerDisplayFrameLength = 4;
- void setLayerDisplayFrame(const Rect& frame) {
- beginCommand(Command::SET_LAYER_DISPLAY_FRAME, kSetLayerDisplayFrameLength);
- writeRect(frame);
- endCommand();
+ void setLayerTransform(int64_t display, int64_t layer, Transform transform) {
+ ParcelableTransform transformPayload;
+ transformPayload.transform = transform;
+ getLayerCommand(display, layer).transform.emplace(std::move(transformPayload));
}
- static constexpr uint16_t kSetLayerPlaneAlphaLength = 1;
- void setLayerPlaneAlpha(float alpha) {
- beginCommand(Command::SET_LAYER_PLANE_ALPHA, kSetLayerPlaneAlphaLength);
- writeFloat(alpha);
- endCommand();
+ void setLayerVisibleRegion(int64_t display, int64_t layer, const std::vector<Rect>& visible) {
+ getLayerCommand(display, layer).visibleRegion.emplace(visible.begin(), visible.end());
}
- static constexpr uint16_t kSetLayerSidebandStreamLength = 1;
- void setLayerSidebandStream(const native_handle_t* stream) {
- beginCommand(Command::SET_LAYER_SIDEBAND_STREAM, kSetLayerSidebandStreamLength);
- writeHandle(stream);
- endCommand();
+ void setLayerZOrder(int64_t display, int64_t layer, uint32_t z) {
+ ZOrder zorder;
+ zorder.z = z;
+ getLayerCommand(display, layer).z.emplace(std::move(zorder));
}
- static constexpr uint16_t kSetLayerSourceCropLength = 4;
- void setLayerSourceCrop(const FRect& crop) {
- beginCommand(Command::SET_LAYER_SOURCE_CROP, kSetLayerSourceCropLength);
- writeFRect(crop);
- endCommand();
+ void setLayerPerFrameMetadata(int64_t display, int64_t layer,
+ const std::vector<PerFrameMetadata>& metadataVec) {
+ getLayerCommand(display, layer)
+ .perFrameMetadata.emplace(metadataVec.begin(), metadataVec.end());
}
- static constexpr uint16_t kSetLayerTransformLength = 1;
- void setLayerTransform(Transform transform) {
- beginCommand(Command::SET_LAYER_TRANSFORM, kSetLayerTransformLength);
- writeSigned(static_cast<int32_t>(transform));
- endCommand();
+ void setLayerColorTransform(int64_t display, int64_t layer, const float* matrix) {
+ getLayerCommand(display, layer).colorTransform.emplace(matrix, matrix + 16);
}
- void setLayerVisibleRegion(const std::vector<Rect>& visible) {
- bool doWrite = (visible.size() <= kMaxLength / 4);
- size_t length = (doWrite) ? visible.size() * 4 : 0;
-
- beginCommand(Command::SET_LAYER_VISIBLE_REGION, length);
- // When there are too many rectangles in the visible region and
- // doWrite is false, we write no rectangle at all which means the
- // entire layer is visible.
- if (doWrite) {
- writeRegion(visible);
- }
- endCommand();
+ void setLayerPerFrameMetadataBlobs(int64_t display, int64_t layer,
+ const std::vector<PerFrameMetadataBlob>& metadata) {
+ getLayerCommand(display, layer)
+ .perFrameMetadataBlob.emplace(metadata.begin(), metadata.end());
}
- static constexpr uint16_t kSetLayerZOrderLength = 1;
- void setLayerZOrder(uint32_t z) {
- beginCommand(Command::SET_LAYER_Z_ORDER, kSetLayerZOrderLength);
- write(z);
- endCommand();
+ void setLayerFloatColor(int64_t display, int64_t layer, FloatColor color) {
+ getLayerCommand(display, layer).floatColor.emplace(color);
}
- void setLayerPerFrameMetadata(const std::vector<PerFrameMetadata>& metadataVec) {
- beginCommand(Command::SET_LAYER_PER_FRAME_METADATA, metadataVec.size() * 2);
- for (const auto& metadata : metadataVec) {
- writeSigned(static_cast<int32_t>(metadata.key));
- writeFloat(metadata.value);
- }
- endCommand();
+ void setLayerGenericMetadata(int64_t display, int64_t layer, const std::string& key,
+ const bool mandatory, const std::vector<uint8_t>& value) {
+ GenericMetadata metadata;
+ metadata.key.name = key;
+ metadata.key.mandatory = mandatory;
+ metadata.value.assign(value.begin(), value.end());
+ getLayerCommand(display, layer).genericMetadata.emplace(std::move(metadata));
}
- static constexpr uint16_t kSetLayerColorTransformLength = 16;
- void setLayerColorTransform(const float* matrix) {
- beginCommand(Command::SET_LAYER_COLOR_TRANSFORM, kSetLayerColorTransformLength);
- for (int i = 0; i < 16; i++) {
- writeFloat(matrix[i]);
- }
- endCommand();
+ void setLayerWhitePointNits(int64_t display, int64_t layer, float whitePointNits) {
+ getLayerCommand(display, layer)
+ .whitePointNits.emplace(WhitePointNits{.nits = whitePointNits});
}
- void setLayerPerFrameMetadataBlobs(const std::vector<PerFrameMetadataBlob>& metadata) {
- // in units of uint32_t's
- size_t commandLength = 0;
-
- if (metadata.size() > std::numeric_limits<uint32_t>::max()) {
- LOG_FATAL("too many metadata blobs - dynamic metadata size is too large");
- return;
- }
-
- // space for numElements
- commandLength += 1;
-
- for (auto metadataBlob : metadata) {
- commandLength += 1; // key of metadata blob
- commandLength += 1; // size information of metadata blob
-
- // metadata content size
- size_t metadataSize = metadataBlob.blob.size() / sizeof(uint32_t);
- commandLength += metadataSize;
- commandLength +=
- (metadataBlob.blob.size() - (metadataSize * sizeof(uint32_t)) > 0) ? 1 : 0;
- }
-
- if (commandLength > std::numeric_limits<uint16_t>::max()) {
- LOG_FATAL("dynamic metadata size is too large");
- return;
- }
-
- // Blobs are written as:
- // {numElements, key1, size1, blob1, key2, size2, blob2, key3, size3...}
- uint16_t length = static_cast<uint16_t>(commandLength);
- beginCommand(Command::SET_LAYER_PER_FRAME_METADATA_BLOBS, length);
- write(static_cast<uint32_t>(metadata.size()));
- for (auto metadataBlob : metadata) {
- writeSigned(static_cast<int32_t>(metadataBlob.key));
- write(static_cast<uint32_t>(metadataBlob.blob.size()));
- writeBlob(static_cast<uint32_t>(metadataBlob.blob.size()), metadataBlob.blob.data());
- }
- endCommand();
+ const std::vector<DisplayCommand>& getPendingCommands() {
+ flushLayerCommand();
+ flushDisplayCommand();
+ return mCommands;
}
- static constexpr uint16_t kSetLayerFloatColorLength = 4;
- void setLayerFloatColor(FloatColor color) {
- beginCommand(Command::SET_LAYER_FLOAT_COLOR, kSetLayerFloatColorLength);
- writeFloatColor(color);
- endCommand();
- }
-
- static constexpr uint16_t kSetClientTargetPropertyLength = 2;
- void setClientTargetProperty(const ClientTargetProperty& clientTargetProperty) {
- beginCommand(Command::SET_CLIENT_TARGET_PROPERTY, kSetClientTargetPropertyLength);
- writeSigned(static_cast<int32_t>(clientTargetProperty.pixelFormat));
- writeSigned(static_cast<int32_t>(clientTargetProperty.dataspace));
- endCommand();
- }
-
- void setLayerGenericMetadata(const std::string& key, const bool mandatory,
- const std::vector<uint8_t>& value) {
- const size_t commandSize = 3 + sizeToElements(key.size()) + sizeToElements(value.size());
- if (commandSize > std::numeric_limits<uint16_t>::max()) {
- LOG_FATAL("Too much generic metadata (%zu elements)", commandSize);
- return;
- }
-
- beginCommand(Command::SET_LAYER_GENERIC_METADATA, static_cast<uint16_t>(commandSize));
- write(key.size());
- writeBlob(key.size(), reinterpret_cast<const unsigned char*>(key.c_str()));
- write(mandatory);
- write(value.size());
- writeBlob(value.size(), value.data());
- endCommand();
+ std::vector<CommandResultPayload> getPendingCommandResults() {
+ return std::move(mCommandsResults);
}
protected:
- template <typename T>
- void beginCommand(T command, uint16_t length) {
- beginCommandBase(static_cast<Command>(command), length);
+ Buffer getBuffer(int slot, const native_handle_t* bufferHandle, int fence) {
+ Buffer bufferCommand;
+ bufferCommand.slot = slot;
+ if (bufferHandle) bufferCommand.handle.emplace(::android::dupToAidl(bufferHandle));
+ if (fence > 0) bufferCommand.fence = ::ndk::ScopedFileDescriptor(fence);
+ return bufferCommand;
}
- void setClientTargetInternal(uint32_t slot, const native_handle_t* target, int acquireFence,
- int32_t dataspace, const std::vector<Rect>& damage) {
- bool doWrite = (damage.size() <= (kMaxLength - 4) / 4);
- size_t length = 4 + ((doWrite) ? damage.size() * 4 : 0);
-
- beginCommand(Command::SET_CLIENT_TARGET, length);
- write(slot);
- writeHandle(target, true);
- writeFence(acquireFence);
- writeSigned(dataspace);
- // When there are too many rectangles in the damage region and doWrite
- // is false, we write no rectangle at all which means the entire
- // client target is damaged.
- if (doWrite) {
- writeRegion(damage);
- }
- endCommand();
- }
-
- void setLayerDataspaceInternal(int32_t dataspace) {
- beginCommand(Command::SET_LAYER_DATASPACE, kSetLayerDataspaceLength);
- writeSigned(dataspace);
- endCommand();
- }
-
- void beginCommandBase(Command command, uint16_t length) {
- if (mCommandEnd) {
- LOG_FATAL("endCommand was not called before command 0x%x", command);
- }
-
- growData(1 + length);
- write(static_cast<uint32_t>(command) | length);
-
- mCommandEnd = mDataWritten + length;
- }
-
- void endCommand() {
- if (!mCommandEnd) {
- LOG_FATAL("beginCommand was not called");
- } else if (mDataWritten > mCommandEnd) {
- LOG_FATAL("too much data written");
- mDataWritten = mCommandEnd;
- } else if (mDataWritten < mCommandEnd) {
- LOG_FATAL("too little data written");
- while (mDataWritten < mCommandEnd) {
- write(0);
- }
- }
-
- mCommandEnd = 0;
- }
-
- void write(uint32_t val) { mData[mDataWritten++] = val; }
-
- void writeSigned(int32_t val) { memcpy(&mData[mDataWritten++], &val, sizeof(val)); }
-
- void writeFloat(float val) { memcpy(&mData[mDataWritten++], &val, sizeof(val)); }
-
- void write64(uint64_t val) {
- uint32_t lo = static_cast<uint32_t>(val & 0xffffffff);
- uint32_t hi = static_cast<uint32_t>(val >> 32);
- write(lo);
- write(hi);
- }
-
- void writeRect(const Rect& rect) {
- writeSigned(rect.left);
- writeSigned(rect.top);
- writeSigned(rect.right);
- writeSigned(rect.bottom);
- }
-
- void writeRegion(const std::vector<Rect>& region) {
- for (const auto& rect : region) {
- writeRect(rect);
- }
- }
-
- void writeFRect(const FRect& rect) {
- writeFloat(rect.left);
- writeFloat(rect.top);
- writeFloat(rect.right);
- writeFloat(rect.bottom);
- }
-
- void writeColor(const Color& color) {
- write((color.r << 0) | (color.g << 8) | (color.b << 16) | (color.a << 24));
- }
-
- void writeFloatColor(const FloatColor& color) {
- writeFloat(color.r);
- writeFloat(color.g);
- writeFloat(color.b);
- writeFloat(color.a);
- }
-
- void writeBlob(uint32_t length, const unsigned char* blob) {
- memcpy(&mData[mDataWritten], blob, length);
- uint32_t numElements = length / 4;
- mDataWritten += numElements;
- mDataWritten += (length - (numElements * 4) > 0) ? 1 : 0;
- }
-
- // ownership of handle is not transferred
- void writeHandle(const native_handle_t* handle, bool useCache) {
- if (!handle) {
- writeSigned(
- static_cast<int32_t>((useCache) ? HandleIndex::CACHED : HandleIndex::EMPTY));
- return;
- }
-
- mDataHandles.push_back(::android::dupToAidl(handle));
- writeSigned(mDataHandles.size() - 1);
- }
-
- void writeHandle(const native_handle_t* handle) { writeHandle(handle, false); }
-
- // ownership of fence is transferred
- void writeFence(int fence) {
- native_handle_t* handle = nullptr;
- if (fence >= 0) {
- handle = getTemporaryHandle(1, 0);
- if (handle) {
- handle->data[0] = fence;
- } else {
- ALOGW("failed to get temporary handle for fence %d", fence);
- sync_wait(fence, -1);
- close(fence);
- }
- }
-
- writeHandle(handle);
- }
-
- native_handle_t* getTemporaryHandle(int numFds, int numInts) {
- native_handle_t* handle = native_handle_create(numFds, numInts);
- if (handle) {
- mTemporaryHandles.push_back(handle);
- }
- return handle;
- }
-
- static constexpr uint16_t kMaxLength = std::numeric_limits<uint16_t>::max();
-
- std::unique_ptr<int32_t[]> mData;
- uint32_t mDataWritten;
+ std::optional<DisplayCommand> mDisplayCommand;
+ std::optional<LayerCommand> mLayerCommand;
+ std::vector<DisplayCommand> mCommands;
+ std::vector<CommandResultPayload> mCommandsResults;
private:
- void growData(uint32_t grow) {
- uint32_t newWritten = mDataWritten + grow;
- if (newWritten < mDataWritten) {
- LOG_ALWAYS_FATAL("buffer overflowed; data written %" PRIu32 ", growing by %" PRIu32,
- mDataWritten, grow);
+ void flushLayerCommand() {
+ if (mLayerCommand.has_value()) {
+ mDisplayCommand->layers.emplace_back(std::move(*mLayerCommand));
+ mLayerCommand.reset();
}
-
- if (newWritten <= mDataMaxSize) {
- return;
- }
-
- uint32_t newMaxSize = mDataMaxSize << 1;
- if (newMaxSize < newWritten) {
- newMaxSize = newWritten;
- }
-
- auto newData = std::make_unique<int32_t[]>(newMaxSize);
- std::copy_n(mData.get(), mDataWritten, newData.get());
- mDataMaxSize = newMaxSize;
- mData = std::move(newData);
}
- uint32_t sizeToElements(uint32_t size) { return (size + 3) / 4; }
+ void flushDisplayCommand() {
+ if (mDisplayCommand.has_value()) {
+ mCommands.emplace_back(std::move(*mDisplayCommand));
+ mDisplayCommand.reset();
+ }
+ }
- uint32_t mDataMaxSize;
- // end offset of the current command
- uint32_t mCommandEnd;
+ DisplayCommand& getDisplayCommand(int64_t display) {
+ if (!mDisplayCommand.has_value() || mDisplayCommand->display != display) {
+ flushLayerCommand();
+ flushDisplayCommand();
+ mDisplayCommand.emplace();
+ mDisplayCommand->display = display;
+ }
+ return *mDisplayCommand;
+ }
- std::vector<NativeHandle> mDataHandles;
- std::vector<native_handle_t*> mTemporaryHandles;
-
- std::unique_ptr<CommandQueueType> mQueue;
+ LayerCommand& getLayerCommand(int64_t display, int64_t layer) {
+ getDisplayCommand(display);
+ if (!mLayerCommand.has_value() || mLayerCommand->layer != layer) {
+ flushLayerCommand();
+ mLayerCommand.emplace();
+ mLayerCommand->layer = layer;
+ }
+ return *mLayerCommand;
+ }
};
-// This class helps parse a command queue. Note that all sizes/lengths are in
-// units of uint32_t's.
class CommandReaderBase {
public:
- CommandReaderBase() : mDataMaxSize(0) { reset(); }
+ ~CommandReaderBase() { resetData(); }
- bool setMQDescriptor(const DescriptorType& descriptor) {
- mQueue = std::make_unique<CommandQueueType>(descriptor, false);
- if (mQueue->isValid()) {
- return true;
- } else {
- mQueue = nullptr;
- return false;
+ // Parse and execute commands from the command queue. The commands are
+ // actually return values from the server and will be saved in ReturnData.
+ void parse(const std::vector<CommandResultPayload>& results) {
+ resetData();
+
+ for (const auto& result : results) {
+ switch (result.getTag()) {
+ case CommandResultPayload::Tag::error:
+ parseSetError(result.get<CommandResultPayload::Tag::error>());
+ break;
+ case CommandResultPayload::Tag::changedCompositionTypes:
+ parseSetChangedCompositionTypes(
+ result.get<CommandResultPayload::Tag::changedCompositionTypes>());
+ break;
+ case CommandResultPayload::Tag::displayRequest:
+ parseSetDisplayRequests(
+ result.get<CommandResultPayload::Tag::displayRequest>());
+ break;
+ case CommandResultPayload::Tag::presentFence:
+ parseSetPresentFence(result.get<CommandResultPayload::Tag::presentFence>());
+ break;
+ case CommandResultPayload::Tag::releaseFences:
+ parseSetReleaseFences(result.get<CommandResultPayload::Tag::releaseFences>());
+ break;
+ case CommandResultPayload::Tag::presentOrValidateResult:
+ parseSetPresentOrValidateDisplayResult(
+ result.get<CommandResultPayload::Tag::presentOrValidateResult>());
+ break;
+ case CommandResultPayload::Tag::clientTargetProperty:
+ parseSetClientTargetProperty(
+ result.get<CommandResultPayload::Tag::clientTargetProperty>());
+ break;
+ }
}
}
- bool readQueue(int32_t commandLength, std::vector<NativeHandle> commandHandles) {
- if (!mQueue) {
+ std::vector<CommandError> takeErrors() { return std::move(mErrors); }
+
+ bool hasChanges(int64_t display, uint32_t* outNumChangedCompositionTypes,
+ uint32_t* outNumLayerRequestMasks) const {
+ auto found = mReturnData.find(display);
+ if (found == mReturnData.end()) {
+ *outNumChangedCompositionTypes = 0;
+ *outNumLayerRequestMasks = 0;
return false;
}
- auto quantumCount = mQueue->getQuantumCount();
- if (mDataMaxSize < quantumCount) {
- mDataMaxSize = quantumCount;
- mData = std::make_unique<int32_t[]>(mDataMaxSize);
+ const ReturnData& data = found->second;
+
+ *outNumChangedCompositionTypes = static_cast<uint32_t>(data.compositionTypes.size());
+ *outNumLayerRequestMasks = static_cast<uint32_t>(data.requestMasks.size());
+
+ return !(data.compositionTypes.empty() && data.requestMasks.empty());
+ }
+
+ // Get and clear saved changed composition types.
+ void takeChangedCompositionTypes(int64_t display, std::vector<int64_t>* outLayers,
+ std::vector<Composition>* outTypes) {
+ auto found = mReturnData.find(display);
+ if (found == mReturnData.end()) {
+ outLayers->clear();
+ outTypes->clear();
+ return;
}
- if (commandLength > mDataMaxSize || !mQueue->read(mData.get(), commandLength)) {
- ALOGE("failed to read commands from message queue");
- return false;
+ ReturnData& data = found->second;
+
+ *outLayers = std::move(data.changedLayers);
+ *outTypes = std::move(data.compositionTypes);
+ }
+
+ // Get and clear saved display requests.
+ void takeDisplayRequests(int64_t display, uint32_t* outDisplayRequestMask,
+ std::vector<int64_t>* outLayers,
+ std::vector<uint32_t>* outLayerRequestMasks) {
+ auto found = mReturnData.find(display);
+ if (found == mReturnData.end()) {
+ *outDisplayRequestMask = 0;
+ outLayers->clear();
+ outLayerRequestMasks->clear();
+ return;
}
- mDataSize = commandLength;
- mDataRead = 0;
- mCommandBegin = 0;
- mCommandEnd = 0;
- mDataHandles = std::move(commandHandles);
- return true;
+ ReturnData& data = found->second;
+
+ *outDisplayRequestMask = data.displayRequests;
+ *outLayers = std::move(data.requestedLayers);
+ *outLayerRequestMasks = std::move(data.requestMasks);
}
- void reset() {
- mDataSize = 0;
- mDataRead = 0;
- mCommandBegin = 0;
- mCommandEnd = 0;
- mDataHandles.clear();
- }
-
- protected:
- template <typename T>
- bool beginCommand(T* outCommand, uint16_t* outLength) {
- return beginCommandBase(reinterpret_cast<Command*>(outCommand), outLength);
- }
-
- bool isEmpty() const { return (mDataRead >= mDataSize); }
-
- bool beginCommandBase(Command* outCommand, uint16_t* outLength) {
- if (mCommandEnd) {
- LOG_FATAL("endCommand was not called for last command");
+ // Get and clear saved release fences.
+ void takeReleaseFences(int64_t display, std::vector<int64_t>* outLayers,
+ std::vector<int>* outReleaseFences) {
+ auto found = mReturnData.find(display);
+ if (found == mReturnData.end()) {
+ outLayers->clear();
+ outReleaseFences->clear();
+ return;
}
- constexpr uint32_t opcode_mask = static_cast<uint32_t>(Command::OPCODE_MASK);
- constexpr uint32_t length_mask = static_cast<uint32_t>(Command::LENGTH_MASK);
+ ReturnData& data = found->second;
- uint32_t val = read();
- *outCommand = static_cast<Command>(val & opcode_mask);
- *outLength = static_cast<uint16_t>(val & length_mask);
+ *outLayers = std::move(data.releasedLayers);
+ *outReleaseFences = std::move(data.releaseFences);
+ }
- if (mDataRead + *outLength > mDataSize) {
- ALOGE("command 0x%x has invalid command length %" PRIu16, *outCommand, *outLength);
- // undo the read() above
- mDataRead--;
- return false;
+ // Get and clear saved present fence.
+ void takePresentFence(int64_t display, int* outPresentFence) {
+ auto found = mReturnData.find(display);
+ if (found == mReturnData.end()) {
+ *outPresentFence = -1;
+ return;
}
- mCommandEnd = mDataRead + *outLength;
+ ReturnData& data = found->second;
- return true;
+ *outPresentFence = data.presentFence;
+ data.presentFence = -1;
}
- void endCommand() {
- if (!mCommandEnd) {
- LOG_FATAL("beginCommand was not called");
- } else if (mDataRead > mCommandEnd) {
- LOG_FATAL("too much data read");
- mDataRead = mCommandEnd;
- } else if (mDataRead < mCommandEnd) {
- LOG_FATAL("too little data read");
- mDataRead = mCommandEnd;
+ // Get what stage succeeded during PresentOrValidate: Present or Validate
+ void takePresentOrValidateStage(int64_t display, uint32_t* state) {
+ auto found = mReturnData.find(display);
+ if (found == mReturnData.end()) {
+ *state = static_cast<uint32_t>(-1);
+ return;
+ }
+ ReturnData& data = found->second;
+ *state = data.presentOrValidateState;
+ }
+
+ // Get the client target properties requested by hardware composer.
+ void takeClientTargetProperty(int64_t display, ClientTargetProperty* outClientTargetProperty,
+ float* outWhitePointNits) {
+ auto found = mReturnData.find(display);
+
+ // If not found, return the default values.
+ if (found == mReturnData.end()) {
+ outClientTargetProperty->pixelFormat = common::PixelFormat::RGBA_8888;
+ outClientTargetProperty->dataspace = Dataspace::UNKNOWN;
+ *outWhitePointNits = -1.f;
+ return;
}
- mCommandBegin = mCommandEnd;
- mCommandEnd = 0;
+ ReturnData& data = found->second;
+ *outClientTargetProperty = data.clientTargetProperty;
+ *outWhitePointNits = data.clientTargetWhitePointNits;
}
- uint32_t getCommandLoc() const { return mCommandBegin; }
-
- uint32_t read() { return mData[mDataRead++]; }
-
- int32_t readSigned() {
- int32_t val;
- memcpy(&val, &mData[mDataRead++], sizeof(val));
- return val;
- }
-
- float readFloat() {
- float val;
- memcpy(&val, &mData[mDataRead++], sizeof(val));
- return val;
- }
-
- uint64_t read64() {
- uint32_t lo = read();
- uint32_t hi = read();
- return (static_cast<uint64_t>(hi) << 32) | lo;
- }
-
- Color readColor() {
- uint32_t val = read();
- return Color{
- static_cast<int8_t>((val >> 0) & 0xff),
- static_cast<int8_t>((val >> 8) & 0xff),
- static_cast<int8_t>((val >> 16) & 0xff),
- static_cast<int8_t>((val >> 24) & 0xff),
- };
- }
-
- // ownership of handle is not transferred
- const native_handle_t* readHandle(bool* outUseCache) {
- const native_handle_t* handle = nullptr;
-
- int32_t index = readSigned();
- switch (index) {
- case static_cast<int32_t>(HandleIndex::EMPTY):
- *outUseCache = false;
- break;
- case static_cast<int32_t>(HandleIndex::CACHED):
- *outUseCache = true;
- break;
- default:
- if (static_cast<size_t>(index) < mDataHandles.size()) {
- handle = ::android::makeFromAidl(mDataHandles[index]);
- } else {
- ALOGE("invalid handle index %zu", static_cast<size_t>(index));
- }
- *outUseCache = false;
- break;
- }
-
- return handle;
- }
-
- const native_handle_t* readHandle() {
- bool useCache;
- return readHandle(&useCache);
- }
-
- // ownership of fence is transferred
- int readFence() {
- auto handle = readHandle();
- if (!handle || handle->numFds == 0) {
- return -1;
- }
-
- if (handle->numFds != 1) {
- ALOGE("invalid fence handle with %d fds", handle->numFds);
- return -1;
- }
-
- int fd = dup(handle->data[0]);
- if (fd < 0) {
- ALOGW("failed to dup fence %d", handle->data[0]);
- sync_wait(handle->data[0], -1);
- fd = -1;
- }
-
- return fd;
- }
-
- std::unique_ptr<int32_t[]> mData;
- uint32_t mDataRead;
-
private:
- std::unique_ptr<CommandQueueType> mQueue;
- uint32_t mDataMaxSize;
+ void resetData() {
+ mErrors.clear();
- uint32_t mDataSize;
+ for (auto& data : mReturnData) {
+ if (data.second.presentFence >= 0) {
+ close(data.second.presentFence);
+ }
+ for (auto fence : data.second.releaseFences) {
+ if (fence >= 0) {
+ close(fence);
+ }
+ }
+ }
- // begin/end offsets of the current command
- uint32_t mCommandBegin;
- uint32_t mCommandEnd;
+ mReturnData.clear();
+ }
- std::vector<NativeHandle> mDataHandles;
+ void parseSetError(const CommandError& error) { mErrors.emplace_back(error); }
+
+ void parseSetChangedCompositionTypes(const ChangedCompositionTypes& changedCompositionTypes) {
+ auto& data = mReturnData[changedCompositionTypes.display];
+
+ data.changedLayers.reserve(changedCompositionTypes.layers.size());
+ data.compositionTypes.reserve(changedCompositionTypes.layers.size());
+ for (const auto& layer : changedCompositionTypes.layers) {
+ data.changedLayers.push_back(layer.layer);
+ data.compositionTypes.push_back(layer.composition);
+ }
+ }
+
+ void parseSetDisplayRequests(const DisplayRequest& displayRequest) {
+ auto& data = mReturnData[displayRequest.display];
+
+ data.displayRequests = displayRequest.mask;
+ data.requestedLayers.reserve(displayRequest.layerRequests.size());
+ data.requestMasks.reserve(displayRequest.layerRequests.size());
+ for (const auto& layerRequest : displayRequest.layerRequests) {
+ data.requestedLayers.push_back(layerRequest.layer);
+ data.requestMasks.push_back(layerRequest.mask);
+ }
+ }
+
+ void parseSetPresentFence(const PresentFence& presentFence) {
+ auto& data = mReturnData[presentFence.display];
+ if (data.presentFence >= 0) {
+ close(data.presentFence);
+ }
+ data.presentFence = dup(presentFence.fence.get());
+ }
+
+ void parseSetReleaseFences(const ReleaseFences& releaseFences) {
+ auto& data = mReturnData[releaseFences.display];
+ data.releasedLayers.reserve(releaseFences.layers.size());
+ data.releaseFences.reserve(releaseFences.layers.size());
+ for (const auto& layer : releaseFences.layers) {
+ data.releasedLayers.push_back(layer.layer);
+ data.releaseFences.push_back(dup(layer.fence.get()));
+ }
+ }
+
+ void parseSetPresentOrValidateDisplayResult(const PresentOrValidate& presentOrValidate) {
+ auto& data = mReturnData[presentOrValidate.display];
+ data.presentOrValidateState =
+ presentOrValidate.result == PresentOrValidate::Result::Presented ? 1 : 0;
+ }
+
+ void parseSetClientTargetProperty(const ClientTargetPropertyWithNits& clientTargetProperty) {
+ auto& data = mReturnData[clientTargetProperty.display];
+ data.clientTargetProperty.pixelFormat =
+ clientTargetProperty.clientTargetProperty.pixelFormat;
+ data.clientTargetProperty.dataspace = clientTargetProperty.clientTargetProperty.dataspace;
+ data.clientTargetWhitePointNits = clientTargetProperty.whitePointNits;
+ }
+
+ struct ReturnData {
+ int32_t displayRequests = 0;
+
+ std::vector<int64_t> changedLayers;
+ std::vector<Composition> compositionTypes;
+
+ std::vector<int64_t> requestedLayers;
+ std::vector<uint32_t> requestMasks;
+
+ int presentFence = -1;
+
+ std::vector<int64_t> releasedLayers;
+ std::vector<int> releaseFences;
+
+ uint32_t presentOrValidateState;
+
+ ClientTargetProperty clientTargetProperty{common::PixelFormat::RGBA_8888,
+ Dataspace::UNKNOWN};
+ float clientTargetWhitePointNits = -1.f;
+ };
+
+ std::vector<CommandError> mErrors;
+ std::unordered_map<int64_t, ReturnData> mReturnData;
};
} // namespace aidl::android::hardware::graphics::composer3
diff --git a/graphics/composer/aidl/include/android/hardware/graphics/composer3/translate-ndk.h b/graphics/composer/aidl/include/android/hardware/graphics/composer3/translate-ndk.h
index c892863..7004955 100644
--- a/graphics/composer/aidl/include/android/hardware/graphics/composer3/translate-ndk.h
+++ b/graphics/composer/aidl/include/android/hardware/graphics/composer3/translate-ndk.h
@@ -17,25 +17,22 @@
#pragma once
#include <limits>
+#include "aidl/android/hardware/graphics/common/BlendMode.h"
#include "aidl/android/hardware/graphics/common/FRect.h"
#include "aidl/android/hardware/graphics/common/Rect.h"
-#include "aidl/android/hardware/graphics/composer3/BlendMode.h"
#include "aidl/android/hardware/graphics/composer3/Capability.h"
#include "aidl/android/hardware/graphics/composer3/ClientTargetProperty.h"
#include "aidl/android/hardware/graphics/composer3/Color.h"
-#include "aidl/android/hardware/graphics/composer3/Command.h"
#include "aidl/android/hardware/graphics/composer3/Composition.h"
#include "aidl/android/hardware/graphics/composer3/ContentType.h"
#include "aidl/android/hardware/graphics/composer3/DisplayAttribute.h"
#include "aidl/android/hardware/graphics/composer3/DisplayCapability.h"
#include "aidl/android/hardware/graphics/composer3/DisplayConnectionType.h"
-#include "aidl/android/hardware/graphics/composer3/DisplayRequest.h"
#include "aidl/android/hardware/graphics/composer3/FloatColor.h"
#include "aidl/android/hardware/graphics/composer3/FormatColorComponent.h"
#include "aidl/android/hardware/graphics/composer3/HandleIndex.h"
#include "aidl/android/hardware/graphics/composer3/IComposer.h"
#include "aidl/android/hardware/graphics/composer3/LayerGenericMetadataKey.h"
-#include "aidl/android/hardware/graphics/composer3/LayerRequest.h"
#include "aidl/android/hardware/graphics/composer3/PerFrameMetadata.h"
#include "aidl/android/hardware/graphics/composer3/PerFrameMetadataBlob.h"
#include "aidl/android/hardware/graphics/composer3/PerFrameMetadataKey.h"
diff --git a/health/aidl/Android.bp b/health/aidl/Android.bp
index fae7592..6e2f1d4 100644
--- a/health/aidl/Android.bp
+++ b/health/aidl/Android.bp
@@ -25,6 +25,7 @@
name: "android.hardware.health",
vendor_available: true,
recovery_available: true,
+ host_supported: true,
srcs: ["android/hardware/health/*.aidl"],
stability: "vintf",
backend: {
@@ -48,6 +49,7 @@
name: "android.hardware.health-translate-ndk",
vendor_available: true,
recovery_available: true,
+ host_supported: true,
srcs: ["android/hardware/health/translate-ndk.cpp"],
shared_libs: [
"libbinder_ndk",
@@ -61,6 +63,9 @@
"android.hardware.health@2.0",
"android.hardware.health@2.1",
],
+ defaults: [
+ "libbinder_ndk_host_user",
+ ],
}
java_library {
diff --git a/health/aidl/README.md b/health/aidl/README.md
index 0d7c4c9..a64fe93 100644
--- a/health/aidl/README.md
+++ b/health/aidl/README.md
@@ -63,8 +63,7 @@
* You may ignore the `service` line. The name of the service does not matter.
* If your service belongs to additional classes beside `charger`, you need a
custom health AIDL service.
-* You may ignore the `seclabel` line. When the health AIDL service runs in
- charger mode, its original SELinux domain is kept.
+* Modify the `seclabel` line. Replace `charger` with `charger_vendor`.
* If your service has a different `user` (not `system`), you need a custom
health AIDL service.
* If your service belongs to additional `group`s beside
@@ -240,6 +239,8 @@
```text
service vendor.charger-tuna /vendor/bin/hw/android.hardware.health-service-tuna --charger
+ class charger
+ seclabel u:r:charger_vendor:s0
# ...
```
@@ -315,6 +316,5 @@
`hal_health_tuna`:
```text
-type hal_health_tuna, charger_type, domain;
-hal_server_domain(hal_health_default, hal_health)
+domain_trans(init, hal_health_tuna_exec, charger_vendor)
```
diff --git a/health/aidl/android/hardware/health/translate-ndk.cpp b/health/aidl/android/hardware/health/translate-ndk.cpp
index 7fe6ced..78880cc 100644
--- a/health/aidl/android/hardware/health/translate-ndk.cpp
+++ b/health/aidl/android/hardware/health/translate-ndk.cpp
@@ -106,36 +106,41 @@
}
__attribute__((warn_unused_result)) bool translate(
+ const ::android::hardware::health::V2_0::HealthInfo& in,
+ aidl::android::hardware::health::HealthInfo* out) {
+ out->chargerAcOnline = static_cast<bool>(in.legacy.chargerAcOnline);
+ out->chargerUsbOnline = static_cast<bool>(in.legacy.chargerUsbOnline);
+ out->chargerWirelessOnline = static_cast<bool>(in.legacy.chargerWirelessOnline);
+ out->maxChargingCurrentMicroamps = static_cast<int32_t>(in.legacy.maxChargingCurrent);
+ out->maxChargingVoltageMicrovolts = static_cast<int32_t>(in.legacy.maxChargingVoltage);
+ out->batteryStatus =
+ static_cast<aidl::android::hardware::health::BatteryStatus>(in.legacy.batteryStatus);
+ out->batteryHealth =
+ static_cast<aidl::android::hardware::health::BatteryHealth>(in.legacy.batteryHealth);
+ out->batteryPresent = static_cast<bool>(in.legacy.batteryPresent);
+ out->batteryLevel = static_cast<int32_t>(in.legacy.batteryLevel);
+ out->batteryVoltageMillivolts = static_cast<int32_t>(in.legacy.batteryVoltage);
+ out->batteryTemperatureTenthsCelsius = static_cast<int32_t>(in.legacy.batteryTemperature);
+ out->batteryCurrentMicroamps = static_cast<int32_t>(in.legacy.batteryCurrent);
+ out->batteryCycleCount = static_cast<int32_t>(in.legacy.batteryCycleCount);
+ out->batteryFullChargeUah = static_cast<int32_t>(in.legacy.batteryFullCharge);
+ out->batteryChargeCounterUah = static_cast<int32_t>(in.legacy.batteryChargeCounter);
+ out->batteryTechnology = in.legacy.batteryTechnology;
+ out->batteryCurrentAverageMicroamps = static_cast<int32_t>(in.batteryCurrentAverage);
+ out->diskStats.clear();
+ out->diskStats.resize(in.diskStats.size());
+ for (size_t i = 0; i < in.diskStats.size(); ++i)
+ if (!translate(in.diskStats[i], &out->diskStats[i])) return false;
+ out->storageInfos.clear();
+ out->storageInfos.resize(in.storageInfos.size());
+ for (size_t i = 0; i < in.storageInfos.size(); ++i)
+ if (!translate(in.storageInfos[i], &out->storageInfos[i])) return false;
+ return true;
+}
+__attribute__((warn_unused_result)) bool translate(
const ::android::hardware::health::V2_1::HealthInfo& in,
aidl::android::hardware::health::HealthInfo* out) {
- out->chargerAcOnline = static_cast<bool>(in.legacy.legacy.chargerAcOnline);
- out->chargerUsbOnline = static_cast<bool>(in.legacy.legacy.chargerUsbOnline);
- out->chargerWirelessOnline = static_cast<bool>(in.legacy.legacy.chargerWirelessOnline);
- out->maxChargingCurrentMicroamps = static_cast<int32_t>(in.legacy.legacy.maxChargingCurrent);
- out->maxChargingVoltageMicrovolts = static_cast<int32_t>(in.legacy.legacy.maxChargingVoltage);
- out->batteryStatus = static_cast<aidl::android::hardware::health::BatteryStatus>(
- in.legacy.legacy.batteryStatus);
- out->batteryHealth = static_cast<aidl::android::hardware::health::BatteryHealth>(
- in.legacy.legacy.batteryHealth);
- out->batteryPresent = static_cast<bool>(in.legacy.legacy.batteryPresent);
- out->batteryLevel = static_cast<int32_t>(in.legacy.legacy.batteryLevel);
- out->batteryVoltageMillivolts = static_cast<int32_t>(in.legacy.legacy.batteryVoltage);
- out->batteryTemperatureTenthsCelsius =
- static_cast<int32_t>(in.legacy.legacy.batteryTemperature);
- out->batteryCurrentMicroamps = static_cast<int32_t>(in.legacy.legacy.batteryCurrent);
- out->batteryCycleCount = static_cast<int32_t>(in.legacy.legacy.batteryCycleCount);
- out->batteryFullChargeUah = static_cast<int32_t>(in.legacy.legacy.batteryFullCharge);
- out->batteryChargeCounterUah = static_cast<int32_t>(in.legacy.legacy.batteryChargeCounter);
- out->batteryTechnology = in.legacy.legacy.batteryTechnology;
- out->batteryCurrentAverageMicroamps = static_cast<int32_t>(in.legacy.batteryCurrentAverage);
- out->diskStats.clear();
- out->diskStats.resize(in.legacy.diskStats.size());
- for (size_t i = 0; i < in.legacy.diskStats.size(); ++i)
- if (!translate(in.legacy.diskStats[i], &out->diskStats[i])) return false;
- out->storageInfos.clear();
- out->storageInfos.resize(in.legacy.storageInfos.size());
- for (size_t i = 0; i < in.legacy.storageInfos.size(); ++i)
- if (!translate(in.legacy.storageInfos[i], &out->storageInfos[i])) return false;
+ if (!translate(in.legacy, out)) return false;
out->batteryCapacityLevel = static_cast<aidl::android::hardware::health::BatteryCapacityLevel>(
in.batteryCapacityLevel);
out->batteryChargeTimeToFullNowSeconds =
diff --git a/health/aidl/default/android.hardware.health-service.example.rc b/health/aidl/default/android.hardware.health-service.example.rc
index dee3d11..4258890 100644
--- a/health/aidl/default/android.hardware.health-service.example.rc
+++ b/health/aidl/default/android.hardware.health-service.example.rc
@@ -7,6 +7,7 @@
service vendor.charger-default /vendor/bin/hw/android.hardware.health-service.example --charger
class charger
+ seclabel u:r:charger_vendor:s0
user system
group system wakelock input
capabilities SYS_BOOT
diff --git a/health/aidl/include/android/hardware/health/translate-ndk.h b/health/aidl/include/android/hardware/health/translate-ndk.h
index 2f8fe04..91add42 100644
--- a/health/aidl/include/android/hardware/health/translate-ndk.h
+++ b/health/aidl/include/android/hardware/health/translate-ndk.h
@@ -33,6 +33,9 @@
const ::android::hardware::health::V2_0::DiskStats& in,
aidl::android::hardware::health::DiskStats* out);
__attribute__((warn_unused_result)) bool translate(
+ const ::android::hardware::health::V2_0::HealthInfo& in,
+ aidl::android::hardware::health::HealthInfo* out);
+__attribute__((warn_unused_result)) bool translate(
const ::android::hardware::health::V2_1::HealthInfo& in,
aidl::android::hardware::health::HealthInfo* out);
diff --git a/health/utils/libhealthshim/Android.bp b/health/utils/libhealthshim/Android.bp
new file mode 100644
index 0000000..311e951
--- /dev/null
+++ b/health/utils/libhealthshim/Android.bp
@@ -0,0 +1,78 @@
+// Copyright (C) 2021 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 {
+ // See: http://go/android-license-faq
+ // A large-scale-change added 'default_applicable_licenses' to import
+ // all of the 'license_kinds' from "hardware_interfaces_license"
+ // to get the below license kinds:
+ // SPDX-license-identifier-Apache-2.0
+ default_applicable_licenses: ["hardware_interfaces_license"],
+}
+
+cc_defaults {
+ name: "libhealthshim_defaults",
+ host_supported: true, // for testing
+ defaults: [
+ "libbinder_ndk_host_user",
+ ],
+ cflags: [
+ "-Wall",
+ "-Werror",
+ ],
+ static_libs: [
+ "android.hardware.health-V1-ndk",
+ "android.hardware.health-translate-ndk",
+ "android.hardware.health@1.0",
+ "android.hardware.health@2.0",
+ ],
+ shared_libs: [
+ // These can be expected from the device or from host.
+ "libbase",
+ "libbinder_ndk",
+ "libcutils",
+ "libhidlbase",
+ "liblog",
+ "libutils",
+ ],
+}
+
+// Shim library that wraps a HIDL IHealth object into an AIDL IHealth object.
+cc_library_static {
+ name: "libhealthshim",
+ defaults: ["libhealthshim_defaults"],
+ recovery_available: true,
+ srcs: [
+ "shim.cpp",
+ ],
+ export_include_dirs: [
+ "include",
+ ],
+}
+
+cc_test {
+ name: "libhealthshim_test",
+ defaults: ["libhealthshim_defaults"],
+ static_libs: [
+ "libhealthshim",
+ "libgmock",
+ ],
+ srcs: [
+ "test.cpp",
+ ],
+ test_suites: ["general-tests"],
+ test_options: {
+ unit_test: true,
+ },
+}
diff --git a/health/utils/libhealthshim/include/health-shim/shim.h b/health/utils/libhealthshim/include/health-shim/shim.h
new file mode 100644
index 0000000..f36fa5d
--- /dev/null
+++ b/health/utils/libhealthshim/include/health-shim/shim.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2021 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 <map>
+
+#include <aidl/android/hardware/health/BnHealth.h>
+#include <android/hardware/health/2.0/IHealth.h>
+
+namespace aidl::android::hardware::health {
+
+// Shim that wraps HIDL IHealth with an AIDL BnHealth.
+// The wrapper always have isRemote() == false because it is BnHealth.
+class HealthShim : public BnHealth {
+ using HidlHealth = ::android::hardware::health::V2_0::IHealth;
+ using HidlHealthInfoCallback = ::android::hardware::health::V2_0::IHealthInfoCallback;
+
+ public:
+ explicit HealthShim(const ::android::sp<HidlHealth>& service);
+
+ ndk::ScopedAStatus registerCallback(
+ const std::shared_ptr<IHealthInfoCallback>& in_callback) override;
+ ndk::ScopedAStatus unregisterCallback(
+ const std::shared_ptr<IHealthInfoCallback>& in_callback) override;
+ ndk::ScopedAStatus update() override;
+ ndk::ScopedAStatus getChargeCounterUah(int32_t* _aidl_return) override;
+ ndk::ScopedAStatus getCurrentNowMicroamps(int32_t* _aidl_return) override;
+ ndk::ScopedAStatus getCurrentAverageMicroamps(int32_t* _aidl_return) override;
+ ndk::ScopedAStatus getCapacity(int32_t* _aidl_return) override;
+ ndk::ScopedAStatus getEnergyCounterNwh(int64_t* _aidl_return) override;
+ ndk::ScopedAStatus getChargeStatus(BatteryStatus* _aidl_return) override;
+ ndk::ScopedAStatus getStorageInfo(std::vector<StorageInfo>* _aidl_return) override;
+ ndk::ScopedAStatus getDiskStats(std::vector<DiskStats>* _aidl_return) override;
+ ndk::ScopedAStatus getHealthInfo(HealthInfo* _aidl_return) override;
+
+ private:
+ ::android::sp<HidlHealth> service_;
+ std::map<std::shared_ptr<IHealthInfoCallback>, ::android::sp<HidlHealthInfoCallback>>
+ callback_map_;
+};
+
+} // namespace aidl::android::hardware::health
diff --git a/health/utils/libhealthshim/shim.cpp b/health/utils/libhealthshim/shim.cpp
new file mode 100644
index 0000000..1329679
--- /dev/null
+++ b/health/utils/libhealthshim/shim.cpp
@@ -0,0 +1,220 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <android-base/logging.h>
+#include <android/hardware/health/translate-ndk.h>
+#include <health-shim/shim.h>
+
+using ::android::sp;
+using ::android::h2a::translate;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+using ::android::hardware::health::V2_0::Result;
+using ::android::hardware::health::V2_0::toString;
+using ::ndk::ScopedAStatus;
+using HidlHealth = ::android::hardware::health::V2_0::IHealth;
+using HidlHealthInfoCallback = ::android::hardware::health::V2_0::IHealthInfoCallback;
+using HidlHealthInfo = ::android::hardware::health::V2_0::HealthInfo;
+
+namespace aidl::android::hardware::health {
+
+namespace {
+
+class HealthInfoCallbackShim : public HidlHealthInfoCallback {
+ using AidlHealthInfoCallback = ::aidl::android::hardware::health::IHealthInfoCallback;
+ using AidlHealthInfo = ::aidl::android::hardware::health::HealthInfo;
+
+ public:
+ explicit HealthInfoCallbackShim(const std::shared_ptr<AidlHealthInfoCallback>& impl)
+ : impl_(impl) {}
+ Return<void> healthInfoChanged(const HidlHealthInfo& info) override {
+ AidlHealthInfo aidl_info;
+ // translate() should always return true.
+ CHECK(translate(info, &aidl_info));
+ // This is a oneway function, so we can't (and shouldn't) check for errors.
+ (void)impl_->healthInfoChanged(aidl_info);
+ return Void();
+ }
+
+ private:
+ std::shared_ptr<AidlHealthInfoCallback> impl_;
+};
+
+ScopedAStatus ResultToStatus(Result result) {
+ switch (result) {
+ case Result::SUCCESS:
+ return ScopedAStatus::ok();
+ case Result::NOT_SUPPORTED:
+ return ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
+ case Result::UNKNOWN:
+ return ScopedAStatus::fromServiceSpecificError(IHealth::STATUS_UNKNOWN);
+ case Result::NOT_FOUND:
+ return ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
+ case Result::CALLBACK_DIED:
+ return ScopedAStatus::fromServiceSpecificError(IHealth::STATUS_CALLBACK_DIED);
+ }
+ return ScopedAStatus::fromServiceSpecificErrorWithMessage(
+ IHealth::STATUS_UNKNOWN, ("Unrecognized result value " + toString(result)).c_str());
+}
+
+template <typename T>
+ScopedAStatus ReturnAndResultToStatus(const Return<T>& ret, Result result) {
+ if (ret.isOk()) {
+ return ResultToStatus(result);
+ }
+ if (ret.isDeadObject()) {
+ return ScopedAStatus::fromStatus(STATUS_DEAD_OBJECT);
+ }
+ return ScopedAStatus::fromServiceSpecificErrorWithMessage(IHealth::STATUS_UNKNOWN,
+ ret.description().c_str());
+}
+
+ScopedAStatus ReturnResultToStatus(const Return<Result>& return_result) {
+ return ReturnAndResultToStatus(return_result, return_result.isOk()
+ ? static_cast<Result>(return_result)
+ : Result::UNKNOWN);
+}
+
+} // namespace
+
+HealthShim::HealthShim(const sp<HidlHealth>& service) : service_(service) {}
+
+ScopedAStatus HealthShim::registerCallback(
+ const std::shared_ptr<IHealthInfoCallback>& in_callback) {
+ sp<HidlHealthInfoCallback> shim(new HealthInfoCallbackShim(in_callback));
+ callback_map_.emplace(in_callback, shim);
+ return ReturnResultToStatus(service_->registerCallback(shim));
+}
+
+ScopedAStatus HealthShim::unregisterCallback(
+ const std::shared_ptr<IHealthInfoCallback>& in_callback) {
+ auto it = callback_map_.find(in_callback);
+ if (it == callback_map_.end()) {
+ return ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
+ }
+ sp<HidlHealthInfoCallback> shim = it->second;
+ callback_map_.erase(it);
+ return ReturnResultToStatus(service_->unregisterCallback(shim));
+}
+
+ScopedAStatus HealthShim::update() {
+ return ReturnResultToStatus(service_->update());
+}
+
+ScopedAStatus HealthShim::getChargeCounterUah(int32_t* out) {
+ Result out_result = Result::UNKNOWN;
+ auto ret = service_->getChargeCounter([out, &out_result](auto result, auto value) {
+ out_result = result;
+ if (out_result != Result::SUCCESS) return;
+ *out = value;
+ });
+ return ReturnAndResultToStatus(ret, out_result);
+}
+
+ScopedAStatus HealthShim::getCurrentNowMicroamps(int32_t* out) {
+ Result out_result = Result::UNKNOWN;
+ auto ret = service_->getCurrentNow([out, &out_result](auto result, auto value) {
+ out_result = result;
+ if (out_result != Result::SUCCESS) return;
+ *out = value;
+ });
+ return ReturnAndResultToStatus(ret, out_result);
+}
+
+ScopedAStatus HealthShim::getCurrentAverageMicroamps(int32_t* out) {
+ Result out_result = Result::UNKNOWN;
+ auto ret = service_->getCurrentAverage([out, &out_result](auto result, auto value) {
+ out_result = result;
+ if (out_result != Result::SUCCESS) return;
+ *out = value;
+ });
+ return ReturnAndResultToStatus(ret, out_result);
+}
+
+ScopedAStatus HealthShim::getCapacity(int32_t* out) {
+ Result out_result = Result::UNKNOWN;
+ auto ret = service_->getCapacity([out, &out_result](auto result, auto value) {
+ out_result = result;
+ if (out_result != Result::SUCCESS) return;
+ *out = value;
+ });
+ return ReturnAndResultToStatus(ret, out_result);
+}
+
+ScopedAStatus HealthShim::getEnergyCounterNwh(int64_t* out) {
+ Result out_result = Result::UNKNOWN;
+ auto ret = service_->getEnergyCounter([out, &out_result](auto result, auto value) {
+ out_result = result;
+ if (out_result != Result::SUCCESS) return;
+ *out = value;
+ });
+ return ReturnAndResultToStatus(ret, out_result);
+}
+
+ScopedAStatus HealthShim::getChargeStatus(BatteryStatus* out) {
+ Result out_result = Result::UNKNOWN;
+ auto ret = service_->getChargeStatus([out, &out_result](auto result, auto value) {
+ out_result = result;
+ if (out_result != Result::SUCCESS) return;
+ *out = static_cast<BatteryStatus>(value);
+ });
+ return ReturnAndResultToStatus(ret, out_result);
+}
+
+ScopedAStatus HealthShim::getStorageInfo(std::vector<StorageInfo>* out) {
+ Result out_result = Result::UNKNOWN;
+ auto ret = service_->getStorageInfo([out, &out_result](auto result, const auto& value) {
+ out_result = result;
+ if (out_result != Result::SUCCESS) return;
+ out->clear();
+ out->reserve(value.size());
+ for (const auto& hidl_info : value) {
+ auto& aidl_info = out->emplace_back();
+ // translate() should always return true.
+ CHECK(translate(hidl_info, &aidl_info));
+ }
+ });
+ return ReturnAndResultToStatus(ret, out_result);
+}
+
+ScopedAStatus HealthShim::getDiskStats(std::vector<DiskStats>* out) {
+ Result out_result = Result::UNKNOWN;
+ auto ret = service_->getDiskStats([out, &out_result](auto result, const auto& value) {
+ out_result = result;
+ if (out_result != Result::SUCCESS) return;
+ out->clear();
+ out->reserve(value.size());
+ for (const auto& hidl_info : value) {
+ auto& aidl_info = out->emplace_back();
+ // translate() should always return true.
+ CHECK(translate(hidl_info, &aidl_info));
+ }
+ });
+ return ReturnAndResultToStatus(ret, out_result);
+}
+
+ScopedAStatus HealthShim::getHealthInfo(HealthInfo* out) {
+ Result out_result = Result::UNKNOWN;
+ auto ret = service_->getHealthInfo([out, &out_result](auto result, const auto& value) {
+ out_result = result;
+ if (out_result != Result::SUCCESS) return;
+ // translate() should always return true.
+ CHECK(translate(value, out));
+ });
+ return ReturnAndResultToStatus(ret, out_result);
+}
+
+} // namespace aidl::android::hardware::health
diff --git a/health/utils/libhealthshim/test.cpp b/health/utils/libhealthshim/test.cpp
new file mode 100644
index 0000000..d1dfb8b
--- /dev/null
+++ b/health/utils/libhealthshim/test.cpp
@@ -0,0 +1,163 @@
+/*
+ * Copyright (C) 2021 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 <health-shim/shim.h>
+
+#include <android/hardware/health/translate-ndk.h>
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+
+using HidlHealth = android::hardware::health::V2_0::IHealth;
+using HidlHealthInfoCallback = android::hardware::health::V2_0::IHealthInfoCallback;
+using HidlStorageInfo = android::hardware::health::V2_0::StorageInfo;
+using HidlDiskStats = android::hardware::health::V2_0::DiskStats;
+using HidlHealthInfo = android::hardware::health::V2_0::HealthInfo;
+using HidlBatteryStatus = android::hardware::health::V1_0::BatteryStatus;
+using android::sp;
+using android::hardware::Return;
+using android::hardware::Void;
+using android::hardware::health::V2_0::Result;
+using ndk::SharedRefBase;
+using testing::Invoke;
+using testing::NiceMock;
+
+namespace aidl::android::hardware::health {
+MATCHER(IsOk, "") {
+ *result_listener << "status is " << arg.getDescription();
+ return arg.isOk();
+}
+
+MATCHER_P(ExceptionIs, exception_code, "") {
+ *result_listener << "status is " << arg.getDescription();
+ return arg.getExceptionCode() == exception_code;
+}
+
+class MockHidlHealth : public HidlHealth {
+ public:
+ MOCK_METHOD(Return<Result>, registerCallback, (const sp<HidlHealthInfoCallback>& callback),
+ (override));
+ MOCK_METHOD(Return<Result>, unregisterCallback, (const sp<HidlHealthInfoCallback>& callback),
+ (override));
+ MOCK_METHOD(Return<Result>, update, (), (override));
+ MOCK_METHOD(Return<void>, getChargeCounter, (getChargeCounter_cb _hidl_cb), (override));
+ MOCK_METHOD(Return<void>, getCurrentNow, (getCurrentNow_cb _hidl_cb), (override));
+ MOCK_METHOD(Return<void>, getCurrentAverage, (getCurrentAverage_cb _hidl_cb), (override));
+ MOCK_METHOD(Return<void>, getCapacity, (getCapacity_cb _hidl_cb), (override));
+ MOCK_METHOD(Return<void>, getEnergyCounter, (getEnergyCounter_cb _hidl_cb), (override));
+ MOCK_METHOD(Return<void>, getChargeStatus, (getChargeStatus_cb _hidl_cb), (override));
+ MOCK_METHOD(Return<void>, getStorageInfo, (getStorageInfo_cb _hidl_cb), (override));
+ MOCK_METHOD(Return<void>, getDiskStats, (getDiskStats_cb _hidl_cb), (override));
+ MOCK_METHOD(Return<void>, getHealthInfo, (getHealthInfo_cb _hidl_cb), (override));
+};
+
+class HealthShimTest : public ::testing::Test {
+ public:
+ void SetUp() override {
+ hidl = new NiceMock<MockHidlHealth>();
+ shim = SharedRefBase::make<HealthShim>(hidl);
+ }
+ sp<MockHidlHealth> hidl;
+ std::shared_ptr<IHealth> shim;
+};
+
+#define ADD_TEST(name, aidl_name, AidlValueType, hidl_value, not_supported_hidl_value) \
+ TEST_F(HealthShimTest, name) { \
+ ON_CALL(*hidl, name).WillByDefault(Invoke([](auto cb) { \
+ cb(Result::SUCCESS, hidl_value); \
+ return Void(); \
+ })); \
+ AidlValueType value; \
+ ASSERT_THAT(shim->aidl_name(&value), IsOk()); \
+ ASSERT_EQ(value, static_cast<AidlValueType>(hidl_value)); \
+ } \
+ \
+ TEST_F(HealthShimTest, name##Unsupported) { \
+ ON_CALL(*hidl, name).WillByDefault(Invoke([](auto cb) { \
+ cb(Result::NOT_SUPPORTED, not_supported_hidl_value); \
+ return Void(); \
+ })); \
+ AidlValueType value; \
+ ASSERT_THAT(shim->aidl_name(&value), ExceptionIs(EX_UNSUPPORTED_OPERATION)); \
+ }
+
+ADD_TEST(getChargeCounter, getChargeCounterUah, int32_t, 0xFEEDBEEF, 0)
+ADD_TEST(getCurrentNow, getCurrentNowMicroamps, int32_t, 0xC0FFEE, 0)
+ADD_TEST(getCurrentAverage, getCurrentAverageMicroamps, int32_t, 0xA2D401D, 0)
+ADD_TEST(getCapacity, getCapacity, int32_t, 77, 0)
+ADD_TEST(getEnergyCounter, getEnergyCounterNwh, int64_t, 0x1234567887654321, 0)
+ADD_TEST(getChargeStatus, getChargeStatus, BatteryStatus, HidlBatteryStatus::CHARGING,
+ HidlBatteryStatus::UNKNOWN)
+
+#undef ADD_TEST
+
+template <typename AidlValueType, typename HidlValueType>
+bool Translate(const HidlValueType& hidl_value, AidlValueType* aidl_value) {
+ return ::android::h2a::translate(hidl_value, aidl_value);
+}
+
+template <typename AidlValueType, typename HidlValueType>
+bool Translate(const std::vector<HidlValueType>& hidl_vec, std::vector<AidlValueType>* aidl_vec) {
+ aidl_vec->clear();
+ aidl_vec->reserve(hidl_vec.size());
+ for (const auto& hidl_value : hidl_vec) {
+ auto& aidl_value = aidl_vec->emplace_back();
+ if (!Translate(hidl_value, &aidl_value)) return false;
+ }
+ return true;
+}
+
+#define ADD_INFO_TEST(name, AidlValueType, hidl_value) \
+ TEST_F(HealthShimTest, name) { \
+ AidlValueType expected_aidl_value; \
+ ASSERT_TRUE(Translate(hidl_value, &expected_aidl_value)); \
+ ON_CALL(*hidl, name).WillByDefault(Invoke([&](auto cb) { \
+ cb(Result::SUCCESS, hidl_value); \
+ return Void(); \
+ })); \
+ AidlValueType aidl_value; \
+ ASSERT_THAT(shim->name(&aidl_value), IsOk()); \
+ ASSERT_EQ(aidl_value, expected_aidl_value); \
+ } \
+ \
+ TEST_F(HealthShimTest, name##Unsupported) { \
+ ON_CALL(*hidl, name).WillByDefault(Invoke([](auto cb) { \
+ cb(Result::NOT_SUPPORTED, {}); \
+ return Void(); \
+ })); \
+ AidlValueType aidl_value; \
+ ASSERT_THAT(shim->name(&aidl_value), ExceptionIs(EX_UNSUPPORTED_OPERATION)); \
+ }
+
+ADD_INFO_TEST(getStorageInfo, std::vector<StorageInfo>,
+ (std::vector<HidlStorageInfo>{{
+ .lifetimeA = 15,
+ .lifetimeB = 18,
+ }}))
+
+ADD_INFO_TEST(getDiskStats, std::vector<DiskStats>,
+ (std::vector<HidlDiskStats>{{
+ .reads = 100,
+ .writes = 200,
+ }}))
+
+ADD_INFO_TEST(getHealthInfo, HealthInfo,
+ (HidlHealthInfo{
+ .batteryCurrentAverage = 999,
+ }))
+
+#undef ADD_INFO_TEST
+
+} // namespace aidl::android::hardware::health
diff --git a/keymaster/4.0/vts/functional/Android.bp b/keymaster/4.0/vts/functional/Android.bp
index a7be660..8e5a0ff 100644
--- a/keymaster/4.0/vts/functional/Android.bp
+++ b/keymaster/4.0/vts/functional/Android.bp
@@ -41,6 +41,10 @@
"general-tests",
"vts",
],
+ sanitize: {
+ cfi: false,
+ },
+
}
cc_test_library {
diff --git a/media/omx/1.0/vts/OWNERS b/media/omx/1.0/vts/OWNERS
index e0e0dd1..9e390c2 100644
--- a/media/omx/1.0/vts/OWNERS
+++ b/media/omx/1.0/vts/OWNERS
@@ -1,7 +1,5 @@
+# Bug component: 25690
# Media team
-pawin@google.com
+taklee@google.com
+wonsik@google.com
lajos@google.com
-
-# VTS team
-yim@google.com
-zhuoyao@google.com
\ No newline at end of file
diff --git a/neuralnetworks/aidl/android/hardware/neuralnetworks/OperationType.aidl b/neuralnetworks/aidl/android/hardware/neuralnetworks/OperationType.aidl
index aebe8d9..0ad254d 100644
--- a/neuralnetworks/aidl/android/hardware/neuralnetworks/OperationType.aidl
+++ b/neuralnetworks/aidl/android/hardware/neuralnetworks/OperationType.aidl
@@ -5385,7 +5385,7 @@
* must be in the range [0, n).
*
* Outputs:
- * * 0: The reversed tensor.
+ * * 0: The reversed tensor of the same shape as the input tensor.
* For {@link OperandType::TENSOR_QUANT8_ASYMM} and
* {@link OperandType::TENSOR_QUANT8_ASYMM_SIGNED} tensors,
* the scales and zeroPoint must be the same as input0.
diff --git a/neuralnetworks/aidl/vts/functional/Android.bp b/neuralnetworks/aidl/vts/functional/Android.bp
index a102fe0..1ed15b8 100644
--- a/neuralnetworks/aidl/vts/functional/Android.bp
+++ b/neuralnetworks/aidl/vts/functional/Android.bp
@@ -60,6 +60,7 @@
"libsync",
],
whole_static_libs: [
+ "neuralnetworks_generated_AIDL_V3_example",
"neuralnetworks_generated_AIDL_V2_example",
"neuralnetworks_generated_V1_0_example",
"neuralnetworks_generated_V1_1_example",
diff --git a/radio/1.6/vts/functional/radio_hidl_hal_api.cpp b/radio/1.6/vts/functional/radio_hidl_hal_api.cpp
index c167a6d..9f530b3 100644
--- a/radio/1.6/vts/functional/radio_hidl_hal_api.cpp
+++ b/radio/1.6/vts/functional/radio_hidl_hal_api.cpp
@@ -645,6 +645,10 @@
if (!deviceSupportsFeature(FEATURE_VOICE_CALL)) {
ALOGI("Skipping emergencyDial because voice call is not supported in device");
return;
+ } else if (!deviceSupportsFeature(FEATURE_TELEPHONY_GSM) &&
+ !deviceSupportsFeature(FEATURE_TELEPHONY_CDMA)) {
+ ALOGI("Skipping emergencyDial because gsm/cdma radio is not supported in device");
+ return;
} else {
ALOGI("Running emergencyDial because voice call is supported in device");
}
@@ -699,6 +703,10 @@
if (!deviceSupportsFeature(FEATURE_VOICE_CALL)) {
ALOGI("Skipping emergencyDial because voice call is not supported in device");
return;
+ } else if (!deviceSupportsFeature(FEATURE_TELEPHONY_GSM) &&
+ !deviceSupportsFeature(FEATURE_TELEPHONY_CDMA)) {
+ ALOGI("Skipping emergencyDial because gsm/cdma radio is not supported in device");
+ return;
} else {
ALOGI("Running emergencyDial because voice call is supported in device");
}
@@ -752,6 +760,10 @@
if (!deviceSupportsFeature(FEATURE_VOICE_CALL)) {
ALOGI("Skipping emergencyDial because voice call is not supported in device");
return;
+ } else if (!deviceSupportsFeature(FEATURE_TELEPHONY_GSM) &&
+ !deviceSupportsFeature(FEATURE_TELEPHONY_CDMA)) {
+ ALOGI("Skipping emergencyDial because gsm/cdma radio is not supported in device");
+ return;
} else {
ALOGI("Running emergencyDial because voice call is supported in device");
}
diff --git a/radio/aidl/aidl_api/android.hardware.radio.data/current/android/hardware/radio/data/DataProfileInfo.aidl b/radio/aidl/aidl_api/android.hardware.radio.data/current/android/hardware/radio/data/DataProfileInfo.aidl
index cfcd42c..9df687c 100644
--- a/radio/aidl/aidl_api/android.hardware.radio.data/current/android/hardware/radio/data/DataProfileInfo.aidl
+++ b/radio/aidl/aidl_api/android.hardware.radio.data/current/android/hardware/radio/data/DataProfileInfo.aidl
@@ -52,6 +52,7 @@
int mtuV6;
boolean preferred;
boolean persistent;
+ boolean alwaysOn;
const int ID_DEFAULT = 0;
const int ID_TETHERED = 1;
const int ID_IMS = 2;
diff --git a/radio/aidl/aidl_api/android.hardware.radio.modem/current/android/hardware/radio/modem/ActivityStatsInfo.aidl b/radio/aidl/aidl_api/android.hardware.radio.modem/current/android/hardware/radio/modem/ActivityStatsInfo.aidl
index 2da0167..93940fd 100644
--- a/radio/aidl/aidl_api/android.hardware.radio.modem/current/android/hardware/radio/modem/ActivityStatsInfo.aidl
+++ b/radio/aidl/aidl_api/android.hardware.radio.modem/current/android/hardware/radio/modem/ActivityStatsInfo.aidl
@@ -36,6 +36,5 @@
parcelable ActivityStatsInfo {
int sleepModeTimeMs;
int idleModeTimeMs;
- int[] txmModetimeMs;
- int rxModeTimeMs;
+ android.hardware.radio.modem.ActivityStatsTechSpecificInfo[] techSpecificInfo;
}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/BlendMode.aidl b/radio/aidl/aidl_api/android.hardware.radio.modem/current/android/hardware/radio/modem/ActivityStatsTechSpecificInfo.aidl
similarity index 75%
copy from graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/BlendMode.aidl
copy to radio/aidl/aidl_api/android.hardware.radio.modem/current/android/hardware/radio/modem/ActivityStatsTechSpecificInfo.aidl
index a522d53..798ec36 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/BlendMode.aidl
+++ b/radio/aidl/aidl_api/android.hardware.radio.modem/current/android/hardware/radio/modem/ActivityStatsTechSpecificInfo.aidl
@@ -1,11 +1,11 @@
-/**
- * Copyright (c) 2021, The Android Open Source Project
+/*
+ * Copyright (C) 2021 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
+ * 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,
@@ -31,11 +31,16 @@
// 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.composer3;
-@Backing(type="int") @VintfStability
-enum BlendMode {
- INVALID = 0,
- NONE = 1,
- PREMULTIPLIED = 2,
- COVERAGE = 3,
+package android.hardware.radio.modem;
+@VintfStability
+parcelable ActivityStatsTechSpecificInfo {
+ android.hardware.radio.AccessNetwork rat;
+ int frequencyRange;
+ int[] txmModetimeMs;
+ int rxModeTimeMs;
+ const int FREQUENCY_RANGE_UNKNOWN = 0;
+ const int FREQUENCY_RANGE_LOW = 1;
+ const int FREQUENCY_RANGE_MID = 2;
+ const int FREQUENCY_RANGE_HIGH = 3;
+ const int FREQUENCY_RANGE_MMWAVE = 4;
}
diff --git a/radio/aidl/aidl_api/android.hardware.radio.network/current/android/hardware/radio/network/IRadioNetwork.aidl b/radio/aidl/aidl_api/android.hardware.radio.network/current/android/hardware/radio/network/IRadioNetwork.aidl
index 16433be..c618791 100644
--- a/radio/aidl/aidl_api/android.hardware.radio.network/current/android/hardware/radio/network/IRadioNetwork.aidl
+++ b/radio/aidl/aidl_api/android.hardware.radio.network/current/android/hardware/radio/network/IRadioNetwork.aidl
@@ -68,4 +68,6 @@
oneway void startNetworkScan(in int serial, in android.hardware.radio.network.NetworkScanRequest request);
oneway void stopNetworkScan(in int serial);
oneway void supplyNetworkDepersonalization(in int serial, in String netPin);
+ oneway void setUsageSetting(in int serial, in android.hardware.radio.network.UsageSetting usageSetting);
+ oneway void getUsageSetting(in int serial);
}
diff --git a/radio/aidl/aidl_api/android.hardware.radio.network/current/android/hardware/radio/network/IRadioNetworkResponse.aidl b/radio/aidl/aidl_api/android.hardware.radio.network/current/android/hardware/radio/network/IRadioNetworkResponse.aidl
index ff95396..8cf4c31 100644
--- a/radio/aidl/aidl_api/android.hardware.radio.network/current/android/hardware/radio/network/IRadioNetworkResponse.aidl
+++ b/radio/aidl/aidl_api/android.hardware.radio.network/current/android/hardware/radio/network/IRadioNetworkResponse.aidl
@@ -67,4 +67,6 @@
oneway void startNetworkScanResponse(in android.hardware.radio.RadioResponseInfo info);
oneway void stopNetworkScanResponse(in android.hardware.radio.RadioResponseInfo info);
oneway void supplyNetworkDepersonalizationResponse(in android.hardware.radio.RadioResponseInfo info, in int remainingRetries);
+ oneway void setUsageSettingResponse(in android.hardware.radio.RadioResponseInfo info);
+ oneway void getUsageSettingResponse(in android.hardware.radio.RadioResponseInfo info, in android.hardware.radio.network.UsageSetting usageSetting);
}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/LayerRequest.aidl b/radio/aidl/aidl_api/android.hardware.radio.network/current/android/hardware/radio/network/UsageSetting.aidl
similarity index 87%
copy from graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/LayerRequest.aidl
copy to radio/aidl/aidl_api/android.hardware.radio.network/current/android/hardware/radio/network/UsageSetting.aidl
index cfafc50..7fdf831 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/LayerRequest.aidl
+++ b/radio/aidl/aidl_api/android.hardware.radio.network/current/android/hardware/radio/network/UsageSetting.aidl
@@ -1,11 +1,11 @@
-/**
- * Copyright (c) 2021, The Android Open Source Project
+/*
+ * Copyright (C) 2021 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
+ * 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,
@@ -31,8 +31,9 @@
// 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.composer3;
+package android.hardware.radio.network;
@Backing(type="int") @VintfStability
-enum LayerRequest {
- CLEAR_CLIENT_TARGET = 1,
+enum UsageSetting {
+ VOICE_CENTRIC = 1,
+ DATA_CENTRIC = 2,
}
diff --git a/radio/aidl/android/hardware/radio/data/DataProfileInfo.aidl b/radio/aidl/android/hardware/radio/data/DataProfileInfo.aidl
index 7657fc9..a14963f 100644
--- a/radio/aidl/android/hardware/radio/data/DataProfileInfo.aidl
+++ b/radio/aidl/android/hardware/radio/data/DataProfileInfo.aidl
@@ -115,4 +115,11 @@
* If the same data profile exists, this data profile must overwrite it.
*/
boolean persistent;
+ /**
+ * Indicates the PDU session brought up by this data profile should be always-on.
+ * An always-on PDU Session is a PDU Session for which User Plane resources have to be
+ * activated during every transition from CM-IDLE mode to CM-CONNECTED state.
+ * See 3GPP TS 23.501 section 5.6.13 for the details.
+ */
+ boolean alwaysOn;
}
diff --git a/radio/aidl/android/hardware/radio/modem/ActivityStatsInfo.aidl b/radio/aidl/android/hardware/radio/modem/ActivityStatsInfo.aidl
index 764a86d..d0aa695 100644
--- a/radio/aidl/android/hardware/radio/modem/ActivityStatsInfo.aidl
+++ b/radio/aidl/android/hardware/radio/modem/ActivityStatsInfo.aidl
@@ -16,6 +16,8 @@
package android.hardware.radio.modem;
+import android.hardware.radio.modem.ActivityStatsTechSpecificInfo;
+
@VintfStability
parcelable ActivityStatsInfo {
/**
@@ -28,17 +30,10 @@
*/
int idleModeTimeMs;
/**
- * Each index represent total time (in ms) during which the transmitter is active/awake for a
- * particular power range as shown below.
- * index 0 = tx_power < 0dBm
- * index 1 = 0dBm < tx_power < 5dBm
- * index 2 = 5dBm < tx_power < 15dBm
- * index 3 = 15dBm < tx_power < 20dBm
- * index 4 = tx_power > 20dBm
+ * Technology specific activity stats info.
+ * List of the activity stats for each RATs (2G, 3G, 4G and 5G) and frequency ranges (HIGH for
+ * sub6 and MMWAVE) in case of 5G. In case implementation doesn't have RAT specific activity
+ * stats then send only one activity stats info with RAT unknown.
*/
- int[] txmModetimeMs;
- /**
- * Total time (in ms) for which receiver is active/awake and the transmitter is inactive
- */
- int rxModeTimeMs;
+ ActivityStatsTechSpecificInfo[] techSpecificInfo;
}
diff --git a/radio/aidl/android/hardware/radio/modem/ActivityStatsTechSpecificInfo.aidl b/radio/aidl/android/hardware/radio/modem/ActivityStatsTechSpecificInfo.aidl
new file mode 100644
index 0000000..fb14223
--- /dev/null
+++ b/radio/aidl/android/hardware/radio/modem/ActivityStatsTechSpecificInfo.aidl
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2021 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.radio.modem;
+
+import android.hardware.radio.AccessNetwork;
+
+@VintfStability
+parcelable ActivityStatsTechSpecificInfo {
+ /** Indicates the frequency range is unknown. */
+ const int FREQUENCY_RANGE_UNKNOWN = 0;
+ /** Indicates the frequency range is below 1GHz. */
+ const int FREQUENCY_RANGE_LOW = 1;
+ /** Indicates the frequency range is between 1GHz and 3GHz. */
+ const int FREQUENCY_RANGE_MID = 2;
+ /** Indicates the frequency range is between 3GHz and 6GHz. */
+ const int FREQUENCY_RANGE_HIGH = 3;
+ /** Indicates the frequency range is above 6GHz (millimeter wave frequency). */
+ const int FREQUENCY_RANGE_MMWAVE = 4;
+ /**
+ * Radio access technology. Set UNKNOWN if the Activity statistics
+ * is RAT independent.
+ */
+ AccessNetwork rat;
+ /**
+ * Frequency range. Values are FREQUENCY_RANGE_
+ * Set FREQUENCY_RANGE_UNKNOWN if the Activity statistics when frequency range
+ * is not applicable.
+ */
+ int frequencyRange;
+ /**
+ * Each index represent total time (in ms) during which the transmitter is active/awake for a
+ * particular power range as shown below.
+ * index 0 = tx_power <= 0dBm
+ * index 1 = 0dBm < tx_power <= 5dBm
+ * index 2 = 5dBm < tx_power <= 15dBm
+ * index 3 = 15dBm < tx_power <= 20dBm
+ * index 4 = tx_power > 20dBm
+ */
+ int[] txmModetimeMs;
+ /**
+ * Total time (in ms) for which receiver is active/awake and the transmitter is inactive
+ */
+ int rxModeTimeMs;
+}
diff --git a/radio/aidl/android/hardware/radio/network/IRadioNetwork.aidl b/radio/aidl/android/hardware/radio/network/IRadioNetwork.aidl
index 1081a75..aaf432a 100644
--- a/radio/aidl/android/hardware/radio/network/IRadioNetwork.aidl
+++ b/radio/aidl/android/hardware/radio/network/IRadioNetwork.aidl
@@ -27,6 +27,7 @@
import android.hardware.radio.network.RadioAccessSpecifier;
import android.hardware.radio.network.RadioBandMode;
import android.hardware.radio.network.SignalThresholdInfo;
+import android.hardware.radio.network.UsageSetting;
/**
* This interface is used by telephony and telecom to talk to cellular radio for network APIs.
@@ -416,4 +417,25 @@
* Response function is IRadioNetworkResponse.supplyNetworkDepersonalizationResponse()
*/
void supplyNetworkDepersonalization(in int serial, in String netPin);
+
+ /**
+ * Set the UE usage setting for data/voice centric usage.
+ *
+ * <p>Sets the usage setting in accordance with 3gpp 24.301 sec 4.3 and 3gpp 24.501 sec 4.3.
+ * <p>This value must be independently preserved for each SIM; (setting the value is not a
+ * "global" override).
+ *
+ * @param serial Serial number of request.
+ * @param usageSetting the usage setting for the current SIM.
+ */
+ oneway void setUsageSetting(in int serial, in UsageSetting usageSetting);
+
+ /**
+ * Get the UE usage setting for data/voice centric usage.
+ *
+ * <p>Gets the usage setting in accordance with 3gpp 24.301 sec 4.3 and 3gpp 24.501 sec 4.3.
+ *
+ * @param serial Serial number of request.
+ */
+ oneway void getUsageSetting(in int serial);
}
diff --git a/radio/aidl/android/hardware/radio/network/IRadioNetworkResponse.aidl b/radio/aidl/android/hardware/radio/network/IRadioNetworkResponse.aidl
index 429b5a8..30f4221 100644
--- a/radio/aidl/android/hardware/radio/network/IRadioNetworkResponse.aidl
+++ b/radio/aidl/android/hardware/radio/network/IRadioNetworkResponse.aidl
@@ -31,6 +31,7 @@
import android.hardware.radio.network.RadioBandMode;
import android.hardware.radio.network.RegStateResult;
import android.hardware.radio.network.SignalStrength;
+import android.hardware.radio.network.UsageSetting;
/**
* Interface declaring response functions to solicited radio requests for network APIs.
@@ -549,4 +550,30 @@
* RadioError:SIM_ABSENT
*/
void supplyNetworkDepersonalizationResponse(in RadioResponseInfo info, in int remainingRetries);
+
+ /**
+ * @param info Response info struct containing response type, serial no. and error.
+ *
+ * Valid errors returned:
+ * RadioError:NONE
+ * RadioError:RADIO_NOT_AVAILABLE
+ * RadioError:INVALID_STATE
+ * RadioError:INVALID_ARGUMENTS
+ * RadioError:INTERNAL_ERR
+ * RadioError:SIM_ABSENT
+ */
+ oneway void setUsageSettingResponse(in RadioResponseInfo info);
+
+ /**
+ * @param info Response info struct containing response type, serial no. and error.
+ * @param usageSetting the usage setting for the current SIM.
+ *
+ * Valid errors returned:
+ * RadioError:NONE
+ * RadioError:RADIO_NOT_AVAILABLE
+ * RadioError:INVALID_STATE
+ * RadioError:INTERNAL_ERR
+ * RadioError:SIM_ABSENT
+ */
+ oneway void getUsageSettingResponse(in RadioResponseInfo info, in UsageSetting usageSetting);
}
diff --git a/radio/aidl/android/hardware/radio/network/UsageSetting.aidl b/radio/aidl/android/hardware/radio/network/UsageSetting.aidl
new file mode 100644
index 0000000..ba8fe93
--- /dev/null
+++ b/radio/aidl/android/hardware/radio/network/UsageSetting.aidl
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2021 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.radio.network;
+
+/**
+ * Cellular usage setting with values according to 3gpp 24.301 sec 4.3 and 3gpp 24.501 sec 4.3.
+ *
+ * <p>Also refer to "UE's usage setting" as defined in 3gpp 24.301 section 3.1 and 3gpp 23.221
+ * Annex A.
+ */
+@VintfStability
+@Backing(type="int")
+enum UsageSetting {
+ /**
+ * UE operates in voice-centric mode. Generally speaking, in this mode of operation, the UE
+ * will not remain camped on a cell or attached to a network unless that cell/network provides
+ * voice service.
+ */
+ VOICE_CENTRIC = 1,
+
+ /**
+ * UE operates in data-centric mode. Generally speaking, in this mode of operation, the UE
+ * will not reselect away from a cell/network that only provides data services.
+ */
+ DATA_CENTRIC = 2,
+}
diff --git a/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioNetwork.h b/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioNetwork.h
index c776fd1..09ae240 100644
--- a/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioNetwork.h
+++ b/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioNetwork.h
@@ -88,6 +88,10 @@
::ndk::ScopedAStatus stopNetworkScan(int32_t serial) override;
::ndk::ScopedAStatus supplyNetworkDepersonalization(int32_t serial,
const std::string& netPin) override;
+ ::ndk::ScopedAStatus setUsageSetting(
+ int32_t serial,
+ ::aidl::android::hardware::radio::network::UsageSetting usageSetting) override;
+ ::ndk::ScopedAStatus getUsageSetting(int32_t serial) override;
public:
using RadioCompatBase::RadioCompatBase;
diff --git a/radio/aidl/compat/libradiocompat/modem/structs.cpp b/radio/aidl/compat/libradiocompat/modem/structs.cpp
index c1cd64c..53d5753 100644
--- a/radio/aidl/compat/libradiocompat/modem/structs.cpp
+++ b/radio/aidl/compat/libradiocompat/modem/structs.cpp
@@ -24,6 +24,7 @@
namespace android::hardware::radio::compat {
+using ::aidl::android::hardware::radio::AccessNetwork;
using ::aidl::android::hardware::radio::RadioAccessFamily;
using ::aidl::android::hardware::radio::RadioTechnology;
namespace aidl = ::aidl::android::hardware::radio::modem;
@@ -82,11 +83,18 @@
}
aidl::ActivityStatsInfo toAidl(const V1_0::ActivityStatsInfo& info) {
+ const aidl::ActivityStatsTechSpecificInfo techSpecificInfo = {
+ .rat = AccessNetwork(AccessNetwork::UNKNOWN),
+ .frequencyRange = static_cast<int32_t>(
+ aidl::ActivityStatsTechSpecificInfo::FREQUENCY_RANGE_UNKNOWN),
+ .txmModetimeMs = toAidl(info.txmModetimeMs),
+ .rxModeTimeMs = static_cast<int32_t>(info.rxModeTimeMs),
+ };
+
return {
.sleepModeTimeMs = static_cast<int32_t>(info.sleepModeTimeMs),
.idleModeTimeMs = static_cast<int32_t>(info.idleModeTimeMs),
- .txmModetimeMs = toAidl(info.txmModetimeMs),
- .rxModeTimeMs = static_cast<int32_t>(info.rxModeTimeMs),
+ .techSpecificInfo = {techSpecificInfo},
};
}
diff --git a/radio/aidl/compat/libradiocompat/modem/structs.h b/radio/aidl/compat/libradiocompat/modem/structs.h
index 3ac1edb..af714c7 100644
--- a/radio/aidl/compat/libradiocompat/modem/structs.h
+++ b/radio/aidl/compat/libradiocompat/modem/structs.h
@@ -16,6 +16,7 @@
#pragma once
#include <aidl/android/hardware/radio/modem/ActivityStatsInfo.h>
+#include <aidl/android/hardware/radio/modem/ActivityStatsTechSpecificInfo.h>
#include <aidl/android/hardware/radio/modem/HardwareConfig.h>
#include <aidl/android/hardware/radio/modem/HardwareConfigModem.h>
#include <aidl/android/hardware/radio/modem/HardwareConfigSim.h>
diff --git a/radio/aidl/compat/libradiocompat/network/RadioNetwork.cpp b/radio/aidl/compat/libradiocompat/network/RadioNetwork.cpp
index af0bc46..5fa1cf5 100644
--- a/radio/aidl/compat/libradiocompat/network/RadioNetwork.cpp
+++ b/radio/aidl/compat/libradiocompat/network/RadioNetwork.cpp
@@ -278,4 +278,19 @@
return ok();
}
+// TODO(b/210498497): is there a cleaner way to send a response back to Android, even though these
+// methods must never be called?
+ScopedAStatus RadioNetwork::setUsageSetting(
+ int32_t ser, ::aidl::android::hardware::radio::network::UsageSetting) {
+ LOG_CALL << ser;
+ LOG(ERROR) << "setUsageSetting is unsupported by HIDL HALs";
+ return ok();
+}
+
+ScopedAStatus RadioNetwork::getUsageSetting(int32_t ser) {
+ LOG_CALL << ser;
+ LOG(ERROR) << "getUsageSetting is unsupported by HIDL HALs";
+ return ok();
+}
+
} // namespace android::hardware::radio::compat
diff --git a/security/keymint/aidl/Android.bp b/security/keymint/aidl/Android.bp
index 028d297..3cf6ff2 100644
--- a/security/keymint/aidl/Android.bp
+++ b/security/keymint/aidl/Android.bp
@@ -38,3 +38,30 @@
},
versions: ["1"],
}
+
+// cc_defaults that includes the latest KeyMint AIDL library.
+// Modules that depend on KeyMint directly can include this cc_defaults to avoid
+// managing dependency versions explicitly.
+cc_defaults {
+ name: "keymint_use_latest_hal_aidl_ndk_static",
+ static_libs: [
+ "android.hardware.security.keymint-V1-ndk",
+ ],
+}
+
+cc_defaults {
+ name: "keymint_use_latest_hal_aidl_ndk_shared",
+ shared_libs: [
+ "android.hardware.security.keymint-V1-ndk",
+ ],
+}
+
+// A rust_defaults that includes the latest KeyMint AIDL library.
+// Modules that depend on KeyMint directly can include this cc_defaults to avoid
+// managing dependency versions explicitly.
+rust_defaults {
+ name: "keymint_use_latest_hal_aidl_rust",
+ rustlibs: [
+ "android.hardware.security.keymint-V1-rust",
+ ],
+}
diff --git a/security/keymint/aidl/default/Android.bp b/security/keymint/aidl/default/Android.bp
index c2918ef..1a17fd4 100644
--- a/security/keymint/aidl/default/Android.bp
+++ b/security/keymint/aidl/default/Android.bp
@@ -21,8 +21,10 @@
"-Wall",
"-Wextra",
],
+ defaults: [
+ "keymint_use_latest_hal_aidl_ndk_shared",
+ ],
shared_libs: [
- "android.hardware.security.keymint-V1-ndk",
"android.hardware.security.sharedsecret-V1-ndk",
"android.hardware.security.secureclock-V1-ndk",
"libbase",
diff --git a/security/keymint/aidl/vts/functional/Android.bp b/security/keymint/aidl/vts/functional/Android.bp
index ff6a6f8..2d2d701 100644
--- a/security/keymint/aidl/vts/functional/Android.bp
+++ b/security/keymint/aidl/vts/functional/Android.bp
@@ -26,6 +26,7 @@
cc_defaults {
name: "keymint_vts_defaults",
defaults: [
+ "keymint_use_latest_hal_aidl_ndk_static",
"use_libaidlvintf_gtest_helper_static",
"VtsHalTargetTestDefaults",
],
@@ -34,7 +35,6 @@
"libcrypto",
],
static_libs: [
- "android.hardware.security.keymint-V1-ndk",
"android.hardware.security.secureclock-V1-ndk",
"libcppbor_external",
"libcppcose_rkp",
diff --git a/security/keymint/aidl/vts/functional/AttestKeyTest.cpp b/security/keymint/aidl/vts/functional/AttestKeyTest.cpp
index 64550ef..73c3820 100644
--- a/security/keymint/aidl/vts/functional/AttestKeyTest.cpp
+++ b/security/keymint/aidl/vts/functional/AttestKeyTest.cpp
@@ -583,6 +583,7 @@
attest_key, &attested_key_blob, &attested_key_characteristics,
&attested_key_cert_chain));
+ ASSERT_GT(attested_key_cert_chain.size(), 0);
CheckedDeleteKey(&attested_key_blob);
AuthorizationSet hw_enforced = HwEnforcedAuthorizations(attested_key_characteristics);
@@ -612,6 +613,7 @@
attest_key, &attested_key_blob, &attested_key_characteristics,
&attested_key_cert_chain));
+ ASSERT_GT(attested_key_cert_chain.size(), 0);
CheckedDeleteKey(&attested_key_blob);
CheckedDeleteKey(&attest_key.keyBlob);
diff --git a/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp b/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp
index 12ce859..6140df1 100644
--- a/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp
+++ b/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp
@@ -1067,6 +1067,8 @@
}
} else {
switch (algorithm) {
+ case Algorithm::AES:
+ return {64, 96, 131, 512};
case Algorithm::TRIPLE_DES:
return {56};
default:
diff --git a/security/keymint/aidl/vts/functional/KeyMintTest.cpp b/security/keymint/aidl/vts/functional/KeyMintTest.cpp
index bb2bb15..d8b19dc 100644
--- a/security/keymint/aidl/vts/functional/KeyMintTest.cpp
+++ b/security/keymint/aidl/vts/functional/KeyMintTest.cpp
@@ -69,6 +69,9 @@
namespace {
+// Whether to check that BOOT_PATCHLEVEL is populated.
+bool check_boot_pl = true;
+
// The maximum number of times we'll attempt to verify that corruption
// of an encrypted blob results in an error. Retries are necessary as there
// is a small (roughly 1/256) chance that corrupting ciphertext still results
@@ -527,12 +530,17 @@
EXPECT_TRUE(os_pl);
EXPECT_EQ(*os_pl, os_patch_level());
- // Should include vendor and boot patchlevels.
+ // Should include vendor patchlevel.
auto vendor_pl = auths.GetTagValue(TAG_VENDOR_PATCHLEVEL);
EXPECT_TRUE(vendor_pl);
EXPECT_EQ(*vendor_pl, vendor_patch_level());
- auto boot_pl = auths.GetTagValue(TAG_BOOT_PATCHLEVEL);
- EXPECT_TRUE(boot_pl);
+
+ // Should include boot patchlevel (but there are some test scenarios where this is not
+ // possible).
+ if (check_boot_pl) {
+ auto boot_pl = auths.GetTagValue(TAG_BOOT_PATCHLEVEL);
+ EXPECT_TRUE(boot_pl);
+ }
return auths;
}
@@ -3143,6 +3151,58 @@
CheckedDeleteKey(&verification_key);
}
+/*
+ * VerificationOperationsTest.HmacVerificationFailsForCorruptSignature
+ *
+ * Verifies HMAC signature verification should fails if message or signature is corrupted.
+ */
+TEST_P(VerificationOperationsTest, HmacVerificationFailsForCorruptSignature) {
+ string key_material = "HelloThisIsAKey";
+
+ vector<uint8_t> signing_key, verification_key;
+ vector<KeyCharacteristics> signing_key_chars, verification_key_chars;
+ EXPECT_EQ(ErrorCode::OK,
+ ImportKey(AuthorizationSetBuilder()
+ .Authorization(TAG_NO_AUTH_REQUIRED)
+ .Authorization(TAG_ALGORITHM, Algorithm::HMAC)
+ .Authorization(TAG_PURPOSE, KeyPurpose::SIGN)
+ .Digest(Digest::SHA_2_256)
+ .Authorization(TAG_MIN_MAC_LENGTH, 160),
+ KeyFormat::RAW, key_material, &signing_key, &signing_key_chars));
+ EXPECT_EQ(ErrorCode::OK,
+ ImportKey(AuthorizationSetBuilder()
+ .Authorization(TAG_NO_AUTH_REQUIRED)
+ .Authorization(TAG_ALGORITHM, Algorithm::HMAC)
+ .Authorization(TAG_PURPOSE, KeyPurpose::VERIFY)
+ .Digest(Digest::SHA_2_256)
+ .Authorization(TAG_MIN_MAC_LENGTH, 160),
+ KeyFormat::RAW, key_material, &verification_key, &verification_key_chars));
+
+ string message = "This is a message.";
+ string signature = SignMessage(
+ signing_key, message,
+ AuthorizationSetBuilder().Digest(Digest::SHA_2_256).Authorization(TAG_MAC_LENGTH, 160));
+
+ AuthorizationSet begin_out_params;
+ ASSERT_EQ(ErrorCode::OK,
+ Begin(KeyPurpose::VERIFY, verification_key,
+ AuthorizationSetBuilder().Digest(Digest::SHA_2_256), &begin_out_params));
+
+ string corruptMessage = "This is b message."; // Corrupted message
+ string output;
+ EXPECT_EQ(ErrorCode::VERIFICATION_FAILED, Finish(corruptMessage, signature, &output));
+
+ ASSERT_EQ(ErrorCode::OK,
+ Begin(KeyPurpose::VERIFY, verification_key,
+ AuthorizationSetBuilder().Digest(Digest::SHA_2_256), &begin_out_params));
+
+ signature[0] += 1; // Corrupt a signature
+ EXPECT_EQ(ErrorCode::VERIFICATION_FAILED, Finish(message, signature, &output));
+
+ CheckedDeleteKey(&signing_key);
+ CheckedDeleteKey(&verification_key);
+}
+
INSTANTIATE_KEYMINT_AIDL_TEST(VerificationOperationsTest);
typedef KeyMintAidlTestBase ExportKeyTest;
@@ -6914,6 +6974,12 @@
} else {
std::cout << "NOT dumping attestations" << std::endl;
}
+ if (std::string(argv[i]) == "--skip_boot_pl_check") {
+ // Allow checks of BOOT_PATCHLEVEL to be disabled, so that the tests can
+ // be run in emulated environments that don't have the normal bootloader
+ // interactions.
+ aidl::android::hardware::security::keymint::test::check_boot_pl = false;
+ }
}
}
return RUN_ALL_TESTS();
diff --git a/security/keymint/aidl/vts/performance/Android.bp b/security/keymint/aidl/vts/performance/Android.bp
index 355f87b..7e3a3e5 100644
--- a/security/keymint/aidl/vts/performance/Android.bp
+++ b/security/keymint/aidl/vts/performance/Android.bp
@@ -27,6 +27,7 @@
name: "VtsAidlKeyMintBenchmarkTest",
defaults: [
"VtsHalTargetTestDefaults",
+ "keymint_use_latest_hal_aidl_ndk_static",
"use_libaidlvintf_gtest_helper_static",
],
srcs: [
@@ -39,7 +40,6 @@
"libkeymint_support",
],
static_libs: [
- "android.hardware.security.keymint-V1-ndk",
"android.hardware.security.secureclock-V1-ndk",
"libcppbor_external",
"libchrome",
diff --git a/security/keymint/support/Android.bp b/security/keymint/support/Android.bp
index e162934..36969bb 100644
--- a/security/keymint/support/Android.bp
+++ b/security/keymint/support/Android.bp
@@ -40,8 +40,10 @@
export_include_dirs: [
"include",
],
+ defaults: [
+ "keymint_use_latest_hal_aidl_ndk_shared",
+ ],
shared_libs: [
- "android.hardware.security.keymint-V1-ndk",
"libbase",
"libcrypto",
"libutils",
diff --git a/security/secureclock/aidl/vts/functional/Android.bp b/security/secureclock/aidl/vts/functional/Android.bp
index 806517d..a34668b 100644
--- a/security/secureclock/aidl/vts/functional/Android.bp
+++ b/security/secureclock/aidl/vts/functional/Android.bp
@@ -27,6 +27,7 @@
name: "VtsAidlSecureClockTargetTest",
defaults: [
"VtsHalTargetTestDefaults",
+ "keymint_use_latest_hal_aidl_ndk_static",
"use_libaidlvintf_gtest_helper_static",
],
cflags: [
@@ -41,7 +42,6 @@
"libcrypto",
],
static_libs: [
- "android.hardware.security.keymint-V1-ndk",
"android.hardware.security.secureclock-V1-ndk",
"libkeymint",
],
diff --git a/security/sharedsecret/aidl/vts/functional/Android.bp b/security/sharedsecret/aidl/vts/functional/Android.bp
index 94da675..1f0f6a6 100644
--- a/security/sharedsecret/aidl/vts/functional/Android.bp
+++ b/security/sharedsecret/aidl/vts/functional/Android.bp
@@ -27,6 +27,7 @@
name: "VtsAidlSharedSecretTargetTest",
defaults: [
"VtsHalTargetTestDefaults",
+ "keymint_use_latest_hal_aidl_ndk_static",
"use_libaidlvintf_gtest_helper_static",
],
srcs: [
@@ -41,7 +42,6 @@
"libcrypto",
],
static_libs: [
- "android.hardware.security.keymint-V1-ndk",
"android.hardware.security.sharedsecret-V1-ndk",
"libkeymint",
],
diff --git a/tv/tuner/aidl/vts/functional/FilterTests.cpp b/tv/tuner/aidl/vts/functional/FilterTests.cpp
index a5acdc1..53afef7 100644
--- a/tv/tuner/aidl/vts/functional/FilterTests.cpp
+++ b/tv/tuner/aidl/vts/functional/FilterTests.cpp
@@ -17,6 +17,7 @@
#include "FilterTests.h"
#include <inttypes.h>
+#include <algorithm>
#include <aidl/android/hardware/tv/tuner/DemuxFilterMonitorEventType.h>
#include <aidlcommonsupport/NativeHandle.h>
@@ -31,23 +32,24 @@
mPidFilterOutputCount++;
mMsgCondition.signal();
- // HACK: we need to cast the const away as DemuxFilterEvent contains a ScopedFileDescriptor
- // that cannot be copied.
- for (auto&& e : const_cast<std::vector<DemuxFilterEvent>&>(events)) {
- auto it = mFilterEventPromises.find(e.getTag());
- if (it != mFilterEventPromises.cend()) {
- it->second.set_value(std::move(e));
- mFilterEventPromises.erase(it);
+ for (auto it = mFilterCallbackVerifiers.begin(); it != mFilterCallbackVerifiers.end();) {
+ auto& [verifier, promise] = *it;
+ if (verifier(events)) {
+ promise.set_value();
+ it = mFilterCallbackVerifiers.erase(it);
+ } else {
+ ++it;
}
- }
+ };
return ::ndk::ScopedAStatus::ok();
}
-std::future<DemuxFilterEvent> FilterCallback::getNextFilterEventWithTag(DemuxFilterEvent::Tag tag) {
- // Note: this currently only supports one future per DemuxFilterEvent::Tag.
- mFilterEventPromises[tag] = std::promise<DemuxFilterEvent>();
- return mFilterEventPromises[tag].get_future();
+std::future<void> FilterCallback::verifyFilterCallback(FilterCallbackVerifier&& verifier) {
+ std::promise<void> promise;
+ auto future = promise.get_future();
+ mFilterCallbackVerifiers.emplace_back(std::move(verifier), std::move(promise));
+ return future;
}
void FilterCallback::testFilterDataOutput() {
diff --git a/tv/tuner/aidl/vts/functional/FilterTests.h b/tv/tuner/aidl/vts/functional/FilterTests.h
index 6258bac..f579441 100644
--- a/tv/tuner/aidl/vts/functional/FilterTests.h
+++ b/tv/tuner/aidl/vts/functional/FilterTests.h
@@ -60,9 +60,18 @@
class FilterCallback : public BnFilterCallback {
public:
+ /**
+ * A FilterCallbackVerifier is used to test and verify filter callbacks.
+ * The function should return true when a callback has been handled by this
+ * filter verifier. This will cause the associated future to be unblocked.
+ * If the function returns false, we continue to wait for future callbacks
+ * (the future remains blocked).
+ */
+ using FilterCallbackVerifier = std::function<bool(const std::vector<DemuxFilterEvent>&)>;
+
virtual ::ndk::ScopedAStatus onFilterEvent(const vector<DemuxFilterEvent>& events) override;
- std::future<DemuxFilterEvent> getNextFilterEventWithTag(DemuxFilterEvent::Tag tag);
+ std::future<void> verifyFilterCallback(FilterCallbackVerifier&& verifier);
virtual ::ndk::ScopedAStatus onFilterStatus(const DemuxFilterStatus /*status*/) override {
return ::ndk::ScopedAStatus::ok();
@@ -85,7 +94,7 @@
int32_t mFilterId;
std::shared_ptr<IFilter> mFilter;
- std::unordered_map<DemuxFilterEvent::Tag, std::promise<DemuxFilterEvent>> mFilterEventPromises;
+ std::vector<std::pair<FilterCallbackVerifier, std::promise<void>>> mFilterCallbackVerifiers;
native_handle_t* mAvSharedHandle = nullptr;
uint64_t mAvSharedMemSize = -1;
diff --git a/tv/tuner/aidl/vts/functional/VtsHalTvTunerTargetTest.cpp b/tv/tuner/aidl/vts/functional/VtsHalTvTunerTargetTest.cpp
index 88890e4..89e42df 100644
--- a/tv/tuner/aidl/vts/functional/VtsHalTvTunerTargetTest.cpp
+++ b/tv/tuner/aidl/vts/functional/VtsHalTvTunerTargetTest.cpp
@@ -640,10 +640,51 @@
testTimeFilter(timeFilterMap[timeFilter.timeFilterId]);
}
-// TODO: move boilerplate into text fixture
-TEST_P(TunerFilterAidlTest, FilterTimeDelayHintTest) {
- description("Test filter delay hint.");
+static bool isMediaFilter(const FilterConfig& filterConfig) {
+ switch (filterConfig.type.mainType) {
+ case DemuxFilterMainType::TS: {
+ // TS Audio and Video filters are media filters
+ auto tsFilterType =
+ filterConfig.type.subType.get<DemuxFilterSubType::Tag::tsFilterType>();
+ return (tsFilterType == DemuxTsFilterType::AUDIO ||
+ tsFilterType == DemuxTsFilterType::VIDEO);
+ }
+ case DemuxFilterMainType::MMTP: {
+ // MMTP Audio and Video filters are media filters
+ auto mmtpFilterType =
+ filterConfig.type.subType.get<DemuxFilterSubType::Tag::mmtpFilterType>();
+ return (mmtpFilterType == DemuxMmtpFilterType::AUDIO ||
+ mmtpFilterType == DemuxMmtpFilterType::VIDEO);
+ }
+ default:
+ return false;
+ }
+}
+static int getDemuxFilterEventDataLength(const DemuxFilterEvent& event) {
+ switch (event.getTag()) {
+ case DemuxFilterEvent::Tag::section:
+ return event.get<DemuxFilterEvent::Tag::section>().dataLength;
+ case DemuxFilterEvent::Tag::media:
+ return event.get<DemuxFilterEvent::Tag::media>().dataLength;
+ case DemuxFilterEvent::Tag::pes:
+ return event.get<DemuxFilterEvent::Tag::pes>().dataLength;
+ case DemuxFilterEvent::Tag::download:
+ return event.get<DemuxFilterEvent::Tag::download>().dataLength;
+ case DemuxFilterEvent::Tag::ipPayload:
+ return event.get<DemuxFilterEvent::Tag::ipPayload>().dataLength;
+
+ case DemuxFilterEvent::Tag::tsRecord:
+ case DemuxFilterEvent::Tag::mmtpRecord:
+ case DemuxFilterEvent::Tag::temi:
+ case DemuxFilterEvent::Tag::monitorEvent:
+ case DemuxFilterEvent::Tag::startId:
+ return 0;
+ }
+}
+
+// TODO: move boilerplate into text fixture
+void TunerFilterAidlTest::testDelayHint(const FilterConfig& filterConf) {
int32_t feId;
int32_t demuxId;
std::shared_ptr<IDemux> demux;
@@ -657,40 +698,87 @@
ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId));
mFilterTests.setDemux(demux);
- const auto& filterConf = filterMap[live.ipFilterId];
ASSERT_TRUE(mFilterTests.openFilterInDemux(filterConf.type, filterConf.bufferSize));
ASSERT_TRUE(mFilterTests.getNewlyOpenedFilterId_64bit(filterId));
- ASSERT_TRUE(mFilterTests.configFilter(filterConf.settings, filterId));
- ASSERT_TRUE(mFilterTests.configIpFilterCid(filterConf.ipCid, filterId));
+ bool mediaFilter = isMediaFilter(filterConf);
auto filter = mFilterTests.getFilterById(filterId);
- auto delayValue = std::chrono::milliseconds(5000);
- FilterDelayHint delayHint;
- delayHint.hintType = FilterDelayHintType::TIME_DELAY_IN_MS;
- delayHint.hintValue = delayValue.count();
+ auto timeDelayInMs = std::chrono::milliseconds(filterConf.timeDelayInMs);
+ if (timeDelayInMs.count() > 0) {
+ FilterDelayHint delayHint;
+ delayHint.hintType = FilterDelayHintType::TIME_DELAY_IN_MS;
+ delayHint.hintValue = timeDelayInMs.count();
- auto status = filter->setDelayHint(delayHint);
- ASSERT_TRUE(status.isOk());
+ // setDelayHint should fail for media filters.
+ ASSERT_EQ(filter->setDelayHint(delayHint).isOk(), !mediaFilter);
+ }
- auto startTime = std::chrono::steady_clock::now();
- ASSERT_TRUE(mFilterTests.startFilter(filterId));
+ int dataDelayInBytes = filterConf.dataDelayInBytes;
+ if (dataDelayInBytes > 0) {
+ FilterDelayHint delayHint;
+ delayHint.hintType = FilterDelayHintType::DATA_SIZE_DELAY_IN_BYTES;
+ delayHint.hintValue = dataDelayInBytes;
- auto cb = mFilterTests.getFilterCallbacks().at(filterId);
- auto future = cb->getNextFilterEventWithTag(DemuxFilterEvent::Tag::ipPayload);
+ // setDelayHint should fail for media filters.
+ ASSERT_EQ(filter->setDelayHint(delayHint).isOk(), !mediaFilter);
+ }
- // block and wait for callback to be received.
- ASSERT_EQ(future.wait_for(std::chrono::seconds(10)), std::future_status::ready);
- auto duration = std::chrono::steady_clock::now() - startTime;
- ASSERT_GE(duration, delayValue);
+ // start and stop filter in order to circumvent callback scheduler race
+ // conditions after adjusting filter delays.
+ mFilterTests.startFilter(filterId);
+ mFilterTests.stopFilter(filterId);
- // cleanup
- ASSERT_TRUE(mFilterTests.stopFilter(filterId));
+ if (!mediaFilter) {
+ auto cb = mFilterTests.getFilterCallbacks().at(filterId);
+ int callbackSize = 0;
+ auto future = cb->verifyFilterCallback(
+ [&callbackSize](const std::vector<DemuxFilterEvent>& events) {
+ for (const auto& event : events) {
+ callbackSize += getDemuxFilterEventDataLength(event);
+ }
+ return true;
+ });
+
+ // The configure stage can also produce events, so we should set the delay
+ // hint beforehand.
+ ASSERT_TRUE(mFilterTests.configFilter(filterConf.settings, filterId));
+
+ auto startTime = std::chrono::steady_clock::now();
+ ASSERT_TRUE(mFilterTests.startFilter(filterId));
+
+ // block and wait for callback to be received.
+ auto timeout = std::chrono::seconds(30);
+ ASSERT_EQ(future.wait_for(timeout), std::future_status::ready);
+ auto duration = std::chrono::steady_clock::now() - startTime;
+
+ bool delayHintTest = duration >= timeDelayInMs;
+ bool dataSizeTest = callbackSize >= dataDelayInBytes;
+
+ if (timeDelayInMs.count() > 0 && dataDelayInBytes > 0) {
+ ASSERT_TRUE(delayHintTest || dataSizeTest);
+ } else {
+ // if only one of time delay / data delay is configured, one of them
+ // holds true by default, so we want both assertions to be true.
+ ASSERT_TRUE(delayHintTest && dataSizeTest);
+ }
+
+ ASSERT_TRUE(mFilterTests.stopFilter(filterId));
+ }
+
ASSERT_TRUE(mFilterTests.closeFilter(filterId));
ASSERT_TRUE(mDemuxTests.closeDemux());
ASSERT_TRUE(mFrontendTests.closeFrontend());
}
+TEST_P(TunerFilterAidlTest, FilterDelayHintTest) {
+ description("Test filter time delay hint.");
+
+ for (const auto& obj : filterMap) {
+ testDelayHint(obj.second);
+ }
+}
+
TEST_P(TunerPlaybackAidlTest, PlaybackDataFlowWithTsSectionFilterTest) {
description("Feed ts data from playback and configure Ts section filter to get output");
if (!playback.support || playback.sectionFilterId.compare(emptyHardwareId) == 0) {
diff --git a/tv/tuner/aidl/vts/functional/VtsHalTvTunerTargetTest.h b/tv/tuner/aidl/vts/functional/VtsHalTvTunerTargetTest.h
index 13c5a80..7f80d90 100644
--- a/tv/tuner/aidl/vts/functional/VtsHalTvTunerTargetTest.h
+++ b/tv/tuner/aidl/vts/functional/VtsHalTvTunerTargetTest.h
@@ -140,6 +140,7 @@
void reconfigSingleFilterInDemuxTest(FilterConfig filterConf, FilterConfig filterReconf,
FrontendConfig frontendConf);
void testTimeFilter(TimeFilterConfig filterConf);
+ void testDelayHint(const FilterConfig& filterConf);
DemuxFilterType getLinkageFilterType(int bit) {
DemuxFilterType type;
diff --git a/tv/tuner/config/TunerTestingConfigAidlReaderV1_0.h b/tv/tuner/config/TunerTestingConfigAidlReaderV1_0.h
index 7ccf31a..b6cc5f8 100644
--- a/tv/tuner/config/TunerTestingConfigAidlReaderV1_0.h
+++ b/tv/tuner/config/TunerTestingConfigAidlReaderV1_0.h
@@ -96,6 +96,8 @@
AvStreamType streamType;
int32_t ipCid;
int32_t monitorEventTypes;
+ int timeDelayInMs = 0;
+ int dataDelayInBytes = 0;
bool operator<(const FilterConfig& /*c*/) const { return false; }
};
@@ -336,6 +338,12 @@
if (filterConfig.hasMonitorEventTypes()) {
filterMap[id].monitorEventTypes = (int32_t)filterConfig.getMonitorEventTypes();
}
+ if (filterConfig.hasTimeDelayInMs()) {
+ filterMap[id].timeDelayInMs = filterConfig.getTimeDelayInMs();
+ }
+ if (filterConfig.hasDataDelayInBytes()) {
+ filterMap[id].dataDelayInBytes = filterConfig.getDataDelayInBytes();
+ }
if (filterConfig.hasAvFilterSettings_optional()) {
auto av = filterConfig.getFirstAvFilterSettings_optional();
if (av->hasAudioStreamType_optional()) {
diff --git a/tv/tuner/config/api/current.txt b/tv/tuner/config/api/current.txt
index 6c637a4..db1d076 100644
--- a/tv/tuner/config/api/current.txt
+++ b/tv/tuner/config/api/current.txt
@@ -256,6 +256,7 @@
ctor public Filter();
method @Nullable public android.media.tuner.testing.configuration.V1_0.AvFilterSettings getAvFilterSettings_optional();
method @Nullable public java.math.BigInteger getBufferSize();
+ method @Nullable public java.math.BigInteger getDataDelayInBytes();
method @Nullable public String getId();
method @Nullable public android.media.tuner.testing.configuration.V1_0.IpFilterConfig getIpFilterConfig_optional();
method @Nullable public android.media.tuner.testing.configuration.V1_0.FilterMainTypeEnum getMainType();
@@ -264,9 +265,11 @@
method @Nullable public android.media.tuner.testing.configuration.V1_0.RecordFilterSettings getRecordFilterSettings_optional();
method @Nullable public android.media.tuner.testing.configuration.V1_0.SectionFilterSettings getSectionFilterSettings_optional();
method @Nullable public android.media.tuner.testing.configuration.V1_0.FilterSubTypeEnum getSubType();
+ method @Nullable public java.math.BigInteger getTimeDelayInMs();
method @Nullable public boolean getUseFMQ();
method public void setAvFilterSettings_optional(@Nullable android.media.tuner.testing.configuration.V1_0.AvFilterSettings);
method public void setBufferSize(@Nullable java.math.BigInteger);
+ method public void setDataDelayInBytes(@Nullable java.math.BigInteger);
method public void setId(@Nullable String);
method public void setIpFilterConfig_optional(@Nullable android.media.tuner.testing.configuration.V1_0.IpFilterConfig);
method public void setMainType(@Nullable android.media.tuner.testing.configuration.V1_0.FilterMainTypeEnum);
@@ -275,6 +278,7 @@
method public void setRecordFilterSettings_optional(@Nullable android.media.tuner.testing.configuration.V1_0.RecordFilterSettings);
method public void setSectionFilterSettings_optional(@Nullable android.media.tuner.testing.configuration.V1_0.SectionFilterSettings);
method public void setSubType(@Nullable android.media.tuner.testing.configuration.V1_0.FilterSubTypeEnum);
+ method public void setTimeDelayInMs(@Nullable java.math.BigInteger);
method public void setUseFMQ(@Nullable boolean);
}
diff --git a/tv/tuner/config/sample_tuner_vts_config_aidl_V1.xml b/tv/tuner/config/sample_tuner_vts_config_aidl_V1.xml
index 8a6229e..da77200 100644
--- a/tv/tuner/config/sample_tuner_vts_config_aidl_V1.xml
+++ b/tv/tuner/config/sample_tuner_vts_config_aidl_V1.xml
@@ -101,7 +101,7 @@
bufferSize="16777216" pid="257" useFMQ="false">
<recordFilterSettings tsIndexMask="1" scIndexType="NONE"/>
</filter>
- <filter id="FILTER_IP_IP_0" mainType="IP" subType="IP" bufferSize="16777216" useFMQ="false">
+ <filter id="FILTER_IP_IP_0" mainType="IP" subType="IP" bufferSize="16777216" useFMQ="false" timeDelayInMs="5000">
<ipFilterConfig ipCid="1">
<srcIpAddress isIpV4="true" ip="192 168 1 1"/>
<destIpAddress isIpV4="true" ip="192 168 1 1"/>
diff --git a/tv/tuner/config/tuner_testing_dynamic_configuration.xsd b/tv/tuner/config/tuner_testing_dynamic_configuration.xsd
index fc2827f..54cedfc 100644
--- a/tv/tuner/config/tuner_testing_dynamic_configuration.xsd
+++ b/tv/tuner/config/tuner_testing_dynamic_configuration.xsd
@@ -243,6 +243,10 @@
"bufferSize": the buffer size of the filter in hex.
"pid": the pid that would be used to configure the filter.
"useFMQ": if the filter uses FMQ.
+ "timeDelayInMs": the filter's time delay hint. 0 by default. Must not be
+ longer than 30 seconds.
+ "dataDelayInBytes": the filter's data delay hint. 0 by default. Configured data
+ size must be received within 30 seconds.
Each filter element also contains at most one type-related "filterSettings".
- The settings type should match the filter "subType" attribute.
@@ -274,6 +278,8 @@
<xs:attribute name="pid" type="xs:nonNegativeInteger" use="optional"/>
<xs:attribute name="useFMQ" type="xs:boolean" use="required"/>
<xs:attribute name="monitorEventTypes" type="monitoEvents" use="optional"/>
+ <xs:attribute name="timeDelayInMs" type="xs:nonNegativeInteger" use="optional"/>
+ <xs:attribute name="dataDelayInBytes" type="xs:nonNegativeInteger" use="optional"/>
</xs:complexType>
<!-- DVR SESSION -->
diff --git a/usb/1.0/default/Android.bp b/usb/1.0/default/Android.bp
index 5f56fe0..4bed2c7 100644
--- a/usb/1.0/default/Android.bp
+++ b/usb/1.0/default/Android.bp
@@ -21,11 +21,21 @@
default_applicable_licenses: ["hardware_interfaces_license"],
}
+filegroup {
+ name: "android.hardware.usb@1.0-service.xml",
+ srcs: ["android.hardware.usb@1.0-service.xml"],
+}
+
+filegroup {
+ name: "android.hardware.usb@1.0-service.rc",
+ srcs: ["android.hardware.usb@1.0-service.rc"],
+}
+
cc_binary {
name: "android.hardware.usb@1.0-service",
defaults: ["hidl_defaults"],
- init_rc: ["android.hardware.usb@1.0-service.rc"],
- vintf_fragments: ["android.hardware.usb@1.0-service.xml"],
+ init_rc: [":android.hardware.usb@1.0-service.rc"],
+ vintf_fragments: [":android.hardware.usb@1.0-service.xml"],
relative_install_path: "hw",
vendor: true,
srcs: [
diff --git a/usb/1.0/default/apex/Android.bp b/usb/1.0/default/apex/Android.bp
new file mode 100644
index 0000000..ee50fdf
--- /dev/null
+++ b/usb/1.0/default/apex/Android.bp
@@ -0,0 +1,59 @@
+// Copyright (C) 2021 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"],
+}
+
+apex_key {
+ name: "com.android.hardware.usb.key",
+ public_key: "com.android.hardware.usb.avbpubkey",
+ private_key: "com.android.hardware.usb.pem",
+}
+
+android_app_certificate {
+ name: "com.android.hardware.usb.certificate",
+ certificate: "com.android.hardware.usb",
+}
+
+genrule {
+ name: "com.android.hardware.usb.rc-gen",
+ srcs: [":android.hardware.usb@1.0-service.rc"],
+ out: ["com.android.hardware.usb.rc"],
+ cmd: "sed -E 's/\\/vendor/\\/apex\\/com.android.hardware.usb/' $(in) > $(out)",
+}
+
+prebuilt_etc {
+ name: "com.android.hardware.usb.rc",
+ src: ":com.android.hardware.usb.rc-gen",
+ installable: false,
+}
+
+apex {
+ name: "com.android.hardware.usb",
+ manifest: "manifest.json",
+ file_contexts: "file_contexts",
+ key: "com.android.hardware.usb.key",
+ certificate: ":com.android.hardware.usb.certificate",
+ updatable: false,
+ soc_specific: true,
+ use_vndk_as_stable: true,
+ binaries: ["android.hardware.usb@1.0-service"],
+ prebuilts: [
+ "com.android.hardware.usb.rc",
+ "android.hardware.usb.accessory.prebuilt.xml",
+ "android.hardware.usb.host.prebuilt.xml",
+ ],
+ vintf_fragments: [":android.hardware.usb@1.0-service.xml"],
+}
diff --git a/usb/1.0/default/apex/com.android.hardware.usb.avbpubkey b/usb/1.0/default/apex/com.android.hardware.usb.avbpubkey
new file mode 100644
index 0000000..0302d63
--- /dev/null
+++ b/usb/1.0/default/apex/com.android.hardware.usb.avbpubkey
Binary files differ
diff --git a/usb/1.0/default/apex/com.android.hardware.usb.pem b/usb/1.0/default/apex/com.android.hardware.usb.pem
new file mode 100644
index 0000000..e1e57da
--- /dev/null
+++ b/usb/1.0/default/apex/com.android.hardware.usb.pem
@@ -0,0 +1,51 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIIJKQIBAAKCAgEAwdimmHgIZHrep3H3YfVaNYEAGg45LUEPIiwHV6aIC9V7zjBS
+SftD30Z21jGyk7hmtas6WMI2vRBDNGrZWDgPeiEQoxXQinuU4Ug5S5X2F8LpWs0y
+ZeNFwQkqZwqGdQlkmy8upfb6T7rDxqRv+C0AtGP1r4r36+Xh5ld5stVaMK0UNhZt
+VW0nQAxyeJL3tm0zfiEA9Zu7FF2IyHm+bo9+eJ7WXfjiJfkclLgqlX3ec2cvVqAf
+NHisj18PEd/qtC64b+FnkgbsdHzWbo8HW5x4STkGXNnH+O3dvkWBX60MOfywfZFw
++yaz5mt7K+ft/V4UA7zKiAEFM+J1lND9/UMJnd0XMYYtcRQF8lmu4dlcjfbbAm0k
+VgoUEsizIeMPLrMj837uVloKKzIXmPsVsfMarP/MrX6TJfzdUhdm01pVO1g0wtHJ
+J3eYQsEnOI7RjL+uZDQvPWAnr71pvacn66PAJC1UPulEEla5lhd30RDItbJkngXp
+3UggW32ZOQt3Oc8P0eo9SCnBlHtCVr8wfxAbxCoPR9qIdX3azkQRqcKqGbBbPnkc
+hSCzeIofUkYGibfbZg4k1yY82xEqZuN7J1zycoGP4wyhXeRLTRWxfPR5dxxmQZaS
+67A1LWrYvAzF8Rd44VMRlI/Qk6zuBsL01j2dfBqit+le+viQmTYb3BpV+1kCAwEA
+AQKCAgAmSfX2LddyiXaLWo6DsePkp5tuihqvHqevl0TIAmPi+oMe4hqO9GueoZt9
+iYl9djILdkvrFkmbpKexpd1SeJhOBlPz8q4jfG+W5B41GOToIp7XSarHx1GS5I2U
+ltaiLX3KzVIIhDVDJF/hT7+yJKl7+DaiOu/nj5vEVMj8EvpinP1eBaYI9quHEi5W
+NKlrRjyikEBRQzZ7ulH3T1zXF87iYnVzUGLTH1aO5aW7q4YSA3KtSKmBQsjK9PrU
+DAefGY9iwgIkLOvtwm7UnbnVVZ3I0NO56WZ/e/SNzcrVLCg7F/eAhgbsBOQKAnbs
+4D35CuknJ9ZVcOYnLncNMw7IRMKULKYLAuLLN1X33y22qaVxYA42rq13mZrijlua
+CMQ2Ur+GNcq8OI3mRDO38yKeJ5b4885LQdlrXXyoGnSjlkU5n8U9Jw6q2rZGiWlk
+4Q71g+KUl0rtXSnFSIJLNTK6Cd3ETStxswLvvCvfLTrRQcO8f2SdVxblmsc9eCDs
+JUxz6Sahkpb9hsY8fozu6laXC/5Ezy0TinRgGjQM/DQqbXtFXgse56mDxzSho5oh
+Spy3X7Q/v4VUtrSKsEZEIEVWCpplzVULpHenCDbU58rHyEcS7ew+kwlfHC73iEhX
+HPujSIKvStO7yCEeY6IdhON8iVX34uvQeAgEe4+rehQHLZUg0QKCAQEA9AS3imKF
+yEt0yNRLcdXSqYkak+OM2kfhBBcLndCT7Terr6yluv/SkPGYjUbmr2XiygMv8IwO
+8f+KbWsNwYCaB22HVYVGL0oUYAlCvWhnia3Iwn6ZZuXuJv5mmfqt/GMlaIfohNLy
+zI2OlcpcAuRfNlenjNyd+inxwdXL28Z86kbabnUlijgqpu4KFOYOlxbTRv93IlfM
+Ico1pZkLS1glDMFLetF+IWq4zqpXrdgNUk1KX3sofOCfZQnlWFrrHbXJPCgPAtlv
+xP4dmJQgtWkWwxUlelfz34LcCUVX2aTlgKjuvgvyCt2ZPWixXbDtjsCBTn3xBhoY
+kDp2OyMC+d543QKCAQEAy11GpYOQvTMKbV07EmN9jTRYg7gRrxsT3Kd4Xy+NpIY8
+v6J5Keeppk9t6WBrJi2cQU/EoHcd3fRkWMnWMNorZDiCu34VG5bfa4pTqnSLdLC4
+/e5UHdHqCy9deAwhlHYWbAx0KnxXWGxkq05dXvQsVuOtAs528NcujnLpwDONQt5P
+e3RIZmOOjr+7rqGp3vA9SuNOINOQpeKxQT6GRGw4mlYofdwOPaE1wCsO8vQCNmCJ
+DEfdm+hWjTLAV2IBCfi5BKRsIAXrABPzkzDeLGDmaQkJTDpK8UQcrFnqItGeo+yl
+fDjxA0zAPWYGcyXcXbtvayX+zCk/SKwQABqUtaumrQKCAQEA0mdizwsGqd8OMsCC
+0QP64j4a0Zvqbqh9yCYK2Sfo9SkEe7SVLnm5WUtIK8EP1fs3ItK+ul454MZj2Nbv
+BINbzL3PbJk/HDV2/hveFS154UgcjD/XC9eEktDXLTvuW2ot7kUJ48V0n5YLdPMI
+hWHfCx9nlFkCSptyHp23aqhqOyOe4pFWLikh9c/Yl46K1BJVWKmcUtt7Y0NVIJWn
+HG9Dew0MhTkv1aaM9X4Bnh9l1SpZz5yFG7AfIGL5A0dZ5cNCYgF0eBN+gVBPuqk2
+ztVvUATizOwblwThr4jAKCU70sVXHj10lZPftwiXrt6I54brt/92HLnRpkMSgQk+
+Xq9KbQKCAQAXxPM47UPBmXGijr8UyyQlmPSvkJggi12q8LgVCA3aKQZ4r5jR2Q3v
+LmF+YZKkh7g3ugcValbHVoVUC2NJmnZv5FsDZx04eE3s1+Inji+ul+lHZM/YHGzq
+mcKnAWP7YkIEpv/850OeRi0OCL7JFmkITtwt88vbIouCgtPnbx8XrbxEhbbgoMpM
+zQQ2yRZ9xD6lviOnmpLRkMl/ArvWy39iKqfY7huMAIezylSY+QQ5LtdV5CB21JUp
+M8FfdUkBzVxyunUY2Rg6jhpuHcwaC8lihXfcvQN9Z6SiUHAZWb7dEg/VkSI6bIIb
+qw0d8FLtcbb4IxzA6CFJcTL9kB3JjiKRAoIBAQC15t3mQHb9iCM4P4U9fpR4syvN
+46vDMhtj3vejerzOro2R7UUCJDvT59DrCQvtKO/ZCyhdTyuyResu6r1vbwq3KWiB
+i0RIeW87cKgJRr6w+KivB+a805WfI9zNRz778b7ajEpBkOs4vRPWu6S1306tdvgM
+Dhj7GT9UFh/k7pNuoSbiuaPUqgZRP55nzgj/FoIN985wnxo/ugckSqZ1bFGFXhYt
+zfIdFvPkf1BlLCnLTE8yESsJ3P37Gfj2XRv9h2I2/8qAGZniKtbVWHlu+5LDJf6V
+x9VpDAH2ZQAqRC3za3gfTjMsglYi7mUDeMYlB4osURNt7jDtElEmsto7AAkI
+-----END RSA PRIVATE KEY-----
diff --git a/usb/1.0/default/apex/com.android.hardware.usb.pk8 b/usb/1.0/default/apex/com.android.hardware.usb.pk8
new file mode 100644
index 0000000..9f3f39b
--- /dev/null
+++ b/usb/1.0/default/apex/com.android.hardware.usb.pk8
Binary files differ
diff --git a/usb/1.0/default/apex/com.android.hardware.usb.x509.pem b/usb/1.0/default/apex/com.android.hardware.usb.x509.pem
new file mode 100644
index 0000000..210c30d
--- /dev/null
+++ b/usb/1.0/default/apex/com.android.hardware.usb.x509.pem
@@ -0,0 +1,34 @@
+-----BEGIN CERTIFICATE-----
+MIIF1TCCA70CFFEdsyLGoTRk+VIzqb6aDl1tXeuZMA0GCSqGSIb3DQEBCwUAMIGl
+MQswCQYDVQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91
+bnRhaW4gVmlldzEQMA4GA1UECgwHQW5kcm9pZDEQMA4GA1UECwwHQW5kcm9pZDEi
+MCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTEhMB8GA1UEAwwYY29t
+LmFuZHJvaWQuaGFyZHdhcmUudXNiMCAXDTIxMTExNzIyMzAwM1oYDzQ3NTkxMDE0
+MjIzMDAzWjCBpTELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFjAU
+BgNVBAcMDU1vdW50YWluIFZpZXcxEDAOBgNVBAoMB0FuZHJvaWQxEDAOBgNVBAsM
+B0FuZHJvaWQxIjAgBgkqhkiG9w0BCQEWE2FuZHJvaWRAYW5kcm9pZC5jb20xITAf
+BgNVBAMMGGNvbS5hbmRyb2lkLmhhcmR3YXJlLnVzYjCCAiIwDQYJKoZIhvcNAQEB
+BQADggIPADCCAgoCggIBAM2E0E9ubNU/or7r9UIcFrC4l7CeM0HwtwSjTUKV1Z9K
+7rPFoUPE3cQ+cResnWQay8IGnomLYptAIMe8sLCC83LwU1ucTihxX87qq2W3V14w
+U4AkqDzNvYqKiD3yz9WofKxcu7ut8+1O4Pvp11X8UXuy5kNzf8WGpGB04k6U6KtA
+q8+U8+4h9h1Uvhaa0AeG9Yp22LzRLTb3J+eCoGHJnjoXYsd9T/gvedyXKkuf0lWB
+b3Aor3/CQrpdCW2/iJbuASdBdfilpQShaagxy2wmQsYxnT8ZWf+tIDYjg3xqqVPl
+GChFwCQBdaTuLI/k9gbaXkSxuzRkp5wc/ELhYbkhIS25yefAF2C6num++AHQBh1+
+qO0fHztsK80c5cVoDPWu17/nP7y3QloRyLFUrL3hVW1RQaFwE2Hmv4H0UwVAsleU
+ZIsz2ifTjiSl/tnkFTx0I6BVk7T87QhO3WXN4v6VDYZKeD4gQYS0NfwplahejrFw
+s3EcwKgt6f0KlIpzoEQBmNQBXxsRgL31GWCwCszb7+VrTMzgUpO41R3PyewbeaZk
+S/SHyEOwyf0WIvnZhZ/5CNd9qirClu6jS8kdLvwC2qA25VqSPw126EX1e2xUqm02
+C/6c7JDVocuQhvsJOnnpZt68Iwgw9g/xLCLA9RszH9ccRctZqRnzHB1AjTrBOq0P
+AgMBAAEwDQYJKoZIhvcNAQELBQADggIBAELbSot2Io/JZIYLTxgeReI4lk1KUzf8
+fGlDNlRm+goxOHXWQgvXgiftwM9IOB+H+EtNHAA9Q6ojAmfRe6rZC4p0ZxWOamtR
+V+pQj0c6Zvx8HJPMQdyoHx538iNXM093s2wnf+QuACb3BnvkK7uuLGAlIzWdImtL
+DKKFN05nppViY04tGP5HgT57b7YGwdkEp6euCJcyWIKjlyEH/bwTWM8ws/Px6uhw
++5W2K7KrBsdRKPBF7qwXoS8Ak8pS5de9Xd7mbGBLaUtjsZ0pJbq0aFpuT0GbLWUm
+wiD5Ljq3ea/2GZxbHGiXQ2yNjFSd/jpuxDnnm99t7+HGw1v5Jld+hUVqXXfVNhWe
+hUKIv5TOk1nttNdsaLyDtxyt22JX7NnoPM0MqrkYwA8Xqrbv0VC8D/CVjiBC9Tce
+crhpCISNfQSkdEn/c+q/naFUvQy8oYqXkg1TjeGlcxwJOpGliYbbYT6VAwuI/ssI
+yX3Fkr8f5KhfN2aFnOpidknmLp9EyL2j5bxAtSD9xAHtczMn10uCUdLELjRB1L4f
+1qY+EjpIgK0NIFuEt9K5uZXirXq3K3eixKeJFNji3x/X8NgDALSdnT8JIlSg4DMg
+iWupLrQ9CSHMlgh5P43ALamiRIHQNqEwgj8OIGzsvQTSLbRjbPWYcDZa+Q1hosiA
+Fv7vjDI6oySM
+-----END CERTIFICATE-----
diff --git a/usb/1.0/default/apex/file_contexts b/usb/1.0/default/apex/file_contexts
new file mode 100644
index 0000000..bc84ac4
--- /dev/null
+++ b/usb/1.0/default/apex/file_contexts
@@ -0,0 +1,5 @@
+(/.*)? u:object_r:vendor_file:s0
+# Permission XMLs
+/etc/permissions(/.*)? u:object_r:vendor_configs_file:s0
+# binary
+/bin/hw/android\.hardware\.usb@1\.0-service u:object_r:hal_usb_default_exec:s0
\ No newline at end of file
diff --git a/usb/1.0/default/apex/manifest.json b/usb/1.0/default/apex/manifest.json
new file mode 100644
index 0000000..6a1095f
--- /dev/null
+++ b/usb/1.0/default/apex/manifest.json
@@ -0,0 +1,4 @@
+{
+ "name": "com.android.hardware.usb",
+ "version": 1
+}
diff --git a/uwb/aidl/aidl_api/android.hardware.uwb.fira_android/current/android/hardware/uwb/fira_android/UwbAndroidCapabilities.aidl b/uwb/aidl/aidl_api/android.hardware.uwb.fira_android/current/android/hardware/uwb/fira_android/UwbAndroidCapabilities.aidl
index 774133e..7e3be56 100644
--- a/uwb/aidl/aidl_api/android.hardware.uwb.fira_android/current/android/hardware/uwb/fira_android/UwbAndroidCapabilities.aidl
+++ b/uwb/aidl/aidl_api/android.hardware.uwb.fira_android/current/android/hardware/uwb/fira_android/UwbAndroidCapabilities.aidl
@@ -35,4 +35,5 @@
@Backing(type="long") @VintfStability
enum UwbAndroidCapabilities {
POWER_STATS_QUERY = 1,
+ ANTENNAE_INTERLEAVING = 2,
}
diff --git a/uwb/aidl/aidl_api/android.hardware.uwb.fira_android/current/android/hardware/uwb/fira_android/UwbVendorGidAndroidOids.aidl b/uwb/aidl/aidl_api/android.hardware.uwb.fira_android/current/android/hardware/uwb/fira_android/UwbVendorGidAndroidOids.aidl
index 4e3d4a2..cd2e122 100644
--- a/uwb/aidl/aidl_api/android.hardware.uwb.fira_android/current/android/hardware/uwb/fira_android/UwbVendorGidAndroidOids.aidl
+++ b/uwb/aidl/aidl_api/android.hardware.uwb.fira_android/current/android/hardware/uwb/fira_android/UwbVendorGidAndroidOids.aidl
@@ -35,4 +35,5 @@
@Backing(type="byte") @VintfStability
enum UwbVendorGidAndroidOids {
ANDROID_GET_POWER_STATS = 0,
+ ANDROID_SET_COUNTRY_CODE = 1,
}
diff --git a/uwb/aidl/aidl_api/android.hardware.uwb.fira_android/current/android/hardware/uwb/fira_android/UwbVendorSessionSetAppConfigCmdParams.aidl b/uwb/aidl/aidl_api/android.hardware.uwb.fira_android/current/android/hardware/uwb/fira_android/UwbVendorSessionSetAppConfigCmdParams.aidl
index 37b7efb..f449c60 100644
--- a/uwb/aidl/aidl_api/android.hardware.uwb.fira_android/current/android/hardware/uwb/fira_android/UwbVendorSessionSetAppConfigCmdParams.aidl
+++ b/uwb/aidl/aidl_api/android.hardware.uwb.fira_android/current/android/hardware/uwb/fira_android/UwbVendorSessionSetAppConfigCmdParams.aidl
@@ -38,4 +38,7 @@
CCC_UWB_CONFIG_ID = 164,
CCC_PULSESHAPE_COMBO = 165,
CCC_URSK_TTL = 166,
+ NB_OF_RANGE_MEASUREMENTS = 227,
+ NB_OF_AZIMUTH_MEASUREMENTS = 228,
+ NB_OF_ELEVATION_MEASUREMENTS = 229,
}
diff --git a/uwb/aidl/aidl_api/android.hardware.uwb/current/android/hardware/uwb/IUwbChip.aidl b/uwb/aidl/aidl_api/android.hardware.uwb/current/android/hardware/uwb/IUwbChip.aidl
index c4cb47b..c7708f1 100644
--- a/uwb/aidl/aidl_api/android.hardware.uwb/current/android/hardware/uwb/IUwbChip.aidl
+++ b/uwb/aidl/aidl_api/android.hardware.uwb/current/android/hardware/uwb/IUwbChip.aidl
@@ -40,6 +40,7 @@
void open(in android.hardware.uwb.IUwbClientCallback clientCallback);
void close();
void coreInit();
+ void sessionInit(int sessionId);
int getSupportedAndroidUciVersion();
long getSupportedAndroidCapabilities();
int sendUciMessage(in byte[] data);
diff --git a/uwb/aidl/android/hardware/uwb/IUwbChip.aidl b/uwb/aidl/android/hardware/uwb/IUwbChip.aidl
index 0c98611..f2bb0f1 100644
--- a/uwb/aidl/android/hardware/uwb/IUwbChip.aidl
+++ b/uwb/aidl/android/hardware/uwb/IUwbChip.aidl
@@ -50,6 +50,14 @@
void coreInit();
/**
+ * Perform any necessary UWB session initializations.
+ * This must be invoked by the framework at the beginging of every new ranging session.
+ *
+ * @param sessionId Session identifier as defined in the UCI specification.
+ */
+ void sessionInit(int sessionId);
+
+ /**
* Supported version of vendor UCI specification.
*
* @return Returns the version of the "android.hardware.uwb.fira_android" types-only
diff --git a/uwb/aidl/android/hardware/uwb/fira_android/UwbAndroidCapabilities.aidl b/uwb/aidl/android/hardware/uwb/fira_android/UwbAndroidCapabilities.aidl
index 3486d5a..0af99e0 100644
--- a/uwb/aidl/android/hardware/uwb/fira_android/UwbAndroidCapabilities.aidl
+++ b/uwb/aidl/android/hardware/uwb/fira_android/UwbAndroidCapabilities.aidl
@@ -26,6 +26,6 @@
@VintfStability
@Backing(type="long")
enum UwbAndroidCapabilities {
- /** TODO: Change the name if necessary when the corresponding vendor commands are added */
POWER_STATS_QUERY = 0x1,
+ ANTENNAE_INTERLEAVING = 0x2,
}
diff --git a/uwb/aidl/android/hardware/uwb/fira_android/UwbVendorGidAndroidOids.aidl b/uwb/aidl/android/hardware/uwb/fira_android/UwbVendorGidAndroidOids.aidl
index de4a2d8..1dfcd6f 100644
--- a/uwb/aidl/android/hardware/uwb/fira_android/UwbVendorGidAndroidOids.aidl
+++ b/uwb/aidl/android/hardware/uwb/fira_android/UwbVendorGidAndroidOids.aidl
@@ -27,4 +27,7 @@
// Supported only if the value returned by getSupportedAndroidCapabilities()
// has the bit of UwbAndroidCapabilities.POWER_STATS_QUERY set to 1.
ANDROID_GET_POWER_STATS = 0x0,
+ // Used to set the current regulatory country code (determined usinag
+ // SIM or hardcoded by OEM).
+ ANDROID_SET_COUNTRY_CODE = 0x1,
}
diff --git a/uwb/aidl/android/hardware/uwb/fira_android/UwbVendorSessionSetAppConfigCmdParams.aidl b/uwb/aidl/android/hardware/uwb/fira_android/UwbVendorSessionSetAppConfigCmdParams.aidl
index 850e2da..f5e02c0 100644
--- a/uwb/aidl/android/hardware/uwb/fira_android/UwbVendorSessionSetAppConfigCmdParams.aidl
+++ b/uwb/aidl/android/hardware/uwb/fira_android/UwbVendorSessionSetAppConfigCmdParams.aidl
@@ -29,9 +29,29 @@
enum UwbVendorSessionSetAppConfigCmdParams {
/** CCC params for ranging start */
- /** Added in vendor version 0. */
+ /**
+ * Added in vendor version 0.
+ * Range 0xA0 - 0xDF reserved for CCC use.
+ */
CCC_RANGING_PROTOCOL_VER = 0xA3,
CCC_UWB_CONFIG_ID = 0xA4,
CCC_PULSESHAPE_COMBO = 0xA5,
CCC_URSK_TTL = 0xA6,
+
+ /**
+ * Range 0xE3 - 0xFF is reserved for proprietary use in the FIRA spec.
+ * In Android, this range is reserved by the Android platform for Android-specific
+ * app config cmd params.
+ * Vendors must not define additional app config cmd params in this range.
+ */
+
+ /**
+ * Added in vendor version 0.
+ * Interleaving ratio if AOA_RESULT_REQ is set to 0xF0.
+ * Supported only if the value returned by getSupportedAndroidCapabilities()
+ * has the bit of UwbAndroidCapabilities.ANTENNAE_INTERLEAVING set to 1.
+ */
+ NB_OF_RANGE_MEASUREMENTS = 0xE3,
+ NB_OF_AZIMUTH_MEASUREMENTS = 0xE4,
+ NB_OF_ELEVATION_MEASUREMENTS = 0xE5,
}
diff --git a/uwb/aidl/default/uwb_chip.cpp b/uwb/aidl/default/uwb_chip.cpp
index 10dbdb6..a5a3f4a 100644
--- a/uwb/aidl/default/uwb_chip.cpp
+++ b/uwb/aidl/default/uwb_chip.cpp
@@ -51,6 +51,10 @@
return ndk::ScopedAStatus::ok();
}
+::ndk::ScopedAStatus UwbChip::sessionInit(int /* sessionId */) {
+ return ndk::ScopedAStatus::ok();
+}
+
::ndk::ScopedAStatus UwbChip::getSupportedAndroidUciVersion(int32_t* version) {
*version = kAndroidUciVersion;
return ndk::ScopedAStatus::ok();
diff --git a/uwb/aidl/default/uwb_chip.h b/uwb/aidl/default/uwb_chip.h
index ca97120..46cecd4 100644
--- a/uwb/aidl/default/uwb_chip.h
+++ b/uwb/aidl/default/uwb_chip.h
@@ -37,6 +37,7 @@
::ndk::ScopedAStatus open(const std::shared_ptr<IUwbClientCallback>& clientCallback) override;
::ndk::ScopedAStatus close() override;
::ndk::ScopedAStatus coreInit() override;
+ ::ndk::ScopedAStatus sessionInit(int sesionId) override;
::ndk::ScopedAStatus getSupportedAndroidUciVersion(int32_t* version) override;
::ndk::ScopedAStatus getSupportedAndroidCapabilities(int64_t* capabilities) override;
::ndk::ScopedAStatus sendUciMessage(const std::vector<uint8_t>& data,
diff --git a/uwb/aidl/vts/VtsHalUwbTargetTest.cpp b/uwb/aidl/vts/VtsHalUwbTargetTest.cpp
index 3820c0f..1da4432 100644
--- a/uwb/aidl/vts/VtsHalUwbTargetTest.cpp
+++ b/uwb/aidl/vts/VtsHalUwbTargetTest.cpp
@@ -166,6 +166,11 @@
EXPECT_TRUE(iuwb_chip->coreInit().isOk());
}
+TEST_P(UwbAidl, ChipSessionInit) {
+ const auto iuwb_chip = getAnyChipAndOpen();
+ EXPECT_TRUE(iuwb_chip->sessionInit(0).isOk());
+}
+
TEST_P(UwbAidl, ChipGetSupportedAndroidUciVersion) {
const auto iuwb_chip = getAnyChipAndOpen();
EXPECT_TRUE(iuwb_chip->coreInit().isOk());
diff --git a/weaver/aidl/default/Weaver.cpp b/weaver/aidl/default/Weaver.cpp
index 56d9c4d..6b77924 100644
--- a/weaver/aidl/default/Weaver.cpp
+++ b/weaver/aidl/default/Weaver.cpp
@@ -15,30 +15,52 @@
*/
#include "Weaver.h"
+#include <array>
namespace aidl {
namespace android {
namespace hardware {
namespace weaver {
+struct Slotinfo {
+ int slot_id;
+ std::vector<uint8_t> key;
+ std::vector<uint8_t> value;
+};
+
+std::array<struct Slotinfo, 16> slot_array;
// Methods from ::android::hardware::weaver::IWeaver follow.
::ndk::ScopedAStatus Weaver::getConfig(WeaverConfig* out_config) {
- (void)out_config;
+ *out_config = {16, 16, 16};
return ::ndk::ScopedAStatus::ok();
}
::ndk::ScopedAStatus Weaver::read(int32_t in_slotId, const std::vector<uint8_t>& in_key, WeaverReadResponse* out_response) {
- (void)in_slotId;
- (void)in_key;
- (void)out_response;
+
+ if (in_slotId > 15 || in_key.size() > 16) {
+ *out_response = {0, {}};
+ return ndk::ScopedAStatus(AStatus_fromServiceSpecificError(Weaver::STATUS_FAILED));
+ }
+
+ if (slot_array[in_slotId].key != in_key) {
+ *out_response = {0, {}};
+ return ndk::ScopedAStatus(AStatus_fromServiceSpecificError(Weaver::STATUS_INCORRECT_KEY));
+ }
+
+ *out_response = {0, slot_array[in_slotId].value};
+
return ::ndk::ScopedAStatus::ok();
}
::ndk::ScopedAStatus Weaver::write(int32_t in_slotId, const std::vector<uint8_t>& in_key, const std::vector<uint8_t>& in_value) {
- (void)in_slotId;
- (void)in_key;
- (void)in_value;
+
+ if (in_slotId > 15 || in_key.size() > 16 || in_value.size() > 16)
+ return ::ndk::ScopedAStatus::fromStatus(STATUS_FAILED_TRANSACTION);
+
+ slot_array[in_slotId].key = in_key;
+ slot_array[in_slotId].value = in_value;
+
return ::ndk::ScopedAStatus::ok();
}
diff --git a/wifi/.clang-format b/wifi/.clang-format
deleted file mode 100644
index 25ed932..0000000
--- a/wifi/.clang-format
+++ /dev/null
@@ -1,2 +0,0 @@
-BasedOnStyle: Google
-IndentWidth: 4
\ No newline at end of file
diff --git a/wifi/netlinkinterceptor/aidl/Android.bp b/wifi/netlinkinterceptor/aidl/Android.bp
new file mode 100644
index 0000000..924edee
--- /dev/null
+++ b/wifi/netlinkinterceptor/aidl/Android.bp
@@ -0,0 +1,36 @@
+//
+// Copyright (C) 2021 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 {
+ // See: http://go/android-license-faq
+ // A large-scale-change added 'default_applicable_licenses' to import
+ // all of the 'license_kinds' from "hardware_interfaces_license"
+ // to get the below license kinds:
+ // SPDX-license-identifier-Apache-2.0
+ default_applicable_licenses: ["hardware_interfaces_license"],
+}
+
+aidl_interface {
+ name: "android.hardware.net.nlinterceptor",
+ vendor_available: true,
+ srcs: ["android/hardware/net/nlinterceptor/*.aidl"],
+ stability: "vintf",
+ backend: {
+ java: {
+ enabled: false,
+ },
+ },
+}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl b/wifi/netlinkinterceptor/aidl/aidl_api/NetlinkInterceptor/current/android/hardware/net/nlinterceptor/IInterceptor.aidl
similarity index 76%
copy from graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
copy to wifi/netlinkinterceptor/aidl/aidl_api/NetlinkInterceptor/current/android/hardware/net/nlinterceptor/IInterceptor.aidl
index 41a1afe..249b343 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
+++ b/wifi/netlinkinterceptor/aidl/aidl_api/NetlinkInterceptor/current/android/hardware/net/nlinterceptor/IInterceptor.aidl
@@ -1,11 +1,11 @@
-/**
- * Copyright (c) 2021, The Android Open Source Project
+/*
+ * Copyright (C) 2021 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
+ * 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,
@@ -31,10 +31,11 @@
// 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.composer3;
+package android.hardware.net.nlinterceptor;
@VintfStability
-parcelable ExecuteCommandsStatus {
- boolean queueChanged;
- int length;
- android.hardware.common.NativeHandle[] handles;
+interface IInterceptor {
+ int createSocket(in int nlFamily, in int clientNlPid, in String clientName);
+ void closeSocket(in int nlFamily, in int interceptorNlPid);
+ void subscribeGroup(in int nlFamily, in int interceptorNlPid, in int nlGroup);
+ void unsubscribeGroup(in int nlFamily, in int interceptorNlPid, in int nlGroup);
}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl b/wifi/netlinkinterceptor/aidl/aidl_api/android.hardware.net.nlinterceptor/current/android/hardware/net/nlinterceptor/IInterceptor.aidl
similarity index 72%
copy from graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
copy to wifi/netlinkinterceptor/aidl/aidl_api/android.hardware.net.nlinterceptor/current/android/hardware/net/nlinterceptor/IInterceptor.aidl
index 41a1afe..3d0f955 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ExecuteCommandsStatus.aidl
+++ b/wifi/netlinkinterceptor/aidl/aidl_api/android.hardware.net.nlinterceptor/current/android/hardware/net/nlinterceptor/IInterceptor.aidl
@@ -1,11 +1,11 @@
-/**
- * Copyright (c) 2021, The Android Open Source Project
+/*
+ * Copyright (C) 2021 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
+ * 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,
@@ -31,10 +31,11 @@
// 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.composer3;
+package android.hardware.net.nlinterceptor;
@VintfStability
-parcelable ExecuteCommandsStatus {
- boolean queueChanged;
- int length;
- android.hardware.common.NativeHandle[] handles;
+interface IInterceptor {
+ android.hardware.net.nlinterceptor.InterceptedSocket createSocket(in int nlFamily, in int clientNlPid, in String clientName);
+ void closeSocket(in android.hardware.net.nlinterceptor.InterceptedSocket handle);
+ void subscribeGroup(in android.hardware.net.nlinterceptor.InterceptedSocket handle, in int nlGroup);
+ void unsubscribeGroup(in android.hardware.net.nlinterceptor.InterceptedSocket handle, in int nlGroup);
}
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/LayerRequest.aidl b/wifi/netlinkinterceptor/aidl/aidl_api/android.hardware.net.nlinterceptor/current/android/hardware/net/nlinterceptor/InterceptedSocket.aidl
similarity index 86%
copy from graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/LayerRequest.aidl
copy to wifi/netlinkinterceptor/aidl/aidl_api/android.hardware.net.nlinterceptor/current/android/hardware/net/nlinterceptor/InterceptedSocket.aidl
index cfafc50..b679be5 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/LayerRequest.aidl
+++ b/wifi/netlinkinterceptor/aidl/aidl_api/android.hardware.net.nlinterceptor/current/android/hardware/net/nlinterceptor/InterceptedSocket.aidl
@@ -1,11 +1,11 @@
-/**
- * Copyright (c) 2021, The Android Open Source Project
+/*
+ * Copyright (C) 2021 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
+ * 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,
@@ -31,8 +31,9 @@
// 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.composer3;
-@Backing(type="int") @VintfStability
-enum LayerRequest {
- CLEAR_CLIENT_TARGET = 1,
+package android.hardware.net.nlinterceptor;
+@VintfStability
+parcelable InterceptedSocket {
+ int nlFamily;
+ int portId;
}
diff --git a/wifi/netlinkinterceptor/aidl/android/hardware/net/nlinterceptor/IInterceptor.aidl b/wifi/netlinkinterceptor/aidl/android/hardware/net/nlinterceptor/IInterceptor.aidl
new file mode 100644
index 0000000..c222a1e
--- /dev/null
+++ b/wifi/netlinkinterceptor/aidl/android/hardware/net/nlinterceptor/IInterceptor.aidl
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2021 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.net.nlinterceptor;
+
+import android.hardware.net.nlinterceptor.InterceptedSocket;
+
+/**
+ * Netlink Interceptor
+ *
+ * This HAL provides a way for Android services to route their Netlink traffic to a location other
+ * than the Kernel. One might want to do this for a variety of reasons:
+ * -> Route Netlink traffic to a different host.
+ * -> Route Netlink traffic to a different VM.
+ * -> Convert Netlink commands into proprietary vendor hardware commands.
+ *
+ * Some important notes regarding Netlink Interceptor.
+ * -> All int values are treated as unsigned.
+ * -> Users of Netlink Interceptor must close their sockets with closeSocket manually.
+ * -> PID != process ID. In this case, it is "port ID", a unique number assigned by the kernel to a
+ * given Netlink socket.
+ * -> Netlink PIDs are only unique per family. This means that for all NETLINK_GENERIC sockets,
+ * there can only be one socket with PID "1234". HOWEVER, there can ALSO be a Netlink socket
+ * using NETLINK_ROUTE which has a PID of "1234". Hence, in order to uniquely identify a Netlink
+ * socket, both the PID and Netlink Family are required.
+ */
+@VintfStability
+interface IInterceptor {
+ /**
+ * Creates a Netlink socket on both the HU and TCU, and a bi-directional gRPC stream to carry
+ * data between them. This must be closed by the caller with closeSocket().
+ *
+ * @param nlFamily - Netlink Family. Support for families other than NETLINK_GENERIC is still
+ * experimental.
+ * @param clientNlPid - Port ID of the caller's Netlink socket.
+ * @param clientName - Human readable name of the caller. Used for debugging.
+ *
+ * @return InterceptedSocket identifying the socket on the HU allocated for the caller.
+ */
+ InterceptedSocket createSocket(in int nlFamily, in int clientNlPid, in String clientName);
+
+ /**
+ * Closes a socket and gRPC stream given the socket's identifier. This must be invoked manually
+ * by the caller of createSocket().
+ *
+ * @param handle - unique identifier for a socket returned by createSocket.
+ */
+ void closeSocket(in InterceptedSocket handle);
+
+ /**
+ * Subscribes a socket on the TCU to a Netlink multicast group.
+ *
+ * @param handle - unique identifier for a socket returned by createSocket.
+ * @param nlGroup - A single Netlink multicast group that the caller wants to subscribe to.
+ */
+ void subscribeGroup(in InterceptedSocket handle, in int nlGroup);
+
+ /**
+ * Unsubscribes a socket on the TCU from a Netlink multicast group.
+ *
+ * @param handle - unique identifier for a socket returned by createSocket.
+ * @param nlGroup - A single Netlink multicast group that the caller wants to unsubscribe from.
+ */
+ void unsubscribeGroup(in InterceptedSocket handle, in int nlGroup);
+}
diff --git a/wifi/netlinkinterceptor/aidl/android/hardware/net/nlinterceptor/InterceptedSocket.aidl b/wifi/netlinkinterceptor/aidl/android/hardware/net/nlinterceptor/InterceptedSocket.aidl
new file mode 100644
index 0000000..d74a556
--- /dev/null
+++ b/wifi/netlinkinterceptor/aidl/android/hardware/net/nlinterceptor/InterceptedSocket.aidl
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2021 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.net.nlinterceptor;
+
+/**
+ * Unique identifier for a Netlink socket.
+ */
+@VintfStability
+parcelable InterceptedSocket {
+ /**
+ * Netlink family of the identified socket
+ */
+ int nlFamily;
+
+ /**
+ * Netlink port ID of the identified socket.
+ */
+ int portId;
+}
diff --git a/wifi/netlinkinterceptor/aidl/default/Android.bp b/wifi/netlinkinterceptor/aidl/default/Android.bp
new file mode 100644
index 0000000..5227e51
--- /dev/null
+++ b/wifi/netlinkinterceptor/aidl/default/Android.bp
@@ -0,0 +1,48 @@
+//
+// Copyright (C) 2021 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 {
+ // See: http://go/android-license-faq
+ // A large-scale-change added 'default_applicable_licenses' to import
+ // all of the 'license_kinds' from "hardware_interfaces_license"
+ // to get the below license kinds:
+ // SPDX-license-identifier-Apache-2.0
+ default_applicable_licenses: ["hardware_interfaces_license"],
+}
+
+cc_binary {
+ name: "android.hardware.net.nlinterceptor-service.default",
+ init_rc: ["nlinterceptor-default.rc"],
+ vintf_fragments: ["nlinterceptor-default.xml"],
+ vendor: true,
+ relative_install_path: "hw",
+ defaults: ["nlinterceptor@defaults"],
+ shared_libs: [
+ "android.hardware.net.nlinterceptor-V1-ndk",
+ "libbase",
+ "libbinder_ndk",
+ ],
+ static_libs: [
+ "libnlinterceptor",
+ "libnl++",
+ ],
+ srcs: [
+ "InterceptorRelay.cpp",
+ "NetlinkInterceptor.cpp",
+ "service.cpp",
+ "util.cpp",
+ ],
+}
diff --git a/wifi/netlinkinterceptor/aidl/default/InterceptorRelay.cpp b/wifi/netlinkinterceptor/aidl/default/InterceptorRelay.cpp
new file mode 100644
index 0000000..ded9122
--- /dev/null
+++ b/wifi/netlinkinterceptor/aidl/default/InterceptorRelay.cpp
@@ -0,0 +1,129 @@
+/*
+ * Copyright (C) 2021 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 "InterceptorRelay.h"
+
+#include <android-base/logging.h>
+#include <libnl++/printer.h>
+#include <poll.h>
+
+#include <chrono>
+
+#include "util.h"
+
+namespace android::nlinterceptor {
+using namespace std::chrono_literals;
+
+static constexpr std::chrono::milliseconds kPollTimeout = 300ms;
+static constexpr bool kSuperVerbose = true;
+
+InterceptorRelay::InterceptorRelay(uint32_t nlFamily, uint32_t clientNlPid,
+ const std::string& clientName)
+ : mClientName(clientName),
+ mNlSocket(std::make_optional<nl::Socket>(nlFamily, 0, 0)),
+ mClientNlPid(clientNlPid) {}
+
+InterceptorRelay::~InterceptorRelay() {
+ mRunning = false;
+ if (mRelayThread.joinable()) mRelayThread.join();
+}
+
+uint32_t InterceptorRelay::getPid() {
+ auto pidMaybe = mNlSocket->getPid();
+ CHECK(pidMaybe.has_value()) << "Failed to get pid of nl::Socket!";
+ return *pidMaybe;
+}
+
+void InterceptorRelay::relayMessages() {
+ pollfd fds[] = {
+ mNlSocket->preparePoll(POLLIN),
+ };
+ while (mRunning) {
+ if (poll(fds, countof(fds), kPollTimeout.count()) < 0) {
+ PLOG(FATAL) << "poll failed";
+ return;
+ }
+ const auto nlsockEvents = fds[0].revents;
+
+ if (isSocketBad(nlsockEvents)) {
+ LOG(ERROR) << "Netlink socket is bad";
+ mRunning = false;
+ return;
+ }
+ if (!isSocketReadable(nlsockEvents)) continue;
+
+ const auto [msgMaybe, sa] = mNlSocket->receiveFrom();
+ if (!msgMaybe.has_value()) {
+ LOG(ERROR) << "Failed to receive Netlink data!";
+ mRunning = false;
+ return;
+ }
+ const auto msg = *msgMaybe;
+ if (!msg.firstOk()) {
+ LOG(ERROR) << "Netlink packet is malformed!";
+ // Test messages might be empty, this isn't fatal.
+ continue;
+ }
+ if constexpr (kSuperVerbose) {
+ LOG(VERBOSE) << "[" << mClientName
+ << "] nlMsg: " << nl::toString(msg, NETLINK_GENERIC);
+ }
+
+ uint32_t destinationPid = 0;
+ if (sa.nl_pid == 0) {
+ destinationPid = mClientNlPid;
+ }
+
+ if (!mNlSocket->send(msg, destinationPid)) {
+ LOG(ERROR) << "Failed to send Netlink message!";
+ mRunning = false;
+ return;
+ }
+ }
+ LOG(VERBOSE) << "[" << mClientName << "] Exiting relay thread!";
+}
+
+bool InterceptorRelay::start() {
+ if (mRunning) {
+ LOG(ERROR)
+ << "Can't relay messages: InterceptorRelay is already running!";
+ return false;
+ }
+ if (mRelayThread.joinable()) {
+ LOG(ERROR) << "relay thread is already running!";
+ return false;
+ }
+ if (!mNlSocket.has_value()) {
+ LOG(ERROR) << "Netlink socket not initialized!";
+ return false;
+ }
+
+ mRunning = true;
+ mRelayThread = std::thread(&InterceptorRelay::relayMessages, this);
+
+ LOG(VERBOSE) << "Relay threads initialized";
+ return true;
+}
+
+bool InterceptorRelay::subscribeGroup(uint32_t nlGroup) {
+ return mNlSocket->addMembership(nlGroup);
+}
+
+bool InterceptorRelay::unsubscribeGroup(uint32_t nlGroup) {
+ return mNlSocket->dropMembership(nlGroup);
+}
+
+} // namespace android::nlinterceptor
diff --git a/wifi/netlinkinterceptor/aidl/default/InterceptorRelay.h b/wifi/netlinkinterceptor/aidl/default/InterceptorRelay.h
new file mode 100644
index 0000000..0178c90
--- /dev/null
+++ b/wifi/netlinkinterceptor/aidl/default/InterceptorRelay.h
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 2021 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 <libnl++/Socket.h>
+
+#include <mutex>
+#include <thread>
+
+namespace android::nlinterceptor {
+
+class InterceptorRelay {
+ public:
+ /**
+ * Wrapper around the netlink socket and thread which relays messages.
+ *
+ * \param nlFamily - netlink family to use for the netlink socket.
+ * \param clientNlPid - pid of the client netlink socket.
+ * \param clientName - name of the client to be used for debugging.
+ */
+ InterceptorRelay(uint32_t nlFamily, uint32_t clientNlPid,
+ const std::string& clientName);
+
+ /**
+ * Stops the relay thread if running and destroys itself.
+ */
+ ~InterceptorRelay();
+
+ /**
+ * Returns the PID of the internal Netlink socket.
+ *
+ * \return value of PID,
+ */
+ uint32_t getPid();
+
+ /**
+ * Spawns relay thread.
+ */
+ bool start();
+
+ /**
+ * Subscribes the internal socket to a single Netlink multicast group.
+ *
+ * \param nlGroup - Netlink group to subscribe to.
+ * \returns - true for success, false for failure.
+ */
+ bool subscribeGroup(uint32_t nlGroup);
+
+ /**
+ * Unsubscribes the internal socket from a single Netlink multicast group.
+ *
+ * \param nlGroup - Netlink group to unsubscribe from.
+ * \returns - true for success, false for failure.
+ */
+ bool unsubscribeGroup(uint32_t nlGroup);
+
+ private:
+ std::string mClientName; ///< Name of client (Wificond, for example).
+ std::optional<nl::Socket> mNlSocket;
+ const uint32_t mClientNlPid = 0; ///< pid of client NL socket.
+
+ /**
+ * If set to true, the relay thread should be running. Setting this to false
+ * stops the relay thread.
+ */
+ std::atomic_bool mRunning = false;
+
+ /**
+ * Reads incoming Netlink messages destined for mNlSocket. If from the
+ * kernel, the message is relayed to the client specified in the
+ * constructor. Otherwise, the message is relayed to the kernel. This will
+ * run as long as mRunning is set to true.
+ */
+ void relayMessages();
+
+ std::thread mRelayThread;
+};
+
+} // namespace android::nlinterceptor
diff --git a/wifi/netlinkinterceptor/aidl/default/NetlinkInterceptor.cpp b/wifi/netlinkinterceptor/aidl/default/NetlinkInterceptor.cpp
new file mode 100644
index 0000000..908ecf2
--- /dev/null
+++ b/wifi/netlinkinterceptor/aidl/default/NetlinkInterceptor.cpp
@@ -0,0 +1,121 @@
+/*
+ * Copyright (C) 2021 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 "NetlinkInterceptor.h"
+
+#include <android-base/logging.h>
+#include <libnl++/Socket.h>
+
+namespace android::nlinterceptor {
+
+ndk::ScopedAStatus NetlinkInterceptor::createSocket(
+ int32_t nlFamilyAidl, int32_t clientNlPidAidl,
+ const std::string& clientName, AidlInterceptedSocket* interceptedSocket) {
+ auto nlFamily = static_cast<uint32_t>(nlFamilyAidl);
+ auto clientNlPid = static_cast<uint32_t>(clientNlPidAidl);
+ uint32_t interceptorNlPid = 0;
+
+ std::unique_ptr<InterceptorRelay> interceptor =
+ std::make_unique<InterceptorRelay>(nlFamily, clientNlPid, clientName);
+
+ interceptorNlPid = interceptor->getPid();
+
+ if (interceptorNlPid == 0) {
+ LOG(ERROR) << "Failed to create a Netlink socket for " << clientName
+ << ", " << nlFamily << ":" << clientNlPid;
+ return ndk::ScopedAStatus(AStatus_fromStatus(::android::UNKNOWN_ERROR));
+ }
+
+ if (mClientMap.find({nlFamily, interceptorNlPid}) != mClientMap.end()) {
+ LOG(ERROR) << "A socket with pid " << interceptorNlPid
+ << " already exists!";
+ return ndk::ScopedAStatus(AStatus_fromStatus(::android::UNKNOWN_ERROR));
+ }
+
+ if (!interceptor->start()) {
+ LOG(ERROR) << "Failed to start interceptor thread!";
+ return ndk::ScopedAStatus(AStatus_fromStatus(::android::UNKNOWN_ERROR));
+ }
+
+ if (!mClientMap
+ .emplace(InterceptedSocket(nlFamily, interceptorNlPid),
+ std::move(interceptor))
+ .second) {
+ // If this happens, it is very bad.
+ LOG(FATAL) << "Failed to insert interceptor instance with pid "
+ << interceptorNlPid << " into map!";
+ return ndk::ScopedAStatus(AStatus_fromStatus(::android::UNKNOWN_ERROR));
+ }
+
+ interceptedSocket->nlFamily = nlFamily;
+ interceptedSocket->portId = interceptorNlPid;
+
+ return ndk::ScopedAStatus::ok();
+}
+
+ndk::ScopedAStatus NetlinkInterceptor::closeSocket(
+ const AidlInterceptedSocket& interceptedSocket) {
+ InterceptedSocket sock(interceptedSocket);
+
+ auto interceptorIt = mClientMap.find(sock);
+ if (interceptorIt == mClientMap.end()) {
+ LOG(ERROR) << "closeSocket Failed! No such socket " << sock;
+ return ndk::ScopedAStatus(AStatus_fromStatus(::android::UNKNOWN_ERROR));
+ }
+ mClientMap.erase(interceptorIt);
+
+ return ndk::ScopedAStatus::ok();
+}
+
+ndk::ScopedAStatus NetlinkInterceptor::subscribeGroup(
+ const AidlInterceptedSocket& interceptedSocket, int32_t nlGroupAidl) {
+ InterceptedSocket sock(interceptedSocket);
+ auto nlGroup = static_cast<uint32_t>(nlGroupAidl);
+
+ auto interceptorIt = mClientMap.find(sock);
+ if (interceptorIt == mClientMap.end()) {
+ LOG(ERROR) << "subscribeGroup failed! No such socket " << sock;
+ return ndk::ScopedAStatus(AStatus_fromStatus(::android::UNKNOWN_ERROR));
+ }
+
+ auto& interceptor = interceptorIt->second;
+ if (!interceptor->subscribeGroup(nlGroup)) {
+ LOG(ERROR) << "Failed to subscribe " << sock << " to " << nlGroup;
+ return ndk::ScopedAStatus(AStatus_fromStatus(::android::UNKNOWN_ERROR));
+ }
+
+ return ndk::ScopedAStatus::ok();
+}
+
+ndk::ScopedAStatus NetlinkInterceptor::unsubscribeGroup(
+ const AidlInterceptedSocket& interceptedSocket, int32_t nlGroupAidl) {
+ InterceptedSocket sock(interceptedSocket);
+ auto nlGroup = static_cast<uint32_t>(nlGroupAidl);
+
+ auto interceptorIt = mClientMap.find(sock);
+ if (interceptorIt == mClientMap.end()) {
+ LOG(ERROR) << "unsubscribeGroup failed! No such socket " << sock;
+ return ndk::ScopedAStatus(AStatus_fromStatus(::android::UNKNOWN_ERROR));
+ }
+
+ auto& interceptor = interceptorIt->second;
+ if (!interceptor->unsubscribeGroup(nlGroup)) {
+ LOG(ERROR) << "Failed to unsubscribe " << sock << " from " << nlGroup;
+ return ndk::ScopedAStatus(AStatus_fromStatus(::android::UNKNOWN_ERROR));
+ }
+ return ndk::ScopedAStatus::ok();
+}
+} // namespace android::nlinterceptor
diff --git a/wifi/netlinkinterceptor/aidl/default/NetlinkInterceptor.h b/wifi/netlinkinterceptor/aidl/default/NetlinkInterceptor.h
new file mode 100644
index 0000000..8345654
--- /dev/null
+++ b/wifi/netlinkinterceptor/aidl/default/NetlinkInterceptor.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2021 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 <aidl/android/hardware/net/nlinterceptor/BnInterceptor.h>
+#include <libnlinterceptor/libnlinterceptor.h>
+
+#include <map>
+
+#include "InterceptorRelay.h"
+
+namespace android::nlinterceptor {
+
+class NetlinkInterceptor
+ : public ::aidl::android::hardware::net::nlinterceptor::BnInterceptor {
+ using ClientMap =
+ std::map<::android::nlinterceptor::InterceptedSocket,
+ std::unique_ptr<::android::nlinterceptor::InterceptorRelay>>;
+
+ using AidlInterceptedSocket =
+ ::aidl::android::hardware::net::nlinterceptor::InterceptedSocket;
+
+ public:
+ ndk::ScopedAStatus createSocket(
+ int32_t nlFamily, int32_t clientNlPid, const std::string& clientName,
+ AidlInterceptedSocket* interceptedSocket) override;
+
+ ndk::ScopedAStatus closeSocket(
+ const AidlInterceptedSocket& interceptedSocket) override;
+
+ ndk::ScopedAStatus subscribeGroup(
+ const AidlInterceptedSocket& interceptedSocket,
+ int32_t nlGroup) override;
+
+ ndk::ScopedAStatus unsubscribeGroup(
+ const AidlInterceptedSocket& interceptedSocket,
+ int32_t nlGroup) override;
+
+ private:
+ ClientMap mClientMap;
+};
+
+} // namespace android::nlinterceptor
diff --git a/wifi/netlinkinterceptor/aidl/default/OWNERS b/wifi/netlinkinterceptor/aidl/default/OWNERS
new file mode 100644
index 0000000..b738dac
--- /dev/null
+++ b/wifi/netlinkinterceptor/aidl/default/OWNERS
@@ -0,0 +1,2 @@
+chrisweir@google.com
+twasilczyk@google.com
diff --git a/wifi/netlinkinterceptor/aidl/default/nlinterceptor-default.rc b/wifi/netlinkinterceptor/aidl/default/nlinterceptor-default.rc
new file mode 100644
index 0000000..353cb27
--- /dev/null
+++ b/wifi/netlinkinterceptor/aidl/default/nlinterceptor-default.rc
@@ -0,0 +1,4 @@
+service nlinterceptor /vendor/bin/hw/android.hardware.net.nlinterceptor-service.default
+ class hal
+ user root
+ group system inet
diff --git a/wifi/netlinkinterceptor/aidl/default/nlinterceptor-default.xml b/wifi/netlinkinterceptor/aidl/default/nlinterceptor-default.xml
new file mode 100644
index 0000000..d7d257e
--- /dev/null
+++ b/wifi/netlinkinterceptor/aidl/default/nlinterceptor-default.xml
@@ -0,0 +1,9 @@
+<manifest version="1.0" type="device">
+ <hal format="aidl">
+ <name>android.hardware.net.nlinterceptor</name>
+ <interface>
+ <name>IInterceptor</name>
+ <instance>default</instance>
+ </interface>
+ </hal>
+</manifest>
diff --git a/wifi/netlinkinterceptor/aidl/default/service.cpp b/wifi/netlinkinterceptor/aidl/default/service.cpp
new file mode 100644
index 0000000..2aec3a5
--- /dev/null
+++ b/wifi/netlinkinterceptor/aidl/default/service.cpp
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <android-base/logging.h>
+#include <android/binder_manager.h>
+#include <android/binder_process.h>
+
+#include "NetlinkInterceptor.h"
+
+namespace android::nlinterceptor {
+using namespace std::string_literals;
+
+static void service() {
+ base::SetDefaultTag("nlinterceptor");
+ base::SetMinimumLogSeverity(base::VERBOSE);
+ LOG(DEBUG) << "Netlink Interceptor service starting...";
+
+ // TODO(202549296): Sometimes this causes an Address Sanitizer error.
+ auto interceptor = ndk::SharedRefBase::make<NetlinkInterceptor>();
+ const auto instance = NetlinkInterceptor::descriptor + "/default"s;
+ const auto status = AServiceManager_addService(
+ interceptor->asBinder().get(), instance.c_str());
+ CHECK(status == STATUS_OK);
+
+ ABinderProcess_joinThreadPool();
+ LOG(FATAL) << "Netlink Interceptor has stopped";
+}
+
+} // namespace android::nlinterceptor
+
+int main() {
+ ::android::nlinterceptor::service();
+ return 0;
+}
diff --git a/wifi/netlinkinterceptor/aidl/default/util.cpp b/wifi/netlinkinterceptor/aidl/default/util.cpp
new file mode 100644
index 0000000..c734747
--- /dev/null
+++ b/wifi/netlinkinterceptor/aidl/default/util.cpp
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2021 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 "util.h"
+
+#include <poll.h>
+
+namespace android::nlinterceptor {
+
+bool isSocketReadable(const short revents) { return 0 != (revents & POLLIN); }
+
+bool isSocketBad(const short revents) {
+ return 0 != (revents & (POLLERR | POLLHUP | POLLNVAL));
+}
+
+} // namespace android::nlinterceptor
diff --git a/wifi/netlinkinterceptor/aidl/default/util.h b/wifi/netlinkinterceptor/aidl/default/util.h
new file mode 100644
index 0000000..9b8ec63
--- /dev/null
+++ b/wifi/netlinkinterceptor/aidl/default/util.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2021 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 <android-base/macros.h>
+
+#include <functional>
+
+namespace android::nlinterceptor {
+
+/**
+ * Handy-dandy helper to get the size of a statically initialized array.
+ *
+ * \param N the array to get the size of.
+ * \return the size of the array.
+ */
+template <typename T, size_t N>
+size_t countof(T (&)[N]) {
+ return N;
+}
+
+/**
+ * Helper to check if socket is readable (POLLIN is set).
+ *
+ * \param revents pollfd.revents value to check.
+ * \return true if socket is ready to read.
+ */
+bool isSocketReadable(short revents);
+
+/**
+ * Helper to check if socket is bad (POLLERR, POLLHUP or POLLNVAL is set).
+ *
+ * \param revents pollfd.revents value to check.
+ * \return true if socket is bad.
+ */
+bool isSocketBad(short revents);
+
+} // namespace android::nlinterceptor
diff --git a/wifi/netlinkinterceptor/libnlinterceptor/Android.bp b/wifi/netlinkinterceptor/libnlinterceptor/Android.bp
new file mode 100644
index 0000000..00cae32
--- /dev/null
+++ b/wifi/netlinkinterceptor/libnlinterceptor/Android.bp
@@ -0,0 +1,65 @@
+//
+// Copyright (C) 2021 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 {
+ // See: http://go/android-license-faq
+ // A large-scale-change added 'default_applicable_licenses' to import
+ // all of the 'license_kinds' from "hardware_interfaces_license"
+ // to get the below license kinds:
+ // SPDX-license-identifier-Apache-2.0
+ default_applicable_licenses: ["hardware_interfaces_license"],
+}
+
+cc_defaults {
+ name: "nlinterceptor@defaults",
+ cpp_std: "experimental",
+ cflags: [
+ "-Wall",
+ "-Wextra",
+ "-Wsuggest-override",
+ "-Werror",
+ ],
+ shared_libs: [
+ "libbase",
+ "libutils",
+ ],
+ sanitize: {
+ address: true,
+ undefined: true,
+ all_undefined: true,
+ fuzzer: true,
+ cfi: true,
+ integer_overflow: true,
+ scs: true,
+ },
+ strip: {
+ keep_symbols_and_debug_frame: true,
+ },
+}
+
+cc_library_static {
+ name: "libnlinterceptor",
+ defaults: ["nlinterceptor@defaults"],
+ vendor_available: true,
+ shared_libs: [
+ "android.hardware.net.nlinterceptor-V1-ndk",
+ "libbinder_ndk",
+ ],
+ srcs: [
+ "libnlinterceptor.cpp",
+ ],
+ export_include_dirs: ["include"],
+}
diff --git a/wifi/netlinkinterceptor/libnlinterceptor/include/libnlinterceptor/libnlinterceptor.h b/wifi/netlinkinterceptor/libnlinterceptor/include/libnlinterceptor/libnlinterceptor.h
new file mode 100644
index 0000000..ac8653e
--- /dev/null
+++ b/wifi/netlinkinterceptor/libnlinterceptor/include/libnlinterceptor/libnlinterceptor.h
@@ -0,0 +1,131 @@
+/*
+ * Copyright (C) 2021 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
+
+#ifdef __cplusplus
+
+#include <aidl/android/hardware/net/nlinterceptor/InterceptedSocket.h>
+#include <android-base/unique_fd.h>
+#include <linux/netlink.h>
+
+#include <optional>
+#include <string>
+
+namespace android::nlinterceptor {
+
+/**
+ * Wrapper structure to uniquely identifies a socket that Netlink Interceptor
+ * has allocated for us.
+ */
+struct InterceptedSocket {
+ uint32_t nlFamily;
+ uint32_t portId;
+
+ InterceptedSocket(
+ ::aidl::android::hardware::net::nlinterceptor::InterceptedSocket sock);
+ InterceptedSocket(uint32_t nlFamily, uint32_t portId);
+
+ bool operator<(const InterceptedSocket& other) const;
+ operator sockaddr_nl() const;
+ operator ::aidl::android::hardware::net::nlinterceptor::InterceptedSocket()
+ const;
+};
+
+/**
+ * Output stream operator for InterceptedSocket
+ */
+std::ostream& operator<<(std::ostream& os, const InterceptedSocket& sock);
+
+/**
+ * Checks if an instance Netlink Interceptor exists.
+ *
+ * \return true if supported, false if not.
+ */
+bool isEnabled();
+
+/**
+ * Asks Netlink Interceptor to allocate a socket to which we can send Netlink
+ * traffic.
+ *
+ * \param clientSocket - File descriptor for the client's Netlink socket.
+ * \param clientName - Human readable name of the client application.
+ * \return Identifier for the socket created by Netlink Interceptor, nullopt on
+ * error.
+ */
+std::optional<InterceptedSocket> createSocket(base::borrowed_fd clientSocket,
+ const std::string& clientName);
+
+/**
+ * Asks Netlink Interceptor to close a socket that it created for us previously,
+ * if it exists.
+ *
+ * \param sock - Identifier for the socket created by Netlink Interceptor.
+ */
+void closeSocket(const InterceptedSocket& sock);
+
+/**
+ * Asks Netlink Interceptor to subscribe a socket that it created for us
+ * previously to a specified multicast group.
+ *
+ * \param sock - Identifier for the socket created by Netlink Interceptor.
+ * \param group - A single Netlink multicast group for which we would like to
+ * receive events.
+ * \return true for success, false if something went wrong.
+ */
+bool subscribe(const InterceptedSocket& sock, uint32_t group);
+
+/**
+ * Asks Netlink Interceptor to unsubscribe a socket that it created for us
+ * previously from a specified multicast group.
+ *
+ * \param sock - Identifier for the socket created by Netlink Interceptor.
+ * \param group - A single Netlink multicast group for which we no longer wish
+ * to receive events.
+ * \return true for success, false if something went wrong.
+ */
+bool unsubscribe(const InterceptedSocket& sock, uint32_t group);
+} // namespace android::nlinterceptor
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// C wrappers for libnlinterceptor
+struct android_nlinterceptor_InterceptedSocket {
+ uint32_t nlFamily;
+ uint32_t portId;
+};
+
+bool android_nlinterceptor_isEnabled();
+
+bool android_nlinterceptor_createSocket(
+ int clientSocketFd, const char* clientName,
+ struct android_nlinterceptor_InterceptedSocket* interceptedSocket);
+
+void android_nlinterceptor_closeSocket(
+ const struct android_nlinterceptor_InterceptedSocket* sock);
+
+bool android_nlinterceptor_subscribe(
+ const struct android_nlinterceptor_InterceptedSocket* sock, uint32_t group);
+
+bool android_nlinterceptor_unsubscribe(
+ const struct android_nlinterceptor_InterceptedSocket* sock, uint32_t group);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/wifi/netlinkinterceptor/libnlinterceptor/libnlinterceptor.cpp b/wifi/netlinkinterceptor/libnlinterceptor/libnlinterceptor.cpp
new file mode 100644
index 0000000..575f900
--- /dev/null
+++ b/wifi/netlinkinterceptor/libnlinterceptor/libnlinterceptor.cpp
@@ -0,0 +1,174 @@
+/*
+ * Copyright (C) 2021 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/net/nlinterceptor/IInterceptor.h>
+#include <android-base/logging.h>
+#include <android-base/macros.h>
+#include <android/binder_manager.h>
+#include <libnlinterceptor/libnlinterceptor.h>
+#include <linux/netlink.h>
+
+#include <mutex>
+
+namespace android::nlinterceptor {
+using namespace std::string_literals;
+using namespace ::aidl::android::hardware::net::nlinterceptor;
+using base::borrowed_fd;
+using AidlInterceptedSocket =
+ ::aidl::android::hardware::net::nlinterceptor::InterceptedSocket;
+
+static const auto kServiceName = IInterceptor::descriptor + "/default"s;
+
+InterceptedSocket::InterceptedSocket(
+ ::aidl::android::hardware::net::nlinterceptor::InterceptedSocket sock)
+ : nlFamily(sock.nlFamily), portId(sock.portId) {}
+
+InterceptedSocket::InterceptedSocket(uint32_t nlFamily, uint32_t portId)
+ : nlFamily(nlFamily), portId(portId) {}
+
+std::ostream& operator<<(std::ostream& os, const InterceptedSocket& sock) {
+ return os << "family: " << sock.nlFamily << ", portId: " << sock.portId;
+}
+
+bool InterceptedSocket::operator<(const InterceptedSocket& other) const {
+ if (nlFamily != other.nlFamily) {
+ return nlFamily < other.nlFamily;
+ }
+ return portId < other.portId;
+}
+
+InterceptedSocket::operator sockaddr_nl() const {
+ return {
+ .nl_family = AF_NETLINK,
+ .nl_pad = 0,
+ .nl_pid = portId,
+ .nl_groups = 0,
+ };
+}
+
+InterceptedSocket::operator AidlInterceptedSocket() const {
+ return {
+ .nlFamily = static_cast<int32_t>(nlFamily),
+ .portId = static_cast<int32_t>(portId),
+ };
+}
+
+bool isEnabled() {
+ static std::mutex supportedMutex;
+ static std::optional<bool> interceptorSupported;
+ // Avoid querying service manager when we can cache the result.
+ if (interceptorSupported.has_value()) return *interceptorSupported;
+ std::lock_guard lock(supportedMutex);
+ if (interceptorSupported.has_value()) return *interceptorSupported;
+
+ if (!AServiceManager_isDeclared(kServiceName.c_str())) {
+ interceptorSupported = false;
+ return false;
+ }
+ interceptorSupported = true;
+ return true;
+}
+
+static IInterceptor& getInstance() {
+ static std::mutex instanceMutex;
+ static std::shared_ptr<IInterceptor> interceptorInstance;
+ CHECK(isEnabled()) << "Can't getInstance! Interceptor not supported!";
+ // Don't overwrite the pointer once we've acquired it.
+ if (interceptorInstance != nullptr) return *interceptorInstance;
+ std::lock_guard lock(instanceMutex);
+ if (interceptorInstance != nullptr) return *interceptorInstance;
+ interceptorInstance = IInterceptor::fromBinder(
+ ndk::SpAIBinder(AServiceManager_waitForService(kServiceName.c_str())));
+ CHECK(interceptorInstance != nullptr)
+ << "Failed to get Netlink Interceptor service!";
+ return *interceptorInstance;
+}
+
+std::optional<InterceptedSocket> createSocket(borrowed_fd clientSocket,
+ const std::string& clientName) {
+ sockaddr_nl nladdr = {};
+ socklen_t nlsize = sizeof(nladdr);
+ if (getsockname(clientSocket.get(), reinterpret_cast<sockaddr*>(&nladdr),
+ &nlsize) < 0) {
+ PLOG(ERROR) << "Failed to get pid of fd passed by " << clientName;
+ return std::nullopt;
+ }
+
+ ::aidl::android::hardware::net::nlinterceptor::InterceptedSocket
+ interceptedSocket;
+ auto aidlStatus = getInstance().createSocket(
+ nladdr.nl_family, nladdr.nl_pid, clientName, &interceptedSocket);
+ if (!aidlStatus.isOk()) {
+ return std::nullopt;
+ }
+
+ return InterceptedSocket{nladdr.nl_family,
+ uint32_t(interceptedSocket.portId)};
+}
+
+void closeSocket(const InterceptedSocket& sock) {
+ auto aidlStatus = getInstance().closeSocket(sock);
+ if (!aidlStatus.isOk()) {
+ LOG(ERROR) << "Failed to close socket with pid = " << sock.portId;
+ }
+}
+
+bool subscribe(const InterceptedSocket& sock, uint32_t group) {
+ auto aidlStatus = getInstance().subscribeGroup(sock, group);
+ return aidlStatus.isOk();
+}
+
+bool unsubscribe(const InterceptedSocket& sock, uint32_t group) {
+ auto aidlStatus = getInstance().unsubscribeGroup(sock, group);
+ return aidlStatus.isOk();
+}
+
+extern "C" bool android_nlinterceptor_isEnabled() { return isEnabled(); }
+
+extern "C" bool android_nlinterceptor_createSocket(
+ int clientSocketFd, const char* clientName,
+ android_nlinterceptor_InterceptedSocket* interceptedSocket) {
+ if (!clientName || clientSocketFd <= 0) return false;
+ const auto maybeSocket =
+ createSocket(borrowed_fd(clientSocketFd), clientName);
+ if (!maybeSocket) return false;
+ *interceptedSocket = {.nlFamily = maybeSocket->nlFamily,
+ .portId = maybeSocket->portId};
+ return true;
+}
+
+extern "C" void android_nlinterceptor_closeSocket(
+ const android_nlinterceptor_InterceptedSocket* sock) {
+ if (!sock) {
+ LOG(ERROR) << "Can't close socket identified by a null pointer!";
+ return;
+ }
+ closeSocket({sock->nlFamily, sock->portId});
+}
+
+extern "C" bool android_nlinterceptor_subscribe(
+ const android_nlinterceptor_InterceptedSocket* sock, uint32_t group) {
+ if (!sock) return false;
+ return subscribe({sock->nlFamily, sock->portId}, group);
+}
+
+extern "C" bool android_nlinterceptor_unsubscribe(
+ const android_nlinterceptor_InterceptedSocket* sock, uint32_t group) {
+ if (!sock) return false;
+ return unsubscribe({sock->nlFamily, sock->portId}, group);
+}
+
+} // namespace android::nlinterceptor
diff --git a/wifi/netlinkinterceptor/vts/OWNERS b/wifi/netlinkinterceptor/vts/OWNERS
new file mode 100644
index 0000000..b738dac
--- /dev/null
+++ b/wifi/netlinkinterceptor/vts/OWNERS
@@ -0,0 +1,2 @@
+chrisweir@google.com
+twasilczyk@google.com
diff --git a/wifi/netlinkinterceptor/vts/functional/Android.bp b/wifi/netlinkinterceptor/vts/functional/Android.bp
new file mode 100644
index 0000000..33284e8
--- /dev/null
+++ b/wifi/netlinkinterceptor/vts/functional/Android.bp
@@ -0,0 +1,51 @@
+//
+// Copyright (C) 2021 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 {
+ // See: http://go/android-license-faq
+ // A large-scale-change added 'default_applicable_licenses' to import
+ // all of the 'license_kinds' from "hardware_interfaces_license"
+ // to get the below license kinds:
+ // SPDX-license-identifier-Apache-2.0
+ default_applicable_licenses: ["hardware_interfaces_license"],
+}
+
+cc_test {
+ name: "VtsHalNetlinkInterceptorV1_0Test",
+ defaults: [
+ "VtsHalTargetTestDefaults",
+ "use_libaidlvintf_gtest_helper_static",
+ ],
+ cpp_std: "experimental",
+ srcs: [
+ "interceptor_aidl_test.cpp",
+ ],
+ shared_libs: [
+ "android.hardware.net.nlinterceptor-V1-ndk",
+ "libbase",
+ "libbinder_ndk",
+ ],
+ static_libs: [
+ "libgmock",
+ "android.hardware.automotive.can@libnetdevice",
+ "libnl++",
+ ],
+ test_suites: [
+ "general-tests",
+ "vts",
+ ],
+ disable_framework: true,
+}
diff --git a/wifi/netlinkinterceptor/vts/functional/interceptor_aidl_test.cpp b/wifi/netlinkinterceptor/vts/functional/interceptor_aidl_test.cpp
new file mode 100644
index 0000000..b26d8ec
--- /dev/null
+++ b/wifi/netlinkinterceptor/vts/functional/interceptor_aidl_test.cpp
@@ -0,0 +1,195 @@
+/*
+ * Copyright (C) 2021 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/net/nlinterceptor/IInterceptor.h>
+#include <android-base/logging.h>
+#include <android/binder_manager.h>
+#include <gtest/gtest.h>
+#include <libnetdevice/libnetdevice.h>
+#include <libnl++/MessageFactory.h>
+#include <libnl++/Socket.h>
+#include <libnl++/printer.h>
+#include <linux/netlink.h>
+#include <linux/rtnetlink.h>
+
+#include <chrono>
+#include <thread>
+
+using aidl::android::hardware::net::nlinterceptor::IInterceptor;
+using AidlInterceptedSocket =
+ ::aidl::android::hardware::net::nlinterceptor::InterceptedSocket;
+using namespace std::chrono_literals;
+using namespace std::string_literals;
+
+class InterceptorAidlTest : public ::testing::TestWithParam<std::string> {
+ public:
+ virtual void SetUp() override {
+ android::base::SetDefaultTag("InterceptorAidlTest");
+ android::base::SetMinimumLogSeverity(android::base::VERBOSE);
+ const auto instance = IInterceptor::descriptor + "/default"s;
+ mNlInterceptorService = IInterceptor::fromBinder(
+ ndk::SpAIBinder(AServiceManager_getService(instance.c_str())));
+
+ ASSERT_NE(mNlInterceptorService, nullptr);
+ mSocket = std::make_unique<android::nl::Socket>(NETLINK_ROUTE);
+ ASSERT_TRUE(mSocket->getPid().has_value());
+
+ // If the test broke last run, clean up our mess, don't worry about "no
+ // such device".
+ if (android::netdevice::del(mTestIfaceName)) {
+ LOG(WARNING) << "Test interface wasn't cleaned up on previous run!";
+ }
+ }
+
+ void multicastReceiver();
+
+ std::shared_ptr<IInterceptor> mNlInterceptorService;
+ std::unique_ptr<android::nl::Socket> mSocket;
+ bool mRunning;
+ bool mGotMulticast;
+ const std::string mTestIfaceName = "interceptorvts0";
+};
+
+TEST_P(InterceptorAidlTest, createSocketTest) {
+ // Ask IInterceptor for a socket.
+ AidlInterceptedSocket interceptedSocket;
+ auto aidlStatus = mNlInterceptorService->createSocket(
+ NETLINK_ROUTE, *(mSocket->getPid()), "createSocketTest",
+ &interceptedSocket);
+ ASSERT_TRUE(aidlStatus.isOk());
+ ASSERT_NE(interceptedSocket.portId, 0);
+ uint32_t interceptorPid = interceptedSocket.portId;
+
+ // Ask the kernel to tell us what interfaces are available.
+ android::nl::MessageFactory<rtgenmsg> req(RTM_GETLINK,
+ NLM_F_REQUEST | NLM_F_DUMP);
+ req->rtgen_family = AF_PACKET;
+ sockaddr_nl sa = {.nl_family = AF_NETLINK,
+ .nl_pad = 0,
+ .nl_pid = interceptorPid,
+ .nl_groups = 0};
+ EXPECT_TRUE(mSocket->send(req, sa));
+
+ // We'll likely get back several messages, as indicated by the MULTI flag.
+ unsigned received = 0;
+ for (const auto msg : *mSocket) {
+ ASSERT_NE(msg->nlmsg_type, NLMSG_ERROR);
+ ++received;
+ break;
+ if (msg->nlmsg_type == NLMSG_DONE) {
+ // TODO(202548749): NLMSG_DONE on NETLINK_ROUTE doesn't work?
+ break;
+ }
+ }
+ ASSERT_GE(received, 1);
+
+ // Close the socket and make sure it's stopped working.
+ aidlStatus = mNlInterceptorService->closeSocket(interceptedSocket);
+ EXPECT_TRUE(aidlStatus.isOk());
+ EXPECT_FALSE(mSocket->send(req, sa));
+}
+
+static bool isSocketReadable(const short revents) {
+ return 0 != (revents & POLLIN);
+}
+
+static bool isSocketBad(const short revents) {
+ return 0 != (revents & (POLLERR | POLLHUP | POLLNVAL));
+}
+
+void InterceptorAidlTest::multicastReceiver() {
+ pollfd fds[] = {
+ mSocket->preparePoll(POLLIN),
+ };
+ while (mRunning) {
+ if (poll(fds, 1, 300) < 0) {
+ PLOG(FATAL) << "poll failed";
+ return;
+ }
+ const auto nlsockEvents = fds[0].revents;
+ ASSERT_FALSE(isSocketBad(nlsockEvents));
+ if (!isSocketReadable(nlsockEvents)) continue;
+
+ const auto [msgMaybe, sa] = mSocket->receiveFrom();
+ ASSERT_TRUE(msgMaybe.has_value());
+ auto msg = *msgMaybe;
+
+ // Multicast messages have 0 for their pid and sequence number.
+ if (msg->nlmsg_pid == 0 && msg->nlmsg_seq == 0) {
+ mGotMulticast = true;
+ }
+ }
+}
+
+TEST_P(InterceptorAidlTest, subscribeGroupTest) {
+ // Ask IInterceptor for a socket.
+ AidlInterceptedSocket interceptedSocket;
+ auto aidlStatus = mNlInterceptorService->createSocket(
+ NETLINK_ROUTE, *(mSocket->getPid()), "subscribeGroupTest",
+ &interceptedSocket);
+ ASSERT_TRUE(aidlStatus.isOk());
+ ASSERT_TRUE(interceptedSocket.portId != 0);
+
+ // Listen for interface up/down events.
+ aidlStatus =
+ mNlInterceptorService->subscribeGroup(interceptedSocket, RTNLGRP_LINK);
+ ASSERT_TRUE(aidlStatus.isOk());
+
+ // Start a thread to receive a multicast
+ mRunning = true;
+ mGotMulticast = false;
+ std::thread successfulReceiver(&InterceptorAidlTest::multicastReceiver,
+ this);
+
+ // TODO(201695162): use futures with wait_for instead of a sleep_for().
+ std::this_thread::sleep_for(50ms);
+ // create a network interface and bring it up to trigger a multicast event.
+ ASSERT_TRUE(android::netdevice::add(mTestIfaceName, /*type=*/"dummy"));
+ ASSERT_TRUE(android::netdevice::up(mTestIfaceName));
+ std::this_thread::sleep_for(50ms);
+ EXPECT_TRUE(mGotMulticast);
+ mRunning = false;
+ successfulReceiver.join();
+
+ // Stop listening to interface up/down events.
+ aidlStatus = mNlInterceptorService->unsubscribeGroup(interceptedSocket,
+ RTNLGRP_LINK);
+ ASSERT_TRUE(aidlStatus.isOk());
+
+ // This time, we should hear nothing.
+ mGotMulticast = false;
+ mRunning = true;
+ std::thread unsuccessfulReceiver(&InterceptorAidlTest::multicastReceiver,
+ this);
+ std::this_thread::sleep_for(50ms);
+ ASSERT_TRUE(android::netdevice::down(mTestIfaceName));
+ ASSERT_TRUE(android::netdevice::del(mTestIfaceName));
+ std::this_thread::sleep_for(50ms);
+ EXPECT_FALSE(mGotMulticast);
+ mRunning = false;
+ unsuccessfulReceiver.join();
+
+ aidlStatus = mNlInterceptorService->closeSocket(interceptedSocket);
+ EXPECT_TRUE(aidlStatus.isOk());
+}
+
+GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(InterceptorAidlTest);
+INSTANTIATE_TEST_SUITE_P(PerInstance, InterceptorAidlTest,
+ testing::ValuesIn(android::getAidlHalInstanceNames(
+ IInterceptor::descriptor)),
+ android::PrintInstanceNameToString);