已合并
fix bug #20206
已合并
xuzheheng创建于 18 天前
37 个文件变更+25-945
@@ -163,7 +163,6 @@ Provides pluggable behavior for ability starts:
163 163 
164| Interceptor | Purpose |164| Interceptor | Purpose |
165|-------------|---------|165|-------------|---------|
166-| `StartOtherAppInterceptor` | Control starting other applications |
167| `EcologicalRuleInterceptor` | Enforce ecosystem rules |166| `EcologicalRuleInterceptor` | Enforce ecosystem rules |
168| `KioskInterceptor` | Kiosk mode enforcement |167| `KioskInterceptor` | Kiosk mode enforcement |
169| `ScreenUnlockInterceptor` | Screen lock state checks |168| `ScreenUnlockInterceptor` | Screen lock state checks |
@@ -72,7 +72,6 @@ abilityms_files = [
72 "src/interceptor/ecological_rule_interceptor.cpp",72 "src/interceptor/ecological_rule_interceptor.cpp",
73 "src/interceptor/extension_control_interceptor.cpp",73 "src/interceptor/extension_control_interceptor.cpp",
74 "src/interceptor/screen_unlock_interceptor.cpp",74 "src/interceptor/screen_unlock_interceptor.cpp",
75- "src/interceptor/start_other_app_interceptor.cpp",
76 "src/interceptor/kiosk_interceptor.cpp",75 "src/interceptor/kiosk_interceptor.cpp",
77 "src/window_focus_changed_listener.cpp",76 "src/window_focus_changed_listener.cpp",
78 "src/window_visibility_changed_listener.cpp",77 "src/window_visibility_changed_listener.cpp",
@@ -51,8 +51,6 @@ public:
51 * Excute the DoProcess of the interceptors.51 * Excute the DoProcess of the interceptors.
52 */52 */
53 ErrCode DoProcess(const AbilityInterceptorParam &param);53 ErrCode DoProcess(const AbilityInterceptorParam &param);
54- 
55- void SetTaskHandler(std::shared_ptr<AAFwk::TaskHandlerWrap> taskHandler);
56private:54private:
57 InterceptorMap GetInterceptorMapCopy();55 InterceptorMap GetInterceptorMapCopy();
58private:56private:
@@ -19,7 +19,6 @@
19#include "ability_info.h"19#include "ability_info.h"
20#include "ability_manager_errors.h"20#include "ability_manager_errors.h"
21#include "start_options.h"21#include "start_options.h"
22-#include "task_handler_wrap.h"
23#include "want.h"22#include "want.h"
24 23 
25namespace OHOS {24namespace OHOS {
@@ -61,11 +60,6 @@ public:
61 * Excute interception processing.60 * Excute interception processing.
62 */61 */
63 virtual ErrCode DoProcess(const AbilityInterceptorParam &param) = 0;62 virtual ErrCode DoProcess(const AbilityInterceptorParam &param) = 0;
64- 
65- /**
66- * Set handler for async task executing.
67- */
68- virtual void SetTaskHandler(std::shared_ptr<AAFwk::TaskHandlerWrap> taskHandler) {};
69};63};
70} // namespace AAFwk64} // namespace AAFwk
71} // namespace OHOS65} // namespace OHOS
@@ -36,10 +36,6 @@ public:
36 36 
37 ErrCode Execute();37 ErrCode Execute();
38 ErrCode Execute(AbilityRequest& abilityRequest, int32_t validUserId);38 ErrCode Execute(AbilityRequest& abilityRequest, int32_t validUserId);
39- virtual void SetTaskHandler(std::shared_ptr<AAFwk::TaskHandlerWrap> taskHandler) override
40- {
41- return;
42- };
43 39 
44private:40private:
45 std::function<bool()> shouldBlockFunc_;41 std::function<bool()> shouldBlockFunc_;
@@ -28,10 +28,6 @@ public:
28 ControlInterceptor() = default;28 ControlInterceptor() = default;
29 ~ControlInterceptor() = default;29 ~ControlInterceptor() = default;
30 ErrCode DoProcess(const AbilityInterceptorParam &param) override;30 ErrCode DoProcess(const AbilityInterceptorParam &param) override;
31- virtual void SetTaskHandler(std::shared_ptr<AAFwk::TaskHandlerWrap> taskHandler) override
32- {
33- return;
34- };
35private:31private:
36 bool CheckControl(const Want &want, int32_t userId, AppExecFwk::AppRunningControlRuleResult &controlRule);32 bool CheckControl(const Want &want, int32_t userId, AppExecFwk::AppRunningControlRuleResult &controlRule);
37};33};
@@ -25,10 +25,6 @@ public:
25 CrowdTestInterceptor() = default;25 CrowdTestInterceptor() = default;
26 ~CrowdTestInterceptor() = default;26 ~CrowdTestInterceptor() = default;
27 ErrCode DoProcess(const AbilityInterceptorParam &param) override;27 ErrCode DoProcess(const AbilityInterceptorParam &param) override;
28- virtual void SetTaskHandler(std::shared_ptr<AAFwk::TaskHandlerWrap> taskHandler) override
29- {
30- return;
31- };
32private:28private:
33 bool CheckCrowdtest(const Want &want, int32_t userId);29 bool CheckCrowdtest(const Want &want, int32_t userId);
34};30};
@@ -19,6 +19,7 @@
19#include "ability_interceptor_interface.h"19#include "ability_interceptor_interface.h"
20 20 
21#include "disposed_observer.h"21#include "disposed_observer.h"
22+#include "task_handler_wrap.h"
22#include "task_utils_wrap.h"23#include "task_utils_wrap.h"
23 24 
24namespace OHOS {25namespace OHOS {
@@ -29,15 +30,11 @@ namespace AAFwk {
29class DisposedRuleInterceptor : public IAbilityInterceptor,30class DisposedRuleInterceptor : public IAbilityInterceptor,
30 public std::enable_shared_from_this<DisposedRuleInterceptor> {31 public std::enable_shared_from_this<DisposedRuleInterceptor> {
31public:32public:
32- DisposedRuleInterceptor() = default;33+ explicit DisposedRuleInterceptor(std::shared_ptr<AAFwk::TaskHandlerWrap> taskHandler = nullptr);
33 ~DisposedRuleInterceptor() = default;34 ~DisposedRuleInterceptor() = default;
34 static std::string GenerateTimeoutTaskName(int32_t uid);35 static std::string GenerateTimeoutTaskName(int32_t uid);
35 static std::string GenerateEventTaskName(int32_t uid);36 static std::string GenerateEventTaskName(int32_t uid);
36 ErrCode DoProcess(const AbilityInterceptorParam &param) override;37 ErrCode DoProcess(const AbilityInterceptorParam &param) override;
37- void SetTaskHandler(std::shared_ptr<AAFwk::TaskHandlerWrap> taskHandler) override
38- {
39- taskHandler_ = taskHandler;
40- };
41 void UnregisterObserver(int32_t uid);38 void UnregisterObserver(int32_t uid);
42private:39private:
43 bool ValidateNonBlockRule(const Want &want, const AppExecFwk::DisposedRule &disposedRule);40 bool ValidateNonBlockRule(const Want &want, const AppExecFwk::DisposedRule &disposedRule);
@@ -37,10 +37,6 @@ public:
37 ~EcologicalRuleInterceptor() = default;37 ~EcologicalRuleInterceptor() = default;
38 ErrCode DoProcess(const AbilityInterceptorParam &param) override;38 ErrCode DoProcess(const AbilityInterceptorParam &param) override;
39 bool DoProcess(Want &want, int32_t userId);39 bool DoProcess(Want &want, int32_t userId);
40- virtual void SetTaskHandler(std::shared_ptr<AAFwk::TaskHandlerWrap> taskHandler) override
41- {
42- return;
43- };
44 ErrCode QueryAtomicServiceStartupRule(Want &want, sptr<IRemoteObject> callerToken,40 ErrCode QueryAtomicServiceStartupRule(Want &want, sptr<IRemoteObject> callerToken,
45 int32_t userId, AtomicServiceStartupRule &rule, sptr<Want> &replaceWant);41 int32_t userId, AtomicServiceStartupRule &rule, sptr<Want> &replaceWant);
46 42 
@@ -25,10 +25,6 @@ public:
25 ScreenUnlockInterceptor() = default;25 ScreenUnlockInterceptor() = default;
26 ~ScreenUnlockInterceptor() = default;26 ~ScreenUnlockInterceptor() = default;
27 ErrCode DoProcess(const AbilityInterceptorParam &param) override;27 ErrCode DoProcess(const AbilityInterceptorParam &param) override;
28- virtual void SetTaskHandler(std::shared_ptr<AAFwk::TaskHandlerWrap> taskHandler) override
29- {
30- return;
31- };
32private:28private:
33 bool GetTargetAbilityInfo(const AbilityInterceptorParam &param, AppExecFwk::AbilityInfo &targetAbilityInfo);29 bool GetTargetAbilityInfo(const AbilityInterceptorParam &param, AppExecFwk::AbilityInfo &targetAbilityInfo);
34 bool QueryTargetAbilityInfoByUri(const AbilityInterceptorParam &param, AppExecFwk::AbilityInfo &targetAbilityInfo);30 bool QueryTargetAbilityInfoByUri(const AbilityInterceptorParam &param, AppExecFwk::AbilityInfo &targetAbilityInfo);
@@ -1,49 +0,0 @@
1-/*
2- * Copyright (c) 2024-2026 Huawei Device Co., Ltd.
3- * Licensed under the Apache License, Version 2.0 (the "License");
4- * you may not use this file except in compliance with the License.
5- * You may obtain a copy of the License at
6- *
7- * http://www.apache.org/licenses/LICENSE-2.0
8- *
9- * Unless required by applicable law or agreed to in writing, software
10- * distributed under the License is distributed on an "AS IS" BASIS,
11- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12- * See the License for the specific language governing permissions and
13- * limitations under the License.
14- */
15- 
16-#ifndef OHOS_ABILITY_RUNTIME_START_OTHER_APP_INTERCEPTOR
17-#define OHOS_ABILITY_RUNTIME_START_OTHER_APP_INTERCEPTOR
18- 
19-#include "ability_interceptor_interface.h"
20-#include "application_info.h"
21-#include "want.h"
22- 
23-namespace OHOS {
24-namespace AAFwk {
25-class StartOtherAppInterceptor : public IAbilityInterceptor {
26-public:
27- StartOtherAppInterceptor() = default;
28- ~StartOtherAppInterceptor() = default;
29- ErrCode DoProcess(const AbilityInterceptorParam &param) override;
30- virtual void SetTaskHandler(std::shared_ptr<AAFwk::TaskHandlerWrap> taskHandler) override
31- {
32- return;
33- };
34-private:
35- bool CheckNativeCall();
36- bool CheckCallerIsSystemApp();
37- bool CheckTargetIsSystemApp(const AppExecFwk::ApplicationInfo &applicationInfo);
38- bool GetApplicationInfo(const sptr<IRemoteObject> &callerToken,
39- AppExecFwk::ApplicationInfo &applicationInfo);
40- bool CheckAncoShellCall(const AppExecFwk::ApplicationInfo &applicationInfo,
41- const Want &want);
42- bool CheckStartOtherApp(const Want &want);
43- bool CheckCallerApiBelow12(const AppExecFwk::ApplicationInfo &applicationInfo);
44- bool IsDelegatorCall(const Want &want);
45-};
46-} // namespace AAFwk
47-} // namespace OHOS
48- 
49-#endif // OHOS_ABILITY_RUNTIME_START_OTHER_APP_INTERCEPTOR
@@ -76,7 +76,6 @@
76#include "interceptor/extension_control_interceptor.h"76#include "interceptor/extension_control_interceptor.h"
77#include "interceptor/kiosk_interceptor.h"77#include "interceptor/kiosk_interceptor.h"
78#include "interceptor/screen_unlock_interceptor.h"78#include "interceptor/screen_unlock_interceptor.h"
79-#include "interceptor/start_other_app_interceptor.h"
80#include "int_wrapper.h"79#include "int_wrapper.h"
81#include "ipc_skeleton.h"80#include "ipc_skeleton.h"
82#include "iservice_registry.h"81#include "iservice_registry.h"
@@ -536,10 +535,8 @@ void AbilityManagerService::InitInterceptor()
536 interceptorExecuter_->AddInterceptor("Control", std::make_shared<ControlInterceptor>());535 interceptorExecuter_->AddInterceptor("Control", std::make_shared<ControlInterceptor>());
537 afterCheckExecuter_ = std::make_shared<AbilityInterceptorExecuter>();536 afterCheckExecuter_ = std::make_shared<AbilityInterceptorExecuter>();
538 afterCheckExecuter_->AddInterceptor("ExtensionControl", std::make_shared<ExtensionControlInterceptor>());537 afterCheckExecuter_->AddInterceptor("ExtensionControl", std::make_shared<ExtensionControlInterceptor>());
539- afterCheckExecuter_->AddInterceptor("StartOtherApp", std::make_shared<StartOtherAppInterceptor>());538+ afterCheckExecuter_->AddInterceptor("DisposedRule", std::make_shared<DisposedRuleInterceptor>(taskHandler_));
540- afterCheckExecuter_->AddInterceptor("DisposedRule", std::make_shared<DisposedRuleInterceptor>());
541 afterCheckExecuter_->AddInterceptor("EcologicalRule", std::make_shared<EcologicalRuleInterceptor>());539 afterCheckExecuter_->AddInterceptor("EcologicalRule", std::make_shared<EcologicalRuleInterceptor>());
542- afterCheckExecuter_->SetTaskHandler(taskHandler_);
543 if (AppUtils::GetInstance().IsStartOptionsWithAnimation()) {540 if (AppUtils::GetInstance().IsStartOptionsWithAnimation()) {
544 TAG_LOGI(AAFwkTag::ABILITYMGR, "create BlockAllAppStartInterceptor");541 TAG_LOGI(AAFwkTag::ABILITYMGR, "create BlockAllAppStartInterceptor");
545 blockAllAppStartInterceptor_ = std::make_shared<BlockAllAppStartInterceptor>();542 blockAllAppStartInterceptor_ = std::make_shared<BlockAllAppStartInterceptor>();
@@ -66,19 +66,6 @@ ErrCode AbilityInterceptorExecuter::DoProcess(const AbilityInterceptorParam &par
66 return result;66 return result;
67}67}
68 68 
69-void AbilityInterceptorExecuter::SetTaskHandler(std::shared_ptr<AAFwk::TaskHandlerWrap> taskHandler)
70-{
71- HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
72-
73- std::lock_guard lock(interceptorMapLock_);
74- for (auto &item : interceptorMap_) {
75- if (item.second == nullptr) {
76- continue;
77- }
78- (item.second)->SetTaskHandler(taskHandler);
79- }
80-}
81- 
82InterceptorMap AbilityInterceptorExecuter::GetInterceptorMapCopy()69InterceptorMap AbilityInterceptorExecuter::GetInterceptorMapCopy()
83{70{
84 std::lock_guard lock(interceptorMapLock_);71 std::lock_guard lock(interceptorMapLock_);
@@ -75,11 +75,11 @@ ErrCode BlockAllAppStartInterceptor::Execute(AbilityRequest& abilityRequest, int
75ErrCode BlockAllAppStartInterceptor::DoProcess(const AbilityInterceptorParam &param)75ErrCode BlockAllAppStartInterceptor::DoProcess(const AbilityInterceptorParam &param)
76{76{
77 if (param.shouldBlockAllAppStartFunc_ == nullptr) {77 if (param.shouldBlockAllAppStartFunc_ == nullptr) {
78- TAG_LOGE(AAFwkTag::ECOLOGICAL_RULE, "shouldBlockAllAppStartFunc_ is nullptr");78+ TAG_LOGE(AAFwkTag::ABILITYMGR, "shouldBlockAllAppStartFunc_ is nullptr");
79 return ERR_INVALID_VALUE;79 return ERR_INVALID_VALUE;
80 }80 }
81 if (param.shouldBlockAllAppStartFunc_()) {81 if (param.shouldBlockAllAppStartFunc_()) {
82- TAG_LOGE(AAFwkTag::ECOLOGICAL_RULE, "blocking app start due to low memory");82+ TAG_LOGE(AAFwkTag::ABILITYMGR, "blocking app start due to low memory");
83 return ERR_ALL_APP_START_BLOCKED;83 return ERR_ALL_APP_START_BLOCKED;
84 }84 }
85 return ERR_OK;85 return ERR_OK;
@@ -22,7 +22,7 @@
22namespace OHOS {22namespace OHOS {
23namespace AAFwk {23namespace AAFwk {
24namespace {24namespace {
25-constexpr const char* INTERCEPT_PARAMETERS = "intercept_parammeters";25+constexpr const char* INTERCEPT_PARAMETERS = "intercept_parameters";
26constexpr const char* INTERCEPT_BUNDLE_NAME = "intercept_bundleName";26constexpr const char* INTERCEPT_BUNDLE_NAME = "intercept_bundleName";
27constexpr const char* INTERCEPT_ABILITY_NAME = "intercept_abilityName";27constexpr const char* INTERCEPT_ABILITY_NAME = "intercept_abilityName";
28constexpr const char* INTERCEPT_MODULE_NAME = "intercept_moduleName";28constexpr const char* INTERCEPT_MODULE_NAME = "intercept_moduleName";
@@ -87,9 +87,6 @@ bool ControlInterceptor::CheckControl(const Want &want, int32_t userId,
87 87 
88 HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, "GetAppRunningControlRule");88 HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, "GetAppRunningControlRule");
89 std::string identity = IPCSkeleton::ResetCallingIdentity();89 std::string identity = IPCSkeleton::ResetCallingIdentity();
90- if (identity == "") {
91- TAG_LOGE(AAFwkTag::ABILITYMGR, "getId fail");
92- }
93 auto ret = appControlMgr->GetAppRunningControlRule(bundleName, userId, controlRule);90 auto ret = appControlMgr->GetAppRunningControlRule(bundleName, userId, controlRule);
94 if (ret == ERR_BUNDLE_MANAGER_PERMISSION_DENIED) {91 if (ret == ERR_BUNDLE_MANAGER_PERMISSION_DENIED) {
95 IPCSkeleton::SetCallingIdentity(identity, true);92 IPCSkeleton::SetCallingIdentity(identity, true);
@@ -32,13 +32,16 @@ constexpr const char* UNREGISTER_EVENT_TASK = "unregister event task";
32constexpr const char* UNREGISTER_TIMEOUT_OBSERVER_TASK = "unregister timeout observer task";32constexpr const char* UNREGISTER_TIMEOUT_OBSERVER_TASK = "unregister timeout observer task";
33constexpr int UNREGISTER_OBSERVER_MILLI_SECONDS = 5000;33constexpr int UNREGISTER_OBSERVER_MILLI_SECONDS = 5000;
34constexpr const char* UIEXTENSION_MODAL_TYPE = "ability.want.params.modalType";34constexpr const char* UIEXTENSION_MODAL_TYPE = "ability.want.params.modalType";
35-constexpr const char* INTERCEPT_PARAMETERS = "intercept_parammeters";35+constexpr const char* INTERCEPT_PARAMETERS = "intercept_parameters";
36constexpr const char* INTERCEPT_BUNDLE_NAME = "intercept_bundleName";36constexpr const char* INTERCEPT_BUNDLE_NAME = "intercept_bundleName";
37constexpr const char* INTERCEPT_ABILITY_NAME = "intercept_abilityName";37constexpr const char* INTERCEPT_ABILITY_NAME = "intercept_abilityName";
38constexpr const char* INTERCEPT_MODULE_NAME = "intercept_moduleName";38constexpr const char* INTERCEPT_MODULE_NAME = "intercept_moduleName";
39constexpr const char* IS_FROM_PARENTCONTROL = "ohos.ability.isFromParentControl";39constexpr const char* IS_FROM_PARENTCONTROL = "ohos.ability.isFromParentControl";
40}40}
41 41 
42+DisposedRuleInterceptor::DisposedRuleInterceptor(std::shared_ptr<AAFwk::TaskHandlerWrap> taskHandler)
43+ : taskHandler_(taskHandler) {}
44+ 
42std::string DisposedRuleInterceptor::GenerateTimeoutTaskName(int32_t uid)45std::string DisposedRuleInterceptor::GenerateTimeoutTaskName(int32_t uid)
43{46{
44 return UNREGISTER_TIMEOUT_OBSERVER_TASK + std::to_string(uid);47 return UNREGISTER_TIMEOUT_OBSERVER_TASK + std::to_string(uid);
@@ -1,156 +0,0 @@
1-/*
2- * Copyright (c) 2024-2026 Huawei Device Co., Ltd.
3- * Licensed under the Apache License, Version 2.0 (the "License");
4- * you may not use this file except in compliance with the License.
5- * You may obtain a copy of the License at
6- *
7- * http://www.apache.org/licenses/LICENSE-2.0
8- *
9- * Unless required by applicable law or agreed to in writing, software
10- * distributed under the License is distributed on an "AS IS" BASIS,
11- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12- * See the License for the specific language governing permissions and
13- * limitations under the License.
14- */
15- 
16-#include "interceptor/start_other_app_interceptor.h"
17- 
18-#include "ability_record.h"
19-#include "hilog_tag_wrapper.h"
20-#include "parameters.h"
21-#include "permission_verification.h"
22-#include "start_ability_utils.h"
23-#include "tokenid_kit.h"
24- 
25-namespace OHOS {
26-namespace AAFwk {
27-namespace {
28-const uint32_t API_VERSION_MOD = 100;
29-const uint32_t API_SINCE_VISION = 12;
30-constexpr const char* ABILITY_SUPPORT_START_OTHER_APP = "persist.sys.abilityms.support.start_other_app";
31-constexpr const char* IS_DELEGATOR_CALL = "isDelegatorCall";
32-constexpr const char* OPEN_LINK_SCENE_IDENTIFICATION = "appLinkingOnly";
33-}
34- 
35-ErrCode StartOtherAppInterceptor::DoProcess(const AbilityInterceptorParam &param)
36-{
37- if (StartAbilityUtils::skipStartOther) {
38- StartAbilityUtils::skipStartOther = false;
39- return ERR_OK;
40- }
41- std::string supportStart = OHOS::system::GetParameter(ABILITY_SUPPORT_START_OTHER_APP, "true");
42- if (supportStart == "true") {
43- TAG_LOGD(AAFwkTag::ABILITYMGR, "Abilityms support start other app.");
44- return ERR_OK;
45- }
46- 
47- if (!param.isWithUI || param.isStartAsCaller) {
48- return ERR_OK;
49- }
50- if (CheckNativeCall() || CheckCallerIsSystemApp() ||
51- (param.abilityInfo != nullptr && CheckTargetIsSystemApp(param.abilityInfo->applicationInfo))) {
52- return ERR_OK;
53- }
54- 
55- if (!CheckStartOtherApp(param.want)) {
56- return ERR_OK;
57- }
58- 
59- if (param.abilityInfo != nullptr && CheckAncoShellCall(param.abilityInfo->applicationInfo, param.want)) {
60- return ERR_OK;
61- }
62- 
63- if (param.want.HasParameter(OPEN_LINK_SCENE_IDENTIFICATION)) {
64- return ERR_OK;
65- }
66- 
67- AppExecFwk::ApplicationInfo callerApplicationInfo;
68- if (!GetApplicationInfo(param.callerToken, callerApplicationInfo)) {
69- if (IsDelegatorCall(param.want)) {
70- return ERR_OK;
71- }
72- TAG_LOGE(AAFwkTag::ABILITYMGR, "not find callerInfo");
73- return ERR_INVALID_CALLER;
74- }
75- 
76- if (CheckCallerApiBelow12(callerApplicationInfo)) {
77- return ERR_OK;
78- }
79- TAG_LOGE(AAFwkTag::ABILITYMGR, "not call others api above 11");
80- return ERR_START_OTHER_APP_FAILED;
81-}
82- 
83-bool StartOtherAppInterceptor::CheckNativeCall()
84-{
85- auto isSaCall = AAFwk::PermissionVerification::GetInstance()->IsSACall();
86- auto isShellCall = AAFwk::PermissionVerification::GetInstance()->IsShellCall();
87- if (isSaCall || isShellCall) {
88- return true;
89- }
90- return false;
91-}
92- 
93-bool StartOtherAppInterceptor::CheckCallerIsSystemApp()
94-{
95- auto callerToken = IPCSkeleton::GetCallingFullTokenID();
96- if (!Security::AccessToken::TokenIdKit::IsSystemAppByFullTokenID(callerToken)) {
97- return false;
98- }
99- return true;
100-}
101- 
102-bool StartOtherAppInterceptor::CheckTargetIsSystemApp(const AppExecFwk::ApplicationInfo &applicationInfo)
103-{
104- return applicationInfo.isSystemApp;
105-}
106- 
107-bool StartOtherAppInterceptor::GetApplicationInfo(const sptr<IRemoteObject> &callerToken,
108- AppExecFwk::ApplicationInfo &applicationInfo)
109-{
110- if (callerToken == nullptr) {
111- int32_t callerPid = IPCSkeleton::GetCallingPid();
112- auto appScheduler = DelayedSingleton<AppScheduler>::GetInstance();
113- bool debug;
114- if (appScheduler != nullptr &&
115- appScheduler->GetApplicationInfoByProcessID(callerPid, applicationInfo, debug) == ERR_OK) {
116- return true;
117- }
118- return false;
119- }
120- auto abilityRecord = Token::GetAbilityRecordByToken(callerToken);
121- if (abilityRecord == nullptr) {
122- return false;
123- }
124- applicationInfo = abilityRecord->GetApplicationInfo();
125- return true;
126-}
127- 
128-bool StartOtherAppInterceptor::CheckAncoShellCall(const AppExecFwk::ApplicationInfo &applicationInfo,
129- const Want &want)
130-{
131- return (applicationInfo.codePath == std::to_string(CollaboratorType::RESERVE_TYPE) ||
132- applicationInfo.codePath == std::to_string(CollaboratorType::OTHERS_TYPE));
133-}
134- 
135-bool StartOtherAppInterceptor::CheckStartOtherApp(const Want &want)
136-{
137- return want.GetStringParam(Want::PARAM_RESV_CALLER_BUNDLE_NAME) != want.GetBundleNameRef();
138-}
139- 
140-bool StartOtherAppInterceptor::CheckCallerApiBelow12(const AppExecFwk::ApplicationInfo &applicationInfo)
141-{
142- return (applicationInfo.apiTargetVersion % API_VERSION_MOD < API_SINCE_VISION);
143-}
144- 
145-bool StartOtherAppInterceptor::IsDelegatorCall(const Want &want)
146-{
147- AppExecFwk::RunningProcessInfo processInfo;
148- DelayedSingleton<AppScheduler>::GetInstance()->
149- GetRunningProcessInfoByPid(IPCSkeleton::GetCallingPid(), processInfo);
150- if (processInfo.isTestProcess && want.GetBoolParam(IS_DELEGATOR_CALL, false)) {
151- return true;
152- }
153- return false;
154-}
155-}
156-}
@@ -527,7 +527,6 @@ group("fuzztest") {
527 "startabilityutils_fuzzer:fuzztest",527 "startabilityutils_fuzzer:fuzztest",
528 "startabilityutilsfirst_fuzzer:fuzztest",528 "startabilityutilsfirst_fuzzer:fuzztest",
529 "startcontinuation_fuzzer:fuzztest",529 "startcontinuation_fuzzer:fuzztest",
530- "startotherappinterceptor_fuzzer:fuzztest",
531 "startrenderprocess_fuzzer:fuzztest",530 "startrenderprocess_fuzzer:fuzztest",
532 "startserviceextensionability_fuzzer:fuzztest",531 "startserviceextensionability_fuzzer:fuzztest",
533 "startspecifiedability_fuzzer:fuzztest",532 "startspecifiedability_fuzzer:fuzztest",
@@ -77,8 +77,6 @@ bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
77 auto shouldBlockFunc = []() { return false; };77 auto shouldBlockFunc = []() { return false; };
78 AbilityInterceptorParam param(want, requestCode, userId, boolParam, callerToken, shouldBlockFunc);78 AbilityInterceptorParam param(want, requestCode, userId, boolParam, callerToken, shouldBlockFunc);
79 executer->DoProcess(param);79 executer->DoProcess(param);
80- std::shared_ptr<AAFwk::TaskHandlerWrap> taskHandler;
81- executer->SetTaskHandler(taskHandler);
82 executer->GetInterceptorMapCopy();80 executer->GetInterceptorMapCopy();
83 return true;81 return true;
84}82}
@@ -1,108 +0,0 @@
1-# Copyright (c) 2024-2025 Huawei Device Co., Ltd.
2-# Licensed under the Apache License, Version 2.0 (the "License");
3-# you may not use this file except in compliance with the License.
4-# You may obtain a copy of the License at
5-#
6-# http://www.apache.org/licenses/LICENSE-2.0
7-#
8-# Unless required by applicable law or agreed to in writing, software
9-# distributed under the License is distributed on an "AS IS" BASIS,
10-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11-# See the License for the specific language governing permissions and
12-# limitations under the License.
13- 
14-#####################hydra-fuzz###################
15-import("//build/config/features.gni")
16-import("//build/ohos.gni")
17-import("//build/test.gni")
18-import("//foundation/ability/ability_runtime/ability_runtime.gni")
19-module_output_path = "ability_runtime/abilitymgr"
20- 
21-##############################fuzztest##########################################
22-ohos_fuzztest("StartOtherappinterceptorFuzzTest") {
23- module_out_path = module_output_path
24- 
25- cflags_cc = []
26- fuzz_config_file =
27- "${ability_runtime_test_path}/fuzztest/startotherappinterceptor_fuzzer"
28- cflags_cc = []
29- include_dirs = [
30- "${ability_runtime_path}/interfaces/kits/native/appkit/ability_bundle_manager_helper",
31- "${ability_runtime_innerkits_path}/app_manager/include/appmgr",
32- "${ability_runtime_services_path}/abilitymgr/include/utils",
33- "${ability_runtime_services_path}/abilitymgr/include",
34- "${ability_runtime_services_path}/abilitymgr/include/interceptor",
35- "${ability_runtime_utils_path}/server/startup/include",
36- ]
37- cflags = [
38- "-g",
39- "-O0",
40- "-Wno-unused-variable",
41- "-fno-omit-frame-pointer",
42- ]
43- 
44- sources = [
45- "${ability_runtime_services_path}/abilitymgr/src/app_scheduler.cpp",
46- "${ability_runtime_services_path}/abilitymgr/src/interceptor/start_other_app_interceptor.cpp",
47- "${ability_runtime_services_path}/abilitymgr/src/utils/start_ability_utils.cpp",
48- "${ability_runtime_services_path}/abilitymgr/src/utils/state_utils.cpp",
49- "startotherappinterceptor_fuzzer.cpp",
50- ]
51- 
52- configs = [ "${ability_runtime_services_path}/abilitymgr:abilityms_config" ]
53- cflags = []
54- if (target_cpu == "arm") {
55- cflags += [ "-DBINDER_IPC_32BIT" ]
56- }
57- deps = [
58- "${ability_runtime_innerkits_path}/ability_manager:ability_manager",
59- "${ability_runtime_innerkits_path}/app_manager:app_manager",
60- "${ability_runtime_innerkits_path}/deps_wrapper:ability_deps_wrapper",
61- "${ability_runtime_native_path}/appkit:appkit_manager_helper",
62- "${ability_runtime_path}/utils/server/startup:startup_util",
63- "${ability_runtime_services_path}/abilitymgr:abilityms",
64- "${ability_runtime_services_path}/appmgr:libappms",
65- "${ability_runtime_services_path}/common:app_util",
66- "${ability_runtime_services_path}/common:perm_verification",
67- ]
68- 
69- external_deps = [
70- "ability_base:want",
71- "ability_base:zuri",
72- "access_token:libaccesstoken_sdk",
73- "access_token:libtokenid_sdk",
74- "bundle_framework:appexecfwk_base",
75- "bundle_framework:appexecfwk_core",
76- "c_utils:utils",
77- "common_event_service:cesfwk_innerkits",
78- "eventhandler:libeventhandler",
79- "ffrt:libffrt",
80- "hilog:libhilog",
81- "hisysevent:libhisysevent",
82- "hitrace:hitrace_meter",
83- "init:libbegetutil",
84- "ipc:ipc_core",
85- "libjpeg-turbo:turbojpeg",
86- "napi:ace_napi",
87- "safwk:api_cache_manager",
88- ]
89- 
90- if (ability_runtime_dsoftbus_enable) {
91- external_deps += [ "dsoftbus:softbus_client" ]
92- }
93- 
94- if (os_dlp_part_enabled) {
95- cflags_cc += [ "-DWITH_DLP" ]
96- }
97-}
98- 
99-###############################################################################
100-group("fuzztest") {
101- testonly = true
102- deps = []
103- deps += [
104- # deps file
105- ":StartOtherappinterceptorFuzzTest",
106- ]
107-}
108-###############################################################################
@@ -1,16 +0,0 @@
1-/*
2- * Copyright (c) 2024 Huawei Device Co., Ltd.
3- * Licensed under the Apache License, Version 2.0 (the "License");
4- * you may not use this file except in compliance with the License.
5- * You may obtain a copy of the License at
6- *
7- * http://www.apache.org/licenses/LICENSE-2.0
8- *
9- * Unless required by applicable law or agreed to in writing, software
10- * distributed under the License is distributed on an "AS IS" BASIS,
11- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12- * See the License for the specific language governing permissions and
13- * limitations under the License.
14- */
15- 
16-FUZZ
@@ -1,25 +0,0 @@
1-<?xml version="1.0" encoding="utf-8"?>
2-<!-- Copyright (c) 2024 Huawei Device Co., Ltd.
3- 
4- Licensed under the Apache License, Version 2.0 (the "License");
5- you may not use this file except in compliance with the License.
6- You may obtain a copy of the License at
7- 
8- http://www.apache.org/licenses/LICENSE-2.0
9- 
10- Unless required by applicable law or agreed to in writing, software
11- distributed under the License is distributed on an "AS IS" BASIS,
12- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13- See the License for the specific language governing permissions and
14- limitations under the License.
15--->
16-<fuzz_config>
17- <fuzztest>
18- <!-- maximum length of a test input -->
19- <max_len>1000</max_len>
20- <!-- maximum total time in seconds to run the fuzzer -->
21- <max_total_time>300</max_total_time>
22- <!-- memory usage limit in Mb -->
23- <rss_limit_mb>4096</rss_limit_mb>
24- </fuzztest>
25-</fuzz_config>
@@ -1,120 +0,0 @@
1-/*
2- * Copyright (c) 2024 Huawei Device Co., Ltd.
3- * Licensed under the Apache License, Version 2.0 (the "License");
4- * you may not use this file except in compliance with the License.
5- * You may obtain a copy of the License at
6- *
7- * http://www.apache.org/licenses/LICENSE-2.0
8- *
9- * Unless required by applicable law or agreed to in writing, software
10- * distributed under the License is distributed on an "AS IS" BASIS,
11- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12- * See the License for the specific language governing permissions and
13- * limitations under the License.
14- */
15- 
16-#include "startotherappinterceptor_fuzzer.h"
17- 
18-#include <cstddef>
19-#include <cstdint>
20-#define private public
21-#include "start_other_app_interceptor.h"
22-#undef private
23-#include "ability_record.h"
24-#include "start_ability_utils.h"
25- 
26-using namespace OHOS::AAFwk;
27-using namespace OHOS::AppExecFwk;
28- 
29-namespace OHOS {
30-namespace {
31-constexpr int INPUT_ZERO = 0;
32-constexpr int INPUT_ONE = 1;
33-constexpr int INPUT_TWO = 2;
34-constexpr int INPUT_THREE = 3;
35-constexpr size_t U32_AT_SIZE = 4;
36-constexpr size_t OFFSET_ZERO = 24;
37-constexpr size_t OFFSET_ONE = 16;
38-constexpr size_t OFFSET_TWO = 8;
39-constexpr uint8_t ENABLE = 2;
40-} // namespace
41- 
42-uint32_t GetU32Data(const char* ptr)
43-{
44- // convert fuzz input data to an integer
45- return (ptr[INPUT_ZERO] << OFFSET_ZERO) | (ptr[INPUT_ONE] << OFFSET_ONE) | (ptr[INPUT_TWO] << OFFSET_TWO) |
46- ptr[INPUT_THREE];
47-}
48- 
49-sptr<Token> GetFuzzAbilityToken()
50-{
51- sptr<Token> token = nullptr;
52- AbilityRequest abilityRequest;
53- abilityRequest.appInfo.bundleName = "com.example.fuzzTest";
54- abilityRequest.abilityInfo.name = "MainAbility";
55- abilityRequest.abilityInfo.type = AbilityType::DATA;
56- std::shared_ptr<AbilityRecord> abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
57- if (abilityRecord) {
58- token = abilityRecord->GetToken();
59- }
60- return token;
61-}
62- 
63-bool DoSomethingInterestingWithMyAPI(const char *data, size_t size)
64-{
65- int intParam = static_cast<int>(GetU32Data(data));
66- int32_t int32Param = static_cast<int32_t>(GetU32Data(data));
67- auto startOtherAppInterceptor = std::make_shared<StartOtherAppInterceptor>();
68- Want want;
69- bool boolParam = *data % ENABLE;
70- AppExecFwk::ApplicationInfo appInfo;
71- sptr<IRemoteObject> token = GetFuzzAbilityToken();
72- auto shouldBlockFunc = []() { return false; };
73- AbilityInterceptorParam param = AbilityInterceptorParam(want, intParam, int32Param, boolParam, token,
74- shouldBlockFunc);
75- startOtherAppInterceptor->DoProcess(param);
76- startOtherAppInterceptor->CheckNativeCall();
77- startOtherAppInterceptor->CheckCallerIsSystemApp();
78- startOtherAppInterceptor->CheckTargetIsSystemApp(appInfo);
79- startOtherAppInterceptor->GetApplicationInfo(token, appInfo);
80- startOtherAppInterceptor->CheckAncoShellCall(appInfo, want);
81- startOtherAppInterceptor->CheckStartOtherApp(want);
82- startOtherAppInterceptor->CheckCallerApiBelow12(appInfo);
83- startOtherAppInterceptor->IsDelegatorCall(want);
84- return true;
85-}
86-} // namespace OHOS
87- 
88-/* Fuzzer entry point */
89-extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
90-{
91- /* Run your code on data */
92- if (data == nullptr) {
93- std::cout << "invalid data" << std::endl;
94- return 0;
95- }
96- 
97- /* Validate the length of size */
98- if (size < OHOS::U32_AT_SIZE) {
99- return 0;
100- }
101- 
102- char *ch = static_cast<char*>(malloc(size + 1));
103- if (ch == nullptr) {
104- std::cout << "malloc failed." << std::endl;
105- return 0;
106- }
107- 
108- (void)memset_s(ch, size + 1, 0x00, size + 1);
109- if (memcpy_s(ch, size + 1, data, size) != EOK) {
110- std::cout << "copy failed." << std::endl;
111- free(ch);
112- ch = nullptr;
113- return 0;
114- }
115- 
116- OHOS::DoSomethingInterestingWithMyAPI(ch, size);
117- free(ch);
118- ch = nullptr;
119- return 0;
120-}
@@ -1,21 +0,0 @@
1-/*
2- * Copyright (c) 2024 Huawei Device Co., Ltd.
3- * Licensed under the Apache License, Version 2.0 (the "License");
4- * you may not use this file except in compliance with the License.
5- * You may obtain a copy of the License at
6- *
7- * http://www.apache.org/licenses/LICENSE-2.0
8- *
9- * Unless required by applicable law or agreed to in writing, software
10- * distributed under the License is distributed on an "AS IS" BASIS,
11- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12- * See the License for the specific language governing permissions and
13- * limitations under the License.
14- */
15- 
16-#ifndef FUZZTEST_OHOS_ABILITY_RUNTIME_STARTOTHERAPPINTERCEPTOR_FUZZER_H
17-#define FUZZTEST_OHOS_ABILITY_RUNTIME_STARTOTHERAPPINTERCEPTOR_FUZZER_H
18- 
19-#define FUZZ_PROJECT_NAME "startotherappinterceptor_fuzzer"
20- 
21-#endif
@@ -529,7 +529,6 @@ group("unittest") {
529 "start_options_impl_test:unittest",529 "start_options_impl_test:unittest",
530 "start_options_test:unittest",530 "start_options_test:unittest",
531 "start_options_utils_test:unittest",531 "start_options_utils_test:unittest",
532- "start_other_app_interceptor_test:unittest",
533 "start_params_by_SCB_test:unittest",532 "start_params_by_SCB_test:unittest",
534 "startup_util_test:unittest",533 "startup_util_test:unittest",
535 "state_utils_test:unittest",534 "state_utils_test:unittest",
@@ -67,21 +67,5 @@ HWTEST_F(AbilityInterceptorThirdTest, RemoveInterceptor_001, TestSize.Level1)
67 EXPECT_EQ(resMap2.size(), 0);67 EXPECT_EQ(resMap2.size(), 0);
68}68}
69 69 
70-/**
71- * @tc.name: AbilityInterceptorThirdTest_SetTaskHandler_001
72- * @tc.desc: SetTaskHandler
73- * @tc.type: FUNC
74- * @tc.require: No
75- */
76-HWTEST_F(AbilityInterceptorThirdTest, SetTaskHandler_001, TestSize.Level1)
77-{
78- std::shared_ptr<AbilityInterceptorExecuter> executer = std::make_shared<AbilityInterceptorExecuter>();
79- std::shared_ptr<AAFwk::TaskHandlerWrap> taskHandler = AAFwk::TaskHandlerWrap::CreateQueueHandler("SetTaskHandler");
80- executer->AddInterceptor("CrowdTest", std::make_shared<CrowdTestInterceptor>());
81- executer->SetTaskHandler(taskHandler);
82- auto resMap2 = executer->GetInterceptorMapCopy();
83- EXPECT_EQ(resMap2.size(), 1);
84-}
85- 
86} // namespace AAFwk70} // namespace AAFwk
87} // namespace OHOS71} // namespace OHOS
@@ -67,7 +67,6 @@ abilityms_files = [
67 "${ability_runtime_services_path}/abilitymgr/src/interceptor/ecological_rule_interceptor.cpp",67 "${ability_runtime_services_path}/abilitymgr/src/interceptor/ecological_rule_interceptor.cpp",
68 "${ability_runtime_services_path}/abilitymgr/src/interceptor/extension_control_interceptor.cpp",68 "${ability_runtime_services_path}/abilitymgr/src/interceptor/extension_control_interceptor.cpp",
69 "${ability_runtime_services_path}/abilitymgr/src/interceptor/screen_unlock_interceptor.cpp",69 "${ability_runtime_services_path}/abilitymgr/src/interceptor/screen_unlock_interceptor.cpp",
70- "${ability_runtime_services_path}/abilitymgr/src/interceptor/start_other_app_interceptor.cpp",
71 "${ability_runtime_services_path}/abilitymgr/src/interceptor/kiosk_interceptor.cpp",70 "${ability_runtime_services_path}/abilitymgr/src/interceptor/kiosk_interceptor.cpp",
72 "${ability_runtime_services_path}/abilitymgr/src/window_focus_changed_listener.cpp",71 "${ability_runtime_services_path}/abilitymgr/src/window_focus_changed_listener.cpp",
73 "${ability_runtime_services_path}/abilitymgr/src/window_visibility_changed_listener.cpp",72 "${ability_runtime_services_path}/abilitymgr/src/window_visibility_changed_listener.cpp",
@@ -154,7 +154,6 @@ ohos_unittest("ability_manager_service_fourteenth_test") {
154 "${ability_runtime_services_path}/abilitymgr/src/interceptor/disposed_rule_interceptor.cpp",154 "${ability_runtime_services_path}/abilitymgr/src/interceptor/disposed_rule_interceptor.cpp",
155 "${ability_runtime_services_path}/abilitymgr/src/interceptor/extension_control_interceptor.cpp",155 "${ability_runtime_services_path}/abilitymgr/src/interceptor/extension_control_interceptor.cpp",
156 "${ability_runtime_services_path}/abilitymgr/src/interceptor/screen_unlock_interceptor.cpp",156 "${ability_runtime_services_path}/abilitymgr/src/interceptor/screen_unlock_interceptor.cpp",
157- "${ability_runtime_services_path}/abilitymgr/src/interceptor/start_other_app_interceptor.cpp",
158 "${ability_runtime_services_path}/abilitymgr/src/keep_alive/ability_keep_alive_data_manager.cpp",157 "${ability_runtime_services_path}/abilitymgr/src/keep_alive/ability_keep_alive_data_manager.cpp",
159 "${ability_runtime_services_path}/abilitymgr/src/keep_alive/ability_keep_alive_service.cpp",158 "${ability_runtime_services_path}/abilitymgr/src/keep_alive/ability_keep_alive_service.cpp",
160 "${ability_runtime_services_path}/abilitymgr/src/keep_alive/keep_alive_process_manager.cpp",159 "${ability_runtime_services_path}/abilitymgr/src/keep_alive/keep_alive_process_manager.cpp",
@@ -46,8 +46,6 @@ public:
46 * Excute the DoProcess of the interceptors.46 * Excute the DoProcess of the interceptors.
47 */47 */
48 ErrCode DoProcess(const AbilityInterceptorParam &param);48 ErrCode DoProcess(const AbilityInterceptorParam &param);
49- 
50- void SetTaskHandler(std::shared_ptr<AAFwk::TaskHandlerWrap> taskHandler);
51private:49private:
52 InterceptorMap GetInterceptorMapCopy();50 InterceptorMap GetInterceptorMapCopy();
53private:51private:
@@ -156,7 +156,6 @@ ohos_unittest("ability_manager_service_second_test") {
156 "${ability_runtime_services_path}/abilitymgr/src/interceptor/extension_control_interceptor.cpp",156 "${ability_runtime_services_path}/abilitymgr/src/interceptor/extension_control_interceptor.cpp",
157 "${ability_runtime_services_path}/abilitymgr/src/interceptor/kiosk_interceptor.cpp",157 "${ability_runtime_services_path}/abilitymgr/src/interceptor/kiosk_interceptor.cpp",
158 "${ability_runtime_services_path}/abilitymgr/src/interceptor/screen_unlock_interceptor.cpp",158 "${ability_runtime_services_path}/abilitymgr/src/interceptor/screen_unlock_interceptor.cpp",
159- "${ability_runtime_services_path}/abilitymgr/src/interceptor/start_other_app_interceptor.cpp",
160 "${ability_runtime_services_path}/abilitymgr/src/keep_alive/ability_keep_alive_data_manager.cpp",159 "${ability_runtime_services_path}/abilitymgr/src/keep_alive/ability_keep_alive_data_manager.cpp",
161 "${ability_runtime_services_path}/abilitymgr/src/keep_alive/ability_keep_alive_service.cpp",160 "${ability_runtime_services_path}/abilitymgr/src/keep_alive/ability_keep_alive_service.cpp",
162 "${ability_runtime_services_path}/abilitymgr/src/keep_alive/keep_alive_process_manager.cpp",161 "${ability_runtime_services_path}/abilitymgr/src/keep_alive/keep_alive_process_manager.cpp",
@@ -67,7 +67,6 @@ abilityms_files = [
67 "${ability_runtime_services_path}/abilitymgr/src/interceptor/ecological_rule_interceptor.cpp",67 "${ability_runtime_services_path}/abilitymgr/src/interceptor/ecological_rule_interceptor.cpp",
68 "${ability_runtime_services_path}/abilitymgr/src/interceptor/extension_control_interceptor.cpp",68 "${ability_runtime_services_path}/abilitymgr/src/interceptor/extension_control_interceptor.cpp",
69 "${ability_runtime_services_path}/abilitymgr/src/interceptor/screen_unlock_interceptor.cpp",69 "${ability_runtime_services_path}/abilitymgr/src/interceptor/screen_unlock_interceptor.cpp",
70- "${ability_runtime_services_path}/abilitymgr/src/interceptor/start_other_app_interceptor.cpp",
71 "${ability_runtime_services_path}/abilitymgr/src/interceptor/kiosk_interceptor.cpp",70 "${ability_runtime_services_path}/abilitymgr/src/interceptor/kiosk_interceptor.cpp",
72 "${ability_runtime_services_path}/abilitymgr/src/window_focus_changed_listener.cpp",71 "${ability_runtime_services_path}/abilitymgr/src/window_focus_changed_listener.cpp",
73 "${ability_runtime_services_path}/abilitymgr/src/window_visibility_changed_listener.cpp",72 "${ability_runtime_services_path}/abilitymgr/src/window_visibility_changed_listener.cpp",
@@ -67,7 +67,6 @@ abilityms_files = [
67 "${ability_runtime_services_path}/abilitymgr/src/interceptor/ecological_rule_interceptor.cpp",67 "${ability_runtime_services_path}/abilitymgr/src/interceptor/ecological_rule_interceptor.cpp",
68 "${ability_runtime_services_path}/abilitymgr/src/interceptor/extension_control_interceptor.cpp",68 "${ability_runtime_services_path}/abilitymgr/src/interceptor/extension_control_interceptor.cpp",
69 "${ability_runtime_services_path}/abilitymgr/src/interceptor/screen_unlock_interceptor.cpp",69 "${ability_runtime_services_path}/abilitymgr/src/interceptor/screen_unlock_interceptor.cpp",
70- "${ability_runtime_services_path}/abilitymgr/src/interceptor/start_other_app_interceptor.cpp",
71 "${ability_runtime_services_path}/abilitymgr/src/interceptor/kiosk_interceptor.cpp",70 "${ability_runtime_services_path}/abilitymgr/src/interceptor/kiosk_interceptor.cpp",
72 "${ability_runtime_services_path}/abilitymgr/src/window_focus_changed_listener.cpp",71 "${ability_runtime_services_path}/abilitymgr/src/window_focus_changed_listener.cpp",
73 "${ability_runtime_services_path}/abilitymgr/src/window_visibility_changed_listener.cpp",72 "${ability_runtime_services_path}/abilitymgr/src/window_visibility_changed_listener.cpp",
@@ -155,7 +155,6 @@ ohos_unittest("ability_manager_service_thirteenth_test") {
155 "${ability_runtime_services_path}/abilitymgr/src/interceptor/disposed_rule_interceptor.cpp",155 "${ability_runtime_services_path}/abilitymgr/src/interceptor/disposed_rule_interceptor.cpp",
156 "${ability_runtime_services_path}/abilitymgr/src/interceptor/extension_control_interceptor.cpp",156 "${ability_runtime_services_path}/abilitymgr/src/interceptor/extension_control_interceptor.cpp",
157 "${ability_runtime_services_path}/abilitymgr/src/interceptor/screen_unlock_interceptor.cpp",157 "${ability_runtime_services_path}/abilitymgr/src/interceptor/screen_unlock_interceptor.cpp",
158- "${ability_runtime_services_path}/abilitymgr/src/interceptor/start_other_app_interceptor.cpp",
159 "${ability_runtime_services_path}/abilitymgr/src/keep_alive/ability_keep_alive_data_manager.cpp",158 "${ability_runtime_services_path}/abilitymgr/src/keep_alive/ability_keep_alive_data_manager.cpp",
160 "${ability_runtime_services_path}/abilitymgr/src/keep_alive/ability_keep_alive_service.cpp",159 "${ability_runtime_services_path}/abilitymgr/src/keep_alive/ability_keep_alive_service.cpp",
161 "${ability_runtime_services_path}/abilitymgr/src/keep_alive/keep_alive_process_manager.cpp",160 "${ability_runtime_services_path}/abilitymgr/src/keep_alive/keep_alive_process_manager.cpp",
@@ -37,10 +37,6 @@ public:
37 ~EcologicalRuleInterceptor() = default;37 ~EcologicalRuleInterceptor() = default;
38 ErrCode DoProcess(const AbilityInterceptorParam &param) override;38 ErrCode DoProcess(const AbilityInterceptorParam &param) override;
39 bool DoProcess(Want &want, int32_t userId);39 bool DoProcess(Want &want, int32_t userId);
40- virtual void SetTaskHandler(std::shared_ptr<AAFwk::TaskHandlerWrap> taskHandler) override
41- {
42- return;
43- };
44 ErrCode QueryAtomicServiceStartupRule(Want &want, sptr<IRemoteObject> callerToken,40 ErrCode QueryAtomicServiceStartupRule(Want &want, sptr<IRemoteObject> callerToken,
45 int32_t userId, AtomicServiceStartupRule &rule, sptr<Want> &replaceWant);41 int32_t userId, AtomicServiceStartupRule &rule, sptr<Want> &replaceWant);
46 42 
@@ -262,7 +262,8 @@ HWTEST_F(DisposedRuleInterceptorTest, StartNonBlockRule_004, TestSize.Level1)
262 auto appMgr = sptr<AppExecFwk::MockAppMgrService>::MakeSptr();262 auto appMgr = sptr<AppExecFwk::MockAppMgrService>::MakeSptr();
263 MyFlag::mockAppMgr_ = appMgr;263 MyFlag::mockAppMgr_ = appMgr;
264 264 
265- std::shared_ptr<DisposedRuleInterceptor> interceptor = std::make_shared<DisposedRuleInterceptor>();265+ std::shared_ptr<DisposedRuleInterceptor> interceptor =
266+ std::make_shared<DisposedRuleInterceptor>(TaskHandlerWrap::CreateQueueHandler("StartNonBlockRule_004"));
266 Want want;267 Want want;
267 want.SetElementName("", "test.bundleName123", "test.abilityName", "test.entry");268 want.SetElementName("", "test.bundleName123", "test.abilityName", "test.entry");
268 AppExecFwk::DisposedRule rule;269 AppExecFwk::DisposedRule rule;
@@ -273,7 +274,6 @@ HWTEST_F(DisposedRuleInterceptorTest, StartNonBlockRule_004, TestSize.Level1)
273 rule.want->SetElementName("", "test.bundleName321", "test.abilityName", "test.entry");274 rule.want->SetElementName("", "test.bundleName321", "test.abilityName", "test.entry");
274 auto abilityInfo = std::make_shared<AppExecFwk::AbilityInfo>();275 auto abilityInfo = std::make_shared<AppExecFwk::AbilityInfo>();
275 abilityInfo->uid = uid;276 abilityInfo->uid = uid;
276- interceptor->taskHandler_ = TaskHandlerWrap::CreateQueueHandler("StartNonBlockRule_004");
277 auto ret = interceptor->StartNonBlockRule(want, rule, abilityInfo);277 auto ret = interceptor->StartNonBlockRule(want, rule, abilityInfo);
278 EXPECT_EQ(ret, ERR_OK);278 EXPECT_EQ(ret, ERR_OK);
279 TAG_LOGI(AAFwkTag::TEST, "StartNonBlockRule_004 end");279 TAG_LOGI(AAFwkTag::TEST, "StartNonBlockRule_004 end");
@@ -293,7 +293,8 @@ HWTEST_F(DisposedRuleInterceptorTest, StartNonBlockRule_005, TestSize.Level1)
293 EXPECT_CALL(*appMgr, RegisterApplicationStateObserver(_, _))293 EXPECT_CALL(*appMgr, RegisterApplicationStateObserver(_, _))
294 .WillOnce(Return(-1));294 .WillOnce(Return(-1));
295 295 
296- std::shared_ptr<DisposedRuleInterceptor> interceptor = std::make_shared<DisposedRuleInterceptor>();296+ std::shared_ptr<DisposedRuleInterceptor> interceptor =
297+ std::make_shared<DisposedRuleInterceptor>(TaskHandlerWrap::CreateQueueHandler("StartNonBlockRule_005"));
297 Want want;298 Want want;
298 want.SetElementName("", "test.bundleName123", "test.abilityName", "test.entry");299 want.SetElementName("", "test.bundleName123", "test.abilityName", "test.entry");
299 AppExecFwk::DisposedRule rule;300 AppExecFwk::DisposedRule rule;
@@ -301,7 +302,6 @@ HWTEST_F(DisposedRuleInterceptorTest, StartNonBlockRule_005, TestSize.Level1)
301 rule.want->SetElementName("", "test.bundleName321", "test.abilityName", "test.entry");302 rule.want->SetElementName("", "test.bundleName321", "test.abilityName", "test.entry");
302 auto abilityInfo = std::make_shared<AppExecFwk::AbilityInfo>();303 auto abilityInfo = std::make_shared<AppExecFwk::AbilityInfo>();
303 abilityInfo->uid = 100;304 abilityInfo->uid = 100;
304- interceptor->taskHandler_ = TaskHandlerWrap::CreateQueueHandler("StartNonBlockRule_005");
305 auto ret = interceptor->StartNonBlockRule(want, rule, abilityInfo);305 auto ret = interceptor->StartNonBlockRule(want, rule, abilityInfo);
306 EXPECT_EQ(ret, -1);306 EXPECT_EQ(ret, -1);
307 TAG_LOGI(AAFwkTag::TEST, "StartNonBlockRule_005 end");307 TAG_LOGI(AAFwkTag::TEST, "StartNonBlockRule_005 end");
@@ -321,7 +321,8 @@ HWTEST_F(DisposedRuleInterceptorTest, StartNonBlockRule_006, TestSize.Level1)
321 EXPECT_CALL(*appMgr, RegisterApplicationStateObserver(_, _))321 EXPECT_CALL(*appMgr, RegisterApplicationStateObserver(_, _))
322 .WillOnce(Return(ERR_OK));322 .WillOnce(Return(ERR_OK));
323 323 
324- std::shared_ptr<DisposedRuleInterceptor> interceptor = std::make_shared<DisposedRuleInterceptor>();324+ std::shared_ptr<DisposedRuleInterceptor> interceptor =
325+ std::make_shared<DisposedRuleInterceptor>(TaskHandlerWrap::CreateQueueHandler("StartNonBlockRule_006"));
325 Want want;326 Want want;
326 want.SetElementName("", "test.bundleName123", "test.abilityName", "test.entry");327 want.SetElementName("", "test.bundleName123", "test.abilityName", "test.entry");
327 AppExecFwk::DisposedRule rule;328 AppExecFwk::DisposedRule rule;
@@ -329,7 +330,6 @@ HWTEST_F(DisposedRuleInterceptorTest, StartNonBlockRule_006, TestSize.Level1)
329 rule.want->SetElementName("", "test.bundleName321", "test.abilityName", "test.entry");330 rule.want->SetElementName("", "test.bundleName321", "test.abilityName", "test.entry");
330 auto abilityInfo = std::make_shared<AppExecFwk::AbilityInfo>();331 auto abilityInfo = std::make_shared<AppExecFwk::AbilityInfo>();
331 abilityInfo->uid = 100;332 abilityInfo->uid = 100;
332- interceptor->taskHandler_ = TaskHandlerWrap::CreateQueueHandler("StartNonBlockRule_006");
333 auto ret = interceptor->StartNonBlockRule(want, rule, abilityInfo);333 auto ret = interceptor->StartNonBlockRule(want, rule, abilityInfo);
334 EXPECT_EQ(ret, ERR_OK);334 EXPECT_EQ(ret, ERR_OK);
335 TAG_LOGI(AAFwkTag::TEST, "StartNonBlockRule_006 end");335 TAG_LOGI(AAFwkTag::TEST, "StartNonBlockRule_006 end");
@@ -349,8 +349,8 @@ HWTEST_F(DisposedRuleInterceptorTest, StartNonBlockRule_007, TestSize.Level1)
349 EXPECT_CALL(*appMgr, RegisterApplicationStateObserver(_, _))349 EXPECT_CALL(*appMgr, RegisterApplicationStateObserver(_, _))
350 .WillOnce(Return(ERR_OK));350 .WillOnce(Return(ERR_OK));
351 351 
352- std::shared_ptr<DisposedRuleInterceptor> interceptor = std::make_shared<DisposedRuleInterceptor>();352+ std::shared_ptr<DisposedRuleInterceptor> interceptor =
353- interceptor->taskHandler_ = TaskHandlerWrap::CreateQueueHandler("test_start_non_block_007");353+ std::make_shared<DisposedRuleInterceptor>(TaskHandlerWrap::CreateQueueHandler("test_start_non_block_007"));
354 Want want;354 Want want;
355 want.SetElementName("", "test.bundleName123", "test.abilityName", "test.entry");355 want.SetElementName("", "test.bundleName123", "test.abilityName", "test.entry");
356 AppExecFwk::DisposedRule rule;356 AppExecFwk::DisposedRule rule;
@@ -933,9 +933,7 @@ HWTEST_F(DisposedRuleInterceptorTest, FindBlockDisposedRule_006, TestSize.Level1
933HWTEST_F(DisposedRuleInterceptorTest, UnregisterObserver_001, TestSize.Level1)933HWTEST_F(DisposedRuleInterceptorTest, UnregisterObserver_001, TestSize.Level1)
934{934{
935 TAG_LOGI(AAFwkTag::TEST, "UnregisterObserver_001 start");935 TAG_LOGI(AAFwkTag::TEST, "UnregisterObserver_001 start");
936- auto interceptor = std::make_shared<DisposedRuleInterceptor>();936+ auto interceptor = std::make_shared<DisposedRuleInterceptor>(nullptr);
937- // Explicitly set taskHandler to nullptr to ensure null pointer check is tested
938- interceptor->taskHandler_ = nullptr;
939 int32_t uid = 1001;937 int32_t uid = 1001;
940 interceptor->UnregisterObserver(uid);938 interceptor->UnregisterObserver(uid);
941 // Verify taskHandler is still null after the call939 // Verify taskHandler is still null after the call
@@ -952,8 +950,8 @@ HWTEST_F(DisposedRuleInterceptorTest, UnregisterObserver_001, TestSize.Level1)
952HWTEST_F(DisposedRuleInterceptorTest, UnregisterObserver_002, TestSize.Level1)950HWTEST_F(DisposedRuleInterceptorTest, UnregisterObserver_002, TestSize.Level1)
953{951{
954 TAG_LOGI(AAFwkTag::TEST, "UnregisterObserver_002 start");952 TAG_LOGI(AAFwkTag::TEST, "UnregisterObserver_002 start");
955- auto interceptor = std::make_shared<DisposedRuleInterceptor>();953+ auto interceptor =
956- interceptor->taskHandler_ = TaskHandlerWrap::CreateQueueHandler("test_unregister_002");954+ std::make_shared<DisposedRuleInterceptor>(TaskHandlerWrap::CreateQueueHandler("test_unregister_002"));
957 int32_t uid = 1001;955 int32_t uid = 1001;
958 interceptor->UnregisterObserver(uid);956 interceptor->UnregisterObserver(uid);
959 EXPECT_EQ(interceptor->disposedObserverMap_.size(), 0);957 EXPECT_EQ(interceptor->disposedObserverMap_.size(), 0);
@@ -976,8 +974,8 @@ HWTEST_F(DisposedRuleInterceptorTest, UnregisterObserver_003, TestSize.Level1)
976 EXPECT_CALL(*appMgr, UnregisterApplicationStateObserver(_))974 EXPECT_CALL(*appMgr, UnregisterApplicationStateObserver(_))
977 .WillOnce(Return(ERR_OK));975 .WillOnce(Return(ERR_OK));
978 976 
979- auto interceptor = std::make_shared<DisposedRuleInterceptor>();977+ auto interceptor =
980- interceptor->taskHandler_ = TaskHandlerWrap::CreateQueueHandler("test_unregister_003");978+ std::make_shared<DisposedRuleInterceptor>(TaskHandlerWrap::CreateQueueHandler("test_unregister_003"));
981 979 
982 int32_t uid = 100;980 int32_t uid = 100;
983 Want want;981 Want want;
@@ -1020,8 +1018,8 @@ HWTEST_F(DisposedRuleInterceptorTest, UnregisterObserver_004, TestSize.Level1)
1020 EXPECT_CALL(*appMgr, UnregisterApplicationStateObserver(_))1018 EXPECT_CALL(*appMgr, UnregisterApplicationStateObserver(_))
1021 .WillOnce(Return(ERR_OK));1019 .WillOnce(Return(ERR_OK));
1022 1020 
1023- auto interceptor = std::make_shared<DisposedRuleInterceptor>();1021+ auto interceptor =
1024- interceptor->taskHandler_ = TaskHandlerWrap::CreateQueueHandler("test_unregister_004");1022+ std::make_shared<DisposedRuleInterceptor>(TaskHandlerWrap::CreateQueueHandler("test_unregister_004"));
1025 1023 
1026 int32_t uid = 100;1024 int32_t uid = 100;
1027 Want want;1025 Want want;
@@ -1,72 +0,0 @@
1-# Copyright (c) 2024 Huawei Device Co., Ltd.
2-# Licensed under the Apache License, Version 2.0 (the "License");
3-# you may not use this file except in compliance with the License.
4-# You may obtain a copy of the License at
5-#
6-# http://www.apache.org/licenses/LICENSE-2.0
7-#
8-# Unless required by applicable law or agreed to in writing, software
9-# distributed under the License is distributed on an "AS IS" BASIS,
10-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11-# See the License for the specific language governing permissions and
12-# limitations under the License.
13- 
14-import("//build/test.gni")
15-import("//foundation/ability/ability_runtime/ability_runtime.gni")
16- 
17-module_output_path = "ability_runtime/ability_runtime/abilitymgr"
18- 
19-ohos_unittest("start_other_app_interceptor_test") {
20- module_out_path = module_output_path
21- 
22- cflags_cc = []
23- include_dirs = [
24- "${ability_runtime_services_path}/abilitymgr/include/utils",
25- "${ability_runtime_services_path}/abilitymgr/include",
26- 
27- "${ability_runtime_services_path}/appmgr/include",
28- ]
29- 
30- sources = [
31- "${ability_runtime_services_path}/abilitymgr/src/interceptor/start_other_app_interceptor.cpp",
32- "start_other_app_interceptor_test.cpp",
33- ]
34- 
35- configs = [ "${ability_runtime_services_path}/abilitymgr:abilityms_config" ]
36- cflags = []
37- if (target_cpu == "arm") {
38- cflags += [ "-DBINDER_IPC_32BIT" ]
39- }
40- deps = [
41- "${ability_runtime_innerkits_path}/app_manager:app_manager",
42- "${ability_runtime_services_path}/abilitymgr:abilityms",
43- "${ability_runtime_services_path}/appmgr:libappms",
44- "${ability_runtime_services_path}/common:perm_verification",
45- ]
46- 
47- external_deps = [
48- "ability_base:want",
49- "ability_base:zuri",
50- "access_token:libaccesstoken_sdk",
51- "access_token:libtokenid_sdk",
52- "bundle_framework:appexecfwk_base",
53- "bundle_framework:appexecfwk_core",
54- "c_utils:utils",
55- "eventhandler:libeventhandler",
56- "ffrt:libffrt",
57- "googletest:gmock_main",
58- "googletest:gtest_main",
59- "hilog:libhilog",
60- "init:libbegetutil",
61- "ipc:ipc_core",
62- ]
63- if (os_dlp_part_enabled) {
64- cflags_cc += [ "-DWITH_DLP" ]
65- }
66-}
67- 
68-group("unittest") {
69- testonly = true
70- 
71- deps = [ ":start_other_app_interceptor_test" ]
72-}
@@ -1,270 +0,0 @@
1-/*
2- * Copyright (c) 2024 Huawei Device Co., Ltd.
3- * Licensed under the Apache License, Version 2.0 (the "License");
4- * you may not use this file except in compliance with the License.
5- * You may obtain a copy of the License at
6- *
7- * http://www.apache.org/licenses/LICENSE-2.0
8- *
9- * Unless required by applicable law or agreed to in writing, software
10- * distributed under the License is distributed on an "AS IS" BASIS,
11- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12- * See the License for the specific language governing permissions and
13- * limitations under the License.
14- */
15- 
16-#include <gtest/gtest.h>
17-#include <gtest/gtest.h>
18- 
19-#define private public
20-#include "interceptor/start_other_app_interceptor.h"
21-#undef private
22-#include "start_ability_utils.h"
23- 
24-using namespace testing;
25-using namespace testing::ext;
26-using namespace OHOS::AppExecFwk;
27- 
28-namespace OHOS {
29-namespace AAFwk {
30-thread_local bool StartAbilityUtils::skipStartOther = false;
31- 
32-class StartOtherAppInterceptorTest : public testing::Test {
33-public:
34- static void SetUpTestCase();
35- static void TearDownTestCase();
36- void SetUp();
37- void TearDown();
38-};
39- 
40-void StartOtherAppInterceptorTest::SetUpTestCase()
41-{}
42- 
43-void StartOtherAppInterceptorTest::TearDownTestCase()
44-{}
45- 
46-void StartOtherAppInterceptorTest::SetUp()
47-{}
48- 
49-void StartOtherAppInterceptorTest::TearDown()
50-{}
51- 
52-/**
53- * @tc.name: CheckNativeCall_001
54- * @tc.desc: test function CheckNaticeCall when call from shell
55- * @tc.type: FUNC
56- */
57-HWTEST_F(StartOtherAppInterceptorTest, CheckNativeCall_001, TestSize.Level1)
58-{
59- auto interceptor = std::make_shared<StartOtherAppInterceptor>();
60- bool res = interceptor->CheckNativeCall();
61- EXPECT_TRUE(res);
62-}
63- 
64-/**
65- * @tc.name: CheckCallerIsSystemApp_001
66- * @tc.desc: test function CheckCallerIsSystemApp when call from shell
67- * @tc.type: FUNC
68- */
69-HWTEST_F(StartOtherAppInterceptorTest, CheckCallerIsSystemApp_001, TestSize.Level1)
70-{
71- auto interceptor = std::make_shared<StartOtherAppInterceptor>();
72- bool res = interceptor->CheckCallerIsSystemApp();
73- EXPECT_FALSE(res);
74-}
75- 
76-/**
77- * @tc.name: GetApplicationInfo_001
78- * @tc.desc: test function GetApplicationInfo when callerToken is nullptr
79- * @tc.type: FUNC
80- */
81-HWTEST_F(StartOtherAppInterceptorTest, GetApplicationInfo_001, TestSize.Level1)
82-{
83- auto interceptor = std::make_shared<StartOtherAppInterceptor>();
84- AppExecFwk::ApplicationInfo applicationInfo;
85- bool res = interceptor->GetApplicationInfo(nullptr, applicationInfo);
86- EXPECT_FALSE(res);
87-}
88- 
89-/**
90- * @tc.name: GetApplicationInfo_002
91- * @tc.desc: test function GetApplicationInfo when callerToken is nullptr
92- * @tc.type: FUNC
93- */
94-HWTEST_F(StartOtherAppInterceptorTest, GetApplicationInfo_002, TestSize.Level1)
95-{
96- auto interceptor = std::make_shared<StartOtherAppInterceptor>();
97- AppExecFwk::ApplicationInfo applicationInfo;
98- sptr<IRemoteObject> callerToken;
99- bool res = interceptor->GetApplicationInfo(callerToken, applicationInfo);
100- EXPECT_FALSE(res);
101-}
102- 
103-/**
104- * @tc.name: CheckAncoShellCall_001
105- * @tc.desc: test function CheckAncoShellCall when caller is anco shell
106- * @tc.type: FUNC
107- */
108-HWTEST_F(StartOtherAppInterceptorTest, CheckAncoShellCall_001, TestSize.Level1)
109-{
110- auto interceptor = std::make_shared<StartOtherAppInterceptor>();
111- AppExecFwk::ApplicationInfo applicationInfo;
112- Want want;
113- ElementName element("", "com.shell_assistant", "MainAbility");
114- want.SetElement(element);
115- bool res = interceptor->CheckAncoShellCall(applicationInfo, want);
116- EXPECT_FALSE(res);
117-}
118- 
119-/**
120- * @tc.name: CheckAncoShellCall_002
121- * @tc.desc: test function CheckAncoShellCall when caller is not anco shell
122- * @tc.type: FUNC
123- */
124-HWTEST_F(StartOtherAppInterceptorTest, CheckAncoShellCall_002, TestSize.Level1)
125-{
126- auto interceptor = std::make_shared<StartOtherAppInterceptor>();
127- AppExecFwk::ApplicationInfo applicationInfo;
128- applicationInfo.codePath = "1";
129- Want want;
130- ElementName element("", "com.test.demo", "MainAbility");
131- want.SetElement(element);
132- bool res = interceptor->CheckAncoShellCall(applicationInfo, want);
133- EXPECT_TRUE(res);
134-}
135- 
136-/**
137- * @tc.name: CheckStartOtherApp_001
138- * @tc.desc: test function CheckStartOtherApp when start the same app
139- * @tc.type: FUNC
140- */
141-HWTEST_F(StartOtherAppInterceptorTest, CheckStartOtherApp_001, TestSize.Level1)
142-{
143- auto interceptor = std::make_shared<StartOtherAppInterceptor>();
144- Want want;
145- ElementName element("", "com.test.demo", "MainAbility");
146- want.SetElement(element);
147- std::string bundleName = "com.test.demo";
148- want.SetParam(Want::PARAM_RESV_CALLER_BUNDLE_NAME, bundleName);
149- bool res = interceptor->CheckStartOtherApp(want);
150- EXPECT_FALSE(res);
151-}
152- 
153-/**
154- * @tc.name: CheckStartOtherApp_002
155- * @tc.desc: test function CheckStartOtherApp when start other app
156- * @tc.type: FUNC
157- */
158-HWTEST_F(StartOtherAppInterceptorTest, CheckStartOtherApp_002, TestSize.Level1)
159-{
160- auto interceptor = std::make_shared<StartOtherAppInterceptor>();
161- Want want;
162- ElementName element("", "com.test.demo2", "MainAbility");
163- want.SetElement(element);std::string bundleName = "com.test.demo";
164- want.SetParam(Want::PARAM_RESV_CALLER_BUNDLE_NAME, bundleName);
165- bool res = interceptor->CheckStartOtherApp(want);
166- EXPECT_TRUE(res);
167-}
168- 
169-/**
170- * @tc.name: CheckCallerApiBelow12_001
171- * @tc.desc: test function CheckCallerApiBelow12 when api is 12
172- * @tc.type: FUNC
173- */
174-HWTEST_F(StartOtherAppInterceptorTest, CheckCallerApiBelow12_001, TestSize.Level1)
175-{
176- auto interceptor = std::make_shared<StartOtherAppInterceptor>();
177- AppExecFwk::ApplicationInfo applicationInfo;
178- applicationInfo.apiTargetVersion = 12;
179- bool res = interceptor->CheckCallerApiBelow12(applicationInfo);
180- EXPECT_FALSE(res);
181-}
182- 
183-/**
184- * @tc.name: CheckCallerApiBelow12_002
185- * @tc.desc: test function CheckCallerApiBelow12 when api is 11
186- * @tc.type: FUNC
187- */
188-HWTEST_F(StartOtherAppInterceptorTest, CheckCallerApiBelow12_002, TestSize.Level1)
189-{
190- auto interceptor = std::make_shared<StartOtherAppInterceptor>();
191- AppExecFwk::ApplicationInfo applicationInfo;
192- applicationInfo.apiCompatibleVersion = 11;
193- bool res = interceptor->CheckCallerApiBelow12(applicationInfo);
194- EXPECT_TRUE(res);
195-}
196- 
197-/**
198- * @tc.name: DoProcess_001
199- * @tc.desc: test function DoProcess when background call
200- * @tc.type: FUNC
201- */
202-HWTEST_F(StartOtherAppInterceptorTest, DoProcess_001, TestSize.Level1)
203-{
204- auto interceptor = std::make_shared<StartOtherAppInterceptor>();
205- Want want;
206- auto shouldBlockFunc = []() { return false; };
207- AbilityInterceptorParam param = AbilityInterceptorParam(want, 0, 0, false, nullptr,
208- shouldBlockFunc);
209- int32_t res = interceptor->DoProcess(param);
210- EXPECT_EQ(res, ERR_OK);
211-}
212- 
213-/**
214- * @tc.name: DoProcess_002
215- * @tc.desc: test function DoProcess when shell call
216- * @tc.type: FUNC
217- */
218-HWTEST_F(StartOtherAppInterceptorTest, DoProcess_002, TestSize.Level1)
219-{
220- auto interceptor = std::make_shared<StartOtherAppInterceptor>();
221- Want want;
222- auto shouldBlockFunc = []() { return false; };
223- AbilityInterceptorParam param = AbilityInterceptorParam(want, 0, 0, false, nullptr,
224- shouldBlockFunc);
225- int32_t res = interceptor->DoProcess(param);
226- EXPECT_EQ(res, ERR_OK);
227-}
228- 
229-/**
230- * @tc.name: CheckTargetIsSystemApp_001
231- * @tc.desc: test function CheckTargetIsSystemApp when applicationInfo is true
232- * @tc.type: FUNC
233- */
234-HWTEST_F(StartOtherAppInterceptorTest, CheckTargetIsSystemApp_001, TestSize.Level1)
235-{
236- std::shared_ptr<StartOtherAppInterceptor> interceptor = std::make_shared<StartOtherAppInterceptor>();
237- AppExecFwk::ApplicationInfo applicationInfo;
238- applicationInfo.isSystemApp = true;
239- bool res = interceptor->CheckTargetIsSystemApp(applicationInfo);
240- EXPECT_EQ(res, true);
241-}
242- 
243-/**
244- * @tc.name: CheckTargetIsSystemApp_002
245- * @tc.desc: test function CheckTargetIsSystemApp when applicationInfo is false
246- * @tc.type: FUNC
247- */
248-HWTEST_F(StartOtherAppInterceptorTest, CheckTargetIsSystemApp_002, TestSize.Level1)
249-{
250- std::shared_ptr<StartOtherAppInterceptor> interceptor = std::make_shared<StartOtherAppInterceptor>();
251- AppExecFwk::ApplicationInfo applicationInfo;
252- applicationInfo.isSystemApp = false;
253- bool res = interceptor->CheckTargetIsSystemApp(applicationInfo);
254- EXPECT_EQ(res, false);
255-}
256- 
257-/**
258- * @tc.name: IsDelegatorCall_001
259- * @tc.desc: test function IsDelegatorCall when applicationInfo is true
260- * @tc.type: FUNC
261- */
262-HWTEST_F(StartOtherAppInterceptorTest, IsDelegatorCall_001, TestSize.Level1)
263-{
264- std::shared_ptr<StartOtherAppInterceptor> interceptor = std::make_shared<StartOtherAppInterceptor>();
265- Want want;
266- bool res = interceptor->IsDelegatorCall(want);
267- EXPECT_EQ(res, false);
268-}
269-} // namespace AAFwk
270-} // namespace OHOS