Skip to content

Commit 3c7c9b1

Browse files
wqx6bzbarsky-apple
andauthored
Add checks for localization-configuration cluster and time-format-localization cluster init callback (#32747)
* Add checks for localization-configuration cluster and time-format-localization cluster * Update src/app/clusters/time-format-localization-server/time-format-localization-server.cpp Co-authored-by: Boris Zbarsky <bzbarsky@apple.com> --------- Co-authored-by: Boris Zbarsky <bzbarsky@apple.com>
1 parent 90663db commit 3c7c9b1

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/app/clusters/localization-configuration-server/localization-configuration-server.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ void emberAfLocalizationConfigurationClusterServerInitCallback(EndpointId endpoi
208208

209209
it->Release();
210210

211-
if (err == CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND)
211+
if (err == CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND && validLocaleCached)
212212
{
213213
// If initial value is not one of the allowed values, write the valid value it.
214214
status = ActiveLocale::Set(endpoint, validLocale);

src/app/clusters/time-format-localization-server/time-format-localization-server.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@ class AutoReleaseIterator
7878

7979
TimeFormatLocalizationAttrAccess gAttrAccess;
8080

81+
bool HasFeature(EndpointId endpoint, Feature feature)
82+
{
83+
uint32_t featureMap;
84+
return FeatureMap::Get(endpoint, &featureMap) == Status::Success ? (featureMap & to_underlying(feature)) : false;
85+
}
86+
8187
CHIP_ERROR TimeFormatLocalizationAttrAccess::ReadSupportedCalendarTypes(AttributeValueEncoder & aEncoder)
8288
{
8389
DeviceLayer::DeviceInfoProvider * provider = DeviceLayer::GetDeviceInfoProvider();
@@ -202,6 +208,10 @@ Protocols::InteractionModel::Status MatterTimeFormatLocalizationClusterServerPre
202208

203209
void emberAfTimeFormatLocalizationClusterServerInitCallback(EndpointId endpoint)
204210
{
211+
if (!HasFeature(endpoint, Feature::kCalendarFormat))
212+
{
213+
return;
214+
}
205215
CalendarTypeEnum calendarType;
206216
CalendarTypeEnum validType;
207217
Status status = ActiveCalendarType::Get(endpoint, &calendarType);

0 commit comments

Comments
 (0)