transfer host window id for uiextension

Signed-off-by: lushi1202 <lushi@huawei.com>
Change-Id: Ia371084b7a250e81e36dd532b0a9b81d6c2a5958
This commit is contained in:
lushi1202 2023-07-31 12:06:16 +08:00
parent 3734a20fc5
commit 342629a612
16 changed files with 6 additions and 79 deletions

View File

@ -65,7 +65,6 @@ public:
void(std::function<void(const std::string& code, const std::string& msg)>&& actionCallback));
MOCK_METHOD1(SetIgnoreViewSafeArea, void(bool ignoreViewSafeArea));
MOCK_METHOD1(SetIsFocusActive, void(bool isFocusActive));
MOCK_METHOD1(SetFocusWindowId, void(uint32_t focusWIndowId));
MOCK_METHOD2(CreateModalUIExtension, int32_t(const AAFwk::Want& want, const ModalUIExtensionCallbacks& callbacks));
MOCK_METHOD1(CloseModalUIExtension, void(int32_t sessionId));
};

View File

@ -36,7 +36,6 @@ public:
WSError TransferPointerEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent) override;
WSError TransferKeyEventForConsumed(const std::shared_ptr<MMI::KeyEvent>& keyEvent, bool& isConsumed) override;
WSError TransferFocusActiveEvent(bool isFocusActive) override;
WSError TransferFocusWindowId(int32_t windowId) override;
WSError TransferFocusState(bool focusState) override;
private:

View File

@ -49,7 +49,6 @@ public:
virtual void NotifyPointerEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent) {}
virtual void NotifyKeyEvent(const std::shared_ptr<MMI::KeyEvent>& keyEvent, bool& isConsumed) {}
virtual void NotifyFocusActiveEvent(bool isFocusActive) {}
virtual void NotifyFocusWindowIdEvent(int32_t windowId) {}
virtual int32_t GetPersistentId() const
{
return -1;

View File

@ -45,7 +45,6 @@ public:
// transfer sync key event for weather consumed
virtual WSError TransferKeyEventForConsumed(const std::shared_ptr<MMI::KeyEvent>& keyEvent, bool& isConsumed) = 0;
virtual WSError TransferFocusActiveEvent(bool isFocusActive) = 0;
virtual WSError TransferFocusWindowId(int32_t windowId) = 0;
virtual WSError TransferFocusState(bool focusState) = 0;
};
} // namespace OHOS::Rosen

View File

@ -32,7 +32,6 @@ public:
WSError TransferPointerEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent) override;
WSError TransferKeyEventForConsumed(const std::shared_ptr<MMI::KeyEvent>& keyEvent, bool& isConsumed) override;
WSError TransferFocusActiveEvent(bool isFocusActive) override;
WSError TransferFocusWindowId(int32_t windowId) override;
WSError TransferFocusState(bool focusState) override;
private:
static inline BrokerDelegator<WindowEventChannelProxy> delegator_;

View File

@ -39,7 +39,6 @@ private:
int HandleTransferPointerEvent(MessageParcel& data, MessageParcel& reply);
int HandleGetApplicationPid(MessageParcel& data, MessageParcel& reply);
int HandleTransferFocusActiveEvent(MessageParcel& data, MessageParcel& reply);
int HandleTransferFocusWindowIdEvent(MessageParcel& data, MessageParcel& reply);
int HandleTransferFocusStateEvent(MessageParcel& data, MessageParcel& reply);
};
} // namespace OHOS::Rosen

View File

