mirror of
https://github.com/openharmony/aafwk_standard.git
synced 2026-07-01 20:04:39 -04:00
IssueNo:#I590L2:无UI界面编译宏优化整改
Description:无UI界面编译宏优化整改 Sig:SIG_ApplicationFramework Feature or Bugfix:Feature Binary Source: No Signed-off-by: dy_study <dingyao5@huawei.com> Change-Id: I4b7b7970263d7603791f2b1370a4eaf577f1a2b9
This commit is contained in:
@@ -41,7 +41,6 @@
|
||||
"input",
|
||||
"multimedia_image_standard",
|
||||
"os_account",
|
||||
"power_manager_native",
|
||||
"safwk",
|
||||
"samgr_standard",
|
||||
"utils_base"
|
||||
|
||||
@@ -100,7 +100,6 @@ ohos_shared_library("libfms") {
|
||||
"form_runtime:form_manager",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"power_manager_native:powermgr_client",
|
||||
"safwk:system_ability_fwk",
|
||||
"samgr_standard:samgr_proxy",
|
||||
"time_native:time_service",
|
||||
@@ -115,6 +114,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);
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
@@ -455,6 +455,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());
|
||||
@@ -465,7 +472,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__);
|
||||
@@ -475,15 +481,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
|
||||
@@ -37,9 +37,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));
|
||||
@@ -189,6 +186,8 @@ void JsAbility::OnStop()
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
const std::string PAGE_STACK_PROPERTY_NAME = "pageStack";
|
||||
|
||||
void JsAbility::OnSceneCreated()
|
||||
{
|
||||
HILOG_INFO("OnSceneCreated begin, ability is %{public}s.", GetAbilityName().c_str());
|
||||
@@ -306,6 +305,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)
|
||||
@@ -509,102 +618,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>();
|
||||
@@ -616,24 +629,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);
|
||||
|
||||
@@ -158,26 +158,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)
|
||||
{
|
||||
HILOG_INFO("OnStartAbility is called.");
|
||||
@@ -987,50 +973,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");
|
||||
@@ -1042,53 +984,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) {
|
||||
@@ -1241,10 +1136,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;
|
||||
@@ -1404,5 +1299,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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -759,6 +759,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();
|
||||
@@ -766,7 +767,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"
|
||||
@@ -65,6 +57,13 @@
|
||||
#include "xcollie/watchdog.h"
|
||||
#include "parameter.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;
|
||||
|
||||
@@ -3321,73 +3320,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);
|
||||
@@ -4007,21 +3939,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();
|
||||
@@ -4545,5 +4462,85 @@ 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 missionListManager = currentMissionListManager_;
|
||||
if (missionListManager) {
|
||||
missionListManager->SetMissionLabel(token, label);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
@@ -1910,6 +1910,7 @@ void MissionListManager::BackToLauncher()
|
||||
launcherRootAbility->ProcessForegroundAbility();
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
int MissionListManager::SetMissionLabel(const sptr<IRemoteObject> &token, const std::string &label)
|
||||
{
|
||||
if (!token) {
|
||||
@@ -1926,7 +1927,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" ]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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") {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user