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

Commit 4d8cd298 authored by Tyler Gunn's avatar Tyler Gunn
Browse files

Add overlay to control vibration pattern used by device.

Added an overlay which is used to determine which vibration pattern a
device uses.  The new vibration pattern ramps up in intensity, which may
not work well on some vibration hardware.  Devices with vibration hardware
that does not work well with the new pattern can overlay the new config
overlay value to indicate that the old-style simple pattern is used
instead.

Test: Manually tested simple vs fancy vibration pattern.
Bug: 68374140
Change-Id: Icfbac1342de562a2891d7af5d11b79d111f2898d
parent f9257363
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -50,4 +50,9 @@
    <!-- Determines if the granting of temporary location permission to the default dialer
         during an emergency call should be allowed. -->
    <bool name="grant_location_permission_enabled">false</bool>

    <!-- When true, a simple full intensity on/off vibration pattern will be used when calls ring.
         When false, a fancy vibration pattern which ramps up and down will be used.
         Devices should overlay this value based on the type of vibration hardware they employ. -->
    <bool name="use_simple_vibration_pattern">false</bool>
</resources>
+21 −2
Original line number Diff line number Diff line
@@ -49,6 +49,18 @@ public class Ringer {
            255, // Peak
            0}; // pause before repetition

    private static final long[] SIMPLE_VIBRATION_PATTERN = {
            0, // No delay before starting
            1000, // How long to vibrate
            1000, // How long to wait before vibrating again
    };

    private static final int[] SIMPLE_VIBRATION_AMPLITUDE = {
            0, // No delay before starting
            255, // Vibrate full amplitude
            0, // No amplitude while waiting
    };

    /**
     * Indicates that vibration should be repeated at element 5 in the {@link #PULSE_AMPLITUDE} and
     * {@link #PULSE_PATTERN} arrays.  This means repetition will happen for the main ease-in/peak
@@ -56,6 +68,8 @@ public class Ringer {
     */
    private static final int REPEAT_VIBRATION_AT = 5;

    private static final int REPEAT_SIMPLE_VIBRATION_AT = 1;

    private static final AudioAttributes VIBRATION_ATTRIBUTES = new AudioAttributes.Builder()
            .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
            .setUsage(AudioAttributes.USAGE_NOTIFICATION_RINGTONE)
@@ -110,9 +124,14 @@ public class Ringer {
        mRingtoneFactory = ringtoneFactory;
        mInCallController = inCallController;

        if (mContext.getResources().getBoolean(R.bool.use_simple_vibration_pattern)) {
            mVibrationEffect = VibrationEffect.createWaveform(SIMPLE_VIBRATION_PATTERN,
                    SIMPLE_VIBRATION_AMPLITUDE, REPEAT_SIMPLE_VIBRATION_AT);
        } else {
            mVibrationEffect = VibrationEffect.createWaveform(PULSE_PATTERN, PULSE_AMPLITUDE,
                    REPEAT_VIBRATION_AT);
        }
    }

    public boolean startRinging(Call foregroundCall, boolean isHfpDeviceAttached) {
        if (foregroundCall == null) {