• 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 MODULETEST_OHOS_ABILITY_RUNTIME_SYSTEM_ABILITY_H
17 #define MODULETEST_OHOS_ABILITY_RUNTIME_SYSTEM_ABILITY_H
18 
19 #include "hilog/log.h"
20 #include "iremote_object.h"
21 namespace OHOS {
22 #define REGISTER_SYSTEM_ABILITY_BY_ID(a, b, c)
23 #define REGISTER_SYSTEM_ABILITY(abilityClassName, abilityId, runOnCreate)
24 #define DECLEAR_SYSTEM_ABILITY(className)
25 
26 static constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, 0xD001100, "MockSystemAbility" };
27 
28 class SystemAbility {
29 public:
MakeAndRegisterAbility(SystemAbility *)30     static bool MakeAndRegisterAbility(SystemAbility*)
31     {
32         return true;
33     }
34 
35     bool AddSystemAbilityListener(int32_t systemAbilityId);
36 
37 protected:
OnStart()38     virtual void OnStart()
39     {
40         HiviewDFX::HiLog::Debug(LABEL, "Mock SystemAbility OnStart called");
41     }
42 
OnStop()43     virtual void OnStop()
44     {
45         HiviewDFX::HiLog::Debug(LABEL, "Mock SystemAbility OnStop called");
46     }
47 
OnAddSystemAbility(int32_t systemAbilityId,const std::string & deviceId)48     virtual void OnAddSystemAbility(int32_t systemAbilityId, const std::string& deviceId)
49     {
50         HiviewDFX::HiLog::Debug(LABEL, "Mock SystemAbility OnAddSystemAbility called");
51     }
52 
OnRemoveSystemAbility(int32_t systemAbilityId,const std::string & deviceId)53     virtual void OnRemoveSystemAbility(int32_t systemAbilityId, const std::string& deviceId)
54     {
55         HiviewDFX::HiLog::Debug(LABEL, "Mock SystemAbility OnRemoveSystemAbility called");
56     }
57 
Publish(sptr<IRemoteObject> systemAbility)58     bool Publish(sptr<IRemoteObject> systemAbility)
59     {
60         HiviewDFX::HiLog::Debug(LABEL, "Mock SystemAbility Publish called");
61         systemAbility.ForceSetRefPtr(nullptr);
62         return true;
63     }
64 
65     explicit SystemAbility(bool runOnCreate = false)
66     {
67         HiviewDFX::HiLog::Debug(LABEL, "Mock SystemAbility default Creator called %d", runOnCreate);
68     }
69 
70     SystemAbility(const int32_t serviceId, bool runOnCreate = false)
71     {
72         HiviewDFX::HiLog::Debug(LABEL, "Mock SystemAbility Creator called %d", runOnCreate);
73     }
74 
~SystemAbility()75     virtual ~SystemAbility()
76     {
77         HiviewDFX::HiLog::Debug(LABEL, "Mock SystemAbility Destructor called");
78     }
79 };
80 }  // namespace OHOS
81 #endif  // MODULETEST_OHOS_ABILITY_RUNTIME_SYSTEM_ABILITY_H
82