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

Commit 8de19bf8 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 8555638 from b5a27f81 to tm-qpr1-release

Change-Id: Ife320ba79acbcd7162f10f5b5c40ada048ea7c3e
parents 1a5d3e0a b5a27f81
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -4138,8 +4138,8 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
        return mStartRingTime;
        return mStartRingTime;
    }
    }


    public void setStartRingTime(long startRingTime) {
    public void setStartRingTime() {
        mStartRingTime = startRingTime;
        mStartRingTime = mClockProxy.elapsedRealtime();
    }
    }


    public CharSequence getCallScreeningAppName() {
    public CharSequence getCallScreeningAppName() {
+5 −1
Original line number Original line Diff line number Diff line
@@ -468,8 +468,12 @@ public class CallAudioManager extends CallsManagerListenerBase {
    @VisibleForTesting
    @VisibleForTesting
    public boolean startRinging() {
    public boolean startRinging() {
        synchronized (mCallsManager.getLock()) {
        synchronized (mCallsManager.getLock()) {
            return mRinger.startRinging(mForegroundCall,
            boolean result = mRinger.startRinging(mForegroundCall,
                    mCallAudioRouteStateMachine.isHfpDeviceAvailable());
                    mCallAudioRouteStateMachine.isHfpDeviceAvailable());
            if (result) {
                mForegroundCall.setStartRingTime();
            }
            return result;
        }
        }
    }
    }


+25 −0
Original line number Original line Diff line number Diff line
@@ -17,6 +17,10 @@
package com.android.server.telecom;
package com.android.server.telecom;


import static android.provider.CallLog.Calls.MISSED_REASON_NOT_MISSED;
import static android.provider.CallLog.Calls.MISSED_REASON_NOT_MISSED;
import static android.provider.CallLog.Calls.SHORT_RING_THRESHOLD;
import static android.provider.CallLog.Calls.USER_MISSED_NEVER_RANG;
import static android.provider.CallLog.Calls.USER_MISSED_NO_ANSWER;
import static android.provider.CallLog.Calls.USER_MISSED_SHORT_RING;
import static android.telecom.TelecomManager.ACTION_POST_CALL;
import static android.telecom.TelecomManager.ACTION_POST_CALL;
import static android.telecom.TelecomManager.DURATION_LONG;
import static android.telecom.TelecomManager.DURATION_LONG;
import static android.telecom.TelecomManager.DURATION_MEDIUM;
import static android.telecom.TelecomManager.DURATION_MEDIUM;
@@ -3142,6 +3146,22 @@ public class CallsManager extends Call.ListenerBase
            // be marked as missed.
            // be marked as missed.
            call.setOverrideDisconnectCauseCode(new DisconnectCause(DisconnectCause.MISSED));
            call.setOverrideDisconnectCauseCode(new DisconnectCause(DisconnectCause.MISSED));
        }
        }
        if (call.getState() == CallState.NEW
                && disconnectCause.getCode() == DisconnectCause.MISSED) {
            Log.i(this, "markCallAsDisconnected: missed call never rang ", call.getId());
            call.setMissedReason(USER_MISSED_NEVER_RANG);
        }
        if (call.getState() == CallState.RINGING
                || call.getState() == CallState.SIMULATED_RINGING) {
            if (call.getStartRingTime() > 0
                    && (mClockProxy.elapsedRealtime() - call.getStartRingTime())
                    < SHORT_RING_THRESHOLD) {
                Log.i(this, "markCallAsDisconnected; callid=%s, short ring.", call.getId());
                call.setUserMissed(USER_MISSED_SHORT_RING);
            } else if (call.getStartRingTime() > 0) {
                call.setUserMissed(USER_MISSED_NO_ANSWER);
            }
        }


        // If a call diagnostic service is in use, we will log the original telephony-provided
        // If a call diagnostic service is in use, we will log the original telephony-provided
        // disconnect cause, inform the CDS of the disconnection, and then chain the update of the
        // disconnect cause, inform the CDS of the disconnection, and then chain the update of the
@@ -5608,4 +5628,9 @@ public class CallsManager extends Call.ListenerBase
        mCalls.forEach(c -> Log.addEvent(c, LogUtils.Events.USER_LOG_MARK, message));
        mCalls.forEach(c -> Log.addEvent(c, LogUtils.Events.USER_LOG_MARK, message));
        Log.addEvent(null /* global */, LogUtils.Events.USER_LOG_MARK, message);
        Log.addEvent(null /* global */, LogUtils.Events.USER_LOG_MARK, message);
    }
    }

    @VisibleForTesting
    public Ringer getRinger() {
        return mRinger;
    }
}
}
+30 −2
Original line number Original line Diff line number Diff line
@@ -16,6 +16,10 @@


