GmsCore icon indicating copy to clipboard operation
GmsCore copied to clipboard

ContactSyncService: Implement related functions

Open DaVinci9196 opened this issue 11 months ago • 20 comments

Includes:

  1. After adding/deleting/modifying contact groups and personnel information, the cloud and device are synchronized with each other.
  2. After adding/deleting/modifying contact avatar information, the cloud and device are synchronized with each other.

Note: Tried to use PeopleApi, but did not have access to the interface.

DaVinci9196 avatar Jan 06 '25 08:01 DaVinci9196

@DaVinci9196 so can people api not be made to work with MicroG? This is critical, as since a few weeks ago all requests made to the old apis return: Received 429 status code: Contacts API has been deprecated. Migrate to People API to retain programmatic access to Google Contacts. See https://developers.google.com/people/contacts-api-migration.

This includes the google contacts sync adapter

Sense101 avatar Feb 25 '25 08:02 Sense101

@DaVinci9196 I would like to help to finish implementing this. Please respond.

Sense101 avatar Feb 27 '25 07:02 Sense101

@DaVinci9196 I would like to help to finish implementing this. Please respond.

Sorry, I just noticed today that I used OauthToken generated based on GMS and Google Contacts app when verifying whether PeopleApi is available. Unfortunately, errors such as unable to access the API and no contacts permission appeared. You can try to see if there are other ways to solve these errors.

DaVinci9196 avatar Feb 28 '25 05:02 DaVinci9196

I am looking into this

Sense101 avatar Mar 06 '25 14:03 Sense101

I am still looking into this, as the entire structure of the api has changed this is not as simple as I thought.

Sense101 avatar Mar 19 '25 15:03 Sense101

@Sense101 sorry for bothering, but what have you discovered?

000exploit avatar Apr 16 '25 18:04 000exploit

No problem, took a break from this although I will be returning to it. Part of what I was working on is that the format of the .proto files (which define data sent between the client and server) must include specific annotations to link up correctly with the new google api's. This required different dependencies to the ones used right now in MicroG, which was a whole mess to sort out.

Still lots of work to do, but that's part of what I discovered :)

Sense101 avatar Apr 16 '25 20:04 Sense101

Just noting I had some incorrect assumptions about this.

Sense101 avatar Jun 19 '25 14:06 Sense101

@DaVinci9196 I have been working on this, and have replicated calling the People api using an oauth generated based on GMS. I got the following error messsage back from google:

People API has not been used in project 745476177629 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/people.googleapis.com/overview?project=745476177629 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.

Was this the same error that you saw? If not, what error did you see?

I tried generating oauth token based on the old contacts sync adapter id but couldn't get an auth token.

I think this is a crucial feature for microg to have so it should be a priority to fix.

The only next step I see from here is reverse engineering how play services does it, which I have no experience with. It seems likely that google play services is using some internal API - would you be able to either find out what that is / know how I could do that?

If anyone else is willing to help with this it would also be appreciated.

Sense101 avatar Sep 10 '25 16:09 Sense101

@Sense101 Yes, we have encountered this problem since the beginning. This is a configuration behavior of GMS itself and there is no way to bypass or fix it. The current solution was adopted as the last resort to sync contacts.

DaVinci9196 avatar Sep 11 '25 02:09 DaVinci9196

@DaVinci9196 so to clarify, you're saying there is no way to now include contacts sync within MicroG? Why is reverse engineering what play services does not an option?

Sense101 avatar Sep 11 '25 13:09 Sense101

@Sense101 At least not yet, maybe Marvin is considering other options.

DaVinci9196 avatar Sep 12 '25 01:09 DaVinci9196

@DaVinci9196 @Sense101

Before implementing the contact sync part have you tried to implement the backup transport part?

On Android 4.4 (Kitkat) the Google Contact Sync Adapter behave in this way:

  • WithOUT Google Backup Transport it use its internal deprecated sync over plain http
  • With Google Backup Transport installed it use Google Backup Transport to do the sync

Before Android 6 (Marshmallow) all Google Backup Transports include the service: com.google.android.backup.BackupTransportService Starting from Android 6 the service .backup.BackupTransportService was removed from Google Backup Transport and added to Google Play Services.

On Android 7.1.2 (Nougat) Google Contact Sync Adapter say this:

09-12 19:36:24.107  6027  6046 I SyncAdapterProxy: Delagator disabled, using the (deprecated) GData sync adapter
09-12 19:36:24.110  6027  6046 I GoogleHttpClient: GMS http client unavailable, use old client

So if we implement the missing parts in microG Services (possibly service .backup.BackupTransportService) maybe the official Google Contact Sync Adapter may start working again.

ale5000-git avatar Sep 12 '25 17:09 ale5000-git

@ale5000-git Compared to implementing another larger function, I prefer the current PR solution :)

DaVinci9196 avatar Sep 15 '25 01:09 DaVinci9196

The whole file is 0.17 MB, I wouldn't say it is big. This is the one I'm referring to: https://www.apkmirror.com/apk/google-inc/google-backup-transport/google-backup-transport-5-1-1-2640980-release/google-backup-transport-5-1-1-2640980-android-apk-download/

Also the current PR don't work, or I'm wrong?

ale5000-git avatar Sep 15 '25 03:09 ale5000-git

As @ale5000-git said, this PR doesn't work anymore, and there isn't any way to get it working.

However, I don't think relying on Google Contacts sync apk is a good solution because Google clearly stopped producing further versions and there's no way it will work long term.

The idea with backup transport may be a good try though for a short term solution, although I don't like the idea of adding old code

Sense101 avatar Sep 15 '25 12:09 Sense101

After verification, this PR still works to obtain contact data. However, additional steps are required. After granting microG permission to read your address book, select your Google account on the Accounts page in System Settings and click Sync Now.

DaVinci9196 avatar Sep 16 '25 02:09 DaVinci9196

After verification, this PR still works to obtain contact data.

This is awesome! Is there an early build for alpha-testing? thanks.

P.S. I see that CI doesn't leave artifacts, sadly

ildar avatar Sep 16 '25 08:09 ildar

Hmm so it seems the shutdown of the old api for contacts sync didn't yet impact when play services is asking for sync?

That's unusual as it is shut down for all other apps I think it is only a matter of time till they shut it down fully

Sense101 avatar Sep 16 '25 11:09 Sense101

hello, Hi, I used to use the Magisk module to sync my contacts, but a few months ago, or maybe at the beginning of the year, after updating the ROM and/or apps, my contacts stopped having names (they wouldn't sync). Now I've formatted my phone and tried the same process I used with the module, but it still doesn't work. I've also tried downloading the latest sync adapters, but that didn't work either. I just tried DAVX, and the implementation for syncing has improved; it's incredibly easy (they've added a button).

And now I see this thread. Has it finally been implemented? Because I see "All checks have passed" and "No conflicts with base branch."

Any updates, please? Thanks a million!

xisnamh avatar Dec 09 '25 16:12 xisnamh