@ -151,17 +151,6 @@ void WindowEventChannel::PrintPointerEvent(const std::shared_ptr<MMI::PointerEve
}
}
WSError WindowEventChannel::TransferFocusWindowId(int32_t windowId)
{
WLOGFD("WindowEventChannel receive focus window Id event: %{public}d", windowId);
if (!sessionStage_) {
WLOGFE("session stage is null!");
return WSError::WS_ERROR_NULLPTR;
}
sessionStage_->NotifyFocusWindowIdEvent(windowId);
return WSError::WS_OK;
}
WSError WindowEventChannel::TransferFocusState(bool focusState)
{
WLOGFD("WindowEventChannel receive focus state event: %{public}d", static_cast<int>(focusState));

View File

@ -126,28 +126,6 @@ WSError WindowEventChannelProxy::TransferFocusActiveEvent(bool isFocusActive)
return static_cast<WSError>(ret);
}
WSError WindowEventChannelProxy::TransferFocusWindowId(int32_t windowId)
{
MessageParcel data;
MessageParcel reply;
MessageOption option(MessageOption::TF_ASYNC);
if (!data.WriteInterfaceToken(GetDescriptor())) {
WLOGFE("WriteInterfaceToken failed");
return WSError::WS_ERROR_IPC_FAILED;
}
if (!data.WriteInt32(windowId)) {
WLOGFE("Write windowId failed");
return WSError::WS_ERROR_IPC_FAILED;
}
if (Remote()->SendRequest(static_cast<uint32_t>(WindowEventChannelMessage::TRANS_ID_TRANSFER_FOCUS_WINDOW_ID_EVENT),
data, reply, option) != ERR_NONE) {
WLOGFE("SendRequest failed");
return WSError::WS_ERROR_IPC_FAILED;
}
int32_t ret = reply.ReadInt32();
return static_cast<WSError>(ret);
}
WSError WindowEventChannelProxy::TransferFocusState(bool focusState)
{
MessageParcel data;

View File

@ -34,8 +34,6 @@ const std::map<uint32_t, WindowEventChannelStubFunc> WindowEventChannelStub::stu
&WindowEventChannelStub::HandleTransferPointerEvent),
std::make_pair(static_cast<uint32_t>(WindowEventChannelMessage::TRANS_ID_TRANSFER_FOCUS_ACTIVE_EVENT),
&WindowEventChannelStub::HandleTransferFocusActiveEvent),
std::make_pair(static_cast<uint32_t>(WindowEventChannelMessage::TRANS_ID_TRANSFER_FOCUS_WINDOW_ID_EVENT),
&WindowEventChannelStub::HandleTransferFocusWindowIdEvent),
std::make_pair(static_cast<uint32_t>(WindowEventChannelMessage::TRANS_ID_TRANSFER_FOCUS_STATE_EVENT),
&WindowEventChannelStub::HandleTransferFocusStateEvent)
};
@ -103,14 +101,6 @@ int WindowEventChannelStub::HandleTransferFocusActiveEvent(MessageParcel& data,
return ERR_NONE;
}
int WindowEventChannelStub::HandleTransferFocusWindowIdEvent(MessageParcel& data, MessageParcel& reply)
{
auto focusWindowId = data.ReadInt32();
WSError errCode = TransferFocusWindowId(focusWindowId);
reply.WriteUint32(static_cast<uint32_t>(errCode));
return ERR_NONE;
}
int WindowEventChannelStub::HandleTransferFocusStateEvent(MessageParcel& data, MessageParcel& reply)
{
bool focusState = data.ReadBool();

View File

@ -119,7 +119,6 @@ public:
virtual WSError TransferKeyEvent(const std::shared_ptr<MMI::KeyEvent>& keyEvent);
WSError TransferKeyEventForConsumed(const std::shared_ptr<MMI::KeyEvent>& keyEvent, bool& isConsumed);
WSError TransferFocusActiveEvent(bool isFocusActive);
WSError TransferFocusWindowIdEvent(int32_t windowId);
WSError TransferFocusStateEvent(bool focusState);
bool RegisterLifecycleListener(const std::shared_ptr<ILifecycleListener>& listener);

View File

@ -777,15 +777,6 @@ WSError Session::TransferFocusActiveEvent(bool isFocusActive)
return windowEventChannel_->TransferFocusActiveEvent(isFocusActive);
}
WSError Session::TransferFocusWindowIdEvent(int32_t windowId)
{
if (!windowEventChannel_) {
WLOGFE("windowEventChannel_ is null");
return WSError::WS_ERROR_NULLPTR;
}
return windowEventChannel_->TransferFocusWindowId(windowId);
}
WSError Session::TransferFocusStateEvent(bool focusState)
{
if (!windowEventChannel_) {

View File

@ -42,7 +42,7 @@ public:
* @param extensionSession the extension session need to be activated
* @return WSError
*/
WSError RequestExtensionSessionActivation(const sptr<ExtensionSession>& extensionSession);
WSError RequestExtensionSessionActivation(const sptr<ExtensionSession>& extensionSession, uint32_t hostWindowId);
/**
* @brief background extension session
*

View File

@ -79,11 +79,12 @@ sptr<ExtensionSession> ExtensionSessionManager::RequestExtensionSession(const Se
return taskScheduler_->PostSyncTask(task);
}
WSError ExtensionSessionManager::RequestExtensionSessionActivation(const sptr<ExtensionSession>& extensionSession)
WSError ExtensionSessionManager::RequestExtensionSessionActivation(
const sptr<ExtensionSession>& extensionSession, uint32_t hostWindowId)
{
wptr<ExtensionSession> weakExtSession(extensionSession);
WSError ret = WSError::WS_OK;
auto task = [this, weakExtSession, &ret]() {
auto task = [this, weakExtSession, &ret, hostWindowId]() {
auto extSession = weakExtSession.promote();
if (extSession == nullptr) {
WLOGFE("session is nullptr");
@ -99,6 +100,7 @@ WSError ExtensionSessionManager::RequestExtensionSessionActivation(const sptr<Ex
if (extSessionInfo == nullptr) {
return WSError::WS_ERROR_NULLPTR;
}
extSessionInfo->hostWindowId = hostWindowId;
auto errorCode = AAFwk::AbilityManagerClient::GetInstance()->StartUIExtensionAbility(extSessionInfo,
AAFwk::DEFAULT_INVAL_VALUE);
ret = (errorCode == ERR_OK) ? WSError::WS_OK : WSError::WS_ERROR_START_UI_EXTENSION_ABILITY_FAILED;

View File

@ -40,7 +40,6 @@ public:
WSError TransferPointerEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent) override;
WSError TransferFocusActiveEvent(bool isFocusActive) override;
WSError TransferKeyEventForConsumed(const std::shared_ptr<MMI::KeyEvent>& keyEvent, bool& isConsumed) override;
WSError TransferFocusWindowId(int32_t windowId) override;
WSError TransferFocusState(bool focusState) override;
sptr<IRemoteObject> AsObject() override
@ -64,11 +63,6 @@ WSError TestWindowEventChannel::TransferFocusActiveEvent(bool isFocusActive)
return WSError::WS_OK;
}
WSError TestWindowEventChannel::TransferFocusWindowId(int32_t windowId)
{
return WSError::WS_OK;
}
WSError TestWindowEventChannel::TransferKeyEventForConsumed(
const std::shared_ptr<MMI::KeyEvent>& keyEvent, bool& isConsumed)
{

View File

@ -39,13 +39,11 @@ public:
void NotifyFocusActiveEvent(bool isFocusActive) override;
void NotifyFocusStateEvent(bool focusState) override;
void NotifyFocusWindowIdEvent(int32_t windowId) override;
protected:
NotifyTransferComponentDataFunc notifyTransferComponentDataFunc_;
private:
std::atomic<int32_t> focusWindowId_ = INVALID_WINDOW_ID;
std::optional<std::atomic<bool>> focusState_ = std::nullopt;
};
} // namespace Rosen

View File

@ -124,14 +124,6 @@ WMError WindowExtensionSessionImpl::SetPrivacyMode(bool isPrivacyMode)
return WMError::WM_OK;
}
void WindowExtensionSessionImpl::NotifyFocusWindowIdEvent(int32_t windowId)
{
if (uiContent_) {
uiContent_->SetFocusWindowId(windowId);
}
focusWindowId_ = windowId;
}
void WindowExtensionSessionImpl::NotifyFocusStateEvent(bool focusState)
{
if (uiContent_) {
@ -164,7 +156,7 @@ WMError WindowExtensionSessionImpl::SetUIContent(const std::string& contentInfo,
WLOGFE("fail to SetUIContent id: %{public}d", GetPersistentId());
return WMError::WM_ERROR_NULLPTR;
}
uiContent->Initialize(this, contentInfo, storage, focusWindowId_);
uiContent->Initialize(this, contentInfo, storage, property_->GetParentId());
// make uiContent available after Initialize/Restore
uiContent_ = std::move(uiContent);