microg / GmsCore

Free implementation of Play Services
https://microg.org
Apache License 2.0
8.09k stars 1.68k forks source link

Checking deprecated permission.C2D_MESSAGE possibly breaking cloud messages #1475

Open Vavun opened 3 years ago

Vavun commented 3 years ago

Hi.

(Sorry for bad English)

User Dark Simpson asked interesting question in a microG thread on 4pda >> URL <<

He suggested that telegram app does not receive cloud messages correctly due to a missing deprecated C2D_MESSAGE permission check.

https://github.com/microg/GmsCore/blob/a830b5dd5de71fa53f9d037c210a81fb38ea3321/play-services-core/src/main/java/org/microg/gms/gcm/McsService.java#L535-L546

So do we really need to check this permission ? Migrating from Google Cloud Messaging (GCM) to Firebase Cloud Messaging (FCM)

And one more question from me: Is it normal that whitelisting doesn't happen for third party apps? https://github.com/microg/GmsCore/blob/a830b5dd5de71fa53f9d037c210a81fb38ea3321/play-services-core/src/main/java/org/microg/gms/gcm/McsService.java#L561-L570 Or have I misunderstood something?

Thanks.

Fox2Code commented 3 years ago

From what I saw, .permission.C2D_MESSAGE is not required to receive messages, but only used to allow 3rd party app to listen on cloud messaging, meaning the package asking for notification always receive the intent, whatever they have the permission or not.

This mean if Telegram register for cloud messaging (aka. GCM), Telegram will always receive the intent even without org.telegram.messenger.permission.C2D_MESSAGE, this check only affect apps that want to receive an intent they didn't register themselves.

Also you can check inside MicroG settings, you can see which apps have registered cloud messaging listeners, if you don't see telegram in the list this mean it's a registration issue, as any apps using GCM should appear here.