Fixes a crash caused when getting values from the ContactInteraction
ContentValues
Change-Id: I5348784465d263d3fc991c6cd288c66b22681659
diff --git a/src/com/android/contacts/interactions/CalendarInteraction.java b/src/com/android/contacts/interactions/CalendarInteraction.java
index 68e37f7..4b766f8 100644
--- a/src/com/android/contacts/interactions/CalendarInteraction.java
+++ b/src/com/android/contacts/interactions/CalendarInteraction.java
@@ -61,6 +61,16 @@
// TODO: build callback to update time zone if different than preferences
String localTimezone = Time.getCurrentTimezone();
+ Long dateEnd = getDtend();
+ Long dateStart = getDtstart();
+ if (dateStart == null && dateEnd == null) {
+ return null;
+ } else if (dateEnd == null) {
+ dateEnd = dateStart;
+ } else if (dateStart == null) {
+ dateStart = dateEnd;
+ }
+
String displayedDatetime = CalendarInteractionUtils.getDisplayedDatetime(
getDtstart(), getDtend(), System.currentTimeMillis(), localTimezone,
getAllDay(), context);
@@ -99,39 +109,39 @@
return mValues.getAsString(Attendees.ATTENDEE_NAME);
}
- public int getAttendeeRelationship() {
+ public Integer getAttendeeRelationship() {
return mValues.getAsInteger(Attendees.ATTENDEE_RELATIONSHIP);
}
- public int getAttendeeStatus() {
+ public Integer getAttendeeStatus() {
return mValues.getAsInteger(Attendees.ATTENDEE_STATUS);
}
- public int getAttendeeType() {
+ public Integer getAttendeeType() {
return mValues.getAsInteger(Attendees.ATTENDEE_TYPE);
}
- public int getEventId() {
+ public Integer getEventId() {
return mValues.getAsInteger(Attendees.EVENT_ID);
}
- public int getAccessLevel() {
+ public Integer getAccessLevel() {
return mValues.getAsInteger(Attendees.ACCESS_LEVEL);
}
- public boolean getAllDay() {
+ public Boolean getAllDay() {
return mValues.getAsBoolean(Attendees.ALL_DAY);
}
- public int getAvailability() {
+ public Integer getAvailability() {
return mValues.getAsInteger(Attendees.AVAILABILITY);
}
- public int getCalendarId() {
+ public Integer getCalendarId() {
return mValues.getAsInteger(Attendees.CALENDAR_ID);
}
- public boolean getCanInviteOthers() {
+ public Boolean getCanInviteOthers() {
return mValues.getAsBoolean(Attendees.CAN_INVITE_OTHERS);
}
@@ -147,15 +157,15 @@
return mValues.getAsString(Attendees.DESCRIPTION);
}
- public int getDisplayColor() {
+ public Integer getDisplayColor() {
return mValues.getAsInteger(Attendees.DISPLAY_COLOR);
}
- public long getDtend() {
+ public Long getDtend() {
return mValues.getAsLong(Attendees.DTEND);
}
- public long getDtstart() {
+ public Long getDtstart() {
return mValues.getAsLong(Attendees.DTSTART);
}
@@ -163,7 +173,7 @@
return mValues.getAsString(Attendees.DURATION);
}
- public int getEventColor() {
+ public Integer getEventColor() {
return mValues.getAsInteger(Attendees.EVENT_COLOR);
}
@@ -187,27 +197,27 @@
return mValues.getAsString(Attendees.EXRULE);
}
- public boolean getGuestsCanInviteOthers() {
+ public Boolean getGuestsCanInviteOthers() {
return mValues.getAsBoolean(Attendees.GUESTS_CAN_INVITE_OTHERS);
}
- public boolean getGuestsCanModify() {
+ public Boolean getGuestsCanModify() {
return mValues.getAsBoolean(Attendees.GUESTS_CAN_MODIFY);
}
- public boolean getGuestsCanSeeGuests() {
+ public Boolean getGuestsCanSeeGuests() {
return mValues.getAsBoolean(Attendees.GUESTS_CAN_SEE_GUESTS);
}
- public boolean getHasAlarm() {
+ public Boolean getHasAlarm() {
return mValues.getAsBoolean(Attendees.HAS_ALARM);
}
- public boolean getHasAttendeeData() {
+ public Boolean getHasAttendeeData() {
return mValues.getAsBoolean(Attendees.HAS_ATTENDEE_DATA);
}
- public boolean getHasExtendedProperties() {
+ public Boolean getHasExtendedProperties() {
return mValues.getAsBoolean(Attendees.HAS_EXTENDED_PROPERTIES);
}
@@ -215,11 +225,11 @@
return mValues.getAsString(Attendees.IS_ORGANIZER);
}
- public long getLastDate() {
+ public Long getLastDate() {
return mValues.getAsLong(Attendees.LAST_DATE);
}
- public boolean getLastSynced() {
+ public Boolean getLastSynced() {
return mValues.getAsBoolean(Attendees.LAST_SYNCED);
}
@@ -227,7 +237,7 @@
return mValues.getAsString(Attendees.ORGANIZER);
}
- public boolean getOriginalAllDay() {
+ public Boolean getOriginalAllDay() {
return mValues.getAsBoolean(Attendees.ORIGINAL_ALL_DAY);
}
@@ -235,7 +245,7 @@
return mValues.getAsString(Attendees.ORIGINAL_ID);
}
- public long getOriginalInstanceTime() {
+ public Long getOriginalInstanceTime() {
return mValues.getAsLong(Attendees.ORIGINAL_INSTANCE_TIME);
}
@@ -251,11 +261,11 @@
return mValues.getAsString(Attendees.RRULE);
}
- public int getSelfAttendeeStatus() {
+ public Integer getSelfAttendeeStatus() {
return mValues.getAsInteger(Attendees.SELF_ATTENDEE_STATUS);
}
- public int getStatus() {
+ public Integer getStatus() {
return mValues.getAsInteger(Attendees.STATUS);
}
diff --git a/src/com/android/contacts/interactions/CallLogInteraction.java b/src/com/android/contacts/interactions/CallLogInteraction.java
index 8607974..28b9655 100644
--- a/src/com/android/contacts/interactions/CallLogInteraction.java
+++ b/src/com/android/contacts/interactions/CallLogInteraction.java
@@ -55,7 +55,9 @@
@Override
public Intent getIntent() {
- return new Intent(Intent.ACTION_CALL).setData(Uri.parse(URI_TARGET_PREFIX + getNumber()));
+ String number = getNumber();
+ return number == null ? null : new Intent(Intent.ACTION_CALL).setData(
+ Uri.parse(URI_TARGET_PREFIX + number));
}
@Override
@@ -65,13 +67,14 @@
@Override
public long getInteractionDate() {
- return getDate();
+ Long date = getDate();
+ return date == null ? -1 : date;
}
@Override
public String getViewBody(Context context) {
- int numberType = getCachedNumberType();
- if (numberType == -1) {
+ Integer numberType = getCachedNumberType();
+ if (numberType == null) {
return null;
}
return Phone.getTypeLabel(context.getResources(), getCachedNumberType(),
@@ -80,7 +83,9 @@
@Override
public String getViewFooter(Context context) {
- return ContactInteractionUtil.formatDateStringFromTimestamp(getDate(), context);
+ Long date = getDate();
+ return date == null ? null : ContactInteractionUtil.formatDateStringFromTimestamp(
+ date, context);
}
@Override
@@ -97,7 +102,11 @@
public Drawable getFooterIcon(Context context) {
Drawable callArrow = null;
Resources res = context.getResources();
- switch (getType()) {
+ Integer type = getType();
+ if (type == null) {
+ return null;
+ }
+ switch (type) {
case Calls.INCOMING_TYPE:
callArrow = res.getDrawable(CALL_ARROW_ICON_RES);
callArrow.setColorFilter(res.getColor(R.color.call_arrow_green),
@@ -125,28 +134,27 @@
return mValues.getAsString(Calls.CACHED_NUMBER_LABEL);
}
- public int getCachedNumberType() {
- Integer type = mValues.getAsInteger(Calls.CACHED_NUMBER_TYPE);
- return type != null ? type : -1;
+ public Integer getCachedNumberType() {
+ return mValues.getAsInteger(Calls.CACHED_NUMBER_TYPE);
}
- public long getDate() {
+ public Long getDate() {
return mValues.getAsLong(Calls.DATE);
}
- public long getDuration() {
+ public Long getDuration() {
return mValues.getAsLong(Calls.DURATION);
}
- public boolean getIsRead() {
+ public Boolean getIsRead() {
return mValues.getAsBoolean(Calls.IS_READ);
}
- public int getLimitParamKey() {
+ public Integer getLimitParamKey() {
return mValues.getAsInteger(Calls.LIMIT_PARAM_KEY);
}
- public boolean getNew() {
+ public Boolean getNew() {
return mValues.getAsBoolean(Calls.NEW);
}
@@ -154,15 +162,15 @@
return mValues.getAsString(Calls.NUMBER);
}
- public int getNumberPresentation() {
+ public Integer getNumberPresentation() {
return mValues.getAsInteger(Calls.NUMBER_PRESENTATION);
}
- public int getOffsetParamKey() {
+ public Integer getOffsetParamKey() {
return mValues.getAsInteger(Calls.OFFSET_PARAM_KEY);
}
- public int getType() {
+ public Integer getType() {
return mValues.getAsInteger(Calls.TYPE);
}
}
\ No newline at end of file
diff --git a/src/com/android/contacts/interactions/SmsInteraction.java b/src/com/android/contacts/interactions/SmsInteraction.java
index c70356e..ac83786 100644
--- a/src/com/android/contacts/interactions/SmsInteraction.java
+++ b/src/com/android/contacts/interactions/SmsInteraction.java
@@ -41,12 +41,15 @@
@Override
public Intent getIntent() {
- return new Intent(Intent.ACTION_VIEW).setData(Uri.parse(URI_TARGET_PREFIX + getAddress()));
+ String address = getAddress();
+ return address == null ? null : new Intent(Intent.ACTION_VIEW).setData(
+ Uri.parse(URI_TARGET_PREFIX + address));
}
@Override
public long getInteractionDate() {
- return getDate();
+ Long date = getDate();
+ return date == null ? -1 : date;
}
@Override
@@ -61,7 +64,9 @@
@Override
public String getViewFooter(Context context) {
- return ContactInteractionUtil.formatDateStringFromTimestamp(getDate(), context);
+ Long date = getDate();
+ return date == null ? null : ContactInteractionUtil.formatDateStringFromTimestamp(
+ date, context);
}
@Override
@@ -87,40 +92,40 @@
return mValues.getAsString(Sms.BODY);
}
- public long getDate() {
+ public Long getDate() {
return mValues.getAsLong(Sms.DATE);
}
- public long getDateSent() {
+ public Long getDateSent() {
return mValues.getAsLong(Sms.DATE_SENT);
}
- public int getErrorCode() {
+ public Integer getErrorCode() {
return mValues.getAsInteger(Sms.ERROR_CODE);
}
- public boolean getLocked() {
+ public Boolean getLocked() {
return mValues.getAsBoolean(Sms.LOCKED);
}
- public int getPerson() {
+ public Integer getPerson() {
return mValues.getAsInteger(Sms.PERSON);
}
- public int getProtocol() {
+ public Integer getProtocol() {
return mValues.getAsInteger(Sms.PROTOCOL);
}
- public boolean getRead() {
+ public Boolean getRead() {
return mValues.getAsBoolean(Sms.READ);
}
- public boolean getReplyPathPresent() {
+ public Boolean getReplyPathPresent() {
return mValues.getAsBoolean(Sms.REPLY_PATH_PRESENT);
}
- public boolean getSeen() {
+ public Boolean getSeen() {
return mValues.getAsBoolean(Sms.SEEN);
}
@@ -128,7 +133,7 @@
return mValues.getAsString(Sms.SERVICE_CENTER);
}
- public int getStatus() {
+ public Integer getStatus() {
return mValues.getAsInteger(Sms.STATUS);
}
@@ -136,11 +141,11 @@
return mValues.getAsString(Sms.SUBJECT);
}
- public int getThreadId() {
+ public Integer getThreadId() {
return mValues.getAsInteger(Sms.THREAD_ID);
}
- public int getType() {
+ public Integer getType() {
return mValues.getAsInteger(Sms.TYPE);
}
}