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:
yuwenze
2022-11-14 07:18:10 +00:00
parent ea3c9e6b35
commit 0ef3152162
3 changed files with 11 additions and 7 deletions
@@ -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
+2 -2
View File
@@ -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) {