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

Commit fb67b77c authored by Tyler Gunn's avatar Tyler Gunn Committed by Android (Google) Code Review
Browse files

Merge "Add overlay to control vibration pattern used by device." into pi-dev

parents 980ccdca 4d8cd298
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) {