Merge branch 'master' of gitee.com:openharmony/bundlemanager_bundle_framework into master

Signed-off-by: 赵淦 <zhaogan2@huawei.com>
This commit is contained in:
赵淦 2024-05-25 06:30:29 +00:00 committed by Gitee
commit 36c5b0a94b
92 changed files with 1345 additions and 178 deletions

View File

@ -37,6 +37,7 @@ group("test_target") {
deps = [
"common/test:unittest",
"interfaces/inner_api/test/unittest:unittest",
"interfaces/kits/js/zip/test:unittest",
"services/bundlemgr/test:unittest",
"services/test/moduletest/common/bms:moduletest",

View File

@ -82,7 +82,8 @@
"ets_runtime",
"json",
"zlib",
"appspawn"
"appspawn",
"bounds_checking_function"
],
"third_party": [
"libuv",

View File

@ -39,6 +39,7 @@ enum {
ERR_APPEXECFWK_FAILED_SERVICE_DIED,
ERR_APPEXECFWK_OPERATION_TIME_OUT,
ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR,
ERR_APPEXECFWK_APP_INDEX_OUT_OF_RANGE,
};
// Error code for AppMgr

View File

@ -221,6 +221,7 @@ constexpr const char* LAUNCHER_BUNDLE_NAME = "com.ohos.launcher";
constexpr const char* SCENE_BOARD_BUNDLE_NAME = "com.ohos.sceneboard";
// clone application
constexpr int32_t MAIN_APP_INDEX = 0;
constexpr int32_t CLONE_APP_INDEX_MIN = 1;
constexpr int32_t CLONE_APP_INDEX_MAX = 5;

View File

@ -60,6 +60,9 @@ private:
ErrCode HandleGetDisposedRule(MessageParcel& data, MessageParcel& reply);
ErrCode HandleSetDisposedRule(MessageParcel& data, MessageParcel& reply);
ErrCode HandleGetAbilityRunningControlRule(MessageParcel& data, MessageParcel& reply);
ErrCode HandleGetDisposedRuleForCloneApp(MessageParcel& data, MessageParcel& reply);
ErrCode HandleSetDisposedRuleForCloneApp(MessageParcel& data, MessageParcel& reply);
ErrCode HandleDeleteDisposedRuleForCloneApp(MessageParcel& data, MessageParcel& reply);
DISALLOW_COPY_AND_MOVE(AppControlHost);
};

View File

@ -144,6 +144,21 @@ public:
{
return ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR;
}
virtual ErrCode GetDisposedRuleForCloneApp(const std::string &appId, DisposedRule& disposedRule,
int32_t appIndex, int32_t userId = Constants::UNSPECIFIED_USERID)
{
return ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR;
}
virtual ErrCode SetDisposedRuleForCloneApp(const std::string &appId, DisposedRule& disposedRule,
int32_t appIndex, int32_t userId = Constants::UNSPECIFIED_USERID)
{
return ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR;
}
virtual ErrCode DeleteDisposedRuleForCloneApp(const std::string &appId, int32_t appIndex,
int32_t userId = Constants::UNSPECIFIED_USERID)
{
return ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR;
}
};
} // namespace AppExecFwk
} // namespace OHOS

View File

@ -68,6 +68,12 @@ public:
DisposedRule& disposedRule, int32_t userId = Constants::UNSPECIFIED_USERID) override;
virtual ErrCode GetAbilityRunningControlRule(
const std::string &bundleName, int32_t userId, std::vector<DisposedRule>& disposedRules) override;
virtual ErrCode GetDisposedRuleForCloneApp(const std::string &appId, DisposedRule& disposedRule,
int32_t appIndex, int32_t userId = Constants::UNSPECIFIED_USERID) override;
virtual ErrCode SetDisposedRuleForCloneApp(const std::string &appId, DisposedRule& disposedRule,
int32_t appIndex, int32_t userId = Constants::UNSPECIFIED_USERID) override;
virtual ErrCode DeleteDisposedRuleForCloneApp(const std::string &appId, int32_t appIndex,
int32_t userId = Constants::UNSPECIFIED_USERID) override;
private:
bool WriteParcelableVector(const std::vector<std::string> &stringVector, MessageParcel &data);

View File

@ -204,6 +204,9 @@ enum class AppControlManagerInterfaceCode : uint32_t {
SET_DISPOSED_RULE,
GET_DISPOSED_RULE,
GET_ABILITY_RUNNING_CONTROL_RULE,
GET_DISPOSED_RULE_FOR_CLONE_APP,
SET_DISPOSED_RULE_FOR_CLONE_APP,
DELETE_DISPOSED_RULE_FOR_CLONE_APP,
};
/* SAID: 401-96 Interface No.96 subservice also provides the following interfaces */

View File

