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 BLUETOOTH_DIALOG_H 17 #define BLUETOOTH_DIALOG_H 18 19 #include <cstdint> 20 #include <map> 21 #include <memory> 22 #include <mutex> 23 #include <queue> 24 25 #include "foundation/ability/ability_runtime/interfaces/kits/native/ability/ability_runtime/ability_connection.h" 26 #include "foundation/communication/bluetooth_service/services/bluetooth/service/src/util/timer.h" 27 #include "json/json.h" 28 #include "json/writer.h" 29 #include "raw_address.h" 30 31 namespace OHOS { 32 namespace bluetooth { 33 enum DialogType : uint8_t { 34 PBAP_AUTH_DIALOG = 0x00, 35 MAP_AUTH_DIALOG, 36 AUTO_PLAY_AUTH_DIALOG, 37 }; 38 39 struct DialogInfo { 40 DialogType type; 41 std::string address; 42 uint32_t timeOutMs; 43 std::shared_ptr<utility::Timer> timer; 44 }; 45 46 class BluetoothDialog { 47 public: 48 static bool RequestAuthDialog(DialogInfo& dialog); 49 50 static bool DismissCurAndShowNext(); 51 52 static bool DialogConnectExtension( 53 const std::string commandStr, const std::string bundleName, const std::string abilityName); 54 55 static bool DialogConnectExtensionAbility(const AAFwk::Want& want, const std::string commandStr, 56 const std::string bundleName, const std::string abilityName); 57 58 private: 59 static std::string BuildStartCommand(const std::string& address); 60 61 static bool DisplayDialog(DialogInfo& dialog); 62 }; 63 64 } // namespace bluetooth 65 } // namespace OHOS 66 #endif 67