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 #include "dinput_sa_manager.h"
17 
18 #include "iservice_registry.h"
19 #include "system_ability_definition.h"
20 
21 #include "constants_dinput.h"
22 #include "distributed_input_source_manager.h"
23 #include "distributed_input_sink_manager.h"
24 #include "dinput_errcode.h"
25 #include "dinput_log.h"
26 
27 namespace OHOS {
28 namespace DistributedHardware {
29 namespace DistributedInput {
30 IMPLEMENT_SINGLE_INSTANCE(DInputSAManager);
31 
OnRemoveSystemAbility(int32_t systemAbilityId,const std::string & deviceId)32 void DInputSAManager::SystemAbilityListener::OnRemoveSystemAbility(int32_t systemAbilityId, const std::string &deviceId)
33 {}
34 
OnAddSystemAbility(int32_t systemAbilityId,const std::string & deviceId)35 void DInputSAManager::SystemAbilityListener::OnAddSystemAbility(int32_t systemAbilityId, const std::string &deviceId)
36 {}
37 
Init()38 void DInputSAManager::Init()
39 {}
40 
RegisterEventHandler(std::shared_ptr<AppExecFwk::EventHandler> handler)41 void DInputSAManager::RegisterEventHandler(std::shared_ptr<AppExecFwk::EventHandler> handler)
42 {
43     eventHandler_ = handler;
44 }
45 
GetDInputSourceProxy()46 bool DInputSAManager::GetDInputSourceProxy()
47 {
48     int32_t saId = 4809;
49     bool runOnCreate = false;
50 
51     if (dInputSourceProxy_ == nullptr) {
52         dInputSourceProxy_ = new DistributedInputSourceManager(saId, runOnCreate);
53     }
54     return dInputSourceProxy_ != nullptr;
55 }
56 
HasDInputSourceProxy()57 bool DInputSAManager::HasDInputSourceProxy()
58 {
59     return dInputSourceProxy_ != nullptr;
60 }
61 
SetDInputSourceProxy(const sptr<IRemoteObject> & remoteObject)62 bool DInputSAManager::SetDInputSourceProxy(const sptr<IRemoteObject> &remoteObject)
63 {
64     dInputSourceProxy_ = iface_cast<IDistributedSourceInput>(remoteObject);
65 
66     if ((!dInputSourceProxy_) || (!dInputSourceProxy_->AsObject())) {
67         DHLOGE("Failed to get dinput source proxy.");
68         return false;
69     }
70     return true;
71 }
72 
GetDInputSinkProxy()73 bool DInputSAManager::GetDInputSinkProxy()
74 {
75     int32_t saId = 4810;
76     bool runOnCreate = false;
77 
78     if (dInputSinkProxy_ == nullptr) {
79         dInputSinkProxy_ = new DistributedInputSinkManager(saId, runOnCreate);
80     }
81 
82     return dInputSinkProxy_ != nullptr;
83 }
84 
HasDInputSinkProxy()85 bool DInputSAManager::HasDInputSinkProxy()
86 {
87     return dInputSinkProxy_ != nullptr;
88 }
89 
SetDInputSinkProxy(const sptr<IRemoteObject> & remoteObject)90 bool DInputSAManager::SetDInputSinkProxy(const sptr<IRemoteObject> &remoteObject)
91 {
92     dInputSinkProxy_ = iface_cast<IDistributedSinkInput>(remoteObject);
93 
94     if ((!dInputSinkProxy_) || (!dInputSinkProxy_->AsObject())) {
95         DHLOGE("Failed to get dinput sink proxy.");
96         return false;
97     }
98     return true;
99 }
100 
RestoreRegisterListenerAndCallback()101 int32_t DInputSAManager::RestoreRegisterListenerAndCallback()
102 {
103     return DH_SUCCESS;
104 }
105 
AddSimEventListenerToCache(sptr<ISimulationEventListener> listener)106 void DInputSAManager::AddSimEventListenerToCache(sptr<ISimulationEventListener> listener)
107 {}
108 
RemoveSimEventListenerFromCache(sptr<ISimulationEventListener> listener)109 void DInputSAManager::RemoveSimEventListenerFromCache(sptr<ISimulationEventListener> listener)
110 {}
111 
AddSessionStateCbToCache(const sptr<ISessionStateCallback> callback)112 void DInputSAManager::AddSessionStateCbToCache(const sptr<ISessionStateCallback> callback)
113 {}
114 
RemoveSessionStateCbFromCache()115 void DInputSAManager::RemoveSessionStateCbFromCache()
116 {}
117 } // namespace DistributedInput
118 } // namespace DistributedHardware
119 } // namespace OHOS