1 /* 2 * Copyright (c) 2022 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 #include "pin_auth_ui.h" 17 18 #include "dm_ability_manager.h" 19 #include "dm_constants.h" 20 #include "dm_log.h" 21 #include "nlohmann/json.hpp" 22 23 namespace OHOS { 24 namespace DistributedHardware { PinAuthUi()25PinAuthUi::PinAuthUi() 26 { 27 LOGI("AuthUi constructor"); 28 } 29 ShowPinDialog(int32_t code,std::shared_ptr<DmAuthManager> authManager)30int32_t PinAuthUi::ShowPinDialog(int32_t code, std::shared_ptr<DmAuthManager> authManager) 31 { 32 LOGI("ShowConfigDialog end"); 33 return DM_OK; 34 } 35 InputPinDialog(std::shared_ptr<DmAuthManager> authManager)36int32_t PinAuthUi::InputPinDialog(std::shared_ptr<DmAuthManager> authManager) 37 { 38 LOGI("InputPinDialog start"); 39 std::shared_ptr<DmAbilityManager> dmAbilityManager_ = std::make_shared<DmAbilityManager>(); 40 LOGI("InputPinDialog end"); 41 return StartFaUiService(dmAbilityManager_); 42 } 43 ClosePage(const int32_t & pageId,std::shared_ptr<DmAuthManager> authManager)44int32_t ClosePage(const int32_t &pageId, std::shared_ptr<DmAuthManager> authManager) 45 { 46 LOGI("ClosePage hap start"); 47 if (authManager == nullptr) { 48 LOGE("PinAuthUi::authManager is null"); 49 return ERR_DM_FAILED; 50 } 51 LOGI("ClosePage hap end"); 52 authManager->CancelDisplay(); 53 return DM_OK; 54 } 55 StartFaUiService(std::shared_ptr<DmAbilityManager> dmAbilityManager)56int32_t PinAuthUi::StartFaUiService(std::shared_ptr<DmAbilityManager> dmAbilityManager) 57 { 58 AbilityStatus status = dmAbilityManager->StartAbility(AbilityRole::ABILITY_ROLE_INITIATIVE); 59 if (status != AbilityStatus::ABILITY_STATUS_SUCCESS) { 60 LOGE("PinAuthUi::StartFaUiService timeout"); 61 return ERR_DM_FAILED; 62 } 63 return DM_OK; 64 } 65 UpdatePinDialog(int32_t pageId)66int32_t PinAuthUi::UpdatePinDialog(int32_t pageId) 67 { 68 return DM_OK; 69 } 70 } // namespace DistributedHardware 71 } // namespace OHOS 72