• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024-2025 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 "dm_single_instance.h"
26 
27 namespace OHOS {
28 namespace DistributedHardware {
29 class DmDialogManager {
30     DM_DECLARE_SINGLE_INSTANCE_BASE(DmDialogManager);
31 public:
32     void ConnectExtension();
33     void ShowConfirmDialog(const std::string param);
34     void ShowPinDialog(const std::string param);
35     void ShowInputDialog(const std::string param);
36     void CloseDialog();
37     void OnAbilityConnectDone(
38         const AppExecFwk::ElementName& element, const sptr<IRemoteObject>& remoteObject, int resultCode);
39     void OnAbilityDisconnectDone(const AppExecFwk::ElementName& element, int resultCode);
40 private:
41     DmDialogManager();
42     ~DmDialogManager();
43     void SendMsgRequest(const sptr<IRemoteObject>& remoteObject);
44     class DialogAbilityConnection : public OHOS::AAFwk::AbilityConnectionStub {
45     public:
46         void OnAbilityConnectDone(
47             const AppExecFwk::ElementName& element, const sptr<IRemoteObject>& remoteObject, int resultCode) override;
48         void OnAbilityDisconnectDone(const AppExecFwk::ElementName& element, int resultCode) override;
49     };
50 
51     std::string bundleName_;
52     std::string abilityName_;
53     std::string deviceName_;
54     std::string targetDeviceName_;
55     std::string appOperationStr_;
56     std::string customDescriptionStr_;
57     std::string pinCode_;
58     std::string hostPkgLabel_;
59     int32_t deviceType_ = -1;
60     bool isProxyBind_ = false;
61     std::string appUserData_;
62     std::string title_;
63     std::mutex mutex_;
64     sptr<OHOS::AAFwk::IAbilityConnection> dialogConnectionCallback_ = nullptr;
65     sptr<IRemoteObject> g_remoteObject = nullptr;
66     std::atomic<bool> isConnectSystemUI_{false};
67     std::atomic<bool> isCloseDialog_{false};
68 };
69 } // namespace DistributedHardware
70 } // namespace OHOS
71 #endif
72