Skip to content

Let a patched app use Google sign-in and push through MicroG RE - #125

Open
kuomartin wants to merge 6 commits into
JingMatrix:masterfrom
kuomartin:master
Open

kuomartin wants to merge 6 commits into
JingMatrix:masterfrom
kuomartin:master

Conversation

@kuomartin

Copy link
Copy Markdown

Problem

A patched app is signed with LSPatch's key, so Google Play services refuses it wherever it checks the caller's certificate; Google sign-in fails with UNREGISTERED_ON_API_CONSOLE. MicroG RE (ReVanced GmsCore) can stand in for it, but only if the app's traffic reaches it and it knows the app's original certificate.

This supersedes #84, which no longer applies to master and cannot be edited by maintainers. The redirect is ported from NPatch's current version of that work; its authors are credited as co-authors.

Solution

An opt-in MicroG RE support option (--microg-re, also in the manager), recorded in the patch config so a re-patch keeps it.

Patch time — the manifest gets:

  • app.revanced.android.gms.SPOOFED_PACKAGE_SIGNATURE: the original certificate's SHA-1, which MicroG RE reports to Google instead of the caller's.
  • Every com.google.android.c2dm.* string renamed to app.revanced.android.c2dm.*. MicroG RE finds the push receiver by its own RECEIVE action, and the receiver only accepts senders holding com.google.android.c2dm.permission.SEND, a signature permission MicroG RE cannot hold. The manifest editor never descends into intent filters, so the rename is a separate pass over the AXML.

Run time — GmsRedirector rewrites the package, component, action and provider authority of GMS-bound intents and provider calls to MicroG RE, and maps C2DM actions both ways. CHOOSE_ACCOUNT goes to the system account picker; the chimera authority is left to Google Play services.

Differences from #84 and NPatch:

  • An intent the app addresses to itself keeps its action, including through readFromParcel: the sign-in library opens its own SignInHubActivity with GOOGLE_SIGN_IN, and that activity finishes on any other action.
  • No ContentResolver.call retry. It rewrote arguments after the call had returned and swallowed the SecurityException, so callers got null instead of an error.
  • No getPackageInfo hook. It reported the app's own certificate as MicroG's, which matches no check a GMS client makes.

Scope:

  • MicroG RE only. Upstream microG installs as Google Play services, needs no redirect, and would lose pushes to the rename. For it, --fake-signature declares fake-signature with FAKE_PACKAGE_SIGNATURE for a ROM with signature spoofing, as a separate option, also recorded in the patch config.
  • The loader redirects only if it can see MicroG RE, which the app's <queries> don't cover. Local mode already holds QUERY_ALL_PACKAGES; integrated mode needs it added through the added permissions. The option's description and the loader's log say so.

Validation

On a Pixel 10 (Android 17), ReVanced GmsCore installed beside Google Play services, local mode:

  • Google sign-in completes through MicroG RE, which reports the original certificate.
  • Push reaches the app's FCM service, and the app acknowledges it.
  • Rewrite rules (action redirect and restore, self-addressed intents, C2DM mapping) pass a JVM check outside the repo, which has no JUnit setup.
  • The patched manifest for --microg-re, --fake-signature and neither, in both modes, carries exactly the entries above.

Not covered: --fake-signature (no ROM with signature spoofing at hand).

kuomartin and others added 6 commits October 16, 2026 14:52
A patched app is signed with LSPatch's key, so Google Play services refuses it wherever it checks the caller's certificate, Google sign-in among them. The MicroG option redirects the app's GMS intents, provider calls and actions to an installed MicroG, and declares the original certificate in both forms MicroG builds read: fake-signature with FAKE_PACKAGE_SIGNATURE for a ROM with signature spoofing, and app.revanced.android.gms.SPOOFED_PACKAGE_SIGNATURE (the certificate's SHA-1) for ReVanced GmsCore. QUERY_ALL_PACKAGES lets the loader find MicroG, since the app's own queries name only Google Play services.

An intent the app addresses to itself keeps its action, including when it arrives through readFromParcel: the Google sign-in library opens its own SignInHubActivity with com.google.android.gms.auth.GOOGLE_SIGN_IN, and that activity finishes on any other action.

The option is recorded in the patch config, so a re-patch keeps it, and is offered in the manager and as --microg on the command line.

Co-Authored-By: NkBe <HSSkyBoy@outlook.com>
Co-Authored-By: MrZhongzq <108169409+mrzhongzq@users.noreply.github.com>
MicroG looks a patched app's push receiver up by its own RECEIVE action, and the receiver only accepts a sender holding com.google.android.c2dm.permission.SEND, a signature permission of Google Play services that MicroG cannot hold, so every push it delivered was dropped. With MicroG on, every com.google.android.c2dm.* string in the manifest -- intent-filter actions and permissions alike -- is renamed to ReVanced GmsCore's app.revanced.android.c2dm.*, the same rename Morphe applies; the manifest editor never descends into intent filters, so this is a pass of its own.

Two hooks carried over from NPatch are removed. The ContentResolver.call retry rewrote its arguments after the call had already returned and then swallowed the SecurityException, so callers got null instead of an error. The getPackageInfo hook reported the app's own certificate as MicroG's, which matches no check a GMS client makes.
…ts own

Everything the option does is specific to MicroG RE (ReVanced GmsCore): the SPOOFED_PACKAGE_SIGNATURE metadata, the app.revanced C2DM rename and the redirect to app.revanced.android.gms. Upstream microG installs as Google Play services itself, so it needs no redirect, and renaming its standard C2DM actions would stop its pushes. The option is now "MicroG RE support" (--microg-re), and the redirect no longer falls back to org.microg.gms, which the C2DM rename would leave without pushes.

fake-signature with FAKE_PACKAGE_SIGNATURE is the one declaration upstream microG can use, through a ROM with signature spoofing, so it becomes an option of its own (--fake-signature) rather than a side effect of MicroG RE support. Both are recorded in the patch config so a re-patch keeps them.
The loader has to see MicroG RE to start the redirect, and the app's own queries do not name it. Granting every package's visibility for that is broader than the option needs: a manager-mode app already holds QUERY_ALL_PACKAGES, and an integrated one can add it through the added permissions. The option's description and the loader's warning now say so.
Let a patched app use Google sign-in and push through MicroG RE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant