• 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 #include <gtest/gtest.h>
17 #include "accessibility_common_helper.h"
18 #include "accessibility_mt_helper.h"
19 #include "system_ability.h"
20 
21 namespace OHOS {
SystemAbility(bool runOnCreate)22 SystemAbility::SystemAbility(bool runOnCreate)
23 {
24     isRunning_ = false;
25     isRunOnCreate_ = runOnCreate;
26     isDistributed_ = false;
27     dumpLevel_ = 0;
28     capability_ = u"";
29 }
30 
SystemAbility(int32_t systemAbilityId,bool runOnCreate)31 SystemAbility::SystemAbility(int32_t systemAbilityId, bool runOnCreate) : SystemAbility(runOnCreate)
32 {
33     saId_ = systemAbilityId;
34 }
35 
~SystemAbility()36 SystemAbility::~SystemAbility()
37 {
38 }
39 
MakeAndRegisterAbility(SystemAbility * systemAbility)40 bool SystemAbility::MakeAndRegisterAbility(SystemAbility* systemAbility)
41 {
42     (void)systemAbility;
43     Accessibility::AccessibilityCommonHelper::GetInstance().SetIsServicePublished(false);
44     return true;
45 }
46 
AddSystemAbilityListener(int32_t systemAbilityId)47 bool SystemAbility::AddSystemAbilityListener(int32_t systemAbilityId)
48 {
49     OnAddSystemAbility(systemAbilityId, "");
50     return true;
51 }
52 
RemoveSystemAbilityListener(int32_t systemAbilityId)53 bool SystemAbility::RemoveSystemAbilityListener(int32_t systemAbilityId)
54 {
55     (void)systemAbilityId;
56     return true;
57 }
58 
Publish(sptr<IRemoteObject> systemAbility)59 bool SystemAbility::Publish(sptr<IRemoteObject> systemAbility)
60 {
61     (void)systemAbility;
62     systemAbility.ForceSetRefPtr(nullptr);
63     Accessibility::AccessibilityCommonHelper::GetInstance().SetIsServicePublished(true);
64     return true;
65 }
66 
StopAbility(int32_t systemAbilityId)67 void SystemAbility::StopAbility(int32_t systemAbilityId)
68 {
69     return;
70 }
71 
Start()72 void SystemAbility::Start()
73 {
74     OnStart();
75     isRunning_ = true;
76 }
77 
Stop()78 void SystemAbility::Stop()
79 {
80     if (!isRunning_) {
81         return;
82     }
83 
84     OnStop();
85     isRunning_ = false;
86 }
87 
SADump()88 void SystemAbility::SADump()
89 {
90     OnDump();
91 }
92 
GetSystemAbilitId() const93 int32_t SystemAbility::GetSystemAbilitId() const
94 {
95     return saId_;
96 }
97 
SetLibPath(const std::u16string & libPath)98 void SystemAbility::SetLibPath(const std::u16string& libPath)
99 {
100     libPath_ = libPath;
101 }
102 
GetLibPath() const103 const std::u16string& SystemAbility::GetLibPath() const
104 {
105     return libPath_;
106 }
107 
SetDependSa(const std::vector<std::u16string> & dependSa)108 void SystemAbility::SetDependSa(const std::vector<std::u16string>& dependSa)
109 {
110     dependSa_ = dependSa;
111 }
112 
GetDependSa() const113 const std::vector<std::u16string>& SystemAbility::GetDependSa() const
114 {
115     return dependSa_;
116 }
117 
SetRunOnCreate(bool isRunOnCreate)118 void SystemAbility::SetRunOnCreate(bool isRunOnCreate)
119 {
120     isRunOnCreate_ = isRunOnCreate;
121 }
122 
IsRunOnCreate() const123 bool SystemAbility::IsRunOnCreate() const
124 {
125     return isRunOnCreate_;
126 }
127 
SetDistributed(bool isDistributed)128 void SystemAbility::SetDistributed(bool isDistributed)
129 {
130     isDistributed_ = isDistributed;
131 }
132 
GetDistributed() const133 bool SystemAbility::GetDistributed() const
134 {
135     return isDistributed_;
136 }
137 
GetRunningStatus() const138 bool SystemAbility::GetRunningStatus() const
139 {
140     return isRunning_;
141 }
142 
SetDumpLevel(uint32_t dumpLevel)143 void SystemAbility::SetDumpLevel(uint32_t dumpLevel)
144 {
145     dumpLevel_ = dumpLevel;
146 }
147 
GetDumpLevel() const148 uint32_t SystemAbility::GetDumpLevel() const
149 {
150     return dumpLevel_;
151 }
152 
SetDependTimeout(int32_t dependTimeout)153 void SystemAbility::SetDependTimeout(int32_t dependTimeout)
154 {
155     (void)dependTimeout;
156 }
157 
GetDependTimeout() const158 int32_t SystemAbility::GetDependTimeout() const
159 {
160     return dependTimeout_;
161 }
162 
163 // The details should be implemented by subclass
OnDump()164 void SystemAbility::OnDump()
165 {
166 }
167 
168 // The details should be implemented by subclass
OnStart()169 void SystemAbility::OnStart()
170 {
171 }
172 
173 // The details should be implemented by subclass
OnStop()174 void SystemAbility::OnStop()
175 {
176 }
177 
178 // The details should be implemented by subclass
OnAddSystemAbility(int32_t systemAbilityId,const std::string & deviceId)179 void SystemAbility::OnAddSystemAbility(int32_t systemAbilityId, const std::string& deviceId)
180 {
181     (void)systemAbilityId;
182     (void)deviceId;
183 }
184 
185 // The details should be implemented by subclass
OnRemoveSystemAbility(int32_t systemAbilityId,const std::string & deviceId)186 void SystemAbility::OnRemoveSystemAbility(int32_t systemAbilityId, const std::string& deviceId)
187 {
188     (void)systemAbilityId;
189     (void)deviceId;
190 }
191 
GetSystemAbility(int32_t systemAbilityId)192 sptr<IRemoteObject> SystemAbility::GetSystemAbility(int32_t systemAbilityId)
193 {
194     (void)systemAbilityId;
195     return nullptr;
196 }
197 
SetCapability(const std::u16string & capability)198 void SystemAbility::SetCapability(const std::u16string& capability)
199 {
200     capability_ = capability;
201 }
202 
GetCapability() const203 const std::u16string& SystemAbility::GetCapability() const
204 {
205     return capability_;
206 }
207 
SetPermission(const std::u16string & permission)208 void SystemAbility::SetPermission(const std::u16string& permission)
209 {
210     permission_ = permission;
211 }
212 }