diff options
author | android-build-team Robot | 2018-01-25 03:07:26 -0600 |
---|---|---|
committer | android-build-team Robot | 2018-01-25 03:07:26 -0600 |
commit | e35089b8bbae459fbd601fc1dcf2ff80024e32e0 (patch) | |
tree | 2ccb3af4d58cf72f9d89abaec697e85938d4b6ec | |
parent | c51089bbd1b048110e42cb321e4b4bb51709cd98 (diff) | |
parent | ea0856fff5bacb6721e4d826d1a6e6278b31a8a7 (diff) | |
download | platform-hardware-interfaces-e35089b8bbae459fbd601fc1dcf2ff80024e32e0.tar.gz platform-hardware-interfaces-e35089b8bbae459fbd601fc1dcf2ff80024e32e0.tar.xz platform-hardware-interfaces-e35089b8bbae459fbd601fc1dcf2ff80024e32e0.zip |
Snap for 4565898 from ea0856fff5bacb6721e4d826d1a6e6278b31a8a7 to pi-release
Change-Id: Id5bda82425928af2c6131e81c54a1302d93e9b47
66 files changed, 2905 insertions, 331 deletions
diff --git a/audio/common/all-versions/test/utility/include/utility/EnvironmentTearDown.h b/audio/common/all-versions/test/utility/include/utility/EnvironmentTearDown.h index 81d92c24..a96d06e0 100644 --- a/audio/common/all-versions/test/utility/include/utility/EnvironmentTearDown.h +++ b/audio/common/all-versions/test/utility/include/utility/EnvironmentTearDown.h | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <functional> | 20 | #include <functional> |
21 | #include <list> | 21 | #include <list> |
22 | 22 | ||
23 | #include <VtsHalHidlTargetTestEnvBase.h> | ||
23 | #include <gtest/gtest.h> | 24 | #include <gtest/gtest.h> |
24 | 25 | ||
25 | namespace android { | 26 | namespace android { |
@@ -33,13 +34,13 @@ namespace utility { | |||
33 | * Avoid destroying static objects after main return. | 34 | * Avoid destroying static objects after main return. |
34 | * Post main return destruction leads to incorrect gtest timing measurements as | 35 | * Post main return destruction leads to incorrect gtest timing measurements as |
35 | * well as harder debuging if anything goes wrong during destruction. */ | 36 | * well as harder debuging if anything goes wrong during destruction. */ |
36 | class Environment : public ::testing::Environment { | 37 | class Environment : public ::testing::VtsHalHidlTargetTestEnvBase { |
37 | public: | 38 | public: |
38 | using TearDownFunc = std::function<void()>; | 39 | using TearDownFunc = std::function<void()>; |
39 | void registerTearDown(TearDownFunc&& tearDown) { tearDowns.push_back(std::move(tearDown)); } | 40 | void registerTearDown(TearDownFunc&& tearDown) { tearDowns.push_back(std::move(tearDown)); } |
40 | 41 | ||
41 | private: | 42 | private: |
42 | void TearDown() override { | 43 | void HidlTearDown() override { |
43 | // Call the tear downs in reverse order of insertion | 44 | // Call the tear downs in reverse order of insertion |
44 | for (auto& tearDown : tearDowns) { | 45 | for (auto& tearDown : tearDowns) { |
45 | tearDown(); | 46 | tearDown(); |
diff --git a/audio/core/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp b/audio/core/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp index 6c09da7e..bb1d26f9 100644 --- a/audio/core/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp +++ b/audio/core/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp | |||
@@ -88,8 +88,13 @@ using ::android::hardware::audio::common::V2_0::ThreadInfo; | |||
88 | 88 | ||
89 | using namespace ::android::hardware::audio::common::test::utility; | 89 | using namespace ::android::hardware::audio::common::test::utility; |
90 | 90 | ||
91 | class AudioHidlTestEnvironment : public ::Environment { | ||
92 | public: | ||
93 | virtual void registerTestServices() override { registerTestService<IDevicesFactory>(); } | ||
94 | }; | ||
95 | |||
91 | // Instance to register global tearDown | 96 | // Instance to register global tearDown |
92 | static Environment* environment; | 97 | static AudioHidlTestEnvironment* environment; |
93 | 98 | ||
94 | class HidlTest : public ::testing::VtsHalHidlTargetTestBase { | 99 | class HidlTest : public ::testing::VtsHalHidlTargetTestBase { |
95 | protected: | 100 | protected: |
@@ -109,7 +114,8 @@ class AudioHidlTest : public HidlTest { | |||
109 | 114 | ||
110 | if (devicesFactory == nullptr) { | 115 | if (devicesFactory == nullptr) { |
111 | environment->registerTearDown([] { devicesFactory.clear(); }); | 116 | environment->registerTearDown([] { devicesFactory.clear(); }); |
112 | devicesFactory = ::testing::VtsHalHidlTargetTestBase::getService<IDevicesFactory>(); | 117 | devicesFactory = ::testing::VtsHalHidlTargetTestBase::getService<IDevicesFactory>( |
118 | environment->getServiceName<IDevicesFactory>("default")); | ||
113 | } | 119 | } |
114 | ASSERT_TRUE(devicesFactory != nullptr); | 120 | ASSERT_TRUE(devicesFactory != nullptr); |
115 | } | 121 | } |
@@ -1265,9 +1271,10 @@ TEST_F(BoolAccessorPrimaryHidlTest, setGetHac) { | |||
1265 | ////////////////////////////////////////////////////////////////////////////// | 1271 | ////////////////////////////////////////////////////////////////////////////// |
1266 | 1272 | ||
1267 | int main(int argc, char** argv) { | 1273 | int main(int argc, char** argv) { |
1268 | environment = new Environment; | 1274 | environment = new AudioHidlTestEnvironment; |
1269 | ::testing::AddGlobalTestEnvironment(environment); | 1275 | ::testing::AddGlobalTestEnvironment(environment); |
1270 | ::testing::InitGoogleTest(&argc, argv); | 1276 | ::testing::InitGoogleTest(&argc, argv); |
1277 | environment->init(&argc, argv); | ||
1271 | int status = RUN_ALL_TESTS(); | 1278 | int status = RUN_ALL_TESTS(); |
1272 | return status; | 1279 | return status; |
1273 | } | 1280 | } |
diff --git a/automotive/vehicle/2.0/Android.bp b/automotive/vehicle/2.0/Android.bp index ffe012e4..a0d20f35 100644 --- a/automotive/vehicle/2.0/Android.bp +++ b/automotive/vehicle/2.0/Android.bp | |||
@@ -56,6 +56,7 @@ hidl_interface { | |||
56 | "VehiclePropertyChangeMode", | 56 | "VehiclePropertyChangeMode", |
57 | "VehiclePropertyGroup", | 57 | "VehiclePropertyGroup", |
58 | "VehiclePropertyOperation", | 58 | "VehiclePropertyOperation", |
59 | "VehiclePropertyStatus", | ||
59 | "VehiclePropertyType", | 60 | "VehiclePropertyType", |
60 | "VehicleRadioConstants", | 61 | "VehicleRadioConstants", |
61 | "VehicleTurnSignal", | 62 | "VehicleTurnSignal", |
@@ -66,6 +67,7 @@ hidl_interface { | |||
66 | "VmsMessageWithLayerAndPublisherIdIntegerValuesIndex", | 67 | "VmsMessageWithLayerAndPublisherIdIntegerValuesIndex", |
67 | "VmsMessageWithLayerIntegerValuesIndex", | 68 | "VmsMessageWithLayerIntegerValuesIndex", |
68 | "VmsOfferingMessageIntegerValuesIndex", | 69 | "VmsOfferingMessageIntegerValuesIndex", |
70 | "VmsPublisherInformationIntegerValuesIndex", | ||
69 | "VmsSubscriptionsStateIntegerValuesIndex", | 71 | "VmsSubscriptionsStateIntegerValuesIndex", |
70 | "Wheel", | 72 | "Wheel", |
71 | ], | 73 | ], |
diff --git a/automotive/vehicle/2.0/default/common/include/vhal_v2_0/SubscriptionManager.h b/automotive/vehicle/2.0/default/common/include/vhal_v2_0/SubscriptionManager.h index 8e9089d6..6086c011 100644 --- a/automotive/vehicle/2.0/default/common/include/vhal_v2_0/SubscriptionManager.h +++ b/automotive/vehicle/2.0/default/common/include/vhal_v2_0/SubscriptionManager.h | |||
@@ -49,7 +49,7 @@ public: | |||
49 | } | 49 | } |
50 | 50 | ||
51 | void addOrUpdateSubscription(const SubscribeOptions &opts); | 51 | void addOrUpdateSubscription(const SubscribeOptions &opts); |
52 | bool isSubscribed(int32_t propId, int32_t areaId, SubscribeFlags flags); | 52 | bool isSubscribed(int32_t propId, SubscribeFlags flags); |
53 | std::vector<int32_t> getSubscribedProperties() const; | 53 | std::vector<int32_t> getSubscribedProperties() const; |
54 | 54 | ||
55 | private: | 55 | private: |
@@ -87,8 +87,7 @@ public: | |||
87 | /** | 87 | /** |
88 | * Constructs SubscriptionManager | 88 | * Constructs SubscriptionManager |
89 | * | 89 | * |
90 | * @param onPropertyUnsubscribed - this callback function will be called when there are no | 90 | * @param onPropertyUnsubscribed - called when no more clients are subscribed to the property. |
91 | * more client subscribed to particular property. | ||
92 | */ | 91 | */ |
93 | SubscriptionManager(const OnPropertyUnsubscribed& onPropertyUnsubscribed) | 92 | SubscriptionManager(const OnPropertyUnsubscribed& onPropertyUnsubscribed) |
94 | : mOnPropertyUnsubscribed(onPropertyUnsubscribed), | 93 | : mOnPropertyUnsubscribed(onPropertyUnsubscribed), |
@@ -115,9 +114,7 @@ public: | |||
115 | const std::vector<recyclable_ptr<VehiclePropValue>>& propValues, | 114 | const std::vector<recyclable_ptr<VehiclePropValue>>& propValues, |
116 | SubscribeFlags flags) const; | 115 | SubscribeFlags flags) const; |
117 | 116 | ||
118 | std::list<sp<HalClient>> getSubscribedClients(int32_t propId, | 117 | std::list<sp<HalClient>> getSubscribedClients(int32_t propId, SubscribeFlags flags) const; |
119 | int32_t area, | ||
120 | SubscribeFlags flags) const; | ||
121 | /** | 118 | /** |
122 | * If there are no clients subscribed to given properties than callback function provided | 119 | * If there are no clients subscribed to given properties than callback function provided |
123 | * in the constructor will be called. | 120 | * in the constructor will be called. |
@@ -125,10 +122,9 @@ public: | |||
125 | void unsubscribe(ClientId clientId, int32_t propId); | 122 | void unsubscribe(ClientId clientId, int32_t propId); |
126 | private: | 123 | private: |
127 | std::list<sp<HalClient>> getSubscribedClientsLocked(int32_t propId, | 124 | std::list<sp<HalClient>> getSubscribedClientsLocked(int32_t propId, |
128 | int32_t area, | ||
129 | SubscribeFlags flags) const; | 125 | SubscribeFlags flags) const; |
130 | 126 | ||
131 | bool updateHalEventSubscriptionLocked(const SubscribeOptions &opts, SubscribeOptions* out); | 127 | bool updateHalEventSubscriptionLocked(const SubscribeOptions& opts, SubscribeOptions* out); |
132 | 128 | ||
133 | void addClientToPropMapLocked(int32_t propId, const sp<HalClient>& client); | 129 | void addClientToPropMapLocked(int32_t propId, const sp<HalClient>& client); |
134 | 130 | ||
diff --git a/automotive/vehicle/2.0/default/common/include/vhal_v2_0/VehicleHal.h b/automotive/vehicle/2.0/default/common/include/vhal_v2_0/VehicleHal.h index 8203a1e6..fd28483a 100644 --- a/automotive/vehicle/2.0/default/common/include/vhal_v2_0/VehicleHal.h +++ b/automotive/vehicle/2.0/default/common/include/vhal_v2_0/VehicleHal.h | |||
@@ -48,17 +48,14 @@ public: | |||
48 | 48 | ||
49 | /** | 49 | /** |
50 | * Subscribe to HAL property events. This method might be called multiple | 50 | * Subscribe to HAL property events. This method might be called multiple |
51 | * times for the same vehicle property to update subscribed areas or sample | 51 | * times for the same vehicle property to update sample rate. |
52 | * rate. | ||
53 | * | 52 | * |
54 | * @param property to subscribe | 53 | * @param property to subscribe |
55 | * @param areas a bitwise vehicle areas or 0 for all supported areas | ||
56 | * @param sampleRate sample rate in Hz for properties that support sample | 54 | * @param sampleRate sample rate in Hz for properties that support sample |
57 | * rate, e.g. for properties with | 55 | * rate, e.g. for properties with |
58 | * VehiclePropertyChangeMode::CONTINUOUS | 56 | * VehiclePropertyChangeMode::CONTINUOUS |
59 | */ | 57 | */ |
60 | virtual StatusCode subscribe(int32_t property, | 58 | virtual StatusCode subscribe(int32_t property, |
61 | int32_t areas, | ||
62 | float sampleRate) = 0; | 59 | float sampleRate) = 0; |
63 | 60 | ||
64 | /** | 61 | /** |
diff --git a/automotive/vehicle/2.0/default/common/include/vhal_v2_0/VehicleObjectPool.h b/automotive/vehicle/2.0/default/common/include/vhal_v2_0/VehicleObjectPool.h index 05c649be..359bb6df 100644 --- a/automotive/vehicle/2.0/default/common/include/vhal_v2_0/VehicleObjectPool.h +++ b/automotive/vehicle/2.0/default/common/include/vhal_v2_0/VehicleObjectPool.h | |||
@@ -191,9 +191,8 @@ public: | |||
191 | VehiclePropValuePool& operator=(VehiclePropValuePool&) = delete; | 191 | VehiclePropValuePool& operator=(VehiclePropValuePool&) = delete; |
192 | private: | 192 | private: |
193 | bool isDisposable(VehiclePropertyType type, size_t vecSize) const { | 193 | bool isDisposable(VehiclePropertyType type, size_t vecSize) const { |
194 | return vecSize > mMaxRecyclableVectorSize || | 194 | return vecSize > mMaxRecyclableVectorSize || VehiclePropertyType::STRING == type || |
195 | VehiclePropertyType::STRING == type || | 195 | VehiclePropertyType::MIXED == type; |
196 | VehiclePropertyType::COMPLEX == type; | ||
197 | } | 196 | } |
198 | 197 | ||
199 | RecyclableType obtainDisposable(VehiclePropertyType valueType, | 198 | RecyclableType obtainDisposable(VehiclePropertyType valueType, |
diff --git a/automotive/vehicle/2.0/default/common/src/SubscriptionManager.cpp b/automotive/vehicle/2.0/default/common/src/SubscriptionManager.cpp index 74f0a5f5..a7d5f509 100644 --- a/automotive/vehicle/2.0/default/common/src/SubscriptionManager.cpp +++ b/automotive/vehicle/2.0/default/common/src/SubscriptionManager.cpp | |||
@@ -34,23 +34,12 @@ namespace V2_0 { | |||
34 | bool mergeSubscribeOptions(const SubscribeOptions &oldOpts, | 34 | bool mergeSubscribeOptions(const SubscribeOptions &oldOpts, |
35 | const SubscribeOptions &newOpts, | 35 | const SubscribeOptions &newOpts, |
36 | SubscribeOptions *outResult) { | 36 | SubscribeOptions *outResult) { |
37 | |||
38 | int32_t updatedAreas = oldOpts.vehicleAreas; | ||
39 | if (updatedAreas != kAllSupportedAreas) { | ||
40 | updatedAreas = newOpts.vehicleAreas != kAllSupportedAreas | ||
41 | ? updatedAreas | newOpts.vehicleAreas | ||
42 | : kAllSupportedAreas; | ||
43 | } | ||
44 | |||
45 | float updatedRate = std::max(oldOpts.sampleRate, newOpts.sampleRate); | 37 | float updatedRate = std::max(oldOpts.sampleRate, newOpts.sampleRate); |
46 | SubscribeFlags updatedFlags = SubscribeFlags(oldOpts.flags | newOpts.flags); | 38 | SubscribeFlags updatedFlags = SubscribeFlags(oldOpts.flags | newOpts.flags); |
47 | 39 | ||
48 | bool updated = updatedRate > oldOpts.sampleRate | 40 | bool updated = (updatedRate > oldOpts.sampleRate) || (updatedFlags != oldOpts.flags); |
49 | || updatedAreas != oldOpts.vehicleAreas | ||
50 | || updatedFlags != oldOpts.flags; | ||
51 | if (updated) { | 41 | if (updated) { |
52 | *outResult = oldOpts; | 42 | *outResult = oldOpts; |
53 | outResult->vehicleAreas = updatedAreas; | ||
54 | outResult->sampleRate = updatedRate; | 43 | outResult->sampleRate = updatedRate; |
55 | outResult->flags = updatedFlags; | 44 | outResult->flags = updatedFlags; |
56 | } | 45 | } |
@@ -75,15 +64,13 @@ void HalClient::addOrUpdateSubscription(const SubscribeOptions &opts) { | |||
75 | } | 64 | } |
76 | 65 | ||
77 | bool HalClient::isSubscribed(int32_t propId, | 66 | bool HalClient::isSubscribed(int32_t propId, |
78 | int32_t areaId, | ||
79 | SubscribeFlags flags) { | 67 | SubscribeFlags flags) { |
80 | auto it = mSubscriptions.find(propId); | 68 | auto it = mSubscriptions.find(propId); |
81 | if (it == mSubscriptions.end()) { | 69 | if (it == mSubscriptions.end()) { |
82 | return false; | 70 | return false; |
83 | } | 71 | } |
84 | const SubscribeOptions& opts = it->second; | 72 | const SubscribeOptions& opts = it->second; |
85 | bool res = (opts.flags & flags) | 73 | bool res = (opts.flags & flags); |
86 | && (opts.vehicleAreas == 0 || areaId == 0 || opts.vehicleAreas & areaId); | ||
87 | return res; | 74 | return res; |
88 | } | 75 | } |
89 | 76 | ||
@@ -139,8 +126,7 @@ std::list<HalClientValues> SubscriptionManager::distributeValuesToClients( | |||
139 | MuxGuard g(mLock); | 126 | MuxGuard g(mLock); |
140 | for (const auto& propValue: propValues) { | 127 | for (const auto& propValue: propValues) { |
141 | VehiclePropValue* v = propValue.get(); | 128 | VehiclePropValue* v = propValue.get(); |
142 | auto clients = getSubscribedClientsLocked( | 129 | auto clients = getSubscribedClientsLocked(v->prop, flags); |
143 | v->prop, v->areaId, flags); | ||
144 | for (const auto& client : clients) { | 130 | for (const auto& client : clients) { |
145 | clientValuesMap[client].push_back(v); | 131 | clientValuesMap[client].push_back(v); |
146 | } | 132 | } |
@@ -158,21 +144,21 @@ std::list<HalClientValues> SubscriptionManager::distributeValuesToClients( | |||
158 | return clientValues; | 144 | return clientValues; |
159 | } | 145 | } |
160 | 146 | ||
161 | std::list<sp<HalClient>> SubscriptionManager::getSubscribedClients( | 147 | std::list<sp<HalClient>> SubscriptionManager::getSubscribedClients(int32_t propId, |
162 | int32_t propId, int32_t area, SubscribeFlags flags) const { | 148 | SubscribeFlags flags) const { |
163 | MuxGuard g(mLock); | 149 | MuxGuard g(mLock); |
164 | return getSubscribedClientsLocked(propId, area, flags); | 150 | return getSubscribedClientsLocked(propId, flags); |
165 | } | 151 | } |
166 | 152 | ||
167 | std::list<sp<HalClient>> SubscriptionManager::getSubscribedClientsLocked( | 153 | std::list<sp<HalClient>> SubscriptionManager::getSubscribedClientsLocked( |
168 | int32_t propId, int32_t area, SubscribeFlags flags) const { | 154 | int32_t propId, SubscribeFlags flags) const { |
169 | std::list<sp<HalClient>> subscribedClients; | 155 | std::list<sp<HalClient>> subscribedClients; |
170 | 156 | ||
171 | sp<HalClientVector> propClients = getClientsForPropertyLocked(propId); | 157 | sp<HalClientVector> propClients = getClientsForPropertyLocked(propId); |
172 | if (propClients.get() != nullptr) { | 158 | if (propClients.get() != nullptr) { |
173 | for (size_t i = 0; i < propClients->size(); i++) { | 159 | for (size_t i = 0; i < propClients->size(); i++) { |
174 | const auto& client = propClients->itemAt(i); | 160 | const auto& client = propClients->itemAt(i); |
175 | if (client->isSubscribed(propId, area, flags)) { | 161 | if (client->isSubscribed(propId, flags)) { |
176 | subscribedClients.push_back(client); | 162 | subscribedClients.push_back(client); |
177 | } | 163 | } |
178 | } | 164 | } |
diff --git a/automotive/vehicle/2.0/default/common/src/VehicleHalManager.cpp b/automotive/vehicle/2.0/default/common/src/VehicleHalManager.cpp index ae543bb3..1918421a 100644 --- a/automotive/vehicle/2.0/default/common/src/VehicleHalManager.cpp +++ b/automotive/vehicle/2.0/default/common/src/VehicleHalManager.cpp | |||
@@ -142,15 +142,6 @@ Return<StatusCode> VehicleHalManager::subscribe(const sp<IVehicleCallback> &call | |||
142 | return StatusCode::INVALID_ARG; | 142 | return StatusCode::INVALID_ARG; |
143 | } | 143 | } |
144 | 144 | ||
145 | int32_t areas = isGlobalProp(prop) ? 0 : ops.vehicleAreas; | ||
146 | if (areas != 0 && ((areas & config->supportedAreas) != areas)) { | ||
147 | ALOGE("Failed to subscribe property 0x%x. Requested areas 0x%x are " | ||
148 | "out of supported range of 0x%x", prop, ops.vehicleAreas, | ||
149 | config->supportedAreas); | ||
150 | return StatusCode::INVALID_ARG; | ||
151 | } | ||
152 | |||
153 | ops.vehicleAreas = areas; | ||
154 | ops.sampleRate = checkSampleRate(*config, ops.sampleRate); | 145 | ops.sampleRate = checkSampleRate(*config, ops.sampleRate); |
155 | } | 146 | } |
156 | 147 | ||
@@ -164,7 +155,7 @@ Return<StatusCode> VehicleHalManager::subscribe(const sp<IVehicleCallback> &call | |||
164 | } | 155 | } |
165 | 156 | ||
166 | for (auto opt : updatedOptions) { | 157 | for (auto opt : updatedOptions) { |
167 | mHal->subscribe(opt.propId, opt.vehicleAreas, opt.sampleRate); | 158 | mHal->subscribe(opt.propId, opt.sampleRate); |
168 | } | 159 | } |
169 | 160 | ||
170 | return StatusCode::OK; | 161 | return StatusCode::OK; |
@@ -224,8 +215,8 @@ void VehicleHalManager::onHalEvent(VehiclePropValuePtr v) { | |||
224 | void VehicleHalManager::onHalPropertySetError(StatusCode errorCode, | 215 | void VehicleHalManager::onHalPropertySetError(StatusCode errorCode, |
225 | int32_t property, | 216 | int32_t property, |
226 | int32_t areaId) { | 217 | int32_t areaId) { |
227 | const auto& clients = mSubscriptionManager.getSubscribedClients( | 218 | const auto& clients = |
228 | property, 0, SubscribeFlags::HAL_EVENT); | 219 | mSubscriptionManager.getSubscribedClients(property, SubscribeFlags::HAL_EVENT); |
229 | 220 | ||
230 | for (auto client : clients) { | 221 | for (auto client : clients) { |
231 | client->getCallback()->onPropertySetError(errorCode, property, areaId); | 222 | client->getCallback()->onPropertySetError(errorCode, property, areaId); |
@@ -326,8 +317,7 @@ bool VehicleHalManager::checkReadPermission(const VehiclePropConfig &config) con | |||
326 | } | 317 | } |
327 | 318 | ||
328 | void VehicleHalManager::handlePropertySetEvent(const VehiclePropValue& value) { | 319 | void VehicleHalManager::handlePropertySetEvent(const VehiclePropValue& value) { |
329 | auto clients = mSubscriptionManager.getSubscribedClients( | 320 | auto clients = mSubscriptionManager.getSubscribedClients(value.prop, SubscribeFlags::SET_CALL); |
330 | value.prop, value.areaId, SubscribeFlags::SET_CALL); | ||
331 | for (auto client : clients) { | 321 | for (auto client : clients) { |
332 | client->getCallback()->onPropertySet(value); | 322 | client->getCallback()->onPropertySet(value); |
333 | } | 323 | } |
diff --git a/automotive/vehicle/2.0/default/common/src/VehicleObjectPool.cpp b/automotive/vehicle/2.0/default/common/src/VehicleObjectPool.cpp index ac1245a0..3f98a940 100644 --- a/automotive/vehicle/2.0/default/common/src/VehicleObjectPool.cpp +++ b/automotive/vehicle/2.0/default/common/src/VehicleObjectPool.cpp | |||
@@ -82,7 +82,7 @@ VehiclePropValuePool::RecyclableType VehiclePropValuePool::obtainString( | |||
82 | } | 82 | } |
83 | 83 | ||
84 | VehiclePropValuePool::RecyclableType VehiclePropValuePool::obtainComplex() { | 84 | VehiclePropValuePool::RecyclableType VehiclePropValuePool::obtainComplex() { |
85 | return obtain(VehiclePropertyType::COMPLEX); | 85 | return obtain(VehiclePropertyType::MIXED); |
86 | } | 86 | } |
87 | 87 | ||
88 | VehiclePropValuePool::RecyclableType VehiclePropValuePool::obtainRecylable( | 88 | VehiclePropValuePool::RecyclableType VehiclePropValuePool::obtainRecylable( |
@@ -138,18 +138,14 @@ void VehiclePropValuePool::InternalPool::recycle(VehiclePropValue* o) { | |||
138 | } | 138 | } |
139 | 139 | ||
140 | bool VehiclePropValuePool::InternalPool::check(VehiclePropValue::RawValue* v) { | 140 | bool VehiclePropValuePool::InternalPool::check(VehiclePropValue::RawValue* v) { |
141 | return check(&v->int32Values, | 141 | return check(&v->int32Values, (VehiclePropertyType::INT32 == mPropType || |
142 | (VehiclePropertyType::INT32 == mPropType | 142 | VehiclePropertyType::INT32_VEC == mPropType || |
143 | || VehiclePropertyType::INT32_VEC == mPropType | 143 | VehiclePropertyType::BOOLEAN == mPropType)) && |
144 | || VehiclePropertyType::BOOLEAN == mPropType)) | 144 | check(&v->floatValues, (VehiclePropertyType::FLOAT == mPropType || |
145 | && check(&v->floatValues, | 145 | VehiclePropertyType::FLOAT_VEC == mPropType)) && |
146 | (VehiclePropertyType::FLOAT == mPropType | 146 | check(&v->int64Values, (VehiclePropertyType::INT64 == mPropType || |
147 | || VehiclePropertyType::FLOAT_VEC == mPropType)) | 147 | VehiclePropertyType::INT64_VEC == mPropType)) && |
148 | && check(&v->int64Values, | 148 | check(&v->bytes, VehiclePropertyType::BYTES == mPropType) && v->stringValue.size() == 0; |
149 | VehiclePropertyType::INT64 == mPropType) | ||
150 | && check(&v->bytes, | ||
151 | VehiclePropertyType::BYTES == mPropType) | ||
152 | && v->stringValue.size() == 0; | ||
153 | } | 149 | } |
154 | 150 | ||
155 | VehiclePropValue* VehiclePropValuePool::InternalPool::createObject() { | 151 | VehiclePropValue* VehiclePropValuePool::InternalPool::createObject() { |
diff --git a/automotive/vehicle/2.0/default/common/src/VehicleUtils.cpp b/automotive/vehicle/2.0/default/common/src/VehicleUtils.cpp index 9146fa12..34a63806 100644 --- a/automotive/vehicle/2.0/default/common/src/VehicleUtils.cpp +++ b/automotive/vehicle/2.0/default/common/src/VehicleUtils.cpp | |||
@@ -42,13 +42,14 @@ std::unique_ptr<VehiclePropValue> createVehiclePropValue( | |||
42 | val->value.floatValues.resize(vecSize); | 42 | val->value.floatValues.resize(vecSize); |
43 | break; | 43 | break; |
44 | case VehiclePropertyType::INT64: | 44 | case VehiclePropertyType::INT64: |
45 | case VehiclePropertyType::INT64_VEC: | ||
45 | val->value.int64Values.resize(vecSize); | 46 | val->value.int64Values.resize(vecSize); |
46 | break; | 47 | break; |
47 | case VehiclePropertyType::BYTES: | 48 | case VehiclePropertyType::BYTES: |
48 | val->value.bytes.resize(vecSize); | 49 | val->value.bytes.resize(vecSize); |
49 | break; | 50 | break; |
50 | case VehiclePropertyType::STRING: | 51 | case VehiclePropertyType::STRING: |
51 | case VehiclePropertyType::COMPLEX: | 52 | case VehiclePropertyType::MIXED: |
52 | break; // Valid, but nothing to do. | 53 | break; // Valid, but nothing to do. |
53 | default: | 54 | default: |
54 | ALOGE("createVehiclePropValue: unknown type: %d", type); | 55 | ALOGE("createVehiclePropValue: unknown type: %d", type); |
@@ -68,6 +69,7 @@ size_t getVehicleRawValueVectorSize( | |||
68 | case VehiclePropertyType::FLOAT_VEC: | 69 | case VehiclePropertyType::FLOAT_VEC: |
69 | return value.floatValues.size(); | 70 | return value.floatValues.size(); |
70 | case VehiclePropertyType::INT64: | 71 | case VehiclePropertyType::INT64: |
72 | case VehiclePropertyType::INT64_VEC: | ||
71 | return value.int64Values.size(); | 73 | return value.int64Values.size(); |
72 | case VehiclePropertyType::BYTES: | 74 | case VehiclePropertyType::BYTES: |
73 | return value.bytes.size(); | 75 | return value.bytes.size(); |
diff --git a/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultConfig.h b/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultConfig.h index 71601a08..18e8c400 100644 --- a/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultConfig.h +++ b/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultConfig.h | |||
@@ -54,10 +54,8 @@ constexpr int ALL_WHEELS = | |||
54 | * floatValues[1] - dispersion defines min and max range relative to initial value | 54 | * floatValues[1] - dispersion defines min and max range relative to initial value |
55 | * floatValues[2] - increment, with every timer tick the value will be incremented by this amount | 55 | * floatValues[2] - increment, with every timer tick the value will be incremented by this amount |
56 | */ | 56 | */ |
57 | const int32_t kGenerateFakeDataControllingProperty = 0x0666 | 57 | const int32_t kGenerateFakeDataControllingProperty = |
58 | | VehiclePropertyGroup::VENDOR | 58 | 0x0666 | VehiclePropertyGroup::VENDOR | VehicleArea::GLOBAL | VehiclePropertyType::MIXED; |
59 | | VehicleArea::GLOBAL | ||
60 | | VehiclePropertyType::COMPLEX; | ||
61 | 59 | ||
62 | const int32_t kHvacPowerProperties[] = { | 60 | const int32_t kHvacPowerProperties[] = { |
63 | toInt(VehicleProperty::HVAC_FAN_SPEED), | 61 | toInt(VehicleProperty::HVAC_FAN_SPEED), |
@@ -238,7 +236,8 @@ const ConfigDeclaration kVehicleProperties[]{ | |||
238 | .prop = toInt(VehicleProperty::HVAC_POWER_ON), | 236 | .prop = toInt(VehicleProperty::HVAC_POWER_ON), |
239 | .access = VehiclePropertyAccess::READ_WRITE, | 237 | .access = VehiclePropertyAccess::READ_WRITE, |
240 | .changeMode = VehiclePropertyChangeMode::ON_CHANGE, | 238 | .changeMode = VehiclePropertyChangeMode::ON_CHANGE, |
241 | .supportedAreas = toInt(VehicleAreaZone::ROW_1), | 239 | .areaConfigs = {VehicleAreaConfig{ |
240 | .areaId = (VehicleAreaZone::ROW_1_LEFT | VehicleAreaZone::ROW_1_RIGHT)}}, | ||
242 | // TODO(bryaneyler): Ideally, this is generated dynamically from | 241 | // TODO(bryaneyler): Ideally, this is generated dynamically from |
243 | // kHvacPowerProperties. | 242 | // kHvacPowerProperties. |
244 | .configString = "0x12400500,0x12400501" // HVAC_FAN_SPEED,HVAC_FAN_DIRECTION | 243 | .configString = "0x12400500,0x12400501" // HVAC_FAN_SPEED,HVAC_FAN_DIRECTION |
@@ -249,51 +248,52 @@ const ConfigDeclaration kVehicleProperties[]{ | |||
249 | .config = {.prop = toInt(VehicleProperty::HVAC_DEFROSTER), | 248 | .config = {.prop = toInt(VehicleProperty::HVAC_DEFROSTER), |
250 | .access = VehiclePropertyAccess::READ_WRITE, | 249 | .access = VehiclePropertyAccess::READ_WRITE, |
251 | .changeMode = VehiclePropertyChangeMode::ON_CHANGE, | 250 | .changeMode = VehiclePropertyChangeMode::ON_CHANGE, |
252 | .supportedAreas = | 251 | .areaConfigs = |
253 | VehicleAreaWindow::FRONT_WINDSHIELD | VehicleAreaWindow::REAR_WINDSHIELD}, | 252 | {VehicleAreaConfig{.areaId = toInt(VehicleAreaWindow::FRONT_WINDSHIELD)}, |
253 | VehicleAreaConfig{.areaId = toInt(VehicleAreaWindow::REAR_WINDSHIELD)}}}, | ||
254 | .initialValue = {.int32Values = {0}} // Will be used for all areas. | 254 | .initialValue = {.int32Values = {0}} // Will be used for all areas. |
255 | }, | 255 | }, |
256 | 256 | ||
257 | {.config = {.prop = toInt(VehicleProperty::HVAC_RECIRC_ON), | 257 | {.config = {.prop = toInt(VehicleProperty::HVAC_RECIRC_ON), |
258 | .access = VehiclePropertyAccess::READ_WRITE, | 258 | .access = VehiclePropertyAccess::READ_WRITE, |
259 | .changeMode = VehiclePropertyChangeMode::ON_CHANGE, | 259 | .changeMode = VehiclePropertyChangeMode::ON_CHANGE, |
260 | .supportedAreas = toInt(VehicleAreaZone::ROW_1)}, | 260 | .areaConfigs = {VehicleAreaConfig{ |
261 | .areaId = (VehicleAreaZone::ROW_1_LEFT | VehicleAreaZone::ROW_1_RIGHT)}}}, | ||
261 | .initialValue = {.int32Values = {1}}}, | 262 | .initialValue = {.int32Values = {1}}}, |
262 | 263 | ||
263 | {.config = {.prop = toInt(VehicleProperty::HVAC_AC_ON), | 264 | {.config = {.prop = toInt(VehicleProperty::HVAC_AC_ON), |
264 | .access = VehiclePropertyAccess::READ_WRITE, | 265 | .access = VehiclePropertyAccess::READ_WRITE, |
265 | .changeMode = VehiclePropertyChangeMode::ON_CHANGE, | 266 | .changeMode = VehiclePropertyChangeMode::ON_CHANGE, |
266 | .supportedAreas = toInt(VehicleAreaZone::ROW_1)}, | 267 | .areaConfigs = {VehicleAreaConfig{ |
268 | .areaId = (VehicleAreaZone::ROW_1_LEFT | VehicleAreaZone::ROW_1_RIGHT)}}}, | ||
267 | .initialValue = {.int32Values = {1}}}, | 269 | .initialValue = {.int32Values = {1}}}, |
268 | 270 | ||
269 | {.config = {.prop = toInt(VehicleProperty::HVAC_AUTO_ON), | 271 | {.config = {.prop = toInt(VehicleProperty::HVAC_AUTO_ON), |
270 | .access = VehiclePropertyAccess::READ_WRITE, | 272 | .access = VehiclePropertyAccess::READ_WRITE, |
271 | .changeMode = VehiclePropertyChangeMode::ON_CHANGE, | 273 | .changeMode = VehiclePropertyChangeMode::ON_CHANGE, |
272 | .supportedAreas = toInt(VehicleAreaZone::ROW_1)}, | 274 | .areaConfigs = {VehicleAreaConfig{ |
275 | .areaId = (VehicleAreaZone::ROW_1_LEFT | VehicleAreaZone::ROW_1_RIGHT)}}}, | ||
273 | .initialValue = {.int32Values = {1}}}, | 276 | .initialValue = {.int32Values = {1}}}, |
274 | 277 | ||
275 | {.config = {.prop = toInt(VehicleProperty::HVAC_FAN_SPEED), | 278 | {.config = {.prop = toInt(VehicleProperty::HVAC_FAN_SPEED), |
276 | .access = VehiclePropertyAccess::READ_WRITE, | 279 | .access = VehiclePropertyAccess::READ_WRITE, |
277 | .changeMode = VehiclePropertyChangeMode::ON_CHANGE, | 280 | .changeMode = VehiclePropertyChangeMode::ON_CHANGE, |
278 | .supportedAreas = toInt(VehicleAreaZone::ROW_1), | 281 | .areaConfigs = {VehicleAreaConfig{ |
279 | .areaConfigs = {VehicleAreaConfig{.areaId = toInt(VehicleAreaZone::ROW_1), | 282 | .areaId = (VehicleAreaZone::ROW_1_LEFT | VehicleAreaZone::ROW_1_RIGHT), |
280 | .minInt32Value = 1, | 283 | .minInt32Value = 1, |
281 | .maxInt32Value = 7}}}, | 284 | .maxInt32Value = 7}}}, |
282 | .initialValue = {.int32Values = {3}}}, | 285 | .initialValue = {.int32Values = {3}}}, |
283 | 286 | ||
284 | {.config = | 287 | {.config = {.prop = toInt(VehicleProperty::HVAC_FAN_DIRECTION), |
285 | { | 288 | .access = VehiclePropertyAccess::READ_WRITE, |
286 | .prop = toInt(VehicleProperty::HVAC_FAN_DIRECTION), | 289 | .changeMode = VehiclePropertyChangeMode::ON_CHANGE, |
287 | .access = VehiclePropertyAccess::READ_WRITE, | 290 | .areaConfigs = {VehicleAreaConfig{ |
288 | .changeMode = VehiclePropertyChangeMode::ON_CHANGE, | 291 | .areaId = (VehicleAreaZone::ROW_1_LEFT | VehicleAreaZone::ROW_1_RIGHT)}}}, |
289 | .supportedAreas = toInt(VehicleAreaZone::ROW_1), | ||
290 | }, | ||
291 | .initialValue = {.int32Values = {toInt(VehicleHvacFanDirection::FACE)}}}, | 292 | .initialValue = {.int32Values = {toInt(VehicleHvacFanDirection::FACE)}}}, |
292 | 293 | ||
293 | {.config = {.prop = toInt(VehicleProperty::HVAC_TEMPERATURE_SET), | 294 | {.config = {.prop = toInt(VehicleProperty::HVAC_TEMPERATURE_SET), |
294 | .access = VehiclePropertyAccess::READ_WRITE, | 295 | .access = VehiclePropertyAccess::READ_WRITE, |
295 | .changeMode = VehiclePropertyChangeMode::ON_CHANGE, | 296 | .changeMode = VehiclePropertyChangeMode::ON_CHANGE, |
296 | .supportedAreas = VehicleAreaZone::ROW_1_LEFT | VehicleAreaZone::ROW_1_RIGHT, | ||
297 | .areaConfigs = {VehicleAreaConfig{ | 297 | .areaConfigs = {VehicleAreaConfig{ |
298 | .areaId = toInt(VehicleAreaZone::ROW_1_LEFT), | 298 | .areaId = toInt(VehicleAreaZone::ROW_1_LEFT), |
299 | .minFloatValue = 16, | 299 | .minFloatValue = 16, |
diff --git a/automotive/vehicle/2.0/default/impl/vhal_v2_0/EmulatedVehicleHal.cpp b/automotive/vehicle/2.0/default/impl/vhal_v2_0/EmulatedVehicleHal.cpp index 6bc05224..16d2b0b5 100644 --- a/automotive/vehicle/2.0/default/impl/vhal_v2_0/EmulatedVehicleHal.cpp +++ b/automotive/vehicle/2.0/default/impl/vhal_v2_0/EmulatedVehicleHal.cpp | |||
@@ -138,8 +138,9 @@ StatusCode EmulatedVehicleHal::set(const VehiclePropValue& propValue) { | |||
138 | return status; | 138 | return status; |
139 | } | 139 | } |
140 | } else if (mHvacPowerProps.count(propValue.prop)) { | 140 | } else if (mHvacPowerProps.count(propValue.prop)) { |
141 | auto hvacPowerOn = mPropStore->readValueOrNull(toInt(VehicleProperty::HVAC_POWER_ON), | 141 | auto hvacPowerOn = mPropStore->readValueOrNull( |
142 | toInt(VehicleAreaZone::ROW_1)); | 142 | toInt(VehicleProperty::HVAC_POWER_ON), |
143 | (VehicleAreaZone::ROW_1_LEFT | VehicleAreaZone::ROW_1_RIGHT)); | ||
143 | 144 | ||
144 | if (hvacPowerOn && hvacPowerOn->value.int32Values.size() == 1 | 145 | if (hvacPowerOn && hvacPowerOn->value.int32Values.size() == 1 |
145 | && hvacPowerOn->value.int32Values[0] == 0) { | 146 | && hvacPowerOn->value.int32Values[0] == 0) { |
@@ -177,7 +178,7 @@ static bool isDiagnosticProperty(VehiclePropConfig propConfig) { | |||
177 | void EmulatedVehicleHal::onCreate() { | 178 | void EmulatedVehicleHal::onCreate() { |
178 | for (auto& it : kVehicleProperties) { | 179 | for (auto& it : kVehicleProperties) { |
179 | VehiclePropConfig cfg = it.config; | 180 | VehiclePropConfig cfg = it.config; |
180 | int32_t supportedAreas = cfg.supportedAreas; | 181 | int32_t numAreas = cfg.areaConfigs.size(); |
181 | 182 | ||
182 | if (isDiagnosticProperty(cfg)) { | 183 | if (isDiagnosticProperty(cfg)) { |
183 | // do not write an initial empty value for the diagnostic properties | 184 | // do not write an initial empty value for the diagnostic properties |
@@ -185,22 +186,26 @@ void EmulatedVehicleHal::onCreate() { | |||
185 | continue; | 186 | continue; |
186 | } | 187 | } |
187 | 188 | ||
188 | // A global property will have supportedAreas = 0 | 189 | // A global property will have only a single area |
189 | if (isGlobalProp(cfg.prop)) { | 190 | if (isGlobalProp(cfg.prop)) { |
190 | supportedAreas = 0; | 191 | numAreas = 1; |
191 | } | 192 | } |
192 | 193 | ||
193 | // This loop is a do-while so it executes at least once to handle global properties | 194 | for (int i = 0; i < numAreas; i++) { |
194 | do { | 195 | int32_t curArea; |
195 | int32_t curArea = supportedAreas; | 196 | |
196 | supportedAreas &= supportedAreas - 1; // Clear the right-most bit of supportedAreas. | 197 | if (isGlobalProp(cfg.prop)) { |
197 | curArea ^= supportedAreas; // Set curArea to the previously cleared bit. | 198 | curArea = 0; |
199 | } else { | ||
200 | curArea = cfg.areaConfigs[i].areaId; | ||
201 | } | ||
198 | 202 | ||
199 | // Create a separate instance for each individual zone | 203 | // Create a separate instance for each individual zone |
200 | VehiclePropValue prop = { | 204 | VehiclePropValue prop = { |
201 | .prop = cfg.prop, | 205 | .prop = cfg.prop, |
202 | .areaId = curArea, | 206 | .areaId = curArea, |
203 | }; | 207 | }; |
208 | |||
204 | if (it.initialAreaValues.size() > 0) { | 209 | if (it.initialAreaValues.size() > 0) { |
205 | auto valueForAreaIt = it.initialAreaValues.find(curArea); | 210 | auto valueForAreaIt = it.initialAreaValues.find(curArea); |
206 | if (valueForAreaIt != it.initialAreaValues.end()) { | 211 | if (valueForAreaIt != it.initialAreaValues.end()) { |
@@ -213,8 +218,7 @@ void EmulatedVehicleHal::onCreate() { | |||
213 | prop.value = it.initialValue; | 218 | prop.value = it.initialValue; |
214 | } | 219 | } |
215 | mPropStore->writeValue(prop); | 220 | mPropStore->writeValue(prop); |
216 | 221 | } | |
217 | } while (supportedAreas != 0); | ||
218 | } | 222 | } |
219 | initObd2LiveFrame(*mPropStore->getConfigOrDie(OBD2_LIVE_FRAME)); | 223 | initObd2LiveFrame(*mPropStore->getConfigOrDie(OBD2_LIVE_FRAME)); |
220 | initObd2FreezeFrame(*mPropStore->getConfigOrDie(OBD2_FREEZE_FRAME)); | 224 | initObd2FreezeFrame(*mPropStore->getConfigOrDie(OBD2_FREEZE_FRAME)); |
@@ -246,8 +250,7 @@ void EmulatedVehicleHal::onContinuousPropertyTimer(const std::vector<int32_t>& p | |||
246 | } | 250 | } |
247 | } | 251 | } |
248 | 252 | ||
249 | StatusCode EmulatedVehicleHal::subscribe(int32_t property, int32_t, | 253 | StatusCode EmulatedVehicleHal::subscribe(int32_t property, float sampleRate) { |
250 | float sampleRate) { | ||
251 | ALOGI("%s propId: 0x%x, sampleRate: %f", __func__, property, sampleRate); | 254 | ALOGI("%s propId: 0x%x, sampleRate: %f", __func__, property, sampleRate); |
252 | 255 | ||
253 | if (isContinuousProperty(property)) { | 256 | if (isContinuousProperty(property)) { |
@@ -389,7 +392,7 @@ void EmulatedVehicleHal::initStaticConfig() { | |||
389 | } | 392 | } |
390 | 393 | ||
391 | void EmulatedVehicleHal::initObd2LiveFrame(const VehiclePropConfig& propConfig) { | 394 | void EmulatedVehicleHal::initObd2LiveFrame(const VehiclePropConfig& propConfig) { |
392 | auto liveObd2Frame = createVehiclePropValue(VehiclePropertyType::COMPLEX, 0); | 395 | auto liveObd2Frame = createVehiclePropValue(VehiclePropertyType::MIXED, 0); |
393 | auto sensorStore = fillDefaultObd2Frame(static_cast<size_t>(propConfig.configArray[0]), | 396 | auto sensorStore = fillDefaultObd2Frame(static_cast<size_t>(propConfig.configArray[0]), |
394 | static_cast<size_t>(propConfig.configArray[1])); | 397 | static_cast<size_t>(propConfig.configArray[1])); |
395 | sensorStore->fillPropValue("", liveObd2Frame.get()); | 398 | sensorStore->fillPropValue("", liveObd2Frame.get()); |
@@ -406,7 +409,7 @@ void EmulatedVehicleHal::initObd2FreezeFrame(const VehiclePropConfig& propConfig | |||
406 | "P0102" | 409 | "P0102" |
407 | "P0123"}; | 410 | "P0123"}; |
408 | for (auto&& dtc : sampleDtcs) { | 411 | for (auto&& dtc : sampleDtcs) { |
409 | auto freezeFrame = createVehiclePropValue(VehiclePropertyType::COMPLEX, 0); | 412 | auto freezeFrame = createVehiclePropValue(VehiclePropertyType::MIXED, 0); |
410 | sensorStore->fillPropValue(dtc, freezeFrame.get()); | 413 | sensorStore->fillPropValue(dtc, freezeFrame.get()); |
411 | freezeFrame->prop = OBD2_FREEZE_FRAME; | 414 | freezeFrame->prop = OBD2_FREEZE_FRAME; |
412 | 415 | ||
diff --git a/automotive/vehicle/2.0/default/impl/vhal_v2_0/EmulatedVehicleHal.h b/automotive/vehicle/2.0/default/impl/vhal_v2_0/EmulatedVehicleHal.h index 99d7edbc..62fc1262 100644 --- a/automotive/vehicle/2.0/default/impl/vhal_v2_0/EmulatedVehicleHal.h +++ b/automotive/vehicle/2.0/default/impl/vhal_v2_0/EmulatedVehicleHal.h | |||
@@ -53,7 +53,7 @@ public: | |||
53 | VehiclePropValuePtr get(const VehiclePropValue& requestedPropValue, | 53 | VehiclePropValuePtr get(const VehiclePropValue& requestedPropValue, |
54 | StatusCode* outStatus) override; | 54 | StatusCode* outStatus) override; |
55 | StatusCode set(const VehiclePropValue& propValue) override; | 55 | StatusCode set(const VehiclePropValue& propValue) override; |
56 | StatusCode subscribe(int32_t property, int32_t areas, float sampleRate) override; | 56 | StatusCode subscribe(int32_t property, float sampleRate) override; |
57 | StatusCode unsubscribe(int32_t property) override; | 57 | StatusCode unsubscribe(int32_t property) override; |
58 | 58 | ||
59 | // Methods from EmulatedVehicleHalIface | 59 | // Methods from EmulatedVehicleHalIface |
diff --git a/automotive/vehicle/2.0/default/impl/vhal_v2_0/VehicleEmulator.cpp b/automotive/vehicle/2.0/default/impl/vhal_v2_0/VehicleEmulator.cpp index 38cb7437..fca8e9ed 100644 --- a/automotive/vehicle/2.0/default/impl/vhal_v2_0/VehicleEmulator.cpp +++ b/automotive/vehicle/2.0/default/impl/vhal_v2_0/VehicleEmulator.cpp | |||
@@ -234,10 +234,6 @@ void VehicleEmulator::populateProtoVehicleConfig(emulator::VehiclePropConfig* pr | |||
234 | protoCfg->set_change_mode(toInt(cfg.changeMode)); | 234 | protoCfg->set_change_mode(toInt(cfg.changeMode)); |
235 | protoCfg->set_value_type(toInt(getPropType(cfg.prop))); | 235 | protoCfg->set_value_type(toInt(getPropType(cfg.prop))); |
236 | 236 | ||
237 | if (!isGlobalProp(cfg.prop)) { | ||
238 | protoCfg->set_supported_areas(cfg.supportedAreas); | ||
239 | } | ||
240 | |||
241 | for (auto& configElement : cfg.configArray) { | 237 | for (auto& configElement : cfg.configArray) { |
242 | protoCfg->add_config_array(configElement); | 238 | protoCfg->add_config_array(configElement); |
243 | } | 239 | } |
@@ -251,9 +247,10 @@ void VehicleEmulator::populateProtoVehicleConfig(emulator::VehiclePropConfig* pr | |||
251 | case VehiclePropertyType::STRING: | 247 | case VehiclePropertyType::STRING: |
252 | case VehiclePropertyType::BOOLEAN: | 248 | case VehiclePropertyType::BOOLEAN: |
253 | case VehiclePropertyType::INT32_VEC: | 249 | case VehiclePropertyType::INT32_VEC: |
250 | case VehiclePropertyType::INT64_VEC: | ||
254 | case VehiclePropertyType::FLOAT_VEC: | 251 | case VehiclePropertyType::FLOAT_VEC: |
255 | case VehiclePropertyType::BYTES: | 252 | case VehiclePropertyType::BYTES: |
256 | case VehiclePropertyType::COMPLEX: | 253 | case VehiclePropertyType::MIXED: |
257 | // Do nothing. These types don't have min/max values | 254 | // Do nothing. These types don't have min/max values |
258 | break; | 255 | break; |
259 | case VehiclePropertyType::INT64: | 256 | case VehiclePropertyType::INT64: |
diff --git a/automotive/vehicle/2.0/default/tests/SubscriptionManager_test.cpp b/automotive/vehicle/2.0/default/tests/SubscriptionManager_test.cpp index 5688dd6d..4865e9e8 100644 --- a/automotive/vehicle/2.0/default/tests/SubscriptionManager_test.cpp +++ b/automotive/vehicle/2.0/default/tests/SubscriptionManager_test.cpp | |||
@@ -51,11 +51,7 @@ public: | |||
51 | } | 51 | } |
52 | 52 | ||
53 | hidl_vec<SubscribeOptions> subscrToProp1 = { | 53 | hidl_vec<SubscribeOptions> subscrToProp1 = { |
54 | SubscribeOptions { | 54 | SubscribeOptions{.propId = PROP1, .flags = SubscribeFlags::HAL_EVENT}, |
55 | .propId = PROP1, | ||
56 | .vehicleAreas = toInt(VehicleAreaZone::ROW_1_LEFT), | ||
57 | .flags = SubscribeFlags::HAL_EVENT | ||
58 | }, | ||
59 | }; | 55 | }; |
60 | 56 | ||
61 | hidl_vec<SubscribeOptions> subscrToProp2 = { | 57 | hidl_vec<SubscribeOptions> subscrToProp2 = { |
@@ -66,15 +62,8 @@ public: | |||
66 | }; | 62 | }; |
67 | 63 | ||
68 | hidl_vec<SubscribeOptions> subscrToProp1and2 = { | 64 | hidl_vec<SubscribeOptions> subscrToProp1and2 = { |
69 | SubscribeOptions { | 65 | SubscribeOptions{.propId = PROP1, .flags = SubscribeFlags::HAL_EVENT}, |
70 | .propId = PROP1, | 66 | SubscribeOptions{.propId = PROP2, .flags = SubscribeFlags::HAL_EVENT}, |
71 | .vehicleAreas = toInt(VehicleAreaZone::ROW_1_LEFT), | ||
72 | .flags = SubscribeFlags::HAL_EVENT | ||
73 | }, | ||
74 | SubscribeOptions { | ||
75 | .propId = PROP2, | ||
76 | .flags = SubscribeFlags::HAL_EVENT | ||
77 | }, | ||
78 | }; | 67 | }; |
79 | 68 | ||
80 | static std::list<sp<IVehicleCallback>> extractCallbacks( | 69 | static std::list<sp<IVehicleCallback>> extractCallbacks( |
@@ -87,14 +76,11 @@ public: | |||
87 | } | 76 | } |
88 | 77 | ||
89 | std::list<sp<HalClient>> clientsToProp1() { | 78 | std::list<sp<HalClient>> clientsToProp1() { |
90 | return manager.getSubscribedClients(PROP1, | 79 | return manager.getSubscribedClients(PROP1, SubscribeFlags::DEFAULT); |
91 | toInt(VehicleAreaZone::ROW_1_LEFT), | ||
92 | SubscribeFlags::DEFAULT); | ||
93 | } | 80 | } |
94 | 81 | ||
95 | std::list<sp<HalClient>> clientsToProp2() { | 82 | std::list<sp<HalClient>> clientsToProp2() { |
96 | return manager.getSubscribedClients(PROP2, 0, | 83 | return manager.getSubscribedClients(PROP2, SubscribeFlags::DEFAULT); |
97 | SubscribeFlags::DEFAULT); | ||
98 | } | 84 | } |
99 | 85 | ||
100 | void onPropertyUnsubscribed(int propertyId) { | 86 | void onPropertyUnsubscribed(int propertyId) { |
@@ -126,7 +112,6 @@ TEST_F(SubscriptionManagerTest, multipleClients) { | |||
126 | 112 | ||
127 | auto clients = manager.getSubscribedClients( | 113 | auto clients = manager.getSubscribedClients( |
128 | PROP1, | 114 | PROP1, |
129 | toInt(VehicleAreaZone::ROW_1_LEFT), | ||
130 | SubscribeFlags::HAL_EVENT); | 115 | SubscribeFlags::HAL_EVENT); |
131 | 116 | ||
132 | ASSERT_ALL_EXISTS({cb1, cb2}, extractCallbacks(clients)); | 117 | ASSERT_ALL_EXISTS({cb1, cb2}, extractCallbacks(clients)); |
@@ -137,24 +122,14 @@ TEST_F(SubscriptionManagerTest, negativeCases) { | |||
137 | ASSERT_EQ(StatusCode::OK, | 122 | ASSERT_EQ(StatusCode::OK, |
138 | manager.addOrUpdateSubscription(1, cb1, subscrToProp1, &updatedOptions)); | 123 | manager.addOrUpdateSubscription(1, cb1, subscrToProp1, &updatedOptions)); |
139 | 124 | ||
140 | // Wrong zone | ||
141 | auto clients = manager.getSubscribedClients( | ||
142 | PROP1, | ||
143 | toInt(VehicleAreaZone::ROW_2_LEFT), | ||
144 | SubscribeFlags::HAL_EVENT); | ||
145 | ASSERT_TRUE(clients.empty()); | ||
146 | |||
147 | // Wrong prop | 125 | // Wrong prop |
148 | clients = manager.getSubscribedClients( | 126 | auto clients = manager.getSubscribedClients(toInt(VehicleProperty::AP_POWER_BOOTUP_REASON), |
149 | toInt(VehicleProperty::AP_POWER_BOOTUP_REASON), | 127 | SubscribeFlags::HAL_EVENT); |
150 | toInt(VehicleAreaZone::ROW_1_LEFT), | ||
151 | SubscribeFlags::HAL_EVENT); | ||
152 | ASSERT_TRUE(clients.empty()); | 128 | ASSERT_TRUE(clients.empty()); |
153 | 129 | ||
154 | // Wrong flag | 130 | // Wrong flag |
155 | clients = manager.getSubscribedClients( | 131 | clients = manager.getSubscribedClients( |
156 | PROP1, | 132 | PROP1, |
157 | toInt(VehicleAreaZone::ROW_1_LEFT), | ||
158 | SubscribeFlags::SET_CALL); | 133 | SubscribeFlags::SET_CALL); |
159 | ASSERT_TRUE(clients.empty()); | 134 | ASSERT_TRUE(clients.empty()); |
160 | } | 135 | } |
@@ -166,7 +141,6 @@ TEST_F(SubscriptionManagerTest, mulipleSubscriptions) { | |||
166 | 141 | ||
167 | auto clients = manager.getSubscribedClients( | 142 | auto clients = manager.getSubscribedClients( |
168 | PROP1, | 143 | PROP1, |
169 | toInt(VehicleAreaZone::ROW_1_LEFT), | ||
170 | SubscribeFlags::DEFAULT); | 144 | SubscribeFlags::DEFAULT); |
171 | ASSERT_EQ((size_t) 1, clients.size()); | 145 | ASSERT_EQ((size_t) 1, clients.size()); |
172 | ASSERT_EQ(cb1, clients.front()->getCallback()); | 146 | ASSERT_EQ(cb1, clients.front()->getCallback()); |
@@ -176,18 +150,15 @@ TEST_F(SubscriptionManagerTest, mulipleSubscriptions) { | |||
176 | ASSERT_EQ(StatusCode::OK, manager.addOrUpdateSubscription(1, cb1, { | 150 | ASSERT_EQ(StatusCode::OK, manager.addOrUpdateSubscription(1, cb1, { |
177 | SubscribeOptions { | 151 | SubscribeOptions { |
178 | .propId = PROP1, | 152 | .propId = PROP1, |
179 | .vehicleAreas = toInt(VehicleAreaZone::ROW_2), | ||
180 | .flags = SubscribeFlags::DEFAULT | 153 | .flags = SubscribeFlags::DEFAULT |
181 | } | 154 | } |
182 | }, &updatedOptions)); | 155 | }, &updatedOptions)); |
183 | 156 | ||
184 | clients = manager.getSubscribedClients(PROP1, | 157 | clients = manager.getSubscribedClients(PROP1, |
185 | toInt(VehicleAreaZone::ROW_1_LEFT), | ||
186 | SubscribeFlags::DEFAULT); | 158 | SubscribeFlags::DEFAULT); |
187 | ASSERT_ALL_EXISTS({cb1}, extractCallbacks(clients)); | 159 | ASSERT_ALL_EXISTS({cb1}, extractCallbacks(clients)); |
188 | 160 | ||
189 | clients = manager.getSubscribedClients(PROP1, | 161 | clients = manager.getSubscribedClients(PROP1, |
190 | toInt(VehicleAreaZone::ROW_2), | ||
191 | SubscribeFlags::DEFAULT); | 162 | SubscribeFlags::DEFAULT); |
192 | ASSERT_ALL_EXISTS({cb1}, extractCallbacks(clients)); | 163 | ASSERT_ALL_EXISTS({cb1}, extractCallbacks(clients)); |
193 | } | 164 | } |
diff --git a/automotive/vehicle/2.0/default/tests/VehicleHalManager_test.cpp b/automotive/vehicle/2.0/default/tests/VehicleHalManager_test.cpp index 4864d5d4..5b195db8 100644 --- a/automotive/vehicle/2.0/default/tests/VehicleHalManager_test.cpp +++ b/automotive/vehicle/2.0/default/tests/VehicleHalManager_test.cpp | |||
@@ -106,7 +106,6 @@ public: | |||
106 | } | 106 | } |
107 | 107 | ||
108 | StatusCode subscribe(int32_t /* property */, | 108 | StatusCode subscribe(int32_t /* property */, |
109 | int32_t /* areas */, | ||
110 | float /* sampleRate */) override { | 109 | float /* sampleRate */) override { |
111 | return StatusCode::OK; | 110 | return StatusCode::OK; |
112 | } | 111 | } |
@@ -286,6 +285,7 @@ TEST_F(VehicleHalManagerTest, subscribe) { | |||
286 | 285 | ||
287 | cb->reset(); | 286 | cb->reset(); |
288 | VehiclePropValue actualValue(*subscribedValue.get()); | 287 | VehiclePropValue actualValue(*subscribedValue.get()); |
288 | actualValue.status = VehiclePropertyStatus::AVAILABLE; | ||
289 | hal->sendPropEvent(std::move(subscribedValue)); | 289 | hal->sendPropEvent(std::move(subscribedValue)); |
290 | 290 | ||
291 | ASSERT_TRUE(cb->waitForExpectedEvents(1)) << "Events received: " | 291 | ASSERT_TRUE(cb->waitForExpectedEvents(1)) << "Events received: " |
diff --git a/automotive/vehicle/2.0/default/tests/VehicleHalTestUtils.h b/automotive/vehicle/2.0/default/tests/VehicleHalTestUtils.h index 2a064175..3cabcf29 100644 --- a/automotive/vehicle/2.0/default/tests/VehicleHalTestUtils.h +++ b/automotive/vehicle/2.0/default/tests/VehicleHalTestUtils.h | |||
@@ -29,10 +29,8 @@ namespace automotive { | |||
29 | namespace vehicle { | 29 | namespace vehicle { |
30 | namespace V2_0 { | 30 | namespace V2_0 { |
31 | 31 | ||
32 | constexpr int32_t kCustomComplexProperty = 0xbeef | 32 | constexpr int32_t kCustomComplexProperty = |
33 | | VehiclePropertyGroup::VENDOR | 33 | 0xbeef | VehiclePropertyGroup::VENDOR | VehiclePropertyType::MIXED | VehicleArea::GLOBAL; |
34 | | VehiclePropertyType::COMPLEX | ||
35 | | VehicleArea::GLOBAL; | ||
36 | 34 | ||
37 | const VehiclePropConfig kVehicleProperties[] = { | 35 | const VehiclePropConfig kVehicleProperties[] = { |
38 | { | 36 | { |
@@ -46,8 +44,6 @@ const VehiclePropConfig kVehicleProperties[] = { | |||
46 | .prop = toInt(VehicleProperty::HVAC_FAN_SPEED), | 44 | .prop = toInt(VehicleProperty::HVAC_FAN_SPEED), |
47 | .access = VehiclePropertyAccess::READ_WRITE, | 45 | .access = VehiclePropertyAccess::READ_WRITE, |
48 | .changeMode = VehiclePropertyChangeMode::ON_CHANGE, | 46 | .changeMode = VehiclePropertyChangeMode::ON_CHANGE, |
49 | .supportedAreas = static_cast<int32_t>( | ||
50 | VehicleAreaZone::ROW_1_LEFT | VehicleAreaZone::ROW_1_RIGHT), | ||
51 | .areaConfigs = { | 47 | .areaConfigs = { |
52 | VehicleAreaConfig { | 48 | VehicleAreaConfig { |
53 | .areaId = toInt(VehicleAreaZone::ROW_1_LEFT), | 49 | .areaId = toInt(VehicleAreaZone::ROW_1_LEFT), |
@@ -66,8 +62,6 @@ const VehiclePropConfig kVehicleProperties[] = { | |||
66 | .prop = toInt(VehicleProperty::HVAC_SEAT_TEMPERATURE), | 62 | .prop = toInt(VehicleProperty::HVAC_SEAT_TEMPERATURE), |
67 | .access = VehiclePropertyAccess::WRITE, | 63 | .access = VehiclePropertyAccess::WRITE, |
68 | .changeMode = VehiclePropertyChangeMode::ON_SET, | 64 | .changeMode = VehiclePropertyChangeMode::ON_SET, |
69 | .supportedAreas = static_cast<int32_t>( | ||
70 | VehicleAreaZone::ROW_1_LEFT | VehicleAreaZone::ROW_1_RIGHT), | ||
71 | .areaConfigs = { | 65 | .areaConfigs = { |
72 | VehicleAreaConfig { | 66 | VehicleAreaConfig { |
73 | .areaId = toInt(VehicleAreaZone::ROW_1_LEFT), | 67 | .areaId = toInt(VehicleAreaZone::ROW_1_LEFT), |
diff --git a/automotive/vehicle/2.0/types.hal b/automotive/vehicle/2.0/types.hal index 7e427812..f673d1ad 100644 --- a/automotive/vehicle/2.0/types.hal +++ b/automotive/vehicle/2.0/types.hal | |||
@@ -27,6 +27,7 @@ enum VehiclePropertyType : int32_t { | |||
27 | INT32 = 0x00400000, | 27 | INT32 = 0x00400000, |
28 | INT32_VEC = 0x00410000, | 28 | INT32_VEC = 0x00410000, |
29 | INT64 = 0x00500000, | 29 | INT64 = 0x00500000, |
30 | INT64_VEC = 0x00510000, | ||
30 | FLOAT = 0x00600000, | 31 | FLOAT = 0x00600000, |
31 | FLOAT_VEC = 0x00610000, | 32 | FLOAT_VEC = 0x00610000, |
32 | BYTES = 0x00700000, | 33 | BYTES = 0x00700000, |
@@ -35,7 +36,7 @@ enum VehiclePropertyType : int32_t { | |||
35 | * Any combination of scalar or vector types. The exact format must be | 36 | * Any combination of scalar or vector types. The exact format must be |
36 | * provided in the description of the property. | 37 | * provided in the description of the property. |
37 | */ | 38 | */ |
38 | COMPLEX = 0x00e00000, | 39 | MIXED = 0x00e00000, |
39 | 40 | ||
40 | MASK = 0x00ff0000 | 41 | MASK = 0x00ff0000 |
41 | }; | 42 | }; |
@@ -315,7 +316,7 @@ enum VehicleProperty: int32_t { | |||
315 | WHEEL_TICK = ( | 316 | WHEEL_TICK = ( |
316 | 0x0306 | 317 | 0x0306 |
317 | | VehiclePropertyGroup:SYSTEM | 318 | | VehiclePropertyGroup:SYSTEM |
318 | | VehiclePropertyType:COMPLEX | 319 | | VehiclePropertyType:MIXED |
319 | | VehicleArea:GLOBAL), | 320 | | VehicleArea:GLOBAL), |
320 | 321 | ||
321 | 322 | ||
@@ -1673,7 +1674,7 @@ enum VehicleProperty: int32_t { | |||
1673 | /** | 1674 | /** |
1674 | * Vehicle Maps Service (VMS) message | 1675 | * Vehicle Maps Service (VMS) message |
1675 | * | 1676 | * |
1676 | * This property uses COMPLEX data to communicate vms messages. | 1677 | * This property uses MIXED data to communicate vms messages. |
1677 | * | 1678 | * |
1678 | * Its contents are to be interpreted as follows: | 1679 | * Its contents are to be interpreted as follows: |
1679 | * the indices defined in VmsMessageIntegerValuesIndex are to be used to | 1680 | * the indices defined in VmsMessageIntegerValuesIndex are to be used to |
@@ -1689,7 +1690,7 @@ enum VehicleProperty: int32_t { | |||
1689 | VEHICLE_MAP_SERVICE = ( | 1690 | VEHICLE_MAP_SERVICE = ( |
1690 | 0x0C00 | 1691 | 0x0C00 |
1691 | | VehiclePropertyGroup:SYSTEM | 1692 | | VehiclePropertyGroup:SYSTEM |
1692 | | VehiclePropertyType:COMPLEX | 1693 | | VehiclePropertyType:MIXED |
1693 | | VehicleArea:GLOBAL), | 1694 | | VehicleArea:GLOBAL), |
1694 | 1695 | ||
1695 | /** | 1696 | /** |
@@ -1736,7 +1737,7 @@ enum VehicleProperty: int32_t { | |||
1736 | OBD2_LIVE_FRAME = ( | 1737 | OBD2_LIVE_FRAME = ( |
1737 | 0x0D00 | 1738 | 0x0D00 |
1738 | | VehiclePropertyGroup:SYSTEM | 1739 | | VehiclePropertyGroup:SYSTEM |
1739 | | VehiclePropertyType:COMPLEX | 1740 | | VehiclePropertyType:MIXED |
1740 | | VehicleArea:GLOBAL), | 1741 | | VehicleArea:GLOBAL), |
1741 | 1742 | ||
1742 | /** | 1743 | /** |
@@ -1766,7 +1767,7 @@ enum VehicleProperty: int32_t { | |||
1766 | OBD2_FREEZE_FRAME = ( | 1767 | OBD2_FREEZE_FRAME = ( |
1767 | 0x0D01 | 1768 | 0x0D01 |
1768 | | VehiclePropertyGroup:SYSTEM | 1769 | | VehiclePropertyGroup:SYSTEM |
1769 | | VehiclePropertyType:COMPLEX | 1770 | | VehiclePropertyType:MIXED |
1770 | | VehicleArea:GLOBAL), | 1771 | | VehicleArea:GLOBAL), |
1771 | 1772 | ||
1772 | /** | 1773 | /** |
@@ -1787,7 +1788,7 @@ enum VehicleProperty: int32_t { | |||
1787 | OBD2_FREEZE_FRAME_INFO = ( | 1788 | OBD2_FREEZE_FRAME_INFO = ( |
1788 | 0x0D02 | 1789 | 0x0D02 |
1789 | | VehiclePropertyGroup:SYSTEM | 1790 | | VehiclePropertyGroup:SYSTEM |
1790 | | VehiclePropertyType:COMPLEX | 1791 | | VehiclePropertyType:MIXED |
1791 | | VehicleArea:GLOBAL), | 1792 | | VehicleArea:GLOBAL), |
1792 | 1793 | ||
1793 | /** | 1794 | /** |
@@ -1813,7 +1814,7 @@ enum VehicleProperty: int32_t { | |||
1813 | OBD2_FREEZE_FRAME_CLEAR = ( | 1814 | OBD2_FREEZE_FRAME_CLEAR = ( |
1814 | 0x0D03 | 1815 | 0x0D03 |
1815 | | VehiclePropertyGroup:SYSTEM | 1816 | | VehiclePropertyGroup:SYSTEM |
1816 | | VehiclePropertyType:COMPLEX | 1817 | | VehiclePropertyType:MIXED |
1817 | | VehicleArea:GLOBAL), | 1818 | | VehicleArea:GLOBAL), |
1818 | }; | 1819 | }; |
1819 | 1820 | ||
@@ -2169,6 +2170,21 @@ enum VehiclePropertyAccess : int32_t { | |||
2169 | }; | 2170 | }; |
2170 | 2171 | ||
2171 | /** | 2172 | /** |
2173 | * Property status is a dynamic value that may change based on the vehicle state. | ||
2174 | */ | ||
2175 | enum VehiclePropertyStatus : int32_t { | ||
2176 | /** Property is available and behaving normally */ | ||
2177 | AVAILABLE = 0x00, | ||
2178 | /** | ||
2179 | * Property is not available, for read and/or write. This is a transient state, as the | ||
2180 | * property is expected to be available at a later time. | ||
2181 | */ | ||
2182 | UNAVAILABLE = 0x01, | ||
2183 | /** There is an error with this property. */ | ||
2184 | ERROR = 0x02, | ||
2185 | }; | ||
2186 | |||
2187 | /** | ||
2172 | * Car states. | 2188 | * Car states. |
2173 | * | 2189 | * |
2174 | * The driving states determine what features of the UI will be accessible. | 2190 | * The driving states determine what features of the UI will be accessible. |
@@ -2212,20 +2228,15 @@ enum VehicleAreaZone : int32_t { | |||
2212 | ROW_1_LEFT = 0x00000001, | 2228 | ROW_1_LEFT = 0x00000001, |
2213 | ROW_1_CENTER = 0x00000002, | 2229 | ROW_1_CENTER = 0x00000002, |
2214 | ROW_1_RIGHT = 0x00000004, | 2230 | ROW_1_RIGHT = 0x00000004, |
2215 | ROW_1 = 0x00000008, | ||
2216 | ROW_2_LEFT = 0x00000010, | 2231 | ROW_2_LEFT = 0x00000010, |
2217 | ROW_2_CENTER = 0x00000020, | 2232 | ROW_2_CENTER = 0x00000020, |
2218 | ROW_2_RIGHT = 0x00000040, | 2233 | ROW_2_RIGHT = 0x00000040, |
2219 | ROW_2 = 0x00000080, | ||
2220 | ROW_3_LEFT = 0x00000100, | 2234 | ROW_3_LEFT = 0x00000100, |
2221 | ROW_3_CENTER = 0x00000200, | 2235 | ROW_3_CENTER = 0x00000200, |
2222 | ROW_3_RIGHT = 0x00000400, | 2236 | ROW_3_RIGHT = 0x00000400, |
2223 | ROW_3 = 0x00000800, | ||
2224 | ROW_4_LEFT = 0x00001000, | 2237 | ROW_4_LEFT = 0x00001000, |
2225 | ROW_4_CENTER = 0x00002000, | 2238 | ROW_4_CENTER = 0x00002000, |
2226 | ROW_4_RIGHT = 0x00004000, | 2239 | ROW_4_RIGHT = 0x00004000, |
2227 | ROW_4 = 0x00008000, | ||
2228 | WHOLE_CABIN = 0x80000000, | ||
2229 | }; | 2240 | }; |
2230 | 2241 | ||
2231 | /** | 2242 | /** |
@@ -2313,13 +2324,6 @@ struct VehiclePropConfig { | |||
2313 | VehiclePropertyChangeMode changeMode; | 2324 | VehiclePropertyChangeMode changeMode; |
2314 | 2325 | ||
2315 | /** | 2326 | /** |
2316 | * Some of the properties may have associated areas (for example, some hvac | ||
2317 | * properties are associated with VehicleAreaZone), in these | ||
2318 | * cases the config may contain an ORed value for the associated areas. | ||
2319 | */ | ||
2320 | int32_t supportedAreas; | ||
2321 | |||
2322 | /** | ||
2323 | * Contains per-area configuration. | 2327 | * Contains per-area configuration. |
2324 | */ | 2328 | */ |
2325 | vec<VehicleAreaConfig> areaConfigs; | 2329 | vec<VehicleAreaConfig> areaConfigs; |
@@ -2372,6 +2376,9 @@ struct VehiclePropValue { | |||
2372 | */ | 2376 | */ |
2373 | int32_t areaId; | 2377 | int32_t areaId; |
2374 | 2378 | ||
2379 | /** Status of the property */ | ||
2380 | VehiclePropertyStatus status; | ||
2381 | |||
2375 | /** | 2382 | /** |
2376 | * Contains value for a single property. Depending on property data type of | 2383 | * Contains value for a single property. Depending on property data type of |
2377 | * this property (VehiclePropetyType) one field of this structure must be filled in. | 2384 | * this property (VehiclePropetyType) one field of this structure must be filled in. |
@@ -2484,12 +2491,6 @@ struct SubscribeOptions { | |||
2484 | int32_t propId; | 2491 | int32_t propId; |
2485 | 2492 | ||
2486 | /** | 2493 | /** |
2487 | * Area ids - this must be a bit mask of areas to subscribe or 0 to subscribe | ||
2488 | * to all areas. | ||
2489 | */ | ||
2490 | int32_t vehicleAreas; | ||
2491 | |||
2492 | /** | ||
2493 | * Sample rate in Hz. | 2494 | * Sample rate in Hz. |
2494 | * | 2495 | * |
2495 | * Must be provided for properties with | 2496 | * Must be provided for properties with |
@@ -2894,9 +2895,42 @@ enum VmsMessageType : int32_t { | |||
2894 | * A message from the VMS service to the subscribers or from the publishers to the VMS service | 2895 | * A message from the VMS service to the subscribers or from the publishers to the VMS service |
2895 | * with a serialized VMS data packet as defined in the VMS protocol. | 2896 | * with a serialized VMS data packet as defined in the VMS protocol. |
2896 | * | 2897 | * |
2897 | * This message type uses enum VmsBaseMessageIntegerValuesIndex. | 2898 | * This message type uses enum VmsMessageWithLayerAndPublisherIdIntegerValuesIndex. |
2898 | */ | 2899 | */ |
2899 | DATA = 12, | 2900 | DATA = 12, |
2901 | |||
2902 | /** | ||
2903 | * A request from the publishers to the VMS service to get a Publisher ID for a serialized VMS | ||
2904 | * provider description packet as defined in the VMS protocol. | ||
2905 | * | ||
2906 | * This message type uses enum VmsBaseMessageIntegerValuesIndex. | ||
2907 | */ | ||
2908 | PUBLISHER_ID_REQUEST = 13, | ||
2909 | |||
2910 | /** | ||
2911 | * A response from the VMS service to the publisher that contains a provider description packet | ||
2912 | * and the publisher ID assigned to it. | ||
2913 | * | ||
2914 | * This message type uses enum VmsPublisherInformationIntegerValuesIndex. | ||
2915 | */ | ||
2916 | PUBLISHER_ID_RESPONSE = 14, | ||
2917 | |||
2918 | /** | ||
2919 | * A request from the subscribers to the VMS service to get information for a Publisher ID. | ||
2920 | * | ||
2921 | * This message type uses enum VmsPublisherInformationIntegerValuesIndex. | ||
2922 | */ | ||
2923 | PUBLISHER_INFORMATION_REQUEST = 15, | ||
2924 | |||
2925 | /** | ||
2926 | * A response from the VMS service to the subscribers that contains a provider description packet | ||
2927 | * and the publisher ID assigned to it. | ||
2928 | * | ||
2929 | * This message type uses enum VmsPublisherInformationIntegerValuesIndex. | ||
2930 | */ | ||
2931 | PUBLISHER_INFORMATION_RESPONSE = 16, | ||
2932 | |||
2933 | LAST_VMS_MESSAGE_TYPE = PUBLISHER_INFORMATION_RESPONSE, | ||
2900 | }; | 2934 | }; |
2901 | 2935 | ||
2902 | /** | 2936 | /** |
@@ -2924,7 +2958,8 @@ enum VmsMessageWithLayerIntegerValuesIndex : VmsBaseMessageIntegerValuesIndex { | |||
2924 | 2958 | ||
2925 | /* | 2959 | /* |
2926 | * A VMS message with a layer and publisher ID is sent as part of a | 2960 | * A VMS message with a layer and publisher ID is sent as part of a |
2927 | * VmsMessageType.SUBSCRIBE_TO_PUBLISHER and VmsMessageType.UNSUBSCRIBE_TO_PUBLISHER messages. | 2961 | * VmsMessageType.SUBSCRIBE_TO_PUBLISHER, VmsMessageType.UNSUBSCRIBE_TO_PUBLISHER messages and |
2962 | * VmsMessageType.DATA . | ||
2928 | */ | 2963 | */ |
2929 | enum VmsMessageWithLayerAndPublisherIdIntegerValuesIndex : VmsMessageWithLayerIntegerValuesIndex { | 2964 | enum VmsMessageWithLayerAndPublisherIdIntegerValuesIndex : VmsMessageWithLayerIntegerValuesIndex { |
2930 | PUBLISHER_ID = 4, | 2965 | PUBLISHER_ID = 4, |
@@ -2993,3 +3028,11 @@ enum VmsAvailabilityStateIntegerValuesIndex : VmsBaseMessageIntegerValuesIndex { | |||
2993 | LAYERS_START = 3, | 3028 | LAYERS_START = 3, |
2994 | }; | 3029 | }; |
2995 | 3030 | ||
3031 | /* | ||
3032 | * Publishers send the VMS service their information and assigned in response a publisher ID. | ||
3033 | * Subscribers can request the publisher information for a publisher ID they received in other messages. | ||
3034 | */ | ||
3035 | enum VmsPublisherInformationIntegerValuesIndex : VmsBaseMessageIntegerValuesIndex { | ||
3036 | PUBLISHER_ID = 1, | ||
3037 | }; | ||
3038 | |||
diff --git a/compatibility_matrices/Android.mk b/compatibility_matrices/Android.mk index 2a01480b..1c86f110 100644 --- a/compatibility_matrices/Android.mk +++ b/compatibility_matrices/Android.mk | |||
@@ -16,123 +16,78 @@ | |||
16 | 16 | ||
17 | LOCAL_PATH := $(call my-dir) | 17 | LOCAL_PATH := $(call my-dir) |
18 | 18 | ||
19 | BUILD_FRAMEWORK_COMPATIBILITY_MATRIX := $(LOCAL_PATH)/compatibility_matrix.mk | ||
20 | |||
21 | # Clear potential input variables to BUILD_FRAMEWORK_COMPATIBILITY_MATRIX | ||
22 | LOCAL_ADD_VBMETA_VERSION := | ||
23 | LOCAL_ASSEMBLE_VINTF_ENV_VARS := | ||
24 | LOCAL_ASSEMBLE_VINTF_FLAGS := | ||
25 | LOCAL_KERNEL_VERSIONS := | ||
26 | LOCAL_GEN_FILE_DEPENDENCIES := | ||
27 | |||
19 | # Install all compatibility_matrix.*.xml to /system/etc/vintf | 28 | # Install all compatibility_matrix.*.xml to /system/etc/vintf |
20 | 29 | ||
30 | |||
21 | include $(CLEAR_VARS) | 31 | include $(CLEAR_VARS) |
22 | LOCAL_MODULE := framework_compatibility_matrix.legacy.xml | ||
23 | LOCAL_MODULE_STEM := compatibility_matrix.legacy.xml | 32 | LOCAL_MODULE_STEM := compatibility_matrix.legacy.xml |
24 | LOCAL_SRC_FILES := $(LOCAL_MODULE_STEM) | 33 | LOCAL_SRC_FILES := $(LOCAL_MODULE_STEM) |
25 | LOCAL_MODULE_CLASS := ETC | 34 | LOCAL_KERNEL_VERSIONS := 3.18.0 4.4.0 4.9.0 |
26 | LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/vintf | 35 | include $(BUILD_FRAMEWORK_COMPATIBILITY_MATRIX) |
27 | include $(BUILD_PREBUILT) | ||
28 | 36 | ||
29 | include $(CLEAR_VARS) | 37 | include $(CLEAR_VARS) |
30 | LOCAL_MODULE := framework_compatibility_matrix.1.xml | ||
31 | LOCAL_MODULE_STEM := compatibility_matrix.1.xml | 38 | LOCAL_MODULE_STEM := compatibility_matrix.1.xml |
32 | LOCAL_SRC_FILES := $(LOCAL_MODULE_STEM) | 39 | LOCAL_SRC_FILES := $(LOCAL_MODULE_STEM) |
33 | LOCAL_MODULE_CLASS := ETC | 40 | LOCAL_KERNEL_VERSIONS := 3.18.0 4.4.0 4.9.0 |
34 | LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/vintf | 41 | include $(BUILD_FRAMEWORK_COMPATIBILITY_MATRIX) |
35 | include $(BUILD_PREBUILT) | ||
36 | 42 | ||
37 | include $(CLEAR_VARS) | 43 | include $(CLEAR_VARS) |
38 | LOCAL_MODULE := framework_compatibility_matrix.2.xml | ||
39 | LOCAL_MODULE_STEM := compatibility_matrix.2.xml | 44 | LOCAL_MODULE_STEM := compatibility_matrix.2.xml |
40 | LOCAL_SRC_FILES := $(LOCAL_MODULE_STEM) | 45 | LOCAL_SRC_FILES := $(LOCAL_MODULE_STEM) |
41 | LOCAL_MODULE_CLASS := ETC | 46 | LOCAL_KERNEL_VERSIONS := 3.18.0 4.4.0 4.9.0 |
42 | LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/vintf | 47 | include $(BUILD_FRAMEWORK_COMPATIBILITY_MATRIX) |
43 | include $(BUILD_PREBUILT) | 48 | |
49 | # TODO(b/72409164): STOPSHIP: update kernel version requirements | ||
44 | 50 | ||
45 | include $(CLEAR_VARS) | 51 | include $(CLEAR_VARS) |
46 | LOCAL_MODULE := framework_compatibility_matrix.current.xml | ||
47 | LOCAL_MODULE_STEM := compatibility_matrix.current.xml | 52 | LOCAL_MODULE_STEM := compatibility_matrix.current.xml |
48 | LOCAL_SRC_FILES := $(LOCAL_MODULE_STEM) | 53 | LOCAL_SRC_FILES := $(LOCAL_MODULE_STEM) |
49 | LOCAL_MODULE_CLASS := ETC | 54 | LOCAL_KERNEL_VERSIONS := 4.4.0 4.9.0 |
50 | LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/vintf | 55 | include $(BUILD_FRAMEWORK_COMPATIBILITY_MATRIX) |
51 | include $(BUILD_PREBUILT) | 56 | |
57 | # Framework Compatibility Matrix (common to all FCM versions) | ||
52 | 58 | ||
53 | # Framework Compatibility Matrix without HALs | ||
54 | include $(CLEAR_VARS) | 59 | include $(CLEAR_VARS) |
55 | LOCAL_MODULE := framework_compatibility_matrix.empty.xml | 60 | LOCAL_MODULE_STEM := compatibility_matrix.empty.xml |
56 | LOCAL_MODULE_STEM := compatibility_matrix.empty.xml | 61 | LOCAL_SRC_FILES := $(LOCAL_MODULE_STEM) |
57 | LOCAL_MODULE_CLASS := ETC | 62 | LOCAL_ADD_VBMETA_VERSION := true |
58 | LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/vintf | 63 | LOCAL_ASSEMBLE_VINTF_ENV_VARS := \ |
59 | 64 | POLICYVERS \ | |
60 | GEN := $(local-generated-sources-dir)/$(LOCAL_MODULE_STEM) | 65 | BOARD_SEPOLICY_VERS |
61 | |||
62 | $(GEN): PRIVATE_FLAGS := | ||
63 | |||
64 | ifeq (true,$(BOARD_AVB_ENABLE)) | ||
65 | $(GEN): $(AVBTOOL) | ||
66 | # INTERNAL_AVB_SYSTEM_SIGNING_ARGS consists of BOARD_AVB_SYSTEM_KEY_PATH and | ||
67 | # BOARD_AVB_SYSTEM_ALGORITHM. We should add the dependency of key path, which | ||
68 | # is a file, here. | ||
69 | $(GEN): $(BOARD_AVB_SYSTEM_KEY_PATH) | ||
70 | # Use deferred assignment (=) instead of immediate assignment (:=). | ||
71 | # Otherwise, cannot get INTERNAL_AVB_SYSTEM_SIGNING_ARGS. | ||
72 | $(GEN): FRAMEWORK_VBMETA_VERSION = $$("$(AVBTOOL)" add_hashtree_footer \ | ||
73 | --print_required_libavb_version \ | ||
74 | $(INTERNAL_AVB_SYSTEM_SIGNING_ARGS) \ | ||
75 | $(BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS)) | ||
76 | else | ||
77 | $(GEN): FRAMEWORK_VBMETA_VERSION := 0.0 | ||
78 | endif | ||
79 | 66 | ||
80 | # Specify kernel versions that the current framework supports. These versions, | 67 | include $(BUILD_FRAMEWORK_COMPATIBILITY_MATRIX) |
81 | # along with kernel configurations, are written to the framework compatibility | ||
82 | # matrix. | ||
83 | $(GEN): KERNEL_VERSIONS := 3.18 4.4 4.9 | ||
84 | |||
85 | # Specify the location of android-base*.cfg files. | ||
86 | $(GEN): KERNEL_CONFIG_DATA := kernel/configs | ||
87 | |||
88 | $(GEN): $(foreach version,$(KERNEL_VERSIONS),\ | ||
89 | $(wildcard $(KERNEL_CONFIG_DATA)/android-$(version)/android-base*.cfg)) | ||
90 | $(GEN): PRIVATE_FLAGS += $(foreach version,$(KERNEL_VERSIONS),\ | ||
91 | --kernel=$(version):$(call normalize-path-list,\ | ||
92 | $(wildcard $(KERNEL_CONFIG_DATA)/android-$(version)/android-base*.cfg))) | ||
93 | |||
94 | $(GEN): $(LOCAL_PATH)/compatibility_matrix.empty.xml $(HOST_OUT_EXECUTABLES)/assemble_vintf | ||
95 | POLICYVERS=$(POLICYVERS) \ | ||
96 | BOARD_SEPOLICY_VERS=$(BOARD_SEPOLICY_VERS) \ | ||
97 | FRAMEWORK_VBMETA_VERSION=$(FRAMEWORK_VBMETA_VERSION) \ | ||
98 | $(HOST_OUT_EXECUTABLES)/assemble_vintf \ | ||
99 | -i $< -o $@ $(PRIVATE_FLAGS) | ||
100 | LOCAL_PREBUILT_MODULE_FILE := $(GEN) | ||
101 | include $(BUILD_PREBUILT) | ||
102 | 68 | ||
103 | # Framework Compatibility Matrix | 69 | # Framework Compatibility Matrix |
104 | include $(CLEAR_VARS) | ||
105 | LOCAL_MODULE := framework_compatibility_matrix.xml | ||
106 | LOCAL_MODULE_STEM := compatibility_matrix.xml | ||
107 | LOCAL_MODULE_CLASS := ETC | ||
108 | LOCAL_MODULE_PATH := $(TARGET_OUT) | ||
109 | 70 | ||
71 | include $(CLEAR_VARS) | ||
72 | LOCAL_MODULE := framework_compatibility_matrix.xml | ||
73 | LOCAL_MODULE_STEM := compatibility_matrix.xml | ||
74 | LOCAL_MODULE_PATH := $(TARGET_OUT) | ||
110 | LOCAL_REQUIRED_MODULES := \ | 75 | LOCAL_REQUIRED_MODULES := \ |
111 | framework_compatibility_matrix.legacy.xml \ | 76 | framework_compatibility_matrix.legacy.xml \ |
112 | framework_compatibility_matrix.1.xml \ | 77 | framework_compatibility_matrix.1.xml \ |
113 | framework_compatibility_matrix.2.xml \ | 78 | framework_compatibility_matrix.2.xml \ |
114 | framework_compatibility_matrix.current.xml \ | 79 | framework_compatibility_matrix.current.xml \ |
115 | framework_compatibility_matrix.empty.xml | 80 | framework_compatibility_matrix.empty.xml |
116 | 81 | LOCAL_GENERATED_SOURCES := $(call module-installed-files,$(LOCAL_REQUIRED_MODULES)) | |
117 | GEN := $(local-generated-sources-dir)/compatibility_matrix.xml | ||
118 | |||
119 | $(GEN): PRIVATE_FLAGS := | ||
120 | 82 | ||
121 | ifdef BUILT_VENDOR_MANIFEST | 83 | ifdef BUILT_VENDOR_MANIFEST |
122 | $(GEN): $(BUILT_VENDOR_MANIFEST) | 84 | LOCAL_GEN_FILE_DEPENDENCIES += $(BUILT_VENDOR_MANIFEST) |
123 | $(GEN): PRIVATE_FLAGS += -c "$(BUILT_VENDOR_MANIFEST)" | 85 | LOCAL_ASSEMBLE_VINTF_FLAGS += -c "$(BUILT_VENDOR_MANIFEST)" |
124 | endif | 86 | endif |
125 | 87 | ||
126 | MATRIX_SRC_FILES := $(call module-installed-files,$(LOCAL_REQUIRED_MODULES)) | 88 | LOCAL_ASSEMBLE_VINTF_ENV_VARS := PRODUCT_ENFORCE_VINTF_MANIFEST |
127 | $(GEN): PRIVATE_MATRIX_SRC_FILES := $(MATRIX_SRC_FILES) | ||
128 | $(GEN): $(MATRIX_SRC_FILES) $(HOST_OUT_EXECUTABLES)/assemble_vintf | ||
129 | PRODUCT_ENFORCE_VINTF_MANIFEST=$(PRODUCT_ENFORCE_VINTF_MANIFEST) \ | ||
130 | $(HOST_OUT_EXECUTABLES)/assemble_vintf \ | ||
131 | -i $(call normalize-path-list,$(PRIVATE_MATRIX_SRC_FILES)) \ | ||
132 | -o $@ $(PRIVATE_FLAGS) | ||
133 | |||
134 | MATRIX_SRC_FILES := | ||
135 | 89 | ||
136 | LOCAL_PREBUILT_MODULE_FILE := $(GEN) | 90 | include $(BUILD_FRAMEWORK_COMPATIBILITY_MATRIX) |
137 | include $(BUILD_PREBUILT) | ||
138 | BUILT_SYSTEM_COMPATIBILITY_MATRIX := $(LOCAL_BUILT_MODULE) | 91 | BUILT_SYSTEM_COMPATIBILITY_MATRIX := $(LOCAL_BUILT_MODULE) |
92 | |||
93 | BUILD_FRAMEWORK_COMPATIBILITY_MATRIX := | ||
diff --git a/compatibility_matrices/compatibility_matrix.mk b/compatibility_matrices/compatibility_matrix.mk new file mode 100644 index 00000000..14c60ab9 --- /dev/null +++ b/compatibility_matrices/compatibility_matrix.mk | |||
@@ -0,0 +1,100 @@ | |||
1 | # | ||
2 | # Copyright (C) 2018 The Android Open Source Project | ||
3 | # | ||
4 | # Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | # you may not use this file except in compliance with the License. | ||
6 | # You may obtain a copy of the License at | ||
7 | # | ||
8 | # http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | # | ||
10 | # Unless required by applicable law or agreed to in writing, software | ||
11 | # distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | # See the License for the specific language governing permissions and | ||
14 | # limitations under the License. | ||
15 | # | ||
16 | |||
17 | ########################################################### | ||
18 | ## Remove minor revision from a kernel version. For example, | ||
19 | ## 3.18.0 becomes 3.18. | ||
20 | ## $(1): kernel version | ||
21 | ########################################################### | ||
22 | define remove-minor-revision | ||
23 | $(strip $(subst $(space),.,$(wordlist 1,2,$(subst .,$(space),$(strip $(1)))))) | ||
24 | endef | ||
25 | |||
26 | # $(warning $(call remove-minor-revision,3.18.0)) | ||
27 | |||
28 | ifndef LOCAL_MODULE_STEM | ||
29 | $(error LOCAL_MODULE_STEM must be defined.) | ||
30 | endif | ||
31 | |||
32 | LOCAL_MODULE := framework_$(LOCAL_MODULE_STEM) | ||
33 | LOCAL_MODULE_CLASS := ETC | ||
34 | |||
35 | ifndef LOCAL_MODULE_PATH | ||
36 | LOCAL_MODULE_PATH := $(TARGET_OUT)/etc/vintf | ||
37 | endif | ||
38 | |||
39 | GEN := $(local-generated-sources-dir)/$(LOCAL_MODULE_STEM) | ||
40 | |||
41 | $(GEN): PRIVATE_ENV_VARS := $(LOCAL_ASSEMBLE_VINTF_ENV_VARS) | ||
42 | $(GEN): PRIVATE_FLAGS := $(LOCAL_ASSEMBLE_VINTF_FLAGS) | ||
43 | |||
44 | $(GEN): $(LOCAL_GEN_FILE_DEPENDENCIES) | ||
45 | |||
46 | ifeq (true,$(strip $(LOCAL_ADD_VBMETA_VERSION))) | ||
47 | ifeq (true,$(BOARD_AVB_ENABLE)) | ||
48 | $(GEN): $(AVBTOOL) | ||
49 | # INTERNAL_AVB_SYSTEM_SIGNING_ARGS consists of BOARD_AVB_SYSTEM_KEY_PATH and | ||
50 | # BOARD_AVB_SYSTEM_ALGORITHM. We should add the dependency of key path, which | ||
51 | # is a file, here. | ||
52 | $(GEN): $(BOARD_AVB_SYSTEM_KEY_PATH) | ||
53 | # Use deferred assignment (=) instead of immediate assignment (:=). | ||
54 | # Otherwise, cannot get INTERNAL_AVB_SYSTEM_SIGNING_ARGS. | ||
55 | $(GEN): FRAMEWORK_VBMETA_VERSION = $$("$(AVBTOOL)" add_hashtree_footer \ | ||
56 | --print_required_libavb_version \ | ||
57 | $(INTERNAL_AVB_SYSTEM_SIGNING_ARGS) \ | ||
58 | $(BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS)) | ||
59 | else | ||
60 | $(GEN): FRAMEWORK_VBMETA_VERSION := 0.0 | ||
61 | endif # BOARD_AVB_ENABLE | ||
62 | $(GEN): PRIVATE_ENV_VARS += FRAMEWORK_VBMETA_VERSION | ||
63 | endif # LOCAL_ADD_VBMETA_VERSION | ||
64 | |||
65 | ifneq (,$(strip $(LOCAL_KERNEL_VERSIONS))) | ||
66 | $(GEN): PRIVATE_KERNEL_CONFIG_DATA := kernel/configs | ||
67 | $(GEN): PRIVATE_KERNEL_VERSIONS := $(LOCAL_KERNEL_VERSIONS) | ||
68 | $(GEN): $(foreach version,$(PRIVATE_KERNEL_VERSIONS),\ | ||
69 | $(wildcard $(PRIVATE_KERNEL_CONFIG_DATA)/android-$(call remove-minor-revision,$(version))/android-base*.cfg)) | ||
70 | $(GEN): PRIVATE_FLAGS += $(foreach version,$(PRIVATE_KERNEL_VERSIONS),\ | ||
71 | --kernel=$(version):$(call normalize-path-list,\ | ||
72 | $(wildcard $(PRIVATE_KERNEL_CONFIG_DATA)/android-$(call remove-minor-revision,$(version))/android-base*.cfg))) | ||
73 | endif | ||
74 | |||
75 | my_matrix_src_files := \ | ||
76 | $(addprefix $(LOCAL_PATH)/,$(LOCAL_SRC_FILES)) \ | ||
77 | $(LOCAL_GENERATED_SOURCES) | ||
78 | |||
79 | $(GEN): PRIVATE_SRC_FILES := $(my_matrix_src_files) | ||
80 | $(GEN): $(my_matrix_src_files) $(HOST_OUT_EXECUTABLES)/assemble_vintf | ||
81 | $(foreach varname,$(PRIVATE_ENV_VARS),$(varname)=$($(varname))) \ | ||
82 | $(HOST_OUT_EXECUTABLES)/assemble_vintf \ | ||
83 | -i $(call normalize-path-list,$(PRIVATE_SRC_FILES)) \ | ||
84 | -o $@ \ | ||
85 | $(PRIVATE_FLAGS) | ||
86 | |||
87 | LOCAL_PREBUILT_MODULE_FILE := $(GEN) | ||
88 | LOCAL_SRC_FILES := | ||
89 | LOCAL_GENERATED_SOURCES := | ||
90 | |||
91 | LOCAL_ADD_VBMETA_VERSION := | ||
92 | LOCAL_ASSEMBLE_VINTF_ENV_VARS := | ||
93 | LOCAL_ASSEMBLE_VINTF_FLAGS := | ||
94 | LOCAL_KERNEL_VERSIONS := | ||
95 | LOCAL_GEN_FILE_DEPENDENCIES := | ||
96 | my_matrix_src_files := | ||
97 | |||
98 | include $(BUILD_PREBUILT) | ||
99 | |||
100 | remove-minor-revision := | ||
diff --git a/drm/1.0/default/DrmPlugin.cpp b/drm/1.0/default/DrmPlugin.cpp index 1695ef77..809f694f 100644 --- a/drm/1.0/default/DrmPlugin.cpp +++ b/drm/1.0/default/DrmPlugin.cpp | |||
@@ -93,6 +93,7 @@ namespace implementation { | |||
93 | requestType = KeyRequestType::RELEASE; | 93 | requestType = KeyRequestType::RELEASE; |
94 | break; | 94 | break; |
95 | case android::DrmPlugin::kKeyRequestType_Unknown: | 95 | case android::DrmPlugin::kKeyRequestType_Unknown: |
96 | default: | ||
96 | requestType = KeyRequestType::UNKNOWN; | 97 | requestType = KeyRequestType::UNKNOWN; |
97 | break; | 98 | break; |
98 | } | 99 | } |
diff --git a/drm/1.1/Android.bp b/drm/1.1/Android.bp index c895af69..ed8196ec 100644 --- a/drm/1.1/Android.bp +++ b/drm/1.1/Android.bp | |||
@@ -18,6 +18,7 @@ hidl_interface { | |||
18 | ], | 18 | ], |
19 | types: [ | 19 | types: [ |
20 | "HdcpLevel", | 20 | "HdcpLevel", |
21 | "KeyRequestType", | ||
21 | "SecurityLevel", | 22 | "SecurityLevel", |
22 | ], | 23 | ], |
23 | gen_java: false, | 24 | gen_java: false, |
diff --git a/drm/1.1/IDrmPlugin.hal b/drm/1.1/IDrmPlugin.hal index 0660a433..c32d2b52 100644 --- a/drm/1.1/IDrmPlugin.hal +++ b/drm/1.1/IDrmPlugin.hal | |||
@@ -17,8 +17,12 @@ package android.hardware.drm@1.1; | |||
17 | 17 | ||
18 | import @1.0::IDrmPlugin; | 18 | import @1.0::IDrmPlugin; |
19 | import @1.0::IDrmPluginListener; | 19 | import @1.0::IDrmPluginListener; |
20 | import @1.0::KeyedVector; | ||
21 | import @1.0::KeyType; | ||
20 | import @1.0::Status; | 22 | import @1.0::Status; |
23 | import @1.1::DrmMetricGroup; | ||
21 | import @1.1::HdcpLevel; | 24 | import @1.1::HdcpLevel; |
25 | import @1.1::KeyRequestType; | ||
22 | import @1.1::SecurityLevel; | 26 | import @1.1::SecurityLevel; |
23 | 27 | ||
24 | /** | 28 | /** |
@@ -28,6 +32,59 @@ import @1.1::SecurityLevel; | |||
28 | */ | 32 | */ |
29 | interface IDrmPlugin extends @1.0::IDrmPlugin { | 33 | interface IDrmPlugin extends @1.0::IDrmPlugin { |
30 | /** | 34 | /** |
35 | * A key request/response exchange occurs between the app and a License | ||
36 | * Server to obtain the keys required to decrypt the content. | ||
37 | * getKeyRequest_1_1() is used to obtain an opaque key request blob that is | ||
38 | * delivered to the license server. | ||
39 | * | ||
40 | * getKeyRequest_1_1() only differs from getKeyRequest() in that additional | ||
41 | * values are returned in 1.1::KeyRequestType as compared to | ||
42 | * 1.0::KeyRequestType | ||
43 | * | ||
44 | * @param scope may be a sessionId or a keySetId, depending on the | ||
45 | * specified keyType. When the keyType is OFFLINE or STREAMING, | ||
46 | * scope should be set to the sessionId the keys will be provided | ||
47 | * to. When the keyType is RELEASE, scope should be set to the | ||
48 | * keySetId of the keys being released. | ||
49 | * @param initData container-specific data, its meaning is interpreted | ||
50 | * based on the mime type provided in the mimeType parameter. | ||
51 | * It could contain, for example, the content ID, key ID or | ||
52 | * other data obtained from the content metadata that is | ||
53 | * required to generate the key request. initData may be empty | ||
54 | * when keyType is RELEASE. | ||
55 | * @param mimeType identifies the mime type of the content | ||
56 | * @param keyType specifies if the keys are to be used for streaming, | ||
57 | * offline or a release | ||
58 | * @param optionalParameters included in the key request message to | ||
59 | * allow a client application to provide additional message | ||
60 | * parameters to the server. | ||
61 | * @return status the status of the call. The status must be OK or one of | ||
62 | * the following errors: ERROR_DRM_SESSION_NOT_OPENED if the | ||
63 | * session is not opened, ERROR_DRM_NOT_PROVISIONED if the device | ||
64 | * requires provisioning before it can generate a key request, | ||
65 | * ERROR_DRM_CANNOT_HANDLE if getKeyRequest is not supported | ||
66 | * at the time of the call, BAD_VALUE if any parameters are | ||
67 | * invalid or ERROR_DRM_INVALID_STATE if the HAL is in a | ||
68 | * state where a key request cannot be generated. | ||
69 | * @return request if successful, the opaque key request blob is returned | ||
70 | * @return requestType indicates type information about the returned | ||
71 | * request. The type may be one of INITIAL, RENEWAL, RELEASE, | ||
72 | * NONE or UPDATE. An INITIAL request is the first key request | ||
73 | * for a license. RENEWAL is a subsequent key request used to | ||
74 | * refresh the keys in a license. RELEASE corresponds to a | ||
75 | * keyType of RELEASE, which indicates keys are being released. | ||
76 | * NONE indicates that no request is needed because the keys are | ||
77 | * already loaded. UPDATE indicates that the keys need to be | ||
78 | * refetched after the initial license request. | ||
79 | * @return defaultUrl the URL that the request may be sent to, if | ||
80 | * provided by the drm HAL. The app may choose to override this URL. | ||
81 | */ | ||
82 | getKeyRequest_1_1(vec<uint8_t> scope, vec<uint8_t> initData, | ||
83 | string mimeType, KeyType keyType, KeyedVector optionalParameters) | ||
84 | generates (Status status, vec<uint8_t> request, | ||
85 | KeyRequestType requestType, string defaultUrl); | ||
86 | |||
87 | /** | ||
31 | * Return the currently negotiated and max supported HDCP levels. | 88 | * Return the currently negotiated and max supported HDCP levels. |
32 | * | 89 | * |
33 | * The current level is based on the display(s) the device is connected to. | 90 | * The current level is based on the display(s) the device is connected to. |
@@ -106,4 +163,17 @@ interface IDrmPlugin extends @1.0::IDrmPlugin { | |||
106 | */ | 163 | */ |
107 | setSecurityLevel(vec<uint8_t> sessionId, SecurityLevel level) | 164 | setSecurityLevel(vec<uint8_t> sessionId, SecurityLevel level) |
108 | generates(Status status); | 165 | generates(Status status); |
166 | |||
167 | /** | ||
168 | * Returns the plugin-specific metrics. Multiple metric groups may be | ||
169 | * returned in one call to getMetrics(). The scope and definition of the | ||
170 | * metrics is defined by the plugin. | ||
171 | * | ||
172 | * @return status the status of the call. The status must be OK or | ||
173 | * ERROR_DRM_INVALID_STATE if the metrics are not available to be | ||
174 | * returned. | ||
175 | * @return metric_groups the collection of metric groups provided by the | ||
176 | * plugin. | ||
177 | */ | ||
178 | getMetrics() generates (Status status, vec<DrmMetricGroup> metric_groups); | ||
109 | }; | 179 | }; |
diff --git a/drm/1.1/types.hal b/drm/1.1/types.hal index 94475247..94a6e667 100644 --- a/drm/1.1/types.hal +++ b/drm/1.1/types.hal | |||
@@ -16,6 +16,105 @@ | |||
16 | 16 | ||
17 | package android.hardware.drm@1.1; | 17 | package android.hardware.drm@1.1; |
18 | 18 | ||
19 | import @1.0::KeyRequestType; | ||
20 | |||
21 | /** | ||
22 | * This message contains plugin-specific metrics made available to the client. | ||
23 | * The message is used for making vendor-specific metrics available to an | ||
24 | * application. The framework is not consuming any of the information. | ||
25 | * | ||
26 | * Metrics are grouped in instances of DrmMetricGroup. Each group contains | ||
27 | * multiple instances of Metric. | ||
28 | * | ||
29 | * Example: | ||
30 | * | ||
31 | * Capture the timing information of a buffer copy event, "buf_copy", broken | ||
32 | * out by the "size" of the buffer. | ||
33 | * | ||
34 | * DrmMetricGroup { | ||
35 | * metrics[0] { | ||
36 | * name: "buf_copy" | ||
37 | * attributes[0] { | ||
38 | * name: "size" | ||
39 | * type: INT64_TYPE | ||
40 | * int64Value: 1024 | ||
41 | * } | ||
42 | * values[0] { | ||
43 | * componentName: "operation_count" | ||
44 | * type: INT64_TYPE | ||
45 | * int64Value: 75 | ||
46 | * } | ||
47 | * values[1] { | ||
48 | * component_name: "average_time_seconds" | ||
49 | * type: DOUBLE_TYPE | ||
50 | * doubleValue: 0.00000042 | ||
51 | * } | ||
52 | * } | ||
53 | * } | ||
54 | */ | ||
55 | struct DrmMetricGroup { | ||
56 | /** | ||
57 | * Used to discriminate the type of value being stored in the structs | ||
58 | * below. | ||
59 | */ | ||
60 | enum ValueType : uint8_t { | ||
61 | INT64_TYPE, | ||
62 | DOUBLE_TYPE, | ||
63 | STRING_TYPE, | ||
64 | }; | ||
65 | |||
66 | /** | ||
67 | * A detail about the metric being captured. The fields of an Attribute | ||
68 | * are opaque to the framework. | ||
69 | */ | ||
70 | struct Attribute { | ||
71 | string name; | ||
72 | /** | ||
73 | * The type field indicates which of the following values is used. | ||
74 | */ | ||
75 | ValueType type; | ||
76 | int64_t int64Value; | ||
77 | double doubleValue; | ||
78 | string stringValue; | ||
79 | }; | ||
80 | |||
81 | /** | ||
82 | * A value of the metric. A metric may have multiple values. The | ||
83 | * component name may be left empty if there is only supposed to be | ||
84 | * one value for the given metric. The fields of the Value are | ||
85 | * opaque to the framework. | ||
86 | */ | ||
87 | struct Value { | ||
88 | string componentName; | ||
89 | /** | ||
90 | * The type field indicates which of the following values is used. | ||
91 | */ | ||
92 | ValueType type; | ||
93 | int64_t int64Value; | ||
94 | double doubleValue; | ||
95 | string stringValue; | ||
96 | }; | ||
97 | |||
98 | /** | ||
99 | * The metric being captured. A metric must have a name and at least one | ||
100 | * value. A metric may have 0 or more attributes. The fields of a Metric | ||
101 | * are opaque to the framework. | ||
102 | */ | ||
103 | struct Metric { | ||
104 | string name; | ||
105 | vec<Attribute> attributes; | ||
106 | // A Metric may have one or more values. Multiple values are useful | ||
107 | // for capturing different aspects of the same metric. E.g. capture | ||
108 | // the min, max, average, count, and stdev of a particular metric. | ||
109 | vec<Value> values; | ||
110 | }; | ||
111 | |||
112 | /** | ||
113 | * The list of metrics to be captured. | ||
114 | */ | ||
115 | vec<Metric> metrics; | ||
116 | }; | ||
117 | |||
19 | /** | 118 | /** |
20 | * HDCP specifications are defined by Digital Content Protection LLC (DCP). | 119 | * HDCP specifications are defined by Digital Content Protection LLC (DCP). |
21 | * "HDCP Specification Rev. 2.2 Interface Independent Adaptation" | 120 | * "HDCP Specification Rev. 2.2 Interface Independent Adaptation" |
@@ -58,6 +157,23 @@ enum HdcpLevel : uint32_t { | |||
58 | HDCP_NO_OUTPUT | 157 | HDCP_NO_OUTPUT |
59 | }; | 158 | }; |
60 | 159 | ||
160 | /** | ||
161 | * KeyRequestTypes (in addition to those from 1.0) which allow an app | ||
162 | * to determine the type of a key request returned from getKeyRequest. | ||
163 | */ | ||
164 | enum KeyRequestType : @1.0::KeyRequestType { | ||
165 | /** | ||
166 | * Keys are already loaded. No key request is needed. | ||
167 | */ | ||
168 | NONE, | ||
169 | |||
170 | /** | ||
171 | * Keys have previously been loaded. An additional (non-renewal) license | ||
172 | * request is needed. | ||
173 | */ | ||
174 | UPDATE, | ||
175 | }; | ||
176 | |||
61 | enum SecurityLevel : uint32_t { | 177 | enum SecurityLevel : uint32_t { |
62 | /** | 178 | /** |
63 | * Unable to determine the security level | 179 | * Unable to determine the security level |
@@ -93,3 +209,4 @@ enum SecurityLevel : uint32_t { | |||
93 | */ | 209 | */ |
94 | HW_SECURE_ALL, | 210 | HW_SECURE_ALL, |
95 | }; | 211 | }; |
212 | |||
diff --git a/graphics/common/1.1/Android.bp b/graphics/common/1.1/Android.bp index 72ef282f..c319d800 100644 --- a/graphics/common/1.1/Android.bp +++ b/graphics/common/1.1/Android.bp | |||
@@ -15,6 +15,7 @@ hidl_interface { | |||
15 | ], | 15 | ], |
16 | types: [ | 16 | types: [ |
17 | "BufferUsage", | 17 | "BufferUsage", |
18 | "Dataspace", | ||
18 | "PixelFormat", | 19 | "PixelFormat", |
19 | ], | 20 | ], |
20 | gen_java: true, | 21 | gen_java: true, |
diff --git a/graphics/common/1.1/types.hal b/graphics/common/1.1/types.hal index 135f6e3c..b917d5e8 100644 --- a/graphics/common/1.1/types.hal +++ b/graphics/common/1.1/types.hal | |||
@@ -18,6 +18,7 @@ package android.hardware.graphics.common@1.1; | |||
18 | 18 | ||
19 | import @1.0::PixelFormat; | 19 | import @1.0::PixelFormat; |
20 | import @1.0::BufferUsage; | 20 | import @1.0::BufferUsage; |
21 | import @1.0::Dataspace; | ||
21 | 22 | ||
22 | /** | 23 | /** |
23 | * Pixel formats for graphics buffers. | 24 | * Pixel formats for graphics buffers. |
@@ -77,6 +78,39 @@ enum PixelFormat : @1.0::PixelFormat { | |||
77 | * defined by the dataspace. | 78 | * defined by the dataspace. |
78 | */ | 79 | */ |
79 | STENCIL_8 = 0x35, | 80 | STENCIL_8 = 0x35, |
81 | |||
82 | /** | ||
83 | * P010 is a 4:2:0 YCbCr semiplanar format comprised of a WxH Y plane | ||
84 | * followed immediately by a Wx(H/2) CbCr plane. Each sample is | ||
85 | * represented by a 16-bit little-endian value, with the lower 6 bits set | ||
86 | * to zero. | ||
87 | * | ||
88 | * This format assumes | ||
89 | * - an even height | ||
90 | * - a vertical stride equal to the height | ||
91 | * | ||
92 | * stride_in_bytes = stride * 2 | ||
93 | * y_size = stride_in_bytes * height | ||
94 | * cbcr_size = stride_in_bytes * (height / 2) | ||
95 | * cb_offset = y_size | ||
96 | * cr_offset = cb_offset + 2 | ||
97 | * | ||
98 | * This format must be accepted by the allocator when used with the | ||
99 | * following usage flags: | ||
100 | * | ||
101 | * - BufferUsage::VIDEO_* | ||
102 | * - BufferUsage::CPU_* | ||
103 | * - BufferUsage::GPU_TEXTURE | ||
104 | * | ||
105 | * The component values are unsigned normalized to the range [0, 1], whose | ||
106 | * interpretation is defined by the dataspace. | ||
107 | * | ||
108 | * This format is appropriate for 10bit video content. | ||
109 | * | ||
110 | * Buffers with this format must be locked with IMapper::lockYCbCr | ||
111 | * or with IMapper::lock. | ||
112 | */ | ||
113 | YCBCR_P010 = 0x36, | ||
80 | }; | 114 | }; |
81 | 115 | ||
82 | /** | 116 | /** |
@@ -91,3 +125,19 @@ enum BufferUsage : @1.0::BufferUsage { | |||
91 | 125 | ||
92 | /** bits 27 and 32-47 must be zero and are reserved for future versions */ | 126 | /** bits 27 and 32-47 must be zero and are reserved for future versions */ |
93 | }; | 127 | }; |
128 | |||
129 | @export(name="android_dataspace_v1_1_t", value_prefix="HAL_DATASPACE_", | ||
130 | export_parent="false") | ||
131 | enum Dataspace : @1.0::Dataspace { | ||
132 | /** | ||
133 | * ITU-R Recommendation 2020 (BT.2020) | ||
134 | * | ||
135 | * Ultra High-definition television | ||
136 | * | ||
137 | * Use limited range, SMPTE 2084 (PQ) transfer and BT2020 standard | ||
138 | * limited range is the preferred / normative definition for BT.2020 | ||
139 | */ | ||
140 | BT2020_ITU = STANDARD_BT2020 | TRANSFER_SMPTE_170M | RANGE_LIMITED, | ||
141 | |||
142 | BT2020_ITU_PQ = STANDARD_BT2020 | TRANSFER_ST2084 | RANGE_LIMITED, | ||
143 | }; | ||
diff --git a/graphics/composer/2.1/vts/functional/VtsHalGraphicsComposerTestUtils.h b/graphics/composer/2.1/vts/functional/VtsHalGraphicsComposerTestUtils.h index 29b9de35..00d9d8c9 100644 --- a/graphics/composer/2.1/vts/functional/VtsHalGraphicsComposerTestUtils.h +++ b/graphics/composer/2.1/vts/functional/VtsHalGraphicsComposerTestUtils.h | |||
@@ -58,10 +58,12 @@ class Composer { | |||
58 | std::string dumpDebugInfo(); | 58 | std::string dumpDebugInfo(); |
59 | std::unique_ptr<ComposerClient> createClient(); | 59 | std::unique_ptr<ComposerClient> createClient(); |
60 | 60 | ||
61 | protected: | ||
62 | sp<IComposer> mComposer; | ||
63 | |||
61 | private: | 64 | private: |
62 | void init(); | 65 | void init(); |
63 | 66 | ||
64 | sp<IComposer> mComposer; | ||
65 | std::unordered_set<IComposer::Capability> mCapabilities; | 67 | std::unordered_set<IComposer::Capability> mCapabilities; |
66 | }; | 68 | }; |
67 | 69 | ||
diff --git a/graphics/composer/2.2/Android.bp b/graphics/composer/2.2/Android.bp new file mode 100644 index 00000000..633a208c --- /dev/null +++ b/graphics/composer/2.2/Android.bp | |||
@@ -0,0 +1,20 @@ | |||
1 | // This file is autogenerated by hidl-gen -Landroidbp. | ||
2 | |||
3 | hidl_interface { | ||
4 | name: "android.hardware.graphics.composer@2.2", | ||
5 | root: "android.hardware", | ||
6 | vndk: { | ||
7 | enabled: true, | ||
8 | }, | ||
9 | srcs: [ | ||
10 | "IComposer.hal", | ||
11 | "IComposerClient.hal", | ||
12 | ], | ||
13 | interfaces: [ | ||
14 | "android.hardware.graphics.common@1.0", | ||
15 | "android.hardware.graphics.composer@2.1", | ||
16 | "android.hidl.base@1.0", | ||
17 | ], | ||
18 | gen_java: false, | ||
19 | } | ||
20 | |||
diff --git a/graphics/composer/2.2/IComposer.hal b/graphics/composer/2.2/IComposer.hal new file mode 100644 index 00000000..05052c89 --- /dev/null +++ b/graphics/composer/2.2/IComposer.hal | |||
@@ -0,0 +1,25 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2018 The Android Open Source Project | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | package android.hardware.graphics.composer@2.2; | ||
18 | |||
19 | import @2.1::IComposer; | ||
20 | |||
21 | interface IComposer extends @2.1::IComposer { | ||
22 | |||
23 | /* createClient from @2.1::IComposer must return an instance of @2.2::IComposerClient */ | ||
24 | |||
25 | }; | ||
diff --git a/graphics/composer/2.2/IComposerClient.hal b/graphics/composer/2.2/IComposerClient.hal new file mode 100644 index 00000000..4a884bc9 --- /dev/null +++ b/graphics/composer/2.2/IComposerClient.hal | |||
@@ -0,0 +1,243 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2018 The Android Open Source Project | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | package android.hardware.graphics.composer@2.2; | ||
18 | |||
19 | import android.hardware.graphics.common@1.0::PixelFormat; | ||
20 | import android.hardware.graphics.common@1.0::Dataspace; | ||
21 | import @2.1::IComposerClient; | ||
22 | import @2.1::Display; | ||
23 | import @2.1::Error; | ||
24 | |||
25 | interface IComposerClient extends @2.1::IComposerClient { | ||
26 | |||
27 | enum PowerMode : @2.1::IComposerClient.PowerMode { | ||
28 | /** | ||
29 | * The display is configured as in ON but may stop applying display | ||
30 | * updates from the client. This is effectively a hint to the device | ||
31 | * that drawing to the display has been suspended and that the the | ||
32 | * device must remain on and continue displaying its current contents | ||
33 | * indefinitely until the power mode changes. | ||
34 | * | ||
35 | * This mode may also be used as a signal to enable hardware-based | ||
36 | * functionality to take over the display and manage it autonomously | ||
37 | * to implement a low power always-on display. | ||
38 | */ | ||
39 | ON_SUSPEND = 4 | ||
40 | }; | ||
41 | |||
42 | /** | ||
43 | * Following enums define keys for metadata defined by SMPTE ST 2086:2014 | ||
44 | * and CTA 861.3. | ||
45 | */ | ||
46 | enum PerFrameMetadataKey : int32_t { | ||
47 | /** SMPTE ST 2084:2014. | ||
48 | * Coordinates defined in CIE 1931 xy chromaticity space | ||
49 | */ | ||
50 | /** SMPTE ST 2084:2014 */ | ||
51 | DISPLAY_RED_PRIMARY_X, | ||
52 | /** SMPTE ST 2084:2014 */ | ||
53 | DISPLAY_RED_PRIMARY_Y, | ||
54 | /** SMPTE ST 2084:2014 */ | ||
55 | DISPLAY_GREEN_PRIMARY_X, | ||
56 | /** SMPTE ST 2084:2014 */ | ||
57 | DISPLAY_GREEN_PRIMARY_Y, | ||
58 | /** SMPTE ST 2084:2014 */ | ||
59 | DISPLAY_BLUE_PRIMARY_X, | ||
60 | /** SMPTE ST 2084:2014 */ | ||
61 | DISPLAY_BLUE_PRIMARY_Y, | ||
62 | /** SMPTE ST 2084:2014 */ | ||
63 | WHITE_POINT_X, | ||
64 | /** SMPTE ST 2084:2014 */ | ||
65 | WHITE_POINT_Y, | ||
66 | /** SMPTE ST 2084:2014. | ||
67 | * Units: nits | ||
68 | * max as defined by ST 2048: 10,000 nits | ||
69 | */ | ||
70 | MAX_LUMINANCE, | ||
71 | /** SMPTE ST 2084:2014 */ | ||
72 | MIN_LUMINANCE, | ||
73 | /** CTA 861.3 */ | ||
74 | MAX_CONTENT_LIGHT_LEVEL, | ||
75 | /** CTA 861.3 */ | ||
76 | MAX_FRAME_AVERAGE_LIGHT_LEVEL, | ||
77 | }; | ||
78 | |||
79 | struct PerFrameMetadata { | ||
80 | PerFrameMetadataKey key; | ||
81 | float value; | ||
82 | }; | ||
83 | |||
84 | /** | ||
85 | * setPerFrameMetadata(Display display, vec<PerFrameMetadata> data) | ||
86 | * Sets the PerFrameMetadata for the display. This metadata must be used | ||
87 | * by the implementation to better tone map content to that display. | ||
88 | * | ||
89 | * This is a method that may be called every frame. Thus it's | ||
90 | * implemented using buffered transport. | ||
91 | * SET_PER_FRAME_METADATA is the command used by the buffered transport | ||
92 | * mechanism. | ||
93 | */ | ||
94 | enum Command : @2.1::IComposerClient.Command { | ||
95 | SET_PER_FRAME_METADATA = 0x207 << @2.1::IComposerClient.Command:OPCODE_SHIFT, | ||
96 | }; | ||
97 | |||
98 | /** | ||
99 | * Returns the PerFrameMetadataKeys that are supported by this device. | ||
100 | * | ||
101 | * @param display is the display on which to create the layer. | ||
102 | * @return keys is the vector of PerFrameMetadataKey keys that are | ||
103 | * supported by this device. | ||
104 | * @return error is NONE upon success. Otherwise, | ||
105 | * UNSUPPORTED if not supported on underlying HAL | ||
106 | */ | ||
107 | getPerFrameMetadataKeys(Display display) | ||
108 | generates (Error error, | ||
109 | vec<PerFrameMetadataKey> keys); | ||
110 | |||
111 | /** | ||
112 | * getReadbackBufferAttributes | ||
113 | * Returns the format which should be used when allocating a buffer for use by | ||
114 | * device readback as well as the dataspace in which its contents should be | ||
115 | * interpreted. | ||
116 | * | ||
117 | * The width and height of this buffer must be those of the currently-active | ||
118 | * display configuration, and the usage flags must consist of the following: | ||
119 | * BufferUsage::CPU_READ | BufferUsage::GPU_TEXTURE | | ||
120 | * BufferUsage::COMPOSER_OUTPUT | ||
121 | * | ||
122 | * The format and dataspace provided must be sufficient such that if a | ||
123 | * correctly-configured buffer is passed into setReadbackBuffer, filled by | ||
124 | * the device, and then displayed by the client as a full-screen buffer, the | ||
125 | * output of the display remains the same (subject to the note about protected | ||
126 | * content in the description of setReadbackBuffer). | ||
127 | * | ||
128 | * Parameters: | ||
129 | * @param display - the display on which to create the layer. | ||
130 | * | ||
131 | * @return format - the format the client should use when allocating a device | ||
132 | * readback buffer | ||
133 | * @return dataspace - the dataspace to use when interpreting the | ||
134 | * contents of a device readback buffer | ||
135 | * @return error is NONE upon success. Otherwise, | ||
136 | * BAD_DISPLAY when an invalid display handle was passed in. | ||
137 | * UNSUPPORTED if not supported on underlying HAL | ||
138 | * | ||
139 | * See also: | ||
140 | * setReadbackBuffer | ||
141 | * getReadbackBufferFence | ||
142 | */ | ||
143 | getReadbackBufferAttributes(Display display) | ||
144 | generates (Error error, | ||
145 | PixelFormat format, | ||
146 | Dataspace dataspace); | ||
147 | |||
148 | /** | ||
149 | * getReadbackBufferFence | ||
150 | * Returns an acquire sync fence file descriptor which must signal when the | ||
151 | * buffer provided to setReadbackBuffer has been filled by the device and is | ||
152 | * safe for the client to read. | ||
153 | * | ||
154 | * If it is already safe to read from this buffer, -1 may be returned instead. | ||
155 | * The client takes ownership of this file descriptor and is responsible for | ||
156 | * closing it when it is no longer needed. | ||
157 | * | ||
158 | * This function must be called immediately after the composition cycle being | ||
159 | * captured into the readback buffer. The complete ordering of a readback buffer | ||
160 | * capture is as follows: | ||
161 | * | ||
162 | * getReadbackBufferAttributes | ||
163 | * // Readback buffer is allocated | ||
164 | * // Many frames may pass | ||
165 | * | ||
166 | * setReadbackBuffer | ||
167 | * validateDisplay | ||
168 | * presentDisplay | ||
169 | * getReadbackBufferFence | ||
170 | * // Implicitly wait on the acquire fence before accessing the buffer | ||
171 | * | ||
172 | * Parameters: | ||
173 | * @param display - the display on which to create the layer. | ||
174 | * | ||
175 | * @return acquireFence - a sync fence file descriptor as described above; pointer | ||
176 | * must be non-NULL | ||
177 | * @return error - is HWC2_ERROR_NONE or one of the following errors: | ||
178 | * BAD_DISPLAY - an invalid display handle was passed in | ||
179 | * UNSUPPORTED if not supported on underlying HAL | ||
180 | * | ||
181 | * See also: | ||
182 | * getReadbackBufferAttributes | ||
183 | * setReadbackBuffer | ||
184 | */ | ||
185 | getReadbackBufferFence(Display display) | ||
186 | generates (Error error, | ||
187 | handle acquireFence); | ||
188 | |||
189 | /** | ||
190 | * setReadbackBuffer | ||
191 | * Sets the readback buffer to be filled with the contents of the next | ||
192 | * composition performed for this display (i.e., the contents present at the | ||
193 | * time of the next validateDisplay/presentDisplay cycle). | ||
194 | * | ||
195 | * This buffer must have been allocated as described in | ||
196 | * getReadbackBufferAttributes and is in the dataspace provided by the same. | ||
197 | * | ||
198 | * If there is hardware protected content on the display at the time of the next | ||
199 | * composition, the area of the readback buffer covered by such content must be | ||
200 | * completely black. Any areas of the buffer not covered by such content may | ||
201 | * optionally be black as well. | ||
202 | * | ||
203 | * The release fence file descriptor provided works identically to the one | ||
204 | * described for setOutputBuffer. | ||
205 | * | ||
206 | * This function must not be called between any call to validateDisplay and a | ||
207 | * subsequent call to presentDisplay. | ||
208 | * | ||
209 | * Parameters: | ||
210 | * @param display - the display on which to create the layer. | ||
211 | * @param buffer - the new readback buffer | ||
212 | * @param releaseFence - a sync fence file descriptor as described in setOutputBuffer | ||
213 | * | ||
214 | * @return error - is HWC2_ERROR_NONE or one of the following errors: | ||
215 | * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in | ||
216 | * HWC2_ERROR_BAD_PARAMETER - the new readback buffer handle was invalid | ||
217 | * | ||
218 | * See also: | ||
219 | * getReadbackBufferAttributes | ||
220 | * getReadbackBufferFence | ||
221 | */ | ||
222 | setReadbackBuffer(Display display, handle buffer, handle releaseFence) generates (Error error); | ||
223 | |||
224 | /** | ||
225 | * setPowerMode_2_2 | ||
226 | * Sets the power mode of the given display. The transition must be | ||
227 | * complete when this function returns. It is valid to call this function | ||
228 | * multiple times with the same power mode. | ||
229 | * | ||
230 | * All displays must support PowerMode::ON and PowerMode::OFF. Whether a | ||
231 | * display supports PowerMode::DOZE or PowerMode::DOZE_SUSPEND may be | ||
232 | * queried using getDozeSupport. | ||
233 | * | ||
234 | * @param display is the display to which the power mode is set. | ||
235 | * @param mode is the new power mode. | ||
236 | * @return error is NONE upon success. Otherwise, | ||
237 | * BAD_DISPLAY when an invalid display handle was passed in. | ||
238 | * BAD_PARAMETER when mode was not a valid power mode. | ||
239 | * UNSUPPORTED when mode is not supported on this display. | ||
240 | */ | ||
241 | setPowerMode_2_2(Display display, PowerMode mode) generates (Error error); | ||
242 | |||
243 | }; | ||
diff --git a/graphics/composer/2.2/utils/OWNERS b/graphics/composer/2.2/utils/OWNERS new file mode 100644 index 00000000..1beb074f --- /dev/null +++ b/graphics/composer/2.2/utils/OWNERS | |||
@@ -0,0 +1,8 @@ | |||
1 | # Graphics team | ||
2 | courtneygo@google.com | ||
3 | olv@google.com | ||
4 | stoza@google.com | ||
5 | |||
6 | # VTS team | ||
7 | yim@google.com | ||
8 | zhuoyao@google.com | ||
diff --git a/graphics/composer/2.2/utils/command-buffer/Android.bp b/graphics/composer/2.2/utils/command-buffer/Android.bp new file mode 100644 index 00000000..efaabd46 --- /dev/null +++ b/graphics/composer/2.2/utils/command-buffer/Android.bp | |||
@@ -0,0 +1,13 @@ | |||
1 | cc_library_headers { | ||
2 | name: "android.hardware.graphics.composer@2.2-command-buffer", | ||
3 | defaults: ["hidl_defaults"], | ||
4 | vendor_available: true, | ||
5 | shared_libs: [ | ||
6 | "android.hardware.graphics.composer@2.1", | ||
7 | "android.hardware.graphics.composer@2.2", | ||
8 | ], | ||
9 | header_libs: [ | ||
10 | "android.hardware.graphics.composer@2.1-command-buffer", | ||
11 | ], | ||
12 | export_include_dirs: ["include"], | ||
13 | } | ||
diff --git a/graphics/composer/2.2/utils/command-buffer/include/composer-command-buffer/2.2/ComposerCommandBuffer.h b/graphics/composer/2.2/utils/command-buffer/include/composer-command-buffer/2.2/ComposerCommandBuffer.h new file mode 100644 index 00000000..f953b96c --- /dev/null +++ b/graphics/composer/2.2/utils/command-buffer/include/composer-command-buffer/2.2/ComposerCommandBuffer.h | |||
@@ -0,0 +1,94 @@ | |||
1 | /* | ||
2 | * Copyright 2018 The Android Open Source Project | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | #pragma once | ||
18 | |||
19 | #ifndef LOG_TAG | ||
20 | #warn "ComposerCommandBuffer.h included without LOG_TAG" | ||
21 | #endif | ||
22 | |||
23 | #undef LOG_NDEBUG | ||
24 | #define LOG_NDEBUG 0 | ||
25 | |||
26 | #include <algorithm> | ||
27 | #include <limits> | ||
28 | #include <memory> | ||
29 | #include <vector> | ||
30 | |||
31 | #include <inttypes.h> | ||
32 | #include <string.h> | ||
33 | |||
34 | #include <android/hardware/graphics/composer/2.2/IComposer.h> | ||
35 | #include <android/hardware/graphics/composer/2.2/IComposerClient.h> | ||
36 | #include <fmq/MessageQueue.h> | ||
37 | #include <log/log.h> | ||
38 | #include <sync/sync.h> | ||
39 | |||
40 | #include <composer-command-buffer/2.1/ComposerCommandBuffer.h> | ||
41 | |||
42 | namespace android { | ||
43 | namespace hardware { | ||
44 | namespace graphics { | ||
45 | namespace composer { | ||
46 | namespace V2_2 { | ||
47 | |||
48 | using android::hardware::MessageQueue; | ||
49 | using android::hardware::graphics::common::V1_0::ColorTransform; | ||
50 | using android::hardware::graphics::common::V1_0::Dataspace; | ||
51 | using android::hardware::graphics::common::V1_0::Transform; | ||
52 | using android::hardware::graphics::composer::V2_1::Config; | ||
53 | using android::hardware::graphics::composer::V2_1::Display; | ||
54 | using android::hardware::graphics::composer::V2_1::Error; | ||
55 | using android::hardware::graphics::composer::V2_1::IComposerCallback; | ||
56 | using android::hardware::graphics::composer::V2_1::Layer; | ||
57 | using android::hardware::graphics::composer::V2_2::IComposerClient; | ||
58 | |||
59 | using CommandQueueType = MessageQueue<uint32_t, kSynchronizedReadWrite>; | ||
60 | |||
61 | // This class helps build a command queue. Note that all sizes/lengths are in | ||
62 | // units of uint32_t's. | ||
63 | class CommandWriterBase : public V2_1::CommandWriterBase { | ||
64 | public: | ||
65 | CommandWriterBase(uint32_t initialMaxSize) : V2_1::CommandWriterBase(initialMaxSize) {} | ||
66 | |||
67 | void setPerFrameMetadata(const hidl_vec<IComposerClient::PerFrameMetadata>& metadataVec) { | ||
68 | beginCommand2_2(IComposerClient::Command::SET_PER_FRAME_METADATA, metadataVec.size() * 2); | ||
69 | for (const auto& metadata : metadataVec) { | ||
70 | writeSigned(static_cast<int32_t>(metadata.key)); | ||
71 | writeFloat(metadata.value); | ||
72 | } | ||
73 | endCommand(); | ||
74 | } | ||
75 | |||
76 | protected: | ||
77 | void beginCommand2_2(IComposerClient::Command command, uint16_t length) { | ||
78 | V2_1::CommandWriterBase::beginCommand( | ||
79 | static_cast<V2_1::IComposerClient::Command>(static_cast<int32_t>(command)), length); | ||
80 | } | ||
81 | }; | ||
82 | |||
83 | // This class helps parse a command queue. Note that all sizes/lengths are in | ||
84 | // units of uint32_t's. | ||
85 | class CommandReaderBase : public V2_1::CommandReaderBase { | ||
86 | public: | ||
87 | CommandReaderBase() : V2_1::CommandReaderBase(){}; | ||
88 | }; | ||
89 | |||
90 | } // namespace V2_2 | ||
91 | } // namespace composer | ||
92 | } // namespace graphics | ||
93 | } // namespace hardware | ||
94 | } // namespace android | ||
diff --git a/graphics/composer/2.2/vts/functional/Android.bp b/graphics/composer/2.2/vts/functional/Android.bp new file mode 100644 index 00000000..0325a6c5 --- /dev/null +++ b/graphics/composer/2.2/vts/functional/Android.bp | |||
@@ -0,0 +1,74 @@ | |||
1 | // | ||
2 | // Copyright (C) 2018 The Android Open Source Project | ||
3 | // | ||
4 | // Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | // you may not use this file except in compliance with the License. | ||
6 | // You may obtain a copy of the License at | ||
7 | // | ||
8 | // http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | // | ||
10 | // Unless required by applicable law or agreed to in writing, software | ||
11 | // distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | // See the License for the specific language governing permissions and | ||
14 | // limitations under the License. | ||
15 | // | ||
16 | |||
17 | cc_library_static { | ||
18 | name: "libVtsHalGraphicsComposerTestUtils@2.2", | ||
19 | defaults: ["hidl_defaults"], | ||
20 | srcs: [ | ||
21 | "VtsHalGraphicsComposerTestUtils.cpp", | ||
22 | ], | ||
23 | shared_libs: [ | ||
24 | "android.hardware.graphics.composer@2.1", | ||
25 | "android.hardware.graphics.composer@2.2", | ||
26 | "libfmq", | ||
27 | "libsync", | ||
28 | ], | ||
29 | static_libs: [ | ||
30 | "libVtsHalGraphicsComposerTestUtils", | ||
31 | "VtsHalHidlTargetTestBase", | ||
32 | ], | ||
33 | header_libs: [ | ||
34 | "android.hardware.graphics.composer@2.1-command-buffer", | ||
35 | "android.hardware.graphics.composer@2.2-command-buffer", | ||
36 | ], | ||
37 | cflags: [ | ||
38 | "-Wall", | ||
39 | "-Wextra", | ||
40 | "-Werror", | ||
41 | "-O0", | ||
42 | "-g", | ||
43 | "-DLOG_TAG=\"GraphicsComposerTestUtils@2.2\"", | ||
44 | ], | ||
45 | export_include_dirs: ["include"], | ||
46 | } | ||
47 | |||
48 | cc_test { | ||
49 | name: "VtsHalGraphicsComposerV2_2TargetTest", | ||
50 | defaults: ["VtsHalTargetTestDefaults"], | ||
51 | srcs: ["VtsHalGraphicsComposerV2_2TargetTest.cpp"], | ||
52 | |||
53 | // TODO(b/64437680): Assume these libs are always available on the device. | ||
54 | shared_libs: [ | ||
55 | "libfmq", | ||
56 | "libhidltransport", | ||
57 | "libsync", | ||
58 | ], | ||
59 | static_libs: [ | ||
60 | "android.hardware.graphics.allocator@2.0", | ||
61 | "android.hardware.graphics.composer@2.2", | ||
62 | "android.hardware.graphics.composer@2.1", | ||
63 | "android.hardware.graphics.mapper@2.0", | ||
64 | "android.hardware.graphics.mapper@2.1", | ||
65 | "libVtsHalGraphicsComposerTestUtils", | ||
66 | "libVtsHalGraphicsComposerTestUtils@2.2", | ||
67 | "libVtsHalGraphicsMapperTestUtils", | ||
68 | "libnativehelper", | ||
69 | ], | ||
70 | header_libs: [ | ||
71 | "android.hardware.graphics.composer@2.1-command-buffer", | ||
72 | "android.hardware.graphics.composer@2.2-command-buffer", | ||
73 | ], | ||
74 | } | ||
diff --git a/graphics/composer/2.2/vts/functional/OWNERS b/graphics/composer/2.2/vts/functional/OWNERS new file mode 100644 index 00000000..1beb074f --- /dev/null +++ b/graphics/composer/2.2/vts/functional/OWNERS | |||
@@ -0,0 +1,8 @@ | |||
1 | # Graphics team | ||
2 | courtneygo@google.com | ||
3 | olv@google.com | ||
4 | stoza@google.com | ||
5 | |||
6 | # VTS team | ||
7 | yim@google.com | ||
8 | zhuoyao@google.com | ||
diff --git a/graphics/composer/2.2/vts/functional/VtsHalGraphicsComposerTestUtils.cpp b/graphics/composer/2.2/vts/functional/VtsHalGraphicsComposerTestUtils.cpp new file mode 100644 index 00000000..00946cef --- /dev/null +++ b/graphics/composer/2.2/vts/functional/VtsHalGraphicsComposerTestUtils.cpp | |||
@@ -0,0 +1,127 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2018 The Android Open Source Project | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | #include <VtsHalHidlTargetTestBase.h> | ||
18 | #include <hidl/HidlTransportUtils.h> | ||
19 | |||
20 | #include <composer-command-buffer/2.2/ComposerCommandBuffer.h> | ||
21 | #include "2.2/VtsHalGraphicsComposerTestUtils.h" | ||
22 | |||
23 | namespace android { | ||
24 | namespace hardware { | ||
25 | namespace graphics { | ||
26 | namespace composer { | ||
27 | namespace V2_2 { | ||
28 | namespace tests { | ||
29 | |||
30 | using android::hardware::graphics::composer::V2_2::IComposerClient; | ||
31 | using android::hardware::details::getDescriptor; | ||
32 | using android::hardware::details::canCastInterface; | ||
33 | |||
34 | std::unique_ptr<ComposerClient_v2_2> Composer_v2_2::createClient_v2_2() { | ||
35 | std::unique_ptr<ComposerClient_v2_2> client; | ||
36 | mComposer->createClient([&](const auto& tmpError, const auto& tmpClient) { | ||
37 | ASSERT_EQ(Error::NONE, tmpError) << "failed to create client"; | ||
38 | ALOGV("tmpClient is a %s", getDescriptor(&(*tmpClient)).c_str()); | ||
39 | ASSERT_TRUE(canCastInterface( | ||
40 | &(*tmpClient), "android.hardware.graphics.composer@2.2::IComposerClient", false)) | ||
41 | << "Cannot create 2.2 IComposerClient"; | ||
42 | client = std::make_unique<ComposerClient_v2_2>(IComposerClient::castFrom(tmpClient, true)); | ||
43 | }); | ||
44 | |||
45 | return client; | ||
46 | } | ||
47 | |||
48 | std::vector<IComposerClient::PerFrameMetadataKey> ComposerClient_v2_2::getPerFrameMetadataKeys( | ||
49 | Display display) { | ||
50 | std::vector<IComposerClient::PerFrameMetadataKey> keys; | ||
51 | mClient_v2_2->getPerFrameMetadataKeys(display, [&](const auto& tmpError, const auto& tmpKeys) { | ||
52 | ASSERT_EQ(Error::NONE, tmpError) << "failed to get HDR metadata keys"; | ||
53 | keys = tmpKeys; | ||
54 | }); | ||
55 | |||
56 | return keys; | ||
57 | } | ||
58 | |||
59 | void ComposerClient_v2_2::execute_v2_2(V2_1::tests::TestCommandReader* reader, | ||
60 | V2_2::CommandWriterBase* writer) { | ||
61 | bool queueChanged = false; | ||
62 | uint32_t commandLength = 0; | ||
63 | hidl_vec<hidl_handle> commandHandles; | ||
64 | ASSERT_TRUE(writer->writeQueue(&queueChanged, &commandLength, &commandHandles)); | ||
65 | |||
66 | if (queueChanged) { | ||
67 | auto ret = mClient_v2_2->setInputCommandQueue(*writer->getMQDescriptor()); | ||
68 | ASSERT_EQ(Error::NONE, static_cast<Error>(ret)); | ||
69 | return; | ||
70 | } | ||
71 | |||
72 | mClient_v2_2->executeCommands(commandLength, commandHandles, | ||
73 | [&](const auto& tmpError, const auto& tmpOutQueueChanged, | ||
74 | const auto& tmpOutLength, const auto& tmpOutHandles) { | ||
75 | ASSERT_EQ(Error::NONE, tmpError); | ||
76 | |||
77 | if (tmpOutQueueChanged) { | ||
78 | mClient_v2_2->getOutputCommandQueue( | ||
79 | [&](const auto& tmpError, const auto& tmpDescriptor) { | ||
80 | ASSERT_EQ(Error::NONE, tmpError); | ||
81 | reader->setMQDescriptor(tmpDescriptor); | ||
82 | }); | ||
83 | } | ||
84 | |||
85 | ASSERT_TRUE(reader->readQueue(tmpOutLength, tmpOutHandles)); | ||
86 | reader->parse(); | ||
87 | }); | ||
88 | } | ||
89 | |||
90 | void ComposerClient_v2_2::setPowerMode_2_2(Display display, V2_2::IComposerClient::PowerMode mode) { | ||
91 | Error error = mClient_v2_2->setPowerMode_2_2(display, mode); | ||
92 | ASSERT_TRUE(error == Error::NONE || error == Error::UNSUPPORTED) << "failed to set power mode"; | ||
93 | } | ||
94 | |||
95 | void ComposerClient_v2_2::setReadbackBuffer(Display display, const native_handle_t* buffer, | ||
96 | int32_t /* releaseFence */) { | ||
97 | // Ignoring fence, HIDL doesn't care | ||
98 | Error error = mClient_v2_2->setReadbackBuffer(display, buffer, nullptr); | ||
99 | ASSERT_EQ(Error::NONE, error) << "failed to setReadbackBuffer"; | ||
100 | } | ||
101 | |||
102 | void ComposerClient_v2_2::getReadbackBufferAttributes(Display display, PixelFormat* outPixelFormat, | ||
103 | Dataspace* outDataspace) { | ||
104 | mClient_v2_2->getReadbackBufferAttributes( | ||
105 | display, | ||
106 | [&](const auto& tmpError, const auto& tmpOutPixelFormat, const auto& tmpOutDataspace) { | ||
107 | ASSERT_EQ(Error::NONE, tmpError) << "failed to get readback buffer attributes"; | ||
108 | *outPixelFormat = tmpOutPixelFormat; | ||
109 | *outDataspace = tmpOutDataspace; | ||
110 | }); | ||
111 | } | ||
112 | |||
113 | void ComposerClient_v2_2::getReadbackBufferFence(Display display, int32_t* outFence) { | ||
114 | hidl_handle handle; | ||
115 | mClient_v2_2->getReadbackBufferFence(display, [&](const auto& tmpError, const auto& tmpHandle) { | ||
116 | ASSERT_EQ(Error::NONE, tmpError) << "failed to get readback fence"; | ||
117 | handle = tmpHandle; | ||
118 | }); | ||
119 | *outFence = 0; | ||
120 | } | ||
121 | |||
122 | } // namespace tests | ||
123 | } // namespace V2_2 | ||
124 | } // namespace composer | ||
125 | } // namespace graphics | ||
126 | } // namespace hardware | ||
127 | } // namespace android | ||
diff --git a/graphics/composer/2.2/vts/functional/VtsHalGraphicsComposerV2_2TargetTest.cpp b/graphics/composer/2.2/vts/functional/VtsHalGraphicsComposerV2_2TargetTest.cpp new file mode 100644 index 00000000..d7826bf3 --- /dev/null +++ b/graphics/composer/2.2/vts/functional/VtsHalGraphicsComposerV2_2TargetTest.cpp | |||
@@ -0,0 +1,242 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2018 The Android Open Source Project | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | #define LOG_TAG "graphics_composer_hidl_hal_test@2.2" | ||
18 | |||
19 | #include <android-base/logging.h> | ||
20 | #include <android/hardware/graphics/mapper/2.1/IMapper.h> | ||
21 | #include <sync/sync.h> | ||
22 | #include "2.2/VtsHalGraphicsComposerTestUtils.h" | ||
23 | #include "GraphicsComposerCallback.h" | ||
24 | #include "TestCommandReader.h" | ||
25 | #include "VtsHalGraphicsComposerTestUtils.h" | ||
26 | #include "VtsHalGraphicsMapperTestUtils.h" | ||
27 | |||
28 | #include <VtsHalHidlTargetTestBase.h> | ||
29 | |||
30 | namespace android { | ||
31 | namespace hardware { | ||
32 | namespace graphics { | ||
33 | namespace composer { | ||
34 | namespace V2_2 { | ||
35 | namespace tests { | ||
36 | namespace { | ||
37 | |||
38 | using android::hardware::graphics::common::V1_0::BufferUsage; | ||
39 | using android::hardware::graphics::common::V1_0::ColorMode; | ||
40 | using android::hardware::graphics::common::V1_0::ColorTransform; | ||
41 | using android::hardware::graphics::common::V1_0::Dataspace; | ||
42 | using android::hardware::graphics::common::V1_0::PixelFormat; | ||
43 | using android::hardware::graphics::common::V1_0::Transform; | ||
44 | using android::hardware::graphics::composer::V2_2::IComposerClient; | ||
45 | using android::hardware::graphics::mapper::V2_0::IMapper; | ||
46 | using android::hardware::graphics::mapper::V2_0::tests::Gralloc; | ||
47 | using GrallocError = android::hardware::graphics::mapper::V2_0::Error; | ||
48 | |||
49 | // Test environment for graphics.composer | ||
50 | class GraphicsComposerHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase { | ||
51 | public: | ||
52 | // get the test environment singleton | ||
53 | static GraphicsComposerHidlEnvironment* Instance() { | ||
54 | static GraphicsComposerHidlEnvironment* instance = new GraphicsComposerHidlEnvironment; | ||
55 | return instance; | ||
56 | } | ||
57 | |||
58 | virtual void registerTestServices() override { registerTestService<IComposer>(); } | ||
59 | |||
60 | private: | ||
61 | GraphicsComposerHidlEnvironment() {} | ||
62 | |||
63 | GTEST_DISALLOW_COPY_AND_ASSIGN_(GraphicsComposerHidlEnvironment); | ||
64 | }; | ||
65 | |||
66 | class GraphicsComposerHidlTest : public ::testing::VtsHalHidlTargetTestBase { | ||
67 | protected: | ||
68 | void SetUp() override { | ||
69 | ASSERT_NO_FATAL_FAILURE( | ||
70 | mComposer = std::make_unique<Composer_v2_2>( | ||
71 | GraphicsComposerHidlEnvironment::Instance()->getServiceName<IComposer>())); | ||
72 | ASSERT_NO_FATAL_FAILURE(mComposerClient = mComposer->createClient_v2_2()); | ||
73 | |||
74 | mComposerCallback = new V2_1::tests::GraphicsComposerCallback; | ||
75 | mComposerClient->registerCallback(mComposerCallback); | ||
76 | |||
77 | // assume the first display is primary and is never removed | ||
78 | mPrimaryDisplay = waitForFirstDisplay(); | ||
79 | |||
80 | // explicitly disable vsync | ||
81 | mComposerClient->setVsyncEnabled(mPrimaryDisplay, false); | ||
82 | mComposerCallback->setVsyncAllowed(false); | ||
83 | } | ||
84 | |||
85 | void TearDown() override { | ||
86 | if (mComposerCallback != nullptr) { | ||
87 | EXPECT_EQ(0, mComposerCallback->getInvalidHotplugCount()); | ||
88 | EXPECT_EQ(0, mComposerCallback->getInvalidRefreshCount()); | ||
89 | EXPECT_EQ(0, mComposerCallback->getInvalidVsyncCount()); | ||
90 | } | ||
91 | } | ||
92 | |||
93 | // use the slot count usually set by SF | ||
94 | static constexpr uint32_t kBufferSlotCount = 64; | ||
95 | |||
96 | std::unique_ptr<Composer_v2_2> mComposer; | ||
97 | std::unique_ptr<ComposerClient_v2_2> mComposerClient; | ||
98 | sp<V2_1::tests::GraphicsComposerCallback> mComposerCallback; | ||
99 | // the first display and is assumed never to be removed | ||
100 | Display mPrimaryDisplay; | ||
101 | |||
102 | private: | ||
103 | Display waitForFirstDisplay() { | ||
104 | while (true) { | ||
105 | std::vector<Display> displays = mComposerCallback->getDisplays(); | ||
106 | if (displays.empty()) { | ||
107 | usleep(5 * 1000); | ||
108 | continue; | ||
109 | } | ||
110 | |||
111 | return displays[0]; | ||
112 | } | ||
113 | } | ||
114 | }; | ||
115 | |||
116 | // Tests for IComposerClient::Command. | ||
117 | class GraphicsComposerHidlCommandTest : public GraphicsComposerHidlTest { | ||
118 | protected: | ||
119 | void SetUp() override { | ||
120 | ASSERT_NO_FATAL_FAILURE(GraphicsComposerHidlTest::SetUp()); | ||
121 | |||
122 | ASSERT_NO_FATAL_FAILURE(mGralloc = std::make_unique<Gralloc>()); | ||
123 | |||
124 | mWriter = std::make_unique<V2_2::CommandWriterBase>(1024); | ||
125 | mReader = std::make_unique<V2_1::tests::TestCommandReader>(); | ||
126 | } | ||
127 | |||
128 | void TearDown() override { ASSERT_NO_FATAL_FAILURE(GraphicsComposerHidlTest::TearDown()); } | ||
129 | |||
130 | const native_handle_t* allocate() { | ||
131 | IMapper::BufferDescriptorInfo info{}; | ||
132 | info.width = 64; | ||
133 | info.height = 64; | ||
134 | info.layerCount = 1; | ||
135 | info.format = PixelFormat::RGBA_8888; | ||
136 | info.usage = | ||
137 | static_cast<uint64_t>(BufferUsage::CPU_WRITE_OFTEN | BufferUsage::CPU_READ_OFTEN); | ||
138 | |||
139 | return mGralloc->allocate(info); | ||
140 | } | ||
141 | |||
142 | void execute() { mComposerClient->execute_v2_2(mReader.get(), mWriter.get()); } | ||
143 | |||
144 | std::unique_ptr<V2_2::CommandWriterBase> mWriter; | ||
145 | std::unique_ptr<V2_1::tests::TestCommandReader> mReader; | ||
146 | |||
147 | private: | ||
148 | std::unique_ptr<Gralloc> mGralloc; | ||
149 | }; | ||
150 | |||
151 | /** | ||
152 | * Test IComposerClient::Command::SET_PER_FRAME_METADATA. | ||
153 | */ | ||
154 | TEST_F(GraphicsComposerHidlCommandTest, SET_PER_FRAME_METADATA) { | ||
155 | Layer layer; | ||
156 | ASSERT_NO_FATAL_FAILURE(layer = | ||
157 | mComposerClient->createLayer(mPrimaryDisplay, kBufferSlotCount)); | ||
158 | |||
159 | mWriter->selectDisplay(mPrimaryDisplay); | ||
160 | mWriter->selectLayer(layer); | ||
161 | |||
162 | /** | ||
163 | * DISPLAY_P3 is a color space that uses the DCI_P3 primaries, | ||
164 | * the D65 white point and the SRGB transfer functions. | ||
165 | * Rendering Intent: Colorimetric | ||
166 | * Primaries: | ||
167 | * x y | ||
168 | * green 0.265 0.690 | ||
169 | * blue 0.150 0.060 | ||
170 | * red 0.680 0.320 | ||
171 | * white (D65) 0.3127 0.3290 | ||
172 | */ | ||
173 | |||
174 | std::vector<IComposerClient::PerFrameMetadata> hidlMetadata; | ||
175 | hidlMetadata.push_back({IComposerClient::PerFrameMetadataKey::DISPLAY_RED_PRIMARY_X, 0.680}); | ||
176 | hidlMetadata.push_back({IComposerClient::PerFrameMetadataKey::DISPLAY_RED_PRIMARY_Y, 0.320}); | ||
177 | hidlMetadata.push_back({IComposerClient::PerFrameMetadataKey::DISPLAY_GREEN_PRIMARY_X, 0.265}); | ||
178 | hidlMetadata.push_back({IComposerClient::PerFrameMetadataKey::DISPLAY_GREEN_PRIMARY_Y, 0.690}); | ||
179 | hidlMetadata.push_back({IComposerClient::PerFrameMetadataKey::DISPLAY_BLUE_PRIMARY_X, 0.150}); | ||
180 | hidlMetadata.push_back({IComposerClient::PerFrameMetadataKey::DISPLAY_BLUE_PRIMARY_Y, 0.060}); | ||
181 | hidlMetadata.push_back({IComposerClient::PerFrameMetadataKey::WHITE_POINT_X, 0.3127}); | ||
182 | hidlMetadata.push_back({IComposerClient::PerFrameMetadataKey::WHITE_POINT_Y, 0.3290}); | ||
183 | hidlMetadata.push_back({IComposerClient::PerFrameMetadataKey::MAX_LUMINANCE, 100.0}); | ||
184 | hidlMetadata.push_back({IComposerClient::PerFrameMetadataKey::MIN_LUMINANCE, 0.1}); | ||
185 | hidlMetadata.push_back({IComposerClient::PerFrameMetadataKey::MAX_CONTENT_LIGHT_LEVEL, 78.0}); | ||
186 | hidlMetadata.push_back( | ||
187 | {IComposerClient::PerFrameMetadataKey::MAX_FRAME_AVERAGE_LIGHT_LEVEL, 62.0}); | ||
188 | mWriter->setPerFrameMetadata(hidlMetadata); | ||
189 | execute(); | ||
190 | } | ||
191 | |||
192 | /** | ||
193 | * Test IComposerClient::getPerFrameMetadataKeys. | ||
194 | */ | ||
195 | TEST_F(GraphicsComposerHidlTest, GetPerFrameMetadataKeys) { | ||
196 | mComposerClient->getPerFrameMetadataKeys(mPrimaryDisplay); | ||
197 | } | ||
198 | /** | ||
199 | * Test IComposerClient::setPowerMode_2_2. | ||
200 | */ | ||
201 | TEST_F(GraphicsComposerHidlTest, setPowerMode_2_2) { | ||
202 | std::vector<IComposerClient::PowerMode> modes; | ||
203 | modes.push_back(IComposerClient::PowerMode::OFF); | ||
204 | modes.push_back(IComposerClient::PowerMode::ON_SUSPEND); | ||
205 | modes.push_back(IComposerClient::PowerMode::ON); | ||
206 | |||
207 | for (auto mode : modes) { | ||
208 | mComposerClient->setPowerMode_2_2(mPrimaryDisplay, mode); | ||
209 | } | ||
210 | } | ||
211 | |||
212 | TEST_F(GraphicsComposerHidlTest, setReadbackBuffer) { | ||
213 | mComposerClient->setReadbackBuffer(mPrimaryDisplay, nullptr, -1); | ||
214 | } | ||
215 | |||
216 | TEST_F(GraphicsComposerHidlTest, getReadbackBufferFence) { | ||
217 | int32_t fence; | ||
218 | mComposerClient->getReadbackBufferFence(mPrimaryDisplay, &fence); | ||
219 | } | ||
220 | |||
221 | TEST_F(GraphicsComposerHidlTest, getReadbackBufferAttributes) { | ||
222 | PixelFormat pixelFormat; | ||
223 | Dataspace dataspace; | ||
224 | mComposerClient->getReadbackBufferAttributes(mPrimaryDisplay, &pixelFormat, &dataspace); | ||
225 | } | ||
226 | |||
227 | } // namespace | ||
228 | } // namespace tests | ||
229 | } // namespace V2_2 | ||
230 | } // namespace composer | ||
231 | } // namespace graphics | ||
232 | } // namespace hardware | ||
233 | } // namespace android | ||
234 | |||
235 | int main(int argc, char** argv) { | ||
236 | using android::hardware::graphics::composer::V2_2::tests::GraphicsComposerHidlEnvironment; | ||
237 | ::testing::AddGlobalTestEnvironment(GraphicsComposerHidlEnvironment::Instance()); | ||
238 | ::testing::InitGoogleTest(&argc, argv); | ||
239 | GraphicsComposerHidlEnvironment::Instance()->init(&argc, argv); | ||
240 | int status = RUN_ALL_TESTS(); | ||
241 | return status; | ||
242 | } | ||
diff --git a/graphics/composer/2.2/vts/functional/include/2.2/VtsHalGraphicsComposerTestUtils.h b/graphics/composer/2.2/vts/functional/include/2.2/VtsHalGraphicsComposerTestUtils.h new file mode 100644 index 00000000..c5756ed8 --- /dev/null +++ b/graphics/composer/2.2/vts/functional/include/2.2/VtsHalGraphicsComposerTestUtils.h | |||
@@ -0,0 +1,84 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2018 The Android Open Source Project | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | #pragma once | ||
18 | |||
19 | #include <memory> | ||
20 | #include <string> | ||
21 | #include <unordered_map> | ||
22 | #include <unordered_set> | ||
23 | #include <vector> | ||
24 | |||
25 | #include <VtsHalGraphicsComposerTestUtils.h> | ||
26 | #include <VtsHalHidlTargetTestBase.h> | ||
27 | #include <android/hardware/graphics/composer/2.2/IComposer.h> | ||
28 | #include <android/hardware/graphics/composer/2.2/IComposerClient.h> | ||
29 | #include <composer-command-buffer/2.2/ComposerCommandBuffer.h> | ||
30 | #include <utils/StrongPointer.h> | ||
31 | |||
32 | namespace android { | ||
33 | namespace hardware { | ||
34 | namespace graphics { | ||
35 | namespace composer { | ||
36 | namespace V2_2 { | ||
37 | namespace tests { | ||
38 | |||
39 | using android::hardware::graphics::common::V1_0::ColorMode; | ||
40 | using android::hardware::graphics::common::V1_0::Dataspace; | ||
41 | using android::hardware::graphics::common::V1_0::Hdr; | ||
42 | using android::hardware::graphics::common::V1_0::PixelFormat; | ||
43 | using android::hardware::graphics::composer::V2_2::IComposer; | ||
44 | using android::hardware::graphics::composer::V2_2::IComposerClient; | ||
45 | |||
46 | class ComposerClient_v2_2; | ||
47 | |||
48 | // Only thing I need for Composer_v2_2 is to create a v2_2 ComposerClient | ||
49 | // Everything else is the same | ||
50 | class Composer_v2_2 : public V2_1::tests::Composer { | ||
51 | public: | ||
52 | Composer_v2_2() : V2_1::tests::Composer(){}; | ||
53 | explicit Composer_v2_2(const std::string& name) : V2_1::tests::Composer(name){}; | ||
54 | |||
55 | std::unique_ptr<ComposerClient_v2_2> createClient_v2_2(); | ||
56 | }; | ||
57 | |||
58 | // A wrapper to IComposerClient. | ||
59 | class ComposerClient_v2_2 | ||
60 | : public android::hardware::graphics::composer::V2_1::tests::ComposerClient { | ||
61 | public: | ||
62 | ComposerClient_v2_2(const sp<IComposerClient>& client) | ||
63 | : V2_1::tests::ComposerClient(client), mClient_v2_2(client){}; | ||
64 | |||
65 | void execute_v2_2(V2_1::tests::TestCommandReader* reader, V2_2::CommandWriterBase* writer); | ||
66 | |||
67 | std::vector<IComposerClient::PerFrameMetadataKey> getPerFrameMetadataKeys(Display display); | ||
68 | |||
69 | void setPowerMode_2_2(Display display, V2_2::IComposerClient::PowerMode mode); | ||
70 | void setReadbackBuffer(Display display, const native_handle_t* buffer, int32_t releaseFence); | ||
71 | void getReadbackBufferAttributes(Display display, PixelFormat* outPixelFormat, | ||
72 | Dataspace* outDataspace); | ||
73 | void getReadbackBufferFence(Display display, int32_t* outFence); | ||
74 | |||
75 | private: | ||
76 | sp<V2_2::IComposerClient> mClient_v2_2; | ||
77 | }; | ||
78 | |||
79 | } // namespace tests | ||
80 | } // namespace V2_2 | ||
81 | } // namespace composer | ||
82 | } // namespace graphics | ||
83 | } // namespace hardware | ||
84 | } // namespace android | ||
diff --git a/graphics/mapper/2.1/IMapper.hal b/graphics/mapper/2.1/IMapper.hal index a23656d4..6047e96c 100644 --- a/graphics/mapper/2.1/IMapper.hal +++ b/graphics/mapper/2.1/IMapper.hal | |||
@@ -16,10 +16,47 @@ | |||
16 | 16 | ||
17 | package android.hardware.graphics.mapper@2.1; | 17 | package android.hardware.graphics.mapper@2.1; |
18 | 18 | ||
19 | import android.hardware.graphics.mapper@2.0::Error; | 19 | import android.hardware.graphics.common@1.1::BufferUsage; |
20 | import android.hardware.graphics.mapper@2.0::IMapper; | 20 | import android.hardware.graphics.common@1.1::PixelFormat; |
21 | import @2.0::BufferDescriptor; | ||
22 | import @2.0::Error; | ||
23 | import @2.0::IMapper; | ||
24 | |||
25 | interface IMapper extends @2.0::IMapper { | ||
26 | /** | ||
27 | * This is the same as @2.0::IMapper::BufferDescriptorInfo except that it | ||
28 | * accepts @1.1::PixelFormat and @1.1::BufferUsage. | ||
29 | */ | ||
30 | struct BufferDescriptorInfo { | ||
31 | /** | ||
32 | * The width specifies how many columns of pixels must be in the | ||
33 | * allocated buffer, but does not necessarily represent the offset in | ||
34 | * columns between the same column in adjacent rows. The rows may be | ||
35 | * padded. | ||
36 | */ | ||
37 | uint32_t width; | ||
38 | |||
39 | /** | ||
40 | * The height specifies how many rows of pixels must be in the | ||
41 | * allocated buffer. | ||
42 | */ | ||
43 | uint32_t height; | ||
44 | |||
45 | /** | ||
46 | * The number of image layers that must be in the allocated buffer. | ||
47 | */ | ||
48 | uint32_t layerCount; | ||
49 | |||
50 | /** Buffer pixel format. */ | ||
51 | PixelFormat format; | ||
52 | |||
53 | /** | ||
54 | * Buffer usage mask; valid flags can be found in the definition of | ||
55 | * BufferUsage. | ||
56 | */ | ||
57 | bitfield<BufferUsage> usage; | ||
58 | }; | ||
21 | 59 | ||
22 | interface IMapper extends android.hardware.graphics.mapper@2.0::IMapper { | ||
23 | /** | 60 | /** |
24 | * Validate that the buffer can be safely accessed by a caller who assumes | 61 | * Validate that the buffer can be safely accessed by a caller who assumes |
25 | * the specified descriptorInfo and stride. This must at least validate | 62 | * the specified descriptorInfo and stride. This must at least validate |
@@ -58,4 +95,30 @@ interface IMapper extends android.hardware.graphics.mapper@2.0::IMapper { | |||
58 | generates (Error error, | 95 | generates (Error error, |
59 | uint32_t numFds, | 96 | uint32_t numFds, |
60 | uint32_t numInts); | 97 | uint32_t numInts); |
98 | |||
99 | /** | ||
100 | * This is the same as @2.0::IMapper::createDescriptor except that it | ||
101 | * accepts @2.1::IMapper::BufferDescriptorInfo. | ||
102 | * | ||
103 | * Creates a buffer descriptor. The descriptor can be used with IAllocator | ||
104 | * to allocate buffers. | ||
105 | * | ||
106 | * Since the buffer descriptor fully describes a buffer, any device | ||
107 | * dependent or device independent checks must be performed here whenever | ||
108 | * possible. Specifically, when layered buffers are not supported, this | ||
109 | * function must return UNSUPPORTED if layerCount is great than 1. | ||
110 | * | ||
111 | * @param descriptorInfo specifies the attributes of the descriptor. | ||
112 | * @return error is NONE upon success. Otherwise, | ||
113 | * BAD_VALUE when any of the specified attributes is | ||
114 | * invalid or conflicting. | ||
115 | * NO_RESOURCES when the creation cannot be fullfilled at | ||
116 | * this time. | ||
117 | * UNSUPPORTED when any of the specified attributes is | ||
118 | * not supported. | ||
119 | * @return descriptor is the newly created buffer descriptor. | ||
120 | */ | ||
121 | createDescriptor_2_1(BufferDescriptorInfo descriptorInfo) | ||
122 | generates (Error error, | ||
123 | BufferDescriptor descriptor); | ||
61 | }; | 124 | }; |
diff --git a/graphics/mapper/2.1/vts/functional/VtsHalGraphicsMapperV2_1TargetTest.cpp b/graphics/mapper/2.1/vts/functional/VtsHalGraphicsMapperV2_1TargetTest.cpp index 4067c8d3..88b96ae1 100644 --- a/graphics/mapper/2.1/vts/functional/VtsHalGraphicsMapperV2_1TargetTest.cpp +++ b/graphics/mapper/2.1/vts/functional/VtsHalGraphicsMapperV2_1TargetTest.cpp | |||
@@ -30,10 +30,27 @@ namespace V2_1 { | |||
30 | namespace tests { | 30 | namespace tests { |
31 | namespace { | 31 | namespace { |
32 | 32 | ||
33 | using android::hardware::graphics::mapper::V2_0::BufferDescriptor; | ||
33 | using android::hardware::graphics::mapper::V2_0::Error; | 34 | using android::hardware::graphics::mapper::V2_0::Error; |
34 | 35 | ||
35 | using android::hardware::graphics::common::V1_0::BufferUsage; | 36 | using android::hardware::graphics::common::V1_1::BufferUsage; |
36 | using android::hardware::graphics::common::V1_0::PixelFormat; | 37 | using android::hardware::graphics::common::V1_1::PixelFormat; |
38 | |||
39 | // abuse VTS to check binary compatibility between BufferDescriptorInfos | ||
40 | using OldBufferDescriptorInfo = | ||
41 | android::hardware::graphics::mapper::V2_0::IMapper::BufferDescriptorInfo; | ||
42 | static_assert(sizeof(OldBufferDescriptorInfo) == sizeof(IMapper::BufferDescriptorInfo) && | ||
43 | offsetof(OldBufferDescriptorInfo, width) == | ||
44 | offsetof(IMapper::BufferDescriptorInfo, width) && | ||
45 | offsetof(OldBufferDescriptorInfo, height) == | ||
46 | offsetof(IMapper::BufferDescriptorInfo, height) && | ||
47 | offsetof(OldBufferDescriptorInfo, layerCount) == | ||
48 | offsetof(IMapper::BufferDescriptorInfo, layerCount) && | ||
49 | offsetof(OldBufferDescriptorInfo, format) == | ||
50 | offsetof(IMapper::BufferDescriptorInfo, format) && | ||
51 | offsetof(OldBufferDescriptorInfo, usage) == | ||
52 | offsetof(IMapper::BufferDescriptorInfo, usage), | ||
53 | ""); | ||
37 | 54 | ||
38 | class Gralloc : public V2_0::tests::Gralloc { | 55 | class Gralloc : public V2_0::tests::Gralloc { |
39 | public: | 56 | public: |
@@ -72,6 +89,32 @@ class Gralloc : public V2_0::tests::Gralloc { | |||
72 | }); | 89 | }); |
73 | } | 90 | } |
74 | 91 | ||
92 | BufferDescriptor createDescriptor(const IMapper::BufferDescriptorInfo& descriptorInfo) { | ||
93 | BufferDescriptor descriptor; | ||
94 | mMapper->createDescriptor_2_1( | ||
95 | descriptorInfo, [&](const auto& tmpError, const auto& tmpDescriptor) { | ||
96 | ASSERT_EQ(Error::NONE, tmpError) << "failed to create descriptor"; | ||
97 | descriptor = tmpDescriptor; | ||
98 | }); | ||
99 | |||
100 | return descriptor; | ||
101 | } | ||
102 | |||
103 | const native_handle_t* allocate(const IMapper::BufferDescriptorInfo& descriptorInfo, | ||
104 | bool import, uint32_t* outStride = nullptr) { | ||
105 | BufferDescriptor descriptor = createDescriptor(descriptorInfo); | ||
106 | if (::testing::Test::HasFatalFailure()) { | ||
107 | return nullptr; | ||
108 | } | ||
109 | |||
110 | auto buffers = V2_0::tests::Gralloc::allocate(descriptor, 1, import, outStride); | ||
111 | if (::testing::Test::HasFatalFailure()) { | ||
112 | return nullptr; | ||
113 | } | ||
114 | |||
115 | return buffers[0]; | ||
116 | } | ||
117 | |||
75 | private: | 118 | private: |
76 | void init() { | 119 | void init() { |
77 | mMapper = IMapper::castFrom(V2_0::tests::Gralloc::getMapper()); | 120 | mMapper = IMapper::castFrom(V2_0::tests::Gralloc::getMapper()); |
@@ -229,6 +272,24 @@ TEST_F(GraphicsMapperHidlTest, GetTransportSizeBadBuffer) { | |||
229 | native_handle_delete(rawBufferHandle); | 272 | native_handle_delete(rawBufferHandle); |
230 | } | 273 | } |
231 | 274 | ||
275 | /** | ||
276 | * Test IMapper::createDescriptor with valid descriptor info. | ||
277 | */ | ||
278 | TEST_F(GraphicsMapperHidlTest, CreateDescriptor_2_1Basic) { | ||
279 | ASSERT_NO_FATAL_FAILURE(mGralloc->createDescriptor(mDummyDescriptorInfo)); | ||
280 | } | ||
281 | |||
282 | /** | ||
283 | * Test IMapper::createDescriptor with invalid descriptor info. | ||
284 | */ | ||
285 | TEST_F(GraphicsMapperHidlTest, CreateDescriptor_2_1Negative) { | ||
286 | auto info = mDummyDescriptorInfo; | ||
287 | info.width = 0; | ||
288 | mGralloc->getMapper()->createDescriptor_2_1(info, [&](const auto& tmpError, const auto&) { | ||
289 | EXPECT_EQ(Error::BAD_VALUE, tmpError) << "createDescriptor did not fail with BAD_VALUE"; | ||
290 | }); | ||
291 | } | ||
292 | |||
232 | } // namespace | 293 | } // namespace |
233 | } // namespace tests | 294 | } // namespace tests |
234 | } // namespace V2_1 | 295 | } // namespace V2_1 |
@@ -238,7 +299,10 @@ TEST_F(GraphicsMapperHidlTest, GetTransportSizeBadBuffer) { | |||
238 | } // namespace android | 299 | } // namespace android |
239 | 300 | ||
240 | int main(int argc, char** argv) { | 301 | int main(int argc, char** argv) { |
302 | using android::hardware::graphics::mapper::V2_0::tests::GraphicsMapperHidlEnvironment; | ||
303 | ::testing::AddGlobalTestEnvironment(GraphicsMapperHidlEnvironment::Instance()); | ||
241 | ::testing::InitGoogleTest(&argc, argv); | 304 | ::testing::InitGoogleTest(&argc, argv); |
305 | GraphicsMapperHidlEnvironment::Instance()->init(&argc, argv); | ||
242 | 306 | ||
243 | int status = RUN_ALL_TESTS(); | 307 | int status = RUN_ALL_TESTS(); |
244 | LOG(INFO) << "Test result = " << status; | 308 | LOG(INFO) << "Test result = " << status; |
diff --git a/radio/1.0/vts/functional/radio_hidl_hal_voice.cpp b/radio/1.0/vts/functional/radio_hidl_hal_voice.cpp index b3d56480..d0320b9e 100644 --- a/radio/1.0/vts/functional/radio_hidl_hal_voice.cpp +++ b/radio/1.0/vts/functional/radio_hidl_hal_voice.cpp | |||
@@ -489,4 +489,4 @@ TEST_F(RadioHidlTest, sendBurstDtmf) { | |||
489 | RadioError::MODEM_ERR, RadioError::OPERATION_NOT_ALLOWED}, | 489 | RadioError::MODEM_ERR, RadioError::OPERATION_NOT_ALLOWED}, |
490 | CHECK_GENERAL_ERROR)); | 490 | CHECK_GENERAL_ERROR)); |
491 | } | 491 | } |
492 | } \ No newline at end of file | 492 | } |
diff --git a/radio/1.2/Android.bp b/radio/1.2/Android.bp index 56e4afd7..f4ca1cfe 100644 --- a/radio/1.2/Android.bp +++ b/radio/1.2/Android.bp | |||
@@ -20,6 +20,7 @@ hidl_interface { | |||
20 | ], | 20 | ], |
21 | types: [ | 21 | types: [ |
22 | "CardStatus", | 22 | "CardStatus", |
23 | "CellConnectionStatus", | ||
23 | "CellIdentityCdma", | 24 | "CellIdentityCdma", |
24 | "CellIdentityGsm", | 25 | "CellIdentityGsm", |
25 | "CellIdentityLte", | 26 | "CellIdentityLte", |
@@ -31,9 +32,12 @@ hidl_interface { | |||
31 | "CellInfoLte", | 32 | "CellInfoLte", |
32 | "CellInfoWcdma", | 33 | "CellInfoWcdma", |
33 | "IncrementalResultsPeriodicityRange", | 34 | "IncrementalResultsPeriodicityRange", |
35 | "IndicationFilter", | ||
36 | "LinkCapacityEstimate", | ||
34 | "MaxSearchTimeRange", | 37 | "MaxSearchTimeRange", |
35 | "NetworkScanRequest", | 38 | "NetworkScanRequest", |
36 | "NetworkScanResult", | 39 | "NetworkScanResult", |
40 | "PhysicalChannelConfig", | ||
37 | "RadioConst", | 41 | "RadioConst", |
38 | "ScanIntervalRange", | 42 | "ScanIntervalRange", |
39 | ], | 43 | ], |
diff --git a/radio/1.2/IRadio.hal b/radio/1.2/IRadio.hal index 6ae78a0b..babe86f6 100644 --- a/radio/1.2/IRadio.hal +++ b/radio/1.2/IRadio.hal | |||
@@ -17,6 +17,7 @@ | |||
17 | package android.hardware.radio@1.2; | 17 | package android.hardware.radio@1.2; |
18 | 18 | ||
19 | import @1.1::IRadio; | 19 | import @1.1::IRadio; |
20 | import @1.1::RadioAccessNetworks; | ||
20 | 21 | ||
21 | /** | 22 | /** |
22 | * This interface is used by telephony and telecom to talk to cellular radio. | 23 | * This interface is used by telephony and telecom to talk to cellular radio. |
@@ -37,4 +38,72 @@ interface IRadio extends @1.1::IRadio { | |||
37 | * Response function is IRadioResponse.startNetworkScanResponse() | 38 | * Response function is IRadioResponse.startNetworkScanResponse() |
38 | */ | 39 | */ |
39 | oneway startNetworkScan_1_2(int32_t serial, NetworkScanRequest request); | 40 | oneway startNetworkScan_1_2(int32_t serial, NetworkScanRequest request); |
41 | |||
42 | /** | ||
43 | * Sets the indication filter. | ||
44 | * | ||
45 | * Prevents the reporting of specified unsolicited indications from the radio. This is used | ||
46 | * for power saving in instances when those indications are not needed. If unset, defaults to | ||
47 | * @1.2::IndicationFilter:ALL. | ||
48 | * | ||
49 | * @param serial Serial number of request. | ||
50 | * @param indicationFilter 32-bit bitmap of IndicationFilter. Bits set to 1 indicate the | ||
51 | * indications are enabled. See @1.2::IndicationFilter for the definition of each bit. | ||
52 | * | ||
53 | * Response callback is IRadioResponse.setIndicationFilterResponse() | ||
54 | */ | ||
55 | oneway setIndicationFilter_1_2(int32_t serial, bitfield<IndicationFilter> indicationFilter); | ||
56 | |||
57 | /** | ||
58 | * Sets the signal strength reporting criteria. | ||
59 | * | ||
60 | * The resulting reporting criteria are the AND of all the supplied criteria. | ||
61 | * | ||
62 | * Note: Reporting criteria must be individually set for each RAN. If unset, reporting criteria | ||
63 | * for that RAN are implementation-defined. | ||
64 | * | ||
65 | * Response callback is IRadioResponse.setSignalStrengthReportingCriteriaResponse(). | ||
66 | * | ||
67 | * @param serial Serial number of request. | ||
68 | * @param hysteresisMs A hysteresis time in milliseconds to prevent flapping. A value of 0 | ||
69 | * disables hysteresis. | ||
70 | * @param hysteresisDb An interval in dB defining the required magnitude change between reports. | ||
71 | * hysteresisDb must be smaller than the smallest threshold delta. An | ||
72 | * interval value of 0 disables hysteresis. | ||
73 | * @param thresholdsDbm A vector of trigger thresholds in dBm. A vector size of 0 disables the | ||
74 | * use of thresholds for reporting. | ||
75 | * @param ran The type of network for which to apply these thresholds. | ||
76 | */ | ||
77 | oneway setSignalStrengthReportingCriteria(int32_t serial, int32_t hysteresisMs, | ||
78 | int32_t hysteresisDb, vec<int32_t> thresholdsDbm, RadioAccessNetworks ran); | ||
79 | |||
80 | /** | ||
81 | * Sets the link capacity reporting criteria. | ||
82 | * | ||
83 | * The resulting reporting criteria are the AND of all the supplied criteria. | ||
84 | * | ||
85 | * Note: Reporting criteria must be individually set for each RAN. If unset, reporting criteria | ||
86 | * for that RAN are implementation-defined. | ||
87 | * | ||
88 | * Response callback is IRadioResponse.setLinkCapacityReportingCriteriaResponse(). | ||
89 | * | ||
90 | * @param serial Serial number of request. | ||
91 | * @param hysteresisMs A hysteresis time in milliseconds to prevent flapping. A value of 0 | ||
92 | * disables hysteresis. | ||
93 | * @param hysteresisDlKbps An interval in kbps defining the required magnitude change between DL | ||
94 | * reports. hysteresisDlKbps must be smaller than the smallest threshold | ||
95 | * delta. A value of 0 disables hysteresis. | ||
96 | * @param hysteresisUlKbps An interval in kbps defining the required magnitude change between UL | ||
97 | * reports. hysteresisUlKbps must be smaller than the smallest threshold | ||
98 | * delta. A value of 0 disables hysteresis. | ||
99 | * @param thresholdsDownlinkKbps A vector of trigger thresholds in kbps for downlink reports. A | ||
100 | * vector size of 0 disables the use of DL thresholds for | ||
101 | * reporting. | ||
102 | * @param thresholdsUplinkKbps A vector of trigger thresholds in kbps for uplink reports. A | ||
103 | * vector size of 0 disables the use of UL thresholds for reporting. | ||
104 | * @param ran The type of network for which to apply these thresholds. | ||
105 | */ | ||
106 | oneway setLinkCapacityReportingCriteria(int32_t serial, int32_t hysteresisMs, | ||
107 | int32_t hysteresisDlKbps, int32_t hysteresisUlKbps, vec<int32_t> thresholdsDownlinkKbps, | ||
108 | vec<int32_t> thresholdsUplinkKbps, RadioAccessNetworks ran); | ||
40 | }; | 109 | }; |
diff --git a/radio/1.2/IRadioIndication.hal b/radio/1.2/IRadioIndication.hal index 22f655c6..a1245573 100644 --- a/radio/1.2/IRadioIndication.hal +++ b/radio/1.2/IRadioIndication.hal | |||
@@ -37,4 +37,29 @@ interface IRadioIndication extends @1.1::IRadioIndication { | |||
37 | * @param records Current cell information known to radio | 37 | * @param records Current cell information known to radio |
38 | */ | 38 | */ |
39 | oneway cellInfoList_1_2(RadioIndicationType type, vec<CellInfo> records); | 39 | oneway cellInfoList_1_2(RadioIndicationType type, vec<CellInfo> records); |
40 | |||
41 | /** | ||
42 | * Indicates current link capacity estimate. | ||
43 | * | ||
44 | * This replaces @1.0::IRadioIndication.lceData(). The framework must be able to handle | ||
45 | * either this function or @1.0::IRadioIndication.lceData(). Implementations supporting | ||
46 | * v1.2 must call this function instead of lceData(). | ||
47 | * | ||
48 | * This indication is sent whenever the reporting criteria, as set by | ||
49 | * @1.2::IRadio.setLinkCapacityReportingCriteria, are met and the indication is not | ||
50 | * suppressed by @1.2::IRadio.setIndicationFilter_1_2(). | ||
51 | * | ||
52 | * @param type Type of radio indication | ||
53 | * @param lce LinkCapacityEstimate information as defined in types.hal | ||
54 | */ | ||
55 | oneway currentLinkCapacityEstimate(RadioIndicationType type, LinkCapacityEstimate lce); | ||
56 | |||
57 | /** | ||
58 | * Indicates physical channel configurations. | ||
59 | * | ||
60 | * @param type Type of radio indication | ||
61 | * @param configs List of PhysicalChannelConfigs as defined in types.hal | ||
62 | */ | ||
63 | oneway currentPhysicalChannelConfigs(RadioIndicationType type, | ||
64 | vec<PhysicalChannelConfig> configs); | ||
40 | }; | 65 | }; |
diff --git a/radio/1.2/IRadioResponse.hal b/radio/1.2/IRadioResponse.hal index a7ad30c1..c356954c 100644 --- a/radio/1.2/IRadioResponse.hal +++ b/radio/1.2/IRadioResponse.hal | |||
@@ -50,4 +50,26 @@ interface IRadioResponse extends @1.1::IRadioResponse { | |||
50 | * RadioError:NONE | 50 | * RadioError:NONE |
51 | */ | 51 | */ |
52 | oneway getIccCardStatusResponse_1_2(RadioResponseInfo info, CardStatus cardStatus); | 52 | oneway getIccCardStatusResponse_1_2(RadioResponseInfo info, CardStatus cardStatus); |
53 | |||
54 | /** | ||
55 | * @param info Response info struct containing response type, serial no. and error | ||
56 | * | ||
57 | * Valid errors returned: | ||
58 | * RadioError:NONE | ||
59 | * RadioError:INVALID_ARGUMENTS | ||
60 | * RadioError:RADIO_NOT_AVAILABLE | ||
61 | * RadioError:INTERNAL_ERR | ||
62 | */ | ||
63 | oneway setSignalStrengthReportingCriteriaResponse(RadioResponseInfo info); | ||
64 | |||
65 | /** | ||
66 | * @param info Response info struct containing response type, serial no. and error | ||
67 | * | ||
68 | * Valid errors returned: | ||
69 | * RadioError:NONE | ||
70 | * RadioError:INVALID_ARGUMENTS | ||
71 | * RadioError:RADIO_NOT_AVAILABLE | ||
72 | * RadioError:INTERNAL_ERR | ||
73 | */ | ||
74 | oneway setLinkCapacityReportingCriteriaResponse(RadioResponseInfo info); | ||
53 | }; | 75 | }; |
diff --git a/radio/1.2/types.hal b/radio/1.2/types.hal index 3aa24460..45152379 100644 --- a/radio/1.2/types.hal +++ b/radio/1.2/types.hal | |||
@@ -64,6 +64,67 @@ enum IncrementalResultsPeriodicityRange : int32_t { | |||
64 | MAX = 10, | 64 | MAX = 10, |
65 | }; | 65 | }; |
66 | 66 | ||
67 | enum CellConnectionStatus : int32_t { | ||
68 | /** | ||
69 | * Cell is not a serving cell. | ||
70 | */ | ||
71 | NONE = 0, | ||
72 | /** | ||
73 | * UE has connection to cell for signalling and possibly data (3GPP 36.331, 25.331). | ||
74 | */ | ||
75 | PRIMARY_SERVING, | ||
76 | /** | ||
77 | * UE has connection to cell for data (3GPP 36.331, 25.331). | ||
78 | */ | ||
79 | SECONDARY_SERVING, | ||
80 | }; | ||
81 | |||
82 | /** | ||
83 | * Overwritten from @1.0::IndicationFilter in order to redefine ALL. In the future, this should | ||
84 | * be extended instead of overwritten. | ||
85 | */ | ||
86 | enum IndicationFilter : int32_t { | ||
87 | NONE = 0, | ||
88 | ALL = ~0, | ||
89 | /** | ||
90 | * When this bit is set, modem must send the signal strength update through | ||
91 | * IRadioIndication.currentSignalStrength() when all criteria specified by | ||
92 | * IRadio.setSignalStrengthReportingCriteria() are met. | ||
93 | */ | ||
94 | SIGNAL_STRENGTH = 1 << 0, | ||
95 | /** | ||
96 | * When this bit is set, modem must invoke IRadioIndication.networkStateChanged() when any field | ||
97 | * in VoiceRegStateResult or DataRegStateResult changes. When this bit is not set, modem must | ||
98 | * suppress IRadioIndication.networkStateChanged() when there are only changes from | ||
99 | * insignificant fields. Modem must invoke IRadioIndication.networkStateChanged() when | ||
100 | * significant fields are updated regardless of whether this bit is set. | ||
101 | * | ||
102 | * The following fields are considered significant: VoiceRegStateResult.regState, | ||
103 | * VoiceRegStateResult.rat, DataRegStateResult.regState, DataRegStateResult.rat. | ||
104 | */ | ||
105 | FULL_NETWORK_STATE = 1 << 1, | ||
106 | /** | ||
107 | * When this bit is set, modem must send IRadioIndication.dataCallListChanged() whenever any | ||
108 | * field in ITypes.SetupDataCallResult changes. When this bit is not set, modem must suppress | ||
109 | * the indication when the only changed field is 'active' (for data dormancy). For all other | ||
110 | * field changes, the modem must send IRadioIndication.dataCallListChanged() regardless of | ||
111 | * whether this bit is set. | ||
112 | */ | ||
113 | DATA_CALL_DORMANCY_CHANGED = 1 << 2, | ||
114 | /** | ||
115 | * When this bit is set, modem must send the link capacity update through | ||
116 | * IRadioIndication.currentLinkCapacityEstimate() when all criteria specified by | ||
117 | * IRadio.setLinkCapacityReportingCriteria() are met. | ||
118 | */ | ||
119 | LINK_CAPACITY_ESTIMATE = 1 << 3, | ||
120 | /** | ||
121 | * When this bit is set, the modem must send the physical channel configuration update through | ||
122 | * IRadioIndication.currentPhysicalChannelConfigs() when the configuration has changed. It is | ||
123 | * recommended that this be reported whenever link capacity or signal strength is reported. | ||
124 | */ | ||
125 | PHYSICAL_CHANNEL_CONFIG = 1 << 4, | ||
126 | }; | ||
127 | |||
67 | struct NetworkScanRequest { | 128 | struct NetworkScanRequest { |
68 | ScanType type; | 129 | ScanType type; |
69 | 130 | ||
@@ -156,6 +217,10 @@ struct CellIdentityGsm { | |||
156 | struct CellIdentityLte { | 217 | struct CellIdentityLte { |
157 | @1.0::CellIdentityLte base; | 218 | @1.0::CellIdentityLte base; |
158 | CellIdentityOperatorNames operatorNames; | 219 | CellIdentityOperatorNames operatorNames; |
220 | /** | ||
221 | * Cell bandwidth, in kHz. | ||
222 | */ | ||
223 | int32_t bandwidth; | ||
159 | }; | 224 | }; |
160 | 225 | ||
161 | struct CellIdentityWcdma { | 226 | struct CellIdentityWcdma { |
@@ -222,6 +287,10 @@ struct CellInfo { | |||
222 | * Valid only if type = tdscdma and size = 1 else must be empty. | 287 | * Valid only if type = tdscdma and size = 1 else must be empty. |
223 | */ | 288 | */ |
224 | vec<CellInfoTdscdma> tdscdma; | 289 | vec<CellInfoTdscdma> tdscdma; |
290 | /** | ||
291 | * Connection status for the cell. | ||
292 | */ | ||
293 | CellConnectionStatus connectionStatus; | ||
225 | }; | 294 | }; |
226 | 295 | ||
227 | struct CardStatus { | 296 | struct CardStatus { |
@@ -244,3 +313,25 @@ struct CardStatus { | |||
244 | */ | 313 | */ |
245 | string iccid; | 314 | string iccid; |
246 | }; | 315 | }; |
316 | |||
317 | struct LinkCapacityEstimate { | ||
318 | /** | ||
319 | * Estimated downlink capacity in kbps. | ||
320 | */ | ||
321 | uint32_t downlinkCapacityKbps; | ||
322 | /** | ||
323 | * Estimated uplink capacity in kbps. | ||
324 | */ | ||
325 | uint32_t uplinkCapacityKbps; | ||
326 | }; | ||
327 | |||
328 | struct PhysicalChannelConfig { | ||
329 | /** | ||
330 | * Connection status for cell. Valid values are PRIMARY_SERVING and SECONDARY_SERVING. | ||
331 | */ | ||
332 | CellConnectionStatus status; | ||
333 | /** | ||
334 | * Cell bandwidth, in kHz. | ||
335 | */ | ||
336 | int32_t cellBandwidthDownlink; | ||
337 | }; | ||
diff --git a/sensors/1.0/vts/functional/VtsHalSensorsV1_0TargetTest.cpp b/sensors/1.0/vts/functional/VtsHalSensorsV1_0TargetTest.cpp index ca3d3e4f..24b58a78 100644 --- a/sensors/1.0/vts/functional/VtsHalSensorsV1_0TargetTest.cpp +++ b/sensors/1.0/vts/functional/VtsHalSensorsV1_0TargetTest.cpp | |||
@@ -15,8 +15,8 @@ | |||
15 | */ | 15 | */ |
16 | 16 | ||
17 | #define LOG_TAG "sensors_hidl_hal_test" | 17 | #define LOG_TAG "sensors_hidl_hal_test" |
18 | #include "GrallocWrapper.h" | ||
19 | #include <VtsHalHidlTargetTestBase.h> | 18 | #include <VtsHalHidlTargetTestBase.h> |
19 | #include <VtsHalHidlTargetTestEnvBase.h> | ||
20 | #include <android-base/logging.h> | 20 | #include <android-base/logging.h> |
21 | #include <android/hardware/sensors/1.0/ISensors.h> | 21 | #include <android/hardware/sensors/1.0/ISensors.h> |
22 | #include <android/hardware/sensors/1.0/types.h> | 22 | #include <android/hardware/sensors/1.0/types.h> |
@@ -24,6 +24,7 @@ | |||
24 | #include <hardware/sensors.h> // for sensor type strings | 24 | #include <hardware/sensors.h> // for sensor type strings |
25 | #include <log/log.h> | 25 | #include <log/log.h> |
26 | #include <utils/SystemClock.h> | 26 | #include <utils/SystemClock.h> |
27 | #include "GrallocWrapper.h" | ||
27 | 28 | ||
28 | #include <algorithm> | 29 | #include <algorithm> |
29 | #include <cinttypes> | 30 | #include <cinttypes> |
@@ -46,63 +47,65 @@ using namespace ::android::hardware::sensors::V1_0; | |||
46 | 47 | ||
47 | // Test environment for sensors | 48 | // Test environment for sensors |
48 | class SensorsHidlTest; | 49 | class SensorsHidlTest; |
49 | class SensorsHidlEnvironment : public ::testing::Environment { | 50 | class SensorsHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase { |
50 | public: | 51 | public: |
51 | // get the test environment singleton | 52 | // get the test environment singleton |
52 | static SensorsHidlEnvironment* Instance() { | 53 | static SensorsHidlEnvironment* Instance() { |
53 | static SensorsHidlEnvironment* instance = new SensorsHidlEnvironment; | 54 | static SensorsHidlEnvironment* instance = new SensorsHidlEnvironment; |
54 | return instance; | 55 | return instance; |
55 | } | 56 | } |
56 | 57 | ||
57 | virtual void SetUp(); | 58 | virtual void HidlSetUp() override; |
58 | virtual void TearDown(); | 59 | virtual void HidlTearDown() override; |
59 | 60 | ||
60 | // Get and clear all events collected so far (like "cat" shell command). | 61 | virtual void registerTestServices() override { registerTestService<ISensors>(); } |
61 | // If output is nullptr, it clears all collected events. | ||
62 | void catEvents(std::vector<Event>* output); | ||
63 | 62 | ||
64 | // set sensor event collection status | 63 | // Get and clear all events collected so far (like "cat" shell command). |
65 | void setCollection(bool enable); | 64 | // If output is nullptr, it clears all collected events. |
65 | void catEvents(std::vector<Event>* output); | ||
66 | 66 | ||
67 | private: | 67 | // set sensor event collection status |
68 | friend SensorsHidlTest; | 68 | void setCollection(bool enable); |
69 | // sensors hidl service | ||
70 | sp<ISensors> sensors; | ||
71 | 69 | ||
72 | SensorsHidlEnvironment() {} | 70 | private: |
71 | friend SensorsHidlTest; | ||
72 | // sensors hidl service | ||
73 | sp<ISensors> sensors; | ||
73 | 74 | ||
74 | void addEvent(const Event& ev); | 75 | SensorsHidlEnvironment() {} |
75 | void startPollingThread(); | ||
76 | void resetHal(); | ||
77 | static void pollingThread(SensorsHidlEnvironment* env, std::shared_ptr<bool> stop); | ||
78 | 76 | ||
79 | bool collectionEnabled; | 77 | void addEvent(const Event& ev); |
80 | std::shared_ptr<bool> stopThread; | 78 | void startPollingThread(); |
81 | std::thread pollThread; | 79 | void resetHal(); |
82 | std::vector<Event> events; | 80 | static void pollingThread(SensorsHidlEnvironment* env, std::shared_ptr<bool> stop); |
83 | std::mutex events_mutex; | 81 | |
82 | bool collectionEnabled; | ||
83 | std::shared_ptr<bool> stopThread; | ||
84 | std::thread pollThread; | ||
85 | std::vector<Event> events; | ||
86 | std::mutex events_mutex; | ||
84 | 87 | ||
85 | GTEST_DISALLOW_COPY_AND_ASSIGN_(SensorsHidlEnvironment); | 88 | GTEST_DISALLOW_COPY_AND_ASSIGN_(SensorsHidlEnvironment); |
86 | }; | 89 | }; |
87 | 90 | ||
88 | void SensorsHidlEnvironment::SetUp() { | 91 | void SensorsHidlEnvironment::HidlSetUp() { |
89 | resetHal(); | 92 | resetHal(); |
90 | 93 | ||
91 | ASSERT_NE(sensors, nullptr) << "sensors is nullptr, cannot get hidl service"; | 94 | ASSERT_NE(sensors, nullptr) << "sensors is nullptr, cannot get hidl service"; |
92 | 95 | ||
93 | collectionEnabled = false; | 96 | collectionEnabled = false; |
94 | startPollingThread(); | 97 | startPollingThread(); |
95 | 98 | ||
96 | // In case framework just stopped for test and there is sensor events in the pipe, | 99 | // In case framework just stopped for test and there is sensor events in the pipe, |
97 | // wait some time for those events to be cleared to avoid them messing up the test. | 100 | // wait some time for those events to be cleared to avoid them messing up the test. |
98 | std::this_thread::sleep_for(std::chrono::seconds(3)); | 101 | std::this_thread::sleep_for(std::chrono::seconds(3)); |
99 | } | 102 | } |
100 | 103 | ||
101 | void SensorsHidlEnvironment::TearDown() { | 104 | void SensorsHidlEnvironment::HidlTearDown() { |
102 | if (stopThread) { | 105 | if (stopThread) { |
103 | *stopThread = true; | 106 | *stopThread = true; |
104 | } | 107 | } |
105 | pollThread.detach(); | 108 | pollThread.detach(); |
106 | } | 109 | } |
107 | 110 | ||
108 | void SensorsHidlEnvironment::resetHal() { | 111 | void SensorsHidlEnvironment::resetHal() { |
@@ -115,7 +118,8 @@ void SensorsHidlEnvironment::resetHal() { | |||
115 | // this do ... while is for easy error handling | 118 | // this do ... while is for easy error handling |
116 | do { | 119 | do { |
117 | step = "getService()"; | 120 | step = "getService()"; |
118 | sensors = ISensors::getService(); | 121 | sensors = ISensors::getService( |
122 | SensorsHidlEnvironment::Instance()->getServiceName<ISensors>()); | ||
119 | if (sensors == nullptr) { | 123 | if (sensors == nullptr) { |
120 | break; | 124 | break; |
121 | } | 125 | } |
@@ -1500,6 +1504,7 @@ TEST_F(SensorsHidlTest, MagnetometerGrallocDirectReportOperationVeryFast) { | |||
1500 | int main(int argc, char **argv) { | 1504 | int main(int argc, char **argv) { |
1501 | ::testing::AddGlobalTestEnvironment(SensorsHidlEnvironment::Instance()); | 1505 | ::testing::AddGlobalTestEnvironment(SensorsHidlEnvironment::Instance()); |
1502 | ::testing::InitGoogleTest(&argc, argv); | 1506 | ::testing::InitGoogleTest(&argc, argv); |
1507 | SensorsHidlEnvironment::Instance()->init(&argc, argv); | ||
1503 | int status = RUN_ALL_TESTS(); | 1508 | int status = RUN_ALL_TESTS(); |
1504 | ALOGI("Test result = %d", status); | 1509 | ALOGI("Test result = %d", status); |
1505 | return status; | 1510 | return status; |
diff --git a/wifi/1.2/Android.bp b/wifi/1.2/Android.bp index 100b36bf..f41324ed 100644 --- a/wifi/1.2/Android.bp +++ b/wifi/1.2/Android.bp | |||
@@ -10,6 +10,7 @@ hidl_interface { | |||
10 | "types.hal", | 10 | "types.hal", |
11 | "IWifi.hal", | 11 | "IWifi.hal", |
12 | "IWifiChip.hal", | 12 | "IWifiChip.hal", |
13 | "IWifiChipEventCallback.hal", | ||
13 | "IWifiNanIface.hal", | 14 | "IWifiNanIface.hal", |
14 | "IWifiNanIfaceEventCallback.hal", | 15 | "IWifiNanIfaceEventCallback.hal", |
15 | ], | 16 | ], |
diff --git a/wifi/1.2/IWifiChip.hal b/wifi/1.2/IWifiChip.hal index 72cbf811..d336a337 100644 --- a/wifi/1.2/IWifiChip.hal +++ b/wifi/1.2/IWifiChip.hal | |||
@@ -16,7 +16,9 @@ | |||
16 | 16 | ||
17 | package android.hardware.wifi@1.2; | 17 | package android.hardware.wifi@1.2; |
18 | 18 | ||
19 | import @1.0::WifiStatus; | ||
19 | import @1.1::IWifiChip; | 20 | import @1.1::IWifiChip; |
21 | import IWifiChipEventCallback; | ||
20 | 22 | ||
21 | /** | 23 | /** |
22 | * Interface that represents a chip that must be configured as a single unit. | 24 | * Interface that represents a chip that must be configured as a single unit. |
@@ -24,4 +26,18 @@ import @1.1::IWifiChip; | |||
24 | * to perform operations like NAN, RTT, etc. | 26 | * to perform operations like NAN, RTT, etc. |
25 | */ | 27 | */ |
26 | interface IWifiChip extends @1.1::IWifiChip { | 28 | interface IWifiChip extends @1.1::IWifiChip { |
29 | /** | ||
30 | * Requests notifications of significant events on this chip. Multiple calls | ||
31 | * to this must register multiple callbacks each of which must receive all | ||
32 | * events. | ||
33 | * | ||
34 | * @param callback An instance of the |IWifiChipEventCallback| HIDL interface | ||
35 | * object. | ||
36 | * @return status WifiStatus of the operation. | ||
37 | * Possible status codes: | ||
38 | * |WifiStatusCode.SUCCESS|, | ||
39 | * |WifiStatusCode.ERROR_WIFI_CHIP_INVALID| | ||
40 | */ | ||
41 | registerEventCallback_1_2(IWifiChipEventCallback callback) | ||
42 | generates (WifiStatus status); | ||
27 | }; | 43 | }; |
diff --git a/wifi/1.2/IWifiChipEventCallback.hal b/wifi/1.2/IWifiChipEventCallback.hal new file mode 100644 index 00000000..5d2e7e9c --- /dev/null +++ b/wifi/1.2/IWifiChipEventCallback.hal | |||
@@ -0,0 +1,71 @@ | |||
1 | /* | ||
2 | * Copyright 2017 The Android Open Source Project | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | package android.hardware.wifi@1.2; | ||
18 | |||
19 | import @1.0::IWifiChipEventCallback; | ||
20 | import @1.0::WifiBand; | ||
21 | |||
22 | /** | ||
23 | * Wifi chip event callbacks. | ||
24 | */ | ||
25 | interface IWifiChipEventCallback extends @1.0::IWifiChipEventCallback { | ||
26 | /** | ||
27 | * Struct describing the state of each iface operating on the radio chain | ||
28 | * (hardware MAC) on the device. | ||
29 | */ | ||
30 | struct IfaceInfo { | ||
31 | /** Name of the interface (For ex: "wlan0"). */ | ||
32 | string name; | ||
33 | /** Wifi channel on which this interface is operating. */ | ||
34 | uint32_t channel; | ||
35 | }; | ||
36 | |||
37 | /** | ||
38 | * Struct describing the state of each hardware radio chain (hardware MAC) | ||
39 | * on the device. | ||
40 | */ | ||
41 | struct RadioModeInfo { | ||
42 | /** | ||
43 | * Identifier for this radio chain. This is vendor dependent & used | ||
44 | * only for debugging purposes. | ||
45 | */ | ||
46 | uint32_t radioId; | ||
47 | /** | ||
48 | * List of bands on which this radio chain is operating. | ||
49 | * Can be one of: | ||
50 | * a) WifiBand.BAND_24GHZ => 2.4Ghz. | ||
51 | * b) WifiBand.BAND_5GHZ => 5Ghz. | ||
52 | * c) WifiBand.BAND_24GHZ_5GHZ = 2.4Ghz + 5Ghz (Radio is time sharing | ||
53 | * across the 2 bands). | ||
54 | */ | ||
55 | WifiBand bandInfo; | ||
56 | /** List of interfaces on this radio chain (hardware MAC). */ | ||
57 | vec<IfaceInfo> ifaceInfos; | ||
58 | }; | ||
59 | |||
60 | /** | ||
61 | * Asynchronous callback indicating a radio mode change. | ||
62 | * Radio mode change could be a result of: | ||
63 | * a) Bringing up concurrent interfaces (For ex: STA + AP). | ||
64 | * b) Change in operating band of one of the concurrent interfaces (For ex: | ||
65 | * STA connection moved from 2.4G to 5G) | ||
66 | * | ||
67 | * @param radioModeInfos List of RadioModeInfo structures for each | ||
68 | * radio chain (hardware MAC) on the device. | ||
69 | */ | ||
70 | oneway onRadioModeChange(vec<RadioModeInfo> radioModeInfos); | ||
71 | }; | ||
diff --git a/wifi/1.2/default/Android.mk b/wifi/1.2/default/Android.mk index 8d0262b7..978cf63f 100644 --- a/wifi/1.2/default/Android.mk +++ b/wifi/1.2/default/Android.mk | |||
@@ -94,6 +94,7 @@ include $(CLEAR_VARS) | |||
94 | LOCAL_MODULE := android.hardware.wifi@1.0-service-tests | 94 | LOCAL_MODULE := android.hardware.wifi@1.0-service-tests |
95 | LOCAL_PROPRIETARY_MODULE := true | 95 | LOCAL_PROPRIETARY_MODULE := true |
96 | LOCAL_SRC_FILES := \ | 96 | LOCAL_SRC_FILES := \ |
97 | tests/hidl_struct_util_unit_tests.cpp \ | ||
97 | tests/main.cpp \ | 98 | tests/main.cpp \ |
98 | tests/mock_wifi_feature_flags.cpp \ | 99 | tests/mock_wifi_feature_flags.cpp \ |
99 | tests/mock_wifi_legacy_hal.cpp \ | 100 | tests/mock_wifi_legacy_hal.cpp \ |
diff --git a/wifi/1.2/default/hidl_struct_util.cpp b/wifi/1.2/default/hidl_struct_util.cpp index f87828c1..b1c609e5 100644 --- a/wifi/1.2/default/hidl_struct_util.cpp +++ b/wifi/1.2/default/hidl_struct_util.cpp | |||
@@ -266,6 +266,57 @@ legacy_hal::wifi_power_scenario convertHidlTxPowerScenarioToLegacy( | |||
266 | CHECK(false); | 266 | CHECK(false); |
267 | } | 267 | } |
268 | 268 | ||
269 | bool convertLegacyWifiMacInfoToHidl( | ||
270 | const legacy_hal::WifiMacInfo& legacy_mac_info, | ||
271 | IWifiChipEventCallback::RadioModeInfo* hidl_radio_mode_info) { | ||
272 | if (!hidl_radio_mode_info) { | ||
273 | return false; | ||
274 | } | ||
275 | *hidl_radio_mode_info = {}; | ||
276 | |||
277 | hidl_radio_mode_info->radioId = legacy_mac_info.wlan_mac_id; | ||
278 | // Convert from bitmask of bands in the legacy HAL to enum value in | ||
279 | // the HIDL interface. | ||
280 | if (legacy_mac_info.mac_band & legacy_hal::WLAN_MAC_2_4_BAND && | ||
281 | legacy_mac_info.mac_band & legacy_hal::WLAN_MAC_5_0_BAND) { | ||
282 | hidl_radio_mode_info->bandInfo = WifiBand::BAND_24GHZ_5GHZ; | ||
283 | } else if (legacy_mac_info.mac_band & legacy_hal::WLAN_MAC_2_4_BAND) { | ||
284 | hidl_radio_mode_info->bandInfo = WifiBand::BAND_24GHZ; | ||
285 | } else if (legacy_mac_info.mac_band & legacy_hal::WLAN_MAC_5_0_BAND) { | ||
286 | hidl_radio_mode_info->bandInfo = WifiBand::BAND_5GHZ; | ||
287 | } else { | ||
288 | hidl_radio_mode_info->bandInfo = WifiBand::BAND_UNSPECIFIED; | ||
289 | } | ||
290 | std::vector<IWifiChipEventCallback::IfaceInfo> iface_info_vec; | ||
291 | for (const auto& legacy_iface_info : legacy_mac_info.iface_infos) { | ||
292 | IWifiChipEventCallback::IfaceInfo iface_info; | ||
293 | iface_info.name = legacy_iface_info.name; | ||
294 | iface_info.channel = legacy_iface_info.channel; | ||
295 | iface_info_vec.push_back(iface_info); | ||
296 | } | ||
297 | hidl_radio_mode_info->ifaceInfos = iface_info_vec; | ||
298 | return true; | ||
299 | } | ||
300 | |||
301 | bool convertLegacyWifiMacInfosToHidl( | ||
302 | const std::vector<legacy_hal::WifiMacInfo>& legacy_mac_infos, | ||
303 | std::vector<IWifiChipEventCallback::RadioModeInfo>* hidl_radio_mode_infos) { | ||
304 | if (!hidl_radio_mode_infos) { | ||
305 | return false; | ||
306 | } | ||
307 | *hidl_radio_mode_infos = {}; | ||
308 | |||
309 | for (const auto& legacy_mac_info : legacy_mac_infos) { | ||
310 | IWifiChipEventCallback::RadioModeInfo hidl_radio_mode_info; | ||
311 | if (!convertLegacyWifiMacInfoToHidl(legacy_mac_info, | ||
312 | &hidl_radio_mode_info)) { | ||
313 | return false; | ||
314 | } | ||
315 | hidl_radio_mode_infos->push_back(hidl_radio_mode_info); | ||
316 | } | ||
317 | return true; | ||
318 | } | ||
319 | |||
269 | bool convertLegacyFeaturesToHidlStaCapabilities( | 320 | bool convertLegacyFeaturesToHidlStaCapabilities( |
270 | uint32_t legacy_feature_set, uint32_t legacy_logger_feature_set, | 321 | uint32_t legacy_feature_set, uint32_t legacy_logger_feature_set, |
271 | uint32_t* hidl_caps) { | 322 | uint32_t* hidl_caps) { |
diff --git a/wifi/1.2/default/hidl_struct_util.h b/wifi/1.2/default/hidl_struct_util.h index 1208afd0..ce4bb81a 100644 --- a/wifi/1.2/default/hidl_struct_util.h +++ b/wifi/1.2/default/hidl_struct_util.h | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <android/hardware/wifi/1.0/IWifiChip.h> | 22 | #include <android/hardware/wifi/1.0/IWifiChip.h> |
23 | #include <android/hardware/wifi/1.0/types.h> | 23 | #include <android/hardware/wifi/1.0/types.h> |
24 | #include <android/hardware/wifi/1.1/IWifiChip.h> | 24 | #include <android/hardware/wifi/1.1/IWifiChip.h> |
25 | #include <android/hardware/wifi/1.2/IWifiChipEventCallback.h> | ||
25 | #include <android/hardware/wifi/1.2/types.h> | 26 | #include <android/hardware/wifi/1.2/types.h> |
26 | 27 | ||
27 | #include "wifi_legacy_hal.h" | 28 | #include "wifi_legacy_hal.h" |
@@ -55,6 +56,9 @@ bool convertLegacyWakeReasonStatsToHidl( | |||
55 | WifiDebugHostWakeReasonStats* hidl_stats); | 56 | WifiDebugHostWakeReasonStats* hidl_stats); |
56 | legacy_hal::wifi_power_scenario convertHidlTxPowerScenarioToLegacy( | 57 | legacy_hal::wifi_power_scenario convertHidlTxPowerScenarioToLegacy( |
57 | V1_1::IWifiChip::TxPowerScenario hidl_scenario); | 58 | V1_1::IWifiChip::TxPowerScenario hidl_scenario); |
59 | bool convertLegacyWifiMacInfosToHidl( | ||
60 | const std::vector<legacy_hal::WifiMacInfo>& legacy_mac_infos, | ||
61 | std::vector<IWifiChipEventCallback::RadioModeInfo>* hidl_radio_mode_infos); | ||
58 | 62 | ||
59 | // STA iface conversion methods. | 63 | // STA iface conversion methods. |
60 | bool convertLegacyFeaturesToHidlStaCapabilities( | 64 | bool convertLegacyFeaturesToHidlStaCapabilities( |
diff --git a/wifi/1.2/default/tests/hidl_struct_util_unit_tests.cpp b/wifi/1.2/default/tests/hidl_struct_util_unit_tests.cpp new file mode 100644 index 00000000..1d6e9e4a --- /dev/null +++ b/wifi/1.2/default/tests/hidl_struct_util_unit_tests.cpp | |||
@@ -0,0 +1,129 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2017, The Android Open Source Project | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | #include <android-base/logging.h> | ||
18 | #include <android-base/macros.h> | ||
19 | #include <gmock/gmock.h> | ||
20 | |||
21 | #undef NAN | ||
22 | #include "hidl_struct_util.h" | ||
23 | |||
24 | using testing::Test; | ||
25 | |||
26 | namespace { | ||
27 | constexpr uint32_t kMacId1 = 1; | ||
28 | constexpr uint32_t kMacId2 = 2; | ||
29 | constexpr uint32_t kIfaceChannel1 = 3; | ||
30 | constexpr uint32_t kIfaceChannel2 = 5; | ||
31 | constexpr char kIfaceName1[] = "wlan0"; | ||
32 | constexpr char kIfaceName2[] = "wlan1"; | ||
33 | } // namespace | ||
34 | namespace android { | ||
35 | namespace hardware { | ||
36 | namespace wifi { | ||
37 | namespace V1_2 { | ||
38 | namespace implementation { | ||
39 | using namespace android::hardware::wifi::V1_0; | ||
40 | |||
41 | class HidlStructUtilTest : public Test {}; | ||
42 | |||
43 | TEST_F(HidlStructUtilTest, CanConvertLegacyWifiMacInfosToHidlWithOneMac) { | ||
44 | std::vector<legacy_hal::WifiMacInfo> legacy_mac_infos; | ||
45 | legacy_hal::WifiMacInfo legacy_mac_info1 = { | ||
46 | .wlan_mac_id = kMacId1, | ||
47 | .mac_band = | ||
48 | legacy_hal::WLAN_MAC_5_0_BAND | legacy_hal::WLAN_MAC_2_4_BAND}; | ||
49 | legacy_hal::WifiIfaceInfo legacy_iface_info1 = {.name = kIfaceName1, | ||
50 | .channel = kIfaceChannel1}; | ||
51 | legacy_hal::WifiIfaceInfo legacy_iface_info2 = {.name = kIfaceName2, | ||
52 | .channel = kIfaceChannel2}; | ||
53 | legacy_mac_info1.iface_infos.push_back(legacy_iface_info1); | ||
54 | legacy_mac_info1.iface_infos.push_back(legacy_iface_info2); | ||
55 | legacy_mac_infos.push_back(legacy_mac_info1); | ||
56 | |||
57 | std::vector<IWifiChipEventCallback::RadioModeInfo> hidl_radio_mode_infos; | ||
58 | ASSERT_TRUE(hidl_struct_util::convertLegacyWifiMacInfosToHidl( | ||
59 | legacy_mac_infos, &hidl_radio_mode_infos)); | ||
60 | |||
61 | ASSERT_EQ(1u, hidl_radio_mode_infos.size()); | ||
62 | auto hidl_radio_mode_info1 = hidl_radio_mode_infos[0]; | ||
63 | EXPECT_EQ(legacy_mac_info1.wlan_mac_id, hidl_radio_mode_info1.radioId); | ||
64 | EXPECT_EQ(WifiBand::BAND_24GHZ_5GHZ, hidl_radio_mode_info1.bandInfo); | ||
65 | ASSERT_EQ(2u, hidl_radio_mode_info1.ifaceInfos.size()); | ||
66 | auto hidl_iface_info1 = hidl_radio_mode_info1.ifaceInfos[0]; | ||
67 | EXPECT_EQ(legacy_iface_info1.name, hidl_iface_info1.name); | ||
68 | EXPECT_EQ(static_cast<uint32_t>(legacy_iface_info1.channel), | ||
69 | hidl_iface_info1.channel); | ||
70 | auto hidl_iface_info2 = hidl_radio_mode_info1.ifaceInfos[1]; | ||
71 | EXPECT_EQ(legacy_iface_info2.name, hidl_iface_info2.name); | ||
72 | EXPECT_EQ(static_cast<uint32_t>(legacy_iface_info2.channel), | ||
73 | hidl_iface_info2.channel); | ||
74 | } | ||
75 | |||
76 | TEST_F(HidlStructUtilTest, CanConvertLegacyWifiMacInfosToHidlWithTwoMac) { | ||
77 | std::vector<legacy_hal::WifiMacInfo> legacy_mac_infos; | ||
78 | legacy_hal::WifiMacInfo legacy_mac_info1 = { | ||
79 | .wlan_mac_id = kMacId1, .mac_band = legacy_hal::WLAN_MAC_5_0_BAND}; | ||
80 | legacy_hal::WifiIfaceInfo legacy_iface_info1 = {.name = kIfaceName1, | ||
81 | .channel = kIfaceChannel1}; | ||
82 | legacy_hal::WifiMacInfo legacy_mac_info2 = { | ||
83 | .wlan_mac_id = kMacId2, .mac_band = legacy_hal::WLAN_MAC_2_4_BAND}; | ||
84 | legacy_hal::WifiIfaceInfo legacy_iface_info2 = {.name = kIfaceName2, | ||
85 | .channel = kIfaceChannel2}; | ||
86 | legacy_mac_info1.iface_infos.push_back(legacy_iface_info1); | ||
87 | legacy_mac_infos.push_back(legacy_mac_info1); | ||
88 | legacy_mac_info2.iface_infos.push_back(legacy_iface_info2); | ||
89 | legacy_mac_infos.push_back(legacy_mac_info2); | ||
90 | |||
91 | std::vector<IWifiChipEventCallback::RadioModeInfo> hidl_radio_mode_infos; | ||
92 | ASSERT_TRUE(hidl_struct_util::convertLegacyWifiMacInfosToHidl( | ||
93 | legacy_mac_infos, &hidl_radio_mode_infos)); | ||
94 | |||
95 | ASSERT_EQ(2u, hidl_radio_mode_infos.size()); | ||
96 | |||
97 | // Find mac info 1. | ||
98 | const auto hidl_radio_mode_info1 = std::find_if( | ||
99 | hidl_radio_mode_infos.begin(), hidl_radio_mode_infos.end(), | ||
100 | [&legacy_mac_info1](const IWifiChipEventCallback::RadioModeInfo& x) { | ||
101 | return x.radioId == legacy_mac_info1.wlan_mac_id; | ||
102 | }); | ||
103 | ASSERT_NE(hidl_radio_mode_infos.end(), hidl_radio_mode_info1); | ||
104 | EXPECT_EQ(WifiBand::BAND_5GHZ, hidl_radio_mode_info1->bandInfo); | ||
105 | ASSERT_EQ(1u, hidl_radio_mode_info1->ifaceInfos.size()); | ||
106 | auto hidl_iface_info1 = hidl_radio_mode_info1->ifaceInfos[0]; | ||
107 | EXPECT_EQ(legacy_iface_info1.name, hidl_iface_info1.name); | ||
108 | EXPECT_EQ(static_cast<uint32_t>(legacy_iface_info1.channel), | ||
109 | hidl_iface_info1.channel); | ||
110 | |||
111 | // Find mac info 2. | ||
112 | const auto hidl_radio_mode_info2 = std::find_if( | ||
113 | hidl_radio_mode_infos.begin(), hidl_radio_mode_infos.end(), | ||
114 | [&legacy_mac_info2](const IWifiChipEventCallback::RadioModeInfo& x) { | ||
115 | return x.radioId == legacy_mac_info2.wlan_mac_id; | ||
116 | }); | ||
117 | ASSERT_NE(hidl_radio_mode_infos.end(), hidl_radio_mode_info2); | ||
118 | EXPECT_EQ(WifiBand::BAND_24GHZ, hidl_radio_mode_info2->bandInfo); | ||
119 | ASSERT_EQ(1u, hidl_radio_mode_info2->ifaceInfos.size()); | ||
120 | auto hidl_iface_info2 = hidl_radio_mode_info2->ifaceInfos[0]; | ||
121 | EXPECT_EQ(legacy_iface_info2.name, hidl_iface_info2.name); | ||
122 | EXPECT_EQ(static_cast<uint32_t>(legacy_iface_info2.channel), | ||
123 | hidl_iface_info2.channel); | ||
124 | } | ||
125 | } // namespace implementation | ||
126 | } // namespace V1_2 | ||
127 | } // namespace wifi | ||
128 | } // namespace hardware | ||
129 | } // namespace android | ||
diff --git a/wifi/1.2/default/wifi.cpp b/wifi/1.2/default/wifi.cpp index d6106b47..79f921fa 100644 --- a/wifi/1.2/default/wifi.cpp +++ b/wifi/1.2/default/wifi.cpp | |||
@@ -80,6 +80,9 @@ Return<void> Wifi::getChip(ChipId chip_id, getChip_cb hidl_status_cb) { | |||
80 | Return<void> Wifi::debug(const hidl_handle& handle, | 80 | Return<void> Wifi::debug(const hidl_handle& handle, |
81 | const hidl_vec<hidl_string>&) { | 81 | const hidl_vec<hidl_string>&) { |
82 | LOG(INFO) << "-----------Debug is called----------------"; | 82 | LOG(INFO) << "-----------Debug is called----------------"; |
83 | if (!chip_.get()) { | ||
84 | return Void(); | ||
85 | } | ||
83 | return chip_->debug(handle, {}); | 86 | return chip_->debug(handle, {}); |
84 | } | 87 | } |
85 | 88 | ||
diff --git a/wifi/1.2/default/wifi_chip.cpp b/wifi/1.2/default/wifi_chip.cpp index bc3404a8..38301e96 100644 --- a/wifi/1.2/default/wifi_chip.cpp +++ b/wifi/1.2/default/wifi_chip.cpp | |||
@@ -306,7 +306,7 @@ Return<void> WifiChip::getId(getId_cb hidl_status_cb) { | |||
306 | } | 306 | } |
307 | 307 | ||
308 | Return<void> WifiChip::registerEventCallback( | 308 | Return<void> WifiChip::registerEventCallback( |
309 | const sp<IWifiChipEventCallback>& event_callback, | 309 | const sp<V1_0::IWifiChipEventCallback>& event_callback, |
310 | registerEventCallback_cb hidl_status_cb) { | 310 | registerEventCallback_cb hidl_status_cb) { |
311 | return validateAndCall(this, WifiStatusCode::ERROR_WIFI_CHIP_INVALID, | 311 | return validateAndCall(this, WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
312 | &WifiChip::registerEventCallbackInternal, | 312 | &WifiChip::registerEventCallbackInternal, |
@@ -520,6 +520,14 @@ Return<void> WifiChip::resetTxPowerScenario( | |||
520 | hidl_status_cb); | 520 | hidl_status_cb); |
521 | } | 521 | } |
522 | 522 | ||
523 | Return<void> WifiChip::registerEventCallback_1_2( | ||
524 | const sp<IWifiChipEventCallback>& event_callback, | ||
525 | registerEventCallback_cb hidl_status_cb) { | ||
526 | return validateAndCall(this, WifiStatusCode::ERROR_WIFI_CHIP_INVALID, | ||
527 | &WifiChip::registerEventCallbackInternal_1_2, | ||
528 | hidl_status_cb, event_callback); | ||
529 | } | ||
530 | |||
523 | Return<void> WifiChip::debug(const hidl_handle& handle, | 531 | Return<void> WifiChip::debug(const hidl_handle& handle, |
524 | const hidl_vec<hidl_string>&) { | 532 | const hidl_vec<hidl_string>&) { |
525 | if (handle != nullptr && handle->numFds >= 1) { | 533 | if (handle != nullptr && handle->numFds >= 1) { |
@@ -556,11 +564,9 @@ std::pair<WifiStatus, ChipId> WifiChip::getIdInternal() { | |||
556 | } | 564 | } |
557 | 565 | ||
558 | WifiStatus WifiChip::registerEventCallbackInternal( | 566 | WifiStatus WifiChip::registerEventCallbackInternal( |
559 | const sp<IWifiChipEventCallback>& event_callback) { | 567 | const sp<V1_0::IWifiChipEventCallback>& /* event_callback */) { |
560 | if (!event_cb_handler_.addCallback(event_callback)) { | 568 | // Deprecated support for this callback. |
561 | return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN); | 569 | return createWifiStatus(WifiStatusCode::ERROR_NOT_SUPPORTED); |
562 | } | ||
563 | return createWifiStatus(WifiStatusCode::SUCCESS); | ||
564 | } | 570 | } |
565 | 571 | ||
566 | std::pair<WifiStatus, uint32_t> WifiChip::getCapabilitiesInternal() { | 572 | std::pair<WifiStatus, uint32_t> WifiChip::getCapabilitiesInternal() { |
@@ -997,6 +1003,14 @@ WifiStatus WifiChip::resetTxPowerScenarioInternal() { | |||
997 | return createWifiStatusFromLegacyError(legacy_status); | 1003 | return createWifiStatusFromLegacyError(legacy_status); |
998 | } | 1004 | } |
999 | 1005 | ||
1006 | WifiStatus WifiChip::registerEventCallbackInternal_1_2( | ||
1007 | const sp<IWifiChipEventCallback>& event_callback) { | ||
1008 | if (!event_cb_handler_.addCallback(event_callback)) { | ||
1009 | return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN); | ||
1010 | } | ||
1011 | return createWifiStatus(WifiStatusCode::SUCCESS); | ||
1012 | } | ||
1013 | |||
1000 | WifiStatus WifiChip::handleChipConfiguration( | 1014 | WifiStatus WifiChip::handleChipConfiguration( |
1001 | /* NONNULL */ std::unique_lock<std::recursive_mutex>* lock, | 1015 | /* NONNULL */ std::unique_lock<std::recursive_mutex>* lock, |
1002 | ChipModeId mode_id) { | 1016 | ChipModeId mode_id) { |
@@ -1030,6 +1044,13 @@ WifiStatus WifiChip::handleChipConfiguration( | |||
1030 | << legacyErrorToString(legacy_status); | 1044 | << legacyErrorToString(legacy_status); |
1031 | return createWifiStatusFromLegacyError(legacy_status); | 1045 | return createWifiStatusFromLegacyError(legacy_status); |
1032 | } | 1046 | } |
1047 | // Every time the HAL is restarted, we need to register the | ||
1048 | // radio mode change callback. | ||
1049 | WifiStatus status = registerRadioModeChangeCallback(); | ||
1050 | if (status.code != WifiStatusCode::SUCCESS) { | ||
1051 | // This probably is not a critical failure? | ||
1052 | LOG(ERROR) << "Failed to register radio mode change callback"; | ||
1053 | } | ||
1033 | return createWifiStatus(WifiStatusCode::SUCCESS); | 1054 | return createWifiStatus(WifiStatusCode::SUCCESS); |
1034 | } | 1055 | } |
1035 | 1056 | ||
@@ -1073,6 +1094,36 @@ WifiStatus WifiChip::registerDebugRingBufferCallback() { | |||
1073 | return createWifiStatusFromLegacyError(legacy_status); | 1094 | return createWifiStatusFromLegacyError(legacy_status); |
1074 | } | 1095 | } |
1075 | 1096 | ||
1097 | WifiStatus WifiChip::registerRadioModeChangeCallback() { | ||
1098 | android::wp<WifiChip> weak_ptr_this(this); | ||
1099 | const auto& on_radio_mode_change_callback = | ||
1100 | [weak_ptr_this](const std::vector<legacy_hal::WifiMacInfo>& mac_infos) { | ||
1101 | const auto shared_ptr_this = weak_ptr_this.promote(); | ||
1102 | if (!shared_ptr_this.get() || !shared_ptr_this->isValid()) { | ||
1103 | LOG(ERROR) << "Callback invoked on an invalid object"; | ||
1104 | return; | ||
1105 | } | ||
1106 | std::vector<IWifiChipEventCallback::RadioModeInfo> | ||
1107 | hidl_radio_mode_infos; | ||
1108 | if (!hidl_struct_util::convertLegacyWifiMacInfosToHidl( | ||
1109 | mac_infos, &hidl_radio_mode_infos)) { | ||
1110 | LOG(ERROR) << "Error converting wifi mac info"; | ||
1111 | return; | ||
1112 | } | ||
1113 | for (const auto& callback : shared_ptr_this->getEventCallbacks()) { | ||
1114 | if (!callback->onRadioModeChange(hidl_radio_mode_infos) | ||
1115 | .isOk()) { | ||
1116 | LOG(ERROR) << "Failed to invoke onRadioModeChange" | ||
1117 | << " callback on: " << toString(callback); | ||
1118 | } | ||
1119 | } | ||
1120 | }; | ||
1121 | legacy_hal::wifi_error legacy_status = | ||
1122 | legacy_hal_.lock()->registerRadioModeChangeCallbackHandler( | ||
1123 | getWlan0IfaceName(), on_radio_mode_change_callback); | ||
1124 | return createWifiStatusFromLegacyError(legacy_status); | ||
1125 | } | ||
1126 | |||
1076 | void WifiChip::populateModes() { | 1127 | void WifiChip::populateModes() { |
1077 | // The chip combination supported for current devices is fixed. | 1128 | // The chip combination supported for current devices is fixed. |
1078 | // They can be one of the following based on device features: | 1129 | // They can be one of the following based on device features: |
diff --git a/wifi/1.2/default/wifi_chip.h b/wifi/1.2/default/wifi_chip.h index 4ffa8da1..24a54862 100644 --- a/wifi/1.2/default/wifi_chip.h +++ b/wifi/1.2/default/wifi_chip.h | |||
@@ -74,7 +74,7 @@ class WifiChip : public V1_2::IWifiChip { | |||
74 | // HIDL methods exposed. | 74 | // HIDL methods exposed. |
75 | Return<void> getId(getId_cb hidl_status_cb) override; | 75 | Return<void> getId(getId_cb hidl_status_cb) override; |
76 | Return<void> registerEventCallback( | 76 | Return<void> registerEventCallback( |
77 | const sp<IWifiChipEventCallback>& event_callback, | 77 | const sp<V1_0::IWifiChipEventCallback>& event_callback, |
78 | registerEventCallback_cb hidl_status_cb) override; | 78 | registerEventCallback_cb hidl_status_cb) override; |
79 | Return<void> getCapabilities(getCapabilities_cb hidl_status_cb) override; | 79 | Return<void> getCapabilities(getCapabilities_cb hidl_status_cb) override; |
80 | Return<void> getAvailableModes( | 80 | Return<void> getAvailableModes( |
@@ -138,6 +138,9 @@ class WifiChip : public V1_2::IWifiChip { | |||
138 | resetTxPowerScenario_cb hidl_status_cb) override; | 138 | resetTxPowerScenario_cb hidl_status_cb) override; |
139 | Return<void> debug(const hidl_handle& handle, | 139 | Return<void> debug(const hidl_handle& handle, |
140 | const hidl_vec<hidl_string>& options) override; | 140 | const hidl_vec<hidl_string>& options) override; |
141 | Return<void> registerEventCallback_1_2( | ||
142 | const sp<IWifiChipEventCallback>& event_callback, | ||
143 | registerEventCallback_1_2_cb hidl_status_cb) override; | ||
141 | 144 | ||
142 | private: | 145 | private: |
143 | void invalidateAndRemoveAllIfaces(); | 146 | void invalidateAndRemoveAllIfaces(); |
@@ -145,7 +148,7 @@ class WifiChip : public V1_2::IWifiChip { | |||
145 | // Corresponding worker functions for the HIDL methods. | 148 | // Corresponding worker functions for the HIDL methods. |
146 | std::pair<WifiStatus, ChipId> getIdInternal(); | 149 | std::pair<WifiStatus, ChipId> getIdInternal(); |
147 | WifiStatus registerEventCallbackInternal( | 150 | WifiStatus registerEventCallbackInternal( |
148 | const sp<IWifiChipEventCallback>& event_callback); | 151 | const sp<V1_0::IWifiChipEventCallback>& event_callback); |
149 | std::pair<WifiStatus, uint32_t> getCapabilitiesInternal(); | 152 | std::pair<WifiStatus, uint32_t> getCapabilitiesInternal(); |
150 | std::pair<WifiStatus, std::vector<ChipMode>> getAvailableModesInternal(); | 153 | std::pair<WifiStatus, std::vector<ChipMode>> getAvailableModesInternal(); |
151 | WifiStatus configureChipInternal( | 154 | WifiStatus configureChipInternal( |
@@ -192,10 +195,13 @@ class WifiChip : public V1_2::IWifiChip { | |||
192 | WifiStatus enableDebugErrorAlertsInternal(bool enable); | 195 | WifiStatus enableDebugErrorAlertsInternal(bool enable); |
193 | WifiStatus selectTxPowerScenarioInternal(TxPowerScenario scenario); | 196 | WifiStatus selectTxPowerScenarioInternal(TxPowerScenario scenario); |
194 | WifiStatus resetTxPowerScenarioInternal(); | 197 | WifiStatus resetTxPowerScenarioInternal(); |
198 | WifiStatus registerEventCallbackInternal_1_2( | ||
199 | const sp<IWifiChipEventCallback>& event_callback); | ||
195 | 200 | ||
196 | WifiStatus handleChipConfiguration( | 201 | WifiStatus handleChipConfiguration( |
197 | std::unique_lock<std::recursive_mutex>* lock, ChipModeId mode_id); | 202 | std::unique_lock<std::recursive_mutex>* lock, ChipModeId mode_id); |
198 | WifiStatus registerDebugRingBufferCallback(); | 203 | WifiStatus registerDebugRingBufferCallback(); |
204 | WifiStatus registerRadioModeChangeCallback(); | ||
199 | 205 | ||
200 | void populateModes(); | 206 | void populateModes(); |
201 | std::vector<IWifiChip::ChipIfaceCombination> | 207 | std::vector<IWifiChip::ChipIfaceCombination> |
diff --git a/wifi/1.2/default/wifi_legacy_hal.cpp b/wifi/1.2/default/wifi_legacy_hal.cpp index 9abe514a..5f40d502 100644 --- a/wifi/1.2/default/wifi_legacy_hal.cpp +++ b/wifi/1.2/default/wifi_legacy_hal.cpp | |||
@@ -148,6 +148,17 @@ void onAsyncErrorAlert(wifi_request_id id, char* buffer, int buffer_size, | |||
148 | } | 148 | } |
149 | } | 149 | } |
150 | 150 | ||
151 | // Callback to be invoked for radio mode change indication. | ||
152 | std::function<void(wifi_request_id, uint32_t, wifi_mac_info*)> | ||
153 | on_radio_mode_change_internal_callback; | ||
154 | void onAsyncRadioModeChange(wifi_request_id id, uint32_t num_macs, | ||
155 | wifi_mac_info* mac_infos) { | ||
156 | const auto lock = hidl_sync_util::acquireGlobalLock(); | ||
157 | if (on_radio_mode_change_internal_callback) { | ||
158 | on_radio_mode_change_internal_callback(id, num_macs, mac_infos); | ||
159 | } | ||
160 | } | ||
161 | |||
151 | // Callback to be invoked for rtt results results. | 162 | // Callback to be invoked for rtt results results. |
152 | std::function<void(wifi_request_id, unsigned num_results, | 163 | std::function<void(wifi_request_id, unsigned num_results, |
153 | wifi_rtt_result* rtt_results[])> | 164 | wifi_rtt_result* rtt_results[])> |
@@ -937,6 +948,41 @@ wifi_error WifiLegacyHal::deregisterErrorAlertCallbackHandler( | |||
937 | 0, getIfaceHandle(iface_name)); | 948 | 0, getIfaceHandle(iface_name)); |
938 | } | 949 | } |
939 | 950 | ||
951 | wifi_error WifiLegacyHal::registerRadioModeChangeCallbackHandler( | ||
952 | const std::string& iface_name, | ||
953 | const on_radio_mode_change_callback& on_user_change_callback) { | ||
954 | if (on_radio_mode_change_internal_callback) { | ||
955 | return WIFI_ERROR_NOT_AVAILABLE; | ||
956 | } | ||
957 | on_radio_mode_change_internal_callback = [on_user_change_callback]( | ||
958 | wifi_request_id /* id */, | ||
959 | uint32_t num_macs, | ||
960 | wifi_mac_info* mac_infos_arr) { | ||
961 | if (num_macs > 0 && mac_infos_arr) { | ||
962 | std::vector<WifiMacInfo> mac_infos_vec; | ||
963 | for (uint32_t i = 0; i < num_macs; i++) { | ||
964 | WifiMacInfo mac_info; | ||
965 | mac_info.wlan_mac_id = mac_infos_arr[i].wlan_mac_id; | ||
966 | mac_info.mac_band = mac_infos_arr[i].mac_band; | ||
967 | for (int32_t j = 0; j < mac_infos_arr[i].num_iface; j++) { | ||
968 | WifiIfaceInfo iface_info; | ||
969 | iface_info.name = mac_infos_arr[i].iface_info[j].iface_name; | ||
970 | iface_info.channel = mac_infos_arr[i].iface_info[j].channel; | ||
971 | mac_info.iface_infos.push_back(iface_info); | ||
972 | } | ||
973 | mac_infos_vec.push_back(mac_info); | ||
974 | } | ||
975 | on_user_change_callback(mac_infos_vec); | ||
976 | } | ||
977 | }; | ||
978 | wifi_error status = global_func_table_.wifi_set_radio_mode_change_handler( | ||
979 | 0, getIfaceHandle(iface_name), {onAsyncRadioModeChange}); | ||
980 | if (status != WIFI_SUCCESS) { | ||
981 | on_radio_mode_change_internal_callback = nullptr; | ||
982 | } | ||
983 | return status; | ||
984 | } | ||
985 | |||
940 | wifi_error WifiLegacyHal::startRttRangeRequest( | 986 | wifi_error WifiLegacyHal::startRttRangeRequest( |
941 | const std::string& iface_name, wifi_request_id id, | 987 | const std::string& iface_name, wifi_request_id id, |
942 | const std::vector<wifi_rtt_config>& rtt_configs, | 988 | const std::vector<wifi_rtt_config>& rtt_configs, |
@@ -1324,6 +1370,7 @@ void WifiLegacyHal::invalidate() { | |||
1324 | on_rssi_threshold_breached_internal_callback = nullptr; | 1370 | on_rssi_threshold_breached_internal_callback = nullptr; |
1325 | on_ring_buffer_data_internal_callback = nullptr; | 1371 | on_ring_buffer_data_internal_callback = nullptr; |
1326 | on_error_alert_internal_callback = nullptr; | 1372 | on_error_alert_internal_callback = nullptr; |
1373 | on_radio_mode_change_internal_callback = nullptr; | ||
1327 | on_rtt_results_internal_callback = nullptr; | 1374 | on_rtt_results_internal_callback = nullptr; |
1328 | on_nan_notify_response_user_callback = nullptr; | 1375 | on_nan_notify_response_user_callback = nullptr; |
1329 | on_nan_event_publish_terminated_user_callback = nullptr; | 1376 | on_nan_event_publish_terminated_user_callback = nullptr; |
diff --git a/wifi/1.2/default/wifi_legacy_hal.h b/wifi/1.2/default/wifi_legacy_hal.h index da88f6b4..bd68bcd2 100644 --- a/wifi/1.2/default/wifi_legacy_hal.h +++ b/wifi/1.2/default/wifi_legacy_hal.h | |||
@@ -132,6 +132,26 @@ using on_ring_buffer_data_callback = | |||
132 | // Callback for alerts. | 132 | // Callback for alerts. |
133 | using on_error_alert_callback = | 133 | using on_error_alert_callback = |
134 | std::function<void(int32_t, const std::vector<uint8_t>&)>; | 134 | std::function<void(int32_t, const std::vector<uint8_t>&)>; |
135 | |||
136 | // Struct for the mac info from the legacy HAL. This is a cleaner version | ||
137 | // of the |wifi_mac_info| & |wifi_iface_info|. | ||
138 | typedef struct { | ||
139 | std::string name; | ||
140 | wifi_channel channel; | ||
141 | } WifiIfaceInfo; | ||
142 | |||
143 | typedef struct { | ||
144 | uint32_t wlan_mac_id; | ||
145 | /* BIT MASK of BIT(WLAN_MAC*) as represented by wlan_mac_band */ | ||
146 | uint32_t mac_band; | ||
147 | /* Represents the connected Wi-Fi interfaces associated with each MAC */ | ||
148 | std::vector<WifiIfaceInfo> iface_infos; | ||
149 | } WifiMacInfo; | ||
150 | |||
151 | // Callback for radio mode change | ||
152 | using on_radio_mode_change_callback = | ||
153 | std::function<void(const std::vector<WifiMacInfo>&)>; | ||
154 | |||
135 | /** | 155 | /** |
136 | * Class that encapsulates all legacy HAL interactions. | 156 | * Class that encapsulates all legacy HAL interactions. |
137 | * This class manages the lifetime of the event loop thread used by legacy HAL. | 157 | * This class manages the lifetime of the event loop thread used by legacy HAL. |
@@ -253,6 +273,10 @@ class WifiLegacyHal { | |||
253 | const on_error_alert_callback& on_alert_callback); | 273 | const on_error_alert_callback& on_alert_callback); |
254 | wifi_error deregisterErrorAlertCallbackHandler( | 274 | wifi_error deregisterErrorAlertCallbackHandler( |
255 | const std::string& iface_name); | 275 | const std::string& iface_name); |
276 | // Radio mode functions. | ||
277 | wifi_error registerRadioModeChangeCallbackHandler( | ||
278 | const std::string& iface_name, | ||
279 | const on_radio_mode_change_callback& on_user_change_callback); | ||
256 | // RTT functions. | 280 | // RTT functions. |
257 | wifi_error startRttRangeRequest( | 281 | wifi_error startRttRangeRequest( |
258 | const std::string& iface_name, wifi_request_id id, | 282 | const std::string& iface_name, wifi_request_id id, |
diff --git a/wifi/1.2/default/wifi_legacy_hal_stubs.cpp b/wifi/1.2/default/wifi_legacy_hal_stubs.cpp index 28972cb1..2ee2aa29 100644 --- a/wifi/1.2/default/wifi_legacy_hal_stubs.cpp +++ b/wifi/1.2/default/wifi_legacy_hal_stubs.cpp | |||
@@ -134,6 +134,7 @@ bool initHalFuncTableWithStubs(wifi_hal_fn* hal_fn) { | |||
134 | populateStubFor(&hal_fn->wifi_configure_roaming); | 134 | populateStubFor(&hal_fn->wifi_configure_roaming); |
135 | populateStubFor(&hal_fn->wifi_select_tx_power_scenario); | 135 | populateStubFor(&hal_fn->wifi_select_tx_power_scenario); |
136 | populateStubFor(&hal_fn->wifi_reset_tx_power_scenario); | 136 | populateStubFor(&hal_fn->wifi_reset_tx_power_scenario); |
137 | populateStubFor(&hal_fn->wifi_set_radio_mode_change_handler); | ||
137 | return true; | 138 | return true; |
138 | } | 139 | } |
139 | } // namespace legacy_hal | 140 | } // namespace legacy_hal |
diff --git a/wifi/hostapd/1.0/vts/functional/Android.bp b/wifi/hostapd/1.0/vts/functional/Android.bp new file mode 100644 index 00000000..7a920b44 --- /dev/null +++ b/wifi/hostapd/1.0/vts/functional/Android.bp | |||
@@ -0,0 +1,52 @@ | |||
1 | // | ||
2 | // Copyright (C) 2018 The Android Open Source Project | ||
3 | // | ||
4 | // Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | // you may not use this file except in compliance with the License. | ||
6 | // You may obtain a copy of the License at | ||
7 | // | ||
8 | // http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | // | ||
10 | // Unless required by applicable law or agreed to in writing, software | ||
11 | // distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | // See the License for the specific language governing permissions and | ||
14 | // limitations under the License. | ||
15 | // | ||
16 | |||
17 | cc_library_static { | ||
18 | name: "VtsHalWifiHostapdV1_0TargetTestUtil", | ||
19 | defaults: ["VtsHalTargetTestDefaults"], | ||
20 | srcs: ["hostapd_hidl_test_utils.cpp"], | ||
21 | export_include_dirs: [ | ||
22 | "." | ||
23 | ], | ||
24 | static_libs: [ | ||
25 | "VtsHalWifiV1_0TargetTestUtil", | ||
26 | "android.hardware.wifi.hostapd@1.0", | ||
27 | "android.hardware.wifi@1.0", | ||
28 | "libcrypto", | ||
29 | "libgmock", | ||
30 | "libwifi-system", | ||
31 | "libwifi-system-iface", | ||
32 | ], | ||
33 | } | ||
34 | |||
35 | cc_test { | ||
36 | name: "VtsHalWifiHostapdV1_0TargetTest", | ||
37 | defaults: ["VtsHalTargetTestDefaults"], | ||
38 | srcs: [ | ||
39 | "VtsHalWifiHostapdV1_0TargetTest.cpp", | ||
40 | "hostapd_hidl_test.cpp", | ||
41 | ], | ||
42 | static_libs: [ | ||
43 | "VtsHalWifiV1_0TargetTestUtil", | ||
44 | "VtsHalWifiHostapdV1_0TargetTestUtil", | ||
45 | "android.hardware.wifi.hostapd@1.0", | ||
46 | "android.hardware.wifi@1.0", | ||
47 | "libcrypto", | ||
48 | "libgmock", | ||
49 | "libwifi-system", | ||
50 | "libwifi-system-iface", | ||
51 | ], | ||
52 | } | ||
diff --git a/wifi/hostapd/1.0/vts/functional/VtsHalWifiHostapdV1_0TargetTest.cpp b/wifi/hostapd/1.0/vts/functional/VtsHalWifiHostapdV1_0TargetTest.cpp new file mode 100644 index 00000000..64e6fbe3 --- /dev/null +++ b/wifi/hostapd/1.0/vts/functional/VtsHalWifiHostapdV1_0TargetTest.cpp | |||
@@ -0,0 +1,35 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2016 The Android Open Source Project | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | #include <android-base/logging.h> | ||
18 | |||
19 | #include <VtsHalHidlTargetTestBase.h> | ||
20 | |||
21 | #include "hostapd_hidl_test_utils.h" | ||
22 | |||
23 | class HostapdHidlEnvironment : public ::testing::Environment { | ||
24 | public: | ||
25 | virtual void SetUp() override { stopHostapd(); } | ||
26 | virtual void TearDown() override { startHostapdAndWaitForHidlService(); } | ||
27 | }; | ||
28 | |||
29 | int main(int argc, char** argv) { | ||
30 | ::testing::AddGlobalTestEnvironment(new HostapdHidlEnvironment); | ||
31 | ::testing::InitGoogleTest(&argc, argv); | ||
32 | int status = RUN_ALL_TESTS(); | ||
33 | LOG(INFO) << "Test result = " << status; | ||
34 | return status; | ||
35 | } | ||
diff --git a/wifi/hostapd/1.0/vts/functional/hostapd_hidl_call_util.h b/wifi/hostapd/1.0/vts/functional/hostapd_hidl_call_util.h new file mode 100644 index 00000000..2f71ccba --- /dev/null +++ b/wifi/hostapd/1.0/vts/functional/hostapd_hidl_call_util.h | |||
@@ -0,0 +1,127 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2018 The Android Open Source Project | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | // This file is copied from | ||
18 | // hardware/interfaces/wifi/1.0/vts/functional/wifi_hidl_call_util.h | ||
19 | // Please make sure these two file are consistent. | ||
20 | |||
21 | #pragma once | ||
22 | |||
23 | #include <functional> | ||
24 | #include <tuple> | ||
25 | #include <type_traits> | ||
26 | #include <utility> | ||
27 | |||
28 | #include <VtsHalHidlTargetTestBase.h> | ||
29 | |||
30 | namespace { | ||
31 | namespace detail { | ||
32 | template <typename> | ||
33 | struct functionArgSaver; | ||
34 | |||
35 | // Provides a std::function that takes one argument, and a buffer | ||
36 | // wherein the function will store its argument. The buffer has | ||
37 | // the same type as the argument, but with const and reference | ||
38 | // modifiers removed. | ||
39 | template <typename ArgT> | ||
40 | struct functionArgSaver<std::function<void(ArgT)>> final { | ||
41 | using StorageT = typename std::remove_const< | ||
42 | typename std::remove_reference<ArgT>::type>::type; | ||
43 | |||
44 | std::function<void(ArgT)> saveArgs = [this](ArgT arg) { | ||
45 | this->saved_values = arg; | ||
46 | }; | ||
47 | |||
48 | StorageT saved_values; | ||
49 | }; | ||
50 | |||
51 | // Provides a std::function that takes two arguments, and a buffer | ||
52 | // wherein the function will store its arguments. The buffer is a | ||
53 | // std::pair, whose elements have the same types as the arguments | ||
54 | // (but with const and reference modifiers removed). | ||
55 | template <typename Arg1T, typename Arg2T> | ||
56 | struct functionArgSaver<std::function<void(Arg1T, Arg2T)>> final { | ||
57 | using StorageT = | ||
58 | std::pair<typename std::remove_const< | ||
59 | typename std::remove_reference<Arg1T>::type>::type, | ||
60 | typename std::remove_const< | ||
61 | typename std::remove_reference<Arg2T>::type>::type>; | ||
62 | |||
63 | std::function<void(Arg1T, Arg2T)> saveArgs = [this](Arg1T arg1, | ||
64 | Arg2T arg2) { | ||
65 | this->saved_values = {arg1, arg2}; | ||
66 | }; | ||
67 | |||
68 | StorageT saved_values; | ||
69 | }; | ||
70 | |||
71 | // Provides a std::function that takes three or more arguments, and a | ||
72 | // buffer wherein the function will store its arguments. The buffer is a | ||
73 | // std::tuple whose elements have the same types as the arguments (but | ||
74 | // with const and reference modifiers removed). | ||
75 | template <typename... ArgT> | ||
76 | struct functionArgSaver<std::function<void(ArgT...)>> final { | ||
77 | using StorageT = std::tuple<typename std::remove_const< | ||
78 | typename std::remove_reference<ArgT>::type>::type...>; | ||
79 | |||
80 | std::function<void(ArgT...)> saveArgs = [this](ArgT... arg) { | ||
81 | this->saved_values = {arg...}; | ||
82 | }; | ||
83 | |||
84 | StorageT saved_values; | ||
85 | }; | ||
86 | |||
87 | // Invokes |method| on |object|, providing |method| a CallbackT as the | ||
88 | // final argument. Returns a copy of the parameters that |method| provided | ||
89 | // to CallbackT. (The parameters are returned by value.) | ||
90 | template <typename CallbackT, typename MethodT, typename ObjectT, | ||
91 | typename... ArgT> | ||
92 | typename functionArgSaver<CallbackT>::StorageT invokeMethod( | ||
93 | MethodT method, ObjectT object, ArgT&&... methodArg) { | ||
94 | functionArgSaver<CallbackT> result_buffer; | ||
95 | const auto& res = ((*object).*method)(std::forward<ArgT>(methodArg)..., | ||
96 | result_buffer.saveArgs); | ||
97 | EXPECT_TRUE(res.isOk()); | ||
98 | return result_buffer.saved_values; | ||
99 | } | ||
100 | } // namespace detail | ||
101 | } // namespace | ||
102 | |||
103 | // Invokes |method| on |strong_pointer|, passing provided arguments through to | ||
104 | // |method|. | ||
105 | // | ||
106 | // Returns either: | ||
107 | // - A copy of the result callback parameter (for callbacks with a single | ||
108 | // parameter), OR | ||
109 | // - A pair containing a copy of the result callback parameters (for callbacks | ||
110 | // with two parameters), OR | ||
111 | // - A tuple containing a copy of the result callback paramters (for callbacks | ||
112 | // with three or more parameters). | ||
113 | // | ||
114 | // Example usage: | ||
115 | // EXPECT_EQ(HostapdStatusCode::SUCCESS, | ||
116 | // HIDL_INVOKE(strong_pointer, methodReturningHostapdStatus).code); | ||
117 | // EXPECT_EQ(HostapdStatusCode::SUCCESS, | ||
118 | // HIDL_INVOKE(strong_pointer, methodReturningHostapdStatusAndOneMore) | ||
119 | // .first.code); | ||
120 | // EXPECT_EQ(HostapdStatusCode::SUCCESS, std::get<0>( | ||
121 | // HIDL_INVOKE(strong_pointer, methodReturningHostapdStatusAndTwoMore)) | ||
122 | // .code); | ||
123 | #define HIDL_INVOKE(strong_pointer, method, ...) \ | ||
124 | (detail::invokeMethod< \ | ||
125 | std::remove_reference<decltype(*strong_pointer)>::type::method##_cb>( \ | ||
126 | &std::remove_reference<decltype(*strong_pointer)>::type::method, \ | ||
127 | strong_pointer, ##__VA_ARGS__)) | ||
diff --git a/wifi/hostapd/1.0/vts/functional/hostapd_hidl_test.cpp b/wifi/hostapd/1.0/vts/functional/hostapd_hidl_test.cpp new file mode 100644 index 00000000..5f51cfbd --- /dev/null +++ b/wifi/hostapd/1.0/vts/functional/hostapd_hidl_test.cpp | |||
@@ -0,0 +1,222 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2016 The Android Open Source Project | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | #include <android-base/logging.h> | ||
18 | #include <cutils/properties.h> | ||
19 | |||
20 | #include <VtsHalHidlTargetTestBase.h> | ||
21 | |||
22 | #include <android/hardware/wifi/hostapd/1.0/IHostapd.h> | ||
23 | |||
24 | #include "hostapd_hidl_call_util.h" | ||
25 | #include "hostapd_hidl_test_utils.h" | ||
26 | |||
27 | using ::android::sp; | ||
28 | using ::android::hardware::hidl_vec; | ||
29 | using ::android::hardware::wifi::hostapd::V1_0::IHostapd; | ||
30 | using ::android::hardware::wifi::hostapd::V1_0::HostapdStatus; | ||
31 | using ::android::hardware::wifi::hostapd::V1_0::HostapdStatusCode; | ||
32 | |||
33 | namespace { | ||
34 | constexpr unsigned char kNwSsid[] = {'t', 'e', 's', 't', '1', | ||
35 | '2', '3', '4', '5'}; | ||
36 | constexpr char kNwPassphrase[] = "test12345"; | ||
37 | constexpr int kIfaceChannel = 6; | ||
38 | constexpr int kIfaceInvalidChannel = 567; | ||
39 | } // namespace | ||
40 | |||
41 | class HostapdHidlTest : public ::testing::VtsHalHidlTargetTestBase { | ||
42 | public: | ||
43 | virtual void SetUp() override { | ||
44 | startHostapdAndWaitForHidlService(); | ||
45 | hostapd_ = getHostapd(); | ||
46 | ASSERT_NE(hostapd_.get(), nullptr); | ||
47 | } | ||
48 | |||
49 | virtual void TearDown() override { stopHostapd(); } | ||
50 | |||
51 | protected: | ||
52 | std::string getPrimaryWlanIfaceName() { | ||
53 | std::array<char, PROPERTY_VALUE_MAX> buffer; | ||
54 | property_get("wifi.interface", buffer.data(), "wlan0"); | ||
55 | return buffer.data(); | ||
56 | } | ||
57 | |||
58 | IHostapd::IfaceParams getIfaceParamsWithAcs() { | ||
59 | IHostapd::IfaceParams iface_params; | ||
60 | iface_params.ifaceName = getPrimaryWlanIfaceName(); | ||
61 | iface_params.hwModeParams.enable80211N = true; | ||
62 | iface_params.hwModeParams.enable80211AC = false; | ||
63 | iface_params.channelParams.enableAcs = true; | ||
64 | iface_params.channelParams.acsShouldExcludeDfs = true; | ||
65 | iface_params.channelParams.channel = 0; | ||
66 | iface_params.channelParams.band = IHostapd::Band::BAND_ANY; | ||
67 | return iface_params; | ||
68 | } | ||
69 | |||
70 | IHostapd::IfaceParams getIfaceParamsWithoutAcs() { | ||
71 | IHostapd::IfaceParams iface_params; | ||
72 | iface_params.ifaceName = getPrimaryWlanIfaceName(); | ||
73 | iface_params.hwModeParams.enable80211N = true; | ||
74 | iface_params.hwModeParams.enable80211AC = false; | ||
75 | iface_params.channelParams.enableAcs = false; | ||
76 | iface_params.channelParams.acsShouldExcludeDfs = false; | ||
77 | iface_params.channelParams.channel = kIfaceChannel; | ||
78 | iface_params.channelParams.band = IHostapd::Band::BAND_2_4_GHZ; | ||
79 | return iface_params; | ||
80 | } | ||
81 | |||
82 | IHostapd::IfaceParams getIfaceParamsWithInvalidChannel() { | ||
83 | IHostapd::IfaceParams iface_params; | ||
84 | iface_params.ifaceName = getPrimaryWlanIfaceName(); | ||
85 | iface_params.hwModeParams.enable80211N = true; | ||
86 | iface_params.hwModeParams.enable80211AC = false; | ||
87 | iface_params.channelParams.enableAcs = false; | ||
88 | iface_params.channelParams.acsShouldExcludeDfs = false; | ||
89 | iface_params.channelParams.channel = kIfaceInvalidChannel; | ||
90 | iface_params.channelParams.band = IHostapd::Band::BAND_2_4_GHZ; | ||
91 | return iface_params; | ||
92 | } | ||
93 | |||
94 | IHostapd::NetworkParams getPskNwParams() { | ||
95 | IHostapd::NetworkParams nw_params; | ||
96 | nw_params.ssid = | ||
97 | std::vector<uint8_t>(kNwSsid, kNwSsid + sizeof(kNwSsid)); | ||
98 | nw_params.isHidden = false; | ||
99 | nw_params.encryptionType = IHostapd::EncryptionType::WPA2; | ||
100 | nw_params.pskPassphrase = kNwPassphrase; | ||
101 | return nw_params; | ||
102 | } | ||
103 | |||
104 | IHostapd::NetworkParams getInvalidPskNwParams() { | ||
105 | IHostapd::NetworkParams nw_params; | ||
106 | nw_params.ssid = | ||
107 | std::vector<uint8_t>(kNwSsid, kNwSsid + sizeof(kNwSsid)); | ||
108 | nw_params.isHidden = false; | ||
109 | nw_params.encryptionType = IHostapd::EncryptionType::WPA2; | ||
110 | return nw_params; | ||
111 | } | ||
112 | |||
113 | IHostapd::NetworkParams getOpenNwParams() { | ||
114 | IHostapd::NetworkParams nw_params; | ||
115 | nw_params.ssid = | ||
116 | std::vector<uint8_t>(kNwSsid, kNwSsid + sizeof(kNwSsid)); | ||
117 | nw_params.isHidden = false; | ||
118 | nw_params.encryptionType = IHostapd::EncryptionType::NONE; | ||
119 | return nw_params; | ||
120 | } | ||
121 | // IHostapd object used for all tests in this fixture. | ||
122 | sp<IHostapd> hostapd_; | ||
123 | }; | ||
124 | |||
125 | /* | ||
126 | * Create: | ||
127 | * Ensures that an instance of the IHostapd proxy object is | ||
128 | * successfully created. | ||
129 | */ | ||
130 | TEST(HostapdHidlTestNoFixture, Create) { | ||
131 | startHostapdAndWaitForHidlService(); | ||
132 | EXPECT_NE(nullptr, getHostapd().get()); | ||
133 | stopHostapd(); | ||
134 | } | ||
135 | |||
136 | /** | ||
137 | * Adds an access point with PSK network config & ACS enabled. | ||
138 | * Access point creation should pass. | ||
139 | */ | ||
140 | TEST_F(HostapdHidlTest, AddPskAccessPointWithAcs) { | ||
141 | auto status = HIDL_INVOKE(hostapd_, addAccessPoint, getIfaceParamsWithAcs(), | ||
142 | getPskNwParams()); | ||
143 | EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code); | ||
144 | } | ||
145 | |||
146 | /** | ||
147 | * Adds an access point with Open network config & ACS enabled. | ||
148 | * Access point creation should pass. | ||
149 | */ | ||
150 | TEST_F(HostapdHidlTest, AddOpenAccessPointWithAcs) { | ||
151 | auto status = HIDL_INVOKE(hostapd_, addAccessPoint, getIfaceParamsWithAcs(), | ||
152 | getOpenNwParams()); | ||
153 | EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code); | ||
154 | } | ||
155 | |||
156 | /** | ||
157 | * Adds an access point with PSK network config & ACS disabled. | ||
158 | * Access point creation should pass. | ||
159 | */ | ||
160 | TEST_F(HostapdHidlTest, AddPskAccessPointWithoutAcs) { | ||
161 | auto status = HIDL_INVOKE(hostapd_, addAccessPoint, | ||
162 | getIfaceParamsWithoutAcs(), getPskNwParams()); | ||
163 | EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code); | ||
164 | } | ||
165 | |||
166 | /** | ||
167 | * Adds an access point with Open network config & ACS disabled. | ||
168 | * Access point creation should pass. | ||
169 | */ | ||
170 | TEST_F(HostapdHidlTest, AddOpenAccessPointWithoutAcs) { | ||
171 | auto status = HIDL_INVOKE(hostapd_, addAccessPoint, | ||
172 | getIfaceParamsWithoutAcs(), getOpenNwParams()); | ||
173 | EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code); | ||
174 | } | ||
175 | |||
176 | /** | ||
177 | * Adds & then removes an access point with PSK network config & ACS enabled. | ||
178 | * Access point creation & removal should pass. | ||
179 | */ | ||
180 | TEST_F(HostapdHidlTest, RemoveAccessPointWithAcs) { | ||
181 | auto status = HIDL_INVOKE(hostapd_, addAccessPoint, getIfaceParamsWithAcs(), | ||
182 | getPskNwParams()); | ||
183 | EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code); | ||
184 | status = | ||
185 | HIDL_INVOKE(hostapd_, removeAccessPoint, getPrimaryWlanIfaceName()); | ||
186 | EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code); | ||
187 | } | ||
188 | |||
189 | /** | ||
190 | * Adds & then removes an access point with PSK network config & ACS disabled. | ||
191 | * Access point creation & removal should pass. | ||
192 | */ | ||
193 | TEST_F(HostapdHidlTest, RemoveAccessPointWithoutAcs) { | ||
194 | auto status = HIDL_INVOKE(hostapd_, addAccessPoint, | ||
195 | getIfaceParamsWithoutAcs(), getPskNwParams()); | ||
196 | EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code); | ||
197 | status = | ||
198 | HIDL_INVOKE(hostapd_, removeAccessPoint, getPrimaryWlanIfaceName()); | ||
199 | EXPECT_EQ(HostapdStatusCode::SUCCESS, status.code); | ||
200 | } | ||
201 | |||
202 | /** | ||
203 | * Adds an access point with invalid channel. | ||
204 | * Access point creation should fail. | ||
205 | */ | ||
206 | TEST_F(HostapdHidlTest, AddPskAccessPointWithInvalidChannel) { | ||
207 | auto status = | ||
208 | HIDL_INVOKE(hostapd_, addAccessPoint, | ||
209 | getIfaceParamsWithInvalidChannel(), getPskNwParams()); | ||
210 | EXPECT_NE(HostapdStatusCode::SUCCESS, status.code); | ||
211 | } | ||
212 | |||
213 | /** | ||
214 | * Adds an access point with invalid PSK network config. | ||
215 | * Access point creation should fail. | ||
216 | */ | ||
217 | TEST_F(HostapdHidlTest, AddInvalidPskAccessPointWithoutAcs) { | ||
218 | auto status = | ||
219 | HIDL_INVOKE(hostapd_, addAccessPoint, getIfaceParamsWithoutAcs(), | ||
220 | getInvalidPskNwParams()); | ||
221 | EXPECT_NE(HostapdStatusCode::SUCCESS, status.code); | ||
222 | } | ||
diff --git a/wifi/hostapd/1.0/vts/functional/hostapd_hidl_test_utils.cpp b/wifi/hostapd/1.0/vts/functional/hostapd_hidl_test_utils.cpp new file mode 100644 index 00000000..0915150f --- /dev/null +++ b/wifi/hostapd/1.0/vts/functional/hostapd_hidl_test_utils.cpp | |||
@@ -0,0 +1,135 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2016 The Android Open Source Project | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | #include <VtsHalHidlTargetTestBase.h> | ||
18 | #include <android-base/logging.h> | ||
19 | |||
20 | #include <android/hidl/manager/1.0/IServiceManager.h> | ||
21 | #include <android/hidl/manager/1.0/IServiceNotification.h> | ||
22 | #include <hidl/HidlTransportSupport.h> | ||
23 | |||
24 | #include <wifi_system/hostapd_manager.h> | ||
25 | #include <wifi_system/interface_tool.h> | ||
26 | |||
27 | #include "hostapd_hidl_test_utils.h" | ||
28 | #include "wifi_hidl_test_utils.h" | ||
29 | |||
30 | using ::android::sp; | ||
31 | using ::android::hardware::configureRpcThreadpool; | ||
32 | using ::android::hardware::joinRpcThreadpool; | ||
33 | using ::android::hardware::hidl_string; | ||
34 | using ::android::hardware::hidl_vec; | ||
35 | using ::android::hardware::Return; | ||
36 | using ::android::hardware::Void; | ||
37 | using ::android::hardware::wifi::V1_0::ChipModeId; | ||
38 | using ::android::hardware::wifi::V1_0::IWifiChip; | ||
39 | using ::android::hardware::wifi::hostapd::V1_0::IHostapd; | ||
40 | using ::android::hardware::wifi::hostapd::V1_0::HostapdStatus; | ||
41 | using ::android::hardware::wifi::hostapd::V1_0::HostapdStatusCode; | ||
42 | using ::android::hidl::manager::V1_0::IServiceNotification; | ||
43 | using ::android::wifi_system::HostapdManager; | ||
44 | |||
45 | namespace { | ||
46 | const char kHostapdServiceName[] = "default"; | ||
47 | |||
48 | // Helper function to initialize the driver and firmware to AP mode | ||
49 | // using the vendor HAL HIDL interface. | ||
50 | void initilializeDriverAndFirmware() { | ||
51 | sp<IWifiChip> wifi_chip = getWifiChip(); | ||
52 | ChipModeId mode_id; | ||
53 | EXPECT_TRUE(configureChipToSupportIfaceType( | ||
54 | wifi_chip, ::android::hardware::wifi::V1_0::IfaceType::AP, &mode_id)); | ||
55 | } | ||
56 | |||
57 | // Helper function to deinitialize the driver and firmware | ||
58 | // using the vendor HAL HIDL interface. | ||
59 | void deInitilializeDriverAndFirmware() { stopWifi(); } | ||
60 | } // namespace | ||
61 | |||
62 | // Utility class to wait for wpa_hostapd's HIDL service registration. | ||
63 | class ServiceNotificationListener : public IServiceNotification { | ||
64 | public: | ||
65 | Return<void> onRegistration(const hidl_string& fully_qualified_name, | ||
66 | const hidl_string& instance_name, | ||
67 | bool pre_existing) override { | ||
68 | if (pre_existing) { | ||
69 | return Void(); | ||
70 | } | ||
71 | std::unique_lock<std::mutex> lock(mutex_); | ||
72 | registered_.push_back(std::string(fully_qualified_name.c_str()) + "/" + | ||
73 | instance_name.c_str()); | ||
74 | lock.unlock(); | ||
75 | condition_.notify_one(); | ||
76 | return Void(); | ||
77 | } | ||
78 | |||
79 | bool registerForHidlServiceNotifications(const std::string& instance_name) { | ||
80 | if (!IHostapd::registerForNotifications(instance_name, this)) { | ||
81 | return false; | ||
82 | } | ||
83 | configureRpcThreadpool(2, false); | ||
84 | return true; | ||
85 | } | ||
86 | |||
87 | bool waitForHidlService(uint32_t timeout_in_millis, | ||
88 | const std::string& instance_name) { | ||
89 | std::unique_lock<std::mutex> lock(mutex_); | ||
90 | condition_.wait_for(lock, std::chrono::milliseconds(timeout_in_millis), | ||
91 | [&]() { return registered_.size() >= 1; }); | ||
92 | if (registered_.size() != 1) { | ||
93 | return false; | ||
94 | } | ||
95 | std::string expected_registered = | ||
96 | std::string(IHostapd::descriptor) + "/" + instance_name; | ||
97 | if (registered_[0] != expected_registered) { | ||
98 | LOG(ERROR) << "Expected: " << expected_registered | ||
99 | << ", Got: " << registered_[0]; | ||
100 | return false; | ||
101 | } | ||
102 | return true; | ||
103 | } | ||
104 | |||
105 | private: | ||
106 | std::vector<std::string> registered_{}; | ||
107 | std::mutex mutex_; | ||
108 | std::condition_variable condition_; | ||
109 | }; | ||
110 | |||
111 | void stopHostapd() { | ||
112 | HostapdManager hostapd_manager; | ||
113 | |||
114 | ASSERT_TRUE(hostapd_manager.StopHostapd()); | ||
115 | deInitilializeDriverAndFirmware(); | ||
116 | } | ||
117 | |||
118 | void startHostapdAndWaitForHidlService() { | ||
119 | initilializeDriverAndFirmware(); | ||
120 | |||
121 | android::sp<ServiceNotificationListener> notification_listener = | ||
122 | new ServiceNotificationListener(); | ||
123 | ASSERT_TRUE(notification_listener->registerForHidlServiceNotifications( | ||
124 | kHostapdServiceName)); | ||
125 | |||
126 | HostapdManager hostapd_manager; | ||
127 | ASSERT_TRUE(hostapd_manager.StartHostapd()); | ||
128 | |||
129 | ASSERT_TRUE( | ||
130 | notification_listener->waitForHidlService(200, kHostapdServiceName)); | ||
131 | } | ||
132 | |||
133 | sp<IHostapd> getHostapd() { | ||
134 | return ::testing::VtsHalHidlTargetTestBase::getService<IHostapd>(); | ||
135 | } | ||
diff --git a/wifi/hostapd/1.0/vts/functional/hostapd_hidl_test_utils.h b/wifi/hostapd/1.0/vts/functional/hostapd_hidl_test_utils.h new file mode 100644 index 00000000..74ed2847 --- /dev/null +++ b/wifi/hostapd/1.0/vts/functional/hostapd_hidl_test_utils.h | |||
@@ -0,0 +1,36 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2016 The Android Open Source Project | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | #ifndef HOSTAPD_HIDL_TEST_UTILS_H | ||
18 | #define HOSTAPD_HIDL_TEST_UTILS_H | ||
19 | |||
20 | #include <android/hardware/wifi/hostapd/1.0/IHostapd.h> | ||
21 | |||
22 | // Used to stop the android wifi framework before every test. | ||
23 | void stopWifiFramework(); | ||
24 | void startWifiFramework(); | ||
25 | void stopHostapd(); | ||
26 | // Used to configure the chip, driver and start wpa_hostapd before every | ||
27 | // test. | ||
28 | void startHostapdAndWaitForHidlService(); | ||
29 | |||
30 | // Helper functions to obtain references to the various HIDL interface objects. | ||
31 | // Note: We only have a single instance of each of these objects currently. | ||
32 | // These helper functions should be modified to return vectors if we support | ||
33 | // multiple instances. | ||
34 | android::sp<android::hardware::wifi::hostapd::V1_0::IHostapd> getHostapd(); | ||
35 | |||
36 | #endif /* HOSTAPD_HIDL_TEST_UTILS_H */ | ||