RCS NPE when uppgrading to N
1) Fixes a crash upon upgrade to N where a null cursor was received when
the data was damaged.
2) Adds permission to AndroidManifest for consistency.
Bug: 30838787
Change-Id: I91196f3753e381d643b242f65469904e5cb4d603
diff --git a/rcs/presencepolling/AndroidManifest.xml b/rcs/presencepolling/AndroidManifest.xml
index 8780c11..8d69796 100644
--- a/rcs/presencepolling/AndroidManifest.xml
+++ b/rcs/presencepolling/AndroidManifest.xml
@@ -35,6 +35,9 @@
<uses-sdk android:minSdkVersion="19"/>
+ <permission android:name="com.android.rcs.eab.permission.READ_WRITE_EAB"
+ android:protectionLevel="signatureOrSystem" />
+
<protected-broadcast android:name="android.provider.rcs.eab.EAB_NEW_CONTACT_INSERTED" />
<protected-broadcast android:name="com.android.service.ims.presence.capability_polling_retry" />
<protected-broadcast android:name="com.android.service.ims.presence.periodical_capability_discovery" />
diff --git a/rcs/presencepolling/src/com/android/service/ims/presence/EABDbUtil.java b/rcs/presencepolling/src/com/android/service/ims/presence/EABDbUtil.java
index 44ab61e..64d7343 100644
--- a/rcs/presencepolling/src/com/android/service/ims/presence/EABDbUtil.java
+++ b/rcs/presencepolling/src/com/android/service/ims/presence/EABDbUtil.java
@@ -72,8 +72,13 @@
null, sortOrder);
ArrayList<PresenceContact> allEligibleContacts = new ArrayList<PresenceContact>();
- logger.debug("cursor count : " + cursor.getCount());
- if (cursor.moveToFirst()) {
+ if (cursor != null) {
+ logger.debug("cursor count : " + cursor.getCount());
+ } else {
+ logger.debug("cursor = null");
+ }
+
+ if (cursor != null && cursor.moveToFirst()) {
do {
String id = cursor.getString(cursor.getColumnIndex(Contacts._ID));
Long time = cursor.getLong(cursor.getColumnIndex(
@@ -94,7 +99,7 @@
+ " = ?", new String[] { id }, null);
ArrayList<String> phoneNumList = new ArrayList<String>();
- if (pCur.moveToFirst()) {
+ if (pCur != null && pCur.moveToFirst()) {
do {
String contactNumber = pCur.getString(pCur.getColumnIndex(
ContactsContract.CommonDataKinds.Phone.NUMBER));
@@ -121,7 +126,9 @@
}
} while (pCur.moveToNext());
}
- pCur.close();
+ if (pCur != null) {
+ pCur.close();
+ }
} while (cursor.moveToNext());
}
if (null != cursor) {