mirror of
https://github.com/openharmony/ability_ability_runtime.git
synced 2026-08-24 22:21:36 -04:00
Description:fix FA getDisplayOrientation
Sig:SIG_ApplicationFramework Feature or Bugfix:Bugfix Binary Source:No Signed-off-by: yuwenze <yuaqiang1@huawei.com> Change-Id: I62803f1738b8a2ea00a13a8869cc8fbf354fa299
This commit is contained in:
@@ -5427,13 +5427,16 @@ NativeValue* JsNapiCommon::JsGetDisplayOrientation(
|
||||
}
|
||||
*value = obj->ability_->GetDisplayOrientation();
|
||||
};
|
||||
auto complete = [obj = this, value = errorVal]
|
||||
(NativeEngine &engine, AsyncTask &task, int32_t status) {
|
||||
if (*value == NAPI_ERR_NO_ERROR) {
|
||||
auto complete = [errorVal] (NativeEngine &engine, AsyncTask &task, int32_t status) {
|
||||
if (*errorVal == NAPI_ERR_ACE_ABILITY) {
|
||||
task.Reject(engine, CreateJsError(engine, NAPI_ERR_ACE_ABILITY, "ability is nullptr"));
|
||||
} else if (*errorVal == NAPI_ERR_ABILITY_TYPE_INVALID) {
|
||||
task.Reject(engine, CreateJsError(engine, NAPI_ERR_ABILITY_TYPE_INVALID, "ability type is invalid."));
|
||||
} else if (*errorVal == NAPI_ERR_NO_WINDOW) {
|
||||
task.Reject(engine, CreateJsError(engine, NAPI_ERR_NO_WINDOW, "window is nullptr"));
|
||||
} else {
|
||||
task.Resolve(engine, CreateJsValue(engine, *errorVal));
|
||||
}
|
||||
|
||||
task.Resolve(engine, CreateJsValue(engine, *value));
|
||||
};
|
||||
|
||||
auto callback = info.argc == ARGS_ZERO ? nullptr : info.argv[PARAM0];
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
#define NAPI_ERR_NO_ERROR 0
|
||||
#define NAPI_ERR_NO_WINDOW (-1)
|
||||
#define NAPI_ERR_NO_PERMISSION (-100)
|
||||
#define NAPI_ERR_INNER_DATA (-101) // Internal data error, data allocation fail
|
||||
#define NAPI_ERR_ACE_ABILITY (-102) // Failed to acquire ability object
|
||||
|
||||
@@ -2089,13 +2089,13 @@ int Ability::GetDisplayOrientation()
|
||||
HILOG_DEBUG("%{public}s called.", __func__);
|
||||
if (abilityWindow_ == nullptr) {
|
||||
HILOG_ERROR("Ability::GetDisplayOrientation error. abilityWindow_ == nullptr.");
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
HILOG_DEBUG("FA mode");
|
||||
auto window = abilityWindow_->GetWindow();
|
||||
if (window == nullptr) {
|
||||
HILOG_ERROR("window is nullptr.");
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
auto orientation = window->GetRequestedOrientation();
|
||||
if (orientation == Rosen::Orientation::HORIZONTAL) {
|
||||
|
||||
Reference in New Issue
Block a user