1 /* 2 * Copyright (C) 2025-2025 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef INTEROPERABLE_DATA_CONTROLLER_H 17 #define INTEROPERABLE_DATA_CONTROLLER_H 18 19 #include "cJSON.h" 20 #include "call_base.h" 21 #include "i_interoperable_device_state_callback.h" 22 #include "session_adapter.h" 23 24 namespace OHOS { 25 namespace Telephony { 26 constexpr const char* DATA_TYPE = "dataType"; 27 constexpr const char* INTEROPERABLE_ITEM_MUTE = "mute"; 28 constexpr uint32_t INTEROPERABLE_MAX_RECV_DATA_LEN = 2048; 29 30 enum class InteroperableMsgType : int32_t { 31 DATA_TYPE_UNKNOWN = -1, 32 DATA_TYPE_MUTE_RINGER = 102, 33 DATA_TYPE_MUTE = 104, 34 }; 35 36 class InteroperableDataController : public IInteroperableDeviceStateCallback, public ISessionCallback { 37 public: 38 InteroperableDataController() = default; 39 ~InteroperableDataController() override = default; 40 void OnReceiveMsg(const char* data, uint32_t dataLen) override; 41 void SetMuted(bool isMute); 42 void MuteRinger(); 43 44 virtual void OnCallCreated(const sptr<CallBase> &call, const std::string &networkId) = 0; 45 virtual void OnCallDestroyed() = 0; 46 47 protected: 48 bool GetInt32Value(const cJSON *msg, const std::string &name, int32_t &value); 49 bool GetBoolValue(const cJSON *msg, const std::string &name, bool &value); 50 51 std::shared_ptr<SessionAdapter> session_{nullptr}; 52 53 private: 54 void HandleMuted(const cJSON *msg); 55 void HandleMuteRinger(); 56 std::string CreateMuteMsg(InteroperableMsgType msgType, bool isMute); 57 std::string CreateMuteRingerMsg(InteroperableMsgType msgType); 58 }; 59 } 60 } 61 #endif // INTEROPERABLE_DATA_CONTROLLER_H