1 /* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef OHOS_DISTRIBUTED_HARDWARE_COMPONENT_PRIVACY_H 17 #define OHOS_DISTRIBUTED_HARDWARE_COMPONENT_PRIVACY_H 18 19 #include "idistributed_hardware_sink.h" 20 #include "event_handler.h" 21 22 namespace OHOS { 23 namespace DistributedHardware { 24 class ComponentPrivacy : public PrivacyResourcesListener { 25 public: 26 ComponentPrivacy(); 27 virtual ~ComponentPrivacy(); 28 int32_t OnPrivaceResourceMessage(const ResourceEventType &type, const std::string &subtype, 29 const std::string &networkId, bool &isSensitive, bool &isSameAccout) override; 30 int32_t OnResourceInfoCallback(const std::string &subtype, const std::string &networkId, 31 bool &isSensitive, bool &isSameAccout); 32 int32_t StartPrivacePage(const std::string &subtype, const std::string &networkId); 33 int32_t StopPrivacePage(const std::string &subtype); 34 void SetPageFlagTrue(); 35 void SetPageFlagFalse(); 36 bool GetPageFlag(); 37 38 class ComponentEventHandler : public AppExecFwk::EventHandler { 39 public: 40 explicit ComponentEventHandler(const std::shared_ptr<AppExecFwk::EventRunner> runner, 41 ComponentPrivacy *comPrivacy); 42 ~ComponentEventHandler() override; 43 44 void ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event) override; 45 private: 46 void ProcessStartPage(const AppExecFwk::InnerEvent::Pointer &event); 47 void ProcessStopPage(const AppExecFwk::InnerEvent::Pointer &event); 48 49 ComponentPrivacy *comPrivacyObj_; 50 }; 51 52 private: 53 std::string DeviceTypeToString(uint16_t deviceTypeId); 54 void HandleClosePage(const std::string &subtype); 55 void HandlePullUpPage(const std::string &subtype, const std::string &networkId); 56 57 std::shared_ptr<ComponentPrivacy::ComponentEventHandler> eventHandler_; 58 std::atomic<bool> isPrivacePageOpen_ = false; 59 }; 60 } // namespace DistributedHardware 61 } // namespace OHOS 62 #endif 63