diff --git a/LICENSE b/LICENSE
old mode 100755
new mode 100644
diff --git a/README.md b/README.md
old mode 100755
new mode 100644
index c2f7ce48bd22f1069bcae128e92990a59731c795..0bde5baf67408416b7d90b9804b5e5d311045337
--- a/README.md
+++ b/README.md
@@ -1,26 +1,31 @@
-# samgr
-## Introduction
+# Samgr
+## Introduction
+
+The System Ability Manager (Samgr) component is a core component of OpenHarmony. It provides functions related to system abilities (also called system services), including the startup, registration, and query.
+
+## System Architecture
+
+Figure 1 Architecture of Samgr
-The **samgr** module is a core module of OpenHarmony. It provides functions, such as start, registration, and query, of system abilities (also called system services).

-## Directory Structure
+## Directory Structure
```
/foundation/systemabilitymgr
├── samgr
-│ ├── bundle.json # Description and build file of samgr
+│ ├── bundle.json # Description and build file of Samgr
│ ├── frameworks # Framework implementation
│ ├── interfaces # APIs
-│ ├── services # Directory for samgr services
+│ ├── services # Directory for the Samgr service
│ ├── test # Test code
│ ├── utils # Utils
```
-## Usage
+## Description
-1. Upon receiving a registration message from the system ability (SA) framework, the samgr service saves the system ability information in the local cache.
+1. Upon receiving a registration message from the system ability framework, the Samgr service saves the system ability information in the local cache.
```
int32_t SystemAbilityManager::AddSystemAbility(int32_t systemAbilityId, const sptr& ability,
@@ -67,7 +72,7 @@ The **samgr** module is a core module of OpenHarmony. It provides functions, suc
}
```
-2. If the system service requested by the SA framework is a local service, the samgr service locates the proxy object of the system service based on the service ID and then returns the proxy object to the SA framework.
+2. If the system service requested by the system ability framework is a local service, the Samgr service locates the proxy object of the system service based on the service ID and returns the proxy object to the system ability framework.
```
sptr SystemAbilityManager::CheckSystemAbility(int32_t systemAbilityId)
@@ -88,51 +93,52 @@ The **samgr** module is a core module of OpenHarmony. It provides functions, suc
}
```
-3. The samgr service dynamically loads the system service process and system ability. Instead of starting upon system startup, the process starts when the system ability is accessed and loads the specified system ability.
-
-
- 3.1 Inherit from the **SystemAbilityLoadCallbackStub** class and overwrite the **OnLoadSystemAbilitySuccess(int32_t systemAbilityId, const sptr& remoteObject)** and **OnLoadSystemAbilityFail(int32_t systemAbilityId)** methods.
-
- ```
- class OnDemandLoadCallback : public SystemAbilityLoadCallbackStub {
- public:
- void OnLoadSystemAbilitySuccess(int32_t systemAbilityId, const sptr& remoteObject) override;
- void OnLoadSystemAbilityFail(int32_t systemAbilityId) override;
- };
-
- void OnDemandLoadCallback::OnLoadSystemAbilitySuccess(int32_t systemAbilityId,
- const sptr& remoteObject) // systemAbilityId is the ID of the system ability to be loaded, and remoteObject indicates the proxy object of the system ability.
- {
- cout << "OnLoadSystemAbilitySuccess systemAbilityId:" << systemAbilityId << " IRemoteObject result:" <<
- ((remoteObject != nullptr) ? "succeed" : "failed") << endl;
- }
-
- void OnDemandLoadCallback::OnLoadSystemAbilityFail(int32_t systemAbilityId) // systemAbilityId is the ID of the system ability to be loaded.
- {
- cout << "OnLoadSystemAbilityFail systemAbilityId:" << systemAbilityId << endl;
- }
- ```
-
- 3.2 Call **LoadSystemAbility(int32_t systemAbilityId, const sptr& callback)** provided by samgr.
- ```
- // Construct a SystemAbilityLoadCallbackStub instance (mentioned in step 3.1).
- sptr loadCallback_ = new OnDemandLoadCallback();
- // Call the LoadSystemAbility method.
- sptr sm = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
- if (sm == nullptr) {
- cout << "GetSystemAbilityManager samgr object null!" << endl;
- return;
- }
- int32_t result = sm->LoadSystemAbility(systemAbilityId, loadCallback_);
- if (result != ERR_OK) {
- cout << "systemAbilityId:" << systemAbilityId << " load failed, result code:" << result << endl;
- return;
- }
- ```
->**NOTE**:
+3. The Samgr service dynamically loads the system service process and system ability. Instead of starting upon system startup, the process starts when the system ability is accessed and loads the specified system ability.
+
+ 3.1 Inherit from the **SystemAbilityLoadCallbackStub** class and override the **OnLoadSystemAbilitySuccess(int32_t systemAbilityId, const sptr& remoteObject)** and **OnLoadSystemAbilityFail(int32_t systemAbilityId)** methods.
+
+ ```
+ class OnDemandLoadCallback : public SystemAbilityLoadCallbackStub {
+ public:
+ void OnLoadSystemAbilitySuccess(int32_t systemAbilityId, const sptr& remoteObject) override;
+ void OnLoadSystemAbilityFail(int32_t systemAbilityId) override;
+ };
+
+ void OnDemandLoadCallback::OnLoadSystemAbilitySuccess(int32_t systemAbilityId,
+ const sptr& remoteObject) // systemAbilityId is the ID of the system ability to be loaded, and remoteObject indicates the proxy object of the system ability.
+ {
+ cout << "OnLoadSystemAbilitySuccess systemAbilityId:" << systemAbilityId << " IRemoteObject result:" <<
+ ((remoteObject != nullptr) ? "succeed" : "failed") << endl;
+ }
+
+ void OnDemandLoadCallback::OnLoadSystemAbilityFail(int32_t systemAbilityId) // systemAbilityId is the ID of the system ability to be loaded.
+ {
+ cout << "OnLoadSystemAbilityFail systemAbilityId:" << systemAbilityId << endl;
+ }
+ ```
+
+ 3.2 Call **LoadSystemAbility(int32_t systemAbilityId, const sptr& callback)** provided by Samgr.
+
+ ```
+ // Construct a SystemAbilityLoadCallbackStub instance (mentioned in step 3.1).
+ sptr loadCallback_ = new OnDemandLoadCallback();
+ // Call the LoadSystemAbility method.
+ sptr sm = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
+ if (sm == nullptr) {
+ cout << "GetSystemAbilityManager samgr object null!" << endl;
+ return;
+ }
+ int32_t result = sm->LoadSystemAbility(systemAbilityId, loadCallback_);
+ if (result != ERR_OK) {
+ cout << "systemAbilityId:" << systemAbilityId << " load failed, result code:" << result << endl;
+ return;
+ }
+ ```
+>NOTE
+>
+>1. After **LoadSystemAbility** is called, the **OnLoadSystemAbilitySuccess** callback will be invoked if the specified system ability is successfully loaded and the **OnLoadSystemAbilityFail** callback will be invoked if the system ability fails to be loaded.
>
->- After the **LoadSystemAbility** method is called, the **OnLoadSystemAbilitySuccess** callback will be invoked if the specified system ability is successfully loaded and the **OnLoadSystemAbilityFail** callback will be invoked if the system ability fails to be loaded.
->- The dynamically loaded process cannot start upon system startup. You must set **"ondemand": true** in the .cfg file. The following is an example:
+>2. The dynamically loaded process cannot start upon system startup. You must set **"ondemand": true** in the .cfg file. The following is an example:
>
>```
>{
@@ -146,12 +152,12 @@ The **samgr** module is a core module of OpenHarmony. It provides functions, suc
>]
>}
>```
->- The **LoadSystemAbility** method applies to dynamic loading of system abilities. In other scenarios, use the **CheckSystemAbility** method to obtain a system ability.
->- The process name in the .cfg file must be the same as that in the .xml configuration file of the system ability.
+>3. The **LoadSystemAbility** method applies to dynamic loading of system abilities. In other scenarios, use the **CheckSystemAbility** method to obtain a system ability.
+>4. The process name in the .cfg file must be the same as that in the .xml configuration file of the system ability.
-## Repositories Involved
+## Repositories Involved
-**System Ability Management Subsystem**
+Samgr
[systemabilitymgr\_safwk](https://gitee.com/openharmony/systemabilitymgr_safwk)
diff --git a/README_zh.md b/README_zh.md
old mode 100755
new mode 100644
index f00ba01c13cb9bab8a486b5de02df823acc02e57..0a16f17ce9639b0883afaf465a76728d897f4565
--- a/README_zh.md
+++ b/README_zh.md
@@ -1,8 +1,13 @@
-# samgr组件
+# 系统服务管理部件
## 简介
samgr组件是OpenHarmony的核心组件,提供OpenHarmony系统服务启动、注册、查询等功能。
+## 系统架构
+
+**图 1** 系统服务管理系统架构图
+
+

## 目录
diff --git a/etc/samgr.para b/etc/samgr.para
old mode 100755
new mode 100644
diff --git a/etc/samgr.para.dac b/etc/samgr.para.dac
index ff314d8b10a2da34bb333b5cc454bbaa82723a00..403ba811414dc63d1127147f977906d6a448f88e 100644
--- a/etc/samgr.para.dac
+++ b/etc/samgr.para.dac
@@ -11,6 +11,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-bootevent.samgr.ready = samgr:samgr:0775
+bootevent.samgr.ready = samgr:samgr:0775:bool
-persist.samgr.perf.ondemand = samgr:samgr:0775
+persist.samgr.perf.ondemand = samgr:samgr:0775:bool
diff --git a/figures/en-us_image_0000001115820566.png b/figures/en-us_image_0000001115820566.png
old mode 100755
new mode 100644
index 5565883f26bdc780a78ab7b1b6f6fb799525f704..826d579fdce32aa57080e14141153f7dda7035f7
Binary files a/figures/en-us_image_0000001115820566.png and b/figures/en-us_image_0000001115820566.png differ
diff --git a/figures/zh-cn_image_0000001115820566.png b/figures/zh-cn_image_0000001115820566.png
old mode 100755
new mode 100644
index c40b07116c06dd275da47df579d8664c6bd52abc..eb084e6dc92931583b1cee2b6b504dad9e9e5d9b
Binary files a/figures/zh-cn_image_0000001115820566.png and b/figures/zh-cn_image_0000001115820566.png differ
diff --git a/hisysevent.yaml b/hisysevent.yaml
index 0c1ac8baace56917881ed994270337847275bb68..aadc950b5c066aa98dc6712b55c0cb1c8a806734 100644
--- a/hisysevent.yaml
+++ b/hisysevent.yaml
@@ -22,4 +22,10 @@ SAMGR_GETSA_FREQUENCY:
SAMGR_ADD_SYSTEMABILITY_FAIL:
__BASE: {type: FAULT, level: CRITICAL, tag: fault, desc: add system ability failed event}
SAID: {type: INT32, desc: system ability id}
- FILE_NAME: {type: STRING, desc: file name}
\ No newline at end of file
+ FILE_NAME: {type: STRING, desc: file name}
+
+SAMGR_SERVICE_BLOCK:
+ __BASE: {type: FAULT, level: CRITICAL, tag: fault, desc: workhander watchdog block}
+ PID: {type: INT32, desc: caller pid}
+ UID: {type: UINT32, desc: caller uid}
+ MSG: {type: STRING, desc: time msg}
\ No newline at end of file
diff --git a/interfaces/innerkits/rust/BUILD.gn b/interfaces/innerkits/rust/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..436df017853e46d4e8dbb63b768879232db6dc6f
--- /dev/null
+++ b/interfaces/innerkits/rust/BUILD.gn
@@ -0,0 +1,132 @@
+# Copyright (C) 2022 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")
+
+SUBSYSTEM_DIR = "//foundation/systemabilitymgr/samgr"
+IPC_CORE_ROOT = "$SUBSYSTEM_DIR/services/samgr/native"
+
+ohos_rust_shared_library("samgr_rust") {
+ sources = [
+ "src/main.rs",
+ ]
+
+ deps = [":samgr_c"]
+
+ crate_name = "samgr_rust"
+ crate_type = "dylib"
+
+ install_images = [ system_base_dir ]
+ relative_install_dir = "chipset-pub-sdk"
+ subsystem_name = "systemabilitymgr"
+ part_name = "samgr"
+}
+
+ohos_rust_shared_library("rust_dlopen") {
+ sources = [
+ "src/dlopen.rs",
+ ]
+
+ crate_name = "rust_dlopen"
+ crate_type = "dylib"
+
+ install_images = [ system_base_dir ]
+ relative_install_dir = "chipset-pub-sdk"
+ subsystem_name = "systemabilitymgr"
+ part_name = "samgr"
+}
+
+ohos_rust_shared_ffi("ctorust") {
+ sources = [ "src/ctorust.rs" ]
+ crate_name = "ctorust"
+ crate_type = "cdylib"
+}
+
+ohos_rust_executable("test_samgr_rust") {
+ sources = [ "tests/test.rs" ]
+ deps = [ ":samgr_rust" ]
+}
+
+ohos_executable("test_dlopen") {
+ sources = [ "$IPC_CORE_ROOT/source/dlopen.cpp" ]
+}
+
+config("libsamgr_c_private_config") {
+ cflags_cc = [ "-O2" ]
+}
+
+ohos_shared_library("samgr_c") {
+ include_dirs = [
+ "$IPC_CORE_ROOT/include",
+ ]
+ sources = [
+ "$IPC_CORE_ROOT/source/c_func.cpp",
+ ]
+
+ configs = [
+ ":libsamgr_c_private_config",
+ ]
+
+ install_images = [ system_base_dir ]
+ relative_install_dir = "chipset-pub-sdk"
+ subsystem_name = "systemabilitymgr"
+ part_name = "samgr"
+}
+
+ohos_shared_library("dlopen_test_cpp") {
+ sources = [
+ "$IPC_CORE_ROOT/source/dlopen_test.cpp",
+ ]
+
+ install_images = [ system_base_dir ]
+ relative_install_dir = "chipset-pub-sdk"
+ subsystem_name = "systemabilitymgr"
+ part_name = "samgr"
+}
+
+ohos_shared_library("c_samgr") {
+ sources = [
+ "$IPC_CORE_ROOT/c_wrapper/source/C_Samgr.cpp",
+ ]
+ include_dirs = [
+ "$IPC_CORE_ROOT/include",
+ "$IPC_CORE_ROOT/c_wrapper/include",
+ "$SUBSYSTEM_DIR/interfaces/innerkits/samgr_proxy/include",
+ "//foundation/communication/ipc/ipc/native/src/c_wrapper/include",
+ ]
+
+ if (is_standard_system) {
+ external_deps = [
+ "c_utils:utils",
+ "ipc:ipc_single",
+ ]
+
+ part_name = "samgr"
+ }
+ deps = [ "//foundation/systemabilitymgr/samgr/interfaces/innerkits/samgr_proxy:samgr_proxy",
+ "//foundation/communication/ipc/interfaces/innerkits/rust:ipc_c", ]
+ install_images = [ system_base_dir ]
+ relative_install_dir = "chipset-pub-sdk"
+ subsystem_name = "systemabilitymgr"
+}
+
+ohos_executable("test_ctorust") {
+ sources = [
+ "$IPC_CORE_ROOT/source/ctorust.cpp",
+ ]
+ include_dirs = [
+ "$IPC_CORE_ROOT/include",
+ ]
+ deps = [ ":ctorust" ]
+}
+
diff --git a/interfaces/innerkits/rust/src/ctorust.rs b/interfaces/innerkits/rust/src/ctorust.rs
new file mode 100644
index 0000000000000000000000000000000000000000..fbaf87f398c76ab76b194bb62a0d93201b73bfc2
--- /dev/null
+++ b/interfaces/innerkits/rust/src/ctorust.rs
@@ -0,0 +1,4 @@
+#[no_mangle]
+pub extern fn print_hello_world() {
+ println!("c++to_rust");
+}
\ No newline at end of file
diff --git a/interfaces/innerkits/rust/src/dlopen.rs b/interfaces/innerkits/rust/src/dlopen.rs
new file mode 100644
index 0000000000000000000000000000000000000000..49f6e67710a25ed9f8a9f14de5146a54c70ad34d
--- /dev/null
+++ b/interfaces/innerkits/rust/src/dlopen.rs
@@ -0,0 +1,11 @@
+// fn print_hello_world() {
+// println!("rust dlopen!!!!!!!!");
+// }
+const fn return_one() -> i32 {
+ let temp = 1;
+ return temp;
+}
+const TEMP:i32 = return_one();
+pub extern "C" fn get() -> i32 {
+ return TEMP;
+}
\ No newline at end of file
diff --git a/interfaces/innerkits/rust/src/main.rs b/interfaces/innerkits/rust/src/main.rs
new file mode 100644
index 0000000000000000000000000000000000000000..1bd6ed7a6aacba93851e5e5e264a32e1df63a70b
--- /dev/null
+++ b/interfaces/innerkits/rust/src/main.rs
@@ -0,0 +1,7 @@
+use std::os::raw::c_int;
+
+//#[link(name = "c_func")]
+extern "C"{
+ pub fn Cfunc() -> ();
+}
+
diff --git a/interfaces/innerkits/rust/src/rust_samgr.rs b/interfaces/innerkits/rust/src/rust_samgr.rs
new file mode 100644
index 0000000000000000000000000000000000000000..4258ac602ee3750843cd734d331ff2342df370be
--- /dev/null
+++ b/interfaces/innerkits/rust/src/rust_samgr.rs
@@ -0,0 +1,71 @@
+use crate::{samgr_rust, MsgParcel, RemoteObj, InterFaceToken, String16};
+DUMP_FLAG_PRIORITY_DEFAULT = 1 << SHEEFT_DEFAULT;
+struct SAExtraProp {
+ isDistributed: bool = false,
+ dumpFlags: u32 = DUMP_FLAG_PRIORITY_DEFAULT,
+ capability: String16 = String16::new(""),
+ permission: String16 = String16::new("")
+}
+
+fn get_service() -> Option
+{
+ unsafe {
+ let samgr = samgr_rust::GetContextManager();
+ RemoteObj::from_raw(samgr)
+ }
+}
+
+pub fn add_service(service: &RemoteObj, said: i32, extraProp: SAExtraProp)
+{
+ let samgr = get_service().expect("samgr is not null");
+ let mut data = MsgParcel::new().expect("MsgParcel is not null");
+ match data.write(&InterFaceToken::new("ohos.samgr.accessToken")) {
+ Ok(()) => { println!("write token success") }
+ Err(val) => { println!("write token fail: {}", val) }
+ }
+ match data.write(&said) {
+ Ok(()) => { println!("write said success") }
+ Err(val) => { println!("write said fail: {}", val) }
+ }
+ match data.write(service) {
+ Ok(()) => { println!("write service success") }
+ Err(val) => { println!("write service fail: {}", val) }
+ }
+ match data.write(extraProp.isDistributed) {
+ Ok(()) => { println!("write bool success") }
+ Err(val) => { println!("write bool fail: {}", val) }
+ }
+ match data.write(extraProp.dumpFlags) {
+ Ok(()) => { println!("write 0 success") }
+ Err(val) => { println!("write 0 fail: {}", val) }
+ }
+ match data.write(extraProp.capability) {
+ Ok(()) => { println!("write string16 111 success") }
+ Err(val) => { println!("write string16 111 fail: {}", val) }
+ }
+ match data.write(extraProp.permission) {
+ Ok(()) => { println!("write string16 222 success") }
+ Err(val) => { println!("write string16 222 fail: {}", val) }
+ }
+ let reply = samgr.send_request(3, &data, false).expect("failed to register service");
+ let replyValue: i32 = reply.read().expect("register service reply should 0");
+ println!("register service result: {}", replyValue);
+}
+
+pub fn get_service(said: i32) -> RemoteObj
+{
+ let samgr = get_samgr().expect("samgr is not null");
+ let mut data = MsgParcel::new().expect("MsgParcel is not null");
+ match data.write(&InterFaceToken::new("ohos.samgr.accessToken")) {
+ Ok(()) => { println!("write token success") }
+ Err(val) => { println!("write token fail: {}", val) }
+ }
+ match data.write(&said) {
+ Ok(()) => { println!("write said success") }
+ Err(val) => { println!("write said fail: {}", val) }
+ }
+ let reply = samgr.send_request(2, &data, false).expect("Failed to get service");
+ let remote: RemoteObj = reply.read().expect("Failed to read remote object");
+ println!("register service result");
+ return remote;
+}
\ No newline at end of file
diff --git a/interfaces/innerkits/rust/src/samgr.rs b/interfaces/innerkits/rust/src/samgr.rs
new file mode 100644
index 0000000000000000000000000000000000000000..ce288515112c8fc05dd23dcefef1c2e1e9433ae7
--- /dev/null
+++ b/interfaces/innerkits/rust/src/samgr.rs
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2022 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.
+ */
+
+#[link(name = "c_samgr")]
+extern "C" {
+ pub fn GetContextManager() -> *mut CRemoteObject;
+}
\ No newline at end of file
diff --git a/interfaces/innerkits/rust/tests/test.rs b/interfaces/innerkits/rust/tests/test.rs
new file mode 100644
index 0000000000000000000000000000000000000000..ed4c59c7ce63fa6fa3b9d50b55910930ae3ee7bb
--- /dev/null
+++ b/interfaces/innerkits/rust/tests/test.rs
@@ -0,0 +1,8 @@
+use samgr_rust::Cfunc;
+
+fn main() {
+ unsafe{ //unsafe 作用域,将引入的C函数,代码约束,保证安全性
+ Cfunc();
+ }
+ print!("unsafe_ask");
+}
\ No newline at end of file
diff --git a/interfaces/innerkits/samgr_proxy/include/if_system_ability_manager.h b/interfaces/innerkits/samgr_proxy/include/if_system_ability_manager.h
index da723600554c982259f096489b8191a696aa1b5e..1022cb94ae0fbede7bd392e0255acd5a5bd34234 100644
--- a/interfaces/innerkits/samgr_proxy/include/if_system_ability_manager.h
+++ b/interfaces/innerkits/samgr_proxy/include/if_system_ability_manager.h
@@ -66,7 +66,7 @@ public:
ADD_SYSTEM_PROCESS_TRANSACTION = 20
};
- // Retrieve an existing ability, blocking for a few seconds if it doesn't ye exist.
+ // Retrieve an existing ability, retrying and blocking for a few seconds if it doesn't exist.
virtual sptr GetSystemAbility(int32_t systemAbilityId) = 0;
// Retrieve an existing ability, no-blocking.
@@ -75,12 +75,15 @@ public:
// Remove an ability.
virtual int32_t RemoveSystemAbility(int32_t systemAbilityId) = 0;
+ // Subscribe a system ability status, and inherit from ISystemAbilityStatusChange class.
virtual int32_t SubscribeSystemAbility(int32_t systemAbilityId,
const sptr& listener) = 0;
+
+ // UnSubscribe a system ability status.
virtual int32_t UnSubscribeSystemAbility(int32_t systemAbilityId,
const sptr& listener) = 0;
- // Retrieve an existing ability, blocking for a few seconds if it doesn't ye exist.
+ // Retrieve an existing ability, blocking for a few seconds if it doesn't exist.
virtual sptr GetSystemAbility(int32_t systemAbilityId, const std::string& deviceId) = 0;
// Retrieve an existing ability, no-blocking
diff --git a/interfaces/innerkits/samgr_proxy/include/iservice_registry.h b/interfaces/innerkits/samgr_proxy/include/iservice_registry.h
index a5c3f1ddea4daf5b48ca2d48216d6197d3af3ef4..caf8c3db4d8356f46c0f4170340f31d2cf8e3599 100644
--- a/interfaces/innerkits/samgr_proxy/include/iservice_registry.h
+++ b/interfaces/innerkits/samgr_proxy/include/iservice_registry.h
@@ -71,11 +71,6 @@ public:
*/
sptr GetSystemAbilityManager();
- /**
- * get remote object of samgr.
- */
- sptr GetRegistryRemoteObject();
-
/**
* destroy remote object of samgr.
*/
diff --git a/interfaces/innerkits/samgr_proxy/include/system_ability_definition.h b/interfaces/innerkits/samgr_proxy/include/system_ability_definition.h
index 0a7691b3f7f4a91858d4fba844b687889768e6d3..417eb74eb617dd5f7aab79f9749aab98a14f518d 100644
--- a/interfaces/innerkits/samgr_proxy/include/system_ability_definition.h
+++ b/interfaces/innerkits/samgr_proxy/include/system_ability_definition.h
@@ -94,6 +94,7 @@ enum {
DFX_FAULT_LOGGER_ABILITY_ID = 1202,
DFX_SYS_EVENT_SERVICE_ABILITY_ID = 1203,
DFX_HI_DUMPER_SERVICE_ABILITY_ID = 1212,
+ XPOWER_MANAGER_SYSTEM_ABILITY_ID = 1213,
SUBSYS_DISTRIBUTEDDATAMNG_SYS_ABILITY_ID_BEGIN = 1300,
DISTRIBUTED_KV_DATA_SERVICE_ABILITY_ID = 1301,
DISTRIBUTED_FS_DAEMON_SERVICE_ID = 1302,
@@ -129,6 +130,8 @@ enum {
MEMORY_MANAGER_SA_ID = 1909,
SUSPEND_MANAGER_SYSTEM_ABILITY_ID = 1910,
ABNORMAL_EFFICIENCY_MGR_SYSTEM_ABILITY_ID = 1911,
+ CONCURRENT_TASK_SERVICE_ID = 1912,
+ RESOURCE_QUOTA_CONTROL_SYSTEM_ABILITY_ID = 1913,
SUBSYS_IDE_SYS_ABILITY_ID_BEGIN = 2000,
SUBSYS_INTELLIACCESSORIES_SYS_ABILITY_ID_BEGIN = 2100,
SUBSYS_INTELLISPEAKER_SYS_ABILITY_ID_BEGIN = 2200,
@@ -186,9 +189,12 @@ enum {
TOKEN_SYNC_MANAGER_SERVICE_ID = 3504,
PRIVACY_MANAGER_SERVICE_ID = 3505,
DEVICE_SECURITY_LEVEL_MANAGER_SA_ID = 3511,
+ CERT_MANAGER_SERVICE_SA_ID = 3512,
+ DEVICE_THREAT_DETECTION_SERVICE_SA_ID = 3513,
DLP_PERMISSION_SERVICE_ID = 3521,
RISK_ANALYSIS_MANAGER_SA_ID = 3523,
DATA_COLLECT_MANAGER_SA_ID = 3524,
+ DLP_CREDENTIAL_SERVICE_ID = 3553,
SUBSYS_SENSORS_SYS_ABILITY_ID_BEGIN = 3600,
SENSOR_SERVICE_ABILITY_ID = 3601,
MISCDEVICE_SERVICE_ABILITY_ID = 3602,
@@ -219,6 +225,7 @@ enum {
TELEPHONY_IMS_SYS_ABILITY_ID = 4014,
SUBSYS_UPDATE_SYS_ABILITY_ID_BEGIN = 4100,
SYS_INSTALLER_DISTRIBUTED_SERVICE_ID = 4101,
+ QUICKFIX_ENGINE_SERVICE_ID = 4102,
SUBSYS_USB_SYS_ABILITY_ID_BEGIN = 4200,
USB_SYSTEM_ABILITY_ID = 4201,
SUBSYS_WEARABLE_SYS_ABILITY_ID_BEGIN = 4300,
@@ -258,6 +265,8 @@ enum {
FILEMANAGEMENT_DISTRIBUTED_FILE_DAEMON_SA_ID = 5201,
FILEMANAGEMENT_DISTRIBUTED_FILE_SERVICE_SA_ID = 5202,
FILEMANAGEMENT_BACKUP_SERVICE_SA_ID = 5203,
+ SUBSYS_TESTPLATFORM_SYS_ABILITY_ID_BEGIN = 5500,
+ DEVICE_ATTEST_PROFILE_SA_ID = 5501,
DISTRIBUTED_DEVICE_PROFILE_SA_ID = 6001,
SUBSYS_ACE_SYS_ABILITY_ID_BEGIN = 7001,
ARKUI_UI_APPEARANCE_SERVICE_ID = 7002,
@@ -278,6 +287,7 @@ static const std::map saNameMap_ = {
{ URI_PERMISSION_MGR_SERVICE_ID, "UriPermissionMgr" },
{ QUICK_FIX_MGR_SERVICE_ID, "QuickFixMgrService"},
{ BUNDLE_MGR_SERVICE_SYS_ABILITY_ID, "BundleMgr" },
+ { INSTALLD_SERVICE_ID, "Installd" },
{ FORM_MGR_SERVICE_ID, "FormMgr" },
{ WIFI_DEVICE_SYS_ABILITY_ID, "WifiDevice" },
{ WIFI_HOTSPOT_SYS_ABILITY_ID, "WifiHotspot" },
@@ -295,6 +305,8 @@ static const std::map saNameMap_ = {
{ RESSCHEDD_SA_ID, "ResourceSchedDamon" },
{ BACKGROUND_TASK_MANAGER_SERVICE_ID, "BackgroundTaskManager" },
{ WORK_SCHEDULE_SERVICE_ID, "WorkSchedule" },
+ { CONCURRENT_TASK_SERVICE_ID, "ConcurrentTaskService" },
+ { RESOURCE_QUOTA_CONTROL_SYSTEM_ABILITY_ID, "ResourceQuotaControl"},
{ COMPONENT_SCHEDULE_SERVICE_ID, "ComponentSchedServer" },
{ SOC_PERF_SERVICE_SA_ID, "SocPerfService" },
{ SUSPEND_MANAGER_SYSTEM_ABILITY_ID, "SuspendManager" },
@@ -309,11 +321,15 @@ static const std::map saNameMap_ = {
{ ADVANCED_NOTIFICATION_SERVICE_ABILITY_ID, "DistributedNotificationService" },
{ COMMON_EVENT_SERVICE_ID, "CommonEventService" },
{ POWER_MANAGER_SERVICE_ID, "PowerManagerService" },
- { POWER_MANAGER_BATT_SERVICE_ID, "PowerManagerBatt" },
- { POWER_MANAGER_BATT_STATS_SERVICE_ID, "BatteryStatsService" },
+ { POWER_MANAGER_BATT_SERVICE_ID, "BatteryService" },
+ { POWER_MANAGER_BATT_STATS_SERVICE_ID, "BatteryStatisticsService" },
+ { POWER_MANAGER_THERMAL_SERVICE_ID, "ThermalService" },
+ { DISPLAY_MANAGER_SERVICE_ID, "DisplayPowerManagerService" },
{ 3502, "DpmsService" },
{ 3510, "KeystoreService" },
{ DEVICE_SECURITY_LEVEL_MANAGER_SA_ID, "DslmService" },
+ { CERT_MANAGER_SERVICE_SA_ID, "CertManagerService"},
+ { DEVICE_THREAT_DETECTION_SERVICE_SA_ID, "DeviceThreatDetectionService" },
{ SENSOR_SERVICE_ABILITY_ID, "SensorService" },
{ MISCDEVICE_SERVICE_ABILITY_ID, "MiscDeviceService" },
{ PASTEBOARD_SERVICE_ID, "PasteboardService" },
@@ -351,6 +367,7 @@ static const std::map saNameMap_ = {
{ WINDOW_MANAGER_SERVICE_ID, "WindowManagerService" },
{ DISPLAY_MANAGER_SERVICE_SA_ID, "DisplayManagerService" },
{ SOFTBUS_SERVER_SA_ID, "DSoftbus" },
+ { DEVICE_AUTH_SERVICE_ID, "DeviceAuthService" },
{ WINDOW_MANAGER_ID, "WindowManager" },
{ VSYNC_MANAGER_ID, "VsyncManager" },
{ VSYNC_MANAGER_TEST_ID, "VsyncManagerTest" },
@@ -380,6 +397,7 @@ static const std::map saNameMap_ = {
{ DFX_FAULT_LOGGER_ABILITY_ID, "HiviewFaultLogger" },
{ DFX_SYS_EVENT_SERVICE_ABILITY_ID, "HiviewSysEventService" },
{ DFX_HI_DUMPER_SERVICE_ABILITY_ID, "HiDumperService" },
+ { XPOWER_MANAGER_SYSTEM_ABILITY_ID, "XpowerManager"},
{ SUBSYS_USERIAM_SYS_ABILITY_USERAUTH, "UserAuthService" },
{ SUBSYS_USERIAM_SYS_ABILITY_PINAUTH, "PinAuthService" },
{ SUBSYS_USERIAM_SYS_ABILITY_FACEAUTH, "FaceAuthService" },
@@ -397,6 +415,12 @@ static const std::map saNameMap_ = {
{ PARAM_WATCHER_DISTRIBUTED_SERVICE_ID, "ParamWatcher" },
{ SYSPARAM_DEVICE_SERVICE_ID, "SysParamDevice" },
{ TIME_SERVICE_ID, "TimeService" },
+ { PLAYER_DISTRIBUTED_SERVICE_ID, "PlayerDistributedService"},
+ { CAMERA_SERVICE_ID, "CameraService"},
+ { AUDIO_POLICY_SERVICE_ID, "AudioPolicyService"},
+ { DLP_CREDENTIAL_SERVICE_ID, "DlpCreService"},
+ { QUICKFIX_ENGINE_SERVICE_ID, "QuickfixEngineService"},
+ { DEVICE_ATTEST_PROFILE_SA_ID, "devattest_service" },
};
} // namespace OHOS
diff --git a/services/common/test/unittest/BUILD.gn b/services/common/test/unittest/BUILD.gn
index 3de283d834ee8593ff4052fc6c5f057bf346c59d..499a3e8a1ac6a9b7255fd876cc6f24ba19fd3e29 100644
--- a/services/common/test/unittest/BUILD.gn
+++ b/services/common/test/unittest/BUILD.gn
@@ -25,7 +25,10 @@ ohos_unittest("ParseUtilTest") {
"//foundation/systemabilitymgr/samgr/utils/native/include",
]
- sources = [ "./parse_util_test.cpp" ]
+ sources = [
+ "./parse_util_test.cpp",
+ "//foundation/systemabilitymgr/samgr/utils/native/source/tools.cpp",
+ ]
configs =
[ "//foundation/systemabilitymgr/samgr/test/resource:coverage_flags" ]
diff --git a/services/common/test/unittest/parse_util_test.cpp b/services/common/test/unittest/parse_util_test.cpp
index b3f2f9e694396d1ff9e46ea9269f549c9d1f7c28..027dc94928d28e213f26789fc4aa2f13690e0db7 100644
--- a/services/common/test/unittest/parse_util_test.cpp
+++ b/services/common/test/unittest/parse_util_test.cpp
@@ -15,6 +15,7 @@
#include "gtest/gtest.h"
#include "string_ex.h"
#include "test_log.h"
+#include "tools.h"
#define private public
#include "parse_util.h"
@@ -191,6 +192,11 @@ HWTEST_F(ParseUtilTest, GetSaProfiles002, TestSize.Level3)
*/
bool ret = parser_->ParseSaProfiles(TEST_RESOURCE_PATH + "profile.xml");
ASSERT_TRUE(ret);
+ SaProfile saRunOnCreateTrue;
+ saRunOnCreateTrue.runOnCreate = true;
+ SaProfile saRunOnCreateFalse;
+ parser_->saProfiles_.emplace_back(saRunOnCreateTrue);
+ parser_->saProfiles_.emplace_back(saRunOnCreateFalse);
parser_->OpenSo();
list profiles = parser_->GetAllSaProfiles();
if (!profiles.empty()) {
@@ -557,6 +563,7 @@ HWTEST_F(ParseUtilTest, LoadSaLib002, TestSize.Level2)
bool ret = parser_->ParseSaProfiles(TEST_RESOURCE_PATH + "multi_sa_profile.xml");
EXPECT_EQ(ret, true);
ret = parser_->LoadSaLib(TEST_PROFILE_SAID_INVAILD);
+ parser_->CloseSo(MOCK_SAID);
EXPECT_NE(ret, true);
}
@@ -600,6 +607,24 @@ HWTEST_F(ParseUtilTest, LoadSaLib004, TestSize.Level2)
parser_->LoadSaLib(MOCK_SAID);
}
+/**
+ * @tc.name: LoadSaLib005
+ * @tc.desc: Verify if can load salib
+ * @tc.type: FUNC
+ * @tc.require: I5KMF7
+ */
+HWTEST_F(ParseUtilTest, LoadSaLib005, TestSize.Level2)
+{
+ DTEST_LOG << " LoadSaLib005 start " << std::endl;
+ /**
+ * @tc.steps: step1. check exsit salib
+ * @tc.expected: step1. return false when load not exist salib
+ */
+ bool ret = parser_->ParseSaProfiles(TEST_RESOURCE_PATH + "empty_libpath.xml");
+ EXPECT_EQ(ret, true);
+ ret = parser_->LoadSaLib(MOCK_SAID);
+ EXPECT_EQ(ret, true);
+}
/**
* @tc.name: GetProcessName001
* @tc.desc: Verify if can get procesname
@@ -870,5 +895,20 @@ HWTEST_F(ParseUtilTest, ParseSaid002, TestSize.Level1)
bool res = parser_->ParseSaId(rootNodeptr, tempSaId);
EXPECT_EQ(res, false);
}
+
+/**
+ * @tc.name: DeleteAllMark001
+ * @tc.desc: Verify if can DeleteAllMark
+ * @tc.type: FUNC
+ * @tc.require: I5KMF7
+ */
+HWTEST_F(ParseUtilTest, DeleteAllMark001, TestSize.Level3)
+{
+ DTEST_LOG << " DeleteAllMark001 " << std::endl;
+ u16string temp = u"stests";
+ u16string mask = u"s";
+ u16string res = DeleteAllMark(temp, mask);
+ EXPECT_EQ(res, u"tet");
+}
} // namespace SAMGR
} // namespace OHOS
diff --git a/services/dfx/include/hicollie_helper.h b/services/dfx/include/hicollie_helper.h
new file mode 100644
index 0000000000000000000000000000000000000000..476353520f83c13f4c771517a03b4f53fbc98348
--- /dev/null
+++ b/services/dfx/include/hicollie_helper.h
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2022 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 SERVICES_DFX_INCLUDE_HICOLLIE_HELLER_H_
+#define SERVICES_DFX_INCLUDE_HICOLLIE_HELLER_H_
+#include "event_handler.h"
+#include
+namespace OHOS {
+class HicollieHelper {
+public:
+ static int AddThread(const std::string& name, std::shared_ptr handler,
+ std::function timeOutCallback, uint64_t interval);
+};
+} // namespace OHOS
+#endif // SERVICES_DFX_INCLUDE_HICOLLIE_HELLER_H_
diff --git a/services/dfx/include/hisysevent_adapter.h b/services/dfx/include/hisysevent_adapter.h
index e5f2229753db7d0734e2b781eca65c91852e91ff..50d15245bf2d8f0197e07f0b878e99b487ec0f88 100644
--- a/services/dfx/include/hisysevent_adapter.h
+++ b/services/dfx/include/hisysevent_adapter.h
@@ -21,5 +21,8 @@ namespace OHOS {
void ReportAddSystemAbilityFailed(int32_t said, const std::string& filaName);
void ReportGetSAFrequency(uint32_t callerPid, uint32_t said, int32_t count);
+
+void WatchDogSendEvent(int32_t pid, uint32_t uid, const std::string& sendMsg,
+ const std::string& eventName);
} // OHOS
#endif // SAMGR_SERVICES_DFX_INCLUDE__HISYSEVENT_ADAPTER_H
diff --git a/services/dfx/source/hicollie_helper.cpp b/services/dfx/source/hicollie_helper.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..23c5305fdb7c43971a371979a950d2a25c72a181
--- /dev/null
+++ b/services/dfx/source/hicollie_helper.cpp
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2022 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 "hicollie_helper.h"
+#ifdef HICOLLIE_ENABLE
+#include "xcollie/watchdog.h"
+#endif
+
+namespace OHOS {
+int HicollieHelper::AddThread(const std::string& name, std::shared_ptr handler,
+ std::function timeOutCallback, uint64_t interval)
+{
+#ifdef HICOLLIE_ENABLE
+ return HiviewDFX::Watchdog::GetInstance().AddThread(name, handler, timeOutCallback, interval);
+#else
+ // HICOLLIE_ENABLE is false, do nothing and return 1.
+ return 1;
+#endif
+}
+} // namespace OHOS
\ No newline at end of file
diff --git a/services/dfx/source/hisysevent_adapter.cpp b/services/dfx/source/hisysevent_adapter.cpp
index 608011e2f5437184ebf61a94de125a4384c3bb88..e09c9b28319753a63f7391521f08a586132388d2 100644
--- a/services/dfx/source/hisysevent_adapter.cpp
+++ b/services/dfx/source/hisysevent_adapter.cpp
@@ -23,7 +23,6 @@
namespace OHOS {
using namespace OHOS::HiviewDFX;
namespace {
-const std::string DOMAIN_NAME = std::string(HiSysEvent::Domain::SAMGR);
const std::string ADD_SYSTEMABILITY_FAIL = "SAMGR_ADD_SYSTEMABILITY_FAIL";
const std::string CALLER_PID = "CALLER_PID";
const std::string SAID = "SAID";
@@ -34,7 +33,7 @@ const std::string GETSA__TAG = "SAMGR_GETSA_FREQUENCY";
void ReportAddSystemAbilityFailed(int32_t said, const std::string& filaName)
{
- int ret = HiSysEvent::Write(DOMAIN_NAME,
+ int ret = HiSysEventWrite(HiSysEvent::Domain::SAMGR,
ADD_SYSTEMABILITY_FAIL,
HiSysEvent::EventType::FAULT,
SAID, said,
@@ -46,7 +45,7 @@ void ReportAddSystemAbilityFailed(int32_t said, const std::string& filaName)
void ReportGetSAFrequency(uint32_t callerPid, uint32_t said, int32_t count)
{
- int ret = HiSysEvent::Write(DOMAIN_NAME,
+ int ret = HiSysEventWrite(HiSysEvent::Domain::SAMGR,
GETSA__TAG,
HiSysEvent::EventType::STATISTIC,
CALLER_PID, callerPid,
@@ -56,4 +55,18 @@ void ReportGetSAFrequency(uint32_t callerPid, uint32_t said, int32_t count)
HILOGE("hisysevent report get sa frequency failed! ret %{public}d.", ret);
}
}
+
+void WatchDogSendEvent(int32_t pid, uint32_t uid, const std::string& sendMsg,
+ const std::string& eventName)
+{
+ int ret = HiSysEventWrite(HiSysEvent::Domain::SAMGR,
+ eventName,
+ HiSysEvent::EventType::FAULT,
+ "PID", pid,
+ "UID", uid,
+ "MSG", sendMsg);
+ if (ret != 0) {
+ HILOGE("hisysevent report watchdog failed! ret %{public}d.", ret);
+ }
+}
} // OHOS
diff --git a/services/samgr/native/BUILD.gn b/services/samgr/native/BUILD.gn
index 413ea222e787b8644185630f88c28d9deb4e2489..88b3ae2f3898b2db74d87fc375eafad218775400 100644
--- a/services/samgr/native/BUILD.gn
+++ b/services/samgr/native/BUILD.gn
@@ -13,6 +13,7 @@
import("//build/ohos.gni")
import("//build/ohos_var.gni")
+import("../var.gni")
config("distributed_store_config") {
visibility = [ ":*" ]
@@ -36,6 +37,7 @@ ohos_executable("samgr") {
install_enable = true
sources = [
"//foundation/systemabilitymgr/samgr/frameworks/native/source/system_ability_load_callback_stub.cpp",
+ "//foundation/systemabilitymgr/samgr/services/dfx/source/hicollie_helper.cpp",
"//foundation/systemabilitymgr/samgr/services/dfx/source/hisysevent_adapter.cpp",
"//foundation/systemabilitymgr/samgr/services/lsamgr/src/local_ability_manager_proxy.cpp",
"//foundation/systemabilitymgr/samgr/services/samgr/native/source/ability_death_recipient.cpp",
@@ -48,7 +50,8 @@ ohos_executable("samgr") {
"//foundation/systemabilitymgr/samgr/utils/native/source/tools.cpp",
]
- deps = [ "//foundation/systemabilitymgr/samgr/interfaces/innerkits/common:samgr_common" ]
+ deps = [ "//foundation/systemabilitymgr/samgr/interfaces/innerkits/common:samgr_common",
+ "//foundation/systemabilitymgr/samgr/interfaces/innerkits/rust:samgr_rust", ]
configs = [
":sam_config",
@@ -56,7 +59,7 @@ ohos_executable("samgr") {
"//foundation/systemabilitymgr/samgr/test/resource:coverage_flags",
":distributed_store_config",
]
-
+ defines = []
if (is_standard_system) {
external_deps = [
"access_token:libaccesstoken_sdk",
@@ -65,6 +68,7 @@ ohos_executable("samgr") {
"hisysevent_native:libhisysevent",
"hitrace_native:hitrace_meter",
"hiviewdfx_hilog_native:libhilog",
+ "init:libbeget_proxy",
"init:libbegetutil",
"ipc:ipc_core",
"ipc:libdbinder",
@@ -72,7 +76,12 @@ ohos_executable("samgr") {
if (build_selinux) {
external_deps += [ "selinux:libservice_checker" ]
- defines = [ "WITH_SELINUX" ]
+ defines += [ "WITH_SELINUX" ]
+ }
+
+ if (hicollie_able) {
+ external_deps += [ "hicollie_native:libhicollie" ]
+ defines += [ "HICOLLIE_ENABLE" ]
}
public_deps = [ "//third_party/libxml2:libxml2" ]
part_name = "samgr"
diff --git a/services/samgr/native/c_wrapper/include/C_Samgr.h b/services/samgr/native/c_wrapper/include/C_Samgr.h
new file mode 100644
index 0000000000000000000000000000000000000000..66e30d949972327c78e82886dd1073f3113e71f5
--- /dev/null
+++ b/services/samgr/native/c_wrapper/include/C_Samgr.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2021-2022 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 SAMGR_C_WRAPPER_INCLUDE_C_SYS_PROXY_H_
+#define SAMGR_C_WRAPPER_INCLUDE_C_SYS_PROXY_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "c_remote_object.h"
+
+CRemoteObject *GetContextManager();
+
+#ifdef __cplusplus
+}
+#endif
+#endif // !defined(INTERFACES_INNERKITS_SAMGR_INCLUDE_SYSTEM_ABILITY_MANAGER_PROXY_H_)
diff --git a/services/samgr/native/c_wrapper/source/C_Samgr.cpp b/services/samgr/native/c_wrapper/source/C_Samgr.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..22e4727098f47a0cba518b7cf745629efd118d28
--- /dev/null
+++ b/services/samgr/native/c_wrapper/source/C_Samgr.cpp
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2021-2022 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 "iremote_object.h"
+#include "c_remote_object_internal.h"
+#include "c_remote_object.h"
+#include "if_system_ability_manager.h"
+#include "ipc_skeleton.h"
+
+using namespace std;
+namespace OHOS {
+CRemoteObject *GetContextManager(void)
+{
+ sptr saMgr = IPCSkeleton::GetContextObject();
+ if (saMgr == nullptr) {
+ return nullptr;
+ }
+ CRemoteObject *holder = new (std::nothrow) CRemoteProxyHolder();
+ if (holder == nullptr) {
+ printf("%s: create samgr proxy holder failed\n", __func__);
+ return nullptr;
+ }
+ holder->IncStrongRef(nullptr);
+ holder->remote_ = saMgr;
+ return holder;
+}
+}
\ No newline at end of file
diff --git a/services/samgr/native/include/c_func.h b/services/samgr/native/include/c_func.h
new file mode 100644
index 0000000000000000000000000000000000000000..3c276f75d6a41ac4c9f8367719d06f47f8f5540c
--- /dev/null
+++ b/services/samgr/native/include/c_func.h
@@ -0,0 +1,13 @@
+#ifndef __FUNC_H__
+#define __FUNC_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void Cfunc();
+
+#ifdef __cplusplus
+}
+#endif
+#endif
\ No newline at end of file
diff --git a/services/samgr/native/include/ctorust.h b/services/samgr/native/include/ctorust.h
new file mode 100644
index 0000000000000000000000000000000000000000..49523828ffff815ee51b183044853b91199123d8
--- /dev/null
+++ b/services/samgr/native/include/ctorust.h
@@ -0,0 +1,10 @@
+#ifndef SAMGR_SIMPLE_PRINTER_H
+#define SAMGR_SIMPLE_PRINTER_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+void print_hello_world();
+#ifdef __cplusplus
+}
+#endif
+#endif
\ No newline at end of file
diff --git a/services/samgr/native/include/system_ability_manager.h b/services/samgr/native/include/system_ability_manager.h
index 9e59a757614c3b1f626c8637dc281ce9d8afac28..3e7ee08a77eaf9cf5f37fa716fa5bbb3f6e44e52 100644
--- a/services/samgr/native/include/system_ability_manager.h
+++ b/services/samgr/native/include/system_ability_manager.h
@@ -87,6 +87,7 @@ public:
std::string TransformDeviceId(const std::string& deviceId, int32_t type, bool isPrivate);
std::string GetLocalNodeId();
void Init();
+ void WatchDogInit();
int32_t AddSystemProcess(const std::u16string& procName, const sptr& procObject) override;
int32_t RemoveSystemProcess(const sptr& procObject);
@@ -102,6 +103,7 @@ public:
void NotifyRpcLoadCompleted(const std::string& srcDeviceId, int32_t systemAbilityId,
const sptr& remoteObject);
void StartDfxTimer();
+ void DoLoadForPerf();
private:
enum class AbilityState {
INIT,
@@ -168,6 +170,9 @@ private:
void UpdateSaFreMap(int32_t pid, int32_t saId);
uint64_t GenerateFreKey(int32_t pid, int32_t saId) const;
void ReportGetSAPeriodically();
+ void OndemandLoad();
+ void OndemandLoadForPerf();
+ std::list GetAllOndemandSa();
std::u16string deviceName_;
static sptr instance;
@@ -204,7 +209,7 @@ private:
std::mutex loadRemoteLock_;
std::map>> remoteCallbacks_; // key : said_deviceId
- ThreadPool loadPool_;
+ std::unique_ptr loadPool_;
std::mutex saFrequencyLock_;
std::map saFrequencyMap_; // {pid_said, count}
diff --git a/services/samgr/native/samgr_standard.rc b/services/samgr/native/samgr_standard.rc
old mode 100755
new mode 100644
diff --git a/services/samgr/native/source/c_func.cpp b/services/samgr/native/source/c_func.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..257793193e0e899d62786bac270efb024375cec5
--- /dev/null
+++ b/services/samgr/native/source/c_func.cpp
@@ -0,0 +1,7 @@
+#include "c_func.h"
+#include
+
+void Cfunc()
+{
+ printf("rust调用C++\n"); // 注意:C调用C++接口时,接口实现不能使用C++独有的特性
+}
\ No newline at end of file
diff --git a/services/samgr/native/source/ctorust.cpp b/services/samgr/native/source/ctorust.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..8fbff4779e5715570781fdc20a5b91011c56a79c
--- /dev/null
+++ b/services/samgr/native/source/ctorust.cpp
@@ -0,0 +1,6 @@
+#include "ctorust.h"
+
+int main() {
+ print_hello_world();
+ return 0;
+}
\ No newline at end of file
diff --git a/services/samgr/native/source/dlopen.cpp b/services/samgr/native/source/dlopen.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..6cd32a7306f79f04a8b7a4194c3860193fedde79
--- /dev/null
+++ b/services/samgr/native/source/dlopen.cpp
@@ -0,0 +1,52 @@
+#include
+#include
+#include
+#include
+#include
+#include
+using namespace std;
+using DlHandle = void*;
+int main() {
+ DlHandle handle1 = dlopen("libdlopen_test_cpp.z.so", RTLD_NOW);
+ cout << "libdlopen_test_cpp dlopen" << endl;
+ if (handle1 == nullptr) {
+ cout << "libdlopen_test_cpp dlopen failed" << endl;
+ } else {
+ cout << "libdlopen_test_cpp dlopen success" << endl;
+ }
+ void* temp1 = dlsym(handle1, "get");
+ if (temp1 == nullptr) {
+ cout << "c++ get failed" << endl;
+ } else {
+ cout << "c++ get not null" << endl;
+ }
+ using OnStartFunc = int(*)();
+ OnStartFunc onStartFunc1 = reinterpret_cast(temp1);
+ if (onStartFunc1 == nullptr) {
+ dlclose(handle1);
+ cout << "libc++ reinterpret_cast failed" << endl;
+ }
+ cout << onStartFunc1() << endl;
+
+ DlHandle handle2 = dlopen("librust_dlopen.dylib.so", RTLD_NOW);
+ cout << "librust_dlopen dlopen" << endl;
+ if (handle2 == nullptr) {
+ cout << "librust_dlopen dlopen failed" << endl;
+ } else {
+ cout << "librust_dlopen dlopen success" << endl;
+ }
+ void* temp = dlsym(handle2, "get");
+ if (temp == nullptr) {
+ cout << "rust get failed" << endl;
+ return 0;
+ } else {
+ cout << "rust get not null" << endl;
+ }
+ OnStartFunc onStartFunc = reinterpret_cast(dlsym(handle2, "get"));
+ if (onStartFunc == nullptr) {
+ dlclose(handle2);
+ cout << "librust_dlopen reinterpret_cast failed" << endl;
+ return 0;
+ }
+ cout << onStartFunc() << endl;
+}
\ No newline at end of file
diff --git a/services/samgr/native/source/dlopen_test.cpp b/services/samgr/native/source/dlopen_test.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a2247fe9269e3a96f978107929a8306bdc6b7d1e
--- /dev/null
+++ b/services/samgr/native/source/dlopen_test.cpp
@@ -0,0 +1,13 @@
+#include
+using namespace std;
+int a = 10;
+static int test() {
+ cout << "c++ dlopen!!!!!!!!" << endl;
+ return 1;
+}
+int b = test();
+extern "C" {
+ int get() {
+ return b;
+ }
+}
diff --git a/services/samgr/native/source/service_registry.cpp b/services/samgr/native/source/service_registry.cpp
index 5d067dd7ace72c7beeca5d242ea901337fcee58d..d559ea35647cda7bbf990327e1e3339ae1bb6c9e 100644
--- a/services/samgr/native/source/service_registry.cpp
+++ b/services/samgr/native/source/service_registry.cpp
@@ -155,11 +155,6 @@ sptr SystemAbilityManagerClient::GetSystemAbilityManager(
return systemAbilityManager_;
}
-sptr SystemAbilityManagerClient::GetRegistryRemoteObject()
-{
- return nullptr;
-}
-
void SystemAbilityManagerClient::DestroySystemAbilityManagerObject()
{
HILOGI("%s called", __func__);
diff --git a/services/samgr/native/source/system_ability_manager.cpp b/services/samgr/native/source/system_ability_manager.cpp
index c1ba70a7851564855184c8b2132e323f654842d8..ba54c14f4a9b06c04c2172cd0e5380601787a5f8 100644
--- a/services/samgr/native/source/system_ability_manager.cpp
+++ b/services/samgr/native/source/system_ability_manager.cpp
@@ -22,12 +22,15 @@
#include "datetime_ex.h"
#include "directory_ex.h"
#include "errors.h"
+#include "hicollie_helper.h"
#include "hisysevent_adapter.h"
#include "hitrace_meter.h"
#include "if_local_ability_manager.h"
#include "ipc_skeleton.h"
#include "local_ability_manager_proxy.h"
#include "parse_util.h"
+#include "parameter.h"
+#include "parameters.h"
#include "sam_log.h"
#include "service_control.h"
#include "string_ex.h"
@@ -40,16 +43,19 @@ namespace OHOS {
namespace {
const string PREFIX = "/system/profile/";
const string LOCAL_DEVICE = "local";
+const string ONDEMAND_PARAM = "persist.samgr.perf.ondemand";
+constexpr const char* ONDEMAND_PERF_PARAM = "persist.samgr.perf.ondemand";
constexpr uint32_t REPORT_GET_SA_INTERVAL = 24 * 60 * 60 * 1000; // ms and is one day
constexpr int32_t MAX_NAME_SIZE = 200;
constexpr int32_t SPLIT_NAME_VECTOR_SIZE = 2;
-
+constexpr int32_t WAITTING = 1;
constexpr int32_t UID_ROOT = 0;
constexpr int32_t UID_SYSTEM = 1000;
constexpr int32_t MAX_SUBSCRIBE_COUNT = 256;
constexpr int32_t MAX_SA_FREQUENCY_COUNT = INT32_MAX - 1000000;
constexpr int32_t SHFIT_BIT = 32;
+constexpr int64_t ONDEMAND_PERF_DELAY_TIME = 60 * 1000; // ms
constexpr int64_t CHECK_LOADED_DELAY_TIME = 4 * 1000; // ms
}
@@ -63,8 +69,12 @@ SystemAbilityManager::SystemAbilityManager()
SystemAbilityManager::~SystemAbilityManager()
{
- loadPool_.Stop();
- reportEventTimer_->Shutdown();
+ if (loadPool_ != nullptr) {
+ loadPool_->Stop();
+ }
+ if (reportEventTimer_ != nullptr) {
+ reportEventTimer_->Shutdown();
+ }
}
void SystemAbilityManager::Init()
@@ -81,9 +91,30 @@ void SystemAbilityManager::Init()
workHandler_ = make_shared(runner);
}
InitSaProfile();
- loadPool_.Start(std::thread::hardware_concurrency());
- loadPool_.SetMaxTaskNum(std::thread::hardware_concurrency());
+ WatchDogInit();
+ loadPool_ = std::make_unique("OndemandLoader");
+ loadPool_->Start(std::thread::hardware_concurrency());
+ loadPool_->SetMaxTaskNum(std::thread::hardware_concurrency());
reportEventTimer_ = std::make_unique("DfxReporter");
+ OndemandLoadForPerf();
+}
+
+void SystemAbilityManager::WatchDogInit()
+{
+ constexpr int CHECK_PERIOD = 10000;
+ auto timeOutCallback = [this](const std::string& name, int waitState) {
+ int32_t pid = getpid();
+ uint32_t uid = getuid();
+ time_t curTime = time(nullptr);
+ std::string sendMsg = std::string((ctime(&curTime) == nullptr) ? "" : ctime(&curTime)) + "\n";
+ if (waitState == WAITTING) {
+ WatchDogSendEvent(pid, uid, sendMsg, "SAMGR_SERVICE_BLOCK");
+ }
+ };
+ int result = HicollieHelper::AddThread("SamgrTask", workHandler_, timeOutCallback, CHECK_PERIOD);
+ if (!result) {
+ HILOGE("Watchdog start failed");
+ }
}
const sptr SystemAbilityManager::GetDBinder() const
@@ -140,6 +171,59 @@ void SystemAbilityManager::InitSaProfile()
}
}
+void SystemAbilityManager::OndemandLoadForPerf()
+{
+ if (workHandler_ == nullptr) {
+ HILOGE("LoadForPerf workHandler_ not init!");
+ return;
+ }
+ auto callback = [this] () {
+ OndemandLoad();
+ };
+ workHandler_->PostTask(callback, ONDEMAND_PERF_DELAY_TIME);
+}
+
+void SystemAbilityManager::OndemandLoad()
+{
+ auto bootEventCallback = [](const char *key, const char *value, void *context) {
+ int64_t begin = GetTickCount();
+ SystemAbilityManager::GetInstance()->DoLoadForPerf();
+ HILOGI("[PerformanceTest] DoLoadForPerf spend %{public}" PRId64 " ms", GetTickCount() - begin);
+ };
+
+ int ret = WatchParameter(ONDEMAND_PERF_PARAM, bootEventCallback, nullptr);
+ HILOGD("OndemandLoad ret %{public}d", ret);
+}
+
+std::list SystemAbilityManager::GetAllOndemandSa()
+{
+ std::list ondemandSaids;
+ {
+ lock_guard autoLock(saProfileMapLock_);
+ for (const auto& [said, value] : saProfileMap_) {
+ shared_lock readLock(abilityMapLock_);
+ auto iter = abilityMap_.find(said);
+ if (iter == abilityMap_.end()) {
+ ondemandSaids.emplace_back(said);
+ }
+ }
+ }
+ return ondemandSaids;
+}
+
+void SystemAbilityManager::DoLoadForPerf()
+{
+ bool value = system::GetBoolParameter(ONDEMAND_PARAM, false);
+ if (value) {
+ std::list saids = GetAllOndemandSa();
+ HILOGD("DoLoadForPerf ondemand size : %{public}zu.", saids.size());
+ sptr callback(new SystemAbilityLoadCallbackStub());
+ for (auto said : saids) {
+ LoadSystemAbility(said, callback);
+ }
+ }
+}
+
bool SystemAbilityManager::GetSaProfile(int32_t saId, SaProfile& saProfile)
{
lock_guard autoLock(saProfileMapLock_);
@@ -961,6 +1045,9 @@ int32_t SystemAbilityManager::LoadSystemAbility(int32_t systemAbilityId,
int32_t SystemAbilityManager::LoadSystemAbility(int32_t systemAbilityId, const std::string& deviceId,
const sptr& callback)
{
+ if (loadPool_ == nullptr) {
+ return ERR_NO_INIT;
+ }
std::string key = ToString(systemAbilityId) + "_" + deviceId;
{
lock_guard autoLock(loadRemoteLock_);
@@ -983,7 +1070,7 @@ int32_t SystemAbilityManager::LoadSystemAbility(int32_t systemAbilityId, const s
auto callingUid = IPCSkeleton::GetCallingUid();
auto task = std::bind(&SystemAbilityManager::DoLoadRemoteSystemAbility, this,
systemAbilityId, callingPid, callingUid, deviceId, callback);
- loadPool_.AddTask(task);
+ loadPool_->AddTask(task);
return ERR_OK;
}
diff --git a/services/samgr/native/test/unittest/BUILD.gn b/services/samgr/native/test/unittest/BUILD.gn
index a080d93ff91f9998116bd25231f383a08b3f7b40..67828148507db7faed3f8ed1b92b72087ecb59a5 100644
--- a/services/samgr/native/test/unittest/BUILD.gn
+++ b/services/samgr/native/test/unittest/BUILD.gn
@@ -12,6 +12,7 @@
# limitations under the License.
import("//build/test.gni")
+import("../../../var.gni")
module_output_path = "samgr/samgr"
samgr_dir = "//foundation/systemabilitymgr/samgr"
@@ -33,6 +34,7 @@ ohos_unittest("SystemAbilityMgrTest") {
sources = [
"${samgr_dir}/utils/native/source/tools.cpp",
"${samgr_services_dir}/source/ability_death_recipient.cpp",
+ "${samgr_services_dir}/source/rpc_callback_imp.cpp",
"${samgr_services_dir}/source/system_ability_load_callback_proxy.cpp",
"${samgr_services_dir}/source/system_ability_manager.cpp",
"${samgr_services_dir}/source/system_ability_manager_stub.cpp",
@@ -41,6 +43,7 @@ ohos_unittest("SystemAbilityMgrTest") {
"${samgr_services_dir}/test/unittest/src/mock_permission.cpp",
"${samgr_services_dir}/test/unittest/src/sa_status_change_mock.cpp",
"${samgr_services_dir}/test/unittest/src/system_ability_mgr_test.cpp",
+ "//foundation/systemabilitymgr/samgr/services/dfx/source/hicollie_helper.cpp",
"//foundation/systemabilitymgr/samgr/services/dfx/source/hisysevent_adapter.cpp",
"//foundation/systemabilitymgr/samgr/services/lsamgr/src/local_ability_manager_proxy.cpp",
]
@@ -71,17 +74,78 @@ ohos_unittest("SystemAbilityMgrTest") {
"hisysevent_native:libhisysevent",
"hitrace_native:hitrace_meter",
"hiviewdfx_hilog_native:libhilog",
+ "init:libbeget_proxy",
"init:libbegetutil",
"ipc:ipc_core",
"ipc:libdbinder",
]
+ if (hicollie_able) {
+ external_deps += [ "hicollie_native:libhicollie" ]
+ defines = [ "HICOLLIE_ENABLE" ]
+ }
+}
+
+ohos_unittest("SystemAbilityMgrStubTest") {
+ module_out_path = module_output_path
+
+ sources = [
+ "${samgr_dir}/utils/native/source/tools.cpp",
+ "${samgr_services_dir}/source/ability_death_recipient.cpp",
+ "${samgr_services_dir}/source/rpc_callback_imp.cpp",
+ "${samgr_services_dir}/source/system_ability_manager.cpp",
+ "${samgr_services_dir}/source/system_ability_manager_stub.cpp",
+ "${samgr_services_dir}/test/unittest/src/itest_transaction_service.cpp",
+ "${samgr_services_dir}/test/unittest/src/mock_permission.cpp",
+ "${samgr_services_dir}/test/unittest/src/sa_status_change_mock.cpp",
+ "${samgr_services_dir}/test/unittest/src/system_ability_mgr_stub_test.cpp",
+ "//foundation/systemabilitymgr/samgr/services/dfx/source/hicollie_helper.cpp",
+ ]
+
+ configs = [
+ ":sam_test_config",
+ "${samgr_dir}/services/samgr/native:sam_config",
+ "//foundation/systemabilitymgr/samgr/test/resource:coverage_flags",
+ ]
+
+ cflags = []
+ if (target_cpu == "arm") {
+ cflags += [ "-DBINDER_IPC_32BIT" ]
+ }
+
+ deps = [
+ "${samgr_dir}/interfaces/innerkits/common:samgr_common",
+ "${samgr_dir}/interfaces/innerkits/samgr_proxy:samgr_proxy",
+ "//third_party/googletest:gtest_main",
+ ]
+
+ external_deps = [
+ "access_token:libaccesstoken_sdk",
+ "access_token:libnativetoken",
+ "access_token:libtoken_setproc",
+ "c_utils:utils",
+ "eventhandler:libeventhandler",
+ "hisysevent_native:libhisysevent",
+ "hitrace_native:hitrace_meter",
+ "hiviewdfx_hilog_native:libhilog",
+ "init:libbeget_proxy",
+ "init:libbegetutil",
+ "ipc:ipc_core",
+ "ipc:libdbinder",
+ ]
+ if (hicollie_able) {
+ external_deps += [ "hicollie_native:libhicollie" ]
+ defines = [ "HICOLLIE_ENABLE" ]
+ }
}
ohos_unittest("SystemAbilityMgrProxyTest") {
module_out_path = module_output_path
sources = [
+ "${samgr_services_dir}/source/system_ability_load_callback_proxy.cpp",
+ "${samgr_services_dir}/source/system_ability_status_change_proxy.cpp",
"${samgr_services_dir}/test/unittest/src/itest_transaction_service.cpp",
+ "${samgr_services_dir}/test/unittest/src/mock_iro_sendrequest.cpp",
"${samgr_services_dir}/test/unittest/src/mock_permission.cpp",
"${samgr_services_dir}/test/unittest/src/sa_status_change_mock.cpp",
"${samgr_services_dir}/test/unittest/src/system_ability_mgr_proxy_test.cpp",
@@ -119,6 +183,7 @@ ohos_unittest("LocalAbilityManagerProxyTest") {
sources = [
"${samgr_services_dir}/test/unittest/src/itest_transaction_service.cpp",
"${samgr_services_dir}/test/unittest/src/local_ability_manager_proxy_test.cpp",
+ "${samgr_services_dir}/test/unittest/src/mock_iro_sendrequest.cpp",
"//foundation/systemabilitymgr/samgr/services/lsamgr/src/local_ability_manager_proxy.cpp",
]
@@ -142,7 +207,10 @@ ohos_unittest("LocalAbilityManagerProxyTest") {
}
ohos_executable("ondemand") {
- sources = [ "./src/ondemand_helper.cpp" ]
+ sources = [
+ "${samgr_services_dir}/test/unittest/src/mock_permission.cpp",
+ "./src/ondemand_helper.cpp",
+ ]
configs = [
":sam_test_config",
"//foundation/systemabilitymgr/samgr/test/resource:coverage_flags",
@@ -182,6 +250,7 @@ ohos_executable("TestTool") {
"${samgr_services_dir}/source/system_ability_status_change_proxy.cpp",
"${samgr_services_dir}/test/unittest/src/itest_transaction_service.cpp",
"./src/system_ability_test_tool.cpp",
+ "//foundation/systemabilitymgr/samgr/services/dfx/source/hicollie_helper.cpp",
"//foundation/systemabilitymgr/samgr/services/dfx/source/hisysevent_adapter.cpp",
]
@@ -205,6 +274,11 @@ ohos_executable("TestTool") {
if (target_cpu == "arm") {
cflags += [ "-DBINDER_IPC_32BIT" ]
}
+
+ if (hicollie_able) {
+ external_deps += [ "hicollie_native:libhicollie" ]
+ defines = [ "HICOLLIE_ENABLE" ]
+ }
external_deps += [
"access_token:libaccesstoken_sdk",
"access_token:libnativetoken",
@@ -216,6 +290,7 @@ ohos_executable("TestTool") {
"hitrace_native:hitrace_meter",
"hiviewdfx_hilog_native:libhilog",
"hiviewdfx_hilog_native:libhilog_base",
+ "init:libbeget_proxy",
"init:libbegetutil",
"ipc:ipc_core",
"ipc:libdbinder",
@@ -229,6 +304,7 @@ group("unittest") {
deps = [
":LocalAbilityManagerProxyTest",
":SystemAbilityMgrProxyTest",
+ ":SystemAbilityMgrStubTest",
":SystemAbilityMgrTest",
":TestTool",
":ondemand",
diff --git a/services/samgr/native/test/unittest/include/mock_iro_sendrequest.h b/services/samgr/native/test/unittest/include/mock_iro_sendrequest.h
new file mode 100644
index 0000000000000000000000000000000000000000..d362f5583d84868a358233a68cc0e4f8609713b8
--- /dev/null
+++ b/services/samgr/native/test/unittest/include/mock_iro_sendrequest.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2022 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 SAMGR_TEST_UNITTEST_INCLUDE_MOCK_IRO_SENDREQUEST_H
+#define SAMGR_TEST_UNITTEST_INCLUDE_MOCK_IRO_SENDREQUEST_H
+
+#include "iremote_broker.h"
+#include "iremote_object.h"
+#include "iremote_proxy.h"
+#include "iremote_stub.h"
+#include "refbase.h"
+#include "sam_log.h"
+
+namespace OHOS {
+class MockIroSendrequest : public IRemoteBroker {
+public:
+ DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.MockIroSendrequest");
+};
+
+class MockIroSendrequesteStub : public IRemoteStub {
+public:
+ MockIroSendrequesteStub() = default;
+ virtual ~MockIroSendrequesteStub() = default;
+ int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
+ int32_t result_ = 0;
+ bool flag_ = false;
+};
+
+} // namespace OHOS
+#endif /* SAMGR_TEST_UNITTEST_INCLUDE_MOCK_IRO_SENDREQUEST_H */
\ No newline at end of file
diff --git a/services/samgr/native/test/unittest/include/system_ability_mgr_stub_test.h b/services/samgr/native/test/unittest/include/system_ability_mgr_stub_test.h
new file mode 100644
index 0000000000000000000000000000000000000000..43ae93e9a9462d0c05cdfc7bbb7f0a8558bdfe36
--- /dev/null
+++ b/services/samgr/native/test/unittest/include/system_ability_mgr_stub_test.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2022 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 SAMGR_TEST_UNITTEST_INCLUDE_SYSTEM_ABILITY_MGR_PROXY_TEST_H
+#define SAMGR_TEST_UNITTEST_INCLUDE_SYSTEM_ABILITY_MGR_PROXY_TEST_H
+
+#include "gtest/gtest.h"
+
+namespace OHOS {
+class SystemAbilityMgrStubTest : public testing::Test {
+public:
+ static void SetUpTestCase();
+ static void TearDownTestCase();
+ void SetUp();
+ void TearDown();
+};
+} // OHOS
+#endif /* SAMGR_TEST_UNITTEST_INCLUDE_SYSTEM_ABILITY_MGR_PROXY_TEST_H */
diff --git a/services/samgr/native/test/unittest/src/local_ability_manager_proxy_test.cpp b/services/samgr/native/test/unittest/src/local_ability_manager_proxy_test.cpp
index 2bc7b7ed03b078e80e85bdb32ab8d963a57d3778..2652a6b7d0921786bad9f88002225d25228137df 100644
--- a/services/samgr/native/test/unittest/src/local_ability_manager_proxy_test.cpp
+++ b/services/samgr/native/test/unittest/src/local_ability_manager_proxy_test.cpp
@@ -16,6 +16,7 @@
#include "itest_transaction_service.h"
#include "local_ability_manager_proxy.h"
+#include "mock_iro_sendrequest.h"
#include "string_ex.h"
#include "test_log.h"
@@ -60,9 +61,8 @@ void LocalAbilityManagerProxyTest::TearDown()
HWTEST_F(LocalAbilityManagerProxyTest, LocalAbilityManagerProxy001, TestSize.Level1)
{
sptr testAbility(new TestTransactionService());
- sptr LocalAbility(new LocalAbilityManagerProxy(testAbility));
- EXPECT_NE(LocalAbility, nullptr);
- bool res = LocalAbility->StartAbility(TEST_SAID_INVAILD);
+ sptr localAbility(new LocalAbilityManagerProxy(testAbility));
+ bool res = localAbility->StartAbility(TEST_SAID_INVAILD);
EXPECT_EQ(res, false);
}
@@ -74,10 +74,38 @@ HWTEST_F(LocalAbilityManagerProxyTest, LocalAbilityManagerProxy001, TestSize.Lev
*/
HWTEST_F(LocalAbilityManagerProxyTest, LocalAbilityManagerProxy002, TestSize.Level1)
{
- sptr testAbility(new TestTransactionService());
- sptr LocalAbility(new LocalAbilityManagerProxy(testAbility));
- EXPECT_NE(LocalAbility, nullptr);
- bool res = LocalAbility->StartAbility(TEST_SAID_VAILD);
+ sptr localAbility(new LocalAbilityManagerProxy(nullptr));
+ bool res = localAbility->StartAbility(TEST_SAID_VAILD);
+ EXPECT_EQ(res, false);
+}
+
+/**
+ * @tc.name: LocalAbilityManagerProxy003
+ * @tc.desc: LocalAbilityManagerProxy and check StartAbility
+ * @tc.type: FUNC
+ * @tc.require: I5KMF7
+ */
+HWTEST_F(LocalAbilityManagerProxyTest, LocalAbilityManagerProxy003, TestSize.Level1)
+{
+ sptr testAbility(new MockIroSendrequesteStub());
+ sptr localAbility(new LocalAbilityManagerProxy(testAbility));
+ bool res = localAbility->StartAbility(TEST_SAID_VAILD);
EXPECT_EQ(res, true);
}
+
+/**
+ * @tc.name: LocalAbilityManagerProxy004
+ * @tc.desc: LocalAbilityManagerProxy and check StartAbility
+ * @tc.type: FUNC
+ * @tc.require: I5KMF7
+ */
+HWTEST_F(LocalAbilityManagerProxyTest, LocalAbilityManagerProxy004, TestSize.Level1)
+{
+ sptr testAbility(new MockIroSendrequesteStub());
+ testAbility->result_ = 1;
+ sptr localAbility(new LocalAbilityManagerProxy(testAbility));
+ EXPECT_NE(localAbility, nullptr);
+ bool res = localAbility->StartAbility(TEST_SAID_VAILD);
+ EXPECT_EQ(res, false);
+}
}
\ No newline at end of file
diff --git a/services/samgr/native/test/unittest/src/mock_iro_sendrequest.cpp b/services/samgr/native/test/unittest/src/mock_iro_sendrequest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..72bcc439b9e100f9139dbba589ade9fdc82919c2
--- /dev/null
+++ b/services/samgr/native/test/unittest/src/mock_iro_sendrequest.cpp
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2022 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 "mock_iro_sendrequest.h"
+
+#include "hilog/log.h"
+#include "ipc_object_stub.h"
+#include "ipc_types.h"
+#include "message_option.h"
+#include "message_parcel.h"
+#include
+
+namespace OHOS {
+int32_t MockIroSendrequesteStub::OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply,
+ MessageOption& option)
+{
+ flag_ = true;
+ return result_;
+}
+} // namespace OHOS
\ No newline at end of file
diff --git a/services/samgr/native/test/unittest/src/ondemand_helper.cpp b/services/samgr/native/test/unittest/src/ondemand_helper.cpp
index ef05e6c60b832ff8cf30377b14fec4340d7cda19..7a1565005d9abddb83fd42f97665126494c8dca4 100644
--- a/services/samgr/native/test/unittest/src/ondemand_helper.cpp
+++ b/services/samgr/native/test/unittest/src/ondemand_helper.cpp
@@ -27,6 +27,7 @@
#include "iservice_registry.h"
#include "isystem_ability_load_callback.h"
#include "nativetoken_kit.h"
+#include "sam_mock_permission.h"
#include "softbus_bus_center.h"
#include "system_ability_definition.h"
#include "token_setproc.h"
@@ -224,7 +225,7 @@ sptr OnDemandHelper::GetSystemAbility(int32_t systemAbilityId)
cout << "GetSystemAbility systemAbilityId:" << systemAbilityId << " failed !" << endl;
return nullptr;
}
- cout << "GetSystemAbility result:" << ((remoteObject != nullptr) ? "succeed" : "failed") << " spend:"
+ cout << "GetSystemAbility result: success "<< " spend:"
<< (GetTickCount() - begin) << " ms" << " systemAbilityId:" << systemAbilityId << endl;
return remoteObject;
}
@@ -254,29 +255,9 @@ void OnDemandHelper::OnDemandLoadCallback::OnLoadSACompleteForRemote(const std::
}
}
-void MockPermission()
-{
- static const char *PERMS[] = {
- "ohos.permission.DISTRIBUTED_DATASYNC"
- };
- uint64_t tokenId;
- NativeTokenInfoParams infoInstance = {
- .dcapsNum = 0,
- .permsNum = 1,
- .aclsNum = 0,
- .dcaps = nullptr,
- .perms = PERMS,
- .acls = nullptr,
- .processName = "distributedsched",
- .aplStr = "system_core",
- };
- tokenId = GetAccessTokenId(&infoInstance);
- SetSelfTokenID(tokenId);
-}
-
int main(int argc, char* argv[])
{
- MockPermission();
+ SamMockPermission::MockPermission();
OHOS::OnDemandHelper& ondemandHelper = OnDemandHelper::GetInstance();
string cmd = "load";
do {
diff --git a/services/samgr/native/test/unittest/src/system_ability_mgr_proxy_test.cpp b/services/samgr/native/test/unittest/src/system_ability_mgr_proxy_test.cpp
index 1a159329a5643bef75b74e306193b1a2bd2d1320..e6fb64f742dc75e4efc3e8623f5a9debd3fa593a 100644
--- a/services/samgr/native/test/unittest/src/system_ability_mgr_proxy_test.cpp
+++ b/services/samgr/native/test/unittest/src/system_ability_mgr_proxy_test.cpp
@@ -16,8 +16,11 @@
#include "if_system_ability_manager.h"
#include "iservice_registry.h"
#include "itest_transaction_service.h"
+#include "mock_iro_sendrequest.h"
#include "sam_mock_permission.h"
#include "sa_status_change_mock.h"
+#include "system_ability_load_callback_proxy.h"
+#include "system_ability_status_change_proxy.h"
#include "string_ex.h"
#include "system_ability_manager_proxy.h"
#include "test_log.h"
@@ -31,6 +34,7 @@ using namespace OHOS;
namespace OHOS {
namespace {
+constexpr int32_t TEST_ID_NORANGE_SAID = -1;
constexpr int32_t TEST_ID_VAILD = 9999;
constexpr int32_t TEST_ID_INVAILD = 9990;
}
@@ -55,18 +59,6 @@ void SystemAbilityMgrProxyTest::TearDown()
DTEST_LOG << "TearDown" << std::endl;
}
-/**
- * @tc.name: GetRegistryRemoteObject001 test
- * @tc.desc: test for get RegistryRemoteObject
- * @tc.type: FUNC
- * @tc.require: I5KMF7
- */
-HWTEST_F(SystemAbilityMgrProxyTest, GetRegistryRemoteObject001, TestSize.Level1)
-{
- sptr remote = SystemAbilityManagerClient::GetInstance().GetRegistryRemoteObject();
- EXPECT_EQ(remote, nullptr);
-}
-
/**
* @tc.name: AddSystemProcess001
* @tc.desc: check add process remoteobject
@@ -111,6 +103,147 @@ HWTEST_F(SystemAbilityMgrProxyTest, AddSystemProcess002, TestSize.Level1)
EXPECT_EQ(ret, ERR_OK);
}
+/**
+ * @tc.name: CheckSystemAbility001
+ * @tc.desc: CheckSystemAbility, systemAbilityId: invalid!
+ * @tc.type: FUNC
+ * @tc.require: I5KMF7
+ */
+HWTEST_F(SystemAbilityMgrProxyTest, CheckSystemAbility001, TestSize.Level1)
+{
+ DTEST_LOG << " CheckSystemAbility001 start " << std::endl;
+ sptr sm = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
+ EXPECT_NE(sm, nullptr);
+ sptr ret = sm->CheckSystemAbility(TEST_ID_NORANGE_SAID);
+ EXPECT_EQ(ret, nullptr);
+}
+
+/**
+ * @tc.name: CheckSystemAbility002
+ * @tc.desc: CheckSystemAbility, CheckSystemAbility:systemAbilityId or deviceId is nullptr
+ * @tc.type: FUNC
+ * @tc.require: I5KMF7
+ */
+HWTEST_F(SystemAbilityMgrProxyTest, CheckSystemAbility002, TestSize.Level1)
+{
+ DTEST_LOG << " CheckSystemAbility002 start " << std::endl;
+ sptr sm = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
+ EXPECT_NE(sm, nullptr);
+ std::string deviceId = "";
+ sptr ret = sm->CheckSystemAbility(TEST_ID_NORANGE_SAID, deviceId);
+ EXPECT_EQ(ret, nullptr);
+}
+
+/**
+ * @tc.name: CheckSystemAbility003
+ * @tc.desc: CheckSystemAbility, CheckSystemAbility:systemAbilityId or deviceId is nullptr
+ * @tc.type: FUNC
+ * @tc.require: I5KMF7
+ */
+HWTEST_F(SystemAbilityMgrProxyTest, CheckSystemAbility003, TestSize.Level1)
+{
+ DTEST_LOG << " CheckSystemAbility003 start " << std::endl;
+ sptr sm = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
+ EXPECT_NE(sm, nullptr);
+ std::string deviceId = "";
+ sptr ret = sm->CheckSystemAbility(TEST_ID_VAILD, deviceId);
+ EXPECT_EQ(ret, nullptr);
+}
+
+/**
+ * @tc.name: CheckSystemAbility004
+ * @tc.desc: CheckSystemAbility, CheckSystemAbility:systemAbilityId invalid!
+ * @tc.type: FUNC
+ * @tc.require: I5KMF7
+ */
+HWTEST_F(SystemAbilityMgrProxyTest, CheckSystemAbility004, TestSize.Level1)
+{
+ DTEST_LOG << " CheckSystemAbility004 start " << std::endl;
+ sptr sm = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
+ EXPECT_NE(sm, nullptr);
+ bool isExist = true;
+ sptr ret = sm->CheckSystemAbility(TEST_ID_VAILD, isExist);
+ EXPECT_EQ(ret, nullptr);
+}
+
+/**
+ * @tc.name: CheckSystemAbility005
+ * @tc.desc: CheckSystemAbility, CheckSystemAbility:systemAbilityId invalid!
+ * @tc.type: FUNC
+ * @tc.require: I5KMF7
+ */
+HWTEST_F(SystemAbilityMgrProxyTest, CheckSystemAbility005, TestSize.Level1)
+{
+ DTEST_LOG << " CheckSystemAbility005 start " << std::endl;
+ sptr sm = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
+ EXPECT_NE(sm, nullptr);
+ bool isExist = true;
+ sptr ret = sm->CheckSystemAbility(TEST_ID_NORANGE_SAID, isExist);
+ EXPECT_EQ(ret, nullptr);
+}
+
+/**
+ * @tc.name: AddOnDemandSystemAbilityInfo001
+ * @tc.desc: AddOnDemandSystemAbilityInfo, AddOnDemandSystemAbilityInfo invalid params
+ * @tc.type: FUNC
+ * @tc.require: I5KMF7
+ */
+HWTEST_F(SystemAbilityMgrProxyTest, AddOnDemandSystemAbilityInfo001, TestSize.Level1)
+{
+ DTEST_LOG << " AddOnDemandSystemAbilityInfo001 start " << std::endl;
+ sptr sm = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
+ EXPECT_NE(sm, nullptr);
+ std::u16string localAbilityManagerName = u"";
+ int32_t ret = sm->AddOnDemandSystemAbilityInfo(TEST_ID_NORANGE_SAID, localAbilityManagerName);
+ EXPECT_EQ(ret, ERR_INVALID_VALUE);
+}
+
+/**
+ * @tc.name: AddOnDemandSystemAbilityInfo002
+ * @tc.desc: AddOnDemandSystemAbilityInfo, AddOnDemandSystemAbilityInfo invalid params
+ * @tc.type: FUNC
+ * @tc.require: I5KMF7
+ */
+HWTEST_F(SystemAbilityMgrProxyTest, AddOnDemandSystemAbilityInfo002, TestSize.Level1)
+{
+ DTEST_LOG << " AddOnDemandSystemAbilityInfo002 start " << std::endl;
+ sptr sm = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
+ EXPECT_NE(sm, nullptr);
+ std::u16string localAbilityManagerName = u"";
+ int32_t ret = sm->AddOnDemandSystemAbilityInfo(TEST_ID_VAILD, localAbilityManagerName);
+ EXPECT_EQ(ret, ERR_INVALID_VALUE);
+}
+
+/**
+ * @tc.name: SubscribeSystemAbility001
+ * @tc.desc: SubscribeSystemAbility, SubscribeSystemAbility systemAbilityId: or listener invalid!
+ * @tc.type: FUNC
+ * @tc.require: I5KMF7
+ */
+HWTEST_F(SystemAbilityMgrProxyTest, SubscribeSystemAbility001, TestSize.Level1)
+{
+ DTEST_LOG << " SubscribeSystemAbility001 start " << std::endl;
+ sptr sm = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
+ EXPECT_NE(sm, nullptr);
+ int32_t ret = sm->SubscribeSystemAbility(TEST_ID_NORANGE_SAID, nullptr);
+ EXPECT_EQ(ret, ERR_INVALID_VALUE);
+}
+
+/**
+ * @tc.name: SubscribeSystemAbility002
+ * @tc.desc: SubscribeSystemAbility, SubscribeSystemAbility systemAbilityId: or listener invalid!
+ * @tc.type: FUNC
+ * @tc.require: I5KMF7
+ */
+HWTEST_F(SystemAbilityMgrProxyTest, SubscribeSystemAbility002, TestSize.Level1)
+{
+ DTEST_LOG << " SubscribeSystemAbility002 start " << std::endl;
+ sptr sm = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
+ EXPECT_NE(sm, nullptr);
+ int32_t ret = sm->SubscribeSystemAbility(TEST_ID_VAILD, nullptr);
+ EXPECT_EQ(ret, ERR_INVALID_VALUE);
+}
+
/**
* @tc.name: UnSubscribeSystemAbility001
* @tc.desc: check UnSubscribeSystemAbility
@@ -143,6 +276,98 @@ HWTEST_F(SystemAbilityMgrProxyTest, UnSubscribeSystemAbility002, TestSize.Level1
EXPECT_EQ(res, ERR_OK);
}
+/**
+ * @tc.name: UnSubscribeSystemAbility003
+ * @tc.desc: check UnSubscribeSystemAbility
+ * @tc.type: FUNC
+ * @tc.require: I5KMF7
+ */
+HWTEST_F(SystemAbilityMgrProxyTest, UnSubscribeSystemAbility003, TestSize.Level1)
+{
+ sptr sm = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
+ EXPECT_NE(sm, nullptr);
+ sptr callback(new SaStatusChangeMock());
+ int32_t res = sm->UnSubscribeSystemAbility(TEST_ID_NORANGE_SAID, callback);
+ EXPECT_EQ(res, ERR_INVALID_VALUE);
+}
+
+/**
+ * @tc.name: UnSubscribeSystemAbility004
+ * @tc.desc: check UnSubscribeSystemAbility
+ * @tc.type: FUNC
+ * @tc.require: I5KMF7
+ */
+HWTEST_F(SystemAbilityMgrProxyTest, UnSubscribeSystemAbility004, TestSize.Level1)
+{
+ sptr sm = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
+ EXPECT_NE(sm, nullptr);
+ int32_t res = sm->UnSubscribeSystemAbility(TEST_ID_VAILD, nullptr);
+ EXPECT_EQ(res, ERR_INVALID_VALUE);
+}
+
+/**
+ * @tc.name: LoadSystemAbility001
+ * @tc.desc: check LoadSystemAbility
+ * @tc.type: FUNC
+ * @tc.require: I5KMF7
+ */
+HWTEST_F(SystemAbilityMgrProxyTest, LoadSystemAbility001, TestSize.Level1)
+{
+ sptr sm = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
+ EXPECT_NE(sm, nullptr);
+ std::string deviceId = "deviceId";
+ sptr callback(new SystemAbilityLoadCallbackMock());
+ int32_t res = sm->LoadSystemAbility(TEST_ID_NORANGE_SAID, deviceId, callback);
+ EXPECT_EQ(res, ERR_INVALID_VALUE);
+}
+
+/**
+ * @tc.name: LoadSystemAbility002
+ * @tc.desc: check LoadSystemAbility
+ * @tc.type: FUNC
+ * @tc.require: I5KMF7
+ */
+HWTEST_F(SystemAbilityMgrProxyTest, LoadSystemAbility002, TestSize.Level1)
+{
+ sptr sm = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
+ EXPECT_NE(sm, nullptr);
+ std::string deviceId = "";
+ sptr callback(new SystemAbilityLoadCallbackMock());
+ int32_t res = sm->LoadSystemAbility(TEST_ID_VAILD, deviceId, callback);
+ EXPECT_EQ(res, ERR_INVALID_VALUE);
+}
+
+/**
+ * @tc.name: LoadSystemAbility003
+ * @tc.desc: check LoadSystemAbility
+ * @tc.type: FUNC
+ * @tc.require: I5KMF7
+ */
+HWTEST_F(SystemAbilityMgrProxyTest, LoadSystemAbility003, TestSize.Level1)
+{
+ sptr sm = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
+ EXPECT_NE(sm, nullptr);
+ std::string deviceId = "deviceId";
+ int32_t res = sm->LoadSystemAbility(TEST_ID_VAILD, deviceId, nullptr);
+ EXPECT_EQ(res, ERR_INVALID_VALUE);
+}
+
+/**
+ * @tc.name: LoadSystemAbility004
+ * @tc.desc: check LoadSystemAbility
+ * @tc.type: FUNC
+ * @tc.require: I5KMF7
+ */
+HWTEST_F(SystemAbilityMgrProxyTest, LoadSystemAbility004, TestSize.Level1)
+{
+ sptr sm = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
+ EXPECT_NE(sm, nullptr);
+ std::string deviceId = "deviceId";
+ sptr callback(new SystemAbilityLoadCallbackMock());
+ int32_t res = sm->LoadSystemAbility(TEST_ID_VAILD, deviceId, callback);
+ EXPECT_EQ(res, ERR_NONE);
+}
+
/**
* @tc.name: ServiceRegistry001
* @tc.desc: check ServiceRegistry
@@ -154,4 +379,313 @@ HWTEST_F(SystemAbilityMgrProxyTest, ServiceRegistry001, TestSize.Level1)
sptr sr = ServiceRegistry::GetInstance();
EXPECT_EQ(sr, nullptr);
}
+
+/**
+ * @tc.name: OnLoadSystemAbilitySuccess001
+ * @tc.desc: check OnLoadSystemAbilitySuccess001
+ * @tc.type: FUNC
+ * @tc.require: I5KMF7
+ */
+HWTEST_F(SystemAbilityMgrProxyTest, OnLoadSystemAbilitySuccess001, TestSize.Level1)
+{
+ sptr testAbility(new MockIroSendrequesteStub());
+ sptr systemAbility(new SystemAbilityLoadCallbackProxy(testAbility));
+ systemAbility->OnLoadSystemAbilitySuccess(TEST_ID_NORANGE_SAID, testAbility);
+ EXPECT_EQ(testAbility->flag_, false);
+}
+
+/**
+ * @tc.name: OnLoadSystemAbilitySuccess002
+ * @tc.desc: check OnLoadSystemAbilitySuccess002
+ * @tc.type: FUNC
+ * @tc.require: I5KMF7
+ */
+HWTEST_F(SystemAbilityMgrProxyTest, OnLoadSystemAbilitySuccess002, TestSize.Level1)
+{
+ sptr testAbility(new MockIroSendrequesteStub());
+ sptr systemAbility(new SystemAbilityLoadCallbackProxy(nullptr));
+ systemAbility->OnLoadSystemAbilitySuccess(TEST_ID_VAILD, testAbility);
+ EXPECT_EQ(testAbility->flag_, false);
+}
+
+/**
+ * @tc.name: OnLoadSystemAbilitySuccess003
+ * @tc.desc: check OnLoadSystemAbilitySuccess003
+ * @tc.type: FUNC
+ * @tc.require: I5KMF7
+ */
+HWTEST_F(SystemAbilityMgrProxyTest, OnLoadSystemAbilitySuccess003, TestSize.Level1)
+{
+ sptr testAbility(new MockIroSendrequesteStub());
+ sptr systemAbility(new SystemAbilityLoadCallbackProxy(testAbility));
+ systemAbility->OnLoadSystemAbilitySuccess(TEST_ID_VAILD, nullptr);
+ EXPECT_EQ(testAbility->flag_, false);
+}
+
+/**
+ * @tc.name: OnLoadSystemAbilitySuccess004
+ * @tc.desc: check OnLoadSystemAbilitySuccess004
+ * @tc.type: FUNC
+ * @tc.require: I5KMF7
+ */
+HWTEST_F(SystemAbilityMgrProxyTest, OnLoadSystemAbilitySuccess004, TestSize.Level1)
+{
+ sptr testAbility(new MockIroSendrequesteStub());
+ sptr systemAbility(new SystemAbilityLoadCallbackProxy(testAbility));
+ systemAbility->OnLoadSystemAbilitySuccess(TEST_ID_VAILD, testAbility);
+ EXPECT_EQ(testAbility->flag_, true);
+}
+
+/**
+ * @tc.name: OnLoadSystemAbilitySuccess005
+ * @tc.desc: check OnLoadSystemAbilitySuccess005
+ * @tc.type: FUNC
+ * @tc.require: I5KMF7
+ */
+HWTEST_F(SystemAbilityMgrProxyTest, OnLoadSystemAbilitySuccess005, TestSize.Level1)
+{
+ sptr testAbility(new MockIroSendrequesteStub());
+ testAbility->result_ = 1;
+ sptr systemAbility(new SystemAbilityLoadCallbackProxy(testAbility));
+ systemAbility->OnLoadSystemAbilitySuccess(TEST_ID_VAILD, testAbility);
+ EXPECT_EQ(testAbility->flag_, true);
+}
+
+/**
+ * @tc.name: OnLoadSystemAbilityFail001
+ * @tc.desc: check OnLoadSystemAbilityFail001
+ * @tc.type: FUNC
+ * @tc.require: I5KMF7
+ */
+HWTEST_F(SystemAbilityMgrProxyTest, OnLoadSystemAbilityFail001, TestSize.Level1)
+{
+ sptr testAbility(new MockIroSendrequesteStub());
+ sptr systemAbility(new SystemAbilityLoadCallbackProxy(testAbility));
+ systemAbility->OnLoadSystemAbilityFail(TEST_ID_NORANGE_SAID);
+ EXPECT_EQ(testAbility->flag_, false);
+}
+
+/**
+ * @tc.name: OnLoadSystemAbilityFail002
+ * @tc.desc: check OnLoadSystemAbilityFail002
+ * @tc.type: FUNC
+ * @tc.require: I5KMF7
+ */
+HWTEST_F(SystemAbilityMgrProxyTest, OnLoadSystemAbilityFail002, TestSize.Level1)
+{
+ sptr testAbility(new MockIroSendrequesteStub());
+ sptr systemAbility(new SystemAbilityLoadCallbackProxy(nullptr));
+ systemAbility->OnLoadSystemAbilityFail(TEST_ID_VAILD);
+ EXPECT_EQ(testAbility->flag_, false);
+}
+
+/**
+ * @tc.name: OnLoadSystemAbilityFail003
+ * @tc.desc: check OnLoadSystemAbilityFail003
+ * @tc.type: FUNC
+ * @tc.require: I5KMF7
+ */
+HWTEST_F(SystemAbilityMgrProxyTest, OnLoadSystemAbilityFail003, TestSize.Level1)
+{
+ sptr testAbility(new MockIroSendrequesteStub());
+ sptr systemAbility(new SystemAbilityLoadCallbackProxy(testAbility));
+ systemAbility->OnLoadSystemAbilityFail(TEST_ID_VAILD);
+ EXPECT_EQ(testAbility->flag_, true);
+}
+
+/**
+ * @tc.name: OnLoadSystemAbilityFail004
+ * @tc.desc: check OnLoadSystemAbilityFail004
+ * @tc.type: FUNC
+ * @tc.require: I5KMF7
+ */
+HWTEST_F(SystemAbilityMgrProxyTest, OnLoadSystemAbilityFail004, TestSize.Level1)
+{
+ sptr testAbility(new MockIroSendrequesteStub());
+ testAbility->result_ = 1;
+ sptr systemAbility(new SystemAbilityLoadCallbackProxy(testAbility));
+ systemAbility->OnLoadSystemAbilityFail(TEST_ID_VAILD);
+ EXPECT_EQ(testAbility->flag_, true);
+}
+
+/**
+ * @tc.name: OnLoadSACompleteForRemote001
+ * @tc.desc: check OnLoadSACompleteForRemote001
+ * @tc.type: FUNC
+ * @tc.require: I5KMF7
+ */
+HWTEST_F(SystemAbilityMgrProxyTest, OnLoadSACompleteForRemote001, TestSize.Level1)
+{
+ sptr testAbility(new MockIroSendrequesteStub());
+ sptr systemAbility(new SystemAbilityLoadCallbackProxy(testAbility));
+ string deviceId = "test";
+ systemAbility->OnLoadSACompleteForRemote(deviceId, TEST_ID_NORANGE_SAID, testAbility);
+ EXPECT_EQ(testAbility->flag_, false);
+}
+
+/**
+ * @tc.name: OnLoadSACompleteForRemote002
+ * @tc.desc: check OnLoadSACompleteForRemote002
+ * @tc.type: FUNC
+ * @tc.require: I5KMF7
+ */
+HWTEST_F(SystemAbilityMgrProxyTest, OnLoadSACompleteForRemote002, TestSize.Level1)
+{
+ sptr testAbility(new MockIroSendrequesteStub());
+ sptr systemAbility(new SystemAbilityLoadCallbackProxy(nullptr));
+ string deviceId = "test";
+ systemAbility->OnLoadSACompleteForRemote(deviceId, TEST_ID_VAILD, testAbility);
+ EXPECT_EQ(testAbility->flag_, false);
+}
+
+/**
+ * @tc.name: OnLoadSACompleteForRemote003
+ * @tc.desc: check OnLoadSACompleteForRemote003
+ * @tc.type: FUNC
+ * @tc.require: I5KMF7
+ */
+HWTEST_F(SystemAbilityMgrProxyTest, OnLoadSACompleteForRemote003, TestSize.Level1)
+{
+ sptr testAbility(new MockIroSendrequesteStub());
+ sptr systemAbility(new SystemAbilityLoadCallbackProxy(testAbility));
+ string deviceId = "test";
+ systemAbility->OnLoadSACompleteForRemote(deviceId, TEST_ID_VAILD, nullptr);
+ EXPECT_EQ(testAbility->flag_, true);
+}
+
+/**
+ * @tc.name: OnLoadSACompleteForRemote004
+ * @tc.desc: check OnLoadSACompleteForRemote004
+ * @tc.type: FUNC
+ * @tc.require: I5KMF7
+ */
+HWTEST_F(SystemAbilityMgrProxyTest, OnLoadSACompleteForRemote004, TestSize.Level1)
+{
+ sptr testAbility(new MockIroSendrequesteStub());
+ sptr systemAbility(new SystemAbilityLoadCallbackProxy(testAbility));
+ string deviceId = "test";
+ systemAbility->OnLoadSACompleteForRemote(deviceId, TEST_ID_VAILD, testAbility);
+ EXPECT_EQ(testAbility->flag_, true);
+}
+
+/**
+ * @tc.name: OnLoadSACompleteForRemote005
+ * @tc.desc: check OnLoadSACompleteForRemote005
+ * @tc.type: FUNC
+ * @tc.require: I5KMF7
+ */
+HWTEST_F(SystemAbilityMgrProxyTest, OnLoadSACompleteForRemote005, TestSize.Level1)
+{
+ sptr testAbility(new MockIroSendrequesteStub());
+ testAbility->result_ = 1;
+ sptr systemAbility(new SystemAbilityLoadCallbackProxy(testAbility));
+ string deviceId = "test";
+ systemAbility->OnLoadSACompleteForRemote(deviceId, TEST_ID_VAILD, testAbility);
+ EXPECT_EQ(testAbility->flag_, true);
+}
+
+/**
+ * @tc.name: OnAddSystemAbility001
+ * @tc.desc: check SystemAbilityStatusChangeProxy OnAddSystemAbility001
+ * @tc.type: FUNC
+ * @tc.require: I5KMF7
+ */
+HWTEST_F(SystemAbilityMgrProxyTest, OnAddSystemAbility001, TestSize.Level1)
+{
+ sptr testAbility(new MockIroSendrequesteStub());
+ sptr systemAbility(new SystemAbilityStatusChangeProxy(testAbility));
+ string deviceId = "test";
+ systemAbility->OnAddSystemAbility(TEST_ID_NORANGE_SAID, deviceId);
+ EXPECT_EQ(testAbility->flag_, false);
+}
+
+/**
+ * @tc.name: OnAddSystemAbility002
+ * @tc.desc: check SystemAbilityStatusChangeProxy OnAddSystemAbility002
+ * @tc.type: FUNC
+ * @tc.require: I5KMF7
+ */
+HWTEST_F(SystemAbilityMgrProxyTest, OnAddSystemAbility002, TestSize.Level1)
+{
+ sptr testAbility(new MockIroSendrequesteStub());
+ sptr systemAbility(new SystemAbilityStatusChangeProxy(nullptr));
+ string deviceId = "test";
+ systemAbility->OnAddSystemAbility(TEST_ID_VAILD, deviceId);
+ EXPECT_EQ(testAbility->flag_, false);
+}
+
+/**
+ * @tc.name: OnAddSystemAbility003
+ * @tc.desc: check SystemAbilityStatusChangeProxy OnAddSystemAbility003
+ * @tc.type: FUNC
+ * @tc.require: I5KMF7
+ */
+HWTEST_F(SystemAbilityMgrProxyTest, OnAddSystemAbility003, TestSize.Level1)
+{
+ sptr testAbility(new MockIroSendrequesteStub());
+ sptr systemAbility(new SystemAbilityStatusChangeProxy(testAbility));
+ string deviceId = "test";
+ systemAbility->OnAddSystemAbility(TEST_ID_VAILD, deviceId);
+ EXPECT_EQ(testAbility->flag_, true);
+}
+
+/**
+ * @tc.name: OnAddSystemAbility004
+ * @tc.desc: check SystemAbilityStatusChangeProxy OnAddSystemAbility004
+ * @tc.type: FUNC
+ * @tc.require: I5KMF7
+ */
+HWTEST_F(SystemAbilityMgrProxyTest, OnAddSystemAbility004, TestSize.Level1)
+{
+ sptr testAbility(new MockIroSendrequesteStub());
+ testAbility->result_ = 1;
+ sptr systemAbility(new SystemAbilityStatusChangeProxy(testAbility));
+ string deviceId = "test";
+ systemAbility->OnAddSystemAbility(TEST_ID_VAILD, deviceId);
+ EXPECT_EQ(testAbility->flag_, true);
+}
+
+/**
+ * @tc.name: OnRemoveSystemAbility001
+ * @tc.desc: check SystemAbilityStatusChangeProxy OnRemoveSystemAbility001
+ * @tc.type: FUNC
+ * @tc.require: I5KMF7
+ */
+HWTEST_F(SystemAbilityMgrProxyTest, OnRemoveSystemAbility001, TestSize.Level1)
+{
+ sptr testAbility(new MockIroSendrequesteStub());
+ testAbility->result_ = 1;
+ sptr systemAbility(new SystemAbilityStatusChangeProxy(testAbility));
+ string deviceId = "test";
+ systemAbility->OnRemoveSystemAbility(TEST_ID_VAILD, deviceId);
+ EXPECT_EQ(testAbility->flag_, true);
+}
+
+/**
+ * @tc.name: OnRemoveSystemAbility002
+ * @tc.desc: check SystemAbilityStatusChangeProxy OnRemoveSystemAbility002
+ * @tc.type: FUNC
+ * @tc.require: I5KMF7
+ */
+HWTEST_F(SystemAbilityMgrProxyTest, OnRemoveSystemAbility002, TestSize.Level1)
+{
+ sptr testAbility(new MockIroSendrequesteStub());
+ sptr systemAbility(new SystemAbilityStatusChangeProxy(testAbility));
+ string deviceId = "test";
+ systemAbility->OnRemoveSystemAbility(TEST_ID_VAILD, deviceId);
+ EXPECT_EQ(testAbility->flag_, true);
+}
+
+/**
+ * @tc.name: DestroySystemAbilityManagerObject001
+ * @tc.desc: check DestroySystemAbilityManagerObject
+ * @tc.type: FUNC
+ * @tc.require: I5KMF7
+ */
+HWTEST_F(SystemAbilityMgrProxyTest, DestroySystemAbilityManagerObject001, TestSize.Level4)
+{
+ SystemAbilityManagerClient::GetInstance().DestroySystemAbilityManagerObject();
+ sptr sm = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
+ EXPECT_TRUE(sm != nullptr);
+}
}
diff --git a/services/samgr/native/test/unittest/src/system_ability_mgr_stub_test.cpp b/services/samgr/native/test/unittest/src/system_ability_mgr_stub_test.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..9dc64c116896ab14947c63bf250b6309e28bad05
--- /dev/null
+++ b/services/samgr/native/test/unittest/src/system_ability_mgr_stub_test.cpp
@@ -0,0 +1,2362 @@
+/*
+ * Copyright (c) 2022 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 "system_ability_mgr_stub_test.h"
+
+#include "ability_death_recipient.h"
+#include "itest_transaction_service.h"
+#include "if_system_ability_manager.h"
+#include "ipc_skeleton.h"
+#include "sam_mock_permission.h"
+#include "string_ex.h"
+#include "system_ability_definition.h"
+#include "test_log.h"
+
+#define private public
+#include "sa_status_change_mock.h"
+#include "system_ability_manager.h"
+
+using namespace std;
+using namespace testing;
+using namespace testing::ext;
+using namespace OHOS;
+
+namespace OHOS {
+namespace {
+const std::u16string SAMANAGER_INTERFACE_TOKEN = u"ohos.samgr.accessToken";
+constexpr uint32_t SAID = 1499;
+constexpr uint32_t INVALID_SAID = -1;
+constexpr uint32_t INVALID_CODE = 50;
+}
+void SystemAbilityMgrStubTest::SetUpTestCase()
+{
+ DTEST_LOG << "SetUpTestCase" << std::endl;
+}
+
+void SystemAbilityMgrStubTest::TearDownTestCase()
+{
+ DTEST_LOG << "TearDownTestCase" << std::endl;
+}
+
+void SystemAbilityMgrStubTest::SetUp()
+{
+ DTEST_LOG << "SetUp" << std::endl;
+}
+
+void SystemAbilityMgrStubTest::TearDown()
+{
+ DTEST_LOG << "TearDown" << std::endl;
+}
+
+/**
+ * @tc.name: OnRemoteRequest001
+ * @tc.desc: test OnRemoteRequest, code not exist
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, OnRemoteRequest001, TestSize.Level4)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ EXPECT_TRUE(saMgr != nullptr);
+ MessageParcel data;
+ data.WriteInterfaceToken(SAMANAGER_INTERFACE_TOKEN);
+ MessageParcel reply;
+ MessageOption option;
+ int32_t result = saMgr->OnRemoteRequest(INVALID_CODE, data, reply, option);
+ EXPECT_EQ(result, IPC_STUB_UNKNOW_TRANS_ERR);
+}
+
+/**
+ * @tc.name: ListSystemAbilityInner001
+ * @tc.desc: test ListSystemAbilityInner, permission denied!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, ListSystemAbilityInner001, TestSize.Level4)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ EXPECT_TRUE(saMgr != nullptr);
+ MessageParcel data;
+ MessageParcel reply;
+ int32_t result = saMgr->ListSystemAbilityInner(data, reply);
+ EXPECT_EQ(result, ERR_PERMISSION_DENIED);
+}
+
+/**
+ * @tc.name: SubsSystemAbilityInner001
+ * @tc.desc: test SubsSystemAbilityInner, permission denied!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, SubsSystemAbilityInner001, TestSize.Level4)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ EXPECT_TRUE(saMgr != nullptr);
+ MessageParcel data;
+ MessageParcel reply;
+ int32_t result = saMgr->SubsSystemAbilityInner(data, reply);
+ EXPECT_EQ(result, ERR_PERMISSION_DENIED);
+}
+
+/**
+ * @tc.name: UnSubsSystemAbilityInner001
+ * @tc.desc: test UnSubsSystemAbilityInner, permission denied!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, UnSubsSystemAbilityInner001, TestSize.Level4)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ EXPECT_TRUE(saMgr != nullptr);
+ MessageParcel data;
+ MessageParcel reply;
+ int32_t result = saMgr->UnSubsSystemAbilityInner(data, reply);
+ EXPECT_EQ(result, ERR_PERMISSION_DENIED);
+}
+
+/**
+ * @tc.name: CheckRemtSystemAbilityInner001
+ * @tc.desc: test CheckRemtSystemAbilityInner, permission denied!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, CheckRemtSystemAbilityInner001, TestSize.Level4)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ EXPECT_TRUE(saMgr != nullptr);
+ MessageParcel data;
+ MessageParcel reply;
+ int32_t result = saMgr->CheckRemtSystemAbilityInner(data, reply);
+ EXPECT_EQ(result, ERR_PERMISSION_DENIED);
+}
+
+/**
+ * @tc.name: AddOndemandSystemAbilityInner001
+ * @tc.desc: test AddOndemandSystemAbilityInner, permission denied!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, AddOndemandSystemAbilityInner001, TestSize.Level4)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ EXPECT_TRUE(saMgr != nullptr);
+ MessageParcel data;
+ MessageParcel reply;
+ int32_t result = saMgr->AddOndemandSystemAbilityInner(data, reply);
+ EXPECT_EQ(result, ERR_PERMISSION_DENIED);
+}
+
+/**
+ * @tc.name: AddSystemAbilityInner001
+ * @tc.desc: test AddSystemAbilityInner, permission denied!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, AddSystemAbilityInner001, TestSize.Level4)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ EXPECT_TRUE(saMgr != nullptr);
+ MessageParcel data;
+ MessageParcel reply;
+ int32_t result = saMgr->AddSystemAbilityInner(data, reply);
+ EXPECT_EQ(result, ERR_PERMISSION_DENIED);
+}
+
+/**
+ * @tc.name: RemoveSystemAbilityInner001
+ * @tc.desc: test RemoveSystemAbilityInner, permission denied!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, RemoveSystemAbilityInner001, TestSize.Level4)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ EXPECT_TRUE(saMgr != nullptr);
+ MessageParcel data;
+ MessageParcel reply;
+ int32_t result = saMgr->RemoveSystemAbilityInner(data, reply);
+ EXPECT_EQ(result, ERR_PERMISSION_DENIED);
+}
+
+/**
+ * @tc.name: AddSystemProcessInner001
+ * @tc.desc: test AddSystemProcessInner, permission denied!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, AddSystemProcessInner001, TestSize.Level4)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ EXPECT_TRUE(saMgr != nullptr);
+ MessageParcel data;
+ MessageParcel reply;
+ int32_t result = saMgr->AddSystemProcessInner(data, reply);
+ EXPECT_EQ(result, ERR_PERMISSION_DENIED);
+}
+
+/**
+ * @tc.name: ListSystemAbilityInner002
+ * @tc.desc: test ListSystemAbilityInner, read dumpflag failed!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, ListSystemAbilityInner002, TestSize.Level3)
+{
+ SamMockPermission::MockPermission();
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ EXPECT_TRUE(saMgr != nullptr);
+ MessageParcel data;
+ MessageParcel reply;
+ int32_t result = saMgr->ListSystemAbilityInner(data, reply);
+ EXPECT_EQ(result, ERR_FLATTEN_OBJECT);
+}
+
+/**
+ * @tc.name: ListSystemAbilityInner003
+ * @tc.desc: test ListSystemAbilityInner, list empty!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, ListSystemAbilityInner003, TestSize.Level3)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ EXPECT_TRUE(saMgr != nullptr);
+ MessageParcel data;
+ MessageParcel reply;
+ int32_t invalidDump = 1;
+ data.WriteInt32(invalidDump);
+ int32_t result = saMgr->ListSystemAbilityInner(data, reply);
+ EXPECT_EQ(result, ERR_NONE);
+}
+
+/**
+ * @tc.name: ListSystemAbilityInner004
+ * @tc.desc: test ListSystemAbilityInner, list no empty!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, ListSystemAbilityInner004, TestSize.Level1)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ SAInfo saInfo;
+ saMgr->abilityMap_[SAID] = saInfo;
+ EXPECT_TRUE(saMgr != nullptr);
+ MessageParcel data;
+ MessageParcel reply;
+ int32_t invalidDump = 1;
+ data.WriteInt32(invalidDump);
+ int32_t result = saMgr->ListSystemAbilityInner(data, reply);
+ EXPECT_EQ(result, ERR_NONE);
+}
+
+/**
+ * @tc.name: SubsSystemAbilityInner002
+ * @tc.desc: test SubsSystemAbilityInner, read systemAbilityId failed!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, SubsSystemAbilityInner002, TestSize.Level3)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ EXPECT_TRUE(saMgr != nullptr);
+ MessageParcel data;
+ MessageParcel reply;
+ data.WriteInt32(INVALID_SAID);
+ int32_t result = saMgr->SubsSystemAbilityInner(data, reply);
+ EXPECT_EQ(result, ERR_NULL_OBJECT);
+}
+
+/**
+ * @tc.name: SubsSystemAbilityInner003
+ * @tc.desc: test SubsSystemAbilityInner, read listener failed!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, SubsSystemAbilityInner003, TestSize.Level3)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ EXPECT_TRUE(saMgr != nullptr);
+ MessageParcel data;
+ MessageParcel reply;
+ data.WriteInt32(SAID);
+ int32_t result = saMgr->SubsSystemAbilityInner(data, reply);
+ EXPECT_EQ(result, ERR_NULL_OBJECT);
+}
+
+/**
+ * @tc.name: SubsSystemAbilityInner004
+ * @tc.desc: test SubsSystemAbilityInner!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, SubsSystemAbilityInner004, TestSize.Level1)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ sptr testAbility(new SaStatusChangeMock());
+ SAInfo saInfo;
+ saMgr->abilityMap_[SAID] = saInfo;
+ EXPECT_TRUE(saMgr != nullptr);
+ MessageParcel data;
+ MessageParcel reply;
+ data.WriteInt32(SAID);
+ data.WriteRemoteObject(testAbility);
+ int32_t result = saMgr->SubsSystemAbilityInner(data, reply);
+ EXPECT_EQ(result, ERR_OK);
+}
+
+/**
+ * @tc.name: UnSubsSystemAbilityInner002
+ * @tc.desc: test UnSubsSystemAbilityInner, read systemAbilityId failed!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, UnSubsSystemAbilityInner002, TestSize.Level3)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ EXPECT_TRUE(saMgr != nullptr);
+ MessageParcel data;
+ MessageParcel reply;
+ data.WriteInt32(INVALID_SAID);
+ int32_t result = saMgr->UnSubsSystemAbilityInner(data, reply);
+ EXPECT_EQ(result, ERR_NULL_OBJECT);
+}
+
+/**
+ * @tc.name: UnSubsSystemAbilityInner003
+ * @tc.desc: test UnSubsSystemAbilityInner, read listener failed!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, UnSubsSystemAbilityInner003, TestSize.Level3)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ EXPECT_TRUE(saMgr != nullptr);
+ MessageParcel data;
+ MessageParcel reply;
+ data.WriteInt32(SAID);
+ int32_t result = saMgr->UnSubsSystemAbilityInner(data, reply);
+ EXPECT_EQ(result, ERR_NULL_OBJECT);
+}
+
+/**
+ * @tc.name: UnSubsSystemAbilityInner004
+ * @tc.desc: test UnSubsSystemAbilityInner!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, UnSubsSystemAbilityInner004, TestSize.Level1)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ sptr testAbility(new SaStatusChangeMock());
+ SAInfo saInfo;
+ saMgr->abilityMap_[SAID] = saInfo;
+ EXPECT_TRUE(saMgr != nullptr);
+ MessageParcel data;
+ MessageParcel reply;
+ data.WriteInt32(SAID);
+ data.WriteRemoteObject(testAbility);
+ int32_t result = saMgr->UnSubsSystemAbilityInner(data, reply);
+ EXPECT_EQ(result, ERR_OK);
+}
+
+
+/**
+ * @tc.name: CheckRemtSystemAbilityInner002
+ * @tc.desc: test CheckRemtSystemAbilityInner, read systemAbilityId failed!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, CheckRemtSystemAbilityInner002, TestSize.Level3)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ EXPECT_TRUE(saMgr != nullptr);
+ MessageParcel data;
+ MessageParcel reply;
+ data.WriteInt32(INVALID_SAID);
+ int32_t result = saMgr->CheckRemtSystemAbilityInner(data, reply);
+ EXPECT_EQ(result, ERR_NULL_OBJECT);
+}
+
+/**
+ * @tc.name: CheckRemtSystemAbilityInner003
+ * @tc.desc: test CheckRemtSystemAbilityInner, read deviceId failed!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, CheckRemtSystemAbilityInner003, TestSize.Level3)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ EXPECT_TRUE(saMgr != nullptr);
+ MessageParcel data;
+ MessageParcel reply;
+ data.WriteInt32(SAID);
+ int32_t result = saMgr->CheckRemtSystemAbilityInner(data, reply);
+ EXPECT_EQ(result, ERR_FLATTEN_OBJECT);
+}
+
+/**
+ * @tc.name: CheckRemtSystemAbilityInner004
+ * @tc.desc: test CheckRemtSystemAbilityInner!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, CheckRemtSystemAbilityInner004, TestSize.Level1)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ EXPECT_TRUE(saMgr != nullptr);
+ MessageParcel data;
+ MessageParcel reply;
+ data.WriteInt32(SAID);
+ std::string deviceId = "test";
+ data.WriteString(deviceId);
+ int32_t result = saMgr->CheckRemtSystemAbilityInner(data, reply);
+ EXPECT_EQ(result, ERR_FLATTEN_OBJECT);
+}
+
+/**
+ * @tc.name: AddOndemandSystemAbilityInner002
+ * @tc.desc: test AddOndemandSystemAbilityInner, read systemAbilityId failed!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, AddOndemandSystemAbilityInner002, TestSize.Level3)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ EXPECT_TRUE(saMgr != nullptr);
+ MessageParcel data;
+ MessageParcel reply;
+ data.WriteInt32(INVALID_SAID);
+ int32_t result = saMgr->AddOndemandSystemAbilityInner(data, reply);
+ EXPECT_EQ(result, ERR_NULL_OBJECT);
+}
+
+/**
+ * @tc.name: AddOndemandSystemAbilityInner003
+ * @tc.desc: test AddOndemandSystemAbilityInner, read localName failed!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, AddOndemandSystemAbilityInner003, TestSize.Level3)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ EXPECT_TRUE(saMgr != nullptr);
+ MessageParcel data;
+ MessageParcel reply;
+ data.WriteInt32(SAID);
+ int32_t result = saMgr->AddOndemandSystemAbilityInner(data, reply);
+ EXPECT_EQ(result, ERR_NULL_OBJECT);
+}
+
+/**
+ * @tc.name: AddOndemandSystemAbilityInner004
+ * @tc.desc: test AddOndemandSystemAbilityInner!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, AddOndemandSystemAbilityInner004, TestSize.Level1)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ EXPECT_TRUE(saMgr != nullptr);
+ MessageParcel data;
+ MessageParcel reply;
+ data.WriteInt32(SAID);
+ u16string localManagerName = u"test";
+ data.WriteString16(localManagerName);
+ int32_t result = saMgr->AddOndemandSystemAbilityInner(data, reply);
+ EXPECT_EQ(result, ERR_INVALID_VALUE);
+}
+
+/**
+ * @tc.name: CheckSystemAbilityImmeInner001
+ * @tc.desc: test CheckSystemAbilityImmeInner, read systemAbilityId failed!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, CheckSystemAbilityImmeInner001, TestSize.Level3)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ EXPECT_TRUE(saMgr != nullptr);
+ MessageParcel data;
+ MessageParcel reply;
+ data.WriteInt32(INVALID_SAID);
+ int32_t result = saMgr->CheckSystemAbilityImmeInner(data, reply);
+ EXPECT_EQ(result, ERR_NULL_OBJECT);
+}
+
+/**
+ * @tc.name: CheckSystemAbilityImmeInner002
+ * @tc.desc: test CheckSystemAbilityImmeInner, read isExist failed!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, CheckSystemAbilityImmeInner002, TestSize.Level3)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ EXPECT_TRUE(saMgr != nullptr);
+ MessageParcel data;
+ MessageParcel reply;
+ data.WriteInt32(SAID);
+ int32_t result = saMgr->CheckSystemAbilityImmeInner(data, reply);
+ EXPECT_EQ(result, ERR_FLATTEN_OBJECT);
+}
+
+/**
+ * @tc.name: CheckSystemAbilityImmeInner003
+ * @tc.desc: test CheckSystemAbilityImmeInner, WriteRemoteObject failed!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, CheckSystemAbilityImmeInner003, TestSize.Level3)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ EXPECT_TRUE(saMgr != nullptr);
+ MessageParcel data;
+ MessageParcel reply;
+ data.WriteInt32(SAID);
+ data.WriteBool(false);
+ int32_t result = saMgr->CheckSystemAbilityImmeInner(data, reply);
+ EXPECT_EQ(result, ERR_FLATTEN_OBJECT);
+}
+
+/**
+ * @tc.name: CheckSystemAbilityImmeInner004
+ * @tc.desc: test CheckSystemAbilityImmeInner!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, CheckSystemAbilityImmeInner004, TestSize.Level1)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ EXPECT_TRUE(saMgr != nullptr);
+ sptr testAbility(new SaStatusChangeMock());
+ EXPECT_TRUE(testAbility != nullptr);
+ SAInfo saInfo;
+ saInfo.remoteObj = testAbility;
+ saMgr->abilityMap_[SAID] = saInfo;
+ MessageParcel data;
+ MessageParcel reply;
+ data.WriteInt32(SAID);
+ data.WriteBool(false);
+ int32_t result = saMgr->CheckSystemAbilityImmeInner(data, reply);
+ EXPECT_EQ(result, ERR_NONE);
+}
+
+/**
+ * @tc.name: UnmarshalingSaExtraProp001
+ * @tc.desc: test UnmarshalingSaExtraProp, read isDistributed failed!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, UnmarshalingSaExtraProp001, TestSize.Level3)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ EXPECT_TRUE(saMgr != nullptr);
+ MessageParcel data;
+ SystemAbilityManager::SAExtraProp extraProp;
+ int32_t result = saMgr->UnmarshalingSaExtraProp(data, extraProp);
+ EXPECT_EQ(result, ERR_FLATTEN_OBJECT);
+}
+
+/**
+ * @tc.name: UnmarshalingSaExtraProp002
+ * @tc.desc: test UnmarshalingSaExtraProp, UnmarshalingSaExtraProp dumpFlags failed!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, UnmarshalingSaExtraProp002, TestSize.Level3)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ EXPECT_TRUE(saMgr != nullptr);
+ MessageParcel data;
+ SystemAbilityManager::SAExtraProp extraProp;
+ data.WriteBool(false);
+ int32_t result = saMgr->UnmarshalingSaExtraProp(data, extraProp);
+ EXPECT_EQ(result, ERR_FLATTEN_OBJECT);
+}
+
+/**
+ * @tc.name: UnmarshalingSaExtraProp003
+ * @tc.desc: test UnmarshalingSaExtraProp!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, UnmarshalingSaExtraProp003, TestSize.Level1)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ EXPECT_TRUE(saMgr != nullptr);
+ MessageParcel data;
+ SystemAbilityManager::SAExtraProp extraProp;
+ bool isExist = false;
+ int32_t dumpFlags = 0;
+ std::u16string capability = u"capability";
+ std::u16string permission = u"permission";
+ data.WriteBool(isExist);
+ data.WriteInt32(dumpFlags);
+ data.WriteString16(capability);
+ data.WriteString16(permission);
+ int32_t result = saMgr->UnmarshalingSaExtraProp(data, extraProp);
+ EXPECT_EQ(result, ERR_OK);
+}
+
+
+/**
+ * @tc.name: AddSystemAbilityInner002
+ * @tc.desc: test AddSystemAbilityInner, read systemAbilityId failed!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, AddSystemAbilityInner002, TestSize.Level3)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ EXPECT_TRUE(saMgr != nullptr);
+ MessageParcel data;
+ MessageParcel reply;
+ data.WriteInt32(INVALID_SAID);
+ int32_t result = saMgr->AddSystemAbilityInner(data, reply);
+ EXPECT_EQ(result, ERR_NULL_OBJECT);
+}
+
+/**
+ * @tc.name: AddSystemAbilityInner003
+ * @tc.desc: test AddSystemAbilityInner, readParcelable failed!!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, AddSystemAbilityInner003, TestSize.Level3)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ EXPECT_TRUE(saMgr != nullptr);
+ MessageParcel data;
+ MessageParcel reply;
+ data.WriteInt32(SAID);
+ int32_t result = saMgr->AddSystemAbilityInner(data, reply);
+ EXPECT_EQ(result, ERR_NULL_OBJECT);
+}
+
+/**
+ * @tc.name: AddSystemAbilityInner004
+ * @tc.desc: test AddSystemAbilityInner, UnmarshalingSaExtraProp failed!!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, AddSystemAbilityInner004, TestSize.Level3)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ sptr testAbility(new SaStatusChangeMock());
+ EXPECT_TRUE(saMgr != nullptr);
+ MessageParcel data;
+ MessageParcel reply;
+ data.WriteInt32(SAID);
+ data.WriteRemoteObject(testAbility);
+ int32_t result = saMgr->AddSystemAbilityInner(data, reply);
+ EXPECT_EQ(result, ERR_FLATTEN_OBJECT);
+}
+
+/**
+ * @tc.name: AddSystemAbilityInner005
+ * @tc.desc: test AddSystemAbilityInner!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, AddSystemAbilityInner005, TestSize.Level1)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ sptr testAbility(new SaStatusChangeMock());
+ EXPECT_TRUE(saMgr != nullptr);
+ SystemAbilityManager::SAExtraProp extraProp;
+ bool isExist = false;
+ int32_t dumpFlags = 0;
+ std::u16string capability = u"capability";
+ std::u16string permission = u"permission";
+ MessageParcel data;
+ MessageParcel reply;
+ data.WriteInt32(SAID);
+ data.WriteRemoteObject(testAbility);
+ data.WriteBool(isExist);
+ data.WriteInt32(dumpFlags);
+ data.WriteString16(capability);
+ data.WriteString16(permission);
+ int32_t result = saMgr->AddSystemAbilityInner(data, reply);
+ EXPECT_EQ(result, ERR_OK);
+}
+
+/**
+ * @tc.name: GetSystemAbilityInner001
+ * @tc.desc: test GetSystemAbilityInner, read systemAbilityId failed!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, GetSystemAbilityInner001, TestSize.Level3)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ EXPECT_TRUE(saMgr != nullptr);
+ MessageParcel data;
+ MessageParcel reply;
+ int32_t result = saMgr->GetSystemAbilityInner(data, reply);
+ EXPECT_EQ(result, ERR_NULL_OBJECT);
+}
+
+/**
+ * @tc.name: GetSystemAbilityInner002
+ * @tc.desc: test GetSystemAbilityInner, GetSystemAbilityInner write reply failed!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, GetSystemAbilityInner002, TestSize.Level3)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ EXPECT_TRUE(saMgr != nullptr);
+ MessageParcel data;
+ MessageParcel reply;
+ data.WriteInt32(SAID);
+ saMgr->abilityMap_.clear();
+ int32_t result = saMgr->GetSystemAbilityInner(data, reply);
+ EXPECT_EQ(result, ERR_FLATTEN_OBJECT);
+}
+
+/**
+ * @tc.name: GetSystemAbilityInner003
+ * @tc.desc: test GetSystemAbilityInner!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, GetSystemAbilityInner003, TestSize.Level1)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ EXPECT_TRUE(saMgr != nullptr);
+ sptr testAbility(new SaStatusChangeMock());
+ MessageParcel data;
+ MessageParcel reply;
+ SAInfo saInfo;
+ saInfo.remoteObj = testAbility;
+ saMgr->abilityMap_[SAID] = saInfo;
+ data.WriteInt32(SAID);
+ int32_t result = saMgr->GetSystemAbilityInner(data, reply);
+ EXPECT_EQ(result, ERR_NONE);
+}
+
+/**
+ * @tc.name: CheckSystemAbilityInner001
+ * @tc.desc: test CheckSystemAbilityInner, read systemAbilityId failed!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, CheckSystemAbilityInner001, TestSize.Level3)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ EXPECT_TRUE(saMgr != nullptr);
+ MessageParcel data;
+ MessageParcel reply;
+ int32_t result = saMgr->CheckSystemAbilityInner(data, reply);
+ EXPECT_EQ(result, ERR_NULL_OBJECT);
+}
+
+/**
+ * @tc.name: CheckSystemAbilityInner002
+ * @tc.desc: test CheckSystemAbilityInner!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, CheckSystemAbilityInner002, TestSize.Level3)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ EXPECT_TRUE(saMgr != nullptr);
+ MessageParcel data;
+ MessageParcel reply;
+ data.WriteInt32(SAID);
+ saMgr->abilityMap_.clear();
+ int32_t result = saMgr->CheckSystemAbilityInner(data, reply);
+ EXPECT_EQ(result, ERR_FLATTEN_OBJECT);
+}
+
+/**
+ * @tc.name: CheckSystemAbilityInner003
+ * @tc.desc: test CheckSystemAbilityInner!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, CheckSystemAbilityInner003, TestSize.Level1)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ EXPECT_TRUE(saMgr != nullptr);
+ sptr testAbility(new SaStatusChangeMock());
+ MessageParcel data;
+ MessageParcel reply;
+ SAInfo saInfo;
+ saInfo.remoteObj = testAbility;
+ saMgr->abilityMap_[SAID] = saInfo;
+ data.WriteInt32(SAID);
+ int32_t result = saMgr->CheckSystemAbilityInner(data, reply);
+ EXPECT_EQ(result, ERR_NONE);
+}
+
+/**
+ * @tc.name: RemoveSystemAbilityInner002
+ * @tc.desc: test RemoveSystemAbilityInner, read systemAbilityId failed!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, RemoveSystemAbilityInner002, TestSize.Level3)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ EXPECT_TRUE(saMgr != nullptr);
+ MessageParcel data;
+ MessageParcel reply;
+ data.WriteInt32(INVALID_SAID);
+ int32_t result = saMgr->RemoveSystemAbilityInner(data, reply);
+ EXPECT_EQ(result, ERR_NULL_OBJECT);
+}
+
+/**
+ * @tc.name: RemoveSystemAbilityInner003
+ * @tc.desc: test RemoveSystemAbilityInner, RemoveSystemability not found!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, RemoveSystemAbilityInner003, TestSize.Level3)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ EXPECT_TRUE(saMgr != nullptr);
+ MessageParcel data;
+ MessageParcel reply;
+ data.WriteInt32(SAID);
+ saMgr->abilityMap_.clear();
+ int32_t result = saMgr->RemoveSystemAbilityInner(data, reply);
+ EXPECT_EQ(result, ERR_INVALID_VALUE);
+}
+
+/**
+ * @tc.name: AddSystemProcessInner002
+ * @tc.desc: test AddSystemProcessInner, read process name failed!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, AddSystemProcessInner002, TestSize.Level3)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ EXPECT_TRUE(saMgr != nullptr);
+ MessageParcel data;
+ MessageParcel reply;
+ int32_t result = saMgr->AddSystemProcessInner(data, reply);
+ EXPECT_EQ(result, ERR_NULL_OBJECT);
+}
+
+/**
+ * @tc.name: AddSystemProcessInner003
+ * @tc.desc: test AddSystemProcessInner readParcelable failed!!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, AddSystemProcessInner003, TestSize.Level3)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ EXPECT_TRUE(saMgr != nullptr);
+ MessageParcel data;
+ MessageParcel reply;
+ std::u16string procName = u"test";
+ data.WriteString16(procName);
+ int32_t result = saMgr->AddSystemProcessInner(data, reply);
+ EXPECT_EQ(result, ERR_NULL_OBJECT);
+}
+
+/**
+ * @tc.name: AddSystemProcessInner004
+ * @tc.desc: test AddSystemProcessInner!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, AddSystemProcessInner004, TestSize.Level1)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ EXPECT_TRUE(saMgr != nullptr);
+ sptr testAbility(new SaStatusChangeMock());
+ MessageParcel data;
+ MessageParcel reply;
+ std::u16string procName = u"test";
+ data.WriteString16(procName);
+ data.WriteRemoteObject(testAbility);
+ int32_t result = saMgr->AddSystemProcessInner(data, reply);
+ EXPECT_EQ(result, ERR_OK);
+}
+
+/**
+ * @tc.name: LoadRemoteSystemAbilityInner001
+ * @tc.desc: test LoadRemoteSystemAbilityInner, systemAbilityId invalid!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, LoadRemoteSystemAbilityInner001, TestSize.Level3)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ EXPECT_TRUE(saMgr != nullptr);
+ MessageParcel data;
+ MessageParcel reply;
+ int32_t result = saMgr->LoadRemoteSystemAbilityInner(data, reply);
+ EXPECT_EQ(result, ERR_INVALID_VALUE);
+}
+
+/**
+ * @tc.name: LoadRemoteSystemAbilityInner002
+ * @tc.desc: test LoadRemoteSystemAbilityInner, LoadRemoteSystemAbilityInner read deviceId failed!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, LoadRemoteSystemAbilityInner002, TestSize.Level3)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ EXPECT_TRUE(saMgr != nullptr);
+ MessageParcel data;
+ MessageParcel reply;
+ data.WriteInt32(SAID);
+ int32_t result = saMgr->LoadRemoteSystemAbilityInner(data, reply);
+ EXPECT_EQ(result, ERR_INVALID_VALUE);
+}
+
+/**
+ * @tc.name: LoadRemoteSystemAbilityInner003
+ * @tc.desc: test LoadRemoteSystemAbilityInner, read callback failed!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, LoadRemoteSystemAbilityInner003, TestSize.Level3)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ EXPECT_TRUE(saMgr != nullptr);
+ MessageParcel data;
+ MessageParcel reply;
+ data.WriteInt32(SAID);
+ string deviceId = "test";
+ data.WriteString(deviceId);
+ int32_t result = saMgr->LoadRemoteSystemAbilityInner(data, reply);
+ EXPECT_EQ(result, ERR_INVALID_VALUE);
+}
+
+/**
+ * @tc.name: LoadRemoteSystemAbilityInner004
+ * @tc.desc: test LoadRemoteSystemAbilityInner!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, LoadRemoteSystemAbilityInner004, TestSize.Level1)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ sptr callback = new SystemAbilityLoadCallbackMock();
+ EXPECT_TRUE(saMgr != nullptr);
+ MessageParcel data;
+ MessageParcel reply;
+ data.WriteInt32(SAID);
+ string deviceId = "test";
+ data.WriteString(deviceId);
+ data.WriteRemoteObject(callback);
+ int32_t result = saMgr->LoadRemoteSystemAbilityInner(data, reply);
+ EXPECT_EQ(result, ERR_NO_INIT);
+}
+
+/**
+ * @tc.name: InitSaProfile001
+ * @tc.desc: test InitSaProfile! InitSaProfile.
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, InitSaProfile001, TestSize.Level1)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ auto runner = AppExecFwk::EventRunner::Create("workHandler");
+ saMgr->workHandler_ = make_shared(runner);
+ saMgr->InitSaProfile();
+ EXPECT_NE(saMgr->workHandler_, nullptr);
+}
+
+/**
+ * @tc.name: InitSaProfile002
+ * @tc.desc: test InitSaProfile! parseHandler_ not init!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, InitSaProfile002, TestSize.Level3)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ saMgr->workHandler_ = nullptr;
+ saMgr->InitSaProfile();
+ EXPECT_EQ(saMgr->workHandler_, nullptr);
+}
+
+/**
+ * @tc.name: GetSaProfile001
+ * @tc.desc: test GetSaProfile! return true
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, GetSaProfile001, TestSize.Level3)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ SaProfile saProfilein;
+ SaProfile SaProfileout;
+ saMgr->saProfileMap_[SAID] = saProfilein;
+ bool res = saMgr->GetSaProfile(SAID, SaProfileout);
+ saMgr->saProfileMap_.clear();
+ EXPECT_EQ(res, true);
+}
+
+/**
+ * @tc.name: GetSystemAbility001
+ * @tc.desc: test GetSystemAbility! return nullptr
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, GetSystemAbility001, TestSize.Level3)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ sptr res = saMgr->GetSystemAbility(INVALID_SAID);
+ EXPECT_EQ(res, nullptr);
+}
+
+/**
+ * @tc.name: GetSystemAbility002
+ * @tc.desc: test GetSystemAbility! return nullptr
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, GetSystemAbility002, TestSize.Level3)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ string deviceId = "test";
+ sptr res = saMgr->GetSystemAbility(SAID, deviceId);
+ EXPECT_EQ(res, nullptr);
+}
+
+/**
+ * @tc.name: GetSystemAbilityFromRemote001
+ * @tc.desc: test GetSystemAbilityFromRemote! GetSystemAbilityFromRemote invalid!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, GetSystemAbilityFromRemote001, TestSize.Level3)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ sptr res = saMgr->GetSystemAbilityFromRemote(INVALID_SAID);
+ EXPECT_EQ(res, nullptr);
+}
+
+/**
+ * @tc.name: GetSystemAbilityFromRemote002
+ * @tc.desc: test GetSystemAbilityFromRemote! not found service!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, GetSystemAbilityFromRemote002, TestSize.Level3)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ sptr res = saMgr->GetSystemAbilityFromRemote(SAID);
+ EXPECT_EQ(res, nullptr);
+}
+
+/**
+ * @tc.name: GetSystemAbilityFromRemote003
+ * @tc.desc: test GetSystemAbilityFromRemote! service not distributed!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, GetSystemAbilityFromRemote003, TestSize.Level3)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ SAInfo saInfo;
+ saInfo.isDistributed = false;
+ saMgr->abilityMap_[SAID] = saInfo;
+ sptr res = saMgr->GetSystemAbilityFromRemote(SAID);
+ saMgr->abilityMap_.clear();
+ EXPECT_EQ(res, nullptr);
+}
+
+/**
+ * @tc.name: GetSystemAbilityFromRemote004
+ * @tc.desc: test GetSystemAbilityFromRemote! GetSystemAbilityFromRemote found service!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, GetSystemAbilityFromRemote004, TestSize.Level3)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ SAInfo saInfo;
+ saInfo.isDistributed = true;
+ saInfo.remoteObj = saMgr;
+ saMgr->abilityMap_[SAID] = saInfo;
+ sptr res = saMgr->GetSystemAbilityFromRemote(SAID);
+ saMgr->abilityMap_.clear();
+ EXPECT_NE(res, nullptr);
+}
+
+/**
+ * @tc.name: CheckSystemAbility001
+ * @tc.desc: test CheckSystemAbility! CheckSystemAbility invalid!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, CheckSystemAbility001, TestSize.Level3)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ sptr res = saMgr->CheckSystemAbility(INVALID_SAID);
+ EXPECT_EQ(res, nullptr);
+}
+
+/**
+ * @tc.name: CheckSystemAbility002
+ * @tc.desc: test CheckSystemAbility! found service!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, CheckSystemAbility002, TestSize.Level3)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ SAInfo saInfo;
+ saInfo.remoteObj = saMgr;
+ saMgr->abilityMap_[SAID] = saInfo;
+ sptr res = saMgr->CheckSystemAbility(SAID);
+ saMgr->abilityMap_.clear();
+ EXPECT_NE(res, nullptr);
+}
+
+/**
+ * @tc.name: CheckDistributedPermission001
+ * @tc.desc: test CheckDistributedPermission! return true!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, CheckDistributedPermission001, TestSize.Level1)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ bool res = saMgr->CheckDistributedPermission();
+ EXPECT_EQ(res, true);
+}
+
+/**
+ * @tc.name: NotifySystemAbilityChanged001
+ * @tc.desc: test NotifySystemAbilityChanged! listener null pointer!!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, NotifySystemAbilityChanged001, TestSize.Level3)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ string deviceId = "test";
+ int32_t code = 1;
+ saMgr->NotifySystemAbilityChanged(SAID, deviceId, code, nullptr);
+ EXPECT_NE(saMgr, nullptr);
+}
+
+/**
+ * @tc.name: NotifySystemAbilityChanged002
+ * @tc.desc: test NotifySystemAbilityChanged!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, NotifySystemAbilityChanged002, TestSize.Level1)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ sptr testAbility(new SaStatusChangeMock());
+ string deviceId = "test";
+ int32_t code = 1;
+ saMgr->NotifySystemAbilityChanged(SAID, deviceId, code, testAbility);
+ EXPECT_NE(saMgr, nullptr);
+}
+
+/**
+ * @tc.name: FindSystemAbilityNotify001
+ * @tc.desc: test FindSystemAbilityNotify!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, FindSystemAbilityNotify001, TestSize.Level1)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ int32_t pid = 1;
+ saMgr->listenerMap_[SAID].push_back(make_pair(nullptr, pid));
+ string deviceId = "test";
+ int32_t code = 1;
+ bool res = saMgr->FindSystemAbilityNotify(SAID, deviceId, code);
+ saMgr->listenerMap_.clear();
+ EXPECT_EQ(res, ERR_OK);
+}
+
+/**
+ * @tc.name: FindSystemAbilityNotify002
+ * @tc.desc: test FindSystemAbilityNotify!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, FindSystemAbilityNotify002, TestSize.Level1)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ saMgr->listenerMap_.clear();
+ string deviceId = "test";
+ int32_t code = 1;
+ bool res = saMgr->FindSystemAbilityNotify(SAID, deviceId, code);
+ saMgr->listenerMap_.clear();
+ EXPECT_EQ(res, ERR_OK);
+}
+
+/**
+ * @tc.name: StartOnDemandAbility001
+ * @tc.desc: test StartOnDemandAbility!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, StartOnDemandAbility001, TestSize.Level3)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ u16string procName = u"test";
+ saMgr->StartOnDemandAbility(procName, SAID);
+ EXPECT_NE(saMgr, nullptr);
+}
+
+/**
+ * @tc.name: StartOnDemandAbility002
+ * @tc.desc: test StartOnDemandAbility!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, StartOnDemandAbility002, TestSize.Level3)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ u16string procName = u"test";
+ SystemAbilityManager::AbilityItem abilityItem;
+ abilityItem.state = SystemAbilityManager::AbilityState::STARTING;
+ saMgr->startingAbilityMap_[SAID] = abilityItem;
+ saMgr->StartOnDemandAbility(procName, SAID);
+ saMgr->startingAbilityMap_.clear();
+ EXPECT_NE(saMgr, nullptr);
+}
+
+/**
+ * @tc.name: StartOnDemandAbilityInner001
+ * @tc.desc: test StartOnDemandAbilityInner!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, StartOnDemandAbilityInner001, TestSize.Level3)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ u16string procName = u"test";
+ SystemAbilityManager::AbilityItem abilityItem;
+ abilityItem.state = SystemAbilityManager::AbilityState::STARTING;
+ saMgr->StartOnDemandAbilityInner(procName, SAID, abilityItem);
+ EXPECT_EQ(abilityItem.state, SystemAbilityManager::AbilityState::STARTING);
+}
+
+/**
+ * @tc.name: StartOnDemandAbilityInner002
+ * @tc.desc: test StartOnDemandAbilityInner, get process fail!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, StartOnDemandAbilityInner002, TestSize.Level3)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ u16string procName = u"";
+ SystemAbilityManager::AbilityItem abilityItem;
+ abilityItem.state = SystemAbilityManager::AbilityState::INIT;
+ saMgr->StartOnDemandAbilityInner(procName, SAID, abilityItem);
+ EXPECT_EQ(abilityItem.state, SystemAbilityManager::AbilityState::INIT);
+}
+
+/**
+ * @tc.name: AddOnDemandSystemAbilityInfo001
+ * @tc.desc: test AddOnDemandSystemAbilityInfo, map size error!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, AddOnDemandSystemAbilityInfo001, TestSize.Level3)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ u16string procName = u"test";
+ int maxService = 1002;
+ for (int tempSaid = 1; tempSaid < maxService; tempSaid++) {
+ saMgr->onDemandAbilityMap_[tempSaid] = procName;
+ }
+ int32_t res = saMgr->AddOnDemandSystemAbilityInfo(SAID, procName);
+ saMgr->onDemandAbilityMap_.clear();
+ EXPECT_EQ(res, ERR_INVALID_VALUE);
+}
+
+/**
+ * @tc.name: AddOnDemandSystemAbilityInfo002
+ * @tc.desc: test AddOnDemandSystemAbilityInfo, onDemand systemAbilityId!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, AddOnDemandSystemAbilityInfo002, TestSize.Level3)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ u16string procName = u"test";
+ saMgr->systemProcessMap_[procName] = saMgr;
+ int32_t res = saMgr->AddOnDemandSystemAbilityInfo(SAID, procName);
+ saMgr->systemProcessMap_.clear();
+ EXPECT_EQ(res, ERR_OK);
+}
+
+/**
+ * @tc.name: AddOnDemandSystemAbilityInfo003
+ * @tc.desc: test AddOnDemandSystemAbilityInfo!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, AddOnDemandSystemAbilityInfo003, TestSize.Level3)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ u16string procName = u"test";
+ saMgr->systemProcessMap_[procName] = saMgr;
+ SystemAbilityManager::AbilityItem abilityItem;
+ abilityItem.state = SystemAbilityManager::AbilityState::STARTING;
+ saMgr->startingAbilityMap_[SAID] = abilityItem;
+ int32_t res = saMgr->AddOnDemandSystemAbilityInfo(SAID, procName);
+ saMgr->systemProcessMap_.clear();
+ saMgr->startingAbilityMap_.clear();
+ EXPECT_EQ(res, ERR_OK);
+}
+
+/**
+ * @tc.name: AddOnDemandSystemAbilityInfo004
+ * @tc.desc: test AddOnDemandSystemAbilityInfo!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, AddOnDemandSystemAbilityInfo004, TestSize.Level1)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ u16string procName = u"test";
+ saMgr->systemProcessMap_[procName] = saMgr;
+ SystemAbilityManager::AbilityItem abilityItem;
+ abilityItem.state = SystemAbilityManager::AbilityState::STARTING;
+ auto runner = AppExecFwk::EventRunner::Create("workHandler");
+ saMgr->workHandler_ = make_shared(runner);
+ saMgr->startingAbilityMap_[SAID] = abilityItem;
+ int32_t res = saMgr->AddOnDemandSystemAbilityInfo(SAID, procName);
+ saMgr->systemProcessMap_.clear();
+ saMgr->startingAbilityMap_.clear();
+ EXPECT_EQ(res, ERR_OK);
+}
+
+/**
+ * @tc.name: StartOnDemandAbility003
+ * @tc.desc: test StartOnDemandAbility!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, StartOnDemandAbility003, TestSize.Level3)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ u16string procName = u"test";
+ saMgr->onDemandAbilityMap_[SAID] = procName;
+ int32_t res = saMgr->StartOnDemandAbility(SAID);
+ saMgr->onDemandAbilityMap_.clear();
+ EXPECT_EQ(res, ERR_OK);
+}
+
+/**
+ * @tc.name: CheckSystemAbility003
+ * @tc.desc: test CheckSystemAbility!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, CheckSystemAbility003, TestSize.Level3)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ bool isExist = false;
+ sptr res = saMgr->CheckSystemAbility(INVALID_SAID, isExist);
+ EXPECT_EQ(res, nullptr);
+}
+
+/**
+ * @tc.name: CheckSystemAbility004
+ * @tc.desc: test CheckSystemAbility!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, CheckSystemAbility004, TestSize.Level1)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ SAInfo saInfo;
+ saInfo.remoteObj = saMgr;
+ saMgr->abilityMap_[SAID] = saInfo;
+ bool isExist = false;
+ sptr res = saMgr->CheckSystemAbility(SAID, isExist);
+ saMgr->abilityMap_.clear();
+ EXPECT_NE(res, nullptr);
+}
+
+/**
+ * @tc.name: CheckSystemAbility005
+ * @tc.desc: test CheckSystemAbility!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, CheckSystemAbility005, TestSize.Level3)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ bool isExist = false;
+ sptr res = saMgr->CheckSystemAbility(SAID, isExist);
+ EXPECT_EQ(res, nullptr);
+}
+
+/**
+ * @tc.name: CheckSystemAbility006
+ * @tc.desc: test CheckSystemAbility!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, CheckSystemAbility006, TestSize.Level3)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ SystemAbilityManager::AbilityItem abilityItem;
+ abilityItem.state = SystemAbilityManager::AbilityState::STARTING;
+ saMgr->startingAbilityMap_[SAID] = abilityItem;
+ bool isExist = false;
+ sptr res = saMgr->CheckSystemAbility(SAID, isExist);
+ saMgr->startingAbilityMap_.clear();
+ EXPECT_EQ(isExist, true);
+}
+
+/**
+ * @tc.name: CheckSystemAbility007
+ * @tc.desc: test CheckSystemAbility!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, CheckSystemAbility007, TestSize.Level3)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ SystemAbilityManager::AbilityItem abilityItem;
+ abilityItem.state = SystemAbilityManager::AbilityState::INIT;
+ saMgr->startingAbilityMap_[SAID] = abilityItem;
+ u16string proName = u"test";
+ saMgr->onDemandAbilityMap_[SAID] = proName;
+ bool isExist = false;
+ sptr res = saMgr->CheckSystemAbility(SAID, isExist);
+ saMgr->startingAbilityMap_.clear();
+ saMgr->onDemandAbilityMap_.clear();
+ EXPECT_EQ(isExist, true);
+}
+
+/**
+ * @tc.name: RemoveSystemAbility001
+ * @tc.desc: test RemoveSystemAbility, RemoveSystemAbility systemAbilityId!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, RemoveSystemAbility001, TestSize.Level3)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ int32_t res = saMgr->RemoveSystemAbility(INVALID_SAID);
+ EXPECT_EQ(res, ERR_INVALID_VALUE);
+}
+
+/**
+ * @tc.name: RemoveSystemAbility002
+ * @tc.desc: test RemoveSystemAbility, RemoveSystemAbility not found!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, RemoveSystemAbility002, TestSize.Level3)
+{
+ sptr saMgr = SystemAbilityManager::GetInstance();
+ int32_t res = saMgr->RemoveSystemAbility(SAID);
+ EXPECT_EQ(res, ERR_INVALID_VALUE);
+}
+
+/**
+ * @tc.name: RemoveSystemAbility003
+ * @tc.desc: test RemoveSystemAbility, ability nullptr!
+ * @tc.type: FUNC
+ */
+HWTEST_F(SystemAbilityMgrStubTest, RemoveSystemAbility003, TestSize.Level3)
+{
+ sptr