格式修改

Signed-off-by: songjindian <songjindian1@huawei.com>
This commit is contained in:
songjindian
2024-07-25 18:54:10 +08:00
parent c2a6c1f863
commit 57c63f1961
26 changed files with 103 additions and 108 deletions
@@ -696,9 +696,9 @@ napi_value JsAbilityManagerInit(napi_env env, napi_value exportObj)
env, exportObj, "getForegroundUIAbilities", moduleName, JsAbilityManager::GetForegroundUIAbilities);
BindNativeFunction(env, exportObj, "on", moduleName, JsAbilityManager::On);
BindNativeFunction(env, exportObj, "off", moduleName, JsAbilityManager::Off);
BindNativeFunction(env, exportObj, "isEmbeddedOpenAllowed", moduleName, JsAbilityManager::IsEmbeddedOpenAllowed);
BindNativeFunction(
env, exportObj, "notifyDebugAssertResult", moduleName, JsAbilityManager::NotifyDebugAssertResult);
BindNativeFunction(env, exportObj, "isEmbeddedOpenAllowed", moduleName, JsAbilityManager::IsEmbeddedOpenAllowed);
BindNativeFunction(
env, exportObj, "setResidentProcessEnabled", moduleName, JsAbilityManager::SetResidentProcessEnabled);
TAG_LOGD(AAFwkTag::ABILITYMGR, "end");
@@ -38,8 +38,8 @@ napi_value CreateJSToken(napi_env env, const sptr<IRemoteObject> target)
env, "TokenClass", NAPI_AUTO_LENGTH, constructorcb, nullptr, 0, nullptr, &tokenClass);
napi_value jsToken = nullptr;
napi_new_instance(env, tokenClass, 0, nullptr, &jsToken);
auto finalizercb = [](napi_env env, void *data, void *hint) {};
napi_wrap(env, jsToken, static_cast<void *>(target.GetRefPtr()), finalizercb, nullptr, nullptr);
auto finalizecb = [](napi_env env, void *data, void *hint) {};
napi_wrap(env, jsToken, static_cast<void *>(target.GetRefPtr()), finalizecb, nullptr, nullptr);
return jsToken;
}
@@ -20,7 +20,7 @@ class AsyncTaskCallback {
this.__impl__ = object;
}
onAsyncTaskCompleted(startupName, startupResult) {
onAsyncTaskCompleted(startupName, startupResult): void {
console.log('AsyncTaskCallback onAsyncTaskCompleted called, startupName: ' + startupName);
this.__impl__.onAsyncTaskCompleted(startupName, startupResult);
}
@@ -13,19 +13,19 @@
* limitations under the License.
*/
async function concurrentFunc(startup, asyncCallback, context, startupName) {
async function concurrentFunc(startup, asyncCallback, context, startupName): void {
'use concurrent';
console.log('concurrentFunc start.');
let startupResult;
await startup.init(context).then((result: Object) => {
startupResult = result
startupResult = result;
let taskPool = requireNapi('taskpool');
taskPool.Task.sendData(asyncCallback, startupName, startupResult);
});
console.log('concurrentFunc end.');
}
function receiveResult(asyncCallback, startupName, startupResult) {
function receiveResult(asyncCallback, startupName, startupResult): void {
console.log('receiveResult called.');
asyncCallback.onAsyncTaskCompleted(startupName, startupResult);
console.log('receiveResult end.');
@@ -702,7 +702,6 @@ private:
{
TAG_LOGI(AAFwkTag::MISSION, "%{public}s is called", __FUNCTION__);
std::vector<int32_t> missionIds;
if (argc < ARGC_ONE) {
TAG_LOGE(AAFwkTag::MISSION, "OnMoveMissionsToBackground Not enough params");
ThrowTooFewParametersError(env);
@@ -726,7 +725,6 @@ private:
}
missionIds.push_back(missionId);
}
NapiAsyncTask::CompleteCallback complete =
[missionIds](napi_env env, NapiAsyncTask &task, int32_t status) {
std::vector<int32_t> resultMissionIds;
@@ -744,7 +742,6 @@ private:
CreateJsErrorByNativeErr(env, ret, PermissionConstants::PERMISSION_MANAGE_MISSION));
}
};
napi_value lastParam = (argc <= 1) ? nullptr : argv[1];
napi_value result = nullptr;
NapiAsyncTask::ScheduleHighQos("MissionManager::OnMoveMissionsToBackground",
@@ -566,6 +566,11 @@ std::string ApplicationContext::GetTempDir()
return (contextImpl_ != nullptr) ? contextImpl_->GetTempDir() : "";
}
std::string ApplicationContext::GetResourceDir()
{
return (contextImpl_ != nullptr) ? contextImpl_->GetResourceDir() : "";
}
void ApplicationContext::GetAllTempDir(std::vector<std::string> &tempPaths)
{
if (contextImpl_ == nullptr) {
@@ -575,11 +580,6 @@ void ApplicationContext::GetAllTempDir(std::vector<std::string> &tempPaths)
contextImpl_->GetAllTempDir(tempPaths);
}
std::string ApplicationContext::GetResourceDir()
{
return (contextImpl_ != nullptr) ? contextImpl_->GetResourceDir() : "";
}
std::string ApplicationContext::GetFilesDir()
{
return (contextImpl_ != nullptr) ? contextImpl_->GetFilesDir() : "";
@@ -268,6 +268,20 @@ std::string ContextImpl::GetTempDir()
return dir;
}
std::string ContextImpl::GetResourceDir()
{
std::shared_ptr<AppExecFwk::HapModuleInfo> hapModuleInfoPtr = GetHapModuleInfo();
if (hapModuleInfoPtr == nullptr || hapModuleInfoPtr->moduleName.empty()) {
return "";
}
std::string dir = std::string(LOCAL_CODE_PATH) + CONTEXT_FILE_SEPARATOR +
hapModuleInfoPtr->moduleName + CONTEXT_RESOURCE_END;
if (OHOS::FileExists(dir)) {
return dir;
}
return "";
}
void ContextImpl::GetAllTempDir(std::vector<std::string> &tempPaths)
{
// Application temp dir
@@ -299,20 +313,6 @@ void ContextImpl::GetAllTempDir(std::vector<std::string> &tempPaths)
}
}
std::string ContextImpl::GetResourceDir()
{
std::shared_ptr<AppExecFwk::HapModuleInfo> hapModuleInfoPtr = GetHapModuleInfo();
if (hapModuleInfoPtr == nullptr || hapModuleInfoPtr->moduleName.empty()) {
return "";
}
std::string dir = std::string(LOCAL_CODE_PATH) + CONTEXT_FILE_SEPARATOR +
hapModuleInfoPtr->moduleName + CONTEXT_RESOURCE_END;
if (OHOS::FileExists(dir)) {
return dir;
}
return "";
}
std::string ContextImpl::GetFilesDir()
{
std::string dir = GetBaseDir() + CONTEXT_FILES;
@@ -246,6 +246,15 @@ AppExecFwk::AbilityType ServiceExtensionContext::GetAbilityInfoType() const
return info->type;
}
ErrCode ServiceExtensionContext::AddFreeInstallObserver(const sptr<AbilityRuntime::IFreeInstallObserver> &observer)
{
ErrCode ret = AAFwk::AbilityManagerClient::GetInstance()->AddFreeInstallObserver(token_, observer);
if (ret != ERR_OK) {
TAG_LOGE(AAFwkTag::APPKIT, "AddFreeInstallObserver error, ret: %{public}d", ret);
}
return ret;
}
ErrCode ServiceExtensionContext::PreStartMission(const std::string& bundleName, const std::string& moduleName,
const std::string& abilityName, const std::string& startTime)
{
@@ -258,14 +267,5 @@ ErrCode ServiceExtensionContext::PreStartMission(const std::string& bundleName,
TAG_LOGI(AAFwkTag::APPKIT, "End.");
return err;
}
ErrCode ServiceExtensionContext::AddFreeInstallObserver(const sptr<AbilityRuntime::IFreeInstallObserver> &observer)
{
ErrCode ret = AAFwk::AbilityManagerClient::GetInstance()->AddFreeInstallObserver(token_, observer);
if (ret != ERR_OK) {
TAG_LOGE(AAFwkTag::APPKIT, "AddFreeInstallObserver error, ret: %{public}d", ret);
}
return ret;
}
} // namespace AbilityRuntime
} // namespace OHOS
@@ -128,7 +128,7 @@ void AppfreezeInner::SendProcessKillEvent(const std::string& killReason)
std::string processName = applicationInfo->process;
int result = HiSysEventWrite(HiviewDFX::HiSysEvent::Domain::FRAMEWORK, "PROCESS_KILL",
HiviewDFX::HiSysEvent::EventType::FAULT, EVENT_PID, pid,
EVENT_PROCESS_NAME, applicationInfo->process, EVENT_MESSAGE, killReason);
EVENT_PROCESS_NAME, processName, EVENT_MESSAGE, killReason);
TAG_LOGI(AAFwkTag::APPDFR, "hisysevent write result=%{public}d, send event [FRAMEWORK,PROCESS_KILL],"
" pid=%{public}d, processName=%{public}s, msg=%{public}s", result, pid, processName.c_str(),
killReason.c_str());
@@ -41,7 +41,6 @@ class AbilityManagerClient {
public:
virtual ~AbilityManagerClient();
static std::shared_ptr<AbilityManagerClient> GetInstance();
void RemoveDeathRecipient();
/**
@@ -1407,6 +1406,13 @@ public:
int32_t UpdateSessionInfoBySCB(std::list<SessionInfo> &sessionInfos, int32_t userId,
std::vector<int32_t> &sessionIds);
/**
* @brief Restart app self.
* @param want The ability type must be UIAbility.
* @return Returns ERR_OK on success, others on failure.
*/
int32_t RestartApp(const AAFwk::Want &want);
/**
* @brief Get host info of root caller.
*
@@ -1429,13 +1435,6 @@ public:
ErrCode GetUIExtensionSessionInfo(const sptr<IRemoteObject> token, UIExtensionSessionInfo &uiExtensionSessionInfo,
int32_t userId = DEFAULT_INVAL_VALUE);
/**
* @brief Restart app self.
* @param want The ability type must be UIAbility.
* @return Returns ERR_OK on success, others on failure.
*/
int32_t RestartApp(const AAFwk::Want &want);
/**
* Pop-up launch of full-screen atomic service.
*
@@ -462,7 +462,7 @@ enum {
* Native error(2097240) for memory size state unchanged.
*/
ERR_NATIVE_MEMORY_SIZE_STATE_UNCHANGED,
/**
* Native error(2097241) for target bundle not exist.
*/
@@ -1505,6 +1505,16 @@ public:
return 0;
}
/**
* @brief Restart app self.
* @param want The ability type must be UIAbility.
* @return Returns ERR_OK on success, others on failure.
*/
virtual int32_t RestartApp(const AAFwk::Want &want)
{
return 0;
}
/**
* @brief Get host info of root caller.
*
@@ -1533,16 +1543,6 @@ public:
return 0;
}
/**
* @brief Restart app self.
* @param want The ability type must be UIAbility.
* @return Returns ERR_OK on success, others on failure.
*/
virtual int32_t RestartApp(const AAFwk::Want &want)
{
return 0;
}
/**
* Open link of ability and atomic service.
*
@@ -377,7 +377,7 @@ enum class AbilityManagerInterfaceCode {
// request modal UIExtension by want
REQUESET_MODAL_UIEXTENSION = 1056,
// get root host info of uiextesnion
// get root host info of uiextension
GET_UI_EXTENSION_ROOT_HOST_INFO = 1057,
// change current ability visibility
@@ -384,8 +384,8 @@ public:
KILL_PROCESSES_BY_PIDS,
ATTACH_PID_TO_PARENT,
IS_MEMORY_SIZE_SUFFICIENT,
SET_KEEP_ALIVE_ENABLE_STATE,
NOTIFY_APP_MGR_RECORD_EXIT_REASON,
SET_KEEP_ALIVE_ENABLE_STATE,
ATTACHED_TO_STATUS_BAR,
BLOCK_PROCESS_CACHE_BY_PIDS,
IS_KILLED_FOR_UPGRADE_WEB,
@@ -682,13 +682,6 @@ public:
*/
int32_t UnregisterAppRunningStatusListener(const sptr<IRemoteObject> &listener);
/**
* Whether the current application process is the last surviving process.
*
* @return Returns true is final application process, others return false.
*/
bool IsFinalAppProcess();
/**
* To clear the process by ability token.
*
@@ -696,6 +689,13 @@ public:
*/
void ClearProcessByToken(sptr<IRemoteObject> token) const;
/**
* Whether the current application process is the last surviving process.
*
* @return Returns true is final application process, others return false.
*/
bool IsFinalAppProcess();
int32_t RegisterRenderStateObserver(const sptr<IRenderStateObserver> &observer);
int32_t UnregisterRenderStateObserver(const sptr<IRenderStateObserver> &observer);
@@ -607,8 +607,6 @@ public:
*/
virtual int32_t NotifyMemorySizeStateChanged(bool isMemorySizeSufficent) override;
int32_t SetSupportedProcessCacheSelf(bool isSupport) override;
/**
* Set application assertion pause state.
*
@@ -616,15 +614,7 @@ public:
*/
void SetAppAssertionPauseState(bool flag) override;
/**
* Start native child process, callde by ChildProcessManager.
* @param libName lib file name to be load in child process
* @param childProcessCount current started child process count
* @param callback callback for notify start result
* @return Returns ERR_OK on success, others on failure.
*/
int32_t StartNativeChildProcess(const std::string &libName, int32_t childProcessCount,
const sptr<IRemoteObject> &callback) override;
int32_t SetSupportedProcessCacheSelf(bool isSupport) override;
virtual void SaveBrowserChannel(sptr<IRemoteObject> browser) override;
@@ -636,6 +626,16 @@ public:
*/
int32_t CheckCallingIsUserTestMode(const pid_t pid, bool &isUserTest) override;
/**
* Start native child process, callde by ChildProcessManager.
* @param libName lib file name to be load in child process
* @param childProcessCount current started child process count
* @param callback callback for notify start result
* @return Returns ERR_OK on success, others on failure.
*/
int32_t StartNativeChildProcess(const std::string &libName, int32_t childProcessCount,
const sptr<IRemoteObject> &callback) override;
virtual int32_t NotifyProcessDependedOnWeb() override;
virtual void KillProcessDependedOnWeb() override;
@@ -128,8 +128,8 @@ private:
int32_t HandleGetChildProcessInfoForSelf(MessageParcel &data, MessageParcel &reply);
int32_t HandleAttachChildProcess(MessageParcel &data, MessageParcel &reply);
int32_t HandleExitChildProcessSafely(MessageParcel &data, MessageParcel &reply);
int32_t HandleIsFinalAppProcess(MessageParcel &data, MessageParcel &reply);
int32_t HandleClearUpApplicationDataBySelf(MessageParcel &data, MessageParcel &reply);
int32_t HandleIsFinalAppProcess(MessageParcel &data, MessageParcel &reply);
int32_t HandleRegisterRenderStateObserver(MessageParcel &data, MessageParcel &reply);
int32_t HandleUnregisterRenderStateObserver(MessageParcel &data, MessageParcel &reply);
int32_t HandleUpdateRenderState(MessageParcel &data, MessageParcel &reply);
@@ -138,11 +138,11 @@ private:
int32_t HandleGetAllUIExtensionRootHostPid(MessageParcel &data, MessageParcel &reply);
int32_t HandleGetAllUIExtensionProviderPid(MessageParcel &data, MessageParcel &reply);
int32_t HandleNotifyMemorySizeStateChanged(MessageParcel &data, MessageParcel &reply);
int32_t HandleSetSupportedProcessCacheSelf(MessageParcel &data, MessageParcel &reply);
int32_t HandleSetAppAssertionPauseState(MessageParcel &data, MessageParcel &reply);
int32_t HandleStartNativeChildProcess(MessageParcel &data, MessageParcel &reply);
int32_t HandleSetSupportedProcessCacheSelf(MessageParcel &data, MessageParcel &reply);
int32_t HandleSaveBrowserChannel(MessageParcel &data, MessageParcel &reply);
int32_t HandleCheckCallingIsUserTestMode(MessageParcel &data, MessageParcel &reply);
int32_t HandleStartNativeChildProcess(MessageParcel &data, MessageParcel &reply);
int32_t HandleNotifyProcessDependedOnWeb(MessageParcel &data, MessageParcel &reply);
int32_t HandleKillProcessDependedOnWeb(MessageParcel &data, MessageParcel &reply);
int32_t HandleRestartResidentProcessDependedOnWeb(MessageParcel &data, MessageParcel &reply);
@@ -28,7 +28,6 @@ AppSchedulerHost::AppSchedulerHost()
InitMemberFuncMap();
}
void AppSchedulerHost::InitMemberFuncMap() {}
AppSchedulerHost::~AppSchedulerHost()
@@ -480,6 +479,13 @@ int32_t AppSchedulerHost::HandleScheduleDumpIpcStat(MessageParcel &data, Message
return NO_ERROR;
}
int32_t AppSchedulerHost::HandleScheduleCacheProcess(MessageParcel &data, MessageParcel &reply)
{
HITRACE_METER(HITRACE_TAG_APP);
ScheduleCacheProcess();
return NO_ERROR;
}
int32_t AppSchedulerHost::HandleScheduleDumpFfrt(MessageParcel &data, MessageParcel &reply)
{
HITRACE_METER(HITRACE_TAG_APP);
@@ -491,12 +497,5 @@ 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
@@ -28,7 +28,7 @@ namespace {
#ifdef SUPPORT_GRAPHICS
constexpr const char* WANT_PARAMS_VIEW_DATA_KEY = "ohos.ability.params.viewData";
constexpr const char* WANT_PARAMS_AUTO_FILL_CMD_KEY = "ohos.ability.params.autoFillCmd";
constexpr const char* WANT_PARAMS_FILL_CONTENT = "ohos.ability.params.fillContent";
constexpr const char* WANT_PARAMS_FILL_CONTENT = "ohos.ability.params.fillContent";
constexpr const char* WANT_PARAMS_CUSTOM_DATA_KEY = "ohos.ability.params.customData";
constexpr const char* WANT_PARAMS_AUTO_FILL_EVENT_KEY = "ability.want.params.AutoFillEvent";
constexpr const char* WANT_PARAMS_UPDATE_POPUP_WIDTH = "ohos.ability.params.popupWidth";
@@ -222,9 +222,10 @@ public:
ErrCode ChangeAbilityVisibility(bool isShow) override;
ErrCode OpenLink(const AAFwk::Want& want, int requestCode) override;
ErrCode AddFreeInstallObserver(const sptr<AbilityRuntime::IFreeInstallObserver> &observer) override;
ErrCode OpenLink(const AAFwk::Want& want, int requestCode) override;
ErrCode OpenAtomicService(AAFwk::Want& want, const AAFwk::StartOptions &options, int requestCode,
RuntimeTask &&task) override;
@@ -256,7 +256,7 @@ public:
virtual void OnInsightIntentExecuteDone(const sptr<AAFwk::SessionInfo> &sessionInfo,
const AppExecFwk::InsightIntentExecuteResult &result);
virtual bool HandleInsightIntent(const AAFwk::Want &want);
virtual bool OnInsightIntentExecuteDone(uint64_t intentId, const AppExecFwk::InsightIntentExecuteResult &result);
@@ -117,10 +117,10 @@ protected:
napi_env env, NapiCallbackInfo& info, std::shared_ptr<int> &innerErrorCode);
void StartAbilityForResultRuntimeTask(napi_env env, AAFwk::Want &want,
std::shared_ptr<NapiAsyncTask> asyncTask, size_t& unwrapArgc, AAFwk::StartOptions startOptions);
void SetCallbackForTerminateWithResult(int32_t resultCode, AAFwk::Want& want,
NapiAsyncTask::CompleteCallback& complete);
bool CheckStartAbilityByTypeParam(napi_env env, NapiCallbackInfo& info, std::string& type,
AAFwk::WantParams& wantParam);
void SetCallbackForTerminateWithResult(int32_t resultCode, AAFwk::Want& want,
NapiAsyncTask::CompleteCallback& complete);
private:
sptr<AAFwk::SessionInfo> sessionInfo_;
@@ -269,8 +269,6 @@ public:
*/
void ScheduleProcessSecurityExit() override;
void ScheduleClearPageStack() override;
void ScheduleAcceptWant(const AAFwk::Want &want, const std::string &moduleName) override;
void ScheduleNewProcessRequest(const AAFwk::Want &want, const std::string &moduleName) override;
@@ -341,6 +339,7 @@ public:
*/
int32_t ScheduleDumpIpcStat(std::string& result) override;
void ScheduleClearPageStack() override;
/**
* ScheduleDumpFfrt, call ScheduleDumpFfrt(std::string& result) through proxy project,
* Start querying the application's ffrt usage.
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* 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
@@ -307,12 +307,6 @@ void JsEnvironment::GetHeapPrepare()
panda::DFXJSNApi::GetHeapPrepare(vm_);
}
void JsEnvironment::ReInitJsEnvImpl(std::unique_ptr<JsEnvironmentImpl> impl)
{
TAG_LOGD(AAFwkTag::JSENV, "ReInit jsenv impl.");
impl_ = std::move(impl);
}
void JsEnvironment::SetModuleLoadChecker(const std::shared_ptr<ModuleCheckerDelegate> moduleCheckerDelegate)
{
if (engine_ == nullptr) {
@@ -323,6 +317,12 @@ void JsEnvironment::SetModuleLoadChecker(const std::shared_ptr<ModuleCheckerDele
engine_->SetModuleLoadChecker(moduleCheckerDelegate);
}
void JsEnvironment::ReInitJsEnvImpl(std::unique_ptr<JsEnvironmentImpl> impl)
{
TAG_LOGD(AAFwkTag::JSENV, "ReInit jsenv impl.");
impl_ = std::move(impl);
}
void JsEnvironment::SetRequestAotCallback(const RequestAotCallback& cb)
{
if (vm_ == nullptr) {
@@ -27,9 +27,9 @@
namespace OHOS {
namespace JsEnv {
class JsEnvironmentImpl;
using DebuggerPostTask = std::function<void(std::function<void()>&&)>;
using RequestAotCallback =
std::function<int32_t(const std::string& bundleName, const std::string& moduleName, int32_t triggerMode)>;
using DebuggerPostTask = std::function<void(std::function<void()>&&)>;
class JsEnvironment final : public std::enable_shared_from_this<JsEnvironment> {
public:
JsEnvironment() {}
@@ -91,19 +91,19 @@ public:
bool LoadScript(const std::string& path, uint8_t* buffer, size_t len, bool isBundle);
DebuggerPostTask GetDebuggerPostTask();
void StartProfiler(const char* libraryPath,
uint32_t instanceId, PROFILERTYPE profiler, int32_t interval, int tid, bool isDebugApp);
DebuggerPostTask GetDebuggerPostTask();
void DestroyHeapProfiler();
void GetHeapPrepare();
void ReInitJsEnvImpl(std::unique_ptr<JsEnvironmentImpl> impl);
void SetModuleLoadChecker(const std::shared_ptr<ModuleCheckerDelegate> moduleCheckerDelegate);
void ReInitJsEnvImpl(std::unique_ptr<JsEnvironmentImpl> impl);
void SetRequestAotCallback(const RequestAotCallback& cb);
void SetDeviceDisconnectCallback(const std::function<bool()> &cb);