1 /* 2 * Copyright (c) 2021 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_DM_ABILITY_MANAGER_H 17 #define OHOS_DM_ABILITY_MANAGER_H 18 19 #include <string> 20 #include <vector> 21 #include <mutex> 22 #include <semaphore.h> 23 24 #include "single_instance.h" 25 26 namespace OHOS { 27 namespace DistributedHardware { 28 enum AbilityRole : int32_t { 29 ABILITY_ROLE_PASSIVE = 0, 30 ABILITY_ROLE_INITIATIVE = 1, 31 ABILITY_ROLE_UNKNOWN = 2 32 }; 33 34 enum AbilityStatus : int32_t { 35 ABILITY_STATUS_FAILED = 0, 36 ABILITY_STATUS_SUCCESS = 1, 37 ABILITY_STATUS_START = 2 38 }; 39 40 typedef enum FaAction { 41 USER_OPERATION_TYPE_ALLOW_AUTH = 0, 42 USER_OPERATION_TYPE_CANCEL_AUTH = 1, 43 USER_OPERATION_TYPE_AUTH_CONFIRM_TIMEOUT = 2, 44 USER_OPERATION_TYPE_CANCEL_PINCODE_DISPLAY = 3, 45 USER_OPERATION_TYPE_CANCEL_PINCODE_INPUT = 4 46 } FaAction; 47 48 class DmAbilityManager { 49 DECLARE_SINGLE_INSTANCE(DmAbilityManager); 50 public: 51 AbilityRole GetAbilityRole(); 52 AbilityStatus StartAbility(AbilityRole role); 53 void StartAbilityDone(); 54 55 private: 56 void waitForTimeout(uint32_t timeout_s); 57 58 private: 59 sem_t mSem_; 60 AbilityStatus mStatus_; 61 AbilityRole mAbilityStatus_; 62 }; 63 } // namespace DistributedHardware 64 } // namespace OHOS 65 #endif 66