diff --git a/BUILD.gn b/BUILD.gn index b81735de42817084d65b12930aeb4af798d83b48..72be0780cac8c3b7f10750390bdbfc24cea5b09f 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -38,9 +38,6 @@ group("accesstoken_build_module_test") { "services/privacymanager/test:unittest", ] } - if (window_manager_enable == true) { - deps += [ "services/common/window_manager/test:unittest" ] - } } if (token_sync_enable == true) { deps += [ diff --git a/access_token.gni b/access_token.gni index 303cfde59a7f59bcd957c06437f49a43a71ceda1..c8ce51bf8338a3dbd6664bf9fe4430a69623941e 100644 --- a/access_token.gni +++ b/access_token.gni @@ -136,10 +136,6 @@ if (!defined(global_parts_info) || access_token_background_task_mgr_continuous_task_enable = false } -declare_args() { - access_token_camera_float_window_enable = true -} - if (!defined(global_parts_info) || defined(global_parts_info.appsecurityprivacy_security_privacy_server)) { access_token_app_security_privacy_service_enable = true @@ -147,13 +143,6 @@ if (!defined(global_parts_info) || access_token_app_security_privacy_service_enable = false } -if (!defined(global_parts_info) || - defined(global_parts_info.window_window_manager)) { - window_manager_enable = true -} else { - window_manager_enable = false -} - if (!defined(global_parts_info) || defined(global_parts_info.powermgr_power_manager)) { power_manager_enable = true diff --git a/services/common/window_manager/include/privacy_mock_session_manager_proxy.h b/services/common/window_manager/include/privacy_mock_session_manager_proxy.h deleted file mode 100644 index aac50b2137e8329de1a81a8f2c9cbdfbfc2d56f2..0000000000000000000000000000000000000000 --- a/services/common/window_manager/include/privacy_mock_session_manager_proxy.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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. - */ - -#ifndef PRIVACY_MOCK_SESSION_MANAGER_PROXY_H -#define PRIVACY_MOCK_SESSION_MANAGER_PROXY_H - -#include - -namespace OHOS { -namespace Security { -namespace AccessToken { -class IMockSessionManagerInterface : public IRemoteBroker { -public: - DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.IMockSessionManager"); - enum class MockSessionManagerServiceMessage : uint32_t { - TRANS_ID_GET_SESSION_MANAGER_SERVICE = 0, - }; - - virtual sptr GetSessionManagerService() = 0; -}; - -class PrivacyMockSessionManagerProxy : public IRemoteProxy { -public: - explicit PrivacyMockSessionManagerProxy(const sptr& impl) - : IRemoteProxy(impl) {} - ~PrivacyMockSessionManagerProxy() {} - sptr GetSessionManagerService() override; -private: - static inline BrokerDelegator delegator_; -}; -} -} -} -#endif // PRIVACY_MOCK_SESSION_MANAGER_PROXY_H \ No newline at end of file diff --git a/services/common/window_manager/include/privacy_scene_session_manager_lite_proxy.h b/services/common/window_manager/include/privacy_scene_session_manager_lite_proxy.h deleted file mode 100644 index 27219d8483a9acf18f0f2b41b6e4688cccb8f21b..0000000000000000000000000000000000000000 --- a/services/common/window_manager/include/privacy_scene_session_manager_lite_proxy.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * 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. - */ - -#ifndef PRIVACY_SCENE_SESSION_MANAGER_LITE_PROXY_H -#define PRIVACY_SCENE_SESSION_MANAGER_LITE_PROXY_H - -#include -#include "privacy_window_manager_interface.h" -#include "privacy_window_manager_interface_lite.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -class ISceneSessionManagerLite : public IWindowManagerLite { -public: - DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.ISceneSessionManagerLite"); - - enum class SceneSessionManagerLiteMessage : uint32_t { - TRANS_ID_REGISTER_WINDOW_MANAGER_AGENT = 22, - TRANS_ID_UNREGISTER_WINDOW_MANAGER_AGENT = 23, - }; - - virtual int32_t RegisterWindowManagerAgent(WindowManagerAgentType type, - const sptr& windowManagerAgent) = 0; - virtual int32_t UnregisterWindowManagerAgent(WindowManagerAgentType type, - const sptr& windowManagerAgent) = 0; -}; - -class PrivacySceneSessionManagerLiteProxy : public IRemoteProxy { -public: - explicit PrivacySceneSessionManagerLiteProxy(const sptr& impl) - : IRemoteProxy(impl) {} - virtual ~PrivacySceneSessionManagerLiteProxy() = default; - - int32_t RegisterWindowManagerAgent(WindowManagerAgentType type, - const sptr& windowManagerAgent) override; - int32_t UnregisterWindowManagerAgent(WindowManagerAgentType type, - const sptr& windowManagerAgent) override; -private: - static inline BrokerDelegator delegator_; -}; -} -} -} -#endif // PRIVACY_SCENE_SESSION_MANAGER_LITE_PROXY_H diff --git a/services/common/window_manager/include/privacy_scene_session_manager_proxy.h b/services/common/window_manager/include/privacy_scene_session_manager_proxy.h deleted file mode 100644 index 934ad9a20878f0a71006fe50928fb9285977cdb6..0000000000000000000000000000000000000000 --- a/services/common/window_manager/include/privacy_scene_session_manager_proxy.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * 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. - */ - -#ifndef PRIVACY_SCENE_SESSION_MANAGER_PROXY_H -#define PRIVACY_SCENE_SESSION_MANAGER_PROXY_H - -#include -#include "privacy_window_manager_interface.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -class ISceneSessionManager : public IWindowManager { -public: - DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.ISceneSessionManager"); - - enum class SceneSessionManagerMessage : uint32_t { - TRANS_ID_REGISTER_WINDOW_MANAGER_AGENT = 4, - TRANS_ID_UNREGISTER_WINDOW_MANAGER_AGENT = 5, - }; - - virtual int32_t RegisterWindowManagerAgent(WindowManagerAgentType type, - const sptr& windowManagerAgent) = 0; - virtual int32_t UnregisterWindowManagerAgent(WindowManagerAgentType type, - const sptr& windowManagerAgent) = 0; -}; - - -class PrivacySceneSessionManagerProxy : public IRemoteProxy { -public: - explicit PrivacySceneSessionManagerProxy(const sptr& impl) - : IRemoteProxy(impl) {} - virtual ~PrivacySceneSessionManagerProxy() = default; - - int32_t RegisterWindowManagerAgent(WindowManagerAgentType type, - const sptr& windowManagerAgent) override; - int32_t UnregisterWindowManagerAgent(WindowManagerAgentType type, - const sptr& windowManagerAgent) override; -private: - static inline BrokerDelegator delegator_; -}; -} -} -} -#endif // PRIVACY_SCENE_SESSION_MANAGER_PROXY_H diff --git a/services/common/window_manager/include/privacy_session_manager_proxy.h b/services/common/window_manager/include/privacy_session_manager_proxy.h deleted file mode 100644 index 9030fde3ff5f449b856b7fecd02b18f59292b078..0000000000000000000000000000000000000000 --- a/services/common/window_manager/include/privacy_session_manager_proxy.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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. - */ - -#ifndef PRIVACY_SESSION_MANAGER_PROXY_H -#define PRIVACY_SESSION_MANAGER_PROXY_H - -#include - -namespace OHOS { -namespace Security { -namespace AccessToken { -class ISessionManagerService : public IRemoteBroker { -public: - DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.ISessionManagerService"); - - enum class SessionManagerServiceMessage : uint32_t { - TRANS_ID_GET_SCENE_SESSION_MANAGER = 0, - TRANS_ID_GET_SCENE_SESSION_MANAGER_LITE = 1, - }; - - virtual sptr GetSceneSessionManager() = 0; - virtual sptr GetSceneSessionManagerLite() = 0; -}; - -class PrivacySessionManagerProxy : public IRemoteProxy { -public: - explicit PrivacySessionManagerProxy(const sptr& object) - : IRemoteProxy(object) {} - virtual ~PrivacySessionManagerProxy() = default; - - sptr GetSceneSessionManager() override; - sptr GetSceneSessionManagerLite() override; - -private: - static inline BrokerDelegator delegator_; -}; -} -} -} -#endif // PRIVACY_SESSION_MANAGER_PROXY_H diff --git a/services/common/window_manager/include/privacy_window_manager_agent.h b/services/common/window_manager/include/privacy_window_manager_agent.h deleted file mode 100644 index fa9b32510d9a4a4b5fffdf1db2a933908574d676..0000000000000000000000000000000000000000 --- a/services/common/window_manager/include/privacy_window_manager_agent.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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. - */ - -#ifndef PRIVACY_WINDOW_MANAGER_AGENT_H -#define PRIVACY_WINDOW_MANAGER_AGENT_H - -#include "iremote_stub.h" -#include "nocopyable.h" -#include "privacy_window_manager_interface.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -using WindowChangeCallback = void (*)(uint32_t, bool); - -class PrivacyWindowManagerAgent : public IRemoteStub { -public: - PrivacyWindowManagerAgent(WindowChangeCallback callback); - ~PrivacyWindowManagerAgent() = default; - - int OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) override; - void UpdateCameraFloatWindowStatus(uint32_t accessTokenId, bool isShowing) override; - void UpdateCameraWindowStatus(uint32_t accessTokenId, bool isShowing) override; -private: - WindowChangeCallback callback_; -}; -} // namespace AccessToken -} // namespace Security -} // namespace OHOS -#endif // PRIVACY_WINDOW_MANAGER_AGENT_H - diff --git a/services/common/window_manager/include/privacy_window_manager_client.h b/services/common/window_manager/include/privacy_window_manager_client.h deleted file mode 100644 index 723ea41260ea4a670345670d007c0bac1ba1633d..0000000000000000000000000000000000000000 --- a/services/common/window_manager/include/privacy_window_manager_client.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * 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. - */ - -#ifndef PRIVACY_WINDOW_MANAGER_CLIENT_H -#define PRIVACY_WINDOW_MANAGER_CLIENT_H - -#include -#include - -#include "nocopyable.h" -#include "privacy_window_manager_death_recipient.h" -#include "privacy_window_manager_interface.h" -#include "privacy_window_manager_interface_lite.h" -#include "privacy_scene_session_manager_lite_proxy.h" -#include "privacy_scene_session_manager_proxy.h" -#include "privacy_session_manager_proxy.h" -#include "privacy_mock_session_manager_proxy.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -class PrivacyWindowManagerClient final { -public: - static PrivacyWindowManagerClient& GetInstance(); - - virtual ~PrivacyWindowManagerClient(); - int32_t RegisterWindowManagerAgent(WindowManagerAgentType type, - const sptr& windowManagerAgent); - int32_t UnregisterWindowManagerAgent(WindowManagerAgentType type, - const sptr& windowManagerAgent); - void AddDeathCallback(void (*callback)()); - void OnRemoteDiedHandle(); - -private: - PrivacyWindowManagerClient(); - DISALLOW_COPY_AND_MOVE(PrivacyWindowManagerClient); - sptr GetProxy(); - sptr GetLiteProxy(); - int32_t RegisterWindowManagerAgentLite(WindowManagerAgentType type, - const sptr& windowManagerAgent); - int32_t UnregisterWindowManagerAgentLite(WindowManagerAgentType type, - const sptr& windowManagerAgent); - - void InitSceneSessionManagerProxy(); - void InitSessionManagerServiceProxy(); - void InitSceneSessionManagerLiteProxy(); - sptr GetSSMProxy(); - sptr GetSSMLiteProxy(); - void InitWMSProxy(); - sptr GetWMSProxy(); - void RemoveDeathRecipient(); - - sptr serviceDeathObserver_ = nullptr; - std::mutex proxyMutex_; - - std::mutex deathMutex_; - void (*deathCallback_)(); - sptr mockSessionManagerServiceProxy_ = nullptr; - sptr sessionManagerServiceProxy_ = nullptr; - sptr sceneSessionManagerProxy_ = nullptr; - sptr sceneSessionManagerLiteProxy_ = nullptr; - sptr wmsProxy_ = nullptr; -}; -} // namespace AccessToken -} // namespace Security -} // namespace OHOS -#endif // PRIVACY_WINDOW_MANAGER_CLIENT_H - diff --git a/services/common/window_manager/include/privacy_window_manager_death_recipient.h b/services/common/window_manager/include/privacy_window_manager_death_recipient.h deleted file mode 100644 index 161f53cc895e63e707f001ff5d5089480ac00b72..0000000000000000000000000000000000000000 --- a/services/common/window_manager/include/privacy_window_manager_death_recipient.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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. - */ -#ifndef PRIVACY_WINDOW_MANAGER_DEATH_RECIPIENT_H -#define PRIVACY_WINDOW_MANAGER_DEATH_RECIPIENT_H - -#include "iremote_object.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -class PrivacyWindowManagerDeathRecipient : public IRemoteObject::DeathRecipient { -public: - PrivacyWindowManagerDeathRecipient() {} - virtual ~PrivacyWindowManagerDeathRecipient() override = default; - void OnRemoteDied(const wptr& object) override; -}; -} // namespace AccessToken -} // namespace Security -} // namespace OHOS -#endif // PRIVACY_WINDOW_MANAGER_DEATH_RECIPIENT_H - diff --git a/services/common/window_manager/include/privacy_window_manager_interface.h b/services/common/window_manager/include/privacy_window_manager_interface.h deleted file mode 100644 index 888e7895ae370438b264bffe6e6faa0427111861..0000000000000000000000000000000000000000 --- a/services/common/window_manager/include/privacy_window_manager_interface.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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. - */ -#ifndef PRIVACY_WINDOW_MANAGER_NTERFACE_H -#define PRIVACY_WINDOW_MANAGER_NTERFACE_H - -#include - -namespace OHOS { -namespace Security { -namespace AccessToken { - -enum class WindowManagerAgentType : uint32_t { - WINDOW_MANAGER_AGENT_TYPE_CAMERA_FLOAT = 5, - WINDOW_MANAGER_AGENT_TYPE_CAMERA_WINDOW = 9, -}; - -enum class PrivacyWindowServiceInterfaceCode { - TRANS_ID_UPDATE_CAMERA_FLOAT = 6, - TRANS_ID_UPDATE_CAMERA_WINDOW_STATUS = 10, -}; - -class IWindowManagerAgent : public IRemoteBroker { -public: - DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.IWindowManagerAgent"); - - virtual void UpdateCameraFloatWindowStatus(uint32_t accessTokenId, bool isShowing) = 0; - virtual void UpdateCameraWindowStatus(uint32_t accessTokenId, bool isShowing) = 0; -}; - -class IWindowManager : public IRemoteBroker { -public: - DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.IWindowManager"); - enum class WindowManagerMessage : uint32_t { - TRANS_ID_REGISTER_WINDOW_MANAGER_AGENT = 7, - TRANS_ID_UNREGISTER_WINDOW_MANAGER_AGENT = 8, - }; - - virtual int32_t RegisterWindowManagerAgent(WindowManagerAgentType type, - const sptr& windowManagerAgent) = 0; - virtual int32_t UnregisterWindowManagerAgent(WindowManagerAgentType type, - const sptr& windowManagerAgent) = 0; -}; -} -} -} -#endif // PRIVACY_WINDOW_MANAGER_NTERFACE_H diff --git a/services/common/window_manager/include/privacy_window_manager_interface_lite.h b/services/common/window_manager/include/privacy_window_manager_interface_lite.h deleted file mode 100644 index f5865ece324bdf5fedd0cddb5ddb3955362a9bc8..0000000000000000000000000000000000000000 --- a/services/common/window_manager/include/privacy_window_manager_interface_lite.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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. - */ -#ifndef PRIVACY_WINDOW_MANAGER_NTERFACE_LITE_H -#define PRIVACY_WINDOW_MANAGER_NTERFACE_LITE_H - -#include - -namespace OHOS { -namespace Security { -namespace AccessToken { -class IWindowManagerLite : public IRemoteBroker { -public: - DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.IWindowManagerLite"); - // do not need enum - virtual int32_t RegisterWindowManagerAgent(WindowManagerAgentType type, - const sptr& windowManagerAgent) = 0; - virtual int32_t UnregisterWindowManagerAgent(WindowManagerAgentType type, - const sptr& windowManagerAgent) = 0; -}; -} -} -} -#endif // PRIVACY_WINDOW_MANAGER_NTERFACE_LITE_H diff --git a/services/common/window_manager/include/privacy_window_manager_proxy.h b/services/common/window_manager/include/privacy_window_manager_proxy.h deleted file mode 100644 index 6ebe1c2bfe06b5b24ad434918ecc1aaedcac4ee8..0000000000000000000000000000000000000000 --- a/services/common/window_manager/include/privacy_window_manager_proxy.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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. - */ - -#ifndef PRIVACY_OHOS_WINDOW_MANAGER_PROXY_H -#define PRIVACY_OHOS_WINDOW_MANAGER_PROXY_H - -#include -#include "privacy_window_manager_interface.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -class PrivacyWindowManagerProxy : public IRemoteProxy { -public: - explicit PrivacyWindowManagerProxy(const sptr& impl) : IRemoteProxy(impl) {} - - ~PrivacyWindowManagerProxy() {} - int32_t RegisterWindowManagerAgent(WindowManagerAgentType type, - const sptr& windowManagerAgent) override; - int32_t UnregisterWindowManagerAgent(WindowManagerAgentType type, - const sptr& windowManagerAgent) override; - -private: - static inline BrokerDelegator delegator_; -}; -} -} -} -#endif // PRIVACY_OHOS_WINDOW_MANAGER_PROXY_H diff --git a/services/common/window_manager/src/privacy_mock_session_manager_proxy.cpp b/services/common/window_manager/src/privacy_mock_session_manager_proxy.cpp deleted file mode 100644 index d2b92b72aa13b7adcd3f026792844cb6c029d8f2..0000000000000000000000000000000000000000 --- a/services/common/window_manager/src/privacy_mock_session_manager_proxy.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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. - */ - -#include -#include "privacy_mock_session_manager_proxy.h" -#include "accesstoken_common_log.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { - -sptr PrivacyMockSessionManagerProxy::GetSessionManagerService() -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - LOGE(PRI_DOMAIN, PRI_TAG, "WriteInterfaceToken failed"); - return nullptr; - } - if (Remote()->SendRequest(static_cast( - MockSessionManagerServiceMessage::TRANS_ID_GET_SESSION_MANAGER_SERVICE), - data, reply, option) != ERR_NONE) { - LOGE(PRI_DOMAIN, PRI_TAG, "SendRequest failed"); - return nullptr; - } - if (reply.ReadInt32() != ERR_NONE) { - LOGE(PRI_DOMAIN, PRI_TAG, "Read result failed"); - return nullptr; - } - sptr remoteObject = reply.ReadRemoteObject(); - return remoteObject; -} -} -} -} \ No newline at end of file diff --git a/services/common/window_manager/src/privacy_scene_session_manager_lite_proxy.cpp b/services/common/window_manager/src/privacy_scene_session_manager_lite_proxy.cpp deleted file mode 100644 index 73503fd66b90b2be519b13208958912d2cb893df..0000000000000000000000000000000000000000 --- a/services/common/window_manager/src/privacy_scene_session_manager_lite_proxy.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/* - * 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. - */ - -#include "privacy_scene_session_manager_lite_proxy.h" - -#include "accesstoken_common_log.h" -#include "privacy_error.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { - -int32_t PrivacySceneSessionManagerLiteProxy::RegisterWindowManagerAgent(WindowManagerAgentType type, - const sptr& windowManagerAgent) -{ - MessageOption option; - MessageParcel reply; - MessageParcel data; - if (!data.WriteInterfaceToken(GetDescriptor())) { - LOGE(PRI_DOMAIN, PRI_TAG, "Write InterfaceToken failed"); - return ERR_WRITE_PARCEL_FAILED; - } - - if (!data.WriteUint32(static_cast(type))) { - LOGE(PRI_DOMAIN, PRI_TAG, "Write type failed"); - return ERR_WRITE_PARCEL_FAILED; - } - - if (!data.WriteRemoteObject(windowManagerAgent->AsObject())) { - LOGE(PRI_DOMAIN, PRI_TAG, "Write IWindowManagerAgent failed"); - return ERR_WRITE_PARCEL_FAILED; - } - - sptr remote = Remote(); - if (remote == nullptr) { - LOGE(PRI_DOMAIN, PRI_TAG, "Remote service is null."); - return ERR_REMOTE_CONNECTION; - } - int32_t error = remote->SendRequest(static_cast( - SceneSessionManagerLiteMessage::TRANS_ID_REGISTER_WINDOW_MANAGER_AGENT), - data, reply, option); - if (error != ERR_NONE) { - LOGE(PRI_DOMAIN, PRI_TAG, "SendRequest failed, err=%{public}d.", error); - return error; - } - - return reply.ReadInt32(); -} - -int32_t PrivacySceneSessionManagerLiteProxy::UnregisterWindowManagerAgent(WindowManagerAgentType type, - const sptr& windowManagerAgent) -{ - MessageParcel reply; - MessageOption option; - MessageParcel data; - if (!data.WriteInterfaceToken(GetDescriptor())) { - LOGE(PRI_DOMAIN, PRI_TAG, "Write InterfaceToken failed"); - return ERR_WRITE_PARCEL_FAILED; - } - - if (!data.WriteUint32(static_cast(type))) { - LOGE(PRI_DOMAIN, PRI_TAG, "Write type failed"); - return ERR_WRITE_PARCEL_FAILED; - } - - if (!data.WriteRemoteObject(windowManagerAgent->AsObject())) { - LOGE(PRI_DOMAIN, PRI_TAG, "Write IWindowManagerAgent failed"); - return ERR_WRITE_PARCEL_FAILED; - } - - sptr remote = Remote(); - if (remote == nullptr) { - LOGE(PRI_DOMAIN, PRI_TAG, "Remote service is null."); - return ERR_REMOTE_CONNECTION; - } - int32_t error = remote->SendRequest(static_cast( - SceneSessionManagerLiteMessage::TRANS_ID_UNREGISTER_WINDOW_MANAGER_AGENT), - data, reply, option); - if (error != ERR_NONE) { - LOGE(PRI_DOMAIN, PRI_TAG, "SendRequest failed, err=%{public}d.", error); - return error; - } - - return reply.ReadInt32(); -} -} -} -} \ No newline at end of file diff --git a/services/common/window_manager/src/privacy_scene_session_manager_proxy.cpp b/services/common/window_manager/src/privacy_scene_session_manager_proxy.cpp deleted file mode 100644 index 0d09f3b57aa9e59eaa35cb69b0d8859418bcdcb6..0000000000000000000000000000000000000000 --- a/services/common/window_manager/src/privacy_scene_session_manager_proxy.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/* - * 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. - */ - -#include "privacy_scene_session_manager_proxy.h" - -#include "accesstoken_common_log.h" -#include "privacy_error.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { - -int32_t PrivacySceneSessionManagerProxy::RegisterWindowManagerAgent(WindowManagerAgentType type, - const sptr& windowManagerAgent) -{ - MessageOption option; - MessageParcel reply; - MessageParcel data; - if (!data.WriteInterfaceToken(GetDescriptor())) { - LOGE(PRI_DOMAIN, PRI_TAG, "Write InterfaceToken failed"); - return ERR_WRITE_PARCEL_FAILED; - } - - if (!data.WriteUint32(static_cast(type))) { - LOGE(PRI_DOMAIN, PRI_TAG, "Write type failed"); - return ERR_WRITE_PARCEL_FAILED; - } - - if (!data.WriteRemoteObject(windowManagerAgent->AsObject())) { - LOGE(PRI_DOMAIN, PRI_TAG, "Write IWindowManagerAgent failed"); - return ERR_WRITE_PARCEL_FAILED; - } - - int32_t error = Remote()->SendRequest(static_cast( - SceneSessionManagerMessage::TRANS_ID_REGISTER_WINDOW_MANAGER_AGENT), - data, reply, option); - if (error != ERR_NONE) { - LOGE(PRI_DOMAIN, PRI_TAG, "SendRequest failed, err=%{public}d.", error); - return error; - } - - return reply.ReadInt32(); -} - -int32_t PrivacySceneSessionManagerProxy::UnregisterWindowManagerAgent(WindowManagerAgentType type, - const sptr& windowManagerAgent) -{ - MessageParcel reply; - MessageOption option; - MessageParcel data; - if (!data.WriteInterfaceToken(GetDescriptor())) { - LOGE(PRI_DOMAIN, PRI_TAG, "Write InterfaceToken failed"); - return ERR_WRITE_PARCEL_FAILED; - } - - if (!data.WriteUint32(static_cast(type))) { - LOGE(PRI_DOMAIN, PRI_TAG, "Write type failed"); - return ERR_WRITE_PARCEL_FAILED; - } - - if (!data.WriteRemoteObject(windowManagerAgent->AsObject())) { - LOGE(PRI_DOMAIN, PRI_TAG, "Write IWindowManagerAgent failed"); - return ERR_WRITE_PARCEL_FAILED; - } - - int32_t error = Remote()->SendRequest(static_cast( - SceneSessionManagerMessage::TRANS_ID_UNREGISTER_WINDOW_MANAGER_AGENT), - data, reply, option); - if (error != ERR_NONE) { - LOGE(PRI_DOMAIN, PRI_TAG, "SendRequest failed, err=%{public}d.", error); - return error; - } - - return reply.ReadInt32(); -} -} -} -} \ No newline at end of file diff --git a/services/common/window_manager/src/privacy_session_manager_proxy.cpp b/services/common/window_manager/src/privacy_session_manager_proxy.cpp deleted file mode 100644 index 1bc8196e8c9ed7c9562b8c14cba694ba0df614b6..0000000000000000000000000000000000000000 --- a/services/common/window_manager/src/privacy_session_manager_proxy.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/* - * 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. - */ - -#include "privacy_session_manager_proxy.h" - -#include "accesstoken_common_log.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { - -sptr PrivacySessionManagerProxy::GetSceneSessionManager() -{ - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - - if (!data.WriteInterfaceToken(GetDescriptor())) { - LOGE(PRI_DOMAIN, PRI_TAG, "WriteInterfaceToken failed"); - return nullptr; - } - - sptr remote = Remote(); - if (remote == nullptr) { - LOGE(PRI_DOMAIN, PRI_TAG, "Remote service is null."); - return nullptr; - } - auto ret = remote->SendRequest( - static_cast(SessionManagerServiceMessage::TRANS_ID_GET_SCENE_SESSION_MANAGER), - data, reply, option); - if (ret != ERR_NONE) { - LOGE(PRI_DOMAIN, PRI_TAG, "SendRequest failed, errorCode %{public}d", ret); - return nullptr; - } - - return reply.ReadRemoteObject(); -} - -sptr PrivacySessionManagerProxy::GetSceneSessionManagerLite() -{ - MessageParcel data; - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - - if (!data.WriteInterfaceToken(GetDescriptor())) { - LOGE(PRI_DOMAIN, PRI_TAG, "WriteInterfaceToken failed"); - return nullptr; - } - - sptr remote = Remote(); - if (remote == nullptr) { - LOGE(PRI_DOMAIN, PRI_TAG, "Remote service is null."); - return nullptr; - } - auto ret = remote->SendRequest( - static_cast(SessionManagerServiceMessage::TRANS_ID_GET_SCENE_SESSION_MANAGER_LITE), - data, reply, option); - if (ret != ERR_NONE) { - LOGE(PRI_DOMAIN, PRI_TAG, "SendRequest failed, errorCode %{public}d", ret); - return nullptr; - } - - return reply.ReadRemoteObject(); -} -} -} -} \ No newline at end of file diff --git a/services/common/window_manager/src/privacy_window_manager_agent.cpp b/services/common/window_manager/src/privacy_window_manager_agent.cpp deleted file mode 100644 index d38169376c41405d790ce3293210e682e6a2bf8c..0000000000000000000000000000000000000000 --- a/services/common/window_manager/src/privacy_window_manager_agent.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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. - */ -#include "privacy_window_manager_agent.h" -#include "accesstoken_common_log.h" -#include "privacy_error.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { - -PrivacyWindowManagerAgent::PrivacyWindowManagerAgent(WindowChangeCallback callback) -{ - callback_ = callback; -} - -int PrivacyWindowManagerAgent::OnRemoteRequest(uint32_t code, MessageParcel& data, - MessageParcel& reply, MessageOption& option) -{ - LOGI(PRI_DOMAIN, PRI_TAG, "%{public}s called, code: %{public}u", __func__, code); - if (data.ReadInterfaceToken() != IWindowManagerAgent::GetDescriptor()) { - LOGI(PRI_DOMAIN, PRI_TAG, "%{public}s called, read desciptor error", __func__); - return ERROR_IPC_REQUEST_FAIL; - } - PrivacyWindowServiceInterfaceCode msgId = static_cast(code); - switch (msgId) { - case PrivacyWindowServiceInterfaceCode::TRANS_ID_UPDATE_CAMERA_FLOAT: { - uint32_t accessTokenId = data.ReadUint32(); - bool isShowing = data.ReadBool(); - UpdateCameraFloatWindowStatus(accessTokenId, isShowing); - break; - } - case PrivacyWindowServiceInterfaceCode::TRANS_ID_UPDATE_CAMERA_WINDOW_STATUS: { - uint32_t accessTokenId = data.ReadUint32(); - bool isShowing = data.ReadBool(); - UpdateCameraWindowStatus(accessTokenId, isShowing); - break; - } - default: - break; - } - return 0; -} - -void PrivacyWindowManagerAgent::UpdateCameraFloatWindowStatus(uint32_t accessTokenId, bool isShowing) -{ - LOGI(PRI_DOMAIN, PRI_TAG, "OnChange(tokenId=%{public}d, isShow=%{public}d)", accessTokenId, isShowing); - callback_(accessTokenId, isShowing); -} - -void PrivacyWindowManagerAgent::UpdateCameraWindowStatus(uint32_t accessTokenId, bool isShowing) -{ - LOGI(PRI_DOMAIN, PRI_TAG, "OnChange(tokenId=%{public}d, isShow=%{public}d)", accessTokenId, isShowing); - callback_(accessTokenId, isShowing); -} -} // namespace AccessToken -} // namespace Security -} // namespace OHOS - diff --git a/services/common/window_manager/src/privacy_window_manager_client.cpp b/services/common/window_manager/src/privacy_window_manager_client.cpp deleted file mode 100644 index 33f4784e0feca582ba856174545a5ff307dcc0aa..0000000000000000000000000000000000000000 --- a/services/common/window_manager/src/privacy_window_manager_client.cpp +++ /dev/null @@ -1,337 +0,0 @@ -/* - * 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. - */ -#include "privacy_window_manager_client.h" - -#include -#include "accesstoken_common_log.h" -#include "iservice_registry.h" -#include "privacy_error.h" - -#include "privacy_mock_session_manager_proxy.h" -#include "privacy_scene_session_manager_proxy.h" -#include "privacy_scene_session_manager_lite_proxy.h" -#include "privacy_session_manager_proxy.h" -#include "privacy_window_manager_proxy.h" -#include "scene_board_judgement.h" -#include "system_ability_definition.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { -namespace { -std::recursive_mutex g_instanceMutex; -static const int MAX_PTHREAD_NAME_LEN = 15; // pthread name max length -} // namespace - -PrivacyWindowManagerClient& PrivacyWindowManagerClient::GetInstance() -{ - static PrivacyWindowManagerClient* instance = nullptr; - if (instance == nullptr) { - std::lock_guard lock(g_instanceMutex); - if (instance == nullptr) { - PrivacyWindowManagerClient* tmp = new (std::nothrow) PrivacyWindowManagerClient(); - instance = std::move(tmp); - } - } - return *instance; -} - -PrivacyWindowManagerClient::PrivacyWindowManagerClient() : deathCallback_(nullptr) -{ - std::lock_guard lock(proxyMutex_); - serviceDeathObserver_ = sptr::MakeSptr(); -} - -PrivacyWindowManagerClient::~PrivacyWindowManagerClient() -{ - LOGI(PRI_DOMAIN, PRI_TAG, "~PrivacyWindowManagerClient()."); - std::lock_guard lock(proxyMutex_); - RemoveDeathRecipient(); -} - -int32_t PrivacyWindowManagerClient::RegisterWindowManagerAgent(WindowManagerAgentType type, - const sptr& windowManagerAgent) -{ - if (type == WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_CAMERA_WINDOW) { - return RegisterWindowManagerAgentLite(type, windowManagerAgent); - } - auto proxy = GetProxy(); - if (proxy == nullptr) { - LOGE(PRI_DOMAIN, PRI_TAG, "Proxy is null"); - return ERR_SERVICE_ABNORMAL; - } - return proxy->RegisterWindowManagerAgent(type, windowManagerAgent); -} - -int32_t PrivacyWindowManagerClient::UnregisterWindowManagerAgent(WindowManagerAgentType type, - const sptr& windowManagerAgent) -{ - if (type == WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_CAMERA_WINDOW) { - return UnregisterWindowManagerAgentLite(type, windowManagerAgent); - } - auto proxy = GetProxy(); - if (proxy == nullptr) { - LOGE(PRI_DOMAIN, PRI_TAG, "Proxy is null"); - return ERR_SERVICE_ABNORMAL; - } - return proxy->UnregisterWindowManagerAgent(type, windowManagerAgent); -} - -int32_t PrivacyWindowManagerClient::RegisterWindowManagerAgentLite(WindowManagerAgentType type, - const sptr& windowManagerAgent) -{ - auto proxy = GetLiteProxy(); - if (proxy == nullptr) { - LOGE(PRI_DOMAIN, PRI_TAG, "Proxy is null"); - return ERR_SERVICE_ABNORMAL; - } - return proxy->RegisterWindowManagerAgent(type, windowManagerAgent); -} - -int32_t PrivacyWindowManagerClient::UnregisterWindowManagerAgentLite(WindowManagerAgentType type, - const sptr& windowManagerAgent) -{ - auto proxy = GetLiteProxy(); - if (proxy == nullptr) { - LOGE(PRI_DOMAIN, PRI_TAG, "Proxy is null"); - return ERR_SERVICE_ABNORMAL; - } - return proxy->UnregisterWindowManagerAgent(type, windowManagerAgent); -} - -void PrivacyWindowManagerClient::AddDeathCallback(void (*callback)()) -{ - std::lock_guard lock(deathMutex_); - deathCallback_ = callback; -} - -void PrivacyWindowManagerClient::InitSessionManagerServiceProxy() -{ - if (sessionManagerServiceProxy_ && sessionManagerServiceProxy_->AsObject() != nullptr && - (!sessionManagerServiceProxy_->AsObject()->IsObjectDead())) { - return; - } - sptr systemAbilityManager = - SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); - if (!systemAbilityManager) { - LOGE(PRI_DOMAIN, PRI_TAG, "Failed to get system ability mgr."); - return; - } - sptr remoteObject = systemAbilityManager->GetSystemAbility(WINDOW_MANAGER_SERVICE_ID); - if (!remoteObject) { - LOGE(PRI_DOMAIN, PRI_TAG, "Remote object is nullptr"); - return; - } - mockSessionManagerServiceProxy_ = new (std::nothrow) PrivacyMockSessionManagerProxy(remoteObject); - if (!mockSessionManagerServiceProxy_ || mockSessionManagerServiceProxy_->AsObject() == nullptr || - mockSessionManagerServiceProxy_->AsObject()->IsObjectDead()) { - LOGW(PRI_DOMAIN, PRI_TAG, "Get mock session manager service proxy failed, nullptr"); - return; - } - sptr remoteObject2 = mockSessionManagerServiceProxy_->GetSessionManagerService(); - if (!remoteObject2) { - LOGE(PRI_DOMAIN, PRI_TAG, "Remote object2 is nullptr"); - return; - } - sessionManagerServiceProxy_ = new (std::nothrow) PrivacySessionManagerProxy(remoteObject2); - if (!sessionManagerServiceProxy_ || sessionManagerServiceProxy_->AsObject() == nullptr || - sessionManagerServiceProxy_->AsObject()->IsObjectDead()) { - LOGE(PRI_DOMAIN, PRI_TAG, "SessionManagerServiceProxy_ is nullptr"); - } -} - -void PrivacyWindowManagerClient::InitSceneSessionManagerProxy() -{ - if (sceneSessionManagerProxy_ && sceneSessionManagerProxy_->AsObject() != nullptr && - (!sceneSessionManagerProxy_->AsObject()->IsObjectDead())) { - return; - } - if (!sessionManagerServiceProxy_ || sessionManagerServiceProxy_->AsObject() == nullptr || - sessionManagerServiceProxy_->AsObject()->IsObjectDead()) { - LOGE(PRI_DOMAIN, PRI_TAG, "SessionManagerServiceProxy_ is nullptr"); - return; - } - - sptr remoteObject = sessionManagerServiceProxy_->GetSceneSessionManager(); - if (!remoteObject) { - LOGW(PRI_DOMAIN, PRI_TAG, "Get scene session manager proxy failed, scene session manager service is null"); - return; - } - sceneSessionManagerProxy_ = new (std::nothrow) PrivacySceneSessionManagerProxy(remoteObject); - if (sceneSessionManagerProxy_ == nullptr || sceneSessionManagerProxy_->AsObject() == nullptr || - sceneSessionManagerProxy_->AsObject()->IsObjectDead()) { - LOGW(PRI_DOMAIN, PRI_TAG, "SceneSessionManagerProxy_ is null."); - return; - } - if (!serviceDeathObserver_) { - LOGE(PRI_DOMAIN, PRI_TAG, "Failed to create death Recipient ptr WMSDeathRecipient"); - return; - } - if (remoteObject->IsProxyObject() && !remoteObject->AddDeathRecipient(serviceDeathObserver_)) { - LOGE(PRI_DOMAIN, PRI_TAG, "Failed to add death recipient"); - return; - } - LOGI(PRI_DOMAIN, PRI_TAG, "InitSceneSessionManagerProxy end."); -} - -void PrivacyWindowManagerClient::InitSceneSessionManagerLiteProxy() -{ - if (sceneSessionManagerLiteProxy_ && sceneSessionManagerLiteProxy_->AsObject() != nullptr && - (!sceneSessionManagerLiteProxy_->AsObject()->IsObjectDead())) { - return; - } - if (!sessionManagerServiceProxy_) { - LOGE(PRI_DOMAIN, PRI_TAG, "SessionManagerServiceProxy_ is nullptr"); - return; - } - - sptr remoteObject = sessionManagerServiceProxy_->GetSceneSessionManagerLite(); - if (!remoteObject) { - LOGW(PRI_DOMAIN, PRI_TAG, "Get scene session manager proxy failed, scene session manager service is null"); - return; - } - sceneSessionManagerLiteProxy_ = new (std::nothrow) PrivacySceneSessionManagerLiteProxy(remoteObject); - if (sceneSessionManagerLiteProxy_ == nullptr || sceneSessionManagerLiteProxy_->AsObject() == nullptr || - sceneSessionManagerLiteProxy_->AsObject()->IsObjectDead()) { - LOGW(PRI_DOMAIN, PRI_TAG, "SceneSessionManagerLiteProxy_ is null."); - return; - } - if (!serviceDeathObserver_) { - LOGE(PRI_DOMAIN, PRI_TAG, "Failed to create death Recipient ptr WMSDeathRecipient"); - return; - } - if (remoteObject->IsProxyObject() && !remoteObject->AddDeathRecipient(serviceDeathObserver_)) { - LOGE(PRI_DOMAIN, PRI_TAG, "Failed to add death recipient"); - return; - } - LOGI(PRI_DOMAIN, PRI_TAG, "InitSceneSessionManagerLiteProxy end."); -} - -sptr PrivacyWindowManagerClient::GetSSMProxy() -{ - std::lock_guard lock(proxyMutex_); - InitSessionManagerServiceProxy(); - InitSceneSessionManagerProxy(); - return sceneSessionManagerProxy_; -} - -sptr PrivacyWindowManagerClient::GetSSMLiteProxy() -{ - std::lock_guard lock(proxyMutex_); - InitSessionManagerServiceProxy(); - InitSceneSessionManagerLiteProxy(); - return sceneSessionManagerLiteProxy_; -} - -void PrivacyWindowManagerClient::InitWMSProxy() -{ - if (wmsProxy_ && wmsProxy_->AsObject() != nullptr && (!wmsProxy_->AsObject()->IsObjectDead())) { - return; - } - auto sam = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); - if (sam == nullptr) { - LOGE(PRI_DOMAIN, PRI_TAG, "GetSystemAbilityManager is null"); - return; - } - auto windowManagerSa = sam->GetSystemAbility(WINDOW_MANAGER_SERVICE_ID); - if (windowManagerSa == nullptr) { - LOGE(PRI_DOMAIN, PRI_TAG, "GetSystemAbility %{public}d is null", - WINDOW_MANAGER_SERVICE_ID); - return; - } - - if (serviceDeathObserver_ != nullptr) { - windowManagerSa->AddDeathRecipient(serviceDeathObserver_); - } - - wmsProxy_ = new (std::nothrow) PrivacyWindowManagerProxy(windowManagerSa); - if (wmsProxy_ == nullptr || wmsProxy_->AsObject() == nullptr || wmsProxy_->AsObject()->IsObjectDead()) { - LOGE(PRI_DOMAIN, PRI_TAG, "WmsProxy_ is null."); - return; - } - LOGI(PRI_DOMAIN, PRI_TAG, "InitWMSProxy end."); -} - -sptr PrivacyWindowManagerClient::GetWMSProxy() -{ - std::lock_guard lock(proxyMutex_); - InitWMSProxy(); - return wmsProxy_; -} - -void PrivacyWindowManagerClient::OnRemoteDiedHandle() -{ - std::lock_guard lock(proxyMutex_); - LOGI(PRI_DOMAIN, PRI_TAG, "Window manager remote died."); - RemoveDeathRecipient(); - - std::function runner = [this]() { - std::string name = "WindowMgrDiedHandler"; - pthread_setname_np(pthread_self(), name.substr(0, MAX_PTHREAD_NAME_LEN).c_str()); - auto sleepTime = std::chrono::milliseconds(1000); - std::this_thread::sleep_for(sleepTime); - std::lock_guard lock(deathMutex_); - if (this->deathCallback_) { - this->deathCallback_(); - } - }; - - std::thread initThread(runner); - initThread.detach(); -} - -sptr PrivacyWindowManagerClient::GetLiteProxy() -{ - if (!Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) { - return nullptr; - } - return GetSSMLiteProxy(); -} - -sptr PrivacyWindowManagerClient::GetProxy() -{ - if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) { - return GetSSMProxy(); - } - return GetWMSProxy(); -} - -void PrivacyWindowManagerClient::RemoveDeathRecipient() -{ - if (serviceDeathObserver_ == nullptr) { - return; - } - // remove SceneSessionManager - if (sceneSessionManagerProxy_ != nullptr) { - sceneSessionManagerProxy_->AsObject()->RemoveDeathRecipient(serviceDeathObserver_); - } - //remove SceneSessionManagerLite - if (sceneSessionManagerLiteProxy_ != nullptr) { - sceneSessionManagerLiteProxy_->AsObject()->RemoveDeathRecipient(serviceDeathObserver_); - } - // remove WMSProxy - if (wmsProxy_ != nullptr) { - wmsProxy_->AsObject()->RemoveDeathRecipient(serviceDeathObserver_); - } - mockSessionManagerServiceProxy_ = nullptr; - sessionManagerServiceProxy_ = nullptr; - sceneSessionManagerProxy_ = nullptr; - sceneSessionManagerLiteProxy_ = nullptr; - wmsProxy_ = nullptr; -} -} // namespace AccessToken -} // namespace Security -} // namespace OHOS - diff --git a/services/common/window_manager/src/privacy_window_manager_death_recipient.cpp b/services/common/window_manager/src/privacy_window_manager_death_recipient.cpp deleted file mode 100644 index 6e5589481d39a4c89ee8690e9c43fe537aea5319..0000000000000000000000000000000000000000 --- a/services/common/window_manager/src/privacy_window_manager_death_recipient.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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. - */ -#include "privacy_window_manager_death_recipient.h" -#include "accesstoken_common_log.h" -#include "privacy_window_manager_client.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { - -void PrivacyWindowManagerDeathRecipient::OnRemoteDied(const wptr& object) -{ - LOGI(PRI_DOMAIN, PRI_TAG, "WindowManger died."); - PrivacyWindowManagerClient::GetInstance().OnRemoteDiedHandle(); -} -} // namespace AccessToken -} // namespace Security -} // namespace OHOS - diff --git a/services/common/window_manager/src/privacy_window_manager_proxy.cpp b/services/common/window_manager/src/privacy_window_manager_proxy.cpp deleted file mode 100644 index b98b267d312d155dc85e8d8b5d5ebf7247661a8b..0000000000000000000000000000000000000000 --- a/services/common/window_manager/src/privacy_window_manager_proxy.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/* - * 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. - */ - -#include "privacy_window_manager_proxy.h" -#include "accesstoken_common_log.h" -#include "privacy_error.h" - -namespace OHOS { -namespace Security { -namespace AccessToken { - -int32_t PrivacyWindowManagerProxy::RegisterWindowManagerAgent(WindowManagerAgentType type, - const sptr& windowManagerAgent) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - LOGE(PRI_DOMAIN, PRI_TAG, "WriteInterfaceToken failed"); - return ERR_WRITE_PARCEL_FAILED; - } - - if (!data.WriteUint32(static_cast(type))) { - LOGE(PRI_DOMAIN, PRI_TAG, "Write type failed"); - return ERR_WRITE_PARCEL_FAILED; - } - - if (!data.WriteRemoteObject(windowManagerAgent->AsObject())) { - LOGE(PRI_DOMAIN, PRI_TAG, "Write IWindowManagerAgent failed"); - return ERR_WRITE_PARCEL_FAILED; - } - sptr remote = Remote(); - if (remote == nullptr) { - LOGE(PRI_DOMAIN, PRI_TAG, "Remote service is null."); - return ERR_REMOTE_CONNECTION; - } - int32_t error = remote->SendRequest( - static_cast(IWindowManager::WindowManagerMessage::TRANS_ID_REGISTER_WINDOW_MANAGER_AGENT), - data, reply, option); - if (error != ERR_NONE) { - LOGE(PRI_DOMAIN, PRI_TAG, "SendRequest failed"); - return error; - } - return reply.ReadInt32(); -} - -int32_t PrivacyWindowManagerProxy::UnregisterWindowManagerAgent(WindowManagerAgentType type, - const sptr& windowManagerAgent) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - if (!data.WriteInterfaceToken(GetDescriptor())) { - LOGE(PRI_DOMAIN, PRI_TAG, "WriteInterfaceToken failed"); - return ERR_WRITE_PARCEL_FAILED; - } - - if (!data.WriteUint32(static_cast(type))) { - LOGE(PRI_DOMAIN, PRI_TAG, "Write type failed"); - return ERR_WRITE_PARCEL_FAILED; - } - - if (!data.WriteRemoteObject(windowManagerAgent->AsObject())) { - LOGE(PRI_DOMAIN, PRI_TAG, "Write IWindowManagerAgent failed"); - return ERR_WRITE_PARCEL_FAILED; - } - - sptr remote = Remote(); - if (remote == nullptr) { - LOGE(PRI_DOMAIN, PRI_TAG, "Remote service is null."); - return ERR_REMOTE_CONNECTION; - } - int32_t error = remote->SendRequest( - static_cast(IWindowManager::WindowManagerMessage::TRANS_ID_UNREGISTER_WINDOW_MANAGER_AGENT), - data, reply, option); - if (error != ERR_NONE) { - LOGE(PRI_DOMAIN, PRI_TAG, "SendRequest failed"); - return error; - } - - return reply.ReadInt32(); -} -} // namespace AccessToken -} // namespace Security -} // namespace OHOS diff --git a/services/common/window_manager/test/BUILD.gn b/services/common/window_manager/test/BUILD.gn deleted file mode 100644 index 0a126623005fa597be339d4e4aea6c011cad080b..0000000000000000000000000000000000000000 --- a/services/common/window_manager/test/BUILD.gn +++ /dev/null @@ -1,62 +0,0 @@ -# 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. - -import("//build/test.gni") -import("../../../../access_token.gni") - -ohos_unittest("libwindow_manager_test") { - subsystem_name = "accesscontrol" - module_out_path = module_output_path_unittest_accesstoken - sanitize = { - cfi = true - cfi_cross_dso = true - debug = false - } - branch_protector_ret = "pac_ret" - include_dirs = [ - "${access_token_path}/frameworks/common/include", - "${access_token_path}/frameworks/privacy/include", - "${access_token_path}/interfaces/innerkits/accesstoken/include", - "${access_token_path}/interfaces/innerkits/privacy/include", - "${access_token_path}/services/common/window_manager/include", - ] - - sources = [ - "${access_token_path}/services/common/window_manager/src/privacy_mock_session_manager_proxy.cpp", - "${access_token_path}/services/common/window_manager/src/privacy_scene_session_manager_lite_proxy.cpp", - "${access_token_path}/services/common/window_manager/src/privacy_scene_session_manager_proxy.cpp", - "${access_token_path}/services/common/window_manager/src/privacy_session_manager_proxy.cpp", - "${access_token_path}/services/common/window_manager/src/privacy_window_manager_agent.cpp", - "${access_token_path}/services/common/window_manager/src/privacy_window_manager_client.cpp", - "${access_token_path}/services/common/window_manager/src/privacy_window_manager_death_recipient.cpp", - "${access_token_path}/services/common/window_manager/src/privacy_window_manager_proxy.cpp", - "unittest/window_manager_test.cpp", - ] - - cflags_cc = [ "-DHILOG_ENABLE" ] - configs = [ "${access_token_path}/config:coverage_flags" ] - - external_deps = [ - "c_utils:utils", - "hilog:libhilog", - "ipc:ipc_core", - "safwk:system_ability_fwk", - "samgr:samgr_proxy", - "window_manager:libwsutils", - ] -} - -group("unittest") { - testonly = true - deps = [ ":libwindow_manager_test" ] -} diff --git a/services/common/window_manager/test/unittest/window_manager_test.cpp b/services/common/window_manager/test/unittest/window_manager_test.cpp deleted file mode 100644 index c2574d603d2687482737e739ca2754416f53cfcc..0000000000000000000000000000000000000000 --- a/services/common/window_manager/test/unittest/window_manager_test.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2022-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. - */ - -#include -#include -#include -#define private public -#include "privacy_window_manager_client.h" -#undef private - -using namespace testing::ext; - -namespace OHOS { -namespace Security { -namespace AccessToken { -class WindowManagerTest : public testing::Test { -public: - static void SetUpTestCase(void); - static void TearDownTestCase(void); - void SetUp(); - void TearDown(); -}; - -void WindowManagerTest::SetUpTestCase() {} -void WindowManagerTest::TearDownTestCase() {} -void WindowManagerTest::SetUp() {} -void WindowManagerTest::TearDown() {} - -/** - * @tc.name: GetWMSProxy001 - * @tc.desc: GetWMSProxy. - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(WindowManagerTest, GetWMSProxy001, TestSize.Level1) { - PrivacyWindowManagerClient::GetInstance().GetWMSProxy(); - EXPECT_NE(nullptr, PrivacyWindowManagerClient::GetInstance().wmsProxy_); -} - -/** - * @tc.name: OnRemoteDiedHandle001 - * @tc.desc: OnRemoteDiedHandle. - * @tc.type: FUNC - * @tc.require: - */ -HWTEST_F(WindowManagerTest, OnRemoteDiedHandle001, TestSize.Level1) { - PrivacyWindowManagerClient::GetInstance().OnRemoteDiedHandle(); - EXPECT_EQ(nullptr, PrivacyWindowManagerClient::GetInstance().wmsProxy_); -} - -} // namespace AccessToken -} // namespace Security -} // namespace OHOS diff --git a/services/privacymanager/BUILD.gn b/services/privacymanager/BUILD.gn index 3918d3409a19160dc007a11936a9b72c03ecb088..d3676311ebac964ad47c9152ba489d4df51fb77c 100644 --- a/services/privacymanager/BUILD.gn +++ b/services/privacymanager/BUILD.gn @@ -240,23 +240,6 @@ if (is_standard_system && ability_base_enable == true) { sources += [ "src/common/privacy_common_event_subscriber.cpp" ] } - if (window_manager_enable && access_token_camera_float_window_enable) { - cflags_cc += [ "-DCAMERA_FLOAT_WINDOW_ENABLE" ] - include_dirs += - [ "${access_token_path}/services/common/window_manager/include" ] - sources += [ - "${access_token_path}/services/common/window_manager/src/privacy_mock_session_manager_proxy.cpp", - "${access_token_path}/services/common/window_manager/src/privacy_scene_session_manager_lite_proxy.cpp", - "${access_token_path}/services/common/window_manager/src/privacy_scene_session_manager_proxy.cpp", - "${access_token_path}/services/common/window_manager/src/privacy_session_manager_proxy.cpp", - "${access_token_path}/services/common/window_manager/src/privacy_window_manager_agent.cpp", - "${access_token_path}/services/common/window_manager/src/privacy_window_manager_client.cpp", - "${access_token_path}/services/common/window_manager/src/privacy_window_manager_death_recipient.cpp", - "${access_token_path}/services/common/window_manager/src/privacy_window_manager_proxy.cpp", - ] - external_deps += [ "window_manager:libwsutils" ] - } - if (access_token_app_security_privacy_service_enable) { cflags_cc += [ "-DAPP_SECURITY_PRIVACY_SERVICE" ] } else { diff --git a/services/privacymanager/include/record/permission_record_manager.h b/services/privacymanager/include/record/permission_record_manager.h index 17f738733380a00281e40aa39a4eaf0cbe49d2e1..5353f27307293a67cf9da338dadcaec829ea38c1 100644 --- a/services/privacymanager/include/record/permission_record_manager.h +++ b/services/privacymanager/include/record/permission_record_manager.h @@ -39,9 +39,6 @@ #include "permission_used_result.h" #include "permission_used_type_info.h" #include "privacy_param.h" -#ifdef CAMERA_FLOAT_WINDOW_ENABLE -#include "privacy_window_manager_agent.h" -#endif #include "rwlock.h" #include "safe_map.h" #include "thread_pool.h" @@ -110,10 +107,6 @@ public: void SetLockScreenStatus(int32_t lockScreenStatus); int32_t GetLockScreenStatus(bool isIpc = false); -#ifdef CAMERA_FLOAT_WINDOW_ENABLE - void NotifyCameraWindowChange(bool isPip, AccessTokenID tokenId, bool isShowing); - void OnWindowMgrRemoteDied(); -#endif void OnAppMgrRemoteDiedHandle(); void OnAudioMgrRemoteDiedHandle(); void OnCameraMgrRemoteDiedHandle(); @@ -180,10 +173,6 @@ private: const PermissionUsedType type); void AddDataValueToResults(const GenericValues value, std::vector& results); -#ifdef CAMERA_FLOAT_WINDOW_ENABLE - bool HasUsingCamera(); - void ClearWindowShowing(); -#endif bool IsCameraWindowShow(AccessTokenID tokenId); uint64_t GetUniqueId(uint32_t tokenId, int32_t pid) const; bool RegisterWindowCallback(); @@ -238,22 +227,6 @@ private: std::mutex foreReminderMutex_; std::vector foreTokenIdList_; -#ifdef CAMERA_FLOAT_WINDOW_ENABLE - std::mutex windowMutex_; - bool isWmRegistered = false; - sptr floatWindowCallback_ = nullptr; - sptr pipWindowCallback_ = nullptr; - - std::mutex windowStatusMutex_; - // camera float window - bool camFloatWindowShowing_ = false; - AccessTokenID floatWindowTokenId_ = 0; - - // pip window - bool pipWindowShowing_ = false; - AccessTokenID pipWindowTokenId_ = 0; -#endif - // record config int32_t recordSizeMaximum_ = 0; int32_t recordAgingTime_ = 0; diff --git a/services/privacymanager/src/record/permission_record_manager.cpp b/services/privacymanager/src/record/permission_record_manager.cpp index 92cd94d658539fe4c488c3de7f851b8d8ab01d77..eec8d2ab982b3d6b9c11102e6924525edf7da0a8 100644 --- a/services/privacymanager/src/record/permission_record_manager.cpp +++ b/services/privacymanager/src/record/permission_record_manager.cpp @@ -48,10 +48,6 @@ #include "state_change_callback_proxy.h" #include "system_ability_definition.h" #include "time_util.h" -#ifdef CAMERA_FLOAT_WINDOW_ENABLE -#include "privacy_window_manager_client.h" -#include "scene_board_judgement.h" -#endif namespace OHOS { namespace Security { @@ -974,7 +970,9 @@ 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->pid == pid) && (it->status != PERM_INACTIVE) && (it->status != status)) { + if ((it->tokenId == tokenId) && // tokenId + ((it->pid == -1) || (it->pid == pid)) && // pid + ((it->status != PERM_INACTIVE) && (it->status != status))) { // status std::string perm; Constant::TransferOpcodeToPermission(it->opCode, perm); if ((GetMuteStatus(perm, EDM)) || (!GetGlobalSwitchStatus(perm))) { @@ -982,14 +980,7 @@ void PermissionRecordManager::ExecuteAndUpdateRecord(uint32_t tokenId, int32_t p continue; } - // app use camera background without float window - bool isShow = IsCameraWindowShow(tokenId); - bool isAllowedBackGround = false; - if (AccessTokenKit::VerifyAccessToken(tokenId, "ohos.permission.CAMERA_BACKGROUND") == PERMISSION_GRANTED) { - isAllowedBackGround = true; - } - if ((perm == CAMERA_PERMISSION_NAME) && (status == PERM_ACTIVE_IN_BACKGROUND) && - (!isShow) && (!isAllowedBackGround)) { + if ((perm == CAMERA_PERMISSION_NAME) && (status == PERM_ACTIVE_IN_BACKGROUND)) { LOGI(PRI_DOMAIN, PRI_TAG, "Camera float window is close!"); camPermList.emplace_back(perm); ++it; @@ -1022,7 +1013,12 @@ void PermissionRecordManager::ExecuteAndUpdateRecord(uint32_t tokenId, int32_t p void PermissionRecordManager::NotifyAppStateChange(AccessTokenID tokenId, int32_t pid, ActiveChangeType status) { LOGI(PRI_DOMAIN, PRI_TAG, "Id %{public}u, pid %{public}d, status %{public}d", tokenId, pid, status); - // find permissions from startRecordList_ by tokenId which status diff from currStatus + + // only handle camera turn background now, send callback only when app without process foreground + if (GetAppStatus(tokenId) == PERM_ACTIVE_IN_FOREGROUND) { + return; + } + ExecuteAndUpdateRecord(tokenId, pid, status); } @@ -1283,7 +1279,8 @@ void PermissionRecordManager::ExecuteCameraCallbackAsync(AccessTokenID tokenId, LOGI(PRI_DOMAIN, PRI_TAG, "ExecuteCameraCallbackAsync task called."); auto it = [&](uint64_t id, sptr cameraCallback) { auto callback = iface_cast(cameraCallback); - if ((uniqueId == id) && (callback != nullptr)) { + int32_t pid = static_cast(id >> 32); + if (((pid == 0) || (uniqueId == id)) && (callback != nullptr)) { LOGI(PRI_DOMAIN, PRI_TAG, "CameraCallback tokenId(%{public}u) pid( %{public}d) changeType %{public}d", tokenId, pid, PERM_INACTIVE); callback->StateChangeNotify(tokenId, false); @@ -1362,10 +1359,6 @@ int32_t PermissionRecordManager::StartUsingPermission(const PermissionUsedTypeIn #endif uint64_t id = GetUniqueId(tokenId, info.pid); cameraCallbackMap_.EnsureInsert(id, callback); - if (!RegisterWindowCallback()) { - cameraCallbackMap_.Erase(id); - return PrivacyError::ERR_WINDOW_CALLBACK_FAILED; - } int32_t ret = AddRecordToStartList(info, status, callerPid); if (ret != RET_SUCCESS) { cameraCallbackMap_.Erase(id); @@ -1743,79 +1736,6 @@ bool PermissionRecordManager::Register() return true; } -#ifdef CAMERA_FLOAT_WINDOW_ENABLE -bool PermissionRecordManager::HasUsingCamera() -{ - std::lock_guard lock(startRecordListMutex_); - bool hasCamera = std::any_of(startRecordList_.begin(), startRecordList_.end(), - [](const auto& record) { return record.opCode == Constant::OP_CAMERA; }); - return hasCamera; -} - -void UpdateCameraFloatWindowStatus(AccessTokenID tokenId, bool isShowing) -{ - PermissionRecordManager::GetInstance().NotifyCameraWindowChange(false, tokenId, isShowing); -} - -void UpdatePipWindowStatus(AccessTokenID tokenId, bool isShowing) -{ - PermissionRecordManager::GetInstance().NotifyCameraWindowChange(true, tokenId, isShowing); -} - -/* Handle window manager die */ -void HandleWindowDied() -{ - PermissionRecordManager::GetInstance().OnWindowMgrRemoteDied(); -} -#endif - -bool PermissionRecordManager::RegisterWindowCallback() -{ -#ifdef CAMERA_FLOAT_WINDOW_ENABLE - LOGI(PRI_DOMAIN, PRI_TAG, "Begin to RegisterWindowCallback."); - - std::lock_guard lock(windowMutex_); - WindowChangeCallback floatCallback = UpdateCameraFloatWindowStatus; - if (floatWindowCallback_ == nullptr) { - floatWindowCallback_ = new (std::nothrow) PrivacyWindowManagerAgent(floatCallback); - if (floatWindowCallback_ == nullptr) { - LOGE(PRI_DOMAIN, PRI_TAG, "Failed to new PrivacyWindowManagerAgent."); - return false; - } - } - ErrCode err = PrivacyWindowManagerClient::GetInstance().RegisterWindowManagerAgent( - WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_CAMERA_FLOAT, floatWindowCallback_); - if (err != ERR_OK) { - LOGE(PRI_DOMAIN, PRI_TAG, "Failed to register float window listener, err:%{public}d", err); - return false; - } - - if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) { - WindowChangeCallback pipCallback = UpdatePipWindowStatus; - - if (pipWindowCallback_ == nullptr) { - pipWindowCallback_ = new (std::nothrow) PrivacyWindowManagerAgent(pipCallback); - if (floatWindowCallback_ == nullptr) { - LOGE(PRI_DOMAIN, PRI_TAG, "Failed to new PrivacyWindowManagerAgent."); - return false; - } - } - - err = PrivacyWindowManagerClient::GetInstance().RegisterWindowManagerAgent( - WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_CAMERA_WINDOW, pipWindowCallback_); - if (err != ERR_OK) { - LOGE(PRI_DOMAIN, PRI_TAG, "Failed to register pip window listener, err:%{public}d", err); - PrivacyWindowManagerClient::GetInstance().UnregisterWindowManagerAgent( - WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_CAMERA_FLOAT, floatWindowCallback_); - return false; - } - } - - PrivacyWindowManagerClient::GetInstance().AddDeathCallback(HandleWindowDied); -#endif - return true; -} - void PermissionRecordManager::InitializeMuteState(const std::string& permissionName) { if (permissionName == MICROPHONE_PERMISSION_NAME) { @@ -1901,72 +1821,8 @@ void PermissionRecordManager::OnCameraMgrRemoteDiedHandle() std::lock_guard lock(camLoadMutex_); isCamLoad_ = false; } -#ifdef CAMERA_FLOAT_WINDOW_ENABLE - ClearWindowShowing(); -#endif } -bool PermissionRecordManager::IsCameraWindowShow(AccessTokenID tokenId) -{ - bool isShow = true; -#ifdef CAMERA_FLOAT_WINDOW_ENABLE - std::lock_guard lock(windowStatusMutex_); - isShow = (((floatWindowTokenId_ == tokenId) && camFloatWindowShowing_) || - ((pipWindowTokenId_ == tokenId) && pipWindowShowing_)); -#endif - return isShow; -} - -#ifdef CAMERA_FLOAT_WINDOW_ENABLE -/* - * when camera float window is not show, notice camera service to use StopUsingPermission - */ -void PermissionRecordManager::NotifyCameraWindowChange(bool isPip, AccessTokenID tokenId, bool isShowing) -{ - LOGI(PRI_DOMAIN, PRI_TAG, "Update window, isPip(%{public}d), id(%{public}u), status(%{public}d)", - isPip, tokenId, isShowing); - { - std::lock_guard lock(windowStatusMutex_); - if (isPip) { - pipWindowShowing_ = isShowing; - pipWindowTokenId_ = tokenId; - } else { - camFloatWindowShowing_ = isShowing; - floatWindowTokenId_ = tokenId; - } - } - if (isShowing) { - LOGI(PRI_DOMAIN, PRI_TAG, "Camera float window is showing!"); - } else { - if ((GetAppStatus(tokenId) == ActiveChangeType::PERM_ACTIVE_IN_BACKGROUND) && - !IsCameraWindowShow(tokenId)) { - LOGI(PRI_DOMAIN, PRI_TAG, "Token(%{public}d) is background, pip and float window is not show.", tokenId); - ExecuteCameraCallbackAsync(tokenId, -1); - } - } -} - -void PermissionRecordManager::ClearWindowShowing() -{ - LOGI(PRI_DOMAIN, PRI_TAG, "Clear window show status."); - { - std::lock_guard lock(windowStatusMutex_); - camFloatWindowShowing_ = false; - floatWindowTokenId_ = 0; - - pipWindowShowing_ = false; - pipWindowTokenId_ = 0; - } -} - -/* Handle window manager die */ -void PermissionRecordManager::OnWindowMgrRemoteDied() -{ - LOGI(PRI_DOMAIN, PRI_TAG, "Handle window manager died."); - ClearWindowShowing(); -} -#endif - void PermissionRecordManager::SetDefaultConfigValue() { recordSizeMaximum_ = DEFAULT_PERMISSION_USED_RECORD_SIZE_MAXIMUM; diff --git a/services/privacymanager/test/coverage/BUILD.gn b/services/privacymanager/test/coverage/BUILD.gn index 76b78de9710f3fa122cacb7d249516943986e046..c8524257df514be7d0d6b85fdd8ff3e3c850b0f0 100644 --- a/services/privacymanager/test/coverage/BUILD.gn +++ b/services/privacymanager/test/coverage/BUILD.gn @@ -132,22 +132,6 @@ if (is_standard_system && ability_base_enable == true) { external_deps += [ "screenlock_mgr:screenlock_client" ] } - if (window_manager_enable && access_token_camera_float_window_enable) { - cflags_cc += [ "-DCAMERA_FLOAT_WINDOW_ENABLE" ] - include_dirs += - [ "${access_token_path}/services/common/window_manager/include" ] - sources += [ - "${access_token_path}/services/common/window_manager/src/privacy_mock_session_manager_proxy.cpp", - "${access_token_path}/services/common/window_manager/src/privacy_scene_session_manager_lite_proxy.cpp", - "${access_token_path}/services/common/window_manager/src/privacy_scene_session_manager_proxy.cpp", - "${access_token_path}/services/common/window_manager/src/privacy_session_manager_proxy.cpp", - "${access_token_path}/services/common/window_manager/src/privacy_window_manager_agent.cpp", - "${access_token_path}/services/common/window_manager/src/privacy_window_manager_client.cpp", - "${access_token_path}/services/common/window_manager/src/privacy_window_manager_death_recipient.cpp", - "${access_token_path}/services/common/window_manager/src/privacy_window_manager_proxy.cpp", - ] - external_deps += [ "window_manager:libwsutils" ] - } if (access_token_app_security_privacy_service_enable) { cflags_cc += [ "-DAPP_SECURITY_PRIVACY_SERVICE" ] } else { 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 bdcf99a3b985619622b3694cf6c3bddec4a0b189..4a8d8a4fe558b5411766f22cc2ccbfe2aaa32ac0 100644 --- a/services/privacymanager/test/coverage/permission_record_manager_coverage_test.cpp +++ b/services/privacymanager/test/coverage/permission_record_manager_coverage_test.cpp @@ -256,10 +256,6 @@ HWTEST_F(PermissionRecordManagerTest, FindRecordsToUpdateAndExecutedTest001, Tes PermissionRecordManager::GetInstance().SetMutePolicy(PolicyType::PRIVACY, CallerType::CAMERA, false, RANDOM_TOKENID); PermissionRecordManager::GetInstance().AddRecordToStartList(MakeInfo(tokenId, PID, permission), status, CALLER_PID); -#ifdef CAMERA_FLOAT_WINDOW_ENABLE - PermissionRecordManager::GetInstance().NotifyCameraWindowChange(false, tokenId, false); - PermissionRecordManager::GetInstance().NotifyCameraWindowChange(true, tokenId, false); -#endif PermissionRecordManager::GetInstance().ExecuteAndUpdateRecord(tokenId, PID, status); PermissionRecordManager::GetInstance().NotifyAppStateChange(tokenId, PID, status); @@ -282,10 +278,6 @@ HWTEST_F(PermissionRecordManagerTest, FindRecordsToUpdateAndExecutedTest002, Tes ActiveChangeType status = PERM_ACTIVE_IN_BACKGROUND; std::string permission = "ohos.permission.MICROPHONE"; PermissionRecordManager::GetInstance().AddRecordToStartList(MakeInfo(tokenId, PID, permission), status, CALLER_PID); -#ifdef CAMERA_FLOAT_WINDOW_ENABLE - PermissionRecordManager::GetInstance().NotifyCameraWindowChange(false, tokenId, false); - PermissionRecordManager::GetInstance().NotifyCameraWindowChange(true, tokenId, false); -#endif PermissionRecordManager::GetInstance().ExecuteAndUpdateRecord(tokenId, PID, status); PermissionRecordManager::GetInstance().NotifyAppStateChange(tokenId, PID, status); @@ -308,10 +300,6 @@ HWTEST_F(PermissionRecordManagerTest, FindRecordsToUpdateAndExecutedTest003, Tes ActiveChangeType status = PERM_ACTIVE_IN_FOREGROUND; std::string permission = "ohos.permission.CAMERA"; PermissionRecordManager::GetInstance().AddRecordToStartList(MakeInfo(tokenId, PID, permission), status, CALLER_PID); -#ifdef CAMERA_FLOAT_WINDOW_ENABLE - PermissionRecordManager::GetInstance().NotifyCameraWindowChange(false, tokenId, false); - PermissionRecordManager::GetInstance().NotifyCameraWindowChange(true, tokenId, false); -#endif PermissionRecordManager::GetInstance().ExecuteAndUpdateRecord(tokenId, PID, status); ASSERT_EQ(RET_SUCCESS, PermissionRecordManager::GetInstance().RemoveRecordFromStartList( @@ -333,10 +321,6 @@ HWTEST_F(PermissionRecordManagerTest, FindRecordsToUpdateAndExecutedTest004, Tes ActiveChangeType status = PERM_ACTIVE_IN_BACKGROUND; std::string permission = "ohos.permission.CAMERA"; PermissionRecordManager::GetInstance().AddRecordToStartList(MakeInfo(tokenId, PID, permission), status, CALLER_PID); -#ifdef CAMERA_FLOAT_WINDOW_ENABLE - PermissionRecordManager::GetInstance().NotifyCameraWindowChange(false, tokenId, false); - PermissionRecordManager::GetInstance().NotifyCameraWindowChange(true, tokenId, false); -#endif PermissionRecordManager::GetInstance().ExecuteAndUpdateRecord(tokenId, PID, status); ASSERT_EQ(RET_SUCCESS, PermissionRecordManager::GetInstance().RemoveRecordFromStartList( diff --git a/services/privacymanager/test/unittest/BUILD.gn b/services/privacymanager/test/unittest/BUILD.gn index c7e4cb58daef7da74b800e4b27e440d5f66bd349..26b021f607fbd0a27ffa77c84b2d74d0d3cd28b2 100644 --- a/services/privacymanager/test/unittest/BUILD.gn +++ b/services/privacymanager/test/unittest/BUILD.gn @@ -139,23 +139,6 @@ if (is_standard_system && ability_base_enable == true) { external_deps += [ "screenlock_mgr:screenlock_client" ] } - if (window_manager_enable && access_token_camera_float_window_enable) { - cflags_cc += [ "-DCAMERA_FLOAT_WINDOW_ENABLE" ] - include_dirs += - [ "${access_token_path}/services/common/window_manager/include" ] - sources += [ - "${access_token_path}/services/common/window_manager/src/privacy_mock_session_manager_proxy.cpp", - "${access_token_path}/services/common/window_manager/src/privacy_scene_session_manager_lite_proxy.cpp", - "${access_token_path}/services/common/window_manager/src/privacy_scene_session_manager_proxy.cpp", - "${access_token_path}/services/common/window_manager/src/privacy_session_manager_proxy.cpp", - "${access_token_path}/services/common/window_manager/src/privacy_window_manager_agent.cpp", - "${access_token_path}/services/common/window_manager/src/privacy_window_manager_client.cpp", - "${access_token_path}/services/common/window_manager/src/privacy_window_manager_death_recipient.cpp", - "${access_token_path}/services/common/window_manager/src/privacy_window_manager_proxy.cpp", - ] - external_deps += [ "window_manager:libwsutils" ] - } - if (access_token_app_security_privacy_service_enable) { cflags_cc += [ "-DAPP_SECURITY_PRIVACY_SERVICE" ] } else { diff --git a/services/privacymanager/test/unittest/permission_record_manager_test.cpp b/services/privacymanager/test/unittest/permission_record_manager_test.cpp index 27776ced7a535a885102a5ebdfd15915cc487d35..d0c524441c704dab74a794e4038fae038fc3bf8c 100644 --- a/services/privacymanager/test/unittest/permission_record_manager_test.cpp +++ b/services/privacymanager/test/unittest/permission_record_manager_test.cpp @@ -580,7 +580,6 @@ 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 @@ -609,28 +608,7 @@ HWTEST_F(PermissionRecordManagerTest, StartUsingPermissionTest009, TestSize.Leve MakeInfo(tokenId, TEST_PID_1, permissionName), callbackWrap1->AsObject(), CALLER_PID)); ASSERT_EQ(RET_SUCCESS, PermissionRecordManager::GetInstance().StartUsingPermission( MakeInfo(tokenId, TEST_PID_2, permissionName), callbackWrap2->AsObject(), CALLER_PID)); - - AppStateData appStateData; - appStateData.accessTokenId = tokenId; - appStateData.state = static_cast(ApplicationState::APP_STATE_FOREGROUND); - appStateData.pid = TEST_PID_1; - appStateObserver_->OnAppStateChanged(appStateData); - appStateData.pid = TEST_PID_2; - appStateObserver_->OnAppStateChanged(appStateData); - - appStateData.state = static_cast(ApplicationState::APP_STATE_BACKGROUND); - appStateData.pid = TEST_PID_1; - appStateObserver_->OnAppStateChanged(appStateData); - usleep(500000); // 500000us = 0.5s - ASSERT_FALSE(callbackPtr1->isShow_); - ASSERT_TRUE(callbackPtr2->isShow_); - - appStateData.pid = TEST_PID_2; - appStateObserver_->OnAppStateChanged(appStateData); - 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 e377c53684e27c9d3790f9369df0d58519edc5f9..0c754da9d51e14173478141e3185ace9e094a14d 100644 --- a/services/privacymanager/test/unittest/privacy_manager_service_test.cpp +++ b/services/privacymanager/test/unittest/privacy_manager_service_test.cpp @@ -217,18 +217,6 @@ HWTEST_F(PrivacyManagerServiceTest, IsAllowedUsingPermission001, TestSize.Level0 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); - ASSERT_EQ(false, PermissionRecordManager::GetInstance().IsAllowedUsingPermission( - tokenId, CAMERA_PERMISSION_NAME, -1)); - - PermissionRecordManager::GetInstance().NotifyCameraWindowChange(false, tokenId, false); - // pip - PermissionRecordManager::GetInstance().NotifyCameraWindowChange(true, tokenId, false); - ASSERT_EQ(false, PermissionRecordManager::GetInstance().IsAllowedUsingPermission( - tokenId, CAMERA_PERMISSION_NAME, -1)); -#endif } /* diff --git a/test/fuzztest/services/privacy/privacy_service_fuzz.gni b/test/fuzztest/services/privacy/privacy_service_fuzz.gni index f833e86570a4e63666d1136821b757b948cf2307..9d01a1e7f8ddd5ddb3e289f00ae1c461bde4c136 100644 --- a/test/fuzztest/services/privacy/privacy_service_fuzz.gni +++ b/test/fuzztest/services/privacy/privacy_service_fuzz.gni @@ -106,23 +106,6 @@ if (common_event_service_enable) { privacy_sources += [ "${access_token_path}/services/privacymanager/src/common/privacy_common_event_subscriber.cpp" ] } -if (window_manager_enable && access_token_camera_float_window_enable) { - privacy_cflags_cc += [ "-DCAMERA_FLOAT_WINDOW_ENABLE" ] - privacy_include_dirs += - [ "${access_token_path}/services/common/window_manager/include" ] - privacy_sources += [ - "${access_token_path}/services/common/window_manager/src/privacy_mock_session_manager_proxy.cpp", - "${access_token_path}/services/common/window_manager/src/privacy_scene_session_manager_lite_proxy.cpp", - "${access_token_path}/services/common/window_manager/src/privacy_scene_session_manager_proxy.cpp", - "${access_token_path}/services/common/window_manager/src/privacy_session_manager_proxy.cpp", - "${access_token_path}/services/common/window_manager/src/privacy_window_manager_agent.cpp", - "${access_token_path}/services/common/window_manager/src/privacy_window_manager_client.cpp", - "${access_token_path}/services/common/window_manager/src/privacy_window_manager_death_recipient.cpp", - "${access_token_path}/services/common/window_manager/src/privacy_window_manager_proxy.cpp", - ] - privacy_external_deps += [ "window_manager:libwsutils" ] -} - if (theme_screenlock_mgr_enable) { privacy_cflags_cc += [ "-DTHEME_SCREENLOCK_MGR_ENABLE" ] privacy_external_deps += [ "screenlock_mgr:screenlock_client" ]