DoorLockManager.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. *
  3. * Copyright (c) 2023 Project CHIP Authors
  4. * All rights reserved.
  5. *
  6. * Licensed under the Apache License, Version 2.0 (the "License");
  7. * you may not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. #pragma once
  19. #include <app-common/zap-generated/cluster-objects.h>
  20. #include <app/clusters/door-lock-server/door-lock-server.h>
  21. #include <app/util/attribute-storage.h>
  22. #include <jni.h>
  23. /**
  24. * @brief Handles interfacing between java code and C++ code for the purposes of DoorLock clusters.
  25. */
  26. class DoorLockManager
  27. {
  28. public:
  29. // installed a bridege for a DoorLock cluster endpoint and java object
  30. static void NewManager(jint endpoint, jobject manager);
  31. // helps for java to set attributes::LockType of DoorLock cluster
  32. static jboolean SetLockType(jint endpoint, jint value);
  33. // helps for java to set attributes::LockState of DoorLock cluster
  34. static jboolean SetLockState(jint endpoint, jint value);
  35. // helps for java to set attributes::ActuatorEnabled of DoorLock cluster
  36. static jboolean SetActuatorEnabled(jint endpoint, jboolean value);
  37. // helps for java to set attributes::AutoRelockTime of DoorLock cluster
  38. static jboolean SetAutoRelockTime(jint endpoint, jint value);
  39. // helps for java to set attributes::OperatingMode of DoorLock cluster
  40. static jboolean SetOperatingMode(jint endpoint, jint value);
  41. // helps for java to set attributes::SupportedOperatingMode of DoorLock cluster
  42. static jboolean SetSupportedOperatingModes(jint endpoint, jint value);
  43. // helps for java to send LockAlarmEvent of DoorLock cluster
  44. static jboolean SendLockAlarmEvent(jint endpoint);
  45. // posts a LockStateChanged event to suitable DoorLockManager
  46. static void PostLockStateChanged(chip::EndpointId endpoint, int value);
  47. // handles `Changed` callbacks by calling the java `void HandleLockStateChanged()` method
  48. void HandleLockStateChanged(int endpoint, int value);
  49. private:
  50. // init with java objects
  51. CHIP_ERROR InitializeWithObjects(jobject managerObject);
  52. jobject mDoorLockManagerObject = nullptr;
  53. jmethodID mHandleLockStateChangedMethod = nullptr;
  54. };