mfurqan777 / imsdroid

Automatically exported from code.google.com/p/imsdroid
0 stars 0 forks source link

Incorrect managed cursor usage in NgnContactService #322

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The cursor during load2 method call is created using managedQuery, which also 
calls startManagingCursor. And if you ever call startManagingCursor, you should 
always call stopManagingCursor after it's not in use. Or in latest OS versions 
you might catch an exception because of that, here's the patch solving the 
issue:

### Eclipse Workspace Patch 1.0
Index: src/org/doubango/ngn/services/impl/NgnContactService.java
===================================================================
--- src/org/doubango/ngn/services/impl/NgnContactService.java   (revision 478)
+++ src/org/doubango/ngn/services/impl/NgnContactService.java   (working copy)
@@ -160,6 +160,7 @@
        mLoading = true;
        boolean bOK = false;
        Cursor managedCursor = null;
+       final Activity activity = NgnEngine.getInstance().getMainActivity();
        final List<NgnContact> contactsCopy = new ArrayList<NgnContact>();

        if(mOnBeginLoadCallback != null){
@@ -170,7 +171,6 @@
            String phoneNumber, displayName, label;
            NgnContact contact = null;
            int id, type, photoId;
-           final Activity activity = NgnEngine.getInstance().getMainActivity();
            final Resources res = NgnApplication.getContext().getResources();

            if(NgnApplication.getSDKVersion() >=5 && activity != null){
@@ -244,6 +244,8 @@
        }
        finally{
            if(managedCursor != null){
+               activity.stopManagingCursor(managedCursor);
+               
                managedCursor.close();
            }
        }

Original issue reported on code.google.com by volkov.r...@gmail.com on 20 Jan 2012 at 9:24

GoogleCodeExporter commented 9 years ago
Should be fixed by IMSDroid 2.0.481

Original comment by boss...@yahoo.fr on 28 Feb 2012 at 12:05