From 2b8b008053fd84992ac397480a1a2208474dd2fd Mon Sep 17 00:00:00 2001 From: Sharad Binjola <31142146+sharadb-amazon@users.noreply.github.com> Date: Wed, 22 Jun 2022 23:37:11 -0700 Subject: [PATCH] Fixing issues with running the iOS TvCasting app on physical iPhones (#19868) --- .../MatterBridge/CastingServerBridge.mm | 20 ++++++++++++++-- .../TvCasting.xcodeproj/project.pbxproj | 8 +++++++ .../darwin/TvCasting/TvCasting/Info.plist | 23 +++++++++++++++++++ .../tv-casting-app/tv-casting-common/BUILD.gn | 5 +++- .../include/CHIPProjectAppConfig.h | 2 ++ 5 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 examples/tv-casting-app/darwin/TvCasting/TvCasting/Info.plist diff --git a/examples/tv-casting-app/darwin/TvCasting/MatterBridge/CastingServerBridge.mm b/examples/tv-casting-app/darwin/TvCasting/MatterBridge/CastingServerBridge.mm index 3c870da50313c9..d523d991d3c8a0 100644 --- a/examples/tv-casting-app/darwin/TvCasting/MatterBridge/CastingServerBridge.mm +++ b/examples/tv-casting-app/darwin/TvCasting/MatterBridge/CastingServerBridge.mm @@ -20,6 +20,10 @@ #import "DiscoveredNodeDataConverter.hpp" +#include +#include +#include +#include #include #include @@ -57,6 +61,16 @@ - (instancetype)init return nil; } + // Initialize device attestation config + SetDeviceAttestationCredentialsProvider(chip::Credentials::Examples::GetExampleDACProvider()); + + // Initialize device attestation verifier from a constant version + { + // TODO: Replace testingRootStore with a AttestationTrustStore that has the necessary official PAA roots available + const chip::Credentials::AttestationTrustStore * testingRootStore = chip::Credentials::GetTestAttestationTrustStore(); + SetDeviceAttestationVerifier(GetDefaultDACVerifier(testingRootStore)); + } + // init app Server static chip::CommonCaseDeviceServerInitParams initParams; err = initParams.InitializeStaticResourcesBeforeServerInit(); @@ -161,9 +175,10 @@ - (void)openBasicCommissioningWindow:(nullable void (^)(bool))commissioningCompl { ChipLogProgress(AppServer, "CastingServerBridge().openBasicCommissioningWindow() called"); + _commissioningCompleteCallback = commissioningCompleteCallback; dispatch_async(_chipWorkQueue, ^{ CHIP_ERROR err = CastingServer::GetInstance()->OpenBasicCommissioningWindow( - [&commissioningCompleteCallback](CHIP_ERROR err) { commissioningCompleteCallback(CHIP_NO_ERROR == err); }); + [](CHIP_ERROR err) { [CastingServerBridge getSharedInstance].commissioningCompleteCallback(CHIP_NO_ERROR == err); }); dispatch_async(clientQueue, ^{ commissioningWindowRequestedHandler(CHIP_NO_ERROR == err); @@ -179,10 +194,11 @@ - (void)contentLauncherLaunchUrl:(NSString * _Nonnull)contentUrl { ChipLogProgress(AppServer, "CastingServerBridge().contentLauncherLaunchUrl() called"); + _launchUrlResponseCallback = launchUrlResponseCallback; dispatch_async(_chipWorkQueue, ^{ CHIP_ERROR err = CastingServer::GetInstance()->ContentLauncherLaunchURL([contentUrl UTF8String], [contentDisplayStr UTF8String], - [&launchUrlResponseCallback](CHIP_ERROR err) { launchUrlResponseCallback(CHIP_NO_ERROR == err); }); + [](CHIP_ERROR err) { [CastingServerBridge getSharedInstance].launchUrlResponseCallback(CHIP_NO_ERROR == err); }); dispatch_async(clientQueue, ^{ launchUrlRequestSentHandler(CHIP_NO_ERROR == err); }); diff --git a/examples/tv-casting-app/darwin/TvCasting/TvCasting.xcodeproj/project.pbxproj b/examples/tv-casting-app/darwin/TvCasting/TvCasting.xcodeproj/project.pbxproj index b03976f499ccd2..22dccecf8e6e0d 100644 --- a/examples/tv-casting-app/darwin/TvCasting/TvCasting.xcodeproj/project.pbxproj +++ b/examples/tv-casting-app/darwin/TvCasting/TvCasting.xcodeproj/project.pbxproj @@ -390,6 +390,7 @@ GCC_PREPROCESSOR_DEFINITIONS = ( CHIP_HAVE_CONFIG_H, "CHIP_ADDRESS_RESOLVE_IMPL_INCLUDE_HEADER=", + "CHIP_CONFIG_KVS_PATH=\"chip_casting_kvs\"", "DEBUG=1", "$(inherited)", ); @@ -410,9 +411,12 @@ "$(CHIP_ROOT)/zzz_generated/app-common", "$(CHIP_ROOT)/zzz_generated/controller-clusters", ); + INFOPLIST_FILE = TvCasting/Info.plist; INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchScreen_Generation = YES; + INFOPLIST_KEY_UIRequiredDeviceCapabilities = armv7; + INFOPLIST_KEY_UISupportedInterfaceOrientations = UIInterfaceOrientationPortrait; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; LD_RUNPATH_SEARCH_PATHS = ( @@ -477,6 +481,7 @@ GCC_PREPROCESSOR_DEFINITIONS = ( CHIP_HAVE_CONFIG_H, "CHIP_ADDRESS_RESOLVE_IMPL_INCLUDE_HEADER=", + "CHIP_CONFIG_KVS_PATH=\"chip_casting_kvs\"", "$(inherited)", ); GENERATE_INFOPLIST_FILE = YES; @@ -496,9 +501,12 @@ "$(CHIP_ROOT)/zzz_generated/app-common", "$(CHIP_ROOT)/zzz_generated/controller-clusters", ); + INFOPLIST_FILE = TvCasting/Info.plist; INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchScreen_Generation = YES; + INFOPLIST_KEY_UIRequiredDeviceCapabilities = armv7; + INFOPLIST_KEY_UISupportedInterfaceOrientations = UIInterfaceOrientationPortrait; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; LD_RUNPATH_SEARCH_PATHS = ( diff --git a/examples/tv-casting-app/darwin/TvCasting/TvCasting/Info.plist b/examples/tv-casting-app/darwin/TvCasting/TvCasting/Info.plist new file mode 100644 index 00000000000000..858e110f19e0ff --- /dev/null +++ b/examples/tv-casting-app/darwin/TvCasting/TvCasting/Info.plist @@ -0,0 +1,23 @@ + + + + + CFBundleURLTypes + + + CFBundleURLName + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleURLSchemes + + mt + + + + NSBonjourServices + + _matter._tcp + _matterc._udp + _matterd._udp + + + diff --git a/examples/tv-casting-app/tv-casting-common/BUILD.gn b/examples/tv-casting-app/tv-casting-common/BUILD.gn index fc3135ab8d263a..ac4e85fb3f06a7 100644 --- a/examples/tv-casting-app/tv-casting-common/BUILD.gn +++ b/examples/tv-casting-app/tv-casting-common/BUILD.gn @@ -74,7 +74,10 @@ chip_data_model("tv-casting-common") { } static_library("tvCastingCommon") { - public_deps = [ "${chip_root}/examples/tv-casting-app/tv-casting-common" ] + public_deps = [ + "${chip_root}/examples/tv-casting-app/tv-casting-common", + "${chip_root}/src/credentials:default_attestation_verifier", + ] cflags = [ "-Wconversion" ] diff --git a/examples/tv-casting-app/tv-casting-common/include/CHIPProjectAppConfig.h b/examples/tv-casting-app/tv-casting-common/include/CHIPProjectAppConfig.h index 999e1236e0ff4e..bc50cb335e274f 100644 --- a/examples/tv-casting-app/tv-casting-common/include/CHIPProjectAppConfig.h +++ b/examples/tv-casting-app/tv-casting-common/include/CHIPProjectAppConfig.h @@ -29,7 +29,9 @@ // include the CHIPProjectConfig from config/standalone +#ifndef CHIP_CONFIG_KVS_PATH #define CHIP_CONFIG_KVS_PATH "/tmp/chip_casting_kvs" +#endif #include