diff options
Diffstat (limited to 'InCallUI/src/com/android/incallui/StatusBarNotifier.java')
-rw-r--r-- | InCallUI/src/com/android/incallui/StatusBarNotifier.java | 45 |
1 files changed, 35 insertions, 10 deletions
diff --git a/InCallUI/src/com/android/incallui/StatusBarNotifier.java b/InCallUI/src/com/android/incallui/StatusBarNotifier.java index 0662cca8d..cc87dd414 100644 --- a/InCallUI/src/com/android/incallui/StatusBarNotifier.java +++ b/InCallUI/src/com/android/incallui/StatusBarNotifier.java @@ -33,7 +33,9 @@ import android.content.Context; import android.content.Intent; import android.graphics.Bitmap; import android.graphics.BitmapFactory; +import android.graphics.Canvas; import android.graphics.drawable.BitmapDrawable; +import android.graphics.drawable.Drawable; import android.media.AudioAttributes; import android.net.Uri; import android.provider.ContactsContract.Contacts; @@ -52,6 +54,7 @@ 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.dialer.service.ExtendedCallInfoService; import com.android.incallui.ContactInfoCache.ContactCacheEntry; import com.android.incallui.ContactInfoCache.ContactInfoCacheCallback; import com.android.incallui.InCallPresenter.InCallState; @@ -76,6 +79,9 @@ public class StatusBarNotifier implements InCallPresenter.InCallStateListener, // Notification for incoming calls. This is interruptive and will show up as a HUN. private static final int NOTIFICATION_INCOMING_CALL = 2; + private static final int PENDING_INTENT_REQUEST_CODE_NON_FULL_SCREEN = 0; + private static final int PENDING_INTENT_REQUEST_CODE_FULL_SCREEN = 1; + private static final long[] VIBRATE_PATTERN = new long[] {0, 1000, 1000}; private final Context mContext; @@ -239,6 +245,10 @@ public class StatusBarNotifier implements InCallPresenter.InCallStateListener, } final int callState = call.getState(); + // Dont' show as spam if the number is in local contact. + if (contactInfo.contactLookupResult == Call.LogState.LOOKUP_LOCAL_CONTACT) { + call.setSpam(false); + } // Check if data has changed; if nothing is different, don't issue another notification. final int iconResId = getIconToDisplay(call); @@ -286,13 +296,13 @@ public class StatusBarNotifier implements InCallPresenter.InCallStateListener, builder.setPublicVersion(publicBuilder.build()); // Set up the main intent to send the user to the in-call screen - final PendingIntent inCallPendingIntent = createLaunchPendingIntent(); - builder.setContentIntent(inCallPendingIntent); + builder.setContentIntent(createLaunchPendingIntent(false /* isFullScreen */)); // Set the intent as a full screen intent as well if a call is incoming if (notificationType == NOTIFICATION_INCOMING_CALL && !InCallPresenter.getInstance().isShowingInCallUi()) { - configureFullScreenIntent(builder, inCallPendingIntent, call); + configureFullScreenIntent( + builder, createLaunchPendingIntent(true /* isFullScreen */), call); // Set the notification category for incoming calls builder.setCategory(Notification.CATEGORY_CALL); } @@ -339,8 +349,10 @@ public class StatusBarNotifier implements InCallPresenter.InCallStateListener, + mCurrentNotification); mNotificationManager.cancel(mCurrentNotification); } + Log.i(this, "Displaying notification for " + notificationType); mNotificationManager.notify(notificationType, notification); + call.getLatencyReport().onNotificationShown(); mCurrentNotification = notificationType; } @@ -464,6 +476,10 @@ public class StatusBarNotifier implements InCallPresenter.InCallStateListener, if (contactInfo.photo != null && (contactInfo.photo instanceof BitmapDrawable)) { largeIcon = ((BitmapDrawable) contactInfo.photo).getBitmap(); } + if (call.isSpam()) { + Drawable drawable = mContext.getResources().getDrawable(R.drawable.blocked_contact); + largeIcon = CallCardFragment.drawableToBitmap(drawable); + } return largeIcon; } @@ -525,7 +541,11 @@ public class StatusBarNotifier implements InCallPresenter.InCallStateListener, if (call.hasProperty(Details.PROPERTY_WIFI)) { resId = R.string.notification_incoming_call_wifi; } else { - resId = R.string.notification_incoming_call; + if (call.isSpam()) { + resId = R.string.notification_incoming_spam_call; + } else { + resId = R.string.notification_incoming_call; + } } } else if (call.getState() == Call.State.ONHOLD) { resId = R.string.notification_on_hold; @@ -707,19 +727,24 @@ public class StatusBarNotifier implements InCallPresenter.InCallStateListener, return builder; } - private PendingIntent createLaunchPendingIntent() { - - final Intent intent = InCallPresenter.getInstance().getInCallIntent( + private PendingIntent createLaunchPendingIntent(boolean isFullScreen) { + Intent intent = InCallPresenter.getInstance().getInCallIntent( false /* showDialpad */, false /* newOutgoingCall */); + int requestCode = PENDING_INTENT_REQUEST_CODE_NON_FULL_SCREEN; + if (isFullScreen) { + intent.putExtra(InCallActivity.FOR_FULL_SCREEN_INTENT, true); + // Use a unique request code so that the pending intent isn't clobbered by the + // non-full screen pending intent. + requestCode = PENDING_INTENT_REQUEST_CODE_FULL_SCREEN; + } + // PendingIntent that can be used to launch the InCallActivity. The // system fires off this intent if the user pulls down the windowshade // and clicks the notification's expanded view. It's also used to // launch the InCallActivity immediately when when there's an incoming // call (see the "fullScreenIntent" field below). - PendingIntent inCallPendingIntent = PendingIntent.getActivity(mContext, 0, intent, 0); - - return inCallPendingIntent; + return PendingIntent.getActivity(mContext, requestCode, intent, 0); } /** |