mirror of
https://github.com/openharmony/ability_ability_runtime.git
synced 2026-08-25 12:23:20 -04:00
Merge branch 'master' of https://gitee.com/openharmony/ability_ability_runtime into wyz001
This commit is contained in:
@@ -51,7 +51,6 @@ void JSAbilityForegroundStateObserver::OnAbilityStateChanged(const AbilityStateD
|
||||
void JSAbilityForegroundStateObserver::HandleOnAbilityStateChanged(const AbilityStateData &abilityStateData)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "Called.");
|
||||
std::lock_guard<std::mutex> lock(mutexlock_);
|
||||
for (auto &item : jsObserverObjectSet_) {
|
||||
if (item == nullptr) {
|
||||
continue;
|
||||
@@ -112,7 +111,6 @@ void JSAbilityForegroundStateObserver::AddJsObserverObject(const napi_value &jsO
|
||||
}
|
||||
napi_ref ref = nullptr;
|
||||
napi_create_reference(env_, jsObserverObject, 1, &ref);
|
||||
std::lock_guard<std::mutex> lock(mutexlock_);
|
||||
jsObserverObjectSet_.emplace(std::shared_ptr<NativeReference>(reinterpret_cast<NativeReference *>(ref)));
|
||||
}
|
||||
|
||||
@@ -124,7 +122,6 @@ void JSAbilityForegroundStateObserver::RemoveJsObserverObject(const napi_value &
|
||||
}
|
||||
|
||||
auto observer = GetObserverObject(jsObserverObject);
|
||||
std::lock_guard<std::mutex> lock(mutexlock_);
|
||||
if (observer != nullptr) {
|
||||
jsObserverObjectSet_.erase(observer);
|
||||
}
|
||||
@@ -132,7 +129,6 @@ void JSAbilityForegroundStateObserver::RemoveJsObserverObject(const napi_value &
|
||||
|
||||
void JSAbilityForegroundStateObserver::RemoveAllJsObserverObject()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutexlock_);
|
||||
if (!jsObserverObjectSet_.empty()) {
|
||||
jsObserverObjectSet_.clear();
|
||||
}
|
||||
@@ -144,7 +140,6 @@ std::shared_ptr<NativeReference> JSAbilityForegroundStateObserver::GetObserverOb
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Observer is null.");
|
||||
return nullptr;
|
||||
}
|
||||
std::lock_guard<std::mutex> lock(mutexlock_);
|
||||
for (auto &observer : jsObserverObjectSet_) {
|
||||
if (observer == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Invalid observer.");
|
||||
|
||||
@@ -47,7 +47,6 @@ public:
|
||||
private:
|
||||
napi_env env_;
|
||||
volatile bool valid_ = true;
|
||||
std::mutex mutexlock_;
|
||||
std::set<std::shared_ptr<NativeReference>> jsObserverObjectSet_;
|
||||
};
|
||||
} // namespace AbilityRuntime
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -310,7 +310,7 @@ napi_value JSAbilityDelegator::OnAddAbilityStageMonitor(napi_env env, NapiCallba
|
||||
if (!ParseAbilityStageMonitorPara(env, info, monitor, isExisted, false)) {
|
||||
TAG_LOGE(AAFwkTag::DELEGATOR, "Parse addAbilityStageMonitor parameters failed");
|
||||
return ThrowJsError(env, INCORRECT_PARAMETERS,
|
||||
"Parse param parameters, failed, monitor must be Monitor and isExited must be boolean.");
|
||||
"Parse parameters failed, monitor must be Monitor and isExited must be boolean.");
|
||||
}
|
||||
|
||||
NapiAsyncTask::CompleteCallback complete = [monitor](napi_env env, NapiAsyncTask &task, int32_t status) {
|
||||
@@ -344,7 +344,7 @@ napi_value JSAbilityDelegator::OnAddAbilityStageMonitorSync(napi_env env, NapiCa
|
||||
if (!ParseAbilityStageMonitorPara(env, info, monitor, isExisted, true)) {
|
||||
TAG_LOGE(AAFwkTag::DELEGATOR, "Parse addAbilityStageMonitorSync parameters failed");
|
||||
return ThrowJsError(env, INCORRECT_PARAMETERS,
|
||||
"Parse param monitor, failed, monitor must be Monitor.");
|
||||
"Parse param monitor failed, monitor must be Monitor.");
|
||||
}
|
||||
auto delegator = AbilityDelegatorRegistry::GetAbilityDelegator();
|
||||
if (!delegator) {
|
||||
@@ -774,7 +774,7 @@ napi_value JSAbilityDelegator::OnGetCurrentTopAbility(napi_env env, NapiCallback
|
||||
|
||||
if (info.argc >= ARGC_ONE && !AppExecFwk::IsTypeForNapiValue(env, info.argv[INDEX_ZERO], napi_function)) {
|
||||
TAG_LOGE(AAFwkTag::DELEGATOR, "Parse getCurrentTopAbility parameter failed");
|
||||
return ThrowJsError(env, INCORRECT_PARAMETERS, "Parse callback failed, callback must be funcation");
|
||||
return ThrowJsError(env, INCORRECT_PARAMETERS, "Parse callback failed, callback must be function");
|
||||
}
|
||||
|
||||
NapiAsyncTask::CompleteCallback complete = [this](napi_env env, NapiAsyncTask &task, int32_t status) {
|
||||
|
||||
@@ -157,6 +157,10 @@ class ApplicationContext {
|
||||
return this.__context_impl__.setLanguage(language);
|
||||
}
|
||||
|
||||
setFont(font) {
|
||||
return this.__context_impl__.setFont(font);
|
||||
}
|
||||
|
||||
setAutoStartup(info, callback) {
|
||||
return this.__context_impl__.setAutoStartup(info, callback);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
+2
@@ -21,6 +21,7 @@ const int32_t CREATE_VALUE_ZERO = 0;
|
||||
const int32_t CREATE_VALUE_ONE = 1;
|
||||
const int32_t CREATE_VALUE_TWO = 2;
|
||||
const int32_t CREATE_VALUE_THREE = 3;
|
||||
const int32_t CREATE_VALUE_FOUR = 4;
|
||||
static napi_status SetEnumItem(napi_env env, napi_value object, const char* name, int32_t value)
|
||||
{
|
||||
napi_status status;
|
||||
@@ -45,6 +46,7 @@ static napi_value InitAreaModeObject(napi_env env)
|
||||
NAPI_CALL(env, SetEnumItem(env, object, "EL2", CREATE_VALUE_ONE));
|
||||
NAPI_CALL(env, SetEnumItem(env, object, "EL3", CREATE_VALUE_TWO));
|
||||
NAPI_CALL(env, SetEnumItem(env, object, "EL4", CREATE_VALUE_THREE));
|
||||
NAPI_CALL(env, SetEnumItem(env, object, "EL5", CREATE_VALUE_FOUR));
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
@@ -85,6 +85,12 @@ napi_value WrapConfiguration(napi_env env, const AppExecFwk::Configuration &conf
|
||||
jsValue = WrapDoubleToJS(env, fontWeightScale != "" ? std::stod(fontWeightScale) : 1.0);
|
||||
SetPropertyValueByPropertyName(env, jsObject, "fontWeightScale", jsValue);
|
||||
|
||||
jsValue = WrapStringToJS(env, configuration.GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_MCC));
|
||||
SetPropertyValueByPropertyName(env, jsObject, "mcc", jsValue);
|
||||
|
||||
jsValue = WrapStringToJS(env, configuration.GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_MNC));
|
||||
SetPropertyValueByPropertyName(env, jsObject, "mnc", jsValue);
|
||||
|
||||
return jsObject;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -113,6 +113,7 @@ napi_value WantConstantInit(napi_env env, napi_value exports)
|
||||
SetNamedProperty(env, params, "ohos.extra.param.key.supportContinuePageStack", "SUPPORT_CONTINUE_PAGE_STACK_KEY");
|
||||
SetNamedProperty(env, params, "ohos.extra.param.key.supportContinueSourceExit", "SUPPORT_CONTINUE_SOURCE_EXIT_KEY");
|
||||
SetNamedProperty(env, params, "ohos.extra.param.key.showMode", "SHOW_MODE_KEY");
|
||||
SetNamedProperty(env, params, "ohos.extra.param.key.appCloneIndex", "APP_CLONE_INDEX_KEY");
|
||||
napi_property_descriptor exportFuncs[] = {
|
||||
DECLARE_NAPI_PROPERTY("Action", action),
|
||||
DECLARE_NAPI_PROPERTY("Entity", entity),
|
||||
|
||||
@@ -1093,7 +1093,7 @@ napi_value JsWantAgent::OnNapiGetWant(napi_env env, napi_callback_info info)
|
||||
TAG_LOGD(AAFwkTag::WANTAGENT, "enter, argc = %{public}d", static_cast<int32_t>(argc));
|
||||
if (argc > ARGC_TWO || argc < ARGC_ONE) {
|
||||
TAG_LOGE(AAFwkTag::WANTAGENT, "Not enough params");
|
||||
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER);
|
||||
ThrowTooFewParametersError(env);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
WantAgent* pWantAgent = nullptr;
|
||||
@@ -1106,14 +1106,14 @@ napi_value JsWantAgent::OnNapiGetWant(napi_env env, napi_callback_info info)
|
||||
|
||||
if (!CheckTypeForNapiValue(env, argv[0], napi_object)) {
|
||||
TAG_LOGE(AAFwkTag::WANTAGENT, "Wrong argument type. Object expected.");
|
||||
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER);
|
||||
ThrowInvalidParamError(env, "Parameter error! Agent must be a WantAgent!");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
UnwrapWantAgent(env, argv[0], reinterpret_cast<void **>(&pWantAgent));
|
||||
if (pWantAgent == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::WANTAGENT, "Parse pWantAgent failed");
|
||||
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER);
|
||||
ThrowInvalidParamError(env, "Parse wantAgent failed! Agent must be a WantAgent!");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
@@ -1143,7 +1143,7 @@ napi_value JsWantAgent::OnNapiTrigger(napi_env env, napi_callback_info info)
|
||||
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
|
||||
if (argc != ARGC_THREE) {
|
||||
TAG_LOGE(AAFwkTag::WANTAGENT, "Not enough params");
|
||||
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER);
|
||||
ThrowTooFewParametersError(env);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
@@ -1152,7 +1152,7 @@ napi_value JsWantAgent::OnNapiTrigger(napi_env env, napi_callback_info info)
|
||||
auto triggerObj = std::make_shared<TriggerCompleteCallBack>();
|
||||
int32_t errCode = UnWrapTriggerInfoParam(env, info, wantAgent, triggerInfo, triggerObj);
|
||||
if (errCode != NO_ERROR) {
|
||||
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER);
|
||||
ThrowInvalidParamError(env, "Parameter error!");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
ErrCode result = WantAgentHelper::TriggerWantAgent(wantAgent, triggerObj, triggerInfo);
|
||||
@@ -1170,7 +1170,7 @@ napi_value JsWantAgent::OnNapiGetWantAgent(napi_env env, napi_callback_info info
|
||||
TAG_LOGD(AAFwkTag::WANTAGENT, "enter, argc = %{public}d", static_cast<int32_t>(argc));
|
||||
if (argc > ARGC_TWO || argc < ARGC_ONE) {
|
||||
TAG_LOGE(AAFwkTag::WANTAGENT, "Not enough params");
|
||||
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER);
|
||||
ThrowTooFewParametersError(env);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
@@ -1178,7 +1178,7 @@ napi_value JsWantAgent::OnNapiGetWantAgent(napi_env env, napi_callback_info info
|
||||
int32_t ret = GetWantAgentParam(env, info, *spParas);
|
||||
if (ret != 0) {
|
||||
TAG_LOGE(AAFwkTag::WANTAGENT, "Failed to get wantAgent param.");
|
||||
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER);
|
||||
ThrowInvalidParamError(env, "Parameter error! Info must be a WantAgentInfo.");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
@@ -1234,13 +1234,13 @@ napi_value JsWantAgent::OnNapiGetOperationType(napi_env env, napi_callback_info
|
||||
WantAgent* pWantAgent = nullptr;
|
||||
if (argc > ARGC_TWO || argc < ARGC_ONE) {
|
||||
TAG_LOGE(AAFwkTag::WANTAGENT, "Not enough params");
|
||||
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER);
|
||||
ThrowTooFewParametersError(env);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
if (!CheckTypeForNapiValue(env, argv[0], napi_object)) {
|
||||
TAG_LOGE(AAFwkTag::WANTAGENT, "Wrong argument type. Object expected.");
|
||||
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER);
|
||||
ThrowInvalidParamError(env, "Parameter error! Agent must be a WantAgent.");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
@@ -1248,7 +1248,7 @@ napi_value JsWantAgent::OnNapiGetOperationType(napi_env env, napi_callback_info
|
||||
|
||||
if (pWantAgent == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::WANTAGENT, "Parse pWantAgent failed");
|
||||
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER);
|
||||
ThrowInvalidParamError(env, "Parse wantAgent failed! Agent must be a WantAgent.");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
|
||||
@@ -136,6 +136,7 @@ ohos_shared_library("abilitykit_utils") {
|
||||
"${ability_runtime_native_path}/ability/native/ability_handler.cpp",
|
||||
"${ability_runtime_native_path}/ability/native/ability_local_record.cpp",
|
||||
"${ability_runtime_native_path}/ability/native/configuration_utils.cpp",
|
||||
"${ability_runtime_native_path}/ability/native/resource_config_helper.cpp",
|
||||
]
|
||||
|
||||
deps = []
|
||||
@@ -148,8 +149,10 @@ ohos_shared_library("abilitykit_utils") {
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"c_utils:utils",
|
||||
"eventhandler:libeventhandler",
|
||||
"graphic_2d:2d_graphics",
|
||||
"hilog:libhilog",
|
||||
"hitrace:hitrace_meter",
|
||||
"ipc:ipc_core",
|
||||
"ipc:ipc_napi",
|
||||
"json:nlohmann_json_static",
|
||||
"napi:ace_napi",
|
||||
|
||||
+3
@@ -86,6 +86,7 @@ napi_value JsFillRequestCallback::OnFillRequestSuccess(napi_env env, NapiCallbac
|
||||
TAG_LOGD(AAFwkTag::AUTOFILL_EXT, "Called.");
|
||||
if (info.argc < ARGC_ONE || !IsTypeForNapiValue(env, info.argv[INDEX_ZERO], napi_object)) {
|
||||
TAG_LOGE(AAFwkTag::AUTOFILL_EXT, "Failed to parse viewData JsonString!");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
SendResultCodeAndViewData(
|
||||
JsAutoFillExtensionUtil::AutoFillResultCode::CALLBACK_FAILED_INVALID_PARAM, "");
|
||||
return CreateJsUndefined(env);
|
||||
@@ -96,6 +97,7 @@ napi_value JsFillRequestCallback::OnFillRequestSuccess(napi_env env, NapiCallbac
|
||||
std::string jsonString = response.viewData.ToJsonString();
|
||||
if (jsonString.empty()) {
|
||||
TAG_LOGE(AAFwkTag::AUTOFILL_EXT, "JsonString is empty");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
SendResultCodeAndViewData(
|
||||
JsAutoFillExtensionUtil::AutoFillResultCode::CALLBACK_FAILED_INVALID_PARAM, "");
|
||||
return CreateJsUndefined(env);
|
||||
@@ -129,6 +131,7 @@ napi_value JsFillRequestCallback::OnFillRequestCanceled(napi_env env, NapiCallba
|
||||
std::string jsonString = UnwrapStringFromJS(env, info.argv[INDEX_ZERO], "");
|
||||
if (jsonString.empty()) {
|
||||
TAG_LOGE(AAFwkTag::AUTOFILL_EXT, "JsonString is empty");
|
||||
ThrowError(env, static_cast<int32_t>(AbilityErrorCode::ERROR_CODE_INVALID_PARAM), ERROR_MSG_INVALID_PARAM);
|
||||
SendResultCodeAndViewData(
|
||||
JsAutoFillExtensionUtil::AutoFillResultCode::CALLBACK_FAILED_INVALID_PARAM, "");
|
||||
return CreateJsUndefined(env);
|
||||
|
||||
@@ -37,66 +37,21 @@ void ConfigurationUtils::UpdateGlobalConfig(const Configuration &configuration,
|
||||
return;
|
||||
}
|
||||
|
||||
std::string language;
|
||||
std::string colormode;
|
||||
std::string hasPointerDevice;
|
||||
GetGlobalConfig(configuration, language, colormode, hasPointerDevice);
|
||||
std::string colorModeIsSetByApp = configuration.GetItem(AAFwk::GlobalConfigurationKey::COLORMODE_IS_SET_BY_APP);
|
||||
std::unique_ptr<Global::Resource::ResConfig> resConfig(Global::Resource::CreateResConfig());
|
||||
if (resConfig == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::ABILITY, "Create resource config failed.");
|
||||
return;
|
||||
}
|
||||
resourceManager->GetResConfig(*resConfig);
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
if (!language.empty()) {
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
icu::Locale locale = icu::Locale::forLanguageTag(language, status);
|
||||
TAG_LOGD(AAFwkTag::ABILITY, "get Locale::forLanguageTag return[%{public}d].", static_cast<int>(status));
|
||||
if (status == U_ZERO_ERROR) {
|
||||
resConfig->SetLocaleInfo(locale);
|
||||
}
|
||||
|
||||
const icu::Locale *localeInfo = resConfig->GetLocaleInfo();
|
||||
if (localeInfo != nullptr) {
|
||||
TAG_LOGD(AAFwkTag::ABILITY, "Update config, language: %{public}s, script: %{public}s, region: %{public}s",
|
||||
localeInfo->getLanguage(), localeInfo->getScript(), localeInfo->getCountry());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!colormode.empty()) {
|
||||
resConfig->SetColorMode(AppExecFwk::ConvertColorMode(colormode));
|
||||
TAG_LOGD(AAFwkTag::ABILITY, "Update config, colorMode: %{public}d", resConfig->GetColorMode());
|
||||
}
|
||||
|
||||
if (!hasPointerDevice.empty()) {
|
||||
resConfig->SetInputDevice(AppExecFwk::ConvertHasPointerDevice(hasPointerDevice));
|
||||
TAG_LOGD(AAFwkTag::ABILITY, "Update config, hasPointerDevice: %{public}d", resConfig->GetInputDevice());
|
||||
}
|
||||
|
||||
if (!colorModeIsSetByApp.empty()) {
|
||||
TAG_LOGD(AAFwkTag::ABILITY, "set app true");
|
||||
resConfig->SetAppColorMode(true);
|
||||
}
|
||||
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, "resourceManager->UpdateResConfig");
|
||||
Global::Resource::RState ret = resourceManager->UpdateResConfig(*resConfig);
|
||||
if (ret != Global::Resource::RState::SUCCESS) {
|
||||
TAG_LOGE(AAFwkTag::ABILITY, "Update resource config failed with %{public}d.", static_cast<int>(ret));
|
||||
return;
|
||||
}
|
||||
|
||||
TAG_LOGD(AAFwkTag::ABILITY, "Update resource config succeed.");
|
||||
ResourceConfigHelper resourceConfig;
|
||||
GetGlobalConfig(configuration, resourceConfig);
|
||||
resourceConfig.UpdateResConfig(configuration, resourceManager);
|
||||
}
|
||||
|
||||
void ConfigurationUtils::GetGlobalConfig(const Configuration &configuration,
|
||||
std::string &language, std::string &colormode, std::string &hasPointerDevice)
|
||||
OHOS::AbilityRuntime::ResourceConfigHelper &resourceConfig)
|
||||
{
|
||||
language = configuration.GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_LANGUAGE);
|
||||
colormode = configuration.GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_COLORMODE);
|
||||
hasPointerDevice = configuration.GetItem(AAFwk::GlobalConfigurationKey::INPUT_POINTER_DEVICE);
|
||||
resourceConfig.SetLanguage(configuration.GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_LANGUAGE));
|
||||
resourceConfig.SetColormode(configuration.GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_COLORMODE));
|
||||
resourceConfig.SetHasPointerDevice(configuration.GetItem(AAFwk::GlobalConfigurationKey::INPUT_POINTER_DEVICE));
|
||||
resourceConfig.SetMcc(configuration.GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_MCC));
|
||||
resourceConfig.SetMnc(configuration.GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_MNC));
|
||||
resourceConfig.SetColorModeIsSetByApp(
|
||||
configuration.GetItem(AAFwk::GlobalConfigurationKey::COLORMODE_IS_SET_BY_APP));
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -362,23 +362,7 @@ void ExtensionAbilityThread::HandleCommandExtensionWindow(
|
||||
void ExtensionAbilityThread::ScheduleUpdateConfiguration(const AppExecFwk::Configuration &config)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::EXT, "Begin.");
|
||||
if (abilityHandler_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::EXT, "abilityHandler_ is nullptr.");
|
||||
return;
|
||||
}
|
||||
wptr<ExtensionAbilityThread> weak = this;
|
||||
auto task = [weak, config]() {
|
||||
auto abilityThread = weak.promote();
|
||||
if (abilityThread == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::EXT, "Ability thread is nullptr.");
|
||||
return;
|
||||
}
|
||||
abilityThread->HandleExtensionUpdateConfiguration(config);
|
||||
};
|
||||
bool ret = abilityHandler_->PostTask(task);
|
||||
if (!ret) {
|
||||
TAG_LOGE(AAFwkTag::EXT, "PostTask error");
|
||||
}
|
||||
HandleExtensionUpdateConfiguration(config);
|
||||
TAG_LOGD(AAFwkTag::EXT, "End.");
|
||||
}
|
||||
|
||||
|
||||
@@ -131,9 +131,7 @@ void ExtensionImpl::ScheduleUpdateConfiguration(const AppExecFwk::Configuration
|
||||
return;
|
||||
}
|
||||
|
||||
if (lifecycleState_ != AAFwk::ABILITY_STATE_INITIAL) {
|
||||
extension_->OnConfigurationUpdated(config);
|
||||
}
|
||||
extension_->OnConfigurationUpdated(config);
|
||||
}
|
||||
|
||||
void ExtensionImpl::NotifyMemoryLevel(int level)
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,158 @@
|
||||
/*
|
||||
* Copyright (c) 2023-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 "resource_config_helper.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "configuration_convertor.h"
|
||||
#include "hitrace_meter.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
using namespace AppExecFwk;
|
||||
|
||||
std::string ResourceConfigHelper::GetLanguage()
|
||||
{
|
||||
return language_;
|
||||
}
|
||||
void ResourceConfigHelper::SetLanguage(std::string language)
|
||||
{
|
||||
language_ = language;
|
||||
}
|
||||
|
||||
std::string ResourceConfigHelper::GetColormode()
|
||||
{
|
||||
return colormode_;
|
||||
}
|
||||
void ResourceConfigHelper::SetColormode(std::string colormode)
|
||||
{
|
||||
colormode_ = colormode;
|
||||
}
|
||||
std::string ResourceConfigHelper::GetHasPointerDevice()
|
||||
{
|
||||
return hasPointerDevice_;
|
||||
}
|
||||
void ResourceConfigHelper::SetHasPointerDevice(std::string hasPointerDevice)
|
||||
{
|
||||
hasPointerDevice_ = hasPointerDevice;
|
||||
}
|
||||
std::string ResourceConfigHelper::GetMcc()
|
||||
{
|
||||
return mcc_;
|
||||
}
|
||||
void ResourceConfigHelper::SetMcc(std::string mcc)
|
||||
{
|
||||
mcc_ = mcc;
|
||||
}
|
||||
std::string ResourceConfigHelper::GetMnc()
|
||||
{
|
||||
return mnc_;
|
||||
}
|
||||
void ResourceConfigHelper::SetMnc(std::string mnc)
|
||||
{
|
||||
mnc_ = mnc;
|
||||
}
|
||||
|
||||
std::string ResourceConfigHelper::GetColorModeIsSetByApp()
|
||||
{
|
||||
return colorModeIsSetByApp_;
|
||||
}
|
||||
void ResourceConfigHelper::SetColorModeIsSetByApp(std::string colorModeIsSetByApp)
|
||||
{
|
||||
colorModeIsSetByApp_ = colorModeIsSetByApp;
|
||||
}
|
||||
|
||||
void ResourceConfigHelper::UpdateResConfig(
|
||||
const AppExecFwk::Configuration &configuration, std::shared_ptr<Global::Resource::ResourceManager> resourceManager)
|
||||
{
|
||||
if (resourceManager == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::ABILITY, "Resource manager is invalid.");
|
||||
return;
|
||||
}
|
||||
std::unique_ptr<Global::Resource::ResConfig> resConfig(Global::Resource::CreateResConfig());
|
||||
if (resConfig == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::ABILITY, "Create res config failed.");
|
||||
return;
|
||||
}
|
||||
resourceManager->GetResConfig(*resConfig);
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
if (!language_.empty()) {
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
icu::Locale locale = icu::Locale::forLanguageTag(language_, status);
|
||||
TAG_LOGD(AAFwkTag::ABILITY, "Get forLanguageTag return[%{public}d].", static_cast<int>(status));
|
||||
if (status == U_ZERO_ERROR) {
|
||||
resConfig->SetLocaleInfo(locale);
|
||||
}
|
||||
const icu::Locale *localeInfo = resConfig->GetLocaleInfo();
|
||||
if (localeInfo != nullptr) {
|
||||
TAG_LOGD(AAFwkTag::ABILITY, "Update config, language: %{public}s, script: %{public}s,"
|
||||
" region: %{public}s", localeInfo->getLanguage(), localeInfo->getScript(), localeInfo->getCountry());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
UpdateResConfig(resConfig);
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, "resourceManager->UpdateResConfig");
|
||||
Global::Resource::RState ret = resourceManager->UpdateResConfig(*resConfig);
|
||||
if (ret != Global::Resource::RState::SUCCESS) {
|
||||
TAG_LOGE(AAFwkTag::ABILITY, "Update resource config failed with %{public}d.", static_cast<int>(ret));
|
||||
return;
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::ABILITY, "Current colorMode: %{public}d, hasPointerDevice: %{public}d.",
|
||||
resConfig->GetColorMode(), resConfig->GetInputDevice());
|
||||
}
|
||||
|
||||
void ResourceConfigHelper::UpdateResConfig(std::unique_ptr<Global::Resource::ResConfig> &resConfig)
|
||||
{
|
||||
if (resConfig == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::ABILITY, "resConfig is nullptr!");
|
||||
return;
|
||||
}
|
||||
if (!colormode_.empty()) {
|
||||
resConfig->SetColorMode(AppExecFwk::ConvertColorMode(colormode_));
|
||||
}
|
||||
if (!hasPointerDevice_.empty()) {
|
||||
resConfig->SetInputDevice(AppExecFwk::ConvertHasPointerDevice(hasPointerDevice_));
|
||||
}
|
||||
if (!colorModeIsSetByApp_.empty()) {
|
||||
TAG_LOGD(AAFwkTag::ABILITY, "set app true");
|
||||
resConfig->SetAppColorMode(true);
|
||||
}
|
||||
if (!mcc_.empty()) {
|
||||
uint32_t mccNum = 0;
|
||||
if (ConvertStringToUint32(mcc_, mccNum)) {
|
||||
resConfig->SetMcc(mccNum);
|
||||
TAG_LOGD(AAFwkTag::ABILITY, "set mcc: %{public}u", resConfig->GetMcc());
|
||||
}
|
||||
}
|
||||
if (!mnc_.empty()) {
|
||||
uint32_t mncNum = 0;
|
||||
if (ConvertStringToUint32(mnc_, mncNum)) {
|
||||
resConfig->SetMnc(mncNum);
|
||||
TAG_LOGD(AAFwkTag::ABILITY, "set mnc: %{public}u", resConfig->GetMnc());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool ResourceConfigHelper::ConvertStringToUint32(std::string source, uint32_t &result)
|
||||
{
|
||||
try {
|
||||
result = static_cast<uint32_t>(std::stoi(source));
|
||||
} catch (...) {
|
||||
TAG_LOGW(AAFwkTag::ABILITY, "source:%{public}s is invalid.", source.c_str());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "ohos_application.h"
|
||||
#include "reverse_continuation_scheduler_primary_stage.h"
|
||||
#include "runtime.h"
|
||||
#include "resource_config_helper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
@@ -299,44 +300,10 @@ void UIAbility::NotifyContinuationResult(const AAFwk::Want &want, bool success)
|
||||
void UIAbility::OnConfigurationUpdatedNotify(const AppExecFwk::Configuration &configuration)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::UIABILITY, "begin");
|
||||
std::string language;
|
||||
std::string colormode;
|
||||
std::string hasPointerDevice;
|
||||
InitConfigurationProperties(configuration, language, colormode, hasPointerDevice);
|
||||
std::string colorModeIsSetByApp = configuration.GetItem(AAFwk::GlobalConfigurationKey::COLORMODE_IS_SET_BY_APP);
|
||||
// Notify ResourceManager
|
||||
std::unique_ptr<Global::Resource::ResConfig> resConfig(Global::Resource::CreateResConfig());
|
||||
if (resConfig == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::UIABILITY, "Create res config failed.");
|
||||
return;
|
||||
}
|
||||
ResourceConfigHelper resourceConfig;
|
||||
InitConfigurationProperties(configuration, resourceConfig);
|
||||
auto resourceManager = GetResourceManager();
|
||||
if (resourceManager != nullptr) {
|
||||
resourceManager->GetResConfig(*resConfig);
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
if (!language.empty()) {
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
icu::Locale locale = icu::Locale::forLanguageTag(language, status);
|
||||
TAG_LOGD(AAFwkTag::UIABILITY, "Get forLanguageTag return[%{public}d].", static_cast<int>(status));
|
||||
if (status == U_ZERO_ERROR) {
|
||||
resConfig->SetLocaleInfo(locale);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (!colormode.empty()) {
|
||||
resConfig->SetColorMode(AppExecFwk::ConvertColorMode(colormode));
|
||||
}
|
||||
if (!hasPointerDevice.empty()) {
|
||||
resConfig->SetInputDevice(AppExecFwk::ConvertHasPointerDevice(hasPointerDevice));
|
||||
}
|
||||
if (!colorModeIsSetByApp.empty()) {
|
||||
TAG_LOGD(AAFwkTag::UIABILITY, "set app true");
|
||||
resConfig->SetAppColorMode(true);
|
||||
}
|
||||
resourceManager->UpdateResConfig(*resConfig);
|
||||
TAG_LOGD(AAFwkTag::UIABILITY, "Current colorMode: %{public}d, hasPointerDevice: %{public}d.",
|
||||
resConfig->GetColorMode(), resConfig->GetInputDevice());
|
||||
}
|
||||
resourceConfig.UpdateResConfig(configuration, resourceManager);
|
||||
|
||||
if (abilityContext_ != nullptr && application_ != nullptr) {
|
||||
abilityContext_->SetConfiguration(application_->GetConfiguration());
|
||||
@@ -346,25 +313,38 @@ void UIAbility::OnConfigurationUpdatedNotify(const AppExecFwk::Configuration &co
|
||||
TAG_LOGD(AAFwkTag::UIABILITY, "End.");
|
||||
}
|
||||
|
||||
void UIAbility::InitConfigurationProperties(const AppExecFwk::Configuration &changeConfiguration, std::string &language,
|
||||
std::string &colormode, std::string &hasPointerDevice)
|
||||
void UIAbility::InitConfigurationProperties(const AppExecFwk::Configuration &changeConfiguration,
|
||||
ResourceConfigHelper &resourceConfig)
|
||||
{
|
||||
resourceConfig.SetMcc(changeConfiguration.GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_MCC));
|
||||
resourceConfig.SetMnc(changeConfiguration.GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_MNC));
|
||||
resourceConfig.SetColorModeIsSetByApp(
|
||||
changeConfiguration.GetItem(AAFwk::GlobalConfigurationKey::COLORMODE_IS_SET_BY_APP));
|
||||
if (setting_) {
|
||||
auto displayId =
|
||||
std::atoi(setting_->GetProperty(AppExecFwk::AbilityStartSetting::WINDOW_DISPLAY_ID_KEY).c_str());
|
||||
language = changeConfiguration.GetItem(displayId, AAFwk::GlobalConfigurationKey::SYSTEM_LANGUAGE);
|
||||
colormode = changeConfiguration.GetItem(displayId, AAFwk::GlobalConfigurationKey::SYSTEM_COLORMODE);
|
||||
hasPointerDevice = changeConfiguration.GetItem(displayId, AAFwk::GlobalConfigurationKey::INPUT_POINTER_DEVICE);
|
||||
resourceConfig.SetLanguage(changeConfiguration.GetItem(displayId,
|
||||
AAFwk::GlobalConfigurationKey::SYSTEM_LANGUAGE));
|
||||
resourceConfig.SetColormode(changeConfiguration.GetItem(displayId,
|
||||
AAFwk::GlobalConfigurationKey::SYSTEM_COLORMODE));
|
||||
resourceConfig.SetHasPointerDevice(changeConfiguration.GetItem(displayId,
|
||||
AAFwk::GlobalConfigurationKey::INPUT_POINTER_DEVICE));
|
||||
TAG_LOGD(AAFwkTag::UIABILITY, "displayId: [%{public}d], language: [%{public}s], colormode: [%{public}s], "
|
||||
"hasPointerDevice: [%{public}s].",
|
||||
displayId, language.c_str(), colormode.c_str(), hasPointerDevice.c_str());
|
||||
"hasPointerDevice: [%{public}s] mcc: [%{public}s], mnc: [%{public}s].", displayId,
|
||||
resourceConfig.GetLanguage().c_str(), resourceConfig.GetColormode().c_str(),
|
||||
resourceConfig.GetHasPointerDevice().c_str(), resourceConfig.GetMcc().c_str(),
|
||||
resourceConfig.GetMnc().c_str());
|
||||
} else {
|
||||
language = changeConfiguration.GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_LANGUAGE);
|
||||
colormode = changeConfiguration.GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_COLORMODE);
|
||||
hasPointerDevice = changeConfiguration.GetItem(AAFwk::GlobalConfigurationKey::INPUT_POINTER_DEVICE);
|
||||
resourceConfig.SetLanguage(changeConfiguration.GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_LANGUAGE));
|
||||
resourceConfig.SetColormode(changeConfiguration.GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_COLORMODE));
|
||||
resourceConfig.SetHasPointerDevice(changeConfiguration.GetItem(
|
||||
AAFwk::GlobalConfigurationKey::INPUT_POINTER_DEVICE));
|
||||
TAG_LOGD(AAFwkTag::UIABILITY,
|
||||
"Language: [%{public}s], colormode: [%{public}s], hasPointerDevice: [%{public}s].",
|
||||
language.c_str(), colormode.c_str(), hasPointerDevice.c_str());
|
||||
"Language: [%{public}s], colormode: [%{public}s], hasPointerDevice: [%{public}s] "
|
||||
"mcc: [%{public}s], mnc: [%{public}s].",
|
||||
resourceConfig.GetLanguage().c_str(), resourceConfig.GetColormode().c_str(),
|
||||
resourceConfig.GetHasPointerDevice().c_str(), resourceConfig.GetMcc().c_str(),
|
||||
resourceConfig.GetMnc().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -324,10 +324,9 @@ void UIAbilityImpl::ScheduleUpdateConfiguration(const AppExecFwk::Configuration
|
||||
return;
|
||||
}
|
||||
|
||||
if (lifecycleState_ != AAFwk::ABILITY_STATE_INITIAL) {
|
||||
TAG_LOGD(AAFwkTag::UIABILITY, "Ability name: [%{public}s].", ability_->GetAbilityName().c_str());
|
||||
ability_->OnConfigurationUpdatedNotify(config);
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::UIABILITY, "Ability name: [%{public}s].", ability_->GetAbilityName().c_str());
|
||||
ability_->OnConfigurationUpdatedNotify(config);
|
||||
|
||||
TAG_LOGD(AAFwkTag::UIABILITY, "End.");
|
||||
}
|
||||
|
||||
|
||||
@@ -262,11 +262,14 @@ void JsUIExtension::OnStart(const AAFwk::Want &want)
|
||||
if (InsightIntentExecuteParam::IsInsightIntentExecute(want)) {
|
||||
launchParam.launchReason = AAFwk::LaunchReason::LAUNCHREASON_INSIGHT_INTENT;
|
||||
}
|
||||
napi_value argv[] = {
|
||||
CreateJsLaunchParam(env, launchParam),
|
||||
napiWant
|
||||
};
|
||||
CallObjectMethod("onCreate", argv, ARGC_TWO);
|
||||
int32_t screenMode = want.GetIntParam(AAFwk::SCREEN_MODE_KEY, AAFwk::IDLE_SCREEN_MODE);
|
||||
if (screenMode == AAFwk::EMBEDDED_FULL_SCREEN_MODE) {
|
||||
napi_value argv[] = {napiWant, CreateJsLaunchParam(env, launchParam) };
|
||||
CallObjectMethod("onCreate", argv, ARGC_TWO);
|
||||
} else {
|
||||
napi_value argv[] = {CreateJsLaunchParam(env, launchParam) };
|
||||
CallObjectMethod("onCreate", argv, ARGC_ONE);
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::UI_EXT, "JsUIExtension OnStart end.");
|
||||
}
|
||||
|
||||
|
||||
@@ -499,7 +499,10 @@ ohos_shared_library("application_context_manager") {
|
||||
cflags += [ "-DBINDER_IPC_32BIT" ]
|
||||
}
|
||||
|
||||
external_deps = [ "napi:ace_napi" ]
|
||||
external_deps = [
|
||||
"ets_runtime:libark_jsruntime",
|
||||
"napi:ace_napi",
|
||||
]
|
||||
|
||||
public_configs = [ ":application_context_manager_config" ]
|
||||
|
||||
|
||||
@@ -644,8 +644,10 @@ bool BundleMgrHelper::ImplicitQueryInfos(const Want &want, int32_t flags, int32_
|
||||
newWant.RemoveAllFd();
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
bool findDefaultApp = false;
|
||||
return bundleMgr->ImplicitQueryInfos(newWant, flags, userId, withDefault, abilityInfos, extensionInfos,
|
||||
findDefaultApp);
|
||||
bool ret = bundleMgr->ImplicitQueryInfos(newWant, flags, userId, withDefault, abilityInfos,
|
||||
extensionInfos, findDefaultApp);
|
||||
TAG_LOGD(AAFwkTag::BUNDLEMGRHELPER, "findDefaultApp is %{public}d.", findDefaultApp);
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool BundleMgrHelper::CleanBundleDataFiles(const std::string &bundleName, const int32_t userId)
|
||||
|
||||
@@ -502,6 +502,19 @@ void ApplicationContext::SetLanguage(const std::string &language)
|
||||
}
|
||||
}
|
||||
|
||||
void ApplicationContext::SetFont(const std::string &font)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "font:%{public}s.", font.c_str());
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
// Notify Window
|
||||
AppExecFwk::Configuration config;
|
||||
config.AddItem(AppExecFwk::ConfigurationInner::APPLICATION_FONT, font);
|
||||
if (appFontCallback_ != nullptr) {
|
||||
appFontCallback_(config);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void ApplicationContext::ClearUpApplicationData()
|
||||
{
|
||||
if (contextImpl_ != nullptr) {
|
||||
@@ -538,6 +551,11 @@ void ApplicationContext::RegisterAppConfigUpdateObserver(AppConfigUpdateCallback
|
||||
appConfigChangeCallback_ = appConfigChangeCallback;
|
||||
}
|
||||
|
||||
void ApplicationContext::RegisterAppFontObserver(AppConfigUpdateCallback appFontCallback)
|
||||
{
|
||||
appFontCallback_ = appFontCallback;
|
||||
}
|
||||
|
||||
std::string ApplicationContext::GetAppRunningUniqueId() const
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "GetAppRunningUniqueId is %{public}s.", appRunningUniqueId_.c_str());
|
||||
|
||||
@@ -71,7 +71,7 @@ const std::string ContextImpl::CONTEXT_DATABASE("database");
|
||||
const std::string ContextImpl::CONTEXT_TEMP("/temp");
|
||||
const std::string ContextImpl::CONTEXT_FILES("/files");
|
||||
const std::string ContextImpl::CONTEXT_HAPS("/haps");
|
||||
const std::string ContextImpl::CONTEXT_ELS[] = {"el1", "el2", "el3", "el4"};
|
||||
const std::string ContextImpl::CONTEXT_ELS[] = {"el1", "el2", "el3", "el4", "el5"};
|
||||
const std::string ContextImpl::CONTEXT_RESOURCE_END = "/resources/resfile";
|
||||
Global::Resource::DeviceType ContextImpl::deviceType_ = Global::Resource::DeviceType::DEVICE_NOT_SET;
|
||||
const std::string OVERLAY_STATE_CHANGED = "usual.event.OVERLAY_STATE_CHANGED";
|
||||
@@ -82,6 +82,7 @@ const int32_t API_VERSION_MOD = 100;
|
||||
const int32_t ERR_ABILITY_RUNTIME_EXTERNAL_NOT_SYSTEM_HSP = 16400001;
|
||||
const int AREA2 = 2;
|
||||
const int AREA3 = 3;
|
||||
const int AREA4 = 4;
|
||||
|
||||
std::string ContextImpl::GetBundleName() const
|
||||
{
|
||||
@@ -328,8 +329,10 @@ std::string ContextImpl::GetDistributedFilesDir()
|
||||
dir = CONTEXT_DISTRIBUTEDFILES_BASE_BEFORE + std::to_string(GetCurrentAccountId()) +
|
||||
CONTEXT_DISTRIBUTEDFILES_BASE_MIDDLE + GetBundleName();
|
||||
} else {
|
||||
if (currArea_ == CONTEXT_ELS[1] || currArea_ == CONTEXT_ELS[AREA2] || currArea_ == CONTEXT_ELS[AREA3]) {
|
||||
//when areamode swith to el3/el4, the distributedfiles dir should be always el2's distributedfilesdir dir
|
||||
if (currArea_ == CONTEXT_ELS[1] || currArea_ == CONTEXT_ELS[AREA2] || currArea_ == CONTEXT_ELS[AREA3] ||
|
||||
currArea_ == CONTEXT_ELS[AREA4]) {
|
||||
// when areamode swith to el3/el4/el5, the distributedfiles dir should be always el2's
|
||||
// distributedfilesdir dir
|
||||
dir = CONTEXT_DATA_STORAGE + CONTEXT_ELS[1] + CONTEXT_FILE_SEPARATOR + CONTEXT_DISTRIBUTEDFILES;
|
||||
} else {
|
||||
dir = CONTEXT_DATA_STORAGE + currArea_ + CONTEXT_FILE_SEPARATOR + CONTEXT_DISTRIBUTEDFILES;
|
||||
|
||||
@@ -666,6 +666,34 @@ napi_value JsApplicationContextUtils::OnSetLanguage(napi_env env, NapiCallbackIn
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
napi_value JsApplicationContextUtils::SetFont(napi_env env, napi_callback_info info)
|
||||
{
|
||||
GET_NAPI_INFO_WITH_NAME_AND_CALL(env, info, JsApplicationContextUtils, OnSetFont, APPLICATION_CONTEXT_NAME);
|
||||
}
|
||||
|
||||
napi_value JsApplicationContextUtils::OnSetFont(napi_env env, NapiCallbackInfo& info)
|
||||
{
|
||||
// only support one params
|
||||
if (info.argc == ARGC_ZERO) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "Not enough params");
|
||||
ThrowInvalidParamError(env, "Not enough params.");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
auto applicationContext = applicationContext_.lock();
|
||||
if (!applicationContext) {
|
||||
TAG_LOGW(AAFwkTag::APPKIT, "applicationContext is already released");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
std::string font;
|
||||
if (!ConvertFromJsValue(env, info.argv[INDEX_ZERO], font)) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "Parse font failed");
|
||||
ThrowInvalidParamError(env, "Parse param font failed, font must be string.");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
applicationContext->SetFont(font);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
napi_value JsApplicationContextUtils::PreloadUIExtensionAbility(napi_env env, napi_callback_info info)
|
||||
{
|
||||
GET_NAPI_INFO_WITH_NAME_AND_CALL(
|
||||
@@ -1058,7 +1086,7 @@ napi_value JsApplicationContextUtils::OnOn(napi_env env, NapiCallbackInfo& info)
|
||||
return OnOnApplicationStateChange(env, info);
|
||||
}
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "on function type not match.");
|
||||
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER);
|
||||
ThrowInvalidParamError(env, "Parse param callback failed, callback must be function.");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
@@ -1113,7 +1141,7 @@ napi_value JsApplicationContextUtils::OnOff(napi_env env, NapiCallbackInfo& info
|
||||
return OnOffEnvironmentEventSync(env, info, callbackId);
|
||||
}
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "off function type not match.");
|
||||
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER);
|
||||
ThrowInvalidParamError(env, "Parse param callback failed, callback must be function.");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
@@ -1329,7 +1357,8 @@ napi_value JsApplicationContextUtils::OnOffApplicationStateChange(
|
||||
std::lock_guard<std::mutex> lock(applicationStateCallbackLock_);
|
||||
if (applicationStateCallback_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "ApplicationStateCallback_ is nullptr.");
|
||||
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER);
|
||||
ThrowInvalidParamError(env,
|
||||
"Parse applicationStateCallback failed, applicationStateCallback must be function.");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
@@ -1337,7 +1366,7 @@ napi_value JsApplicationContextUtils::OnOffApplicationStateChange(
|
||||
applicationStateCallback_->UnRegister();
|
||||
} else if (!applicationStateCallback_->UnRegister(info.argv[INDEX_ONE])) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "call UnRegister failed!");
|
||||
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER);
|
||||
ThrowInvalidParamError(env, "Parse param call UnRegister failed, call UnRegister must be function.");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
@@ -1515,6 +1544,7 @@ void JsApplicationContextUtils::BindNativeApplicationContext(napi_env env, napi_
|
||||
BindNativeFunction(env, object, "killAllProcesses", MD_NAME, JsApplicationContextUtils::KillProcessBySelf);
|
||||
BindNativeFunction(env, object, "setColorMode", MD_NAME, JsApplicationContextUtils::SetColorMode);
|
||||
BindNativeFunction(env, object, "setLanguage", MD_NAME, JsApplicationContextUtils::SetLanguage);
|
||||
BindNativeFunction(env, object, "setFont", MD_NAME, JsApplicationContextUtils::SetFont);
|
||||
BindNativeFunction(env, object, "clearUpApplicationData", MD_NAME,
|
||||
JsApplicationContextUtils::ClearUpApplicationData);
|
||||
BindNativeFunction(env, object, "preloadUIExtensionAbility", MD_NAME,
|
||||
@@ -1525,10 +1555,8 @@ void JsApplicationContextUtils::BindNativeApplicationContext(napi_env env, napi_
|
||||
JsApplicationContextUtils::GetRunningProcessInformation);
|
||||
BindNativeFunction(env, object, "getCurrentAppCloneIndex", MD_NAME,
|
||||
JsApplicationContextUtils::GetCurrentAppCloneIndex);
|
||||
BindNativeFunction(env, object, "getGroupDir", MD_NAME,
|
||||
JsApplicationContextUtils::GetGroupDir);
|
||||
BindNativeFunction(env, object, "restartApp", MD_NAME,
|
||||
JsApplicationContextUtils::RestartApp);
|
||||
BindNativeFunction(env, object, "getGroupDir", MD_NAME, JsApplicationContextUtils::GetGroupDir);
|
||||
BindNativeFunction(env, object, "restartApp", MD_NAME, JsApplicationContextUtils::RestartApp);
|
||||
BindNativeFunction(env, object, "setSupportedProcessCache", MD_NAME,
|
||||
JsApplicationContextUtils::SetSupportedProcessCacheSelf);
|
||||
}
|
||||
|
||||
@@ -57,6 +57,7 @@
|
||||
#include "freeze_util.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "resource_config_helper.h"
|
||||
#ifdef SUPPORT_SCREEN
|
||||
#include "locale_config.h"
|
||||
#include "ace_forward_compatibility.h"
|
||||
@@ -643,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);
|
||||
@@ -1110,6 +1102,21 @@ bool MainThread::InitResourceManager(std::shared_ptr<Global::Resource::ResourceM
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "deviceType is %{public}s <----> %{public}d.", deviceType.c_str(),
|
||||
ConvertDeviceType(deviceType));
|
||||
resConfig->SetDeviceType(ConvertDeviceType(deviceType));
|
||||
|
||||
std::string mcc = config.GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_MCC);
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "mcc is %{public}s.", mcc.c_str());
|
||||
uint32_t mccNum = 0;
|
||||
if (AbilityRuntime::ResourceConfigHelper::ConvertStringToUint32(mcc, mccNum)) {
|
||||
resConfig->SetMcc(mccNum);
|
||||
}
|
||||
|
||||
std::string mnc = config.GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_MNC);
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "mnc is %{public}s.", mnc.c_str());
|
||||
uint32_t mncNum = 0;
|
||||
if (AbilityRuntime::ResourceConfigHelper::ConvertStringToUint32(mnc, mncNum)) {
|
||||
resConfig->SetMnc(mncNum);
|
||||
}
|
||||
|
||||
resourceManager->UpdateResConfig(*resConfig);
|
||||
return true;
|
||||
}
|
||||
@@ -3315,5 +3322,52 @@ int32_t MainThread::ScheduleDumpFfrt(std::string& result)
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "MainThread::ScheduleDumpFfrt::pid:%{public}d", getprocpid());
|
||||
return DumpFfrtHelper::DumpFfrt(result);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Notify application to prepare for process caching.
|
||||
*
|
||||
*/
|
||||
void MainThread::ScheduleCacheProcess()
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "ScheduleCacheProcess");
|
||||
wptr<MainThread> weak = this;
|
||||
auto task = [weak]() {
|
||||
auto appThread = weak.promote();
|
||||
if (appThread == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "appThread is nullptr");
|
||||
return;
|
||||
}
|
||||
appThread->HandleCacheProcess();
|
||||
};
|
||||
if (mainHandler_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "handler nullptr");
|
||||
return;
|
||||
}
|
||||
if (!mainHandler_->PostTask(task, "MainThread:ScheduleCacheProcess")) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "PostTask task failed");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Notify application to prepare for process caching.
|
||||
*
|
||||
*/
|
||||
void MainThread::HandleCacheProcess()
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "start.");
|
||||
|
||||
// force gc
|
||||
if (application_ != nullptr) {
|
||||
auto &runtime = application_->GetRuntime();
|
||||
if (runtime == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "runtime nullptr");
|
||||
return;
|
||||
}
|
||||
runtime->ForceFullGC();
|
||||
}
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -200,10 +200,19 @@ void OHOSApplication::SetApplicationContext(
|
||||
abilityRuntimeContext_->RegisterAppConfigUpdateObserver([applicationWptr](const Configuration &config) {
|
||||
std::shared_ptr<OHOSApplication> applicationSptr = applicationWptr.lock();
|
||||
if (applicationSptr == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "application is nullptr.");
|
||||
return;
|
||||
}
|
||||
applicationSptr->OnConfigurationUpdated(config);
|
||||
});
|
||||
abilityRuntimeContext_->RegisterAppFontObserver([applicationWptr](const Configuration &config) {
|
||||
std::shared_ptr<OHOSApplication> applicationSptr = applicationWptr.lock();
|
||||
if (applicationSptr == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "application is nullptr.");
|
||||
return;
|
||||
}
|
||||
applicationSptr->OnFontUpdated(config);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -537,6 +546,22 @@ void OHOSApplication::OnConfigurationUpdated(Configuration config)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Will be Called when the application font of the device changes.
|
||||
*
|
||||
* @param config Indicates the new Configuration object.
|
||||
*/
|
||||
void OHOSApplication::OnFontUpdated(Configuration config)
|
||||
{
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
// Notify Window
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "Update configuration for all window.");
|
||||
auto diffConfiguration = std::make_shared<AppExecFwk::Configuration>(config);
|
||||
Rosen::Window::UpdateConfigurationForAll(diffConfiguration);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Called when the system has determined to trim the memory, for example,
|
||||
@@ -654,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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -34,7 +34,7 @@ constexpr const char *CONTEXT_TEMP("temp");
|
||||
constexpr const char *CONTEXT_FILES("files");
|
||||
constexpr const char *CONTEXT_HAPS("haps");
|
||||
constexpr const char *CONTEXT_ASSET("asset");
|
||||
constexpr const char *CONTEXT_ELS[] = {"el1", "el2", "el3", "el4"};
|
||||
constexpr const char *CONTEXT_ELS[] = {"el1", "el2", "el3", "el4", "el5"};
|
||||
constexpr const char *CONTEXT_RESOURCE_BASE("/data/storage/el1/bundle");
|
||||
constexpr const char *CONTEXT_RESOURCE_END("/resources/resfile");
|
||||
constexpr int DIR_DEFAULT_PERM = 0770;
|
||||
|
||||
@@ -43,6 +43,7 @@ constexpr const char* EMPTY_STRING = "";
|
||||
constexpr const char* APPLICATION_DIRECTION = "ohos.application.direction";
|
||||
constexpr const char* APPLICATION_DENSITYDPI = "ohos.application.densitydpi";
|
||||
constexpr const char* APPLICATION_DISPLAYID = "ohos.application.displayid";
|
||||
constexpr const char* APPLICATION_FONT = "ohos.application.font";
|
||||
|
||||
constexpr const char* COLOR_MODE_LIGHT = "light";
|
||||
constexpr const char* COLOR_MODE_DARK = "dark";
|
||||
|
||||
@@ -32,6 +32,7 @@ public:
|
||||
std::string abilityName;
|
||||
std::string moduleName;
|
||||
std::string abilityTypeName;
|
||||
std::string accessTokenId;
|
||||
int32_t appCloneIndex = -1;
|
||||
|
||||
bool ReadFromParcel(Parcel &parcel);
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
|
||||
@@ -64,6 +64,7 @@ private:
|
||||
int32_t HandleScheduleDumpIpcStop(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleScheduleDumpIpcStat(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleScheduleDumpFfrt(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleScheduleCacheProcess(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
using AppSchedulerFunc = int32_t (AppSchedulerHost::*)(MessageParcel &data, MessageParcel &reply);
|
||||
std::map<uint32_t, AppSchedulerFunc> memberFuncMap_;
|
||||
|
||||
@@ -272,6 +272,8 @@ public:
|
||||
*/
|
||||
virtual int32_t ScheduleDumpFfrt(std::string& result) = 0;
|
||||
|
||||
virtual void ScheduleCacheProcess() = 0;
|
||||
|
||||
enum class Message {
|
||||
SCHEDULE_FOREGROUND_APPLICATION_TRANSACTION = 0,
|
||||
SCHEDULE_BACKGROUND_APPLICATION_TRANSACTION,
|
||||
@@ -302,6 +304,7 @@ public:
|
||||
SCHEDULE_DUMP_IPC_STOP,
|
||||
SCHEDULE_DUMP_IPC_STAT,
|
||||
SCHEDULE_DUMP_FFRT,
|
||||
SCHEDULE_CACHE_PROCESS,
|
||||
};
|
||||
};
|
||||
} // namespace AppExecFwk
|
||||
|
||||
@@ -232,6 +232,8 @@ public:
|
||||
*/
|
||||
virtual int32_t ScheduleDumpFfrt(std::string& result) override;
|
||||
|
||||
virtual void ScheduleCacheProcess() override;
|
||||
|
||||
private:
|
||||
bool WriteInterfaceToken(MessageParcel &data);
|
||||
void ScheduleMemoryCommon(const int32_t level, const uint32_t operation);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -256,6 +256,10 @@ int32_t AppMgrProxy::GetRunningMultiAppInfoByBundleName(const std::string &bundl
|
||||
return ret;
|
||||
}
|
||||
std::unique_ptr<RunningMultiAppInfo> infoReply(reply.ReadParcelable<RunningMultiAppInfo>());
|
||||
if (infoReply == nullptr) {
|
||||
TAG_LOGW(AAFwkTag::APPMGR, "reply ReadParcelable is nullptr");
|
||||
return ERR_NULL_OBJECT;
|
||||
}
|
||||
info = *infoReply;
|
||||
int result = reply.ReadInt32();
|
||||
return result;
|
||||
@@ -362,6 +366,10 @@ int32_t AppMgrProxy::GetProcessRunningInformation(RunningProcessInfo &info)
|
||||
return ERR_NULL_OBJECT;
|
||||
}
|
||||
std::unique_ptr<RunningProcessInfo> infoReply(reply.ReadParcelable<RunningProcessInfo>());
|
||||
if (infoReply == nullptr) {
|
||||
TAG_LOGW(AAFwkTag::APPMGR, "reply ReadParcelable is nullptr");
|
||||
return ERR_NULL_OBJECT;
|
||||
}
|
||||
info = *infoReply;
|
||||
return reply.ReadInt32();
|
||||
}
|
||||
|
||||
@@ -88,6 +88,8 @@ void AppSchedulerHost::InitMemberFuncMap()
|
||||
&AppSchedulerHost::HandleScheduleDumpIpcStat;
|
||||
memberFuncMap_[static_cast<uint32_t>(IAppScheduler::Message::SCHEDULE_DUMP_FFRT)] =
|
||||
&AppSchedulerHost::HandleScheduleDumpFfrt;
|
||||
memberFuncMap_[static_cast<uint32_t>(IAppScheduler::Message::SCHEDULE_CACHE_PROCESS)] =
|
||||
&AppSchedulerHost::HandleScheduleCacheProcess;
|
||||
}
|
||||
|
||||
AppSchedulerHost::~AppSchedulerHost()
|
||||
@@ -447,5 +449,12 @@ int32_t AppSchedulerHost::HandleScheduleDumpFfrt(MessageParcel &data, MessagePar
|
||||
}
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t AppSchedulerHost::HandleScheduleCacheProcess(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
HITRACE_METER(HITRACE_TAG_APP);
|
||||
ScheduleCacheProcess();
|
||||
return NO_ERROR;
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -751,5 +751,20 @@ int32_t AppSchedulerProxy::SendTransactCmd(uint32_t code, MessageParcel &data,
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void AppSchedulerProxy::ScheduleCacheProcess()
|
||||
{
|
||||
uint32_t operation = static_cast<uint32_t>(IAppScheduler::Message::SCHEDULE_CACHE_PROCESS);
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_ASYNC);
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
return;
|
||||
}
|
||||
int32_t ret = SendTransactCmd(operation, data, reply, option);
|
||||
if (ret != NO_ERROR) {
|
||||
TAG_LOGW(AAFwkTag::APPMGR, "SendRequest is failed, error code: %{public}d", ret);
|
||||
}
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -50,6 +50,7 @@ ohos_shared_library("auto_fill_manager") {
|
||||
"eventhandler:libeventhandler",
|
||||
"hilog:libhilog",
|
||||
"init:libbegetutil",
|
||||
"ipc:ipc_core",
|
||||
]
|
||||
|
||||
if (ability_runtime_graphics) {
|
||||
|
||||
@@ -179,7 +179,7 @@ void AutoFillExtensionCallback::onDestroy()
|
||||
}
|
||||
return;
|
||||
}
|
||||
SendAutoFillFailed(AutoFill::AUTO_FILL_CANCEL);
|
||||
SendAutoFillFailed(AutoFill::AUTO_FILL_FAILED);
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
CloseModalUIExtension();
|
||||
#endif
|
||||
|
||||
@@ -28,6 +28,12 @@ config("dataobs_manager_public_config") {
|
||||
}
|
||||
|
||||
ohos_shared_library("dataobs_manager") {
|
||||
branch_protector_ret = "pac_ret"
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
debug = false
|
||||
}
|
||||
sources = [
|
||||
"${ability_runtime_services_path}/dataobsmgr/src/data_ability_observer_proxy.cpp",
|
||||
"${ability_runtime_services_path}/dataobsmgr/src/data_ability_observer_stub.cpp",
|
||||
|
||||
@@ -108,6 +108,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;
|
||||
|
||||
@@ -65,8 +65,6 @@ ohos_shared_library("wantagent_innerkits") {
|
||||
"src/want_agent_log_wrapper.cpp",
|
||||
]
|
||||
|
||||
configs = [ "${c_utils_base_path}:utils_config" ]
|
||||
|
||||
public_configs = [ ":wantagent_innerkits_public_config" ]
|
||||
|
||||
deps = [
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#define OHOS_ABILITY_RUNTIME_CONFIGURATION_UTILS_H
|
||||
|
||||
#include "configuration.h"
|
||||
#include "resource_config_helper.h"
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
#include "display_manager.h"
|
||||
#endif
|
||||
@@ -40,8 +41,8 @@ public:
|
||||
void UpdateGlobalConfig(const Configuration &configuration, std::shared_ptr<ResourceManager> resourceManager);
|
||||
|
||||
private:
|
||||
void GetGlobalConfig(const Configuration &configuration, std::string &language, std::string &colormode,
|
||||
std::string &hasPointerDevice);
|
||||
void GetGlobalConfig(const Configuration &configuration,
|
||||
OHOS::AbilityRuntime::ResourceConfigHelper &resourceConfig);
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
public:
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_ABILITY_RUNTIME_RESOURCE_CONFIG_HELPER_H
|
||||
#define OHOS_ABILITY_RUNTIME_RESOURCE_CONFIG_HELPER_H
|
||||
#include "resource_manager.h"
|
||||
#include "configuration.h"
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
#include "display_manager.h"
|
||||
#endif
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
|
||||
}
|
||||
namespace AbilityRuntime {
|
||||
class ResourceConfigHelper {
|
||||
public:
|
||||
ResourceConfigHelper() = default;
|
||||
~ResourceConfigHelper() = default;
|
||||
std::string GetLanguage();
|
||||
void SetLanguage(std::string language);
|
||||
std::string GetColormode();
|
||||
void SetColormode(std::string colormode);
|
||||
std::string GetHasPointerDevice();
|
||||
void SetHasPointerDevice(std::string hasPointerDevice);
|
||||
std::string GetMcc();
|
||||
void SetMcc(std::string mcc);
|
||||
std::string GetMnc();
|
||||
void SetMnc(std::string mnc);
|
||||
std::string GetColorModeIsSetByApp();
|
||||
void SetColorModeIsSetByApp(std::string colorModeIsSetByApp);
|
||||
|
||||
void UpdateResConfig(const AppExecFwk::Configuration &configuration,
|
||||
std::shared_ptr<Global::Resource::ResourceManager> resourceManager);
|
||||
|
||||
static bool ConvertStringToUint32(std::string source, uint32_t &result);
|
||||
|
||||
private:
|
||||
std::string language_;
|
||||
std::string colormode_;
|
||||
std::string hasPointerDevice_;
|
||||
std::string mcc_;
|
||||
std::string mnc_;
|
||||
std::string colorModeIsSetByApp_;
|
||||
|
||||
void UpdateResConfig(std::unique_ptr<Global::Resource::ResConfig> &resConfig);
|
||||
};
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_ABILITY_RUNTIME_RESOURCE_CONFIG_HELPER_H
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "foundation/ability/ability_runtime/interfaces/kits/native/ability/ability_runtime/ability_context.h"
|
||||
#include "iability_callback.h"
|
||||
#include "want.h"
|
||||
#include "resource_config_helper.h"
|
||||
#ifdef SUPPORT_SCREEN
|
||||
#include "display_manager.h"
|
||||
#include "session_info.h"
|
||||
@@ -340,8 +341,8 @@ private:
|
||||
void HandleCreateAsRecovery(const AAFwk::Want &want);
|
||||
void SetStartAbilitySetting(std::shared_ptr<AppExecFwk::AbilityStartSetting> setting);
|
||||
void SetLaunchParam(const AAFwk::LaunchParam &launchParam);
|
||||
void InitConfigurationProperties(const AppExecFwk::Configuration &changeConfiguration, std::string &language,
|
||||
std::string &colormode, std::string &hasPointerDevice);
|
||||
void InitConfigurationProperties(const AppExecFwk::Configuration &changeConfiguration,
|
||||
ResourceConfigHelper &resourceConfig);
|
||||
|
||||
std::shared_ptr<AppExecFwk::ContinuationHandlerStage> continuationHandler_ = nullptr;
|
||||
std::shared_ptr<AppExecFwk::ContinuationManagerStage> continuationManager_ = nullptr;
|
||||
|
||||
@@ -91,6 +91,7 @@ public:
|
||||
void SwitchArea(int mode) override;
|
||||
void SetColorMode(int32_t colorMode);
|
||||
void SetLanguage(const std::string &language);
|
||||
void SetFont(const std::string &font);
|
||||
void ClearUpApplicationData();
|
||||
int GetArea() override;
|
||||
std::shared_ptr<AppExecFwk::Configuration> GetConfiguration() const override;
|
||||
@@ -110,6 +111,7 @@ public:
|
||||
bool GetApplicationInfoUpdateFlag() const;
|
||||
void SetApplicationInfoUpdateFlag(bool flag);
|
||||
void RegisterAppConfigUpdateObserver(AppConfigUpdateCallback appConfigChangeCallback);
|
||||
void RegisterAppFontObserver(AppConfigUpdateCallback appFontCallback);
|
||||
|
||||
std::string GetAppRunningUniqueId() const;
|
||||
void SetAppRunningUniqueId(const std::string &appRunningUniqueId);
|
||||
@@ -128,6 +130,7 @@ private:
|
||||
std::recursive_mutex applicationStateCallbackLock_;
|
||||
bool applicationInfoUpdateFlag_ = false;
|
||||
AppConfigUpdateCallback appConfigChangeCallback_ = nullptr;
|
||||
AppConfigUpdateCallback appFontCallback_ = nullptr;
|
||||
std::string appRunningUniqueId_;
|
||||
int32_t appIndex_ = 0;
|
||||
int32_t appMode_ = 0;
|
||||
|
||||
@@ -157,12 +157,19 @@ public:
|
||||
void SetColorMode(int colorMode);
|
||||
|
||||
/**
|
||||
* @brief Set color mode
|
||||
* @brief Set language
|
||||
*
|
||||
* @param colorMode color mode.
|
||||
* @param language language.
|
||||
*/
|
||||
void SetLanguage(std::string language);
|
||||
|
||||
/**
|
||||
* @brief Set font
|
||||
*
|
||||
* @param Font font.
|
||||
*/
|
||||
void SetFont(std::string font);
|
||||
|
||||
/**
|
||||
* @brief clear the application data by app self
|
||||
*/
|
||||
|
||||
@@ -94,6 +94,7 @@ public:
|
||||
napi_value OnGetRunningProcessInformation(napi_env env, NapiCallbackInfo& info);
|
||||
napi_value OnSetColorMode(napi_env env, NapiCallbackInfo& info);
|
||||
napi_value OnSetLanguage(napi_env env, NapiCallbackInfo& info);
|
||||
napi_value OnSetFont(napi_env env, NapiCallbackInfo& info);
|
||||
napi_value OnClearUpApplicationData(napi_env env, NapiCallbackInfo& info);
|
||||
napi_value OnRestartApp(napi_env env, NapiCallbackInfo& info);
|
||||
napi_value OnSetSupportedProcessCacheSelf(napi_env env, NapiCallbackInfo& info);
|
||||
@@ -114,6 +115,7 @@ public:
|
||||
static napi_value KillProcessBySelf(napi_env env, napi_callback_info info);
|
||||
static napi_value SetColorMode(napi_env env, napi_callback_info info);
|
||||
static napi_value SetLanguage(napi_env env, napi_callback_info info);
|
||||
static napi_value SetFont(napi_env env, napi_callback_info info);
|
||||
static napi_value ClearUpApplicationData(napi_env env, napi_callback_info info);
|
||||
static napi_value GetRunningProcessInformation(napi_env env, napi_callback_info info);
|
||||
static napi_value CreateJsApplicationContext(napi_env env);
|
||||
|
||||
@@ -345,6 +345,7 @@ public:
|
||||
*/
|
||||
int32_t ScheduleDumpFfrt(std::string& result) override;
|
||||
|
||||
void ScheduleCacheProcess() override;
|
||||
private:
|
||||
/**
|
||||
*
|
||||
@@ -606,6 +607,8 @@ private:
|
||||
|
||||
int32_t ChangeAppGcState(int32_t state);
|
||||
|
||||
void HandleCacheProcess();
|
||||
|
||||
class MainHandler : public EventHandler {
|
||||
public:
|
||||
MainHandler(const std::shared_ptr<EventRunner> &runner, const sptr<MainThread> &thread);
|
||||
|
||||
@@ -176,6 +176,14 @@ public:
|
||||
* @param config Indicates the new Configuration object.
|
||||
*/
|
||||
virtual void OnConfigurationUpdated(Configuration config);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Will be Called when the application font of the device changes.
|
||||
*
|
||||
* @param config Indicates the new Configuration object.
|
||||
*/
|
||||
virtual void OnFontUpdated(Configuration config);
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
@@ -23,6 +23,7 @@ config("public_js_environment_config") {
|
||||
include_dirs = [
|
||||
"${inner_api_path}",
|
||||
"${utils_path}/include",
|
||||
"${ability_runtime_services_path}/common/include",
|
||||
]
|
||||
}
|
||||
|
||||
@@ -34,10 +35,7 @@ ohos_shared_library("js_environment") {
|
||||
"src/uncaught_exception_callback.cpp",
|
||||
]
|
||||
|
||||
configs = [
|
||||
":js_environment_config",
|
||||
"${ark_compile_path}/ets_runtime:ark_jsruntime_public_config",
|
||||
]
|
||||
configs = [ ":js_environment_config" ]
|
||||
|
||||
public_configs = [ ":public_js_environment_config" ]
|
||||
|
||||
@@ -47,6 +45,7 @@ ohos_shared_library("js_environment") {
|
||||
"eventhandler:libeventhandler",
|
||||
"faultloggerd:libunwinder",
|
||||
"ffrt:libffrt",
|
||||
"hilog:libhilog",
|
||||
"napi:ace_napi",
|
||||
]
|
||||
|
||||
|
||||
@@ -16,7 +16,8 @@
|
||||
#include "js_environment.h"
|
||||
|
||||
#include "ffrt.h"
|
||||
#include "js_env_logger.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "js_environment_impl.h"
|
||||
#include "native_engine/impl/ark/ark_native_engine.h"
|
||||
#include "uncaught_exception_callback.h"
|
||||
@@ -40,12 +41,12 @@ static panda::DFXJSNApi::ProfilerType ConvertProfilerType(JsEnvironment::PROFILE
|
||||
|
||||
JsEnvironment::JsEnvironment(std::unique_ptr<JsEnvironmentImpl> impl) : impl_(std::move(impl))
|
||||
{
|
||||
JSENV_LOG_D("called");
|
||||
TAG_LOGD(AAFwkTag::JSENV, "called");
|
||||
}
|
||||
|
||||
JsEnvironment::~JsEnvironment()
|
||||
{
|
||||
JSENV_LOG_D("called");
|
||||
TAG_LOGD(AAFwkTag::JSENV, "called");
|
||||
|
||||
if (engine_ != nullptr) {
|
||||
delete engine_;
|
||||
@@ -60,10 +61,10 @@ JsEnvironment::~JsEnvironment()
|
||||
|
||||
bool JsEnvironment::Initialize(const panda::RuntimeOption& pandaOption, void* jsEngine)
|
||||
{
|
||||
JSENV_LOG_D("Js environment initialize.");
|
||||
TAG_LOGD(AAFwkTag::JSENV, "Js environment initialize.");
|
||||
vm_ = panda::JSNApi::CreateJSVM(pandaOption);
|
||||
if (vm_ == nullptr) {
|
||||
JSENV_LOG_E("Create vm failed.");
|
||||
TAG_LOGE(AAFwkTag::JSENV, "Create vm failed.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -74,7 +75,7 @@ bool JsEnvironment::Initialize(const panda::RuntimeOption& pandaOption, void* js
|
||||
void JsEnvironment::InitTimerModule()
|
||||
{
|
||||
if (engine_ == nullptr) {
|
||||
JSENV_LOG_E("Invalid native engine.");
|
||||
TAG_LOGE(AAFwkTag::JSENV, "Invalid native engine.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -86,7 +87,7 @@ void JsEnvironment::InitTimerModule()
|
||||
void JsEnvironment::InitWorkerModule(std::shared_ptr<WorkerInfo> workerInfo)
|
||||
{
|
||||
if (engine_ == nullptr) {
|
||||
JSENV_LOG_E("Invalid native engine.");
|
||||
TAG_LOGE(AAFwkTag::JSENV, "Invalid native engine.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -127,7 +128,7 @@ void JsEnvironment::InitSourceMap(const std::shared_ptr<JsEnv::SourceMapOperator
|
||||
{
|
||||
sourceMapOperator_ = operatorObj;
|
||||
if (engine_ == nullptr) {
|
||||
JSENV_LOG_E("Invalid Native Engine.");
|
||||
TAG_LOGE(AAFwkTag::JSENV, "Invalid Native Engine.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -139,7 +140,7 @@ void JsEnvironment::InitSourceMap(const std::shared_ptr<JsEnv::SourceMapOperator
|
||||
if (sourceMapOperator_ != nullptr && sourceMapOperator_->GetInitStatus()) {
|
||||
return sourceMapOperator_->TranslateBySourceMap(rawStack);
|
||||
} else {
|
||||
JSENV_LOG_E("SourceMap is not initialized yet");
|
||||
TAG_LOGE(AAFwkTag::JSENV, "SourceMap is not initialized yet");
|
||||
return NOT_INIT + rawStack;
|
||||
}
|
||||
};
|
||||
@@ -149,7 +150,7 @@ void JsEnvironment::InitSourceMap(const std::shared_ptr<JsEnv::SourceMapOperator
|
||||
if (sourceMapOperator_ != nullptr && sourceMapOperator_->GetInitStatus()) {
|
||||
return sourceMapOperator_->TranslateUrlPositionBySourceMap(url, line, column);
|
||||
}
|
||||
JSENV_LOG_E("SourceMap is not initialized yet");
|
||||
TAG_LOGE(AAFwkTag::JSENV, "SourceMap is not initialized yet");
|
||||
return false;
|
||||
};
|
||||
engine_->RegisterSourceMapTranslateCallback(translateUrlBySourceMapFunc);
|
||||
@@ -158,7 +159,7 @@ void JsEnvironment::InitSourceMap(const std::shared_ptr<JsEnv::SourceMapOperator
|
||||
void JsEnvironment::RegisterUncaughtExceptionHandler(const JsEnv::UncaughtExceptionInfo& uncaughtExceptionInfo)
|
||||
{
|
||||
if (engine_ == nullptr) {
|
||||
JSENV_LOG_E("Invalid Native Engine.");
|
||||
TAG_LOGE(AAFwkTag::JSENV, "Invalid Native Engine.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -169,7 +170,7 @@ void JsEnvironment::RegisterUncaughtExceptionHandler(const JsEnv::UncaughtExcept
|
||||
bool JsEnvironment::LoadScript(const std::string& path, std::vector<uint8_t>* buffer, bool isBundle)
|
||||
{
|
||||
if (engine_ == nullptr) {
|
||||
JSENV_LOG_E("Invalid Native Engine.");
|
||||
TAG_LOGE(AAFwkTag::JSENV, "Invalid Native Engine.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -183,21 +184,21 @@ bool JsEnvironment::LoadScript(const std::string& path, std::vector<uint8_t>* bu
|
||||
bool JsEnvironment::StartDebugger(
|
||||
std::string& option, uint32_t socketFd, bool isDebugApp, const DebuggerPostTask &debuggerPostTask)
|
||||
{
|
||||
JSENV_LOG_D("call.");
|
||||
TAG_LOGD(AAFwkTag::JSENV, "call.");
|
||||
if (vm_ == nullptr) {
|
||||
JSENV_LOG_E("Invalid vm.");
|
||||
TAG_LOGE(AAFwkTag::JSENV, "Invalid vm.");
|
||||
return false;
|
||||
}
|
||||
int32_t identifierId = ParseHdcRegisterOption(option);
|
||||
if (identifierId == -1) {
|
||||
JSENV_LOG_E("Abnormal parsing of tid results.");
|
||||
TAG_LOGE(AAFwkTag::JSENV, "Abnormal parsing of tid results.");
|
||||
return false;
|
||||
}
|
||||
if (isDebugApp) {
|
||||
debugMode_ = panda::JSNApi::StartDebuggerForSocketPair(identifierId, socketFd);
|
||||
} else {
|
||||
if (debuggerPostTask == nullptr) {
|
||||
JSENV_LOG_E("debuggerPostTask is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::JSENV, "debuggerPostTask is nullptr.");
|
||||
return false;
|
||||
}
|
||||
auto startDebuggerForSocketPairTask = [identifierId, socketFd, this]() {
|
||||
@@ -211,7 +212,7 @@ bool JsEnvironment::StartDebugger(
|
||||
void JsEnvironment::StopDebugger()
|
||||
{
|
||||
if (vm_ == nullptr) {
|
||||
JSENV_LOG_E("Invalid vm.");
|
||||
TAG_LOGE(AAFwkTag::JSENV, "Invalid vm.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -222,7 +223,7 @@ void JsEnvironment::StopDebugger(std::string& option)
|
||||
{
|
||||
int32_t identifierId = ParseHdcRegisterOption(option);
|
||||
if (identifierId == -1) {
|
||||
JSENV_LOG_E("Abnormal parsing of tid results.");
|
||||
TAG_LOGE(AAFwkTag::JSENV, "Abnormal parsing of tid results.");
|
||||
return;
|
||||
}
|
||||
panda::JSNApi::StopDebugger(identifierId);
|
||||
@@ -231,7 +232,7 @@ void JsEnvironment::StopDebugger(std::string& option)
|
||||
void JsEnvironment::InitConsoleModule()
|
||||
{
|
||||
if (engine_ == nullptr) {
|
||||
JSENV_LOG_E("Invalid Native Engine.");
|
||||
TAG_LOGE(AAFwkTag::JSENV, "Invalid Native Engine.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -243,7 +244,7 @@ void JsEnvironment::InitConsoleModule()
|
||||
bool JsEnvironment::InitLoop(bool isStage)
|
||||
{
|
||||
if (engine_ == nullptr) {
|
||||
JSENV_LOG_E("Invalid Native Engine.");
|
||||
TAG_LOGE(AAFwkTag::JSENV, "Invalid Native Engine.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -256,7 +257,7 @@ bool JsEnvironment::InitLoop(bool isStage)
|
||||
void JsEnvironment::DeInitLoop()
|
||||
{
|
||||
if (engine_ == nullptr) {
|
||||
JSENV_LOG_E("Invalid Native Engine.");
|
||||
TAG_LOGE(AAFwkTag::JSENV, "Invalid Native Engine.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -268,7 +269,7 @@ void JsEnvironment::DeInitLoop()
|
||||
bool JsEnvironment::LoadScript(const std::string& path, uint8_t* buffer, size_t len, bool isBundle)
|
||||
{
|
||||
if (engine_ == nullptr) {
|
||||
JSENV_LOG_E("Invalid Native Engine.");
|
||||
TAG_LOGE(AAFwkTag::JSENV, "Invalid Native Engine.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -279,14 +280,14 @@ void JsEnvironment::StartProfiler(const char* libraryPath, uint32_t instanceId,
|
||||
int32_t interval, int tid, bool isDebugApp)
|
||||
{
|
||||
if (vm_ == nullptr) {
|
||||
JSENV_LOG_E("Invalid vm.");
|
||||
TAG_LOGE(AAFwkTag::JSENV, "Invalid vm.");
|
||||
return;
|
||||
}
|
||||
|
||||
auto debuggerPostTask = [weak = weak_from_this()](std::function<void()>&& task) {
|
||||
auto jsEnv = weak.lock();
|
||||
if (jsEnv == nullptr) {
|
||||
JSENV_LOG_E("JsEnv is invalid.");
|
||||
TAG_LOGE(AAFwkTag::JSENV, "JsEnv is invalid.");
|
||||
return;
|
||||
}
|
||||
jsEnv->PostTask(task, "JsEnvironment::StartProfiler");
|
||||
@@ -303,7 +304,7 @@ void JsEnvironment::StartProfiler(const char* libraryPath, uint32_t instanceId,
|
||||
void JsEnvironment::DestroyHeapProfiler()
|
||||
{
|
||||
if (vm_ == nullptr) {
|
||||
JSENV_LOG_E("Invalid vm.");
|
||||
TAG_LOGE(AAFwkTag::JSENV, "Invalid vm.");
|
||||
return;
|
||||
}
|
||||
panda::DFXJSNApi::DestroyHeapProfiler(vm_);
|
||||
@@ -312,7 +313,7 @@ void JsEnvironment::DestroyHeapProfiler()
|
||||
void JsEnvironment::GetHeapPrepare()
|
||||
{
|
||||
if (vm_ == nullptr) {
|
||||
JSENV_LOG_E("Invalid vm.");
|
||||
TAG_LOGE(AAFwkTag::JSENV, "Invalid vm.");
|
||||
return;
|
||||
}
|
||||
panda::DFXJSNApi::GetHeapPrepare(vm_);
|
||||
@@ -320,14 +321,14 @@ void JsEnvironment::GetHeapPrepare()
|
||||
|
||||
void JsEnvironment::ReInitJsEnvImpl(std::unique_ptr<JsEnvironmentImpl> impl)
|
||||
{
|
||||
JSENV_LOG_D("ReInit jsenv impl.");
|
||||
TAG_LOGD(AAFwkTag::JSENV, "ReInit jsenv impl.");
|
||||
impl_ = std::move(impl);
|
||||
}
|
||||
|
||||
void JsEnvironment::SetModuleLoadChecker(const std::shared_ptr<ModuleCheckerDelegate>& moduleCheckerDelegate)
|
||||
{
|
||||
if (engine_ == nullptr) {
|
||||
JSENV_LOG_E("Invalid native engine.");
|
||||
TAG_LOGE(AAFwkTag::JSENV, "Invalid native engine.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -337,7 +338,7 @@ void JsEnvironment::SetModuleLoadChecker(const std::shared_ptr<ModuleCheckerDele
|
||||
void JsEnvironment::SetRequestAotCallback(const RequestAotCallback& cb)
|
||||
{
|
||||
if (vm_ == nullptr) {
|
||||
JSENV_LOG_E("Invalid vm.");
|
||||
TAG_LOGE(AAFwkTag::JSENV, "Invalid vm.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -354,7 +355,7 @@ DebuggerPostTask JsEnvironment::GetDebuggerPostTask()
|
||||
auto debuggerPostTask = [weak = weak_from_this()](std::function<void()>&& task) {
|
||||
auto jsEnv = weak.lock();
|
||||
if (jsEnv == nullptr) {
|
||||
JSENV_LOG_E("JsEnv is invalid.");
|
||||
TAG_LOGE(AAFwkTag::JSENV, "JsEnv is invalid.");
|
||||
return;
|
||||
}
|
||||
jsEnv->PostTask(task, "JsEnvironment:GetDebuggerPostTask");
|
||||
@@ -366,14 +367,14 @@ void JsEnvironment::NotifyDebugMode(
|
||||
int tid, const char* libraryPath, uint32_t instanceId, bool debug, bool debugMode)
|
||||
{
|
||||
if (vm_ == nullptr) {
|
||||
JSENV_LOG_E("Invalid vm.");
|
||||
TAG_LOGE(AAFwkTag::JSENV, "Invalid vm.");
|
||||
return;
|
||||
}
|
||||
panda::JSNApi::DebugOption debugOption = {libraryPath, debug ? debugMode : false};
|
||||
auto debuggerPostTask = [weak = weak_from_this()](std::function<void()>&& task) {
|
||||
auto jsEnv = weak.lock();
|
||||
if (jsEnv == nullptr) {
|
||||
JSENV_LOG_E("JsEnv is invalid.");
|
||||
TAG_LOGE(AAFwkTag::JSENV, "JsEnv is invalid.");
|
||||
return;
|
||||
}
|
||||
jsEnv->PostTask(task, "JsEnvironment:NotifyDebugMode");
|
||||
@@ -383,7 +384,7 @@ void JsEnvironment::NotifyDebugMode(
|
||||
|
||||
int32_t JsEnvironment::ParseHdcRegisterOption(std::string& option)
|
||||
{
|
||||
JSENV_LOG_D("Start.");
|
||||
TAG_LOGD(AAFwkTag::JSENV, "Start.");
|
||||
std::size_t pos = option.find_first_of(":");
|
||||
if (pos == std::string::npos) {
|
||||
return -1;
|
||||
|
||||
@@ -23,17 +23,12 @@
|
||||
#include <sstream>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "js_env_logger.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace JsEnv {
|
||||
namespace {
|
||||
constexpr char SOURCES[] = "sources";
|
||||
constexpr char NAMES[] = "names";
|
||||
constexpr char MAPPINGS[] = "mappings";
|
||||
constexpr char FILE[] = "file";
|
||||
constexpr char SOURCE_CONTENT[] = "sourceContent";
|
||||
constexpr char SOURCE_ROOT[] = "sourceRoot";
|
||||
constexpr char DELIMITER_COMMA = ',';
|
||||
constexpr char DELIMITER_SEMICOLON = ';';
|
||||
constexpr char DOUBLE_SLASH = '\\';
|
||||
@@ -48,6 +43,13 @@ constexpr int32_t NUM_TWENTY = 20;
|
||||
constexpr int32_t NUM_TWENTYSIX = 26;
|
||||
constexpr int32_t DIGIT_NUM = 64;
|
||||
const std::string MEGER_SOURCE_MAP_PATH = "ets/sourceMaps.map";
|
||||
const std::string FLAG_SOURCES = " \"sources\":";
|
||||
const std::string FLAG_MAPPINGS = " \"mappings\": \"";
|
||||
const std::string FLAG_END = " }";
|
||||
static constexpr size_t FLAG_MAPPINGS_LEN = 17;
|
||||
static constexpr size_t REAL_SOURCE_SIZE = 7;
|
||||
static constexpr size_t REAL_URL_INDEX = 3;
|
||||
static constexpr size_t REAL_SOURCE_INDEX = 7;
|
||||
} // namespace
|
||||
ReadSourceMapCallback SourceMap::readSourceMapFunc_ = nullptr;
|
||||
GetHapPathCallback SourceMap::getHapPathFunc_ = nullptr;
|
||||
@@ -86,6 +88,12 @@ uint32_t Base64CharToInt(char charCode)
|
||||
return DIGIT_NUM;
|
||||
};
|
||||
|
||||
bool StringStartWith(const std::string& str, const std::string& startStr)
|
||||
{
|
||||
size_t startStrLen = startStr.length();
|
||||
return ((str.length() >= startStrLen) && (str.compare(0, startStrLen, startStr) == 0));
|
||||
}
|
||||
|
||||
void SourceMap::Init(bool isModular, const std::string& hapPath)
|
||||
{
|
||||
isModular_ = isModular;
|
||||
@@ -146,7 +154,7 @@ std::string SourceMap::TranslateBySourceMap(const std::string& stackStr)
|
||||
std::string column;
|
||||
GetPosInfo(temp, closeBracePos, line, column);
|
||||
if (line.empty() || column.empty()) {
|
||||
JSENV_LOG_W("the stack without line info");
|
||||
TAG_LOGW(AAFwkTag::JSENV, "the stack without line info");
|
||||
break;
|
||||
}
|
||||
std::string sourceInfo;
|
||||
@@ -162,7 +170,7 @@ std::string SourceMap::TranslateBySourceMap(const std::string& stackStr)
|
||||
std::string url = key + ".js.map";
|
||||
std::string curSourceMap;
|
||||
if (!ReadSourceMapData(hapPath_, url, curSourceMap)) {
|
||||
JSENV_LOG_W("ReadSourceMapData fail");
|
||||
TAG_LOGW(AAFwkTag::JSENV, "ReadSourceMapData fail");
|
||||
continue;
|
||||
}
|
||||
ExtractSourceMapData(curSourceMap, nonModularMap_);
|
||||
@@ -191,23 +199,48 @@ void SourceMap::SplitSourceMap(const std::string& sourceMapData)
|
||||
return ExtractSourceMapData(sourceMapData, nonModularMap_);
|
||||
}
|
||||
|
||||
size_t leftBracket = 0;
|
||||
size_t rightBracket = 0;
|
||||
size_t urlLeft = 0;
|
||||
size_t urlRight = 0;
|
||||
while ((leftBracket = sourceMapData.find(": {", rightBracket)) != std::string::npos) {
|
||||
urlLeft = leftBracket;
|
||||
urlRight = sourceMapData.find(" \"", rightBracket) + INDEX_THREE;
|
||||
if (urlRight == std::string::npos) {
|
||||
std::stringstream ss(sourceMapData);
|
||||
std::string tmp;
|
||||
std::string url;
|
||||
|
||||
std::getline(ss, tmp);
|
||||
bool isUrl = true;
|
||||
while (std::getline(ss, tmp)) {
|
||||
if (isUrl && tmp.size() > REAL_SOURCE_SIZE) {
|
||||
url = tmp.substr(REAL_URL_INDEX, tmp.size() - REAL_SOURCE_SIZE);
|
||||
isUrl = false;
|
||||
continue;
|
||||
}
|
||||
std::string key = sourceMapData.substr(urlRight, urlLeft - urlRight - INDEX_ONE);
|
||||
rightBracket = sourceMapData.find("},", leftBracket);
|
||||
std::string value = sourceMapData.substr(leftBracket, rightBracket);
|
||||
std::shared_ptr<SourceMapData> modularMap = std::make_shared<SourceMapData>();
|
||||
ExtractSourceMapData(value, modularMap);
|
||||
sourceMaps_[key] = modularMap;
|
||||
if (StringStartWith(tmp.c_str(), FLAG_SOURCES)) {
|
||||
std::getline(ss, tmp);
|
||||
sources_.emplace(url, tmp);
|
||||
continue;
|
||||
}
|
||||
if (StringStartWith(tmp.c_str(), FLAG_MAPPINGS)) {
|
||||
mappings_.emplace(url, tmp);
|
||||
continue;
|
||||
}
|
||||
if (StringStartWith(tmp.c_str(), FLAG_END)) {
|
||||
isUrl = true;
|
||||
}
|
||||
}
|
||||
std::shared_ptr<SourceMapData> modularMap = std::make_shared<SourceMapData>();
|
||||
for (auto it = sources_.begin(); it != sources_.end(); ++it) {
|
||||
std::string mappings = mappings_[it->first];
|
||||
if (mappings.size() < FLAG_MAPPINGS_LEN + 1) {
|
||||
TAG_LOGE(AAFwkTag::JSENV, "Translate failed, url: %{public}s", it->first.c_str());
|
||||
continue;
|
||||
}
|
||||
ExtractSourceMapData(mappings.substr(FLAG_MAPPINGS_LEN, mappings.size() - FLAG_MAPPINGS_LEN - 1), modularMap);
|
||||
if (modularMap == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::JSENV, "Extract mappings failed, url: %{public}s", it->first.c_str());
|
||||
continue;
|
||||
}
|
||||
modularMap->sources_.push_back(it->second);
|
||||
sourceMaps_[it->first] = modularMap;
|
||||
}
|
||||
mappings_.clear();
|
||||
sources_.clear();
|
||||
}
|
||||
|
||||
void SourceMap::ExtractStackInfo(const std::string& stackStr, std::vector<std::string>& res)
|
||||
@@ -219,37 +252,9 @@ void SourceMap::ExtractStackInfo(const std::string& stackStr, std::vector<std::s
|
||||
}
|
||||
}
|
||||
|
||||
void SourceMap::ExtractSourceMapData(const std::string& sourceMapData, std::shared_ptr<SourceMapData>& curMapData)
|
||||
void SourceMap::ExtractSourceMapData(const std::string& allmappings, std::shared_ptr<SourceMapData>& curMapData)
|
||||
{
|
||||
std::vector<std::string> sourceKey;
|
||||
ExtractKeyInfo(sourceMapData, sourceKey);
|
||||
|
||||
std::string mark = "";
|
||||
for (auto sourceKeyInfo : sourceKey) {
|
||||
if (sourceKeyInfo == SOURCES || sourceKeyInfo == NAMES ||
|
||||
sourceKeyInfo == MAPPINGS || sourceKeyInfo == FILE ||
|
||||
sourceKeyInfo == SOURCE_CONTENT || sourceKeyInfo == SOURCE_ROOT) {
|
||||
mark = sourceKeyInfo;
|
||||
} else if (mark == SOURCES) {
|
||||
curMapData->sources_.push_back(sourceKeyInfo);
|
||||
} else if (mark == NAMES) {
|
||||
curMapData->names_.push_back(sourceKeyInfo);
|
||||
} else if (mark == MAPPINGS) {
|
||||
curMapData->mappings_.push_back(sourceKeyInfo);
|
||||
} else if (mark == FILE) {
|
||||
curMapData->files_.push_back(sourceKeyInfo);
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (curMapData->mappings_.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// transform to vector for mapping easily
|
||||
curMapData->mappings_ = HandleMappings(curMapData->mappings_[0]);
|
||||
|
||||
curMapData->mappings_ = HandleMappings(allmappings);
|
||||
// the first bit: the column after transferring.
|
||||
// the second bit: the source file.
|
||||
// the third bit: the row before transferring.
|
||||
@@ -265,11 +270,11 @@ void SourceMap::ExtractSourceMapData(const std::string& sourceMapData, std::shar
|
||||
std::vector<int32_t> ans;
|
||||
|
||||
if (!VlqRevCode(mapping, ans)) {
|
||||
JSENV_LOG_E("decode code fail");
|
||||
TAG_LOGE(AAFwkTag::JSENV, "decode code fail");
|
||||
return;
|
||||
}
|
||||
if (ans.empty()) {
|
||||
JSENV_LOG_E("decode sourcemap fail, mapping: %{public}s", mapping.c_str());
|
||||
TAG_LOGE(AAFwkTag::JSENV, "decode sourcemap fail, mapping: %{public}s", mapping.c_str());
|
||||
break;
|
||||
}
|
||||
if (ans.size() == 1) {
|
||||
@@ -295,8 +300,6 @@ void SourceMap::ExtractSourceMapData(const std::string& sourceMapData, std::shar
|
||||
}
|
||||
curMapData->mappings_.clear();
|
||||
curMapData->mappings_.shrink_to_fit();
|
||||
sourceKey.clear();
|
||||
sourceKey.shrink_to_fit();
|
||||
}
|
||||
|
||||
MappingInfo SourceMap::Find(int32_t row, int32_t col, const SourceMapData& targetMap)
|
||||
@@ -310,8 +313,10 @@ MappingInfo SourceMap::Find(int32_t row, int32_t col, const SourceMapData& targe
|
||||
int32_t left = 0;
|
||||
int32_t right = static_cast<int32_t>(targetMap.afterPos_.size()) - 1;
|
||||
int32_t res = 0;
|
||||
std::string sources = targetMap.sources_[0].substr(REAL_SOURCE_INDEX,
|
||||
targetMap.sources_[0].size() - REAL_SOURCE_SIZE - 1);
|
||||
if (row > targetMap.afterPos_[targetMap.afterPos_.size() - 1].afterRow) {
|
||||
return MappingInfo { row + 1, col + 1, targetMap.sources_[0] };
|
||||
return MappingInfo { row + 1, col + 1, sources };
|
||||
}
|
||||
while (right - left >= 0) {
|
||||
int32_t mid = (right + left) / 2;
|
||||
@@ -323,7 +328,6 @@ MappingInfo SourceMap::Find(int32_t row, int32_t col, const SourceMapData& targe
|
||||
left = mid + 1;
|
||||
}
|
||||
}
|
||||
std::string sources = targetMap.sources_[0];
|
||||
auto pos = sources.find(WEBPACK);
|
||||
if (pos != std::string::npos) {
|
||||
sources.replace(pos, sizeof(WEBPACK) - 1, "");
|
||||
@@ -525,7 +529,7 @@ bool SourceMap::TranslateUrlPositionBySourceMap(std::string& url, int& line, int
|
||||
if (iter != sourceMaps_.end()) {
|
||||
return GetLineAndColumnNumbers(line, column, *(iter->second), url);
|
||||
}
|
||||
JSENV_LOG_E("TranslateUrlPositionBySourceMap: stageMode sourceMaps find fail");
|
||||
TAG_LOGE(AAFwkTag::JSENV, "TranslateUrlPositionBySourceMap: stageMode sourceMaps find fail");
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -17,7 +17,8 @@
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
||||
#include "js_env_logger.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "native_engine/native_engine.h"
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
#include "ui_content.h"
|
||||
@@ -32,7 +33,7 @@ constexpr char BACKTRACE[] = "=====================Backtrace====================
|
||||
std::string NapiUncaughtExceptionCallback::GetNativeStrFromJsTaggedObj(napi_value obj, const char* key)
|
||||
{
|
||||
if (obj == nullptr) {
|
||||
JSENV_LOG_E("Failed to get value from key.");
|
||||
TAG_LOGE(AAFwkTag::JSENV, "Failed to get value from key.");
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -41,7 +42,7 @@ std::string NapiUncaughtExceptionCallback::GetNativeStrFromJsTaggedObj(napi_valu
|
||||
napi_valuetype valueType = napi_undefined;
|
||||
napi_typeof(env_, valueStr, &valueType);
|
||||
if (valueType != napi_string) {
|
||||
JSENV_LOG_E("Failed to convert value from key.");
|
||||
TAG_LOGE(AAFwkTag::JSENV, "Failed to convert value from key.");
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -51,7 +52,7 @@ std::string NapiUncaughtExceptionCallback::GetNativeStrFromJsTaggedObj(napi_valu
|
||||
size_t valueStrLength = 0;
|
||||
napi_get_value_string_utf8(env_, valueStr, valueCStr.get(), valueStrBufLength + 1, &valueStrLength);
|
||||
std::string ret(valueCStr.get(), valueStrLength);
|
||||
JSENV_LOG_D("GetNativeStrFromJsTaggedObj Success.");
|
||||
TAG_LOGD(AAFwkTag::JSENV, "GetNativeStrFromJsTaggedObj Success.");
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -75,7 +76,7 @@ void NapiUncaughtExceptionCallback::operator()(napi_value obj)
|
||||
summary += "Error code:" + errorCode + "\n";
|
||||
}
|
||||
if (errorStack.empty()) {
|
||||
JSENV_LOG_E("errorStack is empty");
|
||||
TAG_LOGE(AAFwkTag::JSENV, "errorStack is empty");
|
||||
return;
|
||||
}
|
||||
auto errorPos = SourceMap::GetErrorPos(topStack);
|
||||
|
||||
@@ -85,7 +85,7 @@ public:
|
||||
void SplitSourceMap(const std::string& sourceMapData);
|
||||
|
||||
private:
|
||||
void ExtractSourceMapData(const std::string& sourceMapData, std::shared_ptr<SourceMapData>& curMapData);
|
||||
void ExtractSourceMapData(const std::string& allmappings, std::shared_ptr<SourceMapData>& curMapData);
|
||||
void ExtractKeyInfo(const std::string& sourceMap, std::vector<std::string>& sourceKeyInfo);
|
||||
std::vector<std::string> HandleMappings(const std::string& mapping);
|
||||
bool VlqRevCode(const std::string& vStr, std::vector<int32_t>& ans);
|
||||
@@ -102,6 +102,8 @@ private:
|
||||
static ReadSourceMapCallback readSourceMapFunc_;
|
||||
static std::mutex sourceMapMutex_;
|
||||
static GetHapPathCallback getHapPathFunc_;
|
||||
std::unordered_map<std::string, std::string> sources_;
|
||||
std::unordered_map<std::string, std::string> mappings_;
|
||||
};
|
||||
} // namespace JsEnv
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
#include <string>
|
||||
|
||||
#include "ffrt.h"
|
||||
#include "js_env_logger.h"
|
||||
#include "source_map.h"
|
||||
|
||||
namespace OHOS {
|
||||
@@ -59,7 +58,6 @@ public:
|
||||
std::string TranslateBySourceMap(const std::string& stackStr)
|
||||
{
|
||||
if (sourceMapObj_ == nullptr) {
|
||||
JSENV_LOG_E("sourceMapObj_ is nullptr");
|
||||
return "";
|
||||
}
|
||||
if (isDebugVersion_) {
|
||||
@@ -72,7 +70,6 @@ public:
|
||||
bool TranslateUrlPositionBySourceMap(std::string& url, int& line, int& column)
|
||||
{
|
||||
if (sourceMapObj_ == nullptr) {
|
||||
JSENV_LOG_E("sourceMapObj_ is nullptr");
|
||||
return false;
|
||||
}
|
||||
return sourceMapObj_->TranslateUrlPositionBySourceMap(url, line, column);
|
||||
|
||||
@@ -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,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
|
||||
@@ -22,7 +22,6 @@
|
||||
|
||||
#include "ecmascript/napi/include/jsnapi.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "js_env_logger.h"
|
||||
#include "ohos_js_env_logger.h"
|
||||
#include "ohos_js_environment_impl.h"
|
||||
|
||||
@@ -97,9 +96,6 @@ HWTEST_F(JsEnvironmentTest, JsEnvInitialize_0100, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(JsEnvironmentTest, JsEnvInitialize_0200, TestSize.Level0)
|
||||
{
|
||||
JSENV_LOG_I("Running in multi-thread, using default thread number.");
|
||||
|
||||
JSENV_LOG_I("Running in thread %{public}" PRIu64 "", gettid());
|
||||
auto jsEnv = std::make_shared<JsEnvironment>(std::make_unique<AbilityRuntime::OHOSJsEnvironmentImpl>());
|
||||
ASSERT_NE(jsEnv, nullptr);
|
||||
|
||||
@@ -384,7 +380,6 @@ HWTEST_F(JsEnvironmentTest, PostSyncTask_0100, TestSize.Level0)
|
||||
std::string taskName = "syncTask001";
|
||||
bool taskExecuted = false;
|
||||
auto task = [taskName, &taskExecuted]() {
|
||||
JSENV_LOG_I("%{public}s called.", taskName.c_str());
|
||||
taskExecuted = true;
|
||||
};
|
||||
jsEnv->PostSyncTask(task, taskName);
|
||||
@@ -403,7 +398,6 @@ HWTEST_F(JsEnvironmentTest, SetRequestAotCallback_0100, TestSize.Level0)
|
||||
ASSERT_NE(jsEnv, nullptr);
|
||||
|
||||
auto callback = [](const std::string& bundleName, const std::string& moduleName, int32_t triggerMode) -> int32_t {
|
||||
JSENV_LOG_I("set request aot callback.");
|
||||
return 0;
|
||||
};
|
||||
jsEnv->SetRequestAotCallback(callback);
|
||||
@@ -538,5 +532,17 @@ HWTEST_F(JsEnvironmentTest, GetHeapPrepare_0200, TestSize.Level0)
|
||||
jsEnv->GetHeapPrepare();
|
||||
ASSERT_NE(jsEnv, nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: GetSourceMapOperator_0100
|
||||
* @tc.desc: Js environment GetSourceMapOperator.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(JsEnvironmentTest, GetSourceMapOperator_0100, TestSize.Level0)
|
||||
{
|
||||
auto jsEnv = std::make_shared<JsEnvironment>(std::make_unique<AbilityRuntime::OHOSJsEnvironmentImpl>());
|
||||
jsEnv->GetSourceMapOperator();
|
||||
ASSERT_NE(jsEnv, nullptr);
|
||||
}
|
||||
} // 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) {
|
||||
|
||||
@@ -62,8 +62,6 @@ config("abilityms_config") {
|
||||
}
|
||||
|
||||
if (ability_runtime_graphics) {
|
||||
include_dirs += []
|
||||
|
||||
defines += [
|
||||
"SUPPORT_GRAPHICS",
|
||||
"SUPPORT_SCREEN",
|
||||
|
||||
@@ -37,13 +37,14 @@ public:
|
||||
|
||||
int32_t DeleteAutoStartupData(const AutoStartupInfo &info);
|
||||
|
||||
int32_t DeleteAutoStartupData(const std::string &bundleName);
|
||||
int32_t DeleteAutoStartupData(const std::string &bundleName, int32_t uid);
|
||||
|
||||
AutoStartupStatus QueryAutoStartupData(const AutoStartupInfo &info);
|
||||
|
||||
int32_t QueryAllAutoStartupApplications(std::vector<AutoStartupInfo> &infoList);
|
||||
|
||||
int32_t GetCurrentAppAutoStartupData(const std::string &bundleName, std::vector<AutoStartupInfo> &infoList);
|
||||
int32_t GetCurrentAppAutoStartupData(const std::string &bundleName,
|
||||
std::vector<AutoStartupInfo> &infoList, const std::string &accessTokenId);
|
||||
|
||||
private:
|
||||
DistributedKv::Status GetKvStore();
|
||||
@@ -55,7 +56,7 @@ private:
|
||||
AutoStartupInfo ConvertAutoStartupInfoFromKeyAndValue(
|
||||
const DistributedKv::Key &key, const DistributedKv::Value &value);
|
||||
bool IsEqual(const DistributedKv::Key &key, const AutoStartupInfo &info);
|
||||
bool IsEqual(const DistributedKv::Key &key, const std::string &bundleName);
|
||||
bool IsEqual(const DistributedKv::Key &key, const std::string &accessTokenId);
|
||||
|
||||
static const DistributedKv::AppId APP_ID;
|
||||
static const DistributedKv::StoreId STORE_ID;
|
||||
|
||||
@@ -78,9 +78,10 @@ public:
|
||||
/**
|
||||
* @brief Delete current bundleName auto start up data.
|
||||
* @param bundleName The current bundleName.
|
||||
* @param uid The uid.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
int32_t DeleteAutoStartupData(const std::string &bundleName);
|
||||
int32_t DeleteAutoStartupData(const std::string &bundleName, int32_t uid);
|
||||
|
||||
/**
|
||||
* @brief Check current bundleName auto start up data.
|
||||
@@ -137,7 +138,8 @@ private:
|
||||
std::string GetSelfApplicationBundleName();
|
||||
bool CheckSelfApplication(const std::string &bundleName);
|
||||
bool GetBundleInfo(const std::string &bundleName, AppExecFwk::BundleInfo &bundleInfo, int32_t uid = -1);
|
||||
bool GetAbilityData(const AutoStartupInfo &info, bool &isVisible, std::string &abilityTypeName);
|
||||
bool GetAbilityData(const AutoStartupInfo &info, bool &isVisible,
|
||||
std::string &abilityTypeName, std::string &accessTokenId);
|
||||
std::string GetAbilityTypeName(AppExecFwk::AbilityInfo abilityInfo);
|
||||
std::string GetExtensionTypeName(AppExecFwk::ExtensionAbilityInfo extensionInfo);
|
||||
std::shared_ptr<AppExecFwk::BundleMgrClient> GetBundleMgrClient();
|
||||
@@ -145,7 +147,7 @@ private:
|
||||
int32_t CheckPermissionForSelf(const std::string &bundleName);
|
||||
int32_t CheckPermissionForEDM();
|
||||
int32_t InnerApplicationAutoStartupByEDM(const AutoStartupInfo &info, bool isSet, bool flag);
|
||||
int32_t GetAbilityInfo(const AutoStartupInfo &info, std::string &abilityTypeName);
|
||||
int32_t GetAbilityInfo(const AutoStartupInfo &info, std::string &abilityTypeName, std::string &accessTokenId);
|
||||
|
||||
mutable std::mutex autoStartUpMutex_;
|
||||
mutable std::mutex deathRecipientsMutex_;
|
||||
|
||||
@@ -553,6 +553,7 @@ private:
|
||||
std::shared_ptr<AbilityRecord> GetExtensionByIdFromServiceMap(int32_t abilityRecordId);
|
||||
int TerminateAbilityInner(const sptr<IRemoteObject> &token);
|
||||
bool IsLauncher(std::shared_ptr<AbilityRecord> serviceExtension) const;
|
||||
bool IsSampleManagement(std::shared_ptr<AbilityRecord> serviceExtension) const;
|
||||
void KillProcessesByUserId() const;
|
||||
void SetLastExitReason(const AbilityRequest &abilityRequest, std::shared_ptr<AbilityRecord> &targetService);
|
||||
inline bool IsUIExtensionAbility(const std::shared_ptr<AbilityRecord> &abilityRecord);
|
||||
|
||||
@@ -1041,6 +1041,8 @@ private:
|
||||
|
||||
bool GetUriListFromWant(Want &want, std::vector<std::string> &uriVec);
|
||||
|
||||
void PublishFileOpenEvent(const Want &want);
|
||||
|
||||
#ifdef SUPPORT_SCREEN
|
||||
std::shared_ptr<Want> GetWantFromMission() const;
|
||||
void SetShowWhenLocked(const AppExecFwk::AbilityInfo &abilityInfo, sptr<AbilityTransitionInfo> &info) const;
|
||||
|
||||
@@ -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_;
|
||||
|
||||
@@ -399,6 +399,7 @@ private:
|
||||
std::shared_ptr<StatusBarDelegateManager> GetStatusBarDelegateManager();
|
||||
int32_t DoProcessAttachment(std::shared_ptr<AbilityRecord> abilityRecord);
|
||||
void BatchCloseUIAbility(const std::unordered_set<std::shared_ptr<AbilityRecord>>& abilitySet);
|
||||
void TerminateSession(std::shared_ptr<AbilityRecord> abilityRecord);
|
||||
int StartWithPersistentIdByDistributed(const AbilityRequest &abilityRequest, int32_t persistentId);
|
||||
|
||||
int32_t userId_ = -1;
|
||||
|
||||
@@ -26,8 +26,6 @@
|
||||
namespace OHOS {
|
||||
namespace AAFwk {
|
||||
struct StartAbilityInfo {
|
||||
static void InitAbilityInfoFromExtension(AppExecFwk::ExtensionAbilityInfo &extensionInfo,
|
||||
AppExecFwk::AbilityInfo &abilityInfo);
|
||||
static std::shared_ptr<StartAbilityInfo> CreateStartAbilityInfo(const Want &want, int32_t userId,
|
||||
int32_t appIndex);
|
||||
static std::shared_ptr<StartAbilityInfo> CreateCallerAbilityInfo(const sptr<IRemoteObject> &callerToken);
|
||||
|
||||
@@ -68,6 +68,7 @@
|
||||
*TaskDataPersistenceMgr*;
|
||||
*Token*;
|
||||
*UserController*;
|
||||
*UnlockScreenManager*;
|
||||
*WantSenderInfo*;
|
||||
*SenderInfo*;
|
||||
*AbilityManagerProxy*;
|
||||
|
||||
@@ -23,6 +23,10 @@
|
||||
{
|
||||
"type": "filePicker",
|
||||
"typePicker": "sysPicker/filePicker"
|
||||
},
|
||||
{
|
||||
"type": "audioPicker",
|
||||
"typePicker": "sysPicker/audioPicker"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -18,11 +18,13 @@
|
||||
#include <algorithm>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "accesstoken_kit.h"
|
||||
#include "errors.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "nlohmann/json.hpp"
|
||||
#include "types.h"
|
||||
#include "os_account_manager_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
@@ -37,6 +39,7 @@ const std::string JSON_KEY_IS_AUTO_STARTUP = "isAutoStartup";
|
||||
const std::string JSON_KEY_IS_EDM_FORCE = "isEdmForce";
|
||||
const std::string JSON_KEY_TYPE_NAME = "abilityTypeName";
|
||||
const std::string JSON_KEY_APP_CLONE_INDEX = "appCloneIndex";
|
||||
const std::string JSON_KEY_ACCESS_TOKENID = "accessTokenId";
|
||||
} // namespace
|
||||
const DistributedKv::AppId AbilityAutoStartupDataManager::APP_ID = { "auto_startup_storage" };
|
||||
const DistributedKv::StoreId AbilityAutoStartupDataManager::STORE_ID = { "auto_startup_infos" };
|
||||
@@ -91,13 +94,14 @@ bool AbilityAutoStartupDataManager::CheckKvStore()
|
||||
int32_t AbilityAutoStartupDataManager::InsertAutoStartupData(
|
||||
const AutoStartupInfo &info, bool isAutoStartup, bool isEdmForce)
|
||||
{
|
||||
if (info.bundleName.empty() || info.abilityName.empty()) {
|
||||
if (info.bundleName.empty() || info.abilityName.empty() || info.accessTokenId.empty()) {
|
||||
TAG_LOGE(AAFwkTag::AUTO_STARTUP, "Invalid value.");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
TAG_LOGD(AAFwkTag::AUTO_STARTUP, "bundleName: %{public}s, moduleName: %{public}s, abilityName: %{public}s.",
|
||||
info.bundleName.c_str(), info.moduleName.c_str(), info.abilityName.c_str());
|
||||
TAG_LOGD(AAFwkTag::AUTO_STARTUP,
|
||||
"bundleName: %{public}s, moduleName: %{public}s, abilityName: %{public}s, accessTokenId: %{public}s.",
|
||||
info.bundleName.c_str(), info.moduleName.c_str(), info.abilityName.c_str(), info.accessTokenId.c_str());
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(kvStorePtrMutex_);
|
||||
if (!CheckKvStore()) {
|
||||
@@ -124,13 +128,14 @@ int32_t AbilityAutoStartupDataManager::InsertAutoStartupData(
|
||||
int32_t AbilityAutoStartupDataManager::UpdateAutoStartupData(
|
||||
const AutoStartupInfo &info, bool isAutoStartup, bool isEdmForce)
|
||||
{
|
||||
if (info.bundleName.empty() || info.abilityName.empty()) {
|
||||
if (info.bundleName.empty() || info.abilityName.empty() || info.accessTokenId.empty()) {
|
||||
TAG_LOGW(AAFwkTag::AUTO_STARTUP, "Invalid value!");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
TAG_LOGD(AAFwkTag::AUTO_STARTUP, "bundleName: %{public}s, moduleName: %{public}s, abilityName: %{public}s.",
|
||||
info.bundleName.c_str(), info.moduleName.c_str(), info.abilityName.c_str());
|
||||
TAG_LOGD(AAFwkTag::AUTO_STARTUP,
|
||||
"bundleName: %{public}s, moduleName: %{public}s, abilityName: %{public}s, accessTokenId: %{public}s.",
|
||||
info.bundleName.c_str(), info.moduleName.c_str(), info.abilityName.c_str(), info.accessTokenId.c_str());
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(kvStorePtrMutex_);
|
||||
if (!CheckKvStore()) {
|
||||
@@ -164,13 +169,14 @@ int32_t AbilityAutoStartupDataManager::UpdateAutoStartupData(
|
||||
|
||||
int32_t AbilityAutoStartupDataManager::DeleteAutoStartupData(const AutoStartupInfo &info)
|
||||
{
|
||||
if (info.bundleName.empty() || info.abilityName.empty()) {
|
||||
if (info.bundleName.empty() || info.abilityName.empty() || info.accessTokenId.empty()) {
|
||||
TAG_LOGW(AAFwkTag::AUTO_STARTUP, "Invalid value!");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
TAG_LOGD(AAFwkTag::AUTO_STARTUP, "bundleName: %{public}s, moduleName: %{public}s, abilityName: %{public}s.",
|
||||
info.bundleName.c_str(), info.moduleName.c_str(), info.abilityName.c_str());
|
||||
TAG_LOGD(AAFwkTag::AUTO_STARTUP,
|
||||
"bundleName: %{public}s, moduleName: %{public}s, abilityName: %{public}s, accessTokenId: %{public}s.",
|
||||
info.bundleName.c_str(), info.moduleName.c_str(), info.abilityName.c_str(), info.accessTokenId.c_str());
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(kvStorePtrMutex_);
|
||||
if (!CheckKvStore()) {
|
||||
@@ -193,14 +199,23 @@ int32_t AbilityAutoStartupDataManager::DeleteAutoStartupData(const AutoStartupIn
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
int32_t AbilityAutoStartupDataManager::DeleteAutoStartupData(const std::string &bundleName)
|
||||
int32_t AbilityAutoStartupDataManager::DeleteAutoStartupData(const std::string &bundleName, int32_t uid)
|
||||
{
|
||||
if (bundleName.empty()) {
|
||||
int32_t userId;
|
||||
if (DelayedSingleton<AppExecFwk::OsAccountManagerWrapper>::GetInstance()->
|
||||
GetOsAccountLocalIdFromUid(uid, userId) != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Get GetOsAccountLocalIdFromUid failed.");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
uint32_t accessTokenId = Security::AccessToken::AccessTokenKit::GetHapTokenID(userId, bundleName, 0);
|
||||
auto accessTokenIdStr = std::to_string(accessTokenId);
|
||||
if (bundleName.empty() || accessTokenIdStr.empty()) {
|
||||
TAG_LOGW(AAFwkTag::AUTO_STARTUP, "Invalid value!");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
TAG_LOGD(AAFwkTag::AUTO_STARTUP, "bundleName: %{public}s.", bundleName.c_str());
|
||||
TAG_LOGD(AAFwkTag::AUTO_STARTUP, "bundleName: %{public}s, accessTokenId: %{public}s.",
|
||||
bundleName.c_str(), accessTokenIdStr.c_str());
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(kvStorePtrMutex_);
|
||||
if (!CheckKvStore()) {
|
||||
@@ -217,7 +232,7 @@ int32_t AbilityAutoStartupDataManager::DeleteAutoStartupData(const std::string &
|
||||
}
|
||||
|
||||
for (const auto &item : allEntries) {
|
||||
if (IsEqual(item.key, bundleName)) {
|
||||
if (IsEqual(item.key, accessTokenIdStr)) {
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(kvStorePtrMutex_);
|
||||
status = kvStorePtr_->Delete(item.key);
|
||||
@@ -235,14 +250,15 @@ int32_t AbilityAutoStartupDataManager::DeleteAutoStartupData(const std::string &
|
||||
AutoStartupStatus AbilityAutoStartupDataManager::QueryAutoStartupData(const AutoStartupInfo &info)
|
||||
{
|
||||
AutoStartupStatus asustatus;
|
||||
if (info.bundleName.empty() || info.abilityName.empty()) {
|
||||
if (info.bundleName.empty() || info.abilityName.empty() || info.accessTokenId.empty()) {
|
||||
TAG_LOGW(AAFwkTag::AUTO_STARTUP, "Invalid value!");
|
||||
asustatus.code = ERR_INVALID_VALUE;
|
||||
return asustatus;
|
||||
}
|
||||
|
||||
TAG_LOGD(AAFwkTag::AUTO_STARTUP, "bundleName: %{public}s, moduleName: %{public}s, abilityName: %{public}s.",
|
||||
info.bundleName.c_str(), info.moduleName.c_str(), info.abilityName.c_str());
|
||||
TAG_LOGD(AAFwkTag::AUTO_STARTUP,
|
||||
"bundleName: %{public}s, moduleName: %{public}s, abilityName: %{public}s, accessTokenId: %{public}s.",
|
||||
info.bundleName.c_str(), info.moduleName.c_str(), info.abilityName.c_str(), info.accessTokenId.c_str());
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(kvStorePtrMutex_);
|
||||
if (!CheckKvStore()) {
|
||||
@@ -301,7 +317,7 @@ int32_t AbilityAutoStartupDataManager::QueryAllAutoStartupApplications(std::vect
|
||||
}
|
||||
|
||||
int32_t AbilityAutoStartupDataManager::GetCurrentAppAutoStartupData(
|
||||
const std::string &bundleName, std::vector<AutoStartupInfo> &infoList)
|
||||
const std::string &bundleName, std::vector<AutoStartupInfo> &infoList, const std::string &accessTokenId)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::AUTO_STARTUP, "Called.");
|
||||
{
|
||||
@@ -320,7 +336,7 @@ int32_t AbilityAutoStartupDataManager::GetCurrentAppAutoStartupData(
|
||||
}
|
||||
|
||||
for (const auto &item : allEntries) {
|
||||
if (IsEqual(item.key, bundleName)) {
|
||||
if (IsEqual(item.key, accessTokenId)) {
|
||||
infoList.emplace_back(ConvertAutoStartupInfoFromKeyAndValue(item.key, item.value));
|
||||
}
|
||||
}
|
||||
@@ -364,6 +380,7 @@ DistributedKv::Key AbilityAutoStartupDataManager::ConvertAutoStartupDataToKey(co
|
||||
{ JSON_KEY_MODULE_NAME, info.moduleName },
|
||||
{ JSON_KEY_ABILITY_NAME, info.abilityName },
|
||||
{ JSON_KEY_APP_CLONE_INDEX, info.appCloneIndex },
|
||||
{ JSON_KEY_ACCESS_TOKENID, info.accessTokenId },
|
||||
};
|
||||
DistributedKv::Key key(jsonObject.dump());
|
||||
TAG_LOGD(AAFwkTag::AUTO_STARTUP, "key: %{public}s.", key.ToString().c_str());
|
||||
@@ -392,8 +409,12 @@ AutoStartupInfo AbilityAutoStartupDataManager::ConvertAutoStartupInfoFromKeyAndV
|
||||
info.abilityName = jsonObject.at(JSON_KEY_ABILITY_NAME).get<std::string>();
|
||||
}
|
||||
|
||||
if (jsonObject.contains(JSON_KEY_APP_CLONE_INDEX) && jsonObject[JSON_KEY_APP_CLONE_INDEX].is_string()) {
|
||||
info.appCloneIndex = jsonObject.at(JSON_KEY_APP_CLONE_INDEX).get<std::int32_t>();
|
||||
if (jsonObject.contains(JSON_KEY_APP_CLONE_INDEX) && jsonObject[JSON_KEY_APP_CLONE_INDEX].is_number()) {
|
||||
info.appCloneIndex = jsonObject.at(JSON_KEY_APP_CLONE_INDEX).get<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);
|
||||
@@ -405,7 +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>();
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
@@ -435,10 +455,23 @@ bool AbilityAutoStartupDataManager::IsEqual(const DistributedKv::Key &key, const
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (jsonObject.contains(JSON_KEY_ACCESS_TOKENID) && jsonObject[JSON_KEY_ACCESS_TOKENID].is_string()) {
|
||||
if (info.accessTokenId != jsonObject.at(JSON_KEY_ACCESS_TOKENID).get<std::string>()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (jsonObject.contains(JSON_KEY_APP_CLONE_INDEX) && jsonObject[JSON_KEY_APP_CLONE_INDEX].is_number()) {
|
||||
if (info.appCloneIndex != jsonObject.at(JSON_KEY_APP_CLONE_INDEX).get<int32_t>()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AbilityAutoStartupDataManager::IsEqual(const DistributedKv::Key &key, const std::string &bundleName)
|
||||
bool AbilityAutoStartupDataManager::IsEqual(const DistributedKv::Key &key, const std::string &accessTokenId)
|
||||
{
|
||||
nlohmann::json jsonObject = nlohmann::json::parse(key.ToString(), nullptr, false);
|
||||
if (jsonObject.is_discarded()) {
|
||||
@@ -446,8 +479,8 @@ bool AbilityAutoStartupDataManager::IsEqual(const DistributedKv::Key &key, const
|
||||
return false;
|
||||
}
|
||||
|
||||
if (jsonObject.contains(JSON_KEY_BUNDLE_NAME) && jsonObject[JSON_KEY_BUNDLE_NAME].is_string()) {
|
||||
if (bundleName == jsonObject.at(JSON_KEY_BUNDLE_NAME).get<std::string>()) {
|
||||
if (jsonObject.contains(JSON_KEY_ACCESS_TOKENID) && jsonObject[JSON_KEY_ACCESS_TOKENID].is_string()) {
|
||||
if (accessTokenId == jsonObject.at(JSON_KEY_ACCESS_TOKENID).get<std::string>()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
|
||||
#include "ability_auto_startup_data_manager.h"
|
||||
#include "ability_manager_errors.h"
|
||||
@@ -102,8 +103,9 @@ int32_t AbilityAutoStartupService::UnregisterAutoStartupSystemCallback(const spt
|
||||
|
||||
int32_t AbilityAutoStartupService::SetApplicationAutoStartup(const AutoStartupInfo &info)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::AUTO_STARTUP, "Called, bundleName: %{public}s, moduleName: %{public}s, abilityName: %{public}s.",
|
||||
info.bundleName.c_str(), info.moduleName.c_str(), info.abilityName.c_str());
|
||||
TAG_LOGD(AAFwkTag::AUTO_STARTUP,
|
||||
"Called, bundleName: %{public}s, moduleName: %{public}s, abilityName: %{public}s, accessTokenId: %{public}s.",
|
||||
info.bundleName.c_str(), info.moduleName.c_str(), info.abilityName.c_str(), info.accessTokenId.c_str());
|
||||
int32_t code = CheckPermissionForSystem();
|
||||
if (code != ERR_OK) {
|
||||
return code;
|
||||
@@ -111,7 +113,8 @@ int32_t AbilityAutoStartupService::SetApplicationAutoStartup(const AutoStartupIn
|
||||
|
||||
bool isVisible;
|
||||
std::string abilityTypeName;
|
||||
if (!GetAbilityData(info, isVisible, abilityTypeName)) {
|
||||
std::string accessTokenId;
|
||||
if (!GetAbilityData(info, isVisible, abilityTypeName, accessTokenId)) {
|
||||
TAG_LOGE(AAFwkTag::AUTO_STARTUP, "Failed to get ability data.");
|
||||
return INNER_ERR;
|
||||
}
|
||||
@@ -123,6 +126,7 @@ int32_t AbilityAutoStartupService::SetApplicationAutoStartup(const AutoStartupIn
|
||||
|
||||
AutoStartupInfo fullInfo(info);
|
||||
fullInfo.abilityTypeName = abilityTypeName;
|
||||
fullInfo.accessTokenId = accessTokenId;
|
||||
|
||||
return InnerSetApplicationAutoStartup(fullInfo);
|
||||
}
|
||||
@@ -163,8 +167,9 @@ int32_t AbilityAutoStartupService::InnerSetApplicationAutoStartup(const AutoStar
|
||||
|
||||
int32_t AbilityAutoStartupService::CancelApplicationAutoStartup(const AutoStartupInfo &info)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::AUTO_STARTUP, "Called, bundleName: %{public}s, moduleName: %{public}s, abilityName: %{public}s.",
|
||||
info.bundleName.c_str(), info.moduleName.c_str(), info.abilityName.c_str());
|
||||
TAG_LOGD(AAFwkTag::AUTO_STARTUP,
|
||||
"Called, bundleName: %{public}s, moduleName: %{public}s, abilityName: %{public}s, accessTokenId: %{public}s.",
|
||||
info.bundleName.c_str(), info.moduleName.c_str(), info.abilityName.c_str(), info.accessTokenId.c_str());
|
||||
int32_t code = CheckPermissionForSystem();
|
||||
if (code != ERR_OK) {
|
||||
return code;
|
||||
@@ -172,7 +177,8 @@ int32_t AbilityAutoStartupService::CancelApplicationAutoStartup(const AutoStartu
|
||||
|
||||
bool isVisible;
|
||||
std::string abilityTypeName;
|
||||
if (!GetAbilityData(info, isVisible, abilityTypeName)) {
|
||||
std::string accessTokenId;
|
||||
if (!GetAbilityData(info, isVisible, abilityTypeName, accessTokenId)) {
|
||||
TAG_LOGE(AAFwkTag::AUTO_STARTUP, "Failed to get ability data.");
|
||||
return INNER_ERR;
|
||||
}
|
||||
@@ -184,6 +190,7 @@ int32_t AbilityAutoStartupService::CancelApplicationAutoStartup(const AutoStartu
|
||||
|
||||
AutoStartupInfo fullInfo(info);
|
||||
fullInfo.abilityTypeName = abilityTypeName;
|
||||
fullInfo.accessTokenId = accessTokenId;
|
||||
|
||||
return InnerCancelApplicationAutoStartup(fullInfo);
|
||||
}
|
||||
@@ -237,17 +244,23 @@ int32_t AbilityAutoStartupService::QueryAllAutoStartupApplicationsWithoutPermiss
|
||||
return DelayedSingleton<AbilityAutoStartupDataManager>::GetInstance()->QueryAllAutoStartupApplications(infoList);
|
||||
}
|
||||
|
||||
int32_t AbilityAutoStartupService::DeleteAutoStartupData(const std::string &bundleName)
|
||||
int32_t AbilityAutoStartupService::DeleteAutoStartupData(const std::string &bundleName, const int32_t uid)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::AUTO_STARTUP, "Called.");
|
||||
return DelayedSingleton<AbilityAutoStartupDataManager>::GetInstance()->DeleteAutoStartupData(bundleName);
|
||||
return DelayedSingleton<AbilityAutoStartupDataManager>::GetInstance()->DeleteAutoStartupData(bundleName, uid);
|
||||
}
|
||||
|
||||
int32_t AbilityAutoStartupService::CheckAutoStartupData(const std::string &bundleName, int32_t uid)
|
||||
{
|
||||
AppExecFwk::BundleInfo bundleInfo;
|
||||
if (!GetBundleInfo(bundleName, bundleInfo, uid)) {
|
||||
return INNER_ERR;
|
||||
}
|
||||
auto tokenId = bundleInfo.applicationInfo.accessTokenId;
|
||||
std::string accessTokenIdStr = std::to_string(tokenId);
|
||||
std::vector<AutoStartupInfo> infoList;
|
||||
int32_t result = DelayedSingleton<AbilityAutoStartupDataManager>::GetInstance()->GetCurrentAppAutoStartupData(
|
||||
bundleName, infoList);
|
||||
bundleName, infoList, accessTokenIdStr);
|
||||
if (result != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::AUTO_STARTUP, "Failed to get auto startup data.");
|
||||
return result;
|
||||
@@ -256,11 +269,6 @@ int32_t AbilityAutoStartupService::CheckAutoStartupData(const std::string &bundl
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
AppExecFwk::BundleInfo bundleInfo;
|
||||
if (!GetBundleInfo(bundleName, bundleInfo, uid)) {
|
||||
return INNER_ERR;
|
||||
}
|
||||
|
||||
bool isFound = false;
|
||||
for (auto info : infoList) {
|
||||
for (auto abilityInfo : bundleInfo.abilityInfos) {
|
||||
@@ -274,15 +282,16 @@ int32_t AbilityAutoStartupService::CheckAutoStartupData(const std::string &bundl
|
||||
|
||||
if (!isFound) {
|
||||
TAG_LOGD(AAFwkTag::AUTO_STARTUP, "Current bundleName not found in Datebase.");
|
||||
return DelayedSingleton<AbilityAutoStartupDataManager>::GetInstance()->DeleteAutoStartupData(bundleName);
|
||||
return DelayedSingleton<AbilityAutoStartupDataManager>::GetInstance()->DeleteAutoStartupData(bundleName, uid);
|
||||
}
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
void AbilityAutoStartupService::ExecuteCallbacks(bool isCallOn, const AutoStartupInfo &info)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::AUTO_STARTUP, "bundleName: %{public}s, moduleName: %{public}s, abilityName: %{public}s.",
|
||||
info.bundleName.c_str(), info.moduleName.c_str(), info.abilityName.c_str());
|
||||
TAG_LOGD(AAFwkTag::AUTO_STARTUP,
|
||||
"bundleName: %{public}s, moduleName: %{public}s, abilityName: %{public}s, accessTokenId: %{public}s.",
|
||||
info.bundleName.c_str(), info.moduleName.c_str(), info.abilityName.c_str(), info.accessTokenId.c_str());
|
||||
for (auto item : callbackVector_) {
|
||||
auto remoteSystemCallback = iface_cast<IAutoStartupCallBack>(item);
|
||||
if (remoteSystemCallback != nullptr) {
|
||||
@@ -443,15 +452,18 @@ bool AbilityAutoStartupService::GetBundleInfo(
|
||||
}
|
||||
|
||||
bool AbilityAutoStartupService::GetAbilityData(
|
||||
const AutoStartupInfo &info, bool &isVisible, std::string &abilityTypeName)
|
||||
const AutoStartupInfo &info, bool &isVisible, std::string &abilityTypeName, std::string &accessTokenId)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::AUTO_STARTUP, "Called, bundleName: %{public}s, moduleName: %{public}s, abilityName: %{public}s.",
|
||||
info.bundleName.c_str(), info.moduleName.c_str(), info.abilityName.c_str());
|
||||
TAG_LOGD(AAFwkTag::AUTO_STARTUP,
|
||||
"Called, bundleName: %{public}s, moduleName: %{public}s, abilityName: %{public}s, accessTokenId: %{public}s.",
|
||||
info.bundleName.c_str(), info.moduleName.c_str(), info.abilityName.c_str(), info.accessTokenId.c_str());
|
||||
AppExecFwk::BundleInfo bundleInfo;
|
||||
if (!GetBundleInfo(info.bundleName, bundleInfo)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto accessTokenIdStr = bundleInfo.applicationInfo.accessTokenId;
|
||||
accessTokenId = std::to_string(accessTokenIdStr);
|
||||
for (auto abilityInfo : bundleInfo.abilityInfos) {
|
||||
if ((abilityInfo.bundleName == info.bundleName) && (abilityInfo.name == info.abilityName)) {
|
||||
if (info.moduleName.empty() || (abilityInfo.moduleName == info.moduleName)) {
|
||||
@@ -538,10 +550,11 @@ int32_t AbilityAutoStartupService::CheckPermissionForSelf(const std::string &bun
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
int32_t AbilityAutoStartupService::GetAbilityInfo(const AutoStartupInfo &info, std::string &abilityTypeName)
|
||||
int32_t AbilityAutoStartupService::GetAbilityInfo(
|
||||
const AutoStartupInfo &info, std::string &abilityTypeName, std::string &accessTokenId)
|
||||
{
|
||||
bool isVisible = false;
|
||||
if (!GetAbilityData(info, isVisible, abilityTypeName)) {
|
||||
if (!GetAbilityData(info, isVisible, abilityTypeName, accessTokenId)) {
|
||||
TAG_LOGE(AAFwkTag::AUTO_STARTUP, "Failed to get ability data.");
|
||||
return INNER_ERR;
|
||||
}
|
||||
@@ -561,12 +574,14 @@ int32_t AbilityAutoStartupService::SetApplicationAutoStartupByEDM(const AutoStar
|
||||
return errorCode;
|
||||
}
|
||||
std::string typeName;
|
||||
errorCode = GetAbilityInfo(info, typeName);
|
||||
std::string accessTokenId;
|
||||
errorCode = GetAbilityInfo(info, typeName, accessTokenId);
|
||||
if (errorCode != ERR_OK) {
|
||||
return errorCode;
|
||||
}
|
||||
AutoStartupInfo fullInfo(info);
|
||||
fullInfo.abilityTypeName = typeName;
|
||||
fullInfo.accessTokenId = accessTokenId;
|
||||
return InnerApplicationAutoStartupByEDM(fullInfo, true, flag);
|
||||
}
|
||||
|
||||
@@ -577,20 +592,24 @@ int32_t AbilityAutoStartupService::CancelApplicationAutoStartupByEDM(const AutoS
|
||||
return errorCode;
|
||||
}
|
||||
std::string typeName;
|
||||
errorCode = GetAbilityInfo(info, typeName);
|
||||
std::string accessTokenId;
|
||||
errorCode = GetAbilityInfo(info, typeName, accessTokenId);
|
||||
if (errorCode != ERR_OK) {
|
||||
return errorCode;
|
||||
}
|
||||
AutoStartupInfo fullInfo(info);
|
||||
fullInfo.abilityTypeName = typeName;
|
||||
fullInfo.accessTokenId = accessTokenId;
|
||||
return InnerApplicationAutoStartupByEDM(fullInfo, false, flag);
|
||||
}
|
||||
|
||||
int32_t AbilityAutoStartupService::InnerApplicationAutoStartupByEDM(const AutoStartupInfo &info, bool isSet, bool flag)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::AUTO_STARTUP,
|
||||
"Called, bundleName: %{public}s, moduleName: %{public}s, abilityName: %{public}s, isSet: %{public}d.,"
|
||||
"flag: %{public}d.", info.bundleName.c_str(), info.moduleName.c_str(), info.abilityName.c_str(), isSet, flag);
|
||||
"Called, bundleName: %{public}s, moduleName: %{public}s, abilityName: %{public}s, accessTokenId: %{public}s,"
|
||||
" isSet: %{public}d.,""flag: %{public}d.",
|
||||
info.bundleName.c_str(), info.moduleName.c_str(), info.abilityName.c_str(),
|
||||
info.accessTokenId.c_str(), isSet, flag);
|
||||
AutoStartupStatus status =
|
||||
DelayedSingleton<AbilityAutoStartupDataManager>::GetInstance()->QueryAutoStartupData(info);
|
||||
if (status.code != ERR_OK && status.code != ERR_NAME_NOT_FOUND) {
|
||||
|
||||
@@ -58,7 +58,7 @@ void AbilityBundleEventCallback::OnReceiveEvent(const EventFwk::CommonEventData
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "OnReceiveEvent failed, abilityAutoStartupService is nullptr");
|
||||
return;
|
||||
}
|
||||
abilityAutoStartupService_->DeleteAutoStartupData(bundleName);
|
||||
abilityAutoStartupService_->DeleteAutoStartupData(bundleName, uid);
|
||||
} else if (action == EventFwk::CommonEventSupport::COMMON_EVENT_PACKAGE_ADDED) {
|
||||
// install or uninstall module/bundle
|
||||
HandleUpdatedModuleInfo(bundleName, uid);
|
||||
|
||||
@@ -75,6 +75,8 @@ const std::unordered_set<std::string> FROZEN_WHITE_LIST {
|
||||
};
|
||||
constexpr char BUNDLE_NAME_DIALOG[] = "com.ohos.amsdialog";
|
||||
constexpr char ABILITY_NAME_ASSERT_FAULT_DIALOG[] = "AssertFaultDialog";
|
||||
constexpr char BUNDLE_NAME_SAMPLE_MANAGEMENT[] = "com.huawei.hmsapp.samplemanagement";
|
||||
constexpr char ABILITY_NAME_SAMPLE_MANAGEMENT[] = "MspesService";
|
||||
|
||||
bool IsSpecialAbility(const AppExecFwk::AbilityInfo &abilityInfo)
|
||||
{
|
||||
@@ -2009,14 +2011,14 @@ void AbilityConnectManager::HandleAbilityDiedTask(
|
||||
if ((IsLauncher(abilityRecord) || abilityRecord->IsSceneBoard()) && token != nullptr) {
|
||||
IN_PROCESS_CALL_WITHOUT_RET(DelayedSingleton<AppScheduler>::GetInstance()->ClearProcessByToken(
|
||||
token->AsObject()));
|
||||
if (abilityRecord->IsSceneBoard() && currentUserId != userId_) {
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "Not the current user's SCB, clear the user and do not restart");
|
||||
KillProcessesByUserId();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (abilityRecord->IsSceneBoard() && currentUserId != userId_) {
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "Not the current user's SCB, clear the user and do not restart");
|
||||
KillProcessesByUserId();
|
||||
return;
|
||||
}
|
||||
if (DelayedSingleton<AppScheduler>::GetInstance()->IsMemorySizeSufficent() ||
|
||||
IsLauncher(abilityRecord) || abilityRecord->IsSceneBoard()) {
|
||||
IsLauncher(abilityRecord) || abilityRecord->IsSceneBoard() || IsSampleManagement(abilityRecord)) {
|
||||
RestartAbility(abilityRecord, currentUserId);
|
||||
}
|
||||
} else {
|
||||
@@ -2345,6 +2347,16 @@ bool AbilityConnectManager::IsLauncher(std::shared_ptr<AbilityRecord> serviceExt
|
||||
serviceExtension->GetAbilityInfo().bundleName == AbilityConfig::LAUNCHER_BUNDLE_NAME;
|
||||
}
|
||||
|
||||
bool AbilityConnectManager::IsSampleManagement(std::shared_ptr<AbilityRecord> serviceExtension) const
|
||||
{
|
||||
if (serviceExtension == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "param is nullptr");
|
||||
return false;
|
||||
}
|
||||
return serviceExtension->GetAbilityInfo().name == ABILITY_NAME_SAMPLE_MANAGEMENT &&
|
||||
serviceExtension->GetAbilityInfo().bundleName == BUNDLE_NAME_SAMPLE_MANAGEMENT;
|
||||
}
|
||||
|
||||
void AbilityConnectManager::KillProcessesByUserId() const
|
||||
{
|
||||
auto appScheduler = DelayedSingleton<AppScheduler>::GetInstance();
|
||||
@@ -2841,7 +2853,8 @@ void AbilityConnectManager::DeleteInvalidServiceRecord(const std::string &bundle
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "Delete invalid record by %{public}s.", bundleName.c_str());
|
||||
std::lock_guard lock(serviceMapMutex_);
|
||||
for (auto it = serviceMap_.begin(); it != serviceMap_.end();) {
|
||||
if (it->second != nullptr && it->second->GetApplicationInfo().bundleName == bundleName) {
|
||||
if (it->second != nullptr && it->second->GetApplicationInfo().bundleName == bundleName &&
|
||||
!IsUIExtensionAbility(it->second)) {
|
||||
it = serviceMap_.erase(it);
|
||||
} else {
|
||||
++it;
|
||||
@@ -2889,7 +2902,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_;
|
||||
|
||||
@@ -143,30 +143,33 @@ namespace {
|
||||
return ERR_NOT_SYSTEM_APP; \
|
||||
}
|
||||
|
||||
const std::string ARGS_USER_ID = "-u";
|
||||
const std::string ARGS_CLIENT = "-c";
|
||||
const std::string ILLEGAL_INFOMATION = "The arguments are illegal and you can enter '-h' for help.";
|
||||
constexpr const char* ARGS_USER_ID = "-u";
|
||||
constexpr const char* ARGS_CLIENT = "-c";
|
||||
constexpr const char* ILLEGAL_INFOMATION = "The arguments are illegal and you can enter '-h' for help.";
|
||||
|
||||
|
||||
constexpr int32_t NEW_RULE_VALUE_SIZE = 6;
|
||||
constexpr int64_t APP_ALIVE_TIME_MS = 1000; // Allow background startup within 1 second after application startup
|
||||
constexpr int32_t APP_ALIVE_TIME_MS = 1000; // Allow background startup within 1 second after application startup
|
||||
constexpr int32_t REGISTER_FOCUS_DELAY = 5000;
|
||||
constexpr size_t OFFSET = 32;
|
||||
const std::string IS_DELEGATOR_CALL = "isDelegatorCall";
|
||||
constexpr const char* IS_DELEGATOR_CALL = "isDelegatorCall";
|
||||
|
||||
// Startup rule switch
|
||||
const std::string COMPONENT_STARTUP_NEW_RULES = "component.startup.newRules";
|
||||
const std::string NEW_RULES_EXCEPT_LAUNCHER_SYSTEMUI = "component.startup.newRules.except.LauncherSystemUI";
|
||||
const std::string BACKGROUND_JUDGE_FLAG = "component.startup.backgroundJudge.flag";
|
||||
const std::string WHITE_LIST_ASS_WAKEUP_FLAG = "component.startup.whitelist.associatedWakeUp";
|
||||
constexpr const char* COMPONENT_STARTUP_NEW_RULES = "component.startup.newRules";
|
||||
constexpr const char* NEW_RULES_EXCEPT_LAUNCHER_SYSTEMUI = "component.startup.newRules.except.LauncherSystemUI";
|
||||
constexpr const char* BACKGROUND_JUDGE_FLAG = "component.startup.backgroundJudge.flag";
|
||||
constexpr const char* WHITE_LIST_ASS_WAKEUP_FLAG = "component.startup.whitelist.associatedWakeUp";
|
||||
|
||||
// White list app
|
||||
const std::string BUNDLE_NAME_SETTINGSDATA = "com.ohos.settingsdata";
|
||||
constexpr const char* BUNDLE_NAME_SETTINGSDATA = "com.ohos.settingsdata";
|
||||
// Support prepare terminate
|
||||
constexpr int32_t PREPARE_TERMINATE_ENABLE_SIZE = 6;
|
||||
const char* PREPARE_TERMINATE_ENABLE_PARAMETER = "persist.sys.prepare_terminate";
|
||||
constexpr const char* PREPARE_TERMINATE_ENABLE_PARAMETER = "persist.sys.prepare_terminate";
|
||||
// UIExtension type
|
||||
const std::string UIEXTENSION_TYPE_KEY = "ability.want.params.uiExtensionType";
|
||||
const std::string UIEXTENSION_TARGET_TYPE_KEY = "ability.want.params.uiExtensionTargetType";
|
||||
const std::string SYSTEM_SHARE = "share";
|
||||
const std::string SYSTEM_SHARE_TYPE = "sysPicker/share";
|
||||
constexpr const char* UIEXTENSION_TYPE_KEY = "ability.want.params.uiExtensionType";
|
||||
constexpr const char* UIEXTENSION_TARGET_TYPE_KEY = "ability.want.params.uiExtensionTargetType";
|
||||
constexpr const char* SYSTEM_SHARE = "share";
|
||||
constexpr const char* SYSTEM_SHARE_TYPE = "sysPicker/share";
|
||||
// Share picker params
|
||||
constexpr char SHARE_PICKER_DIALOG_BUNDLE_NAME_KEY[] = "const.system.sharePicker.bundleName";
|
||||
constexpr char SHARE_PICKER_DIALOG_ABILITY_NAME_KEY[] = "const.system.sharePicker.abilityName";
|
||||
@@ -177,19 +180,19 @@ constexpr char TOKEN_KEY[] = "ohos.ability.params.token";
|
||||
// Developer mode param
|
||||
constexpr char DEVELOPER_MODE_STATE[] = "const.security.developermode.state";
|
||||
// Broker params key
|
||||
const std::string KEY_VISIBLE_ID = "ohos.anco.param.visible";
|
||||
const std::string START_ABILITY_TYPE = "ABILITY_INNER_START_WITH_ACCOUNT";
|
||||
const std::string SHELL_ASSISTANT_BUNDLENAME = "com.huawei.shell_assistant";
|
||||
const std::string SHELL_ASSISTANT_ABILITYNAME = "MainAbility";
|
||||
const std::string AMS_DIALOG_BUNDLENAME = "com.ohos.amsdialog";
|
||||
const std::string STR_PHONE = "phone";
|
||||
constexpr const char* KEY_VISIBLE_ID = "ohos.anco.param.visible";
|
||||
constexpr const char* START_ABILITY_TYPE = "ABILITY_INNER_START_WITH_ACCOUNT";
|
||||
constexpr const char* SHELL_ASSISTANT_BUNDLENAME = "com.huawei.shell_assistant";
|
||||
constexpr const char* SHELL_ASSISTANT_ABILITYNAME = "MainAbility";
|
||||
constexpr const char* AMS_DIALOG_BUNDLENAME = "com.ohos.amsdialog";
|
||||
constexpr const char* STR_PHONE = "phone";
|
||||
// Distributed continued session Id
|
||||
const std::string DMS_CONTINUED_SESSION_ID = "ohos.dms.continueSessionId";
|
||||
const std::string DMS_PERSISTENT_ID = "ohos.dms.persistentId";
|
||||
constexpr const char* DMS_CONTINUED_SESSION_ID = "ohos.dms.continueSessionId";
|
||||
constexpr const char* DMS_PERSISTENT_ID = "ohos.dms.persistentId";
|
||||
|
||||
const std::string DEBUG_APP = "debugApp";
|
||||
const std::string AUTO_FILL_PASSWORD_TPYE = "autoFill/password";
|
||||
const std::string AUTO_FILL_SMART_TPYE = "autoFill/smart";
|
||||
constexpr const char* DEBUG_APP = "debugApp";
|
||||
constexpr const char* AUTO_FILL_PASSWORD_TPYE = "autoFill/password";
|
||||
constexpr const char* AUTO_FILL_SMART_TPYE = "autoFill/smart";
|
||||
constexpr size_t INDEX_ZERO = 0;
|
||||
constexpr size_t INDEX_ONE = 1;
|
||||
constexpr size_t INDEX_TWO = 2;
|
||||
@@ -197,11 +200,11 @@ constexpr size_t ARGC_THREE = 3;
|
||||
constexpr static char WANT_PARAMS_VIEW_DATA_KEY[] = "ohos.ability.params.viewData";
|
||||
|
||||
constexpr int32_t FOUNDATION_UID = 5523;
|
||||
const std::string FRS_BUNDLE_NAME = "com.ohos.formrenderservice";
|
||||
const std::string FOUNDATION_PROCESS_NAME = "foundation";
|
||||
const std::string IS_PRELOAD_UIEXTENSION_ABILITY = "ability.want.params.is_preload_uiextension_ability";
|
||||
const std::string UIEXTENSION_MODAL_TYPE = "ability.want.params.modalType";
|
||||
const std::string ATOMIC_SERVICE_PREFIX = "com.atomicservice.";
|
||||
constexpr const char* FRS_BUNDLE_NAME = "com.ohos.formrenderservice";
|
||||
constexpr const char* FOUNDATION_PROCESS_NAME = "foundation";
|
||||
constexpr const char* IS_PRELOAD_UIEXTENSION_ABILITY = "ability.want.params.is_preload_uiextension_ability";
|
||||
constexpr const char* UIEXTENSION_MODAL_TYPE = "ability.want.params.modalType";
|
||||
constexpr const char* ATOMIC_SERVICE_PREFIX = "com.atomicservice.";
|
||||
constexpr const char* PARAM_SPECIFIED_PROCESS_FLAG = "ohosSpecifiedProcessFlag";
|
||||
|
||||
constexpr char ASSERT_FAULT_DETAIL[] = "assertFaultDialogDetail";
|
||||
@@ -231,54 +234,54 @@ using namespace std::chrono_literals;
|
||||
using namespace BackgroundTaskMgr;
|
||||
#endif
|
||||
const bool CONCURRENCY_MODE_FALSE = false;
|
||||
const int32_t MAIN_USER_ID = 100;
|
||||
constexpr int32_t MAIN_USER_ID = 100;
|
||||
constexpr auto DATA_ABILITY_START_TIMEOUT = 5s;
|
||||
constexpr int32_t NON_ANONYMIZE_LENGTH = 6;
|
||||
constexpr uint32_t SCENE_FLAG_NORMAL = 0;
|
||||
const int32_t MAX_NUMBER_OF_DISTRIBUTED_MISSIONS = 20;
|
||||
const int32_t SWITCH_ACCOUNT_TRY = 3;
|
||||
constexpr int32_t MAX_NUMBER_OF_DISTRIBUTED_MISSIONS = 20;
|
||||
constexpr int32_t SWITCH_ACCOUNT_TRY = 3;
|
||||
#ifdef ABILITY_COMMAND_FOR_TEST
|
||||
const int32_t BLOCK_AMS_SERVICE_TIME = 65;
|
||||
constexpr int32_t BLOCK_AMS_SERVICE_TIME = 65;
|
||||
#endif
|
||||
const std::string EMPTY_DEVICE_ID = "";
|
||||
const int32_t APP_MEMORY_SIZE = 512;
|
||||
const int32_t GET_PARAMETER_INCORRECT = -9;
|
||||
const int32_t GET_PARAMETER_OTHER = -1;
|
||||
const int32_t SIZE_10 = 10;
|
||||
const int32_t HIDUMPER_SERVICE_UID = 1212;
|
||||
const int32_t ACCOUNT_MGR_SERVICE_UID = 3058;
|
||||
const int32_t BROKER_UID = 5557;
|
||||
const int32_t BROKER_RESERVE_UID = 5005;
|
||||
const int32_t DMS_UID = 5522;
|
||||
const int32_t PREPARE_TERMINATE_TIMEOUT_MULTIPLE = 10;
|
||||
const int32_t BOOTEVENT_COMPLETED_DELAY_TIME = 1000;
|
||||
constexpr const char* EMPTY_DEVICE_ID = "";
|
||||
constexpr int32_t APP_MEMORY_SIZE = 512;
|
||||
constexpr int32_t GET_PARAMETER_INCORRECT = -9;
|
||||
constexpr int32_t GET_PARAMETER_OTHER = -1;
|
||||
constexpr int32_t SIZE_10 = 10;
|
||||
constexpr int32_t HIDUMPER_SERVICE_UID = 1212;
|
||||
constexpr int32_t ACCOUNT_MGR_SERVICE_UID = 3058;
|
||||
constexpr int32_t BROKER_UID = 5557;
|
||||
constexpr int32_t BROKER_RESERVE_UID = 5005;
|
||||
constexpr int32_t DMS_UID = 5522;
|
||||
constexpr int32_t PREPARE_TERMINATE_TIMEOUT_MULTIPLE = 10;
|
||||
constexpr int32_t BOOTEVENT_COMPLETED_DELAY_TIME = 1000;
|
||||
constexpr int32_t BOOTEVENT_BOOT_ANIMATION_READY_SIZE = 6;
|
||||
const std::string BUNDLE_NAME_KEY = "bundleName";
|
||||
const std::string DM_PKG_NAME = "ohos.distributedhardware.devicemanager";
|
||||
const std::string ACTION_CHOOSE = "ohos.want.action.select";
|
||||
const std::string HIGHEST_PRIORITY_ABILITY_ENTITY = "flag.home.intent.from.system";
|
||||
const std::string DMS_API_VERSION = "dmsApiVersion";
|
||||
const std::string DMS_IS_CALLER_BACKGROUND = "dmsIsCallerBackGround";
|
||||
const std::string DMS_PROCESS_NAME = "distributedsched";
|
||||
const std::string DMS_MISSION_ID = "dmsMissionId";
|
||||
const std::string BOOTEVENT_APPFWK_READY = "bootevent.appfwk.ready";
|
||||
const std::string BOOTEVENT_BOOT_COMPLETED = "bootevent.boot.completed";
|
||||
const std::string BOOTEVENT_BOOT_ANIMATION_STARTED = "bootevent.bootanimation.started";
|
||||
const std::string BOOTEVENT_BOOT_ANIMATION_READY = "bootevent.bootanimation.ready";
|
||||
const std::string NEED_STARTINGWINDOW = "ohos.ability.NeedStartingWindow";
|
||||
const std::string PERMISSIONMGR_BUNDLE_NAME = "com.ohos.permissionmanager";
|
||||
const std::string PERMISSIONMGR_ABILITY_NAME = "com.ohos.permissionmanager.GrantAbility";
|
||||
const std::string IS_CALL_BY_SCB = "isCallBySCB";
|
||||
const std::string SPECIFY_TOKEN_ID = "specifyTokenId";
|
||||
const std::string PROCESS_SUFFIX = "embeddable";
|
||||
const int DEFAULT_DMS_MISSION_ID = -1;
|
||||
const char* PARAM_PREVENT_STARTABILITY = "persist.sys.abilityms.prevent_startability";
|
||||
const std::string SUSPEND_SERVICE_CONFIG_FILE = "/etc/efficiency_manager/prevent_startability_whitelist.json";
|
||||
const int32_t MAX_BUFFER = 2048;
|
||||
constexpr const char* BUNDLE_NAME_KEY = "bundleName";
|
||||
constexpr const char* DM_PKG_NAME = "ohos.distributedhardware.devicemanager";
|
||||
constexpr const char* ACTION_CHOOSE = "ohos.want.action.select";
|
||||
constexpr const char* HIGHEST_PRIORITY_ABILITY_ENTITY = "flag.home.intent.from.system";
|
||||
constexpr const char* DMS_API_VERSION = "dmsApiVersion";
|
||||
constexpr const char* DMS_IS_CALLER_BACKGROUND = "dmsIsCallerBackGround";
|
||||
constexpr const char* DMS_PROCESS_NAME = "distributedsched";
|
||||
constexpr const char* DMS_MISSION_ID = "dmsMissionId";
|
||||
constexpr const char* BOOTEVENT_APPFWK_READY = "bootevent.appfwk.ready";
|
||||
constexpr const char* BOOTEVENT_BOOT_COMPLETED = "bootevent.boot.completed";
|
||||
constexpr const char* BOOTEVENT_BOOT_ANIMATION_STARTED = "bootevent.bootanimation.started";
|
||||
constexpr const char* BOOTEVENT_BOOT_ANIMATION_READY = "bootevent.bootanimation.ready";
|
||||
constexpr const char* NEED_STARTINGWINDOW = "ohos.ability.NeedStartingWindow";
|
||||
constexpr const char* PERMISSIONMGR_BUNDLE_NAME = "com.ohos.permissionmanager";
|
||||
constexpr const char* PERMISSIONMGR_ABILITY_NAME = "com.ohos.permissionmanager.GrantAbility";
|
||||
constexpr const char* IS_CALL_BY_SCB = "isCallBySCB";
|
||||
constexpr const char* SPECIFY_TOKEN_ID = "specifyTokenId";
|
||||
constexpr const char* PROCESS_SUFFIX = "embeddable";
|
||||
constexpr int32_t DEFAULT_DMS_MISSION_ID = -1;
|
||||
constexpr const char* PARAM_PREVENT_STARTABILITY = "persist.sys.abilityms.prevent_startability";
|
||||
constexpr const char* SUSPEND_SERVICE_CONFIG_FILE = "/etc/efficiency_manager/prevent_startability_whitelist.json";
|
||||
constexpr int32_t MAX_BUFFER = 2048;
|
||||
nlohmann::json whiteListJsonObj;
|
||||
const int32_t API12 = 12;
|
||||
const int32_t API_VERSION_MOD = 100;
|
||||
const std::string WHITE_LIST = "white_list";
|
||||
constexpr int32_t API12 = 12;
|
||||
constexpr int32_t API_VERSION_MOD = 100;
|
||||
constexpr const char* WHITE_LIST = "white_list";
|
||||
const std::map<std::string, AbilityManagerService::DumpKey> AbilityManagerService::dumpMap = {
|
||||
std::map<std::string, AbilityManagerService::DumpKey>::value_type("--all", KEY_DUMP_ALL),
|
||||
std::map<std::string, AbilityManagerService::DumpKey>::value_type("-a", KEY_DUMP_ALL),
|
||||
@@ -375,7 +378,7 @@ void AbilityManagerService::OnStart()
|
||||
return;
|
||||
}
|
||||
|
||||
SetParameter(BOOTEVENT_APPFWK_READY.c_str(), "true");
|
||||
SetParameter(BOOTEVENT_APPFWK_READY, "true");
|
||||
AddSystemAbilityListener(BACKGROUND_TASK_MANAGER_SERVICE_ID);
|
||||
AddSystemAbilityListener(DISTRIBUTED_SCHED_SA_ID);
|
||||
AddSystemAbilityListener(BUNDLE_MGR_SERVICE_SYS_ABILITY_ID);
|
||||
@@ -479,11 +482,11 @@ void AbilityManagerService::InitPushTask()
|
||||
auto bootCompletedTask = [handler = taskHandler_]() {
|
||||
if (ApplicationUtil::IsBootCompleted()) {
|
||||
auto task = []() {
|
||||
ApplicationUtil::AppFwkBootEventCallback(BOOTEVENT_BOOT_COMPLETED.c_str(), "true", nullptr);
|
||||
ApplicationUtil::AppFwkBootEventCallback(BOOTEVENT_BOOT_COMPLETED, "true", nullptr);
|
||||
};
|
||||
handler->SubmitTask(task, "BootCompletedDelayTask", BOOTEVENT_COMPLETED_DELAY_TIME);
|
||||
} else {
|
||||
WatchParameter(BOOTEVENT_BOOT_COMPLETED.c_str(), ApplicationUtil::AppFwkBootEventCallback, nullptr);
|
||||
WatchParameter(BOOTEVENT_BOOT_COMPLETED, ApplicationUtil::AppFwkBootEventCallback, nullptr);
|
||||
}
|
||||
};
|
||||
if (!ParseJsonFromBoot(whiteListJsonObj, SUSPEND_SERVICE_CONFIG_FILE, WHITE_LIST)) {
|
||||
@@ -1823,7 +1826,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;
|
||||
@@ -3422,7 +3425,7 @@ bool AbilityManagerService::GetLocalDeviceId(std::string& localDeviceId)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
auto localNode = std::make_unique<NodeBasicInfo>();
|
||||
int32_t errCode = GetLocalNodeDeviceInfo(DM_PKG_NAME.c_str(), localNode.get());
|
||||
int32_t errCode = GetLocalNodeDeviceInfo(DM_PKG_NAME, localNode.get());
|
||||
if (errCode != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "AbilityManagerService::GetLocalNodeDeviceInfo errCode = %{public}d", errCode);
|
||||
return false;
|
||||
@@ -4168,7 +4171,7 @@ sptr<IWantSender> AbilityManagerService::GetWantSender(
|
||||
|
||||
int32_t callerUid = IPCSkeleton::GetCallingUid();
|
||||
int32_t userId = wantSenderInfo.userId;
|
||||
bool bundleMgrResult = false;
|
||||
int32_t bundleMgrResult = 0;
|
||||
if (userId < 0) {
|
||||
if (DelayedSingleton<AppExecFwk::OsAccountManagerWrapper>::GetInstance()->
|
||||
GetOsAccountLocalIdFromUid(callerUid, userId) != 0) {
|
||||
@@ -4182,12 +4185,13 @@ sptr<IWantSender> AbilityManagerService::GetWantSender(
|
||||
if (!wantSenderInfo.allWants.empty()) {
|
||||
AppExecFwk::BundleInfo bundleInfo;
|
||||
std::string bundleName = wantSenderInfo.allWants.back().want.GetElement().GetBundleName();
|
||||
bundleMgrResult = IN_PROCESS_CALL(bms->GetBundleInfo(bundleName,
|
||||
AppExecFwk::BundleFlag::GET_BUNDLE_DEFAULT, bundleInfo, userId));
|
||||
if (bundleMgrResult) {
|
||||
GetRunningMultiAppIndex(bundleName, callerUid, appIndex);
|
||||
bundleMgrResult = IN_PROCESS_CALL(bms->GetCloneBundleInfo(bundleName,
|
||||
static_cast<int32_t>(AppExecFwk::GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_APPLICATION),
|
||||
appIndex, bundleInfo, userId));
|
||||
if (bundleMgrResult == ERR_OK) {
|
||||
appUid = bundleInfo.uid;
|
||||
}
|
||||
GetRunningMultiAppIndex(bundleName, callerUid, appIndex);
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "App bundleName: %{public}s, uid: %{public}d", bundleName.c_str(), appUid);
|
||||
}
|
||||
if (!CheckSenderWantInfo(callerUid, wantSenderInfo)) {
|
||||
@@ -5992,7 +5996,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 +7612,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 +7648,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 +7725,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 +8901,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 +9073,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 +10169,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.");
|
||||
@@ -10308,15 +10312,15 @@ bool AbilityManagerService::CheckCallerIsDmsProcess()
|
||||
void AbilityManagerService::WaitBootAnimationStart()
|
||||
{
|
||||
char value[BOOTEVENT_BOOT_ANIMATION_READY_SIZE] = "";
|
||||
int32_t ret = GetParameter(BOOTEVENT_BOOT_ANIMATION_READY.c_str(), "", value,
|
||||
int32_t ret = GetParameter(BOOTEVENT_BOOT_ANIMATION_READY, "", value,
|
||||
BOOTEVENT_BOOT_ANIMATION_READY_SIZE);
|
||||
if (ret > 0 && !std::strcmp(value, "false")) {
|
||||
// Get new param success and new param is not ready, wait the new param.
|
||||
WaitParameter(BOOTEVENT_BOOT_ANIMATION_READY.c_str(), "true",
|
||||
WaitParameter(BOOTEVENT_BOOT_ANIMATION_READY, "true",
|
||||
AmsConfigurationParameter::GetInstance().GetBootAnimationTimeoutTime());
|
||||
} else if (ret <= 0 || !std::strcmp(value, "")) {
|
||||
// Get new param failed or new param is not set, wait the old param.
|
||||
WaitParameter(BOOTEVENT_BOOT_ANIMATION_STARTED.c_str(), "true",
|
||||
WaitParameter(BOOTEVENT_BOOT_ANIMATION_STARTED, "true",
|
||||
AmsConfigurationParameter::GetInstance().GetBootAnimationTimeoutTime());
|
||||
}
|
||||
// other, the animation is ready, not wait.
|
||||
@@ -10559,7 +10563,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"
|
||||
@@ -10741,7 +10745,7 @@ void AbilityManagerService::GetRunningMultiAppIndex(const std::string &bundleNam
|
||||
TAG_LOGW(AAFwkTag::ABILITYMGR, "GetAppMgr failed");
|
||||
return;
|
||||
}
|
||||
auto ret = appMgr->GetRunningMultiAppInfoByBundleName(bundleName, runningMultiAppInfo);
|
||||
auto ret = IN_PROCESS_CALL(appMgr->GetRunningMultiAppInfoByBundleName(bundleName, runningMultiAppInfo));
|
||||
if (ret != ERR_OK) {
|
||||
TAG_LOGW(AAFwkTag::ABILITYMGR, "GetRunningMultiAppInfo failed bundleName = %{public}s",
|
||||
bundleName.c_str());
|
||||
|
||||
@@ -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"
|
||||
@@ -33,6 +34,9 @@
|
||||
#include "bundle_mgr_client.h"
|
||||
#include "configuration_convertor.h"
|
||||
#include "connection_state_manager.h"
|
||||
#include "common_event_data.h"
|
||||
#include "common_event_manager.h"
|
||||
#include "common_event_support.h"
|
||||
#include "freeze_util.h"
|
||||
#include "global_constant.h"
|
||||
#include "hitrace_meter.h"
|
||||
@@ -1267,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) {
|
||||
@@ -1436,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();
|
||||
@@ -3049,6 +3059,28 @@ bool AbilityRecord::GetUriListFromWant(Want &want, std::vector<std::string> &uri
|
||||
return true;
|
||||
}
|
||||
|
||||
void AbilityRecord::PublishFileOpenEvent(const Want &want)
|
||||
{
|
||||
auto wangUri = want.GetUri();
|
||||
std::string uriStr = wangUri.ToString();
|
||||
if (!uriStr.empty() && wangUri.GetScheme() == "file") {
|
||||
TAG_LOGI(AAFwkTag::ABILITYMGR, "ability record, file uri: %{private}s, isGranted: %{public}d",
|
||||
uriStr.c_str(), isGrantedUriPermission_);
|
||||
Want msgWant;
|
||||
msgWant.SetAction("file.event.OPEN_TIME");
|
||||
msgWant.SetParam("uri", uriStr);
|
||||
auto timeNow = std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
std::chrono::system_clock::now().time_since_epoch()).count();
|
||||
std::string currentTime = std::to_string(timeNow);
|
||||
msgWant.SetParam("viewTime", currentTime);
|
||||
EventFwk::CommonEventData commonData{msgWant};
|
||||
EventFwk::CommonEventPublishInfo commonEventPublishInfo;
|
||||
std::vector<std::string> subscriberPermissions = {"ohos.permission.MANAGE_LOCAL_ACCOUNTS"};
|
||||
commonEventPublishInfo.SetSubscriberPermissions(subscriberPermissions);
|
||||
EventFwk::CommonEventManager::PublishCommonEvent(commonData, commonEventPublishInfo);
|
||||
}
|
||||
}
|
||||
|
||||
void AbilityRecord::GrantUriPermission(Want &want, std::string targetBundleName, bool isSandboxApp, uint32_t tokenId)
|
||||
{
|
||||
// reject sandbox to grant uri permission by start ability
|
||||
@@ -3089,6 +3121,7 @@ void AbilityRecord::GrantUriPermission(Want &want, std::string targetBundleName,
|
||||
return;
|
||||
}
|
||||
GrantUriPermissionInner(want, uriVec, targetBundleName, tokenId);
|
||||
PublishFileOpenEvent(want);
|
||||
}
|
||||
|
||||
void AbilityRecord::GrantUriPermissionInner(Want &want, std::vector<std::string> &uriVec,
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ void RestartAppManager::AddRestartAppHistory(const RestartAppKeyType &key, time_
|
||||
bool RestartAppManager::IsForegroundToRestartApp() const
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "IsForegroundToRestartApp, called.");
|
||||
auto callerPid = IPCSkeleton::GetCallingRealPid();
|
||||
auto callerPid = IPCSkeleton::GetCallingPid();
|
||||
AppExecFwk::RunningProcessInfo processInfo;
|
||||
DelayedSingleton<AppScheduler>::GetInstance()->GetRunningProcessInfoByPid(callerPid, processInfo);
|
||||
if (processInfo.state_ == AppProcessState::APP_STATE_FOREGROUND || processInfo.isFocused ||
|
||||
|
||||
@@ -104,6 +104,8 @@ int UIAbilityLifecycleManager::StartUIAbility(AbilityRequest &abilityRequest, sp
|
||||
if (sessionInfo->isNewWant) {
|
||||
uiAbilityRecord->SetWant(abilityRequest.want);
|
||||
uiAbilityRecord->GetSessionInfo()->want.CloseAllFd();
|
||||
} else {
|
||||
sessionInfo->want.CloseAllFd();
|
||||
}
|
||||
} else {
|
||||
uiAbilityRecord = CreateAbilityRecord(abilityRequest, sessionInfo);
|
||||
@@ -259,7 +261,7 @@ int UIAbilityLifecycleManager::AttachAbilityThread(const sptr<IAbilityScheduler>
|
||||
abilityRecord->SetScheduler(scheduler);
|
||||
if (DoProcessAttachment(abilityRecord) != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "do process attachment failed, close the ability.");
|
||||
BatchCloseUIAbility({abilityRecord});
|
||||
TerminateSession(abilityRecord);
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
if (abilityRecord->IsStartedByCall()) {
|
||||
@@ -356,7 +358,9 @@ int UIAbilityLifecycleManager::NotifySCBToStartUIAbility(const AbilityRequest &a
|
||||
sessionInfo->processOptions = abilityRequest.processOptions;
|
||||
TAG_LOGI(
|
||||
AAFwkTag::ABILITYMGR, "Reused sessionId: %{public}d, userId: %{public}d.", sessionInfo->persistentId, userId_);
|
||||
return NotifySCBPendingActivation(sessionInfo, abilityRequest);
|
||||
int ret = NotifySCBPendingActivation(sessionInfo, abilityRequest);
|
||||
sessionInfo->want.CloseAllFd();
|
||||
return ret;
|
||||
}
|
||||
|
||||
int UIAbilityLifecycleManager::DispatchState(const std::shared_ptr<AbilityRecord> &abilityRecord, int state)
|
||||
@@ -2220,8 +2224,10 @@ int32_t UIAbilityLifecycleManager::KillProcessWithPrepareTerminate(const std::ve
|
||||
}
|
||||
if (needKillProcess) {
|
||||
pidsToKill.push_back(pid);
|
||||
} else if (!abilitysToTerminate.empty()) {
|
||||
BatchCloseUIAbility(abilitysToTerminate);
|
||||
continue;
|
||||
}
|
||||
for (const auto& abilityRecord: abilitysToTerminate) {
|
||||
TerminateSession(abilityRecord);
|
||||
}
|
||||
}
|
||||
if (!pidsToKill.empty()) {
|
||||
@@ -2251,6 +2257,18 @@ void UIAbilityLifecycleManager::BatchCloseUIAbility(
|
||||
}
|
||||
}
|
||||
|
||||
void UIAbilityLifecycleManager::TerminateSession(std::shared_ptr<AbilityRecord> abilityRecord)
|
||||
{
|
||||
CHECK_POINTER(abilityRecord);
|
||||
auto sessionInfo = abilityRecord->GetSessionInfo();
|
||||
CHECK_POINTER(sessionInfo);
|
||||
CHECK_POINTER(sessionInfo->sessionToken);
|
||||
auto session = iface_cast<Rosen::ISession>(sessionInfo->sessionToken);
|
||||
CHECK_POINTER(session);
|
||||
TAG_LOGI(AAFwkTag::ABILITYMGR, "call TerminateSession, session id: %{public}d", sessionInfo->persistentId);
|
||||
session->TerminateSession(sessionInfo);
|
||||
}
|
||||
|
||||
int UIAbilityLifecycleManager::ChangeAbilityVisibility(sptr<IRemoteObject> token, bool isShow)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
|
||||
@@ -58,11 +58,6 @@ bool UnlockScreenManager::UnlockScreen()
|
||||
if (isScreenLocked && isScreenSecured) {
|
||||
return false;
|
||||
}
|
||||
if (isScreenLocked) {
|
||||
sptr<UnlockScreenCallback> listener = sptr<UnlockScreenCallback>(new (std::nothrow) UnlockScreenCallback());
|
||||
IN_PROCESS_CALL(OHOS::ScreenLock::ScreenLockManager::GetInstance()->Unlock(
|
||||
OHOS::ScreenLock::Action::UNLOCKSCREEN, listener));
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -73,6 +68,14 @@ bool UnlockScreenManager::UnlockScreen()
|
||||
PowerMgr::PowerMgrClient::GetInstance().WakeupDevice();
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
if (isScreenLocked) {
|
||||
sptr<UnlockScreenCallback> listener = sptr<UnlockScreenCallback>(new (std::nothrow) UnlockScreenCallback());
|
||||
IN_PROCESS_CALL(OHOS::ScreenLock::ScreenLockManager::GetInstance()->Unlock(
|
||||
OHOS::ScreenLock::Action::UNLOCKSCREEN, listener));
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
} // namespace AbilityRuntime
|
||||
|
||||
@@ -129,44 +129,6 @@ StartAbilityInfoWrap::~StartAbilityInfoWrap()
|
||||
StartAbilityUtils::skipErms = false;
|
||||
}
|
||||
|
||||
void StartAbilityInfo::InitAbilityInfoFromExtension(AppExecFwk::ExtensionAbilityInfo &extensionInfo,
|
||||
AppExecFwk::AbilityInfo &abilityInfo)
|
||||
{
|
||||
abilityInfo.applicationName = extensionInfo.applicationInfo.name;
|
||||
abilityInfo.applicationInfo = extensionInfo.applicationInfo;
|
||||
abilityInfo.bundleName = extensionInfo.bundleName;
|
||||
abilityInfo.package = extensionInfo.moduleName;
|
||||
abilityInfo.moduleName = extensionInfo.moduleName;
|
||||
abilityInfo.name = extensionInfo.name;
|
||||
abilityInfo.srcEntrance = extensionInfo.srcEntrance;
|
||||
abilityInfo.srcPath = extensionInfo.srcEntrance;
|
||||
abilityInfo.iconPath = extensionInfo.icon;
|
||||
abilityInfo.iconId = extensionInfo.iconId;
|
||||
abilityInfo.label = extensionInfo.label;
|
||||
abilityInfo.labelId = extensionInfo.labelId;
|
||||
abilityInfo.description = extensionInfo.description;
|
||||
abilityInfo.descriptionId = extensionInfo.descriptionId;
|
||||
abilityInfo.priority = extensionInfo.priority;
|
||||
abilityInfo.permissions = extensionInfo.permissions;
|
||||
abilityInfo.readPermission = extensionInfo.readPermission;
|
||||
abilityInfo.writePermission = extensionInfo.writePermission;
|
||||
abilityInfo.uri = extensionInfo.uri;
|
||||
abilityInfo.extensionAbilityType = extensionInfo.type;
|
||||
abilityInfo.visible = extensionInfo.visible;
|
||||
abilityInfo.resourcePath = extensionInfo.resourcePath;
|
||||
abilityInfo.enabled = extensionInfo.enabled;
|
||||
abilityInfo.isModuleJson = true;
|
||||
abilityInfo.isStageBasedModel = true;
|
||||
abilityInfo.process = extensionInfo.process;
|
||||
abilityInfo.metadata = extensionInfo.metadata;
|
||||
abilityInfo.compileMode = extensionInfo.compileMode;
|
||||
abilityInfo.type = AppExecFwk::AbilityType::EXTENSION;
|
||||
abilityInfo.extensionTypeName = extensionInfo.extensionTypeName;
|
||||
if (!extensionInfo.hapPath.empty()) {
|
||||
abilityInfo.hapPath = extensionInfo.hapPath;
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<StartAbilityInfo> StartAbilityInfo::CreateStartAbilityInfo(const Want &want, int32_t userId,
|
||||
int32_t appIndex)
|
||||
{
|
||||
@@ -214,7 +176,7 @@ std::shared_ptr<StartAbilityInfo> StartAbilityInfo::CreateStartAbilityInfo(const
|
||||
}
|
||||
request->extensionProcessMode = extensionInfo.extensionProcessMode;
|
||||
// For compatibility translates to AbilityInfo
|
||||
InitAbilityInfoFromExtension(extensionInfo, request->abilityInfo);
|
||||
AbilityRuntime::StartupUtil::InitAbilityInfoFromExtension(extensionInfo, request->abilityInfo);
|
||||
}
|
||||
return request;
|
||||
}
|
||||
@@ -254,7 +216,7 @@ std::shared_ptr<StartAbilityInfo> StartAbilityInfo::CreateStartExtensionInfo(con
|
||||
}
|
||||
abilityInfo->extensionProcessMode = extensionInfo.extensionProcessMode;
|
||||
// For compatibility translates to AbilityInfo
|
||||
InitAbilityInfoFromExtension(extensionInfo, abilityInfo->abilityInfo);
|
||||
AbilityRuntime::StartupUtil::InitAbilityInfoFromExtension(extensionInfo, abilityInfo->abilityInfo);
|
||||
|
||||
return abilityInfo;
|
||||
}
|
||||
@@ -277,7 +239,7 @@ void StartAbilityInfo::FindExtensionInfo(const Want &want, int32_t flags, int32_
|
||||
if (AbilityRuntime::StartupUtil::IsSupportAppClone(extensionInfo.type)) {
|
||||
abilityInfo->extensionProcessMode = extensionInfo.extensionProcessMode;
|
||||
// For compatibility translates to AbilityInfo
|
||||
InitAbilityInfoFromExtension(extensionInfo, abilityInfo->abilityInfo);
|
||||
AbilityRuntime::StartupUtil::InitAbilityInfoFromExtension(extensionInfo, abilityInfo->abilityInfo);
|
||||
} else {
|
||||
abilityInfo->status = ERR_APP_CLONE_INDEX_INVALID;
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user