Files
ability_ability_runtime/services/common/src/app_utils.cpp
T
altay a8cb37f75d The SCB can be restored independently.
Signed-off-by: altay <yuaqiang1@huawei.com>
Change-Id: I2dc8e35ff714d46c1478cb006f98250d7f84e0c7
2023-12-16 18:06:00 +08:00

76 lines
2.1 KiB
C++

/*
* Copyright (c) 2023 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 "app_utils.h"
#include "hilog_wrapper.h"
#include "parameters.h"
#include "scene_board_judgement.h"
namespace OHOS {
namespace AAFwk {
namespace {
const std::string BUNDLE_NAME_LAUNCHER = "com.ohos.launcher";
const std::string BUNDLE_NAME_SCENEBOARD = "com.ohos.sceneboard";
const std::string LAUNCHER_ABILITY_NAME = "com.ohos.launcher.MainAbility";
const std::string SCENEBOARD_ABILITY_NAME = "com.ohos.sceneboard.MainAbility";
const std::string DEVICE_2IN1 = "2in1";
const std::string DEVICE_PC = "pc";
const std::string DEVICE_TABLET = "tablet";
}
AppUtils::~AppUtils() {}
AppUtils::AppUtils()
{
if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
isSceneBoard_ = true;
}
auto deviceType = system::GetDeviceType();
if (deviceType == DEVICE_2IN1 || deviceType == DEVICE_PC || deviceType == DEVICE_TABLET) {
isPcDevice_ = true;
}
}
AppUtils &AppUtils::GetInstance()
{
static AppUtils utils;
return utils;
}
bool AppUtils::IsLauncher(const std::string &bundleName) const
{
if (isSceneBoard_) {
return bundleName == BUNDLE_NAME_SCENEBOARD;
}
return bundleName == BUNDLE_NAME_LAUNCHER;
}
bool AppUtils::IsLauncherAbility(const std::string &abilityName) const
{
if (isSceneBoard_) {
return abilityName == SCENEBOARD_ABILITY_NAME;
}
return abilityName == LAUNCHER_ABILITY_NAME;
}
bool AppUtils::JudgePCDevice() const
{
return isPcDevice_;
}
} // namespace AAFwk
} // namespace OHOS