• 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 
26 namespace OHOS {
27 namespace Telephony {
28 class TelephonyStateRegistryStub : public IRemoteStub<ITelephonyStateNotify> {
29 public:
30     TelephonyStateRegistryStub();
31     ~TelephonyStateRegistryStub();
32 
33     int32_t OnRemoteRequest(
34         uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
35 
36     virtual int32_t RegisterStateChange(const sptr<TelephonyObserverBroker> &telephonyObserver, int32_t slotId,
37         uint32_t mask, const std::string &bundleName, bool notifyNow, pid_t pid) = 0;
38 
39     virtual int32_t UnregisterStateChange(int32_t slotId, uint32_t mask, pid_t pid) = 0;
40 
41 private:
42     int32_t ReadData(MessageParcel &data, MessageParcel &reply, sptr<TelephonyObserverBroker> &callback);
43     int32_t RegisterStateChange(const sptr<TelephonyObserverBroker> &telephonyObserver,
44         int32_t slotId, uint32_t mask, bool isUpdate) override;
45     int32_t UnregisterStateChange(int32_t slotId, uint32_t mask) override;
46     void parseSignalInfos(
47         MessageParcel &data, const int32_t size, std::vector<sptr<SignalInformation>> &result);
48 
49 private:
50     using TelephonyStateFunc = int32_t (TelephonyStateRegistryStub::*)(MessageParcel &data, MessageParcel &reply);
51 
52     int32_t OnUpdateCellInfo(MessageParcel &data, MessageParcel &reply);
53     int32_t OnUpdateCallState(MessageParcel &data, MessageParcel &reply);
54     int32_t OnUpdateCallStateForSlotId(MessageParcel &data, MessageParcel &reply);
55     int32_t OnUpdateSignalInfo(MessageParcel &data, MessageParcel &reply);
56     int32_t OnUpdateNetworkState(MessageParcel &data, MessageParcel &reply);
57     int32_t OnUpdateSimState(MessageParcel &data, MessageParcel &reply);
58     int32_t OnRegisterStateChange(MessageParcel &data, MessageParcel &reply);
59     int32_t OnUnregisterStateChange(MessageParcel &data, MessageParcel &reply);
60     int32_t OnUpdateCellularDataConnectState(MessageParcel &data, MessageParcel &reply);
61     int32_t OnUpdateCellularDataFlow(MessageParcel &data, MessageParcel &reply);
62 
63 private:
64     std::map<StateNotifyCode, TelephonyStateFunc> memberFuncMap_;
65 };
66 } // namespace Telephony
67 } // namespace OHOS
68 #endif // TELEPHONY_STATE_REGISTRY_STUB_H
69