@ -304,6 +304,17 @@ public:
{
return Constants::INVALID_UID;
}
/**
* @brief Obtains the application UID based on the given bundle name and user ID.
* @param bundleName Indicates the bundle name of the application.
* @param userId Indicates the user ID.
* @param userId Indicates the app Index.
* @return Returns the uid if successfully obtained; returns -1 otherwise.
*/
virtual int32_t GetUidByBundleName(const std::string &bundleName, const int32_t userId, int32_t appIndex)
{
return Constants::INVALID_UID;
}
/**
* @brief Obtains the debug application UID based on the given bundle name and user ID.
* @param bundleName Indicates the bundle name of the application.

View File

@ -219,6 +219,14 @@ public:
* @return Returns the uid if successfully obtained; returns -1 otherwise.
*/
virtual int GetUidByBundleName(const std::string &bundleName, const int userId) override;
/**
* @brief Obtains the application UID based on the given bundle name and user ID through the proxy object.
* @param bundleName Indicates the bundle name of the application.
* @param userId Indicates the user ID.
* @param userId Indicates the app Index.
* @return Returns the uid if successfully obtained; returns -1 otherwise.
*/
virtual int32_t GetUidByBundleName(const std::string &bundleName, const int32_t userId, int32_t appIndex) override;
/**
* @brief Obtains the debug application UID based on the given bundle name and user ID through the proxy object.
* @param bundleName Indicates the bundle name of the application.

View File

@ -91,6 +91,12 @@ int AppControlHost::OnRemoteRequest(
return HandleGetDisposedRule(data, reply);
case static_cast<uint32_t>(AppControlManagerInterfaceCode::GET_ABILITY_RUNNING_CONTROL_RULE):
return HandleGetAbilityRunningControlRule(data, reply);
case static_cast<uint32_t>(AppControlManagerInterfaceCode::GET_DISPOSED_RULE_FOR_CLONE_APP):
return HandleGetDisposedRuleForCloneApp(data, reply);
case static_cast<uint32_t>(AppControlManagerInterfaceCode::SET_DISPOSED_RULE_FOR_CLONE_APP):
return HandleSetDisposedRuleForCloneApp(data, reply);
case static_cast<uint32_t>(AppControlManagerInterfaceCode::DELETE_DISPOSED_RULE_FOR_CLONE_APP):
return HandleDeleteDisposedRuleForCloneApp(data, reply);
default:
LOG_W(BMS_TAG_APP_CONTROL, "AppControlHost receive unknown code, code = %{public}d", code);
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
@ -417,6 +423,57 @@ ErrCode AppControlHost::HandleGetAbilityRunningControlRule(MessageParcel& data,
return ERR_OK;
}
ErrCode AppControlHost::HandleGetDisposedRuleForCloneApp(MessageParcel& data, MessageParcel &reply)
{
std::string appId = data.ReadString();
int32_t userId = data.ReadInt32();
int32_t appIndex = data.ReadInt32();
DisposedRule rule;
ErrCode ret = GetDisposedRuleForCloneApp(appId, rule, appIndex, userId);
if (!reply.WriteInt32(ret)) {
LOG_E(BMS_TAG_APP_CONTROL, "write ret failed");
return ERR_APPEXECFWK_PARCEL_ERROR;
}
if (ret == ERR_OK) {
if (!reply.WriteParcelable(&rule)) {
LOG_E(BMS_TAG_APP_CONTROL, "write failed");
return ERR_APPEXECFWK_PARCEL_ERROR;
}
}
return ERR_OK;
}
ErrCode AppControlHost::HandleSetDisposedRuleForCloneApp(MessageParcel& data, MessageParcel& reply)
{
std::string appId = data.ReadString();
std::unique_ptr<DisposedRule> disposedRule(data.ReadParcelable<DisposedRule>());
int32_t userId = data.ReadInt32();
int32_t appIndex = data.ReadInt32();
if (disposedRule == nullptr) {
LOG_E(BMS_TAG_APP_CONTROL, "ReadParcelable<disposedRule> failed.");
return ERR_APPEXECFWK_PARCEL_ERROR;
}
ErrCode ret = SetDisposedRuleForCloneApp(appId, *disposedRule, appIndex, userId);
if (!reply.WriteInt32(ret)) {
LOG_E(BMS_TAG_APP_CONTROL, "write ret failed");
return ERR_APPEXECFWK_PARCEL_ERROR;
}
return ERR_OK;
}
ErrCode AppControlHost::HandleDeleteDisposedRuleForCloneApp(MessageParcel& data, MessageParcel& reply)
{
std::string appId = data.ReadString();
int32_t userId = data.ReadInt32();
int32_t appIndex = data.ReadInt32();
ErrCode ret = DeleteDisposedRuleForCloneApp(appId, appIndex, userId);
if (!reply.WriteInt32(ret)) {
LOG_E(BMS_TAG_APP_CONTROL, "write ret failed");
return ERR_APPEXECFWK_PARCEL_ERROR;
}
return ERR_OK;
}
bool AppControlHost::WriteStringVector(const std::vector<std::string> &stringVector, MessageParcel &reply)
{
if (!reply.WriteInt32(stringVector.size())) {

View File

@ -472,7 +472,7 @@ ErrCode AppControlProxy::SetDisposedRule(
return ERR_APPEXECFWK_PARCEL_ERROR;
}
if (!data.WriteString(appId)) {
LOG_E(BMS_TAG_APP_CONTROL, "write bundleName failed.");
LOG_E(BMS_TAG_APP_CONTROL, "write appId failed.");
return ERR_APPEXECFWK_PARCEL_ERROR;
}
if (!data.WriteParcelable(&disposedRule)) {
@ -541,6 +541,109 @@ ErrCode AppControlProxy::GetAbilityRunningControlRule(
return GetParcelableInfos(AppControlManagerInterfaceCode::GET_ABILITY_RUNNING_CONTROL_RULE, data, rules);
}
ErrCode AppControlProxy::SetDisposedRuleForCloneApp(
const std::string &appId, DisposedRule &disposedRule, int32_t appIndex, int32_t userId)
{
LOG_D(BMS_TAG_APP_CONTROL, "proxy begin to SetDisposedRuleForCloneApp");
MessageParcel data;
if (!data.WriteInterfaceToken(GetDescriptor())) {
LOG_E(BMS_TAG_APP_CONTROL, "WriteInterfaceToken failed.");
return ERR_APPEXECFWK_PARCEL_ERROR;
}
if (!data.WriteString(appId)) {
LOG_E(BMS_TAG_APP_CONTROL, "write appId failed.");
return ERR_APPEXECFWK_PARCEL_ERROR;
}
if (!data.WriteParcelable(&disposedRule)) {
LOG_E(BMS_TAG_APP_CONTROL, "write disposedRule failed.");
return ERR_APPEXECFWK_PARCEL_ERROR;
}
if (!data.WriteInt32(userId)) {
LOG_E(BMS_TAG_APP_CONTROL, "write userId failed.");
return ERR_APPEXECFWK_PARCEL_ERROR;
}
if (!data.WriteInt32(appIndex)) {
LOG_E(BMS_TAG_APP_CONTROL, "write appIndex appIndex.");
return ERR_APPEXECFWK_PARCEL_ERROR;
}
MessageParcel reply;
ErrCode ret = SendRequest(AppControlManagerInterfaceCode::SET_DISPOSED_RULE_FOR_CLONE_APP, data, reply);
if (ret != ERR_OK) {
LOG_E(BMS_TAG_APP_CONTROL, "SendRequest failed.");
return ret;
}
ret = reply.ReadInt32();
if (ret != ERR_OK) {
LOG_E(BMS_TAG_APP_CONTROL, "host return error : %{public}d", ret);
return ret;
}
return ERR_OK;
}
ErrCode AppControlProxy::GetDisposedRuleForCloneApp(const std::string &appId, DisposedRule &rule,
int32_t appIndex, int32_t userId)
{
LOG_D(BMS_TAG_APP_CONTROL, "proxy begin to GetDisposedRuleForCloneApp");
MessageParcel data;
if (!data.WriteInterfaceToken(GetDescriptor())) {
LOG_E(BMS_TAG_APP_CONTROL, "WriteInterfaceToken failed.");
return ERR_APPEXECFWK_PARCEL_ERROR;
}
if (!data.WriteString(appId)) {
LOG_E(BMS_TAG_APP_CONTROL, "write appId failed.");
return ERR_APPEXECFWK_PARCEL_ERROR;
}
if (!data.WriteInt32(userId)) {
LOG_E(BMS_TAG_APP_CONTROL, "write userId failed.");
return ERR_APPEXECFWK_PARCEL_ERROR;
}
if (!data.WriteInt32(appIndex)) {
LOG_E(BMS_TAG_APP_CONTROL, "write appIndex failed.");
return ERR_APPEXECFWK_PARCEL_ERROR;
}
ErrCode ret = GetParcelableInfo<DisposedRule>(AppControlManagerInterfaceCode::GET_DISPOSED_RULE_FOR_CLONE_APP,
data, rule);
if (ret != ERR_OK) {
LOG_E(BMS_TAG_APP_CONTROL, "host return error : %{public}d", ret);
return ret;
}
return ERR_OK;
}
ErrCode AppControlProxy::DeleteDisposedRuleForCloneApp(const std::string &appId, int32_t appIndex, int32_t userId)
{
LOG_D(BMS_TAG_APP_CONTROL, "proxy begin to DeleteDisposedRuleForCloneApp");
MessageParcel data;
if (!data.WriteInterfaceToken(GetDescriptor())) {
LOG_E(BMS_TAG_APP_CONTROL, "WriteInterfaceToken failed.");
return ERR_APPEXECFWK_PARCEL_ERROR;
}
if (!data.WriteString(appId)) {
LOG_E(BMS_TAG_APP_CONTROL, "write appId failed.");
return ERR_APPEXECFWK_PARCEL_ERROR;
}
if (!data.WriteInt32(userId)) {
LOG_E(BMS_TAG_APP_CONTROL, "write userId failed.");
return ERR_APPEXECFWK_PARCEL_ERROR;
}
if (!data.WriteInt32(appIndex)) {
LOG_E(BMS_TAG_APP_CONTROL, "write appIndex failed.");
return ERR_APPEXECFWK_PARCEL_ERROR;
}
MessageParcel reply;
ErrCode ret = SendRequest(AppControlManagerInterfaceCode::DELETE_DISPOSED_RULE_FOR_CLONE_APP, data, reply);
if (ret != ERR_OK) {
LOG_E(BMS_TAG_APP_CONTROL, "SendRequest failed.");
return ret;
}
ret = reply.ReadInt32();
if (ret != ERR_OK) {
LOG_E(BMS_TAG_APP_CONTROL, "host return error : %{public}d", ret);
return ret;
}
return ERR_OK;
}
bool AppControlProxy::WriteStringVector(const std::vector<std::string> &stringVector, MessageParcel &data)
{
if (!data.WriteInt32(stringVector.size())) {

View File

@ -2209,7 +2209,8 @@ ErrCode BundleMgrHost::HandleGetUidByBundleName(MessageParcel &data, MessageParc
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
std::string bundleName = data.ReadString();
int32_t userId = data.ReadInt32();
int32_t uid = GetUidByBundleName(bundleName, userId);
int32_t appIndex = data.ReadInt32();
int32_t uid = GetUidByBundleName(bundleName, userId, appIndex);
APP_LOGD("uid is %{public}d", uid);
if (!reply.WriteInt32(uid)) {
APP_LOGE("write failed");

View File

@ -641,13 +641,19 @@ ErrCode BundleMgrProxy::GetBundleInfosV9(int32_t flags, std::vector<BundleInfo>
}
int BundleMgrProxy::GetUidByBundleName(const std::string &bundleName, const int userId)
{
return GetUidByBundleName(bundleName, userId, 0);
}
int32_t BundleMgrProxy::GetUidByBundleName(const std::string &bundleName, const int32_t userId, int32_t appIndex)
{
if (bundleName.empty()) {
APP_LOGE("failed to GetUidByBundleName due to bundleName empty");
return Constants::INVALID_UID;
}
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
APP_LOGD("begin to get uid of %{public}s, userId : %{public}d", bundleName.c_str(), userId);
APP_LOGD("begin to get uid of %{public}s, userId : %{public}d, appIndex : %{public}d", bundleName.c_str(),
userId, appIndex);
MessageParcel data;
if (!data.WriteInterfaceToken(GetDescriptor())) {
@ -662,6 +668,10 @@ int BundleMgrProxy::GetUidByBundleName(const std::string &bundleName, const int
APP_LOGE("failed to GetUidByBundleName due to write uid fail");
return Constants::INVALID_UID;
}
if (!data.WriteInt32(appIndex)) {
APP_LOGE("failed to GetUidByBundleName due to write uid fail");
return Constants::INVALID_UID;
}
MessageParcel reply;
if (!SendTransactCmd(BundleMgrInterfaceCode::GET_UID_BY_BUNDLE_NAME, data, reply)) {

View File

@ -0,0 +1,23 @@
# Copyright (c) 2024 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.
import("//build/ohos.gni")
group("unittest") {
testonly = true
deps = [
"bundle_resource_host_test:BundleResourceHostTest",
"bundle_resource_proxy_test:BundleResourceProxyTest",
]
}

View File

@ -0,0 +1,56 @@
# Copyright (c) 2024 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.
import("//build/test.gni")
import("../../../../../appexecfwk.gni")
import("../../../../../services/bundlemgr/appexecfwk_bundlemgr.gni")
config("private_config") {
include_dirs = [ "${services_path}/bundlemgr/test/mock/include" ]
}
module_output_path = "bundle_framework/appexecfwk"
ohos_unittest("BundleResourceHostTest") {
module_out_path = module_output_path
include_dirs = [ "${core_path}/include/bundle_resource" ]
sources = [ "bundle_resource_host_test.cpp" ]
deps = [
"${base_path}:appexecfwk_base",
"${core_path}:appexecfwk_core",
]
external_deps = [
"ability_base:base",
"ability_base:want",
"access_token:libprivacy_sdk",
"access_token:libtokenid_sdk",
"appverify:libhapverify",
"c_utils:utils",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"hilog:libhilog",
"hitrace:hitrace_meter",
"init:libbegetutil",
"ipc:ipc_core",
"safwk:system_ability_fwk",
"samgr:samgr_proxy",
]
}
group("unittest") {
testonly = true
deps = [ ":BundleResourceHostTest" ]
}

View File

@ -0,0 +1,135 @@
/*
* Copyright (c) 2024 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>
#include <vector>
#include "bundle_resource_host.h"
#include "bundle_resource_interface.h"
#include "iremote_stub.h"
using namespace testing::ext;
namespace OHOS {
namespace AppExecFwk {
class MockBundleResourceHostImpl : public BundleResourceHost {
public:
MockBundleResourceHostImpl() = default;
virtual ~MockBundleResourceHostImpl() = default;
virtual ErrCode GetBundleResourceInfo(const std::string &bundleName, const uint32_t flags,
BundleResourceInfo &bundleResourceInfo, const int32_t appIndex = 0) override
{
return ERR_OK;
}
virtual ErrCode GetLauncherAbilityResourceInfo(const std::string &bundleName, const uint32_t flags,
std::vector<LauncherAbilityResourceInfo> &launcherAbilityResourceInfo, const int32_t appIndex = 0) override
{
return ERR_OK;
}
virtual ErrCode GetAllBundleResourceInfo(const uint32_t flags,
std::vector<BundleResourceInfo> &bundleResourceInfos) override
{
BundleResourceInfo temp;
bundleResourceInfos.push_back(temp);
bundleResourceInfos.push_back(temp);
return ERR_OK;
}
virtual ErrCode GetAllLauncherAbilityResourceInfo(const uint32_t flags,
std::vector<LauncherAbilityResourceInfo> &launcherAbilityResourceInfos) override
{
LauncherAbilityResourceInfo temp;
launcherAbilityResourceInfos.push_back(temp);
launcherAbilityResourceInfos.push_back(temp);
return ERR_OK;
}
};
class BundleResourceHostTest : public testing::Test {
public:
BundleResourceHostTest() = default;
~BundleResourceHostTest() = default;
static void SetUpTestCase();
static void TearDownTestCase();
void SetUp();
void TearDown();
private:
};
void BundleResourceHostTest::SetUpTestCase()
{}
void BundleResourceHostTest::TearDownTestCase()
{
}
void BundleResourceHostTest::SetUp()
{}
void BundleResourceHostTest::TearDown()
{
}
HWTEST_F(BundleResourceHostTest, GetBundleResourceInfo_0100, Function | SmallTest | Level0)
{
GTEST_LOG_(INFO) << "GetBundleResourceInfo_0100 start";
sptr<MockBundleResourceHostImpl> stub = new MockBundleResourceHostImpl();
sptr<BundleResourceProxy> proxy = new BundleResourceProxy(stub->AsObject());
BundleResourceInfo info;
ErrCode ret = proxy->GetBundleResourceInfo("com.test.empty", 0, info, 1);
GTEST_LOG_(INFO) << "GetBundleResourceInfo_0100 end, " << ret;
ASSERT_EQ(ret, ERR_OK);
}
HWTEST_F(BundleResourceHostTest, GetLauncherAbilityResourceInfo_0100, Function | SmallTest | Level0)
{
GTEST_LOG_(INFO) << "GetLauncherAbilityResourceInfo_0100 start";
sptr<MockBundleResourceHostImpl> stub = new MockBundleResourceHostImpl();
sptr<BundleResourceProxy> proxy = new BundleResourceProxy(stub->AsObject());
std::vector<LauncherAbilityResourceInfo> info;
ErrCode ret = proxy->GetLauncherAbilityResourceInfo("com.test.empty", 0, info, 1);
GTEST_LOG_(INFO) << "GetLauncherAbilityResourceInfo_0100 end, " << ret;
ASSERT_EQ(ret, ERR_OK);
}
HWTEST_F(BundleResourceHostTest, GetAllBundleResourceInfo_0100, Function | SmallTest | Level0)
{
GTEST_LOG_(INFO) << "GetAllBundleResourceInfo_0100 start";
sptr<MockBundleResourceHostImpl> stub = new MockBundleResourceHostImpl();
sptr<BundleResourceProxy> proxy = new BundleResourceProxy(stub->AsObject());
std::vector<BundleResourceInfo> info;
ErrCode ret = proxy->GetAllBundleResourceInfo(0, info);
GTEST_LOG_(INFO) << "GetAllBundleResourceInfo_0100 end, " << ret;
ASSERT_EQ(ret, ERR_OK);
}
HWTEST_F(BundleResourceHostTest, GetAllLauncherAbilityResourceInfo_0100, Function | SmallTest | Level0)
{
GTEST_LOG_(INFO) << "GetAllLauncherAbilityResourceInfo_0100 start";
sptr<MockBundleResourceHostImpl> stub = new MockBundleResourceHostImpl();
sptr<BundleResourceProxy> proxy = new BundleResourceProxy(stub->AsObject());
std::vector<LauncherAbilityResourceInfo> info;
ErrCode ret = proxy->GetAllLauncherAbilityResourceInfo(0, info);
GTEST_LOG_(INFO) << "GetAllLauncherAbilityResourceInfo_0100 end, " << ret;
ASSERT_EQ(ret, ERR_OK);
}
}
}

View File

@ -0,0 +1,55 @@
# Copyright (c) 2024 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.
import("//build/test.gni")
import("../../../../../appexecfwk.gni")
import("../../../../../services/bundlemgr/appexecfwk_bundlemgr.gni")
config("private_config") {
include_dirs = [ "${services_path}/bundlemgr/test/mock/include" ]
}
module_output_path = "bundle_framework/appexecfwk"
ohos_unittest("BundleResourceProxyTest") {
module_out_path = module_output_path
include_dirs = [ "${core_path}/include/bundle_resource" ]
sources = [ "bundle_resource_proxy_test.cpp" ]
deps = [
"${base_path}:appexecfwk_base",
"${core_path}:appexecfwk_core",
]
external_deps = [
"ability_base:base",
"ability_base:want",
"access_token:libprivacy_sdk",
"access_token:libtokenid_sdk",
"appverify:libhapverify",
"c_utils:utils",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"hilog:libhilog",
"hitrace:hitrace_meter",
"init:libbegetutil",
"ipc:ipc_core",
"safwk:system_ability_fwk",
"samgr:samgr_proxy",
]
}
group("unittest") {
testonly = true
deps = [ ":BundleResourceProxyTest" ]
}

View File

@ -0,0 +1,134 @@
/*
* Copyright (c) 2024 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>
#include "bundle_resource_proxy.h"
#include "bundle_resource_interface.h"
#include "iremote_stub.h"
using namespace testing::ext;
namespace OHOS {
namespace AppExecFwk {
constexpr int32_t MAX_PARCEL_CAPACITY = 100 * 1024 * 1024; // 100M
ErrCode WriteVectorToParcel(std::vector<BundleResourceInfo> &parcelVector, MessageParcel &reply)
{
Parcel tempParcel;
(void)tempParcel.SetMaxCapacity(MAX_PARCEL_CAPACITY);
if (!tempParcel.WriteInt32(parcelVector.size())) {
return ERR_APPEXECFWK_PARCEL_ERROR;
}
for (auto &parcel : parcelVector) {
if (!tempParcel.WriteParcelable(&parcel)) {
return ERR_APPEXECFWK_PARCEL_ERROR;
}
}
size_t dataSize = tempParcel.GetDataSize();
if (!reply.WriteInt32(static_cast<int32_t>(dataSize))) {
return ERR_APPEXECFWK_PARCEL_ERROR;
}
if (!reply.WriteRawData(
reinterpret_cast<uint8_t *>(tempParcel.GetData()), dataSize)) {
return ERR_APPEXECFWK_PARCEL_ERROR;
}
return ERR_OK;
}
class MockStub : public IRemoteStub<IBundleResource> {
public:
MockStub() = default;
virtual ~MockStub() = default;
int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
{
if (code == static_cast<uint32_t>(BundleResourceInterfaceCode::GET_BUNDLE_RESOURCE_INFO)) {
GTEST_LOG_(INFO) << "OnRemoteRequest, GET_BUNDLE_RESOURCE_INFO";
reply.WriteInt32(ERR_OK);
BundleResourceInfo info;
reply.WriteUint32(sizeof(info));
reply.WriteRawData(&info, sizeof(info));
} else {
GTEST_LOG_(INFO) << "OnRemoteRequest, GET_ALL_BUNDLE_RESOURCE_INFO";
reply.WriteInt32(ERR_OK);
std::vector<BundleResourceInfo> infoVector;
BundleResourceInfo item;
infoVector.push_back(item);
infoVector.push_back(item);
infoVector.push_back(item);
WriteVectorToParcel(infoVector, reply);
}
return 0;
}
};
class BundleResourceProxyTest : public testing::Test {
public:
BundleResourceProxyTest() = default;
~BundleResourceProxyTest() = default;
static void SetUpTestCase();
static void TearDownTestCase();
void SetUp();
void TearDown();
private:
};
void BundleResourceProxyTest::SetUpTestCase()
{}
void BundleResourceProxyTest::TearDownTestCase()
{
}
void BundleResourceProxyTest::SetUp()
{}
void BundleResourceProxyTest::TearDown()
{
}
HWTEST_F(BundleResourceProxyTest, GetParceInfo_0100, Function | SmallTest | Level0)
{
GTEST_LOG_(INFO) << "GetParceInfo_0100 start";
sptr<MockStub> stub = new MockStub();
sptr<BundleResourceProxy> proxy = new BundleResourceProxy(stub->AsObject());
BundleResourceInfo info;
ErrCode ret = proxy->GetBundleResourceInfo("com.test.empty", 0, info, 1);
GTEST_LOG_(INFO) << "GetParceInfo_0100 end, " << ret;
ASSERT_EQ(ret, ERR_OK);
}
HWTEST_F(BundleResourceProxyTest, GetVectorParcelInfo_0100, Function | SmallTest | Level0)
{
GTEST_LOG_(INFO) << "GetVectorParcelInfo_0100 start";
sptr<MockStub> stub = new MockStub();
sptr<BundleResourceProxy> proxy = new BundleResourceProxy(stub->AsObject());
std::vector<BundleResourceInfo> info;
ErrCode ret = proxy->GetAllBundleResourceInfo(0, info);
GTEST_LOG_(INFO) << "GetVectorParcelInfo_0100 end, " << ret;
ASSERT_EQ(info.size(), 3);
ASSERT_EQ(ret, ERR_OK);
}
}
}

View File

@ -18,6 +18,7 @@
#include "app_log_wrapper.h"
#include "app_control_interface.h"
#include "bundle_constants.h"
#include "bundle_mgr_interface.h"
#include "bundle_mgr_proxy.h"
#include "bundle_errors.h"
@ -43,6 +44,7 @@ const std::string SET_DISPOSED_STATUS_SYNC = "SetDisposedStatusSync";
const std::string DELETE_DISPOSED_STATUS_SYNC = "DeleteDisposedStatusSync";
const std::string GET_DISPOSED_STATUS_SYNC = "GetDisposedStatusSync";
const std::string APP_ID = "appId";
const std::string APP_INDEX = "appIndex";
const std::string DISPOSED_WANT = "disposedWant";
const std::string DISPOSED_RULE = "disposedRule";
const std::string DISPOSED_RULE_TYPE = "DisposedRule";
@ -303,23 +305,10 @@ napi_value DeleteDisposedStatus(napi_env env, napi_callback_info info)
return promise;
}
napi_value DeleteDisposedStatusSync(napi_env env, napi_callback_info info)
static napi_value InnerDeleteDisposedStatusSync(napi_env env, std::string &appId, int32_t appIndex)
{
APP_LOGD("begin to DeleteDisposedStatusSync.");
NapiArg args(env, info);
napi_value nRet;
napi_get_undefined(env, &nRet);
if (!args.Init(ARGS_SIZE_ONE, ARGS_SIZE_ONE)) {
APP_LOGE("param count invalid.");
BusinessError::ThrowTooFewParametersError(env, ERROR_PARAM_CHECK_ERROR);
return nRet;
}
std::string appId;
if (!CommonFunc::ParseString(env, args[ARGS_POS_ZERO], appId)) {
APP_LOGE("appId %{public}s invalid!", appId.c_str());
BusinessError::ThrowParameterTypeError(env, ERROR_PARAM_CHECK_ERROR, APP_ID, TYPE_STRING);
return nRet;
}
if (appId.size() == 0) {
napi_value businessError = BusinessError::CreateCommonError(
env, ERROR_INVALID_APPID, DELETE_DISPOSED_STATUS_SYNC);
@ -332,17 +321,56 @@ napi_value DeleteDisposedStatusSync(napi_env env, napi_callback_info info)
napi_value error = BusinessError::CreateCommonError(env, ERROR_SYSTEM_ABILITY_NOT_FOUND,
DELETE_DISPOSED_STATUS_SYNC);
napi_throw(env, error);
return nRet;
return nullptr;
}
ErrCode ret = ERR_OK;
if (appIndex == Constants::MAIN_APP_INDEX) {
ret = appControlProxy->DeleteDisposedStatus(appId);
} else {
ret = appControlProxy->DeleteDisposedRuleForCloneApp(appId, appIndex);
}
ErrCode ret = appControlProxy->DeleteDisposedStatus(appId);
ret = CommonFunc::ConvertErrCode(ret);
if (ret != NO_ERROR) {
APP_LOGE("DeleteDisposedStatusSync err = %{public}d", ret);
if (ret != ERR_OK) {
APP_LOGE("DeleteDisposedStatusSync failed");
napi_value businessError = BusinessError::CreateCommonError(
env, ret, DELETE_DISPOSED_STATUS_SYNC, PERMISSION_DISPOSED_STATUS);
napi_throw(env, businessError);
return nullptr;
}
APP_LOGD("call DeleteDisposedStatusSync done.");
return nRet;
}
napi_value DeleteDisposedStatusSync(napi_env env, napi_callback_info info)
{
APP_LOGD("begin to DeleteDisposedStatusSync.");
NapiArg args(env, info);
napi_value nRet;
napi_get_undefined(env, &nRet);
if (!args.Init(ARGS_SIZE_ONE, ARGS_SIZE_TWO)) {
APP_LOGE("param count invalid.");
BusinessError::ThrowTooFewParametersError(env, ERROR_PARAM_CHECK_ERROR);
return nRet;
}
std::string appId;
if (!CommonFunc::ParseString(env, args[ARGS_POS_ZERO], appId)) {
APP_LOGE("appId %{public}s invalid!", appId.c_str());
BusinessError::ThrowParameterTypeError(env, ERROR_PARAM_CHECK_ERROR, APP_ID, TYPE_STRING);
return nRet;
}
if (args.GetMaxArgc() == ARGS_SIZE_ONE) {
return InnerDeleteDisposedStatusSync(env, appId, Constants::MAIN_APP_INDEX);
}
if (args.GetMaxArgc() == ARGS_SIZE_TWO) {
int32_t appIndex;
if (!CommonFunc::ParseInt(env, args[ARGS_POS_ONE], appIndex)) {
APP_LOGE("appIndex invalid!");
BusinessError::ThrowParameterTypeError(env, ERROR_PARAM_CHECK_ERROR, APP_INDEX, TYPE_NUMBER);
return nullptr;
}
return InnerDeleteDisposedStatusSync(env, appId, appIndex);
}
APP_LOGE("parameter is invalid");
BusinessError::ThrowError(env, ERROR_PARAM_CHECK_ERROR, PARAM_TYPE_CHECK_ERROR);
return nRet;
}
@ -586,21 +614,8 @@ bool ParseDiposedRule(napi_env env, napi_value nRule, DisposedRule &rule)
return true;
}
napi_value GetDisposedRule(napi_env env, napi_callback_info info)
static napi_value InnerGetDisposedRule(napi_env env, std::string &appId, int32_t appIndex)
{
APP_LOGD("NAPI GetDisposedRule called");
NapiArg args(env, info);
if (!args.Init(ARGS_SIZE_ONE, ARGS_SIZE_ONE)) {
APP_LOGE("param count invalid.");
BusinessError::ThrowTooFewParametersError(env, ERROR_PARAM_CHECK_ERROR);
return nullptr;
}
std::string appId;
if (!CommonFunc::ParseString(env, args[ARGS_POS_ZERO], appId)) {
APP_LOGE("appId %{public}s invalid!", appId.c_str());
BusinessError::ThrowParameterTypeError(env, ERROR_PARAM_CHECK_ERROR, APP_ID, TYPE_STRING);
return nullptr;
}
if (appId.size() == 0) {
napi_value businessError = BusinessError::CreateCommonError(
env, ERROR_INVALID_APPID, GET_DISPOSED_STATUS_SYNC);
@ -616,7 +631,12 @@ napi_value GetDisposedRule(napi_env env, napi_callback_info info)
return nullptr;
}
DisposedRule disposedRule;
ErrCode ret = appControlProxy->GetDisposedRule(appId, disposedRule);
ErrCode ret = ERR_OK;
if (appIndex == Constants::MAIN_APP_INDEX) {
ret = appControlProxy->GetDisposedRule(appId, disposedRule);
} else {
ret = appControlProxy->GetDisposedRuleForCloneApp(appId, disposedRule, appIndex);
}
ret = CommonFunc::ConvertErrCode(ret);
if (ret != ERR_OK) {
APP_LOGE("GetDisposedStatusSync failed");
@ -631,12 +651,73 @@ napi_value GetDisposedRule(napi_env env, napi_callback_info info)
return nRule;
}
napi_value GetDisposedRule(napi_env env, napi_callback_info info)
{
APP_LOGD("NAPI GetDisposedRule called");
NapiArg args(env, info);
if (!args.Init(ARGS_SIZE_ONE, ARGS_SIZE_TWO)) {
APP_LOGE("param count invalid.");
BusinessError::ThrowTooFewParametersError(env, ERROR_PARAM_CHECK_ERROR);
return nullptr;
}
std::string appId;
if (!CommonFunc::ParseString(env, args[ARGS_POS_ZERO], appId)) {
APP_LOGE("appId %{public}s invalid!", appId.c_str());
BusinessError::ThrowParameterTypeError(env, ERROR_PARAM_CHECK_ERROR, APP_ID, TYPE_STRING);
return nullptr;
}
if (args.GetMaxArgc() == ARGS_SIZE_ONE) {
return InnerGetDisposedRule(env, appId, Constants::MAIN_APP_INDEX);
}
if (args.GetMaxArgc() == ARGS_SIZE_TWO) {
int32_t appIndex;
if (!CommonFunc::ParseInt(env, args[ARGS_POS_ONE], appIndex)) {
APP_LOGE("appIndex invalid!");
BusinessError::ThrowParameterTypeError(env, ERROR_PARAM_CHECK_ERROR, APP_INDEX, TYPE_NUMBER);
return nullptr;
}
return InnerGetDisposedRule(env, appId, appIndex);
}
APP_LOGE("parameter is invalid");
BusinessError::ThrowError(env, ERROR_PARAM_CHECK_ERROR, PARAM_TYPE_CHECK_ERROR);
return nullptr;
}
static napi_value InnerSetDisposedRule(napi_env env, std::string &appId, DisposedRule &rule, int32_t appIndex)
{
napi_value nRet;
napi_get_undefined(env, &nRet);
auto appControlProxy = GetAppControlProxy();
if (appControlProxy == nullptr) {
APP_LOGE("AppControlProxy is null.");
napi_value error = BusinessError::CreateCommonError(env, ERROR_SYSTEM_ABILITY_NOT_FOUND,
SET_DISPOSED_STATUS_SYNC);
napi_throw(env, error);
return nRet;
}
ErrCode ret = ERR_OK;
if (appIndex == Constants::MAIN_APP_INDEX) {
ret = appControlProxy->SetDisposedRule(appId, rule);
} else {
ret = appControlProxy->SetDisposedRuleForCloneApp(appId, rule, appIndex);
}
ret = CommonFunc::ConvertErrCode(ret);
if (ret != NO_ERROR) {
APP_LOGE("SetDisposedStatusSync err = %{public}d", ret);
napi_value businessError = BusinessError::CreateCommonError(
env, ret, SET_DISPOSED_STATUS_SYNC, PERMISSION_DISPOSED_STATUS);
napi_throw(env, businessError);
return nullptr;
}
return nRet;
}
napi_value SetDisposedRule(napi_env env, napi_callback_info info)
{
NapiArg args(env, info);
napi_value nRet;
napi_get_undefined(env, &nRet);
if (!args.Init(ARGS_SIZE_TWO, ARGS_SIZE_TWO)) {
if (!args.Init(ARGS_SIZE_TWO, ARGS_SIZE_THREE)) {
APP_LOGE("Napi func init failed");
BusinessError::ThrowTooFewParametersError(env, ERROR_PARAM_CHECK_ERROR);
return nRet;
@ -659,22 +740,20 @@ napi_value SetDisposedRule(napi_env env, napi_callback_info info)
BusinessError::ThrowParameterTypeError(env, ERROR_PARAM_CHECK_ERROR, DISPOSED_RULE, DISPOSED_RULE_TYPE);
return nRet;
}
auto appControlProxy = GetAppControlProxy();
if (appControlProxy == nullptr) {
APP_LOGE("AppControlProxy is null.");
napi_value error = BusinessError::CreateCommonError(env, ERROR_SYSTEM_ABILITY_NOT_FOUND,
SET_DISPOSED_STATUS_SYNC);
napi_throw(env, error);
return nRet;
if (args.GetMaxArgc() == ARGS_SIZE_TWO) {
return InnerSetDisposedRule(env, appId, rule, Constants::MAIN_APP_INDEX);
}
ErrCode ret = appControlProxy->SetDisposedRule(appId, rule);
ret = CommonFunc::ConvertErrCode(ret);
if (ret != NO_ERROR) {
APP_LOGE("SetDisposedStatusSync err = %{public}d", ret);
napi_value businessError = BusinessError::CreateCommonError(
env, ret, SET_DISPOSED_STATUS_SYNC, PERMISSION_DISPOSED_STATUS);
napi_throw(env, businessError);
if (args.GetMaxArgc() == ARGS_SIZE_THREE) {
int32_t appIndex;
if (!CommonFunc::ParseInt(env, args[ARGS_POS_TWO], appIndex)) {
APP_LOGE("appIndex invalid!");
BusinessError::ThrowParameterTypeError(env, ERROR_PARAM_CHECK_ERROR, APP_INDEX, TYPE_NUMBER);
return nRet;
}
return InnerSetDisposedRule(env, appId, rule, appIndex);
}
APP_LOGE("parameter is invalid");
BusinessError::ThrowError(env, ERROR_PARAM_CHECK_ERROR, PARAM_TYPE_CHECK_ERROR);
return nRet;
}

View File

@ -86,6 +86,8 @@ constexpr ErrCode ERROR_START_SHORTCUT_ERROR = 17700065;
constexpr ErrCode ERROR_INSTALL_NATIVE_FAILED = 17700066;
constexpr ErrCode ERROR_UNINSTALL_NATIVE_FAILED = 17700067;
constexpr ErrCode ERROR_APP_NOT_SUPPORTED_MULTI_TYPE = 17700069;
// bundle service exception
constexpr ErrCode ERROR_BUNDLE_SERVICE_EXCEPTION = 17700101;

View File

@ -140,6 +140,10 @@ constexpr const char* ERR_MSG_NATIVE_INSTALL_FAILED =
"Failed to install the HAP because installing the native package failed.";
constexpr const char* ERR_MSG_NATIVE_UNINSTALL_FAILED =
"Failed to uninstall the HAP because uninstalling the native package failed.";
constexpr const char* ERR_MSG_INVALID_APPINDEX =
"The appIndex is invalid.";
constexpr const char* ERR_MSG_APP_NOT_SUPPORTED_MULTI_TYPE =
"The app does not support the creation of an appClone instance.";
static std::unordered_map<int32_t, const char*> ERR_MSG_MAP = {
{ ERROR_PERMISSION_DENIED_ERROR, ERR_MSG_PERMISSION_DENIED_ERROR },
@ -215,6 +219,8 @@ static std::unordered_map<int32_t, const char*> ERR_MSG_MAP = {
{ ERROR_INSTALL_FAILED_CONTROLLED, ERR_MSG_INSTALL_FAILED_CONTROLLED },
{ ERROR_INSTALL_NATIVE_FAILED, ERR_MSG_NATIVE_INSTALL_FAILED },
{ ERROR_UNINSTALL_NATIVE_FAILED, ERR_MSG_NATIVE_UNINSTALL_FAILED },
{ ERROR_INVALID_APPINDEX, ERR_MSG_INVALID_APPINDEX },
{ ERROR_APP_NOT_SUPPORTED_MULTI_TYPE, ERR_MSG_APP_NOT_SUPPORTED_MULTI_TYPE },
};
} // namespace

View File

@ -167,9 +167,11 @@ static std::unordered_map<int32_t, int32_t> ERR_MAP = {
{ ERR_APPEXECFWK_INSTALL_FAILED_CONTROLLED, ERROR_INSTALL_FAILED_CONTROLLED },
{ ERR_APPEXECFWK_CLONE_INSTALL_APP_INDEX_EXCEED_MAX_NUMBER, ERROR_INVALID_APPINDEX },
{ ERR_APPEXECFWK_SANDBOX_INSTALL_INVALID_APP_INDEX, ERROR_INVALID_APPINDEX },
{ ERR_APPEXECFWK_CLONE_INSTALL_APP_NOT_SUPPORTED_MULTI_TYPE, ERROR_BUNDLE_NOT_EXIST },
{ ERR_APPEXECFWK_CLONE_INSTALL_APP_NOT_SUPPORTED_MULTI_TYPE, ERROR_APP_NOT_SUPPORTED_MULTI_TYPE },
{ ERR_APPEXECFWK_NATIVE_INSTALL_FAILED, ERROR_INSTALL_NATIVE_FAILED},
{ ERR_APPEXECFWK_NATIVE_UNINSTALL_FAILED, ERROR_UNINSTALL_NATIVE_FAILED},
{ ERR_APPEXECFWK_APP_INDEX_OUT_OF_RANGE, ERROR_INVALID_APPINDEX},
{ ERR_APPEXECFWK_CLONE_QUERY_NO_CLONE_APP, ERROR_INVALID_APPINDEX },
};
}
using Want = OHOS::AAFwk::Want;

View File

@ -467,6 +467,7 @@ ohos_shared_library("installs") {
external_deps = [
"access_token:el5_filekey_manager_sdk",
"appspawn:hnpapi",
"bounds_checking_function:libsec_shared",
"eventhandler:libeventhandler",
"hilog:libhilog",
"hitrace:hitrace_meter",

View File

@ -74,21 +74,24 @@ public:
void SetAppInstallControlStatus();
ErrCode SetDisposedRule(const std::string &callerName,
const std::string &appId, const DisposedRule &DisposedRule, int32_t userId);
ErrCode SetDisposedRule(const std::string &callerName, const std::string &appId,
const DisposedRule &DisposedRule, int32_t appIndex, int32_t userId);
ErrCode GetDisposedRule(const std::string &callerName,
const std::string &appId, DisposedRule &DisposedRule, int32_t userId);
ErrCode GetDisposedRule(const std::string &callerName, const std::string &appId,
DisposedRule &DisposedRule, int32_t appIndex, int32_t userId);
ErrCode DeleteDisposedRule(const std::string &callerName, const std::string &appId, int32_t userId);
ErrCode DeleteDisposedRule(const std::string &callerName, const std::string &appId,
int32_t appIndex, int32_t userId);
ErrCode GetAbilityRunningControlRule(
const std::string &bundleName, int32_t userId, std::vector<DisposedRule>& disposedRules);
ErrCode GetAbilityRunningControlRule(const std::string &bundleName, int32_t appIndex, int32_t userId,
std::vector<DisposedRule>& disposedRules);
ErrCode DeleteAllDisposedRuleByBundle(const std::string &appId, int32_t userId);
ErrCode DeleteAllDisposedRuleByBundle(const InnerBundleInfo &bundleInfo, int32_t appIndex, int32_t userId);
private:
void KillRunningApp(const std::vector<AppRunningControlRule> &rules, int32_t userId) const;
void DeleteAppRunningRuleCache(std::string &key);
void DeleteAbilityRunningRuleCache(std::string &key);
bool isAppInstallControlEnabled_ = false;
std::shared_ptr<IAppControlManagerDb> appControlManagerDb_;

View File

@ -56,14 +56,14 @@ public:
virtual ErrCode GetDisposedStatus(const std::string &callingNmae,
const std::string &appId, Want& want, int32_t userId) = 0;
virtual ErrCode SetDisposedRule(const std::string &callingName,
const std::string &appId, const DisposedRule& rule, int32_t userId) = 0;
const std::string &appId, const DisposedRule& rule, int32_t appIndex, int32_t userId) = 0;
virtual ErrCode GetDisposedRule(const std::string &callingName,
const std::string &appId, DisposedRule& rule, int32_t userId) = 0;
const std::string &appId, DisposedRule& rule, int32_t appIndex, int32_t userId) = 0;
virtual ErrCode DeleteDisposedRule(const std::string &callingName,
const std::string &appId, int32_t userId) = 0;
virtual ErrCode GetAbilityRunningControlRule(
const std::string &bundleName, int32_t userId, std::vector<DisposedRule>& disposedRules) = 0;
virtual ErrCode DeleteAllDisposedRuleByBundle(const std::string &appId, int32_t userId) = 0;
const std::string &appId, int32_t appIndex, int32_t userId) = 0;
virtual ErrCode GetAbilityRunningControlRule(const std::string &bundleName, int32_t appIndex, int32_t userId,
std::vector<DisposedRule>& disposedRules) = 0;
virtual ErrCode DeleteAllDisposedRuleByBundle(const std::string &appId, int32_t appIndex, int32_t userId) = 0;
};
} // namespace AppExecFwk
} // namespace OHOS

View File

@ -77,6 +77,15 @@ public:
virtual ErrCode GetAbilityRunningControlRule(
const std::string &bundleName, int32_t userId, std::vector<DisposedRule>& disposedRules) override;
virtual ErrCode SetDisposedRuleForCloneApp(
const std::string &appId, DisposedRule &DisposedRule, int32_t appIndex, int32_t userId) override;
virtual ErrCode GetDisposedRuleForCloneApp(
const std::string &appId, DisposedRule &DisposedRule, int32_t appIndex, int32_t userId) override;
virtual ErrCode DeleteDisposedRuleForCloneApp(
const std::string &appId, int32_t appIndex, int32_t userId) override;
private:
int32_t GetCallingUserId();

View File

@ -53,15 +53,14 @@ public:
virtual ErrCode GetDisposedStatus(const std::string &callingName,
const std::string &appId, Want& want, int32_t userId) override;
virtual ErrCode SetDisposedRule(const std::string &callingName,
const std::string &appId, const DisposedRule& rule, int32_t userId) override;
const std::string &appId, const DisposedRule& rule, int32_t appIndex, int32_t userId) override;
virtual ErrCode GetDisposedRule(const std::string &callingName,
const std::string &appId, DisposedRule& rule, int32_t userId) override;
const std::string &appId, DisposedRule& rule, int32_t appIndex, int32_t userId) override;
virtual ErrCode DeleteDisposedRule(const std::string &callingName,
const std::string &appId, int32_t userId) override;
virtual ErrCode DeleteAllDisposedRuleByBundle(const std::string &appId, int32_t userId) override;
virtual ErrCode GetAbilityRunningControlRule(
const std::string &bundleName, int32_t userId, std::vector<DisposedRule>& disposedRules) override;
const std::string &appId, int32_t appIndex, int32_t userId) override;
virtual ErrCode DeleteAllDisposedRuleByBundle(const std::string &appId, int32_t appIndex, int32_t userId) override;
virtual ErrCode GetAbilityRunningControlRule(const std::string &bundleName, int32_t appIndex, int32_t userId,
std::vector<DisposedRule>& disposedRules) override;
private:
ErrCode DeleteOldControlRule(const std::string &callingName, const std::string &controlRuleType,

View File

@ -77,8 +77,8 @@ public:
const SandboxInstallType &type);
void NotifyOverlayModuleStateStatus(const std::string &bundleName, const std::string &moduleName, bool isEnabled,
int32_t userId, int32_t uid);
void NotifySetDiposedRule(const std::string &appId, int32_t userId, const std::string &data);
void NotifyDeleteDiposedRule(const std::string &appId, int32_t userId);
void NotifySetDiposedRule(const std::string &appId, int32_t userId, const std::string &data, int32_t appIndex);
void NotifyDeleteDiposedRule(const std::string &appId, int32_t userId, int32_t appIndex);
void NotifyDynamicIconEvent(
const std::string &bundleName, bool isEnableDynamicIcon);
void NotifyBundleResourcesChanged(int32_t userId);

View File

@ -787,7 +787,10 @@ public:
virtual std::string GetAppType(const std::string &bundleName) override;
virtual int GetUidByBundleName(const std::string &bundleName, const int userId) override;
virtual int32_t GetUidByBundleName(const std::string &bundleName, const int32_t userId) override;
virtual int32_t GetUidByBundleName(const std::string &bundleName, const int32_t userId,
int32_t appIndex) override;
virtual int GetUidByDebugBundleName(const std::string &bundleName, const int userId) override;

View File

@ -36,6 +36,9 @@ public:
virtual ErrCode GetAllLauncherAbilityResourceInfo(const uint32_t flags,
std::vector<LauncherAbilityResourceInfo> &launcherAbilityResourceInfos) override;
private:
ErrCode CheckBundleNameValid(const std::string &bundleName, int32_t appIndex);
};
} // AppExecFwk
} // OHOS

View File

@ -88,6 +88,8 @@ public:
bool AddCloneBundleResourceInfo(const std::string &bundleName, const int32_t appIndex);
bool AddCloneBundleResourceInfo(const std::string &bundleName, const std::vector<int32_t> appIndexes);
bool DeleteCloneBundleResourceInfo(const std::string &bundleName, const int32_t appIndex);
private:
@ -111,6 +113,9 @@ private:
void InnerProcessResourceInfos(std::map<std::string, std::vector<ResourceInfo>> &resourceInfosMap,
std::vector<ResourceInfo> &resourceInfos);
bool GetBundleResourceInfoForCloneBundle(const std::string &bundleName,
const int32_t appIndex, std::vector<ResourceInfo> &resourceInfos);
std::shared_ptr<BundleResourceRdb> bundleResourceRdb_;
std::mutex mutex_;
std::atomic_uint currentTaskNum_ = 0;

View File

@ -59,6 +59,7 @@ public:
std::vector<uint8_t> background_;
// for app clone
int32_t appIndex_ = 0;
std::vector<int32_t> appIndexes_;
private:
void InnerParseAppIndex(const std::string &key);

View File

@ -28,6 +28,7 @@
#include "bundle_constants.h"
#include "bundle_info.h"
#include "bundle_mgr_service.h"
#include "bundle_service_constants.h"
#include "parameters.h"
namespace OHOS {
@ -229,7 +230,7 @@ ErrCode AppControlManager::SetDisposedStatus(const std::string &appId, const Wan
if (iter != appRunningControlRuleResult_.end()) {
appRunningControlRuleResult_.erase(iter);
}
commonEventMgr_->NotifySetDiposedRule(appId, userId, want.ToString());
commonEventMgr_->NotifySetDiposedRule(appId, userId, want.ToString(), Constants::MAIN_APP_INDEX);
return ERR_OK;
}
@ -246,7 +247,7 @@ ErrCode AppControlManager::DeleteDisposedStatus(const std::string &appId, int32_
if (iter != appRunningControlRuleResult_.end()) {
appRunningControlRuleResult_.erase(iter);
}
commonEventMgr_->NotifyDeleteDiposedRule(appId, userId);
commonEventMgr_->NotifyDeleteDiposedRule(appId, userId, Constants::MAIN_APP_INDEX);
return ERR_OK;
}
@ -333,15 +334,15 @@ void AppControlManager::SetAppInstallControlStatus()
}
}
ErrCode AppControlManager::SetDisposedRule(
const std::string &callerName, const std::string &appId, const DisposedRule& rule, int32_t userId)
ErrCode AppControlManager::SetDisposedRule(const std::string &callerName, const std::string &appId,
const DisposedRule& rule, int32_t appIndex, int32_t userId)
{
auto ret = appControlManagerDb_->SetDisposedRule(callerName, appId, rule, userId);
auto ret = appControlManagerDb_->SetDisposedRule(callerName, appId, rule, appIndex, userId);
if (ret != ERR_OK) {
LOG_E(BMS_TAG_APP_CONTROL, "SetDisposedStatus to rdb failed");
return ret;
}
std::string key = appId + std::string("_") + std::to_string(userId);
std::string key = appId + std::string("_") + std::to_string(userId) + std::string("_") + std::to_string(appIndex);
{
std::lock_guard<std::mutex> lock(abilityRunningControlRuleMutex_);
auto iter = abilityRunningControlRuleCache_.find(key);
@ -349,14 +350,14 @@ ErrCode AppControlManager::SetDisposedRule(
abilityRunningControlRuleCache_.erase(iter);
}
}
commonEventMgr_->NotifySetDiposedRule(appId, userId, rule.ToString());
commonEventMgr_->NotifySetDiposedRule(appId, userId, rule.ToString(), appIndex);
return ERR_OK;
}
ErrCode AppControlManager::GetDisposedRule(
const std::string &callerName, const std::string &appId, DisposedRule& rule, int32_t userId)
const std::string &callerName, const std::string &appId, DisposedRule& rule, int32_t appIndex, int32_t userId)
{
auto ret = appControlManagerDb_->GetDisposedRule(callerName, appId, rule, userId);
auto ret = appControlManagerDb_->GetDisposedRule(callerName, appId, rule, appIndex, userId);
if (ret != ERR_OK) {
LOG_E(BMS_TAG_APP_CONTROL, "GetDisposedRule to rdb failed");
return ret;
@ -365,14 +366,14 @@ ErrCode AppControlManager::GetDisposedRule(
}
ErrCode AppControlManager::DeleteDisposedRule(
const std::string &callerName, const std::string &appId, int32_t userId)
const std::string &callerName, const std::string &appId, int32_t appIndex, int32_t userId)
{
auto ret = appControlManagerDb_->DeleteDisposedRule(callerName, appId, userId);
auto ret = appControlManagerDb_->DeleteDisposedRule(callerName, appId, appIndex, userId);
if (ret != ERR_OK) {
LOG_E(BMS_TAG_APP_CONTROL, "DeleteDisposedRule to rdb failed");
return ret;
}
std::string key = appId + std::string("_") + std::to_string(userId);
std::string key = appId + std::string("_") + std::to_string(userId) + std::string("_") + std::to_string(appIndex);
{
std::lock_guard<std::mutex> lock(abilityRunningControlRuleMutex_);
auto iter = abilityRunningControlRuleCache_.find(key);
@ -380,36 +381,64 @@ ErrCode AppControlManager::DeleteDisposedRule(
abilityRunningControlRuleCache_.erase(iter);
}
}
commonEventMgr_->NotifyDeleteDiposedRule(appId, userId);
commonEventMgr_->NotifyDeleteDiposedRule(appId, userId, appIndex);
return ERR_OK;
}
ErrCode AppControlManager::DeleteAllDisposedRuleByBundle(const std::string &appId, int32_t userId)
ErrCode AppControlManager::DeleteAllDisposedRuleByBundle(const InnerBundleInfo &bundleInfo, int32_t appIndex,
int32_t userId)
{
auto ret = appControlManagerDb_->DeleteAllDisposedRuleByBundle(appId, userId);
std::string appId = bundleInfo.GetAppId();
auto ret = appControlManagerDb_->DeleteAllDisposedRuleByBundle(appId, appIndex, userId);
if (ret != ERR_OK) {
LOG_E(BMS_TAG_APP_CONTROL, "DeleteAllDisposedRuleByBundle to rdb failed");
return ret;
}
std::string key = appId + std::string("_") + std::to_string(userId);
DeleteAppRunningRuleCache(key);
key = key + std::string("_");
std::string cacheKey = key + std::to_string(appIndex);
DeleteAbilityRunningRuleCache(cacheKey);
commonEventMgr_->NotifyDeleteDiposedRule(appId, userId, appIndex);
if (appIndex != Constants::MAIN_APP_INDEX) {
return ERR_OK;
}
// if appIndex is main app clear all clone app cache
auto dataMgr = DelayedSingleton<BundleMgrService>::GetInstance()->GetDataMgr();
if (dataMgr == nullptr) {
LOG_E(BMS_TAG_APP_CONTROL, "DataMgr is nullptr");
return ERR_BUNDLE_MANAGER_INTERNAL_ERROR;
}
std::string bundleName = bundleInfo.GetBundleName();
std::vector<int32_t> appIndexVec = dataMgr->GetCloneAppIndexes(bundleName, Constants::ALL_USERID);
for (const int32_t index : appIndexVec) {
std::string ruleCacheKey = key + std::to_string(index);
DeleteAbilityRunningRuleCache(ruleCacheKey);
commonEventMgr_->NotifyDeleteDiposedRule(appId, userId, index);
}
return ERR_OK;
}
void AppControlManager::DeleteAppRunningRuleCache(std::string &key)
{
std::lock_guard<std::mutex> lock(appRunningControlMutex_);
auto iter = appRunningControlRuleResult_.find(key);
if (iter != appRunningControlRuleResult_.end()) {
appRunningControlRuleResult_.erase(iter);
}
{
std::lock_guard<std::mutex> cacheLock(abilityRunningControlRuleMutex_);
auto cacheIter = abilityRunningControlRuleCache_.find(key);
if (cacheIter != abilityRunningControlRuleCache_.end()) {
abilityRunningControlRuleCache_.erase(cacheIter);
}
}
void AppControlManager::DeleteAbilityRunningRuleCache(std::string &key)
{
std::lock_guard<std::mutex> cacheLock(abilityRunningControlRuleMutex_);
auto cacheIter = abilityRunningControlRuleCache_.find(key);
if (cacheIter != abilityRunningControlRuleCache_.end()) {
abilityRunningControlRuleCache_.erase(cacheIter);
}
commonEventMgr_->NotifyDeleteDiposedRule(appId, userId);
return ERR_OK;
}
ErrCode AppControlManager::GetAbilityRunningControlRule(
const std::string &bundleName, int32_t userId, std::vector<DisposedRule>& disposedRules)
const std::string &bundleName, int32_t appIndex, int32_t userId, std::vector<DisposedRule> &disposedRules)
{
auto dataMgr = DelayedSingleton<BundleMgrService>::GetInstance()->GetDataMgr();
if (dataMgr == nullptr) {
@ -417,20 +446,31 @@ ErrCode AppControlManager::GetAbilityRunningControlRule(
return ERR_BUNDLE_MANAGER_INTERNAL_ERROR;
}
BundleInfo bundleInfo;
ErrCode ret = dataMgr->GetBundleInfoV9(bundleName,
ErrCode ret = ERR_OK;
if (appIndex == Constants::MAIN_APP_INDEX) {
ret = dataMgr->GetBundleInfoV9(bundleName,
static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_DISABLE), bundleInfo, userId);
if (ret != ERR_OK) {
LOG_W(BMS_TAG_APP_CONTROL, "DataMgr GetBundleInfoV9 failed");
return ret;
if (ret != ERR_OK) {
LOG_W(BMS_TAG_APP_CONTROL, "DataMgr GetBundleInfoV9 failed");
return ret;
}
} else {
ret = dataMgr->GetCloneBundleInfo(bundleName,
static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_DISABLE), appIndex, bundleInfo, userId);
if (ret != ERR_OK) {
LOG_W(BMS_TAG_APP_CONTROL, "DataMgr GetBundleInfoV9 failed");
return ret;
}
}
std::string key = bundleInfo.appId + std::string("_") + std::to_string(userId);
std::string key = bundleInfo.appId + std::string("_") + std::to_string(userId) + std::string("_")
+ std::to_string(appIndex);
std::lock_guard<std::mutex> lock(abilityRunningControlRuleMutex_);
auto iter = abilityRunningControlRuleCache_.find(key);
if (iter != abilityRunningControlRuleCache_.end()) {
disposedRules = iter->second;
return ERR_OK;
}
ret = appControlManagerDb_->GetAbilityRunningControlRule(bundleInfo.appId, userId, disposedRules);
ret = appControlManagerDb_->GetAbilityRunningControlRule(bundleInfo.appId, appIndex, userId, disposedRules);
if (ret != ERR_OK) {
LOG_W(BMS_TAG_APP_CONTROL, "GetAbilityRunningControlRule from rdb failed");
return ret;

View File

@ -21,6 +21,7 @@
#include "app_control_constants.h"
#include "bundle_mgr_service.h"
#include "bundle_permission_mgr.h"
#include "bundle_service_constants.h"
#include "ipc_skeleton.h"
namespace OHOS {
@ -327,7 +328,7 @@ ErrCode AppControlManagerHostImpl::DeleteDisposedStatus(const std::string &appId
if (userId == Constants::UNSPECIFIED_USERID) {
userId = GetCallingUserId();
}
ret = appControlManager_->DeleteDisposedRule(callerName, appId, userId);
ret = appControlManager_->DeleteDisposedRule(callerName, appId, Constants::MAIN_APP_INDEX, userId);
return ret;
}
@ -409,7 +410,7 @@ ErrCode AppControlManagerHostImpl::GetDisposedRule(const std::string &appId, Dis
if (userId == Constants::UNSPECIFIED_USERID) {
userId = GetCallingUserId();
}
auto ret = appControlManager_->GetDisposedRule(callerName, appId, rule, userId);
auto ret = appControlManager_->GetDisposedRule(callerName, appId, rule, Constants::MAIN_APP_INDEX, userId);
if (ret != ERR_OK) {
LOG_W(BMS_TAG_APP_CONTROL, "host GetDisposedStatus error:%{public}d", ret);
}
@ -437,7 +438,7 @@ ErrCode AppControlManagerHostImpl::SetDisposedRule(const std::string &appId, Dis
if (userId == Constants::UNSPECIFIED_USERID) {
userId = GetCallingUserId();
}
auto ret = appControlManager_->SetDisposedRule(callerName, appId, rule, userId);
auto ret = appControlManager_->SetDisposedRule(callerName, appId, rule, Constants::MAIN_APP_INDEX, userId);
if (ret != ERR_OK) {
LOG_W(BMS_TAG_APP_CONTROL, "host GetDisposedStatus error:%{public}d", ret);
}
@ -452,7 +453,107 @@ ErrCode AppControlManagerHostImpl::GetAbilityRunningControlRule(
LOG_E(BMS_TAG_APP_CONTROL, "callingName is invalid, uid : %{public}d", uid);
return ERR_BUNDLE_MANAGER_PERMISSION_DENIED;
}
return appControlManager_->GetAbilityRunningControlRule(bundleName, userId, disposedRules);
return appControlManager_->GetAbilityRunningControlRule(bundleName, Constants::MAIN_APP_INDEX, userId,
disposedRules);
}
ErrCode AppControlManagerHostImpl::GetDisposedRuleForCloneApp(const std::string &appId, DisposedRule &rule,
int32_t appIndex, int32_t userId)
{
LOG_D(BMS_TAG_APP_CONTROL, "host begin to GetDisposedRuleForCloneApp");
if (!BundlePermissionMgr::IsSystemApp()) {
LOG_E(BMS_TAG_APP_CONTROL, "non-system app calling system api");
return ERR_BUNDLE_MANAGER_SYSTEM_API_DENIED;
}
if (!BundlePermissionMgr::VerifyCallingPermissionForAll(PERMISSION_DISPOSED_STATUS)) {
LOG_W(BMS_TAG_APP_CONTROL, "verify permission ohos.permission.MANAGE_DISPOSED_STATUS failed");
return ERR_BUNDLE_MANAGER_PERMISSION_DENIED;
}
if (appIndex < Constants::MAIN_APP_INDEX || appIndex > Constants::CLONE_APP_INDEX_MAX) {
LOG_E(BMS_TAG_APP_CONTROL, "appIndex %{public}d is invalid", appIndex);
return ERR_APPEXECFWK_APP_INDEX_OUT_OF_RANGE;
}
int32_t uid = OHOS::IPCSkeleton::GetCallingUid();
std::string callerName;
GetCallerByUid(uid, callerName);
if (userId == Constants::UNSPECIFIED_USERID) {
userId = GetCallingUserId();
}
auto ret = appControlManager_->GetDisposedRule(callerName, appId, rule, appIndex, userId);
if (ret != ERR_OK) {
LOG_W(BMS_TAG_APP_CONTROL, "GetDisposedRuleForCloneApp error:%{public}d, appIndex:%{public}d", ret, appIndex);
}
return ret;
}
ErrCode AppControlManagerHostImpl::SetDisposedRuleForCloneApp(const std::string &appId, DisposedRule &rule,
int32_t appIndex, int32_t userId)
{
LOG_D(BMS_TAG_APP_CONTROL, "host begin to SetDisposedRuleForCloneApp");
if (!BundlePermissionMgr::IsSystemApp()) {
LOG_E(BMS_TAG_APP_CONTROL, "non-system app calling system api");
return ERR_BUNDLE_MANAGER_SYSTEM_API_DENIED;
}
if (!BundlePermissionMgr::VerifyCallingPermissionForAll(PERMISSION_DISPOSED_STATUS)) {
LOG_W(BMS_TAG_APP_CONTROL, "verify permission ohos.permission.MANAGE_DISPOSED_STATUS failed");
return ERR_BUNDLE_MANAGER_PERMISSION_DENIED;
}
if (appIndex < Constants::MAIN_APP_INDEX || appIndex > Constants::CLONE_APP_INDEX_MAX) {
LOG_E(BMS_TAG_APP_CONTROL, "appIndex %{public}d is invalid", appIndex);
return ERR_APPEXECFWK_APP_INDEX_OUT_OF_RANGE;
}
int32_t uid = OHOS::IPCSkeleton::GetCallingUid();
std::string callerName;
GetCallerByUid(uid, callerName);
if (uid == AppControlConstants::EDM_UID) {
rule.isEdm = true;
}
if (userId == Constants::UNSPECIFIED_USERID) {
userId = GetCallingUserId();
}
auto ret = appControlManager_->SetDisposedRule(callerName, appId, rule, appIndex, userId);
if (ret != ERR_OK) {
LOG_W(BMS_TAG_APP_CONTROL, "SetDisposedRuleForCloneApp error:%{public}d, appIndex:%{public}d", ret, appIndex);
}
return ret;
}
ErrCode AppControlManagerHostImpl::DeleteDisposedRuleForCloneApp(const std::string &appId, int32_t appIndex,
int32_t userId)
{
LOG_D(BMS_TAG_APP_CONTROL, "host begin to DeleteDisposedRuleForCloneApp");
if (!BundlePermissionMgr::IsSystemApp()) {
LOG_E(BMS_TAG_APP_CONTROL, "non-system app calling system api");
return ERR_BUNDLE_MANAGER_SYSTEM_API_DENIED;
}
if (!BundlePermissionMgr::VerifyCallingPermissionForAll(PERMISSION_DISPOSED_STATUS)) {
LOG_W(BMS_TAG_APP_CONTROL, "verify permission ohos.permission.MANAGE_DISPOSED_STATUS failed");
return ERR_BUNDLE_MANAGER_PERMISSION_DENIED;
}
if (appIndex < Constants::MAIN_APP_INDEX || appIndex > Constants::CLONE_APP_INDEX_MAX) {
LOG_E(BMS_TAG_APP_CONTROL, "appIndex %{public}d is invalid", appIndex);
return ERR_APPEXECFWK_APP_INDEX_OUT_OF_RANGE;
}
if (userId == Constants::UNSPECIFIED_USERID) {
userId = GetCallingUserId();
}
ErrCode ret = ERR_OK;
if (appIndex == Constants::MAIN_APP_INDEX) {
ret = appControlManager_->DeleteDisposedStatus(appId, userId);
if (ret != ERR_OK) {
LOG_W(BMS_TAG_APP_CONTROL, "DeleteDisposedStatus error:%{public}d", ret);
}
}
int32_t uid = OHOS::IPCSkeleton::GetCallingUid();
std::string callerName;
GetCallerByUid(uid, callerName);
if (userId == Constants::UNSPECIFIED_USERID) {
userId = GetCallingUserId();
}
ret = appControlManager_->DeleteDisposedRule(callerName, appId, appIndex, userId);
if (ret != ERR_OK) {
LOG_W(BMS_TAG_APP_CONTROL, "DeleteDisposedRule error:%{public}d, appIndex:%{public}d", ret, appIndex);
}
return ret;
}
} // AppExecFwk
} // OHOS

View File

@ -43,6 +43,7 @@ namespace {
const std::string DISPOSED_STATUS = "DISPOSED_STATUS";
const std::string PRIORITY = "PRIORITY";
const std::string TIME_STAMP = "TIME_STAMP";
const std::string APP_INDEX = "APP_INDEX";
enum class PRIORITY {
EDM = 100,
@ -61,6 +62,8 @@ AppControlManagerRdb::AppControlManagerRdb()
+ "(ID INTEGER PRIMARY KEY AUTOINCREMENT, CALLING_NAME TEXT NOT NULL, "
+ "APP_CONTROL_LIST TEXT, USER_ID INTEGER, APP_ID TEXT, CONTROL_MESSAGE TEXT, "
+ "DISPOSED_STATUS TEXT, PRIORITY INTEGER, TIME_STAMP INTEGER);");
bmsRdbConfig.insertColumnSql.push_back(std::string("ALTER TABLE " + APP_CONTROL_RDB_TABLE_NAME +
" ADD APP_INDEX INTEGER DEFAULT 0;"));
rdbDataManager_ = std::make_shared<RdbDataManager>(bmsRdbConfig);
rdbDataManager_->CreateTable();
}
@ -442,9 +445,9 @@ ErrCode AppControlManagerRdb::DeleteOldControlRule(const std::string &callingNam
}
ErrCode AppControlManagerRdb::SetDisposedRule(const std::string &callingName,
const std::string &appId, const DisposedRule &rule, int32_t userId)
const std::string &appId, const DisposedRule &rule, int32_t appIndex, int32_t userId)
{
ErrCode code = DeleteDisposedRule(callingName, appId, userId);
ErrCode code = DeleteDisposedRule(callingName, appId, appIndex, userId);
if (code != ERR_OK) {
LOG_E(BMS_TAG_APP_CONTROL, "DeleteDisposedStatus failed.");
return ERR_BUNDLE_MANAGER_APP_CONTROL_INTERNAL_ERROR;
@ -458,6 +461,7 @@ ErrCode AppControlManagerRdb::SetDisposedRule(const std::string &callingName,
valuesBucket.PutInt(PRIORITY, rule.priority);
valuesBucket.PutInt(TIME_STAMP, timeStamp);
valuesBucket.PutString(USER_ID, std::to_string(userId));
valuesBucket.PutString(APP_INDEX, std::to_string(appIndex));
bool ret = rdbDataManager_->InsertData(valuesBucket);
if (!ret) {
LOG_E(BMS_TAG_APP_CONTROL, "SetDisposedStatus callingName:%{public}s appId:%{public}s failed.",
@ -468,13 +472,14 @@ ErrCode AppControlManagerRdb::SetDisposedRule(const std::string &callingName,
}
ErrCode AppControlManagerRdb::DeleteDisposedRule(const std::string &callingName,
const std::string &appId, int32_t userId)
const std::string &appId, int32_t appIndex, int32_t userId)
{
NativeRdb::AbsRdbPredicates absRdbPredicates(APP_CONTROL_RDB_TABLE_NAME);
absRdbPredicates.EqualTo(CALLING_NAME, callingName);
absRdbPredicates.EqualTo(APP_CONTROL_LIST, DISPOSED_RULE);
absRdbPredicates.EqualTo(APP_ID, appId);
absRdbPredicates.EqualTo(USER_ID, std::to_string(userId));
absRdbPredicates.EqualTo(APP_INDEX, std::to_string(appIndex));
bool ret = rdbDataManager_->DeleteData(absRdbPredicates);
if (!ret) {
LOG_E(BMS_TAG_APP_CONTROL, "DeleteDisposedStatus callingName:%{public}s appId:%{public}s failed.",
@ -484,13 +489,17 @@ ErrCode AppControlManagerRdb::DeleteDisposedRule(const std::string &callingName,
return ERR_OK;
}
ErrCode AppControlManagerRdb::DeleteAllDisposedRuleByBundle(const std::string &appId, int32_t userId)
ErrCode AppControlManagerRdb::DeleteAllDisposedRuleByBundle(const std::string &appId, int32_t appIndex, int32_t userId)
{
NativeRdb::AbsRdbPredicates absRdbPredicates(APP_CONTROL_RDB_TABLE_NAME);
std::vector<std::string> controlList = {DISPOSED_RULE, RUNNING_CONTROL};
absRdbPredicates.In(APP_CONTROL_LIST, controlList);
absRdbPredicates.EqualTo(APP_ID, appId);
absRdbPredicates.EqualTo(USER_ID, std::to_string(userId));
// if appIndex is main app also clear all clone app
if (appIndex != Constants::MAIN_APP_INDEX) {
absRdbPredicates.EqualTo(APP_INDEX, std::to_string(appIndex));
}
bool ret = rdbDataManager_->DeleteData(absRdbPredicates);
if (!ret) {
LOG_E(BMS_TAG_APP_CONTROL, "DeleteAllDisposedRuleByBundle appId:%{public}s failed.", appId.c_str());
@ -500,7 +509,7 @@ ErrCode AppControlManagerRdb::DeleteAllDisposedRuleByBundle(const std::string &a
}
ErrCode AppControlManagerRdb::GetDisposedRule(const std::string &callingName,
const std::string &appId, DisposedRule &rule, int32_t userId)
const std::string &appId, DisposedRule &rule, int32_t appIndex, int32_t userId)
{
LOG_D(BMS_TAG_APP_CONTROL, "rdb begin to GetDisposedRule");
NativeRdb::AbsRdbPredicates absRdbPredicates(APP_CONTROL_RDB_TABLE_NAME);
@ -508,6 +517,7 @@ ErrCode AppControlManagerRdb::GetDisposedRule(const std::string &callingName,
absRdbPredicates.EqualTo(APP_CONTROL_LIST, DISPOSED_RULE);
absRdbPredicates.EqualTo(APP_ID, appId);
absRdbPredicates.EqualTo(USER_ID, std::to_string(userId));
absRdbPredicates.EqualTo(APP_INDEX, std::to_string(appIndex));
auto absSharedResultSet = rdbDataManager_->QueryData(absRdbPredicates);
if (absSharedResultSet == nullptr) {
LOG_E(BMS_TAG_APP_CONTROL, "GetAppInstallControlRule failed.");
@ -540,13 +550,14 @@ ErrCode AppControlManagerRdb::GetDisposedRule(const std::string &callingName,
}
ErrCode AppControlManagerRdb::GetAbilityRunningControlRule(
const std::string &appId, int32_t userId, std::vector<DisposedRule>& disposedRules)
const std::string &appId, int32_t appIndex, int32_t userId, std::vector<DisposedRule>& disposedRules)
{
LOG_D(BMS_TAG_APP_CONTROL, "rdb begin to GetAbilityRunningControlRule");
NativeRdb::AbsRdbPredicates absRdbPredicates(APP_CONTROL_RDB_TABLE_NAME);
absRdbPredicates.EqualTo(APP_CONTROL_LIST, DISPOSED_RULE);
absRdbPredicates.EqualTo(APP_ID, appId);
absRdbPredicates.EqualTo(USER_ID, std::to_string(userId));
absRdbPredicates.EqualTo(APP_INDEX, std::to_string(appIndex));
absRdbPredicates.OrderByAsc(PRIORITY); // ascending
auto absSharedResultSet = rdbDataManager_->QueryData(absRdbPredicates);
if (absSharedResultSet == nullptr) {

View File

@ -306,6 +306,7 @@ ErrCode BaseBundleInstaller::Recover(
ErrCode BaseBundleInstaller::UninstallBundle(const std::string &bundleName, const InstallParam &installParam)
{
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
APP_LOGI("begin to process %{public}s bundle uninstall", bundleName.c_str());
PerfProfile::GetInstance().SetBundleUninstallStartTime(GetTickCount());
@ -502,6 +503,7 @@ ErrCode BaseBundleInstaller::UninstallHspVersion(std::string &uninstallDir, int3
ErrCode BaseBundleInstaller::UninstallBundle(
const std::string &bundleName, const std::string &modulePackage, const InstallParam &installParam)
{
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
APP_LOGI("begin to process %{public}s module in %{public}s uninstall", modulePackage.c_str(), bundleName.c_str());
PerfProfile::GetInstance().SetBundleUninstallStartTime(GetTickCount());
@ -1415,7 +1417,7 @@ ErrCode BaseBundleInstaller::ProcessBundleUninstall(
std::shared_ptr<AppControlManager> appControlMgr = DelayedSingleton<AppControlManager>::GetInstance();
if (appControlMgr != nullptr) {
APP_LOGD("Delete disposed rule when bundleName :%{public}s uninstall", bundleName.c_str());
appControlMgr->DeleteAllDisposedRuleByBundle(oldInfo.GetAppId(), userId_);
appControlMgr->DeleteAllDisposedRuleByBundle(oldInfo, Constants::MAIN_APP_INDEX, userId_);
}
#endif
APP_LOGD("finish to process %{public}s bundle uninstall", bundleName.c_str());
@ -1770,6 +1772,7 @@ ErrCode BaseBundleInstaller::ProcessBundleInstallNative(InnerBundleInfo &info, i
hapPath, info.GetCpuAbi(), info.GetBundleName());
if (ret != ERR_OK) {
APP_LOGE("Failed to install because installing the native package failed. error code: %{public}d", ret);
return ret;
}
if ((InstalldClient::GetInstance()->RemoveDir(moduleHnpsPath)) != ERR_OK) {
APP_LOGE("delete dir %{public}s failed!", moduleHnpsPath.c_str());
@ -1786,6 +1789,7 @@ ErrCode BaseBundleInstaller::ProcessBundleUnInstallNative(InnerBundleInfo &info,
std::to_string(userId).c_str(), bundleName.c_str());
if (ret != ERR_OK) {
APP_LOGE("Failed to uninstall because uninstalling the native package failed. error code: %{public}d", ret);
return ret;
}
}
return ERR_OK;
@ -2970,6 +2974,7 @@ ErrCode BaseBundleInstaller::ExtractModule(InnerBundleInfo &info, const std::str
result = ExtractHnpFileDir(cpuAbi, hnpPackageInfoString.str(), modulePath);
if (result != ERR_OK) {
APP_LOGE("fail to ExtractHnpsFileDir, error is %{public}d", result);
return result;
}
}

View File

@ -20,6 +20,7 @@
#include "appexecfwk_errors.h"
#include "bundle_common_event.h"
#include "bundle_constants.h"
#include "bundle_service_constants.h"
#include "bundle_util.h"
#include "common_event_manager.h"
#include "common_event_support.h"
@ -193,13 +194,13 @@ std::string BundleCommonEventMgr::GetCommonEventData(const NotifyType &type)
}
void BundleCommonEventMgr::NotifySetDiposedRule(
const std::string &appId, int32_t userId, const std::string &data)
const std::string &appId, int32_t userId, const std::string &data, int32_t appIndex)
{
OHOS::AAFwk::Want want;
want.SetAction(DISPOSED_RULE_ADDED);
want.SetParam(Constants::USER_ID, userId);
want.SetParam(APP_ID, appId);
want.SetParam(APP_INDEX, appIndex);
EventFwk::CommonEventData commonData { want };
commonData.SetData(data);
EventFwk::CommonEventPublishInfo publishInfo;
@ -208,12 +209,13 @@ void BundleCommonEventMgr::NotifySetDiposedRule(
EventFwk::CommonEventManager::PublishCommonEvent(commonData, publishInfo);
}
void BundleCommonEventMgr::NotifyDeleteDiposedRule(const std::string &appId, int32_t userId)
void BundleCommonEventMgr::NotifyDeleteDiposedRule(const std::string &appId, int32_t userId, int32_t appIndex)
{
OHOS::AAFwk::Want want;
want.SetAction(DISPOSED_RULE_DELETED);
want.SetParam(Constants::USER_ID, userId);
want.SetParam(APP_ID, appId);
want.SetParam(APP_INDEX, appIndex);
EventFwk::CommonEventData commonData { want };
EventFwk::CommonEventPublishInfo publishInfo;
std::vector<std::string> permissionVec { Constants::PERMISSION_MANAGE_DISPOSED_APP_STATUS };

View File

@ -2747,10 +2747,10 @@ ErrCode BundleDataMgr::GetBundleNameAndIndexForUid(const int32_t uid, std::strin
InnerBundleInfo innerBundleInfo;
if (GetInnerBundleInfoAndIndexByUid(uid, innerBundleInfo, appIndex) != ERR_OK) {
if (sandboxAppHelper_ == nullptr) {
return ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST;
return ERR_BUNDLE_MANAGER_INVALID_UID;
}
if (sandboxAppHelper_->GetInnerBundleInfoByUid(uid, innerBundleInfo) != ERR_OK) {
return ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST;
return ERR_BUNDLE_MANAGER_INVALID_UID;
}
}
@ -2765,7 +2765,7 @@ ErrCode BundleDataMgr::GetInnerBundleInfoAndIndexByUid(const int32_t uid, InnerB
{
if (uid < Constants::BASE_APP_UID) {
APP_LOGD("the uid(%{public}d) is not an application.", uid);
return ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST;
return ERR_BUNDLE_MANAGER_INVALID_UID;
}
int32_t userId = GetUserIdByUid(uid);
int32_t bundleId = uid - userId * Constants::BASE_USER_RANGE;
@ -2776,7 +2776,7 @@ ErrCode BundleDataMgr::GetInnerBundleInfoAndIndexByUid(const int32_t uid, InnerB
auto bundleIdIter = bundleIdMap_.find(bundleId);
if (bundleIdIter == bundleIdMap_.end()) {
APP_LOGW("uid %{public}d is not existed.", uid);
return ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST;
return ERR_BUNDLE_MANAGER_INVALID_UID;
}
keyName = bundleIdIter->second;
}
@ -2787,12 +2787,12 @@ ErrCode BundleDataMgr::GetInnerBundleInfoAndIndexByUid(const int32_t uid, InnerB
auto bundleInfoIter = bundleInfos_.find(bundleName);
if (bundleInfoIter == bundleInfos_.end()) {
APP_LOGE("bundleName %{public}s is not existed in bundleInfos_.", bundleName.c_str());
return ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST;
return ERR_BUNDLE_MANAGER_INVALID_UID;
}
if (bundleInfoIter->second.IsDisabled()) {
APP_LOGD("app %{public}s is disabled", bundleInfoIter->second.GetBundleName().c_str());
return ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST;
return ERR_BUNDLE_MANAGER_INVALID_UID;
}
if (bundleInfoIter->second.GetUid(userId, appIndex) == uid) {
innerBundleInfo = bundleInfoIter->second;
@ -2800,7 +2800,7 @@ ErrCode BundleDataMgr::GetInnerBundleInfoAndIndexByUid(const int32_t uid, InnerB
}
APP_LOGW("the uid(%{public}d) is not exists.", uid);
return ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST;
return ERR_BUNDLE_MANAGER_INVALID_UID;
}
ErrCode BundleDataMgr::GetInnerBundleInfoByUid(const int32_t uid, InnerBundleInfo &innerBundleInfo) const
@ -5236,20 +5236,12 @@ std::shared_ptr<Global::Resource::ResourceManager> BundleDataMgr::GetResourceMan
BundleInfo bundleInfo;
innerBundleInfo.GetBundleInfo(BundleFlag::GET_BUNDLE_DEFAULT, bundleInfo, responseUserId);
std::shared_ptr<Global::Resource::ResourceManager> resourceManager(Global::Resource::CreateResourceManager());
for (auto hapModuleInfo : bundleInfo.hapModuleInfos) {
std::string moduleResPath;
if (moduleName.empty() || moduleName == hapModuleInfo.moduleName) {
moduleResPath = hapModuleInfo.hapPath.empty() ? hapModuleInfo.resourcePath : hapModuleInfo.hapPath;
}
if (!moduleResPath.empty()) {
APP_LOGD("DistributedBms::InitResourceManager, moduleResPath: %{public}s", moduleResPath.c_str());
if (!resourceManager->AddResource(moduleResPath.c_str())) {
APP_LOGW("DistributedBms::InitResourceManager AddResource failed");
}
}
}
std::unique_ptr<Global::Resource::ResConfig> resConfig(Global::Resource::CreateResConfig());
if (!resConfig) {
APP_LOGE("resConfig is nullptr");
return nullptr;
}
#ifdef GLOBAL_I18_ENABLE
std::map<std::string, std::string> configs;
OHOS::Global::I18n::LocaleInfo locale(
@ -5257,6 +5249,20 @@ std::shared_ptr<Global::Resource::ResourceManager> BundleDataMgr::GetResourceMan
resConfig->SetLocaleInfo(locale.GetLanguage().c_str(), locale.GetScript().c_str(), locale.GetRegion().c_str());
#endif
resourceManager->UpdateResConfig(*resConfig);
for (auto hapModuleInfo : bundleInfo.hapModuleInfos) {
std::string moduleResPath;
if (moduleName.empty() || moduleName == hapModuleInfo.moduleName) {
moduleResPath = hapModuleInfo.hapPath.empty() ? hapModuleInfo.resourcePath : hapModuleInfo.hapPath;
}
if (!moduleResPath.empty()) {
APP_LOGD("DistributedBms::InitResourceManager, moduleResPath: %{public}s", moduleResPath.c_str());
if (!resourceManager->AddResource(moduleResPath.c_str(), Global::Resource::SELECT_STRING
| Global::Resource::SELECT_MEDIA)) {
APP_LOGW("DistributedBms::InitResourceManager AddResource failed");
}
}
}
return resourceManager;
}
#endif

View File

@ -1209,7 +1209,7 @@ bool BundleInstallChecker::MatchOldSignatures(const std::string &bundleName,
std::vector<std::string> oldAppIds;
std::shared_ptr<BundleDataMgr> dataMgr = DelayedSingleton<BundleMgrService>::GetInstance()->GetDataMgr();
if (!dataMgr->GetOldAppIds(bundleName, oldAppIds)) {
APP_LOGE("Get OldAppIds failed.");
APP_LOGD("Get OldAppIds failed.");
return false;
}
for (const auto &signature : appSignatures) {

View File

@ -311,7 +311,7 @@ ErrCode BundleMgrHostImpl::GetBundleInfoForSelf(int32_t flags, BundleInfo &bundl
auto ret = dataMgr->GetBundleNameAndIndexForUid(uid, bundleName, appIndex);
if (ret != ERR_OK) {
LOG_E(BMS_TAG_QUERY_BUNDLE, "GetBundleNameForUid failed, uid is %{public}d", uid);
return ret;
return ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST;
}
return dataMgr->GetBundleInfoV9(bundleName, flags, bundleInfo, userId, appIndex);
}
@ -2729,7 +2729,12 @@ std::string BundleMgrHostImpl::GetAppType(const std::string &bundleName)
return appType;
}
int BundleMgrHostImpl::GetUidByBundleName(const std::string &bundleName, const int userId)
int32_t BundleMgrHostImpl::GetUidByBundleName(const std::string &bundleName, const int32_t userId)
{
return GetUidByBundleName(bundleName, userId, 0);
}
int32_t BundleMgrHostImpl::GetUidByBundleName(const std::string &bundleName, const int32_t userId, int32_t appIndex)
{
APP_LOGD("bundleName : %{public}s, userId : %{public}d", bundleName.c_str(), userId);
if (!BundlePermissionMgr::VerifyCallingPermissionForAll(Constants::PERMISSION_GET_BUNDLE_INFO_PRIVILEGED) &&
@ -2744,7 +2749,7 @@ int BundleMgrHostImpl::GetUidByBundleName(const std::string &bundleName, const i
}
BundleInfo bundleInfo;
int32_t uid = Constants::INVALID_UID;
ErrCode ret = dataMgr->GetBundleInfoV9(bundleName, GET_BUNDLE_DEFAULT, bundleInfo, userId);
ErrCode ret = dataMgr->GetBundleInfoV9(bundleName, GET_BUNDLE_DEFAULT, bundleInfo, userId, appIndex);
if (ret == ERR_OK) {
uid = bundleInfo.uid;
APP_LOGD("get bundle uid success, uid is %{public}d", uid);
@ -2858,6 +2863,12 @@ bool BundleMgrHostImpl::ImplicitQueryInfos(const Want &want, int32_t flags, int3
APP_LOGD("default app has been found and unnecessary to find from bms extension");
return ret;
}
if ((static_cast<uint32_t>(flags) &
static_cast<uint32_t>(GetAbilityInfoFlag::GET_ABILITY_INFO_WITH_APP_LINKING)) !=
static_cast<uint32_t>(GetAbilityInfoFlag::GET_ABILITY_INFO_WITH_APP_LINKING)) {
APP_LOGI("contains app linking flag, no need to query from bms extension");
return ret;
}
auto bmsExtensionClient = std::make_shared<BmsExtensionClient>();
if (isBrokerServiceExisted_ &&
bmsExtensionClient->ImplicitQueryAbilityInfos(want, flags, userId, abilityInfos, false) == ERR_OK) {

View File

@ -46,7 +46,7 @@ ErrCode BundleResourceHostImpl::GetBundleResourceInfo(const std::string &bundleN
}
if (!manager->GetBundleResourceInfo(bundleName, flags, bundleResourceInfo, appIndex)) {
APP_LOGE("get resource failed, bundleName:%{public}s, flags:%{public}u", bundleName.c_str(), flags);
return ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST;
return CheckBundleNameValid(bundleName, appIndex);
}
return ERR_OK;
}
@ -75,7 +75,7 @@ ErrCode BundleResourceHostImpl::GetLauncherAbilityResourceInfo(const std::string
}
if (!manager->GetLauncherAbilityResourceInfo(bundleName, flags, launcherAbilityResourceInfo, appIndex)) {
APP_LOGE("get resource failed, bundleName:%{public}s, flags:%{public}u", bundleName.c_str(), flags);
return ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST;
return CheckBundleNameValid(bundleName, appIndex);
}
return ERR_OK;
}
@ -103,7 +103,7 @@ ErrCode BundleResourceHostImpl::GetAllBundleResourceInfo(const uint32_t flags,
return ERR_BUNDLE_MANAGER_INTERNAL_ERROR;
}
if (!manager->GetAllBundleResourceInfo(flags, bundleResourceInfos)) {
APP_LOGE("get all resource failed, flags:%{public}u", flags);
APP_LOGE("get all resource failed, flags:%{public}u", flags);
BundlePermissionMgr::AddPermissionUsedRecord(Constants::PERMISSION_GET_INSTALLED_BUNDLE_LIST, 0, 1);
return ERR_BUNDLE_MANAGER_INTERNAL_ERROR;
}
@ -142,5 +142,24 @@ ErrCode BundleResourceHostImpl::GetAllLauncherAbilityResourceInfo(const uint32_t
BundlePermissionMgr::AddPermissionUsedRecord(Constants::PERMISSION_GET_INSTALLED_BUNDLE_LIST, 1, 0);
return ERR_OK;
}
ErrCode BundleResourceHostImpl::CheckBundleNameValid(const std::string &bundleName, int32_t appIndex)
{
if (appIndex == 0) {
return ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST;
}
auto manager = DelayedSingleton<BundleResourceManager>::GetInstance();
if (manager == nullptr) {
APP_LOGE("manager is nullptr, bundleName: %{public}s", bundleName.c_str());
return ERR_BUNDLE_MANAGER_INTERNAL_ERROR;
}
BundleResourceInfo bundleResourceInfo;
if (!manager->GetBundleResourceInfo(bundleName,
static_cast<uint32_t>(ResourceFlag::GET_RESOURCE_INFO_WITH_LABEL), bundleResourceInfo)) {
return ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST;
}
APP_LOGE("get failed, bundleName:%{public}s appIndex:%{public}d", bundleName.c_str(), appIndex);
return ERR_APPEXECFWK_CLONE_INSTALL_INVALID_APP_INDEX;
}
} // AppExecFwk
} // OHOS

View File

@ -77,6 +77,11 @@ bool BundleResourceManager::AddResourceInfoByBundleName(const std::string &bundl
APP_LOGE("error, bundleName:%{public}s", bundleName.c_str());
return false;
}
if (!resourceInfos.empty() && !resourceInfos[0].appIndexes_.empty()) {
if (!AddCloneBundleResourceInfo(resourceInfos[0].bundleName_, resourceInfos[0].appIndexes_)) {
APP_LOGW("bundleName:%{public}s add clone resource failed", bundleName.c_str());
}
}
APP_LOGD("success, bundleName:%{public}s", bundleName.c_str());
return true;
}
@ -119,7 +124,17 @@ bool BundleResourceManager::AddAllResourceInfo(const int32_t userId)
APP_LOGE("add all resource info failed, userId:%{public}d", userId);
return false;
}
// process clone bundle resource info
for (const auto &item : resourceInfosMap) {
if (!item.second.empty() && !item.second[0].appIndexes_.empty()) {
APP_LOGI("start process bundle:%{public}s clone resource info", item.first.c_str());
if (!AddCloneBundleResourceInfo(item.first, item.second[0].appIndexes_)) {
APP_LOGW("bundleName:%{public}s add clone resource failed", item.second[0].bundleName_.c_str());
}
}
}
SendBundleResourcesChangedEvent(userId);
APP_LOGI("add all resource end");
return true;
}
@ -295,6 +310,15 @@ bool BundleResourceManager::AddResourceInfoByColorModeChanged(const int32_t user
APP_LOGE("add resource infos failed, userId:%{public}d", userId);
return false;
}
// process clone bundle resource info
for (const auto &item : resourceInfosMap) {
if (!item.second.empty() && !item.second[0].appIndexes_.empty()) {
APP_LOGI("start process bundle:%{public}s clone resource info", item.first.c_str());
if (!AddCloneBundleResourceInfo(item.first, item.second[0].appIndexes_)) {
APP_LOGW("bundle:%{public}s add clone resource failed", item.first.c_str());
}
}
}
SendBundleResourcesChangedEvent(userId);
return true;
}
@ -480,33 +504,17 @@ bool BundleResourceManager::AddCloneBundleResourceInfo(
APP_LOGD("start add clone bundle resource info, bundleName:%{public}s appIndex:%{public}d",
bundleName.c_str(), appIndex);
// 1. get main bundle resource info
BundleResourceInfo bundleResourceInfo;
uint32_t flags = static_cast<uint32_t>(ResourceFlag::GET_RESOURCE_INFO_ALL) |
static_cast<uint32_t>(ResourceFlag::GET_RESOURCE_INFO_WITH_DRAWABLE_DESCRIPTOR);
if (!bundleResourceRdb_->GetBundleResourceInfo(bundleName, flags, bundleResourceInfo)) {
APP_LOGE("get bundle resource failed, bundleName:%{public}s appIndex:%{public}d", bundleName.c_str(), appIndex);
std::vector<ResourceInfo> resourceInfos;
if (!GetBundleResourceInfoForCloneBundle(bundleName, appIndex, resourceInfos)) {
APP_LOGE("add clone bundle resource failed, bundleName:%{public}s appIndex:%{public}d",
bundleName.c_str(), appIndex);
return false;
}
bundleResourceInfo.appIndex = appIndex;
ResourceInfo bundleResource;
bundleResource.ConvertFromBundleResourceInfo(bundleResourceInfo);
std::vector<ResourceInfo> resourceInfos;
resourceInfos.emplace_back(bundleResource);
// 2. get main launcher ability resource info
std::vector<LauncherAbilityResourceInfo> launcherAbilityResourceInfos;
if (!bundleResourceRdb_->GetLauncherAbilityResourceInfo(bundleName, flags, launcherAbilityResourceInfos)) {
APP_LOGW("get ability resource failed, bundleName:%{public}s appIndex:%{public}d",
bundleName.c_str(), appIndex);
// 2. need to process base icon and badge icon
// 3. need delete old clone resource info
if (!DeleteCloneBundleResourceInfo(bundleName, appIndex)) {
APP_LOGW("delete bundleName:%{public}s appIndex:%{public}d resource failed", bundleName.c_str(), appIndex);
}
for (auto &launcherAbility : launcherAbilityResourceInfos) {
launcherAbility.appIndex = appIndex;
ResourceInfo launcherResource;
launcherResource.ConvertFromLauncherAbilityResourceInfo(launcherAbility);
resourceInfos.emplace_back(launcherResource);
}
APP_LOGI("bundleName:%{public}s appIndex:%{public}d add resource size:%{public}zu", bundleName.c_str(), appIndex,
resourceInfos.size());
// 3.need to process icon
// 4. save clone bundle resource info
if (!bundleResourceRdb_->AddResourceInfos(resourceInfos)) {
APP_LOGE("add resource failed, bundleName:%{public}s appIndex:%{public}d", bundleName.c_str(), appIndex);
@ -526,5 +534,53 @@ bool BundleResourceManager::DeleteCloneBundleResourceInfo(const std::string &bun
info.appIndex_ = appIndex;
return bundleResourceRdb_->DeleteResourceInfo(info.GetKey());
}
bool BundleResourceManager::AddCloneBundleResourceInfo(
const std::string &bundleName,
const std::vector<int32_t> appIndexes)
{
APP_LOGD("start add clone resource info, bundleName:%{public}s", bundleName.c_str());
bool result = true;
for (const auto index : appIndexes) {
result = AddCloneBundleResourceInfo(bundleName, index);
if (!result) {
APP_LOGW("bundleName:%{public}s appIndex:%{public}d add clone bundle resource failed", bundleName.c_str(),
index);
}
}
return result;
}
bool BundleResourceManager::GetBundleResourceInfoForCloneBundle(const std::string &bundleName,
const int32_t appIndex, std::vector<ResourceInfo> &resourceInfos)
{
// 1. get main bundle resource info
BundleResourceInfo bundleResourceInfo;
uint32_t flags = static_cast<uint32_t>(ResourceFlag::GET_RESOURCE_INFO_ALL) |
static_cast<uint32_t>(ResourceFlag::GET_RESOURCE_INFO_WITH_DRAWABLE_DESCRIPTOR);
if (!bundleResourceRdb_->GetBundleResourceInfo(bundleName, flags, bundleResourceInfo)) {
APP_LOGE("get bundle resource failed, bundleName:%{public}s appIndex:%{public}d", bundleName.c_str(), appIndex);
return false;
}
bundleResourceInfo.appIndex = appIndex;
ResourceInfo bundleResource;
bundleResource.ConvertFromBundleResourceInfo(bundleResourceInfo);
resourceInfos.emplace_back(bundleResource);
// 2. get main launcher ability resource info
std::vector<LauncherAbilityResourceInfo> launcherAbilityResourceInfos;
if (!bundleResourceRdb_->GetLauncherAbilityResourceInfo(bundleName, flags, launcherAbilityResourceInfos)) {
APP_LOGW("get ability resource failed, bundleName:%{public}s appIndex:%{public}d",
bundleName.c_str(), appIndex);
}
for (auto &launcherAbility : launcherAbilityResourceInfos) {
launcherAbility.appIndex = appIndex;
ResourceInfo launcherResource;
launcherResource.ConvertFromLauncherAbilityResourceInfo(launcherAbility);
resourceInfos.emplace_back(launcherResource);
}
APP_LOGI("bundleName:%{public}s appIndex:%{public}d add resource size:%{public}zu", bundleName.c_str(), appIndex,
resourceInfos.size());
return true;
}
} // AppExecFwk
} // OHOS

View File

@ -295,7 +295,20 @@ bool BundleResourceProcess::InnerGetResourceInfo(
innerBundleInfo.GetBundleName().c_str());
ChangeDynamicIcon(resourceInfos, dynamicResourceInfo);
}
// for clone bundle
std::vector<int32_t> appIndexes;
InnerBundleUserInfo innerBundleUserInfo;
if (innerBundleInfo.GetInnerBundleUserInfo(userId, innerBundleUserInfo)) {
for (const auto &cloneInfo : innerBundleUserInfo.cloneInfos) {
appIndexes.emplace_back(cloneInfo.second.appIndex);
}
}
if (!appIndexes.empty()) {
APP_LOGI("bundleName:%{public}s contains clone bundle", innerBundleInfo.GetBundleName().c_str());
for (auto &info : resourceInfos) {
info.appIndexes_ = appIndexes;
}
}
return true;
}

View File

@ -61,7 +61,7 @@ void BundleResourceHelper::AddResourceInfoByBundleName(const std::string &bundle
const int32_t userId)
{
#ifdef BUNDLE_FRAMEWORK_BUNDLE_RESOURCE
APP_LOGD("start");
APP_LOGI("bundleName:%{public}s userId:%{public}d add resource start", bundleName.c_str(), userId);
auto manager = DelayedSingleton<BundleResourceManager>::GetInstance();
if (manager == nullptr) {
APP_LOGE("failed, manager is nullptr");
@ -84,6 +84,7 @@ void BundleResourceHelper::AddResourceInfoByBundleName(const std::string &bundle
if (!manager->AddResourceInfoByBundleName(bundleName, currentUserId)) {
APP_LOGW("failed, bundleName:%{public}s", bundleName.c_str());
}
APP_LOGI("bundleName:%{public}s userId:%{public}d add resource end", bundleName.c_str(), userId);
#endif
}

View File

@ -290,6 +290,13 @@ ErrCode BundleCloneInstaller::ProcessCloneBundleUninstall(const std::string &bun
APP_LOGW("delete clone bundle resource info failed, bundleName:%{public}s appIndex:%{public}d",
bundleName.c_str(), appIndex);
}
#ifdef BUNDLE_FRAMEWORK_APP_CONTROL
std::shared_ptr<AppControlManager> appControlMgr = DelayedSingleton<AppControlManager>::GetInstance();
if (appControlMgr != nullptr) {
APP_LOGD("Delete disposed rule when bundleName :%{public}s uninstall", bundleName.c_str());
appControlMgr->DeleteAllDisposedRuleByBundle(info, appIndex, userId);
}
#endif
APP_LOGD("UninstallCloneApp %{public}s _ %{public}d succesfully", bundleName.c_str(), appIndex);
return ERR_OK;
}

View File

@ -40,7 +40,7 @@ bool IsSupportCompressNativeLibs()
char compressNativeLibs[THRESHOLD_VAL_LEN] = {0};
int32_t ret = GetParameter(COMPRESS_NATIVE_LIBS.c_str(), "", compressNativeLibs, THRESHOLD_VAL_LEN);
if (ret <= 0) {
APP_LOGE("GetParameter %{public}s failed.", COMPRESS_NATIVE_LIBS.c_str());
APP_LOGD("GetParameter %{public}s failed.", COMPRESS_NATIVE_LIBS.c_str());
return false;
}
if (std::strcmp(compressNativeLibs, "true") == 0) {

View File

@ -81,6 +81,7 @@ ohos_unittest("BmsBundleAccessTokenIdTest") {
"access_token:libtokenid_sdk",
"appspawn:hnpapi",
"appverify:libhapverify",
"bounds_checking_function:libsec_shared",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"hilog:libhilog",
@ -95,6 +96,7 @@ ohos_unittest("BmsBundleAccessTokenIdTest") {
sources += [ "${services_path}/bundlemgr/src/code_sign_helper.cpp" ]
include_dirs += [ "${services_path}/bundlemgr/include" ]
external_deps += [
"bounds_checking_function:libsec_shared",
"code_signature:libcode_sign_utils",
"ets_runtime:libcompiler_service",
]

View File

@ -69,6 +69,7 @@ ohos_unittest("BmsAOTMgrTest") {
"access_token:libtokenid_sdk",
"appspawn:hnpapi",
"appverify:libhapverify",
"bounds_checking_function:libsec_shared",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"hilog:libhilog",
@ -83,6 +84,7 @@ ohos_unittest("BmsAOTMgrTest") {
sources += [ "${services_path}/bundlemgr/src/code_sign_helper.cpp" ]
include_dirs += [ "${services_path}/bundlemgr/include" ]
external_deps += [
"bounds_checking_function:libsec_shared",
"code_signature:libcode_sign_utils",
"ets_runtime:libcompiler_service",
]

View File

@ -73,6 +73,7 @@ ohos_unittest("BmsBundleAppControlTest") {
"access_token:libtokenid_sdk",
"appspawn:hnpapi",
"appverify:libhapverify",
"bounds_checking_function:libsec_shared",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"hilog:libhilog",
@ -87,6 +88,7 @@ ohos_unittest("BmsBundleAppControlTest") {
sources += [ "${services_path}/bundlemgr/src/code_sign_helper.cpp" ]
include_dirs += [ "${services_path}/bundlemgr/include" ]
external_deps += [
"bounds_checking_function:libsec_shared",
"code_signature:libcode_sign_utils",
"ets_runtime:libcompiler_service",
]
@ -223,6 +225,7 @@ ohos_unittest("BmsBundleMockAppControlTest") {
"access_token:libtokenid_sdk",
"appspawn:hnpapi",
"appverify:libhapverify",
"bounds_checking_function:libsec_shared",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"hilog:libhilog",
@ -237,6 +240,7 @@ ohos_unittest("BmsBundleMockAppControlTest") {
sources += [ "${services_path}/bundlemgr/src/code_sign_helper.cpp" ]
include_dirs += [ "${services_path}/bundlemgr/include" ]
external_deps += [
"bounds_checking_function:libsec_shared",
"code_signature:libcode_sign_utils",
"ets_runtime:libcompiler_service",
]

View File

@ -1416,7 +1416,8 @@ HWTEST_F(BmsBundleAppControlTest, AppControlManagerHostImpl_4500, Function | Sma
auto appControlManager = impl->appControlManager_;
std::vector<DisposedRule> disposedRules;
int32_t userId = Constants::UNSPECIFIED_USERID;
ErrCode res = appControlManager->GetAbilityRunningControlRule(CALLER_BUNDLE_NAME, userId, disposedRules);
ErrCode res = appControlManager->GetAbilityRunningControlRule(CALLER_BUNDLE_NAME, Constants::MAIN_APP_INDEX,
userId, disposedRules);
EXPECT_EQ(res, ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST);
EXPECT_EQ(disposedRules.empty(), true);
}
@ -1432,7 +1433,8 @@ HWTEST_F(BmsBundleAppControlTest, AppControlManagerHostImpl_4600, Function | Sma
auto appControlManager = impl->appControlManager_;
ASSERT_NE(appControlManager, nullptr);
DisposedRule rule;
ErrCode res = appControlManager->GetDisposedRule(CALLER_BUNDLE_NAME, APPID, rule, USERID);
ErrCode res = appControlManager->GetDisposedRule(CALLER_BUNDLE_NAME, APPID, rule, Constants::MAIN_APP_INDEX,
USERID);
EXPECT_EQ(res, ERR_OK);
}

View File

@ -71,6 +71,7 @@ ohos_unittest("BmsBundleAppProvisionInfoTest") {
"access_token:libtokenid_sdk",
"appspawn:hnpapi",
"appverify:libhapverify",
"bounds_checking_function:libsec_shared",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"hilog:libhilog",
@ -85,6 +86,7 @@ ohos_unittest("BmsBundleAppProvisionInfoTest") {
sources += [ "${services_path}/bundlemgr/src/code_sign_helper.cpp" ]
include_dirs += [ "${services_path}/bundlemgr/include" ]
external_deps += [
"bounds_checking_function:libsec_shared",
"code_signature:libcode_sign_utils",
"ets_runtime:libcompiler_service",
]

View File

@ -65,6 +65,7 @@ ohos_unittest("BmsBundleCloneAppBundleLogicTest") {
"access_token:libprivacy_sdk",
"access_token:libtokenid_sdk",
"appverify:libhapverify",
"bounds_checking_function:libsec_shared",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"hilog:libhilog",
@ -79,6 +80,7 @@ ohos_unittest("BmsBundleCloneAppBundleLogicTest") {
sources += [ "${services_path}/bundlemgr/src/code_sign_helper.cpp" ]
include_dirs += [ "${services_path}/bundlemgr/include" ]
external_deps += [
"bounds_checking_function:libsec_shared",
"code_signature:libcode_sign_utils",
"ets_runtime:libcompiler_service",
]
@ -271,6 +273,7 @@ ohos_unittest("BmsBundleCloneAppIpcTest") {
"access_token:libtokenid_sdk",
"appspawn:hnpapi",
"appverify:libhapverify",
"bounds_checking_function:libsec_shared",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"hilog:libhilog",
@ -286,6 +289,7 @@ ohos_unittest("BmsBundleCloneAppIpcTest") {
sources += [ "${services_path}/bundlemgr/src/code_sign_helper.cpp" ]
include_dirs += [ "${services_path}/bundlemgr/include" ]
external_deps += [
"bounds_checking_function:libsec_shared",
"code_signature:libcode_sign_utils",
"ets_runtime:libcompiler_service",
]

View File

@ -73,6 +73,7 @@ ohos_unittest("BmsBundleCommonTest") {
"access_token:libtokenid_sdk",
"appspawn:hnpapi",
"appverify:libhapverify",
"bounds_checking_function:libsec_shared",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"hilog:libhilog",
@ -87,6 +88,7 @@ ohos_unittest("BmsBundleCommonTest") {
sources += [ "${services_path}/bundlemgr/src/code_sign_helper.cpp" ]
include_dirs += [ "${services_path}/bundlemgr/include" ]
external_deps += [
"bounds_checking_function:libsec_shared",
"code_signature:libcode_sign_utils",
"ets_runtime:libcompiler_service",
]

View File

@ -71,6 +71,7 @@ ohos_unittest("BmsBundleCrowdtestingTest") {
"access_token:libtokenid_sdk",
"appspawn:hnpapi",
"appverify:libhapverify",
"bounds_checking_function:libsec_shared",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"hilog:libhilog",
@ -85,6 +86,7 @@ ohos_unittest("BmsBundleCrowdtestingTest") {
sources += [ "${services_path}/bundlemgr/src/code_sign_helper.cpp" ]
include_dirs += [ "${services_path}/bundlemgr/include" ]
external_deps += [
"bounds_checking_function:libsec_shared",
"code_signature:libcode_sign_utils",
"ets_runtime:libcompiler_service",
]

View File

@ -58,6 +58,7 @@ ohos_unittest("BmsBundleDataGroupTest") {
"access_token:libprivacy_sdk",
"access_token:libtokenid_sdk",
"appverify:libhapverify",
"bounds_checking_function:libsec_shared",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"hilog:libhilog",
@ -72,6 +73,7 @@ ohos_unittest("BmsBundleDataGroupTest") {
sources += [ "${services_path}/bundlemgr/src/code_sign_helper.cpp" ]
include_dirs += [ "${services_path}/bundlemgr/include" ]
external_deps += [
"bounds_checking_function:libsec_shared",
"code_signature:libcode_sign_utils",
"ets_runtime:libcompiler_service",
]

View File

@ -69,6 +69,7 @@ ohos_unittest("BmsBundleDefaultAppTest") {
"access_token:libtokenid_sdk",
"appspawn:hnpapi",
"appverify:libhapverify",
"bounds_checking_function:libsec_shared",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"hilog:libhilog",
@ -83,6 +84,7 @@ ohos_unittest("BmsBundleDefaultAppTest") {
sources += [ "${services_path}/bundlemgr/src/code_sign_helper.cpp" ]
include_dirs += [ "${services_path}/bundlemgr/include" ]
external_deps += [
"bounds_checking_function:libsec_shared",
"code_signature:libcode_sign_utils",
"ets_runtime:libcompiler_service",
]

View File

@ -72,6 +72,7 @@ ohos_unittest("BmsBundleDependenciesTest") {
"access_token:libtokenid_sdk",
"appspawn:hnpapi",
"appverify:libhapverify",
"bounds_checking_function:libsec_shared",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"hilog:libhilog",
@ -86,6 +87,7 @@ ohos_unittest("BmsBundleDependenciesTest") {
sources += [ "${services_path}/bundlemgr/src/code_sign_helper.cpp" ]
include_dirs += [ "${services_path}/bundlemgr/include" ]
external_deps += [
"bounds_checking_function:libsec_shared",
"code_signature:libcode_sign_utils",
"ets_runtime:libcompiler_service",
]

View File

@ -80,6 +80,7 @@ ohos_unittest("BmsBundleFreeInstallBaseTest") {
"appspawn:hnpapi",
"appverify:libhapverify",
"battery_manager:batterysrv_client",
"bounds_checking_function:libsec_shared",
"common_event_service:cesfwk_innerkits",
"device_usage_statistics:usagestatsinner",
"display_manager:displaymgr",
@ -98,6 +99,7 @@ ohos_unittest("BmsBundleFreeInstallBaseTest") {
sources += [ "${services_path}/bundlemgr/src/code_sign_helper.cpp" ]
include_dirs += [ "${services_path}/bundlemgr/include" ]
external_deps += [
"bounds_checking_function:libsec_shared",
"code_signature:libcode_sign_utils",
"ets_runtime:libcompiler_service",
]
@ -242,6 +244,7 @@ ohos_unittest("BmsBundleFreeInstallTest") {
"appspawn:hnpapi",
"appverify:libhapverify",
"battery_manager:batterysrv_client",
"bounds_checking_function:libsec_shared",
"common_event_service:cesfwk_innerkits",
"device_usage_statistics:usagestatsinner",
"display_manager:displaymgr",
@ -260,6 +263,7 @@ ohos_unittest("BmsBundleFreeInstallTest") {
sources += [ "${services_path}/bundlemgr/src/code_sign_helper.cpp" ]
include_dirs += [ "${services_path}/bundlemgr/include" ]
external_deps += [
"bounds_checking_function:libsec_shared",
"code_signature:libcode_sign_utils",
"ets_runtime:libcompiler_service",
]

View File

@ -67,6 +67,7 @@ ohos_unittest("BmsBundleHapVerifyTest") {
"access_token:libtokenid_sdk",
"appspawn:hnpapi",
"appverify:libhapverify",
"bounds_checking_function:libsec_shared",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"hilog:libhilog",
@ -81,6 +82,7 @@ ohos_unittest("BmsBundleHapVerifyTest") {
sources += [ "${services_path}/bundlemgr/src/code_sign_helper.cpp" ]
include_dirs += [ "${services_path}/bundlemgr/include" ]
external_deps += [
"bounds_checking_function:libsec_shared",
"code_signature:libcode_sign_utils",
"ets_runtime:libcompiler_service",
]

View File

@ -74,6 +74,7 @@ ohos_unittest("BmsBundleHspTest") {
"access_token:libtokenid_sdk",
"appspawn:hnpapi",
"appverify:libhapverify",
"bounds_checking_function:libsec_shared",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"hilog:libhilog",
@ -88,6 +89,7 @@ ohos_unittest("BmsBundleHspTest") {
sources += [ "${services_path}/bundlemgr/src/code_sign_helper.cpp" ]
include_dirs += [ "${services_path}/bundlemgr/include" ]
external_deps += [
"bounds_checking_function:libsec_shared",
"code_signature:libcode_sign_utils",
"ets_runtime:libcompiler_service",
]
@ -228,6 +230,7 @@ ohos_unittest("BmsBundleSharedLibraryInstallTest") {
"access_token:libtokenid_sdk",
"appspawn:hnpapi",
"appverify:libhapverify",
"bounds_checking_function:libsec_shared",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"hilog:libhilog",
@ -242,6 +245,7 @@ ohos_unittest("BmsBundleSharedLibraryInstallTest") {
sources += [ "${services_path}/bundlemgr/src/code_sign_helper.cpp" ]
include_dirs += [ "${services_path}/bundlemgr/include" ]
external_deps += [
"bounds_checking_function:libsec_shared",
"code_signature:libcode_sign_utils",
"ets_runtime:libcompiler_service",
]
@ -377,6 +381,7 @@ ohos_unittest("BmsBundleSharedLibraryUninstallTest") {
"access_token:libtokenid_sdk",
"appspawn:hnpapi",
"appverify:libhapverify",
"bounds_checking_function:libsec_shared",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"hilog:libhilog",
@ -391,6 +396,7 @@ ohos_unittest("BmsBundleSharedLibraryUninstallTest") {
sources += [ "${services_path}/bundlemgr/src/code_sign_helper.cpp" ]
include_dirs += [ "${services_path}/bundlemgr/include" ]
external_deps += [
"bounds_checking_function:libsec_shared",
"code_signature:libcode_sign_utils",
"ets_runtime:libcompiler_service",
]

View File

@ -69,6 +69,7 @@ ohos_unittest("BmsBundleInstallerManagerTest") {
"access_token:libtokenid_sdk",
"appspawn:hnpapi",
"appverify:libhapverify",
"bounds_checking_function:libsec_shared",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"hilog:libhilog",
@ -86,6 +87,7 @@ ohos_unittest("BmsBundleInstallerManagerTest") {
sources += [ "${services_path}/bundlemgr/src/code_sign_helper.cpp" ]
include_dirs += [ "${services_path}/bundlemgr/include" ]
external_deps += [
"bounds_checking_function:libsec_shared",
"code_signature:libcode_sign_utils",
"ets_runtime:libcompiler_service",
]

View File

@ -83,6 +83,7 @@ ohos_unittest("BmsBundleInstallerTest") {
"access_token:libtokenid_sdk",
"appspawn:hnpapi",
"appverify:libhapverify",
"bounds_checking_function:libsec_shared",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"hilog:libhilog",
@ -98,6 +99,7 @@ ohos_unittest("BmsBundleInstallerTest") {
sources += [ "${services_path}/bundlemgr/src/code_sign_helper.cpp" ]
include_dirs += [ "${services_path}/bundlemgr/include" ]
external_deps += [
"bounds_checking_function:libsec_shared",
"code_signature:libcode_sign_utils",
"ets_runtime:libcompiler_service",
]
@ -263,6 +265,7 @@ ohos_unittest("BmsBundleOtaUpdateTest") {
"access_token:libtokenid_sdk",
"appspawn:hnpapi",
"appverify:libhapverify",
"bounds_checking_function:libsec_shared",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"hilog:libhilog",
@ -278,6 +281,7 @@ ohos_unittest("BmsBundleOtaUpdateTest") {
sources += [ "${services_path}/bundlemgr/src/code_sign_helper.cpp" ]
include_dirs += [ "${services_path}/bundlemgr/include" ]
external_deps += [
"bounds_checking_function:libsec_shared",
"code_signature:libcode_sign_utils",
"ets_runtime:libcompiler_service",
]
@ -452,6 +456,7 @@ ohos_unittest("BmsMultipleBundleInstallerTest") {
"access_token:libtokenid_sdk",
"appspawn:hnpapi",
"appverify:libhapverify",
"bounds_checking_function:libsec_shared",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"hilog:libhilog",
@ -467,6 +472,7 @@ ohos_unittest("BmsMultipleBundleInstallerTest") {
sources += [ "${services_path}/bundlemgr/src/code_sign_helper.cpp" ]
include_dirs += [ "${services_path}/bundlemgr/include" ]
external_deps += [
"bounds_checking_function:libsec_shared",
"code_signature:libcode_sign_utils",
"ets_runtime:libcompiler_service",
]
@ -606,6 +612,7 @@ ohos_unittest("BmsBundleInstallIpcTest") {
"access_token:libtokenid_sdk",
"appspawn:hnpapi",
"appverify:libhapverify",
"bounds_checking_function:libsec_shared",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"hilog:libhilog",
@ -621,6 +628,7 @@ ohos_unittest("BmsBundleInstallIpcTest") {
sources += [ "${services_path}/bundlemgr/src/code_sign_helper.cpp" ]
include_dirs += [ "${services_path}/bundlemgr/include" ]
external_deps += [
"bounds_checking_function:libsec_shared",
"code_signature:libcode_sign_utils",
"ets_runtime:libcompiler_service",
]
@ -1198,6 +1206,7 @@ ohos_unittest("BmsBundleInstallDriverTest") {
"access_token:libtokenid_sdk",
"appspawn:hnpapi",
"appverify:libhapverify",
"bounds_checking_function:libsec_shared",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"hilog:libhilog",
@ -1215,6 +1224,7 @@ ohos_unittest("BmsBundleInstallDriverTest") {
sources += [ "${services_path}/bundlemgr/src/code_sign_helper.cpp" ]
include_dirs += [ "${services_path}/bundlemgr/include" ]
external_deps += [
"bounds_checking_function:libsec_shared",
"code_signature:libcode_sign_utils",
"ets_runtime:libcompiler_service",
]
@ -1356,6 +1366,7 @@ ohos_unittest("BmsBundleAppServiceFwkInstallerTest") {
"access_token:libtokenid_sdk",
"appspawn:hnpapi",
"appverify:libhapverify",
"bounds_checking_function:libsec_shared",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"hilog:libhilog",
@ -1371,6 +1382,7 @@ ohos_unittest("BmsBundleAppServiceFwkInstallerTest") {
sources += [ "${services_path}/bundlemgr/src/code_sign_helper.cpp" ]
include_dirs += [ "${services_path}/bundlemgr/include" ]
external_deps += [
"bounds_checking_function:libsec_shared",
"code_signature:libcode_sign_utils",
"ets_runtime:libcompiler_service",
]

View File

@ -62,6 +62,7 @@ ohos_unittest("BmsBundleInstallersTest") {
"access_token:libtokenid_sdk",
"appspawn:hnpapi",
"appverify:libhapverify",
"bounds_checking_function:libsec_shared",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"hilog:libhilog",
@ -79,6 +80,7 @@ ohos_unittest("BmsBundleInstallersTest") {
sources += [ "${services_path}/bundlemgr/src/code_sign_helper.cpp" ]
include_dirs += [ "${services_path}/bundlemgr/include" ]
external_deps += [
"bounds_checking_function:libsec_shared",
"code_signature:libcode_sign_utils",
"ets_runtime:libcompiler_service",
]

View File

@ -69,6 +69,7 @@ ohos_unittest("BmsBundleKitServiceBaseTest") {
"access_token:libtokenid_sdk",
"appspawn:hnpapi",
"appverify:libhapverify",
"bounds_checking_function:libsec_shared",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"hilog:libhilog",
@ -86,6 +87,7 @@ ohos_unittest("BmsBundleKitServiceBaseTest") {
sources += [ "${services_path}/bundlemgr/src/code_sign_helper.cpp" ]
include_dirs += [ "${services_path}/bundlemgr/include" ]
external_deps += [
"bounds_checking_function:libsec_shared",
"code_signature:libcode_sign_utils",
"ets_runtime:libcompiler_service",
]

View File

@ -71,6 +71,7 @@ ohos_unittest("BmsBundleDataMgrTest") {
"access_token:libtokenid_sdk",
"appspawn:hnpapi",
"appverify:libhapverify",
"bounds_checking_function:libsec_shared",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"hilog:libhilog",
@ -86,6 +87,7 @@ ohos_unittest("BmsBundleDataMgrTest") {
sources += [ "${services_path}/bundlemgr/src/code_sign_helper.cpp" ]
include_dirs += [ "${services_path}/bundlemgr/include" ]
external_deps += [
"bounds_checking_function:libsec_shared",
"code_signature:libcode_sign_utils",
"ets_runtime:libcompiler_service",
]
@ -235,6 +237,7 @@ ohos_unittest("BmsBundleKitServiceTest") {
"access_token:libtokenid_sdk",
"appspawn:hnpapi",
"appverify:libhapverify",
"bounds_checking_function:libsec_shared",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"hilog:libhilog",
@ -253,6 +256,7 @@ ohos_unittest("BmsBundleKitServiceTest") {
sources += [ "${services_path}/bundlemgr/src/code_sign_helper.cpp" ]
include_dirs += [ "${services_path}/bundlemgr/include" ]
external_deps += [
"bounds_checking_function:libsec_shared",
"code_signature:libcode_sign_utils",
"ets_runtime:libcompiler_service",
]
@ -393,6 +397,7 @@ ohos_unittest("BmsBundleGetWindowPropertiesTest") {
"access_token:libtokenid_sdk",
"appspawn:hnpapi",
"appverify:libhapverify",
"bounds_checking_function:libsec_shared",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"hilog:libhilog",
@ -408,6 +413,7 @@ ohos_unittest("BmsBundleGetWindowPropertiesTest") {
sources += [ "${services_path}/bundlemgr/src/code_sign_helper.cpp" ]
include_dirs += [ "${services_path}/bundlemgr/include" ]
external_deps += [
"bounds_checking_function:libsec_shared",
"code_signature:libcode_sign_utils",
"ets_runtime:libcompiler_service",
]

View File

@ -67,6 +67,7 @@ ohos_unittest("BmsBundleManagerTest") {
"access_token:libtokenid_sdk",
"appspawn:hnpapi",
"appverify:libhapverify",
"bounds_checking_function:libsec_shared",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"hilog:libhilog",
@ -82,6 +83,7 @@ ohos_unittest("BmsBundleManagerTest") {
sources += [ "${services_path}/bundlemgr/src/code_sign_helper.cpp" ]
include_dirs += [ "${services_path}/bundlemgr/include" ]
external_deps += [
"bounds_checking_function:libsec_shared",
"code_signature:libcode_sign_utils",
"ets_runtime:libcompiler_service",
]

View File

@ -1638,7 +1638,7 @@ HWTEST_F(BmsBundleManagerTest, bundleInfosFalse_0014, Function | SmallTest | Lev
GetBundleDataMgr()->bundleInfos_.clear();
ErrCode testRet = GetBundleDataMgr()->GetInnerBundleInfoByUid(
2, innerBundleInfo);
EXPECT_EQ(testRet, ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST);
EXPECT_EQ(testRet, ERR_BUNDLE_MANAGER_INVALID_UID);
EXPECT_EQ(GetBundleDataMgr()->bundleInfos_.empty(), true);
}

View File

@ -66,6 +66,7 @@ ohos_unittest("BmsBundleNavigationTest") {
"access_token:libtokenid_sdk",
"appspawn:hnpapi",
"appverify:libhapverify",
"bounds_checking_function:libsec_shared",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"hilog:libhilog",
@ -80,6 +81,7 @@ ohos_unittest("BmsBundleNavigationTest") {
sources += [ "${services_path}/bundlemgr/src/code_sign_helper.cpp" ]
include_dirs += [ "${services_path}/bundlemgr/include" ]
external_deps += [
"bounds_checking_function:libsec_shared",
"code_signature:libcode_sign_utils",
"ets_runtime:libcompiler_service",
]

View File

@ -66,6 +66,7 @@ ohos_unittest("BmsBundleOverlayCheckerTest") {
"access_token:libtokenid_sdk",
"appspawn:hnpapi",
"appverify:libhapverify",
"bounds_checking_function:libsec_shared",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"hilog:libhilog",
@ -92,6 +93,7 @@ ohos_unittest("BmsBundleOverlayCheckerTest") {
sources += [ "${services_path}/bundlemgr/src/code_sign_helper.cpp" ]
include_dirs += [ "${services_path}/bundlemgr/include" ]
external_deps += [
"bounds_checking_function:libsec_shared",
"code_signature:libcode_sign_utils",
"ets_runtime:libcompiler_service",
]

View File

@ -85,6 +85,7 @@ ohos_unittest("BmsBundlePermissionDefListTest") {
"access_token:libtokenid_sdk",
"appspawn:hnpapi",
"appverify:libhapverify",
"bounds_checking_function:libsec_shared",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"hilog:libhilog",
@ -100,6 +101,7 @@ ohos_unittest("BmsBundlePermissionDefListTest") {
sources += [ "${services_path}/bundlemgr/src/code_sign_helper.cpp" ]
include_dirs += [ "${services_path}/bundlemgr/include" ]
external_deps += [
"bounds_checking_function:libsec_shared",
"code_signature:libcode_sign_utils",
"ets_runtime:libcompiler_service",
]
@ -250,6 +252,7 @@ ohos_unittest("BmsBundlePermissionGrantTest") {
"access_token:libtokenid_sdk",
"appspawn:hnpapi",
"appverify:libhapverify",
"bounds_checking_function:libsec_shared",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"hilog:libhilog",
@ -264,6 +267,7 @@ ohos_unittest("BmsBundlePermissionGrantTest") {
sources += [ "${services_path}/bundlemgr/src/code_sign_helper.cpp" ]
include_dirs += [ "${services_path}/bundlemgr/include" ]
external_deps += [
"bounds_checking_function:libsec_shared",
"code_signature:libcode_sign_utils",
"ets_runtime:libcompiler_service",
]
@ -413,6 +417,7 @@ ohos_unittest("BmsBundlePermissionFalseTest") {
"access_token:libtokenid_sdk",
"appspawn:hnpapi",
"appverify:libhapverify",
"bounds_checking_function:libsec_shared",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"hilog:libhilog",
@ -427,6 +432,7 @@ ohos_unittest("BmsBundlePermissionFalseTest") {
sources += [ "${services_path}/bundlemgr/src/code_sign_helper.cpp" ]
include_dirs += [ "${services_path}/bundlemgr/include" ]
external_deps += [
"bounds_checking_function:libsec_shared",
"code_signature:libcode_sign_utils",
"ets_runtime:libcompiler_service",
]
@ -582,6 +588,7 @@ ohos_unittest("BmsBundlePermissionStartFullTest") {
"access_token:libtokenid_sdk",
"appspawn:hnpapi",
"appverify:libhapverify",
"bounds_checking_function:libsec_shared",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"hilog:libhilog",
@ -600,6 +607,7 @@ ohos_unittest("BmsBundlePermissionStartFullTest") {
sources += [ "${services_path}/bundlemgr/src/code_sign_helper.cpp" ]
include_dirs += [ "${services_path}/bundlemgr/include" ]
external_deps += [
"bounds_checking_function:libsec_shared",
"code_signature:libcode_sign_utils",
"ets_runtime:libcompiler_service",
]
@ -750,6 +758,7 @@ ohos_unittest("BmsBundlePermissionSyetemAppFalseTest") {
"access_token:libtokenid_sdk",
"appspawn:hnpapi",
"appverify:libhapverify",
"bounds_checking_function:libsec_shared",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"hilog:libhilog",
@ -764,6 +773,7 @@ ohos_unittest("BmsBundlePermissionSyetemAppFalseTest") {
sources += [ "${services_path}/bundlemgr/src/code_sign_helper.cpp" ]
include_dirs += [ "${services_path}/bundlemgr/include" ]
external_deps += [
"bounds_checking_function:libsec_shared",
"code_signature:libcode_sign_utils",
"ets_runtime:libcompiler_service",
]
@ -916,6 +926,7 @@ ohos_unittest("BmsBundlePermissionTokenTest") {
"access_token:libtokenid_sdk",
"appspawn:hnpapi",
"appverify:libhapverify",
"bounds_checking_function:libsec_shared",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"hilog:libhilog",
@ -930,6 +941,7 @@ ohos_unittest("BmsBundlePermissionTokenTest") {
sources += [ "${services_path}/bundlemgr/src/code_sign_helper.cpp" ]
include_dirs += [ "${services_path}/bundlemgr/include" ]
external_deps += [
"bounds_checking_function:libsec_shared",
"code_signature:libcode_sign_utils",
"ets_runtime:libcompiler_service",
]
@ -1071,6 +1083,7 @@ ohos_unittest("BmsBundlePermissionGetRequestTest") {
"access_token:libprivacy_sdk",
"access_token:libtokenid_sdk",
"appverify:libhapverify",
"bounds_checking_function:libsec_shared",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"hilog:libhilog",
@ -1091,6 +1104,7 @@ ohos_unittest("BmsBundlePermissionGetRequestTest") {
sources += [ "${services_path}/bundlemgr/src/code_sign_helper.cpp" ]
include_dirs += [ "${services_path}/bundlemgr/include" ]
external_deps += [
"bounds_checking_function:libsec_shared",
"code_signature:libcode_sign_utils",
"ets_runtime:libcompiler_service",
]

View File

@ -69,6 +69,7 @@ ohos_unittest("BmsBundleQuickFixBootScannerTest") {
"access_token:libtokenid_sdk",
"appspawn:hnpapi",
"appverify:libhapverify",
"bounds_checking_function:libsec_shared",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"hilog:libhilog",
@ -83,6 +84,7 @@ ohos_unittest("BmsBundleQuickFixBootScannerTest") {
sources += [ "${services_path}/bundlemgr/src/code_sign_helper.cpp" ]
include_dirs += [ "${services_path}/bundlemgr/include" ]
external_deps += [
"bounds_checking_function:libsec_shared",
"code_signature:libcode_sign_utils",
"ets_runtime:libcompiler_service",
]

View File

@ -71,6 +71,7 @@ ohos_unittest("BmsBundleQuickFixDeleterTest") {
"access_token:libtokenid_sdk",
"appspawn:hnpapi",
"appverify:libhapverify",
"bounds_checking_function:libsec_shared",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"hilog:libhilog",
@ -85,6 +86,7 @@ ohos_unittest("BmsBundleQuickFixDeleterTest") {
sources += [ "${services_path}/bundlemgr/src/code_sign_helper.cpp" ]
include_dirs += [ "${services_path}/bundlemgr/include" ]
external_deps += [
"bounds_checking_function:libsec_shared",
"code_signature:libcode_sign_utils",
"ets_runtime:libcompiler_service",
]

View File

@ -69,6 +69,7 @@ ohos_unittest("BmsBundleQuickFixManagerTest") {
"access_token:libtokenid_sdk",
"appspawn:hnpapi",
"appverify:libhapverify",
"bounds_checking_function:libsec_shared",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"hilog:libhilog",
@ -83,6 +84,7 @@ ohos_unittest("BmsBundleQuickFixManagerTest") {
sources += [ "${services_path}/bundlemgr/src/code_sign_helper.cpp" ]
include_dirs += [ "${services_path}/bundlemgr/include" ]
external_deps += [
"bounds_checking_function:libsec_shared",
"code_signature:libcode_sign_utils",
"ets_runtime:libcompiler_service",
]

View File

@ -77,6 +77,7 @@ ohos_unittest("BmsBundleQuickFixMgrRdbTest") {
"access_token:libtokenid_sdk",
"appspawn:hnpapi",
"appverify:libhapverify",
"bounds_checking_function:libsec_shared",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"hilog:libhilog",
@ -91,6 +92,7 @@ ohos_unittest("BmsBundleQuickFixMgrRdbTest") {
sources += [ "${services_path}/bundlemgr/src/code_sign_helper.cpp" ]
include_dirs += [ "${services_path}/bundlemgr/include" ]
external_deps += [
"bounds_checking_function:libsec_shared",
"code_signature:libcode_sign_utils",
"ets_runtime:libcompiler_service",
]

View File

@ -71,6 +71,7 @@ ohos_unittest("BmsBundleQuickFixSwitcherTest") {
"access_token:libtokenid_sdk",
"appspawn:hnpapi",
"appverify:libhapverify",
"bounds_checking_function:libsec_shared",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"hilog:libhilog",
@ -85,6 +86,7 @@ ohos_unittest("BmsBundleQuickFixSwitcherTest") {
sources += [ "${services_path}/bundlemgr/src/code_sign_helper.cpp" ]
include_dirs += [ "${services_path}/bundlemgr/include" ]
external_deps += [
"bounds_checking_function:libsec_shared",
"code_signature:libcode_sign_utils",
"ets_runtime:libcompiler_service",
]

View File

@ -69,6 +69,7 @@ ohos_unittest("BmsBundleQuickFixTest") {
"access_token:libtokenid_sdk",
"appspawn:hnpapi",
"appverify:libhapverify",
"bounds_checking_function:libsec_shared",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"hilog:libhilog",
@ -83,6 +84,7 @@ ohos_unittest("BmsBundleQuickFixTest") {
sources += [ "${services_path}/bundlemgr/src/code_sign_helper.cpp" ]
include_dirs += [ "${services_path}/bundlemgr/include" ]
external_deps += [
"bounds_checking_function:libsec_shared",
"code_signature:libcode_sign_utils",
"ets_runtime:libcompiler_service",
]

View File

@ -70,6 +70,7 @@ ohos_unittest("BmsBundleResourceManagerTest") {
"access_token:libtokenid_sdk",
"appspawn:hnpapi",
"appverify:libhapverify",
"bounds_checking_function:libsec_shared",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"hilog:libhilog",
@ -84,6 +85,7 @@ ohos_unittest("BmsBundleResourceManagerTest") {
sources += [ "${services_path}/bundlemgr/src/code_sign_helper.cpp" ]
include_dirs += [ "${services_path}/bundlemgr/include" ]
external_deps += [
"bounds_checking_function:libsec_shared",
"code_signature:libcode_sign_utils",
"ets_runtime:libcompiler_service",
]

View File

@ -74,6 +74,7 @@ ohos_unittest("BmsBundleResourceTest") {
"access_token:libtokenid_sdk",
"appspawn:hnpapi",
"appverify:libhapverify",
"bounds_checking_function:libsec_shared",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"hilog:libhilog",
@ -88,6 +89,7 @@ ohos_unittest("BmsBundleResourceTest") {
sources += [ "${services_path}/bundlemgr/src/code_sign_helper.cpp" ]
include_dirs += [ "${services_path}/bundlemgr/include" ]
external_deps += [
"bounds_checking_function:libsec_shared",
"code_signature:libcode_sign_utils",
"ets_runtime:libcompiler_service",
]

View File

@ -2415,6 +2415,9 @@ HWTEST_F(BmsBundleResourceTest, BmsBundleResourceTest_0098, Function | SmallTest
ret = bundleResourceHostImpl->GetBundleResourceInfo(BUNDLE_NAME, 0, info, -1);
EXPECT_EQ(ret, ERR_APPEXECFWK_CLONE_INSTALL_INVALID_APP_INDEX);
ret = bundleResourceHostImpl->GetBundleResourceInfo(BUNDLE_NAME, 0, info, 1);
EXPECT_EQ(ret, ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST);
ret = bundleResourceHostImpl->GetBundleResourceInfo(BUNDLE_NAME, 0, info, 100);
EXPECT_EQ(ret, ERR_APPEXECFWK_CLONE_INSTALL_INVALID_APP_INDEX);
@ -2426,6 +2429,9 @@ HWTEST_F(BmsBundleResourceTest, BmsBundleResourceTest_0098, Function | SmallTest
EXPECT_EQ(info.bundleName, BUNDLE_NAME);
EXPECT_FALSE(info.icon.empty());
EXPECT_FALSE(info.label.empty());
ret = bundleResourceHostImpl->GetBundleResourceInfo(BUNDLE_NAME, 0, info, 1);
EXPECT_EQ(ret, ERR_APPEXECFWK_CLONE_INSTALL_INVALID_APP_INDEX);
ErrCode unInstallResult = UnInstallBundle(BUNDLE_NAME);
EXPECT_EQ(unInstallResult, ERR_OK);
}
@ -2453,6 +2459,10 @@ HWTEST_F(BmsBundleResourceTest, BmsBundleResourceTest_0099, Function | SmallTest
EXPECT_EQ(ret, ERR_APPEXECFWK_CLONE_INSTALL_INVALID_APP_INDEX);
EXPECT_TRUE(info.size() == 0);
ret = bundleResourceHostImpl->GetLauncherAbilityResourceInfo(BUNDLE_NAME, 0, info, 1);
EXPECT_EQ(ret, ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST);
EXPECT_TRUE(info.size() == 0);
ret = bundleResourceHostImpl->GetLauncherAbilityResourceInfo(BUNDLE_NAME, 0, info, 100);
EXPECT_EQ(ret, ERR_APPEXECFWK_CLONE_INSTALL_INVALID_APP_INDEX);
EXPECT_TRUE(info.size() == 0);
@ -2470,6 +2480,9 @@ HWTEST_F(BmsBundleResourceTest, BmsBundleResourceTest_0099, Function | SmallTest
EXPECT_FALSE(info[0].icon.empty());
}
ret = bundleResourceHostImpl->GetLauncherAbilityResourceInfo(BUNDLE_NAME, 0, info, 1);
EXPECT_EQ(ret, ERR_APPEXECFWK_CLONE_INSTALL_INVALID_APP_INDEX);
ErrCode unInstallResult = UnInstallBundle(BUNDLE_NAME);
EXPECT_EQ(unInstallResult, ERR_OK);
}

View File

@ -68,6 +68,7 @@ ohos_unittest("BmsSandboxAppTest") {
"access_token:libtokenid_sdk",
"appspawn:hnpapi",
"appverify:libhapverify",
"bounds_checking_function:libsec_shared",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"hilog:libhilog",
@ -84,6 +85,7 @@ ohos_unittest("BmsSandboxAppTest") {
sources += [ "${services_path}/bundlemgr/src/code_sign_helper.cpp" ]
include_dirs += [ "${services_path}/bundlemgr/include" ]
external_deps += [
"bounds_checking_function:libsec_shared",
"code_signature:libcode_sign_utils",
"ets_runtime:libcompiler_service",
]
@ -225,6 +227,7 @@ ohos_unittest("BmsSandboxRdbTest") {
"access_token:libtokenid_sdk",
"appspawn:hnpapi",
"appverify:libhapverify",
"bounds_checking_function:libsec_shared",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"hilog:libhilog",
@ -241,6 +244,7 @@ ohos_unittest("BmsSandboxRdbTest") {
sources += [ "${services_path}/bundlemgr/src/code_sign_helper.cpp" ]
include_dirs += [ "${services_path}/bundlemgr/include" ]
external_deps += [
"bounds_checking_function:libsec_shared",
"code_signature:libcode_sign_utils",
"ets_runtime:libcompiler_service",
]

View File

@ -83,6 +83,7 @@ ohos_unittest("BmsBundleUninstallerTest") {
"access_token:libtokenid_sdk",
"appspawn:hnpapi",
"appverify:libhapverify",
"bounds_checking_function:libsec_shared",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"hilog:libhilog",
@ -97,6 +98,7 @@ ohos_unittest("BmsBundleUninstallerTest") {
sources += [ "${services_path}/bundlemgr/src/code_sign_helper.cpp" ]
include_dirs += [ "${services_path}/bundlemgr/include" ]
external_deps += [
"bounds_checking_function:libsec_shared",
"code_signature:libcode_sign_utils",
"ets_runtime:libcompiler_service",
]

View File

@ -87,6 +87,7 @@ ohos_unittest("BmsBundleUpdaterTest") {
"access_token:libtokenid_sdk",
"appspawn:hnpapi",
"appverify:libhapverify",
"bounds_checking_function:libsec_shared",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"hilog:libhilog",
@ -101,6 +102,7 @@ ohos_unittest("BmsBundleUpdaterTest") {
sources += [ "${services_path}/bundlemgr/src/code_sign_helper.cpp" ]
include_dirs += [ "${services_path}/bundlemgr/include" ]
external_deps += [
"bounds_checking_function:libsec_shared",
"code_signature:libcode_sign_utils",
"ets_runtime:libcompiler_service",
]

View File

@ -70,6 +70,7 @@ ohos_unittest("BmsBundleVerifyManagerTest") {
"access_token:libtokenid_sdk",
"appspawn:hnpapi",
"appverify:libhapverify",
"bounds_checking_function:libsec_shared",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"hilog:libhilog",
@ -84,6 +85,7 @@ ohos_unittest("BmsBundleVerifyManagerTest") {
sources += [ "${services_path}/bundlemgr/src/code_sign_helper.cpp" ]
include_dirs += [ "${services_path}/bundlemgr/include" ]
external_deps += [
"bounds_checking_function:libsec_shared",
"code_signature:libcode_sign_utils",
"ets_runtime:libcompiler_service",
]

View File

@ -72,6 +72,7 @@ ohos_unittest("BmsExtendResourceManagerTest") {
"access_token:libtokenid_sdk",
"appspawn:hnpapi",
"appverify:libhapverify",
"bounds_checking_function:libsec_shared",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"hilog:libhilog",
@ -86,6 +87,7 @@ ohos_unittest("BmsExtendResourceManagerTest") {
sources += [ "${services_path}/bundlemgr/src/code_sign_helper.cpp" ]
include_dirs += [ "${services_path}/bundlemgr/include" ]
external_deps += [
"bounds_checking_function:libsec_shared",
"code_signature:libcode_sign_utils",
"ets_runtime:libcompiler_service",
]

View File

@ -54,6 +54,7 @@ ohos_unittest("BmsInstallDaemonTest") {
"access_token:libprivacy_sdk",
"access_token:libtokenid_sdk",
"appspawn:hnpapi",
"bounds_checking_function:libsec_shared",
"eventhandler:libeventhandler",
"hilog:libhilog",
"hitrace:hitrace_meter",
@ -127,6 +128,7 @@ ohos_unittest("BmsInstallDaemonIpcTest") {
external_deps = [
"access_token:libprivacy_sdk",
"access_token:libtokenid_sdk",
"bounds_checking_function:libsec_shared",
"c_utils:utils",
"eventhandler:libeventhandler",
"hilog:libhilog",
@ -149,6 +151,7 @@ ohos_unittest("BmsInstallDaemonIpcTest") {
sources += [ "${services_path}/bundlemgr/src/code_sign_helper.cpp" ]
include_dirs += [ "${services_path}/bundlemgr/include" ]
external_deps += [
"bounds_checking_function:libsec_shared",
"code_signature:libcode_sign_utils",
"ets_runtime:libcompiler_service",
]
@ -208,6 +211,7 @@ ohos_unittest("BmsInstallDaemonHostImplTest") {
"access_token:libprivacy_sdk",
"access_token:libtokenid_sdk",
"appspawn:hnpapi",
"bounds_checking_function:libsec_shared",
"c_utils:utils",
"eventhandler:libeventhandler",
"hilog:libhilog",
@ -230,6 +234,7 @@ ohos_unittest("BmsInstallDaemonHostImplTest") {
sources += [ "${services_path}/bundlemgr/src/code_sign_helper.cpp" ]
include_dirs += [ "${services_path}/bundlemgr/include" ]
external_deps += [
"bounds_checking_function:libsec_shared",
"code_signature:libcode_sign_utils",
"ets_runtime:libcompiler_service",
]
@ -282,6 +287,7 @@ ohos_unittest("BmsInstallDaemonOperatorTest") {
"access_token:libprivacy_sdk",
"access_token:libtokenid_sdk",
"appspawn:hnpapi",
"bounds_checking_function:libsec_shared",
"c_utils:utils",
"hilog:libhilog",
"hitrace:hitrace_meter",
@ -298,6 +304,7 @@ ohos_unittest("BmsInstallDaemonOperatorTest") {
sources += [ "${services_path}/bundlemgr/src/code_sign_helper.cpp" ]
include_dirs += [ "${services_path}/bundlemgr/include" ]
external_deps += [
"bounds_checking_function:libsec_shared",
"code_signature:libcode_sign_utils",
"ets_runtime:libcompiler_service",
]

View File

@ -44,6 +44,7 @@ ohos_unittest("BmsInstalldClientTest") {
"access_token:el5_filekey_manager_sdk",
"access_token:libaccesstoken_sdk",
"appspawn:hnpapi",
"bounds_checking_function:libsec_shared",
"eventhandler:libeventhandler",
"hilog:libhilog",
"hitrace:hitrace_meter",

View File

@ -68,6 +68,7 @@ ohos_unittest("BmsInstalldHostTest") {
"access_token:libtokenid_sdk",
"appspawn:hnpapi",
"appverify:libhapverify",
"bounds_checking_function:libsec_shared",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"hilog:libhilog",
@ -82,6 +83,7 @@ ohos_unittest("BmsInstalldHostTest") {
sources += [ "${services_path}/bundlemgr/src/code_sign_helper.cpp" ]
include_dirs += [ "${services_path}/bundlemgr/include" ]
external_deps += [
"bounds_checking_function:libsec_shared",
"code_signature:libcode_sign_utils",
"ets_runtime:libcompiler_service",
]

View File

@ -61,6 +61,7 @@ ohos_unittest("BmsSyscapToolTest") {
"access_token:libtokenid_sdk",
"appspawn:hnpapi",
"appverify:libhapverify",
"bounds_checking_function:libsec_shared",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"hilog:libhilog",
@ -76,6 +77,7 @@ ohos_unittest("BmsSyscapToolTest") {
sources += [ "${services_path}/bundlemgr/src/code_sign_helper.cpp" ]
include_dirs += [ "${services_path}/bundlemgr/include" ]
external_deps += [
"bounds_checking_function:libsec_shared",
"code_signature:libcode_sign_utils",
"ets_runtime:libcompiler_service",
]

View File

@ -66,6 +66,7 @@ ohos_fuzztest("BundleInstalldHostFuzzTest") {
"access_token:libtokenid_sdk",
"appspawn:hnpapi",
"appverify:libhapverify",
"bounds_checking_function:libsec_shared",
"c_utils:utils",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
@ -109,6 +110,7 @@ ohos_fuzztest("BundleInstalldHostFuzzTest") {
sources += [ "${services_path}/bundlemgr/src/code_sign_helper.cpp" ]
include_dirs += [ "${services_path}/bundlemgr/include" ]
external_deps += [
"bounds_checking_function:libsec_shared",
"code_signature:libcode_sign_utils",
"ets_runtime:libcompiler_service",
]

View File

@ -66,6 +66,7 @@ ohos_fuzztest("BundleInstallerHostFuzzTest") {
"access_token:libtokenid_sdk",
"appspawn:hnpapi",
"appverify:libhapverify",
"bounds_checking_function:libsec_shared",
"c_utils:utils",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
@ -109,6 +110,7 @@ ohos_fuzztest("BundleInstallerHostFuzzTest") {
sources += [ "${services_path}/bundlemgr/src/code_sign_helper.cpp" ]
include_dirs += [ "${services_path}/bundlemgr/include" ]
external_deps += [
"bounds_checking_function:libsec_shared",
"code_signature:libcode_sign_utils",
"ets_runtime:libcompiler_service",
]

View File

@ -2481,6 +2481,25 @@ HWTEST_F(ActsBmsKitSystemTest, GetUidByBundleName_0500, Function | MediumTest |
std::cout << "END GetUidByBundleName_0500" << std::endl;
}
/**
* @tc.number: GetUidByBundleName_0600
* @tc.name: test query UID
* @tc.desc: 1.under '/data/test/bms_bundle',there is a hap
* 2.install the hap
* 3.query UID by empty bundleName
*/
HWTEST_F(ActsBmsKitSystemTest, GetUidByBundleName_0600, Function | MediumTest | Level1)
{
std::cout << "START GetUidByBundleName_0600" << std::endl;
sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
ASSERT_NE(bundleMgrProxy, nullptr);
std::string bundleName = "";
int uid = bundleMgrProxy->GetUidByBundleName(bundleName, USERID, 0);
EXPECT_EQ(uid, Constants::INVALID_UID);
std::cout << "END GetUidByBundleName_0600" << std::endl;
}
/**
* @tc.number: GetAppType_0100
* @tc.name: test GetAppType interface