13fc297bdSopenharmony_ci/*
23fc297bdSopenharmony_ci * Copyright (C) 2024 Huawei Device Co., Ltd.
33fc297bdSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
43fc297bdSopenharmony_ci * you may not use this file except in compliance with the License.
53fc297bdSopenharmony_ci * You may obtain a copy of the License at
63fc297bdSopenharmony_ci *
73fc297bdSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
83fc297bdSopenharmony_ci *
93fc297bdSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
103fc297bdSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
113fc297bdSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
123fc297bdSopenharmony_ci * See the License for the specific language governing permissions and
133fc297bdSopenharmony_ci * limitations under the License.
143fc297bdSopenharmony_ci */
153fc297bdSopenharmony_ci
163fc297bdSopenharmony_ci#include <gtest/gtest.h>
173fc297bdSopenharmony_ci#include "system_ability.h"
183fc297bdSopenharmony_ci
193fc297bdSopenharmony_ciusing namespace OHOS;
203fc297bdSopenharmony_ci
213fc297bdSopenharmony_ciSystemAbility::SystemAbility(const int32_t serviceId, bool runOnCreate)
223fc297bdSopenharmony_ci{}
233fc297bdSopenharmony_ciSystemAbility::~SystemAbility()
243fc297bdSopenharmony_ci{}
253fc297bdSopenharmony_ci
263fc297bdSopenharmony_cibool SystemAbility::MakeAndRegisterAbility(SystemAbility* systemAbility)
273fc297bdSopenharmony_ci{
283fc297bdSopenharmony_ci    GTEST_LOG_(INFO) << "aams MOCK SystemAbility MakeAndRegisterAbility";
293fc297bdSopenharmony_ci    (void)systemAbility;
303fc297bdSopenharmony_ci    return true;
313fc297bdSopenharmony_ci}
323fc297bdSopenharmony_ci
333fc297bdSopenharmony_cibool SystemAbility::AddSystemAbilityListener(int32_t systemAbilityId)
343fc297bdSopenharmony_ci{
353fc297bdSopenharmony_ci    GTEST_LOG_(INFO) << "aams MOCK SystemAbility MakeAndRegisterAbility";
363fc297bdSopenharmony_ci    OnAddSystemAbility(systemAbilityId, "");
373fc297bdSopenharmony_ci    return true;
383fc297bdSopenharmony_ci}
393fc297bdSopenharmony_ci
403fc297bdSopenharmony_cibool SystemAbility::RemoveSystemAbilityListener(int32_t systemAbilityId)
413fc297bdSopenharmony_ci{
423fc297bdSopenharmony_ci    GTEST_LOG_(INFO) << "aams MOCK SystemAbility RemoveSystemAbilityListener";
433fc297bdSopenharmony_ci    (void)systemAbilityId;
443fc297bdSopenharmony_ci    return true;
453fc297bdSopenharmony_ci}
463fc297bdSopenharmony_ci
473fc297bdSopenharmony_cibool SystemAbility::Publish(sptr<IRemoteObject> systemAbility)
483fc297bdSopenharmony_ci{
493fc297bdSopenharmony_ci    GTEST_LOG_(INFO) << "aams MOCK SystemAbility Publish";
503fc297bdSopenharmony_ci    systemAbility.ForceSetRefPtr(nullptr);
513fc297bdSopenharmony_ci    return true;
523fc297bdSopenharmony_ci}
533fc297bdSopenharmony_ci
543fc297bdSopenharmony_civoid SystemAbility::StopAbility(int32_t systemAbilityId)
553fc297bdSopenharmony_ci{
563fc297bdSopenharmony_ci    GTEST_LOG_(INFO) << "aams MOCK SystemAbility StopAbility";
573fc297bdSopenharmony_ci    (void)systemAbilityId;
583fc297bdSopenharmony_ci}
593fc297bdSopenharmony_ci
603fc297bdSopenharmony_civoid SystemAbility::Start()
613fc297bdSopenharmony_ci{
623fc297bdSopenharmony_ci    GTEST_LOG_(INFO) << "aams MOCK SystemAbility Start";
633fc297bdSopenharmony_ci}
643fc297bdSopenharmony_ci
653fc297bdSopenharmony_civoid SystemAbility::Stop()
663fc297bdSopenharmony_ci{
673fc297bdSopenharmony_ci    GTEST_LOG_(INFO) << "aams MOCK SystemAbility Stop";
683fc297bdSopenharmony_ci}
693fc297bdSopenharmony_ci
703fc297bdSopenharmony_civoid SystemAbility::SADump()
713fc297bdSopenharmony_ci{}
723fc297bdSopenharmony_ci
733fc297bdSopenharmony_ciint32_t SystemAbility::GetSystemAbilitId() const
743fc297bdSopenharmony_ci{
753fc297bdSopenharmony_ci    GTEST_LOG_(INFO) << "aams MOCK SystemAbility GetSystemAbilitId";
763fc297bdSopenharmony_ci    return 0;
773fc297bdSopenharmony_ci}
783fc297bdSopenharmony_ci
793fc297bdSopenharmony_civoid SystemAbility::SetLibPath(const std::string& libPath)
803fc297bdSopenharmony_ci{
813fc297bdSopenharmony_ci    GTEST_LOG_(INFO) << "aams MOCK SystemAbility SetLibPath";
823fc297bdSopenharmony_ci    libPath_ = libPath;
833fc297bdSopenharmony_ci}
843fc297bdSopenharmony_ci
853fc297bdSopenharmony_ciconst std::string& SystemAbility::GetLibPath() const
863fc297bdSopenharmony_ci{
873fc297bdSopenharmony_ci    GTEST_LOG_(INFO) << "aams MOCK SystemAbility GetLibPath";
883fc297bdSopenharmony_ci    return libPath_;
893fc297bdSopenharmony_ci}
903fc297bdSopenharmony_ci
913fc297bdSopenharmony_civoid SystemAbility::SetDependSa(const std::vector<int32_t>& dependSa)
923fc297bdSopenharmony_ci{
933fc297bdSopenharmony_ci    GTEST_LOG_(INFO) << "aams MOCK SystemAbility SetDependSa";
943fc297bdSopenharmony_ci    dependSa_ = dependSa;
953fc297bdSopenharmony_ci}
963fc297bdSopenharmony_ci
973fc297bdSopenharmony_ciconst std::vector<int32_t>& SystemAbility::GetDependSa() const
983fc297bdSopenharmony_ci{
993fc297bdSopenharmony_ci    GTEST_LOG_(INFO) << "aams MOCK SystemAbility SetDependSa";
1003fc297bdSopenharmony_ci    return dependSa_;
1013fc297bdSopenharmony_ci}
1023fc297bdSopenharmony_ci
1033fc297bdSopenharmony_civoid SystemAbility::SetRunOnCreate(bool isRunOnCreate)
1043fc297bdSopenharmony_ci{
1053fc297bdSopenharmony_ci    GTEST_LOG_(INFO) << "aams MOCK SystemAbility SetRunOnCreate";
1063fc297bdSopenharmony_ci    isRunOnCreate_ = isRunOnCreate;
1073fc297bdSopenharmony_ci}
1083fc297bdSopenharmony_ci
1093fc297bdSopenharmony_cibool SystemAbility::IsRunOnCreate() const
1103fc297bdSopenharmony_ci{
1113fc297bdSopenharmony_ci    GTEST_LOG_(INFO) << "aams MOCK SystemAbility IsRunOnCreate";
1123fc297bdSopenharmony_ci    return isRunOnCreate_;
1133fc297bdSopenharmony_ci}
1143fc297bdSopenharmony_ci
1153fc297bdSopenharmony_civoid SystemAbility::SetDistributed(bool isDistributed)
1163fc297bdSopenharmony_ci{
1173fc297bdSopenharmony_ci    GTEST_LOG_(INFO) << "aams MOCK SystemAbility SetDistributed";
1183fc297bdSopenharmony_ci    isDistributed_ = isDistributed;
1193fc297bdSopenharmony_ci}
1203fc297bdSopenharmony_ci
1213fc297bdSopenharmony_cibool SystemAbility::GetDistributed() const
1223fc297bdSopenharmony_ci{
1233fc297bdSopenharmony_ci    GTEST_LOG_(INFO) << "aams MOCK SystemAbility GetDistributed";
1243fc297bdSopenharmony_ci    return isDistributed_;
1253fc297bdSopenharmony_ci}
1263fc297bdSopenharmony_ci
1273fc297bdSopenharmony_cibool SystemAbility::GetRunningStatus() const
1283fc297bdSopenharmony_ci{
1293fc297bdSopenharmony_ci    GTEST_LOG_(INFO) << "aams MOCK SystemAbility GetRunningStatus";
1303fc297bdSopenharmony_ci    return isRunning_;
1313fc297bdSopenharmony_ci}
1323fc297bdSopenharmony_ci
1333fc297bdSopenharmony_civoid SystemAbility::SetDumpLevel(uint32_t dumpLevel)
1343fc297bdSopenharmony_ci{
1353fc297bdSopenharmony_ci    GTEST_LOG_(INFO) << "aams MOCK SystemAbility SetDumpLevel";
1363fc297bdSopenharmony_ci    dumpLevel_ = dumpLevel;
1373fc297bdSopenharmony_ci}
1383fc297bdSopenharmony_ci
1393fc297bdSopenharmony_ciuint32_t SystemAbility::GetDumpLevel() const
1403fc297bdSopenharmony_ci{
1413fc297bdSopenharmony_ci    GTEST_LOG_(INFO) << "aams MOCK SystemAbility GetDumpLevel";
1423fc297bdSopenharmony_ci    return dumpLevel_;
1433fc297bdSopenharmony_ci}
1443fc297bdSopenharmony_ci
1453fc297bdSopenharmony_civoid SystemAbility::SetDependTimeout(int32_t dependTimeout)
1463fc297bdSopenharmony_ci{
1473fc297bdSopenharmony_ci    GTEST_LOG_(INFO) << "aams MOCK SystemAbility SetDependTimeout";
1483fc297bdSopenharmony_ci    (void)dependTimeout;
1493fc297bdSopenharmony_ci}
1503fc297bdSopenharmony_ci
1513fc297bdSopenharmony_ciint32_t SystemAbility::GetDependTimeout() const
1523fc297bdSopenharmony_ci{
1533fc297bdSopenharmony_ci    GTEST_LOG_(INFO) << "aams MOCK SystemAbility GetDependTimeout";
1543fc297bdSopenharmony_ci    return dependTimeout_;
1553fc297bdSopenharmony_ci}
1563fc297bdSopenharmony_ci
1573fc297bdSopenharmony_ci// The details should be implemented by subclass
1583fc297bdSopenharmony_civoid SystemAbility::OnDump()
1593fc297bdSopenharmony_ci{
1603fc297bdSopenharmony_ci    GTEST_LOG_(INFO) << "aams MOCK SystemAbility OnDump";
1613fc297bdSopenharmony_ci}
1623fc297bdSopenharmony_ci
1633fc297bdSopenharmony_ci// The details should be implemented by subclass
1643fc297bdSopenharmony_civoid SystemAbility::OnStart()
1653fc297bdSopenharmony_ci{
1663fc297bdSopenharmony_ci    GTEST_LOG_(INFO) << "aams MOCK SystemAbility OnStart";
1673fc297bdSopenharmony_ci}
1683fc297bdSopenharmony_ci
1693fc297bdSopenharmony_ciint32_t SystemAbility::OnExtension(const std::string& extension, MessageParcel& data, MessageParcel& reply)
1703fc297bdSopenharmony_ci{
1713fc297bdSopenharmony_ci    GTEST_LOG_(INFO) << "aams MOCK SystemAbility OnExtension";
1723fc297bdSopenharmony_ci    return 0;
1733fc297bdSopenharmony_ci}
1743fc297bdSopenharmony_ci
1753fc297bdSopenharmony_civoid SystemAbility::OnStart(const SystemAbilityOnDemandReason& startReason)
1763fc297bdSopenharmony_ci{
1773fc297bdSopenharmony_ci    GTEST_LOG_(INFO) << "aams MOCK SystemAbility OnStart";
1783fc297bdSopenharmony_ci}
1793fc297bdSopenharmony_ci
1803fc297bdSopenharmony_ciint32_t SystemAbility::OnIdle(const SystemAbilityOnDemandReason& idleReason)
1813fc297bdSopenharmony_ci{
1823fc297bdSopenharmony_ci    GTEST_LOG_(INFO) << "aams MOCK SystemAbility OnIdle";
1833fc297bdSopenharmony_ci    return 0;
1843fc297bdSopenharmony_ci}
1853fc297bdSopenharmony_ci
1863fc297bdSopenharmony_civoid SystemAbility::OnActive(const SystemAbilityOnDemandReason& activeReason)
1873fc297bdSopenharmony_ci{
1883fc297bdSopenharmony_ci    GTEST_LOG_(INFO) << "aams MOCK SystemAbility OnActive";
1893fc297bdSopenharmony_ci}
1903fc297bdSopenharmony_ci
1913fc297bdSopenharmony_ci// The details should be implemented by subclass
1923fc297bdSopenharmony_civoid SystemAbility::OnStop()
1933fc297bdSopenharmony_ci{
1943fc297bdSopenharmony_ci    GTEST_LOG_(INFO) << "aams MOCK SystemAbility OnStop";
1953fc297bdSopenharmony_ci}
1963fc297bdSopenharmony_ci
1973fc297bdSopenharmony_civoid SystemAbility::OnStop(const SystemAbilityOnDemandReason& stopReason)
1983fc297bdSopenharmony_ci{
1993fc297bdSopenharmony_ci    GTEST_LOG_(INFO) << "aams MOCK SystemAbility OnStop";
2003fc297bdSopenharmony_ci}
2013fc297bdSopenharmony_ci
2023fc297bdSopenharmony_ci// The details should be implemented by subclass
2033fc297bdSopenharmony_civoid SystemAbility::OnAddSystemAbility(int32_t systemAbilityId, const std::string& deviceId)
2043fc297bdSopenharmony_ci{
2053fc297bdSopenharmony_ci    GTEST_LOG_(INFO) << "aams MOCK SystemAbility OnAddSystemAbility";
2063fc297bdSopenharmony_ci    (void)systemAbilityId;
2073fc297bdSopenharmony_ci    (void)deviceId;
2083fc297bdSopenharmony_ci}
2093fc297bdSopenharmony_ci
2103fc297bdSopenharmony_ci// The details should be implemented by subclass
2113fc297bdSopenharmony_civoid SystemAbility::OnRemoveSystemAbility(int32_t systemAbilityId, const std::string& deviceId)
2123fc297bdSopenharmony_ci{
2133fc297bdSopenharmony_ci    GTEST_LOG_(INFO) << "aams MOCK SystemAbility OnRemoveSystemAbility";
2143fc297bdSopenharmony_ci    (void)systemAbilityId;
2153fc297bdSopenharmony_ci    (void)deviceId;
2163fc297bdSopenharmony_ci}
2173fc297bdSopenharmony_ci
2183fc297bdSopenharmony_cisptr<IRemoteObject> SystemAbility::GetSystemAbility(int32_t systemAbilityId)
2193fc297bdSopenharmony_ci{
2203fc297bdSopenharmony_ci    GTEST_LOG_(INFO) << "aams MOCK SystemAbility GetSystemAbility";
2213fc297bdSopenharmony_ci    (void)systemAbilityId;
2223fc297bdSopenharmony_ci    return nullptr;
2233fc297bdSopenharmony_ci}
2243fc297bdSopenharmony_ci
2253fc297bdSopenharmony_civoid SystemAbility::SetCapability(const std::u16string& capability)
2263fc297bdSopenharmony_ci{
2273fc297bdSopenharmony_ci    GTEST_LOG_(INFO) << "aams MOCK SystemAbility SetCapability";
2283fc297bdSopenharmony_ci    capability_ = capability;
2293fc297bdSopenharmony_ci}
2303fc297bdSopenharmony_ci
2313fc297bdSopenharmony_ciconst std::u16string& SystemAbility::GetCapability() const
2323fc297bdSopenharmony_ci{
2333fc297bdSopenharmony_ci    GTEST_LOG_(INFO) << "aams MOCK SystemAbility GetCapability";
2343fc297bdSopenharmony_ci    return capability_;
2353fc297bdSopenharmony_ci}
2363fc297bdSopenharmony_ci
2373fc297bdSopenharmony_civoid SystemAbility::SetPermission(const std::u16string& permission)
2383fc297bdSopenharmony_ci{
2393fc297bdSopenharmony_ci    GTEST_LOG_(INFO) << "aams MOCK SystemAbility SetPermission";
2403fc297bdSopenharmony_ci    permission_ = permission;
2413fc297bdSopenharmony_ci}
2423fc297bdSopenharmony_ci
2433fc297bdSopenharmony_ci// The details should be implemented by subclass
2443fc297bdSopenharmony_civoid SystemAbility::OnDeviceLevelChanged(int32_t type, int32_t level, std::string& action)
2453fc297bdSopenharmony_ci{
2463fc297bdSopenharmony_ci    GTEST_LOG_(INFO) << "aams MOCK SystemAbility OnDeviceLevelChanged";
2473fc297bdSopenharmony_ci    (void)type;
2483fc297bdSopenharmony_ci    (void)level;
2493fc297bdSopenharmony_ci    (void)action;
2503fc297bdSopenharmony_ci}
251