Repository navigation
Conversation
…mes GMS A replacement that renamed its namespaces, such as MicroG RE (app.revanced.android.gms), breaks Google sign-in at three points when only the package is rewritten. - Actions: each com.google.android.gms.* action is renamed into the replacement's namespace when the renamed action resolves there, asked once per action, and left as Google's otherwise. Intents the app addresses to itself keep Google's names, since SignInHubActivity finishes on any other action. - Chimera bindings: a binding to com.google.android.chimera.BoundService.START carrying chimera-action:<action> is turned back into the API's own action, addressed to the replacement. Intents are rewritten by field just before ContextImpl binds or starts a service and before Instrumentation starts an activity, because AOT-compiled apps can inline Intent's constructor and setters past the setter hooks. - Auth tokens: AccountManager.getAuthToken on the com.google account is retyped to the account type the replacement's authenticator registered, since Google Play services' authenticator answers UNREGISTERED_ON_API_CONSOLE. A replacement that registers no authenticator is left alone.
Author
|
Some applications will not re-register for the FCM service. |
The action rewrite matched com.google.android.gms.* alone, while the package and the authority rewrites both cover com.google.android.gsf: a replacement serves the login and checkin services from inside its own package, so an app reaching them by action needs the same rename the gms actions get. One prefix now covers both -- the vendor's own android namespace, which is the rule redirectAuthority already applies to authorities -- and the declares() gate still decides each name. Retyping a Google account to the replacement's authenticator now stops where the replacement lists accounts of that type and none of them is the one asked for, so the retype cannot turn Google's "unregistered" answer into an authenticator failure. An empty list is not an absent account: since API 26 an app sees only the accounts made visible to it, while a token request for one it cannot list still reaches that authenticator, so anything less than proof asks anyway. getAuthTokenByFeatures and invalidateAuthToken name the account type instead of an account, so the Account-typed hook never saw them. Both are followed now: a token invalidated on Google's authenticator leaves the replacement's copy in place, and the app retries with the same stale token it was told to throw away. "Registers no authenticator" is remembered as well, so the build that answers that way is not asked again on every token request. Also here: ContextImpl's broadcast calls join the egress hook, so the AOT-inlining argument that brought bindService and startService there covers them too; declares() asks for services before activities, since these APIs are bound rather than started; the query guard is removed rather than left set; and what isSelfTargeted cannot see -- an implicit intent to the app's own registered receiver -- is written down.
FCM does not check the caller's certificate, so Google Play services registers and delivers pushes for a re-signed app as it would for the original. On a device that still has Google's own build, only what does check needs the replacement, and a push left where the app already expects it keeps arriving through the names its manifest declares. Under this option the patcher leaves those C2DM names alone, and the loader points com.google.android.c2dm.*, com.google.iid.* and com.google.android.gms.cloudmessaging.* back at Google Play services wherever a package or component rewrite had sent them to the replacement, a chimera binding for one of them included -- that one is left exactly as the client built it, since Google Play services serves it from its own chimera component. Without a replacement the option means nothing, and the patcher refuses it alone. The manager offers it as a switch under the replacement in the Google Play services sheet, shown once one is chosen and cleared when it is, and it joins the patch chips, the app details and the patch report where its neighbours already are. A re-patch and a loader update carry it.
Which accounts an account picker offers is decided by the intent and not by the picker: the client lists the types it will accept in allowableAccountTypes, and the picker shows accounts of those types alone. The client asks for com.google, while a replacement that renamed its namespaces registers its accounts under a type of its own -- app.revanced, for one, which is neither its package nor anything derivable from it. So a user who has both builds installed is offered exactly the accounts that cannot sign in: Google's. The types the intent names are now rewritten to the replacement's, with the accounts it allows and the one it preselects retyped to match, and the intent still goes to the system picker. Sending it to the replacement's own picker instead would change nothing: that one wraps the system picker and answers the same extra the same way. The type is read from the authenticator the replacement registered, so nothing here guesses at it. The setPackage hook's CHOOSE_ACCOUNT case goes with this: the routing runs in the afterHook of both setters, so whichever order the action and the package arrive in, one place decides. Also here: a chimera binding whose action the replacement answers under neither Google's name nor its own is left exactly as the client built it. It answers most of them under Google's own names -- client telemetry, appset and the advertising id among them -- so those are unwrapped as before, now because a query says so rather than by luck. Safebrowsing is the other kind: nothing declares it by action at all, since Google Play services serves it from the very chimera component the client asked for, so unwrapping it addressed the replacement with an action it does not answer. Left alone it reaches Google's build where that is installed, and fails no worse where it is not.
A content provider refuses a Uri whose authority is not one of its own: ContentProvider checks that before the call reaches any of its methods. Rewriting only the authority the app looks a provider up by therefore resolved the replacement's provider and then handed it Google's Uri, and the call failed inside the replacement with a SecurityException instead of being answered. Every authority this redirects had been failing that way -- 25 refusals in one launch of Speedtest, the phenotype configuration lookup among them -- and nothing showed it, because the client libraries log the exception and carry on without the answer. So the Uri is rewritten too, wherever a provider is named. That means ContentProviderClient as well as ContentResolver: a client that acquires a provider itself calls it through the former, which reaches no ContentResolver method at all, and the phenotype and chimera lookups are made exactly that way. Also here: the hooks are installed over the declared methods rather than by name, skipping the abstract ones. hookAllMethods stops at the first overload it cannot hook, and ContentResolver.acquireProvider is abstract, so the concrete acquireProvider(Uri) beside it was hooked or not depending on the order the two came back in.
The authorities were rewritten on the strength of the package name alone, with chimera held back on the grounds that no replacement provides Dynamite modules. MicroG RE 0.3.13 does: it registers app.revanced.android.gms.chimera, and fonts and phenotype beside it. Holding chimera back therefore sent the lookup to Google Play services, which answered with components of its own, and those bindings then had to be recognised and unwrapped on the way out. So each renamed authority is asked for, exactly as each renamed action already is, and rewritten only where the replacement answers to it. One it does not register stays with Google, where a build installed alongside it -- as keeping pushes requires -- answers the lookup rather than failing it. A chimera lookup now reaches the replacement's own provider and the component it names is bound directly: Speedtest built four chimera bindings per launch before this and builds none after it. Also here: a chimera binding is unwrapped only where it names one of Google's own components. A component redirect moves the package and leaves the class name alone, so Google's class name is what tells its bindings from the ones the replacement's own chimera provider answers with -- and those name a component that is already the right one to bind.
The picker is asked for the replacement's accounts, so it answers with one of them, and the app is handed an account of a type it never named: app.revanced, for the build this was tried against. An app that only passes the name on does not notice, but one that builds an account from the answer, or checks the type against the one it asked for, has no reason to recognise it. So the type this offered is put back on the way in, at dispatchActivityResult, where every activity result arrives before the app's own callback is called with it. Only that one type is put back, so an account the user chose of any other type reaches the app exactly as the picker returned it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A replacement that renamed its namespaces, such as MicroG RE (app.revanced.android.gms), breaks Google sign-in at three points when only the package is rewritten.