• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 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_IMS_CORE_SERVICE_CLIENT_H
17 #define TELEPHONY_IMS_CORE_SERVICE_CLIENT_H
18 
19 #include "singleton.h"
20 #include "rwlock.h"
21 #include "ims_core_service_interface.h"
22 #include "event_handler.h"
23 #include "radio_event.h"
24 #include "event_runner.h"
25 #include "iremote_stub.h"
26 #include "system_ability_status_change_stub.h"
27 
28 namespace OHOS {
29 namespace Telephony {
30 class ImsCoreServiceClient {
31     DECLARE_DELAYED_SINGLETON(ImsCoreServiceClient);
32 
33 public:
34     void Init();
35     void UnInit();
36     int32_t RegisterImsCoreServiceCallbackHandler(
37         int32_t slotId, const std::shared_ptr<AppExecFwk::EventHandler> &handler);
38     std::shared_ptr<AppExecFwk::EventHandler> GetHandler(int32_t slotId);
39     int32_t GetImsRegistrationStatus(int32_t slotId);
40 
41 public:
42     sptr<ImsCoreServiceInterface> GetImsCoreServiceProxy();
43 
44 private:
45     class SystemAbilityListener : public SystemAbilityStatusChangeStub {
46     public:
SystemAbilityListener()47         SystemAbilityListener() {}
~SystemAbilityListener()48         ~SystemAbilityListener() {}
49     public:
50         void OnAddSystemAbility(int32_t systemAbilityId, const std::string& deviceId) override;
51         void OnRemoveSystemAbility(int32_t systemAbilityId, const std::string& deviceId) override;
52     };
53 
54 private:
55     bool IsConnect() const;
56     int32_t RegisterImsCoreServiceCallback();
57     int32_t ReConnectService();
58     void Clean();
59 
60 private:
61     std::mutex mutex_;
62     sptr<ImsCoreServiceInterface> imsCoreServiceProxy_ = nullptr;
63     sptr<ImsCoreServiceCallbackInterface> imsCoreServiceCallback_ = nullptr;
64     std::map<int32_t, std::shared_ptr<AppExecFwk::EventHandler>> handlerMap_;
65     Utils::RWLock rwClientLock_;
66     sptr<ISystemAbilityStatusChange> statusChangeListener_ = nullptr;
67 };
68 } // namespace Telephony
69 } // namespace OHOS
70 #endif // TELEPHONY_IMS_CORE_SERVICE_CLIENT_H
71