2022-05-12 05:57:18 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <gtest/gtest.h>
|
2022-09-13 04:42:55 +00:00
|
|
|
#include "accessibility_common_helper.h"
|
|
|
|
#include "accessibility_mt_helper.h"
|
2022-05-12 05:57:18 +00:00
|
|
|
#include "system_ability.h"
|
|
|
|
|
|
|
|
namespace OHOS {
|
|
|
|
SystemAbility::SystemAbility(bool runOnCreate)
|
|
|
|
{
|
2023-07-24 07:33:43 +00:00
|
|
|
GTEST_LOG_(INFO) << "MOCK SystemAbility SystemAbility";
|
2022-05-12 05:57:18 +00:00
|
|
|
isRunning_ = false;
|
|
|
|
isRunOnCreate_ = runOnCreate;
|
|
|
|
isDistributed_ = false;
|
|
|
|
dumpLevel_ = 0;
|
|
|
|
capability_ = u"";
|
|
|
|
}
|
|
|
|
|
|
|
|
SystemAbility::SystemAbility(int32_t systemAbilityId, bool runOnCreate) : SystemAbility(runOnCreate)
|
|
|
|
{
|
2023-07-24 07:33:43 +00:00
|
|
|
GTEST_LOG_(INFO) << "MOCK SystemAbility SystemAbility";
|
2022-05-12 05:57:18 +00:00
|
|
|
saId_ = systemAbilityId;
|
|
|
|
}
|
|
|
|
|
|
|
|
SystemAbility::~SystemAbility()
|
|
|
|
{
|
2023-07-24 07:33:43 +00:00
|
|
|
GTEST_LOG_(INFO) << "MOCK SystemAbility ~SystemAbility";
|
2022-05-12 05:57:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool SystemAbility::MakeAndRegisterAbility(SystemAbility* systemAbility)
|
|
|
|
{
|
2023-07-24 07:33:43 +00:00
|
|
|
GTEST_LOG_(INFO) << "MOCK SystemAbility MakeAndRegisterAbility";
|
2022-05-12 05:57:18 +00:00
|
|
|
(void)systemAbility;
|
2022-09-13 04:42:55 +00:00
|
|
|
Accessibility::AccessibilityCommonHelper::GetInstance().SetIsServicePublished(false);
|
2022-05-12 05:57:18 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SystemAbility::AddSystemAbilityListener(int32_t systemAbilityId)
|
|
|
|
{
|
2023-07-24 07:33:43 +00:00
|
|
|
GTEST_LOG_(INFO) << "MOCK SystemAbility AddSystemAbilityListener";
|
2022-05-12 05:57:18 +00:00
|
|
|
OnAddSystemAbility(systemAbilityId, "");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SystemAbility::RemoveSystemAbilityListener(int32_t systemAbilityId)
|
|
|
|
{
|
2023-07-24 07:33:43 +00:00
|
|
|
GTEST_LOG_(INFO) << "MOCK SystemAbility RemoveSystemAbilityListener";
|
2022-05-12 05:57:18 +00:00
|
|
|
(void)systemAbilityId;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SystemAbility::Publish(sptr<IRemoteObject> systemAbility)
|
|
|
|
{
|
2023-07-24 07:33:43 +00:00
|
|
|
GTEST_LOG_(INFO) << "MOCK SystemAbility Publish";
|
2022-05-12 05:57:18 +00:00
|
|
|
(void)systemAbility;
|
|
|
|
systemAbility.ForceSetRefPtr(nullptr);
|
2022-09-13 04:42:55 +00:00
|
|
|
Accessibility::AccessibilityCommonHelper::GetInstance().SetIsServicePublished(true);
|
2022-05-12 05:57:18 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SystemAbility::StopAbility(int32_t systemAbilityId)
|
|
|
|
{
|
2023-07-24 07:33:43 +00:00
|
|
|
GTEST_LOG_(INFO) << "MOCK SystemAbility StopAbility";
|
2022-05-12 05:57:18 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SystemAbility::Start()
|
|
|
|
{
|
2023-07-24 07:33:43 +00:00
|
|
|
GTEST_LOG_(INFO) << "MOCK SystemAbility Start";
|
2022-05-12 05:57:18 +00:00
|
|
|
OnStart();
|
|
|
|
isRunning_ = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SystemAbility::Stop()
|
|
|
|
{
|
2023-07-24 07:33:43 +00:00
|
|
|
GTEST_LOG_(INFO) << "MOCK SystemAbility Stop";
|
2022-05-12 05:57:18 +00:00
|
|
|
if (!isRunning_) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
OnStop();
|
|
|
|
isRunning_ = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SystemAbility::SADump()
|
|
|
|
{
|
2023-07-24 07:33:43 +00:00
|
|
|
GTEST_LOG_(INFO) << "MOCK SystemAbility SADump";
|
2022-05-12 05:57:18 +00:00
|
|
|
OnDump();
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t SystemAbility::GetSystemAbilitId() const
|
|
|
|
{
|
2023-07-24 07:33:43 +00:00
|
|
|
GTEST_LOG_(INFO) << "MOCK SystemAbility GetSystemAbilitId";
|
2022-05-12 05:57:18 +00:00
|
|
|
return saId_;
|
|
|
|
}
|
|
|
|
|
2022-11-15 04:09:04 +00:00
|
|
|
void SystemAbility::SetLibPath(const std::string& libPath)
|
2022-05-12 05:57:18 +00:00
|
|
|
{
|
2023-07-24 07:33:43 +00:00
|
|
|
GTEST_LOG_(INFO) << "MOCK SystemAbility SetLibPath";
|
2022-05-12 05:57:18 +00:00
|
|
|
libPath_ = libPath;
|
|
|
|
}
|
|
|
|
|
2022-11-15 04:09:04 +00:00
|
|
|
const std::string& SystemAbility::GetLibPath() const
|
2022-05-12 05:57:18 +00:00
|
|
|
{
|
2023-07-24 07:33:43 +00:00
|
|
|
GTEST_LOG_(INFO) << "MOCK SystemAbility GetLibPath";
|
2022-05-12 05:57:18 +00:00
|
|
|
return libPath_;
|
|
|
|
}
|
|
|
|
|
2022-11-15 04:09:04 +00:00
|
|
|
void SystemAbility::SetDependSa(const std::vector<int32_t>& dependSa)
|
2022-05-12 05:57:18 +00:00
|
|
|
{
|
2023-07-24 07:33:43 +00:00
|
|
|
GTEST_LOG_(INFO) << "MOCK SystemAbility SetDependSa";
|
2022-05-12 05:57:18 +00:00
|
|
|
dependSa_ = dependSa;
|
|
|
|
}
|
|
|
|
|
2022-11-15 04:09:04 +00:00
|
|
|
const std::vector<int32_t>& SystemAbility::GetDependSa() const
|
2022-05-12 05:57:18 +00:00
|
|
|
{
|
2023-07-24 07:33:43 +00:00
|
|
|
GTEST_LOG_(INFO) << "MOCK SystemAbility GetDependSa";
|
2022-05-12 05:57:18 +00:00
|
|
|
return dependSa_;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SystemAbility::SetRunOnCreate(bool isRunOnCreate)
|
|
|
|
{
|
2023-07-24 07:33:43 +00:00
|
|
|
GTEST_LOG_(INFO) << "MOCK SystemAbility SetRunOnCreate";
|
2022-05-12 05:57:18 +00:00
|
|
|
isRunOnCreate_ = isRunOnCreate;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SystemAbility::IsRunOnCreate() const
|
|
|
|
{
|
2023-07-24 07:33:43 +00:00
|
|
|
GTEST_LOG_(INFO) << "MOCK SystemAbility IsRunOnCreate";
|
2022-05-12 05:57:18 +00:00
|
|
|
return isRunOnCreate_;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SystemAbility::SetDistributed(bool isDistributed)
|
|
|
|
{
|
2023-07-24 07:33:43 +00:00
|
|
|
GTEST_LOG_(INFO) << "MOCK SystemAbility SetDistributed";
|
2022-05-12 05:57:18 +00:00
|
|
|
isDistributed_ = isDistributed;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SystemAbility::GetDistributed() const
|
|
|
|
{
|
2023-07-24 07:33:43 +00:00
|
|
|
GTEST_LOG_(INFO) << "MOCK SystemAbility GetDistributed";
|
2022-05-12 05:57:18 +00:00
|
|
|
return isDistributed_;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SystemAbility::GetRunningStatus() const
|
|
|
|
{
|
2023-07-24 07:33:43 +00:00
|
|
|
GTEST_LOG_(INFO) << "MOCK SystemAbility GetRunningStatus";
|
2022-05-12 05:57:18 +00:00
|
|
|
return isRunning_;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SystemAbility::SetDumpLevel(uint32_t dumpLevel)
|
|
|
|
{
|
2023-07-24 07:33:43 +00:00
|
|
|
GTEST_LOG_(INFO) << "MOCK SystemAbility SetDumpLevel";
|
2022-05-12 05:57:18 +00:00
|
|
|
dumpLevel_ = dumpLevel;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t SystemAbility::GetDumpLevel() const
|
|
|
|
{
|
2023-07-24 07:33:43 +00:00
|
|
|
GTEST_LOG_(INFO) << "MOCK SystemAbility GetDumpLevel";
|
2022-05-12 05:57:18 +00:00
|
|
|
return dumpLevel_;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SystemAbility::SetDependTimeout(int32_t dependTimeout)
|
|
|
|
{
|
2023-07-24 07:33:43 +00:00
|
|
|
GTEST_LOG_(INFO) << "MOCK SystemAbility SetDependTimeout";
|
2022-05-12 05:57:18 +00:00
|
|
|
(void)dependTimeout;
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t SystemAbility::GetDependTimeout() const
|
|
|
|
{
|
2023-07-24 07:33:43 +00:00
|
|
|
GTEST_LOG_(INFO) << "MOCK SystemAbility GetDependTimeout";
|
2022-05-12 05:57:18 +00:00
|
|
|
return dependTimeout_;
|
|
|
|
}
|
|
|
|
|
|
|
|
// The details should be implemented by subclass
|
|
|
|
void SystemAbility::OnDump()
|
|
|
|
{
|
2023-07-24 07:33:43 +00:00
|
|
|
GTEST_LOG_(INFO) << "MOCK SystemAbility OnDump";
|
2022-05-12 05:57:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// The details should be implemented by subclass
|
|
|
|
void SystemAbility::OnStart()
|
|
|
|
{
|
2023-07-24 07:33:43 +00:00
|
|
|
GTEST_LOG_(INFO) << "MOCK SystemAbility OnStart";
|
2022-05-12 05:57:18 +00:00
|
|
|
}
|
|
|
|
|
2024-04-24 11:12:39 +00:00
|
|
|
int32_t SystemAbility::OnExtension(const std::string& extension, MessageParcel& data, MessageParcel& reply)
|
|
|
|
{
|
|
|
|
GTEST_LOG_(INFO) << "MOCK SystemAbility OnExtension";
|
2024-04-28 02:21:39 +00:00
|
|
|
return 0;
|
2024-04-24 11:12:39 +00:00
|
|
|
}
|
|
|
|
|
2023-04-06 12:23:30 +00:00
|
|
|
void SystemAbility::OnStart(const SystemAbilityOnDemandReason& startReason)
|
2023-03-01 03:31:21 +00:00
|
|
|
{
|
2023-07-24 07:33:43 +00:00
|
|
|
GTEST_LOG_(INFO) << "MOCK SystemAbility OnStart";
|
2023-03-01 03:31:21 +00:00
|
|
|
}
|
|
|
|
|
2023-04-06 12:23:30 +00:00
|
|
|
int32_t SystemAbility::OnIdle(const SystemAbilityOnDemandReason& idleReason)
|
2023-03-01 03:31:21 +00:00
|
|
|
{
|
2023-07-24 07:33:43 +00:00
|
|
|
GTEST_LOG_(INFO) << "MOCK SystemAbility OnIdle";
|
2023-03-01 03:31:21 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2023-04-06 12:23:30 +00:00
|
|
|
void SystemAbility::OnActive(const SystemAbilityOnDemandReason& activeReason)
|
2023-03-01 03:31:21 +00:00
|
|
|
{
|
2023-07-24 07:33:43 +00:00
|
|
|
GTEST_LOG_(INFO) << "MOCK SystemAbility OnActive";
|
2023-03-01 03:31:21 +00:00
|
|
|
}
|
|
|
|
|
2022-05-12 05:57:18 +00:00
|
|
|
// The details should be implemented by subclass
|
|
|
|
void SystemAbility::OnStop()
|
|
|
|
{
|
2023-07-24 07:33:43 +00:00
|
|
|
GTEST_LOG_(INFO) << "MOCK SystemAbility OnStop";
|
2022-05-12 05:57:18 +00:00
|
|
|
}
|
|
|
|
|
2023-04-06 12:23:30 +00:00
|
|
|
void SystemAbility::OnStop(const SystemAbilityOnDemandReason& stopReason)
|
2023-03-01 03:31:21 +00:00
|
|
|
{
|
2023-07-24 07:33:43 +00:00
|
|
|
GTEST_LOG_(INFO) << "MOCK SystemAbility OnStop";
|
2023-03-01 03:31:21 +00:00
|
|
|
}
|
|
|
|
|
2022-05-12 05:57:18 +00:00
|
|
|
// The details should be implemented by subclass
|
|
|
|
void SystemAbility::OnAddSystemAbility(int32_t systemAbilityId, const std::string& deviceId)
|
|
|
|
{
|
2023-07-24 07:33:43 +00:00
|
|
|
GTEST_LOG_(INFO) << "MOCK SystemAbility OnAddSystemAbility";
|
2022-05-12 05:57:18 +00:00
|
|
|
(void)systemAbilityId;
|
|
|
|
(void)deviceId;
|
|
|
|
}
|
|
|
|
|
|
|
|
// The details should be implemented by subclass
|
|
|
|
void SystemAbility::OnRemoveSystemAbility(int32_t systemAbilityId, const std::string& deviceId)
|
|
|
|
{
|
2023-07-24 07:33:43 +00:00
|
|
|
GTEST_LOG_(INFO) << "MOCK SystemAbility OnRemoveSystemAbility";
|
2022-05-12 05:57:18 +00:00
|
|
|
(void)systemAbilityId;
|
|
|
|
(void)deviceId;
|
|
|
|
}
|
|
|
|
|
2024-11-27 11:22:09 +00:00
|
|
|
// The details should be implemented by subclass
|
|
|
|
int32_t SystemAbility::OnSvcCmd(int32_t fd, const std::vector<std::u16string>& args)
|
|
|
|
{
|
|
|
|
(void)fd;
|
|
|
|
(void)args;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-05-12 05:57:18 +00:00
|
|
|
sptr<IRemoteObject> SystemAbility::GetSystemAbility(int32_t systemAbilityId)
|
|
|
|
{
|
2023-07-24 07:33:43 +00:00
|
|
|
GTEST_LOG_(INFO) << "MOCK SystemAbility GetSystemAbility";
|
2022-05-12 05:57:18 +00:00
|
|
|
(void)systemAbilityId;
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SystemAbility::SetCapability(const std::u16string& capability)
|
|
|
|
{
|
2023-07-24 07:33:43 +00:00
|
|
|
GTEST_LOG_(INFO) << "MOCK SystemAbility SetCapability";
|
2022-05-12 05:57:18 +00:00
|
|
|
capability_ = capability;
|
|
|
|
}
|
|
|
|
|
|
|
|
const std::u16string& SystemAbility::GetCapability() const
|
|
|
|
{
|
2023-07-24 07:33:43 +00:00
|
|
|
GTEST_LOG_(INFO) << "MOCK SystemAbility GetCapability";
|
2022-05-12 05:57:18 +00:00
|
|
|
return capability_;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SystemAbility::SetPermission(const std::u16string& permission)
|
|
|
|
{
|
2023-07-24 07:33:43 +00:00
|
|
|
GTEST_LOG_(INFO) << "MOCK SystemAbility SetPermission";
|
2022-05-12 05:57:18 +00:00
|
|
|
permission_ = permission;
|
|
|
|
}
|
2023-11-15 08:44:45 +00:00
|
|
|
|
|
|
|
// The details should be implemented by subclass
|
|
|
|
void SystemAbility::OnDeviceLevelChanged(int32_t type, int32_t level, std::string& action)
|
|
|
|
{
|
|
|
|
GTEST_LOG_(INFO) << "MOCK SystemAbility OnDeviceLevelChanged";
|
|
|
|
(void)type;
|
|
|
|
(void)level;
|
|
|
|
(void)action;
|
|
|
|
}
|
2022-11-15 04:09:04 +00:00
|
|
|
}
|