Loading automotive/vehicle/2.0/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -56,6 +56,7 @@ hidl_interface { "VehiclePropertyChangeMode", "VehiclePropertyGroup", "VehiclePropertyOperation", "VehiclePropertyStatus", "VehiclePropertyType", "VehicleRadioConstants", "VehicleTurnSignal", Loading automotive/vehicle/2.0/default/common/include/vhal_v2_0/SubscriptionManager.h +4 −8 Original line number Diff line number Diff line Loading @@ -49,7 +49,7 @@ public: } void addOrUpdateSubscription(const SubscribeOptions &opts); bool isSubscribed(int32_t propId, int32_t areaId, SubscribeFlags flags); bool isSubscribed(int32_t propId, SubscribeFlags flags); std::vector<int32_t> getSubscribedProperties() const; private: Loading Loading @@ -87,8 +87,7 @@ public: /** * Constructs SubscriptionManager * * @param onPropertyUnsubscribed - this callback function will be called when there are no * more client subscribed to particular property. * @param onPropertyUnsubscribed - called when no more clients are subscribed to the property. */ SubscriptionManager(const OnPropertyUnsubscribed& onPropertyUnsubscribed) : mOnPropertyUnsubscribed(onPropertyUnsubscribed), Loading @@ -115,9 +114,7 @@ public: const std::vector<recyclable_ptr<VehiclePropValue>>& propValues, SubscribeFlags flags) const; std::list<sp<HalClient>> getSubscribedClients(int32_t propId, int32_t area, SubscribeFlags flags) const; std::list<sp<HalClient>> getSubscribedClients(int32_t propId, SubscribeFlags flags) const; /** * If there are no clients subscribed to given properties than callback function provided * in the constructor will be called. Loading @@ -125,7 +122,6 @@ public: void unsubscribe(ClientId clientId, int32_t propId); private: std::list<sp<HalClient>> getSubscribedClientsLocked(int32_t propId, int32_t area, SubscribeFlags flags) const; bool updateHalEventSubscriptionLocked(const SubscribeOptions& opts, SubscribeOptions* out); Loading automotive/vehicle/2.0/default/common/include/vhal_v2_0/VehicleHal.h +1 −4 Original line number Diff line number Diff line Loading @@ -48,17 +48,14 @@ public: /** * Subscribe to HAL property events. This method might be called multiple * times for the same vehicle property to update subscribed areas or sample * rate. * times for the same vehicle property to update sample rate. * * @param property to subscribe * @param areas a bitwise vehicle areas or 0 for all supported areas * @param sampleRate sample rate in Hz for properties that support sample * rate, e.g. for properties with * VehiclePropertyChangeMode::CONTINUOUS */ virtual StatusCode subscribe(int32_t property, int32_t areas, float sampleRate) = 0; /** Loading automotive/vehicle/2.0/default/common/include/vhal_v2_0/VehicleObjectPool.h +2 −3 Original line number Diff line number Diff line Loading @@ -191,9 +191,8 @@ public: VehiclePropValuePool& operator=(VehiclePropValuePool&) = delete; private: bool isDisposable(VehiclePropertyType type, size_t vecSize) const { return vecSize > mMaxRecyclableVectorSize || VehiclePropertyType::STRING == type || VehiclePropertyType::COMPLEX == type; return vecSize > mMaxRecyclableVectorSize || VehiclePropertyType::STRING == type || VehiclePropertyType::MIXED == type; } RecyclableType obtainDisposable(VehiclePropertyType valueType, Loading automotive/vehicle/2.0/default/common/src/SubscriptionManager.cpp +8 −22 Original line number Diff line number Diff line Loading @@ -34,23 +34,12 @@ namespace V2_0 { bool mergeSubscribeOptions(const SubscribeOptions &oldOpts, const SubscribeOptions &newOpts, SubscribeOptions *outResult) { int32_t updatedAreas = oldOpts.vehicleAreas; if (updatedAreas != kAllSupportedAreas) { updatedAreas = newOpts.vehicleAreas != kAllSupportedAreas ? updatedAreas | newOpts.vehicleAreas : kAllSupportedAreas; } float updatedRate = std::max(oldOpts.sampleRate, newOpts.sampleRate); SubscribeFlags updatedFlags = SubscribeFlags(oldOpts.flags | newOpts.flags); bool updated = updatedRate > oldOpts.sampleRate || updatedAreas != oldOpts.vehicleAreas || updatedFlags != oldOpts.flags; bool updated = (updatedRate > oldOpts.sampleRate) || (updatedFlags != oldOpts.flags); if (updated) { *outResult = oldOpts; outResult->vehicleAreas = updatedAreas; outResult->sampleRate = updatedRate; outResult->flags = updatedFlags; } Loading @@ -75,15 +64,13 @@ void HalClient::addOrUpdateSubscription(const SubscribeOptions &opts) { } bool HalClient::isSubscribed(int32_t propId, int32_t areaId, SubscribeFlags flags) { auto it = mSubscriptions.find(propId); if (it == mSubscriptions.end()) { return false; } const SubscribeOptions& opts = it->second; bool res = (opts.flags & flags) && (opts.vehicleAreas == 0 || areaId == 0 || opts.vehicleAreas & areaId); bool res = (opts.flags & flags); return res; } Loading Loading @@ -139,8 +126,7 @@ std::list<HalClientValues> SubscriptionManager::distributeValuesToClients( MuxGuard g(mLock); for (const auto& propValue: propValues) { VehiclePropValue* v = propValue.get(); auto clients = getSubscribedClientsLocked( v->prop, v->areaId, flags); auto clients = getSubscribedClientsLocked(v->prop, flags); for (const auto& client : clients) { clientValuesMap[client].push_back(v); } Loading @@ -158,21 +144,21 @@ std::list<HalClientValues> SubscriptionManager::distributeValuesToClients( return clientValues; } std::list<sp<HalClient>> SubscriptionManager::getSubscribedClients( int32_t propId, int32_t area, SubscribeFlags flags) const { std::list<sp<HalClient>> SubscriptionManager::getSubscribedClients(int32_t propId, SubscribeFlags flags) const { MuxGuard g(mLock); return getSubscribedClientsLocked(propId, area, flags); return getSubscribedClientsLocked(propId, flags); } std::list<sp<HalClient>> SubscriptionManager::getSubscribedClientsLocked( int32_t propId, int32_t area, SubscribeFlags flags) const { int32_t propId, SubscribeFlags flags) const { std::list<sp<HalClient>> subscribedClients; sp<HalClientVector> propClients = getClientsForPropertyLocked(propId); if (propClients.get() != nullptr) { for (size_t i = 0; i < propClients->size(); i++) { const auto& client = propClients->itemAt(i); if (client->isSubscribed(propId, area, flags)) { if (client->isSubscribed(propId, flags)) { subscribedClients.push_back(client); } } Loading Loading
automotive/vehicle/2.0/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -56,6 +56,7 @@ hidl_interface { "VehiclePropertyChangeMode", "VehiclePropertyGroup", "VehiclePropertyOperation", "VehiclePropertyStatus", "VehiclePropertyType", "VehicleRadioConstants", "VehicleTurnSignal", Loading
automotive/vehicle/2.0/default/common/include/vhal_v2_0/SubscriptionManager.h +4 −8 Original line number Diff line number Diff line Loading @@ -49,7 +49,7 @@ public: } void addOrUpdateSubscription(const SubscribeOptions &opts); bool isSubscribed(int32_t propId, int32_t areaId, SubscribeFlags flags); bool isSubscribed(int32_t propId, SubscribeFlags flags); std::vector<int32_t> getSubscribedProperties() const; private: Loading Loading @@ -87,8 +87,7 @@ public: /** * Constructs SubscriptionManager * * @param onPropertyUnsubscribed - this callback function will be called when there are no * more client subscribed to particular property. * @param onPropertyUnsubscribed - called when no more clients are subscribed to the property. */ SubscriptionManager(const OnPropertyUnsubscribed& onPropertyUnsubscribed) : mOnPropertyUnsubscribed(onPropertyUnsubscribed), Loading @@ -115,9 +114,7 @@ public: const std::vector<recyclable_ptr<VehiclePropValue>>& propValues, SubscribeFlags flags) const; std::list<sp<HalClient>> getSubscribedClients(int32_t propId, int32_t area, SubscribeFlags flags) const; std::list<sp<HalClient>> getSubscribedClients(int32_t propId, SubscribeFlags flags) const; /** * If there are no clients subscribed to given properties than callback function provided * in the constructor will be called. Loading @@ -125,7 +122,6 @@ public: void unsubscribe(ClientId clientId, int32_t propId); private: std::list<sp<HalClient>> getSubscribedClientsLocked(int32_t propId, int32_t area, SubscribeFlags flags) const; bool updateHalEventSubscriptionLocked(const SubscribeOptions& opts, SubscribeOptions* out); Loading
automotive/vehicle/2.0/default/common/include/vhal_v2_0/VehicleHal.h +1 −4 Original line number Diff line number Diff line Loading @@ -48,17 +48,14 @@ public: /** * Subscribe to HAL property events. This method might be called multiple * times for the same vehicle property to update subscribed areas or sample * rate. * times for the same vehicle property to update sample rate. * * @param property to subscribe * @param areas a bitwise vehicle areas or 0 for all supported areas * @param sampleRate sample rate in Hz for properties that support sample * rate, e.g. for properties with * VehiclePropertyChangeMode::CONTINUOUS */ virtual StatusCode subscribe(int32_t property, int32_t areas, float sampleRate) = 0; /** Loading
automotive/vehicle/2.0/default/common/include/vhal_v2_0/VehicleObjectPool.h +2 −3 Original line number Diff line number Diff line Loading @@ -191,9 +191,8 @@ public: VehiclePropValuePool& operator=(VehiclePropValuePool&) = delete; private: bool isDisposable(VehiclePropertyType type, size_t vecSize) const { return vecSize > mMaxRecyclableVectorSize || VehiclePropertyType::STRING == type || VehiclePropertyType::COMPLEX == type; return vecSize > mMaxRecyclableVectorSize || VehiclePropertyType::STRING == type || VehiclePropertyType::MIXED == type; } RecyclableType obtainDisposable(VehiclePropertyType valueType, Loading
automotive/vehicle/2.0/default/common/src/SubscriptionManager.cpp +8 −22 Original line number Diff line number Diff line Loading @@ -34,23 +34,12 @@ namespace V2_0 { bool mergeSubscribeOptions(const SubscribeOptions &oldOpts, const SubscribeOptions &newOpts, SubscribeOptions *outResult) { int32_t updatedAreas = oldOpts.vehicleAreas; if (updatedAreas != kAllSupportedAreas) { updatedAreas = newOpts.vehicleAreas != kAllSupportedAreas ? updatedAreas | newOpts.vehicleAreas : kAllSupportedAreas; } float updatedRate = std::max(oldOpts.sampleRate, newOpts.sampleRate); SubscribeFlags updatedFlags = SubscribeFlags(oldOpts.flags | newOpts.flags); bool updated = updatedRate > oldOpts.sampleRate || updatedAreas != oldOpts.vehicleAreas || updatedFlags != oldOpts.flags; bool updated = (updatedRate > oldOpts.sampleRate) || (updatedFlags != oldOpts.flags); if (updated) { *outResult = oldOpts; outResult->vehicleAreas = updatedAreas; outResult->sampleRate = updatedRate; outResult->flags = updatedFlags; } Loading @@ -75,15 +64,13 @@ void HalClient::addOrUpdateSubscription(const SubscribeOptions &opts) { } bool HalClient::isSubscribed(int32_t propId, int32_t areaId, SubscribeFlags flags) { auto it = mSubscriptions.find(propId); if (it == mSubscriptions.end()) { return false; } const SubscribeOptions& opts = it->second; bool res = (opts.flags & flags) && (opts.vehicleAreas == 0 || areaId == 0 || opts.vehicleAreas & areaId); bool res = (opts.flags & flags); return res; } Loading Loading @@ -139,8 +126,7 @@ std::list<HalClientValues> SubscriptionManager::distributeValuesToClients( MuxGuard g(mLock); for (const auto& propValue: propValues) { VehiclePropValue* v = propValue.get(); auto clients = getSubscribedClientsLocked( v->prop, v->areaId, flags); auto clients = getSubscribedClientsLocked(v->prop, flags); for (const auto& client : clients) { clientValuesMap[client].push_back(v); } Loading @@ -158,21 +144,21 @@ std::list<HalClientValues> SubscriptionManager::distributeValuesToClients( return clientValues; } std::list<sp<HalClient>> SubscriptionManager::getSubscribedClients( int32_t propId, int32_t area, SubscribeFlags flags) const { std::list<sp<HalClient>> SubscriptionManager::getSubscribedClients(int32_t propId, SubscribeFlags flags) const { MuxGuard g(mLock); return getSubscribedClientsLocked(propId, area, flags); return getSubscribedClientsLocked(propId, flags); } std::list<sp<HalClient>> SubscriptionManager::getSubscribedClientsLocked( int32_t propId, int32_t area, SubscribeFlags flags) const { int32_t propId, SubscribeFlags flags) const { std::list<sp<HalClient>> subscribedClients; sp<HalClientVector> propClients = getClientsForPropertyLocked(propId); if (propClients.get() != nullptr) { for (size_t i = 0; i < propClients->size(); i++) { const auto& client = propClients->itemAt(i); if (client->isSubscribed(propId, area, flags)) { if (client->isSubscribed(propId, flags)) { subscribedClients.push_back(client); } } Loading