mirror of
https://github.com/openharmony/ability_ability_runtime.git
synced 2026-08-26 18:47:03 -04:00
@@ -119,6 +119,7 @@ ohos_shared_library("app_manager") {
|
||||
"src/appmgr/start_specified_ability_response_proxy.cpp",
|
||||
"src/appmgr/start_specified_ability_response_stub.cpp",
|
||||
"src/appmgr/system_memory_attr.cpp",
|
||||
"src/appmgr/process_bind_data.cpp",
|
||||
]
|
||||
|
||||
public_configs = [
|
||||
|
||||
@@ -142,6 +142,12 @@ public:
|
||||
*/
|
||||
virtual void OnAppCacheStateChanged(const AppStateData &appStateData) override;
|
||||
|
||||
/**
|
||||
* Will be called when bindingRelation change.
|
||||
*
|
||||
* @param processBindData Process bind data.
|
||||
*/
|
||||
virtual void OnProcessBindingRelationChanged(const ProcessBindData &processBindData) override;
|
||||
private:
|
||||
bool WriteInterfaceToken(MessageParcel &data);
|
||||
static inline BrokerDelegator<ApplicationStateObserverProxy> delegator_;
|
||||
|
||||
@@ -144,6 +144,12 @@ public:
|
||||
*/
|
||||
virtual void OnAppCacheStateChanged(const AppStateData &appStateData) override;
|
||||
|
||||
/**
|
||||
* Will be called when bindingRelation change.
|
||||
*
|
||||
* @param processBindData Process bind data.
|
||||
*/
|
||||
virtual void OnProcessBindingRelationChanged(const ProcessBindData &processBindData) override;
|
||||
private:
|
||||
int32_t HandleOnForegroundApplicationChanged(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
@@ -177,6 +183,8 @@ private:
|
||||
|
||||
int32_t HandleOnAppCacheStateChanged(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
int32_t HandleOnProcessBindingRelationChanged(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
static std::mutex callbackMutex_;
|
||||
|
||||
DISALLOW_COPY_AND_MOVE(ApplicationStateObserverStub);
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "app_state_data.h"
|
||||
#include "page_state_data.h"
|
||||
#include "process_data.h"
|
||||
#include "process_bind_data.h"
|
||||
#include "iremote_broker.h"
|
||||
#include "iremote_object.h"
|
||||
|
||||
@@ -143,6 +144,13 @@ public:
|
||||
*/
|
||||
virtual void OnAppCacheStateChanged(const AppStateData &appStateData) {};
|
||||
|
||||
/**
|
||||
* Will be called when bindingRelation change.
|
||||
*
|
||||
* @param processBindData Process bind data.
|
||||
*/
|
||||
virtual void OnProcessBindingRelationChanged(const ProcessBindData &processBindData) {};
|
||||
|
||||
enum class Message {
|
||||
TRANSACT_ON_FOREGROUND_APPLICATION_CHANGED = 0,
|
||||
TRANSACT_ON_ABILITY_STATE_CHANGED,
|
||||
@@ -160,6 +168,7 @@ public:
|
||||
TRANSACT_ON_APP_CACHE_STATE_CHANGED,
|
||||
TRANSACT_ON_WINDOW_SHOW,
|
||||
TRANSACT_ON_WINDOW_HIDDEN,
|
||||
TRANSACT_ON_PROCESS_BINDINGRELATION_CHANGED,
|
||||
};
|
||||
};
|
||||
} // namespace AppExecFwk
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (c) 2025 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_ABILITY_RUNTIME_PROCESS_BIND_DATA_H
|
||||
#define OHOS_ABILITY_RUNTIME_PROCESS_BIND_DATA_H
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "iremote_object.h"
|
||||
#include "parcel.h"
|
||||
#include "running_process_info.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
struct UIExtensionProcessBindInfo {
|
||||
std::string bundleName;
|
||||
int32_t pid = 0;
|
||||
int32_t uid = 0;
|
||||
bool isKeepAlive = false;
|
||||
ProcessType processType = ProcessType::NORMAL;
|
||||
ExtensionAbilityType extensionType = ExtensionAbilityType::UNSPECIFIED;
|
||||
int32_t callerPid = -1;
|
||||
int32_t callerUid = -1;
|
||||
std::string callerBundleName;
|
||||
int32_t notifyProcessBind = -1;
|
||||
};
|
||||
struct ProcessBindData : public Parcelable {
|
||||
/**
|
||||
* @brief read this Sequenceable object from a Parcel.
|
||||
*
|
||||
* @param inParcel Indicates the Parcel object into which the Sequenceable
|
||||
* object has been marshaled.
|
||||
* @return Returns true if read successed; returns false otherwise.
|
||||
*/
|
||||
bool ReadFromParcel(Parcel &parcel);
|
||||
|
||||
/**
|
||||
* @brief Marshals this Sequenceable object into a Parcel.
|
||||
*
|
||||
* @param outParcel Indicates the Parcel object to which the Sequenceable
|
||||
* object will be marshaled.
|
||||
*/
|
||||
virtual bool Marshalling(Parcel &parcel) const override;
|
||||
|
||||
/**
|
||||
* @brief Unmarshals this Sequenceable object from a Parcel.
|
||||
*
|
||||
* @param inParcel Indicates the Parcel object into which the Sequenceable
|
||||
* object has been marshaled.
|
||||
*/
|
||||
static ProcessBindData *Unmarshalling(Parcel &parcel);
|
||||
|
||||
std::string bundleName;
|
||||
int32_t pid = 0;
|
||||
int32_t uid = 0;
|
||||
bool isKeepAlive = false;
|
||||
ProcessType processType = ProcessType::NORMAL;
|
||||
ExtensionAbilityType extensionType = ExtensionAbilityType::UNSPECIFIED;
|
||||
int32_t callerPid = -1;
|
||||
int32_t callerUid = -1;
|
||||
std::string callerBundleName;
|
||||
std::vector<UIExtensionProcessBindInfo> bindInfos;
|
||||
// 0:unBind 1:Bind
|
||||
int32_t bindingRelation;
|
||||
};
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_ABILITY_RUNTIME_PROCESS_BIND_DATA_H
|
||||
@@ -394,5 +394,26 @@ int32_t ApplicationStateObserverProxy::SendTransactCmd(uint32_t code, MessagePar
|
||||
|
||||
return remote->SendRequest(code, data, reply, option);
|
||||
}
|
||||
|
||||
void ApplicationStateObserverProxy::OnProcessBindingRelationChanged(const ProcessBindData &processBindData)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_ASYNC);
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
return;
|
||||
}
|
||||
if (!data.WriteParcelable(&processBindData)) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "write processData failed");
|
||||
return;
|
||||
}
|
||||
int32_t ret = SendTransactCmd(
|
||||
static_cast<uint32_t>(IApplicationStateObserver::Message::TRANSACT_ON_PROCESS_BINDINGRELATION_CHANGED),
|
||||
data, reply, option);
|
||||
if (ret != NO_ERROR && ret != ERR_INVALID_STUB) {
|
||||
TAG_LOGW(AAFwkTag::APPMGR, "SendRequest is wrong, error code: %{public}d, bundleName:%{public}s.",
|
||||
ret, processBindData.bundleName.c_str());
|
||||
}
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -65,6 +65,8 @@ int ApplicationStateObserverStub::OnRemoteRequest(
|
||||
return HandleOnWindowShow(data, reply);
|
||||
case Message::TRANSACT_ON_WINDOW_HIDDEN:
|
||||
return HandleOnWindowHidden(data, reply);
|
||||
case Message::TRANSACT_ON_PROCESS_BINDINGRELATION_CHANGED:
|
||||
return HandleOnProcessBindingRelationChanged(data, reply);
|
||||
}
|
||||
TAG_LOGW(AAFwkTag::APPMGR, "ApplicationStateObserverStub::OnRemoteRequest, default case, need check");
|
||||
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
|
||||
@@ -124,6 +126,9 @@ void ApplicationStateObserverStub::OnPageHide(const PageStateData &pageStateData
|
||||
void ApplicationStateObserverStub::OnAppCacheStateChanged(const AppStateData &appStateData)
|
||||
{}
|
||||
|
||||
void ApplicationStateObserverStub::OnProcessBindingRelationChanged(const ProcessBindData &processBindData)
|
||||
{}
|
||||
|
||||
int32_t ApplicationStateObserverStub::HandleOnForegroundApplicationChanged(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
std::unique_ptr<AppStateData> processData(data.ReadParcelable<AppStateData>());
|
||||
@@ -340,6 +345,18 @@ int32_t ApplicationStateObserverStub::HandleOnAppCacheStateChanged(MessageParcel
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t ApplicationStateObserverStub::HandleOnProcessBindingRelationChanged(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
std::unique_ptr<ProcessBindData> processBindData(data.ReadParcelable<ProcessBindData>());
|
||||
if (!processBindData) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "ReadParcelable<ProcessBindData> failed");
|
||||
return ERR_APPEXECFWK_PARCEL_ERROR;
|
||||
}
|
||||
|
||||
OnProcessBindingRelationChanged(*processBindData);
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
ApplicationStateObserverRecipient::ApplicationStateObserverRecipient(RemoteDiedHandler handler) : handler_(handler)
|
||||
{}
|
||||
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2025 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "process_bind_data.h"
|
||||
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "parcel_macro_base.h"
|
||||
#include "string_ex.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
bool ProcessBindData::Marshalling(Parcel &parcel) const
|
||||
{
|
||||
return (parcel.WriteString(bundleName) && parcel.WriteInt32(pid) &&
|
||||
parcel.WriteInt32(uid) && parcel.WriteBool(isKeepAlive) &&
|
||||
parcel.WriteInt32(static_cast<int32_t>(processType)) &&
|
||||
parcel.WriteInt32(static_cast<int32_t>(extensionType)) &&
|
||||
parcel.WriteInt32(callerPid) && parcel.WriteInt32(callerUid) &&
|
||||
parcel.WriteString(callerBundleName) &&
|
||||
parcel.WriteInt32(bindingRelation));
|
||||
}
|
||||
|
||||
bool ProcessBindData::ReadFromParcel(Parcel &parcel)
|
||||
{
|
||||
bundleName = parcel.ReadString();
|
||||
pid = parcel.ReadInt32();
|
||||
uid = parcel.ReadInt32();
|
||||
isKeepAlive = parcel.ReadBool();
|
||||
processType = static_cast<ProcessType>(parcel.ReadInt32());
|
||||
extensionType = static_cast<ExtensionAbilityType>(parcel.ReadInt32());
|
||||
callerPid = parcel.ReadInt32();
|
||||
callerUid = parcel.ReadInt32();
|
||||
callerBundleName = parcel.ReadString();
|
||||
bindingRelation = parcel.ReadInt32();
|
||||
return true;
|
||||
}
|
||||
|
||||
ProcessBindData *ProcessBindData::Unmarshalling(Parcel &parcel)
|
||||
{
|
||||
ProcessBindData *processBindData = new (std::nothrow) ProcessBindData();
|
||||
if (processBindData && !processBindData->ReadFromParcel(parcel)) {
|
||||
TAG_LOGW(AAFwkTag::APPMGR,
|
||||
"processBindData failed, because ReadFromParcel failed");
|
||||
delete processBindData;
|
||||
processBindData = nullptr;
|
||||
}
|
||||
return processBindData;
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -670,6 +670,8 @@ private:
|
||||
bool NeedExtensionControl(std::shared_ptr<AbilityRecord> abilityRecord);
|
||||
bool GetTimeoutMsgContent(uint32_t msgId, std::string &msgContent, int &typeId);
|
||||
|
||||
void UpdateUIExtensionBindInfo(const std::shared_ptr<AbilityRecord> &abilityRecord,
|
||||
std::string callerBundleName, int32_t notifyProcessBind);
|
||||
private:
|
||||
const std::string TASK_ON_CALLBACK_DIED = "OnCallbackDiedTask";
|
||||
const std::string TASK_ON_ABILITY_DIED = "OnAbilityDiedTask";
|
||||
|
||||
@@ -1216,8 +1216,8 @@ public:
|
||||
void SendEvent(uint32_t msg, uint32_t timeOut, int32_t param = -1, bool isExtension = false,
|
||||
const std::string &taskName = "");
|
||||
|
||||
void UpdateUIExtensionBindInfo(const WantParams &wantParams);
|
||||
protected:
|
||||
|
||||
sptr<Token> token_ = {}; // used to interact with kit and wms
|
||||
std::unique_ptr<LifecycleDeal> lifecycleDeal_ = {}; // life manager used to schedule life
|
||||
AbilityState currentState_ = AbilityState::INITIAL; // current life state
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include "cache_extension_utils.h"
|
||||
#include "datetime_ex.h"
|
||||
#include "init_reboot.h"
|
||||
#include "string_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AAFwk {
|
||||
@@ -53,6 +54,11 @@ const std::string FRS_APP_INDEX = "ohos.extra.param.key.frs_index";
|
||||
const std::string FRS_BUNDLE_NAME = "com.ohos.formrenderservice";
|
||||
const std::string UIEXTENSION_ABILITY_ID = "ability.want.params.uiExtensionAbilityId";
|
||||
const std::string UIEXTENSION_ROOT_HOST_PID = "ability.want.params.uiExtensionRootHostPid";
|
||||
const std::string UIEXTENSION_HOST_PID = "ability.want.params.uiExtensionHostPid";
|
||||
const std::string UIEXTENSION_HOST_UID = "ability.want.params.uiExtensionHostPid";
|
||||
const std::string UIEXTENSION_HOST_BUNDLENAME = "ability.want.params.uiExtensionHostBundleName";
|
||||
const std::string UIEXTENSION_BIND_ABILITY_ID = "ability.want.params.uiExtensionBindAbilityId";
|
||||
const std::string UIEXTENSION_NOTIFY_BIND = "ohos.uiextension.params.uiExtensioNotifyBind";
|
||||
const std::string MAX_UINT64_VALUE = "18446744073709551615";
|
||||
const std::string IS_PRELOAD_UIEXTENSION_ABILITY = "ability.want.params.is_preload_uiextension_ability";
|
||||
const std::string SEPARATOR = ":";
|
||||
@@ -167,13 +173,14 @@ int AbilityConnectManager::StartAbilityLocked(const AbilityRequest &abilityReque
|
||||
|
||||
std::shared_ptr<AbilityRecord> targetService;
|
||||
bool isLoadedAbility = false;
|
||||
std::string hostBundleName;
|
||||
if (UIExtensionUtils::IsUIExtension(abilityRequest.abilityInfo.extensionAbilityType)) {
|
||||
auto callerAbilityRecord = AAFwk::Token::GetAbilityRecordByToken(abilityRequest.callerToken);
|
||||
if (callerAbilityRecord == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "null callerAbilityRecord");
|
||||
return ERR_NULL_OBJECT;
|
||||
}
|
||||
std::string hostBundleName = callerAbilityRecord->GetAbilityInfo().bundleName;
|
||||
hostBundleName = callerAbilityRecord->GetAbilityInfo().bundleName;
|
||||
ret = GetOrCreateExtensionRecord(abilityRequest, false, hostBundleName, targetService, isLoadedAbility);
|
||||
if (ret != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "fail, ret: %{public}d", ret);
|
||||
@@ -224,6 +231,9 @@ int AbilityConnectManager::StartAbilityLocked(const AbilityRequest &abilityReque
|
||||
mgr->UpdateUIExtensionInfo(targetService, AAFwk::DEFAULT_INVAL_VALUE);
|
||||
}
|
||||
};
|
||||
UpdateUIExtensionBindInfo(
|
||||
targetService, hostBundleName,
|
||||
abilityRequest.want.GetIntParam(UIEXTENSION_NOTIFY_BIND, -1));
|
||||
LoadAbility(targetService, updateRecordCallback);
|
||||
} else if (targetService->IsAbilityState(AbilityState::ACTIVE) && !IsUIExtensionAbility(targetService)) {
|
||||
// It may have been started through connect
|
||||
@@ -566,6 +576,9 @@ int AbilityConnectManager::PreloadUIExtensionAbilityInner(const AbilityRequest &
|
||||
mgr->UpdateUIExtensionInfo(targetService, hostPid);
|
||||
}
|
||||
};
|
||||
UpdateUIExtensionBindInfo(
|
||||
targetService, hostBundleName,
|
||||
abilityRequest.want.GetIntParam(UIEXTENSION_NOTIFY_BIND, -1));
|
||||
LoadAbility(targetService, updateRecordCallback);
|
||||
return ERR_OK;
|
||||
}
|
||||
@@ -3583,5 +3596,31 @@ std::shared_ptr<AbilityRecord> AbilityConnectManager::GetUIExtensionBySessionFro
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void AbilityConnectManager::UpdateUIExtensionBindInfo(
|
||||
const std::shared_ptr<AbilityRecord> &abilityRecord,
|
||||
std::string callerBundleName, int32_t notifyProcessBind)
|
||||
{
|
||||
if (abilityRecord == nullptr ||
|
||||
!UIExtensionUtils::IsUIExtension(
|
||||
abilityRecord->GetAbilityInfo().extensionAbilityType)) {
|
||||
TAG_LOGE(AAFwkTag::UI_EXT, "record null or type error");
|
||||
return;
|
||||
}
|
||||
|
||||
WantParams wantParams;
|
||||
auto uiExtensionBindAbilityId = abilityRecord->GetUIExtensionAbilityId();
|
||||
wantParams.SetParam(UIEXTENSION_BIND_ABILITY_ID,
|
||||
AAFwk::Integer::Box(uiExtensionBindAbilityId));
|
||||
wantParams.SetParam(UIEXTENSION_NOTIFY_BIND,
|
||||
AAFwk::Integer::Box(notifyProcessBind));
|
||||
wantParams.SetParam(UIEXTENSION_HOST_PID,
|
||||
AAFwk::Integer::Box(IPCSkeleton::GetCallingPid()));
|
||||
wantParams.SetParam(UIEXTENSION_HOST_UID,
|
||||
AAFwk::Integer::Box(IPCSkeleton::GetCallingUid()));
|
||||
wantParams.SetParam(UIEXTENSION_HOST_BUNDLENAME,
|
||||
String ::Box(callerBundleName));
|
||||
abilityRecord->UpdateUIExtensionBindInfo(wantParams);
|
||||
}
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -88,6 +88,11 @@ const std::string PARAM_MISSION_AFFINITY_KEY = "ohos.anco.param.missionAffinity"
|
||||
const std::string DISTRIBUTED_FILES_PATH = "/data/storage/el2/distributedfiles/";
|
||||
const std::string UIEXTENSION_ABILITY_ID = "ability.want.params.uiExtensionAbilityId";
|
||||
const std::string UIEXTENSION_ROOT_HOST_PID = "ability.want.params.uiExtensionRootHostPid";
|
||||
const std::string UIEXTENSION_HOST_PID = "ability.want.params.uiExtensionHostPid";
|
||||
const std::string UIEXTENSION_HOST_UID = "ability.want.params.uiExtensionHostPid";
|
||||
const std::string UIEXTENSION_HOST_BUNDLENAME = "ability.want.params.uiExtensionHostBundleName";
|
||||
const std::string UIEXTENSION_BIND_ABILITY_ID = "ability.want.params.uiExtensionBindAbilityId";
|
||||
const std::string UIEXTENSION_NOTIFY_BIND = "ohos.uiextension.params.uiExtensioNotifyBind";
|
||||
constexpr const char* PARAM_SEND_RESULT_CALLER_BUNDLENAME = "ohos.anco.param.sendResultCallderBundleName";
|
||||
constexpr const char* PARAM_SEND_RESULT_CALLER_TOKENID = "ohos.anco.param.sendResultCallerTokenId";
|
||||
constexpr const char* PARAM_RESV_ANCO_IS_NEED_UPDATE_NAME = "ohos.anco.param.isNeedUpdateName";
|
||||
@@ -3850,5 +3855,41 @@ void AbilityRecord::NotifyAbilityRequestSuccess(const std::string &requestId, co
|
||||
CHECK_POINTER(lifecycleDeal_);
|
||||
lifecycleDeal_->NotifyAbilityRequestSuccess(requestId, element);
|
||||
}
|
||||
|
||||
void AbilityRecord::UpdateUIExtensionBindInfo(const WantParams &wantParams)
|
||||
{
|
||||
if (!UIExtensionUtils::IsUIExtension(GetAbilityInfo().extensionAbilityType)) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::lock_guard guard(wantLock_);
|
||||
if (want_.HasParameter(UIEXTENSION_BIND_ABILITY_ID)) {
|
||||
want_.RemoveParam(UIEXTENSION_BIND_ABILITY_ID);
|
||||
}
|
||||
want_.SetParam(UIEXTENSION_BIND_ABILITY_ID,
|
||||
wantParams.GetIntParam(UIEXTENSION_BIND_ABILITY_ID, -1));
|
||||
|
||||
if (want_.HasParameter(UIEXTENSION_NOTIFY_BIND)) {
|
||||
want_.RemoveParam(UIEXTENSION_NOTIFY_BIND);
|
||||
}
|
||||
want_.SetParam(UIEXTENSION_NOTIFY_BIND,
|
||||
wantParams.GetIntParam(UIEXTENSION_NOTIFY_BIND, -1));
|
||||
if (want_.HasParameter(UIEXTENSION_HOST_PID)) {
|
||||
want_.RemoveParam(UIEXTENSION_HOST_PID);
|
||||
}
|
||||
want_.SetParam(UIEXTENSION_HOST_PID,
|
||||
wantParams.GetIntParam(UIEXTENSION_HOST_PID, -1));
|
||||
|
||||
if (want_.HasParameter(UIEXTENSION_HOST_UID)) {
|
||||
want_.RemoveParam(UIEXTENSION_HOST_UID);
|
||||
}
|
||||
want_.SetParam(UIEXTENSION_HOST_UID,
|
||||
wantParams.GetIntParam(UIEXTENSION_HOST_UID, -1));
|
||||
if (want_.HasParameter(UIEXTENSION_HOST_BUNDLENAME)) {
|
||||
want_.RemoveParam(UIEXTENSION_HOST_BUNDLENAME);
|
||||
}
|
||||
want_.SetParam(UIEXTENSION_HOST_BUNDLENAME,
|
||||
wantParams.GetStringParam(UIEXTENSION_HOST_BUNDLENAME));
|
||||
}
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -151,6 +151,8 @@ public:
|
||||
|
||||
bool IsHook() const;
|
||||
|
||||
void SetUIExtensionBindAbilityId(const int32_t uiExtensionBindAbilityId);
|
||||
int32_t GetUIExtensionBindAbilityId() const;
|
||||
private:
|
||||
bool isTerminating_ = false;
|
||||
bool isFocused_ = false;
|
||||
@@ -165,6 +167,7 @@ private:
|
||||
std::shared_ptr<AAFwk::Want> want_ = nullptr;
|
||||
sptr<IRemoteObject> token_;
|
||||
sptr<IRemoteObject> preToken_;
|
||||
int32_t uiExtensionBindAbilityId_ = 0;
|
||||
};
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -1978,6 +1978,13 @@ private:
|
||||
void SendAppSpawnUninstallDebugHapMsg(int32_t userId);
|
||||
std::shared_ptr<AppRunningRecord> CreateAppRunningRecord(std::shared_ptr<ApplicationInfo> appInfo,
|
||||
const std::string &processName, const BundleInfo &bundleInfo);
|
||||
void AddUIExtensionBindItem(std::shared_ptr<AAFwk::Want> want, std::shared_ptr<AppRunningRecord> appRecord,
|
||||
sptr<IRemoteObject> token);
|
||||
void RemoveUIExtensionBindItem(std::shared_ptr<AppRunningRecord> appRecord, sptr<IRemoteObject> token);
|
||||
void BindUIExtensionProcess(const std::shared_ptr<AppRunningRecord> &appRecord,
|
||||
const UIExtensionProcessBindInfo &bindInfo);
|
||||
void UnBindUIExtensionProcess(const std::shared_ptr<AppRunningRecord> &appRecord,
|
||||
const UIExtensionProcessBindInfo &bindInfo);
|
||||
|
||||
bool isInitAppWaitingDebugListExecuted_ = false;
|
||||
std::atomic<bool> sceneBoardAttachFlag_ = true;
|
||||
@@ -2037,6 +2044,9 @@ private:
|
||||
|
||||
std::mutex screenOffSubscriberMutex_;
|
||||
std::mutex childProcessRecordMapMutex_;
|
||||
|
||||
std::mutex uiExtensionBindReleationsLock_;
|
||||
std::map<int32_t, std::unordered_map<pid_t, int32_t>> uiExtensionBindReleations_;
|
||||
};
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include "refbase.h"
|
||||
#include "running_process_info.h"
|
||||
#include "simple_process_info.h"
|
||||
#include "process_bind_data.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
@@ -374,6 +375,11 @@ public:
|
||||
|
||||
void UpdateInstanceKeyBySpecifiedId(int32_t specifiedId, std::string &instanceKey);
|
||||
std::shared_ptr<AppRunningRecord> QueryAppRecordPlus(int32_t pid, int32_t uid);
|
||||
UIExtensionProcessBindInfo WarpBindInfo(int32_t pid, int32_t uid, int32_t callerPid, int32_t callerUid,
|
||||
std::string callerBundleName, int32_t notifyProcessBind);
|
||||
int32_t AddUIExtensionBindItem(int32_t uiExtensionBindAbilityId, UIExtensionProcessBindInfo &bindInfo);
|
||||
int32_t QueryUIExtensionBindItemById(int32_t uiExtensionBindAbilityId, UIExtensionProcessBindInfo &bindInfo);
|
||||
int32_t RemoveUIExtensionBindItemById(int32_t uiExtensionBindAbilityId);
|
||||
private:
|
||||
std::shared_ptr<AbilityRunningRecord> GetAbilityRunningRecord(const int64_t eventId);
|
||||
int32_t AssignRunningProcessInfoByAppRecord(
|
||||
@@ -394,6 +400,9 @@ private:
|
||||
|
||||
std::mutex updateConfigurationDelayedLock_;
|
||||
std::map<const int32_t, bool> updateConfigurationDelayedMap_;
|
||||
|
||||
std::mutex uiExtensionBindMapLock_;
|
||||
std::map<int32_t, UIExtensionProcessBindInfo> uiExtensionBindMap_;
|
||||
};
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -72,6 +72,8 @@ public:
|
||||
void OnAppStopped(const std::shared_ptr<AppRunningRecord> &appRecord);
|
||||
void OnProcessCreated(const std::shared_ptr<AppRunningRecord> &appRecord, bool isPreload);
|
||||
void OnProcessStateChanged(const std::shared_ptr<AppRunningRecord> &appRecord);
|
||||
void OnProcessBindingRelationChanged(const std::shared_ptr<AppRunningRecord> &appRecord,
|
||||
const UIExtensionProcessBindInfo &bindInfo, int32_t bindingRelation);
|
||||
void OnWindowShow(const std::shared_ptr<AppRunningRecord> &appRecord);
|
||||
void OnWindowHidden(const std::shared_ptr<AppRunningRecord> &appRecord);
|
||||
void OnRenderProcessCreated(const std::shared_ptr<RenderRecord> &RenderRecord, const bool isPreload);
|
||||
@@ -116,6 +118,8 @@ private:
|
||||
AbilityForegroundObserverMap GetAbilityForegroundObserverMapCopy();
|
||||
ProcessData WrapProcessData(const std::shared_ptr<AppRunningRecord> &appRecord);
|
||||
ProcessData WrapRenderProcessData(const std::shared_ptr<RenderRecord> &renderRecord);
|
||||
ProcessBindData WrapProcessBindData(const std::shared_ptr<AppRunningRecord> &appRecord,
|
||||
const UIExtensionProcessBindInfo &bindInfo, int32_t bindingRelation);
|
||||
#ifdef SUPPORT_CHILD_PROCESS
|
||||
int32_t WrapChildProcessData(ProcessData &processData, std::shared_ptr<ChildProcessRecord> childRecord);
|
||||
#endif // SUPPORT_CHILD_PROCESS
|
||||
@@ -131,6 +135,8 @@ private:
|
||||
void HandleOnAppCacheStateChanged(const std::shared_ptr<AppRunningRecord> &appRecord, ApplicationState state);
|
||||
void AddObserverCount(int32_t uid);
|
||||
void DecreaseObserverCount(int32_t uid);
|
||||
void HandleOnProcessBindingRelationChanged(const std::shared_ptr<AppRunningRecord> &appRecord,
|
||||
const UIExtensionProcessBindInfo &bindInfo, int32_t bindingRelation);
|
||||
|
||||
private:
|
||||
std::shared_ptr<AAFwk::TaskHandlerWrap> handler_;
|
||||
|
||||
@@ -171,5 +171,15 @@ bool AbilityRunningRecord::IsHook() const
|
||||
{
|
||||
return want_ && want_->GetBoolParam(IS_HOOK, false);
|
||||
}
|
||||
|
||||
void AbilityRunningRecord::SetUIExtensionBindAbilityId(const int32_t uiExtensionBindAbilityId)
|
||||
{
|
||||
uiExtensionBindAbilityId_ = uiExtensionBindAbilityId;
|
||||
}
|
||||
|
||||
int32_t AbilityRunningRecord::GetUIExtensionBindAbilityId() const
|
||||
{
|
||||
return uiExtensionBindAbilityId_;
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -206,6 +206,11 @@ constexpr const char* HWASAN_FLAG_NAME = "hwasanEnabled";
|
||||
constexpr const char* UBSAN_FLAG_NAME = "ubsanEnabled";
|
||||
constexpr const char* UIEXTENSION_ABILITY_ID = "ability.want.params.uiExtensionAbilityId";
|
||||
constexpr const char* UIEXTENSION_ROOT_HOST_PID = "ability.want.params.uiExtensionRootHostPid";
|
||||
constexpr const char* UIEXTENSION_HOST_PID = "ability.want.params.uiExtensionHostPid";
|
||||
constexpr const char* UIEXTENSION_HOST_UID = "ability.want.params.uiExtensionHostUid";
|
||||
constexpr const char* UIEXTENSION_HOST_BUNDLENAME = "ability.want.params.uiExtensionHostBundleName";
|
||||
constexpr const char* UIEXTENSION_BIND_ABILITY_ID = "ability.want.params.uiExtensionBindAbilityId";
|
||||
constexpr const char* UIEXTENSION_NOTIFY_BIND = "ohos.uiextension.params.notifyProcessBind";
|
||||
constexpr const char* MEMMGR_PROC_NAME = "memmgrservice";
|
||||
constexpr const char* ISOLATED_SANDBOX = "isolatedSandbox";
|
||||
constexpr const char* RENDER_PROCESS_NAME = ":render";
|
||||
@@ -814,6 +819,7 @@ void AppMgrServiceInner::LoadAbility(std::shared_ptr<AbilityInfo> abilityInfo, s
|
||||
StartAbility(loadParam->token, loadParam->preToken, abilityInfo, appRecord, hapModuleInfo, want,
|
||||
loadParam->abilityRecordId);
|
||||
if (AAFwk::UIExtensionUtils::IsUIExtension(abilityInfo->extensionAbilityType)) {
|
||||
AddUIExtensionBindItem(want, appRecord, loadParam->token);
|
||||
AddUIExtensionLauncherItem(want, appRecord, loadParam->token);
|
||||
}
|
||||
}
|
||||
@@ -822,9 +828,12 @@ void AppMgrServiceInner::LoadAbility(std::shared_ptr<AbilityInfo> abilityInfo, s
|
||||
appRecord != nullptr && want != nullptr) {
|
||||
auto abilityRunningRecord = appRecord->GetAbilityRunningRecordByToken(loadParam->token);
|
||||
auto uiExtensionAbilityId = want->GetIntParam(UIEXTENSION_ABILITY_ID, -1);
|
||||
auto uiExtensionBindAbilityId = want->GetIntParam(UIEXTENSION_BIND_ABILITY_ID, -1);
|
||||
if (abilityRunningRecord != nullptr) {
|
||||
abilityRunningRecord->SetUIExtensionAbilityId(uiExtensionAbilityId);
|
||||
abilityRunningRecord->SetUIExtensionBindAbilityId(uiExtensionBindAbilityId);
|
||||
}
|
||||
want->RemoveParam(UIEXTENSION_BIND_ABILITY_ID);
|
||||
}
|
||||
AfterLoadAbility(appRecord, abilityInfo, loadParam);
|
||||
}
|
||||
@@ -2857,6 +2866,7 @@ void AppMgrServiceInner::TerminateAbility(const sptr<IRemoteObject> &token, bool
|
||||
return;
|
||||
}
|
||||
|
||||
RemoveUIExtensionBindItem(appRecord, token);
|
||||
RemoveUIExtensionLauncherItem(appRecord, token);
|
||||
|
||||
if (appRunningManager_) {
|
||||
@@ -4009,6 +4019,9 @@ int32_t AppMgrServiceInner::StartProcess(const std::string &appName, const std::
|
||||
}
|
||||
OnAppStateChanged(appRecord, ApplicationState::APP_STATE_CREATE, false, false);
|
||||
DelayedSingleton<AppStateObserverManager>::GetInstance()->OnProcessCreated(appRecord, isPreload);
|
||||
if (AAFwk::UIExtensionUtils::IsUIExtension(extensionAbilityType)) {
|
||||
AddUIExtensionBindItem(want, appRecord, token);
|
||||
}
|
||||
if (!appExistFlag) {
|
||||
OnAppStarted(appRecord);
|
||||
}
|
||||
@@ -9385,5 +9398,142 @@ int32_t AppMgrServiceInner::LaunchAbility(sptr<IRemoteObject> token)
|
||||
appRecord->LaunchAbility(ability);
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
void AppMgrServiceInner::AddUIExtensionBindItem(
|
||||
std::shared_ptr<AAFwk::Want> want,
|
||||
std::shared_ptr<AppRunningRecord> appRecord, sptr<IRemoteObject> token)
|
||||
{
|
||||
auto notifyProcessBind = want->GetIntParam(UIEXTENSION_NOTIFY_BIND, -1);
|
||||
if (notifyProcessBind != 1) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "no bind permission");
|
||||
return;
|
||||
}
|
||||
if (want == nullptr || appRecord == nullptr || token == nullptr ||
|
||||
appRunningManager_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "invalid input params");
|
||||
return;
|
||||
}
|
||||
auto uiExtensionBindAbilityId =
|
||||
want->GetIntParam(UIEXTENSION_BIND_ABILITY_ID, -1);
|
||||
auto callerPid = want->GetIntParam(UIEXTENSION_HOST_PID, -1);
|
||||
auto callerUid = want->GetIntParam(UIEXTENSION_HOST_UID, -1);
|
||||
auto callerBundleName = want->GetStringParam(UIEXTENSION_HOST_BUNDLENAME);
|
||||
pid_t providerPid = -1;
|
||||
pid_t providerUid = -1;
|
||||
if (appRecord->GetPriorityObject() != nullptr) {
|
||||
providerPid = appRecord->GetPid();
|
||||
providerUid = appRecord->GetUid();
|
||||
}
|
||||
if (uiExtensionBindAbilityId == -1 || providerPid == -1 ||
|
||||
providerUid == -1 || callerPid == -1 || callerUid == -1 ||
|
||||
callerBundleName.empty()) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "invalid want params");
|
||||
return;
|
||||
}
|
||||
|
||||
TAG_LOGI(AAFwkTag::APPMGR,
|
||||
"uiExtensionBindAbilityId: %{public}d, providerUid: "
|
||||
"%{public}d,providerPid: %{public}d,callerUid: %{public}d, "
|
||||
"callerPid: %{public}d,callerBundleName: %{public}s",
|
||||
uiExtensionBindAbilityId, providerUid, providerPid, callerUid,
|
||||
callerPid, callerBundleName.c_str());
|
||||
UIExtensionProcessBindInfo bindInfo = appRunningManager_->WarpBindInfo(
|
||||
providerPid, providerUid, callerPid, callerUid, callerBundleName,
|
||||
notifyProcessBind);
|
||||
appRunningManager_->AddUIExtensionBindItem(uiExtensionBindAbilityId,
|
||||
bindInfo);
|
||||
BindUIExtensionProcess(appRecord, bindInfo);
|
||||
want->RemoveParam(UIEXTENSION_HOST_PID);
|
||||
want->RemoveParam(UIEXTENSION_HOST_UID);
|
||||
want->RemoveParam(UIEXTENSION_HOST_BUNDLENAME);
|
||||
want->RemoveParam(UIEXTENSION_NOTIFY_BIND);
|
||||
}
|
||||
|
||||
void AppMgrServiceInner::RemoveUIExtensionBindItem(
|
||||
std::shared_ptr<AppRunningRecord> appRecord, sptr<IRemoteObject> token)
|
||||
{
|
||||
if (appRecord == nullptr || token == nullptr ||
|
||||
appRunningManager_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "invalid input params");
|
||||
return;
|
||||
}
|
||||
|
||||
auto abilityRunningRecord = appRecord->GetAbilityRunningRecordByToken(token);
|
||||
if (abilityRunningRecord == nullptr) {
|
||||
TAG_LOGW(AAFwkTag::APPMGR, "invalid ability");
|
||||
return;
|
||||
}
|
||||
|
||||
auto abilityInfo = abilityRunningRecord->GetAbilityInfo();
|
||||
if (abilityInfo == nullptr) {
|
||||
TAG_LOGW(AAFwkTag::APPMGR, "invalid ability");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!AAFwk::UIExtensionUtils::IsUIExtension(
|
||||
abilityInfo->extensionAbilityType)) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto uiExtensionBindAbilityId =
|
||||
abilityRunningRecord->GetUIExtensionBindAbilityId();
|
||||
UIExtensionProcessBindInfo bindInfo;
|
||||
auto result = appRunningManager_->QueryUIExtensionBindItemById(
|
||||
uiExtensionBindAbilityId, bindInfo);
|
||||
if (result != ERR_OK) {
|
||||
return;
|
||||
}
|
||||
if (bindInfo.notifyProcessBind != 1) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "no bind permission");
|
||||
return;
|
||||
}
|
||||
UnBindUIExtensionProcess(appRecord, bindInfo);
|
||||
appRunningManager_->RemoveUIExtensionBindItemById(uiExtensionBindAbilityId);
|
||||
}
|
||||
|
||||
void AppMgrServiceInner::BindUIExtensionProcess(
|
||||
const std::shared_ptr<AppRunningRecord> &appRecord,
|
||||
const UIExtensionProcessBindInfo &bindInfo)
|
||||
{
|
||||
std::lock_guard guard(uiExtensionBindReleationsLock_);
|
||||
auto pid = bindInfo.pid;
|
||||
auto callerPid = bindInfo.callerPid;
|
||||
auto it = uiExtensionBindReleations_.find(pid);
|
||||
|
||||
if (it == uiExtensionBindReleations_.end() ||
|
||||
it->second.find(callerPid) == it->second.end()) {
|
||||
uiExtensionBindReleations_[pid][callerPid] = 1;
|
||||
DelayedSingleton<AppStateObserverManager>::GetInstance()
|
||||
->OnProcessBindingRelationChanged(appRecord, bindInfo, 1);
|
||||
} else {
|
||||
it->second[callerPid]++;
|
||||
}
|
||||
}
|
||||
|
||||
void AppMgrServiceInner::UnBindUIExtensionProcess(
|
||||
const std::shared_ptr<AppRunningRecord> &appRecord,
|
||||
const UIExtensionProcessBindInfo &bindInfo)
|
||||
{
|
||||
std::lock_guard guard(uiExtensionBindReleationsLock_);
|
||||
auto pid = bindInfo.pid;
|
||||
auto callerPid = bindInfo.callerPid;
|
||||
auto it = uiExtensionBindReleations_.find(pid);
|
||||
|
||||
if (it != uiExtensionBindReleations_.end()) {
|
||||
auto &innerMap = it->second;
|
||||
auto innerIt = innerMap.find(callerPid);
|
||||
if (innerIt != innerMap.end()) {
|
||||
innerIt->second--;
|
||||
if (innerIt->second == 0) {
|
||||
DelayedSingleton<AppStateObserverManager>::GetInstance()
|
||||
->OnProcessBindingRelationChanged(appRecord, bindInfo, 0);
|
||||
innerMap.erase(innerIt);
|
||||
}
|
||||
}
|
||||
if (innerMap.empty()) {
|
||||
uiExtensionBindReleations_.erase(it);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -1956,5 +1956,49 @@ void AppRunningManager::RemoveTimeoutDeadAppRecord()
|
||||
}, DEAD_APP_RECORD_CLEAR_TIME);
|
||||
}
|
||||
}
|
||||
|
||||
UIExtensionProcessBindInfo AppRunningManager::WarpBindInfo(int32_t pid, int32_t uid, int32_t callerPid,
|
||||
int32_t callerUid, std::string callerBundleName,
|
||||
int32_t notifyProcessBind)
|
||||
{
|
||||
UIExtensionProcessBindInfo uiExtensionProcessBindInfo;
|
||||
uiExtensionProcessBindInfo.pid = pid;
|
||||
uiExtensionProcessBindInfo.uid = uid;
|
||||
uiExtensionProcessBindInfo.callerPid = callerPid;
|
||||
uiExtensionProcessBindInfo.callerUid = callerUid;
|
||||
uiExtensionProcessBindInfo.callerBundleName = callerBundleName;
|
||||
uiExtensionProcessBindInfo.notifyProcessBind = notifyProcessBind;
|
||||
return uiExtensionProcessBindInfo;
|
||||
}
|
||||
|
||||
int32_t AppRunningManager::AddUIExtensionBindItem(
|
||||
int32_t uiExtensionBindAbilityId, UIExtensionProcessBindInfo &bindInfo)
|
||||
{
|
||||
std::lock_guard guard(uiExtensionBindMapLock_);
|
||||
uiExtensionBindMap_.emplace(uiExtensionBindAbilityId, bindInfo);
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
int32_t AppRunningManager::RemoveUIExtensionBindItemById(int32_t uiExtensionBindAbilityId)
|
||||
{
|
||||
std::lock_guard guard(uiExtensionBindMapLock_);
|
||||
auto it = uiExtensionBindMap_.find(uiExtensionBindAbilityId);
|
||||
if (it != uiExtensionBindMap_.end()) {
|
||||
uiExtensionBindMap_.erase(it);
|
||||
}
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
int32_t AppRunningManager::QueryUIExtensionBindItemById(
|
||||
int32_t uiExtensionBindAbilityId, UIExtensionProcessBindInfo &bindInfo)
|
||||
{
|
||||
std::lock_guard guard(uiExtensionBindMapLock_);
|
||||
auto it = uiExtensionBindMap_.find(uiExtensionBindAbilityId);
|
||||
if (it != uiExtensionBindMap_.end()) {
|
||||
bindInfo = it->second;
|
||||
return ERR_OK;
|
||||
}
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -1249,5 +1249,70 @@ void AppStateObserverManager::HandleOnAppCacheStateChanged(const std::shared_ptr
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ProcessBindData AppStateObserverManager::WrapProcessBindData(
|
||||
const std::shared_ptr<AppRunningRecord> &appRecord,
|
||||
const UIExtensionProcessBindInfo &bindInfo, int32_t bindingRelation)
|
||||
{
|
||||
ProcessBindData processBindData;
|
||||
processBindData.bundleName = appRecord->GetBundleName();
|
||||
processBindData.pid = appRecord->GetPid();
|
||||
processBindData.uid = appRecord->GetUid();
|
||||
processBindData.isKeepAlive = appRecord->IsKeepAliveApp();
|
||||
processBindData.extensionType = appRecord->GetExtensionType();
|
||||
processBindData.processType = appRecord->GetProcessType();
|
||||
processBindData.callerPid = bindInfo.callerPid;
|
||||
processBindData.callerUid = bindInfo.callerUid;
|
||||
processBindData.callerBundleName = bindInfo.callerBundleName;
|
||||
processBindData.bindingRelation = bindingRelation;
|
||||
return processBindData;
|
||||
}
|
||||
|
||||
void AppStateObserverManager::OnProcessBindingRelationChanged(
|
||||
const std::shared_ptr<AppRunningRecord> &appRecord,
|
||||
const UIExtensionProcessBindInfo &bindInfo, int32_t bindingRelation)
|
||||
{
|
||||
if (handler_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "null handler");
|
||||
return;
|
||||
}
|
||||
|
||||
auto task =
|
||||
[weak = weak_from_this(), appRecord, bindInfo, bindingRelation]() {
|
||||
auto self = weak.lock();
|
||||
if (self == nullptr){
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "null self");
|
||||
return;
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "OnProcessBindingRelationChanged come.");
|
||||
self->HandleOnProcessBindingRelationChanged(appRecord, bindInfo, bindingRelation);
|
||||
};
|
||||
handler_->SubmitTask(task);
|
||||
}
|
||||
|
||||
void AppStateObserverManager::HandleOnProcessBindingRelationChanged(
|
||||
const std::shared_ptr<AppRunningRecord> &appRecord,
|
||||
const UIExtensionProcessBindInfo &bindInfo, int32_t bindingRelation)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
if (appRecord == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "null appRecord");
|
||||
return;
|
||||
}
|
||||
|
||||
ProcessBindData data =
|
||||
WrapProcessBindData(appRecord, bindInfo, bindingRelation);
|
||||
auto appStateObserverMapCopy = GetAppStateObserverMapCopy();
|
||||
for (auto it = appStateObserverMapCopy.begin();
|
||||
it != appStateObserverMapCopy.end(); ++it) {
|
||||
const auto &bundleNames = it->second.bundleNames;
|
||||
auto iter =
|
||||
std::find(bundleNames.begin(), bundleNames.end(), data.bundleName);
|
||||
if ((bundleNames.empty() || iter != bundleNames.end()) &&
|
||||
it->first != nullptr) {
|
||||
it->first->OnProcessBindingRelationChanged(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -42,6 +42,7 @@ ohos_fuzztest("AbilitymgrPreloadUiextStateObserverFuzzTest") {
|
||||
"${ability_runtime_innerkits_path}/app_manager/src/appmgr/application_state_observer_stub.cpp",
|
||||
"${ability_runtime_innerkits_path}/app_manager/src/appmgr/page_state_data.cpp",
|
||||
"${ability_runtime_innerkits_path}/app_manager/src/appmgr/process_data.cpp",
|
||||
"${ability_runtime_innerkits_path}/app_manager/src/appmgr/process_bind_data.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/extension_record/extension_record.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/ui_extension/preload_uiext_state_observer.cpp",
|
||||
"${bundlefwk_inner_api_path}/appexecfwk_base/src/application_info.cpp",
|
||||
|
||||
@@ -41,6 +41,7 @@ ohos_fuzztest("DisposedObserverFuzzTest") {
|
||||
"${ability_runtime_innerkits_path}/app_manager/src/appmgr/application_state_observer_stub.cpp",
|
||||
"${ability_runtime_innerkits_path}/app_manager/src/appmgr/page_state_data.cpp",
|
||||
"${ability_runtime_innerkits_path}/app_manager/src/appmgr/process_data.cpp",
|
||||
"${ability_runtime_innerkits_path}/app_manager/src/appmgr/process_bind_data.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/disposed_observer.cpp",
|
||||
"disposedobserver_fuzzer.cpp",
|
||||
]
|
||||
|
||||
@@ -43,6 +43,7 @@ ohos_fuzztest("ExtensionRecordManagerFuzzTest") {
|
||||
"${ability_runtime_innerkits_path}/app_manager/src/appmgr/application_state_observer_stub.cpp",
|
||||
"${ability_runtime_innerkits_path}/app_manager/src/appmgr/page_state_data.cpp",
|
||||
"${ability_runtime_innerkits_path}/app_manager/src/appmgr/process_data.cpp",
|
||||
"${ability_runtime_innerkits_path}/app_manager/src/appmgr/process_bind_data.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/extension_record/extension_record.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/extension_record/extension_record_factory.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/extension_record/extension_record_manager.cpp",
|
||||
|
||||
@@ -43,6 +43,7 @@ ohos_fuzztest("ExtensionRecordManageraFuzzTest") {
|
||||
"${ability_runtime_innerkits_path}/app_manager/src/appmgr/application_state_observer_stub.cpp",
|
||||
"${ability_runtime_innerkits_path}/app_manager/src/appmgr/page_state_data.cpp",
|
||||
"${ability_runtime_innerkits_path}/app_manager/src/appmgr/process_data.cpp",
|
||||
"${ability_runtime_innerkits_path}/app_manager/src/appmgr/process_bind_data.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/extension_record/extension_record.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/extension_record/extension_record_factory.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/extension_record/extension_record_manager.cpp",
|
||||
|
||||
@@ -43,6 +43,7 @@ ohos_unittest("extension_record_manager_second_test") {
|
||||
"${ability_runtime_innerkits_path}/app_manager/src/appmgr/application_state_observer_stub.cpp",
|
||||
"${ability_runtime_innerkits_path}/app_manager/src/appmgr/page_state_data.cpp",
|
||||
"${ability_runtime_innerkits_path}/app_manager/src/appmgr/process_data.cpp",
|
||||
"${ability_runtime_innerkits_path}/app_manager/src/appmgr/process_bind_data.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/extension_record/extension_record.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/extension_record/extension_record_factory.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/extension_record/extension_record_manager.cpp",
|
||||
|
||||
@@ -40,6 +40,7 @@ ohos_unittest("extension_record_manager_test") {
|
||||
"${ability_runtime_innerkits_path}/app_manager/src/appmgr/application_state_observer_stub.cpp",
|
||||
"${ability_runtime_innerkits_path}/app_manager/src/appmgr/page_state_data.cpp",
|
||||
"${ability_runtime_innerkits_path}/app_manager/src/appmgr/process_data.cpp",
|
||||
"${ability_runtime_innerkits_path}/app_manager/src/appmgr/process_bind_data.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/extension_record/extension_record.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/extension_record/extension_record_factory.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/extension_record/extension_record_manager.cpp",
|
||||
|
||||
Reference in New Issue
Block a user