• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_STATE_REGISTRY_STUB_H
17 #define TELEPHONY_STATE_REGISTRY_STUB_H
18 
19 #include <map>
20 
21 #include "iremote_stub.h"
22 
23 #include "telephony_log_wrapper.h"
24 #include "i_telephony_state_notify.h"
25 #include "state_registry_ipc_interface_code.h"
26 
27 namespace OHOS {
28 namespace Telephony {
29 class TelephonyStateRegistryStub : public IRemoteStub<ITelephonyStateNotify> {
30 public:
31     TelephonyStateRegistryStub();
32     ~TelephonyStateRegistryStub();
33 
34     int32_t OnRemoteRequest(
35         uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
36 
37     virtual int32_t RegisterStateChange(const sptr<TelephonyObserverBroker> &telephonyObserver, int32_t slotId,
38         uint32_t mask, const std::string &bundleName, bool notifyNow, pid_t pid) = 0;
39 
40     virtual int32_t UnregisterStateChange(int32_t slotId, uint32_t mask, pid_t pid) = 0;
41 
42 private:
43     int32_t ReadData(MessageParcel &data, MessageParcel &reply, sptr<TelephonyObserverBroker> &callback);
44     int32_t RegisterStateChange(const sptr<TelephonyObserverBroker> &telephonyObserver,
45         int32_t slotId, uint32_t mask, bool isUpdate) override;
46     int32_t UnregisterStateChange(int32_t slotId, uint32_t mask) override;
47     void parseSignalInfos(
48         MessageParcel &data, const int32_t size, std::vector<sptr<SignalInformation>> &result);
49 
50 private:
51     using TelephonyStateFunc = int32_t (TelephonyStateRegistryStub::*)(MessageParcel &data, MessageParcel &reply);
52 
53     int32_t OnUpdateCellInfo(MessageParcel &data, MessageParcel &reply);
54     int32_t OnUpdateCallState(MessageParcel &data, MessageParcel &reply);
55     int32_t OnUpdateCallStateForSlotId(MessageParcel &data, MessageParcel &reply);
56     int32_t OnUpdateSignalInfo(MessageParcel &data, MessageParcel &reply);
57     int32_t OnUpdateNetworkState(MessageParcel &data, MessageParcel &reply);
58     int32_t OnUpdateSimState(MessageParcel &data, MessageParcel &reply);
59     int32_t OnRegisterStateChange(MessageParcel &data, MessageParcel &reply);
60     int32_t OnUnregisterStateChange(MessageParcel &data, MessageParcel &reply);
61     int32_t OnUpdateCellularDataConnectState(MessageParcel &data, MessageParcel &reply);
62     int32_t OnUpdateCellularDataFlow(MessageParcel &data, MessageParcel &reply);
63     int32_t OnUpdateCfuIndicator(MessageParcel &data, MessageParcel &reply);
64     int32_t OnUpdateVoiceMailMsgIndicator(MessageParcel &data, MessageParcel &reply);
65     int32_t OnIccAccountUpdated(MessageParcel &data, MessageParcel &reply);
66 
67 private:
68     std::map<StateNotifyInterfaceCode, TelephonyStateFunc> memberFuncMap_;
69 };
70 } // namespace Telephony
71 } // namespace OHOS
72 #endif // TELEPHONY_STATE_REGISTRY_STUB_H
73