From e924ffb4ed7ed294d94d681b126cecaf50cae5b3 Mon Sep 17 00:00:00 2001 From: Brandon Maxwell Date: Tue, 1 Mar 2016 16:13:58 -0800 Subject: Added public notification for calls + Previously we didn't have a notification for ongoing/incoming calls to show users when they're on the lock screen and have their notification settings set to 'hide sensitive notification content'. This change adds that notification, to disambiguate between notifications for calls and other notifications such as those for missed calls. + This notification matches the version shown when the device is unlocked except that we choose to not show work call information as that is related to contact info. See http://screen/zYZseSS1d54 Bug: 13387034 Change-Id: I02290e585a9b46eb9207adf8258a67d29882518b --- .../com/android/incallui/StatusBarNotifier.java | 38 +++++++++++++++++----- 1 file changed, 30 insertions(+), 8 deletions(-) (limited to 'InCallUI') diff --git a/InCallUI/src/com/android/incallui/StatusBarNotifier.java b/InCallUI/src/com/android/incallui/StatusBarNotifier.java index 315c0d0ae..946e0ebd0 100644 --- a/InCallUI/src/com/android/incallui/StatusBarNotifier.java +++ b/InCallUI/src/com/android/incallui/StatusBarNotifier.java @@ -51,7 +51,6 @@ import com.android.contacts.common.testing.NeededForTesting; import com.android.contacts.common.util.BitmapUtil; import com.android.contacts.common.util.ContactDisplayUtils; import com.android.dialer.R; -import com.android.incallui.Call.State; import com.android.incallui.ContactInfoCache.ContactCacheEntry; import com.android.incallui.ContactInfoCache.ContactInfoCacheCallback; import com.android.incallui.InCallPresenter.InCallState; @@ -268,9 +267,23 @@ public class StatusBarNotifier implements InCallPresenter.InCallStateListener, } /* - * Nothing more to check...build and send it. + * 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)) + // Hide work call state for the lock screen notification + .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 final PendingIntent inCallPendingIntent = createLaunchPendingIntent(); @@ -335,12 +348,7 @@ public class StatusBarNotifier implements InCallPresenter.InCallStateListener, private void createIncomingCallNotification( Call call, int state, Notification.Builder builder) { - if (state == Call.State.ACTIVE) { - builder.setUsesChronometer(true); - builder.setWhen(call.getConnectTimeMillis()); - } else { - builder.setUsesChronometer(false); - } + setNotificationWhen(call, state, builder); // Add hang up option for any active calls (active | onhold), outgoing calls (dialing). if (state == Call.State.ACTIVE || @@ -358,6 +366,20 @@ public class StatusBarNotifier implements InCallPresenter.InCallStateListener, } } + /* + * Sets the notification's when section as needed. For active calls, this is explicitly set as + * the duration of the call. For all other states, the notification will automatically show the + * time at which the notification was created. + */ + private void setNotificationWhen(Call call, int state, Notification.Builder builder) { + if (state == Call.State.ACTIVE) { + builder.setUsesChronometer(true); + builder.setWhen(call.getConnectTimeMillis()); + } else { + builder.setUsesChronometer(false); + } + } + /** * Checks the new notification data and compares it against any notification that we * are already displaying. If the data is exactly the same, we return false so that -- cgit v1.2.3