• 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 #include <gtest/gtest.h>
17 #include "iservice_registry.h"
18 #include "mock_bundle_manager.h"
19 #include "string_ex.h"
20 #include "system_ability_definition.h"
21 #include "system_ability_manager_proxy.h"
22 #include "mock_accessible_ability_manager_service_stub.h"
23 
24 namespace OHOS {
25 static sptr<OHOS::Accessibility::MockAccessibleAbilityManagerServiceStub> g_MgrService = nullptr;
26 
GetInstance()27 SystemAbilityManagerClient& SystemAbilityManagerClient::GetInstance()
28 {
29     static auto instance = new SystemAbilityManagerClient();
30     return *instance;
31 }
32 
GetSystemAbilityManager()33 sptr<ISystemAbilityManager> SystemAbilityManagerClient::GetSystemAbilityManager()
34 {
35     std::lock_guard<std::mutex> lock(systemAbilityManagerLock_);
36     if (systemAbilityManager_ != nullptr) {
37         return systemAbilityManager_;
38     }
39 
40     systemAbilityManager_ = new SystemAbilityManagerProxy(nullptr);
41     return systemAbilityManager_;
42 }
43 
GetSystemAbility(int32_t systemAbilityId,const std::string & deviceId)44 sptr<IRemoteObject> SystemAbilityManagerProxy::GetSystemAbility(int32_t systemAbilityId,
45     const std::string& deviceId)
46 {
47     (void)deviceId;
48     return GetSystemAbility(systemAbilityId);
49 }
50 
GetSystemAbility(int32_t systemAbilityId)51 sptr<IRemoteObject> SystemAbilityManagerProxy::GetSystemAbility(int32_t systemAbilityId)
52 {
53     sptr<IRemoteObject> remote = nullptr;
54     switch (systemAbilityId) {
55         case ACCESSIBILITY_MANAGER_SERVICE_ID:
56             if (!g_MgrService) {
57                 g_MgrService = new OHOS::Accessibility::MockAccessibleAbilityManagerServiceStub();
58             }
59             remote = g_MgrService;
60             break;
61         default:
62             GTEST_LOG_(INFO) << "This service is not dummy!!!!" << systemAbilityId;
63             break;
64     }
65     return remote;
66 }
67 
CheckSystemAbilityWrapper(int32_t code,MessageParcel & data)68 sptr<IRemoteObject> SystemAbilityManagerProxy::CheckSystemAbilityWrapper(int32_t code, MessageParcel& data)
69 {
70     (void)code;
71     (void)data;
72     return nullptr;
73 }
74 
CheckSystemAbility(int32_t systemAbilityId)75 sptr<IRemoteObject> SystemAbilityManagerProxy::CheckSystemAbility(int32_t systemAbilityId)
76 {
77     (void)systemAbilityId;
78     sptr<IRemoteObject> remote = new OHOS::Accessibility::MockAccessibleAbilityManagerServiceStub();
79     return remote;
80 }
81 
CheckSystemAbility(int32_t systemAbilityId,const std::string & deviceId)82 sptr<IRemoteObject> SystemAbilityManagerProxy::CheckSystemAbility(int32_t systemAbilityId, const std::string& deviceId)
83 {
84     (void)systemAbilityId;
85     (void)deviceId;
86     return nullptr;
87 }
88 
CheckSystemAbility(int32_t systemAbilityId,bool & isExist)89 sptr<IRemoteObject> SystemAbilityManagerProxy::CheckSystemAbility(int32_t systemAbilityId, bool& isExist)
90 {
91     (void)systemAbilityId;
92     (void)isExist;
93     return nullptr;
94 }
95 
AddOnDemandSystemAbilityInfo(int32_t systemAbilityId,const std::u16string & localAbilityManagerName)96 int32_t SystemAbilityManagerProxy::AddOnDemandSystemAbilityInfo(int32_t systemAbilityId,
97     const std::u16string& localAbilityManagerName)
98 {
99     (void)systemAbilityId;
100     (void)localAbilityManagerName;
101     return -1;
102 }
103 
RemoveSystemAbilityWrapper(int32_t code,MessageParcel & data)104 int32_t SystemAbilityManagerProxy::RemoveSystemAbilityWrapper(int32_t code, MessageParcel& data)
105 {
106     (void)code;
107     (void)data;
108     return -1;
109 }
110 
RemoveSystemAbility(int32_t systemAbilityId)111 int32_t SystemAbilityManagerProxy::RemoveSystemAbility(int32_t systemAbilityId)
112 {
113     (void)systemAbilityId;
114     return -1;
115 }
116 
ListSystemAbilities(unsigned int dumpFlags)117 std::vector<std::u16string> SystemAbilityManagerProxy::ListSystemAbilities(unsigned int dumpFlags)
118 {
119     (void)dumpFlags;
120     std::vector<std::u16string> saNames;
121     return saNames;
122 }
123 
SubscribeSystemAbility(int32_t systemAbilityId,const sptr<ISystemAbilityStatusChange> & listener)124 int32_t SystemAbilityManagerProxy::SubscribeSystemAbility(int32_t systemAbilityId,
125     const sptr<ISystemAbilityStatusChange>& listener)
126 {
127     (void)systemAbilityId;
128     (void)listener;
129     return -1;
130 }
131 
UnSubscribeSystemAbility(int32_t systemAbilityId,const sptr<ISystemAbilityStatusChange> & listener)132 int32_t SystemAbilityManagerProxy::UnSubscribeSystemAbility(int32_t systemAbilityId,
133     const sptr<ISystemAbilityStatusChange>& listener)
134 {
135     (void)systemAbilityId;
136     (void)listener;
137     return -1;
138 }
139 
LoadSystemAbility(int32_t systemAbilityId,const sptr<ISystemAbilityLoadCallback> & callback)140 int32_t SystemAbilityManagerProxy::LoadSystemAbility(int32_t systemAbilityId,
141     const sptr<ISystemAbilityLoadCallback>& callback)
142 {
143     (void)systemAbilityId;
144     (void)callback;
145     return -1;
146 }
147 
UnloadSystemAbility(int32_t systemAbilityId)148 int32_t SystemAbilityManagerProxy::UnloadSystemAbility(int32_t systemAbilityId)
149 {
150     return -1;
151 }
152 
CancelUnloadSystemAbility(int32_t systemAbilityId)153 int32_t SystemAbilityManagerProxy::CancelUnloadSystemAbility(int32_t systemAbilityId)
154 {
155     return -1;
156 }
157 
AddSystemAbility(int32_t systemAbilityId,const sptr<IRemoteObject> & ability,const SAExtraProp & extraProp)158 int32_t SystemAbilityManagerProxy::AddSystemAbility(int32_t systemAbilityId, const sptr<IRemoteObject>& ability,
159     const SAExtraProp& extraProp)
160 {
161     (void)systemAbilityId;
162     (void)ability;
163     (void)extraProp;
164     return -1;
165 }
166 
AddSystemAbilityWrapper(int32_t code,MessageParcel & data)167 int32_t SystemAbilityManagerProxy::AddSystemAbilityWrapper(int32_t code, MessageParcel& data)
168 {
169     (void)code;
170     (void)data;
171     return -1;
172 }
173 
AddSystemProcess(const std::u16string & procName,const sptr<IRemoteObject> & procObject)174 int32_t SystemAbilityManagerProxy::AddSystemProcess(
175     const std::u16string& procName, const sptr<IRemoteObject>& procObject)
176 {
177     (void)procName;
178     (void)procObject;
179     return -1;
180 }
181 
GetRunningSystemProcess(std::list<SystemProcessInfo> & systemProcessInfos)182 int32_t SystemAbilityManagerProxy::GetRunningSystemProcess(std::list<SystemProcessInfo>& systemProcessInfos)
183 {
184     return -1;
185 }
186 
SubscribeSystemProcess(const sptr<ISystemProcessStatusChange> & listener)187 int32_t SystemAbilityManagerProxy::SubscribeSystemProcess(const sptr<ISystemProcessStatusChange>& listener)
188 {
189     return -1;
190 }
191 
UnSubscribeSystemProcess(const sptr<ISystemProcessStatusChange> & listener)192 int32_t SystemAbilityManagerProxy::UnSubscribeSystemProcess(const sptr<ISystemProcessStatusChange>& listener)
193 {
194     return -1;
195 }
196 
GetOnDemandSystemAbilityIds(std::vector<int32_t> & systemAbilityIds)197 int32_t SystemAbilityManagerProxy::GetOnDemandSystemAbilityIds(std::vector<int32_t>& systemAbilityIds)
198 {
199     return -1;
200 }
201 
Recompute(int32_t systemAbilityId,int32_t code)202 sptr<IRemoteObject> SystemAbilityManagerProxy::Recompute(int32_t systemAbilityId, int32_t code)
203 {
204     return nullptr;
205 }
206 }