1 /* 2 * Copyright (c) 2021-2025 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_ENABLE_TASK_H 17 #define OHOS_DISTRIBUTED_HARDWARE_ENABLE_TASK_H 18 19 #include "task.h" 20 21 namespace OHOS { 22 namespace DistributedHardware { 23 class EnableTask : public Task { 24 public: 25 EnableTask() = delete; 26 EnableTask(const std::string &networkId, const std::string &uuid, const std::string &udid, 27 const std::string &dhId, const DHType dhType); 28 virtual ~EnableTask(); 29 virtual void DoTask(); 30 31 void SetEffectSink(bool isEffect); 32 bool GetEffectSink(); 33 void SetEffectSource(bool isEffect); 34 bool GetEffectSource(); 35 void SetCallingUid(int32_t callingUid); 36 int32_t GetCallingUid(); 37 void SetCallingPid(int32_t callingPid); 38 int32_t GetCallingPid(); 39 40 private: 41 /* synchronous function for register distributed hardware, return on asynchronous register finish */ 42 int32_t RegisterHardware(); 43 void DoTaskInner(); 44 int32_t DoAutoEnable(); 45 int32_t DoActiveEnable(); 46 47 private: 48 // effect sink 49 bool effectSink_{ false }; 50 // effect source 51 bool effectSource_{ false }; 52 // enable or disable calling uid 53 int32_t callingUid_{ 0 }; 54 // enable or disable calling pid 55 int32_t callingPid_{ 0 }; 56 }; 57 } // namespace DistributedHardware 58 } // namespace OHOS 59 #endif 60