package com.android.server.telecom;
package com.android.server.telecom;


import static android.provider.CallLog.Calls.USER_MISSED_DND_MODE;
import static android.provider.CallLog.Calls.USER_MISSED_LOW_RING_VOLUME;
import static android.provider.CallLog.Calls.USER_MISSED_NO_VIBRATE;

import android.app.Notification;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.NotificationManager;
import android.app.Person;
import android.app.Person;
@@ -38,6 +42,7 @@ import com.android.server.telecom.LogUtils.EventTimer;


import java.util.ArrayList;
import java.util.ArrayList;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.TimeoutException;
@@ -59,6 +64,9 @@ public class Ringer {
    @VisibleForTesting
    @VisibleForTesting
    public VibrationEffect mDefaultVibrationEffect;
    public VibrationEffect mDefaultVibrationEffect;


    // Used for test to notify the completion of RingerAttributes
    private CountDownLatch mAttributesLatch;

    private static final long[] PULSE_PRIMING_PATTERN = {0,12,250,12,500}; // priming  + interval
    private static final long[] PULSE_PRIMING_PATTERN = {0,12,250,12,500}; // priming  + interval


    private static final int[] PULSE_PRIMING_AMPLITUDE = {0,255,0,255,0};  // priming  + interval
    private static final int[] PULSE_PRIMING_AMPLITUDE = {0,255,0,255,0};  // priming  + interval
@@ -193,7 +201,6 @@ public class Ringer {
        mRingtoneFactory = ringtoneFactory;
        mRingtoneFactory = ringtoneFactory;
        mInCallController = inCallController;
        mInCallController = inCallController;
        mVibrationEffectProxy = vibrationEffectProxy;
        mVibrationEffectProxy = vibrationEffectProxy;
        mAudioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);


        if (mContext.getResources().getBoolean(R.bool.use_simple_vibration_pattern)) {
        if (mContext.getResources().getBoolean(R.bool.use_simple_vibration_pattern)) {
            mDefaultVibrationEffect = mVibrationEffectProxy.createWaveform(SIMPLE_VIBRATION_PATTERN,
            mDefaultVibrationEffect = mVibrationEffectProxy.createWaveform(SIMPLE_VIBRATION_PATTERN,
@@ -236,6 +243,7 @@ public class Ringer {


        RingerAttributes attributes = null;
        RingerAttributes attributes = null;
        try {
        try {
            mAttributesLatch = new CountDownLatch(1);
            attributes = ringerAttributesFuture.get(
            attributes = ringerAttributesFuture.get(
                    RINGER_ATTRIBUTES_TIMEOUT, TimeUnit.MILLISECONDS);
                    RINGER_ATTRIBUTES_TIMEOUT, TimeUnit.MILLISECONDS);
        } catch (ExecutionException | InterruptedException | TimeoutException e) {
        } catch (ExecutionException | InterruptedException | TimeoutException e) {
@@ -351,6 +359,7 @@ public class Ringer {
    private void maybeStartVibration(Call foregroundCall, boolean shouldRingForContact,
    private void maybeStartVibration(Call foregroundCall, boolean shouldRingForContact,
        VibrationEffect effect, boolean isVibrationEnabled, boolean isRingerAudible) {
        VibrationEffect effect, boolean isVibrationEnabled, boolean isRingerAudible) {
        synchronized (mLock) {
        synchronized (mLock) {
            mAudioManager = mContext.getSystemService(AudioManager.class);
            if (isVibrationEnabled
            if (isVibrationEnabled
                    && !mIsVibrating && shouldRingForContact) {
                    && !mIsVibrating && shouldRingForContact) {
                Log.addEvent(foregroundCall, LogUtils.Events.START_VIBRATOR,
                Log.addEvent(foregroundCall, LogUtils.Events.START_VIBRATOR,
@@ -367,12 +376,12 @@ public class Ringer {
                mIsVibrating = true;
                mIsVibrating = true;
                mVibrator.vibrate(effect, VIBRATION_ATTRIBUTES);
                mVibrator.vibrate(effect, VIBRATION_ATTRIBUTES);
            } else {
            } else {
                foregroundCall.setUserMissed(USER_MISSED_NO_VIBRATE);
                Log.addEvent(foregroundCall, LogUtils.Events.SKIP_VIBRATION,
                Log.addEvent(foregroundCall, LogUtils.Events.SKIP_VIBRATION,
                        "hasVibrator=%b, userRequestsVibrate=%b, ringerMode=%d, isVibrating=%b",
                        "hasVibrator=%b, userRequestsVibrate=%b, ringerMode=%d, isVibrating=%b",
                        mVibrator.hasVibrator(),
                        mVibrator.hasVibrator(),
                        mSystemSettingsUtil.canVibrateWhenRinging(mContext),
                        mSystemSettingsUtil.canVibrateWhenRinging(mContext),
                        mAudioManager.getRingerModeInternal(), mIsVibrating);
                        mAudioManager.getRingerModeInternal(), mIsVibrating);
                Log.addEvent(foregroundCall, LogUtils.Events.SKIP_VIBRATION, "already vibrating");
            }
            }
        }
        }
    }
    }
@@ -516,6 +525,7 @@ public class Ringer {
    }
    }


    private RingerAttributes getRingerAttributes(Call call, boolean isHfpDeviceAttached) {
    private RingerAttributes getRingerAttributes(Call call, boolean isHfpDeviceAttached) {
        mAudioManager = mContext.getSystemService(AudioManager.class);
        RingerAttributes.Builder builder = new RingerAttributes.Builder();
        RingerAttributes.Builder builder = new RingerAttributes.Builder();


        LogUtils.EventTimer timer = new EventTimer();
        LogUtils.EventTimer timer = new EventTimer();
@@ -567,6 +577,15 @@ public class Ringer {
        boolean shouldAcquireAudioFocus =
        boolean shouldAcquireAudioFocus =
                isRingerAudible || (isHfpDeviceAttached && shouldRingForContact) || isSelfManaged;
                isRingerAudible || (isHfpDeviceAttached && shouldRingForContact) || isSelfManaged;


        // Set missed reason according to attributes
        if (!isVolumeOverZero) {
            call.setUserMissed(USER_MISSED_LOW_RING_VOLUME);
        }
        if (!shouldRingForContact) {
            call.setUserMissed(USER_MISSED_DND_MODE);
        }

        mAttributesLatch.countDown();
        return builder.setEndEarly(endEarly)
        return builder.setEndEarly(endEarly)
                .setLetDialerHandleRinging(letDialerHandleRinging)
                .setLetDialerHandleRinging(letDialerHandleRinging)
                .setAcquireAudioFocus(shouldAcquireAudioFocus)
                .setAcquireAudioFocus(shouldAcquireAudioFocus)
@@ -585,4 +604,13 @@ public class Ringer {
        }
        }
        return mHandler;
        return mHandler;
    }
    }

    @VisibleForTesting
    public boolean waitForAttributesCompletion() throws InterruptedException {
        if (mAttributesLatch != null) {
            return mAttributesLatch.await(RINGER_ATTRIBUTES_TIMEOUT, TimeUnit.MILLISECONDS);
        } else {
            return false;
        }
    }
}
}
+3 −1
Original line number Original line Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.server.telecom.tests;


import static android.provider.CallLog.Calls.MISSED_REASON_NOT_MISSED;
import static android.provider.CallLog.Calls.MISSED_REASON_NOT_MISSED;
import static android.provider.CallLog.Calls.USER_MISSED_CALL_FILTERS_TIMEOUT;
import static android.provider.CallLog.Calls.USER_MISSED_CALL_FILTERS_TIMEOUT;
import static android.provider.CallLog.Calls.USER_MISSED_NO_VIBRATE;


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertFalse;
@@ -209,7 +210,8 @@ public class AnalyticsTests extends TelecomSystemTest {
        assertEquals(0, callAnalytics2.endTime);
        assertEquals(0, callAnalytics2.endTime);
        long missedReason1 = callAnalytics1.missedReason;
        long missedReason1 = callAnalytics1.missedReason;
        assertTrue(missedReason1 == MISSED_REASON_NOT_MISSED
        assertTrue(missedReason1 == MISSED_REASON_NOT_MISSED
                || missedReason1 == USER_MISSED_CALL_FILTERS_TIMEOUT);
                || ((missedReason1 & USER_MISSED_CALL_FILTERS_TIMEOUT) > 0)
                || ((missedReason1 & USER_MISSED_NO_VIBRATE) > 0));
        assertEquals(MISSED_REASON_NOT_MISSED, callAnalytics2.missedReason);
        assertEquals(MISSED_REASON_NOT_MISSED, callAnalytics2.missedReason);


        assertEquals(Analytics.INCOMING_DIRECTION, callAnalytics1.callDirection);
        assertEquals(Analytics.INCOMING_DIRECTION, callAnalytics1.callDirection);
Loading