Bluetooth sync adr-type "other" between two devices

{@link ContactsContract} has a {@link StructuredPostal.TYPE_OTHER}.
However, when a vCard is created in {@link VCardBuilder}, {@code
TYPE_OTHER} does not get mapped to anything, i.e., the {@code ADR} entry
in the vCard does not have a {@code TYPE=}. Then, when a vCard is parsed
in {@link VCardEntry}, it will get a null String when trying to get the
address's {@code TYPE=}, which it will then default to {@link
StructuredPostal.TYPE_HOME}.

As a result, if a user syncs contact information between two Android
devices using vCards (e.g., over Bluetooth), an address marked as type
"Other" on the source device will appear as type "Home" on the sink
device.

To correctly sync the type "Other", this CL uses the existing framework
in the vcard package that handles {@link ContactsContract}'s custom
types, i.e., prepending with "X-". According to RFC 2426, this
constitutes a valid "x-name", which constitutes a valid "adr-type".

Bug: 197177611
Test: atest AndroidVCardTests
Test: (Manual) Create a contact with address of type "other". Sync the
contact to a second device. Verify on the second device that the address
is still of type "other", and not of type "home". Also, in the Bluetooth
HCI snoop logs, look for the raw vCards, and verify in the "ADR" entry,
there is a "TYPE=X-OTHER". Note, both devices must be Android.

Change-Id: I47217041e52d2d1c57b206bf88cc3b763baae418
7 files changed
tree: ddcd3c9846c98a2d3334ff7e1d2501c9cc53cd02
  1. java/
  2. tests/
  3. Android.bp
  4. build.gradle
  5. OWNERS