From df46bb0ec93dce1ad08651fb4742e670d370ab5f Mon Sep 17 00:00:00 2001 From: zhouyan Date: Mon, 26 May 2025 20:35:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9D=83=E9=99=90=E7=AE=A1=E7=90=86=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E6=95=B0=E6=8D=AE=E5=BA=93OnUpgrade=E4=BC=98=E5=8C=96?= =?UTF-8?q?+=E9=9A=90=E7=A7=81=E6=97=A0=E6=95=88=E7=94=A8=E4=BE=8B?= =?UTF-8?q?=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhouyan Change-Id: Id3333136ae53dedbf0fbb1f43277900fe6712afd --- .../test/unittest/src/privacy_kit_test.cpp | 33 +++-- .../database/access_token_open_callback.h | 2 - .../database/access_token_open_callback.cpp | 135 +++++++----------- .../service/accesstoken_manager_service.cpp | 2 +- .../active/active_status_callback_manager.cpp | 4 +- .../src/record/permission_record_manager.cpp | 5 +- ...ermission_record_manager_coverage_test.cpp | 17 --- .../permission_record_manager_test.cpp | 2 + .../unittest/privacy_manager_service_test.cpp | 27 ++-- 9 files changed, 88 insertions(+), 139 deletions(-) diff --git a/interfaces/innerkits/privacy/test/unittest/src/privacy_kit_test.cpp b/interfaces/innerkits/privacy/test/unittest/src/privacy_kit_test.cpp index 2aef3adb5..49a983315 100644 --- a/interfaces/innerkits/privacy/test/unittest/src/privacy_kit_test.cpp +++ b/interfaces/innerkits/privacy/test/unittest/src/privacy_kit_test.cpp @@ -1096,28 +1096,31 @@ HWTEST_F(PrivacyKitTest, RegisterPermActiveStatusCallback001, TestSize.Level0) std::vector permList = {"ohos.permission.CAMERA"}; auto callbackPtr = std::make_shared(permList); - callbackPtr->type_ = PERM_INACTIVE; + callbackPtr->type_ = PERM_TEMPORARY_CALL; ASSERT_EQ(RET_NO_ERROR, PrivacyKit::RegisterPermActiveStatusCallback(callbackPtr)); - - ASSERT_EQ(RET_NO_ERROR, PrivacyKit::StartUsingPermission(g_tokenIdE, "ohos.permission.CAMERA")); + EXPECT_EQ(RET_NO_ERROR, PrivacyKit::StartUsingPermission(g_tokenIdE, "ohos.permission.CAMERA")); usleep(1000000); // 1000000us = 1s - ASSERT_EQ(PERM_ACTIVE_IN_BACKGROUND, callbackPtr->type_); + EXPECT_EQ(PERM_ACTIVE_IN_BACKGROUND, callbackPtr->type_); - ASSERT_EQ(RET_NO_ERROR, PrivacyKit::StopUsingPermission(g_tokenIdE, "ohos.permission.CAMERA")); + EXPECT_EQ(RET_NO_ERROR, PrivacyKit::StopUsingPermission(g_tokenIdE, "ohos.permission.CAMERA")); usleep(1000000); // 1000000us = 1s - ASSERT_EQ(PERM_INACTIVE, callbackPtr->type_); + EXPECT_EQ(PERM_INACTIVE, callbackPtr->type_); - ASSERT_EQ(RET_NO_ERROR, PrivacyKit::UnRegisterPermActiveStatusCallback(callbackPtr)); - callbackPtr->type_ = PERM_INACTIVE; + EXPECT_EQ(RET_NO_ERROR, PrivacyKit::UnRegisterPermActiveStatusCallback(callbackPtr)); + callbackPtr->type_ = PERM_TEMPORARY_CALL; ASSERT_EQ(RET_NO_ERROR, PrivacyKit::StartUsingPermission(g_tokenIdE, "ohos.permission.CAMERA")); - ASSERT_EQ(PERM_INACTIVE, callbackPtr->type_); + EXPECT_NE(PERM_INACTIVE, callbackPtr->type_); + EXPECT_NE(PERM_ACTIVE_IN_FOREGROUND, callbackPtr->type_); + EXPECT_NE(PERM_ACTIVE_IN_BACKGROUND, callbackPtr->type_); ASSERT_EQ(RET_NO_ERROR, PrivacyKit::StopUsingPermission(g_tokenIdE, "ohos.permission.CAMERA")); - ASSERT_EQ(PERM_INACTIVE, callbackPtr->type_); + ASSERT_NE(PERM_INACTIVE, callbackPtr->type_); + ASSERT_NE(PERM_ACTIVE_IN_FOREGROUND, callbackPtr->type_); + ASSERT_NE(PERM_ACTIVE_IN_BACKGROUND, callbackPtr->type_); } class CbCustomizeTest3 : public PermActiveStatusCustomizedCbk { @@ -1156,15 +1159,15 @@ HWTEST_F(PrivacyKitTest, RegisterPermActiveStatusCallback002, TestSize.Level0) { std::vector permList1 = {"ohos.permission.READ_CONTACTS"}; auto callbackPtr1 = std::make_shared(permList1); - callbackPtr1->type_ = PERM_INACTIVE; + callbackPtr1->type_ = PERM_TEMPORARY_CALL; std::vector permList2 = {"ohos.permission.READ_MEDIA"}; auto callbackPtr2 = std::make_shared(permList2); - callbackPtr2->type_ = PERM_INACTIVE; + callbackPtr2->type_ = PERM_TEMPORARY_CALL; std::vector permList3 = {}; auto callbackPtr3 = std::make_shared(permList3); - callbackPtr3->type_ = PERM_INACTIVE; + callbackPtr3->type_ = PERM_TEMPORARY_CALL; ASSERT_EQ(RET_NO_ERROR, PrivacyKit::RegisterPermActiveStatusCallback(callbackPtr1)); ASSERT_EQ(RET_NO_ERROR, PrivacyKit::RegisterPermActiveStatusCallback(callbackPtr2)); @@ -1174,7 +1177,6 @@ HWTEST_F(PrivacyKitTest, RegisterPermActiveStatusCallback002, TestSize.Level0) usleep(1000000); // 1000000us = 1s EXPECT_EQ(PERM_ACTIVE_IN_BACKGROUND, callbackPtr1->type_); - EXPECT_EQ(PERM_INACTIVE, callbackPtr2->type_); EXPECT_EQ(PERM_ACTIVE_IN_BACKGROUND, callbackPtr3->type_); ASSERT_EQ(RET_NO_ERROR, PrivacyKit::StopUsingPermission(g_tokenIdE, "ohos.permission.READ_CONTACTS")); @@ -1186,13 +1188,14 @@ HWTEST_F(PrivacyKitTest, RegisterPermActiveStatusCallback002, TestSize.Level0) ASSERT_EQ(RET_NO_ERROR, PrivacyKit::StartUsingPermission(g_tokenIdE, "ohos.permission.READ_MEDIA")); usleep(1000000); // 1000000us = 1s - EXPECT_EQ(PERM_INACTIVE, callbackPtr1->type_); EXPECT_EQ(PERM_ACTIVE_IN_BACKGROUND, callbackPtr2->type_); + EXPECT_EQ(PERM_ACTIVE_IN_BACKGROUND, callbackPtr3->type_); ASSERT_EQ(RET_NO_ERROR, PrivacyKit::StopUsingPermission(g_tokenIdE, "ohos.permission.READ_MEDIA")); usleep(1000000); // 1000000us = 1s EXPECT_EQ(PERM_INACTIVE, callbackPtr2->type_); + EXPECT_EQ(PERM_INACTIVE, callbackPtr3->type_); ASSERT_EQ(RET_NO_ERROR, PrivacyKit::UnRegisterPermActiveStatusCallback(callbackPtr1)); ASSERT_EQ(RET_NO_ERROR, PrivacyKit::UnRegisterPermActiveStatusCallback(callbackPtr2)); diff --git a/services/accesstokenmanager/main/cpp/include/database/access_token_open_callback.h b/services/accesstokenmanager/main/cpp/include/database/access_token_open_callback.h index 40f84d553..33f959fcc 100644 --- a/services/accesstokenmanager/main/cpp/include/database/access_token_open_callback.h +++ b/services/accesstokenmanager/main/cpp/include/database/access_token_open_callback.h @@ -71,8 +71,6 @@ private: int32_t AddRequestToggleStatusColumn(NativeRdb::RdbStore& rdbStore); int32_t AddPermDialogCapColumn(NativeRdb::RdbStore& rdbStore); int32_t AddKernelEffectAndHasValueColumn(NativeRdb::RdbStore& rdbStore); - void GetUpgradeFlag(int32_t currentVersion, int32_t targetVersion, uint32_t& flag); - int32_t HandleUpgradeWithFlag(NativeRdb::RdbStore& rdbStore, uint32_t flag); }; } // namespace AccessToken } // namespace Security diff --git a/services/accesstokenmanager/main/cpp/src/database/access_token_open_callback.cpp b/services/accesstokenmanager/main/cpp/src/database/access_token_open_callback.cpp index 7132680d3..fb5c7459f 100644 --- a/services/accesstokenmanager/main/cpp/src/database/access_token_open_callback.cpp +++ b/services/accesstokenmanager/main/cpp/src/database/access_token_open_callback.cpp @@ -28,12 +28,6 @@ constexpr const char* INTEGER_STR = " integer not null,"; constexpr const char* TEXT_STR = " text not null,"; // back up name is xxx_slave fixed, can not be changed constexpr const char* DATABASE_NAME_BACK = "access_token_slave.db"; - -constexpr const uint32_t FLAG_HANDLE_FROM_ONE_TO_TWO = 1; -constexpr const uint32_t FLAG_HANDLE_FROM_TWO_TO_THREE = 1 << 1; -constexpr const uint32_t FLAG_HANDLE_FROM_THREE_TO_FOUR = 1 << 2; -constexpr const uint32_t FLAG_HANDLE_FROM_FOUR_TO_FIVE = 1 << 3; -constexpr const uint32_t FLAG_HANDLE_FROM_FIVE_TO_SIX = 1 << 4; } int32_t AccessTokenOpenCallback::CreateHapTokenInfoTable(NativeRdb::RdbStore& rdbStore) @@ -504,92 +498,61 @@ int32_t AccessTokenOpenCallback::AddKernelEffectAndHasValueColumn(NativeRdb::Rdb return NativeRdb::E_OK; } -int32_t AccessTokenOpenCallback::HandleUpgradeWithFlag(NativeRdb::RdbStore& rdbStore, uint32_t flag) -{ - int32_t res = NativeRdb::E_OK; - - if ((flag & FLAG_HANDLE_FROM_ONE_TO_TWO) == FLAG_HANDLE_FROM_ONE_TO_TWO) { - res = AddAvailableTypeColumn(rdbStore); - if (res != NativeRdb::E_OK) { - LOGE(ATM_DOMAIN, ATM_TAG, "Failed to add column available_type."); - return res; - } - - res = AddPermDialogCapColumn(rdbStore); - if (res != NativeRdb::E_OK) { - LOGE(ATM_DOMAIN, ATM_TAG, "Failed to add column perm_dialog_cap_state."); - return res; - } - } - - if ((flag & FLAG_HANDLE_FROM_TWO_TO_THREE) == FLAG_HANDLE_FROM_TWO_TO_THREE) { - res = CreatePermissionRequestToggleStatusTable(rdbStore); - if (res != NativeRdb::E_OK) { - LOGE(ATM_DOMAIN, ATM_TAG, "Failed to create table permission_request_toggle_status_table."); - return res; - } - } - - if ((flag & FLAG_HANDLE_FROM_THREE_TO_FOUR) == FLAG_HANDLE_FROM_THREE_TO_FOUR) { - res = AddRequestToggleStatusColumn(rdbStore); - if (res != NativeRdb::E_OK) { - LOGE(ATM_DOMAIN, ATM_TAG, "Failed to add column status."); - return res; - } - } - - if ((flag & FLAG_HANDLE_FROM_FOUR_TO_FIVE) == FLAG_HANDLE_FROM_FOUR_TO_FIVE) { - res = CreateVersionFiveTable(rdbStore); - if (res != NativeRdb::E_OK) { - return res; - } - - res = AddKernelEffectAndHasValueColumn(rdbStore); - if (res != NativeRdb::E_OK) { - LOGE(ATM_DOMAIN, ATM_TAG, "Failed to add column kernel_effect or has_value."); - return res; - } - } - - if ((flag & FLAG_HANDLE_FROM_FIVE_TO_SIX) == FLAG_HANDLE_FROM_FIVE_TO_SIX) { - return CreateVersionSixTable(rdbStore); - } - - return res; -} - -void AccessTokenOpenCallback::GetUpgradeFlag(int32_t currentVersion, int32_t targetVersion, uint32_t& flag) -{ - if ((targetVersion >= DATABASE_VERSION_2) && (currentVersion < DATABASE_VERSION_2)) { - flag += FLAG_HANDLE_FROM_ONE_TO_TWO; - } - - if ((targetVersion >= DATABASE_VERSION_3) && (currentVersion < DATABASE_VERSION_3)) { - flag += FLAG_HANDLE_FROM_TWO_TO_THREE; - } - - if ((targetVersion >= DATABASE_VERSION_4) && (currentVersion < DATABASE_VERSION_4)) { - flag += FLAG_HANDLE_FROM_THREE_TO_FOUR; - } - - if ((targetVersion >= DATABASE_VERSION_5) && (currentVersion < DATABASE_VERSION_5)) { - flag += FLAG_HANDLE_FROM_FOUR_TO_FIVE; - } - - if ((targetVersion >= DATABASE_VERSION_6) && (currentVersion < DATABASE_VERSION_6)) { - flag += FLAG_HANDLE_FROM_FIVE_TO_SIX; - } -} - int32_t AccessTokenOpenCallback::OnUpgrade(NativeRdb::RdbStore& rdbStore, int32_t currentVersion, int32_t targetVersion) { LOGI(ATM_DOMAIN, ATM_TAG, "DB OnUpgrade from currentVersion %{public}d to targetVersion %{public}d.", currentVersion, targetVersion); - uint32_t flag = 0; - GetUpgradeFlag(currentVersion, targetVersion, flag); + int32_t res = 0; + switch (currentVersion) { // upgrade to the latest db version in rom, no mather how much the version is + case DATABASE_VERSION_1: // 1->2 + res = AddAvailableTypeColumn(rdbStore); + if (res != NativeRdb::E_OK) { + LOGE(ATM_DOMAIN, ATM_TAG, "Failed to add column available_type, res is %{public}d.", res); + return res; + } + res = AddPermDialogCapColumn(rdbStore); + if (res != NativeRdb::E_OK) { + LOGE(ATM_DOMAIN, ATM_TAG, "Failed to add column perm_dialog_cap_state, res is %{public}d.", res); + return res; + } + + case DATABASE_VERSION_2: // 2->3 + res = CreatePermissionRequestToggleStatusTable(rdbStore); + if (res != NativeRdb::E_OK) { + LOGE(ATM_DOMAIN, ATM_TAG, "Failed to create table permission_request_toggle_status_table."); + return res; + } + + case DATABASE_VERSION_3: // 3->4 + res = AddRequestToggleStatusColumn(rdbStore); + if (res != NativeRdb::E_OK) { + LOGE(ATM_DOMAIN, ATM_TAG, "Failed to add column status."); + return res; + } + + case DATABASE_VERSION_4: // 4->5 + res = CreateVersionFiveTable(rdbStore); + if (res != NativeRdb::E_OK) { + return res; + } + res = AddKernelEffectAndHasValueColumn(rdbStore); + if (res != NativeRdb::E_OK) { + LOGE(ATM_DOMAIN, ATM_TAG, "Failed to add column kernel_effect or has_value."); + return res; + } + + case DATABASE_VERSION_5: // 5->6 + res = CreateVersionSixTable(rdbStore); + if (res != NativeRdb::E_OK) { + return res; + } + + default: + return NativeRdb::E_OK; + } - return HandleUpgradeWithFlag(rdbStore, flag); + return NativeRdb::E_OK; } } // namespace AccessToken } // namespace Security 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 a650004bb..94ce16c7f 100644 --- a/services/accesstokenmanager/main/cpp/src/service/accesstoken_manager_service.cpp +++ b/services/accesstokenmanager/main/cpp/src/service/accesstoken_manager_service.cpp @@ -1529,7 +1529,7 @@ void AccessTokenManagerService::HandleHapUndefinedInfo(std::map task = ([info]() mutable { ActiveStatusCallbackManager::GetInstance().ActiveStatusChange(info); LOGI(PRI_DOMAIN, PRI_TAG, - "Token: %{public}u, permName: %{public}s, changeType: %{public}d, ActiveStatusChange end", - info.tokenID, info.permissionName.c_str(), info.type); + "Token: %{public}u, pid: %{public}d, permName: %{public}s, changeType: %{public}d, ActiveStatusChange end", + info.tokenID, info.pid, info.permissionName.c_str(), info.type); }); eventHandler_->ProxyPostTask(task, taskName); LOGI(PRI_DOMAIN, PRI_TAG, "The callback execution is complete"); diff --git a/services/privacymanager/src/record/permission_record_manager.cpp b/services/privacymanager/src/record/permission_record_manager.cpp index 36fac081b..2e57a7ed5 100644 --- a/services/privacymanager/src/record/permission_record_manager.cpp +++ b/services/privacymanager/src/record/permission_record_manager.cpp @@ -974,7 +974,7 @@ void PermissionRecordManager::ExecuteAndUpdateRecord(uint32_t tokenId, int32_t p std::lock_guard lock(startRecordListMutex_); std::set updateList; for (auto it = startRecordList_.begin(); it != startRecordList_.end();) { - if ((it->tokenId == tokenId) && ((it->status) != PERM_INACTIVE) && ((it->status) != status)) { + if ((it->tokenId == tokenId) && (it->pid == pid) && (it->status != PERM_INACTIVE) && (it->status != status)) { std::string perm; Constant::TransferOpcodeToPermission(it->opCode, perm); if ((GetMuteStatus(perm, EDM)) || (!GetGlobalSwitchStatus(perm))) { @@ -1001,7 +1001,8 @@ void PermissionRecordManager::ExecuteAndUpdateRecord(uint32_t tokenId, int32_t p record.status = status; updateList.emplace(record); it = startRecordList_.erase(it); - LOGD(PRI_DOMAIN, PRI_TAG, "TokenId %{public}d get permission %{public}s.", tokenId, perm.c_str()); + LOGD(PRI_DOMAIN, PRI_TAG, "TokenId %{public}d pid %{public}d get permission %{public}s.", tokenId, pid, + perm.c_str()); continue; } ++it; diff --git a/services/privacymanager/test/coverage/permission_record_manager_coverage_test.cpp b/services/privacymanager/test/coverage/permission_record_manager_coverage_test.cpp index c14bce14a..62ae2ea2a 100644 --- a/services/privacymanager/test/coverage/permission_record_manager_coverage_test.cpp +++ b/services/privacymanager/test/coverage/permission_record_manager_coverage_test.cpp @@ -178,23 +178,6 @@ static PermissionUsedTypeInfo MakeInfo(AccessTokenID tokenId, int32_t pid, const return info; } -/** - * @tc.name: OnAppStateChanged001 - * @tc.desc: RegisterPermActiveStatusCallback with invalid parameter. - * @tc.type: FUNC - * @tc.require: issueI5RWX8 - */ -HWTEST_F(PermissionRecordManagerTest, OnAppStateChanged001, TestSize.Level4) -{ - PrivacyAppStateObserver observer; - AppStateData appStateData; - appStateData.state = static_cast(ApplicationState::APP_STATE_FOREGROUND); - observer.OnAppStateChanged(appStateData); - appStateData.state = static_cast(ApplicationState::APP_STATE_BACKGROUND); - observer.OnAppStateChanged(appStateData); - ASSERT_EQ(static_cast(ApplicationState::APP_STATE_BACKGROUND), appStateData.state); -} - /* * @tc.name: AppStatusListener001 * @tc.desc: register and startusing permissions then use NotifyAppStateChange diff --git a/services/privacymanager/test/unittest/permission_record_manager_test.cpp b/services/privacymanager/test/unittest/permission_record_manager_test.cpp index e328aab92..710a8d95a 100644 --- a/services/privacymanager/test/unittest/permission_record_manager_test.cpp +++ b/services/privacymanager/test/unittest/permission_record_manager_test.cpp @@ -580,6 +580,7 @@ HWTEST_F(PermissionRecordManagerTest, StartUsingPermissionTest008, TestSize.Leve ASSERT_EQ(PERM_INACTIVE, callback->type_); } +#ifdef CAMERA_FLOAT_WINDOW_ENABLE /* * @tc.name: StartUsingPermissionTest009 * @tc.desc: Test multiple process start using permission @@ -629,6 +630,7 @@ HWTEST_F(PermissionRecordManagerTest, StartUsingPermissionTest009, TestSize.Leve usleep(500000); // 500000us = 0.5s ASSERT_FALSE(callbackPtr2->isShow_); } +#endif /* * @tc.name: StartUsingPermissionTest010 diff --git a/services/privacymanager/test/unittest/privacy_manager_service_test.cpp b/services/privacymanager/test/unittest/privacy_manager_service_test.cpp index 10599d3b1..e377c5368 100644 --- a/services/privacymanager/test/unittest/privacy_manager_service_test.cpp +++ b/services/privacymanager/test/unittest/privacy_manager_service_test.cpp @@ -211,24 +211,23 @@ HWTEST_F(PrivacyManagerServiceTest, IsAllowedUsingPermission001, TestSize.Level0 AccessTokenID tokenId = tokenIdEx.tokenIdExStruct.tokenID; ASSERT_NE(INVALID_TOKENID, tokenId); - bool isAllowed = false; - privacyManagerService_->IsAllowedUsingPermission(tokenId, MICROPHONE_PERMISSION_NAME, -1, isAllowed); - ASSERT_EQ(false, isAllowed); - privacyManagerService_->IsAllowedUsingPermission(tokenId, LOCATION_PERMISSION_NAME, -1, isAllowed); - ASSERT_EQ(false, isAllowed); - privacyManagerService_->IsAllowedUsingPermission(tokenId, CAMERA_PERMISSION_NAME, -1, isAllowed); - ASSERT_EQ(false, isAllowed); + ASSERT_EQ(false, PermissionRecordManager::GetInstance().IsAllowedUsingPermission( + tokenId, MICROPHONE_PERMISSION_NAME, -1)); + ASSERT_EQ(false, PermissionRecordManager::GetInstance().IsAllowedUsingPermission( + tokenId, LOCATION_PERMISSION_NAME, -1)); + ASSERT_EQ(false, PermissionRecordManager::GetInstance().IsAllowedUsingPermission( + tokenId, CAMERA_PERMISSION_NAME, -1)); #ifdef CAMERA_FLOAT_WINDOW_ENABLE // not pip PermissionRecordManager::GetInstance().NotifyCameraWindowChange(false, tokenId, false); - privacyManagerService_->IsAllowedUsingPermission(tokenId, CAMERA_PERMISSION_NAME, -1, isAllowed); - ASSERT_EQ(false, isAllowed); + ASSERT_EQ(false, PermissionRecordManager::GetInstance().IsAllowedUsingPermission( + tokenId, CAMERA_PERMISSION_NAME, -1)); PermissionRecordManager::GetInstance().NotifyCameraWindowChange(false, tokenId, false); // pip PermissionRecordManager::GetInstance().NotifyCameraWindowChange(true, tokenId, false); - privacyManagerService_->IsAllowedUsingPermission(tokenId, CAMERA_PERMISSION_NAME, -1, isAllowed); - ASSERT_EQ(false, isAllowed); + ASSERT_EQ(false, PermissionRecordManager::GetInstance().IsAllowedUsingPermission( + tokenId, CAMERA_PERMISSION_NAME, -1)); #endif } @@ -242,7 +241,7 @@ HWTEST_F(PrivacyManagerServiceTest, IsAllowedUsingPermission002, TestSize.Level0 { AccessTokenID tokenId = PrivacyTestCommon::GetNativeTokenIdFromProcess("privacy_service"); // invalid tokenId - bool isAllowed = false; + bool isAllowed = true; privacyManagerService_->IsAllowedUsingPermission(0, CAMERA_PERMISSION_NAME, -1, isAllowed); ASSERT_EQ(false, isAllowed); @@ -272,7 +271,7 @@ HWTEST_F(PrivacyManagerServiceTest, IsAllowedUsingPermission003, TestSize.Level0 AccessTokenID tokenId = tokenIdEx.tokenIdExStruct.tokenID; ASSERT_NE(INVALID_TOKENID, tokenId); - bool isAllowed = false; + bool isAllowed = true; privacyManagerService_->IsAllowedUsingPermission(tokenId, CAMERA_PERMISSION_NAME, -1, isAllowed); ASSERT_EQ(false, isAllowed); } @@ -1038,7 +1037,7 @@ HWTEST_F(PrivacyManagerServiceTest, IsAllowedUsingPermissionInner001, TestSize.L AccessTokenID tokenID = 123; // 123 is invalid tokenID std::string permissionName = "ohos.permission.test"; // is invalid permission int32_t pid = 11; - bool isAllowed = false; + bool isAllowed = true; // callingTokenID is native token hdcd with need permission, but tokenID is invalid int32_t result = privacyManagerService_->IsAllowedUsingPermission(tokenID, permissionName, pid, isAllowed); -- Gitee