cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mad-nuts <...@git.apache.org>
Subject [GitHub] cordova-plugin-contacts issue #146: CB-12326
Date Thu, 23 Feb 2017 12:56:47 GMT
Github user mad-nuts commented on the issue:

    https://github.com/apache/cordova-plugin-contacts/pull/146
  
    
    I've tried for hours to reproduce the error, but the app just won't crash anymore.
    Something must have changed since then and I don't know what it is...
    
    
    Despite the fact, that the app won't crash anymore, the code is still buggy and should
be fixed some day.
    
    **Here is what had happened in detail, maybe it is useful nevertheless:**
    
    Executing `ContactAccessorSdk5.search` with one or more of the following fields caused
the crash:
    
    ```
    - navigator.contacts.fieldType.phoneNumbers
      - phoneQuery
        - CommonDataKinds.Phone.LABEL
    - navigator.contacts.fieldType.emails
      - emailQuery
        - CommonDataKinds.Email.LABEL
    - navigator.contacts.fieldType.postalCode
      - addressQuery
        - CommonDataKinds.StructuredPostal.LABEL
    - navigator.contacts.fieldType.organizations
      - organizationQuery
        - CommonDataKinds.Organization.LABEL
    - navigator.contacts.fieldType.urls
      - websiteQuery
        - CommonDataKinds.Website.LABEL
    ```
    
    - `ContactAccessorSdk5.search` is called with the `JSONArray fields` containing one /
some / all fields of the above
    - the contentResolver projection `columnsToFetch` is created by adding the required columns
for each passed field (`columnsToFetch.add(...)`)
      - but without adding the columns for `CommonDataKinds.[...].LABEL` to `columnsToFetch`
    - `columnsToFetch `is fed to `mApp.getActivity().getContentResolver().query(...)`, resulting
in Cursor `c`
      - at this state the cursor is already missing the later required `LABEL` columns
    - `populateContactArray(limit, populate, c);` is called
    - within the `while` loop query methods are executed to fetch the required fields from
the cursor.
      - in those query methods `getColumnIndex` is called to retrieve the none existing `LABEL`
column, returning `-1`
      - `cursor.getString(-1)` is called
        - returns nullable now, which is fine
        - threw an `java.lang.IllegalStateException` back then
    
    `getContactById` is using `populateContactArray `too, but should be fine for now, because
"null" is passed as the projection param, which returns a cursor, pointing to all columns.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org


Mime
View raw message