mirror of
https://gitee.com/openharmony/ability_ability_runtime
synced 2024-12-04 05:22:25 +00:00
commit
537a6b8adf
@ -39,13 +39,11 @@ namespace {
|
||||
constexpr int32_t INDEX_ZERO = 0;
|
||||
constexpr int32_t INDEX_ONE = 1;
|
||||
constexpr int32_t INDEX_TWO = 2;
|
||||
constexpr int32_t INDEX_THREE = 3;
|
||||
constexpr int32_t ERROR_CODE_ONE = 1;
|
||||
constexpr size_t ARGC_ZERO = 0;
|
||||
constexpr size_t ARGC_ONE = 1;
|
||||
constexpr size_t ARGC_TWO = 2;
|
||||
constexpr size_t ARGC_THREE = 3;
|
||||
constexpr size_t ARGC_FOUR = 4;
|
||||
constexpr int32_t ERR_NOT_OK = -1;
|
||||
|
||||
class JsAppManager final {
|
||||
@ -317,11 +315,9 @@ private:
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "called");
|
||||
int32_t errCode = 0;
|
||||
std::string bundleName;
|
||||
bool clearPageStack = false;
|
||||
bool hasClearPageStack = false;
|
||||
int32_t appIndex = 0;
|
||||
// only support 1 or 2 or 3 params
|
||||
if (argc != ARGC_ONE && argc != ARGC_TWO && argc != ARGC_THREE) {
|
||||
|
||||
// only support 1 or 2 params
|
||||
if (argc != ARGC_ONE && argc != ARGC_TWO) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "invalid argc");
|
||||
errCode = ERR_NOT_OK;
|
||||
} else {
|
||||
@ -329,19 +325,10 @@ private:
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "convert bundleName failed");
|
||||
errCode = ERR_NOT_OK;
|
||||
}
|
||||
if (argc > ARGC_ONE && ConvertFromJsValue(env, argv[INDEX_ONE], clearPageStack)) {
|
||||
hasClearPageStack = true;
|
||||
}
|
||||
if (hasClearPageStack && argc == ARGC_THREE && !ConvertFromJsValue(env, argv[INDEX_TWO], appIndex)) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "get appIndex failed");
|
||||
errCode = ERR_NOT_OK;
|
||||
}
|
||||
}
|
||||
TAG_LOGI(AAFwkTag::APPMGR,
|
||||
"kill:%{public}s,hasClearPageStack:%{public}d,clearPageStack:%{public}d,appIndex:%{public}d",
|
||||
bundleName.c_str(), hasClearPageStack, clearPageStack, appIndex);
|
||||
|
||||
NapiAsyncTask::CompleteCallback complete =
|
||||
[bundleName, clearPageStack, abilityManager = abilityManager_, errCode](napi_env env, NapiAsyncTask& task,
|
||||
[bundleName, abilityManager = abilityManager_, errCode](napi_env env, NapiAsyncTask& task,
|
||||
int32_t status) {
|
||||
if (errCode != 0) {
|
||||
task.Reject(env, CreateJsError(env, errCode, "Invalidate params."));
|
||||
@ -352,14 +339,14 @@ private:
|
||||
task.Reject(env, CreateJsError(env, ERROR_CODE_ONE, "abilityManager nullptr"));
|
||||
return;
|
||||
}
|
||||
auto ret = abilityManager->KillProcess(bundleName, clearPageStack);
|
||||
auto ret = abilityManager->KillProcess(bundleName);
|
||||
if (ret == 0) {
|
||||
task.Resolve(env, CreateJsValue(env, ret));
|
||||
} else {
|
||||
task.Reject(env, CreateJsError(env, ret, "kill process failed."));
|
||||
}
|
||||
};
|
||||
napi_value lastParam = (argc == ARGC_TWO && !hasClearPageStack) ? argv[INDEX_ONE] : nullptr;
|
||||
napi_value lastParam = (argc == ARGC_TWO) ? argv[INDEX_ONE] : nullptr;
|
||||
napi_value result = nullptr;
|
||||
NapiAsyncTask::ScheduleHighQos("JSAppManager::OnKillProcessByBundleName",
|
||||
env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result));
|
||||
@ -419,11 +406,9 @@ private:
|
||||
int32_t errCode = 0;
|
||||
int32_t accountId = -1;
|
||||
std::string bundleName;
|
||||
bool clearPageStack = false;
|
||||
bool hasClearPageStack = false;
|
||||
int32_t appIndex = 0;
|
||||
// only support 2 or 3 or 4 params
|
||||
if (argc != ARGC_TWO && argc != ARGC_THREE && argc != ARGC_FOUR) {
|
||||
|
||||
// only support 2 or 3 params
|
||||
if (argc != ARGC_TWO && argc != ARGC_THREE) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "invalid argc");
|
||||
errCode = ERR_NOT_OK;
|
||||
} else {
|
||||
@ -435,25 +420,16 @@ private:
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "convert userId failed");
|
||||
errCode = ERR_NOT_OK;
|
||||
}
|
||||
if (argc > ARGC_TWO && ConvertFromJsValue(env, argv[INDEX_TWO], clearPageStack)) {
|
||||
hasClearPageStack = true;
|
||||
}
|
||||
if (hasClearPageStack && argc == ARGC_FOUR && !ConvertFromJsValue(env, argv[INDEX_THREE], appIndex)) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "get appIndex failed");
|
||||
errCode = ERR_NOT_OK;
|
||||
}
|
||||
}
|
||||
TAG_LOGI(AAFwkTag::APPMGR,
|
||||
"kill [%{public}s], hasClearPageStack [%{public}d], clearPageStack [%{public}d],appIndex [%{public}d]",
|
||||
bundleName.c_str(), hasClearPageStack, clearPageStack, appIndex);
|
||||
|
||||
NapiAsyncTask::CompleteCallback complete =
|
||||
[appManager = appManager_, bundleName, accountId, clearPageStack, errCode](
|
||||
[appManager = appManager_, bundleName, accountId, errCode](
|
||||
napi_env env, NapiAsyncTask &task, int32_t status) {
|
||||
if (errCode != 0) {
|
||||
task.Reject(env, CreateJsError(env, errCode, "Invalidate params."));
|
||||
return;
|
||||
}
|
||||
auto ret = appManager->GetAmsMgr()->KillProcessWithAccount(bundleName, accountId, clearPageStack);
|
||||
auto ret = appManager->GetAmsMgr()->KillProcessWithAccount(bundleName, accountId);
|
||||
if (ret == 0) {
|
||||
task.Resolve(env, CreateJsUndefined(env));
|
||||
} else {
|
||||
|
@ -587,7 +587,7 @@ public:
|
||||
* @param clearPageStack.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
ErrCode KillProcess(const std::string &bundleName, const bool clearPageStack = true);
|
||||
ErrCode KillProcess(const std::string &bundleName, const bool clearpagestack = false);
|
||||
|
||||
#ifdef ABILITY_COMMAND_FOR_TEST
|
||||
/**
|
||||
|
@ -439,7 +439,7 @@ public:
|
||||
*/
|
||||
virtual int TerminateAbility(
|
||||
const sptr<IRemoteObject> &token, int resultCode, const Want *resultWant = nullptr) = 0;
|
||||
|
||||
|
||||
/**
|
||||
* BackToCallerAbilityWithResult, return to the caller ability.
|
||||
*
|
||||
@ -733,7 +733,7 @@ public:
|
||||
* @param bundleName.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int KillProcess(const std::string &bundleName, const bool clearPageStack = true) = 0;
|
||||
virtual int KillProcess(const std::string &bundleName, const bool clearpagestack = false) = 0;
|
||||
|
||||
#ifdef ABILITY_COMMAND_FOR_TEST
|
||||
/**
|
||||
|
@ -127,7 +127,7 @@ public:
|
||||
* @return ERR_OK, return back success, others fail.
|
||||
*/
|
||||
virtual int KillProcessWithAccount(
|
||||
const std::string &bundleName, const int accountId, const bool clearPageStack = true) = 0;
|
||||
const std::string &bundleName, const int accountId, const bool clearpagestack = false) = 0;
|
||||
|
||||
/**
|
||||
* UpdateApplicationInfoInstalled, call UpdateApplicationInfoInstalled() through proxy object,
|
||||
@ -145,7 +145,7 @@ public:
|
||||
* @param bundleName, bundle name in Application record.
|
||||
* @return ERR_OK, return back success, others fail.
|
||||
*/
|
||||
virtual int KillApplication(const std::string &bundleName, const bool clearPageStack = true) = 0;
|
||||
virtual int KillApplication(const std::string &bundleName, const bool clearpagestack = false) = 0;
|
||||
|
||||
/**
|
||||
* ForceKillApplication, call ForceKillApplication() through proxy object, force kill the application.
|
||||
@ -180,7 +180,7 @@ public:
|
||||
*
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int KillApplicationSelf(const bool clearPageStack = true)
|
||||
virtual int KillApplicationSelf(const bool clearpagestack = false)
|
||||
{
|
||||
return ERR_OK;
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ public:
|
||||
* @return ERR_OK, return back success, others fail.
|
||||
*/
|
||||
virtual int32_t KillProcessWithAccount(
|
||||
const std::string &bundleName, const int accountId, const bool clearPageStack = true) override;
|
||||
const std::string &bundleName, const int accountId, const bool clearpagestack = false) override;
|
||||
|
||||
/**
|
||||
* UpdateApplicationInfoInstalled, call UpdateApplicationInfoInstalled() through proxy object,
|
||||
@ -138,7 +138,7 @@ public:
|
||||
* @param bundleName, bundle name in Application record.
|
||||
* @return ERR_OK, return back success, others fail.
|
||||
*/
|
||||
virtual int32_t KillApplication(const std::string &bundleName, const bool clearPageStack = true) override;
|
||||
virtual int32_t KillApplication(const std::string &bundleName, const bool clearpagestack = false) override;
|
||||
|
||||
/**
|
||||
* ForceKillApplication, call ForceKillApplication() through proxy object, force kill the application.
|
||||
@ -169,7 +169,7 @@ public:
|
||||
*/
|
||||
virtual int32_t KillApplicationByUid(const std::string &bundleName, const int uid) override;
|
||||
|
||||
virtual int KillApplicationSelf(const bool clearPageStack = true) override;
|
||||
virtual int KillApplicationSelf(const bool clearpagestack = false) override;
|
||||
|
||||
virtual int GetApplicationInfoByProcessID(const int pid, AppExecFwk::ApplicationInfo &application,
|
||||
bool &debug) override;
|
||||
|
@ -160,7 +160,7 @@ public:
|
||||
* @param bundleName, bundle name in Application record.
|
||||
* @return ERR_OK, return back success, others fail.
|
||||
*/
|
||||
virtual AppMgrResultCode KillApplication(const std::string &bundleName, const bool clearPageStack = true);
|
||||
virtual AppMgrResultCode KillApplication(const std::string &bundleName, const bool clearpagestack = false);
|
||||
|
||||
/**
|
||||
* ForceKillApplication, call ForceKillApplication() through proxy object, force kill the application.
|
||||
@ -196,7 +196,7 @@ public:
|
||||
*
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual AppMgrResultCode KillApplicationSelf(const bool clearPageStack = true);
|
||||
virtual AppMgrResultCode KillApplicationSelf(const bool clearpagestack = false);
|
||||
|
||||
/**
|
||||
* ClearUpApplicationData, call ClearUpApplicationData() through proxy project,
|
||||
|
@ -120,7 +120,7 @@ public:
|
||||
void AppHasDarkRes(bool &darkRes);
|
||||
std::string GetBaseDir() const override;
|
||||
Global::Resource::DeviceType GetDeviceType() const override;
|
||||
void KillProcessBySelf(const bool clearPageStack = true);
|
||||
void KillProcessBySelf(const bool clearpagestack = false);
|
||||
int32_t GetProcessRunningInformation(AppExecFwk::RunningProcessInfo &info);
|
||||
int32_t RestartApp(const AAFwk::Want& want);
|
||||
|
||||
|
@ -329,7 +329,7 @@ public:
|
||||
*
|
||||
* @return error code
|
||||
*/
|
||||
void KillProcessBySelf(const bool clearPageStack = true);
|
||||
void KillProcessBySelf(const bool clearpagestack = false);
|
||||
|
||||
/**
|
||||
* @brief Get running informationfor cuirrent process
|
||||
|
@ -62,7 +62,7 @@ public:
|
||||
* @param bundleName.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
int KillProcessesByBundleName(const std::string &bundleName, const bool clearPageStack = true);
|
||||
int KillProcessesByBundleName(const std::string &bundleName, const bool clearpagestack = false);
|
||||
};
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
@ -314,7 +314,7 @@ public:
|
||||
*/
|
||||
virtual int TerminateAbility(
|
||||
const sptr<IRemoteObject> &token, int resultCode, const Want *resultWant = nullptr) override;
|
||||
|
||||
|
||||
/**
|
||||
* BackToCallerAbilityWithResult, return to the caller ability.
|
||||
*
|
||||
@ -577,7 +577,7 @@ public:
|
||||
* @param bundleName.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int KillProcess(const std::string &bundleName, const bool clearPageStack = true) override;
|
||||
virtual int KillProcess(const std::string &bundleName, const bool clearpagestack = false) override;
|
||||
|
||||
#ifdef ABILITY_COMMAND_FOR_TEST
|
||||
/**
|
||||
|
@ -455,7 +455,7 @@ public:
|
||||
*/
|
||||
virtual int TerminateAbility(const sptr<IRemoteObject> &token, int resultCode = DEFAULT_INVAL_VALUE,
|
||||
const Want *resultWant = nullptr) override;
|
||||
|
||||
|
||||
/**
|
||||
* BackToCallerAbilityWithResult, return to the caller ability.
|
||||
*
|
||||
@ -826,7 +826,7 @@ public:
|
||||
* @param bundleName.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int KillProcess(const std::string &bundleName, const bool clearPageStack = true) override;
|
||||
virtual int KillProcess(const std::string &bundleName, const bool clearpagestack = false) override;
|
||||
|
||||
/**
|
||||
* Uninstall app
|
||||
|
@ -231,7 +231,7 @@ public:
|
||||
*
|
||||
* @param bundleName.
|
||||
*/
|
||||
int KillApplication(const std::string &bundleName, const bool clearPageStack = true);
|
||||
int KillApplication(const std::string &bundleName, const bool clearpagestack = false);
|
||||
|
||||
/**
|
||||
* ForceKillApplication, force kill the application.
|
||||
|
@ -133,7 +133,7 @@ public:
|
||||
* @return ERR_OK, return back success, others fail.
|
||||
*/
|
||||
virtual int32_t KillProcessWithAccount(
|
||||
const std::string &bundleName, const int accountId, const bool clearPageStack = true) override;
|
||||
const std::string &bundleName, const int accountId, const bool clearpagestack = false) override;
|
||||
|
||||
/**
|
||||
* UpdateApplicationInfoInstalled, call UpdateApplicationInfoInstalled() through proxy object,
|
||||
@ -151,7 +151,7 @@ public:
|
||||
* @param bundleName, bundle name in Application record.
|
||||
* @return ERR_OK, return back success, others fail.
|
||||
*/
|
||||
virtual int32_t KillApplication(const std::string &bundleName, const bool clearPageStack = true) override;
|
||||
virtual int32_t KillApplication(const std::string &bundleName, const bool clearpagestack = false) override;
|
||||
|
||||
/**
|
||||
* ForceKillApplication, force kill the application.
|
||||
@ -181,7 +181,7 @@ public:
|
||||
*/
|
||||
virtual int KillApplicationByUid(const std::string &bundleName, const int uid) override;
|
||||
|
||||
virtual int KillApplicationSelf(const bool clearPageStack = true) override;
|
||||
virtual int KillApplicationSelf(const bool clearpagestack = false) override;
|
||||
|
||||
int GetApplicationInfoByProcessID(const int pid, AppExecFwk::ApplicationInfo &application, bool &debug) override;
|
||||
|
||||
|
@ -258,7 +258,7 @@ public:
|
||||
*
|
||||
* @return ERR_OK, return back success, others fail.
|
||||
*/
|
||||
virtual int32_t KillApplication(const std::string &bundleName, const bool clearPageStack = true);
|
||||
virtual int32_t KillApplication(const std::string &bundleName, const bool clearpagestack = false);
|
||||
|
||||
/**
|
||||
* ForceKillApplication, force kill the application.
|
||||
@ -288,7 +288,7 @@ public:
|
||||
*/
|
||||
virtual int32_t KillApplicationByUid(const std::string &bundleName, const int uid);
|
||||
|
||||
virtual int32_t KillApplicationSelf(const bool clearPageStack = true);
|
||||
virtual int32_t KillApplicationSelf(const bool clearpagestack = false);
|
||||
|
||||
/**
|
||||
* KillApplicationByUserId, kill the application by user ID.
|
||||
@ -300,7 +300,7 @@ public:
|
||||
* @return ERR_OK, return back success, others fail.
|
||||
*/
|
||||
virtual int32_t KillApplicationByUserId(const std::string &bundleName, int32_t appCloneIndex, int userId,
|
||||
const bool clearPageStack = true);
|
||||
const bool clearpagestack = false);
|
||||
|
||||
/**
|
||||
* ClearUpApplicationData, clear the application data.
|
||||
@ -1222,7 +1222,7 @@ private:
|
||||
* @return ERR_OK, return back success, others fail.
|
||||
*/
|
||||
int32_t KillApplicationByUserIdLocked(const std::string &bundleName, int32_t appCloneIndex, int32_t userId,
|
||||
const bool clearPageStack = true);
|
||||
const bool clearpagestack = false);
|
||||
|
||||
/**
|
||||
* WaitForRemoteProcessExit, Wait for the process to exit normally.
|
||||
@ -1347,7 +1347,7 @@ private:
|
||||
bool CheckGetRunningInfoPermission() const;
|
||||
|
||||
int32_t KillApplicationByBundleName(
|
||||
const std::string &bundleName, const bool clearPageStack = true);
|
||||
const std::string &bundleName, const bool clearpagestack = false);
|
||||
|
||||
bool SendProcessStartEvent(const std::shared_ptr<AppRunningRecord> &appRecord);
|
||||
|
||||
|
@ -169,7 +169,7 @@ public:
|
||||
* @return Return true if found, otherwise return false.
|
||||
*/
|
||||
bool ProcessExitByBundleName(
|
||||
const std::string &bundleName, std::list<pid_t> &pids, const bool clearPageStack = true);
|
||||
const std::string &bundleName, std::list<pid_t> &pids, const bool clearpagestack = false);
|
||||
/**
|
||||
* Get Foreground Applications.
|
||||
*
|
||||
@ -253,7 +253,7 @@ public:
|
||||
int32_t ProcessUpdateApplicationInfoInstalled(const ApplicationInfo &appInfo);
|
||||
|
||||
bool ProcessExitByBundleNameAndUid(
|
||||
const std::string &bundleName, const int uid, std::list<pid_t> &pids, const bool clearPageStack = true);
|
||||
const std::string &bundleName, const int uid, std::list<pid_t> &pids, const bool clearpagestack = false);
|
||||
bool GetPidsByUserId(int32_t userId, std::list<pid_t> &pids);
|
||||
|
||||
void PrepareTerminate(const sptr<IRemoteObject> &token, bool clearMissionFlag = false);
|
||||
|
@ -173,7 +173,7 @@ public:
|
||||
return releaseDataAbility_;
|
||||
}
|
||||
|
||||
int KillProcess(const std::string& bundleName, const bool clearPageStack = true) override;
|
||||
int KillProcess(const std::string& bundleName, const bool clearpagestack = false) override;
|
||||
|
||||
int UninstallApp(const std::string& bundleName, int32_t uid) override;
|
||||
|
||||
|
@ -123,7 +123,7 @@ public:
|
||||
* @param bundleName, bundle name in Application record.
|
||||
* @return ERR_OK, return back success, others fail.
|
||||
*/
|
||||
virtual AppMgrResultCode KillApplication(const std::string& bundleName, const bool clearPageStack = true);
|
||||
virtual AppMgrResultCode KillApplication(const std::string& bundleName, const bool clearpagestack = false);
|
||||
|
||||
/**
|
||||
* ClearUpApplicationData, call ClearUpApplicationData() through proxy project,
|
||||
|
@ -78,7 +78,7 @@ AppMgrResultCode AppMgrClient::KillProcessesByUserId(int32_t userId)
|
||||
}
|
||||
|
||||
AppMgrResultCode AppMgrClient::KillApplication(
|
||||
const std::string& bundleName, const bool clearPageStack = true)
|
||||
const std::string& bundleName, const bool clearpagestack = false)
|
||||
{
|
||||
return AppMgrResultCode::RESULT_OK;
|
||||
}
|
||||
|
@ -418,7 +418,7 @@ HWTEST_F(AppMgrServiceModuleTest, KillApplication_001, TestSize.Level1)
|
||||
Semaphore sem(0);
|
||||
|
||||
auto mockHandler = [&testResult, testBundleName, &sem](
|
||||
const std::string& bundleName, const bool clearPageStack = true) {
|
||||
const std::string& bundleName, const bool clearpagestack = false) {
|
||||
testResult = (bundleName == testBundleName);
|
||||
sem.Post();
|
||||
return 0;
|
||||
|
@ -142,7 +142,7 @@ public:
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual int KillProcess(const std::string& bundleName, const bool clearPageStack = true) override
|
||||
virtual int KillProcess(const std::string& bundleName, const bool clearpagestack = false) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -200,7 +200,7 @@ public:
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual int KillProcess(const std::string& bundleName, const bool clearPageStack = true)
|
||||
virtual int KillProcess(const std::string& bundleName, const bool clearpagestack = false)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -210,7 +210,7 @@ public:
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual int KillProcess(const std::string& bundleName, const bool clearPageStack = true)
|
||||
virtual int KillProcess(const std::string& bundleName, const bool clearpagestack = false)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -220,7 +220,7 @@ public:
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual int KillProcess(const std::string& bundleName, const bool clearPageStack = true)
|
||||
virtual int KillProcess(const std::string& bundleName, const bool clearpagestack = false)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -193,7 +193,7 @@ public:
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual int KillProcess(const std::string& bundleName, const bool clearPageStack = true)
|
||||
virtual int KillProcess(const std::string& bundleName, const bool clearpagestack = false)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -174,7 +174,7 @@ public:
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual int KillProcess(const std::string& bundleName, const bool clearPageStack = true)
|
||||
virtual int KillProcess(const std::string& bundleName, const bool clearpagestack = false)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user