Skip to content

Uninstall and install for every user, not only this one - #136

Open
JingMatrix wants to merge 2 commits into
masterfrom
uninstall-for-all-users
Open

JingMatrix wants to merge 2 commits into
masterfrom
uninstall-for-all-users

Conversation

@JingMatrix

Copy link
Copy Markdown
Owner

A package has one apk and one certificate for the whole device, while the installed bit is per user. An app that is also in a second user or a work profile therefore survives a single-user uninstall with its certificate still on record, and the install it was uninstalled for — a patched build, so differently signed — is refused with a bare INSTALL_FAILED_UPDATE_INCOMPATIBLE. The user has by then lost the app's data for nothing.

Three changes close it:

  • The Shizuku uninstall passes DELETE_ALL_USERS, through the flagged uninstall overload that is hidden rather than absent, so it is called reflectively; a platform without it falls back to the single-user call.
  • The shell install sets INSTALL_ALL_USERS, so the patched build replaces the app in every user that had it instead of landing in the primary one and leaving the others without the app they had.
  • The platform installer has no such flag and acts for the calling user only. There the uninstall reports what it could not do and names pm uninstall as the way out, rather than reporting a success the install then contradicts.

Deciding whether to ask for an uninstall at all needs evidence an unprivileged app does not have: a package installed in another user and not in this one answers nothing, MATCH_UNINSTALLED_PACKAGES included — measured on Android 16. The installed app's own apk paths stand in for it. They come from the package manager at a moment the app was visible here, they point into /data/app, and that directory lives exactly as long as some user still has the package, so the certificate can be read from the file.

The prompt and the effect line now say every user, and the thirty translations say it too.

A package has one apk and one certificate for the whole device, while
the installed bit is per user. An app left behind in a second user or
a work profile keeps its certificate on record, and the next install
of a differently signed build — which every patched build is — is
refused with INSTALL_FAILED_UPDATE_INCOMPATIBLE, after the manager has
asked for an uninstall and the data is already gone.

So the Shizuku uninstall passes DELETE_ALL_USERS through the hidden
flagged overload, reflectively, and falls back to the single-user call
where a platform has none; the shell install sets INSTALL_ALL_USERS,
so the patched build replaces the app wherever it was. The platform
installer has no such flag, so there the uninstall says what it could
not do and names pm uninstall as the way out, rather than report a
success the install then contradicts.

Whether to ask at all needs evidence an unprivileged app does not
have: a package installed in another user and not in this one answers
nothing, MATCH_UNINSTALLED_PACKAGES included. The installed app's own
apk paths stand in. They point into /data/app, which lives exactly as
long as some user still has the package, and the certificate is read
from the file there.

Also here: the prompt and the effect line say every user, in all
thirty languages.
The sentence a surviving record produces is what the failure screen
puts in front of the reader, so it is a string resource like the rest
of what the app says, translated with the prompt it follows.

Restoring an original over a patched app installs a differently signed
build just as a patch does, so that path hands the installed apks over
as well; without them it would uninstall for this user, report
success, and leave the install to fail. One accessor on PatchTarget
answers which paths are the package manager's, for both callers and
the keystore warning.

Also here: the surviving record is looked for only after an uninstall
that reported success — on any other outcome the apk read would name a
survivor for a package nothing has removed.
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