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 0000000000000000000000000000000000000000..5a49358f637c5547a262df7ebeab5a866137d4da --- /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 8ee5f3fbad385dbff6785acfa5c3531949dea670..137f5886406aaf77e073d446879683e823247240 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 0000000000000000000000000000000000000000..b870dd23d287ee3b7fd100a3f93123f25f9ef772 --- /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 0000000000000000000000000000000000000000..eec60b42681c365c2f293985d9f3ddc1db75e54c --- /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 0000000000000000000000000000000000000000..71f73446229551d4471d16ba135f7340a13505dc --- /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 0000000000000000000000000000000000000000..71838bd3a47d324d9d1e5143f7442859dc3880f6 --- /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 b3fb9a4d1e58d5bb63f9857dbc9a35428c29f6f0..86ccf9d61b09bcc0907bcba1e2e79e9a275c7307 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 0000000000000000000000000000000000000000..8c540cb342b2b28ce624d6db649726edb1902113 --- /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 0000000000000000000000000000000000000000..5f36610981d6327e152ccca219fe794e19d98d14 --- /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 0b9557bdd38c5d61acc97c2fb206349b3b8894fc..893770860abef8d9c86d392c16a9b83ac095ad81 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 495f5b42a47dbb4a65ca5e769bd7452f84318c77..6673ce3854580e2ada9d29654c225c9fec4bf83a 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 c43bd9dd1fc9bf60b36c6ec648285fa12ff97650..86bdfaf82636771c7bed33686f5f7b4e6d30645a 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 b8224d258bd3a7eca109c6cb1332b871342b6bea..4bba218fd7ded19b0aef7582e0266d250787c403 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 1ed65c1283edd58e8bb5e56df0e40ee619675b1c..a84957aacc52b0cf8f0e6755d475a0f2c7e7a1e3 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 0000000000000000000000000000000000000000..3b193b2cb5287cbb7dfbc1364b19b701cf29009e --- /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 d2c89b6cedfecd4194ed0e6e61a8b733eea44cdd..116249c7fb4b76e13dea65d9f943ed16bb40d170 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 1a8ce60baef75b5b0ae1ddb8ec81cd936a2d7ced..dcce8b61df24ef88a4fe644f93cd5dc5b336314f 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 0000000000000000000000000000000000000000..153aa62793d41665e10d9a264f99747aa9121d61 --- /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 1f9cecd49093288fff571c590dc68b9b9acf3184..d0b2fc88f1a5bb5ec5f1b48b7e144e207ddaed93 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 bd1dd4fe72a035c93122eca81bc5d2435cfe3b14..2d4391889bfd56e5734c1e396b3d961b7ab3a5b5 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 Binary files /dev/null and b/services/tokensyncmanager/src/remote/.soft_bus_device_connection_listener.cpp.swp differ