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

Commit ac1eebc3 authored by Danny Baumann's avatar Danny Baumann Committed by Bruno Martins
Browse files

Add back increasing ring feature (1/2).

Change-Id: I1d5173fb8134400e5fa72c19181f34e1a5ec4e0d
parent 9173f3a0
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -17,7 +17,10 @@ filegroup {
// Build the Telecom service.
android_app {
    name: "Telecom",
    static_libs: ["org.lineageos.lib.phone"],
    static_libs: [
        "org.lineageos.lib.phone",
        "org.lineageos.platform.internal",
    ],
    srcs: [
        ":Telecom-srcs",
        "proto/**/*.proto",
+30 −3
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.server.telecom;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.Person;
import android.content.ContentResolver;
import android.content.Context;
import android.os.VibrationEffect;
import android.telecom.Log;
@@ -34,6 +35,8 @@ import android.os.Vibrator;
import com.android.internal.annotations.VisibleForTesting;
import com.android.server.telecom.LogUtils.EventTimer;

import lineageos.providers.LineageSettings;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -77,6 +80,9 @@ public class Ringer {
    private static final int RAMPING_RINGER_VIBRATION_DURATION = 5000;
    private static final int RAMPING_RINGER_DURATION = 10000;

    private int mRampingRingerDuration = -1;  // ramping ringer duration in millisecond
    private float mRampingRingerStartVolume = 0f;

    static {
        // construct complete pulse pattern
        PULSE_PATTERN = new long[PULSE_PRIMING_PATTERN.length + PULSE_RAMPING_PATTERN.length];
@@ -303,9 +309,30 @@ public class Ringer {
                hapticsFuture = mRingtonePlayer.play(mRingtoneFactory, foregroundCall,
                        mVolumeShaperConfig, isVibratorEnabled);
            } else {
                // Ramping ringtone is not enabled.
                hapticsFuture = mRingtonePlayer.play(mRingtoneFactory, foregroundCall, null,
                        isVibratorEnabled);
                final ContentResolver cr = mContext.getContentResolver();
                if (LineageSettings.System.getInt(cr,
                        LineageSettings.System.INCREASING_RING, 0) != 0) {
                    float startVolume = LineageSettings.System.getFloat(cr,
                            LineageSettings.System.INCREASING_RING_START_VOLUME, 0.1f);
                    int rampUpTime = LineageSettings.System.getInt(cr,
                            LineageSettings.System.INCREASING_RING_RAMP_UP_TIME, 20);
                    if (mVolumeShaperConfig == null
                        || mRampingRingerDuration != rampUpTime
                        || mRampingRingerStartVolume != startVolume) {
                        mVolumeShaperConfig = new VolumeShaper.Configuration.Builder()
                            .setDuration(rampUpTime * 1000)
                            .setCurve(new float[] {0.f, 1.f}, new float[] {startVolume, 1.f})
                            .setInterpolatorType(VolumeShaper
                                    .Configuration.INTERPOLATOR_TYPE_LINEAR)
                            .build();
                        mRampingRingerDuration = rampUpTime;
                        mRampingRingerStartVolume = startVolume;
                    }
                } else {
                    mVolumeShaperConfig = null;
                }
                hapticsFuture = mRingtonePlayer.play(mRingtoneFactory, foregroundCall,
                        mVolumeShaperConfig, isVibratorEnabled);
                effect = getVibrationEffectForCall(mRingtoneFactory, foregroundCall);
            }
        } else {