mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-27 11:12:15 -05:00
Merge pull request #1147 from Hiperzone/development
-fixed out of bounds crash when retrieving the main profile name with se...
This commit is contained in:
commit
f1dc58ddfd
@ -135,7 +135,9 @@ public class ViewKeyFragment extends LoaderFragment implements
|
|||||||
if (mIsSecret) {//all secret keys are linked to "me" profile in contacts
|
if (mIsSecret) {//all secret keys are linked to "me" profile in contacts
|
||||||
contactId = ContactHelper.getMainProfileContactId(resolver);
|
contactId = ContactHelper.getMainProfileContactId(resolver);
|
||||||
List<String> mainProfileNames = ContactHelper.getMainProfileContactName(context);
|
List<String> mainProfileNames = ContactHelper.getMainProfileContactName(context);
|
||||||
if (mainProfileNames != null) contactName = mainProfileNames.get(0);
|
if (mainProfileNames != null && mainProfileNames.size() > 0) {
|
||||||
|
contactName = mainProfileNames.get(0);
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
contactId = ContactHelper.findContactId(resolver, masterKeyId);
|
contactId = ContactHelper.findContactId(resolver, masterKeyId);
|
||||||
|
@ -222,18 +222,20 @@ public class ContactHelper {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static long getMainProfileContactId(ContentResolver resolver) {
|
public static long getMainProfileContactId(ContentResolver resolver) {
|
||||||
Cursor profileCursor = resolver.query(
|
Cursor profileCursor = resolver.query(ContactsContract.Profile.CONTENT_URI,
|
||||||
ContactsContract.Profile.CONTENT_URI,
|
new String[]{ ContactsContract.Profile._ID}, null, null, null);
|
||||||
new String[]{
|
|
||||||
ContactsContract.Profile._ID
|
if(profileCursor != null && profileCursor.getCount() != 0 && profileCursor.moveToNext()) {
|
||||||
},
|
long contactId = profileCursor.getLong(0);
|
||||||
null, null, null);
|
profileCursor.close();
|
||||||
if (profileCursor == null) {
|
return contactId;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if(profileCursor != null) {
|
||||||
|
profileCursor.close();
|
||||||
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
profileCursor.moveToNext();
|
|
||||||
return profileCursor.getLong(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user