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

2

0

EDIT

FYI, The trick which consists in extracting RawContactID from lookupKey (similar to "1450iSkype_288") does not work anymore.

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:

EDIT: this trick does not work anymore ->

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 ;-)

<- this trick does not work anymore

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.

Dermatoglyphics answered 26/4, 2020 at 9:21 Comment(1)
FYI, I also posted this on answers.microsoft.com here: answers.microsoft.com/en-us/skype/forum/sk_dev-sk_devbots/…Dermatoglyphics
S
0

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?

Stenophagous answered 27/4, 2020 at 8:43 Comment(8)
Thanks. I listed all sync adapters and authorities on the device and found only com.skype.raider related to Skype (no com.skype4life despite it's mentioned here and there on the web)Dermatoglyphics
Hmmm, suddenly they where added to mij addressbook. I have no idea what the trigger was... Would you know how one could trigger an automatic audio or videocall? I'm able to to so using: Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.setData(Uri.parse("skype:" + contactNumber + "?call")); context.startActivity(intent); But that only triggers the callscreen itself, without actually callingStenophagous
OK, so there is really some sync mechanism, but it's not immediate. Also Skype changed the way calls are started so now the user has to tap a button. I could not (yet) find any workaround for that. For video calls, just use Uri.parse("skype:" + skypeId + "?call&video=true"), but you probably already know that ;-) FYI, I'll soon investigate Google Duo, as I would also like to integrate to my app.Dermatoglyphics
I think you're trying the same as I did :-D Search Google play store for 'seniorfoon' (it's dutch, but you'll figure)Stenophagous
Nice. So Whatsapp calls can be done even to people not being in your WhatsApp contact list? My (10) apps are here: play.google.com/store/apps/developer?id=Elementique Feel free to reach out by email if you want us the discuss further. Ik spreek een beetje Nederlands ;-)Dermatoglyphics
I just saw you're Belgian too? Flanders or Wallonie? BTW, I also created a facebook group "seniorfoon" for feedback etcStenophagous
Ok, so it's clear you are doing much more than I did :-D I'll reach out to you by e-mail. Just the info@... from play store?Stenophagous
Yes, the info@... email address is fine. Let's continue by email then ;-)Dermatoglyphics
X
0

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:

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

Xanthein answered 27/4, 2020 at 9:1 Comment(3)
Thanks for your answer. As explained, I do query using the ContentProvider. I already checked the 2 links: 1st link : I already use IM.protocol, and the rest of the sinfo is not useful. 2nd link: solution is not working. Despite packageName is "com.skype.raider", source code is withing the "com.skype4life" package, so this is OK. Maybe what I try to do is just not possible because of 'com.skype.raider.permission.ACCOUNT' missing permission..Dermatoglyphics
These mime-types are actually ContactsDataKind. Uri.parse("skype:" + phoneNumber + "?call") should still work; Besides Skype URIs, there doesn't seem to be much accessible.Xanthein
I tried ContactsDataKind. Uri.parse("skype:" + phoneNumber + "?call") but it does trigger a 'regular mobile phone call', not an 'Internet / VOIP Phone call'Dermatoglyphics

© 2022 - 2024 — McMap. All rights reserved.