Merge pull request !1606 from 阿勒泰/master
This commit is contained in:
openharmony_ci
2022-05-05 01:13:46 +00:00
committed by Gitee
31 changed files with 570 additions and 105 deletions
@@ -271,7 +271,7 @@ public:
return 0;
}
virtual int RegisterWindowHandler(const sptr<IWindowHandler>& handler) override
virtual int RegisterWindowManagerServiceHandler(const sptr<IWindowManagerServiceHandler>& handler) override
{
return 0;
}
@@ -254,7 +254,7 @@ public:
return 0;
}
virtual int RegisterWindowHandler(const sptr<IWindowHandler>& handler) override
virtual int RegisterWindowManagerServiceHandler(const sptr<IWindowManagerServiceHandler>& handler) override
{
return 0;
}
@@ -231,7 +231,7 @@ public:
return 0;
}
virtual int RegisterWindowHandler(const sptr<IWindowHandler>& handler) override
virtual int RegisterWindowManagerServiceHandler(const sptr<IWindowManagerServiceHandler>& handler) override
{
return 0;
}
@@ -244,7 +244,7 @@ public:
return 0;
}
virtual int RegisterWindowHandler(const sptr<IWindowHandler>& handler) override
virtual int RegisterWindowManagerServiceHandler(const sptr<IWindowManagerServiceHandler>& handler) override
{
return 0;
}
@@ -86,6 +86,8 @@ ohos_shared_library("ability_manager") {
"${services_path}/abilitymgr/src/want_sender_proxy.cpp",
"${services_path}/abilitymgr/src/want_sender_stub.cpp",
"${services_path}/abilitymgr/src/wants_info.cpp",
"src/window_manager_service_handler_proxy.cpp",
"src/window_manager_service_handler_stub.cpp",
]
public_configs = [
@@ -538,13 +538,6 @@ public:
*/
ErrCode RegisterSnapshotHandler(const sptr<ISnapshotHandler>& handler);
/**
* @brief Register the window handler
* @param handler window handler
* @return ErrCode Returns ERR_OK on success, others on failure.
*/
ErrCode RegisterWindowHandler(const sptr<IWindowHandler>& handler);
/**
* Set mission label of this ability.
*
@@ -564,6 +557,13 @@ public:
*/
ErrCode SetMissionIcon(const sptr<IRemoteObject> &abilityToken,
const std::shared_ptr<OHOS::Media::PixelMap> &icon);
/**
* @brief Register the WMS handler
* @param handler WMS handler
* @return ErrCode Returns ERR_OK on success, others on failure.
*/
ErrCode RegisterWindowManagerServiceHandler(const sptr<IWindowManagerServiceHandler>& handler);
#endif
/**
@@ -22,28 +22,28 @@
#include <iremote_broker.h>
#include "ability_connect_callback_interface.h"
#include "ability_running_info.h"
#include "ability_scheduler_interface.h"
#include "ability_start_setting.h"
#include "foundation/aafwk/standard/interfaces/innerkits/app_manager/include/appmgr/configuration.h"
#include "mission_snapshot.h"
#include "ability_running_info.h"
#include "extension_running_info.h"
#include "uri.h"
#include "want.h"
#include "want_sender_info.h"
#include "sender_info.h"
#include "want_sender_interface.h"
#include "want_receiver_interface.h"
#include "system_memory_attr.h"
#include "system_memory_attr.h"
#include "foundation/aafwk/standard/interfaces/innerkits/app_manager/include/appmgr/configuration.h"
#include "iability_controller.h"
#include "mission_listener_interface.h"
#include "mission_info.h"
#include "mission_snapshot.h"
#include "remote_mission_listener_interface.h"
#include "running_process_info.h"
#include "sender_info.h"
#include "snapshot.h"
#include "start_options.h"
#include "stop_user_callback.h"
#include "running_process_info.h"
#include "remote_mission_listener_interface.h"
#include "iability_controller.h"
#include "system_memory_attr.h"
#include "want.h"
#include "want_receiver_interface.h"
#include "want_sender_info.h"
#include "want_sender_interface.h"
#include "uri.h"
#include "window_manager_service_handler.h"
namespace OHOS {
namespace AAFwk {
@@ -433,6 +433,8 @@ public:
#ifdef SUPPORT_GRAPHICS
virtual int SetMissionIcon(const sptr<IRemoteObject> &token,
const std::shared_ptr<OHOS::Media::PixelMap> &icon) = 0;
virtual int RegisterWindowManagerServiceHandler(const sptr<IWindowManagerServiceHandler>& handler) = 0;
#endif
virtual int GetAbilityRunningInfos(std::vector<AbilityRunningInfo> &info) = 0;
@@ -547,8 +549,6 @@ public:
*/
virtual int32_t GetMissionIdByToken(const sptr<IRemoteObject> &token) = 0;
virtual int RegisterWindowHandler(const sptr<IWindowHandler>& handler) = 0;
#ifdef ABILITY_COMMAND_FOR_TEST
/**
* Block ability manager service.
@@ -879,7 +879,7 @@ public:
DUMPSYS_STATE = 2002,
FORCE_TIMEOUT,
REGISTER_WINDOW_HANDLER = 2500,
REGISTER_WMS_HANDLER = 2500,
GET_TOP_ABILITY = 3000,
FREE_INSTALL_ABILITY_FROM_REMOTE = 3001,
@@ -66,23 +66,6 @@ public:
*/
virtual int32_t GetSnapshot(const sptr<IRemoteObject>& token, Snapshot& snapshot) = 0;
};
/**
* @class IWindowHandler
* Window handler, use to get window
*/
class IWindowHandler : public OHOS::IRemoteBroker {
public:
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.aafwk.WindowHandler");
/**
* @brief Get the Window object
* @param abilityToken ability token
* @return int32_t function result
*/
virtual int32_t GetFocusAbility(sptr<IRemoteObject>& abilityToken);
};
} // namespace AAFwk
} // namespace OHOS
#endif // OHOS_AAFWK_SNAPSHOT_H
@@ -0,0 +1,79 @@
/*
* Copyright (c) 2022 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_AAFWK_WINDOW_TRANSITION_INFO_H
#define OHOS_AAFWK_WINDOW_TRANSITION_INFO_H
#ifdef SUPPORT_GRAPHICS
#include <typeinfo>
#include "iremote_object.h"
#include "parcel.h"
namespace OHOS {
namespace AAFwk {
struct AbilityTransitionInfo : public Parcelable {
std::string bundleName_;
std::string abilityName_;
uint32_t mode_ = 1;
sptr<IRemoteObject> abilityToken_ = nullptr;
uint64_t displayId_ = 0;
bool isShowWhenLocked_ = false;
virtual bool Marshalling(Parcel& parcel) const override
{
if (!parcel.WriteString(bundleName_)) {
return false;
}
if (!parcel.WriteString(abilityName_)) {
return false;
}
if (!parcel.WriteUint32(mode_)) {
return false;
}
if (!parcel.WriteObject(abilityToken_)) {
return false;
}
if (!parcel.WriteUint64(displayId_)) {
return false;
}
if (!parcel.WriteBool(isShowWhenLocked_)) {
return false;
}
return true;
}
static AbilityTransitionInfo* Unmarshalling(Parcel& parcel)
{
AbilityTransitionInfo* info = new AbilityTransitionInfo();
info->bundleName_ = parcel.ReadString();
info->abilityName_ = parcel.ReadString();
info->mode_ = parcel.ReadUint32();
info->abilityToken_ = parcel.ReadObject<IRemoteObject>();
info->displayId_ = parcel.ReadUint64();
info->isShowWhenLocked_ = parcel.ReadBool();
return info;
}
};
} // namespace AAFwk
} // namespace OHOS
#endif
#endif // OHOS_AAFWK_WINDOW_TRANSITION_INFO_H
@@ -0,0 +1,43 @@
/*
* Copyright (c) 2022 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_AAFWK_WMS_HANDLER_H
#define OHOS_AAFWK_WMS_HANDLER_H
#ifdef SUPPORT_GRAPHICS
#include "iremote_broker.h"
#include "window_info.h"
namespace OHOS {
namespace AAFwk {
/**
* @class IWindowManagerServiceHandler
* Window Manager Service Handler, use to call methods of WMS
*/
class IWindowManagerServiceHandler : public OHOS::IRemoteBroker {
public:
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.aafwk.WindowManagerServiceHandler");
virtual void NotifyWindowTransition(sptr<AbilityTransitionInfo> fromInfo, sptr<AbilityTransitionInfo> toInfo) = 0;
enum WMSCmd {
// ipc id for NotifyWindowTransition
ON_NOTIFY_WINDOW_TRANSITION,
};
};
} // namespace AAFwk
} // namespace OHOS
#endif
#endif // OHOS_AAFWK_WMS_HANDLER_H
@@ -0,0 +1,39 @@
/*
* Copyright (c) 2022 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_AAFWK_WMS_HANDLER_PROXY_H
#define OHOS_AAFWK_WMS_HANDLER_PROXY_H
#ifdef SUPPORT_GRAPHICS
#include "iremote_proxy.h"
#include "window_manager_service_handler.h"
namespace OHOS {
namespace AAFwk {
class WindowManagerServiceHandlerProxy : public IRemoteProxy<IWindowManagerServiceHandler> {
public:
explicit WindowManagerServiceHandlerProxy(const sptr<IRemoteObject> &impl);
virtual ~WindowManagerServiceHandlerProxy() = default;
virtual void NotifyWindowTransition(sptr<AbilityTransitionInfo> fromInfo,
sptr<AbilityTransitionInfo> toInfo) override;
private:
static inline BrokerDelegator<WindowManagerServiceHandlerProxy> delegator_;
};
} // namespace AAFwk
} // namespace OHOS
#endif
#endif // OHOS_AAFWK_WMS_HANDLER_PROXY_H
@@ -0,0 +1,40 @@
/*
* Copyright (c) 2022 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_AAFWK_WMS_HANDLER_STUB_H
#define OHOS_AAFWK_WMS_HANDLER_STUB_H
#ifdef SUPPORT_GRAPHICS
#include "iremote_stub.h"
#include "message_parcel.h"
#include "nocopyable.h"
#include "window_manager_service_handler.h"
namespace OHOS {
namespace AAFwk {
class WindowManagerServiceHandlerStub : public IRemoteStub<IWindowManagerServiceHandler> {
public:
WindowManagerServiceHandlerStub() = default;
virtual ~WindowManagerServiceHandlerStub() = default;
int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
private:
DISALLOW_COPY_AND_MOVE(WindowManagerServiceHandlerStub);
};
} // namespace AAFwk
} // namespace OHOS
#endif
#endif // OHOS_AAFWK_WMS_HANDLER_STUB_H
@@ -0,0 +1,53 @@
/*
* Copyright (c) 2022 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.
*/
#ifdef SUPPORT_GRAPHICS
#include "window_manager_service_handler_proxy.h"
#include "hilog_wrapper.h"
#include "parcel.h"
namespace OHOS {
namespace AAFwk {
WindowManagerServiceHandlerProxy::WindowManagerServiceHandlerProxy(const sptr<IRemoteObject> &impl)
: IRemoteProxy<IWindowManagerServiceHandler>(impl) {}
void WindowManagerServiceHandlerProxy::NotifyWindowTransition(sptr<AbilityTransitionInfo> fromInfo,
sptr<AbilityTransitionInfo> toInfo)
{
HILOG_DEBUG("%{public}s is called.", __func__);
MessageParcel data;
if (!data.WriteInterfaceToken(IWindowManagerServiceHandler::GetDescriptor())) {
HILOG_ERROR("Write interface token failed.");
return;
}
if (!data.WriteParcelable(fromInfo.GetRefPtr())) {
HILOG_ERROR("Write fromInfo failed.");
return;
}
if (!data.WriteParcelable(toInfo.GetRefPtr())) {
HILOG_ERROR("Write toInfo failed.");
return;
}
MessageParcel reply;
MessageOption option;
int error = Remote()->SendRequest(WMSCmd::ON_NOTIFY_WINDOW_TRANSITION, data, reply, option);
if (error != ERR_OK) {
HILOG_ERROR("SendRequest fial, error: %{public}d", error);
}
}
} // namespace AAFwk
} // namespace OHOS
#endif
@@ -0,0 +1,55 @@
/*
* Copyright (c) 2022 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.
*/
#ifdef SUPPORT_GRAPHICS
#include "window_manager_service_handler_stub.h"
#include "hilog_wrapper.h"
namespace OHOS {
namespace AAFwk {
int WindowManagerServiceHandlerStub::OnRemoteRequest(
uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
{
if (data.ReadInterfaceToken() != IWindowManagerServiceHandler::GetDescriptor()) {
HILOG_ERROR("InterfaceToken not equal IWindowManagerServiceHandler's descriptor.");
return ERR_INVALID_VALUE;
}
ErrCode errCode = ERR_OK;
switch (code) {
case WMSCmd::ON_NOTIFY_WINDOW_TRANSITION : {
sptr<AbilityTransitionInfo> fromInfo(data.ReadParcelable<AbilityTransitionInfo>());
if (!fromInfo) {
errCode = ERR_DEAD_OBJECT;
HILOG_ERROR("To read fromInfo failed.");
break;
}
sptr<AbilityTransitionInfo> toInfo(data.ReadParcelable<AbilityTransitionInfo>());
if (!toInfo) {
errCode = ERR_DEAD_OBJECT;
HILOG_ERROR("To read toInfo failed.");
break;
}
NotifyWindowTransition(fromInfo, toInfo);
break;
}
default:
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
}
return errCode;
}
} // namespace AAFwk
} // namespace OHOS
#endif
@@ -63,6 +63,9 @@ const std::string SCREEN_LOCK_ABILITY_NAME = "com.ohos.screenlock.ServiceExtAbil
const std::string SCREEN_LOCK_BUNDLE_NAME = "com.ohos.screenlock";
const std::string PARAMS_STREAM = "ability.params.stream";
const std::string GRANT_ABILITY_BUNDLE_NAME = "com.ohos.permissionmanager";
const std::string GRANT_ABILITY_ABILITY_NAME = "com.ohos.permissionmanager.GrantAbility";
} // namespace AbilityConfig
} // namespace AAFwk
} // namespace OHOS
@@ -407,6 +407,8 @@ public:
#ifdef SUPPORT_GRAPHICS
virtual int SetMissionIcon(const sptr<IRemoteObject> &token,
const std::shared_ptr<OHOS::Media::PixelMap> &icon) override;
virtual int RegisterWindowManagerServiceHandler(const sptr<IWindowManagerServiceHandler>& handler) override;
#endif
virtual int GetAbilityRunningInfos(std::vector<AbilityRunningInfo> &info) override;
@@ -439,8 +441,6 @@ public:
virtual int RegisterSnapshotHandler(const sptr<ISnapshotHandler>& handler) override;
virtual int RegisterWindowHandler(const sptr<IWindowHandler>& handler) override;
virtual int GetMissionSnapshot(const std::string& deviceId, int32_t missionId, MissionSnapshot& snapshot) override;
virtual int StartUserTest(const Want &want, const sptr<IRemoteObject> &observer) override;
@@ -592,14 +592,16 @@ public:
#ifdef SUPPORT_GRAPHICS
virtual int SetMissionIcon(const sptr<IRemoteObject> &token,
const std::shared_ptr<OHOS::Media::PixelMap> &icon) override;
virtual int RegisterWindowManagerServiceHandler(const sptr<IWindowManagerServiceHandler>& handler) override;
sptr<IWindowManagerServiceHandler> GetWMSHandler() const;
#endif
void ClearUserData(int32_t userId);
virtual int RegisterSnapshotHandler(const sptr<ISnapshotHandler>& handler) override;
virtual int RegisterWindowHandler(const sptr<IWindowHandler>& handler) override;
virtual int32_t GetMissionSnapshot(const std::string& deviceId, int32_t missionId,
MissionSnapshot& snapshot) override;
@@ -1038,7 +1040,9 @@ private:
std::unordered_map<int, std::shared_ptr<MissionListManager>> missionListManagers_;
std::shared_ptr<MissionListManager> currentMissionListManager_;
sptr<IWindowHandler> windowHandler_;
#ifdef SUPPORT_GRAPHICS
sptr<IWindowManagerServiceHandler> wmsHandler_;
#endif
std::shared_ptr<UserController> userController_;
sptr<AppExecFwk::IAbilityController> abilityController_ = nullptr;
bool controllerIsAStabilityTest_ = false;
@@ -152,7 +152,9 @@ private:
int IsRunningInStabilityTestInner(MessageParcel &data, MessageParcel &reply);
int MoveMissionToFrontByOptionsInner(MessageParcel &data, MessageParcel &reply);
int RegisterWindowHandlerInner(MessageParcel &data, MessageParcel &reply);
#ifdef SUPPORT_GRAPHICS
int RegisterWindowManagerServiceHandlerInner(MessageParcel &data, MessageParcel &reply);
#endif
#ifdef ABILITY_COMMAND_FOR_TEST
int ForceTimeoutForTestInner(MessageParcel &data, MessageParcel &reply);
@@ -29,6 +29,9 @@
#include "snapshot.h"
#include "start_options.h"
#include "want.h"
#ifdef SUPPORT_GRAPHICS
#include "window_manager_service_handler.h"
#endif
namespace OHOS {
namespace AAFwk {
@@ -432,6 +435,18 @@ private:
void AddUninstallTags(const std::string &bundleName, int32_t uid);
#ifdef SUPPORT_GRAPHICS
void NotifyAnimationFromRecentTask(const std::shared_ptr<AbilityRecord> &abilityRecord,
const std::shared_ptr<StartOptions> &startOptions, const Want &want) const;
void NotifyAnimationFromStartingAbility(const std::shared_ptr<AbilityRecord> &callerAbility,
const AbilityRequest &abilityRequest, const std::shared_ptr<AbilityRecord> &targetAbilityRecord) const;
void SetShowWhenLocked(const AppExecFwk::AbilityInfo &abilityInfo, sptr<AbilityTransitionInfo> &info) const;
void SetAbilityTransitionInfo(const AppExecFwk::AbilityInfo &abilityInfo, sptr<AbilityTransitionInfo> &info,
const std::shared_ptr<AbilityRecord> &abilityRecord) const;
void SetWindowModeAndDisplayId(sptr<AbilityTransitionInfo> &info, const Want &want) const;
sptr<IWindowManagerServiceHandler> GetWMSHandler() const;
#endif
private:
int userId_;
mutable std::recursive_mutex managerLock_;
@@ -659,13 +659,6 @@ ErrCode AbilityManagerClient::RegisterSnapshotHandler(const sptr<ISnapshotHandle
return abms->RegisterSnapshotHandler(handler);
}
ErrCode AbilityManagerClient::RegisterWindowHandler(const sptr<IWindowHandler>& handler)
{
auto abms = GetAbilityManager();
CHECK_POINTER_RETURN_NOT_CONNECTED(abms);
return abms->RegisterWindowHandler(handler);
}
ErrCode AbilityManagerClient::GetMissionSnapshot(const std::string& deviceId, int32_t missionId,
MissionSnapshot& snapshot)
{
@@ -725,6 +718,13 @@ ErrCode AbilityManagerClient::SetMissionIcon(
CHECK_POINTER_RETURN_NOT_CONNECTED(abms);
return abms->SetMissionIcon(abilityToken, icon);
}
ErrCode AbilityManagerClient::RegisterWindowManagerServiceHandler(const sptr<IWindowManagerServiceHandler>& handler)
{
auto abms = GetAbilityManager();
CHECK_POINTER_RETURN_NOT_CONNECTED(abms);
return abms->RegisterWindowManagerServiceHandler(handler);
}
#endif
ErrCode AbilityManagerClient::DoAbilityForeground(const sptr<IRemoteObject> &token, uint32_t flag)
@@ -1757,6 +1757,31 @@ int AbilityManagerProxy::SetMissionIcon(const sptr<IRemoteObject> &token,
}
return reply.ReadInt32();
}
int AbilityManagerProxy::RegisterWindowManagerServiceHandler(const sptr<IWindowManagerServiceHandler>& handler)
{
if (!handler) {
HILOG_ERROR("%{public}s: handler is nullptr.", __func__);
return INNER_ERR;
}
MessageParcel data;
if (!WriteInterfaceToken(data)) {
HILOG_ERROR("%{public}s: write interface token failed.", __func__);
return INNER_ERR;
}
if (!data.WriteRemoteObject(handler->AsObject())) {
HILOG_ERROR("%{public}s: handler write failed.", __func__);
return INNER_ERR;
}
MessageOption option;
MessageParcel reply;
auto error = Remote()->SendRequest(IAbilityManager::REGISTER_WMS_HANDLER, data, reply, option);
if (error != NO_ERROR) {
HILOG_ERROR("%{public}s: send request error: %{public}d", __func__, error);
return error;
}
return reply.ReadInt32();
}
#endif
int AbilityManagerProxy::GetAbilityRunningInfos(std::vector<AbilityRunningInfo> &info)
@@ -2012,26 +2037,6 @@ int AbilityManagerProxy::RegisterSnapshotHandler(const sptr<ISnapshotHandler>& h
return reply.ReadInt32();
}
int AbilityManagerProxy::RegisterWindowHandler(const sptr<IWindowHandler>& handler)
{
MessageParcel data;
MessageParcel reply;
MessageOption option;
if (!WriteInterfaceToken(data)) {
return INNER_ERR;
}
if (!data.WriteRemoteObject(handler->AsObject())) {
HILOG_ERROR("window: handler write failed.");
return INNER_ERR;
}
auto error = Remote()->SendRequest(IAbilityManager::REGISTER_WINDOW_HANDLER, data, reply, option);
if (error != NO_ERROR) {
HILOG_ERROR("window: send request error: %{public}d", error);
return error;
}
return reply.ReadInt32();
}
int AbilityManagerProxy::SetAbilityController(const sptr<AppExecFwk::IAbilityController> &abilityController,
bool imAStabilityTest)
{
@@ -3273,6 +3273,23 @@ int AbilityManagerService::SetMissionIcon(const sptr<IRemoteObject> &token,
return missionListManager->SetMissionIcon(token, icon);
}
int AbilityManagerService::RegisterWindowManagerServiceHandler(const sptr<IWindowManagerServiceHandler> &handler)
{
auto isSaCall = AAFwk::PermissionVerification::GetInstance()->IsSACall();
if (!isSaCall) {
HILOG_ERROR("%{public}s: Permission verification failed", __func__);
return CHECK_PERMISSION_FAILED;
}
wmsHandler_ = handler;
HILOG_DEBUG("%{public}s: WMS handler registered successfully.", __func__);
return ERR_OK;
}
sptr<IWindowManagerServiceHandler> AbilityManagerService::GetWMSHandler() const
{
return wmsHandler_;
}
#endif
int AbilityManagerService::StartUser(int userId)
@@ -3388,18 +3405,6 @@ int AbilityManagerService::RegisterSnapshotHandler(const sptr<ISnapshotHandler>&
return ERR_OK;
}
int AbilityManagerService::RegisterWindowHandler(const sptr<IWindowHandler> &handler)
{
auto isSaCall = AAFwk::PermissionVerification::GetInstance()->IsSACall();
if (!isSaCall) {
HILOG_ERROR("%{public}s: Permission verification failed", __func__);
return 0;
}
windowHandler_ = handler;
HILOG_INFO("window: AbilityManagerService register windows handler success.");
return ERR_OK;
}
int32_t AbilityManagerService::GetMissionSnapshot(const std::string& deviceId, int32_t missionId,
MissionSnapshot& missionSnapshot)
{
@@ -138,8 +138,10 @@ void AbilityManagerStub::ThirdStepInit()
requestFuncMap_[GET_MISSION_ID_BY_ABILITY_TOKEN] = &AbilityManagerStub::GetMissionIdByTokenInner;
requestFuncMap_[GET_TOP_ABILITY] = &AbilityManagerStub::GetTopAbilityInner;
requestFuncMap_[SET_MISSION_ICON] = &AbilityManagerStub::SetMissionIconInner;
requestFuncMap_[REGISTER_WINDOW_HANDLER] = &AbilityManagerStub::RegisterWindowHandlerInner;
requestFuncMap_[DUMP_ABILITY_INFO_DONE] = &AbilityManagerStub::DumpAbilityInfoDoneInner;
#ifdef SUPPORT_GRAPHICS
requestFuncMap_[REGISTER_WMS_HANDLER] = &AbilityManagerStub::RegisterWindowManagerServiceHandlerInner;
#endif
}
int AbilityManagerStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
@@ -1182,17 +1184,17 @@ int AbilityManagerStub::RegisterSnapshotHandlerInner(MessageParcel &data, Messag
return result;
}
int AbilityManagerStub::RegisterWindowHandlerInner(MessageParcel &data, MessageParcel &reply)
#ifdef SUPPORT_GRAPHICS
int AbilityManagerStub::RegisterWindowManagerServiceHandlerInner(MessageParcel &data, MessageParcel &reply)
{
sptr<IWindowHandler> handler = iface_cast<IWindowHandler>(data.ReadRemoteObject());
sptr<IWindowManagerServiceHandler> handler = iface_cast<IWindowManagerServiceHandler>(data.ReadRemoteObject());
if (handler == nullptr) {
HILOG_ERROR("window: AbilityManagerStub read window handler failed!");
HILOG_ERROR("%{public}s read WMS handler failed!", __func__);
return ERR_NULL_OBJECT;
}
int32_t result = RegisterWindowHandler(handler);
HILOG_INFO("window: AbilityManagerStub register window handler result = %{public}d", result);
return result;
return RegisterWindowManagerServiceHandler(handler);
}
#endif
int AbilityManagerStub::GetMissionSnapshotInfoInner(MessageParcel &data, MessageParcel &reply)
{
@@ -34,6 +34,7 @@ constexpr char EVENT_KEY_PACKAGE_NAME[] = "PACKAGE_NAME";
constexpr char EVENT_KEY_PROCESS_NAME[] = "PROCESS_NAME";
constexpr uint32_t NEXTABILITY_TIMEOUT = 1000; // ms
constexpr uint64_t NANO_SECOND_PER_SEC = 1000000000; // ns
const std::string SHOW_ON_LOCK_SCREEN = "ShowOnLockScreen";
std::string GetCurrentTime()
{
struct timespec tn;
@@ -41,7 +42,8 @@ std::string GetCurrentTime()
uint64_t uTime = static_cast<uint64_t>(tn.tv_sec) * NANO_SECOND_PER_SEC + tn.tv_nsec;
return std::to_string(uTime);
}
}
} // namespace
MissionListManager::MissionListManager(int userId) : userId_(userId) {}
MissionListManager::~MissionListManager() {}
@@ -183,6 +185,18 @@ int MissionListManager::MoveMissionToFront(int32_t missionId, bool isCallerFromL
if (startOptions != nullptr) {
targetAbilityRecord->SetWindowMode(startOptions->GetWindowMode());
}
#ifdef SUPPORT_GRAPHICS
InnerMissionInfo innerMissionInfo;
int getMission = DelayedSingleton<MissionInfoMgr>::GetInstance()->GetInnerMissionInfoById(
missionId, innerMissionInfo);
if (getMission != ERR_OK) {
HILOG_ERROR("cannot find mission info from MissionInfoList by missionId: %{public}d", missionId);
return MOVE_MISSION_FAILED;
}
NotifyAnimationFromRecentTask(targetAbilityRecord, startOptions, innerMissionInfo.missionInfo.want);
#endif
// schedule target ability to foreground.
targetAbilityRecord->ProcessForegroundAbility();
HILOG_DEBUG("SetMovingState, missionId: %{public}d", missionId);
@@ -245,6 +259,7 @@ int MissionListManager::StartAbilityLocked(const std::shared_ptr<AbilityRecord>
HILOG_ERROR("Failed to get mission or record.");
return ERR_INVALID_VALUE;
}
if (abilityRequest.IsContinuation()) {
targetAbilityRecord->SetLaunchReason(LaunchReason::LAUNCHREASON_CONTINUATION);
} else {
@@ -259,6 +274,13 @@ int MissionListManager::StartAbilityLocked(const std::shared_ptr<AbilityRecord>
// 4. move target list to top
MoveMissionListToTop(targetList);
#ifdef SUPPORT_GRAPHICS
auto state = targetAbilityRecord->GetAbilityState();
if (state != AbilityState::FOREGROUND && state != AbilityState::FOREGROUNDING) {
NotifyAnimationFromStartingAbility(callerAbility, abilityRequest, targetAbilityRecord);
}
#endif
// 5. schedule target ability
if (!currentTopAbility) {
// top ability is null, then launch the first Ability.
@@ -1908,6 +1930,119 @@ int MissionListManager::SetMissionIcon(const sptr<IRemoteObject> &token, const s
return 0;
}
void MissionListManager::SetShowWhenLocked(const AppExecFwk::AbilityInfo &abilityInfo,
sptr<AbilityTransitionInfo> &info) const
{
bool showOnLockScreen = false;
std::vector<AppExecFwk::CustomizeData> datas = abilityInfo.metaData.customizeData;
for (AppExecFwk::CustomizeData data : datas) {
if (data.name == SHOW_ON_LOCK_SCREEN) {
showOnLockScreen = true;
}
}
if (showOnLockScreen) {
info->isShowWhenLocked_ = true;
}
}
sptr<IWindowManagerServiceHandler> MissionListManager::GetWMSHandler() const
{
auto abilityMgr = DelayedSingleton<AbilityManagerService>::GetInstance();
if (!abilityMgr) {
HILOG_WARN("%{public}s, Get Ability Manager Service failed.", __func__);
return nullptr;
}
return abilityMgr->GetWMSHandler();
}
void MissionListManager::SetAbilityTransitionInfo(const AppExecFwk::AbilityInfo &abilityInfo,
sptr<AbilityTransitionInfo> &info, const std::shared_ptr<AbilityRecord> &abilityRecord) const
{
info->abilityName_ = abilityInfo.name;
info->bundleName_ = abilityInfo.bundleName;
info->abilityToken_ = abilityRecord->GetToken();
SetShowWhenLocked(abilityInfo, info);
}
void MissionListManager::SetWindowModeAndDisplayId(sptr<AbilityTransitionInfo> &info, const Want &want) const
{
auto mode = want.GetIntParam(Want::PARAM_RESV_WINDOW_MODE, -1);
auto displayId = want.GetIntParam(Want::PARAM_RESV_DISPLAY_ID, -1);
if (mode != -1) {
info->mode_ = static_cast<uint32_t>(mode);
}
if (displayId != -1) {
info->displayId_ = static_cast<uint64_t>(displayId);
}
}
void MissionListManager::NotifyAnimationFromRecentTask(const std::shared_ptr<AbilityRecord> &abilityRecord,
const std::shared_ptr<StartOptions> &startOptions, const Want &want) const
{
auto abilityInfo = abilityRecord->GetAbilityInfo();
if (abilityInfo.name == AbilityConfig::GRANT_ABILITY_ABILITY_NAME &&
abilityInfo.bundleName == AbilityConfig::GRANT_ABILITY_BUNDLE_NAME) {
HILOG_INFO("%{public}s, ignore GrantAbility.", __func__);
return;
}
auto windowHandler = GetWMSHandler();
if (!windowHandler) {
HILOG_WARN("%{public}s, Get WMS handler failed.", __func__);
return;
}
sptr<AbilityTransitionInfo> toInfo = new AbilityTransitionInfo();
if (startOptions != nullptr) {
toInfo->mode_ = static_cast<uint32_t>(startOptions->GetWindowMode());
toInfo->displayId_ = static_cast<uint64_t>(startOptions->GetDisplayID());
} else {
SetWindowModeAndDisplayId(toInfo, want);
}
SetAbilityTransitionInfo(abilityInfo, toInfo, abilityRecord);
sptr<AbilityTransitionInfo> fromInfo = new AbilityTransitionInfo();
windowHandler->NotifyWindowTransition(fromInfo, toInfo);
}
void MissionListManager::NotifyAnimationFromStartingAbility(const std::shared_ptr<AbilityRecord> &callerAbility,
const AbilityRequest &abilityRequest, const std::shared_ptr<AbilityRecord> &targetAbilityRecord) const
{
auto abilityInfo = abilityRequest.abilityInfo;
if (abilityInfo.name == AbilityConfig::GRANT_ABILITY_ABILITY_NAME &&
abilityInfo.bundleName == AbilityConfig::GRANT_ABILITY_BUNDLE_NAME) {
HILOG_INFO("%{public}s, ignore GrantAbility.", __func__);
return;
}
auto windowHandler = GetWMSHandler();
if (!windowHandler) {
HILOG_WARN("%{public}s, Get WMS handler failed.", __func__);
return;
}
sptr<AbilityTransitionInfo> fromInfo = new AbilityTransitionInfo();
if (callerAbility) {
auto callerAbilityInfo = callerAbility->GetAbilityInfo();
SetAbilityTransitionInfo(callerAbilityInfo, fromInfo, callerAbility);
} else {
fromInfo->abilityToken_ = abilityRequest.callerToken;
}
sptr<AbilityTransitionInfo> toInfo = new AbilityTransitionInfo();
auto abilityStartSetting = abilityRequest.startSetting;
if (abilityStartSetting) {
auto mode = std::stoi(abilityStartSetting->GetProperty(AbilityStartSetting::WINDOW_MODE_KEY));
toInfo->mode_ = static_cast<uint32_t>(mode);
auto displayId = std::stoi(abilityStartSetting->GetProperty(AbilityStartSetting::WINDOW_DISPLAY_ID_KEY));
toInfo->displayId_ = static_cast<uint64_t>(displayId);
} else {
SetWindowModeAndDisplayId(toInfo, abilityRequest.want);
}
SetAbilityTransitionInfo(abilityInfo, toInfo, targetAbilityRecord);
windowHandler->NotifyWindowTransition(fromInfo, toInfo);
}
#endif
void MissionListManager::Dump(std::vector<std::string> &info)
@@ -220,7 +220,7 @@ public:
return 0;
}
virtual int RegisterWindowHandler(const sptr<IWindowHandler>& handler) override
virtual int RegisterWindowManagerServiceHandler(const sptr<IWindowManagerServiceHandler>& handler) override
{
return 0;
}
@@ -220,7 +220,7 @@ public:
return 0;
}
virtual int RegisterWindowHandler(const sptr<IWindowHandler>& handler) override
virtual int RegisterWindowManagerServiceHandler(const sptr<IWindowManagerServiceHandler>& handler) override
{
return 0;
}
@@ -291,7 +291,7 @@ public:
return 0;
}
virtual int RegisterWindowHandler(const sptr<IWindowHandler>& handler) override
virtual int RegisterWindowManagerServiceHandler(const sptr<IWindowManagerServiceHandler>& handler) override
{
return 0;
}
@@ -130,7 +130,7 @@ public:
return 0;
}
virtual int RegisterWindowHandler(const sptr<IWindowHandler>& handler) override
virtual int RegisterWindowManagerServiceHandler(const sptr<IWindowManagerServiceHandler>& handler) override
{
return 0;
}
@@ -679,7 +679,7 @@ public:
return 0;
}
virtual int RegisterWindowHandler(const sptr<IWindowHandler>& handler) override
virtual int RegisterWindowManagerServiceHandler(const sptr<IWindowManagerServiceHandler>& handler) override
{
return 0;
}
@@ -163,7 +163,7 @@ public:
return 0;
}
virtual int RegisterWindowHandler(const sptr<IWindowHandler>& handler) override
virtual int RegisterWindowManagerServiceHandler(const sptr<IWindowManagerServiceHandler>& handler) override
{
return 0;
}
+1 -1
View File
@@ -182,7 +182,7 @@ public:
return 0;
}
virtual int RegisterWindowHandler(const sptr<IWindowHandler>& handler) override
virtual int RegisterWindowManagerServiceHandler(const sptr<IWindowManagerServiceHandler>& handler) override
{
return 0;
}