!11653 add Preload module

Merge pull request !11653 from jsy/master
This commit is contained in:
openharmony_ci 2024-11-20 03:12:01 +00:00 committed by Gitee
commit 97545916c8
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
8 changed files with 14 additions and 6 deletions

View File

@ -1874,10 +1874,6 @@ void MainThread::PreloadModule(const AppExecFwk::HapModuleInfo &entryHapModuleIn
if (isAsyncCallback) {
return;
}
if (!appMgr_ || !applicationImpl_) {
TAG_LOGE(AAFwkTag::APPKIT, "appMgr_ is nullptr");
return;
}
for (const auto &info : entryHapModuleInfo.abilityInfos) {
if (info.name == entryHapModuleInfo.mainAbility) {
ProcessMainAbility(info, runtime);

View File

@ -69,6 +69,7 @@ struct AppStateData : public Parcelable {
bool isFloatingWindowMode = false;
bool isSpecifyTokenId = false;
int32_t appIndex = 0;
bool isPreloadModule = false;
};
} // namespace AppExecFwk
} // namespace OHOS

View File

@ -68,6 +68,7 @@ struct ProcessData : public Parcelable {
std::string exitMsg = "";
int32_t childUid = -1;
bool isPreload = false;
bool isPreloadModule = false;
};
} // namespace AppExecFwk
} // namespace OHOS

View File

@ -26,7 +26,7 @@ bool AppStateData::Marshalling(Parcel &parcel) const
&& parcel.WriteInt32(pid) && parcel.WriteUint32(accessTokenId) && parcel.WriteBool(isFocused)
&& parcel.WriteInt32(static_cast<int32_t>(extensionType)) && parcel.WriteInt32Vector(renderPids)
&& parcel.WriteString(callerBundleName) && parcel.WriteBool(isSplitScreenMode)
&& parcel.WriteBool(isFloatingWindowMode) && parcel.WriteInt32(appIndex));
&& parcel.WriteBool(isFloatingWindowMode) && parcel.WriteInt32(appIndex) && parcel.WriteBool(isPreloadModule));
}
bool AppStateData::ReadFromParcel(Parcel &parcel)
@ -43,6 +43,7 @@ bool AppStateData::ReadFromParcel(Parcel &parcel)
isSplitScreenMode = parcel.ReadBool();
isFloatingWindowMode = parcel.ReadBool();
appIndex = parcel.ReadInt32();
isPreloadModule = parcel.ReadBool();
return true;
}

View File

@ -31,7 +31,7 @@ bool ProcessData::Marshalling(Parcel &parcel) const
parcel.WriteInt32(static_cast<int32_t>(processType)) && parcel.WriteInt32(static_cast<int32_t>(extensionType))
&& parcel.WriteInt32(renderUid) && parcel.WriteUint32(accessTokenId) &&
parcel.WriteBool(isTestMode) && parcel.WriteInt32(exitReason) && parcel.WriteString16(Str8ToStr16(exitMsg)) &&
parcel.WriteInt32(childUid) && parcel.WriteBool(isPreload));
parcel.WriteInt32(childUid) && parcel.WriteBool(isPreload) && parcel.WriteBool(isPreloadModule));
}
bool ProcessData::ReadFromParcel(Parcel &parcel)
@ -57,6 +57,7 @@ bool ProcessData::ReadFromParcel(Parcel &parcel)
exitMsg = Str16ToStr8(parcel.ReadString16());
childUid = parcel.ReadInt32();
isPreload = parcel.ReadBool();
isPreloadModule = parcel.ReadBool();
return true;
}

View File

@ -965,6 +965,7 @@ public:
void SetProcessCaching(bool isCaching);
bool IsCaching();
void SetNeedPreloadModule(bool isNeedPreloadModule);
bool GetNeedPreloadModule();
/**
* ScheduleForegroundRunning, Notify application to switch to foreground.

View File

@ -2575,6 +2575,11 @@ void AppRunningRecord::SetNeedPreloadModule(bool isNeedPreloadModule)
isNeedPreloadModule_ = isNeedPreloadModule;
}
bool AppRunningRecord::GetNeedPreloadModule()
{
return isNeedPreloadModule_;
}
void AppRunningRecord::SetNWebPreload(const bool isAllowedNWebPreload)
{
isAllowedNWebPreload_ = isAllowedNWebPreload;

View File

@ -612,6 +612,7 @@ void AppStateObserverManager::HandleOnAppProcessCreated(const std::shared_ptr<Ap
}
ProcessData data = WrapProcessData(appRecord);
data.isPreload = isPreload;
data.isPreloadModule = appRecord->GetNeedPreloadModule();
if (data.bundleName == XIAOYI_BUNDLE_NAME && data.extensionType == ExtensionAbilityType::SERVICE) {
TAG_LOGI(AAFwkTag::APPMGR, "change processType to NORMAL");
data.processType = ProcessType::NORMAL;
@ -1029,6 +1030,7 @@ AppStateData AppStateObserverManager::WrapAppStateData(const std::shared_ptr<App
appStateData.state = static_cast<int32_t>(state);
appStateData.uid = appRecord->GetUid();
appStateData.extensionType = appRecord->GetExtensionType();
appStateData.isPreloadModule = appRecord->GetNeedPreloadModule();
if (appRecord->GetApplicationInfo() != nullptr) {
appStateData.accessTokenId = static_cast<uint32_t>(appRecord->GetApplicationInfo()->accessTokenId);
}