mirror of
https://gitee.com/openharmony/accessibility
synced 2024-11-23 15:01:17 +00:00
!1396 systemapi安全问题set接口整改
Merge pull request !1396 from lsl/lsl_systemapi_back
This commit is contained in:
commit
191e7f8d8a
@ -139,9 +139,7 @@ private:
|
||||
static void GetConfigComplete(napi_env env, napi_status status, void* data);
|
||||
static void GetConfigExecute(napi_env env, void* data);
|
||||
static bool CheckReadPermission(const std::string &permission);
|
||||
static bool CheckWritePermission(const std::string &permission);
|
||||
static bool IsAvailable(napi_env env, napi_callback_info info);
|
||||
static bool IsAvailableWrite(napi_env env, napi_callback_info info);
|
||||
static void GetScreenTouchConfigExecute(NAccessibilityConfigData* callbackInfo);
|
||||
static void EnableAbilityError(size_t& argc, OHOS::Accessibility::RetError& errCode,
|
||||
napi_env env, napi_value* parameters, NAccessibilityConfigData* callbackInfo);
|
||||
|
@ -219,27 +219,6 @@ bool NAccessibilityConfig::CheckReadPermission(const std::string &permission)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool NAccessibilityConfig::CheckWritePermission(const std::string &permission)
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
uint32_t tokenId = IPCSkeleton::GetCallingTokenID();
|
||||
int result = TypePermissionState::PERMISSION_GRANTED;
|
||||
ATokenTypeEnum tokenType = AccessTokenKit::GetTokenTypeFlag(tokenId);
|
||||
if (tokenType == TOKEN_INVALID) {
|
||||
HILOG_WARN("AccessToken type invalid!");
|
||||
return false;
|
||||
} else {
|
||||
result = AccessTokenKit::VerifyAccessToken(tokenId, permission);
|
||||
}
|
||||
if (result == TypePermissionState::PERMISSION_DENIED) {
|
||||
HILOG_WARN("AccessTokenID denied!");
|
||||
return false;
|
||||
}
|
||||
HILOG_DEBUG("tokenType %{private}d dAccessTokenID:%{private}u, permission:%{private}s matched!",
|
||||
tokenType, tokenId, permission.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool NAccessibilityConfig::IsAvailable(napi_env env, napi_callback_info info)
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
@ -260,26 +239,6 @@ bool NAccessibilityConfig::IsAvailable(napi_env env, napi_callback_info info)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool NAccessibilityConfig::IsAvailableWrite(napi_env env, napi_callback_info info)
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
if (!Security::AccessToken::TokenIdKit::IsSystemAppByFullTokenID(IPCSkeleton::GetCallingFullTokenID())) {
|
||||
napi_value err = CreateBusinessError(env, OHOS::Accessibility::RET_ERR_NOT_SYSTEM_APP);
|
||||
napi_throw(env, err);
|
||||
HILOG_ERROR("is not system app");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!CheckWritePermission(OHOS_PERMISSION_WRITE_ACCESSIBILITY_CONFIG)) {
|
||||
napi_value err = CreateBusinessError(env, OHOS::Accessibility::RET_ERR_NO_PERMISSION);
|
||||
napi_throw(env, err);
|
||||
HILOG_ERROR("have no write permission");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
napi_value NAccessibilityConfig::SubscribeState(napi_env env, napi_callback_info info)
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
@ -754,10 +713,6 @@ bool NAccessibilityConfig::SetConfigParseData(napi_env env, NAccessibilityConfig
|
||||
napi_value NAccessibilityConfig::SetConfig(napi_env env, napi_callback_info info)
|
||||
{
|
||||
HILOG_DEBUG();
|
||||
if (!IsAvailableWrite(env, info)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
NAccessibilityConfigClass* obj;
|
||||
size_t argc = ARGS_SIZE_TWO;
|
||||
napi_value parameters[ARGS_SIZE_TWO] = {0};
|
||||
|
Loading…
Reference in New Issue
Block a user