mirror of
https://github.com/chararomandroid/android_device_samsung_a20
synced 2026-08-23 12:35:33 -04:00
universal7885: run clang-format based on system-clang-format
* On every *.cpp *.h files Signed-off-by: roynatech2544 <whiteshell2544@naver.com>
This commit is contained in:
parent
6bc1c25485
commit
098179eabb
47 changed files with 1545 additions and 1709 deletions
|
|
@ -41,10 +41,12 @@ Lights::Lights() {
|
|||
mLights.emplace(LightType::BACKLIGHT,
|
||||
std::bind(&Lights::handleBacklight, this, std::placeholders::_1));
|
||||
#ifdef BUTTON_BRIGHTNESS_NODE
|
||||
mLights.emplace(LightType::BUTTONS, std::bind(&Lights::handleButtons, this, std::placeholders::_1));
|
||||
mLights.emplace(LightType::BUTTONS,
|
||||
std::bind(&Lights::handleButtons, this, std::placeholders::_1));
|
||||
#endif /* BUTTON_BRIGHTNESS_NODE */
|
||||
#ifdef LED_BLINK_NODE
|
||||
mLights.emplace(LightType::BATTERY, std::bind(&Lights::handleBattery, this, std::placeholders::_1));
|
||||
mLights.emplace(LightType::BATTERY,
|
||||
std::bind(&Lights::handleBattery, this, std::placeholders::_1));
|
||||
mLights.emplace(LightType::NOTIFICATIONS,
|
||||
std::bind(&Lights::handleNotifications, this, std::placeholders::_1));
|
||||
mLights.emplace(LightType::ATTENTION,
|
||||
|
|
@ -147,7 +149,7 @@ void Lights::setNotificationLED() {
|
|||
|
||||
state.color = calibrateColor(state.color & COLOR_MASK, adjusted_brightness);
|
||||
set(LED_BLINK_NODE, ::android::base::StringPrintf("0x%08x %d %d", state.color, state.flashOnMs,
|
||||
state.flashOffMs));
|
||||
state.flashOffMs));
|
||||
|
||||
#ifdef LED_BLN_NODE
|
||||
if (bln) {
|
||||
|
|
@ -166,9 +168,10 @@ uint32_t Lights::calibrateColor(uint32_t color, int32_t brightness) {
|
|||
}
|
||||
#endif /* LED_BLINK_NODE */
|
||||
|
||||
#define AutoHwLight(light) {.id = (int32_t)light, .type = light, .ordinal = 0}
|
||||
#define AutoHwLight(light) \
|
||||
{ .id = (int32_t)light, .type = light, .ordinal = 0 }
|
||||
|
||||
ndk::ScopedAStatus Lights::getLights(std::vector<HwLight> *_aidl_return) {
|
||||
ndk::ScopedAStatus Lights::getLights(std::vector<HwLight>* _aidl_return) {
|
||||
for (auto const& light : mLights) {
|
||||
_aidl_return->push_back(AutoHwLight(light.first));
|
||||
}
|
||||
|
|
@ -179,11 +182,12 @@ ndk::ScopedAStatus Lights::getLights(std::vector<HwLight> *_aidl_return) {
|
|||
uint32_t Lights::rgbToBrightness(const HwLightState& state) {
|
||||
uint32_t color = state.color & COLOR_MASK;
|
||||
|
||||
return ((77 * ((color >> 16) & 0xff)) + (150 * ((color >> 8) & 0xff)) + (29 * (color & 0xff))) >>
|
||||
return ((77 * ((color >> 16) & 0xff)) + (150 * ((color >> 8) & 0xff)) +
|
||||
(29 * (color & 0xff))) >>
|
||||
8;
|
||||
}
|
||||
|
||||
} // namespace light
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // namespace aidl
|
||||
} // namespace light
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // namespace aidl
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
#include <unordered_map>
|
||||
#include "samsung_lights.h"
|
||||
|
||||
using ::aidl::android::hardware::light::HwLightState;
|
||||
using ::aidl::android::hardware::light::HwLight;
|
||||
using ::aidl::android::hardware::light::HwLightState;
|
||||
|
||||
namespace aidl {
|
||||
namespace android {
|
||||
|
|
@ -19,13 +19,13 @@ namespace hardware {
|
|||
namespace light {
|
||||
|
||||
class Lights : public BnLights {
|
||||
public:
|
||||
public:
|
||||
Lights();
|
||||
|
||||
ndk::ScopedAStatus setLightState(int32_t id, const HwLightState& state) override;
|
||||
ndk::ScopedAStatus getLights(std::vector<HwLight> *_aidl_return) override;
|
||||
ndk::ScopedAStatus getLights(std::vector<HwLight>* _aidl_return) override;
|
||||
|
||||
private:
|
||||
private:
|
||||
void handleBacklight(const HwLightState& state);
|
||||
#ifdef BUTTON_BRIGHTNESS_NODE
|
||||
void handleButtons(const HwLightState& state);
|
||||
|
|
@ -48,7 +48,7 @@ private:
|
|||
std::unordered_map<LightType, std::function<void(const HwLightState&)>> mLights;
|
||||
};
|
||||
|
||||
} // namespace light
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // namespace aidl
|
||||
} // namespace light
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // namespace aidl
|
||||
|
|
|
|||
|
|
@ -8,9 +8,9 @@
|
|||
|
||||
#include "Lights.h"
|
||||
|
||||
#include <android-base/logging.h>
|
||||
#include <android/binder_manager.h>
|
||||
#include <android/binder_process.h>
|
||||
#include <android-base/logging.h>
|
||||
|
||||
using ::aidl::android::hardware::light::Lights;
|
||||
|
||||
|
|
@ -23,5 +23,5 @@ int main() {
|
|||
CHECK(status == STATUS_OK);
|
||||
|
||||
ABinderProcess_joinThreadPool();
|
||||
return EXIT_FAILURE; // should not reach
|
||||
return EXIT_FAILURE; // should not reach
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@
|
|||
static const std::vector<std::string> fb_idle_patch = {"/sys/class/drm/card0/device/idle_state",
|
||||
"/sys/class/graphics/fb0/idle_state"};
|
||||
|
||||
InteractionHandler::InteractionHandler(std::shared_ptr<HintManager> const &hint_manager)
|
||||
InteractionHandler::InteractionHandler(std::shared_ptr<HintManager> const& hint_manager)
|
||||
: mState(INTERACTION_STATE_UNINITIALIZED),
|
||||
mWaitMs(100),
|
||||
mMinDurationMs(1400),
|
||||
|
|
@ -50,10 +50,9 @@ InteractionHandler::~InteractionHandler() {
|
|||
|
||||
static int fb_idle_open(void) {
|
||||
int fd;
|
||||
for (auto &path : fb_idle_patch) {
|
||||
for (auto& path : fb_idle_patch) {
|
||||
fd = open(path.c_str(), O_RDONLY);
|
||||
if (fd >= 0)
|
||||
return fd;
|
||||
if (fd >= 0) return fd;
|
||||
}
|
||||
ALOGE("Unable to open fb idle state path (%d)", errno);
|
||||
return -1;
|
||||
|
|
@ -62,8 +61,7 @@ static int fb_idle_open(void) {
|
|||
bool InteractionHandler::Init() {
|
||||
std::lock_guard<std::mutex> lk(mLock);
|
||||
|
||||
if (mState != INTERACTION_STATE_UNINITIALIZED)
|
||||
return true;
|
||||
if (mState != INTERACTION_STATE_UNINITIALIZED) return true;
|
||||
|
||||
mIdleFd = fb_idle_open();
|
||||
|
||||
|
|
@ -84,8 +82,7 @@ bool InteractionHandler::Init() {
|
|||
|
||||
void InteractionHandler::Exit() {
|
||||
std::unique_lock<std::mutex> lk(mLock);
|
||||
if (mState == INTERACTION_STATE_UNINITIALIZED)
|
||||
return;
|
||||
if (mState == INTERACTION_STATE_UNINITIALIZED) return;
|
||||
|
||||
AbortWaitLocked();
|
||||
mState = INTERACTION_STATE_UNINITIALIZED;
|
||||
|
|
@ -186,8 +183,7 @@ void InteractionHandler::Release() {
|
|||
void InteractionHandler::AbortWaitLocked() {
|
||||
uint64_t val = 1;
|
||||
ssize_t ret = write(mEventFd, &val, sizeof(val));
|
||||
if (ret != sizeof(val))
|
||||
ALOGW("Unable to write to event fd (%zd)", ret);
|
||||
if (ret != sizeof(val)) ALOGW("Unable to write to event fd (%zd)", ret);
|
||||
}
|
||||
|
||||
void InteractionHandler::WaitForIdle(int32_t wait_ms, int32_t timeout_ms) {
|
||||
|
|
@ -253,8 +249,7 @@ void InteractionHandler::Routine() {
|
|||
while (true) {
|
||||
lk.lock();
|
||||
mCond.wait(lk, [&] { return mState != INTERACTION_STATE_IDLE; });
|
||||
if (mState == INTERACTION_STATE_UNINITIALIZED)
|
||||
return;
|
||||
if (mState == INTERACTION_STATE_UNINITIALIZED) return;
|
||||
mState = INTERACTION_STATE_WAITING;
|
||||
lk.unlock();
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ enum interaction_state {
|
|||
|
||||
class InteractionHandler {
|
||||
public:
|
||||
InteractionHandler(std::shared_ptr<HintManager> const &hint_manager);
|
||||
InteractionHandler(std::shared_ptr<HintManager> const& hint_manager);
|
||||
~InteractionHandler();
|
||||
bool Init();
|
||||
void Exit();
|
||||
|
|
|
|||
|
|
@ -169,10 +169,10 @@ ndk::ScopedAStatus Power::setMode(Mode type, bool enabled) {
|
|||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus Power::isModeSupported(Mode type, bool *_aidl_return) {
|
||||
ndk::ScopedAStatus Power::isModeSupported(Mode type, bool* _aidl_return) {
|
||||
bool supported = mHintManager->IsHintSupported(toString(type));
|
||||
switch (type) {
|
||||
case Mode::LOW_POWER: // LOW_POWER handled insides PowerHAL specifically
|
||||
case Mode::LOW_POWER: // LOW_POWER handled insides PowerHAL specifically
|
||||
supported = true;
|
||||
break;
|
||||
case Mode::DOUBLE_TAP_TO_WAKE:
|
||||
|
|
@ -227,18 +227,18 @@ ndk::ScopedAStatus Power::setBoost(Boost type, int32_t durationMs) {
|
|||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus Power::isBoostSupported(Boost type, bool *_aidl_return) {
|
||||
ndk::ScopedAStatus Power::isBoostSupported(Boost type, bool* _aidl_return) {
|
||||
bool supported = mHintManager->IsHintSupported(toString(type));
|
||||
LOG(INFO) << "Power boost " << toString(type) << " isBoostSupported: " << supported;
|
||||
*_aidl_return = supported;
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
constexpr const char *boolToString(bool b) {
|
||||
constexpr const char* boolToString(bool b) {
|
||||
return b ? "true" : "false";
|
||||
}
|
||||
|
||||
binder_status_t Power::dump(int fd, const char **, uint32_t) {
|
||||
binder_status_t Power::dump(int fd, const char**, uint32_t) {
|
||||
std::string buf(::android::base::StringPrintf(
|
||||
"HintManager Running: %s\n"
|
||||
"VRMode: %s\n"
|
||||
|
|
|
|||
|
|
@ -41,10 +41,10 @@ class Power : public ::aidl::android::hardware::power::BnPower {
|
|||
public:
|
||||
Power(std::shared_ptr<HintManager> hm);
|
||||
ndk::ScopedAStatus setMode(Mode type, bool enabled) override;
|
||||
ndk::ScopedAStatus isModeSupported(Mode type, bool *_aidl_return) override;
|
||||
ndk::ScopedAStatus isModeSupported(Mode type, bool* _aidl_return) override;
|
||||
ndk::ScopedAStatus setBoost(Boost type, int32_t durationMs) override;
|
||||
ndk::ScopedAStatus isBoostSupported(Boost type, bool *_aidl_return) override;
|
||||
binder_status_t dump(int fd, const char **args, uint32_t numArgs) override;
|
||||
ndk::ScopedAStatus isBoostSupported(Boost type, bool* _aidl_return) override;
|
||||
binder_status_t dump(int fd, const char** args, uint32_t numArgs) override;
|
||||
|
||||
private:
|
||||
std::shared_ptr<HintManager> mHintManager;
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ namespace power {
|
|||
namespace impl {
|
||||
namespace pixel {
|
||||
|
||||
ndk::ScopedAStatus PowerExt::setMode(const std::string &mode, bool enabled) {
|
||||
ndk::ScopedAStatus PowerExt::setMode(const std::string& mode, bool enabled) {
|
||||
LOG(DEBUG) << "PowerExt setMode: " << mode << " to: " << enabled;
|
||||
ATRACE_INT(mode.c_str(), enabled);
|
||||
|
||||
|
|
@ -50,14 +50,14 @@ ndk::ScopedAStatus PowerExt::setMode(const std::string &mode, bool enabled) {
|
|||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus PowerExt::isModeSupported(const std::string &mode, bool *_aidl_return) {
|
||||
ndk::ScopedAStatus PowerExt::isModeSupported(const std::string& mode, bool* _aidl_return) {
|
||||
bool supported = mHintManager->IsHintSupported(mode);
|
||||
LOG(INFO) << "PowerExt mode " << mode << " isModeSupported: " << supported;
|
||||
*_aidl_return = supported;
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus PowerExt::setBoost(const std::string &boost, int32_t durationMs) {
|
||||
ndk::ScopedAStatus PowerExt::setBoost(const std::string& boost, int32_t durationMs) {
|
||||
LOG(DEBUG) << "PowerExt setBoost: " << boost << " duration: " << durationMs;
|
||||
ATRACE_INT(boost.c_str(), durationMs);
|
||||
|
||||
|
|
@ -72,7 +72,7 @@ ndk::ScopedAStatus PowerExt::setBoost(const std::string &boost, int32_t duration
|
|||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus PowerExt::isBoostSupported(const std::string &boost, bool *_aidl_return) {
|
||||
ndk::ScopedAStatus PowerExt::isBoostSupported(const std::string& boost, bool* _aidl_return) {
|
||||
bool supported = mHintManager->IsHintSupported(boost);
|
||||
LOG(INFO) << "PowerExt boost " << boost << " isBoostSupported: " << supported;
|
||||
*_aidl_return = supported;
|
||||
|
|
|
|||
|
|
@ -34,12 +34,11 @@ using ::android::perfmgr::HintManager;
|
|||
|
||||
class PowerExt : public ::aidl::google::hardware::power::extension::pixel::BnPowerExt {
|
||||
public:
|
||||
PowerExt(std::shared_ptr<HintManager> hm)
|
||||
: mHintManager(hm) {}
|
||||
ndk::ScopedAStatus setMode(const std::string &mode, bool enabled) override;
|
||||
ndk::ScopedAStatus isModeSupported(const std::string &mode, bool *_aidl_return) override;
|
||||
ndk::ScopedAStatus setBoost(const std::string &boost, int32_t durationMs) override;
|
||||
ndk::ScopedAStatus isBoostSupported(const std::string &boost, bool *_aidl_return) override;
|
||||
PowerExt(std::shared_ptr<HintManager> hm) : mHintManager(hm) {}
|
||||
ndk::ScopedAStatus setMode(const std::string& mode, bool enabled) override;
|
||||
ndk::ScopedAStatus isModeSupported(const std::string& mode, bool* _aidl_return) override;
|
||||
ndk::ScopedAStatus setBoost(const std::string& boost, int32_t durationMs) override;
|
||||
ndk::ScopedAStatus isBoostSupported(const std::string& boost, bool* _aidl_return) override;
|
||||
|
||||
private:
|
||||
std::shared_ptr<HintManager> mHintManager;
|
||||
|
|
|
|||
|
|
@ -53,7 +53,8 @@ Vibrator::Vibrator() {
|
|||
ndk::ScopedAStatus Vibrator::getCapabilities(int32_t* _aidl_return) {
|
||||
*_aidl_return = IVibrator::CAP_ON_CALLBACK | IVibrator::CAP_PERFORM_CALLBACK |
|
||||
IVibrator::CAP_EXTERNAL_CONTROL /*| IVibrator::CAP_COMPOSE_EFFECTS |
|
||||
IVibrator::CAP_ALWAYS_ON_CONTROL*/;
|
||||
IVibrator::CAP_ALWAYS_ON_CONTROL*/
|
||||
;
|
||||
|
||||
if (mHasTimedOutIntensity) {
|
||||
*_aidl_return = *_aidl_return | IVibrator::CAP_AMPLITUDE_CONTROL |
|
||||
|
|
@ -67,7 +68,8 @@ ndk::ScopedAStatus Vibrator::off() {
|
|||
return activate(0);
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus Vibrator::on(int32_t timeoutMs, const std::shared_ptr<IVibratorCallback>& callback) {
|
||||
ndk::ScopedAStatus Vibrator::on(int32_t timeoutMs,
|
||||
const std::shared_ptr<IVibratorCallback>& callback) {
|
||||
ndk::ScopedAStatus status = activate(timeoutMs);
|
||||
|
||||
if (callback != nullptr) {
|
||||
|
|
@ -84,7 +86,9 @@ ndk::ScopedAStatus Vibrator::on(int32_t timeoutMs, const std::shared_ptr<IVibrat
|
|||
return status;
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus Vibrator::perform(Effect effect, EffectStrength strength, const std::shared_ptr<IVibratorCallback>& callback, int32_t* _aidl_return) {
|
||||
ndk::ScopedAStatus Vibrator::perform(Effect effect, EffectStrength strength,
|
||||
const std::shared_ptr<IVibratorCallback>& callback,
|
||||
int32_t* _aidl_return) {
|
||||
ndk::ScopedAStatus status;
|
||||
uint8_t amplitude;
|
||||
uint32_t ms;
|
||||
|
|
@ -115,14 +119,13 @@ ndk::ScopedAStatus Vibrator::perform(Effect effect, EffectStrength strength, con
|
|||
}
|
||||
|
||||
ndk::ScopedAStatus Vibrator::getSupportedEffects(std::vector<Effect>* _aidl_return) {
|
||||
*_aidl_return = {Effect::CLICK, Effect::DOUBLE_CLICK, Effect::HEAVY_CLICK,
|
||||
Effect::TICK, Effect::TEXTURE_TICK, Effect::THUD, Effect::POP,
|
||||
Effect::RINGTONE_1, Effect::RINGTONE_2, Effect::RINGTONE_3,
|
||||
Effect::RINGTONE_4, Effect::RINGTONE_5, Effect::RINGTONE_6,
|
||||
Effect::RINGTONE_7, Effect::RINGTONE_7, Effect::RINGTONE_8,
|
||||
Effect::RINGTONE_9, Effect::RINGTONE_10, Effect::RINGTONE_11,
|
||||
Effect::RINGTONE_12, Effect::RINGTONE_13, Effect::RINGTONE_14,
|
||||
Effect::RINGTONE_15};
|
||||
*_aidl_return = {
|
||||
Effect::CLICK, Effect::DOUBLE_CLICK, Effect::HEAVY_CLICK, Effect::TICK,
|
||||
Effect::TEXTURE_TICK, Effect::THUD, Effect::POP, Effect::RINGTONE_1,
|
||||
Effect::RINGTONE_2, Effect::RINGTONE_3, Effect::RINGTONE_4, Effect::RINGTONE_5,
|
||||
Effect::RINGTONE_6, Effect::RINGTONE_7, Effect::RINGTONE_7, Effect::RINGTONE_8,
|
||||
Effect::RINGTONE_9, Effect::RINGTONE_10, Effect::RINGTONE_11, Effect::RINGTONE_12,
|
||||
Effect::RINGTONE_13, Effect::RINGTONE_14, Effect::RINGTONE_15};
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
|
|
@ -168,15 +171,18 @@ ndk::ScopedAStatus Vibrator::getCompositionSizeMax(int32_t* /*_aidl_return*/) {
|
|||
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus Vibrator::getSupportedPrimitives(std::vector<CompositePrimitive>* /*_aidl_return*/) {
|
||||
ndk::ScopedAStatus Vibrator::getSupportedPrimitives(
|
||||
std::vector<CompositePrimitive>* /*_aidl_return*/) {
|
||||
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus Vibrator::getPrimitiveDuration(CompositePrimitive /*primitive*/, int32_t* /*_aidl_return*/) {
|
||||
ndk::ScopedAStatus Vibrator::getPrimitiveDuration(CompositePrimitive /*primitive*/,
|
||||
int32_t* /*_aidl_return*/) {
|
||||
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus Vibrator::compose(const std::vector<CompositeEffect>& /*composite*/, const std::shared_ptr<IVibratorCallback>& /*callback*/) {
|
||||
ndk::ScopedAStatus Vibrator::compose(const std::vector<CompositeEffect>& /*composite*/,
|
||||
const std::shared_ptr<IVibratorCallback>& /*callback*/) {
|
||||
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
||||
}
|
||||
|
||||
|
|
@ -184,7 +190,8 @@ ndk::ScopedAStatus Vibrator::getSupportedAlwaysOnEffects(std::vector<Effect>* /*
|
|||
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus Vibrator::alwaysOnEnable(int32_t /*id*/, Effect /*effect*/, EffectStrength /*strength*/) {
|
||||
ndk::ScopedAStatus Vibrator::alwaysOnEnable(int32_t /*id*/, Effect /*effect*/,
|
||||
EffectStrength /*strength*/) {
|
||||
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
||||
}
|
||||
|
||||
|
|
@ -224,7 +231,8 @@ ndk::ScopedAStatus Vibrator::getSupportedBraking(std::vector<Braking>* /*_aidl_r
|
|||
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus Vibrator::composePwle(const std::vector<PrimitivePwle>& /*composite*/, const std::shared_ptr<IVibratorCallback>& /*callback*/) {
|
||||
ndk::ScopedAStatus Vibrator::composePwle(const std::vector<PrimitivePwle>& /*composite*/,
|
||||
const std::shared_ptr<IVibratorCallback>& /*callback*/) {
|
||||
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
||||
}
|
||||
|
||||
|
|
@ -290,7 +298,7 @@ uint32_t Vibrator::effectToMs(Effect effect, ndk::ScopedAStatus* status) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
} // namespace vibrator
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // namespace aidl
|
||||
} // namespace vibrator
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // namespace aidl
|
||||
|
|
|
|||
|
|
@ -15,12 +15,12 @@
|
|||
#define VIBRATOR_TIMEOUT_PATH "/sys/class/timed_output/vibrator/enable"
|
||||
#define VIBRATOR_INTENSITY_PATH "/sys/class/timed_output/vibrator/intensity"
|
||||
|
||||
using ::aidl::android::hardware::vibrator::IVibratorCallback;
|
||||
using ::aidl::android::hardware::vibrator::Braking;
|
||||
using ::aidl::android::hardware::vibrator::Effect;
|
||||
using ::aidl::android::hardware::vibrator::EffectStrength;
|
||||
using ::aidl::android::hardware::vibrator::CompositeEffect;
|
||||
using ::aidl::android::hardware::vibrator::CompositePrimitive;
|
||||
using ::aidl::android::hardware::vibrator::Effect;
|
||||
using ::aidl::android::hardware::vibrator::EffectStrength;
|
||||
using ::aidl::android::hardware::vibrator::IVibratorCallback;
|
||||
using ::aidl::android::hardware::vibrator::PrimitivePwle;
|
||||
|
||||
namespace aidl {
|
||||
|
|
@ -29,20 +29,26 @@ namespace hardware {
|
|||
namespace vibrator {
|
||||
|
||||
class Vibrator : public BnVibrator {
|
||||
public:
|
||||
public:
|
||||
Vibrator();
|
||||
ndk::ScopedAStatus getCapabilities(int32_t* _aidl_return) override;
|
||||
ndk::ScopedAStatus off() override;
|
||||
ndk::ScopedAStatus on(int32_t timeoutMs, const std::shared_ptr<IVibratorCallback>& callback) override;
|
||||
ndk::ScopedAStatus perform(Effect effect, EffectStrength strength, const std::shared_ptr<IVibratorCallback>& callback, int32_t* _aidl_return) override;
|
||||
ndk::ScopedAStatus on(int32_t timeoutMs,
|
||||
const std::shared_ptr<IVibratorCallback>& callback) override;
|
||||
ndk::ScopedAStatus perform(Effect effect, EffectStrength strength,
|
||||
const std::shared_ptr<IVibratorCallback>& callback,
|
||||
int32_t* _aidl_return) override;
|
||||
ndk::ScopedAStatus getSupportedEffects(std::vector<Effect>* _aidl_return) override;
|
||||
ndk::ScopedAStatus setAmplitude(float amplitude) override;
|
||||
ndk::ScopedAStatus setExternalControl(bool enabled) override;
|
||||
ndk::ScopedAStatus getCompositionDelayMax(int32_t* _aidl_return) override;
|
||||
ndk::ScopedAStatus getCompositionSizeMax(int32_t* _aidl_return) override;
|
||||
ndk::ScopedAStatus getSupportedPrimitives(std::vector<CompositePrimitive>* _aidl_return) override;
|
||||
ndk::ScopedAStatus getPrimitiveDuration(CompositePrimitive primitive, int32_t* _aidl_return) override;
|
||||
ndk::ScopedAStatus compose(const std::vector<CompositeEffect>& composite, const std::shared_ptr<IVibratorCallback>& callback) override;
|
||||
ndk::ScopedAStatus getSupportedPrimitives(
|
||||
std::vector<CompositePrimitive>* _aidl_return) override;
|
||||
ndk::ScopedAStatus getPrimitiveDuration(CompositePrimitive primitive,
|
||||
int32_t* _aidl_return) override;
|
||||
ndk::ScopedAStatus compose(const std::vector<CompositeEffect>& composite,
|
||||
const std::shared_ptr<IVibratorCallback>& callback) override;
|
||||
ndk::ScopedAStatus getSupportedAlwaysOnEffects(std::vector<Effect>* _aidl_return) override;
|
||||
ndk::ScopedAStatus alwaysOnEnable(int32_t id, Effect effect, EffectStrength strength) override;
|
||||
ndk::ScopedAStatus alwaysOnDisable(int32_t id) override;
|
||||
|
|
@ -54,9 +60,10 @@ public:
|
|||
ndk::ScopedAStatus getPwlePrimitiveDurationMax(int32_t* _aidl_return) override;
|
||||
ndk::ScopedAStatus getPwleCompositionSizeMax(int32_t* _aidl_return) override;
|
||||
ndk::ScopedAStatus getSupportedBraking(std::vector<Braking>* _aidl_return) override;
|
||||
ndk::ScopedAStatus composePwle(const std::vector<PrimitivePwle>& composite, const std::shared_ptr<IVibratorCallback>& callback) override;
|
||||
ndk::ScopedAStatus composePwle(const std::vector<PrimitivePwle>& composite,
|
||||
const std::shared_ptr<IVibratorCallback>& callback) override;
|
||||
|
||||
private:
|
||||
private:
|
||||
ndk::ScopedAStatus activate(uint32_t ms);
|
||||
static uint32_t effectToMs(Effect effect, ndk::ScopedAStatus* status);
|
||||
static uint8_t strengthToAmplitude(EffectStrength strength, ndk::ScopedAStatus* status);
|
||||
|
|
@ -69,7 +76,7 @@ private:
|
|||
bool mHasTimedOutIntensity;
|
||||
};
|
||||
|
||||
} // namespace vibrator
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // namespace aidl
|
||||
} // namespace vibrator
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // namespace aidl
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
|
||||
#include "Vibrator.h"
|
||||
|
||||
#include <android-base/logging.h>
|
||||
#include <android/binder_manager.h>
|
||||
#include <android/binder_process.h>
|
||||
#include <android-base/logging.h>
|
||||
|
||||
using ::aidl::android::hardware::vibrator::Vibrator;
|
||||
|
||||
|
|
@ -17,9 +17,10 @@ int main() {
|
|||
std::shared_ptr<Vibrator> vibrator = ndk::SharedRefBase::make<Vibrator>();
|
||||
|
||||
const std::string instance = std::string() + Vibrator::descriptor + "/default";
|
||||
binder_status_t status = AServiceManager_addService(vibrator->asBinder().get(), instance.c_str());
|
||||
binder_status_t status =
|
||||
AServiceManager_addService(vibrator->asBinder().get(), instance.c_str());
|
||||
CHECK(status == STATUS_OK);
|
||||
|
||||
ABinderProcess_joinThreadPool();
|
||||
return EXIT_FAILURE; // should not reach
|
||||
return EXIT_FAILURE; // should not reach
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue