Skip to content

Commit

Permalink
tv-casting-app: Fixes for #24399 and #24400 (#24401)
Browse files Browse the repository at this point in the history
* iOS tv-casting-app: Re-init binding handlers in startMatterServer API

* tv-casting-app: Disconnecting from previous video player before connecting to the new one

* Moving SetRotatingDeviceIdUniqueId to preInitApp so it always happens before- Matter server is initialized
iOS tv-casting-app: Changed initApp to initializeApp and added return value

* Addressing andy31415@'s feedback
  • Loading branch information
sharadb-amazon authored and pull[bot] committed Jul 17, 2023
1 parent 2082d95 commit 4546128
Show file tree
Hide file tree
Showing 9 changed files with 181 additions and 307 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

initJni();
boolean ret = initJni();
if (!ret) {
Log.e(TAG, "Failed to initialize Matter TV casting library");
return;
}

Fragment fragment = CommissionerDiscoveryFragment.newInstance(tvCastingApp);
getSupportFragmentManager()
Expand Down Expand Up @@ -71,7 +75,7 @@ public void handleDisconnect() {
* AndroidChipPlatform to prepare platform, then start ChipAppServer, then call init on
* TvCastingApp
*/
private void initJni() {
private boolean initJni() {
tvCastingApp = new TvCastingApp();

Context applicationContext = this.getApplicationContext();
Expand All @@ -84,7 +88,7 @@ private void initJni() {
appParameters.setDacProvider(new DACProviderStub());
appParameters.setSetupPasscode(GlobalCastingConstants.SetupPasscode);
appParameters.setDiscriminator(GlobalCastingConstants.Discriminator);
tvCastingApp.initApp(applicationContext, appParameters);
return tvCastingApp.initApp(applicationContext, appParameters);
}

private void showFragment(Fragment fragment, boolean showOnBack) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,22 +65,41 @@ public boolean initApp(Context applicationContext, AppParameters appParameters)
new ChipMdnsCallbackImpl(),
new DiagnosticDataProviderImpl(applicationContext));

chipPlatform.updateCommissionableDataProviderData(
appParameters.getSpake2pVerifierBase64(),
appParameters.getSpake2pSaltBase64(),
appParameters.getSpake2pIterationCount(),
appParameters.getSetupPasscode(),
appParameters.getDiscriminator());
boolean ret =
chipPlatform.updateCommissionableDataProviderData(
appParameters.getSpake2pVerifierBase64(),
appParameters.getSpake2pSaltBase64(),
appParameters.getSpake2pIterationCount(),
appParameters.getSetupPasscode(),
appParameters.getDiscriminator());
if (!ret) {
Log.e(
TAG,
"TvCastingApp.initApp failed to updateCommissionableDataProviderData on chipPlatform");
return ret;
}

ret = preInitJni(appParameters);
if (!ret) {
Log.e(TAG, "TvCastingApp.initApp failed in preInitJni");
return ret;
}

chipAppServer = new ChipAppServer();
chipAppServer.startApp();
ret = chipAppServer.startApp();
if (!ret) {
Log.e(TAG, "TvCastingApp.initApp failed in start chipAppServer");
return ret;
}

setDACProvider(appParameters.getDacProvider());
return initJni(appParameters);
}

private native void setDACProvider(DACProvider provider);

private native boolean preInitJni(AppParameters appParameters);

private native boolean initJni(AppParameters appParameters);

public void discoverVideoPlayerCommissioners(
Expand Down
Loading

0 comments on commit 4546128

Please sign in to comment.