-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix java im sub crash * address comments When onDone is triggered from ShutdownSubscription API in android ui thread, RAII unlock in OnDone could cause context switch, then eventloop in matter would acquire the lock in matter thread, complete the work, switch back with the lock acquired from matter thread, then it delete readClient, and session, where it crash when it find the lock's thread id is different from ui thread. The fix is to move the stackUnlock after readClient delete operation. enable lock error detection
- Loading branch information
1 parent
bb403f0
commit 2876097
Showing
25 changed files
with
1,863 additions
and
1,521 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
...er/java/src/com/matter/controller/commands/pairing/PairOnNetworkLongImSubscribeCommand.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
package com.matter.controller.commands.pairing | ||
|
||
import chip.devicecontroller.ChipDeviceController | ||
import chip.devicecontroller.GetConnectedDeviceCallbackJni.GetConnectedDeviceCallback | ||
import chip.devicecontroller.ReportCallback | ||
import chip.devicecontroller.SubscriptionEstablishedCallback | ||
import chip.devicecontroller.ResubscriptionAttemptCallback | ||
import chip.devicecontroller.model.NodeState | ||
import chip.devicecontroller.model.ChipAttributePath | ||
import chip.devicecontroller.model.ChipEventPath | ||
import com.matter.controller.commands.common.CredentialsIssuer | ||
import java.util.Collections | ||
import java.util.logging.Level | ||
import java.util.logging.Logger | ||
|
||
class PairOnNetworkLongImSubscribeCommand( | ||
controller: ChipDeviceController, credsIssue: CredentialsIssuer? | ||
) : PairingCommand( | ||
controller, | ||
"onnetwork-long-im-subscribe", | ||
credsIssue, | ||
PairingModeType.ON_NETWORK, | ||
PairingNetworkType.NONE, | ||
DiscoveryFilterType.LONG_DISCRIMINATOR | ||
) { | ||
private var devicePointer: Long = 0 | ||
private var subscriptionId: Long = 0 | ||
|
||
private inner class InternalReportCallback : ReportCallback { | ||
override fun onError(attributePath: ChipAttributePath?, eventPath: ChipEventPath?, e: Exception) { | ||
logger.log(Level.INFO, "Subscribe receive onError") | ||
setFailure("write failure") | ||
} | ||
|
||
override fun onReport(nodeState: NodeState) { | ||
logger.log(Level.INFO, "Subscribe receve onReport") | ||
} | ||
} | ||
|
||
private inner class InternalGetConnectedDeviceCallback : GetConnectedDeviceCallback { | ||
override fun onDeviceConnected(devicePointer: Long) { | ||
this@PairOnNetworkLongImSubscribeCommand.devicePointer = devicePointer | ||
logger.log(Level.INFO, "onDeviceConnected") | ||
} | ||
|
||
override fun onConnectionFailure(nodeId: Long, error: Exception?) { | ||
logger.log(Level.INFO, "onConnectionFailure") | ||
} | ||
} | ||
|
||
private inner class InternalSubscriptionEstablishedCallback : SubscriptionEstablishedCallback { | ||
override fun onSubscriptionEstablished(subscriptionId: Long) { | ||
this@PairOnNetworkLongImSubscribeCommand.subscriptionId = subscriptionId | ||
logger.log(Level.INFO, "onSubscriptionEstablished with Id" + subscriptionId) | ||
setSuccess() | ||
} | ||
} | ||
|
||
private inner class InternalResubscriptionAttemptCallback : ResubscriptionAttemptCallback { | ||
override fun onResubscriptionAttempt(terminationCause: Int, nextResubscribeIntervalMsec: Int) { | ||
logger.log(Level.INFO, "ResubscriptionAttemptCallback"); | ||
} | ||
} | ||
|
||
override fun runCommand() { | ||
val attributePathList = listOf(ChipAttributePath.newInstance( | ||
/* endpointId= */ 0, CLUSTER_ID_BASIC, ATTR_ID_LOCAL_CONFIG_DISABLED)) | ||
|
||
currentCommissioner() | ||
.pairDeviceWithAddress( | ||
getNodeId(), | ||
getRemoteAddr().getHostAddress(), | ||
MATTER_PORT, | ||
getDiscriminator(), | ||
getSetupPINCode(), | ||
null | ||
) | ||
currentCommissioner().setCompletionListener(this) | ||
waitCompleteMs(getTimeoutMillis()) | ||
currentCommissioner() | ||
.getConnectedDevicePointer(getNodeId(), InternalGetConnectedDeviceCallback()) | ||
clear() | ||
currentCommissioner() | ||
.subscribeToPath(InternalSubscriptionEstablishedCallback(), InternalResubscriptionAttemptCallback(), InternalReportCallback(), devicePointer, attributePathList, Collections.emptyList(), 0, 5, false, false) | ||
waitCompleteMs(getTimeoutMillis()) | ||
currentCommissioner().shutdownSubscriptions(currentCommissioner().getFabricIndex(), getNodeId(), subscriptionId); | ||
} | ||
|
||
companion object { | ||
private val logger = Logger.getLogger( | ||
PairOnNetworkLongImSubscribeCommand::class.java.name | ||
) | ||
|
||
private const val MATTER_PORT = 5540 | ||
private const val CLUSTER_ID_BASIC = 0x0028L | ||
private const val ATTR_ID_LOCAL_CONFIG_DISABLED = 16L | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.