Loading vibrator/aidl/aidl_api/android.hardware.vibrator/current/android/hardware/vibrator/VendorEffect.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -37,4 +37,5 @@ parcelable VendorEffect { android.os.PersistableBundle vendorData; android.hardware.vibrator.EffectStrength strength = android.hardware.vibrator.EffectStrength.MEDIUM; float scale; float vendorScale; } vibrator/aidl/android/hardware/vibrator/VendorEffect.aidl +22 −3 Original line number Diff line number Diff line Loading @@ -36,16 +36,35 @@ parcelable VendorEffect { /** * The intensity of the haptic effect. * * This value is defined by discrete scale levels that represents the intensity of this haptic * effect. This is a discrete representation of the scale parameter below. */ EffectStrength strength = EffectStrength.MEDIUM; /** * A scale to be applied to the haptic effect intensity. * The intensity of the haptic effect. * * This value represents a linear scale that should be applied on top of the effect strength to * dynamically adapt to the device state. * This value is defined by continuous scale that represents the intensity of this haptic * effect. The vendor implementation can follow the platform scaling function or customize the * implementation to their needs. This is a continuous representation of the strength parameter * above. * * Values in [0,1) should scale down. Values > 1 should scale up within hardware bounds. */ float scale; /** * The dynamic scale parameter provided by the vendor vibrator controller. * * This value is the same provided by the vendor to the platform IVibratorControlService and * should be applied on top of the effect intensity provided by the strength/scale fields. * The vendor can use this to dynamically adapt the haptic effect intensity to the device state. * * See frameworks/hardware/interfaces/vibrator for more documentation on vendor vibrator * controller, and ScaleParam for more about this scale parameter. * * Values in [0,1) should scale down. Values > 1 should scale up within hardware bounds. */ float vendorScale; } vibrator/aidl/default/Vibrator.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -117,6 +117,10 @@ ndk::ScopedAStatus Vibrator::performVendorEffect( if (scale <= 0) { return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT); } float vendorScale = effect.vendorScale; if (vendorScale <= 0) { return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT); } int32_t durationMs = 0; if (!effect.vendorData.getInt("DURATION_MS", &durationMs) || durationMs <= 0) { Loading vibrator/aidl/vts/VtsHalVibratorTargetTest.cpp +14 −4 Original line number Diff line number Diff line Loading @@ -366,7 +366,8 @@ TEST_P(VibratorAidl, InvalidEffectsUnsupported) { TEST_P(VibratorAidl, PerformVendorEffectSupported) { if ((capabilities & IVibrator::CAP_PERFORM_VENDOR_EFFECTS) == 0) return; float scale = 0.5f; float scale = 0.0f; float vendorScale = 0.0f; for (EffectStrength strength : kEffectStrengths) { PersistableBundle vendorData; ::aidl::android::hardware::vibrator::testing::fillBasicData(&vendorData); Loading @@ -379,7 +380,9 @@ TEST_P(VibratorAidl, PerformVendorEffectSupported) { effect.vendorData = vendorData; effect.strength = strength; effect.scale = scale; scale *= 1.5f; effect.vendorScale = vendorScale; scale += 0.5f; vendorScale += 0.2f; auto callback = ndk::SharedRefBase::make<CompletionCallback>([] {}); ndk::ScopedAStatus status = vibrator->performVendorEffect(effect, callback); Loading Loading @@ -408,6 +411,7 @@ TEST_P(VibratorAidl, PerformVendorEffectStability) { for (EffectStrength strength : kEffectStrengths) { float scale = 0.5f; float vendorScale = 0.2f; for (uint8_t i = 0; i < iterations; i++) { PersistableBundle vendorData; ::aidl::android::hardware::vibrator::testing::fillRandomData(&vendorData); Loading @@ -416,7 +420,9 @@ TEST_P(VibratorAidl, PerformVendorEffectStability) { effect.vendorData = vendorData; effect.strength = strength; effect.scale = scale; effect.vendorScale = vendorScale; scale *= 2; vendorScale *= 1.5f; auto callback = ndk::SharedRefBase::make<CompletionCallback>([] {}); ndk::ScopedAStatus status = vibrator->performVendorEffect(effect, callback); Loading Loading @@ -444,6 +450,7 @@ TEST_P(VibratorAidl, PerformVendorEffectEmptyVendorData) { VendorEffect effect; effect.strength = strength; effect.scale = 1.0f; effect.vendorScale = 1.0f; ndk::ScopedAStatus status = vibrator->performVendorEffect(effect, nullptr /*callback*/); Loading @@ -459,10 +466,12 @@ TEST_P(VibratorAidl, PerformVendorEffectInvalidScale) { VendorEffect effect; effect.strength = EffectStrength::MEDIUM; effect.scale = 0.0f; effect.scale = -1.0f; effect.vendorScale = 1.0f; EXPECT_ILLEGAL_ARGUMENT(vibrator->performVendorEffect(effect, nullptr /*callback*/)); effect.scale = -1.0f; effect.scale = 1.0f; effect.vendorScale = -1.0f; EXPECT_ILLEGAL_ARGUMENT(vibrator->performVendorEffect(effect, nullptr /*callback*/)); } Loading @@ -473,6 +482,7 @@ TEST_P(VibratorAidl, PerformVendorEffectUnsupported) { VendorEffect effect; effect.strength = strength; effect.scale = 1.0f; effect.vendorScale = 1.0f; EXPECT_UNKNOWN_OR_UNSUPPORTED(vibrator->performVendorEffect(effect, nullptr /*callback*/)) << "\n For vendor effect with strength " << toString(strength); Loading Loading
vibrator/aidl/aidl_api/android.hardware.vibrator/current/android/hardware/vibrator/VendorEffect.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -37,4 +37,5 @@ parcelable VendorEffect { android.os.PersistableBundle vendorData; android.hardware.vibrator.EffectStrength strength = android.hardware.vibrator.EffectStrength.MEDIUM; float scale; float vendorScale; }
vibrator/aidl/android/hardware/vibrator/VendorEffect.aidl +22 −3 Original line number Diff line number Diff line Loading @@ -36,16 +36,35 @@ parcelable VendorEffect { /** * The intensity of the haptic effect. * * This value is defined by discrete scale levels that represents the intensity of this haptic * effect. This is a discrete representation of the scale parameter below. */ EffectStrength strength = EffectStrength.MEDIUM; /** * A scale to be applied to the haptic effect intensity. * The intensity of the haptic effect. * * This value represents a linear scale that should be applied on top of the effect strength to * dynamically adapt to the device state. * This value is defined by continuous scale that represents the intensity of this haptic * effect. The vendor implementation can follow the platform scaling function or customize the * implementation to their needs. This is a continuous representation of the strength parameter * above. * * Values in [0,1) should scale down. Values > 1 should scale up within hardware bounds. */ float scale; /** * The dynamic scale parameter provided by the vendor vibrator controller. * * This value is the same provided by the vendor to the platform IVibratorControlService and * should be applied on top of the effect intensity provided by the strength/scale fields. * The vendor can use this to dynamically adapt the haptic effect intensity to the device state. * * See frameworks/hardware/interfaces/vibrator for more documentation on vendor vibrator * controller, and ScaleParam for more about this scale parameter. * * Values in [0,1) should scale down. Values > 1 should scale up within hardware bounds. */ float vendorScale; }
vibrator/aidl/default/Vibrator.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -117,6 +117,10 @@ ndk::ScopedAStatus Vibrator::performVendorEffect( if (scale <= 0) { return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT); } float vendorScale = effect.vendorScale; if (vendorScale <= 0) { return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT); } int32_t durationMs = 0; if (!effect.vendorData.getInt("DURATION_MS", &durationMs) || durationMs <= 0) { Loading
vibrator/aidl/vts/VtsHalVibratorTargetTest.cpp +14 −4 Original line number Diff line number Diff line Loading @@ -366,7 +366,8 @@ TEST_P(VibratorAidl, InvalidEffectsUnsupported) { TEST_P(VibratorAidl, PerformVendorEffectSupported) { if ((capabilities & IVibrator::CAP_PERFORM_VENDOR_EFFECTS) == 0) return; float scale = 0.5f; float scale = 0.0f; float vendorScale = 0.0f; for (EffectStrength strength : kEffectStrengths) { PersistableBundle vendorData; ::aidl::android::hardware::vibrator::testing::fillBasicData(&vendorData); Loading @@ -379,7 +380,9 @@ TEST_P(VibratorAidl, PerformVendorEffectSupported) { effect.vendorData = vendorData; effect.strength = strength; effect.scale = scale; scale *= 1.5f; effect.vendorScale = vendorScale; scale += 0.5f; vendorScale += 0.2f; auto callback = ndk::SharedRefBase::make<CompletionCallback>([] {}); ndk::ScopedAStatus status = vibrator->performVendorEffect(effect, callback); Loading Loading @@ -408,6 +411,7 @@ TEST_P(VibratorAidl, PerformVendorEffectStability) { for (EffectStrength strength : kEffectStrengths) { float scale = 0.5f; float vendorScale = 0.2f; for (uint8_t i = 0; i < iterations; i++) { PersistableBundle vendorData; ::aidl::android::hardware::vibrator::testing::fillRandomData(&vendorData); Loading @@ -416,7 +420,9 @@ TEST_P(VibratorAidl, PerformVendorEffectStability) { effect.vendorData = vendorData; effect.strength = strength; effect.scale = scale; effect.vendorScale = vendorScale; scale *= 2; vendorScale *= 1.5f; auto callback = ndk::SharedRefBase::make<CompletionCallback>([] {}); ndk::ScopedAStatus status = vibrator->performVendorEffect(effect, callback); Loading Loading @@ -444,6 +450,7 @@ TEST_P(VibratorAidl, PerformVendorEffectEmptyVendorData) { VendorEffect effect; effect.strength = strength; effect.scale = 1.0f; effect.vendorScale = 1.0f; ndk::ScopedAStatus status = vibrator->performVendorEffect(effect, nullptr /*callback*/); Loading @@ -459,10 +466,12 @@ TEST_P(VibratorAidl, PerformVendorEffectInvalidScale) { VendorEffect effect; effect.strength = EffectStrength::MEDIUM; effect.scale = 0.0f; effect.scale = -1.0f; effect.vendorScale = 1.0f; EXPECT_ILLEGAL_ARGUMENT(vibrator->performVendorEffect(effect, nullptr /*callback*/)); effect.scale = -1.0f; effect.scale = 1.0f; effect.vendorScale = -1.0f; EXPECT_ILLEGAL_ARGUMENT(vibrator->performVendorEffect(effect, nullptr /*callback*/)); } Loading @@ -473,6 +482,7 @@ TEST_P(VibratorAidl, PerformVendorEffectUnsupported) { VendorEffect effect; effect.strength = strength; effect.scale = 1.0f; effect.vendorScale = 1.0f; EXPECT_UNKNOWN_OR_UNSUPPORTED(vibrator->performVendorEffect(effect, nullptr /*callback*/)) << "\n For vendor effect with strength " << toString(strength); Loading