• 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 OHOS_DM_DIALOG_MANAGER_H
17 #define OHOS_DM_DIALOG_MANAGER_H
18 
19 #include <semaphore.h>
20 #include <mutex>
21 
22 #include "ability_connect_callback_interface.h"
23 #include "ability_connect_callback_stub.h"
24 
25 #include "single_instance.h"
26 
27 namespace OHOS {
28 namespace DistributedHardware {
29 class DmDialogManager {
30 public:
31     DmDialogManager();
32     ~DmDialogManager();
33     void ConnectExtension();
34     void ShowConfirmDialog(const std::string param);
35     void ShowPinDialog(const std::string param);
36     void ShowInputDialog(const std::string param);
GetBundleName()37     static std::string GetBundleName()
38     {
39         return bundleName_;
40     }
41 
GetAbilityName()42     static std::string GetAbilityName()
43     {
44         return abilityName_;
45     }
46 
GetPinCode()47     static std::string GetPinCode()
48     {
49         return pinCode_;
50     }
51 
GetDeviceName()52     static std::string GetDeviceName()
53     {
54         return deviceName_;
55     }
56 
GetAppOperationStr()57     static std::string GetAppOperationStr()
58     {
59         return appOperationStr_;
60     }
61 
GetCustomDescriptionStr()62     static std::string GetCustomDescriptionStr()
63     {
64         return customDescriptionStr_;
65     }
66 
GetDeviceType()67     static int32_t GetDeviceType()
68     {
69         return deviceType_;
70     }
71 
GetTargetDeviceName()72     static std::string GetTargetDeviceName()
73     {
74         return targetDeviceName_;
75     }
76 private:
77     class DialogAbilityConnection : public OHOS::AAFwk::AbilityConnectionStub {
78     public:
79         void OnAbilityConnectDone(
80             const AppExecFwk::ElementName& element, const sptr<IRemoteObject>& remoteObject, int resultCode) override;
81         void OnAbilityDisconnectDone(const AppExecFwk::ElementName& element, int resultCode) override;
82 
83     private:
84         std::mutex mutex_;
85     };
86 
87     static std::string bundleName_;
88     static std::string abilityName_;
89     static std::string deviceName_;
90     static std::string targetDeviceName_;
91     static std::string appOperationStr_;
92     static std::string customDescriptionStr_;
93     static std::string pinCode_;
94     static int32_t deviceType_;
95     static std::atomic<bool> isDialogDestroy_;
96     static std::condition_variable dialogCondition_;
97     sptr<OHOS::AAFwk::IAbilityConnection> dialogConnectionCallback_ {nullptr};
98 };
99 } // namespace DistributedHardware
100 } // namespace OHOS
101 #endif
102