How to obtain Skype ID from Contact DB on Android (my solution is almost OK)

我与影子孤独终老i 提交于 2020-05-14 09:08:12

问题


Summary

I am able to obtain 'Skype ID' / 'Skype user name' , but my solution does not always work because it seems the contact DB of the Skype app does not always contain (expose?) 'all' the data.
Let me explain the situation before asking my question:

1 - Gathering info from Skype apk

Skype App (apk) contains /res/xml/contacts.xml which contains

<ContactsDataKind
    android:icon="@ref/0x7f0e0004"
    android:mimeType="vnd.android.cursor.item/com.skype4life.audio"
    android:summaryColumn="data3"
    android:detailColumn="data4" />

<ContactsDataKind
    android:icon="@ref/0x7f0e0004"
    android:mimeType="vnd.android.cursor.item/com.skype4life.video"
    android:summaryColumn="data3"
    android:detailColumn="data4" />

<ContactsDataKind
    android:icon="@ref/0x7f0e0004"
    android:mimeType="vnd.android.cursor.item/com.skype4life.message"
    android:summaryColumn="data3"
    android:detailColumn="data4" />

<ContactsDataKind
    android:icon="@ref/0x7f0e0004"
    android:mimeType="vnd.android.cursor.item/com.skype4life.phone"
    android:summaryColumn="data3"
    android:detailColumn="data4" />

The important data here is these 4 Skype mimeTypes:

"vnd.android.cursor.item/com.skype4life.phone"
"vnd.android.cursor.item/com.skype4life.message"
"vnd.android.cursor.item/com.skype4life.audio"
"vnd.android.cursor.item/com.skype4life.video"

Note:
It looks like these have been added around Augustus 2018 (see here http://www.skaip.org/skype-8-27-0-88-for-android )

One more usefull info is that the ContactsContract.RawContacts.ACCOUNT_TYPE of Skype is "com.skype.raider"

2 - Querying Content provider

Using info obtained in point 1, I could query the Skype ContentProvider (using selection ContactsContract.Data.MIMETYPE+ "= ? " and selectionArgs "com.skype.raider" ) and obtain data which must be 'interpreted' according to the mimeType (one of the 4 Skype mimeTypes obtained in point 1).

2.1 - For mimeType vnd.android.cursor.item/com.skype4life.message, I obtain something like this:

mimetype = vnd.android.cursor.item/com.skype4life.message
_id = 2773
lookup = 1450iSkype_288
contact_id = 1601
display_name = <Skype User DISPLAY Name HERE>
raw_contact_id = 515
mimetype = vnd.android.cursor.item/com.skype4life.message
data1 = 8:<skype.user.name.value.here>
data2 = null
data3 = Skype
is_primary = 0
data5 = null

Where

<Skype User DISPLAY Name HERE>  is an actual Display Name
<skype.user.name.value.here>    is an actual Skype user name / Skype ID

<skype.user.name.value.here> is the data I want, so this is good!

Important note:

The lookup = 1450iSkype_288 can be parsed to obtain 288 which is the RawcontactId of some other contact!
If this rawContact has a contactId, then this allows me to find the original Contact (vs RawContact) It does even sometimes refer some contact which is NOT a Google contact, but, for example, a WhatsApp contact!
Enjoy this important info ;-)

2.2 - Similar data for theses 2 mimeTypes:

"vnd.android.cursor.item/com.skype4life.audio"
"vnd.android.cursor.item/com.skype4life.video"

So I am also able to obtain <skype.user.name.value.here>. Again, this is good!

2.3 - the Phone mimeType

"vnd.android.cursor.item/com.skype4life.phone"

does not contain Skype ID (in field data1), but instead the phone number, which makes sense.

3 - The Problem

So, all this works fine an I decided to test my code on some other devices, where I installed Skype and used it with same Skype account + same Google account and, BOOM, here is the problem:

The Skype Content Provider only has data for mimeType

"vnd.android.cursor.item/com.skype4life.phone" // <- contains Skype user's phone number, NOT Skype user name / Skype ID

and has NO data for these 3 mimeTypes

"vnd.android.cursor.item/com.skype4life.message" // <- contains Skype username / ID
"vnd.android.cursor.item/com.skype4life.audio"   // <- contains Skype username / ID
"vnd.android.cursor.item/com.skype4life.video"   // <- contains Skype username / ID

Skype Phone Numbers are only usefull to pass phone call using Skype, but that's not what I want to do: I want to pass 'Internet Skype audio / video' calls, not 'regular cell phone' calls.

4 - Question

Why is the Skype app sometimes storing all 4 'phone/message/audio/video' mimeTypes data and sometimes, only 'phone' mimeType?
In the latter case, I am not able to obtain Skype Ids / Skype user names, i.e. the <skype.user.name.value.here> I mentioned above.

I understand my solution is the result of some kind of 'reverse-engineering-like method' and is not 'official' at all, but maybe someone else did the same kind of investigation I did and could find a solution?

Maybe there is some 'Skype sync settings' which should be activated within the Skype app or Within Android?

I already force contacts re-sync for Google and Skype accounts, but this did not help.

Thanks for your help.


回答1:


What a great research! I got here because I stumbled upon the same problem. I also want to get skype username, but only mimetype "vnd.android.cursor.item/com.skype4life.phone" is present in the address book.

If I look at your link, where you mention these com.skype4life.* are added, I also see the addition of:

sync_adapter_account_type:
= com.skype4life
sync_adapter_authority:
= com.android.contacts

So they added this together. Maybe we should sync it in one way or another?




回答2:


The mere problem is, that you don't have com.skype.raider.permission.ACCOUNT.

So you can only query them through ContentProvider or build an index to look them up.

For example:

  • How to get Skype info from the Android contact list?
  • Get Skype name from Contacts list

Intent strings alike com.skype.android.skypecall.action might not exist anymore, because com.skype.raider/com.skype4life obviously is not the same application.



来源:https://stackoverflow.com/questions/61438438/how-to-obtain-skype-id-from-contact-db-on-android-my-solution-is-almost-ok

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!