-
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.
- Loading branch information
Showing
20 changed files
with
478 additions
and
20 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* | ||
* Copyright (c) 2020-2023 Project CHIP Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
#include <jni.h> | ||
|
||
#include "AndroidCallbacks.h" | ||
#include "lib/support/CHIPMem.h" | ||
#include "lib/support/CodeUtils.h" | ||
#include "lib/support/logging/CHIPLogging.h" | ||
#include "messaging/tests/MessagingContext.h" | ||
|
||
#define JNI_METHOD(RETURN, CLASS_NAME, METHOD_NAME) \ | ||
extern "C" JNIEXPORT RETURN JNICALL Java_chip_devicecontroller_##CLASS_NAME##_##METHOD_NAME | ||
|
||
using namespace chip; | ||
using namespace chip::Controller; | ||
using namespace chip::Test; | ||
|
||
JNI_METHOD(void, GetConnectedDeviceCallbackForTestJni, onDeviceConnected) | ||
(JNIEnv * env, jobject self, jlong callbackHandle, jlong messagingContextHandle) | ||
{ | ||
GetConnectedDeviceCallback * connectedDeviceCallback = reinterpret_cast<GetConnectedDeviceCallback *>(callbackHandle); | ||
VerifyOrReturn(connectedDeviceCallback != nullptr, ChipLogError(Controller, "GetConnectedDeviceCallbackJni handle is nullptr")); | ||
|
||
MessagingContext * messagingContext = reinterpret_cast<MessagingContext *>(messagingContextHandle); | ||
VerifyOrReturn(messagingContext != nullptr, ChipLogError(Controller, "MessagingContext handle is nullptr")); | ||
|
||
GetConnectedDeviceCallback::OnDeviceConnectedFn(connectedDeviceCallback, messagingContext->GetExchangeManager(), | ||
messagingContext->GetSessionBobToAlice()); | ||
} | ||
|
||
JNI_METHOD(void, GetConnectedDeviceCallbackForTestJni, onDeviceConnectionFailure) | ||
(JNIEnv * env, jobject self, jlong callbackHandle, jint errorCode) | ||
{ | ||
GetConnectedDeviceCallback * connectedDeviceCallback = reinterpret_cast<GetConnectedDeviceCallback *>(callbackHandle); | ||
VerifyOrReturn(connectedDeviceCallback != nullptr, ChipLogError(Controller, "GetConnectedDeviceCallbackJni handle is nullptr")); | ||
|
||
GetConnectedDeviceCallback::OnDeviceConnectionFailureFn(connectedDeviceCallback, ScopedNodeId(), chip::ChipError(errorCode)); | ||
} |
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
45 changes: 45 additions & 0 deletions
45
src/controller/java/src/chip/devicecontroller/GetConnectedDeviceCallbackForTestJni.java
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,45 @@ | ||
/* | ||
* Copyright (c) 2020-2023 Project CHIP Authors | ||
* All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
package chip.devicecontroller; | ||
|
||
import chip.testing.MessagingContext; | ||
|
||
/** Utilities for unit testing {@link GetConnectedDeviceCallbackJni}. */ | ||
public final class GetConnectedDeviceCallbackForTestJni { | ||
private final MessagingContext messagingContext; | ||
|
||
static { | ||
System.loadLibrary("CHIPForTestController"); | ||
} | ||
|
||
public GetConnectedDeviceCallbackForTestJni(MessagingContext messagingContext) { | ||
this.messagingContext = messagingContext; | ||
} | ||
|
||
public void onDeviceConnected(GetConnectedDeviceCallbackJni callback) { | ||
onDeviceConnected(callback.getCallbackHandle(), messagingContext.getMessagingContextHandle()); | ||
} | ||
|
||
private native void onDeviceConnected(long callbackHandle, long messagingContextHandle); | ||
|
||
public void onDeviceConnectionFailure(GetConnectedDeviceCallbackJni callback, int errorCode) { | ||
onDeviceConnectionFailure(callback.getCallbackHandle(), errorCode); | ||
} | ||
|
||
private native void onDeviceConnectionFailure(long callbackHandle, int errorCode); | ||
} |
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.