!1486 无障碍修改幕帘屏接口

Merge pull request !1486 from qianchuang/master
This commit is contained in:
openharmony_ci 2024-10-11 08:40:48 +00:00 committed by Gitee
commit 2d84a77ab6
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
6 changed files with 74 additions and 0 deletions

View File

@ -309,6 +309,21 @@ export default class AccessibilityExtensionContext extends ExtensionContext {
* @since 12
*/
startAbility(want: Want): Promise<void>;
/**
* Set the screen curtain enable or disable.
*
* @param { boolean } isEnable Indicates whether the screen curtain is enabled.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1. Mandatory parameters are left unspecified;
* 2. Incorrect parameter types;
* 3. Parameter verification failed.
* @throws { BusinessError } 9300003 - No accessibility permission to perform the operation.
* @syscap SystemCapability.BarrierFree.Accessibility.Core
* @systemapi
* @since 12
*/
enableScreenCurtain(isEnable: boolean): void;
}
/**

View File

@ -54,6 +54,11 @@ class AccessibilityExtensionContext extends ExtensionContext {
console.log('startAbility');
return this.__context_impl__.startAbility(want, callback);
}
enableScreenCurtain(isEnable) {
console.log('enableScreenCurtain');
return this.__context_impl__.enableScreenCurtain(isEnable);
}
}
export default AccessibilityExtensionContext;

View File

@ -167,6 +167,13 @@ public:
*/
RetError StartAbility(const AAFwk::Want &want);
/**
* @brief Set the screen curtain enable or disable.
* @param isEnable Indicates whether the screen curtain is enabled.
* @return Return RET_OK if set screen curtain successfully, otherwise refer to the RetError for the failure.
*/
RetError EnableScreenCurtain(bool isEnable);
private:
static int illegalRequestCode_;
};

View File

@ -199,5 +199,16 @@ RetError AccessibilityExtensionContext::StartAbility(const AAFwk::Want &want)
}
return RET_OK;
}
RetError AccessibilityExtensionContext::EnableScreenCurtain(const bool isEnable)
{
HILOG_DEBUG();
sptr<AccessibleAbilityClient> aaClient = AccessibleAbilityClient::GetInstance();
if (aaClient == nullptr) {
HILOG_ERROR("aaClient is nullptr");
return RET_ERR_NULLPTR;
}
return aaClient->EnableScreenCurtain(isEnable);
}
} // namespace Accessibility
} // namespace OHOS

View File

@ -216,6 +216,11 @@ public:
GET_NAPI_INFO_AND_CALL(env, info, NAccessibilityExtensionContext, OnStartAbility);
}
static napi_value EnableScreenCurtain(napi_env env, napi_callback_info info)
{
GET_NAPI_INFO_AND_CALL(env, info, NAccessibilityExtensionContext, OnEnableScreenCurtain);
}
private:
std::weak_ptr<AccessibilityExtensionContext> context_;
@ -691,6 +696,33 @@ private:
env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result));
return result;
}
napi_value OnEnableScreenCurtain(napi_env env, NapiCallbackInfo& info)
{
HILOG_INFO();
if (info.argc != ARGS_SIZE_ONE) {
HILOG_ERROR("Not enough params");
napi_throw(env, CreateJsError(env,
static_cast<int32_t>(NAccessibilityErrorCode::ACCESSIBILITY_ERROR_INVALID_PARAM),
ERROR_MESSAGE_PARAMETER_ERROR));
return CreateJsUndefined(env);
}
bool isEnable = false;
napi_get_value_bool(env, info.argv[PARAM0], &isEnable);
auto context = context_.lock();
RetError ret = context->EnableScreenCurtain(isEnable);
if (ret != RET_OK) {
HILOG_ERROR("result error, ret %{public}d", ret);
napi_throw(env, CreateJsError(env,
static_cast<int32_t>(NAccessibilityErrorCode::ACCESSIBILITY_ERROR_INVALID_PARAM),
ERROR_MESSAGE_PARAMETER_ERROR));
return CreateJsUndefined(env);
}
HILOG_INFO("OnEnableScreenCurtain success");
return CreateJsUndefined(env);
}
};
} // namespace
@ -717,6 +749,8 @@ napi_value CreateJsAccessibilityExtensionContext(
BindNativeFunction(env, object, "injectGesture", moduleName, NAccessibilityExtensionContext::InjectGesture);
BindNativeFunction(env, object, "injectGestureSync", moduleName, NAccessibilityExtensionContext::InjectGestureSync);
BindNativeFunction(env, object, "startAbility", moduleName, NAccessibilityExtensionContext::StartAbility);
BindNativeFunction(env, object, "enableScreenCurtain", moduleName,
NAccessibilityExtensionContext::EnableScreenCurtain);
return object;
}
} // namespace Accessibility

View File

@ -292,6 +292,7 @@ HWTEST_F(AAMSServerTest, RegisterElementOperator_001, TestSize.Level1)
sleep(1);
AAConnection_->OnAbilityDisconnectDoneSync(*elementName_);
accountData_->ClearInstalledAbility();
sleep(1);
GTEST_LOG_(INFO) << "AAMSServerTest RegisterElementOperator_001 end";
}
@ -330,6 +331,7 @@ HWTEST_F(AAMSServerTest, DeregisterElementOperator_001, TestSize.Level1)
AAConnection_->OnAbilityDisconnectDoneSync(*elementName_);
accountData_->ClearInstalledAbility();
sleep(1);
GTEST_LOG_(INFO) << "AAMSServerTest DeregisterElementOperator_001 end";
}
} // namespace Accessibility