From c05da3ffcb50b3bdde22a7013dfa89e7671234b4 Mon Sep 17 00:00:00 2001 From: Michael Rupp <95718139+mykrupp@users.noreply.github.com> Date: Wed, 7 Aug 2024 19:05:14 -0400 Subject: [PATCH 01/45] [Silabs] Use provision storage manager singleton in OTA factory data processor (#34822) * Use provision storage manager singleton * Restyled by clang-format * rekick ci --------- Co-authored-by: Restyled.io --- .../silabs/multi-ota/OTAFactoryDataProcessor.cpp | 11 +++++------ .../silabs/multi-ota/OTAFactoryDataProcessor.h | 4 ++-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/platform/silabs/multi-ota/OTAFactoryDataProcessor.cpp b/src/platform/silabs/multi-ota/OTAFactoryDataProcessor.cpp index 8d38207df35542..a39a39b8f3aa87 100644 --- a/src/platform/silabs/multi-ota/OTAFactoryDataProcessor.cpp +++ b/src/platform/silabs/multi-ota/OTAFactoryDataProcessor.cpp @@ -22,7 +22,7 @@ namespace chip { -using FactoryProvider = DeviceLayer::Silabs::Provision::Storage; +using namespace ::chip::DeviceLayer::Silabs; CHIP_ERROR OTAFactoryDataProcessor::Init() { @@ -146,21 +146,20 @@ CHIP_ERROR OTAFactoryDataProcessor::Update(uint8_t tag, Optional & opt CHIP_ERROR OTAFactoryDataProcessor::UpdateValue(uint8_t tag, ByteSpan & newValue) { - FactoryProvider factoryProvider; switch (tag) { case (int) FactoryTags::kDacKey: ChipLogProgress(SoftwareUpdate, "Set Device Attestation Key"); - return factoryProvider.FactoryProvider::SetDeviceAttestationKey(newValue); + return Provision::Manager::GetInstance().GetStorage().SetDeviceAttestationKey(newValue); case (int) FactoryTags::kDacCert: ChipLogProgress(SoftwareUpdate, "Set Device Attestation Cert"); - return factoryProvider.FactoryProvider::SetDeviceAttestationCert(newValue); + return Provision::Manager::GetInstance().GetStorage().SetDeviceAttestationCert(newValue); case (int) FactoryTags::kPaiCert: ChipLogProgress(SoftwareUpdate, "Set Product Attestionation Intermediate Cert"); - return factoryProvider.FactoryProvider::SetProductAttestationIntermediateCert(newValue); + return Provision::Manager::GetInstance().GetStorage().SetProductAttestationIntermediateCert(newValue); case (int) FactoryTags::kCdCert: ChipLogProgress(SoftwareUpdate, "Set Certification Declaration"); - return factoryProvider.FactoryProvider::SetCertificationDeclaration(newValue); + return Provision::Manager::GetInstance().GetStorage().SetCertificationDeclaration(newValue); } ChipLogError(DeviceLayer, "Failed to find tag %d.", tag); diff --git a/src/platform/silabs/multi-ota/OTAFactoryDataProcessor.h b/src/platform/silabs/multi-ota/OTAFactoryDataProcessor.h index f7fd106de17220..da325bbba16110 100644 --- a/src/platform/silabs/multi-ota/OTAFactoryDataProcessor.h +++ b/src/platform/silabs/multi-ota/OTAFactoryDataProcessor.h @@ -18,12 +18,12 @@ #pragma once +#include +#include #include #include #include #include -#include // nogncheck -#include // nogncheck namespace chip { From 78a8357130b995c53233410e409d70ef746afc5a Mon Sep 17 00:00:00 2001 From: Philip Gregor <147669098+pgregorr-amazon@users.noreply.github.com> Date: Wed, 7 Aug 2024 19:06:31 -0400 Subject: [PATCH 02/45] tv-casting-app fixed memory issues around stopDiscovery function (#34758) * tv-casting-app fixed memory issues around stopDiscovery function * Fixing style issues * Addressed comments by sharadb-amazon --- .../casting/ConnectionExampleFragment.java | 6 +- .../casting/DiscoveryExampleFragment.java | 14 +++-- .../res/layout/custom_passcode_dialog.xml | 3 +- .../fragment_matter_connection_example.xml | 33 +++++++---- .../tv-casting-common/core/CastingPlayer.cpp | 56 +++++++++++++------ .../tv-casting-common/core/CastingPlayer.h | 34 ++++++++++- .../core/CastingPlayerDiscovery.cpp | 37 +++++++++++- .../core/CastingPlayerDiscovery.h | 22 +++++++- .../support/CastingStore.cpp | 16 +++--- .../support/ChipDeviceEventHandler.cpp | 13 +++-- 10 files changed, 181 insertions(+), 53 deletions(-) diff --git a/examples/tv-casting-app/android/App/app/src/main/java/com/matter/casting/ConnectionExampleFragment.java b/examples/tv-casting-app/android/App/app/src/main/java/com/matter/casting/ConnectionExampleFragment.java index b61b63f3e0785e..5db9a3560749b5 100644 --- a/examples/tv-casting-app/android/App/app/src/main/java/com/matter/casting/ConnectionExampleFragment.java +++ b/examples/tv-casting-app/android/App/app/src/main/java/com/matter/casting/ConnectionExampleFragment.java @@ -160,13 +160,17 @@ public void handle(Void v) { Log.i( TAG, "Successfully connected to CastingPlayer with deviceId: " - + targetCastingPlayer.getDeviceId()); + + targetCastingPlayer.getDeviceId() + + ", useCommissionerGeneratedPasscode: " + + useCommissionerGeneratedPasscode); getActivity() .runOnUiThread( () -> { connectionFragmentStatusTextView.setText( "Successfully connected to Casting Player with device name: " + targetCastingPlayer.getDeviceName() + + "\n\nUsed CastingPlayer Passcode: " + + useCommissionerGeneratedPasscode + "\n\n"); connectionFragmentNextButton.setEnabled(true); }); diff --git a/examples/tv-casting-app/android/App/app/src/main/java/com/matter/casting/DiscoveryExampleFragment.java b/examples/tv-casting-app/android/App/app/src/main/java/com/matter/casting/DiscoveryExampleFragment.java index 3dca2320b8924c..64130fa94cfe7b 100644 --- a/examples/tv-casting-app/android/App/app/src/main/java/com/matter/casting/DiscoveryExampleFragment.java +++ b/examples/tv-casting-app/android/App/app/src/main/java/com/matter/casting/DiscoveryExampleFragment.java @@ -67,7 +67,8 @@ public class DiscoveryExampleFragment extends Fragment { public void onAdded(CastingPlayer castingPlayer) { Log.i( TAG, - "onAdded() Discovered CastingPlayer deviceId: " + castingPlayer.getDeviceId()); + "DiscoveryExampleFragment onAdded() Discovered CastingPlayer deviceId: " + + castingPlayer.getDeviceId()); // Display CastingPlayer info on the screen new Handler(Looper.getMainLooper()) .post( @@ -80,7 +81,7 @@ public void onAdded(CastingPlayer castingPlayer) { public void onChanged(CastingPlayer castingPlayer) { Log.i( TAG, - "onChanged() Discovered changes to CastingPlayer with deviceId: " + "DiscoveryExampleFragment onChanged() Discovered changes to CastingPlayer with deviceId: " + castingPlayer.getDeviceId()); // Update the CastingPlayer on the screen new Handler(Looper.getMainLooper()) @@ -107,7 +108,7 @@ public void onChanged(CastingPlayer castingPlayer) { public void onRemoved(CastingPlayer castingPlayer) { Log.i( TAG, - "onRemoved() Removed CastingPlayer with deviceId: " + "DiscoveryExampleFragment onRemoved() Removed CastingPlayer with deviceId: " + castingPlayer.getDeviceId()); // Remove CastingPlayer from the screen new Handler(Looper.getMainLooper()) @@ -215,7 +216,10 @@ public void onResume() { @Override public void onPause() { super.onPause(); - Log.i(TAG, "onPause() called"); + Log.i(TAG, "DiscoveryExampleFragment onPause() called, calling stopDiscovery()"); + // Stop discovery when leaving the fragment, for example, while displaying the + // ConnectionExampleFragment. + stopDiscovery(); } /** Interface for notifying the host. */ @@ -261,7 +265,7 @@ private boolean startDiscovery() { } private void stopDiscovery() { - Log.i(TAG, "stopDiscovery() called"); + Log.i(TAG, "DiscoveryExampleFragment stopDiscovery() called"); matterDiscoveryErrorMessageTextView.setText( getString(R.string.matter_discovery_error_message_initial)); diff --git a/examples/tv-casting-app/android/App/app/src/main/res/layout/custom_passcode_dialog.xml b/examples/tv-casting-app/android/App/app/src/main/res/layout/custom_passcode_dialog.xml index 1b868e06b71f29..c91fa4ad404089 100644 --- a/examples/tv-casting-app/android/App/app/src/main/res/layout/custom_passcode_dialog.xml +++ b/examples/tv-casting-app/android/App/app/src/main/res/layout/custom_passcode_dialog.xml @@ -1,5 +1,6 @@ @@ -11,7 +12,6 @@ android:textStyle="bold" android:textSize="18sp" android:padding="16dp" - android:textColor="@android:color/white" android:gravity="center" android:text="@string/matter_connection_input_dialog_title" /> @@ -24,7 +24,6 @@ android:paddingEnd="16dp" android:paddingTop="8dp" android:paddingBottom="8dp" - android:textColor="@android:color/white" android:text="@string/matter_connection_input_dialog_instructions" /> - - -