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

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

Snap for 7546365 from 4d9d9d9e to sc-v2-release

Change-Id: I7c9ffdb48a5c0208242f7aba49ed7d81325e3821
parents d7a30d51 4d9d9d9e
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -1371,10 +1371,12 @@ static SecondaryDexAccess check_secondary_dex_access(const std::string& dex_path
        return kSecondaryDexAccessReadOk;
    } else {
        if (errno == ENOENT) {
            LOG(INFO) << "Secondary dex does not exist: " <<  dex_path;
            async_safe_format_log(ANDROID_LOG_INFO, LOG_TAG,
                    "Secondary dex does not exist: %s", dex_path.c_str());
            return kSecondaryDexAccessDoesNotExist;
        } else {
            PLOG(ERROR) << "Could not access secondary dex " << dex_path;
            async_safe_format_log(ANDROID_LOG_ERROR, LOG_TAG,
                    "Could not access secondary dex: %s (%d)", dex_path.c_str(), errno);
            return errno == EACCES
                ? kSecondaryDexAccessPermissionError
                : kSecondaryDexAccessIOError;
+1 −1
Original line number Diff line number Diff line
@@ -81,7 +81,7 @@ sk_sp<SkImage> BlurFilter::generate(GrRecordingContext* context, const uint32_t
    // Kawase is an approximation of Gaussian, but it behaves differently from it.
    // A radius transformation is required for approximating them, and also to introduce
    // non-integer steps, necessary to smoothly interpolate large radii.
    float tmpRadius = (float)blurRadius / 6.0f;
    float tmpRadius = (float)blurRadius / 2.0f;
    float numberOfPasses = std::min(kMaxPasses, (uint32_t)ceil(tmpRadius));
    float radiusByPasses = tmpRadius / (float)numberOfPasses;

+34 −14
Original line number Diff line number Diff line
@@ -56,6 +56,36 @@ float getHapticMaxAmplitudeRatio(HapticScale scale) {
    }
}

void applyHapticScale(float* buffer, size_t length, HapticScale scale) {
    if (scale == HapticScale::MUTE) {
        memset(buffer, 0, length * sizeof(float));
        return;
    }
    if (scale == HapticScale::NONE) {
        return;
    }
    float gamma = getHapticScaleGamma(scale);
    float maxAmplitudeRatio = getHapticMaxAmplitudeRatio(scale);
    for (size_t i = 0; i < length; i++) {
        float sign = buffer[i] >= 0 ? 1.0 : -1.0;
        buffer[i] = powf(fabsf(buffer[i] / HAPTIC_MAX_AMPLITUDE_FLOAT), gamma)
                * maxAmplitudeRatio * HAPTIC_MAX_AMPLITUDE_FLOAT * sign;
    }
}

void clipHapticData(float* buffer, size_t length, float limit) {
    if (isnan(limit) || limit == 0) {
        return;
    }
    limit = fabsf(limit);
    for (size_t i = 0; i < length; i++) {
        float sign = buffer[i] >= 0 ? 1.0 : -1.0;
        if (fabsf(buffer[i]) > limit) {
            buffer[i] = limit * sign;
        }
    }
}

} // namespace

bool isValidHapticScale(HapticScale scale) {
@@ -71,21 +101,11 @@ bool isValidHapticScale(HapticScale scale) {
    return false;
}

void scaleHapticData(float* buffer, size_t length, HapticScale scale) {
    if (!isValidHapticScale(scale) || scale == HapticScale::NONE) {
        return;
    }
    if (scale == HapticScale::MUTE) {
        memset(buffer, 0, length * sizeof(float));
        return;
    }
    float gamma = getHapticScaleGamma(scale);
    float maxAmplitudeRatio = getHapticMaxAmplitudeRatio(scale);
    for (size_t i = 0; i < length; i++) {
        float sign = buffer[i] >= 0 ? 1.0 : -1.0;
        buffer[i] = powf(fabsf(buffer[i] / HAPTIC_MAX_AMPLITUDE_FLOAT), gamma)
                * maxAmplitudeRatio * HAPTIC_MAX_AMPLITUDE_FLOAT * sign;
void scaleHapticData(float* buffer, size_t length, HapticScale scale, float limit) {
    if (isValidHapticScale(scale)) {
        applyHapticScale(buffer, length, scale);
    }
    clipHapticData(buffer, length, limit);
}

} // namespace android::os
+5 −1
Original line number Diff line number Diff line
@@ -32,7 +32,11 @@ enum class HapticScale {

bool isValidHapticScale(HapticScale scale);

void scaleHapticData(float* buffer, size_t length, HapticScale scale);
/* Scales the haptic data in given buffer using the selected HapticScale and ensuring no absolute
 * value will be larger than the absolute of given limit.
 * The limit will be ignored if it is NaN or zero.
 */
void scaleHapticData(float* buffer, size_t length, HapticScale scale, float limit);

} // namespace android::os