Loading src/com/android/server/telecom/Analytics.java +34 −2 Original line number Diff line number Diff line Loading @@ -50,6 +50,16 @@ import java.util.Map; import java.util.concurrent.LinkedBlockingDeque; import java.util.stream.Collectors; import static android.provider.CallLog.Calls.AUTO_MISSED_EMERGENCY_CALL; import static android.provider.CallLog.Calls.AUTO_MISSED_MAXIMUM_DIALING; import static android.provider.CallLog.Calls.AUTO_MISSED_MAXIMUM_RINGING; import static android.provider.CallLog.Calls.USER_MISSED_CALL_FILTERS_TIMEOUT; import static android.provider.CallLog.Calls.USER_MISSED_CALL_SCREENING_SERVICE_SILENCED; 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_NEVER_RANG; import static android.provider.CallLog.Calls.USER_MISSED_NO_VIBRATE; import static android.provider.CallLog.Calls.USER_MISSED_SHORT_RING; import static android.telecom.ParcelableCallAnalytics.AnalyticsEvent; import static android.telecom.TelecomAnalytics.SessionTiming; Loading Loading @@ -542,8 +552,30 @@ public class Analytics { } private String getMissedReasonString() { //TODO: Implement this return null; StringBuilder s = new StringBuilder(); s.append('['); if ((missedReason & AUTO_MISSED_EMERGENCY_CALL) != 0) { s.append("emergency]"); return s.toString(); } else if ((missedReason & AUTO_MISSED_MAXIMUM_DIALING) != 0) { s.append("max_dialing]"); return s.toString(); } else if ((missedReason & AUTO_MISSED_MAXIMUM_RINGING) != 0) { s.append("max_ringing]"); return s.toString(); } // user missed if ((missedReason & USER_MISSED_SHORT_RING) != 0) s.append("short_ring "); if ((missedReason & USER_MISSED_DND_MODE) != 0) s.append("dnd "); if ((missedReason & USER_MISSED_LOW_RING_VOLUME) != 0) s.append("low_volume "); if ((missedReason & USER_MISSED_NO_VIBRATE) != 0) s.append("no_vibrate "); if ((missedReason & USER_MISSED_CALL_SCREENING_SERVICE_SILENCED) != 0) s.append("css_silenced "); if ((missedReason & USER_MISSED_CALL_FILTERS_TIMEOUT) != 0) s.append("filter_timeout "); if ((missedReason & USER_MISSED_NEVER_RANG) != 0) s.append("no_ring "); s.append("]"); return s.toString(); } private String getInCallServicesString() { Loading src/com/android/server/telecom/Ringer.java +4 −3 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ 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 static android.provider.Settings.Global.ZEN_MODE_OFF; import android.app.Notification; import android.app.NotificationManager; Loading Loading @@ -531,7 +532,6 @@ public class Ringer { return mRingtonePlayer.isPlaying(); } /** * shouldRingForContact checks if the caller matches one of the Do Not Disturb bypass * settings (ex. A contact or repeat caller might be able to bypass DND settings). If Loading @@ -546,7 +546,6 @@ public class Ringer { } final Uri contactUri = call.getHandle(); final Bundle peopleExtras = new Bundle(); if (contactUri != null) { ArrayList<Person> personList = new ArrayList<>(); Loading Loading @@ -575,10 +574,12 @@ public class Ringer { AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); // Use AudioManager#getRingerMode for more accurate result, instead of // AudioManager#getRingerModeInternal which only useful for volume controllers boolean zenModeOn = mNotificationManager != null && mNotificationManager.getZenMode() != ZEN_MODE_OFF; return mVibrator.hasVibrator() && mSystemSettingsUtil.isRingVibrationEnabled(context) && (audioManager.getRingerMode() != AudioManager.RINGER_MODE_SILENT || shouldRingForContact); || (zenModeOn && shouldRingForContact)); } private RingerAttributes getRingerAttributes(Call call, boolean isHfpDeviceAttached) { Loading tests/src/com/android/server/telecom/tests/RingerTest.java +10 −7 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.server.telecom.tests; import static android.provider.Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; Loading Loading @@ -134,6 +136,7 @@ public class RingerTest extends TelecomTestCase { @Mock RingtoneFactory mockRingtoneFactory; @Mock Vibrator mockVibrator; @Mock InCallController mockInCallController; @Mock NotificationManager mockNotificationManager; @Spy Ringer.VibrationEffectProxy spyVibrationEffectProxy; @Mock InCallTonePlayer mockTonePlayer; Loading Loading @@ -161,17 +164,18 @@ public class RingerTest extends TelecomTestCase { when(mockAudioManager.getRingerMode()).thenReturn(AudioManager.RINGER_MODE_NORMAL); when(mockSystemSettingsUtil.isHapticPlaybackSupported(any(Context.class))).thenReturn(true); NotificationManager notificationManager = mockNotificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE); when(mockTonePlayer.startTone()).thenReturn(true); when(notificationManager.matchesCallFilter(any(Bundle.class))).thenReturn(true); when(mockNotificationManager.matchesCallFilter(any(Bundle.class))).thenReturn(true); when(mockRingtoneFactory.hasHapticChannels(any(Ringtone.class))).thenReturn(false); mRingerUnderTest = new Ringer(mockPlayerFactory, mContext, mockSystemSettingsUtil, mockRingtonePlayer, mockRingtoneFactory, mockVibrator, spyVibrationEffectProxy, mockInCallController, notificationManager); mockInCallController, mNotificationManager); when(mockCall1.getState()).thenReturn(CallState.RINGING); when(mockCall2.getState()).thenReturn(CallState.RINGING); mRingerUnderTest.setBlockOnRingingFuture(mRingCompletionFuture); mRingerUnderTest.setNotificationManager(mockNotificationManager); } @Override Loading Loading @@ -268,9 +272,7 @@ public class RingerTest extends TelecomTestCase { @SmallTest @Test public void testCallWaitingButNoRingForSpecificContacts() { NotificationManager notificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE); when(notificationManager.matchesCallFilter(any(Bundle.class))).thenReturn(false); when(mockNotificationManager.matchesCallFilter(any(Bundle.class))).thenReturn(false); // Start call waiting to make sure that it does stop when we start ringing mRingerUnderTest.startCallWaiting(mockCall1); verify(mockTonePlayer).startTone(); Loading Loading @@ -465,6 +467,7 @@ public class RingerTest extends TelecomTestCase { public void testRingAndVibrateForAllowedCallInDndMode() throws Exception { mRingerUnderTest.startCallWaiting(mockCall1); Ringtone mockRingtone = mock(Ringtone.class); when(mockNotificationManager.getZenMode()).thenReturn(ZEN_MODE_IMPORTANT_INTERRUPTIONS); when(mockRingtoneFactory.getRingtone(any(Call.class), eq(null), anyBoolean())) .thenReturn(mockRingtone); when(mockAudioManager.getRingerMode()).thenReturn(AudioManager.RINGER_MODE_SILENT); Loading Loading
src/com/android/server/telecom/Analytics.java +34 −2 Original line number Diff line number Diff line Loading @@ -50,6 +50,16 @@ import java.util.Map; import java.util.concurrent.LinkedBlockingDeque; import java.util.stream.Collectors; import static android.provider.CallLog.Calls.AUTO_MISSED_EMERGENCY_CALL; import static android.provider.CallLog.Calls.AUTO_MISSED_MAXIMUM_DIALING; import static android.provider.CallLog.Calls.AUTO_MISSED_MAXIMUM_RINGING; import static android.provider.CallLog.Calls.USER_MISSED_CALL_FILTERS_TIMEOUT; import static android.provider.CallLog.Calls.USER_MISSED_CALL_SCREENING_SERVICE_SILENCED; 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_NEVER_RANG; import static android.provider.CallLog.Calls.USER_MISSED_NO_VIBRATE; import static android.provider.CallLog.Calls.USER_MISSED_SHORT_RING; import static android.telecom.ParcelableCallAnalytics.AnalyticsEvent; import static android.telecom.TelecomAnalytics.SessionTiming; Loading Loading @@ -542,8 +552,30 @@ public class Analytics { } private String getMissedReasonString() { //TODO: Implement this return null; StringBuilder s = new StringBuilder(); s.append('['); if ((missedReason & AUTO_MISSED_EMERGENCY_CALL) != 0) { s.append("emergency]"); return s.toString(); } else if ((missedReason & AUTO_MISSED_MAXIMUM_DIALING) != 0) { s.append("max_dialing]"); return s.toString(); } else if ((missedReason & AUTO_MISSED_MAXIMUM_RINGING) != 0) { s.append("max_ringing]"); return s.toString(); } // user missed if ((missedReason & USER_MISSED_SHORT_RING) != 0) s.append("short_ring "); if ((missedReason & USER_MISSED_DND_MODE) != 0) s.append("dnd "); if ((missedReason & USER_MISSED_LOW_RING_VOLUME) != 0) s.append("low_volume "); if ((missedReason & USER_MISSED_NO_VIBRATE) != 0) s.append("no_vibrate "); if ((missedReason & USER_MISSED_CALL_SCREENING_SERVICE_SILENCED) != 0) s.append("css_silenced "); if ((missedReason & USER_MISSED_CALL_FILTERS_TIMEOUT) != 0) s.append("filter_timeout "); if ((missedReason & USER_MISSED_NEVER_RANG) != 0) s.append("no_ring "); s.append("]"); return s.toString(); } private String getInCallServicesString() { Loading
src/com/android/server/telecom/Ringer.java +4 −3 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ 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 static android.provider.Settings.Global.ZEN_MODE_OFF; import android.app.Notification; import android.app.NotificationManager; Loading Loading @@ -531,7 +532,6 @@ public class Ringer { return mRingtonePlayer.isPlaying(); } /** * shouldRingForContact checks if the caller matches one of the Do Not Disturb bypass * settings (ex. A contact or repeat caller might be able to bypass DND settings). If Loading @@ -546,7 +546,6 @@ public class Ringer { } final Uri contactUri = call.getHandle(); final Bundle peopleExtras = new Bundle(); if (contactUri != null) { ArrayList<Person> personList = new ArrayList<>(); Loading Loading @@ -575,10 +574,12 @@ public class Ringer { AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); // Use AudioManager#getRingerMode for more accurate result, instead of // AudioManager#getRingerModeInternal which only useful for volume controllers boolean zenModeOn = mNotificationManager != null && mNotificationManager.getZenMode() != ZEN_MODE_OFF; return mVibrator.hasVibrator() && mSystemSettingsUtil.isRingVibrationEnabled(context) && (audioManager.getRingerMode() != AudioManager.RINGER_MODE_SILENT || shouldRingForContact); || (zenModeOn && shouldRingForContact)); } private RingerAttributes getRingerAttributes(Call call, boolean isHfpDeviceAttached) { Loading
tests/src/com/android/server/telecom/tests/RingerTest.java +10 −7 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.server.telecom.tests; import static android.provider.Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; Loading Loading @@ -134,6 +136,7 @@ public class RingerTest extends TelecomTestCase { @Mock RingtoneFactory mockRingtoneFactory; @Mock Vibrator mockVibrator; @Mock InCallController mockInCallController; @Mock NotificationManager mockNotificationManager; @Spy Ringer.VibrationEffectProxy spyVibrationEffectProxy; @Mock InCallTonePlayer mockTonePlayer; Loading Loading @@ -161,17 +164,18 @@ public class RingerTest extends TelecomTestCase { when(mockAudioManager.getRingerMode()).thenReturn(AudioManager.RINGER_MODE_NORMAL); when(mockSystemSettingsUtil.isHapticPlaybackSupported(any(Context.class))).thenReturn(true); NotificationManager notificationManager = mockNotificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE); when(mockTonePlayer.startTone()).thenReturn(true); when(notificationManager.matchesCallFilter(any(Bundle.class))).thenReturn(true); when(mockNotificationManager.matchesCallFilter(any(Bundle.class))).thenReturn(true); when(mockRingtoneFactory.hasHapticChannels(any(Ringtone.class))).thenReturn(false); mRingerUnderTest = new Ringer(mockPlayerFactory, mContext, mockSystemSettingsUtil, mockRingtonePlayer, mockRingtoneFactory, mockVibrator, spyVibrationEffectProxy, mockInCallController, notificationManager); mockInCallController, mNotificationManager); when(mockCall1.getState()).thenReturn(CallState.RINGING); when(mockCall2.getState()).thenReturn(CallState.RINGING); mRingerUnderTest.setBlockOnRingingFuture(mRingCompletionFuture); mRingerUnderTest.setNotificationManager(mockNotificationManager); } @Override Loading Loading @@ -268,9 +272,7 @@ public class RingerTest extends TelecomTestCase { @SmallTest @Test public void testCallWaitingButNoRingForSpecificContacts() { NotificationManager notificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE); when(notificationManager.matchesCallFilter(any(Bundle.class))).thenReturn(false); when(mockNotificationManager.matchesCallFilter(any(Bundle.class))).thenReturn(false); // Start call waiting to make sure that it does stop when we start ringing mRingerUnderTest.startCallWaiting(mockCall1); verify(mockTonePlayer).startTone(); Loading Loading @@ -465,6 +467,7 @@ public class RingerTest extends TelecomTestCase { public void testRingAndVibrateForAllowedCallInDndMode() throws Exception { mRingerUnderTest.startCallWaiting(mockCall1); Ringtone mockRingtone = mock(Ringtone.class); when(mockNotificationManager.getZenMode()).thenReturn(ZEN_MODE_IMPORTANT_INTERRUPTIONS); when(mockRingtoneFactory.getRingtone(any(Call.class), eq(null), anyBoolean())) .thenReturn(mockRingtone); when(mockAudioManager.getRingerMode()).thenReturn(AudioManager.RINGER_MODE_SILENT); Loading