Closed Bug 583242 Opened 14 years ago Closed 4 years ago

Add contact support to form autocomplete (Android)

Categories

(Firefox for Android Graveyard :: General, defect, P5)

All
Android
defect

Tracking

(fennec+)

RESOLVED INCOMPLETE
Tracking Status
fennec + ---

People

(Reporter: mfinkle, Unassigned, Mentored)

References

Details

(Whiteboard: [lang=java])

Attachments

(1 file, 4 obsolete files)

Bug 578691 adds most of the infrastructure to support showing contact information in form autocomplete. We need to add a data provider for Android.
OS: Linux → Android
Hardware: x86 → All
flagging for fennec 2.0 to get on triage plate
blocking2.0: --- → ?
tracking-fennec: --- → ?
blocking2.0: ? → ---
tracking-fennec: ? → 2.0+
Attached patch patch (obsolete) (deleted) — Splinter Review
Assignee: nobody → blassey.bugs
Attachment #495185 - Flags: review?(mwu)
Attached patch patch (obsolete) (deleted) — Splinter Review
forgot to add the new files
Attachment #495185 - Attachment is obsolete: true
Attachment #495541 - Flags: review?(mwu)
Attachment #495185 - Flags: review?(mwu)
Attached patch m-b patch (obsolete) (deleted) — Splinter Review
Attachment #495542 - Flags: review?(mark.finkle)
Comment on attachment 495542 [details] [diff] [review] m-b patch >-#ifndef ANDROID >+#ifdef ANDROID >+function AndroidContactsProvider() { >+} >+AndroidContactsProvider.prototype = { nit: Add a blank line >+ getContacts: function() { >+ return JSON.parse(Cc["@mozilla.org/dom/contacts;1"].getService(Ci.nsIContacts).contacts); As I mentioned on IRC, since this is going in platform, I think .getContactsAsJSON() might be better. Then, in the future, we could add other means of retrieving contacts, which would be wrapped nicely in a JSM. but that is for the platform review. This looks good to me.
Attachment #495542 - Flags: review?(mark.finkle) → review+
This seems like something that needs superreview. It looks mostly ok to me otherwise - I'll do a more thorough review with superreview.
Attachment #495541 - Flags: superreview?(pavlov)
Attachment #495541 - Flags: superreview?(pavlov) → superreview?(jst)
Might take if reviewed, but not blocking at this point
tracking-fennec: 2.0+ → 2.0-
Comment on attachment 495541 [details] [diff] [review] patch sr=jst (verbally)
Attachment #495541 - Flags: superreview?(jst) → superreview+
Attachment #495541 - Flags: review?(mwu) → review?(mbrubeck)
Comment on attachment 495541 [details] [diff] [review] patch >+++ b/embedding/android/AndroidManifest.xml.in >+ <uses-permission android:name="android.permission.READ_CONTACTS" /> Outside the scope of this bug, but we need to think about how to tell users why Firefox requests these permissions. (I've already seen some comment threads speculating about why we request location permissions, and this one probably looks even weirder/more dangerous.) >+++ b/embedding/android/GeckoAppShell.java >+import android.provider.Contacts.*; Do you actually use anything from this deprecated class? >+ Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI, >+ null, null, null, null); We should pass a projection argument to avoid retrieving all columns, which the docs say is "inefficient." >+ if (cur.getCount() > 0) { >+ while (cur.moveToNext()) { You can remove the "if" statement. >+ JSONObject obj = new JSONObject(); >+ String id = cur.getString( >+ cur.getColumnIndex(ContactsContract.Contacts._ID)); >+ String name = cur.getString( >+ cur.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME)); Move the getColumnIndex calls out of the while loops and save the results in local variables. >+ if (Integer.parseInt(cur.getString(cur.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER))) > 0) { Can't you use cur.getInt instead? >+ Cursor pCur = cr.query( >+ ContactsContract.CommonDataKinds.Phone.CONTENT_URI, >+ null, >+ ContactsContract.CommonDataKinds.Phone.CONTACT_ID +" = ?", >+ new String[]{id}, null); It would probably be much faster if we could query all the tables at once with a join, or query each table once and join the results. But the only way I can see to do this is CursorJoiner, which looks kind of annoying. Since we're only using this data for form suggestions, could we change the format to include separate arrays of names, emails, and phone numbers, without joining them at all? This would probably be most efficient. I'd like to see some timing of this function with a large (say 500+) number of contacts. If there's a chance it will block for a significant amount of time on a very large (say 5000+) contact database, then we should either limit the number of rows we read, or make this API async.
Attachment #495541 - Flags: review?(mbrubeck) → review-
Whiteboard: [fennec-4.1?]
Matt - Want to take a shot at refactoring? Possible things to tweak besides the cleanup: * Projection * Timing * Async
This feature has implications to the form autocomplete system, but also for add-ons and a future built-in sharing system.
... and possibly any future web content contact APIs
tracking-fennec: - → 7+
Whiteboard: [fennec-4.1?]
Attached patch updated patch (obsolete) (deleted) — Splinter Review
This patch replaces the two separate previous patches. This patch also addresses some of Matt's review comments. The Android code uses projects to limit the queries and removes the need for the column index calls. The form autocomplete code now reuses the previous list of contacts, filtering _that_ list instead of filtering the entire list of contacts. We also limit the number of suggestions shown in the popup bubble - to speed up the display of the UI.
Assignee: blassey.bugs → mark.finkle
Attachment #495541 - Attachment is obsolete: true
Attachment #495542 - Attachment is obsolete: true
Blocks: 672352
Attached patch patch v4 (deleted) — Splinter Review
The last patch had speed issues. On my Nexus One, with 391 contacts, it was taking >4400ms to load the contacts from Android. Brad has many more contacts and it was taking over 40secs. I tried to turn the query into an async query, but I ran into trouble with using Looper. I converted the XPCOM part of the patch to work async, but I left the Java part sync for now. I did change the Java query part into two separate queries: 1 to fetch the emails, and 1 to fetch the phone numbers. Each query also returns the contact's display name. I use a HashMap to create a master list of contacts with emails and phoneNumbers properties, just like before. However, this approach is 40x faster. Queries on my Nexus One now take 108ms. Posting the patch for feedback and to let people stress test the performance.
Attachment #546000 - Attachment is obsolete: true
tracking-fennec: 7+ → +
No longer blocks: 672352
Depends on: 672352
Assignee: mark.finkle → nobody
Flags: superreview+
Product: Fennec → Fennec Native
Assignee: nobody → esawin
Assignee: esawin → nobody
Whiteboard: [lang=java][mentor=blassey]
Mentor: blassey.bugs
Whiteboard: [lang=java][mentor=blassey] → [lang=java]
filter on [mass-p5]
Priority: -- → P5
We have completed our launch of our new Firefox on Android. The development of the new versions use GitHub for issue tracking. If the bug report still reproduces in a current version of [Firefox on Android nightly](https://play.google.com/store/apps/details?id=org.mozilla.fenix) an issue can be reported at the [Fenix GitHub project](https://github.com/mozilla-mobile/fenix/). If you want to discuss your report please use [Mozilla's chat](https://wiki.mozilla.org/Matrix#Connect_to_Matrix) server https://chat.mozilla.org and join the [#fenix](https://chat.mozilla.org/#/room/#fenix:mozilla.org) channel.
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → INCOMPLETE
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: