mirror of
https://github.com/openharmony/aafwk_standard.git
synced 2026-07-01 20:04:39 -04:00
Signed-off-by: zhoushicheng2@huawei.com <zhoushicheng2@huawei.com> Change-Id: Ia08d2d34ba0ffa09f6d1cd66a99eb8fc87d715b9
This commit is contained in:
@@ -17,7 +17,7 @@ multimedia_path = "//foundation/multimedia/image_standard"
|
||||
services_path = "//foundation/aafwk/standard/services"
|
||||
multimodalinput_path = "//foundation/multimodalinput/input"
|
||||
windowmanager_path = "//foundation/windowmanager"
|
||||
graphic_path = "//foundation/graphic/graphic"
|
||||
graphic_path = "//foundation/graphic/graphic_2d"
|
||||
global_path = "//base/global"
|
||||
distributedschedule_path = "//foundation/distributedschedule"
|
||||
notification_path = "//base/notification"
|
||||
|
||||
@@ -1417,10 +1417,8 @@ WantParams *WantParams::Unmarshalling(Parcel &parcel)
|
||||
|
||||
void WantParams::DumpInfo(int level) const
|
||||
{
|
||||
int typeId = VALUE_TYPE_NULL;
|
||||
for (auto it : params_) {
|
||||
typeId = VALUE_TYPE_NULL;
|
||||
typeId = WantParams::GetDataType(it.second);
|
||||
int typeId = WantParams::GetDataType(it.second);
|
||||
if (typeId != VALUE_TYPE_NULL) {
|
||||
std::string value = WantParams::GetStringByType(it.second, typeId);
|
||||
ABILITYBASE_LOGI("=WantParams[%{public}s]:%{private}s =======", it.first.c_str(), value.c_str());
|
||||
|
||||
@@ -42,7 +42,6 @@
|
||||
"input",
|
||||
"multimedia_image_standard",
|
||||
"os_account",
|
||||
"power_manager_native",
|
||||
"safwk",
|
||||
"samgr_standard",
|
||||
"utils_base"
|
||||
|
||||
@@ -101,7 +101,6 @@ ohos_shared_library("libfms") {
|
||||
"hisysevent_native:libhisysevent",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"power_manager_native:powermgr_client",
|
||||
"safwk:system_ability_fwk",
|
||||
"samgr_standard:samgr_proxy",
|
||||
"time_native:time_service",
|
||||
@@ -116,6 +115,12 @@ ohos_shared_library("libfms") {
|
||||
]
|
||||
}
|
||||
|
||||
defines = []
|
||||
if (ability_runtime_power) {
|
||||
defines = [ "SUPPORT_POWER" ]
|
||||
external_deps += [ "power_manager_native:powermgr_client" ]
|
||||
}
|
||||
|
||||
subsystem_name = "aafwk"
|
||||
part_name = "form_runtime"
|
||||
}
|
||||
|
||||
@@ -48,7 +48,6 @@
|
||||
#include "ipc_skeleton.h"
|
||||
#include "iservice_registry.h"
|
||||
#include "ohos_account_kits.h"
|
||||
#include "power_mgr_client.h"
|
||||
#include "system_ability_definition.h"
|
||||
|
||||
namespace OHOS {
|
||||
|
||||
@@ -29,8 +29,9 @@
|
||||
#include "form_refresh_connection.h"
|
||||
#include "form_timer_mgr.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#ifdef SUPPORT_POWER
|
||||
#include "power_mgr_client.h"
|
||||
|
||||
#endif
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
FormProviderMgr::FormProviderMgr(){}
|
||||
@@ -133,12 +134,14 @@ ErrCode FormProviderMgr::RefreshForm(const int64_t formId, const Want &want, boo
|
||||
FormDataMgr::GetInstance().SetCountTimerRefresh(formId, true);
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_POWER
|
||||
bool screenOnFlag = PowerMgr::PowerMgrClient::GetInstance().IsScreenOn();
|
||||
if (!screenOnFlag) {
|
||||
FormDataMgr::GetInstance().SetNeedRefresh(formId, true);
|
||||
HILOG_ERROR("%{public}s fail, screen off, set refresh flag, do not refresh now", __func__);
|
||||
return ERR_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool needRefresh = IsNeedToFresh(record, formId, isVisibleToFresh);
|
||||
if (!needRefresh) {
|
||||
@@ -313,6 +316,7 @@ ErrCode FormProviderMgr::UpdateForm(const int64_t formId,
|
||||
// update form for host clients
|
||||
FormDataMgr::GetInstance().UpdateHostNeedRefresh(formId, true);
|
||||
|
||||
#ifdef SUPPORT_POWER
|
||||
bool screenOnFlag = PowerMgr::PowerMgrClient::GetInstance().IsScreenOn();
|
||||
if (screenOnFlag) {
|
||||
if (FormDataMgr::GetInstance().UpdateHostForm(formId, formRecord)) {
|
||||
@@ -320,9 +324,13 @@ ErrCode FormProviderMgr::UpdateForm(const int64_t formId,
|
||||
formRecord.formProviderInfo.SetUpgradeFlg(false);
|
||||
}
|
||||
}
|
||||
|
||||
HILOG_DEBUG("%{public}s screenOn:%{public}d.", __func__, screenOnFlag);
|
||||
#endif
|
||||
|
||||
// check if cache data size is less than 1k or not
|
||||
std::string jsonData = formRecord.formProviderInfo.GetFormDataString(); // get json data
|
||||
HILOG_DEBUG("%{public}s screenOn:%{public}d jsonData:%{public}s.", __func__, screenOnFlag, jsonData.c_str());
|
||||
HILOG_DEBUG("%{public}s jsonData:%{public}s.", __func__, jsonData.c_str());
|
||||
|
||||
std::map<std::string, std::pair<sptr<Ashmem>, int32_t>> imageDataMap = formProviderData.GetImageDataMap();
|
||||
// check if cache data size is less than 1k or not
|
||||
@@ -347,11 +355,13 @@ int FormProviderMgr::MessageEvent(const int64_t formId, const FormRecord &record
|
||||
{
|
||||
HILOG_INFO("%{public}s called, formId:%{public}" PRId64 ".", __func__, formId);
|
||||
|
||||
#ifdef SUPPORT_POWER
|
||||
bool screenOnFlag = PowerMgr::PowerMgrClient::GetInstance().IsScreenOn();
|
||||
if (!screenOnFlag) {
|
||||
HILOG_WARN("%{public}s fail, screen off now", __func__);
|
||||
return ERR_APPEXECFWK_FORM_COMMON_CODE;
|
||||
}
|
||||
#endif
|
||||
|
||||
sptr<IAbilityConnection> formMsgEventConnection = new FormMsgEventConnection(formId, want,
|
||||
record.bundleName, record.abilityName);
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "form_timer_option.h"
|
||||
#include "form_util.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "in_process_call_wrapper.h"
|
||||
#ifdef OS_ACCOUNT_PART_ENABLED
|
||||
#include "os_account_manager.h"
|
||||
#endif // OS_ACCOUNT_PART_ENABLED
|
||||
@@ -930,7 +931,7 @@ std::shared_ptr<WantAgent> FormTimerMgr::GetUpdateAtWantAgent(long updateAtTime,
|
||||
wants.emplace_back(want);
|
||||
WantAgentInfo wantAgentInfo(REQUEST_UPDATE_AT_CODE, WantAgentConstant::OperationType::SEND_COMMON_EVENT,
|
||||
WantAgentConstant::Flags::UPDATE_PRESENT_FLAG, wants, nullptr);
|
||||
return WantAgentHelper::GetWantAgent(wantAgentInfo, userId);
|
||||
return IN_PROCESS_CALL(WantAgentHelper::GetWantAgent(wantAgentInfo, userId));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1043,7 +1044,7 @@ std::shared_ptr<WantAgent> FormTimerMgr::GetLimiterWantAgent()
|
||||
wants.emplace_back(want);
|
||||
WantAgentInfo wantAgentInfo(REQUEST_LIMITER_CODE, WantAgentConstant::OperationType::SEND_COMMON_EVENT,
|
||||
WantAgentConstant::Flags::UPDATE_PRESENT_FLAG, wants, nullptr);
|
||||
return WantAgentHelper::GetWantAgent(wantAgentInfo);
|
||||
return IN_PROCESS_CALL(WantAgentHelper::GetWantAgent(wantAgentInfo));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1118,7 +1119,7 @@ std::shared_ptr<WantAgent> FormTimerMgr::GetDynamicWantAgent(int64_t nextTime, i
|
||||
wants.emplace_back(want);
|
||||
WantAgentInfo wantAgentInfo(REQUEST_DYNAMIC_CODE, WantAgentConstant::OperationType::SEND_COMMON_EVENT,
|
||||
WantAgentConstant::Flags::UPDATE_PRESENT_FLAG, wants, nullptr);
|
||||
return WantAgentHelper::GetWantAgent(wantAgentInfo, userId);
|
||||
return IN_PROCESS_CALL(WantAgentHelper::GetWantAgent(wantAgentInfo, userId));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
# limitations under the License.
|
||||
|
||||
import("//build/test.gni")
|
||||
import("//foundation/aafwk/standard/aafwk.gni")
|
||||
import("//foundation/aafwk/standard/form_runtime/form_runtime.gni")
|
||||
|
||||
module_output_path = "form_runtime/formmgrservice"
|
||||
@@ -71,8 +72,12 @@ ohos_unittest("FmsFormMgrMessageEventTest") {
|
||||
"form_runtime:form_manager",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"power_manager_native:powermgr_client",
|
||||
]
|
||||
|
||||
if (ability_runtime_power) {
|
||||
defines = [ "SUPPORT_POWER" ]
|
||||
external_deps += [ "power_manager_native:powermgr_client" ]
|
||||
}
|
||||
}
|
||||
|
||||
group("unittest") {
|
||||
|
||||
+4
-1
@@ -32,7 +32,9 @@
|
||||
#include "mock_ability_manager.h"
|
||||
#include "mock_bundle_manager.h"
|
||||
#include "mock_form_host_client.h"
|
||||
#ifdef SUPPORT_POWER
|
||||
#include "power_mgr_client.h"
|
||||
#endif
|
||||
#include "running_process_info.h"
|
||||
#include "system_ability_definition.h"
|
||||
|
||||
@@ -133,13 +135,14 @@ HWTEST_F(FmsFormMgrMessageEventTest, MessageEvent_001, TestSize.Level0)
|
||||
want.SetElementName(DEVICE_ID, FORM_PROVIDER_BUNDLE_NAME, FORM_PROVIDER_ABILITY_NAME);
|
||||
want.SetParam(Constants::PARAM_MESSAGE_KEY, FORM_MESSAGE_EVENT_VALUE_1);
|
||||
|
||||
#ifdef SUPPORT_POWER
|
||||
bool screenOnFlag = PowerMgr::PowerMgrClient::GetInstance().IsScreenOn();
|
||||
if (!screenOnFlag) {
|
||||
EXPECT_EQ(ERR_APPEXECFWK_FORM_COMMON_CODE, FormMgr::GetInstance().MessageEvent(formId, want, token_));
|
||||
} else {
|
||||
EXPECT_EQ(ERR_OK, FormMgr::GetInstance().MessageEvent(formId, want, token_));
|
||||
}
|
||||
|
||||
#endif
|
||||
GTEST_LOG_(INFO) << "fms_form_mgr_message_event_test_001 end";
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
# limitations under the License.
|
||||
|
||||
import("//build/test.gni")
|
||||
import("//foundation/aafwk/standard/aafwk.gni")
|
||||
import("//foundation/aafwk/standard/form_runtime/form_runtime.gni")
|
||||
|
||||
module_output_path = "form_runtime/formmgrservice"
|
||||
@@ -71,8 +72,12 @@ ohos_unittest("FmsFormProviderMgrTest") {
|
||||
"form_runtime:form_manager",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"power_manager_native:powermgr_client",
|
||||
]
|
||||
|
||||
if (ability_runtime_power) {
|
||||
defines = [ "SUPPORT_POWER" ]
|
||||
external_deps += [ "power_manager_native:powermgr_client" ]
|
||||
}
|
||||
}
|
||||
|
||||
group("unittest") {
|
||||
|
||||
@@ -34,7 +34,9 @@
|
||||
#include "mock_ability_manager.h"
|
||||
#include "mock_bundle_manager.h"
|
||||
#include "mock_form_host_client.h"
|
||||
#ifdef SUPPORT_POWER
|
||||
#include "power_mgr_client.h"
|
||||
#endif
|
||||
#include "running_process_info.h"
|
||||
#include "system_ability_definition.h"
|
||||
|
||||
@@ -213,6 +215,7 @@ HWTEST_F(FmsFormProviderMgrTest, RefreshForm_002, TestSize.Level0)
|
||||
FormRecord realFormRecord = FormDataMgr::GetInstance().AllotFormRecord(record, callingUid);
|
||||
FormItemInfo info;
|
||||
FormDataMgr::GetInstance().AllotFormHostRecord(info, token_, formId, callingUid);
|
||||
#ifdef SUPPORT_POWER
|
||||
bool screenOnFlag = PowerMgr::PowerMgrClient::GetInstance().IsScreenOn();
|
||||
if (!screenOnFlag) {
|
||||
EXPECT_EQ(ERR_OK, FormProviderMgr::GetInstance().RefreshForm(formId, want, true));
|
||||
@@ -220,6 +223,7 @@ HWTEST_F(FmsFormProviderMgrTest, RefreshForm_002, TestSize.Level0)
|
||||
EXPECT_EQ(ERR_APPEXECFWK_FORM_PROVIDER_DEL_FAIL, FormProviderMgr::GetInstance().RefreshForm(formId, want,
|
||||
true));
|
||||
}
|
||||
#endif
|
||||
|
||||
GTEST_LOG_(INFO) << "fms_form_mgr_provider_test_005 end";
|
||||
}
|
||||
|
||||
@@ -230,24 +230,6 @@ public:
|
||||
*/
|
||||
virtual ErrCode ReleaseAbility(const std::shared_ptr<CallerCallBack> &callback) = 0;
|
||||
|
||||
/**
|
||||
* @brief Set mission label of this ability.
|
||||
*
|
||||
* @param label the label of this ability.
|
||||
* @return Returns ERR_OK if success.
|
||||
*/
|
||||
virtual ErrCode SetMissionLabel(const std::string &label) = 0;
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
/**
|
||||
* @brief Set mission icon of this ability.
|
||||
*
|
||||
* @param icon the icon of this ability.
|
||||
* @return Returns ERR_OK if success.
|
||||
*/
|
||||
virtual ErrCode SetMissionIcon(const std::shared_ptr<OHOS::Media::PixelMap> &icon) = 0;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Get LocalCallContainer.
|
||||
*
|
||||
@@ -258,7 +240,24 @@ public:
|
||||
virtual void SetConfiguration(const std::shared_ptr<AppExecFwk::Configuration> &config) = 0;
|
||||
|
||||
virtual void RegisterAbilityCallback(std::weak_ptr<AppExecFwk::IAbilityCallback> abilityCallback) = 0;
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
/**
|
||||
* @brief Set mission label of this ability.
|
||||
*
|
||||
* @param label the label of this ability.
|
||||
* @return Returns ERR_OK if success.
|
||||
*/
|
||||
virtual ErrCode SetMissionLabel(const std::string &label) = 0;
|
||||
|
||||
/**
|
||||
* @brief Set mission icon of this ability.
|
||||
*
|
||||
* @param icon the icon of this ability.
|
||||
* @return Returns ERR_OK if success.
|
||||
*/
|
||||
virtual ErrCode SetMissionIcon(const std::shared_ptr<OHOS::Media::PixelMap> &icon) = 0;
|
||||
|
||||
virtual int GetCurrentWindowMode() = 0;
|
||||
#endif
|
||||
virtual bool IsTerminating() = 0;
|
||||
|
||||
@@ -86,24 +86,6 @@ public:
|
||||
|
||||
ErrCode RestoreWindowStage(NativeEngine& engine, NativeValue* contentStorage) override;
|
||||
|
||||
/**
|
||||
* @brief Set mission label of this ability.
|
||||
*
|
||||
* @param label the label of this ability.
|
||||
* @return Returns ERR_OK if success.
|
||||
*/
|
||||
ErrCode SetMissionLabel(const std::string &label) override;
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
/**
|
||||
* @brief Set mission icon of this ability.
|
||||
*
|
||||
* @param icon the icon of this ability.
|
||||
* @return Returns ERR_OK if success.
|
||||
*/
|
||||
ErrCode SetMissionIcon(const std::shared_ptr<OHOS::Media::PixelMap> &icon) override;
|
||||
#endif
|
||||
|
||||
void SetStageContext(const std::shared_ptr<AbilityRuntime::Context> &stageContext);
|
||||
|
||||
/**
|
||||
@@ -183,6 +165,22 @@ public:
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
/**
|
||||
* @brief Set mission label of this ability.
|
||||
*
|
||||
* @param label the label of this ability.
|
||||
* @return Returns ERR_OK if success.
|
||||
*/
|
||||
ErrCode SetMissionLabel(const std::string &label) override;
|
||||
|
||||
/**
|
||||
* @brief Set mission icon of this ability.
|
||||
*
|
||||
* @param icon the icon of this ability.
|
||||
* @return Returns ERR_OK if success.
|
||||
*/
|
||||
ErrCode SetMissionIcon(const std::shared_ptr<OHOS::Media::PixelMap> &icon) override;
|
||||
|
||||
/**
|
||||
* get current window mode
|
||||
*/
|
||||
|
||||
@@ -459,6 +459,13 @@ ErrCode AbilityContextImpl::ReleaseAbility(const std::shared_ptr<CallerCallBack>
|
||||
return localCallContainer_->Release(callback);
|
||||
}
|
||||
|
||||
void AbilityContextImpl::RegisterAbilityCallback(std::weak_ptr<AppExecFwk::IAbilityCallback> abilityCallback)
|
||||
{
|
||||
HILOG_INFO("%{public}s called.", __func__);
|
||||
abilityCallback_ = abilityCallback;
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
ErrCode AbilityContextImpl::SetMissionLabel(const std::string &label)
|
||||
{
|
||||
HILOG_INFO("%{public}s begin. label = %{public}s", __func__, label.c_str());
|
||||
@@ -469,7 +476,6 @@ ErrCode AbilityContextImpl::SetMissionLabel(const std::string &label)
|
||||
return err;
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
ErrCode AbilityContextImpl::SetMissionIcon(const std::shared_ptr<OHOS::Media::PixelMap> &icon)
|
||||
{
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
@@ -479,15 +485,7 @@ ErrCode AbilityContextImpl::SetMissionIcon(const std::shared_ptr<OHOS::Media::Pi
|
||||
}
|
||||
return err;
|
||||
}
|
||||
#endif
|
||||
|
||||
void AbilityContextImpl::RegisterAbilityCallback(std::weak_ptr<AppExecFwk::IAbilityCallback> abilityCallback)
|
||||
{
|
||||
HILOG_INFO("%{public}s called.", __func__);
|
||||
abilityCallback_ = abilityCallback;
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
int AbilityContextImpl::GetCurrentWindowMode()
|
||||
{
|
||||
HILOG_INFO("%{public}s called.", __func__);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -97,38 +97,6 @@ public:
|
||||
// Page Service Ability has different AbilityTransaction
|
||||
virtual void HandleAbilityTransaction(const Want &want, const AAFwk::LifeCycleStateInfo &targetState);
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
/**
|
||||
* @brief Execution the KeyDown callback of the ability
|
||||
* @param keyEvent Indicates the key-down event.
|
||||
*
|
||||
* @return Returns true if this event is handled and will not be passed further; returns false if this event is
|
||||
* not handled and should be passed to other handlers.
|
||||
*
|
||||
*/
|
||||
virtual void DoKeyDown(const std::shared_ptr<MMI::KeyEvent>& keyEvent);
|
||||
|
||||
/**
|
||||
* @brief Execution the KeyUp callback of the ability
|
||||
* @param keyEvent Indicates the key-up event.
|
||||
*
|
||||
* @return Returns true if this event is handled and will not be passed further; returns false if this event is
|
||||
* not handled and should be passed to other handlers.
|
||||
*
|
||||
*/
|
||||
virtual void DoKeyUp(const std::shared_ptr<MMI::KeyEvent>& keyEvent);
|
||||
|
||||
/**
|
||||
* @brief Called when a touch event is dispatched to this ability. The default implementation of this callback
|
||||
* does nothing and returns false.
|
||||
* @param touchEvent Indicates information about the touch event.
|
||||
*
|
||||
* @return Returns true if the event is handled; returns false otherwise.
|
||||
*
|
||||
*/
|
||||
virtual void DoPointerEvent(std::shared_ptr<MMI::PointerEvent>& pointerEvent);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Send the result code and data to be returned by this Page ability to the caller.
|
||||
* When a Page ability is destroyed, the caller overrides the AbilitySlice#onAbilityResult(int, int, Want)
|
||||
@@ -345,9 +313,57 @@ public:
|
||||
bool IsStageBasedModel() const;
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
public:
|
||||
/**
|
||||
* @brief Execution the KeyDown callback of the ability
|
||||
* @param keyEvent Indicates the key-down event.
|
||||
*
|
||||
* @return Returns true if this event is handled and will not be passed further; returns false if this event is
|
||||
* not handled and should be passed to other handlers.
|
||||
*
|
||||
*/
|
||||
virtual void DoKeyDown(const std::shared_ptr<MMI::KeyEvent>& keyEvent);
|
||||
|
||||
/**
|
||||
* @brief Execution the KeyUp callback of the ability
|
||||
* @param keyEvent Indicates the key-up event.
|
||||
*
|
||||
* @return Returns true if this event is handled and will not be passed further; returns false if this event is
|
||||
* not handled and should be passed to other handlers.
|
||||
*
|
||||
*/
|
||||
virtual void DoKeyUp(const std::shared_ptr<MMI::KeyEvent>& keyEvent);
|
||||
|
||||
/**
|
||||
* @brief Called when a touch event is dispatched to this ability. The default implementation of this callback
|
||||
* does nothing and returns false.
|
||||
* @param touchEvent Indicates information about the touch event.
|
||||
*
|
||||
* @return Returns true if the event is handled; returns false otherwise.
|
||||
*
|
||||
*/
|
||||
virtual void DoPointerEvent(std::shared_ptr<MMI::PointerEvent>& pointerEvent);
|
||||
|
||||
void AfterUnFocused();
|
||||
void AfterFocused();
|
||||
|
||||
protected:
|
||||
/**
|
||||
* @brief Toggles the lifecycle status of Ability to AAFwk::ABILITY_STATE_INACTIVE. And notifies the application
|
||||
* that it belongs to of the lifecycle status.
|
||||
*
|
||||
* @param want The Want object to switch the life cycle.
|
||||
*/
|
||||
void Foreground(const Want &want);
|
||||
|
||||
/**
|
||||
* @brief Toggles the lifecycle status of Ability to AAFwk::ABILITY_STATE_BACKGROUND. And notifies the
|
||||
* application that it belongs to of the lifecycle status.
|
||||
*
|
||||
*/
|
||||
void Background();
|
||||
#endif
|
||||
|
||||
protected:
|
||||
/**
|
||||
* @brief Toggles the lifecycle status of Ability to AAFwk::ABILITY_STATE_INACTIVE. And notifies the application
|
||||
@@ -378,23 +394,6 @@ protected:
|
||||
*/
|
||||
void Inactive();
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
/**
|
||||
* @brief Toggles the lifecycle status of Ability to AAFwk::ABILITY_STATE_INACTIVE. And notifies the application
|
||||
* that it belongs to of the lifecycle status.
|
||||
*
|
||||
* @param want The Want object to switch the life cycle.
|
||||
*/
|
||||
void Foreground(const Want &want);
|
||||
|
||||
/**
|
||||
* @brief Toggles the lifecycle status of Ability to AAFwk::ABILITY_STATE_BACKGROUND. And notifies the
|
||||
* application that it belongs to of the lifecycle status.
|
||||
*
|
||||
*/
|
||||
void Background();
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief SerUriString
|
||||
*/
|
||||
@@ -430,7 +429,24 @@ protected:
|
||||
std::shared_ptr<AbilityHandler> handler_;
|
||||
|
||||
private:
|
||||
typedef enum {
|
||||
START,
|
||||
INACTIVE,
|
||||
ACTIVE,
|
||||
BACKGROUND,
|
||||
FOREGROUND,
|
||||
STOP,
|
||||
} Action;
|
||||
|
||||
std::shared_ptr<AbilityLifecycleCallbacks> abilityLifecycleCallbacks_;
|
||||
std::shared_ptr<ApplicationImpl> applicationImpl_;
|
||||
std::shared_ptr<ContextDeal> contextDeal_;
|
||||
bool hasSaveData_ = false;
|
||||
bool needSaveDate_ = false;
|
||||
PacMap restoreData_;
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
private:
|
||||
class WindowLifeCycleImpl : public Rosen::IWindowLifeCycle {
|
||||
public:
|
||||
WindowLifeCycleImpl(const sptr<IRemoteObject>& token, const std::shared_ptr<AbilityImpl>& owner)
|
||||
@@ -456,23 +472,6 @@ private:
|
||||
std::shared_ptr<AbilityImpl> abilityImpl_;
|
||||
};
|
||||
#endif
|
||||
typedef enum {
|
||||
START,
|
||||
INACTIVE,
|
||||
ACTIVE,
|
||||
BACKGROUND,
|
||||
FOREGROUND,
|
||||
STOP,
|
||||
} Action;
|
||||
|
||||
std::shared_ptr<AbilityLifecycleCallbacks> abilityLifecycleCallbacks_;
|
||||
std::shared_ptr<ApplicationImpl> applicationImpl_;
|
||||
std::shared_ptr<ContextDeal> contextDeal_;
|
||||
|
||||
private:
|
||||
bool hasSaveData_ = false;
|
||||
bool needSaveDate_ = false;
|
||||
PacMap restoreData_;
|
||||
};
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -46,14 +46,6 @@ public:
|
||||
|
||||
void OnStart(const Want &want) override;
|
||||
void OnStop() override;
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
void OnSceneCreated() override;
|
||||
void onSceneDestroyed() override;
|
||||
void OnSceneRestored() override;
|
||||
|
||||
void OnForeground(const Want &want) override;
|
||||
void OnBackground() override;
|
||||
#endif
|
||||
int32_t OnContinue(WantParams &wantParams) override;
|
||||
void OnConfigurationUpdated(const Configuration &configuration) override;
|
||||
void UpdateContextConfiguration() override;
|
||||
@@ -73,17 +65,26 @@ public:
|
||||
*/
|
||||
virtual void Dump(const std::vector<std::string> ¶ms, std::vector<std::string> &info) override;
|
||||
|
||||
protected:
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
public:
|
||||
void OnSceneCreated() override;
|
||||
void onSceneDestroyed() override;
|
||||
void OnSceneRestored() override;
|
||||
|
||||
void OnForeground(const Want &want) override;
|
||||
void OnBackground() override;
|
||||
|
||||
protected:
|
||||
void DoOnForeground(const Want &want) override;
|
||||
void RequsetFocus(const Want &want) override;
|
||||
|
||||
private:
|
||||
void GetPageStackFromWant(const Want &want, std::string &pageStack);
|
||||
#endif
|
||||
|
||||
private:
|
||||
void CallObjectMethod(const char *name, NativeValue *const *argv = nullptr, size_t argc = 0);
|
||||
std::unique_ptr<NativeReference> CreateAppWindowStage();
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
void GetPageStackFromWant(const Want &want, std::string &pageStack);
|
||||
#endif
|
||||
std::shared_ptr<AppExecFwk::ADelegatorAbilityProperty> CreateADelegatorAbilityProperty();
|
||||
|
||||
JsRuntime &jsRuntime_;
|
||||
|
||||
@@ -54,13 +54,8 @@ public:
|
||||
static NativeValue* TerminateSelfWithResult(NativeEngine* engine, NativeCallbackInfo* info);
|
||||
static NativeValue* RequestPermissionsFromUser(NativeEngine* engine, NativeCallbackInfo* info);
|
||||
static NativeValue* RestoreWindowStage(NativeEngine* engine, NativeCallbackInfo* info);
|
||||
static NativeValue* SetMissionLabel(NativeEngine* engine, NativeCallbackInfo* info);
|
||||
static NativeValue* IsTerminating(NativeEngine* engine, NativeCallbackInfo* info);
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
static NativeValue* SetMissionIcon(NativeEngine* engine, NativeCallbackInfo* info);
|
||||
#endif
|
||||
|
||||
static void ConfigurationUpdated(NativeEngine* engine, std::shared_ptr<NativeReference> &jsContext,
|
||||
const std::shared_ptr<AppExecFwk::Configuration> &config);
|
||||
|
||||
@@ -69,6 +64,16 @@ public:
|
||||
return context_.lock();
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
public:
|
||||
static NativeValue* SetMissionLabel(NativeEngine* engine, NativeCallbackInfo* info);
|
||||
static NativeValue* SetMissionIcon(NativeEngine* engine, NativeCallbackInfo* info);
|
||||
|
||||
private:
|
||||
NativeValue* OnSetMissionLabel(NativeEngine& engine, NativeCallbackInfo& info);
|
||||
NativeValue* OnSetMissionIcon(NativeEngine& engine, NativeCallbackInfo& info);
|
||||
#endif
|
||||
|
||||
private:
|
||||
NativeValue* OnStartAbility(NativeEngine& engine, NativeCallbackInfo& info);
|
||||
NativeValue* OnStartAbilityWithAccount(NativeEngine& engine, NativeCallbackInfo& info);
|
||||
@@ -86,13 +91,8 @@ private:
|
||||
NativeValue* OnTerminateSelf(NativeEngine& engine, NativeCallbackInfo& info);
|
||||
NativeValue* OnRequestPermissionsFromUser(NativeEngine& engine, NativeCallbackInfo& info);
|
||||
NativeValue* OnRestoreWindowStage(NativeEngine& engine, NativeCallbackInfo& info);
|
||||
NativeValue* OnSetMissionLabel(NativeEngine& engine, NativeCallbackInfo& info);
|
||||
NativeValue* OnIsTerminating(NativeEngine& engine, NativeCallbackInfo& info);
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
NativeValue* OnSetMissionIcon(NativeEngine& engine, NativeCallbackInfo& info);
|
||||
#endif
|
||||
|
||||
static bool UnWrapWant(NativeEngine& engine, NativeValue* argv, AAFwk::Want& want);
|
||||
static NativeValue* WrapWant(NativeEngine& engine, const AAFwk::Want& want);
|
||||
static bool UnWrapAbilityResult(NativeEngine& engine, NativeValue* argv, int& resultCode, AAFwk::Want& want);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -182,160 +182,6 @@ bool AbilityImpl::IsStageBasedModel() const
|
||||
return isStageBasedModel_;
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
void AbilityImpl::AfterUnFocused()
|
||||
{
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
if (!ability_ || !ability_->GetAbilityInfo() || !contextDeal_ || !handler_) {
|
||||
HILOG_ERROR("AbilityImpl::AfterUnFocused failed");
|
||||
return;
|
||||
}
|
||||
|
||||
if (ability_->GetAbilityInfo()->isStageBasedModel) {
|
||||
HILOG_INFO("new version ability, do nothing when after unfocused.");
|
||||
return;
|
||||
}
|
||||
|
||||
HILOG_INFO("old version ability, window after unfocused.");
|
||||
auto task = [abilityImpl = shared_from_this(), ability = ability_, contextDeal = contextDeal_]() {
|
||||
auto info = contextDeal->GetLifeCycleStateInfo();
|
||||
info.state = AbilityLifeCycleState::ABILITY_STATE_INACTIVE;
|
||||
info.isNewWant = false;
|
||||
Want want(*(ability->GetWant()));
|
||||
abilityImpl->HandleAbilityTransaction(want, info);
|
||||
};
|
||||
handler_->PostTask(task);
|
||||
HILOG_INFO("%{public}s end.", __func__);
|
||||
}
|
||||
|
||||
void AbilityImpl::AfterFocused()
|
||||
{
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
if (!ability_ || !ability_->GetAbilityInfo() || !contextDeal_ || !handler_) {
|
||||
HILOG_ERROR("AbilityImpl::AfterFocused failed");
|
||||
return;
|
||||
}
|
||||
|
||||
if (ability_->GetAbilityInfo()->isStageBasedModel) {
|
||||
HILOG_INFO("new version ability, do nothing when after focused.");
|
||||
return;
|
||||
}
|
||||
|
||||
HILOG_INFO("fa mode ability, window after focused.");
|
||||
auto task = [abilityImpl = shared_from_this(), ability = ability_, contextDeal = contextDeal_]() {
|
||||
auto info = contextDeal->GetLifeCycleStateInfo();
|
||||
info.state = AbilityLifeCycleState::ABILITY_STATE_ACTIVE;
|
||||
info.isNewWant = false;
|
||||
Want want(*(ability->GetWant()));
|
||||
abilityImpl->HandleAbilityTransaction(want, info);
|
||||
};
|
||||
handler_->PostTask(task);
|
||||
HILOG_INFO("%{public}s end.", __func__);
|
||||
}
|
||||
|
||||
void AbilityImpl::WindowLifeCycleImpl::AfterForeground()
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
auto owner = owner_.lock();
|
||||
if (owner && !owner->IsStageBasedModel()) {
|
||||
return;
|
||||
}
|
||||
|
||||
HILOG_INFO("Stage mode ability, window after foreground, notify ability manager service.");
|
||||
PacMap restoreData;
|
||||
AbilityManagerClient::GetInstance()->AbilityTransitionDone(token_,
|
||||
AbilityLifeCycleState::ABILITY_STATE_FOREGROUND_NEW, restoreData);
|
||||
}
|
||||
|
||||
void AbilityImpl::WindowLifeCycleImpl::AfterBackground()
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
auto owner = owner_.lock();
|
||||
if (owner && !owner->IsStageBasedModel()) {
|
||||
return;
|
||||
}
|
||||
|
||||
HILOG_INFO("new version ability, window after background.");
|
||||
PacMap restoreData;
|
||||
AbilityManagerClient::GetInstance()->AbilityTransitionDone(token_,
|
||||
AbilityLifeCycleState::ABILITY_STATE_BACKGROUND_NEW, restoreData);
|
||||
}
|
||||
|
||||
void AbilityImpl::WindowLifeCycleImpl::AfterFocused()
|
||||
{
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
auto owner = owner_.lock();
|
||||
if (owner) {
|
||||
owner->AfterFocused();
|
||||
}
|
||||
HILOG_INFO("%{public}s end.", __func__);
|
||||
}
|
||||
|
||||
void AbilityImpl::WindowLifeCycleImpl::AfterUnfocused()
|
||||
{
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
auto owner = owner_.lock();
|
||||
if (owner) {
|
||||
owner->AfterUnFocused();
|
||||
}
|
||||
HILOG_INFO("%{public}s end.", __func__);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Toggles the lifecycle status of Ability to AAFwk::ABILITY_STATE_INACTIVE. And notifies the application
|
||||
* that it belongs to of the lifecycle status.
|
||||
*
|
||||
* @param want The Want object to switch the life cycle.
|
||||
*/
|
||||
void AbilityImpl::Foreground(const Want &want)
|
||||
{
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
if (ability_ == nullptr || ability_->GetAbilityInfo() == nullptr || abilityLifecycleCallbacks_ == nullptr) {
|
||||
HILOG_ERROR("AbilityImpl::Foreground ability_ or abilityLifecycleCallbacks_ is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
HILOG_INFO("AbilityImpl::Foreground");
|
||||
ability_->OnForeground(want);
|
||||
if ((ability_->GetAbilityInfo()->type == AppExecFwk::AbilityType::PAGE) &&
|
||||
(ability_->GetAbilityInfo()->isStageBasedModel)) {
|
||||
lifecycleState_ = AAFwk::ABILITY_STATE_FOREGROUND_NEW;
|
||||
} else {
|
||||
lifecycleState_ = AAFwk::ABILITY_STATE_INACTIVE;
|
||||
}
|
||||
abilityLifecycleCallbacks_->OnAbilityForeground(ability_);
|
||||
HILOG_INFO("%{public}s end.", __func__);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Toggles the lifecycle status of Ability to AAFwk::ABILITY_STATE_BACKGROUND. And notifies the application
|
||||
* that it belongs to of the lifecycle status.
|
||||
*
|
||||
*/
|
||||
void AbilityImpl::Background()
|
||||
{
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
if (ability_ == nullptr || ability_->GetAbilityInfo() == nullptr || abilityLifecycleCallbacks_ == nullptr) {
|
||||
HILOG_ERROR("AbilityImpl::Background ability_ or abilityLifecycleCallbacks_ is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
HILOG_INFO("AbilityImpl::Background");
|
||||
ability_->OnLeaveForeground();
|
||||
ability_->OnBackground();
|
||||
if ((ability_->GetAbilityInfo()->type == AppExecFwk::AbilityType::PAGE) &&
|
||||
(ability_->GetAbilityInfo()->isStageBasedModel)) {
|
||||
lifecycleState_ = AAFwk::ABILITY_STATE_BACKGROUND_NEW;
|
||||
} else {
|
||||
lifecycleState_ = AAFwk::ABILITY_STATE_BACKGROUND;
|
||||
}
|
||||
abilityLifecycleCallbacks_->OnAbilityBackground(ability_);
|
||||
HILOG_INFO("%{public}s end.", __func__);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Save data and states of an ability when it is restored by the system. and Calling information back to Ability.
|
||||
* This method should be implemented by a Page ability.
|
||||
@@ -450,47 +296,6 @@ int AbilityImpl::GetCurrentState()
|
||||
return lifecycleState_;
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
/**
|
||||
* @brief Execution the KeyDown callback of the ability
|
||||
* @param keyEvent Indicates the key-down event.
|
||||
*
|
||||
* @return Returns true if this event is handled and will not be passed further; returns false if this event is
|
||||
* not handled and should be passed to other handlers.
|
||||
*
|
||||
*/
|
||||
void AbilityImpl::DoKeyDown(const std::shared_ptr<MMI::KeyEvent>& keyEvent)
|
||||
{
|
||||
HILOG_INFO("AbilityImpl::DoKeyDown called");
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Execution the KeyUp callback of the ability
|
||||
* @param keyEvent Indicates the key-up event.
|
||||
*
|
||||
* @return Returns true if this event is handled and will not be passed further; returns false if this event is
|
||||
* not handled and should be passed to other handlers.
|
||||
*
|
||||
*/
|
||||
void AbilityImpl::DoKeyUp(const std::shared_ptr<MMI::KeyEvent>& keyEvent)
|
||||
{
|
||||
HILOG_INFO("AbilityImpl::DoKeyUp called");
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Called when a touch event is dispatched to this ability. The default implementation of this callback
|
||||
* does nothing and returns false.
|
||||
* @param touchEvent Indicates information about the touch event.
|
||||
*
|
||||
* @return Returns true if the event is handled; returns false otherwise.
|
||||
*
|
||||
*/
|
||||
void AbilityImpl::DoPointerEvent(std::shared_ptr<MMI::PointerEvent>& pointerEvent)
|
||||
{
|
||||
HILOG_INFO("AbilityImpl::DoPointerEvent called");
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Send the result code and data to be returned by this Page ability to the caller.
|
||||
* When a Page ability is destroyed, the caller overrides the AbilitySlice#onAbilityResult(int, int, Want) method to
|
||||
@@ -861,26 +666,6 @@ void AbilityImpl::ScheduleUpdateConfiguration(const Configuration &config)
|
||||
HILOG_INFO("%{public}s end.", __func__);
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
void AbilityImpl::InputEventConsumerImpl::OnInputEvent(std::shared_ptr<MMI::KeyEvent> keyEvent) const
|
||||
{
|
||||
int32_t code = keyEvent->GetKeyAction();
|
||||
if (code == MMI::KeyEvent::KEY_ACTION_DOWN) {
|
||||
abilityImpl_->DoKeyDown(keyEvent);
|
||||
HILOG_INFO("AbilityImpl::OnKeyDown keyAction: %{public}d.", code);
|
||||
} else if (code == MMI::KeyEvent::KEY_ACTION_UP) {
|
||||
abilityImpl_->DoKeyUp(keyEvent);
|
||||
HILOG_INFO("AbilityImpl::DoKeyUp keyAction: %{public}d.", code);
|
||||
}
|
||||
}
|
||||
|
||||
void AbilityImpl::InputEventConsumerImpl::OnInputEvent(std::shared_ptr<MMI::PointerEvent> pointerEvent) const
|
||||
{
|
||||
HILOG_INFO("AbilityImpl::DoPointerEvent called.");
|
||||
abilityImpl_->DoPointerEvent(pointerEvent);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Create a PostEvent timeout task. The default delay is 5000ms
|
||||
*
|
||||
@@ -921,5 +706,216 @@ void AbilityImpl::NotifyContinuationResult(int32_t result)
|
||||
}
|
||||
ability_->OnCompleteContinuation(result);
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
void AbilityImpl::AfterUnFocused()
|
||||
{
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
if (!ability_ || !ability_->GetAbilityInfo() || !contextDeal_ || !handler_) {
|
||||
HILOG_ERROR("AbilityImpl::AfterUnFocused failed");
|
||||
return;
|
||||
}
|
||||
|
||||
if (ability_->GetAbilityInfo()->isStageBasedModel) {
|
||||
HILOG_INFO("new version ability, do nothing when after unfocused.");
|
||||
return;
|
||||
}
|
||||
|
||||
HILOG_INFO("old version ability, window after unfocused.");
|
||||
auto task = [abilityImpl = shared_from_this(), ability = ability_, contextDeal = contextDeal_]() {
|
||||
auto info = contextDeal->GetLifeCycleStateInfo();
|
||||
info.state = AbilityLifeCycleState::ABILITY_STATE_INACTIVE;
|
||||
info.isNewWant = false;
|
||||
Want want(*(ability->GetWant()));
|
||||
abilityImpl->HandleAbilityTransaction(want, info);
|
||||
};
|
||||
handler_->PostTask(task);
|
||||
HILOG_INFO("%{public}s end.", __func__);
|
||||
}
|
||||
|
||||
void AbilityImpl::AfterFocused()
|
||||
{
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
if (!ability_ || !ability_->GetAbilityInfo() || !contextDeal_ || !handler_) {
|
||||
HILOG_ERROR("AbilityImpl::AfterFocused failed");
|
||||
return;
|
||||
}
|
||||
|
||||
if (ability_->GetAbilityInfo()->isStageBasedModel) {
|
||||
HILOG_INFO("new version ability, do nothing when after focused.");
|
||||
return;
|
||||
}
|
||||
|
||||
HILOG_INFO("fa mode ability, window after focused.");
|
||||
auto task = [abilityImpl = shared_from_this(), ability = ability_, contextDeal = contextDeal_]() {
|
||||
auto info = contextDeal->GetLifeCycleStateInfo();
|
||||
info.state = AbilityLifeCycleState::ABILITY_STATE_ACTIVE;
|
||||
info.isNewWant = false;
|
||||
Want want(*(ability->GetWant()));
|
||||
abilityImpl->HandleAbilityTransaction(want, info);
|
||||
};
|
||||
handler_->PostTask(task);
|
||||
HILOG_INFO("%{public}s end.", __func__);
|
||||
}
|
||||
|
||||
void AbilityImpl::WindowLifeCycleImpl::AfterForeground()
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
auto owner = owner_.lock();
|
||||
if (owner && !owner->IsStageBasedModel()) {
|
||||
return;
|
||||
}
|
||||
|
||||
HILOG_INFO("Stage mode ability, window after foreground, notify ability manager service.");
|
||||
PacMap restoreData;
|
||||
AbilityManagerClient::GetInstance()->AbilityTransitionDone(token_,
|
||||
AbilityLifeCycleState::ABILITY_STATE_FOREGROUND_NEW, restoreData);
|
||||
}
|
||||
|
||||
void AbilityImpl::WindowLifeCycleImpl::AfterBackground()
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
auto owner = owner_.lock();
|
||||
if (owner && !owner->IsStageBasedModel()) {
|
||||
return;
|
||||
}
|
||||
|
||||
HILOG_INFO("new version ability, window after background.");
|
||||
PacMap restoreData;
|
||||
AbilityManagerClient::GetInstance()->AbilityTransitionDone(token_,
|
||||
AbilityLifeCycleState::ABILITY_STATE_BACKGROUND_NEW, restoreData);
|
||||
}
|
||||
|
||||
void AbilityImpl::WindowLifeCycleImpl::AfterFocused()
|
||||
{
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
auto owner = owner_.lock();
|
||||
if (owner) {
|
||||
owner->AfterFocused();
|
||||
}
|
||||
HILOG_INFO("%{public}s end.", __func__);
|
||||
}
|
||||
|
||||
void AbilityImpl::WindowLifeCycleImpl::AfterUnfocused()
|
||||
{
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
auto owner = owner_.lock();
|
||||
if (owner) {
|
||||
owner->AfterUnFocused();
|
||||
}
|
||||
HILOG_INFO("%{public}s end.", __func__);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Toggles the lifecycle status of Ability to AAFwk::ABILITY_STATE_INACTIVE. And notifies the application
|
||||
* that it belongs to of the lifecycle status.
|
||||
*
|
||||
* @param want The Want object to switch the life cycle.
|
||||
*/
|
||||
void AbilityImpl::Foreground(const Want &want)
|
||||
{
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
if (ability_ == nullptr || ability_->GetAbilityInfo() == nullptr || abilityLifecycleCallbacks_ == nullptr) {
|
||||
HILOG_ERROR("AbilityImpl::Foreground ability_ or abilityLifecycleCallbacks_ is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
HILOG_INFO("AbilityImpl::Foreground");
|
||||
ability_->OnForeground(want);
|
||||
if ((ability_->GetAbilityInfo()->type == AppExecFwk::AbilityType::PAGE) &&
|
||||
(ability_->GetAbilityInfo()->isStageBasedModel)) {
|
||||
lifecycleState_ = AAFwk::ABILITY_STATE_FOREGROUND_NEW;
|
||||
} else {
|
||||
lifecycleState_ = AAFwk::ABILITY_STATE_INACTIVE;
|
||||
}
|
||||
abilityLifecycleCallbacks_->OnAbilityForeground(ability_);
|
||||
HILOG_INFO("%{public}s end.", __func__);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Toggles the lifecycle status of Ability to AAFwk::ABILITY_STATE_BACKGROUND. And notifies the application
|
||||
* that it belongs to of the lifecycle status.
|
||||
*
|
||||
*/
|
||||
void AbilityImpl::Background()
|
||||
{
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
if (ability_ == nullptr || ability_->GetAbilityInfo() == nullptr || abilityLifecycleCallbacks_ == nullptr) {
|
||||
HILOG_ERROR("AbilityImpl::Background ability_ or abilityLifecycleCallbacks_ is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
HILOG_INFO("AbilityImpl::Background");
|
||||
ability_->OnLeaveForeground();
|
||||
ability_->OnBackground();
|
||||
if ((ability_->GetAbilityInfo()->type == AppExecFwk::AbilityType::PAGE) &&
|
||||
(ability_->GetAbilityInfo()->isStageBasedModel)) {
|
||||
lifecycleState_ = AAFwk::ABILITY_STATE_BACKGROUND_NEW;
|
||||
} else {
|
||||
lifecycleState_ = AAFwk::ABILITY_STATE_BACKGROUND;
|
||||
}
|
||||
abilityLifecycleCallbacks_->OnAbilityBackground(ability_);
|
||||
HILOG_INFO("%{public}s end.", __func__);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Execution the KeyDown callback of the ability
|
||||
* @param keyEvent Indicates the key-down event.
|
||||
*
|
||||
* @return Returns true if this event is handled and will not be passed further; returns false if this event is
|
||||
* not handled and should be passed to other handlers.
|
||||
*
|
||||
*/
|
||||
void AbilityImpl::DoKeyDown(const std::shared_ptr<MMI::KeyEvent>& keyEvent)
|
||||
{
|
||||
HILOG_INFO("AbilityImpl::DoKeyDown called");
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Execution the KeyUp callback of the ability
|
||||
* @param keyEvent Indicates the key-up event.
|
||||
*
|
||||
* @return Returns true if this event is handled and will not be passed further; returns false if this event is
|
||||
* not handled and should be passed to other handlers.
|
||||
*
|
||||
*/
|
||||
void AbilityImpl::DoKeyUp(const std::shared_ptr<MMI::KeyEvent>& keyEvent)
|
||||
{
|
||||
HILOG_INFO("AbilityImpl::DoKeyUp called");
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Called when a touch event is dispatched to this ability. The default implementation of this callback
|
||||
* does nothing and returns false.
|
||||
* @param touchEvent Indicates information about the touch event.
|
||||
*
|
||||
* @return Returns true if the event is handled; returns false otherwise.
|
||||
*
|
||||
*/
|
||||
void AbilityImpl::DoPointerEvent(std::shared_ptr<MMI::PointerEvent>& pointerEvent)
|
||||
{
|
||||
HILOG_INFO("AbilityImpl::DoPointerEvent called");
|
||||
}
|
||||
|
||||
void AbilityImpl::InputEventConsumerImpl::OnInputEvent(std::shared_ptr<MMI::KeyEvent> keyEvent) const
|
||||
{
|
||||
int32_t code = keyEvent->GetKeyAction();
|
||||
if (code == MMI::KeyEvent::KEY_ACTION_DOWN) {
|
||||
abilityImpl_->DoKeyDown(keyEvent);
|
||||
HILOG_INFO("AbilityImpl::OnKeyDown keyAction: %{public}d.", code);
|
||||
} else if (code == MMI::KeyEvent::KEY_ACTION_UP) {
|
||||
abilityImpl_->DoKeyUp(keyEvent);
|
||||
HILOG_INFO("AbilityImpl::DoKeyUp keyAction: %{public}d.", code);
|
||||
}
|
||||
}
|
||||
|
||||
void AbilityImpl::InputEventConsumerImpl::OnInputEvent(std::shared_ptr<MMI::PointerEvent> pointerEvent) const
|
||||
{
|
||||
HILOG_INFO("AbilityImpl::DoPointerEvent called.");
|
||||
abilityImpl_->DoPointerEvent(pointerEvent);
|
||||
}
|
||||
#endif
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -24,28 +24,6 @@ namespace AppExecFwk {
|
||||
void LifecycleObserver::OnActive()
|
||||
{}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
/**
|
||||
* @brief Called back in response to an ON_BACKGROUND event.
|
||||
* When an ON_BACKGROUND event is received, the ability or ability slice is invisible. You are advised to
|
||||
* suspend the threads related to this ability or ability slice and clear resources for more system memory.
|
||||
*
|
||||
*/
|
||||
void LifecycleObserver::OnBackground()
|
||||
{}
|
||||
|
||||
/**
|
||||
* @brief Called back in response to an ON_FOREGROUND event, where information for the
|
||||
* ability or ability slice to go back to the ACTIVE state is carried in the want parameter.
|
||||
* When an ON_FOREGROUND event is received, the ability or ability slice returns to the foreground. You can use
|
||||
* this method to implement re-initialization or adjust the UI display by using the want parameter.
|
||||
*
|
||||
* @param want Indicates the information for the ability or ability slice to go back to the ACTIVE state.
|
||||
*/
|
||||
void LifecycleObserver::OnForeground(const Want &want)
|
||||
{}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Called back in response to an ON_INACTIVE event.
|
||||
* When an ON_INACTIVE event is received, the ability or ability slice is in the INACTIVE state. INACTIVE is an
|
||||
@@ -95,5 +73,27 @@ void LifecycleObserver::OnStateChanged(Lifecycle::Event event, const Want &want)
|
||||
*/
|
||||
virtual void LifecycleObserver::OnStateChanged(LifeCycle::Event event)
|
||||
{}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
/**
|
||||
* @brief Called back in response to an ON_BACKGROUND event.
|
||||
* When an ON_BACKGROUND event is received, the ability or ability slice is invisible. You are advised to
|
||||
* suspend the threads related to this ability or ability slice and clear resources for more system memory.
|
||||
*
|
||||
*/
|
||||
void LifecycleObserver::OnBackground()
|
||||
{}
|
||||
|
||||
/**
|
||||
* @brief Called back in response to an ON_FOREGROUND event, where information for the
|
||||
* ability or ability slice to go back to the ACTIVE state is carried in the want parameter.
|
||||
* When an ON_FOREGROUND event is received, the ability or ability slice returns to the foreground. You can use
|
||||
* this method to implement re-initialization or adjust the UI display by using the want parameter.
|
||||
*
|
||||
* @param want Indicates the information for the ability or ability slice to go back to the ACTIVE state.
|
||||
*/
|
||||
void LifecycleObserver::OnForeground(const Want &want)
|
||||
{}
|
||||
#endif
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
@@ -38,9 +38,6 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
const std::string PAGE_STACK_PROPERTY_NAME = "pageStack";
|
||||
#endif
|
||||
Ability *JsAbility::Create(const std::unique_ptr<Runtime> &runtime)
|
||||
{
|
||||
return new JsAbility(static_cast<JsRuntime &>(*runtime));
|
||||
@@ -192,6 +189,8 @@ void JsAbility::OnStop()
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
const std::string PAGE_STACK_PROPERTY_NAME = "pageStack";
|
||||
|
||||
void JsAbility::OnSceneCreated()
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
@@ -313,6 +312,116 @@ void JsAbility::OnBackground()
|
||||
applicationContext->DispatchOnAbilityBackground(jsAbilityObj_);
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<NativeReference> JsAbility::CreateAppWindowStage()
|
||||
{
|
||||
HandleScope handleScope(jsRuntime_);
|
||||
auto &engine = jsRuntime_.GetNativeEngine();
|
||||
NativeValue *jsWindowStage = Rosen::CreateJsWindowStage(engine, GetScene());
|
||||
if (jsWindowStage == nullptr) {
|
||||
HILOG_ERROR("Failed to create jsWindowSatge object");
|
||||
return nullptr;
|
||||
}
|
||||
return jsRuntime_.LoadSystemModule("application.WindowStage", &jsWindowStage, 1);
|
||||
}
|
||||
|
||||
void JsAbility::GetPageStackFromWant(const Want &want, std::string &pageStack)
|
||||
{
|
||||
auto stringObj = AAFwk::IString::Query(want.GetParams().GetParam(PAGE_STACK_PROPERTY_NAME));
|
||||
if (stringObj != nullptr) {
|
||||
pageStack = AAFwk::String::Unbox(stringObj);
|
||||
}
|
||||
}
|
||||
|
||||
void JsAbility::DoOnForeground(const Want &want)
|
||||
{
|
||||
if (scene_ == nullptr) {
|
||||
if ((abilityContext_ == nullptr) || (sceneListener_ == nullptr)) {
|
||||
HILOG_ERROR("Ability::OnForeground error. abilityContext_ or sceneListener_ is nullptr!");
|
||||
return;
|
||||
}
|
||||
scene_ = std::make_shared<Rosen::WindowScene>();
|
||||
if (scene_ == nullptr) {
|
||||
HILOG_ERROR("%{public}s error. failed to create WindowScene instance!", __func__);
|
||||
return;
|
||||
}
|
||||
int32_t displayId = Rosen::WindowScene::DEFAULT_DISPLAY_ID;
|
||||
if (setting_ != nullptr) {
|
||||
std::string strDisplayId =
|
||||
setting_->GetProperty(OHOS::AppExecFwk::AbilityStartSetting::WINDOW_DISPLAY_ID_KEY);
|
||||
std::regex formatRegex("[0-9]{0,9}$");
|
||||
std::smatch sm;
|
||||
bool flag = std::regex_match(strDisplayId, sm, formatRegex);
|
||||
if (flag && !strDisplayId.empty()) {
|
||||
displayId = std::stoi(strDisplayId);
|
||||
HILOG_INFO("%{public}s success. displayId is %{public}d", __func__, displayId);
|
||||
} else {
|
||||
HILOG_INFO("%{public}s failed to formatRegex:[%{public}s]", __func__, strDisplayId.c_str());
|
||||
}
|
||||
}
|
||||
auto option = GetWindowOption(want);
|
||||
Rosen::WMError ret = scene_->Init(displayId, abilityContext_, sceneListener_, option);
|
||||
if (ret != Rosen::WMError::WM_OK) {
|
||||
HILOG_ERROR("%{public}s error. failed to init window scene!", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
// multi-instance ability continuation
|
||||
HILOG_INFO("lauch reason = %{public}d", launchParam_.launchReason);
|
||||
if (IsRestoredInContinuation()) {
|
||||
std::string pageStack;
|
||||
GetPageStackFromWant(want, pageStack);
|
||||
HandleScope handleScope(jsRuntime_);
|
||||
auto &engine = jsRuntime_.GetNativeEngine();
|
||||
if (abilityContext_->GetContentStorage()) {
|
||||
scene_->GetMainWindow()->SetUIContent(pageStack, &engine,
|
||||
abilityContext_->GetContentStorage()->Get(), true);
|
||||
} else {
|
||||
HILOG_ERROR("restore: content storage is nullptr");
|
||||
}
|
||||
OnSceneRestored();
|
||||
WaitingDistributedObjectSyncComplete(want);
|
||||
} else {
|
||||
OnSceneCreated();
|
||||
}
|
||||
} else {
|
||||
auto window = scene_->GetMainWindow();
|
||||
if (window != nullptr && want.HasParameter(Want::PARAM_RESV_WINDOW_MODE)) {
|
||||
auto windowMode = want.GetIntParam(Want::PARAM_RESV_WINDOW_MODE,
|
||||
AAFwk::AbilityWindowConfiguration::MULTI_WINDOW_DISPLAY_UNDEFINED);
|
||||
window->SetWindowMode(static_cast<Rosen::WindowMode>(windowMode));
|
||||
HILOG_INFO("set window mode = %{public}d.", windowMode);
|
||||
}
|
||||
}
|
||||
|
||||
auto window = scene_->GetMainWindow();
|
||||
if (window) {
|
||||
HILOG_INFO("Call RegisterDisplayMoveListener, windowId: %{public}d", window->GetWindowId());
|
||||
std::weak_ptr<Ability> weakAbility = shared_from_this();
|
||||
abilityDisplayMoveListener_ = new AbilityDisplayMoveListener(weakAbility);
|
||||
window->RegisterDisplayMoveListener(abilityDisplayMoveListener_);
|
||||
}
|
||||
|
||||
HILOG_INFO("%{public}s begin scene_->GoForeground, sceneFlag_:%{public}d.", __func__, Ability::sceneFlag_);
|
||||
scene_->GoForeground(Ability::sceneFlag_);
|
||||
HILOG_INFO("%{public}s end scene_->GoForeground.", __func__);
|
||||
}
|
||||
|
||||
void JsAbility::RequsetFocus(const Want &want)
|
||||
{
|
||||
HILOG_INFO("%{public}s called.", __func__);
|
||||
if (scene_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
auto window = scene_->GetMainWindow();
|
||||
if (window != nullptr && want.HasParameter(Want::PARAM_RESV_WINDOW_MODE)) {
|
||||
auto windowMode = want.GetIntParam(Want::PARAM_RESV_WINDOW_MODE,
|
||||
AAFwk::AbilityWindowConfiguration::MULTI_WINDOW_DISPLAY_UNDEFINED);
|
||||
window->SetWindowMode(static_cast<Rosen::WindowMode>(windowMode));
|
||||
HILOG_INFO("set window mode = %{public}d.", windowMode);
|
||||
}
|
||||
scene_->GoForeground(Ability::sceneFlag_);
|
||||
}
|
||||
#endif
|
||||
|
||||
int32_t JsAbility::OnContinue(WantParams &wantParams)
|
||||
@@ -516,102 +625,6 @@ void JsAbility::CallObjectMethod(const char *name, NativeValue *const *argv, siz
|
||||
nativeEngine.CallFunction(value, methodOnCreate, argv, argc);
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
std::unique_ptr<NativeReference> JsAbility::CreateAppWindowStage()
|
||||
{
|
||||
HandleScope handleScope(jsRuntime_);
|
||||
auto &engine = jsRuntime_.GetNativeEngine();
|
||||
NativeValue *jsWindowStage = Rosen::CreateJsWindowStage(engine, GetScene());
|
||||
if (jsWindowStage == nullptr) {
|
||||
HILOG_ERROR("Failed to create jsWindowSatge object");
|
||||
return nullptr;
|
||||
}
|
||||
return jsRuntime_.LoadSystemModule("application.WindowStage", &jsWindowStage, 1);
|
||||
}
|
||||
|
||||
void JsAbility::GetPageStackFromWant(const Want &want, std::string &pageStack)
|
||||
{
|
||||
auto stringObj = AAFwk::IString::Query(want.GetParams().GetParam(PAGE_STACK_PROPERTY_NAME));
|
||||
if (stringObj != nullptr) {
|
||||
pageStack = AAFwk::String::Unbox(stringObj);
|
||||
}
|
||||
}
|
||||
|
||||
void JsAbility::DoOnForeground(const Want &want)
|
||||
{
|
||||
if (scene_ == nullptr) {
|
||||
if ((abilityContext_ == nullptr) || (sceneListener_ == nullptr)) {
|
||||
HILOG_ERROR("Ability::OnForeground error. abilityContext_ or sceneListener_ is nullptr!");
|
||||
return;
|
||||
}
|
||||
scene_ = std::make_shared<Rosen::WindowScene>();
|
||||
if (scene_ == nullptr) {
|
||||
HILOG_ERROR("%{public}s error. failed to create WindowScene instance!", __func__);
|
||||
return;
|
||||
}
|
||||
int32_t displayId = Rosen::WindowScene::DEFAULT_DISPLAY_ID;
|
||||
if (setting_ != nullptr) {
|
||||
std::string strDisplayId =
|
||||
setting_->GetProperty(OHOS::AppExecFwk::AbilityStartSetting::WINDOW_DISPLAY_ID_KEY);
|
||||
std::regex formatRegex("[0-9]{0,9}$");
|
||||
std::smatch sm;
|
||||
bool flag = std::regex_match(strDisplayId, sm, formatRegex);
|
||||
if (flag && !strDisplayId.empty()) {
|
||||
displayId = std::stoi(strDisplayId);
|
||||
HILOG_INFO("%{public}s success. displayId is %{public}d", __func__, displayId);
|
||||
} else {
|
||||
HILOG_INFO("%{public}s failed to formatRegex:[%{public}s]", __func__, strDisplayId.c_str());
|
||||
}
|
||||
}
|
||||
auto option = GetWindowOption(want);
|
||||
Rosen::WMError ret = scene_->Init(displayId, abilityContext_, sceneListener_, option);
|
||||
if (ret != Rosen::WMError::WM_OK) {
|
||||
HILOG_ERROR("%{public}s error. failed to init window scene!", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
// multi-instance ability continuation
|
||||
HILOG_INFO("lauch reason = %{public}d", launchParam_.launchReason);
|
||||
if (IsRestoredInContinuation()) {
|
||||
std::string pageStack;
|
||||
GetPageStackFromWant(want, pageStack);
|
||||
HandleScope handleScope(jsRuntime_);
|
||||
auto &engine = jsRuntime_.GetNativeEngine();
|
||||
if (abilityContext_->GetContentStorage()) {
|
||||
scene_->GetMainWindow()->SetUIContent(pageStack, &engine,
|
||||
abilityContext_->GetContentStorage()->Get(), true);
|
||||
} else {
|
||||
HILOG_ERROR("restore: content storage is nullptr");
|
||||
}
|
||||
OnSceneRestored();
|
||||
WaitingDistributedObjectSyncComplete(want);
|
||||
} else {
|
||||
OnSceneCreated();
|
||||
}
|
||||
} else {
|
||||
auto window = scene_->GetMainWindow();
|
||||
if (window != nullptr && want.HasParameter(Want::PARAM_RESV_WINDOW_MODE)) {
|
||||
auto windowMode = want.GetIntParam(Want::PARAM_RESV_WINDOW_MODE,
|
||||
AAFwk::AbilityWindowConfiguration::MULTI_WINDOW_DISPLAY_UNDEFINED);
|
||||
window->SetWindowMode(static_cast<Rosen::WindowMode>(windowMode));
|
||||
HILOG_INFO("set window mode = %{public}d.", windowMode);
|
||||
}
|
||||
}
|
||||
|
||||
auto window = scene_->GetMainWindow();
|
||||
if (window) {
|
||||
HILOG_INFO("Call RegisterDisplayMoveListener, windowId: %{public}d", window->GetWindowId());
|
||||
std::weak_ptr<Ability> weakAbility = shared_from_this();
|
||||
abilityDisplayMoveListener_ = new AbilityDisplayMoveListener(weakAbility);
|
||||
window->RegisterDisplayMoveListener(abilityDisplayMoveListener_);
|
||||
}
|
||||
|
||||
HILOG_INFO("%{public}s begin scene_->GoForeground, sceneFlag_:%{public}d.", __func__, Ability::sceneFlag_);
|
||||
scene_->GoForeground(Ability::sceneFlag_);
|
||||
HILOG_INFO("%{public}s end scene_->GoForeground.", __func__);
|
||||
}
|
||||
#endif
|
||||
|
||||
std::shared_ptr<AppExecFwk::ADelegatorAbilityProperty> JsAbility::CreateADelegatorAbilityProperty()
|
||||
{
|
||||
auto property = std::make_shared<AppExecFwk::ADelegatorAbilityProperty>();
|
||||
@@ -623,24 +636,6 @@ std::shared_ptr<AppExecFwk::ADelegatorAbilityProperty> JsAbility::CreateADelegat
|
||||
return property;
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
void JsAbility::RequsetFocus(const Want &want)
|
||||
{
|
||||
HILOG_INFO("%{public}s called.", __func__);
|
||||
if (scene_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
auto window = scene_->GetMainWindow();
|
||||
if (window != nullptr && want.HasParameter(Want::PARAM_RESV_WINDOW_MODE)) {
|
||||
auto windowMode = want.GetIntParam(Want::PARAM_RESV_WINDOW_MODE,
|
||||
AAFwk::AbilityWindowConfiguration::MULTI_WINDOW_DISPLAY_UNDEFINED);
|
||||
window->SetWindowMode(static_cast<Rosen::WindowMode>(windowMode));
|
||||
HILOG_INFO("set window mode = %{public}d.", windowMode);
|
||||
}
|
||||
scene_->GoForeground(Ability::sceneFlag_);
|
||||
}
|
||||
#endif
|
||||
|
||||
void JsAbility::Dump(const std::vector<std::string> ¶ms, std::vector<std::string> &info)
|
||||
{
|
||||
Ability::Dump(params, info);
|
||||
|
||||
@@ -160,26 +160,12 @@ NativeValue* JsAbilityContext::RestoreWindowStage(NativeEngine* engine, NativeCa
|
||||
return (me != nullptr) ? me->OnRestoreWindowStage(*engine, *info) : nullptr;
|
||||
}
|
||||
|
||||
NativeValue* JsAbilityContext::SetMissionLabel(NativeEngine* engine, NativeCallbackInfo* info)
|
||||
{
|
||||
JsAbilityContext* me = CheckParamsAndGetThis<JsAbilityContext>(engine, info);
|
||||
return (me != nullptr) ? me->OnSetMissionLabel(*engine, *info) : nullptr;
|
||||
}
|
||||
|
||||
NativeValue* JsAbilityContext::IsTerminating(NativeEngine* engine, NativeCallbackInfo* info)
|
||||
{
|
||||
JsAbilityContext* me = CheckParamsAndGetThis<JsAbilityContext>(engine, info);
|
||||
return (me != nullptr) ? me->OnIsTerminating(*engine, *info) : nullptr;
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
NativeValue* JsAbilityContext::SetMissionIcon(NativeEngine* engine, NativeCallbackInfo* info)
|
||||
{
|
||||
JsAbilityContext* me = CheckParamsAndGetThis<JsAbilityContext>(engine, info);
|
||||
return (me != nullptr) ? me->OnSetMissionIcon(*engine, *info) : nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
NativeValue* JsAbilityContext::OnStartAbility(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
@@ -991,50 +977,6 @@ NativeValue* JsAbilityContext::OnRestoreWindowStage(NativeEngine& engine, Native
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
|
||||
NativeValue* JsAbilityContext::OnSetMissionLabel(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
{
|
||||
HILOG_INFO("OnSetMissionLabel is called, argc = %{public}d", static_cast<int>(info.argc));
|
||||
if (info.argc < ARGC_ONE) {
|
||||
HILOG_ERROR("OnSetMissionLabel, Not enough params");
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
|
||||
int32_t errorCode = 0;
|
||||
std::string label;
|
||||
if (!ConvertFromJsValue(engine, info.argv[0], label)) {
|
||||
HILOG_ERROR("OnSetMissionLabel, parse label failed.");
|
||||
errorCode = ERR_NOT_OK;
|
||||
}
|
||||
|
||||
AsyncTask::CompleteCallback complete =
|
||||
[weak = context_, label, errorCode](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
if (errorCode != 0) {
|
||||
task.Reject(engine, CreateJsError(engine, errorCode, "Invalidate params."));
|
||||
return;
|
||||
}
|
||||
|
||||
auto context = weak.lock();
|
||||
if (!context) {
|
||||
HILOG_WARN("context is released");
|
||||
task.Reject(engine, CreateJsError(engine, 1, "Context is released"));
|
||||
return;
|
||||
}
|
||||
|
||||
auto errcode = context->SetMissionLabel(label);
|
||||
if (errcode == 0) {
|
||||
task.Resolve(engine, engine.CreateUndefined());
|
||||
} else {
|
||||
task.Reject(engine, CreateJsError(engine, errcode, "SetMissionLabel failed."));
|
||||
}
|
||||
};
|
||||
|
||||
NativeValue* lastParam = (info.argc == ARGC_ONE) ? nullptr : info.argv[1];
|
||||
NativeValue* result = nullptr;
|
||||
AsyncTask::Schedule(
|
||||
engine, CreateAsyncTaskWithLastParam(engine, lastParam, nullptr, std::move(complete), &result));
|
||||
return result;
|
||||
}
|
||||
|
||||
NativeValue* JsAbilityContext::OnIsTerminating(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
{
|
||||
HILOG_INFO("OnIsTerminating is called");
|
||||
@@ -1046,53 +988,6 @@ NativeValue* JsAbilityContext::OnIsTerminating(NativeEngine& engine, NativeCallb
|
||||
return engine.CreateBoolean(context->IsTerminating());
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
NativeValue* JsAbilityContext::OnSetMissionIcon(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
{
|
||||
HILOG_INFO("OnSetMissionIcon is called, argc = %{public}d", static_cast<int>(info.argc));
|
||||
if (info.argc < ARGC_ONE) {
|
||||
HILOG_ERROR("OnSetMissionIcon, Not enough params");
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
|
||||
int32_t errorCode = 0;
|
||||
auto icon = OHOS::Media::PixelMapNapi::GetPixelMap(reinterpret_cast<napi_env>(&engine),
|
||||
reinterpret_cast<napi_value>(info.argv[0]));
|
||||
if (!icon) {
|
||||
HILOG_ERROR("OnSetMissionIcon, parse icon failed.");
|
||||
errorCode = ERR_NOT_OK;
|
||||
}
|
||||
|
||||
AsyncTask::CompleteCallback complete =
|
||||
[weak = context_, icon, errorCode](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
if (errorCode != 0) {
|
||||
task.Reject(engine, CreateJsError(engine, errorCode, "Invalidate params."));
|
||||
return;
|
||||
}
|
||||
|
||||
auto context = weak.lock();
|
||||
if (!context) {
|
||||
HILOG_WARN("context is released when set mission icon");
|
||||
task.Reject(engine, CreateJsError(engine, -1, "Context is released"));
|
||||
return;
|
||||
}
|
||||
|
||||
auto errcode = context->SetMissionIcon(icon);
|
||||
if (errcode == 0) {
|
||||
task.Resolve(engine, engine.CreateUndefined());
|
||||
} else {
|
||||
task.Reject(engine, CreateJsError(engine, errcode, "SetMissionIcon failed."));
|
||||
}
|
||||
};
|
||||
|
||||
NativeValue* lastParam = (info.argc == ARGC_ONE) ? nullptr : info.argv[1];
|
||||
NativeValue* result = nullptr;
|
||||
AsyncTask::Schedule(
|
||||
engine, CreateAsyncTaskWithLastParam(engine, lastParam, nullptr, std::move(complete), &result));
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool JsAbilityContext::UnWrapWant(NativeEngine& engine, NativeValue* argv, AAFwk::Want& want)
|
||||
{
|
||||
if (argv == nullptr) {
|
||||
@@ -1245,10 +1140,10 @@ NativeValue* CreateJsAbilityContext(NativeEngine& engine, std::shared_ptr<Abilit
|
||||
BindNativeFunction(engine, *object, "terminateSelfWithResult", JsAbilityContext::TerminateSelfWithResult);
|
||||
BindNativeFunction(engine, *object, "requestPermissionsFromUser", JsAbilityContext::RequestPermissionsFromUser);
|
||||
BindNativeFunction(engine, *object, "restoreWindowStage", JsAbilityContext::RestoreWindowStage);
|
||||
BindNativeFunction(engine, *object, "setMissionLabel", JsAbilityContext::SetMissionLabel);
|
||||
BindNativeFunction(engine, *object, "isTerminating", JsAbilityContext::IsTerminating);
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
BindNativeFunction(engine, *object, "setMissionLabel", JsAbilityContext::SetMissionLabel);
|
||||
BindNativeFunction(engine, *object, "setMissionIcon", JsAbilityContext::SetMissionIcon);
|
||||
#endif
|
||||
return objValue;
|
||||
@@ -1408,5 +1303,108 @@ void JSAbilityConnection::SetJsConnectionObject(NativeValue* jsConnectionObject)
|
||||
{
|
||||
jsConnectionObject_ = std::unique_ptr<NativeReference>(engine_.CreateReference(jsConnectionObject, 1));
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
NativeValue* JsAbilityContext::SetMissionLabel(NativeEngine* engine, NativeCallbackInfo* info)
|
||||
{
|
||||
JsAbilityContext* me = CheckParamsAndGetThis<JsAbilityContext>(engine, info);
|
||||
return (me != nullptr) ? me->OnSetMissionLabel(*engine, *info) : nullptr;
|
||||
}
|
||||
|
||||
NativeValue* JsAbilityContext::SetMissionIcon(NativeEngine* engine, NativeCallbackInfo* info)
|
||||
{
|
||||
JsAbilityContext* me = CheckParamsAndGetThis<JsAbilityContext>(engine, info);
|
||||
return (me != nullptr) ? me->OnSetMissionIcon(*engine, *info) : nullptr;
|
||||
}
|
||||
|
||||
NativeValue* JsAbilityContext::OnSetMissionLabel(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
{
|
||||
HILOG_INFO("OnSetMissionLabel is called, argc = %{public}d", static_cast<int>(info.argc));
|
||||
if (info.argc < ARGC_ONE) {
|
||||
HILOG_ERROR("OnSetMissionLabel, Not enough params");
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
|
||||
int32_t errorCode = 0;
|
||||
std::string label;
|
||||
if (!ConvertFromJsValue(engine, info.argv[0], label)) {
|
||||
HILOG_ERROR("OnSetMissionLabel, parse label failed.");
|
||||
errorCode = ERR_NOT_OK;
|
||||
}
|
||||
|
||||
AsyncTask::CompleteCallback complete =
|
||||
[weak = context_, label, errorCode](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
if (errorCode != 0) {
|
||||
task.Reject(engine, CreateJsError(engine, errorCode, "Invalidate params."));
|
||||
return;
|
||||
}
|
||||
|
||||
auto context = weak.lock();
|
||||
if (!context) {
|
||||
HILOG_WARN("context is released");
|
||||
task.Reject(engine, CreateJsError(engine, 1, "Context is released"));
|
||||
return;
|
||||
}
|
||||
|
||||
auto errcode = context->SetMissionLabel(label);
|
||||
if (errcode == 0) {
|
||||
task.Resolve(engine, engine.CreateUndefined());
|
||||
} else {
|
||||
task.Reject(engine, CreateJsError(engine, errcode, "SetMissionLabel failed."));
|
||||
}
|
||||
};
|
||||
|
||||
NativeValue* lastParam = (info.argc == ARGC_ONE) ? nullptr : info.argv[1];
|
||||
NativeValue* result = nullptr;
|
||||
AsyncTask::Schedule(
|
||||
engine, CreateAsyncTaskWithLastParam(engine, lastParam, nullptr, std::move(complete), &result));
|
||||
return result;
|
||||
}
|
||||
|
||||
NativeValue* JsAbilityContext::OnSetMissionIcon(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
{
|
||||
HILOG_INFO("OnSetMissionIcon is called, argc = %{public}d", static_cast<int>(info.argc));
|
||||
if (info.argc < ARGC_ONE) {
|
||||
HILOG_ERROR("OnSetMissionIcon, Not enough params");
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
|
||||
int32_t errorCode = 0;
|
||||
auto icon = OHOS::Media::PixelMapNapi::GetPixelMap(reinterpret_cast<napi_env>(&engine),
|
||||
reinterpret_cast<napi_value>(info.argv[0]));
|
||||
if (!icon) {
|
||||
HILOG_ERROR("OnSetMissionIcon, parse icon failed.");
|
||||
errorCode = ERR_NOT_OK;
|
||||
}
|
||||
|
||||
AsyncTask::CompleteCallback complete =
|
||||
[weak = context_, icon, errorCode](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
if (errorCode != 0) {
|
||||
task.Reject(engine, CreateJsError(engine, errorCode, "Invalidate params."));
|
||||
return;
|
||||
}
|
||||
|
||||
auto context = weak.lock();
|
||||
if (!context) {
|
||||
HILOG_WARN("context is released when set mission icon");
|
||||
task.Reject(engine, CreateJsError(engine, -1, "Context is released"));
|
||||
return;
|
||||
}
|
||||
|
||||
auto errcode = context->SetMissionIcon(icon);
|
||||
if (errcode == 0) {
|
||||
task.Resolve(engine, engine.CreateUndefined());
|
||||
} else {
|
||||
task.Reject(engine, CreateJsError(engine, errcode, "SetMissionIcon failed."));
|
||||
}
|
||||
};
|
||||
|
||||
NativeValue* lastParam = (info.argc == ARGC_ONE) ? nullptr : info.argv[1];
|
||||
NativeValue* result = nullptr;
|
||||
AsyncTask::Schedule(
|
||||
engine, CreateAsyncTaskWithLastParam(engine, lastParam, nullptr, std::move(complete), &result));
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -409,12 +409,10 @@ void FormExtensionProviderClient::NotifyFormExtensionAcquireState(const Want &wa
|
||||
const sptr<IRemoteObject> &callerToken)
|
||||
{
|
||||
HILOG_INFO("%{public}s called.", __func__);
|
||||
int errorCode = ERR_OK;
|
||||
FormState state = FormState::UNKNOWN;
|
||||
std::shared_ptr<FormExtension> ownerFormExtension = GetOwner();
|
||||
if (ownerFormExtension == nullptr) {
|
||||
HILOG_ERROR("%{public}s error, ownerFormExtension is nullptr.", __func__);
|
||||
errorCode = ERR_APPEXECFWK_FORM_NO_SUCH_ABILITY;
|
||||
} else {
|
||||
state = ownerFormExtension->OnAcquireFormState(wantArg);
|
||||
}
|
||||
|
||||
@@ -67,18 +67,6 @@ void Ability::OnActive()
|
||||
void Ability::OnInactive()
|
||||
{}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
void Ability::OnForeground(const Want &want)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void Ability::OnBackground()
|
||||
{
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
sptr<IRemoteObject> Ability::OnConnect(const Want &want)
|
||||
{
|
||||
return nullptr;
|
||||
@@ -102,100 +90,12 @@ void Ability::StartAbility(const Want &want, AbilityStartSetting abilityStartSet
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
bool Ability::OnKeyDown(int keyCode, const KeyEvent &keyEvent)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Ability::OnKeyUp(int keyCode, const KeyEvent &keyEvent)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Ability::OnTouchEvent(const TouchEvent &touchEvent)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void Ability::SetUIContent(const ComponentContainer &componentContainer)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void Ability::SetUIContent(int layoutRes)
|
||||
{
|
||||
return;
|
||||
} // namespace AppExecFwk
|
||||
|
||||
void Ability::SetUIContent(
|
||||
const ComponentContainer &componentContainer, std::shared_ptr<Context> &context, int typeFlag)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void Ability::SetUIContent(int layoutRes, std::shared_ptr<Context> &context, int typeFlag)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Inflates UI controls by using WindowConfig.
|
||||
*
|
||||
* @param config Indicates the window config defined by the user.
|
||||
*/
|
||||
void Ability::SetUIContent(const WindowConfig &config)
|
||||
{
|
||||
if (abilityWindow_ == nullptr) {
|
||||
HILOG_ERROR("Ability::SetUIContent abilityWindow_ is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
HILOG_INFO("Ability::SetUIContent called");
|
||||
abilityWindow_->SetWindowConfig(config);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the window belong to the ability.
|
||||
*
|
||||
* @return Returns a IWindowsManager object pointer.
|
||||
*/
|
||||
std::unique_ptr<Window> &Ability::GetWindow(int windowID)
|
||||
{
|
||||
HILOG_INFO("Ability::GetWindow called windowID = %d.", windowID);
|
||||
|
||||
return abilityWindow_->GetWindow(windowID);
|
||||
}
|
||||
|
||||
int Ability::GetVolumeTypeAdjustedByKey()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool Ability::HasWindowFocus()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Ability::OnKeyPressAndHold(int keyCode, const std::shared_ptr<KeyEvent> &keyEvent)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
void Ability::OnRequestPermissionsFromUserResult(
|
||||
int requestCode, const std::vector<std::string> &permissions, const std::vector<int> &grantResults)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
void Ability::OnLeaveForeground()
|
||||
{
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
std::string Ability::GetType(const Uri &uri)
|
||||
{
|
||||
std::string value("\nullptr");
|
||||
@@ -272,13 +172,6 @@ void Ability::OnEventDispatch()
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
void Ability::OnWindowFocusChanged(bool hasFocus)
|
||||
{
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
void Ability::SetWant(const AAFwk::Want &want)
|
||||
{
|
||||
setWant_ = std::make_shared<AAFwk::Want>(want);
|
||||
@@ -302,13 +195,6 @@ void Ability::SetResult(int resultCode, const Want &resultData)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
void Ability::SetVolumeTypeAdjustedByKey(int volumeType)
|
||||
{
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
void Ability::OnCommand(const AAFwk::Want &want, bool restart, int startId)
|
||||
{
|
||||
return;
|
||||
@@ -442,6 +328,110 @@ void Ability::AddActionRoute(const std::string &action, const std::string &entry
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
void Ability::OnForeground(const Want &want)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void Ability::OnBackground()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
bool Ability::OnKeyDown(int keyCode, const KeyEvent &keyEvent)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Ability::OnKeyUp(int keyCode, const KeyEvent &keyEvent)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Ability::OnTouchEvent(const TouchEvent &touchEvent)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void Ability::SetUIContent(const ComponentContainer &componentContainer)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void Ability::SetUIContent(int layoutRes)
|
||||
{
|
||||
return;
|
||||
} // namespace AppExecFwk
|
||||
|
||||
void Ability::SetUIContent(
|
||||
const ComponentContainer &componentContainer, std::shared_ptr<Context> &context, int typeFlag)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void Ability::SetUIContent(int layoutRes, std::shared_ptr<Context> &context, int typeFlag)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Inflates UI controls by using WindowConfig.
|
||||
*
|
||||
* @param config Indicates the window config defined by the user.
|
||||
*/
|
||||
void Ability::SetUIContent(const WindowConfig &config)
|
||||
{
|
||||
if (abilityWindow_ == nullptr) {
|
||||
HILOG_ERROR("Ability::SetUIContent abilityWindow_ is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
HILOG_INFO("Ability::SetUIContent called");
|
||||
abilityWindow_->SetWindowConfig(config);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the window belong to the ability.
|
||||
*
|
||||
* @return Returns a IWindowsManager object pointer.
|
||||
*/
|
||||
std::unique_ptr<Window> &Ability::GetWindow(int windowID)
|
||||
{
|
||||
HILOG_INFO("Ability::GetWindow called windowID = %d.", windowID);
|
||||
|
||||
return abilityWindow_->GetWindow(windowID);
|
||||
}
|
||||
|
||||
int Ability::GetVolumeTypeAdjustedByKey()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool Ability::HasWindowFocus()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Ability::OnKeyPressAndHold(int keyCode, const std::shared_ptr<KeyEvent> &keyEvent)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void Ability::OnLeaveForeground()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void Ability::OnWindowFocusChanged(bool hasFocus)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void Ability::SetVolumeTypeAdjustedByKey(int volumeType)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int Ability::SetWindowBackgroundColor(int red, int green, int blue)
|
||||
{
|
||||
return -1;
|
||||
|
||||
@@ -49,18 +49,6 @@ public:
|
||||
this->Inactive();
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
void ImplForeground(const Want &want)
|
||||
{
|
||||
this->Foreground(want);
|
||||
}
|
||||
|
||||
void ImplBackground()
|
||||
{
|
||||
this->Background();
|
||||
}
|
||||
#endif
|
||||
|
||||
void SetlifecycleState(int state)
|
||||
{
|
||||
this->lifecycleState_ = state;
|
||||
@@ -93,6 +81,18 @@ public:
|
||||
return AbilityImpl::CheckAndRestore();
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
void ImplForeground(const Want &want)
|
||||
{
|
||||
this->Foreground(want);
|
||||
}
|
||||
|
||||
void ImplBackground()
|
||||
{
|
||||
this->Background();
|
||||
}
|
||||
#endif
|
||||
|
||||
private:
|
||||
AbilityImpl AbilityImpl_;
|
||||
};
|
||||
|
||||
@@ -38,34 +38,6 @@ public:
|
||||
GTEST_LOG_(INFO) << "MockLifecycleObserver::OnActive called";
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
/**
|
||||
* Called back in response to an ON_BACKGROUND event.
|
||||
* When an ON_BACKGROUND event is received, the ability or ability slice is invisible. You are advised to
|
||||
* suspend the threads related to this ability or ability slice and clear resources for more system memory.
|
||||
*
|
||||
*/
|
||||
|
||||
virtual void OnBackground()
|
||||
{
|
||||
GTEST_LOG_(INFO) << "MockLifecycleObserver::OnBackground called";
|
||||
}
|
||||
|
||||
/**
|
||||
* Called back in response to an ON_FOREGROUND event, where information for the
|
||||
* ability or ability slice to go back to the ACTIVE state is carried in the want parameter.
|
||||
* When an ON_FOREGROUND event is received, the ability or ability slice returns to the foreground. You can use
|
||||
* this method to implement re-initialization or adjust the UI display by using the want parameter.
|
||||
*
|
||||
* @param want Indicates the information for the ability or ability slice to go back to the ACTIVE state.
|
||||
*/
|
||||
virtual void OnForeground(const Want &want)
|
||||
{
|
||||
(void)want;
|
||||
GTEST_LOG_(INFO) << "MockLifecycleObserver::OnForeground called";
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Called back in response to an ON_INACTIVE event.
|
||||
* When an ON_INACTIVE event is received, the ability or ability slice is in the INACTIVE state. INACTIVE is an
|
||||
@@ -129,6 +101,34 @@ public:
|
||||
(void)event;
|
||||
GTEST_LOG_(INFO) << "MockLifecycleObserver::OnStateChanged called";
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
/**
|
||||
* Called back in response to an ON_BACKGROUND event.
|
||||
* When an ON_BACKGROUND event is received, the ability or ability slice is invisible. You are advised to
|
||||
* suspend the threads related to this ability or ability slice and clear resources for more system memory.
|
||||
*
|
||||
*/
|
||||
|
||||
virtual void OnBackground()
|
||||
{
|
||||
GTEST_LOG_(INFO) << "MockLifecycleObserver::OnBackground called";
|
||||
}
|
||||
|
||||
/**
|
||||
* Called back in response to an ON_FOREGROUND event, where information for the
|
||||
* ability or ability slice to go back to the ACTIVE state is carried in the want parameter.
|
||||
* When an ON_FOREGROUND event is received, the ability or ability slice returns to the foreground. You can use
|
||||
* this method to implement re-initialization or adjust the UI display by using the want parameter.
|
||||
*
|
||||
* @param want Indicates the information for the ability or ability slice to go back to the ACTIVE state.
|
||||
*/
|
||||
virtual void OnForeground(const Want &want)
|
||||
{
|
||||
(void)want;
|
||||
GTEST_LOG_(INFO) << "MockLifecycleObserver::OnForeground called";
|
||||
}
|
||||
#endif
|
||||
};
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -86,18 +86,6 @@ void AbilityImpl::Inactive()
|
||||
GTEST_LOG_(INFO) << "Mock AbilityImpl::Inactive called";
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
void AbilityImpl::Foreground(const Want &want)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "Mock AbilityImpl::Foreground called";
|
||||
}
|
||||
|
||||
void AbilityImpl::Background()
|
||||
{
|
||||
GTEST_LOG_(INFO) << "Mock AbilityImpl::Background called";
|
||||
}
|
||||
#endif
|
||||
|
||||
void AbilityImpl::DispatchSaveAbilityState()
|
||||
{
|
||||
GTEST_LOG_(INFO) << "Mock AbilityImpl::DispatchSaveAbilityState called";
|
||||
@@ -134,14 +122,6 @@ int AbilityImpl::GetCurrentState()
|
||||
return lifecycleState_;
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
void AbilityImpl::DoKeyDown(const std::shared_ptr<MMI::KeyEvent>& keyEvent) {}
|
||||
|
||||
void AbilityImpl::DoKeyUp(const std::shared_ptr<MMI::KeyEvent>& keyEvent) {}
|
||||
|
||||
void AbilityImpl::DoPointerEvent(std::shared_ptr<MMI::PointerEvent>& pointerEvent) {}
|
||||
#endif
|
||||
|
||||
void AbilityImpl::SendResult(int requestCode, int resultCode, const Want &resultData)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "Mock AbilityImpl::SendResult called";
|
||||
@@ -195,5 +175,23 @@ std::string AbilityImpl::GetType(const Uri &uri)
|
||||
GTEST_LOG_(INFO) << "Mock AbilityImpl::GetType called";
|
||||
return "";
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
void AbilityImpl::Foreground(const Want &want)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "Mock AbilityImpl::Foreground called";
|
||||
}
|
||||
|
||||
void AbilityImpl::Background()
|
||||
{
|
||||
GTEST_LOG_(INFO) << "Mock AbilityImpl::Background called";
|
||||
}
|
||||
|
||||
void AbilityImpl::DoKeyDown(const std::shared_ptr<MMI::KeyEvent>& keyEvent) {}
|
||||
|
||||
void AbilityImpl::DoKeyUp(const std::shared_ptr<MMI::KeyEvent>& keyEvent) {}
|
||||
|
||||
void AbilityImpl::DoPointerEvent(std::shared_ptr<MMI::PointerEvent>& pointerEvent) {}
|
||||
#endif
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
@@ -27,6 +27,7 @@
|
||||
#ifndef SUPPORT_GRAPHICS
|
||||
#include "inttypes.h"
|
||||
#endif
|
||||
|
||||
#include "ability_delegator_infos.h"
|
||||
#include "iability_monitor.h"
|
||||
#include "delegator_thread.h"
|
||||
|
||||
+16
-20
@@ -199,26 +199,6 @@ int MockAbilityDelegatorStub::BlockAppService()
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef ABILITY_COMMAND_FOR_TEST
|
||||
int MockAbilityDelegatorStub::ForceTimeoutForTest(const std::string &abilityName, const std::string &state)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
int MockAbilityDelegatorStub::SetMissionIcon(
|
||||
const sptr<IRemoteObject> &token, const std::shared_ptr<OHOS::Media::PixelMap> &icon)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int MockAbilityDelegatorStub::RegisterWindowManagerServiceHandler(const sptr<IWindowManagerServiceHandler>& handler)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool MockAbilityDelegatorStub2::finishFlag_ = false;
|
||||
|
||||
MockAbilityDelegatorStub2::MockAbilityDelegatorStub2()
|
||||
@@ -396,6 +376,11 @@ int MockAbilityDelegatorStub2::BlockAppService()
|
||||
}
|
||||
|
||||
#ifdef ABILITY_COMMAND_FOR_TEST
|
||||
int MockAbilityDelegatorStub::ForceTimeoutForTest(const std::string &abilityName, const std::string &state)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int MockAbilityDelegatorStub2::ForceTimeoutForTest(const std::string &abilityName, const std::string &state)
|
||||
{
|
||||
return 0;
|
||||
@@ -403,6 +388,17 @@ int MockAbilityDelegatorStub2::ForceTimeoutForTest(const std::string &abilityNam
|
||||
#endif
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
int MockAbilityDelegatorStub::SetMissionIcon(
|
||||
const sptr<IRemoteObject> &token, const std::shared_ptr<OHOS::Media::PixelMap> &icon)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int MockAbilityDelegatorStub::RegisterWindowManagerServiceHandler(const sptr<IWindowManagerServiceHandler>& handler)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int MockAbilityDelegatorStub2::SetMissionIcon(
|
||||
const sptr<IRemoteObject> &token, const std::shared_ptr<OHOS::Media::PixelMap> &icon)
|
||||
{
|
||||
|
||||
+2
-2
@@ -110,7 +110,6 @@ public:
|
||||
MOCK_METHOD0(CleanAllMissions, int());
|
||||
MOCK_METHOD1(MoveMissionToFront, int(int32_t missionId));
|
||||
MOCK_METHOD2(MoveMissionToFront, int(int32_t missionId, const StartOptions &startOptions));
|
||||
MOCK_METHOD2(SetMissionLabel, int(const sptr<IRemoteObject> &token, const std::string &label));
|
||||
MOCK_METHOD1(ClearUpApplicationData, int(const std::string &));
|
||||
MOCK_METHOD1(GetAbilityRunningInfos, int(std::vector<AbilityRunningInfo> &info));
|
||||
MOCK_METHOD2(GetExtensionRunningInfos, int(int upperLimit, std::vector<ExtensionRunningInfo> &info));
|
||||
@@ -152,6 +151,7 @@ public:
|
||||
virtual int ForceTimeoutForTest(const std::string &abilityName, const std::string &state) override;
|
||||
#endif
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
MOCK_METHOD2(SetMissionLabel, int(const sptr<IRemoteObject> &token, const std::string &label));
|
||||
virtual int SetMissionIcon(
|
||||
const sptr<IRemoteObject> &token, const std::shared_ptr<OHOS::Media::PixelMap> &icon) override;
|
||||
virtual int RegisterWindowManagerServiceHandler(const sptr<IWindowManagerServiceHandler>& handler);
|
||||
@@ -247,7 +247,6 @@ public:
|
||||
MOCK_METHOD0(CleanAllMissions, int());
|
||||
MOCK_METHOD1(MoveMissionToFront, int(int32_t missionId));
|
||||
MOCK_METHOD2(MoveMissionToFront, int(int32_t missionId, const StartOptions &startOptions));
|
||||
MOCK_METHOD2(SetMissionLabel, int(const sptr<IRemoteObject> &token, const std::string &label));
|
||||
MOCK_METHOD1(ClearUpApplicationData, int(const std::string &));
|
||||
MOCK_METHOD1(GetAbilityRunningInfos, int(std::vector<AbilityRunningInfo> &info));
|
||||
MOCK_METHOD2(GetExtensionRunningInfos, int(int upperLimit, std::vector<ExtensionRunningInfo> &info));
|
||||
@@ -289,6 +288,7 @@ public:
|
||||
virtual int ForceTimeoutForTest(const std::string &abilityName, const std::string &state) override;
|
||||
#endif
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
MOCK_METHOD2(SetMissionLabel, int(const sptr<IRemoteObject> &token, const std::string &label));
|
||||
virtual int SetMissionIcon(
|
||||
const sptr<IRemoteObject> &token, const std::shared_ptr<OHOS::Media::PixelMap> &icon) override;
|
||||
virtual int RegisterWindowManagerServiceHandler(const sptr<IWindowManagerServiceHandler>& handler);
|
||||
|
||||
@@ -406,6 +406,7 @@ PendingWant *PendingWant::Unmarshalling(Parcel &parcel)
|
||||
}
|
||||
sptr<AAFwk::IWantSender> target = iface_cast<AAFwk::IWantSender>(parcel.ReadObject<IRemoteObject>());
|
||||
if (target == nullptr) {
|
||||
delete pendingWant;
|
||||
return nullptr;
|
||||
}
|
||||
pendingWant->SetTarget(target);
|
||||
|
||||
@@ -589,6 +589,7 @@ public:
|
||||
*/
|
||||
ErrCode RegisterSnapshotHandler(const sptr<ISnapshotHandler>& handler);
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
/**
|
||||
* Set mission label of this ability.
|
||||
*
|
||||
@@ -598,7 +599,6 @@ public:
|
||||
*/
|
||||
ErrCode SetMissionLabel(const sptr<IRemoteObject> &abilityToken, const std::string &label);
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
/**
|
||||
* Set mission icon of this ability.
|
||||
*
|
||||
|
||||
@@ -466,9 +466,9 @@ public:
|
||||
|
||||
virtual int StopUser(int userId, const sptr<IStopUserCallback> &callback) = 0;
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
virtual int SetMissionLabel(const sptr<IRemoteObject> &abilityToken, const std::string &label) = 0;
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
virtual int SetMissionIcon(const sptr<IRemoteObject> &token,
|
||||
const std::shared_ptr<OHOS::Media::PixelMap> &icon) = 0;
|
||||
|
||||
|
||||
@@ -41,6 +41,16 @@ enum LastExitReason {
|
||||
LASTEXITREASON_NORMAL
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum OnContinueResult
|
||||
* OnContinueResult defines the result of onContinue.
|
||||
*/
|
||||
enum OnContinueResult {
|
||||
ONCONTINUE_AGREE = 0,
|
||||
ONCONTINUE_REJECT,
|
||||
ONCONTINUE_MISMATCH
|
||||
};
|
||||
|
||||
/**
|
||||
* @struct LaunchParam
|
||||
* LaunchParam is used to save information about ability launch param.
|
||||
|
||||
@@ -59,6 +59,18 @@ static napi_value InitLastExitReasonObject(napi_env env)
|
||||
return object;
|
||||
}
|
||||
|
||||
static napi_value InitOnContinueResultObject(napi_env env)
|
||||
{
|
||||
napi_value object;
|
||||
NAPI_CALL(env, napi_create_object(env, &object));
|
||||
|
||||
NAPI_CALL(env, SetEnumItem(env, object, "AGREE", ONCONTINUE_AGREE));
|
||||
NAPI_CALL(env, SetEnumItem(env, object, "REJECT", ONCONTINUE_REJECT));
|
||||
NAPI_CALL(env, SetEnumItem(env, object, "MISMATCH", ONCONTINUE_MISMATCH));
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
/*
|
||||
* The module initialization.
|
||||
*/
|
||||
@@ -70,9 +82,13 @@ static napi_value AbilityConstantInit(napi_env env, napi_value exports)
|
||||
napi_value lastExitReason = InitLastExitReasonObject(env);
|
||||
NAPI_ASSERT(env, lastExitReason != nullptr, "failed to create last exit reason object");
|
||||
|
||||
napi_value onContinueResult = InitOnContinueResultObject(env);
|
||||
NAPI_ASSERT(env, onContinueResult != nullptr, "failed to create onContinue result object");
|
||||
|
||||
napi_property_descriptor exportObjs[] = {
|
||||
DECLARE_NAPI_PROPERTY("LaunchReason", launchReason),
|
||||
DECLARE_NAPI_PROPERTY("LastExitReason", lastExitReason),
|
||||
DECLARE_NAPI_PROPERTY("OnContinueResult", onContinueResult),
|
||||
};
|
||||
napi_status status = napi_define_properties(env, exports, sizeof(exportObjs) / sizeof(exportObjs[0]), exportObjs);
|
||||
NAPI_ASSERT(env, status == napi_ok, "failed to define properties for exports");
|
||||
|
||||
@@ -911,11 +911,7 @@ void CallOnAbilityResult(int requestCode, int resultCode, const Want &resultData
|
||||
} else {
|
||||
// promise
|
||||
HILOG_INFO("CallOnAbilityResult, promise");
|
||||
if (onAbilityCB->resultCode == ERR_OK) {
|
||||
napi_resolve_deferred(onAbilityCB->cb.env, onAbilityCB->cb.deferred, result[PARAM1]);
|
||||
} else {
|
||||
napi_reject_deferred(onAbilityCB->cb.env, onAbilityCB->cb.deferred, result[PARAM1]);
|
||||
}
|
||||
napi_resolve_deferred(onAbilityCB->cb.env, onAbilityCB->cb.deferred, result[PARAM1]);
|
||||
HILOG_INFO("CallOnAbilityResult, promise end");
|
||||
}
|
||||
|
||||
|
||||
@@ -181,8 +181,265 @@ napi_value SetShowOnLockScreenPromise(napi_env env, ShowOnLockScreenCB *cbData)
|
||||
HILOG_INFO("%{public}s, promise end.", __func__);
|
||||
return promise;
|
||||
}
|
||||
#endif
|
||||
|
||||
napi_value NAPI_SetDisplayOrientationWrap(napi_env env, napi_callback_info info, AsyncJSCallbackInfo *asyncCallbackInfo)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s called.", __func__);
|
||||
size_t argc = ARGS_MAX_COUNT;
|
||||
napi_value args[ARGS_MAX_COUNT] = {nullptr};
|
||||
napi_value jsthis = 0;
|
||||
void *data = nullptr;
|
||||
|
||||
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, &jsthis, &data));
|
||||
|
||||
if (!UnwrapSetDisplayOrientation(env, argc, args, asyncCallbackInfo)) {
|
||||
HILOG_INFO("%{public}s called. Invoke UnwrapSetDisplayOrientation fail", __func__);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
AsyncParamEx asyncParamEx;
|
||||
if (asyncCallbackInfo->cbInfo.callback != nullptr) {
|
||||
HILOG_INFO("%{public}s called. asyncCallback.", __func__);
|
||||
asyncParamEx.resource = "NAPI_SetDisplayOrientationCallback";
|
||||
asyncParamEx.execute = SetDisplayOrientationExecuteCallbackWork;
|
||||
asyncParamEx.complete = CompleteAsyncCallbackWork;
|
||||
|
||||
return ExecuteAsyncCallbackWork(env, asyncCallbackInfo, &asyncParamEx);
|
||||
} else {
|
||||
HILOG_INFO("%{public}s called. promise.", __func__);
|
||||
asyncParamEx.resource = "NAPI_SetDisplayOrientationPromise";
|
||||
asyncParamEx.execute = SetDisplayOrientationExecuteCallbackWork;
|
||||
asyncParamEx.complete = CompletePromiseCallbackWork;
|
||||
|
||||
return ExecutePromiseCallbackWork(env, asyncCallbackInfo, &asyncParamEx);
|
||||
}
|
||||
}
|
||||
|
||||
void SetDisplayOrientationExecuteCallbackWork(napi_env env, void *data)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s called.", __func__);
|
||||
AsyncJSCallbackInfo *asyncCallbackInfo = static_cast<AsyncJSCallbackInfo *>(data);
|
||||
if (asyncCallbackInfo == nullptr) {
|
||||
HILOG_INFO("%{public}s called. asyncCallbackInfo is null", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
asyncCallbackInfo->error_code = NAPI_ERR_NO_ERROR;
|
||||
asyncCallbackInfo->native_data.data_type = NVT_NONE;
|
||||
if (asyncCallbackInfo->ability == nullptr) {
|
||||
asyncCallbackInfo->error_code = NAPI_ERR_ACE_ABILITY;
|
||||
return;
|
||||
}
|
||||
|
||||
int orientation = asyncCallbackInfo->param.paramArgs.GetIntValue("orientation");
|
||||
asyncCallbackInfo->ability->SetDisplayOrientation(orientation);
|
||||
asyncCallbackInfo->native_data.data_type = NVT_INT32;
|
||||
asyncCallbackInfo->native_data.int32_value = 1;
|
||||
}
|
||||
|
||||
bool UnwrapSetDisplayOrientation(napi_env env, size_t argc, napi_value *argv, AsyncJSCallbackInfo *asyncCallbackInfo)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s called, argc=%{public}zu", __func__, argc);
|
||||
|
||||
const size_t argcMax = 2;
|
||||
if (argc > argcMax || argc < argcMax - 1) {
|
||||
HILOG_ERROR("%{public}s called, Params is invalid.", __func__);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (argc == argcMax) {
|
||||
if (!CreateAsyncCallback(env, argv[PARAM1], asyncCallbackInfo)) {
|
||||
HILOG_DEBUG("%{public}s called, the second parameter is invalid.", __func__);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
int orientation = 0;
|
||||
if (!UnwrapInt32FromJS2(env, argv[PARAM0], orientation)) {
|
||||
HILOG_ERROR("%{public}s called, the parameter is invalid.", __func__);
|
||||
return false;
|
||||
}
|
||||
|
||||
int maxRange = 3;
|
||||
if (orientation < 0 || orientation > maxRange) {
|
||||
HILOG_ERROR("%{public}s called, wrong parameter range.", __func__);
|
||||
return false;
|
||||
}
|
||||
|
||||
asyncCallbackInfo->param.paramArgs.PutIntValue("orientation", orientation);
|
||||
return true;
|
||||
}
|
||||
|
||||
static void SetWakeUpScreenAsyncCompleteCB(napi_env env, napi_status status, void *data)
|
||||
{
|
||||
HILOG_INFO("%{public}s,called", __func__);
|
||||
SetWakeUpScreenCB *setWakeUpScreenCB = static_cast<SetWakeUpScreenCB *>(data);
|
||||
if (setWakeUpScreenCB == nullptr) {
|
||||
HILOG_ERROR("%{public}s, input param is nullptr", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
do {
|
||||
setWakeUpScreenCB->cbBase.errCode = NAPI_ERR_NO_ERROR;
|
||||
if (setWakeUpScreenCB->cbBase.ability == nullptr) {
|
||||
HILOG_ERROR("%{public}s, input param is nullptr", __func__);
|
||||
setWakeUpScreenCB->cbBase.errCode = NAPI_ERR_ACE_ABILITY;
|
||||
break;
|
||||
}
|
||||
|
||||
setWakeUpScreenCB->cbBase.ability->SetWakeUpScreen(setWakeUpScreenCB->wakeUp);
|
||||
} while (false);
|
||||
|
||||
napi_value callback = nullptr;
|
||||
napi_value undefined = nullptr;
|
||||
napi_value callResult = nullptr;
|
||||
napi_value result[ARGS_TWO] = {nullptr};
|
||||
napi_get_undefined(env, &undefined);
|
||||
result[PARAM0] = GetCallbackErrorValue(env, setWakeUpScreenCB->cbBase.errCode);
|
||||
napi_get_null(env, &result[PARAM1]);
|
||||
napi_get_reference_value(env, setWakeUpScreenCB->cbBase.cbInfo.callback, &callback);
|
||||
napi_call_function(env, undefined, callback, ARGS_TWO, &result[PARAM0], &callResult);
|
||||
|
||||
if (setWakeUpScreenCB->cbBase.cbInfo.callback != nullptr) {
|
||||
napi_delete_reference(env, setWakeUpScreenCB->cbBase.cbInfo.callback);
|
||||
}
|
||||
napi_delete_async_work(env, setWakeUpScreenCB->cbBase.asyncWork);
|
||||
delete setWakeUpScreenCB;
|
||||
setWakeUpScreenCB = nullptr;
|
||||
|
||||
HILOG_INFO("%{public}s,called end", __func__);
|
||||
}
|
||||
|
||||
static napi_value SetWakeUpScreenAsync(napi_env env, napi_value *args, SetWakeUpScreenCB *cbData)
|
||||
{
|
||||
HILOG_INFO("%{public}s,called", __func__);
|
||||
if (cbData == nullptr || args == nullptr) {
|
||||
HILOG_ERROR("%{public}s, input param is nullptr", __func__);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
napi_valuetype valuetypeParam0 = napi_undefined;
|
||||
napi_valuetype valuetypeParam1 = napi_undefined;
|
||||
NAPI_CALL(env, napi_typeof(env, args[PARAM0], &valuetypeParam0));
|
||||
NAPI_CALL(env, napi_typeof(env, args[PARAM1], &valuetypeParam1));
|
||||
if (valuetypeParam0 != napi_boolean || valuetypeParam1 != napi_function) {
|
||||
HILOG_ERROR("%{public}s, Params is error type", __func__);
|
||||
return nullptr;
|
||||
}
|
||||
NAPI_CALL(env, napi_create_reference(env, args[PARAM1], 1, &cbData->cbBase.cbInfo.callback));
|
||||
|
||||
napi_value resourceName = nullptr;
|
||||
NAPI_CALL(env, napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName));
|
||||
|
||||
NAPI_CALL(env,
|
||||
napi_create_async_work(
|
||||
env,
|
||||
nullptr,
|
||||
resourceName,
|
||||
[](napi_env env, void *data) { HILOG_INFO("NAPI_SetWakeUpScreenScreen, worker pool thread execute."); },
|
||||
SetWakeUpScreenAsyncCompleteCB,
|
||||
(void *)cbData,
|
||||
&cbData->cbBase.asyncWork));
|
||||
NAPI_CALL(env, napi_queue_async_work(env, cbData->cbBase.asyncWork));
|
||||
napi_value result = nullptr;
|
||||
NAPI_CALL(env, napi_get_null(env, &result));
|
||||
|
||||
HILOG_INFO("%{public}s,called end", __func__);
|
||||
return result;
|
||||
}
|
||||
|
||||
napi_value SetWakeUpScreenPromise(napi_env env, SetWakeUpScreenCB *cbData)
|
||||
{
|
||||
HILOG_INFO("%{public}s, promise.", __func__);
|
||||
if (cbData == nullptr) {
|
||||
HILOG_ERROR("%{public}s, param == nullptr.", __func__);
|
||||
return nullptr;
|
||||
}
|
||||
napi_value resourceName = 0;
|
||||
napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName);
|
||||
napi_deferred deferred;
|
||||
napi_value promise = 0;
|
||||
napi_create_promise(env, &deferred, &promise);
|
||||
cbData->cbBase.deferred = deferred;
|
||||
|
||||
napi_create_async_work(
|
||||
env,
|
||||
nullptr,
|
||||
resourceName,
|
||||
[](napi_env env, void *data) { HILOG_INFO("NAPI_SetWakeUpScreenScreen, worker pool thread execute."); },
|
||||
[](napi_env env, napi_status status, void *data) {
|
||||
HILOG_INFO("SetWakeUpScreenPromise, main event thread complete.");
|
||||
SetWakeUpScreenCB *setWakeUpScreenCB = static_cast<SetWakeUpScreenCB *>(data);
|
||||
setWakeUpScreenCB->cbBase.errCode = NO_ERROR;
|
||||
if (setWakeUpScreenCB->cbBase.ability == nullptr) {
|
||||
HILOG_ERROR("%{public}s, input param is nullptr", __func__);
|
||||
setWakeUpScreenCB->cbBase.errCode = NAPI_ERR_ACE_ABILITY;
|
||||
}
|
||||
|
||||
setWakeUpScreenCB->cbBase.ability->SetWakeUpScreen(setWakeUpScreenCB->wakeUp);
|
||||
napi_value result = GetCallbackErrorValue(env, setWakeUpScreenCB->cbBase.errCode);
|
||||
if (setWakeUpScreenCB->cbBase.errCode == NO_ERROR) {
|
||||
napi_resolve_deferred(env, setWakeUpScreenCB->cbBase.deferred, result);
|
||||
} else {
|
||||
napi_reject_deferred(env, setWakeUpScreenCB->cbBase.deferred, result);
|
||||
}
|
||||
|
||||
napi_delete_async_work(env, setWakeUpScreenCB->cbBase.asyncWork);
|
||||
delete setWakeUpScreenCB;
|
||||
setWakeUpScreenCB = nullptr;
|
||||
HILOG_INFO("SetWakeUpScreenPromise, main event thread complete end.");
|
||||
},
|
||||
(void *)cbData,
|
||||
&cbData->cbBase.asyncWork);
|
||||
napi_queue_async_work(env, cbData->cbBase.asyncWork);
|
||||
HILOG_INFO("%{public}s, promise end.", __func__);
|
||||
return promise;
|
||||
}
|
||||
|
||||
static napi_value SetWakeUpScreenWrap(napi_env env, napi_callback_info info, SetWakeUpScreenCB *cbData)
|
||||
{
|
||||
HILOG_INFO("%{public}s,called", __func__);
|
||||
if (cbData == nullptr) {
|
||||
HILOG_ERROR("%{public}s, input param cbData is nullptr", __func__);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
size_t argcAsync = 2;
|
||||
const size_t argStdValue = 2;
|
||||
const size_t argPromise = 1;
|
||||
napi_value args[ARGS_MAX_COUNT] = {nullptr};
|
||||
|
||||
NAPI_CALL(env, napi_get_cb_info(env, info, &argcAsync, args, nullptr, nullptr));
|
||||
if (argcAsync != argStdValue && argcAsync != argPromise) {
|
||||
HILOG_ERROR("%{public}s, Wrong argument count.", __func__);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!UnwrapBoolFromJS2(env, args[PARAM0], cbData->wakeUp)) {
|
||||
HILOG_ERROR("%{public}s, UnwrapBoolFromJS2(wakeUp) run error", __func__);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
napi_value global = nullptr;
|
||||
NAPI_CALL(env, napi_get_global(env, &global));
|
||||
|
||||
napi_value abilityObj = nullptr;
|
||||
NAPI_CALL(env, napi_get_named_property(env, global, "ability", &abilityObj));
|
||||
|
||||
Ability *ability = nullptr;
|
||||
NAPI_CALL(env, napi_get_value_external(env, abilityObj, (void **)&ability));
|
||||
|
||||
cbData->cbBase.ability = ability;
|
||||
napi_value ret = nullptr;
|
||||
if (argcAsync == argStdValue) {
|
||||
ret = SetWakeUpScreenAsync(env, args, cbData);
|
||||
} else {
|
||||
ret = SetWakeUpScreenPromise(env, cbData);
|
||||
}
|
||||
HILOG_INFO("%{public}s,called end", __func__);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
napi_value NAPI_SetShowOnLockScreen(napi_env env, napi_callback_info info)
|
||||
{
|
||||
@@ -2470,96 +2727,6 @@ napi_value NAPI_SetDisplayOrientation(napi_env env, napi_callback_info info)
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
napi_value NAPI_SetDisplayOrientationWrap(napi_env env, napi_callback_info info, AsyncJSCallbackInfo *asyncCallbackInfo)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s called.", __func__);
|
||||
size_t argc = ARGS_MAX_COUNT;
|
||||
napi_value args[ARGS_MAX_COUNT] = {nullptr};
|
||||
napi_value jsthis = 0;
|
||||
void *data = nullptr;
|
||||
|
||||
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, &jsthis, &data));
|
||||
|
||||
if (!UnwrapSetDisplayOrientation(env, argc, args, asyncCallbackInfo)) {
|
||||
HILOG_INFO("%{public}s called. Invoke UnwrapSetDisplayOrientation fail", __func__);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
AsyncParamEx asyncParamEx;
|
||||
if (asyncCallbackInfo->cbInfo.callback != nullptr) {
|
||||
HILOG_INFO("%{public}s called. asyncCallback.", __func__);
|
||||
asyncParamEx.resource = "NAPI_SetDisplayOrientationCallback";
|
||||
asyncParamEx.execute = SetDisplayOrientationExecuteCallbackWork;
|
||||
asyncParamEx.complete = CompleteAsyncCallbackWork;
|
||||
|
||||
return ExecuteAsyncCallbackWork(env, asyncCallbackInfo, &asyncParamEx);
|
||||
} else {
|
||||
HILOG_INFO("%{public}s called. promise.", __func__);
|
||||
asyncParamEx.resource = "NAPI_SetDisplayOrientationPromise";
|
||||
asyncParamEx.execute = SetDisplayOrientationExecuteCallbackWork;
|
||||
asyncParamEx.complete = CompletePromiseCallbackWork;
|
||||
|
||||
return ExecutePromiseCallbackWork(env, asyncCallbackInfo, &asyncParamEx);
|
||||
}
|
||||
}
|
||||
|
||||
void SetDisplayOrientationExecuteCallbackWork(napi_env env, void *data)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s called.", __func__);
|
||||
AsyncJSCallbackInfo *asyncCallbackInfo = static_cast<AsyncJSCallbackInfo *>(data);
|
||||
if (asyncCallbackInfo == nullptr) {
|
||||
HILOG_INFO("%{public}s called. asyncCallbackInfo is null", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
asyncCallbackInfo->error_code = NAPI_ERR_NO_ERROR;
|
||||
asyncCallbackInfo->native_data.data_type = NVT_NONE;
|
||||
if (asyncCallbackInfo->ability == nullptr) {
|
||||
asyncCallbackInfo->error_code = NAPI_ERR_ACE_ABILITY;
|
||||
return;
|
||||
}
|
||||
|
||||
int orientation = asyncCallbackInfo->param.paramArgs.GetIntValue("orientation");
|
||||
asyncCallbackInfo->ability->SetDisplayOrientation(orientation);
|
||||
asyncCallbackInfo->native_data.data_type = NVT_INT32;
|
||||
asyncCallbackInfo->native_data.int32_value = 1;
|
||||
}
|
||||
|
||||
bool UnwrapSetDisplayOrientation(napi_env env, size_t argc, napi_value *argv, AsyncJSCallbackInfo *asyncCallbackInfo)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s called, argc=%{public}zu", __func__, argc);
|
||||
|
||||
const size_t argcMax = 2;
|
||||
if (argc > argcMax || argc < argcMax - 1) {
|
||||
HILOG_ERROR("%{public}s called, Params is invalid.", __func__);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (argc == argcMax) {
|
||||
if (!CreateAsyncCallback(env, argv[PARAM1], asyncCallbackInfo)) {
|
||||
HILOG_DEBUG("%{public}s called, the second parameter is invalid.", __func__);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
int orientation = 0;
|
||||
if (!UnwrapInt32FromJS2(env, argv[PARAM0], orientation)) {
|
||||
HILOG_ERROR("%{public}s called, the parameter is invalid.", __func__);
|
||||
return false;
|
||||
}
|
||||
|
||||
int maxRange = 3;
|
||||
if (orientation < 0 || orientation > maxRange) {
|
||||
HILOG_ERROR("%{public}s called, wrong parameter range.", __func__);
|
||||
return false;
|
||||
}
|
||||
|
||||
asyncCallbackInfo->param.paramArgs.PutIntValue("orientation", orientation);
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
napi_value NAPI_GetDisplayOrientation(napi_env env, napi_callback_info info)
|
||||
{
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
@@ -2616,178 +2783,6 @@ napi_value ContextPermissionInit(napi_env env, napi_value exports)
|
||||
return exports;
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
static void SetWakeUpScreenAsyncCompleteCB(napi_env env, napi_status status, void *data)
|
||||
{
|
||||
HILOG_INFO("%{public}s,called", __func__);
|
||||
SetWakeUpScreenCB *setWakeUpScreenCB = static_cast<SetWakeUpScreenCB *>(data);
|
||||
if (setWakeUpScreenCB == nullptr) {
|
||||
HILOG_ERROR("%{public}s, input param is nullptr", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
do {
|
||||
setWakeUpScreenCB->cbBase.errCode = NAPI_ERR_NO_ERROR;
|
||||
if (setWakeUpScreenCB->cbBase.ability == nullptr) {
|
||||
HILOG_ERROR("%{public}s, input param is nullptr", __func__);
|
||||
setWakeUpScreenCB->cbBase.errCode = NAPI_ERR_ACE_ABILITY;
|
||||
break;
|
||||
}
|
||||
|
||||
setWakeUpScreenCB->cbBase.ability->SetWakeUpScreen(setWakeUpScreenCB->wakeUp);
|
||||
} while (false);
|
||||
|
||||
napi_value callback = nullptr;
|
||||
napi_value undefined = nullptr;
|
||||
napi_value callResult = nullptr;
|
||||
napi_value result[ARGS_TWO] = {nullptr};
|
||||
napi_get_undefined(env, &undefined);
|
||||
result[PARAM0] = GetCallbackErrorValue(env, setWakeUpScreenCB->cbBase.errCode);
|
||||
napi_get_null(env, &result[PARAM1]);
|
||||
napi_get_reference_value(env, setWakeUpScreenCB->cbBase.cbInfo.callback, &callback);
|
||||
napi_call_function(env, undefined, callback, ARGS_TWO, &result[PARAM0], &callResult);
|
||||
|
||||
if (setWakeUpScreenCB->cbBase.cbInfo.callback != nullptr) {
|
||||
napi_delete_reference(env, setWakeUpScreenCB->cbBase.cbInfo.callback);
|
||||
}
|
||||
napi_delete_async_work(env, setWakeUpScreenCB->cbBase.asyncWork);
|
||||
delete setWakeUpScreenCB;
|
||||
setWakeUpScreenCB = nullptr;
|
||||
|
||||
HILOG_INFO("%{public}s,called end", __func__);
|
||||
}
|
||||
|
||||
static napi_value SetWakeUpScreenAsync(napi_env env, napi_value *args, SetWakeUpScreenCB *cbData)
|
||||
{
|
||||
HILOG_INFO("%{public}s,called", __func__);
|
||||
if (cbData == nullptr || args == nullptr) {
|
||||
HILOG_ERROR("%{public}s, input param is nullptr", __func__);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
napi_valuetype valuetypeParam0 = napi_undefined;
|
||||
napi_valuetype valuetypeParam1 = napi_undefined;
|
||||
NAPI_CALL(env, napi_typeof(env, args[PARAM0], &valuetypeParam0));
|
||||
NAPI_CALL(env, napi_typeof(env, args[PARAM1], &valuetypeParam1));
|
||||
if (valuetypeParam0 != napi_boolean || valuetypeParam1 != napi_function) {
|
||||
HILOG_ERROR("%{public}s, Params is error type", __func__);
|
||||
return nullptr;
|
||||
}
|
||||
NAPI_CALL(env, napi_create_reference(env, args[PARAM1], 1, &cbData->cbBase.cbInfo.callback));
|
||||
|
||||
napi_value resourceName = nullptr;
|
||||
NAPI_CALL(env, napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName));
|
||||
|
||||
NAPI_CALL(env,
|
||||
napi_create_async_work(
|
||||
env,
|
||||
nullptr,
|
||||
resourceName,
|
||||
[](napi_env env, void *data) { HILOG_INFO("NAPI_SetWakeUpScreenScreen, worker pool thread execute."); },
|
||||
SetWakeUpScreenAsyncCompleteCB,
|
||||
(void *)cbData,
|
||||
&cbData->cbBase.asyncWork));
|
||||
NAPI_CALL(env, napi_queue_async_work(env, cbData->cbBase.asyncWork));
|
||||
napi_value result = nullptr;
|
||||
NAPI_CALL(env, napi_get_null(env, &result));
|
||||
|
||||
HILOG_INFO("%{public}s,called end", __func__);
|
||||
return result;
|
||||
}
|
||||
|
||||
napi_value SetWakeUpScreenPromise(napi_env env, SetWakeUpScreenCB *cbData)
|
||||
{
|
||||
HILOG_INFO("%{public}s, promise.", __func__);
|
||||
if (cbData == nullptr) {
|
||||
HILOG_ERROR("%{public}s, param == nullptr.", __func__);
|
||||
return nullptr;
|
||||
}
|
||||
napi_value resourceName = 0;
|
||||
napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName);
|
||||
napi_deferred deferred;
|
||||
napi_value promise = 0;
|
||||
napi_create_promise(env, &deferred, &promise);
|
||||
cbData->cbBase.deferred = deferred;
|
||||
|
||||
napi_create_async_work(
|
||||
env,
|
||||
nullptr,
|
||||
resourceName,
|
||||
[](napi_env env, void *data) { HILOG_INFO("NAPI_SetWakeUpScreenScreen, worker pool thread execute."); },
|
||||
[](napi_env env, napi_status status, void *data) {
|
||||
HILOG_INFO("SetWakeUpScreenPromise, main event thread complete.");
|
||||
SetWakeUpScreenCB *setWakeUpScreenCB = static_cast<SetWakeUpScreenCB *>(data);
|
||||
setWakeUpScreenCB->cbBase.errCode = NO_ERROR;
|
||||
if (setWakeUpScreenCB->cbBase.ability == nullptr) {
|
||||
HILOG_ERROR("%{public}s, input param is nullptr", __func__);
|
||||
setWakeUpScreenCB->cbBase.errCode = NAPI_ERR_ACE_ABILITY;
|
||||
}
|
||||
|
||||
setWakeUpScreenCB->cbBase.ability->SetWakeUpScreen(setWakeUpScreenCB->wakeUp);
|
||||
napi_value result = GetCallbackErrorValue(env, setWakeUpScreenCB->cbBase.errCode);
|
||||
if (setWakeUpScreenCB->cbBase.errCode == NO_ERROR) {
|
||||
napi_resolve_deferred(env, setWakeUpScreenCB->cbBase.deferred, result);
|
||||
} else {
|
||||
napi_reject_deferred(env, setWakeUpScreenCB->cbBase.deferred, result);
|
||||
}
|
||||
|
||||
napi_delete_async_work(env, setWakeUpScreenCB->cbBase.asyncWork);
|
||||
delete setWakeUpScreenCB;
|
||||
setWakeUpScreenCB = nullptr;
|
||||
HILOG_INFO("SetWakeUpScreenPromise, main event thread complete end.");
|
||||
},
|
||||
(void *)cbData,
|
||||
&cbData->cbBase.asyncWork);
|
||||
napi_queue_async_work(env, cbData->cbBase.asyncWork);
|
||||
HILOG_INFO("%{public}s, promise end.", __func__);
|
||||
return promise;
|
||||
}
|
||||
|
||||
static napi_value SetWakeUpScreenWrap(napi_env env, napi_callback_info info, SetWakeUpScreenCB *cbData)
|
||||
{
|
||||
HILOG_INFO("%{public}s,called", __func__);
|
||||
if (cbData == nullptr) {
|
||||
HILOG_ERROR("%{public}s, input param cbData is nullptr", __func__);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
size_t argcAsync = 2;
|
||||
const size_t argStdValue = 2;
|
||||
const size_t argPromise = 1;
|
||||
napi_value args[ARGS_MAX_COUNT] = {nullptr};
|
||||
|
||||
NAPI_CALL(env, napi_get_cb_info(env, info, &argcAsync, args, nullptr, nullptr));
|
||||
if (argcAsync != argStdValue && argcAsync != argPromise) {
|
||||
HILOG_ERROR("%{public}s, Wrong argument count.", __func__);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!UnwrapBoolFromJS2(env, args[PARAM0], cbData->wakeUp)) {
|
||||
HILOG_ERROR("%{public}s, UnwrapBoolFromJS2(wakeUp) run error", __func__);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
napi_value global = nullptr;
|
||||
NAPI_CALL(env, napi_get_global(env, &global));
|
||||
|
||||
napi_value abilityObj = nullptr;
|
||||
NAPI_CALL(env, napi_get_named_property(env, global, "ability", &abilityObj));
|
||||
|
||||
Ability *ability = nullptr;
|
||||
NAPI_CALL(env, napi_get_value_external(env, abilityObj, (void **)&ability));
|
||||
|
||||
cbData->cbBase.ability = ability;
|
||||
napi_value ret = nullptr;
|
||||
if (argcAsync == argStdValue) {
|
||||
ret = SetWakeUpScreenAsync(env, args, cbData);
|
||||
} else {
|
||||
ret = SetWakeUpScreenPromise(env, cbData);
|
||||
}
|
||||
HILOG_INFO("%{public}s,called end", __func__);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
napi_value NAPI_SetWakeUpScreen(napi_env env, napi_callback_info info)
|
||||
{
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
|
||||
@@ -44,33 +44,6 @@ void JsMissionListener::OnMissionMovedToFront(int32_t missionId)
|
||||
CallJsMethod("onMissionMovedToFront", missionId);
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
void JsMissionListener::OnMissionIconUpdated(int32_t missionId, const std::shared_ptr<Media::PixelMap> &icon)
|
||||
{
|
||||
HILOG_INFO("OnMissionIconUpdated, missionId = %{public}d", missionId);
|
||||
if (engine_ == nullptr) {
|
||||
HILOG_ERROR("engine_ is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
if (missionId <= 0 || !icon) {
|
||||
HILOG_ERROR("missionId or icon is invalid, missionId:%{public}d", missionId);
|
||||
return;
|
||||
}
|
||||
|
||||
// js callback must run in js thread
|
||||
std::unique_ptr<AsyncTask::CompleteCallback> complete = std::make_unique<AsyncTask::CompleteCallback>
|
||||
([jsMissionListener = this, missionId, icon](NativeEngine &engine, AsyncTask &task, int32_t status) {
|
||||
if (jsMissionListener) {
|
||||
jsMissionListener->CallJsMissionIconUpdated(missionId, icon);
|
||||
}
|
||||
});
|
||||
NativeReference* callback = nullptr;
|
||||
std::unique_ptr<AsyncTask::ExecuteCallback> execute = nullptr;
|
||||
AsyncTask::Schedule(*engine_, std::make_unique<AsyncTask>(callback, std::move(execute), std::move(complete)));
|
||||
}
|
||||
#endif
|
||||
|
||||
void JsMissionListener::AddJsListenerObject(int32_t listenerId, NativeValue* jsListenerObject)
|
||||
{
|
||||
jsListenerObjectMap_.emplace(
|
||||
@@ -134,6 +107,31 @@ void JsMissionListener::CallJsMethodInner(const std::string &methodName, int32_t
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
void JsMissionListener::OnMissionIconUpdated(int32_t missionId, const std::shared_ptr<Media::PixelMap> &icon)
|
||||
{
|
||||
HILOG_INFO("OnMissionIconUpdated, missionId = %{public}d", missionId);
|
||||
if (engine_ == nullptr) {
|
||||
HILOG_ERROR("engine_ is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
if (missionId <= 0 || !icon) {
|
||||
HILOG_ERROR("missionId or icon is invalid, missionId:%{public}d", missionId);
|
||||
return;
|
||||
}
|
||||
|
||||
// js callback must run in js thread
|
||||
std::unique_ptr<AsyncTask::CompleteCallback> complete = std::make_unique<AsyncTask::CompleteCallback>
|
||||
([jsMissionListener = this, missionId, icon](NativeEngine &engine, AsyncTask &task, int32_t status) {
|
||||
if (jsMissionListener) {
|
||||
jsMissionListener->CallJsMissionIconUpdated(missionId, icon);
|
||||
}
|
||||
});
|
||||
NativeReference* callback = nullptr;
|
||||
std::unique_ptr<AsyncTask::ExecuteCallback> execute = nullptr;
|
||||
AsyncTask::Schedule(*engine_, std::make_unique<AsyncTask>(callback, std::move(execute), std::move(complete)));
|
||||
}
|
||||
|
||||
void JsMissionListener::CallJsMissionIconUpdated(int32_t missionId, const std::shared_ptr<Media::PixelMap> &icon)
|
||||
{
|
||||
if (engine_ == nullptr) {
|
||||
|
||||
@@ -35,22 +35,22 @@ public:
|
||||
void OnMissionSnapshotChanged(int32_t missionId) override;
|
||||
void OnMissionMovedToFront(int32_t missionId) override;
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
void OnMissionIconUpdated(int32_t missionId, const std::shared_ptr<Media::PixelMap> &icon) override;
|
||||
#endif
|
||||
|
||||
void AddJsListenerObject(int32_t listenerId, NativeValue* jsListenerObject);
|
||||
bool RemoveJsListenerObject(int32_t listenerId);
|
||||
bool IsEmpty();
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
public:
|
||||
void OnMissionIconUpdated(int32_t missionId, const std::shared_ptr<Media::PixelMap> &icon) override;
|
||||
|
||||
private:
|
||||
void CallJsMissionIconUpdated(int32_t missionId, const std::shared_ptr<Media::PixelMap> &icon);
|
||||
#endif
|
||||
|
||||
private:
|
||||
void CallJsMethod(const std::string &methodName, int32_t missionId);
|
||||
void CallJsMethodInner(const std::string &methodName, int32_t missionId);
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
void CallJsMissionIconUpdated(int32_t missionId, const std::shared_ptr<Media::PixelMap> &icon);
|
||||
#endif
|
||||
|
||||
NativeEngine* engine_ = nullptr;
|
||||
std::map<int32_t, std::shared_ptr<NativeReference>> jsListenerObjectMap_;
|
||||
std::shared_ptr<OHOS::AppExecFwk::EventHandler> mainHandler_;
|
||||
|
||||
@@ -431,9 +431,9 @@ public:
|
||||
|
||||
virtual int StopUser(int userId, const sptr<IStopUserCallback> &callback) override;
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
virtual int SetMissionLabel(const sptr<IRemoteObject> &abilityToken, const std::string &label) override;
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
virtual int SetMissionIcon(const sptr<IRemoteObject> &token,
|
||||
const std::shared_ptr<OHOS::Media::PixelMap> &icon) override;
|
||||
|
||||
|
||||
@@ -595,8 +595,6 @@ public:
|
||||
|
||||
virtual int StopUser(int userId, const sptr<IStopUserCallback> &callback) override;
|
||||
|
||||
virtual int SetMissionLabel(const sptr<IRemoteObject> &abilityToken, const std::string &label) override;
|
||||
|
||||
/**
|
||||
* Called when client complete dump.
|
||||
*
|
||||
@@ -607,6 +605,8 @@ public:
|
||||
virtual int DumpAbilityInfoDone(std::vector<std::string> &infos, const sptr<IRemoteObject> &callerToken) override;
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
virtual int SetMissionLabel(const sptr<IRemoteObject> &abilityToken, const std::string &label) override;
|
||||
|
||||
virtual int SetMissionIcon(const sptr<IRemoteObject> &token,
|
||||
const std::shared_ptr<OHOS::Media::PixelMap> &icon) override;
|
||||
|
||||
@@ -949,9 +949,6 @@ private:
|
||||
|
||||
int32_t InitAbilityInfoFromExtension(AppExecFwk::ExtensionAbilityInfo &extensionInfo,
|
||||
AppExecFwk::AbilityInfo &abilityInfo);
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
int32_t ShowPickerDialog(const Want& want, int32_t userId);
|
||||
#endif
|
||||
|
||||
// multi user
|
||||
void StartFreezingScreen();
|
||||
@@ -1041,9 +1038,7 @@ private:
|
||||
|
||||
std::unordered_map<int, std::shared_ptr<MissionListManager>> missionListManagers_;
|
||||
std::shared_ptr<MissionListManager> currentMissionListManager_;
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
sptr<IWindowManagerServiceHandler> wmsHandler_;
|
||||
#endif
|
||||
|
||||
std::shared_ptr<UserController> userController_;
|
||||
sptr<AppExecFwk::IAbilityController> abilityController_ = nullptr;
|
||||
bool controllerIsAStabilityTest_ = false;
|
||||
@@ -1053,6 +1048,12 @@ private:
|
||||
std::multimap<std::string, std::string> timeoutMap_;
|
||||
|
||||
static sptr<AbilityManagerService> instance_;
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
int32_t ShowPickerDialog(const Want& want, int32_t userId);
|
||||
|
||||
sptr<IWindowManagerServiceHandler> wmsHandler_;
|
||||
#endif
|
||||
};
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -129,8 +129,6 @@ private:
|
||||
int ReleaseInner(MessageParcel &data, MessageParcel &reply);
|
||||
int StartUserInner(MessageParcel &data, MessageParcel &reply);
|
||||
int StopUserInner(MessageParcel &data, MessageParcel &reply);
|
||||
int SetMissionLabelInner(MessageParcel &data, MessageParcel &reply);
|
||||
int SetMissionIconInner(MessageParcel &data, MessageParcel &reply);
|
||||
int GetAbilityRunningInfosInner(MessageParcel &data, MessageParcel &reply);
|
||||
int GetExtensionRunningInfosInner(MessageParcel &data, MessageParcel &reply);
|
||||
int GetProcessRunningInfosInner(MessageParcel &data, MessageParcel &reply);
|
||||
@@ -155,6 +153,8 @@ private:
|
||||
int MoveMissionToFrontByOptionsInner(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
int SetMissionLabelInner(MessageParcel &data, MessageParcel &reply);
|
||||
int SetMissionIconInner(MessageParcel &data, MessageParcel &reply);
|
||||
int RegisterWindowManagerServiceHandlerInner(MessageParcel &data, MessageParcel &reply);
|
||||
int CompleteFirstFrameDrawingInner(MessageParcel &data, MessageParcel &reply);
|
||||
#endif
|
||||
|
||||
@@ -666,6 +666,8 @@ public:
|
||||
int32_t GetUid();
|
||||
void SetSwitchingPause(bool state);
|
||||
bool IsSwitchingPause();
|
||||
void SetOwnerMissionUserId(int32_t userId);
|
||||
int32_t GetOwnerMissionUserId();
|
||||
|
||||
// new version
|
||||
ResolveResultType Resolve(const AbilityRequest &abilityRequest);
|
||||
@@ -759,6 +761,7 @@ private:
|
||||
std::weak_ptr<MissionList> missionList_;
|
||||
std::weak_ptr<Mission> mission_;
|
||||
int32_t missionId_ = -1;
|
||||
int32_t ownerMissionUserId_ = -1;
|
||||
bool isSwitchingPause_ = false;
|
||||
|
||||
// new version
|
||||
|
||||
@@ -71,15 +71,6 @@ public:
|
||||
*/
|
||||
void DeleteMissionSnapshot(int32_t missionId);
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
/**
|
||||
* @brief Get the Snapshot object
|
||||
* @param missionId Indicates this mission id.
|
||||
* @return Returns PixelMap of snapshot.
|
||||
*/
|
||||
sptr<Media::PixelMap> GetSnapshot(int missionId) const;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Get the Mission Snapshot object
|
||||
* @param missionId
|
||||
@@ -88,6 +79,21 @@ public:
|
||||
*/
|
||||
bool GetMissionSnapshot(int32_t missionId, MissionSnapshot& missionSnapshot);
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
public:
|
||||
/**
|
||||
* @brief Get the Snapshot object
|
||||
* @param missionId Indicates this mission id.
|
||||
* @return Returns PixelMap of snapshot.
|
||||
*/
|
||||
sptr<Media::PixelMap> GetSnapshot(int missionId) const;
|
||||
|
||||
std::unique_ptr<Media::PixelMap> GetPixelMap(int missionId) const;
|
||||
|
||||
private:
|
||||
std::map<int32_t, std::shared_ptr<Media::PixelMap>> cachedPixelMap_;
|
||||
#endif
|
||||
|
||||
private:
|
||||
std::string GetMissionDataDirPath() const;
|
||||
|
||||
@@ -107,17 +113,9 @@ private:
|
||||
|
||||
void SaveSnapshotFile(int32_t missionId, const MissionSnapshot& missionSnapshot);
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
std::unique_ptr<Media::PixelMap> GetPixelMap(int missionId) const;
|
||||
#endif
|
||||
|
||||
private:
|
||||
int userId_ = 0;
|
||||
std::shared_ptr<AppExecFwk::EventHandler> handler_;
|
||||
std::mutex cachedPixelMapMutex_;
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
std::map<int32_t, std::shared_ptr<Media::PixelMap>> cachedPixelMap_;
|
||||
#endif
|
||||
};
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -256,28 +256,6 @@ public:
|
||||
*/
|
||||
sptr<IRemoteObject> GetAbilityTokenByMissionId(int32_t missionId);
|
||||
|
||||
/**
|
||||
* Set mission label of this ability.
|
||||
*
|
||||
* @param abilityToken target ability token.
|
||||
* @param label target label.
|
||||
* @return Retun 0 if success.
|
||||
*/
|
||||
int SetMissionLabel(const sptr<IRemoteObject> &abilityToken, const std::string &label);
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
/**
|
||||
* Set mission icon of this ability.
|
||||
*
|
||||
* @param token target ability token.
|
||||
* @param icon target label.
|
||||
* @return Retun 0 if success.
|
||||
*/
|
||||
int SetMissionIcon(const sptr<IRemoteObject> &token, const std::shared_ptr<Media::PixelMap> &icon);
|
||||
|
||||
void CompleteFirstFrameDrawing(const sptr<IRemoteObject> &abilityToken) const;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief dump all abilities
|
||||
*
|
||||
@@ -364,6 +342,62 @@ public:
|
||||
bool IsStarted();
|
||||
void PauseManager();
|
||||
void ResumeManager();
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
public:
|
||||
/**
|
||||
* Set mission label of this ability.
|
||||
*
|
||||
* @param abilityToken target ability token.
|
||||
* @param label target label.
|
||||
* @return Retun 0 if success.
|
||||
*/
|
||||
int SetMissionLabel(const sptr<IRemoteObject> &abilityToken, const std::string &label);
|
||||
|
||||
/**
|
||||
* Set mission icon of this ability.
|
||||
*
|
||||
* @param token target ability token.
|
||||
* @param icon target label.
|
||||
* @return Retun 0 if success.
|
||||
*/
|
||||
int SetMissionIcon(const sptr<IRemoteObject> &token, const std::shared_ptr<Media::PixelMap> &icon);
|
||||
|
||||
void CompleteFirstFrameDrawing(const sptr<IRemoteObject> &abilityToken) const;
|
||||
|
||||
private:
|
||||
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 sptr<IRemoteObject> abilityToken) const;
|
||||
void SetShowWhenLocked(const AppExecFwk::AbilityInfo &abilityInfo, sptr<AbilityTransitionInfo> &info) const;
|
||||
void SetAbilityTransitionInfo(const AppExecFwk::AbilityInfo &abilityInfo, sptr<AbilityTransitionInfo> &info) const;
|
||||
void SetWindowModeAndDisplayId(sptr<AbilityTransitionInfo> &info, const Want &want) const;
|
||||
|
||||
sptr<IWindowManagerServiceHandler> GetWMSHandler() const;
|
||||
|
||||
void StartingWindowCold(const std::shared_ptr<AbilityRecord> &abilityRecord,
|
||||
const std::shared_ptr<StartOptions> &startOptions, const Want &want,
|
||||
const AbilityRequest &abilityRequest) const;
|
||||
void StartingWindowHot(const std::shared_ptr<AbilityRecord> &abilityRecord,
|
||||
const std::shared_ptr<StartOptions> &startOptions, const Want &want, const AbilityRequest &abilityRequest,
|
||||
int32_t missionId) const;
|
||||
std::shared_ptr<Global::Resource::ResourceManager> CreateResourceManager(
|
||||
const AppExecFwk::AbilityInfo &abilityInfo) const;
|
||||
sptr<Media::PixelMap> GetPixelMap(const uint32_t windowIconId,
|
||||
std::shared_ptr<Global::Resource::ResourceManager> resourceManager) const;
|
||||
sptr<AbilityTransitionInfo> CreateAbilityTransitionInfo(const sptr<IRemoteObject> abilityToken,
|
||||
const std::shared_ptr<StartOptions> &startOptions, const Want &want) const;
|
||||
sptr<AbilityTransitionInfo> CreateAbilityTransitionInfo(const AbilityRequest &abilityRequest,
|
||||
const sptr<IRemoteObject> abilityToken) const;
|
||||
void CancelStartingWindow(const sptr<IRemoteObject> abilityToken, bool isDelay) const;
|
||||
void NotifyStartingWindow(bool isCold, const std::shared_ptr<Mission> &targetMission,
|
||||
const std::shared_ptr<AbilityRecord> &targetAbilityRecord, const AbilityRequest &abilityRequest,
|
||||
const std::shared_ptr<AbilityRecord> &callerAbility);
|
||||
void NotifyStartingWindow(bool isCold, const std::shared_ptr<AbilityRecord> &targetAbilityRecord,
|
||||
std::shared_ptr<StartOptions> &startOptions, int32_t missionId);
|
||||
#endif
|
||||
|
||||
private:
|
||||
int StartAbilityLocked(const std::shared_ptr<AbilityRecord> ¤tTopAbility,
|
||||
const std::shared_ptr<AbilityRecord> &callerAbility, const AbilityRequest &abilityRequest);
|
||||
@@ -430,40 +464,6 @@ private:
|
||||
void AddUninstallTags(const std::string &bundleName, int32_t uid);
|
||||
void RemoveMissionLocked(int32_t missionId);
|
||||
|
||||
#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 sptr<IRemoteObject> abilityToken) const;
|
||||
void SetShowWhenLocked(const AppExecFwk::AbilityInfo &abilityInfo, sptr<AbilityTransitionInfo> &info) const;
|
||||
void SetAbilityTransitionInfo(const AppExecFwk::AbilityInfo &abilityInfo, sptr<AbilityTransitionInfo> &info) const;
|
||||
void SetWindowModeAndDisplayId(sptr<AbilityTransitionInfo> &info, const Want &want) const;
|
||||
|
||||
sptr<IWindowManagerServiceHandler> GetWMSHandler() const;
|
||||
|
||||
void StartingWindowCold(const std::shared_ptr<AbilityRecord> &abilityRecord,
|
||||
const std::shared_ptr<StartOptions> &startOptions, const Want &want,
|
||||
const AbilityRequest &abilityRequest) const;
|
||||
void StartingWindowHot(const std::shared_ptr<AbilityRecord> &abilityRecord,
|
||||
const std::shared_ptr<StartOptions> &startOptions, const Want &want, const AbilityRequest &abilityRequest,
|
||||
int32_t missionId) const;
|
||||
std::shared_ptr<Global::Resource::ResourceManager> CreateResourceManager(
|
||||
const AppExecFwk::AbilityInfo &abilityInfo) const;
|
||||
sptr<Media::PixelMap> GetPixelMap(const uint32_t windowIconId,
|
||||
std::shared_ptr<Global::Resource::ResourceManager> resourceManager) const;
|
||||
sptr<AbilityTransitionInfo> CreateAbilityTransitionInfo(const sptr<IRemoteObject> abilityToken,
|
||||
const std::shared_ptr<StartOptions> &startOptions, const Want &want) const;
|
||||
sptr<AbilityTransitionInfo> CreateAbilityTransitionInfo(const AbilityRequest &abilityRequest,
|
||||
const sptr<IRemoteObject> abilityToken) const;
|
||||
void CancelStartingWindow(const sptr<IRemoteObject> abilityToken, bool isDelay) const;
|
||||
void NotifyStartingWindow(bool isCold, const std::shared_ptr<Mission> &targetMission,
|
||||
const std::shared_ptr<AbilityRecord> &targetAbilityRecord, const AbilityRequest &abilityRequest,
|
||||
const std::shared_ptr<AbilityRecord> &callerAbility);
|
||||
void NotifyStartingWindow(bool isCold, const std::shared_ptr<AbilityRecord> &targetAbilityRecord,
|
||||
std::shared_ptr<StartOptions> &startOptions, int32_t missionId);
|
||||
#endif
|
||||
|
||||
private:
|
||||
int userId_;
|
||||
mutable std::recursive_mutex managerLock_;
|
||||
// launcher list is also in currentMissionLists_
|
||||
@@ -479,14 +479,12 @@ private:
|
||||
std::shared_ptr<MissionListenerController> listenerController_;
|
||||
bool isPC_ = false;
|
||||
|
||||
private:
|
||||
class MissionDmInitCallback : public DistributedHardware::DmInitCallback {
|
||||
public:
|
||||
void OnRemoteDied() override;
|
||||
class MissionDmInitCallback : public DistributedHardware::DmInitCallback {
|
||||
public:
|
||||
void OnRemoteDied() override;
|
||||
|
||||
public:
|
||||
static bool isInit_;
|
||||
};
|
||||
static bool isInit_;
|
||||
};
|
||||
};
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -34,13 +34,14 @@ public:
|
||||
virtual ~ScreenshotHandler() = default;
|
||||
|
||||
void StartScreenshot(int32_t missionId, int32_t winId);
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
OHOS::WMImageInfo GetImageInfo(int32_t missionId);
|
||||
#endif
|
||||
|
||||
void RemoveImageInfo(int32_t missionId);
|
||||
|
||||
private:
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
public:
|
||||
OHOS::WMImageInfo GetImageInfo(int32_t missionId);
|
||||
|
||||
private:
|
||||
std::map<int32_t, OHOS::WMImageInfo> screenShot_;
|
||||
sptr<IWindowManagerService> windowMS_;
|
||||
#endif
|
||||
|
||||
@@ -32,18 +32,20 @@ class ScreenShotResponse {
|
||||
public:
|
||||
ScreenShotResponse() = default;
|
||||
virtual ~ScreenShotResponse() = default;
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
public:
|
||||
void OnWindowShot(const OHOS::WMImageInfo &info);
|
||||
OHOS::WMImageInfo GetImageInfo();
|
||||
|
||||
private:
|
||||
std::shared_ptr<OHOS::WMImageInfo> info_;
|
||||
#endif
|
||||
|
||||
private:
|
||||
static constexpr int TIME_OUT = 200 * 1000;
|
||||
std::mutex mutex_;
|
||||
std::condition_variable condition_;
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
std::shared_ptr<OHOS::WMImageInfo> info_;
|
||||
#endif
|
||||
};
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -769,6 +769,7 @@ ErrCode AbilityManagerClient::DelegatorDoAbilityBackground(const sptr<IRemoteObj
|
||||
return abms->DelegatorDoAbilityBackground(token);
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
ErrCode AbilityManagerClient::SetMissionLabel(const sptr<IRemoteObject> &token, const std::string& label)
|
||||
{
|
||||
auto abms = GetAbilityManager();
|
||||
@@ -776,7 +777,6 @@ ErrCode AbilityManagerClient::SetMissionLabel(const sptr<IRemoteObject> &token,
|
||||
return abms->SetMissionLabel(token, label);
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
ErrCode AbilityManagerClient::SetMissionIcon(
|
||||
const sptr<IRemoteObject> &abilityToken, const std::shared_ptr<OHOS::Media::PixelMap> &icon)
|
||||
{
|
||||
|
||||
@@ -1791,6 +1791,7 @@ int AbilityManagerProxy::StopUser(int userId, const sptr<IStopUserCallback> &cal
|
||||
return reply.ReadInt32();
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
int AbilityManagerProxy::SetMissionLabel(const sptr<IRemoteObject> &token, const std::string &label)
|
||||
{
|
||||
MessageParcel data;
|
||||
@@ -1815,7 +1816,6 @@ int AbilityManagerProxy::SetMissionLabel(const sptr<IRemoteObject> &token, const
|
||||
return reply.ReadInt32();
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
int AbilityManagerProxy::SetMissionIcon(const sptr<IRemoteObject> &token,
|
||||
const std::shared_ptr<OHOS::Media::PixelMap> &icon)
|
||||
{
|
||||
|
||||
@@ -35,9 +35,6 @@
|
||||
#include "ability_util.h"
|
||||
#include "hitrace_meter.h"
|
||||
#include "bundle_mgr_client.h"
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
#include "display_manager.h"
|
||||
#endif
|
||||
#include "distributed_client.h"
|
||||
#include "free_install_manager.h"
|
||||
#include "hilog_wrapper.h"
|
||||
@@ -46,11 +43,6 @@
|
||||
#include "ipc_skeleton.h"
|
||||
#include "iservice_registry.h"
|
||||
#include "itest_observer.h"
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
#include "png.h"
|
||||
#include "ui_service_mgr_client.h"
|
||||
#include "locale_config.h"
|
||||
#endif
|
||||
#include "mission_info_mgr.h"
|
||||
#include "permission_constants.h"
|
||||
#include "permission_verification.h"
|
||||
@@ -66,6 +58,13 @@
|
||||
#include "parameter.h"
|
||||
#include "event_report.h"
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
#include "display_manager.h"
|
||||
#include "png.h"
|
||||
#include "ui_service_mgr_client.h"
|
||||
#include "locale_config.h"
|
||||
#endif
|
||||
|
||||
using OHOS::AppExecFwk::ElementName;
|
||||
using OHOS::Security::AccessToken::AccessTokenKit;
|
||||
|
||||
@@ -325,7 +324,8 @@ int AbilityManagerService::StartAbilityInner(const Want &want, const sptr<IRemot
|
||||
HILOG_ERROR("%{public}s VerificationAllToken failed.", __func__);
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
int32_t validUserId = GetValidUserId(userId);
|
||||
int32_t oriValidUserId = GetValidUserId(userId);
|
||||
int32_t validUserId = oriValidUserId;
|
||||
if (!JudgeMultiUserConcurrency(validUserId)) {
|
||||
HILOG_ERROR("Multi-user non-concurrent mode is not satisfied.");
|
||||
return ERR_INVALID_VALUE;
|
||||
@@ -383,7 +383,7 @@ int AbilityManagerService::StartAbilityInner(const Want &want, const sptr<IRemot
|
||||
HILOG_ERROR("IsAbilityControllerStart failed: %{public}s.", abilityInfo.bundleName.c_str());
|
||||
return ERR_WOULD_BLOCK;
|
||||
}
|
||||
auto missionListManager = GetListManagerByUserId(validUserId);
|
||||
auto missionListManager = GetListManagerByUserId(oriValidUserId);
|
||||
if (missionListManager == nullptr) {
|
||||
HILOG_ERROR("missionListManager is nullptr. userId=%{public}d", validUserId);
|
||||
return ERR_INVALID_VALUE;
|
||||
@@ -416,7 +416,8 @@ int AbilityManagerService::StartAbility(const Want &want, const AbilityStartSett
|
||||
AAFWK::EventReport::SendAbilityEvent(AAFWK::START_ABILITY_ERROR, AAFWK::HiSysEventType::FAULT, eventInfo);
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
int32_t validUserId = GetValidUserId(userId);
|
||||
int32_t oriValidUserId = GetValidUserId(userId);
|
||||
int32_t validUserId = oriValidUserId;
|
||||
if (!JudgeMultiUserConcurrency(validUserId)) {
|
||||
HILOG_ERROR("Multi-user non-concurrent mode is not satisfied.");
|
||||
eventInfo.errCode = ERR_INVALID_VALUE;
|
||||
@@ -484,11 +485,15 @@ int AbilityManagerService::StartAbility(const Want &want, const AbilityStartSett
|
||||
AAFWK::EventReport::SendAbilityEvent(AAFWK::START_ABILITY_ERROR, AAFWK::HiSysEventType::FAULT, eventInfo);
|
||||
return ERR_WOULD_BLOCK;
|
||||
}
|
||||
auto missionListManager = GetListManagerByUserId(validUserId);
|
||||
auto missionListManager = GetListManagerByUserId(oriValidUserId);
|
||||
if (missionListManager == nullptr) {
|
||||
<<<<<<< HEAD
|
||||
HILOG_ERROR("missionListManager is Null. userId=%{public}d", validUserId);
|
||||
eventInfo.errCode = ERR_INVALID_VALUE;
|
||||
AAFWK::EventReport::SendAbilityEvent(AAFWK::START_ABILITY_ERROR, AAFWK::HiSysEventType::FAULT, eventInfo);
|
||||
=======
|
||||
HILOG_ERROR("missionListManager is Null. userId=%{public}d", oriValidUserId);
|
||||
>>>>>>> upstream/master
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
return missionListManager->StartAbility(abilityRequest);
|
||||
@@ -518,7 +523,8 @@ int AbilityManagerService::StartAbility(const Want &want, const StartOptions &st
|
||||
AAFWK::EventReport::SendAbilityEvent(AAFWK::START_ABILITY_ERROR, AAFWK::HiSysEventType::FAULT, eventInfo);
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
int32_t validUserId = GetValidUserId(userId);
|
||||
int32_t oriValidUserId = GetValidUserId(userId);
|
||||
int32_t validUserId = oriValidUserId;
|
||||
if (!JudgeMultiUserConcurrency(validUserId)) {
|
||||
HILOG_ERROR("Multi-user non-concurrent mode is not satisfied.");
|
||||
eventInfo.errCode = ERR_INVALID_VALUE;
|
||||
@@ -581,11 +587,15 @@ int AbilityManagerService::StartAbility(const Want &want, const StartOptions &st
|
||||
GrantUriPermission(want, validUserId);
|
||||
abilityRequest.want.SetParam(Want::PARAM_RESV_DISPLAY_ID, startOptions.GetDisplayID());
|
||||
abilityRequest.want.SetParam(Want::PARAM_RESV_WINDOW_MODE, startOptions.GetWindowMode());
|
||||
auto missionListManager = GetListManagerByUserId(validUserId);
|
||||
auto missionListManager = GetListManagerByUserId(oriValidUserId);
|
||||
if (missionListManager == nullptr) {
|
||||
<<<<<<< HEAD
|
||||
HILOG_ERROR("missionListManager is Null. userId=%{public}d", validUserId);
|
||||
eventInfo.errCode = ERR_INVALID_VALUE;
|
||||
AAFWK::EventReport::SendAbilityEvent(AAFWK::START_ABILITY_ERROR, AAFWK::HiSysEventType::FAULT, eventInfo);
|
||||
=======
|
||||
HILOG_ERROR("missionListManager is Null. userId=%{public}d", oriValidUserId);
|
||||
>>>>>>> upstream/master
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
return missionListManager->StartAbility(abilityRequest);
|
||||
@@ -874,9 +884,10 @@ int AbilityManagerService::TerminateAbilityWithFlag(const sptr<IRemoteObject> &t
|
||||
return ERR_WOULD_BLOCK;
|
||||
}
|
||||
|
||||
auto missionListManager = GetListManagerByUserId(userId);
|
||||
auto ownerUserId = abilityRecord->GetOwnerMissionUserId();
|
||||
auto missionListManager = GetListManagerByUserId(ownerUserId);
|
||||
if (missionListManager == nullptr) {
|
||||
HILOG_ERROR("missionListManager is Null. userId=%{public}d", userId);
|
||||
HILOG_ERROR("missionListManager is Null. ownerUserId=%{public}d", ownerUserId);
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
return missionListManager->TerminateAbility(abilityRecord, resultCode, resultWant, flag);
|
||||
@@ -1038,7 +1049,6 @@ int AbilityManagerService::MinimizeAbility(const sptr<IRemoteObject> &token, boo
|
||||
return result;
|
||||
}
|
||||
|
||||
auto userId = abilityRecord->GetApplicationInfo().uid / BASE_USER_RANGE;
|
||||
auto type = abilityRecord->GetAbilityInfo().type;
|
||||
if (type != AppExecFwk::AbilityType::PAGE) {
|
||||
HILOG_ERROR("Cannot minimize except page ability.");
|
||||
@@ -1048,7 +1058,8 @@ int AbilityManagerService::MinimizeAbility(const sptr<IRemoteObject> &token, boo
|
||||
if (!IsAbilityControllerForeground(abilityRecord->GetAbilityInfo().bundleName)) {
|
||||
return ERR_WOULD_BLOCK;
|
||||
}
|
||||
auto missionListManager = GetListManagerByUserId(userId);
|
||||
|
||||
auto missionListManager = GetListManagerByUserId(abilityRecord->GetOwnerMissionUserId());
|
||||
if (!missionListManager) {
|
||||
HILOG_ERROR("missionListManager is Null.");
|
||||
return ERR_INVALID_VALUE;
|
||||
@@ -1909,9 +1920,10 @@ int AbilityManagerService::AttachAbilityThread(
|
||||
}
|
||||
returnCode = dataAbilityManager->AttachAbilityThread(scheduler, token);
|
||||
} else {
|
||||
auto missionListManager = GetListManagerByUserId(userId);
|
||||
int32_t ownerMissionUserId = abilityRecord->GetOwnerMissionUserId();
|
||||
auto missionListManager = GetListManagerByUserId(ownerMissionUserId);
|
||||
if (!missionListManager) {
|
||||
HILOG_ERROR("missionListManager is Null. userId=%{public}d", userId);
|
||||
HILOG_ERROR("missionListManager is Null. userId=%{public}d", ownerMissionUserId);
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
returnCode = missionListManager->AttachAbilityThread(scheduler, token);
|
||||
@@ -2334,9 +2346,10 @@ int AbilityManagerService::AbilityTransitionDone(const sptr<IRemoteObject> &toke
|
||||
}
|
||||
return dataAbilityManager->AbilityTransitionDone(token, state);
|
||||
}
|
||||
auto missionListManager = GetListManagerByUserId(userId);
|
||||
int32_t ownerMissionUserId = abilityRecord->GetOwnerMissionUserId();
|
||||
auto missionListManager = GetListManagerByUserId(ownerMissionUserId);
|
||||
if (!missionListManager) {
|
||||
HILOG_ERROR("missionListManager is Null. userId=%{public}d", userId);
|
||||
HILOG_ERROR("missionListManager is Null. userId=%{public}d", ownerMissionUserId);
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
return missionListManager->AbilityTransactionDone(token, state, saveData);
|
||||
@@ -2453,9 +2466,10 @@ void AbilityManagerService::OnAbilityRequestDone(const sptr<IRemoteObject> &toke
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
auto missionListManager = GetListManagerByUserId(userId);
|
||||
int32_t ownerMissionUserId = abilityRecord->GetOwnerMissionUserId();
|
||||
auto missionListManager = GetListManagerByUserId(ownerMissionUserId);
|
||||
if (!missionListManager) {
|
||||
HILOG_ERROR("missionListManager is Null. userId=%{public}d", userId);
|
||||
HILOG_ERROR("missionListManager is Null. userId=%{public}d", ownerMissionUserId);
|
||||
return;
|
||||
}
|
||||
missionListManager->OnAbilityRequestDone(token, state);
|
||||
@@ -2735,7 +2749,7 @@ void AbilityManagerService::OnAbilityDied(std::shared_ptr<AbilityRecord> ability
|
||||
{
|
||||
CHECK_POINTER(abilityRecord);
|
||||
|
||||
auto manager = GetListManagerByToken(abilityRecord->GetToken());
|
||||
auto manager = GetListManagerByUserId(abilityRecord->GetOwnerMissionUserId());
|
||||
if (manager) {
|
||||
manager->OnAbilityDied(abilityRecord, GetUserId());
|
||||
return;
|
||||
@@ -2814,10 +2828,20 @@ int AbilityManagerService::UninstallApp(const std::string &bundleName, int32_t u
|
||||
}
|
||||
|
||||
int32_t targetUserId = uid / BASE_USER_RANGE;
|
||||
auto listManager = GetListManagerByUserId(targetUserId);
|
||||
if (listManager) {
|
||||
listManager->UninstallApp(bundleName, uid);
|
||||
if (targetUserId == U0_USER_ID) {
|
||||
std::shared_lock<std::shared_mutex> lock(managersMutex_);
|
||||
for (auto item: missionListManagers_) {
|
||||
if (item.second) {
|
||||
item.second->UninstallApp(bundleName, uid);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
auto listManager = GetListManagerByUserId(targetUserId);
|
||||
if (listManager) {
|
||||
listManager->UninstallApp(bundleName, uid);
|
||||
}
|
||||
}
|
||||
|
||||
if (pendingWantManager_) {
|
||||
pendingWantManager_->ClearPendingWantRecord(bundleName, uid);
|
||||
}
|
||||
@@ -3081,22 +3105,6 @@ std::shared_ptr<DataAbilityManager> AbilityManagerService::GetDataAbilityManager
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::shared_ptr<MissionListManager> AbilityManagerService::GetListManagerByToken(const sptr<IRemoteObject> &token)
|
||||
{
|
||||
std::shared_lock<std::shared_mutex> lock(managersMutex_);
|
||||
for (auto item: missionListManagers_) {
|
||||
if (item.second && item.second->GetAbilityRecordByToken(token)) {
|
||||
return item.second;
|
||||
}
|
||||
|
||||
if (item.second && item.second->GetAbilityFromTerminateList(token)) {
|
||||
return item.second;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::shared_ptr<AbilityConnectManager> AbilityManagerService::GetConnectManagerByToken(
|
||||
const sptr<IRemoteObject> &token)
|
||||
{
|
||||
@@ -3275,10 +3283,10 @@ int32_t AbilityManagerService::GetMissionIdByAbilityToken(const sptr<IRemoteObje
|
||||
HILOG_ERROR("abilityRecord is Null.");
|
||||
return -1;
|
||||
}
|
||||
auto userId = abilityRecord->GetApplicationInfo().uid / BASE_USER_RANGE;
|
||||
auto userId = abilityRecord->GetOwnerMissionUserId();
|
||||
auto missionListManager = GetListManagerByUserId(userId);
|
||||
if (!missionListManager) {
|
||||
HILOG_ERROR("missionListManager is Null. userId=%{public}d", userId);
|
||||
HILOG_ERROR("missionListManager is Null. owner mission userId=%{public}d", userId);
|
||||
return -1;
|
||||
}
|
||||
return missionListManager->GetMissionIdByAbilityToken(token);
|
||||
@@ -3379,14 +3387,10 @@ int AbilityManagerService::StartAbilityByCall(
|
||||
|
||||
HILOG_DEBUG("abilityInfo.applicationInfo.singleton is %{public}s",
|
||||
abilityRequest.abilityInfo.applicationInfo.singleton ? "true" : "false");
|
||||
if (abilityRequest.abilityInfo.applicationInfo.singleton) {
|
||||
auto missionListManager = GetListManagerByUserId(U0_USER_ID);
|
||||
if (missionListManager == nullptr) {
|
||||
HILOG_ERROR("missionListManager is Null. userId=%{public}d", U0_USER_ID);
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
return missionListManager->ResolveLocked(abilityRequest);
|
||||
if (!currentMissionListManager_) {
|
||||
HILOG_ERROR("currentMissionListManager_ is Null. curentUserId=%{public}d", GetUserId());
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
return currentMissionListManager_->ResolveLocked(abilityRequest);
|
||||
@@ -3453,73 +3457,6 @@ int AbilityManagerService::CheckCallPermissions(const AbilityRequest &abilityReq
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
int AbilityManagerService::SetMissionLabel(const sptr<IRemoteObject> &token, const std::string &label)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s", __func__);
|
||||
auto missionListManager = currentMissionListManager_;
|
||||
if (missionListManager) {
|
||||
missionListManager->SetMissionLabel(token, label);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
int AbilityManagerService::SetMissionIcon(const sptr<IRemoteObject> &token,
|
||||
const std::shared_ptr<OHOS::Media::PixelMap> &icon)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s", __func__);
|
||||
auto abilityRecord = Token::GetAbilityRecordByToken(token);
|
||||
if (!abilityRecord) {
|
||||
HILOG_ERROR("no such ability record");
|
||||
return -1;
|
||||
}
|
||||
|
||||
auto callingUid = IPCSkeleton::GetCallingUid();
|
||||
auto recordUid = abilityRecord->GetUid();
|
||||
if (callingUid != recordUid) {
|
||||
HILOG_ERROR("not self, callingUid:%{public}d, recordUid:%{public}d", callingUid, recordUid);
|
||||
return -1;
|
||||
}
|
||||
|
||||
auto userId = callingUid / BASE_USER_RANGE;
|
||||
auto missionListManager = GetListManagerByUserId(userId);
|
||||
if (!missionListManager) {
|
||||
HILOG_ERROR("failed to find mission list manager.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
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_;
|
||||
}
|
||||
|
||||
void AbilityManagerService::CompleteFirstFrameDrawing(const sptr<IRemoteObject> &abilityToken)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s is called.", __func__);
|
||||
std::shared_lock<std::shared_mutex> lock(managersMutex_);
|
||||
for (auto& item : missionListManagers_) {
|
||||
if (item.second) {
|
||||
item.second->CompleteFirstFrameDrawing(abilityToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
int AbilityManagerService::StartUser(int userId)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s, userId:%{public}d", __func__, userId);
|
||||
@@ -3723,7 +3660,9 @@ void AbilityManagerService::SwitchManagers(int32_t userId, bool switchUser)
|
||||
{
|
||||
HILOG_INFO("%{public}s, SwitchManagers:%{public}d-----begin", __func__, userId);
|
||||
InitConnectManager(userId, switchUser);
|
||||
InitMissionListManager(userId, switchUser);
|
||||
if (userId != U0_USER_ID) {
|
||||
InitMissionListManager(userId, switchUser);
|
||||
}
|
||||
InitDataAbilityManager(userId, switchUser);
|
||||
InitPendWantManager(userId, switchUser);
|
||||
HILOG_INFO("%{public}s, SwitchManagers:%{public}d-----end", __func__, userId);
|
||||
@@ -4145,21 +4084,6 @@ int AbilityManagerService::DelegatorMoveMissionToFront(int32_t missionId)
|
||||
return currentMissionListManager_->MoveMissionToFront(missionId);
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
int32_t AbilityManagerService::ShowPickerDialog(const Want& want, int32_t userId)
|
||||
{
|
||||
auto bms = GetBundleManager();
|
||||
CHECK_POINTER_AND_RETURN(bms, GET_ABILITY_SERVICE_FAILED);
|
||||
HILOG_INFO("share content: ShowPickerDialog, userId is %{public}d", userId);
|
||||
std::vector<AppExecFwk::AbilityInfo> abilityInfos;
|
||||
IN_PROCESS_CALL_WITHOUT_RET(
|
||||
bms->QueryAbilityInfos(
|
||||
want, AppExecFwk::AbilityInfoFlag::GET_ABILITY_INFO_WITH_APPLICATION, userId, abilityInfos)
|
||||
);
|
||||
return Ace::UIServiceMgrClient::GetInstance()->ShowAppPickerDialog(want, abilityInfos, userId);
|
||||
}
|
||||
#endif
|
||||
|
||||
void AbilityManagerService::UpdateCallerInfo(Want& want)
|
||||
{
|
||||
int32_t tokenId = (int32_t)IPCSkeleton::GetCallingTokenID();
|
||||
@@ -4683,5 +4607,101 @@ int AbilityManagerService::DumpAbilityInfoDone(std::vector<std::string> &infos,
|
||||
abilityRecord->DumpAbilityInfoDone(infos);
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
int AbilityManagerService::SetMissionLabel(const sptr<IRemoteObject> &token, const std::string &label)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s", __func__);
|
||||
auto abilityRecord = Token::GetAbilityRecordByToken(token);
|
||||
if (!abilityRecord) {
|
||||
HILOG_ERROR("no such ability record");
|
||||
return -1;
|
||||
}
|
||||
|
||||
auto callingUid = IPCSkeleton::GetCallingUid();
|
||||
auto recordUid = abilityRecord->GetUid();
|
||||
if (callingUid != recordUid) {
|
||||
HILOG_ERROR("SetMissionLabel not self, callingUid:%{public}d, recordUid:%{public}d", callingUid, recordUid);
|
||||
return -1;
|
||||
}
|
||||
|
||||
auto userId = abilityRecord->GetOwnerMissionUserId();
|
||||
auto missionListManager = GetListManagerByUserId(userId);
|
||||
if (!missionListManager) {
|
||||
HILOG_ERROR("failed to find mission list manager when set mission label.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return missionListManager->SetMissionLabel(token, label);
|
||||
}
|
||||
|
||||
int AbilityManagerService::SetMissionIcon(const sptr<IRemoteObject> &token,
|
||||
const std::shared_ptr<OHOS::Media::PixelMap> &icon)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s", __func__);
|
||||
auto abilityRecord = Token::GetAbilityRecordByToken(token);
|
||||
if (!abilityRecord) {
|
||||
HILOG_ERROR("no such ability record");
|
||||
return -1;
|
||||
}
|
||||
|
||||
auto callingUid = IPCSkeleton::GetCallingUid();
|
||||
auto recordUid = abilityRecord->GetUid();
|
||||
if (callingUid != recordUid) {
|
||||
HILOG_ERROR("not self, callingUid:%{public}d, recordUid:%{public}d", callingUid, recordUid);
|
||||
return -1;
|
||||
}
|
||||
|
||||
auto userId = abilityRecord->GetOwnerMissionUserId();
|
||||
auto missionListManager = GetListManagerByUserId(userId);
|
||||
if (!missionListManager) {
|
||||
HILOG_ERROR("failed to find mission list manager.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
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_;
|
||||
}
|
||||
|
||||
void AbilityManagerService::CompleteFirstFrameDrawing(const sptr<IRemoteObject> &abilityToken)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s is called.", __func__);
|
||||
std::shared_lock<std::shared_mutex> lock(managersMutex_);
|
||||
for (auto& item : missionListManagers_) {
|
||||
if (item.second) {
|
||||
item.second->CompleteFirstFrameDrawing(abilityToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int32_t AbilityManagerService::ShowPickerDialog(const Want& want, int32_t userId)
|
||||
{
|
||||
auto bms = GetBundleManager();
|
||||
CHECK_POINTER_AND_RETURN(bms, GET_ABILITY_SERVICE_FAILED);
|
||||
HILOG_INFO("share content: ShowPickerDialog, userId is %{public}d", userId);
|
||||
std::vector<AppExecFwk::AbilityInfo> abilityInfos;
|
||||
IN_PROCESS_CALL_WITHOUT_RET(
|
||||
bms->QueryAbilityInfos(
|
||||
want, AppExecFwk::AbilityInfoFlag::GET_ABILITY_INFO_WITH_APPLICATION, userId, abilityInfos)
|
||||
);
|
||||
return Ace::UIServiceMgrClient::GetInstance()->ShowAppPickerDialog(want, abilityInfos, userId);
|
||||
}
|
||||
#endif
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -109,7 +109,6 @@ void AbilityManagerStub::SecondStepInit()
|
||||
requestFuncMap_[MOVE_MISSION_TO_FRONT_BY_OPTIONS] = &AbilityManagerStub::MoveMissionToFrontByOptionsInner;
|
||||
requestFuncMap_[START_CALL_ABILITY] = &AbilityManagerStub::StartAbilityByCallInner;
|
||||
requestFuncMap_[RELEASE_CALL_ABILITY] = &AbilityManagerStub::ReleaseInner;
|
||||
requestFuncMap_[SET_MISSION_LABEL] = &AbilityManagerStub::SetMissionLabelInner;
|
||||
requestFuncMap_[START_USER] = &AbilityManagerStub::StartUserInner;
|
||||
requestFuncMap_[STOP_USER] = &AbilityManagerStub::StopUserInner;
|
||||
requestFuncMap_[GET_ABILITY_RUNNING_INFO] = &AbilityManagerStub::GetAbilityRunningInfosInner;
|
||||
@@ -137,11 +136,12 @@ void AbilityManagerStub::ThirdStepInit()
|
||||
requestFuncMap_[DO_ABILITY_BACKGROUND] = &AbilityManagerStub::DoAbilityBackgroundInner;
|
||||
requestFuncMap_[GET_MISSION_ID_BY_ABILITY_TOKEN] = &AbilityManagerStub::GetMissionIdByTokenInner;
|
||||
requestFuncMap_[GET_TOP_ABILITY] = &AbilityManagerStub::GetTopAbilityInner;
|
||||
requestFuncMap_[SET_MISSION_ICON] = &AbilityManagerStub::SetMissionIconInner;
|
||||
requestFuncMap_[DUMP_ABILITY_INFO_DONE] = &AbilityManagerStub::DumpAbilityInfoDoneInner;
|
||||
requestFuncMap_[START_EXTENSION_ABILITY] = &AbilityManagerStub::StartExtensionAbilityInner;
|
||||
requestFuncMap_[STOP_EXTENSION_ABILITY] = &AbilityManagerStub::StopExtensionAbilityInner;
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
requestFuncMap_[SET_MISSION_LABEL] = &AbilityManagerStub::SetMissionLabelInner;
|
||||
requestFuncMap_[SET_MISSION_ICON] = &AbilityManagerStub::SetMissionIconInner;
|
||||
requestFuncMap_[REGISTER_WMS_HANDLER] = &AbilityManagerStub::RegisterWindowManagerServiceHandlerInner;
|
||||
requestFuncMap_[COMPLETEFIRSTFRAMEDRAWING] = &AbilityManagerStub::CompleteFirstFrameDrawingInner;
|
||||
#endif
|
||||
@@ -1065,50 +1065,6 @@ int AbilityManagerStub::StopUserInner(MessageParcel &data, MessageParcel &reply)
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
int AbilityManagerStub::SetMissionLabelInner(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
sptr<IRemoteObject> token = data.ReadRemoteObject();
|
||||
if (!token) {
|
||||
HILOG_ERROR("SetMissionLabelInner read ability token failed.");
|
||||
return ERR_NULL_OBJECT;
|
||||
}
|
||||
|
||||
std::string label = Str16ToStr8(data.ReadString16());
|
||||
int result = SetMissionLabel(token, label);
|
||||
if (!reply.WriteInt32(result)) {
|
||||
HILOG_ERROR("SetMissionLabel failed.");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
int AbilityManagerStub::SetMissionIconInner(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
sptr<IRemoteObject> token = data.ReadRemoteObject();
|
||||
if (!token) {
|
||||
HILOG_ERROR("SetMissionIconInner read ability token failed.");
|
||||
return ERR_NULL_OBJECT;
|
||||
}
|
||||
|
||||
std::shared_ptr<Media::PixelMap> icon(data.ReadParcelable<Media::PixelMap>());
|
||||
if (!icon) {
|
||||
HILOG_ERROR("SetMissionIconInner read icon failed.");
|
||||
return ERR_NULL_OBJECT;
|
||||
}
|
||||
|
||||
int result = SetMissionIcon(token, icon);
|
||||
if (!reply.WriteInt32(result)) {
|
||||
HILOG_ERROR("SetMissionIcon failed.");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
return NO_ERROR;
|
||||
#else
|
||||
HILOG_ERROR("do not support SetMissionIcon.");
|
||||
return ERR_INVALID_VALUE;
|
||||
#endif
|
||||
}
|
||||
|
||||
int AbilityManagerStub::GetAbilityRunningInfosInner(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
std::vector<AbilityRunningInfo> abilityRunningInfos;
|
||||
@@ -1227,30 +1183,6 @@ int AbilityManagerStub::RegisterSnapshotHandlerInner(MessageParcel &data, Messag
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
int AbilityManagerStub::RegisterWindowManagerServiceHandlerInner(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
sptr<IWindowManagerServiceHandler> handler = iface_cast<IWindowManagerServiceHandler>(data.ReadRemoteObject());
|
||||
if (handler == nullptr) {
|
||||
HILOG_ERROR("%{public}s read WMS handler failed!", __func__);
|
||||
return ERR_NULL_OBJECT;
|
||||
}
|
||||
return RegisterWindowManagerServiceHandler(handler);
|
||||
}
|
||||
|
||||
int AbilityManagerStub::CompleteFirstFrameDrawingInner(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s is called.", __func__);
|
||||
sptr<IRemoteObject> abilityToken = data.ReadRemoteObject();
|
||||
if (abilityToken == nullptr) {
|
||||
HILOG_ERROR("%{public}s read abilityToken failed!", __func__);
|
||||
return ERR_NULL_OBJECT;
|
||||
}
|
||||
CompleteFirstFrameDrawing(abilityToken);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
int AbilityManagerStub::GetMissionSnapshotInfoInner(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
std::string deviceId = data.ReadString();
|
||||
@@ -1473,5 +1405,68 @@ int AbilityManagerStub::DumpAbilityInfoDoneInner(MessageParcel &data, MessagePar
|
||||
}
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
int AbilityManagerStub::SetMissionLabelInner(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
sptr<IRemoteObject> token = data.ReadRemoteObject();
|
||||
if (!token) {
|
||||
HILOG_ERROR("SetMissionLabelInner read ability token failed.");
|
||||
return ERR_NULL_OBJECT;
|
||||
}
|
||||
|
||||
std::string label = Str16ToStr8(data.ReadString16());
|
||||
int result = SetMissionLabel(token, label);
|
||||
if (!reply.WriteInt32(result)) {
|
||||
HILOG_ERROR("SetMissionLabel failed.");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
int AbilityManagerStub::SetMissionIconInner(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
sptr<IRemoteObject> token = data.ReadRemoteObject();
|
||||
if (!token) {
|
||||
HILOG_ERROR("SetMissionIconInner read ability token failed.");
|
||||
return ERR_NULL_OBJECT;
|
||||
}
|
||||
|
||||
std::shared_ptr<Media::PixelMap> icon(data.ReadParcelable<Media::PixelMap>());
|
||||
if (!icon) {
|
||||
HILOG_ERROR("SetMissionIconInner read icon failed.");
|
||||
return ERR_NULL_OBJECT;
|
||||
}
|
||||
|
||||
int result = SetMissionIcon(token, icon);
|
||||
if (!reply.WriteInt32(result)) {
|
||||
HILOG_ERROR("SetMissionIcon failed.");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
int AbilityManagerStub::RegisterWindowManagerServiceHandlerInner(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
sptr<IWindowManagerServiceHandler> handler = iface_cast<IWindowManagerServiceHandler>(data.ReadRemoteObject());
|
||||
if (handler == nullptr) {
|
||||
HILOG_ERROR("%{public}s read WMS handler failed!", __func__);
|
||||
return ERR_NULL_OBJECT;
|
||||
}
|
||||
return RegisterWindowManagerServiceHandler(handler);
|
||||
}
|
||||
|
||||
int AbilityManagerStub::CompleteFirstFrameDrawingInner(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s is called.", __func__);
|
||||
sptr<IRemoteObject> abilityToken = data.ReadRemoteObject();
|
||||
if (abilityToken == nullptr) {
|
||||
HILOG_ERROR("%{public}s read abilityToken failed!", __func__);
|
||||
return ERR_NULL_OBJECT;
|
||||
}
|
||||
CompleteFirstFrameDrawing(abilityToken);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
namespace OHOS {
|
||||
namespace AAFwk {
|
||||
const std::string DEBUG_APP = "debugApp";
|
||||
const std::string ABILITY_OWNER_USERID = "AbilityMS_Owner_UserId";
|
||||
int64_t AbilityRecord::abilityRecordId = 0;
|
||||
int64_t AbilityRecord::g_abilityRecordEventId_ = 0;
|
||||
const int32_t DEFAULT_USER_ID = 0;
|
||||
@@ -183,8 +184,11 @@ int AbilityRecord::LoadAbility()
|
||||
callerToken_ = caller->GetToken();
|
||||
}
|
||||
}
|
||||
return DelayedSingleton<AppScheduler>::GetInstance()->LoadAbility(
|
||||
want_.SetParam(ABILITY_OWNER_USERID, ownerMissionUserId_);
|
||||
auto result = DelayedSingleton<AppScheduler>::GetInstance()->LoadAbility(
|
||||
token_, callerToken_, abilityInfo_, applicationInfo_, want_);
|
||||
want_.RemoveParam(ABILITY_OWNER_USERID);
|
||||
return result;
|
||||
}
|
||||
|
||||
bool AbilityRecord::CanRestartRootLauncher()
|
||||
@@ -1239,6 +1243,16 @@ bool AbilityRecord::IsSwitchingPause()
|
||||
return isSwitchingPause_;
|
||||
}
|
||||
|
||||
void AbilityRecord::SetOwnerMissionUserId(int32_t userId)
|
||||
{
|
||||
ownerMissionUserId_ = userId;
|
||||
}
|
||||
|
||||
int32_t AbilityRecord::GetOwnerMissionUserId()
|
||||
{
|
||||
return ownerMissionUserId_;
|
||||
}
|
||||
|
||||
void AbilityRecord::DumpSys(std::vector<std::string> &info, bool isClient)
|
||||
{
|
||||
std::string dumpInfo = " AbilityRecord ID #" + std::to_string(recordId_);
|
||||
|
||||
@@ -377,6 +377,7 @@ void MissionListManager::GetTargetMissionAndAbility(const AbilityRequest &abilit
|
||||
isCold = true;
|
||||
targetMission = std::make_shared<Mission>(info.missionInfo.id, targetRecord, missionName, startMethod);
|
||||
targetRecord->SetMission(targetMission);
|
||||
targetRecord->SetOwnerMissionUserId(userId_);
|
||||
} else {
|
||||
HILOG_DEBUG("Update old mission data.");
|
||||
auto state = targetMission->UpdateMissionId(info.missionInfo.id, startMethod);
|
||||
@@ -1718,6 +1719,7 @@ std::shared_ptr<MissionList> MissionListManager::GetTargetMissionList(int missio
|
||||
isCold = true;
|
||||
mission = std::make_shared<Mission>(innerMissionInfo.missionInfo.id, abilityRecord, innerMissionInfo.missionName);
|
||||
abilityRecord->SetMission(mission);
|
||||
abilityRecord->SetOwnerMissionUserId(userId_);
|
||||
std::shared_ptr<MissionList> newMissionList = std::make_shared<MissionList>();
|
||||
listenerController_->NotifyMissionCreated(innerMissionInfo.missionInfo.id);
|
||||
return newMissionList;
|
||||
@@ -1915,6 +1917,7 @@ void MissionListManager::BackToLauncher()
|
||||
launcherRootAbility->ProcessForegroundAbility();
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
int MissionListManager::SetMissionLabel(const sptr<IRemoteObject> &token, const std::string &label)
|
||||
{
|
||||
if (!token) {
|
||||
@@ -1931,7 +1934,6 @@ int MissionListManager::SetMissionLabel(const sptr<IRemoteObject> &token, const
|
||||
return DelayedSingleton<MissionInfoMgr>::GetInstance()->UpdateMissionLabel(missionId, label);
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
int MissionListManager::SetMissionIcon(const sptr<IRemoteObject> &token, const std::shared_ptr<Media::PixelMap> &icon)
|
||||
{
|
||||
if (!token) {
|
||||
|
||||
@@ -53,7 +53,6 @@ ohos_source_set("appmgr_test_service") {
|
||||
|
||||
if (ability_runtime_graphics) {
|
||||
public_deps = [ "${graphic_path}:libwmservice" ]
|
||||
defines = [ "SUPPORT_GRAPHICS" ]
|
||||
}
|
||||
|
||||
external_deps = [
|
||||
|
||||
@@ -57,8 +57,4 @@ ohos_source_set("aakit_mock") {
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
]
|
||||
|
||||
if (ability_runtime_graphics) {
|
||||
defines = [ "SUPPORT_GRAPHICS" ]
|
||||
}
|
||||
}
|
||||
|
||||
+7
@@ -411,6 +411,13 @@ public:
|
||||
{
|
||||
return false;
|
||||
}
|
||||
virtual bool ImplicitQueryInfoByPriority(const Want &want, int32_t flags, int32_t userId,
|
||||
AbilityInfo &abilityInfo, ExtensionAbilityInfo &extensionAbilityInfo) override
|
||||
{
|
||||
abilityInfo.name = "MainAbility";
|
||||
abilityInfo.bundleName = "com.ohos.launcher";
|
||||
return true;
|
||||
}
|
||||
public:
|
||||
using QueryAbilityInfoFunType =
|
||||
std::function<bool(std::string bundleName, AbilityInfo &abilityInfo, ElementName &elementTemp)>;
|
||||
|
||||
@@ -60,10 +60,6 @@ ohos_unittest("ability_record_test") {
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
]
|
||||
|
||||
if (ability_runtime_graphics) {
|
||||
defines = [ "SUPPORT_GRAPHICS" ]
|
||||
}
|
||||
}
|
||||
|
||||
ohos_unittest("ability_record_test_call") {
|
||||
|
||||
@@ -170,6 +170,11 @@ public:
|
||||
void SetEventId(const int64_t eventId);
|
||||
int64_t GetEventId() const;
|
||||
|
||||
void SetOwnerUserId(int32_t ownerUserId);
|
||||
int32_t GetOwnerUserId() const;
|
||||
void SetIsSingleUser(bool flag);
|
||||
bool IsSingleUser() const;
|
||||
|
||||
private:
|
||||
int32_t lastLaunchTime_ = 0;
|
||||
int32_t visibility_ = 0;
|
||||
@@ -182,6 +187,8 @@ private:
|
||||
std::shared_ptr<AAFwk::Want> want_ = nullptr;
|
||||
sptr<IRemoteObject> token_;
|
||||
sptr<IRemoteObject> preToken_;
|
||||
int32_t ownerUserId_ = -1;
|
||||
bool isSingleUser_ = false;
|
||||
};
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -233,10 +233,12 @@ public:
|
||||
* GetAbilityRunningRecord, Get ability record by the ability Name.
|
||||
*
|
||||
* @param abilityName, the ability name.
|
||||
* @param ownerUserId, the owner userId of this ability.
|
||||
*
|
||||
* @return the ability record.
|
||||
*/
|
||||
std::shared_ptr<AbilityRunningRecord> GetAbilityRunningRecord(const std::string &abilityName) const;
|
||||
std::shared_ptr<AbilityRunningRecord> GetAbilityRunningRecord(
|
||||
const std::string &abilityName, int32_t ownerUserId = -1) const;
|
||||
|
||||
std::shared_ptr<AbilityRunningRecord> GetAbilityRunningRecord(const int64_t eventId) const;
|
||||
|
||||
|
||||
@@ -102,10 +102,12 @@ public:
|
||||
* GetAbilityRunningRecord, Get ability record by the ability Name.
|
||||
*
|
||||
* @param abilityName, the ability name.
|
||||
* @param ownerUserId, the owner userId of this ability.
|
||||
*
|
||||
* @return the ability record.
|
||||
*/
|
||||
std::shared_ptr<AbilityRunningRecord> GetAbilityRunningRecord(const std::string &abilityName) const;
|
||||
std::shared_ptr<AbilityRunningRecord> GetAbilityRunningRecord(
|
||||
const std::string &abilityName, int32_t ownerUserId = -1) const;
|
||||
|
||||
std::shared_ptr<AbilityRunningRecord> GetAbilityRunningRecord(const int64_t eventId) const;
|
||||
|
||||
|
||||
@@ -130,5 +130,25 @@ bool AbilityRunningRecord::IsTerminating() const
|
||||
{
|
||||
return isTerminating_;
|
||||
}
|
||||
|
||||
void AbilityRunningRecord::SetOwnerUserId(int32_t ownerUserId)
|
||||
{
|
||||
ownerUserId_ = ownerUserId;
|
||||
}
|
||||
|
||||
int32_t AbilityRunningRecord::GetOwnerUserId() const
|
||||
{
|
||||
return ownerUserId_;
|
||||
}
|
||||
|
||||
void AbilityRunningRecord::SetIsSingleUser(bool flag)
|
||||
{
|
||||
isSingleUser_ = flag;
|
||||
}
|
||||
|
||||
bool AbilityRunningRecord::IsSingleUser() const
|
||||
{
|
||||
return isSingleUser_;
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -94,6 +94,7 @@ const std::string EVENT_MESSAGE_DEFAULT = "AppMgrServiceInner HandleTimeOut!";
|
||||
|
||||
const std::string SYSTEM_BASIC = "system_basic";
|
||||
const std::string SYSTEM_CORE = "system_core";
|
||||
const std::string ABILITY_OWNER_USERID = "AbilityMS_Owner_UserId";
|
||||
|
||||
int32_t GetUserIdByUid(int32_t uid)
|
||||
{
|
||||
@@ -1061,7 +1062,11 @@ void AppMgrServiceInner::StartAbility(const sptr<IRemoteObject> &token, const sp
|
||||
}
|
||||
|
||||
if (abilityInfo->launchMode == LaunchMode::SINGLETON) {
|
||||
auto abilityRecord = appRecord->GetAbilityRunningRecord(abilityInfo->name);
|
||||
int32_t ownerUserId = -1;
|
||||
if (want) {
|
||||
ownerUserId = want->GetIntParam(ABILITY_OWNER_USERID, -1);
|
||||
}
|
||||
auto abilityRecord = appRecord->GetAbilityRunningRecord(abilityInfo->name, ownerUserId);
|
||||
if (abilityRecord) {
|
||||
HILOG_WARN("same ability info in singleton launch mode, will not add ability");
|
||||
return;
|
||||
|
||||
@@ -236,12 +236,13 @@ sptr<IAppScheduler> AppRunningRecord::GetApplicationClient() const
|
||||
return (appLifeCycleDeal_ ? appLifeCycleDeal_->GetApplicationClient() : nullptr);
|
||||
}
|
||||
|
||||
std::shared_ptr<AbilityRunningRecord> AppRunningRecord::GetAbilityRunningRecord(const std::string &abilityName) const
|
||||
std::shared_ptr<AbilityRunningRecord> AppRunningRecord::GetAbilityRunningRecord(
|
||||
const std::string &abilityName, int32_t ownerUserId) const
|
||||
{
|
||||
HILOG_INFO("Get ability running record by ability name.");
|
||||
auto moduleRecordList = GetAllModuleRecord();
|
||||
for (const auto &moduleRecord : moduleRecordList) {
|
||||
auto abilityRecord = moduleRecord->GetAbilityRunningRecord(abilityName);
|
||||
auto abilityRecord = moduleRecord->GetAbilityRunningRecord(abilityName, ownerUserId);
|
||||
if (abilityRecord) {
|
||||
return abilityRecord;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,9 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
namespace {
|
||||
const std::string ABILITY_OWNER_USERID = "AbilityMS_Owner_UserId";
|
||||
}
|
||||
ModuleRunningRecord::ModuleRunningRecord(
|
||||
const std::shared_ptr<ApplicationInfo> &info, const std::shared_ptr<AMSEventHandler> &eventHandler)
|
||||
: appInfo_(info), eventHandler_(eventHandler)
|
||||
@@ -73,6 +76,12 @@ std::shared_ptr<AbilityRunningRecord> ModuleRunningRecord::AddAbility(const sptr
|
||||
}
|
||||
auto abilityRecord = std::make_shared<AbilityRunningRecord>(abilityInfo, token);
|
||||
abilityRecord->SetWant(want);
|
||||
if (appInfo_) {
|
||||
abilityRecord->SetIsSingleUser(appInfo_->singleton);
|
||||
}
|
||||
if (want) {
|
||||
abilityRecord->SetOwnerUserId(want->GetIntParam(ABILITY_OWNER_USERID, -1));
|
||||
}
|
||||
abilities_.emplace(token, abilityRecord);
|
||||
return abilityRecord;
|
||||
}
|
||||
@@ -121,13 +130,25 @@ void ModuleRunningRecord::ClearAbility(const std::shared_ptr<AbilityRunningRecor
|
||||
abilities_.erase(record->GetToken());
|
||||
}
|
||||
|
||||
std::shared_ptr<AbilityRunningRecord> ModuleRunningRecord::GetAbilityRunningRecord(const std::string &abilityName) const
|
||||
std::shared_ptr<AbilityRunningRecord> ModuleRunningRecord::GetAbilityRunningRecord(
|
||||
const std::string &abilityName, int32_t ownerUserId) const
|
||||
{
|
||||
HILOG_INFO("Get ability running record by ability name.");
|
||||
const auto &iter = std::find_if(abilities_.begin(), abilities_.end(), [&abilityName](const auto &pair) {
|
||||
return pair.second->GetName() == abilityName;
|
||||
const auto &it = std::find_if(abilities_.begin(), abilities_.end(), [&abilityName, ownerUserId](const auto &pair) {
|
||||
auto ability = pair.second;
|
||||
if (!ability) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool flag = ability->GetName() == abilityName;
|
||||
if (ability->GetAbilityInfo() && ability->GetAbilityInfo()->type == AppExecFwk::AbilityType::PAGE &&
|
||||
ability->GetAbilityInfo()->launchMode == AppExecFwk::LaunchMode::SINGLETON) {
|
||||
flag = flag && (ability->GetOwnerUserId() == ownerUserId);
|
||||
}
|
||||
return flag;
|
||||
});
|
||||
return ((iter == abilities_.end()) ? nullptr : iter->second);
|
||||
|
||||
return ((it == abilities_.end()) ? nullptr : it->second);
|
||||
}
|
||||
|
||||
std::shared_ptr<AbilityRunningRecord> ModuleRunningRecord::GetAbilityRunningRecord(const int64_t eventId) const
|
||||
@@ -158,7 +179,7 @@ void ModuleRunningRecord::OnAbilityStateChanged(
|
||||
}
|
||||
AbilityState oldState = ability->GetState();
|
||||
ability->SetState(state);
|
||||
HILOG_INFO("Ability state change from %{public}d to %{public}d, name is %{public}s.",
|
||||
HILOG_INFO("Ability state change from %{public}d to %{public}d, name is %{public}s.",
|
||||
oldState, state, ability->GetName().c_str());
|
||||
auto serviceInner = appMgrServiceInner_.lock();
|
||||
if (serviceInner) {
|
||||
|
||||
@@ -103,7 +103,6 @@ ohos_moduletest("AbilityRecordModuleTest") {
|
||||
"//foundation/arkui/ace_engine/interfaces/inner_api/ui_service_manager:ui_service_mgr",
|
||||
"//third_party/libpng:libpng",
|
||||
]
|
||||
defines = [ "SUPPORT_GRAPHICS" ]
|
||||
}
|
||||
|
||||
external_deps = [
|
||||
|
||||
@@ -42,7 +42,6 @@ ohos_moduletest("IpcAbilityMgrServiceModuleTest") {
|
||||
|
||||
if (ability_runtime_graphics) {
|
||||
deps += [ "//third_party/libpng:libpng" ]
|
||||
defines = [ "SUPPORT_GRAPHICS" ]
|
||||
}
|
||||
|
||||
external_deps = [
|
||||
|
||||
@@ -44,8 +44,10 @@ group("benchmarktest") {
|
||||
testonly = true
|
||||
deps = []
|
||||
|
||||
deps += [
|
||||
# deps file
|
||||
":BenchmarkTestForMissionManager",
|
||||
]
|
||||
if (ability_runtime_graphics) {
|
||||
deps += [
|
||||
# deps file
|
||||
":BenchmarkTestForMissionManager",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,13 +48,9 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
|
||||
void OnMissionIconUpdated(int32_t missionId, const std::shared_ptr<OHOS::Media::PixelMap> &icon) override
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
};
|
||||
|
||||
class MissionManagerTest : public benchmark::Fixture {
|
||||
|
||||
@@ -53,13 +53,15 @@ const std::string HELP_MSG_START =
|
||||
"usage: aa start <options>\n"
|
||||
"options list:\n"
|
||||
" -h, --help list available commands\n"
|
||||
" [-d <device-id>] -a <ability-name> -b <bundle-name> [-D] start ability with an element name\n";
|
||||
" [-d <device-id>] -a <ability-name> -b <bundle-name> [-m <module-name>] [-D] "
|
||||
" start ability with an element name\n";
|
||||
|
||||
const std::string HELP_MSG_STOP_SERVICE =
|
||||
"usage: aa stop-service <options>\n"
|
||||
"options list:\n"
|
||||
" -h, --help list available commands\n"
|
||||
" [-d <device-id>] -a <ability-name> -b <bundle-name> stop service with an element name\n";
|
||||
" [-d <device-id>] -a <ability-name> -b <bundle-name> [-m <module-name>] "
|
||||
" stop service with an element name\n";
|
||||
|
||||
const std::string HELP_MSG_DUMPSYS = "usage: aa dump <options>\n"
|
||||
"options list:\n"
|
||||
|
||||
@@ -32,7 +32,7 @@ using namespace OHOS::AppExecFwk;
|
||||
namespace OHOS {
|
||||
namespace AAFwk {
|
||||
namespace {
|
||||
const std::string SHORT_OPTIONS = "ch:d:a:b:p:s:CD";
|
||||
const std::string SHORT_OPTIONS = "ch:d:a:b:p:s:m:CD";
|
||||
constexpr struct option LONG_OPTIONS[] = {
|
||||
{"help", no_argument, nullptr, 'h'},
|
||||
{"device", required_argument, nullptr, 'd'},
|
||||
@@ -40,6 +40,7 @@ constexpr struct option LONG_OPTIONS[] = {
|
||||
{"bundle", required_argument, nullptr, 'b'},
|
||||
{"power", required_argument, nullptr, 'p'},
|
||||
{"setting", required_argument, nullptr, 's'},
|
||||
{"module", required_argument, nullptr, 'm'},
|
||||
{"cold-start", no_argument, nullptr, 'C'},
|
||||
{"debug", no_argument, nullptr, 'D'},
|
||||
{nullptr, 0, nullptr, 0},
|
||||
@@ -487,7 +488,7 @@ ErrCode AbilityManagerShellCommand::RunAsDumpsysCommand()
|
||||
// 'aa dump -i 10 -element -lastpage'
|
||||
// 'aa dump -i 10 -render -lastpage'
|
||||
// 'aa dump -i 10 -layer'
|
||||
if (strcmp(optarg, "astpage") && strcmp(optarg, "ayer")) {
|
||||
if ((optarg != nullptr) && strcmp(optarg, "astpage") && strcmp(optarg, "ayer")) {
|
||||
result = OHOS::ERR_INVALID_VALUE;
|
||||
resultReceiver_.append(HELP_MSG_DUMPSYS);
|
||||
return result;
|
||||
@@ -509,7 +510,7 @@ ErrCode AbilityManagerShellCommand::RunAsDumpsysCommand()
|
||||
}
|
||||
} else {
|
||||
// 'aa dumpsys -i 10 -inspector'
|
||||
if (strcmp(optarg, "nspector")) {
|
||||
if ((optarg != nullptr) && strcmp(optarg, "nspector")) {
|
||||
result = OHOS::ERR_INVALID_VALUE;
|
||||
resultReceiver_.append(HELP_MSG_DUMPSYS);
|
||||
return result;
|
||||
@@ -524,7 +525,7 @@ ErrCode AbilityManagerShellCommand::RunAsDumpsysCommand()
|
||||
isfirstCommand = true;
|
||||
} else {
|
||||
// 'aa dumpsys -i 10 -element'
|
||||
if (strcmp(optarg, "lement")) {
|
||||
if ((optarg != nullptr) && strcmp(optarg, "lement")) {
|
||||
result = OHOS::ERR_INVALID_VALUE;
|
||||
resultReceiver_.append(HELP_MSG_DUMPSYS);
|
||||
return result;
|
||||
@@ -553,7 +554,8 @@ ErrCode AbilityManagerShellCommand::RunAsDumpsysCommand()
|
||||
// 'aa dump -i 10 -render'
|
||||
// 'aa dump -i 10 -rotation'
|
||||
// 'aa dump -i 10 -frontend'
|
||||
if (strcmp(optarg, "ender") && strcmp(optarg, "otation") && strcmp(optarg, "ontend")) {
|
||||
if ((optarg != nullptr) && strcmp(optarg, "ender") && strcmp(optarg, "otation") &&
|
||||
strcmp(optarg, "ontend")) {
|
||||
result = OHOS::ERR_INVALID_VALUE;
|
||||
resultReceiver_.append(HELP_MSG_DUMPSYS);
|
||||
return result;
|
||||
@@ -694,6 +696,7 @@ ErrCode AbilityManagerShellCommand::MakeWantFromCmd(Want &want, std::string &win
|
||||
std::string deviceId = "";
|
||||
std::string bundleName = "";
|
||||
std::string abilityName = "";
|
||||
std::string moduleName;
|
||||
bool isColdStart = false;
|
||||
bool isDebugApp = false;
|
||||
bool isContinuation = false;
|
||||
@@ -777,6 +780,17 @@ ErrCode AbilityManagerShellCommand::MakeWantFromCmd(Want &want, std::string &win
|
||||
result = OHOS::ERR_INVALID_VALUE;
|
||||
break;
|
||||
}
|
||||
case 'm': {
|
||||
// 'aa start -m' with no argument
|
||||
// 'aa stop-service -m' with no argument
|
||||
HILOG_INFO("'aa %{public}s -m' with no argument.", cmd_.c_str());
|
||||
|
||||
resultReceiver_.append("error: option ");
|
||||
resultReceiver_.append("requires a value.\n");
|
||||
|
||||
result = OHOS::ERR_INVALID_VALUE;
|
||||
break;
|
||||
}
|
||||
case 0: {
|
||||
// 'aa start' with an unknown option: aa start --x
|
||||
// 'aa start' with an unknown option: aa start --xxx
|
||||
@@ -850,6 +864,14 @@ ErrCode AbilityManagerShellCommand::MakeWantFromCmd(Want &want, std::string &win
|
||||
windowMode = optarg;
|
||||
break;
|
||||
}
|
||||
case 'm': {
|
||||
// 'aa start -m xxx'
|
||||
// 'aa stop-service -m xxx'
|
||||
|
||||
// save module name
|
||||
moduleName = optarg;
|
||||
break;
|
||||
}
|
||||
case 'C': {
|
||||
// 'aa start -C'
|
||||
// cold start app
|
||||
@@ -893,18 +915,14 @@ ErrCode AbilityManagerShellCommand::MakeWantFromCmd(Want &want, std::string &win
|
||||
|
||||
result = OHOS::ERR_INVALID_VALUE;
|
||||
} else {
|
||||
ElementName element(deviceId, bundleName, abilityName);
|
||||
ElementName element(deviceId, bundleName, abilityName, moduleName);
|
||||
want.SetElement(element);
|
||||
|
||||
if (isColdStart) {
|
||||
WantParams wantParams;
|
||||
wantParams.SetParam("coldStart", Boolean::Box(isColdStart));
|
||||
want.SetParams(wantParams);
|
||||
want.SetParam("coldStart", isColdStart);
|
||||
}
|
||||
if (isDebugApp) {
|
||||
WantParams wantParams;
|
||||
wantParams.SetParam("debugApp", Boolean::Box(isDebugApp));
|
||||
want.SetParams(wantParams);
|
||||
want.SetParam("debugApp", isDebugApp);
|
||||
}
|
||||
if (isContinuation) {
|
||||
want.AddFlags(Want::FLAG_ABILITY_CONTINUATION);
|
||||
|
||||
Reference in New Issue
Block a user