1 /* 2 * Copyright (C) 2021 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 OHOS_USIM_OPERATOR_PRIVILEGE_CONTROLLER_H 17 #define OHOS_USIM_OPERATOR_PRIVILEGE_CONTROLLER_H 18 19 #include <atomic> 20 #include <string_view> 21 22 #include "i_tel_ril_manager.h" 23 #include "icc_operator_rule.h" 24 #include "sim_state_manager.h" 25 #include "tel_event_handler.h" 26 27 namespace OHOS { 28 namespace Telephony { 29 class IccOperatorPrivilegeController : public TelEventHandler { 30 public: 31 enum : uint32_t { 32 MSG_OPEN_LOGICAL_CHANNEL_DONE = 0x7ffffff0, 33 MSG_TRANSMIT_LOGICAL_CHANNEL_DONE = 0x7ffffff1, 34 MSG_CLOSE_LOGICAL_CHANNEL_DONE = 0x7ffffff2 35 }; 36 37 explicit IccOperatorPrivilegeController( 38 std::shared_ptr<Telephony::ITelRilManager> telRilManager, std::shared_ptr<SimStateManager> simStateManager); 39 40 virtual ~IccOperatorPrivilegeController(); 41 42 void Init(const int32_t slotId); 43 int32_t HasOperatorPrivileges(bool &hasOperatorPrivileges); 44 int32_t HasOperatorPrivileges( 45 const std::string_view &certHash, const std::string_view &packageName, bool &hasOperatorPrivileges); 46 47 protected: 48 void ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event) override; 49 virtual void ProcessSimStateChanged(); 50 virtual void ProcessOpenLogicalChannelDone(const AppExecFwk::InnerEvent::Pointer &event); 51 virtual void ProcessTransmitLogicalChannelDone(const AppExecFwk::InnerEvent::Pointer &event); 52 virtual void ProcessCloseLogicalChannelDone(); 53 54 private: 55 void OpenChannel(); 56 57 private: 58 int32_t slotId_; 59 std::shared_ptr<Telephony::ITelRilManager> telRilManager_; 60 std::shared_ptr<SimStateManager> simStateManager_; 61 std::vector<IccOperatorRule> rules_; 62 63 class LogicalStateMachine; 64 LogicalStateMachine *const state_; 65 }; 66 } // namespace Telephony 67 } // namespace OHOS 68 #endif 69