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

Commit d8f3a3a4 authored by Automerger Merge Worker's avatar Automerger Merge Worker
Browse files

Merge "VibratorService: Conditionally Use Callbacks" into rvc-dev am: 92a82e2d

Change-Id: Ieb02b1e068172fc03a5a590ba837ae44d2a20d9d
parents 7e68e65a 92a82e2d
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -183,7 +183,8 @@ public class VibratorService extends IVibratorService.Stub
    static native boolean vibratorSupportsAmplitudeControl();
    static native void vibratorSetAmplitude(int amplitude);
    static native int[] vibratorGetSupportedEffects();
    static native long vibratorPerformEffect(long effect, long strength, Vibration vibration);
    static native long vibratorPerformEffect(long effect, long strength, Vibration vibration,
            boolean withCallback);
    static native void vibratorPerformComposedEffect(
            VibrationEffect.Composition.PrimitiveEffect[] effect, Vibration vibration);
    static native boolean vibratorSupportsExternalControl();
@@ -1334,7 +1335,8 @@ public class VibratorService extends IVibratorService.Stub
            // Input devices don't support prebaked effect, so skip trying it with them.
            if (!usingInputDeviceVibrators) {
                long duration = vibratorPerformEffect(prebaked.getId(),
                        prebaked.getEffectStrength(), vib);
                        prebaked.getEffectStrength(), vib,
                        hasCapability(IVibrator.CAP_PERFORM_CALLBACK));
                long timeout = duration;
                if (hasCapability(IVibrator.CAP_PERFORM_CALLBACK)) {
                    timeout *= ASYNC_TIMEOUT_MULTIPLIER;
+21 −20
Original line number Diff line number Diff line
@@ -355,10 +355,11 @@ static jintArray vibratorGetSupportedEffects(JNIEnv *env, jclass) {
}

static jlong vibratorPerformEffect(JNIEnv* env, jclass, jlong effect, jlong strength,
                                   jobject vibration) {
                                   jobject vibration, jboolean withCallback) {
    if (auto hal = getHal<aidl::IVibrator>()) {
        int32_t lengthMs;
        sp<AidlVibratorCallback> effectCallback = new AidlVibratorCallback(env, vibration);
        sp<AidlVibratorCallback> effectCallback =
                (withCallback != JNI_FALSE ? new AidlVibratorCallback(env, vibration) : nullptr);
        aidl::Effect effectType(static_cast<aidl::Effect>(effect));
        aidl::EffectStrength effectStrength(static_cast<aidl::EffectStrength>(strength));

@@ -484,13 +485,13 @@ static const JNINativeMethod method_table[] = {
        {"vibratorOff", "()V", (void*)vibratorOff},
        {"vibratorSupportsAmplitudeControl", "()Z", (void*)vibratorSupportsAmplitudeControl},
        {"vibratorSetAmplitude", "(I)V", (void*)vibratorSetAmplitude},
    { "vibratorPerformEffect", "(JJLcom/android/server/VibratorService$Vibration;)J",
        {"vibratorPerformEffect", "(JJLcom/android/server/VibratorService$Vibration;Z)J",
         (void*)vibratorPerformEffect},
        {"vibratorPerformComposedEffect",
            "([Landroid/os/VibrationEffect$Composition$PrimitiveEffect;Lcom/android/server/VibratorService$Vibration;)V",
         "([Landroid/os/VibrationEffect$Composition$PrimitiveEffect;Lcom/android/server/"
         "VibratorService$Vibration;)V",
         (void*)vibratorPerformComposedEffect},
    { "vibratorGetSupportedEffects", "()[I",
            (void*)vibratorGetSupportedEffects},
        {"vibratorGetSupportedEffects", "()[I", (void*)vibratorGetSupportedEffects},
        {"vibratorSupportsExternalControl", "()Z", (void*)vibratorSupportsExternalControl},
        {"vibratorSetExternalControl", "(Z)V", (void*)vibratorSetExternalControl},
        {"vibratorGetCapabilities", "()J", (void*)vibratorGetCapabilities},