diff --git a/frameworks/js/napi/accesstoken/src/napi_atmanager.cpp b/frameworks/js/napi/accesstoken/src/napi_atmanager.cpp index f4d99b0efe8ca050ef44d3316317642434f19a39..fb96bff4c5b5288b6cd815562c901c5f9cea18ea 100644 --- a/frameworks/js/napi/accesstoken/src/napi_atmanager.cpp +++ b/frameworks/js/napi/accesstoken/src/napi_atmanager.cpp @@ -31,16 +31,12 @@ namespace AccessToken { std::mutex g_lockForPermStateChangeRegisters; std::vector g_permStateChangeRegisters; std::mutex g_lockCache; -std::map g_cache; -std::mutex g_lockStatusCache; -std::map g_statusCache; +std::map g_cache; static PermissionParamCache g_paramCache; -static PermissionParamCache g_paramFlagCache; static std::atomic g_cnt = 0; constexpr uint32_t REPORT_CNT = 10; namespace { static const char* PERMISSION_STATUS_CHANGE_KEY = "accesstoken.permission.change"; -static const char* PERMISSION_STATUS_FLAG_CHANGE_KEY = "accesstoken.permission.flagchange"; static const char* REGISTER_PERMISSION_STATE_CHANGE_TYPE = "permissionStateChange"; static const char* REGISTER_SELF_PERMISSION_STATE_CHANGE_TYPE = "selfPermissionStateChange"; constexpr uint32_t THIRD_PARAM = 2; @@ -242,7 +238,6 @@ napi_value NapiAtManager::Init(napi_env env, napi_value exports) DECLARE_NAPI_FUNCTION("requestPermissionOnSetting", NapiRequestPermissionOnSetting::RequestPermissionOnSetting), DECLARE_NAPI_FUNCTION("requestGlobalSwitch", NapiRequestGlobalSwitch::RequestGlobalSwitch), DECLARE_NAPI_FUNCTION("requestPermissionOnApplicationSetting", RequestAppPermOnSetting), - DECLARE_NAPI_FUNCTION("getSelfPermissionStatus", GetSelfPermissionStatusSync), }; napi_value cons = nullptr; @@ -538,36 +533,36 @@ napi_value NapiAtManager::CheckAccessToken(napi_env env, napi_callback_info info return result; } -std::string NapiAtManager::GetPermParamValue(PermissionParamCache& paramCache, const char* paramKey) +std::string NapiAtManager::GetPermParamValue() { long long sysCommitId = GetSystemCommitId(); - if (sysCommitId == paramCache.sysCommitIdCache) { + if (sysCommitId == g_paramCache.sysCommitIdCache) { LOGD(ATM_DOMAIN, ATM_TAG, "SysCommitId = %{public}lld", sysCommitId); - return paramCache.sysParamCache; + return g_paramCache.sysParamCache; } - paramCache.sysCommitIdCache = sysCommitId; - if (paramCache.handle == PARAM_DEFAULT_VALUE) { - int32_t handle = static_cast(FindParameter(paramKey)); + g_paramCache.sysCommitIdCache = sysCommitId; + if (g_paramCache.handle == PARAM_DEFAULT_VALUE) { + int32_t handle = static_cast(FindParameter(PERMISSION_STATUS_CHANGE_KEY)); if (handle == PARAM_DEFAULT_VALUE) { LOGE(ATM_DOMAIN, ATM_TAG, "FindParameter failed"); return "-1"; } - paramCache.handle = handle; + g_paramCache.handle = handle; } - int32_t currCommitId = static_cast(GetParameterCommitId(paramCache.handle)); - if (currCommitId != paramCache.commitIdCache) { + int32_t currCommitId = static_cast(GetParameterCommitId(g_paramCache.handle)); + if (currCommitId != g_paramCache.commitIdCache) { char value[NapiContextCommon::VALUE_MAX_LEN] = {0}; - auto ret = GetParameterValue(paramCache.handle, value, NapiContextCommon::VALUE_MAX_LEN - 1); + auto ret = GetParameterValue(g_paramCache.handle, value, NapiContextCommon::VALUE_MAX_LEN - 1); if (ret < 0) { LOGE(ATM_DOMAIN, ATM_TAG, "Return default value, ret=%{public}d", ret); return "-1"; } std::string resStr(value); - paramCache.sysParamCache = resStr; - paramCache.commitIdCache = currCommitId; + g_paramCache.sysParamCache = resStr; + g_paramCache.commitIdCache = currCommitId; } - return paramCache.sysParamCache; + return g_paramCache.sysParamCache; } void NapiAtManager::UpdatePermissionCache(AtManagerSyncContext* syncContext) @@ -575,7 +570,7 @@ void NapiAtManager::UpdatePermissionCache(AtManagerSyncContext* syncContext) std::lock_guard lock(g_lockCache); auto iter = g_cache.find(syncContext->permissionName); if (iter != g_cache.end()) { - std::string currPara = GetPermParamValue(g_paramCache, PERMISSION_STATUS_CHANGE_KEY); + std::string currPara = GetPermParamValue(); if (currPara != iter->second.paramValue) { syncContext->result = AccessTokenKit::VerifyAccessToken( syncContext->tokenId, syncContext->permissionName); @@ -588,7 +583,7 @@ void NapiAtManager::UpdatePermissionCache(AtManagerSyncContext* syncContext) } else { syncContext->result = AccessTokenKit::VerifyAccessToken(syncContext->tokenId, syncContext->permissionName); g_cache[syncContext->permissionName].status = syncContext->result; - g_cache[syncContext->permissionName].paramValue = GetPermParamValue(g_paramCache, PERMISSION_STATUS_CHANGE_KEY); + g_cache[syncContext->permissionName].paramValue = GetPermParamValue(); LOGD(ATM_DOMAIN, ATM_TAG, "G_cacheParam set %{public}s", g_cache[syncContext->permissionName].paramValue.c_str()); } @@ -1249,85 +1244,6 @@ napi_value NapiAtManager::RequestAppPermOnSetting(napi_env env, napi_callback_in return result; } -bool NapiAtManager::ParseInputGetPermStatus(const napi_env env, const napi_callback_info info, - AtManagerSyncContext& syncContext) -{ - size_t argc = NapiContextCommon::MAX_PARAMS_ONE; - napi_value argv[NapiContextCommon::MAX_PARAMS_ONE] = {nullptr}; - napi_value thisVar = nullptr; - - void *data = nullptr; - NAPI_CALL_BASE(env, napi_get_cb_info(env, info, &argc, argv, &thisVar, &data), false); - if (argc < NapiContextCommon::MAX_PARAMS_ONE) { - NAPI_CALL_BASE(env, napi_throw(env, GenerateBusinessError(env, - JsErrorCode::JS_ERROR_PARAM_ILLEGAL, "Parameter is missing.")), false); - return false; - } - - syncContext.env = env; - if (!ParseString(env, argv[0], syncContext.permissionName)) { - std::string errMsg = GetParamErrorMsg("permissionName", "string"); - NAPI_CALL_BASE(env, - napi_throw(env, GenerateBusinessError(env, JsErrorCode::JS_ERROR_PARAM_ILLEGAL, errMsg)), false); - return false; - } - return true; -} - -napi_value NapiAtManager::GetSelfPermissionStatusSync(napi_env env, napi_callback_info info) -{ - auto* syncContext = new (std::nothrow) AtManagerSyncContext(); - if (syncContext == nullptr) { - LOGE(ATM_DOMAIN, ATM_TAG, "New struct fail."); - return nullptr; - } - - std::unique_ptr context {syncContext}; - if (!ParseInputGetPermStatus(env, info, *syncContext)) { - return nullptr; - } - - if ((syncContext->permissionName.empty()) || - ((syncContext->permissionName.length() > NapiContextCommon::MAX_LENGTH))) { - std::string errMsg = "Invalid parameter. The permissionName is empty or exceeds 256 characters."; - NAPI_CALL(env, napi_throw(env, GenerateBusinessError(env, JS_ERROR_PARAM_INVALID, errMsg))); - return nullptr; - } - - { - std::lock_guard lock(g_lockStatusCache); - auto iter = g_statusCache.find(syncContext->permissionName); - if (iter != g_statusCache.end()) { - std::string currPara = GetPermParamValue(g_paramFlagCache, PERMISSION_STATUS_FLAG_CHANGE_KEY); - if (currPara != iter->second.paramValue) { - syncContext->result = AccessTokenKit::GetSelfPermissionStatus(syncContext->permissionName, - syncContext->permissionsState); - iter->second.status = syncContext->permissionsState; - iter->second.paramValue = currPara; - } else { - syncContext->result = RET_SUCCESS; - syncContext->permissionsState = iter->second.status; - } - } else { - syncContext->result = AccessTokenKit::GetSelfPermissionStatus(syncContext->permissionName, - syncContext->permissionsState); - g_statusCache[syncContext->permissionName].status = syncContext->permissionsState; - g_statusCache[syncContext->permissionName].paramValue = GetPermParamValue( - g_paramFlagCache, PERMISSION_STATUS_FLAG_CHANGE_KEY); - } - } - - if (syncContext->result != RET_SUCCESS) { - int32_t jsCode = NapiContextCommon::GetJsErrorCode(syncContext->result); - NAPI_CALL(env, napi_throw(env, GenerateBusinessError(env, jsCode, GetErrorMessage(jsCode)))); - return nullptr; - } - - napi_value result = nullptr; - NAPI_CALL(env, napi_create_int32(env, static_cast(syncContext->permissionsState), &result)); - return result; -} - bool NapiAtManager::FillPermStateChangeInfo(const napi_env env, const napi_value* argv, const std::string& type, const napi_value thisVar, RegisterPermStateChangeInfo& registerPermStateChangeInfo) { diff --git a/interfaces/innerkits/accesstoken/include/accesstoken_kit.h b/interfaces/innerkits/accesstoken/include/accesstoken_kit.h index b47baeff22b92f7c6e50ddeb4907c04305ae9f79..abe082293a887c66c856f5c35049e05dad7dc87d 100644 --- a/interfaces/innerkits/accesstoken/include/accesstoken_kit.h +++ b/interfaces/innerkits/accesstoken/include/accesstoken_kit.h @@ -297,13 +297,6 @@ public: * @return error code, see access_token_error.h */ static int32_t RequestAppPermOnSetting(AccessTokenID tokenID); - /** - * @brief Get self permission status - * @param permissionName permission name quote - * @param status the permission status - * @return error code, see access_token_error.h - */ - static int32_t GetSelfPermissionStatus(const std::string& permissionName, PermissionOper& status); /** * @brief Get requsted permission grant result * @param permList PermissionListState list quote, as input and query result diff --git a/interfaces/innerkits/accesstoken/libaccesstoken_sdk.map b/interfaces/innerkits/accesstoken/libaccesstoken_sdk.map index 373be35dba2b684246cde84822d7fdd609bc5caa..19192e683f5cad787ad0a8a8e96f7b8781932543 100644 --- a/interfaces/innerkits/accesstoken/libaccesstoken_sdk.map +++ b/interfaces/innerkits/accesstoken/libaccesstoken_sdk.map @@ -83,7 +83,6 @@ "OHOS::Security::AccessToken::AccessTokenKit::RequestAppPermOnSetting(unsigned int)"; "OHOS::Security::AccessToken::AccessTokenKit::GetReqPermissionByName(unsigned int, std::__h::basic_string, std::__h::allocator> const&, std::__h::basic_string, std::__h::allocator>&)"; "OHOS::Security::AccessToken::AccessTokenKit::GetKernelPermissions(unsigned int, std::__h::vector>&)"; - "OHOS::Security::AccessToken::AccessTokenKit::GetSelfPermissionStatus(std::__h::basic_string, std::__h::allocator> const&, OHOS::Security::AccessToken::TypePermissionOper&)"; OHOS::Security::AccessToken::AccessTokenKit::IsSystemAppByFullTokenID*; OHOS::Security::AccessToken::AccessTokenKit::GetRenderTokenID*; ""; diff --git a/interfaces/innerkits/accesstoken/src/accesstoken_kit.cpp b/interfaces/innerkits/accesstoken/src/accesstoken_kit.cpp index b41d98847a818c3f323954c2c673bd6d0c9be0b7..83590b74dcc027e25f3547236cbe54183b556408 100644 --- a/interfaces/innerkits/accesstoken/src/accesstoken_kit.cpp +++ b/interfaces/innerkits/accesstoken/src/accesstoken_kit.cpp @@ -37,7 +37,6 @@ static const uint64_t SYSTEM_APP_MASK = (static_cast(1) << 32); static const uint64_t TOKEN_ID_LOWMASK = 0xffffffff; static const int INVALID_DLP_TOKEN_FLAG = -1; static const int FIRSTCALLER_TOKENID_DEFAULT = 0; -static const int MAX_LENGTH = 256; } // namespace PermUsedTypeEnum AccessTokenKit::GetPermissionUsedType( @@ -280,14 +279,6 @@ int AccessTokenKit::GetNativeTokenInfo( return AccessTokenManagerClient::GetInstance().GetNativeTokenInfo(tokenID, nativeTokenInfoRes); } -int32_t AccessTokenKit::GetSelfPermissionStatus(const std::string& permissionName, PermissionOper& status) -{ - if (permissionName.empty() || permissionName.size() > MAX_LENGTH) { - return ERR_PARAM_INVALID; - } - return AccessTokenManagerClient::GetInstance().GetSelfPermissionStatus(permissionName, status); -} - PermissionOper AccessTokenKit::GetSelfPermissionsState(std::vector& permList, PermissionGrantInfo& info) { diff --git a/interfaces/innerkits/accesstoken/src/accesstoken_manager_client.cpp b/interfaces/innerkits/accesstoken/src/accesstoken_manager_client.cpp index 7bff459460cba6b0142b728f77c5da044c50205f..cc2de1369d28c3b7fd0b1cce2cab6b018ca118c3 100644 --- a/interfaces/innerkits/accesstoken/src/accesstoken_manager_client.cpp +++ b/interfaces/innerkits/accesstoken/src/accesstoken_manager_client.cpp @@ -210,24 +210,6 @@ int AccessTokenManagerClient::GetPermissionFlag( return result; } -int32_t AccessTokenManagerClient::GetSelfPermissionStatus(const std::string& permissionName, PermissionOper& status) -{ - auto proxy = GetProxy(); - if (proxy == nullptr) { - LOGE(ATM_DOMAIN, ATM_TAG, "Proxy is null."); - status = INVALID_OPER; - return AccessTokenError::ERR_SERVICE_ABNORMAL; - } - int32_t retStatus = INVALID_OPER; - int32_t result = proxy->GetSelfPermissionStatus(permissionName, retStatus); - if (result != RET_SUCCESS) { - result = ConvertResult(result); - } - status = static_cast(retStatus); - LOGI(ATM_DOMAIN, ATM_TAG, "Result from server (error=%{public}d, status=%{public}d).", result, retStatus); - return result; -} - PermissionOper AccessTokenManagerClient::GetSelfPermissionsState(std::vector& permList, PermissionGrantInfo& info) { diff --git a/interfaces/innerkits/accesstoken/src/accesstoken_manager_client.h b/interfaces/innerkits/accesstoken/src/accesstoken_manager_client.h index 0689d1697eb8892399afcbb27a1c4bdf961dd953..df0ed58159917301bf98b2a5bb5cc815b8ba0230 100644 --- a/interfaces/innerkits/accesstoken/src/accesstoken_manager_client.h +++ b/interfaces/innerkits/accesstoken/src/accesstoken_manager_client.h @@ -60,7 +60,6 @@ public: int32_t SetPermissionRequestToggleStatus(const std::string& permissionName, uint32_t status, int32_t userID); int32_t GetPermissionRequestToggleStatus(const std::string& permissionName, uint32_t& status, int32_t userID); int32_t RequestAppPermOnSetting(AccessTokenID tokenID); - int32_t GetSelfPermissionStatus(const std::string& permissionName, PermissionOper& status); PermissionOper GetSelfPermissionsState(std::vector& permList, PermissionGrantInfo& info); int32_t GetPermissionsStatus(AccessTokenID tokenID, std::vector& permList); diff --git a/interfaces/innerkits/accesstoken/test/unittest/BUILD.gn b/interfaces/innerkits/accesstoken/test/unittest/BUILD.gn index 973d2c7a3a354f8ec7ee230cbc32fc84bc2ad68d..c8267ecdb7a51539444b1efd34d9a156e0f7ba39 100755 --- a/interfaces/innerkits/accesstoken/test/unittest/BUILD.gn +++ b/interfaces/innerkits/accesstoken/test/unittest/BUILD.gn @@ -60,7 +60,6 @@ ohos_unittest("libaccesstoken_sdk_test") { "PermDenyTest/accesstoken_deny_test.cpp", "PermisionDialogTest/accesstoken_location_request_test.cpp", "PermisionDialogTest/get_self_permission_state_test.cpp", - "PermisionDialogTest/get_self_permission_status_test.cpp", "PermisionDialogTest/request_permission_on_setting_test.cpp", "PermisionDialogTest/set_perm_dialog_cap_test.cpp", "PermissionsTest/check_permission_map_test.cpp", diff --git a/interfaces/innerkits/accesstoken/test/unittest/PermisionDialogTest/get_self_permission_status_test.cpp b/interfaces/innerkits/accesstoken/test/unittest/PermisionDialogTest/get_self_permission_status_test.cpp deleted file mode 100644 index cd529a1084af62d3b2585325d604a2bd0c77c5a2..0000000000000000000000000000000000000000 --- a/interfaces/innerkits/accesstoken/test/unittest/PermisionDialogTest/get_self_permission_status_test.cpp +++ /dev/null @@ -1,560 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include "get_self_permission_status_test.h" -#include "access_token_error.h" -#include "nativetoken_kit.h" -#include "test_common.h" -#include "token_setproc.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -using namespace testing::ext; -namespace { -static const std::string TEST_BUNDLE_NAME = "ohos"; -static const int TEST_USER_ID = 0; -static const std::string APPROXIMATELY_LOCATION_PERMISSION = "ohos.permission.APPROXIMATELY_LOCATION"; -static const std::string LOCATION_PERMISSION = "ohos.permission.LOCATION"; - -PermissionStateFull g_permTestState1 = { - .permissionName = APPROXIMATELY_LOCATION_PERMISSION, - .isGeneral = true, - .resDeviceID = {"local"}, - .grantStatus = {PermissionState::PERMISSION_DENIED}, - .grantFlags = {PermissionFlag::PERMISSION_DEFAULT_FLAG}, -}; - -PermissionStateFull g_permTestState2 = { - .permissionName = "ohos.permission.MICROPHONE", - .isGeneral = true, - .resDeviceID = {"local"}, - .grantStatus = {PermissionState::PERMISSION_DENIED}, - .grantFlags = {PermissionFlag::PERMISSION_USER_SET} -}; - -PermissionStateFull g_permTestState3 = { - .permissionName = "ohos.permission.WRITE_CALENDAR", - .isGeneral = true, - .resDeviceID = {"local"}, - .grantStatus = {PermissionState::PERMISSION_DENIED}, - .grantFlags = {PermissionFlag::PERMISSION_USER_FIXED} -}; - -PermissionStateFull g_permTestState4 = { - .permissionName = "ohos.permission.READ_IMAGEVIDEO", - .isGeneral = true, - .resDeviceID = {"local"}, - .grantStatus = {PermissionState::PERMISSION_GRANTED}, - .grantFlags = {PermissionFlag::PERMISSION_USER_SET} -}; - -PermissionStateFull g_permTestState5 = { - .permissionName = LOCATION_PERMISSION, - .isGeneral = true, - .resDeviceID = {"local"}, - .grantStatus = {PermissionState::PERMISSION_DENIED}, - .grantFlags = {PermissionFlag::PERMISSION_DEFAULT_FLAG}, -}; - -PermissionStateFull g_permTestState6 = { - .permissionName = "ohos.permission.READ_CALENDAR", - .isGeneral = true, - .resDeviceID = {"local"}, - .grantStatus = {PermissionState::PERMISSION_DENIED}, - .grantFlags = {PermissionFlag::PERMISSION_DEFAULT_FLAG}, -}; - -HapPolicyParams g_policy = { - .apl = APL_NORMAL, - .domain = "domain", - .permStateList = {g_permTestState1, g_permTestState2, g_permTestState3, g_permTestState4, g_permTestState5, - g_permTestState6} -}; - -static uint64_t g_selfTokenId = 0; -} - -void GetSelfPermissionStatusTest::SetUpTestCase() -{ - g_selfTokenId = GetSelfTokenID(); - TestCommon::SetTestEvironment(g_selfTokenId); -} - -void GetSelfPermissionStatusTest::TearDownTestCase() -{ - ASSERT_EQ(RET_SUCCESS, SetSelfTokenID(g_selfTokenId)); - TestCommon::ResetTestEvironment(); -} - -void GetSelfPermissionStatusTest::SetUp() -{ - HapInfoParams info = { - .userID = TEST_USER_ID, - .bundleName = TEST_BUNDLE_NAME, - .instIndex = 0, - .appIDDesc = "appIDDesc", - .apiVersion = 20 // 20: api version - }; - - AccessTokenIDEx tokenIdEx = TestCommon::AllocAndGrantHapTokenByTest(info, g_policy); - AccessTokenID tokenId = tokenIdEx.tokenIdExStruct.tokenID; - ASSERT_NE(tokenId, INVALID_TOKENID); - ASSERT_EQ(RET_SUCCESS, SetSelfTokenID(tokenIdEx.tokenIDEx)); -} - -void GetSelfPermissionStatusTest::TearDown() -{ - AccessTokenIDEx tokenIdEx = TestCommon::GetHapTokenIdFromBundle(TEST_USER_ID, TEST_BUNDLE_NAME, 0); - AccessTokenID tokenId = tokenIdEx.tokenIdExStruct.tokenID; - if (tokenId != INVALID_TOKENID) { - EXPECT_EQ(RET_SUCCESS, TestCommon::DeleteTestHapToken(tokenId)); - } -} - -/** - * @tc.name: GetSelfPermissionStatus001 - * @tc.desc: default permission status - * @tc.type: FUNC - * @tc.require: Issue Number - */ -HWTEST_F(GetSelfPermissionStatusTest, GetSelfPermissionStatus001, TestSize.Level1) -{ - AccessTokenIDEx tokenIdEx = TestCommon::GetHapTokenIdFromBundle(TEST_USER_ID, TEST_BUNDLE_NAME, 0); - AccessTokenID tokenID = tokenIdEx.tokenIdExStruct.tokenID; - ASSERT_NE(INVALID_TOKENID, tokenID); - - // default flag, user not operation - PermissionOper status; - int32_t ret = AccessTokenKit::GetSelfPermissionStatus(APPROXIMATELY_LOCATION_PERMISSION, status); - EXPECT_EQ(RET_SUCCESS, ret); - EXPECT_EQ(DYNAMIC_OPER, status); - - // user set DENIED - ret = AccessTokenKit::GetSelfPermissionStatus("ohos.permission.MICROPHONE", status); - EXPECT_EQ(RET_SUCCESS, ret); - EXPECT_EQ(DYNAMIC_OPER, status); - - // user fixed DENIED - ret = AccessTokenKit::GetSelfPermissionStatus("ohos.permission.WRITE_CALENDAR", status); - EXPECT_EQ(RET_SUCCESS, ret); - EXPECT_EQ(SETTING_OPER, status); - - // user set GRANTED - ret = AccessTokenKit::GetSelfPermissionStatus("ohos.permission.READ_IMAGEVIDEO", status); - EXPECT_EQ(RET_SUCCESS, ret); - EXPECT_EQ(PASS_OPER, status); - - // not request permission CAMERA - ret = AccessTokenKit::GetSelfPermissionStatus("ohos.permission.CAMERA", status); - EXPECT_EQ(RET_SUCCESS, ret); - EXPECT_EQ(INVALID_OPER, status); -} - -/** - * @tc.name: GetSelfPermissionStatus002 - * @tc.desc: forbidden permission status - * @tc.type: FUNC - * @tc.require: Issue Number - */ -HWTEST_F(GetSelfPermissionStatusTest, GetSelfPermissionStatus002, TestSize.Level1) -{ - AccessTokenIDEx tokenIdEx = TestCommon::GetHapTokenIdFromBundle(TEST_USER_ID, TEST_BUNDLE_NAME, 0); - AccessTokenID tokenID = tokenIdEx.tokenIdExStruct.tokenID; - ASSERT_NE(INVALID_TOKENID, tokenID); - - { - std::vector reqPerm; - reqPerm.emplace_back("ohos.permission.DISABLE_PERMISSION_DIALOG"); - MockHapToken mock("GetSelfPermissionStatus002", reqPerm, true); - - HapBaseInfo hapBaseInfo = { - .userID = TEST_USER_ID, - .bundleName = TEST_BUNDLE_NAME, - .instIndex = 0, - }; - - ASSERT_EQ(0, AccessTokenKit::SetPermDialogCap(hapBaseInfo, true)); - } - - // default flag, user not operation - PermissionOper status; - int32_t ret = AccessTokenKit::GetSelfPermissionStatus(APPROXIMATELY_LOCATION_PERMISSION, status); - EXPECT_EQ(RET_SUCCESS, ret); - EXPECT_EQ(FORBIDDEN_OPER, status); - - // user set DENIED - ret = AccessTokenKit::GetSelfPermissionStatus("ohos.permission.MICROPHONE", status); - EXPECT_EQ(RET_SUCCESS, ret); - EXPECT_EQ(FORBIDDEN_OPER, status); - - // user fixed DENIED - ret = AccessTokenKit::GetSelfPermissionStatus("ohos.permission.WRITE_CALENDAR", status); - EXPECT_EQ(RET_SUCCESS, ret); - EXPECT_EQ(FORBIDDEN_OPER, status); - - // user set GRANTED - ret = AccessTokenKit::GetSelfPermissionStatus("ohos.permission.READ_IMAGEVIDEO", status); - EXPECT_EQ(RET_SUCCESS, ret); - EXPECT_EQ(FORBIDDEN_OPER, status); - - // not request permission CAMERA - ret = AccessTokenKit::GetSelfPermissionStatus("ohos.permission.CAMERA", status); - EXPECT_EQ(RET_SUCCESS, ret); - EXPECT_EQ(INVALID_OPER, status); -} - -/** - * @tc.name: GetSelfPermissionStatus003 - * @tc.desc: grant permission status - * @tc.type: FUNC - * @tc.require: Issue Number - */ -HWTEST_F(GetSelfPermissionStatusTest, GetSelfPermissionStatus003, TestSize.Level1) -{ - AccessTokenIDEx tokenIdEx = TestCommon::GetHapTokenIdFromBundle(TEST_USER_ID, TEST_BUNDLE_NAME, 0); - AccessTokenID tokenID = tokenIdEx.tokenIdExStruct.tokenID; - ASSERT_NE(INVALID_TOKENID, tokenID); - - { - std::vector reqPerm; - reqPerm.emplace_back("ohos.permission.GRANT_SENSITIVE_PERMISSIONS"); - MockHapToken mock("GetSelfPermissionStatus003", reqPerm, true); - - // grant user set - ASSERT_EQ(0, AccessTokenKit::GrantPermission(tokenID, APPROXIMATELY_LOCATION_PERMISSION, PERMISSION_USER_SET)); - } - - // grant permission - PermissionOper status; - int32_t ret = AccessTokenKit::GetSelfPermissionStatus(APPROXIMATELY_LOCATION_PERMISSION, status); - EXPECT_EQ(RET_SUCCESS, ret); - EXPECT_EQ(PASS_OPER, status); - - // user set DENIED - ret = AccessTokenKit::GetSelfPermissionStatus("ohos.permission.MICROPHONE", status); - EXPECT_EQ(RET_SUCCESS, ret); - EXPECT_EQ(DYNAMIC_OPER, status); - - // user fixed DENIED - ret = AccessTokenKit::GetSelfPermissionStatus("ohos.permission.WRITE_CALENDAR", status); - EXPECT_EQ(RET_SUCCESS, ret); - EXPECT_EQ(SETTING_OPER, status); - - // user set GRANTED - ret = AccessTokenKit::GetSelfPermissionStatus("ohos.permission.READ_IMAGEVIDEO", status); - EXPECT_EQ(RET_SUCCESS, ret); - EXPECT_EQ(PASS_OPER, status); - - // not request permission CAMERA - ret = AccessTokenKit::GetSelfPermissionStatus("ohos.permission.CAMERA", status); - EXPECT_EQ(RET_SUCCESS, ret); - EXPECT_EQ(INVALID_OPER, status); -} - -/** - * @tc.name: GetSelfPermissionStatus004 - * @tc.desc: revoke user set permission status - * @tc.type: FUNC - * @tc.require: Issue Number - */ -HWTEST_F(GetSelfPermissionStatusTest, GetSelfPermissionStatus004, TestSize.Level1) -{ - AccessTokenIDEx tokenIdEx = TestCommon::GetHapTokenIdFromBundle(TEST_USER_ID, TEST_BUNDLE_NAME, 0); - AccessTokenID tokenID = tokenIdEx.tokenIdExStruct.tokenID; - ASSERT_NE(INVALID_TOKENID, tokenID); - - { - std::vector reqPerm; - reqPerm.emplace_back("ohos.permission.REVOKE_SENSITIVE_PERMISSIONS"); - MockHapToken mock("GetSelfPermissionStatus004", reqPerm, true); - - // revoke user set - ASSERT_EQ(0, AccessTokenKit::RevokePermission(tokenID, "ohos.permission.READ_IMAGEVIDEO", PERMISSION_USER_SET)); - } - - // default flag, user not operation - PermissionOper status; - int32_t ret = AccessTokenKit::GetSelfPermissionStatus(APPROXIMATELY_LOCATION_PERMISSION, status); - EXPECT_EQ(RET_SUCCESS, ret); - EXPECT_EQ(DYNAMIC_OPER, status); - - // user set DENIED - ret = AccessTokenKit::GetSelfPermissionStatus("ohos.permission.MICROPHONE", status); - EXPECT_EQ(RET_SUCCESS, ret); - EXPECT_EQ(DYNAMIC_OPER, status); - - // user fixed DENIED - ret = AccessTokenKit::GetSelfPermissionStatus("ohos.permission.WRITE_CALENDAR", status); - EXPECT_EQ(RET_SUCCESS, ret); - EXPECT_EQ(SETTING_OPER, status); - - // revoke user set - ret = AccessTokenKit::GetSelfPermissionStatus("ohos.permission.READ_IMAGEVIDEO", status); - EXPECT_EQ(RET_SUCCESS, ret); - EXPECT_EQ(DYNAMIC_OPER, status); - - // not request permission CAMERA - ret = AccessTokenKit::GetSelfPermissionStatus("ohos.permission.CAMERA", status); - EXPECT_EQ(RET_SUCCESS, ret); - EXPECT_EQ(INVALID_OPER, status); -} - -/** - * @tc.name: GetSelfPermissionStatus005 - * @tc.desc: revoke user fixed permission status - * @tc.type: FUNC - * @tc.require: Issue Number - */ -HWTEST_F(GetSelfPermissionStatusTest, GetSelfPermissionStatus005, TestSize.Level1) -{ - AccessTokenIDEx tokenIdEx = TestCommon::GetHapTokenIdFromBundle(TEST_USER_ID, TEST_BUNDLE_NAME, 0); - AccessTokenID tokenID = tokenIdEx.tokenIdExStruct.tokenID; - ASSERT_NE(INVALID_TOKENID, tokenID); - - { - std::vector reqPerm; - reqPerm.emplace_back("ohos.permission.REVOKE_SENSITIVE_PERMISSIONS"); - MockHapToken mock("GetSelfPermissionStatus005", reqPerm, true); - - // revoke user fixed - ASSERT_EQ(0, - AccessTokenKit::RevokePermission(tokenID, "ohos.permission.READ_IMAGEVIDEO", PERMISSION_USER_FIXED)); - } - - // default flag, user not operation - PermissionOper status; - int32_t ret = AccessTokenKit::GetSelfPermissionStatus(APPROXIMATELY_LOCATION_PERMISSION, status); - EXPECT_EQ(RET_SUCCESS, ret); - EXPECT_EQ(DYNAMIC_OPER, status); - - // user set DENIED - ret = AccessTokenKit::GetSelfPermissionStatus("ohos.permission.MICROPHONE", status); - EXPECT_EQ(RET_SUCCESS, ret); - EXPECT_EQ(DYNAMIC_OPER, status); - - // user fixed DENIED - ret = AccessTokenKit::GetSelfPermissionStatus("ohos.permission.WRITE_CALENDAR", status); - EXPECT_EQ(RET_SUCCESS, ret); - EXPECT_EQ(SETTING_OPER, status); - - // revoke user fixed - ret = AccessTokenKit::GetSelfPermissionStatus("ohos.permission.READ_IMAGEVIDEO", status); - EXPECT_EQ(RET_SUCCESS, ret); - EXPECT_EQ(SETTING_OPER, status); - - // not request permission CAMERA - ret = AccessTokenKit::GetSelfPermissionStatus("ohos.permission.CAMERA", status); - EXPECT_EQ(RET_SUCCESS, ret); - EXPECT_EQ(INVALID_OPER, status); -} - -/** - * @tc.name: GetSelfPermissionStatus006 - * @tc.desc: invalid permission - * @tc.type: FUNC - * @tc.require: Issue Number - */ -HWTEST_F(GetSelfPermissionStatusTest, GetSelfPermissionStatus006, TestSize.Level1) -{ - AccessTokenIDEx tokenIdEx = TestCommon::GetHapTokenIdFromBundle(TEST_USER_ID, TEST_BUNDLE_NAME, 0); - AccessTokenID tokenID = tokenIdEx.tokenIdExStruct.tokenID; - ASSERT_NE(INVALID_TOKENID, tokenID); - - PermissionOper status; - // invalid permission - int32_t ret = AccessTokenKit::GetSelfPermissionStatus("ohos.permission.TTTTT", status); - EXPECT_EQ(RET_SUCCESS, ret); - EXPECT_EQ(INVALID_OPER, status); - - // not request permission - ret = AccessTokenKit::GetSelfPermissionStatus("ohos.permission.ACCESS_NEARLINK", status); - EXPECT_EQ(RET_SUCCESS, ret); - EXPECT_EQ(INVALID_OPER, status); - - // empty permission - std::string testPerm1; - ret = AccessTokenKit::GetSelfPermissionStatus(testPerm1, status); - EXPECT_EQ(ERR_PARAM_INVALID, ret); - - // oversize permission - std::string testPerm2(257, 'a'); - ret = AccessTokenKit::GetSelfPermissionStatus(testPerm2, status); - EXPECT_EQ(ERR_PARAM_INVALID, ret); -} - -/** - * @tc.name: GetSelfPermissionStatus007 - * @tc.desc: location permission test - * @tc.type: FUNC - * @tc.require: Issue Number - */ -HWTEST_F(GetSelfPermissionStatusTest, GetSelfPermissionStatus007, TestSize.Level1) -{ - AccessTokenIDEx tokenIdEx = TestCommon::GetHapTokenIdFromBundle(TEST_USER_ID, TEST_BUNDLE_NAME, 0); - AccessTokenID tokenID = tokenIdEx.tokenIdExStruct.tokenID; - ASSERT_NE(INVALID_TOKENID, tokenID); - - // default flag, user not operation - PermissionOper status; - int32_t ret = AccessTokenKit::GetSelfPermissionStatus(APPROXIMATELY_LOCATION_PERMISSION, status); - EXPECT_EQ(RET_SUCCESS, ret); - EXPECT_EQ(DYNAMIC_OPER, status); - - // APPROXIMATELY_LOCATION not set, LOCATION status is INVALID_OPER - ret = AccessTokenKit::GetSelfPermissionStatus(LOCATION_PERMISSION, status); - EXPECT_EQ(RET_SUCCESS, ret); - EXPECT_EQ(INVALID_OPER, status); - - { - std::vector reqPerm; - reqPerm.emplace_back("ohos.permission.GRANT_SENSITIVE_PERMISSIONS"); - MockHapToken mock("GetSelfPermissionStatus0071", reqPerm, true); - - // grant user set - ASSERT_EQ(0, AccessTokenKit::GrantPermission(tokenID, APPROXIMATELY_LOCATION_PERMISSION, PERMISSION_USER_SET)); - } - - // grant permission - ret = AccessTokenKit::GetSelfPermissionStatus(APPROXIMATELY_LOCATION_PERMISSION, status); - EXPECT_EQ(RET_SUCCESS, ret); - EXPECT_EQ(PASS_OPER, status); - - // APPROXIMATELY_LOCATION already set, LOCATION status is DYNAMIC_OPER - ret = AccessTokenKit::GetSelfPermissionStatus(LOCATION_PERMISSION, status); - EXPECT_EQ(RET_SUCCESS, ret); - EXPECT_EQ(DYNAMIC_OPER, status); - - { - std::vector reqPerm; - reqPerm.emplace_back("ohos.permission.GRANT_SENSITIVE_PERMISSIONS"); - MockHapToken mock("GetSelfPermissionStatus0072", reqPerm, true); - - // grant user set - ASSERT_EQ(0, AccessTokenKit::GrantPermission(tokenID, LOCATION_PERMISSION, PERMISSION_USER_SET)); - } - - // grant permission - ret = AccessTokenKit::GetSelfPermissionStatus(LOCATION_PERMISSION, status); - EXPECT_EQ(RET_SUCCESS, ret); - EXPECT_EQ(PASS_OPER, status); -} - -/** - * @tc.name: GetSelfPermissionStatus008 - * @tc.desc: only change flag - * @tc.type: FUNC - * @tc.require: Issue Number - */ -HWTEST_F(GetSelfPermissionStatusTest, GetSelfPermissionStatus008, TestSize.Level1) -{ - AccessTokenIDEx tokenIdEx = TestCommon::GetHapTokenIdFromBundle(TEST_USER_ID, TEST_BUNDLE_NAME, 0); - AccessTokenID tokenID = tokenIdEx.tokenIdExStruct.tokenID; - ASSERT_NE(INVALID_TOKENID, tokenID); - - // default flag, user not operation - PermissionOper status; - int32_t ret = AccessTokenKit::GetSelfPermissionStatus(APPROXIMATELY_LOCATION_PERMISSION, status); - EXPECT_EQ(RET_SUCCESS, ret); - EXPECT_EQ(DYNAMIC_OPER, status); - - { - std::vector reqPerm; - reqPerm.emplace_back("ohos.permission.GRANT_SENSITIVE_PERMISSIONS"); - MockHapToken mock("GetSelfPermissionStatus0081", reqPerm, true); - - // grant user set - ASSERT_EQ(0, AccessTokenKit::GrantPermission(tokenID, APPROXIMATELY_LOCATION_PERMISSION, PERMISSION_USER_SET)); - } - - // grant permission - ret = AccessTokenKit::GetSelfPermissionStatus(APPROXIMATELY_LOCATION_PERMISSION, status); - EXPECT_EQ(RET_SUCCESS, ret); - EXPECT_EQ(PASS_OPER, status); - - { - std::vector reqPerm; - reqPerm.emplace_back("ohos.permission.REVOKE_SENSITIVE_PERMISSIONS"); - MockHapToken mock("GetSelfPermissionStatus0082", reqPerm, true); - - // revoke user fixed - ASSERT_EQ(0, AccessTokenKit::RevokePermission( - tokenID, APPROXIMATELY_LOCATION_PERMISSION, PERMISSION_USER_FIXED)); - } - - // revoke permission - ret = AccessTokenKit::GetSelfPermissionStatus(APPROXIMATELY_LOCATION_PERMISSION, status); - EXPECT_EQ(RET_SUCCESS, ret); - EXPECT_EQ(SETTING_OPER, status); - - { - std::vector reqPerm; - reqPerm.emplace_back("ohos.permission.REVOKE_SENSITIVE_PERMISSIONS"); - MockHapToken mock("GetSelfPermissionStatus0083", reqPerm, true); - - // revoke to default flag - ASSERT_EQ(0, AccessTokenKit::RevokePermission( - tokenID, APPROXIMATELY_LOCATION_PERMISSION, PERMISSION_DEFAULT_FLAG)); - } - - ret = AccessTokenKit::GetSelfPermissionStatus(APPROXIMATELY_LOCATION_PERMISSION, status); - EXPECT_EQ(RET_SUCCESS, ret); - EXPECT_EQ(DYNAMIC_OPER, status); -} - -/** - * @tc.name: GetSelfPermissionStatus009 - * @tc.desc: test permission group - * @tc.type: FUNC - * @tc.require: Issue Number - */ -HWTEST_F(GetSelfPermissionStatusTest, GetSelfPermissionStatus009, TestSize.Level1) -{ - AccessTokenIDEx tokenIdEx = TestCommon::GetHapTokenIdFromBundle(TEST_USER_ID, TEST_BUNDLE_NAME, 0); - AccessTokenID tokenID = tokenIdEx.tokenIdExStruct.tokenID; - ASSERT_NE(INVALID_TOKENID, tokenID); - - PermissionOper status; - - // default - int32_t ret = AccessTokenKit::GetSelfPermissionStatus("ohos.permission.READ_CALENDAR", status); - EXPECT_EQ(RET_SUCCESS, ret); - EXPECT_EQ(DYNAMIC_OPER, status); - - // default denied - ret = AccessTokenKit::GetSelfPermissionStatus("ohos.permission.WRITE_CALENDAR", status); - EXPECT_EQ(RET_SUCCESS, ret); - EXPECT_EQ(SETTING_OPER, status); - - { - std::vector reqPerm; - reqPerm.emplace_back("ohos.permission.GRANT_SENSITIVE_PERMISSIONS"); - MockHapToken mock("GetSelfPermissionStatus009", reqPerm, true); - - // grant user set - ASSERT_EQ(0, AccessTokenKit::GrantPermission(tokenID, "ohos.permission.WRITE_CALENDAR", PERMISSION_USER_SET)); - } - - ret = AccessTokenKit::GetSelfPermissionStatus("ohos.permission.READ_CALENDAR", status); - EXPECT_EQ(RET_SUCCESS, ret); - EXPECT_EQ(DYNAMIC_OPER, status); - - // no change - ret = AccessTokenKit::GetSelfPermissionStatus("ohos.permission.WRITE_CALENDAR", status); - EXPECT_EQ(RET_SUCCESS, ret); - EXPECT_EQ(PASS_OPER, status); -} -} // namespace AccessToken -} // namespace Security -} // namespace OHOS diff --git a/interfaces/innerkits/accesstoken/test/unittest/PermisionDialogTest/get_self_permission_status_test.h b/interfaces/innerkits/accesstoken/test/unittest/PermisionDialogTest/get_self_permission_status_test.h deleted file mode 100644 index 58ee97f3ef33df1a0083627c6f1f7068d87b90fa..0000000000000000000000000000000000000000 --- a/interfaces/innerkits/accesstoken/test/unittest/PermisionDialogTest/get_self_permission_status_test.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef GET_SELF_PERMISSION_STATUS_TEST_H -#define GET_SELF_PERMISSION_STATUS_TEST_H - -#include - -#include "access_token.h" -#include "accesstoken_kit.h" -#include "permission_def.h" -#include "permission_state_full.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -class GetSelfPermissionStatusTest : public testing::Test { -public: - static void SetUpTestCase(); - static void TearDownTestCase(); - void SetUp(); - void TearDown(); - unsigned int GetAccessTokenID(int userID, std::string bundleName, int instIndex); - AccessTokenID AllocTestToken(const HapInfoParams& hapInfo, const HapPolicyParams& hapPolicy) const; - void DeleteTestToken() const; -}; -} // namespace AccessToken -} // namespace Security -} // namespace OHOS -#endif // GET_SELF_PERMISSION_STATUS_TEST_H diff --git a/interfaces/innerkits/accesstoken/test/unittest/ProxyMockTest/accesstoken_mock_test.cpp b/interfaces/innerkits/accesstoken/test/unittest/ProxyMockTest/accesstoken_mock_test.cpp index 6d919b20c1c5cb0bf0b895870b9c89fb94fb6942..1678ab82f99baf1ac8b96b27072b24a32e1bb2d9 100644 --- a/interfaces/innerkits/accesstoken/test/unittest/ProxyMockTest/accesstoken_mock_test.cpp +++ b/interfaces/innerkits/accesstoken/test/unittest/ProxyMockTest/accesstoken_mock_test.cpp @@ -341,19 +341,6 @@ HWTEST_F(AccessTokenMockTest, GetPermissionRequestToggleStatus001, TestSize.Leve status, userID)); } -/** - * @tc.name: GetSelfPermissionStatus001 - * @tc.desc: GetSelfPermissionStatus with proxy is null - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(AccessTokenMockTest, GetSelfPermissionStatus001, TestSize.Level1) -{ - std::string permission = "ohos.permission.CAMERA"; - PermissionOper status; - ASSERT_EQ(AccessTokenError::ERR_SERVICE_ABNORMAL, AccessTokenKit::GetSelfPermissionStatus(permission, status)); -} - /** * @tc.name: GetSelfPermissionsState001 * @tc.desc: GetSelfPermissionsState with proxy is null diff --git a/interfaces/kits/cj/accesstoken/include/at_manager_impl.h b/interfaces/kits/cj/accesstoken/include/at_manager_impl.h index 96e92dae8cb367af0fa15d307934c66d239b7af3..512f66d930d4bbbab5f6268dc5b5f26950eda64f 100644 --- a/interfaces/kits/cj/accesstoken/include/at_manager_impl.h +++ b/interfaces/kits/cj/accesstoken/include/at_manager_impl.h @@ -57,7 +57,7 @@ const int AT_PERM_OPERA_FAIL = -1; const int AT_PERM_OPERA_SUCC = 0; const int32_t PARAM_DEFAULT_VALUE = -1; -struct GrantStatusCache { +struct PermissionStatusCache { int32_t status; std::string paramValue; }; diff --git a/interfaces/kits/cj/accesstoken/src/at_manager_impl.cpp b/interfaces/kits/cj/accesstoken/src/at_manager_impl.cpp index 9165560cede139875e2078458f9344cd0a76a7f5..6cf2e6c12f152670ecb99eb0f1c0ed6f595e568d 100644 --- a/interfaces/kits/cj/accesstoken/src/at_manager_impl.cpp +++ b/interfaces/kits/cj/accesstoken/src/at_manager_impl.cpp @@ -33,7 +33,7 @@ namespace CJSystemapi { std::mutex g_lockForPermStateChangeRegisters; std::vector g_permStateChangeRegisters; std::mutex g_lockCache; -std::map g_cache; +std::map g_cache; static PermissionParamCache g_paramCache; std::mutex g_lockForPermRequestCallbacks; static const char* PERMISSION_STATUS_CHANGE_KEY = "accesstoken.permission.change"; diff --git a/interfaces/kits/js/napi/accesstoken/include/napi_atmanager.h b/interfaces/kits/js/napi/accesstoken/include/napi_atmanager.h index 5545ecaa247b56c0d287d24f8c4604a5f1fd4854..d36729b2795319dafb075653e42e271230ac8985 100644 --- a/interfaces/kits/js/napi/accesstoken/include/napi_atmanager.h +++ b/interfaces/kits/js/napi/accesstoken/include/napi_atmanager.h @@ -93,16 +93,10 @@ struct AtManagerSyncContext { std::string permissionName; int32_t result = RET_FAILED; int32_t errorCode = 0; - PermissionOper permissionsState = PermissionOper::INVALID_OPER; -}; - -struct GrantStatusCache { - int32_t status; - std::string paramValue; }; struct PermissionStatusCache { - PermissionOper status; + int32_t status; std::string paramValue; }; @@ -130,7 +124,6 @@ private: static napi_value SetPermissionRequestToggleStatus(napi_env env, napi_callback_info info); static napi_value GetPermissionRequestToggleStatus(napi_env env, napi_callback_info info); static napi_value RequestAppPermOnSetting(napi_env env, napi_callback_info info); - static napi_value GetSelfPermissionStatusSync(napi_env env, napi_callback_info info); static bool ParseInputVerifyPermissionOrGetFlag(const napi_env env, const napi_callback_info info, AtManagerAsyncContext& asyncContext); @@ -140,8 +133,6 @@ private: AtManagerAsyncContext& asyncContext); static bool ParseInputGetToggleStatus(const napi_env env, const napi_callback_info info, AtManagerAsyncContext& asyncContext); - static bool ParseInputGetPermStatus(const napi_env env, const napi_callback_info info, - AtManagerSyncContext& syncContext); static void VerifyAccessTokenExecute(napi_env env, void *data); static void VerifyAccessTokenComplete(napi_env env, napi_status status, void *data); static void CheckAccessTokenExecute(napi_env env, void* data); @@ -181,7 +172,7 @@ private: std::vector& batchPermStateChangeRegisters, const napi_env env); static void DeleteRegisterFromVector(const PermStateChangeScope& scopeInfo, const napi_env env, napi_ref subscriberRef); - static std::string GetPermParamValue(PermissionParamCache& paramCache, const char* paramKey); + static std::string GetPermParamValue(); static void UpdatePermissionCache(AtManagerSyncContext* syncContext); }; } // namespace AccessToken diff --git a/services/accesstokenmanager/etc/access_token.para b/services/accesstokenmanager/etc/access_token.para index 27ad4958839e002bd8843a655d5c1213f67a4194..c9f7458a99c9586df08b1dc4836212c733b78268 100644 --- a/services/accesstokenmanager/etc/access_token.para +++ b/services/accesstokenmanager/etc/access_token.para @@ -1,4 +1,4 @@ -# Copyright (c) 2022-2025 Huawei Device Co., Ltd. +# Copyright (c) 2022 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -13,5 +13,4 @@ accesstoken.permission.change = 0 -accesstoken.permission.init = 0 -accesstoken.permission.flagchange = 0 \ No newline at end of file +accesstoken.permission.init = 0 \ No newline at end of file diff --git a/services/accesstokenmanager/etc/access_token.para.dac b/services/accesstokenmanager/etc/access_token.para.dac index 15b0be5d235114f6509cb7223a2422597815a566..33de56a3e39aa999cb9712d7251bebe52d9d6ca8 100644 --- a/services/accesstokenmanager/etc/access_token.para.dac +++ b/services/accesstokenmanager/etc/access_token.para.dac @@ -1,4 +1,4 @@ -# Copyright (c) 2022-2025 Huawei Device Co., Ltd. +# Copyright (c) 2022 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -13,4 +13,3 @@ accesstoken.permission.change="access_token:access_token:0774" accesstoken.permission.init="access_token:access_token:0774" -accesstoken.permission.flagchange="access_token:access_token:0774" diff --git a/services/accesstokenmanager/idl/IAccessTokenManager.idl b/services/accesstokenmanager/idl/IAccessTokenManager.idl index c5497e408c9990a31e95a117270dc2ad847711ed..31da0d22520ae5509129c772d607a409230cbf8e 100644 --- a/services/accesstokenmanager/idl/IAccessTokenManager.idl +++ b/services/accesstokenmanager/idl/IAccessTokenManager.idl @@ -86,5 +86,4 @@ interface OHOS.Security.AccessToken.IAccessTokenManager{ [ipccode 67] void GetKernelPermissions([in] unsigned int tokenId, [out] List kernelPermIdlList); [ipccode 68] void GetReqPermissionByName([in] unsigned int tokenId, [in] String permissionName, [out] String value); [ipccode 80] void VerifyAccessToken([in] unsigned int tokenID, [in] List permissionList, [out] List permStateList); - [ipccode 81] void GetSelfPermissionStatus([in] String permissionName, [out] int status); } \ No newline at end of file diff --git a/services/accesstokenmanager/main/cpp/include/permission/permission_manager.h b/services/accesstokenmanager/main/cpp/include/permission/permission_manager.h index 8fd5fef4292dcb1eb307b096883485b4dd07f844..14cd8a00aa4e814b859d692a3833e5c01217747a 100644 --- a/services/accesstokenmanager/main/cpp/include/permission/permission_manager.h +++ b/services/accesstokenmanager/main/cpp/include/permission/permission_manager.h @@ -85,7 +85,6 @@ public: std::vector& permsList, int32_t apiVersion); void NotifyPermGrantStoreResult(bool result, uint64_t timestamp); void ParamUpdate(const std::string& permissionName, uint32_t flag, bool filtered); - void ParamFlagUpdate(); void NotifyWhenPermissionStateUpdated(AccessTokenID tokenID, const std::string& permissionName, bool isGranted, uint32_t flag, const std::shared_ptr& infoPtr); void AddNativePermToKernel( @@ -126,9 +125,6 @@ private: OHOS::Utils::RWLock permParamSetLock_; uint64_t paramValue_ = 0; - OHOS::Utils::RWLock permFlagParamSetLock_; - uint64_t paramFlagValue_ = 0; - OHOS::Utils::RWLock permToggleStateLock_; DISALLOW_COPY_AND_MOVE(PermissionManager); diff --git a/services/accesstokenmanager/main/cpp/include/service/accesstoken_manager_service.h b/services/accesstokenmanager/main/cpp/include/service/accesstoken_manager_service.h index ad9361d703abee90dcce68e19d25c001a35ccf73..5ab5562baa4e9948bfc4fb0621f4fc8c0488d8c0 100644 --- a/services/accesstokenmanager/main/cpp/include/service/accesstoken_manager_service.h +++ b/services/accesstokenmanager/main/cpp/include/service/accesstoken_manager_service.h @@ -58,7 +58,6 @@ public: int GetDefPermission(const std::string& permissionName, PermissionDefParcel& permissionDefResult) override; int GetReqPermissions( AccessTokenID tokenID, std::vector& reqPermList, bool isSystemGrant) override; - int32_t GetSelfPermissionStatus(const std::string& permissionName, int32_t& status) override; int32_t GetSelfPermissionsState(std::vector& reqPermList, PermissionGrantInfoParcel& infoParcel, int32_t& permOper) override; int32_t GetPermissionsStatus(AccessTokenID tokenID, std::vector& reqPermList) override; diff --git a/services/accesstokenmanager/main/cpp/src/permission/permission_manager.cpp b/services/accesstokenmanager/main/cpp/src/permission/permission_manager.cpp index 24e1a9336eab326636137ea87ad234d61cd5264f..e8f12d45707d1506aae607d55be9b55aa2c81d92 100644 --- a/services/accesstokenmanager/main/cpp/src/permission/permission_manager.cpp +++ b/services/accesstokenmanager/main/cpp/src/permission/permission_manager.cpp @@ -50,7 +50,6 @@ namespace Security { namespace AccessToken { namespace { static const char* PERMISSION_STATUS_CHANGE_KEY = "accesstoken.permission.change"; -static const char* PERMISSION_STATUS_FLAG_CHANGE_KEY = "accesstoken.permission.flagchange"; static constexpr int32_t VALUE_MAX_LEN = 32; static const std::vector g_notDisplayedPerms = { "ohos.permission.ANSWER_CALL", @@ -93,18 +92,9 @@ PermissionManager::PermissionManager() if (ret < 0) { LOGE(ATM_DOMAIN, ATM_TAG, "Return default value, ret=%{public}d", ret); paramValue_ = 0; - } else { - paramValue_ = static_cast(std::atoll(value)); - } - - char flagValue[VALUE_MAX_LEN] = {0}; - ret = GetParameter(PERMISSION_STATUS_FLAG_CHANGE_KEY, "", flagValue, VALUE_MAX_LEN - 1); - if (ret < 0) { - LOGE(ATM_DOMAIN, ATM_TAG, "Return default flag value, ret=%{public}d", ret); - paramFlagValue_ = 0; return; } - paramFlagValue_ = static_cast(std::atoll(flagValue)); + paramValue_ = static_cast(std::atoll(value)); } PermissionManager::~PermissionManager() @@ -328,18 +318,6 @@ void PermissionManager::ParamUpdate(const std::string& permissionName, uint32_t } } -void PermissionManager::ParamFlagUpdate() -{ - Utils::UniqueWriteGuard infoGuard(this->permFlagParamSetLock_); - paramFlagValue_++; - LOGD(ATM_DOMAIN, ATM_TAG, - "paramFlagValue_ change %{public}llu", static_cast(paramFlagValue_)); - int32_t res = SetParameter(PERMISSION_STATUS_FLAG_CHANGE_KEY, std::to_string(paramFlagValue_).c_str()); - if (res != 0) { - LOGE(ATM_DOMAIN, ATM_TAG, "SetParameter failed %{public}d", res); - } -} - void PermissionManager::NotifyWhenPermissionStateUpdated(AccessTokenID tokenID, const std::string& permissionName, bool isGranted, uint32_t flag, const std::shared_ptr& infoPtr) { @@ -389,10 +367,6 @@ int32_t PermissionManager::UpdateTokenPermissionState( "INT_VAL2", static_cast(flag), "NEED_KILL", needKill); return ret; } - - // notify flag change - ParamFlagUpdate(); - if (statusChanged) { NotifyWhenPermissionStateUpdated(id, permission, isGranted, flag, infoPtr); // To notify kill process when perm is revoke diff --git a/services/accesstokenmanager/main/cpp/src/service/accesstoken_manager_service.cpp b/services/accesstokenmanager/main/cpp/src/service/accesstoken_manager_service.cpp index 173e99765fa0066cfa30ab2cf6c48bd46653fc65..ccdf0fff3f08d0d1fed18c31dcd98fa0e3312ddf 100644 --- a/services/accesstokenmanager/main/cpp/src/service/accesstoken_manager_service.cpp +++ b/services/accesstokenmanager/main/cpp/src/service/accesstoken_manager_service.cpp @@ -266,21 +266,6 @@ int AccessTokenManagerService::GetReqPermissions( return ret; } -int32_t AccessTokenManagerService::GetSelfPermissionStatus(const std::string& permissionName, int32_t& status) -{ - status = INVALID_OPER; - AccessTokenID callingTokenID = IPCSkeleton::GetCallingTokenID(); - PermissionListStateParcel parcel; - parcel.permsState.permissionName = permissionName; - parcel.permsState.state = INVALID_OPER; - std::vector list{parcel}; - (void)GetPermissionsState(callingTokenID, list); - if (!list.empty()) { - status = static_cast(list[0].permsState.state); - } - return ERR_OK; -} - int32_t AccessTokenManagerService::GetSelfPermissionsState(std::vector& reqPermList, PermissionGrantInfoParcel& infoParcel, int32_t& permOper) { diff --git a/test/fuzztest/innerkits/accesstoken/BUILD.gn b/test/fuzztest/innerkits/accesstoken/BUILD.gn index 6ebac1ef1c747979ee168b304e1e424339fdcae3..8b1334097bcf3cbf52c7894cda6ffa3d741faee8 100644 --- a/test/fuzztest/innerkits/accesstoken/BUILD.gn +++ b/test/fuzztest/innerkits/accesstoken/BUILD.gn @@ -40,7 +40,6 @@ group("fuzztest") { "getrendertokenid_fuzzer:GetRenderTokenIdFuzzTest", "getreqpermissions_fuzzer:GetReqPermissionsFuzzTest", "getselfpermissionsstate_fuzzer:GetSelfPermissionsStateFuzzTest", - "getselfpermissionstatus_fuzzer:GetSelfPermissionStatusFuzzTest", "gettokenidbyuserid_fuzzer:GetTokenIDByUserIDFuzzTest", "gettokentype_fuzzer:GetTokenTypeFuzzTest", "gettokentypeflag_fuzzer:GetTokenTypeFlagFuzzTest", diff --git a/test/fuzztest/innerkits/accesstoken/getselfpermissionstatus_fuzzer/BUILD.gn b/test/fuzztest/innerkits/accesstoken/getselfpermissionstatus_fuzzer/BUILD.gn deleted file mode 100644 index 2968c428b3267f517ad03b977414b4e8eb61401b..0000000000000000000000000000000000000000 --- a/test/fuzztest/innerkits/accesstoken/getselfpermissionstatus_fuzzer/BUILD.gn +++ /dev/null @@ -1,42 +0,0 @@ -# Copyright (c) 2025 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//build/config/features.gni") -import("//build/test.gni") -import("../../../../../access_token.gni") - -ohos_fuzztest("GetSelfPermissionStatusFuzzTest") { - module_out_path = module_output_path_interface_access_token - fuzz_config_file = "." - include_dirs = [ - "${access_token_path}/interfaces/innerkits/accesstoken/include", - "${access_token_path}/test/fuzztest/common", - ] - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - sources = [ "getselfpermissionstatus_fuzzer.cpp" ] - deps = [ - "${access_token_path}/interfaces/innerkits/accesstoken:libaccesstoken_sdk", - ] - - configs = [ "${access_token_path}/config:coverage_flags" ] - - external_deps = [ - "c_utils:utils", - "hilog:libhilog", - ] -} diff --git a/test/fuzztest/innerkits/accesstoken/getselfpermissionstatus_fuzzer/corpus/init b/test/fuzztest/innerkits/accesstoken/getselfpermissionstatus_fuzzer/corpus/init deleted file mode 100644 index 8f37f09254457133cae0f828d0a5faee7dcbd779..0000000000000000000000000000000000000000 --- a/test/fuzztest/innerkits/accesstoken/getselfpermissionstatus_fuzzer/corpus/init +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright (c) 2025 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -FUZZ \ No newline at end of file diff --git a/test/fuzztest/innerkits/accesstoken/getselfpermissionstatus_fuzzer/getselfpermissionstatus_fuzzer.cpp b/test/fuzztest/innerkits/accesstoken/getselfpermissionstatus_fuzzer/getselfpermissionstatus_fuzzer.cpp deleted file mode 100644 index a9b21bd237bce727e93954607d9d7945095fc4a7..0000000000000000000000000000000000000000 --- a/test/fuzztest/innerkits/accesstoken/getselfpermissionstatus_fuzzer/getselfpermissionstatus_fuzzer.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "getselfpermissionstatus_fuzzer.h" - -#include -#include -#include -#include "accesstoken_fuzzdata.h" -#undef private -#include "accesstoken_kit.h" - -using namespace std; -using namespace OHOS::Security::AccessToken; - -namespace OHOS { - bool GetSelfPermissionStatusFuzzTest(const uint8_t* data, size_t size) - { - if ((data == nullptr) || (size == 0)) { - return false; - } - - AccessTokenFuzzData fuzzData(data, size); - std::string permissionName = fuzzData.GenerateStochasticString(); - PermissionOper status; - - AccessTokenKit::GetSelfPermissionStatus(permissionName, status); - return true; - } -} - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - /* Run your code on data */ - OHOS::GetSelfPermissionStatusFuzzTest(data, size); - return 0; -} diff --git a/test/fuzztest/innerkits/accesstoken/getselfpermissionstatus_fuzzer/getselfpermissionstatus_fuzzer.h b/test/fuzztest/innerkits/accesstoken/getselfpermissionstatus_fuzzer/getselfpermissionstatus_fuzzer.h deleted file mode 100644 index 46854bbce527c0bc6b6ab0d3821b49da4ac6a465..0000000000000000000000000000000000000000 --- a/test/fuzztest/innerkits/accesstoken/getselfpermissionstatus_fuzzer/getselfpermissionstatus_fuzzer.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef TEST_FUZZTEST_GETSELFPERMISSIONSTATUS_FUZZER_H -#define TEST_FUZZTEST_GETSELFPERMISSIONSTATUS_FUZZER_H - -#define FUZZ_PROJECT_NAME "getselfpermissionstatus_fuzzer" - -#include -#include -#include -#include -#include -#include - -#endif // TEST_FUZZTEST_GETSELFPERMISSIONSTATUS_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/innerkits/accesstoken/getselfpermissionstatus_fuzzer/project.xml b/test/fuzztest/innerkits/accesstoken/getselfpermissionstatus_fuzzer/project.xml deleted file mode 100644 index 66e1dcac475475fb101b6f8670ec699e6e9696aa..0000000000000000000000000000000000000000 --- a/test/fuzztest/innerkits/accesstoken/getselfpermissionstatus_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 1000 - - 300 - - 4096 - - diff --git a/test/fuzztest/services/accesstoken/BUILD.gn b/test/fuzztest/services/accesstoken/BUILD.gn index ef172e3383e74bd9987fd09b1cc25a8075857e43..99767dcd121b6ef2222e50f44a1aa95c9658ebed 100644 --- a/test/fuzztest/services/accesstoken/BUILD.gn +++ b/test/fuzztest/services/accesstoken/BUILD.gn @@ -39,7 +39,6 @@ group("fuzztest") { "getreqpermissionbynamestub_fuzzer:GetReqPermissionByNameStubFuzzTest", "getreqpermissionsstub_fuzzer:GetReqPermissionsStubFuzzTest", "getselfpermissionsstatestub_fuzzer:GetSelfPermissionsStateStubFuzzTest", - "getselfpermissionstatusstub_fuzzer:GetSelfPermissionStatusStubFuzzTest", "gettokenidbyuseridstub_fuzzer:GetTokenIDByUserIDStubFuzzTest", "gettokentypestub_fuzzer:GetTokenTypeStubFuzzTest", "grantpermissionforspecifiedtimestub_fuzzer:GrantPermissionForSpecifiedTimeStubFuzzTest", diff --git a/test/fuzztest/services/accesstoken/getselfpermissionstatusstub_fuzzer/BUILD.gn b/test/fuzztest/services/accesstoken/getselfpermissionstatusstub_fuzzer/BUILD.gn deleted file mode 100644 index 4e1b33289c85ff733e6f55970d22be063026e58b..0000000000000000000000000000000000000000 --- a/test/fuzztest/services/accesstoken/getselfpermissionstatusstub_fuzzer/BUILD.gn +++ /dev/null @@ -1,50 +0,0 @@ -# Copyright (c) 2025 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//build/config/features.gni") -import("//build/test.gni") -import("../../../../../access_token.gni") -import("../access_token_service_fuzz.gni") - -ohos_fuzztest("GetSelfPermissionStatusStubFuzzTest") { - module_out_path = module_output_path_service_access_token - fuzz_config_file = "." - - sources = [ "getselfpermissionstatusstub_fuzzer.cpp" ] - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - - include_dirs = access_token_include_dirs - - deps = access_token_deps - - configs = [ - "${access_token_path}/config:coverage_flags", - "${access_token_path}/services/accesstokenmanager/idl:access_token_manager_gen_config", - ] - - external_deps = access_token_external_deps - - include_dirs += access_token_impl_include_dirs - - cflags_cc = access_token_cflags_cc - - sources += access_token_sources - - sources += access_token_impl_sources -} diff --git a/test/fuzztest/services/accesstoken/getselfpermissionstatusstub_fuzzer/corpus/init b/test/fuzztest/services/accesstoken/getselfpermissionstatusstub_fuzzer/corpus/init deleted file mode 100644 index 65af8ee8d11bf23407ea34d4de49f7cbb6a2b791..0000000000000000000000000000000000000000 --- a/test/fuzztest/services/accesstoken/getselfpermissionstatusstub_fuzzer/corpus/init +++ /dev/null @@ -1,14 +0,0 @@ -# Copyright (c) 2025 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -FUZZ \ No newline at end of file diff --git a/test/fuzztest/services/accesstoken/getselfpermissionstatusstub_fuzzer/getselfpermissionstatusstub_fuzzer.cpp b/test/fuzztest/services/accesstoken/getselfpermissionstatusstub_fuzzer/getselfpermissionstatusstub_fuzzer.cpp deleted file mode 100644 index 5587af8d23d54c7b71713a0063e57672b8ceb941..0000000000000000000000000000000000000000 --- a/test/fuzztest/services/accesstoken/getselfpermissionstatusstub_fuzzer/getselfpermissionstatusstub_fuzzer.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "getselfpermissionstatusstub_fuzzer.h" - -#include -#include -#include -#undef private -#include "accesstoken_fuzzdata.h" -#include "accesstoken_manager_service.h" -#include "iaccess_token_manager.h" - -using namespace std; -using namespace OHOS; -using namespace OHOS::Security::AccessToken; - -namespace OHOS { - bool GetSelfPermissionStatusStubFuzzTest(const uint8_t* data, size_t size) - { - if ((data == nullptr) || (size == 0)) { - return false; - } - AccessTokenFuzzData fuzzData(data, size); - std::string permissionName = fuzzData.GenerateStochasticString(); - MessageParcel datas; - datas.WriteInterfaceToken(IAccessTokenManager::GetDescriptor()); - if (!datas.WriteString(permissionName)) { - return false; - } - - uint32_t code = static_cast( - IAccessTokenManagerIpcCode::COMMAND_GET_SELF_PERMISSION_STATUS); - MessageParcel reply; - MessageOption option; - DelayedSingleton::GetInstance()->OnRemoteRequest(code, datas, reply, option); - return true; - } -} - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - /* Run your code on data */ - OHOS::GetSelfPermissionStatusStubFuzzTest(data, size); - return 0; -} - diff --git a/test/fuzztest/services/accesstoken/getselfpermissionstatusstub_fuzzer/getselfpermissionstatusstub_fuzzer.h b/test/fuzztest/services/accesstoken/getselfpermissionstatusstub_fuzzer/getselfpermissionstatusstub_fuzzer.h deleted file mode 100644 index 6c3de023ffd7666c123353d1b7b55aa5f20b4155..0000000000000000000000000000000000000000 --- a/test/fuzztest/services/accesstoken/getselfpermissionstatusstub_fuzzer/getselfpermissionstatusstub_fuzzer.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef TEST_FUZZTEST_GETSELFPERMISSIONSTATUSSTUB_FUZZER_H -#define TEST_FUZZTEST_GETSELFPERMISSIONSTATUSSTUB_FUZZER_H - -#define FUZZ_PROJECT_NAME "getselfpermissionstatusstub_fuzzer" - -#endif // TEST_FUZZTEST_GETSELFPERMISSIONSTATUSSTUB_FUZZER_H diff --git a/test/fuzztest/services/accesstoken/getselfpermissionstatusstub_fuzzer/project.xml b/test/fuzztest/services/accesstoken/getselfpermissionstatusstub_fuzzer/project.xml deleted file mode 100644 index 66e1dcac475475fb101b6f8670ec699e6e9696aa..0000000000000000000000000000000000000000 --- a/test/fuzztest/services/accesstoken/getselfpermissionstatusstub_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 1000 - - 300 - - 4096 - -