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 2aef3adb5e0428cbff9683baeea8e92450801eec..ecafa566719390d7dda6c59d0e6c310aa1bb5627 100644 --- a/interfaces/innerkits/privacy/test/unittest/src/privacy_kit_test.cpp +++ b/interfaces/innerkits/privacy/test/unittest/src/privacy_kit_test.cpp @@ -1529,8 +1529,7 @@ HWTEST_F(PrivacyKitTest, IsAllowedUsingPermission005, TestSize.Level0) */ HWTEST_F(PrivacyKitTest, IsAllowedUsingPermission006, TestSize.Level0) { - std::string permissionName = "ohos.permission.MICROPHONE"; - ASSERT_EQ(false, PrivacyKit::IsAllowedUsingPermission(g_tokenIdE, permissionName)); + ASSERT_EQ(false, PrivacyKit::IsAllowedUsingPermission(g_tokenIdE, "ohos.permission.MICROPHONE")); HapInfoParams info = { .userID = 1, @@ -1557,7 +1556,7 @@ HWTEST_F(PrivacyKitTest, IsAllowedUsingPermission006, TestSize.Level0) AccessTokenIDEx tokenIdEx = PrivacyTestCommon::AllocTestHapToken(info, policy); AccessTokenID tokenId = tokenIdEx.tokenIdExStruct.tokenID; ASSERT_NE(0, tokenId); // hap MICROPHONE_BACKGROUND permission - ASSERT_EQ(true, PrivacyKit::IsAllowedUsingPermission(tokenId, permissionName)); // background hap + ASSERT_EQ(true, PrivacyKit::IsAllowedUsingPermission(tokenId, "ohos.permission.MICROPHONE")); // background hap info.isSystemApp = true; info.bundleName = "ohos.privacy_test.microphone.sys_app"; @@ -1575,13 +1574,11 @@ HWTEST_F(PrivacyKitTest, IsAllowedUsingPermission006, TestSize.Level0) ASSERT_EQ(0, AddPermissionToKernel(sysApptokenId, {opCode1, opCode2}, {1, 1})); EXPECT_EQ(0, SetSelfTokenID(tokenIdEx.tokenIDEx)); - // callkit set hap to foreground with MICROPHONE_BACKGROUND - EXPECT_EQ(0, PrivacyKit::SetHapWithFGReminder(tokenId, true)); - EXPECT_EQ(true, PrivacyKit::IsAllowedUsingPermission(tokenId, permissionName)); + EXPECT_EQ(0, PrivacyKit::SetHapWithFGReminder(tokenId, true)); // tokenId with MICROPHONE_BACKGROUND + EXPECT_EQ(true, PrivacyKit::IsAllowedUsingPermission(tokenId, "ohos.permission.MICROPHONE")); - // callkit set g_tokenIdE to foreground without MICROPHONE_BACKGROUND - EXPECT_EQ(0, PrivacyKit::SetHapWithFGReminder(g_tokenIdE, true)); - EXPECT_EQ(true, PrivacyKit::IsAllowedUsingPermission(g_tokenIdE, permissionName)); + EXPECT_EQ(0, PrivacyKit::SetHapWithFGReminder(g_tokenIdE, true)); // g_tokenIdE without MICROPHONE_BACKGROUND + EXPECT_EQ(true, PrivacyKit::IsAllowedUsingPermission(g_tokenIdE, "ohos.permission.MICROPHONE")); EXPECT_EQ(0, PrivacyKit::SetHapWithFGReminder(tokenId, false)); EXPECT_EQ(0, PrivacyKit::SetHapWithFGReminder(g_tokenIdE, false)); diff --git a/services/accesstokenmanager/test/unittest/accesstoken_manager_service_test.cpp b/services/accesstokenmanager/test/unittest/accesstoken_manager_service_test.cpp index 9591979c8353abf1848d4c824da43916b1f1645f..4227b3b309a91e6990815222931d19e2d6e66c4c 100644 --- a/services/accesstokenmanager/test/unittest/accesstoken_manager_service_test.cpp +++ b/services/accesstokenmanager/test/unittest/accesstoken_manager_service_test.cpp @@ -301,7 +301,7 @@ HWTEST_F(AccessTokenManagerServiceTest, UpdateHapTokenTest001, TestSize.Level0) ASSERT_EQ(1, results2.size()); ASSERT_EQ(static_cast(tokenId), results2[0].GetInt(TokenFiledConst::FIELD_TOKEN_ID)); // undefine permission change from INVALIDA to INVALIDB - ASSERT_EQ(g_state3.permissionName, results2[0].GetString(TokenFiledConst::FIELD_PERMISSION_NAME)); + ASSERT_EQ(g_state3.permissionName, results2[0].GetString(TokenFiledConst::FIELD_PERMISSION_NAME)); ASSERT_EQ(0, atManagerService_->DeleteToken(tokenId)); } diff --git a/services/common/app_manager/src/app_status_change_callback.cpp b/services/common/app_manager/src/app_status_change_callback.cpp index a87ced615882fd0cb4d50dfd6214c469f865c627..ef48082eba906cdec7d0f12042883aa79ba97d13 100644 --- a/services/common/app_manager/src/app_status_change_callback.cpp +++ b/services/common/app_manager/src/app_status_change_callback.cpp @@ -39,26 +39,21 @@ int32_t ApplicationStateObserverStub::OnRemoteRequest( return ERROR_IPC_REQUEST_FAIL; } switch (static_cast(code)) { - case IApplicationStateObserver::Message::TRANSACT_ON_PROCESS_STATE_CHANGED: { + case IApplicationStateObserver::Message::TRANSACT_ON_PROCESS_STATE_CHANGED: HandleOnProcessStateChanged(data, reply); return NO_ERROR; - } - case IApplicationStateObserver::Message::TRANSACT_ON_PROCESS_DIED: { + case IApplicationStateObserver::Message::TRANSACT_ON_PROCESS_DIED: HandleOnProcessDied(data, reply); return NO_ERROR; - } - case IApplicationStateObserver::Message::TRANSACT_ON_APP_STATE_CHANGED: { + case IApplicationStateObserver::Message::TRANSACT_ON_APP_STATE_CHANGED: HandleOnAppStateChanged(data, reply); return NO_ERROR; - } - case IApplicationStateObserver::Message::TRANSACT_ON_APP_STOPPED: { + case IApplicationStateObserver::Message::TRANSACT_ON_APP_STOPPED: HandleOnAppStopped(data, reply); return NO_ERROR; - } - case IApplicationStateObserver::Message::TRANSACT_ON_APP_CACHE_STATE_CHANGED: { + case IApplicationStateObserver::Message::TRANSACT_ON_APP_CACHE_STATE_CHANGED: HandleOnAppCacheStateChanged(data, reply); return NO_ERROR; - } case IApplicationStateObserver::Message::TRANSACT_ON_FOREGROUND_APPLICATION_CHANGED: case IApplicationStateObserver::Message::TRANSACT_ON_ABILITY_STATE_CHANGED: case IApplicationStateObserver::Message::TRANSACT_ON_EXTENSION_STATE_CHANGED: @@ -71,13 +66,10 @@ int32_t ApplicationStateObserverStub::OnRemoteRequest( case IApplicationStateObserver::Message::TRANSACT_ON_WINDOW_SHOW: case IApplicationStateObserver::Message::TRANSACT_ON_WINDOW_HIDDEN: case IApplicationStateObserver::Message::TRANSACT_ON_PROCESS_BINDINGRELATION_CHANGED: - { return NO_ERROR; - } - default: { + default: LOGD(ATM_DOMAIN, ATM_TAG, "Default case, need check AudioListenerStub"); return IPCObjectStub::OnRemoteRequest(code, data, reply, option); - } } return NO_ERROR; } diff --git a/services/common/dfx/test/unittest/dfx_test.cpp b/services/common/dfx/test/unittest/dfx_test.cpp index 856fd8b550fc5fba9a8c60bf00103fe59008c3a4..7cd2345fdf4d5e863d9c765c10c4d7934fd19c5b 100644 --- a/services/common/dfx/test/unittest/dfx_test.cpp +++ b/services/common/dfx/test/unittest/dfx_test.cpp @@ -16,7 +16,7 @@ #include #include "data_usage_dfx.h" #include -#include +#include using namespace testing::ext; diff --git a/test/fuzztest/normalize_service/accesstoken/gethaptokenidservice_fuzzer/corpus/init b/test/fuzztest/normalize_service/accesstoken/gethaptokenidservice_fuzzer/corpus/init index 26cdf7c64f9ab77b47b3703faa9fc59c0e66a5e2..e2c475d1565fbbddbbd638f3dad0e4dfc1b0a1d2 100644 --- a/test/fuzztest/normalize_service/accesstoken/gethaptokenidservice_fuzzer/corpus/init +++ b/test/fuzztest/normalize_service/accesstoken/gethaptokenidservice_fuzzer/corpus/init @@ -1 +1,14 @@ +# Copyright (c) 2024 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. + 0x6f0x680x6f0x730x2e0x670x6c0x6f0x620x610x6c0x2e0x730x790x730x740x650x6d0x720x650x735c0000000000 \ No newline at end of file diff --git a/test/fuzztest/normalize_service/accesstoken/gethaptokeninfoservice_fuzzer/corpus/init b/test/fuzztest/normalize_service/accesstoken/gethaptokeninfoservice_fuzzer/corpus/init index 342d76d4a087023d6e9c98d840ccfaec5e4c0491..2fe6675dccf44dd7f14e4434be3aa3f05d724010 100644 --- a/test/fuzztest/normalize_service/accesstoken/gethaptokeninfoservice_fuzzer/corpus/init +++ b/test/fuzztest/normalize_service/accesstoken/gethaptokeninfoservice_fuzzer/corpus/init @@ -1 +1,14 @@ +# Copyright (c) 2024 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. + 15460020 \ No newline at end of file diff --git a/test/fuzztest/normalize_service/accesstoken/getnativetokenidservice_fuzzer/getnativetokenidservice_fuzzer.cpp b/test/fuzztest/normalize_service/accesstoken/getnativetokenidservice_fuzzer/getnativetokenidservice_fuzzer.cpp index c171f5b5ba75ded63b1ac6e3732dcb084b8788dd..b1445ef0542770c9f8e4687b60ae4af3fc5c0619 100644 --- a/test/fuzztest/normalize_service/accesstoken/getnativetokenidservice_fuzzer/getnativetokenidservice_fuzzer.cpp +++ b/test/fuzztest/normalize_service/accesstoken/getnativetokenidservice_fuzzer/getnativetokenidservice_fuzzer.cpp @@ -31,7 +31,7 @@ using namespace OHOS; using namespace OHOS::Security::AccessToken; const int CONSTANTS_NUMBER_TEN = 10; static const int32_t ROOT_UID = 0; -static bool REAL_DATA_FLAG = true; +static bool g_realDataFlag = true; namespace OHOS { bool GetNativeTokenIdServiceFuzzTest(const uint8_t* data, size_t size) @@ -41,7 +41,7 @@ namespace OHOS { } AccessTokenFuzzData fuzzData(data, size); std::string testName(fuzzData.GenerateStochasticString()); - if (REAL_DATA_FLAG) { + if (g_realDataFlag) { testName = "accesstoken_service"; } @@ -60,9 +60,9 @@ namespace OHOS { if (enable) { setuid(CONSTANTS_NUMBER_TEN); } - if (REAL_DATA_FLAG) { + if (g_realDataFlag) { setuid(ROOT_UID); - REAL_DATA_FLAG = false; + g_realDataFlag = false; } DelayedSingleton::GetInstance()->OnRemoteRequest(code, datas, reply, option); setuid(ROOT_UID); diff --git a/test/fuzztest/normalize_service/accesstoken/getnativetokeninfoservice_fuzzer/getnativetokeninfoservice_fuzzer.cpp b/test/fuzztest/normalize_service/accesstoken/getnativetokeninfoservice_fuzzer/getnativetokeninfoservice_fuzzer.cpp index fe3b247bf0a540d737ff7f0a0f7feb3dda8b1e06..386fc63877cc3becb49943c398469503fb8c7e21 100644 --- a/test/fuzztest/normalize_service/accesstoken/getnativetokeninfoservice_fuzzer/getnativetokeninfoservice_fuzzer.cpp +++ b/test/fuzztest/normalize_service/accesstoken/getnativetokeninfoservice_fuzzer/getnativetokeninfoservice_fuzzer.cpp @@ -30,7 +30,7 @@ using namespace std; using namespace OHOS::Security::AccessToken; const int CONSTANTS_NUMBER_TEN = 10; static const int32_t ROOT_UID = 0; -static bool REAL_DATA_FLAG = true; +static bool g_realDataFlag = true; namespace OHOS { bool GetNativeTokenInfoServiceFuzzTest(const uint8_t* data, size_t size) @@ -40,7 +40,7 @@ namespace OHOS { } AccessTokenFuzzData fuzzData(data, size); AccessTokenID tokenId = fuzzData.GetData(); - if (REAL_DATA_FLAG) { + if (g_realDataFlag) { tokenId = AccessTokenKit::GetNativeTokenId("accesstoken_service"); } MessageParcel inData; @@ -58,9 +58,9 @@ namespace OHOS { if (enable) { setuid(CONSTANTS_NUMBER_TEN); } - if (REAL_DATA_FLAG) { + if (g_realDataFlag) { setuid(ROOT_UID); - REAL_DATA_FLAG = false; + g_realDataFlag = false; } DelayedSingleton::GetInstance()->OnRemoteRequest(code, inData, reply, option); setuid(ROOT_UID);