mirror of
https://gitee.com/openharmony/accesscontrol_sandbox_manager
synced 2024-11-27 00:40:46 +00:00
no message
Match-id-0cd07a510314aff8cee6dca26d9d60e077cab8c1
This commit is contained in:
parent
06ab156732
commit
3dc72f9eba
25
BUILD.gn
Normal file
25
BUILD.gn
Normal file
@ -0,0 +1,25 @@
|
||||
# Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//build/ohos.gni")
|
||||
import("sandbox_manager.gni")
|
||||
|
||||
group("sandbox_manager_build_module_test") {
|
||||
testonly = true
|
||||
deps = []
|
||||
if (is_standard_system) {
|
||||
deps += [
|
||||
"interfaces/innerkits/sandbox_manager/test:unittest",
|
||||
]
|
||||
}
|
||||
}
|
54
bundle.json
Normal file
54
bundle.json
Normal file
@ -0,0 +1,54 @@
|
||||
{
|
||||
"name": "@openharmony/sandbox_manager",
|
||||
"description": "SandboxManager",
|
||||
"version": "0.0.0",
|
||||
"license": "Apache License 2.0",
|
||||
"publishAs": "code-segment",
|
||||
"segment": {
|
||||
"destPath": "base/accesscontrol/sandbox_manager"
|
||||
},
|
||||
"dirs": {},
|
||||
"scripts": {},
|
||||
"component": {
|
||||
"name": "sandbox_manager",
|
||||
"subsystem": "accesscontrol",
|
||||
"syscap": [
|
||||
],
|
||||
"features": [],
|
||||
"adapted_system_type": [ "standard" ],
|
||||
"rom": "10000KB",
|
||||
"ram": "5000KB",
|
||||
"deps": {
|
||||
"components": [
|
||||
"c_utils",
|
||||
"hilog",
|
||||
"ipc",
|
||||
"safwk",
|
||||
"samgr"
|
||||
],
|
||||
"third_party": [
|
||||
"sqlite"
|
||||
]
|
||||
},
|
||||
"build": {
|
||||
"group_type":{
|
||||
"service_group": [
|
||||
]
|
||||
},
|
||||
"inner_kits": [
|
||||
{
|
||||
"name": "//base/accesscontrol/sandbox_manager/interfaces/innerkits/sandbox_manager:libsandbox_manager_sdk",
|
||||
"header": {
|
||||
"header_base": "//base/accesscontrol/sandbox_manager/interfaces/innerkits/sandbox_manager/include",
|
||||
"header_files": [
|
||||
"sandbox_manager_kit.h"
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"test": [
|
||||
"//base/accesscontrol/sandbox_manager:sandbox_manager_build_module_test"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
23
config/BUILD.gn
Normal file
23
config/BUILD.gn
Normal file
@ -0,0 +1,23 @@
|
||||
# Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
declare_args() {
|
||||
sandbox_manager_feature_coverage = false
|
||||
}
|
||||
|
||||
config("coverage_flags") {
|
||||
if (sandbox_manager_feature_coverage) {
|
||||
cflags = [ "--coverage" ]
|
||||
ldflags = [ "--coverage" ]
|
||||
}
|
||||
}
|
51
frameworks/common/BUILD.gn
Normal file
51
frameworks/common/BUILD.gn
Normal file
@ -0,0 +1,51 @@
|
||||
# Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//build/ohos.gni")
|
||||
import("../../sandbox_manager.gni")
|
||||
|
||||
config("sandbox_manager_common_cxx_public_config") {
|
||||
visibility = [ ":*" ]
|
||||
include_dirs = [ "include" ]
|
||||
}
|
||||
|
||||
ohos_shared_library("sandbox_manager_common_cxx") {
|
||||
subsystem_name = "accesscontrol"
|
||||
innerapi_tags = [ "platformsdk_indirect" ]
|
||||
part_name = "sandbox_manager"
|
||||
|
||||
public_configs = [ ":sandbox_manager_common_cxx_public_config" ]
|
||||
|
||||
include_dirs = [
|
||||
"${sandbox_manager_path}/interfaces/innerkits/sandbox_manager/include",
|
||||
"include",
|
||||
]
|
||||
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
debug = true
|
||||
}
|
||||
|
||||
sources = []
|
||||
|
||||
deps = [ ]
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"hilog:libhilog",
|
||||
]
|
||||
|
||||
configs = [ "${sandbox_manager_path}/config:coverage_flags" ]
|
||||
|
||||
cflags_cc = [ "-DHILOG_ENABLE" ]
|
||||
}
|
68
frameworks/common/include/sandbox_manager_log.h
Normal file
68
frameworks/common/include/sandbox_manager_log.h
Normal file
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef SANDBOXMANAGER_LOG_H
|
||||
#define SANDBOXMANAGER_LOG_H
|
||||
|
||||
#ifdef HILOG_ENABLE
|
||||
|
||||
#include "hilog/log.h"
|
||||
|
||||
#ifndef __cplusplus
|
||||
|
||||
#define SANDBOXMANAGER_LOG_DEBUG(fmt, ...) HILOG_DEBUG(LOG_CORE, "[%{public}s]:" fmt, __func__, ##__VA_ARGS__)
|
||||
#define SANDBOXMANAGER_LOG_INFO(fmt, ...) HILOG_INFO(LOG_CORE, "[%{public}s]:" fmt, __func__, ##__VA_ARGS__)
|
||||
#define SANDBOXMANAGER_LOG_WARN(fmt, ...) HILOG_WARN(LOG_CORE, "[%{public}s]:" fmt, __func__, ##__VA_ARGS__)
|
||||
#define SANDBOXMANAGER_LOG_ERROR(fmt, ...) HILOG_ERROR(LOG_CORE, "[%{public}s]:" fmt, __func__, ##__VA_ARGS__)
|
||||
#define SANDBOXMANAGER_LOG_FATAL(fmt, ...) HILOG_FATAL(LOG_CORE, "[%{public}s]:" fmt, __func__, ##__VA_ARGS__)
|
||||
|
||||
#else
|
||||
|
||||
#define SANDBOXMANAGER_LOG_DEBUG(label, fmt, ...) \
|
||||
OHOS::HiviewDFX::HiLog::Debug(label, "[%{public}s]:" fmt, __func__, ##__VA_ARGS__)
|
||||
#define SANDBOXMANAGER_LOG_INFO(label, fmt, ...) \
|
||||
OHOS::HiviewDFX::HiLog::Info(label, "[%{public}s]:" fmt, __func__, ##__VA_ARGS__)
|
||||
#define SANDBOXMANAGER_LOG_WARN(label, fmt, ...) \
|
||||
OHOS::HiviewDFX::HiLog::Warn(label, "[%{public}s]:" fmt, __func__, ##__VA_ARGS__)
|
||||
#define SANDBOXMANAGER_LOG_ERROR(label, fmt, ...) \
|
||||
OHOS::HiviewDFX::HiLog::Error(label, "[%{public}s]:" fmt, __func__, ##__VA_ARGS__)
|
||||
#define SANDBOXMANAGER_LOG_FATAL(label, fmt, ...) \
|
||||
OHOS::HiviewDFX::HiLog::Fatal(label, "[%{public}s]:" fmt, __func__, ##__VA_ARGS__)
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
/* define LOG_TAG as "accesscontrol_*" at your submodule, * means your submodule name such as "accesscontrol__dac" */
|
||||
#undef LOG_TAG
|
||||
#undef LOG_DOMAIN
|
||||
// static constexpr unsigned int ACCESSCONTROL_DOMAIN_SANDBOXMANAGER = 0xD005A07;
|
||||
static constexpr unsigned int ACCESSCONTROL_DOMAIN_SANDBOXMANAGER = 0xD002F0A;
|
||||
|
||||
#else
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
/* define LOG_TAG as "accesscontrol__*" at your submodule, * means your submodule name such as "accesscontrol__dac" */
|
||||
#undef LOG_TAG
|
||||
|
||||
#define SANDBOXMANAGER_LOG_DEBUG(fmt, ...) printf("[%s] debug: %s: " fmt "\n", LOG_TAG, __func__, ##__VA_ARGS__)
|
||||
#define SANDBOXMANAGER_LOG_INFO(fmt, ...) printf("[%s] info: %s: " fmt "\n", LOG_TAG, __func__, ##__VA_ARGS__)
|
||||
#define SANDBOXMANAGER_LOG_WARN(fmt, ...) printf("[%s] warn: %s: " fmt "\n", LOG_TAG, __func__, ##__VA_ARGS__)
|
||||
#define SANDBOXMANAGER_LOG_ERROR(fmt, ...) printf("[%s] error: %s: " fmt "\n", LOG_TAG, __func__, ##__VA_ARGS__)
|
||||
#define SANDBOXMANAGER_LOG_FATAL(fmt, ...) printf("[%s] fatal: %s: " fmt "\n", LOG_TAG, __func__, ##__VA_ARGS__)
|
||||
|
||||
#endif // HILOG_ENABLE
|
||||
|
||||
#endif // SANDBOXMANAGER_LOG_H
|
48
frameworks/sandbox_manager/BUILD.gn
Normal file
48
frameworks/sandbox_manager/BUILD.gn
Normal file
@ -0,0 +1,48 @@
|
||||
# Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//build/ohos.gni")
|
||||
import("../../sandbox_manager.gni")
|
||||
|
||||
config("sandbox_manager_communication_adapter_cxx_public_config") {
|
||||
visibility = [ ":*" ]
|
||||
include_dirs = [
|
||||
"include",
|
||||
"${sandbox_manager_path}/frameworks/common/include",
|
||||
"${sandbox_manager_path}/interfaces/innerkits/sandbox_manager/include",
|
||||
]
|
||||
}
|
||||
|
||||
ohos_shared_library("sandbox_manager_communication_adapter_cxx") {
|
||||
subsystem_name = "accesscontrol"
|
||||
innerapi_tags = [ "platformsdk_indirect" ]
|
||||
part_name = "sandbox_manager"
|
||||
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
debug = true
|
||||
}
|
||||
|
||||
public_configs = [ ":sandbox_manager_communication_adapter_cxx_public_config" ]
|
||||
configs = [ "${sandbox_manager_path}/config:coverage_flags" ]
|
||||
|
||||
include_dirs = [
|
||||
"${sandbox_manager_path}/interfaces/innerkits/sandbox_manager/include",
|
||||
"include",
|
||||
]
|
||||
|
||||
sources = []
|
||||
|
||||
external_deps = [ "c_utils:utils" ]
|
||||
}
|
45
frameworks/sandbox_manager/include/i_sandbox_manager.h
Normal file
45
frameworks/sandbox_manager/include/i_sandbox_manager.h
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef I_SANDBOX_MANAGER_H
|
||||
#define I_SANDBOX_MANAGER_H
|
||||
|
||||
#include "errors.h"
|
||||
#include "iremote_broker.h"
|
||||
#include "system_ability_definition.h"
|
||||
#include "policy_info.h"
|
||||
#include <vector>
|
||||
|
||||
namespace OHOS {
|
||||
namespace AccessControl {
|
||||
namespace SandboxManager {
|
||||
class ISandboxManager : public IRemoteBroker {
|
||||
public:
|
||||
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.accesscontrol.sandbox_manager.ISandboxManager");
|
||||
|
||||
virtual int persistPermission(const std::vector<PolicyInfo> &policy, std::vector<uint32_t> &result) = 0;
|
||||
virtual int unPersistPermission(const std::vector<PolicyInfo> &policy, std::vector<uint32_t> &result) = 0;
|
||||
virtual int setPolicy(
|
||||
uint64_t tokenid, const std::vector<PolicyInfo> &policy, std::vector<uint32_t> &result) = 0;
|
||||
virtual int startAccessingURI(const std::vector<PolicyInfo> &policy, std::vector<uint32_t> &result) = 0;
|
||||
virtual int stopAccessingURI(const std::vector<PolicyInfo> &policy, std::vector<uint32_t> &result) = 0;
|
||||
virtual int checkPersistPermission(
|
||||
uint64_t tokenid, const std::vector<PolicyInfo> &policy, std::vector<bool> &result) = 0;
|
||||
};
|
||||
} // namespace SandboxManager
|
||||
} // namespace AccessControl
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // I_SANDBOX_MANAGER_H
|
78
interfaces/innerkits/sandbox_manager/BUILD.gn
Normal file
78
interfaces/innerkits/sandbox_manager/BUILD.gn
Normal file
@ -0,0 +1,78 @@
|
||||
# Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//build/ohos.gni")
|
||||
import("../../../sandbox_manager.gni")
|
||||
|
||||
config("sandbox_manager") {
|
||||
visibility = [ ":*" ]
|
||||
include_dirs = [ "include" ]
|
||||
}
|
||||
|
||||
if (is_standard_system) {
|
||||
ohos_shared_library("libsandbox_manager_sdk") {
|
||||
subsystem_name = "accesscontrol"
|
||||
part_name = "sandbox_manager"
|
||||
innerapi_tags = [
|
||||
"platformsdk",
|
||||
"sasdk",
|
||||
]
|
||||
if (!use_clang_coverage) {
|
||||
version_script = "libsandbox_manager_sdk.map"
|
||||
}
|
||||
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
debug = true
|
||||
}
|
||||
|
||||
output_name = "libsandbox_manager_sdk"
|
||||
|
||||
public_configs = [ ":sandbox_manager" ]
|
||||
|
||||
include_dirs = [
|
||||
"${sandbox_manager_path}/frameworks/sandbox_manager/include",
|
||||
"${sandbox_manager_path}/frameworks/common/include",
|
||||
"src",
|
||||
"include",
|
||||
]
|
||||
|
||||
sources = [
|
||||
"src/sandbox_manager_kit.cpp",
|
||||
"src/sandbox_manager_client.cpp",
|
||||
# "src/sandbox_manager_proxy.cpp",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"${sandbox_manager_path}/frameworks/sandbox_manager:sandbox_manager_communication_adapter_cxx",
|
||||
"${sandbox_manager_path}/frameworks/common:sandbox_manager_common_cxx",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_single",
|
||||
"samgr:samgr_proxy",
|
||||
]
|
||||
|
||||
configs = [ "${sandbox_manager_path}/config:coverage_flags" ]
|
||||
|
||||
cflags_cc = [
|
||||
"-DHILOG_ENABLE",
|
||||
"-DDEBUG_API_PERFORMANCE",
|
||||
]
|
||||
|
||||
}
|
||||
}
|
||||
|
35
interfaces/innerkits/sandbox_manager/include/policy_info.h
Normal file
35
interfaces/innerkits/sandbox_manager/include/policy_info.h
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef POLICY_INFO_H
|
||||
#define POLICY_INFO_H
|
||||
|
||||
#include <string>
|
||||
#include <cstdint>
|
||||
|
||||
namespace OHOS {
|
||||
namespace AccessControl {
|
||||
namespace SandboxManager {
|
||||
struct PolicyInfo final {
|
||||
public:
|
||||
std::string path;
|
||||
uint64_t mode;
|
||||
};
|
||||
|
||||
} // namespace SandboxManager
|
||||
} // namespace AccessControl
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // POLICY_INFO_H
|
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup
|
||||
* @{
|
||||
*
|
||||
* @brief
|
||||
*
|
||||
* @since
|
||||
* @version
|
||||
*/
|
||||
|
||||
#ifndef SANDBOXMANAGER_CLIENT_H
|
||||
#define SANDBOXMANAGER_CLIENT_H
|
||||
|
||||
#include "i_sandbox_manager.h"
|
||||
#include "refbase.h"
|
||||
#include "nocopyable.h"
|
||||
#include "policy_info.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AccessControl {
|
||||
namespace SandboxManager {
|
||||
class SandboxManagerClient final {
|
||||
public:
|
||||
static SandboxManagerClient& GetInstance();
|
||||
virtual ~SandboxManagerClient();
|
||||
|
||||
int persistPermission(const std::vector<PolicyInfo> &policy, std::vector<uint32_t> &result);
|
||||
int unPersistPermission(const std::vector<PolicyInfo> &policy, std::vector<uint32_t> &result);
|
||||
int setPolicy(uint64_t tokenid, const std::vector<PolicyInfo> &policy, std::vector<uint32_t> &result);
|
||||
int startAccessingURI(const std::vector<PolicyInfo> &policy, std::vector<uint32_t> &result);
|
||||
int stopAccessingURI(const std::vector<PolicyInfo> &policy, std::vector<uint32_t> &result);
|
||||
int checkPersistPermission(uint64_t tokenid, const std::vector<PolicyInfo> &policy, std::vector<bool> &result);
|
||||
|
||||
private:
|
||||
SandboxManagerClient();
|
||||
DISALLOW_COPY_AND_MOVE(SandboxManagerClient);
|
||||
sptr<ISandboxManager> proxy_ = nullptr;
|
||||
};
|
||||
} // SandboxManager
|
||||
} // AccessControl
|
||||
} // OHOS
|
||||
#endif //SANDBOXMANAGER_CLIENT_H
|
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup
|
||||
* @{
|
||||
*
|
||||
* @brief
|
||||
*
|
||||
* @since
|
||||
* @version
|
||||
*/
|
||||
|
||||
#ifndef SANDBOXMANAGER_KIT_H
|
||||
#define SANDBOXMANAGER_KIT_H
|
||||
|
||||
#include "policy_info.h"
|
||||
namespace OHOS {
|
||||
namespace AccessControl {
|
||||
namespace SandboxManager {
|
||||
/**
|
||||
* @brief Declares SandboxManagerKit class
|
||||
*/
|
||||
class SandboxManagerKit {
|
||||
public:
|
||||
static int persistPermission(const std::vector<PolicyInfo> &policy, std::vector<uint32_t> &result);
|
||||
static int unPersistPermission(const std::vector<PolicyInfo> &policy, std::vector<uint32_t> &result);
|
||||
static int setPolicy(uint64_t tokenid, const std::vector<PolicyInfo> &policy, std::vector<uint32_t> &result);
|
||||
static int startAccessingURI(const std::vector<PolicyInfo> &policy, std::vector<uint32_t> &result);
|
||||
static int stopAccessingURI(const std::vector<PolicyInfo> &policy, std::vector<uint32_t> &result);
|
||||
static int checkPersistPermission(
|
||||
uint64_t tokenid, const std::vector<PolicyInfo> &policy, std::vector<bool> &result);
|
||||
};
|
||||
} // SandboxManager
|
||||
} // AccessControl
|
||||
} // OHOS
|
||||
#endif //SANDBOXMANAGER_KIT_H
|
@ -0,0 +1,30 @@
|
||||
# Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
1.0 {
|
||||
global:
|
||||
extern "C++" {
|
||||
"OHOS::AccessControl::SandboxManager::SandboxManagerKit::persistPermission(std::__h::vector<OHOS::AccessControl::SandboxManager::PolicyInfo, std::__h::allocator<OHOS::AccessControl::SandboxManager::PolicyInfo>> const&, std::__h::vector<unsigned int, std::__h::allocator<unsigned int>>&)";
|
||||
"OHOS::AccessControl::SandboxManager::SandboxManagerKit::unPersistPermission(std::__h::vector<OHOS::AccessControl::SandboxManager::PolicyInfo, std::__h::allocator<OHOS::AccessControl::SandboxManager::PolicyInfo>> const&, std::__h::vector<unsigned int, std::__h::allocator<unsigned int>>&)";
|
||||
"OHOS::AccessControl::SandboxManager::SandboxManagerKit::setPolicy(unsigned long, std::__h::vector<OHOS::AccessControl::SandboxManager::PolicyInfo, std::__h::allocator<OHOS::AccessControl::SandboxManager::PolicyInfo>> const&, std::__h::vector<unsigned int, std::__h::allocator<unsigned int>>&)";
|
||||
"OHOS::AccessControl::SandboxManager::SandboxManagerKit::startAccessingURI(std::__h::vector<OHOS::AccessControl::SandboxManager::PolicyInfo, std::__h::allocator<OHOS::AccessControl::SandboxManager::PolicyInfo>> const&, std::__h::vector<unsigned int, std::__h::allocator<unsigned int>>&)";
|
||||
"OHOS::AccessControl::SandboxManager::SandboxManagerKit::stopAccessingURI(std::__h::vector<OHOS::AccessControl::SandboxManager::PolicyInfo, std::__h::allocator<OHOS::AccessControl::SandboxManager::PolicyInfo>> const&, std::__h::vector<unsigned int, std::__h::allocator<unsigned int>>&)";
|
||||
"OHOS::AccessControl::SandboxManager::SandboxManagerKit::checkPersistPermission(unsigned long, std::__h::vector<OHOS::AccessControl::SandboxManager::PolicyInfo, std::__h::allocator<OHOS::AccessControl::SandboxManager::PolicyInfo>> const&, std::__h::vector<bool, std::__h::allocator<bool>>&)";
|
||||
"OHOS::AccessControl::SandboxManager::SandboxManagerClient::GetInstance()";
|
||||
"OHOS::AccessControl::SandboxManager::SandboxManagerClient::InitProxy()";
|
||||
"";
|
||||
"";
|
||||
};
|
||||
local:
|
||||
*;
|
||||
};
|
@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "sandbox_manager_client.h"
|
||||
#include "i_sandbox_manager.h"
|
||||
#include "refbase.h"
|
||||
#include "sandbox_manager_log.h"
|
||||
#include "iservice_registry.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AccessControl {
|
||||
namespace SandboxManager {
|
||||
static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {
|
||||
LOG_CORE, ACCESSCONTROL_DOMAIN_SANDBOXMANAGER, "SandboxManagerClient"
|
||||
};
|
||||
|
||||
SandboxManagerClient& SandboxManagerClient::GetInstance()
|
||||
{
|
||||
static SandboxManagerClient instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
SandboxManagerClient::SandboxManagerClient()
|
||||
{}
|
||||
|
||||
SandboxManagerClient::~SandboxManagerClient()
|
||||
{}
|
||||
|
||||
|
||||
int SandboxManagerClient::persistPermission(const std::vector<PolicyInfo> &policy, std::vector<uint32_t> &result)
|
||||
{
|
||||
SANDBOXMANAGER_LOG_DEBUG(LABEL, "call");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SandboxManagerClient::unPersistPermission(const std::vector<PolicyInfo> &policy, std::vector<uint32_t> &result)
|
||||
{
|
||||
SANDBOXMANAGER_LOG_DEBUG(LABEL, "call");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SandboxManagerClient::setPolicy(
|
||||
uint64_t tokenid, const std::vector<PolicyInfo> &policy, std::vector<uint32_t> &result)
|
||||
{
|
||||
SANDBOXMANAGER_LOG_DEBUG(LABEL, "call");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SandboxManagerClient::startAccessingURI(const std::vector<PolicyInfo> &policy, std::vector<uint32_t> &result)
|
||||
{
|
||||
SANDBOXMANAGER_LOG_DEBUG(LABEL, "call");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SandboxManagerClient::stopAccessingURI(const std::vector<PolicyInfo> &policy, std::vector<uint32_t> &result)
|
||||
{
|
||||
SANDBOXMANAGER_LOG_DEBUG(LABEL, "call");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SandboxManagerClient::checkPersistPermission(
|
||||
uint64_t tokenid, const std::vector<PolicyInfo> &policy, std::vector<bool> &result)
|
||||
{
|
||||
SANDBOXMANAGER_LOG_DEBUG(LABEL, "call");
|
||||
return 0;
|
||||
}
|
||||
} // SandboxManager
|
||||
} // AccessControl
|
||||
} // OHOS
|
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
#include "sandbox_manager_client.h"
|
||||
#include "sandbox_manager_kit.h"
|
||||
#include "sandbox_manager_log.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AccessControl {
|
||||
namespace SandboxManager {
|
||||
namespace {
|
||||
static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, ACCESSCONTROL_DOMAIN_SANDBOXMANAGER, "SandboxMngKit"};
|
||||
}
|
||||
|
||||
int SandboxManagerKit::persistPermission(const std::vector<PolicyInfo> &policy, std::vector<uint32_t> &result)
|
||||
{
|
||||
SANDBOXMANAGER_LOG_DEBUG(LABEL, "called");
|
||||
return SandboxManagerClient::GetInstance().persistPermission(policy, result);
|
||||
}
|
||||
|
||||
int SandboxManagerKit::unPersistPermission(const std::vector<PolicyInfo> &policy, std::vector<uint32_t> &result)
|
||||
{
|
||||
SANDBOXMANAGER_LOG_DEBUG(LABEL, "called");
|
||||
return SandboxManagerClient::GetInstance().unPersistPermission(policy, result);
|
||||
}
|
||||
|
||||
int SandboxManagerKit::setPolicy(
|
||||
uint64_t tokenid, const std::vector<PolicyInfo> &policy, std::vector<uint32_t> &result)
|
||||
{
|
||||
SANDBOXMANAGER_LOG_DEBUG(LABEL, "called");
|
||||
return SandboxManagerClient::GetInstance().setPolicy(tokenid, policy, result);
|
||||
}
|
||||
|
||||
int SandboxManagerKit::startAccessingURI(const std::vector<PolicyInfo> &policy, std::vector<uint32_t> &result)
|
||||
{
|
||||
SANDBOXMANAGER_LOG_DEBUG(LABEL, "called");
|
||||
return SandboxManagerClient::GetInstance().startAccessingURI(policy, result);
|
||||
}
|
||||
|
||||
int SandboxManagerKit::stopAccessingURI(const std::vector<PolicyInfo> &policy, std::vector<uint32_t> &result)
|
||||
{
|
||||
SANDBOXMANAGER_LOG_DEBUG(LABEL, "called");
|
||||
return SandboxManagerClient::GetInstance().stopAccessingURI(policy, result);
|
||||
}
|
||||
|
||||
int SandboxManagerKit::checkPersistPermission(
|
||||
uint64_t tokenid, const std::vector<PolicyInfo> &policy, std::vector<bool> &result)
|
||||
{
|
||||
SANDBOXMANAGER_LOG_DEBUG(LABEL, "called");
|
||||
return SandboxManagerClient::GetInstance().checkPersistPermission(tokenid, policy, result);
|
||||
}
|
||||
|
||||
} // SandboxManager
|
||||
} // AccessControl
|
||||
} // OHOS
|
58
interfaces/innerkits/sandbox_manager/test/BUILD.gn
Normal file
58
interfaces/innerkits/sandbox_manager/test/BUILD.gn
Normal file
@ -0,0 +1,58 @@
|
||||
# Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//build/test.gni")
|
||||
import("../../../../sandbox_manager.gni")
|
||||
|
||||
ohos_unittest("libsandbox_manager_sdk_test") {
|
||||
subsystem_name = "accesscontrol"
|
||||
part_name = "sandbox_manager"
|
||||
module_out_path = part_name + "/" + part_name
|
||||
|
||||
include_dirs = [
|
||||
"${sandbox_manager_path}/frameworks/sandbox_manager/include",
|
||||
"${sandbox_manager_path}/frameworks/common/include",
|
||||
"../include",
|
||||
"../src",
|
||||
"//third_party/googletest/include",
|
||||
"//foundation/systemabilitymgr/samgr/interfaces/innerkits/samgr_proxy/include",
|
||||
"unittest/include",
|
||||
]
|
||||
|
||||
sources = [
|
||||
"unittest/src/sandbox_manager_kit_test.cpp",
|
||||
]
|
||||
|
||||
cflags_cc = [ "-DHILOG_ENABLE" ]
|
||||
|
||||
|
||||
deps = [
|
||||
"${sandbox_manager_path}/frameworks/sandbox_manager:sandbox_manager_communication_adapter_cxx",
|
||||
"../:libsandbox_manager_sdk",
|
||||
"${sandbox_manager_path}/frameworks/common:sandbox_manager_common_cxx"
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"dsoftbus:softbus_client",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_single",
|
||||
]
|
||||
}
|
||||
|
||||
group("unittest") {
|
||||
testonly = true
|
||||
deps = [
|
||||
":libsandbox_manager_sdk_test"
|
||||
]
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef SANDBOXMANAGER_KIT_TEST_H
|
||||
#define SANDBOXMANAGER_KIT_TEST_H
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
namespace OHOS {
|
||||
namespace AccessControl {
|
||||
namespace SandboxManager {
|
||||
class SandboxManagerKitTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
static void TearDownTestCase();
|
||||
|
||||
void SetUp();
|
||||
void TearDown();
|
||||
};
|
||||
} //SandboxManager
|
||||
} //AccessControl
|
||||
} // OHOS
|
||||
|
||||
#endif // SANDBOXMANAGER_KIT_TEST_H
|
@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "sandbox_manager_kit_test.h"
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
#include "policy_info.h"
|
||||
#include "sandbox_manager_client.h"
|
||||
#include "sandbox_manager_kit.h"
|
||||
#include "sandbox_manager_log.h"
|
||||
|
||||
using namespace testing::ext;
|
||||
|
||||
namespace OHOS {
|
||||
namespace AccessControl {
|
||||
namespace SandboxManager {
|
||||
|
||||
static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {
|
||||
LOG_CORE, ACCESSCONTROL_DOMAIN_SANDBOXMANAGER, "SandboxManagerKitTest"
|
||||
};
|
||||
|
||||
void SandboxManagerKitTest::SetUpTestCase()
|
||||
{
|
||||
}
|
||||
|
||||
void SandboxManagerKitTest::TearDownTestCase()
|
||||
{
|
||||
}
|
||||
|
||||
void SandboxManagerKitTest::SetUp()
|
||||
{
|
||||
}
|
||||
|
||||
void SandboxManagerKitTest::TearDown()
|
||||
{
|
||||
}
|
||||
|
||||
HWTEST_F(SandboxManagerKitTest, SdkTest, TestSize.Level1)
|
||||
{
|
||||
SANDBOXMANAGER_LOG_DEBUG(LABEL, "call");
|
||||
PolicyInfo info;
|
||||
std::vector<PolicyInfo> policy;
|
||||
policy.push_back(info);
|
||||
std::vector<uint32_t> result;
|
||||
ASSERT_EQ(0, SandboxManagerKit::persistPermission(policy, result));
|
||||
ASSERT_EQ(0, SandboxManagerKit::unPersistPermission(policy, result));
|
||||
uint64_t token = 0;
|
||||
ASSERT_EQ(0, SandboxManagerKit::setPolicy(token, policy, result));
|
||||
ASSERT_EQ(0, SandboxManagerKit::startAccessingURI(policy, result));
|
||||
ASSERT_EQ(0, SandboxManagerKit::stopAccessingURI(policy, result));
|
||||
std::vector<bool> tmp;
|
||||
ASSERT_EQ(0, SandboxManagerKit::checkPersistPermission(token, policy, tmp));
|
||||
}
|
||||
|
||||
} //SandboxManager
|
||||
} //AccessControl
|
||||
} // OHOS
|
20
sandbox_manager.gni
Normal file
20
sandbox_manager.gni
Normal file
@ -0,0 +1,20 @@
|
||||
# Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
sandbox_manager_path = "//base/accesscontrol/sandbox_manager"
|
||||
module_output_path_interface_sandbox =
|
||||
"sandbox_manager/interface/"
|
||||
module_output_path_service_sandbox =
|
||||
"sandbox_manager/service"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user