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