vibrator: Add Vibrator HAL 1.3
Bug: 117835666 Test: Sanity Check Via 'cmd vibrator' Change-Id: I6cd13429895e1d8b26d6f615a359561986b6b871 Signed-off-by: Harpreet "Eli" Sangha <eliptus@google.com>
This commit is contained in:
parent
ba281ccf76
commit
a456f087a2
@ -735,6 +735,7 @@ java_defaults {
|
||||
"android.hardware.vibrator-V1.0-java",
|
||||
"android.hardware.vibrator-V1.1-java",
|
||||
"android.hardware.vibrator-V1.2-java",
|
||||
"android.hardware.vibrator-V1.3-java",
|
||||
"android.hardware.wifi-V1.0-java-constants",
|
||||
"android.hardware.radio-V1.0-java",
|
||||
"android.hardware.radio-V1.3-java",
|
||||
|
@ -149,6 +149,8 @@ public class VibratorService extends IVibratorService.Stub
|
||||
native static boolean vibratorSupportsAmplitudeControl();
|
||||
native static void vibratorSetAmplitude(int amplitude);
|
||||
native static long vibratorPerformEffect(long effect, long strength);
|
||||
static native boolean vibratorSupportsExternalControl();
|
||||
static native void vibratorSetExternalControl(boolean enabled);
|
||||
|
||||
private final IUidObserver mUidObserver = new IUidObserver.Stub() {
|
||||
@Override public void onUidStateChanged(int uid, int procState, long procStateSeq) {
|
||||
|
@ -118,6 +118,7 @@ cc_defaults {
|
||||
"android.hardware.vibrator@1.0",
|
||||
"android.hardware.vibrator@1.1",
|
||||
"android.hardware.vibrator@1.2",
|
||||
"android.hardware.vibrator@1.3",
|
||||
"android.hardware.vr@1.0",
|
||||
"android.frameworks.schedulerservice@1.0",
|
||||
"android.frameworks.sensorservice@1.0",
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include <android/hardware/vibrator/1.1/types.h>
|
||||
#include <android/hardware/vibrator/1.2/IVibrator.h>
|
||||
#include <android/hardware/vibrator/1.2/types.h>
|
||||
#include <android/hardware/vibrator/1.3/IVibrator.h>
|
||||
|
||||
#include "jni.h"
|
||||
#include <nativehelper/JNIHelp.h>
|
||||
@ -42,6 +43,7 @@ using android::hardware::vibrator::V1_1::Effect_1_1;
|
||||
namespace V1_0 = android::hardware::vibrator::V1_0;
|
||||
namespace V1_1 = android::hardware::vibrator::V1_1;
|
||||
namespace V1_2 = android::hardware::vibrator::V1_2;
|
||||
namespace V1_3 = android::hardware::vibrator::V1_3;
|
||||
|
||||
namespace android {
|
||||
|
||||
@ -136,6 +138,19 @@ static void vibratorSetAmplitude(JNIEnv*, jobject, jint amplitude) {
|
||||
}
|
||||
}
|
||||
|
||||
static jboolean vibratorSupportsExternalControl(JNIEnv*, jobject) {
|
||||
return halCall(&V1_3::IVibrator::supportsExternalControl).withDefault(false);
|
||||
}
|
||||
|
||||
static void vibratorSetExternalControl(JNIEnv*, jobject, jboolean enabled) {
|
||||
Status status = halCall(&V1_3::IVibrator::setExternalControl, static_cast<uint32_t>(enabled))
|
||||
.withDefault(Status::UNKNOWN_ERROR);
|
||||
if (status != Status::OK) {
|
||||
ALOGE("Failed to set vibrator external control (%" PRIu32 ").",
|
||||
static_cast<uint32_t>(status));
|
||||
}
|
||||
}
|
||||
|
||||
static jlong vibratorPerformEffect(JNIEnv*, jobject, jlong effect, jint strength) {
|
||||
Status status;
|
||||
uint32_t lengthMs;
|
||||
@ -187,7 +202,9 @@ static const JNINativeMethod method_table[] = {
|
||||
{ "vibratorOff", "()V", (void*)vibratorOff },
|
||||
{ "vibratorSupportsAmplitudeControl", "()Z", (void*)vibratorSupportsAmplitudeControl},
|
||||
{ "vibratorSetAmplitude", "(I)V", (void*)vibratorSetAmplitude},
|
||||
{ "vibratorPerformEffect", "(JJ)J", (void*)vibratorPerformEffect}
|
||||
{ "vibratorPerformEffect", "(JJ)J", (void*)vibratorPerformEffect},
|
||||
{ "vibratorSupportsExternalControl", "()Z", (void*)vibratorSupportsExternalControl},
|
||||
{ "vibratorSetExternalControl", "(Z)V", (void*)vibratorSetExternalControl},
|
||||
};
|
||||
|
||||
int register_android_server_VibratorService(JNIEnv *env)
|
||||
|
Loading…
x
Reference in New Issue
Block a user