• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 USER_AUTH_MODAL_CALLBACK_H
17 #define USER_AUTH_MODAL_CALLBACK_H
18 
19 #include <string>
20 
21 #include "modal_extension_callback.h"
22 #include "user_auth_modal_client_callback.h"
23 
24 namespace OHOS {
25 namespace UserIam {
26 namespace UserAuth {
27 class UserAuthModalCallback : public UserAuthModalClientCallback {
28 public:
29     explicit UserAuthModalCallback(const std::shared_ptr<AbilityRuntime::Context> context);
30     ~UserAuthModalCallback();
31     void SendCommand(uint64_t contextId, const std::string &cmdData) override;
32     bool IsModalInit() override;
33     bool IsModalDestroy() override;
34 
35 private:
36     void CancelAuthentication(uint64_t contextId, int32_t cancelReason) override;
37     Ace::UIContent* InitAndGetUIContent(const std::shared_ptr<OHOS::AbilityRuntime::Context> context);
38     bool CreateUIExtension(const std::shared_ptr<OHOS::AbilityRuntime::Context> context, uint64_t contextId,
39         const std::string &cmdData);
40     void ReleaseModal();
41 
42     std::shared_ptr<AbilityRuntime::Context> context_ {nullptr};
43     std::shared_ptr<ModalExtensionCallback> uiExtCallback_ {nullptr};
44     uint64_t contextId_ {0};
45     bool isInit_ {false};
46     bool isInitError_ {false};
47     std::recursive_mutex mutex_;
48 };
49 } // namespace UserAuth
50 } // namespace UserIam
51 } // namespace OHOS
52 #endif // USER_AUTH_MODAL_CALLBACK_H