mirror of
https://github.com/openharmony/ability_ability_runtime.git
synced 2026-08-24 12:43:16 -04:00
add mission move mission to background
Signed-off-by: unknown <sijunjie@huawei.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2023 Huawei Device Co., Ltd.
|
||||
* 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
|
||||
@@ -59,6 +59,8 @@ public:
|
||||
*/
|
||||
virtual void OnMissionMovedToFront(int32_t missionId) = 0;
|
||||
|
||||
virtual void OnMissionMovedToBackground(int32_t missionId) {};
|
||||
|
||||
/**
|
||||
* @brief When the ability focused, AbilityMs notifies the listener of the mission id
|
||||
*
|
||||
@@ -125,6 +127,9 @@ public:
|
||||
// ipc id for OnMissionUnfocused
|
||||
ON_MISSION_UNFOCUSED,
|
||||
|
||||
// ipc id for OnMissionMovedToBackground
|
||||
ON_MISSION_MOVED_TO_BACKGROUND,
|
||||
|
||||
// maximum of enum
|
||||
MISSION_LINSTENER_CMD_MAX
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2023 Huawei Device Co., Ltd.
|
||||
* 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
|
||||
@@ -58,6 +58,8 @@ public:
|
||||
*/
|
||||
virtual void OnMissionMovedToFront(int32_t missionId) override;
|
||||
|
||||
virtual void OnMissionMovedToBackground(int32_t missionId) override;
|
||||
|
||||
/**
|
||||
* @brief Sends OnMissionFocused request.
|
||||
*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2023 Huawei Device Co., Ltd.
|
||||
* 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
|
||||
@@ -44,6 +44,7 @@ private:
|
||||
int OnMissionDestroyedInner(MessageParcel &data, MessageParcel &reply);
|
||||
int OnMissionSnapshotChangedInner(MessageParcel &data, MessageParcel &reply);
|
||||
int OnMissionMovedToFrontInner(MessageParcel &data, MessageParcel &reply);
|
||||
int OnMissionMovedToBackgroundInner(MessageParcel &data, MessageParcel &reply);
|
||||
int OnMissionIconUpdatedInner(MessageParcel &data, MessageParcel &reply);
|
||||
int OnMissionClosedInner(MessageParcel &data, MessageParcel &reply);
|
||||
int OnMissionLabelUpdatedInner(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2024 Huawei Device Co., Ltd.
|
||||
* 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
|
||||
@@ -39,6 +39,11 @@ void MissionListenerProxy::OnMissionMovedToFront(int32_t missionId)
|
||||
SendRequestCommon(missionId, IMissionListener::ON_MISSION_MOVED_TO_FRONT);
|
||||
}
|
||||
|
||||
void MissionListenerProxy::OnMissionMovedToBackground(int32_t missionId)
|
||||
{
|
||||
SendRequestCommon(missionId, IMissionListener::ON_MISSION_MOVED_TO_BACKGROUND);
|
||||
}
|
||||
|
||||
void MissionListenerProxy::OnMissionFocused(int32_t missionId)
|
||||
{
|
||||
SendRequestCommon(missionId, IMissionListener::ON_MISSION_FOCUSED);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2024 Huawei Device Co., Ltd.
|
||||
* 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
|
||||
@@ -49,6 +49,13 @@ int MissionListenerStub::OnMissionMovedToFrontInner(MessageParcel &data, Message
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
int MissionListenerStub::OnMissionMovedToBackgroundInner(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
auto missionId = data.ReadInt32();
|
||||
OnMissionMovedToBackground(missionId);
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
int MissionListenerStub::OnMissionFocusedInner(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
auto missionId = data.ReadInt32();
|
||||
@@ -126,6 +133,8 @@ int MissionListenerStub::OnRemoteRequest(
|
||||
case ON_MISSION_UNFOCUSED:
|
||||
return OnMissionUnfocusedInner(data, reply);
|
||||
break;
|
||||
case ON_MISSION_MOVED_TO_BACKGROUND:
|
||||
return OnMissionMovedToBackgroundInner(data, reply);
|
||||
}
|
||||
}
|
||||
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2024-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
|
||||
@@ -67,6 +67,11 @@ public:
|
||||
isMissionMovedToFront_ = true;
|
||||
}
|
||||
|
||||
void OnMissionMovedToBackground(int32_t missionId) override
|
||||
{
|
||||
isMissionMovedToBackground_ = true;
|
||||
}
|
||||
|
||||
void OnMissionIconUpdated(int32_t missionId, const std::shared_ptr<OHOS::Media::PixelMap>& icon) override
|
||||
{
|
||||
isMissionIconUpdated_ = true;
|
||||
@@ -122,6 +127,7 @@ private:
|
||||
bool isMissionDestroyed_ = false;
|
||||
bool isMissionSnapshotChanged_ = false;
|
||||
bool isMissionMovedToFront_ = false;
|
||||
bool isMissionMovedToBackground_ = false;
|
||||
bool isMissionIconUpdated_ = false;
|
||||
bool isMissionClosed_ = false;
|
||||
bool isMissionLabelUpdated_ = false;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2024-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
|
||||
@@ -44,6 +44,8 @@ public:
|
||||
{}
|
||||
void OnMissionMovedToFront(int32_t missionId) override
|
||||
{}
|
||||
void OnMissionMovedToBackground(int32_t missionId) override
|
||||
{}
|
||||
void OnMissionIconUpdated(int32_t missionId, const std::shared_ptr<OHOS::Media::PixelMap>& icon) override
|
||||
{}
|
||||
void OnMissionClosed(int32_t missionId) override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2024-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
|
||||
@@ -38,6 +38,7 @@ public:
|
||||
void OnMissionDestroyed(int32_t missionId) override {};
|
||||
void OnMissionSnapshotChanged(int32_t missionId) override {};
|
||||
void OnMissionMovedToFront(int32_t missionId) override {};
|
||||
void OnMissionMovedToBackground(int32_t missionId) override {};
|
||||
void OnMissionClosed(int32_t missionId) override {};
|
||||
void OnMissionLabelUpdated(int32_t missionId) override {};
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2024-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
|
||||
@@ -38,6 +38,7 @@ public:
|
||||
void OnMissionDestroyed(int32_t missionId) override {};
|
||||
void OnMissionSnapshotChanged(int32_t missionId) override {};
|
||||
void OnMissionMovedToFront(int32_t missionId) override {};
|
||||
void OnMissionMovedToBackground(int32_t missionId) override {};
|
||||
void OnMissionClosed(int32_t missionId) override {};
|
||||
void OnMissionLabelUpdated(int32_t missionId) override {};
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022-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
|
||||
@@ -109,6 +109,13 @@ HWTEST_F(MissionListenerProxyTest, OnMissionMovedToFront_001, TestSize.Level1)
|
||||
EXPECT_TRUE(proxy_ != nullptr);
|
||||
}
|
||||
|
||||
HWTEST_F(MissionListenerProxyTest, OnMissionMovedToBackground_001, TestSize.Level1)
|
||||
{
|
||||
int32_t missionId = 0;
|
||||
proxy_->OnMissionMovedToBackground(missionId);
|
||||
EXPECT_TRUE(proxy_ != nullptr);
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
/*
|
||||
* Feature: MissionListenerProxy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* 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
|
||||
@@ -43,6 +43,7 @@ public:
|
||||
virtual void OnMissionDestroyed(int32_t missionId) {}
|
||||
virtual void OnMissionSnapshotChanged(int32_t missionId) {}
|
||||
virtual void OnMissionMovedToFront(int32_t missionId) {}
|
||||
virtual void OnMissionMovedToBackground(int32_t missionId) {}
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
virtual void OnMissionIconUpdated(int32_t missionId, const std::shared_ptr<OHOS::Media::PixelMap> &icon) {}
|
||||
#endif
|
||||
|
||||
@@ -166,5 +166,20 @@ HWTEST_F(MissionListenerStubSecondTest, OnRemoteRequest_008, TestSize.Level1)
|
||||
int res = stub_->OnRemoteRequest(IMissionListener::ON_MISSION_UNFOCUSED, data, reply, option);
|
||||
EXPECT_EQ(res, NO_ERROR);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: OnRemoteRequest_009
|
||||
* Function: OnRemoteRequest
|
||||
* SubFunction: NA
|
||||
*/
|
||||
HWTEST_F(MissionListenerStubSecondTest, OnRemoteRequest_009, TestSize.Level1)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
WriteInterfaceToken(data);
|
||||
int res = stub_->OnRemoteRequest(IMissionListener::ON_MISSION_MOVED_TO_BACKGROUND, data, reply, option);
|
||||
EXPECT_EQ(res, NO_ERROR);
|
||||
}
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -33,6 +33,7 @@ public:
|
||||
MOCK_METHOD1(OnMissionDestroyed, void(int32_t missionId));
|
||||
MOCK_METHOD1(OnMissionSnapshotChanged, void(int32_t missionId));
|
||||
MOCK_METHOD1(OnMissionMovedToFront, void(int32_t missionId));
|
||||
MOCK_METHOD1(OnMissionMovedToBackground, void(int32_t missionId));
|
||||
MOCK_METHOD2(OnMissionIconUpdated, void(int32_t missionId, const std::shared_ptr<OHOS::Media::PixelMap>& icon));
|
||||
MOCK_METHOD1(OnMissionClosed, void(int32_t missionId));
|
||||
MOCK_METHOD1(OnMissionLabelUpdated, void(int32_t missionId));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* 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
|
||||
@@ -169,6 +169,15 @@ HWTEST_F(MissionListenerStubTest, MissionListenerStubTest_OnMissionMovedToFrontI
|
||||
EXPECT_EQ(res, NO_ERROR);
|
||||
}
|
||||
|
||||
HWTEST_F(MissionListenerStubTest, MissionListenerStubTest_OnMissionMovedToBackgroundInner_001, TestSize.Level1)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
EXPECT_CALL(*stub_, OnMissionMovedToBackground(_)).Times(1).WillOnce(Return());
|
||||
int res = stub_->OnMissionMovedToBackgroundInner(data, reply);
|
||||
EXPECT_EQ(res, NO_ERROR);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: MissionListenerStub
|
||||
* Function: OnMissionIconUpdatedInner
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* 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
|
||||
@@ -33,6 +33,7 @@ public:
|
||||
MOCK_METHOD1(OnMissionDestroyed, void(int32_t missionId));
|
||||
MOCK_METHOD1(OnMissionSnapshotChanged, void(int32_t missionId));
|
||||
MOCK_METHOD1(OnMissionMovedToFront, void(int32_t missionId));
|
||||
MOCK_METHOD1(OnMissionMovedToBackground, void(int32_t missionId));
|
||||
MOCK_METHOD2(OnMissionIconUpdated, void(int32_t missionId, const std::shared_ptr<OHOS::Media::PixelMap>& icon));
|
||||
MOCK_METHOD1(OnMissionClosed, void(int32_t missionId));
|
||||
MOCK_METHOD1(OnMissionLabelUpdated, void(int32_t missionId));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022-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
|
||||
@@ -53,6 +53,11 @@ public:
|
||||
isMissionMovedToFront_ = true;
|
||||
}
|
||||
|
||||
void OnMissionMovedToBackground(int32_t missionId) override
|
||||
{
|
||||
isMissionMovedToBackground_ = true;
|
||||
}
|
||||
|
||||
void OnMissionIconUpdated(int32_t missionId, const std::shared_ptr<OHOS::Media::PixelMap>& icon) override
|
||||
{
|
||||
isMissionIconUpdated_ = true;
|
||||
@@ -108,6 +113,7 @@ private:
|
||||
bool isMissionDestroyed_ = false;
|
||||
bool isMissionSnapshotChanged_ = false;
|
||||
bool isMissionMovedToFront_ = false;
|
||||
bool isMissionMovedToBackground_ = false;
|
||||
bool isMissionIconUpdated_ = false;
|
||||
bool isMissionClosed_ = false;
|
||||
bool isMissionLabelUpdated_ = false;
|
||||
|
||||
Reference in New Issue
Block a user