Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use remote contact directories (global address list; GAL) for recipient auto-complete #8004

Open
2 tasks done
doctorjei opened this issue Jul 2, 2024 · 6 comments
Open
2 tasks done
Labels
status: needs design Issues requiring design decisions or inputs type: enhancement New features or improvements to existing features.

Comments

@doctorjei
Copy link

doctorjei commented Jul 2, 2024

Checklist

  • I have used the search function to see if someone else has already submitted the same bug report.
  • I will describe the problem with as much detail as possible.

App version

6.804

Where did you get the app from?

Google Play

Android version

12

Device model

Pixel 3a

Steps to reproduce

  1. Add an exchange account to GMail
  2. in contacts app, select new exchange account (upper right corner)
  3. Search for a contact not in the local account list, but in the Exchange GAL (to verify it exists)
  4. In K9, compose new email
  5. Touch three dots in upper right corner to open menu
  6. Select "add from contacts"
  7. Search for same contact previously searched in contacts app

Expected behavior

The contact from the GAL should appear

Actual behavior

The contact from the GAL is not found

Additional Info

Please note that this is not requesting AES or AWS support - just for K9 to look at existing contacts.

This may be due to K9 defaulting to the "main" contact account (as there doesn't appear to be any way to change the account to search from). So, it may actually be a feature request - but there is no indication of which account (if any) is being used to pull contacts.

@doctorjei doctorjei added type: bug Something is causing incorrect behavior or errors unconfirmed Newly reported issues awaiting triage or confirmation labels Jul 2, 2024
@cketti
Copy link
Member

cketti commented Jul 15, 2024

The "Add from contacts" menu option opens the contacts app to select a contact. If that doesn't show the "GAL contacts", that's an issue with the contacts app, not K-9 Mail.

@doctorjei
Copy link
Author

doctorjei commented Jul 15, 2024

But it does show up in the contacts app when directly directly invoked; that's the issue.

I suppose it's possible that there is no way for another application to open the more general dialog or the Contacts app. I'll try to investigate that and follow up.

@doctorjei
Copy link
Author

doctorjei commented Jul 15, 2024

I have confirmed that from the Android phone app (Pixel 3a, Android 10), search also searches from other accounts (not just the primary / default), including directories. Here's how I get that result:

  1. Touch the "contacts" tab on the bottom right
  2. search for a contact only in the directory (GAL for Exchange)
  3. The contact appears

I will continue digging, but this does show at least that other applications can get to this data.

@user12921
Copy link

@cketti
According to https://developer.android.com/reference/android/provider/ContactsContract.Directory:
"Access to Contacts Provider is protected by the READ_CONTACTS permission, but access to the directory provider is protected by BIND_DIRECTORY_SEARCH."

K9Mail only requests READ_CONTACTS, so this is clearly not a problem of the contact provider but K9Mail. I experience the same problem with our Google Workspace Directory. Problem is, all our employees are in the GAL only, if I wish to use K9Mail autocomplete I have to copy a contact from the Directory to my private contacts first. Other Android apps seem to support this feature generally, i.e. Samsung and Google dialer apps search in the Directory automatically.

@cketti
Copy link
Member

cketti commented Aug 21, 2024

Apparently, Google Workspace contacts (and presumably contacts from other such directories) are not treated like regular contacts on Android. See e.g. https://support.google.com/a/users/answer/7559344?hl=en

Some digging around revealed that Email.CONTENT_FILTER_URI can be used with a DIRECTORY_PARAM_KEY parameter to search a specific directory. Notably, also company directories that are not searched by default.

For an example see https://github.com/klinker41/android-chips/blob/81d0719c80b7aa214b8b7191f31e320e5be8b2b8/library/src/main/java/com/android/ex/chips/BaseRecipientAdapter.java#L943-L944

So K-9 Mail not searching company contact directories is not a bug, but a missing feature.


According to https://developer.android.com/reference/android/provider/ContactsContract.Directory:
"Access to Contacts Provider is protected by the READ_CONTACTS permission, but access to the directory provider is protected by BIND_DIRECTORY_SEARCH."

The same page also contains this:

Clients should send directory requests to Contacts Provider and let it forward them to the respective providers rather than constructing directory provider URIs by themselves.

Accessing the list of directories and searching directories via the method described above doesn't need a permission other than READ_CONTACTS. I had a quick look and the Gmail app for example doesn't use the BIND_DIRECTORY_SEARCH permission.

@cketti cketti added type: enhancement New features or improvements to existing features. status: needs design Issues requiring design decisions or inputs and removed type: bug Something is causing incorrect behavior or errors unconfirmed Newly reported issues awaiting triage or confirmation labels Aug 21, 2024
@cketti cketti changed the title K9 does not pull all contacts from contacts app (e.g., exchange accounts in contacts) Use remote contact directories (global address list; GAL) for recipient auto-complete Aug 21, 2024
@user12921
Copy link

Indeed, thats interesting. I just checked the Lineage dialer, which can access the Google directory, but also does not request BIND_DIRECTORY_SEARCH.

This might be helpful:
https://github.com/LineageOS/android_packages_apps_Dialer/blob/lineage-21.0/java/com/android/dialer/phonelookup/cp2/Cp2ExtendedDirectoryPhoneLookup.java

In queryCp2ForExtendedDirectoryIds they seem to load all available directory ids first, before doing a lookup. I had wondered how you would decide which directory to query.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs design Issues requiring design decisions or inputs type: enhancement New features or improvements to existing features.
Projects
None yet
Development

No branches or pull requests

3 participants