diff options
author | Yorke Lee <yorkelee@google.com> | 2012-11-09 10:40:22 -0800 |
---|---|---|
committer | Yorke Lee <yorkelee@google.com> | 2012-11-09 10:40:22 -0800 |
commit | 442756084d75d4ebd878e08617a5a4d578589734 (patch) | |
tree | 76016eae8ad6a9334cd05e78dbc7c13d2f12aed4 | |
parent | ac834156f56a4d4edcf207865f8235647fa26980 (diff) |
Fix NPE if SmartDialLoaderTask has null context
Add null check for mContext to prevent NPE if somehow
SmartDialLoaderTask receives a null context
Bug: 6977981
Change-Id: Id87b254520a48ad78dc0c579f0fd58d7f7ce270e
-rw-r--r-- | src/com/android/dialer/dialpad/SmartDialLoaderTask.java | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/com/android/dialer/dialpad/SmartDialLoaderTask.java b/src/com/android/dialer/dialpad/SmartDialLoaderTask.java index ec99d8a14..b4613b30d 100644 --- a/src/com/android/dialer/dialpad/SmartDialLoaderTask.java +++ b/src/com/android/dialer/dialpad/SmartDialLoaderTask.java @@ -170,14 +170,21 @@ public class SmartDialLoaderTask extends AsyncTask<String, Integer, List<SmartDi stopWatch.stopAndLog("SmartDial Already Cached", 0); return; } - + if (mContext == null) { + if (DEBUG) { + stopWatch.stopAndLog("Invalid context", 0); + } + return; + } final Cursor c = mContext.getContentResolver().query(ContactQuery.URI, (mNameDisplayOrder == ContactsContract.Preferences.DISPLAY_ORDER_PRIMARY) ? ContactQuery.PROJECTION : ContactQuery.PROJECTION_ALTERNATIVE, ContactQuery.SELECTION, null, ContactQuery.ORDER_BY); if (c == null) { - stopWatch.stopAndLog("Query Failuregi", 0); + if (DEBUG) { + stopWatch.stopAndLog("Query Failure", 0); + } return; } sContactsCache = Lists.newArrayListWithCapacity(c.getCount()); |