// for enabling and disabling notification pulse behavior
boolean mScreenOn = true;
- protected boolean mInCall = false;
+ protected boolean mInCallStateOffHook = false;
boolean mNotificationPulseEnabled;
private Uri mInCallNotificationUri;
mScreenOn = false;
updateNotificationPulse();
} else if (action.equals(TelephonyManager.ACTION_PHONE_STATE_CHANGED)) {
- mInCall = TelephonyManager.EXTRA_STATE_OFFHOOK
+ mInCallStateOffHook = TelephonyManager.EXTRA_STATE_OFFHOOK
.equals(intent.getStringExtra(TelephonyManager.EXTRA_STATE));
updateNotificationPulse();
} else if (action.equals(Intent.ACTION_USER_STOPPED)) {
}
if (DBG) Slog.v(TAG, "Interrupting!");
if (hasValidSound) {
- if (mInCall) {
+ if (isInCall()) {
playInCallNotification();
beep = true;
} else {
final boolean ringerModeSilent =
mAudioManager.getRingerModeInternal()
== AudioManager.RINGER_MODE_SILENT;
- if (!mInCall && hasValidVibrate && !ringerModeSilent) {
+ if (!isInCall() && hasValidVibrate && !ringerModeSilent) {
buzz = playVibration(record, vibration, hasValidSound);
if(buzz) {
mVibrateNotificationKey = key;
return false;
}
// not if in call or the screen's on
- if (mInCall || mScreenOn) {
+ if (isInCall() || mScreenOn) {
return false;
}
}
// Don't flash while we are in a call or screen is on
- if (ledNotification == null || mInCall || mScreenOn) {
+ if (ledNotification == null || isInCall() || mScreenOn) {
mNotificationLight.turnOff();
} else {
NotificationRecord.Light light = ledNotification.getLight();
}
}
+ private boolean isInCall() {
+ if (mInCallStateOffHook) {
+ return true;
+ }
+ int audioMode = mAudioManager.getMode();
+ if (audioMode == AudioManager.MODE_IN_CALL
+ || audioMode == AudioManager.MODE_IN_COMMUNICATION) {
+ return true;
+ }
+ return false;
+ }
+
public class NotificationAssistants extends ManagedServices {
static final String TAG_ENABLED_NOTIFICATION_ASSISTANTS = "enabled_assistants";
mService.setUsageStats(mUsageStats);
mService.setAccessibilityManager(accessibilityManager);
mService.mScreenOn = false;
- mService.mInCall = false;
+ mService.mInCallStateOffHook = false;
mService.mNotificationPulseEnabled = true;
}
mService.buzzBeepBlinkLocked(r);
Mockito.reset(mRingtonePlayer);
- mService.mInCall = true;
+ mService.mInCallStateOffHook = true;
mService.buzzBeepBlinkLocked(r);
verify(mService, times(1)).playInCallNotification();
@Test
public void testLightsInCall() {
- mService.mInCall = true;
+ mService.mInCallStateOffHook = true;
NotificationRecord r = getLightsNotification();
mService.buzzBeepBlinkLocked(r);
verifyNeverLights();