Skip to content

Commit

Permalink
Addressing cliffamzn@ feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
sharadb-amazon committed Jul 27, 2023
1 parent 641215b commit b7ce31b
Showing 4 changed files with 66 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -121,7 +121,7 @@ private void beginCommissioning(
FailureCallback onConnectionFailure,
SuccessCallback<ContentApp> onNewOrUpdatedEndpoints) {
Log.d(TAG, "Running commissioning");
Object commissioningComplete =
MatterCallbackHandler commissioningCompleteCallback =
new MatterCallbackHandler() {
@Override
public void handle(MatterError error) {
@@ -161,12 +161,14 @@ public void handle(MatterError error) {
}
};

CommissioningCallbacks commissioningCallbacks = new CommissioningCallbacks();
commissioningCallbacks.setCommissioningComplete(commissioningComplete);
commissioningCallbacks.setSessionEstablishmentStarted(sessionEstablishmentStartedCallback);
commissioningCallbacks.setSessionEstablished(sessionEstablishedCallback);
commissioningCallbacks.setSessionEstablishmentError(sessionEstablishmentErrorCallback);
commissioningCallbacks.setSessionEstablishmentStopped(sessionEstablishmentStoppedCallback);
CommissioningCallbacks commissioningCallbacks =
new CommissioningCallbacks.Builder()
.commissioningComplete(commissioningCompleteCallback)
.sessionEstablishmentStarted(sessionEstablishmentStartedCallback)
.sessionEstablished(sessionEstablishedCallback)
.sessionEstablishmentError(sessionEstablishmentErrorCallback)
.sessionEstablishmentStopped(sessionEstablishmentStoppedCallback)
.build();

this.openCommissioningWindowSuccess =
tvCastingApp.openBasicCommissioningWindow(
Original file line number Diff line number Diff line change
@@ -46,43 +46,68 @@ public class CommissioningCallbacks {
/** This is called when the commissioning has been completed */
private Object commissioningComplete;

public SuccessCallback<Void> getSessionEstablishmentStarted() {
return sessionEstablishmentStarted;
private CommissioningCallbacks(Builder builder) {
this.sessionEstablishmentStarted = builder.sessionEstablishmentStarted;
this.sessionEstablished = builder.sessionEstablished;
this.sessionEstablishmentError = builder.sessionEstablishmentError;
this.sessionEstablishmentStopped = builder.sessionEstablishmentStopped;
this.commissioningComplete = builder.commissioningComplete;
}

public void setSessionEstablishmentStarted(SuccessCallback<Void> sessionEstablishmentStarted) {
this.sessionEstablishmentStarted = sessionEstablishmentStarted;
public SuccessCallback<Void> getSessionEstablishmentStarted() {
return sessionEstablishmentStarted;
}

public SuccessCallback<Void> getSessionEstablished() {
return sessionEstablished;
}

public void setSessionEstablished(SuccessCallback<Void> sessionEstablished) {
this.sessionEstablished = sessionEstablished;
}

public FailureCallback getSessionEstablishmentError() {
return sessionEstablishmentError;
}

public void setSessionEstablishmentError(FailureCallback sessionEstablishmentStopped) {
this.sessionEstablishmentError = sessionEstablishmentError;
}

public FailureCallback getSessionEstablishmentStopped() {
return sessionEstablishmentStopped;
}

public void setSessionEstablishmentStopped(FailureCallback sessionEstablishmentStopped) {
this.sessionEstablishmentStopped = sessionEstablishmentStopped;
}

public Object getCommissioningComplete() {
return commissioningComplete;
}

public void setCommissioningComplete(Object commissioningComplete) {
this.commissioningComplete = commissioningComplete;
public static class Builder {
private SuccessCallback<Void> sessionEstablishmentStarted;
private SuccessCallback<Void> sessionEstablished;
private FailureCallback sessionEstablishmentError;
private FailureCallback sessionEstablishmentStopped;
private Object commissioningComplete;

public Builder sessionEstablishmentStarted(SuccessCallback<Void> sessionEstablishmentStarted) {
this.sessionEstablishmentStarted = sessionEstablishmentStarted;
return this;
}

public Builder sessionEstablished(SuccessCallback<Void> sessionEstablished) {
this.sessionEstablished = sessionEstablished;
return this;
}

public Builder sessionEstablishmentError(FailureCallback sessionEstablishmentError) {
this.sessionEstablishmentError = sessionEstablishmentError;
return this;
}

public Builder sessionEstablishmentStopped(FailureCallback sessionEstablishmentStopped) {
this.sessionEstablishmentStopped = sessionEstablishmentStopped;
return this;
}

public Builder commissioningComplete(Object commissioningComplete) {
this.commissioningComplete = commissioningComplete;
return this;
}

public CommissioningCallbacks build() {
return new CommissioningCallbacks(this);
}
}
}
Original file line number Diff line number Diff line change
@@ -108,14 +108,24 @@ class SessionEstablishmentStartedHandlerJNI : public SuccessHandlerJNI<void *>
{
public:
SessionEstablishmentStartedHandlerJNI() : SuccessHandlerJNI("(Ljava/lang/Object;)V") {}
jobject ConvertToJObject(void * responseData) { return nullptr; }
jobject ConvertToJObject(void * responseData)
{
// return nullptr because the Java callback extends SuccessCallback<Void> and its handle() expects a Void param.
// It expects a Void becauase no value is passed as part of this callback.
return nullptr;
}
};

class SessionEstablishedHandlerJNI : public SuccessHandlerJNI<void *>
{
public:
SessionEstablishedHandlerJNI() : SuccessHandlerJNI("(Ljava/lang/Object;)V") {}
jobject ConvertToJObject(void * responseData) { return nullptr; }
jobject ConvertToJObject(void * responseData)
{
// return nullptr because the Java callback extends SuccessCallback<Void> and its handle() expects a Void param.
// It expects a Void becauase no value is passed as part of this callback.
return nullptr;
}
};

class OnConnectionSuccessHandlerJNI : public SuccessHandlerJNI<TargetVideoPlayerInfo *>
Original file line number Diff line number Diff line change
@@ -110,14 +110,14 @@
@param clientQueue Queue to dispatch the call to the commissioningWindowRequestedHandler on
@param commissioningCallbackHandlers Optional parameter to specific handlers for callbacks during commissioning
@param onConnectionSuccessCallback Handles a VideoPlayer * once connection is successfully established
@param onConnectionFailureCallback Handles MatterError if there is a failure in establishing connection
@param onNewOrUpdatedEndpointCallback Handles a ContentApp * for each new ContentApp is found. May be called multiple times based
on the number of ContentApp
@param commissioningCallbackHandlers Optional parameter to specific handlers for callbacks during commissioning
*/
- (void)openBasicCommissioningWindow:(dispatch_queue_t _Nonnull)clientQueue
commissioningCallbackHandlers:(CommissioningCallbackHandlers * _Nullable)commissioningCallbackHandlers

0 comments on commit b7ce31b

Please sign in to comment.