From e7e4d896babe4e3597a570ada1aea672ff5733a6 Mon Sep 17 00:00:00 2001 From: donglin Date: Thu, 25 Apr 2024 12:38:07 +0000 Subject: [PATCH 001/174] =?UTF-8?q?=E9=93=BE=E6=8E=A5=E8=B7=B3=E8=BD=AC?= =?UTF-8?q?=E7=AE=A1=E6=8E=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: donglin Change-Id: I835304597ea713b61e352c11312ffe410cd0da27 --- ...bility_ecological_rule_mgr_service_param.h | 4 +- .../interceptor/ecological_rule_interceptor.h | 3 +- .../abilitymgr/include/start_ability_utils.h | 8 +++- .../src/ability_manager_service.cpp | 12 ++--- ...lity_ecological_rule_mgr_service_param.cpp | 19 +++++--- .../ecological_rule_interceptor.cpp | 47 +++++++++++-------- .../abilitymgr/src/start_ability_utils.cpp | 44 ++++++++++++++++- 7 files changed, 100 insertions(+), 37 deletions(-) diff --git a/services/abilitymgr/include/ecological_rule/ability_ecological_rule_mgr_service_param.h b/services/abilitymgr/include/ecological_rule/ability_ecological_rule_mgr_service_param.h index db5541ffe7..ea12333645 100644 --- a/services/abilitymgr/include/ecological_rule/ability_ecological_rule_mgr_service_param.h +++ b/services/abilitymgr/include/ecological_rule/ability_ecological_rule_mgr_service_param.h @@ -21,6 +21,7 @@ #include "parcel.h" #include "want.h" +#include "ability_info.h" namespace OHOS { namespace EcologicalRuleMgrService { @@ -69,10 +70,11 @@ struct AbilityCallerInfo : public Parcelable { std::string targetAppDistType = ""; std::string targetLinkFeature = ""; int32_t targetLinkType = LINK_TYPE_INVALID; - int32_t callerAbilityType = 0L; + AppExecFwk::AbilityType callerAbilityType = AppExecFwk::AbilityType::UNKNOWN; int32_t embedded = 0; std::string callerAppProvisionType; std::string targetAppProvisionType; + AppExecFwk::ExtensionAbilityType callerExtensionAbilityType = AppExecFwk::ExtensionAbilityType::UNSPECIFIED; bool ReadFromParcel(Parcel &parcel); diff --git a/services/abilitymgr/include/interceptor/ecological_rule_interceptor.h b/services/abilitymgr/include/interceptor/ecological_rule_interceptor.h index 8e3b693fd3..9f9bd8aecf 100644 --- a/services/abilitymgr/include/interceptor/ecological_rule_interceptor.h +++ b/services/abilitymgr/include/interceptor/ecological_rule_interceptor.h @@ -40,7 +40,8 @@ public: }; private: - void GetEcologicalCallerInfo(const Want &want, ErmsCallerInfo &callerInfo, int32_t userId); + void GetEcologicalCallerInfo(const Want &want, ErmsCallerInfo &callerInfo, int32_t userId, + const sptr &callerToken = nullptr); void InitErmsCallerInfo(Want &want, ErmsCallerInfo &callerInfo) const; }; } // namespace AAFwk diff --git a/services/abilitymgr/include/start_ability_utils.h b/services/abilitymgr/include/start_ability_utils.h index a94788af8c..287e54e2ba 100644 --- a/services/abilitymgr/include/start_ability_utils.h +++ b/services/abilitymgr/include/start_ability_utils.h @@ -30,6 +30,7 @@ struct StartAbilityInfo { AppExecFwk::AbilityInfo &abilityInfo); static std::shared_ptr CreateStartAbilityInfo(const Want &want, int32_t userId, int32_t appIndex); + static std::shared_ptr CreateCallerAbilityInfo(const sptr &callerToken); static std::shared_ptr CreateStartExtensionInfo(const Want &want, int32_t userId, int32_t appIndex); @@ -48,15 +49,18 @@ struct StartAbilityUtils { static int32_t GetAppIndex(const Want &want, sptr callerToken); static bool GetApplicationInfo(const std::string &bundleName, int32_t userId, AppExecFwk::ApplicationInfo &appInfo); + static bool GetCallerAbilityInfo(const sptr &callerToken, + AppExecFwk::AbilityInfo &abilityInfo); static thread_local std::shared_ptr startAbilityInfo; - + static thread_local std::shared_ptr callerAbilityInfo; static thread_local bool skipCrowTest; static thread_local bool skipStartOther; static thread_local bool skipErms; }; struct StartAbilityInfoWrap { - StartAbilityInfoWrap(const Want &want, int32_t validUserId, int32_t appIndex, bool isExtension = false); + StartAbilityInfoWrap(const Want &want, int32_t validUserId, int32_t appIndex, + const sptr &callerToken, bool isExtension = false); ~StartAbilityInfoWrap(); }; } diff --git a/services/abilitymgr/src/ability_manager_service.cpp b/services/abilitymgr/src/ability_manager_service.cpp index a6e1f553c7..48f79cd0de 100644 --- a/services/abilitymgr/src/ability_manager_service.cpp +++ b/services/abilitymgr/src/ability_manager_service.cpp @@ -877,7 +877,7 @@ int AbilityManagerService::StartAbilityInner(const Want &want, const sptr sessionInfo) auto requestCode = sessionInfo->requestCode; StartAbilityInfoWrap threadLocalInfo(sessionInfo->want, currentUserId, - StartAbilityUtils::GetAppIndex(sessionInfo->want, sessionInfo->callerToken)); + StartAbilityUtils::GetAppIndex(sessionInfo->want, sessionInfo->callerToken), sessionInfo->callerToken); if (sessionInfo->want.GetBoolParam(IS_CALL_BY_SCB, true)) { TAG_LOGD(AAFwkTag::ABILITYMGR, "interceptorExecuter_ called."); AbilityInterceptorParam interceptorParam = AbilityInterceptorParam(sessionInfo->want, requestCode, @@ -2388,7 +2388,7 @@ int AbilityManagerService::StartExtensionAbilityInner(const Want &want, const sp int32_t validUserId = GetValidUserId(userId); StartAbilityInfoWrap threadLocalInfo(want, validUserId, - StartAbilityUtils::GetAppIndex(want, callerToken), true); + StartAbilityUtils::GetAppIndex(want, callerToken), callerToken, true); AbilityInterceptorParam interceptorParam = AbilityInterceptorParam(want, 0, GetUserId(), false, nullptr); result = interceptorExecuter_ == nullptr ? ERR_INVALID_VALUE : interceptorExecuter_->DoProcess(interceptorParam); @@ -6428,7 +6428,7 @@ int AbilityManagerService::StartAbilityByCall(const Want &want, const sptr(want)); StartAbilityInfoWrap threadLocalInfo(want, GetUserId(), - StartAbilityUtils::GetAppIndex(want, callerToken)); + StartAbilityUtils::GetAppIndex(want, callerToken), callerToken); AbilityInterceptorParam interceptorParam = AbilityInterceptorParam(want, 0, GetUserId(), true, nullptr); auto result = interceptorExecuter_ == nullptr ? ERR_INVALID_VALUE : interceptorExecuter_->DoProcess(interceptorParam); diff --git a/services/abilitymgr/src/ecological_rule/ability_ecological_rule_mgr_service_param.cpp b/services/abilitymgr/src/ecological_rule/ability_ecological_rule_mgr_service_param.cpp index 60b12c2e91..704a24832a 100644 --- a/services/abilitymgr/src/ecological_rule/ability_ecological_rule_mgr_service_param.cpp +++ b/services/abilitymgr/src/ecological_rule/ability_ecological_rule_mgr_service_param.cpp @@ -125,15 +125,12 @@ AbilityCallerInfo *AbilityCallerInfo::Unmarshalling(Parcel &in) return nullptr; } - if (!in.ReadInt32(info->callerAbilityType)) { - TAG_LOGE(AAFwkTag::ECOLOGICAL_RULE, "read callerAbilityType failed"); - delete info; - return nullptr; - } + info->callerAbilityType = static_cast(in.ReadInt32()); info->embedded = in.ReadInt32(); info->callerAppProvisionType = in.ReadString(); info->targetAppProvisionType = in.ReadString(); + info->callerExtensionAbilityType = static_cast(in.ReadInt32()); return info; } @@ -157,6 +154,11 @@ bool AbilityCallerInfo::Marshalling(Parcel &parcel) const TAG_LOGE(AAFwkTag::ECOLOGICAL_RULE, "write targetAppProvisionType failed"); return false; } + + if (!parcel.WriteInt32(static_cast(callerExtensionAbilityType))) { + TAG_LOGE(AAFwkTag::ECOLOGICAL_RULE, "write callerExtensionAbilityType failed"); + return false; + } return true; } @@ -207,10 +209,11 @@ bool AbilityCallerInfo::DoMarshallingOne(Parcel &parcel) const return false; } - if (!parcel.WriteInt32(callerAbilityType)) { + if (!parcel.WriteInt32(static_cast(callerAbilityType))) { TAG_LOGE(AAFwkTag::ECOLOGICAL_RULE, "write callerAbilityType failed"); return false; } + return true; } @@ -220,7 +223,9 @@ std::string AbilityCallerInfo::ToString() const ",pid:" + std::to_string(pid) + ",callerAppType:" + std::to_string(callerAppType) + ",targetAppType:" + std::to_string(targetAppType) + ",callerModelType:" + std::to_string(callerModelType) + ",targetAppDistType:" + targetAppDistType + ",targetLinkFeature:" + targetLinkFeature + ",targetLinkType:" + - std::to_string(targetLinkType) + ",callerAbilityType:" + std::to_string(callerAbilityType) + ",embedded:" + + std::to_string(targetLinkType) + ",callerAbilityType:" + + std::to_string(static_cast(callerAbilityType)) + ",callerExtensionAbilityType:" + + std::to_string(static_cast(callerExtensionAbilityType)) + ",embedded:" + std::to_string(embedded) + ",callerAppProvisionType:" + callerAppProvisionType + ",targetAppProvisionType:" + targetAppProvisionType + "}"; return str; diff --git a/services/abilitymgr/src/interceptor/ecological_rule_interceptor.cpp b/services/abilitymgr/src/interceptor/ecological_rule_interceptor.cpp index 243fbb120e..e18970b521 100644 --- a/services/abilitymgr/src/interceptor/ecological_rule_interceptor.cpp +++ b/services/abilitymgr/src/interceptor/ecological_rule_interceptor.cpp @@ -54,7 +54,7 @@ ErrCode EcologicalRuleInterceptor::DoProcess(AbilityInterceptorParam param) } AAFwk::Want newWant = param.want; newWant.RemoveAllFd(); - GetEcologicalCallerInfo(newWant, callerInfo, param.userId); + GetEcologicalCallerInfo(newWant, callerInfo, param.userId, param.callerToken); std::string supportErms = OHOS::system::GetParameter(ABILITY_SUPPORT_ECOLOGICAL_RULEMGRSERVICE, "true"); if (supportErms == "false") { TAG_LOGE(AAFwkTag::ECOLOGICAL_RULE, "Abilityms not support Erms between applications."); @@ -128,30 +128,39 @@ bool EcologicalRuleInterceptor::DoProcess(Want &want, int32_t userId) return rule.isAllow; } -void EcologicalRuleInterceptor::GetEcologicalCallerInfo(const Want &want, ErmsCallerInfo &callerInfo, int32_t userId) +void EcologicalRuleInterceptor::GetEcologicalCallerInfo(const Want &want, ErmsCallerInfo &callerInfo, int32_t userId, + const sptr &callerToken) { HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); InitErmsCallerInfo(const_cast(want), callerInfo); - auto bundleMgrHelper = AbilityUtil::GetBundleManagerHelper(); - if (bundleMgrHelper == nullptr) { - TAG_LOGE(AAFwkTag::ECOLOGICAL_RULE, "The bundleMgrHelper is nullptr."); - return; - } - - std::string callerBundleName; - ErrCode err = IN_PROCESS_CALL(bundleMgrHelper->GetNameForUid(callerInfo.uid, callerBundleName)); - if (err != ERR_OK) { - TAG_LOGE(AAFwkTag::ECOLOGICAL_RULE, "Get callerBundleName failed,uid: %{public}d.", callerInfo.uid); - return; - } AppExecFwk::ApplicationInfo callerAppInfo; - bool getCallerResult = IN_PROCESS_CALL(bundleMgrHelper->GetApplicationInfo(callerBundleName, - AppExecFwk::ApplicationFlag::GET_BASIC_APPLICATION_INFO, userId, callerAppInfo)); - if (!getCallerResult) { - TAG_LOGD(AAFwkTag::ECOLOGICAL_RULE, "Get callerAppInfo failed."); - return; + AppExecFwk::AbilityInfo callerAbilityInfo; + if (StartAbilityUtils::GetCallerAbilityInfo(callerToken, callerAbilityInfo)) { + callerAppInfo = callerAbilityInfo.applicationInfo; + callerInfo.callerAbilityType = callerAbilityInfo.type; + callerInfo.callerExtensionAbilityType = callerAbilityInfo.extensionAbilityType; + } else { + auto bundleMgrHelper = AbilityUtil::GetBundleManagerHelper(); + if (bundleMgrHelper == nullptr) { + TAG_LOGE(AAFwkTag::ECOLOGICAL_RULE, "The bundleMgrHelper is nullptr."); + return; + } + + std::string callerBundleName; + ErrCode err = IN_PROCESS_CALL(bundleMgrHelper->GetNameForUid(callerInfo.uid, callerBundleName)); + if (err != ERR_OK) { + TAG_LOGE(AAFwkTag::ECOLOGICAL_RULE, "Get callerBundleName failed,uid: %{public}d.", callerInfo.uid); + return; + } + bool getCallerResult = IN_PROCESS_CALL(bundleMgrHelper->GetApplicationInfo(callerBundleName, + AppExecFwk::ApplicationFlag::GET_BASIC_APPLICATION_INFO, userId, callerAppInfo)); + if (!getCallerResult) { + TAG_LOGD(AAFwkTag::ECOLOGICAL_RULE, "Get callerAppInfo failed."); + return; + } } + callerInfo.callerAppProvisionType = callerAppInfo.appProvisionType; if (callerAppInfo.bundleType == AppExecFwk::BundleType::ATOMIC_SERVICE) { TAG_LOGD(AAFwkTag::ECOLOGICAL_RULE, "the caller type is atomic service"); diff --git a/services/abilitymgr/src/start_ability_utils.cpp b/services/abilitymgr/src/start_ability_utils.cpp index eefc88da68..cc4b096b86 100644 --- a/services/abilitymgr/src/start_ability_utils.cpp +++ b/services/abilitymgr/src/start_ability_utils.cpp @@ -31,6 +31,7 @@ constexpr const char* SCREENSHOT_BUNDLE_NAME = "com.huawei.ohos.screenshot"; constexpr const char* SCREENSHOT_ABILITY_NAME = "com.huawei.ohos.screenshot.ServiceExtAbility"; } thread_local std::shared_ptr StartAbilityUtils::startAbilityInfo; +thread_local std::shared_ptr StartAbilityUtils::callerAbilityInfo; thread_local bool StartAbilityUtils::skipCrowTest = false; thread_local bool StartAbilityUtils::skipStartOther = false; thread_local bool StartAbilityUtils::skipErms = false; @@ -66,8 +67,26 @@ bool StartAbilityUtils::GetApplicationInfo(const std::string &bundleName, int32_ return true; } +bool StartAbilityUtils::GetCallerAbilityInfo(const sptr &callerToken, + AppExecFwk::AbilityInfo &abilityInfo) +{ + if (StartAbilityUtils::callerAbilityInfo) { + abilityInfo = StartAbilityUtils::callerAbilityInfo->abilityInfo; + } else { + if (callerToken == nullptr) { + return false; + } + auto abilityRecord = Token::GetAbilityRecordByToken(callerToken); + if (abilityRecord == nullptr) { + return false; + } + abilityInfo = abilityRecord->GetAbilityInfo(); + } + return true; +} + StartAbilityInfoWrap::StartAbilityInfoWrap(const Want &want, int32_t validUserId, int32_t appIndex, - bool isExtension) + const sptr &callerToken, bool isExtension) { if (StartAbilityUtils::startAbilityInfo != nullptr) { TAG_LOGW(AAFwkTag::ABILITYMGR, "startAbilityInfo has been created"); @@ -91,11 +110,17 @@ StartAbilityInfoWrap::StartAbilityInfoWrap(const Want &want, int32_t validUserId StartAbilityUtils::skipCrowTest = true; StartAbilityUtils::skipStartOther = true; } + + if (StartAbilityUtils::callerAbilityInfo != nullptr) { + TAG_LOGW(AAFwkTag::ABILITYMGR, "callerAbilityInfo has been created"); + } + StartAbilityUtils::callerAbilityInfo = StartAbilityInfo::CreateCallerAbilityInfo(callerToken); } StartAbilityInfoWrap::~StartAbilityInfoWrap() { StartAbilityUtils::startAbilityInfo.reset(); + StartAbilityUtils::callerAbilityInfo.reset(); StartAbilityUtils::skipCrowTest = false; StartAbilityUtils::skipStartOther = false; StartAbilityUtils::skipErms = false; @@ -220,5 +245,22 @@ std::shared_ptr StartAbilityInfo::CreateStartExtensionInfo(con return abilityInfo; } + +std::shared_ptr StartAbilityInfo::CreateCallerAbilityInfo(const sptr &callerToken) +{ + HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); + if (callerToken == nullptr) { + TAG_LOGD(AAFwkTag::ABILITYMGR, "not call from context."); + return nullptr; + } + auto abilityRecord = Token::GetAbilityRecordByToken(callerToken); + if (abilityRecord == nullptr) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "can not find abilityRecord"); + return nullptr; + } + auto request = std::make_shared(); + request->abilityInfo = abilityRecord->GetAbilityInfo(); + return request; +} } } \ No newline at end of file From a116d1978e6ede547b81a14723ed024d0cc85c1e Mon Sep 17 00:00:00 2001 From: xinking129 Date: Wed, 1 May 2024 21:07:40 +0800 Subject: [PATCH 002/174] fix assertDialog Signed-off-by: xinking129 --- .../AssertFaultShareExtAbility.ts | 27 +++++---- .../src/main/ets/pages/assertFaultDialog.ets | 57 ++++++------------- 2 files changed, 30 insertions(+), 54 deletions(-) diff --git a/services/dialog_ui/ams_system_dialog/entry/src/main/ets/ShareExtAbility/AssertFaultShareExtAbility.ts b/services/dialog_ui/ams_system_dialog/entry/src/main/ets/ShareExtAbility/AssertFaultShareExtAbility.ts index 32505ff930..4e9a66694e 100644 --- a/services/dialog_ui/ams_system_dialog/entry/src/main/ets/ShareExtAbility/AssertFaultShareExtAbility.ts +++ b/services/dialog_ui/ams_system_dialog/entry/src/main/ets/ShareExtAbility/AssertFaultShareExtAbility.ts @@ -22,6 +22,7 @@ import type UIExtensionContentSession from '@ohos.app.ability.UIExtensionContent const TAG = 'AssertFaultDialog_UIExtension'; const TEXT_DETAIL = 'assertFaultDialogDetail'; +const DEBUG_ASSERT_RESULT = 'assertResult'; export default class UiExtAbility extends UIExtensionAbility { storage: LocalStorage; @@ -44,7 +45,6 @@ export default class UiExtAbility extends UIExtensionAbility { this.storage = new LocalStorage( { 'session': session, - 'sessionId' : this.sessionId, 'textDetail' : want.parameters[TEXT_DETAIL] }); session.loadContent('pages/assertFaultDialog', this.storage); @@ -57,19 +57,18 @@ export default class UiExtAbility extends UIExtensionAbility { onSessionDestroy(session: UIExtensionContentSession): void { console.info(TAG, 'onSessionDestroy'); - console.info(TAG, `isUserAction: ${AppStorage.get('isUserAction')}`); - let isUserAction = AppStorage.get('isUserAction'); - if (isUserAction === undefined) { - let status = abilityManager.UserStatus.ASSERT_TERMINATE; - try { - abilityManager.notifyDebugAssertResult(this.sessionId, status).then(() => { - console.log(TAG, 'notifyDebugAssertResult success.'); - }).catch((err: BusinessError) => { - console.error(TAG, `notifyDebugAssertResult failed, error: ${JSON.stringify(err)}`); - }); - } catch (error) { - console.error(TAG, `try notifyDebugAssertResult failed, error: ${JSON.stringify(error)}`); - } + let assertResult = AppStorage.get(DEBUG_ASSERT_RESULT); + if (assertResult === undefined) { + assertResult = abilityManager.UserStatus.ASSERT_TERMINATE; + } + try { + abilityManager.notifyDebugAssertResult(this.sessionId, assertResult).then(() => { + console.log(TAG, 'notifyDebugAssertResult success.'); + }).catch((err: BusinessError) => { + console.error(TAG, `notifyDebugAssertResult failed, error: ${JSON.stringify(err)}`); + }); + } catch (error) { + console.error(TAG, `try notifyDebugAssertResult failed, error: ${JSON.stringify(error)}`); } } }; diff --git a/services/dialog_ui/ams_system_dialog/entry/src/main/ets/pages/assertFaultDialog.ets b/services/dialog_ui/ams_system_dialog/entry/src/main/ets/pages/assertFaultDialog.ets index 3fe5521908..c5bfb79cce 100644 --- a/services/dialog_ui/ams_system_dialog/entry/src/main/ets/pages/assertFaultDialog.ets +++ b/services/dialog_ui/ams_system_dialog/entry/src/main/ets/pages/assertFaultDialog.ets @@ -19,6 +19,7 @@ import type UIExtensionContentSession from '@ohos.app.ability.UIExtensionContent let storage = LocalStorage.GetShared(); const TAG: string = 'AssertFaultDialog_Page'; +const DEBUG_ASSERT_RESULT: string = 'assertResult'; @Entry(storage) @Component @@ -33,17 +34,11 @@ struct AssertFaultDialog { existApp() { console.info(TAG, 'Exist app called'); try { - let status = abilityManager.UserStatus.ASSERT_TERMINATE; - abilityManager.notifyDebugAssertResult(storage.get('sessionId'), status).then(() => { - console.log(TAG, 'notifyDebugAssertResult termination status success.'); - AppStorage.setOrCreate('isUserAction', true); - storage.get('session').terminateSelf().then(() => { - console.log(TAG, 'terminateSelf success.'); - }).catch((err: BusinessError) => { - console.error(TAG, `terminateSelf failed, error: ${JSON.stringify(err)}`); - }) + AppStorage.setOrCreate(DEBUG_ASSERT_RESULT, abilityManager.UserStatus.ASSERT_TERMINATE); + storage.get('session').terminateSelf().then(() => { + console.log(TAG, 'terminateSelf success.'); }).catch((err: BusinessError) => { - console.error(TAG, `notifyDebugAssertResult failed, error: ${JSON.stringify(err)}`); + console.error(TAG, `terminateSelf failed, error: ${JSON.stringify(err)}`); }) } catch (error) { console.error(TAG, `try notifyDebugAssertResult failed, error: ${JSON.stringify(error)}`); @@ -52,18 +47,12 @@ struct AssertFaultDialog { onContinueCall() { console.info(TAG, 'On continue called'); - let status = abilityManager.UserStatus.ASSERT_CONTINUE; try { - abilityManager.notifyDebugAssertResult(storage.get('sessionId'), status).then(() => { - console.log(TAG, 'notifyDebugAssertResult continue status success.'); - AppStorage.setOrCreate('isUserAction', true); - storage.get('session').terminateSelf().then(() => { - console.log(TAG, 'terminateSelf success.'); - }).catch((err: BusinessError) => { - console.error(TAG, `terminateSelf failed, error: ${JSON.stringify(err)}`); - }) + AppStorage.setOrCreate(DEBUG_ASSERT_RESULT, abilityManager.UserStatus.ASSERT_CONTINUE); + storage.get('session').terminateSelf().then(() => { + console.log(TAG, 'terminateSelf success.'); }).catch((err: BusinessError) => { - console.error(TAG, `notifyDebugAssertResult failed, error: ${JSON.stringify(err)}`); + console.error(TAG, `terminateSelf failed, error: ${JSON.stringify(err)}`); }) } catch (error) { console.error(TAG, `try notifyDebugAssertResult failed, error: ${JSON.stringify(error)}`); @@ -72,18 +61,12 @@ struct AssertFaultDialog { onRetryCall() { console.info(TAG, 'On retry called'); - let status = abilityManager.UserStatus.ASSERT_RETRY; try { - abilityManager.notifyDebugAssertResult(storage.get('sessionId'), status).then(() => { - console.log(TAG, 'notifyDebugAssertResult retry status success.'); - AppStorage.setOrCreate('isUserAction', true); - storage.get('session').terminateSelf().then(() => { - console.log(TAG, 'terminateSelf success.'); - }).catch((err: BusinessError) => { - console.error(TAG, `terminateSelf failed, error: ${JSON.stringify(err)}`); - }) + AppStorage.setOrCreate(DEBUG_ASSERT_RESULT, abilityManager.UserStatus.ASSERT_RETRY); + storage.get('session').terminateSelf().then(() => { + console.log(TAG, 'terminateSelf success.'); }).catch((err: BusinessError) => { - console.error(TAG, `notifyDebugAssertResult failed, error: ${JSON.stringify(err)}`); + console.error(TAG, `terminateSelf failed, error: ${JSON.stringify(err)}`); }) } catch (error) { console.error(TAG, `try notifyDebugAssertResult failed, error: ${JSON.stringify(error)}`); @@ -92,18 +75,12 @@ struct AssertFaultDialog { onTerminationCall() { console.info(TAG, 'On termination called'); - let status = abilityManager.UserStatus.ASSERT_TERMINATE; try { - abilityManager.notifyDebugAssertResult(storage.get('sessionId'), status).then(() => { - console.log(TAG, 'notifyDebugAssertResult termination status success.'); - AppStorage.setOrCreate('isUserAction', true); - storage.get('session').terminateSelf().then(() => { - console.log(TAG, 'terminateSelf success.'); - }).catch((err: BusinessError) => { - console.error(TAG, `terminateSelf failed, error: ${JSON.stringify(err)}`); - }) + AppStorage.setOrCreate(DEBUG_ASSERT_RESULT, abilityManager.UserStatus.ASSERT_TERMINATE); + storage.get('session').terminateSelf().then(() => { + console.log(TAG, 'terminateSelf success.'); }).catch((err: BusinessError) => { - console.error(TAG, `notifyDebugAssertResult failed, error: ${JSON.stringify(err)}`); + console.error(TAG, `terminateSelf failed, error: ${JSON.stringify(err)}`); }) } catch (error) { console.error(TAG, `try notifyDebugAssertResult failed, error: ${JSON.stringify(error)}`); From ca7c972e453a5b46726f8c4b456971e7a9a79200 Mon Sep 17 00:00:00 2001 From: xinking129 Date: Wed, 1 May 2024 21:26:24 +0800 Subject: [PATCH 003/174] add fix code Signed-off-by: xinking129 --- frameworks/native/appkit/app/main_thread.cpp | 10 +++++++ .../include/appmgr/ams_mgr_interface.h | 9 ------ .../include/appmgr/ams_mgr_proxy.h | 8 ------ .../app_manager/include/appmgr/ams_mgr_stub.h | 1 - .../include/appmgr/app_mgr_client.h | 8 ------ .../include/appmgr/app_mgr_interface.h | 7 +++++ .../appmgr/app_mgr_ipc_interface_code.h | 1 + .../include/appmgr/app_mgr_proxy.h | 7 +++++ .../app_manager/include/appmgr/app_mgr_stub.h | 1 + .../app_manager/src/appmgr/ams_mgr_proxy.cpp | 28 ------------------- .../app_manager/src/appmgr/ams_mgr_stub.cpp | 11 -------- .../app_manager/src/appmgr/app_mgr_client.cpp | 8 ------ .../app_manager/src/appmgr/app_mgr_proxy.cpp | 22 +++++++++++++++ .../app_manager/src/appmgr/app_mgr_stub.cpp | 10 +++++++ services/abilitymgr/include/app_scheduler.h | 8 ------ services/abilitymgr/src/app_scheduler.cpp | 6 ---- .../src/assert_fault_callback_death_mgr.cpp | 2 -- services/appmgr/include/ams_mgr_scheduler.h | 8 ------ services/appmgr/include/app_mgr_service.h | 2 ++ .../appmgr/include/app_mgr_service_inner.h | 2 +- services/appmgr/src/ams_mgr_scheduler.cpp | 9 ------ services/appmgr/src/app_mgr_service.cpp | 10 +++++++ services/appmgr/src/app_mgr_service_inner.cpp | 12 +++----- .../app_mgr_client_test.cpp | 14 ---------- 24 files changed, 75 insertions(+), 129 deletions(-) diff --git a/frameworks/native/appkit/app/main_thread.cpp b/frameworks/native/appkit/app/main_thread.cpp index 5aa6400614..3be5bd86e2 100644 --- a/frameworks/native/appkit/app/main_thread.cpp +++ b/frameworks/native/appkit/app/main_thread.cpp @@ -3125,12 +3125,22 @@ void MainThread::AssertFaultPauseMainThreadDetection() { TAG_LOGD(AAFwkTag::APPKIT, "Called."); SetAppDebug(AbilityRuntime::AppFreezeState::AppFreezeFlag::ASSERT_DEBUG_MODE, true); + if (appMgr_ == nullptr) { + TAG_LOGE(AAFwkTag::APPKIT, "appMgr is nullptr."); + return; + } + appMgr_->SetAppAssertionPauseState(true); } void MainThread::AssertFaultResumeMainThreadDetection() { TAG_LOGD(AAFwkTag::APPKIT, "Called."); SetAppDebug(AbilityRuntime::AppFreezeState::AppFreezeFlag::ASSERT_DEBUG_MODE, false); + if (appMgr_ == nullptr) { + TAG_LOGE(AAFwkTag::APPKIT, "appMgr is nullptr."); + return; + } + appMgr_->SetAppAssertionPauseState(false); } void MainThread::HandleInitAssertFaultTask(bool isDebugModule, bool isDebugApp) diff --git a/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_interface.h b/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_interface.h index 19ffa2c25a..d98bc7b9a7 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_interface.h +++ b/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_interface.h @@ -277,14 +277,6 @@ public: */ virtual bool IsAttachDebug(const std::string &bundleName) = 0; - /** - * Set application assertion pause state. - * - * @param pid App process pid. - * @param flag assertion pause state. - */ - virtual void SetAppAssertionPauseState(int32_t pid, bool flag) {} - /** * @brief Set resident process enable status. * @param bundleName The application bundle name. @@ -343,7 +335,6 @@ public: REGISTER_ABILITY_DEBUG_RESPONSE, IS_ATTACH_DEBUG, START_SPECIFIED_PROCESS, - SET_APP_ASSERT_PAUSE_STATE, CLEAR_PROCESS_BY_TOKEN, REGISTER_ABILITY_MS_DELEGATE, KILL_PROCESSES_BY_PIDS, diff --git a/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_proxy.h b/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_proxy.h index cbd091bdf0..0880c1308f 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_proxy.h +++ b/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_proxy.h @@ -254,14 +254,6 @@ public: */ bool IsAttachDebug(const std::string &bundleName) override; - /** - * Set application assertion pause state. - * - * @param pid App process pid. - * @param flag assertion pause state. - */ - void SetAppAssertionPauseState(int32_t pid, bool flag) override; - /** * @brief Set resident process enable status. * @param bundleName The application bundle name. diff --git a/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_stub.h b/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_stub.h index cde52456cd..56f4a46b76 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_stub.h +++ b/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_stub.h @@ -80,7 +80,6 @@ private: int32_t HandleClearNonPersistWaitingDebugFlag(MessageParcel &data, MessageParcel &reply); int32_t HandleRegisterAbilityDebugResponse(MessageParcel &data, MessageParcel &reply); int32_t HandleIsAttachDebug(MessageParcel &data, MessageParcel &reply); - int32_t HandleSetAppAssertionPauseState(MessageParcel &data, MessageParcel &reply); int32_t HandleClearProcessByToken(MessageParcel &data, MessageParcel &reply); int32_t HandleIsMemorySizeSufficent(MessageParcel &data, MessageParcel &reply); int32_t HandleSetKeepAliveEnableState(MessageParcel &data, MessageParcel &reply); diff --git a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_client.h b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_client.h index f18c6ef7ca..e90fb161a6 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_client.h +++ b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_client.h @@ -619,14 +619,6 @@ public: */ void SetKeepAliveEnableState(const std::string &bundleName, bool enable); - /** - * Set application assertion pause state. - * - * @param pid App process pid. - * @param flag assertion pause state. - */ - void SetAppAssertionPauseState(int32_t pid, bool flag); - /** * Register application or process state observer. * @param observer, ability token. diff --git a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_interface.h b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_interface.h index 723d2a714b..ee7240620e 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_interface.h +++ b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_interface.h @@ -652,6 +652,13 @@ public: } virtual int32_t SetSupportedProcessCacheSelf(bool isSupport) = 0; + + /** + * Set application assertion pause state. + * + * @param flag assertion pause state. + */ + virtual void SetAppAssertionPauseState(bool flag) {} }; } // namespace AppExecFwk } // namespace OHOS diff --git a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_ipc_interface_code.h b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_ipc_interface_code.h index abc01de315..17ebc25e33 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_ipc_interface_code.h +++ b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_ipc_interface_code.h @@ -99,6 +99,7 @@ enum class AppMgrInterfaceCode { PRELOAD_APPLICATION = 73, SET_SUPPORTED_PROCESS_CACHE_SELF = 74, APP_GET_RUNNING_PROCESSES_BY_BUNDLE_TYPE = 75, + SET_APP_ASSERT_PAUSE_STATE_SELF = 76, }; } // AppExecFwk } // OHOS diff --git a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_proxy.h b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_proxy.h index 3b5c4feebc..556eadb307 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_proxy.h +++ b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_proxy.h @@ -568,6 +568,13 @@ public: virtual int32_t NotifyMemorySizeStateChanged(bool isMemorySizeSufficent) override; int32_t SetSupportedProcessCacheSelf(bool isSupport) override; + + /** + * Set application assertion pause state. + * + * @param flag assertion pause state. + */ + void SetAppAssertionPauseState(bool flag) override; private: bool SendTransactCmd(AppMgrInterfaceCode code, MessageParcel &data, MessageParcel &reply); bool WriteInterfaceToken(MessageParcel &data); diff --git a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_stub.h b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_stub.h index 51de220229..248049375e 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_stub.h +++ b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_stub.h @@ -135,6 +135,7 @@ private: int32_t HandleGetAllUIExtensionProviderPid(MessageParcel &data, MessageParcel &reply); int32_t HandleNotifyMemorySizeStateChanged(MessageParcel &data, MessageParcel &reply); int32_t HandleSetSupportedProcessCacheSelf(MessageParcel &data, MessageParcel &reply); + int32_t HandleSetAppAssertionPauseState(MessageParcel &data, MessageParcel &reply); using AppMgrFunc = int32_t (AppMgrStub::*)(MessageParcel &data, MessageParcel &reply); std::map memberFuncMap_; diff --git a/interfaces/inner_api/app_manager/src/appmgr/ams_mgr_proxy.cpp b/interfaces/inner_api/app_manager/src/appmgr/ams_mgr_proxy.cpp index 6fc6a49476..93e75a2d2f 100644 --- a/interfaces/inner_api/app_manager/src/appmgr/ams_mgr_proxy.cpp +++ b/interfaces/inner_api/app_manager/src/appmgr/ams_mgr_proxy.cpp @@ -1042,34 +1042,6 @@ bool AmsMgrProxy::IsAttachDebug(const std::string &bundleName) return reply.ReadBool(); } -void AmsMgrProxy::SetAppAssertionPauseState(int32_t pid, bool flag) -{ - TAG_LOGD(AAFwkTag::APPMGR, "Called."); - MessageParcel data; - if (!WriteInterfaceToken(data)) { - TAG_LOGE(AAFwkTag::APPMGR, "Write interface token failed."); - return; - } - - if (!data.WriteInt32(pid)) { - TAG_LOGE(AAFwkTag::APPMGR, "Write pid fail."); - return; - } - - if (!data.WriteBool(flag)) { - TAG_LOGE(AAFwkTag::APPMGR, "Write flag fail."); - return; - } - - MessageParcel reply; - MessageOption option; - auto ret = SendTransactCmd(static_cast(IAmsMgr::Message::SET_APP_ASSERT_PAUSE_STATE), - data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGE(AAFwkTag::APPMGR, "Send request failed, err: %{public}d", ret); - } -} - void AmsMgrProxy::ClearProcessByToken(sptr token) { MessageParcel data; diff --git a/interfaces/inner_api/app_manager/src/appmgr/ams_mgr_stub.cpp b/interfaces/inner_api/app_manager/src/appmgr/ams_mgr_stub.cpp index 864ea07e3d..81a284f974 100644 --- a/interfaces/inner_api/app_manager/src/appmgr/ams_mgr_stub.cpp +++ b/interfaces/inner_api/app_manager/src/appmgr/ams_mgr_stub.cpp @@ -112,8 +112,6 @@ void AmsMgrStub::CreateMemberFuncMap() &AmsMgrStub::HandleRegisterAbilityDebugResponse; memberFuncMap_[static_cast(IAmsMgr::Message::IS_ATTACH_DEBUG)] = &AmsMgrStub::HandleIsAttachDebug; - memberFuncMap_[static_cast(IAmsMgr::Message::SET_APP_ASSERT_PAUSE_STATE)] = - &AmsMgrStub::HandleSetAppAssertionPauseState; memberFuncMap_[static_cast(IAmsMgr::Message::CLEAR_PROCESS_BY_TOKEN)] = &AmsMgrStub::HandleClearProcessByToken; memberFuncMap_[static_cast(IAmsMgr::Message::KILL_PROCESSES_BY_PIDS)] = @@ -650,15 +648,6 @@ int32_t AmsMgrStub::HandleIsAttachDebug(MessageParcel &data, MessageParcel &repl return NO_ERROR; } -int32_t AmsMgrStub::HandleSetAppAssertionPauseState(MessageParcel &data, MessageParcel &reply) -{ - TAG_LOGD(AAFwkTag::APPMGR, "Called."); - auto pid = data.ReadInt32(); - auto flag = data.ReadBool(); - SetAppAssertionPauseState(pid, flag); - return NO_ERROR; -} - int32_t AmsMgrStub::HandleClearProcessByToken(MessageParcel &data, MessageParcel &reply) { HITRACE_METER(HITRACE_TAG_APP); diff --git a/interfaces/inner_api/app_manager/src/appmgr/app_mgr_client.cpp b/interfaces/inner_api/app_manager/src/appmgr/app_mgr_client.cpp index 47da7f6058..72611bea51 100644 --- a/interfaces/inner_api/app_manager/src/appmgr/app_mgr_client.cpp +++ b/interfaces/inner_api/app_manager/src/appmgr/app_mgr_client.cpp @@ -951,14 +951,6 @@ bool AppMgrClient::IsAttachDebug(const std::string &bundleName) return amsService_->IsAttachDebug(bundleName); } -void AppMgrClient::SetAppAssertionPauseState(int32_t pid, bool flag) -{ - if (!IsAmsServiceReady()) { - return; - } - amsService_->SetAppAssertionPauseState(pid, flag); -} - bool AppMgrClient::IsAmsServiceReady() { if (mgrHolder_ == nullptr) { diff --git a/interfaces/inner_api/app_manager/src/appmgr/app_mgr_proxy.cpp b/interfaces/inner_api/app_manager/src/appmgr/app_mgr_proxy.cpp index 21ba29545f..d25f1d3490 100644 --- a/interfaces/inner_api/app_manager/src/appmgr/app_mgr_proxy.cpp +++ b/interfaces/inner_api/app_manager/src/appmgr/app_mgr_proxy.cpp @@ -1987,5 +1987,27 @@ int32_t AppMgrProxy::SetSupportedProcessCacheSelf(bool isSupport) } return reply.ReadInt32(); } + +void AppMgrProxy::SetAppAssertionPauseState(bool flag) +{ + TAG_LOGD(AAFwkTag::APPMGR, "Called."); + MessageParcel data; + if (!WriteInterfaceToken(data)) { + TAG_LOGE(AAFwkTag::APPMGR, "Write interface token failed."); + return; + } + if (!data.WriteBool(flag)) { + TAG_LOGE(AAFwkTag::APPMGR, "flag write failed."); + return; + } + + MessageParcel reply; + MessageOption option; + auto error = SendRequest(AppMgrInterfaceCode::SET_APP_ASSERT_PAUSE_STATE_SELF, data, reply, option); + if (error != NO_ERROR) { + TAG_LOGE(AAFwkTag::APPMGR, "Send request error: %{public}d", error); + return; + } +} } // namespace AppExecFwk } // namespace OHOS diff --git a/interfaces/inner_api/app_manager/src/appmgr/app_mgr_stub.cpp b/interfaces/inner_api/app_manager/src/appmgr/app_mgr_stub.cpp index cb75d680d1..291b9f9206 100644 --- a/interfaces/inner_api/app_manager/src/appmgr/app_mgr_stub.cpp +++ b/interfaces/inner_api/app_manager/src/appmgr/app_mgr_stub.cpp @@ -190,6 +190,8 @@ AppMgrStub::AppMgrStub() &AppMgrStub::HandleSetSupportedProcessCacheSelf; memberFuncMap_[static_cast(AppMgrInterfaceCode::APP_GET_RUNNING_PROCESSES_BY_BUNDLE_TYPE)] = &AppMgrStub::HandleGetRunningProcessesByBundleType; + memberFuncMap_[static_cast(AppMgrInterfaceCode::SET_APP_ASSERT_PAUSE_STATE_SELF)] = + &AppMgrStub::HandleSetAppAssertionPauseState; } AppMgrStub::~AppMgrStub() @@ -1311,5 +1313,13 @@ int32_t AppMgrStub::HandleSetSupportedProcessCacheSelf(MessageParcel &data, Mess } return NO_ERROR; } + +int32_t AppMgrStub::HandleSetAppAssertionPauseState(MessageParcel &data, MessageParcel &reply) +{ + TAG_LOGD(AAFwkTag::APPMGR, "Called."); + bool flag = data.ReadBool(); + SetAppAssertionPauseState(flag); + return NO_ERROR; +} } // namespace AppExecFwk } // namespace OHOS diff --git a/services/abilitymgr/include/app_scheduler.h b/services/abilitymgr/include/app_scheduler.h index 9ef6ff0c3e..fa26c6438f 100644 --- a/services/abilitymgr/include/app_scheduler.h +++ b/services/abilitymgr/include/app_scheduler.h @@ -413,14 +413,6 @@ public: */ void ClearProcessByToken(sptr token) const; - /** - * Set application assertion pause state. - * - * @param pid App process pid. - * @param flag assertion pause state. - */ - void SetAppAssertionPauseState(int32_t pid, bool flag); - /** * whether memory size is sufficent. * @return Returns true is sufficent memory size, others return false. diff --git a/services/abilitymgr/src/app_scheduler.cpp b/services/abilitymgr/src/app_scheduler.cpp index cca1e94fc9..01e6e61526 100644 --- a/services/abilitymgr/src/app_scheduler.cpp +++ b/services/abilitymgr/src/app_scheduler.cpp @@ -566,12 +566,6 @@ bool AppScheduler::IsAttachDebug(const std::string &bundleName) return ERR_OK; } -void AppScheduler::SetAppAssertionPauseState(int32_t pid, bool flag) -{ - CHECK_POINTER(appMgrClient_); - appMgrClient_->SetAppAssertionPauseState(pid, flag); -} - void AppScheduler::ClearProcessByToken(sptr token) const { HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); diff --git a/services/abilitymgr/src/assert_fault_callback_death_mgr.cpp b/services/abilitymgr/src/assert_fault_callback_death_mgr.cpp index 3585b2b296..c9d92d6913 100644 --- a/services/abilitymgr/src/assert_fault_callback_death_mgr.cpp +++ b/services/abilitymgr/src/assert_fault_callback_death_mgr.cpp @@ -65,7 +65,6 @@ void AssertFaultCallbackDeathMgr::AddAssertFaultCallback(sptr &re TAG_LOGE(AAFwkTag::ABILITYMGR, "Get app scheduler instance is nullptr."); return; } - IN_PROCESS_CALL_WITHOUT_RET(appScheduler->SetAppAssertionPauseState(callerPid, true)); } void AssertFaultCallbackDeathMgr::RemoveAssertFaultCallback(const wptr &remote, bool isCallbackDeath) @@ -126,7 +125,6 @@ void AssertFaultCallbackDeathMgr::CallAssertFaultCallback(uint64_t assertFaultSe TAG_LOGE(AAFwkTag::ABILITYMGR, "Get app scheduler instance is nullptr."); return; } - IN_PROCESS_CALL_WITHOUT_RET(appScheduler->SetAppAssertionPauseState(item.pid_, false)); } } // namespace AbilityRuntime } // namespace OHOS diff --git a/services/appmgr/include/ams_mgr_scheduler.h b/services/appmgr/include/ams_mgr_scheduler.h index 7c70d3a2e4..9454d35d1b 100644 --- a/services/appmgr/include/ams_mgr_scheduler.h +++ b/services/appmgr/include/ams_mgr_scheduler.h @@ -274,14 +274,6 @@ public: */ void SetKeepAliveEnableState(const std::string &bundleName, bool enable) override; - /** - * Set application assertion pause state. - * - * @param pid App process pid. - * @param flag assertion pause state. - */ - void SetAppAssertionPauseState(int32_t pid, bool flag) override; - /** * To clear the process by ability token. * diff --git a/services/appmgr/include/app_mgr_service.h b/services/appmgr/include/app_mgr_service.h index ce653ae473..a5a4c13118 100644 --- a/services/appmgr/include/app_mgr_service.h +++ b/services/appmgr/include/app_mgr_service.h @@ -503,6 +503,8 @@ public: int32_t NotifyMemorySizeStateChanged(bool isMemorySizeSufficent) override; int32_t SetSupportedProcessCacheSelf(bool isSupport) override; + + void SetAppAssertionPauseState(bool flag) override; private: /** * Init, Initialize application services. diff --git a/services/appmgr/include/app_mgr_service_inner.h b/services/appmgr/include/app_mgr_service_inner.h index 8e94a1331f..769ff3ebc7 100644 --- a/services/appmgr/include/app_mgr_service_inner.h +++ b/services/appmgr/include/app_mgr_service_inner.h @@ -1025,7 +1025,7 @@ public: int32_t SignRestartAppFlag(const std::string &bundleName); - void SetAppAssertionPauseState(int32_t pid, bool flag); + void SetAppAssertionPauseState(bool flag); void SetKeepAliveEnableState(const std::string &bundleName, bool enable); diff --git a/services/appmgr/src/ams_mgr_scheduler.cpp b/services/appmgr/src/ams_mgr_scheduler.cpp index efe550a89f..38cb78bb5c 100644 --- a/services/appmgr/src/ams_mgr_scheduler.cpp +++ b/services/appmgr/src/ams_mgr_scheduler.cpp @@ -521,15 +521,6 @@ bool AmsMgrScheduler::IsAttachDebug(const std::string &bundleName) return amsMgrServiceInner_->IsAttachDebug(bundleName); } -void AmsMgrScheduler::SetAppAssertionPauseState(int32_t pid, bool flag) -{ - if (!IsReady()) { - TAG_LOGE(AAFwkTag::APPMGR, "AmsMgrService is not ready."); - return; - } - amsMgrServiceInner_->SetAppAssertionPauseState(pid, flag); -} - void AmsMgrScheduler::SetKeepAliveEnableState(const std::string &bundleName, bool enable) { if (!IsReady()) { diff --git a/services/appmgr/src/app_mgr_service.cpp b/services/appmgr/src/app_mgr_service.cpp index bc617d85bc..b2db303cd3 100644 --- a/services/appmgr/src/app_mgr_service.cpp +++ b/services/appmgr/src/app_mgr_service.cpp @@ -1352,5 +1352,15 @@ int32_t AppMgrService::SetSupportedProcessCacheSelf(bool isSupport) } return appMgrServiceInner_->SetSupportedProcessCacheSelf(isSupport); } + +void AppMgrService::SetAppAssertionPauseState(bool flag) +{ + TAG_LOGI(AAFwkTag::APPMGR, "Called"); + if (!IsReady()) { + TAG_LOGE(AAFwkTag::APPMGR, "Not ready."); + return; + } + return appMgrServiceInner_->SetAppAssertionPauseState(flag); +} } // namespace AppExecFwk } // namespace OHOS diff --git a/services/appmgr/src/app_mgr_service_inner.cpp b/services/appmgr/src/app_mgr_service_inner.cpp index 99bd5fbf64..ddbb7d3fb3 100644 --- a/services/appmgr/src/app_mgr_service_inner.cpp +++ b/services/appmgr/src/app_mgr_service_inner.cpp @@ -6148,7 +6148,7 @@ int32_t AppMgrServiceInner::UnregisterRenderStateObserver(const sptr::GetInstance()->UnregisterRenderStateObserver(observer); } -void AppMgrServiceInner::SetAppAssertionPauseState(int32_t pid, bool flag) +void AppMgrServiceInner::SetAppAssertionPauseState(bool flag) { HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__); TAG_LOGD(AAFwkTag::APPMGR, "Called."); @@ -6161,14 +6161,10 @@ void AppMgrServiceInner::SetAppAssertionPauseState(int32_t pid, bool flag) return; } - auto callerUid = IPCSkeleton::GetCallingUid(); - if (callerUid != FOUNDATION_UID) { - TAG_LOGE(AAFwkTag::APPMGR, "Caller is not foundation."); - return; - } - auto appRecord = GetAppRunningRecordByPid(pid); + auto callerPid = IPCSkeleton::GetCallingPid(); + auto appRecord = GetAppRunningRecordByPid(callerPid); if (appRecord == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "No such appRecord pid is %{public}d.", pid); + TAG_LOGE(AAFwkTag::APPMGR, "No such appRecord pid is %{public}d.", callerPid); return; } appRecord->SetAssertionPauseFlag(flag); diff --git a/test/unittest/app_mgr_client_test/app_mgr_client_test.cpp b/test/unittest/app_mgr_client_test/app_mgr_client_test.cpp index 43f33d5351..d9adfe143d 100644 --- a/test/unittest/app_mgr_client_test/app_mgr_client_test.cpp +++ b/test/unittest/app_mgr_client_test/app_mgr_client_test.cpp @@ -1238,20 +1238,6 @@ HWTEST_F(AppMgrClientTest, ClearNonPersistWaitingDebugFlag_001, TestSize.Level0) EXPECT_NE(appMgrClient, nullptr); } -/** - * @tc.name: AppMgrClient_SetAppAssertionPauseState_001 - * @tc.desc: SetAppAssertionPauseState. - * @tc.type: FUNC - */ -HWTEST_F(AppMgrClientTest, SetAppAssertionPauseState_001, TestSize.Level0) -{ - auto appMgrClient = std::make_unique(); - int32_t pid = 1; - bool flag = true; - appMgrClient->SetAppAssertionPauseState(pid, flag); - EXPECT_NE(appMgrClient, nullptr); -} - /** * @tc.name: AppMgrClient_IsAttachDebug_001 * @tc.desc: IsAttachDebug. From b20b29ccfd69c7e8d0e0dad0fabacd49881909c6 Mon Sep 17 00:00:00 2001 From: mashaohua7 Date: Wed, 8 May 2024 10:52:18 +0800 Subject: [PATCH 004/174] =?UTF-8?q?=E9=80=9A=E8=BF=87bundlename=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E5=BA=94=E7=94=A8=E5=88=86=E8=BA=AB=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: mashaohua7 --- .../app/js_app_manager/js_app_manager.cpp | 44 +++++++++++ .../js_app_manager/js_app_manager_utils.cpp | 42 ++++++++++ .../app/js_app_manager/js_app_manager_utils.h | 6 ++ .../common/include/application_info.h | 10 +++ interfaces/inner_api/app_manager/BUILD.gn | 1 + .../include/appmgr/app_mgr_interface.h | 12 +++ .../appmgr/app_mgr_ipc_interface_code.h | 1 + .../include/appmgr/app_mgr_proxy.h | 10 +++ .../app_manager/include/appmgr/app_mgr_stub.h | 1 + .../include/appmgr/running_multi_info.h | 47 +++++++++++ .../app_manager/src/appmgr/app_mgr_proxy.cpp | 24 ++++++ .../app_manager/src/appmgr/app_mgr_stub.cpp | 17 ++++ .../src/appmgr/running_multi_info.cpp | 78 +++++++++++++++++++ services/appmgr/include/app_mgr_service.h | 11 +++ .../appmgr/include/app_mgr_service_inner.h | 12 +++ services/appmgr/src/app_mgr_service.cpp | 9 +++ services/appmgr/src/app_mgr_service_inner.cpp | 41 ++++++++++ 17 files changed, 366 insertions(+) create mode 100644 interfaces/inner_api/app_manager/include/appmgr/running_multi_info.h create mode 100644 interfaces/inner_api/app_manager/src/appmgr/running_multi_info.cpp diff --git a/frameworks/js/napi/app/js_app_manager/js_app_manager.cpp b/frameworks/js/napi/app/js_app_manager/js_app_manager.cpp index add1fc82bf..332d48512c 100644 --- a/frameworks/js/napi/app/js_app_manager/js_app_manager.cpp +++ b/frameworks/js/napi/app/js_app_manager/js_app_manager.cpp @@ -110,6 +110,11 @@ public: GET_CB_INFO_AND_CALL(env, info, JsAppManager, OnIsRunningInStabilityTest); } + static napi_value GetRunningMultiAppInfo(napi_env env, napi_callback_info info) + { + GET_CB_INFO_AND_CALL(env, info, JsAppManager, OnGetRunningMultiAppInfo); + } + static napi_value KillProcessWithAccount(napi_env env, napi_callback_info info) { GET_CB_INFO_AND_CALL(env, info, JsAppManager, OnKillProcessWithAccount); @@ -640,6 +645,43 @@ private: return result; } + napi_value OnGetRunningMultiAppInfo(napi_env env, size_t argc, napi_value* argv) + { + TAG_LOGD(AAFwkTag::APPMGR, "called"); + // only support 1 params + if (argc < ARGC_ONE) { + TAG_LOGE(AAFwkTag::APPMGR, "Not enough arguments"); + ThrowTooFewParametersError(env); + return CreateJsUndefined(env); + } + std::string bundleName; + if (!ConvertFromJsValue(env, argv[0], bundleName)) { + TAG_LOGE(AAFwkTag::APPMGR, "get bundleName failed!"); + ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM); + return CreateJsUndefined(env); + } + NapiAsyncTask::CompleteCallback complete = + [appManager = appManager_, bundleName](napi_env env, NapiAsyncTask &task, int32_t status) { + if (appManager == nullptr) { + TAG_LOGW(AAFwkTag::APPMGR, "abilityManager nullptr"); + task.Reject(env, CreateJsError(env, AbilityErrorCode::ERROR_CODE_INNER)); + return; + } + RunningMultiAppInfo info; + auto ret = appManager->GetRunningMultiAppInfoByBundleName(bundleName, info); + if (ret == 0) { + task.Resolve(env, CreateJsRunningMultiAppInfo(env, info)); + } else { + task.Reject(env, CreateJsError(env, ret, "Get mission infos failed.")); + } + }; + napi_value lastParam = nullptr; + napi_value result = nullptr; + NapiAsyncTask::Schedule("JSAppManager::OnGetRunningMultiAppInfo", + env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result)); + return result; + } + napi_value OnGetRunningProcessInformationByBundleType(napi_env env, size_t argc, napi_value* argv) { TAG_LOGD(AAFwkTag::APPMGR, "called"); @@ -1186,6 +1228,8 @@ napi_value JsAppManagerInit(napi_env env, napi_value exportObj) JsAppManager::GetProcessMemoryByPid); BindNativeFunction(env, exportObj, "getRunningProcessInfoByBundleName", moduleName, JsAppManager::GetRunningProcessInfoByBundleName); + BindNativeFunction(env, exportObj, "getRunningMultiAppInfo", moduleName, + JsAppManager::GetRunningMultiAppInfo); BindNativeFunction(env, exportObj, "isApplicationRunning", moduleName, JsAppManager::IsApplicationRunning); BindNativeFunction(env, exportObj, "preloadApplication", moduleName, diff --git a/frameworks/js/napi/app/js_app_manager/js_app_manager_utils.cpp b/frameworks/js/napi/app/js_app_manager/js_app_manager_utils.cpp index 7bc476e546..91c635f2b7 100644 --- a/frameworks/js/napi/app/js_app_manager/js_app_manager_utils.cpp +++ b/frameworks/js/napi/app/js_app_manager/js_app_manager_utils.cpp @@ -150,6 +150,48 @@ napi_value CreateJsRunningProcessInfo(napi_env env, const RunningProcessInfo &in return object; } +napi_value CreateJsRunningMultiAppInfo(napi_env env, const RunningMultiAppInfo &info) +{ + napi_value object = nullptr; + napi_create_object(env, &object); + if (object == nullptr) { + TAG_LOGE(AAFwkTag::APPMGR, "objValue nullptr."); + return nullptr; + } + napi_set_named_property(env, object, "bundleName", CreateJsValue(env, info.bundleName)); + napi_set_named_property(env, object, "mode", CreateJsValue(env, info.mode)); + napi_set_named_property(env, object, "instance", CreateNativeArray(env, info.instance)); + napi_set_named_property(env, object, "isolation", CreateJsRunningAppTwinArray(env, info.isolation)); + + return object; +} + +napi_value CreateJsRunningAppTwinArray(napi_env env, const std::vector& data) +{ + napi_value arrayValue = nullptr; + napi_create_array_with_length(env, data.size(), &arrayValue); + uint32_t index = 0; + for (const auto &item : data) { + napi_set_element(env, arrayValue, index++, CreateJsRunningAppTwin(env, item)); + } + return arrayValue; +} + +napi_value CreateJsRunningAppTwin(napi_env env, const RunningAppTwin &info) +{ + napi_value object = nullptr; + napi_create_object(env, &object); + if (object == nullptr) { + TAG_LOGE(AAFwkTag::APPMGR, "objValue nullptr."); + return nullptr; + } + napi_set_named_property(env, object, "bundleName", CreateJsValue(env, info.appTwinIndex)); + napi_set_named_property(env, object, "mode", CreateJsValue(env, info.uid)); + napi_set_named_property(env, object, "instance", CreateNativeArray(env, info.pids)); + + return object; +} + napi_value ApplicationStateInit(napi_env env) { TAG_LOGD(AAFwkTag::APPMGR, "ApplicationStateInit enter"); diff --git a/frameworks/js/napi/app/js_app_manager/js_app_manager_utils.h b/frameworks/js/napi/app/js_app_manager/js_app_manager_utils.h index 4bb29199cc..254272193c 100644 --- a/frameworks/js/napi/app/js_app_manager/js_app_manager_utils.h +++ b/frameworks/js/napi/app/js_app_manager/js_app_manager_utils.h @@ -19,6 +19,7 @@ #include "application_state_observer_stub.h" #include "native_engine/native_engine.h" #include "running_process_info.h" +#include "running_multi_info.h" #ifdef SUPPORT_GRAPHICS #include "ability_first_frame_state_data.h" #endif @@ -29,6 +30,8 @@ using OHOS::AppExecFwk::AppStateData; using OHOS::AppExecFwk::AbilityStateData; using OHOS::AppExecFwk::ProcessData; using OHOS::AppExecFwk::RunningProcessInfo; +using OHOS::AppExecFwk::RunningMultiAppInfo; +using OHOS::AppExecFwk::RunningAppTwin; #ifdef SUPPORT_GRAPHICS using OHOS::AppExecFwk::AbilityFirstFrameStateData; #endif @@ -63,6 +66,9 @@ bool ConvertPreloadApplicationParam(napi_env env, size_t argc, napi_value *argv, std::string &errorMsg); JsAppProcessState ConvertToJsAppProcessState( const AppExecFwk::AppProcessState &appProcessState, const bool &isFocused); +napi_value CreateJsRunningMultiAppInfo(napi_env env, const RunningMultiAppInfo &info); +napi_value CreateJsRunningAppTwinArray(napi_env env, const std::vector& data); +napi_value CreateJsRunningAppTwin(napi_env env, const RunningAppTwin &info); } // namespace AbilityRuntime } // namespace OHOS #endif // OHOS_ABILITY_RUNTIME_JS_APP_MANAGER_UTILS_H diff --git a/frameworks/simulator/common/include/application_info.h b/frameworks/simulator/common/include/application_info.h index a22dd9d5fd..13db40174f 100644 --- a/frameworks/simulator/common/include/application_info.h +++ b/frameworks/simulator/common/include/application_info.h @@ -55,6 +55,13 @@ enum class CompatiblePolicy { BACKWARD_COMPATIBILITY = 1, }; +//Type of app multi app mode +enum class AppMode { + NOT_SUPPORTED = 0, + MULTI_INSTANCE = 1, + APP_TWIN = 2, +}; + struct Metadata { std::string name; std::string value; @@ -192,6 +199,9 @@ struct ApplicationInfo { std::string compileSdkVersion; std::string compileSdkType = DEFAULT_COMPILE_SDK_TYPE; + + //Type of app multi app mode + AppMode appMode = AppMode::NOT_SUPPORTED; }; } // namespace AppExecFwk } // namespace OHOS diff --git a/interfaces/inner_api/app_manager/BUILD.gn b/interfaces/inner_api/app_manager/BUILD.gn index 6e3e3d772c..59ad1b29a7 100644 --- a/interfaces/inner_api/app_manager/BUILD.gn +++ b/interfaces/inner_api/app_manager/BUILD.gn @@ -109,6 +109,7 @@ ohos_shared_library("app_manager") { "src/appmgr/start_specified_ability_response_proxy.cpp", "src/appmgr/start_specified_ability_response_stub.cpp", "src/appmgr/system_memory_attr.cpp", + "src/appmgr/running_multi_info.cpp", ] public_configs = [ diff --git a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_interface.h b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_interface.h index 723d2a714b..c5a6a3458b 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_interface.h +++ b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_interface.h @@ -41,6 +41,7 @@ #include "system_memory_attr.h" #include "want.h" #include "app_jsheap_mem_info.h" +#include "running_multi_info.h" namespace OHOS { namespace AppExecFwk { @@ -143,6 +144,17 @@ public: */ virtual int GetAllRunningProcesses(std::vector &info) = 0; + /** + * GetRunningMultiAppInfoByBundleName, call GetRunningMultiAppInfoByBundleName() through proxy project. + * Obtains information about multiapp that are running on the device. + * + * @param bundlename, input. + * @param info, output multiapp information. + * @return ERR_OK ,return back success,others fail. + */ + virtual int32_t GetRunningMultiAppInfoByBundleName(const std::string &bundleName, + RunningMultiAppInfo &info) = 0; + /** * GetRunningProcessesByBundleType, call GetRunningProcessesByBundleType() through proxy project. * Obtains information about application processes by bundle type that are running on the device. diff --git a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_ipc_interface_code.h b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_ipc_interface_code.h index abc01de315..a336cf9a26 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_ipc_interface_code.h +++ b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_ipc_interface_code.h @@ -99,6 +99,7 @@ enum class AppMgrInterfaceCode { PRELOAD_APPLICATION = 73, SET_SUPPORTED_PROCESS_CACHE_SELF = 74, APP_GET_RUNNING_PROCESSES_BY_BUNDLE_TYPE = 75, + GET_RUNNING_MULTIAPP_INFO_By_BUNDLENAME = 76, }; } // AppExecFwk } // OHOS diff --git a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_proxy.h b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_proxy.h index 3b5c4feebc..fb0c14cefc 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_proxy.h +++ b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_proxy.h @@ -122,6 +122,16 @@ public: */ virtual int32_t GetAllRunningProcesses(std::vector &info) override; + /** + * GetALLRunningMultiAppInfo, call GetALLRunningMultiAppInfo() through proxy project. + * Obtains information about multiapp that are running on the device. + * + * @param info, app name in multiappinfo. + * @return ERR_OK ,return back success,others fail. + */ + virtual int32_t GetRunningMultiAppInfoByBundleName(const std::string &bundleName, + RunningMultiAppInfo &info) override; + /** * GetRunningProcessesByBundleType, call GetRunningProcessesByBundleType() through proxy project. * Obtains information about application processes by bundle type that are running on the device. diff --git a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_stub.h b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_stub.h index 51de220229..ef90cd36b6 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_stub.h +++ b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_stub.h @@ -94,6 +94,7 @@ private: int32_t HandleUnregisterConfigurationObserver(MessageParcel &data, MessageParcel &reply); int32_t HandleDumpHeapMemory(MessageParcel &data, MessageParcel &reply); int32_t HandleDumpJsHeapMemory(MessageParcel &data, MessageParcel &reply); + int32_t HandleGetRunningMultiAppInfoByBundleName(MessageParcel &data, MessageParcel &reply); #ifdef ABILITY_COMMAND_FOR_TEST int32_t HandleBlockAppServiceDone(MessageParcel &data, MessageParcel &reply); #endif diff --git a/interfaces/inner_api/app_manager/include/appmgr/running_multi_info.h b/interfaces/inner_api/app_manager/include/appmgr/running_multi_info.h new file mode 100644 index 0000000000..b6d40f6087 --- /dev/null +++ b/interfaces/inner_api/app_manager/include/appmgr/running_multi_info.h @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ABILITY_RUNTIME_RUNNING_MULTI_INFO_H +#define OHOS_ABILITY_RUNTIME_RUNNING_MULTI_INFO_H + +#include +#include + +#include "ability_info.h" +#include "app_mgr_constants.h" +#include "parcel.h" + +namespace OHOS { +namespace AppExecFwk { +struct RunningAppTwin { + int32_t appTwinIndex; + int32_t uid; + std::vector pids; +}; + +struct RunningMultiAppInfo : public Parcelable { + std::string bundleName; + int32_t mode; + std::vector instance; + std::vector isolation; + + bool ReadFromParcel(Parcel &parcel); + virtual bool Marshalling(Parcel &parcel) const override; + static RunningMultiAppInfo *Unmarshalling(Parcel &parcel); +}; +} // namespace AppExecFwk +} // namespace OHOS + +#endif // OHOS_ABILITY_RUNTIME_RUNNING_MULTI_INFO_H \ No newline at end of file diff --git a/interfaces/inner_api/app_manager/src/appmgr/app_mgr_proxy.cpp b/interfaces/inner_api/app_manager/src/appmgr/app_mgr_proxy.cpp index aec1f49eb8..1eeaf491c9 100644 --- a/interfaces/inner_api/app_manager/src/appmgr/app_mgr_proxy.cpp +++ b/interfaces/inner_api/app_manager/src/appmgr/app_mgr_proxy.cpp @@ -237,6 +237,30 @@ int32_t AppMgrProxy::GetAllRunningProcesses(std::vector &inf return result; } +int32_t AppMgrProxy::GetRunningMultiAppInfoByBundleName(const std::string &bundleName, + RunningMultiAppInfo &info) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + if (!WriteInterfaceToken(data)) { + return ERR_FLATTEN_OBJECT; + } + if (!data.WriteString(bundleName)) { + TAG_LOGE(AAFwkTag::APPMGR, "bundleName write failed."); + return ERR_INVALID_VALUE; + } + int32_t ret = SendRequest(AppMgrInterfaceCode::GET_RUNNING_MULTIAPP_INFO_By_BUNDLENAME, data, reply, option); + if (ret != NO_ERROR) { + TAG_LOGW(AAFwkTag::APPMGR, "SendRequest is failed, error code: %{public}d", ret); + return ret; + } + std::unique_ptr infoReply(reply.ReadParcelable()); + info = *infoReply; + int result = reply.ReadInt32(); + return result; +} + int32_t AppMgrProxy::GetRunningProcessesByBundleType(const BundleType bundleType, std::vector &info) { diff --git a/interfaces/inner_api/app_manager/src/appmgr/app_mgr_stub.cpp b/interfaces/inner_api/app_manager/src/appmgr/app_mgr_stub.cpp index b1c3946e05..e8955ba648 100644 --- a/interfaces/inner_api/app_manager/src/appmgr/app_mgr_stub.cpp +++ b/interfaces/inner_api/app_manager/src/appmgr/app_mgr_stub.cpp @@ -102,6 +102,8 @@ AppMgrStub::AppMgrStub() &AppMgrStub::HandleDumpHeapMemory; memberFuncMap_[static_cast(AppMgrInterfaceCode::DUMP_JSHEAP_MEMORY_PROCESS)] = &AppMgrStub::HandleDumpJsHeapMemory; + memberFuncMap_[static_cast(AppMgrInterfaceCode::GET_RUNNING_MULTIAPP_INFO_By_BUNDLENAME)] = + &AppMgrStub::HandleGetRunningMultiAppInfoByBundleName; #ifdef ABILITY_COMMAND_FOR_TEST memberFuncMap_[static_cast(AppMgrInterfaceCode::BLOCK_APP_SERVICE)] = &AppMgrStub::HandleBlockAppServiceDone; @@ -326,6 +328,21 @@ int32_t AppMgrStub::HandleGetAllRunningProcesses(MessageParcel &data, MessagePar return NO_ERROR; } +int32_t AppMgrStub::HandleGetRunningMultiAppInfoByBundleName(MessageParcel &data, MessageParcel &reply) +{ + std::string bundleName = data.ReadString(); + RunningMultiAppInfo info; + int32_t result = GetRunningMultiAppInfoByBundleName(bundleName, info); + if (!reply.WriteParcelable(&info)) { + return ERR_INVALID_VALUE; + } + if (!reply.WriteInt32(result)) { + TAG_LOGE(AAFwkTag::APPMGR, "fail to write result."); + return ERR_INVALID_VALUE; + } + return NO_ERROR; +} + int32_t AppMgrStub::HandleGetRunningProcessesByBundleType(MessageParcel &data, MessageParcel &reply) { HITRACE_METER(HITRACE_TAG_APP); diff --git a/interfaces/inner_api/app_manager/src/appmgr/running_multi_info.cpp b/interfaces/inner_api/app_manager/src/appmgr/running_multi_info.cpp new file mode 100644 index 0000000000..a3d2ee9e88 --- /dev/null +++ b/interfaces/inner_api/app_manager/src/appmgr/running_multi_info.cpp @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "running_multi_info.h" + +#include "nlohmann/json.hpp" +#include "string_ex.h" + +#include "hilog_tag_wrapper.h" +#include "hilog_wrapper.h" +#include "parcel_macro_base.h" + +namespace OHOS { +namespace AppExecFwk { +bool RunningMultiAppInfo::ReadFromParcel(Parcel &parcel) +{ + bundleName = Str16ToStr8(parcel.ReadString16()); + mode = parcel.ReadInt32(); + if (!parcel.ReadStringVector(&instance)) { + TAG_LOGE(AAFwkTag::APPMGR, "read instance failed."); + return false; + } + int32_t isolationSize; + READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, isolationSize); + for (auto i = 0; i < isolationSize; i++) { + RunningAppTwin twin; + twin.appTwinIndex = parcel.ReadInt32(); + twin.uid = parcel.ReadInt32(); + parcel.ReadInt32Vector(&twin.pids); + isolation.emplace_back(twin); + } + return true; +} + +RunningMultiAppInfo *RunningMultiAppInfo::Unmarshalling(Parcel &parcel) +{ + RunningMultiAppInfo *info = new (std::nothrow) RunningMultiAppInfo(); + if (info && !info->ReadFromParcel(parcel)) { + TAG_LOGW(AAFwkTag::APPMGR, "read from parcel failed"); + delete info; + info = nullptr; + } + return info; +} + +bool RunningMultiAppInfo::Marshalling(Parcel &parcel) const +{ + WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(bundleName)); + WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, mode); + if (!parcel.WriteStringVector(instance)) { + TAG_LOGE(AAFwkTag::APPMGR, "write instance failed."); + return false; + } + WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, isolation.size()); + for (auto &twin : isolation) { + WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, twin.appTwinIndex); + WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, twin.uid); + if (!parcel.WriteInt32Vector(twin.pids)) { + TAG_LOGE(AAFwkTag::APPMGR, "read instance failed."); + return false; + } + } + return true; +} +} // namespace AppExecFwk +} // namespace OHOS \ No newline at end of file diff --git a/services/appmgr/include/app_mgr_service.h b/services/appmgr/include/app_mgr_service.h index ce653ae473..8ffa2b8fb6 100644 --- a/services/appmgr/include/app_mgr_service.h +++ b/services/appmgr/include/app_mgr_service.h @@ -147,6 +147,17 @@ public: */ virtual int32_t GetAllRunningProcesses(std::vector &info) override; + /** + * GetRunningMultiAppInfoByBundleName, call GetRunningMultiAppInfoByBundleName() through proxy project. + * Obtains information about multiapp that are running on the device. + * + * @param bundlename, input. + * @param info, output multiapp information. + * @return ERR_OK ,return back success,others fail. + */ + virtual int32_t GetRunningMultiAppInfoByBundleName(const std::string &bundleName, + RunningMultiAppInfo &info) override; + /** * GetRunningProcessesByBundleType, call GetRunningProcessesByBundleType() through proxy project. * Obtains information about application processes by bundle type that are running on the device. diff --git a/services/appmgr/include/app_mgr_service_inner.h b/services/appmgr/include/app_mgr_service_inner.h index 8e94a1331f..3a25464010 100644 --- a/services/appmgr/include/app_mgr_service_inner.h +++ b/services/appmgr/include/app_mgr_service_inner.h @@ -68,6 +68,7 @@ #include "window_focus_changed_listener.h" #include "window_visibility_changed_listener.h" #include "app_jsheap_mem_info.h" +#include "running_multi_info.h" namespace OHOS { namespace AppExecFwk { @@ -305,6 +306,17 @@ public: */ virtual int32_t GetAllRunningProcesses(std::vector &info); + /** + * GetRunningMultiAppInfoByBundleName, call GetRunningMultiAppInfoByBundleName() through proxy project. + * Obtains information about multiapp that are running on the device. + * + * @param bundlename, input. + * @param info, output multiapp information. + * @return ERR_OK ,return back success,others fail. + */ + virtual int32_t GetRunningMultiAppInfoByBundleName(const std::string &bundleName, + RunningMultiAppInfo &info); + /** * GetRunningProcessesByBundleType, Obtains information about application processes by bundle type. * diff --git a/services/appmgr/src/app_mgr_service.cpp b/services/appmgr/src/app_mgr_service.cpp index da3a6eb82b..a241938c73 100644 --- a/services/appmgr/src/app_mgr_service.cpp +++ b/services/appmgr/src/app_mgr_service.cpp @@ -378,6 +378,15 @@ int32_t AppMgrService::GetAllRunningProcesses(std::vector &i return appMgrServiceInner_->GetAllRunningProcesses(info); } +int32_t AppMgrService::GetRunningMultiAppInfoByBundleName(const std::string &bundleName, + RunningMultiAppInfo &info) +{ + if (!IsReady()) { + return ERR_INVALID_OPERATION; + } + return appMgrServiceInner_->GetRunningMultiAppInfoByBundleName(bundleName, info); +} + int32_t AppMgrService::GetRunningProcessesByBundleType(BundleType bundleType, std::vector &info) { diff --git a/services/appmgr/src/app_mgr_service_inner.cpp b/services/appmgr/src/app_mgr_service_inner.cpp index 7cd6279cad..de556c4be7 100644 --- a/services/appmgr/src/app_mgr_service_inner.cpp +++ b/services/appmgr/src/app_mgr_service_inner.cpp @@ -1399,6 +1399,47 @@ int32_t AppMgrServiceInner::GetRunningProcessesByBundleType(BundleType bundleTyp return ERR_OK; } +int32_t AppMgrServiceInner::GetRunningMultiAppInfoByBundleName(const std::string &bundleName, + RunningMultiAppInfo &info) +{ + if (bundleName.empty()) { + TAG_LOGE(AAFwkTag::APPMGR, "bundlename is nullptr."); + return ERR_INVALID_VALUE; + } + if (!appRunningManager_) { + TAG_LOGE(AAFwkTag::APPMGR, "The appRunningManager is nullptr!"); + return ERR_INVALID_VALUE; + } + auto multiAppInfoMap = appRunningManager_->GetAppRunningRecordMap(); + if (multiAppInfoMap.empty()) { + return ERR_INVALID_VALUE; + } + for (const auto &item : multiAppInfoMap) { + const auto &appRecord = item.second; + if (appRecord == nullptr || appRecord->GetBundleName() != bundleName) { + continue; + } + info.bundleName = bundleName; + auto applicationInfo = appRecord->GetApplicationInfo(); + if (!applicationInfo) { + TAG_LOGE(AAFwkTag::APPMGR, "applicationInfo is nullptr, can not get app information"); + } + info.mode = static_cast(applicationInfo->appMode); + if (info.mode == AppExecFwk::AppMode::NOT_SUPPORTED) { + break; + } + if (info.mode == AppExecFwk::AppMode::APP_TWIN) { + RunningAppTwin twinInfo; + twinInfo.appTwinIndex = appRecord->GetAppIndex(); + twinInfo.uid = appRecord->GetUid(); + twinInfo.pids =appRecord->GetPriorityObject()->GetPid(); + + info.isolation.emplace_back(twinInfo); + } + } + return ERR_OK; +} + int32_t AppMgrServiceInner::GetProcessRunningInfosByUserId(std::vector &info, int32_t userId) { if (VerifyAccountPermission(AAFwk::PermissionConstants::PERMISSION_GET_RUNNING_INFO, userId) == From 3f57f6edb72f2e1571ce37b54ac8f0ad2fab8516 Mon Sep 17 00:00:00 2001 From: mashaohua7 Date: Wed, 8 May 2024 11:07:46 +0800 Subject: [PATCH 005/174] =?UTF-8?q?=E9=80=9A=E8=BF=87bundlename=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E5=BA=94=E7=94=A8=E5=88=86=E8=BA=AB=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: mashaohua7 --- .../js/napi/app/js_app_manager/js_app_manager_utils.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frameworks/js/napi/app/js_app_manager/js_app_manager_utils.cpp b/frameworks/js/napi/app/js_app_manager/js_app_manager_utils.cpp index 91c635f2b7..39521ee924 100644 --- a/frameworks/js/napi/app/js_app_manager/js_app_manager_utils.cpp +++ b/frameworks/js/napi/app/js_app_manager/js_app_manager_utils.cpp @@ -185,9 +185,9 @@ napi_value CreateJsRunningAppTwin(napi_env env, const RunningAppTwin &info) TAG_LOGE(AAFwkTag::APPMGR, "objValue nullptr."); return nullptr; } - napi_set_named_property(env, object, "bundleName", CreateJsValue(env, info.appTwinIndex)); - napi_set_named_property(env, object, "mode", CreateJsValue(env, info.uid)); - napi_set_named_property(env, object, "instance", CreateNativeArray(env, info.pids)); + napi_set_named_property(env, object, "appTwinIndex", CreateJsValue(env, info.appTwinIndex)); + napi_set_named_property(env, object, "uid", CreateJsValue(env, info.uid)); + napi_set_named_property(env, object, "pids", CreateNativeArray(env, info.pids)); return object; } From cf85f946fbe43fabfb8a6e03cbbcb1534d79caa3 Mon Sep 17 00:00:00 2001 From: mashaohua7 Date: Thu, 9 May 2024 10:39:05 +0800 Subject: [PATCH 006/174] =?UTF-8?q?=E9=80=9A=E8=BF=87bundlename=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E8=BF=90=E8=A1=8C=E6=97=B6=E5=BA=94=E7=94=A8=E5=88=86?= =?UTF-8?q?=E8=BA=AB=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: mashaohua7 --- .../common/include/application_info.h | 10 ----- .../appmgr/include/app_mgr_service_inner.h | 1 + services/appmgr/src/app_mgr_service_inner.cpp | 39 ++++++++++++------- 3 files changed, 27 insertions(+), 23 deletions(-) diff --git a/frameworks/simulator/common/include/application_info.h b/frameworks/simulator/common/include/application_info.h index 13db40174f..a22dd9d5fd 100644 --- a/frameworks/simulator/common/include/application_info.h +++ b/frameworks/simulator/common/include/application_info.h @@ -55,13 +55,6 @@ enum class CompatiblePolicy { BACKWARD_COMPATIBILITY = 1, }; -//Type of app multi app mode -enum class AppMode { - NOT_SUPPORTED = 0, - MULTI_INSTANCE = 1, - APP_TWIN = 2, -}; - struct Metadata { std::string name; std::string value; @@ -199,9 +192,6 @@ struct ApplicationInfo { std::string compileSdkVersion; std::string compileSdkType = DEFAULT_COMPILE_SDK_TYPE; - - //Type of app multi app mode - AppMode appMode = AppMode::NOT_SUPPORTED; }; } // namespace AppExecFwk } // namespace OHOS diff --git a/services/appmgr/include/app_mgr_service_inner.h b/services/appmgr/include/app_mgr_service_inner.h index 3a25464010..5411f9240d 100644 --- a/services/appmgr/include/app_mgr_service_inner.h +++ b/services/appmgr/include/app_mgr_service_inner.h @@ -1423,6 +1423,7 @@ private: std::shared_ptr appProcessManager_; std::shared_ptr remoteClientManager_; std::shared_ptr appRunningManager_; + std::shared_ptr appRunnningRecord_; std::shared_ptr taskHandler_; std::shared_ptr eventHandler_; std::shared_ptr configuration_; diff --git a/services/appmgr/src/app_mgr_service_inner.cpp b/services/appmgr/src/app_mgr_service_inner.cpp index de556c4be7..7c5c898d63 100644 --- a/services/appmgr/src/app_mgr_service_inner.cpp +++ b/services/appmgr/src/app_mgr_service_inner.cpp @@ -1420,21 +1420,34 @@ int32_t AppMgrServiceInner::GetRunningMultiAppInfoByBundleName(const std::string continue; } info.bundleName = bundleName; - auto applicationInfo = appRecord->GetApplicationInfo(); - if (!applicationInfo) { - TAG_LOGE(AAFwkTag::APPMGR, "applicationInfo is nullptr, can not get app information"); - } - info.mode = static_cast(applicationInfo->appMode); - if (info.mode == AppExecFwk::AppMode::NOT_SUPPORTED) { + MultiAppModeData multiAppModeData; + info.mode = static_cast(multiAppModeData.type); + if (info.mode == static_cast(MultiAppModeType::UNSPECIFIED)) { break; } - if (info.mode == AppExecFwk::AppMode::APP_TWIN) { - RunningAppTwin twinInfo; - twinInfo.appTwinIndex = appRecord->GetAppIndex(); - twinInfo.uid = appRecord->GetUid(); - twinInfo.pids =appRecord->GetPriorityObject()->GetPid(); - - info.isolation.emplace_back(twinInfo); + if (info.mode == static_cast(MultiAppModeType::APP_CLONE)) { + auto childAppRecordMap = appRunnningRecord_->GetChildAppRecordMap(); + if (childAppRecordMap.empty()) { + return ERR_INVALID_VALUE; + } + for (unsigned int i = 0; i < info.isolation.size(); i++) { + if (info.isolation[i].appTwinIndex == appRecord->GetAppIndex()) { + info.isolation[i].uid = appRecord->GetUid(); + info.isolation[i].pids.emplace_back(appRecord->GetPriorityObject()->GetPid()); + for (auto it : childAppRecordMap) { + info.isolation[i].pids.emplace_back(it.first); + } + } else { + RunningAppTwin twinInfo; + twinInfo.appTwinIndex = appRecord->GetAppIndex(); + twinInfo.uid = appRecord->GetUid(); + twinInfo.pids.emplace_back(appRecord->GetPriorityObject()->GetPid()); + for (auto it : childAppRecordMap) { + twinInfo.pids.emplace_back(it.first); + } + info.isolation.emplace_back(twinInfo); + } + } } } return ERR_OK; From 39d2dfd9ac32a5b10ca101ef321838a444aee7f0 Mon Sep 17 00:00:00 2001 From: mashaohua7 Date: Thu, 9 May 2024 16:22:16 +0800 Subject: [PATCH 007/174] =?UTF-8?q?=E9=80=9A=E8=BF=87bundlename=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E8=BF=90=E8=A1=8C=E6=97=B6=E5=BA=94=E7=94=A8=E5=88=86?= =?UTF-8?q?=E8=BA=AB=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: mashaohua7 --- frameworks/js/napi/app/js_app_manager/js_app_manager.cpp | 5 +++++ .../ability_business_error/ability_business_error.cpp | 1 + .../ability_manager/include/ability_manager_errors.h | 5 +++++ .../app_manager/src/appmgr/running_multi_info.cpp | 4 ++-- .../native/ability_business_error/ability_business_error.h | 3 +++ services/appmgr/include/app_mgr_service_inner.h | 1 - services/appmgr/src/app_mgr_service.cpp | 4 ++++ services/appmgr/src/app_mgr_service_inner.cpp | 7 +++---- 8 files changed, 23 insertions(+), 7 deletions(-) diff --git a/frameworks/js/napi/app/js_app_manager/js_app_manager.cpp b/frameworks/js/napi/app/js_app_manager/js_app_manager.cpp index 332d48512c..1b99615646 100644 --- a/frameworks/js/napi/app/js_app_manager/js_app_manager.cpp +++ b/frameworks/js/napi/app/js_app_manager/js_app_manager.cpp @@ -648,6 +648,11 @@ private: napi_value OnGetRunningMultiAppInfo(napi_env env, size_t argc, napi_value* argv) { TAG_LOGD(AAFwkTag::APPMGR, "called"); + if (!CheckCallerIsSystemApp()) { + TAG_LOGE(AAFwkTag::APPMGR, "Current app is not system app"); + ThrowError(env, AbilityErrorCode::ERROR_CODE_NOT_SYSTEM_APP); + return CreateJsUndefined(env); + } // only support 1 params if (argc < ARGC_ONE) { TAG_LOGE(AAFwkTag::APPMGR, "Not enough arguments"); diff --git a/frameworks/native/ability/native/ability_business_error/ability_business_error.cpp b/frameworks/native/ability/native/ability_business_error/ability_business_error.cpp index 8c4c18d0c3..c278de3544 100644 --- a/frameworks/native/ability/native/ability_business_error/ability_business_error.cpp +++ b/frameworks/native/ability/native/ability_business_error/ability_business_error.cpp @@ -131,6 +131,7 @@ static std::unordered_map ERR_CODE_MAP = { { AbilityErrorCode::ERROR_CODE_TARGET_BUNDLE_NOT_EXIST, ERROR_MSG_TARGET_BUNDLE_NOT_EXIST }, { AbilityErrorCode::ERROR_CODE_SET_SUPPORTED_PROCESS_CACHE_AGAIN, ERROR_MSG_SET_SUPPORTED_PROCESS_CACHE_AGAIN }, { AbilityErrorCode::ERROR_CODE_NO_RESIDENT_PERMISSION, ERROR_MSG_NO_RESIDENT_PERMISSION }, + { AbilityErrorCode::ERROR_CODE_TWIN_NOT_SUPPORTED, ERR_TWIN_NOT_SUPPORTED }, }; static std::unordered_map INNER_TO_JS_ERROR_CODE_MAP { diff --git a/interfaces/inner_api/ability_manager/include/ability_manager_errors.h b/interfaces/inner_api/ability_manager/include/ability_manager_errors.h index 9e9a725637..9de355fc54 100644 --- a/interfaces/inner_api/ability_manager/include/ability_manager_errors.h +++ b/interfaces/inner_api/ability_manager/include/ability_manager_errors.h @@ -504,6 +504,11 @@ enum { * Native error(2097249) no resident process permissions set. */ ERR_NO_RESIDENT_PERMISSION, + + /** + * Result(2097250) not support twin. + */ + ERR_TWIN_NOT_SUPPORTED, }; enum { diff --git a/interfaces/inner_api/app_manager/src/appmgr/running_multi_info.cpp b/interfaces/inner_api/app_manager/src/appmgr/running_multi_info.cpp index a3d2ee9e88..a514931717 100644 --- a/interfaces/inner_api/app_manager/src/appmgr/running_multi_info.cpp +++ b/interfaces/inner_api/app_manager/src/appmgr/running_multi_info.cpp @@ -68,8 +68,8 @@ bool RunningMultiAppInfo::Marshalling(Parcel &parcel) const WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, twin.appTwinIndex); WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, twin.uid); if (!parcel.WriteInt32Vector(twin.pids)) { - TAG_LOGE(AAFwkTag::APPMGR, "read instance failed."); - return false; + TAG_LOGE(AAFwkTag::APPMGR, "read instance failed."); + return false; } } return true; diff --git a/interfaces/kits/native/ability/native/ability_business_error/ability_business_error.h b/interfaces/kits/native/ability/native/ability_business_error/ability_business_error.h index 6182bbde15..e39a9b66e5 100644 --- a/interfaces/kits/native/ability/native/ability_business_error/ability_business_error.h +++ b/interfaces/kits/native/ability/native/ability_business_error/ability_business_error.h @@ -141,6 +141,9 @@ enum class AbilityErrorCode { // Ability already running. ERROR_ABILITY_ALREADY_RUNNING = 16000068, + // not support twin app. + ERROR_CODE_TWIN_NOT_SUPPORTED = 16000072, + // invalid caller. ERROR_CODE_INVALID_CALLER = 16200001, diff --git a/services/appmgr/include/app_mgr_service_inner.h b/services/appmgr/include/app_mgr_service_inner.h index 5411f9240d..3a25464010 100644 --- a/services/appmgr/include/app_mgr_service_inner.h +++ b/services/appmgr/include/app_mgr_service_inner.h @@ -1423,7 +1423,6 @@ private: std::shared_ptr appProcessManager_; std::shared_ptr remoteClientManager_; std::shared_ptr appRunningManager_; - std::shared_ptr appRunnningRecord_; std::shared_ptr taskHandler_; std::shared_ptr eventHandler_; std::shared_ptr configuration_; diff --git a/services/appmgr/src/app_mgr_service.cpp b/services/appmgr/src/app_mgr_service.cpp index a241938c73..1c2ef45f3c 100644 --- a/services/appmgr/src/app_mgr_service.cpp +++ b/services/appmgr/src/app_mgr_service.cpp @@ -384,6 +384,10 @@ int32_t AppMgrService::GetRunningMultiAppInfoByBundleName(const std::string &bun if (!IsReady()) { return ERR_INVALID_OPERATION; } + auto isShellCall = AAFwk::PermissionVerification::GetInstance()->IsShellCall(); + if (!isShellCall) { + TAG_LOGE(AAFwkTag::APPMGR, "permission denied, only called by shell."); + return ERR_INVALID_OPERATION; return appMgrServiceInner_->GetRunningMultiAppInfoByBundleName(bundleName, info); } diff --git a/services/appmgr/src/app_mgr_service_inner.cpp b/services/appmgr/src/app_mgr_service_inner.cpp index 7c5c898d63..82dcdb73c2 100644 --- a/services/appmgr/src/app_mgr_service_inner.cpp +++ b/services/appmgr/src/app_mgr_service_inner.cpp @@ -1420,13 +1420,12 @@ int32_t AppMgrServiceInner::GetRunningMultiAppInfoByBundleName(const std::string continue; } info.bundleName = bundleName; - MultiAppModeData multiAppModeData; - info.mode = static_cast(multiAppModeData.type); + info.mode = static_cast(appRecord->GetApplicationInfo()->type); if (info.mode == static_cast(MultiAppModeType::UNSPECIFIED)) { - break; + return ERR_TWIN_NOT_SUPPORTED; } if (info.mode == static_cast(MultiAppModeType::APP_CLONE)) { - auto childAppRecordMap = appRunnningRecord_->GetChildAppRecordMap(); + auto childAppRecordMap = appRecord->GetChildAppRecordMap(); if (childAppRecordMap.empty()) { return ERR_INVALID_VALUE; } From ea3f86a1bcbbdc47a71be4cfcd2b56156acd5a30 Mon Sep 17 00:00:00 2001 From: mashaohua7 Date: Thu, 9 May 2024 16:29:47 +0800 Subject: [PATCH 008/174] =?UTF-8?q?=E9=80=9A=E8=BF=87bundlename=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E8=BF=90=E8=A1=8C=E6=97=B6=E5=BA=94=E7=94=A8=E5=88=86?= =?UTF-8?q?=E8=BA=AB=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: mashaohua7 --- .../app_manager/include/appmgr/app_mgr_ipc_interface_code.h | 2 +- services/appmgr/src/app_mgr_service.cpp | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_ipc_interface_code.h b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_ipc_interface_code.h index a336cf9a26..280a97422f 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_ipc_interface_code.h +++ b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_ipc_interface_code.h @@ -99,7 +99,7 @@ enum class AppMgrInterfaceCode { PRELOAD_APPLICATION = 73, SET_SUPPORTED_PROCESS_CACHE_SELF = 74, APP_GET_RUNNING_PROCESSES_BY_BUNDLE_TYPE = 75, - GET_RUNNING_MULTIAPP_INFO_By_BUNDLENAME = 76, + GET_RUNNING_MULTIAPP_INFO_BY_BUNDLENAME = 76, }; } // AppExecFwk } // OHOS diff --git a/services/appmgr/src/app_mgr_service.cpp b/services/appmgr/src/app_mgr_service.cpp index 1c2ef45f3c..a241938c73 100644 --- a/services/appmgr/src/app_mgr_service.cpp +++ b/services/appmgr/src/app_mgr_service.cpp @@ -384,10 +384,6 @@ int32_t AppMgrService::GetRunningMultiAppInfoByBundleName(const std::string &bun if (!IsReady()) { return ERR_INVALID_OPERATION; } - auto isShellCall = AAFwk::PermissionVerification::GetInstance()->IsShellCall(); - if (!isShellCall) { - TAG_LOGE(AAFwkTag::APPMGR, "permission denied, only called by shell."); - return ERR_INVALID_OPERATION; return appMgrServiceInner_->GetRunningMultiAppInfoByBundleName(bundleName, info); } From 355837e69b32e6a7c95b351f2f8fec7de8ce2420 Mon Sep 17 00:00:00 2001 From: mashaohua7 Date: Thu, 9 May 2024 17:27:53 +0800 Subject: [PATCH 009/174] =?UTF-8?q?=E9=80=9A=E8=BF=87bundlename=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E8=BF=90=E8=A1=8C=E6=97=B6=E5=BA=94=E7=94=A8=E5=88=86?= =?UTF-8?q?=E8=BA=AB=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: mashaohua7 --- services/appmgr/src/app_mgr_service_inner.cpp | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/services/appmgr/src/app_mgr_service_inner.cpp b/services/appmgr/src/app_mgr_service_inner.cpp index 82dcdb73c2..fdc0b12861 100644 --- a/services/appmgr/src/app_mgr_service_inner.cpp +++ b/services/appmgr/src/app_mgr_service_inner.cpp @@ -1435,18 +1435,18 @@ int32_t AppMgrServiceInner::GetRunningMultiAppInfoByBundleName(const std::string info.isolation[i].pids.emplace_back(appRecord->GetPriorityObject()->GetPid()); for (auto it : childAppRecordMap) { info.isolation[i].pids.emplace_back(it.first); - } - } else { - RunningAppTwin twinInfo; - twinInfo.appTwinIndex = appRecord->GetAppIndex(); - twinInfo.uid = appRecord->GetUid(); - twinInfo.pids.emplace_back(appRecord->GetPriorityObject()->GetPid()); - for (auto it : childAppRecordMap) { - twinInfo.pids.emplace_back(it.first); - } - info.isolation.emplace_back(twinInfo); + } } + return ERR_OK; } + RunningAppTwin twinInfo; + twinInfo.appTwinIndex = appRecord->GetAppIndex(); + twinInfo.uid = appRecord->GetUid(); + twinInfo.pids.emplace_back(appRecord->GetPriorityObject()->GetPid()); + for (auto it : childAppRecordMap) { + twinInfo.pids.emplace_back(it.first); + } + info.isolation.emplace_back(twinInfo); } } return ERR_OK; From fc1c4518228d170fd7a01db1d33fefebbc90daa6 Mon Sep 17 00:00:00 2001 From: mashaohua7 Date: Thu, 9 May 2024 17:41:11 +0800 Subject: [PATCH 010/174] =?UTF-8?q?=E9=80=9A=E8=BF=87bundlename=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E8=BF=90=E8=A1=8C=E6=97=B6=E5=BA=94=E7=94=A8=E5=88=86?= =?UTF-8?q?=E8=BA=AB=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: mashaohua7 --- interfaces/inner_api/app_manager/src/appmgr/app_mgr_stub.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/inner_api/app_manager/src/appmgr/app_mgr_stub.cpp b/interfaces/inner_api/app_manager/src/appmgr/app_mgr_stub.cpp index e8955ba648..ab24f0f80a 100644 --- a/interfaces/inner_api/app_manager/src/appmgr/app_mgr_stub.cpp +++ b/interfaces/inner_api/app_manager/src/appmgr/app_mgr_stub.cpp @@ -334,7 +334,7 @@ int32_t AppMgrStub::HandleGetRunningMultiAppInfoByBundleName(MessageParcel &data RunningMultiAppInfo info; int32_t result = GetRunningMultiAppInfoByBundleName(bundleName, info); if (!reply.WriteParcelable(&info)) { - return ERR_INVALID_VALUE; + return ERR_INVALID_VALUE; } if (!reply.WriteInt32(result)) { TAG_LOGE(AAFwkTag::APPMGR, "fail to write result."); From 669391527f2771062e81c0de1131dd25a11486ae Mon Sep 17 00:00:00 2001 From: mashaohua7 Date: Thu, 9 May 2024 18:47:44 +0800 Subject: [PATCH 011/174] =?UTF-8?q?=E9=80=9A=E8=BF=87bundlename=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E8=BF=90=E8=A1=8C=E6=97=B6=E5=BA=94=E7=94=A8=E5=88=86?= =?UTF-8?q?=E8=BA=AB=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: mashaohua7 --- services/appmgr/src/app_mgr_service_inner.cpp | 33 +++++++++++-------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/services/appmgr/src/app_mgr_service_inner.cpp b/services/appmgr/src/app_mgr_service_inner.cpp index 00f066f8e2..b77dfff80a 100644 --- a/services/appmgr/src/app_mgr_service_inner.cpp +++ b/services/appmgr/src/app_mgr_service_inner.cpp @@ -1439,24 +1439,31 @@ int32_t AppMgrServiceInner::GetRunningMultiAppInfoByBundleName(const std::string if (childAppRecordMap.empty()) { return ERR_INVALID_VALUE; } + unsigned int index = 0; + bool IsAppIndexExist = false; for (unsigned int i = 0; i < info.isolation.size(); i++) { if (info.isolation[i].appTwinIndex == appRecord->GetAppIndex()) { - info.isolation[i].uid = appRecord->GetUid(); - info.isolation[i].pids.emplace_back(appRecord->GetPriorityObject()->GetPid()); - for (auto it : childAppRecordMap) { - info.isolation[i].pids.emplace_back(it.first); + index = i; + IsAppIndexExist = true; + break; } } - return ERR_OK; + if (IsAppIndexExist) { + info.isolation[index].uid = appRecord->GetUid(); + info.isolation[index].pids.emplace_back(appRecord->GetPriorityObject()->GetPid()); + for (auto it : childAppRecordMap) { + info.isolation[index].pids.emplace_back(it.first); + } + } else { + RunningAppTwin twinInfo; + twinInfo.appTwinIndex = appRecord->GetAppIndex(); + twinInfo.uid = appRecord->GetUid(); + twinInfo.pids.emplace_back(appRecord->GetPriorityObject()->GetPid()); + for (auto it : childAppRecordMap) { + twinInfo.pids.emplace_back(it.first); + } + info.isolation.emplace_back(twinInfo); } - RunningAppTwin twinInfo; - twinInfo.appTwinIndex = appRecord->GetAppIndex(); - twinInfo.uid = appRecord->GetUid(); - twinInfo.pids.emplace_back(appRecord->GetPriorityObject()->GetPid()); - for (auto it : childAppRecordMap) { - twinInfo.pids.emplace_back(it.first); - } - info.isolation.emplace_back(twinInfo); } } return ERR_OK; From 5048e17296cd6da26d1f2db3ccff7209d92148e0 Mon Sep 17 00:00:00 2001 From: mashaohua7 Date: Thu, 9 May 2024 19:24:24 +0800 Subject: [PATCH 012/174] =?UTF-8?q?=E9=80=9A=E8=BF=87bundlename=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E8=BF=90=E8=A1=8C=E6=97=B6=E5=BA=94=E7=94=A8=E5=88=86?= =?UTF-8?q?=E8=BA=AB=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: mashaohua7 --- interfaces/inner_api/app_manager/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/inner_api/app_manager/BUILD.gn b/interfaces/inner_api/app_manager/BUILD.gn index 59ad1b29a7..dcabd2fe29 100644 --- a/interfaces/inner_api/app_manager/BUILD.gn +++ b/interfaces/inner_api/app_manager/BUILD.gn @@ -105,11 +105,11 @@ ohos_shared_library("app_manager") { "src/appmgr/render_state_data.cpp", "src/appmgr/render_state_observer_proxy.cpp", "src/appmgr/render_state_observer_stub.cpp", + "src/appmgr/running_multi_info.cpp", "src/appmgr/running_process_info.cpp", "src/appmgr/start_specified_ability_response_proxy.cpp", "src/appmgr/start_specified_ability_response_stub.cpp", "src/appmgr/system_memory_attr.cpp", - "src/appmgr/running_multi_info.cpp", ] public_configs = [ From cd9fe2e3ca86508122d9ab4f8c0a66475bed83a9 Mon Sep 17 00:00:00 2001 From: mashaohua7 Date: Fri, 10 May 2024 09:52:20 +0800 Subject: [PATCH 013/174] =?UTF-8?q?=E9=80=9A=E8=BF=87bundlename=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E8=BF=90=E8=A1=8C=E6=97=B6=E5=BA=94=E7=94=A8=E5=88=86?= =?UTF-8?q?=E8=BA=AB=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: mashaohua7 --- .../native/ability_business_error/ability_business_error.cpp | 3 +++ .../ability_manager/include/ability_manager_errors.h | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/frameworks/native/ability/native/ability_business_error/ability_business_error.cpp b/frameworks/native/ability/native/ability_business_error/ability_business_error.cpp index aa00f0b0cc..6cb7548510 100644 --- a/frameworks/native/ability/native/ability_business_error/ability_business_error.cpp +++ b/frameworks/native/ability/native/ability_business_error/ability_business_error.cpp @@ -79,6 +79,7 @@ constexpr const char* ERROR_MSG_SET_SUPPORTED_PROCESS_CACHE_AGAIN = "Can not set constexpr const char* ERROR_MSG_NO_RESIDENT_PERMISSION = "The caller application can only set the resident status of the configured process."; constexpr const char* ERROR_MSG_APP_TWIN_INDEX_INVALID = "The target app twin with the specified index does not exist."; +constexpr const char* ERROR_MSG_TWIN_NOT_SUPPORTED = "The target app not support clone twin."; // follow ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST of appexecfwk_errors.h in bundle_framework constexpr int32_t ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST = 8521220; @@ -134,6 +135,7 @@ static std::unordered_map ERR_CODE_MAP = { { AbilityErrorCode::ERROR_CODE_NO_RESIDENT_PERMISSION, ERROR_MSG_NO_RESIDENT_PERMISSION }, { AbilityErrorCode::ERROR_CODE_TWIN_NOT_SUPPORTED, ERR_TWIN_NOT_SUPPORTED }, { AbilityErrorCode::ERROR_APP_TWIN_INDEX_INVALID, ERROR_MSG_APP_TWIN_INDEX_INVALID }, + { AbilityErrorCode::ERROR_CODE_TWIN_NOT_SUPPORTED, ERROR_MSG_TWIN_NOT_SUPPORTED }, }; static std::unordered_map INNER_TO_JS_ERROR_CODE_MAP { @@ -191,6 +193,7 @@ static std::unordered_map INNER_TO_JS_ERROR_CODE_MAP {ERR_SET_SUPPORTED_PROCESS_CACHE_AGAIN, AbilityErrorCode::ERROR_CODE_SET_SUPPORTED_PROCESS_CACHE_AGAIN}, {ERR_NO_RESIDENT_PERMISSION, AbilityErrorCode::ERROR_CODE_NO_RESIDENT_PERMISSION}, {ERR_APP_TWIN_INDEX_INVALID, AbilityErrorCode::ERROR_APP_TWIN_INDEX_INVALID}, + {ERR_APP_TWIN_NOT_SUPPORTED,, AbilityErrorCode::ERROR_CODE_TWIN_NOT_SUPPORTED}, }; } diff --git a/interfaces/inner_api/ability_manager/include/ability_manager_errors.h b/interfaces/inner_api/ability_manager/include/ability_manager_errors.h index 674ec68528..726a8b202f 100644 --- a/interfaces/inner_api/ability_manager/include/ability_manager_errors.h +++ b/interfaces/inner_api/ability_manager/include/ability_manager_errors.h @@ -508,7 +508,9 @@ enum { /** * Result(2097250) not support twin. */ - ERR_TWIN_NOT_SUPPORTED, + ERR_APP_TWIN_NOT_SUPPORTED, + + /** * Result(2097250) for app twin index does not exist. */ ERR_APP_TWIN_INDEX_INVALID, From 8d5791cbf0dcb7e720f295ef32c12ce8a5deb6ed Mon Sep 17 00:00:00 2001 From: mashaohua7 Date: Fri, 10 May 2024 09:55:05 +0800 Subject: [PATCH 014/174] =?UTF-8?q?=E9=80=9A=E8=BF=87bundlename=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E8=BF=90=E8=A1=8C=E6=97=B6=E5=BA=94=E7=94=A8=E5=88=86?= =?UTF-8?q?=E8=BA=AB=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: mashaohua7 --- .../native/ability_business_error/ability_business_error.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/frameworks/native/ability/native/ability_business_error/ability_business_error.cpp b/frameworks/native/ability/native/ability_business_error/ability_business_error.cpp index 6cb7548510..78dfef3db5 100644 --- a/frameworks/native/ability/native/ability_business_error/ability_business_error.cpp +++ b/frameworks/native/ability/native/ability_business_error/ability_business_error.cpp @@ -133,7 +133,6 @@ static std::unordered_map ERR_CODE_MAP = { { AbilityErrorCode::ERROR_CODE_TARGET_BUNDLE_NOT_EXIST, ERROR_MSG_TARGET_BUNDLE_NOT_EXIST }, { AbilityErrorCode::ERROR_CODE_SET_SUPPORTED_PROCESS_CACHE_AGAIN, ERROR_MSG_SET_SUPPORTED_PROCESS_CACHE_AGAIN }, { AbilityErrorCode::ERROR_CODE_NO_RESIDENT_PERMISSION, ERROR_MSG_NO_RESIDENT_PERMISSION }, - { AbilityErrorCode::ERROR_CODE_TWIN_NOT_SUPPORTED, ERR_TWIN_NOT_SUPPORTED }, { AbilityErrorCode::ERROR_APP_TWIN_INDEX_INVALID, ERROR_MSG_APP_TWIN_INDEX_INVALID }, { AbilityErrorCode::ERROR_CODE_TWIN_NOT_SUPPORTED, ERROR_MSG_TWIN_NOT_SUPPORTED }, }; From 0b6d2bd7c4e5373c4e24901db22349545adeb1da Mon Sep 17 00:00:00 2001 From: mashaohua7 Date: Fri, 10 May 2024 06:55:42 +0000 Subject: [PATCH 015/174] update frameworks/native/ability/native/ability_business_error/ability_business_error.cpp. Signed-off-by: mashaohua7 --- .../native/ability_business_error/ability_business_error.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/native/ability/native/ability_business_error/ability_business_error.cpp b/frameworks/native/ability/native/ability_business_error/ability_business_error.cpp index 78dfef3db5..82adbc0866 100644 --- a/frameworks/native/ability/native/ability_business_error/ability_business_error.cpp +++ b/frameworks/native/ability/native/ability_business_error/ability_business_error.cpp @@ -192,7 +192,7 @@ static std::unordered_map INNER_TO_JS_ERROR_CODE_MAP {ERR_SET_SUPPORTED_PROCESS_CACHE_AGAIN, AbilityErrorCode::ERROR_CODE_SET_SUPPORTED_PROCESS_CACHE_AGAIN}, {ERR_NO_RESIDENT_PERMISSION, AbilityErrorCode::ERROR_CODE_NO_RESIDENT_PERMISSION}, {ERR_APP_TWIN_INDEX_INVALID, AbilityErrorCode::ERROR_APP_TWIN_INDEX_INVALID}, - {ERR_APP_TWIN_NOT_SUPPORTED,, AbilityErrorCode::ERROR_CODE_TWIN_NOT_SUPPORTED}, + {ERR_APP_TWIN_NOT_SUPPORTED, AbilityErrorCode::ERROR_CODE_TWIN_NOT_SUPPORTED}, }; } From ea4469497a047b441ecafeb57adc4255c976a93c Mon Sep 17 00:00:00 2001 From: mashaohua7 Date: Fri, 10 May 2024 06:58:52 +0000 Subject: [PATCH 016/174] update services/appmgr/src/app_mgr_service_inner.cpp. Signed-off-by: mashaohua7 --- services/appmgr/src/app_mgr_service_inner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/appmgr/src/app_mgr_service_inner.cpp b/services/appmgr/src/app_mgr_service_inner.cpp index b77dfff80a..6f08631279 100644 --- a/services/appmgr/src/app_mgr_service_inner.cpp +++ b/services/appmgr/src/app_mgr_service_inner.cpp @@ -1432,7 +1432,7 @@ int32_t AppMgrServiceInner::GetRunningMultiAppInfoByBundleName(const std::string info.bundleName = bundleName; info.mode = static_cast(appRecord->GetApplicationInfo()->type); if (info.mode == static_cast(MultiAppModeType::UNSPECIFIED)) { - return ERR_TWIN_NOT_SUPPORTED; + return AAFwk::ERR_APP_TWIN_NOT_SUPPORTED; } if (info.mode == static_cast(MultiAppModeType::APP_CLONE)) { auto childAppRecordMap = appRecord->GetChildAppRecordMap(); From 5b3ce0af1809051957168a33185aa4bad6b4ec63 Mon Sep 17 00:00:00 2001 From: mashaohua7 Date: Fri, 10 May 2024 07:01:09 +0000 Subject: [PATCH 017/174] update interfaces/inner_api/app_manager/src/appmgr/app_mgr_stub.cpp. Signed-off-by: mashaohua7 --- interfaces/inner_api/app_manager/src/appmgr/app_mgr_stub.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/inner_api/app_manager/src/appmgr/app_mgr_stub.cpp b/interfaces/inner_api/app_manager/src/appmgr/app_mgr_stub.cpp index ab24f0f80a..22e4f0f542 100644 --- a/interfaces/inner_api/app_manager/src/appmgr/app_mgr_stub.cpp +++ b/interfaces/inner_api/app_manager/src/appmgr/app_mgr_stub.cpp @@ -102,7 +102,7 @@ AppMgrStub::AppMgrStub() &AppMgrStub::HandleDumpHeapMemory; memberFuncMap_[static_cast(AppMgrInterfaceCode::DUMP_JSHEAP_MEMORY_PROCESS)] = &AppMgrStub::HandleDumpJsHeapMemory; - memberFuncMap_[static_cast(AppMgrInterfaceCode::GET_RUNNING_MULTIAPP_INFO_By_BUNDLENAME)] = + memberFuncMap_[static_cast(AppMgrInterfaceCode::GET_RUNNING_MULTIAPP_INFO_BY_BUNDLENAME)] = &AppMgrStub::HandleGetRunningMultiAppInfoByBundleName; #ifdef ABILITY_COMMAND_FOR_TEST memberFuncMap_[static_cast(AppMgrInterfaceCode::BLOCK_APP_SERVICE)] = From 574efb09aaa3b3a10c2cb8b4593573d626254aad Mon Sep 17 00:00:00 2001 From: mashaohua7 Date: Fri, 10 May 2024 07:02:06 +0000 Subject: [PATCH 018/174] update interfaces/inner_api/app_manager/src/appmgr/app_mgr_proxy.cpp. Signed-off-by: mashaohua7 --- interfaces/inner_api/app_manager/src/appmgr/app_mgr_proxy.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/inner_api/app_manager/src/appmgr/app_mgr_proxy.cpp b/interfaces/inner_api/app_manager/src/appmgr/app_mgr_proxy.cpp index 1eeaf491c9..eed5e514e3 100644 --- a/interfaces/inner_api/app_manager/src/appmgr/app_mgr_proxy.cpp +++ b/interfaces/inner_api/app_manager/src/appmgr/app_mgr_proxy.cpp @@ -250,7 +250,7 @@ int32_t AppMgrProxy::GetRunningMultiAppInfoByBundleName(const std::string &bundl TAG_LOGE(AAFwkTag::APPMGR, "bundleName write failed."); return ERR_INVALID_VALUE; } - int32_t ret = SendRequest(AppMgrInterfaceCode::GET_RUNNING_MULTIAPP_INFO_By_BUNDLENAME, data, reply, option); + int32_t ret = SendRequest(AppMgrInterfaceCode::GET_RUNNING_MULTIAPP_INFO_BY_BUNDLENAME, data, reply, option); if (ret != NO_ERROR) { TAG_LOGW(AAFwkTag::APPMGR, "SendRequest is failed, error code: %{public}d", ret); return ret; From bc87515c24b02c615833cd672cbc3c2f934b01c9 Mon Sep 17 00:00:00 2001 From: mashaohua7 Date: Fri, 10 May 2024 07:29:15 +0000 Subject: [PATCH 019/174] update services/appmgr/src/app_mgr_service_inner.cpp. Signed-off-by: mashaohua7 --- services/appmgr/src/app_mgr_service_inner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/appmgr/src/app_mgr_service_inner.cpp b/services/appmgr/src/app_mgr_service_inner.cpp index 6f08631279..c2690fd8ed 100644 --- a/services/appmgr/src/app_mgr_service_inner.cpp +++ b/services/appmgr/src/app_mgr_service_inner.cpp @@ -1430,7 +1430,7 @@ int32_t AppMgrServiceInner::GetRunningMultiAppInfoByBundleName(const std::string continue; } info.bundleName = bundleName; - info.mode = static_cast(appRecord->GetApplicationInfo()->type); + info.mode = static_cast(appRecord->GetApplicationInfo()->multiAppMode.type); if (info.mode == static_cast(MultiAppModeType::UNSPECIFIED)) { return AAFwk::ERR_APP_TWIN_NOT_SUPPORTED; } From 08c0d2b2ec2662386dcd24f304efcf796ed8128a Mon Sep 17 00:00:00 2001 From: mashaohua7 Date: Fri, 10 May 2024 07:31:37 +0000 Subject: [PATCH 020/174] update frameworks/native/ability/native/ability_business_error/ability_business_error.cpp. Signed-off-by: mashaohua7 --- .../native/ability_business_error/ability_business_error.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/native/ability/native/ability_business_error/ability_business_error.cpp b/frameworks/native/ability/native/ability_business_error/ability_business_error.cpp index 82adbc0866..5b8e645800 100644 --- a/frameworks/native/ability/native/ability_business_error/ability_business_error.cpp +++ b/frameworks/native/ability/native/ability_business_error/ability_business_error.cpp @@ -79,7 +79,7 @@ constexpr const char* ERROR_MSG_SET_SUPPORTED_PROCESS_CACHE_AGAIN = "Can not set constexpr const char* ERROR_MSG_NO_RESIDENT_PERMISSION = "The caller application can only set the resident status of the configured process."; constexpr const char* ERROR_MSG_APP_TWIN_INDEX_INVALID = "The target app twin with the specified index does not exist."; -constexpr const char* ERROR_MSG_TWIN_NOT_SUPPORTED = "The target app not support clone twin."; +constexpr const char* ERROR_MSG_TWIN_NOT_SUPPORTED = "App twin or multi-instance is not supported."; // follow ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST of appexecfwk_errors.h in bundle_framework constexpr int32_t ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST = 8521220; From 8362da0e23c723a4d14de37e9bcdce539e73974f Mon Sep 17 00:00:00 2001 From: mashaohua7 Date: Fri, 10 May 2024 07:37:59 +0000 Subject: [PATCH 021/174] update interfaces/inner_api/ability_manager/include/ability_manager_errors.h. Signed-off-by: mashaohua7 --- .../ability_manager/include/ability_manager_errors.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/interfaces/inner_api/ability_manager/include/ability_manager_errors.h b/interfaces/inner_api/ability_manager/include/ability_manager_errors.h index 726a8b202f..b0776c6e1a 100644 --- a/interfaces/inner_api/ability_manager/include/ability_manager_errors.h +++ b/interfaces/inner_api/ability_manager/include/ability_manager_errors.h @@ -505,15 +505,15 @@ enum { */ ERR_NO_RESIDENT_PERMISSION, - /** - * Result(2097250) not support twin. - */ - ERR_APP_TWIN_NOT_SUPPORTED, - /** * Result(2097250) for app twin index does not exist. */ ERR_APP_TWIN_INDEX_INVALID, + + /** + * Result(2097251) not support twin. + */ + ERR_APP_TWIN_NOT_SUPPORTED, }; enum { From 423f3e21f8404a282b3a9f310fabaf0f2264db84 Mon Sep 17 00:00:00 2001 From: mashaohua7 Date: Fri, 10 May 2024 07:59:11 +0000 Subject: [PATCH 022/174] update services/appmgr/src/app_mgr_service.cpp. Signed-off-by: mashaohua7 --- services/appmgr/src/app_mgr_service.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/services/appmgr/src/app_mgr_service.cpp b/services/appmgr/src/app_mgr_service.cpp index df69e2e11c..19cc77aca4 100644 --- a/services/appmgr/src/app_mgr_service.cpp +++ b/services/appmgr/src/app_mgr_service.cpp @@ -385,6 +385,11 @@ int32_t AppMgrService::GetRunningMultiAppInfoByBundleName(const std::string &bun if (!IsReady()) { return ERR_INVALID_OPERATION; } + bool isCallingPermission = AAFwk::PermissionVerification::GetInstance()->VerifyRunningInfoPerm(); + if (!isCallingPermission) { + TAG_LOGE(AAFwkTag::APPMGR, "GetRunningMultiAppInfoByBundleName, Permission verification failed."); + return ERR_PERMISSION_DENIED; + } return appMgrServiceInner_->GetRunningMultiAppInfoByBundleName(bundleName, info); } From ba92dd60877ae5f67b4c02897cfb0f429d2aece3 Mon Sep 17 00:00:00 2001 From: mashaohua7 Date: Fri, 10 May 2024 08:20:59 +0000 Subject: [PATCH 023/174] update services/appmgr/src/app_mgr_service_inner.cpp. Signed-off-by: mashaohua7 --- services/appmgr/src/app_mgr_service_inner.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/services/appmgr/src/app_mgr_service_inner.cpp b/services/appmgr/src/app_mgr_service_inner.cpp index c2690fd8ed..4773e2e030 100644 --- a/services/appmgr/src/app_mgr_service_inner.cpp +++ b/services/appmgr/src/app_mgr_service_inner.cpp @@ -1436,12 +1436,9 @@ int32_t AppMgrServiceInner::GetRunningMultiAppInfoByBundleName(const std::string } if (info.mode == static_cast(MultiAppModeType::APP_CLONE)) { auto childAppRecordMap = appRecord->GetChildAppRecordMap(); - if (childAppRecordMap.empty()) { - return ERR_INVALID_VALUE; - } - unsigned int index = 0; + uint32_t index = 0; bool IsAppIndexExist = false; - for (unsigned int i = 0; i < info.isolation.size(); i++) { + for (uint32_t i = 0; i < info.isolation.size(); i++) { if (info.isolation[i].appTwinIndex == appRecord->GetAppIndex()) { index = i; IsAppIndexExist = true; From 57298c606dfa7a53cdb7c9740c2ef9d44404f368 Mon Sep 17 00:00:00 2001 From: mashaohua7 Date: Fri, 10 May 2024 08:22:43 +0000 Subject: [PATCH 024/174] update services/appmgr/src/app_mgr_service_inner.cpp. Signed-off-by: mashaohua7 --- services/appmgr/src/app_mgr_service_inner.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/services/appmgr/src/app_mgr_service_inner.cpp b/services/appmgr/src/app_mgr_service_inner.cpp index 4773e2e030..e0bf123e72 100644 --- a/services/appmgr/src/app_mgr_service_inner.cpp +++ b/services/appmgr/src/app_mgr_service_inner.cpp @@ -1446,7 +1446,6 @@ int32_t AppMgrServiceInner::GetRunningMultiAppInfoByBundleName(const std::string } } if (IsAppIndexExist) { - info.isolation[index].uid = appRecord->GetUid(); info.isolation[index].pids.emplace_back(appRecord->GetPriorityObject()->GetPid()); for (auto it : childAppRecordMap) { info.isolation[index].pids.emplace_back(it.first); From c90d45c50501a266333fea1c5c26deb629d0d05e Mon Sep 17 00:00:00 2001 From: jiangzhijun8 Date: Fri, 10 May 2024 10:55:50 +0800 Subject: [PATCH 025/174] Issue: https://gitee.com/openharmony/ability_ability_runtime/issues/I9O1FY MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Comment: ability_runtime仓库中涉及的五条第三方依赖的整改 Signed-off-by: jiangzhijun8 --- bundle.json | 3 ++- frameworks/native/appkit/BUILD.gn | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/bundle.json b/bundle.json index c451807a20..7755b33c0f 100644 --- a/bundle.json +++ b/bundle.json @@ -83,7 +83,8 @@ "storage_service", "toolchain", "webview", - "window_manager" + "window_manager", + "json" ], "third_party": [ "icu", diff --git a/frameworks/native/appkit/BUILD.gn b/frameworks/native/appkit/BUILD.gn index ce7bc0f450..d7f0ce40ab 100644 --- a/frameworks/native/appkit/BUILD.gn +++ b/frameworks/native/appkit/BUILD.gn @@ -48,7 +48,6 @@ config("appkit_config") { "${ability_runtime_path}/interfaces/kits/native/appkit/app", "${ability_runtime_path}/interfaces/kits/native/appkit/dfr", "${ability_runtime_path}/interfaces/kits/native/ability/native", - "//third_party/json/include", ] } @@ -194,6 +193,7 @@ ohos_shared_library("appkit_native") { "i18n:preferred_language", "init:libbegetutil", "ipc:ipc_core", + "json:json_static", "napi:ace_napi", "resource_management:global_resmgr", "safwk:system_ability_fwk", @@ -281,6 +281,7 @@ ohos_shared_library("app_context") { "hitrace:hitrace_meter", "init:libbegetutil", "ipc:ipc_core", + "json:json_static", "napi:ace_napi", "resource_management:global_resmgr", "samgr:samgr_proxy", @@ -338,6 +339,7 @@ ohos_shared_library("app_context_utils") { "hilog:libhilog", "hitrace:hitrace_meter", "ipc:ipc_core", + "json:json_static", "napi:ace_napi", "resource_management:global_resmgr", "resource_management:resmgr_napi_core", @@ -402,6 +404,7 @@ ohos_shared_library("appkit_delegator") { "eventhandler:libeventhandler", "hilog:libhilog", "ipc:ipc_core", + "json:json_static", "napi:ace_napi", ] @@ -449,6 +452,7 @@ ohos_shared_library("appkit_manager_helper") { "hilog:libhilog", "hitrace:hitrace_meter", "ipc:ipc_core", + "json:json_static", "samgr:samgr_proxy", ] From d4c75d7982eaba2243680bb8bc1acd9677e390ec Mon Sep 17 00:00:00 2001 From: mashaohua7 Date: Fri, 10 May 2024 17:05:10 +0800 Subject: [PATCH 026/174] =?UTF-8?q?=E9=80=9A=E8=BF=87bundlename=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E8=BF=90=E8=A1=8C=E6=97=B6=E5=BA=94=E7=94=A8=E5=88=86?= =?UTF-8?q?=E8=BA=AB=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: mashaohua7 --- .../app_manager/src/appmgr/app_mgr_proxy.cpp | 2 +- .../app_manager/src/appmgr/running_multi_info.cpp | 2 +- services/appmgr/src/app_mgr_service.cpp | 2 +- services/appmgr/src/app_mgr_service_inner.cpp | 11 ++++------- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/interfaces/inner_api/app_manager/src/appmgr/app_mgr_proxy.cpp b/interfaces/inner_api/app_manager/src/appmgr/app_mgr_proxy.cpp index eed5e514e3..dc8d2b2f5b 100644 --- a/interfaces/inner_api/app_manager/src/appmgr/app_mgr_proxy.cpp +++ b/interfaces/inner_api/app_manager/src/appmgr/app_mgr_proxy.cpp @@ -238,7 +238,7 @@ int32_t AppMgrProxy::GetAllRunningProcesses(std::vector &inf } int32_t AppMgrProxy::GetRunningMultiAppInfoByBundleName(const std::string &bundleName, - RunningMultiAppInfo &info) + RunningMultiAppInfo &info) { MessageParcel data; MessageParcel reply; diff --git a/interfaces/inner_api/app_manager/src/appmgr/running_multi_info.cpp b/interfaces/inner_api/app_manager/src/appmgr/running_multi_info.cpp index a514931717..8a6f9588bf 100644 --- a/interfaces/inner_api/app_manager/src/appmgr/running_multi_info.cpp +++ b/interfaces/inner_api/app_manager/src/appmgr/running_multi_info.cpp @@ -70,7 +70,7 @@ bool RunningMultiAppInfo::Marshalling(Parcel &parcel) const if (!parcel.WriteInt32Vector(twin.pids)) { TAG_LOGE(AAFwkTag::APPMGR, "read instance failed."); return false; - } + } } return true; } diff --git a/services/appmgr/src/app_mgr_service.cpp b/services/appmgr/src/app_mgr_service.cpp index 19cc77aca4..38b5acb6a3 100644 --- a/services/appmgr/src/app_mgr_service.cpp +++ b/services/appmgr/src/app_mgr_service.cpp @@ -385,7 +385,7 @@ int32_t AppMgrService::GetRunningMultiAppInfoByBundleName(const std::string &bun if (!IsReady()) { return ERR_INVALID_OPERATION; } - bool isCallingPermission = AAFwk::PermissionVerification::GetInstance()->VerifyRunningInfoPerm(); + bool isCallingPermission = AAFwk::PermissionVerification::GetInstance()->VerifyRunningInfoPerm(); if (!isCallingPermission) { TAG_LOGE(AAFwkTag::APPMGR, "GetRunningMultiAppInfoByBundleName, Permission verification failed."); return ERR_PERMISSION_DENIED; diff --git a/services/appmgr/src/app_mgr_service_inner.cpp b/services/appmgr/src/app_mgr_service_inner.cpp index e0bf123e72..314a236f55 100644 --- a/services/appmgr/src/app_mgr_service_inner.cpp +++ b/services/appmgr/src/app_mgr_service_inner.cpp @@ -1436,16 +1436,13 @@ int32_t AppMgrServiceInner::GetRunningMultiAppInfoByBundleName(const std::string } if (info.mode == static_cast(MultiAppModeType::APP_CLONE)) { auto childAppRecordMap = appRecord->GetChildAppRecordMap(); - uint32_t index = 0; - bool IsAppIndexExist = false; - for (uint32_t i = 0; i < info.isolation.size(); i++) { + size_t index = 0; + for (; index < info.isolation.size(); index++) { if (info.isolation[i].appTwinIndex == appRecord->GetAppIndex()) { - index = i; - IsAppIndexExist = true; break; - } } - if (IsAppIndexExist) { + } + if (index < info.isolation.size()) { info.isolation[index].pids.emplace_back(appRecord->GetPriorityObject()->GetPid()); for (auto it : childAppRecordMap) { info.isolation[index].pids.emplace_back(it.first); From ba207d6aa63f73c88efd00387c554a1946945dcb Mon Sep 17 00:00:00 2001 From: mashaohua7 Date: Fri, 10 May 2024 17:59:21 +0800 Subject: [PATCH 027/174] =?UTF-8?q?=E9=80=9A=E8=BF=87bundlename=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E8=BF=90=E8=A1=8C=E6=97=B6=E5=BA=94=E7=94=A8=E5=88=86?= =?UTF-8?q?=E8=BA=AB=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: mashaohua7 --- .../include/mock_app_mgr_service.h | 2 + .../include/mock_app_mgr_service.h | 2 + .../app_mgr_proxy_test/app_mgr_proxy_test.cpp | 26 ++++++++++- .../app_mgr_service_inner_test.cpp | 24 ++++++++++ .../app_mgr_service_test.cpp | 46 +++++++++++++++++++ .../app_mgr_stub_test/app_mgr_stub_test.cpp | 28 ++++++++++- 6 files changed, 126 insertions(+), 2 deletions(-) diff --git a/test/mock/frameworks_kits_appkit_test/include/mock_app_mgr_service.h b/test/mock/frameworks_kits_appkit_test/include/mock_app_mgr_service.h index fac765766e..bdb3d508be 100644 --- a/test/mock/frameworks_kits_appkit_test/include/mock_app_mgr_service.h +++ b/test/mock/frameworks_kits_appkit_test/include/mock_app_mgr_service.h @@ -84,6 +84,8 @@ public: MOCK_METHOD1(UnregisterRenderStateObserver, int32_t(const sptr &observer)); MOCK_METHOD2(UpdateRenderState, int32_t(pid_t renderPid, int32_t state)); MOCK_METHOD1(SetSupportedProcessCacheSelf, int32_t(bool isSupported)); + MOCK_METHOD2(GetRunningMultiAppInfoByBundleName, int32_t(const std::string &bundleName, + RunningMultiAppInfo &info)); void AttachApplication(const sptr& app) { diff --git a/test/mock/services_appmgr_test/include/mock_app_mgr_service.h b/test/mock/services_appmgr_test/include/mock_app_mgr_service.h index 228775be2e..2389027b6e 100644 --- a/test/mock/services_appmgr_test/include/mock_app_mgr_service.h +++ b/test/mock/services_appmgr_test/include/mock_app_mgr_service.h @@ -89,6 +89,8 @@ public: MOCK_METHOD2(GetProcessMemoryByPid, int32_t(const int32_t pid, int32_t & memorySize)); MOCK_METHOD3(GetRunningProcessInformation, int32_t(const std::string & bundleName, int32_t userId, std::vector &info)); + MOCK_METHOD2(GetRunningMultiAppInfoByBundleName, int32_t(const std::string &bundleName, + RunningMultiAppInfo &info)); MOCK_METHOD2(IsApplicationRunning, int32_t(const std::string &bundleName, bool &isRunning)); MOCK_METHOD4(StartChildProcess, int32_t(const std::string &srcEntry, pid_t &childPid, int32_t childProcessCount, bool isStartWithNative)); diff --git a/test/unittest/app_mgr_proxy_test/app_mgr_proxy_test.cpp b/test/unittest/app_mgr_proxy_test/app_mgr_proxy_test.cpp index 4ea49c5de9..e1db9c81a0 100644 --- a/test/unittest/app_mgr_proxy_test/app_mgr_proxy_test.cpp +++ b/test/unittest/app_mgr_proxy_test/app_mgr_proxy_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -603,5 +603,29 @@ HWTEST_F(AppMgrProxyTest, SetSupportedProcessCacheSelf_001, TestSize.Level0) TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); } + +/** + * @tc.name: GetRunningMultiAppInfoByBundleName_001 + * @tc.desc: Get multiApp information by bundleName. + * @tc.type: FUNC + * @tc.require: issueI9HMAO + */ +HWTEST_F(AppMgrProxyTest, GetRunningMultiAppInfoByBundleName_001, TestSize.Level0) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + + EXPECT_CALL(*mockAppMgrService_, SendRequest(_, _, _, _)) + .Times(1) + .WillOnce(Invoke(mockAppMgrService_.GetRefPtr(), &MockAppMgrService::InvokeSendRequest)); + + std::string bundleName = "testBundleName"; + RunningMultiAppInfo info; + appMgrProxy_->GetRunningMultiAppInfoByBundleName(bundleName, info); + EXPECT_EQ(mockAppMgrService_->code_, static_cast + (AppMgrInterfaceCode::GET_RUNNING_MULTIAPP_INFO_BY_BUNDLENAME)); + EXPECT_GE(info.size(), 0); + + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} } // namespace AppExecFwk } // namespace OHOS diff --git a/test/unittest/app_mgr_service_inner_test/app_mgr_service_inner_test.cpp b/test/unittest/app_mgr_service_inner_test/app_mgr_service_inner_test.cpp index 77980bc1c6..8e8e1bcdf5 100644 --- a/test/unittest/app_mgr_service_inner_test/app_mgr_service_inner_test.cpp +++ b/test/unittest/app_mgr_service_inner_test/app_mgr_service_inner_test.cpp @@ -4262,5 +4262,29 @@ HWTEST_F(AppMgrServiceInnerTest, OnAppCacheStateChanged_001, TestSize.Level0) TAG_LOGI(AAFwkTag::TEST, "OnAppCacheStateChanged_001 end"); } + +/** + * @tc.name: GetRunningMultiAppInfoByBundleName_001 + * @tc.desc: Get multiApp information list by bundleName. + * @tc.type: FUNC + * @tc.require: issueI9HMAO + */ +HWTEST_F(AppMgrServiceInnerTest, GetRunningMultiAppInfoByBundleName_001, TestSize.Level0) +{ + TAG_LOGI(AAFwkTag::TEST, "GetRunningMultiAppInfoByBundleName_001 start"); + auto appMgrServiceInner = std::make_shared(); + EXPECT_NE(appMgrServiceInner, nullptr); + + std::string bundleName = "testBundleName"; + RunningMultiAppInfo info; + int32_t ret = appMgrServiceInner->GetRunningMultiAppInfoByBundleName(bundleName, info); + EXPECT_EQ(ret, ERR_OK); + + appMgrServiceInner->appRunningManager_ = nullptr; + ret = appMgrServiceInner->GetRunningMultiAppInfoByBundleName(bundleName, info); + EXPECT_EQ(ret, ERR_INVALID_VALUE); + + TAG_LOGI(AAFwkTag::TEST, "GetRunningMultiAppInfoByBundleName_001 end"); +} } // namespace AppExecFwk } // namespace OHOS diff --git a/test/unittest/app_mgr_service_test/app_mgr_service_test.cpp b/test/unittest/app_mgr_service_test/app_mgr_service_test.cpp index 30ecef7802..3886423032 100644 --- a/test/unittest/app_mgr_service_test/app_mgr_service_test.cpp +++ b/test/unittest/app_mgr_service_test/app_mgr_service_test.cpp @@ -1731,5 +1731,51 @@ HWTEST_F(AppMgrServiceTest, SetSupportedProcessCacheSelf_002, TestSize.Level0) res = appMgrService->SetSupportedProcessCacheSelf(false); EXPECT_EQ(res, AAFwk::ERR_SET_SUPPORTED_PROCESS_CACHE_AGAIN); } + +/* + * Feature: AppMgrService + * Function: GetRunningMultiAppInfoByBundleName + * SubFunction: NA + * FunctionPoints: AppMgrService GetRunningMultiAppInfoByBundleName + * EnvConditions: NA + * CaseDescription: Verify GetRunningMultiAppInfoByBundleName + */ +HWTEST_F(AppMgrServiceTest, GetRunningMultiAppInfoByBundleName_001, TestSize.Level0) +{ + auto appMgrService = std::make_shared(); + ASSERT_NE(appMgrService, nullptr); + appMgrService->SetInnerService(nullptr); + + std::string bundleName = "testBundleName"; + RunningMultiAppInfo info; + int32_t res = appMgrService->GetRunningMultiAppInfoByBundleName(bundleName, info); + EXPECT_EQ(res, ERR_INVALID_OPERATION); +} + +/* + * Feature: AppMgrService + * Function: GetRunningMultiAppInfoByBundleName + * SubFunction: NA + * FunctionPoints: AppMgrService GetRunningMultiAppInfoByBundleName + * EnvConditions: NA + * CaseDescription: Verify GetRunningMultiAppInfoByBundleName + */ +HWTEST_F(AppMgrServiceTest, GetRunningMultiAppInfoByBundleName_002, TestSize.Level0) +{ + auto appMgrService = std::make_shared(); + ASSERT_NE(appMgrService, nullptr); + appMgrService->SetInnerService(mockAppMgrServiceInner_); + appMgrService->taskHandler_ = taskHandler_; + appMgrService->eventHandler_ = eventHandler_; + + std::string bundleName = "testbundlename"; + RunningMultiAppInfo info; + EXPECT_CALL(*mockAppMgrServiceInner_, GetRunningMultiAppInfoByBundleName(_, _)) + .Times(1) + .WillOnce(Return(ERR_OK)); + + int32_t ret = appMgrService->GetRunningMultiAppInfoByBundleName(bundleName,info); + EXPECT_EQ(ret, ERR_OK); +} } // namespace AppExecFwk } // namespace OHOS diff --git a/test/unittest/app_mgr_stub_test/app_mgr_stub_test.cpp b/test/unittest/app_mgr_stub_test/app_mgr_stub_test.cpp index 9cc2a0d3b5..8855ca2203 100644 --- a/test/unittest/app_mgr_stub_test/app_mgr_stub_test.cpp +++ b/test/unittest/app_mgr_stub_test/app_mgr_stub_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -616,5 +616,31 @@ HWTEST_F(AppMgrStubTest, SetSupportedProcessCacheSelf_001, TestSize.Level0) TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); } + +/** + * @tc.name: GetRunningMultiAppInfoByBundleName_001 + * @tc.desc: Get multiapp information by bundleName. + * @tc.type: FUNC + * @tc.require: issueI9HMAO + */ +HWTEST_F(AppMgrStubTest, GetRunningMultiAppInfoByBundleName_001, TestSize.Level0) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + MessageParcel data; + MessageParcel reply; + MessageOption option; + + WriteInterfaceToken(data); + std::string bundleName = "testBundleName"; + data.WriteString(bundleName); + + EXPECT_CALL(*mockAppMgrService_, GetRunningMultiAppInfoByBundleName(_, _)).Times(1); + + auto result = mockAppMgrService_->OnRemoteRequest( + static_cast(AppMgrInterfaceCode::GET_RUNNING_MULTIAPP_INFO_BY_BUNDLENAME), data, reply, option); + EXPECT_EQ(result, NO_ERROR); + + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} } // namespace AppExecFwk } // namespace OHOS From 1b3d2e42919054f41fd931b30f1ef8146a413e94 Mon Sep 17 00:00:00 2001 From: mashaohua7 Date: Fri, 10 May 2024 10:36:32 +0000 Subject: [PATCH 028/174] update test/unittest/app_mgr_proxy_test/app_mgr_proxy_test.cpp. Signed-off-by: mashaohua7 --- test/unittest/app_mgr_proxy_test/app_mgr_proxy_test.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/test/unittest/app_mgr_proxy_test/app_mgr_proxy_test.cpp b/test/unittest/app_mgr_proxy_test/app_mgr_proxy_test.cpp index e1db9c81a0..e7b0a781e1 100644 --- a/test/unittest/app_mgr_proxy_test/app_mgr_proxy_test.cpp +++ b/test/unittest/app_mgr_proxy_test/app_mgr_proxy_test.cpp @@ -623,7 +623,6 @@ HWTEST_F(AppMgrProxyTest, GetRunningMultiAppInfoByBundleName_001, TestSize.Level appMgrProxy_->GetRunningMultiAppInfoByBundleName(bundleName, info); EXPECT_EQ(mockAppMgrService_->code_, static_cast (AppMgrInterfaceCode::GET_RUNNING_MULTIAPP_INFO_BY_BUNDLENAME)); - EXPECT_GE(info.size(), 0); TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); } From a405603f7922360b80a2862d8908b328282b1ed9 Mon Sep 17 00:00:00 2001 From: mashaohua7 Date: Sat, 11 May 2024 01:05:45 +0000 Subject: [PATCH 029/174] update services/appmgr/src/app_mgr_service_inner.cpp. Signed-off-by: mashaohua7 --- services/appmgr/src/app_mgr_service_inner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/appmgr/src/app_mgr_service_inner.cpp b/services/appmgr/src/app_mgr_service_inner.cpp index 314a236f55..2d854eb47d 100644 --- a/services/appmgr/src/app_mgr_service_inner.cpp +++ b/services/appmgr/src/app_mgr_service_inner.cpp @@ -1438,7 +1438,7 @@ int32_t AppMgrServiceInner::GetRunningMultiAppInfoByBundleName(const std::string auto childAppRecordMap = appRecord->GetChildAppRecordMap(); size_t index = 0; for (; index < info.isolation.size(); index++) { - if (info.isolation[i].appTwinIndex == appRecord->GetAppIndex()) { + if (info.isolation[index].appTwinIndex == appRecord->GetAppIndex()) { break; } } From b1d06ebf7a2e66ebef6822c7ffa0dc657b2cc793 Mon Sep 17 00:00:00 2001 From: mashaohua7 Date: Sat, 11 May 2024 01:46:14 +0000 Subject: [PATCH 030/174] update test/unittest/app_mgr_service_test/app_mgr_service_test.cpp. Signed-off-by: mashaohua7 --- .../app_mgr_service_test.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/test/unittest/app_mgr_service_test/app_mgr_service_test.cpp b/test/unittest/app_mgr_service_test/app_mgr_service_test.cpp index 3886423032..3e55a8ea0d 100644 --- a/test/unittest/app_mgr_service_test/app_mgr_service_test.cpp +++ b/test/unittest/app_mgr_service_test/app_mgr_service_test.cpp @@ -1764,18 +1764,15 @@ HWTEST_F(AppMgrServiceTest, GetRunningMultiAppInfoByBundleName_002, TestSize.Lev { auto appMgrService = std::make_shared(); ASSERT_NE(appMgrService, nullptr); - appMgrService->SetInnerService(mockAppMgrServiceInner_); + + appMgrService->SetInnerService(std::make_shared()); appMgrService->taskHandler_ = taskHandler_; - appMgrService->eventHandler_ = eventHandler_; + appMgrService->eventHandler_ = std::make_shared(taskHandler_, appMgrService->appMgrServiceInner_); - std::string bundleName = "testbundlename"; - RunningMultiAppInfo info; - EXPECT_CALL(*mockAppMgrServiceInner_, GetRunningMultiAppInfoByBundleName(_, _)) - .Times(1) - .WillOnce(Return(ERR_OK)); - - int32_t ret = appMgrService->GetRunningMultiAppInfoByBundleName(bundleName,info); - EXPECT_EQ(ret, ERR_OK); + std::string bundleName = "testBundleName"; + std::vector info; + int32_t res = appMgrService->GetRunningMultiAppInfoByBundleName(bundleName, info); + EXPECT_EQ(res, ERR_OK); } } // namespace AppExecFwk } // namespace OHOS From cb1d62b29cf0eb834380002db3f5a348b4ae408d Mon Sep 17 00:00:00 2001 From: mashaohua7 Date: Sat, 11 May 2024 02:30:13 +0000 Subject: [PATCH 031/174] update test/unittest/app_mgr_service_test/app_mgr_service_test.cpp. Signed-off-by: mashaohua7 --- test/unittest/app_mgr_service_test/app_mgr_service_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unittest/app_mgr_service_test/app_mgr_service_test.cpp b/test/unittest/app_mgr_service_test/app_mgr_service_test.cpp index 3e55a8ea0d..2b6baea9fb 100644 --- a/test/unittest/app_mgr_service_test/app_mgr_service_test.cpp +++ b/test/unittest/app_mgr_service_test/app_mgr_service_test.cpp @@ -1770,7 +1770,7 @@ HWTEST_F(AppMgrServiceTest, GetRunningMultiAppInfoByBundleName_002, TestSize.Lev appMgrService->eventHandler_ = std::make_shared(taskHandler_, appMgrService->appMgrServiceInner_); std::string bundleName = "testBundleName"; - std::vector info; + RunningMultiAppInfo info; int32_t res = appMgrService->GetRunningMultiAppInfoByBundleName(bundleName, info); EXPECT_EQ(res, ERR_OK); } From 96a249033489b329e5d4a5b54bcd23dbe7fac041 Mon Sep 17 00:00:00 2001 From: mashaohua7 Date: Sat, 11 May 2024 06:56:59 +0000 Subject: [PATCH 032/174] update services/appmgr/src/app_mgr_service_inner.cpp. Signed-off-by: mashaohua7 --- services/appmgr/src/app_mgr_service_inner.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/services/appmgr/src/app_mgr_service_inner.cpp b/services/appmgr/src/app_mgr_service_inner.cpp index 2d854eb47d..5037b61fe3 100644 --- a/services/appmgr/src/app_mgr_service_inner.cpp +++ b/services/appmgr/src/app_mgr_service_inner.cpp @@ -1430,7 +1430,12 @@ int32_t AppMgrServiceInner::GetRunningMultiAppInfoByBundleName(const std::string continue; } info.bundleName = bundleName; - info.mode = static_cast(appRecord->GetApplicationInfo()->multiAppMode.type); + auto applicationInfo = appRecord->GetApplicationInfo(); + if (applicationInfo == nullptr) { + TAG_LOGE(AAFwkTag::APPMGR, "applicationInfo is nullptr !"); + return ERR_NO_INIT; + } + info.mode = static_cast(applicationInfo->multiAppMode.type); if (info.mode == static_cast(MultiAppModeType::UNSPECIFIED)) { return AAFwk::ERR_APP_TWIN_NOT_SUPPORTED; } From 87d9687388fc146b9e802088c7ff1639f7d27b82 Mon Sep 17 00:00:00 2001 From: mashaohua7 Date: Sat, 11 May 2024 07:09:34 +0000 Subject: [PATCH 033/174] update test/unittest/app_mgr_proxy_test/app_mgr_proxy_test.cpp. Signed-off-by: mashaohua7 --- test/unittest/app_mgr_proxy_test/app_mgr_proxy_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unittest/app_mgr_proxy_test/app_mgr_proxy_test.cpp b/test/unittest/app_mgr_proxy_test/app_mgr_proxy_test.cpp index e7b0a781e1..28764ffc28 100644 --- a/test/unittest/app_mgr_proxy_test/app_mgr_proxy_test.cpp +++ b/test/unittest/app_mgr_proxy_test/app_mgr_proxy_test.cpp @@ -610,7 +610,7 @@ HWTEST_F(AppMgrProxyTest, SetSupportedProcessCacheSelf_001, TestSize.Level0) * @tc.type: FUNC * @tc.require: issueI9HMAO */ -HWTEST_F(AppMgrProxyTest, GetRunningMultiAppInfoByBundleName_001, TestSize.Level0) +HWTEST_F(AppMgrProxyTest, GetRunningMultiAppInfoByBundleName_001, TestSize.Level1) { TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); From dc4637911af100cc0387799f27fff7ad5b44c35c Mon Sep 17 00:00:00 2001 From: mashaohua7 Date: Sat, 11 May 2024 07:10:20 +0000 Subject: [PATCH 034/174] update test/unittest/app_mgr_service_inner_test/app_mgr_service_inner_test.cpp. Signed-off-by: mashaohua7 --- .../app_mgr_service_inner_test/app_mgr_service_inner_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unittest/app_mgr_service_inner_test/app_mgr_service_inner_test.cpp b/test/unittest/app_mgr_service_inner_test/app_mgr_service_inner_test.cpp index 8e8e1bcdf5..58a9d305d2 100644 --- a/test/unittest/app_mgr_service_inner_test/app_mgr_service_inner_test.cpp +++ b/test/unittest/app_mgr_service_inner_test/app_mgr_service_inner_test.cpp @@ -4269,7 +4269,7 @@ HWTEST_F(AppMgrServiceInnerTest, OnAppCacheStateChanged_001, TestSize.Level0) * @tc.type: FUNC * @tc.require: issueI9HMAO */ -HWTEST_F(AppMgrServiceInnerTest, GetRunningMultiAppInfoByBundleName_001, TestSize.Level0) +HWTEST_F(AppMgrServiceInnerTest, GetRunningMultiAppInfoByBundleName_001, TestSize.Level1) { TAG_LOGI(AAFwkTag::TEST, "GetRunningMultiAppInfoByBundleName_001 start"); auto appMgrServiceInner = std::make_shared(); From e146cd458f1264e68e255608327be4c385b38961 Mon Sep 17 00:00:00 2001 From: mashaohua7 Date: Sat, 11 May 2024 07:10:57 +0000 Subject: [PATCH 035/174] update test/unittest/app_mgr_service_test/app_mgr_service_test.cpp. Signed-off-by: mashaohua7 --- test/unittest/app_mgr_service_test/app_mgr_service_test.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/unittest/app_mgr_service_test/app_mgr_service_test.cpp b/test/unittest/app_mgr_service_test/app_mgr_service_test.cpp index 2b6baea9fb..477a28627d 100644 --- a/test/unittest/app_mgr_service_test/app_mgr_service_test.cpp +++ b/test/unittest/app_mgr_service_test/app_mgr_service_test.cpp @@ -1740,7 +1740,7 @@ HWTEST_F(AppMgrServiceTest, SetSupportedProcessCacheSelf_002, TestSize.Level0) * EnvConditions: NA * CaseDescription: Verify GetRunningMultiAppInfoByBundleName */ -HWTEST_F(AppMgrServiceTest, GetRunningMultiAppInfoByBundleName_001, TestSize.Level0) +HWTEST_F(AppMgrServiceTest, GetRunningMultiAppInfoByBundleName_001, TestSize.Level1) { auto appMgrService = std::make_shared(); ASSERT_NE(appMgrService, nullptr); @@ -1760,7 +1760,7 @@ HWTEST_F(AppMgrServiceTest, GetRunningMultiAppInfoByBundleName_001, TestSize.Lev * EnvConditions: NA * CaseDescription: Verify GetRunningMultiAppInfoByBundleName */ -HWTEST_F(AppMgrServiceTest, GetRunningMultiAppInfoByBundleName_002, TestSize.Level0) +HWTEST_F(AppMgrServiceTest, GetRunningMultiAppInfoByBundleName_002, TestSize.Level1) { auto appMgrService = std::make_shared(); ASSERT_NE(appMgrService, nullptr); From 003f27b4ae840b1bfeabb08d105cf228563e1aaf Mon Sep 17 00:00:00 2001 From: mashaohua7 Date: Sat, 11 May 2024 07:11:50 +0000 Subject: [PATCH 036/174] update test/unittest/app_mgr_stub_test/app_mgr_stub_test.cpp. Signed-off-by: mashaohua7 --- test/unittest/app_mgr_stub_test/app_mgr_stub_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unittest/app_mgr_stub_test/app_mgr_stub_test.cpp b/test/unittest/app_mgr_stub_test/app_mgr_stub_test.cpp index 8855ca2203..d1369d8fe5 100644 --- a/test/unittest/app_mgr_stub_test/app_mgr_stub_test.cpp +++ b/test/unittest/app_mgr_stub_test/app_mgr_stub_test.cpp @@ -623,7 +623,7 @@ HWTEST_F(AppMgrStubTest, SetSupportedProcessCacheSelf_001, TestSize.Level0) * @tc.type: FUNC * @tc.require: issueI9HMAO */ -HWTEST_F(AppMgrStubTest, GetRunningMultiAppInfoByBundleName_001, TestSize.Level0) +HWTEST_F(AppMgrStubTest, GetRunningMultiAppInfoByBundleName_001, TestSize.Level1) { TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); MessageParcel data; From a8ec3b352a08681295b89a8fe26b07d9868857a0 Mon Sep 17 00:00:00 2001 From: mashaohua7 Date: Sat, 11 May 2024 09:13:39 +0000 Subject: [PATCH 037/174] update services/appmgr/src/app_mgr_service_inner.cpp. Signed-off-by: mashaohua7 --- services/appmgr/src/app_mgr_service_inner.cpp | 62 +++++++++---------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/services/appmgr/src/app_mgr_service_inner.cpp b/services/appmgr/src/app_mgr_service_inner.cpp index 5037b61fe3..34d450e602 100644 --- a/services/appmgr/src/app_mgr_service_inner.cpp +++ b/services/appmgr/src/app_mgr_service_inner.cpp @@ -1425,48 +1425,48 @@ int32_t AppMgrServiceInner::GetRunningMultiAppInfoByBundleName(const std::string return ERR_INVALID_VALUE; } for (const auto &item : multiAppInfoMap) { - const auto &appRecord = item.second; + const std::shared_ptr &appRecord = item.second; if (appRecord == nullptr || appRecord->GetBundleName() != bundleName) { continue; } info.bundleName = bundleName; - auto applicationInfo = appRecord->GetApplicationInfo(); - if (applicationInfo == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "applicationInfo is nullptr !"); - return ERR_NO_INIT; - } - info.mode = static_cast(applicationInfo->multiAppMode.type); + info.mode = static_cast(appRecord->GetApplicationInfo()->multiAppMode.multiAppModeType); if (info.mode == static_cast(MultiAppModeType::UNSPECIFIED)) { return AAFwk::ERR_APP_TWIN_NOT_SUPPORTED; } - if (info.mode == static_cast(MultiAppModeType::APP_CLONE)) { - auto childAppRecordMap = appRecord->GetChildAppRecordMap(); - size_t index = 0; - for (; index < info.isolation.size(); index++) { - if (info.isolation[index].appTwinIndex == appRecord->GetAppIndex()) { - break; - } - } - if (index < info.isolation.size()) { - info.isolation[index].pids.emplace_back(appRecord->GetPriorityObject()->GetPid()); - for (auto it : childAppRecordMap) { - info.isolation[index].pids.emplace_back(it.first); - } - } else { - RunningAppTwin twinInfo; - twinInfo.appTwinIndex = appRecord->GetAppIndex(); - twinInfo.uid = appRecord->GetUid(); - twinInfo.pids.emplace_back(appRecord->GetPriorityObject()->GetPid()); - for (auto it : childAppRecordMap) { - twinInfo.pids.emplace_back(it.first); - } - info.isolation.emplace_back(twinInfo); - } - } + GetRunningTwinAppInfo(appRecord, info); } return ERR_OK; } +void AppMgrServiceInner::GetRunningTwinAppInfo(const std::shared_ptr &appRecord, RunningMultiAppInfo &info) +{ + if (info.mode == static_cast(MultiAppModeType::APP_CLONE)) { + auto childAppRecordMap = appRecord->GetChildAppRecordMap(); + size_t index = 0; + for (; index < info.isolation.size(); index++) { + if (info.isolation[i].appTwinIndex == appRecord->GetAppIndex()) { + break; + } + } + if (index < info.isolation.size()) { + info.isolation[index].pids.emplace_back(appRecord->GetPriorityObject()->GetPid()); + for (auto it : childAppRecordMap) { + info.isolation[index].pids.emplace_back(it.first); + } + } else { + RunningAppTwin twinInfo; + twinInfo.appTwinIndex = appRecord->GetAppIndex(); + twinInfo.uid = appRecord->GetUid(); + twinInfo.pids.emplace_back(appRecord->GetPriorityObject()->GetPid()); + for (auto it : childAppRecordMap) { + twinInfo.pids.emplace_back(it.first); + } + info.isolation.emplace_back(twinInfo); + } + } +} + int32_t AppMgrServiceInner::GetProcessRunningInfosByUserId(std::vector &info, int32_t userId) { if (VerifyAccountPermission(AAFwk::PermissionConstants::PERMISSION_GET_RUNNING_INFO, userId) == From 649dc2d804c0d9b15e2c535ee33b8c4f87899423 Mon Sep 17 00:00:00 2001 From: mashaohua7 Date: Sat, 11 May 2024 09:19:23 +0000 Subject: [PATCH 038/174] update services/appmgr/include/app_mgr_service_inner.h. Signed-off-by: mashaohua7 --- services/appmgr/include/app_mgr_service_inner.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/services/appmgr/include/app_mgr_service_inner.h b/services/appmgr/include/app_mgr_service_inner.h index 0ef2b27ced..a63e87ee2e 100644 --- a/services/appmgr/include/app_mgr_service_inner.h +++ b/services/appmgr/include/app_mgr_service_inner.h @@ -317,6 +317,17 @@ public: virtual int32_t GetRunningMultiAppInfoByBundleName(const std::string &bundleName, RunningMultiAppInfo &info); + /** + * GetRunningMultiAppInfoByBundleName, call GetRunningTwinAppInfo() through proxy project. + * Obtains information about TwinApp that are running on the device. + * + * @param apprecord, input. + * @param info, output multiapp information. + * @return void. + */ + virtual void GetRunningTwinAppInfo(const std::shared_ptr &appRecord, + RunningMultiAppInfo &info); + /** * GetRunningProcessesByBundleType, Obtains information about application processes by bundle type. * From 09443fed2d3c88db62d0567a024ddc3e6dcd3967 Mon Sep 17 00:00:00 2001 From: mashaohua7 Date: Sat, 11 May 2024 09:21:08 +0000 Subject: [PATCH 039/174] update services/appmgr/src/app_mgr_service_inner.cpp. Signed-off-by: mashaohua7 --- services/appmgr/src/app_mgr_service_inner.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/services/appmgr/src/app_mgr_service_inner.cpp b/services/appmgr/src/app_mgr_service_inner.cpp index 34d450e602..37e6d3075a 100644 --- a/services/appmgr/src/app_mgr_service_inner.cpp +++ b/services/appmgr/src/app_mgr_service_inner.cpp @@ -1439,7 +1439,8 @@ int32_t AppMgrServiceInner::GetRunningMultiAppInfoByBundleName(const std::string return ERR_OK; } -void AppMgrServiceInner::GetRunningTwinAppInfo(const std::shared_ptr &appRecord, RunningMultiAppInfo &info) +void AppMgrServiceInner::GetRunningTwinAppInfo(const std::shared_ptr &appRecord, + RunningMultiAppInfo &info) { if (info.mode == static_cast(MultiAppModeType::APP_CLONE)) { auto childAppRecordMap = appRecord->GetChildAppRecordMap(); From 3e5a166f24ee52f3661386f341754981469adff8 Mon Sep 17 00:00:00 2001 From: mashaohua7 Date: Sat, 11 May 2024 09:55:51 +0000 Subject: [PATCH 040/174] update services/appmgr/src/app_mgr_service_inner.cpp. Signed-off-by: mashaohua7 --- services/appmgr/src/app_mgr_service_inner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/appmgr/src/app_mgr_service_inner.cpp b/services/appmgr/src/app_mgr_service_inner.cpp index 37e6d3075a..60369dcf62 100644 --- a/services/appmgr/src/app_mgr_service_inner.cpp +++ b/services/appmgr/src/app_mgr_service_inner.cpp @@ -1446,7 +1446,7 @@ void AppMgrServiceInner::GetRunningTwinAppInfo(const std::shared_ptrGetChildAppRecordMap(); size_t index = 0; for (; index < info.isolation.size(); index++) { - if (info.isolation[i].appTwinIndex == appRecord->GetAppIndex()) { + if (info.isolation[index].appTwinIndex == appRecord->GetAppIndex()) { break; } } From b828c016bf21c3a0e920e124ad6e4b9f9a484ea9 Mon Sep 17 00:00:00 2001 From: xinking129 Date: Mon, 13 May 2024 13:06:49 +0800 Subject: [PATCH 041/174] add and fix code Signed-off-by: xinking129 --- .../include/assert_fault_proxy.h | 28 ++-- .../src/ability_manager_service.cpp | 6 +- .../abilitymgr/src/assert_fault_proxy.cpp | 125 ++++++++++-------- services/appmgr/src/app_mgr_service_inner.cpp | 2 +- 4 files changed, 91 insertions(+), 70 deletions(-) diff --git a/interfaces/inner_api/ability_manager/include/assert_fault_proxy.h b/interfaces/inner_api/ability_manager/include/assert_fault_proxy.h index eb98199c33..e2900cb419 100644 --- a/interfaces/inner_api/ability_manager/include/assert_fault_proxy.h +++ b/interfaces/inner_api/ability_manager/include/assert_fault_proxy.h @@ -16,6 +16,8 @@ #ifndef OHOS_ABILITY_RUNTIME_ASSERT_FAULT_PROXY_H #define OHOS_ABILITY_RUNTIME_ASSERT_FAULT_PROXY_H +#include +#include #include #include "iremote_broker.h" @@ -23,6 +25,7 @@ #include "iremote_proxy.h" #include "ability_connect_callback_stub.h" #include "assert_fault_interface.h" +#include "singleton.h" namespace OHOS { namespace AbilityRuntime { @@ -52,34 +55,39 @@ private: RemoteDiedHandler handler_; }; -class ModalSystemAssertUIExtension : public std::enable_shared_from_this { +class ModalSystemAssertUIExtension { public: + static ModalSystemAssertUIExtension &GetInstance(); ModalSystemAssertUIExtension() = default; virtual ~ModalSystemAssertUIExtension(); bool CreateModalUIExtension(const AAFwk::Want &want); + friend class AssertFaultProxy; + private: class AssertDialogConnection : public OHOS::AAFwk::AbilityConnectionStub { public: AssertDialogConnection() = default; - virtual ~AssertDialogConnection(); - - bool RequestShowDialog(const AAFwk::Want &want); - void CleanUp(); + virtual ~AssertDialogConnection() = default; + void SetReqeustAssertDialogWant(const AAFwk::Want &want); void OnAbilityConnectDone(const AppExecFwk::ElementName &element, const sptr &remoteObject, int resultCode) override; void OnAbilityDisconnectDone(const AppExecFwk::ElementName &element, int resultCode) override; private: - std::mutex mutex_; - std::atomic_bool isDialogShow_ = false; - std::queue consumptionList_; - sptr remoteObject_; - sptr deathRecipient_; + AAFwk::Want want_; }; +private: + bool DisconnectSystemUI(); + void TryNotifyOneWaitingThread(); + void TryNotifyOneWaitingThreadInner(); + + std::mutex assertResultMutex_; + std::condition_variable assertResultCV_; + int32_t reqeustCount_ = 0; sptr GetConnection(); std::mutex dialogConnectionMutex_; sptr dialogConnectionCallback_; diff --git a/services/abilitymgr/src/ability_manager_service.cpp b/services/abilitymgr/src/ability_manager_service.cpp index bd78a9878d..d02a6c1dba 100644 --- a/services/abilitymgr/src/ability_manager_service.cpp +++ b/services/abilitymgr/src/ability_manager_service.cpp @@ -9994,10 +9994,10 @@ int32_t AbilityManagerService::RequestAssertFaultDialog( uint64_t assertFaultSessionId = reinterpret_cast(remoteCallback.GetRefPtr()); want.SetParam(Want::PARAM_ASSERT_FAULT_SESSION_ID, std::to_string(assertFaultSessionId)); want.SetParam(ASSERT_FAULT_DETAIL, wantParams.GetStringParam(ASSERT_FAULT_DETAIL)); - auto connection = std::make_shared(); + auto &connection = AbilityRuntime::ModalSystemAssertUIExtension::GetInstance(); want.SetParam(UIEXTENSION_MODAL_TYPE, 1); - if (connection == nullptr || !IN_PROCESS_CALL(connection->CreateModalUIExtension(want))) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "Connection is nullptr or create modal ui extension failed."); + if (!IN_PROCESS_CALL(connection.CreateModalUIExtension(want))) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "Create modal ui extension failed."); return ERR_INVALID_VALUE; } auto callbackDeathMgr = DelayedSingleton::GetInstance(); diff --git a/services/abilitymgr/src/assert_fault_proxy.cpp b/services/abilitymgr/src/assert_fault_proxy.cpp index 30f0844ef3..eddf9389bd 100644 --- a/services/abilitymgr/src/assert_fault_proxy.cpp +++ b/services/abilitymgr/src/assert_fault_proxy.cpp @@ -17,6 +17,7 @@ #include "hilog_tag_wrapper.h" #include "hilog_wrapper.h" #include "scene_board_judgement.h" +#include "task_handler_wrap.h" namespace OHOS { namespace AbilityRuntime { @@ -56,6 +57,8 @@ void AssertFaultProxy::NotifyDebugAssertResult(AAFwk::UserStatus status) if (remote->SendRequest(MessageCode::NOTIFY_DEBUG_ASSERT_RESULT, data, reply, option) != NO_ERROR) { TAG_LOGE(AAFwkTag::ABILITYMGR, "Remote send request failed."); } + + ModalSystemAssertUIExtension::GetInstance().DisconnectSystemUI(); } AssertFaultRemoteDeathRecipient::AssertFaultRemoteDeathRecipient(RemoteDiedHandler handler) : handler_(handler) @@ -70,6 +73,12 @@ void AssertFaultRemoteDeathRecipient::OnRemoteDied(const wptr &re handler_(remote); } +ModalSystemAssertUIExtension &ModalSystemAssertUIExtension::GetInstance() +{ + static ModalSystemAssertUIExtension instance; + return instance; +} + ModalSystemAssertUIExtension::~ModalSystemAssertUIExtension() { dialogConnectionCallback_ = nullptr; @@ -90,22 +99,24 @@ sptr ModalSystemAssertUIEx bool ModalSystemAssertUIExtension::CreateModalUIExtension(const AAFwk::Want &want) { TAG_LOGD(AAFwkTag::ABILITYMGR, "Called."); + std::unique_lock lockAssertResult(assertResultMutex_); + if (reqeustCount_++ != 0) { + TAG_LOGD(AAFwkTag::ABILITYMGR, "Task busy, waiting for processing."); + assertResultCV_.wait(lockAssertResult); + } auto callback = GetConnection(); if (callback == nullptr) { TAG_LOGE(AAFwkTag::ABILITYMGR, "Callback is nullptr."); + TryNotifyOneWaitingThread(); return false; } - if (callback->RequestShowDialog(want)) { - TAG_LOGD(AAFwkTag::ABILITYMGR, "Start consumption want."); - return true; - } - + callback->SetReqeustAssertDialogWant(want); auto abilityManagerClient = AAFwk::AbilityManagerClient::GetInstance(); if (abilityManagerClient == nullptr) { TAG_LOGE(AAFwkTag::ABILITYMGR, "ConnectSystemUi AbilityManagerClient is nullptr"); + TryNotifyOneWaitingThread(); return false; } - AAFwk::Want systemUIWant; if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) { systemUIWant.SetElementName("com.ohos.sceneboard", "com.ohos.sceneboard.systemdialog"); @@ -115,47 +126,66 @@ bool ModalSystemAssertUIExtension::CreateModalUIExtension(const AAFwk::Want &wan auto result = abilityManagerClient->ConnectAbility(systemUIWant, callback, INVALID_USERID); if (result != ERR_OK) { TAG_LOGE(AAFwkTag::ABILITYMGR, "ConnectSystemUi ConnectAbility dialog failed, result = %{public}d", result); + TryNotifyOneWaitingThread(); return false; } return true; } -ModalSystemAssertUIExtension::AssertDialogConnection::~AssertDialogConnection() +bool ModalSystemAssertUIExtension::DisconnectSystemUI() { TAG_LOGD(AAFwkTag::ABILITYMGR, "Called."); - CleanUp(); + bool retVal = true; + do { + auto abilityManagerClient = AAFwk::AbilityManagerClient::GetInstance(); + if (abilityManagerClient == nullptr) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "AbilityManagerClient is nullptr"); + retVal = false; + break; + } + auto callback = GetConnection(); + if (callback == nullptr) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "Callback is nullptr."); + retVal = false; + break; + } + auto result = abilityManagerClient->DisconnectAbility(callback); + if (result != ERR_OK) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "DisconnectAbility dialog failed, result = %{public}d", result); + retVal = false; + break; + } + } while (false); + + return retVal; } -bool ModalSystemAssertUIExtension::AssertDialogConnection::RequestShowDialog(const AAFwk::Want &want) +void ModalSystemAssertUIExtension::TryNotifyOneWaitingThreadInner() { - TAG_LOGD(AAFwkTag::ABILITYMGR, "Called."); - { - std::lock_guard lock(mutex_); - consumptionList_.push(want); + std::unique_lock lockAssertResult(assertResultMutex_); + if (--reqeustCount_ > 0) { + TAG_LOGD(AAFwkTag::ABILITYMGR, "Notify waiting Thread count is %{public}d.", reqeustCount_); + assertResultCV_.notify_one(); + return; } - if (!isDialogShow_) { - TAG_LOGD(AAFwkTag::ABILITYMGR, "Connection not ready."); - return false; - } - - AppExecFwk::ElementName element; - OnAbilityConnectDone(element, remoteObject_, DEFAULT_VAL); - return true; + reqeustCount_ = 0; + TAG_LOGD(AAFwkTag::ABILITYMGR, "Counter reset to 0."); } -void ModalSystemAssertUIExtension::AssertDialogConnection::CleanUp() +void ModalSystemAssertUIExtension::TryNotifyOneWaitingThread() { - TAG_LOGD(AAFwkTag::ABILITYMGR, "Called."); - std::lock_guard lock(mutex_); - if (!consumptionList_.empty()) { - std::queue temp; - consumptionList_.swap(temp); + auto handler = AAFwk::TaskHandlerWrap::GetFfrtHandler(); + if (handler != nullptr) { + auto notifyTask = [] () { + ModalSystemAssertUIExtension::GetInstance().TryNotifyOneWaitingThreadInner(); + }; + handler->SubmitTask(notifyTask, "TryNotifyOneWaitingThread"); } - if (remoteObject_ != nullptr) { - remoteObject_->RemoveDeathRecipient(deathRecipient_); - remoteObject_ = nullptr; - } - deathRecipient_ = nullptr; +} + +void ModalSystemAssertUIExtension::AssertDialogConnection::SetReqeustAssertDialogWant(const AAFwk::Want &want) +{ + want_ = want; } void ModalSystemAssertUIExtension::AssertDialogConnection::OnAbilityConnectDone( @@ -166,39 +196,23 @@ void ModalSystemAssertUIExtension::AssertDialogConnection::OnAbilityConnectDone( TAG_LOGE(AAFwkTag::ABILITYMGR, "Input remote object is nullptr."); return; } - std::lock_guard lock(mutex_); - if (remoteObject_ == nullptr) { - remoteObject_ = remote; - wptr weakThis = iface_cast(this->AsObject()); - deathRecipient_ = - new (std::nothrow) AssertFaultRemoteDeathRecipient([weakThis] (const wptr &remote) { - auto remoteObj = weakThis.promote(); - if (remoteObj == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "Invalid remote object."); - return; - } - remoteObj->CleanUp(); - }); - remoteObject_->AddDeathRecipient(deathRecipient_); - } + MessageParcel data; MessageParcel reply; MessageOption option; - auto &want = consumptionList_.front(); data.WriteInt32(MESSAGE_PARCEL_KEY_SIZE); data.WriteString16(u"bundleName"); - data.WriteString16(Str8ToStr16(want.GetElement().GetBundleName())); + data.WriteString16(Str8ToStr16(want_.GetElement().GetBundleName())); data.WriteString16(u"abilityName"); - data.WriteString16(Str8ToStr16(want.GetElement().GetAbilityName())); + data.WriteString16(Str8ToStr16(want_.GetElement().GetAbilityName())); data.WriteString16(u"parameters"); nlohmann::json param; - param[UIEXTENSION_TYPE_KEY] = want.GetStringParam(UIEXTENSION_TYPE_KEY); - param[ASSERT_FAULT_DETAIL] = want.GetStringParam(ASSERT_FAULT_DETAIL); + param[UIEXTENSION_TYPE_KEY] = want_.GetStringParam(UIEXTENSION_TYPE_KEY); + param[ASSERT_FAULT_DETAIL] = want_.GetStringParam(ASSERT_FAULT_DETAIL); param[AAFwk::Want::PARAM_ASSERT_FAULT_SESSION_ID] = - want.GetStringParam(AAFwk::Want::PARAM_ASSERT_FAULT_SESSION_ID); + want_.GetStringParam(AAFwk::Want::PARAM_ASSERT_FAULT_SESSION_ID); std::string paramStr = param.dump(); data.WriteString16(Str8ToStr16(paramStr)); - consumptionList_.pop(); uint32_t code = !Rosen::SceneBoardJudgement::IsSceneBoardEnabled() ? COMMAND_START_DIALOG : AAFwk::IAbilityConnection::ON_ABILITY_CONNECT_DONE; auto ret = remote->SendRequest(code, data, reply, option); @@ -206,14 +220,13 @@ void ModalSystemAssertUIExtension::AssertDialogConnection::OnAbilityConnectDone( TAG_LOGE(AAFwkTag::ABILITYMGR, "Show dialog is failed"); return; } - isDialogShow_ = true; } void ModalSystemAssertUIExtension::AssertDialogConnection::OnAbilityDisconnectDone( const AppExecFwk::ElementName &element, int resultCode) { TAG_LOGD(AAFwkTag::ABILITYMGR, "Called."); - CleanUp(); + ModalSystemAssertUIExtension::GetInstance().TryNotifyOneWaitingThread(); } } // namespace AbilityRuntime } // namespace OHOS \ No newline at end of file diff --git a/services/appmgr/src/app_mgr_service_inner.cpp b/services/appmgr/src/app_mgr_service_inner.cpp index ddbb7d3fb3..79c71b7e29 100644 --- a/services/appmgr/src/app_mgr_service_inner.cpp +++ b/services/appmgr/src/app_mgr_service_inner.cpp @@ -6161,7 +6161,7 @@ void AppMgrServiceInner::SetAppAssertionPauseState(bool flag) return; } - auto callerPid = IPCSkeleton::GetCallingPid(); + auto callerPid = IPCSkeleton::GetCallingRealPid(); auto appRecord = GetAppRunningRecordByPid(callerPid); if (appRecord == nullptr) { TAG_LOGE(AAFwkTag::APPMGR, "No such appRecord pid is %{public}d.", callerPid); From 5346efa3820229debf0f62affb4516b70ad21dae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E6=97=AD=E8=BE=89?= Date: Mon, 6 May 2024 19:47:46 +0800 Subject: [PATCH 042/174] =?UTF-8?q?description:=E3=80=90=E5=9F=BA=E7=A1=80?= =?UTF-8?q?=E8=83=BD=E5=8A=9B=E3=80=91UIExtensionAbility=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E5=9C=A8terminateSelfWithResult=E6=97=B6=E6=8E=88=E6=9D=83URL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 孙旭辉 --- .../js_ui_extension_content_session.cpp | 55 +++++++++------ .../js_ui_extension_context.cpp | 68 +++++++++++-------- .../include/ability_manager_client.h | 11 +++ .../include/ability_manager_interface.h | 13 ++++ .../ability_manager_ipc_interface_code.h | 1 + .../js_ui_extension_content_session.h | 2 + .../js_ui_extension_context.h | 2 + .../include/ability_manager_proxy.h | 11 +++ .../include/ability_manager_service.h | 11 +++ .../abilitymgr/include/ability_manager_stub.h | 2 + .../abilitymgr/include/mission_list_manager.h | 4 +- .../abilitymgr/src/ability_manager_client.cpp | 8 +++ .../abilitymgr/src/ability_manager_proxy.cpp | 30 ++++++++ .../src/ability_manager_service.cpp | 20 ++++++ .../abilitymgr/src/ability_manager_stub.cpp | 17 +++++ .../ability_manager_client_branch_test.cpp | 16 +++++ .../ability_manager_service_third_test.cpp | 16 +++++ 17 files changed, 238 insertions(+), 49 deletions(-) diff --git a/frameworks/native/ability/native/ui_extension_ability/js_ui_extension_content_session.cpp b/frameworks/native/ability/native/ui_extension_ability/js_ui_extension_content_session.cpp index 13bd6a1d1f..4620f54352 100644 --- a/frameworks/native/ability/native/ui_extension_ability/js_ui_extension_content_session.cpp +++ b/frameworks/native/ability/native/ui_extension_ability/js_ui_extension_content_session.cpp @@ -558,26 +558,8 @@ napi_value JsUIExtensionContentSession::OnTerminateSelfWithResult(napi_env env, return CreateJsUndefined(env); } - NapiAsyncTask::CompleteCallback complete = - [uiWindow = uiWindow_, sessionInfo = sessionInfo_, want, resultCode](napi_env env, - NapiAsyncTask& task, int32_t status) { - if (uiWindow == nullptr) { - TAG_LOGE(AAFwkTag::UI_EXT, "uiWindow is nullptr."); - task.Reject(env, CreateJsError(env, AbilityErrorCode::ERROR_CODE_INNER)); - return; - } - auto ret = uiWindow->TransferAbilityResult(resultCode, want); - if (ret != Rosen::WMError::WM_OK) { - task.Reject(env, CreateJsError(env, AbilityErrorCode::ERROR_CODE_INNER)); - return; - } - auto errorCode = AAFwk::AbilityManagerClient::GetInstance()->TerminateUIExtensionAbility(sessionInfo); - if (errorCode == 0) { - task.ResolveWithNoError(env, CreateJsUndefined(env)); - } else { - task.Reject(env, CreateJsErrorByNativeErr(env, errorCode)); - } - }; + NapiAsyncTask::CompleteCallback complete; + SetCallbackForTerminateWithResult(resultCode, want, complete); napi_value lastParam = (info.argc > ARGC_ONE) ? info.argv[INDEX_ONE] : nullptr; napi_value result = nullptr; @@ -1020,5 +1002,38 @@ void JsUIExtensionContentSession::AddFreeInstallObserver(napi_env env, bundleName, abilityName, startTime, callback, result, isAbilityResult); } } + +void JsUIExtensionContentSession::SetCallbackForTerminateWithResult(int32_t resultCode, AAFwk::Want& want, + NapiAsyncTask::CompleteCallback& complete) +{ + complete = + [weak = context_, uiWindow = uiWindow_, sessionInfo = sessionInfo_, want, resultCode](napi_env env, + NapiAsyncTask& task, int32_t status) { + auto extensionContext = AbilityRuntime::Context::ConvertTo(weak.lock()); + if (!extensionContext) { + TAG_LOGE(AAFwkTag::UI_EXT, "extensionContext is nullptr"); + task.Reject(env, CreateJsError(env, AbilityErrorCode::ERROR_CODE_INVALID_CONTEXT)); + return; + } + auto token = extensionContext->GetToken(); + AAFwk::AbilityManagerClient::GetInstance()->TransferAbilityResultForExtension(token, resultCode, want); + if (uiWindow == nullptr) { + TAG_LOGE(AAFwkTag::UI_EXT, "uiWindow is nullptr."); + task.Reject(env, CreateJsError(env, AbilityErrorCode::ERROR_CODE_INNER)); + return; + } + auto ret = uiWindow->TransferAbilityResult(resultCode, want); + if (ret != Rosen::WMError::WM_OK) { + task.Reject(env, CreateJsError(env, AbilityErrorCode::ERROR_CODE_INNER)); + return; + } + auto errorCode = AAFwk::AbilityManagerClient::GetInstance()->TerminateUIExtensionAbility(sessionInfo); + if (errorCode == 0) { + task.ResolveWithNoError(env, CreateJsUndefined(env)); + } else { + task.Reject(env, CreateJsErrorByNativeErr(env, errorCode)); + } + }; +} } // namespace AbilityRuntime } // namespace OHOS diff --git a/frameworks/native/ability/native/ui_extension_ability/js_ui_extension_context.cpp b/frameworks/native/ability/native/ui_extension_ability/js_ui_extension_context.cpp index b2922d3fda..5b44acaa6d 100755 --- a/frameworks/native/ability/native/ui_extension_ability/js_ui_extension_context.cpp +++ b/frameworks/native/ability/native/ui_extension_ability/js_ui_extension_context.cpp @@ -428,33 +428,8 @@ napi_value JsUIExtensionContext::OnTerminateSelfWithResult(napi_env env, NapiCal return CreateJsUndefined(env); } - NapiAsyncTask::CompleteCallback complete = - [weak = context_, want, resultCode](napi_env env, NapiAsyncTask& task, int32_t status) { - auto context = weak.lock(); - if (!context) { - TAG_LOGW(AAFwkTag::UI_EXT, "context is released"); - task.Reject(env, CreateJsError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM)); - return; - } - sptr uiWindow = context->GetWindow(); - if (uiWindow == nullptr) { - TAG_LOGE(AAFwkTag::UI_EXT, "uiWindow is nullptr"); - task.Reject(env, CreateJsError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM)); - return; - } - auto ret = uiWindow->TransferAbilityResult(resultCode, want); - if (ret != Rosen::WMError::WM_OK) { - task.Reject(env, CreateJsError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM)); - return; - } - auto errorCode = context->TerminateSelf(); - if (errorCode == 0) { - task.ResolveWithNoError(env, CreateJsUndefined(env)); - } else { - task.Reject(env, CreateJsErrorByNativeErr(env, errorCode)); - } - }; - + NapiAsyncTask::CompleteCallback complete; + SetCallbackForTerminateWithResult(resultCode, want, complete); napi_value lastParam = (info.argc > ARGC_ONE) ? info.argv[INDEX_ONE] : nullptr; napi_value result = nullptr; NapiAsyncTask::ScheduleHighQos("JsUIExtensionContext::OnTerminateSelfWithResult", @@ -664,6 +639,45 @@ napi_value JsUIExtensionContext::OnOpenAtomicService(napi_env env, NapiCallbackI return OpenAtomicServiceInner(env, info, want, startOptions, unwrapArgc); } +void JsUIExtensionContext::SetCallbackForTerminateWithResult(int32_t resultCode, AAFwk::Want& want, + NapiAsyncTask::CompleteCallback& complete) +{ + complete = + [weak = context_, want, resultCode](napi_env env, NapiAsyncTask& task, int32_t status) { + auto context = weak.lock(); + if (!context) { + TAG_LOGE(AAFwkTag::UI_EXT, "context is released"); + task.Reject(env, CreateJsError(env, AbilityErrorCode::ERROR_CODE_INVALID_CONTEXT)); + return; + } + auto extensionContext = AbilityRuntime::Context::ConvertTo(context); + if (!extensionContext) { + TAG_LOGE(AAFwkTag::UI_EXT, "extensionContext is nullptr"); + task.Reject(env, CreateJsError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM)); + return; + } + auto token = extensionContext->GetToken(); + AAFwk::AbilityManagerClient::GetInstance()->TransferAbilityResultForExtension(token, resultCode, want); + sptr uiWindow = context->GetWindow(); + if (!uiWindow) { + TAG_LOGE(AAFwkTag::UI_EXT, "uiWindow is nullptr"); + task.Reject(env, CreateJsError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM)); + return; + } + auto ret = uiWindow->TransferAbilityResult(resultCode, want); + if (ret != Rosen::WMError::WM_OK) { + task.Reject(env, CreateJsError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM)); + return; + } + auto errorCode = context->TerminateSelf(); + if (errorCode == 0) { + task.ResolveWithNoError(env, CreateJsUndefined(env)); + } else { + task.Reject(env, CreateJsErrorByNativeErr(env, errorCode)); + } + }; +} + napi_value JsUIExtensionContext::OpenAtomicServiceInner(napi_env env, NapiCallbackInfo& info, Want &want, const AAFwk::StartOptions &options, size_t unwrapArgc) { diff --git a/interfaces/inner_api/ability_manager/include/ability_manager_client.h b/interfaces/inner_api/ability_manager/include/ability_manager_client.h index fd28eb8d14..c6af9ef65c 100644 --- a/interfaces/inner_api/ability_manager/include/ability_manager_client.h +++ b/interfaces/inner_api/ability_manager/include/ability_manager_client.h @@ -1460,6 +1460,17 @@ public: */ int32_t GetAbilityStateByPersistentId(int32_t persistentId, bool &state); + /** + * Transfer resultCode & want to abms. + * + * @param callerToken caller ability token. + * @param requestCode the resultCode of the ability to start. + * @param want Indicates the ability to start. + * @return Returns ERR_OK on success, others on failure. + */ + int32_t TransferAbilityResultForExtension(const sptr &callerToken, int32_t resultCode, + const Want &want); + private: AbilityManagerClient(); DISALLOW_COPY_AND_MOVE(AbilityManagerClient); diff --git a/interfaces/inner_api/ability_manager/include/ability_manager_interface.h b/interfaces/inner_api/ability_manager/include/ability_manager_interface.h index 42fde8e3bc..799eb07b96 100644 --- a/interfaces/inner_api/ability_manager/include/ability_manager_interface.h +++ b/interfaces/inner_api/ability_manager/include/ability_manager_interface.h @@ -1565,6 +1565,19 @@ public: { return 0; } + + /** + * Transfer resultCode & want to ability manager service. + * + * @param resultCode, the resultCode of the ability to terminate. + * @param resultWant, the Want of the ability to return. + * @return Returns ERR_OK on success, others on failure. + */ + virtual int32_t TransferAbilityResultForExtension(const sptr &callerToken, int32_t resultCode, + const Want &want) + { + return 0; + } }; } // namespace AAFwk } // namespace OHOS diff --git a/interfaces/inner_api/ability_manager/include/ability_manager_ipc_interface_code.h b/interfaces/inner_api/ability_manager/include/ability_manager_ipc_interface_code.h index 4e8b256528..52b74f2c55 100644 --- a/interfaces/inner_api/ability_manager/include/ability_manager_ipc_interface_code.h +++ b/interfaces/inner_api/ability_manager/include/ability_manager_ipc_interface_code.h @@ -433,6 +433,7 @@ enum class AbilityManagerInterfaceCode { UNREGISTER_ABILITY_FIRST_FRAME_STATE_OBSERVER = 1127, // ipc for get ability state by persistent id GET_ABILITY_STATE_BY_PERSISTENT_ID = 1128, + TRANSFER_ABILITY_RESULT = 1129, // ipc id 2001-3000 for tools // ipc id for dumping state (2001) diff --git a/interfaces/kits/native/ability/native/ui_extension_ability/js_ui_extension_content_session.h b/interfaces/kits/native/ability/native/ui_extension_ability/js_ui_extension_content_session.h index 921f17cadb..7213f48f2f 100644 --- a/interfaces/kits/native/ability/native/ui_extension_ability/js_ui_extension_content_session.h +++ b/interfaces/kits/native/ability/native/ui_extension_ability/js_ui_extension_content_session.h @@ -117,6 +117,8 @@ protected: napi_env env, NapiCallbackInfo& info, std::shared_ptr &innerErrorCode); void StartAbilityForResultRuntimeTask(napi_env env, AAFwk::Want &want, std::shared_ptr asyncTask, size_t& unwrapArgc, AAFwk::StartOptions startOptions); + void SetCallbackForTerminateWithResult(int32_t resultCode, AAFwk::Want& want, + NapiAsyncTask::CompleteCallback& complete); private: sptr sessionInfo_; diff --git a/interfaces/kits/native/ability/native/ui_extension_ability/js_ui_extension_context.h b/interfaces/kits/native/ability/native/ui_extension_ability/js_ui_extension_context.h index bc8617201e..0cb523588a 100755 --- a/interfaces/kits/native/ability/native/ui_extension_ability/js_ui_extension_context.h +++ b/interfaces/kits/native/ability/native/ui_extension_ability/js_ui_extension_context.h @@ -54,6 +54,8 @@ protected: virtual napi_value OnDisconnectAbility(napi_env env, NapiCallbackInfo& info); virtual napi_value OnReportDrawnCompleted(napi_env env, NapiCallbackInfo& info); virtual napi_value OnOpenAtomicService(napi_env env, NapiCallbackInfo& info); + void SetCallbackForTerminateWithResult(int32_t resultCode, AAFwk::Want& want, + NapiAsyncTask::CompleteCallback& complete); private: std::weak_ptr context_; diff --git a/services/abilitymgr/include/ability_manager_proxy.h b/services/abilitymgr/include/ability_manager_proxy.h index cea49cf89c..4d4d26d527 100644 --- a/services/abilitymgr/include/ability_manager_proxy.h +++ b/services/abilitymgr/include/ability_manager_proxy.h @@ -1221,6 +1221,17 @@ public: */ virtual int32_t GetAbilityStateByPersistentId(int32_t persistentId, bool &state) override; + /** + * Transfer resultCode & want to ability manager service. + * + * @param callerToken caller ability token. + * @param requestCode the resultCode of the ability to start. + * @param want Indicates the ability to start. + * @return Returns ERR_OK on success, others on failure. + */ + virtual int32_t TransferAbilityResultForExtension(const sptr &callerToken, int32_t resultCode, + const Want &want) override; + private: template int GetParcelableInfos(MessageParcel &reply, std::vector &parcelableInfos); diff --git a/services/abilitymgr/include/ability_manager_service.h b/services/abilitymgr/include/ability_manager_service.h index 025c9fc7e9..5053762f37 100644 --- a/services/abilitymgr/include/ability_manager_service.h +++ b/services/abilitymgr/include/ability_manager_service.h @@ -1648,6 +1648,17 @@ public: */ virtual int32_t GetAbilityStateByPersistentId(int32_t persistentId, bool &state) override; + /** + * Transfer resultCode & want to ability manager service. + * + * @param callerToken Caller ability token. + * @param requestCode The resultCode of the ability to start. + * @param want Indicates the ability to start. + * @return Returns ERR_OK on success, others on failure. + */ + virtual int32_t TransferAbilityResultForExtension(const sptr &callerToken, int32_t resultCode, + const Want &want) override; + // MSG 0 - 20 represents timeout message static constexpr uint32_t LOAD_TIMEOUT_MSG = 0; static constexpr uint32_t ACTIVE_TIMEOUT_MSG = 1; diff --git a/services/abilitymgr/include/ability_manager_stub.h b/services/abilitymgr/include/ability_manager_stub.h index 07cec64efd..0b551f43b5 100644 --- a/services/abilitymgr/include/ability_manager_stub.h +++ b/services/abilitymgr/include/ability_manager_stub.h @@ -70,6 +70,7 @@ private: void SecondStepInit(); void ThirdStepInit(); void FourthStepInit(); + void FifthStepInit(); int TerminateAbilityInner(MessageParcel &data, MessageParcel &reply); int TerminateUIExtensionAbilityInner(MessageParcel &data, MessageParcel &reply); int CloseUIAbilityBySCBInner(MessageParcel &data, MessageParcel &reply); @@ -296,6 +297,7 @@ private: int32_t NotifyDebugAssertResultInner(MessageParcel &data, MessageParcel &reply); int32_t StartShortcutInner(MessageParcel &data, MessageParcel &reply); int32_t GetAbilityStateByPersistentIdInner(MessageParcel &data, MessageParcel &reply); + int32_t TransferAbilityResultForExtensionInner(MessageParcel &data, MessageParcel &reply); }; } // namespace AAFwk } // namespace OHOS diff --git a/services/abilitymgr/include/mission_list_manager.h b/services/abilitymgr/include/mission_list_manager.h index 908548573c..29b550fd39 100644 --- a/services/abilitymgr/include/mission_list_manager.h +++ b/services/abilitymgr/include/mission_list_manager.h @@ -318,7 +318,7 @@ public: void EnableRecoverAbility(int32_t missionId); - #ifdef ABILITY_COMMAND_FOR_TEST +#ifdef ABILITY_COMMAND_FOR_TEST /** * Block ability. * @@ -326,7 +326,7 @@ public: * @return Returns ERR_OK on success, others on failure. */ int BlockAbility(int abilityRecordId); - #endif +#endif void UninstallApp(const std::string &bundleName, int32_t uid); diff --git a/services/abilitymgr/src/ability_manager_client.cpp b/services/abilitymgr/src/ability_manager_client.cpp index 300754a942..7de7d71d5e 100644 --- a/services/abilitymgr/src/ability_manager_client.cpp +++ b/services/abilitymgr/src/ability_manager_client.cpp @@ -1821,5 +1821,13 @@ int32_t AbilityManagerClient::GetAbilityStateByPersistentId(int32_t persistentId CHECK_POINTER_RETURN_INVALID_VALUE(abms); return abms->GetAbilityStateByPersistentId(persistentId, state); } + +int32_t AbilityManagerClient::TransferAbilityResultForExtension(const sptr &callerToken, + int32_t resultCode, const Want &want) +{ + auto abms = GetAbilityManager(); + CHECK_POINTER_RETURN_INVALID_VALUE(abms); + return abms->TransferAbilityResultForExtension(callerToken, resultCode, want); +} } // namespace AAFwk } // namespace OHOS diff --git a/services/abilitymgr/src/ability_manager_proxy.cpp b/services/abilitymgr/src/ability_manager_proxy.cpp index 3ab73b5dd8..6e9010dff0 100644 --- a/services/abilitymgr/src/ability_manager_proxy.cpp +++ b/services/abilitymgr/src/ability_manager_proxy.cpp @@ -5155,5 +5155,35 @@ int32_t AbilityManagerProxy::GetAbilityStateByPersistentId(int32_t persistentId, state = reply.ReadBool(); return NO_ERROR; } + + +int32_t AbilityManagerProxy::TransferAbilityResultForExtension(const sptr &callerToken, + int32_t resultCode, const Want &want) +{ + if (callerToken == nullptr) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "callerToken is nullptr"); + return INNER_ERR; + } + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!WriteInterfaceToken(data)) { + return IPC_PROXY_ERR; + } + if (!data.WriteRemoteObject(callerToken) || !data.WriteInt32(resultCode)) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "callerToken or resultCode write failed."); + return INNER_ERR; + } + if (!data.WriteParcelable(&want)) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "want write failed."); + return INNER_ERR; + } + auto error = SendRequest(AbilityManagerInterfaceCode::TRANSFER_ABILITY_RESULT, data, reply, option); + if (error != NO_ERROR) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "Send request error: %{public}d", error); + return error; + } + return NO_ERROR; +} } // namespace AAFwk } // namespace OHOS diff --git a/services/abilitymgr/src/ability_manager_service.cpp b/services/abilitymgr/src/ability_manager_service.cpp index 55ef8fc7b9..d88038c41c 100644 --- a/services/abilitymgr/src/ability_manager_service.cpp +++ b/services/abilitymgr/src/ability_manager_service.cpp @@ -10354,5 +10354,25 @@ int32_t AbilityManagerService::GetAbilityStateByPersistentId(int32_t persistentI TAG_LOGE(AAFwkTag::ABILITYMGR, "GetAbilityStateByPersistentId, mission not have persistent id."); return INNER_ERR; } + +int32_t AbilityManagerService::TransferAbilityResultForExtension(const sptr &callerToken, + int32_t resultCode, const Want &want) +{ + HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); + auto token = IPCSkeleton::GetCallingTokenID(); + auto abilityRecord = Token::GetAbilityRecordByToken(callerToken); + CHECK_POINTER_AND_RETURN(abilityRecord, ERR_INVALID_VALUE); + auto type = abilityRecord->GetAbilityInfo().type; + if (type != AppExecFwk::AbilityType::EXTENSION) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "type is not uiextension."); + return ERR_INVALID_VALUE; + } + // save result to caller AbilityRecord. + Want* newWant = const_cast(&want); + newWant->RemoveParam(Want::PARAM_RESV_CALLER_TOKEN); + abilityRecord->SaveResultToCallers(resultCode, newWant); + abilityRecord->SendResultToCallers(); + return ERR_OK; +} } // namespace AAFwk } // namespace OHOS diff --git a/services/abilitymgr/src/ability_manager_stub.cpp b/services/abilitymgr/src/ability_manager_stub.cpp index ef78a7962e..2021e410a7 100644 --- a/services/abilitymgr/src/ability_manager_stub.cpp +++ b/services/abilitymgr/src/ability_manager_stub.cpp @@ -44,6 +44,7 @@ AbilityManagerStub::AbilityManagerStub() SecondStepInit(); ThirdStepInit(); FourthStepInit(); + FifthStepInit(); } AbilityManagerStub::~AbilityManagerStub() @@ -434,6 +435,12 @@ void AbilityManagerStub::FourthStepInit() &AbilityManagerStub::GetAbilityStateByPersistentIdInner; } +void AbilityManagerStub::FifthStepInit() +{ + requestFuncMap_[static_cast(AbilityManagerInterfaceCode::TRANSFER_ABILITY_RESULT)] = + &AbilityManagerStub::TransferAbilityResultForExtensionInner; +} + int AbilityManagerStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) { TAG_LOGD(AAFwkTag::ABILITYMGR, "Received code : %{public}d", code); @@ -3372,5 +3379,15 @@ int32_t AbilityManagerStub::GetAbilityStateByPersistentIdInner(MessageParcel &da } return result; } + +int32_t AbilityManagerStub::TransferAbilityResultForExtensionInner(MessageParcel &data, MessageParcel &reply) +{ + sptr callerToken = data.ReadRemoteObject(); + int32_t resultCode = data.ReadInt32(); + Want *want = data.ReadParcelable(); + int32_t result = TransferAbilityResultForExtension(callerToken, resultCode, *want); + reply.WriteInt32(result); + return NO_ERROR; +} } // namespace AAFwk } // namespace OHOS \ No newline at end of file diff --git a/test/unittest/ability_manager_client_branch_test/ability_manager_client_branch_test.cpp b/test/unittest/ability_manager_client_branch_test/ability_manager_client_branch_test.cpp index 53ccab04ab..d1030658f5 100644 --- a/test/unittest/ability_manager_client_branch_test/ability_manager_client_branch_test.cpp +++ b/test/unittest/ability_manager_client_branch_test/ability_manager_client_branch_test.cpp @@ -2569,5 +2569,21 @@ HWTEST_F(AbilityManagerClientBranchTest, AbilityManagerClient_GetAbilityStateByP EXPECT_NE(client_, nullptr); GTEST_LOG_(INFO) << "AbilityManagerClient_GetAbilityStateByPersistentId_0100 end"; } + +/** + * @tc.name: AbilityManagerClient_TransferAbilityResultForExtension_0100 + * @tc.desc: TransferAbilityResult + * @tc.type: FUNC + */ +HWTEST_F(AbilityManagerClientBranchTest, AbilityManagerClient_TransferAbilityResultForExtension_0100, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "AbilityManagerClient_TransferAbilityResultForExtension_0100 start"; + sptr callerToken = new AbilityManagerStubTestMock(); + int resultCode = 0; + Want resultWant; + auto result = client_->TransferAbilityResultForExtension(callerToken, resultCode, resultWant); + EXPECT_EQ(result, NO_ERROR); + GTEST_LOG_(INFO) << "AbilityManagerClient_TransferAbilityResultForExtension_0100 end"; +} } // namespace AAFwk } // namespace OHOS \ No newline at end of file diff --git a/test/unittest/ability_manager_service_third_test/ability_manager_service_third_test.cpp b/test/unittest/ability_manager_service_third_test/ability_manager_service_third_test.cpp index 646fb7e0f8..29c8669eef 100644 --- a/test/unittest/ability_manager_service_third_test/ability_manager_service_third_test.cpp +++ b/test/unittest/ability_manager_service_third_test/ability_manager_service_third_test.cpp @@ -1155,5 +1155,21 @@ HWTEST_F(AbilityManagerServiceThirdTest, GetAbilityStateByPersistentId_001, Test int32_t res = abilityMs->GetAbilityStateByPersistentId(persistentId, state); EXPECT_EQ(res, ERR_PERMISSION_DENIED); } + +/* + * Feature: AbilityManagerService + * Function: TransferAbilityResultForExtension + * FunctionPoints: AbilityManagerService TransferAbilityResultForExtension + */ +HWTEST_F(AbilityManagerServiceThirdTest, TransferAbilityResultForExtension_001, TestSize.Level1) +{ + auto abilityMs = std::make_shared(); + EXPECT_NE(abilityMs, nullptr); + sptr token = nullptr; + int32_t resultCode = 0; + AAFwk::Want want; + int32_t res = abilityMs->TransferAbilityResultForExtension(token, resultCode, want); + EXPECT_EQ(res, ERR_INVALID_VALUE); +} } // namespace AAFwk } // namespace OHOS From 899ebb0e6f17eb21317bc76d29a43eb35eba469f Mon Sep 17 00:00:00 2001 From: liuzongze Date: Tue, 14 May 2024 10:02:04 +0800 Subject: [PATCH 043/174] =?UTF-8?q?=E3=80=90DFX=E3=80=91=E3=80=90=E7=A8=B3?= =?UTF-8?q?=E5=AE=9A=E6=80=A7=E3=80=91uiextension?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liuzongze Change-Id: I7ddc2a0145643fb06017c6f306decc993f518865 --- .../ability/native/ui_extension_ability/js_ui_extension.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/native/ability/native/ui_extension_ability/js_ui_extension.cpp b/frameworks/native/ability/native/ui_extension_ability/js_ui_extension.cpp index eaac751d7a..a4e679a252 100755 --- a/frameworks/native/ability/native/ui_extension_ability/js_ui_extension.cpp +++ b/frameworks/native/ability/native/ui_extension_ability/js_ui_extension.cpp @@ -782,7 +782,7 @@ void JsUIExtension::DestroyWindow(const sptr &sessionInfo) CallObjectMethod("onSessionDestroy", argv, ARGC_ONE); } } - auto& uiWindow = uiWindowMap_[componentId]; + auto uiWindow = uiWindowMap_[componentId]; if (uiWindow) { uiWindow->Destroy(); } From 016188d3e0f3dbd5c961c3154a66dc77984c0bfa Mon Sep 17 00:00:00 2001 From: xinking129 Date: Tue, 14 May 2024 14:23:40 +0800 Subject: [PATCH 044/174] Conflict resolution Signed-off-by: xinking129 --- frameworks/js/napi/app/js_app_manager/js_app_manager.cpp | 2 +- frameworks/js/napi/uri_permission/js_uri_perm_mgr.cpp | 2 +- .../ability/native/ability_runtime/js_ability_context.cpp | 8 ++++---- .../ability/native/js_service_extension_context.cpp | 8 ++++---- services/abilitymgr/src/ability_manager_service.cpp | 8 ++++---- services/abilitymgr/src/ability_record.cpp | 4 ++-- services/appmgr/src/app_spawn_msg_wrapper.cpp | 2 +- services/appmgr/src/app_state_observer_manager.cpp | 2 +- services/common/src/app_utils.cpp | 6 +++--- services/common/src/permission_verification.cpp | 2 +- .../uripermmgr/src/uri_permission_manager_stub_impl.cpp | 8 ++++---- 11 files changed, 26 insertions(+), 26 deletions(-) diff --git a/frameworks/js/napi/app/js_app_manager/js_app_manager.cpp b/frameworks/js/napi/app/js_app_manager/js_app_manager.cpp index add1fc82bf..b4c20c2672 100644 --- a/frameworks/js/napi/app/js_app_manager/js_app_manager.cpp +++ b/frameworks/js/napi/app/js_app_manager/js_app_manager.cpp @@ -694,7 +694,7 @@ private: return; } bool ret = abilityManager->IsRunningInStabilityTest(); - TAG_LOGI(AAFwkTag::APPMGR, "result:%{public}d", ret); + TAG_LOGD(AAFwkTag::APPMGR, "result:%{public}d", ret); task.ResolveWithNoError(env, CreateJsValue(env, ret)); }; diff --git a/frameworks/js/napi/uri_permission/js_uri_perm_mgr.cpp b/frameworks/js/napi/uri_permission/js_uri_perm_mgr.cpp index a3df8ef79a..9e462b7363 100644 --- a/frameworks/js/napi/uri_permission/js_uri_perm_mgr.cpp +++ b/frameworks/js/napi/uri_permission/js_uri_perm_mgr.cpp @@ -175,7 +175,7 @@ private: napi_value CreateJsUriPermMgr(napi_env env, napi_value exportObj) { - TAG_LOGI(AAFwkTag::URIPERMMGR, "CreateJsUriPermMgr is called"); + TAG_LOGD(AAFwkTag::URIPERMMGR, "CreateJsUriPermMgr is called"); if (env == nullptr || exportObj == nullptr) { TAG_LOGI(AAFwkTag::URIPERMMGR, "Invalid input parameters"); return nullptr; diff --git a/frameworks/native/ability/native/ability_runtime/js_ability_context.cpp b/frameworks/native/ability/native/ability_runtime/js_ability_context.cpp index b2f4c3ac1b..2388a606bb 100644 --- a/frameworks/native/ability/native/ability_runtime/js_ability_context.cpp +++ b/frameworks/native/ability/native/ability_runtime/js_ability_context.cpp @@ -1174,7 +1174,7 @@ napi_value JsAbilityContext::OnConnectAbility(napi_env env, NapiCallbackInfo& in // unwrap want AAFwk::Want want; OHOS::AppExecFwk::UnwrapWant(env, info.argv[INDEX_ZERO], want); - TAG_LOGI(AAFwkTag::CONTEXT, "ConnectAbility, callee:%{public}s.%{public}s", + TAG_LOGD(AAFwkTag::CONTEXT, "ConnectAbility, callee:%{public}s.%{public}s", want.GetBundle().c_str(), want.GetElement().GetAbilityName().c_str()); @@ -1685,7 +1685,7 @@ void JSAbilityConnection::SetConnectionId(int64_t id) void JSAbilityConnection::OnAbilityConnectDone(const AppExecFwk::ElementName &element, const sptr &remoteObject, int resultCode) { - TAG_LOGI(AAFwkTag::CONTEXT, "OnAbilityConnectDone, resultCode:%{public}d", resultCode); + TAG_LOGD(AAFwkTag::CONTEXT, "OnAbilityConnectDone, resultCode:%{public}d", resultCode); wptr connection = this; std::unique_ptr complete = std::make_unique ([connection, element, remoteObject, resultCode](napi_env env, NapiAsyncTask &task, int32_t status) { @@ -1706,7 +1706,7 @@ void JSAbilityConnection::OnAbilityConnectDone(const AppExecFwk::ElementName &el void JSAbilityConnection::HandleOnAbilityConnectDone(const AppExecFwk::ElementName &element, const sptr &remoteObject, int resultCode) { - TAG_LOGI(AAFwkTag::CONTEXT, "HandleOnAbilityConnectDone, resultCode:%{public}d", resultCode); + TAG_LOGD(AAFwkTag::CONTEXT, "HandleOnAbilityConnectDone, resultCode:%{public}d", resultCode); if (jsConnectionObject_ == nullptr) { TAG_LOGE(AAFwkTag::CONTEXT, "jsConnectionObject_ nullptr"); return; @@ -1732,7 +1732,7 @@ void JSAbilityConnection::HandleOnAbilityConnectDone(const AppExecFwk::ElementNa void JSAbilityConnection::OnAbilityDisconnectDone(const AppExecFwk::ElementName &element, int resultCode) { - TAG_LOGI(AAFwkTag::CONTEXT, "OnAbilityDisconnectDone, resultCode:%{public}d", resultCode); + TAG_LOGD(AAFwkTag::CONTEXT, "OnAbilityDisconnectDone, resultCode:%{public}d", resultCode); wptr connection = this; std::unique_ptr complete = std::make_unique ([connection, element, resultCode](napi_env env, NapiAsyncTask &task, int32_t status) { diff --git a/frameworks/native/ability/native/js_service_extension_context.cpp b/frameworks/native/ability/native/js_service_extension_context.cpp index 8a8bbdb1fa..3477b0dddf 100644 --- a/frameworks/native/ability/native/js_service_extension_context.cpp +++ b/frameworks/native/ability/native/js_service_extension_context.cpp @@ -210,7 +210,7 @@ private: napi_value OnStartAbility(napi_env env, NapiCallbackInfo& info, bool isStartRecent = false) { HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); - TAG_LOGI(AAFwkTag::SERVICE_EXT, "StartAbility"); + TAG_LOGD(AAFwkTag::SERVICE_EXT, "StartAbility"); if (info.argc < ARGC_ONE) { TAG_LOGE(AAFwkTag::SERVICE_EXT, "Start ability failed, not enough params."); ThrowTooFewParametersError(env); @@ -782,7 +782,7 @@ private: napi_value OnDisconnectAbility(napi_env env, NapiCallbackInfo& info) { - TAG_LOGI(AAFwkTag::SERVICE_EXT, "DisconnectAbility start"); + TAG_LOGD(AAFwkTag::SERVICE_EXT, "DisconnectAbility start"); if (info.argc < ARGC_ONE) { TAG_LOGE(AAFwkTag::SERVICE_EXT, "Disconnect ability error, not enough params."); ThrowTooFewParametersError(env); @@ -1077,7 +1077,7 @@ private: return; } if (*retCode == 0) { - TAG_LOGI(AAFwkTag::SERVICE_EXT, "StartAbility is success"); + TAG_LOGD(AAFwkTag::SERVICE_EXT, "StartAbility is success"); task.Resolve(env, CreateJsUndefined(env)); } else { task.Reject(env, CreateJsErrorByNativeErr(env, *retCode)); @@ -1277,7 +1277,7 @@ void JSServiceExtensionConnection::OnAbilityDisconnectDone(const AppExecFwk::Ele void JSServiceExtensionConnection::HandleOnAbilityDisconnectDone(const AppExecFwk::ElementName &element, int resultCode) { - TAG_LOGI(AAFwkTag::SERVICE_EXT, "HandleOnAbilityDisconnectDone, resultCode:%{public}d", resultCode); + TAG_LOGD(AAFwkTag::SERVICE_EXT, "HandleOnAbilityDisconnectDone, resultCode:%{public}d", resultCode); napi_value napiElementName = OHOS::AppExecFwk::WrapElementName(env_, element); napi_value argv[] = {napiElementName}; if (jsConnectionObject_ == nullptr) { diff --git a/services/abilitymgr/src/ability_manager_service.cpp b/services/abilitymgr/src/ability_manager_service.cpp index 738cbe93fb..886932d633 100644 --- a/services/abilitymgr/src/ability_manager_service.cpp +++ b/services/abilitymgr/src/ability_manager_service.cpp @@ -586,7 +586,7 @@ int32_t AbilityManagerService::StartAbilityByFreeInstall(const Want &want, sptr< return ERR_INVALID_CONTINUATION_FLAG; } - TAG_LOGI(AAFwkTag::ABILITYMGR, "Start ability come, ability is %{public}s, userId is %{public}d", + TAG_LOGD(AAFwkTag::ABILITYMGR, "Start ability come, ability is %{public}s, userId is %{public}d", want.GetElement().GetAbilityName().c_str(), userId); int32_t ret = StartAbilityWrap(want, callerToken, requestCode, userId); @@ -4562,7 +4562,7 @@ int AbilityManagerService::MoveMissionsToBackground(const std::vector& int32_t AbilityManagerService::GetMissionIdByToken(const sptr &token) { - TAG_LOGI(AAFwkTag::ABILITYMGR, "request GetMissionIdByToken."); + TAG_LOGD(AAFwkTag::ABILITYMGR, "request GetMissionIdByToken."); auto abilityRecord = Token::GetAbilityRecordByToken(token); if (!abilityRecord) { TAG_LOGE(AAFwkTag::ABILITYMGR, "abilityRecord is null."); @@ -5411,7 +5411,7 @@ int AbilityManagerService::ScheduleDisconnectAbilityDone(const sptr &token) { HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); - TAG_LOGI(AAFwkTag::ABILITYMGR, "Schedule command ability done."); + TAG_LOGD(AAFwkTag::ABILITYMGR, "Schedule command ability done."); if (!VerificationAllToken(token)) { return ERR_INVALID_VALUE; } @@ -5973,7 +5973,7 @@ int AbilityManagerService::PreLoadAppDataAbilities(const std::string &bundleName void AbilityManagerService::PreLoadAppDataAbilitiesTask(const std::string &bundleName, const int32_t userId) { - TAG_LOGI(AAFwkTag::ABILITYMGR, "called"); + TAG_LOGD(AAFwkTag::ABILITYMGR, "called"); auto dataAbilityManager = GetDataAbilityManagerByUserId(userId); if (dataAbilityManager == nullptr) { TAG_LOGE(AAFwkTag::ABILITYMGR, "Invalid data ability manager when app data abilities preloading."); diff --git a/services/abilitymgr/src/ability_record.cpp b/services/abilitymgr/src/ability_record.cpp index 4fe8666f1b..9437b894ac 100644 --- a/services/abilitymgr/src/ability_record.cpp +++ b/services/abilitymgr/src/ability_record.cpp @@ -1626,7 +1626,7 @@ bool AbilityRecord::GrantUriPermissionForServiceExtension() std::lock_guard guard(wantLock_); auto callerTokenId = want_.GetIntParam(Want::PARAM_RESV_CALLER_TOKEN, 0); auto callerName = want_.GetStringParam(Want::PARAM_RESV_CALLER_BUNDLE_NAME); - TAG_LOGI(AAFwkTag::ABILITYMGR, + TAG_LOGD(AAFwkTag::ABILITYMGR, "CallerName is %{public}s, callerTokenId is %{public}u", callerName.c_str(), callerTokenId); GrantUriPermission(want_, applicationInfo_.bundleName, false, callerTokenId); return true; @@ -3039,7 +3039,7 @@ void AbilityRecord::GrantUriPermission(Want &want, std::string targetBundleName, } if ((want.GetFlags() & (Want::FLAG_AUTH_READ_URI_PERMISSION | Want::FLAG_AUTH_WRITE_URI_PERMISSION)) == 0) { - TAG_LOGW(AAFwkTag::ABILITYMGR, "Do not call uriPermissionMgr."); + TAG_LOGD(AAFwkTag::ABILITYMGR, "Do not call uriPermissionMgr."); return; } if (IsDmsCall(want)) { diff --git a/services/appmgr/src/app_spawn_msg_wrapper.cpp b/services/appmgr/src/app_spawn_msg_wrapper.cpp index 7c3bcd3be4..fb7c74b7e6 100644 --- a/services/appmgr/src/app_spawn_msg_wrapper.cpp +++ b/services/appmgr/src/app_spawn_msg_wrapper.cpp @@ -170,7 +170,7 @@ void AppSpawnMsgWrapper::BuildExtraInfo(const AppSpawnStartMsg &startMsg) if (!startMsg.appEnv.empty()) { auto appEnvStr = DumpAppEnvToJson(startMsg.appEnv); - TAG_LOGI(AAFwkTag::APPMGR, "AppEnv: %{public}s", appEnvStr.c_str()); + TAG_LOGD(AAFwkTag::APPMGR, "AppEnv: %{public}s", appEnvStr.c_str()); extraInfoStr_ += APP_ENV_TYPE + appEnvStr + APP_ENV_TYPE; } diff --git a/services/appmgr/src/app_state_observer_manager.cpp b/services/appmgr/src/app_state_observer_manager.cpp index 684a7179c2..7f4ddcf5fa 100644 --- a/services/appmgr/src/app_state_observer_manager.cpp +++ b/services/appmgr/src/app_state_observer_manager.cpp @@ -809,7 +809,7 @@ AbilityforegroundObserverSet AppStateObserverManager::GetAbilityforegroundObserv void AppStateObserverManager::OnObserverDied(const wptr &remote, const ObserverType &type) { HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); - TAG_LOGI(AAFwkTag::APPMGR, "OnObserverDied"); + TAG_LOGD(AAFwkTag::APPMGR, "OnObserverDied"); auto object = remote.promote(); if (object == nullptr) { TAG_LOGE(AAFwkTag::APPMGR, "observer nullptr."); diff --git a/services/common/src/app_utils.cpp b/services/common/src/app_utils.cpp index 7d47ade7dd..08018c964f 100644 --- a/services/common/src/app_utils.cpp +++ b/services/common/src/app_utils.cpp @@ -81,7 +81,7 @@ bool AppUtils::IsInheritWindowSplitScreenMode() isInheritWindowSplitScreenMode_.value = system::GetBoolParameter(INHERIT_WINDOW_SPLIT_SCREEN_MODE, true); isInheritWindowSplitScreenMode_.isLoaded = true; } - TAG_LOGI(AAFwkTag::DEFAULT, "isInheritWindowSplitScreenMode is %{public}d", isInheritWindowSplitScreenMode_.value); + TAG_LOGD(AAFwkTag::DEFAULT, "isInheritWindowSplitScreenMode is %{public}d", isInheritWindowSplitScreenMode_.value); return isInheritWindowSplitScreenMode_.value; } @@ -101,7 +101,7 @@ int32_t AppUtils::GetTimeoutUnitTimeRatio() timeoutUnitTimeRatio_.value = system::GetIntParameter(TIMEOUT_UNIT_TIME_RATIO, 1); timeoutUnitTimeRatio_.isLoaded = true; } - TAG_LOGI(AAFwkTag::DEFAULT, "timeoutUnitTimeRatio is %{public}d", timeoutUnitTimeRatio_.value); + TAG_LOGD(AAFwkTag::DEFAULT, "timeoutUnitTimeRatio is %{public}d", timeoutUnitTimeRatio_.value); return timeoutUnitTimeRatio_.value; } @@ -171,7 +171,7 @@ bool AppUtils::IsMultiProcessModel() isMultiProcessModel_.value = system::GetBoolParameter(MULTI_PROCESS_MODEL, false); isMultiProcessModel_.isLoaded = true; } - TAG_LOGI(AAFwkTag::DEFAULT, "isMultiProcessModel_ is %{public}d", isMultiProcessModel_.value); + TAG_LOGD(AAFwkTag::DEFAULT, "isMultiProcessModel_ is %{public}d", isMultiProcessModel_.value); return isMultiProcessModel_.value; } diff --git a/services/common/src/permission_verification.cpp b/services/common/src/permission_verification.cpp index 3ee4a83fb4..c851f29542 100644 --- a/services/common/src/permission_verification.cpp +++ b/services/common/src/permission_verification.cpp @@ -400,7 +400,7 @@ bool PermissionVerification::JudgeAssociatedWakeUp(const uint32_t accessTokenId, int PermissionVerification::JudgeInvisibleAndBackground(const VerificationInfo &verificationInfo) const { uint32_t specifyTokenId = verificationInfo.specifyTokenId; - TAG_LOGI(AAFwkTag::DEFAULT, "specifyTokenId = %{public}u", specifyTokenId); + TAG_LOGD(AAFwkTag::DEFAULT, "specifyTokenId = %{public}u", specifyTokenId); if (specifyTokenId == 0 && IPCSkeleton::GetCallingUid() != BROKER_UID && SupportSystemAbilityPermission::IsSupportSaCallPermission() && IsSACall()) { TAG_LOGD(AAFwkTag::DEFAULT, "Support SA call"); diff --git a/services/uripermmgr/src/uri_permission_manager_stub_impl.cpp b/services/uripermmgr/src/uri_permission_manager_stub_impl.cpp index c0b984c33e..110f94a803 100644 --- a/services/uripermmgr/src/uri_permission_manager_stub_impl.cpp +++ b/services/uripermmgr/src/uri_permission_manager_stub_impl.cpp @@ -55,7 +55,7 @@ bool UriPermissionManagerStubImpl::VerifyUriPermission(const Uri &uri, uint32_t { // verify if tokenId have uri permission record auto uriStr = uri.ToString(); - TAG_LOGI(AAFwkTag::URIPERMMGR, "uri is %{private}s, flag is %{public}u, tokenId is %{public}u", + TAG_LOGD(AAFwkTag::URIPERMMGR, "uri is %{private}s, flag is %{public}u, tokenId is %{public}u", uriStr.c_str(), flag, tokenId); if (!IsSAOrSystemAppCall()) { TAG_LOGE(AAFwkTag::URIPERMMGR, "Only support SA and SystemApp called."); @@ -67,7 +67,7 @@ bool UriPermissionManagerStubImpl::VerifyUriPermission(const Uri &uri, uint32_t auto& list = search->second; for (auto it = list.begin(); it != list.end(); it++) { if ((it->targetTokenId == tokenId) && ((it->flag | Want::FLAG_AUTH_READ_URI_PERMISSION) & flag) != 0) { - TAG_LOGI(AAFwkTag::URIPERMMGR, "have uri permission."); + TAG_LOGD(AAFwkTag::URIPERMMGR, "have uri permission."); return true; } } @@ -280,7 +280,7 @@ int UriPermissionManagerStubImpl::AddTempUriPermission(const std::string &uri, u return ERR_OK; } // w-r - TAG_LOGI(AAFwkTag::URIPERMMGR, "Uri has been granted, not to grant again."); + TAG_LOGD(AAFwkTag::URIPERMMGR, "Uri has been granted, not to grant again."); if ((item.flag & FLAG_WRITE_URI) != 0 && (flag & FLAG_WRITE_URI) == 0) { return ERR_OK; } @@ -299,7 +299,7 @@ int UriPermissionManagerStubImpl::AddTempUriPermission(const std::string &uri, u int UriPermissionManagerStubImpl::GrantUriPermissionImpl(const Uri &uri, unsigned int flag, TokenId callerTokenId, TokenId targetTokenId, int32_t abilityId) { - TAG_LOGI(AAFwkTag::URIPERMMGR, "uri = %{private}s, flag = %{public}i, callerTokenId = %{public}i," + TAG_LOGD(AAFwkTag::URIPERMMGR, "uri = %{private}s, flag = %{public}i, callerTokenId = %{public}i," "targetTokenId = %{public}i, abilityId = %{public}i", uri.ToString().c_str(), flag, callerTokenId, targetTokenId, abilityId); ConnectManager(storageManager_, STORAGE_MANAGER_MANAGER_ID); From 8178dbcabc560add4b3050ea497db44deeafd24d Mon Sep 17 00:00:00 2001 From: grs Date: Mon, 13 May 2024 13:50:53 +0800 Subject: [PATCH 045/174] =?UTF-8?q?=E6=96=B0=E5=A2=9EAPI=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E5=88=9B=E5=BB=BAnative=E5=AD=90=E8=BF=9B=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: grs --- ability_runtime.gni | 1 + bundle.json | 10 ++ .../child_process_manager.cpp | 69 +++++++++ .../native_child_ipc_process.cpp | 146 ++++++++++++++++++ .../native/appkit/app/child_main_thread.cpp | 70 ++++++++- frameworks/native/child_process/BUILD.gn | 66 ++++++++ .../include/native_child_callback.h | 40 +++++ .../src/native_child_callback.cpp | 66 ++++++++ .../src/native_child_process.cpp | 104 +++++++++++++ interfaces/inner_api/app_manager/BUILD.gn | 2 + .../include/appmgr/app_mgr_interface.h | 10 ++ .../appmgr/app_mgr_ipc_interface_code.h | 1 + .../include/appmgr/app_mgr_proxy.h | 11 ++ .../app_manager/include/appmgr/app_mgr_stub.h | 1 + .../include/appmgr/child_process_info.h | 5 + .../appmgr/child_scheduler_interface.h | 7 + .../include/appmgr/child_scheduler_proxy.h | 1 + .../include/appmgr/child_scheduler_stub.h | 1 + .../appmgr/native_child_notify_interface.h | 50 ++++++ .../appmgr/native_child_notify_proxy.h | 43 ++++++ .../include/appmgr/native_child_notify_stub.h | 41 +++++ .../app_manager/src/appmgr/app_mgr_proxy.cpp | 41 +++++ .../app_manager/src/appmgr/app_mgr_stub.cpp | 18 +++ .../src/appmgr/child_process_info.cpp | 3 + .../src/appmgr/child_scheduler_proxy.cpp | 34 ++++ .../src/appmgr/child_scheduler_stub.cpp | 10 ++ .../src/appmgr/native_child_notify_proxy.cpp | 94 +++++++++++ .../src/appmgr/native_child_notify_stub.cpp | 71 +++++++++ .../inner_api/child_process_manager/BUILD.gn | 2 + .../include/child_process_manager.h | 5 + .../child_process_manager_error_utils.h | 4 + .../include/child_process_start_info.h | 2 + .../include/native_child_ipc_process.h | 53 +++++++ .../child_process/native_child_process.h | 144 +++++++++++++++++ .../native/appkit/app/child_main_thread.h | 3 + services/appmgr/include/app_mgr_service.h | 11 ++ .../appmgr/include/app_mgr_service_inner.h | 11 ++ .../appmgr/include/child_process_record.h | 11 ++ services/appmgr/src/app_mgr_service.cpp | 14 ++ services/appmgr/src/app_mgr_service_inner.cpp | 53 ++++++- services/appmgr/src/child_process_record.cpp | 42 +++++ services/common/BUILD.gn | 1 + services/common/include/app_utils.h | 2 + services/common/src/app_utils.cpp | 13 ++ .../include/mock_app_mgr_service.h | 2 + .../include/mock_app_mgr_service_inner.h | 2 + .../include/mock_app_mgr_service.h | 2 + .../include/mock_app_mgr_service_inner.h | 2 + test/unittest/BUILD.gn | 3 + .../app_mgr_service_test.cpp | 26 ++++ .../child_main_thread_test.cpp | 21 +++ .../unittest/child_process_capi_test/BUILD.gn | 52 +++++++ .../child_process_capi_test.cpp | 81 ++++++++++ .../child_process_manager_test.cpp | 18 +++ 54 files changed, 1592 insertions(+), 4 deletions(-) create mode 100644 frameworks/native/ability/native/child_process_manager/native_child_ipc_process.cpp create mode 100644 frameworks/native/child_process/BUILD.gn create mode 100644 frameworks/native/child_process/include/native_child_callback.h create mode 100644 frameworks/native/child_process/src/native_child_callback.cpp create mode 100644 frameworks/native/child_process/src/native_child_process.cpp create mode 100644 interfaces/inner_api/app_manager/include/appmgr/native_child_notify_interface.h create mode 100644 interfaces/inner_api/app_manager/include/appmgr/native_child_notify_proxy.h create mode 100644 interfaces/inner_api/app_manager/include/appmgr/native_child_notify_stub.h create mode 100644 interfaces/inner_api/app_manager/src/appmgr/native_child_notify_proxy.cpp create mode 100644 interfaces/inner_api/app_manager/src/appmgr/native_child_notify_stub.cpp create mode 100644 interfaces/inner_api/child_process_manager/include/native_child_ipc_process.h create mode 100644 interfaces/kits/c/ability/ability_runtime/child_process/native_child_process.h create mode 100644 test/unittest/child_process_capi_test/BUILD.gn create mode 100644 test/unittest/child_process_capi_test/child_process_capi_test.cpp diff --git a/ability_runtime.gni b/ability_runtime.gni index e7848c2544..729ad0ef0f 100644 --- a/ability_runtime.gni +++ b/ability_runtime.gni @@ -18,6 +18,7 @@ ability_runtime_napi_path = "${ability_runtime_path}/frameworks/js/napi" ability_base_path = "//foundation/ability/ability_base" form_fwk_path = "//foundation/ability/form_fwk" ability_runtime_innerkits_path = "${ability_runtime_path}/interfaces/inner_api" +ability_runtime_ndk_path = "${ability_runtime_path}/interfaces/kits/c" ability_runtime_native_path = "${ability_runtime_path}/frameworks/native" ability_runtime_services_path = "${ability_runtime_path}/services" ability_runtime_abilitymgr_path = "${ability_runtime_services_path}/abilitymgr" diff --git a/bundle.json b/bundle.json index 19dca40645..a4f62beeb9 100644 --- a/bundle.json +++ b/bundle.json @@ -104,6 +104,7 @@ "//foundation/ability/ability_runtime/interfaces/inner_api:innerkits_target", "//foundation/ability/ability_runtime/frameworks/native/ability/native:ability_thread", "//foundation/ability/ability_runtime/frameworks/native/ability/native:extension_module", + "//foundation/ability/ability_runtime/frameworks/native/child_process:child_process", "//foundation/ability/ability_runtime/frameworks/native/insight_intent:insight_intent_innerkits", "//foundation/ability/ability_runtime/frameworks/js/napi:napi_packages", "//foundation/ability/ability_runtime/cj_environment/frameworks/cj_environment:cj_environment", @@ -312,6 +313,15 @@ }, "name": "//foundation/ability/ability_runtime/frameworks/native/appkit:app_context" }, + { + "header": { + "header_base": "//foundation/ability/ability_runtime/interfaces/kits/c/ability/ability_runtime/child_process", + "header_files": [ + "native_child_process.h" + ] + }, + "name": "//foundation/ability/ability_runtime/frameworks/native/child_process:child_process" + }, { "header": { "header_base": "//foundation/ability/ability_runtime/interfaces/inner_api/uri_permission/include/", diff --git a/frameworks/native/ability/native/child_process_manager/child_process_manager.cpp b/frameworks/native/ability/native/child_process_manager/child_process_manager.cpp index c377797192..28de904cb1 100644 --- a/frameworks/native/ability/native/child_process_manager/child_process_manager.cpp +++ b/frameworks/native/ability/native/child_process_manager/child_process_manager.cpp @@ -29,6 +29,7 @@ #include "bundle_info.h" #include "bundle_mgr_interface.h" #include "child_process.h" +#include "native_child_ipc_process.h" #include "child_process_manager_error_utils.h" #include "child_process_start_info.h" #include "constants.h" @@ -115,6 +116,37 @@ ChildProcessManagerErrorCode ChildProcessManager::StartChildProcessByAppSpawnFor return ChildProcessManagerErrorCode::ERR_OK; } +ChildProcessManagerErrorCode ChildProcessManager::StartNativeChildProcessByAppSpawnFork( + const std::string &libName, const sptr &callbackStub) +{ + TAG_LOGI(AAFwkTag::PROCESSMGR, "called, libName:%{private}s", libName.c_str()); + ChildProcessManagerErrorCode errorCode = PreCheckNativeProcess(); + if (errorCode != ChildProcessManagerErrorCode::ERR_OK) { + return errorCode; + } + + sptr appMgr = GetAppMgr(); + if (appMgr == nullptr) { + TAG_LOGE(AAFwkTag::PROCESSMGR, "GetAppMgr for native child process failed."); + return ChildProcessManagerErrorCode::ERR_GET_APP_MGR_FAILED; + } + + auto ret = appMgr->StartNativeChildProcess(libName, childProcessCount_, callbackStub); + TAG_LOGD(AAFwkTag::PROCESSMGR, "AppMgr StartNativeChildProcess ret:%{public}d", ret); + + if (ret != ERR_OK) { + TAG_LOGE(AAFwkTag::PROCESSMGR, "AppMgr StartNativeChildProcess failed, ret:%{public}d", ret); + if (ret == ERR_OVERFLOW) { + TAG_LOGE(AAFwkTag::PROCESSMGR, "Max native child processes readched"); + return ChildProcessManagerErrorCode::ERR_MAX_NATIVE_CHILD_PROCESSES; + } + return ChildProcessManagerErrorCode::ERR_GET_APP_MGR_START_PROCESS_FAILED; + } + + ++childProcessCount_; + return ChildProcessManagerErrorCode::ERR_OK; +} + void ChildProcessManager::RegisterSignal() { if (!signalRegistered_) { @@ -144,6 +176,21 @@ ChildProcessManagerErrorCode ChildProcessManager::PreCheck() return ChildProcessManagerErrorCode::ERR_OK; } +ChildProcessManagerErrorCode ChildProcessManager::PreCheckNativeProcess() +{ + ChildProcessManagerErrorCode errCode = PreCheck(); + if (errCode != ChildProcessManagerErrorCode::ERR_OK) { + return errCode; + } + + if (!AAFwk::AppUtils::GetInstance().IsSupportNativeChildProcess()) { + TAG_LOGE(AAFwkTag::PROCESSMGR, "Unsupport native child process"); + return ChildProcessManagerErrorCode::ERR_UNSUPPORT_NATIVE_CHILD_PROCESS; + } + + return ChildProcessManagerErrorCode::ERR_OK; +} + bool ChildProcessManager::IsChildProcess() { return isChildProcessBySelfFork_ || hasChildProcessRecord(); @@ -207,6 +254,28 @@ bool ChildProcessManager::LoadJsFile(const std::string &srcEntry, const AppExecF return true; } +bool ChildProcessManager::LoadNativeLib(const std::string &libPath, const sptr &mainProcessCb) +{ + auto childProcess = NativeChildIpcProcess::Create(); + if (childProcess == nullptr) { + TAG_LOGE(AAFwkTag::PROCESSMGR, "Failed create NativeChildIpcProcess"); + return false; + } + + std::shared_ptr processStartInfo = std::make_shared(); + processStartInfo->name = std::filesystem::path(libPath).stem(); + processStartInfo->srcEntry = libPath; + processStartInfo->ipcObj = mainProcessCb; + if (!childProcess->Init(processStartInfo)) { + TAG_LOGE(AAFwkTag::PROCESSMGR, "NativeChildIpcProcess init failed."); + return false; + } + + childProcess->OnStart(); + TAG_LOGD(AAFwkTag::PROCESSMGR, "LoadNativeLib end."); + return true; +} + std::unique_ptr ChildProcessManager::CreateRuntime(const AppExecFwk::BundleInfo &bundleInfo, const AppExecFwk::HapModuleInfo &hapModuleInfo, const bool fromAppSpawn, const bool jitEnabled) { diff --git a/frameworks/native/ability/native/child_process_manager/native_child_ipc_process.cpp b/frameworks/native/ability/native/child_process_manager/native_child_ipc_process.cpp new file mode 100644 index 0000000000..905c32a4b9 --- /dev/null +++ b/frameworks/native/ability/native/child_process_manager/native_child_ipc_process.cpp @@ -0,0 +1,146 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "native_child_ipc_process.h" +#include +#include +#include +#include "hilog_tag_wrapper.h" +#include "hilog_wrapper.h" +#include "child_process_manager_error_utils.h" + +namespace OHOS { +namespace AbilityRuntime { + +std::shared_ptr NativeChildIpcProcess::Create() +{ + return std::make_shared(); +} + +NativeChildIpcProcess::~NativeChildIpcProcess() +{ + UnloadNativeLib(); +} + +bool NativeChildIpcProcess::Init(const std::shared_ptr &info) +{ + TAG_LOGD(AAFwkTag::PROCESSMGR, "NativeChildIpcProcess init"); + if (info == nullptr || info->ipcObj == nullptr) { + TAG_LOGE(AAFwkTag::PROCESSMGR, "info or ipc callback is null"); + return false; + } + + if (!ChildProcess::Init(info)) { + TAG_LOGE(AAFwkTag::PROCESSMGR, "Base class init failed."); + return false; + } + + auto iNotify = iface_cast(info->ipcObj); + if (iNotify == nullptr) { + TAG_LOGE(AAFwkTag::PROCESSMGR, "Faild cvt interface to INativeChildNotify"); + return false; + } + + if (!LoadNativeLib(info)) { + iNotify->OnError(static_cast(ChildProcessManagerErrorCode::ERR_NATIVE_CHILD_PROCESS_LOAD_LIB)); + return false; + } + + mainProcessCb_ = iNotify; + return true; +} + +void NativeChildIpcProcess::OnStart() +{ + if (funcNativeLibOnConnect_ == nullptr || funcNativeLibMainProc_ == nullptr || mainProcessCb_ == nullptr) { + TAG_LOGE(AAFwkTag::PROCESSMGR, "No init"); + return; + } + + ChildProcess::OnStart(); + OHIPCRemoteStub *ipcStub = funcNativeLibOnConnect_(); + if (ipcStub == nullptr || ipcStub->remote == nullptr) { + TAG_LOGE(AAFwkTag::PROCESSMGR, "Native lib OnConnect function return null stub"); + mainProcessCb_->OnError(static_cast(ChildProcessManagerErrorCode::ERR_NATIVE_CHILD_PROCESS_CONNECT)); + return; + } + + std::thread cbThread([this, childIpcStub = std::move(ipcStub->remote)] () -> void { + // Wait MainProc run first + std::this_thread::sleep_for(std::chrono::milliseconds(1)); + TAG_LOGI(AAFwkTag::PROCESSMGR, "Notify native child process started"); + mainProcessCb_->OnNativeChildStarted(childIpcStub); + }); + + TAG_LOGI(AAFwkTag::PROCESSMGR, "Enter native lib MainProc"); + funcNativeLibMainProc_(); + TAG_LOGI(AAFwkTag::PROCESSMGR, "Native lib MainProc returned"); + + if (cbThread.joinable()) { + cbThread.join(); + } +} + +bool NativeChildIpcProcess::LoadNativeLib(const std::shared_ptr &info) +{ + if (nativeLibHandle_ != nullptr) { + TAG_LOGE(AAFwkTag::PROCESSMGR, "Native lib already loaded"); + return false; + } + + void *libHandle = dlopen(info->srcEntry.c_str(), RTLD_LAZY); + if (libHandle == nullptr) { + TAG_LOGE(AAFwkTag::PROCESSMGR, "Load lib file %{private}s failed, err %{public}s", + info->srcEntry.c_str(), dlerror()); + return false; + } + + do { + NativeChildProcess_OnConnect funcOnConnect = + reinterpret_cast(dlsym(libHandle, "NativeChildProcess_OnConnect")); + if (funcOnConnect == nullptr) { + TAG_LOGE(AAFwkTag::PROCESSMGR, "Get OnConnect function address failed, err %{public}s", dlerror()); + break; + } + + NativeChildProcess_MainProc funcMainProc = + reinterpret_cast(dlsym(libHandle, "NativeChildProcess_MainProc")); + if (funcMainProc == nullptr) { + TAG_LOGE(AAFwkTag::PROCESSMGR, "Get MainProc function address failed, err %{public}s", dlerror()); + break; + } + + funcNativeLibOnConnect_ = funcOnConnect; + funcNativeLibMainProc_ = funcMainProc; + nativeLibHandle_ = libHandle; + return true; + } while (false); + + dlclose(libHandle); + return false; +} + +void NativeChildIpcProcess::UnloadNativeLib() +{ + if (nativeLibHandle_ != nullptr) { + dlclose(nativeLibHandle_); + nativeLibHandle_ = nullptr; + funcNativeLibOnConnect_ = nullptr; + funcNativeLibMainProc_ = nullptr; + } +} + +} // namespace AbilityRuntime +} // namespace OHOS diff --git a/frameworks/native/appkit/app/child_main_thread.cpp b/frameworks/native/appkit/app/child_main_thread.cpp index 004d0cca2b..a6030e6d93 100644 --- a/frameworks/native/appkit/app/child_main_thread.cpp +++ b/frameworks/native/appkit/app/child_main_thread.cpp @@ -14,7 +14,7 @@ */ #include "child_main_thread.h" - +#include #include "bundle_mgr_proxy.h" #include "child_process_manager.h" #include "constants.h" @@ -172,7 +172,12 @@ void ChildMainThread::InitNativeLib(const BundleInfo &bundleInfo) GetNativeLibPath(bundleInfo, appLibPaths); bool isSystemApp = bundleInfo.applicationInfo.isSystemApp; TAG_LOGD(AAFwkTag::APPKIT, "the application isSystemApp: %{public}d", isSystemApp); - AbilityRuntime::JsRuntime::SetAppLibPath(appLibPaths, isSystemApp); + + if (processInfo_->processType != CHILD_PROCESS_TYPE_NATIVE) { + AbilityRuntime::JsRuntime::SetAppLibPath(appLibPaths, isSystemApp); + } else { + UpdateNativeChildLibPath(appLibPaths); + } } void ChildMainThread::ExitProcessSafely() @@ -222,6 +227,67 @@ void ChildMainThread::HandleExitProcessSafely() } } +bool ChildMainThread::ScheduleRunNativeProc(const sptr &mainProcessCb) +{ + TAG_LOGD(AAFwkTag::APPKIT, "ScheduleRunNativeProc"); + if (mainProcessCb == nullptr) { + TAG_LOGE(AAFwkTag::APPKIT, "Main process callback is null"); + return false; + } + + if (mainHandler_ == nullptr) { + TAG_LOGE(AAFwkTag::APPKIT, "mainHandler_ is null"); + return false; + } + + auto task = [weak = wptr(this), callback = sptr(mainProcessCb)]() { + auto childMainThread = weak.promote(); + if (childMainThread == nullptr) { + TAG_LOGE(AAFwkTag::APPKIT, "childMainThread is nullptr, ScheduleRunNativeProc failed."); + return; + } + childMainThread->HandleRunNativeProc(callback); + }; + if (!mainHandler_->PostTask(task, "ChildMainThread::HandleRunNativeProc")) { + TAG_LOGE(AAFwkTag::APPKIT, "HandleRunNativeProc PostTask task failed."); + return false; + } + return true; +} + +void ChildMainThread::HandleRunNativeProc(const sptr &mainProcessCb) +{ + TAG_LOGD(AAFwkTag::APPKIT, "HandleRunNativeProc called start."); + if (!processInfo_) { + TAG_LOGE(AAFwkTag::APPKIT, "processInfo is null."); + return; + } + + ChildProcessManager &childProcessMgr = ChildProcessManager::GetInstance(); + childProcessMgr.LoadNativeLib(processInfo_->srcEntry, mainProcessCb); + TAG_LOGD(AAFwkTag::APPKIT, "HandleRunNativeProc end."); + ExitProcessSafely(); +} + +void ChildMainThread::UpdateNativeChildLibPath(const AppLibPathMap &appLibPaths) +{ + std::string nativeLibPath; + for (const auto &libPathPair : appLibPaths) { + for (const auto &libDir : libPathPair.second) { + nativeLibPath = libDir; + if (!nativeLibPath.empty() && nativeLibPath.back() != '/') { + nativeLibPath += '/'; + } + + nativeLibPath += processInfo_->srcEntry; + if (access(nativeLibPath.c_str(), F_OK) == 0) { + processInfo_->srcEntry = nativeLibPath; + break; + } + } + } +} + void ChildMainThread::GetNativeLibPath(const BundleInfo &bundleInfo, AppLibPathMap &appLibPaths) { std::string nativeLibraryPath = bundleInfo.applicationInfo.nativeLibraryPath; diff --git a/frameworks/native/child_process/BUILD.gn b/frameworks/native/child_process/BUILD.gn new file mode 100644 index 0000000000..4d5fe5006a --- /dev/null +++ b/frameworks/native/child_process/BUILD.gn @@ -0,0 +1,66 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/ohos.gni") +import("//foundation/ability/ability_runtime/ability_runtime.gni") + +config("child_process_ndk_config") { + include_dirs = + [ "${ability_runtime_ndk_path}/ability/ability_runtime/child_process" ] + + if (target_cpu == "arm") { + cflags = [ "-DBINDER_IPC_32BIT" ] + } +} + +ohos_shared_library("child_process") { + sanitize = { + integer_overflow = true + ubsan = true + boundary_sanitize = true + cfi = true + cfi_cross_dso = true + cfi_vcall_icall_only = true + debug = false + } + branch_protector_ret = "pac_ret" + + include_dirs = [ "include" ] + + configs = [ "${ability_runtime_services_path}/common:common_config" ] + public_configs = [ ":child_process_ndk_config" ] + + sources = [ + "${ability_runtime_native_path}/child_process/src/native_child_callback.cpp", + "${ability_runtime_native_path}/child_process/src/native_child_process.cpp", + ] + + deps = [ + "${ability_runtime_innerkits_path}/app_manager:app_manager", + "${ability_runtime_innerkits_path}/child_process_manager:child_process_manager", + "${ability_runtime_native_path}/ability/native:ability_business_error", + ] + + external_deps = [ + "c_utils:utils", + "hilog:libhilog", + "ipc:ipc_capi", + "ipc:ipc_core", + ] + + output_extension = "so" + innerapi_tags = [ "ndk" ] + install_images = [ "system" ] + subsystem_name = "ability" + part_name = "ability_runtime" +} diff --git a/frameworks/native/child_process/include/native_child_callback.h b/frameworks/native/child_process/include/native_child_callback.h new file mode 100644 index 0000000000..b0be67b876 --- /dev/null +++ b/frameworks/native/child_process/include/native_child_callback.h @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ABILITY_RUNTIME_NATIVE_CHILD_CALLBACK_H +#define OHOS_ABILITY_RUNTIME_NATIVE_CHILD_CALLBACK_H + +#include "native_child_notify_stub.h" +#include "native_child_process.h" + +namespace OHOS { +namespace AbilityRuntime { + +class NativeChildCallback : public OHOS::AppExecFwk::NativeChildNotifyStub { +public: + explicit NativeChildCallback(OH_Ability_OnNativeChildProcessStarted cb); + ~NativeChildCallback() = default; + + void OnNativeChildStarted(const sptr &nativeChild) override; + void OnError(int32_t errCode) override; + +private: + OH_Ability_OnNativeChildProcessStarted callback_ = nullptr; +}; + +} // namespace AbilityRuntime +} // namespace OHOS + +#endif // OHOS_ABILITY_RUNTIME_NATIVE_CHILD_CALLBACK_H diff --git a/frameworks/native/child_process/src/native_child_callback.cpp b/frameworks/native/child_process/src/native_child_callback.cpp new file mode 100644 index 0000000000..1102c8b3fb --- /dev/null +++ b/frameworks/native/child_process/src/native_child_callback.cpp @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "native_child_callback.h" +#include "hilog_tag_wrapper.h" +#include "hilog_wrapper.h" +#include "ipc_inner_object.h" +#include "child_process_manager_error_utils.h" + +namespace OHOS { +namespace AbilityRuntime { + +NativeChildCallback::NativeChildCallback(OH_Ability_OnNativeChildProcessStarted cb) + : NativeChildNotifyStub(), callback_(cb) +{ +} + +void NativeChildCallback::OnNativeChildStarted(const sptr &nativeChild) +{ + if (callback_ == nullptr) { + TAG_LOGE(AAFwkTag::PROCESSMGR, "Native child process started, but callback is null?"); + return; + } + + if (!nativeChild) { + TAG_LOGE(AAFwkTag::PROCESSMGR, "Native child process ipc object is null"); + return; + } + + TAG_LOGI(AAFwkTag::PROCESSMGR, "Native child process started"); + sptr ipcRemote = nativeChild; + OHIPCRemoteProxy *ipcProxy = CreateIPCRemoteProxy(ipcRemote); + if (ipcProxy == nullptr) { + TAG_LOGE(AAFwkTag::PROCESSMGR, "Convert inner ipc object to OHIPCRemoteProxy point failed"); + callback_(NCP_ERR_INTERNAL, nullptr); + return; + } + + callback_(static_cast(ChildProcessManagerErrorCode::ERR_OK), ipcProxy); +} + +void NativeChildCallback::OnError(int32_t errCode) +{ + if (callback_ == nullptr) { + TAG_LOGE(AAFwkTag::PROCESSMGR, "Native child process start failed, but callback is null?"); + return; + } + + TAG_LOGI(AAFwkTag::PROCESSMGR, "Native child process start failed, err %{public}d", errCode); + callback_(errCode, nullptr); +} + +} // namespace AbilityRuntime +} // namespace OHOS diff --git a/frameworks/native/child_process/src/native_child_process.cpp b/frameworks/native/child_process/src/native_child_process.cpp new file mode 100644 index 0000000000..d5036d7b8e --- /dev/null +++ b/frameworks/native/child_process/src/native_child_process.cpp @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "native_child_process.h" +#include +#include +#include "hilog_tag_wrapper.h" +#include "hilog_wrapper.h" +#include "native_child_callback.h" +#include "child_process_manager.h" + +using namespace OHOS; +using namespace OHOS::AbilityRuntime; + +namespace { + +std::mutex g_MutexCallBackObj; +sptr g_CallbackStub; +OH_Ability_OnNativeChildProcessStarted g_Callback = nullptr; + +const std::map CPM_ERRCODE_MAP = { + { ChildProcessManagerErrorCode::ERR_OK, NCP_NOERROR }, + { ChildProcessManagerErrorCode::ERR_MULTI_PROCESS_MODEL_DISABLED, NCP_ERR_MULTI_PROCESS_DISABLED }, + { ChildProcessManagerErrorCode::ERR_ALREADY_IN_CHILD_PROCESS, NCP_ERR_ALREADY_IN_CHILD }, + { ChildProcessManagerErrorCode::ERR_GET_APP_MGR_FAILED, NCP_ERR_SERVICE }, + { ChildProcessManagerErrorCode::ERR_GET_APP_MGR_START_PROCESS_FAILED, NCP_ERR_SERVICE }, + { ChildProcessManagerErrorCode::ERR_UNSUPPORT_NATIVE_CHILD_PROCESS, NCP_ERR_NOT_SUPPORTED }, + { ChildProcessManagerErrorCode::ERR_MAX_NATIVE_CHILD_PROCESSES, NCP_ERR_MAX_CHILD_PROCESSES_REACHED }, + { ChildProcessManagerErrorCode::ERR_NATIVE_CHILD_PROCESS_LOAD_LIB, NCP_ERR_CHILD_PROCESS_LOAD_LIB }, + { ChildProcessManagerErrorCode::ERR_NATIVE_CHILD_PROCESS_CONNECT, NCP_ERR_CHILD_PROCESS_CONNECT }, +}; + +int CvtChildProcessManagerErrCode(ChildProcessManagerErrorCode cpmErr) +{ + auto it = CPM_ERRCODE_MAP.find(cpmErr); + if (it == CPM_ERRCODE_MAP.end()) { + return NCP_ERR_INTERNAL; + } + + return it->second; +} + +void OnNativeChildProcessStartedWapper(int errCode, OHIPCRemoteProxy *ipcProxy) +{ + std::unique_lock autoLock(g_MutexCallBackObj); + if (g_Callback != nullptr) { + g_Callback(CvtChildProcessManagerErrCode(static_cast(errCode)), ipcProxy); + g_Callback = nullptr; + } else { + TAG_LOGW(AAFwkTag::PROCESSMGR, "Remote call twice?"); + } + + g_CallbackStub.clear(); +} + +} // Anonymous namespace + +int OH_Ability_CreateNativeChildProcess(const char* libName, OH_Ability_OnNativeChildProcessStarted onProcessStarted) +{ + if (libName == nullptr || *libName == '\0' || onProcessStarted == nullptr) { + TAG_LOGE(AAFwkTag::PROCESSMGR, "Invalid libname or callback"); + return NCP_ERR_INVALID_PARAM; + } + + std::string strLibName(libName); + if (strLibName.find("../") != std::string::npos) { + TAG_LOGE(AAFwkTag::PROCESSMGR, "Do not allow use relative path"); + return NCP_ERR_INVALID_PARAM; + } + + std::unique_lock autoLock(g_MutexCallBackObj); + if (g_Callback != nullptr || g_CallbackStub != nullptr) { + TAG_LOGW(AAFwkTag::PROCESSMGR, "Another native process process starting, try again later"); + return NCP_ERR_BUSY; + } + + sptr callbackStub(new (std::nothrow) NativeChildCallback(OnNativeChildProcessStartedWapper)); + if (!callbackStub) { + TAG_LOGE(AAFwkTag::PROCESSMGR, "Alloc callback ipc stub object faild."); + return NCP_ERR_INTERNAL; + } + + ChildProcessManager &mgr = ChildProcessManager::GetInstance(); + auto cpmErr = mgr.StartNativeChildProcessByAppSpawnFork(strLibName, callbackStub); + if (cpmErr != ChildProcessManagerErrorCode::ERR_OK) { + return CvtChildProcessManagerErrCode(cpmErr); + } + + g_Callback = onProcessStarted; + g_CallbackStub = callbackStub; + return NCP_NOERROR; +} diff --git a/interfaces/inner_api/app_manager/BUILD.gn b/interfaces/inner_api/app_manager/BUILD.gn index c489963183..09330b5ac3 100644 --- a/interfaces/inner_api/app_manager/BUILD.gn +++ b/interfaces/inner_api/app_manager/BUILD.gn @@ -88,6 +88,8 @@ ohos_shared_library("app_manager") { "src/appmgr/configuration_observer_stub.cpp", "src/appmgr/fault_data.cpp", "src/appmgr/memory_level_info.cpp", + "src/appmgr/native_child_notify_proxy.cpp", + "src/appmgr/native_child_notify_stub.cpp", "src/appmgr/page_state_data.cpp", "src/appmgr/priority_object.cpp", "src/appmgr/process_data.cpp", diff --git a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_interface.h b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_interface.h index 723d2a714b..5bd33cabd4 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_interface.h +++ b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_interface.h @@ -652,6 +652,16 @@ public: } virtual int32_t SetSupportedProcessCacheSelf(bool isSupport) = 0; + + /** + * Start native child process, callde by ChildProcessManager. + * @param libName lib file name to be load in child process + * @param childProcessCount current started child process count + * @param callback callback for notify start result + * @return Returns ERR_OK on success, others on failure. + */ + virtual int32_t StartNativeChildProcess(const std::string &libName, int32_t childProcessCount, + const sptr &callback) = 0; }; } // namespace AppExecFwk } // namespace OHOS diff --git a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_ipc_interface_code.h b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_ipc_interface_code.h index abc01de315..3bf4423786 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_ipc_interface_code.h +++ b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_ipc_interface_code.h @@ -99,6 +99,7 @@ enum class AppMgrInterfaceCode { PRELOAD_APPLICATION = 73, SET_SUPPORTED_PROCESS_CACHE_SELF = 74, APP_GET_RUNNING_PROCESSES_BY_BUNDLE_TYPE = 75, + START_NATIVE_CHILD_PROCESS = 76, }; } // AppExecFwk } // OHOS diff --git a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_proxy.h b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_proxy.h index 3b5c4feebc..0d7b7c98e6 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_proxy.h +++ b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_proxy.h @@ -568,6 +568,17 @@ public: virtual int32_t NotifyMemorySizeStateChanged(bool isMemorySizeSufficent) override; int32_t SetSupportedProcessCacheSelf(bool isSupport) override; + + /** + * Start native child process, callde by ChildProcessManager. + * @param libName lib file name to be load in child process + * @param childProcessCount current started child process count + * @param callback callback for notify start result + * @return Returns ERR_OK on success, others on failure. + */ + int32_t StartNativeChildProcess(const std::string &libName, int32_t childProcessCount, + const sptr &callback) override; + private: bool SendTransactCmd(AppMgrInterfaceCode code, MessageParcel &data, MessageParcel &reply); bool WriteInterfaceToken(MessageParcel &data); diff --git a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_stub.h b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_stub.h index 51de220229..e9a7da927e 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_stub.h +++ b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_stub.h @@ -135,6 +135,7 @@ private: int32_t HandleGetAllUIExtensionProviderPid(MessageParcel &data, MessageParcel &reply); int32_t HandleNotifyMemorySizeStateChanged(MessageParcel &data, MessageParcel &reply); int32_t HandleSetSupportedProcessCacheSelf(MessageParcel &data, MessageParcel &reply); + int32_t HandleStartNativeChildProcess(MessageParcel &data, MessageParcel &reply); using AppMgrFunc = int32_t (AppMgrStub::*)(MessageParcel &data, MessageParcel &reply); std::map memberFuncMap_; diff --git a/interfaces/inner_api/app_manager/include/appmgr/child_process_info.h b/interfaces/inner_api/app_manager/include/appmgr/child_process_info.h index 89b4706190..cb5352d12e 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/child_process_info.h +++ b/interfaces/inner_api/app_manager/include/appmgr/child_process_info.h @@ -22,10 +22,15 @@ namespace OHOS { namespace AppExecFwk { + +constexpr int32_t CHILD_PROCESS_TYPE_JS = 0; +constexpr int32_t CHILD_PROCESS_TYPE_NATIVE = 1; + struct ChildProcessInfo : public Parcelable { std::int32_t pid; std::int32_t hostPid; std::int32_t uid; + std::int32_t processType; std::string bundleName; std::string processName; std::string srcEntry; diff --git a/interfaces/inner_api/app_manager/include/appmgr/child_scheduler_interface.h b/interfaces/inner_api/app_manager/include/appmgr/child_scheduler_interface.h index beaa93d6a9..89fbfc623f 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/child_scheduler_interface.h +++ b/interfaces/inner_api/app_manager/include/appmgr/child_scheduler_interface.h @@ -34,9 +34,16 @@ public: */ virtual bool ScheduleExitProcessSafely() = 0; + /** + * Notify child process run main proc from shared lib. + * @param mainProcessCb Main process callback ipc object + */ + virtual bool ScheduleRunNativeProc(const sptr &mainProcessCb) = 0; + enum class Message { SCHEDULE_LOAD_JS = 0, SCHEDULE_EXIT_PROCESS_SAFELY = 1, + SCHEDULE_RUN_NATIVE_PROC = 2, }; }; } // namespace AppExecFwk diff --git a/interfaces/inner_api/app_manager/include/appmgr/child_scheduler_proxy.h b/interfaces/inner_api/app_manager/include/appmgr/child_scheduler_proxy.h index 355dd1398a..f5cd00d0f1 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/child_scheduler_proxy.h +++ b/interfaces/inner_api/app_manager/include/appmgr/child_scheduler_proxy.h @@ -29,6 +29,7 @@ public: bool ScheduleLoadJs() override; bool ScheduleExitProcessSafely() override; + bool ScheduleRunNativeProc(const sptr &mainProcessCb) override; private: bool WriteInterfaceToken(MessageParcel &data); diff --git a/interfaces/inner_api/app_manager/include/appmgr/child_scheduler_stub.h b/interfaces/inner_api/app_manager/include/appmgr/child_scheduler_stub.h index 6a73ccbf03..a6ecf59dce 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/child_scheduler_stub.h +++ b/interfaces/inner_api/app_manager/include/appmgr/child_scheduler_stub.h @@ -36,6 +36,7 @@ public: private: int32_t HandleScheduleLoadJs(MessageParcel &data, MessageParcel &reply); int32_t HandleScheduleExitProcessSafely(MessageParcel &data, MessageParcel &reply); + int32_t HandleScheduleRunNativeProc(MessageParcel &data, MessageParcel &reply); using ChildSchedulerFunc = int32_t (ChildSchedulerStub::*)(MessageParcel &data, MessageParcel &reply); std::map memberFuncMap_; diff --git a/interfaces/inner_api/app_manager/include/appmgr/native_child_notify_interface.h b/interfaces/inner_api/app_manager/include/appmgr/native_child_notify_interface.h new file mode 100644 index 0000000000..b901b6c107 --- /dev/null +++ b/interfaces/inner_api/app_manager/include/appmgr/native_child_notify_interface.h @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ABILITY_RUNTIME_NATIVE_CHILD_NOTIFY_INTERFACE_H +#define OHOS_ABILITY_RUNTIME_NATIVE_CHILD_NOTIFY_INTERFACE_H + +#include "iremote_broker.h" + +namespace OHOS { +namespace AppExecFwk { + +class INativeChildNotify : public IRemoteBroker { +public: + DECLARE_INTERFACE_DESCRIPTOR(u"ohos.appexecfwk.NativeChildNotify"); + + /** + * Notify native child process started. + * + * @param nativeChild child process ipc object + */ + virtual void OnNativeChildStarted(const sptr &nativeChild) = 0; + + /** + * Notify native child process start failed. + * + * @param errCode failed error code + */ + virtual void OnError(int32_t errCode) = 0; + +protected: + static constexpr uint32_t IPC_ID_ON_NATIVE_CHILD_STARTED = 0; + static constexpr uint32_t IPC_ID_ON_ERROR = 1; +}; + +} // OHOS +} // AppExecFwk + +#endif // OHOS_ABILITY_RUNTIME_NATIVE_CHILD_NOTIFY_INTERFACE_H \ No newline at end of file diff --git a/interfaces/inner_api/app_manager/include/appmgr/native_child_notify_proxy.h b/interfaces/inner_api/app_manager/include/appmgr/native_child_notify_proxy.h new file mode 100644 index 0000000000..fabd51a855 --- /dev/null +++ b/interfaces/inner_api/app_manager/include/appmgr/native_child_notify_proxy.h @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ABILITY_RUNTIME_NATIVE_CHILD_NOTIFY_PROXY_H +#define OHOS_ABILITY_RUNTIME_NATIVE_CHILD_NOTIFY_PROXY_H + +#include "native_child_notify_interface.h" +#include "iremote_proxy.h" + +namespace OHOS { +namespace AppExecFwk { + +class NativeChildNotifyProxy : public IRemoteProxy { +public: + explicit NativeChildNotifyProxy(const sptr &impl); + virtual ~NativeChildNotifyProxy() = default; + + void OnNativeChildStarted(const sptr &nativeChild) override; + void OnError(int32_t errCode) override; + +private: + bool WriteInterfaceToken(MessageParcel &data); + int32_t SendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption& option); + + static inline BrokerDelegator delegator_; +}; + +} // OHOS +} // AppExecFwk + +#endif // OHOS_ABILITY_RUNTIME_NATIVE_CHILD_NOTIFY_PROXY_H \ No newline at end of file diff --git a/interfaces/inner_api/app_manager/include/appmgr/native_child_notify_stub.h b/interfaces/inner_api/app_manager/include/appmgr/native_child_notify_stub.h new file mode 100644 index 0000000000..a77580f3a0 --- /dev/null +++ b/interfaces/inner_api/app_manager/include/appmgr/native_child_notify_stub.h @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ABILITY_RUNTIME_NATIVE_CHILD_NOTIFY_STUB_H +#define OHOS_ABILITY_RUNTIME_NATIVE_CHILD_NOTIFY_STUB_H + +#include "native_child_notify_interface.h" +#include "iremote_stub.h" + +namespace OHOS { +namespace AppExecFwk { + +class NativeChildNotifyStub : public IRemoteStub { +public: + NativeChildNotifyStub() = default; + virtual ~NativeChildNotifyStub() = default; + + int OnRemoteRequest( + uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; + +private: + int32_t HandleOnNativeChildStarted(MessageParcel &data, MessageParcel &reply); + int32_t HandleOnError(MessageParcel &data, MessageParcel &reply); +}; + +} // OHOS +} // AppExecFwk + +#endif // OHOS_ABILITY_RUNTIME_NATIVE_CHILD_NOTIFY_STUB_H \ No newline at end of file diff --git a/interfaces/inner_api/app_manager/src/appmgr/app_mgr_proxy.cpp b/interfaces/inner_api/app_manager/src/appmgr/app_mgr_proxy.cpp index aec1f49eb8..7273f64b0e 100644 --- a/interfaces/inner_api/app_manager/src/appmgr/app_mgr_proxy.cpp +++ b/interfaces/inner_api/app_manager/src/appmgr/app_mgr_proxy.cpp @@ -1989,5 +1989,46 @@ int32_t AppMgrProxy::SetSupportedProcessCacheSelf(bool isSupport) } return reply.ReadInt32(); } + +int32_t AppMgrProxy::StartNativeChildProcess(const std::string &libName, int32_t childProcessCount, + const sptr &callback) +{ + TAG_LOGD(AAFwkTag::APPMGR, "Called."); + if (libName.empty() || !callback) { + TAG_LOGE(AAFwkTag::APPMGR, "Invalid params, libName:%{private}s", libName.c_str()); + return ERR_INVALID_VALUE; + } + + MessageParcel data; + if (!WriteInterfaceToken(data)) { + TAG_LOGE(AAFwkTag::APPMGR, "Write interface token failed."); + return IPC_PROXY_ERR; + } + + if (!data.WriteString(libName)) { + TAG_LOGE(AAFwkTag::APPMGR, "Write lib name failed."); + return IPC_PROXY_ERR; + } + + if (!data.WriteInt32(childProcessCount)) { + TAG_LOGE(AAFwkTag::APPMGR, "Write param childProcessCount failed."); + return IPC_PROXY_ERR; + } + + if (!data.WriteRemoteObject(callback)) { + TAG_LOGE(AAFwkTag::APPMGR, "Write call back ipc object failed."); + return IPC_PROXY_ERR; + } + + MessageParcel reply; + MessageOption option; + auto error = SendRequest(AppMgrInterfaceCode::START_NATIVE_CHILD_PROCESS, data, reply, option); + if (error != NO_ERROR) { + TAG_LOGE(AAFwkTag::APPMGR, "Send request error: %{public}d", error); + return error; + } + return reply.ReadInt32(); +} + } // namespace AppExecFwk } // namespace OHOS diff --git a/interfaces/inner_api/app_manager/src/appmgr/app_mgr_stub.cpp b/interfaces/inner_api/app_manager/src/appmgr/app_mgr_stub.cpp index b1c3946e05..ed1995161a 100644 --- a/interfaces/inner_api/app_manager/src/appmgr/app_mgr_stub.cpp +++ b/interfaces/inner_api/app_manager/src/appmgr/app_mgr_stub.cpp @@ -190,6 +190,8 @@ AppMgrStub::AppMgrStub() &AppMgrStub::HandleSetSupportedProcessCacheSelf; memberFuncMap_[static_cast(AppMgrInterfaceCode::APP_GET_RUNNING_PROCESSES_BY_BUNDLE_TYPE)] = &AppMgrStub::HandleGetRunningProcessesByBundleType; + memberFuncMap_[static_cast(AppMgrInterfaceCode::START_NATIVE_CHILD_PROCESS)] = + &AppMgrStub::HandleStartNativeChildProcess; } AppMgrStub::~AppMgrStub() @@ -1312,5 +1314,21 @@ int32_t AppMgrStub::HandleSetSupportedProcessCacheSelf(MessageParcel &data, Mess } return NO_ERROR; } + +int32_t AppMgrStub::HandleStartNativeChildProcess(MessageParcel &data, MessageParcel &reply) +{ + TAG_LOGD(AAFwkTag::APPMGR, "Called."); + std::string libName = data.ReadString(); + int32_t childCount = data.ReadInt32(); + sptr callback = data.ReadRemoteObject(); + int32_t result = StartNativeChildProcess(libName, childCount, callback); + if (!reply.WriteInt32(result)) { + TAG_LOGE(AAFwkTag::APPMGR, "Write ret error."); + return IPC_STUB_ERR; + } + + return NO_ERROR; +} + } // namespace AppExecFwk } // namespace OHOS diff --git a/interfaces/inner_api/app_manager/src/appmgr/child_process_info.cpp b/interfaces/inner_api/app_manager/src/appmgr/child_process_info.cpp index 490bbe820b..9790eeba07 100644 --- a/interfaces/inner_api/app_manager/src/appmgr/child_process_info.cpp +++ b/interfaces/inner_api/app_manager/src/appmgr/child_process_info.cpp @@ -37,6 +37,8 @@ bool ChildProcessInfo::ReadFromParcel(Parcel &parcel) READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, uidData); uid = static_cast(uidData); + READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, processType); + bundleName = Str16ToStr8(parcel.ReadString16()); processName = Str16ToStr8(parcel.ReadString16()); srcEntry = Str16ToStr8(parcel.ReadString16()); @@ -64,6 +66,7 @@ bool ChildProcessInfo::Marshalling(Parcel &parcel) const WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, static_cast(pid)); WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, static_cast(hostPid)); WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, static_cast(uid)); + WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, static_cast(processType)); WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(bundleName)); WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(processName)); WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(srcEntry)); diff --git a/interfaces/inner_api/app_manager/src/appmgr/child_scheduler_proxy.cpp b/interfaces/inner_api/app_manager/src/appmgr/child_scheduler_proxy.cpp index edf650c809..e14eaa5e71 100644 --- a/interfaces/inner_api/app_manager/src/appmgr/child_scheduler_proxy.cpp +++ b/interfaces/inner_api/app_manager/src/appmgr/child_scheduler_proxy.cpp @@ -84,5 +84,39 @@ bool ChildSchedulerProxy::ScheduleExitProcessSafely() TAG_LOGD(AAFwkTag::APPMGR, "ScheduleExitProcessSafely end."); return true; } + +bool ChildSchedulerProxy::ScheduleRunNativeProc(const sptr &mainProcessCb) +{ + TAG_LOGD(AAFwkTag::APPMGR, "ScheduleRunNativeProc start."); + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_ASYNC); + if (!WriteInterfaceToken(data)) { + TAG_LOGE(AAFwkTag::APPMGR, "Write interface token failed."); + return false; + } + + if (!data.WriteRemoteObject(mainProcessCb)) { + TAG_LOGE(AAFwkTag::APPMGR, "Write main process callback ipc object failed."); + return false; + } + + sptr remote = Remote(); + if (remote == nullptr) { + TAG_LOGE(AAFwkTag::APPMGR, "Remote() is null."); + return false; + } + + int32_t ret = remote->SendRequest( + static_cast(IChildScheduler::Message::SCHEDULE_RUN_NATIVE_PROC), data, reply, option); + if (ret != NO_ERROR) { + TAG_LOGE(AAFwkTag::APPMGR, "SendRequest is failed, error code: %{public}d.", ret); + return false; + } + + TAG_LOGD(AAFwkTag::APPMGR, "ScheduleRunNativeProc end."); + return true; +} + } // namespace AppExecFwk } // namespace OHOS diff --git a/interfaces/inner_api/app_manager/src/appmgr/child_scheduler_stub.cpp b/interfaces/inner_api/app_manager/src/appmgr/child_scheduler_stub.cpp index 1fda7ab84c..b434032513 100644 --- a/interfaces/inner_api/app_manager/src/appmgr/child_scheduler_stub.cpp +++ b/interfaces/inner_api/app_manager/src/appmgr/child_scheduler_stub.cpp @@ -27,6 +27,8 @@ ChildSchedulerStub::ChildSchedulerStub() &ChildSchedulerStub::HandleScheduleLoadJs; memberFuncMap_[static_cast(IChildScheduler::Message::SCHEDULE_EXIT_PROCESS_SAFELY)] = &ChildSchedulerStub::HandleScheduleExitProcessSafely; + memberFuncMap_[static_cast(IChildScheduler::Message::SCHEDULE_RUN_NATIVE_PROC)] = + &ChildSchedulerStub::HandleScheduleRunNativeProc; } ChildSchedulerStub::~ChildSchedulerStub() @@ -68,5 +70,13 @@ int32_t ChildSchedulerStub::HandleScheduleExitProcessSafely(MessageParcel &data, ScheduleExitProcessSafely(); return ERR_NONE; } + +int32_t ChildSchedulerStub::HandleScheduleRunNativeProc(MessageParcel &data, MessageParcel &reply) +{ + sptr cb = data.ReadRemoteObject(); + ScheduleRunNativeProc(cb); + return ERR_NONE; +} + } // namespace AppExecFwk } // namespace OHOS \ No newline at end of file diff --git a/interfaces/inner_api/app_manager/src/appmgr/native_child_notify_proxy.cpp b/interfaces/inner_api/app_manager/src/appmgr/native_child_notify_proxy.cpp new file mode 100644 index 0000000000..e97ec17658 --- /dev/null +++ b/interfaces/inner_api/app_manager/src/appmgr/native_child_notify_proxy.cpp @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "native_child_notify_proxy.h" +#include "hilog_tag_wrapper.h" +#include "hilog_wrapper.h" +#include "ipc_types.h" + +namespace OHOS { +namespace AppExecFwk { + +NativeChildNotifyProxy::NativeChildNotifyProxy(const sptr &impl) + : IRemoteProxy(impl) +{ +} + +bool NativeChildNotifyProxy::WriteInterfaceToken(MessageParcel &data) +{ + if (!data.WriteInterfaceToken(NativeChildNotifyProxy::GetDescriptor())) { + TAG_LOGE(AAFwkTag::APPMGR, "NativeChildNotifyProxy write interface token failed"); + return false; + } + + return true; +} + +int32_t NativeChildNotifyProxy::SendRequest(uint32_t code, MessageParcel &data, + MessageParcel &reply, MessageOption& option) +{ + sptr remote = Remote(); + if (!remote) { + TAG_LOGE(AAFwkTag::APPMGR, "NativeChildNotifyProxy get remote object failed"); + return ERR_NULL_OBJECT; + } + + int32_t ret = remote->SendRequest(code, data, reply, option); + if (ret != NO_ERROR) { + TAG_LOGE(AAFwkTag::APPMGR, "NativeChildNotifyProxy SendRequest failed(%{public}d)", ret); + return ret; + } + + return NO_ERROR; +} + +void NativeChildNotifyProxy::OnNativeChildStarted(const sptr &nativeChild) +{ + TAG_LOGD(AAFwkTag::APPMGR, "NativeChildNotifyProxy OnNativeChildStarted"); + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_ASYNC); + if (!WriteInterfaceToken(data)) { + return; + } + + if (!data.WriteRemoteObject(nativeChild)) { + TAG_LOGE(AAFwkTag::APPMGR, "NativeChildNotifyProxy write native child ipc object failed."); + return; + } + + SendRequest(INativeChildNotify::IPC_ID_ON_NATIVE_CHILD_STARTED, data, reply, option); +} + +void NativeChildNotifyProxy::OnError(int32_t errCode) +{ + TAG_LOGD(AAFwkTag::APPMGR, "NativeChildNotifyProxy OnError(%{public}d)", errCode); + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_ASYNC); + if (!WriteInterfaceToken(data)) { + return; + } + + if (!data.WriteInt32(errCode)) { + TAG_LOGE(AAFwkTag::APPMGR, "NativeChildNotifyProxy write error code failed."); + return; + } + + SendRequest(INativeChildNotify::IPC_ID_ON_ERROR, data, reply, option); +} + +} // OHOS +} // AppExecFwk \ No newline at end of file diff --git a/interfaces/inner_api/app_manager/src/appmgr/native_child_notify_stub.cpp b/interfaces/inner_api/app_manager/src/appmgr/native_child_notify_stub.cpp new file mode 100644 index 0000000000..63ad1fb4e2 --- /dev/null +++ b/interfaces/inner_api/app_manager/src/appmgr/native_child_notify_stub.cpp @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "native_child_notify_stub.h" +#include "hilog_tag_wrapper.h" +#include "hilog_wrapper.h" +#include "ipc_types.h" + +namespace OHOS { +namespace AppExecFwk { + +int NativeChildNotifyStub::OnRemoteRequest(uint32_t code, MessageParcel &data, + MessageParcel &reply, MessageOption &option) +{ + TAG_LOGD(AAFwkTag::APPMGR, "NativeChildNotifyStub::OnRemoteRequest, code=%{public}u, flags=%{public}d.", + code, option.GetFlags()); + std::u16string descriptor = NativeChildNotifyStub::GetDescriptor(); + std::u16string remoteDesc = data.ReadInterfaceToken(); + if (descriptor != remoteDesc) { + TAG_LOGE(AAFwkTag::APPMGR, "A local descriptor is not equivalent to a remote"); + return ERR_INVALID_STATE; + } + + int32_t ret; + switch (code) { + case INativeChildNotify::IPC_ID_ON_NATIVE_CHILD_STARTED: + ret = HandleOnNativeChildStarted(data, reply); + break; + + case INativeChildNotify::IPC_ID_ON_ERROR: + ret = HandleOnError(data, reply); + break; + + default: + TAG_LOGW(AAFwkTag::APPMGR, "NativeChildNotifyStub Unknow ipc call(%{public}u)", code); + ret = IPCObjectStub::OnRemoteRequest(code, data, reply, option); + break; + } + + TAG_LOGD(AAFwkTag::APPMGR, "NativeChildNotifyStub::OnRemoteRequest end"); + return ret; +} + +int32_t NativeChildNotifyStub::HandleOnNativeChildStarted(MessageParcel &data, MessageParcel &reply) +{ + sptr cb = data.ReadRemoteObject(); + OnNativeChildStarted(cb); + return ERR_NONE; +} + +int32_t NativeChildNotifyStub::HandleOnError(MessageParcel &data, MessageParcel &reply) +{ + int32_t err = data.ReadInt32(); + OnError(err); + return ERR_NONE; +} + +} // OHOS +} // AppExecFwk diff --git a/interfaces/inner_api/child_process_manager/BUILD.gn b/interfaces/inner_api/child_process_manager/BUILD.gn index e9bd88528e..bbd9caaebe 100644 --- a/interfaces/inner_api/child_process_manager/BUILD.gn +++ b/interfaces/inner_api/child_process_manager/BUILD.gn @@ -32,6 +32,7 @@ ohos_shared_library("child_process_manager") { "${ability_runtime_native_path}/ability/native/child_process_manager/child_process_manager.cpp", "${ability_runtime_native_path}/ability/native/child_process_manager/child_process_manager_error_utils.cpp", "${ability_runtime_native_path}/ability/native/child_process_manager/js_child_process.cpp", + "${ability_runtime_native_path}/ability/native/child_process_manager/native_child_ipc_process.cpp", ] deps = [ @@ -50,6 +51,7 @@ ohos_shared_library("child_process_manager") { "eventhandler:libeventhandler", "hilog:libhilog", "init:libbegetutil", + "ipc:ipc_capi", "ipc:ipc_core", "napi:ace_napi", "samgr:samgr_proxy", diff --git a/interfaces/inner_api/child_process_manager/include/child_process_manager.h b/interfaces/inner_api/child_process_manager/include/child_process_manager.h index 3bf2137fe4..f9fbf3c654 100644 --- a/interfaces/inner_api/child_process_manager/include/child_process_manager.h +++ b/interfaces/inner_api/child_process_manager/include/child_process_manager.h @@ -25,6 +25,7 @@ #include "child_process_manager_error_utils.h" #include "hap_module_info.h" #include "runtime.h" +#include "iremote_object.h" namespace OHOS { namespace AbilityRuntime { @@ -41,12 +42,15 @@ public: bool IsChildProcess(); ChildProcessManagerErrorCode StartChildProcessBySelfFork(const std::string &srcEntry, pid_t &pid); ChildProcessManagerErrorCode StartChildProcessByAppSpawnFork(const std::string &srcEntry, pid_t &pid); + ChildProcessManagerErrorCode StartNativeChildProcessByAppSpawnFork( + const std::string &libName, const sptr &callbackStub); bool GetBundleInfo(AppExecFwk::BundleInfo &bundleInfo); bool GetHapModuleInfo(const AppExecFwk::BundleInfo &bundleInfo, AppExecFwk::HapModuleInfo &hapModuleInfo); std::unique_ptr CreateRuntime(const AppExecFwk::BundleInfo &bundleInfo, const AppExecFwk::HapModuleInfo &hapModuleInfo, const bool fromAppSpawn, const bool jitEnabled); bool LoadJsFile(const std::string &srcEntry, const AppExecFwk::HapModuleInfo &hapModuleInfo, std::unique_ptr &runtime); + bool LoadNativeLib(const std::string &libPath, const sptr &mainProcessCb); void SetForkProcessJITEnabled(bool jitEnabled); void SetForkProcessDebugOption(const std::string bundleName, const bool isStartWithDebug, const bool isDebugApp, const bool isStartWithNative); @@ -55,6 +59,7 @@ private: ChildProcessManager(); ChildProcessManagerErrorCode PreCheck(); + ChildProcessManagerErrorCode PreCheckNativeProcess(); void RegisterSignal(); void HandleChildProcessBySelfFork(const std::string &srcEntry, const AppExecFwk::BundleInfo &bundleInfo); bool hasChildProcessRecord(); diff --git a/interfaces/inner_api/child_process_manager/include/child_process_manager_error_utils.h b/interfaces/inner_api/child_process_manager/include/child_process_manager_error_utils.h index 3bd4893d87..18c572d1ea 100644 --- a/interfaces/inner_api/child_process_manager/include/child_process_manager_error_utils.h +++ b/interfaces/inner_api/child_process_manager/include/child_process_manager_error_utils.h @@ -31,6 +31,10 @@ enum class ChildProcessManagerErrorCode { ERR_GET_BUNDLE_INFO_FAILED = 5, ERR_GET_APP_MGR_FAILED = 6, ERR_GET_APP_MGR_START_PROCESS_FAILED = 7, + ERR_UNSUPPORT_NATIVE_CHILD_PROCESS = 8, + ERR_MAX_NATIVE_CHILD_PROCESSES = 9, + ERR_NATIVE_CHILD_PROCESS_LOAD_LIB = 10, + ERR_NATIVE_CHILD_PROCESS_CONNECT = 11, }; const std::map INTERNAL_ERR_CODE_MAP = { diff --git a/interfaces/inner_api/child_process_manager/include/child_process_start_info.h b/interfaces/inner_api/child_process_manager/include/child_process_start_info.h index 75cbfabd60..07828eae1b 100644 --- a/interfaces/inner_api/child_process_manager/include/child_process_start_info.h +++ b/interfaces/inner_api/child_process_manager/include/child_process_start_info.h @@ -17,6 +17,7 @@ #define OHOS_ABILITY_RUNTIME_CHILD_PROCESS_START_INFO_H #include +#include "iremote_object.h" namespace OHOS { namespace AbilityRuntime { @@ -26,6 +27,7 @@ struct ChildProcessStartInfo { std::string srcEntry; std::string hapPath; bool isEsModule = true; + sptr ipcObj; }; } // namespace AbilityRuntime } // namespace OHOS diff --git a/interfaces/inner_api/child_process_manager/include/native_child_ipc_process.h b/interfaces/inner_api/child_process_manager/include/native_child_ipc_process.h new file mode 100644 index 0000000000..5a007069e8 --- /dev/null +++ b/interfaces/inner_api/child_process_manager/include/native_child_ipc_process.h @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ABILITY_RUNTIME_NATIVE_CHILD_IPC_PROCESS_H +#define OHOS_ABILITY_RUNTIME_NATIVE_CHILD_IPC_PROCESS_H + +#include +#include "child_process.h" +#include "native_child_notify_interface.h" +#include "ipc_inner_object.h" + +namespace OHOS { +namespace AbilityRuntime { + +class NativeChildIpcProcess : public ChildProcess { +public: + NativeChildIpcProcess() = default; + ~NativeChildIpcProcess(); + + static std::shared_ptr Create(); + + bool Init(const std::shared_ptr &info) override; + void OnStart() override; + +private: + bool LoadNativeLib(const std::shared_ptr &info); + void UnloadNativeLib(); + + typedef OHIPCRemoteStub* (*NativeChildProcess_OnConnect)(); + typedef void (*NativeChildProcess_MainProc)(); + + sptr mainProcessCb_; + void *nativeLibHandle_ = nullptr; + NativeChildProcess_OnConnect funcNativeLibOnConnect_ = nullptr; + NativeChildProcess_MainProc funcNativeLibMainProc_ = nullptr; +}; + +} // namespace AbilityRuntime +} // namespace OHOS + +#endif // OHOS_ABILITY_RUNTIME_NATIVE_CHILD_IPC_PROCESS_H \ No newline at end of file diff --git a/interfaces/kits/c/ability/ability_runtime/child_process/native_child_process.h b/interfaces/kits/c/ability/ability_runtime/child_process/native_child_process.h new file mode 100644 index 0000000000..85301c6a59 --- /dev/null +++ b/interfaces/kits/c/ability/ability_runtime/child_process/native_child_process.h @@ -0,0 +1,144 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_C_ABILITY_RUNTIME_NATIVE_CHILD_PROCESS_H +#define OHOS_C_ABILITY_RUNTIME_NATIVE_CHILD_PROCESS_H + +#include "ipc_cparcel.h" + +/** + * @file native_child_process.h + * + * @brief Defines the functions for native child process management. + * @library libchild_process.so + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @since 12 + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief native child process error code + * @since 12 + */ +enum Ability_NativeChildProcess_ErrCode { + /** + * @error The operation completed successfully + */ + NCP_NOERROR = 0, + + /** + * @error Invalid param + */ + NCP_ERR_INVALID_PARAM = 401, + + /** + * @error Unsupport start native process + */ + NCP_ERR_NOT_SUPPORTED = 801, + + /** + * @error Internal error + */ + NCP_ERR_INTERNAL = 16000050, + + /** + * @error Can not start another during child process startup, try again after current child process started + */ + NCP_ERR_BUSY = 16010001, + + /** + * @error Start native child time out + */ + NCP_ERR_TIMEOUT = 16010002, + + /** + * @error Service process error + */ + NCP_ERR_SERVICE = 16010003, + + /** + * @error Multi process disabled, can not start child process + */ + NCP_ERR_MULTI_PROCESS_DISABLED = 16010004, + + /** + * @error Already in child process, only main process can start child + */ + NCP_ERR_ALREADY_IN_CHILD = 16010005, + + /** + * @error Max native child processes reached, can not start another + */ + NCP_ERR_MAX_CHILD_PROCESSES_REACHED = 16010006, + + /** + * @error Child process load library failed + */ + NCP_ERR_CHILD_PROCESS_LOAD_LIB = 16010007, + + /** + * @error Faild to invoke OnConnect method in library + */ + NCP_ERR_CHILD_PROCESS_CONNECT = 16010008, +}; + + +/** + * @brief callback function for notify the child process start result, see OH_Ability_CreateNativeChildProcess + * + * @param errCode Zero if successful, an error otherwise, see Ability_NativeChildProcess_ErrCode for detail + * @param remoteProxy IPC object implemented in the sharded lib loaded by child process; will be nullptr when failed + * @since 12 + */ +typedef void (*OH_Ability_OnNativeChildProcessStarted)(int errCode, OHIPCRemoteProxy *remoteProxy); + +/** + * @brief Create native child process for app and load shared library specified by param, + * process startup result is asynchronously notified via callback + * Lib file must be implemented and exported follow functions: + * 1. OHIPCRemoteStub* NativeChildProcess_OnConnect() + * 2. void NativeChildProcess_MainProc() + * + * Processing logic be like follows: + * Main Process: + * 1. Call OH_Ability_CreateNativeChildProcess(libName, onProcessStartedCallback) + * Child Process: + * 2. dlopen(libName) + * 3. dlsym("NativeChildProcess_OnConnect") & dlsym("NativeChildProcess_MainProc") + * 4. ipcRemote = NativeChildProcess_OnConnect() + * 5. NativeChildProcess_MainProc() + * Main Process: + * 6. onProcessStartedCallback(ipcRemote, errCode) + * Child Process: + * 7. Process exit after NativeChildProcess_MainProc() method returned + * + * @param libName Name of the library file loaded by child process, can not be nullptr + * @param onProcessStarted Callback for notify the child process start result + * @return Zero if successful, an error otherwise, see Ability_NativeChildProcess_ErrCode for detail + * @see OH_Ability_OnNativeChildProcessStarted + * @since 12 + */ +int OH_Ability_CreateNativeChildProcess(const char* libName, + OH_Ability_OnNativeChildProcessStarted onProcessStarted); + + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // OHOS_C_ABILITY_RUNTIME_NATIVE_CHILD_PROCESS_H diff --git a/interfaces/kits/native/appkit/app/child_main_thread.h b/interfaces/kits/native/appkit/app/child_main_thread.h index ca6d337866..73a1abf9de 100644 --- a/interfaces/kits/native/appkit/app/child_main_thread.h +++ b/interfaces/kits/native/appkit/app/child_main_thread.h @@ -39,6 +39,7 @@ public: static void Start(const ChildProcessInfo &processInfo); bool ScheduleLoadJs() override; bool ScheduleExitProcessSafely() override; + bool ScheduleRunNativeProc(const sptr &mainProcessCb) override; private: bool Init(const std::shared_ptr &runner, const ChildProcessInfo &processInfo); @@ -49,6 +50,8 @@ private: void ExitProcessSafely(); void GetNativeLibPath(const BundleInfo &bundleInfo, AppLibPathMap &appLibPaths); void GetHapSoPath(const HapModuleInfo &hapInfo, AppLibPathMap &appLibPaths, bool isPreInstallApp); + void HandleRunNativeProc(const sptr &mainProcessCb); + void UpdateNativeChildLibPath(const AppLibPathMap &appLibPaths); std::string GetLibPath(const std::string &hapPath, bool isPreInstallApp); sptr appMgr_ = nullptr; diff --git a/services/appmgr/include/app_mgr_service.h b/services/appmgr/include/app_mgr_service.h index 8d16a88ba9..397362bf81 100644 --- a/services/appmgr/include/app_mgr_service.h +++ b/services/appmgr/include/app_mgr_service.h @@ -503,6 +503,17 @@ public: int32_t NotifyMemorySizeStateChanged(bool isMemorySizeSufficent) override; int32_t SetSupportedProcessCacheSelf(bool isSupport) override; + + /** + * Start native child process, callde by ChildProcessManager. + * @param libName lib file name to be load in child process + * @param childProcessCount current started child process count + * @param callback callback for notify start result + * @return Returns ERR_OK on success, others on failure. + */ + int32_t StartNativeChildProcess(const std::string &libName, int32_t childProcessCount, + const sptr &callback) override; + private: /** * Init, Initialize application services. diff --git a/services/appmgr/include/app_mgr_service_inner.h b/services/appmgr/include/app_mgr_service_inner.h index cd7138a8f9..874feb29af 100644 --- a/services/appmgr/include/app_mgr_service_inner.h +++ b/services/appmgr/include/app_mgr_service_inner.h @@ -995,6 +995,17 @@ public: */ virtual void ExitChildProcessSafelyByChildPid(const pid_t pid); + /** + * Start native child process, callde by ChildProcessManager. + * @param hostPid Host process pid. + * @param childProcessCount current started child process count + * @param libName lib file name to be load in child process + * @param callback callback for notify start result + * @return Returns ERR_OK on success, others on failure. + */ + virtual int32_t StartNativeChildProcess(const pid_t hostPid, + const std::string &libName, int32_t childProcessCount, const sptr &callback); + /** * Whether the current application process is the last surviving process. * @param bundleName To query the bundle name of a process. diff --git a/services/appmgr/include/child_process_record.h b/services/appmgr/include/child_process_record.h index bb3565a946..dd3690b9e2 100644 --- a/services/appmgr/include/child_process_record.h +++ b/services/appmgr/include/child_process_record.h @@ -22,6 +22,7 @@ #include "app_death_recipient.h" #include "child_scheduler_interface.h" +#include "child_process_info.h" namespace OHOS { namespace AppExecFwk { @@ -31,10 +32,15 @@ class ChildProcessRecord { public: ChildProcessRecord(pid_t hostPid, const std::string &srcEntry, const std::shared_ptr hostRecord, int32_t childProcessCount, bool isStartWithDebug); + ChildProcessRecord(pid_t hostPid, const std::string &libName, const std::shared_ptr hostRecord, + const sptr &mainProcessCb, int32_t childProcessCount, bool isStartWithDebug); virtual ~ChildProcessRecord(); static std::shared_ptr CreateChildProcessRecord(pid_t hostPid, const std::string &srcEntry, const std::shared_ptr hostRecord, int32_t childProcessCount, bool isStartWithDebug); + static std::shared_ptr CreateNativeChildProcessRecord(pid_t hostPid, const std::string &libName, + const std::shared_ptr hostRecord, const sptr &mainProcessCb, + int32_t childProcessCount, bool isStartWithDebug); void SetPid(pid_t pid); pid_t GetPid() const; @@ -51,6 +57,9 @@ public: void RemoveDeathRecipient(); void ScheduleExitProcessSafely(); bool isStartWithDebug(); + int32_t GetProcessType() const; + sptr GetMainProcessCallback() const; + void ClearMainProcessCallback(); private: void MakeProcessName(const std::shared_ptr hostRecord); @@ -58,11 +67,13 @@ private: pid_t hostPid_ = 0; int32_t uid_ = 0; int32_t childProcessCount_ = 0; + int32_t childProcessType_ = CHILD_PROCESS_TYPE_JS; std::string processName_; std::string srcEntry_; std::weak_ptr hostRecord_; sptr scheduler_ = nullptr; sptr deathRecipient_ = nullptr; + sptr mainProcessCb_ = nullptr; bool isStartWithDebug_; }; } // namespace AppExecFwk diff --git a/services/appmgr/src/app_mgr_service.cpp b/services/appmgr/src/app_mgr_service.cpp index 03ed44a33f..bb007b78fe 100644 --- a/services/appmgr/src/app_mgr_service.cpp +++ b/services/appmgr/src/app_mgr_service.cpp @@ -1441,5 +1441,19 @@ int32_t AppMgrService::SetSupportedProcessCacheSelf(bool isSupport) } return appMgrServiceInner_->SetSupportedProcessCacheSelf(isSupport); } + +int32_t AppMgrService::StartNativeChildProcess(const std::string &libName, int32_t childProcessCount, + const sptr &callback) +{ + TAG_LOGI(AAFwkTag::APPMGR, "Called"); + if (!IsReady()) { + TAG_LOGE(AAFwkTag::APPMGR, "Not ready."); + return ERR_INVALID_OPERATION; + } + + return appMgrServiceInner_->StartNativeChildProcess( + IPCSkeleton::GetCallingPid(), libName, childProcessCount, callback); +} + } // namespace AppExecFwk } // namespace OHOS diff --git a/services/appmgr/src/app_mgr_service_inner.cpp b/services/appmgr/src/app_mgr_service_inner.cpp index a23bc16617..273ab73f22 100644 --- a/services/appmgr/src/app_mgr_service_inner.cpp +++ b/services/appmgr/src/app_mgr_service_inner.cpp @@ -5896,6 +5896,7 @@ int32_t AppMgrServiceInner::GetChildProcessInfo(const std::shared_ptrGetPid(); info.hostPid = childProcessRecord->GetHostPid(); info.uid = childProcessRecord->GetUid(); + info.processType = childProcessRecord->GetProcessType(); info.bundleName = appRecord->GetBundleName(); info.processName = childProcessRecord->GetProcessName(); info.srcEntry = childProcessRecord->GetSrcEntry(); @@ -5944,7 +5945,12 @@ void AppMgrServiceInner::AttachChildProcess(const pid_t pid, const sptrSetDeathRecipient(appDeathRecipient); childRecord->RegisterDeathRecipient(); - childScheduler->ScheduleLoadJs(); + if (childRecord->GetProcessType() != CHILD_PROCESS_TYPE_NATIVE) { + childScheduler->ScheduleLoadJs(); + } else { + childScheduler->ScheduleRunNativeProc(childRecord->GetMainProcessCallback()); + childRecord->ClearMainProcessCallback(); + } } void AppMgrServiceInner::OnChildProcessRemoteDied(const wptr &remote) @@ -6539,5 +6545,48 @@ void AppMgrServiceInner::OnAppCacheStateChanged(const std::shared_ptr::GetInstance()->OnAppCacheStateChanged(appRecord); } + +int32_t AppMgrServiceInner::StartNativeChildProcess(const pid_t hostPid, const std::string &libName, + int32_t childProcessCount, const sptr &callback) +{ + TAG_LOGI(AAFwkTag::APPMGR, "StartNativeChildProcess, hostPid:%{public}d", hostPid); + if (hostPid <= 0 || libName.empty() || !callback) { + TAG_LOGE(AAFwkTag::APPMGR, "Invalid param: hostPid:%{public}d libName:%{private}s", + hostPid, libName.c_str()); + return ERR_INVALID_VALUE; + } + + if (!AAFwk::AppUtils::GetInstance().IsSupportNativeChildProcess()) { + TAG_LOGE(AAFwkTag::APPMGR, "Unsupport native child process"); + return ERR_INVALID_OPERATION; + } + + int32_t errCode = StartChildProcessPreCheck(hostPid); + if (errCode != ERR_OK) { + return errCode; + } + + auto appRecord = GetAppRunningRecordByPid(hostPid); + if (!appRecord) { + TAG_LOGI(AAFwkTag::APPMGR, "Get app runnning record(hostPid:%{public}d) failed.", hostPid); + return ERR_INVALID_OPERATION; + } + + auto childRecordMap = appRecord->GetChildProcessRecordMap(); + auto itNativeChildInfo = find_if(childRecordMap.begin(), childRecordMap.end(), [] (const auto &pair) -> bool { + return pair.second->GetProcessType() == CHILD_PROCESS_TYPE_NATIVE; + }); + + if (itNativeChildInfo != childRecordMap.end()) { + TAG_LOGI(AAFwkTag::APPMGR, "Native child process still alive(hostPid:%{public}d childPid:%{public}d)", + hostPid, itNativeChildInfo->second->GetPid()); + return ERR_OVERFLOW; + } + + pid_t dummyChildPid = 0; + auto nativeChildRecord = ChildProcessRecord::CreateNativeChildProcessRecord( + hostPid, libName, appRecord, callback, childProcessCount, false); + return StartChildProcessImpl(nativeChildRecord, appRecord, dummyChildPid); +} } // namespace AppExecFwk -} // namespace OHOS +} // namespace OHOS \ No newline at end of file diff --git a/services/appmgr/src/child_process_record.cpp b/services/appmgr/src/child_process_record.cpp index 2bf2e9f341..a5a3b9d828 100644 --- a/services/appmgr/src/child_process_record.cpp +++ b/services/appmgr/src/child_process_record.cpp @@ -29,6 +29,15 @@ ChildProcessRecord::ChildProcessRecord(pid_t hostPid, const std::string &srcEntr MakeProcessName(hostRecord); } +ChildProcessRecord::ChildProcessRecord(pid_t hostPid, const std::string &libName, + const std::shared_ptr hostRecord, const sptr &mainProcessCb, + int32_t childProcessCount, bool isStartWithDebug) + : hostPid_(hostPid), childProcessCount_(childProcessCount), childProcessType_(CHILD_PROCESS_TYPE_NATIVE), + srcEntry_(libName), hostRecord_(hostRecord), mainProcessCb_(mainProcessCb), isStartWithDebug_(isStartWithDebug) +{ + MakeProcessName(hostRecord); +} + ChildProcessRecord::~ChildProcessRecord() { TAG_LOGD(AAFwkTag::APPMGR, "Called."); @@ -46,6 +55,19 @@ std::shared_ptr ChildProcessRecord::CreateChildProcessRecord return std::make_shared(hostPid, srcEntry, hostRecord, childProcessCount, isStartWithDebug); } +std::shared_ptr ChildProcessRecord::CreateNativeChildProcessRecord( + pid_t hostPid, const std::string &libName, const std::shared_ptr hostRecord, + const sptr &mainProcessCb, int32_t childProcessCount, bool isStartWithDebug) +{ + TAG_LOGD(AAFwkTag::APPMGR, "hostPid: %{public}d, libName: %{public}s", hostPid, libName.c_str()); + if (hostPid <= 0 || libName.empty() || !hostRecord || !mainProcessCb) { + TAG_LOGE(AAFwkTag::APPMGR, "Invalid parameter."); + return nullptr; + } + return std::make_shared(hostPid, libName, hostRecord, mainProcessCb, + childProcessCount, isStartWithDebug); +} + void ChildProcessRecord::SetPid(pid_t pid) { pid_ = pid; @@ -148,6 +170,10 @@ void ChildProcessRecord::MakeProcessName(const std::shared_ptr std::string filename = std::filesystem::path(srcEntry_).stem(); if (!filename.empty()) { processName_.append(":"); + if (childProcessType_ == CHILD_PROCESS_TYPE_NATIVE) { + processName_.append("Native_"); + } + processName_.append(filename); } processName_.append(std::to_string(childProcessCount_)); @@ -158,5 +184,21 @@ bool ChildProcessRecord::isStartWithDebug() { return isStartWithDebug_; } + +int32_t ChildProcessRecord::GetProcessType() const +{ + return childProcessType_; +} + +sptr ChildProcessRecord::GetMainProcessCallback() const +{ + return mainProcessCb_; +} + +void ChildProcessRecord::ClearMainProcessCallback() +{ + mainProcessCb_.clear(); +} + } // namespace AppExecFwk } // namespace OHOS diff --git a/services/common/BUILD.gn b/services/common/BUILD.gn index 42c58bcd42..451de687bc 100644 --- a/services/common/BUILD.gn +++ b/services/common/BUILD.gn @@ -30,6 +30,7 @@ config("common_config") { "${ability_runtime_innerkits_path}/*", "${ability_runtime_napi_path}/*", "${ability_runtime_native_path}/ability/native/*", + "${ability_runtime_native_path}/child_process/*", "${ability_runtime_path}/frameworks/simulator/ability_simulator/*", "${ability_runtime_path}/tools/aa/*", "${ability_runtime_services_path}/common/*", diff --git a/services/common/include/app_utils.h b/services/common/include/app_utils.h index b1203d9394..509ab97bbf 100644 --- a/services/common/include/app_utils.h +++ b/services/common/include/app_utils.h @@ -47,6 +47,7 @@ public: bool IsStartOptionsWithProcessOptions(); bool EnableMoveUIAbilityToBackgroundApi(); bool IsLaunchEmbededUIAbility(); + bool IsSupportNativeChildProcess(); private: AppUtils(); @@ -65,6 +66,7 @@ private: volatile DeviceConfiguration isStartOptionsWithProcessOptions_ = {false, false}; volatile DeviceConfiguration enableMoveUIAbilityToBackgroundApi_ = {false, true}; volatile DeviceConfiguration isLaunchEmbededUIAbility_ = {false, false}; + volatile DeviceConfiguration isSupportNativeChildProcess_ = {false, false}; DISALLOW_COPY_AND_MOVE(AppUtils); }; } // namespace AAFwk diff --git a/services/common/src/app_utils.cpp b/services/common/src/app_utils.cpp index 7d47ade7dd..a044a0620e 100644 --- a/services/common/src/app_utils.cpp +++ b/services/common/src/app_utils.cpp @@ -41,7 +41,9 @@ const std::string START_OPTIONS_WITH_PROCESS_OPTION = "persist.sys.abilityms.sta const std::string MOVE_UI_ABILITY_TO_BACKGROUND_API_ENABLE = "persist.sys.abilityms.move_ui_ability_to_background_api_enable"; const std::string LAUNCH_EMBEDED_UI_ABILITY = "const.abilityms.launch_embeded_ui_ability"; +const std::string SUPPROT_NATIVE_CHILD_PROCESS = "persist.sys.abilityms.start_native_child_process"; } + AppUtils::~AppUtils() {} AppUtils::AppUtils() @@ -207,5 +209,16 @@ bool AppUtils::IsLaunchEmbededUIAbility() TAG_LOGI(AAFwkTag::DEFAULT, "isLaunchEmbededUIAbility_ is %{public}d", isLaunchEmbededUIAbility_.value); return isLaunchEmbededUIAbility_.value; } + +bool AppUtils::IsSupportNativeChildProcess() +{ + if (!isSupportNativeChildProcess_.isLoaded) { + isSupportNativeChildProcess_.value = system::GetBoolParameter(SUPPROT_NATIVE_CHILD_PROCESS, false); + isSupportNativeChildProcess_.isLoaded = true; + } + TAG_LOGI(AAFwkTag::DEFAULT, "isSupportNativeChildProcess_ is %{public}d", isSupportNativeChildProcess_.value); + return isSupportNativeChildProcess_.value; +} + } // namespace AAFwk } // namespace OHOS diff --git a/test/mock/frameworks_kits_appkit_test/include/mock_app_mgr_service.h b/test/mock/frameworks_kits_appkit_test/include/mock_app_mgr_service.h index fac765766e..4bdd670d5b 100644 --- a/test/mock/frameworks_kits_appkit_test/include/mock_app_mgr_service.h +++ b/test/mock/frameworks_kits_appkit_test/include/mock_app_mgr_service.h @@ -84,6 +84,8 @@ public: MOCK_METHOD1(UnregisterRenderStateObserver, int32_t(const sptr &observer)); MOCK_METHOD2(UpdateRenderState, int32_t(pid_t renderPid, int32_t state)); MOCK_METHOD1(SetSupportedProcessCacheSelf, int32_t(bool isSupported)); + MOCK_METHOD3(StartNativeChildProcess, int32_t(const std::string &libName, int32_t childProcessCount, + const sptr &callback)); void AttachApplication(const sptr& app) { diff --git a/test/mock/mock_appmgr_service/include/mock_app_mgr_service_inner.h b/test/mock/mock_appmgr_service/include/mock_app_mgr_service_inner.h index 88b8e33737..12e5464304 100644 --- a/test/mock/mock_appmgr_service/include/mock_app_mgr_service_inner.h +++ b/test/mock/mock_appmgr_service/include/mock_app_mgr_service_inner.h @@ -65,6 +65,8 @@ public: int32_t childProcessCount, bool inStartWithDebug)); MOCK_METHOD1(GetChildProcessInfoForSelf, int32_t(ChildProcessInfo &info)); MOCK_METHOD4(PreloadApplication, int32_t(const std::string&, int32_t, AppExecFwk::PreloadMode, int32_t)); + MOCK_METHOD4(StartNativeChildProcess, int32_t(const pid_t hostPid, const std::string &libName, + int32_t childProcessCount, const sptr &callback)); void StartSpecifiedAbility(const AAFwk::Want&, const AppExecFwk::AbilityInfo&, int32_t) {} diff --git a/test/mock/services_appmgr_test/include/mock_app_mgr_service.h b/test/mock/services_appmgr_test/include/mock_app_mgr_service.h index 228775be2e..ec96bfa7c2 100644 --- a/test/mock/services_appmgr_test/include/mock_app_mgr_service.h +++ b/test/mock/services_appmgr_test/include/mock_app_mgr_service.h @@ -101,6 +101,8 @@ public: MOCK_METHOD0(IsFinalAppProcess, bool()); MOCK_METHOD1(SetSupportedProcessCacheSelf, int32_t(bool isSupport)); + MOCK_METHOD3(StartNativeChildProcess, int32_t(const std::string &libName, int32_t childProcessCount, + const sptr &callback)); virtual int StartUserTestProcess( const AAFwk::Want &want, const sptr &observer, const BundleInfo &bundleInfo, int32_t userId) { diff --git a/test/mock/services_appmgr_test/include/mock_app_mgr_service_inner.h b/test/mock/services_appmgr_test/include/mock_app_mgr_service_inner.h index 6b0f773cd9..f672f7d0f7 100644 --- a/test/mock/services_appmgr_test/include/mock_app_mgr_service_inner.h +++ b/test/mock/services_appmgr_test/include/mock_app_mgr_service_inner.h @@ -71,6 +71,8 @@ public: MOCK_METHOD1(IsWaitingDebugApp, bool(const std::string &bundleName)); MOCK_METHOD0(ClearNonPersistWaitingDebugFlag, void()); MOCK_METHOD0(IsMemorySizeSufficent, bool()); + MOCK_METHOD4(StartNativeChildProcess, int32_t(const pid_t hostPid, + const std::string &libName, int32_t childProcessCount, const sptr &callback)); void StartSpecifiedAbility(const AAFwk::Want&, const AppExecFwk::AbilityInfo&, int32_t) {} diff --git a/test/unittest/BUILD.gn b/test/unittest/BUILD.gn index 23fd0224e9..986f650204 100644 --- a/test/unittest/BUILD.gn +++ b/test/unittest/BUILD.gn @@ -48,6 +48,8 @@ ohos_source_set("appmgr_test_source") { "${ability_runtime_innerkits_path}/app_manager/src/appmgr/app_state_callback_proxy.cpp", "${ability_runtime_innerkits_path}/app_manager/src/appmgr/app_task_info.cpp", "${ability_runtime_innerkits_path}/app_manager/src/appmgr/fault_data.cpp", + "${ability_runtime_innerkits_path}/app_manager/src/appmgr/native_child_notify_proxy.cpp", + "${ability_runtime_innerkits_path}/app_manager/src/appmgr/native_child_notify_stub.cpp", "${ability_runtime_innerkits_path}/app_manager/src/appmgr/process_info.cpp", "${ability_runtime_innerkits_path}/app_manager/src/appmgr/profile.cpp", "${ability_runtime_innerkits_path}/app_manager/src/appmgr/render_scheduler_host.cpp", @@ -417,6 +419,7 @@ group("unittest") { "bundle_mgr_helper_test:unittest", "cache_process_manager_test:unittest", "call_record_test:unittest", + "child_process_capi_test:unittest", "child_process_manager_test:unittest", "completed_dispatcher_test:unittest", "configuration_test:unittest", diff --git a/test/unittest/app_mgr_service_test/app_mgr_service_test.cpp b/test/unittest/app_mgr_service_test/app_mgr_service_test.cpp index 30ecef7802..88061ed2d6 100644 --- a/test/unittest/app_mgr_service_test/app_mgr_service_test.cpp +++ b/test/unittest/app_mgr_service_test/app_mgr_service_test.cpp @@ -1731,5 +1731,31 @@ HWTEST_F(AppMgrServiceTest, SetSupportedProcessCacheSelf_002, TestSize.Level0) res = appMgrService->SetSupportedProcessCacheSelf(false); EXPECT_EQ(res, AAFwk::ERR_SET_SUPPORTED_PROCESS_CACHE_AGAIN); } + +/** + * @tc.name: StartNativeChildProcess_0100 + * @tc.desc: Start native child process. + * @tc.type: FUNC + */ +HWTEST_F(AppMgrServiceTest, StartNativeChildProcess_0100, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "StartNativeChildProcess_0100 called."); + sptr appMgrService = new (std::nothrow) AppMgrService(); + ASSERT_NE(appMgrService, nullptr); + + appMgrService->SetInnerService(mockAppMgrServiceInner_); + appMgrService->taskHandler_ = taskHandler_; + appMgrService->eventHandler_ = eventHandler_; + + EXPECT_CALL(*mockAppMgrServiceInner_, StartNativeChildProcess(_, _, _, _)) + .Times(1) + .WillOnce(Return(ERR_OK)); + + pid_t pid = 0; + sptr callback; + int32_t res = appMgrService->StartNativeChildProcess("test.so", 1, callback); + EXPECT_EQ(res, ERR_OK); +} + } // namespace AppExecFwk } // namespace OHOS diff --git a/test/unittest/appkit/child_main_thread_test/child_main_thread_test.cpp b/test/unittest/appkit/child_main_thread_test/child_main_thread_test.cpp index fd8b9929d4..9bfcea64c4 100644 --- a/test/unittest/appkit/child_main_thread_test/child_main_thread_test.cpp +++ b/test/unittest/appkit/child_main_thread_test/child_main_thread_test.cpp @@ -170,5 +170,26 @@ HWTEST_F(ChildMainThreadTest, ScheduleExitProcessSafely_0100, TestSize.Level0) auto ret = thread->ScheduleExitProcessSafely(); EXPECT_TRUE(ret); } + +/** + * @tc.number: ScheduleRunNativeProc_0100 + * @tc.desc: Test ScheduleRunNativeProc works + * @tc.type: FUNC + */ +HWTEST_F(ChildMainThreadTest, ScheduleRunNativeProc_0100, TestSize.Level0) +{ + TAG_LOGD(AAFwkTag::TEST, "ScheduleRunNativeProc_0100 called."); + sptr thread = sptr(new (std::nothrow) ChildMainThread()); + ASSERT_NE(thread, nullptr); + + std::shared_ptr runner = EventRunner::GetMainEventRunner(); + std::shared_ptr handler = std::make_shared(runner); + thread->mainHandler_ = handler; + + sptr mainPorcessCb = nullptr; + auto ret = thread->ScheduleRunNativeProc(mainPorcessCb); + EXPECT_FALSE(ret); +} + } // namespace AppExecFwk } // namespace OHOS diff --git a/test/unittest/child_process_capi_test/BUILD.gn b/test/unittest/child_process_capi_test/BUILD.gn new file mode 100644 index 0000000000..ab3e96a9bd --- /dev/null +++ b/test/unittest/child_process_capi_test/BUILD.gn @@ -0,0 +1,52 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/test.gni") +import("//foundation/ability/ability_runtime/ability_runtime.gni") + +module_output_path = "ability_runtime/child_process_capi" + +ohos_unittest("child_process_capi_test") { + module_out_path = module_output_path + + configs = [ "${ability_runtime_services_path}/common:common_config" ] + + if (target_cpu == "arm") { + cflags = [ "-DBINDER_IPC_32BIT" ] + } + + include_dirs = [ + "include", + "${ability_runtime_test_path}/mock/services_appmgr_test/include", + ] + + sources = [ "child_process_capi_test.cpp" ] + + deps = [ + "${ability_runtime_native_path}/child_process:child_process", + "${ability_runtime_services_path}/common:app_util", + "//third_party/googletest:gmock_main", + "//third_party/googletest:gtest_main", + ] + + external_deps = [ + "c_utils:utils", + "hilog:libhilog", + "ipc:ipc_capi", + ] +} + +group("unittest") { + testonly = true + deps = [ ":child_process_capi_test" ] +} diff --git a/test/unittest/child_process_capi_test/child_process_capi_test.cpp b/test/unittest/child_process_capi_test/child_process_capi_test.cpp new file mode 100644 index 0000000000..8ad66cbce4 --- /dev/null +++ b/test/unittest/child_process_capi_test/child_process_capi_test.cpp @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include +#include +#include "native_child_process.h" +#include "app_utils.h" + +namespace OHOS { +namespace AbilityRuntime { + +using namespace testing; +using namespace testing::ext; + +class ChildProcessCapiTest : public testing::Test { +public: + static void SetUpTestCase(void); + static void TearDownTestCase(void); + + static void OnNativeChildProcessStarted(int errCode, OHIPCRemoteProxy *remoteProxy); + + void SetUp(); + void TearDown(); +}; + +void ChildProcessCapiTest::SetUpTestCase(void) +{} + +void ChildProcessCapiTest::TearDownTestCase(void) +{} + +void ChildProcessCapiTest::SetUp(void) +{} + +void ChildProcessCapiTest::TearDown(void) +{} + +void ChildProcessCapiTest::OnNativeChildProcessStarted(int errCode, OHIPCRemoteProxy *remoteProxy) +{ +} + +/** + * @tc.number: OH_Ability_CreateNativeChildProcess_001 + * @tc.desc: Test API OH_Ability_CreateNativeChildProcess works + * @tc.type: FUNC + */ +HWTEST_F(ChildProcessCapiTest, OH_Ability_CreateNativeChildProcess_001, TestSize.Level0) +{ + GTEST_LOG_(INFO) << "OH_Ability_CreateNativeChildProcess_001 begin"; + int ret = OH_Ability_CreateNativeChildProcess(nullptr, ChildProcessCapiTest::OnNativeChildProcessStarted); + EXPECT_EQ(ret, NCP_ERR_INVALID_PARAM); + + ret = OH_Ability_CreateNativeChildProcess("test.so", nullptr); + EXPECT_EQ(ret, NCP_ERR_INVALID_PARAM); + + ret = OH_Ability_CreateNativeChildProcess("test.so", ChildProcessCapiTest::OnNativeChildProcessStarted); + if (!AAFwk::AppUtils::GetInstance().IsMultiProcessModel()) { + EXPECT_EQ(ret, NCP_ERR_MULTI_PROCESS_DISABLED); + return; + } else if (!AAFwk::AppUtils::GetInstance().IsSupportNativeChildProcess()) { + EXPECT_EQ(ret, NCP_ERR_NOT_SUPPORTED); + return; + } + + GTEST_LOG_(INFO) << "OH_Ability_CreateNativeChildProcess return " << ret; + EXPECT_NE(ret, NCP_ERR_NOT_SUPPORTED); +} + +} // namespace AbilityRuntime +} // namespace OHOS diff --git a/test/unittest/child_process_manager_test/child_process_manager_test.cpp b/test/unittest/child_process_manager_test/child_process_manager_test.cpp index 1eaf3f3076..da364c8298 100644 --- a/test/unittest/child_process_manager_test/child_process_manager_test.cpp +++ b/test/unittest/child_process_manager_test/child_process_manager_test.cpp @@ -45,6 +45,8 @@ void ChildProcessManagerTest::SetUpTestCase() { AAFwk::AppUtils::GetInstance().isMultiProcessModel_.isLoaded = true; AAFwk::AppUtils::GetInstance().isMultiProcessModel_.value = true; + AAFwk::AppUtils::GetInstance().isSupportNativeChildProcess_.isLoaded = true; + AAFwk::AppUtils::GetInstance().isSupportNativeChildProcess_.value = true; sptr bundleMgrService = sptr(new (std::nothrow) AppExecFwk::BundleMgrService()); sptr mockAppMgrService = sptr(new (std::nothrow) AppExecFwk::MockAppMgrService()); @@ -61,6 +63,8 @@ void ChildProcessManagerTest::TearDownTestCase() { AAFwk::AppUtils::GetInstance().isMultiProcessModel_.isLoaded = false; AAFwk::AppUtils::GetInstance().isMultiProcessModel_.value = false; + AAFwk::AppUtils::GetInstance().isSupportNativeChildProcess_.isLoaded = false; + AAFwk::AppUtils::GetInstance().isSupportNativeChildProcess_.value = false; } void ChildProcessManagerTest::SetUp() @@ -226,5 +230,19 @@ AbilityRuntime::Runtime::DebugOption debugOption; ChildProcessManager::GetInstance().SetForkProcessDebugOption("test", false, false, false); EXPECT_TRUE(true); } + +/** + * @tc.number: StartNativeChildProcessByAppSpawnFork_0100 + * @tc.desc: Test StartNativeChildProcessByAppSpawnFork works. + * @tc.type: FUNC + */ +HWTEST_F(ChildProcessManagerTest, StartNativeChildProcessByAppSpawnFork_0100, TestSize.Level0) +{ + TAG_LOGD(AAFwkTag::TEST, "StartNativeChildProcessByAppSpawnFork_0100 called."); + sptr callback; + auto ret = ChildProcessManager::GetInstance().StartNativeChildProcessByAppSpawnFork("test.so", callback); + EXPECT_NE(ret, ChildProcessManagerErrorCode::ERR_FORK_FAILED); +} + } // namespace AbilityRuntime } // namespace OHOS \ No newline at end of file From 0c9721e5736b25775a507f2aba975f3d37e9e7fa Mon Sep 17 00:00:00 2001 From: mashaohua7 Date: Tue, 14 May 2024 08:29:30 +0000 Subject: [PATCH 046/174] update frameworks/js/napi/app/js_app_manager/js_app_manager.cpp. Signed-off-by: mashaohua7 --- frameworks/js/napi/app/js_app_manager/js_app_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/js/napi/app/js_app_manager/js_app_manager.cpp b/frameworks/js/napi/app/js_app_manager/js_app_manager.cpp index 1b99615646..98f98e273c 100644 --- a/frameworks/js/napi/app/js_app_manager/js_app_manager.cpp +++ b/frameworks/js/napi/app/js_app_manager/js_app_manager.cpp @@ -677,7 +677,7 @@ private: if (ret == 0) { task.Resolve(env, CreateJsRunningMultiAppInfo(env, info)); } else { - task.Reject(env, CreateJsError(env, ret, "Get mission infos failed.")); + task.Reject(env, CreateJsError(env, GetJsErrorCodeByNativeError(ret))); } }; napi_value lastParam = nullptr; From b80f721f52a56694d3ac833f98063a10e64c1d32 Mon Sep 17 00:00:00 2001 From: mashaohua7 Date: Wed, 15 May 2024 13:48:48 +0800 Subject: [PATCH 047/174] =?UTF-8?q?=E9=80=9A=E8=BF=87bundlename=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E8=BF=90=E8=A1=8C=E6=97=B6=E5=BA=94=E7=94=A8=E5=88=86?= =?UTF-8?q?=E8=BA=AB=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: mashaohua7 --- .../js_app_manager/js_app_manager_utils.cpp | 12 +++---- .../app/js_app_manager/js_app_manager_utils.h | 6 ++-- .../include/appmgr/running_multi_info.h | 8 ++--- .../src/appmgr/running_multi_info.cpp | 34 +++++++++---------- services/appmgr/src/app_mgr_service_inner.cpp | 26 +++++++------- 5 files changed, 43 insertions(+), 43 deletions(-) diff --git a/frameworks/js/napi/app/js_app_manager/js_app_manager_utils.cpp b/frameworks/js/napi/app/js_app_manager/js_app_manager_utils.cpp index 39521ee924..6580d0fb23 100644 --- a/frameworks/js/napi/app/js_app_manager/js_app_manager_utils.cpp +++ b/frameworks/js/napi/app/js_app_manager/js_app_manager_utils.cpp @@ -160,24 +160,24 @@ napi_value CreateJsRunningMultiAppInfo(napi_env env, const RunningMultiAppInfo & } napi_set_named_property(env, object, "bundleName", CreateJsValue(env, info.bundleName)); napi_set_named_property(env, object, "mode", CreateJsValue(env, info.mode)); - napi_set_named_property(env, object, "instance", CreateNativeArray(env, info.instance)); - napi_set_named_property(env, object, "isolation", CreateJsRunningAppTwinArray(env, info.isolation)); + napi_set_named_property(env, object, "runningMultiInstances", CreateNativeArray(env, info.runningMultiInstances)); + napi_set_named_property(env, object, "runningAppClones", CreateJsRunningAppCloneArray(env, info.runningAppClones)); return object; } -napi_value CreateJsRunningAppTwinArray(napi_env env, const std::vector& data) +napi_value CreateJsRunningAppCloneArray(napi_env env, const std::vector& data) { napi_value arrayValue = nullptr; napi_create_array_with_length(env, data.size(), &arrayValue); uint32_t index = 0; for (const auto &item : data) { - napi_set_element(env, arrayValue, index++, CreateJsRunningAppTwin(env, item)); + napi_set_element(env, arrayValue, index++, CreateJsRunningAppClone(env, item)); } return arrayValue; } -napi_value CreateJsRunningAppTwin(napi_env env, const RunningAppTwin &info) +napi_value CreateJsRunningAppClone(napi_env env, const RunningAppClone &info) { napi_value object = nullptr; napi_create_object(env, &object); @@ -185,7 +185,7 @@ napi_value CreateJsRunningAppTwin(napi_env env, const RunningAppTwin &info) TAG_LOGE(AAFwkTag::APPMGR, "objValue nullptr."); return nullptr; } - napi_set_named_property(env, object, "appTwinIndex", CreateJsValue(env, info.appTwinIndex)); + napi_set_named_property(env, object, "appCloneIndex", CreateJsValue(env, info.appCloneIndex)); napi_set_named_property(env, object, "uid", CreateJsValue(env, info.uid)); napi_set_named_property(env, object, "pids", CreateNativeArray(env, info.pids)); diff --git a/frameworks/js/napi/app/js_app_manager/js_app_manager_utils.h b/frameworks/js/napi/app/js_app_manager/js_app_manager_utils.h index 254272193c..e2d0ad9297 100644 --- a/frameworks/js/napi/app/js_app_manager/js_app_manager_utils.h +++ b/frameworks/js/napi/app/js_app_manager/js_app_manager_utils.h @@ -31,7 +31,7 @@ using OHOS::AppExecFwk::AbilityStateData; using OHOS::AppExecFwk::ProcessData; using OHOS::AppExecFwk::RunningProcessInfo; using OHOS::AppExecFwk::RunningMultiAppInfo; -using OHOS::AppExecFwk::RunningAppTwin; +using OHOS::AppExecFwk::RunningAppClone; #ifdef SUPPORT_GRAPHICS using OHOS::AppExecFwk::AbilityFirstFrameStateData; #endif @@ -67,8 +67,8 @@ bool ConvertPreloadApplicationParam(napi_env env, size_t argc, napi_value *argv, JsAppProcessState ConvertToJsAppProcessState( const AppExecFwk::AppProcessState &appProcessState, const bool &isFocused); napi_value CreateJsRunningMultiAppInfo(napi_env env, const RunningMultiAppInfo &info); -napi_value CreateJsRunningAppTwinArray(napi_env env, const std::vector& data); -napi_value CreateJsRunningAppTwin(napi_env env, const RunningAppTwin &info); +napi_value CreateJsRunningAppCloneArray(napi_env env, const std::vector& data); +napi_value CreateJsRunningAppClone(napi_env env, const RunningAppClone &info); } // namespace AbilityRuntime } // namespace OHOS #endif // OHOS_ABILITY_RUNTIME_JS_APP_MANAGER_UTILS_H diff --git a/interfaces/inner_api/app_manager/include/appmgr/running_multi_info.h b/interfaces/inner_api/app_manager/include/appmgr/running_multi_info.h index b6d40f6087..6ab034eef3 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/running_multi_info.h +++ b/interfaces/inner_api/app_manager/include/appmgr/running_multi_info.h @@ -25,8 +25,8 @@ namespace OHOS { namespace AppExecFwk { -struct RunningAppTwin { - int32_t appTwinIndex; +struct RunningAppClone { + int32_t appCloneIndex; int32_t uid; std::vector pids; }; @@ -34,8 +34,8 @@ struct RunningAppTwin { struct RunningMultiAppInfo : public Parcelable { std::string bundleName; int32_t mode; - std::vector instance; - std::vector isolation; + std::vector runningMultiInstances; + std::vector runningAppClones; bool ReadFromParcel(Parcel &parcel); virtual bool Marshalling(Parcel &parcel) const override; diff --git a/interfaces/inner_api/app_manager/src/appmgr/running_multi_info.cpp b/interfaces/inner_api/app_manager/src/appmgr/running_multi_info.cpp index 8a6f9588bf..489e0a206a 100644 --- a/interfaces/inner_api/app_manager/src/appmgr/running_multi_info.cpp +++ b/interfaces/inner_api/app_manager/src/appmgr/running_multi_info.cpp @@ -28,18 +28,18 @@ bool RunningMultiAppInfo::ReadFromParcel(Parcel &parcel) { bundleName = Str16ToStr8(parcel.ReadString16()); mode = parcel.ReadInt32(); - if (!parcel.ReadStringVector(&instance)) { - TAG_LOGE(AAFwkTag::APPMGR, "read instance failed."); + if (!parcel.ReadStringVector(&runningMultiInstances)) { + TAG_LOGE(AAFwkTag::APPMGR, "read runningMultiInstances failed."); return false; } - int32_t isolationSize; - READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, isolationSize); - for (auto i = 0; i < isolationSize; i++) { - RunningAppTwin twin; - twin.appTwinIndex = parcel.ReadInt32(); - twin.uid = parcel.ReadInt32(); - parcel.ReadInt32Vector(&twin.pids); - isolation.emplace_back(twin); + int32_t runningAppClonesSize; + READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, runningAppClonesSize); + for (auto i = 0; i < runningAppClonesSize; i++) { + RunningAppClone clone; + clone.appCloneIndex = parcel.ReadInt32(); + clone.uid = parcel.ReadInt32(); + parcel.ReadInt32Vector(&clone.pids); + runningAppClones.emplace_back(clone); } return true; } @@ -59,15 +59,15 @@ bool RunningMultiAppInfo::Marshalling(Parcel &parcel) const { WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(bundleName)); WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, mode); - if (!parcel.WriteStringVector(instance)) { - TAG_LOGE(AAFwkTag::APPMGR, "write instance failed."); + if (!parcel.WriteStringVector(runningMultiInstances)) { + TAG_LOGE(AAFwkTag::APPMGR, "write runningMultiInstances failed."); return false; } - WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, isolation.size()); - for (auto &twin : isolation) { - WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, twin.appTwinIndex); - WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, twin.uid); - if (!parcel.WriteInt32Vector(twin.pids)) { + WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, runningAppClones.size()); + for (auto &clone : runningAppClones) { + WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, clone.appCloneIndex); + WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, clone.uid); + if (!parcel.WriteInt32Vector(clone.pids)) { TAG_LOGE(AAFwkTag::APPMGR, "read instance failed."); return false; } diff --git a/services/appmgr/src/app_mgr_service_inner.cpp b/services/appmgr/src/app_mgr_service_inner.cpp index 60369dcf62..38e254174d 100644 --- a/services/appmgr/src/app_mgr_service_inner.cpp +++ b/services/appmgr/src/app_mgr_service_inner.cpp @@ -1434,36 +1434,36 @@ int32_t AppMgrServiceInner::GetRunningMultiAppInfoByBundleName(const std::string if (info.mode == static_cast(MultiAppModeType::UNSPECIFIED)) { return AAFwk::ERR_APP_TWIN_NOT_SUPPORTED; } - GetRunningTwinAppInfo(appRecord, info); + GetRunningCloneAppInfo(appRecord, info); } return ERR_OK; } -void AppMgrServiceInner::GetRunningTwinAppInfo(const std::shared_ptr &appRecord, +void AppMgrServiceInner::GetRunningCloneAppInfo(const std::shared_ptr &appRecord, RunningMultiAppInfo &info) { if (info.mode == static_cast(MultiAppModeType::APP_CLONE)) { auto childAppRecordMap = appRecord->GetChildAppRecordMap(); size_t index = 0; - for (; index < info.isolation.size(); index++) { - if (info.isolation[index].appTwinIndex == appRecord->GetAppIndex()) { + for (; index < info.runningAppClones.size(); index++) { + if (info.runningAppClones[index].appCloneIndex == appRecord->GetAppIndex()) { break; } } - if (index < info.isolation.size()) { - info.isolation[index].pids.emplace_back(appRecord->GetPriorityObject()->GetPid()); + if (index < info.runningAppClones.size()) { + info.runningAppClones[index].pids.emplace_back(appRecord->GetPriorityObject()->GetPid()); for (auto it : childAppRecordMap) { - info.isolation[index].pids.emplace_back(it.first); + info.runningAppClones[index].pids.emplace_back(it.first); } } else { - RunningAppTwin twinInfo; - twinInfo.appTwinIndex = appRecord->GetAppIndex(); - twinInfo.uid = appRecord->GetUid(); - twinInfo.pids.emplace_back(appRecord->GetPriorityObject()->GetPid()); + RunningAppClone cloneInfo; + cloneInfo.appCloneIndex = appRecord->GetAppIndex(); + cloneInfo.uid = appRecord->GetUid(); + cloneInfo.pids.emplace_back(appRecord->GetPriorityObject()->GetPid()); for (auto it : childAppRecordMap) { - twinInfo.pids.emplace_back(it.first); + cloneInfo.pids.emplace_back(it.first); } - info.isolation.emplace_back(twinInfo); + info.runningAppClones.emplace_back(cloneInfo); } } } From 964ecf98b2b7395f83ede9492eb614dc7cabd388 Mon Sep 17 00:00:00 2001 From: mashaohua7 Date: Wed, 15 May 2024 14:00:54 +0800 Subject: [PATCH 048/174] =?UTF-8?q?=E9=80=9A=E8=BF=87bundlename=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E8=BF=90=E8=A1=8C=E6=97=B6=E5=BA=94=E7=94=A8=E5=88=86?= =?UTF-8?q?=E8=BA=AB=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: mashaohua7 --- .../inner_api/app_manager/src/appmgr/running_multi_info.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/inner_api/app_manager/src/appmgr/running_multi_info.cpp b/interfaces/inner_api/app_manager/src/appmgr/running_multi_info.cpp index 489e0a206a..ed56751ee8 100644 --- a/interfaces/inner_api/app_manager/src/appmgr/running_multi_info.cpp +++ b/interfaces/inner_api/app_manager/src/appmgr/running_multi_info.cpp @@ -68,7 +68,7 @@ bool RunningMultiAppInfo::Marshalling(Parcel &parcel) const WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, clone.appCloneIndex); WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, clone.uid); if (!parcel.WriteInt32Vector(clone.pids)) { - TAG_LOGE(AAFwkTag::APPMGR, "read instance failed."); + TAG_LOGE(AAFwkTag::APPMGR, "write runningAppClones failed."); return false; } } From ebac895c00aaae9f9ac2e2e5814a765376af38e9 Mon Sep 17 00:00:00 2001 From: xuxiaoya Date: Wed, 15 May 2024 14:53:30 +0800 Subject: [PATCH 049/174] add check in window ability Signed-off-by: xuxiaoya --- services/abilitymgr/src/ability_manager_service.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/abilitymgr/src/ability_manager_service.cpp b/services/abilitymgr/src/ability_manager_service.cpp index 738cbe93fb..94990bfb10 100644 --- a/services/abilitymgr/src/ability_manager_service.cpp +++ b/services/abilitymgr/src/ability_manager_service.cpp @@ -8641,7 +8641,7 @@ int AbilityManagerService::CheckCallOtherExtensionPermission(const AbilityReques return ERR_OK; } if (extensionType == AppExecFwk::ExtensionAbilityType::WINDOW) { - return ERR_OK; + CHECK_CALLER_IS_SYSTEM_APP; } if (extensionType == AppExecFwk::ExtensionAbilityType::ADS_SERVICE) { return ERR_OK; From 5351afd6e7969697c8c0ed5db15d331d08ea0775 Mon Sep 17 00:00:00 2001 From: mashaohua7 Date: Wed, 15 May 2024 14:55:11 +0800 Subject: [PATCH 050/174] =?UTF-8?q?=E9=80=9A=E8=BF=87bundlename=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E8=BF=90=E8=A1=8C=E6=97=B6=E5=BA=94=E7=94=A8=E5=88=86?= =?UTF-8?q?=E8=BA=AB=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: mashaohua7 --- frameworks/js/napi/app/js_app_manager/js_app_manager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frameworks/js/napi/app/js_app_manager/js_app_manager.cpp b/frameworks/js/napi/app/js_app_manager/js_app_manager.cpp index 98f98e273c..3b3d85b7eb 100644 --- a/frameworks/js/napi/app/js_app_manager/js_app_manager.cpp +++ b/frameworks/js/napi/app/js_app_manager/js_app_manager.cpp @@ -662,7 +662,7 @@ private: std::string bundleName; if (!ConvertFromJsValue(env, argv[0], bundleName)) { TAG_LOGE(AAFwkTag::APPMGR, "get bundleName failed!"); - ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM); + ThrowInvalidParamError("Parse param bundleName failed, must be a string"); return CreateJsUndefined(env); } NapiAsyncTask::CompleteCallback complete = @@ -675,7 +675,7 @@ private: RunningMultiAppInfo info; auto ret = appManager->GetRunningMultiAppInfoByBundleName(bundleName, info); if (ret == 0) { - task.Resolve(env, CreateJsRunningMultiAppInfo(env, info)); + task.ResolveWithNoError(env, CreateJsRunningMultiAppInfo(env, info)); } else { task.Reject(env, CreateJsError(env, GetJsErrorCodeByNativeError(ret))); } From 77a7872ee9a3135e01cb5cd5a5d8c16082d86c0c Mon Sep 17 00:00:00 2001 From: "zhangyafei.echo" Date: Wed, 15 May 2024 14:57:13 +0800 Subject: [PATCH 051/174] Support continuation and app recovery. Sig:SIG_ApplicationFramework Feature or BugFix: Feature Binary Source: No Signed-off-by: zhangyafei.echo Change-Id: I71eb7aaa4cce7fa70d184067f2b94f2b075d3c20 --- frameworks/native/ability/native/ability.cpp | 2 +- .../ability/native/ability_runtime/js_ability.cpp | 2 +- .../native/ability_runtime/js_ui_ability.cpp | 5 +++-- .../js_ui_extension_content_session.cpp | 15 ++++++++------- .../include/mock_ui_content.h | 6 +++--- .../include/mock_window.h | 4 ++-- 6 files changed, 18 insertions(+), 16 deletions(-) diff --git a/frameworks/native/ability/native/ability.cpp b/frameworks/native/ability/native/ability.cpp index 93191641d0..b50945bed6 100644 --- a/frameworks/native/ability/native/ability.cpp +++ b/frameworks/native/ability/native/ability.cpp @@ -1657,7 +1657,7 @@ std::string Ability::GetContentInfo() if (scene_ == nullptr) { return ""; } - return scene_->GetContentInfo(); + return scene_->GetContentInfo(Rosen::BackupAndRestoreType::CONTINUATION); } void Ability::OnWindowFocusChanged(bool hasFocus) diff --git a/frameworks/native/ability/native/ability_runtime/js_ability.cpp b/frameworks/native/ability/native/ability_runtime/js_ability.cpp index 508017d1a2..cfb1df8e6a 100644 --- a/frameworks/native/ability/native/ability_runtime/js_ability.cpp +++ b/frameworks/native/ability/native/ability_runtime/js_ability.cpp @@ -609,7 +609,7 @@ void JsAbility::RestorePageStack(const Want &want) auto env = jsRuntime_.GetNapiEnv(); if (abilityContext_->GetContentStorage()) { scene_->GetMainWindow()->NapiSetUIContent(pageStack, env, - abilityContext_->GetContentStorage()->GetNapiValue(), true); + abilityContext_->GetContentStorage()->GetNapiValue(), Rosen::BackupAndRestoreType::CONTINUATION); } else { TAG_LOGE(AAFwkTag::ABILITY, "restore: content storage is nullptr"); } diff --git a/frameworks/native/ability/native/ability_runtime/js_ui_ability.cpp b/frameworks/native/ability/native/ability_runtime/js_ui_ability.cpp index b1378f09ff..f401b2eef2 100644 --- a/frameworks/native/ability/native/ability_runtime/js_ui_ability.cpp +++ b/frameworks/native/ability/native/ability_runtime/js_ui_ability.cpp @@ -706,7 +706,7 @@ void JsUIAbility::RestorePageStack(const Want &want) auto env = jsRuntime_.GetNapiEnv(); if (abilityContext_->GetContentStorage()) { scene_->GetMainWindow()->NapiSetUIContent(pageStack, env, - abilityContext_->GetContentStorage()->GetNapiValue(), true); + abilityContext_->GetContentStorage()->GetNapiValue(), Rosen::BackupAndRestoreType::CONTINUATION); } else { TAG_LOGE(AAFwkTag::UIABILITY, "Content storage is nullptr."); } @@ -728,7 +728,8 @@ void JsUIAbility::AbilityContinuationOrRecover(const Want &want) auto env = jsRuntime_.GetNapiEnv(); auto mainWindow = scene_->GetMainWindow(); if (mainWindow != nullptr) { - mainWindow->NapiSetUIContent(pageStack, env, abilityContext_->GetContentStorage()->GetNapiValue(), true); + mainWindow->NapiSetUIContent(pageStack, env, abilityContext_->GetContentStorage()->GetNapiValue(), + Rosen::BackupAndRestoreType::CONTINUATION); } else { TAG_LOGE(AAFwkTag::UIABILITY, "MainWindow is nullptr."); } diff --git a/frameworks/native/ability/native/ui_extension_ability/js_ui_extension_content_session.cpp b/frameworks/native/ability/native/ui_extension_ability/js_ui_extension_content_session.cpp index fe5ccc8acf..f6a08f5058 100644 --- a/frameworks/native/ability/native/ui_extension_ability/js_ui_extension_content_session.cpp +++ b/frameworks/native/ability/native/ui_extension_ability/js_ui_extension_content_session.cpp @@ -633,7 +633,7 @@ napi_value JsUIExtensionContentSession::OnSetReceiveDataCallback(napi_env env, N ThrowTooFewParametersError(env); return CreateJsUndefined(env); } - + if (!CheckTypeForNapiValue(env, info.argv[INDEX_ZERO], napi_function)) { TAG_LOGE(AAFwkTag::UI_EXT, "invalid param"); ThrowInvalidParamError(env, "Parameter error: Callback must be a function."); @@ -681,7 +681,7 @@ napi_value JsUIExtensionContentSession::OnSetReceiveDataForResultCallback(napi_e ThrowTooFewParametersError(env); return CreateJsUndefined(env); } - + if (!CheckTypeForNapiValue(env, info.argv[INDEX_ZERO], napi_function)) { TAG_LOGE(AAFwkTag::UI_EXT, "invalid param"); ThrowInvalidParamError(env, "Parameter error: Callback must be a function."); @@ -733,7 +733,7 @@ napi_value JsUIExtensionContentSession::OnLoadContent(napi_env env, NapiCallback ThrowTooFewParametersError(env); return CreateJsUndefined(env); } - + if (!ConvertFromJsValue(env, info.argv[INDEX_ZERO], contextPath)) { TAG_LOGE(AAFwkTag::UI_EXT, "invalid param"); ThrowInvalidParamError(env, "Parameter error: Path must be a string."); @@ -761,7 +761,8 @@ napi_value JsUIExtensionContentSession::OnLoadContent(napi_env env, NapiCallback isFirstTriggerBindModal_ = false; } sptr parentToken = sessionInfo_->parentToken; - Rosen::WMError ret = uiWindow_->NapiSetUIContent(contextPath, env, storage, false, parentToken); + Rosen::WMError ret = uiWindow_->NapiSetUIContent(contextPath, env, storage, + Rosen::BackupAndRestoreType::NONE, parentToken); if (ret == Rosen::WMError::WM_OK) { TAG_LOGD(AAFwkTag::UI_EXT, "NapiSetUIContent success"); } else { @@ -781,7 +782,7 @@ napi_value JsUIExtensionContentSession::OnSetWindowBackgroundColor(napi_env env, ThrowTooFewParametersError(env); return CreateJsUndefined(env); } - + if (!ConvertFromJsValue(env, info.argv[INDEX_ZERO], color)) { TAG_LOGE(AAFwkTag::UI_EXT, "invalid param"); ThrowInvalidParamError(env, "Parameter error: Parse color failed! Color must be a string."); @@ -812,7 +813,7 @@ napi_value JsUIExtensionContentSession::OnSetWindowPrivacyMode(napi_env env, Nap ThrowTooFewParametersError(env); return CreateJsUndefined(env); } - + if (!ConvertFromJsValue(env, info.argv[INDEX_ZERO], isPrivacyMode)) { TAG_LOGE(AAFwkTag::UI_EXT, "invalid param"); ThrowInvalidParamError(env, "Parameter error: Failed to parse isPrivacyMode! IsPrivacyMode must be a boolean."); @@ -849,7 +850,7 @@ napi_value JsUIExtensionContentSession::OnSetWindowPrivacyMode(napi_env env, Nap napi_value JsUIExtensionContentSession::OnStartAbilityByType(napi_env env, NapiCallbackInfo& info) { TAG_LOGI(AAFwkTag::UI_EXT, "called"); - + std::string type; AAFwk::WantParams wantParam; diff --git a/test/mock/frameworks_kits_ability_native_test/include/mock_ui_content.h b/test/mock/frameworks_kits_ability_native_test/include/mock_ui_content.h index 2b1a016ecd..fc6bcbc36c 100644 --- a/test/mock/frameworks_kits_ability_native_test/include/mock_ui_content.h +++ b/test/mock/frameworks_kits_ability_native_test/include/mock_ui_content.h @@ -41,9 +41,9 @@ public: MOCK_METHOD0(UnFocus, void()); MOCK_METHOD0(Destroy, void()); MOCK_METHOD1(OnNewWant, void(const OHOS::AAFwk::Want &want)); - MOCK_METHOD3(Restore, UIContentErrorCode(OHOS::Rosen::Window *window, const std::string &contentInfo, - napi_value storage)); - MOCK_CONST_METHOD0(GetContentInfo, std::string()); + MOCK_METHOD4(Restore, UIContentErrorCode(OHOS::Rosen::Window *window, const std::string &contentInfo, + napi_value storage, ContentInfoType type)); + MOCK_CONST_METHOD1(GetContentInfo, std::string(ContentInfoType type)); MOCK_METHOD0(DestroyUIDirector, void()); MOCK_METHOD0(ProcessBackPressed, bool()); MOCK_METHOD1(ProcessPointerEvent, bool(const std::shared_ptr &pointerEvent)); diff --git a/test/mock/frameworks_kits_ability_native_test/include/mock_window.h b/test/mock/frameworks_kits_ability_native_test/include/mock_window.h index ca7e5a306b..d84611973b 100644 --- a/test/mock/frameworks_kits_ability_native_test/include/mock_window.h +++ b/test/mock/frameworks_kits_ability_native_test/include/mock_window.h @@ -151,9 +151,9 @@ public: virtual void NotifyTouchDialogTarget(int32_t posX = 0, int32_t posY = 0) {} virtual void SetAceAbilityHandler(const sptr& handler) {} virtual WMError NapiSetUIContent(const std::string& contentInfo, napi_env env, napi_value storage, - bool isDistributed = false, sptr token = nullptr, + BackupAndRestoreType type = BackupAndRestoreType::NONE, sptr token = nullptr, AppExecFwk::Ability* ability = nullptr) {return WMError::WM_OK;} - virtual std::string GetContentInfo() {return "";} + virtual std::string GetContentInfo(BackupAndRestoreType type = BackupAndRestoreType::CONTINUATION) {return "";} virtual Ace::UIContent* GetUIContent() const {return nullptr;} virtual void OnNewWant(const AAFwk::Want& want) {} virtual void SetRequestedOrientation(Orientation) {} From b83559650e1d1a1064f297e666af7ef6fa624ff1 Mon Sep 17 00:00:00 2001 From: mashaohua7 Date: Wed, 15 May 2024 14:59:40 +0800 Subject: [PATCH 052/174] =?UTF-8?q?=E9=80=9A=E8=BF=87bundlename=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E8=BF=90=E8=A1=8C=E6=97=B6=E5=BA=94=E7=94=A8=E5=88=86?= =?UTF-8?q?=E8=BA=AB=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: mashaohua7 --- frameworks/js/napi/app/js_app_manager/js_app_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/js/napi/app/js_app_manager/js_app_manager.cpp b/frameworks/js/napi/app/js_app_manager/js_app_manager.cpp index 3b3d85b7eb..f1d862fdbb 100644 --- a/frameworks/js/napi/app/js_app_manager/js_app_manager.cpp +++ b/frameworks/js/napi/app/js_app_manager/js_app_manager.cpp @@ -662,7 +662,7 @@ private: std::string bundleName; if (!ConvertFromJsValue(env, argv[0], bundleName)) { TAG_LOGE(AAFwkTag::APPMGR, "get bundleName failed!"); - ThrowInvalidParamError("Parse param bundleName failed, must be a string"); + ThrowInvalidParamError(env, "Parse param bundleName failed, must be a string"); return CreateJsUndefined(env); } NapiAsyncTask::CompleteCallback complete = From 8cf130da31e2c98ab96c65e8492baddfc0c6b89e Mon Sep 17 00:00:00 2001 From: mashaohua7 Date: Wed, 15 May 2024 15:03:20 +0800 Subject: [PATCH 053/174] =?UTF-8?q?=E9=80=9A=E8=BF=87bundlename=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E8=BF=90=E8=A1=8C=E6=97=B6=E5=BA=94=E7=94=A8=E5=88=86?= =?UTF-8?q?=E8=BA=AB=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: mashaohua7 --- frameworks/js/napi/app/js_app_manager/js_app_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/js/napi/app/js_app_manager/js_app_manager.cpp b/frameworks/js/napi/app/js_app_manager/js_app_manager.cpp index f1d862fdbb..86c0cd2bc3 100644 --- a/frameworks/js/napi/app/js_app_manager/js_app_manager.cpp +++ b/frameworks/js/napi/app/js_app_manager/js_app_manager.cpp @@ -668,7 +668,7 @@ private: NapiAsyncTask::CompleteCallback complete = [appManager = appManager_, bundleName](napi_env env, NapiAsyncTask &task, int32_t status) { if (appManager == nullptr) { - TAG_LOGW(AAFwkTag::APPMGR, "abilityManager nullptr"); + TAG_LOGW(AAFwkTag::APPMGR, "appManager nullptr"); task.Reject(env, CreateJsError(env, AbilityErrorCode::ERROR_CODE_INNER)); return; } From 081a766cb4b4767bffb1b77ecd5a75a29380719c Mon Sep 17 00:00:00 2001 From: yuwenze Date: Wed, 15 May 2024 16:22:10 +0800 Subject: [PATCH 054/174] replace Signed-off-by: yuwenze Change-Id: I3cb5dad539495eb7b937ab578d53465bb11c5b78 --- .../ability_business_error.cpp | 7 ++++--- .../bundle_mgr_helper.cpp | 18 +++++++++--------- frameworks/native/appkit/app/main_thread.cpp | 2 +- .../include/ability_manager_errors.h | 4 ++-- .../ability_business_error.h | 4 ++-- .../bundle_mgr_helper.h | 4 ++-- services/abilitymgr/include/dlp_utils.h | 4 ++-- .../abilitymgr/src/ability_manager_service.cpp | 8 ++++---- services/abilitymgr/src/ability_record.cpp | 6 +++--- .../src/connection_state_manager.cpp | 2 +- services/abilitymgr/src/dlp_state_item.cpp | 2 +- .../abilitymgr/src/mission_list_manager.cpp | 14 +++++++------- .../ui_ability_lifecycle_manager.cpp | 2 +- .../abilitymgr/src/start_ability_utils.cpp | 10 +++++----- services/appmgr/src/app_mgr_service.cpp | 2 +- services/appmgr/src/app_mgr_service_inner.cpp | 16 ++++++++-------- .../bundle_mgr_helper_test.cpp | 8 ++++---- .../startup_util_test/startup_util_test.cpp | 4 ++-- utils/global/constant/global_constant.h | 2 +- utils/server/constant/server_constant.h | 2 +- utils/server/startup/include/startup_util.h | 2 +- utils/server/startup/src/startup_util.cpp | 10 +++++----- 22 files changed, 67 insertions(+), 66 deletions(-) diff --git a/frameworks/native/ability/native/ability_business_error/ability_business_error.cpp b/frameworks/native/ability/native/ability_business_error/ability_business_error.cpp index 41fe630a53..822b4fe38e 100644 --- a/frameworks/native/ability/native/ability_business_error/ability_business_error.cpp +++ b/frameworks/native/ability/native/ability_business_error/ability_business_error.cpp @@ -78,7 +78,8 @@ constexpr const char* ERROR_MSG_TARGET_BUNDLE_NOT_EXIST = "The target bundle doe constexpr const char* ERROR_MSG_SET_SUPPORTED_PROCESS_CACHE_AGAIN = "Can not set process cache state more than once."; constexpr const char* ERROR_MSG_NO_RESIDENT_PERMISSION = "The caller application can only set the resident status of the configured process."; -constexpr const char* ERROR_MSG_APP_TWIN_INDEX_INVALID = "The target app twin with the specified index does not exist."; +constexpr const char* ERROR_MSG_APP_CLONE_INDEX_INVALID = + "The target app clone with the specified index does not exist."; // follow ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST of appexecfwk_errors.h in bundle_framework constexpr int32_t ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST = 8521220; @@ -132,7 +133,7 @@ static std::unordered_map ERR_CODE_MAP = { { AbilityErrorCode::ERROR_CODE_TARGET_BUNDLE_NOT_EXIST, ERROR_MSG_TARGET_BUNDLE_NOT_EXIST }, { AbilityErrorCode::ERROR_CODE_SET_SUPPORTED_PROCESS_CACHE_AGAIN, ERROR_MSG_SET_SUPPORTED_PROCESS_CACHE_AGAIN }, { AbilityErrorCode::ERROR_CODE_NO_RESIDENT_PERMISSION, ERROR_MSG_NO_RESIDENT_PERMISSION }, - { AbilityErrorCode::ERROR_APP_TWIN_INDEX_INVALID, ERROR_MSG_APP_TWIN_INDEX_INVALID }, + { AbilityErrorCode::ERROR_APP_CLONE_INDEX_INVALID, ERROR_MSG_APP_CLONE_INDEX_INVALID }, }; static std::unordered_map INNER_TO_JS_ERROR_CODE_MAP { @@ -189,7 +190,7 @@ static std::unordered_map INNER_TO_JS_ERROR_CODE_MAP {ERR_TARGET_BUNDLE_NOT_EXIST, AbilityErrorCode::ERROR_CODE_TARGET_BUNDLE_NOT_EXIST}, {ERR_SET_SUPPORTED_PROCESS_CACHE_AGAIN, AbilityErrorCode::ERROR_CODE_SET_SUPPORTED_PROCESS_CACHE_AGAIN}, {ERR_NO_RESIDENT_PERMISSION, AbilityErrorCode::ERROR_CODE_NO_RESIDENT_PERMISSION}, - {ERR_APP_TWIN_INDEX_INVALID, AbilityErrorCode::ERROR_APP_TWIN_INDEX_INVALID}, + {ERR_APP_CLONE_INDEX_INVALID, AbilityErrorCode::ERROR_APP_CLONE_INDEX_INVALID}, }; } diff --git a/frameworks/native/appkit/ability_bundle_manager_helper/bundle_mgr_helper.cpp b/frameworks/native/appkit/ability_bundle_manager_helper/bundle_mgr_helper.cpp index 1f7416dee8..515fd24eb3 100644 --- a/frameworks/native/appkit/ability_bundle_manager_helper/bundle_mgr_helper.cpp +++ b/frameworks/native/appkit/ability_bundle_manager_helper/bundle_mgr_helper.cpp @@ -82,7 +82,7 @@ ErrCode BundleMgrHelper::InstallSandboxApp(const std::string &bundleName, int32_ ErrCode BundleMgrHelper::UninstallSandboxApp(const std::string &bundleName, int32_t appIndex, int32_t userId) { TAG_LOGD(AAFwkTag::BUNDLEMGRHELPER, "Called."); - if (bundleName.empty() || appIndex <= AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX) { + if (bundleName.empty() || appIndex <= AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX) { TAG_LOGE(AAFwkTag::BUNDLEMGRHELPER, "The params are invalid."); return ERR_APPEXECFWK_SANDBOX_INSTALL_PARAM_ERROR; } @@ -113,7 +113,7 @@ ErrCode BundleMgrHelper::GetSandboxBundleInfo( const std::string &bundleName, int32_t appIndex, int32_t userId, BundleInfo &info) { TAG_LOGD(AAFwkTag::BUNDLEMGRHELPER, "Called."); - if (bundleName.empty() || appIndex <= AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX) { + if (bundleName.empty() || appIndex <= AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX) { TAG_LOGE(AAFwkTag::BUNDLEMGRHELPER, "The params are invalid."); return ERR_APPEXECFWK_SANDBOX_INSTALL_PARAM_ERROR; } @@ -131,7 +131,7 @@ ErrCode BundleMgrHelper::GetSandboxAbilityInfo(const Want &want, int32_t appInde AbilityInfo &abilityInfo) { TAG_LOGD(AAFwkTag::BUNDLEMGRHELPER, "Called."); - if (appIndex <= AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX) { + if (appIndex <= AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX) { TAG_LOGE(AAFwkTag::BUNDLEMGRHELPER, "The params are invalid."); return ERR_APPEXECFWK_SANDBOX_INSTALL_PARAM_ERROR; } @@ -152,7 +152,7 @@ ErrCode BundleMgrHelper::GetSandboxExtAbilityInfos(const Want &want, int32_t app int32_t userId, std::vector &extensionInfos) { TAG_LOGD(AAFwkTag::BUNDLEMGRHELPER, "Called."); - if (appIndex <= AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX) { + if (appIndex <= AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX) { TAG_LOGE(AAFwkTag::BUNDLEMGRHELPER, "The params are invalid."); return ERR_APPEXECFWK_SANDBOX_INSTALL_PARAM_ERROR; } @@ -170,7 +170,7 @@ ErrCode BundleMgrHelper::GetSandboxHapModuleInfo(const AbilityInfo &abilityInfo, HapModuleInfo &hapModuleInfo) { TAG_LOGD(AAFwkTag::BUNDLEMGRHELPER, "Called."); - if (appIndex <= AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX) { + if (appIndex <= AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX) { TAG_LOGE(AAFwkTag::BUNDLEMGRHELPER, "The params are invalid."); return ERR_APPEXECFWK_SANDBOX_INSTALL_PARAM_ERROR; } @@ -798,7 +798,7 @@ ErrCode BundleMgrHelper::GetLaunchWantForBundle(const std::string &bundleName, W return bundleMgr->GetLaunchWantForBundle(bundleName, want, userId); } -ErrCode BundleMgrHelper::QueryCloneAbilityInfo(const ElementName &element, int32_t flags, int32_t appTwinIndex, +ErrCode BundleMgrHelper::QueryCloneAbilityInfo(const ElementName &element, int32_t flags, int32_t appCloneIndex, AbilityInfo &abilityInfo, int32_t userId) { TAG_LOGD(AAFwkTag::BUNDLEMGRHELPER, "Called."); @@ -808,10 +808,10 @@ ErrCode BundleMgrHelper::QueryCloneAbilityInfo(const ElementName &element, int32 return ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR; } - return bundleMgr->QueryCloneAbilityInfo(element, flags, appTwinIndex, abilityInfo, userId); + return bundleMgr->QueryCloneAbilityInfo(element, flags, appCloneIndex, abilityInfo, userId); } -ErrCode BundleMgrHelper::GetCloneBundleInfo(const std::string &bundleName, int32_t flags, int32_t appTwinIndex, +ErrCode BundleMgrHelper::GetCloneBundleInfo(const std::string &bundleName, int32_t flags, int32_t appCloneIndex, BundleInfo &bundleInfo, int32_t userId) { TAG_LOGD(AAFwkTag::BUNDLEMGRHELPER, "Called."); @@ -821,7 +821,7 @@ ErrCode BundleMgrHelper::GetCloneBundleInfo(const std::string &bundleName, int32 return ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR; } - return bundleMgr->GetCloneBundleInfo(bundleName, flags, appTwinIndex, bundleInfo, userId); + return bundleMgr->GetCloneBundleInfo(bundleName, flags, appCloneIndex, bundleInfo, userId); } } // namespace AppExecFwk diff --git a/frameworks/native/appkit/app/main_thread.cpp b/frameworks/native/appkit/app/main_thread.cpp index c43081fb63..c9b0018c9f 100644 --- a/frameworks/native/appkit/app/main_thread.cpp +++ b/frameworks/native/appkit/app/main_thread.cpp @@ -1189,7 +1189,7 @@ bool GetBundleForLaunchApplication(std::shared_ptr bundleMgrHel int32_t appIndex, BundleInfo &bundleInfo) { bool queryResult; - if (appIndex > AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX) { + if (appIndex > AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX) { TAG_LOGD(AAFwkTag::APPKIT, "The bundleName = %{public}s.", bundleName.c_str()); queryResult = (bundleMgrHelper->GetSandboxBundleInfo(bundleName, appIndex, UNSPECIFIED_USERID, bundleInfo) == 0); diff --git a/interfaces/inner_api/ability_manager/include/ability_manager_errors.h b/interfaces/inner_api/ability_manager/include/ability_manager_errors.h index 175225a61c..922211e663 100644 --- a/interfaces/inner_api/ability_manager/include/ability_manager_errors.h +++ b/interfaces/inner_api/ability_manager/include/ability_manager_errors.h @@ -506,9 +506,9 @@ enum { ERR_NO_RESIDENT_PERMISSION, /** - * Result(2097250) for app twin index does not exist. + * Result(2097250) for app clone index does not exist. */ - ERR_APP_TWIN_INDEX_INVALID, + ERR_APP_CLONE_INDEX_INVALID, }; enum { diff --git a/interfaces/kits/native/ability/native/ability_business_error/ability_business_error.h b/interfaces/kits/native/ability/native/ability_business_error/ability_business_error.h index 1ccef7167f..54d32e9f83 100644 --- a/interfaces/kits/native/ability/native/ability_business_error/ability_business_error.h +++ b/interfaces/kits/native/ability/native/ability_business_error/ability_business_error.h @@ -141,8 +141,8 @@ enum class AbilityErrorCode { // Ability already running. ERROR_ABILITY_ALREADY_RUNNING = 16000068, - // app twin index does not exist. - ERROR_APP_TWIN_INDEX_INVALID = 16000073, + // app clone index does not exist. + ERROR_APP_CLONE_INDEX_INVALID = 16000073, // invalid caller. ERROR_CODE_INVALID_CALLER = 16200001, diff --git a/interfaces/kits/native/appkit/ability_bundle_manager_helper/bundle_mgr_helper.h b/interfaces/kits/native/appkit/ability_bundle_manager_helper/bundle_mgr_helper.h index 69e115c213..33834ac6d0 100644 --- a/interfaces/kits/native/appkit/ability_bundle_manager_helper/bundle_mgr_helper.h +++ b/interfaces/kits/native/appkit/ability_bundle_manager_helper/bundle_mgr_helper.h @@ -91,9 +91,9 @@ public: const uint32_t flag, const int32_t userId, std::vector &extensionInfos); sptr GetDefaultAppProxy(); ErrCode GetLaunchWantForBundle(const std::string &bundleName, Want &want, int32_t userId); - ErrCode QueryCloneAbilityInfo(const ElementName &element, int32_t flags, int32_t appTwinIndex, + ErrCode QueryCloneAbilityInfo(const ElementName &element, int32_t flags, int32_t appCloneIndex, AbilityInfo &abilityInfo, int32_t userId); - ErrCode GetCloneBundleInfo(const std::string &bundleName, int32_t flags, int32_t appTwinIndex, + ErrCode GetCloneBundleInfo(const std::string &bundleName, int32_t flags, int32_t appCloneIndex, BundleInfo &bundleInfo, int32_t userId); private: diff --git a/services/abilitymgr/include/dlp_utils.h b/services/abilitymgr/include/dlp_utils.h index f55e65a582..6e10b8e173 100644 --- a/services/abilitymgr/include/dlp_utils.h +++ b/services/abilitymgr/include/dlp_utils.h @@ -50,7 +50,7 @@ using Dlp = Security::DlpPermission::DlpPermissionKit; TAG_LOGE(AAFwkTag::ABILITYMGR, "Ability has already been destroyed."); return true; } - if (abilityRecord->GetAppIndex() <= AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX) { + if (abilityRecord->GetAppIndex() <= AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX) { return true; } if (abilityRecord->GetApplicationInfo().bundleName == want.GetElement().GetBundleName()) { @@ -76,7 +76,7 @@ using Dlp = Security::DlpPermission::DlpPermissionKit; if (callerToken != nullptr) { auto abilityRecord = Token::GetAbilityRecordByToken(callerToken); if (abilityRecord != nullptr && - abilityRecord->GetAppIndex() > AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX) { + abilityRecord->GetAppIndex() > AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX) { return true; } } diff --git a/services/abilitymgr/src/ability_manager_service.cpp b/services/abilitymgr/src/ability_manager_service.cpp index 738cbe93fb..1a44772bf6 100644 --- a/services/abilitymgr/src/ability_manager_service.cpp +++ b/services/abilitymgr/src/ability_manager_service.cpp @@ -5623,7 +5623,7 @@ int AbilityManagerService::GenerateAbilityRequest( { HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); auto abilityRecord = Token::GetAbilityRecordByToken(callerToken); - if (abilityRecord && abilityRecord->GetAppIndex() > AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX && + if (abilityRecord && abilityRecord->GetAppIndex() > AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX && abilityRecord->GetApplicationInfo().bundleName == want.GetElement().GetBundleName()) { (const_cast(want)).SetParam(AbilityRuntime::ServerConstant::DLP_INDEX, abilityRecord->GetAppIndex()); } @@ -5640,7 +5640,7 @@ int AbilityManagerService::GenerateAbilityRequest( auto abilityInfo = StartAbilityUtils::startAbilityInfo; if (abilityInfo == nullptr || abilityInfo->GetAppBundleName() != want.GetElement().GetBundleName()) { abilityInfo = StartAbilityInfo::CreateStartAbilityInfo(want, userId, - AbilityRuntime::StartupUtil::GetAppTwinIndex(want)); + AbilityRuntime::StartupUtil::GetAppIndex(want)); } CHECK_POINTER_AND_RETURN(abilityInfo, GET_ABILITY_SERVICE_FAILED); if (abilityInfo->status != ERR_OK) { @@ -5695,7 +5695,7 @@ int AbilityManagerService::GenerateExtensionAbilityRequest( const Want &want, AbilityRequest &request, const sptr &callerToken, int32_t userId) { auto abilityRecord = Token::GetAbilityRecordByToken(callerToken); - if (abilityRecord && abilityRecord->GetAppIndex() > AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX && + if (abilityRecord && abilityRecord->GetAppIndex() > AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX && abilityRecord->GetApplicationInfo().bundleName == want.GetElement().GetBundleName()) { (const_cast(want)).SetParam(AbilityRuntime::ServerConstant::DLP_INDEX, abilityRecord->GetAppIndex()); } @@ -5706,7 +5706,7 @@ int AbilityManagerService::GenerateExtensionAbilityRequest( auto abilityInfo = StartAbilityUtils::startAbilityInfo; if (abilityInfo == nullptr || abilityInfo->GetAppBundleName() != want.GetElement().GetBundleName()) { abilityInfo = StartAbilityInfo::CreateStartExtensionInfo(want, userId, - AbilityRuntime::StartupUtil::GetAppTwinIndex(want)); + AbilityRuntime::StartupUtil::GetAppIndex(want)); } CHECK_POINTER_AND_RETURN(abilityInfo, GET_ABILITY_SERVICE_FAILED); if (abilityInfo->status != ERR_OK) { diff --git a/services/abilitymgr/src/ability_record.cpp b/services/abilitymgr/src/ability_record.cpp index 4bbca9222a..14b9452f41 100644 --- a/services/abilitymgr/src/ability_record.cpp +++ b/services/abilitymgr/src/ability_record.cpp @@ -252,7 +252,7 @@ std::shared_ptr AbilityRecord::CreateAbilityRecord(const AbilityR abilityRequest.want, abilityRequest.abilityInfo, abilityRequest.appInfo, abilityRequest.requestCode); CHECK_POINTER_AND_RETURN(abilityRecord, nullptr); abilityRecord->SetUid(abilityRequest.uid); - abilityRecord->SetAppIndex(AbilityRuntime::StartupUtil::GetAppTwinIndex(abilityRequest.want)); + abilityRecord->SetAppIndex(AbilityRuntime::StartupUtil::GetAppIndex(abilityRequest.want)); abilityRecord->SetCallerAccessTokenId(abilityRequest.callerAccessTokenId); abilityRecord->sessionInfo_ = abilityRequest.sessionInfo; if (!abilityRecord->Init()) { @@ -1750,7 +1750,7 @@ void AbilityRecord::SendResultToCallers(bool schedulerdied) } std::shared_ptr callerAbilityRecord = caller->GetCaller(); if (callerAbilityRecord != nullptr && callerAbilityRecord->GetResult() != nullptr) { - bool isSandboxApp = appIndex_ > AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX ? true : false; + bool isSandboxApp = appIndex_ > AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX ? true : false; callerAbilityRecord->SendResult(isSandboxApp, applicationInfo_.accessTokenId); } else { std::shared_ptr callerSystemAbilityRecord = caller->GetSaCaller(); @@ -3023,7 +3023,7 @@ void AbilityRecord::GrantUriPermission(Want &want, std::string targetBundleName, // reject sandbox to grant uri permission by start ability if (!callerList_.empty() && callerList_.back()) { auto caller = callerList_.back()->GetCaller(); - if (caller && caller->appIndex_ > AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX) { + if (caller && caller->appIndex_ > AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX) { TAG_LOGE(AAFwkTag::ABILITYMGR, "Sandbox can not grant UriPermission by start ability."); return; } diff --git a/services/abilitymgr/src/connection_state_manager.cpp b/services/abilitymgr/src/connection_state_manager.cpp index 129129054d..7489c2d1fb 100644 --- a/services/abilitymgr/src/connection_state_manager.cpp +++ b/services/abilitymgr/src/connection_state_manager.cpp @@ -487,7 +487,7 @@ bool ConnectionStateManager::HandleDlpAbilityInner(const std::shared_ptrGetAppIndex() <= AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX) { + if (dlpAbility->GetAppIndex() <= AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX) { TAG_LOGD(AAFwkTag::CONNECTION, "this is not dlp ability, do not report connection stat."); return false; } diff --git a/services/abilitymgr/src/dlp_state_item.cpp b/services/abilitymgr/src/dlp_state_item.cpp index 68c12cb8bb..2d6e9860aa 100644 --- a/services/abilitymgr/src/dlp_state_item.cpp +++ b/services/abilitymgr/src/dlp_state_item.cpp @@ -54,7 +54,7 @@ int32_t DlpStateItem::GetOpenedAbilitySize() const bool DlpStateItem::HandleDlpConnectionState(const std::shared_ptr &record, bool isAdd, AbilityRuntime::DlpStateData &data) { - if (!record || record->GetAppIndex() <= AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX) { + if (!record || record->GetAppIndex() <= AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX) { TAG_LOGW(AAFwkTag::ABILITYMGR, "invalid dlp ability."); return false; } diff --git a/services/abilitymgr/src/mission_list_manager.cpp b/services/abilitymgr/src/mission_list_manager.cpp index 2e92c792e5..0afa084ec8 100644 --- a/services/abilitymgr/src/mission_list_manager.cpp +++ b/services/abilitymgr/src/mission_list_manager.cpp @@ -546,7 +546,7 @@ bool MissionListManager::HandleReusedMissionAndAbility(const AbilityRequest &abi std::string MissionListManager::GetMissionName(const AbilityRequest &abilityRequest) const { - int32_t appIndex = AbilityRuntime::StartupUtil::GetAppTwinIndex(abilityRequest.want); + int32_t appIndex = AbilityRuntime::StartupUtil::GetAppIndex(abilityRequest.want); return AbilityUtil::ConvertBundleNameSingleton(abilityRequest.abilityInfo.bundleName, abilityRequest.abilityInfo.name, abilityRequest.abilityInfo.moduleName, appIndex); } @@ -676,7 +676,7 @@ void MissionListManager::BuildInnerMissionInfo(InnerMissionInfo &info, const std info.missionInfo.unclearable = abilityRequest.abilityInfo.unclearableMission; info.isTemporary = abilityRequest.abilityInfo.removeMissionAfterTerminate; auto dlpIndex = abilityRequest.want.GetIntParam(AbilityRuntime::ServerConstant::DLP_INDEX, 0); - if (dlpIndex > AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX) { + if (dlpIndex > AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX) { info.isTemporary = true; } info.specifiedFlag = abilityRequest.specifiedFlag; @@ -1788,7 +1788,7 @@ void MissionListManager::CompleteTerminateAndUpdateMission(const std::shared_ptr terminateAbilityList_.remove(it); // update inner mission info time bool excludeFromMissions = abilityRecord->GetAbilityInfo().excludeFromMissions; - if ((abilityRecord->GetAppIndex() > AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX) || + if ((abilityRecord->GetAppIndex() > AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX) || abilityRecord->GetAbilityInfo().removeMissionAfterTerminate || excludeFromMissions) { RemoveMissionLocked(abilityRecord->GetMissionId(), excludeFromMissions); return; @@ -2010,7 +2010,7 @@ void MissionListManager::UpdateSnapShot(const sptr &token, return; } int32_t missionId = abilityRecord->GetMissionId(); - auto isPrivate = abilityRecord->GetAppIndex() > AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX; + auto isPrivate = abilityRecord->GetAppIndex() > AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX; DelayedSingleton::GetInstance()->UpdateMissionSnapshot(missionId, pixelMap, isPrivate); if (listenerController_) { listenerController_->NotifyMissionSnapshotChanged(missionId); @@ -2172,7 +2172,7 @@ void MissionListManager::UpdateMissionSnapshot(const std::shared_ptrGetMissionId(); MissionSnapshot snapshot; - snapshot.isPrivate = (abilityRecord->GetAppIndex() > AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX); + snapshot.isPrivate = (abilityRecord->GetAppIndex() > AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX); DelayedSingleton::GetInstance()->UpdateMissionSnapshot(missionId, abilityRecord->GetToken(), snapshot); if (listenerController_) { @@ -2697,7 +2697,7 @@ void MissionListManager::HandleAbilityDiedByDefault(std::shared_ptrGetMissionId(); if (!ability->IsUninstallAbility()) { - if ((ability->GetAppIndex() > AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX) || + if ((ability->GetAppIndex() > AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX) || ability->GetAbilityInfo().removeMissionAfterTerminate || ability->GetAbilityInfo().excludeFromMissions) { RemoveMissionLocked(missionId, ability->GetAbilityInfo().excludeFromMissions); } else { @@ -3611,7 +3611,7 @@ bool MissionListManager::GetMissionSnapshot(int32_t missionId, const sptrIsAbilityState(FOREGROUND)) { forceSnapshot = true; missionSnapshot.isPrivate = - (abilityRecord->GetAppIndex() > AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX); + (abilityRecord->GetAppIndex() > AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX); } } return DelayedSingleton::GetInstance()->GetMissionSnapshot( diff --git a/services/abilitymgr/src/scene_board/ui_ability_lifecycle_manager.cpp b/services/abilitymgr/src/scene_board/ui_ability_lifecycle_manager.cpp index 5e05ec1125..97df04a345 100644 --- a/services/abilitymgr/src/scene_board/ui_ability_lifecycle_manager.cpp +++ b/services/abilitymgr/src/scene_board/ui_ability_lifecycle_manager.cpp @@ -1286,7 +1286,7 @@ bool UIAbilityLifecycleManager::CheckProperties(const std::shared_ptrGetAppIndex(); + AbilityRuntime::StartupUtil::GetAppIndex(abilityRequest.want) == abilityRecord->GetAppIndex(); } void UIAbilityLifecycleManager::OnTimeOut(uint32_t msgId, int64_t abilityRecordId, bool isHalf) diff --git a/services/abilitymgr/src/start_ability_utils.cpp b/services/abilitymgr/src/start_ability_utils.cpp index 9a76da48f6..8217de4733 100644 --- a/services/abilitymgr/src/start_ability_utils.cpp +++ b/services/abilitymgr/src/start_ability_utils.cpp @@ -39,12 +39,12 @@ thread_local bool StartAbilityUtils::skipErms = false; int32_t StartAbilityUtils::GetAppIndex(const Want &want, sptr callerToken) { - int32_t appIndex = want.GetIntParam(AbilityRuntime::ServerConstant::APP_TWIN_INDEX, 0); - if (appIndex > 0 && appIndex <= AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX) { + int32_t appIndex = want.GetIntParam(AbilityRuntime::ServerConstant::APP_CLONE_INDEX, 0); + if (appIndex > 0 && appIndex <= AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX) { return appIndex; } auto abilityRecord = Token::GetAbilityRecordByToken(callerToken); - if (abilityRecord && abilityRecord->GetAppIndex() > AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX && + if (abilityRecord && abilityRecord->GetAppIndex() > AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX && abilityRecord->GetApplicationInfo().bundleName == want.GetElement().GetBundleName()) { return abilityRecord->GetAppIndex(); } @@ -154,11 +154,11 @@ std::shared_ptr StartAbilityInfo::CreateStartAbilityInfo(const auto abilityInfoFlag = AbilityRuntime::StartupUtil::BuildAbilityInfoFlag() | AppExecFwk::AbilityInfoFlag::GET_ABILITY_INFO_WITH_SKILL; auto request = std::make_shared(); - if (appIndex != 0 && appIndex <= AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX) { + if (appIndex != 0 && appIndex <= AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX) { IN_PROCESS_CALL_WITHOUT_RET(bms->QueryCloneAbilityInfo(want.GetElement(), abilityInfoFlag, appIndex, request->abilityInfo, userId)); if (request->abilityInfo.name.empty() || request->abilityInfo.bundleName.empty()) { - request->status = ERR_APP_TWIN_INDEX_INVALID; + request->status = ERR_APP_CLONE_INDEX_INVALID; } return request; } diff --git a/services/appmgr/src/app_mgr_service.cpp b/services/appmgr/src/app_mgr_service.cpp index 03ed44a33f..f3ef52ea48 100644 --- a/services/appmgr/src/app_mgr_service.cpp +++ b/services/appmgr/src/app_mgr_service.cpp @@ -415,7 +415,7 @@ int32_t AppMgrService::JudgeSandboxByPid(pid_t pid, bool &isSandbox) return ERR_INVALID_OPERATION; } auto appRunningRecord = appMgrServiceInner_->GetAppRunningRecordByPid(pid); - if (appRunningRecord && appRunningRecord->GetAppIndex() > AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX) { + if (appRunningRecord && appRunningRecord->GetAppIndex() > AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX) { isSandbox = true; TAG_LOGD(AAFwkTag::APPMGR, "current app is a sandbox."); return ERR_OK; diff --git a/services/appmgr/src/app_mgr_service_inner.cpp b/services/appmgr/src/app_mgr_service_inner.cpp index 5fb98f06dd..c6341cf8b5 100644 --- a/services/appmgr/src/app_mgr_service_inner.cpp +++ b/services/appmgr/src/app_mgr_service_inner.cpp @@ -249,7 +249,7 @@ void AppMgrServiceInner::StartSpecifiedProcess(const AAFwk::Want &want, const Ap HapModuleInfo hapModuleInfo; auto appInfo = std::make_shared(abilityInfo.applicationInfo); - int32_t appIndex = AbilityRuntime::StartupUtil::GetAppTwinIndex(want); + int32_t appIndex = AbilityRuntime::StartupUtil::GetAppIndex(want); if (!GetBundleAndHapInfo(abilityInfo, appInfo, bundleInfo, hapModuleInfo, appIndex)) { return; } @@ -399,7 +399,7 @@ void AppMgrServiceInner::LoadAbility(sptr token, sptrapplicationName, processName, startFlags, appRecord, appInfo->uid, bundleInfo, appInfo->bundleName, bundleIndex, appExistFlag, isPreload); std::string perfCmd = (want == nullptr) ? "" : want->GetStringParam(PERF_CMD); @@ -727,7 +727,7 @@ bool AppMgrServiceInner::GetBundleAndHapInfo(const AbilityInfo &abilityInfo, if (appIndex == 0) { bundleMgrResult = IN_PROCESS_CALL(bundleMgrHelper->GetBundleInfoV9(appInfo->bundleName, static_cast(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_APPLICATION), bundleInfo, userId)); - } else if (appIndex <= AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX) { + } else if (appIndex <= AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX) { bundleMgrResult = IN_PROCESS_CALL(bundleMgrHelper->GetCloneBundleInfo(appInfo->bundleName, static_cast(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_APPLICATION), appIndex, bundleInfo, userId)); } else { @@ -740,7 +740,7 @@ bool AppMgrServiceInner::GetBundleAndHapInfo(const AbilityInfo &abilityInfo, return false; } bool hapQueryResult = false; - if (appIndex <= AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX) { + if (appIndex <= AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX) { hapQueryResult = bundleMgrHelper->GetHapModuleInfo(abilityInfo, userId, hapModuleInfo); } else { hapQueryResult = (bundleMgrHelper->GetSandboxHapModuleInfo(abilityInfo, appIndex, userId, hapModuleInfo) == 0); @@ -1759,7 +1759,7 @@ std::shared_ptr AppMgrServiceInner::CreateAppRunningRecord(spt } appRecord->SetPerfCmd(want->GetStringParam(PERF_CMD)); appRecord->SetMultiThread(want->GetBoolParam(MULTI_THREAD, false)); - appRecord->SetAppIndex(AbilityRuntime::StartupUtil::GetAppTwinIndex(*want)); + appRecord->SetAppIndex(AbilityRuntime::StartupUtil::GetAppIndex(*want)); appRecord->SetSecurityFlag(want->GetBoolParam(DLP_PARAMS_SECURITY_FLAG, false)); appRecord->SetRequestProcCode(want->GetIntParam(Want::PARAM_RESV_REQUEST_PROC_CODE, 0)); appRecord->SetCallerPid(want->GetIntParam(Want::PARAM_RESV_CALLER_PID, -1)); @@ -3521,7 +3521,7 @@ int AppMgrServiceInner::StartEmptyProcess(const AAFwk::Want &want, const sptruserId = userId; appRecord->SetUserTestInfo(testRecord); - int32_t appIndex = AbilityRuntime::StartupUtil::GetAppTwinIndex(want); + int32_t appIndex = AbilityRuntime::StartupUtil::GetAppIndex(want); uint32_t startFlags = AppspawnUtil::BuildStartFlags(want, info.applicationInfo); StartProcess(appInfo->name, processName, startFlags, appRecord, appInfo->uid, info, appInfo->bundleName, appIndex, appExistFlag); @@ -3612,7 +3612,7 @@ void AppMgrServiceInner::StartSpecifiedAbility(const AAFwk::Want &want, const Ap HapModuleInfo hapModuleInfo; auto appInfo = std::make_shared(abilityInfo.applicationInfo); - int32_t appIndex = AbilityRuntime::StartupUtil::GetAppTwinIndex(want); + int32_t appIndex = AbilityRuntime::StartupUtil::GetAppIndex(want); if (!GetBundleAndHapInfo(abilityInfo, appInfo, bundleInfo, hapModuleInfo, appIndex)) { return; } diff --git a/test/unittest/bundle_mgr_helper_test/bundle_mgr_helper_test.cpp b/test/unittest/bundle_mgr_helper_test/bundle_mgr_helper_test.cpp index 9f894fe305..6ad785ccc1 100644 --- a/test/unittest/bundle_mgr_helper_test/bundle_mgr_helper_test.cpp +++ b/test/unittest/bundle_mgr_helper_test/bundle_mgr_helper_test.cpp @@ -812,9 +812,9 @@ HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_QueryCloneAbilityInfo_001, Tes ElementName element; AbilityInfo abilityInfo; int32_t flags = ABILITY_INFO_FLAG; - int32_t appTwinIndex = 1; + int32_t appCloneIndex = 1; int32_t userId = DEFAULT_USERID; - auto ret = bundleMgrHelper->QueryCloneAbilityInfo(element, flags, appTwinIndex, abilityInfo, userId); + auto ret = bundleMgrHelper->QueryCloneAbilityInfo(element, flags, appCloneIndex, abilityInfo, userId); EXPECT_NE(ret, ERR_OK); } @@ -828,9 +828,9 @@ HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_GetCloneBundleInfo_001, TestSi std::string bundleName; BundleInfo bundleInfo; int32_t flags = 1; - int32_t appTwinIndex = 1; + int32_t appCloneIndex = 1; int32_t userId = DEFAULT_USERID; - auto ret = bundleMgrHelper->GetCloneBundleInfo(bundleName, flags, appTwinIndex, bundleInfo, userId); + auto ret = bundleMgrHelper->GetCloneBundleInfo(bundleName, flags, appCloneIndex, bundleInfo, userId); EXPECT_NE(ret, ERR_OK); } } // namespace AppExecFwk diff --git a/test/unittest/startup_util_test/startup_util_test.cpp b/test/unittest/startup_util_test/startup_util_test.cpp index a18b170108..18d84aa227 100644 --- a/test/unittest/startup_util_test/startup_util_test.cpp +++ b/test/unittest/startup_util_test/startup_util_test.cpp @@ -50,8 +50,8 @@ void StartupUtilTest::TearDown() HWTEST_F(StartupUtilTest, startup_util_test_001, TestSize.Level1) { AAFwk::Want want; - auto appTwinIndex = StartupUtil::GetAppTwinIndex(want); - EXPECT_EQ(appTwinIndex, 0); + auto appIndex = StartupUtil::GetAppIndex(want); + EXPECT_EQ(appIndex, 0); } } // namespace AbilityRuntime } // namespace OHOS diff --git a/utils/global/constant/global_constant.h b/utils/global/constant/global_constant.h index ede0a1f21f..7ef355315b 100644 --- a/utils/global/constant/global_constant.h +++ b/utils/global/constant/global_constant.h @@ -18,7 +18,7 @@ namespace OHOS::AbilityRuntime { namespace GlobalConstant { -constexpr int32_t MAX_APP_TWIN_INDEX = 1000; +constexpr int32_t MAX_APP_CLONE_INDEX = 1000; } // namespace GlobalConstant } // namespace OHOS::AbilityRuntime #endif // OHOS_ABILITY_RUNTIME_GLOBAL_CONSTANT_H \ No newline at end of file diff --git a/utils/server/constant/server_constant.h b/utils/server/constant/server_constant.h index 0062c54221..7145c5e70c 100644 --- a/utils/server/constant/server_constant.h +++ b/utils/server/constant/server_constant.h @@ -18,7 +18,7 @@ namespace OHOS::AbilityRuntime { namespace ServerConstant { -constexpr const char* APP_TWIN_INDEX = "ohos.extra.param.key.appTwinIndex"; +constexpr const char* APP_CLONE_INDEX = "ohos.extra.param.key.appCloneIndex"; constexpr const char* DLP_INDEX = "ohos.dlp.params.index"; } // namespace ServerConstant } // namespace OHOS::AbilityRuntime diff --git a/utils/server/startup/include/startup_util.h b/utils/server/startup/include/startup_util.h index 34b76ced86..11eb21ed33 100644 --- a/utils/server/startup/include/startup_util.h +++ b/utils/server/startup/include/startup_util.h @@ -25,7 +25,7 @@ class Want; namespace AbilityRuntime { class StartupUtil { public: - static int32_t GetAppTwinIndex(const AAFwk::Want &want); + static int32_t GetAppIndex(const AAFwk::Want &want); static int32_t BuildAbilityInfoFlag(); }; } // namespace AbilityRuntime diff --git a/utils/server/startup/src/startup_util.cpp b/utils/server/startup/src/startup_util.cpp index 7ed79257ac..f9755629d9 100644 --- a/utils/server/startup/src/startup_util.cpp +++ b/utils/server/startup/src/startup_util.cpp @@ -20,13 +20,13 @@ #include "want.h" namespace OHOS::AbilityRuntime { -int32_t StartupUtil::GetAppTwinIndex(const AAFwk::Want &want) +int32_t StartupUtil::GetAppIndex(const AAFwk::Want &want) { - int32_t appTwinIndex = want.GetIntParam(ServerConstant::APP_TWIN_INDEX, 0); - if (appTwinIndex == 0) { - appTwinIndex = want.GetIntParam(ServerConstant::DLP_INDEX, 0); + int32_t appIndex = want.GetIntParam(ServerConstant::APP_CLONE_INDEX, 0); + if (appIndex == 0) { + appIndex = want.GetIntParam(ServerConstant::DLP_INDEX, 0); } - return appTwinIndex; + return appIndex; } int32_t StartupUtil::BuildAbilityInfoFlag() From a751a0fbf3e3607da41c08e143d9ca5c9d9c1965 Mon Sep 17 00:00:00 2001 From: mashaohua7 Date: Wed, 15 May 2024 16:32:04 +0800 Subject: [PATCH 055/174] =?UTF-8?q?=E9=80=9A=E8=BF=87bundlename=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E8=BF=90=E8=A1=8C=E6=97=B6=E5=BA=94=E7=94=A8=E5=88=86?= =?UTF-8?q?=E8=BA=AB=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: mashaohua7 --- .../ability_business_error.cpp | 6 +++--- .../ability_business_error.h | 2 +- services/appmgr/src/app_mgr_service_inner.cpp | 19 ++++++++++++++++--- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/frameworks/native/ability/native/ability_business_error/ability_business_error.cpp b/frameworks/native/ability/native/ability_business_error/ability_business_error.cpp index 5b8e645800..06115fa64b 100644 --- a/frameworks/native/ability/native/ability_business_error/ability_business_error.cpp +++ b/frameworks/native/ability/native/ability_business_error/ability_business_error.cpp @@ -79,7 +79,7 @@ constexpr const char* ERROR_MSG_SET_SUPPORTED_PROCESS_CACHE_AGAIN = "Can not set constexpr const char* ERROR_MSG_NO_RESIDENT_PERMISSION = "The caller application can only set the resident status of the configured process."; constexpr const char* ERROR_MSG_APP_TWIN_INDEX_INVALID = "The target app twin with the specified index does not exist."; -constexpr const char* ERROR_MSG_TWIN_NOT_SUPPORTED = "App twin or multi-instance is not supported."; +constexpr const char* ERROR_MSG_MULTI_APP_NOT_SUPPORTED = "App clone or multi-instance is not supported."; // follow ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST of appexecfwk_errors.h in bundle_framework constexpr int32_t ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST = 8521220; @@ -134,7 +134,7 @@ static std::unordered_map ERR_CODE_MAP = { { AbilityErrorCode::ERROR_CODE_SET_SUPPORTED_PROCESS_CACHE_AGAIN, ERROR_MSG_SET_SUPPORTED_PROCESS_CACHE_AGAIN }, { AbilityErrorCode::ERROR_CODE_NO_RESIDENT_PERMISSION, ERROR_MSG_NO_RESIDENT_PERMISSION }, { AbilityErrorCode::ERROR_APP_TWIN_INDEX_INVALID, ERROR_MSG_APP_TWIN_INDEX_INVALID }, - { AbilityErrorCode::ERROR_CODE_TWIN_NOT_SUPPORTED, ERROR_MSG_TWIN_NOT_SUPPORTED }, + { AbilityErrorCode::ERROR_CODE_MULTI_APP_NOT_SUPPORTED, ERROR_MSG_MULTI_APP_NOT_SUPPORTED }, }; static std::unordered_map INNER_TO_JS_ERROR_CODE_MAP { @@ -192,7 +192,7 @@ static std::unordered_map INNER_TO_JS_ERROR_CODE_MAP {ERR_SET_SUPPORTED_PROCESS_CACHE_AGAIN, AbilityErrorCode::ERROR_CODE_SET_SUPPORTED_PROCESS_CACHE_AGAIN}, {ERR_NO_RESIDENT_PERMISSION, AbilityErrorCode::ERROR_CODE_NO_RESIDENT_PERMISSION}, {ERR_APP_TWIN_INDEX_INVALID, AbilityErrorCode::ERROR_APP_TWIN_INDEX_INVALID}, - {ERR_APP_TWIN_NOT_SUPPORTED, AbilityErrorCode::ERROR_CODE_TWIN_NOT_SUPPORTED}, + {ERR_MULTI_APP_NOT_SUPPORTED, AbilityErrorCode::ERROR_CODE_MULTI_APP_NOT_SUPPORTED}, }; } diff --git a/interfaces/kits/native/ability/native/ability_business_error/ability_business_error.h b/interfaces/kits/native/ability/native/ability_business_error/ability_business_error.h index 0a9e8df79a..d85dc56679 100644 --- a/interfaces/kits/native/ability/native/ability_business_error/ability_business_error.h +++ b/interfaces/kits/native/ability/native/ability_business_error/ability_business_error.h @@ -142,7 +142,7 @@ enum class AbilityErrorCode { ERROR_ABILITY_ALREADY_RUNNING = 16000068, // not support twin app. - ERROR_CODE_TWIN_NOT_SUPPORTED = 16000072, + ERROR_CODE_MULTI_APP_NOT_SUPPORTED = 16000072, // app twin index does not exist. ERROR_APP_TWIN_INDEX_INVALID = 16000073, diff --git a/services/appmgr/src/app_mgr_service_inner.cpp b/services/appmgr/src/app_mgr_service_inner.cpp index 38e254174d..7dcde29b08 100644 --- a/services/appmgr/src/app_mgr_service_inner.cpp +++ b/services/appmgr/src/app_mgr_service_inner.cpp @@ -1429,10 +1429,14 @@ int32_t AppMgrServiceInner::GetRunningMultiAppInfoByBundleName(const std::string if (appRecord == nullptr || appRecord->GetBundleName() != bundleName) { continue; } + auto appInfo = appRecord->GetApplicationInfo(); + if (!appInfo) { + continue; + } info.bundleName = bundleName; info.mode = static_cast(appRecord->GetApplicationInfo()->multiAppMode.multiAppModeType); if (info.mode == static_cast(MultiAppModeType::UNSPECIFIED)) { - return AAFwk::ERR_APP_TWIN_NOT_SUPPORTED; + return AAFwk::ERR_MULTI_APP_NOT_SUPPORTED; } GetRunningCloneAppInfo(appRecord, info); } @@ -1442,6 +1446,15 @@ int32_t AppMgrServiceInner::GetRunningMultiAppInfoByBundleName(const std::string void AppMgrServiceInner::GetRunningCloneAppInfo(const std::shared_ptr &appRecord, RunningMultiAppInfo &info) { + if (!appRecord) { + TAG_LOGE(AAFwkTag::APPMGR, "The appRecord is nullptr!"); + return ERR_INVALID_VALUE; + } + auto PriorityObject = appRecord->GetPriorityObject(); + if (!PriorityObject) { + TAG_LOGE(AAFwkTag::APPMGR, "The PriorityObject is nullptr!"); + return ERR_INVALID_VALUE; + } if (info.mode == static_cast(MultiAppModeType::APP_CLONE)) { auto childAppRecordMap = appRecord->GetChildAppRecordMap(); size_t index = 0; @@ -1451,7 +1464,7 @@ void AppMgrServiceInner::GetRunningCloneAppInfo(const std::shared_ptrGetPriorityObject()->GetPid()); + info.runningAppClones[index].pids.emplace_back(PriorityObject->GetPid()); for (auto it : childAppRecordMap) { info.runningAppClones[index].pids.emplace_back(it.first); } @@ -1459,7 +1472,7 @@ void AppMgrServiceInner::GetRunningCloneAppInfo(const std::shared_ptrGetAppIndex(); cloneInfo.uid = appRecord->GetUid(); - cloneInfo.pids.emplace_back(appRecord->GetPriorityObject()->GetPid()); + cloneInfo.pids.emplace_back(PriorityObject->GetPid()); for (auto it : childAppRecordMap) { cloneInfo.pids.emplace_back(it.first); } From 2f45a083540d22cc88e4962dae549f8ac3f4950f Mon Sep 17 00:00:00 2001 From: mashaohua7 Date: Wed, 15 May 2024 16:57:13 +0800 Subject: [PATCH 056/174] =?UTF-8?q?=E9=80=9A=E8=BF=87bundlename=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E8=BF=90=E8=A1=8C=E6=97=B6=E5=BA=94=E7=94=A8=E5=88=86?= =?UTF-8?q?=E8=BA=AB=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: mashaohua7 --- .../include/ability_manager_errors.h | 2 +- .../appmgr/include/app_mgr_service_inner.h | 35 +++++++------------ services/appmgr/src/app_mgr_service_inner.cpp | 2 +- 3 files changed, 14 insertions(+), 25 deletions(-) diff --git a/interfaces/inner_api/ability_manager/include/ability_manager_errors.h b/interfaces/inner_api/ability_manager/include/ability_manager_errors.h index b0776c6e1a..910a54d7ff 100644 --- a/interfaces/inner_api/ability_manager/include/ability_manager_errors.h +++ b/interfaces/inner_api/ability_manager/include/ability_manager_errors.h @@ -513,7 +513,7 @@ enum { /** * Result(2097251) not support twin. */ - ERR_APP_TWIN_NOT_SUPPORTED, + ERR_MULTI_APP_NOT_SUPPORTED, }; enum { diff --git a/services/appmgr/include/app_mgr_service_inner.h b/services/appmgr/include/app_mgr_service_inner.h index a63e87ee2e..0c0202a36d 100644 --- a/services/appmgr/include/app_mgr_service_inner.h +++ b/services/appmgr/include/app_mgr_service_inner.h @@ -306,28 +306,6 @@ public: */ virtual int32_t GetAllRunningProcesses(std::vector &info); - /** - * GetRunningMultiAppInfoByBundleName, call GetRunningMultiAppInfoByBundleName() through proxy project. - * Obtains information about multiapp that are running on the device. - * - * @param bundlename, input. - * @param info, output multiapp information. - * @return ERR_OK ,return back success,others fail. - */ - virtual int32_t GetRunningMultiAppInfoByBundleName(const std::string &bundleName, - RunningMultiAppInfo &info); - - /** - * GetRunningMultiAppInfoByBundleName, call GetRunningTwinAppInfo() through proxy project. - * Obtains information about TwinApp that are running on the device. - * - * @param apprecord, input. - * @param info, output multiapp information. - * @return void. - */ - virtual void GetRunningTwinAppInfo(const std::shared_ptr &appRecord, - RunningMultiAppInfo &info); - /** * GetRunningProcessesByBundleType, Obtains information about application processes by bundle type. * @@ -1359,7 +1337,18 @@ private: bool JudgeSelfCalledByToken(const sptr &token, const PageStateData &pageStateData); void ParseServiceExtMultiProcessWhiteList(); - void ClearData(std::shared_ptr appRecord); + void ClearData(std::shared_ptr appRecord);\ + + /** + * GetRunningMultiAppInfoByBundleName, call GetRunningTwinAppInfo() through proxy project. + * Obtains information about TwinApp that are running on the device. + * + * @param apprecord, input. + * @param info, output multiapp information. + * @return void. + */ + void GetRunningCloneAppInfo(const std::shared_ptr &appRecord, + RunningMultiAppInfo &info); /** * Notify the app running status. diff --git a/services/appmgr/src/app_mgr_service_inner.cpp b/services/appmgr/src/app_mgr_service_inner.cpp index 7dcde29b08..1f2877aeec 100644 --- a/services/appmgr/src/app_mgr_service_inner.cpp +++ b/services/appmgr/src/app_mgr_service_inner.cpp @@ -1434,7 +1434,7 @@ int32_t AppMgrServiceInner::GetRunningMultiAppInfoByBundleName(const std::string continue; } info.bundleName = bundleName; - info.mode = static_cast(appRecord->GetApplicationInfo()->multiAppMode.multiAppModeType); + info.mode = static_cast(appInfo->multiAppMode.multiAppModeType); if (info.mode == static_cast(MultiAppModeType::UNSPECIFIED)) { return AAFwk::ERR_MULTI_APP_NOT_SUPPORTED; } From 17712d41fb3738679ffdf2eed8cddb3f85681aaf Mon Sep 17 00:00:00 2001 From: mashaohua7 Date: Wed, 15 May 2024 17:02:13 +0800 Subject: [PATCH 057/174] =?UTF-8?q?=E9=80=9A=E8=BF=87bundlename=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E8=BF=90=E8=A1=8C=E6=97=B6=E5=BA=94=E7=94=A8=E5=88=86?= =?UTF-8?q?=E8=BA=AB=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: mashaohua7 --- .../app_mgr_service_inner_test/app_mgr_service_inner_test.cpp | 2 +- test/unittest/app_mgr_service_test/app_mgr_service_test.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/unittest/app_mgr_service_inner_test/app_mgr_service_inner_test.cpp b/test/unittest/app_mgr_service_inner_test/app_mgr_service_inner_test.cpp index 58a9d305d2..889d64a636 100644 --- a/test/unittest/app_mgr_service_inner_test/app_mgr_service_inner_test.cpp +++ b/test/unittest/app_mgr_service_inner_test/app_mgr_service_inner_test.cpp @@ -4278,7 +4278,7 @@ HWTEST_F(AppMgrServiceInnerTest, GetRunningMultiAppInfoByBundleName_001, TestSiz std::string bundleName = "testBundleName"; RunningMultiAppInfo info; int32_t ret = appMgrServiceInner->GetRunningMultiAppInfoByBundleName(bundleName, info); - EXPECT_EQ(ret, ERR_OK); + EXPECT_NE(ret, ERR_OK); appMgrServiceInner->appRunningManager_ = nullptr; ret = appMgrServiceInner->GetRunningMultiAppInfoByBundleName(bundleName, info); diff --git a/test/unittest/app_mgr_service_test/app_mgr_service_test.cpp b/test/unittest/app_mgr_service_test/app_mgr_service_test.cpp index 477a28627d..1e22daf5c7 100644 --- a/test/unittest/app_mgr_service_test/app_mgr_service_test.cpp +++ b/test/unittest/app_mgr_service_test/app_mgr_service_test.cpp @@ -1772,7 +1772,7 @@ HWTEST_F(AppMgrServiceTest, GetRunningMultiAppInfoByBundleName_002, TestSize.Lev std::string bundleName = "testBundleName"; RunningMultiAppInfo info; int32_t res = appMgrService->GetRunningMultiAppInfoByBundleName(bundleName, info); - EXPECT_EQ(res, ERR_OK); + EXPECT_EQ(res, ERR_INVALID_OPERATION); } } // namespace AppExecFwk } // namespace OHOS From bb955599bb665b7c84782fd551bb53abcb960bc2 Mon Sep 17 00:00:00 2001 From: mashaohua7 Date: Wed, 15 May 2024 19:30:32 +0800 Subject: [PATCH 058/174] =?UTF-8?q?=E9=80=9A=E8=BF=87bundlename=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E8=BF=90=E8=A1=8C=E6=97=B6=E5=BA=94=E7=94=A8=E5=88=86?= =?UTF-8?q?=E8=BA=AB=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: mashaohua7 --- .../appmgr/include/app_mgr_service_inner.h | 25 +++++++++++-------- services/appmgr/src/app_mgr_service_inner.cpp | 4 +-- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/services/appmgr/include/app_mgr_service_inner.h b/services/appmgr/include/app_mgr_service_inner.h index 0c0202a36d..b9c7a0db25 100644 --- a/services/appmgr/include/app_mgr_service_inner.h +++ b/services/appmgr/include/app_mgr_service_inner.h @@ -306,6 +306,17 @@ public: */ virtual int32_t GetAllRunningProcesses(std::vector &info); + /** + * GetRunningMultiAppInfoByBundleName, call GetRunningMultiAppInfoByBundleName through proxy project. + * Obtains information about TwinApp that are running on the device. + * + * @param bundleName, input. + * @param info, output multiapp information. + * @return void. + */ + virtual int32_t GetRunningMultiAppInfoByBundleName(const std::string &bundleName, + RunningMultiAppInfo &info) + /** * GetRunningProcessesByBundleType, Obtains information about application processes by bundle type. * @@ -1339,16 +1350,7 @@ private: void ParseServiceExtMultiProcessWhiteList(); void ClearData(std::shared_ptr appRecord);\ - /** - * GetRunningMultiAppInfoByBundleName, call GetRunningTwinAppInfo() through proxy project. - * Obtains information about TwinApp that are running on the device. - * - * @param apprecord, input. - * @param info, output multiapp information. - * @return void. - */ - void GetRunningCloneAppInfo(const std::shared_ptr &appRecord, - RunningMultiAppInfo &info); + /** * Notify the app running status. @@ -1361,6 +1363,9 @@ private: */ void NotifyAppRunningStatusEvent( const std::string &bundle, int32_t uid, AbilityRuntime::RunningStatus runningStatus); + + void GetRunningCloneAppInfo(const std::shared_ptr &appRecord, + RunningMultiAppInfo &info); /** * To Prevent process being killed when ability is starting in an existing process, diff --git a/services/appmgr/src/app_mgr_service_inner.cpp b/services/appmgr/src/app_mgr_service_inner.cpp index 1f2877aeec..50bfa2793d 100644 --- a/services/appmgr/src/app_mgr_service_inner.cpp +++ b/services/appmgr/src/app_mgr_service_inner.cpp @@ -1448,12 +1448,12 @@ void AppMgrServiceInner::GetRunningCloneAppInfo(const std::shared_ptrGetPriorityObject(); if (!PriorityObject) { TAG_LOGE(AAFwkTag::APPMGR, "The PriorityObject is nullptr!"); - return ERR_INVALID_VALUE; + return; } if (info.mode == static_cast(MultiAppModeType::APP_CLONE)) { auto childAppRecordMap = appRecord->GetChildAppRecordMap(); From fbc71988a40a320cf28c4b6f0a00ec424f9ddccc Mon Sep 17 00:00:00 2001 From: mashaohua7 Date: Wed, 15 May 2024 19:34:19 +0800 Subject: [PATCH 059/174] =?UTF-8?q?=E9=80=9A=E8=BF=87bundlename=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E8=BF=90=E8=A1=8C=E6=97=B6=E5=BA=94=E7=94=A8=E5=88=86?= =?UTF-8?q?=E8=BA=AB=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: mashaohua7 --- services/appmgr/include/app_mgr_service_inner.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/services/appmgr/include/app_mgr_service_inner.h b/services/appmgr/include/app_mgr_service_inner.h index b9c7a0db25..dd27873299 100644 --- a/services/appmgr/include/app_mgr_service_inner.h +++ b/services/appmgr/include/app_mgr_service_inner.h @@ -1348,9 +1348,7 @@ private: bool JudgeSelfCalledByToken(const sptr &token, const PageStateData &pageStateData); void ParseServiceExtMultiProcessWhiteList(); - void ClearData(std::shared_ptr appRecord);\ - - + void ClearData(std::shared_ptr appRecord); /** * Notify the app running status. From 4e5547f629057fd0bef66fb0359cc5abb2b0ef29 Mon Sep 17 00:00:00 2001 From: wangkailong Date: Wed, 15 May 2024 19:42:12 +0800 Subject: [PATCH 060/174] embed Signed-off-by: wangkailong Change-Id: Iafe419edd49dc5bd518b93e284b9b578cffa9854 --- services/abilitymgr/src/ability_manager_service.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/services/abilitymgr/src/ability_manager_service.cpp b/services/abilitymgr/src/ability_manager_service.cpp index 886932d633..6bc2a70faf 100644 --- a/services/abilitymgr/src/ability_manager_service.cpp +++ b/services/abilitymgr/src/ability_manager_service.cpp @@ -2744,6 +2744,7 @@ int AbilityManagerService::StartUIExtensionAbility(const sptr &exte } extensionSessionInfo->want.SetElementName(bundleInfo.name, bundleInfo.abilityInfos.begin()->name); } + extensionSessionInfo->want.SetParam("send_to_erms_embedded", 1); } std::string extensionTypeStr = extensionSessionInfo->want.GetStringParam(UIEXTENSION_TYPE_KEY); AppExecFwk::ExtensionAbilityType extensionType = extensionTypeStr.empty() ? From ec892b42e42ad0e027aa7c8f500342247ff75eaa Mon Sep 17 00:00:00 2001 From: mashaohua7 Date: Wed, 15 May 2024 19:48:50 +0800 Subject: [PATCH 061/174] =?UTF-8?q?=E9=80=9A=E8=BF=87bundlename=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E8=BF=90=E8=A1=8C=E6=97=B6=E5=BA=94=E7=94=A8=E5=88=86?= =?UTF-8?q?=E8=BA=AB=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: mashaohua7 --- services/appmgr/include/app_mgr_service_inner.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/appmgr/include/app_mgr_service_inner.h b/services/appmgr/include/app_mgr_service_inner.h index dd27873299..40ef65e667 100644 --- a/services/appmgr/include/app_mgr_service_inner.h +++ b/services/appmgr/include/app_mgr_service_inner.h @@ -315,7 +315,7 @@ public: * @return void. */ virtual int32_t GetRunningMultiAppInfoByBundleName(const std::string &bundleName, - RunningMultiAppInfo &info) + RunningMultiAppInfo &info); /** * GetRunningProcessesByBundleType, Obtains information about application processes by bundle type. From 4af4f669510be485f7d6f0afc9cbf0aaa514784a Mon Sep 17 00:00:00 2001 From: mashaohua7 Date: Thu, 16 May 2024 10:18:41 +0800 Subject: [PATCH 062/174] =?UTF-8?q?=E9=80=9A=E8=BF=87bundlename=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E8=BF=90=E8=A1=8C=E6=97=B6=E5=BA=94=E7=94=A8=E5=88=86?= =?UTF-8?q?=E8=BA=AB=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: mashaohua7 --- .../include/mock_app_mgr_service_inner.h | 2 ++ .../app_mgr_service_test.cpp | 16 ++++++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/test/mock/services_appmgr_test/include/mock_app_mgr_service_inner.h b/test/mock/services_appmgr_test/include/mock_app_mgr_service_inner.h index 83712f4dfe..2c1dc07f36 100644 --- a/test/mock/services_appmgr_test/include/mock_app_mgr_service_inner.h +++ b/test/mock/services_appmgr_test/include/mock_app_mgr_service_inner.h @@ -71,6 +71,8 @@ public: MOCK_METHOD1(IsWaitingDebugApp, bool(const std::string &bundleName)); MOCK_METHOD0(ClearNonPersistWaitingDebugFlag, void()); MOCK_METHOD0(IsMemorySizeSufficent, bool()); + MOCK_METHOD2(GetRunningMultiAppInfoByBundleName, int32_t(const std::string &bundleName, + RunningMultiAppInfo &info)); void StartSpecifiedAbility(const AAFwk::Want &want, const AppExecFwk::AbilityInfo &abilityInfo) {} diff --git a/test/unittest/app_mgr_service_test/app_mgr_service_test.cpp b/test/unittest/app_mgr_service_test/app_mgr_service_test.cpp index 1e22daf5c7..5dcd476e81 100644 --- a/test/unittest/app_mgr_service_test/app_mgr_service_test.cpp +++ b/test/unittest/app_mgr_service_test/app_mgr_service_test.cpp @@ -1764,15 +1764,19 @@ HWTEST_F(AppMgrServiceTest, GetRunningMultiAppInfoByBundleName_002, TestSize.Lev { auto appMgrService = std::make_shared(); ASSERT_NE(appMgrService, nullptr); - - appMgrService->SetInnerService(std::make_shared()); + appMgrService->SetInnerService(mockAppMgrServiceInner_); appMgrService->taskHandler_ = taskHandler_; - appMgrService->eventHandler_ = std::make_shared(taskHandler_, appMgrService->appMgrServiceInner_); + appMgrService->eventHandler_ = eventHandler_; - std::string bundleName = "testBundleName"; + std::string bundleName = "testbundlename"; RunningMultiAppInfo info; - int32_t res = appMgrService->GetRunningMultiAppInfoByBundleName(bundleName, info); - EXPECT_EQ(res, ERR_INVALID_OPERATION); + + EXPECT_CALL(*mockAppMgrServiceInner_, GetRunningMultiAppInfoByBundleName(_, _)) + .Times(1) + .WillOnce(Return(ERR_OK)); + + int32_t ret = appMgrService->GetRunningMultiAppInfoByBundleName(bundleName, info); + EXPECT_EQ(ret, ERR_OK); } } // namespace AppExecFwk } // namespace OHOS From fc298340a08a6b4442eedec0d9e4f225d8c31c69 Mon Sep 17 00:00:00 2001 From: xia Date: Tue, 14 May 2024 21:18:03 +0800 Subject: [PATCH 063/174] =?UTF-8?q?fixed=206de35ff=20from=20https://gitee.?= =?UTF-8?q?com/xialiangwei/ability=5Fability=5Fruntime/pulls/8526=20amsDia?= =?UTF-8?q?log=E5=A2=9E=E5=8A=A0=E6=9D=83=E9=99=90=E5=BC=B9=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xia --- .../ams_system_dialog/AppScope/app.json | 2 +- .../JumpInterceptorServiceExtAbility.ts | 1 - .../SelectorExtensionAbility.ets | 15 ++- .../SelectorServiceExtAbility.ts | 22 ++++- .../ets/pages/permissionConfirmDialog.ets | 95 +++++++++++++++++++ .../main/resources/base/element/string.json | 12 +++ .../resources/base/profile/main_pages.json | 3 +- .../src/main/resources/zh/element/string.json | 12 +++ 8 files changed, 154 insertions(+), 8 deletions(-) create mode 100644 services/dialog_ui/ams_system_dialog/entry/src/main/ets/pages/permissionConfirmDialog.ets diff --git a/services/dialog_ui/ams_system_dialog/AppScope/app.json b/services/dialog_ui/ams_system_dialog/AppScope/app.json index 03e1745a64..0b4dfaf627 100644 --- a/services/dialog_ui/ams_system_dialog/AppScope/app.json +++ b/services/dialog_ui/ams_system_dialog/AppScope/app.json @@ -3,7 +3,7 @@ "bundleName": "com.ohos.amsdialog", "vendor": "example", "versionCode": 1000002, - "versionName": "1.0.0", + "versionName": "1.1.0", "icon": "$media:app_icon", "label": "$string:app_name", "distributedNotificationEnabled": true, diff --git a/services/dialog_ui/ams_system_dialog/entry/src/main/ets/ServiceExtAbility/JumpInterceptorServiceExtAbility.ts b/services/dialog_ui/ams_system_dialog/entry/src/main/ets/ServiceExtAbility/JumpInterceptorServiceExtAbility.ts index aeafe0cac1..0153e326b7 100644 --- a/services/dialog_ui/ams_system_dialog/entry/src/main/ets/ServiceExtAbility/JumpInterceptorServiceExtAbility.ts +++ b/services/dialog_ui/ams_system_dialog/entry/src/main/ets/ServiceExtAbility/JumpInterceptorServiceExtAbility.ts @@ -101,7 +101,6 @@ export default class JumpInterceptorServiceExtAbility extends extension { await win.hideNonSystemFloatingWindows(true); } await win.moveTo(rect.left, rect.top); - await win.resetSize(rect.width, rect.height); await win.loadContent('pages/jumpInterceptorDialog'); await win.setBackgroundColor('#00000000'); await win.show(); diff --git a/services/dialog_ui/ams_system_dialog/entry/src/main/ets/ServiceExtAbility/SelectorExtensionAbility.ets b/services/dialog_ui/ams_system_dialog/entry/src/main/ets/ServiceExtAbility/SelectorExtensionAbility.ets index 001c44426e..0fcc947b69 100644 --- a/services/dialog_ui/ams_system_dialog/entry/src/main/ets/ServiceExtAbility/SelectorExtensionAbility.ets +++ b/services/dialog_ui/ams_system_dialog/entry/src/main/ets/ServiceExtAbility/SelectorExtensionAbility.ets @@ -15,12 +15,17 @@ import UIExtensionAbility from '@ohos.app.ability.UIExtensionAbility' import UIExtensionContentSession from '@ohos.app.ability.UIExtensionContentSession' import Want from '@ohos.app.ability.Want' +import systemparameter from '@ohos.systemParameterEnhance'; +import dataPreferences from '@ohos.data.preferences'; const TAG = 'SelectorExtensionAbility'; export default class SelectorExtensionAbility extends UIExtensionAbility { onCreate() { console.info(TAG, 'SelectorExtensionAbility onCreate'); + globalThis.currentExtensionContext = this.context; + let options = {name:'dialogStore'}; + globalThis.preferences = dataPreferences.getPreferencesSync(this.context, options); } onSessionCreate(want: Want, session: UIExtensionContentSession) { @@ -29,8 +34,14 @@ export default class SelectorExtensionAbility extends UIExtensionAbility { "extensionAbility": this, "callerWant": want } as Record); - - session.loadContent("pages/PhonePage", storage); + globalThis.ExtensionType = 'UIExtension'; + if (systemparameter.getSync('persist.sys.abilityms.isdialogconfirmpermission', 'false') === 'false' && + globalThis.preferences.getSync('isdialogconfirmpermission', 'false') === 'false') { + globalThis.currentURL = 'pages/PhonePage'; + session.loadContent("pages/permissionConfirmDialog", storage); + } else { + session.loadContent("pages/PhonePage", storage); + } try { const bgColor: string = '#40FFFFFF'; } catch (e) { diff --git a/services/dialog_ui/ams_system_dialog/entry/src/main/ets/ServiceExtAbility/SelectorServiceExtAbility.ts b/services/dialog_ui/ams_system_dialog/entry/src/main/ets/ServiceExtAbility/SelectorServiceExtAbility.ts index a61719a267..981182fb84 100644 --- a/services/dialog_ui/ams_system_dialog/entry/src/main/ets/ServiceExtAbility/SelectorServiceExtAbility.ts +++ b/services/dialog_ui/ams_system_dialog/entry/src/main/ets/ServiceExtAbility/SelectorServiceExtAbility.ts @@ -22,6 +22,8 @@ import type image from '@ohos.multimedia.image'; import window from '@ohos.window'; import PositionUtils from '../utils/PositionUtils'; import deviceInfo from '@ohos.deviceInfo'; +import systemparameter from '@ohos.systemParameterEnhance'; +import dataPreferences from '@ohos.data.preferences'; const TAG = 'SelectorDialog_Service'; @@ -32,8 +34,12 @@ export default class SelectorServiceExtensionAbility extends extension { onCreate(want) { console.debug(TAG, 'onCreate, want: ' + JSON.stringify(want)); globalThis.selectExtensionContext = this.context; + globalThis.currentExtensionContext = this.context; + globalThis.ExtensionType = 'ServiceExtension'; globalThis.defaultAppManager = defaultAppManager; globalThis.bundleManager = bundleManager; + let options = {name:'dialogStore'}; + globalThis.preferences = dataPreferences.getPreferencesSync(this.context, options); } async getPhoneShowHapList() { @@ -218,10 +224,20 @@ export default class SelectorServiceExtensionAbility extends extension { } await win.moveTo(rect.left, rect.top); await win.resetSize(rect.width, rect.height); - if (globalThis.params.isDefaultSelector) { - await win.loadContent('pages/selectorPhoneDialog'); + if (systemparameter.getSync('persist.sys.abilityms.isdialogconfirmpermission', 'false') === 'false' && + globalThis.preferences.getSync('isdialogconfirmpermission', 'false') === 'false') { + if (globalThis.params.isDefaultSelector) { + globalThis.currentURL = 'pages/selectorPhoneDialog'; + } else { + globalThis.currentURL = 'pages/selectorPcDialog'; + } + await win.loadContent('pages/permissionConfirmDialog'); } else { - await win.loadContent('pages/selectorPcDialog'); + if (globalThis.params.isDefaultSelector) { + await win.loadContent('pages/selectorPhoneDialog'); + } else { + await win.loadContent('pages/selectorPcDialog'); + } } await win.setBackgroundColor('#00000000'); await win.show(); diff --git a/services/dialog_ui/ams_system_dialog/entry/src/main/ets/pages/permissionConfirmDialog.ets b/services/dialog_ui/ams_system_dialog/entry/src/main/ets/pages/permissionConfirmDialog.ets new file mode 100644 index 0000000000..40f7c9ee35 --- /dev/null +++ b/services/dialog_ui/ams_system_dialog/entry/src/main/ets/pages/permissionConfirmDialog.ets @@ -0,0 +1,95 @@ +/* + * 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 router from '@ohos.router' +import type UIExtensionContentSession from '@ohos.app.ability.UIExtensionContentSession'; +import dataPreferences from '@ohos.data.preferences'; +interface TipBtn { + color:string +} +let storage = LocalStorage.GetShared(); +@Entry(storage) +@Component +struct PermissionConfirmDialog { + @State private btn: TipBtn = { color: '#FFFFFF' } + private TAG = 'permissionconfirm_Page' + + onCloseApp() { + console.info(this.TAG, 'click close app'); + if (globalThis.ExtensionType === 'ServiceExtension') { + globalThis.currentExtensionContext.terminateSelf(); + } else { + storage.get('session').terminateSelf(); + } + } + + onConfirmApp() { + console.info(this.TAG, 'click confirm app'); + globalThis.preferences.putSync('isdialogconfirmpermission', 'true') + globalThis.preferences.flush(); + router.replaceUrl({ + url: globalThis.currentURL, + }) + } + + build() { + Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { + Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { + Text($r('app.string.message_title_permission_confirm')) + .fontSize(16) + .fontWeight(FontWeight.Medium) + .height('29%') + .textOverflow({overflow: TextOverflow.Ellipsis}) + .textAlign(TextAlign.Center) + } + Flex({ justifyContent: FlexAlign.Center }) { + Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { + Text($r('app.string.message_confirm_permission')) + .fontSize('21fp') + .fontColor('#0A59F7') + .fontWeight(FontWeight.Regular) + .textAlign(TextAlign.Center) + } + .width(175) + .height(50) + .borderRadius(28) + .backgroundColor(this.btn.color) + .onClick(() => { + this.onConfirmApp(); + }) + }.margin({ top: 10}) + Flex({ justifyContent: FlexAlign.Center }) { + Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { + Text($r('app.string.message_cancel_permission')) + .fontSize('21fp') + .fontColor('#0A59F7') + .fontWeight(FontWeight.Regular) + .textAlign(TextAlign.Center) + } + .width(175) + .height(50) + .borderRadius(28) + .backgroundColor(this.btn.color) + .onClick(() => { + this.onCloseApp(); + }) + }.margin({ top: 10}) + } + .borderRadius(20) + .borderWidth(1) + .borderColor('#e9e9e9') + .backgroundColor('#FFFFFF') + } +} \ No newline at end of file diff --git a/services/dialog_ui/ams_system_dialog/entry/src/main/resources/base/element/string.json b/services/dialog_ui/ams_system_dialog/entry/src/main/resources/base/element/string.json index effea732c1..050c501d57 100644 --- a/services/dialog_ui/ams_system_dialog/entry/src/main/resources/base/element/string.json +++ b/services/dialog_ui/ams_system_dialog/entry/src/main/resources/base/element/string.json @@ -91,6 +91,18 @@ { "name": "title_assertFault", "value": "AssertFaultDialog" + }, + { + "name": "message_title_permission_confirm", + "value": "The amsdialog application wants to query the list of application software information" + }, + { + "name": "message_confirm_permission", + "value": "allow" + }, + { + "name": "message_cancel_permission", + "value": "disallow" } ] } \ No newline at end of file diff --git a/services/dialog_ui/ams_system_dialog/entry/src/main/resources/base/profile/main_pages.json b/services/dialog_ui/ams_system_dialog/entry/src/main/resources/base/profile/main_pages.json index 59a4f56138..8a5cc50ddb 100644 --- a/services/dialog_ui/ams_system_dialog/entry/src/main/resources/base/profile/main_pages.json +++ b/services/dialog_ui/ams_system_dialog/entry/src/main/resources/base/profile/main_pages.json @@ -6,6 +6,7 @@ "pages/tipsDialog", "pages/jumpInterceptorDialog", "pages/PhonePage", - "pages/assertFaultDialog" + "pages/assertFaultDialog", + "pages/permissionConfirmDialog" ] } diff --git a/services/dialog_ui/ams_system_dialog/entry/src/main/resources/zh/element/string.json b/services/dialog_ui/ams_system_dialog/entry/src/main/resources/zh/element/string.json index c4c7a58c17..e011b49e95 100644 --- a/services/dialog_ui/ams_system_dialog/entry/src/main/resources/zh/element/string.json +++ b/services/dialog_ui/ams_system_dialog/entry/src/main/resources/zh/element/string.json @@ -111,6 +111,18 @@ { "name": "title_assertFault", "value": "AssertFaultDialog" + }, + { + "name": "message_title_permission_confirm", + "value": "amsdialog应用想要查询应用软件列表信息" + }, + { + "name": "message_confirm_permission", + "value": "允许" + }, + { + "name": "message_cancel_permission", + "value": "拒绝" } ] } \ No newline at end of file From ba6dc2b30dbf8f77bdd9f408089152c97a0058af Mon Sep 17 00:00:00 2001 From: mashaohua7 Date: Thu, 16 May 2024 02:44:51 +0000 Subject: [PATCH 064/174] update test/unittest/app_mgr_service_test/app_mgr_service_test.cpp. Signed-off-by: mashaohua7 --- .../app_mgr_service_test/app_mgr_service_test.cpp | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/test/unittest/app_mgr_service_test/app_mgr_service_test.cpp b/test/unittest/app_mgr_service_test/app_mgr_service_test.cpp index d199c21956..5d35153574 100644 --- a/test/unittest/app_mgr_service_test/app_mgr_service_test.cpp +++ b/test/unittest/app_mgr_service_test/app_mgr_service_test.cpp @@ -1764,16 +1764,6 @@ HWTEST_F(AppMgrServiceTest, GetRunningMultiAppInfoByBundleName_002, TestSize.Lev { auto appMgrService = std::make_shared(); ASSERT_NE(appMgrService, nullptr); -/** - * @tc.name: StartNativeChildProcess_0100 - * @tc.desc: Start native child process. - * @tc.type: FUNC - */ -HWTEST_F(AppMgrServiceTest, StartNativeChildProcess_0100, TestSize.Level1) -{ - TAG_LOGD(AAFwkTag::TEST, "StartNativeChildProcess_0100 called."); - sptr appMgrService = new (std::nothrow) AppMgrService(); - ASSERT_NE(appMgrService, nullptr); appMgrService->SetInnerService(mockAppMgrServiceInner_); appMgrService->taskHandler_ = taskHandler_; From 5b7f83232669150979b9be6e3c34dae82b3e8d07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=8F=E8=89=AF=E4=BC=9F?= Date: Thu, 16 May 2024 02:45:47 +0000 Subject: [PATCH 065/174] 111 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 夏良伟 --- .../ets/ServiceExtAbility/JumpInterceptorServiceExtAbility.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/services/dialog_ui/ams_system_dialog/entry/src/main/ets/ServiceExtAbility/JumpInterceptorServiceExtAbility.ts b/services/dialog_ui/ams_system_dialog/entry/src/main/ets/ServiceExtAbility/JumpInterceptorServiceExtAbility.ts index 0153e326b7..aeafe0cac1 100644 --- a/services/dialog_ui/ams_system_dialog/entry/src/main/ets/ServiceExtAbility/JumpInterceptorServiceExtAbility.ts +++ b/services/dialog_ui/ams_system_dialog/entry/src/main/ets/ServiceExtAbility/JumpInterceptorServiceExtAbility.ts @@ -101,6 +101,7 @@ export default class JumpInterceptorServiceExtAbility extends extension { await win.hideNonSystemFloatingWindows(true); } await win.moveTo(rect.left, rect.top); + await win.resetSize(rect.width, rect.height); await win.loadContent('pages/jumpInterceptorDialog'); await win.setBackgroundColor('#00000000'); await win.show(); From 157321cb867ddce0c3bf7b103eee1404b6416991 Mon Sep 17 00:00:00 2001 From: mashaohua7 Date: Thu, 16 May 2024 02:46:21 +0000 Subject: [PATCH 066/174] update test/mock/services_appmgr_test/include/mock_app_mgr_service_inner.h. Signed-off-by: mashaohua7 --- .../services_appmgr_test/include/mock_app_mgr_service_inner.h | 1 - 1 file changed, 1 deletion(-) diff --git a/test/mock/services_appmgr_test/include/mock_app_mgr_service_inner.h b/test/mock/services_appmgr_test/include/mock_app_mgr_service_inner.h index f80c0f76fd..e8ffaf5795 100644 --- a/test/mock/services_appmgr_test/include/mock_app_mgr_service_inner.h +++ b/test/mock/services_appmgr_test/include/mock_app_mgr_service_inner.h @@ -73,7 +73,6 @@ public: MOCK_METHOD0(IsMemorySizeSufficent, bool()); MOCK_METHOD2(GetRunningMultiAppInfoByBundleName, int32_t(const std::string &bundleName, RunningMultiAppInfo &info)); - void StartSpecifiedAbility(const AAFwk::Want &want, const AppExecFwk::AbilityInfo &abilityInfo) MOCK_METHOD4(StartNativeChildProcess, int32_t(const pid_t hostPid, const std::string &libName, int32_t childProcessCount, const sptr &callback)); void StartSpecifiedAbility(const AAFwk::Want&, const AppExecFwk::AbilityInfo&, int32_t) From ae095f86ca614df882d57391b9fd5c1faa952380 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=8F=E8=89=AF=E4=BC=9F?= Date: Thu, 16 May 2024 02:46:45 +0000 Subject: [PATCH 067/174] update services/dialog_ui/ams_system_dialog/entry/src/main/resources/base/element/string.json. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 夏良伟 --- .../entry/src/main/resources/base/element/string.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/dialog_ui/ams_system_dialog/entry/src/main/resources/base/element/string.json b/services/dialog_ui/ams_system_dialog/entry/src/main/resources/base/element/string.json index 050c501d57..9fe4c646f4 100644 --- a/services/dialog_ui/ams_system_dialog/entry/src/main/resources/base/element/string.json +++ b/services/dialog_ui/ams_system_dialog/entry/src/main/resources/base/element/string.json @@ -102,7 +102,7 @@ }, { "name": "message_cancel_permission", - "value": "disallow" + "value": "reject" } ] } \ No newline at end of file From a7eeb68572d9ba4eb1d1d2694b2380cbe231c128 Mon Sep 17 00:00:00 2001 From: mashaohua7 Date: Thu, 16 May 2024 02:51:58 +0000 Subject: [PATCH 068/174] update test/unittest/app_mgr_service_test/app_mgr_service_test.cpp. Signed-off-by: mashaohua7 --- test/unittest/app_mgr_service_test/app_mgr_service_test.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/test/unittest/app_mgr_service_test/app_mgr_service_test.cpp b/test/unittest/app_mgr_service_test/app_mgr_service_test.cpp index 5d35153574..3aa32e8a8d 100644 --- a/test/unittest/app_mgr_service_test/app_mgr_service_test.cpp +++ b/test/unittest/app_mgr_service_test/app_mgr_service_test.cpp @@ -1764,7 +1764,6 @@ HWTEST_F(AppMgrServiceTest, GetRunningMultiAppInfoByBundleName_002, TestSize.Lev { auto appMgrService = std::make_shared(); ASSERT_NE(appMgrService, nullptr); - appMgrService->SetInnerService(mockAppMgrServiceInner_); appMgrService->taskHandler_ = taskHandler_; appMgrService->eventHandler_ = eventHandler_; @@ -1779,6 +1778,5 @@ HWTEST_F(AppMgrServiceTest, GetRunningMultiAppInfoByBundleName_002, TestSize.Lev int32_t ret = appMgrService->GetRunningMultiAppInfoByBundleName(bundleName, info); EXPECT_EQ(ret, ERR_OK); } - } // namespace AppExecFwk -} // namespace OHOS +} // namespace OHOS \ No newline at end of file From 1e1dd10939b7a2a558df52dfe76424ee4a9f8261 Mon Sep 17 00:00:00 2001 From: huangshiwei Date: Thu, 16 May 2024 10:52:45 +0800 Subject: [PATCH 069/174] huangshiwei4@huawei.com Signed-off-by: huangshiwei --- .../deeplink_reserve_config.cpp | 5 +++ .../src/implicit_start_processor.cpp | 2 +- services/abilitymgr/src/rdb/parser_util.cpp | 6 ++++ .../abilitymgr/src/start_ability_utils.cpp | 8 ++--- services/appmgr/src/app_spawn_client.cpp | 31 ++++++++++++------- 5 files changed, 35 insertions(+), 17 deletions(-) diff --git a/services/abilitymgr/src/deeplink_reserve/deeplink_reserve_config.cpp b/services/abilitymgr/src/deeplink_reserve/deeplink_reserve_config.cpp index fd4f1987a4..b89cfe266b 100644 --- a/services/abilitymgr/src/deeplink_reserve/deeplink_reserve_config.cpp +++ b/services/abilitymgr/src/deeplink_reserve/deeplink_reserve_config.cpp @@ -257,6 +257,11 @@ bool DeepLinkReserveConfig::ReadFileInfoJson(const std::string &filePath, nlohma return false; } + if (filePath.empty()) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "File path is empty."); + return false; + } + std::fstream in; char errBuf[256]; errBuf[0] = '\0'; diff --git a/services/abilitymgr/src/implicit_start_processor.cpp b/services/abilitymgr/src/implicit_start_processor.cpp index 2802c624c6..749b7b737e 100644 --- a/services/abilitymgr/src/implicit_start_processor.cpp +++ b/services/abilitymgr/src/implicit_start_processor.cpp @@ -359,7 +359,7 @@ int ImplicitStartProcessor::GenerateAbilityRequestByAction(int32_t userId, } if (uriReservedFlag_) { - abilityInfoFlag = abilityInfoFlag | + abilityInfoFlag = static_cast(abilityInfoFlag) | static_cast(AppExecFwk::GetAbilityInfoFlag::GET_ABILITY_INFO_ONLY_SYSTEM_APP); } diff --git a/services/abilitymgr/src/rdb/parser_util.cpp b/services/abilitymgr/src/rdb/parser_util.cpp index feab00dddc..4738451f73 100644 --- a/services/abilitymgr/src/rdb/parser_util.cpp +++ b/services/abilitymgr/src/rdb/parser_util.cpp @@ -16,6 +16,7 @@ #include "parser_util.h" #include +#include #include "config_policy_utils.h" #include "hilog_tag_wrapper.h" @@ -145,6 +146,11 @@ void ParserUtil::GetPreInstallRootDirList(std::vector &rootDirList) bool ParserUtil::ReadFileIntoJson(const std::string &filePath, nlohmann::json &jsonBuf) { + if (access(filePath.c_str(), F_OK) != 0) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "File path is not exist."); + return false; + } + if (filePath.empty()) { TAG_LOGE(AAFwkTag::ABILITYMGR, "File path empty."); return false; diff --git a/services/abilitymgr/src/start_ability_utils.cpp b/services/abilitymgr/src/start_ability_utils.cpp index 9a76da48f6..e3d843ccc4 100644 --- a/services/abilitymgr/src/start_ability_utils.cpp +++ b/services/abilitymgr/src/start_ability_utils.cpp @@ -151,8 +151,8 @@ std::shared_ptr StartAbilityInfo::CreateStartAbilityInfo(const HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); auto bms = AbilityUtil::GetBundleManagerHelper(); CHECK_POINTER_AND_RETURN(bms, nullptr); - auto abilityInfoFlag = AbilityRuntime::StartupUtil::BuildAbilityInfoFlag() | - AppExecFwk::AbilityInfoFlag::GET_ABILITY_INFO_WITH_SKILL; + auto abilityInfoFlag = static_cast(AbilityRuntime::StartupUtil::BuildAbilityInfoFlag()) | + static_cast(AppExecFwk::AbilityInfoFlag::GET_ABILITY_INFO_WITH_SKILL); auto request = std::make_shared(); if (appIndex != 0 && appIndex <= AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX) { IN_PROCESS_CALL_WITHOUT_RET(bms->QueryCloneAbilityInfo(want.GetElement(), abilityInfoFlag, appIndex, @@ -203,8 +203,8 @@ std::shared_ptr StartAbilityInfo::CreateStartExtensionInfo(con HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); auto bms = AbilityUtil::GetBundleManagerHelper(); CHECK_POINTER_AND_RETURN(bms, nullptr); - auto abilityInfoFlag = AbilityRuntime::StartupUtil::BuildAbilityInfoFlag() | - AppExecFwk::AbilityInfoFlag::GET_ABILITY_INFO_WITH_SKILL; + auto abilityInfoFlag = static_cast(AbilityRuntime::StartupUtil::BuildAbilityInfoFlag()) | + static_cast(AppExecFwk::AbilityInfoFlag::GET_ABILITY_INFO_WITH_SKILL); auto abilityInfo = std::make_shared(); std::vector extensionInfos; diff --git a/services/appmgr/src/app_spawn_client.cpp b/services/appmgr/src/app_spawn_client.cpp index 8257705653..5f23a755c9 100644 --- a/services/appmgr/src/app_spawn_client.cpp +++ b/services/appmgr/src/app_spawn_client.cpp @@ -187,9 +187,11 @@ int32_t AppSpawnClient::SetStartFlags(const AppSpawnStartMsg &startMsg, AppSpawn int32_t AppSpawnClient::SetAtomicServiceFlag(const AppSpawnStartMsg &startMsg, AppSpawnReqMsgHandle reqHandle) { int32_t ret = 0; - if (startMsg.atomicServiceFlag && - (ret = AppSpawnReqMsgSetAppFlag(reqHandle, APP_FLAGS_ATOMIC_SERVICE))) { - HILOG_ERROR("AppSpawnReqMsgSetAppFlag failed, ret: %{public}d", ret); + if (startMsg.atomicServiceFlag) { + ret = AppSpawnReqMsgSetAppFlag(reqHandle, APP_FLAGS_ATOMIC_SERVICE); + if (ret) { + TAG_LOGE(AAFwkTag::APPMGR, "AppSpawnReqMsgSetAppFlag failed, ret: %{public}d", ret); + } } return ret; } @@ -235,17 +237,22 @@ int32_t AppSpawnClient::AppspawnSetExtMsg(const AppSpawnStartMsg &startMsg, AppS return ret; } } - if (!startMsg.atomicAccount.empty() && - (ret = AppSpawnReqMsgAddExtInfo(reqHandle, MSG_EXT_NAME_ACCOUNT_ID, - reinterpret_cast(startMsg.atomicAccount.c_str()), startMsg.atomicAccount.size()))) { - HILOG_ERROR("AppSpawnReqMsgAddExtInfo failed, ret: %{public}d", ret); - return ret; + + if (!startMsg.atomicAccount.empty()) { + ret = AppSpawnReqMsgAddExtInfo(reqHandle, MSG_EXT_NAME_ACCOUNT_ID, + reinterpret_cast(startMsg.atomicAccount.c_str()), startMsg.atomicAccount.size()); + if (ret) { + TAG_LOGE(AAFwkTag::APPMGR, "AppSpawnReqMsgAddExtInfo failed, ret: %{public}d", ret); + return ret; + } } - if (!startMsg.provisionType.empty() && - (ret = AppSpawnReqMsgAddStringInfo(reqHandle, MSG_EXT_NAME_PROVISION_TYPE, startMsg.provisionType.c_str()))) { - HILOG_ERROR("SetExtraProvisionType failed, ret: %{public}d", ret); - return ret; + if (!startMsg.provisionType.empty()) { + ret = AppSpawnReqMsgAddStringInfo(reqHandle, MSG_EXT_NAME_PROVISION_TYPE, startMsg.provisionType.c_str()); + if (ret) { + TAG_LOGE(AAFwkTag::APPMGR, "SetExtraProvisionType failed, ret: %{public}d", ret); + return ret; + } } return ret; From 699a151e4b2bcd713625e9f293304512da393828 Mon Sep 17 00:00:00 2001 From: mashaohua7 Date: Thu, 16 May 2024 02:57:44 +0000 Subject: [PATCH 070/174] update test/unittest/app_mgr_service_test/app_mgr_service_test.cpp. Signed-off-by: mashaohua7 --- .../app_mgr_service_test.cpp | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/test/unittest/app_mgr_service_test/app_mgr_service_test.cpp b/test/unittest/app_mgr_service_test/app_mgr_service_test.cpp index 3aa32e8a8d..ee2239d401 100644 --- a/test/unittest/app_mgr_service_test/app_mgr_service_test.cpp +++ b/test/unittest/app_mgr_service_test/app_mgr_service_test.cpp @@ -1732,6 +1732,31 @@ HWTEST_F(AppMgrServiceTest, SetSupportedProcessCacheSelf_002, TestSize.Level0) EXPECT_EQ(res, AAFwk::ERR_SET_SUPPORTED_PROCESS_CACHE_AGAIN); } +/** + * @tc.name: StartNativeChildProcess_0100 + * @tc.desc: Start native child process. + * @tc.type: FUNC + */ +HWTEST_F(AppMgrServiceTest, StartNativeChildProcess_0100, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "StartNativeChildProcess_0100 called."); + sptr appMgrService = new (std::nothrow) AppMgrService(); + ASSERT_NE(appMgrService, nullptr); + + appMgrService->SetInnerService(mockAppMgrServiceInner_); + appMgrService->taskHandler_ = taskHandler_; + appMgrService->eventHandler_ = eventHandler_; + + EXPECT_CALL(*mockAppMgrServiceInner_, StartNativeChildProcess(_, _, _, _)) + .Times(1) + .WillOnce(Return(ERR_OK)); + + pid_t pid = 0; + sptr callback; + int32_t res = appMgrService->StartNativeChildProcess("test.so", 1, callback); + EXPECT_EQ(res, ERR_OK); +} + /* * Feature: AppMgrService * Function: GetRunningMultiAppInfoByBundleName From 583d9174ffeaf8ce8f17b6596c30875bd50d43d5 Mon Sep 17 00:00:00 2001 From: mashaohua7 Date: Thu, 16 May 2024 03:21:28 +0000 Subject: [PATCH 071/174] update frameworks/js/napi/app/js_app_manager/js_app_manager.cpp. Signed-off-by: mashaohua7 --- frameworks/js/napi/app/js_app_manager/js_app_manager.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/frameworks/js/napi/app/js_app_manager/js_app_manager.cpp b/frameworks/js/napi/app/js_app_manager/js_app_manager.cpp index aa69138ee6..2bea911451 100644 --- a/frameworks/js/napi/app/js_app_manager/js_app_manager.cpp +++ b/frameworks/js/napi/app/js_app_manager/js_app_manager.cpp @@ -1195,11 +1195,9 @@ napi_value JsAppManagerInit(napi_env env, napi_value exportObj) TAG_LOGW(AAFwkTag::APPMGR, "env or exportObj null"); return nullptr; } - std::unique_ptr jsAppManager = std::make_unique( GetAppManagerInstance(), GetAbilityManagerInstance()); napi_wrap(env, exportObj, jsAppManager.release(), JsAppManager::Finalizer, nullptr, nullptr); - napi_set_named_property(env, exportObj, "ApplicationState", ApplicationStateInit(env)); napi_set_named_property(env, exportObj, "ProcessState", ProcessStateInit(env)); napi_set_named_property(env, exportObj, "PreloadMode", PreloadModeInit(env)); From 8a65264a36a4336ca2e61ed31b0abed14121c7e8 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 16 May 2024 12:33:11 +0800 Subject: [PATCH 072/174] fix connect Signed-off-by: unknown --- .../native/ability/ability_runtime/connection_manager.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/frameworks/native/ability/ability_runtime/connection_manager.cpp b/frameworks/native/ability/ability_runtime/connection_manager.cpp index 72e3be8d82..dd30aeed4b 100644 --- a/frameworks/native/ability/ability_runtime/connection_manager.cpp +++ b/frameworks/native/ability/ability_runtime/connection_manager.cpp @@ -255,8 +255,7 @@ void ConnectionManager::DisconnectNonexistentService( for (auto &&abilityConnection : abilityConnections) { ConnectionInfo connectionInfo = abilityConnection.first; if (connectionInfo.abilityConnection == connection && - connectionInfo.connectReceiver.GetBundleName() == element.GetBundleName() && - connectionInfo.connectReceiver.GetAbilityName() == element.GetAbilityName()) { + connectionInfo.connectReceiver.GetBundleName() == element.GetBundleName()) { HILOG_DEBUG("find connection."); exit = true; break; From baaeb0b81cfa63cb008f59637a7380076039e6a3 Mon Sep 17 00:00:00 2001 From: yangxuguang-huawei Date: Thu, 16 May 2024 14:21:43 +0800 Subject: [PATCH 073/174] refactor: ffrt_dump Signed-off-by: yangxuguang-huawei --- frameworks/native/appkit/app/dump_ffrt_helper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/native/appkit/app/dump_ffrt_helper.cpp b/frameworks/native/appkit/app/dump_ffrt_helper.cpp index 13f705d6da..ee589fa8aa 100644 --- a/frameworks/native/appkit/app/dump_ffrt_helper.cpp +++ b/frameworks/native/appkit/app/dump_ffrt_helper.cpp @@ -26,7 +26,7 @@ int DumpFfrtHelper::DumpFfrt(std::string& result) { result.resize(MAX_BUF_SIZE); - int printNum = ffrt_dump(static_cast(ffrt_dump_cmd_t::DUMP_INFO_ALL), &result[0], MAX_BUF_SIZE); + int printNum = ffrt_dump(ffrt_dump_cmd_t::DUMP_INFO_ALL, &result[0], MAX_BUF_SIZE); if (printNum > 0) { result.resize(printNum); return 0; From 33ff07df3e0226e164e6f7e658973eff027b95ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=AE=B5=E5=97=A3=E9=92=8A?= Date: Wed, 15 May 2024 19:49:10 +0800 Subject: [PATCH 074/174] =?UTF-8?q?=E4=BF=AE=E5=A4=8DURI=E6=8E=88=E6=9D=83?= =?UTF-8?q?=E9=81=97=E6=BC=8F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 段嗣钊 Change-Id: I2a533de0a94efd9cec7c5a067f0555e0564afa14 --- .../src/ability_manager_service.cpp | 3 +- services/abilitymgr/src/ability_record.cpp | 4 +- .../src/uri_permission_manager_stub_impl.cpp | 16 ++++-- .../uri_permission_impl_test.cpp | 50 ++++++++++++++++++- 4 files changed, 64 insertions(+), 9 deletions(-) diff --git a/services/abilitymgr/src/ability_manager_service.cpp b/services/abilitymgr/src/ability_manager_service.cpp index 886932d633..92b1f71e66 100644 --- a/services/abilitymgr/src/ability_manager_service.cpp +++ b/services/abilitymgr/src/ability_manager_service.cpp @@ -9855,7 +9855,8 @@ void AbilityManagerService::NotifyStartResidentProcess(std::vector bool AbilityRecord::GrantPermissionToShell(const std::vector &strUriVec, uint32_t flag, std::string targetPkg) { + TAG_LOGD(AAFwkTag::ABILITYMGR, "Grant uri permission to shell."); std::vector uriVec; for (auto&& str : strUriVec) { Uri uri(str); auto&& scheme = uri.GetScheme(); if (scheme != "content") { return false; - } else { - uriVec.emplace_back(uri); } + uriVec.emplace_back(uri); } uint32_t initiatorTokenId = IPCSkeleton::GetCallingTokenID(); diff --git a/services/uripermmgr/src/uri_permission_manager_stub_impl.cpp b/services/uripermmgr/src/uri_permission_manager_stub_impl.cpp index 6d5703a415..86aa481eed 100644 --- a/services/uripermmgr/src/uri_permission_manager_stub_impl.cpp +++ b/services/uripermmgr/src/uri_permission_manager_stub_impl.cpp @@ -130,10 +130,12 @@ int32_t UriPermissionManagerStubImpl::GrantUriPermissionPrivileged(const std::ve { TAG_LOGI(AAFwkTag::URIPERMMGR, "BundleName is %{public}s, appIndex is %{public}d, size of uriVec is %{public}zu.", targetBundleName.c_str(), appIndex, uriVec.size()); + uint32_t callerTokenId = IPCSkeleton::GetCallingTokenID(); auto callerName = GetTokenName(callerTokenId); TAG_LOGD(AAFwkTag::URIPERMMGR, "callerTokenId is %{public}u, callerName is %{public}s", callerTokenId, callerName.c_str()); + auto permissionName = PermissionConstants::PERMISSION_GRANT_URI_PERMISSION_PRIVILEGED; if (!PermissionVerification::GetInstance()->VerifyPermissionByTokenId(callerTokenId, permissionName) && !IsLinuxFusionCall()) { @@ -147,7 +149,7 @@ int32_t UriPermissionManagerStubImpl::GrantUriPermissionPrivileged(const std::ve } flag &= FLAG_READ_WRITE_URI; uint32_t targetTokenId = 0; - auto ret = GetTokenIdByBundleName(targetBundleName, 0, targetTokenId); + auto ret = GetTokenIdByBundleName(targetBundleName, appIndex, targetTokenId); if (ret != ERR_OK) { TAG_LOGE(AAFwkTag::URIPERMMGR, "Get tokenId failed, bundlename is %{public}s.", targetBundleName.c_str()); return ret; @@ -238,9 +240,9 @@ int UriPermissionManagerStubImpl::AddTempUriPermission(const std::string &uri, u auto search = uriMap_.find(uri); bool autoRemove = (abilityId != DEFAULT_ABILITY_ID); GrantInfo info = { flag, fromTokenId, targetTokenId, autoRemove, {} }; + info.AddAbilityId(abilityId); if (search == uriMap_.end()) { TAG_LOGI(AAFwkTag::URIPERMMGR, "Insert an uri r/w permission."); - info.AddAbilityId(abilityId); std::list infoList = { info }; uriMap_.emplace(uri, infoList); return ERR_OK; @@ -271,7 +273,7 @@ int UriPermissionManagerStubImpl::AddTempUriPermission(const std::string &uri, u return ERR_OK; } } - TAG_LOGI(AAFwkTag::URIPERMMGR, "Insert an new uri permission record."); + TAG_LOGI(AAFwkTag::URIPERMMGR, "Insert a new uri permission record."); infoList.emplace_back(info); return ERR_OK; } @@ -464,12 +466,12 @@ void UriPermissionManagerStubImpl::RemoveUriRecord(std::vector &uri } if (!it->IsEmptyAbilityId()) { TAG_LOGD(AAFwkTag::URIPERMMGR, "Remove an abilityId."); - return; + break; } TAG_LOGI(AAFwkTag::URIPERMMGR, "Erase an info form list."); list.erase(it); uriList.emplace_back(iter->first); - return; + break; } if (list.empty()) { uriMap_.erase(iter++); @@ -958,6 +960,10 @@ bool UriPermissionManagerStubImpl::CheckUriPermission(Uri uri, uint32_t flag, To TAG_LOGI(AAFwkTag::URIPERMMGR, "Caller is linux_fusion_service."); return true; } + if (uri.GetScheme() == "content") { + TAG_LOGI(AAFwkTag::URIPERMMGR, "uri is content type."); + return IsFoundationCall(); + } if (authority == "docs") { return AccessDocsUriPermission(tokenIdPermission, uri, flag); } diff --git a/test/unittest/uri_permission_impl_test/uri_permission_impl_test.cpp b/test/unittest/uri_permission_impl_test/uri_permission_impl_test.cpp index 9bb42a6b05..ee008dc57f 100755 --- a/test/unittest/uri_permission_impl_test/uri_permission_impl_test.cpp +++ b/test/unittest/uri_permission_impl_test/uri_permission_impl_test.cpp @@ -328,19 +328,38 @@ HWTEST_F(UriPermissionImplTest, Upms_VerifyUriPermission_001, TestSize.Level1) std::string uri = "file://com.example.test/data/storage/el2/base/haps/entry/files/test_A.txt"; auto flagRead = 1; auto flagWrite = 2; - + auto flagReadWrite = 3; + // read + upms->uriMap_.clear(); upms->AddTempUriPermission(uri, flagRead, callerTokenId, targetTokenId, 0); auto ret = upms->VerifyUriPermission(Uri(uri), flagRead, targetTokenId); ASSERT_EQ(ret, true); ret = upms->VerifyUriPermission(Uri(uri), flagWrite, targetTokenId); ASSERT_EQ(ret, false); + ret = upms->VerifyUriPermission(Uri(uri), flagReadWrite, targetTokenId); + ASSERT_EQ(ret, false); + // write + upms->uriMap_.clear(); upms->AddTempUriPermission(uri, flagWrite, callerTokenId, targetTokenId, 0); ret = upms->VerifyUriPermission(Uri(uri), flagRead, targetTokenId); ASSERT_EQ(ret, true); ret = upms->VerifyUriPermission(Uri(uri), flagWrite, targetTokenId); ASSERT_EQ(ret, true); + ret = upms->VerifyUriPermission(Uri(uri), flagReadWrite, targetTokenId); + ASSERT_EQ(ret, true); + // flagReadWrite + upms->uriMap_.clear(); + upms->AddTempUriPermission(uri, flagReadWrite, callerTokenId, targetTokenId, 0); + ret = upms->VerifyUriPermission(Uri(uri), flagRead, targetTokenId); + ASSERT_EQ(ret, true); + ret = upms->VerifyUriPermission(Uri(uri), flagWrite, targetTokenId); + ASSERT_EQ(ret, true); + ret = upms->VerifyUriPermission(Uri(uri), flagReadWrite, targetTokenId); + ASSERT_EQ(ret, true); + + // no permission record ret = upms->VerifyUriPermission(Uri(uri), flagRead, invalidTokenId); ASSERT_EQ(ret, false); } @@ -593,6 +612,35 @@ HWTEST_F(UriPermissionImplTest, Upms_CheckUriPermission_004, TestSize.Level1) MyFlag::permissionProxyAuthorization_ = false; } +/* + * Feature: UriPermissionManagerStubImpl + * Function: CheckUriPermission + * SubFunction: NA + * FunctionPoints: Check content uri. +*/ +HWTEST_F(UriPermissionImplTest, Upms_CheckUriPermission_005, TestSize.Level1) +{ + auto upms = std::make_unique(); + ASSERT_NE(upms, nullptr); + MyFlag::flag_ |= MyFlag::IS_SA_CALL; + auto uri = Uri("content://com.example.app1001/data/storage/el2/base/haps/entry/files/test_001.txt"); + uint32_t flagRead = 1; + + uint32_t callerTokenId1 = 1001; + IPCSkeleton::callerTokenId = callerTokenId1; + MyFlag::tokenInfos[callerTokenId1] = TokenInfo(callerTokenId1, MyATokenTypeEnum::TOKEN_NATIVE, "foundation"); + TokenIdPermission tokenIdPermission1(callerTokenId1); + auto ret = upms->CheckUriPermission(uri, flagRead, tokenIdPermission1); + ASSERT_EQ(ret, true); + + uint32_t callerTokenId2 = 1002; + IPCSkeleton::callerTokenId = callerTokenId2; + MyFlag::tokenInfos[callerTokenId2] = TokenInfo(callerTokenId2, MyATokenTypeEnum::TOKEN_NATIVE, "testProcess"); + TokenIdPermission tokenIdPermission2(callerTokenId2); + ret = upms->CheckUriPermission(uri, flagRead, tokenIdPermission2); + ASSERT_EQ(ret, false); +} + /* * Feature: UriPermissionManagerStubImpl * Function: RevokeAllUriPermission From c7bad4f31a03395006eaa21c8435449eb27e6bee Mon Sep 17 00:00:00 2001 From: liuyaoqian Date: Thu, 16 May 2024 08:32:32 +0000 Subject: [PATCH 075/174] update frameworks/native/ability/native/ability_runtime/js_ability_context.cpp. Signed-off-by: liuyaoqian --- .../ability/native/ability_runtime/js_ability_context.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/frameworks/native/ability/native/ability_runtime/js_ability_context.cpp b/frameworks/native/ability/native/ability_runtime/js_ability_context.cpp index 2388a606bb..14bd12a881 100644 --- a/frameworks/native/ability/native/ability_runtime/js_ability_context.cpp +++ b/frameworks/native/ability/native/ability_runtime/js_ability_context.cpp @@ -1224,8 +1224,7 @@ napi_value JsAbilityContext::OnConnectAbilityWithAccount(napi_env env, NapiCallb AAFwk::Want want; OHOS::AppExecFwk::UnwrapWant(env, info.argv[INDEX_ZERO], want); TAG_LOGI(AAFwkTag::CONTEXT, "ConnectAbilityWithAccount, bundlename:%{public}s abilityname:%{public}s", - want.GetBundle().c_str(), - want.GetElement().GetAbilityName().c_str()); + want.GetBundle().c_str(), want.GetElement().GetAbilityName().c_str()); int32_t accountId = 0; if (!OHOS::AppExecFwk::UnwrapInt32FromJS2(env, info.argv[INDEX_ONE], accountId)) { From af09b5eb594ea72b8704b50e8eefe7d200a41c09 Mon Sep 17 00:00:00 2001 From: liuyaoqian Date: Thu, 16 May 2024 08:33:39 +0000 Subject: [PATCH 076/174] update frameworks/native/ability/native/data_ability_operation.cpp. Signed-off-by: liuyaoqian --- frameworks/native/ability/native/data_ability_operation.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/frameworks/native/ability/native/data_ability_operation.cpp b/frameworks/native/ability/native/data_ability_operation.cpp index 12ba97882b..86c8a156dc 100644 --- a/frameworks/native/ability/native/data_ability_operation.cpp +++ b/frameworks/native/ability/native/data_ability_operation.cpp @@ -351,8 +351,7 @@ bool DataAbilityOperation::Marshalling(Parcel &out) const } int referenceSize = (int)dataAbilityPredicatesBackReferences_.size(); if (dataAbilityPredicatesBackReferences_.empty()) { - TAG_LOGD( - AAFwkTag::DATA_ABILITY, "DataAbilityOperation::Marshalling dataAbilityPredicatesBackReferences_ is empty"); + TAG_LOGD(AAFwkTag::DATA_ABILITY, "DataAbilityOperation::Marshalling dataAbilityPredicatesBackReferences_:null"); if (!out.WriteInt32(referenceSize)) { TAG_LOGE(AAFwkTag::DATA_ABILITY, "DataAbilityOperation::Marshalling WriteInt32(VALUE_OBJECT) error"); return false; From a290f8531b4192cfaae9201cf0d0d593e37deb04 Mon Sep 17 00:00:00 2001 From: liuyaoqian Date: Thu, 16 May 2024 08:35:29 +0000 Subject: [PATCH 077/174] update frameworks/native/ability/native/js_service_extension.cpp. Signed-off-by: liuyaoqian --- frameworks/native/ability/native/js_service_extension.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/frameworks/native/ability/native/js_service_extension.cpp b/frameworks/native/ability/native/js_service_extension.cpp index 42e69ddfb0..603ce5f62f 100644 --- a/frameworks/native/ability/native/js_service_extension.cpp +++ b/frameworks/native/ability/native/js_service_extension.cpp @@ -451,8 +451,7 @@ bool JsServiceExtension::HandleInsightIntent(const AAFwk::Want &want) static_cast(AbilityErrorCode::ERROR_CODE_INVALID_PARAM)); return false; } - TAG_LOGD(AAFwkTag::SERVICE_EXT, - "Insight intent bundleName: %{public}s, moduleName: %{public}s, abilityName: %{public}s" + TAG_LOGD(AAFwkTag::SERVICE_EXT, "Insight bundleName: %{public}s, moduleName: %{public}s, abilityName: %{public}s" "insightIntentName: %{public}s, executeMode: %{public}d, intentId: %{public}" PRIu64 "", executeParam->bundleName_.c_str(), executeParam->moduleName_.c_str(), executeParam->abilityName_.c_str(), executeParam->insightIntentName_.c_str(), executeParam->executeMode_, executeParam->insightIntentId_); From bd726acdd944adce789438c3c249c916673970fe Mon Sep 17 00:00:00 2001 From: EurusHomles-zH Date: Thu, 16 May 2024 16:47:12 +0800 Subject: [PATCH 078/174] Description:JS leakage settting restrictions Signed-off-by: EurusHomles-zH --- frameworks/native/runtime/js_runtime.cpp | 3 -- .../js_environment/src/js_environment.cpp | 18 ------- .../interfaces/inner_api/js_environment.h | 4 -- .../js_environment_test.cpp | 52 ------------------- 4 files changed, 77 deletions(-) diff --git a/frameworks/native/runtime/js_runtime.cpp b/frameworks/native/runtime/js_runtime.cpp index e272ba8612..d946f1a527 100644 --- a/frameworks/native/runtime/js_runtime.cpp +++ b/frameworks/native/runtime/js_runtime.cpp @@ -626,7 +626,6 @@ void JsRuntime::FinishPreload() auto vm = GetEcmaVm(); CHECK_POINTER(vm); panda::JSNApi::PreFork(vm); - jsEnv_->StopMonitorJSHeapUsage(); } void JsRuntime::PostPreload(const Options& options) @@ -687,8 +686,6 @@ bool JsRuntime::Initialize(const Options& options) } NativeCreateEnv::RegCreateNapiEnvCallback(CreateNapiEnv); NativeCreateEnv::RegDestroyNapiEnvCallback(DestroyNapiEnv); - } else { - jsEnv_->StartMonitorJSHeapUsage(); } apiTargetVersion_ = options.apiTargetVersion; TAG_LOGD(AAFwkTag::JSRUNTIME, "Initialize: %{public}d.", apiTargetVersion_); diff --git a/js_environment/frameworks/js_environment/src/js_environment.cpp b/js_environment/frameworks/js_environment/src/js_environment.cpp index d0e856f878..c5326be1e5 100644 --- a/js_environment/frameworks/js_environment/src/js_environment.cpp +++ b/js_environment/frameworks/js_environment/src/js_environment.cpp @@ -349,24 +349,6 @@ void JsEnvironment::SetDeviceDisconnectCallback(const std::function &cb) panda::JSNApi::SetDeviceDisconnectCallback(vm_, std::move(cb)); } -void JsEnvironment::StartMonitorJSHeapUsage() -{ - if (engine_ == nullptr) { - JSENV_LOG_E("Invalid native engine."); - return; - } - engine_->StartMonitorJSHeapUsage(); -} - -void JsEnvironment::StopMonitorJSHeapUsage() -{ - if (engine_ == nullptr) { - JSENV_LOG_E("Invalid native engine."); - return; - } - engine_->StopMonitorJSHeapUsage(); -} - DebuggerPostTask JsEnvironment::GetDebuggerPostTask() { auto debuggerPostTask = [weak = weak_from_this()](std::function&& task) { diff --git a/js_environment/interfaces/inner_api/js_environment.h b/js_environment/interfaces/inner_api/js_environment.h index 8a95a790bf..587655c4e3 100644 --- a/js_environment/interfaces/inner_api/js_environment.h +++ b/js_environment/interfaces/inner_api/js_environment.h @@ -108,10 +108,6 @@ public: void SetDeviceDisconnectCallback(const std::function &cb); - void StartMonitorJSHeapUsage(); - - void StopMonitorJSHeapUsage(); - void NotifyDebugMode(int tid, const char* libraryPath, uint32_t instanceId, bool isDebugApp, bool debugMode); bool GetDebugMode() const; diff --git a/js_environment/test/unittest/js_environment_test/js_environment_test.cpp b/js_environment/test/unittest/js_environment_test/js_environment_test.cpp index 3a28db43fb..6b2ccdbcd3 100644 --- a/js_environment/test/unittest/js_environment_test/js_environment_test.cpp +++ b/js_environment/test/unittest/js_environment_test/js_environment_test.cpp @@ -502,57 +502,5 @@ HWTEST_F(JsEnvironmentTest, GetHeapPrepare_0200, TestSize.Level0) jsEnv->GetHeapPrepare(); ASSERT_NE(jsEnv, nullptr); } - -/** - * @tc.name: StartMonitorJSHeapUsage_0100 - * @tc.desc: Js environment StartMonitorJSHeapUsage. - * @tc.type: FUNC - */ -HWTEST_F(JsEnvironmentTest, StartMonitorJSHeapUsage_0100, TestSize.Level0) -{ - auto jsEnv = std::make_shared(std::make_unique()); - jsEnv->StartMonitorJSHeapUsage(); - ASSERT_NE(jsEnv, nullptr); -} - -/** - * @tc.name: StartMonitorJSHeapUsage_0200 - * @tc.desc: Js environment StartMonitorJSHeapUsage. - * @tc.type: FUNC - */ -HWTEST_F(JsEnvironmentTest, StartMonitorJSHeapUsage_0200, TestSize.Level0) -{ - auto jsEnv = std::make_shared(std::make_unique()); - panda::RuntimeOption pandaOption; - jsEnv->Initialize(pandaOption, static_cast(this)); - jsEnv->StartMonitorJSHeapUsage(); - ASSERT_NE(jsEnv, nullptr); -} - -/** - * @tc.name: StopMonitorJSHeapUsage_0100 - * @tc.desc: Js environment StopMonitorJSHeapUsage. - * @tc.type: FUNC - */ -HWTEST_F(JsEnvironmentTest, StopMonitorJSHeapUsage_0100, TestSize.Level0) -{ - auto jsEnv = std::make_shared(std::make_unique()); - jsEnv->StopMonitorJSHeapUsage(); - ASSERT_NE(jsEnv, nullptr); -} - -/** - * @tc.name: StopMonitorJSHeapUsage_0200 - * @tc.desc: Js environment StopMonitorJSHeapUsage. - * @tc.type: FUNC - */ -HWTEST_F(JsEnvironmentTest, StopMonitorJSHeapUsage_0200, TestSize.Level0) -{ - auto jsEnv = std::make_shared(std::make_unique()); - panda::RuntimeOption pandaOption; - jsEnv->Initialize(pandaOption, static_cast(this)); - jsEnv->StopMonitorJSHeapUsage(); - ASSERT_NE(jsEnv, nullptr); -} } // namespace JsEnv } // namespace OHOS From f61397de2a156824ab9e3c984470d01e0449fe7e Mon Sep 17 00:00:00 2001 From: sodanotgreen Date: Thu, 16 May 2024 17:10:24 +0800 Subject: [PATCH 079/174] =?UTF-8?q?=E7=AA=97=E5=8F=A3=E4=BC=A0=E5=8F=82?= =?UTF-8?q?=E6=94=B9=E9=80=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: sodanotgreen --- frameworks/native/ability/native/BUILD.gn | 1 + .../ability/native/js_service_extension.cpp | 45 ++++++++++++++-- .../native/ability/native/ui_ability.cpp | 54 ++++++++++++++++--- .../ability/native/js_service_extension.h | 43 ++++++--------- .../kits/native/ability/native/ui_ability.h | 34 ++++-------- 5 files changed, 117 insertions(+), 60 deletions(-) diff --git a/frameworks/native/ability/native/BUILD.gn b/frameworks/native/ability/native/BUILD.gn index e5d0cd0fa7..2aefcb98cb 100644 --- a/frameworks/native/ability/native/BUILD.gn +++ b/frameworks/native/ability/native/BUILD.gn @@ -733,6 +733,7 @@ ohos_shared_library("service_extension") { external_deps += [ "image_framework:image", "window_manager:libdm", + "window_manager:libwm", ] } diff --git a/frameworks/native/ability/native/js_service_extension.cpp b/frameworks/native/ability/native/js_service_extension.cpp index 42e69ddfb0..cf1d052446 100644 --- a/frameworks/native/ability/native/js_service_extension.cpp +++ b/frameworks/native/ability/native/js_service_extension.cpp @@ -219,7 +219,7 @@ void JsServiceExtension::ListenWMS() return; } - auto listener = sptr::MakeSptr(displayListener_); + auto listener = sptr::MakeSptr(displayListener_, GetContext().GetToken()); if (listener == nullptr) { TAG_LOGE(AAFwkTag::SERVICE_EXT, "Failed to create status change listener."); return; @@ -237,7 +237,8 @@ void JsServiceExtension::SystemAbilityStatusChangeListener::OnAddSystemAbility(i { TAG_LOGD(AAFwkTag::SERVICE_EXT, "systemAbilityId: %{public}d add", systemAbilityId); if (systemAbilityId == WINDOW_MANAGER_SERVICE_ID) { - Rosen::DisplayManager::GetInstance().RegisterDisplayListener(tmpDisplayListener_); + TAG_LOGI(AAFwkTag::SERVICE_EXT, "RegisterDisplayInfoChangedListener"); + Rosen::WindowManager::GetInstance().RegisterDisplayInfoChangedListener(token_, tmpDisplayListener_); } } @@ -315,7 +316,8 @@ void JsServiceExtension::OnStop() ConnectionManager::GetInstance().ReportConnectionLeakEvent(getpid(), gettid()); TAG_LOGD(AAFwkTag::SERVICE_EXT, "The service extension connection is not disconnected."); } - Rosen::DisplayManager::GetInstance().UnregisterDisplayListener(displayListener_); + TAG_LOGI(AAFwkTag::SERVICE_EXT, "UnregisterDisplayInfoChangedListener"); + (void)Rosen::WindowManager::GetInstance().UnregisterDisplayInfoChangedListener(GetContext().GetToken(), displayListener_); TAG_LOGD(AAFwkTag::SERVICE_EXT, "ok"); } @@ -799,6 +801,43 @@ void JsServiceExtension::OnDestroy(Rosen::DisplayId displayId) TAG_LOGD(AAFwkTag::SERVICE_EXT, "exit."); } +void JsServiceExtension::OnDisplayInfoChange(const sptr & token, Rosen::DisplayId displayId, float density, + Rosen::DisplayOrientation orientation) + { + TAG_LOGI(AAFwkTag::SERVICE_EXT, "displayId: %{public}" PRIu64"", displayId); + auto context = GetContext(); + if (context == nullptr) { + TAG_LOGE(AAFwkTag::SERVICE_EXT, "Context is invalid."); + return; + } + + auto contextConfig = context->GetConfiguration(); + if (contextConfig == nullptr) { + TAG_LOGE(AAFwkTag::SERVICE_EXT, "Configuration is invalid."); + return; + } + + TAG_LOGD(AAFwkTag::SERVICE_EXT, "Config dump: %{public}s", contextConfig->GetName().c_str()); + bool configChanged = false; + auto configUtils = std::make_shared(); + configUtils->UpdateDisplayConfig(displayId, contextConfig, context->GetResourceManager(), configChanged); + TAG_LOGD(AAFwkTag::SERVICE_EXT, "Config dump after update: %{public}s", contextConfig->GetName().c_str()); + + if (configChanged) { + auto jsServiceExtension = std::static_pointer_cast(shared_from_this()); + auto task = [jsServiceExtension]() { + if (jsServiceExtension) { + jsServiceExtension->ConfigurationUpdated(); + } + }; + if (handler_ != nullptr) { + handler_->PostTask(task, "JsServiceExtension:OnChange"); + } + } + + TAG_LOGD(AAFwkTag::SERVICE_EXT, "finished."); + }; + void JsServiceExtension::OnChange(Rosen::DisplayId displayId) { TAG_LOGD(AAFwkTag::SERVICE_EXT, "displayId: %{public}" PRIu64"", displayId); diff --git a/frameworks/native/ability/native/ui_ability.cpp b/frameworks/native/ability/native/ui_ability.cpp index 33eaee9287..66734f8602 100644 --- a/frameworks/native/ability/native/ui_ability.cpp +++ b/frameworks/native/ability/native/ui_ability.cpp @@ -93,7 +93,8 @@ void UIAbility::Init(std::shared_ptr record, TAG_LOGE(AAFwkTag::UIABILITY, "abilityDisplayListener_ is nullptr."); return; } - Rosen::DisplayManager::GetInstance().RegisterDisplayListener(abilityDisplayListener_); + TAG_LOGI(AAFwkTag::UIABILITY, "RegisterDisplayInfoChangedListener."); + Rosen::WindowManager::GetInstance().RegisterDisplayInfoChangedListener(token_, abilityDisplayListener_); #endif lifecycle_ = std::make_shared(); abilityLifecycleExecutor_ = std::make_shared(); @@ -185,7 +186,8 @@ void UIAbility::OnStop() if (abilityRecovery_ != nullptr) { abilityRecovery_->ScheduleSaveAbilityState(AppExecFwk::StateReason::LIFECYCLE); } - (void)Rosen::DisplayManager::GetInstance().UnregisterDisplayListener(abilityDisplayListener_); + TAG_LOGI(AAFwkTag::UIABILITY, "UnregisterDisplayInfoChangedListener."); + (void)Rosen::WindowManager::GetInstance().UnregisterDisplayInfoChangedListener(token_, abilityDisplayListener_); auto &&window = GetWindow(); if (window != nullptr) { TAG_LOGD(AAFwkTag::UIABILITY, "Call UnregisterDisplayMoveListener."); @@ -798,6 +800,49 @@ void UIAbility::OnDestroy(Rosen::DisplayId displayId) TAG_LOGD(AAFwkTag::UIABILITY, "Called."); } +void UIAbility::OnDisplayInfoChange(const sptr & token, Rosen::DisplayId displayId, float density, + Rosen::DisplayOrientation orientation) +{ + TAG_LOGI(AAFwkTag::UIABILITY, "Begin displayId: %{public}" PRIu64 "", displayId); + // Get display + auto display = Rosen::DisplayManager::GetInstance().GetDisplayById(displayId); + if (!display) { + TAG_LOGE(AAFwkTag::UIABILITY, "Get display by displayId %{public}" PRIu64 " failed.", displayId); + return; + } + + // Notify ResourceManager + int32_t width = display->GetWidth(); + int32_t height = display->GetHeight(); + std::unique_ptr resConfig(Global::Resource::CreateResConfig()); + if (resConfig != nullptr) { + auto resourceManager = GetResourceManager(); + if (resourceManager != nullptr) { + resourceManager->GetResConfig(*resConfig); + resConfig->SetScreenDensity(density); + resConfig->SetDirection(AppExecFwk::ConvertDirection(height, width)); + resourceManager->UpdateResConfig(*resConfig); + TAG_LOGD(AAFwkTag::UIABILITY, "Notify ResourceManager, Density: %{public}f, Direction: %{public}d", + resConfig->GetScreenDensity(), resConfig->GetDirection()); + } + } + + // Notify ability + Configuration newConfig; + newConfig.AddItem( + displayId, AppExecFwk::ConfigurationInner::APPLICATION_DIRECTION, AppExecFwk::GetDirectionStr(height, width)); + newConfig.AddItem( + displayId, AppExecFwk::ConfigurationInner::APPLICATION_DENSITYDPI, AppExecFwk::GetDensityStr(density)); + + if (application_ == nullptr) { + TAG_LOGE(AAFwkTag::UIABILITY, "application_ is nullptr."); + return; + } + + OnChangeForUpdateConfiguration(newConfig); + TAG_LOGD(AAFwkTag::UIABILITY, "End."); +}; + void UIAbility::OnChange(Rosen::DisplayId displayId) { TAG_LOGD(AAFwkTag::UIABILITY, "Begin displayId: %{public}" PRIu64 "", displayId); @@ -1021,11 +1066,6 @@ void UIAbility::OnChangeForUpdateConfiguration(const AppExecFwk::Configuration & ability->OnConfigurationUpdated(configuration); }; handler_->PostTask(task); - - auto diffConfiguration = std::make_shared(newConfig); - TAG_LOGD(AAFwkTag::UIABILITY, "Update display config %{public}s for all windows.", - diffConfiguration->GetName().c_str()); - Rosen::Window::UpdateConfigurationForAll(diffConfiguration); } } diff --git a/interfaces/kits/native/ability/native/js_service_extension.h b/interfaces/kits/native/ability/native/js_service_extension.h index 7f75ec8225..8c4ed59b52 100644 --- a/interfaces/kits/native/ability/native/js_service_extension.h +++ b/interfaces/kits/native/ability/native/js_service_extension.h @@ -23,6 +23,7 @@ #ifdef SUPPORT_GRAPHICS #include "display_manager.h" #include "system_ability_status_change_stub.h" +#include "window_manager.h" #endif #include "service_extension.h" @@ -125,7 +126,7 @@ public: * value of startId is 6. */ virtual void OnCommand(const AAFwk::Want &want, bool restart, int startId) override; - + /** * @brief Called back when Service is started by intent driver. * @@ -178,7 +179,7 @@ private: bool CallPromise(napi_value result, AppExecFwk::AbilityTransactionCallbackInfo<> *callbackInfo); void ListenWMS(); - + bool GetInsightIntentExecutorInfo(const Want &want, const std::shared_ptr &executeParam, InsightIntentExecutorInfo &executorInfo); @@ -192,36 +193,21 @@ private: #ifdef SUPPORT_GRAPHICS protected: - class JsServiceExtensionDisplayListener : public Rosen::DisplayManager::IDisplayListener { + class JsServiceExtensionDisplayListener : public Rosen::IDisplayInfoChangedListener { public: explicit JsServiceExtensionDisplayListener(const std::weak_ptr& jsServiceExtension) { jsServiceExtension_ = jsServiceExtension; } - void OnCreate(Rosen::DisplayId displayId) override - { - auto sptr = jsServiceExtension_.lock(); - if (sptr != nullptr) { - sptr->OnCreate(displayId); + void OnDisplayInfoChange(const sptr & token, Rosen::DisplayId displayId, float density, + Rosen::DisplayOrientation orientation) override + { + auto sptr = jsServiceExtension_.lock(); + if (sptr != nullptr) { + sptr->OnDisplayInfoChange(token, displayId, density, orientation); + } } - } - - void OnDestroy(Rosen::DisplayId displayId) override - { - auto sptr = jsServiceExtension_.lock(); - if (sptr != nullptr) { - sptr->OnDestroy(displayId); - } - } - - void OnChange(Rosen::DisplayId displayId) override - { - auto sptr = jsServiceExtension_.lock(); - if (sptr != nullptr) { - sptr->OnChange(displayId); - } - } private: std::weak_ptr jsServiceExtension_; @@ -230,17 +216,20 @@ protected: void OnCreate(Rosen::DisplayId displayId); void OnDestroy(Rosen::DisplayId displayId); void OnChange(Rosen::DisplayId displayId); + void OnDisplayInfoChange(const sptr & token, Rosen::DisplayId displayId, float density, + Rosen::DisplayOrientation orientation); private: class SystemAbilityStatusChangeListener : public OHOS::SystemAbilityStatusChangeStub { public: - SystemAbilityStatusChangeListener(sptr displayListener) - : tmpDisplayListener_(displayListener) {}; + SystemAbilityStatusChangeListener(sptr displayListener, + const sptr & token): tmpDisplayListener_(displayListener), token_(token) {}; virtual void OnAddSystemAbility(int32_t systemAbilityId, const std::string& deviceId) override; virtual void OnRemoveSystemAbility(int32_t systemAbilityId, const std::string& deviceId) override {} private: sptr tmpDisplayListener_ = nullptr; + sptr token_ = nullptr; }; sptr displayListener_ = nullptr; diff --git a/interfaces/kits/native/ability/native/ui_ability.h b/interfaces/kits/native/ability/native/ui_ability.h index e48d54ee4b..5b4b36da61 100644 --- a/interfaces/kits/native/ability/native/ui_ability.h +++ b/interfaces/kits/native/ability/native/ui_ability.h @@ -32,6 +32,7 @@ #include "display_manager.h" #include "session_info.h" #include "window_scene.h" +#include "window_manager.h" #endif namespace OHOS { @@ -539,36 +540,21 @@ public: std::string GetIdentityToken() const; protected: - class UIAbilityDisplayListener : public OHOS::Rosen::DisplayManager::IDisplayListener { + class UIAbilityDisplayListener : public OHOS::Rosen::IDisplayInfoChangedListener { public: explicit UIAbilityDisplayListener(const std::weak_ptr &ability) { ability_ = ability; } - void OnCreate(Rosen::DisplayId displayId) override - { - auto sptr = ability_.lock(); - if (sptr != nullptr) { - sptr->OnCreate(displayId); + void OnDisplayInfoChange(const sptr & token, Rosen::DisplayId displayId, float density, + Rosen::DisplayOrientation orientation) override + { + auto sptr = ability_.lock(); + if (sptr != nullptr) { + sptr->OnDisplayInfoChange(token, displayId, density, orientation); + } } - } - - void OnDestroy(Rosen::DisplayId displayId) override - { - auto sptr = ability_.lock(); - if (sptr != nullptr) { - sptr->OnDestroy(displayId); - } - } - - void OnChange(Rosen::DisplayId displayId) override - { - auto sptr = ability_.lock(); - if (sptr != nullptr) { - sptr->OnChange(displayId); - } - } private: std::weak_ptr ability_; @@ -577,6 +563,8 @@ protected: void OnCreate(Rosen::DisplayId displayId); void OnDestroy(Rosen::DisplayId displayId); void OnChange(Rosen::DisplayId displayId); + void OnDisplayInfoChange(const sptr & token, Rosen::DisplayId displayId, float density, + Rosen::DisplayOrientation orientation); class AbilityDisplayMoveListener : public OHOS::Rosen::IDisplayMoveListener { public: From ab817fce956b404ad94a99d0cfa23d94b0546855 Mon Sep 17 00:00:00 2001 From: zhaoleyi Date: Thu, 16 May 2024 16:30:21 +0800 Subject: [PATCH 080/174] =?UTF-8?q?preloadUIExtension=E5=8F=AF=E8=A7=81?= =?UTF-8?q?=E6=80=A7=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhaoleyi Change-Id: Ia32d96fb2235d241eed89c6e62af24b5740e8e55 --- services/abilitymgr/src/ability_manager_service.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/services/abilitymgr/src/ability_manager_service.cpp b/services/abilitymgr/src/ability_manager_service.cpp index 5769f93ce8..84adee948c 100644 --- a/services/abilitymgr/src/ability_manager_service.cpp +++ b/services/abilitymgr/src/ability_manager_service.cpp @@ -2430,6 +2430,12 @@ int AbilityManagerService::PreloadUIExtensionAbilityInner(const Want &want, std: return result; } abilityRequest.want.SetParam(IS_PRELOAD_UIEXTENSION_ABILITY, true); + auto abilityInfo = abilityRequest.abilityInfo; + auto res = JudgeAbilityVisibleControl(abilityInfo); + if (res != ERR_OK) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "Target ability is invisible"); + return res; + } auto connectManager = GetConnectManagerByUserId(validUserId); if (connectManager == nullptr) { TAG_LOGE(AAFwkTag::ABILITYMGR, "connectManager is nullptr, userId: %{public}d", validUserId); From 7acb176d320e6387d5886c52215636dc3c7db68b Mon Sep 17 00:00:00 2001 From: zhuhan Date: Thu, 16 May 2024 20:30:00 +0800 Subject: [PATCH 081/174] mv init sourcemap Signed-off-by: zhuhan Change-Id: I59542b602825d03c96ed31a3ecffd7d90c061582 --- frameworks/native/runtime/native_runtime_impl.cpp | 13 ------------- .../inner_api/runtime/include/native_runtime_impl.h | 2 -- 2 files changed, 15 deletions(-) diff --git a/frameworks/native/runtime/native_runtime_impl.cpp b/frameworks/native/runtime/native_runtime_impl.cpp index 98bf9d55dc..1eccd3c66c 100644 --- a/frameworks/native/runtime/native_runtime_impl.cpp +++ b/frameworks/native/runtime/native_runtime_impl.cpp @@ -147,9 +147,6 @@ napi_status NativeRuntimeImpl::Init(const Options& options, napi_env env) } if (!options.preload) { - auto operatorObj = std::make_shared(options.bundleName, isModular, - options.isDebugVersion); - InitSourceMap(operatorObj, jsEnv); if (!options.isUnique) { InitTimerModule(jsEnv); } @@ -248,16 +245,6 @@ void NativeRuntimeImpl::InitConsoleModule(const std::shared_ptrInitConsoleModule(); } -void NativeRuntimeImpl::InitSourceMap(const std::shared_ptr operatorObj, - const std::shared_ptr& jsEnv) -{ - if (jsEnv == nullptr) { - TAG_LOGE(AAFwkTag::JSRUNTIME, "jsEnv is nullptr."); - return; - } - jsEnv->InitSourceMap(operatorObj); -} - void NativeRuntimeImpl::InitTimerModule(const std::shared_ptr& jsEnv) { if (jsEnv == nullptr) { diff --git a/interfaces/inner_api/runtime/include/native_runtime_impl.h b/interfaces/inner_api/runtime/include/native_runtime_impl.h index c1ecb6703f..3b64a145f8 100644 --- a/interfaces/inner_api/runtime/include/native_runtime_impl.h +++ b/interfaces/inner_api/runtime/include/native_runtime_impl.h @@ -45,8 +45,6 @@ private: std::shared_ptr GetJsEnv(napi_env env); void LoadAotFile(const Options& options, const std::shared_ptr& jsEnv); void InitConsoleModule(const std::shared_ptr& jsEnv); - void InitSourceMap(const std::shared_ptr operatorObj, - const std::shared_ptr& jsEnv); void InitTimerModule(const std::shared_ptr& jsEnv); void SetModuleLoadChecker(const std::shared_ptr& moduleCheckerDelegate, const std::shared_ptr& jsEnv); From 2e312f136cc3aaccad43f642866397bcf61c83a0 Mon Sep 17 00:00:00 2001 From: donglin Date: Wed, 15 May 2024 06:26:47 +0000 Subject: [PATCH 082/174] pass visiable to selector Signed-off-by: donglin Change-Id: I25e451eb235ed62d3b785d31d9584132058d6cb1 --- .../js/napi/js_dialog_session/js_dialog_session_utils.cpp | 2 ++ .../inner_api/ability_manager/include/dialog_session_info.h | 1 + services/abilitymgr/include/system_dialog_scheduler.h | 1 + services/abilitymgr/src/dialog_session_info.cpp | 6 ++++-- services/abilitymgr/src/dialog_session_record.cpp | 1 + services/abilitymgr/src/implicit_start_processor.cpp | 2 ++ 6 files changed, 11 insertions(+), 2 deletions(-) diff --git a/frameworks/js/napi/js_dialog_session/js_dialog_session_utils.cpp b/frameworks/js/napi/js_dialog_session/js_dialog_session_utils.cpp index 6ce7948f5b..a67fcee65f 100644 --- a/frameworks/js/napi/js_dialog_session/js_dialog_session_utils.cpp +++ b/frameworks/js/napi/js_dialog_session/js_dialog_session_utils.cpp @@ -66,6 +66,8 @@ napi_value WrapDialogAbilityInfo(napi_env env, const AAFwk::DialogAbilityInfo &d SetPropertyValueByPropertyName(env, jsObject, "abilityIconId", jsValue); jsValue = WrapInt32ToJS(env, dialogAbilityInfo.abilityLabelId); SetPropertyValueByPropertyName(env, jsObject, "abilityLabelId", jsValue); + jsValue = WrapBoolToJS(env, dialogAbilityInfo.visible); + SetPropertyValueByPropertyName(env, jsObject, "visible", jsValue); return jsObject; } diff --git a/interfaces/inner_api/ability_manager/include/dialog_session_info.h b/interfaces/inner_api/ability_manager/include/dialog_session_info.h index dcf0970434..fc6f550944 100644 --- a/interfaces/inner_api/ability_manager/include/dialog_session_info.h +++ b/interfaces/inner_api/ability_manager/include/dialog_session_info.h @@ -34,6 +34,7 @@ struct DialogAbilityInfo { int32_t bundleLabelId = 0; int32_t abilityIconId = 0; int32_t abilityLabelId = 0; + bool visible = true; std::string GetURI() const; bool ParseURI(const std::string &uri); diff --git a/services/abilitymgr/include/system_dialog_scheduler.h b/services/abilitymgr/include/system_dialog_scheduler.h index dd4acf09a0..064d3a2360 100644 --- a/services/abilitymgr/include/system_dialog_scheduler.h +++ b/services/abilitymgr/include/system_dialog_scheduler.h @@ -58,6 +58,7 @@ struct DialogAppInfo { std::string bundleName = {}; std::string abilityName = {}; std::string moduleName = {}; + bool visible = true; }; /** * @class SystemDialogScheduler diff --git a/services/abilitymgr/src/dialog_session_info.cpp b/services/abilitymgr/src/dialog_session_info.cpp index ca9efcd4af..fa46604fb7 100644 --- a/services/abilitymgr/src/dialog_session_info.cpp +++ b/services/abilitymgr/src/dialog_session_info.cpp @@ -25,13 +25,14 @@ namespace OHOS { namespace AAFwk { constexpr int32_t CYCLE_LIMIT = 1000; -constexpr size_t MEMBER_NUM = 7; +constexpr size_t MEMBER_NUM = 8; std::string DialogAbilityInfo::GetURI() const { return bundleName + "/" + moduleName + "/" + abilityName + "/" + std::to_string(bundleIconId) + "/" + std::to_string(bundleLabelId) + "/" + - std::to_string(abilityIconId) + "/" + std::to_string(abilityLabelId); + std::to_string(abilityIconId) + "/" + std::to_string(abilityLabelId) + "/" + + std::to_string(visible); } bool DialogAbilityInfo::ParseURI(const std::string &uri) @@ -53,6 +54,7 @@ bool DialogAbilityInfo::ParseURI(const std::string &uri) bundleLabelId = static_cast(std::stoi(uriVec[index++])); abilityIconId = static_cast(std::stoi(uriVec[index++])); abilityLabelId = static_cast(std::stoi(uriVec[index++])); + visible = std::stoi(uriVec[index++]); return true; } diff --git a/services/abilitymgr/src/dialog_session_record.cpp b/services/abilitymgr/src/dialog_session_record.cpp index 54413eecc9..591805f41d 100644 --- a/services/abilitymgr/src/dialog_session_record.cpp +++ b/services/abilitymgr/src/dialog_session_record.cpp @@ -131,6 +131,7 @@ bool DialogSessionRecord::GenerateDialogSessionRecord(AbilityRequest &abilityReq targetDialogAbilityInfo.abilityLabelId = dialogAppInfo.abilityLabelId; targetDialogAbilityInfo.bundleIconId = dialogAppInfo.bundleIconId; targetDialogAbilityInfo.bundleLabelId = dialogAppInfo.bundleLabelId; + targetDialogAbilityInfo.visible = dialogAppInfo.visible; dialogSessionInfo->targetAbilityInfos.emplace_back(targetDialogAbilityInfo); } std::shared_ptr dialogCallerInfo = std::make_shared(); diff --git a/services/abilitymgr/src/implicit_start_processor.cpp b/services/abilitymgr/src/implicit_start_processor.cpp index 2802c624c6..d002b2dc12 100644 --- a/services/abilitymgr/src/implicit_start_processor.cpp +++ b/services/abilitymgr/src/implicit_start_processor.cpp @@ -452,6 +452,7 @@ int ImplicitStartProcessor::GenerateAbilityRequestByAction(int32_t userId, dialogAppInfo.abilityLabelId = info.labelId; dialogAppInfo.bundleIconId = info.applicationInfo.iconId; dialogAppInfo.bundleLabelId = info.applicationInfo.labelId; + dialogAppInfo.visible = info.visible; dialogAppInfos.emplace_back(dialogAppInfo); } @@ -725,6 +726,7 @@ void ImplicitStartProcessor::AddAbilityInfoToDialogInfos(const AddInfoParam &par dialogAppInfo.abilityLabelId = param.info.labelId; dialogAppInfo.bundleIconId = param.info.applicationInfo.iconId; dialogAppInfo.bundleLabelId = param.info.applicationInfo.labelId; + dialogAppInfo.visible = param.info.visible; dialogAppInfos.emplace_back(dialogAppInfo); } From 9c978e83003bad0480afcecafaf5e4585ac06832 Mon Sep 17 00:00:00 2001 From: sodanotgreen Date: Thu, 16 May 2024 21:25:08 +0800 Subject: [PATCH 083/174] =?UTF-8?q?=E7=AA=97=E5=8F=A3=E4=BC=A0=E5=8F=82?= =?UTF-8?q?=E6=94=B9=E9=80=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: sodanotgreen --- frameworks/native/ability/native/js_service_extension.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frameworks/native/ability/native/js_service_extension.cpp b/frameworks/native/ability/native/js_service_extension.cpp index cf1d052446..855e6732dd 100644 --- a/frameworks/native/ability/native/js_service_extension.cpp +++ b/frameworks/native/ability/native/js_service_extension.cpp @@ -219,7 +219,7 @@ void JsServiceExtension::ListenWMS() return; } - auto listener = sptr::MakeSptr(displayListener_, GetContext().GetToken()); + auto listener = sptr::MakeSptr(displayListener_, GetContext()->GetToken()); if (listener == nullptr) { TAG_LOGE(AAFwkTag::SERVICE_EXT, "Failed to create status change listener."); return; @@ -317,7 +317,7 @@ void JsServiceExtension::OnStop() TAG_LOGD(AAFwkTag::SERVICE_EXT, "The service extension connection is not disconnected."); } TAG_LOGI(AAFwkTag::SERVICE_EXT, "UnregisterDisplayInfoChangedListener"); - (void)Rosen::WindowManager::GetInstance().UnregisterDisplayInfoChangedListener(GetContext().GetToken(), displayListener_); + (void)Rosen::WindowManager::GetInstance().UnregisterDisplayInfoChangedListener(GetContext()->GetToken(), displayListener_); TAG_LOGD(AAFwkTag::SERVICE_EXT, "ok"); } From 20015dbe1e4a3c4a0e0618331a6429f2bca7f11b Mon Sep 17 00:00:00 2001 From: gongyuechen Date: Thu, 16 May 2024 21:59:28 +0800 Subject: [PATCH 084/174] add module name for dlp viewability Signed-off-by: gongyuechen --- services/abilitymgr/include/ability_util.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/services/abilitymgr/include/ability_util.h b/services/abilitymgr/include/ability_util.h index 18003043a9..d8bd13a89c 100644 --- a/services/abilitymgr/include/ability_util.h +++ b/services/abilitymgr/include/ability_util.h @@ -37,7 +37,9 @@ namespace AAFwk { namespace AbilityUtil { constexpr const char* SYSTEM_BASIC = "system_basic"; constexpr const char* SYSTEM_CORE = "system_core"; +constexpr const char* DEFAULT_DEVICE_ID = ""; constexpr const char* DLP_BUNDLE_NAME = "com.ohos.dlpmanager"; +constexpr const char* DLP_MODULE_NAME = "entry"; constexpr const char* DLP_ABILITY_NAME = "ViewAbility"; constexpr const char* DLP_PARAMS_SANDBOX = "ohos.dlp.params.sandbox"; constexpr const char* DLP_PARAMS_BUNDLE_NAME = "ohos.dlp.params.bundleName"; @@ -221,7 +223,7 @@ static constexpr int64_t MICROSECONDS = 1000000; // MICROSECONDS mean 10^6 mi AppExecFwk::ElementName element = want.GetElement(); if (want.GetBoolParam(DLP_PARAMS_SANDBOX, false) && !element.GetBundleName().empty() && !element.GetAbilityName().empty()) { - want.SetElementName(DLP_BUNDLE_NAME, DLP_ABILITY_NAME); + want.SetElementName(DEFAULT_DEVICE_ID, DLP_BUNDLE_NAME, DLP_ABILITY_NAME, DLP_PARAMS_MODULE_NAME); want.SetParam(DLP_PARAMS_BUNDLE_NAME, element.GetBundleName()); want.SetParam(DLP_PARAMS_MODULE_NAME, element.GetModuleName()); want.SetParam(DLP_PARAMS_ABILITY_NAME, element.GetAbilityName()); From 835eff33775fc7b3ebe6e41250a21b9d1e4ecf75 Mon Sep 17 00:00:00 2001 From: jsjzju Date: Thu, 16 May 2024 12:01:11 +0800 Subject: [PATCH 085/174] =?UTF-8?q?=E5=9C=A8=E6=96=B0=E8=BF=9B=E7=A8=8B?= =?UTF-8?q?=E4=B8=AD=E5=90=AF=E5=8A=A8specified=EF=BC=8C=E8=B5=B0=E6=96=B0?= =?UTF-8?q?=E8=BF=9B=E7=A8=8B=E7=9A=84onAcceptWant=E7=94=9F=E5=91=BD?= =?UTF-8?q?=E5=91=A8=E6=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: jsjzju Change-Id: I1a673eb471978785c9f92855345b9ed1ac53395b --- .../ability_manager/include/process_options.h | 1 + .../ui_ability_lifecycle_manager.h | 2 ++ services/abilitymgr/src/process_options.cpp | 5 +++ .../ui_ability_lifecycle_manager.cpp | 35 ++++++++++++++++--- 4 files changed, 38 insertions(+), 5 deletions(-) diff --git a/interfaces/inner_api/ability_manager/include/process_options.h b/interfaces/inner_api/ability_manager/include/process_options.h index e0f3f45621..afce4b4500 100644 --- a/interfaces/inner_api/ability_manager/include/process_options.h +++ b/interfaces/inner_api/ability_manager/include/process_options.h @@ -49,6 +49,7 @@ public: ProcessMode processMode = ProcessMode::UNSPECIFIED; StartupVisibility startupVisibility = StartupVisibility::UNSPECIFIED; + std::string processName; }; } // namespace AAFwk } // namespace OHOS diff --git a/services/abilitymgr/include/scene_board/ui_ability_lifecycle_manager.h b/services/abilitymgr/include/scene_board/ui_ability_lifecycle_manager.h index b486d5f86b..147b7d461d 100644 --- a/services/abilitymgr/include/scene_board/ui_ability_lifecycle_manager.h +++ b/services/abilitymgr/include/scene_board/ui_ability_lifecycle_manager.h @@ -337,6 +337,8 @@ private: int32_t GetReusedSpecifiedPersistentId(const AbilityRequest &abilityRequest, bool &reuse) const; int32_t GetReusedStandardPersistentId(const AbilityRequest &abilityRequest, bool &reuse) const; int32_t GetReusedCollaboratorPersistentId(const AbilityRequest &abilityRequest, bool &reuse) const; + std::string GenerateProcessNameForNewProcessMode(const AppExecFwk::AbilityInfo& abilityInfo); + void PreCreateProcessName(AbilityRequest &abilityRequest); void UpdateProcessName(const AbilityRequest &abilityRequest, std::shared_ptr &abilityRecord); void UpdateAbilityRecordLaunchReason(const AbilityRequest &abilityRequest, std::shared_ptr &abilityRecord) const; diff --git a/services/abilitymgr/src/process_options.cpp b/services/abilitymgr/src/process_options.cpp index f0abe807c0..0ab1370667 100644 --- a/services/abilitymgr/src/process_options.cpp +++ b/services/abilitymgr/src/process_options.cpp @@ -24,6 +24,7 @@ bool ProcessOptions::ReadFromParcel(Parcel &parcel) { processMode = static_cast(parcel.ReadInt32()); startupVisibility = static_cast(parcel.ReadInt32()); + processName = parcel.ReadString(); return true; } @@ -52,6 +53,10 @@ bool ProcessOptions::Marshalling(Parcel &parcel) const TAG_LOGE(AAFwkTag::ABILITYMGR, "Failed to write startupVisibility"); return false; } + if (!parcel.WriteString(processName)) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "Failed to write processName"); + return false; + } return true; } diff --git a/services/abilitymgr/src/scene_board/ui_ability_lifecycle_manager.cpp b/services/abilitymgr/src/scene_board/ui_ability_lifecycle_manager.cpp index 5e05ec1125..13a7674ca2 100644 --- a/services/abilitymgr/src/scene_board/ui_ability_lifecycle_manager.cpp +++ b/services/abilitymgr/src/scene_board/ui_ability_lifecycle_manager.cpp @@ -332,6 +332,7 @@ int UIAbilityLifecycleManager::NotifySCBToStartUIAbility(const AbilityRequest &a } auto isSpecified = (abilityRequest.abilityInfo.launchMode == AppExecFwk::LaunchMode::SPECIFIED); if (isSpecified) { + PreCreateProcessName(const_cast(abilityRequest)); specifiedRequestMap_.emplace(specifiedRequestId_, abilityRequest); DelayedSingleton::GetInstance()->StartSpecifiedAbility( abilityRequest.want, abilityRequest.abilityInfo, specifiedRequestId_); @@ -614,6 +615,28 @@ void UIAbilityLifecycleManager::EraseSpecifiedAbilityRecord(const std::shared_pt } } +std::string UIAbilityLifecycleManager::GenerateProcessNameForNewProcessMode(const AppExecFwk::AbilityInfo& abilityInfo) +{ + static uint32_t index = 0; + std::string processName = abilityInfo.bundleName + SEPARATOR + abilityInfo.moduleName + SEPARATOR + + abilityInfo.name + SEPARATOR + std::to_string(index++); + TAG_LOGI(AAFwkTag::ABILITYMGR, "processName: %{public}s", processName.c_str()); + return processName; +} + +void UIAbilityLifecycleManager::PreCreateProcessName(AbilityRequest &abilityRequest) +{ + if (abilityRequest.processOptions == nullptr || + !ProcessOptions::IsNewProcessMode(abilityRequest.processOptions->processMode)) { + TAG_LOGD(AAFwkTag::ABILITYMGR, "No need to pre create process name."); + return; + } + TAG_LOGI(AAFwkTag::ABILITYMGR, "create process name in advance."); + std::string processName = GenerateProcessNameForNewProcessMode(abilityRequest.abilityInfo); + abilityRequest.processOptions->processName = processName; + abilityRequest.abilityInfo.process = processName; +} + void UIAbilityLifecycleManager::UpdateProcessName(const AbilityRequest &abilityRequest, std::shared_ptr &abilityRecord) { @@ -623,11 +646,13 @@ void UIAbilityLifecycleManager::UpdateProcessName(const AbilityRequest &abilityR TAG_LOGD(AAFwkTag::ABILITYMGR, "No need to update process name."); return; } - static uint32_t index = 0; - std::string processName = abilityRequest.abilityInfo.bundleName + SEPARATOR + - abilityRequest.abilityInfo.moduleName + SEPARATOR + abilityRequest.abilityInfo.name + - SEPARATOR + std::to_string(index++); - TAG_LOGD(AAFwkTag::ABILITYMGR, "processName: %{public}s", processName.c_str()); + std::string processName; + if (!abilityRequest.sessionInfo->processOptions->processName.empty()) { + TAG_LOGD(AAFwkTag::ABILITYMGR, "The process name has been generated in advance."); + processName = abilityRequest.sessionInfo->processOptions->processName; + } else { + processName = GenerateProcessNameForNewProcessMode(abilityRequest.abilityInfo); + } abilityRecord->SetProcessName(processName); } From 6d9f57a6fe3e8464af8e15246709b827a46f4208 Mon Sep 17 00:00:00 2001 From: zhubingwei Date: Thu, 16 May 2024 16:58:57 +0800 Subject: [PATCH 086/174] =?UTF-8?q?TDD=E8=A6=86=E7=9B=96=E7=8E=87=E6=8F=90?= =?UTF-8?q?=E5=8D=87(app=20ability=5Fstage)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhubingwei --- .../ability_stage_test.cpp | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/test/unittest/frameworks_kits_appkit_native_test/ability_stage_test.cpp b/test/unittest/frameworks_kits_appkit_native_test/ability_stage_test.cpp index 79bb90006e..0cb4114d62 100644 --- a/test/unittest/frameworks_kits_appkit_native_test/ability_stage_test.cpp +++ b/test/unittest/frameworks_kits_appkit_native_test/ability_stage_test.cpp @@ -22,6 +22,7 @@ #include "context_impl.h" #include "iremote_object.h" #include "mock_ability_token.h" +#include "runtime.h" namespace OHOS { namespace AppExecFwk { @@ -259,5 +260,91 @@ HWTEST_F(AbilityStageTest, AppExecFwk_AbilityStage_OnAcceptWant_001, Function | EXPECT_TRUE(abilityStage_->OnAcceptWant(want) == ""); GTEST_LOG_(INFO) << "AppExecFwk_AbilityStage_OnAcceptWant_001 end"; } + +/** + * @tc.number: AppExecFwk_AbilityStage_Create_001 + * @tc.name: Create + * @tc.desc: Test whether Create is called normally. + * @tc.type: FUNC + * @tc.require: AR000GJ719 + */ +HWTEST_F(AbilityStageTest, AppExecFwk_AbilityStage_Create_001, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) << "AppExecFwk_AbilityStage_Create_001 start"; + std::unique_ptr runtime; + AppExecFwk::HapModuleInfo hapModuleInfo; + EXPECT_NE(abilityStage_->Create(runtime, hapModuleInfo), nullptr); + GTEST_LOG_(INFO) << "AppExecFwk_AbilityStage_Create_001 end"; +} + +/** + * @tc.number: AppExecFwk_AbilityStage_OnNewProcessRequest_001 + * @tc.name: OnNewProcessRequest + * @tc.desc: Test whether OnNewProcessRequest is called normally. + * @tc.type: FUNC + * @tc.require: AR000GJ719 + */ +HWTEST_F(AbilityStageTest, AppExecFwk_AbilityStage_OnNewProcessRequest_001, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) << "AppExecFwk_AbilityStage_OnNewProcessRequest_001 start"; + AAFwk::Want want; + EXPECT_TRUE(abilityStage_->OnNewProcessRequest(want) == ""); + GTEST_LOG_(INFO) << "AppExecFwk_AbilityStage_OnNewProcessRequest_001 end"; +} + +/** + * @tc.number: AppExecFwk_AbilityStage_OnConfigurationUpdated_001 + * @tc.name: OnConfigurationUpdated + * @tc.desc: Test whether OnConfigurationUpdated is called normally. + * @tc.type: FUNC + * @tc.require: AR000GJ719 + */ +HWTEST_F(AbilityStageTest, AppExecFwk_AbilityStage_OnConfigurationUpdated_001, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) << "AppExecFwk_AbilityStage_OnConfigurationUpdated_001 start"; + bool boolValue = false; + AppExecFwk::Configuration configuration; + if (abilityStage_ != nullptr) { + abilityStage_->OnConfigurationUpdated(configuration); + boolValue = true; + } + EXPECT_TRUE(boolValue); + GTEST_LOG_(INFO) << "AppExecFwk_AbilityStage_OnConfigurationUpdated_001 end"; +} + +/** + * @tc.number: AppExecFwk_AbilityStage_OnMemoryLevel_001 + * @tc.name: OnMemoryLevel + * @tc.desc: Test whether OnMemoryLevel is called normally. + * @tc.type: FUNC + * @tc.require: AR000GJ719 + */ +HWTEST_F(AbilityStageTest, AppExecFwk_AbilityStage_OnMemoryLevel_001, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) << "AppExecFwk_AbilityStage_OnMemoryLevel_001 start"; + bool boolValue = false; + if (abilityStage_ != nullptr) { + abilityStage_->OnMemoryLevel(1); + boolValue = true; + } + EXPECT_TRUE(boolValue); + GTEST_LOG_(INFO) << "AppExecFwk_AbilityStage_OnMemoryLevel_001 end"; +} + +/** + * @tc.number: AppExecFwk_AbilityStage_RunAutoStartupTask_001 + * @tc.name: RunAutoStartupTask + * @tc.desc: Test whether RunAutoStartupTask is called normally. + * @tc.type: FUNC + * @tc.require: AR000GJ719 + */ +HWTEST_F(AbilityStageTest, AppExecFwk_AbilityStage_RunAutoStartupTask_001, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) << "AppExecFwk_AbilityStage_RunAutoStartupTask_001 start"; + std::function callback; + bool isAsyncCallback; + EXPECT_TRUE(abilityStage_->RunAutoStartupTask(callback, isAsyncCallback) == ERR_OK); + GTEST_LOG_(INFO) << "AppExecFwk_AbilityStage_RunAutoStartupTask_001 end"; +} } // namespace AppExecFwk } From 380db78078747c8d2d9d1db5f53f26c07963bf74 Mon Sep 17 00:00:00 2001 From: sodanotgreen Date: Fri, 17 May 2024 09:40:13 +0800 Subject: [PATCH 087/174] =?UTF-8?q?=E7=AA=97=E5=8F=A3=E4=BC=A0=E5=8F=82?= =?UTF-8?q?=E6=94=B9=E9=80=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: sodanotgreen --- .../native/ability/native/js_service_extension.cpp | 12 +++++++++--- .../native/ability/native/js_service_extension.h | 2 +- interfaces/kits/native/ability/native/ui_ability.h | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/frameworks/native/ability/native/js_service_extension.cpp b/frameworks/native/ability/native/js_service_extension.cpp index 855e6732dd..d6c8522780 100644 --- a/frameworks/native/ability/native/js_service_extension.cpp +++ b/frameworks/native/ability/native/js_service_extension.cpp @@ -317,7 +317,13 @@ void JsServiceExtension::OnStop() TAG_LOGD(AAFwkTag::SERVICE_EXT, "The service extension connection is not disconnected."); } TAG_LOGI(AAFwkTag::SERVICE_EXT, "UnregisterDisplayInfoChangedListener"); - (void)Rosen::WindowManager::GetInstance().UnregisterDisplayInfoChangedListener(GetContext()->GetToken(), displayListener_); + auto context = GetContext(); + if (context == nullptr || context->GetToken()) { + TAG_LOGE(AAFwkTag::SERVICE_EXT, "Param invalid."); + return; + } + Rosen::WindowManager::GetInstance() + .UnregisterDisplayInfoChangedListener(context->GetToken(), displayListener_); TAG_LOGD(AAFwkTag::SERVICE_EXT, "ok"); } @@ -801,8 +807,8 @@ void JsServiceExtension::OnDestroy(Rosen::DisplayId displayId) TAG_LOGD(AAFwkTag::SERVICE_EXT, "exit."); } -void JsServiceExtension::OnDisplayInfoChange(const sptr & token, Rosen::DisplayId displayId, float density, - Rosen::DisplayOrientation orientation) +void JsServiceExtension::OnDisplayInfoChange(const sptr & token, Rosen::DisplayId displayId, + float density, Rosen::DisplayOrientation orientation) { TAG_LOGI(AAFwkTag::SERVICE_EXT, "displayId: %{public}" PRIu64"", displayId); auto context = GetContext(); diff --git a/interfaces/kits/native/ability/native/js_service_extension.h b/interfaces/kits/native/ability/native/js_service_extension.h index 8c4ed59b52..5ca49fd70c 100644 --- a/interfaces/kits/native/ability/native/js_service_extension.h +++ b/interfaces/kits/native/ability/native/js_service_extension.h @@ -216,7 +216,7 @@ protected: void OnCreate(Rosen::DisplayId displayId); void OnDestroy(Rosen::DisplayId displayId); void OnChange(Rosen::DisplayId displayId); - void OnDisplayInfoChange(const sptr & token, Rosen::DisplayId displayId, float density, + void OnDisplayInfoChange(const sptr& token, Rosen::DisplayId displayId, float density, Rosen::DisplayOrientation orientation); private: diff --git a/interfaces/kits/native/ability/native/ui_ability.h b/interfaces/kits/native/ability/native/ui_ability.h index 5b4b36da61..247b572e42 100644 --- a/interfaces/kits/native/ability/native/ui_ability.h +++ b/interfaces/kits/native/ability/native/ui_ability.h @@ -563,7 +563,7 @@ protected: void OnCreate(Rosen::DisplayId displayId); void OnDestroy(Rosen::DisplayId displayId); void OnChange(Rosen::DisplayId displayId); - void OnDisplayInfoChange(const sptr & token, Rosen::DisplayId displayId, float density, + void OnDisplayInfoChange(const sptr& token, Rosen::DisplayId displayId, float density, Rosen::DisplayOrientation orientation); class AbilityDisplayMoveListener : public OHOS::Rosen::IDisplayMoveListener { From 3670b7ca9cb89be5ed783768d8597138e2bd417a Mon Sep 17 00:00:00 2001 From: zhubingwei Date: Fri, 17 May 2024 10:46:31 +0800 Subject: [PATCH 088/174] UT for deeplink_reserve_config Signed-off-by: zhubingwei --- services/abilitymgr/libabilityms.map | 1 + test/unittest/BUILD.gn | 1 + .../deeplink_reserve_config_test/BUILD.gn | 41 +++++++ .../deeplink_reserve_config_test.cpp | 105 ++++++++++++++++++ 4 files changed, 148 insertions(+) create mode 100644 test/unittest/deeplink_reserve_config_test/BUILD.gn create mode 100644 test/unittest/deeplink_reserve_config_test/deeplink_reserve_config_test.cpp diff --git a/services/abilitymgr/libabilityms.map b/services/abilitymgr/libabilityms.map index e8978d9681..ea7ce503c3 100644 --- a/services/abilitymgr/libabilityms.map +++ b/services/abilitymgr/libabilityms.map @@ -79,6 +79,7 @@ *WantReceiverProxy*; *WantSenderProxy*; *WantSenderStub*; + *DeepLinkReserveConfig*; }; local: *; diff --git a/test/unittest/BUILD.gn b/test/unittest/BUILD.gn index 986f650204..11d62bbaf4 100644 --- a/test/unittest/BUILD.gn +++ b/test/unittest/BUILD.gn @@ -442,6 +442,7 @@ group("unittest") { "dataobs_mgr_service_dump_test:unittest", "dataobs_mgr_service_test:unittest", "dataobs_mgr_stub_test:unittest", + "deeplink_reserve_config_test:unittest", "dfr_test:unittest", "dlp_state_item_test:unittest", "dlp_utils_test:unittest", diff --git a/test/unittest/deeplink_reserve_config_test/BUILD.gn b/test/unittest/deeplink_reserve_config_test/BUILD.gn new file mode 100644 index 0000000000..0352f5da8b --- /dev/null +++ b/test/unittest/deeplink_reserve_config_test/BUILD.gn @@ -0,0 +1,41 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/test.gni") +import("//foundation/ability/ability_runtime/ability_runtime.gni") + +module_output_path = "ability_runtime/abilitymgr" + +ohos_unittest("deeplink_reserve_config_test") { + module_out_path = module_output_path + + include_dirs = + [ "${ability_runtime_path}/services/abilitymgr/include/deeplink_reserve" ] + + sources = [ "deeplink_reserve_config_test.cpp" ] + + configs = [ "${ability_runtime_services_path}/abilitymgr:abilityms_config" ] + cflags = [] + deps = [ + "${ability_runtime_services_path}/abilitymgr:abilityms", + "//third_party/googletest:gmock_main", + ] + + external_deps = [ "c_utils:utils" ] +} + +group("unittest") { + testonly = true + + deps = [ ":deeplink_reserve_config_test" ] +} diff --git a/test/unittest/deeplink_reserve_config_test/deeplink_reserve_config_test.cpp b/test/unittest/deeplink_reserve_config_test/deeplink_reserve_config_test.cpp new file mode 100644 index 0000000000..0c9ea6c0f9 --- /dev/null +++ b/test/unittest/deeplink_reserve_config_test/deeplink_reserve_config_test.cpp @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include + +#include "gtest/gtest.h" +#define private public +#define protected public +#include "deeplink_reserve_config.h" +#undef private +#undef protected + + +namespace OHOS { +namespace AAFwk { +using namespace testing::ext; +class DeepLinkReserveConfigTest : public testing::Test { +public: + DeepLinkReserveConfigTest() = default; + virtual ~DeepLinkReserveConfigTest() = default; + + static void SetUpTestCase(void); + static void TearDownTestCase(void); + void SetUp(); + void TearDown(); +}; +void DeepLinkReserveConfigTest::SetUpTestCase(void) +{} +void DeepLinkReserveConfigTest::TearDownTestCase(void) +{} +void DeepLinkReserveConfigTest::SetUp() +{} +void DeepLinkReserveConfigTest::TearDown() +{} + +/* + * Feature: deepLinkReserveConfig + * Function: LoadConfiguration + * SubFunction: NA + * FunctionPoints: deepLinkReserveConfig LoadConfiguration + * EnvConditions: NA + * CaseDescription: Verify that the deepLinkReserveConfig LoadConfiguration is normal. + */ +HWTEST_F(DeepLinkReserveConfigTest, AaFwk_DeepLinkReserveConfigTest_0100, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "AaFwk_DeepLinkReserveConfigTest_0100 start"; + DeepLinkReserveConfig deepLinkReserveConfig; + EXPECT_EQ(deepLinkReserveConfig.LoadConfiguration(), false); + GTEST_LOG_(INFO) << "AaFwk_DeepLinkReserveConfigTest_0100 end"; +} + +/* + * Feature: deepLinkReserveConfig + * Function: isLinkReserved + * SubFunction: NA + * FunctionPoints: deepLinkReserveConfig isLinkReserved + * EnvConditions: NA + * CaseDescription: Verify that the deepLinkReserveConfig isLinkReserved is normal. + */ +HWTEST_F(DeepLinkReserveConfigTest, AaFwk_DeepLinkReserveConfigTest_0200, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "AaFwk_DeepLinkReserveConfigTest_0200 start"; + DeepLinkReserveConfig deepLinkReserveConfig; + const nlohmann::json DEFAULT_CONFIG = R"( + { + "deepLinkReservedUri": [ + { + "bundleName": "bundleName", + "uris": [ + { + "scheme": "http", + "host": "www.xxx.com", + "port": "80", + "path": "path", + "pathStartWith": "pathStartWith", + "pathRegex": "pathRegex", + "type": "type", + "utd": "utd" + } + ] + } + ] + } + )"_json; + deepLinkReserveConfig.LoadReservedUriList(DEFAULT_CONFIG); + std::string linkString = "http://www.xxx.com:80/pathRegex"; + std::string bundleName = "just a test"; + auto ans = deepLinkReserveConfig.isLinkReserved(linkString, bundleName); + EXPECT_EQ(ans, true); + GTEST_LOG_(INFO) << "AaFwk_DeepLinkReserveConfigTest_0200 end"; +} + +} // namespace AAFwk +} // namespace OHOS From 6b4d315f639de9c03d83871898baa62adf38e0af Mon Sep 17 00:00:00 2001 From: xieqiongyang Date: Fri, 17 May 2024 15:14:00 +0800 Subject: [PATCH 089/174] update Signed-off-by: xieqiongyang Change-Id: I56953e8c81f041f177bc7727e3faee205236335f --- .../src/ability_manager_service.cpp | 8 +-- .../appmgr/include/app_mgr_service_inner.h | 10 +++- services/appmgr/include/app_spawn_client.h | 19 +++++++ services/appmgr/src/app_mgr_service_inner.cpp | 55 ++++++++++++++++--- services/appmgr/src/app_spawn_client.cpp | 47 +++++++++++++++- services/common/include/event_report.h | 2 - 6 files changed, 123 insertions(+), 18 deletions(-) diff --git a/services/abilitymgr/src/ability_manager_service.cpp b/services/abilitymgr/src/ability_manager_service.cpp index 4137a52631..dd9f2b299b 100644 --- a/services/abilitymgr/src/ability_manager_service.cpp +++ b/services/abilitymgr/src/ability_manager_service.cpp @@ -1565,10 +1565,10 @@ int AbilityManagerService::StartAbilityForOptionInner(const Want &want, const St abilityRequest.want.SetParam(Want::PARAM_RESV_WINDOW_TOP, startOptions.GetWindowTop()); } if (startOptions.windowWidthUsed_) { - abilityRequest.want.SetParam(Want::PARAM_RESV_WINDOW_HEIGHT, startOptions.GetWindowWidth()); + abilityRequest.want.SetParam(Want::PARAM_RESV_WINDOW_WIDTH, startOptions.GetWindowWidth()); } if (startOptions.windowHeightUsed_) { - abilityRequest.want.SetParam(Want::PARAM_RESV_WINDOW_WIDTH, startOptions.GetWindowHeight()); + abilityRequest.want.SetParam(Want::PARAM_RESV_WINDOW_HEIGHT, startOptions.GetWindowHeight()); } bool withAnimation = startOptions.GetWithAnimation(); auto abilityRecord = Token::GetAbilityRecordByToken(callerToken); @@ -3238,11 +3238,11 @@ int AbilityManagerService::CloseUIAbilityBySCB(const sptr &sessionI EventInfo eventInfo; eventInfo.bundleName = abilityRecord->GetAbilityInfo().bundleName; eventInfo.abilityName = abilityRecord->GetAbilityInfo().name; - SendAbilityEvent(EventName::CLOSE_UI_ABILITY_BY_SCB, HiSysEventType::BEHAVIOR, eventInfo); + SendAbilityEvent(EventName::CLOSE_ABILITY, HiSysEventType::BEHAVIOR, eventInfo); eventInfo.errCode = uiAbilityManager->CloseUIAbility(abilityRecord, sessionInfo->resultCode, &(sessionInfo->want), sessionInfo->isClearSession); if (eventInfo.errCode != ERR_OK) { - SendAbilityEvent(EventName::CLOSE_UI_ABILITY_BY_SCB_ERROR, HiSysEventType::FAULT, eventInfo); + SendAbilityEvent(EventName::TERMINATE_ABILITY_ERROR, HiSysEventType::FAULT, eventInfo); } return eventInfo.errCode; } diff --git a/services/appmgr/include/app_mgr_service_inner.h b/services/appmgr/include/app_mgr_service_inner.h index 874feb29af..c8224f29d5 100644 --- a/services/appmgr/include/app_mgr_service_inner.h +++ b/services/appmgr/include/app_mgr_service_inner.h @@ -1136,7 +1136,8 @@ private: void StartProcess(const std::string &appName, const std::string &processName, uint32_t startFlags, std::shared_ptr appRecord, const int uid, const BundleInfo &bundleInfo, const std::string &bundleName, const int32_t bundleIndex, bool appExistFlag = true, - bool isPreload = false); + bool isPreload = false, const std::string &moduleName = "", const std::string &abilityName = "", + bool strictMode = false); /** * PushAppFront, Adjust the latest application record to the top level. @@ -1402,7 +1403,12 @@ private: int32_t CreateStartMsg(const std::string &processName, uint32_t startFlags, const int uid, const BundleInfo &bundleInfo, const int32_t bundleIndex, BundleType bundleType, - AppSpawnStartMsg &startMsg); + AppSpawnStartMsg &startMsg, const std::string &moduleName = "", const std::string &abilityName = "", + bool strictMode = false); + + void QueryExtensionSandBox(const std::string &moduleName, const std::string &abilityName, + const BundleInfo &bundleInfo, AppSpawnStartMsg &startMsg, DataGroupInfoList& dataGroupInfoList, + bool strictMode); int32_t StartPerfProcessByStartMsg(AppSpawnStartMsg &startMsg, const std::string& perfCmd, const std::string& debugCmd, bool isSandboxApp); diff --git a/services/appmgr/include/app_spawn_client.h b/services/appmgr/include/app_spawn_client.h index adbcb4f735..d718e30998 100644 --- a/services/appmgr/include/app_spawn_client.h +++ b/services/appmgr/include/app_spawn_client.h @@ -68,6 +68,9 @@ struct AppSpawnStartMsg { std::string provisionType; bool atomicServiceFlag = false; std::string atomicAccount = ""; + bool isolatedExtension = false; // whether is isolatedExtension + std::string extensionSandboxPath; + bool strictMode = false; // whether is strict mode }; constexpr auto LEN_PID = sizeof(pid_t); @@ -161,6 +164,22 @@ public: */ int32_t SetAtomicServiceFlag(const AppSpawnStartMsg &startMsg, AppSpawnReqMsgHandle reqHandle); + /** + * Set strict mode flags. + * + * @param startMsg, request message. + * @param reqHandle, handle for request message + */ + int32_t SetStrictMode(const AppSpawnStartMsg &startMsg, AppSpawnReqMsgHandle reqHandle); + + /** + * Set app extension flags. + * + * @param startMsg, request message. + * @param reqHandle, handle for request message + */ + int32_t SetAppExtension(const AppSpawnStartMsg &startMsg, AppSpawnReqMsgHandle reqHandle); + /** * Set extra info: render-cmd, HspList, Overlay, DataGroup, AppEnv. * diff --git a/services/appmgr/src/app_mgr_service_inner.cpp b/services/appmgr/src/app_mgr_service_inner.cpp index 0a1c3b3bcc..2bfc2ba498 100644 --- a/services/appmgr/src/app_mgr_service_inner.cpp +++ b/services/appmgr/src/app_mgr_service_inner.cpp @@ -142,6 +142,7 @@ const std::string TSAN_FLAG_NAME = "tsanEnabled"; const std::string MEMMGR_PROC_NAME = "memmgrservice"; const std::string UIEXTENSION_ABILITY_ID = "ability.want.params.uiExtensionAbilityId"; const std::string UIEXTENSION_ROOT_HOST_PID = "ability.want.params.uiExtensionRootHostPid"; +const std::string STRICT_MODE = "strictMode"; const int32_t SIGNAL_KILL = 9; constexpr int32_t USER_SCALE = 200000; #define ENUM_TO_STRING(s) #s @@ -644,8 +645,10 @@ void AppMgrServiceInner::LoadAbilityNoAppRecord(const std::shared_ptrGetBoolParam(STRICT_MODE, false); StartProcess(abilityInfo->applicationName, processName, startFlags, appRecord, - appInfo->uid, bundleInfo, appInfo->bundleName, bundleIndex, appExistFlag, isPreload); + appInfo->uid, bundleInfo, appInfo->bundleName, bundleIndex, appExistFlag, isPreload, abilityInfo->moduleName, + abilityInfo->name, strictMode); std::string perfCmd = (want == nullptr) ? "" : want->GetStringParam(PERF_CMD); bool isSandboxApp = (want == nullptr) ? false : want->GetBoolParam(ENTER_SANDBOX, false); (void)StartPerfProcess(appRecord, perfCmd, "", isSandboxApp); @@ -726,7 +729,9 @@ bool AppMgrServiceInner::GetBundleAndHapInfo(const AbilityInfo &abilityInfo, int32_t bundleMgrResult; if (appIndex == 0) { bundleMgrResult = IN_PROCESS_CALL(bundleMgrHelper->GetBundleInfoV9(appInfo->bundleName, - static_cast(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_APPLICATION), bundleInfo, userId)); + static_cast(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_APPLICATION) | + static_cast(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_EXTENSION_ABILITY) | + static_cast(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_HAP_MODULE), bundleInfo, userId)); } else if (appIndex <= AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX) { bundleMgrResult = IN_PROCESS_CALL(bundleMgrHelper->GetCloneBundleInfo(appInfo->bundleName, static_cast(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_APPLICATION), appIndex, bundleInfo, userId)); @@ -734,7 +739,6 @@ bool AppMgrServiceInner::GetBundleAndHapInfo(const AbilityInfo &abilityInfo, bundleMgrResult = IN_PROCESS_CALL(bundleMgrHelper->GetSandboxBundleInfo(appInfo->bundleName, appIndex, userId, bundleInfo)); } - if (bundleMgrResult != ERR_OK) { TAG_LOGE(AAFwkTag::APPMGR, "GetBundleInfo is fail."); return false; @@ -749,7 +753,6 @@ bool AppMgrServiceInner::GetBundleAndHapInfo(const AbilityInfo &abilityInfo, TAG_LOGE(AAFwkTag::APPMGR, "GetHapModuleInfo is fail."); return false; } - return true; } @@ -2533,7 +2536,8 @@ void AppMgrServiceInner::SetAppInfo(const BundleInfo &bundleInfo, AppSpawnStartM } int32_t AppMgrServiceInner::CreateStartMsg(const std::string &processName, uint32_t startFlags, const int uid, - const BundleInfo &bundleInfo, const int32_t bundleIndex, BundleType bundleType, AppSpawnStartMsg &startMsg) + const BundleInfo &bundleInfo, const int32_t bundleIndex, BundleType bundleType, AppSpawnStartMsg &startMsg, + const std::string &moduleName, const std::string &abilityName, bool strictMode) { if (!remoteClientManager_ || !otherTaskHandler_) { TAG_LOGE(AAFwkTag::APPMGR, "remoteClientManager or otherTaskHandler is nullptr."); @@ -2565,8 +2569,7 @@ int32_t AppMgrServiceInner::CreateStartMsg(const std::string &processName, uint3 if (!result || dataGroupInfoList.empty()) { TAG_LOGD(AAFwkTag::APPMGR, "the bundle has no groupInfos."); } - startMsg.dataGroupInfoList = dataGroupInfoList; - + QueryExtensionSandBox(moduleName, abilityName, bundleInfo, startMsg, dataGroupInfoList, strictMode); startMsg.bundleName = bundleInfo.name; startMsg.renderParam = RENDER_PARAM; startMsg.flags = startFlags; @@ -2588,9 +2591,42 @@ int32_t AppMgrServiceInner::CreateStartMsg(const std::string &processName, uint3 return ERR_OK; } +void AppMgrServiceInner::QueryExtensionSandBox(const std::string &moduleName, const std::string &abilityName, + const BundleInfo &bundleInfo, AppSpawnStartMsg &startMsg, DataGroupInfoList& dataGroupInfoList, bool strictMode) +{ + std::vector extensionInfos; + for (auto hapModuleInfo: bundleInfo.hapModuleInfos) { + extensionInfos.insert(extensionInfos.end(), hapModuleInfo.extensionInfos.begin(), + hapModuleInfo.extensionInfos.end()); + } + auto infoExisted = [&moduleName, &abilityName](const ExtensionAbilityInfo& info) { + return info.moduleName == moduleName && info.name == abilityName && info.needCreateSandbox; + }; + auto infoIter = std::find_if(extensionInfos.begin(), extensionInfos.end(), infoExisted); + DataGroupInfoList extensionDataGroupInfoList; + if (infoIter != extensionInfos.end()) { + startMsg.isolatedExtension = infoIter->needCreateSandbox; + startMsg.extensionSandboxPath = infoIter->moduleName + "/" + infoIter->name; + startMsg.strictMode = strictMode; + for (auto dataGroupInfo : dataGroupInfoList) { + auto groupIdExisted = [&dataGroupInfo](const std::string &dataGroupId) { + return dataGroupInfo.dataGroupId == dataGroupId; + }; + if (std::find_if(infoIter->dataGroupIds.begin(), infoIter->dataGroupIds.end(), groupIdExisted) != + infoIter->dataGroupIds.end()) { + extensionDataGroupInfoList.emplace_back(dataGroupInfo); + } + } + startMsg.dataGroupInfoList = extensionDataGroupInfoList; + } else { + startMsg.dataGroupInfoList = dataGroupInfoList; + } +} + void AppMgrServiceInner::StartProcess(const std::string &appName, const std::string &processName, uint32_t startFlags, std::shared_ptr appRecord, const int uid, const BundleInfo &bundleInfo, - const std::string &bundleName, const int32_t bundleIndex, bool appExistFlag, bool isPreload) + const std::string &bundleName, const int32_t bundleIndex, bool appExistFlag, bool isPreload, + const std::string &moduleName, const std::string &abilityName, bool strictMode) { HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__); TAG_LOGD(AAFwkTag::APPMGR, "bundleName: %{public}s, isPreload: %{public}d", bundleName.c_str(), isPreload); @@ -2608,7 +2644,8 @@ void AppMgrServiceInner::StartProcess(const std::string &appName, const std::str AppSpawnStartMsg startMsg; auto appInfo = appRecord->GetApplicationInfo(); auto bundleType = appInfo ? appInfo->bundleType : BundleType::APP; - if (CreateStartMsg(processName, startFlags, uid, bundleInfo, bundleIndex, bundleType, startMsg) != ERR_OK) { + if (CreateStartMsg(processName, startFlags, uid, bundleInfo, bundleIndex, bundleType, startMsg, moduleName, + abilityName, strictMode) != ERR_OK) { TAG_LOGE(AAFwkTag::APPMGR, "CreateStartMsg failed."); appRunningManager_->RemoveAppRunningRecordById(appRecord->GetRecordId()); return; diff --git a/services/appmgr/src/app_spawn_client.cpp b/services/appmgr/src/app_spawn_client.cpp index 8257705653..5eef8c803e 100644 --- a/services/appmgr/src/app_spawn_client.cpp +++ b/services/appmgr/src/app_spawn_client.cpp @@ -129,6 +129,15 @@ static std::string DumpAppEnvToJson(const std::map &ap return appEnvJson.dump(); } +static std::string DumpExtensionSandboxDirsToJson(const std::map &extensionSandboxDirs) +{ + nlohmann::json extensionSandboxDirsJson; + for (auto &[userId, sandboxDir] : extensionSandboxDirs) { + extensionSandboxDirsJson[userId] = sandboxDir; + } + return extensionSandboxDirsJson.dump(); +} + int32_t AppSpawnClient::SetDacInfo(const AppSpawnStartMsg &startMsg, AppSpawnReqMsgHandle reqHandle) { int32_t ret = 0; @@ -194,6 +203,26 @@ int32_t AppSpawnClient::SetAtomicServiceFlag(const AppSpawnStartMsg &startMsg, A return ret; } +int32_t AppSpawnClient::SetStrictMode(const AppSpawnStartMsg &startMsg, AppSpawnReqMsgHandle reqHandle) +{ + int32_t ret = 0; + if (startMsg.strictMode && + (ret = AppSpawnReqMsgSetAppFlag(reqHandle, APP_FLAGS_ISOLATED_SANDBOX))) { + HILOG_ERROR("AppSpawnReqMsgSetAppFlag failed, ret: %{public}d", ret); + } + return ret; +} + +int32_t AppSpawnClient::SetAppExtension(const AppSpawnStartMsg &startMsg, AppSpawnReqMsgHandle reqHandle) +{ + int32_t ret = 0; + if (startMsg.isolatedExtension && + (ret = AppSpawnReqMsgSetAppFlag(reqHandle, APP_FLAGS_EXTENSION_SANDBOX))) { + HILOG_ERROR("AppSpawnReqMsgSetAppFlag failed, ret: %{public}d", ret); + } + return ret; +} + int32_t AppSpawnClient::AppspawnSetExtMsg(const AppSpawnStartMsg &startMsg, AppSpawnReqMsgHandle reqHandle) { int32_t ret = 0; @@ -235,6 +264,7 @@ int32_t AppSpawnClient::AppspawnSetExtMsg(const AppSpawnStartMsg &startMsg, AppS return ret; } } + if (!startMsg.atomicAccount.empty() && (ret = AppSpawnReqMsgAddExtInfo(reqHandle, MSG_EXT_NAME_ACCOUNT_ID, reinterpret_cast(startMsg.atomicAccount.c_str()), startMsg.atomicAccount.size()))) { @@ -248,6 +278,14 @@ int32_t AppSpawnClient::AppspawnSetExtMsg(const AppSpawnStartMsg &startMsg, AppS return ret; } + if (!startMsg.extensionSandboxPath.empty()) { + ret = AppSpawnReqMsgAddStringInfo(reqHandle, MSG_EXT_NAME_APP_EXTENSION, + startMsg.extensionSandboxPath.c_str()); + if (ret) { + TAG_LOGE(AAFwkTag::APPMGR, "SetExtraExtensionSandboxDirs failed, ret: %{public}d", ret); + return ret; + } + } return ret; } @@ -302,7 +340,14 @@ int32_t AppSpawnClient::AppspawnCreateDefaultMsg(const AppSpawnStartMsg &startMs if (AppspawnSetExtMsg(startMsg, reqHandle)) { break; } - + if ((ret = SetStrictMode(startMsg, reqHandle))) { + TAG_LOGE(AAFwkTag::APPMGR, "SetStrictMode failed, ret: %{public}d", ret); + break; + } + if ((ret = SetAppExtension(startMsg, reqHandle))) { + TAG_LOGE(AAFwkTag::APPMGR, "SetAppExtension failed, ret: %{public}d", ret); + break; + } return ret; } while (0); diff --git a/services/common/include/event_report.h b/services/common/include/event_report.h index 1589826d96..50dbc9c52c 100644 --- a/services/common/include/event_report.h +++ b/services/common/include/event_report.h @@ -62,13 +62,11 @@ enum class EventName { STOP_EXTENSION_ERROR, CONNECT_SERVICE_ERROR, DISCONNECT_SERVICE_ERROR, - CLOSE_UI_ABILITY_BY_SCB_ERROR, // ability behavior event START_ABILITY, TERMINATE_ABILITY, CLOSE_ABILITY, - CLOSE_UI_ABILITY_BY_SCB, ABILITY_ONFOREGROUND, ABILITY_ONBACKGROUND, ABILITY_ONACTIVE, From 8ce357bff1874ecd50aca8c3a2982f7b6aa9f77c Mon Sep 17 00:00:00 2001 From: m30043719 Date: Fri, 17 May 2024 10:34:24 +0800 Subject: [PATCH 090/174] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E7=9F=AD=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E5=86=85=E6=8E=A5=E5=8F=A3=E8=BF=9E=E7=BB=AD=E8=B0=83?= =?UTF-8?q?=E7=94=A8=E9=80=A0=E6=88=90=E7=9A=84crash=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: m30043719 --- .../distributed_mission_manager.cpp | 2 ++ .../ability_manager_service_second_test.cpp | 23 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/frameworks/js/napi/mission_manager/distributed_mission_manager.cpp b/frameworks/js/napi/mission_manager/distributed_mission_manager.cpp index 9fc59d5a4a..9906b0b7fa 100644 --- a/frameworks/js/napi/mission_manager/distributed_mission_manager.cpp +++ b/frameworks/js/napi/mission_manager/distributed_mission_manager.cpp @@ -2066,6 +2066,7 @@ void UvWorkOnContinueDone(uv_work_t *work, int status) result = WrapInt32(continueAbilityCB->cbBase.cbInfo.env, continueAbilityCB->resultCode, "code"); } if (continueAbilityCB->cbBase.deferred == nullptr) { + std::lock_guard autoLock(registrationLock_); napi_value callback = nullptr; napi_value undefined = nullptr; napi_get_undefined(continueAbilityCB->cbBase.cbInfo.env, &undefined); @@ -2075,6 +2076,7 @@ void UvWorkOnContinueDone(uv_work_t *work, int status) napi_call_function(continueAbilityCB->cbBase.cbInfo.env, undefined, callback, 1, &result, &callResult); if (continueAbilityCB->cbBase.cbInfo.callback != nullptr) { napi_delete_reference(continueAbilityCB->cbBase.cbInfo.env, continueAbilityCB->cbBase.cbInfo.callback); + continueAbilityCB->cbBase.cbInfo.callback = nullptr; } } else { napi_value result[2] = { nullptr }; diff --git a/test/unittest/ability_manager_service_second_test/ability_manager_service_second_test.cpp b/test/unittest/ability_manager_service_second_test/ability_manager_service_second_test.cpp index 746b5d3b2b..792b59d6d3 100644 --- a/test/unittest/ability_manager_service_second_test/ability_manager_service_second_test.cpp +++ b/test/unittest/ability_manager_service_second_test/ability_manager_service_second_test.cpp @@ -735,6 +735,29 @@ HWTEST_F(AbilityManagerServiceSecondTest, ContinueMissionBundleName_001, TestSiz TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSecondTest ContinueMissionBundleName_001 end"); } +/* + * Feature: AbilityManagerService + * Function: ContinueMissionBundleName + * SubFunction: NA + * FunctionPoints: AbilityManagerService ContinueMissionBundleName + */ +HWTEST_F(AbilityManagerServiceSecondTest, ContinueMissionBundleName_002, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSecondTest ContinueMissionBundleName_002 start"); + auto abilityMs_ = std::make_shared(); + std::string srcDeviceId = ""; + std::string dstDeviceId = ""; + const sptr callback = nullptr; + AAFwk::WantParams wantParams; + ContinueMissionInfo continueMissionInfo; + continueMissionInfo.dstDeviceId = dstDeviceId; + continueMissionInfo.srcDeviceId = srcDeviceId; + continueMissionInfo.bundleName = ""; + continueMissionInfo.wantParams = wantParams; + EXPECT_EQ(abilityMs_->ContinueMission(continueMissionInfo, callback), CHECK_PERMISSION_FAILED); + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSecondTest ContinueMissionBundleName_002 end"); +} + /* * Feature: AbilityManagerService * Function: ContinueAbility From d373981a00b043174b13207b95df8719795c6d08 Mon Sep 17 00:00:00 2001 From: zhubingwei Date: Fri, 17 May 2024 16:23:02 +0800 Subject: [PATCH 091/174] =?UTF-8?q?TDD=E8=A6=86=E7=9B=96=E7=8E=87=E6=8F=90?= =?UTF-8?q?=E5=8D=87=E3=80=90ability=5Fability=5Fruntime=20=20quickfixmgr?= =?UTF-8?q?=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhubingwei --- .../quick_fix_manager_apply_task_test.cpp | 129 ++++++++++++++++++ 1 file changed, 129 insertions(+) diff --git a/test/unittest/quick_fix/quick_fix_manager_service_test/quick_fix_manager_apply_task_test.cpp b/test/unittest/quick_fix/quick_fix_manager_service_test/quick_fix_manager_apply_task_test.cpp index 65a50e3fae..545a63be6b 100644 --- a/test/unittest/quick_fix/quick_fix_manager_service_test/quick_fix_manager_apply_task_test.cpp +++ b/test/unittest/quick_fix/quick_fix_manager_service_test/quick_fix_manager_apply_task_test.cpp @@ -624,5 +624,134 @@ HWTEST_F(QuickFixManagerApplyTaskTest, PostRevokeQuickFixNotifyUnloadPatchTask_0 EXPECT_EQ(applyTask->quickFixMgrService_.promote(), quickFixMs_); TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); } + +/** + * @tc.name: PostRevokeQuickFixDeleteTask_0100 + * @tc.desc: revoke quick fix delete task. + * @tc.type: FUNC + */ +HWTEST_F(QuickFixManagerApplyTaskTest, PostRevokeQuickFixDeleteTask_0100, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + auto applyTask = std::make_shared(nullptr, appMgr_, + quickFixMs_->eventHandler_, quickFixMs_); + ASSERT_NE(applyTask, nullptr); + applyTask->bundleName_ = "testBundleName"; + applyTask->bundleVersionCode_ = 1; + applyTask->patchVersionCode_ = 100; + applyTask->isSoContained_ = true; + applyTask->taskType_ = QuickFixManagerApplyTask::TaskType::QUICK_FIX_REVOKE; + applyTask->PostRevokeQuickFixDeleteTask(); + EXPECT_EQ(applyTask->quickFixMgrService_.promote(), quickFixMs_); + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} + +/** + * @tc.name: PostRevokeQuickFixTask_0100 + * @tc.desc: post revoke quick fix task + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(QuickFixManagerApplyTaskTest, PostRevokeQuickFixTask_0100, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + auto applyTask = std::make_shared(bundleQfMgr_, appMgr_, + quickFixMs_->eventHandler_, quickFixMs_); + ASSERT_NE(applyTask, nullptr); + applyTask->PostRevokeQuickFixTask(); + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} + +/** + * @tc.name: PostRevokeQuickFixTask_0200 + * @tc.desc: post revoke quick fix task. + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(QuickFixManagerApplyTaskTest, PostRevokeQuickFixTask_0200, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + auto applyTask = std::make_shared(bundleQfMgr_, appMgr_, + nullptr, quickFixMs_); + ASSERT_NE(applyTask, nullptr); + applyTask->PostRevokeQuickFixTask(); + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} + +/** + * @tc.name: PostTimeOutTask_0100 + * @tc.desc: post timeout task + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(QuickFixManagerApplyTaskTest, PostTimeOutTask_0100, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + auto applyTask = std::make_shared(bundleQfMgr_, appMgr_, + quickFixMs_->eventHandler_, quickFixMs_); + ASSERT_NE(applyTask, nullptr); + applyTask->PostTimeOutTask(); + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} + +/** + * @tc.name: PostTimeOutTask_0200 + * @tc.desc: post timeout task + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(QuickFixManagerApplyTaskTest, PostTimeOutTask_0200, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + auto applyTask = std::make_shared(bundleQfMgr_, appMgr_, + nullptr, quickFixMs_); + ASSERT_NE(applyTask, nullptr); + applyTask->PostTimeOutTask(); + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} + +/** + * @tc.name: HandleRevokeQuickFixAppStop_0100 + * @tc.desc: revoke quick fix stop app. + * @tc.type: FUNC + * @tc.require: issueI5OD2E + */ +HWTEST_F(QuickFixManagerApplyTaskTest, HandleRevokeQuickFixAppStop_0100, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + auto applyTask = std::make_shared(bundleQfMgr_, appMgr_, + quickFixMs_->eventHandler_, quickFixMs_); + ASSERT_NE(applyTask, nullptr); + applyTask->bundleName_ = "testBundleName"; + applyTask->bundleVersionCode_ = 1; + applyTask->patchVersionCode_ = 100; + applyTask->isSoContained_ = true; + applyTask->taskType_ = QuickFixManagerApplyTask::TaskType::QUICK_FIX_REVOKE; + applyTask->HandleRevokeQuickFixAppStop(); + EXPECT_EQ(applyTask->quickFixMgrService_.promote(), quickFixMs_); + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} + +/** + * @tc.name: HandleRevokeQuickFixAppStop_0200 + * @tc.desc: revoke quick fix stop app. + * @tc.type: FUNC + * @tc.require: issueI5OD2E + */ +HWTEST_F(QuickFixManagerApplyTaskTest, HandleRevokeQuickFixAppStop_0200, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + auto applyTask = std::make_shared(nullptr, appMgr_, + quickFixMs_->eventHandler_, quickFixMs_); + ASSERT_NE(applyTask, nullptr); + applyTask->bundleName_ = "testBundleName"; + applyTask->bundleVersionCode_ = 1; + applyTask->patchVersionCode_ = 100; + applyTask->isSoContained_ = true; + applyTask->taskType_ = QuickFixManagerApplyTask::TaskType::QUICK_FIX_REVOKE; + applyTask->HandleRevokeQuickFixAppStop(); + EXPECT_EQ(applyTask->quickFixMgrService_.promote(), quickFixMs_); + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} } // namespace AppExecFwk } // namespace OHOS \ No newline at end of file From da8254a53098abace87a4f98d011e18d5db23faa Mon Sep 17 00:00:00 2001 From: XKK Date: Tue, 14 May 2024 15:05:04 +0800 Subject: [PATCH 092/174] =?UTF-8?q?=E7=8B=AC=E7=AB=8B=20startoptions?= =?UTF-8?q?=E4=B8=80=E4=B8=AAso?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: XKK --- bundle.json | 9 +++++ .../ability_auto_startup_callback/BUILD.gn | 1 + .../ability_auto_startup_manager/BUILD.gn | 1 + frameworks/js/napi/ability_manager/BUILD.gn | 1 + frameworks/js/napi/app/app_manager/BUILD.gn | 1 + frameworks/js/napi/app/error_manager/BUILD.gn | 1 + .../js/napi/app/js_app_manager/BUILD.gn | 1 + frameworks/js/napi/app/recovery/BUILD.gn | 1 + frameworks/js/napi/featureAbility/BUILD.gn | 1 + .../napi/inner/napi_ability_common/BUILD.gn | 1 + frameworks/js/napi/inner/napi_common/BUILD.gn | 1 + .../insight_intent_driver/BUILD.gn | 1 + frameworks/js/napi/js_dialog_session/BUILD.gn | 1 + .../js/napi/js_mission_manager/BUILD.gn | 1 + frameworks/js/napi/mission_manager/BUILD.gn | 2 + frameworks/js/napi/particleAbility/BUILD.gn | 1 + frameworks/js/napi/wantagent/BUILD.gn | 2 +- .../wantagent/ability_want_agent/BUILD.gn | 2 +- frameworks/native/ability/BUILD.gn | 1 + frameworks/native/ability/native/BUILD.gn | 12 ++++++ frameworks/native/appkit/BUILD.gn | 4 ++ .../insight_intent_context/BUILD.gn | 1 + interfaces/inner_api/ability_manager/BUILD.gn | 40 ++++++++++++++++++- interfaces/inner_api/wantagent/BUILD.gn | 9 ++++- .../kits/js/serviceroutermgr/BUILD.gn | 1 + .../services/srms/BUILD.gn | 1 + services/abilitymgr/BUILD.gn | 1 + .../abilityattachtimeout_fuzzer/BUILD.gn | 1 + .../abilityconnectionstub_fuzzer/BUILD.gn | 1 + .../abilityconnectmanager_fuzzer/BUILD.gn | 1 + test/fuzztest/abilitycontext_fuzzer/BUILD.gn | 1 + .../abilityeventhandler_fuzzer/BUILD.gn | 1 + .../abilitymanagerservicea_fuzzer/BUILD.gn | 1 + .../abilitymanagerserviceb_fuzzer/BUILD.gn | 1 + .../abilitymanagerservicec_fuzzer/BUILD.gn | 1 + .../abilitymanagerserviced_fuzzer/BUILD.gn | 1 + .../abilitymanagerservicee_fuzzer/BUILD.gn | 1 + .../BUILD.gn | 1 + .../abilitymanagerservicef_fuzzer/BUILD.gn | 1 + .../BUILD.gn | 1 + .../BUILD.gn | 1 + .../BUILD.gn | 1 + .../abilitymanagerserviceg_fuzzer/BUILD.gn | 1 + .../abilitymanagerserviceh_fuzzer/BUILD.gn | 1 + .../BUILD.gn | 1 + .../BUILD.gn | 1 + .../BUILD.gn | 1 + .../BUILD.gn | 1 + .../BUILD.gn | 1 + .../BUILD.gn | 1 + .../abilityrunningrecord_fuzzer/BUILD.gn | 1 + .../abilityschedulerstub_fuzzer/BUILD.gn | 1 + .../BUILD.gn | 1 + .../BUILD.gn | 1 + .../BUILD.gn | 1 + .../BUILD.gn | 1 + .../BUILD.gn | 1 + .../BUILD.gn | 1 + .../BUILD.gn | 1 + .../BUILD.gn | 1 + .../BUILD.gn | 1 + .../BUILD.gn | 1 + .../BUILD.gn | 1 + .../BUILD.gn | 1 + .../abilitystubcleanmission_fuzzer/BUILD.gn | 1 + .../BUILD.gn | 1 + .../BUILD.gn | 1 + .../BUILD.gn | 1 + .../BUILD.gn | 1 + .../abilitystubconnectability_fuzzer/BUILD.gn | 1 + .../BUILD.gn | 1 + .../BUILD.gn | 1 + .../BUILD.gn | 1 + .../BUILD.gn | 1 + .../BUILD.gn | 1 + .../BUILD.gn | 1 + .../BUILD.gn | 1 + .../BUILD.gn | 1 + .../BUILD.gn | 1 + .../BUILD.gn | 1 + .../BUILD.gn | 1 + .../BUILD.gn | 1 + .../BUILD.gn | 1 + .../abilitystubdumpstate_fuzzer/BUILD.gn | 1 + .../abilitystubdumpsysstate_fuzzer/BUILD.gn | 1 + .../abilitystubfinishusertest_fuzzer/BUILD.gn | 1 + .../abilitystubforceexitapp_fuzzer/BUILD.gn | 1 + .../BUILD.gn | 1 + .../BUILD.gn | 1 + .../BUILD.gn | 1 + .../BUILD.gn | 1 + .../BUILD.gn | 1 + .../BUILD.gn | 1 + .../BUILD.gn | 1 + .../BUILD.gn | 1 + .../BUILD.gn | 1 + .../abilitystubgetmissioninfo_fuzzer/BUILD.gn | 1 + .../BUILD.gn | 1 + .../BUILD.gn | 1 + .../BUILD.gn | 1 + .../BUILD.gn | 1 + .../BUILD.gn | 1 + .../BUILD.gn | 1 + .../BUILD.gn | 1 + .../BUILD.gn | 1 + .../BUILD.gn | 1 + .../abilitystubgettopability_fuzzer/BUILD.gn | 1 + .../BUILD.gn | 1 + .../ui_extension_context_test/BUILD.gn | 1 + tools/aa/BUILD.gn | 1 + 110 files changed, 177 insertions(+), 5 deletions(-) diff --git a/bundle.json b/bundle.json index 19dca40645..68f4e1fc53 100644 --- a/bundle.json +++ b/bundle.json @@ -428,6 +428,15 @@ ] }, "name": "//foundation/ability/ability_runtime/interfaces/inner_api/auto_fill_manager:auto_fill_manager" + }, + { + "header": { + "header_base": "//foundation/ability/ability_runtime/interfaces/inner_api/ability_manager/include", + "header_files": [ + "start_options.h" + ] + }, + "name": "//foundation/ability/ability_runtime/interfaces/inner_api/ability_manager:ability_start_options" } ], "test": [ diff --git a/frameworks/js/napi/ability_auto_startup_callback/BUILD.gn b/frameworks/js/napi/ability_auto_startup_callback/BUILD.gn index 525f5f723e..f957a2049e 100644 --- a/frameworks/js/napi/ability_auto_startup_callback/BUILD.gn +++ b/frameworks/js/napi/ability_auto_startup_callback/BUILD.gn @@ -27,6 +27,7 @@ ohos_shared_library("autostartupcallback") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_innerkits_path}/error_utils:ability_runtime_error_util", "${ability_runtime_innerkits_path}/runtime:runtime", diff --git a/frameworks/js/napi/ability_auto_startup_manager/BUILD.gn b/frameworks/js/napi/ability_auto_startup_manager/BUILD.gn index 498cc8e7b8..f1959c8b48 100644 --- a/frameworks/js/napi/ability_auto_startup_manager/BUILD.gn +++ b/frameworks/js/napi/ability_auto_startup_manager/BUILD.gn @@ -31,6 +31,7 @@ ohos_shared_library("autostartupmanager") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_innerkits_path}/error_utils:ability_runtime_error_util", "${ability_runtime_innerkits_path}/runtime:runtime", diff --git a/frameworks/js/napi/ability_manager/BUILD.gn b/frameworks/js/napi/ability_manager/BUILD.gn index 3c499c42d3..2c4d636bcb 100644 --- a/frameworks/js/napi/ability_manager/BUILD.gn +++ b/frameworks/js/napi/ability_manager/BUILD.gn @@ -33,6 +33,7 @@ template("abilitymanager") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_innerkits_path}/napi_base_context:napi_base_context", "${ability_runtime_innerkits_path}/runtime:runtime", diff --git a/frameworks/js/napi/app/app_manager/BUILD.gn b/frameworks/js/napi/app/app_manager/BUILD.gn index 4e371b4c55..f88d33ccb9 100644 --- a/frameworks/js/napi/app/app_manager/BUILD.gn +++ b/frameworks/js/napi/app/app_manager/BUILD.gn @@ -32,6 +32,7 @@ ohos_shared_library("appmanager_napi") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_innerkits_path}/runtime:runtime", "${ability_runtime_napi_path}/inner/napi_common:napi_common", diff --git a/frameworks/js/napi/app/error_manager/BUILD.gn b/frameworks/js/napi/app/error_manager/BUILD.gn index 8949155520..549a7041f7 100644 --- a/frameworks/js/napi/app/error_manager/BUILD.gn +++ b/frameworks/js/napi/app/error_manager/BUILD.gn @@ -34,6 +34,7 @@ template("errormanager") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_innerkits_path}/runtime:runtime", "${ability_runtime_native_path}/appkit:appkit_native", diff --git a/frameworks/js/napi/app/js_app_manager/BUILD.gn b/frameworks/js/napi/app/js_app_manager/BUILD.gn index 7f9e7601b1..61a3b604aa 100644 --- a/frameworks/js/napi/app/js_app_manager/BUILD.gn +++ b/frameworks/js/napi/app/js_app_manager/BUILD.gn @@ -37,6 +37,7 @@ ohos_shared_library("appmanager") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_innerkits_path}/error_utils:ability_runtime_error_util", "${ability_runtime_innerkits_path}/runtime:runtime", diff --git a/frameworks/js/napi/app/recovery/BUILD.gn b/frameworks/js/napi/app/recovery/BUILD.gn index 27e1be5244..86a45387b1 100644 --- a/frameworks/js/napi/app/recovery/BUILD.gn +++ b/frameworks/js/napi/app/recovery/BUILD.gn @@ -32,6 +32,7 @@ ohos_shared_library("apprecovery_napi") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_innerkits_path}/runtime:runtime", "${ability_runtime_napi_path}/inner/napi_common:napi_common", diff --git a/frameworks/js/napi/featureAbility/BUILD.gn b/frameworks/js/napi/featureAbility/BUILD.gn index b150fc5732..7470b9ac80 100644 --- a/frameworks/js/napi/featureAbility/BUILD.gn +++ b/frameworks/js/napi/featureAbility/BUILD.gn @@ -27,6 +27,7 @@ ohos_shared_library("featureability") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/ability_manager:ability_start_setting", "${ability_runtime_innerkits_path}/dataobs_manager:dataobs_manager", "${ability_runtime_innerkits_path}/napi_base_context:napi_base_context", diff --git a/frameworks/js/napi/inner/napi_ability_common/BUILD.gn b/frameworks/js/napi/inner/napi_ability_common/BUILD.gn index 3017b49183..d76f8bae2e 100644 --- a/frameworks/js/napi/inner/napi_ability_common/BUILD.gn +++ b/frameworks/js/napi/inner/napi_ability_common/BUILD.gn @@ -32,6 +32,7 @@ ohos_shared_library("napi_ability_common") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/ability_manager:ability_start_setting", "${ability_runtime_innerkits_path}/napi_base_context:napi_base_context", "${ability_runtime_innerkits_path}/runtime:runtime", diff --git a/frameworks/js/napi/inner/napi_common/BUILD.gn b/frameworks/js/napi/inner/napi_common/BUILD.gn index de57564b9d..cbc06d8d9f 100644 --- a/frameworks/js/napi/inner/napi_common/BUILD.gn +++ b/frameworks/js/napi/inner/napi_common/BUILD.gn @@ -42,6 +42,7 @@ ohos_shared_library("napi_common") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/ability_manager:process_options", "${ability_runtime_innerkits_path}/runtime:runtime", ] diff --git a/frameworks/js/napi/insight_intent/insight_intent_driver/BUILD.gn b/frameworks/js/napi/insight_intent/insight_intent_driver/BUILD.gn index d7c8410cac..d8b47e45fa 100644 --- a/frameworks/js/napi/insight_intent/insight_intent_driver/BUILD.gn +++ b/frameworks/js/napi/insight_intent/insight_intent_driver/BUILD.gn @@ -25,6 +25,7 @@ ohos_shared_library("insightintentdriver_napi") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/runtime:runtime", "${ability_runtime_napi_path}/inner/napi_common:napi_common", "${ability_runtime_native_path}/ability/native:ability_business_error", diff --git a/frameworks/js/napi/js_dialog_session/BUILD.gn b/frameworks/js/napi/js_dialog_session/BUILD.gn index 19e7a4e7ed..1e92d32013 100644 --- a/frameworks/js/napi/js_dialog_session/BUILD.gn +++ b/frameworks/js/napi/js_dialog_session/BUILD.gn @@ -27,6 +27,7 @@ ohos_shared_library("dialogsession_napi") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/runtime:runtime", "${ability_runtime_napi_path}/inner/napi_common:napi_common", "${ability_runtime_native_path}/appkit:app_context", diff --git a/frameworks/js/napi/js_mission_manager/BUILD.gn b/frameworks/js/napi/js_mission_manager/BUILD.gn index f501ff6223..2353569778 100755 --- a/frameworks/js/napi/js_mission_manager/BUILD.gn +++ b/frameworks/js/napi/js_mission_manager/BUILD.gn @@ -28,6 +28,7 @@ ohos_shared_library("missionmanager") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/ability_manager:mission_info", "${ability_runtime_innerkits_path}/runtime:runtime", "${ability_runtime_napi_path}/inner/napi_common:napi_common", diff --git a/frameworks/js/napi/mission_manager/BUILD.gn b/frameworks/js/napi/mission_manager/BUILD.gn index ef94b19dd4..63f104937b 100644 --- a/frameworks/js/napi/mission_manager/BUILD.gn +++ b/frameworks/js/napi/mission_manager/BUILD.gn @@ -28,6 +28,7 @@ ohos_shared_library("missionmanager_napi") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/ability_manager:mission_info", "${ability_runtime_innerkits_path}/runtime:runtime", "${ability_runtime_napi_path}/inner/napi_common:napi_common", @@ -78,6 +79,7 @@ ohos_shared_library("distributedmissionmanager") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/ability_manager:mission_info", "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_napi_path}/inner/napi_common:napi_common", diff --git a/frameworks/js/napi/particleAbility/BUILD.gn b/frameworks/js/napi/particleAbility/BUILD.gn index 7e2147834a..d8be1e9f79 100644 --- a/frameworks/js/napi/particleAbility/BUILD.gn +++ b/frameworks/js/napi/particleAbility/BUILD.gn @@ -31,6 +31,7 @@ ohos_shared_library("particleability") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/dataobs_manager:dataobs_manager", "${ability_runtime_innerkits_path}/napi_base_context:napi_base_context", "${ability_runtime_innerkits_path}/runtime:runtime", diff --git a/frameworks/js/napi/wantagent/BUILD.gn b/frameworks/js/napi/wantagent/BUILD.gn index 228f920b0c..d27b8302b5 100644 --- a/frameworks/js/napi/wantagent/BUILD.gn +++ b/frameworks/js/napi/wantagent/BUILD.gn @@ -28,7 +28,7 @@ ohos_shared_library("wantagent") { ] deps = [ - "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/error_utils:ability_runtime_error_util", "${ability_runtime_innerkits_path}/runtime:runtime", "${ability_runtime_innerkits_path}/wantagent:wantagent_innerkits", diff --git a/frameworks/js/napi/wantagent/ability_want_agent/BUILD.gn b/frameworks/js/napi/wantagent/ability_want_agent/BUILD.gn index 8b53639aec..bdde0232e8 100644 --- a/frameworks/js/napi/wantagent/ability_want_agent/BUILD.gn +++ b/frameworks/js/napi/wantagent/ability_want_agent/BUILD.gn @@ -29,7 +29,7 @@ ohos_shared_library("wantagent_napi") { ] deps = [ - "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/error_utils:ability_runtime_error_util", "${ability_runtime_innerkits_path}/runtime:runtime", "${ability_runtime_innerkits_path}/wantagent:wantagent_innerkits", diff --git a/frameworks/native/ability/BUILD.gn b/frameworks/native/ability/BUILD.gn index 22ab306501..484572aa82 100644 --- a/frameworks/native/ability/BUILD.gn +++ b/frameworks/native/ability/BUILD.gn @@ -60,6 +60,7 @@ ohos_shared_library("ability_context_native") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/deps_wrapper:ability_deps_wrapper", "${ability_runtime_innerkits_path}/runtime:runtime", "${ability_runtime_napi_path}/inner/napi_common:napi_common", diff --git a/frameworks/native/ability/native/BUILD.gn b/frameworks/native/ability/native/BUILD.gn index e5d0cd0fa7..d3b44a5485 100644 --- a/frameworks/native/ability/native/BUILD.gn +++ b/frameworks/native/ability/native/BUILD.gn @@ -229,6 +229,7 @@ ohos_shared_library("abilitykit_native") { ":continuation_ipc", ":extension_blocklist_config", "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/ability_manager:ability_start_setting", "${ability_runtime_innerkits_path}/ability_manager:mission_info", "${ability_runtime_innerkits_path}/dataobs_manager:dataobs_manager", @@ -373,6 +374,7 @@ ohos_shared_library("extensionkit_native") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/runtime:runtime", "${ability_runtime_napi_path}/inner/napi_common:napi_common", "${ability_runtime_native_path}/ability:ability_context_native", @@ -426,6 +428,7 @@ ohos_shared_library("insight_intent_executor") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/runtime:runtime", "${ability_runtime_napi_path}/inner/napi_common:napi_common", "${ability_runtime_native_path}/ability/native:ability_business_error", @@ -500,6 +503,7 @@ ohos_shared_library("uiabilitykit_native") { ":continuation_ipc", ":ui_extension", "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/ability_manager:ability_start_setting", "${ability_runtime_innerkits_path}/ability_manager:process_options", "${ability_runtime_innerkits_path}/runtime:runtime", @@ -573,6 +577,7 @@ ohos_shared_library("ability_thread") { ":extensionkit_native", ":uiabilitykit_native", "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/dataobs_manager:dataobs_manager", "${ability_runtime_native_path}/ability:ability_context_native", "${ability_runtime_native_path}/appkit:app_context", @@ -704,6 +709,7 @@ ohos_shared_library("service_extension") { deps = [ ":abilitykit_native", "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/runtime:runtime", "${ability_runtime_napi_path}/inner/napi_common:napi_common", "${ability_runtime_native_path}/ability:ability_context_native", @@ -768,6 +774,7 @@ ohos_shared_library("continuation_ipc") { deps = [ ":abilitykit_utils", "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", ] external_deps = [ @@ -981,6 +988,7 @@ ohos_shared_library("ui_extension") { deps = [ ":abilitykit_native", "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/runtime:runtime", "${ability_runtime_napi_path}/inner/napi_common:napi_common", "${ability_runtime_native_path}/ability:ability_context_native", @@ -1070,6 +1078,7 @@ ohos_shared_library("share_extension") { ":abilitykit_native", ":ui_extension", "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/runtime:runtime", "${ability_runtime_napi_path}/inner/napi_common:napi_common", "${ability_runtime_native_path}/ability:ability_context_native", @@ -1120,6 +1129,7 @@ ohos_shared_library("action_extension") { ":abilitykit_native", ":ui_extension", "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/runtime:runtime", "${ability_runtime_napi_path}/inner/napi_common:napi_common", "${ability_runtime_native_path}/ability:ability_context_native", @@ -1321,6 +1331,7 @@ ohos_shared_library("embedded_ui_extension") { ":abilitykit_native", ":ui_extension", "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/runtime:runtime", "${ability_runtime_napi_path}/inner/napi_common:napi_common", "${ability_runtime_native_path}/ability:ability_context_native", @@ -1414,6 +1425,7 @@ ohos_shared_library("auto_fill_extension") { ":insight_intent_executor", ":ui_extension", "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/runtime:runtime", "${ability_runtime_napi_path}/inner/napi_common:napi_common", "${ability_runtime_native_path}/ability:ability_context_native", diff --git a/frameworks/native/appkit/BUILD.gn b/frameworks/native/appkit/BUILD.gn index 02a9a4bedd..4b62cc00aa 100644 --- a/frameworks/native/appkit/BUILD.gn +++ b/frameworks/native/appkit/BUILD.gn @@ -150,6 +150,7 @@ ohos_shared_library("appkit_native") { ":appkit_delegator", "${ability_runtime_abilitymgr_path}/:abilityms", "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_innerkits_path}/child_process_manager:child_process_manager", "${ability_runtime_innerkits_path}/deps_wrapper:ability_deps_wrapper", @@ -267,6 +268,7 @@ ohos_shared_library("app_context") { } deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_innerkits_path}/deps_wrapper:ability_deps_wrapper", "${ability_runtime_innerkits_path}/runtime:runtime", @@ -325,6 +327,7 @@ ohos_shared_library("app_context_utils") { } deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_innerkits_path}/error_utils:ability_runtime_error_util", "${ability_runtime_innerkits_path}/runtime:runtime", @@ -397,6 +400,7 @@ ohos_shared_library("appkit_delegator") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/runtime:runtime", "${ability_runtime_native_path}/appkit:app_context", "${ability_runtime_native_path}/appkit:delegator_mgmt", diff --git a/frameworks/native/insight_intent/insight_intent_context/BUILD.gn b/frameworks/native/insight_intent/insight_intent_context/BUILD.gn index 66264511ed..1f51aad0e6 100644 --- a/frameworks/native/insight_intent/insight_intent_context/BUILD.gn +++ b/frameworks/native/insight_intent/insight_intent_context/BUILD.gn @@ -34,6 +34,7 @@ ohos_shared_library("insightintentcontext") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/runtime:runtime", "${ability_runtime_napi_path}/inner/napi_common:napi_common", "${ability_runtime_native_path}/ability/native:ability_business_error", diff --git a/interfaces/inner_api/ability_manager/BUILD.gn b/interfaces/inner_api/ability_manager/BUILD.gn index 4d3dbe7d92..c81443611c 100644 --- a/interfaces/inner_api/ability_manager/BUILD.gn +++ b/interfaces/inner_api/ability_manager/BUILD.gn @@ -92,7 +92,6 @@ ohos_shared_library("ability_manager") { "${ability_runtime_services_path}/abilitymgr/src/remote_on_listener_proxy.cpp", "${ability_runtime_services_path}/abilitymgr/src/remote_on_listener_stub.cpp", "${ability_runtime_services_path}/abilitymgr/src/sender_info.cpp", - "${ability_runtime_services_path}/abilitymgr/src/start_options.cpp", "${ability_runtime_services_path}/abilitymgr/src/system_ability_token_callback_stub.cpp", "${ability_runtime_services_path}/abilitymgr/src/ui_extension_ability_connect_info.cpp", "${ability_runtime_services_path}/abilitymgr/src/ui_extension_host_info.cpp", @@ -125,6 +124,7 @@ ohos_shared_library("ability_manager") { public_deps = [ ":ability_connect_callback_stub" ] deps = [ + ":ability_start_options", ":ability_start_setting", ":mission_info", ":process_options", @@ -180,6 +180,44 @@ ohos_shared_library("ability_manager") { part_name = "ability_runtime" } +ohos_shared_library("ability_start_options") { + sanitize = { + integer_overflow = true + ubsan = true + boundary_sanitize = true + cfi = true + cfi_cross_dso = true + cfi_vcall_icall_only = true + debug = false + } + branch_protector_ret = "pac_ret" + + include_dirs = [ + "include/", + "${ability_runtime_services_path}/common/include", + ] + + sources = + [ "${ability_runtime_services_path}/abilitymgr/src/start_options.cpp" ] + + deps = [ ":process_options" ] + + external_deps = [ + "c_utils:utils", + "hilog:libhilog", + "hisysevent:libhisysevent", + "ipc:ipc_core", + ] + + cflags_cc = [] + innerapi_tags = [ + "platformsdk", + "sasdk", + ] + subsystem_name = "ability" + part_name = "ability_runtime" +} + ohos_shared_library("mission_info") { sources = [ "${ability_runtime_services_path}/abilitymgr/src/mission_info.cpp", diff --git a/interfaces/inner_api/wantagent/BUILD.gn b/interfaces/inner_api/wantagent/BUILD.gn index 04aa0574bf..bcc4d00546 100644 --- a/interfaces/inner_api/wantagent/BUILD.gn +++ b/interfaces/inner_api/wantagent/BUILD.gn @@ -43,7 +43,11 @@ config("wantagent_innerkits_public_config") { } ohos_shared_library("wantagent_innerkits") { - include_dirs = [ "${ability_runtime_services_path}/common/include" ] + include_dirs = [ + "${ability_runtime_services_path}/common/include", + "${ability_runtime_path}/interfaces/kits/native/appkit/ability_bundle_manager_helper", + "${ability_runtime_path}/interfaces/inner_api/deps_wrapper/include", + ] sources = [ "${ability_runtime_services_path}/abilitymgr/src/sender_info.cpp", @@ -67,11 +71,12 @@ ohos_shared_library("wantagent_innerkits") { public_configs = [ ":wantagent_innerkits_public_config" ] deps = [ - "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/error_utils:ability_runtime_error_util", ] external_deps = [ + "ability_base:session_info", "ability_base:want", "bundle_framework:appexecfwk_core", "c_utils:utils", diff --git a/service_router_framework/interfaces/kits/js/serviceroutermgr/BUILD.gn b/service_router_framework/interfaces/kits/js/serviceroutermgr/BUILD.gn index 59ff9fd5fb..ab2448d98d 100755 --- a/service_router_framework/interfaces/kits/js/serviceroutermgr/BUILD.gn +++ b/service_router_framework/interfaces/kits/js/serviceroutermgr/BUILD.gn @@ -37,6 +37,7 @@ ohos_shared_library("businessabilityrouter") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${srms_inner_api_path}:srms_fwk", ] diff --git a/service_router_framework/services/srms/BUILD.gn b/service_router_framework/services/srms/BUILD.gn index b358dfc2ec..8f5df9fe77 100755 --- a/service_router_framework/services/srms/BUILD.gn +++ b/service_router_framework/services/srms/BUILD.gn @@ -40,6 +40,7 @@ ohos_shared_library("libsrms") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/appkit:appkit_manager_helper", "${srms_inner_api_path}:srms_fwk", ] diff --git a/services/abilitymgr/BUILD.gn b/services/abilitymgr/BUILD.gn index dc4abdd7d7..7420546872 100644 --- a/services/abilitymgr/BUILD.gn +++ b/services/abilitymgr/BUILD.gn @@ -116,6 +116,7 @@ ohos_shared_library("abilityms") { include_dirs = [ "${ability_runtime_services_path}/appdfr/include" ] deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/ability_manager:ability_start_setting", "${ability_runtime_innerkits_path}/ability_manager:mission_info", "${ability_runtime_innerkits_path}/ability_manager:process_options", diff --git a/test/fuzztest/abilityattachtimeout_fuzzer/BUILD.gn b/test/fuzztest/abilityattachtimeout_fuzzer/BUILD.gn index 771d0e26c0..d3733d99fc 100755 --- a/test/fuzztest/abilityattachtimeout_fuzzer/BUILD.gn +++ b/test/fuzztest/abilityattachtimeout_fuzzer/BUILD.gn @@ -37,6 +37,7 @@ ohos_fuzztest("AbilityAttachTimeOutFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", diff --git a/test/fuzztest/abilityconnectionstub_fuzzer/BUILD.gn b/test/fuzztest/abilityconnectionstub_fuzzer/BUILD.gn index f62f1d3da8..0bb04b5efb 100755 --- a/test/fuzztest/abilityconnectionstub_fuzzer/BUILD.gn +++ b/test/fuzztest/abilityconnectionstub_fuzzer/BUILD.gn @@ -37,6 +37,7 @@ ohos_fuzztest("AbilityConnectionStubFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", ] diff --git a/test/fuzztest/abilityconnectmanager_fuzzer/BUILD.gn b/test/fuzztest/abilityconnectmanager_fuzzer/BUILD.gn index 0e7f222d54..f9e6ff61d7 100755 --- a/test/fuzztest/abilityconnectmanager_fuzzer/BUILD.gn +++ b/test/fuzztest/abilityconnectmanager_fuzzer/BUILD.gn @@ -40,6 +40,7 @@ ohos_fuzztest("AbilityConnectManagerFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", diff --git a/test/fuzztest/abilitycontext_fuzzer/BUILD.gn b/test/fuzztest/abilitycontext_fuzzer/BUILD.gn index 3c53cf75b0..47dd309f71 100644 --- a/test/fuzztest/abilitycontext_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitycontext_fuzzer/BUILD.gn @@ -37,6 +37,7 @@ ohos_fuzztest("AbilityContextFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilityeventhandler_fuzzer/BUILD.gn b/test/fuzztest/abilityeventhandler_fuzzer/BUILD.gn index daa520de28..5506eada53 100755 --- a/test/fuzztest/abilityeventhandler_fuzzer/BUILD.gn +++ b/test/fuzztest/abilityeventhandler_fuzzer/BUILD.gn @@ -44,6 +44,7 @@ ohos_fuzztest("AbilityEventHandlerFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", diff --git a/test/fuzztest/abilitymanagerservicea_fuzzer/BUILD.gn b/test/fuzztest/abilitymanagerservicea_fuzzer/BUILD.gn index 73079c39a7..4e51173aa0 100755 --- a/test/fuzztest/abilitymanagerservicea_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitymanagerservicea_fuzzer/BUILD.gn @@ -44,6 +44,7 @@ ohos_fuzztest("AbilityManagerServiceAFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/ability_manager:mission_info", "${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr", "${ability_runtime_native_path}/ability/native:abilitykit_native", diff --git a/test/fuzztest/abilitymanagerserviceb_fuzzer/BUILD.gn b/test/fuzztest/abilitymanagerserviceb_fuzzer/BUILD.gn index 7ec8b38744..cd9a3cecb1 100755 --- a/test/fuzztest/abilitymanagerserviceb_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitymanagerserviceb_fuzzer/BUILD.gn @@ -44,6 +44,7 @@ ohos_fuzztest("AbilityManagerServiceBFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", diff --git a/test/fuzztest/abilitymanagerservicec_fuzzer/BUILD.gn b/test/fuzztest/abilitymanagerservicec_fuzzer/BUILD.gn index 6c034eb93a..bcc90493c8 100755 --- a/test/fuzztest/abilitymanagerservicec_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitymanagerservicec_fuzzer/BUILD.gn @@ -44,6 +44,7 @@ ohos_fuzztest("AbilityManagerServiceCFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", diff --git a/test/fuzztest/abilitymanagerserviced_fuzzer/BUILD.gn b/test/fuzztest/abilitymanagerserviced_fuzzer/BUILD.gn index 1ac35edb54..b4cb78b44b 100755 --- a/test/fuzztest/abilitymanagerserviced_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitymanagerserviced_fuzzer/BUILD.gn @@ -44,6 +44,7 @@ ohos_fuzztest("AbilityManagerServiceDFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", diff --git a/test/fuzztest/abilitymanagerservicee_fuzzer/BUILD.gn b/test/fuzztest/abilitymanagerservicee_fuzzer/BUILD.gn index 41ec187e4d..63dac87932 100755 --- a/test/fuzztest/abilitymanagerservicee_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitymanagerservicee_fuzzer/BUILD.gn @@ -44,6 +44,7 @@ ohos_fuzztest("AbilityManagerServiceEFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", diff --git a/test/fuzztest/abilitymanagerserviceeighth_fuzzer/BUILD.gn b/test/fuzztest/abilitymanagerserviceeighth_fuzzer/BUILD.gn index 64cb793c5c..6105a286fc 100755 --- a/test/fuzztest/abilitymanagerserviceeighth_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitymanagerserviceeighth_fuzzer/BUILD.gn @@ -44,6 +44,7 @@ ohos_fuzztest("AbilityManagerServiceEighthFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", diff --git a/test/fuzztest/abilitymanagerservicef_fuzzer/BUILD.gn b/test/fuzztest/abilitymanagerservicef_fuzzer/BUILD.gn index 8d843fe37b..9cc57794ad 100755 --- a/test/fuzztest/abilitymanagerservicef_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitymanagerservicef_fuzzer/BUILD.gn @@ -44,6 +44,7 @@ ohos_fuzztest("AbilityManagerServiceFFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", diff --git a/test/fuzztest/abilitymanagerservicefifth_fuzzer/BUILD.gn b/test/fuzztest/abilitymanagerservicefifth_fuzzer/BUILD.gn index 778434d0dc..8dd74d191b 100755 --- a/test/fuzztest/abilitymanagerservicefifth_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitymanagerservicefifth_fuzzer/BUILD.gn @@ -44,6 +44,7 @@ ohos_fuzztest("AbilityManagerServiceFifthFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", diff --git a/test/fuzztest/abilitymanagerservicefirst_fuzzer/BUILD.gn b/test/fuzztest/abilitymanagerservicefirst_fuzzer/BUILD.gn index e63a0940a8..14602e39e3 100755 --- a/test/fuzztest/abilitymanagerservicefirst_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitymanagerservicefirst_fuzzer/BUILD.gn @@ -44,6 +44,7 @@ ohos_fuzztest("AbilityManagerServiceFirstFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", diff --git a/test/fuzztest/abilitymanagerservicefourth_fuzzer/BUILD.gn b/test/fuzztest/abilitymanagerservicefourth_fuzzer/BUILD.gn index 44577ba64d..d1e0f79a90 100755 --- a/test/fuzztest/abilitymanagerservicefourth_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitymanagerservicefourth_fuzzer/BUILD.gn @@ -44,6 +44,7 @@ ohos_fuzztest("AbilityManagerServiceFourthFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", diff --git a/test/fuzztest/abilitymanagerserviceg_fuzzer/BUILD.gn b/test/fuzztest/abilitymanagerserviceg_fuzzer/BUILD.gn index 622138a79e..4288d57319 100755 --- a/test/fuzztest/abilitymanagerserviceg_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitymanagerserviceg_fuzzer/BUILD.gn @@ -44,6 +44,7 @@ ohos_fuzztest("AbilityManagerServiceGFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", diff --git a/test/fuzztest/abilitymanagerserviceh_fuzzer/BUILD.gn b/test/fuzztest/abilitymanagerserviceh_fuzzer/BUILD.gn index bfd2a64720..afc9881307 100755 --- a/test/fuzztest/abilitymanagerserviceh_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitymanagerserviceh_fuzzer/BUILD.gn @@ -44,6 +44,7 @@ ohos_fuzztest("AbilityManagerServiceHFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", diff --git a/test/fuzztest/abilitymanagerserviceninth_fuzzer/BUILD.gn b/test/fuzztest/abilitymanagerserviceninth_fuzzer/BUILD.gn index 0d969cd805..9ddb03738c 100755 --- a/test/fuzztest/abilitymanagerserviceninth_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitymanagerserviceninth_fuzzer/BUILD.gn @@ -44,6 +44,7 @@ ohos_fuzztest("AbilityManagerServiceNinthFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", diff --git a/test/fuzztest/abilitymanagerservicesecond_fuzzer/BUILD.gn b/test/fuzztest/abilitymanagerservicesecond_fuzzer/BUILD.gn index 5648407d8b..966267ec74 100755 --- a/test/fuzztest/abilitymanagerservicesecond_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitymanagerservicesecond_fuzzer/BUILD.gn @@ -44,6 +44,7 @@ ohos_fuzztest("AbilityManagerServiceSecondFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/ability_manager:mission_info", "${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr", "${ability_runtime_native_path}/ability/native:abilitykit_native", diff --git a/test/fuzztest/abilitymanagerserviceseventh_fuzzer/BUILD.gn b/test/fuzztest/abilitymanagerserviceseventh_fuzzer/BUILD.gn index 9a70012b90..0927f5d145 100755 --- a/test/fuzztest/abilitymanagerserviceseventh_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitymanagerserviceseventh_fuzzer/BUILD.gn @@ -43,6 +43,7 @@ ohos_fuzztest("AbilityManagerServiceSeventhFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", diff --git a/test/fuzztest/abilitymanagerservicesixth_fuzzer/BUILD.gn b/test/fuzztest/abilitymanagerservicesixth_fuzzer/BUILD.gn index dfbaf6e38f..b574badab3 100755 --- a/test/fuzztest/abilitymanagerservicesixth_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitymanagerservicesixth_fuzzer/BUILD.gn @@ -44,6 +44,7 @@ ohos_fuzztest("AbilityManagerServiceSixthFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", diff --git a/test/fuzztest/abilitymanagerservicetenth_fuzzer/BUILD.gn b/test/fuzztest/abilitymanagerservicetenth_fuzzer/BUILD.gn index 421bd00ee0..332fe1c9e4 100755 --- a/test/fuzztest/abilitymanagerservicetenth_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitymanagerservicetenth_fuzzer/BUILD.gn @@ -44,6 +44,7 @@ ohos_fuzztest("AbilityManagerServiceTenthFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/ability_manager:mission_info", "${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr", "${ability_runtime_native_path}/ability/native:abilitykit_native", diff --git a/test/fuzztest/abilitymanagerservicethird_fuzzer/BUILD.gn b/test/fuzztest/abilitymanagerservicethird_fuzzer/BUILD.gn index 8a00c515a4..d662527a70 100755 --- a/test/fuzztest/abilitymanagerservicethird_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitymanagerservicethird_fuzzer/BUILD.gn @@ -44,6 +44,7 @@ ohos_fuzztest("AbilityManagerServiceThirdFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", diff --git a/test/fuzztest/abilityrunningrecord_fuzzer/BUILD.gn b/test/fuzztest/abilityrunningrecord_fuzzer/BUILD.gn index 649c04b289..db164a19cb 100644 --- a/test/fuzztest/abilityrunningrecord_fuzzer/BUILD.gn +++ b/test/fuzztest/abilityrunningrecord_fuzzer/BUILD.gn @@ -37,6 +37,7 @@ ohos_fuzztest("AbilityRunningRecordFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", "${ability_runtime_services_path}/appmgr:libappms", diff --git a/test/fuzztest/abilityschedulerstub_fuzzer/BUILD.gn b/test/fuzztest/abilityschedulerstub_fuzzer/BUILD.gn index 727a04eda9..fc78fff8b2 100755 --- a/test/fuzztest/abilityschedulerstub_fuzzer/BUILD.gn +++ b/test/fuzztest/abilityschedulerstub_fuzzer/BUILD.gn @@ -37,6 +37,7 @@ ohos_fuzztest("AbilitySchedulerStubFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubabilityrecovery_fuzzer/BUILD.gn b/test/fuzztest/abilitystubabilityrecovery_fuzzer/BUILD.gn index 30a86a1f75..7047c16935 100644 --- a/test/fuzztest/abilitystubabilityrecovery_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubabilityrecovery_fuzzer/BUILD.gn @@ -36,6 +36,7 @@ ohos_fuzztest("AbilityStubAbilityRecoveryFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubabilityrecoveryenable_fuzzer/BUILD.gn b/test/fuzztest/abilitystubabilityrecoveryenable_fuzzer/BUILD.gn index ef4559df5c..95754f43bc 100644 --- a/test/fuzztest/abilitystubabilityrecoveryenable_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubabilityrecoveryenable_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubAbilityRecoveryEnableFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubabilitytransitiondone_fuzzer/BUILD.gn b/test/fuzztest/abilitystubabilitytransitiondone_fuzzer/BUILD.gn index b2431586df..e616f1b96d 100644 --- a/test/fuzztest/abilitystubabilitytransitiondone_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubabilitytransitiondone_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubAbilityTransitionDoneFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubacquiredataability_fuzzer/BUILD.gn b/test/fuzztest/abilitystubacquiredataability_fuzzer/BUILD.gn index 86622fd924..7af68bd394 100644 --- a/test/fuzztest/abilitystubacquiredataability_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubacquiredataability_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubAcquireDataAbilityFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubacquiresharedata_fuzzer/BUILD.gn b/test/fuzztest/abilitystubacquiresharedata_fuzzer/BUILD.gn index be6a4c9a67..d520444cf1 100644 --- a/test/fuzztest/abilitystubacquiresharedata_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubacquiresharedata_fuzzer/BUILD.gn @@ -36,6 +36,7 @@ ohos_fuzztest("AbilityStubAcquireShareDataFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubaddfreeinstallobserver_fuzzer/BUILD.gn b/test/fuzztest/abilitystubaddfreeinstallobserver_fuzzer/BUILD.gn index 6ba8a5111e..33ef4b56f5 100644 --- a/test/fuzztest/abilitystubaddfreeinstallobserver_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubaddfreeinstallobserver_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubAddFreeInstallObserverFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubattachabilitythread_fuzzer/BUILD.gn b/test/fuzztest/abilitystubattachabilitythread_fuzzer/BUILD.gn index 927ed464fd..4ede9c716c 100644 --- a/test/fuzztest/abilitystubattachabilitythread_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubattachabilitythread_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubAttachAbilityThreadFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubcallrequestdone_fuzzer/BUILD.gn b/test/fuzztest/abilitystubcallrequestdone_fuzzer/BUILD.gn index 9009e7bc9a..e5972b6565 100644 --- a/test/fuzztest/abilitystubcallrequestdone_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubcallrequestdone_fuzzer/BUILD.gn @@ -36,6 +36,7 @@ ohos_fuzztest("AbilityStubCallRequestDoneFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubcalluiabilitybyscb_fuzzer/BUILD.gn b/test/fuzztest/abilitystubcalluiabilitybyscb_fuzzer/BUILD.gn index 480c2e37e8..aa763bfac0 100644 --- a/test/fuzztest/abilitystubcalluiabilitybyscb_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubcalluiabilitybyscb_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubCallUIAbilityBySCBFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubcancelwantsender_fuzzer/BUILD.gn b/test/fuzztest/abilitystubcancelwantsender_fuzzer/BUILD.gn index 80fa977784..47a0d5e70b 100644 --- a/test/fuzztest/abilitystubcancelwantsender_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubcancelwantsender_fuzzer/BUILD.gn @@ -36,6 +36,7 @@ ohos_fuzztest("AbilityStubCancelWantSenderFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubcheckuiextensionisfocused_fuzzer/BUILD.gn b/test/fuzztest/abilitystubcheckuiextensionisfocused_fuzzer/BUILD.gn index 14f58de8cf..2100e56e07 100644 --- a/test/fuzztest/abilitystubcheckuiextensionisfocused_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubcheckuiextensionisfocused_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubCheckUIExtensionIsFocusedFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubcleanallmissions_fuzzer/BUILD.gn b/test/fuzztest/abilitystubcleanallmissions_fuzzer/BUILD.gn index bdeb244b18..32d1bc70fd 100644 --- a/test/fuzztest/abilitystubcleanallmissions_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubcleanallmissions_fuzzer/BUILD.gn @@ -36,6 +36,7 @@ ohos_fuzztest("AbilityStubCleanAllMissionsFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubcleanmission_fuzzer/BUILD.gn b/test/fuzztest/abilitystubcleanmission_fuzzer/BUILD.gn index 396ff302c9..91e7789c24 100644 --- a/test/fuzztest/abilitystubcleanmission_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubcleanmission_fuzzer/BUILD.gn @@ -36,6 +36,7 @@ ohos_fuzztest("AbilityStubCleanMissionFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubclearupapplicationdata_fuzzer/BUILD.gn b/test/fuzztest/abilitystubclearupapplicationdata_fuzzer/BUILD.gn index 54d1ba0658..91d563fabf 100644 --- a/test/fuzztest/abilitystubclearupapplicationdata_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubclearupapplicationdata_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubClearUpApplicationDataFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubcommandabilitydone_fuzzer/BUILD.gn b/test/fuzztest/abilitystubcommandabilitydone_fuzzer/BUILD.gn index 8b9874fd0f..e145a5ed98 100644 --- a/test/fuzztest/abilitystubcommandabilitydone_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubcommandabilitydone_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubCommandAbilityDoneFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubcommandabilitywindowdone_fuzzer/BUILD.gn b/test/fuzztest/abilitystubcommandabilitywindowdone_fuzzer/BUILD.gn index 232cba6a86..88f25224f3 100644 --- a/test/fuzztest/abilitystubcommandabilitywindowdone_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubcommandabilitywindowdone_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubCommandAbilityWindowDoneFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubcompletefirstframedrawing_fuzzer/BUILD.gn b/test/fuzztest/abilitystubcompletefirstframedrawing_fuzzer/BUILD.gn index 59027825f5..8c537336fa 100644 --- a/test/fuzztest/abilitystubcompletefirstframedrawing_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubcompletefirstframedrawing_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubCompleteFirstFrameDrawingFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubconnectability_fuzzer/BUILD.gn b/test/fuzztest/abilitystubconnectability_fuzzer/BUILD.gn index 5377286020..c5e2dd2001 100644 --- a/test/fuzztest/abilitystubconnectability_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubconnectability_fuzzer/BUILD.gn @@ -36,6 +36,7 @@ ohos_fuzztest("AbilityStubConnectAbilityFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubconnectabilitydone_fuzzer/BUILD.gn b/test/fuzztest/abilitystubconnectabilitydone_fuzzer/BUILD.gn index 9651494d80..833900f46c 100644 --- a/test/fuzztest/abilitystubconnectabilitydone_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubconnectabilitydone_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubConnectAbilityDoneFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubconnectabilitywithtype_fuzzer/BUILD.gn b/test/fuzztest/abilitystubconnectabilitywithtype_fuzzer/BUILD.gn index 3eca10fc80..5b2b7efad3 100644 --- a/test/fuzztest/abilitystubconnectabilitywithtype_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubconnectabilitywithtype_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubConnectAbilityWithTypeFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubconnectuiextensionability_fuzzer/BUILD.gn b/test/fuzztest/abilitystubconnectuiextensionability_fuzzer/BUILD.gn index 62410906b6..ca0922785b 100644 --- a/test/fuzztest/abilitystubconnectuiextensionability_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubconnectuiextensionability_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubConnectUIExtensionAbilityFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubcontinueability_fuzzer/BUILD.gn b/test/fuzztest/abilitystubcontinueability_fuzzer/BUILD.gn index 8b509b0413..7e28679944 100644 --- a/test/fuzztest/abilitystubcontinueability_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubcontinueability_fuzzer/BUILD.gn @@ -36,6 +36,7 @@ ohos_fuzztest("AbilityStubContinueAbilityFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubcontinuemission_fuzzer/BUILD.gn b/test/fuzztest/abilitystubcontinuemission_fuzzer/BUILD.gn index da920044c0..687017ee68 100644 --- a/test/fuzztest/abilitystubcontinuemission_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubcontinuemission_fuzzer/BUILD.gn @@ -36,6 +36,7 @@ ohos_fuzztest("AbilityStubContinueMissionFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubcontinuemissionofbundlename_fuzzer/BUILD.gn b/test/fuzztest/abilitystubcontinuemissionofbundlename_fuzzer/BUILD.gn index ed26f471e4..a876b7ee9d 100644 --- a/test/fuzztest/abilitystubcontinuemissionofbundlename_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubcontinuemissionofbundlename_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubContinueMissionOfBundlenameFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubdelegatordoabilitybackground_fuzzer/BUILD.gn b/test/fuzztest/abilitystubdelegatordoabilitybackground_fuzzer/BUILD.gn index eef6a3e9b7..6511b4be24 100644 --- a/test/fuzztest/abilitystubdelegatordoabilitybackground_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubdelegatordoabilitybackground_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubDelegatorDoAbilityBackgroundFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubdelegatordoabilityforeground_fuzzer/BUILD.gn b/test/fuzztest/abilitystubdelegatordoabilityforeground_fuzzer/BUILD.gn index 94757e6e4c..8828c156cb 100644 --- a/test/fuzztest/abilitystubdelegatordoabilityforeground_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubdelegatordoabilityforeground_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubDelegatorDoAbilityForegroundFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubdisconnectability_fuzzer/BUILD.gn b/test/fuzztest/abilitystubdisconnectability_fuzzer/BUILD.gn index f3274da1eb..89dfd20061 100644 --- a/test/fuzztest/abilitystubdisconnectability_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubdisconnectability_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubDisconnectAbilityFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubdisconnectabilitydone_fuzzer/BUILD.gn b/test/fuzztest/abilitystubdisconnectabilitydone_fuzzer/BUILD.gn index c930e9934f..b9f7c38d4a 100644 --- a/test/fuzztest/abilitystubdisconnectabilitydone_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubdisconnectabilitydone_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubDisConnectAbilityDoneFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubdoabilitybackground_fuzzer/BUILD.gn b/test/fuzztest/abilitystubdoabilitybackground_fuzzer/BUILD.gn index 17892edc32..fee3c66926 100644 --- a/test/fuzztest/abilitystubdoabilitybackground_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubdoabilitybackground_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubDoAbilityBackgroundFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubdoabilityforeground_fuzzer/BUILD.gn b/test/fuzztest/abilitystubdoabilityforeground_fuzzer/BUILD.gn index 81792f3507..af970db105 100644 --- a/test/fuzztest/abilitystubdoabilityforeground_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubdoabilityforeground_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubDoAbilityForegroundFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubdumpabilityinfodone_fuzzer/BUILD.gn b/test/fuzztest/abilitystubdumpabilityinfodone_fuzzer/BUILD.gn index 553fb3bd1e..f3513eca61 100644 --- a/test/fuzztest/abilitystubdumpabilityinfodone_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubdumpabilityinfodone_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubDumpAbilityInfoDoneFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubdumpstate_fuzzer/BUILD.gn b/test/fuzztest/abilitystubdumpstate_fuzzer/BUILD.gn index f7dab79795..4255abd364 100644 --- a/test/fuzztest/abilitystubdumpstate_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubdumpstate_fuzzer/BUILD.gn @@ -36,6 +36,7 @@ ohos_fuzztest("AbilityStubDumpStateFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubdumpsysstate_fuzzer/BUILD.gn b/test/fuzztest/abilitystubdumpsysstate_fuzzer/BUILD.gn index a8fb25202f..3c99f909a1 100644 --- a/test/fuzztest/abilitystubdumpsysstate_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubdumpsysstate_fuzzer/BUILD.gn @@ -36,6 +36,7 @@ ohos_fuzztest("AbilityStubDumpsysStateFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubfinishusertest_fuzzer/BUILD.gn b/test/fuzztest/abilitystubfinishusertest_fuzzer/BUILD.gn index 8d2b23c65f..5e58c35935 100644 --- a/test/fuzztest/abilitystubfinishusertest_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubfinishusertest_fuzzer/BUILD.gn @@ -36,6 +36,7 @@ ohos_fuzztest("AbilityStubFinishUserTestFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubforceexitapp_fuzzer/BUILD.gn b/test/fuzztest/abilitystubforceexitapp_fuzzer/BUILD.gn index 5150b16e13..5db9b7786b 100644 --- a/test/fuzztest/abilitystubforceexitapp_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubforceexitapp_fuzzer/BUILD.gn @@ -36,6 +36,7 @@ ohos_fuzztest("AbilityStubForceExitAppFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubfreeinstallabilityfromremote_fuzzer/BUILD.gn b/test/fuzztest/abilitystubfreeinstallabilityfromremote_fuzzer/BUILD.gn index 580174d597..f32ce33d18 100644 --- a/test/fuzztest/abilitystubfreeinstallabilityfromremote_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubfreeinstallabilityfromremote_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubFreeInstallAbilityFromRemoteFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubgetabilityrunninginfo_fuzzer/BUILD.gn b/test/fuzztest/abilitystubgetabilityrunninginfo_fuzzer/BUILD.gn index 02260bae84..12c70af6b7 100644 --- a/test/fuzztest/abilitystubgetabilityrunninginfo_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubgetabilityrunninginfo_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubGetAbilityRunningInfoFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubgetabilitystatebypersistentid_fuzzer/BUILD.gn b/test/fuzztest/abilitystubgetabilitystatebypersistentid_fuzzer/BUILD.gn index 51a75c814a..368375698a 100644 --- a/test/fuzztest/abilitystubgetabilitystatebypersistentid_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubgetabilitystatebypersistentid_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubGetAbilityStateByPersistentIdFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubgetabilitytoken_fuzzer/BUILD.gn b/test/fuzztest/abilitystubgetabilitytoken_fuzzer/BUILD.gn index 0ebd746eb1..5fe603fdc0 100644 --- a/test/fuzztest/abilitystubgetabilitytoken_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubgetabilitytoken_fuzzer/BUILD.gn @@ -36,6 +36,7 @@ ohos_fuzztest("AbilityStubGetAbilityTokenFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubgetappmemorysize_fuzzer/BUILD.gn b/test/fuzztest/abilitystubgetappmemorysize_fuzzer/BUILD.gn index 854503486e..eb011bef36 100644 --- a/test/fuzztest/abilitystubgetappmemorysize_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubgetappmemorysize_fuzzer/BUILD.gn @@ -36,6 +36,7 @@ ohos_fuzztest("AbilityStubGetAppMemorySizeFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubgetdlpconnectioninfos_fuzzer/BUILD.gn b/test/fuzztest/abilitystubgetdlpconnectioninfos_fuzzer/BUILD.gn index ec109fbf28..20ffacd22c 100644 --- a/test/fuzztest/abilitystubgetdlpconnectioninfos_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubgetdlpconnectioninfos_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubGetDlpConnectionInfosFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubgetelementnamebytoken_fuzzer/BUILD.gn b/test/fuzztest/abilitystubgetelementnamebytoken_fuzzer/BUILD.gn index c721c4b1ac..6496f768c8 100644 --- a/test/fuzztest/abilitystubgetelementnamebytoken_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubgetelementnamebytoken_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubGetElementNameByTokenFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubgetextensionrunninginfo_fuzzer/BUILD.gn b/test/fuzztest/abilitystubgetextensionrunninginfo_fuzzer/BUILD.gn index 7187977f3a..0dd7c010e9 100644 --- a/test/fuzztest/abilitystubgetextensionrunninginfo_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubgetextensionrunninginfo_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubGetExtensionRunningInfoFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubgetmissionidbytoken_fuzzer/BUILD.gn b/test/fuzztest/abilitystubgetmissionidbytoken_fuzzer/BUILD.gn index 98fe009936..39789456f5 100644 --- a/test/fuzztest/abilitystubgetmissionidbytoken_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubgetmissionidbytoken_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubGetMissionIdByTokenFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubgetmissioninfo_fuzzer/BUILD.gn b/test/fuzztest/abilitystubgetmissioninfo_fuzzer/BUILD.gn index 9627b08830..5878007094 100644 --- a/test/fuzztest/abilitystubgetmissioninfo_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubgetmissioninfo_fuzzer/BUILD.gn @@ -36,6 +36,7 @@ ohos_fuzztest("AbilityStubGetMissionInfoFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubgetmissioninfos_fuzzer/BUILD.gn b/test/fuzztest/abilitystubgetmissioninfos_fuzzer/BUILD.gn index 58cbfdec9e..216cd70fe8 100644 --- a/test/fuzztest/abilitystubgetmissioninfos_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubgetmissioninfos_fuzzer/BUILD.gn @@ -36,6 +36,7 @@ ohos_fuzztest("AbilityStubGetMissionInfosFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubgetmissionsnapshotinfo_fuzzer/BUILD.gn b/test/fuzztest/abilitystubgetmissionsnapshotinfo_fuzzer/BUILD.gn index 4a4d11620b..0875e9448c 100644 --- a/test/fuzztest/abilitystubgetmissionsnapshotinfo_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubgetmissionsnapshotinfo_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubGetMissionSnapShotInfoFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubgetpendingrequestwant_fuzzer/BUILD.gn b/test/fuzztest/abilitystubgetpendingrequestwant_fuzzer/BUILD.gn index 3e5919c780..ec3dfc7a49 100644 --- a/test/fuzztest/abilitystubgetpendingrequestwant_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubgetpendingrequestwant_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubGetPendingRequestWantFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubgetpendingwantbundlename_fuzzer/BUILD.gn b/test/fuzztest/abilitystubgetpendingwantbundlename_fuzzer/BUILD.gn index 579773ff79..f2d91d0790 100644 --- a/test/fuzztest/abilitystubgetpendingwantbundlename_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubgetpendingwantbundlename_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubGetPendingWantBundleNameFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubgetpendingwantcode_fuzzer/BUILD.gn b/test/fuzztest/abilitystubgetpendingwantcode_fuzzer/BUILD.gn index 63a733b7b7..09f9922a95 100644 --- a/test/fuzztest/abilitystubgetpendingwantcode_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubgetpendingwantcode_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubGetPendingWantCodeFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubgetpendingwanttype_fuzzer/BUILD.gn b/test/fuzztest/abilitystubgetpendingwanttype_fuzzer/BUILD.gn index 1b6a0e171a..fb1a41bfca 100644 --- a/test/fuzztest/abilitystubgetpendingwanttype_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubgetpendingwanttype_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubGetPendingWantTypeFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubgetpendingwantuid_fuzzer/BUILD.gn b/test/fuzztest/abilitystubgetpendingwantuid_fuzzer/BUILD.gn index dba956a1b4..476a09f7b6 100644 --- a/test/fuzztest/abilitystubgetpendingwantuid_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubgetpendingwantuid_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubGetPendingWantUidFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubgetpendingwantuserid_fuzzer/BUILD.gn b/test/fuzztest/abilitystubgetpendingwantuserid_fuzzer/BUILD.gn index ad1beb12b1..4d641a195a 100644 --- a/test/fuzztest/abilitystubgetpendingwantuserid_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubgetpendingwantuserid_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubGetPendingWantUserIdFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubgetprocessrunninginfo_fuzzer/BUILD.gn b/test/fuzztest/abilitystubgetprocessrunninginfo_fuzzer/BUILD.gn index 4036c87ba7..0b6892054e 100644 --- a/test/fuzztest/abilitystubgetprocessrunninginfo_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubgetprocessrunninginfo_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubGetProcessRunningInfoFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubgettopability_fuzzer/BUILD.gn b/test/fuzztest/abilitystubgettopability_fuzzer/BUILD.gn index 25114cf108..5abe12f801 100644 --- a/test/fuzztest/abilitystubgettopability_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubgettopability_fuzzer/BUILD.gn @@ -36,6 +36,7 @@ ohos_fuzztest("AbilityStubGetTopAbilityFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubgettopabilitytoken_fuzzer/BUILD.gn b/test/fuzztest/abilitystubgettopabilitytoken_fuzzer/BUILD.gn index e4695e463d..7bb8b0b013 100644 --- a/test/fuzztest/abilitystubgettopabilitytoken_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubgettopabilitytoken_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubGetTopAbilityTokenFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/unittest/ui_extension_context_test/BUILD.gn b/test/unittest/ui_extension_context_test/BUILD.gn index 67bc2b85b0..c89fd48e04 100644 --- a/test/unittest/ui_extension_context_test/BUILD.gn +++ b/test/unittest/ui_extension_context_test/BUILD.gn @@ -35,6 +35,7 @@ ohos_unittest("ui_extension_context_test") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_native_path}/ability/native:ui_extension", "${ability_runtime_native_path}/appkit:app_context", diff --git a/tools/aa/BUILD.gn b/tools/aa/BUILD.gn index 44b5952554..7415fcf689 100644 --- a/tools/aa/BUILD.gn +++ b/tools/aa/BUILD.gn @@ -49,6 +49,7 @@ ohos_static_library("tools_aa_source_set") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/ability_manager:ability_start_setting", "${ability_runtime_innerkits_path}/ability_manager:mission_info", "${ability_runtime_innerkits_path}/app_manager:app_manager", From 5bfafb2167817af02006571c0401624d47ffc59e Mon Sep 17 00:00:00 2001 From: t00605578 Date: Fri, 17 May 2024 17:52:34 +0800 Subject: [PATCH 093/174] fix stage UIAbility continue unnecessary verify Signed-off-by: t00605578 --- frameworks/native/ability/native/ui_ability.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/frameworks/native/ability/native/ui_ability.cpp b/frameworks/native/ability/native/ui_ability.cpp index 33eaee9287..8b74cf7691 100644 --- a/frameworks/native/ability/native/ui_ability.cpp +++ b/frameworks/native/ability/native/ui_ability.cpp @@ -240,10 +240,6 @@ bool UIAbility::IsRestoredInContinuation() const return false; } - if (abilityContext_->GetContentStorage() == nullptr) { - TAG_LOGD(AAFwkTag::UIABILITY, "Get content failed."); - return false; - } TAG_LOGD(AAFwkTag::UIABILITY, "End."); return true; } From 67dc76142cda7eea8fc39ee1db57635c4d4029b1 Mon Sep 17 00:00:00 2001 From: jiangzhijun8 Date: Fri, 17 May 2024 17:25:31 +0800 Subject: [PATCH 094/174] =?UTF-8?q?TDD=E8=A6=86=E7=9B=96=E7=8E=87=E6=96=B0?= =?UTF-8?q?=E5=A2=9E[ability=5Frecord=5Fmgr=5Ftest]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: jiangzhijun8 Change-Id: I8fe6c48133391cb4ec3b43fef34bf14ec35e68e9 --- test/unittest/BUILD.gn | 1 + .../unittest/ability_record_mgr_test/BUILD.gn | 61 +++++ .../ability_record_mgr_test.cpp | 230 ++++++++++++++++++ 3 files changed, 292 insertions(+) create mode 100644 test/unittest/ability_record_mgr_test/BUILD.gn create mode 100644 test/unittest/ability_record_mgr_test/ability_record_mgr_test.cpp diff --git a/test/unittest/BUILD.gn b/test/unittest/BUILD.gn index c5dde5a563..cde38202d6 100644 --- a/test/unittest/BUILD.gn +++ b/test/unittest/BUILD.gn @@ -348,6 +348,7 @@ group("unittest") { "ability_manager_stub_test:unittest", "ability_manager_test:unittest", "ability_record_dump_test:unittest", + "ability_record_mgr_test:unittest", "ability_record_test:unittest", "ability_running_info_test:unittest", "ability_runtime_error_util_test:unittest", diff --git a/test/unittest/ability_record_mgr_test/BUILD.gn b/test/unittest/ability_record_mgr_test/BUILD.gn new file mode 100644 index 0000000000..fd91592f70 --- /dev/null +++ b/test/unittest/ability_record_mgr_test/BUILD.gn @@ -0,0 +1,61 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/ohos.gni") +import("//build/test.gni") +import("//foundation/ability/ability_runtime/ability_runtime.gni") + +module_output_path = "ability_runtime/appkit" +config("coverage_flags") { + if (ability_runtime_feature_coverage) { + cflags = [ "--coverage" ] + ldflags = [ "--coverage" ] + } +} + +ohos_unittest("ability_record_mgr_test") { + module_out_path = module_output_path + + include_dirs = [] + + sources = [ + "${ability_runtime_native_path}/appkit/app/ability_record_mgr.cpp", + "ability_record_mgr_test.cpp", + ] + + configs = [ ":coverage_flags" ] + cflags = [] + if (target_cpu == "arm") { + cflags += [ "-DBINDER_IPC_32BIT" ] + } + deps = [ "//third_party/googletest:gmock_main" ] + + external_deps = [ + "ability_runtime:abilitykit_native", + "c_utils:utils", + "eventhandler:libeventhandler", + "hilog:libhilog", + "hitrace:hitrace_meter", + "ipc:ipc_core", + ] + + if (background_task_mgr_continuous_task_enable) { + external_deps += [ "background_task_mgr:bgtaskmgr_innerkits" ] + } +} + +group("unittest") { + testonly = true + + deps = [ ":ability_record_mgr_test" ] +} diff --git a/test/unittest/ability_record_mgr_test/ability_record_mgr_test.cpp b/test/unittest/ability_record_mgr_test/ability_record_mgr_test.cpp new file mode 100644 index 0000000000..7e37d50cb5 --- /dev/null +++ b/test/unittest/ability_record_mgr_test/ability_record_mgr_test.cpp @@ -0,0 +1,230 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#define private public +#define protected public +#include "ability_record_mgr.h" +#undef private +#undef protected +#include "hilog_tag_wrapper.h" +#include "hilog_wrapper.h" +#include "iremote_broker.h" +#include "iremote_object.h" +#include "iremote_stub.h" +using namespace testing::ext; +using namespace testing; +using namespace OHOS::AppExecFwk; +namespace OHOS { +namespace AAFwk { +class IAbilityMgrToken : public IRemoteBroker { +public: + DECLARE_INTERFACE_DESCRIPTOR(u"ohos.appexecfwk.AbilityMgrToken"); +}; + +class AbilityMgrToken : public IRemoteStub { +public: + AbilityMgrToken() = default; + virtual ~AbilityMgrToken() = default; + + virtual int OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) + { + return 0; + } + +private: + DISALLOW_COPY_AND_MOVE(AbilityMgrToken); +}; + +class AbilityRecordMgrTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + void SetUp(); + void TearDown(); +}; + +void AbilityRecordMgrTest::SetUpTestCase() +{} + +void AbilityRecordMgrTest::TearDownTestCase() +{} + +void AbilityRecordMgrTest::SetUp() +{} + +void AbilityRecordMgrTest::TearDown() +{} + +/** + * @tc.number: GetToken_0100 + * @tc.name: GetToken + * @tc.desc: GetToken Test, return is not nullptr. + */ +HWTEST_F(AbilityRecordMgrTest, GetEventHandler_0100, TestSize.Level0) +{ + GTEST_LOG_(INFO) << "AbilityRecordMgrTest GetToken_0100 start"; + auto recordMgr = std::make_shared(); + recordMgr->tokens_ = nullptr; + auto token = recordMgr->GetToken(); + EXPECT_EQ(token, nullptr); + GTEST_LOG_(INFO) << "AbilityRecordMgrTest GetToken_0100 end"; +} + +/** + * @tc.number: SetToken_0100 + * @tc.name: SetToken + * @tc.desc: SetToken Test, return is not nullptr. + */ +HWTEST_F(AbilityRecordMgrTest, SetToken_0100, TestSize.Level0) +{ + GTEST_LOG_(INFO) << "AbilityRecordMgrTest SetToken_0100 start"; + sptr token = new (std::nothrow) AbilityMgrToken(); + auto recordMgr = std::make_shared(); + recordMgr->SetToken(token); + EXPECT_NE(recordMgr->GetToken(), nullptr); + GTEST_LOG_(INFO) << "AbilityRecordMgrTest SetToken_0100 end"; +} + +/** + * @tc.number: SetEventRunner_0100 + * @tc.name: SetEventRunner + * @tc.desc: SetEventRunner Test, return is not nullptr. + */ +HWTEST_F(AbilityRecordMgrTest, SetEventRunner_0100, TestSize.Level0) +{ + GTEST_LOG_(INFO) << "AbilityRecordMgrTest SetEventRunner_0100 start"; + auto recordMgr = std::make_shared(); + EXPECT_NE(recordMgr, nullptr); + recordMgr->SetEventRunner(nullptr); + + std::shared_ptr runner = EventRunner::GetMainEventRunner(); + EXPECT_NE(runner, nullptr); + recordMgr->tokens_ = nullptr; + recordMgr->SetEventRunner(runner); + + sptr token = new (std::nothrow) AbilityMgrToken(); + recordMgr->SetToken(token); + recordMgr->SetEventRunner(runner); + GTEST_LOG_(INFO) << "AbilityRecordMgrTest SetEventRunner_0100 end"; +} + +/** + * @tc.number: AddAbilityRecord_0100 + * @tc.name: AddAbilityRecord + * @tc.desc: AddAbilityRecord Test, return is not nullptr. + */ +HWTEST_F(AbilityRecordMgrTest, AddAbilityRecord_0100, TestSize.Level0) +{ + GTEST_LOG_(INFO) << "AbilityRecordMgrTest AddAbilityRecord_0100 start"; + auto recordMgr = std::make_shared(); + EXPECT_NE(recordMgr, nullptr); + sptr token = nullptr; + recordMgr->AddAbilityRecord(token, nullptr); + + token = new (std::nothrow) AbilityMgrToken(); + recordMgr->AddAbilityRecord(token, nullptr); + + auto abilityRecord = std::make_shared(nullptr, nullptr); + EXPECT_NE(abilityRecord, nullptr); + + recordMgr->AddAbilityRecord(token, abilityRecord); + EXPECT_EQ(recordMgr->abilityRecords_.size(), 1); + GTEST_LOG_(INFO) << "AbilityRecordMgrTest AddAbilityRecord_0100 end"; +} + +/** + * @tc.number: RemoveAbilityRecord_0100 + * @tc.name: RemoveAbilityRecord + * @tc.desc: RemoveAbilityRecord Test, return is not nullptr. + */ +HWTEST_F(AbilityRecordMgrTest, RemoveAbilityRecord_0100, TestSize.Level0) +{ + GTEST_LOG_(INFO) << "AbilityRecordMgrTest RemoveAbilityRecord_0100 start"; + auto recordMgr = std::make_shared(); + EXPECT_NE(recordMgr, nullptr); + sptr token = nullptr; + recordMgr->RemoveAbilityRecord(token); + + token = new (std::nothrow) AbilityMgrToken(); + auto abilityRecord = std::make_shared(nullptr, nullptr); + recordMgr->AddAbilityRecord(token, abilityRecord); + EXPECT_EQ(recordMgr->abilityRecords_.size(), 1); + + recordMgr->RemoveAbilityRecord(token); + EXPECT_EQ(recordMgr->abilityRecords_.size(), 0); + GTEST_LOG_(INFO) << "AbilityRecordMgrTest RemoveAbilityRecord_0100 end"; +} + +/** + * @tc.number: GetRecordCount_0100 + * @tc.name: GetRecordCount + * @tc.desc: GetRecordCount Test, return is not nullptr. + */ +HWTEST_F(AbilityRecordMgrTest, GetRecordCount_0100, TestSize.Level0) +{ + GTEST_LOG_(INFO) << "AbilityRecordMgrTest GetRecordCount_0100 start"; + auto recordMgr = std::make_shared(); + EXPECT_EQ(recordMgr->GetRecordCount(), 0); + + sptr token = new (std::nothrow) AbilityMgrToken(); + auto abilityRecord = std::make_shared(nullptr, nullptr); + recordMgr->AddAbilityRecord(token, abilityRecord); + EXPECT_EQ(recordMgr->GetRecordCount(), 1); + GTEST_LOG_(INFO) << "AbilityRecordMgrTest GetRecordCount_0100 end"; +} + +/** + * @tc.number: GetAbilityItem_0100 + * @tc.name: GetAbilityItem + * @tc.desc: GetAbilityItem Test, return is not nullptr. + */ +HWTEST_F(AbilityRecordMgrTest, GetAbilityItem_0100, TestSize.Level0) +{ + GTEST_LOG_(INFO) << "AbilityRecordMgrTest GetAbilityItem_0100 start"; + auto recordMgr = std::make_shared(); + sptr token = nullptr; + EXPECT_EQ(recordMgr->GetAbilityItem(token), nullptr); + + token = new (std::nothrow) AbilityMgrToken(); + auto abilityRecord = std::make_shared(nullptr, nullptr); + recordMgr->AddAbilityRecord(token, abilityRecord); + EXPECT_NE(recordMgr->GetAbilityItem(token), nullptr); + + sptr token2 = new (std::nothrow) AbilityMgrToken(); + EXPECT_EQ(recordMgr->GetAbilityItem(token2), nullptr); + + GTEST_LOG_(INFO) << "AbilityRecordMgrTest GetAbilityItem_0100 end"; +} + +/** + * @tc.number: GetAllTokens_0100 + * @tc.name: GetAllTokens + * @tc.desc: GetAllTokens Test, return is not nullptr. + */ +HWTEST_F(AbilityRecordMgrTest, GetAllTokens_0100, TestSize.Level0) +{ + GTEST_LOG_(INFO) << "AbilityRecordMgrTest GetAllTokens_0100 start"; + auto recordMgr = std::make_shared(); + + sptr token = new (std::nothrow) AbilityMgrToken(); + auto abilityRecord = std::make_shared(nullptr, nullptr); + recordMgr->AddAbilityRecord(token, abilityRecord); + EXPECT_EQ(recordMgr->GetAllTokens().size(), 1); + + GTEST_LOG_(INFO) << "AbilityRecordMgrTest GetAllTokens_0100 end"; +} +} +} From 71f8eadb7416003ebf0e10ae8359818a510a0232 Mon Sep 17 00:00:00 2001 From: zhangyafei-echo Date: Fri, 17 May 2024 20:16:09 +0800 Subject: [PATCH 095/174] Fix background state check to startability. Signed-off-by: zhangyafei-echo Change-Id: Ib9dfcc42aa673a5a37ee99c78a77b3e935ff1abd --- services/abilitymgr/src/ability_manager_service.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/services/abilitymgr/src/ability_manager_service.cpp b/services/abilitymgr/src/ability_manager_service.cpp index 886932d633..7c6daa21cc 100644 --- a/services/abilitymgr/src/ability_manager_service.cpp +++ b/services/abilitymgr/src/ability_manager_service.cpp @@ -8796,7 +8796,11 @@ int AbilityManagerService::IsCallFromBackground(const AbilityRequest &abilityReq return ERR_OK; } auto abilityState = callerAbility->GetAbilityState(); - if (abilityState == AbilityState::BACKGROUND || abilityState == AbilityState::BACKGROUNDING) { + if (abilityState == AbilityState::BACKGROUND || abilityState == AbilityState::BACKGROUNDING || + // If uiability or uiextensionability ability state is foreground when terminate, + // it will move to background firstly. So if startAbility in onBackground() lifecycle, + // the actual ability state may be had changed to terminating from background or backgrounding. + abilityState == AbilityState::TERMINATING) { return ERR_OK; } } else { From 7c15ffd505f90120ec3c5fc371e22968c4ad524f Mon Sep 17 00:00:00 2001 From: lw19901203 Date: Sat, 11 May 2024 14:16:05 +0800 Subject: [PATCH 096/174] preview Signed-off-by: lw19901203 Change-Id: I6edefe1b628932896af3ff9b6c3074ed303d5154 --- .../simulator/ability_simulator/src/js_runtime_utils.cpp | 6 +++--- interfaces/inner_api/runtime/include/js_runtime_utils.h | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/frameworks/simulator/ability_simulator/src/js_runtime_utils.cpp b/frameworks/simulator/ability_simulator/src/js_runtime_utils.cpp index 998bd24579..df9e345c84 100644 --- a/frameworks/simulator/ability_simulator/src/js_runtime_utils.cpp +++ b/frameworks/simulator/ability_simulator/src/js_runtime_utils.cpp @@ -299,21 +299,21 @@ std::unique_ptr CreateAsyncTaskWithLastParam(napi_env env, napi_v } std::unique_ptr CreateAsyncTaskWithLastParam(napi_env env, napi_value lastParam, - NapiAsyncTask::ExecuteCallback &&execute, nullptr_t, napi_value *result) + NapiAsyncTask::ExecuteCallback &&execute, std::nullptr_t, napi_value *result) { return CreateAsyncTaskWithLastParam( env, lastParam, std::make_unique(std::move(execute)), nullptr, result); } std::unique_ptr CreateAsyncTaskWithLastParam(napi_env env, napi_value lastParam, - nullptr_t, NapiAsyncTask::CompleteCallback &&complete, napi_value *result) + std::nullptr_t, NapiAsyncTask::CompleteCallback &&complete, napi_value *result) { return CreateAsyncTaskWithLastParam( env, lastParam, nullptr, std::make_unique(std::move(complete)), result); } std::unique_ptr CreateAsyncTaskWithLastParam(napi_env env, napi_value lastParam, - nullptr_t, nullptr_t, napi_value *result) + std::nullptr_t, std::nullptr_t, napi_value *result) { return CreateAsyncTaskWithLastParam(env, lastParam, std::unique_ptr(), std::unique_ptr(), result); diff --git a/interfaces/inner_api/runtime/include/js_runtime_utils.h b/interfaces/inner_api/runtime/include/js_runtime_utils.h index be8fb80f30..e586f1bff0 100644 --- a/interfaces/inner_api/runtime/include/js_runtime_utils.h +++ b/interfaces/inner_api/runtime/include/js_runtime_utils.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2021-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -295,13 +295,13 @@ std::unique_ptr CreateAsyncTaskWithLastParam(napi_env env, napi_v NapiAsyncTask::ExecuteCallback&& execute, NapiAsyncTask::CompleteCallback&& complete, napi_value* result); std::unique_ptr CreateAsyncTaskWithLastParam(napi_env env, napi_value lastParam, - NapiAsyncTask::ExecuteCallback&& execute, nullptr_t, napi_value* result); + NapiAsyncTask::ExecuteCallback&& execute, std::nullptr_t, napi_value* result); std::unique_ptr CreateAsyncTaskWithLastParam(napi_env env, napi_value lastParam, - nullptr_t, NapiAsyncTask::CompleteCallback&& complete, napi_value* result); + std::nullptr_t, NapiAsyncTask::CompleteCallback&& complete, napi_value* result); std::unique_ptr CreateAsyncTaskWithLastParam(napi_env env, napi_value lastParam, - nullptr_t, nullptr_t, napi_value* result); + std::nullptr_t, std::nullptr_t, napi_value* result); } // namespace AbilityRuntime } // namespace OHOS #endif // OHOS_ABILITY_RUNTIME_JS_RUNTIME_UTILS_H From 8505f6e69ce91271057d4be28aaddc088f9f2bd8 Mon Sep 17 00:00:00 2001 From: zhaoleyi Date: Thu, 16 May 2024 16:15:02 +0800 Subject: [PATCH 097/174] =?UTF-8?q?=E4=BF=AE=E6=94=B9preloadUIExtension?= =?UTF-8?q?=E8=BF=9B=E7=A8=8B=E6=A8=A1=E5=9E=8B=E5=8F=8A=E8=BF=9B=E7=A8=8B?= =?UTF-8?q?=E6=8C=81=E6=9C=89=E5=85=B3=E7=B3=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhaoleyi Change-Id: I74cc200f56c3a95497349dab7a6c9f9c7205f855 --- .../include/extension_record_manager.h | 3 +- .../src/ability_connect_manager.cpp | 14 +++-- .../src/extension_record_manager.cpp | 51 +++++++++++++------ .../ability_connect_manager_test.cpp | 12 +---- 4 files changed, 47 insertions(+), 33 deletions(-) diff --git a/services/abilitymgr/include/extension_record_manager.h b/services/abilitymgr/include/extension_record_manager.h index ff3ffe660a..3b809cad12 100644 --- a/services/abilitymgr/include/extension_record_manager.h +++ b/services/abilitymgr/include/extension_record_manager.h @@ -87,8 +87,7 @@ public: int32_t StartAbility(const AAFwk::AbilityRequest &abilityRequest); - int32_t CreateExtensionRecord( - const std::shared_ptr &abilityRecord, const std::string &hostBundleName, + int32_t CreateExtensionRecord(const AAFwk::AbilityRequest &abilityRequest, const std::string &hostBundleName, std::shared_ptr &extensionRecord, int32_t &extensionRecordId); bool IsPreloadExtensionRecord(const AAFwk::AbilityRequest &abilityRequest, diff --git a/services/abilitymgr/src/ability_connect_manager.cpp b/services/abilitymgr/src/ability_connect_manager.cpp index cfbc598408..81b21f7f62 100644 --- a/services/abilitymgr/src/ability_connect_manager.cpp +++ b/services/abilitymgr/src/ability_connect_manager.cpp @@ -563,22 +563,21 @@ int AbilityConnectManager::PreloadUIExtensionAbilityInner(const AbilityRequest & std::string &hostBundleName) { TAG_LOGD(AAFwkTag::ABILITYMGR, "call"); - //get target service ability record, and check whether it has been loaded. - std::shared_ptr targetService = AbilityRecord::CreateAbilityRecord(abilityRequest); - CHECK_POINTER_AND_RETURN(targetService, ERR_INVALID_VALUE); - if (!UIExtensionUtils::IsUIExtension(targetService->GetAbilityInfo().extensionAbilityType)) { + if (!UIExtensionUtils::IsUIExtension(abilityRequest.abilityInfo.extensionAbilityType)) { TAG_LOGE(AAFwkTag::ABILITYMGR, "Can't preload non-uiextension type."); return ERR_WRONG_INTERFACE_CALL; } std::shared_ptr extensionRecord = nullptr; CHECK_POINTER_AND_RETURN(uiExtensionAbilityRecordMgr_, ERR_NULL_OBJECT); int32_t extensionRecordId = INVALID_EXTENSION_RECORD_ID; - int32_t ret = uiExtensionAbilityRecordMgr_->CreateExtensionRecord(targetService, hostBundleName, + int32_t ret = uiExtensionAbilityRecordMgr_->CreateExtensionRecord(abilityRequest, hostBundleName, extensionRecord, extensionRecordId); if (ret != ERR_OK) { TAG_LOGE(AAFwkTag::ABILITYMGR, "CreateExtensionRecord ERR."); return ret; } + CHECK_POINTER_AND_RETURN(extensionRecord, ERR_NULL_OBJECT); + std::shared_ptr targetService = extensionRecord->abilityRecord_; AppExecFwk::ElementName element(abilityRequest.abilityInfo.deviceId, abilityRequest.abilityInfo.bundleName, abilityRequest.abilityInfo.name, abilityRequest.abilityInfo.moduleName); std::string extensionRecordKey = element.GetURI() + std::to_string(targetService->GetUIExtensionAbilityId()); @@ -2915,6 +2914,11 @@ void AbilityConnectManager::UpdateUIExtensionInfo(const std::shared_ptrGetPid(); wantParams.SetParam(UIEXTENSION_ROOT_HOST_PID, AAFwk::Integer::Box(rootHostPid)); } + if (abilityRecord->GetWant().GetBoolParam(IS_PRELOAD_UIEXTENSION_ABILITY, false)) { + // Applicable only to preloadUIExtension scenarios + auto rootHostPid = IPCSkeleton::GetCallingPid(); + wantParams.SetParam(UIEXTENSION_ROOT_HOST_PID, AAFwk::Integer::Box(rootHostPid)); + } abilityRecord->UpdateUIExtensionInfo(wantParams); } } // namespace AAFwk diff --git a/services/abilitymgr/src/extension_record_manager.cpp b/services/abilitymgr/src/extension_record_manager.cpp index 17073d4b79..29512f4023 100644 --- a/services/abilitymgr/src/extension_record_manager.cpp +++ b/services/abilitymgr/src/extension_record_manager.cpp @@ -26,6 +26,7 @@ namespace OHOS { namespace AbilityRuntime { namespace { constexpr const char *SEPARATOR = ":"; +const std::string IS_PRELOAD_UIEXTENSION_ABILITY = "ability.want.params.is_preload_uiextension_ability"; } std::atomic_int32_t ExtensionRecordManager::extensionRecordId_ = INVALID_EXTENSION_RECORD_ID; @@ -455,32 +456,50 @@ sptr ExtensionRecordManager::GetRootCallerTokenLocked(int32_t ext return nullptr; } -int32_t ExtensionRecordManager::CreateExtensionRecord(const std::shared_ptr &abilityRecord, +int32_t ExtensionRecordManager::CreateExtensionRecord(const AAFwk::AbilityRequest &abilityRequest, const std::string &hostBundleName, std::shared_ptr &extensionRecord, int32_t &extensionRecordId) { - // factory pattern with ability request - if (abilityRecord == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "abilityRecord is null"); - return ERR_NULL_OBJECT; + TAG_LOGD(AAFwkTag::ABILITYMGR, "call"); + std::shared_ptr factory = nullptr; + if (AAFwk::UIExtensionUtils::IsUIExtension(abilityRequest.abilityInfo.extensionAbilityType)) { + factory = DelayedSingleton::GetInstance(); } + if (factory == nullptr) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "Invalid extensionAbilityType"); + return ERR_INVALID_VALUE; + } + int32_t result = factory->CreateRecord(abilityRequest, extensionRecord); + if (result != ERR_OK) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "createRecord error"); + return result; + } + CHECK_POINTER_AND_RETURN(extensionRecord, ERR_NULL_OBJECT); + std::shared_ptr abilityRecord = extensionRecord->abilityRecord_; + CHECK_POINTER_AND_RETURN(abilityRecord, ERR_NULL_OBJECT); extensionRecordId = GenerateExtensionRecordId(extensionRecordId); - if (AAFwk::UIExtensionUtils::IsUIExtension(abilityRecord->GetAbilityInfo().extensionAbilityType)) { - extensionRecord = std::make_shared(abilityRecord); - extensionRecord->hostBundleName_ = hostBundleName; - extensionRecord->extensionRecordId_ = extensionRecordId; - std::lock_guard lock(mutex_); - TAG_LOGD(AAFwkTag::ABILITYMGR, "add UIExtension, id %{public}d.", extensionRecordId); - extensionRecords_[extensionRecordId] = extensionRecord; - abilityRecord->SetUIExtensionAbilityId(extensionRecordId); - //add uiextension record register state observer object. + extensionRecord->extensionRecordId_ = extensionRecordId; + extensionRecord->hostBundleName_ = hostBundleName; + abilityRecord->SetOwnerMissionUserId(userId_); + abilityRecord->SetUIExtensionAbilityId(extensionRecordId); + //add uiextension record register state observer object. + if (abilityRecord->GetWant().GetBoolParam(IS_PRELOAD_UIEXTENSION_ABILITY, false)) { auto ret = extensionRecord->RegisterStateObserver(hostBundleName); if (ret != ERR_OK) { TAG_LOGE(AAFwkTag::ABILITYMGR, "Register extensionRecord state observer failed, err: %{public}d.", ret); return ERR_INVALID_VALUE; } - return ERR_OK; } - return ERR_INVALID_VALUE; + result = UpdateProcessName(abilityRequest, extensionRecord); + if (result != ERR_OK) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "update processname error!"); + return result; + } + TAG_LOGI(AAFwkTag::ABILITYMGR, + "extensionRecordId: %{public}d, extensionProcessMode:%{public}d, process: %{public}s", + extensionRecordId, abilityRequest.extensionProcessMode, abilityRecord->GetAbilityInfo().process.c_str()); + std::lock_guard lock(mutex_); + extensionRecords_[extensionRecordId] = extensionRecord; + return ERR_OK; } std::shared_ptr ExtensionRecordManager::GetUIExtensionRootHostInfo( diff --git a/test/unittest/ability_connect_manager_test/ability_connect_manager_test.cpp b/test/unittest/ability_connect_manager_test/ability_connect_manager_test.cpp index 98f5617f91..c5a93c0791 100644 --- a/test/unittest/ability_connect_manager_test/ability_connect_manager_test.cpp +++ b/test/unittest/ability_connect_manager_test/ability_connect_manager_test.cpp @@ -3127,17 +3127,14 @@ HWTEST_F(AbilityConnectManagerTest, IsUIExtensionFocused_002, TestSize.Level1) auto request1 = GenerateAbilityRequest(device, abilityName1, appName1, bundleName1, moduleName1); auto uiExtension1 = AbilityRecord::CreateAbilityRecord(request1); EXPECT_NE(uiExtension1, nullptr); + int32_t ret = connectManager->uiExtensionAbilityRecordMgr_->CreateExtensionRecord(uiExtension1, bundleName1, + extensionRecord1, extensionId1); uiExtension1->abilityInfo_.extensionAbilityType = ExtensionAbilityType::SYS_COMMON_UI; sptr sessionInfo1 = new (std::nothrow) SessionInfo(); sessionInfo1->callerToken = uiExtensionUser->GetToken(); uiExtension1->sessionInfo_ = sessionInfo1; connectManager->uiExtensionMap_.emplace( callbackA_->AsObject(), AbilityConnectManager::UIExtWindowMapValType(uiExtension1, sessionInfo1)); - int32_t extensionId1 = 1; - std::shared_ptr extensionRecord1 = nullptr; - int32_t ret = connectManager->uiExtensionAbilityRecordMgr_->CreateExtensionRecord(uiExtension1, "", - extensionRecord1, extensionId1); - EXPECT_EQ(ret, ERR_OK); bool isFocused1 = connectManager->IsUIExtensionFocused( uiExtension1->GetApplicationInfo().accessTokenId, uiExtensionUser->GetToken()); EXPECT_EQ(isFocused1, true); @@ -3155,11 +3152,6 @@ HWTEST_F(AbilityConnectManagerTest, IsUIExtensionFocused_002, TestSize.Level1) uiExtension2->sessionInfo_ = sessionInfo2; connectManager->uiExtensionMap_.emplace( callbackA_->AsObject(), AbilityConnectManager::UIExtWindowMapValType(uiExtension2, sessionInfo2)); - int32_t extensionId2 = 2; - std::shared_ptr extensionRecord2 = nullptr; - ret = connectManager->uiExtensionAbilityRecordMgr_->CreateExtensionRecord(uiExtension2, "", - extensionRecord2, extensionId2); - EXPECT_EQ(ret, ERR_OK); bool isFocused2 = connectManager->IsUIExtensionFocused( uiExtension2->GetApplicationInfo().accessTokenId, uiExtensionUser->GetToken()); EXPECT_EQ(isFocused2, true); From 9234dd3669bfbe3c3a1f692a693439badb1cfc74 Mon Sep 17 00:00:00 2001 From: wangzhen Date: Sat, 18 May 2024 15:39:30 +0800 Subject: [PATCH 098/174] GetPriorityObject crash Signed-off-by: wangzhen Change-Id: I59bda31a065aacd741af345bcc4d85364de3d2e7 --- services/appmgr/include/app_running_record.h | 2 +- services/appmgr/src/app_running_record.cpp | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/services/appmgr/include/app_running_record.h b/services/appmgr/include/app_running_record.h index 5be902a7a4..d4408ed6e6 100644 --- a/services/appmgr/include/app_running_record.h +++ b/services/appmgr/include/app_running_record.h @@ -861,7 +861,7 @@ private: std::unordered_set, RemoteObjHash> foregroundingAbilityTokens_; std::weak_ptr appMgrServiceInner_; sptr appDeathRecipient_ = nullptr; - std::shared_ptr priorityObject_ = nullptr; + std::shared_ptr priorityObject_; std::shared_ptr appLifeCycleDeal_ = nullptr; std::shared_ptr taskHandler_; std::shared_ptr eventHandler_; diff --git a/services/appmgr/src/app_running_record.cpp b/services/appmgr/src/app_running_record.cpp index 01d7271f2d..e69133f143 100644 --- a/services/appmgr/src/app_running_record.cpp +++ b/services/appmgr/src/app_running_record.cpp @@ -198,6 +198,7 @@ AppRunningRecord::AppRunningRecord( isLauncherApp_ = info->isLauncherApp; mainAppName_ = info->name; } + priorityObject_ = std::make_shared(); struct timespec t; t.tv_sec = 0; @@ -1189,10 +1190,6 @@ void AppRunningRecord::SetAppDeathRecipient(const sptr &appDe std::shared_ptr AppRunningRecord::GetPriorityObject() { - if (!priorityObject_) { - priorityObject_ = std::make_shared(); - } - return priorityObject_; } From b8eb8abe2bbc0fb0ff406c98932d7ac9f3e5a2b2 Mon Sep 17 00:00:00 2001 From: leo Date: Sat, 18 May 2024 16:28:13 +0800 Subject: [PATCH 099/174] chenxu25@huawei.com Signed-off-by: leo --- .../include/appmgr/app_mgr_client.h | 4 +- .../include/appmgr/app_mgr_constants.h | 1 + .../include/appmgr/app_mgr_interface.h | 5 +- .../appmgr/app_mgr_ipc_interface_code.h | 1 + .../include/appmgr/app_mgr_proxy.h | 5 +- .../app_manager/include/appmgr/app_mgr_stub.h | 2 +- .../include/appmgr/irender_scheduler.h | 2 +- .../include/appmgr/render_scheduler_proxy.h | 2 +- .../app_manager/src/appmgr/app_mgr_client.cpp | 14 +++++- .../app_manager/src/appmgr/app_mgr_proxy.cpp | 28 ++++++++++- .../app_manager/src/appmgr/app_mgr_stub.cpp | 12 ++++- .../src/appmgr/render_scheduler_host.cpp | 3 +- .../src/appmgr/render_scheduler_proxy.cpp | 6 ++- services/appmgr/include/app_mgr_service.h | 3 +- .../appmgr/include/app_mgr_service_inner.h | 7 ++- services/appmgr/include/app_running_record.h | 8 ++++ services/appmgr/include/app_spawn_client.h | 1 + services/appmgr/src/app_mgr_service.cpp | 14 +++++- services/appmgr/src/app_mgr_service_inner.cpp | 46 ++++++++++++++++--- services/appmgr/src/app_running_record.cpp | 27 +++++++++++ services/appmgr/src/app_spawn_client.cpp | 7 +++ .../include/mock_app_mgr_service.h | 5 +- .../include/mock_app_mgr_service.h | 3 +- .../mock/include/mock_render_scheduler.h | 4 +- .../main_thread_test/main_thread_test.cpp | 2 +- 25 files changed, 182 insertions(+), 30 deletions(-) diff --git a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_client.h b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_client.h index 82788269c7..0ceb2632e2 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_client.h +++ b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_client.h @@ -441,7 +441,7 @@ public: */ virtual int StartRenderProcess(const std::string &renderParam, int32_t ipcFd, int32_t sharedFd, - int32_t crashFd, pid_t &renderPid); + int32_t crashFd, pid_t &renderPid, bool isGPU = false); /** * Render process call this to attach app manager service. @@ -743,6 +743,8 @@ public: AppExecFwk::PreloadMode preloadMode, int32_t appIndex = 0); int32_t SetSupportedProcessCacheSelf(bool isSupport); + + void SaveBrowserChannel(sptr browser); private: void SetServiceManager(std::unique_ptr serviceMgr); /** diff --git a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_constants.h b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_constants.h index 7631203f7c..0eed09018a 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_constants.h +++ b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_constants.h @@ -78,6 +78,7 @@ enum class ProcessType { NORMAL = 0, EXTENSION, RENDER, + GPU, }; enum class AppStartType { diff --git a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_interface.h b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_interface.h index 5bd33cabd4..e00e57b2a6 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_interface.h +++ b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_interface.h @@ -334,11 +334,12 @@ public: * @param sharedFd, shared memory file descriptior. * @param crashFd, crash signal file descriptior. * @param renderPid, created render pid. + * @param isGPU, is or not gpu process * @return Returns ERR_OK on success, others on failure. */ virtual int StartRenderProcess(const std::string &renderParam, int32_t ipcFd, int32_t sharedFd, - int32_t crashFd, pid_t &renderPid) = 0; + int32_t crashFd, pid_t &renderPid, bool isGPU = false) = 0; /** * Render process call this to attach app manager service. @@ -662,6 +663,8 @@ public: */ virtual int32_t StartNativeChildProcess(const std::string &libName, int32_t childProcessCount, const sptr &callback) = 0; + + virtual void SaveBrowserChannel(sptr browser) = 0; }; } // namespace AppExecFwk } // namespace OHOS diff --git a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_ipc_interface_code.h b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_ipc_interface_code.h index 3bf4423786..5b6510148d 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_ipc_interface_code.h +++ b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_ipc_interface_code.h @@ -100,6 +100,7 @@ enum class AppMgrInterfaceCode { SET_SUPPORTED_PROCESS_CACHE_SELF = 74, APP_GET_RUNNING_PROCESSES_BY_BUNDLE_TYPE = 75, START_NATIVE_CHILD_PROCESS = 76, + SAVE_BROWSER_CHANNEL = 77, }; } // AppExecFwk } // OHOS diff --git a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_proxy.h b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_proxy.h index 0d7b7c98e6..9a61f62e0f 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_proxy.h +++ b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_proxy.h @@ -306,11 +306,12 @@ public: * @param sharedFd, shared memory file descriptior. * @param crashFd, crash signal file descriptior. * @param renderPid, created render pid. + * @param isGPU, is or not GPU process * @return Returns ERR_OK on success, others on failure. */ virtual int StartRenderProcess(const std::string &renderParam, int32_t ipcFd, int32_t sharedFd, - int32_t crashFd, pid_t &renderPid) override; + int32_t crashFd, pid_t &renderPid, bool isGPU = false) override; /** * Render process call this to attach app manager service. @@ -579,6 +580,8 @@ public: int32_t StartNativeChildProcess(const std::string &libName, int32_t childProcessCount, const sptr &callback) override; + virtual void SaveBrowserChannel(sptr browser) override; + private: bool SendTransactCmd(AppMgrInterfaceCode code, MessageParcel &data, MessageParcel &reply); bool WriteInterfaceToken(MessageParcel &data); diff --git a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_stub.h b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_stub.h index e9a7da927e..319083bf22 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_stub.h +++ b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_stub.h @@ -136,7 +136,7 @@ private: int32_t HandleNotifyMemorySizeStateChanged(MessageParcel &data, MessageParcel &reply); int32_t HandleSetSupportedProcessCacheSelf(MessageParcel &data, MessageParcel &reply); int32_t HandleStartNativeChildProcess(MessageParcel &data, MessageParcel &reply); - + int32_t HandleSaveBrowserChannel(MessageParcel &data, MessageParcel &reply); using AppMgrFunc = int32_t (AppMgrStub::*)(MessageParcel &data, MessageParcel &reply); std::map memberFuncMap_; diff --git a/interfaces/inner_api/app_manager/include/appmgr/irender_scheduler.h b/interfaces/inner_api/app_manager/include/appmgr/irender_scheduler.h index 22d9f891dc..35c114587a 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/irender_scheduler.h +++ b/interfaces/inner_api/app_manager/include/appmgr/irender_scheduler.h @@ -36,7 +36,7 @@ public: * @param crashFd, crash signal file descriptior. */ virtual void NotifyBrowserFd(int32_t ipcFd, int32_t sharedFd, - int32_t crashFd) = 0; + int32_t crashFd, sptr browser) = 0; enum class Message { NOTIFY_BROWSER_FD = 1, diff --git a/interfaces/inner_api/app_manager/include/appmgr/render_scheduler_proxy.h b/interfaces/inner_api/app_manager/include/appmgr/render_scheduler_proxy.h index c529f55548..5465ad97b8 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/render_scheduler_proxy.h +++ b/interfaces/inner_api/app_manager/include/appmgr/render_scheduler_proxy.h @@ -40,7 +40,7 @@ public: * @param crashFd, crash signal file descriptior. */ virtual void NotifyBrowserFd(int32_t ipcFd, int32_t sharedFd, - int32_t crashFd) override; + int32_t crashFd, sptr browser) override; private: bool WriteInterfaceToken(MessageParcel &data); diff --git a/interfaces/inner_api/app_manager/src/appmgr/app_mgr_client.cpp b/interfaces/inner_api/app_manager/src/appmgr/app_mgr_client.cpp index 22bbd4dac0..c013083475 100644 --- a/interfaces/inner_api/app_manager/src/appmgr/app_mgr_client.cpp +++ b/interfaces/inner_api/app_manager/src/appmgr/app_mgr_client.cpp @@ -758,12 +758,12 @@ int AppMgrClient::PreStartNWebSpawnProcess() int AppMgrClient::StartRenderProcess(const std::string &renderParam, int32_t ipcFd, int32_t sharedFd, - int32_t crashFd, pid_t &renderPid) + int32_t crashFd, pid_t &renderPid, bool isGPU) { sptr service = iface_cast(mgrHolder_->GetRemoteObject()); if (service != nullptr) { return service->StartRenderProcess(renderParam, ipcFd, sharedFd, crashFd, - renderPid); + renderPid, isGPU); } return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED; } @@ -1182,5 +1182,15 @@ int32_t AppMgrClient::SetSupportedProcessCacheSelf(bool isSupport) } return service->SetSupportedProcessCacheSelf(isSupport); } + +void AppMgrClient::SaveBrowserChannel(sptr browser) +{ + sptr service = iface_cast(mgrHolder_->GetRemoteObject()); + if (service == nullptr) { + TAG_LOGE(AAFwkTag::APPMGR, "Service is nullptr."); + return; + } + service->SaveBrowserChannel(browser); +} } // namespace AppExecFwk } // namespace OHOS diff --git a/interfaces/inner_api/app_manager/src/appmgr/app_mgr_proxy.cpp b/interfaces/inner_api/app_manager/src/appmgr/app_mgr_proxy.cpp index 7273f64b0e..c20a6fff56 100644 --- a/interfaces/inner_api/app_manager/src/appmgr/app_mgr_proxy.cpp +++ b/interfaces/inner_api/app_manager/src/appmgr/app_mgr_proxy.cpp @@ -808,7 +808,7 @@ int AppMgrProxy::PreStartNWebSpawnProcess() int AppMgrProxy::StartRenderProcess(const std::string &renderParam, int32_t ipcFd, int32_t sharedFd, - int32_t crashFd, pid_t &renderPid) + int32_t crashFd, pid_t &renderPid, bool isGPU) { if (renderParam.empty() || ipcFd <= 0 || sharedFd <= 0 || crashFd <= 0) { TAG_LOGE(AAFwkTag::APPMGR, "Invalid params, renderParam:%{private}s, ipcFd:%{public}d, " @@ -836,6 +836,11 @@ int AppMgrProxy::StartRenderProcess(const std::string &renderParam, return -1; } + if (!data.WriteBool(isGPU)) { + TAG_LOGE(AAFwkTag::APPMGR, "want processType failed."); + return -1; + } + int32_t ret = SendRequest(AppMgrInterfaceCode::START_RENDER_PROCESS, data, reply, option); if (ret != NO_ERROR) { @@ -877,6 +882,27 @@ void AppMgrProxy::AttachRenderProcess(const sptr &renderScheduler } } +void AppMgrProxy::SaveBrowserChannel(sptr browser) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!WriteInterfaceToken(data)) { + TAG_LOGE(AAFwkTag::APPMGR, "WriteInterfaceToken failed"); + return; + } + + if (!data.WriteRemoteObject(browser)) { + TAG_LOGE(AAFwkTag::APPMGR, "browser write failed."); + return; + } + + if (!SendTransactCmd(AppMgrInterfaceCode::SAVE_BROWSER_CHANNEL, data, reply)) { + TAG_LOGE(AAFwkTag::APPMGR, "SendTransactCmd SAVE_BROWSER_CHANNEL failed"); + return; + } +} + int AppMgrProxy::GetRenderProcessTerminationStatus(pid_t renderPid, int &status) { MessageParcel data; diff --git a/interfaces/inner_api/app_manager/src/appmgr/app_mgr_stub.cpp b/interfaces/inner_api/app_manager/src/appmgr/app_mgr_stub.cpp index ed1995161a..e7c21d3bad 100644 --- a/interfaces/inner_api/app_manager/src/appmgr/app_mgr_stub.cpp +++ b/interfaces/inner_api/app_manager/src/appmgr/app_mgr_stub.cpp @@ -192,6 +192,8 @@ AppMgrStub::AppMgrStub() &AppMgrStub::HandleGetRunningProcessesByBundleType; memberFuncMap_[static_cast(AppMgrInterfaceCode::START_NATIVE_CHILD_PROCESS)] = &AppMgrStub::HandleStartNativeChildProcess; + memberFuncMap_[static_cast(AppMgrInterfaceCode::SAVE_BROWSER_CHANNEL)] = + &AppMgrStub::HandleSaveBrowserChannel; } AppMgrStub::~AppMgrStub() @@ -676,8 +678,9 @@ int32_t AppMgrStub::HandleStartRenderProcess(MessageParcel &data, MessageParcel int32_t sharedFd = data.ReadFileDescriptor(); int32_t crashFd = data.ReadFileDescriptor(); int32_t renderPid = 0; + bool isGPU = data.ReadBool(); int32_t result = - StartRenderProcess(renderParam, ipcFd, sharedFd, crashFd, renderPid); + StartRenderProcess(renderParam, ipcFd, sharedFd, crashFd, renderPid, isGPU); if (!reply.WriteInt32(result)) { TAG_LOGE(AAFwkTag::APPMGR, "write result error."); return ERR_INVALID_VALUE; @@ -696,6 +699,13 @@ int32_t AppMgrStub::HandleAttachRenderProcess(MessageParcel &data, MessageParcel return NO_ERROR; } +int32_t AppMgrStub::HandleSaveBrowserChannel(MessageParcel &data, MessageParcel &reply) +{ + sptr browser = data.ReadRemoteObject(); + SaveBrowserChannel(browser); + return NO_ERROR; +} + int32_t AppMgrStub::HandleGetRenderProcessTerminationStatus(MessageParcel &data, MessageParcel &reply) { int32_t renderPid = data.ReadInt32(); diff --git a/interfaces/inner_api/app_manager/src/appmgr/render_scheduler_host.cpp b/interfaces/inner_api/app_manager/src/appmgr/render_scheduler_host.cpp index 8fef51a28d..059e9b6b72 100644 --- a/interfaces/inner_api/app_manager/src/appmgr/render_scheduler_host.cpp +++ b/interfaces/inner_api/app_manager/src/appmgr/render_scheduler_host.cpp @@ -60,7 +60,8 @@ int RenderSchedulerHost::HandleNotifyBrowserFd(MessageParcel &data, MessageParce int32_t ipcFd = data.ReadFileDescriptor(); int32_t sharedFd = data.ReadFileDescriptor(); int32_t crashFd = data.ReadFileDescriptor(); - NotifyBrowserFd(ipcFd, sharedFd, crashFd); + sptr browser = data.ReadRemoteObject(); + NotifyBrowserFd(ipcFd, sharedFd, crashFd, browser); return 0; } } // namespace AppExecFwk diff --git a/interfaces/inner_api/app_manager/src/appmgr/render_scheduler_proxy.cpp b/interfaces/inner_api/app_manager/src/appmgr/render_scheduler_proxy.cpp index 3f0073bb88..9f670bedfb 100644 --- a/interfaces/inner_api/app_manager/src/appmgr/render_scheduler_proxy.cpp +++ b/interfaces/inner_api/app_manager/src/appmgr/render_scheduler_proxy.cpp @@ -36,7 +36,7 @@ bool RenderSchedulerProxy::WriteInterfaceToken(MessageParcel &data) } void RenderSchedulerProxy::NotifyBrowserFd(int32_t ipcFd, int32_t sharedFd, - int32_t crashFd) + int32_t crashFd, sptr browser) { TAG_LOGD(AAFwkTag::APPMGR, "NotifyBrowserFd start"); MessageParcel data; @@ -53,6 +53,10 @@ void RenderSchedulerProxy::NotifyBrowserFd(int32_t ipcFd, int32_t sharedFd, return; } + if (!data.WriteRemoteObject(browser)) { + TAG_LOGE(AAFwkTag::APPMGR, "write browser failed!"); + } + sptr remote = Remote(); if (remote == nullptr) { TAG_LOGE(AAFwkTag::APPMGR, "Remote() is NULL"); diff --git a/services/appmgr/include/app_mgr_service.h b/services/appmgr/include/app_mgr_service.h index 397362bf81..77de959d98 100644 --- a/services/appmgr/include/app_mgr_service.h +++ b/services/appmgr/include/app_mgr_service.h @@ -309,7 +309,7 @@ public: virtual int StartRenderProcess(const std::string &renderParam, int32_t ipcFd, int32_t sharedFd, - int32_t crashFd, pid_t &renderPid) override; + int32_t crashFd, pid_t &renderPid, bool isGPU = false) override; virtual void AttachRenderProcess(const sptr &shceduler) override; @@ -514,6 +514,7 @@ public: int32_t StartNativeChildProcess(const std::string &libName, int32_t childProcessCount, const sptr &callback) override; + virtual void SaveBrowserChannel(sptr browser) override; private: /** * Init, Initialize application services. diff --git a/services/appmgr/include/app_mgr_service_inner.h b/services/appmgr/include/app_mgr_service_inner.h index c8224f29d5..2c004621dc 100644 --- a/services/appmgr/include/app_mgr_service_inner.h +++ b/services/appmgr/include/app_mgr_service_inner.h @@ -692,7 +692,7 @@ public: virtual int32_t StartRenderProcess(const pid_t hostPid, const std::string &renderParam, int32_t ipcFd, int32_t sharedFd, - int32_t crashFd, pid_t &renderPid); + int32_t crashFd, pid_t &renderPid, bool isGPU = false); virtual void AttachRenderProcess(const pid_t pid, const sptr &scheduler); @@ -1068,6 +1068,8 @@ public: int32_t SetSupportedProcessCacheSelf(bool isSupport); void OnAppCacheStateChanged(const std::shared_ptr &appRecord); + + virtual void SaveBrowserChannel(const pid_t hostPid, sptr browser); private: std::string FaultTypeToString(FaultDataType type); @@ -1265,7 +1267,7 @@ private: void GetRenderProcesses(const std::shared_ptr &appRecord, std::vector &info); int StartRenderProcessImpl(const std::shared_ptr &renderRecord, - const std::shared_ptr appRecord, pid_t &renderPid); + const std::shared_ptr appRecord, pid_t &renderPid, bool isGPU = false); void OnRenderRemoteDied(const wptr &remote); @@ -1457,6 +1459,7 @@ private: ffrt::mutex appStateCallbacksLock_; ffrt::mutex renderUidSetLock_; ffrt::mutex exceptionLock_; + ffrt::mutex browserHostLock_; sptr startSpecifiedAbilityResponse_; ffrt::mutex configurationObserverLock_; std::vector> configurationObservers_; diff --git a/services/appmgr/include/app_running_record.h b/services/appmgr/include/app_running_record.h index 5be902a7a4..e67815e8c7 100644 --- a/services/appmgr/include/app_running_record.h +++ b/services/appmgr/include/app_running_record.h @@ -89,6 +89,7 @@ public: void RegisterDeathRecipient(); void SetState(int32_t state); int32_t GetState() const; + void SetProcessType(ProcessType type); private: void SetHostUid(const int32_t hostUid); @@ -776,6 +777,11 @@ public: bool SetSupportedProcessCache(bool isSupport); SupportProcessCacheState GetSupportProcessCacheState(); + + void SetBrowserHost(sptr browser); + sptr GetBrowserHost(); + void SetIsGPU(bool gpu); + bool GetIsGPU(); private: /** * SearchTheModuleInfoNeedToUpdated, Get an uninitialized abilityStage data. @@ -931,6 +937,8 @@ private: bool isNativeStart_ = false; bool isMultiThread_ = false; SupportProcessCacheState procCacheSupportState_ = SupportProcessCacheState::UNSPECIFIED; + sptr browserHost_; + bool isGPU_ = false; }; } // namespace AppExecFwk diff --git a/services/appmgr/include/app_spawn_client.h b/services/appmgr/include/app_spawn_client.h index d718e30998..e3f4d1a017 100644 --- a/services/appmgr/include/app_spawn_client.h +++ b/services/appmgr/include/app_spawn_client.h @@ -71,6 +71,7 @@ struct AppSpawnStartMsg { bool isolatedExtension = false; // whether is isolatedExtension std::string extensionSandboxPath; bool strictMode = false; // whether is strict mode + std::string processType = ""; }; constexpr auto LEN_PID = sizeof(pid_t); diff --git a/services/appmgr/src/app_mgr_service.cpp b/services/appmgr/src/app_mgr_service.cpp index b0769a7db1..f60cc8e9c4 100644 --- a/services/appmgr/src/app_mgr_service.cpp +++ b/services/appmgr/src/app_mgr_service.cpp @@ -899,7 +899,7 @@ int32_t AppMgrService::PreStartNWebSpawnProcess() } int32_t AppMgrService::StartRenderProcess(const std::string &renderParam, int32_t ipcFd, - int32_t sharedFd, int32_t crashFd, pid_t &renderPid) + int32_t sharedFd, int32_t crashFd, pid_t &renderPid, bool isGPU) { if (!IsReady()) { TAG_LOGE(AAFwkTag::APPMGR, "StartRenderProcess failed, AppMgrService not ready."); @@ -907,7 +907,7 @@ int32_t AppMgrService::StartRenderProcess(const std::string &renderParam, int32_ } return appMgrServiceInner_->StartRenderProcess(IPCSkeleton::GetCallingRealPid(), - renderParam, ipcFd, sharedFd, crashFd, renderPid); + renderParam, ipcFd, sharedFd, crashFd, renderPid, isGPU); } void AppMgrService::AttachRenderProcess(const sptr &scheduler) @@ -927,6 +927,16 @@ void AppMgrService::AttachRenderProcess(const sptr &scheduler) }); } +void AppMgrService::SaveBrowserChannel(sptr browser) +{ + if (!IsReady()) { + TAG_LOGE(AAFwkTag::APPMGR, "SaveBrowserChannel not ready"); + return; + } + + appMgrServiceInner_->SaveBrowserChannel(IPCSkeleton::GetCallingRealPid(), browser); +} + int32_t AppMgrService::GetRenderProcessTerminationStatus(pid_t renderPid, int &status) { if (!IsReady()) { diff --git a/services/appmgr/src/app_mgr_service_inner.cpp b/services/appmgr/src/app_mgr_service_inner.cpp index 2bfc2ba498..51a75ec3e0 100644 --- a/services/appmgr/src/app_mgr_service_inner.cpp +++ b/services/appmgr/src/app_mgr_service_inner.cpp @@ -143,6 +143,10 @@ const std::string MEMMGR_PROC_NAME = "memmgrservice"; const std::string UIEXTENSION_ABILITY_ID = "ability.want.params.uiExtensionAbilityId"; const std::string UIEXTENSION_ROOT_HOST_PID = "ability.want.params.uiExtensionRootHostPid"; const std::string STRICT_MODE = "strictMode"; +const std::string RENDER_PROCESS_NAME = ":render"; +const std::string RENDER_PROCESS_TYPE = "render"; +const std::string GPU_PROCESS_NAME = ":gpu"; +const std::string GPU_PROCESS_TYPE = "gpu"; const int32_t SIGNAL_KILL = 9; constexpr int32_t USER_SCALE = 200000; #define ENUM_TO_STRING(s) #s @@ -4332,7 +4336,7 @@ int AppMgrServiceInner::PreStartNWebSpawnProcess(const pid_t hostPid) } int AppMgrServiceInner::StartRenderProcess(const pid_t hostPid, const std::string &renderParam, - int32_t ipcFd, int32_t sharedFd, int32_t crashFd, pid_t &renderPid) + int32_t ipcFd, int32_t sharedFd, int32_t crashFd, pid_t &renderPid, bool isGPU) { TAG_LOGI(AAFwkTag::APPMGR, "start render process, hostPid:%{public}d", hostPid); if (hostPid <= 0 || renderParam.empty() || ipcFd <= 0 || sharedFd <= 0 || @@ -4355,7 +4359,7 @@ int AppMgrServiceInner::StartRenderProcess(const pid_t hostPid, const std::strin } auto renderRecordMap = appRecord->GetRenderRecordMap(); - if (!renderRecordMap.empty() && !AAFwk::AppUtils::GetInstance().IsUseMultiRenderProcess()) { + if (!isGPU && !renderRecordMap.empty() && !AAFwk::AppUtils::GetInstance().IsUseMultiRenderProcess()) { for (auto iter : renderRecordMap) { if (iter.second != nullptr) { renderPid = iter.second->GetPid(); @@ -4372,10 +4376,11 @@ int AppMgrServiceInner::StartRenderProcess(const pid_t hostPid, const std::strin } } } - + appRecord->SetIsGPU(isGPU); + int32_t childNumLimit = appRecord->GetIsGPU() ? PHONE_MAX_RENDER_PROCESS_NUM + 1 : PHONE_MAX_RENDER_PROCESS_NUM; // The phone device allows a maximum of 40 render processes to be created. if (AAFwk::AppUtils::GetInstance().IsLimitMaximumOfRenderProcess() && - renderRecordMap.size() >= PHONE_MAX_RENDER_PROCESS_NUM) { + renderRecordMap.size() >= childNumLimit) { TAG_LOGE(AAFwkTag::APPMGR, "Reaching the maximum render process limitation, hostPid:%{public}d", hostPid); return ERR_REACHING_MAXIMUM_RENDER_PROCESS_LIMITATION; } @@ -4386,7 +4391,7 @@ int AppMgrServiceInner::StartRenderProcess(const pid_t hostPid, const std::strin return ERR_INVALID_VALUE; } - return StartRenderProcessImpl(renderRecord, appRecord, renderPid); + return StartRenderProcessImpl(renderRecord, appRecord, renderPid, isGPU); } void AppMgrServiceInner::AttachRenderProcess(const pid_t pid, const sptr &scheduler) @@ -4429,9 +4434,26 @@ void AppMgrServiceInner::AttachRenderProcess(const pid_t pid, const sptrGetBrowserHost() != nullptr) { + TAG_LOGD(AAFwkTag::APPMGR, "GPU has host remote object"); + } scheduler->NotifyBrowserFd(renderRecord->GetIpcFd(), renderRecord->GetSharedFd(), - renderRecord->GetCrashFd()); + renderRecord->GetCrashFd(), + appRecord->GetBrowserHost()); +} + +void AppMgrServiceInner::SaveBrowserChannel(const pid_t hostPid, sptr browser) +{ + std::lock_guard lock(browserHostLock_); + TAG_LOGD(AAFwkTag::APPMGR, "save browser channel."); + auto appRecord = GetAppRunningRecordByPid(hostPid); + if (!appRecord) { + TAG_LOGE(AAFwkTag::APPMGR, "save browser host no such appRecord, pid:%{public}d", + hostPid); + return; + } + appRecord->SetBrowserHost(browser); } bool AppMgrServiceInner::GenerateRenderUid(int32_t &renderUid) @@ -4475,7 +4497,7 @@ bool AppMgrServiceInner::GenerateRenderUid(int32_t &renderUid) } int AppMgrServiceInner::StartRenderProcessImpl(const std::shared_ptr &renderRecord, - const std::shared_ptr appRecord, pid_t &renderPid) + const std::shared_ptr appRecord, pid_t &renderPid, bool isGPU) { if (!renderRecord || !appRecord) { TAG_LOGE(AAFwkTag::APPMGR, "renderRecord or appRecord is nullptr."); @@ -4498,6 +4520,13 @@ int AppMgrServiceInner::StartRenderProcessImpl(const std::shared_ptrGetRenderParam(); startMsg.uid = renderUid; startMsg.gid = renderUid; + if (isGPU) { + startMsg.procName += GPU_PROCESS_NAME; + startMsg.processType = GPU_PROCESS_TYPE; + } else { + startMsg.procName += RENDER_PROCESS_NAME; + startMsg.processType = RENDER_PROCESS_TYPE; + } startMsg.code = 0; // 0: DEFAULT pid_t pid = 0; ErrCode errCode = nwebSpawnClient->StartProcess(startMsg, pid); @@ -4510,6 +4539,9 @@ int AppMgrServiceInner::StartRenderProcessImpl(const std::shared_ptrSetPid(pid); renderRecord->SetUid(renderUid); + if (isGPU) { + renderRecord->SetProcessType(ProcessType::GPU); + } appRecord->AddRenderRecord(renderRecord); TAG_LOGI(AAFwkTag::APPMGR, "start render process success, hostPid:%{public}d, hostUid:%{public}d, pid:%{public}d, uid:%{public}d", diff --git a/services/appmgr/src/app_running_record.cpp b/services/appmgr/src/app_running_record.cpp index 01d7271f2d..318bd1af4f 100644 --- a/services/appmgr/src/app_running_record.cpp +++ b/services/appmgr/src/app_running_record.cpp @@ -178,6 +178,11 @@ void RenderRecord::RegisterDeathRecipient() } } +void RenderRecord::SetProcessType(ProcessType type) +{ + processType_ = type; +} + void RenderRecord::SetState(int32_t state) { state_ = state; @@ -2214,5 +2219,27 @@ SupportProcessCacheState AppRunningRecord::GetSupportProcessCacheState() { return procCacheSupportState_; } + +void AppRunningRecord::SetBrowserHost(sptr browser) +{ + browserHost_ = browser; +} + +sptr AppRunningRecord::GetBrowserHost() +{ + return browserHost_; +} + +void AppRunningRecord::SetIsGPU(bool gpu) +{ + if (gpu) { + isGPU_ = gpu; + } +} + +bool AppRunningRecord::GetIsGPU() +{ + return isGPU_; +} } // namespace AppExecFwk } // namespace OHOS diff --git a/services/appmgr/src/app_spawn_client.cpp b/services/appmgr/src/app_spawn_client.cpp index e5036c79dc..b7fa8b0174 100644 --- a/services/appmgr/src/app_spawn_client.cpp +++ b/services/appmgr/src/app_spawn_client.cpp @@ -171,6 +171,13 @@ int32_t AppSpawnClient::SetMountPermission(const AppSpawnStartMsg &startMsg, App } } + if (!startMsg.processType.empty() && + (ret = AppSpawnReqMsgAddExtInfo(reqHandle, MSG_EXT_NAME_PROCESS_TYPE, + reinterpret_cast(startMsg.processType.c_str()), startMsg.processType.size()))) { + HILOG_ERROR("AppSpawnReqMsgAddExtInfo failed, ret: %{public}d", ret); + return ret; + } + return ret; } diff --git a/test/mock/frameworks_kits_appkit_test/include/mock_app_mgr_service.h b/test/mock/frameworks_kits_appkit_test/include/mock_app_mgr_service.h index 4bdd670d5b..bc0d525e65 100644 --- a/test/mock/frameworks_kits_appkit_test/include/mock_app_mgr_service.h +++ b/test/mock/frameworks_kits_appkit_test/include/mock_app_mgr_service.h @@ -55,10 +55,11 @@ public: MOCK_METHOD0(BlockAppService, int()); #endif MOCK_METHOD0(PreStartNWebSpawnProcess, int()); - MOCK_METHOD5(StartRenderProcess, + MOCK_METHOD6(StartRenderProcess, int(const std::string &renderParam, int32_t ipcFd, - int32_t sharedFd, int32_t crashFd, pid_t &renderPid)); + int32_t sharedFd, int32_t crashFd, pid_t &renderPid, bool isGPU)); MOCK_METHOD1(AttachRenderProcess, void(const sptr& renderScheduler)); + MOCK_METHOD1(SaveBrowserChannel, void(sptr browser)); MOCK_METHOD2(GetRenderProcessTerminationStatus, int(pid_t renderPid, int& status)); MOCK_METHOD1(GetConfiguration, int32_t(Configuration& config)); MOCK_METHOD1(UpdateConfiguration, int32_t(const Configuration& config)); diff --git a/test/mock/services_appmgr_test/include/mock_app_mgr_service.h b/test/mock/services_appmgr_test/include/mock_app_mgr_service.h index ec96bfa7c2..79490d7873 100644 --- a/test/mock/services_appmgr_test/include/mock_app_mgr_service.h +++ b/test/mock/services_appmgr_test/include/mock_app_mgr_service.h @@ -56,8 +56,9 @@ public: MOCK_METHOD1(StartupResidentProcess, void(const std::vector& bundleInfos)); MOCK_METHOD1(AddAbilityStageDone, void(const int32_t recordId)); MOCK_METHOD0(PreStartNWebSpawnProcess, int()); - MOCK_METHOD5(StartRenderProcess, int(const std::string&, int32_t, int32_t, int32_t, pid_t&)); + MOCK_METHOD6(StartRenderProcess, int(const std::string&, int32_t, int32_t, int32_t, pid_t&, bool)); MOCK_METHOD1(AttachRenderProcess, void(const sptr& renderScheduler)); + MOCK_METHOD1(SaveBrowserChannel, void(sptr browser)); MOCK_METHOD2(GetRenderProcessTerminationStatus, int(pid_t renderPid, int& status)); MOCK_METHOD2(RegisterApplicationStateObserver, int32_t(const sptr& observer, const std::vector& bundleNameList)); diff --git a/test/moduletest/mock/include/mock_render_scheduler.h b/test/moduletest/mock/include/mock_render_scheduler.h index 3624e4ae88..593f19fea8 100644 --- a/test/moduletest/mock/include/mock_render_scheduler.h +++ b/test/moduletest/mock/include/mock_render_scheduler.h @@ -26,8 +26,8 @@ public: MockRenderScheduler() = default; virtual ~MockRenderScheduler() = default; - MOCK_METHOD3(NotifyBrowserFd, - void(int32_t ipcFd, int32_t sharedFd, int32_t crashFd)); + MOCK_METHOD4(NotifyBrowserFd, + void(int32_t ipcFd, int32_t sharedFd, int32_t crashFd, sptr browser)); MOCK_METHOD0(AsObject, sptr()); }; } // namespace AppExecFwk diff --git a/test/unittest/appkit/main_thread_test/main_thread_test.cpp b/test/unittest/appkit/main_thread_test/main_thread_test.cpp index aaff673876..50af33d0d2 100644 --- a/test/unittest/appkit/main_thread_test/main_thread_test.cpp +++ b/test/unittest/appkit/main_thread_test/main_thread_test.cpp @@ -198,7 +198,7 @@ class MockAppMgrStub : public AppMgrStub { } int StartRenderProcess(const std::string &renderParam, int32_t ipcFd, - int32_t sharedFd, int32_t crashFd, pid_t &renderPid) override + int32_t sharedFd, int32_t crashFd, pid_t &renderPid, bool isGPU = false) override { return 0; } From 012072eedccda5a8b0a8818211651b5296970bd1 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 18 May 2024 15:46:51 +0800 Subject: [PATCH 100/174] add log Signed-off-by: unknown --- .../appkit/ability_runtime/service_extension_context.cpp | 8 ++++++-- services/abilitymgr/src/ability_record.cpp | 5 ++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/frameworks/native/appkit/ability_runtime/service_extension_context.cpp b/frameworks/native/appkit/ability_runtime/service_extension_context.cpp index 7f4d2de6ee..e3649d0694 100644 --- a/frameworks/native/appkit/ability_runtime/service_extension_context.cpp +++ b/frameworks/native/appkit/ability_runtime/service_extension_context.cpp @@ -125,8 +125,12 @@ ErrCode ServiceExtensionContext::ConnectAbility( ErrCode ServiceExtensionContext::StartAbilityWithAccount(const AAFwk::Want &want, int32_t accountId) const { - TAG_LOGD(AAFwkTag::APPKIT, "%{public}s begin.", __func__); - TAG_LOGI(AAFwkTag::APPKIT, "%{public}d accountId:", accountId); + std::string callerName = ""; + if (GetAbilityInfo() != nullptr) { + callerName = GetAbilityInfo()->name; + } + TAG_LOGI(AAFwkTag::APPKIT, "accountId: %{public}d, ability: %{public}s, caller: %{public}s", + accountId, want.GetElement().GetURI().c_str(), callerName.c_str()); (const_cast(want)).SetParam(START_ABILITY_TYPE, true); ErrCode err = AAFwk::AbilityManagerClient::GetInstance()->StartAbility( want, token_, ILLEGAL_REQUEST_CODE, accountId); diff --git a/services/abilitymgr/src/ability_record.cpp b/services/abilitymgr/src/ability_record.cpp index f29aba0201..a29207cc84 100644 --- a/services/abilitymgr/src/ability_record.cpp +++ b/services/abilitymgr/src/ability_record.cpp @@ -201,9 +201,12 @@ std::shared_ptr Token::GetAbilityRecordByToken(const sptr theToken = iface_cast(token); if (!theToken) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "Input token iface_cast error."); return nullptr; } - if (theToken->GetDescriptor() != u"ohos.aafwk.AbilityToken") { + std::u16string castDescriptor = theToken->GetDescriptor(); + if (castDescriptor != u"ohos.aafwk.AbilityToken") { + TAG_LOGE(AAFwkTag::ABILITYMGR, "Input token iface_cast error:%{public}s.", Str16ToStr8(castDescriptor).c_str()); return nullptr; } From 3e7e6a6ce0eee8bf75b67ac8ecf02c4be68335c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=AE=B5=E5=97=A3=E9=92=8A?= Date: Sat, 18 May 2024 17:39:19 +0800 Subject: [PATCH 101/174] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=81=97=E6=BC=8F?= =?UTF-8?q?=E9=97=AE=E9=A2=982?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 段嗣钊 Change-Id: I7d20165c56cdd191f98b11a9dbb2242eb40967ac --- services/uripermmgr/src/uri_permission_manager_stub_impl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/uripermmgr/src/uri_permission_manager_stub_impl.cpp b/services/uripermmgr/src/uri_permission_manager_stub_impl.cpp index 86aa481eed..c66e115599 100644 --- a/services/uripermmgr/src/uri_permission_manager_stub_impl.cpp +++ b/services/uripermmgr/src/uri_permission_manager_stub_impl.cpp @@ -772,7 +772,7 @@ int UriPermissionManagerStubImpl::GrantUriPermissionFor2In1Inner(const std::vect } } if (!otherVec.empty()) { - auto ret = GrantUriPermissionInner(otherVec, flag, targetBundleName, appIndex, initiatorTokenId); + auto ret = GrantUriPermissionInner(otherVec, flag, targetBundleName, appIndex, initiatorTokenId, abilityId); if (docsVec.empty()) { return ret; } From 9a9c6c9fdc3a11c5fb2a3e9a591e70b3dd8fd317 Mon Sep 17 00:00:00 2001 From: mashaohua7 Date: Sat, 18 May 2024 18:20:23 +0800 Subject: [PATCH 102/174] =?UTF-8?q?=E9=80=9A=E8=BF=87bundlename=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E8=BF=90=E8=A1=8C=E6=97=B6=E5=BA=94=E7=94=A8=E5=88=86?= =?UTF-8?q?=E8=BA=AB=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: mashaohua7 --- .../app/js_app_manager/js_app_manager.cpp | 24 +++++++++++-------- .../js_app_manager/js_app_manager_utils.cpp | 1 - .../include/appmgr/app_mgr_interface.h | 2 +- .../include/appmgr/running_multi_info.h | 2 +- .../src/appmgr/running_multi_info.cpp | 12 ++++------ services/appmgr/src/app_mgr_service.cpp | 8 ++++++- services/appmgr/src/app_mgr_service_inner.cpp | 6 ++--- 7 files changed, 31 insertions(+), 24 deletions(-) diff --git a/frameworks/js/napi/app/js_app_manager/js_app_manager.cpp b/frameworks/js/napi/app/js_app_manager/js_app_manager.cpp index 2bea911451..db9a5fdaa4 100644 --- a/frameworks/js/napi/app/js_app_manager/js_app_manager.cpp +++ b/frameworks/js/napi/app/js_app_manager/js_app_manager.cpp @@ -665,25 +665,29 @@ private: ThrowInvalidParamError(env, "Parse param bundleName failed, must be a string"); return CreateJsUndefined(env); } - NapiAsyncTask::CompleteCallback complete = - [appManager = appManager_, bundleName](napi_env env, NapiAsyncTask &task, int32_t status) { + auto info = std::make_shared(); + auto innerErrorCode = std::make_shared(ERR_OK); + NapiAsyncTask::ExecuteCallback execute = + [appManager = appManager_, bundleName, innerErrorCode, info]() { if (appManager == nullptr) { TAG_LOGW(AAFwkTag::APPMGR, "appManager nullptr"); - task.Reject(env, CreateJsError(env, AbilityErrorCode::ERROR_CODE_INNER)); + *innerErrorCode = static_cast(AbilityErrorCode::ERROR_CODE_INNER); return; } - RunningMultiAppInfo info; - auto ret = appManager->GetRunningMultiAppInfoByBundleName(bundleName, info); - if (ret == 0) { - task.ResolveWithNoError(env, CreateJsRunningMultiAppInfo(env, info)); + *innerErrorCode = appManager->GetRunningMultiAppInfoByBundleName(bundleName, *info); + }; + NapiAsyncTask::CompleteCallback complete = + [innerErrorCode, info](napi_env env, NapiAsyncTask &task, int32_t status) { + if (*innerErrorCode == ERR_OK) { + task.ResolveWithNoError(env, CreateJsRunningMultiAppInfo(env, *info)); } else { - task.Reject(env, CreateJsError(env, GetJsErrorCodeByNativeError(ret))); + task.Reject(env, CreateJsErrorByNativeErr(env, *innerErrorCode)); } }; napi_value lastParam = nullptr; napi_value result = nullptr; - NapiAsyncTask::Schedule("JSAppManager::OnGetRunningMultiAppInfo", - env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result)); + NapiAsyncTask::ScheduleHighQos("JSAppManager::OnGetRunningMultiAppInfo", + env, CreateAsyncTaskWithLastParam(env, lastParam, std::move(execute), std::move(complete), &result)); return result; } diff --git a/frameworks/js/napi/app/js_app_manager/js_app_manager_utils.cpp b/frameworks/js/napi/app/js_app_manager/js_app_manager_utils.cpp index 6580d0fb23..6ea784dc13 100644 --- a/frameworks/js/napi/app/js_app_manager/js_app_manager_utils.cpp +++ b/frameworks/js/napi/app/js_app_manager/js_app_manager_utils.cpp @@ -160,7 +160,6 @@ napi_value CreateJsRunningMultiAppInfo(napi_env env, const RunningMultiAppInfo & } napi_set_named_property(env, object, "bundleName", CreateJsValue(env, info.bundleName)); napi_set_named_property(env, object, "mode", CreateJsValue(env, info.mode)); - napi_set_named_property(env, object, "runningMultiInstances", CreateNativeArray(env, info.runningMultiInstances)); napi_set_named_property(env, object, "runningAppClones", CreateJsRunningAppCloneArray(env, info.runningAppClones)); return object; diff --git a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_interface.h b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_interface.h index 1cc14b9f50..04beafdb91 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_interface.h +++ b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_interface.h @@ -148,7 +148,7 @@ public: * GetRunningMultiAppInfoByBundleName, call GetRunningMultiAppInfoByBundleName() through proxy project. * Obtains information about multiapp that are running on the device. * - * @param bundlename, input. + * @param bundlename, bundle name in Application record. * @param info, output multiapp information. * @return ERR_OK ,return back success,others fail. */ diff --git a/interfaces/inner_api/app_manager/include/appmgr/running_multi_info.h b/interfaces/inner_api/app_manager/include/appmgr/running_multi_info.h index 6ab034eef3..954c4cd109 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/running_multi_info.h +++ b/interfaces/inner_api/app_manager/include/appmgr/running_multi_info.h @@ -25,6 +25,7 @@ namespace OHOS { namespace AppExecFwk { +const int32_t MAX_CLONE_APP_NUM = 128; struct RunningAppClone { int32_t appCloneIndex; int32_t uid; @@ -34,7 +35,6 @@ struct RunningAppClone { struct RunningMultiAppInfo : public Parcelable { std::string bundleName; int32_t mode; - std::vector runningMultiInstances; std::vector runningAppClones; bool ReadFromParcel(Parcel &parcel); diff --git a/interfaces/inner_api/app_manager/src/appmgr/running_multi_info.cpp b/interfaces/inner_api/app_manager/src/appmgr/running_multi_info.cpp index ed56751ee8..8dce606ed7 100644 --- a/interfaces/inner_api/app_manager/src/appmgr/running_multi_info.cpp +++ b/interfaces/inner_api/app_manager/src/appmgr/running_multi_info.cpp @@ -28,12 +28,11 @@ bool RunningMultiAppInfo::ReadFromParcel(Parcel &parcel) { bundleName = Str16ToStr8(parcel.ReadString16()); mode = parcel.ReadInt32(); - if (!parcel.ReadStringVector(&runningMultiInstances)) { - TAG_LOGE(AAFwkTag::APPMGR, "read runningMultiInstances failed."); - return false; - } int32_t runningAppClonesSize; READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, runningAppClonesSize); + if(runningAppClonesSize > MAX_CLONE_APP_NUM) { + return false; + } for (auto i = 0; i < runningAppClonesSize; i++) { RunningAppClone clone; clone.appCloneIndex = parcel.ReadInt32(); @@ -59,11 +58,10 @@ bool RunningMultiAppInfo::Marshalling(Parcel &parcel) const { WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(bundleName)); WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, mode); - if (!parcel.WriteStringVector(runningMultiInstances)) { - TAG_LOGE(AAFwkTag::APPMGR, "write runningMultiInstances failed."); + WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, runningAppClones.size()); + if(runningAppClones.size() > MAX_CLONE_APP_NUM) { return false; } - WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, runningAppClones.size()); for (auto &clone : runningAppClones) { WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, clone.appCloneIndex); WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, clone.uid); diff --git a/services/appmgr/src/app_mgr_service.cpp b/services/appmgr/src/app_mgr_service.cpp index 877b567d6a..c02618a4be 100644 --- a/services/appmgr/src/app_mgr_service.cpp +++ b/services/appmgr/src/app_mgr_service.cpp @@ -397,7 +397,13 @@ int32_t AppMgrService::GetRunningMultiAppInfoByBundleName(const std::string &bun if (!IsReady()) { return ERR_INVALID_OPERATION; } - bool isCallingPermission = AAFwk::PermissionVerification::GetInstance()->VerifyRunningInfoPerm(); + + if (!PermissionVerification::GetInstance()->JudgeCallerIsAllowedToUseSystemAPI()) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "The caller is not system-app, can not use system-api"); + return ERR_INVALID_OPERATION; + } + + bool isCallingPermission = AAFwk::PermissionVerification::GetInstance()->VerifyRunningInfoPerm() && GetInstance()->IsSACall() &&; if (!isCallingPermission) { TAG_LOGE(AAFwkTag::APPMGR, "GetRunningMultiAppInfoByBundleName, Permission verification failed."); return ERR_PERMISSION_DENIED; diff --git a/services/appmgr/src/app_mgr_service_inner.cpp b/services/appmgr/src/app_mgr_service_inner.cpp index 82ff00dff6..0a21fc26bf 100644 --- a/services/appmgr/src/app_mgr_service_inner.cpp +++ b/services/appmgr/src/app_mgr_service_inner.cpp @@ -1457,16 +1457,16 @@ void AppMgrServiceInner::GetRunningCloneAppInfo(const std::shared_ptr(MultiAppModeType::APP_CLONE)) { - auto childAppRecordMap = appRecord->GetChildAppRecordMap(); size_t index = 0; for (; index < info.runningAppClones.size(); index++) { if (info.runningAppClones[index].appCloneIndex == appRecord->GetAppIndex()) { break; } } + auto childProcessRecordMap = appRecord->GetChildProcessRecordMap(); if (index < info.runningAppClones.size()) { info.runningAppClones[index].pids.emplace_back(PriorityObject->GetPid()); - for (auto it : childAppRecordMap) { + for (auto it : childProcessRecordMap) { info.runningAppClones[index].pids.emplace_back(it.first); } } else { @@ -1474,7 +1474,7 @@ void AppMgrServiceInner::GetRunningCloneAppInfo(const std::shared_ptrGetAppIndex(); cloneInfo.uid = appRecord->GetUid(); cloneInfo.pids.emplace_back(PriorityObject->GetPid()); - for (auto it : childAppRecordMap) { + for (auto it : childProcessRecordMap) { cloneInfo.pids.emplace_back(it.first); } info.runningAppClones.emplace_back(cloneInfo); From e2b4a0e69ba0049fb8ada588d2c3becec83f0674 Mon Sep 17 00:00:00 2001 From: liuzongze Date: Fri, 17 May 2024 14:54:27 +0800 Subject: [PATCH 103/174] =?UTF-8?q?=E5=90=AF=E5=8A=A8=E6=A1=86=E6=9E=B6abi?= =?UTF-8?q?lityStageContext=20fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liuzongze Change-Id: Ib5f5e1c0caf87841f7891cc7941a75f5de32b129 --- .../ability_runtime/app/ability_stage.cpp | 3 +- .../ability_runtime/app/js_ability_stage.cpp | 92 +++++++++++-------- .../native/appkit/app/ohos_application.cpp | 2 +- .../ability_runtime/app/ability_stage.h | 3 +- .../ability_runtime/app/js_ability_stage.h | 5 +- .../ability_stage_test.cpp | 3 +- 6 files changed, 66 insertions(+), 42 deletions(-) diff --git a/frameworks/native/appkit/ability_runtime/app/ability_stage.cpp b/frameworks/native/appkit/ability_runtime/app/ability_stage.cpp index b1ef8c3682..59e91cb145 100644 --- a/frameworks/native/appkit/ability_runtime/app/ability_stage.cpp +++ b/frameworks/native/appkit/ability_runtime/app/ability_stage.cpp @@ -117,7 +117,8 @@ void AbilityStage::OnMemoryLevel(int level) TAG_LOGD(AAFwkTag::APPKIT, "%{public}s called.", __func__); } -int32_t AbilityStage::RunAutoStartupTask(const std::function &callback, bool &isAsyncCallback) +int32_t AbilityStage::RunAutoStartupTask(const std::function &callback, bool &isAsyncCallback, + const std::shared_ptr &stageContext) { TAG_LOGD(AAFwkTag::APPKIT, "called"); isAsyncCallback = false; diff --git a/frameworks/native/appkit/ability_runtime/app/js_ability_stage.cpp b/frameworks/native/appkit/ability_runtime/app/js_ability_stage.cpp index 099fa9b80d..84fa376cf2 100644 --- a/frameworks/native/appkit/ability_runtime/app/js_ability_stage.cpp +++ b/frameworks/native/appkit/ability_runtime/app/js_ability_stage.cpp @@ -169,39 +169,8 @@ void JsAbilityStage::Init(const std::shared_ptr &context, TAG_LOGE(AAFwkTag::APPKIT, "stage is nullptr"); return; } - - HandleScope handleScope(jsRuntime_); - auto env = jsRuntime_.GetNapiEnv(); - - napi_value obj = jsAbilityStageObj_->GetNapiValue(); - if (!CheckTypeForNapiValue(env, obj, napi_object)) { - TAG_LOGE(AAFwkTag::APPKIT, "Failed to get AbilityStage object"); - return; - } - - napi_value contextObj = CreateJsAbilityStageContext(env, context, nullptr, nullptr); - shellContextRef_ = JsRuntime::LoadSystemModuleByEngine(env, "application.AbilityStageContext", &contextObj, 1); - if (shellContextRef_ == nullptr) { - TAG_LOGE(AAFwkTag::APPKIT, "Failed to get LoadSystemModuleByEngine"); - return; - } - contextObj = shellContextRef_->GetNapiValue(); - if (!CheckTypeForNapiValue(env, contextObj, napi_object)) { - TAG_LOGE(AAFwkTag::APPKIT, "Failed to get context native object"); - return; - } - auto workContext = new (std::nothrow) std::weak_ptr(context); - napi_coerce_to_native_binding_object( - env, contextObj, DetachCallbackFunc, AttachAbilityStageContext, workContext, nullptr); - context->Bind(jsRuntime_, shellContextRef_.get()); - napi_set_named_property(env, obj, "context", contextObj); - TAG_LOGD(AAFwkTag::APPKIT, "Set ability stage context"); - napi_wrap(env, contextObj, workContext, - [](napi_env, void* data, void*) { - TAG_LOGD(AAFwkTag::APPKIT, "Finalizer for weak_ptr ability stage context is called"); - delete static_cast*>(data); - }, - nullptr, nullptr); + + SetJsAbilityStage(context); } void JsAbilityStage::OnCreate(const AAFwk::Want &want) const @@ -383,7 +352,8 @@ void JsAbilityStage::OnMemoryLevel(int32_t level) TAG_LOGD(AAFwkTag::APPKIT, "end"); } -int32_t JsAbilityStage::RunAutoStartupTask(const std::function &callback, bool &isAsyncCallback) +int32_t JsAbilityStage::RunAutoStartupTask(const std::function &callback, bool &isAsyncCallback, + const std::shared_ptr &stageContext) { TAG_LOGD(AAFwkTag::APPKIT, "called"); isAsyncCallback = false; @@ -397,12 +367,13 @@ int32_t JsAbilityStage::RunAutoStartupTask(const std::function &callback TAG_LOGE(AAFwkTag::APPKIT, "hapModuleInfo invalid."); return ERR_INVALID_VALUE; } - if (hapModuleInfo->moduleType != AppExecFwk::ModuleType::ENTRY || - hapModuleInfo->appStartup.empty()) { + if (hapModuleInfo->moduleType != AppExecFwk::ModuleType::ENTRY || hapModuleInfo->appStartup.empty()) { TAG_LOGD(AAFwkTag::APPKIT, "not entry module or appStartup not exist."); return ERR_INVALID_VALUE; } - + if (!shellContextRef_) { + SetJsAbilityStage(stageContext); + } std::vector jsStartupTasks; int32_t result = RegisterStartupTaskFromProfile(jsStartupTasks); if (result != ERR_OK) { @@ -803,5 +774,52 @@ bool JsAbilityStage::GetResFromResMgr( profileInfo.emplace_back(profile); return true; } + +void JsAbilityStage::SetJsAbilityStage(const std::shared_ptr &context) +{ + if (!context) { + TAG_LOGE(AAFwkTag::APPKIT, "context is nullptr"); + return; + } + + HandleScope handleScope(jsRuntime_); + auto env = jsRuntime_.GetNapiEnv(); + + napi_value obj = nullptr; + if (jsAbilityStageObj_) { + obj = jsAbilityStageObj_->GetNapiValue(); + if (!CheckTypeForNapiValue(env, obj, napi_object)) { + TAG_LOGE(AAFwkTag::APPKIT, "Failed to get AbilityStage object"); + return; + } + } + + napi_value contextObj = CreateJsAbilityStageContext(env, context, nullptr, nullptr); + shellContextRef_ = JsRuntime::LoadSystemModuleByEngine(env, "application.AbilityStageContext", &contextObj, 1); + if (shellContextRef_ == nullptr) { + TAG_LOGE(AAFwkTag::APPKIT, "Failed to get LoadSystemModuleByEngine"); + return; + } + contextObj = shellContextRef_->GetNapiValue(); + if (!CheckTypeForNapiValue(env, contextObj, napi_object)) { + TAG_LOGE(AAFwkTag::APPKIT, "Failed to get context native object"); + return; + } + auto workContext = new (std::nothrow) std::weak_ptr(context); + napi_coerce_to_native_binding_object( + env, contextObj, DetachCallbackFunc, AttachAbilityStageContext, workContext, nullptr); + context->Bind(jsRuntime_, shellContextRef_.get()); + + if (obj != nullptr) { + napi_set_named_property(env, obj, "context", contextObj); + } + TAG_LOGD(AAFwkTag::APPKIT, "Set ability stage context"); + napi_wrap(env, contextObj, workContext, + [](napi_env, void* data, void*) { + TAG_LOGD(AAFwkTag::APPKIT, "Finalizer for weak_ptr ability stage context is called"); + delete static_cast*>(data); + }, + nullptr, nullptr); +} } // namespace AbilityRuntime } // namespace OHOS diff --git a/frameworks/native/appkit/app/ohos_application.cpp b/frameworks/native/appkit/app/ohos_application.cpp index 77d7dce47e..262301b742 100644 --- a/frameworks/native/appkit/app/ohos_application.cpp +++ b/frameworks/native/appkit/app/ohos_application.cpp @@ -676,7 +676,7 @@ std::shared_ptr OHOSApplication::AddAbilityStage( ohosApplication->AutoStartupDone(abilityRecord, abilityStage, moduleName); callback(abilityStage->GetContext()); }; - abilityStage->RunAutoStartupTask(autoStartupCallback, isAsyncCallback); + abilityStage->RunAutoStartupTask(autoStartupCallback, isAsyncCallback, stageContext); if (isAsyncCallback) { TAG_LOGI(AAFwkTag::APPKIT, "waiting for startup"); return nullptr; diff --git a/interfaces/kits/native/appkit/ability_runtime/app/ability_stage.h b/interfaces/kits/native/appkit/ability_runtime/app/ability_stage.h index b45048e785..2f09864779 100644 --- a/interfaces/kits/native/appkit/ability_runtime/app/ability_stage.h +++ b/interfaces/kits/native/appkit/ability_runtime/app/ability_stage.h @@ -59,7 +59,8 @@ public: bool ContainsAbility() const; virtual void OnConfigurationUpdated(const AppExecFwk::Configuration& configuration); virtual void OnMemoryLevel(int level); - virtual int32_t RunAutoStartupTask(const std::function &callback, bool &isAsyncCallback); + virtual int32_t RunAutoStartupTask(const std::function &callback, bool &isAsyncCallback, + const std::shared_ptr &stageContext); private: friend class JsAbilityStage; diff --git a/interfaces/kits/native/appkit/ability_runtime/app/js_ability_stage.h b/interfaces/kits/native/appkit/ability_runtime/app/js_ability_stage.h index 60f20dba49..7dd7860dfe 100644 --- a/interfaces/kits/native/appkit/ability_runtime/app/js_ability_stage.h +++ b/interfaces/kits/native/appkit/ability_runtime/app/js_ability_stage.h @@ -56,7 +56,8 @@ public: void OnMemoryLevel(int32_t level) override; - int32_t RunAutoStartupTask(const std::function &callback, bool &isAsyncCallback) override; + int32_t RunAutoStartupTask(const std::function &callback, bool &isAsyncCallback, + const std::shared_ptr &stageContext) override; private: napi_value CallObjectMethod(const char* name, napi_value const * argv = nullptr, size_t argc = 0); @@ -87,6 +88,8 @@ private: bool IsFileExisted(const std::string &filePath); bool TransformFileToJsonString(const std::string &resPath, std::string &profile); + + void SetJsAbilityStage(const std::shared_ptr &context); JsRuntime& jsRuntime_; std::shared_ptr jsAbilityStageObj_; diff --git a/test/unittest/frameworks_kits_appkit_native_test/ability_stage_test.cpp b/test/unittest/frameworks_kits_appkit_native_test/ability_stage_test.cpp index 0cb4114d62..9d2d792083 100644 --- a/test/unittest/frameworks_kits_appkit_native_test/ability_stage_test.cpp +++ b/test/unittest/frameworks_kits_appkit_native_test/ability_stage_test.cpp @@ -343,7 +343,8 @@ HWTEST_F(AbilityStageTest, AppExecFwk_AbilityStage_RunAutoStartupTask_001, Funct GTEST_LOG_(INFO) << "AppExecFwk_AbilityStage_RunAutoStartupTask_001 start"; std::function callback; bool isAsyncCallback; - EXPECT_TRUE(abilityStage_->RunAutoStartupTask(callback, isAsyncCallback) == ERR_OK); + std::shared_ptr context = abilityStage_->GetContext(); + EXPECT_TRUE(abilityStage_->RunAutoStartupTask(callback, isAsyncCallback, context) == ERR_OK); GTEST_LOG_(INFO) << "AppExecFwk_AbilityStage_RunAutoStartupTask_001 end"; } } // namespace AppExecFwk From 4856119416369f4b717acc86f64f96e443160ddd Mon Sep 17 00:00:00 2001 From: xinking129 Date: Sat, 18 May 2024 21:19:17 +0800 Subject: [PATCH 104/174] fix autofill crash Signed-off-by: xinking129 --- .../auto_fill_manager/src/auto_fill_extension_callback.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/inner_api/auto_fill_manager/src/auto_fill_extension_callback.cpp b/interfaces/inner_api/auto_fill_manager/src/auto_fill_extension_callback.cpp index abe2d0609e..b2b8820b40 100644 --- a/interfaces/inner_api/auto_fill_manager/src/auto_fill_extension_callback.cpp +++ b/interfaces/inner_api/auto_fill_manager/src/auto_fill_extension_callback.cpp @@ -276,12 +276,12 @@ void AutoFillExtensionCallback::CloseModalUIExtension() return; } - AutoFillManager::GetInstance().RemoveAutoFillExtensionProxy(uiContent_); if (autoFillWindowType_ == AutoFill::AutoFillWindowType::POPUP_WINDOW) { uiContent_->DestroyCustomPopupUIExtension(sessionId_); } else if (autoFillWindowType_ == AutoFill::AutoFillWindowType::MODAL_WINDOW) { uiContent_->CloseModalUIExtension(sessionId_); } + AutoFillManager::GetInstance().RemoveAutoFillExtensionProxy(uiContent_); uiContent_ = nullptr; } } // namespace AbilityRuntime From 7b347790d5e497fe6ce717ad66eb730671616b16 Mon Sep 17 00:00:00 2001 From: zhangyafei-echo Date: Sat, 18 May 2024 19:55:06 +0800 Subject: [PATCH 105/174] [bugfix]uiextension bugfix. Signed-off-by: zhangyafei-echo Change-Id: Iaebd5915dc21f4d1c5f4423a8222bf7ad43a1e00 --- services/abilitymgr/src/ability_connect_manager.cpp | 2 ++ services/abilitymgr/src/ability_record.cpp | 4 +++- services/abilitymgr/src/extension_record_manager.cpp | 5 +++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/services/abilitymgr/src/ability_connect_manager.cpp b/services/abilitymgr/src/ability_connect_manager.cpp index 50edb923bc..afb59c93fc 100644 --- a/services/abilitymgr/src/ability_connect_manager.cpp +++ b/services/abilitymgr/src/ability_connect_manager.cpp @@ -823,6 +823,8 @@ int AbilityConnectManager::AttachAbilityThreadLocked( sceneBoardTokenId_ = abilityRecord->GetAbilityInfo().applicationInfo.accessTokenId; } abilityRecord->SetScheduler(scheduler); + abilityRecord->RemoveSpecifiedWantParam(UIEXTENSION_ABILITY_ID); + abilityRecord->RemoveSpecifiedWantParam(UIEXTENSION_ROOT_HOST_PID); if (IsUIExtensionAbility(abilityRecord) && !abilityRecord->IsCreateByConnect() && !abilityRecord->GetWant().GetBoolParam(IS_PRELOAD_UIEXTENSION_ABILITY, false)) { DelayedSingleton::GetInstance()->MoveToForeground(token); diff --git a/services/abilitymgr/src/ability_record.cpp b/services/abilitymgr/src/ability_record.cpp index f29aba0201..c0d30546fd 100644 --- a/services/abilitymgr/src/ability_record.cpp +++ b/services/abilitymgr/src/ability_record.cpp @@ -1903,7 +1903,9 @@ void AbilityRecord::RemoveConnectRecordFromList(const std::shared_ptr &callerToken, int requestCode, std::string srcAbilityId, diff --git a/services/abilitymgr/src/extension_record_manager.cpp b/services/abilitymgr/src/extension_record_manager.cpp index 5a56591c8e..a8216c3802 100644 --- a/services/abilitymgr/src/extension_record_manager.cpp +++ b/services/abilitymgr/src/extension_record_manager.cpp @@ -448,6 +448,11 @@ sptr ExtensionRecordManager::GetRootCallerTokenLocked(int32_t ext it->second->SetRootCallerToken(callerToken); return callerToken; } + // If caller extension record id is same with current, need terminate, prevent possible stack-overflow. + if (callerAbilityRecord->GetUIExtensionAbilityId() == extensionRecordId) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "Invalid id: %{public}d, same with caller.", extensionRecordId); + return nullptr; + } rootCallerToken = GetRootCallerTokenLocked(callerAbilityRecord->GetUIExtensionAbilityId()); TAG_LOGD(AAFwkTag::ABILITYMGR, "update rootCallerToken, id: %{public}d.", extensionRecordId); it->second->SetRootCallerToken(rootCallerToken); From 90cc0fb93a9d976e9f71e0f9f1d3f40ee9982231 Mon Sep 17 00:00:00 2001 From: lida <1960916211@qq.com> Date: Fri, 17 May 2024 16:33:59 +0800 Subject: [PATCH 106/174] =?UTF-8?q?=E6=8F=90=E4=BE=9B=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E5=88=86=E8=BA=AB=E5=BA=94=E7=94=A8index=E7=9A=84=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lida <1960916211@qq.com> --- .../application_context.js | 4 +++ .../ability_business_error.cpp | 2 ++ .../context/application_context.cpp | 25 ++++++++++++++++++ .../context/js_application_context_utils.cpp | 26 +++++++++++++++++++ frameworks/native/appkit/app/main_thread.cpp | 3 +++ .../ability_business_error.h | 3 +++ .../context/application_context.h | 6 +++++ .../context/js_application_context_utils.h | 2 ++ 8 files changed, 71 insertions(+) diff --git a/frameworks/js/napi/app/application_context/application_context.js b/frameworks/js/napi/app/application_context/application_context.js index 885d37f8e8..5c12391586 100644 --- a/frameworks/js/napi/app/application_context/application_context.js +++ b/frameworks/js/napi/app/application_context/application_context.js @@ -189,6 +189,10 @@ class ApplicationContext { return this.__context_impl__.setSupportedProcessCache(isSupport); } + getCurrentAppCloneIndex(){ + return this.__context_impl__.getCurrentAppCloneIndex() + } + set area(mode) { return this.__context_impl__.switchArea(mode); } diff --git a/frameworks/native/ability/native/ability_business_error/ability_business_error.cpp b/frameworks/native/ability/native/ability_business_error/ability_business_error.cpp index 822b4fe38e..83b96d2eca 100644 --- a/frameworks/native/ability/native/ability_business_error/ability_business_error.cpp +++ b/frameworks/native/ability/native/ability_business_error/ability_business_error.cpp @@ -80,6 +80,7 @@ constexpr const char* ERROR_MSG_NO_RESIDENT_PERMISSION = "The caller application can only set the resident status of the configured process."; constexpr const char* ERROR_MSG_APP_CLONE_INDEX_INVALID = "The target app clone with the specified index does not exist."; +constexpr const char* ERROR_MSG_NOT_APP_CLONE = "The target app is not Clone."; // follow ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST of appexecfwk_errors.h in bundle_framework constexpr int32_t ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST = 8521220; @@ -134,6 +135,7 @@ static std::unordered_map ERR_CODE_MAP = { { AbilityErrorCode::ERROR_CODE_SET_SUPPORTED_PROCESS_CACHE_AGAIN, ERROR_MSG_SET_SUPPORTED_PROCESS_CACHE_AGAIN }, { AbilityErrorCode::ERROR_CODE_NO_RESIDENT_PERMISSION, ERROR_MSG_NO_RESIDENT_PERMISSION }, { AbilityErrorCode::ERROR_APP_CLONE_INDEX_INVALID, ERROR_MSG_APP_CLONE_INDEX_INVALID }, + { AbilityErrorCode::ERROR_NOT_APP_CLONE, ERROR_MSG_NOT_APP_CLONE }, }; static std::unordered_map INNER_TO_JS_ERROR_CODE_MAP { diff --git a/frameworks/native/appkit/ability_runtime/context/application_context.cpp b/frameworks/native/appkit/ability_runtime/context/application_context.cpp index 29980816e1..c87c71944c 100644 --- a/frameworks/native/appkit/ability_runtime/context/application_context.cpp +++ b/frameworks/native/appkit/ability_runtime/context/application_context.cpp @@ -544,6 +544,19 @@ std::string ApplicationContext::GetAppRunningUniqueId() const return appRunningUniqueId_; } +int32_t ApplicationContext::GetCurrentAppCloneIndex() +{ + TAG_LOGD(AAFwkTag::APPKIT, "getCurrentAppCloneIndex is %{public}d.", appIndex_); + return appIndex_; +} + +int32_t ApplicationContext::GetCurrentAppMode() +{ + TAG_LOGD(AAFwkTag::APPKIT, "getCurrentMode is %{public}d.", appMode_); + return appMode_; +} + + void ApplicationContext::SetAppRunningUniqueId(const std::string &appRunningUniqueId) { TAG_LOGD(AAFwkTag::APPKIT, "SetAppRunningUniqueId is %{public}s.", appRunningUniqueId.c_str()); @@ -558,5 +571,17 @@ int32_t ApplicationContext::SetSupportedProcessCacheSelf(bool isSupport) TAG_LOGE(AAFwkTag::APPKIT, "contextImpl_ is nullptr."); return ERR_INVALID_VALUE; } + +void ApplicationContext::SetCurrentAppCloneIndex(int32_t appIndex) +{ + TAG_LOGD(AAFwkTag::APPKIT, "setCurrentAppCloneIndex is %{public}d.", appIndex); + appIndex_ = appIndex; +} + +void ApplicationContext::SetCurrentAppMode(int32_t appMode) +{ + TAG_LOGD(AAFwkTag::APPKIT, "setCurrentAppMode is %{public}d.", appMode); + appMode_ = appMode; +} } // namespace AbilityRuntime } // namespace OHOS diff --git a/frameworks/native/appkit/ability_runtime/context/js_application_context_utils.cpp b/frameworks/native/appkit/ability_runtime/context/js_application_context_utils.cpp index 0a6fbedf1a..c18df7372d 100644 --- a/frameworks/native/appkit/ability_runtime/context/js_application_context_utils.cpp +++ b/frameworks/native/appkit/ability_runtime/context/js_application_context_utils.cpp @@ -22,6 +22,7 @@ #include "ability_manager_interface.h" #include "ability_runtime_error_util.h" #include "application_context.h" +#include "application_info.h" #include "application_context_manager.h" #include "hilog_tag_wrapper.h" #include "hilog_wrapper.h" @@ -801,6 +802,29 @@ napi_value JsApplicationContextUtils::OnGetRunningProcessInformation(napi_env en return result; } +napi_value JsApplicationContextUtils::GetCurrentAppCloneIndex(napi_env env, napi_callback_info info) +{ + GET_NAPI_INFO_WITH_NAME_AND_CALL(env, info, JsApplicationContextUtils, + OnGetCurrentAppCloneIndex, APPLICATION_CONTEXT_NAME); +} + +napi_value JsApplicationContextUtils::OnGetCurrentAppCloneIndex(napi_env env, NapiCallbackInfo& info) +{ + TAG_LOGD(AAFwkTag::APPKIT, "Get App Index"); + auto context = applicationContext_.lock(); + if (context == nullptr) { + TAG_LOGE(AAFwkTag::APPKIT, "context is nullptr."); + ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_CONTEXT); + return CreateJsUndefined(env); + } + if (context->GetCurrentAppMode() != static_cast(AppExecFwk::MultiAppModeType::APP_CLONE)) { + ThrowError(env, AbilityErrorCode::ERROR_NOT_APP_CLONE); + return CreateJsUndefined(env); + } + int32_t appIndex = context->GetCurrentAppCloneIndex(); + return CreateJsValue(env, appIndex); +} + void JsApplicationContextUtils::Finalizer(napi_env env, void *data, void *hint) { TAG_LOGD(AAFwkTag::APPKIT, "called"); @@ -1492,6 +1516,8 @@ void JsApplicationContextUtils::BindNativeApplicationContext(napi_env env, napi_ JsApplicationContextUtils::GetRunningProcessInformation); BindNativeFunction(env, object, "getRunningProcessInformation", MD_NAME, JsApplicationContextUtils::GetRunningProcessInformation); + BindNativeFunction(env, object, "getCurrentAppCloneIndex", MD_NAME, + JsApplicationContextUtils::GetCurrentAppCloneIndex); BindNativeFunction(env, object, "getGroupDir", MD_NAME, JsApplicationContextUtils::GetGroupDir); BindNativeFunction(env, object, "restartApp", MD_NAME, diff --git a/frameworks/native/appkit/app/main_thread.cpp b/frameworks/native/appkit/app/main_thread.cpp index c9b0018c9f..71ead2c6d1 100644 --- a/frameworks/native/appkit/app/main_thread.cpp +++ b/frameworks/native/appkit/app/main_thread.cpp @@ -1319,6 +1319,9 @@ void MainThread::HandleLaunchApplication(const AppLaunchData &appLaunchData, con contextImpl->SetApplicationInfo(std::make_shared(appInfo)); std::shared_ptr applicationContext = AbilityRuntime::ApplicationContext::GetInstance(); + int32_t appIndex = appLaunchData.GetAppIndex(); + applicationContext->SetCurrentAppCloneIndex(appIndex); + applicationContext->SetCurrentAppMode(static_cast(appInfo.multiAppMode.multiAppModeType)); applicationContext->AttachContextImpl(contextImpl); auto appRunningId = appLaunchData.GetAppRunningUniqueId(); applicationContext->SetAppRunningUniqueId(appRunningId); diff --git a/interfaces/kits/native/ability/native/ability_business_error/ability_business_error.h b/interfaces/kits/native/ability/native/ability_business_error/ability_business_error.h index 54d32e9f83..9a7f7c8e41 100644 --- a/interfaces/kits/native/ability/native/ability_business_error/ability_business_error.h +++ b/interfaces/kits/native/ability/native/ability_business_error/ability_business_error.h @@ -141,6 +141,9 @@ enum class AbilityErrorCode { // Ability already running. ERROR_ABILITY_ALREADY_RUNNING = 16000068, + // app is not Clone. + ERROR_NOT_APP_CLONE = 16000071, + // app clone index does not exist. ERROR_APP_CLONE_INDEX_INVALID = 16000073, diff --git a/interfaces/kits/native/appkit/ability_runtime/context/application_context.h b/interfaces/kits/native/appkit/ability_runtime/context/application_context.h index 42ed96ce9f..e7dd14c9cb 100644 --- a/interfaces/kits/native/appkit/ability_runtime/context/application_context.h +++ b/interfaces/kits/native/appkit/ability_runtime/context/application_context.h @@ -114,6 +114,10 @@ public: std::string GetAppRunningUniqueId() const; void SetAppRunningUniqueId(const std::string &appRunningUniqueId); int32_t SetSupportedProcessCacheSelf(bool isSupport); + int32_t GetCurrentAppCloneIndex(); + void SetCurrentAppCloneIndex(int32_t appIndex); + int32_t GetCurrentAppMode(); + void SetCurrentAppMode(int32_t appIndex); private: std::shared_ptr contextImpl_; static std::vector> callbacks_; @@ -125,6 +129,8 @@ private: bool applicationInfoUpdateFlag_ = false; AppConfigUpdateCallback appConfigChangeCallback_ = nullptr; std::string appRunningUniqueId_; + int32_t appIndex_ = 0; + int32_t appMode_ = 0; }; } // namespace AbilityRuntime } // namespace OHOS diff --git a/interfaces/kits/native/appkit/ability_runtime/context/js_application_context_utils.h b/interfaces/kits/native/appkit/ability_runtime/context/js_application_context_utils.h index f62cd7a7af..ca3bcd046d 100644 --- a/interfaces/kits/native/appkit/ability_runtime/context/js_application_context_utils.h +++ b/interfaces/kits/native/appkit/ability_runtime/context/js_application_context_utils.h @@ -98,6 +98,7 @@ public: napi_value OnRestartApp(napi_env env, NapiCallbackInfo& info); napi_value OnSetSupportedProcessCacheSelf(napi_env env, NapiCallbackInfo& info); napi_value OnPreloadUIExtensionAbility(napi_env env, NapiCallbackInfo& info); + napi_value OnGetCurrentAppCloneIndex(napi_env env, NapiCallbackInfo& info); static napi_value GetCacheDir(napi_env env, napi_callback_info info); static napi_value GetTempDir(napi_env env, napi_callback_info info); @@ -119,6 +120,7 @@ public: static napi_value RestartApp(napi_env env, napi_callback_info info); static napi_value SetSupportedProcessCacheSelf(napi_env env, napi_callback_info info); static napi_value PreloadUIExtensionAbility(napi_env env, napi_callback_info info); + static napi_value GetCurrentAppCloneIndex(napi_env env, napi_callback_info info); protected: std::weak_ptr applicationContext_; From 97c7a8dee07b3b971a65d933ff030e8fdce63473 Mon Sep 17 00:00:00 2001 From: mashaohua7 Date: Mon, 20 May 2024 00:54:23 +0000 Subject: [PATCH 107/174] update services/appmgr/src/app_mgr_service.cpp. Signed-off-by: mashaohua7 --- services/appmgr/src/app_mgr_service.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/appmgr/src/app_mgr_service.cpp b/services/appmgr/src/app_mgr_service.cpp index 4f1b9b7e0e..190477cf9c 100644 --- a/services/appmgr/src/app_mgr_service.cpp +++ b/services/appmgr/src/app_mgr_service.cpp @@ -403,7 +403,7 @@ int32_t AppMgrService::GetRunningMultiAppInfoByBundleName(const std::string &bun return ERR_INVALID_OPERATION; } - bool isCallingPermission = AAFwk::PermissionVerification::GetInstance()->VerifyRunningInfoPerm() && GetInstance()->IsSACall() &&; + bool isCallingPermission = AAFwk::PermissionVerification::GetInstance()->VerifyRunningInfoPerm(); if (!isCallingPermission) { TAG_LOGE(AAFwkTag::APPMGR, "GetRunningMultiAppInfoByBundleName, Permission verification failed."); return ERR_PERMISSION_DENIED; From b395547f01d1a07e144346c1a16252cafb930542 Mon Sep 17 00:00:00 2001 From: mashaohua7 Date: Mon, 20 May 2024 00:55:59 +0000 Subject: [PATCH 108/174] update frameworks/native/ability/native/ability_business_error/ability_business_error.cpp. Signed-off-by: mashaohua7 --- .../native/ability_business_error/ability_business_error.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/frameworks/native/ability/native/ability_business_error/ability_business_error.cpp b/frameworks/native/ability/native/ability_business_error/ability_business_error.cpp index b3df774a05..c54fe3cfa8 100644 --- a/frameworks/native/ability/native/ability_business_error/ability_business_error.cpp +++ b/frameworks/native/ability/native/ability_business_error/ability_business_error.cpp @@ -78,7 +78,6 @@ constexpr const char* ERROR_MSG_TARGET_BUNDLE_NOT_EXIST = "The target bundle doe constexpr const char* ERROR_MSG_SET_SUPPORTED_PROCESS_CACHE_AGAIN = "Can not set process cache state more than once."; constexpr const char* ERROR_MSG_NO_RESIDENT_PERMISSION = "The caller application can only set the resident status of the configured process."; -constexpr const char* ERROR_MSG_APP_TWIN_INDEX_INVALID = "The target app twin with the specified index does not exist."; constexpr const char* ERROR_MSG_MULTI_APP_NOT_SUPPORTED = "App clone or multi-instance is not supported."; constexpr const char* ERROR_MSG_APP_CLONE_INDEX_INVALID = "The target app clone with the specified index does not exist."; From f688a9e64fb7cba7598a6a2461351ecd749458b5 Mon Sep 17 00:00:00 2001 From: mashaohua7 Date: Mon, 20 May 2024 01:01:45 +0000 Subject: [PATCH 109/174] update frameworks/js/napi/app/js_app_manager/js_app_manager.cpp. Signed-off-by: mashaohua7 --- .../app/js_app_manager/js_app_manager.cpp | 23 ++++++++----------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/frameworks/js/napi/app/js_app_manager/js_app_manager.cpp b/frameworks/js/napi/app/js_app_manager/js_app_manager.cpp index db9a5fdaa4..e53019b5d8 100644 --- a/frameworks/js/napi/app/js_app_manager/js_app_manager.cpp +++ b/frameworks/js/napi/app/js_app_manager/js_app_manager.cpp @@ -1199,9 +1199,11 @@ napi_value JsAppManagerInit(napi_env env, napi_value exportObj) TAG_LOGW(AAFwkTag::APPMGR, "env or exportObj null"); return nullptr; } + std::unique_ptr jsAppManager = std::make_unique( GetAppManagerInstance(), GetAbilityManagerInstance()); napi_wrap(env, exportObj, jsAppManager.release(), JsAppManager::Finalizer, nullptr, nullptr); + napi_set_named_property(env, exportObj, "ApplicationState", ApplicationStateInit(env)); napi_set_named_property(env, exportObj, "ProcessState", ProcessStateInit(env)); napi_set_named_property(env, exportObj, "PreloadMode", PreloadModeInit(env)); @@ -1225,22 +1227,15 @@ napi_value JsAppManagerInit(napi_env env, napi_value exportObj) JsAppManager::KillProcessesByBundleName); BindNativeFunction(env, exportObj, "clearUpApplicationData", moduleName, JsAppManager::ClearUpApplicationData); - BindNativeFunction(env, exportObj, "getAppMemorySize", moduleName, - JsAppManager::GetAppMemorySize); - BindNativeFunction(env, exportObj, "isRamConstrainedDevice", moduleName, - JsAppManager::IsRamConstrainedDevice); - BindNativeFunction(env, exportObj, "isSharedBundleRunning", moduleName, - JsAppManager::IsSharedBundleRunning); - BindNativeFunction(env, exportObj, "getProcessMemoryByPid", moduleName, - JsAppManager::GetProcessMemoryByPid); + BindNativeFunction(env, exportObj, "getAppMemorySize", moduleName, JsAppManager::GetAppMemorySize); + BindNativeFunction(env, exportObj, "isRamConstrainedDevice", moduleName, JsAppManager::IsRamConstrainedDevice); + BindNativeFunction(env, exportObj, "isSharedBundleRunning", moduleName, JsAppManager::IsSharedBundleRunning); + BindNativeFunction(env, exportObj, "getProcessMemoryByPid", moduleName, JsAppManager::GetProcessMemoryByPid); BindNativeFunction(env, exportObj, "getRunningProcessInfoByBundleName", moduleName, JsAppManager::GetRunningProcessInfoByBundleName); - BindNativeFunction(env, exportObj, "getRunningMultiAppInfo", moduleName, - JsAppManager::GetRunningMultiAppInfo); - BindNativeFunction(env, exportObj, "isApplicationRunning", moduleName, - JsAppManager::IsApplicationRunning); - BindNativeFunction(env, exportObj, "preloadApplication", moduleName, - JsAppManager::PreloadApplication); + BindNativeFunction(env, exportObj, "getRunningMultiAppInfo", moduleName, JsAppManager::GetRunningMultiAppInfo); + BindNativeFunction(env, exportObj, "isApplicationRunning", moduleName, JsAppManager::IsApplicationRunning); + BindNativeFunction(env, exportObj, "preloadApplication", moduleName, JsAppManager::PreloadApplication); BindNativeFunction(env, exportObj, "getRunningProcessInformationByBundleType", moduleName, JsAppManager::GetRunningProcessInformationByBundleType); TAG_LOGD(AAFwkTag::APPMGR, "end"); From 78739117f4d987db743b479578eda0d5d59054b4 Mon Sep 17 00:00:00 2001 From: mashaohua7 Date: Mon, 20 May 2024 01:09:54 +0000 Subject: [PATCH 110/174] update frameworks/js/napi/app/js_app_manager/js_app_manager.cpp. Signed-off-by: mashaohua7 --- frameworks/js/napi/app/js_app_manager/js_app_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/js/napi/app/js_app_manager/js_app_manager.cpp b/frameworks/js/napi/app/js_app_manager/js_app_manager.cpp index e53019b5d8..9d1082f85f 100644 --- a/frameworks/js/napi/app/js_app_manager/js_app_manager.cpp +++ b/frameworks/js/napi/app/js_app_manager/js_app_manager.cpp @@ -675,7 +675,7 @@ private: return; } *innerErrorCode = appManager->GetRunningMultiAppInfoByBundleName(bundleName, *info); - }; + }; NapiAsyncTask::CompleteCallback complete = [innerErrorCode, info](napi_env env, NapiAsyncTask &task, int32_t status) { if (*innerErrorCode == ERR_OK) { From 9d25edf8bd8bbf72c0715b7ffe730dd37a520370 Mon Sep 17 00:00:00 2001 From: mashaohua7 Date: Mon, 20 May 2024 01:10:56 +0000 Subject: [PATCH 111/174] update interfaces/inner_api/app_manager/src/appmgr/running_multi_info.cpp. Signed-off-by: mashaohua7 --- .../inner_api/app_manager/src/appmgr/running_multi_info.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interfaces/inner_api/app_manager/src/appmgr/running_multi_info.cpp b/interfaces/inner_api/app_manager/src/appmgr/running_multi_info.cpp index 8dce606ed7..104963d4c1 100644 --- a/interfaces/inner_api/app_manager/src/appmgr/running_multi_info.cpp +++ b/interfaces/inner_api/app_manager/src/appmgr/running_multi_info.cpp @@ -30,7 +30,7 @@ bool RunningMultiAppInfo::ReadFromParcel(Parcel &parcel) mode = parcel.ReadInt32(); int32_t runningAppClonesSize; READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, runningAppClonesSize); - if(runningAppClonesSize > MAX_CLONE_APP_NUM) { + if (runningAppClonesSize > MAX_CLONE_APP_NUM) { return false; } for (auto i = 0; i < runningAppClonesSize; i++) { @@ -59,7 +59,7 @@ bool RunningMultiAppInfo::Marshalling(Parcel &parcel) const WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(bundleName)); WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, mode); WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, runningAppClones.size()); - if(runningAppClones.size() > MAX_CLONE_APP_NUM) { + if (runningAppClones.size() > MAX_CLONE_APP_NUM) { return false; } for (auto &clone : runningAppClones) { From 38b5d73b619efdf637fb66d1f0846408df5637c0 Mon Sep 17 00:00:00 2001 From: gongyuechen Date: Mon, 20 May 2024 09:24:29 +0800 Subject: [PATCH 112/174] fix dlp module name Signed-off-by: gongyuechen --- services/abilitymgr/include/ability_util.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/abilitymgr/include/ability_util.h b/services/abilitymgr/include/ability_util.h index d8bd13a89c..b8abf0a737 100644 --- a/services/abilitymgr/include/ability_util.h +++ b/services/abilitymgr/include/ability_util.h @@ -223,7 +223,7 @@ static constexpr int64_t MICROSECONDS = 1000000; // MICROSECONDS mean 10^6 mi AppExecFwk::ElementName element = want.GetElement(); if (want.GetBoolParam(DLP_PARAMS_SANDBOX, false) && !element.GetBundleName().empty() && !element.GetAbilityName().empty()) { - want.SetElementName(DEFAULT_DEVICE_ID, DLP_BUNDLE_NAME, DLP_ABILITY_NAME, DLP_PARAMS_MODULE_NAME); + want.SetElementName(DEFAULT_DEVICE_ID, DLP_BUNDLE_NAME, DLP_ABILITY_NAME, DLP_MODULE_NAME); want.SetParam(DLP_PARAMS_BUNDLE_NAME, element.GetBundleName()); want.SetParam(DLP_PARAMS_MODULE_NAME, element.GetModuleName()); want.SetParam(DLP_PARAMS_ABILITY_NAME, element.GetAbilityName()); From 3d052d4673e9683941b5feb2ff5c8a6d53f45b7b Mon Sep 17 00:00:00 2001 From: mashaohua7 Date: Mon, 20 May 2024 01:34:39 +0000 Subject: [PATCH 113/174] update services/appmgr/src/app_mgr_service.cpp. Signed-off-by: mashaohua7 --- services/appmgr/src/app_mgr_service.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/appmgr/src/app_mgr_service.cpp b/services/appmgr/src/app_mgr_service.cpp index d995bd4f7b..b8b7b1d65c 100644 --- a/services/appmgr/src/app_mgr_service.cpp +++ b/services/appmgr/src/app_mgr_service.cpp @@ -398,7 +398,7 @@ int32_t AppMgrService::GetRunningMultiAppInfoByBundleName(const std::string &bun return ERR_INVALID_OPERATION; } - if (!PermissionVerification::GetInstance()->JudgeCallerIsAllowedToUseSystemAPI()) { + if (!AAFwk::PermissionVerification::GetInstance()->JudgeCallerIsAllowedToUseSystemAPI()) { TAG_LOGE(AAFwkTag::ABILITYMGR, "The caller is not system-app, can not use system-api"); return ERR_INVALID_OPERATION; } From 29ace0800d32c0dbf89452cefa70d0d39bd8f860 Mon Sep 17 00:00:00 2001 From: hanchenZz Date: Thu, 16 May 2024 15:59:53 +0800 Subject: [PATCH 114/174] Send maxChildProcess to appspawn. Signed-off-by: hanchenZz --- services/appmgr/include/app_spawn_client.h | 9 +++++++++ services/appmgr/src/app_mgr_service_inner.cpp | 1 + services/appmgr/src/app_spawn_client.cpp | 17 +++++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/services/appmgr/include/app_spawn_client.h b/services/appmgr/include/app_spawn_client.h index e3f4d1a017..693dfab866 100644 --- a/services/appmgr/include/app_spawn_client.h +++ b/services/appmgr/include/app_spawn_client.h @@ -72,6 +72,7 @@ struct AppSpawnStartMsg { std::string extensionSandboxPath; bool strictMode = false; // whether is strict mode std::string processType = ""; + int32_t maxChildProcess = 0; }; constexpr auto LEN_PID = sizeof(pid_t); @@ -189,6 +190,14 @@ public: */ int32_t AppspawnSetExtMsg(const AppSpawnStartMsg &startMsg, AppSpawnReqMsgHandle reqHandle); + /** + * Set extra info: provision_type, max_child_process. + * + * @param startMsg, request message. + * @param reqHandle, handle for request message + */ + int32_t AppspawnSetExtMsgMore(const AppSpawnStartMsg &startMsg, AppSpawnReqMsgHandle reqHandle); + /** * Create default appspawn msg. * diff --git a/services/appmgr/src/app_mgr_service_inner.cpp b/services/appmgr/src/app_mgr_service_inner.cpp index 51a75ec3e0..a6b1602cc2 100644 --- a/services/appmgr/src/app_mgr_service_inner.cpp +++ b/services/appmgr/src/app_mgr_service_inner.cpp @@ -2532,6 +2532,7 @@ void AppMgrServiceInner::SetAppInfo(const BundleInfo &bundleInfo, AppSpawnStartM startMsg.apl = bundleInfo.applicationInfo.appPrivilegeLevel; startMsg.ownerId = bundleInfo.signatureInfo.appIdentifier; startMsg.provisionType = bundleInfo.applicationInfo.appProvisionType; + startMsg.maxChildProcess = bundleInfo.applicationInfo.maxChildProcess; startMsg.setAllowInternet = setAllowInternet; startMsg.allowInternet = allowInternet; startMsg.gids = gids; diff --git a/services/appmgr/src/app_spawn_client.cpp b/services/appmgr/src/app_spawn_client.cpp index b7fa8b0174..ff4f2ca156 100644 --- a/services/appmgr/src/app_spawn_client.cpp +++ b/services/appmgr/src/app_spawn_client.cpp @@ -37,6 +37,7 @@ namespace { const std::string APPSPAWN_CLIENT_USER_NAME = "APP_MANAGER_SERVICE"; constexpr int32_t RIGHT_SHIFT_STEP = 1; constexpr int32_t START_FLAG_TEST_NUM = 1; + const std::string MAX_CHILD_PROCESS = "MaxChildProcess"; } AppSpawnClient::AppSpawnClient(bool isNWebSpawn) { @@ -283,6 +284,13 @@ int32_t AppSpawnClient::AppspawnSetExtMsg(const AppSpawnStartMsg &startMsg, AppS } } + return AppspawnSetExtMsgMore(startMsg, reqHandle); +} + +int32_t AppSpawnClient::AppspawnSetExtMsgMore(const AppSpawnStartMsg &startMsg, AppSpawnReqMsgHandle reqHandle) +{ + int32_t ret = 0; + if (!startMsg.provisionType.empty()) { ret = AppSpawnReqMsgAddStringInfo(reqHandle, MSG_EXT_NAME_PROVISION_TYPE, startMsg.provisionType.c_str()); if (ret) { @@ -299,6 +307,15 @@ int32_t AppSpawnClient::AppspawnSetExtMsg(const AppSpawnStartMsg &startMsg, AppS return ret; } } + + std::string maxChildProcessStr = std::to_string(startMsg.maxChildProcess); + if ((ret = AppSpawnReqMsgAddExtInfo(reqHandle, MAX_CHILD_PROCESS.c_str(), + reinterpret_cast(maxChildProcessStr.c_str()), maxChildProcessStr.size()))) { + TAG_LOGE(AAFwkTag::APPMGR, "Send maxChildProcess failed, ret: %{public}d", ret); + return ret; + } + TAG_LOGI(AAFwkTag::APPMGR, "Send maxChildProcess %{public}s success.", maxChildProcessStr.c_str()); + return ret; } From d5608ea67d069d070cf1acae2b93dc0ea89b6435 Mon Sep 17 00:00:00 2001 From: mashaohua7 Date: Mon, 20 May 2024 02:08:22 +0000 Subject: [PATCH 115/174] update test/mock/services_appmgr_test/include/mock_app_mgr_service_inner.h. Signed-off-by: mashaohua7 --- .../services_appmgr_test/include/mock_app_mgr_service_inner.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/mock/services_appmgr_test/include/mock_app_mgr_service_inner.h b/test/mock/services_appmgr_test/include/mock_app_mgr_service_inner.h index e8ffaf5795..f672f7d0f7 100644 --- a/test/mock/services_appmgr_test/include/mock_app_mgr_service_inner.h +++ b/test/mock/services_appmgr_test/include/mock_app_mgr_service_inner.h @@ -71,8 +71,6 @@ public: MOCK_METHOD1(IsWaitingDebugApp, bool(const std::string &bundleName)); MOCK_METHOD0(ClearNonPersistWaitingDebugFlag, void()); MOCK_METHOD0(IsMemorySizeSufficent, bool()); - MOCK_METHOD2(GetRunningMultiAppInfoByBundleName, int32_t(const std::string &bundleName, - RunningMultiAppInfo &info)); MOCK_METHOD4(StartNativeChildProcess, int32_t(const pid_t hostPid, const std::string &libName, int32_t childProcessCount, const sptr &callback)); void StartSpecifiedAbility(const AAFwk::Want&, const AppExecFwk::AbilityInfo&, int32_t) From 8b1f36fc16de2c0f35023aa5d8ad234455a8b992 Mon Sep 17 00:00:00 2001 From: mashaohua7 Date: Mon, 20 May 2024 02:11:05 +0000 Subject: [PATCH 116/174] update test/unittest/app_mgr_service_test/app_mgr_service_test.cpp. Signed-off-by: mashaohua7 --- .../app_mgr_service_test/app_mgr_service_test.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/test/unittest/app_mgr_service_test/app_mgr_service_test.cpp b/test/unittest/app_mgr_service_test/app_mgr_service_test.cpp index ee2239d401..5136b144f3 100644 --- a/test/unittest/app_mgr_service_test/app_mgr_service_test.cpp +++ b/test/unittest/app_mgr_service_test/app_mgr_service_test.cpp @@ -1789,19 +1789,15 @@ HWTEST_F(AppMgrServiceTest, GetRunningMultiAppInfoByBundleName_002, TestSize.Lev { auto appMgrService = std::make_shared(); ASSERT_NE(appMgrService, nullptr); - appMgrService->SetInnerService(mockAppMgrServiceInner_); + appMgrService->SetInnerService(nullptr); appMgrService->taskHandler_ = taskHandler_; appMgrService->eventHandler_ = eventHandler_; std::string bundleName = "testbundlename"; RunningMultiAppInfo info; - EXPECT_CALL(*mockAppMgrServiceInner_, GetRunningMultiAppInfoByBundleName(_, _)) - .Times(1) - .WillOnce(Return(ERR_OK)); - int32_t ret = appMgrService->GetRunningMultiAppInfoByBundleName(bundleName, info); - EXPECT_EQ(ret, ERR_OK); + EXPECT_NE(ret, ERR_OK); } } // namespace AppExecFwk } // namespace OHOS \ No newline at end of file From de7d9874c2df1869dc40df0a759948b945ec3483 Mon Sep 17 00:00:00 2001 From: wangzhen Date: Mon, 20 May 2024 10:20:25 +0800 Subject: [PATCH 117/174] move StartResidentAbility to bundlerManagerListener Signed-off-by: wangzhen Change-Id: I9539c18aac7622a436fb6daf09fc4dada93cb729 --- services/abilitymgr/src/ability_manager_service.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/services/abilitymgr/src/ability_manager_service.cpp b/services/abilitymgr/src/ability_manager_service.cpp index 762548dd5d..eb318ba65f 100644 --- a/services/abilitymgr/src/ability_manager_service.cpp +++ b/services/abilitymgr/src/ability_manager_service.cpp @@ -454,8 +454,6 @@ void AbilityManagerService::InitPushTask() TAG_LOGE(AAFwkTag::ABILITYMGR, "taskHandler_ is nullptr."); return; } - auto startResidentAppsTask = [aams = shared_from_this()]() { aams->StartResidentApps(); }; - taskHandler_->SubmitTask(startResidentAppsTask, "StartResidentApps"); auto initStartupFlagTask = [aams = shared_from_this()]() { aams->InitStartupFlag(); }; taskHandler_->SubmitTask(initStartupFlagTask, "InitStartupFlag"); @@ -2263,7 +2261,13 @@ void AbilityManagerService::UnSubscribeBackgroundTask() void AbilityManagerService::SubscribeBundleEventCallback() { - TAG_LOGD(AAFwkTag::ABILITYMGR, "SubscribeBundleEventCallback to receive hap updates."); + TAG_LOGI(AAFwkTag::ABILITYMGR, "SubscribeBundleEventCallback begin."); + if (taskHandler_) { + TAG_LOGI(AAFwkTag::ABILITYMGR, "submit StartResidentApps task."); + auto startResidentAppsTask = [aams = shared_from_this()]() { aams->StartResidentApps(); }; + taskHandler_->SubmitTask(startResidentAppsTask, "StartResidentApps"); + } + if (abilityBundleEventCallback_) { return; } From becb224d18b6db22aa030081c2736fce3a362d05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=AE=B5=E5=97=A3=E9=92=8A?= Date: Mon, 20 May 2024 11:17:48 +0800 Subject: [PATCH 118/174] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=91=E5=9B=BE?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E6=8E=88=E6=9D=83=E5=A4=B1=E8=B4=A5=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 段嗣钊 Change-Id: I904d6a18a02a4a4c1e6ab24b2bfc50922d8c64fb --- services/uripermmgr/src/uri_permission_manager_stub_impl.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/services/uripermmgr/src/uri_permission_manager_stub_impl.cpp b/services/uripermmgr/src/uri_permission_manager_stub_impl.cpp index c66e115599..ce4413a425 100644 --- a/services/uripermmgr/src/uri_permission_manager_stub_impl.cpp +++ b/services/uripermmgr/src/uri_permission_manager_stub_impl.cpp @@ -427,7 +427,7 @@ int32_t UriPermissionManagerStubImpl::GrantBatchUriPermissionFor2In1Privileged(c continue; } auto &&authority = uriInner.GetAuthority(); - if (authority != "docs" || uriStr.find(CLOUND_DOCS_URI_MARK) == std::string::npos) { + if (authority != "docs" || uriStr.find(CLOUND_DOCS_URI_MARK) != std::string::npos) { uriStrVec.emplace_back(uriStr); continue; } @@ -437,6 +437,9 @@ int32_t UriPermissionManagerStubImpl::GrantBatchUriPermissionFor2In1Privileged(c docsVec.emplace_back(policyInfo); } + TAG_LOGI(AAFwkTag::URIPERMMGR, "docsUri size is %{public}zu, otherUri size is %{public}zu", + docsVec.size(), uriStrVec.size()); + if (uriStrVec.empty() && docsVec.empty()) { TAG_LOGE(AAFwkTag::URIPERMMGR, "Valid uri list is empty."); return ERR_CODE_INVALID_URI_TYPE; From db56195e4a04150a12750e1cd821ac72b5a40c27 Mon Sep 17 00:00:00 2001 From: sodanotgreen Date: Mon, 20 May 2024 11:38:14 +0800 Subject: [PATCH 119/174] review Signed-off-by: sodanotgreen --- frameworks/native/ability/native/js_service_extension.cpp | 2 +- frameworks/native/ability/native/ui_ability.cpp | 2 +- interfaces/kits/native/ability/native/js_service_extension.h | 2 +- interfaces/kits/native/ability/native/ui_ability.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/frameworks/native/ability/native/js_service_extension.cpp b/frameworks/native/ability/native/js_service_extension.cpp index d6c8522780..395a78498c 100644 --- a/frameworks/native/ability/native/js_service_extension.cpp +++ b/frameworks/native/ability/native/js_service_extension.cpp @@ -807,7 +807,7 @@ void JsServiceExtension::OnDestroy(Rosen::DisplayId displayId) TAG_LOGD(AAFwkTag::SERVICE_EXT, "exit."); } -void JsServiceExtension::OnDisplayInfoChange(const sptr & token, Rosen::DisplayId displayId, +void JsServiceExtension::OnDisplayInfoChange(const sptr& token, Rosen::DisplayId displayId, float density, Rosen::DisplayOrientation orientation) { TAG_LOGI(AAFwkTag::SERVICE_EXT, "displayId: %{public}" PRIu64"", displayId); diff --git a/frameworks/native/ability/native/ui_ability.cpp b/frameworks/native/ability/native/ui_ability.cpp index 66734f8602..ddc41dfdb4 100644 --- a/frameworks/native/ability/native/ui_ability.cpp +++ b/frameworks/native/ability/native/ui_ability.cpp @@ -800,7 +800,7 @@ void UIAbility::OnDestroy(Rosen::DisplayId displayId) TAG_LOGD(AAFwkTag::UIABILITY, "Called."); } -void UIAbility::OnDisplayInfoChange(const sptr & token, Rosen::DisplayId displayId, float density, +void UIAbility::OnDisplayInfoChange(const sptr& token, Rosen::DisplayId displayId, float density, Rosen::DisplayOrientation orientation) { TAG_LOGI(AAFwkTag::UIABILITY, "Begin displayId: %{public}" PRIu64 "", displayId); diff --git a/interfaces/kits/native/ability/native/js_service_extension.h b/interfaces/kits/native/ability/native/js_service_extension.h index 5ca49fd70c..7cbed03673 100644 --- a/interfaces/kits/native/ability/native/js_service_extension.h +++ b/interfaces/kits/native/ability/native/js_service_extension.h @@ -200,7 +200,7 @@ protected: jsServiceExtension_ = jsServiceExtension; } - void OnDisplayInfoChange(const sptr & token, Rosen::DisplayId displayId, float density, + void OnDisplayInfoChange(const sptr& token, Rosen::DisplayId displayId, float density, Rosen::DisplayOrientation orientation) override { auto sptr = jsServiceExtension_.lock(); diff --git a/interfaces/kits/native/ability/native/ui_ability.h b/interfaces/kits/native/ability/native/ui_ability.h index 247b572e42..5319a9c1e3 100644 --- a/interfaces/kits/native/ability/native/ui_ability.h +++ b/interfaces/kits/native/ability/native/ui_ability.h @@ -547,7 +547,7 @@ protected: ability_ = ability; } - void OnDisplayInfoChange(const sptr & token, Rosen::DisplayId displayId, float density, + void OnDisplayInfoChange(const sptr& token, Rosen::DisplayId displayId, float density, Rosen::DisplayOrientation orientation) override { auto sptr = ability_.lock(); From 3236d24c38d42ec18bd9ec94e03366c3faa29b16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=8F=E8=89=AF=E4=BC=9F?= Date: Mon, 20 May 2024 06:18:11 +0000 Subject: [PATCH 120/174] fixed a1cf510 from https://gitee.com/xialiangwei/ability_ability_runtime/pulls/8540 update services/dialog_ui/ams_system_dialog/AppScope/app.json. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 夏良伟 --- services/dialog_ui/ams_system_dialog/AppScope/app.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/dialog_ui/ams_system_dialog/AppScope/app.json b/services/dialog_ui/ams_system_dialog/AppScope/app.json index 0b4dfaf627..1a0d7f436c 100644 --- a/services/dialog_ui/ams_system_dialog/AppScope/app.json +++ b/services/dialog_ui/ams_system_dialog/AppScope/app.json @@ -2,8 +2,8 @@ "app": { "bundleName": "com.ohos.amsdialog", "vendor": "example", - "versionCode": 1000002, - "versionName": "1.1.0", + "versionCode": 1000003, + "versionName": "1.0.0", "icon": "$media:app_icon", "label": "$string:app_name", "distributedNotificationEnabled": true, From 3949be4ba92594abd67b83c5708d169537055305 Mon Sep 17 00:00:00 2001 From: sodanotgreen Date: Mon, 20 May 2024 14:52:40 +0800 Subject: [PATCH 121/174] review Signed-off-by: sodanotgreen --- .../ability/native/js_service_extension.cpp | 64 ++++++++++--------- 1 file changed, 35 insertions(+), 29 deletions(-) diff --git a/frameworks/native/ability/native/js_service_extension.cpp b/frameworks/native/ability/native/js_service_extension.cpp index 395a78498c..fc6da8680e 100644 --- a/frameworks/native/ability/native/js_service_extension.cpp +++ b/frameworks/native/ability/native/js_service_extension.cpp @@ -219,7 +219,13 @@ void JsServiceExtension::ListenWMS() return; } - auto listener = sptr::MakeSptr(displayListener_, GetContext()->GetToken()); + auto context = GetContext(); + if (context == nullptr || context->GetToken()) { + TAG_LOGE(AAFwkTag::SERVICE_EXT, "Param invalid."); + return; + } + + auto listener = sptr::MakeSptr(displayListener_, context->GetToken()); if (listener == nullptr) { TAG_LOGE(AAFwkTag::SERVICE_EXT, "Failed to create status change listener."); return; @@ -809,40 +815,40 @@ void JsServiceExtension::OnDestroy(Rosen::DisplayId displayId) void JsServiceExtension::OnDisplayInfoChange(const sptr& token, Rosen::DisplayId displayId, float density, Rosen::DisplayOrientation orientation) - { - TAG_LOGI(AAFwkTag::SERVICE_EXT, "displayId: %{public}" PRIu64"", displayId); - auto context = GetContext(); - if (context == nullptr) { - TAG_LOGE(AAFwkTag::SERVICE_EXT, "Context is invalid."); - return; - } +{ + TAG_LOGI(AAFwkTag::SERVICE_EXT, "displayId: %{public}" PRIu64, displayId); + auto context = GetContext(); + if (context == nullptr) { + TAG_LOGE(AAFwkTag::SERVICE_EXT, "Context is invalid."); + return; + } - auto contextConfig = context->GetConfiguration(); - if (contextConfig == nullptr) { - TAG_LOGE(AAFwkTag::SERVICE_EXT, "Configuration is invalid."); - return; - } + auto contextConfig = context->GetConfiguration(); + if (contextConfig == nullptr) { + TAG_LOGE(AAFwkTag::SERVICE_EXT, "Configuration is invalid."); + return; + } - TAG_LOGD(AAFwkTag::SERVICE_EXT, "Config dump: %{public}s", contextConfig->GetName().c_str()); - bool configChanged = false; - auto configUtils = std::make_shared(); - configUtils->UpdateDisplayConfig(displayId, contextConfig, context->GetResourceManager(), configChanged); - TAG_LOGD(AAFwkTag::SERVICE_EXT, "Config dump after update: %{public}s", contextConfig->GetName().c_str()); + TAG_LOGD(AAFwkTag::SERVICE_EXT, "Config dump: %{public}s", contextConfig->GetName().c_str()); + bool configChanged = false; + auto configUtils = std::make_shared(); + configUtils->UpdateDisplayConfig(displayId, contextConfig, context->GetResourceManager(), configChanged); + TAG_LOGD(AAFwkTag::SERVICE_EXT, "Config dump after update: %{public}s", contextConfig->GetName().c_str()); - if (configChanged) { - auto jsServiceExtension = std::static_pointer_cast(shared_from_this()); - auto task = [jsServiceExtension]() { - if (jsServiceExtension) { - jsServiceExtension->ConfigurationUpdated(); - } - }; - if (handler_ != nullptr) { - handler_->PostTask(task, "JsServiceExtension:OnChange"); + if (configChanged) { + auto jsServiceExtension = weak_from_this(); + auto task = [jsServiceExtension]() { + if (jsServiceExtension) { + jsServiceExtension->ConfigurationUpdated(); } + }; + if (handler_ != nullptr) { + handler_->PostTask(task, "JsServiceExtension:OnChange"); } + } - TAG_LOGD(AAFwkTag::SERVICE_EXT, "finished."); - }; + TAG_LOGD(AAFwkTag::SERVICE_EXT, "finished."); +} void JsServiceExtension::OnChange(Rosen::DisplayId displayId) { From 622c1f8607f7529bf08413d059eef621b580ae7f Mon Sep 17 00:00:00 2001 From: sodanotgreen Date: Mon, 20 May 2024 14:57:24 +0800 Subject: [PATCH 122/174] review Signed-off-by: sodanotgreen --- frameworks/native/ability/native/ui_ability.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frameworks/native/ability/native/ui_ability.cpp b/frameworks/native/ability/native/ui_ability.cpp index ddc41dfdb4..3549cd125d 100644 --- a/frameworks/native/ability/native/ui_ability.cpp +++ b/frameworks/native/ability/native/ui_ability.cpp @@ -803,7 +803,7 @@ void UIAbility::OnDestroy(Rosen::DisplayId displayId) void UIAbility::OnDisplayInfoChange(const sptr& token, Rosen::DisplayId displayId, float density, Rosen::DisplayOrientation orientation) { - TAG_LOGI(AAFwkTag::UIABILITY, "Begin displayId: %{public}" PRIu64 "", displayId); + TAG_LOGI(AAFwkTag::UIABILITY, "Begin displayId: %{public}" PRIu64, displayId); // Get display auto display = Rosen::DisplayManager::GetInstance().GetDisplayById(displayId); if (!display) { @@ -841,7 +841,7 @@ void UIAbility::OnDisplayInfoChange(const sptr& token, Rosen::Dis OnChangeForUpdateConfiguration(newConfig); TAG_LOGD(AAFwkTag::UIABILITY, "End."); -}; +} void UIAbility::OnChange(Rosen::DisplayId displayId) { From c70059967daab0c3cf0eb1e0b13e20a800e6a526 Mon Sep 17 00:00:00 2001 From: sodanotgreen Date: Mon, 20 May 2024 15:47:51 +0800 Subject: [PATCH 123/174] review Signed-off-by: sodanotgreen --- frameworks/native/ability/native/js_service_extension.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/native/ability/native/js_service_extension.cpp b/frameworks/native/ability/native/js_service_extension.cpp index fc6da8680e..91b8628159 100644 --- a/frameworks/native/ability/native/js_service_extension.cpp +++ b/frameworks/native/ability/native/js_service_extension.cpp @@ -836,7 +836,7 @@ void JsServiceExtension::OnDisplayInfoChange(const sptr& token, R TAG_LOGD(AAFwkTag::SERVICE_EXT, "Config dump after update: %{public}s", contextConfig->GetName().c_str()); if (configChanged) { - auto jsServiceExtension = weak_from_this(); + auto jsServiceExtension = std::static_pointer_cast(shared_from_this()); auto task = [jsServiceExtension]() { if (jsServiceExtension) { jsServiceExtension->ConfigurationUpdated(); From 49760a8b660f1f03d07710f8f7751a74f738b4be Mon Sep 17 00:00:00 2001 From: sodanotgreen Date: Mon, 20 May 2024 16:22:38 +0800 Subject: [PATCH 124/174] review Signed-off-by: sodanotgreen --- frameworks/native/ability/native/js_service_extension.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/native/ability/native/js_service_extension.cpp b/frameworks/native/ability/native/js_service_extension.cpp index 91b8628159..4f6bcdf4c3 100644 --- a/frameworks/native/ability/native/js_service_extension.cpp +++ b/frameworks/native/ability/native/js_service_extension.cpp @@ -836,7 +836,7 @@ void JsServiceExtension::OnDisplayInfoChange(const sptr& token, R TAG_LOGD(AAFwkTag::SERVICE_EXT, "Config dump after update: %{public}s", contextConfig->GetName().c_str()); if (configChanged) { - auto jsServiceExtension = std::static_pointer_cast(shared_from_this()); + auto jsServiceExtension = std::weak_ptr(shared_from_this()); auto task = [jsServiceExtension]() { if (jsServiceExtension) { jsServiceExtension->ConfigurationUpdated(); From 94c64603fa9d57c36e18297de7210b24a5c4c304 Mon Sep 17 00:00:00 2001 From: huangshiwei Date: Mon, 20 May 2024 16:26:47 +0800 Subject: [PATCH 125/174] huangshiwei4@huawei.com Signed-off-by: huangshiwei --- tools/aa/src/ability_command.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/aa/src/ability_command.cpp b/tools/aa/src/ability_command.cpp index 2b3050f3f1..6375d07741 100644 --- a/tools/aa/src/ability_command.cpp +++ b/tools/aa/src/ability_command.cpp @@ -1805,6 +1805,8 @@ ErrCode AbilityManagerShellCommand::MakeWantFromCmd(Want& want, std::string& win TAG_LOGD(AAFwkTag::AA_TOOL, "isMultiThread"); } case 0: { + // 'aa start' with an unknown option: aa start -x + // 'aa start' with an unknown option: aa start -xxx break; } default: { From 9ebfd058ca4968c71b51242bf8dae2ee3c513cb2 Mon Sep 17 00:00:00 2001 From: zhangyafei-echo Date: Sun, 19 May 2024 12:17:15 +0800 Subject: [PATCH 126/174] fix extension record id alloc. Signed-off-by: zhangyafei-echo Change-Id: I06e23ba99819af5b3cd32b646a277490f92df91f --- services/abilitymgr/src/extension_record_manager.cpp | 3 ++- services/abilitymgr/src/ui_extension_record_factory.cpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/services/abilitymgr/src/extension_record_manager.cpp b/services/abilitymgr/src/extension_record_manager.cpp index 5a56591c8e..469de7e17c 100644 --- a/services/abilitymgr/src/extension_record_manager.cpp +++ b/services/abilitymgr/src/extension_record_manager.cpp @@ -391,7 +391,8 @@ int32_t ExtensionRecordManager::GetOrCreateExtensionRecordInner(const AAFwk::Abi std::shared_ptr abilityRecord = extensionRecord->abilityRecord_; CHECK_POINTER_AND_RETURN(abilityRecord, ERR_NULL_OBJECT); isLoaded = false; - extensionRecordId = GenerateExtensionRecordId(extensionRecordId); + // Reuse id or not has been checked, so alloc a new id here. + extensionRecordId = GenerateExtensionRecordId(INVALID_EXTENSION_RECORD_ID); extensionRecord->extensionRecordId_ = extensionRecordId; extensionRecord->hostBundleName_ = hostBundleName; abilityRecord->SetOwnerMissionUserId(userId_); diff --git a/services/abilitymgr/src/ui_extension_record_factory.cpp b/services/abilitymgr/src/ui_extension_record_factory.cpp index 754df8ec8a..2612fb60b3 100644 --- a/services/abilitymgr/src/ui_extension_record_factory.cpp +++ b/services/abilitymgr/src/ui_extension_record_factory.cpp @@ -39,7 +39,7 @@ bool UIExtensionRecordFactory::NeedReuse(const AAFwk::AbilityRequest &abilityReq } TAG_LOGI(AAFwkTag::ABILITYMGR, "UIExtensionAbility id: %{public}d.", uiExtensionAbilityId); extensionRecordId = uiExtensionAbilityId; - return ExtensionRecordFactory::NeedReuse(abilityRequest, extensionRecordId); + return true; } int32_t UIExtensionRecordFactory::PreCheck( From f33a74aab9068cac693244690971dfd60325651a Mon Sep 17 00:00:00 2001 From: zhubingwei Date: Mon, 20 May 2024 09:37:54 +0000 Subject: [PATCH 127/174] dataobs UT Signed-off-by: zhubingwei --- .../dataobs_mgr_client_test.cpp | 36 +++++++++++++++++++ .../dataobs_mgr_service_test.cpp | 25 +++++++++++++ 2 files changed, 61 insertions(+) diff --git a/test/unittest/dataobs_mgr_client_test/dataobs_mgr_client_test.cpp b/test/unittest/dataobs_mgr_client_test/dataobs_mgr_client_test.cpp index 8fd42dcefc..deb233ee93 100644 --- a/test/unittest/dataobs_mgr_client_test/dataobs_mgr_client_test.cpp +++ b/test/unittest/dataobs_mgr_client_test/dataobs_mgr_client_test.cpp @@ -158,5 +158,41 @@ HWTEST_F(DataObsMgrClientTest, DataObsMgrClient_ReregisterObserver_0200, TestSiz testing::Mock::AllowLeak(DataObsMgrClient::GetInstance()->dataObsManger_); } +/* + * Feature: DataObsMgrClient. + * Function: re-subscribe when service restart. + * SubFunction: NA. + * FunctionPoints: NA. + * EnvConditions: NA. + * CaseDescription: NA. + */ +HWTEST_F(DataObsMgrClientTest, DataObsMgrClient_ReregisterObserver_0300, TestSize.Level1) +{ + sptr callBack1(new (std::nothrow) MockDataObsManagerOnChangeCallBack()); + sptr callBack2(new (std::nothrow) MockDataObsManagerOnChangeCallBack()); + + auto client = DataObsMgrClient::GetInstance(); + client->observers_.Clear(); + client->observerExts_.Clear(); + + sptr service1(new (std::nothrow) MockDataObsMgrService()); + client->dataObsManger_ = service1; + EXPECT_TRUE(client->dataObsManger_ != nullptr); + Uri uri1("datashare://device_id/com.domainname.dataability.persondata/person/25"); + Uri uri2("datashare://device_id/com.domainname.dataability.persondata/person/26"); + + EXPECT_EQ(client->RegisterObserver(uri1, callBack1), NO_ERROR); + EXPECT_EQ(client->RegisterObserver(uri2, callBack2), NO_ERROR); + EXPECT_EQ(service1->onChangeCall_, 2); + + sptr service2(new (std::nothrow) MockDataObsMgrService()); + client->dataObsManger_ = service2; + EXPECT_TRUE(client->dataObsManger_ != nullptr); + + client->OnRemoteDied(); + EXPECT_EQ(service2->onChangeCall_, 0); + testing::Mock::AllowLeak(DataObsMgrClient::GetInstance()->dataObsManger_); +} + } // namespace AAFwk } // namespace OHOS diff --git a/test/unittest/dataobs_mgr_service_test/dataobs_mgr_service_test.cpp b/test/unittest/dataobs_mgr_service_test/dataobs_mgr_service_test.cpp index 9ac0da86be..032638d0d9 100644 --- a/test/unittest/dataobs_mgr_service_test/dataobs_mgr_service_test.cpp +++ b/test/unittest/dataobs_mgr_service_test/dataobs_mgr_service_test.cpp @@ -254,5 +254,30 @@ HWTEST_F(DataObsMgrServiceTest, AaFwk_DataObsMgrServiceTest_OnStop_0100, TestSiz GTEST_LOG_(INFO) << "AaFwk_DataObsMgrServiceTest_OnStop_0100 end"; } + +/* + * Feature: DataObsMgrService + * Function: Dump + * SubFunction: NA + * FunctionPoints: DataObsMgrService Dump + * EnvConditions: NA + * CaseDescription: Verify that the DataObsMgrService Dump is normal. + */ +HWTEST_F(DataObsMgrServiceTest, AaFwk_DataObsMgrServiceTest_Dump_0100, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "AaFwk_DataObsMgrServiceTest_Dump_0100 start"; + const DataObsServiceRunningState testValue = DataObsServiceRunningState::STATE_RUNNING; + auto dataObsMgrServer = DelayedSingleton::GetInstance(); + + std::string fileName = "test.txt"; + std::vector args; + args.push_back(u"-h"); + FILE *fp = fopen(fileName.c_str(), "w"); + int ret = dataObsMgrServer->Dump(fileno(fp), args); + fclose(fp); + EXPECT_EQ(SUCCESS, ret); + + GTEST_LOG_(INFO) << "AaFwk_DataObsMgrServiceTest_Dump_0100 end"; +} } // namespace AAFwk } // namespace OHOS From 6109fc5eaccad4d922f029b767acd6b72bf543af Mon Sep 17 00:00:00 2001 From: zhubingwei Date: Mon, 20 May 2024 17:10:01 +0800 Subject: [PATCH 128/174] =?UTF-8?q?TDD=E8=A6=86=E7=9B=96=E7=8E=87=E6=8F=90?= =?UTF-8?q?=E5=8D=87=E3=80=90ability=5Fability=5Fruntime=20=20quickfixmgr?= =?UTF-8?q?=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhubingwei --- .../quick_fix_manager_apply_task_test.cpp | 242 ++++++++++++++++++ 1 file changed, 242 insertions(+) diff --git a/test/unittest/quick_fix/quick_fix_manager_service_test/quick_fix_manager_apply_task_test.cpp b/test/unittest/quick_fix/quick_fix_manager_service_test/quick_fix_manager_apply_task_test.cpp index 545a63be6b..95e7f56f6d 100644 --- a/test/unittest/quick_fix/quick_fix_manager_service_test/quick_fix_manager_apply_task_test.cpp +++ b/test/unittest/quick_fix/quick_fix_manager_service_test/quick_fix_manager_apply_task_test.cpp @@ -625,6 +625,248 @@ HWTEST_F(QuickFixManagerApplyTaskTest, PostRevokeQuickFixNotifyUnloadPatchTask_0 TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); } +/** + * @tc.name: RunRevoke_0100 + * @tc.desc: run apply revoke task + * @tc.type: FUNC + * @tc.require: issueI5OD2E + */ +HWTEST_F(QuickFixManagerApplyTaskTest, RunRevoke_0100, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + auto applyTask = std::make_shared(bundleQfMgr_, appMgr_, + quickFixMs_->eventHandler_, quickFixMs_); + ASSERT_NE(applyTask, nullptr); + applyTask->bundleName_ = "testBundleName"; + applyTask->isSoContained_ = true; + applyTask->taskType_ = QuickFixManagerApplyTask::TaskType::QUICK_FIX_REVOKE; + applyTask->RunRevoke(); + WaitUntilTaskDone(quickFixMs_->eventHandler_); + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} + +/** + * @tc.name: InitRevokeTask_0100 + * @tc.desc: init revok task. + * @tc.type: FUNC + * @tc.require: issueI5OD2E + */ +HWTEST_F(QuickFixManagerApplyTaskTest, InitRevokeTask_0100, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + auto applyTask = std::make_shared(bundleQfMgr_, appMgr_, + quickFixMs_->eventHandler_, quickFixMs_); + ASSERT_NE(applyTask, nullptr); + std::string bundleName = "testBundleName"; + bool isSoContained = true; + applyTask->InitRevokeTask(bundleName, isSoContained); + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} + +/** + * @tc.name: GetBundleName_0100 + * @tc.desc: get bundle name. + * @tc.type: FUNC + * @tc.require: issueI5OD2E + */ +HWTEST_F(QuickFixManagerApplyTaskTest, GetBundleName_0100, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + auto applyTask = std::make_shared(bundleQfMgr_, appMgr_, + quickFixMs_->eventHandler_, quickFixMs_); + ASSERT_NE(applyTask, nullptr); + std::string bundleName = "testBundleName"; + bool isSoContained = true; + applyTask->InitRevokeTask(bundleName, isSoContained); + std::string result = applyTask->GetBundleName(); + ASSERT_EQ(result, bundleName); + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} + +/** + * @tc.name: GetTaskType_0100 + * @tc.desc: get task type. + * @tc.type: FUNC + * @tc.require: issueI5OD2E + */ +HWTEST_F(QuickFixManagerApplyTaskTest, GetTaskType_0100, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + auto applyTask = std::make_shared(bundleQfMgr_, appMgr_, + quickFixMs_->eventHandler_, quickFixMs_); + ASSERT_NE(applyTask, nullptr); + std::string bundleName = "testBundleName"; + bool isSoContained = true; + applyTask->taskType_ = QuickFixManagerApplyTask::TaskType::QUICK_FIX_REVOKE; + QuickFixManagerApplyTask::TaskType taskType = QuickFixManagerApplyTask::TaskType::QUICK_FIX_REVOKE; + applyTask->InitRevokeTask(bundleName, isSoContained); + QuickFixManagerApplyTask::TaskType result = applyTask->GetTaskType(); + ASSERT_EQ(result, taskType); + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} + +/** + * @tc.name: RemoveSelf_0100 + * @tc.desc: remove timeout task + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(QuickFixManagerApplyTaskTest, RemoveSelf_0100, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + auto applyTask = std::make_shared(bundleQfMgr_, appMgr_, + nullptr, quickFixMs_); + ASSERT_NE(applyTask, nullptr); + applyTask->RemoveSelf(); + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} + +/** + * @tc.name: RemoveSelf_0200 + * @tc.desc: remove self + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(QuickFixManagerApplyTaskTest, RemoveSelf_0200, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + auto applyTask = std::make_shared(bundleQfMgr_, appMgr_, + quickFixMs_->eventHandler_, quickFixMs_); + ASSERT_NE(applyTask, nullptr); + applyTask->RemoveSelf(); + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} + +/** + * @tc.name: PostSwitchQuickFixTask_0100 + * @tc.desc: post switch quick fix task + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(QuickFixManagerApplyTaskTest, PostSwitchQuickFixTask_0100, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + auto applyTask = std::make_shared(bundleQfMgr_, appMgr_, + quickFixMs_->eventHandler_, quickFixMs_); + ASSERT_NE(applyTask, nullptr); + applyTask->PostSwitchQuickFixTask(); + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} +/** + * @tc.name: PostSwitchQuickFixTask_0200 + * @tc.desc: post switch quick fix task + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(QuickFixManagerApplyTaskTest, PostSwitchQuickFixTask_0200, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + auto applyTask = std::make_shared(bundleQfMgr_, appMgr_, + nullptr, quickFixMs_); + ASSERT_NE(applyTask, nullptr); + applyTask->PostSwitchQuickFixTask(); + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} + +/** + * @tc.name: PostDeployQuickFixTask_0100 + * @tc.desc: post deploy quick fix task + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(QuickFixManagerApplyTaskTest, PostDeployQuickFixTask_0100, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + auto applyTask = std::make_shared(bundleQfMgr_, appMgr_, + quickFixMs_->eventHandler_, quickFixMs_); + ASSERT_NE(applyTask, nullptr); + std::vector quickFixFiles; + applyTask->PostDeployQuickFixTask(quickFixFiles); + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} + +/** + * @tc.name: PostDeployQuickFixTask_0200 + * @tc.desc: post deploy quick fix task + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(QuickFixManagerApplyTaskTest, PostDeployQuickFixTask_0200, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + auto applyTask = std::make_shared(bundleQfMgr_, appMgr_, + nullptr, quickFixMs_); + ASSERT_NE(applyTask, nullptr); + std::vector quickFixFiles; + applyTask->PostDeployQuickFixTask(quickFixFiles); + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} + +/** + * @tc.name: PostDeleteQuickFixTask_0100 + * @tc.desc: post delete quick fix task + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(QuickFixManagerApplyTaskTest, PostDeleteQuickFixTask_0100, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + auto applyTask = std::make_shared(bundleQfMgr_, appMgr_, + quickFixMs_->eventHandler_, quickFixMs_); + ASSERT_NE(applyTask, nullptr); + applyTask->PostDeleteQuickFixTask(); + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} +/** + * @tc.name: PostDeleteQuickFixTask_0200 + * @tc.desc: post delete quick fix task + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(QuickFixManagerApplyTaskTest, PostDeleteQuickFixTask_0200, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + auto applyTask = std::make_shared(bundleQfMgr_, appMgr_, + nullptr, quickFixMs_); + ASSERT_NE(applyTask, nullptr); + applyTask->PostDeleteQuickFixTask(); + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} + +/** + * @tc.name: UnregAppStateObserver_0100 + * @tc.desc: unregister app state observer + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(QuickFixManagerApplyTaskTest, UnregAppStateObserver_0100, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + SetPermission(); + auto applyTask = std::make_shared(bundleQfMgr_, appMgr_, + quickFixMs_->eventHandler_, quickFixMs_); + ASSERT_NE(applyTask, nullptr); + applyTask->UnregAppStateObserver(); + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} + +/** + * @tc.name: UnregAppStateObserver_0200 + * @tc.desc: unregister app state observer + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(QuickFixManagerApplyTaskTest, UnregAppStateObserver_0200, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + SetPermission(); + auto applyTask = std::make_shared(bundleQfMgr_, nullptr, + quickFixMs_->eventHandler_, quickFixMs_); + ASSERT_NE(applyTask, nullptr); + applyTask->UnregAppStateObserver(); + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} + /** * @tc.name: PostRevokeQuickFixDeleteTask_0100 * @tc.desc: revoke quick fix delete task. From 29ae4b991e6f64b702799661fd5586a8e8cb3943 Mon Sep 17 00:00:00 2001 From: zhubingwei Date: Mon, 20 May 2024 20:06:47 +0800 Subject: [PATCH 129/174] =?UTF-8?q?=E3=80=90TDD=E8=A6=86=E7=9B=96=E7=8E=87?= =?UTF-8?q?=E6=8F=90=E5=8D=87=E3=80=91service=5Frouter=5Fframework\service?= =?UTF-8?q?s\srms\src?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhubingwei --- .../BUILD.gn | 2 + .../srms_interface_test.cpp | 110 ++++++++++++++++++ 2 files changed, 112 insertions(+) diff --git a/service_router_framework/services/srms/test/unittest/service_router_mgr_interface_test/BUILD.gn b/service_router_framework/services/srms/test/unittest/service_router_mgr_interface_test/BUILD.gn index 0e96c19afc..c53934f6f8 100755 --- a/service_router_framework/services/srms/test/unittest/service_router_mgr_interface_test/BUILD.gn +++ b/service_router_framework/services/srms/test/unittest/service_router_mgr_interface_test/BUILD.gn @@ -23,10 +23,12 @@ ohos_unittest("ServiceRouterMgrInterfaceTest") { sources = [ "${srms_services_path}/src/inner_service_info.cpp", "${srms_services_path}/src/service_router_data_mgr.cpp", + "${srms_services_path}/src/sr_samgr_helper.cpp", "srms_interface_test.cpp", ] deps = [ + "${ability_runtime_native_path}/appkit:appkit_manager_helper", "${bundlefwk_common_path}:libappexecfwk_common", "${srms_inner_api_path}:srms_fwk", ] diff --git a/service_router_framework/services/srms/test/unittest/service_router_mgr_interface_test/srms_interface_test.cpp b/service_router_framework/services/srms/test/unittest/service_router_mgr_interface_test/srms_interface_test.cpp index ee661879ce..dd8c61d50a 100755 --- a/service_router_framework/services/srms/test/unittest/service_router_mgr_interface_test/srms_interface_test.cpp +++ b/service_router_framework/services/srms/test/unittest/service_router_mgr_interface_test/srms_interface_test.cpp @@ -391,6 +391,116 @@ HWTEST_F(ServiceRouterMgrInterfaceTest, ServiceRouterMgrInterfaceTest_0019, Func EXPECT_TRUE(ret); } +/** + * @tc.number: ServiceRouterMgrInterfaceTest + * @tc.name: test LoadAllBundleInfos + * @tc.desc: test LoadAllBundleInfos function + */ +HWTEST_F(ServiceRouterMgrInterfaceTest, ServiceRouterMgrInterfaceTest_0020, Function | SmallTest | Level0) +{ + auto serviceRouterMgr = std::make_shared(); + EXPECT_NE(serviceRouterMgr, nullptr); + if (serviceRouterMgr != nullptr) { + auto ret = serviceRouterMgr->LoadAllBundleInfos(); + EXPECT_EQ(ret, true); + } +} + +/** + * @tc.number: ServiceRouterMgrInterfaceTest + * @tc.name: test LoadBundleInfo + * @tc.desc: test LoadBundleInfo function + */ +HWTEST_F(ServiceRouterMgrInterfaceTest, ServiceRouterMgrInterfaceTest_0021, Function | SmallTest | Level0) +{ + auto serviceRouterMgr = std::make_shared(); + EXPECT_NE(serviceRouterMgr, nullptr); + if (serviceRouterMgr != nullptr) { + std::string bundleName = BUNDLE_NAME; + auto ret = serviceRouterMgr->LoadBundleInfo(bundleName); + EXPECT_EQ(ret, false); + } +} + +/** + * @tc.number: ServiceRouterMgrInterfaceTest + * @tc.name: test UpdateBundleInfoLocked + * @tc.desc: test UpdateBundleInfoLocked function + */ +HWTEST_F(ServiceRouterMgrInterfaceTest, ServiceRouterMgrInterfaceTest_0022, Function | SmallTest | Level0) +{ + auto serviceRouterMgr = std::make_shared(); + EXPECT_NE(serviceRouterMgr, nullptr); + if (serviceRouterMgr != nullptr) { + BundleInfo bundleInfo; + serviceRouterMgr->UpdateBundleInfoLocked(bundleInfo); + } +} + +/** + * @tc.number: ServiceRouterMgrInterfaceTest + * @tc.name: test DeleteBundleInfo + * @tc.desc: test DeleteBundleInfo function + */ +HWTEST_F(ServiceRouterMgrInterfaceTest, ServiceRouterMgrInterfaceTest_0023, Function | SmallTest | Level0) +{ + auto serviceRouterMgr = std::make_shared(); + EXPECT_NE(serviceRouterMgr, nullptr); + if (serviceRouterMgr != nullptr) { + std::string bundleName = BUNDLE_NAME; + serviceRouterMgr->DeleteBundleInfo(bundleName); + } +} + +/** + * @tc.number: ServiceRouterMgrInterfaceTest + * @tc.name: test GetBusinessType + * @tc.desc: test GetBusinessType function 1 + */ +HWTEST_F(ServiceRouterMgrInterfaceTest, ServiceRouterMgrInterfaceTest_0024, Function | SmallTest | Level0) +{ + auto serviceRouterMgr = std::make_shared(); + EXPECT_NE(serviceRouterMgr, nullptr); + if (serviceRouterMgr != nullptr) { + BusinessAbilityFilter filter; + filter.businessType = BusinessType::SHARE; + auto ret = serviceRouterMgr->GetBusinessType(filter); + EXPECT_EQ(ret, BusinessType::SHARE); + } +} + +/** + * @tc.number: ServiceRouterMgrInterfaceTest + * @tc.name: test GetBusinessType + * @tc.desc: test GetBusinessType function 2 + */ +HWTEST_F(ServiceRouterMgrInterfaceTest, ServiceRouterMgrInterfaceTest_0025, Function | SmallTest | Level0) +{ + auto serviceRouterMgr = std::make_shared(); + EXPECT_NE(serviceRouterMgr, nullptr); + if (serviceRouterMgr != nullptr) { + BusinessAbilityFilter filter; + filter.businessType = BusinessType::UNSPECIFIED; + filter.uri = ""; + auto ret = serviceRouterMgr->GetBusinessType(filter); + EXPECT_EQ(ret, BusinessType::UNSPECIFIED); + } +} + +/** + * @tc.number: ServiceRouterMgrInterfaceTest + * @tc.name: test ClearAllBundleInfos + * @tc.desc: test ClearAllBundleInfos function + */ +HWTEST_F(ServiceRouterMgrInterfaceTest, ServiceRouterMgrInterfaceTest_0026, Function | SmallTest | Level0) +{ + auto serviceRouterMgr = std::make_shared(); + EXPECT_NE(serviceRouterMgr, nullptr); + if (serviceRouterMgr != nullptr) { + serviceRouterMgr->ClearAllBundleInfos(); + } +} + /** * @tc.number: serviceRouterMgrProxy * @tc.name: test QueryBusinessAbilityInfos From c117c2885e664e31afac60584d520564db4c9f4e Mon Sep 17 00:00:00 2001 From: sodanotgreen Date: Mon, 20 May 2024 20:23:44 +0800 Subject: [PATCH 130/174] review Signed-off-by: sodanotgreen --- frameworks/native/ability/native/js_service_extension.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/native/ability/native/js_service_extension.cpp b/frameworks/native/ability/native/js_service_extension.cpp index 4f6bcdf4c3..91b8628159 100644 --- a/frameworks/native/ability/native/js_service_extension.cpp +++ b/frameworks/native/ability/native/js_service_extension.cpp @@ -836,7 +836,7 @@ void JsServiceExtension::OnDisplayInfoChange(const sptr& token, R TAG_LOGD(AAFwkTag::SERVICE_EXT, "Config dump after update: %{public}s", contextConfig->GetName().c_str()); if (configChanged) { - auto jsServiceExtension = std::weak_ptr(shared_from_this()); + auto jsServiceExtension = std::static_pointer_cast(shared_from_this()); auto task = [jsServiceExtension]() { if (jsServiceExtension) { jsServiceExtension->ConfigurationUpdated(); From 5fdd38732f896b8cbc3ccda54936089dd69742a4 Mon Sep 17 00:00:00 2001 From: sodanotgreen Date: Mon, 20 May 2024 20:25:50 +0800 Subject: [PATCH 131/174] review Signed-off-by: sodanotgreen --- frameworks/native/ability/native/js_service_extension.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/native/ability/native/js_service_extension.cpp b/frameworks/native/ability/native/js_service_extension.cpp index 91b8628159..0e346d96be 100644 --- a/frameworks/native/ability/native/js_service_extension.cpp +++ b/frameworks/native/ability/native/js_service_extension.cpp @@ -836,7 +836,7 @@ void JsServiceExtension::OnDisplayInfoChange(const sptr& token, R TAG_LOGD(AAFwkTag::SERVICE_EXT, "Config dump after update: %{public}s", contextConfig->GetName().c_str()); if (configChanged) { - auto jsServiceExtension = std::static_pointer_cast(shared_from_this()); + std::weak_ptr jsServiceExtension = std::static_pointer_cast(shared_from_this()); auto task = [jsServiceExtension]() { if (jsServiceExtension) { jsServiceExtension->ConfigurationUpdated(); From aee3cad196d9fb57cce433929d1fab869c175faa Mon Sep 17 00:00:00 2001 From: yangxuguang-huawei Date: Mon, 20 May 2024 20:31:55 +0800 Subject: [PATCH 132/174] temp fix: remove OHOS_ACCOUNT_ENABLED macro Signed-off-by: yangxuguang-huawei --- services/appmgr/BUILD.gn | 2 -- 1 file changed, 2 deletions(-) diff --git a/services/appmgr/BUILD.gn b/services/appmgr/BUILD.gn index 13bf86aa6f..f1c759f7aa 100644 --- a/services/appmgr/BUILD.gn +++ b/services/appmgr/BUILD.gn @@ -125,8 +125,6 @@ ohos_shared_library("libappms") { ] public_external_deps = [ "kv_store:distributeddata_mgr" ] - defines += [ "OHOS_ACCOUNT_ENABLED" ] - if (product_name != "ohcore") { external_deps += [ "netmanager_base:net_conn_manager_if" ] } From 1a97627bd27cc3d517dbcf384908ad57c9d4eb43 Mon Sep 17 00:00:00 2001 From: sodanotgreen Date: Mon, 20 May 2024 20:40:29 +0800 Subject: [PATCH 133/174] review Signed-off-by: sodanotgreen --- frameworks/native/ability/native/js_service_extension.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frameworks/native/ability/native/js_service_extension.cpp b/frameworks/native/ability/native/js_service_extension.cpp index 0e346d96be..f797e579de 100644 --- a/frameworks/native/ability/native/js_service_extension.cpp +++ b/frameworks/native/ability/native/js_service_extension.cpp @@ -836,7 +836,8 @@ void JsServiceExtension::OnDisplayInfoChange(const sptr& token, R TAG_LOGD(AAFwkTag::SERVICE_EXT, "Config dump after update: %{public}s", contextConfig->GetName().c_str()); if (configChanged) { - std::weak_ptr jsServiceExtension = std::static_pointer_cast(shared_from_this()); + std::weak_ptr jsServiceExtension = + std::static_pointer_cast(shared_from_this()); auto task = [jsServiceExtension]() { if (jsServiceExtension) { jsServiceExtension->ConfigurationUpdated(); From 88af3cb0d597803fa123a52e5a195b65cabfddc2 Mon Sep 17 00:00:00 2001 From: yangzk Date: Wed, 15 May 2024 11:34:15 +0800 Subject: [PATCH 134/174] =?UTF-8?q?Description:=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E6=A3=80=E8=A7=86=E6=84=8F=E8=A7=81=20IssueNo:=20#I9PFCV=20Sig?= =?UTF-8?q?:=20SIG=5FApplicationFramework=20Feature=20or=20Bugfix:=20Featu?= =?UTF-8?q?re=20Binary=20Source:=20No?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yangzk Change-Id: I033103994c7a232e65a968567a9c5da27e8ea947 --- .../app_startup/js_startup_task_executor.cpp | 2 ++ .../appkit/app_startup/js_startup_task_result.cpp | 2 +- .../native/appkit/app_startup/startup_config.cpp | 3 +-- .../native/appkit/app_startup/startup_manager.cpp | 2 +- .../native/appkit/app_startup/startup_task.cpp | 14 +++++--------- .../appkit/app_startup/startup_task_manager.cpp | 3 +-- .../appkit/app_startup/startup_task_result.cpp | 2 +- .../appkit/app_startup/js_startup_task_result.h | 2 +- .../native/appkit/app_startup/startup_config.h | 4 ++-- .../native/appkit/app_startup/startup_manager.h | 2 +- .../kits/native/appkit/app_startup/startup_task.h | 4 ++-- .../appkit/app_startup/startup_task_manager.h | 2 +- .../appkit/app_startup/startup_task_result.h | 2 +- .../abilitymgr/src/extension_record_factory.cpp | 2 +- .../abilitymgr/src/extension_record_manager.cpp | 2 +- services/abilitymgr/src/pending_want_manager.cpp | 2 ++ .../abilitymgr/src/ui_extension_record_factory.cpp | 4 ++-- 17 files changed, 26 insertions(+), 28 deletions(-) diff --git a/frameworks/native/appkit/app_startup/js_startup_task_executor.cpp b/frameworks/native/appkit/app_startup/js_startup_task_executor.cpp index 8ea932fc5a..e4bb365e22 100644 --- a/frameworks/native/appkit/app_startup/js_startup_task_executor.cpp +++ b/frameworks/native/appkit/app_startup/js_startup_task_executor.cpp @@ -182,6 +182,7 @@ void JsStartupTaskExecutor::ReplyFailed(StartupTaskResultCallback *callback, std::shared_ptr result = std::make_shared(resultCode, resultMessage); callback->Call(result); delete callback; + callback = nullptr; } void JsStartupTaskExecutor::ReplyFailed(std::unique_ptr callback, @@ -205,6 +206,7 @@ void JsStartupTaskExecutor::ReplySucceeded(StartupTaskResultCallback *callback, std::shared_ptr result = std::make_shared(resultRef); callback->Call(result); delete callback; + callback = nullptr; } } // namespace AbilityRuntime } // namespace OHOS diff --git a/frameworks/native/appkit/app_startup/js_startup_task_result.cpp b/frameworks/native/appkit/app_startup/js_startup_task_result.cpp index cdacf747ad..113f5d37e6 100644 --- a/frameworks/native/appkit/app_startup/js_startup_task_result.cpp +++ b/frameworks/native/appkit/app_startup/js_startup_task_result.cpp @@ -35,7 +35,7 @@ StartupTaskResult::ResultType JsStartupTaskResult::GetResultType() const return ResultType::JS; } -std::shared_ptr JsStartupTaskResult::GetJsStartupResultRef() const +const std::shared_ptr& JsStartupTaskResult::GetJsStartupResultRef() const { return jsStartupResultRef_; } diff --git a/frameworks/native/appkit/app_startup/startup_config.cpp b/frameworks/native/appkit/app_startup/startup_config.cpp index a77d6560e6..3e0dffed88 100644 --- a/frameworks/native/appkit/app_startup/startup_config.cpp +++ b/frameworks/native/appkit/app_startup/startup_config.cpp @@ -36,12 +36,11 @@ int32_t StartupConfig::GetAwaitTimeoutMs() const return awaitTimeoutMs_; } -int32_t StartupConfig::ListenerOnCompleted(const std::shared_ptr &result) +void StartupConfig::ListenerOnCompleted(const std::shared_ptr &result) { if (listener_ != nullptr) { listener_->OnCompleted(result); } - return ERR_OK; } } // namespace AbilityRuntime } // namespace OHOS diff --git a/frameworks/native/appkit/app_startup/startup_manager.cpp b/frameworks/native/appkit/app_startup/startup_manager.cpp index d64aeab7fd..3cc7f822ca 100644 --- a/frameworks/native/appkit/app_startup/startup_manager.cpp +++ b/frameworks/native/appkit/app_startup/startup_manager.cpp @@ -128,7 +128,7 @@ void StartupManager::SetDefaultConfig(const std::shared_ptr &conf defaultConfig_ = config; } -std::shared_ptr StartupManager::GetDefaultConfig() const +const std::shared_ptr& StartupManager::GetDefaultConfig() const { return defaultConfig_; } diff --git a/frameworks/native/appkit/app_startup/startup_task.cpp b/frameworks/native/appkit/app_startup/startup_task.cpp index 4ce4529368..00203dcc5a 100644 --- a/frameworks/native/appkit/app_startup/startup_task.cpp +++ b/frameworks/native/appkit/app_startup/startup_task.cpp @@ -13,22 +13,18 @@ * limitations under the License. */ - #include "startup_task.h" - #include "hilog_tag_wrapper.h" #include "hilog_wrapper.h" namespace OHOS { namespace AbilityRuntime { -StartupTask::StartupTask(const std::string &name) : name_(name) -{ - state_ = State::CREATED; -} +StartupTask::StartupTask(const std::string &name) : name_(name), state_(State::CREATED) +{} StartupTask::~StartupTask() = default; -std::string StartupTask::GetName() const +const std::string& StartupTask::GetName() const { return name_; } @@ -100,7 +96,7 @@ int32_t StartupTask::RemoveResult() return ERR_OK; } -std::shared_ptr StartupTask::GetResult() const +const std::shared_ptr& StartupTask::GetResult() const { return result_; } @@ -117,7 +113,7 @@ std::string StartupTask::DumpDependencies() const } bool isFirst = true; std::string dumpResult; - for (auto &iter : dependencies_) { + for (const auto &iter : dependencies_) { if (isFirst) { dumpResult = iter; isFirst = false; diff --git a/frameworks/native/appkit/app_startup/startup_task_manager.cpp b/frameworks/native/appkit/app_startup/startup_task_manager.cpp index 05ee16c31f..b7b3203ef7 100644 --- a/frameworks/native/appkit/app_startup/startup_task_manager.cpp +++ b/frameworks/native/appkit/app_startup/startup_task_manager.cpp @@ -47,10 +47,9 @@ int32_t StartupTaskManager::AddTask(const std::shared_ptr &task) return ERR_OK; } -int32_t StartupTaskManager::SetConfig(const std::shared_ptr &config) +void StartupTaskManager::SetConfig(const std::shared_ptr &config) { config_ = config; - return ERR_OK; } int32_t StartupTaskManager::Prepare() diff --git a/frameworks/native/appkit/app_startup/startup_task_result.cpp b/frameworks/native/appkit/app_startup/startup_task_result.cpp index e9b0cebc5e..a378faf843 100644 --- a/frameworks/native/appkit/app_startup/startup_task_result.cpp +++ b/frameworks/native/appkit/app_startup/startup_task_result.cpp @@ -44,7 +44,7 @@ int32_t StartupTaskResult::GetResultCode() const return resultCode_; } -std::string StartupTaskResult::GetResultMessage() const +const std::string& StartupTaskResult::GetResultMessage() const { return resultMessage_; } diff --git a/interfaces/kits/native/appkit/app_startup/js_startup_task_result.h b/interfaces/kits/native/appkit/app_startup/js_startup_task_result.h index a64af705a2..9f67decc8c 100644 --- a/interfaces/kits/native/appkit/app_startup/js_startup_task_result.h +++ b/interfaces/kits/native/appkit/app_startup/js_startup_task_result.h @@ -33,7 +33,7 @@ public: ResultType GetResultType() const override; - std::shared_ptr GetJsStartupResultRef() const; + const std::shared_ptr& GetJsStartupResultRef() const; private: std::shared_ptr jsStartupResultRef_; diff --git a/interfaces/kits/native/appkit/app_startup/startup_config.h b/interfaces/kits/native/appkit/app_startup/startup_config.h index c180beae8c..c76bb163d9 100644 --- a/interfaces/kits/native/appkit/app_startup/startup_config.h +++ b/interfaces/kits/native/appkit/app_startup/startup_config.h @@ -34,11 +34,11 @@ public: explicit StartupConfig(const std::shared_ptr &listener); - explicit StartupConfig(int32_t awaitTimeoutMs, const std::shared_ptr &listener); + StartupConfig(int32_t awaitTimeoutMs, const std::shared_ptr &listener); int32_t GetAwaitTimeoutMs() const; - int32_t ListenerOnCompleted(const std::shared_ptr &result); + void ListenerOnCompleted(const std::shared_ptr &result); static constexpr int32_t DEFAULT_AWAIT_TIMEOUT_MS = 10000; // 10s diff --git a/interfaces/kits/native/appkit/app_startup/startup_manager.h b/interfaces/kits/native/appkit/app_startup/startup_manager.h index 5cfe561aa2..6420be5acd 100644 --- a/interfaces/kits/native/appkit/app_startup/startup_manager.h +++ b/interfaces/kits/native/appkit/app_startup/startup_manager.h @@ -43,7 +43,7 @@ public: void SetDefaultConfig(const std::shared_ptr &config); - std::shared_ptr GetDefaultConfig() const; + const std::shared_ptr& GetDefaultConfig() const; int32_t RemoveAllResult(); diff --git a/interfaces/kits/native/appkit/app_startup/startup_task.h b/interfaces/kits/native/appkit/app_startup/startup_task.h index dbc881571a..1fb05f411d 100644 --- a/interfaces/kits/native/appkit/app_startup/startup_task.h +++ b/interfaces/kits/native/appkit/app_startup/startup_task.h @@ -38,7 +38,7 @@ public: virtual ~StartupTask(); - std::string GetName() const; + const std::string& GetName() const; std::vector GetDependencies() const; @@ -62,7 +62,7 @@ public: int32_t RemoveResult(); - std::shared_ptr GetResult() const; + const std::shared_ptr& GetResult() const; virtual int32_t RunTaskInit(std::unique_ptr callback) = 0; diff --git a/interfaces/kits/native/appkit/app_startup/startup_task_manager.h b/interfaces/kits/native/appkit/app_startup/startup_task_manager.h index 73119ecd2d..7985e2021a 100644 --- a/interfaces/kits/native/appkit/app_startup/startup_task_manager.h +++ b/interfaces/kits/native/appkit/app_startup/startup_task_manager.h @@ -37,7 +37,7 @@ public: int32_t AddTask(const std::shared_ptr &task); - int32_t SetConfig(const std::shared_ptr &config); + void SetConfig(const std::shared_ptr &config); int32_t Prepare(); diff --git a/interfaces/kits/native/appkit/app_startup/startup_task_result.h b/interfaces/kits/native/appkit/app_startup/startup_task_result.h index 247f88e37c..8dc820eca5 100644 --- a/interfaces/kits/native/appkit/app_startup/startup_task_result.h +++ b/interfaces/kits/native/appkit/app_startup/startup_task_result.h @@ -42,7 +42,7 @@ public: int32_t GetResultCode() const; - std::string GetResultMessage() const; + const std::string& GetResultMessage() const; virtual ResultType GetResultType() const; diff --git a/services/abilitymgr/src/extension_record_factory.cpp b/services/abilitymgr/src/extension_record_factory.cpp index 5def6f480e..c855c12cc7 100644 --- a/services/abilitymgr/src/extension_record_factory.cpp +++ b/services/abilitymgr/src/extension_record_factory.cpp @@ -112,7 +112,7 @@ uint32_t ExtensionRecordFactory::GetExtensionProcessMode( int32_t ExtensionRecordFactory::CreateRecord( const AAFwk::AbilityRequest &abilityRequest, std::shared_ptr &extensionRecord) { - std::shared_ptr abilityRecord = AAFwk::AbilityRecord::CreateAbilityRecord(abilityRequest); + auto abilityRecord = AAFwk::AbilityRecord::CreateAbilityRecord(abilityRequest); if (abilityRecord == nullptr) { TAG_LOGE(AAFwkTag::ABILITYMGR, "Failed to create ability record"); return ERR_NULL_OBJECT; diff --git a/services/abilitymgr/src/extension_record_manager.cpp b/services/abilitymgr/src/extension_record_manager.cpp index 17073d4b79..a2f697e808 100644 --- a/services/abilitymgr/src/extension_record_manager.cpp +++ b/services/abilitymgr/src/extension_record_manager.cpp @@ -215,7 +215,7 @@ bool ExtensionRecordManager::IsHostSpecifiedProcessValid(const AAFwk::AbilityReq std::shared_ptr &record, const std::string &process) { std::lock_guard lock(mutex_); - for (auto &iter: extensionRecords_) { + for (const auto &iter: extensionRecords_) { if (iter.second == nullptr || iter.second->abilityRecord_ == nullptr) { continue; } diff --git a/services/abilitymgr/src/pending_want_manager.cpp b/services/abilitymgr/src/pending_want_manager.cpp index f7ca346c13..ac4fce00b6 100644 --- a/services/abilitymgr/src/pending_want_manager.cpp +++ b/services/abilitymgr/src/pending_want_manager.cpp @@ -605,6 +605,7 @@ void PendingWantManager::ClearPendingWantRecordTask(const std::string &bundleNam void PendingWantManager::Dump(std::vector &info) { + TAG_LOGD(AAFwkTag::WANTAGENT, "dump begin."); std::string dumpInfo = " PendingWantRecords:"; info.push_back(dumpInfo); @@ -636,6 +637,7 @@ void PendingWantManager::Dump(std::vector &info) } void PendingWantManager::DumpByRecordId(std::vector &info, const std::string &args) { + TAG_LOGD(AAFwkTag::WANTAGENT, "dump by id begin."); std::string dumpInfo = " PendingWantRecords:"; info.push_back(dumpInfo); diff --git a/services/abilitymgr/src/ui_extension_record_factory.cpp b/services/abilitymgr/src/ui_extension_record_factory.cpp index 754df8ec8a..8e47d1db46 100644 --- a/services/abilitymgr/src/ui_extension_record_factory.cpp +++ b/services/abilitymgr/src/ui_extension_record_factory.cpp @@ -14,10 +14,10 @@ */ #include "ui_extension_record_factory.h" -#include "ui_extension_record.h" #include "ability_util.h" #include "extension_record_manager.h" #include "hilog_tag_wrapper.h" +#include "ui_extension_record.h" namespace OHOS { namespace AbilityRuntime { @@ -51,7 +51,7 @@ int32_t UIExtensionRecordFactory::PreCheck( int32_t UIExtensionRecordFactory::CreateRecord( const AAFwk::AbilityRequest &abilityRequest, std::shared_ptr &extensionRecord) { - std::shared_ptr abilityRecord = AAFwk::AbilityRecord::CreateAbilityRecord(abilityRequest); + auto abilityRecord = AAFwk::AbilityRecord::CreateAbilityRecord(abilityRequest); if (abilityRecord == nullptr) { TAG_LOGE(AAFwkTag::ABILITYMGR, "Failed to create ability record"); return ERR_NULL_OBJECT; From 26a9d9769fd5d1abcc231c6715962d9a43ad0c1b Mon Sep 17 00:00:00 2001 From: sodanotgreen Date: Mon, 20 May 2024 21:03:57 +0800 Subject: [PATCH 135/174] review Signed-off-by: sodanotgreen --- frameworks/native/ability/native/js_service_extension.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/frameworks/native/ability/native/js_service_extension.cpp b/frameworks/native/ability/native/js_service_extension.cpp index f797e579de..91b8628159 100644 --- a/frameworks/native/ability/native/js_service_extension.cpp +++ b/frameworks/native/ability/native/js_service_extension.cpp @@ -836,8 +836,7 @@ void JsServiceExtension::OnDisplayInfoChange(const sptr& token, R TAG_LOGD(AAFwkTag::SERVICE_EXT, "Config dump after update: %{public}s", contextConfig->GetName().c_str()); if (configChanged) { - std::weak_ptr jsServiceExtension = - std::static_pointer_cast(shared_from_this()); + auto jsServiceExtension = std::static_pointer_cast(shared_from_this()); auto task = [jsServiceExtension]() { if (jsServiceExtension) { jsServiceExtension->ConfigurationUpdated(); From eba964e02d611f868d4d85d155423f85f66c2a53 Mon Sep 17 00:00:00 2001 From: zhubingwei Date: Mon, 20 May 2024 16:16:03 +0800 Subject: [PATCH 136/174] freeze_util_test commit Signed-off-by: zhubingwei --- test/unittest/BUILD.gn | 1 + test/unittest/freeze_util_test/BUILD.gn | 46 ++++++++ .../freeze_util_test/freeze_util_test.cpp | 103 ++++++++++++++++++ 3 files changed, 150 insertions(+) create mode 100644 test/unittest/freeze_util_test/BUILD.gn create mode 100644 test/unittest/freeze_util_test/freeze_util_test.cpp diff --git a/test/unittest/BUILD.gn b/test/unittest/BUILD.gn index 38d6e5a8f3..2c62b70b86 100644 --- a/test/unittest/BUILD.gn +++ b/test/unittest/BUILD.gn @@ -457,6 +457,7 @@ group("unittest") { "frameworks_kits_ability_native_test:unittest", "frameworks_kits_appkit_native_test:unittest", "free_install_manager_test:unittest", + "freeze_util_test:unittest", "implicit_start_processor_test:unittest", "insight_intent:unittest", "js_auto_fill_extension_test:unittest", diff --git a/test/unittest/freeze_util_test/BUILD.gn b/test/unittest/freeze_util_test/BUILD.gn new file mode 100644 index 0000000000..f991156b3b --- /dev/null +++ b/test/unittest/freeze_util_test/BUILD.gn @@ -0,0 +1,46 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/test.gni") +import("//foundation/ability/ability_runtime/ability_runtime.gni") + +module_output_path = "ability_runtime/freeze_util" + +ohos_unittest("freeze_util_test") { + module_out_path = module_output_path + + configs = [ "${ability_runtime_utils_path}/global/freeze:freeze_util_config" ] + + include_dirs = [ "${ability_runtime_services_path}/common/include" ] + + sources = [ "freeze_util_test.cpp" ] + + cflags = [] + + deps = [ + "${ability_runtime_path}/utils/global/freeze:freeze_util", + "//third_party/googletest:gtest_main", + ] + + external_deps = [ + "c_utils:utils", + "hilog:libhilog", + "ipc:ipc_core", + ] +} + +group("unittest") { + testonly = true + + deps = [ ":freeze_util_test" ] +} diff --git a/test/unittest/freeze_util_test/freeze_util_test.cpp b/test/unittest/freeze_util_test/freeze_util_test.cpp new file mode 100644 index 0000000000..66d651ef40 --- /dev/null +++ b/test/unittest/freeze_util_test/freeze_util_test.cpp @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include "freeze_util.h" +#include "hilog_tag_wrapper.h" +#include "hilog_wrapper.h" +#include "ipc_object_stub.h" +using namespace testing; +using namespace testing::ext; + +namespace OHOS { +namespace AbilityRuntime { +class FreezeUtilTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + void SetUp() override; + void TearDown() override; +}; + +void FreezeUtilTest::SetUpTestCase(void) +{} + +void FreezeUtilTest::TearDownTestCase(void) +{} + +void FreezeUtilTest::SetUp() +{} + +void FreezeUtilTest::TearDown() +{} + +/* + * @tc.number : FreezeUtilTest_001 + * @tc.name : FreezeUtilTest + * @tc.desc : Test Function FreezeUtil::GetInstance() and AddLifecycleEvent() and GetLifecycleEvent() + */ +HWTEST_F(FreezeUtilTest, FreezeUtilTest_001, TestSize.Level1) +{ + FreezeUtil::LifecycleFlow flow; + EXPECT_EQ(FreezeUtil::GetInstance().GetLifecycleEvent(flow), ""); + flow.state = FreezeUtil::TimeoutState::FOREGROUND; + FreezeUtil::GetInstance().AddLifecycleEvent(flow, "firstEntry"); + EXPECT_EQ(FreezeUtil::GetInstance().GetLifecycleEvent(flow), "firstEntry"); + + FreezeUtil::GetInstance().AddLifecycleEvent(flow, "secondEntry"); + EXPECT_EQ(FreezeUtil::GetInstance().GetLifecycleEvent(flow), "firstEntry\nsecondEntry"); + TAG_LOGI(AAFwkTag::TEST, "FreezeUtilTest_001 is end"); +} + +/* + * @tc.number : FreezeUtilTest_002 + * @tc.name : FreezeUtilTest + * @tc.desc : Test Function FreezeUtil::GetInstance() and DeleteLifecycleEvent() and GetLifecycleEvent() + */ +HWTEST_F(FreezeUtilTest, FreezeUtilTest_002, TestSize.Level1) +{ + FreezeUtil::LifecycleFlow flow; + flow.state = FreezeUtil::TimeoutState::LOAD; + FreezeUtil::GetInstance().AddLifecycleEvent(flow, "testDeleteEntry"); + EXPECT_EQ(FreezeUtil::GetInstance().GetLifecycleEvent(flow), "testDeleteEntry"); + FreezeUtil::GetInstance().DeleteLifecycleEvent(flow); + EXPECT_EQ(FreezeUtil::GetInstance().GetLifecycleEvent(flow), ""); + TAG_LOGI(AAFwkTag::TEST, "FreezeUtilTest_002 is end"); +} + +/* + * @tc.number : FreezeUtilTest_003 + * @tc.name : FreezeUtilTest + * @tc.desc : Test Function DeleteLifecycleEvent() and DeleteLifecycleEventInner() + */ +HWTEST_F(FreezeUtilTest, FreezeUtilTest_003, TestSize.Level1) +{ + sptr token_(new IPCObjectStub()); + FreezeUtil::LifecycleFlow foregroundFlow = { token_, FreezeUtil::TimeoutState::FOREGROUND }; + FreezeUtil::GetInstance().AddLifecycleEvent(foregroundFlow, "testDeleteLifecyleEventForground"); + EXPECT_EQ(FreezeUtil::GetInstance().GetLifecycleEvent(foregroundFlow), "testDeleteLifecyleEventForground"); + + FreezeUtil::LifecycleFlow backgroundFlow = { token_, FreezeUtil::TimeoutState::BACKGROUND }; + FreezeUtil::GetInstance().AddLifecycleEvent(backgroundFlow, "testDeleteLifecyleEventBackground"); + EXPECT_EQ(FreezeUtil::GetInstance().GetLifecycleEvent(backgroundFlow), "testDeleteLifecyleEventBackground"); + + FreezeUtil::GetInstance().DeleteLifecycleEvent(token_); + EXPECT_EQ(FreezeUtil::GetInstance().GetLifecycleEvent(foregroundFlow), ""); + EXPECT_EQ(FreezeUtil::GetInstance().GetLifecycleEvent(backgroundFlow), ""); + TAG_LOGI(AAFwkTag::TEST, "FreezeUtilTest_003 is end"); +} +} +} From f728d7c1c990116ba0dc43ec103c85e338c6196c Mon Sep 17 00:00:00 2001 From: xieqiongyang Date: Tue, 21 May 2024 10:09:12 +0800 Subject: [PATCH 137/174] update Signed-off-by: xieqiongyang Change-Id: I80314ae2d6854867c4a29f65d7123b883e370cf1 --- .../inner/napi_common/napi_common_want.cpp | 8 ++ .../js_mission_manager/mission_manager.cpp | 5 + .../app_mgr_service_inner_tdd_test.cpp | 120 ++++++++++++++++++ 3 files changed, 133 insertions(+) diff --git a/frameworks/js/napi/inner/napi_common/napi_common_want.cpp b/frameworks/js/napi/inner/napi_common/napi_common_want.cpp index 74568fa6bd..b13a069837 100644 --- a/frameworks/js/napi/inner/napi_common/napi_common_want.cpp +++ b/frameworks/js/napi/inner/napi_common/napi_common_want.cpp @@ -86,6 +86,14 @@ napi_value WrapElementName(napi_env env, const ElementName &elementName) NAPI_CALL(env, napi_create_string_utf8(env, elementName.GetModuleName().c_str(), NAPI_AUTO_LENGTH, &jsValue)); NAPI_CALL(env, napi_set_named_property(env, jsObject, "moduleName", jsValue)); + jsValue = nullptr; + NAPI_CALL(env, napi_create_string_utf8(env, elementName.GetShortName().c_str(), NAPI_AUTO_LENGTH, &jsValue)); + NAPI_CALL(env, napi_set_named_property(env, jsObject, "shortName", jsValue)); + + jsValue = nullptr; + NAPI_CALL(env, napi_create_string_utf8(env, elementName.GetUri().c_str(), NAPI_AUTO_LENGTH, &jsValue)); + NAPI_CALL(env, napi_set_named_property(env, jsObject, "uri", jsValue)); + return jsObject; } diff --git a/frameworks/js/napi/js_mission_manager/mission_manager.cpp b/frameworks/js/napi/js_mission_manager/mission_manager.cpp index dcad35035d..fd4ae855a1 100755 --- a/frameworks/js/napi/js_mission_manager/mission_manager.cpp +++ b/frameworks/js/napi/js_mission_manager/mission_manager.cpp @@ -434,10 +434,15 @@ private: napi_create_object(env, &object); napi_value abilityObj = nullptr; napi_create_object(env, &abilityObj); + std::string defalutValue = ""; + napi_set_named_property(env, abilityObj, "deviceId", CreateJsValue(env, defalutValue)); napi_set_named_property(env, abilityObj, "bundleName", CreateJsValue(env, snapshotWrap->missionSnapshot.topAbility.GetBundleName())); napi_set_named_property(env, abilityObj, "abilityName", CreateJsValue(env, snapshotWrap->missionSnapshot.topAbility.GetAbilityName())); + napi_set_named_property(env, abilityObj, "moduleName", CreateJsValue(env, defalutValue)); + napi_set_named_property(env, abilityObj, "shortName", CreateJsValue(env, defalutValue)); + napi_set_named_property(env, abilityObj, "uri", CreateJsValue(env, defalutValue)); napi_set_named_property(env, object, "ability", abilityObj); #ifdef SUPPORT_GRAPHICS auto snapshotValue = Media::PixelMapNapi::CreatePixelMap( diff --git a/test/unittest/app_mgr_service_inner_tdd_test/app_mgr_service_inner_tdd_test.cpp b/test/unittest/app_mgr_service_inner_tdd_test/app_mgr_service_inner_tdd_test.cpp index a43999cab2..aae2dd24f1 100644 --- a/test/unittest/app_mgr_service_inner_tdd_test/app_mgr_service_inner_tdd_test.cpp +++ b/test/unittest/app_mgr_service_inner_tdd_test/app_mgr_service_inner_tdd_test.cpp @@ -574,5 +574,125 @@ HWTEST_F(AppMgrServiceInnerTest, ChangeAppGcState_001, TestSize.Level1) EXPECT_EQ(ret, ERR_INVALID_VALUE); TAG_LOGI(AAFwkTag::TEST, "ChangeAppGcState_001 end"); } + +/** + * @tc.name: QueryExtensionSandBox_001 + * @tc.desc: query extension sandBox. + * @tc.type: FUNC + */ +HWTEST_F(AppMgrServiceInnerTest, QueryExtensionSandBox_001, TestSize.Level0) +{ + TAG_LOGI(AAFwkTag::TEST, "QueryExtensionSandBox_001 start"); + auto appMgrServiceInner = std::make_shared(); + EXPECT_NE(appMgrServiceInner, nullptr); + const string moduleName = "entry"; + const string extensionName = "inputMethod"; + BundleInfo bundleInfo; + HapModuleInfo hapModuleInfo; + ExtensionAbilityInfo extensionAbilityInfo; + extensionAbilityInfo.name = "inputMethod"; + extensionAbilityInfo.moduleName = "entry"; + extensionAbilityInfo.needCreateSandbox = true; + extensionAbilityInfo.dataGroupIds = {"test1"}; + hapModuleInfo.extensionInfos.emplace_back(extensionAbilityInfo); + bundleInfo.hapModuleInfos.emplace_back(hapModuleInfo); + AppSpawnStartMsg startMsg; + DataGroupInfoList dataGroupInfoList; + DataGroupInfo dataGroupInfo; + dataGroupInfo.dataGroupId = "test1"; + dataGroupInfoList.emplace_back(dataGroupInfo); + bool strictMode = false; + appMgrServiceInner->QueryExtensionSandBox(moduleName, extensionName, bundleInfo, startMsg, dataGroupInfoList, + strictMode); + EXPECT_EQ(startMsg.dataGroupInfoList.size(), 1); + TAG_LOGI(AAFwkTag::TEST, "QueryExtensionSandBox_001 end"); +} + +/** + * @tc.name: QueryExtensionSandBox_002 + * @tc.desc: query extension sandBox. + * @tc.type: FUNC + */ +HWTEST_F(AppMgrServiceInnerTest, QueryExtensionSandBox_002, TestSize.Level0) +{ + TAG_LOGI(AAFwkTag::TEST, "QueryExtensionSandBox_002 start"); + auto appMgrServiceInner = std::make_shared(); + EXPECT_NE(appMgrServiceInner, nullptr); + const string moduleName = "entry"; + const string extensionName = "inputMethod"; + BundleInfo bundleInfo; + HapModuleInfo hapModuleInfo; + ExtensionAbilityInfo extensionAbilityInfo; + extensionAbilityInfo.name = "inputMethod"; + extensionAbilityInfo.moduleName = "entry"; + extensionAbilityInfo.needCreateSandbox = true; + extensionAbilityInfo.dataGroupIds = {"test2"}; + hapModuleInfo.extensionInfos.emplace_back(extensionAbilityInfo); + bundleInfo.hapModuleInfos.emplace_back(hapModuleInfo); + AppSpawnStartMsg startMsg; + DataGroupInfoList dataGroupInfoList; + DataGroupInfo dataGroupInfo; + dataGroupInfo.dataGroupId = "test3"; + dataGroupInfoList.emplace_back(dataGroupInfo); + bool strictMode = false; + appMgrServiceInner->QueryExtensionSandBox(moduleName, extensionName, bundleInfo, startMsg, dataGroupInfoList, + strictMode); + EXPECT_EQ(startMsg.dataGroupInfoList.size(), 0); + TAG_LOGI(AAFwkTag::TEST, "QueryExtensionSandBox_002 end"); +} + +/** + * @tc.name: QueryExtensionSandBox_003 + * @tc.desc: query extension sandBox. + * @tc.type: FUNC + */ +HWTEST_F(AppMgrServiceInnerTest, QueryExtensionSandBox_003, TestSize.Level0) +{ + TAG_LOGI(AAFwkTag::TEST, "QueryExtensionSandBox_003 start"); + auto appMgrServiceInner = std::make_shared(); + EXPECT_NE(appMgrServiceInner, nullptr); + const string moduleName = "entry"; + const string extensionName = "inputMethod"; + BundleInfo bundleInfo; + HapModuleInfo hapModuleInfo; + ExtensionAbilityInfo extensionAbilityInfo; + extensionAbilityInfo.name = "inputMethod"; + extensionAbilityInfo.moduleName = "entry"; + extensionAbilityInfo.needCreateSandbox = false; + AppSpawnStartMsg startMsg; + DataGroupInfoList dataGroupInfoList; + bool strictMode = false; + appMgrServiceInner->QueryExtensionSandBox(moduleName, extensionName, bundleInfo, startMsg, dataGroupInfoList, + strictMode); + EXPECT_EQ(startMsg.dataGroupInfoList.size(), 0); + TAG_LOGI(AAFwkTag::TEST, "QueryExtensionSandBox_003 end"); +} + +/** + * @tc.name: QueryExtensionSandBox_004 + * @tc.desc: query extension sandBox. + * @tc.type: FUNC + */ +HWTEST_F(AppMgrServiceInnerTest, QueryExtensionSandBox_004, TestSize.Level0) +{ + TAG_LOGI(AAFwkTag::TEST, "QueryExtensionSandBox_004 start"); + auto appMgrServiceInner = std::make_shared(); + EXPECT_NE(appMgrServiceInner, nullptr); + const string moduleName = "entry"; + const string extensionName = "inputMethod"; + BundleInfo bundleInfo; + HapModuleInfo hapModuleInfo; + ExtensionAbilityInfo extensionAbilityInfo; + extensionAbilityInfo.name = "inputMethod1"; + extensionAbilityInfo.moduleName = "entry"; + extensionAbilityInfo.needCreateSandbox = true; + AppSpawnStartMsg startMsg; + DataGroupInfoList dataGroupInfoList; + bool strictMode = false; + appMgrServiceInner->QueryExtensionSandBox(moduleName, extensionName, bundleInfo, startMsg, dataGroupInfoList, + strictMode); + EXPECT_EQ(startMsg.dataGroupInfoList.size(), 0); + TAG_LOGI(AAFwkTag::TEST, "QueryExtensionSandBox_004 end"); +} } // namespace AppExecFwk } // namespace OHOS \ No newline at end of file From d719623fb6948a17c0e11291a85a38af330da8ef Mon Sep 17 00:00:00 2001 From: huzeshan Date: Thu, 16 May 2024 20:02:38 +0800 Subject: [PATCH 138/174] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E7=83=AD=E5=90=AF?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E9=94=99=E8=AF=AF=E7=A0=81=E5=86=B2=E7=AA=81?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: huzeshan --- .../inner_api/error_utils/include/ability_runtime_error_util.h | 2 +- services/appmgr/src/module_running_record.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/interfaces/inner_api/error_utils/include/ability_runtime_error_util.h b/interfaces/inner_api/error_utils/include/ability_runtime_error_util.h index c3de0b5c47..1c621573e5 100644 --- a/interfaces/inner_api/error_utils/include/ability_runtime_error_util.h +++ b/interfaces/inner_api/error_utils/include/ability_runtime_error_util.h @@ -55,11 +55,11 @@ enum { ERR_ABILITY_RUNTIME_CHILD_PROCESS_NUMBER_EXCEEDS_UPPER_BOUND = 16000062, ERR_ABILITY_RUNTIME_RESTART_APP_INCORRECT_ABILITY = 16000063, ERR_ABILITY_RUNTIME_RESTART_APP_FREQUENT = 16000064, - ERR_ABILITY_RUNTIME_SET_SUPPORTED_PROCESS_CACHE_AGAIN = 16000068, ERR_ABILITY_RUNTIME_EXTERNAL_EXECUTE_SHELL_COMMAND_FAILED = 16000101, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_WANTAGENT = 16000151, ERR_ABILITY_RUNTIME_EXTERNAL_WANTAGENT_NOT_FOUND = 16000152, ERR_ABILITY_RUNTIME_EXTERNAL_WANTAGENT_CANCELED = 16000153, + ERR_ABILITY_RUNTIME_SET_SUPPORTED_PROCESS_CACHE_AGAIN = 16000200, ERR_ABILITY_RUNTIME_EXTERNAL_NO_SUCH_URI_ABILITY = 16100001, ERR_ABILITY_RUNTIME_EXTERNAL_FA_NOT_SUPPORT_OPERATION = 16100002, diff --git a/services/appmgr/src/module_running_record.cpp b/services/appmgr/src/module_running_record.cpp index 8fa674b59f..face85c1ee 100644 --- a/services/appmgr/src/module_running_record.cpp +++ b/services/appmgr/src/module_running_record.cpp @@ -248,7 +248,7 @@ void ModuleRunningRecord::TerminateAbility(const std::shared_ptr::GetInstance()->QueryEnableProcessCache(); + bool isCachedProcess = DelayedSingleton::GetInstance()->IsAppShouldCache(appRecord); appLifeCycleDeal_->ScheduleCleanAbility(token, isCachedProcess); } else { TAG_LOGW(AAFwkTag::APPMGR, "appLifeCycleDeal_ is null"); From e5cbcfad79ac385ee72f1a8cb08aed1e9aa406fb Mon Sep 17 00:00:00 2001 From: xinking129 Date: Tue, 21 May 2024 14:37:13 +0800 Subject: [PATCH 139/174] Resolve initialization issues Signed-off-by: xinking129 --- services/appmgr/src/app_mgr_service_inner.cpp | 1 - services/appmgr/src/app_running_manager.cpp | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/services/appmgr/src/app_mgr_service_inner.cpp b/services/appmgr/src/app_mgr_service_inner.cpp index 7415f7bed7..01dbcfab5c 100644 --- a/services/appmgr/src/app_mgr_service_inner.cpp +++ b/services/appmgr/src/app_mgr_service_inner.cpp @@ -1826,7 +1826,6 @@ std::shared_ptr AppMgrServiceInner::CreateAppRunningRecord(spt bool isKeepAlive = bundleInfo.isKeepAlive && bundleInfo.singleton; appRecord->SetKeepAliveEnableState(isKeepAlive); appRecord->SetEmptyKeepAliveAppState(false); - appRecord->SetSingleton(bundleInfo.singleton); appRecord->SetTaskHandler(taskHandler_); appRecord->SetEventHandler(eventHandler_); appRecord->AddModule(appInfo, abilityInfo, token, hapModuleInfo, want, abilityRecordId); diff --git a/services/appmgr/src/app_running_manager.cpp b/services/appmgr/src/app_running_manager.cpp index 008ee29c3e..7dbaae9d0b 100644 --- a/services/appmgr/src/app_running_manager.cpp +++ b/services/appmgr/src/app_running_manager.cpp @@ -79,6 +79,7 @@ std::shared_ptr AppRunningManager::CreateAppRunningRecord( processName.c_str(), isStageBasedModel, recordId); appRecord->SetStageModelState(isStageBasedModel); + appRecord->SetSingleton(bundleInfo.singleton); appRecord->SetSignCode(signCode); appRecord->SetJointUserId(bundleInfo.jointUserId); std::lock_guard guard(runningRecordMapMutex_); From a90ab066dcb8179da4151ab85d2ea1ad196e72b9 Mon Sep 17 00:00:00 2001 From: zhu-bingwei123 Date: Tue, 21 May 2024 15:11:31 +0800 Subject: [PATCH 140/174] =?UTF-8?q?=E5=85=83=E8=83=BD=E5=8A=9BTDD=E8=A6=86?= =?UTF-8?q?=E7=9B=96=E7=8E=87=E6=8F=90=E5=8D=87(dialog=20callback)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhu-bingwei123 --- bundle.json | 8 ++ .../BUILD.gn | 36 +++++ .../dialog_request_callback_impl_test.cpp | 55 ++++++++ .../dialog_ui_extension_callback_test.cpp | 131 ++++++++++++++++++ 4 files changed, 230 insertions(+) create mode 100644 test/unittest/frameworks_kits_ability_ability_runtime_test/dialog_request_callback_impl_test.cpp create mode 100644 test/unittest/frameworks_kits_ability_ability_runtime_test/dialog_ui_extension_callback_test.cpp diff --git a/bundle.json b/bundle.json index 6d0d9a79b2..1157cd7261 100644 --- a/bundle.json +++ b/bundle.json @@ -447,6 +447,14 @@ ] }, "name": "//foundation/ability/ability_runtime/interfaces/inner_api/ability_manager:ability_start_options" + }, + { + "header": { + "header_base": "//foundation/ability/ability_runtime/interfaces/kits/native/ability/native/dialog_request_callback", + "header_files": [ + ] + }, + "name": "//foundation/ability/ability_runtime/frameworks/native/ability/native:dialog_request_callback" } ], "test": [ diff --git a/test/unittest/frameworks_kits_ability_ability_runtime_test/BUILD.gn b/test/unittest/frameworks_kits_ability_ability_runtime_test/BUILD.gn index ff47f134bd..3a95c5a187 100644 --- a/test/unittest/frameworks_kits_ability_ability_runtime_test/BUILD.gn +++ b/test/unittest/frameworks_kits_ability_ability_runtime_test/BUILD.gn @@ -152,6 +152,41 @@ ohos_unittest("local_call_record_ut_test") { ] } +ohos_unittest("dialog_callback_test") { + module_out_path = module_out_path + + include_dirs = [ + "${ability_runtime_test_path}/mock/frameworks_kits_ability_native_test/include", + "${ability_runtime_path}/interfaces/kits/native/ability/native/dialog_request_callback", + ] + + sources = [ + "${ability_runtime_path}/frameworks/native/ability/ability_runtime/dialog_request_callback_impl.cpp", + "${ability_runtime_path}/frameworks/native/ability/ability_runtime/dialog_ui_extension_callback.cpp", + "dialog_request_callback_impl_test.cpp", + "dialog_ui_extension_callback_test.cpp", + ] + + deps = [ + "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_native_path}/ability:ability_context_native", + "${ability_runtime_native_path}/ability/native:abilitykit_native", + "${ability_runtime_native_path}/ability/native:dialog_request_callback", + "//third_party/googletest:gmock_main", + "//third_party/googletest:gtest_main", + ] + + external_deps = [ + "ability_base:want", + "ace_engine:ace_uicontent", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "hilog:libhilog", + "ipc:ipc_core", + "napi:ace_napi", + ] +} + ################################################################################ group("unittest") { testonly = true @@ -160,6 +195,7 @@ group("unittest") { deps += [ ":ability_context_impl_test", ":caller_call_back_ut_test", + ":dialog_callback_test", ":local_call_container_ut_test", ":local_call_record_ut_test", ] diff --git a/test/unittest/frameworks_kits_ability_ability_runtime_test/dialog_request_callback_impl_test.cpp b/test/unittest/frameworks_kits_ability_ability_runtime_test/dialog_request_callback_impl_test.cpp new file mode 100644 index 0000000000..98949f6019 --- /dev/null +++ b/test/unittest/frameworks_kits_ability_ability_runtime_test/dialog_request_callback_impl_test.cpp @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include "dialog_request_callback_impl.h" + +using namespace testing::ext; +using namespace testing; +using namespace OHOS::AppExecFwk; +using namespace OHOS::AbilityRuntime; +namespace OHOS { +namespace AAFwk { +class DialogRequestCallbackImplTest : public testing::Test { +public: + static void SetUpTestCase(void); + static void TearDownTestCase(void); + void SetUp(); + void TearDown(); +}; +void DialogRequestCallbackImplTest::SetUpTestCase(void) {} +void DialogRequestCallbackImplTest::TearDownTestCase(void) {} +void DialogRequestCallbackImplTest::TearDown() {} +void DialogRequestCallbackImplTest::SetUp() {} + +void RequestDialogResultTaskCallBack(int32_t resultCode, const AAFwk::Want&) +{ + GTEST_LOG_(INFO) << "RequestDialogResultTask call back"; +} + +/** + * @tc.name: DialogRequestCallbackImplTest_SendResult_0100 + * @tc.desc: Test the state of SendResult + * @tc.type: FUNC + */ +HWTEST_F(DialogRequestCallbackImplTest, SendResult_0100, TestSize.Level1) +{ + auto dialogRequestCallbackImpl = std::make_shared(RequestDialogResultTaskCallBack); + Want want; + dialogRequestCallbackImpl->SendResult(401, want); +} + +} // namespace AAFwk +} // namespace OHOS diff --git a/test/unittest/frameworks_kits_ability_ability_runtime_test/dialog_ui_extension_callback_test.cpp b/test/unittest/frameworks_kits_ability_ability_runtime_test/dialog_ui_extension_callback_test.cpp new file mode 100644 index 0000000000..a71d786c41 --- /dev/null +++ b/test/unittest/frameworks_kits_ability_ability_runtime_test/dialog_ui_extension_callback_test.cpp @@ -0,0 +1,131 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include "dialog_ui_extension_callback.h" +#include "mock_ui_content.h" + +using namespace testing::ext; +using namespace testing; +using namespace OHOS::AppExecFwk; +using namespace OHOS::AbilityRuntime; +namespace OHOS { +namespace AAFwk { +class MyAbilityCallback : public IAbilityCallback { +public: + virtual int GetCurrentWindowMode() + { + return 0; + } + + virtual ErrCode SetMissionLabel(const std::string& label) + { + return 0; + } + + virtual ErrCode SetMissionIcon(const std::shared_ptr& icon) + { + GTEST_LOG_(INFO) << "========AbilityCallback SetMissionIcon------------------------."; + return 0; + } + + virtual void GetWindowRect(int32_t &left, int32_t &top, int32_t &width, int32_t &height) + { + return; + } + + virtual Ace::UIContent* GetUIContent() + { + return nullptr; + } + + void EraseUIExtension(int32_t sessionId) + { + return; + } + + void RegisterAbilityLifecycleObserver(const std::shared_ptr &observer) + { + } + + void UnregisterAbilityLifecycleObserver(const std::shared_ptr &observer) + { + } +}; + +class DialogUIExtensionCallbackTest : public testing::Test { +public: + static void SetUpTestCase(void); + static void TearDownTestCase(void); + void SetUp(); + void TearDown(); +}; + +void DialogUIExtensionCallbackTest::SetUpTestCase(void) {} +void DialogUIExtensionCallbackTest::TearDownTestCase(void) {} +void DialogUIExtensionCallbackTest::TearDown() {} +void DialogUIExtensionCallbackTest::SetUp() {} + +/** + * @tc.name: DialogUIExtensionCallbackTest_OnRelease_0100 + * @tc.desc: Test the state of OnRelease + * @tc.type: FUNC + */ +HWTEST_F(DialogUIExtensionCallbackTest, OnRelease_0100, TestSize.Level1) +{ + Ace::MockUIContent *uicontent = new Ace::MockUIContent(); + EXPECT_CALL(*uicontent, CloseModalUIExtension(_)).Times(1).WillOnce(Return()); + auto abilityCallback_ = std::make_shared(); + auto dialogUIExtensionCallback_ = + std::make_shared(std::weak_ptr(abilityCallback_)); + dialogUIExtensionCallback_->SetUIContent(uicontent); + dialogUIExtensionCallback_->SetSessionId(1); + dialogUIExtensionCallback_->OnRelease(); + delete uicontent; +} + +/** + * @tc.name: DialogUIExtensionCallbackTest_OnError_0100 + * @tc.desc: Test the state of OnError + * @tc.type: FUNC + */ +HWTEST_F(DialogUIExtensionCallbackTest, OnError_0100, TestSize.Level1) +{ + Ace::MockUIContent *uicontent = new Ace::MockUIContent(); + EXPECT_CALL(*uicontent, CloseModalUIExtension(_)).Times(1).WillOnce(Return()); + auto abilityCallback_ = std::make_shared(); + auto dialogUIExtensionCallback_ = + std::make_shared(std::weak_ptr(abilityCallback_)); + dialogUIExtensionCallback_->SetUIContent(uicontent); + dialogUIExtensionCallback_->SetSessionId(1); + dialogUIExtensionCallback_->OnError(); + delete uicontent; +} + +/** + * @tc.name: DialogUIExtensionCallbackTest_OnDestroy_0100 + * @tc.desc: Test the state of OnDestroy + * @tc.type: FUNC + */ +HWTEST_F(DialogUIExtensionCallbackTest, OnDestroy_0100, TestSize.Level1) +{ + auto abilityCallback = std::make_shared(); + auto dialogUIExtensionCallback = + std::make_shared(std::weak_ptr(abilityCallback)); + dialogUIExtensionCallback->OnDestroy(); +} + +} // namespace AAFwk +} // namespace OHOS From 85caed05ebf241686ae7e1bfe62d0d297ff66ab1 Mon Sep 17 00:00:00 2001 From: XKK Date: Tue, 21 May 2024 15:57:21 +0800 Subject: [PATCH 141/174] fix get font size Signed-off-by: XKK --- services/appmgr/src/app_mgr_service_inner.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/services/appmgr/src/app_mgr_service_inner.cpp b/services/appmgr/src/app_mgr_service_inner.cpp index 7415f7bed7..5e87d40b0a 100644 --- a/services/appmgr/src/app_mgr_service_inner.cpp +++ b/services/appmgr/src/app_mgr_service_inner.cpp @@ -147,6 +147,8 @@ const std::string RENDER_PROCESS_NAME = ":render"; const std::string RENDER_PROCESS_TYPE = "render"; const std::string GPU_PROCESS_NAME = ":gpu"; const std::string GPU_PROCESS_TYPE = "gpu"; +const std::string FONT_WGHT_SCALE = "persist.sys.font_wght_scale_for_user0"; +const std::string FONT_SCALE = "persist.sys.font_scale_for_user0"; const int32_t SIGNAL_KILL = 9; constexpr int32_t USER_SCALE = 200000; #define ENUM_TO_STRING(s) #s @@ -4045,6 +4047,12 @@ void AppMgrServiceInner::InitGlobalConfiguration() auto deviceType = GetDeviceType(); TAG_LOGI(AAFwkTag::APPMGR, "current deviceType is %{public}s", deviceType); configuration_->AddItem(AAFwk::GlobalConfigurationKey::DEVICE_TYPE, deviceType); + auto fontSizeScale = OHOS::system::GetParameter(FONT_SCALE, "1.0"); + auto fontWeightScale = OHOS::system::GetParameter(FONT_WGHT_SCALE, "1.0"); + TAG_LOGI(AAFwkTag::APPMGR, "current fontSizeScale is: %{public}s, fontWeightScale is: %{public}s", + fontSizeScale.c_str(), fontWeightScale.c_str()); + configuration_->AddItem(AAFwk::GlobalConfigurationKey::SYSTEM_FONT_SIZE_SCALE, fontSizeScale); + configuration_->AddItem(AAFwk::GlobalConfigurationKey::SYSTEM_FONT_WEIGHT_SCALE, fontWeightScale); } std::shared_ptr AppMgrServiceInner::GetConfiguration() From 1427d47959881493b5807b1f999ea01f35632860 Mon Sep 17 00:00:00 2001 From: "zhubingwei@huawei.com" Date: Tue, 21 May 2024 14:45:21 +0800 Subject: [PATCH 142/174] =?UTF-8?q?TDD=E8=A6=86=E7=9B=96=E7=8E=87=E6=8F=90?= =?UTF-8?q?=E5=8D=87(app=5Fmodule=5Fchecker)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhubingwei@huawei.com Change-Id: Ib1bdedeb5266a3d137901688b8f788c2eb363430 --- .../BUILD.gn | 29 ++++ .../app_module_checker_test.cpp | 131 ++++++++++++++++++ 2 files changed, 160 insertions(+) create mode 100644 test/unittest/frameworks_kits_ability_native_test/app_module_checker_test.cpp diff --git a/test/unittest/frameworks_kits_ability_native_test/BUILD.gn b/test/unittest/frameworks_kits_ability_native_test/BUILD.gn index 4d927bcfed..1a75761d50 100644 --- a/test/unittest/frameworks_kits_ability_native_test/BUILD.gn +++ b/test/unittest/frameworks_kits_ability_native_test/BUILD.gn @@ -2701,6 +2701,34 @@ ohos_unittest("embedded_ui_extension_test") { ] } +ohos_unittest("app_module_checker_test") { + module_out_path = module_output_path + include_dirs = [ + "${ability_runtime_test_path}/mock/frameworks_kits_ability_native_test/include", + "${ability_runtime_path}/interfaces/kits/native/ability/native", + ] + + sources = [ "app_module_checker_test.cpp" ] + + configs = [ ":module_private_config" ] + + deps = [ + "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/runtime:runtime", + "${ability_runtime_native_path}/ability/native:abilitykit_native", + "//third_party/googletest:gmock_main", + "//third_party/googletest:gtest_main", + ] + + external_deps = [ + "ability_base:base", + "c_utils:utils", + "hilog:libhilog", + "ipc:ipc_core", + "napi:ace_napi", + ] +} + ############################################################################### group("unittest") { @@ -2728,6 +2756,7 @@ group("unittest") { ":abilityruntime_test", ":action_extension_module_loader_test", ":action_extension_test", + ":app_module_checker_test", ":auto_fill_extension_module_loader_test", ":auto_fill_extension_test", ":continuation_test", diff --git a/test/unittest/frameworks_kits_ability_native_test/app_module_checker_test.cpp b/test/unittest/frameworks_kits_ability_native_test/app_module_checker_test.cpp new file mode 100644 index 0000000000..71108ea063 --- /dev/null +++ b/test/unittest/frameworks_kits_ability_native_test/app_module_checker_test.cpp @@ -0,0 +1,131 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +#include "ability_handler.h" +#include "app_module_checker.h" +#include "context_deal.h" +#include "hilog_wrapper.h" +#include "locale_config.h" +#include "ohos_application.h" +#include "process_options.h" +#include "session_info.h" + +namespace OHOS { +namespace AppExecFwk { +using namespace testing::ext; +using namespace OHOS; +using namespace OHOS::AbilityRuntime; +namespace { +static const int32_t EXTENSION_TYPE = 10; +static const int32_t EXTENSION_TYPE1 = 2; +} +class AppModuleCheckTest : public testing::Test { +public: + AppModuleCheckTest() : appModuleChecker_(nullptr) {} + ~AppModuleCheckTest() {} + std::shared_ptr appModuleChecker_; + static void SetUpTestCase(void); + static void TearDownTestCase(void); + void SetUp(); + void TearDown(); +}; + +void AppModuleCheckTest::SetUpTestCase(void) {} + +void AppModuleCheckTest::TearDownTestCase(void) {} + +void AppModuleCheckTest::SetUp(void) {} + +void AppModuleCheckTest::TearDown(void) {} + +/* + * Feature: DiskCheckOnly_001 + * Function: DiskCheckOnly + */ +HWTEST_F(AppModuleCheckTest, DiskCheckOnly_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "DiskCheckOnly_001 start"; + std::unordered_map> blocklist = { + {1, {"module1"}}, + {2, {"module2"}}, + {3, {"module3"}} + }; + appModuleChecker_ = std::make_shared(EXTENSION_TYPE, std::move(blocklist)); + bool ret = appModuleChecker_->DiskCheckOnly(); + EXPECT_FALSE(ret); + GTEST_LOG_(INFO) << "DiskCheckOnly_001 end"; +} + +/* + * Feature: CheckModuleLoadable_001 + * Function: CheckModuleLoadable + */ +HWTEST_F(AppModuleCheckTest, CheckModuleLoadable_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "CheckModuleLoadable_001 start"; + std::unordered_map> blocklist = { + {1, {"module1"}}, + {2, {"module2"}}, + {3, {"module3"}} + }; + appModuleChecker_ = std::make_shared(EXTENSION_TYPE, std::move(blocklist)); + std::unique_ptr apiAllowListChecker(nullptr); + bool ret = appModuleChecker_->CheckModuleLoadable("module4", apiAllowListChecker); + EXPECT_TRUE(ret); + GTEST_LOG_(INFO) << "CheckModuleLoadable_001 end"; +} + +/* + * Feature: CheckModuleLoadable_002 + * Function: CheckModuleLoadable + */ +HWTEST_F(AppModuleCheckTest, CheckModuleLoadable_002, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "CheckModuleLoadable_002 start"; + std::unordered_map> blocklist = { + {1, {"module1"}}, + {2, {"module2"}}, + {3, {"module3"}} + }; + appModuleChecker_ = std::make_shared(EXTENSION_TYPE1, std::move(blocklist)); + std::unique_ptr apiAllowListChecker(nullptr); + bool ret = appModuleChecker_->CheckModuleLoadable("module4", apiAllowListChecker); + EXPECT_TRUE(ret); + GTEST_LOG_(INFO) << "CheckModuleLoadable_002 end"; +} + +/* + * Feature: CheckModuleLoadable_003 + * Function: CheckModuleLoadable + */ +HWTEST_F(AppModuleCheckTest, CheckModuleLoadable_003, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "CheckModuleLoadable_003 start"; + std::unordered_map> blocklist = { + {1, {"module1"}}, + {2, {"module2"}}, + {3, {"module3"}} + }; + appModuleChecker_ = std::make_shared(EXTENSION_TYPE1, std::move(blocklist)); + std::unique_ptr apiAllowListChecker(nullptr); + bool ret = appModuleChecker_->CheckModuleLoadable("module2", apiAllowListChecker); + EXPECT_FALSE(ret); + GTEST_LOG_(INFO) << "CheckModuleLoadable_003 end"; +} +} // namespace AppExecFwk +} // namespace OHOS From 1f7778cc89e7e006734840c93b41107aeb2b2896 Mon Sep 17 00:00:00 2001 From: huangshiwei Date: Tue, 21 May 2024 16:56:18 +0800 Subject: [PATCH 143/174] huangshiwei4@huawei.com Signed-off-by: huangshiwei --- .../cache_process_manager_test.cpp | 1 + .../aa/aa_command_dumpsys_module_test.cpp | 4 +- .../accessibility_ability_command_test.cpp | 402 +++++++++--------- 3 files changed, 211 insertions(+), 196 deletions(-) diff --git a/test/unittest/cache_process_manager_test/cache_process_manager_test.cpp b/test/unittest/cache_process_manager_test/cache_process_manager_test.cpp index 500e952bcc..edfa2201ef 100644 --- a/test/unittest/cache_process_manager_test/cache_process_manager_test.cpp +++ b/test/unittest/cache_process_manager_test/cache_process_manager_test.cpp @@ -126,6 +126,7 @@ HWTEST_F(CacheProcessManagerTest, CacheProcessManager_PenddingCacheProcess_0100, auto appRecord = MockAppRecord(); EXPECT_NE(appRecord, nullptr); appRecord->SetKeepAliveEnableState(true); + appRecord->SetSingleton(true); appRecord->SetEmptyKeepAliveAppState(true); EXPECT_EQ(cacheProcMgr->PenddingCacheProcess(appRecord), false); // nullptr not allowed diff --git a/tools/test/moduletest/aa/aa_command_dumpsys_module_test.cpp b/tools/test/moduletest/aa/aa_command_dumpsys_module_test.cpp index 8005eb2e7b..28e298c29e 100644 --- a/tools/test/moduletest/aa/aa_command_dumpsys_module_test.cpp +++ b/tools/test/moduletest/aa/aa_command_dumpsys_module_test.cpp @@ -316,7 +316,7 @@ HWTEST_F(AaCommandDumpsysModuleTest, Aa_Command_Dumpsys_ModuleTest_1100, Functio std::vector lines; SplitStr(result, " ", lines); // expect that no information showup since no permission - EXPECT_LE(lines.size(), SIZE_ONE); + EXPECT_GE(lines.size(), SIZE_ONE); } /** @@ -341,7 +341,7 @@ HWTEST_F(AaCommandDumpsysModuleTest, Aa_Command_Dumpsys_ModuleTest_1200, Functio std::vector lines; SplitStr(result, " ", lines); // expect that no information showup since no permission - EXPECT_LE(lines.size(), SIZE_ONE); + EXPECT_GE(lines.size(), SIZE_ONE); } /** diff --git a/tools/test/unittest/ability_delegator/accessibility_ability_command_test.cpp b/tools/test/unittest/ability_delegator/accessibility_ability_command_test.cpp index 801ca7cd68..96ec81f404 100644 --- a/tools/test/unittest/ability_delegator/accessibility_ability_command_test.cpp +++ b/tools/test/unittest/ability_delegator/accessibility_ability_command_test.cpp @@ -49,20 +49,34 @@ const std::string ACCESSIBILITY_HELP_MSG = " setAudioBalance set the value of the audio balance configuration item\n"; const std::string ACCESSIBILITY_SET_SCREEN_MAGNIFICATION_STATE_OK = "set screen magnification state successfully."; +const std::string ACCESSIBILITY_SET_SCREEN_MAGNIFICATION_STATE_NG = + "error: failed to set screen magnification state"; const std::string ACCESSIBILITY_SET_SHORT_KEY_STATE_OK = "set short key state successfully."; +const std::string ACCESSIBILITY_SET_SHORT_KEY_STATE_NG = "error: failed to set short key state."; const std::string ACCESSIBILITY_SET_MOUSE_KEY_STATE_OK = "set mouse key state successfully."; +const std::string ACCESSIBILITY_SET_MOUSE_KEY_STATE_NG = "error: failed to set mouse key state."; const std::string ACCESSIBILITY_SET_CAPTION_STATE_OK = "set caption state successfully."; +const std::string ACCESSIBILITY_SET_CAPTION_STATE_NG = "error: failed to set caption state."; const std::string ACCESSIBILITY_SET_AUTO_CLICK_TIME_OK = "set mouse auto click time successfully."; +const std::string ACCESSIBILITY_SET_AUTO_CLICK_TIME_NG = "error: failed to set mouse auto click time."; const std::string ACCESSIBILITY_SET_HIGH_CONTRAST_TEXT_STATE_OK = "set high contrast text state successfully."; +const std::string ACCESSIBILITY_SET_HIGH_CONTRAST_TEXT_STATE_NG = "error: failed to set high contrast text state."; const std::string ACCESSIBILITY_SET_INVERT_COLOR_STATE_OK = "set invert color state successfully."; +const std::string ACCESSIBILITY_SET_INVERT_COLOR_STATE_NG = "error: failed to set invert color state."; const std::string ACCESSIBILITY_SET_DALTONIZATIONZATION_COLOR_FILTER_OK = "set daltonization color filter successfully."; +const std::string ACCESSIBILITY_SET_DALTONIZATIONZATION_COLOR_FILTER_NG = + "error: failed to set daltonization color filter."; const std::string ACCESSIBILITY_SET_CONTENT_TIME_OK = "set content timeout successfully."; +const std::string ACCESSIBILITY_SET_CONTENT_TIME_NG = "error: failed to set content timeout."; const std::string ACCESSIBILITY_SET_ANIMATION_OFF_STATE_OK = "set animation off state successfully."; +const std::string ACCESSIBILITY_SET_ANIMATION_OFF_STATE_NG = "error: failed to set animation off state."; const std::string ACCESSIBILITY_SET_BRIGHTNESS_DISCOUNT_OK = "set brightness discount successfully."; const std::string ACCESSIBILITY_SET_BRIGHTNESS_DISCOUNT_NG = "error: failed to set brightness discount.\n"; const std::string ACCESSIBILITY_SET_AUDIO_MONO_STATE_OK = "set audio mono state successfully."; +const std::string ACCESSIBILITY_SET_AUDIO_MONO_STATE_NG = "error: failed to set audio mono state."; const std::string ACCESSIBILITY_SET_AUDIO_BALANCE_OK = "set audio balance successfully."; +const std::string ACCESSIBILITY_SET_AUDIO_BALANCE_NG = "error: failed to set audio balance successfully."; const std::string ACCESSIBILITY_ABILITY_NO_ABILITY_ARGUMENT = "argument -a or --ability= is required!"; @@ -275,7 +289,7 @@ AccessibilityAbilityShellCommand_GetEnabledAbilities_0100, TestSize.Level1) * @tc.name: GetInstalledAbilities * @tc.desc: Test whether GetInstalledAbilities is called normally. */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_GetInstalledAbilities_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_GetInstalledAbilities_0100 start"; @@ -295,7 +309,7 @@ AccessibilityAbilityShellCommand_GetInstalledAbilities_0100, TestSize.Level1) * @tc.name: CheckAbilityArgument * @tc.desc: Test whether CheckAbilityArgument is called normally. */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_CheckAbilityArgument_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckAbilityArgument_0100 start"; @@ -318,7 +332,7 @@ AccessibilityAbilityShellCommand_CheckAbilityArgument_0100, TestSize.Level1) * @tc.name: CheckAbilityArgument * @tc.desc: Test whether CheckAbilityArgument is called normally. */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_CheckAbilityArgument_0200, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckAbilityArgument_0200 start"; @@ -341,7 +355,7 @@ AccessibilityAbilityShellCommand_CheckAbilityArgument_0200, TestSize.Level1) * @tc.name: CheckAbilityArgument * @tc.desc: Test whether CheckAbilityArgument is called normally. */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_CheckAbilityArgument_0300, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckAbilityArgument_0300 start"; @@ -354,7 +368,7 @@ AccessibilityAbilityShellCommand_CheckAbilityArgument_0300, TestSize.Level1) }; int argc = sizeof(argv) / sizeof(argv[0]) - 1; AccessibilityAbilityShellCommand cmd(argc, argv); - ErrCode result = cmd.CheckAbilityArgument(argument,resultMessage); + ErrCode result = cmd.CheckAbilityArgument(argument, resultMessage); EXPECT_EQ(result, false); EXPECT_EQ(resultMessage, ACCESSIBILITY_ABILITY_NO_ABILITY_ARGUMENT_VALUE); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckAbilityArgument_0300 end"; @@ -365,7 +379,7 @@ AccessibilityAbilityShellCommand_CheckAbilityArgument_0300, TestSize.Level1) * @tc.name: CheckAbilityArgument * @tc.desc: Test whether CheckAbilityArgument is called normally. */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_CheckAbilityArgument_0400, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckAbilityArgument_0400 start"; @@ -378,7 +392,7 @@ AccessibilityAbilityShellCommand_CheckAbilityArgument_0400, TestSize.Level1) }; int argc = sizeof(argv) / sizeof(argv[0]) - 1; AccessibilityAbilityShellCommand cmd(argc, argv); - ErrCode result = cmd.CheckAbilityArgument(argument,resultMessage); + ErrCode result = cmd.CheckAbilityArgument(argument, resultMessage); EXPECT_EQ(result, true); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckAbilityArgument_0400 end"; } @@ -388,7 +402,7 @@ AccessibilityAbilityShellCommand_CheckAbilityArgument_0400, TestSize.Level1) * @tc.name: CheckBundleArgument * @tc.desc: Test whether CheckBundleArgument is called normally. */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_CheckBundleArgument_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckBundleArgument_0100 start"; @@ -411,7 +425,7 @@ AccessibilityAbilityShellCommand_CheckBundleArgument_0100, TestSize.Level1) * @tc.name: CheckBundleArgument * @tc.desc: Test whether CheckAbilityArgument is called normally. */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_CheckBundleArgument_0200, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckBundleArgument_0200 start"; @@ -434,7 +448,7 @@ AccessibilityAbilityShellCommand_CheckBundleArgument_0200, TestSize.Level1) * @tc.name: CheckBundleArgument * @tc.desc: Test whether CheckBundleArgument is called normally. */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_CheckBundleArgument_0300, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckBundleArgument_0300 start"; @@ -447,7 +461,7 @@ AccessibilityAbilityShellCommand_CheckBundleArgument_0300, TestSize.Level1) }; int argc = sizeof(argv) / sizeof(argv[0]) - 1; AccessibilityAbilityShellCommand cmd(argc, argv); - ErrCode result = cmd.CheckBundleArgument(argument,resultMessage); + ErrCode result = cmd.CheckBundleArgument(argument, resultMessage); EXPECT_EQ(result, false); EXPECT_EQ(resultMessage, ACCESSIBILITY_ABILITY_NO_BUNDLE_ARGUMENT_VALUE); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckBundleArgument_0300 end"; @@ -458,7 +472,7 @@ AccessibilityAbilityShellCommand_CheckBundleArgument_0300, TestSize.Level1) * @tc.name: CheckBundleArgument * @tc.desc: Test whether CheckBundleArgument is called normally. */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_CheckBundleArgument_0400, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckBundleArgument_0400 start"; @@ -471,7 +485,7 @@ AccessibilityAbilityShellCommand_CheckBundleArgument_0400, TestSize.Level1) }; int argc = sizeof(argv) / sizeof(argv[0]) - 1; AccessibilityAbilityShellCommand cmd(argc, argv); - ErrCode result = cmd.CheckBundleArgument(argument,resultMessage); + ErrCode result = cmd.CheckBundleArgument(argument, resultMessage); EXPECT_EQ(result, true); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckBundleArgument_0400 end"; } @@ -481,12 +495,12 @@ AccessibilityAbilityShellCommand_CheckBundleArgument_0400, TestSize.Level1) * @tc.name: CheckCapabilitiesArgument * @tc.desc: Test whether CheckCapabilitiesArgument is called normally. */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_CheckCapabilitiesArgument_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckCapabilitiesArgument_0100 start"; AccessibilityCommandArgument argument; - std::vector installedAbilities ; + std::vector installedAbilities; argument.capabilityNamesArgumentNum = 0; std::string resultMessage; char* argv[] = { @@ -494,7 +508,7 @@ AccessibilityAbilityShellCommand_CheckCapabilitiesArgument_0100, TestSize.Level1 }; int argc = sizeof(argv) / sizeof(argv[0]) - 1; AccessibilityAbilityShellCommand cmd(argc, argv); - ErrCode result = cmd.CheckCapabilitiesArgument(argument,installedAbilities,resultMessage); + ErrCode result = cmd.CheckCapabilitiesArgument(argument, installedAbilities, resultMessage); EXPECT_EQ(result, false); EXPECT_EQ(resultMessage, ACCESSIBILITY_ABILITY_NO_CAPABILITIES_ARGUMENT); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckCapabilitiesArgument_0100 end"; @@ -505,12 +519,12 @@ AccessibilityAbilityShellCommand_CheckCapabilitiesArgument_0100, TestSize.Level1 * @tc.name: CheckCapabilitiesArgument * @tc.desc: Test whether CheckCapabilitiesArgument is called normally. */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_CheckCapabilitiesArgument_0200, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckCapabilitiesArgument_0200 start"; AccessibilityCommandArgument argument; - std::vector installedAbilities ; + std::vector installedAbilities; argument.capabilityNamesArgumentNum = 2; std::string resultMessage; char* argv[] = { @@ -529,12 +543,12 @@ AccessibilityAbilityShellCommand_CheckCapabilitiesArgument_0200, TestSize.Level1 * @tc.name: CheckCapabilitiesArgument * @tc.desc: Test whether CheckCapabilitiesArgument is called normally. */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_CheckCapabilitiesArgument_0300, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckCapabilitiesArgument_0300 start"; AccessibilityCommandArgument argument; - std::vector installedAbilities ; + std::vector installedAbilities; argument.capabilityNamesArgumentNum = 1; argument.capabilityNames[0] = '-'; std::string resultMessage; @@ -554,12 +568,12 @@ AccessibilityAbilityShellCommand_CheckCapabilitiesArgument_0300, TestSize.Level1 * @tc.name: CheckCapabilitiesArgument * @tc.desc: Test whether CheckCapabilitiesArgument is called normally. */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_CheckCapabilitiesArgument_0400, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckCapabilitiesArgument_0400 start"; AccessibilityCommandArgument argument; - std::vector installedAbilities ; + std::vector installedAbilities; argument.capabilityNamesArgumentNum = 1; argument.capabilityNames = "capability"; std::string resultMessage; @@ -568,7 +582,7 @@ AccessibilityAbilityShellCommand_CheckCapabilitiesArgument_0400, TestSize.Level1 }; int argc = sizeof(argv) / sizeof(argv[0]) - 1; AccessibilityAbilityShellCommand cmd(argc, argv); - ErrCode result = cmd.CheckCapabilitiesArgument(argument,installedAbilities,resultMessage); + ErrCode result = cmd.CheckCapabilitiesArgument(argument, installedAbilities, resultMessage); EXPECT_EQ(result, true); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckCapabilitiesArgument_0400 end"; } @@ -578,7 +592,7 @@ AccessibilityAbilityShellCommand_CheckCapabilitiesArgument_0400, TestSize.Level1 * @tc.name: CheckSetCommandArgument * @tc.desc: Test whether CheckSetCommandArgument is called normally.(totalArgumentNum > 1) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_CheckSetCommandArgument_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckSetCommandArgument_0100 start"; @@ -602,7 +616,7 @@ AccessibilityAbilityShellCommand_CheckSetCommandArgument_0100, TestSize.Level1) * @tc.name: CheckSetCommandArgument * @tc.desc: Test whether CheckSetCommandArgument is called normally.(unknownArgumentNum > 0) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_CheckSetCommandArgument_0200, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckSetCommandArgument_0200 start"; @@ -626,7 +640,7 @@ AccessibilityAbilityShellCommand_CheckSetCommandArgument_0200, TestSize.Level1) * @tc.name: CheckSetCommandArgument * @tc.desc: Test whether CheckSetCommandArgument is called normally.(setArgumentNum = 0) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_CheckSetCommandArgument_0300, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckSetCommandArgument_0300 start"; @@ -639,7 +653,7 @@ AccessibilityAbilityShellCommand_CheckSetCommandArgument_0300, TestSize.Level1) }; int argc = sizeof(argv) / sizeof(argv[0]) - 1; AccessibilityAbilityShellCommand cmd(argc, argv); - ErrCode result = cmd.CheckSetCommandArgument(argument,resultMessage); + ErrCode result = cmd.CheckSetCommandArgument(argument, resultMessage); EXPECT_EQ(result, OHOS::ERR_INVALID_VALUE); EXPECT_EQ(resultMessage, ": " + ACCESSIBILITY_HELP_MSG_NO_OPTION); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckSetCommandArgument_0300 end"; @@ -650,7 +664,7 @@ AccessibilityAbilityShellCommand_CheckSetCommandArgument_0300, TestSize.Level1) * @tc.name: CheckSetCommandArgument * @tc.desc: Test whether CheckSetCommandArgument is called normally.(OHOS::ERR_OK) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_CheckSetCommandArgument_0400, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckSetCommandArgument_0400 start"; @@ -663,7 +677,7 @@ AccessibilityAbilityShellCommand_CheckSetCommandArgument_0400, TestSize.Level1) }; int argc = sizeof(argv) / sizeof(argv[0]) - 1; AccessibilityAbilityShellCommand cmd(argc, argv); - ErrCode result = cmd.CheckSetCommandArgument(argument,resultMessage); + ErrCode result = cmd.CheckSetCommandArgument(argument, resultMessage); EXPECT_EQ(result, OHOS::ERR_OK); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckSetCommandArgument_0400 end"; } @@ -673,7 +687,7 @@ AccessibilityAbilityShellCommand_CheckSetCommandArgument_0400, TestSize.Level1) * @tc.name: MakeEnableCommandArgumentFromCmd * @tc.desc: Test whether MakeEnableCommandArgumentFromCmd is called normally.(optind < 0) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_MakeEnableCommandArgumentFromCmd_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_MakeEnableCommandArgumentFromCmd_0100 start"; @@ -694,7 +708,7 @@ AccessibilityAbilityShellCommand_MakeEnableCommandArgumentFromCmd_0100, TestSize * @tc.name: MakeEnableCommandArgumentFromCmd * @tc.desc: Test whether MakeEnableCommandArgumentFromCmd is called normally.(option = -1) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_MakeEnableCommandArgumentFromCmd_0200, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_MakeEnableCommandArgumentFromCmd_0200 start"; @@ -717,7 +731,7 @@ AccessibilityAbilityShellCommand_MakeEnableCommandArgumentFromCmd_0200, TestSize * @tc.name: MakeEnableCommandArgumentFromCmd * @tc.desc: Test whether MakeEnableCommandArgumentFromCmd is called normally.(option -a requires a value) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_MakeEnableCommandArgumentFromCmd_0300, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_MakeEnableCommandArgumentFromCmd_0300 start"; @@ -741,7 +755,7 @@ AccessibilityAbilityShellCommand_MakeEnableCommandArgumentFromCmd_0300, TestSize * @tc.name: MakeEnableCommandArgumentFromCmd * @tc.desc: Test whether MakeEnableCommandArgumentFromCmd is called normally.(option -b requires a value) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_MakeEnableCommandArgumentFromCmd_0400, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_MakeEnableCommandArgumentFromCmd_0400 start"; @@ -767,7 +781,7 @@ AccessibilityAbilityShellCommand_MakeEnableCommandArgumentFromCmd_0400, TestSize * @tc.name: MakeEnableCommandArgumentFromCmd * @tc.desc: Test whether MakeEnableCommandArgumentFromCmd is called normally.(option -c requires a value) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_MakeEnableCommandArgumentFromCmd_0500, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_MakeEnableCommandArgumentFromCmd_0500 start"; @@ -796,7 +810,7 @@ AccessibilityAbilityShellCommand_MakeEnableCommandArgumentFromCmd_0500, TestSize * @tc.desc: Test whether MakeEnableCommandArgumentFromCmd is called normally. * (CheckEnableCommandArgument = OHOS::ERR_INVALID_VALUE) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_MakeEnableCommandArgumentFromCmd_0600, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_MakeEnableCommandArgumentFromCmd_0600 start"; @@ -818,8 +832,8 @@ AccessibilityAbilityShellCommand_MakeEnableCommandArgumentFromCmd_0600, TestSize AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.MakeEnableCommandArgumentFromCmd(argument); EXPECT_EQ(result, OHOS::ERR_INVALID_VALUE); - EXPECT_EQ(cmd.resultReceiver_, "enable: " + ACCESSIBILITY_ABILITY_TOO_MANY_ARGUMENT - + "and exist unknown arguments.-v "); + EXPECT_EQ(cmd.resultReceiver_, "enable: " + ACCESSIBILITY_ABILITY_TOO_MANY_ARGUMENT + + "and exist unknown arguments.-v "); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_MakeEnableCommandArgumentFromCmd_0600 end"; } @@ -829,7 +843,7 @@ AccessibilityAbilityShellCommand_MakeEnableCommandArgumentFromCmd_0600, TestSize * @tc.desc: Test whether MakeEnableCommandArgumentFromCmd is called normally. * (CheckEnableCommandArgument = OHOS::ERR_INVALID_VALUE) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_MakeEnableCommandArgumentFromCmd_0700, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_MakeEnableCommandArgumentFromCmd_0700 start"; @@ -849,8 +863,8 @@ AccessibilityAbilityShellCommand_MakeEnableCommandArgumentFromCmd_0700, TestSize AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.MakeEnableCommandArgumentFromCmd(argument); EXPECT_EQ(result, OHOS::ERR_INVALID_VALUE); - EXPECT_EQ(cmd.resultReceiver_, "enable: the auxiliary application bundle/ability" - + ACCESSIBILITY_ABILITY_NOT_FOUND); + EXPECT_EQ(cmd.resultReceiver_, "enable: the auxiliary application bundle/ability" + + ACCESSIBILITY_ABILITY_NOT_FOUND); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_MakeEnableCommandArgumentFromCmd_0700 end"; } @@ -859,15 +873,15 @@ AccessibilityAbilityShellCommand_MakeEnableCommandArgumentFromCmd_0700, TestSize * @tc.name: CheckParamValidity * @tc.desc: Test whether CheckParamValidity is called normally.(return true) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_CheckParamValidity_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckParamValidity_0100 start"; Accessibility::AccessibilityAbilityInitParams params; params.name = "ability"; params.bundleName = "bundle"; - Accessibility::AccessibilityAbilityInfo abilityInfo(params) ; - std::vector installedAbilities ; + Accessibility::AccessibilityAbilityInfo abilityInfo(params); + std::vector installedAbilities; installedAbilities.push_back(abilityInfo); AccessibilityCommandArgument argument; argument.abilityArgumentNum = 1; @@ -890,15 +904,15 @@ AccessibilityAbilityShellCommand_CheckParamValidity_0100, TestSize.Level1) * @tc.name: CheckParamValidity * @tc.desc: Test whether CheckParamValidity is called normally.(isExisted = false) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_CheckParamValidity_0200, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckParamValidity_0200 start"; Accessibility::AccessibilityAbilityInitParams params; params.name = "ability"; params.bundleName = "bundle"; - Accessibility::AccessibilityAbilityInfo abilityInfo(params) ; - std::vector installedAbilities ; + Accessibility::AccessibilityAbilityInfo abilityInfo(params); + std::vector installedAbilities; installedAbilities.push_back(abilityInfo); AccessibilityCommandArgument argument; std::string resultMessage; @@ -909,8 +923,8 @@ AccessibilityAbilityShellCommand_CheckParamValidity_0200, TestSize.Level1) AccessibilityAbilityShellCommand cmd(argc, argv); bool result = cmd.CheckParamValidity(argument, installedAbilities, resultMessage); EXPECT_EQ(result, false); - EXPECT_EQ(resultMessage, "the auxiliary application " + - argument.bundleName + "/" + argument.abilityName + ACCESSIBILITY_ABILITY_NOT_FOUND); + EXPECT_EQ(resultMessage, "the auxiliary application " + argument.bundleName + "/" + + argument.abilityName + ACCESSIBILITY_ABILITY_NOT_FOUND); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckParamValidity_0200 end"; } @@ -919,7 +933,7 @@ AccessibilityAbilityShellCommand_CheckParamValidity_0200, TestSize.Level1) * @tc.name: CheckParamValidity * @tc.desc: Test whether CheckParamValidity is called normally.(invalidCapabilityNames.empty() = false) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_CheckParamValidity_0300, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckParamValidity_0300 start"; @@ -927,8 +941,8 @@ AccessibilityAbilityShellCommand_CheckParamValidity_0300, TestSize.Level1) params.name = "ability"; params.bundleName = "bundle"; params.staticCapabilities = 1; - Accessibility::AccessibilityAbilityInfo abilityInfo(params) ; - std::vector installedAbilities ; + Accessibility::AccessibilityAbilityInfo abilityInfo(params); + std::vector installedAbilities; installedAbilities.push_back(abilityInfo); AccessibilityCommandArgument argument; argument.abilityArgumentNum = 1; @@ -943,7 +957,7 @@ AccessibilityAbilityShellCommand_CheckParamValidity_0300, TestSize.Level1) }; int argc = sizeof(argv) / sizeof(argv[0]) - 1; AccessibilityAbilityShellCommand cmd(argc, argv); - bool result = cmd.CheckParamValidity(argument,installedAbilities,resultMessage); + bool result = cmd.CheckParamValidity(argument, installedAbilities, resultMessage); EXPECT_EQ(result, false); EXPECT_EQ(resultMessage, "the capabilities capability" + ACCESSIBILITY_ABILITY_NOT_FOUND); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckParamValidity_0300 end"; @@ -954,7 +968,7 @@ AccessibilityAbilityShellCommand_CheckParamValidity_0300, TestSize.Level1) * @tc.name: CheckEnableCommandArgument * @tc.desc: Test whether CheckEnableCommandArgument is called normally.(totalArgumentNum > 3) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_CheckEnableCommandArgument_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckEnableCommandArgument_0100 start"; @@ -969,9 +983,9 @@ AccessibilityAbilityShellCommand_CheckEnableCommandArgument_0100, TestSize.Level }; int argc = sizeof(argv) / sizeof(argv[0]) - 1; AccessibilityAbilityShellCommand cmd(argc, argv); - ErrCode result = cmd.CheckEnableCommandArgument(argument,resultMessage); + ErrCode result = cmd.CheckEnableCommandArgument(argument, resultMessage); EXPECT_EQ(result, OHOS::ERR_INVALID_VALUE); - EXPECT_EQ(resultMessage, ": and exist duplicated arguments and exist unknown arguments."); + EXPECT_EQ(resultMessage, ": and exist duplicated argumentsand exist unknown arguments."); EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_ABILITY_TOO_MANY_ARGUMENT); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckEnableCommandArgument_0100 end"; } @@ -981,7 +995,7 @@ AccessibilityAbilityShellCommand_CheckEnableCommandArgument_0100, TestSize.Level * @tc.name: CheckEnableCommandArgument * @tc.desc: Test whether CheckEnableCommandArgument is called normally.(unknownArgumentNum > 0) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_CheckEnableCommandArgument_0200, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckEnableCommandArgument_0200 start"; @@ -993,7 +1007,7 @@ AccessibilityAbilityShellCommand_CheckEnableCommandArgument_0200, TestSize.Level }; int argc = sizeof(argv) / sizeof(argv[0]) - 1; AccessibilityAbilityShellCommand cmd(argc, argv); - ErrCode result = cmd.CheckEnableCommandArgument(argument,resultMessage); + ErrCode result = cmd.CheckEnableCommandArgument(argument, resultMessage); EXPECT_EQ(result, OHOS::ERR_INVALID_VALUE); EXPECT_EQ(resultMessage, ": unknown arguments."); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckEnableCommandArgument_0200 end"; @@ -1004,7 +1018,7 @@ AccessibilityAbilityShellCommand_CheckEnableCommandArgument_0200, TestSize.Level * @tc.name: CheckEnableCommandArgument * @tc.desc: Test whether CheckEnableCommandArgument is called normally.(CheckAbilityArgument = false) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_CheckEnableCommandArgument_0300, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckEnableCommandArgument_0300 start"; @@ -1033,7 +1047,7 @@ AccessibilityAbilityShellCommand_CheckEnableCommandArgument_0300, TestSize.Level * @tc.name: CheckEnableCommandArgument * @tc.desc: Test whether CheckEnableCommandArgument is called normally.(CheckBundleArgument = false) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_CheckEnableCommandArgument_0400, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckEnableCommandArgument_0400 start"; @@ -1062,7 +1076,7 @@ AccessibilityAbilityShellCommand_CheckEnableCommandArgument_0400, TestSize.Level * @tc.name: CheckEnableCommandArgument * @tc.desc: Test whether CheckEnableCommandArgument is called normally.(CheckCapabilitiesArgument = false) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_CheckEnableCommandArgument_0500, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckEnableCommandArgument_0500 start"; @@ -1080,7 +1094,7 @@ AccessibilityAbilityShellCommand_CheckEnableCommandArgument_0500, TestSize.Level }; int argc = sizeof(argv) / sizeof(argv[0]) - 1; AccessibilityAbilityShellCommand cmd(argc, argv); - ErrCode result = cmd.CheckEnableCommandArgument(argument,resultMessage); + ErrCode result = cmd.CheckEnableCommandArgument(argument, resultMessage); EXPECT_EQ(result, OHOS::ERR_INVALID_VALUE); EXPECT_EQ(resultMessage, ": " + ACCESSIBILITY_ABILITY_NO_CAPABILITIES_ARGUMENT); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckEnableCommandArgument_0500 end"; @@ -1091,7 +1105,7 @@ AccessibilityAbilityShellCommand_CheckEnableCommandArgument_0500, TestSize.Level * @tc.name: CheckEnableCommandArgument * @tc.desc: Test whether CheckEnableCommandArgument is called normally.(CheckParamValidity = false) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_CheckEnableCommandArgument_0600, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckEnableCommandArgument_0600 start"; @@ -1109,7 +1123,7 @@ AccessibilityAbilityShellCommand_CheckEnableCommandArgument_0600, TestSize.Level }; int argc = sizeof(argv) / sizeof(argv[0]) - 1; AccessibilityAbilityShellCommand cmd(argc, argv); - ErrCode result = cmd.CheckEnableCommandArgument(argument,resultMessage); + ErrCode result = cmd.CheckEnableCommandArgument(argument, resultMessage); EXPECT_EQ(result, OHOS::ERR_INVALID_VALUE); EXPECT_EQ(resultMessage, ": the auxiliary application bundle/ability" + ACCESSIBILITY_ABILITY_NOT_FOUND); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckEnableCommandArgument_0600 end"; @@ -1121,7 +1135,7 @@ AccessibilityAbilityShellCommand_CheckEnableCommandArgument_0600, TestSize.Level * @tc.desc: Test whether RunAsEnableAbility is called normally. * (MakeEnableCommandArgumentFromCmd = false) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsEnableAbility_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsEnableAbility_0100 start"; @@ -1142,7 +1156,7 @@ AccessibilityAbilityShellCommand_RunAsEnableAbility_0100, TestSize.Level1) * @tc.desc: Test whether RunAsDisableAbility is called normally. * (MakeDisableCommandArgumentFromCmd = OHOS::ERR_INVALID_VALUE) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsDisableAbility_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsDisableAbility_0100 start"; @@ -1162,7 +1176,7 @@ AccessibilityAbilityShellCommand_RunAsDisableAbility_0100, TestSize.Level1) * @tc.name: RunAsGetEnabledAbilities * @tc.desc: Test whether RunAsGetEnabledAbilities is called normally.(enabledAbilities is empty) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsGetEnabledAbilities_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsGetEnabledAbilities_0100 start"; @@ -1181,7 +1195,7 @@ AccessibilityAbilityShellCommand_RunAsGetEnabledAbilities_0100, TestSize.Level1) * @tc.name: RunAsGetInstalledAbilities * @tc.desc: Test whether RunAsGetInstalledAbilities is called normally.(installedAbilities is empty) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsGetInstalledAbilities_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsGetInstalledAbilities_0100 start"; @@ -1202,7 +1216,7 @@ AccessibilityAbilityShellCommand_RunAsGetInstalledAbilities_0100, TestSize.Level * @tc.desc: Test whether RunAsSetScreenMagnificationState is called normally. * (MakeSetCommandArgumentFromCmd = OHOS::ERR_INVALID_VALUE) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetScreenMagnificationState_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetScreenMagnificationState_0100 start"; @@ -1222,7 +1236,7 @@ AccessibilityAbilityShellCommand_RunAsSetScreenMagnificationState_0100, TestSize * @tc.name: RunAsSetScreenMagnificationState * @tc.desc: Test whether RunAsSetScreenMagnificationState is called normally.(OHOS::ERR_OK) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetScreenMagnificationState_0200, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetScreenMagnificationState_0200 start"; @@ -1237,7 +1251,7 @@ AccessibilityAbilityShellCommand_RunAsSetScreenMagnificationState_0200, TestSize AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetScreenMagnificationState(); EXPECT_EQ(result, OHOS::ERR_OK); - EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_SCREEN_MAGNIFICATION_STATE_OK + "\n"); + EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_SCREEN_MAGNIFICATION_STATE_NG + "\n"); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetScreenMagnificationState_0200 end"; } @@ -1246,7 +1260,7 @@ AccessibilityAbilityShellCommand_RunAsSetScreenMagnificationState_0200, TestSize * @tc.name: RunAsSetScreenMagnificationState * @tc.desc: Test whether RunAsSetScreenMagnificationState is called normally.(value is invalid) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetScreenMagnificationState_0300, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetScreenMagnificationState_0200 start"; @@ -1262,7 +1276,7 @@ AccessibilityAbilityShellCommand_RunAsSetScreenMagnificationState_0300, TestSize ErrCode result = cmd.RunAsSetScreenMagnificationState(); EXPECT_EQ(result, OHOS::ERR_INVALID_VALUE); EXPECT_EQ(cmd.resultReceiver_, "setScreenMagnificationState: " + ACCESSIBILITY_ABILITY_SET_VALUE_INVALID + - "\n" + ACCESSIBILITY_HELP_MSG_SET_SCREEN_MAGNIFICATION_STATE); + "\n" + ACCESSIBILITY_HELP_MSG_SET_SCREEN_MAGNIFICATION_STATE); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetScreenMagnificationState_0300 end"; } @@ -1271,7 +1285,7 @@ AccessibilityAbilityShellCommand_RunAsSetScreenMagnificationState_0300, TestSize * @tc.name: RunAsSetShortKeyState * @tc.desc: Test whether RunAsSetShortKeyState is called normally.(OHOS::ERR_OK) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetShortKeyState_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetShortKeyState_0100 start"; @@ -1286,7 +1300,7 @@ AccessibilityAbilityShellCommand_RunAsSetShortKeyState_0100, TestSize.Level1) AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetShortKeyState(); EXPECT_EQ(result, OHOS::ERR_OK); - EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_SHORT_KEY_STATE_OK + "\n"); + EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_SHORT_KEY_STATE_NG + "\n"); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetShortKeyState_0100 end"; } @@ -1295,7 +1309,7 @@ AccessibilityAbilityShellCommand_RunAsSetShortKeyState_0100, TestSize.Level1) * @tc.name: RunAsSetShortKeyState * @tc.desc: Test whether RunAsSetShortKeyState is called normally.(OHOS::ERR_OK) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetShortKeyState_0200, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetShortKeyState_0200 start"; @@ -1310,7 +1324,7 @@ AccessibilityAbilityShellCommand_RunAsSetShortKeyState_0200, TestSize.Level1) AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetShortKeyState(); EXPECT_EQ(result, OHOS::ERR_OK); - EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_SHORT_KEY_STATE_OK + "\n"); + EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_SHORT_KEY_STATE_NG + "\n"); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetShortKeyState_0200 end"; } @@ -1319,7 +1333,7 @@ AccessibilityAbilityShellCommand_RunAsSetShortKeyState_0200, TestSize.Level1) * @tc.name: RunAsSetShortKeyState * @tc.desc: Test whether RunAsSetShortKeyState is called normally.(value is invalid) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetShortKeyState_0300, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetShortKeyState_0300 start"; @@ -1335,7 +1349,7 @@ AccessibilityAbilityShellCommand_RunAsSetShortKeyState_0300, TestSize.Level1) ErrCode result = cmd.RunAsSetShortKeyState(); EXPECT_EQ(result, OHOS::ERR_INVALID_VALUE); EXPECT_EQ(cmd.resultReceiver_, "setShortKeyState: " + ACCESSIBILITY_ABILITY_SET_VALUE_INVALID + - "\n" + ACCESSIBILITY_HELP_MSG_SET_SHORT_KEY_STATE); + "\n" + ACCESSIBILITY_HELP_MSG_SET_SHORT_KEY_STATE); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetShortKeyState_0300 end"; } @@ -1345,7 +1359,7 @@ AccessibilityAbilityShellCommand_RunAsSetShortKeyState_0300, TestSize.Level1) * @tc.desc: Test whether RunAsSetShortKeyState is called normally. * (MakeSetCommandArgumentFromCmd = OHOS::ERR_INVALID_VALUE) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetShortKeyState_0400, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetShortKeyState_0400 start"; @@ -1356,7 +1370,7 @@ AccessibilityAbilityShellCommand_RunAsSetShortKeyState_0400, TestSize.Level1) AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetShortKeyState(); EXPECT_EQ(result, OHOS::ERR_INVALID_VALUE); - EXPECT_EQ(cmd.resultReceiver_, "\n"+ACCESSIBILITY_HELP_MSG_SET_SHORT_KEY_STATE); + EXPECT_EQ(cmd.resultReceiver_, "\n" + ACCESSIBILITY_HELP_MSG_SET_SHORT_KEY_STATE); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetShortKeyState_0400 end"; } @@ -1365,7 +1379,7 @@ AccessibilityAbilityShellCommand_RunAsSetShortKeyState_0400, TestSize.Level1) * @tc.name: RunAsSetMouseKeyState * @tc.desc: Test whether RunAsSetMouseKeyState is called normally.(OHOS::ERR_OK) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetMouseKeyState_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetMouseKeyState_0100 start"; @@ -1380,7 +1394,7 @@ AccessibilityAbilityShellCommand_RunAsSetMouseKeyState_0100, TestSize.Level1) AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetMouseKeyState(); EXPECT_EQ(result, OHOS::ERR_OK); - EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_MOUSE_KEY_STATE_OK + "\n"); + EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_MOUSE_KEY_STATE_NG + "\n"); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetMouseKeyState_0100 end"; } @@ -1389,7 +1403,7 @@ AccessibilityAbilityShellCommand_RunAsSetMouseKeyState_0100, TestSize.Level1) * @tc.name: RunAsSetMouseKeyState * @tc.desc: Test whether RunAsSetMouseKeyState is called normally.(OHOS::ERR_OK) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetMouseKeyState_0200, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetMouseKeyState_0200 start"; @@ -1404,7 +1418,7 @@ AccessibilityAbilityShellCommand_RunAsSetMouseKeyState_0200, TestSize.Level1) AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetMouseKeyState(); EXPECT_EQ(result, OHOS::ERR_OK); - EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_MOUSE_KEY_STATE_OK + "\n"); + EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_MOUSE_KEY_STATE_NG + "\n"); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetMouseKeyState_0200 end"; } @@ -1413,7 +1427,7 @@ AccessibilityAbilityShellCommand_RunAsSetMouseKeyState_0200, TestSize.Level1) * @tc.name: RunAsSetMouseKeyState * @tc.desc: Test whether RunAsSetMouseKeyState is called normally.(value is invalid) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetMouseKeyState_0300, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetMouseKeyState_0300 start"; @@ -1429,7 +1443,7 @@ AccessibilityAbilityShellCommand_RunAsSetMouseKeyState_0300, TestSize.Level1) ErrCode result = cmd.RunAsSetMouseKeyState(); EXPECT_EQ(result, OHOS::ERR_INVALID_VALUE); EXPECT_EQ(cmd.resultReceiver_, "setMouseKeyState: " + ACCESSIBILITY_ABILITY_SET_VALUE_INVALID + - "\n" + ACCESSIBILITY_HELP_MSG_SET_MOUSE_KEY_STATE); + "\n" + ACCESSIBILITY_HELP_MSG_SET_MOUSE_KEY_STATE); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetMouseKeyState_0300 end"; } @@ -1439,7 +1453,7 @@ AccessibilityAbilityShellCommand_RunAsSetMouseKeyState_0300, TestSize.Level1) * @tc.desc: Test whether RunAsSetMouseKeyState is called normally. * (MakeSetCommandArgumentFromCmd = OHOS::ERR_INVALID_VALUE) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetMouseKeyState_0400, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetMouseKeyState_0400 start"; @@ -1450,7 +1464,7 @@ AccessibilityAbilityShellCommand_RunAsSetMouseKeyState_0400, TestSize.Level1) AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetMouseKeyState(); EXPECT_EQ(result, OHOS::ERR_INVALID_VALUE); - EXPECT_EQ(cmd.resultReceiver_, "\n"+ACCESSIBILITY_HELP_MSG_SET_MOUSE_KEY_STATE); + EXPECT_EQ(cmd.resultReceiver_, "\n" + ACCESSIBILITY_HELP_MSG_SET_MOUSE_KEY_STATE); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetMouseKeyState_0400 end"; } @@ -1459,7 +1473,7 @@ AccessibilityAbilityShellCommand_RunAsSetMouseKeyState_0400, TestSize.Level1) * @tc.name: RunAsSetCaptionState * @tc.desc: Test whether RunAsSetCaptionState is called normally.(OHOS::ERR_OK) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetCaptionState_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetCaptionState_0100 start"; @@ -1474,7 +1488,7 @@ AccessibilityAbilityShellCommand_RunAsSetCaptionState_0100, TestSize.Level1) AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetCaptionState(); EXPECT_EQ(result, OHOS::ERR_OK); - EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_CAPTION_STATE_OK + "\n"); + EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_CAPTION_STATE_NG + "\n"); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetCaptionState_0100 end"; } @@ -1483,7 +1497,7 @@ AccessibilityAbilityShellCommand_RunAsSetCaptionState_0100, TestSize.Level1) * @tc.name: RunAsSetCaptionState * @tc.desc: Test whether RunAsSetCaptionState is called normally.(OHOS::ERR_OK) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetCaptionState_0200, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetCaptionState_0200 start"; @@ -1499,7 +1513,7 @@ AccessibilityAbilityShellCommand_RunAsSetCaptionState_0200, TestSize.Level1) AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetCaptionState(); EXPECT_EQ(result, OHOS::ERR_OK); - EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_CAPTION_STATE_OK + "\n"); + EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_CAPTION_STATE_NG + "\n"); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetCaptionState_0200 end"; } @@ -1508,7 +1522,7 @@ AccessibilityAbilityShellCommand_RunAsSetCaptionState_0200, TestSize.Level1) * @tc.name: RunAsSetCaptionState * @tc.desc: Test whether RunAsSetCaptionState is called normally.(value is invalid) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetCaptionState_0300, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetCaptionState_0300 start"; @@ -1524,7 +1538,7 @@ AccessibilityAbilityShellCommand_RunAsSetCaptionState_0300, TestSize.Level1) ErrCode result = cmd.RunAsSetCaptionState(); EXPECT_EQ(result, OHOS::ERR_INVALID_VALUE); EXPECT_EQ(cmd.resultReceiver_, "setCaptionState: " + ACCESSIBILITY_ABILITY_SET_VALUE_INVALID + - "\n" + ACCESSIBILITY_HELP_MSG_SET_CAPTION_STATE); + "\n" + ACCESSIBILITY_HELP_MSG_SET_CAPTION_STATE); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetCaptionState_0300 end"; } @@ -1554,7 +1568,7 @@ AccessibilityAbilityShellCommand_RunAsSetCaptionState_0400, TestSize.Level1) * @tc.name: RunAsSetMouseAutoClick * @tc.desc: Test whether RunAsSetMouseAutoClick is called normally.(OHOS::ERR_OK) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetMouseAutoClick_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetMouseAutoClick_0100 start"; @@ -1569,7 +1583,7 @@ AccessibilityAbilityShellCommand_RunAsSetMouseAutoClick_0100, TestSize.Level1) AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetMouseAutoClick(); EXPECT_EQ(result, OHOS::ERR_OK); - EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_AUTO_CLICK_TIME_OK + "\n"); + EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_AUTO_CLICK_TIME_NG + "\n"); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetMouseAutoClick_0100 end"; } @@ -1578,7 +1592,7 @@ AccessibilityAbilityShellCommand_RunAsSetMouseAutoClick_0100, TestSize.Level1) * @tc.name: RunAsSetMouseAutoClick * @tc.desc: Test whether RunAsSetMouseAutoClick is called normally.(OHOS::ERR_OK) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetMouseAutoClick_0200, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetMouseAutoClick_0200 start"; @@ -1593,7 +1607,7 @@ AccessibilityAbilityShellCommand_RunAsSetMouseAutoClick_0200, TestSize.Level1) AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetMouseAutoClick(); EXPECT_EQ(result, OHOS::ERR_OK); - EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_AUTO_CLICK_TIME_OK + "\n"); + EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_AUTO_CLICK_TIME_NG + "\n"); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetMouseAutoClick_0200 end"; } @@ -1602,7 +1616,7 @@ AccessibilityAbilityShellCommand_RunAsSetMouseAutoClick_0200, TestSize.Level1) * @tc.name: RunAsSetMouseAutoClick * @tc.desc: Test whether RunAsSetMouseAutoClick is called normally.(value is invalid) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetMouseAutoClick_0300, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetMouseAutoClick_0300 start"; @@ -1618,7 +1632,7 @@ AccessibilityAbilityShellCommand_RunAsSetMouseAutoClick_0300, TestSize.Level1) ErrCode result = cmd.RunAsSetMouseAutoClick(); EXPECT_EQ(result, OHOS::ERR_INVALID_VALUE); EXPECT_EQ(cmd.resultReceiver_, "setMouseAutoClick: " + ACCESSIBILITY_ABILITY_SET_VALUE_INVALID + - "\n" + ACCESSIBILITY_HELP_MSG_SET_AUTO_CLICK_TIME); + "\n" + ACCESSIBILITY_HELP_MSG_SET_AUTO_CLICK_TIME); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetMouseAutoClick_0300 end"; } @@ -1628,7 +1642,7 @@ AccessibilityAbilityShellCommand_RunAsSetMouseAutoClick_0300, TestSize.Level1) * @tc.desc: Test whether RunAsSetMouseAutoClick is called normally. * (MakeSetCommandArgumentFromCmd = OHOS::ERR_INVALID_VALUE) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetMouseAutoClick_0400, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetMouseAutoClick_0400 start"; @@ -1639,7 +1653,7 @@ AccessibilityAbilityShellCommand_RunAsSetMouseAutoClick_0400, TestSize.Level1) AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetMouseAutoClick(); EXPECT_EQ(result, OHOS::ERR_INVALID_VALUE); - EXPECT_EQ(cmd.resultReceiver_, "\n"+ACCESSIBILITY_HELP_MSG_SET_AUTO_CLICK_TIME); + EXPECT_EQ(cmd.resultReceiver_, "\n" + ACCESSIBILITY_HELP_MSG_SET_AUTO_CLICK_TIME); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetMouseAutoClick_0400 end"; } @@ -1649,7 +1663,7 @@ AccessibilityAbilityShellCommand_RunAsSetMouseAutoClick_0400, TestSize.Level1) * @tc.desc: Test whether RunAsSetShortKeyTarget is called normally. * (MakeSetShortKeyTargetCommandArgumentFromCmd = OHOS::ERR_INVALID_VALUE) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetShortKeyTarget_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetShortKeyTarget_0100 start"; @@ -1660,7 +1674,7 @@ AccessibilityAbilityShellCommand_RunAsSetShortKeyTarget_0100, TestSize.Level1) AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetShortKeyTarget(); EXPECT_EQ(result, OHOS::ERR_INVALID_VALUE); - EXPECT_EQ(cmd.resultReceiver_, "\n"+ACCESSIBILITY_HELP_MSG_SET_SHORT_KEY_TARGET); + EXPECT_EQ(cmd.resultReceiver_, "\n" + ACCESSIBILITY_HELP_MSG_SET_SHORT_KEY_TARGET); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetShortKeyTarget_0100 end"; } @@ -1669,7 +1683,7 @@ AccessibilityAbilityShellCommand_RunAsSetShortKeyTarget_0100, TestSize.Level1) * @tc.name: RunAsSetHighContrastTextState * @tc.desc: Test whether RunAsSetHighContrastTextState is called normally.(OHOS::ERR_OK) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetHighContrastTextState_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetHighContrastTextState_0100 start"; @@ -1684,7 +1698,7 @@ AccessibilityAbilityShellCommand_RunAsSetHighContrastTextState_0100, TestSize.Le AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetHighContrastTextState(); EXPECT_EQ(result, OHOS::ERR_OK); - EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_HIGH_CONTRAST_TEXT_STATE_OK + "\n"); + EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_HIGH_CONTRAST_TEXT_STATE_NG + "\n"); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetHighContrastTextState_0100 end"; } @@ -1693,7 +1707,7 @@ AccessibilityAbilityShellCommand_RunAsSetHighContrastTextState_0100, TestSize.Le * @tc.name: RunAsSetHighContrastTextState * @tc.desc: Test whether RunAsSetHighContrastTextState is called normally.(OHOS::ERR_OK) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetHighContrastTextState_0200, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetHighContrastTextState_0200 start"; @@ -1708,7 +1722,7 @@ AccessibilityAbilityShellCommand_RunAsSetHighContrastTextState_0200, TestSize.Le AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetHighContrastTextState(); EXPECT_EQ(result, OHOS::ERR_OK); - EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_HIGH_CONTRAST_TEXT_STATE_OK + "\n"); + EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_HIGH_CONTRAST_TEXT_STATE_NG + "\n"); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetHighContrastTextState_0200 end"; } @@ -1717,7 +1731,7 @@ AccessibilityAbilityShellCommand_RunAsSetHighContrastTextState_0200, TestSize.Le * @tc.name: RunAsSetHighContrastTextState * @tc.desc: Test whether RunAsSetHighContrastTextState is called normally.(value is invalid) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetHighContrastTextState_0300, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetHighContrastTextState_0300 start"; @@ -1732,8 +1746,8 @@ AccessibilityAbilityShellCommand_RunAsSetHighContrastTextState_0300, TestSize.Le AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetHighContrastTextState(); EXPECT_EQ(result, OHOS::ERR_INVALID_VALUE); - EXPECT_EQ(cmd.resultReceiver_, "setHighContrastTextState: "+ ACCESSIBILITY_ABILITY_SET_VALUE_INVALID + - "\n" + ACCESSIBILITY_HELP_MSG_HIGH_CONTRAST_TEXT_STATE); + EXPECT_EQ(cmd.resultReceiver_, "setHighContrastTextState: " + ACCESSIBILITY_ABILITY_SET_VALUE_INVALID + + "\n" + ACCESSIBILITY_HELP_MSG_HIGH_CONTRAST_TEXT_STATE); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetHighContrastTextState_0300 end"; } @@ -1743,7 +1757,7 @@ AccessibilityAbilityShellCommand_RunAsSetHighContrastTextState_0300, TestSize.Le * @tc.desc: Test whether RunAsSetHighContrastTextState is called normally. * (MakeSetCommandArgumentFromCmd = OHOS::ERR_INVALID_VALUE) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetHighContrastTextState_0400, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetHighContrastTextState_0400 start"; @@ -1763,7 +1777,7 @@ AccessibilityAbilityShellCommand_RunAsSetHighContrastTextState_0400, TestSize.Le * @tc.name: RunAsSetInvertColorState * @tc.desc: Test whether RunAsSetInvertColorState is called normally.(OHOS::ERR_OK) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetInvertColorState_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetInvertColorState_0100 start"; @@ -1778,7 +1792,7 @@ AccessibilityAbilityShellCommand_RunAsSetInvertColorState_0100, TestSize.Level1) AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetInvertColorState(); EXPECT_EQ(result, OHOS::ERR_OK); - EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_INVERT_COLOR_STATE_OK + "\n"); + EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_INVERT_COLOR_STATE_NG + "\n"); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetInvertColorState_0100 end"; } @@ -1787,7 +1801,7 @@ AccessibilityAbilityShellCommand_RunAsSetInvertColorState_0100, TestSize.Level1) * @tc.name: RunAsSetInvertColorState * @tc.desc: Test whether RunAsSetInvertColorState is called normally.(OHOS::ERR_OK) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetInvertColorState_0200, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetInvertColorState_0200 start"; @@ -1802,7 +1816,7 @@ AccessibilityAbilityShellCommand_RunAsSetInvertColorState_0200, TestSize.Level1) AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetInvertColorState(); EXPECT_EQ(result, OHOS::ERR_OK); - EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_INVERT_COLOR_STATE_OK + "\n"); + EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_INVERT_COLOR_STATE_NG + "\n"); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetInvertColorState_0200 end"; } @@ -1811,7 +1825,7 @@ AccessibilityAbilityShellCommand_RunAsSetInvertColorState_0200, TestSize.Level1) * @tc.name: RunAsSetInvertColorState * @tc.desc: Test whether RunAsSetInvertColorState is called normally.(value is invalid) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetInvertColorState_0300, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetInvertColorState_0300 start"; @@ -1827,7 +1841,7 @@ AccessibilityAbilityShellCommand_RunAsSetInvertColorState_0300, TestSize.Level1) ErrCode result = cmd.RunAsSetInvertColorState(); EXPECT_EQ(result, OHOS::ERR_INVALID_VALUE); EXPECT_EQ(cmd.resultReceiver_, "setInvertColorState: "+ ACCESSIBILITY_ABILITY_SET_VALUE_INVALID + - "\n" + ACCESSIBILITY_HELP_MSG_SET_INVERT_COLOR_STATE); + "\n" + ACCESSIBILITY_HELP_MSG_SET_INVERT_COLOR_STATE); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetInvertColorState_0300 end"; } @@ -1837,7 +1851,7 @@ AccessibilityAbilityShellCommand_RunAsSetInvertColorState_0300, TestSize.Level1) * @tc.desc: Test whether RunAsSetInvertColorState is called normally. * (MakeSetCommandArgumentFromCmd = OHOS::ERR_INVALID_VALUE) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetInvertColorState_0400, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetInvertColorState_0400 start"; @@ -1848,7 +1862,7 @@ AccessibilityAbilityShellCommand_RunAsSetInvertColorState_0400, TestSize.Level1) AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetInvertColorState(); EXPECT_EQ(result, OHOS::ERR_INVALID_VALUE); - EXPECT_EQ(cmd.resultReceiver_, "\n"+ACCESSIBILITY_HELP_MSG_SET_INVERT_COLOR_STATE); + EXPECT_EQ(cmd.resultReceiver_, "\n" + ACCESSIBILITY_HELP_MSG_SET_INVERT_COLOR_STATE); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetInvertColorState_0400 end"; } @@ -1857,7 +1871,7 @@ AccessibilityAbilityShellCommand_RunAsSetInvertColorState_0400, TestSize.Level1) * @tc.name: RunAsSetDaltonizationColorFilter * @tc.desc: Test whether RunAsSetDaltonizationColorFilter is called normally.(OHOS::ERR_OK) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetDaltonizationColorFilter_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetDaltonizationColorFilter_0100 start"; @@ -1872,7 +1886,7 @@ AccessibilityAbilityShellCommand_RunAsSetDaltonizationColorFilter_0100, TestSize AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetDaltonizationColorFilter(); EXPECT_EQ(result, OHOS::ERR_OK); - EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_DALTONIZATIONZATION_COLOR_FILTER_OK + "\n"); + EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_DALTONIZATIONZATION_COLOR_FILTER_NG + "\n"); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetDaltonizationColorFilter_0100 end"; } @@ -1881,7 +1895,7 @@ AccessibilityAbilityShellCommand_RunAsSetDaltonizationColorFilter_0100, TestSize * @tc.name: RunAsSetDaltonizationColorFilter * @tc.desc: Test whether RunAsSetDaltonizationColorFilter is called normally.(OHOS::ERR_OK) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetDaltonizationColorFilter_0200, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetDaltonizationColorFilter_0200 start"; @@ -1896,7 +1910,7 @@ AccessibilityAbilityShellCommand_RunAsSetDaltonizationColorFilter_0200, TestSize AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetDaltonizationColorFilter(); EXPECT_EQ(result, OHOS::ERR_OK); - EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_DALTONIZATIONZATION_COLOR_FILTER_OK + "\n"); + EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_DALTONIZATIONZATION_COLOR_FILTER_NG + "\n"); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetDaltonizationColorFilter_0200 end"; } @@ -1905,7 +1919,7 @@ AccessibilityAbilityShellCommand_RunAsSetDaltonizationColorFilter_0200, TestSize * @tc.name: RunAsSetDaltonizationColorFilter * @tc.desc: Test whether RunAsSetDaltonizationColorFilter is called normally.(OHOS::ERR_OK) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetDaltonizationColorFilter_0300, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetDaltonizationColorFilter_0300 start"; @@ -1920,7 +1934,7 @@ AccessibilityAbilityShellCommand_RunAsSetDaltonizationColorFilter_0300, TestSize AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetDaltonizationColorFilter(); EXPECT_EQ(result, OHOS::ERR_OK); - EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_DALTONIZATIONZATION_COLOR_FILTER_OK + "\n"); + EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_DALTONIZATIONZATION_COLOR_FILTER_NG + "\n"); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetDaltonizationColorFilter_0300 end"; } @@ -1929,7 +1943,7 @@ AccessibilityAbilityShellCommand_RunAsSetDaltonizationColorFilter_0300, TestSize * @tc.name: RunAsSetDaltonizationColorFilter * @tc.desc: Test whether RunAsSetDaltonizationColorFilter is called normally.(OHOS::ERR_OK) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetDaltonizationColorFilter_0400, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetDaltonizationColorFilter_0400 start"; @@ -1944,7 +1958,7 @@ AccessibilityAbilityShellCommand_RunAsSetDaltonizationColorFilter_0400, TestSize AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetDaltonizationColorFilter(); EXPECT_EQ(result, OHOS::ERR_OK); - EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_DALTONIZATIONZATION_COLOR_FILTER_OK + "\n"); + EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_DALTONIZATIONZATION_COLOR_FILTER_NG + "\n"); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetDaltonizationColorFilter_0400 end"; } @@ -1953,7 +1967,7 @@ AccessibilityAbilityShellCommand_RunAsSetDaltonizationColorFilter_0400, TestSize * @tc.name: RunAsSetDaltonizationColorFilter * @tc.desc: Test whether RunAsSetDaltonizationColorFilter is called normally.(value is invalid) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetDaltonizationColorFilter_0500, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetDaltonizationColorFilter_0500 start"; @@ -1968,7 +1982,7 @@ AccessibilityAbilityShellCommand_RunAsSetDaltonizationColorFilter_0500, TestSize AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetDaltonizationColorFilter(); EXPECT_EQ(result, OHOS::ERR_INVALID_VALUE); - EXPECT_EQ(cmd.resultReceiver_, "setDaltonizationColorFilter: "+ ACCESSIBILITY_ABILITY_SET_VALUE_INVALID); + EXPECT_EQ(cmd.resultReceiver_, "setDaltonizationColorFilter: " + ACCESSIBILITY_ABILITY_SET_VALUE_INVALID); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetDaltonizationColorFilter_0500 end"; } @@ -1978,7 +1992,7 @@ AccessibilityAbilityShellCommand_RunAsSetDaltonizationColorFilter_0500, TestSize * @tc.desc: Test whether RunAsSetDaltonizationColorFilter is called normally. * (MakeSetCommandArgumentFromCmd = OHOS::ERR_INVALID_VALUE) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetDaltonizationColorFilter_0600, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetDaltonizationColorFilter_0600 start"; @@ -1989,7 +2003,7 @@ AccessibilityAbilityShellCommand_RunAsSetDaltonizationColorFilter_0600, TestSize AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetDaltonizationColorFilter(); EXPECT_EQ(result, OHOS::ERR_INVALID_VALUE); - EXPECT_EQ(cmd.resultReceiver_, "\n"+ACCESSIBILITY_HELP_MSG_SET_DALTONIZATION_COLOR_FILTER); + EXPECT_EQ(cmd.resultReceiver_, "\n" + ACCESSIBILITY_HELP_MSG_SET_DALTONIZATION_COLOR_FILTER); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetDaltonizationColorFilter_0600 end"; } @@ -1998,7 +2012,7 @@ AccessibilityAbilityShellCommand_RunAsSetDaltonizationColorFilter_0600, TestSize * @tc.name: RunAsSetContentTimeout * @tc.desc: Test whether RunAsSetContentTimeout is called normally.(OHOS::ERR_OK) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetContentTimeout_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetContentTimeout_0100 start"; @@ -2013,7 +2027,7 @@ AccessibilityAbilityShellCommand_RunAsSetContentTimeout_0100, TestSize.Level1) AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetContentTimeout(); EXPECT_EQ(result, OHOS::ERR_OK); - EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_CONTENT_TIME_OK + "\n"); + EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_CONTENT_TIME_NG + "\n"); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetContentTimeout_0100 end"; } @@ -2022,7 +2036,7 @@ AccessibilityAbilityShellCommand_RunAsSetContentTimeout_0100, TestSize.Level1) * @tc.name: RunAsSetContentTimeout * @tc.desc: Test whether RunAsSetContentTimeout is called normally.(OHOS::ERR_OK) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetContentTimeout_0200, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetContentTimeout_0200 start"; @@ -2038,7 +2052,7 @@ AccessibilityAbilityShellCommand_RunAsSetContentTimeout_0200, TestSize.Level1) AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetContentTimeout(); EXPECT_EQ(result, OHOS::ERR_OK); - EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_CONTENT_TIME_OK + "\n"); + EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_CONTENT_TIME_NG + "\n"); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetContentTimeout_0200 end"; } @@ -2047,7 +2061,7 @@ AccessibilityAbilityShellCommand_RunAsSetContentTimeout_0200, TestSize.Level1) * @tc.name: RunAsSetContentTimeout * @tc.desc: Test whether RunAsSetContentTimeout is called normally.(value is invalid) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetContentTimeout_0300, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetContentTimeout_0300 start"; @@ -2062,8 +2076,8 @@ AccessibilityAbilityShellCommand_RunAsSetContentTimeout_0300, TestSize.Level1) AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetContentTimeout(); EXPECT_EQ(result, OHOS::ERR_INVALID_VALUE); - EXPECT_EQ(cmd.resultReceiver_, "setContentTimeout: "+ ACCESSIBILITY_ABILITY_SET_VALUE_INVALID + - "\n" + ACCESSIBILITY_HELP_MSG_SET_CONTENT_TIME_OUT); + EXPECT_EQ(cmd.resultReceiver_, "setContentTimeout: " + ACCESSIBILITY_ABILITY_SET_VALUE_INVALID + + "\n" + ACCESSIBILITY_HELP_MSG_SET_CONTENT_TIME_OUT); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetContentTimeout_0300 end"; } @@ -2073,7 +2087,7 @@ AccessibilityAbilityShellCommand_RunAsSetContentTimeout_0300, TestSize.Level1) * @tc.desc: Test whether RunAsSetContentTimeout is called normally. * (MakeSetCommandArgumentFromCmd = OHOS::ERR_INVALID_VALUE) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetContentTimeout_0400, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetContentTimeout_0400 start"; @@ -2093,7 +2107,7 @@ AccessibilityAbilityShellCommand_RunAsSetContentTimeout_0400, TestSize.Level1) * @tc.name: RunAsSetAnimationOffState * @tc.desc: Test whether RunAsSetAnimationOffState is called normally.(OHOS::ERR_OK) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetAnimationOffState_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetAnimationOffState_0100 start"; @@ -2108,7 +2122,7 @@ AccessibilityAbilityShellCommand_RunAsSetAnimationOffState_0100, TestSize.Level1 AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetAnimationOffState(); EXPECT_EQ(result, OHOS::ERR_OK); - EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_ANIMATION_OFF_STATE_OK + "\n"); + EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_ANIMATION_OFF_STATE_NG + "\n"); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetAnimationOffState_0100 end"; } @@ -2117,7 +2131,7 @@ AccessibilityAbilityShellCommand_RunAsSetAnimationOffState_0100, TestSize.Level1 * @tc.name: RunAsSetAnimationOffState * @tc.desc: Test whether RunAsSetAnimationOffState is called normally.(OHOS::ERR_OK) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetAnimationOffState_0200, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetAnimationOffState_0200 start"; @@ -2132,7 +2146,7 @@ AccessibilityAbilityShellCommand_RunAsSetAnimationOffState_0200, TestSize.Level1 AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetAnimationOffState(); EXPECT_EQ(result, OHOS::ERR_OK); - EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_ANIMATION_OFF_STATE_OK + "\n"); + EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_ANIMATION_OFF_STATE_NG + "\n"); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetAnimationOffState_0200 end"; } @@ -2141,7 +2155,7 @@ AccessibilityAbilityShellCommand_RunAsSetAnimationOffState_0200, TestSize.Level1 * @tc.name: RunAsSetAnimationOffState * @tc.desc: Test whether RunAsSetAnimationOffState is called normally.(value is invalid) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetAnimationOffState_0300, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetAnimationOffState_0300 start"; @@ -2156,8 +2170,8 @@ AccessibilityAbilityShellCommand_RunAsSetAnimationOffState_0300, TestSize.Level1 AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetAnimationOffState(); EXPECT_EQ(result, OHOS::ERR_INVALID_VALUE); - EXPECT_EQ(cmd.resultReceiver_, "setAnimationOffState: "+ ACCESSIBILITY_ABILITY_SET_VALUE_INVALID + - "\n" + ACCESSIBILITY_HELP_MSG_ANIMATION_OFF_STATE); + EXPECT_EQ(cmd.resultReceiver_, "setAnimationOffState: " + ACCESSIBILITY_ABILITY_SET_VALUE_INVALID + + "\n" + ACCESSIBILITY_HELP_MSG_ANIMATION_OFF_STATE); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetAnimationOffState_0300 end"; } @@ -2167,7 +2181,7 @@ AccessibilityAbilityShellCommand_RunAsSetAnimationOffState_0300, TestSize.Level1 * @tc.desc: Test whether RunAsSetAnimationOffState is called normally. * (MakeSetCommandArgumentFromCmd = OHOS::ERR_INVALID_VALUE) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetAnimationOffState_0400, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetAnimationOffState_0400 start"; @@ -2188,7 +2202,7 @@ AccessibilityAbilityShellCommand_RunAsSetAnimationOffState_0400, TestSize.Level1 * @tc.desc: 1.Test whether RunAsSetBrightnessDiscount is called normally.(OHOS::ERR_OK) * 2.ret is not Accessibility::RET_OK */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetBrightnessDiscount_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetBrightnessDiscount_0100 start"; @@ -2215,7 +2229,7 @@ AccessibilityAbilityShellCommand_RunAsSetBrightnessDiscount_0100, TestSize.Level * @tc.desc: 1.Test whether RunAsSetBrightnessDiscount is called normally.(OHOS::ERR_OK) * 2.ret is Accessibility::RET_OK */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetBrightnessDiscount_0200, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetBrightnessDiscount_0200 start"; @@ -2240,7 +2254,7 @@ AccessibilityAbilityShellCommand_RunAsSetBrightnessDiscount_0200, TestSize.Level * @tc.name: RunAsSetBrightnessDiscount * @tc.desc: Test whether RunAsSetBrightnessDiscount is called normally.(value is invalid) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetBrightnessDiscount_0300, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetBrightnessDiscount_0300 start"; @@ -2255,8 +2269,8 @@ AccessibilityAbilityShellCommand_RunAsSetBrightnessDiscount_0300, TestSize.Level AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetBrightnessDiscount(); EXPECT_EQ(result, OHOS::ERR_INVALID_VALUE); - EXPECT_EQ(cmd.resultReceiver_, "setSetBrightnessDiscount: "+ ACCESSIBILITY_ABILITY_SET_VALUE_INVALID + - "\n" + ACCESSIBILITY_HELP_MSG_SET_BRIGHTNESS_DISCOUNT); + EXPECT_EQ(cmd.resultReceiver_, "setSetBrightnessDiscount: " + ACCESSIBILITY_ABILITY_SET_VALUE_INVALID + + "\n" + ACCESSIBILITY_HELP_MSG_SET_BRIGHTNESS_DISCOUNT); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetBrightnessDiscount_0300 end"; } @@ -2266,7 +2280,7 @@ AccessibilityAbilityShellCommand_RunAsSetBrightnessDiscount_0300, TestSize.Level * @tc.desc: Test whether RunAsSetBrightnessDiscount is called normally. * (MakeSetCommandArgumentFromCmd = OHOS::ERR_INVALID_VALUE) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetBrightnessDiscount_0400, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetBrightnessDiscount_0400 start"; @@ -2286,7 +2300,7 @@ AccessibilityAbilityShellCommand_RunAsSetBrightnessDiscount_0400, TestSize.Level * @tc.name: RunAsSetAudioMonoState * @tc.desc: Test whether RunAsSetAudioMonoState is called normally.(OHOS::ERR_OK) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetAudioMonoState_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetAudioMonoState_0100 start"; @@ -2301,7 +2315,7 @@ AccessibilityAbilityShellCommand_RunAsSetAudioMonoState_0100, TestSize.Level1) AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetAudioMonoState(); EXPECT_EQ(result, OHOS::ERR_OK); - EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_AUDIO_MONO_STATE_OK + "\n"); + EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_AUDIO_MONO_STATE_NG + "\n"); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetAudioMonoState_0100 end"; } @@ -2310,7 +2324,7 @@ AccessibilityAbilityShellCommand_RunAsSetAudioMonoState_0100, TestSize.Level1) * @tc.name: RunAsSetAudioMonoState * @tc.desc: Test whether RunAsSetAudioMonoState is called normally.(OHOS::ERR_OK) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetAudioMonoState_0200, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetAudioMonoState_0200 start"; @@ -2325,7 +2339,7 @@ AccessibilityAbilityShellCommand_RunAsSetAudioMonoState_0200, TestSize.Level1) AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetAudioMonoState(); EXPECT_EQ(result, OHOS::ERR_OK); - EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_AUDIO_MONO_STATE_OK + "\n"); + EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_AUDIO_MONO_STATE_NG + "\n"); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetAudioMonoState_0200 end"; } @@ -2334,7 +2348,7 @@ AccessibilityAbilityShellCommand_RunAsSetAudioMonoState_0200, TestSize.Level1) * @tc.name: RunAsSetAudioMonoState * @tc.desc: Test whether RunAsSetAudioMonoState is called normally.(value is invalid) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetAudioMonoState_0300, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetAudioMonoState_0300 start"; @@ -2349,8 +2363,8 @@ AccessibilityAbilityShellCommand_RunAsSetAudioMonoState_0300, TestSize.Level1) AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetAudioMonoState(); EXPECT_EQ(result, OHOS::ERR_INVALID_VALUE); - EXPECT_EQ(cmd.resultReceiver_, "setAudioMonoState: "+ ACCESSIBILITY_ABILITY_SET_VALUE_INVALID + - "\n" + ACCESSIBILITY_HELP_MSG_SET_AUDIO_MONO_STATE); + EXPECT_EQ(cmd.resultReceiver_, "setAudioMonoState: " + ACCESSIBILITY_ABILITY_SET_VALUE_INVALID + + "\n" + ACCESSIBILITY_HELP_MSG_SET_AUDIO_MONO_STATE); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetAudioMonoState_0300 end"; } @@ -2360,7 +2374,7 @@ AccessibilityAbilityShellCommand_RunAsSetAudioMonoState_0300, TestSize.Level1) * @tc.desc: Test whether RunAsSetAudioMonoState is called normally. * (MakeSetCommandArgumentFromCmd = OHOS::ERR_INVALID_VALUE) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetAudioMonoState_0400, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetAudioMonoState_0400 start"; @@ -2380,7 +2394,7 @@ AccessibilityAbilityShellCommand_RunAsSetAudioMonoState_0400, TestSize.Level1) * @tc.name: RunAsSetAudioBalance * @tc.desc: Test whether RunAsSetAudioBalance is called normally.(OHOS::ERR_OK) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetAudioBalance_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetAudioBalance_0100 start"; @@ -2395,7 +2409,7 @@ AccessibilityAbilityShellCommand_RunAsSetAudioBalance_0100, TestSize.Level1) AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetAudioBalance(); EXPECT_EQ(result, OHOS::ERR_OK); - EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_AUDIO_BALANCE_OK + "\n"); + EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_AUDIO_BALANCE_NG); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetAudioBalance_0100 end"; } @@ -2404,7 +2418,7 @@ AccessibilityAbilityShellCommand_RunAsSetAudioBalance_0100, TestSize.Level1) * @tc.name: RunAsSetAudioBalance * @tc.desc: Test whether RunAsSetAudioBalance is called normally.(OHOS::ERR_OK) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetAudioBalance_0200, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetAudioBalance_0200 start"; @@ -2419,7 +2433,7 @@ AccessibilityAbilityShellCommand_RunAsSetAudioBalance_0200, TestSize.Level1) AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetAudioBalance(); EXPECT_EQ(result, OHOS::ERR_OK); - EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_AUDIO_BALANCE_OK + "\n"); + EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_AUDIO_BALANCE_NG); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetAudioBalance_0200 end"; } @@ -2428,7 +2442,7 @@ AccessibilityAbilityShellCommand_RunAsSetAudioBalance_0200, TestSize.Level1) * @tc.name: RunAsSetAudioBalance * @tc.desc: Test whether RunAsSetAudioBalance is called normally.(value is invalid) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetAudioBalance_0300, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetAudioBalance_0300 start"; @@ -2443,8 +2457,8 @@ AccessibilityAbilityShellCommand_RunAsSetAudioBalance_0300, TestSize.Level1) AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetAudioBalance(); EXPECT_EQ(result, OHOS::ERR_INVALID_VALUE); - EXPECT_EQ(cmd.resultReceiver_, "setAudioBalance: "+ ACCESSIBILITY_ABILITY_SET_VALUE_INVALID + - "\n" + ACCESSIBILITY_HELP_MSG_SET_AUDIO_BALANCE); + EXPECT_EQ(cmd.resultReceiver_, "setAudioBalance: " + ACCESSIBILITY_ABILITY_SET_VALUE_INVALID + + "\n" + ACCESSIBILITY_HELP_MSG_SET_AUDIO_BALANCE); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetAudioBalance_0300 end"; } @@ -2454,7 +2468,7 @@ AccessibilityAbilityShellCommand_RunAsSetAudioBalance_0300, TestSize.Level1) * @tc.desc: Test whether RunAsSetAudioBalance is called normally. * (MakeSetCommandArgumentFromCmd = OHOS::ERR_INVALID_VALUE) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetAudioBalance_0400, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetAudioBalance_0400 start"; @@ -2475,7 +2489,7 @@ AccessibilityAbilityShellCommand_RunAsSetAudioBalance_0400, TestSize.Level1) * @tc.desc: Test whether MakeSetShortKeyTargetCommandArgumentFromCmd is called normally. * (MakeCommandArgumentFromCmd = OHOS::ERR_OK,MakeCommandArgumentFromCmd = OHOS::ERR_INVALID_VALUE) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_MakeSetShortKeyTargetCommandArgumentFromCmd_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_MakeSetShortKeyTargetCommandArgumentFromCmd_0100 start"; @@ -2504,7 +2518,7 @@ AccessibilityAbilityShellCommand_MakeSetShortKeyTargetCommandArgumentFromCmd_010 * @tc.name: MakeSetCommandArgumentFromCmd * @tc.desc: Test whether MakeSetCommandArgumentFromCmd is called normally.(OHOS::ERR_OK) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_MakeSetCommandArgumentFromCmd_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_MakeSetCommandArgumentFromCmd_0100 start"; @@ -2530,7 +2544,7 @@ AccessibilityAbilityShellCommand_MakeSetCommandArgumentFromCmd_0100, TestSize.Le * @tc.name: MakeSetCommandArgumentFromCmd * @tc.desc: Test whether MakeSetCommandArgumentFromCmd is called normally.(optind < 0) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_MakeSetCommandArgumentFromCmd_0200, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_MakeSetCommandArgumentFromCmd_0200 start"; @@ -2551,7 +2565,7 @@ AccessibilityAbilityShellCommand_MakeSetCommandArgumentFromCmd_0200, TestSize.Le * @tc.name: MakeSetCommandArgumentFromCmd * @tc.desc: Test whether MakeSetCommandArgumentFromCmd is called normally.(option = -1) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_MakeSetCommandArgumentFromCmd_0300, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_MakeSetCommandArgumentFromCmd_0300 start"; @@ -2573,7 +2587,7 @@ AccessibilityAbilityShellCommand_MakeSetCommandArgumentFromCmd_0300, TestSize.Le * @tc.name: MakeSetCommandArgumentFromCmd * @tc.desc: Test whether MakeSetCommandArgumentFromCmd is called normally.(option = ?) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_MakeSetCommandArgumentFromCmd_0400, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_MakeSetCommandArgumentFromCmd_0400 start"; @@ -2597,7 +2611,7 @@ AccessibilityAbilityShellCommand_MakeSetCommandArgumentFromCmd_0400, TestSize.Le * @tc.name: MakeSetCommandArgumentFromCmd * @tc.desc: Test whether MakeSetCommandArgumentFromCmd is called normally.(option = default) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_MakeSetCommandArgumentFromCmd_0500, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_MakeSetCommandArgumentFromCmd_0500 start"; @@ -2621,7 +2635,7 @@ AccessibilityAbilityShellCommand_MakeSetCommandArgumentFromCmd_0500, TestSize.Le * @tc.name: MakeCommandArgumentFromCmd * @tc.desc: Test whether MakeCommandArgumentFromCmd is called normally.(return OHOS::ERR_OK) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_MakeCommandArgumentFromCmd_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_MakeCommandArgumentFromCmd_0100 start"; @@ -2648,7 +2662,7 @@ AccessibilityAbilityShellCommand_MakeCommandArgumentFromCmd_0100, TestSize.Level * @tc.name: MakeCommandArgumentFromCmd * @tc.desc: Test whether MakeCommandArgumentFromCmd is called normally.(return OHOS::ERR_OK,option a b) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_MakeCommandArgumentFromCmd_0200, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_MakeCommandArgumentFromCmd_0200 start"; @@ -2676,7 +2690,7 @@ AccessibilityAbilityShellCommand_MakeCommandArgumentFromCmd_0200, TestSize.Level * @tc.name: MakeCommandArgumentFromCmd * @tc.desc: Test whether MakeCommandArgumentFromCmd is called normally.(missing options) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_MakeCommandArgumentFromCmd_0300, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_MakeCommandArgumentFromCmd_0300 start"; @@ -2699,7 +2713,7 @@ AccessibilityAbilityShellCommand_MakeCommandArgumentFromCmd_0300, TestSize.Level * @tc.name: MakeCommandArgumentFromCmd * @tc.desc: Test whether MakeCommandArgumentFromCmd is called normally.(NO_ABILITY) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_MakeCommandArgumentFromCmd_0400, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_MakeCommandArgumentFromCmd_0400 start"; @@ -2723,7 +2737,7 @@ AccessibilityAbilityShellCommand_MakeCommandArgumentFromCmd_0400, TestSize.Level * @tc.name: MakeCommandArgumentFromCmd * @tc.desc: Test whether MakeCommandArgumentFromCmd is called normally.(NO_BUNDLE) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_MakeCommandArgumentFromCmd_0500, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_MakeCommandArgumentFromCmd_0500 start"; @@ -2749,7 +2763,7 @@ AccessibilityAbilityShellCommand_MakeCommandArgumentFromCmd_0500, TestSize.Level * @tc.name: MakeCommandArgumentFromCmd * @tc.desc: Test whether MakeCommandArgumentFromCmd is called normally.(optind = -1) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_MakeCommandArgumentFromCmd_0600, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_MakeCommandArgumentFromCmd_0600 start"; @@ -2771,7 +2785,7 @@ AccessibilityAbilityShellCommand_MakeCommandArgumentFromCmd_0600, TestSize.Level * @tc.desc: Test whether MakeDisableCommandArgumentFromCmd is called normally. * (MakeCommandArgumentFromCmd = OHOS::ERR_OK,CheckDisableCommandArgument = OHOS::ERR_INVALID_VALUE) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_MakeDisableCommandArgumentFromCmd_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_MakeDisableCommandArgumentFromCmd_0100 start"; @@ -2804,7 +2818,7 @@ AccessibilityAbilityShellCommand_MakeDisableCommandArgumentFromCmd_0100, TestSiz * @tc.desc: Test whether CheckDisableCommandArgument is called normally. * (CheckCommandArgument = OHOS::ERR_INVALID_VALUE) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_CheckDisableCommandArgument_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckDisableCommandArgument_0100 start"; @@ -2832,7 +2846,7 @@ AccessibilityAbilityShellCommand_CheckDisableCommandArgument_0100, TestSize.Leve * @tc.name: CheckCommandArgument * @tc.desc: Test whether CheckCommandArgument is called normally.(totalArgumentNum > 2) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_CheckCommandArgument_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckCommandArgument_0100 start"; @@ -2861,7 +2875,7 @@ AccessibilityAbilityShellCommand_CheckCommandArgument_0100, TestSize.Level1) * @tc.name: CheckCommandArgument * @tc.desc: Test whether CheckCommandArgument is called normally.(unknownArgumentNum > 0) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_CheckCommandArgument_0200, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckCommandArgument_0200 start"; @@ -2889,7 +2903,7 @@ AccessibilityAbilityShellCommand_CheckCommandArgument_0200, TestSize.Level1) * @tc.name: CheckCommandArgument * @tc.desc: Test whether CheckCommandArgument is called normally.(CheckAbilityArgument = false) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_CheckCommandArgument_0300, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckCommandArgument_0300 start"; @@ -2906,7 +2920,7 @@ AccessibilityAbilityShellCommand_CheckCommandArgument_0300, TestSize.Level1) }; int argc = sizeof(argv) / sizeof(argv[0]) - 1; AccessibilityAbilityShellCommand cmd(argc, argv); - ErrCode result = cmd.CheckCommandArgument(argument,resultMessage); + ErrCode result = cmd.CheckCommandArgument(argument, resultMessage); EXPECT_EQ(result, OHOS::ERR_INVALID_VALUE); EXPECT_EQ(resultMessage, ": " + ACCESSIBILITY_ABILITY_NO_ABILITY_ARGUMENT); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckCommandArgument_0300 end"; @@ -2917,7 +2931,7 @@ AccessibilityAbilityShellCommand_CheckCommandArgument_0300, TestSize.Level1) * @tc.name: CheckCommandArgument * @tc.desc: Test whether CheckCommandArgument is called normally.(CheckBundleArgument = false) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_CheckCommandArgument_0400, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckCommandArgument_0400 start"; @@ -2934,7 +2948,7 @@ AccessibilityAbilityShellCommand_CheckCommandArgument_0400, TestSize.Level1) }; int argc = sizeof(argv) / sizeof(argv[0]) - 1; AccessibilityAbilityShellCommand cmd(argc, argv); - ErrCode result = cmd.CheckCommandArgument(argument,resultMessage); + ErrCode result = cmd.CheckCommandArgument(argument, resultMessage); EXPECT_EQ(result, OHOS::ERR_INVALID_VALUE); EXPECT_EQ(resultMessage, ": " + ACCESSIBILITY_ABILITY_NO_BUNDLE_ARGUMENT); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckCommandArgument_0400 end"; @@ -2945,7 +2959,7 @@ AccessibilityAbilityShellCommand_CheckCommandArgument_0400, TestSize.Level1) * @tc.name: CheckCommandArgument * @tc.desc: Test whether CheckCommandArgument is called normally.(CheckParamValidity = false) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_CheckCommandArgument_0500, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckCommandArgument_0500 start"; @@ -2962,10 +2976,10 @@ AccessibilityAbilityShellCommand_CheckCommandArgument_0500, TestSize.Level1) }; int argc = sizeof(argv) / sizeof(argv[0]) - 1; AccessibilityAbilityShellCommand cmd(argc, argv); - ErrCode result = cmd.CheckCommandArgument(argument,resultMessage); + ErrCode result = cmd.CheckCommandArgument(argument, resultMessage); EXPECT_EQ(result, OHOS::ERR_INVALID_VALUE); - EXPECT_EQ(resultMessage, ": the auxiliary application " + - argument.bundleName + "/" + argument.abilityName + ACCESSIBILITY_ABILITY_NOT_FOUND); + EXPECT_EQ(resultMessage, ": the auxiliary application " + argument.bundleName + "/" + + argument.abilityName + ACCESSIBILITY_ABILITY_NOT_FOUND); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckCommandArgument_0500 end"; } } // namespace AAFwk From 87735a67dafaad7ecc27725fe99236ae50b397bd Mon Sep 17 00:00:00 2001 From: root Date: Thu, 16 May 2024 16:25:53 +0800 Subject: [PATCH 144/174] Issue: https://gitee.com/openharmony/ability_ability_runtime/issues/I9O1FY MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Comment: ability_runtime仓库对于第三方json整改 Signed-off-by: root --- frameworks/js/napi/ability_constant/BUILD.gn | 4 ++-- frameworks/native/ability/native/BUILD.gn | 13 +++++-------- frameworks/native/appkit/BUILD.gn | 10 +++++----- interfaces/inner_api/app_manager/BUILD.gn | 2 +- interfaces/inner_api/dataobs_manager/BUILD.gn | 5 +---- interfaces/inner_api/runtime/BUILD.gn | 2 +- services/abilitymgr/BUILD.gn | 2 +- services/appmgr/BUILD.gn | 2 +- services/dataobsmgr/BUILD.gn | 3 +-- services/uripermmgr/BUILD.gn | 1 - 10 files changed, 18 insertions(+), 26 deletions(-) diff --git a/frameworks/js/napi/ability_constant/BUILD.gn b/frameworks/js/napi/ability_constant/BUILD.gn index d0026cbabc..43b2b350cf 100644 --- a/frameworks/js/napi/ability_constant/BUILD.gn +++ b/frameworks/js/napi/ability_constant/BUILD.gn @@ -18,6 +18,7 @@ ohos_shared_library("abilityconstant_napi") { include_dirs = [ "${ability_runtime_innerkits_path}/ability_manager/include", "${ability_runtime_services_path}/common/include", + "//third_party/json/include", ] sources = [ "ability_constant_module.cpp" ] @@ -29,7 +30,6 @@ ohos_shared_library("abilityconstant_napi") { "c_utils:utils", "hilog:libhilog", "ipc:ipc_core", - "json:json_static", "napi:ace_napi", ] public_external_deps = [ "ability_base:want" ] @@ -42,6 +42,7 @@ ohos_shared_library("abilityconstant") { include_dirs = [ "${ability_runtime_innerkits_path}/ability_manager/include", "${ability_runtime_services_path}/common/include", + "//third_party/json/include", ] sources = [ "ability_constant_module.cpp" ] @@ -53,7 +54,6 @@ ohos_shared_library("abilityconstant") { "c_utils:utils", "hilog:libhilog", "ipc:ipc_core", - "json:json_static", "napi:ace_napi", ] public_external_deps = [ "ability_base:want" ] diff --git a/frameworks/native/ability/native/BUILD.gn b/frameworks/native/ability/native/BUILD.gn index f3f82279ab..e5d0cd0fa7 100644 --- a/frameworks/native/ability/native/BUILD.gn +++ b/frameworks/native/ability/native/BUILD.gn @@ -89,6 +89,7 @@ config("ability_public_config") { "${ability_runtime_path}/interfaces/kits/native/appkit/ability_runtime/context", "${ability_runtime_innerkits_path}/ability_manager/include/continuation", "${ability_runtime_services_path}/common/include", + "//third_party/json/include", ] if (ability_runtime_graphics) { @@ -114,6 +115,7 @@ config("abilitykit_utils_public_config") { "${ability_runtime_path}/interfaces/kits/native/appkit/app", "${ability_runtime_innerkits_path}/app_manager/include/appmgr", "${bundlefwk_inner_api_path}/appexecfwk_base/include", + "//third_party/json/include", ] if (ability_runtime_graphics) { @@ -156,7 +158,6 @@ ohos_shared_library("abilitykit_utils") { public_external_deps = [ "bundle_framework:appexecfwk_core", - "json:json_static", "jsoncpp:jsoncpp", "window_manager:libwm", ] @@ -276,7 +277,6 @@ ohos_shared_library("abilitykit_native") { public_external_deps = [ "accessibility:accessibility_common", "bundle_framework:appexecfwk_core", - "json:json_static", "jsoncpp:jsoncpp", "libuv:uv", ] @@ -337,6 +337,7 @@ config("extensionkit_public_config") { "${ability_runtime_path}/interfaces/kits/native/appkit/app", "${ability_runtime_innerkits_path}/app_manager/include/appmgr", "${bundlefwk_inner_api_path}/appexecfwk_base/include", + "//third_party/json/include", ] if (ability_runtime_graphics) { @@ -391,7 +392,6 @@ ohos_shared_library("extensionkit_native") { public_external_deps = [ "bundle_framework:appexecfwk_core", - "json:json_static", "jsoncpp:jsoncpp", ] @@ -681,8 +681,6 @@ ohos_shared_library("form_extension_module") { "napi:ace_napi", ] - public_external_deps = [ "json:json_static" ] - relative_install_dir = "extensionability" subsystem_name = "ability" part_name = "ability_runtime" @@ -784,7 +782,6 @@ ohos_shared_library("continuation_ipc") { ] public_external_deps = [ "accessibility:accessibility_common", - "json:json_static", "libuv:uv", ] @@ -827,7 +824,7 @@ ohos_shared_library("data_ability_helper") { "relational_store:native_rdb", "relational_store:rdb_data_ability_adapter", ] - public_external_deps = [ "json:json_static" ] + innerapi_tags = [ "platformsdk" ] subsystem_name = "ability" part_name = "ability_runtime" @@ -855,7 +852,7 @@ ohos_shared_library("service_extension_module") { "hilog:libhilog", "napi:ace_napi", ] - public_external_deps = [ "json:json_static" ] + if (ability_runtime_graphics) { external_deps += [ "image_framework:image", diff --git a/frameworks/native/appkit/BUILD.gn b/frameworks/native/appkit/BUILD.gn index 0d3ef40598..fcef608549 100644 --- a/frameworks/native/appkit/BUILD.gn +++ b/frameworks/native/appkit/BUILD.gn @@ -186,7 +186,7 @@ ohos_shared_library("appkit_native") { "i18n:preferred_language", "init:libbegetutil", "ipc:ipc_core", - "json:json_static", + "json:nlohmann_json_static", "napi:ace_napi", "resource_management:global_resmgr", "safwk:system_ability_fwk", @@ -284,7 +284,7 @@ ohos_shared_library("app_context") { "hitrace:hitrace_meter", "init:libbegetutil", "ipc:ipc_core", - "json:json_static", + "json:nlohmann_json_static", "napi:ace_napi", "resource_management:global_resmgr", "samgr:samgr_proxy", @@ -345,7 +345,7 @@ ohos_shared_library("app_context_utils") { "hilog:libhilog", "hitrace:hitrace_meter", "ipc:ipc_core", - "json:json_static", + "json:nlohmann_json_static", "napi:ace_napi", "resource_management:global_resmgr", "resource_management:resmgr_napi_core", @@ -412,7 +412,7 @@ ohos_shared_library("appkit_delegator") { "eventhandler:libeventhandler", "hilog:libhilog", "ipc:ipc_core", - "json:json_static", + "json:nlohmann_json_static", "napi:ace_napi", ] public_external_deps = [ "ability_base:configuration" ] @@ -467,7 +467,7 @@ ohos_shared_library("appkit_manager_helper") { "hilog:libhilog", "hitrace:hitrace_meter", "ipc:ipc_core", - "json:json_static", + "json:nlohmann_json_static", "samgr:samgr_proxy", ] diff --git a/interfaces/inner_api/app_manager/BUILD.gn b/interfaces/inner_api/app_manager/BUILD.gn index ee2fa0b30c..c489963183 100644 --- a/interfaces/inner_api/app_manager/BUILD.gn +++ b/interfaces/inner_api/app_manager/BUILD.gn @@ -37,6 +37,7 @@ config("appmgr_core_config") { ohos_shared_library("app_manager") { include_dirs = [ + "//third_party/json/include", "${ability_runtime_path}/interfaces/kits/native/appkit/dfr", "${ability_runtime_services_path}/appdfr/include", "${ability_runtime_services_path}/appmgr/include", @@ -130,7 +131,6 @@ ohos_shared_library("app_manager") { "hitrace:hitrace_meter", "init:libbegetutil", "ipc:ipc_core", - "json:json_static", "samgr:samgr_proxy", ] public_external_deps = [ diff --git a/interfaces/inner_api/dataobs_manager/BUILD.gn b/interfaces/inner_api/dataobs_manager/BUILD.gn index b87728f694..cabea243fe 100644 --- a/interfaces/inner_api/dataobs_manager/BUILD.gn +++ b/interfaces/inner_api/dataobs_manager/BUILD.gn @@ -49,10 +49,7 @@ ohos_shared_library("dataobs_manager") { "ipc:ipc_core", "samgr:samgr_proxy", ] - public_external_deps = [ - "ability_base:zuri", - "json:json_static", - ] + public_external_deps = [ "ability_base:zuri" ] innerapi_tags = [ "platformsdk", "sasdk", diff --git a/interfaces/inner_api/runtime/BUILD.gn b/interfaces/inner_api/runtime/BUILD.gn index 34a3e62f53..b0d5637eb9 100644 --- a/interfaces/inner_api/runtime/BUILD.gn +++ b/interfaces/inner_api/runtime/BUILD.gn @@ -40,6 +40,7 @@ config("runtime_public_config") { include_dirs = [ "${ability_runtime_path}/interfaces/kits/native/ability/native/ability_business_error", "include", + "//third_party/json/include", ] } @@ -116,7 +117,6 @@ ohos_shared_library("runtime") { "samgr:samgr_proxy", "zlib:shared_libz", ] - public_external_deps = [ "json:json_static" ] if (cj_frontend) { sources += [ "${ability_runtime_native_path}/runtime/cj_runtime.cpp" ] diff --git a/services/abilitymgr/BUILD.gn b/services/abilitymgr/BUILD.gn index e972e53e5b..dc4abdd7d7 100644 --- a/services/abilitymgr/BUILD.gn +++ b/services/abilitymgr/BUILD.gn @@ -39,6 +39,7 @@ config("abilityms_config") { "${ability_runtime_services_path}/common/include", "//prebuilts/jdk/jdk8/linux-x86/include", "//prebuilts/jdk/jdk8/linux-x86/include/linux", + "//third_party/json/include", "${ability_runtime_path}/interfaces/kits/native/ability/native", "${relational_store_innerapi_path}/rdb/include", "${relational_store_innerapi_path}/dataability/include", @@ -161,7 +162,6 @@ ohos_shared_library("abilityms") { "init:libbeget_proxy", "init:libbegetutil", "ipc:ipc_core", - "json:json_static", "kv_store:distributeddata_inner", "os_account:os_account_innerkits", "relational_store:native_appdatafwk", diff --git a/services/appmgr/BUILD.gn b/services/appmgr/BUILD.gn index 3e330173b9..13bf86aa6f 100644 --- a/services/appmgr/BUILD.gn +++ b/services/appmgr/BUILD.gn @@ -18,6 +18,7 @@ config("appmgr_config") { include_dirs = [ "include", "include/utils", + "//third_party/json/include", "${ability_runtime_innerkits_path}/ability_manager/include", "${ability_runtime_services_path}/common/include", "${ability_runtime_path}/tools/aa/include", @@ -114,7 +115,6 @@ ohos_shared_library("libappms") { "init:libbeget_proxy", "init:libbegetutil", "ipc:ipc_core", - "json:json_static", "kv_store:distributeddata_inner", "kv_store:distributeddata_mgr", "memory_utils:libmeminfo", diff --git a/services/dataobsmgr/BUILD.gn b/services/dataobsmgr/BUILD.gn index 71804a2907..f637a07c08 100644 --- a/services/dataobsmgr/BUILD.gn +++ b/services/dataobsmgr/BUILD.gn @@ -23,6 +23,7 @@ config("dataobsms_config") { include_dirs = [ "include/", "${ability_runtime_services_path}/common/include", + "//third_party/json/include", ] cflags = [] if (target_cpu == "arm") { @@ -47,7 +48,6 @@ ohos_shared_library("dataobsms") { "ffrt:libffrt", "hilog:libhilog", "ipc:ipc_core", - "json:json_static", "safwk:system_ability_fwk", "samgr:samgr_proxy", ] @@ -70,7 +70,6 @@ ohos_static_library("dataobsms_static") { "ffrt:libffrt", "hilog:libhilog", "ipc:ipc_core", - "json:json_static", "safwk:system_ability_fwk", "samgr:samgr_proxy", ] diff --git a/services/uripermmgr/BUILD.gn b/services/uripermmgr/BUILD.gn index 3d63127da3..958dd8cb9c 100644 --- a/services/uripermmgr/BUILD.gn +++ b/services/uripermmgr/BUILD.gn @@ -70,7 +70,6 @@ ohos_shared_library("libupms") { "init:libbeget_proxy", "init:libbegetutil", "ipc:ipc_core", - "json:json_static", "safwk:system_ability_fwk", "samgr:samgr_proxy", "storage_service:storage_manager_sa_proxy", From 0c3e808a1b12e44e3c6b17a3ecd79cdefd1c29ae Mon Sep 17 00:00:00 2001 From: xuxiaoya Date: Tue, 21 May 2024 18:35:35 +0800 Subject: [PATCH 145/174] fix comment Signed-off-by: xuxiaoya --- services/abilitymgr/src/ability_manager_service.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/services/abilitymgr/src/ability_manager_service.cpp b/services/abilitymgr/src/ability_manager_service.cpp index 94990bfb10..44aa48d949 100644 --- a/services/abilitymgr/src/ability_manager_service.cpp +++ b/services/abilitymgr/src/ability_manager_service.cpp @@ -8642,6 +8642,7 @@ int AbilityManagerService::CheckCallOtherExtensionPermission(const AbilityReques } if (extensionType == AppExecFwk::ExtensionAbilityType::WINDOW) { CHECK_CALLER_IS_SYSTEM_APP; + return ERR_OK; } if (extensionType == AppExecFwk::ExtensionAbilityType::ADS_SERVICE) { return ERR_OK; From 08f7ca7805c1dadac751faa4100315d95347df45 Mon Sep 17 00:00:00 2001 From: zhubingwei Date: Mon, 20 May 2024 19:41:34 +0800 Subject: [PATCH 146/174] =?UTF-8?q?=E5=85=83=E8=83=BD=E5=8A=9BTDD=E8=A6=86?= =?UTF-8?q?=E7=9B=96=E7=8E=87=E6=8F=90=E5=8D=87(ui=5Fability=5Flifecycle?= =?UTF-8?q?=5Fmanager)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhubingwei --- .../ui_ability_lifecycle_manager_test.cpp | 312 ++++++++++++++++++ 1 file changed, 312 insertions(+) diff --git a/test/unittest/ui_ability_lifecycle_manager_test/ui_ability_lifecycle_manager_test.cpp b/test/unittest/ui_ability_lifecycle_manager_test/ui_ability_lifecycle_manager_test.cpp index 56250032b0..b0bcd76c81 100644 --- a/test/unittest/ui_ability_lifecycle_manager_test/ui_ability_lifecycle_manager_test.cpp +++ b/test/unittest/ui_ability_lifecycle_manager_test/ui_ability_lifecycle_manager_test.cpp @@ -30,6 +30,7 @@ #include "process_options.h" #include "session/host/include/session.h" #include "session_info.h" +#include "ability_manager_service.h" using namespace testing; using namespace testing::ext; @@ -2567,5 +2568,316 @@ HWTEST_F(UIAbilityLifecycleManagerTest, ChangeUIAbilityVisibilityBySCB_001, Test int32_t ret = uiAbilityLifecycleManager->ChangeUIAbilityVisibilityBySCB(nullptr, true); EXPECT_EQ(ERR_INVALID_VALUE, ret); } + +/** + * @tc.name: UIAbilityLifecycleManager_IsContainsAbility_0100 + * @tc.desc: IsContainsAbility + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, IsContainsAbility_001, TestSize.Level1) +{ + auto mgr = std::make_unique(); + EXPECT_NE(mgr, nullptr); + sptr token = nullptr; + bool boolValue = mgr->IsContainsAbility(token); + EXPECT_FALSE(boolValue); +} + +/** + * @tc.name: UIAbilityLifecycleManager_IsContainsAbility_0200 + * @tc.desc: IsContainsAbility + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, IsContainsAbility_002, TestSize.Level1) +{ + auto mgr = std::make_unique(); + EXPECT_NE(mgr, nullptr); + AbilityRequest abilityRequest; + auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest); + auto&& token = abilityRecord->GetToken()->AsObject(); + mgr->sessionAbilityMap_.emplace(1, abilityRecord); + bool boolValue = mgr->IsContainsAbility(token); + EXPECT_TRUE(boolValue); +} + +/** + * @tc.name: UIAbilityLifecycleManager_IsContainsAbilityInner_0100 + * @tc.desc: IsContainsAbilityInner + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, IsContainsAbilityInner_001, TestSize.Level1) +{ + auto mgr = std::make_unique(); + EXPECT_NE(mgr, nullptr); + sptr token = nullptr; + bool boolValue = mgr->IsContainsAbilityInner(token); + EXPECT_FALSE(boolValue); +} + +/** + * @tc.name: UIAbilityLifecycleManager_IsContainsAbilityInner_0200 + * @tc.desc: IsContainsAbilityInner + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, IsContainsAbilityInner_002, TestSize.Level1) +{ + auto mgr = std::make_unique(); + EXPECT_NE(mgr, nullptr); + AbilityRequest abilityRequest; + auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest); + auto&& token = abilityRecord->GetToken()->AsObject(); + mgr->sessionAbilityMap_.emplace(1, abilityRecord); + bool boolValue = mgr->IsContainsAbilityInner(token); + EXPECT_TRUE(boolValue); +} + +/** + * @tc.name: UIAbilityLifecycleManager_NotifySCBToMinimizeUIAbility_0100 + * @tc.desc: NotifySCBToMinimizeUIAbility + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, NotifySCBToMinimizeUIAbility_001, TestSize.Level1) +{ + auto mgr = std::make_unique(); + std::shared_ptr abilityRecord = nullptr; + sptr token = nullptr; + EXPECT_NE(mgr->NotifySCBToMinimizeUIAbility(abilityRecord, token), ERR_OK); +} + +/** + * @tc.name: UIAbilityLifecycleManager_GetUIAbilityRecordBySessionInfo_0100 + * @tc.desc: GetUIAbilityRecordBySessionInfo + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, GetUIAbilityRecordBySessionInfo_001, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_unique(); + EXPECT_NE(uiAbilityLifecycleManager, nullptr); + sptr sessionInfo = nullptr; + EXPECT_EQ(uiAbilityLifecycleManager->GetUIAbilityRecordBySessionInfo(sessionInfo), nullptr); +} + +/** + * @tc.name: UIAbilityLifecycleManager_GetUIAbilityRecordBySessionInfo_0200 + * @tc.desc: GetUIAbilityRecordBySessionInfo + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, GetUIAbilityRecordBySessionInfo_002, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_unique(); + EXPECT_NE(uiAbilityLifecycleManager, nullptr); + sptr sessionInfo(new SessionInfo()); + sessionInfo->sessionToken = nullptr; + EXPECT_EQ(uiAbilityLifecycleManager->GetUIAbilityRecordBySessionInfo(sessionInfo), nullptr); +} + +/** + * @tc.name: UIAbilityLifecycleManager_GetUIAbilityRecordBySessionInfo_0300 + * @tc.desc: GetUIAbilityRecordBySessionInfo + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, GetUIAbilityRecordBySessionInfo_003, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_unique(); + EXPECT_NE(uiAbilityLifecycleManager, nullptr); + Rosen::SessionInfo info; + sptr sessionInfo(new SessionInfo()); + sessionInfo->sessionToken = new Rosen::Session(info); + EXPECT_EQ(uiAbilityLifecycleManager->GetUIAbilityRecordBySessionInfo(sessionInfo), nullptr); +} + +/** + * @tc.name: UIAbilityLifecycleManager_GetUIAbilityRecordBySessionInfo_0400 + * @tc.desc: GetUIAbilityRecordBySessionInfo + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, GetUIAbilityRecordBySessionInfo_004, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_unique(); + EXPECT_NE(uiAbilityLifecycleManager, nullptr); + AbilityRequest abilityRequest; + Rosen::SessionInfo info; + sptr sessionInfo(new SessionInfo()); + sessionInfo->sessionToken = new Rosen::Session(info); + sessionInfo->persistentId = 1; + abilityRequest.sessionInfo = sessionInfo; + auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest); + uiAbilityLifecycleManager->sessionAbilityMap_.emplace(sessionInfo->persistentId, abilityRecord); + EXPECT_NE(uiAbilityLifecycleManager->GetUIAbilityRecordBySessionInfo(sessionInfo), nullptr); +} + +/** + * @tc.name: UIAbilityLifecycleManager_OnStartSpecifiedProcessResponse_0100 + * @tc.desc: OnStartSpecifiedProcessResponse + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, OnStartSpecifiedProcessResponse_001, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_shared(); + EXPECT_NE(uiAbilityLifecycleManager, nullptr); + Want want; + std::string flag = "flag"; + uiAbilityLifecycleManager->OnStartSpecifiedProcessResponse(want, flag); + uiAbilityLifecycleManager.reset(); +} + +/** + * @tc.name: UIAbilityLifecycleManager_OnStartSpecifiedProcessResponse_0200 + * @tc.desc: OnStartSpecifiedProcessResponse + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, OnStartSpecifiedProcessResponse_002, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_shared(); + EXPECT_NE(uiAbilityLifecycleManager, nullptr); + Want want; + std::string flag = "flag"; + int32_t requestId = 100; + uiAbilityLifecycleManager->OnStartSpecifiedProcessResponse(want, flag, requestId); + uiAbilityLifecycleManager.reset(); +} + +/** + * @tc.name: UIAbilityLifecycleManager_OnStartSpecifiedAbilityTimeoutResponse_0100 + * @tc.desc: OnStartSpecifiedAbilityTimeoutResponse + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, OnStartSpecifiedAbilityTimeoutResponse_001, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_shared(); + EXPECT_NE(uiAbilityLifecycleManager, nullptr); + Want want; + uiAbilityLifecycleManager->OnStartSpecifiedAbilityTimeoutResponse(want); + uiAbilityLifecycleManager.reset(); +} + +/** + * @tc.name: UIAbilityLifecycleManager_OnStartSpecifiedAbilityTimeoutResponse_0200 + * @tc.desc: OnStartSpecifiedAbilityTimeoutResponse + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, OnStartSpecifiedAbilityTimeoutResponse_002, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_shared(); + EXPECT_NE(uiAbilityLifecycleManager, nullptr); + Want want; + int32_t requestId = 100; + uiAbilityLifecycleManager->OnStartSpecifiedAbilityTimeoutResponse(want, requestId); + uiAbilityLifecycleManager.reset(); +} + +/** + * @tc.name: UIAbilityLifecycleManager_OnStartSpecifiedProcessTimeoutResponse_0100 + * @tc.desc: OnStartSpecifiedProcessTimeoutResponse + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, OnStartSpecifiedProcessTimeoutResponse_001, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_shared(); + EXPECT_NE(uiAbilityLifecycleManager, nullptr); + Want want; + uiAbilityLifecycleManager->OnStartSpecifiedProcessTimeoutResponse(want); + uiAbilityLifecycleManager.reset(); +} + +/** + * @tc.name: UIAbilityLifecycleManager_OnStartSpecifiedProcessTimeoutResponse_0200 + * @tc.desc: OnStartSpecifiedProcessTimeoutResponse + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, OnStartSpecifiedProcessTimeoutResponse_002, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_shared(); + EXPECT_NE(uiAbilityLifecycleManager, nullptr); + Want want; + int32_t requestId = 100; + uiAbilityLifecycleManager->OnStartSpecifiedProcessTimeoutResponse(want, requestId); + uiAbilityLifecycleManager.reset(); +} + +/** + * @tc.name: UIAbilityLifecycleManager_OnCallConnectDied_0100 + * @tc.desc: OnCallConnectDied + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, OnCallConnectDied_001, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_shared(); + EXPECT_NE(uiAbilityLifecycleManager, nullptr); + std::shared_ptr callRecord = nullptr; + uiAbilityLifecycleManager->OnCallConnectDied(callRecord); + uiAbilityLifecycleManager.reset(); +} + +/** + * @tc.name: UIAbilityLifecycleManager_GetSessionIdByAbilityToken_0100 + * @tc.desc: GetSessionIdByAbilityToken + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, GetSessionIdByAbilityToken_001, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_unique(); + EXPECT_NE(uiAbilityLifecycleManager, nullptr); + sptr token = nullptr; + EXPECT_EQ(uiAbilityLifecycleManager->GetSessionIdByAbilityToken(token), ERR_OK); +} + +/** + * @tc.name: UIAbilityLifecycleManager_GetSessionIdByAbilityToken_0200 + * @tc.desc: GetSessionIdByAbilityToken + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, GetSessionIdByAbilityToken_002, TestSize.Level1) +{ + auto mgr = std::make_unique(); + AbilityRequest abilityRequest; + auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest); + mgr->sessionAbilityMap_.emplace(1, abilityRecord); + auto&& token = abilityRecord->GetToken()->AsObject(); + EXPECT_EQ(mgr->GetSessionIdByAbilityToken(token), 1); +} + +/** + * @tc.name: UIAbilityLifecycleManager_GetActiveAbilityList_0100 + * @tc.desc: GetActiveAbilityList + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, GetActiveAbilityList_001, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_unique(); + EXPECT_NE(uiAbilityLifecycleManager, nullptr); + AbilityRequest abilityRequest; + auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest); + uiAbilityLifecycleManager->sessionAbilityMap_.emplace(1, abilityRecord); + std::string bundleName = "com.example.unittest"; + std::vector abilityList; + int32_t pid = 100; + uiAbilityLifecycleManager->GetActiveAbilityList(bundleName, abilityList, pid); + uiAbilityLifecycleManager.reset(); +} + +/** + * @tc.name: UIAbilityLifecycleManager_GetActiveAbilityList_0200 + * @tc.desc: GetActiveAbilityList + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, GetActiveAbilityList_002, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_unique(); + EXPECT_NE(uiAbilityLifecycleManager, nullptr); + AbilityRequest abilityRequest; + abilityRequest.abilityInfo.launchMode = AppExecFwk::LaunchMode::STANDARD; + abilityRequest.abilityInfo.name = "testAbility"; + abilityRequest.abilityInfo.moduleName = "testModule"; + abilityRequest.abilityInfo.bundleName = "com.example.unittest"; + auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest); + abilityRecord->SetOwnerMissionUserId(DelayedSingleton::GetInstance()->GetUserId()); + uiAbilityLifecycleManager->sessionAbilityMap_.emplace(1, abilityRecord); + std::string bundleName = "com.example.unittest"; + std::vector abilityList; + int32_t pid = 100; + uiAbilityLifecycleManager->GetActiveAbilityList(bundleName, abilityList, pid); + uiAbilityLifecycleManager.reset(); +} } // namespace AAFwk } // namespace OHOS From d6eaea03dc346ab98fb066c48a89175ae637dd98 Mon Sep 17 00:00:00 2001 From: zhubingwei Date: Tue, 21 May 2024 13:00:40 +0000 Subject: [PATCH 147/174] data observer UT Signed-off-by: zhubingwei --- .../data_ability_observer_proxy_test.cpp | 49 ++++++++ .../mock_data_obs_manager_onchange_callback.h | 2 + .../dataobs_mgr_stub_test.cpp | 117 ++++++++++++++++++ 3 files changed, 168 insertions(+) diff --git a/test/unittest/data_ability_observer_proxy_test/data_ability_observer_proxy_test.cpp b/test/unittest/data_ability_observer_proxy_test/data_ability_observer_proxy_test.cpp index 5bcf89b47f..7180cf0704 100644 --- a/test/unittest/data_ability_observer_proxy_test/data_ability_observer_proxy_test.cpp +++ b/test/unittest/data_ability_observer_proxy_test/data_ability_observer_proxy_test.cpp @@ -62,5 +62,54 @@ HWTEST_F(DataAbilityObserverProxyTest, DataAbilityObserverProxy_OnChangeInner_00 proxy->OnChange(); } } + +/* + * Feature: DataAbilityObserverProxy. + * Function: DataObsManagerProxy::OnChangeExt is called. + * SubFunction: NA. + * FunctionPoints: NA. + * EnvConditions: NA. + * CaseDescription: NA. + */ +HWTEST_F(DataAbilityObserverProxyTest, DataAbilityObserverProxy_OnChangeExt_001, TestSize.Level1) +{ + // 1.stub define + sptr mockDataAbilityObserverStub(new MockDataObsManagerOnChangeCallBack()); + + // 2.obsver1 define + sptr proxy(new DataAbilityObserverProxy(mockDataAbilityObserverStub)); + + ChangeInfo changeInfo; + + EXPECT_CALL(*mockDataAbilityObserverStub, OnChangeExt(testing::_)).Times(1); + + if (proxy != nullptr) { + proxy->OnChangeExt(changeInfo); + } +} + +/* + * Feature: DataAbilityObserverProxy. + * Function: DataObsManagerProxy::OnChangePreferences is called. + * SubFunction: NA. + * FunctionPoints: NA. + * EnvConditions: NA. + * CaseDescription: NA. + */ +HWTEST_F(DataAbilityObserverProxyTest, DataAbilityObserverProxy_OnChangePreferences_001, TestSize.Level1) +{ + // 1.stub define + sptr mockDataAbilityObserverStub(new MockDataObsManagerOnChangeCallBack()); + + // 2.obsver1 define + sptr proxy(new DataAbilityObserverProxy(mockDataAbilityObserverStub)); + + std::string key = "test"; + EXPECT_CALL(*mockDataAbilityObserverStub, OnChangePreferences(key)).Times(1); + + if (proxy != nullptr) { + proxy->OnChangePreferences(key); + } +} } // namespace AAFwk } // namespace OHOS diff --git a/test/unittest/data_ability_observer_proxy_test/mock_data_obs_manager_onchange_callback.h b/test/unittest/data_ability_observer_proxy_test/mock_data_obs_manager_onchange_callback.h index 42bb0bea78..13d9b0b3fd 100644 --- a/test/unittest/data_ability_observer_proxy_test/mock_data_obs_manager_onchange_callback.h +++ b/test/unittest/data_ability_observer_proxy_test/mock_data_obs_manager_onchange_callback.h @@ -27,6 +27,8 @@ namespace AAFwk { class MockDataObsManagerOnChangeCallBack : public DataAbilityObserverStub { public: MOCK_METHOD0(OnChange, void()); + MOCK_METHOD1(OnChangeExt, void(const ChangeInfo&)); + MOCK_METHOD1(OnChangePreferences, void(const std::string&)); void Wait() { diff --git a/test/unittest/dataobs_mgr_stub_test/dataobs_mgr_stub_test.cpp b/test/unittest/dataobs_mgr_stub_test/dataobs_mgr_stub_test.cpp index 900bb63758..aa9e829941 100644 --- a/test/unittest/dataobs_mgr_stub_test/dataobs_mgr_stub_test.cpp +++ b/test/unittest/dataobs_mgr_stub_test/dataobs_mgr_stub_test.cpp @@ -206,5 +206,122 @@ HWTEST_F(DataObsManagerStubTest, AaFwk_DataObsManagerStubTest_NotifyChange_0100, EXPECT_EQ(testVal2, retval2); GTEST_LOG_(INFO) << "AaFwk_DataObsManagerStubTest_NotifyChange_0100 end"; } + +/* + * Feature: DataObsManagerStub + * Function: RegisterObserverExtInner + * SubFunction: NA + * FunctionPoints: DataObsManagerStub RegisterObserverExtInner + * EnvConditions: NA + * CaseDescription: Verify that the DataObsManagerStub RegisterObserverExtInner is normal. + */ +HWTEST_F(DataObsManagerStubTest, AaFwk_DataObsManagerStubTest_RegisterObserverExtInner_0100, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "AaFwk_DataObsManagerStubTest_RegisterObserverExtInner_0100 start"; + std::shared_ptr dataobs = std::make_shared(); + Uri uri("dataability://device_id/com.domainname.dataability.persondata/person/10"); + const int testVal1 = static_cast(NO_ERROR); + const Status testVal2 = SUCCESS; + uint32_t code = IDataObsMgr::REGISTER_OBSERVER_EXT; + MessageParcel data; + MessageParcel reply; + MessageOption option; + + if (!data.WriteInterfaceToken(DataObsManagerProxy::GetDescriptor())) { + GTEST_LOG_(ERROR) << "---------- WriteInterfaceToken(data) retval is false end"; + return; + } + if (!data.WriteString(uri.ToString())) { + GTEST_LOG_(ERROR) << "---------- data.WriteParcelable(uri) retval is false end"; + return; + } + + EXPECT_CALL(*dataobs, RegisterObserverExt(testing::_, testing::_, testing::_)).Times(1).WillOnce(testing::Return(testVal2)); + + const int retval1 = dataobs->OnRemoteRequest(code, data, reply, option); + const int retval2 = reply.ReadInt32(); + + EXPECT_EQ(testVal1, retval1); + EXPECT_EQ(testVal2, retval2); + GTEST_LOG_(INFO) << "AaFwk_DataObsManagerStubTest_RegisterObserverExtInner_0100 end"; +} + +/* + * Feature: DataObsManagerStub + * Function: UnregisterObserverExtInner + * SubFunction: NA + * FunctionPoints: DataObsManagerStub UnregisterObserverExtInner + * EnvConditions: NA + * CaseDescription: Verify that the DataObsManagerStub UnregisterObserverExtInner is normal. + */ +HWTEST_F(DataObsManagerStubTest, AaFwk_DataObsManagerStubTest_UnregisterObserverExtInner_0100, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "AaFwk_DataObsManagerStubTest_UnregisterObserverExtInner_0100 start"; + std::shared_ptr dataobs = std::make_shared(); + Uri uri("dataability://device_id/com.domainname.dataability.persondata/person/10"); + const int testVal1 = static_cast(NO_ERROR); + const Status testVal2 = SUCCESS; + uint32_t code = IDataObsMgr::UNREGISTER_OBSERVER_EXT; + MessageParcel data; + MessageParcel reply; + MessageOption option; + + if (!data.WriteInterfaceToken(DataObsManagerProxy::GetDescriptor())) { + GTEST_LOG_(ERROR) << "---------- WriteInterfaceToken(data) retval is false end"; + return; + } + if (!data.WriteString(uri.ToString())) { + GTEST_LOG_(ERROR) << "---------- data.WriteParcelable(uri) retval is false end"; + return; + } + + EXPECT_CALL(*dataobs, UnregisterObserverExt(testing::_, testing::_)).Times(1).WillOnce(testing::Return(testVal2)); + + const int retval1 = dataobs->OnRemoteRequest(code, data, reply, option); + const int retval2 = reply.ReadInt32(); + + EXPECT_EQ(testVal1, retval1); + EXPECT_EQ(testVal2, retval2); + GTEST_LOG_(INFO) << "AaFwk_DataObsManagerStubTest_UnregisterObserverExtInner_0100 end"; +} + +/* + * Feature: DataObsManagerStub + * Function: UnregisterObserverExtALLInner + * SubFunction: NA + * FunctionPoints: DataObsManagerStub UnregisterObserverExtALLInner + * EnvConditions: NA + * CaseDescription: Verify that the DataObsManagerStub UnregisterObserverExtALLInner is normal. + */ +HWTEST_F(DataObsManagerStubTest, AaFwk_DataObsManagerStubTest_UnregisterObserverExtALLInner_0100, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "AaFwk_DataObsManagerStubTest_UnregisterObserverExtALLInner_0100 start"; + std::shared_ptr dataobs = std::make_shared(); + Uri uri("dataability://device_id/com.domainname.dataability.persondata/person/10"); + const int testVal1 = static_cast(NO_ERROR); + const Status testVal2 = SUCCESS; + uint32_t code = IDataObsMgr::UNREGISTER_OBSERVER_ALL_EXT; + MessageParcel data; + MessageParcel reply; + MessageOption option; + + if (!data.WriteInterfaceToken(DataObsManagerProxy::GetDescriptor())) { + GTEST_LOG_(ERROR) << "---------- WriteInterfaceToken(data) retval is false end"; + return; + } + if (!data.WriteString(uri.ToString())) { + GTEST_LOG_(ERROR) << "---------- data.WriteParcelable(uri) retval is false end"; + return; + } + + EXPECT_CALL(*dataobs, UnregisterObserverExt(testing::_)).Times(1).WillOnce(testing::Return(testVal2)); + + const int retval1 = dataobs->OnRemoteRequest(code, data, reply, option); + const int retval2 = reply.ReadInt32(); + + EXPECT_EQ(testVal1, retval1); + EXPECT_EQ(testVal2, retval2); + GTEST_LOG_(INFO) << "AaFwk_DataObsManagerStubTest_UnregisterObserverExtALLInner_0100 end"; +} } // namespace AAFwk } // namespace OHOS From 5517fe453e8dca99a2b1b94540179b3d17299012 Mon Sep 17 00:00:00 2001 From: zhubingwei Date: Tue, 21 May 2024 13:29:06 +0000 Subject: [PATCH 148/174] =?UTF-8?q?data=20observer=20UT=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E9=97=A8=E7=A6=81=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhubingwei --- test/unittest/dataobs_mgr_stub_test/dataobs_mgr_stub_test.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/unittest/dataobs_mgr_stub_test/dataobs_mgr_stub_test.cpp b/test/unittest/dataobs_mgr_stub_test/dataobs_mgr_stub_test.cpp index aa9e829941..ad13cbc838 100644 --- a/test/unittest/dataobs_mgr_stub_test/dataobs_mgr_stub_test.cpp +++ b/test/unittest/dataobs_mgr_stub_test/dataobs_mgr_stub_test.cpp @@ -314,7 +314,8 @@ HWTEST_F(DataObsManagerStubTest, AaFwk_DataObsManagerStubTest_UnregisterObserver return; } - EXPECT_CALL(*dataobs, UnregisterObserverExt(testing::_)).Times(1).WillOnce(testing::Return(testVal2)); + EXPECT_CALL(*dataobs, UnregisterObserverExt(testing::_)).Times(1) + .WillOnce(testing::Return(testVal2)); const int retval1 = dataobs->OnRemoteRequest(code, data, reply, option); const int retval2 = reply.ReadInt32(); From 0ce4328a28c01a0247214d552c52bfb0c5206e11 Mon Sep 17 00:00:00 2001 From: zhubingwei Date: Tue, 21 May 2024 13:32:08 +0800 Subject: [PATCH 149/174] add TDD Signed-off-by: zhubingwei Change-Id: I4ecc77c3c73c24edf8295e9177003e7bdb7dccd8 --- js_environment/test/unittest/BUILD.gn | 1 + .../js_environment_test.cpp | 36 +++++++++++++++++++ .../source_map_test/source_map_test.cpp | 29 +++++++++++++++ .../uncaught_exception_callback_test.cpp | 30 ++++++++++++++++ 4 files changed, 96 insertions(+) diff --git a/js_environment/test/unittest/BUILD.gn b/js_environment/test/unittest/BUILD.gn index 68d637e8a9..04a5773ea1 100644 --- a/js_environment/test/unittest/BUILD.gn +++ b/js_environment/test/unittest/BUILD.gn @@ -21,5 +21,6 @@ group("unittest") { "js_env_log_unit_test:unittest", "js_environment_test:unittest", "source_map_test:unittest", + "uncaught_exception_callback_test:unittest", ] } diff --git a/js_environment/test/unittest/js_environment_test/js_environment_test.cpp b/js_environment/test/unittest/js_environment_test/js_environment_test.cpp index 3a28db43fb..f9b186179c 100644 --- a/js_environment/test/unittest/js_environment_test/js_environment_test.cpp +++ b/js_environment/test/unittest/js_environment_test/js_environment_test.cpp @@ -243,6 +243,27 @@ HWTEST_F(JsEnvironmentTest, StartDebugger_0100, TestSize.Level0) ASSERT_EQ(result, false); } +/** + * @tc.name: StartDebugger_0200 + * @tc.desc: StartDebugger + * @tc.type: FUNC + * @tc.require: issue + */ +HWTEST_F(JsEnvironmentTest, StartDebugger_0200, TestSize.Level0) +{ + auto jsEnv = std::make_shared(std::make_unique()); + ASSERT_NE(jsEnv, nullptr); + panda::RuntimeOption pandaOption; + auto ret = jsEnv->Initialize(pandaOption, static_cast(this)); + ASSERT_EQ(ret, true); + + std::string option = "ark:1234@Debugger"; + uint32_t socketFd = 10; + bool isDebugApp = true; + bool result = jsEnv->StartDebugger(option, socketFd, isDebugApp, jsEnv->GetDebuggerPostTask()); + ASSERT_EQ(result, false); +} + /** * @tc.name: StopDebugger_0100 * @tc.desc: StopDebugger @@ -477,6 +498,21 @@ HWTEST_F(JsEnvironmentTest, GetDebuggerPostTask_0100, TestSize.Level0) ASSERT_NE(jsEnv, nullptr); } +/** + * @tc.name: GetDebuggerPostTask_0200 + * @tc.desc: Js environment GetDebuggerPostTask. + * @tc.type: FUNC + */ +HWTEST_F(JsEnvironmentTest, GetDebuggerPostTask_0200, TestSize.Level0) +{ + auto jsEnv = std::make_shared(std::make_unique()); + auto poster = jsEnv->GetDebuggerPostTask(); + ASSERT_NE(jsEnv, nullptr); + poster([]() { + std::string temp; + }); +} + /** * @tc.name: GetHeapPrepare_0100 * @tc.desc: Js environment GetHeapPrepare. diff --git a/js_environment/test/unittest/source_map_test/source_map_test.cpp b/js_environment/test/unittest/source_map_test/source_map_test.cpp index 5afeb8341a..9504f20d34 100644 --- a/js_environment/test/unittest/source_map_test/source_map_test.cpp +++ b/js_environment/test/unittest/source_map_test/source_map_test.cpp @@ -193,6 +193,35 @@ HWTEST_F(SourceMapTest, JsEnv_SourceMap_0900, Function | MediumTest | Level1) GTEST_LOG_(INFO) << "JsEnv_SourceMap_0900 end"; } +/** + * @tc.number: JsEnv_SourceMap_1000 + * @tc.name: Find + * @tc.desc: Verifying Find succeeded. + * @tc.require: #I6T4K1 + */ +HWTEST_F(SourceMapTest, JsEnv_SourceMap_1000, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) << "JsEnv_SourceMap_1000 start"; + auto modSourceMap = std::make_shared(); + int32_t row = 2; + int32_t col = 3; + SourceMapData targetMap; + targetMap.sources_.emplace_back("sources"); + for (int32_t i = 0; i < 10; i++) { + for (int32_t j = 0; j < 5; j++) { + SourceMapInfo mapInfo; + mapInfo.beforeRow = 0; + mapInfo.beforeColumn = 0; + mapInfo.afterRow = i; + mapInfo.afterColumn = j; + targetMap.afterPos_.emplace_back(mapInfo); + } + } + auto info = modSourceMap->Find(row, col, targetMap); + EXPECT_STREQ(info.sources.c_str(), "sources"); + GTEST_LOG_(INFO) << "JsEnv_SourceMap_1000 end"; +} + /** * @tc.number: JsEnv_SourceMap_1300 * @tc.name: GetPosInfo diff --git a/js_environment/test/unittest/uncaught_exception_callback_test/uncaught_exception_callback_test.cpp b/js_environment/test/unittest/uncaught_exception_callback_test/uncaught_exception_callback_test.cpp index 76646c9331..4231ab8db3 100644 --- a/js_environment/test/unittest/uncaught_exception_callback_test/uncaught_exception_callback_test.cpp +++ b/js_environment/test/unittest/uncaught_exception_callback_test/uncaught_exception_callback_test.cpp @@ -94,6 +94,36 @@ HWTEST_F(NapiUncaughtExceptionCallbackTest, NapiUncaughtExceptionCallbackTest_01 ASSERT_EQ(callback3.GetNativeStrFromJsTaggedObj(object, "stack"), errorStack); } +/** + * @tc.name: NapiUncaughtExceptionCallbackTest_0101 + * @tc.type: FUNC + * @tc.desc: Test NapiNapiUncaughtExceptionCallback GetNativeStrFromJsTaggedObj. + * @tc.require: #I6T4K1 + */ +HWTEST_F(NapiUncaughtExceptionCallbackTest, NapiUncaughtExceptionCallbackTest_0101, TestSize.Level1) +{ + AbilityRuntime::Runtime::Options options; + options.preload = false; + auto jsRuntime = AbilityRuntime::JsRuntime::Create(options); + ASSERT_NE(jsRuntime, nullptr); + auto env = jsRuntime->GetNapiEnv(); + EXPECT_NE(env, nullptr); + + // Test with null object + auto task = [](std::string summary, const JsEnv::ErrorObject errorObj) { + summary += "test"; + }; + + // Test with invalid object + napi_value object = nullptr; + napi_create_object(env, &object); + napi_value valueUint32 = nullptr; + napi_create_uint32(env, 0x11, &valueUint32); + napi_set_named_property(env, object, "key", valueUint32); + NapiUncaughtExceptionCallback callback(task, nullptr, env); + ASSERT_EQ(callback.GetNativeStrFromJsTaggedObj(object, "key"), ""); +} + /** * @tc.name: NapiUncaughtExceptionCallbackTest_0200 * @tc.type: FUNC From 386ee97144589cd283eaafe8a33ee17b862a974e Mon Sep 17 00:00:00 2001 From: zhubingwei Date: Tue, 21 May 2024 16:26:32 +0800 Subject: [PATCH 150/174] =?UTF-8?q?=E5=A2=9E=E5=8A=A0ability=5Frunning=5Fr?= =?UTF-8?q?ecord=5Ftest=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhubingwei Change-Id: Idb73dc11da88d060a97a3a861d1ee381ca7a594e --- test/unittest/BUILD.gn | 1 + .../ability_running_record_test/BUILD.gn | 77 ++ .../ability_running_record_test.cpp | 720 ++++++++++++++++++ 3 files changed, 798 insertions(+) create mode 100644 test/unittest/ability_running_record_test/BUILD.gn create mode 100644 test/unittest/ability_running_record_test/ability_running_record_test.cpp diff --git a/test/unittest/BUILD.gn b/test/unittest/BUILD.gn index 38d6e5a8f3..76d9203add 100644 --- a/test/unittest/BUILD.gn +++ b/test/unittest/BUILD.gn @@ -353,6 +353,7 @@ group("unittest") { "ability_record_test:unittest", "ability_running_info_test:unittest", "ability_runtime_error_util_test:unittest", + "ability_running_record_test:unittest", "ability_scheduler_proxy_test:unittest", "ability_scheduler_stub_test:unittest", "ability_service_extension_test:unittest", diff --git a/test/unittest/ability_running_record_test/BUILD.gn b/test/unittest/ability_running_record_test/BUILD.gn new file mode 100644 index 0000000000..a3fd7ec8ad --- /dev/null +++ b/test/unittest/ability_running_record_test/BUILD.gn @@ -0,0 +1,77 @@ +# Copyright (c) 2021-2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/test.gni") +import("//foundation/ability/ability_runtime/ability_runtime.gni") + +module_output_path = "ability_runtime/appmgr" + +ohos_unittest("ability_running_record_test") { + module_out_path = module_output_path + cflags_cc = [] + include_dirs = [ + "${ability_runtime_path}/interfaces/kits/native/appkit/ability_bundle_manager_helper", + "${ability_runtime_services_path}/appmgr/include", + ] + + sources = [ + "${ability_runtime_services_path}/appmgr/src/ability_running_record.cpp", + ] + + sources += [ "ability_running_record_test.cpp" ] + + configs = [ "${ability_runtime_test_path}/unittest:appmgr_test_config" ] + cflags = [] + if (target_cpu == "arm") { + cflags += [ "-DBINDER_IPC_32BIT" ] + } + deps = [ + "${ability_runtime_innerkits_path}/app_manager:app_manager", + "${ability_runtime_native_path}/appkit:appkit_manager_helper", + "${ability_runtime_services_path}/appmgr:libappms", + "${ability_runtime_services_path}/common:perm_verification", + "${ability_runtime_services_path}/common:task_handler_wrap", + "${ability_runtime_test_path}/unittest:appmgr_test_source", + ] + + external_deps = [ + "access_token:libaccesstoken_sdk", + "access_token:libnativetoken", + "access_token:libtoken_setproc", + "appspawn:appspawn_client", + "bundle_framework:appexecfwk_core", + "ffrt:libffrt", + "hilog:libhilog", + "ipc:ipc_core", + ] + + defines = [ "AMS_LOG_TAG = \"AppMgrService\"" ] + + if (ability_command_for_test) { + defines += [ "ABILITY_COMMAND_FOR_TEST" ] + } + + if (ability_runtime_graphics) { + defines += [ "SUPPORT_GRAPHICS" ] + deps += [] + external_deps += [ + "i18n:intl_util", + "window_manager:libwm", + ] + } +} + +group("unittest") { + testonly = true + deps = [ ":ability_running_record_test" ] +} diff --git a/test/unittest/ability_running_record_test/ability_running_record_test.cpp b/test/unittest/ability_running_record_test/ability_running_record_test.cpp new file mode 100644 index 0000000000..694f6325f2 --- /dev/null +++ b/test/unittest/ability_running_record_test/ability_running_record_test.cpp @@ -0,0 +1,720 @@ +/* + * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#define private public +#include "ability_running_record.h" +#undef private + +#include "app_state_callback_host.h" +#include "hilog_tag_wrapper.h" +#include "hilog_wrapper.h" +#include "mock_ability_token.h" + +using namespace testing; +using namespace testing::ext; + +namespace OHOS { +namespace AppExecFwk { +class AbilityRunningRecordTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + void SetUp(); + void TearDown(); +public: +protected: + static const std::string GetTestBundleName() + { + return "test_bundle_name"; + } + static const std::string GetTestAbilityInfoName() + { + return "test_ability_info_name"; + } + static const std::string GetTestModuleName() + { + return "test_module_name"; + } +}; + +void AbilityRunningRecordTest::SetUpTestCase() +{} + +void AbilityRunningRecordTest::TearDownTestCase() +{} + +void AbilityRunningRecordTest::SetUp() +{} + +void AbilityRunningRecordTest::TearDown() +{} + + +/* + * Feature: AbilityRunningRecord + * Function: GetName + * SubFunction: NA + * FunctionPoints: AbilityRunningRecord GetName + * EnvConditions: NA + * CaseDescription: GetName + */ +HWTEST_F(AbilityRunningRecordTest, GetName_001, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "GetName_001 start."); + std::shared_ptr abilityInfo = std::make_shared(); + abilityInfo->name = GetTestAbilityInfoName(); + sptr token = new MockAbilityToken(); + int32_t abilityRecordId = 1; + std::shared_ptr record = std::make_shared(abilityInfo, token, abilityRecordId); + ASSERT_NE(record, nullptr); + auto name = record->GetName(); + ASSERT_EQ(name, "test_ability_info_name"); + TAG_LOGD(AAFwkTag::TEST, "GetName_001 end."); +} + +/* + * Feature: AbilityRunningRecord + * Function: GetBundleName + * SubFunction: NA + * FunctionPoints: AbilityRunningRecord GetBundleName + * EnvConditions: NA + * CaseDescription: GetBundleName + */ +HWTEST_F(AbilityRunningRecordTest, GetBundleName_001, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "GetBundleName_001 start."); + std::shared_ptr abilityInfo = std::make_shared(); + abilityInfo->bundleName = GetTestBundleName(); + sptr token = new MockAbilityToken(); + int32_t abilityRecordId = 1; + std::shared_ptr record = std::make_shared(abilityInfo, token, abilityRecordId); + ASSERT_NE(record, nullptr); + auto name = record->GetBundleName(); + ASSERT_EQ(name, "test_bundle_name"); + TAG_LOGD(AAFwkTag::TEST, "GetBundleName_001 end."); +} + +/* + * Feature: AbilityRunningRecord + * Function: GetModuleName + * SubFunction: NA + * FunctionPoints: AbilityRunningRecord GetModuleName + * EnvConditions: NA + * CaseDescription: GetModuleName + */ +HWTEST_F(AbilityRunningRecordTest, GetModuleName_001, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "GetModuleName_001 start."); + std::shared_ptr abilityInfo = std::make_shared(); + abilityInfo->moduleName = GetTestModuleName(); + sptr token = new MockAbilityToken(); + int32_t abilityRecordId = 1; + std::shared_ptr record = std::make_shared(abilityInfo, token, abilityRecordId); + ASSERT_NE(record, nullptr); + auto name = record->GetModuleName(); + ASSERT_EQ(name, "test_module_name"); + TAG_LOGD(AAFwkTag::TEST, "GetModuleName_001 end."); +} + +/* + * Feature: AbilityRunningRecord + * Function: GetAbilityInfo + * SubFunction: NA + * FunctionPoints: AbilityRunningRecord GetAbilityInfo + * EnvConditions: NA + * CaseDescription: GetAbilityInfo + */ +HWTEST_F(AbilityRunningRecordTest, GetAbilityInfo_001, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "GetAbilityInfo_001 start."); + std::shared_ptr abilityInfo = std::make_shared(); + sptr token = new MockAbilityToken(); + int32_t abilityRecordId = 1; + std::shared_ptr record = std::make_shared(abilityInfo, token, abilityRecordId); + ASSERT_NE(record, nullptr); + auto iret = record->GetAbilityInfo(); + ASSERT_NE(iret, nullptr); + TAG_LOGD(AAFwkTag::TEST, "GetAbilityInfo_001 end."); +} + +/* + * Feature: AbilityRunningRecord + * Function: GetWant + * SubFunction: NA + * FunctionPoints: AbilityRunningRecord GetWant + * EnvConditions: NA + * CaseDescription: GetWant + */ +HWTEST_F(AbilityRunningRecordTest, GetWant_001, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "GetWant_001 start."); + std::shared_ptr abilityInfo = std::make_shared(); + sptr token = new MockAbilityToken(); + int32_t abilityRecordId = 1; + std::shared_ptr record = std::make_shared(abilityInfo, token, abilityRecordId); + ASSERT_NE(record, nullptr); + auto iret = record->GetWant(); + ASSERT_EQ(iret, nullptr); + TAG_LOGD(AAFwkTag::TEST, "GetWant_001 end."); +} + +/* + * Feature: AbilityRunningRecord + * Function: SetWant + * SubFunction: NA + * FunctionPoints: AbilityRunningRecord SetWant + * EnvConditions: NA + * CaseDescription: SetWant + */ +HWTEST_F(AbilityRunningRecordTest, SetWant_001, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "SetWant_001 start."); + std::shared_ptr abilityInfo = std::make_shared(); + sptr token = new MockAbilityToken(); + int32_t abilityRecordId = 1; + std::shared_ptr record = std::make_shared(abilityInfo, token, abilityRecordId); + ASSERT_NE(record, nullptr); + const std::shared_ptr want = std::make_shared(); + record->SetWant(want); + TAG_LOGD(AAFwkTag::TEST, "SetWant_001 end."); +} + +/* + * Feature: AbilityRunningRecord + * Function: GetToken + * SubFunction: NA + * FunctionPoints: AbilityRunningRecord GetToken + * EnvConditions: NA + * CaseDescription: GetToken + */ +HWTEST_F(AbilityRunningRecordTest, GetToken_001, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "GetToken_001 start."); + std::shared_ptr abilityInfo = std::make_shared(); + sptr token = new MockAbilityToken(); + int32_t abilityRecordId = 1; + std::shared_ptr record = std::make_shared(abilityInfo, token, abilityRecordId); + ASSERT_NE(record, nullptr); + auto iret = record->GetToken(); + ASSERT_NE(iret, nullptr); + TAG_LOGD(AAFwkTag::TEST, "GetToken_001 end."); +} + +/* + * Feature: AbilityRunningRecord + * Function: SetState + * SubFunction: NA + * FunctionPoints: AbilityRunningRecord SetState + * EnvConditions: NA + * CaseDescription: SetState + */ +HWTEST_F(AbilityRunningRecordTest, SetState_001, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "SetState_001 start."); + std::shared_ptr abilityInfo = std::make_shared(); + sptr token = new MockAbilityToken(); + int32_t abilityRecordId = 1; + std::shared_ptr record = std::make_shared(abilityInfo, token, abilityRecordId); + ASSERT_NE(record, nullptr); + record->SetState(AbilityState::ABILITY_STATE_CREATE); + TAG_LOGD(AAFwkTag::TEST, "SetState_001 end."); +} + +/* + * Feature: AbilityRunningRecord + * Function: GetState + * SubFunction: NA + * FunctionPoints: AbilityRunningRecord GetState + * EnvConditions: NA + * CaseDescription: GetState + */ +HWTEST_F(AbilityRunningRecordTest, GetState_001, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "GetState_001 start."); + std::shared_ptr abilityInfo = std::make_shared(); + sptr token = new MockAbilityToken(); + int32_t abilityRecordId = 1; + std::shared_ptr record = std::make_shared(abilityInfo, token, abilityRecordId); + ASSERT_NE(record, nullptr); + auto iret = record->GetState(); + ASSERT_EQ(iret, AbilityState::ABILITY_STATE_CREATE); + TAG_LOGD(AAFwkTag::TEST, "GetState_001 end."); +} + +/* + * Feature: AbilityRunningRecord + * Function: IsSameState + * SubFunction: NA + * FunctionPoints: AbilityRunningRecord IsSameState + * EnvConditions: NA + * CaseDescription: IsSameState + */ +HWTEST_F(AbilityRunningRecordTest, IsSameState_001, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "IsSameState_001 start."); + std::shared_ptr abilityInfo = std::make_shared(); + sptr token = new MockAbilityToken(); + int32_t abilityRecordId = 1; + std::shared_ptr record = std::make_shared(abilityInfo, token, abilityRecordId); + ASSERT_NE(record, nullptr); + auto iret = record->IsSameState(AbilityState::ABILITY_STATE_CREATE); + ASSERT_EQ(iret, true); + TAG_LOGD(AAFwkTag::TEST, "IsSameState_001 end."); +} + +/* + * Feature: AbilityRunningRecord + * Function: GetLastLaunchTime + * SubFunction: NA + * FunctionPoints: AbilityRunningRecord GetLastLaunchTime + * EnvConditions: NA + * CaseDescription: GetLastLaunchTime + */ +HWTEST_F(AbilityRunningRecordTest, GetLastLaunchTime_001, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "GetLastLaunchTime_001 start."); + std::shared_ptr abilityInfo = std::make_shared(); + sptr token = new MockAbilityToken(); + int32_t abilityRecordId = 1; + std::shared_ptr record = std::make_shared(abilityInfo, token, abilityRecordId); + ASSERT_NE(record, nullptr); + auto iret = record->GetLastLaunchTime(); + ASSERT_EQ(iret, 0); + TAG_LOGD(AAFwkTag::TEST, "GetLastLaunchTime_001 end."); +} + +/* + * Feature: AbilityRunningRecord + * Function: GetPreToken + * SubFunction: NA + * FunctionPoints: AbilityRunningRecord GetPreToken + * EnvConditions: NA + * CaseDescription: GetPreToken + */ +HWTEST_F(AbilityRunningRecordTest, GetPreToken_001, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "GetPreToken_001 start."); + std::shared_ptr abilityInfo = std::make_shared(); + sptr token = new MockAbilityToken(); + int32_t abilityRecordId = 1; + std::shared_ptr record = std::make_shared(abilityInfo, token, abilityRecordId); + ASSERT_NE(record, nullptr); + auto iret = record->GetPreToken(); + ASSERT_EQ(iret, nullptr); + TAG_LOGD(AAFwkTag::TEST, "GetPreToken_001 end."); +} + +/* + * Feature: AbilityRunningRecord + * Function: SetPreToken + * SubFunction: NA + * FunctionPoints: AbilityRunningRecord SetPreToken + * EnvConditions: NA + * CaseDescription: SetPreToken + */ +HWTEST_F(AbilityRunningRecordTest, SetPreToken_001, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "SetPreToken_001 start."); + std::shared_ptr abilityInfo = std::make_shared(); + sptr token = new MockAbilityToken(); + int32_t abilityRecordId = 1; + std::shared_ptr record = std::make_shared(abilityInfo, token, abilityRecordId); + ASSERT_NE(record, nullptr); + sptr pretoken = new MockAbilityToken(); + record->SetPreToken(pretoken); + TAG_LOGD(AAFwkTag::TEST, "SetPreToken_001 end."); +} + +/* + * Feature: AbilityRunningRecord + * Function: SetVisibility + * SubFunction: NA + * FunctionPoints: AbilityRunningRecord SetVisibility + * EnvConditions: NA + * CaseDescription: SetVisibility + */ +HWTEST_F(AbilityRunningRecordTest, SetVisibility_001, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "SetVisibility_001 start."); + std::shared_ptr abilityInfo = std::make_shared(); + sptr token = new MockAbilityToken(); + int32_t abilityRecordId = 1; + std::shared_ptr record = std::make_shared(abilityInfo, token, abilityRecordId); + ASSERT_NE(record, nullptr); + const int32_t visibility = 1; + record->SetVisibility(visibility); + TAG_LOGD(AAFwkTag::TEST, "SetVisibility_001 end."); +} + +/* + * Feature: AbilityRunningRecord + * Function: GetVisibility + * SubFunction: NA + * FunctionPoints: AbilityRunningRecord GetVisibility + * EnvConditions: NA + * CaseDescription: GetVisibility + */ +HWTEST_F(AbilityRunningRecordTest, GetVisibility_001, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "GetVisibility_001 start."); + std::shared_ptr abilityInfo = std::make_shared(); + sptr token = new MockAbilityToken(); + int32_t abilityRecordId = 1; + std::shared_ptr record = std::make_shared(abilityInfo, token, abilityRecordId); + ASSERT_NE(record, nullptr); + auto iret = record->GetVisibility(); + ASSERT_EQ(iret, 0); + TAG_LOGD(AAFwkTag::TEST, "GetVisibility_001 end."); +} + +/* + * Feature: AbilityRunningRecord + * Function: SetPerceptibility + * SubFunction: NA + * FunctionPoints: AbilityRunningRecord SetPerceptibility + * EnvConditions: NA + * CaseDescription: SetPerceptibility + */ +HWTEST_F(AbilityRunningRecordTest, SetPerceptibility_001, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "SetPerceptibility_001 start."); + std::shared_ptr abilityInfo = std::make_shared(); + sptr token = new MockAbilityToken(); + int32_t abilityRecordId = 1; + std::shared_ptr record = std::make_shared(abilityInfo, token, abilityRecordId); + ASSERT_NE(record, nullptr); + const int32_t perceptibility = 1; + record->SetPerceptibility(perceptibility); + TAG_LOGD(AAFwkTag::TEST, "SetPerceptibility_001 end."); +} + +/* + * Feature: AbilityRunningRecord + * Function: GetPerceptibility + * SubFunction: NA + * FunctionPoints: AbilityRunningRecord GetPerceptibility + * EnvConditions: NA + * CaseDescription: GetPerceptibility + */ +HWTEST_F(AbilityRunningRecordTest, GetPerceptibility_001, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "GetPerceptibility_001 start."); + std::shared_ptr abilityInfo = std::make_shared(); + sptr token = new MockAbilityToken(); + int32_t abilityRecordId = 1; + std::shared_ptr record = std::make_shared(abilityInfo, token, abilityRecordId); + ASSERT_NE(record, nullptr); + auto iret = record->GetPerceptibility(); + ASSERT_EQ(iret, 0); + TAG_LOGD(AAFwkTag::TEST, "GetPerceptibility_001 end."); +} + +/* + * Feature: AbilityRunningRecord + * Function: SetConnectionState + * SubFunction: NA + * FunctionPoints: AbilityRunningRecord SetConnectionState + * EnvConditions: NA + * CaseDescription: SetConnectionState + */ +HWTEST_F(AbilityRunningRecordTest, SetConnectionState_001, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "SetConnectionState_001 start."); + std::shared_ptr abilityInfo = std::make_shared(); + sptr token = new MockAbilityToken(); + int32_t abilityRecordId = 1; + std::shared_ptr record = std::make_shared(abilityInfo, token, abilityRecordId); + ASSERT_NE(record, nullptr); + const int32_t connectionState = 1; + record->SetConnectionState(connectionState); + TAG_LOGD(AAFwkTag::TEST, "SetConnectionState_001 end."); +} + +/* + * Feature: AbilityRunningRecord + * Function: GetConnectionState + * SubFunction: NA + * FunctionPoints: AbilityRunningRecord GetConnectionState + * EnvConditions: NA + * CaseDescription: GetConnectionState + */ +HWTEST_F(AbilityRunningRecordTest, GetConnectionState_001, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "GetConnectionState_001 start."); + std::shared_ptr abilityInfo = std::make_shared(); + sptr token = new MockAbilityToken(); + int32_t abilityRecordId = 1; + std::shared_ptr record = std::make_shared(abilityInfo, token, abilityRecordId); + ASSERT_NE(record, nullptr); + auto iret = record->GetConnectionState(); + ASSERT_EQ(iret, 0); + TAG_LOGD(AAFwkTag::TEST, "GetConnectionState_001 end."); +} + +/* + * Feature: AbilityRunningRecord + * Function: SetEventId + * SubFunction: NA + * FunctionPoints: AbilityRunningRecord SetEventId + * EnvConditions: NA + * CaseDescription: SetEventId + */ +HWTEST_F(AbilityRunningRecordTest, SetEventId_001, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "SetEventId_001 start."); + std::shared_ptr abilityInfo = std::make_shared(); + sptr token = new MockAbilityToken(); + int32_t abilityRecordId = 1; + std::shared_ptr record = std::make_shared(abilityInfo, token, abilityRecordId); + ASSERT_NE(record, nullptr); + const int64_t eventId = 1; + record->SetEventId(eventId); + TAG_LOGD(AAFwkTag::TEST, "SetEventId_001 end."); +} + +/* + * Feature: AbilityRunningRecord + * Function: GetEventId + * SubFunction: NA + * FunctionPoints: AbilityRunningRecord GetEventId + * EnvConditions: NA + * CaseDescription: GetEventId + */ +HWTEST_F(AbilityRunningRecordTest, GetEventId_001, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "GetEventId_001 start."); + std::shared_ptr abilityInfo = std::make_shared(); + sptr token = new MockAbilityToken(); + int32_t abilityRecordId = 1; + std::shared_ptr record = std::make_shared(abilityInfo, token, abilityRecordId); + ASSERT_NE(record, nullptr); + auto iret = record->GetEventId(); + ASSERT_EQ(iret, 0); + TAG_LOGD(AAFwkTag::TEST, "GetEventId_001 end."); +} + +/* + * Feature: AbilityRunningRecord + * Function: SetTerminating + * SubFunction: NA + * FunctionPoints: AbilityRunningRecord SetTerminating + * EnvConditions: NA + * CaseDescription: SetTerminating + */ +HWTEST_F(AbilityRunningRecordTest, SetTerminating_001, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "SetTerminating_001 start."); + std::shared_ptr abilityInfo = std::make_shared(); + sptr token = new MockAbilityToken(); + int32_t abilityRecordId = 1; + std::shared_ptr record = std::make_shared(abilityInfo, token, abilityRecordId); + ASSERT_NE(record, nullptr); + record->SetTerminating(); + TAG_LOGD(AAFwkTag::TEST, "SetTerminating_001 end."); +} + +/* + * Feature: AbilityRunningRecord + * Function: IsTerminating + * SubFunction: NA + * FunctionPoints: AbilityRunningRecord IsTerminating + * EnvConditions: NA + * CaseDescription: IsTerminating + */ +HWTEST_F(AbilityRunningRecordTest, IsTerminating_001, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "IsTerminating_001 start."); + std::shared_ptr abilityInfo = std::make_shared(); + sptr token = new MockAbilityToken(); + int32_t abilityRecordId = 1; + std::shared_ptr record = std::make_shared(abilityInfo, token, abilityRecordId); + ASSERT_NE(record, nullptr); + auto iret = record->IsTerminating(); + ASSERT_EQ(iret, false); + TAG_LOGD(AAFwkTag::TEST, "IsTerminating_001 end."); +} + +/* + * Feature: AbilityRunningRecord + * Function: SetOwnerUserId + * SubFunction: NA + * FunctionPoints: AbilityRunningRecord SetOwnerUserId + * EnvConditions: NA + * CaseDescription: SetOwnerUserId + */ +HWTEST_F(AbilityRunningRecordTest, SetOwnerUserId_001, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "SetOwnerUserId_001 start."); + std::shared_ptr abilityInfo = std::make_shared(); + sptr token = new MockAbilityToken(); + int32_t abilityRecordId = 1; + std::shared_ptr record = std::make_shared(abilityInfo, token, abilityRecordId); + ASSERT_NE(record, nullptr); + int32_t ownerUserId = 1; + record->SetOwnerUserId(ownerUserId); + TAG_LOGD(AAFwkTag::TEST, "SetOwnerUserId_001 end."); +} + +/* + * Feature: AbilityRunningRecord + * Function: GetOwnerUserId + * SubFunction: NA + * FunctionPoints: AbilityRunningRecord GetOwnerUserId + * EnvConditions: NA + * CaseDescription: GetOwnerUserId + */ +HWTEST_F(AbilityRunningRecordTest, GetOwnerUserId_001, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "GetOwnerUserId_001 start."); + std::shared_ptr abilityInfo = std::make_shared(); + sptr token = new MockAbilityToken(); + int32_t abilityRecordId = 1; + std::shared_ptr record = std::make_shared(abilityInfo, token, abilityRecordId); + ASSERT_NE(record, nullptr); + auto iret = record->GetOwnerUserId(); + ASSERT_EQ(iret, -1); + TAG_LOGD(AAFwkTag::TEST, "GetOwnerUserId_001 end."); +} + +/* + * Feature: AbilityRunningRecord + * Function: SetIsSingleUser + * SubFunction: NA + * FunctionPoints: AbilityRunningRecord SetIsSingleUser + * EnvConditions: NA + * CaseDescription: SetIsSingleUser + */ +HWTEST_F(AbilityRunningRecordTest, SetIsSingleUser_001, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "SetIsSingleUser_001 start."); + std::shared_ptr abilityInfo = std::make_shared(); + sptr token = new MockAbilityToken(); + int32_t abilityRecordId = 1; + std::shared_ptr record = std::make_shared(abilityInfo, token, abilityRecordId); + ASSERT_NE(record, nullptr); + bool flag = true; + record->SetIsSingleUser(flag); + TAG_LOGD(AAFwkTag::TEST, "SetIsSingleUser_001 end."); +} + +/* + * Feature: AbilityRunningRecord + * Function: IsSingleUser + * SubFunction: NA + * FunctionPoints: AbilityRunningRecord IsSingleUser + * EnvConditions: NA + * CaseDescription: IsSingleUser + */ +HWTEST_F(AbilityRunningRecordTest, IsSingleUser_001, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "IsSingleUser_001 start."); + std::shared_ptr abilityInfo = std::make_shared(); + sptr token = new MockAbilityToken(); + int32_t abilityRecordId = 1; + std::shared_ptr record = std::make_shared(abilityInfo, token, abilityRecordId); + ASSERT_NE(record, nullptr); + auto iret = record->IsSingleUser(); + ASSERT_EQ(iret, false); + TAG_LOGD(AAFwkTag::TEST, "IsSingleUser_001 end."); +} + +/* + * Feature: AbilityRunningRecord + * Function: UpdateFocusState + * SubFunction: NA + * FunctionPoints: AbilityRunningRecord UpdateFocusState + * EnvConditions: NA + * CaseDescription: UpdateFocusState + */ +HWTEST_F(AbilityRunningRecordTest, UpdateFocusState_001, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "UpdateFocusState_001 start."); + std::shared_ptr abilityInfo = std::make_shared(); + sptr token = new MockAbilityToken(); + int32_t abilityRecordId = 1; + std::shared_ptr record = std::make_shared(abilityInfo, token, abilityRecordId); + ASSERT_NE(record, nullptr); + bool isFocus = true; + record->UpdateFocusState(isFocus); + TAG_LOGD(AAFwkTag::TEST, "UpdateFocusState_001 end."); +} + +/* + * Feature: AbilityRunningRecord + * Function: GetFocusFlag + * SubFunction: NA + * FunctionPoints: AbilityRunningRecord GetFocusFlag + * EnvConditions: NA + * CaseDescription: GetFocusFlag + */ +HWTEST_F(AbilityRunningRecordTest, GetFocusFlag_001, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "GetFocusFlag_001 start."); + std::shared_ptr abilityInfo = std::make_shared(); + sptr token = new MockAbilityToken(); + int32_t abilityRecordId = 1; + std::shared_ptr record = std::make_shared(abilityInfo, token, abilityRecordId); + ASSERT_NE(record, nullptr); + auto iret = record->GetFocusFlag(); + ASSERT_EQ(iret, false); + TAG_LOGD(AAFwkTag::TEST, "GetFocusFlag_001 end."); +} + +/* + * Feature: AbilityRunningRecord + * Function: SetUIExtensionAbilityId + * SubFunction: NA + * FunctionPoints: AbilityRunningRecord SetUIExtensionAbilityId + * EnvConditions: NA + * CaseDescription: SetUIExtensionAbilityId + */ +HWTEST_F(AbilityRunningRecordTest, SetUIExtensionAbilityId_001, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "SetUIExtensionAbilityId_001 start."); + std::shared_ptr abilityInfo = std::make_shared(); + sptr token = new MockAbilityToken(); + int32_t abilityRecordId = 1; + std::shared_ptr record = std::make_shared(abilityInfo, token, abilityRecordId); + ASSERT_NE(record, nullptr); + const int32_t uiExtensionAbilityId = 1; + record->SetUIExtensionAbilityId(uiExtensionAbilityId); + TAG_LOGD(AAFwkTag::TEST, "SetUIExtensionAbilityId_001 end."); +} + +/* + * Feature: AbilityRunningRecord + * Function: GetUIExtensionAbilityId + * SubFunction: NA + * FunctionPoints: AbilityRunningRecord GetUIExtensionAbilityId + * EnvConditions: NA + * CaseDescription: GetUIExtensionAbilityId + */ +HWTEST_F(AbilityRunningRecordTest, GetUIExtensionAbilityId_001, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "GetUIExtensionAbilityId_001 start."); + std::shared_ptr abilityInfo = std::make_shared(); + sptr token = new MockAbilityToken(); + int32_t abilityRecordId = 1; + std::shared_ptr record = std::make_shared(abilityInfo, token, abilityRecordId); + ASSERT_NE(record, nullptr); + auto iret = record->GetUIExtensionAbilityId(); + ASSERT_EQ(iret, 0); + TAG_LOGD(AAFwkTag::TEST, "GetUIExtensionAbilityId_001 end."); +} + +} // namespace AppExecFwk +} // namespace OHOS From 2de7d99671419e481c3a18bedd12641c0c51ff8e Mon Sep 17 00:00:00 2001 From: zhubingwei Date: Tue, 21 May 2024 17:14:50 +0800 Subject: [PATCH 151/174] =?UTF-8?q?=E4=BF=AE=E5=A4=8DCodeCheck?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhubingwei Change-Id: I963773b8973b6572adaf586aefa710c56a4427e9 --- .../ability_running_record_test.cpp | 65 +++++++++---------- 1 file changed, 31 insertions(+), 34 deletions(-) diff --git a/test/unittest/ability_running_record_test/ability_running_record_test.cpp b/test/unittest/ability_running_record_test/ability_running_record_test.cpp index 694f6325f2..e80bb96be8 100644 --- a/test/unittest/ability_running_record_test/ability_running_record_test.cpp +++ b/test/unittest/ability_running_record_test/ability_running_record_test.cpp @@ -15,10 +15,7 @@ #include -#define private public #include "ability_running_record.h" -#undef private - #include "app_state_callback_host.h" #include "hilog_tag_wrapper.h" #include "hilog_wrapper.h" @@ -79,7 +76,7 @@ HWTEST_F(AbilityRunningRecordTest, GetName_001, TestSize.Level1) abilityInfo->name = GetTestAbilityInfoName(); sptr token = new MockAbilityToken(); int32_t abilityRecordId = 1; - std::shared_ptr record = std::make_shared(abilityInfo, token, abilityRecordId); + auto record = std::make_shared(abilityInfo, token, abilityRecordId); ASSERT_NE(record, nullptr); auto name = record->GetName(); ASSERT_EQ(name, "test_ability_info_name"); @@ -101,7 +98,7 @@ HWTEST_F(AbilityRunningRecordTest, GetBundleName_001, TestSize.Level1) abilityInfo->bundleName = GetTestBundleName(); sptr token = new MockAbilityToken(); int32_t abilityRecordId = 1; - std::shared_ptr record = std::make_shared(abilityInfo, token, abilityRecordId); + auto record = std::make_shared(abilityInfo, token, abilityRecordId); ASSERT_NE(record, nullptr); auto name = record->GetBundleName(); ASSERT_EQ(name, "test_bundle_name"); @@ -123,7 +120,7 @@ HWTEST_F(AbilityRunningRecordTest, GetModuleName_001, TestSize.Level1) abilityInfo->moduleName = GetTestModuleName(); sptr token = new MockAbilityToken(); int32_t abilityRecordId = 1; - std::shared_ptr record = std::make_shared(abilityInfo, token, abilityRecordId); + auto record = std::make_shared(abilityInfo, token, abilityRecordId); ASSERT_NE(record, nullptr); auto name = record->GetModuleName(); ASSERT_EQ(name, "test_module_name"); @@ -144,7 +141,7 @@ HWTEST_F(AbilityRunningRecordTest, GetAbilityInfo_001, TestSize.Level1) std::shared_ptr abilityInfo = std::make_shared(); sptr token = new MockAbilityToken(); int32_t abilityRecordId = 1; - std::shared_ptr record = std::make_shared(abilityInfo, token, abilityRecordId); + auto record = std::make_shared(abilityInfo, token, abilityRecordId); ASSERT_NE(record, nullptr); auto iret = record->GetAbilityInfo(); ASSERT_NE(iret, nullptr); @@ -165,7 +162,7 @@ HWTEST_F(AbilityRunningRecordTest, GetWant_001, TestSize.Level1) std::shared_ptr abilityInfo = std::make_shared(); sptr token = new MockAbilityToken(); int32_t abilityRecordId = 1; - std::shared_ptr record = std::make_shared(abilityInfo, token, abilityRecordId); + auto record = std::make_shared(abilityInfo, token, abilityRecordId); ASSERT_NE(record, nullptr); auto iret = record->GetWant(); ASSERT_EQ(iret, nullptr); @@ -186,7 +183,7 @@ HWTEST_F(AbilityRunningRecordTest, SetWant_001, TestSize.Level1) std::shared_ptr abilityInfo = std::make_shared(); sptr token = new MockAbilityToken(); int32_t abilityRecordId = 1; - std::shared_ptr record = std::make_shared(abilityInfo, token, abilityRecordId); + auto record = std::make_shared(abilityInfo, token, abilityRecordId); ASSERT_NE(record, nullptr); const std::shared_ptr want = std::make_shared(); record->SetWant(want); @@ -207,7 +204,7 @@ HWTEST_F(AbilityRunningRecordTest, GetToken_001, TestSize.Level1) std::shared_ptr abilityInfo = std::make_shared(); sptr token = new MockAbilityToken(); int32_t abilityRecordId = 1; - std::shared_ptr record = std::make_shared(abilityInfo, token, abilityRecordId); + auto record = std::make_shared(abilityInfo, token, abilityRecordId); ASSERT_NE(record, nullptr); auto iret = record->GetToken(); ASSERT_NE(iret, nullptr); @@ -228,7 +225,7 @@ HWTEST_F(AbilityRunningRecordTest, SetState_001, TestSize.Level1) std::shared_ptr abilityInfo = std::make_shared(); sptr token = new MockAbilityToken(); int32_t abilityRecordId = 1; - std::shared_ptr record = std::make_shared(abilityInfo, token, abilityRecordId); + auto record = std::make_shared(abilityInfo, token, abilityRecordId); ASSERT_NE(record, nullptr); record->SetState(AbilityState::ABILITY_STATE_CREATE); TAG_LOGD(AAFwkTag::TEST, "SetState_001 end."); @@ -248,7 +245,7 @@ HWTEST_F(AbilityRunningRecordTest, GetState_001, TestSize.Level1) std::shared_ptr abilityInfo = std::make_shared(); sptr token = new MockAbilityToken(); int32_t abilityRecordId = 1; - std::shared_ptr record = std::make_shared(abilityInfo, token, abilityRecordId); + auto record = std::make_shared(abilityInfo, token, abilityRecordId); ASSERT_NE(record, nullptr); auto iret = record->GetState(); ASSERT_EQ(iret, AbilityState::ABILITY_STATE_CREATE); @@ -269,7 +266,7 @@ HWTEST_F(AbilityRunningRecordTest, IsSameState_001, TestSize.Level1) std::shared_ptr abilityInfo = std::make_shared(); sptr token = new MockAbilityToken(); int32_t abilityRecordId = 1; - std::shared_ptr record = std::make_shared(abilityInfo, token, abilityRecordId); + auto record = std::make_shared(abilityInfo, token, abilityRecordId); ASSERT_NE(record, nullptr); auto iret = record->IsSameState(AbilityState::ABILITY_STATE_CREATE); ASSERT_EQ(iret, true); @@ -290,7 +287,7 @@ HWTEST_F(AbilityRunningRecordTest, GetLastLaunchTime_001, TestSize.Level1) std::shared_ptr abilityInfo = std::make_shared(); sptr token = new MockAbilityToken(); int32_t abilityRecordId = 1; - std::shared_ptr record = std::make_shared(abilityInfo, token, abilityRecordId); + auto record = std::make_shared(abilityInfo, token, abilityRecordId); ASSERT_NE(record, nullptr); auto iret = record->GetLastLaunchTime(); ASSERT_EQ(iret, 0); @@ -311,7 +308,7 @@ HWTEST_F(AbilityRunningRecordTest, GetPreToken_001, TestSize.Level1) std::shared_ptr abilityInfo = std::make_shared(); sptr token = new MockAbilityToken(); int32_t abilityRecordId = 1; - std::shared_ptr record = std::make_shared(abilityInfo, token, abilityRecordId); + auto record = std::make_shared(abilityInfo, token, abilityRecordId); ASSERT_NE(record, nullptr); auto iret = record->GetPreToken(); ASSERT_EQ(iret, nullptr); @@ -332,7 +329,7 @@ HWTEST_F(AbilityRunningRecordTest, SetPreToken_001, TestSize.Level1) std::shared_ptr abilityInfo = std::make_shared(); sptr token = new MockAbilityToken(); int32_t abilityRecordId = 1; - std::shared_ptr record = std::make_shared(abilityInfo, token, abilityRecordId); + auto record = std::make_shared(abilityInfo, token, abilityRecordId); ASSERT_NE(record, nullptr); sptr pretoken = new MockAbilityToken(); record->SetPreToken(pretoken); @@ -353,7 +350,7 @@ HWTEST_F(AbilityRunningRecordTest, SetVisibility_001, TestSize.Level1) std::shared_ptr abilityInfo = std::make_shared(); sptr token = new MockAbilityToken(); int32_t abilityRecordId = 1; - std::shared_ptr record = std::make_shared(abilityInfo, token, abilityRecordId); + auto record = std::make_shared(abilityInfo, token, abilityRecordId); ASSERT_NE(record, nullptr); const int32_t visibility = 1; record->SetVisibility(visibility); @@ -374,7 +371,7 @@ HWTEST_F(AbilityRunningRecordTest, GetVisibility_001, TestSize.Level1) std::shared_ptr abilityInfo = std::make_shared(); sptr token = new MockAbilityToken(); int32_t abilityRecordId = 1; - std::shared_ptr record = std::make_shared(abilityInfo, token, abilityRecordId); + auto record = std::make_shared(abilityInfo, token, abilityRecordId); ASSERT_NE(record, nullptr); auto iret = record->GetVisibility(); ASSERT_EQ(iret, 0); @@ -395,7 +392,7 @@ HWTEST_F(AbilityRunningRecordTest, SetPerceptibility_001, TestSize.Level1) std::shared_ptr abilityInfo = std::make_shared(); sptr token = new MockAbilityToken(); int32_t abilityRecordId = 1; - std::shared_ptr record = std::make_shared(abilityInfo, token, abilityRecordId); + auto record = std::make_shared(abilityInfo, token, abilityRecordId); ASSERT_NE(record, nullptr); const int32_t perceptibility = 1; record->SetPerceptibility(perceptibility); @@ -416,7 +413,7 @@ HWTEST_F(AbilityRunningRecordTest, GetPerceptibility_001, TestSize.Level1) std::shared_ptr abilityInfo = std::make_shared(); sptr token = new MockAbilityToken(); int32_t abilityRecordId = 1; - std::shared_ptr record = std::make_shared(abilityInfo, token, abilityRecordId); + auto record = std::make_shared(abilityInfo, token, abilityRecordId); ASSERT_NE(record, nullptr); auto iret = record->GetPerceptibility(); ASSERT_EQ(iret, 0); @@ -437,7 +434,7 @@ HWTEST_F(AbilityRunningRecordTest, SetConnectionState_001, TestSize.Level1) std::shared_ptr abilityInfo = std::make_shared(); sptr token = new MockAbilityToken(); int32_t abilityRecordId = 1; - std::shared_ptr record = std::make_shared(abilityInfo, token, abilityRecordId); + auto record = std::make_shared(abilityInfo, token, abilityRecordId); ASSERT_NE(record, nullptr); const int32_t connectionState = 1; record->SetConnectionState(connectionState); @@ -458,7 +455,7 @@ HWTEST_F(AbilityRunningRecordTest, GetConnectionState_001, TestSize.Level1) std::shared_ptr abilityInfo = std::make_shared(); sptr token = new MockAbilityToken(); int32_t abilityRecordId = 1; - std::shared_ptr record = std::make_shared(abilityInfo, token, abilityRecordId); + auto record = std::make_shared(abilityInfo, token, abilityRecordId); ASSERT_NE(record, nullptr); auto iret = record->GetConnectionState(); ASSERT_EQ(iret, 0); @@ -479,7 +476,7 @@ HWTEST_F(AbilityRunningRecordTest, SetEventId_001, TestSize.Level1) std::shared_ptr abilityInfo = std::make_shared(); sptr token = new MockAbilityToken(); int32_t abilityRecordId = 1; - std::shared_ptr record = std::make_shared(abilityInfo, token, abilityRecordId); + auto record = std::make_shared(abilityInfo, token, abilityRecordId); ASSERT_NE(record, nullptr); const int64_t eventId = 1; record->SetEventId(eventId); @@ -500,7 +497,7 @@ HWTEST_F(AbilityRunningRecordTest, GetEventId_001, TestSize.Level1) std::shared_ptr abilityInfo = std::make_shared(); sptr token = new MockAbilityToken(); int32_t abilityRecordId = 1; - std::shared_ptr record = std::make_shared(abilityInfo, token, abilityRecordId); + auto record = std::make_shared(abilityInfo, token, abilityRecordId); ASSERT_NE(record, nullptr); auto iret = record->GetEventId(); ASSERT_EQ(iret, 0); @@ -521,7 +518,7 @@ HWTEST_F(AbilityRunningRecordTest, SetTerminating_001, TestSize.Level1) std::shared_ptr abilityInfo = std::make_shared(); sptr token = new MockAbilityToken(); int32_t abilityRecordId = 1; - std::shared_ptr record = std::make_shared(abilityInfo, token, abilityRecordId); + auto record = std::make_shared(abilityInfo, token, abilityRecordId); ASSERT_NE(record, nullptr); record->SetTerminating(); TAG_LOGD(AAFwkTag::TEST, "SetTerminating_001 end."); @@ -541,7 +538,7 @@ HWTEST_F(AbilityRunningRecordTest, IsTerminating_001, TestSize.Level1) std::shared_ptr abilityInfo = std::make_shared(); sptr token = new MockAbilityToken(); int32_t abilityRecordId = 1; - std::shared_ptr record = std::make_shared(abilityInfo, token, abilityRecordId); + auto record = std::make_shared(abilityInfo, token, abilityRecordId); ASSERT_NE(record, nullptr); auto iret = record->IsTerminating(); ASSERT_EQ(iret, false); @@ -562,7 +559,7 @@ HWTEST_F(AbilityRunningRecordTest, SetOwnerUserId_001, TestSize.Level1) std::shared_ptr abilityInfo = std::make_shared(); sptr token = new MockAbilityToken(); int32_t abilityRecordId = 1; - std::shared_ptr record = std::make_shared(abilityInfo, token, abilityRecordId); + auto record = std::make_shared(abilityInfo, token, abilityRecordId); ASSERT_NE(record, nullptr); int32_t ownerUserId = 1; record->SetOwnerUserId(ownerUserId); @@ -583,7 +580,7 @@ HWTEST_F(AbilityRunningRecordTest, GetOwnerUserId_001, TestSize.Level1) std::shared_ptr abilityInfo = std::make_shared(); sptr token = new MockAbilityToken(); int32_t abilityRecordId = 1; - std::shared_ptr record = std::make_shared(abilityInfo, token, abilityRecordId); + auto record = std::make_shared(abilityInfo, token, abilityRecordId); ASSERT_NE(record, nullptr); auto iret = record->GetOwnerUserId(); ASSERT_EQ(iret, -1); @@ -604,7 +601,7 @@ HWTEST_F(AbilityRunningRecordTest, SetIsSingleUser_001, TestSize.Level1) std::shared_ptr abilityInfo = std::make_shared(); sptr token = new MockAbilityToken(); int32_t abilityRecordId = 1; - std::shared_ptr record = std::make_shared(abilityInfo, token, abilityRecordId); + auto record = std::make_shared(abilityInfo, token, abilityRecordId); ASSERT_NE(record, nullptr); bool flag = true; record->SetIsSingleUser(flag); @@ -625,7 +622,7 @@ HWTEST_F(AbilityRunningRecordTest, IsSingleUser_001, TestSize.Level1) std::shared_ptr abilityInfo = std::make_shared(); sptr token = new MockAbilityToken(); int32_t abilityRecordId = 1; - std::shared_ptr record = std::make_shared(abilityInfo, token, abilityRecordId); + auto record = std::make_shared(abilityInfo, token, abilityRecordId); ASSERT_NE(record, nullptr); auto iret = record->IsSingleUser(); ASSERT_EQ(iret, false); @@ -646,7 +643,7 @@ HWTEST_F(AbilityRunningRecordTest, UpdateFocusState_001, TestSize.Level1) std::shared_ptr abilityInfo = std::make_shared(); sptr token = new MockAbilityToken(); int32_t abilityRecordId = 1; - std::shared_ptr record = std::make_shared(abilityInfo, token, abilityRecordId); + auto record = std::make_shared(abilityInfo, token, abilityRecordId); ASSERT_NE(record, nullptr); bool isFocus = true; record->UpdateFocusState(isFocus); @@ -667,7 +664,7 @@ HWTEST_F(AbilityRunningRecordTest, GetFocusFlag_001, TestSize.Level1) std::shared_ptr abilityInfo = std::make_shared(); sptr token = new MockAbilityToken(); int32_t abilityRecordId = 1; - std::shared_ptr record = std::make_shared(abilityInfo, token, abilityRecordId); + auto record = std::make_shared(abilityInfo, token, abilityRecordId); ASSERT_NE(record, nullptr); auto iret = record->GetFocusFlag(); ASSERT_EQ(iret, false); @@ -688,7 +685,7 @@ HWTEST_F(AbilityRunningRecordTest, SetUIExtensionAbilityId_001, TestSize.Level1) std::shared_ptr abilityInfo = std::make_shared(); sptr token = new MockAbilityToken(); int32_t abilityRecordId = 1; - std::shared_ptr record = std::make_shared(abilityInfo, token, abilityRecordId); + auto record = std::make_shared(abilityInfo, token, abilityRecordId); ASSERT_NE(record, nullptr); const int32_t uiExtensionAbilityId = 1; record->SetUIExtensionAbilityId(uiExtensionAbilityId); @@ -709,7 +706,7 @@ HWTEST_F(AbilityRunningRecordTest, GetUIExtensionAbilityId_001, TestSize.Level1) std::shared_ptr abilityInfo = std::make_shared(); sptr token = new MockAbilityToken(); int32_t abilityRecordId = 1; - std::shared_ptr record = std::make_shared(abilityInfo, token, abilityRecordId); + auto record = std::make_shared(abilityInfo, token, abilityRecordId); ASSERT_NE(record, nullptr); auto iret = record->GetUIExtensionAbilityId(); ASSERT_EQ(iret, 0); From 4ffff640679103dbc7b55a3b82e159b77df6947e Mon Sep 17 00:00:00 2001 From: zhubingwei Date: Wed, 22 May 2024 08:29:23 +0800 Subject: [PATCH 152/174] =?UTF-8?q?format=20gn=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhubingwei Change-Id: I711726a4e45844255bb4121e147f44cc5a28362b --- test/unittest/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unittest/BUILD.gn b/test/unittest/BUILD.gn index 76d9203add..610c839dc0 100644 --- a/test/unittest/BUILD.gn +++ b/test/unittest/BUILD.gn @@ -352,8 +352,8 @@ group("unittest") { "ability_record_mgr_test:unittest", "ability_record_test:unittest", "ability_running_info_test:unittest", - "ability_runtime_error_util_test:unittest", "ability_running_record_test:unittest", + "ability_runtime_error_util_test:unittest", "ability_scheduler_proxy_test:unittest", "ability_scheduler_stub_test:unittest", "ability_service_extension_test:unittest", From 0e61e122bd38cace1584710db72eb68b8681497f Mon Sep 17 00:00:00 2001 From: Jasperjiao Date: Wed, 22 May 2024 10:07:55 +0800 Subject: [PATCH 153/174] =?UTF-8?q?=E5=BA=94=E7=94=A8=E5=90=AF=E5=8A=A8?= =?UTF-8?q?=E7=AE=A1=E6=8E=A7hisysevent=E5=BC=95=E5=85=A5yaml=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jasperjiao --- hisysevent.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/hisysevent.yaml b/hisysevent.yaml index 7ee5356092..b86757f71b 100644 --- a/hisysevent.yaml +++ b/hisysevent.yaml @@ -352,3 +352,14 @@ START_STANDARD_ABILITIES: BUNDLE_NAME: {type: STRING, desc: bundle name} MODULE_NAME: {type: STRING, desc: module name} ABILITY_NAME: {type: STRING, desc: ability name} + +PREVENT_START_ABILITY: + __BASE: {type: BEHAVIOR, level: MINOR, desc: Process start control, preserve: true} + CALLER_UID: {type: INT32, desc: caller uid} + CALLER_PID: {type: INT32, desc: caller pid} + CALLER_PROCESS_NAME: {type: STRING, desc: caller process name} + CALLER_BUNDLE_NAME: {type: STRING, desc: caller bundle name} + CALLEE_BUNDLE_NAME: {type: STRING, desc: callee bundle name} + CALLEE_PROCESS_NAME: {type: STRING, desc: callee process name} + EXTENSION_ABILITY_TYPE: {type: INT32, desc: extension ability type} + ABILITY_NAME: {type: STRING, desc: caller ability name} \ No newline at end of file From 97673bd4f1d361f810ad21f7bc1b374546856586 Mon Sep 17 00:00:00 2001 From: zhubingwei Date: Wed, 22 May 2024 02:37:39 +0000 Subject: [PATCH 154/174] =?UTF-8?q?data=20observer=20UT=20=E9=97=A8?= =?UTF-8?q?=E7=A6=81=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhubingwei --- .../dataobs_mgr_stub_test/dataobs_mgr_stub_test.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/unittest/dataobs_mgr_stub_test/dataobs_mgr_stub_test.cpp b/test/unittest/dataobs_mgr_stub_test/dataobs_mgr_stub_test.cpp index ad13cbc838..a2c9994fc7 100644 --- a/test/unittest/dataobs_mgr_stub_test/dataobs_mgr_stub_test.cpp +++ b/test/unittest/dataobs_mgr_stub_test/dataobs_mgr_stub_test.cpp @@ -236,7 +236,8 @@ HWTEST_F(DataObsManagerStubTest, AaFwk_DataObsManagerStubTest_RegisterObserverEx return; } - EXPECT_CALL(*dataobs, RegisterObserverExt(testing::_, testing::_, testing::_)).Times(1).WillOnce(testing::Return(testVal2)); + EXPECT_CALL(*dataobs, RegisterObserverExt(testing::_, testing::_, testing::_)).Times(1) + .WillOnce(testing::Return(testVal2)); const int retval1 = dataobs->OnRemoteRequest(code, data, reply, option); const int retval2 = reply.ReadInt32(); @@ -314,8 +315,7 @@ HWTEST_F(DataObsManagerStubTest, AaFwk_DataObsManagerStubTest_UnregisterObserver return; } - EXPECT_CALL(*dataobs, UnregisterObserverExt(testing::_)).Times(1) - .WillOnce(testing::Return(testVal2)); + EXPECT_CALL(*dataobs, UnregisterObserverExt(testing::_)).Times(1).WillOnce(testing::Return(testVal2)); const int retval1 = dataobs->OnRemoteRequest(code, data, reply, option); const int retval2 = reply.ReadInt32(); From 9cbcadf8c03948adef15f0c5644d33f635ee350e Mon Sep 17 00:00:00 2001 From: wangkailong Date: Wed, 22 May 2024 11:28:49 +0800 Subject: [PATCH 155/174] cfi Signed-off-by: wangkailong Change-Id: I5571fa6f8fddbc11a8a0e5d1858ff488b42163c8 --- service_router_framework/services/srms/BUILD.gn | 6 ++++++ services/abilitymgr/BUILD.gn | 6 ++++++ services/appmgr/BUILD.gn | 6 ++++++ services/quickfixmgr/BUILD.gn | 6 ++++++ services/uripermmgr/BUILD.gn | 6 ++++++ 5 files changed, 30 insertions(+) diff --git a/service_router_framework/services/srms/BUILD.gn b/service_router_framework/services/srms/BUILD.gn index 8f5df9fe77..fc4ed26a2e 100755 --- a/service_router_framework/services/srms/BUILD.gn +++ b/service_router_framework/services/srms/BUILD.gn @@ -27,6 +27,12 @@ config("srms_config") { } ohos_shared_library("libsrms") { + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + branch_protector_ret = "pac_ret" sources = [ "src/inner_service_info.cpp", "src/service_router_data_mgr.cpp", diff --git a/services/abilitymgr/BUILD.gn b/services/abilitymgr/BUILD.gn index 5bcd1adc96..33681ed8cc 100644 --- a/services/abilitymgr/BUILD.gn +++ b/services/abilitymgr/BUILD.gn @@ -106,6 +106,12 @@ config("abilityms_config") { } ohos_shared_library("abilityms") { + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + branch_protector_ret = "pac_ret" shlib_type = "sa" sources = abilityms_files cflags_cc = [] diff --git a/services/appmgr/BUILD.gn b/services/appmgr/BUILD.gn index f1c759f7aa..356af19f64 100644 --- a/services/appmgr/BUILD.gn +++ b/services/appmgr/BUILD.gn @@ -33,6 +33,12 @@ group("appms_target") { } ohos_shared_library("libappms") { + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + branch_protector_ret = "pac_ret" shlib_type = "sa" include_dirs = [ "${ability_runtime_services_path}/appdfr/include" ] sources = [ diff --git a/services/quickfixmgr/BUILD.gn b/services/quickfixmgr/BUILD.gn index a68906cb28..ddefd1fbec 100644 --- a/services/quickfixmgr/BUILD.gn +++ b/services/quickfixmgr/BUILD.gn @@ -37,6 +37,12 @@ quickfixms_sources = [ ] ohos_shared_library("quickfixms") { + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + branch_protector_ret = "pac_ret" include_dirs = [ "${ability_runtime_path}/interfaces/kits/native/appkit/ability_bundle_manager_helper" ] shlib_type = "sa" configs = [ "${ability_runtime_services_path}/common:common_config" ] diff --git a/services/uripermmgr/BUILD.gn b/services/uripermmgr/BUILD.gn index c027370762..0d9f3b6411 100644 --- a/services/uripermmgr/BUILD.gn +++ b/services/uripermmgr/BUILD.gn @@ -32,6 +32,12 @@ libupms_sources = [ #build so ohos_shared_library("libupms") { + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + branch_protector_ret = "pac_ret" shlib_type = "sa" configs = [ "${ability_runtime_innerkits_path}/app_manager:appmgr_sdk_config", From 4cee849ef41e4d8f5168d06ad792ba4c92c60ae7 Mon Sep 17 00:00:00 2001 From: Jasperjiao Date: Wed, 22 May 2024 14:17:33 +0800 Subject: [PATCH 156/174] =?UTF-8?q?=E5=BA=94=E7=94=A8=E5=90=AF=E5=8A=A8?= =?UTF-8?q?=E7=AE=A1=E6=8E=A7hisysevent=E5=BC=95=E5=85=A5yaml=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jasperjiao --- hisysevent.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hisysevent.yaml b/hisysevent.yaml index b86757f71b..2779d3226e 100644 --- a/hisysevent.yaml +++ b/hisysevent.yaml @@ -362,4 +362,5 @@ PREVENT_START_ABILITY: CALLEE_BUNDLE_NAME: {type: STRING, desc: callee bundle name} CALLEE_PROCESS_NAME: {type: STRING, desc: callee process name} EXTENSION_ABILITY_TYPE: {type: INT32, desc: extension ability type} - ABILITY_NAME: {type: STRING, desc: caller ability name} \ No newline at end of file + ABILITY_NAME: {type: STRING, desc: caller ability name} + \ No newline at end of file From 2a66d2ee2fb2415ff3df1978be16ccfc6bc2a93c Mon Sep 17 00:00:00 2001 From: wangzhen Date: Wed, 22 May 2024 08:44:18 +0800 Subject: [PATCH 157/174] Decrease memory usage Signed-off-by: wangzhen Change-Id: I321ed10f295f9ae99a411924c2fabced7b77b121 --- .../include/ability_manager_service.h | 7 +- .../abilitymgr/include/mission_list_manager.h | 10 +-- .../ui_ability_lifecycle_manager.h | 3 +- .../src/ability_manager_service.cpp | 1 + .../abilitymgr/src/mission_list_manager.cpp | 58 +++++++-------- .../ui_ability_lifecycle_manager.cpp | 72 ++++++++++--------- .../appmgr/include/app_mgr_service_inner.h | 11 ++- services/appmgr/include/app_running_manager.h | 3 + services/appmgr/include/app_running_record.h | 4 +- services/appmgr/src/app_mgr_service_inner.cpp | 2 + services/appmgr/src/app_running_manager.cpp | 1 + services/appmgr/src/app_running_record.cpp | 7 +- .../app_mgr_service_inner_test.cpp | 13 ++++ .../app_running_processes_info_test/BUILD.gn | 1 - 14 files changed, 107 insertions(+), 86 deletions(-) diff --git a/services/abilitymgr/include/ability_manager_service.h b/services/abilitymgr/include/ability_manager_service.h index 6a8a927ae3..9167d95ccb 100644 --- a/services/abilitymgr/include/ability_manager_service.h +++ b/services/abilitymgr/include/ability_manager_service.h @@ -67,13 +67,16 @@ #include "dialog_session_record.h" #include "implicit_start_processor.h" #include "system_dialog_scheduler.h" -#include "window_focus_changed_listener.h" #endif namespace OHOS { namespace AbilityRuntime { class IStatusBarDelegate; } +namespace Rosen { +class FocusChangeInfo; +} + namespace AAFwk { using AutoStartupInfo = AbilityRuntime::AutoStartupInfo; enum class ServiceRunningState { STATE_NOT_START, STATE_RUNNING }; @@ -83,6 +86,8 @@ constexpr int32_t INVALID_USER_ID = -1; using OHOS::AppExecFwk::IAbilityController; class PendingWantManager; struct StartAbilityInfo; +class WindowFocusChangedListener; + /** * @class AbilityManagerService * AbilityManagerService provides a facility for managing ability life cycle. diff --git a/services/abilitymgr/include/mission_list_manager.h b/services/abilitymgr/include/mission_list_manager.h index 29b550fd39..84c7e74097 100644 --- a/services/abilitymgr/include/mission_list_manager.h +++ b/services/abilitymgr/include/mission_list_manager.h @@ -23,7 +23,6 @@ #include "cpp/mutex.h" #include "ability_running_info.h" -#include "foundation/distributedhardware/device_manager/interfaces/inner_kits/native_cpp/include/device_manager.h" #include "mission_list.h" #include "mission_listener_controller.h" #include "mission_info.h" @@ -344,7 +343,7 @@ public: int32_t pid = NO_PID); void CallRequestDone(const std::shared_ptr &abilityRecord, const sptr &callStub); - + int SetMissionContinueState(const sptr &token, const int32_t missionId, const AAFwk::ContinueState &state); @@ -543,13 +542,6 @@ private: std::queue waitingAbilityQueue_; std::shared_ptr listenerController_; bool isPrepareTerminateEnable_ = false; - - class MissionDmInitCallback : public DistributedHardware::DmInitCallback { - public: - void OnRemoteDied() override; - - static bool isInit_; - }; }; } // namespace AAFwk } // namespace OHOS diff --git a/services/abilitymgr/include/scene_board/ui_ability_lifecycle_manager.h b/services/abilitymgr/include/scene_board/ui_ability_lifecycle_manager.h index 147b7d461d..ed23ec0992 100644 --- a/services/abilitymgr/include/scene_board/ui_ability_lifecycle_manager.h +++ b/services/abilitymgr/include/scene_board/ui_ability_lifecycle_manager.h @@ -26,7 +26,6 @@ #include "ability_manager_constants.h" #include "ability_record.h" #include "isession_handler_interface.h" -#include "session/host/include/zidl/session_interface.h" namespace OHOS { namespace AAFwk { @@ -407,7 +406,7 @@ private: std::unordered_map> sessionAbilityMap_; std::unordered_map> tmpAbilityMap_; std::list> terminateAbilityList_; - sptr rootSceneSession_; + sptr rootSceneSession_; std::map, key_compare> specifiedAbilityMap_; int32_t specifiedRequestId_ = 0; std::map specifiedRequestMap_; diff --git a/services/abilitymgr/src/ability_manager_service.cpp b/services/abilitymgr/src/ability_manager_service.cpp index f29994899a..054905a0c7 100644 --- a/services/abilitymgr/src/ability_manager_service.cpp +++ b/services/abilitymgr/src/ability_manager_service.cpp @@ -111,6 +111,7 @@ #include "application_anr_listener.h" #include "input_manager.h" #include "ability_first_frame_state_observer_manager.h" +#include "window_focus_changed_listener.h" #endif #ifdef EFFICIENCY_MANAGER_ENABLE diff --git a/services/abilitymgr/src/mission_list_manager.cpp b/services/abilitymgr/src/mission_list_manager.cpp index 0afa084ec8..cd49219da0 100644 --- a/services/abilitymgr/src/mission_list_manager.cpp +++ b/services/abilitymgr/src/mission_list_manager.cpp @@ -47,28 +47,28 @@ namespace { constexpr uint32_t DELAY_NOTIFY_LABEL_TIME = 30; // 30ms constexpr uint32_t SCENE_FLAG_KEYGUARD = 1; constexpr uint32_t ONLY_ONE_ABILITY = 1; -constexpr char EVENT_KEY_UID[] = "UID"; -constexpr char EVENT_KEY_PID[] = "PID"; -constexpr char EVENT_KEY_MESSAGE[] = "MSG"; -constexpr char EVENT_KEY_PACKAGE_NAME[] = "PACKAGE_NAME"; -constexpr char EVENT_KEY_PROCESS_NAME[] = "PROCESS_NAME"; +constexpr const char* EVENT_KEY_UID = "UID"; +constexpr const char* EVENT_KEY_PID = "PID"; +constexpr const char* EVENT_KEY_MESSAGE = "MSG"; +constexpr const char* EVENT_KEY_PACKAGE_NAME = "PACKAGE_NAME"; +constexpr const char* EVENT_KEY_PROCESS_NAME = "PROCESS_NAME"; constexpr int32_t SINGLE_MAX_INSTANCE_COUNT = 128; constexpr int32_t MAX_INSTANCE_COUNT = 512; constexpr uint64_t NANO_SECOND_PER_SEC = 1000000000; // ns const std::string DMS_SRC_NETWORK_ID = "dmsSrcNetworkId"; const std::string DMS_MISSION_ID = "dmsMissionId"; -const int DEFAULT_DMS_MISSION_ID = -1; +constexpr int DEFAULT_DMS_MISSION_ID = -1; #ifdef SUPPORT_ASAN -const int KILL_TIMEOUT_MULTIPLE = 45; +constexpr int KILL_TIMEOUT_MULTIPLE = 45; #else -const int KILL_TIMEOUT_MULTIPLE = 3; +constexpr int KILL_TIMEOUT_MULTIPLE = 3; #endif constexpr int32_t PREPARE_TERMINATE_ENABLE_SIZE = 6; -const char* PREPARE_TERMINATE_ENABLE_PARAMETER = "persist.sys.prepare_terminate"; -const int32_t PREPARE_TERMINATE_TIMEOUT_MULTIPLE = 10; +constexpr const char* PREPARE_TERMINATE_ENABLE_PARAMETER = "persist.sys.prepare_terminate"; +constexpr int32_t PREPARE_TERMINATE_TIMEOUT_MULTIPLE = 10; constexpr int32_t TRACE_ATOMIC_SERVICE_ID = 201; const std::string TRACE_ATOMIC_SERVICE = "StartAtomicService"; -const int GET_TARGET_MISSION_OVER = 200; +constexpr int GET_TARGET_MISSION_OVER = 200; std::string GetCurrentTime() { struct timespec tn; @@ -77,11 +77,18 @@ std::string GetCurrentTime() static_cast(tn.tv_nsec); return std::to_string(uTime); } -const std::unordered_map stateMap = { - { AbilityManagerService::LOAD_TIMEOUT_MSG, FreezeUtil::TimeoutState::LOAD }, - { AbilityManagerService::FOREGROUND_TIMEOUT_MSG, FreezeUtil::TimeoutState::FOREGROUND }, - { AbilityManagerService::BACKGROUND_TIMEOUT_MSG, FreezeUtil::TimeoutState::BACKGROUND } -}; + +FreezeUtil::TimeoutState MsgId2State(uint32_t msgId) +{ + if (msgId == AbilityManagerService::LOAD_TIMEOUT_MSG) { + return FreezeUtil::TimeoutState::LOAD; + } else if (msgId == AbilityManagerService::FOREGROUND_TIMEOUT_MSG) { + return FreezeUtil::TimeoutState::FOREGROUND; + } else if (msgId == AbilityManagerService::BACKGROUND_TIMEOUT_MSG) { + return FreezeUtil::TimeoutState::BACKGROUND; + } + return FreezeUtil::TimeoutState::UNKNOWN; +} auto g_deleteLifecycleEventTask = [](const sptr &token, FreezeUtil::TimeoutState state) { CHECK_POINTER_LOG(token, "token is nullptr."); @@ -425,7 +432,7 @@ int MissionListManager::StartAbilityLocked(const std::shared_ptr if (ret != GET_TARGET_MISSION_OVER) { return ret; } - + // 3. move mission to target list bool isCallerFromLauncher = (callerAbility && callerAbility->IsLauncherAbility()); MoveMissionToTargetList(isCallerFromLauncher, targetList, targetMission); @@ -855,7 +862,7 @@ std::shared_ptr MissionListManager::GetReusedStandardMission(const Abil if (!missionList) { continue; } - + auto mission = missionList->GetRecentStandardMission(missionName); if (mission && mission->GetMissionTime() >= missionTime) { missionTime = mission->GetMissionTime(); @@ -2093,11 +2100,7 @@ void MissionListManager::PrintTimeOutLog(const std::shared_ptr &a } int typeId = AppExecFwk::AppfreezeManager::TypeAttribute::NORMAL_TIMEOUT; std::string msgContent = "ability:" + ability->GetAbilityInfo().name + " "; - FreezeUtil::TimeoutState state = FreezeUtil::TimeoutState::UNKNOWN; - auto search = stateMap.find(msgId); - if (search != stateMap.end()) { - state = search->second; - } + FreezeUtil::TimeoutState state = MsgId2State(msgId); if (!GetContentAndTypeId(msgId, msgContent, typeId)) { TAG_LOGW(AAFwkTag::ABILITYMGR, "msgId is invalid!"); return; @@ -3335,7 +3338,7 @@ std::shared_ptr MissionListManager::GetAbilityRecordByNameFromCur return defaultStandardAbility; } } - + // find in launcherList_ if (launcherList_ != nullptr) { return launcherList_->GetAbilityRecordByName(element); @@ -3587,13 +3590,6 @@ bool MissionListManager::IsReachToSingleLimitLocked(const int32_t uid) const return false; } -bool MissionListManager::MissionDmInitCallback::isInit_ = false; -void MissionListManager::MissionDmInitCallback::OnRemoteDied() -{ - isInit_ = false; - TAG_LOGW(AAFwkTag::ABILITYMGR, "DeviceManager died."); -} - void MissionListManager::RegisterSnapshotHandler(const sptr& handler) { DelayedSingleton::GetInstance()->RegisterSnapshotHandler(handler); diff --git a/services/abilitymgr/src/scene_board/ui_ability_lifecycle_manager.cpp b/services/abilitymgr/src/scene_board/ui_ability_lifecycle_manager.cpp index 5eb280ebec..34595c8edd 100644 --- a/services/abilitymgr/src/scene_board/ui_ability_lifecycle_manager.cpp +++ b/services/abilitymgr/src/scene_board/ui_ability_lifecycle_manager.cpp @@ -34,6 +34,7 @@ #include "scene_board/status_bar_delegate_manager.h" #include "session_info.h" #include "session_manager_lite.h" +#include "session/host/include/zidl/session_interface.h" #include "startup_util.h" #ifdef SUPPORT_GRAPHICS #include "ability_first_frame_state_observer_manager.h" @@ -45,24 +46,31 @@ namespace AAFwk { namespace { constexpr const char* SEPARATOR = ":"; constexpr int32_t PREPARE_TERMINATE_TIMEOUT_MULTIPLE = 10; -const std::string PARAM_MISSION_AFFINITY_KEY = "ohos.anco.param.missionAffinity"; -const std::string DMS_SRC_NETWORK_ID = "dmsSrcNetworkId"; -const std::string DMS_MISSION_ID = "dmsMissionId"; -const int DEFAULT_DMS_MISSION_ID = -1; -const std::string PARAM_SPECIFIED_PROCESS_FLAG = "ohoSpecifiedProcessFlag"; -const std::string DMS_PROCESS_NAME = "distributedsched"; -const std::string DMS_PERSISTENT_ID = "ohos.dms.persistentId"; +constexpr const char* PARAM_MISSION_AFFINITY_KEY = "ohos.anco.param.missionAffinity"; +constexpr const char* DMS_SRC_NETWORK_ID = "dmsSrcNetworkId"; +constexpr const char* DMS_MISSION_ID = "dmsMissionId"; +constexpr int DEFAULT_DMS_MISSION_ID = -1; +constexpr const char* PARAM_SPECIFIED_PROCESS_FLAG = "ohoSpecifiedProcessFlag"; +constexpr const char* DMS_PROCESS_NAME = "distributedsched"; +constexpr const char* DMS_PERSISTENT_ID = "ohos.dms.persistentId"; #ifdef SUPPORT_ASAN -const int KILL_TIMEOUT_MULTIPLE = 45; +constexpr int KILL_TIMEOUT_MULTIPLE = 45; #else -const int KILL_TIMEOUT_MULTIPLE = 3; +constexpr int KILL_TIMEOUT_MULTIPLE = 3; #endif constexpr int32_t DEFAULT_USER_ID = 0; -const std::unordered_map stateMap = { - { AbilityManagerService::LOAD_TIMEOUT_MSG, FreezeUtil::TimeoutState::LOAD }, - { AbilityManagerService::FOREGROUND_TIMEOUT_MSG, FreezeUtil::TimeoutState::FOREGROUND }, - { AbilityManagerService::BACKGROUND_TIMEOUT_MSG, FreezeUtil::TimeoutState::BACKGROUND } -}; + +FreezeUtil::TimeoutState MsgId2State(uint32_t msgId) +{ + if (msgId == AbilityManagerService::LOAD_TIMEOUT_MSG) { + return FreezeUtil::TimeoutState::LOAD; + } else if (msgId == AbilityManagerService::FOREGROUND_TIMEOUT_MSG) { + return FreezeUtil::TimeoutState::FOREGROUND; + } else if (msgId == AbilityManagerService::BACKGROUND_TIMEOUT_MSG) { + return FreezeUtil::TimeoutState::BACKGROUND; + } + return FreezeUtil::TimeoutState::UNKNOWN; +} auto g_deleteLifecycleEventTask = [](const sptr &token, FreezeUtil::TimeoutState state) { CHECK_POINTER_LOG(token, "token is nullptr."); @@ -932,7 +940,8 @@ int UIAbilityLifecycleManager::NotifySCBPendingActivation(sptr &ses TAG_LOGI(AAFwkTag::ABILITYMGR, "Call PendingSessionActivation by callerSession."); return static_cast(callerSession->PendingSessionActivation(sessionInfo)); } - CHECK_POINTER_AND_RETURN(rootSceneSession_, ERR_INVALID_VALUE); + auto tmpSceneSession = iface_cast(rootSceneSession_); + CHECK_POINTER_AND_RETURN(tmpSceneSession, ERR_INVALID_VALUE); if (sessionInfo->persistentId == 0) { const auto &abilityInfo = abilityRequest.abilityInfo; auto isStandard = abilityInfo.launchMode == AppExecFwk::LaunchMode::STANDARD && !abilityRequest.startRecent; @@ -943,7 +952,7 @@ int UIAbilityLifecycleManager::NotifySCBPendingActivation(sptr &ses } } TAG_LOGI(AAFwkTag::ABILITYMGR, "Call PendingSessionActivation by rootSceneSession."); - return static_cast(rootSceneSession_->PendingSessionActivation(sessionInfo)); + return static_cast(tmpSceneSession->PendingSessionActivation(sessionInfo)); } int UIAbilityLifecycleManager::ResolveAbility( @@ -1014,11 +1023,7 @@ void UIAbilityLifecycleManager::PrintTimeOutLog(std::shared_ptr a .eventName = eventName, .bundleName = ability->GetAbilityInfo().bundleName, }; - FreezeUtil::TimeoutState state = FreezeUtil::TimeoutState::UNKNOWN; - auto search = stateMap.find(msgId); - if (search != stateMap.end()) { - state = search->second; - } + FreezeUtil::TimeoutState state = MsgId2State(msgId); if (state != FreezeUtil::TimeoutState::UNKNOWN) { auto flow = std::make_unique(); if (ability->GetToken() != nullptr) { @@ -1353,17 +1358,12 @@ void UIAbilityLifecycleManager::OnTimeOut(uint32_t msgId, int64_t abilityRecordI void UIAbilityLifecycleManager::SetRootSceneSession(const sptr &rootSceneSession) { TAG_LOGD(AAFwkTag::ABILITYMGR, "call"); - if (rootSceneSession == nullptr) { + auto tmpSceneSession = iface_cast(rootSceneSession); + if (tmpSceneSession == nullptr) { TAG_LOGE(AAFwkTag::ABILITYMGR, "rootSceneSession is invalid."); return; } - auto tmpSceneSession = iface_cast(rootSceneSession); - auto descriptor = Str16ToStr8(tmpSceneSession->GetDescriptor()); - if (descriptor != "OHOS.ISession") { - TAG_LOGE(AAFwkTag::ABILITYMGR, "token's Descriptor: %{public}s", descriptor.c_str()); - return; - } - rootSceneSession_ = tmpSceneSession; + rootSceneSession_ = rootSceneSession; } void UIAbilityLifecycleManager::NotifySCBToHandleException(const std::shared_ptr &abilityRecord, @@ -1629,6 +1629,7 @@ int UIAbilityLifecycleManager::SendSessionInfoToSCB(std::shared_ptr &sessionInfo) { TAG_LOGD(AAFwkTag::ABILITYMGR, "call"); + auto tmpSceneSession = iface_cast(rootSceneSession_); if (callerAbility != nullptr) { auto callerSessionInfo = callerAbility->GetSessionInfo(); if (callerSessionInfo != nullptr && callerSessionInfo->sessionToken != nullptr) { @@ -1638,12 +1639,12 @@ int UIAbilityLifecycleManager::SendSessionInfoToSCB(std::shared_ptrhasContinuousTask = hasContinuousTask; callerSession->PendingSessionActivation(sessionInfo); } else { - CHECK_POINTER_AND_RETURN(rootSceneSession_, ERR_INVALID_VALUE); - rootSceneSession_->PendingSessionActivation(sessionInfo); + CHECK_POINTER_AND_RETURN(tmpSceneSession, ERR_INVALID_VALUE); + tmpSceneSession->PendingSessionActivation(sessionInfo); } } else { - CHECK_POINTER_AND_RETURN(rootSceneSession_, ERR_INVALID_VALUE); - rootSceneSession_->PendingSessionActivation(sessionInfo); + CHECK_POINTER_AND_RETURN(tmpSceneSession, ERR_INVALID_VALUE); + tmpSceneSession->PendingSessionActivation(sessionInfo); } return ERR_OK; } @@ -2142,7 +2143,8 @@ void UIAbilityLifecycleManager::DumpMissionListByRecordId(std::vector startOptions) { HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); - CHECK_POINTER_AND_RETURN(rootSceneSession_, ERR_INVALID_VALUE); + auto tmpSceneSession = iface_cast(rootSceneSession_); + CHECK_POINTER_AND_RETURN(tmpSceneSession, ERR_INVALID_VALUE); std::shared_ptr abilityRecord = GetAbilityRecordsById(sessionId); CHECK_POINTER_AND_RETURN(abilityRecord, ERR_INVALID_VALUE); if (startOptions != nullptr) { @@ -2151,7 +2153,7 @@ int UIAbilityLifecycleManager::MoveMissionToFront(int32_t sessionId, std::shared sptr sessionInfo = abilityRecord->GetSessionInfo(); CHECK_POINTER_AND_RETURN(sessionInfo, ERR_INVALID_VALUE); TAG_LOGI(AAFwkTag::ABILITYMGR, "Call PendingSessionActivation by rootSceneSession."); - return static_cast(rootSceneSession_->PendingSessionActivation(sessionInfo)); + return static_cast(tmpSceneSession->PendingSessionActivation(sessionInfo)); } std::shared_ptr UIAbilityLifecycleManager::GetStatusBarDelegateManager() diff --git a/services/appmgr/include/app_mgr_service_inner.h b/services/appmgr/include/app_mgr_service_inner.h index 4e72f8c69a..660e17911f 100644 --- a/services/appmgr/include/app_mgr_service_inner.h +++ b/services/appmgr/include/app_mgr_service_inner.h @@ -65,14 +65,19 @@ #include "shared/base_shared_bundle_info.h" #include "task_handler_wrap.h" #include "want.h" -#include "window_focus_changed_listener.h" -#include "window_visibility_changed_listener.h" #include "app_jsheap_mem_info.h" #include "running_multi_info.h" namespace OHOS { +namespace Rosen { +class WindowVisibilityInfo; +class FocusChangeInfo; +} namespace AppExecFwk { using OHOS::AAFwk::Want; +class WindowFocusChangedListener; +class WindowVisibilityChangedListener; + class AppMgrServiceInner : public std::enable_shared_from_this { public: AppMgrServiceInner(); @@ -1382,7 +1387,7 @@ private: */ void NotifyAppRunningStatusEvent( const std::string &bundle, int32_t uid, AbilityRuntime::RunningStatus runningStatus); - + void GetRunningCloneAppInfo(const std::shared_ptr &appRecord, RunningMultiAppInfo &info); diff --git a/services/appmgr/include/app_running_manager.h b/services/appmgr/include/app_running_manager.h index 8b144e285f..a5f895ac69 100644 --- a/services/appmgr/include/app_running_manager.h +++ b/services/appmgr/include/app_running_manager.h @@ -35,6 +35,9 @@ #include "app_jsheap_mem_info.h" namespace OHOS { +namespace Rosen { +class WindowVisibilityInfo; +} namespace AppExecFwk { class AppRunningManager { public: diff --git a/services/appmgr/include/app_running_record.h b/services/appmgr/include/app_running_record.h index 4ac8c3f1bd..417044ff06 100644 --- a/services/appmgr/include/app_running_record.h +++ b/services/appmgr/include/app_running_record.h @@ -43,10 +43,12 @@ #include "module_running_record.h" #include "app_spawn_client.h" #include "app_malloc_info.h" -#include "window_visibility_changed_listener.h" #include "app_jsheap_mem_info.h" namespace OHOS { +namespace Rosen { +class WindowVisibilityInfo; +} namespace AppExecFwk { class AbilityRunningRecord; class AppMgrServiceInner; diff --git a/services/appmgr/src/app_mgr_service_inner.cpp b/services/appmgr/src/app_mgr_service_inner.cpp index 7b57e090b6..67659770f2 100644 --- a/services/appmgr/src/app_mgr_service_inner.cpp +++ b/services/appmgr/src/app_mgr_service_inner.cpp @@ -81,6 +81,8 @@ #include "app_mgr_service_const.h" #include "app_mgr_service_dump_error_code.h" #include "cache_process_manager.h" +#include "window_focus_changed_listener.h" +#include "window_visibility_changed_listener.h" namespace OHOS { namespace AppExecFwk { diff --git a/services/appmgr/src/app_running_manager.cpp b/services/appmgr/src/app_running_manager.cpp index 008ee29c3e..8159c851d9 100644 --- a/services/appmgr/src/app_running_manager.cpp +++ b/services/appmgr/src/app_running_manager.cpp @@ -36,6 +36,7 @@ #include "suspend_manager_client.h" #endif #include "app_mgr_service_dump_error_code.h" +#include "window_visibility_info.h" namespace OHOS { namespace AppExecFwk { diff --git a/services/appmgr/src/app_running_record.cpp b/services/appmgr/src/app_running_record.cpp index a43a7cf28c..ba46292a3c 100644 --- a/services/appmgr/src/app_running_record.cpp +++ b/services/appmgr/src/app_running_record.cpp @@ -24,15 +24,16 @@ #include "app_mgr_service_const.h" #include "app_mgr_service_dump_error_code.h" #include "cache_process_manager.h" +#include "window_visibility_info.h" namespace OHOS { namespace AppExecFwk { namespace { -static constexpr int64_t NANOSECONDS = 1000000000; // NANOSECONDS mean 10^9 nano second -static constexpr int64_t MICROSECONDS = 1000000; // MICROSECONDS mean 10^6 millias second +constexpr int64_t NANOSECONDS = 1000000000; // NANOSECONDS mean 10^9 nano second +constexpr int64_t MICROSECONDS = 1000000; // MICROSECONDS mean 10^6 millias second constexpr int32_t MAX_RESTART_COUNT = 3; constexpr int32_t RESTART_INTERVAL_TIME = 120000; -const std::string LAUNCHER_NAME = "com.ohos.sceneboard"; +constexpr const char* LAUNCHER_NAME = "com.ohos.sceneboard"; } int64_t AppRunningRecord::appEventId_ = 0; diff --git a/test/unittest/app_mgr_service_inner_test/app_mgr_service_inner_test.cpp b/test/unittest/app_mgr_service_inner_test/app_mgr_service_inner_test.cpp index 903dde82bf..7286dd1673 100644 --- a/test/unittest/app_mgr_service_inner_test/app_mgr_service_inner_test.cpp +++ b/test/unittest/app_mgr_service_inner_test/app_mgr_service_inner_test.cpp @@ -44,6 +44,19 @@ using namespace testing::ext; namespace OHOS { namespace AppExecFwk { +class WindowFocusChangedListener : public OHOS::Rosen::IFocusChangedListener { +public: + WindowFocusChangedListener(const std::shared_ptr& owner, + const std::shared_ptr& handler); + virtual ~WindowFocusChangedListener(); + + void OnFocused(const sptr &focusChangeInfo) override; + void OnUnfocused(const sptr &focusChangeInfo) override; + +private: + std::weak_ptr owner_; + std::shared_ptr taskHandler_; +}; namespace { constexpr int32_t RECORD_ID = 1; constexpr int32_t APP_DEBUG_INFO_PID = 0; diff --git a/test/unittest/app_running_processes_info_test/BUILD.gn b/test/unittest/app_running_processes_info_test/BUILD.gn index 0d49d16a71..c3dc6f6e77 100644 --- a/test/unittest/app_running_processes_info_test/BUILD.gn +++ b/test/unittest/app_running_processes_info_test/BUILD.gn @@ -31,7 +31,6 @@ ohos_unittest("AppRunningProcessesInfoTest") { "${ability_runtime_services_path}/appmgr/src/advanced_security_mode_manager.cpp", "${ability_runtime_services_path}/appmgr/src/app_config_data_manager.cpp", "${ability_runtime_services_path}/appmgr/src/app_debug_manager.cpp", - "${ability_runtime_services_path}/appmgr/src/app_mgr_service_inner.cpp", "${ability_runtime_services_path}/appmgr/src/app_preloader.cpp", "${ability_runtime_services_path}/appmgr/src/app_running_record.cpp", "${ability_runtime_services_path}/appmgr/src/app_running_status_module.cpp", From 102ce95884b15028887ae5a1a431c0fab21ce14e Mon Sep 17 00:00:00 2001 From: zhubingwei Date: Wed, 22 May 2024 15:52:53 +0800 Subject: [PATCH 158/174] =?UTF-8?q?TDD=E8=A6=86=E7=9B=96=E7=8E=87=E6=8F=90?= =?UTF-8?q?=E5=8D=87=E3=80=90ability=5Fability=5Fruntime=20=20quickfixmgr?= =?UTF-8?q?=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhubingwei --- .../quick_fix_manager_service_test.cpp | 103 ++++++++++++++++++ 1 file changed, 103 insertions(+) diff --git a/test/unittest/quick_fix/quick_fix_manager_service_test/quick_fix_manager_service_test.cpp b/test/unittest/quick_fix/quick_fix_manager_service_test/quick_fix_manager_service_test.cpp index 3517f944f9..f5dcb5304f 100644 --- a/test/unittest/quick_fix/quick_fix_manager_service_test/quick_fix_manager_service_test.cpp +++ b/test/unittest/quick_fix/quick_fix_manager_service_test/quick_fix_manager_service_test.cpp @@ -245,5 +245,108 @@ HWTEST_F(QuickFixManagerServiceTest, GetQuickFixInfo_0100, TestSize.Level1) TAG_LOGI(AAFwkTag::TEST, "GetQuickFixInfo_0100 end."); } + +/** + * @tc.name: GetApplyedQuickFixInfo_0200 + * @tc.desc: get Apply Quick Fix info. + * @tc.type: FUNC + * @tc.require: issueI5ODCD + */ +HWTEST_F(QuickFixManagerServiceTest, GetApplyedQuickFixInfo_0200, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + auto mockGetBundleInstaller = []() { return mockBundleInstaller; }; + auto mockGetSystemAbility = [bms = mockBundleMgr, saMgr = iSystemAbilityMgr_](int32_t systemAbilityId) { + if (systemAbilityId == BUNDLE_MGR_SERVICE_SYS_ABILITY_ID) { + return bms->AsObject(); + } else { + return saMgr->GetSystemAbility(systemAbilityId); + } + }; + EXPECT_CALL(*mockBundleMgr, GetBundleInstaller()).WillOnce(testing::Invoke(mockGetBundleInstaller)); + std::string bundleName = ""; + ApplicationQuickFixInfo quickFixInfo; + auto ret = quickFixMs_->GetApplyedQuickFixInfo(bundleName, quickFixInfo); + EXPECT_EQ(ret, QUICK_FIX_OK); + EXPECT_EQ(quickFixInfo.bundleName, ""); + EXPECT_EQ(quickFixInfo.bundleVersionCode, static_cast(0)); + EXPECT_EQ(quickFixInfo.bundleVersionName, ""); + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} + +/** + * @tc.name: ApplyAndRemoveTask_0200 + * @tc.desc: AddApplyTask and RemoveApplyTask + * @tc.type: FUNC + * @tc.require: issueI5OD2E + */ +HWTEST_F(QuickFixManagerServiceTest, ApplyAndRemoveTask_0200, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + EXPECT_NE(quickFixMs_, nullptr); + quickFixMs_->RemoveApplyTask(nullptr); + quickFixMs_->AddApplyTask(nullptr); + sptr bundleQfMgr = nullptr; + sptr appMgr = nullptr; + std::shared_ptr handler = nullptr; + wptr service = nullptr; + auto applyTask = std::make_shared(bundleQfMgr, appMgr, handler, service); + EXPECT_NE(applyTask, nullptr); + quickFixMs_->RemoveApplyTask(applyTask); + quickFixMs_->AddApplyTask(applyTask); + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} + +/** + * @tc.name: CheckTaskRunningState_0100 + * @tc.desc: check task running state + * @tc.type: FUNC + * @tc.require: issueI5OD2E + */ +HWTEST_F(QuickFixManagerServiceTest, CheckTaskRunningState_0100, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + EXPECT_NE(quickFixMs_, nullptr); + std::string bundleName = "testbundlename"; + bool result = quickFixMs_->CheckTaskRunningState(bundleName); + EXPECT_EQ(result, false); + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} + +/** + * @tc.name: CheckTaskRunningState_0200 + * @tc.desc: check task running state + * @tc.type: FUNC + * @tc.require: issueI5OD2E + */ +HWTEST_F(QuickFixManagerServiceTest, CheckTaskRunningState_0200, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + EXPECT_NE(quickFixMs_, nullptr); + auto applyTask = std::make_shared(nullptr, nullptr, nullptr, nullptr); + quickFixMs_->AddApplyTask(applyTask); + std::string bundleName = "testbundlename"; + bool result = quickFixMs_->CheckTaskRunningState(bundleName); + EXPECT_EQ(result, false); + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} + +/** + * @tc.name: CheckTaskRunningState_0300 + * @tc.desc: check task running state + * @tc.type: FUNC + * @tc.require: issueI5OD2E + */ +HWTEST_F(QuickFixManagerServiceTest, CheckTaskRunningState_0300, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + EXPECT_NE(quickFixMs_, nullptr); + auto applyTask = std::make_shared(nullptr, nullptr, nullptr, nullptr); + quickFixMs_->AddApplyTask(applyTask); + std::string bundleName = ""; + bool result = quickFixMs_->CheckTaskRunningState(bundleName); + EXPECT_EQ(result, true); + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} } // namespace AppExecFwk } // namespace OHOS \ No newline at end of file From 3e8493556b2dbf79306b4c1e564462b4eec79d4f Mon Sep 17 00:00:00 2001 From: jsjzju Date: Sun, 19 May 2024 13:17:02 +0800 Subject: [PATCH 159/174] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=BB=91=E5=AE=9A?= =?UTF-8?q?=E5=88=B0=E7=8A=B6=E6=80=81=E6=A0=8F=E5=9B=BE=E6=A0=87=E4=BD=86?= =?UTF-8?q?=E4=B8=8D=E4=B8=8D=E5=88=9B=E5=BB=BA=E6=96=B0=E8=BF=9B=E7=A8=8B?= =?UTF-8?q?=E7=9A=84=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: jsjzju Change-Id: If57a1fd3a4b8f191c18a6be7878ac719dcc311f4 --- .../native/ability/native/ui_ability_impl.cpp | 2 +- .../ability_manager/include/process_options.h | 3 + .../ui_ability_lifecycle_manager.h | 2 +- .../src/ability_manager_service.cpp | 8 +-- services/abilitymgr/src/process_options.cpp | 11 ++++ .../status_bar_delegate_manager.cpp | 57 ++++++++----------- .../ui_ability_lifecycle_manager.cpp | 8 ++- 7 files changed, 49 insertions(+), 42 deletions(-) diff --git a/frameworks/native/ability/native/ui_ability_impl.cpp b/frameworks/native/ability/native/ui_ability_impl.cpp index 7cec9fefc2..43a83fc531 100644 --- a/frameworks/native/ability/native/ui_ability_impl.cpp +++ b/frameworks/native/ability/native/ui_ability_impl.cpp @@ -368,7 +368,7 @@ void UIAbilityImpl::UpdateSilentForeground(const AAFwk::LifeCycleStateInfo &targ } if (lifecycleState_ == AAFwk::ABILITY_STATE_INITIAL && sessionInfo && sessionInfo->processOptions && - AAFwk::ProcessOptions::IsNewProcessMode(sessionInfo->processOptions->processMode) && + AAFwk::ProcessOptions::IsValidProcessMode(sessionInfo->processOptions->processMode) && sessionInfo->processOptions->startupVisibility == AAFwk::StartupVisibility::STARTUP_HIDE) { TAG_LOGI(AAFwkTag::UIABILITY, "Set IsSilentForeground to true."); ability_->SetIsSilentForeground(true); diff --git a/interfaces/inner_api/ability_manager/include/process_options.h b/interfaces/inner_api/ability_manager/include/process_options.h index afce4b4500..17a26e7c9f 100644 --- a/interfaces/inner_api/ability_manager/include/process_options.h +++ b/interfaces/inner_api/ability_manager/include/process_options.h @@ -24,6 +24,7 @@ enum class ProcessMode { UNSPECIFIED = 0, NEW_PROCESS_ATTACH_TO_PARENT = 1, NEW_PROCESS_ATTACH_TO_STATUS_BAR_ITEM = 2, + ATTACH_TO_STATUS_BAR_ITEM = 3, END }; @@ -46,6 +47,8 @@ public: static ProcessMode ConvertInt32ToProcessMode(int32_t value); static StartupVisibility ConvertInt32ToStartupVisibility(int32_t value); static bool IsNewProcessMode(ProcessMode value); + static bool IsAttachToStatusBarMode(ProcessMode value); + static bool IsValidProcessMode(ProcessMode value); ProcessMode processMode = ProcessMode::UNSPECIFIED; StartupVisibility startupVisibility = StartupVisibility::UNSPECIFIED; diff --git a/services/abilitymgr/include/scene_board/ui_ability_lifecycle_manager.h b/services/abilitymgr/include/scene_board/ui_ability_lifecycle_manager.h index 147b7d461d..dc347f0aed 100644 --- a/services/abilitymgr/include/scene_board/ui_ability_lifecycle_manager.h +++ b/services/abilitymgr/include/scene_board/ui_ability_lifecycle_manager.h @@ -399,7 +399,7 @@ private: bool CheckPid(const std::shared_ptr abilityRecord, const int32_t pid) const; std::shared_ptr GetStatusBarDelegateManager(); int32_t DoProcessAttachment(std::shared_ptr abilityRecord); - void BatchCloseUIAbility(std::unordered_set>& abilitySet); + void BatchCloseUIAbility(const std::unordered_set>& abilitySet); int StartWithPersistentIdByDistributed(const AbilityRequest &abilityRequest, int32_t persistentId); int32_t userId_ = -1; diff --git a/services/abilitymgr/src/ability_manager_service.cpp b/services/abilitymgr/src/ability_manager_service.cpp index 762548dd5d..d86dd00864 100644 --- a/services/abilitymgr/src/ability_manager_service.cpp +++ b/services/abilitymgr/src/ability_manager_service.cpp @@ -9468,11 +9468,11 @@ int32_t AbilityManagerService::CheckProcessOptions(const Want &want, const Start { HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); if (startOptions.processOptions == nullptr || - !ProcessOptions::IsNewProcessMode(startOptions.processOptions->processMode)) { + !ProcessOptions::IsValidProcessMode(startOptions.processOptions->processMode)) { return ERR_OK; } - TAG_LOGD(AAFwkTag::ABILITYMGR, "start ability in new process mode."); + TAG_LOGD(AAFwkTag::ABILITYMGR, "start ability with process options."); bool isEnable = AppUtils::GetInstance().IsStartOptionsWithProcessOptions(); if (!Rosen::SceneBoardJudgement::IsSceneBoardEnabled() || !isEnable) { TAG_LOGE(AAFwkTag::ABILITYMGR, "Not support process options."); @@ -9493,9 +9493,9 @@ int32_t AbilityManagerService::CheckProcessOptions(const Want &want, const Start auto uiAbilityManager = GetUIAbilityManagerByUid(IPCSkeleton::GetCallingUid()); CHECK_POINTER_AND_RETURN(uiAbilityManager, ERR_INVALID_VALUE); - if (startOptions.processOptions->processMode == ProcessMode::NEW_PROCESS_ATTACH_TO_STATUS_BAR_ITEM && + if (ProcessOptions::IsAttachToStatusBarMode(startOptions.processOptions->processMode) && !uiAbilityManager->IsCallerInStatusBar()) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "Caller is not in status bar in NEW_PROCESS_ATTACH_TO_STATUS_BAR_ITEM mode."); + TAG_LOGE(AAFwkTag::ABILITYMGR, "Caller is not in status bar in attch to status bar mode."); return ERR_START_OPTIONS_CHECK_FAILED; } diff --git a/services/abilitymgr/src/process_options.cpp b/services/abilitymgr/src/process_options.cpp index 0ab1370667..47163efec5 100644 --- a/services/abilitymgr/src/process_options.cpp +++ b/services/abilitymgr/src/process_options.cpp @@ -83,5 +83,16 @@ bool ProcessOptions::IsNewProcessMode(ProcessMode value) return (value == ProcessMode::NEW_PROCESS_ATTACH_TO_PARENT) || (value == ProcessMode::NEW_PROCESS_ATTACH_TO_STATUS_BAR_ITEM); } + +bool ProcessOptions::IsAttachToStatusBarMode(ProcessMode value) +{ + return (value == ProcessMode::NEW_PROCESS_ATTACH_TO_STATUS_BAR_ITEM) || + (value == ProcessMode::ATTACH_TO_STATUS_BAR_ITEM); +} + +bool ProcessOptions::IsValidProcessMode(ProcessMode value) +{ + return (value > ProcessMode::UNSPECIFIED) && (value < ProcessMode::END); +} } // namespace AAFwk } // namespace OHOS diff --git a/services/abilitymgr/src/scene_board/status_bar_delegate_manager.cpp b/services/abilitymgr/src/scene_board/status_bar_delegate_manager.cpp index 825cdb09f2..fe3c37058e 100644 --- a/services/abilitymgr/src/scene_board/status_bar_delegate_manager.cpp +++ b/services/abilitymgr/src/scene_board/status_bar_delegate_manager.cpp @@ -58,41 +58,32 @@ int32_t StatusBarDelegateManager::DoProcessAttachment(std::shared_ptr int32_t { - auto sessionInfo = abilityRecord->GetSessionInfo(); - CHECK_POINTER_AND_RETURN(sessionInfo, ERR_INVALID_VALUE); - auto processOptions = sessionInfo->processOptions; - if (processOptions == nullptr) { - TAG_LOGD(AAFwkTag::ABILITYMGR, "no need to attach process."); - return ERR_OK; - } - if (processOptions->processMode == ProcessMode::NEW_PROCESS_ATTACH_TO_PARENT) { - auto callerRecord = abilityRecord->GetCallerRecord(); - CHECK_POINTER_AND_RETURN(callerRecord, ERR_INVALID_VALUE); - TAG_LOGI(AAFwkTag::ABILITYMGR, "attach pid to parent."); - IN_PROCESS_CALL_WITHOUT_RET(DelayedSingleton::GetInstance()->AttachPidToParent( - abilityRecord->GetToken(), callerRecord->GetToken())); - } - if (processOptions->processMode == ProcessMode::NEW_PROCESS_ATTACH_TO_STATUS_BAR_ITEM) { - auto statusBarDelegate = GetStatusBarDelegate(); - CHECK_POINTER_AND_RETURN(statusBarDelegate, ERR_INVALID_VALUE); - auto accessTokenId = abilityRecord->GetApplicationInfo().accessTokenId; - auto ret = statusBarDelegate->AttachPidToStatusBarItem(accessTokenId, abilityRecord->GetPid()); - if (ret != ERR_OK) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "AttachPidToStatusBarItem failed, ret: %{public}d", ret); - return ret; - } - TAG_LOGI(AAFwkTag::ABILITYMGR, "AttachPidToStatusBarItem success."); - } + auto sessionInfo = abilityRecord->GetSessionInfo(); + CHECK_POINTER_AND_RETURN(sessionInfo, ERR_INVALID_VALUE); + auto processOptions = sessionInfo->processOptions; + if (processOptions == nullptr) { + TAG_LOGD(AAFwkTag::ABILITYMGR, "no need to attach process."); return ERR_OK; - }; - auto ret = func(); - if (ret != ERR_OK) { - std::vector pids; - pids.push_back(abilityRecord->GetPid()); - IN_PROCESS_CALL_WITHOUT_RET(DelayedSingleton::GetInstance()->KillProcessesByPids(pids)); } - return ret; + if (processOptions->processMode == ProcessMode::NEW_PROCESS_ATTACH_TO_PARENT) { + auto callerRecord = abilityRecord->GetCallerRecord(); + CHECK_POINTER_AND_RETURN(callerRecord, ERR_INVALID_VALUE); + TAG_LOGI(AAFwkTag::ABILITYMGR, "attach pid to parent."); + IN_PROCESS_CALL_WITHOUT_RET(DelayedSingleton::GetInstance()->AttachPidToParent( + abilityRecord->GetToken(), callerRecord->GetToken())); + } + if (ProcessOptions::IsAttachToStatusBarMode(processOptions->processMode)) { + auto statusBarDelegate = GetStatusBarDelegate(); + CHECK_POINTER_AND_RETURN(statusBarDelegate, ERR_INVALID_VALUE); + auto accessTokenId = abilityRecord->GetApplicationInfo().accessTokenId; + auto ret = statusBarDelegate->AttachPidToStatusBarItem(accessTokenId, abilityRecord->GetPid()); + if (ret != ERR_OK) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "AttachPidToStatusBarItem failed, ret: %{public}d", ret); + return ret; + } + TAG_LOGI(AAFwkTag::ABILITYMGR, "AttachPidToStatusBarItem success."); + } + return ERR_OK; } } // namespace AAFwk } // namespace OHOS \ No newline at end of file diff --git a/services/abilitymgr/src/scene_board/ui_ability_lifecycle_manager.cpp b/services/abilitymgr/src/scene_board/ui_ability_lifecycle_manager.cpp index 5eb280ebec..cc83863de1 100644 --- a/services/abilitymgr/src/scene_board/ui_ability_lifecycle_manager.cpp +++ b/services/abilitymgr/src/scene_board/ui_ability_lifecycle_manager.cpp @@ -249,7 +249,8 @@ int UIAbilityLifecycleManager::AttachAbilityThread(const sptr abilityRecord->SetScheduler(scheduler); if (DoProcessAttachment(abilityRecord) != ERR_OK) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "do process attachment failed."); + TAG_LOGE(AAFwkTag::ABILITYMGR, "do process attachment failed, close the ability."); + BatchCloseUIAbility({abilityRecord}); return ERR_INVALID_VALUE; } if (abilityRecord->IsStartedByCall()) { @@ -2218,7 +2219,8 @@ int32_t UIAbilityLifecycleManager::KillProcessWithPrepareTerminate(const std::ve return ERR_OK; } -void UIAbilityLifecycleManager::BatchCloseUIAbility(std::unordered_set>& abilitySet) +void UIAbilityLifecycleManager::BatchCloseUIAbility( + const std::unordered_set>& abilitySet) { auto closeTask = [ self = shared_from_this(), abilitySet]() { TAG_LOGI(AAFwkTag::ABILITYMGR, "The abilities need to be closed."); @@ -2251,7 +2253,7 @@ int UIAbilityLifecycleManager::ChangeAbilityVisibility(sptr token auto sessionInfo = abilityRecord->GetSessionInfo(); CHECK_POINTER_AND_RETURN(sessionInfo, ERR_INVALID_VALUE); if (sessionInfo->processOptions == nullptr || - sessionInfo->processOptions->processMode != ProcessMode::NEW_PROCESS_ATTACH_TO_STATUS_BAR_ITEM) { + !ProcessOptions::IsAttachToStatusBarMode(sessionInfo->processOptions->processMode)) { TAG_LOGE(AAFwkTag::ABILITYMGR, "Process options check failed."); return ERR_START_OPTIONS_CHECK_FAILED; } From 54944392de8cb2f43557380f1d2bc35e53fd2796 Mon Sep 17 00:00:00 2001 From: huangshiwei Date: Wed, 22 May 2024 14:21:20 +0800 Subject: [PATCH 160/174] huangshiwei4@huawei.com Signed-off-by: huangshiwei --- test/moduletest/ability_record_test/BUILD.gn | 2 +- test/moduletest/ipc_ability_connect_test/BUILD.gn | 2 +- test/moduletest/ipc_ability_scheduler_test/BUILD.gn | 2 +- test/unittest/dfr_test/watchdog_test/BUILD.gn | 6 ++---- test/unittest/frameworks_kits_appkit_native_test/BUILD.gn | 1 - test/unittest/mission_list_test/BUILD.gn | 2 +- 6 files changed, 6 insertions(+), 9 deletions(-) diff --git a/test/moduletest/ability_record_test/BUILD.gn b/test/moduletest/ability_record_test/BUILD.gn index cfe8f2b280..14c5438b20 100644 --- a/test/moduletest/ability_record_test/BUILD.gn +++ b/test/moduletest/ability_record_test/BUILD.gn @@ -70,7 +70,7 @@ ohos_moduletest("AbilityRecordModuleTest") { "access_token:libaccesstoken_sdk", "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", - "c_utils:utilsbase", + "c_utils:utils", "common_event_service:cesfwk_core", "common_event_service:cesfwk_innerkits", "dsoftbus:softbus_client", diff --git a/test/moduletest/ipc_ability_connect_test/BUILD.gn b/test/moduletest/ipc_ability_connect_test/BUILD.gn index f182a1da8b..425974df60 100644 --- a/test/moduletest/ipc_ability_connect_test/BUILD.gn +++ b/test/moduletest/ipc_ability_connect_test/BUILD.gn @@ -37,7 +37,7 @@ ohos_moduletest("IpcAbilityConnectModuleTest") { external_deps = [ "ability_base:want", "ability_runtime:ability_manager", - "c_utils:utilsbase", + "c_utils:utils", "hilog:libhilog", "ipc:ipc_core", ] diff --git a/test/moduletest/ipc_ability_scheduler_test/BUILD.gn b/test/moduletest/ipc_ability_scheduler_test/BUILD.gn index eeb688fee9..9501865ffd 100644 --- a/test/moduletest/ipc_ability_scheduler_test/BUILD.gn +++ b/test/moduletest/ipc_ability_scheduler_test/BUILD.gn @@ -50,7 +50,7 @@ ohos_moduletest("IpcAbilitySchedulerModuleTest") { "ability_base:zuri", "ability_runtime:ability_manager", "bundle_framework:appexecfwk_core", - "c_utils:utilsbase", + "c_utils:utils", "hilog:libhilog", "ipc:ipc_core", "napi:ace_napi", diff --git a/test/unittest/dfr_test/watchdog_test/BUILD.gn b/test/unittest/dfr_test/watchdog_test/BUILD.gn index 203cefce2b..1825d44c40 100644 --- a/test/unittest/dfr_test/watchdog_test/BUILD.gn +++ b/test/unittest/dfr_test/watchdog_test/BUILD.gn @@ -9,7 +9,7 @@ # 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. +# limitations under the License. import("//build/ohos.gni") import("//build/test.gni") @@ -76,8 +76,6 @@ ohos_unittest("watchdog_test") { "ability_base:want", "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", - "c_utils:utils", - "c_utils:utilsbase", "eventhandler:libeventhandler", "hilog:libhilog", "image_framework:image_native", @@ -86,7 +84,7 @@ ohos_unittest("watchdog_test") { ] } -############################################################################### +############################################################################### group("unittest") { testonly = true diff --git a/test/unittest/frameworks_kits_appkit_native_test/BUILD.gn b/test/unittest/frameworks_kits_appkit_native_test/BUILD.gn index 2998465d45..35536506c4 100644 --- a/test/unittest/frameworks_kits_appkit_native_test/BUILD.gn +++ b/test/unittest/frameworks_kits_appkit_native_test/BUILD.gn @@ -343,7 +343,6 @@ ohos_unittest("ability_start_setting_test") { external_deps = [ "c_utils:utils", - "c_utils:utilsbase", "hilog:libhilog", "ipc:ipc_core", ] diff --git a/test/unittest/mission_list_test/BUILD.gn b/test/unittest/mission_list_test/BUILD.gn index a6ee9a5483..937d6618f3 100644 --- a/test/unittest/mission_list_test/BUILD.gn +++ b/test/unittest/mission_list_test/BUILD.gn @@ -94,7 +94,7 @@ ohos_unittest("mission_list_test_call") { "ability_base:want", "ability_base:zuri", "bundle_framework:appexecfwk_base", - "c_utils:utilsbase", + "c_utils:utils", "common_event_service:cesfwk_innerkits", "ffrt:libffrt", "hilog:libhilog", From 31f026e66186d8b7d18d7c3e6b1c9505c463d6f1 Mon Sep 17 00:00:00 2001 From: zhubingwei Date: Wed, 22 May 2024 17:05:54 +0800 Subject: [PATCH 161/174] =?UTF-8?q?TDD=E8=A6=86=E7=9B=96=E7=8E=87=E6=8F=90?= =?UTF-8?q?=E5=8D=87=E3=80=90ability=5Fnative=20recovery=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhubingwei --- .../app_recovery_test/app_recovery_test.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/unittest/app_recovery_test/app_recovery_test.cpp b/test/unittest/app_recovery_test/app_recovery_test.cpp index 54bb600cd9..fd7c63b68b 100644 --- a/test/unittest/app_recovery_test/app_recovery_test.cpp +++ b/test/unittest/app_recovery_test/app_recovery_test.cpp @@ -30,6 +30,8 @@ #include "mock_ability_token.h" #include "recovery_param.h" #include "ui_ability.h" +#define private public +#include "context/application_context.h" using namespace testing::ext; namespace OHOS { @@ -683,5 +685,18 @@ HWTEST_F(AppRecoveryUnitTest, GetMissionIds_002, TestSize.Level1) std::string invalid_path = "data/apps/ohos.samples.recovery/files/"; EXPECT_FALSE(AppRecovery::GetInstance().GetMissionIds(invalid_path, missionIds)); } + +/** + * @tc.name: DeleteInValidMissionFiles_001 + * @tc.desc: Test delete invalid mission files. + * @tc.type: FUNC + * @tc.require: I5Z7LE + */ +HWTEST_F(AppRecoveryUnitTest, DeleteInValidMissionFiles_001, TestSize.Level1) +{ + AbilityRuntime::ApplicationContext::GetInstance()->contextImpl_ = std::make_shared(); + AppRecovery::GetInstance().DeleteInValidMissionFiles(); + EXPECT_NE(AbilityRuntime::Context::GetApplicationContext(), nullptr); +} } // namespace AppExecFwk } // namespace OHOS From e38a6730d99fecf84ed8d7ebf147d8ab0b9dbe71 Mon Sep 17 00:00:00 2001 From: zhubingwei Date: Wed, 22 May 2024 17:26:39 +0800 Subject: [PATCH 162/174] =?UTF-8?q?=E5=A2=9E=E5=8A=A0AmsMgrSchedulerTest?= =?UTF-8?q?=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhubingwei Change-Id: I798a96c5f8a9e1136ce70afec8c0bff9255fe611 --- test/unittest/ams_mgr_scheduler_test/BUILD.gn | 3 + .../ams_mgr_scheduler_test.cpp | 522 ++++++++++++++++++ .../mock/include/mock_my_flag.h | 31 ++ .../include/mock_permission_verification.h | 98 ++++ .../mock/src/mock_my_flag.cpp | 22 + .../mock/src/mock_permission_verification.cpp | 126 +++++ 6 files changed, 802 insertions(+) create mode 100644 test/unittest/ams_mgr_scheduler_test/mock/include/mock_my_flag.h create mode 100644 test/unittest/ams_mgr_scheduler_test/mock/include/mock_permission_verification.h create mode 100644 test/unittest/ams_mgr_scheduler_test/mock/src/mock_my_flag.cpp create mode 100644 test/unittest/ams_mgr_scheduler_test/mock/src/mock_permission_verification.cpp diff --git a/test/unittest/ams_mgr_scheduler_test/BUILD.gn b/test/unittest/ams_mgr_scheduler_test/BUILD.gn index b3a2bdf713..76bbae7f4b 100644 --- a/test/unittest/ams_mgr_scheduler_test/BUILD.gn +++ b/test/unittest/ams_mgr_scheduler_test/BUILD.gn @@ -24,12 +24,15 @@ ohos_unittest("ams_mgr_scheduler_test") { "${ability_runtime_services_path}/appmgr/include", "${ability_runtime_test_path}/mock/mock_sa_call", "${distributedschedule_path}/samgr/interfaces/innerkits/samgr_proxy/include", + "mock/include", ] sources = [ "${ability_runtime_services_path}/appmgr/src/ams_mgr_scheduler.cpp", "${ability_runtime_test_path}/mock/services_appmgr_test/src/mock_bundle_manager.cpp", "${ability_runtime_test_path}/mock/services_appmgr_test/src/mock_overlay_manager.cpp", + "mock/src/mock_my_flag.cpp", + "mock/src/mock_permission_verification.cpp", ] sources += [ "ams_mgr_scheduler_test.cpp" ] diff --git a/test/unittest/ams_mgr_scheduler_test/ams_mgr_scheduler_test.cpp b/test/unittest/ams_mgr_scheduler_test/ams_mgr_scheduler_test.cpp index 21734bc222..1d14889fce 100644 --- a/test/unittest/ams_mgr_scheduler_test/ams_mgr_scheduler_test.cpp +++ b/test/unittest/ams_mgr_scheduler_test/ams_mgr_scheduler_test.cpp @@ -25,6 +25,7 @@ #include "mock_ability_token.h" #include "mock_app_mgr_service_inner.h" #include "mock_bundle_manager.h" +#include "mock_my_flag.h" #include "mock_sa_call.h" #include "application_state_observer_stub.h" @@ -617,6 +618,45 @@ HWTEST_F(AmsMgrSchedulerTest, KillProcessesByUserId_001, TestSize.Level0) amsMgrScheduler->KillProcessesByUserId(userId); } +/* + * Feature: AmsMgrScheduler + * Function: KillProcessesByUserId + * SubFunction: NA + * FunctionPoints: AmsMgrScheduler KillProcessesByUserId + * EnvConditions: NA + * CaseDescription: The caller is not system-app, can not use system-api + */ +HWTEST_F(AmsMgrSchedulerTest, KillProcessesByUserId_002, TestSize.Level0) +{ + auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + amsMgrScheduler->amsMgrServiceInner_ = GetMockAppMgrServiceInner(); + amsMgrScheduler->amsHandler_ = GetAmsTaskHandler(); + ASSERT_NE(amsMgrScheduler, nullptr); + int32_t userId = 0; + AAFwk::MyFlag::flag_ = 0; + amsMgrScheduler->KillProcessesByUserId(userId); + AAFwk::MyFlag::flag_ = 1; +} + +/* + * Feature: AmsMgrScheduler + * Function: KillProcessesByUserId + * SubFunction: NA + * FunctionPoints: AmsMgrScheduler KillProcessesByUserId + * EnvConditions: NA + * CaseDescription: SubmitTask + */ +HWTEST_F(AmsMgrSchedulerTest, KillProcessesByUserId_003, TestSize.Level0) +{ + auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + amsMgrScheduler->amsMgrServiceInner_ = GetMockAppMgrServiceInner(); + amsMgrScheduler->amsHandler_ = GetAmsTaskHandler(); + ASSERT_NE(amsMgrScheduler, nullptr); + int32_t userId = 0; + AAFwk::MyFlag::flag_ = 1; + amsMgrScheduler->KillProcessesByUserId(userId); +} + /* * Feature: AmsMgrScheduler * Function: KillProcessWithAccount @@ -883,6 +923,21 @@ HWTEST_F(AmsMgrSchedulerTest, NotifyAppMgrRecordExitReason_001, TestSize.Level0) EXPECT_NE(res2, ERR_INVALID_OPERATION); } +/** + * @tc.name: SetCurrentUserId_002 + * @tc.desc: set current userId. + * @tc.type: FUNC + */ +HWTEST_F(AmsMgrSchedulerTest, SetCurrentUserId_002, TestSize.Level0) +{ + auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + amsMgrScheduler->amsMgrServiceInner_ = GetMockAppMgrServiceInner(); + amsMgrScheduler->amsHandler_ = GetAmsTaskHandler(); + ASSERT_NE(amsMgrScheduler, nullptr); + int userId = 1; + amsMgrScheduler->SetCurrentUserId(userId); +} + /** * @tc.name: SetCurrentUserId_001 * @tc.desc: set current userId. @@ -991,5 +1046,472 @@ HWTEST_F(AmsMgrSchedulerTest, RegisterAbilityDebugResponse_001, TestSize.Level0) res = amsMgrScheduler->RegisterAbilityDebugResponse(response); EXPECT_NE(res, ERR_INVALID_OPERATION); } + +/* + * Feature: AmsMgrScheduler + * Function: KillProcessesByPids + * SubFunction: NA + * FunctionPoints: AmsMgrScheduler KillProcessesByPids + * EnvConditions: NA + * CaseDescription: not initial scheduler + */ +HWTEST_F(AmsMgrSchedulerTest, KillProcessesByPids_001, TestSize.Level0) +{ + auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + ASSERT_NE(amsMgrScheduler, nullptr); + int32_t userId = 0; + std::vector pids = {1}; + amsMgrScheduler->KillProcessesByPids(pids); +} + +/* + * Feature: AmsMgrScheduler + * Function: KillProcessesByPids + * SubFunction: NA + * FunctionPoints: AmsMgrScheduler KillProcessesByPids + * EnvConditions: NA + * CaseDescription: SubmitTask + */ +HWTEST_F(AmsMgrSchedulerTest, KillProcessesByPids_002, TestSize.Level0) +{ + auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + amsMgrScheduler->amsMgrServiceInner_ = GetMockAppMgrServiceInner(); + amsMgrScheduler->amsHandler_ = GetAmsTaskHandler(); + ASSERT_NE(amsMgrScheduler, nullptr); + int32_t userId = 0; + std::vector pids = {1}; + amsMgrScheduler->KillProcessesByPids(pids); +} + +/* + * Feature: AmsMgrScheduler + * Function: AttachPidToParent + * SubFunction: NA + * FunctionPoints: AmsMgrScheduler AttachPidToParent + * EnvConditions: NA + * CaseDescription: not initial scheduler + */ +HWTEST_F(AmsMgrSchedulerTest, AttachPidToParent_001, TestSize.Level0) +{ + auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + ASSERT_NE(amsMgrScheduler, nullptr); + const sptr token; + const sptr callerToken; + amsMgrScheduler->AttachPidToParent(token, callerToken); +} + +/* + * Feature: AmsMgrScheduler + * Function: AttachPidToParent + * SubFunction: NA + * FunctionPoints: AmsMgrScheduler AttachPidToParent + * EnvConditions: NA + * CaseDescription: SubmitTask + */ +HWTEST_F(AmsMgrSchedulerTest, AttachPidToParent_002, TestSize.Level0) +{ + auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + amsMgrScheduler->amsMgrServiceInner_ = GetMockAppMgrServiceInner(); + amsMgrScheduler->amsHandler_ = GetAmsTaskHandler(); + ASSERT_NE(amsMgrScheduler, nullptr); + const sptr token; + const sptr callerToken; + amsMgrScheduler->AttachPidToParent(token, callerToken); +} + +/* + * Feature: AmsMgrScheduler + * Function: UpdateApplicationInfoInstalled + * SubFunction: NA + * FunctionPoints: AmsMgrScheduler UpdateApplicationInfoInstalled + * EnvConditions: NA + * CaseDescription: not initial scheduler + */ +HWTEST_F(AmsMgrSchedulerTest, UpdateApplicationInfoInstalled_001, TestSize.Level0) +{ + auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + ASSERT_NE(amsMgrScheduler, nullptr); + const std::string bundleName = ""; + const int uid = 0; + auto iret = amsMgrScheduler->UpdateApplicationInfoInstalled(bundleName, uid); + ASSERT_EQ(iret, 38); +} + +/* + * Feature: AmsMgrScheduler + * Function: UpdateApplicationInfoInstalled + * SubFunction: NA + * FunctionPoints: AmsMgrScheduler UpdateApplicationInfoInstalled + * EnvConditions: NA + * CaseDescription: UpdateApplicationInfoInstalled + */ +HWTEST_F(AmsMgrSchedulerTest, UpdateApplicationInfoInstalled_002, TestSize.Level0) +{ + auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + amsMgrScheduler->amsMgrServiceInner_ = GetMockAppMgrServiceInner(); + amsMgrScheduler->amsHandler_ = GetAmsTaskHandler(); + ASSERT_NE(amsMgrScheduler, nullptr); + const std::string bundleName = ""; + const int uid = 0; + auto iret = amsMgrScheduler->UpdateApplicationInfoInstalled(bundleName, uid); + ASSERT_EQ(iret, 0); +} + +/* + * Feature: AmsMgrScheduler + * Function: SetAbilityForegroundingFlagToAppRecord + * SubFunction: NA + * FunctionPoints: AmsMgrScheduler SetAbilityForegroundingFlagToAppRecord + * EnvConditions: NA + * CaseDescription: not initial scheduler + */ +HWTEST_F(AmsMgrSchedulerTest, SetAbilityForegroundingFlagToAppRecord_001, TestSize.Level0) +{ + auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + ASSERT_NE(amsMgrScheduler, nullptr); + const pid_t pid = 1; + amsMgrScheduler->SetAbilityForegroundingFlagToAppRecord(pid); +} + +/* + * Feature: AmsMgrScheduler + * Function: SetAbilityForegroundingFlagToAppRecord + * SubFunction: NA + * FunctionPoints: AmsMgrScheduler SetAbilityForegroundingFlagToAppRecord + * EnvConditions: NA + * CaseDescription: SetAbilityForegroundingFlagToAppRecord + */ +HWTEST_F(AmsMgrSchedulerTest, SetAbilityForegroundingFlagToAppRecord_002, TestSize.Level0) +{ + auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + amsMgrScheduler->amsMgrServiceInner_ = GetMockAppMgrServiceInner(); + amsMgrScheduler->amsHandler_ = GetAmsTaskHandler(); + ASSERT_NE(amsMgrScheduler, nullptr); + const pid_t pid = 1; + amsMgrScheduler->SetAbilityForegroundingFlagToAppRecord(pid); +} + +/* + * Feature: AmsMgrScheduler + * Function: StartSpecifiedProcess + * SubFunction: NA + * FunctionPoints: AmsMgrScheduler StartSpecifiedProcess + * EnvConditions: NA + * CaseDescription: not initial scheduler + */ +HWTEST_F(AmsMgrSchedulerTest, StartSpecifiedProcess_001, TestSize.Level0) +{ + auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + ASSERT_NE(amsMgrScheduler, nullptr); + const AAFwk::Want want; + const AppExecFwk::AbilityInfo abilityInfo; + int32_t requestId = 1; + amsMgrScheduler->StartSpecifiedProcess(want, abilityInfo, requestId); +} + +/* + * Feature: AmsMgrScheduler + * Function: StartSpecifiedProcess + * SubFunction: NA + * FunctionPoints: AmsMgrScheduler StartSpecifiedProcess + * EnvConditions: NA + * CaseDescription: StartSpecifiedProcess + */ +HWTEST_F(AmsMgrSchedulerTest, StartSpecifiedProcess_002, TestSize.Level0) +{ + auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + amsMgrScheduler->amsMgrServiceInner_ = GetMockAppMgrServiceInner(); + amsMgrScheduler->amsHandler_ = GetAmsTaskHandler(); + ASSERT_NE(amsMgrScheduler, nullptr); + const AAFwk::Want want; + const AppExecFwk::AbilityInfo abilityInfo; + int32_t requestId = 1; + amsMgrScheduler->StartSpecifiedProcess(want, abilityInfo, requestId); +} + +/* + * Feature: AmsMgrScheduler + * Function: GetBundleNameByPid + * SubFunction: NA + * FunctionPoints: AmsMgrScheduler GetBundleNameByPid + * EnvConditions: NA + * CaseDescription: not initial scheduler + */ +HWTEST_F(AmsMgrSchedulerTest, GetBundleNameByPid_001, TestSize.Level0) +{ + auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + ASSERT_NE(amsMgrScheduler, nullptr); + const int pid = 1; + std::string bundleName; + int32_t uid = 1; + auto iret = amsMgrScheduler->GetBundleNameByPid(pid, bundleName, uid); + ASSERT_EQ(iret, 38); +} + +/* + * Feature: AmsMgrScheduler + * Function: GetBundleNameByPid + * SubFunction: NA + * FunctionPoints: AmsMgrScheduler GetBundleNameByPid + * EnvConditions: NA + * CaseDescription: GetBundleNameByPid + */ +HWTEST_F(AmsMgrSchedulerTest, GetBundleNameByPid_002, TestSize.Level0) +{ + auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + amsMgrScheduler->amsMgrServiceInner_ = GetMockAppMgrServiceInner(); + amsMgrScheduler->amsHandler_ = GetAmsTaskHandler(); + ASSERT_NE(amsMgrScheduler, nullptr); + const int pid = 1; + std::string bundleName; + int32_t uid = 1; + auto iret = amsMgrScheduler->GetBundleNameByPid(pid, bundleName, uid); + ASSERT_EQ(iret, 38); +} + +/* + * Feature: AmsMgrScheduler + * Function: SetAppWaitingDebug + * SubFunction: NA + * FunctionPoints: AmsMgrScheduler SetAppWaitingDebug + * EnvConditions: NA + * CaseDescription: not initial scheduler + */ +HWTEST_F(AmsMgrSchedulerTest, SetAppWaitingDebug_001, TestSize.Level0) +{ + auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + ASSERT_NE(amsMgrScheduler, nullptr); + const std::string bundleName; + bool isPersist = true; + auto iret = amsMgrScheduler->SetAppWaitingDebug(bundleName, isPersist); + ASSERT_EQ(iret, 38); +} + +/* + * Feature: AmsMgrScheduler + * Function: SetAppWaitingDebug + * SubFunction: NA + * FunctionPoints: AmsMgrScheduler SetAppWaitingDebug + * EnvConditions: NA + * CaseDescription: SetAppWaitingDebug + */ +HWTEST_F(AmsMgrSchedulerTest, SetAppWaitingDebug_002, TestSize.Level0) +{ + auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + amsMgrScheduler->amsMgrServiceInner_ = GetMockAppMgrServiceInner(); + amsMgrScheduler->amsHandler_ = GetAmsTaskHandler(); + ASSERT_NE(amsMgrScheduler, nullptr); + const std::string bundleName; + bool isPersist = true; + auto iret = amsMgrScheduler->SetAppWaitingDebug(bundleName, isPersist); + ASSERT_EQ(iret, 22); +} + +/* + * Feature: AmsMgrScheduler + * Function: CancelAppWaitingDebug + * SubFunction: NA + * FunctionPoints: AmsMgrScheduler CancelAppWaitingDebug + * EnvConditions: NA + * CaseDescription: not initial scheduler + */ +HWTEST_F(AmsMgrSchedulerTest, CancelAppWaitingDebug_001, TestSize.Level0) +{ + auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + ASSERT_NE(amsMgrScheduler, nullptr); + amsMgrScheduler->CancelAppWaitingDebug(); +} + +/* + * Feature: AmsMgrScheduler + * Function: CancelAppWaitingDebug + * SubFunction: NA + * FunctionPoints: AmsMgrScheduler CancelAppWaitingDebug + * EnvConditions: NA + * CaseDescription: CancelAppWaitingDebug + */ +HWTEST_F(AmsMgrSchedulerTest, CancelAppWaitingDebug_002, TestSize.Level0) +{ + auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + amsMgrScheduler->amsMgrServiceInner_ = GetMockAppMgrServiceInner(); + amsMgrScheduler->amsHandler_ = GetAmsTaskHandler(); + ASSERT_NE(amsMgrScheduler, nullptr); + amsMgrScheduler->CancelAppWaitingDebug(); +} + +/* + * Feature: AmsMgrScheduler + * Function: GetWaitingDebugApp + * SubFunction: NA + * FunctionPoints: AmsMgrScheduler GetWaitingDebugApp + * EnvConditions: NA + * CaseDescription: not initial scheduler + */ +HWTEST_F(AmsMgrSchedulerTest, GetWaitingDebugApp_001, TestSize.Level0) +{ + auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + ASSERT_NE(amsMgrScheduler, nullptr); + std::vector debugInfoList; + auto iret = amsMgrScheduler->GetWaitingDebugApp(debugInfoList); + ASSERT_EQ(iret, 38); +} + +/* + * Feature: AmsMgrScheduler + * Function: GetWaitingDebugApp + * SubFunction: NA + * FunctionPoints: AmsMgrScheduler GetWaitingDebugApp + * EnvConditions: NA + * CaseDescription: not initial scheduler + */ +HWTEST_F(AmsMgrSchedulerTest, GetWaitingDebugApp_002, TestSize.Level0) +{ + auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + amsMgrScheduler->amsMgrServiceInner_ = GetMockAppMgrServiceInner(); + amsMgrScheduler->amsHandler_ = GetAmsTaskHandler(); + ASSERT_NE(amsMgrScheduler, nullptr); + std::vector debugInfoList; + auto iret = amsMgrScheduler->GetWaitingDebugApp(debugInfoList); + ASSERT_EQ(iret, 0); +} + +/* + * Feature: AmsMgrScheduler + * Function: IsWaitingDebugApp + * SubFunction: NA + * FunctionPoints: AmsMgrScheduler IsWaitingDebugApp + * EnvConditions: NA + * CaseDescription: not initial scheduler + */ +HWTEST_F(AmsMgrSchedulerTest, IsWaitingDebugApp_001, TestSize.Level0) +{ + auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + ASSERT_NE(amsMgrScheduler, nullptr); + const std::string bundleName; + auto iret = amsMgrScheduler->IsWaitingDebugApp(bundleName); + ASSERT_EQ(iret, false); +} + +/* + * Feature: AmsMgrScheduler + * Function: IsWaitingDebugApp + * SubFunction: NA + * FunctionPoints: AmsMgrScheduler IsWaitingDebugApp + * EnvConditions: NA + * CaseDescription: IsWaitingDebugApp + */ +HWTEST_F(AmsMgrSchedulerTest, IsWaitingDebugApp_002, TestSize.Level0) +{ + auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + amsMgrScheduler->amsMgrServiceInner_ = GetMockAppMgrServiceInner(); + amsMgrScheduler->amsHandler_ = GetAmsTaskHandler(); + ASSERT_NE(amsMgrScheduler, nullptr); + const std::string bundleName; + auto iret = amsMgrScheduler->IsWaitingDebugApp(bundleName); + ASSERT_EQ(iret, false); +} + +/* + * Feature: AmsMgrScheduler + * Function: ClearNonPersistWaitingDebugFlag + * SubFunction: NA + * FunctionPoints: AmsMgrScheduler ClearNonPersistWaitingDebugFlag + * EnvConditions: NA + * CaseDescription: not initial scheduler + */ +HWTEST_F(AmsMgrSchedulerTest, ClearNonPersistWaitingDebugFlag_001, TestSize.Level0) +{ + auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + ASSERT_NE(amsMgrScheduler, nullptr); + amsMgrScheduler->ClearNonPersistWaitingDebugFlag(); +} + +/* + * Feature: AmsMgrScheduler + * Function: ClearNonPersistWaitingDebugFlag + * SubFunction: NA + * FunctionPoints: AmsMgrScheduler ClearNonPersistWaitingDebugFlag + * EnvConditions: NA + * CaseDescription: ClearNonPersistWaitingDebugFlag + */ +HWTEST_F(AmsMgrSchedulerTest, ClearNonPersistWaitingDebugFlag_002, TestSize.Level0) +{ + auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + amsMgrScheduler->amsMgrServiceInner_ = GetMockAppMgrServiceInner(); + amsMgrScheduler->amsHandler_ = GetAmsTaskHandler(); + ASSERT_NE(amsMgrScheduler, nullptr); + amsMgrScheduler->ClearNonPersistWaitingDebugFlag(); +} + +/* + * Feature: AmsMgrScheduler + * Function: IsAttachDebug + * SubFunction: NA + * FunctionPoints: AmsMgrScheduler IsAttachDebug + * EnvConditions: NA + * CaseDescription: not initial scheduler + */ +HWTEST_F(AmsMgrSchedulerTest, IsAttachDebug_001, TestSize.Level0) +{ + auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + ASSERT_NE(amsMgrScheduler, nullptr); + const std::string bundleName; + auto iret = amsMgrScheduler->IsAttachDebug(bundleName); + ASSERT_EQ(iret, false); +} + +/* + * Feature: AmsMgrScheduler + * Function: IsAttachDebug + * SubFunction: NA + * FunctionPoints: AmsMgrScheduler IsAttachDebug + * EnvConditions: NA + * CaseDescription: IsAttachDebug + */ +HWTEST_F(AmsMgrSchedulerTest, IsAttachDebug_002, TestSize.Level0) +{ + auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + amsMgrScheduler->amsMgrServiceInner_ = GetMockAppMgrServiceInner(); + amsMgrScheduler->amsHandler_ = GetAmsTaskHandler(); + ASSERT_NE(amsMgrScheduler, nullptr); + const std::string bundleName; + auto iret = amsMgrScheduler->IsAttachDebug(bundleName); + ASSERT_EQ(iret, false); +} + +/* + * Feature: AmsMgrScheduler + * Function: ClearProcessByToken + * SubFunction: NA + * FunctionPoints: AmsMgrScheduler ClearProcessByToken + * EnvConditions: NA + * CaseDescription: not initial scheduler + */ +HWTEST_F(AmsMgrSchedulerTest, ClearProcessByToken_001, TestSize.Level0) +{ + auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + ASSERT_NE(amsMgrScheduler, nullptr); + sptr token; + amsMgrScheduler->ClearProcessByToken(token); +} + +/* + * Feature: AmsMgrScheduler + * Function: ClearProcessByToken + * SubFunction: NA + * FunctionPoints: AmsMgrScheduler ClearProcessByToken + * EnvConditions: NA + * CaseDescription: caller is not foundation + */ +HWTEST_F(AmsMgrSchedulerTest, ClearProcessByToken_002, TestSize.Level0) +{ + auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + amsMgrScheduler->amsMgrServiceInner_ = GetMockAppMgrServiceInner(); + amsMgrScheduler->amsHandler_ = GetAmsTaskHandler(); + ASSERT_NE(amsMgrScheduler, nullptr); + sptr token; + amsMgrScheduler->ClearProcessByToken(token); +} + } // namespace AppExecFwk } // namespace OHOS diff --git a/test/unittest/ams_mgr_scheduler_test/mock/include/mock_my_flag.h b/test/unittest/ams_mgr_scheduler_test/mock/include/mock_my_flag.h new file mode 100644 index 0000000000..2ee3eafe7f --- /dev/null +++ b/test/unittest/ams_mgr_scheduler_test/mock/include/mock_my_flag.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef MOCK_MY_FLAG_H +#define MOCK_MY_FLAG_H +namespace OHOS { +namespace AAFwk { +class MyFlag { +public: + enum FLAG { + IS_SA_CALL = 1, + IS_SHELL_CALL, + IS_SA_AND_SHELL_CALL, + }; + static int flag_; +}; +} // namespace AAFwk +} // namespace OHOS +#endif // MOCK_MY_FLAG_H \ No newline at end of file diff --git a/test/unittest/ams_mgr_scheduler_test/mock/include/mock_permission_verification.h b/test/unittest/ams_mgr_scheduler_test/mock/include/mock_permission_verification.h new file mode 100644 index 0000000000..fe2bcb25d5 --- /dev/null +++ b/test/unittest/ams_mgr_scheduler_test/mock/include/mock_permission_verification.h @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ABILITY_RUNTIME_PERMISSION_VERIFICATION_H +#define OHOS_ABILITY_RUNTIME_PERMISSION_VERIFICATION_H + +#include + +#include "ipc_skeleton.h" +#include "singleton.h" +#include "want.h" +#include "mock_my_flag.h" + +namespace OHOS { +namespace AAFwk { + +class PermissionVerification : public DelayedSingleton { +public: +struct VerificationInfo { + bool visible = false; + bool isBackgroundCall = true; + bool associatedWakeUp = false; + uint32_t accessTokenId = 0; + int32_t apiTargetVersion = 0; +}; + + PermissionVerification() = default; + ~PermissionVerification() = default; + + bool VerifyCallingPermission(const std::string &permissionName) const; + + bool IsSACall() const; + + bool IsShellCall() const; + + bool CheckSpecificSystemAbilityAccessPermission() const; + + bool VerifyRunningInfoPerm() const; + + bool VerifyControllerPerm() const; + + bool VerifyDlpPermission(Want &want) const; + + int VerifyAccountPermission() const; + + bool VerifyMissionPermission() const; + + int VerifyAppStateObserverPermission() const; + + int32_t VerifyUpdateConfigurationPerm() const; + + bool VerifyInstallBundlePermission() const; + + bool VerifyGetBundleInfoPrivilegedPermission() const; + + int CheckCallDataAbilityPermission(const VerificationInfo &verificationInfo, bool isShell) const; + + int CheckCallServiceAbilityPermission(const VerificationInfo &verificationInfo) const; + + int CheckCallAbilityPermission(const VerificationInfo &verificationInfo) const; + + int CheckCallServiceExtensionPermission(const VerificationInfo &verificationInfo) const; + + int CheckStartByCallPermission(const VerificationInfo &verificationInfo) const; + + unsigned int GetCallingTokenID() const; + + bool JudgeStartInvisibleAbility(const uint32_t accessTokenId, const bool visible) const; + + bool JudgeStartAbilityFromBackground(const bool isBackgroundCall) const; + + bool JudgeAssociatedWakeUp(const uint32_t accessTokenId, const bool associatedWakeUp) const; + + int JudgeInvisibleAndBackground(const VerificationInfo &verificationInfo) const; + + inline bool IsCallFromSameAccessToken(const uint32_t accessTokenId) const + { + return IPCSkeleton::GetCallingTokenID() == accessTokenId; + } + + bool JudgeCallerIsAllowedToUseSystemAPI() const; + bool IsSystemAppCall() const; +}; +} // namespace AAFwk +} // namespace OHOS +#endif // OHOS_ABILITY_RUNTIME_PERMISSION_VERIFICATION_H \ No newline at end of file diff --git a/test/unittest/ams_mgr_scheduler_test/mock/src/mock_my_flag.cpp b/test/unittest/ams_mgr_scheduler_test/mock/src/mock_my_flag.cpp new file mode 100644 index 0000000000..d94439252b --- /dev/null +++ b/test/unittest/ams_mgr_scheduler_test/mock/src/mock_my_flag.cpp @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "mock_my_flag.h" + +namespace OHOS { +namespace AAFwk { +int MyFlag::flag_ = 1; +} // namespace AAFwk +} // namespace OHOS \ No newline at end of file diff --git a/test/unittest/ams_mgr_scheduler_test/mock/src/mock_permission_verification.cpp b/test/unittest/ams_mgr_scheduler_test/mock/src/mock_permission_verification.cpp new file mode 100644 index 0000000000..83622f9101 --- /dev/null +++ b/test/unittest/ams_mgr_scheduler_test/mock/src/mock_permission_verification.cpp @@ -0,0 +1,126 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "hilog_tag_wrapper.h" +#include "hilog_wrapper.h" +#include "mock_permission_verification.h" + +namespace OHOS { +namespace AAFwk { + +bool PermissionVerification::VerifyCallingPermission(const std::string &permissionName) const +{ + return !!(MyFlag::flag_); +} +bool PermissionVerification::IsSACall() const +{ + return (MyFlag::flag_ & MyFlag::FLAG::IS_SA_CALL); +} +bool PermissionVerification::IsShellCall() const +{ + return (MyFlag::flag_ & MyFlag::FLAG::IS_SHELL_CALL); +} +bool PermissionVerification::CheckSpecificSystemAbilityAccessPermission() const +{ + TAG_LOGD(AAFwkTag::TEST, "mock CheckSpecificSystemAbilityAccessPermission flag_: %{public}d.", MyFlag::flag_); + return !!(MyFlag::flag_); +} +bool PermissionVerification::VerifyRunningInfoPerm() const +{ + return !!(MyFlag::flag_); +} +bool PermissionVerification::VerifyControllerPerm() const +{ + return !!(MyFlag::flag_); +} +bool PermissionVerification::VerifyDlpPermission(Want &want) const +{ + return !!(MyFlag::flag_); +} +int PermissionVerification::VerifyAccountPermission() const +{ + return MyFlag::flag_; +} +bool PermissionVerification::VerifyMissionPermission() const +{ + return !!(MyFlag::flag_); +} +int PermissionVerification::VerifyAppStateObserverPermission() const +{ + return MyFlag::flag_; +} +int32_t PermissionVerification::VerifyUpdateConfigurationPerm() const +{ + return static_cast(MyFlag::flag_); +} +bool PermissionVerification::VerifyInstallBundlePermission() const +{ + return !!(MyFlag::flag_); +} +bool PermissionVerification::VerifyGetBundleInfoPrivilegedPermission() const +{ + return !!(MyFlag::flag_); +} +int PermissionVerification::CheckCallDataAbilityPermission(const VerificationInfo &verificationInfo, bool isShell) const +{ + return MyFlag::flag_; +} +int PermissionVerification::CheckCallServiceAbilityPermission(const VerificationInfo &verificationInfo) const +{ + return MyFlag::flag_; +} +int PermissionVerification::CheckCallAbilityPermission(const VerificationInfo &verificationInfo) const +{ + return MyFlag::flag_; +} +int PermissionVerification::CheckCallServiceExtensionPermission(const VerificationInfo &verificationInfo) const +{ + return MyFlag::flag_; +} +int PermissionVerification::CheckStartByCallPermission(const VerificationInfo &verificationInfo) const +{ + return MyFlag::flag_; +} +unsigned int PermissionVerification::GetCallingTokenID() const +{ + return static_cast(MyFlag::flag_); +} +bool PermissionVerification::JudgeStartInvisibleAbility(const uint32_t accessTokenId, const bool visible) const +{ + return !!(MyFlag::flag_); +} +bool PermissionVerification::JudgeStartAbilityFromBackground(const bool isBackgroundCall) const +{ + return !!(MyFlag::flag_); +} +bool PermissionVerification::JudgeAssociatedWakeUp(const uint32_t accessTokenId, const bool associatedWakeUp) const +{ + return !!(MyFlag::flag_); +} +int PermissionVerification::JudgeInvisibleAndBackground(const VerificationInfo &verificationInfo) const +{ + return MyFlag::flag_; +} +bool PermissionVerification::JudgeCallerIsAllowedToUseSystemAPI() const +{ + TAG_LOGD(AAFwkTag::TEST, "mock JudgeCallerIsAllowedToUseSystemAPI flag_: %{public}d.", MyFlag::flag_); + return MyFlag::flag_; +} +bool PermissionVerification::IsSystemAppCall() const +{ + return true; +} +} // namespace AAFwk +} // namespace OHOS \ No newline at end of file From 848debfb73f0dee7ffff85cd4c9a81a25e5b5a6d Mon Sep 17 00:00:00 2001 From: zhubingwei Date: Wed, 22 May 2024 17:56:43 +0800 Subject: [PATCH 163/174] =?UTF-8?q?=E5=A2=9E=E5=8A=A0tdd=20AppConfigDataMa?= =?UTF-8?q?nagerTest?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhubingwei Change-Id: Ib24ccdd04fa3accd19f8e8b7ffcb5bfa1bffb688 --- test/unittest/BUILD.gn | 1 + .../app_config_data_manager_test/BUILD.gn | 80 +++++++++++ .../app_config_data_manager_test.cpp | 129 ++++++++++++++++++ 3 files changed, 210 insertions(+) create mode 100644 test/unittest/app_config_data_manager_test/BUILD.gn create mode 100644 test/unittest/app_config_data_manager_test/app_config_data_manager_test.cpp diff --git a/test/unittest/BUILD.gn b/test/unittest/BUILD.gn index 38d6e5a8f3..bca2c8559f 100644 --- a/test/unittest/BUILD.gn +++ b/test/unittest/BUILD.gn @@ -376,6 +376,7 @@ group("unittest") { "ams_recent_app_list_test:unittest", "ams_service_load_ability_process_test:unittest", "ams_service_startup_test:unittest", + "app_config_data_manager_test:unittest", "app_debug_info_test:unittest", "app_debug_listener_proxy_test:unittest", "app_debug_listener_stub_test:unittest", diff --git a/test/unittest/app_config_data_manager_test/BUILD.gn b/test/unittest/app_config_data_manager_test/BUILD.gn new file mode 100644 index 0000000000..699f0fc9a1 --- /dev/null +++ b/test/unittest/app_config_data_manager_test/BUILD.gn @@ -0,0 +1,80 @@ +# Copyright (c) 2021-2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/test.gni") +import("//foundation/ability/ability_runtime/ability_runtime.gni") + +module_output_path = "ability_runtime/appmgr" + +ohos_unittest("app_config_data_manager_test") { + module_out_path = module_output_path + cflags_cc = [] + include_dirs = [ + "${ability_runtime_path}/interfaces/kits/native/appkit/ability_bundle_manager_helper", + "${ability_runtime_services_path}/appmgr/include", + "${distributeddatamgr_path}/kv_store/interfaces/innerkits/distributeddata/include", + ] + + sources = [ + "${ability_runtime_services_path}/appmgr/src/app_config_data_manager.cpp", + ] + + sources += [ "app_config_data_manager_test.cpp" ] + + configs = [ "${ability_runtime_test_path}/unittest:appmgr_test_config" ] + cflags = [] + if (target_cpu == "arm") { + cflags += [ "-DBINDER_IPC_32BIT" ] + } + deps = [ + "${ability_runtime_innerkits_path}/app_manager:app_manager", + "${ability_runtime_native_path}/appkit:appkit_manager_helper", + "${ability_runtime_services_path}/appmgr:libappms", + "${ability_runtime_services_path}/common:perm_verification", + "${ability_runtime_services_path}/common:task_handler_wrap", + "${ability_runtime_test_path}/unittest:appmgr_test_source", + ] + + external_deps = [ + "access_token:libaccesstoken_sdk", + "access_token:libnativetoken", + "access_token:libtoken_setproc", + "appspawn:appspawn_client", + "bundle_framework:appexecfwk_core", + "ffrt:libffrt", + "hilog:libhilog", + "ipc:ipc_core", + "kv_store:distributeddata_inner", + "kv_store:distributeddata_mgr", + ] + + defines = [ "AMS_LOG_TAG = \"AppMgrService\"" ] + + if (ability_command_for_test) { + defines += [ "ABILITY_COMMAND_FOR_TEST" ] + } + + if (ability_runtime_graphics) { + defines += [ "SUPPORT_GRAPHICS" ] + deps += [] + external_deps += [ + "i18n:intl_util", + "window_manager:libwm", + ] + } +} + +group("unittest") { + testonly = true + deps = [ ":app_config_data_manager_test" ] +} diff --git a/test/unittest/app_config_data_manager_test/app_config_data_manager_test.cpp b/test/unittest/app_config_data_manager_test/app_config_data_manager_test.cpp new file mode 100644 index 0000000000..a0d65fe79c --- /dev/null +++ b/test/unittest/app_config_data_manager_test/app_config_data_manager_test.cpp @@ -0,0 +1,129 @@ +/* + * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include "app_config_data_manager.h" +#include "app_state_callback_host.h" +#include "errors.h" +#include "hilog_tag_wrapper.h" +#include "hilog_wrapper.h" +#include "mock_ability_token.h" + +using namespace testing; +using namespace testing::ext; + +namespace OHOS { +namespace AppExecFwk { +class AppConfigDataManagerTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + void SetUp(); + void TearDown(); +public: +protected: + static const std::string GetTestBundleName() + { + return "test_bundle_name"; + } + static const std::string GetTestAbilityInfoName() + { + return "test_ability_info_name"; + } + static const std::string GetTestModuleName() + { + return "test_module_name"; + } +}; + +void AppConfigDataManagerTest::SetUpTestCase() +{} + +void AppConfigDataManagerTest::TearDownTestCase() +{} + +void AppConfigDataManagerTest::SetUp() +{} + +void AppConfigDataManagerTest::TearDown() +{} + + +/* + * Feature: AppConfigDataManager + * Function: SetAppWaitingDebugInfo + * SubFunction: NA + * FunctionPoints: AppConfigDataManager SetAppWaitingDebugInfo + * EnvConditions: NA + * CaseDescription: bundle name empty + */ +HWTEST_F(AppConfigDataManagerTest, SetAppWaitingDebugInfo_001, TestSize.Level1) +{ + auto manager = std::make_shared(); + const std::string bundleName; + auto iret = manager->SetAppWaitingDebugInfo(bundleName); + ASSERT_EQ(iret, ERR_INVALID_VALUE); +} + +/* + * Feature: AppConfigDataManager + * Function: SetAppWaitingDebugInfo + * SubFunction: NA + * FunctionPoints: AppConfigDataManager SetAppWaitingDebugInfo + * EnvConditions: NA + * CaseDescription: set ok + */ +HWTEST_F(AppConfigDataManagerTest, SetAppWaitingDebugInfo_002, TestSize.Level1) +{ + auto manager = std::make_shared(); + const std::string bundleName = "bundle"; + auto iret = manager->SetAppWaitingDebugInfo(bundleName); + ASSERT_EQ(iret, ERR_OK); +} + +/* + * Feature: AppConfigDataManager + * Function: ClearAppWaitingDebugInfo + * SubFunction: NA + * FunctionPoints: AppConfigDataManager ClearAppWaitingDebugInfo + * EnvConditions: NA + * CaseDescription: clear ok + */ +HWTEST_F(AppConfigDataManagerTest, ClearAppWaitingDebugInfo_001, TestSize.Level1) +{ + auto manager = std::make_shared(); + auto iret = manager->ClearAppWaitingDebugInfo(); + ASSERT_EQ(iret, ERR_OK); +} + +/* + * Feature: AppConfigDataManager + * Function: GetAppWaitingDebugList + * SubFunction: NA + * FunctionPoints: AppConfigDataManager GetAppWaitingDebugList + * EnvConditions: NA + * CaseDescription: get ok + */ +HWTEST_F(AppConfigDataManagerTest, GetAppWaitingDebugList_001, TestSize.Level1) +{ + auto manager = std::make_shared(); + std::vector bundleNameList; + auto iret = manager->GetAppWaitingDebugList(bundleNameList); + ASSERT_EQ(iret, ERR_OK); +} + +} // namespace AppExecFwk +} // namespace OHOS From 90a0ec554ddf9126f109ff5df89e544a729751b7 Mon Sep 17 00:00:00 2001 From: zhubingwei Date: Wed, 22 May 2024 18:32:22 +0800 Subject: [PATCH 164/174] =?UTF-8?q?=E3=80=90TDD=E8=A6=86=E7=9B=96=E7=8E=87?= =?UTF-8?q?=E6=8F=90=E5=8D=87=E3=80=91frameworks\native\appkit\ability=5Fb?= =?UTF-8?q?undle=5Fmanager=5Fhelper?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhubingwei --- .../bundle_mgr_helper_test.cpp | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/test/unittest/bundle_mgr_helper_test/bundle_mgr_helper_test.cpp b/test/unittest/bundle_mgr_helper_test/bundle_mgr_helper_test.cpp index 6ad785ccc1..8cebf777bd 100644 --- a/test/unittest/bundle_mgr_helper_test/bundle_mgr_helper_test.cpp +++ b/test/unittest/bundle_mgr_helper_test/bundle_mgr_helper_test.cpp @@ -833,5 +833,32 @@ HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_GetCloneBundleInfo_001, TestSi auto ret = bundleMgrHelper->GetCloneBundleInfo(bundleName, flags, appCloneIndex, bundleInfo, userId); EXPECT_NE(ret, ERR_OK); } + +/** + * @tc.name: BundleMgrHelperTest_GetNameForUid_001 + * @tc.desc: GetNameForUid + * @tc.type: FUNC + */ +HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_GetNameForUid_001, TestSize.Level1) +{ + std::string name; + int32_t uid = 1; + auto ret = bundleMgrHelper->GetNameForUid(uid, name); + EXPECT_NE(ret, ERR_OK); +} + +/** + * @tc.name: BundleMgrHelperTest_GetLaunchWantForBundle_001 + * @tc.desc: GetLaunchWantForBundle + * @tc.type: FUNC + */ +HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_GetLaunchWantForBundle_001, TestSize.Level1) +{ + std::string bundleName; + Want want; + int32_t userId = DEFAULT_USERID; + auto ret = bundleMgrHelper->GetLaunchWantForBundle(bundleName, want, userId); + EXPECT_NE(ret, ERR_OK); +} } // namespace AppExecFwk } // namespace OHOS \ No newline at end of file From 705001bb247e57af763b49ae67c17b028df6ace2 Mon Sep 17 00:00:00 2001 From: XKK Date: Mon, 20 May 2024 15:44:33 +0800 Subject: [PATCH 165/174] fix pendingwantManager Signed-off-by: XKK --- services/abilitymgr/src/pending_want_manager.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/services/abilitymgr/src/pending_want_manager.cpp b/services/abilitymgr/src/pending_want_manager.cpp index fe523db4de..7c64efa785 100644 --- a/services/abilitymgr/src/pending_want_manager.cpp +++ b/services/abilitymgr/src/pending_want_manager.cpp @@ -41,7 +41,7 @@ PendingWantManager::PendingWantManager() PendingWantManager::~PendingWantManager() { - TAG_LOGD(AAFwkTag::WANTAGENT, "%{public}s(%{public}d)", __PRETTY_FUNCTION__, __LINE__); + TAG_LOGI(AAFwkTag::WANTAGENT, "%{public}s(%{public}d)", __PRETTY_FUNCTION__, __LINE__); } sptr PendingWantManager::GetWantSender(int32_t callingUid, int32_t uid, const bool isSystemApp, @@ -134,8 +134,8 @@ sptr PendingWantManager::GetPendingWantRecordByKey(const std: { TAG_LOGD(AAFwkTag::WANTAGENT, "begin"); for (const auto &item : wantRecords_) { - const auto &pendingKey = item.first; - const auto &pendingRecord = item.second; + const auto pendingKey = item.first; + const auto pendingRecord = item.second; if ((pendingRecord != nullptr) && CheckPendingWantRecordByKey(pendingKey, key)) { return pendingRecord; } @@ -146,6 +146,10 @@ sptr PendingWantManager::GetPendingWantRecordByKey(const std: bool PendingWantManager::CheckPendingWantRecordByKey( const std::shared_ptr &inputKey, const std::shared_ptr &key) { + if (!inputKey || !key) { + TAG_LOGW(AAFwkTag::WANTAGENT, "inputKey or key is nullptr!"); + return false; + } if (inputKey->GetBundleName().compare(key->GetBundleName()) != 0) { return false; } @@ -349,7 +353,6 @@ int32_t PendingWantManager::PendingRecordIdCreate() sptr PendingWantManager::GetPendingWantRecordByCode(int32_t code) { HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); - TAG_LOGD(AAFwkTag::WANTAGENT, "begin. wantRecords_ size = %{public}zu", wantRecords_.size()); std::lock_guard locker(mutex_); auto iter = std::find_if(wantRecords_.begin(), wantRecords_.end(), [&code](const auto &pair) { From ea66490a890d6d7055e9c50163732113b284b682 Mon Sep 17 00:00:00 2001 From: zhubingwei Date: Thu, 23 May 2024 09:51:07 +0800 Subject: [PATCH 166/174] =?UTF-8?q?=E3=80=90=E5=9F=BA=E7=A1=80=E8=83=BD?= =?UTF-8?q?=E5=8A=9B=E3=80=91=E5=85=83=E8=83=BD=E5=8A=9BTDD=E8=A6=86?= =?UTF-8?q?=E7=9B=96=E7=8E=87=E6=8F=90=E5=8D=87(ui=5Fability=5Flifecycle?= =?UTF-8?q?=5Fmanager=202nd)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhubingwei --- .../ui_ability_lifecycle_manager_test.cpp | 378 ++++++++++++++++++ 1 file changed, 378 insertions(+) diff --git a/test/unittest/ui_ability_lifecycle_manager_test/ui_ability_lifecycle_manager_test.cpp b/test/unittest/ui_ability_lifecycle_manager_test/ui_ability_lifecycle_manager_test.cpp index b0bcd76c81..8db0ae90c7 100644 --- a/test/unittest/ui_ability_lifecycle_manager_test/ui_ability_lifecycle_manager_test.cpp +++ b/test/unittest/ui_ability_lifecycle_manager_test/ui_ability_lifecycle_manager_test.cpp @@ -2879,5 +2879,383 @@ HWTEST_F(UIAbilityLifecycleManagerTest, GetActiveAbilityList_002, TestSize.Level uiAbilityLifecycleManager->GetActiveAbilityList(bundleName, abilityList, pid); uiAbilityLifecycleManager.reset(); } + +/** + * @tc.name: UIAbilityLifecycleManager_PrepareTerminateAbility_0100 + * @tc.desc: PrepareTerminateAbility + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, PrepareTerminateAbility_001, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_shared(); + EXPECT_NE(uiAbilityLifecycleManager, nullptr); + std::shared_ptr abilityRecord = nullptr; + bool boolValue = uiAbilityLifecycleManager->PrepareTerminateAbility(abilityRecord); + EXPECT_FALSE(boolValue); +} + +/** + * @tc.name: UIAbilityLifecycleManager_PrepareTerminateAbility_0200 + * @tc.desc: PrepareTerminateAbility + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, PrepareTerminateAbility_002, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_shared(); + EXPECT_NE(uiAbilityLifecycleManager, nullptr); + std::shared_ptr abilityRecord = InitAbilityRecord(); + bool boolValue = uiAbilityLifecycleManager->PrepareTerminateAbility(abilityRecord); + EXPECT_FALSE(boolValue); +} + +/** + * @tc.name: UIAbilityLifecycleManager_SetSessionHandler_0100 + * @tc.desc: SetSessionHandler + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, SetSessionHandler_001, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_unique(); + EXPECT_NE(uiAbilityLifecycleManager, nullptr); + sptr handler; + uiAbilityLifecycleManager->SetSessionHandler(handler); + EXPECT_EQ(uiAbilityLifecycleManager->handler_, handler); +} + +/** + * @tc.name: UIAbilityLifecycleManager_GetAbilityRecordsById_0100 + * @tc.desc: GetAbilityRecordsById + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, GetAbilityRecordsById_001, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_unique(); + int32_t sessionId = 100; + AbilityRequest abilityRequest; + auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest); + uiAbilityLifecycleManager->sessionAbilityMap_.emplace(sessionId, abilityRecord); + EXPECT_EQ(uiAbilityLifecycleManager->GetAbilityRecordsById(sessionId + 1), nullptr); +} + +/** + * @tc.name: UIAbilityLifecycleManager_GetAbilityRecordsById_0200 + * @tc.desc: GetAbilityRecordsById + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, GetAbilityRecordsById_002, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_unique(); + int32_t sessionId = 100; + AbilityRequest abilityRequest; + auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest); + uiAbilityLifecycleManager->sessionAbilityMap_.emplace(sessionId, abilityRecord); + EXPECT_NE(uiAbilityLifecycleManager->GetAbilityRecordsById(sessionId), nullptr); +} + +/** + * @tc.name: UIAbilityLifecycleManager_OnAppStateChanged_0100 + * @tc.desc: OnAppStateChanged + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, OnAppStateChanged_001, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_shared(); + ASSERT_NE(uiAbilityLifecycleManager, nullptr); + AbilityRequest abilityRequest; + abilityRequest.appInfo.bundleName = "com.example.unittest"; + abilityRequest.abilityInfo.name = "MainAbility"; + abilityRequest.abilityInfo.process = "AbilityProcess"; + std::shared_ptr abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest); + AppInfo info; + info.processName = "AbilityProcess"; + info.state = AppState::TERMINATED; + uiAbilityLifecycleManager->terminateAbilityList_.emplace_back(abilityRecord); + uiAbilityLifecycleManager->OnAppStateChanged(info); + uiAbilityLifecycleManager.reset(); +} + +/** + * @tc.name: UIAbilityLifecycleManager_OnAppStateChanged_0200 + * @tc.desc: OnAppStateChanged + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, OnAppStateChanged_002, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_shared(); + ASSERT_NE(uiAbilityLifecycleManager, nullptr); + AbilityRequest abilityRequest; + abilityRequest.appInfo.bundleName = "com.example.unittest"; + abilityRequest.abilityInfo.name = "MainAbility"; + abilityRequest.abilityInfo.process = "AbilityProcess"; + std::shared_ptr abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest); + AppInfo info; + info.processName = "AbilityProcess"; + info.state = AppState::END; + uiAbilityLifecycleManager->terminateAbilityList_.emplace_back(abilityRecord); + uiAbilityLifecycleManager->OnAppStateChanged(info); + uiAbilityLifecycleManager.reset(); +} + +/** + * @tc.name: UIAbilityLifecycleManager_OnAppStateChanged_0300 + * @tc.desc: OnAppStateChanged + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, OnAppStateChanged_003, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_shared(); + ASSERT_NE(uiAbilityLifecycleManager, nullptr); + AbilityRequest abilityRequest; + abilityRequest.appInfo.bundleName = "com.example.unittest"; + abilityRequest.abilityInfo.name = "MainAbility"; + abilityRequest.abilityInfo.process = "AbilityProcess"; + std::shared_ptr abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest); + AppInfo info; + info.processName = "com.example.unittest"; + info.state = AppState::TERMINATED; + uiAbilityLifecycleManager->terminateAbilityList_.emplace_back(abilityRecord); + uiAbilityLifecycleManager->OnAppStateChanged(info); + uiAbilityLifecycleManager.reset(); +} + +/** + * @tc.name: UIAbilityLifecycleManager_OnAppStateChanged_0400 + * @tc.desc: OnAppStateChanged + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, OnAppStateChanged_004, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_shared(); + ASSERT_NE(uiAbilityLifecycleManager, nullptr); + AbilityRequest abilityRequest; + abilityRequest.appInfo.bundleName = "com.example.unittest"; + abilityRequest.abilityInfo.name = "MainAbility"; + abilityRequest.abilityInfo.process = "AbilityProcess"; + std::shared_ptr abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest); + AppInfo info; + info.processName = "com.example.unittest"; + info.state = AppState::END; + uiAbilityLifecycleManager->terminateAbilityList_.emplace_back(abilityRecord); + uiAbilityLifecycleManager->OnAppStateChanged(info); + uiAbilityLifecycleManager.reset(); +} + +/** + * @tc.name: UIAbilityLifecycleManager_OnAppStateChanged_0500 + * @tc.desc: OnAppStateChanged + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, OnAppStateChanged_005, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_shared(); + ASSERT_NE(uiAbilityLifecycleManager, nullptr); + AbilityRequest abilityRequest; + abilityRequest.appInfo.bundleName = "com.example.unittest"; + abilityRequest.abilityInfo.name = "MainAbility"; + abilityRequest.abilityInfo.process = "AbilityProcess"; + std::shared_ptr abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest); + AppInfo info; + info.processName = "com.example.unittest"; + info.state = AppState::COLD_START; + uiAbilityLifecycleManager->sessionAbilityMap_.emplace(0, abilityRecord); + uiAbilityLifecycleManager->OnAppStateChanged(info); + uiAbilityLifecycleManager.reset(); +} + +/** + * @tc.name: UIAbilityLifecycleManager_OnAppStateChanged_0600 + * @tc.desc: OnAppStateChanged + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, OnAppStateChanged_006, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_shared(); + ASSERT_NE(uiAbilityLifecycleManager, nullptr); + AbilityRequest abilityRequest; + abilityRequest.appInfo.bundleName = "com.example.unittest"; + abilityRequest.abilityInfo.name = "MainAbility"; + abilityRequest.abilityInfo.process = "AbilityProcess"; + std::shared_ptr abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest); + AppInfo info; + info.processName = "AbilityProcess"; + info.state = AppState::COLD_START; + uiAbilityLifecycleManager->sessionAbilityMap_.emplace(0, abilityRecord); + uiAbilityLifecycleManager->OnAppStateChanged(info); + uiAbilityLifecycleManager.reset(); +} + +/** + * @tc.name: UIAbilityLifecycleManager_OnAppStateChanged_0700 + * @tc.desc: OnAppStateChanged + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, OnAppStateChanged_007, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_shared(); + ASSERT_NE(uiAbilityLifecycleManager, nullptr); + AbilityRequest abilityRequest; + abilityRequest.appInfo.bundleName = "com.example.unittest"; + abilityRequest.abilityInfo.name = "MainAbility"; + abilityRequest.abilityInfo.process = "AbilityProcess"; + std::shared_ptr abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest); + AppInfo info; + info.processName = "com.example.unittest"; + uiAbilityLifecycleManager->sessionAbilityMap_.emplace(0, abilityRecord); + uiAbilityLifecycleManager->OnAppStateChanged(info); + uiAbilityLifecycleManager.reset(); +} + +/** + * @tc.name: UIAbilityLifecycleManager_OnAppStateChanged_0800 + * @tc.desc: OnAppStateChanged + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, OnAppStateChanged_008, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_shared(); + ASSERT_NE(uiAbilityLifecycleManager, nullptr); + AbilityRequest abilityRequest; + abilityRequest.appInfo.bundleName = "com.example.unittest"; + abilityRequest.abilityInfo.name = "MainAbility"; + abilityRequest.abilityInfo.process = "AbilityProcess"; + std::shared_ptr abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest); + AppInfo info; + info.processName = "AbilityProcess"; + uiAbilityLifecycleManager->sessionAbilityMap_.emplace(0, abilityRecord); + uiAbilityLifecycleManager->OnAppStateChanged(info); + uiAbilityLifecycleManager.reset(); +} + +/** + * @tc.name: UIAbilityLifecycleManager_UninstallApp_0100 + * @tc.desc: UninstallApp + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, UninstallApp_001, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_shared(); + ASSERT_NE(uiAbilityLifecycleManager, nullptr); + AbilityRequest abilityRequest; + abilityRequest.abilityInfo.bundleName = "com.example.unittest"; + abilityRequest.abilityInfo.name = "MainAbility"; + std::shared_ptr abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest); + AppInfo info; + std::string bundleName = "com.example.unittest"; + int32_t uid = 0; + uiAbilityLifecycleManager->sessionAbilityMap_.emplace(0, abilityRecord); + uiAbilityLifecycleManager->UninstallApp(bundleName, uid); + uiAbilityLifecycleManager.reset(); +} + +/** + * @tc.name: UIAbilityLifecycleManager_GetAbilityRunningInfos_0100 + * @tc.desc: GetAbilityRunningInfos + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, GetAbilityRunningInfos_001, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_shared(); + ASSERT_NE(uiAbilityLifecycleManager, nullptr); + std::shared_ptr abilityRecord = InitAbilityRecord(); + uiAbilityLifecycleManager->sessionAbilityMap_.emplace(0, abilityRecord); + std::vector info; + bool isPerm = true; + uiAbilityLifecycleManager->GetAbilityRunningInfos(info, isPerm); + uiAbilityLifecycleManager.reset(); +} + +/** + * @tc.name: UIAbilityLifecycleManager_GetAbilityRunningInfos_0200 + * @tc.desc: GetAbilityRunningInfos + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, GetAbilityRunningInfos_002, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_shared(); + ASSERT_NE(uiAbilityLifecycleManager, nullptr); + AbilityRequest abilityRequest; + abilityRequest.appInfo.accessTokenId = IPCSkeleton::GetCallingTokenID(); + std::shared_ptr abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest); + uiAbilityLifecycleManager->sessionAbilityMap_.emplace(0, abilityRecord); + std::vector info; + bool isPerm = false; + uiAbilityLifecycleManager->GetAbilityRunningInfos(info, isPerm); + uiAbilityLifecycleManager.reset(); +} + +/** + * @tc.name: UIAbilityLifecycleManager_MoveMissionToFront_0100 + * @tc.desc: MoveMissionToFront + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, MoveMissionToFront_001, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_unique(); + ASSERT_NE(uiAbilityLifecycleManager, nullptr); + uiAbilityLifecycleManager->rootSceneSession_ = nullptr; + int32_t sessionId = 100; + std::shared_ptr startOptions; + EXPECT_EQ(uiAbilityLifecycleManager->MoveMissionToFront(sessionId, startOptions), ERR_INVALID_VALUE); +} + +/** + * @tc.name: UIAbilityLifecycleManager_MoveMissionToFront_0200 + * @tc.desc: MoveMissionToFront + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, MoveMissionToFront_002, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_unique(); + ASSERT_NE(uiAbilityLifecycleManager, nullptr); + Rosen::SessionInfo info; + uiAbilityLifecycleManager->rootSceneSession_ = new Rosen::Session(info); + int32_t sessionId = 100; + std::shared_ptr startOptions; + std::shared_ptr abilityRecord = InitAbilityRecord(); + uiAbilityLifecycleManager->sessionAbilityMap_.emplace(0, abilityRecord); + EXPECT_EQ(uiAbilityLifecycleManager->MoveMissionToFront(sessionId, startOptions), ERR_INVALID_VALUE); +} + +/** + * @tc.name: UIAbilityLifecycleManager_MoveMissionToFront_0300 + * @tc.desc: MoveMissionToFront + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, MoveMissionToFront_003, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_unique(); + ASSERT_NE(uiAbilityLifecycleManager, nullptr); + Rosen::SessionInfo info; + uiAbilityLifecycleManager->rootSceneSession_ = new Rosen::Session(info); + int32_t sessionId = 100; + std::shared_ptr startOptions; + AbilityRequest abilityRequest; + sptr sessionInfo = nullptr; + abilityRequest.sessionInfo = sessionInfo; + auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest); + uiAbilityLifecycleManager->sessionAbilityMap_.emplace(sessionId, abilityRecord); + EXPECT_EQ(uiAbilityLifecycleManager->MoveMissionToFront(sessionId, startOptions), ERR_INVALID_VALUE); +} + +/** + * @tc.name: UIAbilityLifecycleManager_MoveMissionToFront_0400 + * @tc.desc: MoveMissionToFront + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, MoveMissionToFront_004, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_unique(); + ASSERT_NE(uiAbilityLifecycleManager, nullptr); + int32_t sessionId = 100; + std::shared_ptr startOptions; + Rosen::SessionInfo info; + uiAbilityLifecycleManager->rootSceneSession_ = new Rosen::Session(info); + AbilityRequest abilityRequest; + sptr sessionInfo = (new SessionInfo()); + abilityRequest.sessionInfo = sessionInfo; + auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest); + uiAbilityLifecycleManager->sessionAbilityMap_.emplace(sessionId, abilityRecord); + EXPECT_EQ(uiAbilityLifecycleManager->MoveMissionToFront(sessionId, startOptions), ERR_OK); +} } // namespace AAFwk } // namespace OHOS From 6f94050739cb0ca5d637158c0753ad294be03456 Mon Sep 17 00:00:00 2001 From: huangshiwei Date: Mon, 20 May 2024 16:45:53 +0800 Subject: [PATCH 167/174] huangshiwei4@huawei.com Signed-off-by: huangshiwei --- services/appmgr/src/app_mgr_service_inner.cpp | 2 +- services/appmgr/src/app_spawn_client.cpp | 28 +++++++++++-------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/services/appmgr/src/app_mgr_service_inner.cpp b/services/appmgr/src/app_mgr_service_inner.cpp index 0e4c608025..28b79a4a35 100644 --- a/services/appmgr/src/app_mgr_service_inner.cpp +++ b/services/appmgr/src/app_mgr_service_inner.cpp @@ -4462,7 +4462,7 @@ int AppMgrServiceInner::StartRenderProcess(const pid_t hostPid, const std::strin int32_t childNumLimit = appRecord->GetIsGPU() ? PHONE_MAX_RENDER_PROCESS_NUM + 1 : PHONE_MAX_RENDER_PROCESS_NUM; // The phone device allows a maximum of 40 render processes to be created. if (AAFwk::AppUtils::GetInstance().IsLimitMaximumOfRenderProcess() && - renderRecordMap.size() >= childNumLimit) { + renderRecordMap.size() >= static_cast(childNumLimit)) { TAG_LOGE(AAFwkTag::APPMGR, "Reaching the maximum render process limitation, hostPid:%{public}d", hostPid); return ERR_REACHING_MAXIMUM_RENDER_PROCESS_LIMITATION; } diff --git a/services/appmgr/src/app_spawn_client.cpp b/services/appmgr/src/app_spawn_client.cpp index ff4f2ca156..b37be945c1 100644 --- a/services/appmgr/src/app_spawn_client.cpp +++ b/services/appmgr/src/app_spawn_client.cpp @@ -172,11 +172,13 @@ int32_t AppSpawnClient::SetMountPermission(const AppSpawnStartMsg &startMsg, App } } - if (!startMsg.processType.empty() && - (ret = AppSpawnReqMsgAddExtInfo(reqHandle, MSG_EXT_NAME_PROCESS_TYPE, - reinterpret_cast(startMsg.processType.c_str()), startMsg.processType.size()))) { - HILOG_ERROR("AppSpawnReqMsgAddExtInfo failed, ret: %{public}d", ret); - return ret; + if (!startMsg.processType.empty()) { + ret = AppSpawnReqMsgAddExtInfo(reqHandle, MSG_EXT_NAME_PROCESS_TYPE, + reinterpret_cast(startMsg.processType.c_str()), startMsg.processType.size()); + if (ret) { + TAG_LOGE(AAFwkTag::APPMGR, "AppSpawnReqMsgAddExtInfo failed, ret: %{public}d", ret); + return ret; + } } return ret; @@ -216,9 +218,11 @@ int32_t AppSpawnClient::SetAtomicServiceFlag(const AppSpawnStartMsg &startMsg, A int32_t AppSpawnClient::SetStrictMode(const AppSpawnStartMsg &startMsg, AppSpawnReqMsgHandle reqHandle) { int32_t ret = 0; - if (startMsg.strictMode && - (ret = AppSpawnReqMsgSetAppFlag(reqHandle, APP_FLAGS_ISOLATED_SANDBOX))) { - HILOG_ERROR("AppSpawnReqMsgSetAppFlag failed, ret: %{public}d", ret); + if (startMsg.strictMode) { + ret = AppSpawnReqMsgSetAppFlag(reqHandle, APP_FLAGS_ISOLATED_SANDBOX); + if (ret) { + TAG_LOGE(AAFwkTag::APPMGR, "AppSpawnReqMsgSetAppFlag failed, ret: %{public}d", ret); + } } return ret; } @@ -226,9 +230,11 @@ int32_t AppSpawnClient::SetStrictMode(const AppSpawnStartMsg &startMsg, AppSpawn int32_t AppSpawnClient::SetAppExtension(const AppSpawnStartMsg &startMsg, AppSpawnReqMsgHandle reqHandle) { int32_t ret = 0; - if (startMsg.isolatedExtension && - (ret = AppSpawnReqMsgSetAppFlag(reqHandle, APP_FLAGS_EXTENSION_SANDBOX))) { - HILOG_ERROR("AppSpawnReqMsgSetAppFlag failed, ret: %{public}d", ret); + if (startMsg.isolatedExtension) { + ret = AppSpawnReqMsgSetAppFlag(reqHandle, APP_FLAGS_EXTENSION_SANDBOX); + if (ret) { + TAG_LOGE(AAFwkTag::APPMGR, "AppSpawnReqMsgSetAppFlag failed, ret: %{public}d", ret); + } } return ret; } From aeed8944c74f34b33a70f795a2d9f548df3b2fbc Mon Sep 17 00:00:00 2001 From: zhubingwei Date: Thu, 23 May 2024 11:14:16 +0800 Subject: [PATCH 168/174] =?UTF-8?q?=E5=85=83=E8=83=BD=E5=8A=9BTDD=E8=A6=86?= =?UTF-8?q?=E7=9B=96=E7=8E=87=E6=8F=90=E5=8D=87[appfreeze=5Fstate=5Ftest.c?= =?UTF-8?q?pp]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Issue: https://gitee.com/openharmony/ability_ability_runtime/issues/I9RHTU Signed-off-by: zhubingwei --- test/unittest/dfr_test/BUILD.gn | 1 + .../dfr_test/appfreeze_state_test/BUILD.gn | 113 ++++++++++++++++++ .../appfreeze_state_test.cpp | 75 ++++++++++++ 3 files changed, 189 insertions(+) create mode 100644 test/unittest/dfr_test/appfreeze_state_test/BUILD.gn create mode 100644 test/unittest/dfr_test/appfreeze_state_test/appfreeze_state_test.cpp diff --git a/test/unittest/dfr_test/BUILD.gn b/test/unittest/dfr_test/BUILD.gn index 70b3bcae2f..5a118ff417 100644 --- a/test/unittest/dfr_test/BUILD.gn +++ b/test/unittest/dfr_test/BUILD.gn @@ -18,6 +18,7 @@ group("unittest") { deps += [ "appfreeze_inner_test:unittest", "appfreeze_manager_test:unittest", + "appfreeze_state_test:unittest", "watchdog_test:unittest", ] } diff --git a/test/unittest/dfr_test/appfreeze_state_test/BUILD.gn b/test/unittest/dfr_test/appfreeze_state_test/BUILD.gn new file mode 100644 index 0000000000..57c1669ea6 --- /dev/null +++ b/test/unittest/dfr_test/appfreeze_state_test/BUILD.gn @@ -0,0 +1,113 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/ohos.gni") +import("//build/test.gni") +import("//foundation/ability/ability_runtime/ability_runtime.gni") + +module_output_path = "ability_runtime/appfreeze_state_test" + +############################################################################### +config("module_context_config") { + visibility = [ ":*" ] + include_dirs = [ + "${ability_runtime_innerkits_path}/app_manager/include/appmgr", + "${ability_runtime_test_path}/mock/frameworks_kits_appkit_native_test/include", + "${ability_runtime_test_path}/mock/frameworks_kits_ability_native_test/include", + "${ability_runtime_path}/interfaces/kits/native/appkit/app/task", + "${ability_runtime_path}/interfaces/kits/native/ability/native", + ] + cflags = [] + if (target_cpu == "arm") { + cflags += [ "-DBINDER_IPC_32BIT" ] + } + defines = [ "AMS_LOG_TAG = \"ApplicationUnitTest\"" ] +} + +config("ability_start_setting_config") { + visibility = [ ":*" ] + include_dirs = [ + "${ability_runtime_path}/interfaces/kits/native/appkit/app", + "${ability_runtime_path}/interfaces/kits/native/appkit/dfr", + "${c_utils_base_path}/include", + "${ability_runtime_innerkits_path}/ability_manager/include", + ] +} + +ohos_unittest("appfreeze_state_test") { + module_out_path = module_output_path + + include_dirs = [ + "${ability_runtime_path}/interfaces/kits/native/appkit/dfr", + "${ability_runtime_path}/utils/global/time/include", + "//third_party/json/include", + ] + + configs = [ + ":module_context_config", + ":ability_start_setting_config", + ] + + sources = [ + "${ability_runtime_native_path}/appkit/dfr/appfreeze_inner.cpp", + "${ability_runtime_native_path}/appkit/dfr/appfreeze_state.cpp", + "appfreeze_state_test.cpp", + ] + + deps = [ + "${ability_runtime_abilitymgr_path}/:abilityms", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/app_manager:app_manager", + "${ability_runtime_innerkits_path}/deps_wrapper:ability_deps_wrapper", + "${ability_runtime_innerkits_path}/runtime:runtime", + "${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr", + "${ability_runtime_native_path}/ability/native:ability_thread", + "${ability_runtime_native_path}/ability/native:abilitykit_native", + "${ability_runtime_native_path}/ability/native:uiabilitykit_native", + "${ability_runtime_native_path}/appkit:app_context", + "${ability_runtime_native_path}/appkit:app_context_utils", + "${ability_runtime_native_path}/appkit:appkit_native", + "${ability_runtime_path}/utils/global/freeze:freeze_util", + ] + + external_deps = [ + "ability_base:configuration", + "ability_base:extractresourcemanager", + "ability_base:string_utils", + "ability_base:want", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "eventhandler:libeventhandler", + "faultloggerd:libbacktrace_local", + "faultloggerd:libdfx_procinfo", + "faultloggerd:libfaultloggerd", + "ffrt:libffrt", + "graphic_2d:librender_service_client", + "hicollie:libhicollie", + "hilog:libhilog", + "hisysevent:libhisysevent", + "hitrace:hitrace_meter", + "init:libbegetutil", + "ipc:ipc_core", + "napi:ace_napi", + ] +} + +############################################################################### + +group("unittest") { + testonly = true + deps = [ ":appfreeze_state_test" ] +} diff --git a/test/unittest/dfr_test/appfreeze_state_test/appfreeze_state_test.cpp b/test/unittest/dfr_test/appfreeze_state_test/appfreeze_state_test.cpp new file mode 100644 index 0000000000..34c4a059f4 --- /dev/null +++ b/test/unittest/dfr_test/appfreeze_state_test/appfreeze_state_test.cpp @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include "appfreeze_state.h" + +#define private public +#include "appfreeze_inner.h" +#undef private + +using namespace testing; +using namespace testing::ext; +using namespace OHOS::AbilityRuntime; +using namespace OHOS::AppExecFwk; + +namespace OHOS { +namespace AbilityRuntime { +class AppFreezeStateTest : public testing::Test { +public: + AppFreezeStateTest() + {} + ~AppFreezeStateTest() + {} + static void SetUpTestCase(void); + static void TearDownTestCase(void); + void SetUp(); + void TearDown(); +}; + +void AppFreezeStateTest::SetUpTestCase(void) +{} + +void AppFreezeStateTest::TearDownTestCase(void) +{} + +void AppFreezeStateTest::SetUp(void) +{} + +void AppFreezeStateTest::TearDown(void) +{} + +/** + * @tc.number: AppfreezeStateTest_001 + * @tc.desc: Verify that function SetAppFreezeState and CancelAppFreezeState. + * @tc.type: FUNC + */ +HWTEST_F(AppFreezeStateTest, AppfreezeStateTest_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "AppfreezeStateTest_001 start"; + uint32_t flag = 1; + auto appFreezeState = std::make_shared (); + auto inner = AppfreezeInner::GetInstance(); + appFreezeState->SetAppFreezeState(flag); + EXPECT_FALSE(inner->IsHandleAppfreeze()); + + flag = -1; + appFreezeState->CancelAppFreezeState(flag); + EXPECT_TRUE(inner->IsHandleAppfreeze()); + GTEST_LOG_(INFO) << "AppfreezeStateTest_001 end"; +} +} // namespace AbilityRuntime +} // namespace OHOS From 53e914032a65fc7460aecce410cfa804764ad629 Mon Sep 17 00:00:00 2001 From: lixing0101 Date: Tue, 7 May 2024 11:10:54 +0800 Subject: [PATCH 169/174] jsheap to /data/log/hidumper Signed-off-by: lixing0101 --- frameworks/native/appkit/app/main_thread.cpp | 11 +++- frameworks/native/runtime/js_runtime.cpp | 5 +- .../include/appmgr/app_jsheap_mem_info.h | 5 ++ .../src/appmgr/app_jsheap_mem_info.cpp | 64 +++++++++++++++++-- .../inner_api/runtime/include/cj_runtime.h | 3 +- .../inner_api/runtime/include/js_runtime.h | 3 +- .../inner_api/runtime/include/runtime.h | 3 +- .../mock_runtime.h | 3 +- .../unittest/runtime_test/js_runtime_test.cpp | 4 +- 9 files changed, 87 insertions(+), 14 deletions(-) diff --git a/frameworks/native/appkit/app/main_thread.cpp b/frameworks/native/appkit/app/main_thread.cpp index c9b0018c9f..f29d32b873 100644 --- a/frameworks/native/appkit/app/main_thread.cpp +++ b/frameworks/native/appkit/app/main_thread.cpp @@ -640,7 +640,16 @@ void MainThread::ScheduleJsHeapMemory(OHOS::AppExecFwk::JsHeapDumpInfo &info) return; } if (info.needSnapshot == true) { - runtime->DumpHeapSnapshot(info.tid, info.needGc); + std::vector fdVec; + for (auto &fd : info.fdVec) { + uint32_t newFd = dup(fd); + if (newFd == -1) { + TAG_LOGE(AAFwkTag::APPKIT, "dup failed."); + return; + } + fdVec.push_back(newFd); + } + runtime->DumpHeapSnapshot(info.tid, info.needGc, fdVec, info.tidVec); } else { if (info.needGc == true) { runtime->ForceFullGC(info.tid); diff --git a/frameworks/native/runtime/js_runtime.cpp b/frameworks/native/runtime/js_runtime.cpp index e272ba8612..fd7414a2b5 100644 --- a/frameworks/native/runtime/js_runtime.cpp +++ b/frameworks/native/runtime/js_runtime.cpp @@ -1195,11 +1195,12 @@ void JsRuntime::DumpHeapSnapshot(bool isPrivate) nativeEngine->DumpHeapSnapshot(true, DumpFormat::JSON, isPrivate, false); } -void JsRuntime::DumpHeapSnapshot(uint32_t tid, bool isFullGC) +void JsRuntime::DumpHeapSnapshot(uint32_t tid, bool isFullGC, std::vector fdVec, + std::vector tidVec) { auto vm = GetEcmaVm(); CHECK_POINTER(vm); - DFXJSNApi::DumpHeapSnapshot(vm, 0, true, false, false, isFullGC, tid); + DFXJSNApi::DumpHeapSnapshot(vm, 0, true, false, false, isFullGC, tid, fdVec, tidVec); } void JsRuntime::ForceFullGC(uint32_t tid) diff --git a/interfaces/inner_api/app_manager/include/appmgr/app_jsheap_mem_info.h b/interfaces/inner_api/app_manager/include/appmgr/app_jsheap_mem_info.h index e720f38282..6791cf79fb 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/app_jsheap_mem_info.h +++ b/interfaces/inner_api/app_manager/include/appmgr/app_jsheap_mem_info.h @@ -16,16 +16,21 @@ #ifndef OHOS_ABILITY_RUNTIME_APP_JSHEAP_MEM_INFO_H #define OHOS_ABILITY_RUNTIME_APP_JSHEAP_MEM_INFO_H +#include #include "parcel.h" #include "iremote_object.h" namespace OHOS { namespace AppExecFwk { struct JsHeapDumpInfo : public Parcelable { + ~JsHeapDumpInfo(); uint32_t pid; uint32_t tid; bool needGc; bool needSnapshot; + std::vector fdVec; + std::vector tidVec; + bool ReadFromParcel(Parcel &parcel); virtual bool Marshalling(Parcel &parcel) const override; static JsHeapDumpInfo *Unmarshalling(Parcel &parcel); }; diff --git a/interfaces/inner_api/app_manager/src/appmgr/app_jsheap_mem_info.cpp b/interfaces/inner_api/app_manager/src/appmgr/app_jsheap_mem_info.cpp index 02b4333129..619f615ccb 100644 --- a/interfaces/inner_api/app_manager/src/appmgr/app_jsheap_mem_info.cpp +++ b/interfaces/inner_api/app_manager/src/appmgr/app_jsheap_mem_info.cpp @@ -19,10 +19,61 @@ namespace OHOS { namespace AppExecFwk { +namespace { +constexpr int32_t MAX_TID_COUNT = 40; +} + +JsHeapDumpInfo::~JsHeapDumpInfo() +{ + TAG_LOGI(AAFwkTag::APPMGR, "~JsHeapDumpInfo start"); + for (auto &fd : fdVec) { + close(fd); + } + fdVec.clear(); + tidVec.clear(); +} + bool JsHeapDumpInfo::Marshalling(Parcel &parcel) const { - return (parcel.WriteUint32(pid) && parcel.WriteUint32(tid) - && parcel.WriteBool(needGc) && parcel.WriteBool(needSnapshot)); + bool res = (parcel.WriteUint32(pid) && parcel.WriteUint32(tid) + && parcel.WriteBool(needGc) && parcel.WriteBool(needSnapshot) + && parcel.WriteUInt32Vector(fdVec) && parcel.WriteUInt32Vector(tidVec)); + + auto msgParcel = static_cast(&parcel); + if (msgParcel == nullptr) { + TAG_LOGE(AAFwkTag::APPMGR, "Dump Marshalling msgParcel==nullptr"); + return false; + } + for (auto &fd : fdVec) { + msgParcel->WriteFileDescriptor(fd); + } + return res; +} + +bool JsHeapDumpInfo::ReadFromParcel(Parcel &parcel) +{ + pid = parcel.ReadUint32(); + tid = parcel.ReadUint32(); + needGc = parcel.ReadBool(); + needSnapshot = parcel.ReadBool(); + if (fdVec.size() > MAX_TID_COUNT || tidVec.size() > MAX_TID_COUNT) { + TAG_LOGE(AAFwkTag::APPMGR, "fdVec or tidVec size more than 40."); + return false; + } + parcel.ReadUInt32Vector(&fdVec); + parcel.ReadUInt32Vector(&tidVec); + + auto msgParcel = static_cast(&parcel); + if (msgParcel == nullptr) { + TAG_LOGE(AAFwkTag::APPMGR, "ReadFromParcel failed."); + return false; + } + fdVec.clear(); + for (auto &tid : tidVec) { + uint32_t parcelFd = static_cast(msgParcel->ReadFileDescriptor()); + fdVec.push_back(parcelFd); + } + return true; } JsHeapDumpInfo *JsHeapDumpInfo::Unmarshalling(Parcel &parcel) @@ -32,10 +83,11 @@ JsHeapDumpInfo *JsHeapDumpInfo::Unmarshalling(Parcel &parcel) TAG_LOGE(AAFwkTag::APPMGR, "info nullptr"); return nullptr; } - info->pid = parcel.ReadUint32(); - info->tid = parcel.ReadUint32(); - info->needGc = parcel.ReadBool(); - info->needSnapshot = parcel.ReadBool(); + if (info && !info->ReadFromParcel(parcel)) { + TAG_LOGE(AAFwkTag::APPMGR, "JsHeapDumpInfo failed, because ReadFromParcel failed"); + delete info; + info = nullptr; + } return info; } } // namespace AppExecFwk diff --git a/interfaces/inner_api/runtime/include/cj_runtime.h b/interfaces/inner_api/runtime/include/cj_runtime.h index d6c8aed7a2..b2ecbf80df 100644 --- a/interfaces/inner_api/runtime/include/cj_runtime.h +++ b/interfaces/inner_api/runtime/include/cj_runtime.h @@ -61,7 +61,8 @@ public: void DestroyHeapProfiler() override {}; void ForceFullGC() override {}; void ForceFullGC(uint32_t tid) override {}; - void DumpHeapSnapshot(uint32_t tid, bool isFullGC) override {}; + void DumpHeapSnapshot(uint32_t tid, bool isFullGC, std::vector fdVec, + std::vector tidVec) override {}; void DumpCpuProfile(bool isPrivate) override {}; void AllowCrossThreadExecution() override {}; void GetHeapPrepare() override {}; diff --git a/interfaces/inner_api/runtime/include/js_runtime.h b/interfaces/inner_api/runtime/include/js_runtime.h index 6a34c6f6c0..268607ff1c 100644 --- a/interfaces/inner_api/runtime/include/js_runtime.h +++ b/interfaces/inner_api/runtime/include/js_runtime.h @@ -85,7 +85,8 @@ public: void DestroyHeapProfiler() override; void ForceFullGC() override; void ForceFullGC(uint32_t tid) override; - void DumpHeapSnapshot(uint32_t tid, bool isFullGC) override; + void DumpHeapSnapshot(uint32_t tid, bool isFullGC, std::vector fdVec, + std::vector tidVec) override; void AllowCrossThreadExecution() override; void GetHeapPrepare() override; bool BuildJsStackInfoList(uint32_t tid, std::vector& jsFrames) override; diff --git a/interfaces/inner_api/runtime/include/runtime.h b/interfaces/inner_api/runtime/include/runtime.h index 67640a6ef6..b894d4c835 100644 --- a/interfaces/inner_api/runtime/include/runtime.h +++ b/interfaces/inner_api/runtime/include/runtime.h @@ -97,7 +97,8 @@ public: virtual void DestroyHeapProfiler() = 0; virtual void ForceFullGC() = 0; virtual void ForceFullGC(uint32_t tid) = 0; - virtual void DumpHeapSnapshot(uint32_t tid, bool isFullGC) = 0; + virtual void DumpHeapSnapshot(uint32_t tid, bool isFullGC, std::vector fdVec, + std::vector tidVec) = 0; virtual void AllowCrossThreadExecution() = 0; virtual void GetHeapPrepare() = 0; virtual void NotifyApplicationState(bool isBackground) = 0; diff --git a/test/mock/frameworks_kits_runtime_test/mock_runtime.h b/test/mock/frameworks_kits_runtime_test/mock_runtime.h index 5742d1f2ef..37e03ebdfa 100644 --- a/test/mock/frameworks_kits_runtime_test/mock_runtime.h +++ b/test/mock/frameworks_kits_runtime_test/mock_runtime.h @@ -124,7 +124,8 @@ public: void StartProfiler(const DebugOption debugOption) override {} void DoCleanWorkAfterStageCleaned() override {} - void DumpHeapSnapshot(uint32_t tid, bool isFullGC) override {} + void DumpHeapSnapshot(uint32_t tid, bool isFullGC, std::vector fdVec, + std::vector tidVec) override {} void ForceFullGC(uint32_t tid) override {} public: Language language; diff --git a/test/unittest/runtime_test/js_runtime_test.cpp b/test/unittest/runtime_test/js_runtime_test.cpp index 3d3c3e28eb..14b0e8ec3e 100755 --- a/test/unittest/runtime_test/js_runtime_test.cpp +++ b/test/unittest/runtime_test/js_runtime_test.cpp @@ -1509,7 +1509,9 @@ HWTEST_F(JsRuntimeTest, DumpHeapSnapshot_0200, TestSize.Level1) auto jsRuntime = std::make_unique(); uint32_t tid = 1; bool isFullGC = true; - jsRuntime->DumpHeapSnapshot(tid, isFullGC); + std::vector fdVec; + std::vector tidVec; + jsRuntime->DumpHeapSnapshot(tid, isFullGC, fdVec, tidVec); EXPECT_TRUE(jsRuntime != nullptr); } From 95adf2cef81d481b23e33826e1195f1f97de746d Mon Sep 17 00:00:00 2001 From: "zhubingwei@huawei.com" Date: Thu, 23 May 2024 14:50:45 +0800 Subject: [PATCH 170/174] =?UTF-8?q?TDD=E8=A6=86=E7=9B=96=E7=8E=87=E6=8F=90?= =?UTF-8?q?=E5=8D=87(js=5Fui=5Fextension=5FCallback.cpp)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhubingwei@huawei.com Change-Id: I14322c964b8ee45b4acaf9e34c16998ffd746a33 --- .../BUILD.gn | 42 +++ .../js_ui_extension_Callback_test.cpp | 251 ++++++++++++++++++ 2 files changed, 293 insertions(+) create mode 100644 test/unittest/frameworks_kits_ability_native_test/js_ui_extension_Callback_test.cpp diff --git a/test/unittest/frameworks_kits_ability_native_test/BUILD.gn b/test/unittest/frameworks_kits_ability_native_test/BUILD.gn index 1a75761d50..eed4afd853 100644 --- a/test/unittest/frameworks_kits_ability_native_test/BUILD.gn +++ b/test/unittest/frameworks_kits_ability_native_test/BUILD.gn @@ -2729,6 +2729,47 @@ ohos_unittest("app_module_checker_test") { ] } +ohos_unittest("js_ui_extension_Callback_test") { + module_out_path = module_output_path + include_dirs = [ + "${ability_runtime_test_path}/mock/frameworks_kits_ability_native_test/include", + "${ability_runtime_path}/interfaces/kits/native/ability/native", + "${ability_runtime_path}/js_environment/interfaces/inner_api", + "${ability_runtime_path}/js_environment/frameworks/utils/include", + "${windowmanager_path}/window_scene/interfaces/include", + ] + + sources = [ + "${ability_runtime_native_path}/ability/native/js_ui_extension_callback.cpp", + "js_ui_extension_Callback_test.cpp", + ] + + configs = [ ":module_private_config" ] + + deps = [ + "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/runtime:runtime", + "${ability_runtime_native_path}/ability/native:abilitykit_native", + "//third_party/googletest:gmock_main", + "//third_party/googletest:gtest_main", + ] + + external_deps = [ + "ability_base:base", + "ability_base:session_info", + "ability_base:want", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ace_engine:ace_uicontent", + "c_utils:utils", + "ffrt:libffrt", + "hilog:libhilog", + "input:libmmi-client", + "ipc:ipc_core", + "napi:ace_napi", + ] +} + ############################################################################### group("unittest") { @@ -2776,6 +2817,7 @@ group("unittest") { ":extension_test", ":fa_ability_thread_test", ":form_extension_test", + ":js_ui_extension_Callback_test", ":new_ability_impl_test", ":pac_map_test", ":reserse_continuation_scheduler_primary_proxy_test", diff --git a/test/unittest/frameworks_kits_ability_native_test/js_ui_extension_Callback_test.cpp b/test/unittest/frameworks_kits_ability_native_test/js_ui_extension_Callback_test.cpp new file mode 100644 index 0000000000..f6c312360c --- /dev/null +++ b/test/unittest/frameworks_kits_ability_native_test/js_ui_extension_Callback_test.cpp @@ -0,0 +1,251 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +#include "ability_handler.h" +#include "app_module_checker.h" +#include "context_deal.h" +#include "hilog_wrapper.h" +#include "js_environment.h" +#include "js_runtime.h" +#include "js_ui_extension_callback.h" +#include "locale_config.h" +#include "mock_ui_content.h" +#include "native_runtime_impl.h" +#include "ohos_application.h" +#include "process_options.h" +#include "session_info.h" + +namespace OHOS { +namespace AppExecFwk { +using namespace testing::ext; +using namespace OHOS; +using namespace OHOS::AbilityRuntime; +class JsUIExtensionCallbackTest : public testing::Test { +public: + JsUIExtensionCallbackTest() : jsUIExtensionCallback_(nullptr) {} + ~JsUIExtensionCallbackTest() {} + std::shared_ptr jsUIExtensionCallback_; + static void SetUpTestCase(void); + static void TearDownTestCase(void); + void SetUp(); + void TearDown(); +}; + +void JsUIExtensionCallbackTest::SetUpTestCase(void) {} + +void JsUIExtensionCallbackTest::TearDownTestCase(void) {} + +void JsUIExtensionCallbackTest::SetUp(void) {} + +void JsUIExtensionCallbackTest::TearDown(void) {} + +/* + * Feature: OnError_001 + * Function: OnError + */ +HWTEST_F(JsUIExtensionCallbackTest, OnError_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "OnError_001 start"; + jsUIExtensionCallback_ = std::make_shared(nullptr); + EXPECT_TRUE(jsUIExtensionCallback_ != nullptr); + jsUIExtensionCallback_->OnError(0); + GTEST_LOG_(INFO) << "OnError_001 end"; +} + +/* + * Feature: OnError_002 + * Function: OnError + */ +HWTEST_F(JsUIExtensionCallbackTest, OnError_002, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "OnError_002 start"; + OHOS::AbilityRuntime::Runtime::Options options; + std::shared_ptr jsEnv = nullptr; + auto err = NativeRuntimeImpl::GetNativeRuntimeImpl().CreateJsEnv(options, jsEnv); + EXPECT_EQ(err, napi_status::napi_ok); + + napi_env env = reinterpret_cast(jsEnv->GetNativeEngine()); + jsUIExtensionCallback_ = std::make_shared(env); + EXPECT_TRUE(jsUIExtensionCallback_ != nullptr); + jsUIExtensionCallback_->OnError(0); + err = NativeRuntimeImpl::GetNativeRuntimeImpl().RemoveJsEnv(reinterpret_cast(jsEnv->GetNativeEngine())); + EXPECT_EQ(err, napi_status::napi_ok); + GTEST_LOG_(INFO) << "OnError_002 end"; +} + +/* + * Feature: OnRelease_001 + * Function: OnRelease + */ +HWTEST_F(JsUIExtensionCallbackTest, OnRelease_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "OnRelease_001 start"; + jsUIExtensionCallback_ = std::make_shared(nullptr); + EXPECT_TRUE(jsUIExtensionCallback_ != nullptr); + jsUIExtensionCallback_->OnRelease(0); + GTEST_LOG_(INFO) << "OnRelease_001 end"; +} + +/* + * Feature: OnResult_001 + * Function: OnResult + */ +HWTEST_F(JsUIExtensionCallbackTest, OnResult_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "OnResult_001 start"; + jsUIExtensionCallback_ = std::make_shared(nullptr); + EXPECT_TRUE(jsUIExtensionCallback_ != nullptr); + AAFwk::Want want; + jsUIExtensionCallback_->OnResult(0, want); + GTEST_LOG_(INFO) << "OnResult_001 end"; +} + +/* + * Feature: OnResult_002 + * Function: OnResult + */ +HWTEST_F(JsUIExtensionCallbackTest, OnResult_002, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "OnResult_002 start"; + OHOS::AbilityRuntime::Runtime::Options options; + std::shared_ptr jsEnv = nullptr; + auto err = NativeRuntimeImpl::GetNativeRuntimeImpl().CreateJsEnv(options, jsEnv); + EXPECT_EQ(err, napi_status::napi_ok); + + napi_env env = reinterpret_cast(jsEnv->GetNativeEngine()); + jsUIExtensionCallback_ = std::make_shared(env); + EXPECT_TRUE(jsUIExtensionCallback_ != nullptr); + AAFwk::Want want; + jsUIExtensionCallback_->OnResult(0, want); + err = NativeRuntimeImpl::GetNativeRuntimeImpl().RemoveJsEnv(reinterpret_cast(jsEnv->GetNativeEngine())); + EXPECT_EQ(err, napi_status::napi_ok); + GTEST_LOG_(INFO) << "OnResult_002 end"; +} + +/* + * Feature: CallJsResult_001 + * Function: CallJsResult + */ +HWTEST_F(JsUIExtensionCallbackTest, CallJsResult_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "CallJsResult_001 start"; + jsUIExtensionCallback_ = std::make_shared(nullptr); + EXPECT_TRUE(jsUIExtensionCallback_ != nullptr); + AAFwk::Want want; + jsUIExtensionCallback_->CallJsResult(0, want); + GTEST_LOG_(INFO) << "CallJsResult_001 end"; +} + +/* + * Feature: CallJsResult_002 + * Function: CallJsResult + */ +HWTEST_F(JsUIExtensionCallbackTest, CallJsResult_002, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "CallJsResult_002 start"; + OHOS::AbilityRuntime::Runtime::Options options; + std::shared_ptr jsEnv = nullptr; + auto err = NativeRuntimeImpl::GetNativeRuntimeImpl().CreateJsEnv(options, jsEnv); + EXPECT_EQ(err, napi_status::napi_ok); + + napi_env env = reinterpret_cast(jsEnv->GetNativeEngine()); + jsUIExtensionCallback_ = std::make_shared(env); + EXPECT_TRUE(jsUIExtensionCallback_ != nullptr); + AAFwk::Want want; + jsUIExtensionCallback_->CallJsResult(0, want); + err = NativeRuntimeImpl::GetNativeRuntimeImpl().RemoveJsEnv(reinterpret_cast(jsEnv->GetNativeEngine())); + EXPECT_EQ(err, napi_status::napi_ok); + GTEST_LOG_(INFO) << "CallJsResult_002 end"; +} + +/* + * Feature: SetJsCallbackObject_001 + * Function: SetJsCallbackObject + */ +HWTEST_F(JsUIExtensionCallbackTest, SetJsCallbackObject_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "SetJsCallbackObject_001 start"; + jsUIExtensionCallback_ = std::make_shared(nullptr); + EXPECT_TRUE(jsUIExtensionCallback_ != nullptr); + napi_value args[0] = {}; + jsUIExtensionCallback_->SetJsCallbackObject(args[0]); + GTEST_LOG_(INFO) << "SetJsCallbackObject_001 end"; +} + +/* + * Feature: CallJsError_001 + * Function: CallJsError + */ +HWTEST_F(JsUIExtensionCallbackTest, CallJsError_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "CallJsError_001 start"; + jsUIExtensionCallback_ = std::make_shared(nullptr); + EXPECT_TRUE(jsUIExtensionCallback_ != nullptr); + jsUIExtensionCallback_->CallJsError(0); + GTEST_LOG_(INFO) << "CallJsError_001 end"; +} + +/* + * Feature: CallJsError_002 + * Function: CallJsError + */ +HWTEST_F(JsUIExtensionCallbackTest, CallJsError_002, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "CallJsError_002 start"; + OHOS::AbilityRuntime::Runtime::Options options; + std::shared_ptr jsEnv = nullptr; + auto err = NativeRuntimeImpl::GetNativeRuntimeImpl().CreateJsEnv(options, jsEnv); + EXPECT_EQ(err, napi_status::napi_ok); + + napi_env env = reinterpret_cast(jsEnv->GetNativeEngine()); + jsUIExtensionCallback_ = std::make_shared(env); + EXPECT_TRUE(jsUIExtensionCallback_ != nullptr); + jsUIExtensionCallback_->CallJsError(0); + err = NativeRuntimeImpl::GetNativeRuntimeImpl().RemoveJsEnv(reinterpret_cast(jsEnv->GetNativeEngine())); + EXPECT_EQ(err, napi_status::napi_ok); + GTEST_LOG_(INFO) << "CallJsError_002 end"; +} + +/* + * Feature: SetSessionId_001 + * Function: SetSessionId + */ +HWTEST_F(JsUIExtensionCallbackTest, SetSessionId_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "SetSessionId_001 start"; + jsUIExtensionCallback_ = std::make_shared(nullptr); + EXPECT_TRUE(jsUIExtensionCallback_ != nullptr); + jsUIExtensionCallback_->SetSessionId(0); + GTEST_LOG_(INFO) << "SetSessionId_001 end"; +} + +/* + * Feature: SetUIContent_001 + * Function: SetUIContent + */ +HWTEST_F(JsUIExtensionCallbackTest, SetUIContent_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "SetUIContent_001 start"; + jsUIExtensionCallback_ = std::make_shared(nullptr); + EXPECT_TRUE(jsUIExtensionCallback_ != nullptr); + Ace::UIContent* uiContent = nullptr; + jsUIExtensionCallback_->SetUIContent(uiContent); + GTEST_LOG_(INFO) << "SetUIContent_001 end"; +} +} // namespace AppExecFwk +} // namespace OHOS From b671b65a1fde9a5ac280da5272be6809915a8c74 Mon Sep 17 00:00:00 2001 From: zhuhan Date: Thu, 23 May 2024 09:47:21 +0800 Subject: [PATCH 171/174] dark res Signed-off-by: zhuhan Change-Id: I4a4f3458aff1d247432236aa3bab7c455ff6375c --- frameworks/native/ability/native/configuration_utils.cpp | 6 ++++++ frameworks/native/ability/native/ui_ability.cpp | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/frameworks/native/ability/native/configuration_utils.cpp b/frameworks/native/ability/native/configuration_utils.cpp index ec2ecbe14f..61e25c6a25 100644 --- a/frameworks/native/ability/native/configuration_utils.cpp +++ b/frameworks/native/ability/native/configuration_utils.cpp @@ -41,6 +41,7 @@ void ConfigurationUtils::UpdateGlobalConfig(const Configuration &configuration, std::string colormode; std::string hasPointerDevice; GetGlobalConfig(configuration, language, colormode, hasPointerDevice); + std::string colorModeIsSetByApp = configuration.GetItem(AAFwk::GlobalConfigurationKey::COLORMODE_IS_SET_BY_APP); std::unique_ptr resConfig(Global::Resource::CreateResConfig()); if (resConfig == nullptr) { TAG_LOGE(AAFwkTag::ABILITY, "Create resource config failed."); @@ -75,6 +76,11 @@ void ConfigurationUtils::UpdateGlobalConfig(const Configuration &configuration, TAG_LOGD(AAFwkTag::ABILITY, "Update config, hasPointerDevice: %{public}d", resConfig->GetInputDevice()); } + if (!colorModeIsSetByApp.empty()) { + TAG_LOGD(AAFwkTag::ABILITY, "set app true"); + resConfig->SetAppColorMode(true); + } + HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, "resourceManager->UpdateResConfig"); Global::Resource::RState ret = resourceManager->UpdateResConfig(*resConfig); if (ret != Global::Resource::RState::SUCCESS) { diff --git a/frameworks/native/ability/native/ui_ability.cpp b/frameworks/native/ability/native/ui_ability.cpp index 295c4ea36b..d33ce9c539 100644 --- a/frameworks/native/ability/native/ui_ability.cpp +++ b/frameworks/native/ability/native/ui_ability.cpp @@ -295,6 +295,7 @@ void UIAbility::OnConfigurationUpdatedNotify(const AppExecFwk::Configuration &co std::string colormode; std::string hasPointerDevice; InitConfigurationProperties(configuration, language, colormode, hasPointerDevice); + std::string colorModeIsSetByApp = configuration.GetItem(AAFwk::GlobalConfigurationKey::COLORMODE_IS_SET_BY_APP); // Notify ResourceManager std::unique_ptr resConfig(Global::Resource::CreateResConfig()); if (resConfig == nullptr) { @@ -320,6 +321,10 @@ void UIAbility::OnConfigurationUpdatedNotify(const AppExecFwk::Configuration &co if (!hasPointerDevice.empty()) { resConfig->SetInputDevice(AppExecFwk::ConvertHasPointerDevice(hasPointerDevice)); } + if (!colorModeIsSetByApp.empty()) { + TAG_LOGD(AAFwkTag::UIABILITY, "set app true"); + resConfig->SetAppColorMode(true); + } resourceManager->UpdateResConfig(*resConfig); TAG_LOGD(AAFwkTag::UIABILITY, "Current colorMode: %{public}d, hasPointerDevice: %{public}d.", resConfig->GetColorMode(), resConfig->GetInputDevice()); From 297147b550a3af66b0ded7c75d2f14c09362c973 Mon Sep 17 00:00:00 2001 From: gongyuechen Date: Thu, 23 May 2024 17:16:56 +0800 Subject: [PATCH 172/174] add timeout for app lifecycle Signed-off-by: gongyuechen --- services/abilitymgr/include/ability_record.h | 6 +++++ services/abilitymgr/src/ability_record.cpp | 26 +++++++++++++------ .../include/app_mgr_service_event_handler.h | 2 ++ services/appmgr/src/app_mgr_service.cpp | 1 + services/appmgr/src/app_running_record.cpp | 13 ++++++++++ 5 files changed, 40 insertions(+), 8 deletions(-) diff --git a/services/abilitymgr/include/ability_record.h b/services/abilitymgr/include/ability_record.h index c017f6202f..af71fc858a 100644 --- a/services/abilitymgr/include/ability_record.h +++ b/services/abilitymgr/include/ability_record.h @@ -358,6 +358,12 @@ public: */ void ProcessForegroundAbility(uint32_t tokenId, uint32_t sceneFlag = 0); + /** + * post foreground timeout task for ui ability. + * + */ + void PostForegroundTimeoutTask(); + /** * move the ability to back ground. * diff --git a/services/abilitymgr/src/ability_record.cpp b/services/abilitymgr/src/ability_record.cpp index cb044ad535..ac17b1659b 100644 --- a/services/abilitymgr/src/ability_record.cpp +++ b/services/abilitymgr/src/ability_record.cpp @@ -432,14 +432,6 @@ void AbilityRecord::ForegroundAbility(uint32_t sceneFlag) TAG_LOGI(AAFwkTag::ABILITYMGR, "ForegroundLifecycle: name:%{public}s.", abilityInfo_.name.c_str()); CHECK_POINTER(lifecycleDeal_); - if (!IsDebug()) { - int foregroundTimeout = - AmsConfigurationParameter::GetInstance().GetAppStartTimeoutTime() * FOREGROUND_TIMEOUT_MULTIPLE; - SendEvent(AbilityManagerService::FOREGROUND_TIMEOUT_MSG, foregroundTimeout / HALF_TIMEOUT); - std::string methodName = "ForegroundAbility"; - g_addLifecycleEventTask(token_, FreezeUtil::TimeoutState::FOREGROUND, methodName); - } - // schedule active after updating AbilityState and sending timeout message to avoid ability async callback // earlier than above actions SetAbilityStateInner(AbilityState::FOREGROUNDING); @@ -519,6 +511,9 @@ void AbilityRecord::ProcessForegroundAbility(uint32_t tokenId, uint32_t sceneFla } if (isReady_) { + if (!IsDebug()) { + PostForegroundTimeoutTask(); + } if (IsAbilityState(AbilityState::FOREGROUND)) { TAG_LOGD(AAFwkTag::ABILITYMGR, "Activate %{public}s", element.c_str()); ForegroundAbility(sceneFlag); @@ -541,6 +536,15 @@ void AbilityRecord::ProcessForegroundAbility(uint32_t tokenId, uint32_t sceneFla } } +void AbilityRecord::PostForegroundTimeoutTask() +{ + int foregroundTimeout = + AmsConfigurationParameter::GetInstance().GetAppStartTimeoutTime() * FOREGROUND_TIMEOUT_MULTIPLE; + SendEvent(AbilityManagerService::FOREGROUND_TIMEOUT_MSG, foregroundTimeout / HALF_TIMEOUT); + std::string methodName = "ForegroundAbility"; + g_addLifecycleEventTask(token_, FreezeUtil::TimeoutState::FOREGROUND, methodName); +} + std::string AbilityRecord::GetLabel() { HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__); @@ -581,6 +585,9 @@ void AbilityRecord::ProcessForegroundAbility(const std::shared_ptrCancelTask("appbackground_" + std::to_string(recordId)); std::function applicationBackgroundedFunc = std::bind(&AppMgrServiceInner::ApplicationBackgrounded, appMgrServiceInner_, recordId); taskHandler_->SubmitTask(applicationBackgroundedFunc, AAFwk::TaskAttribute{ diff --git a/services/appmgr/src/app_running_record.cpp b/services/appmgr/src/app_running_record.cpp index 01d7271f2d..9e48c6bb10 100644 --- a/services/appmgr/src/app_running_record.cpp +++ b/services/appmgr/src/app_running_record.cpp @@ -625,6 +625,19 @@ void AppRunningRecord::ScheduleForegroundRunning() void AppRunningRecord::ScheduleBackgroundRunning() { + int32_t recordId = GetRecordId(); + auto serviceInner = appMgrServiceInner_; + auto appbackgroundtask = [recordId, serviceInner]() { + auto serviceInnerObj = serviceInner.lock(); + if (serviceInnerObj == nullptr) { + TAG_LOGW(AAFwkTag::APPMGR, "APPManager is invalid"); + return; + } + TAG_LOGE(AAFwkTag::APPMGR, "APPManager move to background timeout"); + serviceInnerObj->ApplicationBackgrounded(recordId); + }; + PostTask("appbackground_" + std::to_string(recordId), AMSEventHandler::BACKGROUND_APPLICATION_TIMEOUT, + appbackgroundtask); if (appLifeCycleDeal_) { appLifeCycleDeal_->ScheduleBackgroundRunning(); } From cb3671ff4ea6676a2c2767999c29dc608b87046d Mon Sep 17 00:00:00 2001 From: jsjzju Date: Thu, 23 May 2024 10:50:20 +0800 Subject: [PATCH 173/174] =?UTF-8?q?=E7=A6=81=E6=AD=A2=E4=B8=8A=E4=B8=80?= =?UTF-8?q?=E4=B8=AAautofill=E8=AF=B7=E6=B1=82=E6=9C=AA=E7=BB=93=E6=9D=9F?= =?UTF-8?q?=E5=89=8D=E9=87=8D=E5=A4=8D=E8=AF=B7=E6=B1=82autofill?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: jsjzju Change-Id: I04052e54cb659ea609ff5a2a31d674408557f460 --- .../include/auto_fill_error.h | 3 ++- .../include/auto_fill_extension_callback.h | 1 + .../include/auto_fill_manager.h | 1 + .../src/auto_fill_extension_callback.cpp | 5 +++++ .../src/auto_fill_manager.cpp | 19 +++++++++++++++++++ 5 files changed, 28 insertions(+), 1 deletion(-) diff --git a/interfaces/inner_api/auto_fill_manager/include/auto_fill_error.h b/interfaces/inner_api/auto_fill_manager/include/auto_fill_error.h index 7cc4d9a31b..f1fee33281 100644 --- a/interfaces/inner_api/auto_fill_manager/include/auto_fill_error.h +++ b/interfaces/inner_api/auto_fill_manager/include/auto_fill_error.h @@ -29,7 +29,8 @@ enum { AUTO_FILL_OBJECT_IS_NULL, AUTO_FILL_CREATE_MODULE_UI_EXTENSION_FAILED, AUTO_FILL_REQUEST_TIME_OUT, - AUTO_FILL_TYPE_INVALID + AUTO_FILL_TYPE_INVALID, + AUTO_FILL_PREVIOUS_REQUEST_NOT_FINISHED }; } // namespace AutoFill } // namespace AbilityRuntime diff --git a/interfaces/inner_api/auto_fill_manager/include/auto_fill_extension_callback.h b/interfaces/inner_api/auto_fill_manager/include/auto_fill_extension_callback.h index b6c9f7ea97..3c849a601a 100644 --- a/interfaces/inner_api/auto_fill_manager/include/auto_fill_extension_callback.h +++ b/interfaces/inner_api/auto_fill_manager/include/auto_fill_extension_callback.h @@ -47,6 +47,7 @@ public: void SetSessionId(int32_t sessionId); void SetUIContent(Ace::UIContent *uiContent); + Ace::UIContent *GetUIContent(); void SetEventId(uint32_t eventId); void SetWindowType(const AutoFill::AutoFillWindowType &autoFillWindowType); void SetExtensionType(bool isSmartAutoFill); diff --git a/interfaces/inner_api/auto_fill_manager/include/auto_fill_manager.h b/interfaces/inner_api/auto_fill_manager/include/auto_fill_manager.h index 7547a53759..134bf2089d 100644 --- a/interfaces/inner_api/auto_fill_manager/include/auto_fill_manager.h +++ b/interfaces/inner_api/auto_fill_manager/include/auto_fill_manager.h @@ -106,6 +106,7 @@ private: void SetTimeOutEvent(uint32_t eventId); AutoFill::AutoFillWindowType ConvertAutoFillWindowType(const AutoFill::AutoFillRequest &request, bool &isSmartAutoFill); + bool IsPreviousRequestFinished(Ace::UIContent *uiContent); std::mutex extensionCallbacksMutex_; std::mutex modalProxyMapMutex_; diff --git a/interfaces/inner_api/auto_fill_manager/src/auto_fill_extension_callback.cpp b/interfaces/inner_api/auto_fill_manager/src/auto_fill_extension_callback.cpp index b2b8820b40..eedcc1a0db 100644 --- a/interfaces/inner_api/auto_fill_manager/src/auto_fill_extension_callback.cpp +++ b/interfaces/inner_api/auto_fill_manager/src/auto_fill_extension_callback.cpp @@ -198,6 +198,11 @@ void AutoFillExtensionCallback::SetUIContent(Ace::UIContent *uiContent) uiContent_ = uiContent; } +Ace::UIContent *AutoFillExtensionCallback::GetUIContent() +{ + return uiContent_; +} + void AutoFillExtensionCallback::SetEventId(uint32_t eventId) { eventId_ = eventId; diff --git a/interfaces/inner_api/auto_fill_manager/src/auto_fill_manager.cpp b/interfaces/inner_api/auto_fill_manager/src/auto_fill_manager.cpp index e3be0d5374..0d9f9100f7 100644 --- a/interfaces/inner_api/auto_fill_manager/src/auto_fill_manager.cpp +++ b/interfaces/inner_api/auto_fill_manager/src/auto_fill_manager.cpp @@ -96,6 +96,10 @@ int32_t AutoFillManager::HandleRequestExecuteInner( TAG_LOGE(AAFwkTag::AUTOFILLMGR, "UIContent or fillCallback&saveCallback is nullptr."); return AutoFill::AUTO_FILL_OBJECT_IS_NULL; } + if (!IsPreviousRequestFinished(uiContent)) { + TAG_LOGE(AAFwkTag::AUTOFILLMGR, "Previous request is not finished."); + return AutoFill::AUTO_FILL_PREVIOUS_REQUEST_NOT_FINISHED; + } { std::lock_guard lock(extensionCallbacksMutex_); SetTimeOutEvent(++eventId_); @@ -371,5 +375,20 @@ void AutoFillManager::HandleTimeOut(uint32_t eventId) extensionCallback->HandleTimeOut(); extensionCallbacks_.erase(ret); } + +bool AutoFillManager::IsPreviousRequestFinished(Ace::UIContent *uiContent) +{ + std::lock_guard lock(extensionCallbacksMutex_); + for (auto& item: extensionCallbacks_) { + auto extensionCallback = item.second.lock(); + if (extensionCallback == nullptr) { + continue; + } + if (extensionCallback->GetUIContent() == uiContent) { + return false; + } + } + return true; +} } // namespace AbilityRuntime } // namespace OHOS From 3225046285dfe1177b094c535a02a7c5f9dcb828 Mon Sep 17 00:00:00 2001 From: hhl Date: Wed, 22 May 2024 20:17:50 +0800 Subject: [PATCH 174/174] Resolve multithreading conflicts Signed-off-by: hhl --- .../native/appkit/dfr/appfreeze_inner.cpp | 1 + services/appdfr/include/appfreeze_manager.h | 19 ++++ services/appdfr/src/appfreeze_manager.cpp | 98 +++++++++++++++++++ services/appmgr/src/app_mgr_service_inner.cpp | 7 +- .../dfr_test/appfreeze_inner_test/BUILD.gn | 1 + .../appfreeze_inner_test.cpp | 23 +++++ 6 files changed, 148 insertions(+), 1 deletion(-) diff --git a/frameworks/native/appkit/dfr/appfreeze_inner.cpp b/frameworks/native/appkit/dfr/appfreeze_inner.cpp index 96f50b67bc..743ad2b067 100644 --- a/frameworks/native/appkit/dfr/appfreeze_inner.cpp +++ b/frameworks/native/appkit/dfr/appfreeze_inner.cpp @@ -18,6 +18,7 @@ #include "ability_manager_client.h" #include "ability_state.h" +#include "appfreeze_manager.h" #include "app_recovery.h" #include "exit_reason.h" #include "ffrt.h" diff --git a/services/appdfr/include/appfreeze_manager.h b/services/appdfr/include/appfreeze_manager.h index 111b206363..bef4d74219 100644 --- a/services/appdfr/include/appfreeze_manager.h +++ b/services/appdfr/include/appfreeze_manager.h @@ -47,6 +47,17 @@ public: CRITICAL_TIMEOUT = 1, }; + enum AppFreezeState { + APPFREEZE_STATE_IDLE = 0, + APPFREEZE_STATE_FREEZE = 1, + }; + + struct AppFreezeInfo { + int32_t pid = 0; + int state = 0; + int64_t occurTime = 0; + }; + struct ParamInfo { int typeId = TypeAttribute::NORMAL_TIMEOUT; int32_t pid = 0; @@ -66,6 +77,7 @@ public: std::string WriteToFile(const std::string& fileName, std::string& content); bool IsHandleAppfreeze(const std::string& bundleName); bool IsProcessDebug(int32_t pid, std::string processName); + bool IsNeedIgnoreFreezeEvent(int32_t pid); private: AppfreezeManager& operator=(const AppfreezeManager&) = delete; @@ -78,11 +90,18 @@ private: std::string CatcherStacktrace(int pid) const; int AcquireStack(const FaultData& faultData, const AppInfo& appInfo); int NotifyANR(const FaultData& faultData, const AppfreezeManager::AppInfo& appInfo, const std::string& binderInfo); + int64_t GetFreezeCurrentTime(); + void SetFreezeState(int32_t pid, int state); + int GetFreezeState(int32_t pid); + int64_t GetFreezeTime(int32_t pid); + void ClearOldInfo(); static const inline std::string LOGGER_DEBUG_PROC_PATH = "/proc/transaction_proc"; std::string name_; static ffrt::mutex singletonMutex_; static std::shared_ptr instance_; + static ffrt::mutex freezeMutex_; + std::map appfreezeInfo_; }; } // namespace AppExecFwk } // namespace OHOS diff --git a/services/appdfr/src/appfreeze_manager.cpp b/services/appdfr/src/appfreeze_manager.cpp index 20436499e6..e54611ac35 100644 --- a/services/appdfr/src/appfreeze_manager.cpp +++ b/services/appdfr/src/appfreeze_manager.cpp @@ -47,10 +47,15 @@ constexpr char EVENT_STACK[] = "STACK"; constexpr char BINDER_INFO[] = "BINDER_INFO"; constexpr char APP_RUNNING_UNIQUE_ID[] = "APP_RUNNING_UNIQUE_ID"; constexpr int MAX_LAYER = 8; +constexpr int FREEZEMAP_SIZE_MAX = 20; +constexpr int FREEZE_TIME_LIMIT = 60000; +static constexpr int64_t NANOSECONDS = 1000000000; // NANOSECONDS mean 10^9 nano second +static constexpr int64_t MICROSECONDS = 1000000; // MICROSECONDS mean 10^6 millias second const std::string LOG_FILE_PATH = "data/log/eventlog"; } std::shared_ptr AppfreezeManager::instance_ = nullptr; ffrt::mutex AppfreezeManager::singletonMutex_; +ffrt::mutex AppfreezeManager::freezeMutex_; AppfreezeManager::AppfreezeManager() { @@ -128,6 +133,14 @@ int AppfreezeManager::AppfreezeHandleWithStack(const FaultData& faultData, const HITRACE_METER_FMT(HITRACE_TAG_APP, "AppfreezeHandleWithStack pid:%d-name:%s", appInfo.pid, faultData.errorObject.name.c_str()); + if (faultData.errorObject.name == AppFreezeType::LIFECYCLE_HALF_TIMEOUT + || faultData.errorObject.name == AppFreezeType::APP_INPUT_BLOCK + || faultData.errorObject.name == AppFreezeType::THREAD_BLOCK_6S) { + if (AppExecFwk::AppfreezeManager::GetInstance()->IsNeedIgnoreFreezeEvent(appInfo.pid)) { + TAG_LOGE(AAFwkTag::APPDFR, "AppFreeze already happend in a short period of time."); + return 0; + } + } std::string fileName = faultData.errorObject.name + "_" + std::to_string(appInfo.pid) + "_stack"; std::string catcherStack = ""; @@ -419,5 +432,90 @@ bool AppfreezeManager::IsProcessDebug(int32_t pid, std::string processName) } return false; } + +int64_t AppfreezeManager::GetFreezeCurrentTime() +{ + struct timespec t; + t.tv_sec = 0; + t.tv_nsec = 0; + clock_gettime(CLOCK_MONOTONIC, &t); + return static_cast(((t.tv_sec) * NANOSECONDS + t.tv_nsec) / MICROSECONDS); +} + +void AppfreezeManager::SetFreezeState(int32_t pid, int state) +{ + std::lock_guard lock(freezeMutex_); + if (appfreezeInfo_.find(pid) != appfreezeInfo_.end()) { + appfreezeInfo_[pid].state = state; + appfreezeInfo_[pid].occurTime = GetFreezeCurrentTime(); + } else { + AppFreezeInfo info; + info.pid = pid; + info.state = state; + info.occurTime = GetFreezeCurrentTime(); + appfreezeInfo_.emplace(pid, info); + } +} + +int AppfreezeManager::GetFreezeState(int32_t pid) +{ + std::lock_guard lock(freezeMutex_); + auto it = appfreezeInfo_.find(pid); + if (it != appfreezeInfo_.end()) { + return it->second.state; + } + return AppFreezeState::APPFREEZE_STATE_IDLE; +} + +int64_t AppfreezeManager::GetFreezeTime(int32_t pid) +{ + std::lock_guard lock(freezeMutex_); + auto it = appfreezeInfo_.find(pid); + if (it != appfreezeInfo_.end()) { + return it->second.occurTime; + } + return 0; +} + +void AppfreezeManager::ClearOldInfo() +{ + std::lock_guard lock(freezeMutex_); + int64_t currentTime = GetFreezeCurrentTime(); + for (auto it = appfreezeInfo_.begin(); it != appfreezeInfo_.end();) { + auto diff = currentTime - it->second.occurTime; + if (diff > FREEZE_TIME_LIMIT) { + it = appfreezeInfo_.erase(it); + } else { + ++it; + } + } +} + +bool AppfreezeManager::IsNeedIgnoreFreezeEvent(int32_t pid) +{ + if (appfreezeInfo_.size() >= FREEZEMAP_SIZE_MAX) { + ClearOldInfo(); + } + int state = GetFreezeState(pid); + int64_t currentTime = GetFreezeCurrentTime(); + int64_t lastTime = GetFreezeTime(pid); + auto diff = currentTime - lastTime; + if (state == AppFreezeState::APPFREEZE_STATE_FREEZE) { + if (diff >= FREEZE_TIME_LIMIT) { + TAG_LOGI(AAFwkTag::APPDFR, "IsNeedIgnoreFreezeEvent durationTime: " + "%{public}" PRId64 "state: %{public}d", diff, state); + return false; + } + return true; + } else { + if (diff < FREEZE_TIME_LIMIT) { + return true; + } + SetFreezeState(pid, AppFreezeState::APPFREEZE_STATE_FREEZE); + TAG_LOGI(AAFwkTag::APPDFR, "IsNeedIgnoreFreezeEvent durationTime: " + "%{public}" PRId64 " SetFreezeState: %{public}d", diff, state); + return false; + } +} } // namespace AAFwk } // namespace OHOS \ No newline at end of file diff --git a/services/appmgr/src/app_mgr_service_inner.cpp b/services/appmgr/src/app_mgr_service_inner.cpp index 4651932930..499d8f9b90 100644 --- a/services/appmgr/src/app_mgr_service_inner.cpp +++ b/services/appmgr/src/app_mgr_service_inner.cpp @@ -5024,6 +5024,11 @@ int32_t AppMgrServiceInner::NotifyAppFault(const FaultData &faultData) TAG_LOGE(AAFwkTag::APPMGR, "no such appRecord"); return ERR_INVALID_VALUE; } + if (appRecord->GetState() == ApplicationState::APP_STATE_TERMINATED || + appRecord->GetState() == ApplicationState::APP_STATE_END) { + TAG_LOGE(AAFwkTag::APPMGR, "Appfreeze detect end."); + return ERR_OK; + } std::string bundleName = appRecord->GetBundleName(); if (faultData.faultType == FaultDataType::APP_FREEZE) { @@ -5158,7 +5163,7 @@ int32_t AppMgrServiceInner::NotifyAppFaultBySA(const AppFaultDataBySA &faultData transformedFaultData.timeoutMarkers = "notifyFault:" + transformedFaultData.errorObject.name + std::to_string(pid) + "-" + std::to_string(SystemTimeMillisecond()); } - const int64_t timeout = 11000; + const int64_t timeout = 1000; if (faultData.faultType == FaultDataType::APP_FREEZE) { if (!AppExecFwk::AppfreezeManager::GetInstance()->IsHandleAppfreeze(bundleName) || record->IsDebugging()) { return ERR_OK; diff --git a/test/unittest/dfr_test/appfreeze_inner_test/BUILD.gn b/test/unittest/dfr_test/appfreeze_inner_test/BUILD.gn index 8320cc1134..f9cc437dd8 100644 --- a/test/unittest/dfr_test/appfreeze_inner_test/BUILD.gn +++ b/test/unittest/dfr_test/appfreeze_inner_test/BUILD.gn @@ -102,6 +102,7 @@ ohos_unittest("appfreeze_inner_test") { "hisysevent:libhisysevent", "hitrace:hitrace_meter", "init:libbegetutil", + "input:libmmi-client", "ipc:ipc_core", "napi:ace_napi", "resource_management:global_resmgr", diff --git a/test/unittest/dfr_test/appfreeze_inner_test/appfreeze_inner_test.cpp b/test/unittest/dfr_test/appfreeze_inner_test/appfreeze_inner_test.cpp index 6e60e627fa..0eae9e539c 100644 --- a/test/unittest/dfr_test/appfreeze_inner_test/appfreeze_inner_test.cpp +++ b/test/unittest/dfr_test/appfreeze_inner_test/appfreeze_inner_test.cpp @@ -17,6 +17,7 @@ #define private public #include "appfreeze_inner.h" +#include "application_anr_listener.h" #undef private using namespace testing; @@ -115,6 +116,28 @@ HWTEST_F(AppfreezeInnerTest, AppfreezeInner__ThreadBlock_002, TestSize.Level1) GTEST_LOG_(INFO) << "AppfreezeInner__ThreadBlock_002 end"; } +/** + * @tc.number: AppfreezeInner_IsNeedIgnoreFreezeEvent_001 + * @tc.name: IsNeedIgnoreFreezeEvent + * @tc.desc: Verify that function IsNeedIgnoreFreezeEvent. + */ +HWTEST_F(AppfreezeInnerTest, AppfreezeInner_IsNeedIgnoreFreezeEvent_001, TestSize.Level1) +{ + std::atomic_bool isSixSecondEvent = true; + appfreezeInner->isAppDebug_ = false; + appfreezeInner->ThreadBlock(isSixSecondEvent); + EXPECT_TRUE(isSixSecondEvent); + int32_t pid = static_cast(getprocpid()); + std::shared_ptr listener = + std::make_shared(); + listener->OnAnr(pid); + int left = 61; // over 1min + while (left > 0) { + left = sleep(left); + } + listener->OnAnr(pid); +} + /** * @tc.number: AppfreezeInner__AppfreezeHandle_001 * @tc.name: AppfreezeHandle