Add null checks to MissedCallNotifier.
Bug: 16782303
Change-Id: I1ffee114315c20db33512082f9c0d25db8010988
diff --git a/res/values/strings.xml b/res/values/strings.xml
index ad8829c..f2f80ee 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -108,4 +108,7 @@
<string name="test_account_2_short_description">Talk to everyone in your Circles!</string>
<!-- DO NOT TRANSLATE. Short description for test Subscription 3. -->
<string name="test_account_3_short_description">Chat with Chat Network users</string>
+
+ <!-- DO NOT TRANSLATE. Hardcoded number used for restricted incoming phone numbers. -->
+ <string name="handle_restricted">RESTRICTED</string>
</resources>
diff --git a/src/com/android/telecomm/MissedCallNotifier.java b/src/com/android/telecomm/MissedCallNotifier.java
index e9e453b..ca2c56e 100644
--- a/src/com/android/telecomm/MissedCallNotifier.java
+++ b/src/com/android/telecomm/MissedCallNotifier.java
@@ -129,19 +129,22 @@
.setDeleteIntent(createClearMissedCallsPendingIntent());
Uri handleUri = call.getHandle();
- String handle = handleUri.getSchemeSpecificPart();
+ String handle = handleUri == null ? null : handleUri.getSchemeSpecificPart();
// Add additional actions when there is only 1 missed call, like call-back and SMS.
if (mMissedCallCount == 1) {
Log.d(this, "Add actions with number %s.", Log.piiHandle(handle));
- builder.addAction(R.drawable.stat_sys_phone_call,
- mContext.getString(R.string.notification_missedCall_call_back),
- createCallBackPendingIntent(handleUri));
+ if (!TextUtils.isEmpty(handle)
+ && !TextUtils.equals(handle, mContext.getString(R.string.handle_restricted))) {
+ builder.addAction(R.drawable.stat_sys_phone_call,
+ mContext.getString(R.string.notification_missedCall_call_back),
+ createCallBackPendingIntent(handleUri));
- builder.addAction(R.drawable.ic_text_holo_dark,
- mContext.getString(R.string.notification_missedCall_message),
- createSendSmsFromNotificationPendingIntent(handleUri));
+ builder.addAction(R.drawable.ic_text_holo_dark,
+ mContext.getString(R.string.notification_missedCall_message),
+ createSendSmsFromNotificationPendingIntent(handleUri));
+ }
Bitmap photoIcon = call.getPhotoIcon();
if (photoIcon != null) {
@@ -175,7 +178,7 @@
* Returns the name to use in the missed call notification.
*/
private String getNameForCall(Call call) {
- String handle = call.getHandle().getSchemeSpecificPart();
+ String handle = call.getHandle() == null ? null : call.getHandle().getSchemeSpecificPart();
String name = call.getName();
if (!TextUtils.isEmpty(name) && TextUtils.isGraphic(name)) {