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 TELEPHONY_OBSERVER_H 17 #define TELEPHONY_OBSERVER_H 18 19 #include <cstdint> 20 #include <string> 21 #include <vector> 22 23 #include "iremote_stub.h" 24 25 #include "telephony_observer_broker.h" 26 27 namespace OHOS { 28 namespace Telephony { 29 class TelephonyObserver : public IRemoteStub<TelephonyObserverBroker> { 30 public: TelephonyObserver()31 TelephonyObserver() {} ~TelephonyObserver()32 ~TelephonyObserver() {} 33 void OnCallStateUpdated( 34 int32_t slotId, int32_t callState, const std::u16string &phoneNumber) override; 35 void OnSignalInfoUpdated( 36 int32_t slotId, const std::vector<sptr<SignalInformation>> &vec) override; 37 void OnNetworkStateUpdated( 38 int32_t slotId, const sptr<NetworkState> &networkState) override; 39 void OnCellInfoUpdated( 40 int32_t slotId, const std::vector<sptr<CellInformation>> &vec) override; 41 void OnSimStateUpdated( 42 int32_t slotId, CardType type, SimState state, LockReason reason) override; 43 void OnCellularDataConnectStateUpdated( 44 int32_t slotId, int32_t dataState, int32_t networkType) override; 45 void OnCellularDataFlowUpdated( 46 int32_t slotId, int32_t dataFlowType) override; 47 int32_t OnRemoteRequest( 48 uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; 49 50 private: 51 void ConvertSignalInfoList(MessageParcel &data, std::vector<sptr<SignalInformation>> &signalInfos); 52 void ConvertCellInfoList(MessageParcel &data, std::vector<sptr<CellInformation>> &cells); 53 void OnCallStateUpdatedInner(MessageParcel &data, MessageParcel &reply); 54 void OnSignalInfoUpdatedInner(MessageParcel &data, MessageParcel &reply); 55 void OnNetworkStateUpdatedInner(MessageParcel &data, MessageParcel &reply); 56 void OnCellInfoUpdatedInner(MessageParcel &data, MessageParcel &reply); 57 void OnSimStateUpdatedInner(MessageParcel &data, MessageParcel &reply); 58 void OnCellularDataConnectStateUpdatedInner(MessageParcel &data, MessageParcel &reply); 59 void OnCellularDataFlowUpdatedInner(MessageParcel &data, MessageParcel &reply); 60 static constexpr int32_t CELL_NUM_MAX = 100; 61 static constexpr int32_t SIGNAL_NUM_MAX = 100; 62 }; 63 } // namespace Telephony 64 } // namespace OHOS 65 #endif // TELEPHONY_OBSERVER_H 66