• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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()25 PinAuthUi::PinAuthUi()
26 {
27     LOGI("AuthUi constructor");
28 }
29 
ShowPinDialog(int32_t code,std::shared_ptr<DmAuthManager> authManager)30 int32_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)36 int32_t PinAuthUi::InputPinDialog(std::shared_ptr<DmAuthManager> authManager)
37 {
38     LOGI("InputPinDialog start");
39     std::shared_ptr<DmAbilityManager> dmAbilityManager_ = std::make_shared<DmAbilityManager>();
40     return StartFaUiService(dmAbilityManager_);
41 }
42 
ClosePage(const int32_t & pageId,std::shared_ptr<DmAuthManager> authManager)43 int32_t ClosePage(const int32_t &pageId, std::shared_ptr<DmAuthManager> authManager)
44 {
45     LOGI("ClosePage hap start");
46     if (authManager == nullptr) {
47         LOGE("PinAuthUi::authManager is null");
48         return ERR_DM_FAILED;
49     }
50     LOGI("ClosePage hap end");
51     authManager->CancelDisplay();
52     return DM_OK;
53 }
54 
StartFaUiService(std::shared_ptr<DmAbilityManager> dmAbilityManager)55 int32_t PinAuthUi::StartFaUiService(std::shared_ptr<DmAbilityManager> dmAbilityManager)
56 {
57     AbilityStatus status = dmAbilityManager->StartAbility(AbilityRole::ABILITY_ROLE_INITIATIVE);
58     if (status != AbilityStatus::ABILITY_STATUS_SUCCESS) {
59         LOGE("PinAuthUi::StartFaUiService timeout");
60         return ERR_DM_FAILED;
61     }
62     return DM_OK;
63 }
64 
UpdatePinDialog(int32_t pageId)65 int32_t PinAuthUi::UpdatePinDialog(int32_t pageId)
66 {
67     return DM_OK;
68 }
69 } // namespace DistributedHardware
70 } // namespace OHOS
71