mirror of
https://gitee.com/openharmony/ability_ability_runtime
synced 2024-11-27 09:21:28 +00:00
app startup process quarantine
Signed-off-by: liuzongze <liuzongze@huawei.com> Change-Id: I467bb8dc938bd098ac8d025428344c0e92567452
This commit is contained in:
parent
7fa45ddf39
commit
c00bc5a381
@ -201,7 +201,7 @@ void UIAbility::OnStop()
|
||||
(void)Rosen::WindowManager::GetInstance().UnregisterDisplayInfoChangedListener(token_, abilityDisplayListener_);
|
||||
auto &&window = GetWindow();
|
||||
if (window != nullptr) {
|
||||
TAG_LOGD(AAFwkTag::UIABILITY, "UnregisterDisplayMoveListener");
|
||||
TAG_LOGD(AAFwkTag::UIABILITY, "UnregisterDisplayMoveListener");
|
||||
window->UnregisterDisplayMoveListener(abilityDisplayMoveListener_);
|
||||
}
|
||||
// Call JS Func(onWindowStageDestroy) and Release the scene.
|
||||
|
@ -635,6 +635,7 @@ std::shared_ptr<AbilityRuntime::Context> OHOSApplication::AddAbilityStage(
|
||||
auto application = std::static_pointer_cast<OHOSApplication>(shared_from_this());
|
||||
std::weak_ptr<OHOSApplication> weak = application;
|
||||
abilityStage->Init(stageContext, weak);
|
||||
|
||||
auto autoStartupCallback = CreateAutoStartupCallback(abilityStage, abilityRecord, callback);
|
||||
if (autoStartupCallback != nullptr) {
|
||||
abilityStage->RunAutoStartupTask(autoStartupCallback, isAsyncCallback, stageContext);
|
||||
@ -669,7 +670,7 @@ const std::function<void()> OHOSApplication::CreateAutoStartupCallback(
|
||||
const std::function<void(const std::shared_ptr<AbilityRuntime::Context>&)>& callback)
|
||||
{
|
||||
const std::shared_ptr<AbilityInfo> &abilityInfo = abilityRecord->GetAbilityInfo();
|
||||
if (!IsBackupExtension(abilityInfo)) {
|
||||
if (!IsMainProcess(abilityInfo->bundleName, abilityInfo->applicationInfo.process)) {
|
||||
return nullptr;
|
||||
}
|
||||
std::string moduleName = abilityInfo->moduleName;
|
||||
@ -1068,5 +1069,25 @@ bool OHOSApplication::IsBackupExtension(const std::shared_ptr<AbilityInfo> &abil
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OHOSApplication::IsMainProcess(const std::string &bundleName, const std::string &process)
|
||||
{
|
||||
auto processInfo = GetProcessInfo();
|
||||
if (processInfo == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "null processInfo");
|
||||
return false;
|
||||
}
|
||||
ProcessType processType = processInfo->GetProcessType();
|
||||
if (processType == ProcessType::NORMAL) {
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string processName = processInfo->GetProcessName();
|
||||
if (processName == bundleName || processName == process) {
|
||||
return true;
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "not main process");
|
||||
return false;
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
#include "nocopyable.h"
|
||||
#include "parcel.h"
|
||||
#include "app_mgr_constants.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
@ -72,9 +73,24 @@ public:
|
||||
*/
|
||||
static ProcessInfo *Unmarshalling(Parcel &parcel);
|
||||
|
||||
/**
|
||||
* @brief Set process type
|
||||
*
|
||||
* @param ProcessType process type.
|
||||
*/
|
||||
void SetProcessType(const ProcessType &processType);
|
||||
|
||||
/**
|
||||
* @brief Obtains type of the process.
|
||||
*
|
||||
* @return Returns process type.
|
||||
*/
|
||||
ProcessType GetProcessType() const;
|
||||
|
||||
private:
|
||||
std::string processName_;
|
||||
pid_t pid_ = 0;
|
||||
ProcessType processType_ = ProcessType::NORMAL;
|
||||
};
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
@ -61,5 +61,15 @@ bool ProcessInfo::Marshalling(Parcel &parcel) const
|
||||
{
|
||||
return (parcel.WriteString16(Str8ToStr16(processName_)) && parcel.WriteInt32(pid_));
|
||||
}
|
||||
|
||||
void ProcessInfo::SetProcessType(const ProcessType &processType)
|
||||
{
|
||||
processType_ = processType;
|
||||
}
|
||||
|
||||
ProcessType ProcessInfo::GetProcessType() const
|
||||
{
|
||||
return processType_;
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
@ -329,7 +329,7 @@ private:
|
||||
const std::shared_ptr<AbilityRuntime::AbilityStage> abilityStage,
|
||||
const std::shared_ptr<AbilityLocalRecord> abilityRecord,
|
||||
const std::function<void(const std::shared_ptr<AbilityRuntime::Context>&)>& callback);
|
||||
bool IsBackupExtension(const std::shared_ptr<AbilityInfo> &abilityInfo);
|
||||
bool IsMainProcess(const std::string &bundleName, const std::string &process);
|
||||
|
||||
private:
|
||||
std::list<std::shared_ptr<AbilityLifecycleCallbacks>> abilityLifecycleCallbacks_;
|
||||
|
@ -472,6 +472,7 @@ void AppRunningRecord::LaunchApplication(const Configuration &config)
|
||||
}
|
||||
}
|
||||
ProcessInfo processInfo(processName_, GetPriorityObject()->GetPid());
|
||||
processInfo.SetProcessType(processType_);
|
||||
launchData.SetProcessInfo(processInfo);
|
||||
launchData.SetRecordId(appRecordId_);
|
||||
launchData.SetUId(mainUid_);
|
||||
|
Loading…
Reference in New Issue
Block a user