diff --git a/interfaces/innerkits/privacy/BUILD.gn b/interfaces/innerkits/privacy/BUILD.gn index c137d8098ca85b8c91f7ed2a3156e82efcf4c431..8b1ca6245a43b0c6d9cadcd05a9a579ea74479ea 100644 --- a/interfaces/innerkits/privacy/BUILD.gn +++ b/interfaces/innerkits/privacy/BUILD.gn @@ -38,6 +38,7 @@ if (is_standard_system) { ] sources = [ + "src/on_permission_used_record_callback_stub.cpp", "src/perm_active_status_change_callback.cpp", "src/perm_active_status_change_callback_stub.cpp", "src/perm_active_status_customized_cbk.cpp", diff --git a/services/privacymanager/include/record/on_permission_used_record_callback_stub.h b/interfaces/innerkits/privacy/include/on_permission_used_record_callback_stub.h similarity index 100% rename from services/privacymanager/include/record/on_permission_used_record_callback_stub.h rename to interfaces/innerkits/privacy/include/on_permission_used_record_callback_stub.h diff --git a/services/privacymanager/src/record/on_permission_used_record_callback_stub.cpp b/interfaces/innerkits/privacy/src/on_permission_used_record_callback_stub.cpp similarity index 93% rename from services/privacymanager/src/record/on_permission_used_record_callback_stub.cpp rename to interfaces/innerkits/privacy/src/on_permission_used_record_callback_stub.cpp index d4b8215251c2bf436419ea0a9f26a5fa694eb07f..6d3c6f73b8474fd2409b129ae9dc481ab33fd3be 100644 --- a/services/privacymanager/src/record/on_permission_used_record_callback_stub.cpp +++ b/interfaces/innerkits/privacy/src/on_permission_used_record_callback_stub.cpp @@ -16,9 +16,7 @@ #include "on_permission_used_record_callback_stub.h" #include "accesstoken_log.h" -#include "constant.h" #include "permission_used_result_parcel.h" -#include "constant.h" #include "string_ex.h" namespace OHOS { @@ -28,6 +26,7 @@ namespace { static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, SECURITY_DOMAIN_PRIVACY, "OnPermissionUsedRecordCallbackStub" }; +static constexpr int32_t RET_NOK = -1; } int32_t OnPermissionUsedRecordCallbackStub::OnRemoteRequest( @@ -37,7 +36,7 @@ int32_t OnPermissionUsedRecordCallbackStub::OnRemoteRequest( std::u16string descriptor = data.ReadInterfaceToken(); if (descriptor != OnPermissionUsedRecordCallback::GetDescriptor()) { ACCESSTOKEN_LOG_ERROR(LABEL, "get unexpect descriptor: %{public}s", Str16ToStr8(descriptor).c_str()); - return Constant::FAILURE; + return RET_NOK; } int32_t msgCode = static_cast(code); @@ -46,12 +45,12 @@ int32_t OnPermissionUsedRecordCallbackStub::OnRemoteRequest( PermissionUsedResult result; if (errCode != NO_ERROR) { OnQueried(errCode, result); - return Constant::FAILURE; + return RET_NOK; } sptr resultSptr = data.ReadParcelable(); if (resultSptr == nullptr) { ACCESSTOKEN_LOG_ERROR(LABEL, "ReadParcelable fail"); - return Constant::FAILURE; + return RET_NOK; } ACCESSTOKEN_LOG_INFO(LABEL, "errCode: %{public}d", errCode); OnQueried(errCode, resultSptr->result); diff --git a/interfaces/innerkits/privacy/test/BUILD.gn b/interfaces/innerkits/privacy/test/BUILD.gn index 7e63b81e2ebff238c02c43234234683951226d9c..58ff5e9fd3a589df6df03b0d078248fe73a4353d 100644 --- a/interfaces/innerkits/privacy/test/BUILD.gn +++ b/interfaces/innerkits/privacy/test/BUILD.gn @@ -25,7 +25,6 @@ ohos_unittest("libprivacy_sdk_test") { "//base/security/access_token/interfaces/innerkits/nativetoken/include", "//base/security/access_token/interfaces/innerkits/privacy/include", "//base/security/access_token/interfaces/innerkits/token_setproc/include", - "//base/security/access_token/services/privacymanager/include/record", ] sources = [ "unittest/src/privacy_kit_test.cpp" ] @@ -39,7 +38,6 @@ ohos_unittest("libprivacy_sdk_test") { "//base/security/access_token/interfaces/innerkits/nativetoken:libnativetoken", "//base/security/access_token/interfaces/innerkits/privacy:libprivacy_sdk", "//base/security/access_token/interfaces/innerkits/token_setproc:libtoken_setproc", - "//base/security/access_token/services/privacymanager:privacy_manager_service", ] external_deps = [ "c_utils:utils", diff --git a/interfaces/innerkits/token_callback/BUILD.gn b/interfaces/innerkits/token_callback/BUILD.gn index 9c5f025cd67422f31551069dbb34d96c588d800f..55454820915ae2d1c4f88a79e8378b72764b7c02 100644 --- a/interfaces/innerkits/token_callback/BUILD.gn +++ b/interfaces/innerkits/token_callback/BUILD.gn @@ -37,10 +37,7 @@ if (is_standard_system) { "//base/security/access_token/frameworks/common/include", ] - sources = [ - "src/token_callback_proxy.cpp", - "src/token_callback_stub.cpp", - ] + sources = [ "src/token_callback_stub.cpp" ] deps = [] diff --git a/interfaces/innerkits/token_callback/include/token_callback_proxy.h b/interfaces/innerkits/token_callback/include/token_callback_proxy.h deleted file mode 100644 index bba2db4e2779ed35e82050acc040f6b664e00f4e..0000000000000000000000000000000000000000 --- a/interfaces/innerkits/token_callback/include/token_callback_proxy.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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 - * - * 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 PERMISSION_STATE_CHANGE_CALLBACK_PROXY_H -#define PERMISSION_STATE_CHANGE_CALLBACK_PROXY_H - -#include "i_token_callback.h" - -#include "iremote_proxy.h" -#include "nocopyable.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -class TokenCallbackProxy : public IRemoteProxy { -public: - explicit TokenCallbackProxy(const sptr& impl); - ~TokenCallbackProxy() override; - - virtual void GrantResultsCallback( - const std::vector &permissions, const std::vector &grantResults) override; - -private: - static inline BrokerDelegator delegator_; -}; -} // namespace AccessToken -} // namespace Security -} // namespace OHOS -#endif // PERMISSION_STATE_CHANGE_CALLBACK_PROXY_H diff --git a/interfaces/innerkits/token_callback/src/token_callback_proxy.cpp b/interfaces/innerkits/token_callback/src/token_callback_proxy.cpp deleted file mode 100644 index b7fc7b759a45a8f0f972d7bc8ef950497b2492dc..0000000000000000000000000000000000000000 --- a/interfaces/innerkits/token_callback/src/token_callback_proxy.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/* - * 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 - * - * 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 "token_callback_proxy.h" - -#include "accesstoken_log.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -namespace { -static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { - LOG_CORE, SECURITY_DOMAIN_ACCESSTOKEN, "TokenCallbackProxy" -}; -static const int32_t LIST_SIZE_MAX = 1024; -} - -TokenCallbackProxy::TokenCallbackProxy(const sptr& impl) - : IRemoteProxy(impl) { -} - -TokenCallbackProxy::~TokenCallbackProxy() -{} - -void TokenCallbackProxy::GrantResultsCallback( - const std::vector &permissions, const std::vector &grantResults) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(ITokenCallback::GetDescriptor())) { - ACCESSTOKEN_LOG_ERROR(LABEL, "get unexpect descriptor"); - return; - } - - uint32_t listSize = permissions.size(); - uint32_t resultSize = grantResults.size(); - if ((listSize > LIST_SIZE_MAX) || (resultSize != listSize)) { - ACCESSTOKEN_LOG_ERROR(LABEL, "listSize %{public}d or resultSize %{public}d is invalid", listSize, resultSize); - return; - } - if (!data.WriteUint32(listSize)) { - ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to write listSize"); - return; - } - for (uint32_t i = 0; i < listSize; i++) { - if (!data.WriteString(permissions[i])) { - ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to write permList[%{public}d], %{public}s", i, permissions[i].c_str()); - return; - } - } - - if (!data.WriteUint32(resultSize)) { - ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to write resultSize"); - return; - } - for (uint32_t i = 0; i < resultSize; i++) { - if (!data.WriteInt32(grantResults[i])) { - ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to write permList[%{public}d], %{public}d", i, grantResults[i]); - return; - } - } - - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - sptr remote = Remote(); - if (remote == nullptr) { - ACCESSTOKEN_LOG_ERROR(LABEL, "remote service null."); - return; - } - int32_t requestResult = remote->SendRequest( - static_cast(ITokenCallback::GRANT_RESULT_CALLBACK), data, reply, option); - if (requestResult != NO_ERROR) { - ACCESSTOKEN_LOG_ERROR(LABEL, "send request fail, result: %{public}d", requestResult); - return; - } - - ACCESSTOKEN_LOG_DEBUG(LABEL, "SendRequest success"); -} -} // namespace AccessToken -} // namespace Security -} // namespace OHOS diff --git a/services/privacymanager/BUILD.gn b/services/privacymanager/BUILD.gn index c531dd03cfe0aff667df3f43f9dd34b94c87046c..afbee07e8b55713303734ef2e5a0481da9dfd1bd 100644 --- a/services/privacymanager/BUILD.gn +++ b/services/privacymanager/BUILD.gn @@ -50,7 +50,6 @@ if (is_standard_system) { "src/database/data_translator.cpp", "src/database/permission_used_record_db.cpp", "src/record/on_permission_used_record_callback_proxy.cpp", - "src/record/on_permission_used_record_callback_stub.cpp", "src/record/permission_record.cpp", "src/record/permission_record_manager.cpp", "src/record/permission_record_repository.cpp",