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

Commit 4e5ceff1 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Use hardcoded value for HapticScale"

parents 79aca929 e214e64b
Loading
Loading
Loading
Loading
+44 −16
Original line number Diff line number Diff line
@@ -21,10 +21,30 @@ package {
    default_applicable_licenses: ["frameworks_native_license"],
}

cc_defaults {
    name: "libvibrator_defaults",

    cflags: [
        "-Wall",
        "-Werror",
        "-Wno-missing-field-initializers",
        "-Wno-unused-variable",
        "-Wno-unused-parameter",
    ],

    export_include_dirs: ["include"],

    host_supported: true,
    target: {
        darwin: {
            enabled: false,
        },
    },
}

cc_library {
    name: "libvibrator",
    vendor_available: true,
    double_loadable: true,
    defaults: ["libvibrator_defaults"],

    shared_libs: [
        "libbinder",
@@ -32,6 +52,10 @@ cc_library {
        "libutils",
    ],

    whole_static_libs: [
        "libvibratorutils",
    ],

    header_libs: [
        "libaudio_system_headers",
    ],
@@ -44,23 +68,27 @@ cc_library {

    srcs: [
        ":libvibrator_aidl",
        "*.cpp",
        "ExternalVibration.cpp",
    ],
}

    cflags: [
        "-Wall",
        "-Werror",
        "-Wno-missing-field-initializers",
        "-Wno-unused-variable",
        "-Wno-unused-parameter",
cc_library {
    name: "libvibratorutils",
    defaults: ["libvibrator_defaults"],

    vendor_available: true,
    double_loadable: true,

    shared_libs: [
        "libutils",
    ],

    export_include_dirs: ["include"],
    srcs: [
        "ExternalVibrationUtils.cpp",
    ],

    host_supported: true,
    target: {
        darwin: {
            enabled: false,
        },
    },
    visibility: [
        "//frameworks/native/libs/vibrator",
        "//frameworks/av/media/libeffects/hapticgenerator",
    ],
}
+11 −0
Original line number Diff line number Diff line
@@ -15,11 +15,22 @@
 */

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

#include <android/os/IExternalVibratorService.h>
#include <binder/Parcel.h>
#include <log/log.h>
#include <utils/Errors.h>


// To guarantee if HapticScale enum has the same value as IExternalVibratorService
static_assert(static_cast<int>(android::os::HapticScale::MUTE) == static_cast<int>(android::os::IExternalVibratorService::SCALE_MUTE));
static_assert(static_cast<int>(android::os::HapticScale::VERY_LOW) == static_cast<int>(android::os::IExternalVibratorService::SCALE_VERY_LOW));
static_assert(static_cast<int>(android::os::HapticScale::LOW) == static_cast<int>(android::os::IExternalVibratorService::SCALE_LOW));
static_assert(static_cast<int>(android::os::HapticScale::NONE) == static_cast<int>(android::os::IExternalVibratorService::SCALE_NONE));
static_assert(static_cast<int>(android::os::HapticScale::HIGH) == static_cast<int>(android::os::IExternalVibratorService::SCALE_HIGH));
static_assert(static_cast<int>(android::os::HapticScale::VERY_HIGH) == static_cast<int>(android::os::IExternalVibratorService::SCALE_VERY_HIGH));

void writeAudioAttributes(const audio_attributes_t& attrs, android::Parcel* out) {
    out->writeInt32(attrs.usage);
    out->writeInt32(attrs.content_type);
+8 −8
Original line number Diff line number Diff line
@@ -17,17 +17,17 @@
#ifndef ANDROID_EXTERNAL_VIBRATION_UTILS_H
#define ANDROID_EXTERNAL_VIBRATION_UTILS_H

#include <android/os/IExternalVibratorService.h>

namespace android::os {

// Copied from frameworks/base/core/java/android/os/IExternalVibratorService.aidl
// The values are checked in ExternalVibration.cpp
enum class HapticScale {
    MUTE = IExternalVibratorService::SCALE_MUTE,
    VERY_LOW = IExternalVibratorService::SCALE_VERY_LOW,
    LOW = IExternalVibratorService::SCALE_LOW,
    NONE = IExternalVibratorService::SCALE_NONE,
    HIGH = IExternalVibratorService::SCALE_HIGH,
    VERY_HIGH = IExternalVibratorService::SCALE_VERY_HIGH,
    MUTE = -100,
    VERY_LOW = -2,
    LOW = -1,
    NONE = 0,
    HIGH = 1,
    VERY_HIGH = 2,
};

bool isValidHapticScale(HapticScale scale);