!9663 回退 'Pull Request !9579 : AppStateData添加应用分身index信息'

Merge pull request !9663 from openharmony_ci/revert-merge-9579-master
This commit is contained in:
openharmony_ci 2024-07-30 09:01:25 +00:00 committed by Gitee
commit a8f7d292bb
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
7 changed files with 15 additions and 21 deletions

View File

@ -60,7 +60,6 @@ struct AppStateData : public Parcelable {
int32_t pid = -1;
int32_t uid = 0;
int32_t state = 0;
int32_t appIndex = 0;
uint32_t accessTokenId = 0;
bool isFocused = false;
ExtensionAbilityType extensionType = ExtensionAbilityType::UNSPECIFIED;

View File

@ -23,10 +23,10 @@ namespace AppExecFwk {
bool AppStateData::Marshalling(Parcel &parcel) const
{
return (parcel.WriteString(bundleName) && parcel.WriteInt32(uid) && parcel.WriteInt32(state)
&& parcel.WriteInt32(pid) && parcel.WriteInt32(appIndex) && 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(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));
}
bool AppStateData::ReadFromParcel(Parcel &parcel)
@ -35,7 +35,6 @@ bool AppStateData::ReadFromParcel(Parcel &parcel)
uid = parcel.ReadInt32();
state = parcel.ReadInt32();
pid = parcel.ReadInt32();
appIndex = parcel.ReadInt32();
accessTokenId = parcel.ReadUint32();
isFocused = parcel.ReadBool();
extensionType = static_cast<ExtensionAbilityType>(parcel.ReadInt32());

View File

@ -272,7 +272,7 @@ public:
int32_t NotifyHotReloadPage(const std::string &bundleName, const sptr<IQuickFixCallback> &callback);
int32_t NotifyUnLoadRepairPatch(const std::string &bundleName, const sptr<IQuickFixCallback> &callback);
bool IsApplicationFirstForeground(const AppRunningRecord &foregroundingRecord);
bool IsApplicationBackground(const AppRunningRecord &backgroundingRecord);
bool IsApplicationBackground(const std::string &bundleName);
bool IsApplicationFirstFocused(const AppRunningRecord &foregroundingRecord);
bool IsApplicationUnfocused(const std::string &bundleName);
#ifdef SUPPORT_SCREEN

View File

@ -1030,7 +1030,7 @@ void AppMgrServiceInner::ApplicationBackgrounded(const int32_t recordId)
appRecord->SetState(ApplicationState::APP_STATE_BACKGROUND);
bool needNotifyApp = !AAFwk::UIExtensionUtils::IsUIExtension(appRecord->GetExtensionType())
&& !AAFwk::UIExtensionUtils::IsWindowExtension(appRecord->GetExtensionType())
&& appRunningManager_->IsApplicationBackground(*appRecord);
&& appRunningManager_->IsApplicationBackground(appRecord->GetBundleName());
OnAppStateChanged(appRecord, ApplicationState::APP_STATE_BACKGROUND, needNotifyApp, false);
DelayedSingleton<AppStateObserverManager>::GetInstance()->OnProcessStateChanged(appRecord);
} else {

View File

@ -761,7 +761,6 @@ void AppRunningManager::GetForegroundApplications(std::vector<AppStateData> &lis
appData.accessTokenId = appInfo ? appInfo->accessTokenId : 0;
appData.extensionType = appRecord->GetExtensionType();
appData.isFocused = appRecord->GetFocusFlag();
appData.appIndex = appRecord->GetAppIndex();
list.push_back(appData);
TAG_LOGD(AAFwkTag::APPMGR, "bundleName:%{public}s", appData.bundleName.c_str());
}
@ -1114,8 +1113,7 @@ bool AppRunningManager::IsApplicationFirstForeground(const AppRunningRecord &for
const auto &appRecord = item.second;
if (appRecord == nullptr || appRecord->GetBundleName() != foregroundingRecord.GetBundleName()
|| AAFwk::UIExtensionUtils::IsUIExtension(appRecord->GetExtensionType())
|| AAFwk::UIExtensionUtils::IsWindowExtension(appRecord->GetExtensionType())
|| appRecord->GetAppIndex() != foregroundingRecord.GetAppIndex()) {
|| AAFwk::UIExtensionUtils::IsWindowExtension(appRecord->GetExtensionType())) {
continue;
}
auto state = appRecord->GetState();
@ -1127,7 +1125,7 @@ bool AppRunningManager::IsApplicationFirstForeground(const AppRunningRecord &for
return true;
}
bool AppRunningManager::IsApplicationBackground(const AppRunningRecord &backgroundingRecord)
bool AppRunningManager::IsApplicationBackground(const std::string &bundleName)
{
TAG_LOGD(AAFwkTag::APPMGR, "called");
std::lock_guard guard(runningRecordMapMutex_);
@ -1138,12 +1136,11 @@ bool AppRunningManager::IsApplicationBackground(const AppRunningRecord &backgrou
return false;
}
if (AAFwk::UIExtensionUtils::IsUIExtension(appRecord->GetExtensionType())
|| AAFwk::UIExtensionUtils::IsWindowExtension(appRecord->GetExtensionType())
|| appRecord->GetAppIndex() != backgroundingRecord.GetAppIndex()) {
|| AAFwk::UIExtensionUtils::IsWindowExtension(appRecord->GetExtensionType())) {
continue;
}
auto state = appRecord->GetState();
if (appRecord && appRecord->GetBundleName() == backgroundingRecord.GetBundleName() &&
if (appRecord && appRecord->GetBundleName() == bundleName &&
state == ApplicationState::APP_STATE_FOREGROUND) {
return false;
}

View File

@ -873,11 +873,10 @@ AppStateData AppStateObserverManager::WrapAppStateData(const std::shared_ptr<App
} else {
appStateData.callerBundleName = "";
}
appStateData.appIndex = appRecord->GetAppIndex();
TAG_LOGD(AAFwkTag::APPMGR, "Handle state change, bundle:%{public}s, state:%{public}d, pid:%{public}d,"
"uid:%{public}d, appIndex:%{public}d, isFocused:%{public}d, callerBUndleName: %{public}s",
appStateData.bundleName.c_str(), appStateData.state, appStateData.pid,
appStateData.uid, appStateData.appIndex, appStateData.isFocused, appStateData.callerBundleName.c_str());
TAG_LOGD(AAFwkTag::APPMGR, "Handle state change, bundle:%{public}s, state:%{public}d,"
"pid:%{public}d ,uid:%{public}d, isFocused:%{public}d, callerBUndleName: %{public}s",
appStateData.bundleName.c_str(), appStateData.state,
appStateData.pid, appStateData.uid, appStateData.isFocused, appStateData.callerBundleName.c_str());
return appStateData;
}

View File

@ -117,7 +117,7 @@ void DoSomethingInterestingWithMyAPIaddb(const char* data, size_t size)
std::shared_ptr<ApplicationInfo> infoAPP;
OHOS::AppExecFwk::AppRunningRecord foregroundingRecord(infoAPP, recordId, jsonStr);
manager->IsApplicationFirstForeground(foregroundingRecord);
manager->IsApplicationBackground(foregroundingRecord);
manager->IsApplicationBackground(jsonStr);
manager->IsApplicationFirstFocused(foregroundingRecord);
manager->IsApplicationUnfocused(jsonStr);
bool isAttachDebug = *data % ENABLE;