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

Commit e924ffb4 authored by Brandon Maxwell's avatar Brandon Maxwell
Browse files

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
parent 0c00c3ef
Loading
Loading
Loading
Loading
+30 −8
Original line number Diff line number Diff line
@@ -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