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 "test_ondemand_ability.h"
17 
18 #include "hilog/log.h"
19 #include "iremote_object.h"
20 
21 using namespace OHOS;
22 using namespace OHOS::HiviewDFX;
23 
24 REGISTER_SYSTEM_ABILITY_BY_ID(TestOnDemandAbility, 1497, false); // 1497 is test SA
25 
26 namespace OHOS {
TestOnDemandAbility(int32_t saId,bool runOnCreate)27 TestOnDemandAbility::TestOnDemandAbility(int32_t saId, bool runOnCreate) : SystemAbility(1497, false) // 1497 is test SA
28 {
29     HiLog::Info(label_, "%{public}s called", __func__);
30 }
31 
~TestOnDemandAbility()32 TestOnDemandAbility::~TestOnDemandAbility()
33 {
34     HiLog::Info(label_, "%{public}s called", __func__);
35 }
36 
GetBaseSystemAbility(int32_t systemAbilityId)37 sptr<IRemoteObject> TestOnDemandAbility::GetBaseSystemAbility(int32_t systemAbilityId)
38 {
39     sptr<IRemoteObject> object = GetSystemAbility(systemAbilityId);
40     return object;
41 }
42 
AddVolume(int volume)43 int TestOnDemandAbility::AddVolume(int volume)
44 {
45     HiLog::Info(label_, "TestOnDemandAbility:: %{public}s called, volume = %{public}d",
46         __func__, volume);
47     return (volume + 1);
48 }
49 
OnStart()50 void TestOnDemandAbility::OnStart()
51 {
52     HiLog::Info(label_, "%{public}s called", __func__);
53     bool res = Publish(this);
54     if (!res) {
55         HiLog::Error(label_, "%{public}s:fail to onstart res = %{public}d", __func__, res);
56     }
57     return;
58 }
59 
OnStop()60 void TestOnDemandAbility::OnStop()
61 {
62 }
63 }
64