Merge remote-tracking branch 'ohos/master' into m

This commit is contained in:
jiangzhijun8
2024-06-04 16:08:31 +08:00
53 changed files with 780 additions and 430 deletions
@@ -157,7 +157,7 @@ private:
}
if (!AppExecFwk::IsTypeForNapiValue(env, argv[INDEX_ONE], napi_object)) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "Invalid param.");
ThrowInvalidParamError(env, "Parse param observer failed, must be a AbilityForegroundStateObserver");
ThrowInvalidParamError(env, "Parse param observer failed, must be a AbilityForegroundStateObserver.");
return CreateJsUndefined(env);
}
@@ -165,7 +165,7 @@ private:
if (type == ON_OFF_TYPE_ABILITY_FOREGROUND_STATE) {
return OnOnAbilityForeground(env, argc, argv);
}
ThrowInvalidParamError(env, "Parse param type failed, must be a string, value must be abilityForegroundState");
ThrowInvalidParamError(env, "Parse param type failed, must be a string, value must be abilityForegroundState.");
return CreateJsUndefined(env);
}
@@ -203,7 +203,7 @@ private:
}
if (argc == ARGC_TWO && !AppExecFwk::IsTypeForNapiValue(env, argv[INDEX_ONE], napi_object)) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "Invalid param.");
ThrowInvalidParamError(env, "Parse param observer failed, must be a AbilityForegroundStateObserver");
ThrowInvalidParamError(env, "Parse param observer failed, must be a AbilityForegroundStateObserver.");
return CreateJsUndefined(env);
}
@@ -211,7 +211,7 @@ private:
if (type == ON_OFF_TYPE_ABILITY_FOREGROUND_STATE) {
return OnOffAbilityForeground(env, argc, argv);
}
ThrowInvalidParamError(env, "Parse param type failed, must be a string, value must be abilityForegroundState");
ThrowInvalidParamError(env, "Parse param type failed, must be a string, value must be abilityForegroundState.");
return CreateJsUndefined(env);
}
@@ -243,19 +243,19 @@ private:
std::string assertSessionStr;
if (!ConvertFromJsValue(env, argv[INDEX_ZERO], assertSessionStr) || !CheckIsNumString(assertSessionStr)) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "Convert session id error.");
ThrowInvalidParamError(env, "Parse param sessionId failed, must be a string");
ThrowInvalidParamError(env, "Parse param sessionId failed, must be a string.");
return CreateJsUndefined(env);
}
uint64_t assertSessionId = std::stoull(assertSessionStr);
if (assertSessionId == 0) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "Convert session id failed.");
ThrowInvalidParamError(env, "Parse param sessionId failed, value must not be equal to zero");
ThrowInvalidParamError(env, "Parse param sessionId failed, value must not be equal to zero.");
return CreateJsUndefined(env);
}
int32_t userStatus;
if (!ConvertFromJsValue(env, argv[INDEX_ONE], userStatus)) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "Convert status failed.");
ThrowInvalidParamError(env, "Parse param status failed, must be a UserStatus");
ThrowInvalidParamError(env, "Parse param status failed, must be a UserStatus.");
return CreateJsUndefined(env);
}
@@ -346,7 +346,7 @@ private:
int upperLimit = -1;
if (!ConvertFromJsValue(env, info.argv[0], upperLimit)) {
#ifdef ENABLE_ERRCODE
ThrowInvalidParamError(env, "Parse param upperLimit failed, must be a number");
ThrowInvalidParamError(env, "Parse param upperLimit failed, must be a number.");
#endif
return CreateJsUndefined(env);
}
@@ -397,7 +397,7 @@ private:
AppExecFwk::Configuration changeConfig;
if (!UnwrapConfiguration(env, info.argv[0], changeConfig)) {
#ifdef ENABLE_ERRCODE
ThrowInvalidParamError(env, "Parse param config failed, must be a Configuration");
ThrowInvalidParamError(env, "Parse param config failed, must be a Configuration.");
#else
complete = [](napi_env env, NapiAsyncTask& task, int32_t status) {
task.Reject(env, CreateJsError(env, ERR_INVALID_VALUE, "config is invalid."));
@@ -467,7 +467,7 @@ private:
}
int32_t missionId = -1;
if (!ConvertFromJsValue(env, info.argv[INDEX_ZERO], missionId)) {
ThrowInvalidParamError(env, "Parse param missionId failed, must be a number");
ThrowInvalidParamError(env, "Parse param missionId failed, must be a number.");
return CreateJsUndefined(env);
}
napi_value lastParam = info.argc > ARGC_ONE ? info.argv[INDEX_ONE] : nullptr;
@@ -515,7 +515,7 @@ private:
int reqCode = 0;
if (!ConvertFromJsValue(env, info.argv[1], reqCode)) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "Get requestCode param error");
ThrowInvalidParamError(env, "Parse param requestCode failed, must be a number");
ThrowInvalidParamError(env, "Parse param requestCode failed, must be a number.");
break;
}
@@ -523,7 +523,7 @@ private:
int resultCode = ERR_OK;
if (!AppExecFwk::UnWrapAbilityResult(env, info.argv[0], resultCode, want)) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "Unrwrap abilityResult param error");
ThrowInvalidParamError(env, "Parse param parameter failed, must be a AbilityResult");
ThrowInvalidParamError(env, "Parse param parameter failed, must be a AbilityResult.");
break;
}
@@ -580,17 +580,15 @@ private:
std::string bundleName;
if (!ConvertFromJsValue(env, argv[INDEX_ZERO], bundleName) || bundleName.empty()) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "Convert session id error.");
auto errMsg = "Non empty package name needs to be provided";
ThrowError(env, static_cast<int32_t>(AbilityErrorCode::ERROR_CODE_INVALID_PARAM), errMsg);
TAG_LOGE(AAFwkTag::ABILITYMGR, "Parse param bundleName failed, must be a string.");
ThrowInvalidParamError(env, "Parse param bundleName failed, must be a string.");
return CreateJsUndefined(env);
}
bool enableState = false;
if (!ConvertFromJsValue(env, argv[INDEX_ONE], enableState)) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "Convert status failed.");
auto errMsg = "The second parameter needs to provide a Boolean type setting value";
ThrowError(env, static_cast<int32_t>(AbilityErrorCode::ERROR_CODE_INVALID_PARAM), errMsg);
TAG_LOGE(AAFwkTag::ABILITYMGR, "Parse param enable failed, must be a boolean.");
ThrowInvalidParamError(env, "Parse param enable failed, must be a boolean.");
return CreateJsUndefined(env);
}
@@ -633,27 +631,27 @@ private:
bool stageMode = false;
napi_status status = OHOS::AbilityRuntime::IsStageContext(env, info.argv[0], stageMode);
if (status != napi_ok || !stageMode) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "it is not a stage mode");
ThrowInvalidParamError(env, "Parse param context failed, must be stageMode");
TAG_LOGE(AAFwkTag::ABILITYMGR, "it is not a context of stageMode");
ThrowInvalidParamError(env, "Parse param context failed, must be a context of stageMode.");
return CreateJsUndefined(env);
}
auto context = OHOS::AbilityRuntime::GetStageModeContext(env, info.argv[0]);
if (context == nullptr) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "get context failed");
ThrowInvalidParamError(env, "Parse param context failed, must not be nullptr");
ThrowInvalidParamError(env, "Parse param context failed, must not be nullptr.");
return CreateJsUndefined(env);
}
auto uiAbilityContext = AbilityRuntime::Context::ConvertTo<AbilityRuntime::AbilityContext>(context);
if (uiAbilityContext == nullptr) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "convert to UIAbility context failed");
ThrowInvalidParamError(env, "Parse param context failed, must be UIAbilityContext");
ThrowInvalidParamError(env, "Parse param context failed, must be UIAbilityContext.");
return CreateJsUndefined(env);
}
std::string appId;
if (!ConvertFromJsValue(env, info.argv[1], appId)) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "OnOpenAtomicService, parse appId failed.");
ThrowInvalidParamError(env, "Parse param appId failed, must be a string");
ThrowInvalidParamError(env, "Parse param appId failed, must be a string.");
return CreateJsUndefined(env);
}
@@ -254,7 +254,7 @@ private:
if (!CheckOnOffType(env, argc, argv)) {
ThrowInvalidParamError(env, "Parse param type failed, must be a string,"
"value must be applicationState, appForegroundState or abilityFirstFrameState");
"value must be applicationState, appForegroundState or abilityFirstFrameState.");
return CreateJsUndefined(env);
}
@@ -300,7 +300,7 @@ private:
}
if (!AppExecFwk::IsTypeForNapiValue(env, argv[INDEX_ONE], napi_object)) {
TAG_LOGE(AAFwkTag::APPMGR, "Invalid param");
ThrowInvalidParamError(env, "Parse param observer failed, must be a ApplicationStateObserver");
ThrowInvalidParamError(env, "Parse param observer failed, must be a ApplicationStateObserver.");
return CreateJsUndefined(env);
}
std::vector<std::string> bundleNameList;
@@ -343,7 +343,7 @@ private:
}
if (!AppExecFwk::IsTypeForNapiValue(env, argv[INDEX_ONE], napi_object)) {
TAG_LOGE(AAFwkTag::APPMGR, "Invalid param.");
ThrowInvalidParamError(env, "Parse param observer failed, must be a AppForegroundStateObserver");
ThrowInvalidParamError(env, "Parse param observer failed, must be a AppForegroundStateObserver.");
return CreateJsUndefined(env);
}
if (observerForeground_ == nullptr) {
@@ -406,7 +406,7 @@ private:
if (!AppExecFwk::IsTypeForNapiValue(env, argv[INDEX_ONE], napi_object) ||
!IsJSFunctionExist(env, argv[INDEX_ONE], "onAbilityFirstFrameDrawn")) {
TAG_LOGE(AAFwkTag::APPMGR, "Invalid param.");
ThrowInvalidParamError(env, "Parse param observer failed, must be a AbilityFirstFrameStateObserver");
ThrowInvalidParamError(env, "Parse param observer failed, must be a AbilityFirstFrameStateObserver.");
return CreateJsUndefined(env);
}
std::string bundleName;
@@ -414,7 +414,7 @@ private:
if (!IsParasNullOrUndefined(env, argv[INDEX_TWO]) &&
(!ConvertFromJsValue(env, argv[INDEX_TWO], bundleName) || bundleName.empty())) {
TAG_LOGE(AAFwkTag::APPMGR, "Get bundleName error or bundleName empty!");
ThrowInvalidParamError(env, "Parse param bundleName failed, must be a string");
ThrowInvalidParamError(env, "Parse param bundleName failed, must be a string.");
return CreateJsUndefined(env);
}
}
@@ -460,7 +460,7 @@ private:
(!AppExecFwk::IsTypeForNapiValue(env, argv[INDEX_ONE], napi_object) ||
!IsJSFunctionExist(env, argv[INDEX_ONE], "onAbilityFirstFrameDrawn"))) {
TAG_LOGE(AAFwkTag::APPMGR, "Invalid param.");
ThrowInvalidParamError(env, "Parse param observer failed, must be a AbilityFirstFrameStateObserver");
ThrowInvalidParamError(env, "Parse param observer failed, must be a AbilityFirstFrameStateObserver.");
return CreateJsUndefined(env);
}
}
@@ -485,20 +485,20 @@ private:
}
if (!CheckOnOffType(env, argc, argv)) {
ThrowInvalidParamError(env, "Parse param type failed, must be a string,"
"value must be applicationState, appForegroundState or abilityFirstFrameState");
"value must be applicationState, appForegroundState or abilityFirstFrameState.");
return CreateJsUndefined(env);
}
int64_t observerId = -1;
napi_get_value_int64(env, argv[INDEX_ONE], &observerId);
if (observer_ == nullptr) {
TAG_LOGE(AAFwkTag::APPMGR, "observer is nullptr, please register first");
ThrowInvalidParamError(env, "observer is nullptr, please register first");
TAG_LOGE(AAFwkTag::APPMGR, "observer is nullptr, please register first.");
ThrowInvalidParamError(env, "observer is nullptr, please register first.");
return CreateJsUndefined(env);
}
if (!observer_->FindObserverByObserverId(observerId)) {
TAG_LOGE(AAFwkTag::APPMGR, "not find observer, observer:%{public}d", static_cast<int32_t>(observerId));
ThrowInvalidParamError(env, "not find observerId");
ThrowInvalidParamError(env, "not find observerId.");
return CreateJsUndefined(env);
}
TAG_LOGD(AAFwkTag::APPMGR, "find observer exist observer:%{public}d", static_cast<int32_t>(observerId));
@@ -540,7 +540,7 @@ private:
int32_t observerId = -1;
if (!ConvertFromJsValue(env, argv[INDEX_ONE], observerId)) {
TAG_LOGE(AAFwkTag::APPMGR, "Parse observerId failed");
ThrowInvalidParamError(env, "Parse param observerId failed, must be a number");
ThrowInvalidParamError(env, "Parse param observerId failed, must be a number.");
return CreateJsUndefined(env);
}
@@ -551,7 +551,7 @@ private:
}
if (!observerSync_->FindObserverByObserverId(observerId)) {
TAG_LOGE(AAFwkTag::APPMGR, "not find observer, observer:%{public}d", static_cast<int32_t>(observerId));
ThrowInvalidParamError(env, "not find observerId");
ThrowInvalidParamError(env, "not find observerId.");
return CreateJsUndefined(env);
}
int32_t ret = appManager_->UnregisterApplicationStateObserver(observerSync_);
@@ -575,7 +575,7 @@ private:
}
if (argc == ARGC_TWO && !AppExecFwk::IsTypeForNapiValue(env, argv[INDEX_ONE], napi_object)) {
TAG_LOGE(AAFwkTag::APPMGR, "Invalid param.");
ThrowInvalidParamError(env, "Parse param observer failed, must be a AppForegroundStateObserver");
ThrowInvalidParamError(env, "Parse param observer failed, must be a AppForegroundStateObserver.");
return CreateJsUndefined(env);
}
if (observerForeground_ == nullptr || appManager_ == nullptr) {
@@ -673,7 +673,7 @@ private:
std::string bundleName;
if (!ConvertFromJsValue(env, argv[0], bundleName)) {
TAG_LOGE(AAFwkTag::APPMGR, "get bundleName failed!");
ThrowInvalidParamError(env, "Parse param bundleName failed, must be a string");
ThrowInvalidParamError(env, "Parse param bundleName failed, must be a string.");
return CreateJsUndefined(env);
}
auto info = std::make_shared<RunningMultiAppInfo>();
@@ -713,12 +713,12 @@ private:
int32_t bundleType = -1;
if (!ConvertFromJsValue(env, argv[INDEX_ZERO], bundleType)) {
TAG_LOGE(AAFwkTag::APPMGR, "get bundleType error!");
ThrowInvalidParamError(env, "failed to get bundleType");
ThrowInvalidParamError(env, "Parse param bundleType failed, must be a BundleType.");
return CreateJsUndefined(env);
}
if (bundleType < 0) {
TAG_LOGE(AAFwkTag::APPMGR, "Invalid bundle type:%{public}d", bundleType);
ThrowInvalidParamError(env, "invalid bundle type");
ThrowInvalidParamError(env, "Parse param bundleType failed, must not be less then zero.");
return CreateJsUndefined(env);
}
NapiAsyncTask::CompleteCallback complete =
@@ -779,7 +779,7 @@ private:
std::string bundleName;
if (!ConvertFromJsValue(env, argv[0], bundleName)) {
TAG_LOGE(AAFwkTag::APPMGR, "get bundleName error!");
ThrowInvalidParamError(env, "Parse param bundleName failed, must be a string");
ThrowInvalidParamError(env, "Parse param bundleName failed, must be a string.");
return CreateJsUndefined(env);
}
@@ -818,7 +818,7 @@ private:
std::string bundleName;
if (!ConvertFromJsValue(env, argv[0], bundleName)) {
TAG_LOGE(AAFwkTag::APPMGR, "get bundleName failed!");
ThrowInvalidParamError(env, "Parse param bundleName failed, must be a string");
ThrowInvalidParamError(env, "Parse param bundleName failed, must be a string.");
return CreateJsUndefined(env);
}
@@ -856,14 +856,14 @@ private:
std::string bundleName;
if (!ConvertFromJsValue(env, argv[0], bundleName)) {
TAG_LOGE(AAFwkTag::APPMGR, "get bundleName wrong!");
ThrowInvalidParamError(env, "Parse param bundleName failed, must be a string");
ThrowInvalidParamError(env, "Parse param bundleName failed, must be a string.");
return CreateJsUndefined(env);
}
uint32_t versionCode = 0;
if (!ConvertFromJsValue(env, argv[1], versionCode)) {
TAG_LOGE(AAFwkTag::APPMGR, "get versionCode failed!");
ThrowInvalidParamError(env, "Parse param versionCode failed, must be a number");
ThrowInvalidParamError(env, "Parse param versionCode failed, must be a number.");
return CreateJsUndefined(env);
}
@@ -898,13 +898,13 @@ private:
std::string bundleName;
if (!ConvertFromJsValue(env, argv[0], bundleName)) {
TAG_LOGE(AAFwkTag::APPMGR, "Parse bundleName failed");
ThrowInvalidParamError(env, "Parse param bundleName failed, must be a string");
ThrowInvalidParamError(env, "Parse param bundleName failed, must be a string.");
return CreateJsUndefined(env);
}
int32_t accountId = -1;
if (!ConvertFromJsValue(env, argv[1], accountId)) {
TAG_LOGE(AAFwkTag::APPMGR, "Parse userId failed");
ThrowInvalidParamError(env, "Parse param accountId failed, must be a number");
ThrowInvalidParamError(env, "Parse param accountId failed, must be a number.");
return CreateJsUndefined(env);
}
@@ -984,7 +984,7 @@ private:
int32_t pid;
if (!ConvertFromJsValue(env, argv[0], pid)) {
TAG_LOGE(AAFwkTag::APPMGR, "get pid failed");
ThrowInvalidParamError(env, "Parse param pid failed, must be a number");
ThrowInvalidParamError(env, "Parse param pid failed, must be a number.");
return CreateJsUndefined(env);
}
@@ -1023,7 +1023,7 @@ private:
bool isPromiseType = false;
if (!ConvertFromJsValue(env, argv[0], bundleName)) {
TAG_LOGE(AAFwkTag::APPMGR, "First parameter must be string");
ThrowInvalidParamError(env, "Parse param bundleName failed, must be a string");
ThrowInvalidParamError(env, "Parse param bundleName failed, must be a string.");
return CreateJsUndefined(env);
}
if (argc == ARGC_ONE) {
@@ -1035,11 +1035,11 @@ private:
} else if (argc == ARGC_THREE) {
if (!ConvertFromJsValue(env, argv[1], userId)) {
TAG_LOGW(AAFwkTag::APPMGR, "Must input userid and use callback when argc is three.");
ThrowInvalidParamError(env, "Parse param userId failed, must be a number");
ThrowInvalidParamError(env, "Parse param userId failed, must be a number.");
return CreateJsUndefined(env);
}
} else {
ThrowInvalidParamError(env, "The number of param exceeded");
ThrowInvalidParamError(env, "The number of param exceeded.");
return CreateJsUndefined(env);
}
@@ -1076,7 +1076,7 @@ private:
std::string bundleName;
if (!ConvertFromJsValue(env, argv[0], bundleName)) {
TAG_LOGE(AAFwkTag::APPMGR, "Get bundle name wrong.");
ThrowInvalidParamError(env, "Parse param bundleName failed, must be a string");
ThrowInvalidParamError(env, "Parse param bundleName failed, must be a string.");
return CreateJsUndefined(env);
}
@@ -1121,13 +1121,13 @@ private:
std::string bundleName;
if (!ConvertFromJsValue(env, argv[0], bundleName)) {
TAG_LOGE(AAFwkTag::APPMGR, "Get bundle name wrong.");
ThrowInvalidParamError(env, "Parse param bundleName failed, must be a string");
ThrowInvalidParamError(env, "Parse param bundleName failed, must be a string.");
return CreateJsUndefined(env);
}
int32_t appCloneIndex = 0;
if (argc > ARGC_ONE && !ConvertFromJsValue(env, argv[1], appCloneIndex)) {
TAG_LOGE(AAFwkTag::APPMGR, "Get appCloneIndex wrong.");
ThrowInvalidParamError(env, "Parse param appCloneIndex failed, must be a string");
ThrowInvalidParamError(env, "Parse param appCloneIndex failed, must be a string.");
return CreateJsUndefined(env);
}
@@ -276,12 +276,12 @@ bool ConvertPreloadApplicationParam(napi_env env, size_t argc, napi_value *argv,
{
if (!ConvertFromJsValue(env, argv[ARG_INDEX_0], param.bundleName)) {
TAG_LOGE(AAFwkTag::APPMGR, "PreloadApplication get param bundleName failed.");
errorMsg = "Param bundleName must be a valid string.";
errorMsg = "Parse param bundleName failed, must be a valid string.";
return false;
}
if (!ConvertFromJsValue(env, argv[ARG_INDEX_1], param.userId)) {
TAG_LOGE(AAFwkTag::APPMGR, "PreloadApplication get param userId failed.");
errorMsg = "Param userId must be a valid number.";
errorMsg = "Parse param userId failed, must be a valid number.";
return false;
}
if (!ConvertFromJsValue(env, argv[ARG_INDEX_2], param.preloadMode)
@@ -292,7 +292,7 @@ bool ConvertPreloadApplicationParam(napi_env env, size_t argc, napi_value *argv,
}
if (argc > ARG_INDEX_3 && !ConvertFromJsValue(env, argv[ARG_INDEX_3], param.appIndex)) {
TAG_LOGE(AAFwkTag::APPMGR, "PreloadApplication get param appIndex failed.");
errorMsg = "Param appIndex must be a valid number.";
errorMsg = "Parse param appIndex failed, must be a valid number.";
return false;
}
return true;
@@ -86,15 +86,15 @@ private:
OHOS::AAFwk::Want want;
if (!OHOS::AppExecFwk::UnwrapWant(env, info.argv[0], want)) {
TAG_LOGE(AAFwkTag::DIALOG, "The input want is invalid.");
ThrowInvalidParamError(env, "Parameter error: The input want is invalid.");
TAG_LOGE(AAFwkTag::DIALOG, "Parse param want failed, must be a Want.");
ThrowInvalidParamError(env, "Parse param want failed, must be a Want.");
return CreateJsUndefined(env);
}
sptr<IRemoteObject> callerToken = want.GetRemoteObject(RequestConstants::REQUEST_TOKEN_KEY);
if (!callerToken) {
TAG_LOGE(AAFwkTag::DIALOG, "Can not get token from target want.");
ThrowInvalidParamError(env, "Parameter error: Can not get token from target want.");
TAG_LOGE(AAFwkTag::DIALOG, "get token from target want failed.");
ThrowInvalidParamError(env, "Parameter error: get token from target want failed.");
return CreateJsUndefined(env);
}
int32_t left = want.GetIntParam(RequestConstants::WINDOW_RECTANGLE_LEFT_KEY, 0);
@@ -105,8 +105,8 @@ private:
auto requestInfo = new RequestInfo(callerToken, left, top, width, height);
auto jsRequestInfo = RequestInfo::WrapRequestInfo(env, requestInfo);
if (jsRequestInfo == nullptr) {
TAG_LOGE(AAFwkTag::DIALOG, "Can not wrap request info from target request.");
ThrowInvalidParamError(env, "Parameter error: Can not wrap request info from target request.");
TAG_LOGE(AAFwkTag::DIALOG, "Wrap Param requestInfo failed, must be a RequestInfo.");
ThrowInvalidParamError(env, "Wrap Param requestInfo failed, must be a RequestInfo.");
return CreateJsUndefined(env);
}
@@ -125,14 +125,14 @@ private:
OHOS::AAFwk::Want want;
if (!OHOS::AppExecFwk::UnwrapWant(env, info.argv[0], want)) {
TAG_LOGE(AAFwkTag::DIALOG, "The input want is invalid.");
ThrowInvalidParamError(env, "Parameter error: The input want is invalid.");
ThrowInvalidParamError(env, "Parse param want failed, must be a Want.");
return CreateJsUndefined(env);
}
sptr<IRemoteObject> remoteObj = want.GetRemoteObject(RequestConstants::REQUEST_CALLBACK_KEY);
if (!remoteObj) {
TAG_LOGE(AAFwkTag::DIALOG, "Can not get callback from target want.");
ThrowInvalidParamError(env, "Parameter error: Can not get callback from target want.");
TAG_LOGE(AAFwkTag::DIALOG, "Wrap Param requestCallback failed, must be a RequestCallback.");
ThrowInvalidParamError(env, "Wrap Param requestCallback failed, must be a RequestCallback.");
return CreateJsUndefined(env);
}
@@ -146,7 +146,7 @@ private:
}
if (!CheckOnOffType(env, argc, argv)) {
ThrowInvalidParamError(env, "Parse param type failed, must be a string, value must be mission");
ThrowInvalidParamError(env, "Parse param type failed, must be a string, value must be mission.");
return CreateJsUndefined(env);
}
@@ -183,7 +183,7 @@ private:
}
if (!AppExecFwk::IsTypeForNapiValue(env, argv[1], napi_object)) {
TAG_LOGE(AAFwkTag::MISSION, "Invalid param");
ThrowInvalidParamError(env, "Parse param listener failed, must be a MissionListener");
ThrowInvalidParamError(env, "Parse param listener failed, must be a MissionListener.");
return CreateJsUndefined(env);
}
@@ -230,14 +230,14 @@ private:
}
if (!CheckOnOffType(env, argc, argv)) {
ThrowInvalidParamError(env, "Parse param type failed, must be a string, value must be mission");
ThrowInvalidParamError(env, "Parse param type failed, must be a string, value must be mission.");
return CreateJsUndefined(env);
}
int32_t missionListenerId = -1;
if (!ConvertFromJsValue(env, argv[ARGC_ONE], missionListenerId)) {
TAG_LOGE(AAFwkTag::MISSION, "Parse missionListenerId failed");
ThrowInvalidParamError(env, "Parse param listenerId failed, must be a number");
ThrowInvalidParamError(env, "Parse param listenerId failed, must be a number.");
return CreateJsUndefined(env);
}
@@ -282,7 +282,7 @@ private:
int32_t missionListenerId = -1;
if (!ConvertFromJsValue(env, argv[INDEX_ONE], missionListenerId)) {
TAG_LOGE(AAFwkTag::MISSION, "Parse missionListenerId failed");
ThrowInvalidParamError(env, "Parse param listenerId failed, must be a number");
ThrowInvalidParamError(env, "Parse param listenerId failed, must be a number.");
return CreateJsUndefined(env);
}
@@ -326,13 +326,13 @@ private:
std::string deviceId;
if (!ConvertFromJsValue(env, argv[0], deviceId)) {
TAG_LOGE(AAFwkTag::MISSION, "Parse deviceId failed");
ThrowInvalidParamError(env, "Parse param deviceId failed, must be a string");
ThrowInvalidParamError(env, "Parse param deviceId failed, must be a string.");
return CreateJsUndefined(env);
}
int numMax = -1;
if (!ConvertFromJsValue(env, argv[1], numMax)) {
TAG_LOGE(AAFwkTag::MISSION, "Parse numMax failed");
ThrowInvalidParamError(env, "Parse param numMax failed, must be a number");
ThrowInvalidParamError(env, "Parse param numMax failed, must be a number.");
return CreateJsUndefined(env);
}
@@ -366,13 +366,13 @@ private:
std::string deviceId;
if (!ConvertFromJsValue(env, argv[0], deviceId)) {
TAG_LOGE(AAFwkTag::MISSION, "Parse deviceId failed");
ThrowInvalidParamError(env, "Parse param deviceId failed, must be a string");
ThrowInvalidParamError(env, "Parse param deviceId failed, must be a string.");
return CreateJsUndefined(env);
}
int32_t missionId = -1;
if (!ConvertFromJsValue(env, argv[1], missionId)) {
TAG_LOGE(AAFwkTag::MISSION, "Parse missionId failed");
ThrowInvalidParamError(env, "Parse param missionId failed, must be a number");
ThrowInvalidParamError(env, "Parse param missionId failed, must be a number.");
return CreateJsUndefined(env);
}
@@ -467,13 +467,13 @@ private:
if (!ConvertFromJsValue(env, argv[0], deviceId)) {
TAG_LOGE(AAFwkTag::MISSION, "missionSnapshot: Parse deviceId failed");
ThrowInvalidParamError(env, "Parse param deviceId failed, must be a string");
ThrowInvalidParamError(env, "Parse param deviceId failed, must be a string.");
return false;
}
if (!ConvertFromJsValue(env, argv[1], missionId)) {
TAG_LOGE(AAFwkTag::MISSION, "missionSnapshot: Parse missionId failed");
ThrowInvalidParamError(env, "Parse param missionId failed, must be a number");
ThrowInvalidParamError(env, "Parse param missionId failed, must be a number.");
return false;
}
@@ -491,7 +491,7 @@ private:
int32_t missionId = -1;
if (!ConvertFromJsValue(env, argv[0], missionId)) {
TAG_LOGE(AAFwkTag::MISSION, "OnLockMission Parse missionId failed");
ThrowInvalidParamError(env, "Parse param missionId failed, must be a number");
ThrowInvalidParamError(env, "Parse param missionId failed, must be a number.");
return CreateJsUndefined(env);
}
@@ -524,7 +524,7 @@ private:
int32_t missionId = -1;
if (!ConvertFromJsValue(env, argv[0], missionId)) {
TAG_LOGE(AAFwkTag::MISSION, "OnUnlockMission Parse missionId failed");
ThrowInvalidParamError(env, "Parse param missionId failed, must be a number");
ThrowInvalidParamError(env, "Parse param missionId failed, must be a number.");
return CreateJsUndefined(env);
}
@@ -557,7 +557,7 @@ private:
int32_t missionId = -1;
if (!ConvertFromJsValue(env, argv[0], missionId)) {
TAG_LOGE(AAFwkTag::MISSION, "OnClearMission Parse missionId failed");
ThrowInvalidParamError(env, "Parse param missionId failed, must be a number");
ThrowInvalidParamError(env, "Parse param missionId failed, must be a number.");
return CreateJsUndefined(env);
}
@@ -611,7 +611,7 @@ private:
int32_t missionId = -1;
if (!ConvertFromJsValue(env, argv[0], missionId)) {
TAG_LOGE(AAFwkTag::MISSION, "OnMoveMissionToFront Parse missionId failed");
ThrowInvalidParamError(env, "Parse param missionId failed, must be a number");
ThrowInvalidParamError(env, "Parse param missionId failed, must be a number.");
return CreateJsUndefined(env);
}
decltype(argc) unwrapArgc = 1;
@@ -654,7 +654,7 @@ private:
napi_get_array_length(env, argv[0], &nativeArrayLen);
if (nativeArrayLen == 0) {
TAG_LOGE(AAFwkTag::MISSION, "OnMoveMissionsToForeground MissionId is null");
ThrowInvalidParamError(env, "Parse param missionIds failed, the size of missionIds must above zero");
ThrowInvalidParamError(env, "Parse param missionIds failed, the size of missionIds must above zero.");
return CreateJsUndefined(env);
}
napi_value element = nullptr;
@@ -663,7 +663,7 @@ private:
napi_get_element(env, argv[0], i, &element);
if (!ConvertFromJsValue(env, element, missionId)) {
TAG_LOGE(AAFwkTag::MISSION, "OnMoveMissionsToForeground Parse missionId failed");
ThrowInvalidParamError(env, "Parse param missionIds failed, missionId must be a number");
ThrowInvalidParamError(env, "Parse param missionIds failed, missionId must be a number.");
return CreateJsUndefined(env);
}
missionIds.push_back(missionId);
@@ -674,7 +674,7 @@ private:
if (argc > ARGC_ONE && AppExecFwk::IsTypeForNapiValue(env, argv[1], napi_number)) {
if (!ConvertFromJsValue(env, argv[1], topMissionId)) {
TAG_LOGE(AAFwkTag::MISSION, "OnMoveMissionsToForeground Parse topMissionId failed");
ThrowInvalidParamError(env, "Parse param topMission failed, must be a number");
ThrowInvalidParamError(env, "Parse param topMission failed, must be a number.");
return CreateJsUndefined(env);
}
unwrapArgc++;
@@ -713,7 +713,7 @@ private:
napi_get_array_length(env, argv[0], &nativeArrayLen);
if (nativeArrayLen == 0) {
TAG_LOGE(AAFwkTag::MISSION, "OnMoveMissionsToBackground MissionId is null");
ThrowInvalidParamError(env, "Parse param missionIds failed, the size of missionIds must above zero");
ThrowInvalidParamError(env, "Parse param missionIds failed, the size of missionIds must above zero.");
return CreateJsUndefined(env);
}
napi_value element = nullptr;
@@ -722,7 +722,7 @@ private:
napi_get_element(env, argv[0], i, &element);
if (!ConvertFromJsValue(env, element, missionId)) {
TAG_LOGE(AAFwkTag::MISSION, "OnMoveMissionsToBackground Parse topMissionId failed");
ThrowInvalidParamError(env, "Parse param missionIds failed, missionId must be a number");
ThrowInvalidParamError(env, "Parse param missionIds failed, missionId must be a number.");
return CreateJsUndefined(env);
}
missionIds.push_back(missionId);
@@ -503,7 +503,7 @@ bool DistributedClient::WriteInfosToParcel(MessageParcel& data, const OHOS::AAFw
const sptr<IRemoteObject>& connect)
{
int32_t callerUid = IPCSkeleton::GetCallingUid();
int32_t callerPid = IPCSkeleton::GetCallingRealPid();
int32_t callerPid = IPCSkeleton::GetCallingPid();
uint32_t accessToken = IPCSkeleton::GetCallingTokenID();
if (!data.WriteInterfaceToken(DMS_PROXY_INTERFACE_TOKEN)) {
return false;
@@ -277,12 +277,12 @@ private:
if (!CheckTypeForNapiValue(env, info.argv[ARGC_ZERO], napi_string)) {
TAG_LOGE(AAFwkTag::SERVICE_EXT, "link must be string");
ThrowInvalidParamError(env, "Parse param link failed, must be a string");
ThrowInvalidParamError(env, "Parse param link failed, must be a string.");
return false;
}
if (!ConvertFromJsValue(env, info.argv[ARGC_ZERO], linkValue) || !CheckUrl(linkValue)) {
TAG_LOGE(AAFwkTag::SERVICE_EXT, "link parameter invalid");
ThrowInvalidParamError(env, "link parameter invalid");
ThrowInvalidParamError(env, "link parameter invalid.");
return false;
}
@@ -290,7 +290,7 @@ private:
TAG_LOGD(AAFwkTag::SERVICE_EXT, "OpenLinkOptions is used.");
if (!AppExecFwk::UnwrapOpenLinkOptions(env, info.argv[INDEX_ONE], openLinkOptions, want)) {
TAG_LOGE(AAFwkTag::SERVICE_EXT, "OpenLinkOptions parse failed");
ThrowInvalidParamError(env, "Parse param options failed, must be a OpenLinkOptions");
ThrowInvalidParamError(env, "Parse param options failed, must be a OpenLinkOptions.");
return false;
}
}
@@ -405,7 +405,7 @@ private:
unwrapArgc = ARGC_ZERO;
// Check input want
if (!AppExecFwk::UnwrapWant(env, info.argv[INDEX_ZERO], want)) {
ThrowInvalidParamError(env, "Parse param want failed, must be a Want");
ThrowInvalidParamError(env, "Parse param want failed, must be a Want.");
return false;
}
++unwrapArgc;
@@ -467,7 +467,7 @@ private:
napi_env env, NapiCallbackInfo& info, AAFwk::Want& want, int32_t& accountId)
{
if (!AppExecFwk::UnwrapWant(env, info.argv[INDEX_ZERO], want)) {
ThrowInvalidParamError(env, "Parse param want failed, must be a Want");
ThrowInvalidParamError(env, "Parse param want failed, must be a Want.");
return false;
}
@@ -475,12 +475,12 @@ private:
if (CheckTypeForNapiValue(env, info.argv[INDEX_ONE], napi_number)) {
if (!ConvertFromJsValue(env, info.argv[1], accountId)) {
TAG_LOGE(AAFwkTag::SERVICE_EXT, "check input param accountId failed");
ThrowInvalidParamError(env, "Parse param accountId failed, must be a number");
ThrowInvalidParamError(env, "Parse param accountId failed, must be a number.");
return false;
}
} else {
TAG_LOGE(AAFwkTag::SERVICE_EXT, "input parameter type invalid");
ThrowInvalidParamError(env, "Parse param accountId failed, must be a number");
ThrowInvalidParamError(env, "Parse param accountId failed, must be a number.");
return false;
}
}
@@ -624,12 +624,12 @@ private:
unwrapArgc = ARGC_ZERO;
// Check input want
if (!AppExecFwk::UnwrapWant(env, info.argv[INDEX_ZERO], want)) {
ThrowInvalidParamError(env, "Parse param want failed, must be a Want");
ThrowInvalidParamError(env, "Parse param want failed, must be a Want.");
return false;
}
++unwrapArgc;
if (!AppExecFwk::UnwrapInt32FromJS2(env, info.argv[INDEX_ONE], accountId)) {
ThrowInvalidParamError(env, "Parse param accountId failed, must be a number");
ThrowInvalidParamError(env, "Parse param accountId failed, must be a number.");
return false;
}
++unwrapArgc;
@@ -677,11 +677,11 @@ private:
AAFwk::Want want;
sptr<JSServiceExtensionConnection> connection = new JSServiceExtensionConnection(env);
if (!AppExecFwk::UnwrapWant(env, info.argv[0], want)) {
ThrowInvalidParamError(env, "Parse param want failed, must be a Want");
ThrowInvalidParamError(env, "Parse param want failed, must be a Want.");
return CreateJsUndefined(env);
}
if (!CheckConnectionParam(env, info.argv[1], connection, want)) {
ThrowInvalidParamError(env, "Parse param options failed, must be a ConnectOptions");
ThrowInvalidParamError(env, "Parse param options failed, must be a ConnectOptions.");
return CreateJsUndefined(env);
}
int64_t connectId = connection->GetConnectionId();
@@ -726,7 +726,7 @@ private:
return CreateJsUndefined(env);
}
if (!CheckConnectionParam(env, info.argv[INDEX_TWO], connection, want, accountId)) {
ThrowInvalidParamError(env, "Parse param options failed, must be a ConnectOptions");
ThrowInvalidParamError(env, "Parse param options failed, must be a ConnectOptions.");
return CreateJsUndefined(env);
}
int64_t connectId = connection->GetConnectionId();
@@ -792,7 +792,7 @@ private:
}
int64_t connectId = -1;
if (!AppExecFwk::UnwrapInt64FromJS2(env, info.argv[INDEX_ZERO], connectId)) {
ThrowInvalidParamError(env, "Parse param connection failed, must be a number");
ThrowInvalidParamError(env, "Parse param connection failed, must be a number.");
return CreateJsUndefined(env);
}
@@ -862,7 +862,7 @@ private:
}
AAFwk::Want want;
if (!AppExecFwk::UnwrapWant(env, info.argv[INDEX_ZERO], want)) {
ThrowInvalidParamError(env, "Parse param want failed, must be a Want");
ThrowInvalidParamError(env, "Parse param want failed, must be a Want.");
return CreateJsUndefined(env);
}
@@ -937,7 +937,7 @@ private:
}
AAFwk::Want want;
if (!AppExecFwk::UnwrapWant(env, info.argv[INDEX_ZERO], want)) {
ThrowInvalidParamError(env, "Parse param want failed, must be a Want");
ThrowInvalidParamError(env, "Parse param want failed, must be a Want.");
return CreateJsUndefined(env);
}
@@ -1014,7 +1014,7 @@ private:
AAFwk::Want want;
if (!AppExecFwk::UnwrapWant(env, info.argv[0], want)) {
TAG_LOGE(AAFwkTag::SERVICE_EXT, "Failed to parse want!");
ThrowInvalidParamError(env, "Parse param want failed, must be a Want");
ThrowInvalidParamError(env, "Parse param want failed, must be a Want.");
return CreateJsUndefined(env);
}
+1 -10
View File
@@ -644,16 +644,7 @@ void MainThread::ScheduleJsHeapMemory(OHOS::AppExecFwk::JsHeapDumpInfo &info)
return;
}
if (info.needSnapshot == true) {
std::vector<uint32_t> 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);
runtime->DumpHeapSnapshot(info.tid, info.needGc);
} else {
if (info.needGc == true) {
runtime->ForceFullGC(info.tid);
@@ -679,6 +679,10 @@ std::shared_ptr<AbilityRuntime::Context> OHOSApplication::AddAbilityStage(
TAG_LOGE(AAFwkTag::APPKIT, "hapModuleInfo is nullptr");
return nullptr;
}
if (runtime_) {
runtime_->UpdatePkgContextInfoJson(
hapModuleInfo->moduleName, hapModuleInfo->hapPath, hapModuleInfo->packageName);
}
SetAppEnv(hapModuleInfo->appEnvironments);
if (abilityInfo->applicationInfo.multiProjects) {
+20 -3
View File
@@ -757,6 +757,8 @@ bool JsRuntime::Initialize(const Options& options)
panda::JSNApi::SetHmsModuleList(vm, systemKitsMap);
std::map<std::string, std::vector<std::vector<std::string>>> pkgContextInfoMap;
std::map<std::string, std::string> pkgAliasMap;
pkgContextInfoJsonStringMap_ = options.pkgContextInfoJsonStringMap;
packageNameList_ = options.packageNameList;
GetPkgContextInfoListMap(options.pkgContextInfoJsonStringMap, pkgContextInfoMap, pkgAliasMap);
panda::JSNApi::SetpkgContextInfoList(vm, pkgContextInfoMap);
panda::JSNApi::SetPkgAliasList(vm, pkgAliasMap);
@@ -1197,12 +1199,11 @@ void JsRuntime::DumpHeapSnapshot(bool isPrivate)
nativeEngine->DumpHeapSnapshot(true, DumpFormat::JSON, isPrivate, false);
}
void JsRuntime::DumpHeapSnapshot(uint32_t tid, bool isFullGC, std::vector<uint32_t> fdVec,
std::vector<uint32_t> tidVec)
void JsRuntime::DumpHeapSnapshot(uint32_t tid, bool isFullGC)
{
auto vm = GetEcmaVm();
CHECK_POINTER(vm);
DFXJSNApi::DumpHeapSnapshot(vm, 0, true, false, false, isFullGC, tid, fdVec, tidVec);
DFXJSNApi::DumpHeapSnapshot(vm, 0, true, false, false, isFullGC, tid);
}
void JsRuntime::ForceFullGC(uint32_t tid)
@@ -1695,5 +1696,21 @@ std::shared_ptr<Runtime::Options> JsRuntime::GetChildOptions()
TAG_LOGD(AAFwkTag::JSRUNTIME, "called");
return childOptions_;
}
void JsRuntime::UpdatePkgContextInfoJson(std::string moduleName, std::string hapPath, std::string packageName)
{
auto iterator = pkgContextInfoJsonStringMap_.find(moduleName);
if (iterator == pkgContextInfoJsonStringMap_.end()) {
pkgContextInfoJsonStringMap_[moduleName] = hapPath;
packageNameList_[moduleName] = packageName;
auto vm = GetEcmaVm();
std::map<std::string, std::vector<std::vector<std::string>>> pkgContextInfoMap;
std::map<std::string, std::string> pkgAliasMap;
GetPkgContextInfoListMap(pkgContextInfoJsonStringMap_, pkgContextInfoMap, pkgAliasMap);
panda::JSNApi::SetpkgContextInfoList(vm, pkgContextInfoMap);
panda::JSNApi::SetPkgAliasList(vm, pkgAliasMap);
panda::JSNApi::SetPkgNameList(vm, packageNameList_);
}
}
} // namespace AbilityRuntime
} // namespace OHOS
+2
View File
@@ -43,6 +43,7 @@
#include "js_runtime_utils.h"
#include "native_engine/impl/ark/ark_native_engine.h"
#include "commonlibrary/ets_utils/js_sys_module/console/console.h"
#include "syscap_ts.h"
#ifdef SUPPORT_SCREEN
using OHOS::Ace::ContainerScope;
#endif
@@ -88,6 +89,7 @@ void InitWorkerFunc(NativeEngine* nativeEngine)
}
OHOS::JsSysModule::Console::InitConsoleModule(reinterpret_cast<napi_env>(nativeEngine));
InitSyscapModule(reinterpret_cast<napi_env>(nativeEngine), globalObj);
#ifdef SUPPORT_SCREEN
OHOS::Ace::DeclarativeModulePreloader::PreloadWorker(*nativeEngine);
#endif
@@ -16,21 +16,16 @@
#ifndef OHOS_ABILITY_RUNTIME_APP_JSHEAP_MEM_INFO_H
#define OHOS_ABILITY_RUNTIME_APP_JSHEAP_MEM_INFO_H
#include <vector>
#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<uint32_t> fdVec;
std::vector<uint32_t> tidVec;
bool ReadFromParcel(Parcel &parcel);
virtual bool Marshalling(Parcel &parcel) const override;
static JsHeapDumpInfo *Unmarshalling(Parcel &parcel);
};
@@ -19,61 +19,10 @@
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
{
bool res = (parcel.WriteUint32(pid) && parcel.WriteUint32(tid)
&& parcel.WriteBool(needGc) && parcel.WriteBool(needSnapshot)
&& parcel.WriteUInt32Vector(fdVec) && parcel.WriteUInt32Vector(tidVec));
auto msgParcel = static_cast<MessageParcel*>(&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<MessageParcel*>(&parcel);
if (msgParcel == nullptr) {
TAG_LOGE(AAFwkTag::APPMGR, "ReadFromParcel failed.");
return false;
}
fdVec.clear();
for (auto &tid : tidVec) {
uint32_t parcelFd = static_cast<uint32_t>(msgParcel->ReadFileDescriptor());
fdVec.push_back(parcelFd);
}
return true;
return (parcel.WriteUint32(pid) && parcel.WriteUint32(tid)
&& parcel.WriteBool(needGc) && parcel.WriteBool(needSnapshot));
}
JsHeapDumpInfo *JsHeapDumpInfo::Unmarshalling(Parcel &parcel)
@@ -83,11 +32,10 @@ JsHeapDumpInfo *JsHeapDumpInfo::Unmarshalling(Parcel &parcel)
TAG_LOGE(AAFwkTag::APPMGR, "info nullptr");
return nullptr;
}
if (info && !info->ReadFromParcel(parcel)) {
TAG_LOGE(AAFwkTag::APPMGR, "JsHeapDumpInfo failed, because ReadFromParcel failed");
delete info;
info = nullptr;
}
info->pid = parcel.ReadUint32();
info->tid = parcel.ReadUint32();
info->needGc = parcel.ReadBool();
info->needSnapshot = parcel.ReadBool();
return info;
}
} // namespace AppExecFwk
+1
View File
@@ -109,6 +109,7 @@ ohos_shared_library("runtime") {
"ffrt:libffrt",
"hilog:libhilog",
"hitrace:hitrace_meter",
"init:syscap_ts",
"ipc:ipc_core",
"json:nlohmann_json_static",
"jsoncpp:jsoncpp",
@@ -60,12 +60,12 @@ public:
void DestroyHeapProfiler() override {};
void ForceFullGC() override {};
void ForceFullGC(uint32_t tid) override {};
void DumpHeapSnapshot(uint32_t tid, bool isFullGC, std::vector<uint32_t> fdVec,
std::vector<uint32_t> tidVec) override {};
void DumpHeapSnapshot(uint32_t tid, bool isFullGC) override {};
void DumpCpuProfile(bool isPrivate) override {};
void AllowCrossThreadExecution() override {};
void GetHeapPrepare() override {};
void RegisterUncaughtExceptionHandler(const CJUncaughtExceptionInfo& uncaughtExceptionInfo);
void UpdatePkgContextInfoJson(std::string moduleName, std::string hapPath, std::string packageName) override {};
private:
bool StartDebugger();
bool LoadCJAppLibrary(const AppLibPathVec& appLibPaths);
@@ -85,8 +85,7 @@ public:
void DestroyHeapProfiler() override;
void ForceFullGC() override;
void ForceFullGC(uint32_t tid) override;
void DumpHeapSnapshot(uint32_t tid, bool isFullGC, std::vector<uint32_t> fdVec,
std::vector<uint32_t> tidVec) override;
void DumpHeapSnapshot(uint32_t tid, bool isFullGC) override;
void AllowCrossThreadExecution() override;
void GetHeapPrepare() override;
void NotifyApplicationState(bool isBackground) override;
@@ -133,6 +132,7 @@ public:
std::unique_ptr<NativeReference> LoadSystemModule(
const std::string& moduleName, const napi_value* argv = nullptr, size_t argc = 0);
void SetDeviceDisconnectCallback(const std::function<bool()> &cb) override;
void UpdatePkgContextInfoJson(std::string moduleName, std::string hapPath, std::string packageName) override;
private:
void FinishPreload() override;
@@ -156,6 +156,8 @@ private:
uint32_t instanceId_ = 0;
std::string bundleName_;
int32_t apiTargetVersion_ = 0;
std::map<std::string, std::string> pkgContextInfoJsonStringMap_;
std::map<std::string, std::string> packageNameList_;
static std::atomic<bool> hasInstance;
@@ -89,8 +89,7 @@ public:
virtual void DestroyHeapProfiler() = 0;
virtual void ForceFullGC() = 0;
virtual void ForceFullGC(uint32_t tid) = 0;
virtual void DumpHeapSnapshot(uint32_t tid, bool isFullGC, std::vector<uint32_t> fdVec,
std::vector<uint32_t> tidVec) = 0;
virtual void DumpHeapSnapshot(uint32_t tid, bool isFullGC) = 0;
virtual void AllowCrossThreadExecution() = 0;
virtual void GetHeapPrepare() = 0;
virtual void NotifyApplicationState(bool isBackground) = 0;
@@ -106,6 +105,7 @@ public:
virtual void DoCleanWorkAfterStageCleaned() = 0;
virtual void SetModuleLoadChecker(const std::shared_ptr<ModuleCheckerDelegate>& moduleCheckerDelegate) const {}
virtual void SetDeviceDisconnectCallback(const std::function<bool()> &cb) = 0;
virtual void UpdatePkgContextInfoJson(std::string moduleName, std::string hapPath, std::string packageName) = 0;
Runtime(const Runtime&) = delete;
Runtime(Runtime&&) = delete;
Runtime& operator=(const Runtime&) = delete;
-1
View File
@@ -18,7 +18,6 @@ group("unittest") {
testonly = true
deps = [
"js_env_log_unit_test:unittest",
"js_environment_test:unittest",
"source_map_test:unittest",
"uncaught_exception_callback_test:unittest",
@@ -1,37 +0,0 @@
# 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("../../../js_environment.gni")
module_output_path = "ability_runtime/js_environment"
ohos_unittest("js_env_log_test") {
module_out_path = module_output_path
include_dirs = [ "${utils_path}/include" ]
sources = [ "js_env_log_unit_test.cpp" ]
configs = []
external_deps = [
"ability_runtime:js_environment",
"c_utils:utils",
"hilog:libhilog",
]
}
group("unittest") {
testonly = true
deps = [ ":js_env_log_test" ]
}
@@ -1,122 +0,0 @@
/*
* 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 <gtest/gtest.h>
#include <cstdarg>
#include "js_env_logger.h"
#include "hilog/log.h"
#include <string>
using namespace testing;
using namespace testing::ext;
#ifndef ENV_LOG_DOMAIN
#define ENV_LOG_DOMAIN 0xD001300
#endif
#ifndef ENV_LOG_TAG
#define ENV_LOG_TAG "JsEnv"
#endif
namespace OHOS {
namespace JsEnv {
void Logger(JsEnvLogLevel level, const char* fileName, const char* functionName, int line,
const char* fmt, ...)
{
std::string cFormat = "[%{public}s(%{public}s:%{public}d)]";
cFormat += fmt;
va_list printArgs;
va_start(printArgs, fmt);
switch (level) {
case JsEnvLogLevel::DEBUG:
HILOG_IMPL(LOG_CORE, LOG_DEBUG, ENV_LOG_DOMAIN, ENV_LOG_TAG,
cFormat.c_str(), fileName, functionName, line, printArgs);
break;
case JsEnvLogLevel::INFO:
HILOG_IMPL(LOG_CORE, LOG_INFO, ENV_LOG_DOMAIN, ENV_LOG_TAG,
cFormat.c_str(), fileName, functionName, line, printArgs);
break;
case JsEnvLogLevel::WARN:
HILOG_IMPL(LOG_CORE, LOG_WARN, ENV_LOG_DOMAIN, ENV_LOG_TAG,
cFormat.c_str(), fileName, functionName, line, printArgs);
break;
case JsEnvLogLevel::ERROR:
HILOG_IMPL(LOG_CORE, LOG_ERROR, ENV_LOG_DOMAIN, ENV_LOG_TAG,
cFormat.c_str(), fileName, functionName, line, printArgs);
break;
case JsEnvLogLevel::FATAL:
HILOG_IMPL(LOG_CORE, LOG_FATAL, ENV_LOG_DOMAIN, ENV_LOG_TAG,
cFormat.c_str(), fileName, functionName, line, printArgs);
break;
default:
break;
}
va_end(printArgs);
}
class JsEnvLogTest : public testing::Test {
public:
static void SetUpTestCase();
static void TearDownTestCase();
void SetUp() override;
void TearDown() override;
};
void JsEnvLogTest::SetUpTestCase()
{
JsEnvLogger::logger = Logger;
}
void JsEnvLogTest::TearDownTestCase()
{}
void JsEnvLogTest::SetUp()
{}
void JsEnvLogTest::TearDown()
{}
/**
* @tc.name: Logger_0100
* @tc.desc: Logger_0100 Test
* @tc.type: FUNC
* @tc.require: issueI6I13A
*/
HWTEST_F(JsEnvLogTest, Logger_0100, TestSize.Level0)
{
JSENV_LOG_D(">>>>>>>>TestDebug<<<<<<<<<<<");
JSENV_LOG_I(">>>>>>>>TestInfo<<<<<<<<<<<");
JSENV_LOG_W(">>>>>>>>TestWarning<<<<<<<<<<<");
JSENV_LOG_E(">>>>>>>>TestError<<<<<<<<<<<");
JSENV_LOG_F(">>>>>>>>TestFatal<<<<<<<<<<<");
}
/**
* @tc.name: Logger_0200
* @tc.desc: Logger_0200 Test
* @tc.type: FUNC
* @tc.require: issueI6I13A
*/
HWTEST_F(JsEnvLogTest, Logger_0200, TestSize.Level0)
{
JSENV_LOG_D(">>>>>>>>TestDebug<<<<<<<<<<< + %s", "with string");
JSENV_LOG_I(">>>>>>>>TestInfo<<<<<<<<<<< + %s", "with string");
JSENV_LOG_W(">>>>>>>>TestWarning<<<<<<<<<<< + %s", "with string");
JSENV_LOG_E(">>>>>>>>TestError<<<<<<<<<<< + %s + %d", "with int", 32);
JSENV_LOG_F(">>>>>>>>TestFatal<<<<<<<<<<< + %s", "with string");
}
} // namespace JsEnv
} // namespace OHOS
@@ -238,7 +238,7 @@ napi_value QueryBusinessAbilityInfos(napi_env env, napi_callback_info info)
if (args.GetMaxArgc() >= ARGS_SIZE_ONE) {
if (!ParseBusinessAbilityInfo(env, args[ARGS_POS_ZERO], asyncCallbackInfo->filter)) {
BusinessError::ThrowParameterTypeError(env, ERROR_PARAM_CHECK_ERROR, TYPE_BUSINESS_AIBILITY_FILTER,
TYPE_STRING);
"BusinessAbilityFilter");
return nullptr;
}
if (args.GetMaxArgc() == ARGS_SIZE_TWO) {
@@ -22,6 +22,7 @@
namespace OHOS {
namespace AAFwk {
using InterceptorMap = std::unordered_map<std::string, std::shared_ptr<IAbilityInterceptor>>;
/**
* @class AbilityInterceptorExecuter
* AbilityInterceptorExecuter excute the interceptors.
@@ -47,6 +48,8 @@ public:
ErrCode DoProcess(AbilityInterceptorParam param);
void SetTaskHandler(std::shared_ptr<AAFwk::TaskHandlerWrap> taskHandler);
private:
InterceptorMap GetInterceptorMapCopy();
private:
std::mutex interceptorMapLock_;
std::unordered_map<std::string, std::shared_ptr<IAbilityInterceptor>> interceptorMap_;
@@ -413,6 +413,10 @@ AutoStartupInfo AbilityAutoStartupDataManager::ConvertAutoStartupInfoFromKeyAndV
info.appCloneIndex = jsonObject.at(JSON_KEY_APP_CLONE_INDEX).get<std::int32_t>();
}
if (jsonObject.contains(JSON_KEY_ACCESS_TOKENID) && jsonObject[JSON_KEY_ACCESS_TOKENID].is_string()) {
info.accessTokenId = jsonObject.at(JSON_KEY_ACCESS_TOKENID).get<std::string>();
}
nlohmann::json jsonValueObject = nlohmann::json::parse(value.ToString(), nullptr, false);
if (jsonValueObject.is_discarded()) {
TAG_LOGE(AAFwkTag::AUTO_STARTUP, "Failed to parse jsonValueObject.");
@@ -422,10 +426,6 @@ AutoStartupInfo AbilityAutoStartupDataManager::ConvertAutoStartupInfoFromKeyAndV
if (jsonValueObject.contains(JSON_KEY_TYPE_NAME) && jsonValueObject[JSON_KEY_TYPE_NAME].is_string()) {
info.abilityTypeName = jsonValueObject.at(JSON_KEY_TYPE_NAME).get<std::string>();
}
if (jsonValueObject.contains(JSON_KEY_ACCESS_TOKENID) && jsonValueObject[JSON_KEY_ACCESS_TOKENID].is_string()) {
info.accessTokenId = jsonValueObject.at(JSON_KEY_ACCESS_TOKENID).get<std::string>();
}
return info;
}
@@ -2901,7 +2901,7 @@ EventInfo AbilityConnectManager::BuildEventInfo(const std::shared_ptr<AbilityRec
eventInfo.time = std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::system_clock::now().time_since_epoch()).count();
auto callerPid = abilityRecord->GetWant().GetIntParam(Want::PARAM_RESV_CALLER_PID, -1);
eventInfo.callerPid = callerPid == -1 ? IPCSkeleton::GetCallingRealPid() : callerPid;
eventInfo.callerPid = callerPid == -1 ? IPCSkeleton::GetCallingPid() : callerPid;
DelayedSingleton<AppScheduler>::GetInstance()->GetRunningProcessInfoByPid(eventInfo.callerPid, processInfo);
eventInfo.callerPid = processInfo.pid_;
eventInfo.callerProcessName = processInfo.processName_;
@@ -1823,7 +1823,7 @@ int32_t AbilityManagerService::ReportDrawnCompleted(const sptr<IRemoteObject> &c
EventInfo eventInfo;
eventInfo.userId = IPCSkeleton::GetCallingUid() / BASE_USER_RANGE;
eventInfo.pid = IPCSkeleton::GetCallingRealPid();
eventInfo.pid = IPCSkeleton::GetCallingPid();
eventInfo.bundleName = abilityInfo.bundleName;
eventInfo.moduleName = abilityInfo.moduleName;
eventInfo.abilityName = abilityInfo.name;
@@ -5992,7 +5992,7 @@ int32_t AbilityManagerService::UpgradeApp(const std::string &bundleName, const i
int32_t AbilityManagerService::UninstallAppInner(const std::string &bundleName, const int32_t uid, const bool isUpgrade,
const std::string &exitMsg)
{
pid_t callingPid = IPCSkeleton::GetCallingRealPid();
pid_t callingPid = IPCSkeleton::GetCallingPid();
pid_t pid = getprocpid();
if (callingPid != pid) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "%{public}s: Not bundleMgr call.", __func__);
@@ -7608,7 +7608,7 @@ int AbilityManagerService::DelegatorDoAbilityForeground(const sptr<IRemoteObject
CHECK_POINTER_AND_RETURN(token, ERR_INVALID_VALUE);
auto &&abilityRecord = Token::GetAbilityRecordByToken(token);
CHECK_POINTER_AND_RETURN(abilityRecord, ERR_INVALID_VALUE);
int32_t callerPid = IPCSkeleton::GetCallingRealPid();
int32_t callerPid = IPCSkeleton::GetCallingPid();
int32_t appPid = abilityRecord->GetPid();
TAG_LOGD(AAFwkTag::ABILITYMGR, "callerPid: %{public}d, appPid: %{public}d", callerPid, appPid);
if (callerPid != appPid) {
@@ -7644,7 +7644,7 @@ int AbilityManagerService::DelegatorDoAbilityBackground(const sptr<IRemoteObject
auto &&abilityRecord = Token::GetAbilityRecordByToken(token);
CHECK_POINTER_AND_RETURN(abilityRecord, ERR_INVALID_VALUE);
int32_t appPid = abilityRecord->GetPid();
int32_t callerPid = IPCSkeleton::GetCallingRealPid();
int32_t callerPid = IPCSkeleton::GetCallingPid();
TAG_LOGD(AAFwkTag::ABILITYMGR, "callerPid: %{public}d, appPid: %{public}d", callerPid, appPid);
if (callerPid != appPid) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "Caller is not the application itself");
@@ -7721,7 +7721,7 @@ void AbilityManagerService::UpdateCallerInfo(Want& want, const sptr<IRemoteObjec
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
int32_t tokenId = static_cast<int32_t>(IPCSkeleton::GetCallingTokenID());
int32_t callerUid = IPCSkeleton::GetCallingUid();
int32_t callerPid = IPCSkeleton::GetCallingRealPid();
int32_t callerPid = IPCSkeleton::GetCallingPid();
want.RemoveParam(Want::PARAM_RESV_CALLER_TOKEN);
want.SetParam(Want::PARAM_RESV_CALLER_TOKEN, tokenId);
want.RemoveParam(Want::PARAM_RESV_CALLER_UID);
@@ -8897,7 +8897,7 @@ int AbilityManagerService::IsCallFromBackground(const AbilityRequest &abilityReq
return ERR_OK;
}
} else {
auto callerPid = IPCSkeleton::GetCallingRealPid();
auto callerPid = IPCSkeleton::GetCallingPid();
DelayedSingleton<AppScheduler>::GetInstance()->GetRunningProcessInfoByPid(callerPid, processInfo);
if (processInfo.processName_.empty()) {
TAG_LOGD(AAFwkTag::ABILITYMGR, "Can not find caller application by callerPid: %{private}d.", callerPid);
@@ -9069,7 +9069,7 @@ int AbilityManagerService::CheckDlpForExtension(
bool AbilityManagerService::JudgeSelfCalled(const std::shared_ptr<AbilityRecord> &abilityRecord)
{
if (IPCSkeleton::GetCallingRealPid() == getprocpid()) {
if (IPCSkeleton::GetCallingPid() == getprocpid()) {
return true;
}
@@ -10165,7 +10165,7 @@ int32_t AbilityManagerService::SetResidentProcessEnabled(const std::string &bund
std::string callerName;
int32_t uid = 0;
auto callerPid = IPCSkeleton::GetCallingRealPid();
auto callerPid = IPCSkeleton::GetCallingPid();
DelayedSingleton<AppScheduler>::GetInstance()->GetBundleNameByPid(callerPid, callerName, uid);
if (callerName.empty()) {
HILOG_ERROR("Failed to obtain caller name.");
@@ -10559,7 +10559,7 @@ void AbilityManagerService::ReportPreventStartAbilityResult(const AppExecFwk::Ab
const AppExecFwk::AbilityInfo &abilityInfo)
{
int32_t callerUid = IPCSkeleton::GetCallingUid();
int32_t callerPid = IPCSkeleton::GetCallingRealPid();
int32_t callerPid = IPCSkeleton::GetCallingPid();
int32_t extensionAbilityType = static_cast<int32_t>(abilityInfo.extensionAbilityType);
TAG_LOGD(AAFwkTag::ABILITYMGR,
"Prevent start ability debug log CALLER_BUNDLE_NAME %{public}s CALLEE_BUNDLE_NAME"
+8 -1
View File
@@ -26,6 +26,7 @@
#include "ability_resident_process_rdb.h"
#include "ability_scheduler_stub.h"
#include "ability_util.h"
#include "app_exit_reason_data_manager.h"
#include "app_utils.h"
#include "appfreeze_manager.h"
#include "array_wrapper.h"
@@ -1270,6 +1271,12 @@ int AbilityRecord::TerminateAbility()
AAFwk::EventInfo eventInfo;
eventInfo.bundleName = GetAbilityInfo().bundleName;
eventInfo.abilityName = GetAbilityInfo().name;
if (clearMissionFlag_) {
TAG_LOGI(AAFwkTag::ABILITYMGR, "deleteAbilityRecoverInfo before clearMission.");
(void)DelayedSingleton<AbilityRuntime::AppExitReasonDataManager>::GetInstance()->
DeleteAbilityRecoverInfo(GetAbilityInfo().applicationInfo.accessTokenId, GetAbilityInfo().moduleName,
GetAbilityInfo().name);
}
AAFwk::EventReport::SendAbilityEvent(AAFwk::EventName::TERMINATE_ABILITY, HiSysEventType::BEHAVIOR, eventInfo);
eventInfo.errCode = DelayedSingleton<AppScheduler>::GetInstance()->TerminateAbility(token_, clearMissionFlag_);
if (eventInfo.errCode != ERR_OK) {
@@ -1439,7 +1446,7 @@ void AbilityRecord::SetScheduler(const sptr<IAbilityScheduler> &scheduler)
if (IsSceneBoard()) {
TAG_LOGI(AAFwkTag::ABILITYMGR, "Sceneboard DeathRecipient Added");
}
pid_ = static_cast<int32_t>(IPCSkeleton::GetCallingRealPid()); // set pid when ability attach to service.
pid_ = static_cast<int32_t>(IPCSkeleton::GetCallingPid()); // set pid when ability attach to service.
// add collaborator mission bind pid
NotifyMissionBindPid();
HandleDlpAttached();
@@ -49,7 +49,7 @@ int32_t AppExitReasonHelper::RecordAppExitReason(const ExitReason &exitReason)
return ERR_INVALID_VALUE;
}
auto pid = IPCSkeleton::GetCallingRealPid();
auto pid = IPCSkeleton::GetCallingPid();
AppExecFwk::ApplicationInfo application;
bool debug = false;
auto ret = IN_PROCESS_CALL(DelayedSingleton<AppScheduler>::GetInstance()->GetApplicationInfoByProcessID(pid,
@@ -56,7 +56,7 @@ void AssertFaultCallbackDeathMgr::AddAssertFaultCallback(sptr<IRemoteObject> &re
});
remote->AddDeathRecipient(deathRecipient);
auto callerPid = IPCSkeleton::GetCallingRealPid();
auto callerPid = IPCSkeleton::GetCallingPid();
uint64_t assertFaultSessionId = reinterpret_cast<uint64_t>(remote.GetRefPtr());
std::unique_lock<std::mutex> lock(assertFaultSessionMutex_);
assertFaultSessionDialogs_[assertFaultSessionId] = {callerPid, remote, deathRecipient, callback};
@@ -270,7 +270,7 @@ void ConnectionRecord::AttachCallerInfo()
}
callerUid_ = static_cast<int32_t>(IPCSkeleton::GetCallingUid());
callerPid_ = static_cast<int32_t>(IPCSkeleton::GetCallingRealPid());
callerPid_ = static_cast<int32_t>(IPCSkeleton::GetCallingPid());
callerName_ = ConnectionStateManager::GetProcessNameByPid(callerPid_);
}
@@ -683,7 +683,7 @@ void DataAbilityManager::ReportDataAbilityAcquired(const sptr<IRemoteObject> &cl
{
DataAbilityCaller caller;
caller.isNotHap = isNotHap;
caller.callerPid = IPCSkeleton::GetCallingRealPid();
caller.callerPid = IPCSkeleton::GetCallingPid();
caller.callerUid = IPCSkeleton::GetCallingUid();
caller.callerToken = client;
if (client && !isNotHap) {
@@ -703,7 +703,7 @@ void DataAbilityManager::ReportDataAbilityReleased(const sptr<IRemoteObject> &cl
{
DataAbilityCaller caller;
caller.isNotHap = isNotHap;
caller.callerPid = IPCSkeleton::GetCallingRealPid();
caller.callerPid = IPCSkeleton::GetCallingPid();
caller.callerUid = IPCSkeleton::GetCallingUid();
caller.callerToken = client;
DelayedSingleton<ConnectionStateManager>::GetInstance()->RemoveDataAbilityConnection(caller, record);
@@ -228,7 +228,7 @@ int DataAbilityRecord::AddClient(const sptr<IRemoteObject> &client, bool tryBind
clientInfo.client = client;
clientInfo.tryBind = tryBind;
clientInfo.isNotHap = isNotHap;
clientInfo.clientPid = IPCSkeleton::GetCallingRealPid();
clientInfo.clientPid = IPCSkeleton::GetCallingPid();
return ERR_OK;
}
@@ -633,7 +633,7 @@ void ImplicitStartProcessor::GetEcologicalCallerInfo(const Want &want, ErmsCalle
{
callerInfo.packageName = want.GetStringParam(Want::PARAM_RESV_CALLER_BUNDLE_NAME);
callerInfo.uid = want.GetIntParam(Want::PARAM_RESV_CALLER_UID, IPCSkeleton::GetCallingUid());
callerInfo.pid = want.GetIntParam(Want::PARAM_RESV_CALLER_PID, IPCSkeleton::GetCallingRealPid());
callerInfo.pid = want.GetIntParam(Want::PARAM_RESV_CALLER_PID, IPCSkeleton::GetCallingPid());
callerInfo.targetAppType = ErmsCallerInfo::TYPE_INVALID;
callerInfo.callerAppType = ErmsCallerInfo::TYPE_INVALID;
@@ -41,9 +41,9 @@ ErrCode AbilityInterceptorExecuter::DoProcess(AbilityInterceptorParam param)
{
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
int32_t result = ERR_OK;
std::lock_guard lock(interceptorMapLock_);
auto item = interceptorMap_.begin();
while (item != interceptorMap_.end()) {
auto interceptorMap = GetInterceptorMapCopy();
auto item = interceptorMap.begin();
while (item != interceptorMap.end()) {
result = (*item).second->DoProcess(param);
if (result != ERR_OK) {
break;
@@ -66,5 +66,11 @@ void AbilityInterceptorExecuter::SetTaskHandler(std::shared_ptr<AAFwk::TaskHandl
(item.second)->SetTaskHandler(taskHandler);
}
}
InterceptorMap AbilityInterceptorExecuter::GetInterceptorMapCopy()
{
std::lock_guard lock(interceptorMapLock_);
return interceptorMap_;
}
} // namespace AAFwk
} // namespace OHOS
@@ -181,7 +181,7 @@ void EcologicalRuleInterceptor::InitErmsCallerInfo(Want &want, ErmsCallerInfo &c
{
callerInfo.packageName = want.GetStringParam(Want::PARAM_RESV_CALLER_BUNDLE_NAME);
callerInfo.uid = want.GetIntParam(Want::PARAM_RESV_CALLER_UID, IPCSkeleton::GetCallingUid());
callerInfo.pid = want.GetIntParam(Want::PARAM_RESV_CALLER_PID, IPCSkeleton::GetCallingRealPid());
callerInfo.pid = want.GetIntParam(Want::PARAM_RESV_CALLER_PID, IPCSkeleton::GetCallingPid());
callerInfo.targetAppType = ErmsCallerInfo::TYPE_INVALID;
callerInfo.callerAppType = ErmsCallerInfo::TYPE_INVALID;
callerInfo.targetLinkFeature = want.GetStringParam("send_to_erms_targetLinkFeature");
@@ -46,6 +46,12 @@ ErrCode ScreenUnlockInterceptor::DoProcess(AbilityInterceptorParam param)
}
IN_PROCESS_CALL_WITHOUT_RET(bundleMgrHelper->QueryAbilityInfo(param.want,
AppExecFwk::AbilityInfoFlag::GET_ABILITY_INFO_WITH_APPLICATION, param.userId, targetAbilityInfo));
if (targetAbilityInfo.applicationInfo.name.empty() ||
targetAbilityInfo.applicationInfo.bundleName.empty()) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "Cannot find targetAbilityInfo, element uri: %{public}s",
param.want.GetElement().GetURI().c_str());
return ERR_OK;
}
}
// temp add isSystemApp pass, remove after systemapp adjust
@@ -110,7 +110,7 @@ bool StartOtherAppInterceptor::GetApplicationInfo(const sptr<IRemoteObject> &cal
AppExecFwk::ApplicationInfo &applicationInfo)
{
if (callerToken == nullptr) {
int32_t callerPid = IPCSkeleton::GetCallingRealPid();
int32_t callerPid = IPCSkeleton::GetCallingPid();
auto appScheduler = DelayedSingleton<AppScheduler>::GetInstance();
bool debug;
if (appScheduler != nullptr &&
@@ -148,7 +148,7 @@ bool StartOtherAppInterceptor::IsDelegatorCall(const Want want)
{
AppExecFwk::RunningProcessInfo processInfo;
DelayedSingleton<AppScheduler>::GetInstance()->
GetRunningProcessInfoByPid(IPCSkeleton::GetCallingRealPid(), processInfo);
GetRunningProcessInfoByPid(IPCSkeleton::GetCallingPid(), processInfo);
if (processInfo.isTestProcess && want.GetBoolParam(IS_DELEGATOR_CALL, false)) {
return true;
}
@@ -77,6 +77,7 @@ namespace AppExecFwk {
using OHOS::AAFwk::Want;
class WindowFocusChangedListener;
class WindowVisibilityChangedListener;
using LoabAbilityTaskFunc = std::function<void()>;
class AppMgrServiceInner : public std::enable_shared_from_this<AppMgrServiceInner> {
public:
@@ -1100,6 +1101,14 @@ public:
bool IsAppProcessesAllCached(const std::string &bundleName, int32_t uid,
const std::set<std::shared_ptr<AppRunningRecord>> &cachedSet);
bool GetSceneBoardAttachFlag() const;
void SetSceneBoardAttachFlag(bool flag);
void CacheLoabAbilityTask(const LoabAbilityTaskFunc& func);
void SubmitCacheLoabAbilityTask();
private:
std::string FaultTypeToString(FaultDataType type);
@@ -1525,6 +1534,8 @@ private:
std::shared_ptr<AAFwk::TaskHandlerWrap> dfxTaskHandler_;
std::shared_ptr<AAFwk::TaskHandlerWrap> otherTaskHandler_;
std::shared_ptr<AppPreloader> appPreloader_;
std::atomic<bool> sceneBoardAttachFlag_ = true;
std::vector<LoabAbilityTaskFunc> loadAbilityTaskFuncList_;
};
} // namespace AppExecFwk
} // namespace OHOS
+24 -2
View File
@@ -44,6 +44,10 @@ constexpr const char* TASK_ATTACH_PID_TO_PARENT = "AttachPidToParent";
constexpr const char* TASK_KILL_APPLICATION = "KillApplicationTask";
constexpr const char* TASK_CLEAR_PROCESS_BY_ABILITY_TOKEN = "ClearProcessByAbilityTokenTask";
constexpr const char* FOUNDATION_NAME = "foundation";
constexpr const char* SCENE_BOARD_BUNDLE_NAME = "com.ohos.sceneboard";
constexpr const char* SCENEBOARD_ABILITY_NAME = "com.ohos.sceneboard.MainAbility";
constexpr const char* TASK_SCENE_BOARD_ATTACH_TIMEOUT = "sceneBoardAttachTimeoutTask";
constexpr int32_t SCENE_BOARD_ATTACH_TIMEOUT_TASK_TIME = 1000;
}; // namespace
AmsMgrScheduler::AmsMgrScheduler(
@@ -81,6 +85,24 @@ void AmsMgrScheduler::LoadAbility(const sptr<IRemoteObject> &token, const sptr<I
std::bind(&AppMgrServiceInner::LoadAbility, amsMgrServiceInner_, token, preToken, abilityInfo,
appInfo, want, abilityRecordId);
// cache other application load ability task before scene board attach
if (!amsMgrServiceInner_->GetSceneBoardAttachFlag() && abilityInfo->bundleName != SCENE_BOARD_BUNDLE_NAME) {
amsMgrServiceInner_->CacheLoabAbilityTask(loadAbilityFunc);
return;
}
if (abilityInfo->bundleName == SCENE_BOARD_BUNDLE_NAME && abilityInfo->name == SCENEBOARD_ABILITY_NAME) {
amsMgrServiceInner_->SetSceneBoardAttachFlag(false);
// set scene board attach timeout task
std::weak_ptr<AppMgrServiceInner> amsMgrServiceInner = amsMgrServiceInner_;
auto timeoutTask = [amsMgrServiceInner]() {
auto inner = amsMgrServiceInner.lock();
if (inner != nullptr) {
inner->SetSceneBoardAttachFlag(true);
}
};
amsHandler_->SubmitTask(timeoutTask, TASK_SCENE_BOARD_ATTACH_TIMEOUT, SCENE_BOARD_ATTACH_TIMEOUT_TASK_TIME);
}
amsHandler_->SubmitTask(loadAbilityFunc);
}
@@ -211,7 +233,7 @@ void AmsMgrScheduler::KillProcessesByPids(std::vector<int32_t> &pids)
return;
}
pid_t callingPid = IPCSkeleton::GetCallingRealPid();
pid_t callingPid = IPCSkeleton::GetCallingPid();
pid_t pid = getprocpid();
if (callingPid != pid) {
TAG_LOGE(AAFwkTag::APPMGR, "Not allow other process to call.");
@@ -229,7 +251,7 @@ void AmsMgrScheduler::AttachPidToParent(const sptr<IRemoteObject> &token, const
return;
}
pid_t callingPid = IPCSkeleton::GetCallingRealPid();
pid_t callingPid = IPCSkeleton::GetCallingPid();
pid_t pid = getprocpid();
if (callingPid != pid) {
TAG_LOGE(AAFwkTag::APPMGR, "Not allow other process to call.");
+1 -1
View File
@@ -104,7 +104,7 @@ bool AppMgrEventUtil::SendProcessStartEvent(const std::shared_ptr<AppRunningReco
Security::AccessToken::AccessTokenKit::GetNativeTokenInfo(token, nativeTokenInfo);
eventInfo.callerBundleName = "";
eventInfo.callerProcessName = nativeTokenInfo.processName;
eventInfo.callerPid = IPCSkeleton::GetCallingRealPid();
eventInfo.callerPid = IPCSkeleton::GetCallingPid();
} else {
if (callerAppRecord->GetBundleName().empty()) {
eventInfo.callerBundleName = callerAppRecord->GetName();
+12 -12
View File
@@ -183,7 +183,7 @@ void AppMgrService::AttachApplication(const sptr<IRemoteObject> &app)
return;
}
pid_t pid = IPCSkeleton::GetCallingRealPid();
pid_t pid = IPCSkeleton::GetCallingPid();
std::function<void()> attachApplicationFunc =
std::bind(&AppMgrServiceInner::AttachApplication, appMgrServiceInner_, pid, iface_cast<IAppScheduler>(app));
taskHandler_->SubmitTask(attachApplicationFunc, AAFwk::TaskAttribute{
@@ -288,7 +288,7 @@ void AppMgrService::StartupResidentProcess(const std::vector<AppExecFwk::BundleI
if (!IsReady()) {
return;
}
pid_t callingPid = IPCSkeleton::GetCallingRealPid();
pid_t callingPid = IPCSkeleton::GetCallingPid();
pid_t pid = getprocpid();
if (callingPid != pid) {
TAG_LOGE(AAFwkTag::APPMGR, "Not this process call.");
@@ -339,7 +339,7 @@ int32_t AppMgrService::ClearUpApplicationData(const std::string &bundleName, con
}
}
int32_t uid = IPCSkeleton::GetCallingUid();
pid_t pid = IPCSkeleton::GetCallingRealPid();
pid_t pid = IPCSkeleton::GetCallingPid();
appMgrServiceInner_->ClearUpApplicationData(bundleName, uid, pid, userId);
return ERR_OK;
}
@@ -350,7 +350,7 @@ int32_t AppMgrService::ClearUpApplicationDataBySelf(int32_t userId)
return ERR_INVALID_OPERATION;
}
int32_t uid = IPCSkeleton::GetCallingUid();
pid_t pid = IPCSkeleton::GetCallingRealPid();
pid_t pid = IPCSkeleton::GetCallingPid();
return appMgrServiceInner_->ClearUpApplicationDataBySelf(uid, pid, userId);
}
@@ -589,7 +589,7 @@ int AppMgrService::FinishUserTest(const std::string &msg, const int64_t &resultC
TAG_LOGE(AAFwkTag::APPMGR, "GetBundleName failed: %{public}d.", result);
return ERR_INVALID_OPERATION;
}
pid_t callingPid = IPCSkeleton::GetCallingRealPid();
pid_t callingPid = IPCSkeleton::GetCallingPid();
std::function<void()> finishUserTestProcessFunc =
std::bind(&AppMgrServiceInner::FinishUserTest, appMgrServiceInner_, msg, resultCode, bundleName, callingPid);
taskHandler_->SubmitTask(finishUserTestProcessFunc, TASK_FINISH_USER_TEST);
@@ -934,7 +934,7 @@ int32_t AppMgrService::PreStartNWebSpawnProcess()
return ERR_INVALID_OPERATION;
}
return appMgrServiceInner_->PreStartNWebSpawnProcess(IPCSkeleton::GetCallingRealPid());
return appMgrServiceInner_->PreStartNWebSpawnProcess(IPCSkeleton::GetCallingPid());
}
int32_t AppMgrService::StartRenderProcess(const std::string &renderParam, int32_t ipcFd,
@@ -945,7 +945,7 @@ int32_t AppMgrService::StartRenderProcess(const std::string &renderParam, int32_
return ERR_INVALID_OPERATION;
}
return appMgrServiceInner_->StartRenderProcess(IPCSkeleton::GetCallingRealPid(),
return appMgrServiceInner_->StartRenderProcess(IPCSkeleton::GetCallingPid(),
renderParam, ipcFd, sharedFd, crashFd, renderPid, isGPU);
}
@@ -957,7 +957,7 @@ void AppMgrService::AttachRenderProcess(const sptr<IRemoteObject> &scheduler)
return;
}
auto pid = IPCSkeleton::GetCallingRealPid();
auto pid = IPCSkeleton::GetCallingPid();
auto fun = std::bind(&AppMgrServiceInner::AttachRenderProcess,
appMgrServiceInner_, pid, iface_cast<IRenderScheduler>(scheduler));
taskHandler_->SubmitTask(fun, AAFwk::TaskAttribute{
@@ -973,7 +973,7 @@ void AppMgrService::SaveBrowserChannel(sptr<IRemoteObject> browser)
return;
}
appMgrServiceInner_->SaveBrowserChannel(IPCSkeleton::GetCallingRealPid(), browser);
appMgrServiceInner_->SaveBrowserChannel(IPCSkeleton::GetCallingPid(), browser);
}
int32_t AppMgrService::GetRenderProcessTerminationStatus(pid_t renderPid, int &status)
@@ -1344,7 +1344,7 @@ int32_t AppMgrService::StartChildProcess(const std::string &srcEntry, pid_t &chi
TAG_LOGE(AAFwkTag::APPMGR, "StartChildProcess failed, AppMgrService not ready.");
return ERR_INVALID_OPERATION;
}
return appMgrServiceInner_->StartChildProcess(IPCSkeleton::GetCallingRealPid(), srcEntry, childPid,
return appMgrServiceInner_->StartChildProcess(IPCSkeleton::GetCallingPid(), srcEntry, childPid,
childProcessCount, isStartWithDebug);
}
@@ -1368,7 +1368,7 @@ void AppMgrService::AttachChildProcess(const sptr<IRemoteObject> &childScheduler
TAG_LOGE(AAFwkTag::APPMGR, "taskHandler_ is null.");
return;
}
pid_t pid = IPCSkeleton::GetCallingRealPid();
pid_t pid = IPCSkeleton::GetCallingPid();
std::function<void()> task = std::bind(&AppMgrServiceInner::AttachChildProcess,
appMgrServiceInner_, pid, iface_cast<IChildScheduler>(childScheduler));
taskHandler_->SubmitTask(task, AAFwk::TaskAttribute{
@@ -1387,7 +1387,7 @@ void AppMgrService::ExitChildProcessSafely()
TAG_LOGE(AAFwkTag::APPMGR, "taskHandler_ is null.");
return;
}
pid_t pid = IPCSkeleton::GetCallingRealPid();
pid_t pid = IPCSkeleton::GetCallingPid();
std::function<void()> task = std::bind(&AppMgrServiceInner::ExitChildProcessSafelyByChildPid,
appMgrServiceInner_, pid);
taskHandler_->SubmitTask(task, AAFwk::TaskAttribute{
+61 -30
View File
@@ -110,6 +110,12 @@ namespace {
return ERR_PERMISSION_DENIED; \
}
#define CHECK_POINTER_AND_RETURN_LOG(object, log) \
if (!object) { \
TAG_LOGE(AAFwkTag::APPMGR, "%{public}s", log); \
return; \
}
// NANOSECONDS mean 10^9 nano second
constexpr int64_t NANOSECONDS = 1000000000;
// MICROSECONDS mean 10^6 milli second
@@ -829,10 +835,7 @@ void AppMgrServiceInner::AttachApplication(const pid_t pid, const sptr<IAppSched
return;
}
auto appRecord = GetAppRunningRecordByPid(pid);
if (!appRecord) {
TAG_LOGE(AAFwkTag::APPMGR, "no such appRecord");
return;
}
CHECK_POINTER_AND_RETURN_LOG(appRecord, "no such appRecord");
auto applicationInfo = appRecord->GetApplicationInfo();
AAFwk::EventInfo eventInfo;
if (!applicationInfo) {
@@ -845,16 +848,10 @@ void AppMgrServiceInner::AttachApplication(const pid_t pid, const sptr<IAppSched
std::string connector = "##";
std::string traceName = __PRETTY_FUNCTION__ + connector + eventInfo.bundleName;
HITRACE_METER_NAME(HITRACE_TAG_APP, traceName);
if (!appScheduler) {
TAG_LOGE(AAFwkTag::APPMGR, "app client is null");
return;
}
CHECK_POINTER_AND_RETURN_LOG(appScheduler, "app client is null");
TAG_LOGI(AAFwkTag::APPMGR, "attach, pid:%{public}d.", pid);
sptr<AppDeathRecipient> appDeathRecipient = new (std::nothrow) AppDeathRecipient();
if (appDeathRecipient == nullptr) {
TAG_LOGE(AAFwkTag::APPMGR, "Failed to create death recipient.");
return;
}
CHECK_POINTER_AND_RETURN_LOG(appDeathRecipient, "Failed to create death recipient.");
appDeathRecipient->SetTaskHandler(taskHandler_);
appDeathRecipient->SetAppMgrServiceInner(shared_from_this());
auto object = appScheduler->AsObject();
@@ -868,6 +865,12 @@ void AppMgrServiceInner::AttachApplication(const pid_t pid, const sptr<IAppSched
if (appRecord->GetState() == ApplicationState::APP_STATE_CREATE) {
LaunchApplication(appRecord);
}
// submit cached load ability task after scene board attach
if (appRecord->GetBundleName() == SCENE_BOARD_BUNDLE_NAME) {
sceneBoardAttachFlag_ = true;
SubmitCacheLoabAbilityTask();
}
eventInfo.pid = appRecord->GetPriorityObject()->GetPid();
eventInfo.processName = appRecord->GetProcessName();
AAFwk::EventReport::SendAppEvent(AAFwk::EventName::APP_ATTACH, HiSysEventType::BEHAVIOR, eventInfo);
@@ -972,7 +975,7 @@ void AppMgrServiceInner::ApplicationForegrounded(const int32_t recordId)
eventInfo.processName = appRecord->GetProcessName();
eventInfo.processType = static_cast<int32_t>(appRecord->GetProcessType());
int32_t callerPid = appRecord->GetCallerPid() == -1 ?
IPCSkeleton::GetCallingRealPid() : appRecord->GetCallerPid();
IPCSkeleton::GetCallingPid() : appRecord->GetCallerPid();
auto callerRecord = GetAppRunningRecordByPid(callerPid);
if (callerRecord != nullptr) {
eventInfo.callerBundleName = callerRecord->GetBundleName();
@@ -1240,7 +1243,7 @@ int32_t AppMgrServiceInner::KillApplicationSelf()
return ERR_NO_INIT;
}
auto callerPid = IPCSkeleton::GetCallingRealPid();
auto callerPid = IPCSkeleton::GetCallingPid();
auto appRecord = GetAppRunningRecordByPid(callerPid);
if (!appRecord) {
TAG_LOGE(AAFwkTag::APPMGR, "no such appRecord, callerPid:%{public}d", callerPid);
@@ -1577,7 +1580,7 @@ int32_t AppMgrServiceInner::GetProcessRunningInformation(RunningProcessInfo &inf
TAG_LOGE(AAFwkTag::APPMGR, "appRunningManager_ is nullptr");
return ERR_NO_INIT;
}
auto callerPid = IPCSkeleton::GetCallingRealPid();
auto callerPid = IPCSkeleton::GetCallingPid();
auto appRecord = GetAppRunningRecordByPid(callerPid);
if (!appRecord) {
TAG_LOGE(AAFwkTag::APPMGR, "no such appRecord, callerPid:%{public}d", callerPid);
@@ -2083,7 +2086,7 @@ void AppMgrServiceInner::SetBundleManagerHelper(const std::shared_ptr<BundleMgrH
void AppMgrServiceInner::RegisterAppStateCallback(const sptr<IAppStateCallback> &callback)
{
pid_t callingPid = IPCSkeleton::GetCallingRealPid();
pid_t callingPid = IPCSkeleton::GetCallingPid();
pid_t pid = getprocpid();
if (callingPid != pid) {
TAG_LOGE(AAFwkTag::APPMGR, "%{public}s: Not abilityMgr call.", __func__);
@@ -2928,7 +2931,7 @@ bool AppMgrServiceInner::SendCreateAtomicServiceProcessEvent(const std::shared_p
return false;
}
TAG_LOGI(AAFwkTag::APPMGR, "to report create atomic service process event.");
auto callerPid = appRecord->GetCallerPid() == -1 ? IPCSkeleton::GetCallingRealPid() : appRecord->GetCallerPid();
auto callerPid = appRecord->GetCallerPid() == -1 ? IPCSkeleton::GetCallingPid() : appRecord->GetCallerPid();
auto callerAppRecord = GetAppRunningRecordByPid(callerPid);
return AppMgrEventUtil::SendCreateAtomicServiceProcessEvent(callerAppRecord, appRecord, moduleName, abilityName);
}
@@ -2940,7 +2943,7 @@ bool AppMgrServiceInner::SendProcessStartEvent(const std::shared_ptr<AppRunningR
return false;
}
AAFwk::EventInfo eventInfo;
auto callerPid = appRecord->GetCallerPid() == -1 ? IPCSkeleton::GetCallingRealPid() : appRecord->GetCallerPid();
auto callerPid = appRecord->GetCallerPid() == -1 ? IPCSkeleton::GetCallingPid() : appRecord->GetCallerPid();
auto callerAppRecord = GetAppRunningRecordByPid(callerPid);
AppMgrEventUtil::SendProcessStartEvent(callerAppRecord, appRecord, eventInfo);
SendReStartProcessEvent(eventInfo, appRecord->GetUid());
@@ -3900,7 +3903,7 @@ void AppMgrServiceInner::RegisterStartSpecifiedAbilityResponse(const sptr<IStart
return;
}
pid_t callingPid = IPCSkeleton::GetCallingRealPid();
pid_t callingPid = IPCSkeleton::GetCallingPid();
pid_t pid = getprocpid();
if (callingPid != pid) {
TAG_LOGE(AAFwkTag::APPMGR, "%{public}s: Not abilityMgr call.", __func__);
@@ -4258,7 +4261,7 @@ int AppMgrServiceInner::GetAbilityRecordsByProcessID(const int pid, std::vector<
}
auto isSaCall = AAFwk::PermissionVerification::GetInstance()->IsSACall();
auto callingPid = IPCSkeleton::GetCallingRealPid();
auto callingPid = IPCSkeleton::GetCallingPid();
if (!isSaCall && callingPid != pid) {
TAG_LOGE(AAFwkTag::APPMGR, "Permission verify failed.");
return ERR_PERMISSION_DENIED;
@@ -4345,7 +4348,7 @@ int AppMgrServiceInner::VerifyProcessPermission(const std::string &bundleName) c
auto isCallingPerm = AAFwk::PermissionVerification::GetInstance()->VerifyCallingPermission(
AAFwk::PermissionConstants::PERMISSION_CLEAN_BACKGROUND_PROCESSES);
if (isCallingPerm) {
auto callerPid = IPCSkeleton::GetCallingRealPid();
auto callerPid = IPCSkeleton::GetCallingPid();
auto appRecord = GetAppRunningRecordByPid(callerPid);
if (!appRecord || appRecord->GetBundleName() != bundleName) {
TAG_LOGE(AAFwkTag::APPMGR, "Permission verification failed.");
@@ -4395,7 +4398,7 @@ bool AppMgrServiceInner::CheckCallerIsAppGallery()
TAG_LOGE(AAFwkTag::APPMGR, "appRunningManager_ is nullptr");
return false;
}
auto callerPid = IPCSkeleton::GetCallingRealPid();
auto callerPid = IPCSkeleton::GetCallingPid();
auto appRecord = appRunningManager_->GetAppRunningRecordByPid(callerPid);
if (!appRecord) {
TAG_LOGE(AAFwkTag::APPMGR, "Get app running record by calling pid failed. callingPId: %{public}d", callerPid);
@@ -4429,7 +4432,7 @@ bool AppMgrServiceInner::VerifyAPL() const
return false;
}
auto callerPid = IPCSkeleton::GetCallingRealPid();
auto callerPid = IPCSkeleton::GetCallingPid();
auto appRecord = appRunningManager_->GetAppRunningRecordByPid(callerPid);
if (!appRecord) {
TAG_LOGE(AAFwkTag::APPMGR, "Get app running record by calling pid failed. callingPId: %{public}d", callerPid);
@@ -5116,7 +5119,7 @@ int32_t AppMgrServiceInner::NotifyAppFault(const FaultData &faultData)
{
TAG_LOGD(AAFwkTag::APPMGR, "called.");
int32_t callerUid = IPCSkeleton::GetCallingUid();
int32_t pid = IPCSkeleton::GetCallingRealPid();
int32_t pid = IPCSkeleton::GetCallingPid();
auto appRecord = GetAppRunningRecordByPid(pid);
if (appRecord == nullptr) {
TAG_LOGE(AAFwkTag::APPMGR, "no such appRecord");
@@ -6159,7 +6162,7 @@ int32_t AppMgrServiceInner::GetChildProcessInfoForSelf(ChildProcessInfo &info)
TAG_LOGE(AAFwkTag::APPMGR, "appRunningManager_ is null");
return ERR_NO_INIT;
}
auto callingPid = IPCSkeleton::GetCallingRealPid();
auto callingPid = IPCSkeleton::GetCallingPid();
if (appRunningManager_->GetAppRunningRecordByPid(callingPid)) {
TAG_LOGD(AAFwkTag::APPMGR, "record of callingPid is not child record.");
return ERR_NAME_NOT_FOUND;
@@ -6468,7 +6471,7 @@ void AppMgrServiceInner::SendAppLaunchEvent(const std::shared_ptr<AppRunningReco
}
eventInfo.processName = appRecord->GetProcessName();
int32_t callerPid = appRecord->GetCallerPid() == -1 ?
IPCSkeleton::GetCallingRealPid() : appRecord->GetCallerPid();
IPCSkeleton::GetCallingPid() : appRecord->GetCallerPid();
auto callerRecord = GetAppRunningRecordByPid(callerPid);
if (callerRecord != nullptr) {
eventInfo.callerBundleName = callerRecord->GetBundleName();
@@ -6492,7 +6495,7 @@ bool AppMgrServiceInner::IsFinalAppProcessByBundleName(const std::string &bundle
auto name = bundleName;
if (bundleName.empty()) {
auto callingPid = IPCSkeleton::GetCallingRealPid();
auto callingPid = IPCSkeleton::GetCallingPid();
auto appRecord = appRunningManager_->GetAppRunningRecordByPid(callingPid);
if (appRecord == nullptr) {
TAG_LOGE(AAFwkTag::APPMGR, "Get app running record is nullptr.");
@@ -6587,7 +6590,7 @@ void AppMgrServiceInner::SetAppAssertionPauseState(bool flag)
return;
}
auto callerPid = IPCSkeleton::GetCallingRealPid();
auto callerPid = IPCSkeleton::GetCallingPid();
auto appRecord = GetAppRunningRecordByPid(callerPid);
if (appRecord == nullptr) {
TAG_LOGE(AAFwkTag::APPMGR, "No such appRecord pid is %{public}d.", callerPid);
@@ -6606,7 +6609,7 @@ void AppMgrServiceInner::SetAppAssertionPauseState(bool flag)
int32_t AppMgrServiceInner::UpdateRenderState(pid_t renderPid, int32_t state)
{
int32_t hostPid = IPCSkeleton::GetCallingRealPid();
int32_t hostPid = IPCSkeleton::GetCallingPid();
auto appRecord = GetAppRunningRecordByPid(hostPid);
if (!appRecord) {
TAG_LOGE(AAFwkTag::APPMGR, "No such appRecord, hostPid:%{public}d", hostPid);
@@ -6798,7 +6801,7 @@ int32_t AppMgrServiceInner::SetSupportedProcessCacheSelf(bool isSupport)
return result;
}
auto callerPid = IPCSkeleton::GetCallingRealPid();
auto callerPid = IPCSkeleton::GetCallingPid();
auto appRecord = GetAppRunningRecordByPid(callerPid);
if (!appRecord) {
TAG_LOGE(AAFwkTag::APPMGR, "no such appRecord, callerPid:%{public}d", callerPid);
@@ -6893,5 +6896,33 @@ bool AppMgrServiceInner::IsAppProcessesAllCached(const std::string &bundleName,
}
return appRunningManager_->IsAppProcessesAllCached(bundleName, uid, cachedSet);
}
void AppMgrServiceInner::CacheLoabAbilityTask(const LoabAbilityTaskFunc& func)
{
loadAbilityTaskFuncList_.emplace_back(func);
}
void AppMgrServiceInner::SubmitCacheLoabAbilityTask()
{
std::weak_ptr<AAFwk::TaskHandlerWrap> taskHandler = taskHandler_;
for_each(loadAbilityTaskFuncList_.begin(), loadAbilityTaskFuncList_.end(),
[taskHandler](LoabAbilityTaskFunc loadAbilityFunc) {
auto LoadAbilityhandler = taskHandler.lock();
if (LoadAbilityhandler != nullptr && loadAbilityFunc) {
LoadAbilityhandler->SubmitTask(loadAbilityFunc);
}
});
loadAbilityTaskFuncList_.clear();
}
bool AppMgrServiceInner::GetSceneBoardAttachFlag() const
{
return sceneBoardAttachFlag_;
}
void AppMgrServiceInner::SetSceneBoardAttachFlag(bool flag)
{
sceneBoardAttachFlag_ = flag;
}
} // namespace AppExecFwk
} // namespace OHOS
@@ -220,7 +220,7 @@ int32_t UriPermissionManagerStubImpl::CheckCalledBySandBox()
TAG_LOGE(AAFwkTag::URIPERMMGR, "Get BundleManager failed!");
return INNER_ERR;
}
auto callerPid = IPCSkeleton::GetCallingRealPid();
auto callerPid = IPCSkeleton::GetCallingPid();
bool isSandbox = false;
if (appMgr_->JudgeSandboxByPid(callerPid, isSandbox) != ERR_OK) {
TAG_LOGE(AAFwkTag::URIPERMMGR, "JudgeSandboxByPid failed.");
@@ -50,6 +50,7 @@ ohos_fuzztest("AbilityStubUninstallAppFuzzTest") {
"ffrt:libffrt",
"hilog:libhilog",
"ipc:ipc_core",
"kv_store:distributeddata_inner",
"napi:ace_napi",
"safwk:system_ability_fwk",
"samgr:samgr_proxy",
@@ -21,6 +21,7 @@
#define private public
#include "ability_manager_service.h"
#undef private
#include "app_exit_reason_data_manager.h"
#include "message_parcel.h"
#include "securec.h"
@@ -48,7 +49,7 @@ bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
DelayedSingleton<AbilityManagerService>::GetInstance()->subManagersHelper_->currentUIAbilityManager_ =
std::make_shared<UIAbilityLifecycleManager>();
DelayedSingleton<AbilityManagerService>::GetInstance()->OnRemoteRequest(code, parcel, reply, option);
DelayedSingleton<AbilityRuntime::AppExitReasonDataManager>::DestroyInstance();
return true;
}
}
@@ -118,9 +118,10 @@ public:
void StartProfiler(const DebugOption debugOption) override {}
void DoCleanWorkAfterStageCleaned() override {}
void DumpHeapSnapshot(uint32_t tid, bool isFullGC, std::vector<uint32_t> fdVec,
std::vector<uint32_t> tidVec) override {}
void DumpHeapSnapshot(uint32_t tid, bool isFullGC) override {}
void ForceFullGC(uint32_t tid) override {}
void UpdatePkgContextInfoJson(std::string moduleName, std::string hapPath, std::string packageName) override {};
public:
Language language;
};
@@ -1329,6 +1329,7 @@ HWTEST_F(AbilityManagerServiceFirstTest, AppRecoverKill_001, TestSize.Level1)
abilityMs_->AppRecoverKill(pid, StateReason::JS_ERROR);
abilityMs_->AppRecoverKill(pid, StateReason::LIFECYCLE);
abilityMs_->AppRecoverKill(pid, StateReason::APP_FREEZE);
EXPECT_TRUE(abilityMs_ != nullptr);
}
/*
@@ -45,7 +45,7 @@ void DataObsMgrInnerPrefTest::SetUpTestCase(void) {}
void DataObsMgrInnerPrefTest::TearDownTestCase(void) {}
void DataObsMgrInnerPrefTest::SetUp()
{
std::shared_ptr<DataObsMgrInnerPref> dataObsMgrInnerPref_ = std::make_shared<DataObsMgrInnerPref>();
dataObsMgrInnerPref_ = std::make_shared<DataObsMgrInnerPref>();
}
void DataObsMgrInnerPrefTest::TearDown() {}
@@ -272,14 +272,12 @@ HWTEST_F(DataObsMgrInnerPrefTest, DataObsMgrInnerPref_RemoveObs_HaveRegistered_0
EXPECT_EQ(false, dataObsMgrInnerPref_->HaveRegistered(callback));
obsPair->second.clear();
obsPair = dataObsMgrInnerPref_->observers_.find(uri.ToString());
EXPECT_EQ((std::size_t)1, obsPair->second.size());
EXPECT_EQ(false, dataObsMgrInnerPref_->HaveRegistered(callback));
dataObsMgrInnerPref_->RemoveObs(callback2->AsObject());
EXPECT_EQ(false, dataObsMgrInnerPref_->HaveRegistered(callback2));
obsPair->second.clear();
obsPair = dataObsMgrInnerPref_->observers_.find(uri.ToString());
EXPECT_EQ((std::size_t)0, obsPair->second.size());
EXPECT_EQ(false, dataObsMgrInnerPref_->HaveRegistered(callback2));
}
@@ -45,7 +45,7 @@ void DataObsMgrInnerTest::SetUpTestCase(void) {}
void DataObsMgrInnerTest::TearDownTestCase(void) {}
void DataObsMgrInnerTest::SetUp()
{
std::shared_ptr<DataObsMgrInner> dataObsMgrInner_ = std::make_shared<DataObsMgrInner>();
dataObsMgrInner_ = std::make_shared<DataObsMgrInner>();
}
void DataObsMgrInnerTest::TearDown() {}
@@ -272,14 +272,12 @@ HWTEST_F(DataObsMgrInnerTest, DataObsMgrInner_RemoveObs_HaveRegistered_0100, Tes
EXPECT_EQ(false, dataObsMgrInner_->HaveRegistered(callback));
obsPair->second.clear();
obsPair = dataObsMgrInner_->observers_.find(uri.ToString());
EXPECT_EQ((std::size_t)1, obsPair->second.size());
EXPECT_EQ(false, dataObsMgrInner_->HaveRegistered(callback));
dataObsMgrInner_->RemoveObs(callback2->AsObject());
EXPECT_EQ(false, dataObsMgrInner_->HaveRegistered(callback2));
obsPair->second.clear();
obsPair = dataObsMgrInner_->observers_.find(uri.ToString());
EXPECT_EQ((std::size_t)0, obsPair->second.size());
EXPECT_EQ(false, dataObsMgrInner_->HaveRegistered(callback2));
}
@@ -585,6 +585,87 @@ ohos_unittest("assert_fault_test") {
}
}
ohos_unittest("dump_ipc_helper_test") {
include_dirs = []
module_out_path = module_output_path
sources = [
"${ability_runtime_native_path}/appkit/app/dump_ipc_helper.cpp",
"dump_ipc_helper_test.cpp",
]
configs = [ ":module_context_config" ]
deps = [
"${ability_runtime_native_path}/appkit:appkit_native",
"//third_party/googletest:gtest_main",
]
external_deps = [
"ability_runtime:runtime",
"c_utils:utils",
"hilog:libhilog",
"ipc:ipc_core",
"napi:ace_napi",
]
}
config("appkit_exception_config") {
cflags_cc = [ "-fexceptions" ]
}
ohos_unittest("extension_plugin_info_test") {
module_out_path = module_output_path
sources = [
"${ability_runtime_native_path}/appkit/app/extension_plugin_info.cpp",
"extension_plugin_info_test.cpp",
]
configs = [
":module_context_config",
":appkit_exception_config",
]
deps = [
"${ability_runtime_native_path}/ability/native:abilitykit_native",
"${ability_runtime_native_path}/appkit:appkit_native",
"//third_party/googletest:gtest_main",
]
external_deps = [
"ability_base:string_utils",
"ability_runtime:runtime",
"c_utils:utils",
"hilog:libhilog",
"ipc:ipc_core",
"napi:ace_napi",
]
}
ohos_unittest("idle_time_test") {
module_out_path = module_output_path
sources = [
"${ability_runtime_native_path}/appkit/app/idle_time.cpp",
"idle_time_test.cpp",
]
configs = [ ":module_context_config" ]
deps = [
"${ability_runtime_native_path}/appkit:appkit_native",
"//third_party/googletest:gtest_main",
]
external_deps = [
"ability_runtime:runtime",
"c_utils:utils",
"eventhandler:libeventhandler",
"graphic_2d:librender_service_client",
"hilog:libhilog",
"ipc:ipc_core",
"napi:ace_napi",
]
}
###############################################################################
group("unittest") {
@@ -601,7 +682,10 @@ group("unittest") {
":context_container_by_mock_bms_test",
":context_container_test",
":context_deal_test",
":dump_ipc_helper_test",
":extension_plugin_info_test",
":form_extension_context_test",
":idle_time_test",
]
deps += [ "ability_delegator:unittest" ]
@@ -0,0 +1,99 @@
/*
* 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 <algorithm>
#include <gtest/gtest.h>
#define private public
#define protected public
#include "dump_ipc_helper.h"
#undef private
#undef protected
using namespace testing::ext;
namespace OHOS {
namespace AppExecFwk {
class DumpIpcHelperTest : public testing::Test {
public:
DumpIpcHelperTest()
{}
~DumpIpcHelperTest()
{}
static void SetUpTestCase(void);
static void TearDownTestCase(void);
void SetUp();
void TearDown();
};
void DumpIpcHelperTest::SetUpTestCase(void)
{}
void DumpIpcHelperTest::TearDownTestCase(void)
{}
void DumpIpcHelperTest::SetUp(void)
{}
void DumpIpcHelperTest::TearDown(void)
{}
/**
* @tc.number: DumpIpcStart_0100
* @tc.name: DumpIpcStart
* @tc.desc: Test whether DumpIpcStart and are called normally.
*/
HWTEST_F(DumpIpcHelperTest, DumpIpcStart_0100, Function | MediumTest | Level1)
{
GTEST_LOG_(INFO) << "DumpIpcHelperTest DumpIpcStart_0100 start";
std::string result = "";
DumpIpcHelper::DumpIpcStart(result);
EXPECT_NE(result, "");
GTEST_LOG_(INFO) << "DumpIpcHelperTest DumpIpcStart_0100 end";
}
/**
* @tc.number: DumpIpcStop_0100
* @tc.name: DumpIpcStop
* @tc.desc: Test whether DumpIpcStop and are called normally.
*/
HWTEST_F(DumpIpcHelperTest, DumpIpcStop_0100, Function | MediumTest | Level1)
{
GTEST_LOG_(INFO) << "DumpIpcHelperTest DumpIpcStop_0100 start";
std::string result = "";
DumpIpcHelper::DumpIpcStop(result);
EXPECT_NE(result, "");
GTEST_LOG_(INFO) << "DumpIpcHelperTest DumpIpcStop_0100 end";
}
/**
* @tc.number: DumpIpcStat_0100
* @tc.name: DumpIpcStat
* @tc.desc: Test whether DumpIpcStat and are called normally.
*/
HWTEST_F(DumpIpcHelperTest, DumpIpcStat_0100, Function | MediumTest | Level1)
{
GTEST_LOG_(INFO) << "DumpIpcHelperTest DumpIpcStat_0100 start";
std::string result = "";
DumpIpcHelper::DumpIpcStat(result);
EXPECT_NE(result, "");
GTEST_LOG_(INFO) << "DumpIpcHelperTest DumpIpcStat_0100 end";
}
}
}
@@ -0,0 +1,148 @@
/*
* 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 <algorithm>
#include <gtest/gtest.h>
#define private public
#define protected public
#include "extension_plugin_info.h"
#include "file_ex.h"
#undef private
#undef protected
using namespace testing::ext;
using namespace OHOS::AbilityRuntime;
namespace OHOS {
namespace AppExecFwk {
class ExtensionPluginInfoTest : public testing::Test {
public:
ExtensionPluginInfoTest()
{}
~ExtensionPluginInfoTest()
{}
static void SetUpTestCase(void);
static void TearDownTestCase(void);
void SetUp();
void TearDown();
};
void ExtensionPluginInfoTest::SetUpTestCase(void)
{}
void ExtensionPluginInfoTest::TearDownTestCase(void)
{}
void ExtensionPluginInfoTest::SetUp(void)
{}
void ExtensionPluginInfoTest::TearDown(void)
{}
/**
* @tc.number: Preload_0100
* @tc.name: Preload
* @tc.desc: Test whether Preload and are called normally.
*/
HWTEST_F(ExtensionPluginInfoTest, Preload_0100, Function | MediumTest | Level1)
{
GTEST_LOG_(INFO) << "ExtensionPluginInfoTest Preload_0100 start";
ExtensionPluginInfo::GetInstance().Preload();
GTEST_LOG_(INFO) << "ExtensionPluginInfoTest Preload_0100 end";
}
/**
* @tc.number: GetExtensionPlugins_0100
* @tc.name: GetExtensionPlugins
* @tc.desc: Test whether GetExtensionPlugins and are called normally.
*/
HWTEST_F(ExtensionPluginInfoTest, GetExtensionPlugins_0100, Function | MediumTest | Level1)
{
GTEST_LOG_(INFO) << "ExtensionPluginInfoTest GetExtensionPlugins_0100 start";
ExtensionPluginInfo::GetInstance().extensionPlugins_.clear();
auto extensionPlugins = ExtensionPluginInfo::GetInstance().GetExtensionPlugins();
EXPECT_EQ(extensionPlugins.size(), 0);
GTEST_LOG_(INFO) << "ExtensionPluginInfoTest GetExtensionPlugins_0100 end";
}
/**
* @tc.number: ScanExtensions_0100
* @tc.name: ScanExtensions
* @tc.desc: Test whether ScanExtensions and are called normally.
*/
HWTEST_F(ExtensionPluginInfoTest, ScanExtensions_0100, Function | MediumTest | Level1)
{
GTEST_LOG_(INFO) << "ExtensionPluginInfoTest ScanExtensions_0100 start";
std::vector<std::string> files;
bool res = ExtensionPluginInfo::GetInstance().ScanExtensions(files);
if (OHOS::FileExists("system/lib/extensionability")) {
EXPECT_EQ(res, true);
EXPECT_NE(files.size(), 0);
} else {
EXPECT_EQ(res, false);
EXPECT_EQ(files.size(), 0);
}
GTEST_LOG_(INFO) << "ExtensionPluginInfoTest ScanExtensions_0100 end";
}
/**
* @tc.number: ParseExtensions_0100
* @tc.name: ParseExtensions
* @tc.desc: Test whether ParseExtensions and are called normally.
*/
HWTEST_F(ExtensionPluginInfoTest, ParseExtensions_0100, Function | MediumTest | Level1)
{
GTEST_LOG_(INFO) << "ExtensionPluginInfoTest ParseExtensions_0100 start";
std::vector<std::string> files;
bool res = ExtensionPluginInfo::GetInstance().ScanExtensions(files);
if (OHOS::FileExists("system/lib/extensionability")) {
EXPECT_EQ(res, true);
EXPECT_NE(files.size(), 0);
} else {
EXPECT_EQ(res, false);
EXPECT_EQ(files.size(), 0);
}
ExtensionPluginInfo::GetInstance().ParseExtensions(files);
GTEST_LOG_(INFO) << "ExtensionPluginInfoTest ParseExtensions_0100 end";
}
/**
* @tc.number: CheckFileType_0100
* @tc.name: CheckFileType
* @tc.desc: Test whether CheckFileType and are called normally.
*/
HWTEST_F(ExtensionPluginInfoTest, CheckFileType_0100, Function | MediumTest | Level1)
{
GTEST_LOG_(INFO) << "ExtensionPluginInfoTest CheckFileType_0100 start";
std::string fileName = "";
bool res = ExtensionPluginInfo::GetInstance().CheckFileType(fileName, ".so");
EXPECT_EQ(res, false);
fileName = "ability";
res = ExtensionPluginInfo::GetInstance().CheckFileType(fileName, ".so");
EXPECT_EQ(res, false);
fileName = "ability.so";
res = ExtensionPluginInfo::GetInstance().CheckFileType(fileName, ".so");
EXPECT_EQ(res, true);
GTEST_LOG_(INFO) << "ExtensionPluginInfoTest CheckFileType_0100 end";
}
}
}
@@ -0,0 +1,137 @@
/*
* 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 <algorithm>
#include <gtest/gtest.h>
#define private public
#define protected public
#include "idle_time.h"
#include "main_thread.h"
#undef private
#undef protected
using namespace testing::ext;
using namespace OHOS::AbilityRuntime;
namespace OHOS {
namespace AppExecFwk {
class IdleTimeTest : public testing::Test {
public:
IdleTimeTest()
{
std::function<void(int32_t)> callback = nullptr;
std::shared_ptr<EventHandler> mainHandler = std::make_shared<EventHandler>(EventRunner::GetMainEventRunner());
idleTime_ = std::make_shared<IdleTime>(mainHandler, callback);
}
~IdleTimeTest()
{}
static void SetUpTestCase(void);
static void TearDownTestCase(void);
void SetUp();
void TearDown();
std::shared_ptr<IdleTime> idleTime_ = nullptr;
};
void IdleTimeTest::SetUpTestCase(void)
{
}
void IdleTimeTest::TearDownTestCase(void)
{}
void IdleTimeTest::SetUp(void)
{
}
void IdleTimeTest::TearDown(void)
{}
/**
* @tc.number: Preload_0100
* @tc.name: Preload
* @tc.desc: Test whether Preload and are called normally.
*/
HWTEST_F(IdleTimeTest, Preload_0100, Function | MediumTest | Level1)
{
GTEST_LOG_(INFO) << "IdleTimeTest Preload_0100 start";
int64_t time = 0;
time = idleTime_->GetSysTimeNs();
EXPECT_NE(time, 0);
GTEST_LOG_(INFO) << "IdleTimeTest Preload_0100 end";
}
/**
* @tc.number: InitVSyncReceiver_0100
* @tc.name: InitVSyncReceiver
* @tc.desc: Test whether InitVSyncReceiver and are called normally.
*/
HWTEST_F(IdleTimeTest, InitVSyncReceiver_0100, Function | MediumTest | Level1)
{
GTEST_LOG_(INFO) << "IdleTimeTest InitVSyncReceiver_0100 start";
idleTime_->needStop_ = true;
idleTime_->receiver_ = nullptr;
idleTime_->InitVSyncReceiver();
EXPECT_EQ(idleTime_->receiver_, nullptr);
GTEST_LOG_(INFO) << "IdleTimeTest InitVSyncReceiver_0100 end";
}
/**
* @tc.number: EventTask_0100
* @tc.name: EventTask
* @tc.desc: Test whether EventTask and are called normally.
*/
HWTEST_F(IdleTimeTest, EventTask_0100, Function | MediumTest | Level1)
{
GTEST_LOG_(INFO) << "IdleTimeTest EventTask_0100 start";
idleTime_->needStop_ = false;
idleTime_->EventTask();
EXPECT_EQ(idleTime_->callback_, nullptr);
GTEST_LOG_(INFO) << "IdleTimeTest EventTask_0100 end";
}
/**
* @tc.number: PostTask_0100
* @tc.name: PostTask
* @tc.desc: Test whether PostTask and are called normally.
*/
HWTEST_F(IdleTimeTest, PostTask_0100, Function | MediumTest | Level1)
{
GTEST_LOG_(INFO) << "IdleTimeTest PostTask_0100 start";
idleTime_->needStop_ = true;
idleTime_->PostTask();
EXPECT_NE(idleTime_->eventHandler_, nullptr);
GTEST_LOG_(INFO) << "IdleTimeTest PostTask_0100 end";
}
/**
* @tc.number: GetIdleNotifyFunc_0100
* @tc.name: GetIdleNotifyFunc
* @tc.desc: Test whether GetIdleNotifyFunc and are called normally.
*/
HWTEST_F(IdleTimeTest, GetIdleNotifyFunc_0100, Function | MediumTest | Level1)
{
GTEST_LOG_(INFO) << "IdleTimeTest GetIdleNotifyFunc_0100 start";
IdleNotifyStatusCallback callBack = idleTime_->GetIdleNotifyFunc();
EXPECT_NE(callBack, nullptr);
GTEST_LOG_(INFO) << "IdleTimeTest GetIdleNotifyFunc_0100 end";
}
}
}
@@ -1492,9 +1492,7 @@ HWTEST_F(JsRuntimeTest, DumpHeapSnapshot_0200, TestSize.Level1)
auto jsRuntime = std::make_unique<JsRuntime>();
uint32_t tid = 1;
bool isFullGC = true;
std::vector<uint32_t> fdVec;
std::vector<uint32_t> tidVec;
jsRuntime->DumpHeapSnapshot(tid, isFullGC, fdVec, tidVec);
jsRuntime->DumpHeapSnapshot(tid, isFullGC);
EXPECT_TRUE(jsRuntime != nullptr);
}