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 #ifndef AUDIO_DIALOG_ABILITY_CONNECTION_H 16 #define AUDIO_DIALOG_ABILITY_CONNECTION_H 17 18 #include <queue> 19 #include <string> 20 #include <atomic> 21 #include <mutex> 22 #include <element_name.h> 23 #include <ability_connect_callback_interface.h> 24 #include "ability_connect_callback_stub.h" 25 #include "audio_errors.h" 26 #include "audio_policy_log.h" 27 28 namespace OHOS { 29 namespace AudioStandard { 30 constexpr int32_t WAIT_DIALOG_CLOSE_TIME_S = 3; 31 constexpr int32_t MESSAGE_PARCEL_KEY_SIZE = 3; 32 constexpr int32_t SYS_DIALOG_TYPE_UPPER = 2; 33 class AudioDialogAbilityConnection : public OHOS::AAFwk::AbilityConnectionStub { 34 public: 35 AudioDialogAbilityConnection() = default; 36 virtual ~AudioDialogAbilityConnection() = default; 37 38 void OnAbilityConnectDone(const AppExecFwk::ElementName &element, const sptr<IRemoteObject> &remoteObject, 39 int resultCode) override; 40 41 void OnAbilityDisconnectDone(const AppExecFwk::ElementName &element, int resultCode) override; 42 43 static std::atomic<bool> isDialogDestroy_; 44 static std::condition_variable dialogCondition_; 45 private: 46 std::mutex mutex_; 47 }; 48 } // namespace AudioStandard 49 } // namespace OHOS 50 #endif // AUDIO_DIALOG_ABILITY_CONNECTION_H 51