diff --git a/patches/platform_frameworks_av/0032-Fix-AAC-decoder-failing-to-instantiate.patch b/patches/platform_frameworks_av/0032-Fix-AAC-decoder-failing-to-instantiate.patch deleted file mode 100644 index 5f00d25..0000000 --- a/patches/platform_frameworks_av/0032-Fix-AAC-decoder-failing-to-instantiate.patch +++ /dev/null @@ -1,37 +0,0 @@ -From 624cfc90b8bedb024f289772960f3cd7072fa940 Mon Sep 17 00:00:00 2001 -From: Pierre-Hugues Husson -Date: Sat, 6 Mar 2021 19:15:24 -0500 -Subject: [PATCH 32/32] Fix AAC decoder failing to instantiate - -This has been caused by I50fcc5ef35cb7e96592c2267652228b5fa074ba9 -Non-Android 11 vendors won't provide those calls, and will thus fail. ---- - media/libstagefright/ACodec.cpp | 5 ++--- - 1 file changed, 2 insertions(+), 3 deletions(-) - -diff --git a/media/libstagefright/ACodec.cpp b/media/libstagefright/ACodec.cpp -index 0f8cd39edb..35cdf86319 100644 ---- a/media/libstagefright/ACodec.cpp -+++ b/media/libstagefright/ACodec.cpp -@@ -5340,9 +5340,7 @@ status_t ACodec::getPortFormat(OMX_U32 portIndex, sp ¬ify) { - err = mOMXNode->getParameter( - (OMX_INDEXTYPE)OMX_IndexParamAudioAndroidAacDrcPresentation, - &presentation, sizeof(presentation)); -- if (err != OK) { -- return err; -- } -+ if (err == OK) { - notify->setInt32("aac-encoded-target-level", - presentation.nEncodedTargetLevel); - notify->setInt32("aac-drc-cut-level", presentation.nDrcCut); -@@ -5355,6 +5353,7 @@ status_t ACodec::getPortFormat(OMX_U32 portIndex, sp ¬ify) { - notify->setInt32("aac-drc-album-mode", presentation.nDrcAlbumMode); - notify->setInt32("aac-drc-output-loudness", - presentation.nDrcOutputLoudness); -+ } - } - } - break; --- -2.25.1 - diff --git a/patches/platform_frameworks_av/0039-Revert-AudioPolicyManager-retry-with-SW-bridge-if-ha.patch b/patches/platform_frameworks_av/0039-Revert-AudioPolicyManager-retry-with-SW-bridge-if-ha.patch new file mode 100644 index 0000000..34ac8c3 --- /dev/null +++ b/patches/platform_frameworks_av/0039-Revert-AudioPolicyManager-retry-with-SW-bridge-if-ha.patch @@ -0,0 +1,73 @@ +From 2fd4810ec5e6a453e980cacba2e1bcdd30b3f967 Mon Sep 17 00:00:00 2001 +From: Peter Cai +Date: Wed, 14 Apr 2021 10:20:22 +0800 +Subject: [PATCH 39/40] Revert "AudioPolicyManager: retry with SW bridge if + hardware audio patch fails" + +This reverts commit 5d869232d42a2fee6b7cb07b6a240aef5838021b. +--- + .../managerdefault/AudioPolicyManager.cpp | 13 +++---------- + .../audiopolicy/managerdefault/AudioPolicyManager.h | 4 +--- + 2 files changed, 4 insertions(+), 13 deletions(-) + +diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp +index 6d2c38811e..63dcd538b1 100644 +--- a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp ++++ b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp +@@ -3490,8 +3490,7 @@ status_t AudioPolicyManager::getAudioPort(struct audio_port *port) + status_t AudioPolicyManager::createAudioPatchInternal(const struct audio_patch *patch, + audio_patch_handle_t *handle, + uid_t uid, uint32_t delayMs, +- const sp& sourceDesc, +- bool forceSwBridge) ++ const sp& sourceDesc) + { + ALOGV("%s", __func__); + if (handle == NULL || patch == NULL) { +@@ -3695,8 +3694,7 @@ status_t AudioPolicyManager::createAudioPatchInternal(const struct audio_patch * + // - audio HAL version is >= 3.0 but no route has been declared between devices + // - called from startAudioSource (aka sourceDesc != nullptr) and source device does + // not have a gain controller +- // - a previous attempt at using HW bridge failed (forceSwBridge) +- if (forceSwBridge || !srcDevice->hasSameHwModuleAs(sinkDevice) || ++ if (!srcDevice->hasSameHwModuleAs(sinkDevice) || + (srcDevice->getModuleVersionMajor() < 3) || + !srcDevice->getModule()->supportsPatch(srcDevice, sinkDevice) || + (sourceDesc != nullptr && +@@ -3761,12 +3759,7 @@ status_t AudioPolicyManager::createAudioPatchInternal(const struct audio_patch * + __func__, index, handle, patchBuilder.patch(), delayMs, uid, &patchDesc); + if (status != NO_ERROR) { + ALOGW("%s patch panel could not connect device patch, error %d", __func__, status); +- if (forceSwBridge || patch->sinks[0].type != AUDIO_PORT_TYPE_DEVICE) { +- return INVALID_OPERATION; +- } else { +- ALOGW("Retrying with software bridging."); +- return createAudioPatchInternal(patch, handle, uid, delayMs, sourceDesc, true); +- } ++ return INVALID_OPERATION; + } + } else { + return BAD_VALUE; +diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.h b/services/audiopolicy/managerdefault/AudioPolicyManager.h +index 60cbd7175e..b588f898d4 100644 +--- a/services/audiopolicy/managerdefault/AudioPolicyManager.h ++++ b/services/audiopolicy/managerdefault/AudioPolicyManager.h +@@ -910,14 +910,12 @@ private: + * @param[in] delayMs if required + * @param[in] sourceDesc [optional] in case of external source, source client to be + * configured by the patch, i.e. assigning an Output (HW or SW) +- * @param[in] forceSwBridge [optional] force the creation of a SW bridge (internal use only) + * @return NO_ERROR if patch installed correctly, error code otherwise. + */ + status_t createAudioPatchInternal(const struct audio_patch *patch, + audio_patch_handle_t *handle, + uid_t uid, uint32_t delayMs = 0, +- const sp& sourceDesc = nullptr, +- bool forceSwBridge = false); ++ const sp& sourceDesc = nullptr); + /** + * @brief releaseAudioPatchInternal internal function to remove an audio patch + * @param[in] handle of the patch to be removed +-- +2.25.1 + diff --git a/patches/platform_frameworks_av/0040-APM-Fall-back-to-legacy-voice-call-routing-if-creati.patch b/patches/platform_frameworks_av/0040-APM-Fall-back-to-legacy-voice-call-routing-if-creati.patch new file mode 100644 index 0000000..8238a90 --- /dev/null +++ b/patches/platform_frameworks_av/0040-APM-Fall-back-to-legacy-voice-call-routing-if-creati.patch @@ -0,0 +1,78 @@ +From 7bb3de067cec0c8c3bd5341bf9ad42b808fefd39 Mon Sep 17 00:00:00 2001 +From: Peter Cai +Date: Wed, 14 Apr 2021 11:09:12 +0800 +Subject: [PATCH 40/40] APM: Fall back to legacy voice call routing if creating + audio patch failed + +* On some MT6771 Q vendor devices, in-call audio is broken due to APM + failing to create an HW audio patch for RX / TX devices. + +> 03-28 11:56:42.300 1345 1345 W DeviceHAL: Error from HAL Device in +function create_audio_patch: Function not implemented +> 03-28 11:56:42.301 1358 1374 W APM_AudioPolicyManager: +createAudioPatchInternal patch panel could not connect device patch, +error -38 +> 03-28 11:56:42.301 1358 1374 W APM_AudioPolicyManager: +createTelephonyPatch() error -38 creating RX audio patch + +* Our previous attempt at fixing this by falling back to SW bridging was + wrong, because SW bridging requires a corresponding audio policy + configuration that includes said SW bridges, which is not the case on + these devices. + +* The sole reason why this was broken at all is that the new R behavior + tries to use the newer `createAudioPatch` interface of the audio HAL, + which is broken on these devices for telephony inputs and outputs, + even though the HAL claims to support it. + +* Let's fall back to pre-R behavior (i.e. using the legacy + setOutputDevices() interface) whenever the new method fails. The + legacy method takes care of TX (Mic input) as well, so we don't need + to create the TX patch either. +--- + .../managerdefault/AudioPolicyManager.cpp | 23 +++++++++++++++---- + 1 file changed, 18 insertions(+), 5 deletions(-) + +diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp +index 63dcd538b1..124c6ca6ef 100644 +--- a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp ++++ b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp +@@ -575,17 +575,30 @@ uint32_t AudioPolicyManager::updateCallRouting(const DeviceVector &rxDevices, ui + createTxPatch = !(availablePrimaryModuleInputDevices().contains(txSourceDevice)) && + (txSinkDevice != 0); + } +- // Use legacy routing method for voice calls via setOutputDevice() on primary output. +- // Otherwise, create two audio patches for TX and RX path. +- if (!createRxPatch) { +- muteWaitMs = setOutputDevices(mPrimaryOutput, rxDevices, true, delayMs); +- } else { // create RX path audio patch ++ if (createRxPatch) { // create RX path audio patch + mCallRxPatch = createTelephonyPatch(true /*isRx*/, rxDevices.itemAt(0), delayMs); + ++ if (mCallRxPatch == nullptr) { ++ // Fall back to legacy routing for voice calls if the new patching method ++ // failed. setOutputDevice() will take care of TX in this case, so don't ++ // create the TX patch either. ++ // This is seen on some MT6771 devices on Q vendor, where the HAL claims ++ // support for HW patch between telephony inputs and outputs, but fails ++ // to create one when called with the createAudioPatch() method. SW audio ++ // bridges are also broken on them due to improperly configured audio policy. ++ ALOGW("Failed to create RX path audio patch, falling back to pre-R behavior"); ++ createRxPatch = false; ++ createTxPatch = false; ++ } ++ + // If the TX device is on the primary HW module but RX device is + // on other HW module, SinkMetaData of telephony input should handle it + // assuming the device uses audio HAL V5.0 and above + } ++ // Use legacy routing method for voice calls via setOutputDevice() on primary output. ++ if (!createRxPatch) { ++ muteWaitMs = setOutputDevices(mPrimaryOutput, rxDevices, true, delayMs); ++ } + if (createTxPatch) { // create TX path audio patch + // terminate active capture if on the same HW module as the call TX source device + // FIXME: would be better to refine to only inputs whose profile connects to the +-- +2.25.1 + diff --git a/patches/platform_frameworks_base/0049-Fix-build.patch b/patches/platform_frameworks_base/0049-Fix-build.patch new file mode 100644 index 0000000..689e280 --- /dev/null +++ b/patches/platform_frameworks_base/0049-Fix-build.patch @@ -0,0 +1,24 @@ +From 50edb017dc10058835e178885d432eb89ec7e131 Mon Sep 17 00:00:00 2001 +From: Pierre-Hugues Husson +Date: Mon, 19 Apr 2021 21:03:45 +0200 +Subject: [PATCH 49/49] Fix build + +--- + .../java/com/android/server/display/DisplayPowerController.java | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/services/core/java/com/android/server/display/DisplayPowerController.java b/services/core/java/com/android/server/display/DisplayPowerController.java +index 908c3b852fe1..550965ef7cd2 100644 +--- a/services/core/java/com/android/server/display/DisplayPowerController.java ++++ b/services/core/java/com/android/server/display/DisplayPowerController.java +@@ -62,6 +62,7 @@ import com.android.server.display.whitebalance.DisplayWhiteBalanceController; + import com.android.server.display.whitebalance.DisplayWhiteBalanceFactory; + import com.android.server.display.whitebalance.DisplayWhiteBalanceSettings; + import com.android.server.lights.LightsManager; ++import com.android.server.lights.LogicalLight; + import com.android.server.policy.WindowManagerPolicy; + + import java.io.PrintWriter; +-- +2.25.1 +