MyUserPrompterResolver-JNI.cpp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. *
  3. * Copyright (c) 2022 Project CHIP Authors
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. #include "MyUserPrompterResolver-JNI.h"
  18. #include "TvApp-JNI.h"
  19. #include <jni.h>
  20. #include <lib/core/CHIPError.h>
  21. #include <lib/support/CHIPJNIError.h>
  22. #include <lib/support/JniReferences.h>
  23. #include <lib/support/JniTypeWrappers.h>
  24. using namespace chip;
  25. #define JNI_METHOD(RETURN, METHOD_NAME) \
  26. extern "C" JNIEXPORT RETURN JNICALL Java_com_matter_tv_server_tvapp_UserPrompterResolver_##METHOD_NAME
  27. JNI_METHOD(void, OnPinCodeEntered)(JNIEnv *, jobject, jint jPinCode)
  28. {
  29. #if CHIP_DEVICE_CONFIG_ENABLE_BOTH_COMMISSIONER_AND_COMMISSIONEE
  30. chip::DeviceLayer::StackLock lock;
  31. uint32_t pinCode = (uint32_t) jPinCode;
  32. ChipLogProgress(Zcl, "OnPinCodeEntered %d", pinCode);
  33. GetCommissionerDiscoveryController()->CommissionWithPincode(pinCode);
  34. #endif
  35. }
  36. JNI_METHOD(void, OnPinCodeDeclined)(JNIEnv *, jobject)
  37. {
  38. #if CHIP_DEVICE_CONFIG_ENABLE_BOTH_COMMISSIONER_AND_COMMISSIONEE
  39. chip::DeviceLayer::StackLock lock;
  40. ChipLogProgress(Zcl, "OnPinCodeDeclined");
  41. GetCommissionerDiscoveryController()->Cancel();
  42. #endif
  43. }
  44. JNI_METHOD(void, OnPromptAccepted)(JNIEnv *, jobject)
  45. {
  46. #if CHIP_DEVICE_CONFIG_ENABLE_BOTH_COMMISSIONER_AND_COMMISSIONEE
  47. chip::DeviceLayer::StackLock lock;
  48. ChipLogProgress(Zcl, "OnPromptAccepted");
  49. GetCommissionerDiscoveryController()->Ok();
  50. #endif
  51. }
  52. JNI_METHOD(void, OnPromptDeclined)(JNIEnv *, jobject)
  53. {
  54. #if CHIP_DEVICE_CONFIG_ENABLE_BOTH_COMMISSIONER_AND_COMMISSIONEE
  55. chip::DeviceLayer::StackLock lock;
  56. ChipLogProgress(Zcl, "OnPromptDeclined");
  57. GetCommissionerDiscoveryController()->Cancel();
  58. #endif
  59. }