15b8fca66Sopenharmony_ci/*
25b8fca66Sopenharmony_ci * Copyright (C) 2021 Huawei Device Co., Ltd.
35b8fca66Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
45b8fca66Sopenharmony_ci * you may not use this file except in compliance with the License.
55b8fca66Sopenharmony_ci * You may obtain a copy of the License at
65b8fca66Sopenharmony_ci *
75b8fca66Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
85b8fca66Sopenharmony_ci *
95b8fca66Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
105b8fca66Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
115b8fca66Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
125b8fca66Sopenharmony_ci * See the License for the specific language governing permissions and
135b8fca66Sopenharmony_ci * limitations under the License.
145b8fca66Sopenharmony_ci */
155b8fca66Sopenharmony_ci
165b8fca66Sopenharmony_ci#ifndef TELEPHONY_STATE_REGISTRY_STUB_H
175b8fca66Sopenharmony_ci#define TELEPHONY_STATE_REGISTRY_STUB_H
185b8fca66Sopenharmony_ci
195b8fca66Sopenharmony_ci#include <map>
205b8fca66Sopenharmony_ci
215b8fca66Sopenharmony_ci#include "iremote_stub.h"
225b8fca66Sopenharmony_ci
235b8fca66Sopenharmony_ci#include "telephony_log_wrapper.h"
245b8fca66Sopenharmony_ci#include "i_telephony_state_notify.h"
255b8fca66Sopenharmony_ci#include "state_registry_ipc_interface_code.h"
265b8fca66Sopenharmony_ci
275b8fca66Sopenharmony_cinamespace OHOS {
285b8fca66Sopenharmony_cinamespace Telephony {
295b8fca66Sopenharmony_ciclass TelephonyStateRegistryStub : public IRemoteStub<ITelephonyStateNotify> {
305b8fca66Sopenharmony_cipublic:
315b8fca66Sopenharmony_ci    TelephonyStateRegistryStub();
325b8fca66Sopenharmony_ci    ~TelephonyStateRegistryStub();
335b8fca66Sopenharmony_ci
345b8fca66Sopenharmony_ci    int32_t OnRemoteRequest(
355b8fca66Sopenharmony_ci        uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
365b8fca66Sopenharmony_ci
375b8fca66Sopenharmony_ci    virtual int32_t RegisterStateChange(const sptr<TelephonyObserverBroker> &telephonyObserver, int32_t slotId,
385b8fca66Sopenharmony_ci        uint32_t mask, const std::string &bundleName, bool notifyNow, pid_t pid, int32_t uid, int32_t tokenId) = 0;
395b8fca66Sopenharmony_ci
405b8fca66Sopenharmony_ci    virtual int32_t UnregisterStateChange(int32_t slotId, uint32_t mask, int32_t tokenId, pid_t pid) = 0;
415b8fca66Sopenharmony_ci
425b8fca66Sopenharmony_ciprivate:
435b8fca66Sopenharmony_ci    int32_t ReadData(MessageParcel &data, MessageParcel &reply, sptr<TelephonyObserverBroker> &callback);
445b8fca66Sopenharmony_ci    int32_t RegisterStateChange(const sptr<TelephonyObserverBroker> &telephonyObserver,
455b8fca66Sopenharmony_ci        int32_t slotId, uint32_t mask, bool isUpdate) override;
465b8fca66Sopenharmony_ci    int32_t UnregisterStateChange(int32_t slotId, uint32_t mask) override;
475b8fca66Sopenharmony_ci    void parseSignalInfos(
485b8fca66Sopenharmony_ci        MessageParcel &data, const int32_t size, std::vector<sptr<SignalInformation>> &result);
495b8fca66Sopenharmony_ci    void ParseLteNrSignalInfos(
505b8fca66Sopenharmony_ci        MessageParcel &data, std::vector<sptr<SignalInformation>> &result, SignalInformation::NetworkType type);
515b8fca66Sopenharmony_ci
525b8fca66Sopenharmony_ciprivate:
535b8fca66Sopenharmony_ci    using TelephonyStateFunc = std::function<int32_t(MessageParcel &data, MessageParcel &reply)>;
545b8fca66Sopenharmony_ci
555b8fca66Sopenharmony_ci    int32_t OnUpdateCellInfo(MessageParcel &data, MessageParcel &reply);
565b8fca66Sopenharmony_ci    int32_t OnUpdateCallState(MessageParcel &data, MessageParcel &reply);
575b8fca66Sopenharmony_ci    int32_t OnUpdateCallStateForSlotId(MessageParcel &data, MessageParcel &reply);
585b8fca66Sopenharmony_ci    int32_t OnUpdateSignalInfo(MessageParcel &data, MessageParcel &reply);
595b8fca66Sopenharmony_ci    int32_t OnUpdateNetworkState(MessageParcel &data, MessageParcel &reply);
605b8fca66Sopenharmony_ci    int32_t OnUpdateSimState(MessageParcel &data, MessageParcel &reply);
615b8fca66Sopenharmony_ci    int32_t OnRegisterStateChange(MessageParcel &data, MessageParcel &reply);
625b8fca66Sopenharmony_ci    int32_t OnUnregisterStateChange(MessageParcel &data, MessageParcel &reply);
635b8fca66Sopenharmony_ci    int32_t OnUpdateCellularDataConnectState(MessageParcel &data, MessageParcel &reply);
645b8fca66Sopenharmony_ci    int32_t OnUpdateCellularDataFlow(MessageParcel &data, MessageParcel &reply);
655b8fca66Sopenharmony_ci    int32_t OnUpdateCfuIndicator(MessageParcel &data, MessageParcel &reply);
665b8fca66Sopenharmony_ci    int32_t OnUpdateVoiceMailMsgIndicator(MessageParcel &data, MessageParcel &reply);
675b8fca66Sopenharmony_ci    int32_t OnIccAccountUpdated(MessageParcel &data, MessageParcel &reply);
685b8fca66Sopenharmony_ci    int32_t SetTimer(uint32_t code);
695b8fca66Sopenharmony_ci    void CancelTimer(int32_t id);
705b8fca66Sopenharmony_ci
715b8fca66Sopenharmony_ciprivate:
725b8fca66Sopenharmony_ci    std::map<StateNotifyInterfaceCode, TelephonyStateFunc> memberFuncMap_;
735b8fca66Sopenharmony_ci    std::map<uint32_t, std::string> collieCodeStringMap_ = {
745b8fca66Sopenharmony_ci        { uint32_t(StateNotifyInterfaceCode::ADD_OBSERVER), "ADD_OBSERVER" },
755b8fca66Sopenharmony_ci    };
765b8fca66Sopenharmony_ci};
775b8fca66Sopenharmony_ci} // namespace Telephony
785b8fca66Sopenharmony_ci} // namespace OHOS
795b8fca66Sopenharmony_ci#endif // TELEPHONY_STATE_REGISTRY_STUB_H
80