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