use of com.android.incallui.call.DialerCall in project android_packages_apps_Dialer by LineageOS.
the class ReturnToCallActionReceiver method toggleMute.
private void toggleMute(Context context) {
DialerCall call = getCall();
boolean shouldMute = !AudioModeProvider.getInstance().getAudioState().isMuted();
Logger.get(context).logCallImpression(shouldMute ? DialerImpression.Type.BUBBLE_MUTE_CALL : DialerImpression.Type.BUBBLE_UNMUTE_CALL, call != null ? call.getUniqueCallId() : "", call != null ? call.getTimeAddedMs() : 0);
TelecomAdapter.getInstance().mute(shouldMute);
}
use of com.android.incallui.call.DialerCall in project android_packages_apps_Dialer by LineageOS.
the class StatusBarNotifier method updateInCallNotification.
/**
* Helper method for updateInCallNotification() and updateNotification(): Update the phone app's
* status bar notification based on the current telephony state, or cancels the notification if
* the phone is totally idle.
*/
@RequiresPermission(Manifest.permission.READ_PHONE_STATE)
private void updateInCallNotification(CallList callList) {
LogUtil.d("StatusBarNotifier.updateInCallNotification", "");
final DialerCall call = getCallToShow(callList);
if (call != null) {
showNotification(callList, call);
} else {
cancelNotification();
}
}
use of com.android.incallui.call.DialerCall in project android_packages_apps_Dialer by LineageOS.
the class StatusBarNotifier method buildAndSendNotification.
/**
* Sets up the main Ui for the notification
*/
@RequiresPermission(Manifest.permission.READ_PHONE_STATE)
private void buildAndSendNotification(CallList callList, DialerCall originalCall, ContactCacheEntry contactInfo) {
// This can get called to update an existing notification after contact information has come
// back. However, it can happen much later. Before we continue, we need to make sure that
// the call being passed in is still the one we want to show in the notification.
final DialerCall call = getCallToShow(callList);
if (call == null || !call.getId().equals(originalCall.getId())) {
return;
}
final int callState = call.getState();
// Check if data has changed; if nothing is different, don't issue another notification.
final int iconResId = getIconToDisplay(call);
Bitmap largeIcon = getLargeIconToDisplay(mContext, contactInfo, call);
final String content = getContentString(call, contactInfo.userType);
final String contentTitle = getContentTitle(contactInfo, call);
final boolean isVideoUpgradeRequest = call.getVideoTech().getSessionModificationState() == SessionModificationState.RECEIVED_UPGRADE_TO_VIDEO_REQUEST;
final int notificationType;
if (callState == DialerCall.State.INCOMING || callState == DialerCall.State.CALL_WAITING || isVideoUpgradeRequest) {
if (ConfigProviderBindings.get(mContext).getBoolean("quiet_incoming_call_if_ui_showing", true)) {
notificationType = InCallPresenter.getInstance().isShowingInCallUi() ? NOTIFICATION_INCOMING_CALL_QUIET : NOTIFICATION_INCOMING_CALL;
} else {
boolean alreadyActive = callList.getActiveOrBackgroundCall() != null && InCallPresenter.getInstance().isShowingInCallUi();
notificationType = alreadyActive ? NOTIFICATION_INCOMING_CALL_QUIET : NOTIFICATION_INCOMING_CALL;
}
} else {
notificationType = NOTIFICATION_IN_CALL;
}
if (!checkForChangeAndSaveData(iconResId, content, largeIcon, contentTitle, callState, notificationType, contactInfo.contactRingtoneUri)) {
return;
}
if (largeIcon != null) {
largeIcon = getRoundedIcon(largeIcon);
}
// This builder is used for the notification shown when the device is locked and the user
// has set their notification settings to 'hide sensitive content'
// {@see Notification.Builder#setPublicVersion}.
Notification.Builder publicBuilder = new Notification.Builder(mContext);
publicBuilder.setSmallIcon(iconResId).setColor(mContext.getResources().getColor(R.color.dialer_theme_color, mContext.getTheme())).setContentTitle(getContentString(call, ContactsUtils.USER_TYPE_CURRENT));
setNotificationWhen(call, callState, publicBuilder);
// Builder for the notification shown when the device is unlocked or the user has set their
// notification settings to 'show all notification content'.
final Notification.Builder builder = getNotificationBuilder();
builder.setPublicVersion(publicBuilder.build());
// Set up the main intent to send the user to the in-call screen
builder.setContentIntent(createLaunchPendingIntent(false));
// Set the intent as a full screen intent as well if a call is incoming
PhoneAccountHandle accountHandle = call.getAccountHandle();
if (accountHandle == null) {
accountHandle = getAnyPhoneAccount();
}
LogUtil.i("StatusBarNotifier.buildAndSendNotification", "notificationType=" + notificationType);
switch(notificationType) {
case NOTIFICATION_INCOMING_CALL:
if (BuildCompat.isAtLeastO()) {
builder.setChannelId(NotificationChannelId.INCOMING_CALL);
}
configureFullScreenIntent(builder, createLaunchPendingIntent(true));
// Set the notification category and bump the priority for incoming calls
builder.setCategory(Notification.CATEGORY_CALL);
// This will be ignored on O+ and handled by the channel
builder.setPriority(Notification.PRIORITY_MAX);
if (mCurrentNotification != NOTIFICATION_INCOMING_CALL) {
LogUtil.i("StatusBarNotifier.buildAndSendNotification", "Canceling old notification so this one can be noisy");
// Moving from a non-interuptive notification (or none) to a noisy one. Cancel the old
// notification (if there is one) so the fullScreenIntent or HUN will show
mNotificationManager.cancel(NOTIFICATION_TAG, NOTIFICATION_ID);
}
break;
case NOTIFICATION_INCOMING_CALL_QUIET:
if (BuildCompat.isAtLeastO()) {
builder.setChannelId(NotificationChannelId.ONGOING_CALL);
}
break;
case NOTIFICATION_IN_CALL:
if (BuildCompat.isAtLeastO()) {
publicBuilder.setColorized(true);
builder.setColorized(true);
builder.setChannelId(NotificationChannelId.ONGOING_CALL);
}
break;
}
// Set the content
builder.setContentText(content);
builder.setSmallIcon(iconResId);
builder.setContentTitle(contentTitle);
builder.setLargeIcon(largeIcon);
builder.setColor(mContext.getResources().getColor(R.color.dialer_theme_color, mContext.getTheme()));
if (isVideoUpgradeRequest) {
builder.setUsesChronometer(false);
addDismissUpgradeRequestAction(builder);
addAcceptUpgradeRequestAction(builder);
} else {
createIncomingCallNotification(call, callState, builder);
}
addPersonReference(builder, contactInfo, call);
// Fire off the notification
Notification notification = builder.build();
if (mDialerRingtoneManager.shouldPlayRingtone(callState, contactInfo.contactRingtoneUri)) {
notification.flags |= Notification.FLAG_INSISTENT;
notification.sound = contactInfo.contactRingtoneUri;
AudioAttributes.Builder audioAttributes = new AudioAttributes.Builder();
audioAttributes.setContentType(AudioAttributes.CONTENT_TYPE_MUSIC);
audioAttributes.setUsage(AudioAttributes.USAGE_NOTIFICATION_RINGTONE);
notification.audioAttributes = audioAttributes.build();
if (mDialerRingtoneManager.shouldVibrate(mContext.getContentResolver())) {
notification.vibrate = VIBRATE_PATTERN;
}
}
if (mDialerRingtoneManager.shouldPlayCallWaitingTone(callState)) {
LogUtil.v("StatusBarNotifier.buildAndSendNotification", "playing call waiting tone");
mDialerRingtoneManager.playCallWaitingTone();
}
LogUtil.i("StatusBarNotifier.buildAndSendNotification", "displaying notification for " + notificationType);
try {
mNotificationManager.notify(NOTIFICATION_TAG, NOTIFICATION_ID, notification);
} catch (RuntimeException e) {
// TODO(b/34744003): Move the memory stats into silent feedback PSD.
ActivityManager activityManager = mContext.getSystemService(ActivityManager.class);
ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
activityManager.getMemoryInfo(memoryInfo);
throw new RuntimeException(String.format(Locale.US, "Error displaying notification with photo type: %d (low memory? %b, availMem: %d)", contactInfo.photoType, memoryInfo.lowMemory, memoryInfo.availMem), e);
}
call.getLatencyReport().onNotificationShown();
mCurrentNotification = notificationType;
}
use of com.android.incallui.call.DialerCall in project android_packages_apps_Dialer by LineageOS.
the class ExternalCallNotifier method showNotifcation.
/**
* Shows a notification for a new external call. Performs a contact cache lookup to find any
* associated photo and information for the call.
*/
private void showNotifcation(final NotificationInfo info) {
// We make a call to the contact info cache to query for supplemental data to what the
// call provides. This includes the contact name and photo.
// This callback will always get called immediately and synchronously with whatever data
// it has available, and may make a subsequent call later (same thread) if it had to
// call into the contacts provider for more data.
DialerCall dialerCall = new DialerCall(mContext, new DialerCallDelegateStub(), info.getCall(), new LatencyReport(), false);
mContactInfoCache.findInfo(dialerCall, false, /* isIncoming */
new ContactInfoCache.ContactInfoCacheCallback() {
@Override
public void onContactInfoComplete(String callId, ContactInfoCache.ContactCacheEntry entry) {
// removed during async contact info lookup.
if (mNotifications.containsKey(info.getCall())) {
saveContactInfo(info, entry);
}
}
@Override
public void onImageLoadComplete(String callId, ContactInfoCache.ContactCacheEntry entry) {
// removed during async contact info lookup.
if (mNotifications.containsKey(info.getCall())) {
savePhoto(info, entry);
}
}
});
}
use of com.android.incallui.call.DialerCall in project android_packages_apps_Dialer by LineageOS.
the class InCallActivityCommon method onBackPressed.
public boolean onBackPressed(boolean isInCallScreenVisible) {
LogUtil.i("InCallActivityCommon.onBackPressed", "");
// in-call UI:
if (!inCallActivity.isVisible()) {
return true;
}
if (!isInCallScreenVisible) {
return true;
}
DialpadFragment dialpadFragment = getDialpadFragment();
if (dialpadFragment != null && dialpadFragment.isVisible()) {
inCallActivity.showDialpadFragment(false, /* show */
true);
return true;
}
// Always disable the Back key while an incoming call is ringing
DialerCall call = CallList.getInstance().getIncomingCall();
if (call != null) {
LogUtil.i("InCallActivityCommon.onBackPressed", "consume Back press for an incoming call");
return true;
}
// Nothing special to do. Fall back to the default behavior.
return false;
}
Aggregations