Skip to content

Commit

Permalink
Chip tool fixes (#24420)
Browse files Browse the repository at this point in the history
* * Change various references of "SessionHandle &" to instead use "const SessionHandle &" to match how SessionHandle is often used as a parameter & to support rvalue
* Add Java/JNI hooks into for-test classes (like MessagingContext) to allow for unit tests of Java & JNI functionality
* Add first JNI unit test, GetConnectedDeviceCallbackJniTest, testing success/failure cases for device callback

* Restyled by whitespace

* Restyled by clang-format

* Restyled by gn

* * Fix a user-reported bug where we were seeing the following callstack:

JNIEnv::NewObject(_jclass*, _jmethodID*, ...)
chip::Controller::GetConnectedDeviceCallback::OnDeviceConnectionFailureFn(void*, chip::ScopedNodeId const&, chip::ChipError)
chip::OperationalSessionSetup::DequeueConnectionCallbacks(chip::ChipError)
chip::OperationalSessionSetup::OnNodeAddressResolutionFailed(chip::PeerId const&, chip::ChipError)
chip::AddressResolve::Impl::Resolver::HandleAction(chip::IntrusiveList<chip::AddressResolve::Impl::NodeLookupHandle, (chip::IntrusiveMode)0, chip::IntrusiveListBaseHook<chip::AddressResolve::Impl::NodeLookupHandle, (chip::IntrusiveMode)0> >::Iterator&)
chip::AddressResolve::Impl::Resolver::HandleTimer()
chip::System::LayerImplSelect::HandleEvents()

Though JNI tests were added to try to catch this at presubmit, those tests did not fail, which leads me to believe there's a difference in the JRE (wherein the version with the user-reported bug), a cast to an int is not being done, whereas in android emulator, the cast to int is done

* Add a README pointing to building android guide & specifying that these tests must be run externally due to android emulator dependency

* Fix path to android_building.md

* Restyled by clang-format

* Restyled by prettier-markdown

* Missed const correctness changes for SessionHandle&

* Restyled by clang-format

* More missed const correctness changes for SessionHandle&

* Restyled by clang-format

* More missed const correctness changes for SessionHandle&

* Restyled by clang-format

* Only build JNI test libs if chip_link_tests

* Restyled by gn

* Add missing tests.gni import

* Fixes to Java CHIPTool

* Match class name to file name

---------

Co-authored-by: Restyled.io <[email protected]>
Co-authored-by: Andrei Litvin <[email protected]>
  • Loading branch information
3 people authored and pull[bot] committed Nov 6, 2023
1 parent d4d6333 commit 3763347
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions examples/android/CHIPTool/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
xmlns:tools="http://schemas.android.com/tools"
package="com.google.chip.chiptool">

<uses-sdk android:minSdkVersion="28" />

<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import chip.platform.PreferencesKeyValueStoreManager
import com.google.chip.chiptool.attestation.ExampleAttestationTrustStoreDelegate
import kotlin.coroutines.resume
import kotlin.coroutines.resumeWithException
import kotlin.coroutines.suspendCoroutine
import kotlinx.coroutines.suspendCancellableCoroutine

/** Lazily instantiates [ChipDeviceController] and holds a reference to it. */
object ChipClient {
Expand Down Expand Up @@ -75,7 +75,7 @@ object ChipClient {
// once we are done with the returned device pointer. Memory leak was introduced since the refactor
// that introduced it was very large in order to fix a use after free, which was considered to be
// worse than the memory leak that was introduced.
return suspendCoroutine { continuation ->
return suspendCancellableCoroutine { continuation ->
getDeviceController(context).getConnectedDevicePointer(
nodeId,
object : GetConnectedDeviceCallback {
Expand Down

0 comments on commit 3763347

Please sign in to comment.