Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ca9f6143 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 11828632 from fce78599 to 24Q3-release

Change-Id: I82a2d033a2215b423a865ab3f53ea6a635f79f78
parents 010d82cd fce78599
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -32,10 +32,15 @@
namespace android {


static bool isAtLeast(int version, const char *codeName) {
    char deviceCodeName[PROP_VALUE_MAX];
    __system_property_get("ro.build.version.codename", deviceCodeName);
    return android_get_device_api_level() >= version || !strcmp(deviceCodeName, codeName);
static bool isAtLeast(int version, const std::string codeName) {
    static std::once_flag sCheckOnce;
    static std::string sDeviceCodeName;
    static int sDeviceApiLevel;
    std::call_once(sCheckOnce, [&](){
        sDeviceCodeName = base::GetProperty("ro.build.version.codename", "");
        sDeviceApiLevel = android_get_device_api_level();
    });
    return sDeviceApiLevel >= version || sDeviceCodeName == codeName;
}

bool isAtLeastT() {
+8 −6
Original line number Diff line number Diff line
@@ -37,6 +37,14 @@ cc_defaults {
    header_libs: [
        "libaudioeffects",
    ],
    cflags: [
        // This is needed for the non-zero coefficients optimization for
        // BiquadFilter. Try the biquad_filter_benchmark test in audio_utils
        // with/without `-ffast-math` for more context.
        "-ffast-math",
        "-fhonor-infinities",
        "-fhonor-nans",
    ],
    relative_install_path: "soundfx",
}

@@ -59,12 +67,6 @@ cc_library_shared {
        "-O2",
        "-Wall",
        "-Werror",
        // This is needed for the non-zero coefficients optimization for
        // BiquadFilter. Try the biquad_filter_benchmark test in audio_utils
        // with/without `-ffast-math` for more context.
        "-ffast-math",
        "-fhonor-infinities",
        "-fhonor-nans",
        "-fvisibility=hidden",
    ],
}
+13 −3
Original line number Diff line number Diff line
@@ -14,16 +14,17 @@
 * limitations under the License.
 */

#include <cstddef>
#define LOG_TAG "AHAL_HapticGeneratorContext"

#include <Utils.h>
#include "HapticGeneratorContext.h"
#include <android-base/logging.h>
#include <android-base/parsedouble.h>
#include <android-base/properties.h>
#include <audio_utils/primitives.h>
#include <audio_utils/safe_math.h>
#include <Utils.h>

#include "HapticGeneratorContext.h"
#include <cstddef>

using aidl::android::hardware::audio::common::getChannelCount;
using aidl::android::hardware::audio::common::getPcmSampleSizeInBytes;
@@ -110,6 +111,15 @@ std::vector<HapticGenerator::HapticScale> HapticGeneratorContext::getHgHapticSca
RetCode HapticGeneratorContext::setHgVibratorInformation(
        const HapticGenerator::VibratorInformation& vibratorInfo) {
    mParams.mVibratorInfo = vibratorInfo;
    if (::android::audio_utils::safe_isnan(mParams.mVibratorInfo.resonantFrequencyHz)) {
        LOG(WARNING) << __func__ << " resonantFrequencyHz reset from nan to "
                     << DEFAULT_RESONANT_FREQUENCY;
        mParams.mVibratorInfo.resonantFrequencyHz = DEFAULT_RESONANT_FREQUENCY;
    }
    if (::android::audio_utils::safe_isnan(mParams.mVibratorInfo.qFactor)) {
        LOG(WARNING) << __func__ << " qFactor reset from nan to " << DEFAULT_BSF_ZERO_Q;
        mParams.mVibratorInfo.qFactor = DEFAULT_BSF_ZERO_Q;
    }

    if (mProcessorsRecord.bpf != nullptr) {
        mProcessorsRecord.bpf->setCoefficients(::android::audio_effect::haptic_generator::bpfCoefs(
+5 −3
Original line number Diff line number Diff line
@@ -16,11 +16,13 @@

#pragma once

#include "effect-impl/EffectContext.h"
#include "Processors.h"

#include <vibrator/ExternalVibrationUtils.h>
#include <map>

#include "Processors.h"
#include "effect-impl/EffectContext.h"
#include <cstddef>
#include <map>

namespace aidl::android::hardware::audio::effect {

+38 −4
Original line number Diff line number Diff line
@@ -17,11 +17,18 @@
//#define LOG_NDEBUG 0
#define LOG_TAG "MediaPlayerService-DeathNotifier"
#include <android-base/logging.h>
#include <map>

#include "DeathNotifier.h"

namespace android {

// Only dereference the cookie if it's valid (if it's in this set)
// Only used with ndk
static uintptr_t sCookieKeyCounter = 0;
static std::map<uintptr_t, wp<DeathNotifier::DeathRecipient>> sCookies;
static std::mutex sCookiesMutex;

class DeathNotifier::DeathRecipient :
        public IBinder::DeathRecipient,
        public hardware::hidl_death_recipient {
@@ -44,13 +51,32 @@ public:
    }

    static void OnBinderDied(void *cookie) {
        DeathRecipient *thiz = (DeathRecipient *)cookie;
        thiz->mNotify();
        std::unique_lock<std::mutex> guard(sCookiesMutex);
        if (auto it = sCookies.find(reinterpret_cast<uintptr_t>(cookie)); it != sCookies.end()) {
            sp<DeathRecipient> recipient = it->second.promote();
            sCookies.erase(it);
            guard.unlock();

            if (recipient) {
                LOG(INFO) << "Notifying DeathRecipient from OnBinderDied.";
                recipient->mNotify();
            } else {
                LOG(INFO) <<
                    "Tried to notify DeathRecipient from OnBinderDied but could not promote.";
            }
        }
    }

    AIBinder_DeathRecipient *getNdkRecipient() {
        return mNdkRecipient.get();;
    }
    ~DeathRecipient() {
        // lock must be taken so object is not used in OnBinderDied"
        std::lock_guard<std::mutex> guard(sCookiesMutex);
        sCookies.erase(mCookieKey);
    }

    uintptr_t mCookieKey;

private:
    Notify mNotify;
@@ -73,8 +99,15 @@ DeathNotifier::DeathNotifier(::ndk::SpAIBinder const& service, Notify const& not
      : mService{std::in_place_index<3>, service},
        mDeathRecipient{new DeathRecipient(notify)} {
    mDeathRecipient->initNdk();
    {
        std::lock_guard<std::mutex> guard(sCookiesMutex);
        mDeathRecipient->mCookieKey = sCookieKeyCounter++;
        sCookies[mDeathRecipient->mCookieKey] = mDeathRecipient;
    }
    AIBinder_linkToDeath(
            service.get(), mDeathRecipient->getNdkRecipient(), mDeathRecipient.get());
            service.get(),
            mDeathRecipient->getNdkRecipient(),
            reinterpret_cast<void*>(mDeathRecipient->mCookieKey));
}

DeathNotifier::DeathNotifier(DeathNotifier&& other)
@@ -94,10 +127,11 @@ DeathNotifier::~DeathNotifier() {
        std::get<2>(mService)->unlinkToDeath(mDeathRecipient);
        break;
    case 3:

        AIBinder_unlinkToDeath(
                std::get<3>(mService).get(),
                mDeathRecipient->getNdkRecipient(),
                mDeathRecipient.get());
                reinterpret_cast<void*>(mDeathRecipient->mCookieKey));
        break;
    default:
        CHECK(false) << "Corrupted service type during destruction.";
Loading