mirror of
https://gitee.com/openharmony/ability_dmsfwk
synced 2024-11-27 16:40:44 +00:00
!214 connectAbility 支持跨设备绑定 ServiceExtension
Merge pull request !214 from 王洋/master
This commit is contained in:
commit
9bbf334f41
@ -33,6 +33,9 @@ public:
|
|||||||
static bool GetBundleNameListFromBms(int32_t callingUid, std::vector<std::string>& bundleNameList);
|
static bool GetBundleNameListFromBms(int32_t callingUid, std::vector<std::string>& bundleNameList);
|
||||||
static bool GetBundleNameListFromBms(int32_t callingUid, std::vector<std::u16string>& u16BundleNameList);
|
static bool GetBundleNameListFromBms(int32_t callingUid, std::vector<std::u16string>& u16BundleNameList);
|
||||||
static bool QueryAbilityInfo(const AAFwk::Want& want, AppExecFwk::AbilityInfo& abilityInfo);
|
static bool QueryAbilityInfo(const AAFwk::Want& want, AppExecFwk::AbilityInfo& abilityInfo);
|
||||||
|
static bool QueryExtensionAbilityInfo(const AAFwk::Want& want, AppExecFwk::ExtensionAbilityInfo& extensionInfo);
|
||||||
|
static void InitAbilityInfoFromExtension(const AppExecFwk::ExtensionAbilityInfo &extensionAbilityInfo,
|
||||||
|
AppExecFwk::AbilityInfo &abilityInfo);
|
||||||
static bool IsSameAppId(const std::string& callerAppId, const std::string& targetBundleName);
|
static bool IsSameAppId(const std::string& callerAppId, const std::string& targetBundleName);
|
||||||
static int32_t GetLocalBundleInfo(const std::string& bundleName, AppExecFwk::BundleInfo &localBundleInfo);
|
static int32_t GetLocalBundleInfo(const std::string& bundleName, AppExecFwk::BundleInfo &localBundleInfo);
|
||||||
static int32_t CheckRemoteBundleInfoForContinuation(const std::string& dstDeviceId,
|
static int32_t CheckRemoteBundleInfoForContinuation(const std::string& dstDeviceId,
|
||||||
|
@ -43,8 +43,8 @@ public:
|
|||||||
using AccountInfo = IDistributedSched::AccountInfo;
|
using AccountInfo = IDistributedSched::AccountInfo;
|
||||||
|
|
||||||
int32_t CheckDPermission(const AAFwk::Want& want, const CallerInfo& callerInfo,
|
int32_t CheckDPermission(const AAFwk::Want& want, const CallerInfo& callerInfo,
|
||||||
const AccountInfo& accountInfo, const AppExecFwk::AbilityInfo& abilityInfo,
|
const AccountInfo& accountInfo, const std::string& localDeviceId,
|
||||||
const std::string& localDeviceId);
|
bool needQueryExtension = false);
|
||||||
int32_t CheckGetCallerPermission(const AAFwk::Want& want, const CallerInfo& callerInfo,
|
int32_t CheckGetCallerPermission(const AAFwk::Want& want, const CallerInfo& callerInfo,
|
||||||
const AccountInfo& accountInfo, const std::string& localDeviceId);
|
const AccountInfo& accountInfo, const std::string& localDeviceId);
|
||||||
int32_t CheckPermission(uint32_t accessToken, const std::string& permissionName) const;
|
int32_t CheckPermission(uint32_t accessToken, const std::string& permissionName) const;
|
||||||
@ -64,8 +64,8 @@ private:
|
|||||||
const CallerInfo& callerInfo, const AccountInfo& accountInfo, const AAFwk::Want& want) const;
|
const CallerInfo& callerInfo, const AccountInfo& accountInfo, const AAFwk::Want& want) const;
|
||||||
bool CheckCustomPermission(const AppExecFwk::AbilityInfo& targetAbility,
|
bool CheckCustomPermission(const AppExecFwk::AbilityInfo& targetAbility,
|
||||||
const CallerInfo& callerInfo) const;
|
const CallerInfo& callerInfo) const;
|
||||||
bool getTargetAbility(const AAFwk::Want& want, const AppExecFwk::AbilityInfo& abilityInfo,
|
bool GetTargetAbility(const AAFwk::Want& want, bool needQueryExtension, const std::string& localDeviceId,
|
||||||
const std::string& localDeviceId, AppExecFwk::AbilityInfo& targetAbility, const CallerInfo& callerInfo) const;
|
AppExecFwk::AbilityInfo& targetAbility, const CallerInfo& callerInfo) const;
|
||||||
};
|
};
|
||||||
} // namespace DistributedSchedule
|
} // namespace DistributedSchedule
|
||||||
} // namespace OHOS
|
} // namespace OHOS
|
||||||
|
@ -92,7 +92,7 @@ bool BundleManagerInternal::GetBundleNameListFromBms(int32_t callingUid,
|
|||||||
|
|
||||||
bool BundleManagerInternal::QueryAbilityInfo(const AAFwk::Want& want, AppExecFwk::AbilityInfo& abilityInfo)
|
bool BundleManagerInternal::QueryAbilityInfo(const AAFwk::Want& want, AppExecFwk::AbilityInfo& abilityInfo)
|
||||||
{
|
{
|
||||||
std::vector<int> ids;
|
std::vector<int32_t> ids;
|
||||||
int32_t ret = OsAccountManager::QueryActiveOsAccountIds(ids);
|
int32_t ret = OsAccountManager::QueryActiveOsAccountIds(ids);
|
||||||
if (ret != ERR_OK || ids.empty()) {
|
if (ret != ERR_OK || ids.empty()) {
|
||||||
return false;
|
return false;
|
||||||
@ -111,6 +111,44 @@ bool BundleManagerInternal::QueryAbilityInfo(const AAFwk::Want& want, AppExecFwk
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool BundleManagerInternal::QueryExtensionAbilityInfo(const AAFwk::Want& want,
|
||||||
|
AppExecFwk::ExtensionAbilityInfo& extensionInfo)
|
||||||
|
{
|
||||||
|
std::vector<int32_t> ids;
|
||||||
|
int32_t ret = OsAccountManager::QueryActiveOsAccountIds(ids);
|
||||||
|
if (ret != ERR_OK || ids.empty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
auto bundleMgr = GetBundleManager();
|
||||||
|
if (bundleMgr == nullptr) {
|
||||||
|
HILOGE("failed to get bms");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
std::vector<AppExecFwk::ExtensionAbilityInfo> extensionInfos;
|
||||||
|
bundleMgr->QueryExtensionAbilityInfos(want, AppExecFwk::AbilityInfoFlag::GET_ABILITY_INFO_DEFAULT
|
||||||
|
| AppExecFwk::AbilityInfoFlag::GET_ABILITY_INFO_WITH_PERMISSION, ids[0], extensionInfos);
|
||||||
|
if (extensionInfos.size() <= 0) {
|
||||||
|
HILOGE("QueryExtensionAbilityInfo failed.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
extensionInfo = extensionInfos.front();
|
||||||
|
if (extensionInfo.bundleName.empty() || extensionInfo.name.empty()) {
|
||||||
|
HILOGE("ExtensionAbilityInfo is empty.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
HILOGD("ExtensionAbilityInfo found, name=%{public}s.", extensionInfo.name.c_str());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BundleManagerInternal::InitAbilityInfoFromExtension(const AppExecFwk::ExtensionAbilityInfo &extensionAbilityInfo,
|
||||||
|
AppExecFwk::AbilityInfo &abilityInfo)
|
||||||
|
{
|
||||||
|
abilityInfo.bundleName = extensionAbilityInfo.bundleName;
|
||||||
|
abilityInfo.name = extensionAbilityInfo.name;
|
||||||
|
abilityInfo.permissions = extensionAbilityInfo.permissions;
|
||||||
|
abilityInfo.visible = extensionAbilityInfo.visible;
|
||||||
|
}
|
||||||
|
|
||||||
bool BundleManagerInternal::IsSameAppId(const std::string& callerAppId, const std::string& targetBundleName)
|
bool BundleManagerInternal::IsSameAppId(const std::string& callerAppId, const std::string& targetBundleName)
|
||||||
{
|
{
|
||||||
if (targetBundleName.empty() || callerAppId.empty()) {
|
if (targetBundleName.empty() || callerAppId.empty()) {
|
||||||
|
@ -53,13 +53,13 @@ void from_json(const nlohmann::json& jsonObject, GroupInfo& groupInfo)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t DistributedSchedPermission::CheckDPermission(const AAFwk::Want& want, const CallerInfo& callerInfo,
|
int32_t DistributedSchedPermission::CheckDPermission(const AAFwk::Want& want, const CallerInfo& callerInfo,
|
||||||
const AccountInfo& accountInfo, const AppExecFwk::AbilityInfo& abilityInfo, const std::string& localDeviceId)
|
const AccountInfo& accountInfo, const std::string& localDeviceId, bool needQueryExtension)
|
||||||
{
|
{
|
||||||
if (localDeviceId.empty()) {
|
if (localDeviceId.empty()) {
|
||||||
return INVALID_PARAMETERS_ERR;
|
return INVALID_PARAMETERS_ERR;
|
||||||
}
|
}
|
||||||
AppExecFwk::AbilityInfo targetAbility;
|
AppExecFwk::AbilityInfo targetAbility;
|
||||||
bool result = getTargetAbility(want, abilityInfo, localDeviceId, targetAbility, callerInfo);
|
bool result = GetTargetAbility(want, needQueryExtension, localDeviceId, targetAbility, callerInfo);
|
||||||
if (!result) {
|
if (!result) {
|
||||||
HILOGE("CheckDPermission can not find the target ability");
|
HILOGE("CheckDPermission can not find the target ability");
|
||||||
return INVALID_PARAMETERS_ERR;
|
return INVALID_PARAMETERS_ERR;
|
||||||
@ -155,22 +155,32 @@ bool DistributedSchedPermission::ParseGroupInfos(const std::string& returnGroupS
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DistributedSchedPermission::getTargetAbility(const AAFwk::Want& want,
|
bool DistributedSchedPermission::GetTargetAbility(const AAFwk::Want& want,
|
||||||
const AppExecFwk::AbilityInfo& abilityInfo, const std::string& localDeviceId,
|
bool needQueryExtension, const std::string& localDeviceId,
|
||||||
AppExecFwk::AbilityInfo& targetAbility, const CallerInfo& callerInfo) const
|
AppExecFwk::AbilityInfo& targetAbility, const CallerInfo& callerInfo) const
|
||||||
{
|
{
|
||||||
if (!BundleManagerInternal::QueryAbilityInfo(want, targetAbility)) {
|
if (BundleManagerInternal::QueryAbilityInfo(want, targetAbility)) {
|
||||||
HILOGE("QueryAbilityInfo failed");
|
return true;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
return true;
|
if (needQueryExtension) {
|
||||||
|
HILOGI("QueryAbilityInfo failed, try to QueryExtensionAbilityInfo");
|
||||||
|
// try to find extension
|
||||||
|
AppExecFwk::ExtensionAbilityInfo extensionAbility;
|
||||||
|
if (BundleManagerInternal::QueryExtensionAbilityInfo(want, extensionAbility)) {
|
||||||
|
// extensionAbilityInfo translates to abilityInfo
|
||||||
|
BundleManagerInternal::InitAbilityInfoFromExtension(extensionAbility, targetAbility);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
HILOGE("QueryAbilityInfo failed, want bundle name=%{public}s, ability name=%{public}s.",
|
||||||
|
want.GetElement().GetBundleName().c_str(), want.GetElement().GetAbilityName().c_str());
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t DistributedSchedPermission::CheckGetCallerPermission(const AAFwk::Want& want, const CallerInfo& callerInfo,
|
int32_t DistributedSchedPermission::CheckGetCallerPermission(const AAFwk::Want& want, const CallerInfo& callerInfo,
|
||||||
const AccountInfo& accountInfo, const std::string& localDeviceId)
|
const AccountInfo& accountInfo, const std::string& localDeviceId)
|
||||||
{
|
{
|
||||||
AppExecFwk::AbilityInfo abilityInfo;
|
int32_t result = CheckDPermission(want, callerInfo, accountInfo, localDeviceId);
|
||||||
int32_t result = CheckDPermission(want, callerInfo, accountInfo, abilityInfo, localDeviceId);
|
|
||||||
if (result != ERR_OK) {
|
if (result != ERR_OK) {
|
||||||
HILOGE("CheckGetCallerPermission fail, error:%{public}d", result);
|
HILOGE("CheckGetCallerPermission fail, error:%{public}d", result);
|
||||||
return result;
|
return result;
|
||||||
|
@ -183,7 +183,7 @@ int32_t DistributedSchedService::StartAbilityFromRemote(const OHOS::AAFwk::Want&
|
|||||||
return INVALID_REMOTE_PARAMETERS_ERR;
|
return INVALID_REMOTE_PARAMETERS_ERR;
|
||||||
}
|
}
|
||||||
DistributedSchedPermission& permissionInstance = DistributedSchedPermission::GetInstance();
|
DistributedSchedPermission& permissionInstance = DistributedSchedPermission::GetInstance();
|
||||||
ErrCode err = permissionInstance.CheckDPermission(want, callerInfo, accountInfo, abilityInfo, deviceId);
|
ErrCode err = permissionInstance.CheckDPermission(want, callerInfo, accountInfo, deviceId);
|
||||||
if (err != ERR_OK) {
|
if (err != ERR_OK) {
|
||||||
HILOGE("CheckDPermission denied!!");
|
HILOGE("CheckDPermission denied!!");
|
||||||
return err;
|
return err;
|
||||||
@ -1199,7 +1199,8 @@ int32_t DistributedSchedService::ConnectAbilityFromRemote(const OHOS::AAFwk::Wan
|
|||||||
}
|
}
|
||||||
|
|
||||||
DistributedSchedPermission& permissionInstance = DistributedSchedPermission::GetInstance();
|
DistributedSchedPermission& permissionInstance = DistributedSchedPermission::GetInstance();
|
||||||
int32_t result = permissionInstance.CheckDPermission(want, callerInfo, accountInfo, abilityInfo, localDeviceId);
|
int32_t result = permissionInstance.CheckDPermission(want, callerInfo, accountInfo,
|
||||||
|
localDeviceId, true);
|
||||||
if (result != ERR_OK) {
|
if (result != ERR_OK) {
|
||||||
HILOGE("ConnectAbilityFromRemote CheckDPermission denied!!");
|
HILOGE("ConnectAbilityFromRemote CheckDPermission denied!!");
|
||||||
return result;
|
return result;
|
||||||
|
@ -53,6 +53,7 @@ if (dmsfwk_standard_mission_manager) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dsched_public_deps = [
|
dsched_public_deps = [
|
||||||
|
"//third_party/googletest:gmock_main",
|
||||||
"//third_party/googletest:gtest_main",
|
"//third_party/googletest:gtest_main",
|
||||||
"//third_party/libxml2:libxml2",
|
"//third_party/libxml2:libxml2",
|
||||||
]
|
]
|
||||||
@ -187,6 +188,20 @@ ohos_unittest("dscheddatastoragetest") {
|
|||||||
part_name = "dmsfwk_standard"
|
part_name = "dmsfwk_standard"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ohos_unittest("bundlemanagerinternaltest") {
|
||||||
|
module_out_path = module_output_path
|
||||||
|
sources = [ "unittest/bundle_manager_internal_test.cpp" ]
|
||||||
|
sources += dtbschedmgr_sources
|
||||||
|
configs = [ ":test_config" ]
|
||||||
|
configs += dsched_configs
|
||||||
|
deps = [ "${distributed_service}/dtbschedmgr:distributedschedsvr" ]
|
||||||
|
if (is_standard_system) {
|
||||||
|
external_deps = dsched_external_deps
|
||||||
|
public_deps = dsched_public_deps
|
||||||
|
}
|
||||||
|
part_name = "dmsfwk_standard"
|
||||||
|
}
|
||||||
|
|
||||||
group("unittest") {
|
group("unittest") {
|
||||||
testonly = true
|
testonly = true
|
||||||
deps = [
|
deps = [
|
||||||
@ -196,6 +211,7 @@ group("unittest") {
|
|||||||
]
|
]
|
||||||
if (dmsfwk_standard_mission_manager) {
|
if (dmsfwk_standard_mission_manager) {
|
||||||
deps += [
|
deps += [
|
||||||
|
":bundlemanagerinternaltest",
|
||||||
":dscheddatastoragetest",
|
":dscheddatastoragetest",
|
||||||
":dschedmissionmanagertest",
|
":dschedmissionmanagertest",
|
||||||
":dschedpermissiontest",
|
":dschedpermissiontest",
|
||||||
|
@ -0,0 +1,93 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "bundle_manager_internal_test.h"
|
||||||
|
#include "bundle/bundle_manager_internal.h"
|
||||||
|
#include "dtbschedmgr_log.h"
|
||||||
|
#include "test_log.h"
|
||||||
|
|
||||||
|
using namespace testing;
|
||||||
|
using namespace testing::ext;
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace DistributedSchedule {
|
||||||
|
namespace {
|
||||||
|
const string GROUP_ID = "TEST_GROUP_ID";
|
||||||
|
}
|
||||||
|
|
||||||
|
void BundleManagerInternalTest::SetUpTestCase()
|
||||||
|
{
|
||||||
|
DTEST_LOG << "BundleManagerInternalTest::SetUpTestCase" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BundleManagerInternalTest::TearDownTestCase()
|
||||||
|
{
|
||||||
|
DTEST_LOG << "BundleManagerInternalTest::TearDownTestCase" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BundleManagerInternalTest::TearDown()
|
||||||
|
{
|
||||||
|
DTEST_LOG << "BundleManagerInternalTest::TearDown" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BundleManagerInternalTest::SetUp()
|
||||||
|
{
|
||||||
|
DTEST_LOG << "BundleManagerInternalTest::SetUp" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.name: BundleManagerInternalTest_001
|
||||||
|
* @tc.desc: input invalid params
|
||||||
|
* @tc.type: FUNC
|
||||||
|
* @tc.require: AR000H3FD0
|
||||||
|
*/
|
||||||
|
HWTEST_F(BundleManagerInternalTest, BundleManagerInternalTest_001, TestSize.Level0)
|
||||||
|
{
|
||||||
|
DTEST_LOG << "BundleManagerInternalTest BundleManagerInternalTest_001 begin" << std::endl;
|
||||||
|
AAFwk::Want want;
|
||||||
|
AppExecFwk::ExtensionAbilityInfo extensionInfo;
|
||||||
|
|
||||||
|
bool ret = BundleManagerInternal::QueryExtensionAbilityInfo(want, extensionInfo);
|
||||||
|
EXPECT_TRUE(!ret);
|
||||||
|
EXPECT_TRUE(extensionInfo.name.empty());
|
||||||
|
DTEST_LOG << "BundleManagerInternalTest BundleManagerInternalTest_001 end ret:" << ret << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.name: BundleManagerInternalTest_002
|
||||||
|
* @tc.desc: test ability info convert
|
||||||
|
* @tc.type: FUNC
|
||||||
|
* @tc.require: AR000H3FD0
|
||||||
|
*/
|
||||||
|
HWTEST_F(BundleManagerInternalTest, BundleManagerInternalTest_002, TestSize.Level0)
|
||||||
|
{
|
||||||
|
DTEST_LOG << "BundleManagerInternalTest BundleManagerInternalTest_002 begin" << std::endl;
|
||||||
|
AppExecFwk::AbilityInfo abilityInfo;
|
||||||
|
AppExecFwk::ExtensionAbilityInfo extensionInfo;
|
||||||
|
extensionInfo.bundleName.append("bundleName");
|
||||||
|
extensionInfo.name.append("name");
|
||||||
|
vector<string> permissions;
|
||||||
|
extensionInfo.permissions = permissions;
|
||||||
|
extensionInfo.visible = true;
|
||||||
|
|
||||||
|
BundleManagerInternal::InitAbilityInfoFromExtension(extensionInfo, abilityInfo);
|
||||||
|
EXPECT_TRUE(abilityInfo.bundleName.compare("bundleName") == 0);
|
||||||
|
EXPECT_TRUE(abilityInfo.name.compare("name") == 0);
|
||||||
|
EXPECT_TRUE(abilityInfo.permissions == permissions);
|
||||||
|
EXPECT_TRUE(abilityInfo.visible);
|
||||||
|
DTEST_LOG << "BundleManagerInternalTest BundleManagerInternalTest_002 end "<< std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef BUNDLE_MANAGER_INTERNAL_TEST_H
|
||||||
|
#define BUNDLE_MANAGER_INTERNAL_TEST_H
|
||||||
|
|
||||||
|
#include "gtest/gtest.h"
|
||||||
|
#include "gmock/gmock.h"
|
||||||
|
|
||||||
|
namespace OHOS {
|
||||||
|
namespace DistributedSchedule {
|
||||||
|
class BundleManagerInternalTest : public testing::Test {
|
||||||
|
public:
|
||||||
|
static void SetUpTestCase();
|
||||||
|
static void TearDownTestCase();
|
||||||
|
void SetUp();
|
||||||
|
void TearDown();
|
||||||
|
};
|
||||||
|
} // namespace DistributedSchedule
|
||||||
|
} // namespace OHOS
|
||||||
|
#endif // DISTRIBUTED_SCHED_PERMISSION_TEST_H
|
@ -61,11 +61,9 @@ HWTEST_F(DistributedSchedPermissionTest, CheckDPermission_001, TestSize.Level0)
|
|||||||
CallerInfo callerInfo;
|
CallerInfo callerInfo;
|
||||||
IDistributedSched::AccountInfo accountInfo;
|
IDistributedSched::AccountInfo accountInfo;
|
||||||
accountInfo.accountType = IDistributedSched::DIFF_ACCOUNT_TYPE;
|
accountInfo.accountType = IDistributedSched::DIFF_ACCOUNT_TYPE;
|
||||||
AppExecFwk::AbilityInfo abilityInfo;
|
|
||||||
abilityInfo.visible = true;
|
|
||||||
std::string localDeviceId = "255.255.255.255";
|
std::string localDeviceId = "255.255.255.255";
|
||||||
int32_t ret = DistributedSchedPermission::GetInstance().CheckDPermission(want,
|
int32_t ret = DistributedSchedPermission::GetInstance().CheckDPermission(want,
|
||||||
callerInfo, accountInfo, abilityInfo, localDeviceId);
|
callerInfo, accountInfo, localDeviceId);
|
||||||
EXPECT_TRUE(ret != ERR_OK);
|
EXPECT_TRUE(ret != ERR_OK);
|
||||||
DTEST_LOG << "DistributedSchedPermissionTest CheckDPermission_001 end ret:" << ret << std::endl;
|
DTEST_LOG << "DistributedSchedPermissionTest CheckDPermission_001 end ret:" << ret << std::endl;
|
||||||
}
|
}
|
||||||
@ -82,11 +80,10 @@ HWTEST_F(DistributedSchedPermissionTest, CheckDPermission_002, TestSize.Level0)
|
|||||||
CallerInfo callerInfo;
|
CallerInfo callerInfo;
|
||||||
IDistributedSched::AccountInfo accountInfo;
|
IDistributedSched::AccountInfo accountInfo;
|
||||||
accountInfo.accountType = IDistributedSched::DIFF_ACCOUNT_TYPE;
|
accountInfo.accountType = IDistributedSched::DIFF_ACCOUNT_TYPE;
|
||||||
AppExecFwk::AbilityInfo abilityInfo;
|
bool needQueryExtension = true;
|
||||||
abilityInfo.visible = false;
|
|
||||||
std::string localDeviceId = "255.255.255.255";
|
std::string localDeviceId = "255.255.255.255";
|
||||||
int32_t ret = DistributedSchedPermission::GetInstance().CheckDPermission(want,
|
int32_t ret = DistributedSchedPermission::GetInstance().CheckDPermission(want,
|
||||||
callerInfo, accountInfo, abilityInfo, localDeviceId);
|
callerInfo, accountInfo, localDeviceId, needQueryExtension);
|
||||||
EXPECT_TRUE(ret != ERR_OK);
|
EXPECT_TRUE(ret != ERR_OK);
|
||||||
DTEST_LOG << "DistributedSchedPermissionTest CheckDPermission_002 end ret:" << ret << std::endl;
|
DTEST_LOG << "DistributedSchedPermissionTest CheckDPermission_002 end ret:" << ret << std::endl;
|
||||||
}
|
}
|
||||||
@ -103,11 +100,9 @@ HWTEST_F(DistributedSchedPermissionTest, CheckDPermission_003, TestSize.Level0)
|
|||||||
CallerInfo callerInfo;
|
CallerInfo callerInfo;
|
||||||
IDistributedSched::AccountInfo accountInfo;
|
IDistributedSched::AccountInfo accountInfo;
|
||||||
accountInfo.accountType = IDistributedSched::DIFF_ACCOUNT_TYPE;
|
accountInfo.accountType = IDistributedSched::DIFF_ACCOUNT_TYPE;
|
||||||
AppExecFwk::AbilityInfo abilityInfo;
|
|
||||||
abilityInfo.visible = true;
|
|
||||||
std::string localDeviceId = "";
|
std::string localDeviceId = "";
|
||||||
int32_t ret = DistributedSchedPermission::GetInstance().CheckDPermission(want,
|
int32_t ret = DistributedSchedPermission::GetInstance().CheckDPermission(want,
|
||||||
callerInfo, accountInfo, abilityInfo, localDeviceId);
|
callerInfo, accountInfo, localDeviceId);
|
||||||
EXPECT_TRUE(ret == INVALID_PARAMETERS_ERR);
|
EXPECT_TRUE(ret == INVALID_PARAMETERS_ERR);
|
||||||
DTEST_LOG << "DistributedSchedPermissionTest CheckDPermission_003 end ret:" << ret << std::endl;
|
DTEST_LOG << "DistributedSchedPermissionTest CheckDPermission_003 end ret:" << ret << std::endl;
|
||||||
}
|
}
|
||||||
@ -124,11 +119,10 @@ HWTEST_F(DistributedSchedPermissionTest, CheckDPermission_004, TestSize.Level0)
|
|||||||
CallerInfo callerInfo;
|
CallerInfo callerInfo;
|
||||||
IDistributedSched::AccountInfo accountInfo;
|
IDistributedSched::AccountInfo accountInfo;
|
||||||
accountInfo.accountType = IDistributedSched::DIFF_ACCOUNT_TYPE;
|
accountInfo.accountType = IDistributedSched::DIFF_ACCOUNT_TYPE;
|
||||||
AppExecFwk::AbilityInfo abilityInfo;
|
bool needQueryExtension = true;
|
||||||
abilityInfo.visible = false;
|
|
||||||
std::string localDeviceId = "";
|
std::string localDeviceId = "";
|
||||||
int32_t ret = DistributedSchedPermission::GetInstance().CheckDPermission(want,
|
int32_t ret = DistributedSchedPermission::GetInstance().CheckDPermission(want,
|
||||||
callerInfo, accountInfo, abilityInfo, localDeviceId);
|
callerInfo, accountInfo, localDeviceId, needQueryExtension);
|
||||||
EXPECT_TRUE(ret == INVALID_PARAMETERS_ERR);
|
EXPECT_TRUE(ret == INVALID_PARAMETERS_ERR);
|
||||||
DTEST_LOG << "DistributedSchedPermissionTest CheckDPermission_004 end ret:" << ret << std::endl;
|
DTEST_LOG << "DistributedSchedPermissionTest CheckDPermission_004 end ret:" << ret << std::endl;
|
||||||
}
|
}
|
||||||
@ -146,10 +140,9 @@ HWTEST_F(DistributedSchedPermissionTest, CheckDPermission_005, TestSize.Level0)
|
|||||||
CallerInfo callerInfo;
|
CallerInfo callerInfo;
|
||||||
callerInfo.accessToken = 0;
|
callerInfo.accessToken = 0;
|
||||||
IDistributedSched::AccountInfo accountInfo;
|
IDistributedSched::AccountInfo accountInfo;
|
||||||
AppExecFwk::AbilityInfo abilityInfo;
|
|
||||||
std::string localDeviceId = "255.255.255.255";
|
std::string localDeviceId = "255.255.255.255";
|
||||||
int32_t ret = DistributedSchedPermission::GetInstance().CheckDPermission(want, callerInfo, accountInfo, abilityInfo,
|
int32_t ret = DistributedSchedPermission::GetInstance().CheckDPermission(want,
|
||||||
localDeviceId);
|
callerInfo, accountInfo, localDeviceId);
|
||||||
EXPECT_TRUE(ret != ERR_OK);
|
EXPECT_TRUE(ret != ERR_OK);
|
||||||
DTEST_LOG << "DistributedSchedPermissionTest CheckDPermission_005 end result:" << ret << std::endl;
|
DTEST_LOG << "DistributedSchedPermissionTest CheckDPermission_005 end result:" << ret << std::endl;
|
||||||
}
|
}
|
||||||
@ -168,10 +161,9 @@ HWTEST_F(DistributedSchedPermissionTest, CheckDPermission_006, TestSize.Level1)
|
|||||||
callerInfo.accessToken = 0;
|
callerInfo.accessToken = 0;
|
||||||
IDistributedSched::AccountInfo accountInfo;
|
IDistributedSched::AccountInfo accountInfo;
|
||||||
accountInfo.accountType = IDistributedSched::DIFF_ACCOUNT_TYPE;
|
accountInfo.accountType = IDistributedSched::DIFF_ACCOUNT_TYPE;
|
||||||
AppExecFwk::AbilityInfo abilityInfo;
|
|
||||||
string localDeviceId = "255.255.255.255";
|
string localDeviceId = "255.255.255.255";
|
||||||
int32_t ret = DistributedSchedPermission::GetInstance().CheckDPermission(want, callerInfo, accountInfo, abilityInfo,
|
int32_t ret = DistributedSchedPermission::GetInstance().CheckDPermission(want,
|
||||||
localDeviceId);
|
callerInfo, accountInfo, localDeviceId);
|
||||||
EXPECT_TRUE(ret != ERR_OK);
|
EXPECT_TRUE(ret != ERR_OK);
|
||||||
DTEST_LOG << "DistributedSchedPermissionTest CheckDPermission_006 end result:" << ret << std::endl;
|
DTEST_LOG << "DistributedSchedPermissionTest CheckDPermission_006 end result:" << ret << std::endl;
|
||||||
}
|
}
|
||||||
@ -189,11 +181,9 @@ HWTEST_F(DistributedSchedPermissionTest, CheckDPermission_007, TestSize.Level1)
|
|||||||
CallerInfo callerInfo;
|
CallerInfo callerInfo;
|
||||||
callerInfo.accessToken = 0;
|
callerInfo.accessToken = 0;
|
||||||
IDistributedSched::AccountInfo accountInfo;
|
IDistributedSched::AccountInfo accountInfo;
|
||||||
AppExecFwk::AbilityInfo abilityInfo;
|
|
||||||
abilityInfo.visible = true;
|
|
||||||
string localDeviceId = "255.255.255.255";
|
string localDeviceId = "255.255.255.255";
|
||||||
int32_t ret = DistributedSchedPermission::GetInstance().CheckDPermission(want, callerInfo, accountInfo, abilityInfo,
|
int32_t ret = DistributedSchedPermission::GetInstance().CheckDPermission(want,
|
||||||
localDeviceId);
|
callerInfo, accountInfo, localDeviceId);
|
||||||
EXPECT_TRUE(ret != ERR_OK);
|
EXPECT_TRUE(ret != ERR_OK);
|
||||||
DTEST_LOG << "DistributedSchedPermissionTest CheckDPermission_007 end result:" << ret << std::endl;
|
DTEST_LOG << "DistributedSchedPermissionTest CheckDPermission_007 end result:" << ret << std::endl;
|
||||||
}
|
}
|
||||||
@ -212,10 +202,9 @@ HWTEST_F(DistributedSchedPermissionTest, CheckDPermission_008, TestSize.Level0)
|
|||||||
callerInfo.accessToken = 0;
|
callerInfo.accessToken = 0;
|
||||||
IDistributedSched::AccountInfo accountInfo;
|
IDistributedSched::AccountInfo accountInfo;
|
||||||
accountInfo.accountType = IDistributedSched::SAME_ACCOUNT_TYPE;
|
accountInfo.accountType = IDistributedSched::SAME_ACCOUNT_TYPE;
|
||||||
AppExecFwk::AbilityInfo abilityInfo;
|
|
||||||
string localDeviceId = "255.255.255.255";
|
string localDeviceId = "255.255.255.255";
|
||||||
int32_t ret = DistributedSchedPermission::GetInstance().CheckDPermission(want, callerInfo, accountInfo, abilityInfo,
|
int32_t ret = DistributedSchedPermission::GetInstance().CheckDPermission(want,
|
||||||
localDeviceId);
|
callerInfo, accountInfo, localDeviceId);
|
||||||
EXPECT_TRUE(ret != ERR_OK);
|
EXPECT_TRUE(ret != ERR_OK);
|
||||||
DTEST_LOG << "DistributedSchedPermissionTest CheckDPermission_008 end result:" << ret << std::endl;
|
DTEST_LOG << "DistributedSchedPermissionTest CheckDPermission_008 end result:" << ret << std::endl;
|
||||||
}
|
}
|
||||||
@ -236,11 +225,9 @@ HWTEST_F(DistributedSchedPermissionTest, CheckDPermission_009, TestSize.Level1)
|
|||||||
accountInfo.accountType = IDistributedSched::DIFF_ACCOUNT_TYPE;
|
accountInfo.accountType = IDistributedSched::DIFF_ACCOUNT_TYPE;
|
||||||
std::string groupId = GROUP_ID;
|
std::string groupId = GROUP_ID;
|
||||||
accountInfo.groupIdList.push_back(groupId);
|
accountInfo.groupIdList.push_back(groupId);
|
||||||
AppExecFwk::AbilityInfo abilityInfo;
|
|
||||||
abilityInfo.visible = true;
|
|
||||||
string localDeviceId = "255.255.255.255";
|
string localDeviceId = "255.255.255.255";
|
||||||
int32_t ret = DistributedSchedPermission::GetInstance().CheckDPermission(want, callerInfo, accountInfo, abilityInfo,
|
int32_t ret = DistributedSchedPermission::GetInstance().CheckDPermission(want,
|
||||||
localDeviceId);
|
callerInfo, accountInfo, localDeviceId);
|
||||||
EXPECT_TRUE(ret != ERR_OK);
|
EXPECT_TRUE(ret != ERR_OK);
|
||||||
DTEST_LOG << "DistributedSchedPermissionTest CheckDPermission_009 end result:" << ret << std::endl;
|
DTEST_LOG << "DistributedSchedPermissionTest CheckDPermission_009 end result:" << ret << std::endl;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user