From cbb508b7450fcb5e94236f89a3e856c9b21b47ab Mon Sep 17 00:00:00 2001 From: lsq Date: Sat, 23 Jul 2022 08:50:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9D=83=E9=99=90=E4=BD=BF=E7=94=A8=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E5=8F=98=E5=8C=96=E5=9B=9E=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lsq --- .../include/i_perm_active_status_callback.h | 42 +++++++++++ .../privacy/include/i_privacy_manager.h | 8 ++- .../include/perm_active_response_parcel.h | 40 +++++++++++ .../src/perm_active_response_parcel.cpp | 45 ++++++++++++ .../include/active_change_response_info.h | 47 ++++++++++++ .../perm_active_status_change_callback_stub.h | 38 ++++++++++ .../innerkits/privacy/include/privacy_kit.h | 2 + ...erm_active_status_change_callback_stub.cpp | 60 ++++++++++++++++ ...perm_active_status_change_customized_cbk.h | 45 ++++++++++++ .../innerkits/privacy/src/privacy_kit.cpp | 12 ++++ .../privacy/src/privacy_manager_client.cpp | 10 +++ .../privacy/src/privacy_manager_client.h | 3 + .../privacy/src/privacy_manager_proxy.cpp | 11 +++ .../privacy/src/privacy_manager_proxy.h | 3 +- ...perm_active_status_change_callback_proxy.h | 40 +++++++++++ .../include/service/privacy_manager_service.h | 3 + .../include/service/privacy_manager_stub.h | 4 +- ...rm_active_status_change_callback_proxy.cpp | 67 ++++++++++++++++++ .../src/service/privacy_manager_service.cpp | 9 +++ .../src/service/privacy_manager_stub.cpp | 17 +++++ ...oft_bus_device_connection_listener.cpp.swp | Bin 0 -> 16384 bytes 21 files changed, 502 insertions(+), 4 deletions(-) create mode 100644 frameworks/privacy/include/i_perm_active_status_callback.h create mode 100644 frameworks/privacy/include/perm_active_response_parcel.h create mode 100644 frameworks/privacy/src/perm_active_response_parcel.cpp create mode 100644 interfaces/innerkits/privacy/include/active_change_response_info.h create mode 100644 interfaces/innerkits/privacy/include/perm_active_status_change_callback_stub.h create mode 100644 interfaces/innerkits/privacy/src/perm_active_status_change_callback_stub.cpp create mode 100644 interfaces/innerkits/privacy/src/perm_active_status_change_customized_cbk.h create mode 100644 services/privacymanager/include/active/perm_active_status_change_callback_proxy.h create mode 100644 services/privacymanager/src/active/perm_active_status_change_callback_proxy.cpp create mode 100644 services/tokensyncmanager/src/remote/.soft_bus_device_connection_listener.cpp.swp diff --git a/frameworks/privacy/include/i_perm_active_status_callback.h b/frameworks/privacy/include/i_perm_active_status_callback.h new file mode 100644 index 000000000..5a49358f6 --- /dev/null +++ b/frameworks/privacy/include/i_perm_active_status_callback.h @@ -0,0 +1,42 @@ +/* + * 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 I_PERMI_ACTIVE_STATUS_CALLBACK_H +#define I_PERMI_ACTIVE_STATUS_CALLBACK_H + +#include + +#include "access_token.h" +#include "active_change_response_info.h" +#include "iremote_broker.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +class IPermActiveStatusChangeCbk : public IRemoteBroker { +public: + DECLARE_INTERFACE_DESCRIPTOR(u"ohos.security.accesstoken.IPermActiveStatusChangeCbk"); + + virtual void PermActiveStatusChangeCallback(ActiveChangeResponse& result) = 0; + + enum { + PERM_ACTIVE_STATUS_CHANGE = 0, + }; +}; +} // namespace AccessToken +} // namespace Security +} // namespace OHOS + +#endif // PERMI_ACTIVE_STATUS_CALLBACK_H \ No newline at end of file diff --git a/frameworks/privacy/include/i_privacy_manager.h b/frameworks/privacy/include/i_privacy_manager.h index 8ee5f3fba..137f58864 100644 --- a/frameworks/privacy/include/i_privacy_manager.h +++ b/frameworks/privacy/include/i_privacy_manager.h @@ -45,7 +45,9 @@ public: virtual int32_t GetPermissionUsedRecords( const PermissionUsedRequestParcel& request, const sptr& callback) = 0; virtual std::string DumpRecordInfo(const std::string& bundleName, const std::string& permissionName) = 0; - + virtual int32_t RegisterPermActiveStatusCallback( + std::vector& permList, const sptr& callback) = 0; + virtual int32_t UnRegisterPermActiveStatusCallback(const sptr& callback) = 0; enum class InterfaceCode { ADD_PERMISSION_USED_RECORD = 0xf001, START_USING_PERMISSION = 0xf002, @@ -53,7 +55,9 @@ public: DELETE_PERMISSION_USED_RECORDS = 0xf004, GET_PERMISSION_USED_RECORDS = 0xf005, GET_PERMISSION_USED_RECORDS_ASYNC = 0xf006, - DUMP_RECORD_INFO = 0xf007 + DUMP_RECORD_INFO = 0xf007, + REGISTER_PERM_ACTIVE_STATUS_CHANGE_CALLBACK = 0xf008, + UNREGISTER_PERM_ACTIVE_STATUS_CHANGE_CALLBACK = 0xf009, }; }; } // namespace AccessToken diff --git a/frameworks/privacy/include/perm_active_response_parcel.h b/frameworks/privacy/include/perm_active_response_parcel.h new file mode 100644 index 000000000..b870dd23d --- /dev/null +++ b/frameworks/privacy/include/perm_active_response_parcel.h @@ -0,0 +1,40 @@ +/* + * 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_USED_RECORD_PRACEL_H +#define PERMISSION_USED_RECORD_PRACEL_H + +#include "parcel.h" +#include "active_change_response_info.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +struct ActiveChangeResponseParcel final : public Parcelable { + ActiveChangeResponseParcel() = default; + + ~ActiveChangeResponseParcel() override = default; + + bool Marshalling(Parcel& out) const override; + + static ActiveChangeResponseParcel* Unmarshalling(Parcel& in); + + ActiveChangeResponse changeResponse; +}; +} // namespace AccessToken +} // namespace Security +} // namespace OHOS + +#endif // PERMISSION_USED_RECORD_PRACEL_H diff --git a/frameworks/privacy/src/perm_active_response_parcel.cpp b/frameworks/privacy/src/perm_active_response_parcel.cpp new file mode 100644 index 000000000..eec60b426 --- /dev/null +++ b/frameworks/privacy/src/perm_active_response_parcel.cpp @@ -0,0 +1,45 @@ +/* + * 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 "perm_active_response_parcel.h" +#include "parcel_utils.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +bool ActiveChangeResponseParcel::Marshalling(Parcel& out) const +{ + RETURN_IF_FALSE(out.WriteUint32(this->changeResponse.tokenID)); + RETURN_IF_FALSE(out.WriteString(this->changeResponse.permissionName)); + RETURN_IF_FALSE(out.WriteString(this->changeResponse.deviceId)); + RETURN_IF_FALSE(out.WriteInt(this->changeResponse.type)); + return true; +} + +ActiveChangeResponseParcel* ActiveChangeResponseParcel::Unmarshalling(Parcel& in) +{ + auto* activeChangeResponseParcel = new (std::nothrow) ActiveChangeResponseParcel(); + if (activeChangeResponseParcel == nullptr) { + return nullptr; + } + + RELEASE_IF_FALSE(in.ReadInt32(activeChangeResponseParcel->changeResponse.status), activeChangeResponseParcel); + RELEASE_IF_FALSE(in.ReadInt64(activeChangeResponseParcel->changeResponse.timestamp), activeChangeResponseParcel); + RELEASE_IF_FALSE(in.ReadInt64(activeChangeResponseParcel->changeResponse.accessDuration), activeChangeResponseParcel); + return activeChangeResponseParcel; +} +} // namespace AccessToken +} // namespace Security +} // namespace OHOS diff --git a/interfaces/innerkits/privacy/include/active_change_response_info.h b/interfaces/innerkits/privacy/include/active_change_response_info.h new file mode 100644 index 000000000..71f734462 --- /dev/null +++ b/interfaces/innerkits/privacy/include/active_change_response_info.h @@ -0,0 +1,47 @@ +/* + * 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 ACTIVE_CHANGE_RESPONSE_INFO_H +#define ACTIVE_CHANGE_RESPONSE_INFO_H + +#include +#include + +#include "access_token.h" + +namespace OHOS { +namespace Security { +namespace AccessToken{ +#define TOKENID_LIST_SIZE_MAX 1024 +#define PERM_LIST_SIZE_MAX 1024 + +enum ActiveChangeType { + PERM_INACTIVE = 0, + PERM_ACTIVE_IN_FOREGROUND = 1, + PERM_ACTIVE_IN_BACKGRONGD = 2, +}; + +struct ActiveChangeResponse { + AccessTokenID tokenID; + std::string permissionName; + std::string deviceId; + ActiveChangeType type; +}; + +} // namespace AccessToken +} // namespace Security +} // namespace OHOS + +#endif // ACTIVE_CHANGE_RESPONSE_INFO_H \ No newline at end of file diff --git a/interfaces/innerkits/privacy/include/perm_active_status_change_callback_stub.h b/interfaces/innerkits/privacy/include/perm_active_status_change_callback_stub.h new file mode 100644 index 000000000..71838bd3a --- /dev/null +++ b/interfaces/innerkits/privacy/include/perm_active_status_change_callback_stub.h @@ -0,0 +1,38 @@ +/* + * 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 PERM_ACTIVE_STATUS_CHANGE_CALLBACK_STUB_H +#define PERM_ACTIVE_STATUS_CHANGE_CALLBACK_STUB_H + + +#include "i_perm_active_status_callback.h" + +#include "iremote_stub.h" +#include "nocopyable.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +class PermActiveStatusChangeCallbackStub : public IRemoteStub { +public: + PermActiveStatusChangeCallbackStub() = default; + virtual ~PermActiveStatusChangeCallbackStub() = default; + + int32_t OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) override; +}; +} // namespace AccessToken +} // namespace Security +} // namespace OHOS +#endif // PERM_ACTIVE_STATUS_CHANGE_CALLBACK_STUB_H diff --git a/interfaces/innerkits/privacy/include/privacy_kit.h b/interfaces/innerkits/privacy/include/privacy_kit.h index b3fb9a4d1..86ccf9d61 100644 --- a/interfaces/innerkits/privacy/include/privacy_kit.h +++ b/interfaces/innerkits/privacy/include/privacy_kit.h @@ -37,6 +37,8 @@ public: static int32_t GetPermissionUsedRecords( const PermissionUsedRequest& request, const sptr& callback); static std::string DumpRecordInfo(const std::string& bundleName, const std::string& permissionName); + int32_t RegisterPermActiveStatusCallback(const sptr& callback); + int32_t UnRegisterPermActiveStatusCallback(const sptr& callback); }; } // namespace AccessToken } // namespace Security diff --git a/interfaces/innerkits/privacy/src/perm_active_status_change_callback_stub.cpp b/interfaces/innerkits/privacy/src/perm_active_status_change_callback_stub.cpp new file mode 100644 index 000000000..8c540cb34 --- /dev/null +++ b/interfaces/innerkits/privacy/src/perm_active_status_change_callback_stub.cpp @@ -0,0 +1,60 @@ +/* + * 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 "perm_active_status_change_callback_stub.h" + +#include "accesstoken_log.h" +#include "constant.h" +#include "perm_active_response_parcel.h" +#include "constant.h" +#include "string_ex.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +namespace { +static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { + LOG_CORE, SECURITY_DOMAIN_PRIVACY, "PermActiveStatusChangeCallbackStub" +}; +} + +int32_t PermActiveStatusChangeCallbackStub::OnRemoteRequest( + uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) +{ + ACCESSTOKEN_LOG_DEBUG(LABEL, "Entry, code: 0x%{public}x", code); + std::u16string descriptor = data.ReadInterfaceToken(); + if (descriptor != IPermActiveStatusChangeCbk::GetDescriptor()) { + ACCESSTOKEN_LOG_ERROR(LABEL, "get unexpect descriptor: %{public}s", Str16ToStr8(descriptor).c_str()); + return RET_FAILED; + } + + int32_t msgCode = static_cast(code); + if (msgCode == IPermActiveStatusChangeCbk::PERM_ACTIVE_STATUS_CHANGE) { + sptr resultSptr = data.ReadParcelable(); + if (resultSptr == nullptr) { + ACCESSTOKEN_LOG_ERROR(LABEL, "ReadParcelable fail"); + return RET_FAILED; + } + + PermActiveStatusChangeCallback(resultSptr->changeResponse); + } else { + return IPCObjectStub::OnRemoteRequest(code, data, reply, option); + } + return RET_SUCCESS; +} + +} // namespace AccessToken +} // namespace Security +} // namespace OHOS diff --git a/interfaces/innerkits/privacy/src/perm_active_status_change_customized_cbk.h b/interfaces/innerkits/privacy/src/perm_active_status_change_customized_cbk.h new file mode 100644 index 000000000..5f3661098 --- /dev/null +++ b/interfaces/innerkits/privacy/src/perm_active_status_change_customized_cbk.h @@ -0,0 +1,45 @@ +/* + * 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 PERM_ACTIVE_STATUS_CHANGE_CUSTOMIZED_CBK_H +#define PERM_ACTIVE_STATUS_CHANGE_CUSTOMIZED_CBK_H + +#include +#include + +#include "access_token.h" +#include "active_change_response_info.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +class PermActiveStatusCustomizedCbk { +public: + PermActiveStatusCustomizedCbk(); + explicit PermActiveStatusCustomizedCbk(const std::vector& permList); + virtual ~PermActiveStatusCustomizedCbk(); + + virtual PermActiveStatusChangeCallback(ActiveChangeResponse& result) = 0; + + void GetPermList(const std::vector& permList) const; + +private: + std::vector permList_; +}; +} // namespace AccessToken +} // namespace Security +} // namespace OHOS + +#endif // PERM_ACTIVE_STATUS_CHANGE_CUSTOMIZED_CBK_H \ No newline at end of file diff --git a/interfaces/innerkits/privacy/src/privacy_kit.cpp b/interfaces/innerkits/privacy/src/privacy_kit.cpp index 0b9557bdd..893770860 100644 --- a/interfaces/innerkits/privacy/src/privacy_kit.cpp +++ b/interfaces/innerkits/privacy/src/privacy_kit.cpp @@ -78,6 +78,18 @@ std::string PrivacyKit::DumpRecordInfo(const std::string& bundleName, const std: bundleName.c_str(), permissionName.c_str()); return PrivacyManagerClient::GetInstance().DumpRecordInfo(bundleName, permissionName); } + +int32_t PrivacyKit::RegisterPermActiveStatusCallback(const sptr& callback) +{ + ACCESSTOKEN_LOG_DEBUG(LABEL, "Entry"); + return PrivacyManagerClient::GetInstance().RegisterPermActiveStatusCallback(callback); +} + +int32_t PrivacyKit::UnRegisterPermActiveStatusCallback(const sptr& callback) +{ + ACCESSTOKEN_LOG_DEBUG(LABEL, "Entry"); + return PrivacyManagerClient::GetInstance().UnRegisterPermActiveStatusCallback(callback); +} } // namespace AccessToken } // namespace Security } // namespace OHOS diff --git a/interfaces/innerkits/privacy/src/privacy_manager_client.cpp b/interfaces/innerkits/privacy/src/privacy_manager_client.cpp index 495f5b42a..6673ce385 100644 --- a/interfaces/innerkits/privacy/src/privacy_manager_client.cpp +++ b/interfaces/innerkits/privacy/src/privacy_manager_client.cpp @@ -142,6 +142,16 @@ std::string PrivacyManagerClient::DumpRecordInfo(const std::string& bundleName, return proxy->DumpRecordInfo(bundleName, permissionName); } +int32_t PrivacyManagerClient::RegisterPermActiveStatusCallback(const sptr& callback) +{ + return 0; +} + +int32_t PrivacyManagerClient::UnRegisterPermActiveStatusCallback(const sptr& callback) +{ + return 0; +} + void PrivacyManagerClient::InitProxy() { std::lock_guard lock(proxyMutex_); diff --git a/interfaces/innerkits/privacy/src/privacy_manager_client.h b/interfaces/innerkits/privacy/src/privacy_manager_client.h index c43bd9dd1..86bdfaf82 100644 --- a/interfaces/innerkits/privacy/src/privacy_manager_client.h +++ b/interfaces/innerkits/privacy/src/privacy_manager_client.h @@ -22,6 +22,7 @@ #include "i_privacy_manager.h" #include "privacy_death_recipient.h" +include "perm_active_status_change_customized_cbk.h" namespace OHOS { namespace Security { @@ -41,6 +42,8 @@ public: int32_t GetPermissionUsedRecords( const PermissionUsedRequest& request, const sptr& callback); std::string DumpRecordInfo(const std::string& bundleName, const std::string& permissionName); + int32_t RegisterPermActiveStatusCallback(const sptr& callback); + int32_t UnRegisterPermActiveStatusCallback(const sptr& callback); void OnRemoteDiedHandle(); private: diff --git a/interfaces/innerkits/privacy/src/privacy_manager_proxy.cpp b/interfaces/innerkits/privacy/src/privacy_manager_proxy.cpp index b8224d258..4bba218fd 100644 --- a/interfaces/innerkits/privacy/src/privacy_manager_proxy.cpp +++ b/interfaces/innerkits/privacy/src/privacy_manager_proxy.cpp @@ -211,6 +211,17 @@ std::string PrivacyManagerProxy::DumpRecordInfo(const std::string& bundleName, c return dumpInfo; } +int32_t PrivacyManagerProxy::RegisterPermActiveStatusCallback( + std::vector& permList, const sptr& callback) +{ + +} + +int32_t PrivacyManagerProxy::UnRegisterPermActiveStatusCallback(const sptr& callback) +{ + +} + bool PrivacyManagerProxy::SendRequest( IPrivacyManager::InterfaceCode code, MessageParcel& data, MessageParcel& reply) { diff --git a/interfaces/innerkits/privacy/src/privacy_manager_proxy.h b/interfaces/innerkits/privacy/src/privacy_manager_proxy.h index 1ed65c128..a84957aac 100644 --- a/interfaces/innerkits/privacy/src/privacy_manager_proxy.h +++ b/interfaces/innerkits/privacy/src/privacy_manager_proxy.h @@ -39,7 +39,8 @@ public: int32_t GetPermissionUsedRecords(const PermissionUsedRequestParcel& request, const sptr& callback) override; std::string DumpRecordInfo(const std::string& bundleName, const std::string& permissionName) override; - + int32_t RegisterPermActiveStatusCallback(std::vector& permList, const sptr& callback); + int32_t UnRegisterPermActiveStatusCallback(const sptr& callback); private: bool SendRequest(IPrivacyManager::InterfaceCode code, MessageParcel& data, MessageParcel& reply); static inline BrokerDelegator delegator_; diff --git a/services/privacymanager/include/active/perm_active_status_change_callback_proxy.h b/services/privacymanager/include/active/perm_active_status_change_callback_proxy.h new file mode 100644 index 000000000..3b193b2cb --- /dev/null +++ b/services/privacymanager/include/active/perm_active_status_change_callback_proxy.h @@ -0,0 +1,40 @@ +/* + * 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 PERM_ACTIVE_STATUS_CHANGE_CALLBACK_PROXY_H +#define PERM_ACTIVE_STATUS_CHANGE_CALLBACK_PROXY_H + + +#include "i_perm_active_status_callback.h" + +#include "iremote_proxy.h" +#include "nocopyable.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +class PermActiveStatusChangeCallbackProxy : public IRemoteProxy { +public: + explicit PermActiveStatusChangeCallbackProxy(const sptr& impl); + ~PermActiveStatusChangeCallbackProxy() override; + + virtual void PermActiveStatusChangeCallback(ActiveChangeResponse& result) override; +private: + static inline BrokerDelegator delegator_; +}; +} // namespace AccessToken +} // namespace Security +} // namespace OHOS +#endif // PERM_ACTIVE_STATUS_CHANGE_CALLBACK_PROXY_H diff --git a/services/privacymanager/include/service/privacy_manager_service.h b/services/privacymanager/include/service/privacy_manager_service.h index d2c89b6ce..116249c7f 100644 --- a/services/privacymanager/include/service/privacy_manager_service.h +++ b/services/privacymanager/include/service/privacy_manager_service.h @@ -46,6 +46,9 @@ public: int32_t GetPermissionUsedRecords( const PermissionUsedRequestParcel& request, const sptr& callback) override; std::string DumpRecordInfo(const std::string& bundleName, const std::string& permissionName) override; + int32_t RegisterPermActiveStatusCallback( + std::vector& permList, const sptr& callback) override; + int32_t UnRegisterPermActiveStatusCallback(const sptr& callback) override; private: bool Initialize() const; diff --git a/services/privacymanager/include/service/privacy_manager_stub.h b/services/privacymanager/include/service/privacy_manager_stub.h index 1a8ce60ba..dcce8b61d 100644 --- a/services/privacymanager/include/service/privacy_manager_stub.h +++ b/services/privacymanager/include/service/privacy_manager_stub.h @@ -39,7 +39,9 @@ private: void GetPermissionUsedRecordsInner(MessageParcel& data, MessageParcel& reply); void GetPermissionUsedRecordsAsyncInner(MessageParcel& data, MessageParcel& reply); void DumpRecordInfoInner(MessageParcel& data, MessageParcel& reply); - + int32_t RegisterPermActiveStatusCallbackInner( + std::vector& permList, const sptr& callback); + int32_t UnRegisterPermActiveStatusCallbackInner(const sptr& callback); bool IsAccessTokenCalling() const; static const int32_t ACCESSTOKEN_UID = 3020; }; diff --git a/services/privacymanager/src/active/perm_active_status_change_callback_proxy.cpp b/services/privacymanager/src/active/perm_active_status_change_callback_proxy.cpp new file mode 100644 index 000000000..153aa6279 --- /dev/null +++ b/services/privacymanager/src/active/perm_active_status_change_callback_proxy.cpp @@ -0,0 +1,67 @@ +/* + * 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 "perm_active_status_change_callback_proxy.h" + +#include "accesstoken_log.h" +#include "perm_active_response_parcel.h" + +namespace OHOS { +namespace Security { +namespace AccessToken { +namespace { +static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { + LOG_CORE, SECURITY_DOMAIN_PRIVACY, "PermActiveStatusChangeCallbackProxy" +}; +} + +PermActiveStatusChangeCallbackProxy::PermActiveStatusChangeCallbackProxy(const sptr& impl) + : IRemoteProxy(impl) { +} + +PermActiveStatusChangeCallbackProxy::~PermActiveStatusChangeCallbackProxy() +{} + +void PermActiveStatusChangeCallbackProxy::PermActiveStatusChangeCallback(ActiveChangeResponse& result) +{ + MessageParcel data; + data.WriteInterfaceToken(IPermActiveStatusChangeCbk::GetDescriptor()); + + ActiveChangeResponseParcel resultParcel; + resultParcel.result = result; + if (!data.WriteParcelable(&resultParcel)) { + ACCESSTOKEN_LOG_ERROR(LABEL, "Failed to WriteParcelable"); + 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(IPermActiveStatusChangeCbk::PERM_ACTIVE_STATUS_CHANGE), data, reply, option); + if (requestResult != NO_ERROR) { + ACCESSTOKEN_LOG_ERROR(LABEL, "send request fail, result: %{public}d", requestResult); + return; + } + + ACCESSTOKEN_LOG_INFO(LABEL, "SendRequest success"); +} +} // namespace AccessToken +} // namespace Security +} // namespace OHOS diff --git a/services/privacymanager/src/service/privacy_manager_service.cpp b/services/privacymanager/src/service/privacy_manager_service.cpp index 1f9cecd49..d0b2fc88f 100644 --- a/services/privacymanager/src/service/privacy_manager_service.cpp +++ b/services/privacymanager/src/service/privacy_manager_service.cpp @@ -125,6 +125,15 @@ std::string PrivacyManagerService::DumpRecordInfo(const std::string& bundleName, return PermissionRecordManager::GetInstance().DumpRecordInfo(bundleName, permissionName); } +int32_t RegisterPermActiveStatusCallback( + std::vector& permList, const sptr& callback) +{ + return 0; +} +int32_t UnRegisterPermActiveStatusCallback(const sptr& callback) +{ + return 0; +} bool PrivacyManagerService::Initialize() const { PermissionRecordManager::GetInstance().Init(); diff --git a/services/privacymanager/src/service/privacy_manager_stub.cpp b/services/privacymanager/src/service/privacy_manager_stub.cpp index bd1dd4fe7..2d4391889 100644 --- a/services/privacymanager/src/service/privacy_manager_stub.cpp +++ b/services/privacymanager/src/service/privacy_manager_stub.cpp @@ -60,6 +60,12 @@ int32_t PrivacyManagerStub::OnRemoteRequest( case static_cast(IPrivacyManager::InterfaceCode::DUMP_RECORD_INFO): DumpRecordInfoInner(data, reply); break; + case static_cast(IPrivacyManager::InterfaceCode::REGISTER_PERM_ACTIVE_STATUS_CHANGE_CALLBACK): + RegisterPermActiveStatusCallbackInner(data, reply); + break; + case static_cast(IPrivacyManager::InterfaceCode::UNREGISTER_PERM_ACTIVE_STATUS_CHANGE_CALLBACK): + UnRegisterPermActiveStatusCallbackInner(data, reply); + break; default: return IPCObjectStub::OnRemoteRequest(code, data, reply, option); } @@ -158,6 +164,17 @@ void PrivacyManagerStub::DumpRecordInfoInner(MessageParcel& data, MessageParcel& reply.WriteString(dumpInfo); } +int32_t PrivacyManagerStub::RegisterPermActiveStatusCallbackInner( + std::vector& permList, const sptr& callback) +{ + return 0; +} + +int32_t PrivacyManagerStub::UnRegisterPermActiveStatusCallbackInner(const sptr& callback) +{ + return 0; +} + bool PrivacyManagerStub::IsAccessTokenCalling() const { int32_t callingUid = IPCSkeleton::GetCallingUid(); diff --git a/services/tokensyncmanager/src/remote/.soft_bus_device_connection_listener.cpp.swp b/services/tokensyncmanager/src/remote/.soft_bus_device_connection_listener.cpp.swp new file mode 100644 index 0000000000000000000000000000000000000000..e6e8dea2f3b5b1c7e28c2ff08fe03f72dfbe1c4a GIT binary patch literal 16384 zcmeHOU5p!76~6u9uOWco0Vt|;;y~nGTzj)AQsiwSytcDz*0F=_O&SEX#xvL6A@+8O3nV-(R3dQFwF#|CJF#|CJF#|CJF#|CJF#|CJF#|CJF#~Tv1~fy6 z55lhNyy3_B|7idJuXhUZd*Eqc9e4zI7S^Z8=EzCb%-RF8k<73F9t3Q{G? zNRL=p8JC-uIkK>I4md zd5Of{_TmGenxR5yy1=DA#cBezy;R&r;HD-%;D%J*qj4QVFZlK(0>shqT=8raUI zl98hDsnHnr!BM5yxKOQaG)sjDx54XqyN3i8V;@BoTbb=)AgtPMcTGzsJ;OBah8S-w zhDVEsTOKZn1RXm@tRuMN(K7C%(O6=mZ7Z8CTDmjrE7(^u0=v?B6TOmLh#1I{M~_ou zQDd%dFG`Hdvh<;yzSruS`mUQIVoB4F*v{yaM4%wr$K~o;vs5`#O_p=3#d0{{qQl2; zD+aeej(NoG(-&y`wscg(-n7ii-l*S=s&hsveQVPBVbiBnFuAW&1$4Puw>u29l@6q5 zOdOP%Xi3@#8fC1A9kFf0h&nQ(Ry{XpELs$%Me)4ktf*|ZY6WGZ(WdkALD30G$5`|N z7Eix3Ga0gMvZORf+0?Z)1Ala_OMU6|OxH!yl}oK5Dh<;93&CrIYqpz;wOX|n_7f%i z5otTYSTtRdy}lZz$hLSEP+K#*(nu#lws%Q(T^U)~Uia+s#m-JHwsK5r${&FEi$Rx) z^6Rf;mNUW?lLur{upR#=v-E#DNyFj0&kV)aW_oU} z4lBqe#M(6O!~G}cK}65a$pgtB>%I$j7y7n_CZ*<7j8jA%(wVveDS-4y|sO_@6R_R1@LhpOw*+y`$j8y^1JN1y8!HqgDw%PT>$EE112Q=|UIZM@}4O=+aWNFB^ei*0{HH7T~|Vr*6l08GX%g`sPRo zb-~`-l9$mSL5mrHx@OPh!NQ+e&oZP#YD-cXY0s7`@x@)Fx|Gpp)W%1Z>$rWXn{AA; zu4Z*S5Jeq$wT{K3Ci?M)r7Y$`sj*(&Y|w>Vt(L1aO2s-=Ym~263Z+J=TEX2J%2h7X zMyXOrku;&gfp6Y-ki1P$Y4-YE6Q69B6`4!78%_AwM=RJCX%;1Nbt=^pw3@4z>TvTG zY18VmXh&Z5Ob6}uq3{=l_q2gDL+2M2(kUt{^igI}@cw@b`|Ag> z2j~4ih5OHI*z11@_&lHh7x*~vckK6H1zrSx3;Y5Y02{z*;2+rUzXIF@ZUA2ct^%J1 z9sxc8JPiB>`hE?39XJP6fMwwQ0Ne5a5MMC^F#|CJF#|CJF#|CJF#|CJF#~s>fn6ew z?~bDiybBkz4@dj;+X^BZ{CxsJk-$9d9rjP8CIQ&dQNbQTyt^1=%Wq*jERAFkE4oAE zI}+4s&YUv5VH#7DnlYT;l>as+9~@2X88_zxU@-tr){$?D14idl*qEUQ!QRKscDxwz2AZikxW1b4GvCv67S&h76 zs^k(z)3}_U-mzObs3AE(fisUFn1ka<9YKQdTmpd)2*pVVf?E8a)2Z*+{J+;n=M=1f z1Njpx)Bd>zPRuyE^>}d6dNEfJT$itDqj41LIo9N)lWWYHJbjR|*C8xP$FZFh+TeO! O6*)pPFyWvAr2GdmetU2L literal 0 HcmV?d00001 -- Gitee