已合并
anco name #16836
GaoYJ_61创建于 14 天前
anco name #16836
已合并
共 10 个文件变更+63-12
| @@ -350,6 +350,7 @@ private: | |||
| 350 | std::atomic<uint32_t> switchStreamInNewThreadTaskCount_ = 0; | 350 | std::atomic<uint32_t> switchStreamInNewThreadTaskCount_ = 0; |
| 351 | std::string bundleNameByUid_ = ""; | 351 | std::string bundleNameByUid_ = ""; |
| 352 | std::string bundleNameByAppUid_ = ""; | 352 | std::string bundleNameByAppUid_ = ""; |
| 353 | + std::string ancoBundleName_ = ""; | ||
| 353 | 354 | ||
| 354 | AudioLoopThread taskLoop_ = AudioLoopThread("OS_Recreate"); | 355 | AudioLoopThread taskLoop_ = AudioLoopThread("OS_Recreate"); |
| 355 | int32_t audioHapticsSyncId_ = 0; | 356 | int32_t audioHapticsSyncId_ = 0; |
| @@ -466,6 +466,7 @@ void AudioRendererPrivate::HandleSetRendererInfoByOptions(const AudioRendererOpt | |||
| 466 | rendererInfo_.isCallWaitingTone = rendererOptions.rendererInfo.isCallWaitingTone; | 466 | rendererInfo_.isCallWaitingTone = rendererOptions.rendererInfo.isCallWaitingTone; |
| 467 | strategy_ = rendererOptions.strategy; | 467 | strategy_ = rendererOptions.strategy; |
| 468 | originalStrategy_ = rendererOptions.strategy; | 468 | originalStrategy_ = rendererOptions.strategy; |
| 469 | + ancoBundleName_ = rendererOptions.ancoBundleName; | ||
| 469 | } | 470 | } |
| 470 | 471 | ||
| 471 | std::shared_ptr<AudioRendererPrivate> AudioRenderer::CreateAndInitRendererObject( | 472 | std::shared_ptr<AudioRendererPrivate> AudioRenderer::CreateAndInitRendererObject( |
| @@ -712,6 +713,7 @@ int32_t AudioRendererPrivate::InitAudioInterruptCallback(bool isRestoreAudio) | |||
| 712 | audioInterrupt_.api = rendererInfo_.playerType; | 713 | audioInterrupt_.api = rendererInfo_.playerType; |
| 713 | audioInterrupt_.isCallWaitingTone = rendererInfo_.isCallWaitingTone; | 714 | audioInterrupt_.isCallWaitingTone = rendererInfo_.isCallWaitingTone; |
| 714 | audioInterrupt_.bundleName = audioStream_->GetBundleName(); | 715 | audioInterrupt_.bundleName = audioStream_->GetBundleName(); |
| 716 | + audioInterrupt_.ancoBundleName = ancoBundleName_; | ||
| 715 | if (audioInterrupt_.bundleName.empty()) { | 717 | if (audioInterrupt_.bundleName.empty()) { |
| 716 | audioInterrupt_.bundleName = AppBundleManager::GetSelfBundleName(); | 718 | audioInterrupt_.bundleName = AppBundleManager::GetSelfBundleName(); |
| 717 | } | 719 | } |
| @@ -1351,6 +1351,7 @@ struct AudioRendererOptions { | |||
| 1351 | AudioPrivacyType privacyType = PRIVACY_TYPE_PUBLIC; | 1351 | AudioPrivacyType privacyType = PRIVACY_TYPE_PUBLIC; |
| 1352 | AudioSessionStrategy strategy = { AudioConcurrencyMode::INVALID }; | 1352 | AudioSessionStrategy strategy = { AudioConcurrencyMode::INVALID }; |
| 1353 | AppInfo appInfo; | 1353 | AppInfo appInfo; |
| 1354 | + std::string ancoBundleName; | ||
| 1354 | }; | 1355 | }; |
| 1355 | 1356 | ||
| 1356 | struct BufferQueueState { | 1357 | struct BufferQueueState { |
| @@ -340,6 +340,7 @@ public: | |||
| 340 | bool activatedRegisterCallbackFlag = false; | 340 | bool activatedRegisterCallbackFlag = false; |
| 341 | bool isCallWaitingTone = false; | 341 | bool isCallWaitingTone = false; |
| 342 | bool isCheckMuteStream = false; | 342 | bool isCheckMuteStream = false; |
| 343 | + std::string ancoBundleName = ""; | ||
| 343 | // no serialization required | 344 | // no serialization required |
| 344 | bool voipCaptureMixWithOthersFlag = false; | 345 | bool voipCaptureMixWithOthersFlag = false; |
| 345 | 346 | ||
| @@ -410,6 +411,7 @@ public: | |||
| 410 | res = res && parcel.WriteBool(interrupt.activatedRegisterCallbackFlag); | 411 | res = res && parcel.WriteBool(interrupt.activatedRegisterCallbackFlag); |
| 411 | res = res && parcel.WriteBool(interrupt.isCallWaitingTone); | 412 | res = res && parcel.WriteBool(interrupt.isCallWaitingTone); |
| 412 | res = res && parcel.WriteBool(interrupt.isCheckMuteStream); | 413 | res = res && parcel.WriteBool(interrupt.isCheckMuteStream); |
| 414 | + res = res && parcel.WriteString(interrupt.ancoBundleName); | ||
| 413 | return res; | 415 | return res; |
| 414 | } | 416 | } |
| 415 | static void Unmarshalling(Parcel &parcel, AudioInterrupt &interrupt) | 417 | static void Unmarshalling(Parcel &parcel, AudioInterrupt &interrupt) |
| @@ -452,6 +454,7 @@ public: | |||
| 452 | interrupt.activatedRegisterCallbackFlag = parcel.ReadBool(); | 454 | interrupt.activatedRegisterCallbackFlag = parcel.ReadBool(); |
| 453 | interrupt.isCallWaitingTone = parcel.ReadBool(); | 455 | interrupt.isCallWaitingTone = parcel.ReadBool(); |
| 454 | interrupt.isCheckMuteStream = parcel.ReadBool(); | 456 | interrupt.isCheckMuteStream = parcel.ReadBool(); |
| 457 | + interrupt.ancoBundleName = parcel.ReadString(); | ||
| 455 | } | 458 | } |
| 456 | 459 | ||
| 457 | bool Marshalling(Parcel &parcel) const override | 460 | bool Marshalling(Parcel &parcel) const override |
| @@ -24,10 +24,6 @@ | |||
| 24 | 24 | ||
| 25 | 25 | ||
| 26 | 26 | ||
| 27 | - | ||
| 28 | - | ||
| 29 | - | ||
| 30 | - | ||
| 31 | namespace OHOS { | 27 | namespace OHOS { |
| 32 | namespace AudioStandard { | 28 | namespace AudioStandard { |
| 33 | 29 | ||
| @@ -44,9 +40,8 @@ private: | |||
| 44 | 40 | ||
| 45 | void UpdateMuteAudioFocusStrategy(const AudioInterrupt ¤tInterrupt, | 41 | void UpdateMuteAudioFocusStrategy(const AudioInterrupt ¤tInterrupt, |
| 46 | const AudioInterrupt &incomingInterrupt, AudioFocusEntry &focusEntry); | 42 | const AudioInterrupt &incomingInterrupt, AudioFocusEntry &focusEntry); |
| 47 | - void UpdateWindowFocusStrategy(const int32_t ¤tPid, | 43 | + void UpdateWindowFocusStrategy(const AudioInterrupt ¤tInterrupt, |
| 48 | - const int32_t &incomingPid, const AudioStreamType &existStreamType, | 44 | + const AudioInterrupt &incomingInterrupt, AudioFocusEntry &focusEntry); |
| 49 | - const AudioStreamType &incomingStreamType, AudioFocusEntry &focusEntry); | ||
| 50 | void UpdatePauseAudioFocusStrategy(const AudioInterrupt ¤tInterrupt, | 45 | void UpdatePauseAudioFocusStrategy(const AudioInterrupt ¤tInterrupt, |
| 51 | const AudioInterrupt &incomingInterrupt, AudioFocusEntry &focusEntry); | 46 | const AudioInterrupt &incomingInterrupt, AudioFocusEntry &focusEntry); |
| 52 | void UpdateMicFocusByUid(const AudioInterrupt ¤tInterrupt, | 47 | void UpdateMicFocusByUid(const AudioInterrupt ¤tInterrupt, |
| @@ -19,6 +19,10 @@ | |||
| 19 | 19 | ||
| 20 | 20 | ||
| 21 | 21 | ||
| 22 | + | ||
| 23 | + | ||
| 24 | + | ||
| 25 | + | ||
| 22 | namespace OHOS { | 26 | namespace OHOS { |
| 23 | namespace AudioStandard { | 27 | namespace AudioStandard { |
| 24 | 28 | ||
| @@ -28,6 +32,7 @@ public: | |||
| 28 | static uint8_t GetAppState(int32_t appPid); | 32 | static uint8_t GetAppState(int32_t appPid); |
| 29 | static bool IsMediaStream(AudioStreamType audioStreamType); | 33 | static bool IsMediaStream(AudioStreamType audioStreamType); |
| 30 | static bool IsInterPhoneInterrupt(const AudioInterrupt &audioInterrupt); | 34 | static bool IsInterPhoneInterrupt(const AudioInterrupt &audioInterrupt); |
| 35 | + static bool GetWindowState(const AudioInterrupt &audioInterrupt); | ||
| 31 | }; | 36 | }; |
| 32 | 37 | ||
| 33 | } // namespace AudioStandard | 38 | } // namespace AudioStandard |
| @@ -126,9 +126,13 @@ void AudioInterruptStrategy::UpdateMicFocusByUid(const AudioInterrupt ¤tIn | |||
| 126 | } | 126 | } |
| 127 | } | 127 | } |
| 128 | 128 | ||
| 129 | -void AudioInterruptStrategy::UpdateWindowFocusStrategy(const int32_t ¤tPid, const int32_t &incomingPid, | 129 | +void AudioInterruptStrategy::UpdateWindowFocusStrategy(const AudioInterrupt ¤tInterrupt, |
| 130 | - const AudioStreamType &existStreamType, const AudioStreamType &incomingStreamType, AudioFocusEntry &focusEntry) | 130 | + const AudioInterrupt &incomingInterrupt, AudioFocusEntry &focusEntry) |
| 131 | { | 131 | { |
| 132 | + int32_t currentPid = currentInterrupt.pid; | ||
| 133 | + int32_t incomingPid = incomingInterrupt.pid; | ||
| 134 | + AudioStreamType existStreamType = currentInterrupt.audioFocusType.streamType; | ||
| 135 | + AudioStreamType incomingStreamType = incomingInterrupt.audioFocusType.streamType; | ||
| 132 | 136 | ||
| 133 | if (currentPid == incomingPid) { | 137 | if (currentPid == incomingPid) { |
| 134 | return; | 138 | return; |
| @@ -140,8 +144,8 @@ void AudioInterruptStrategy::UpdateWindowFocusStrategy(const int32_t ¤tPid | |||
| 140 | return; | 144 | return; |
| 141 | } | 145 | } |
| 142 | 146 | ||
| 143 | - bool isCurTargetWindowState = WindowUtils::CheckWindowState(currentPid); | 147 | + bool isCurTargetWindowState = AudioInterruptUtils::GetWindowState(currentInterrupt); |
| 144 | - bool isIncomingTargetWindowState = WindowUtils::CheckWindowState(incomingPid); | 148 | + bool isIncomingTargetWindowState = AudioInterruptUtils::GetWindowState(incomingInterrupt); |
| 145 | if (isCurTargetWindowState && isIncomingTargetWindowState) { | 149 | if (isCurTargetWindowState && isIncomingTargetWindowState) { |
| 146 | AUDIO_INFO_LOG("The media windowStates concurrent"); | 150 | AUDIO_INFO_LOG("The media windowStates concurrent"); |
| 147 | focusEntry.hintType = INTERRUPT_HINT_NONE; | 151 | focusEntry.hintType = INTERRUPT_HINT_NONE; |
| @@ -245,7 +249,7 @@ void AudioInterruptStrategy::UpdateAudioFocusStrategy(const AudioInterrupt &curr | |||
| 245 | UpdateMediaWithMixStrategy(currentInterrupt, incomingInterrupt, focusEntry); | 249 | UpdateMediaWithMixStrategy(currentInterrupt, incomingInterrupt, focusEntry); |
| 246 | UpdateMediaWithDuckStrategy(currentInterrupt, incomingInterrupt, focusEntry); | 250 | UpdateMediaWithDuckStrategy(currentInterrupt, incomingInterrupt, focusEntry); |
| 247 | UpdateMicFocusByUid(currentInterrupt, incomingInterrupt, focusEntry); | 251 | UpdateMicFocusByUid(currentInterrupt, incomingInterrupt, focusEntry); |
| 248 | - UpdateWindowFocusStrategy(currentPid, incomingPid, existStreamType, incomingStreamType, focusEntry); | 252 | + UpdateWindowFocusStrategy(currentInterrupt, incomingInterrupt, focusEntry); |
| 249 | UpdateMuteAudioFocusStrategy(currentInterrupt, incomingInterrupt, focusEntry); | 253 | UpdateMuteAudioFocusStrategy(currentInterrupt, incomingInterrupt, focusEntry); |
| 250 | UpdatePauseAudioFocusStrategy(currentInterrupt, incomingInterrupt, focusEntry); | 254 | UpdatePauseAudioFocusStrategy(currentInterrupt, incomingInterrupt, focusEntry); |
| 251 | UpdateAIBaseFocusStrategy(currentInterrupt, incomingInterrupt, focusEntry); | 255 | UpdateAIBaseFocusStrategy(currentInterrupt, incomingInterrupt, focusEntry); |
| @@ -63,5 +63,18 @@ bool AudioInterruptUtils::IsInterPhoneInterrupt(const AudioInterrupt &audioInter | |||
| 63 | return (audioInterrupt.audioFocusType.streamType == STREAM_INTERPHONE || | 63 | return (audioInterrupt.audioFocusType.streamType == STREAM_INTERPHONE || |
| 64 | audioInterrupt.audioFocusType.sourceType == SOURCE_TYPE_INTERPHONE); | 64 | audioInterrupt.audioFocusType.sourceType == SOURCE_TYPE_INTERPHONE); |
| 65 | } | 65 | } |
| 66 | + | ||
| 67 | +bool AudioInterruptUtils::GetWindowState(const AudioInterrupt &audioInterrupt) | ||
| 68 | +{ | ||
| 69 | + | ||
| 70 | + if (audioInterrupt.uid == AUDIO_ID) { | ||
| 71 | + return WindowUtils::CheckAncoWindowState(audioInterrupt.ancoBundleName); | ||
| 72 | + } else { | ||
| 73 | + return WindowUtils::CheckWindowState(audioInterrupt.pid); | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + return false; | ||
| 77 | + | ||
| 78 | +} | ||
| 66 | } // namespace AudioStandard | 79 | } // namespace AudioStandard |
| 67 | } // namespace OHOS | 80 | } // namespace OHOS |
| @@ -16,6 +16,7 @@ | |||
| 16 | 16 | ||
| 17 | 17 | ||
| 18 | 18 | ||
| 19 | + | ||
| 19 | 20 | ||
| 20 | namespace OHOS { | 21 | namespace OHOS { |
| 21 | namespace AudioStandard { | 22 | namespace AudioStandard { |
| @@ -23,6 +24,7 @@ namespace AudioStandard { | |||
| 23 | class WindowUtils { | 24 | class WindowUtils { |
| 24 | public: | 25 | public: |
| 25 | static bool CheckWindowState(const int32_t pid); | 26 | static bool CheckWindowState(const int32_t pid); |
| 27 | + static bool CheckAncoWindowState(const std::string &bundleName); | ||
| 26 | }; | 28 | }; |
| 27 | } | 29 | } |
| 28 | } | 30 | } |
| @@ -64,6 +64,31 @@ static int32_t CheckVirtualDisplay(const int32_t pid, bool &isVirtualDisplay) | |||
| 64 | return SUCCESS; | 64 | return SUCCESS; |
| 65 | } | 65 | } |
| 66 | 66 | ||
| 67 | +bool WindowUtils::CheckAncoWindowState(const std::string &bundleName) | ||
| 68 | +{ | ||
| 69 | + auto sceneSessionManager = Rosen::SessionManagerLite::GetInstance().GetSceneSessionManagerLiteProxy(); | ||
| 70 | + if (sceneSessionManager == nullptr) { | ||
| 71 | + AUDIO_ERR_LOG("sceneSessionManager is null manager"); | ||
| 72 | + return false; | ||
| 73 | + } | ||
| 74 | + std::vector<OHOS::Rosen::MainWindowInfo> mainWindowInfo; | ||
| 75 | + if (sceneSessionManager->GetAllMainWindowInfos(mainWindowInfo) != Rosen::WMError::WM_OK) { | ||
| 76 | + AUDIO_ERR_LOG("GetAllMainWindowInfos failed"); | ||
| 77 | + return false; | ||
| 78 | + } | ||
| 79 | + for (auto &windowInfo : mainWindowInfo) { | ||
| 80 | + AUDIO_DEBUG_LOG("pid:%{public}d app, bundleName = %{public}s", | ||
| 81 | + windowInfo.pid_, windowInfo.bundleName_.c_str()); | ||
| 82 | + if (bundleName == windowInfo.bundleName_) { | ||
| 83 | + bool isforeground = CheckWindowState(windowInfo.pid_); | ||
| 84 | + AUDIO_INFO_LOG("pid:%{public}d app, bundleName = %{public}s, isforeground = %{public}d", | ||
| 85 | + windowInfo.pid_, windowInfo.bundleName_.c_str(), isforeground); | ||
| 86 | + return isforeground; | ||
| 87 | + } | ||
| 88 | + } | ||
| 89 | + return false; | ||
| 90 | +} | ||
| 91 | + | ||
| 67 | bool WindowUtils::CheckWindowState(const int32_t pid) | 92 | bool WindowUtils::CheckWindowState(const int32_t pid) |
| 68 | { | 93 | { |
| 69 | AUDIO_INFO_LOG("CheckWindowState pid:%{public}d", pid); | 94 | AUDIO_INFO_LOG("CheckWindowState pid:%{public}d", pid); |