-
Notifications
You must be signed in to change notification settings - Fork 119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] Apps frozen using pm hide
can't be backed up
#826
Comments
I first tried with 8.3.5, I could not reproduce the issue with my first test app. Note, now I'm on 8.3.6 (which shouldn't be different according to this issue). Interestingly it's different for Kiwi browser, Adaway, Advanced Tools (didn't try more, yet, because this experiment removed the icons from my Nova Launcher). Btw. you need to be root to execute pm hide, I assume you used adb root?
this works (note,
which variant? there are multiple "Hide" options, I used "SuperUser Hide". This didn't change the state of "Abfall App ZEW". With Hail, the icons are kept (at least some time), Nova still shows the icon, reporting "not installed" when clicking on it. Interesting, that Hail can hide "Abfall App ZEW", while neither pm hide nor pm unhide works with Abfall App ZEW. The command always reports
and that's not time based. Summary: not all apps may react and there is a delay for certain following effects. |
something like this is schizophrenic... we might get certain problems, because the app is officially "not installed" and we might get errors.
hopefully, it's a state that doesn't effect much for a superuser. |
|
I thought it would be a simple change, but it's more complicated and I have not enough spare time for a longer trip:
|
I also tested using the 8192 in getInstalledPackages, but this doesn't help much, probably because isInstalled is still "no" |
I don't have (and never had) that problem with KISS launcher. I guess it's a bug on Nova's side. Maybe it does aggressive caching and/or mishandles some broadcast events.
Wait, so at the end is Hail able to hide "Abfall App ZEW" on your side or not? I tried the methods Note that Shizuku needs to be installed (+ granted root) for
I didn't try this method, it's what people recommend on the internet. I can try later if you want me to.
Good question. I'm not entirely sure but since Android properly lists the hidden apps in the settings and it knows their state as well (some buttons are grayed out cf my screenshot), then I guess it's not too shaky either. What kind of commands does Neo-Backup need to run? I'd assume it mostly copies data directories and apks when backing up applications. Is there something else?
Did you try to force stop the app first? I haven't dug into Hail's source code but the answers are probably there. At least on my side I haven't had any issues or edge cases with Hail even though I've been intensively using it for the past 2 weeks.
I'm not sure, but we may want to look it up on the internet. This private flag looks stable enough that Hail doesn't seem to have problems with this flag across the many devices and ROMs that people use (as far as I know).
I'm not sure to understand what you mean here. Could you expand?
Note that I'm not sure that an app can be in both states (disabled and hidden) at once. To be confirmed. |
yes, and pm hide sometimes works, too, but most of the time not... I don't see a pattern it feels like Hail does something different from pm hide |
does it remove the icon? or is it kept? the interesting thing is: I restored the Nova data on my current device, and still have icons that are grayed out, because the apps are not installed (or not restored), yet. I guess deinstalling removes the icon. And pm hide seems to count as uninstall. NB and Nove both react on the action, NB replaces the icon by a generic icon. NB uses a broadcast to receive install/uninstall actions, I guess Nova does the same. |
yes, but only if there is no backup, otherwise the icon changes to a generic icon |
well, I didn't think much about it, it's only from experience with such things... Internal Anroid parts probably use states that are available to the system. Well, root applications are already on that path...so I wouldn't worry about it too much. |
well, for Hail it's the main functionality, it has no chance to ignore it...
this was meant for Antonios (@machiav3lli)
I can hide an app then disable it and then unhide, the result is a disabled app (you see it in NB, the disable buitton changes to enable, at the same time you cannot change disabled state in NB while it is hidden, not sure what is happening). On the other side not all parts of the system seem to handle that situation. That's the kind of things that I mean with "schizophrenic situations creating unexpected problems". |
I used the original code from Hail to implement a test (cannot be kept as final code, because it breaks the concept). I added isHidden and made isInstalled report hidden packages as installed. Then the app sheet shows alle buttons but "Launch", which is good. --- mom --- well, app and data sizes are zero in the app sheet |
8192 is PackageManager.MATCH_UNINSTALLED_PACKAGES (which also matches installed packages), |
adding that to getPackageStorageStats (only when retrieving the storageUuid) doesn't help, maybe because queryStatsForPackage only works for installed packages. There are other cases, where storageStats would be interesting, e.g. uninstalled packages with data kept. |
Here is the function that dispatches the freeze operation to the right function depending on the chosen mode: fun setAppFrozen(packageName: String, frozen: Boolean): Boolean =
packageName != BuildConfig.APPLICATION_ID && when (HailData.workingMode) {
HailData.MODE_OWNER_HIDE -> HPolicy.setAppHidden(packageName, frozen)
HailData.MODE_OWNER_SUSPEND -> HPolicy.setAppSuspended(packageName, frozen)
HailData.MODE_DHIZUKU_HIDE -> HDhizuku.setAppHidden(packageName, frozen)
HailData.MODE_DHIZUKU_SUSPEND -> HDhizuku.setAppSuspended(packageName, frozen)
HailData.MODE_SU_DISABLE -> HShell.setAppDisabled(packageName, frozen)
HailData.MODE_SU_HIDE -> HShell.setAppHidden(packageName, frozen)
HailData.MODE_SU_SUSPEND -> HShell.setAppSuspended(packageName, frozen)
HailData.MODE_SHIZUKU_DISABLE -> HShizuku.setAppDisabled(packageName, frozen)
HailData.MODE_SHIZUKU_HIDE -> HShizuku.setAppHidden(packageName, frozen)
HailData.MODE_SHIZUKU_SUSPEND -> HShizuku.setAppSuspended(packageName, frozen)
HailData.MODE_ISLAND_HIDE -> HIsland.setAppHidden(packageName, frozen)
HailData.MODE_ISLAND_SUSPEND -> HIsland.setAppSuspended(packageName, frozen)
else -> false
} Here is what Hail does for the fun setAppHidden(packageName: String, hidden: Boolean): Boolean =
execSU("pm ${if (hidden) "hide" else "unhide"} $packageName").first == 0 And for the fun setAppHidden(packageName: String, hidden: Boolean): Boolean {
HPackages.getApplicationInfoOrNull(packageName) ?: return false
if (hidden) forceStopApp(packageName)
return runCatching {
val pm = asInterface("android.content.pm.IPackageManager", "package")
pm::class.java.getMethod(
"setApplicationHiddenSettingAsUser",
String::class.java,
Boolean::class.java,
Int::class.java
).invoke(pm, packageName, hidden, userId) as Boolean
}.getOrElse {
HLog.e(it)
false
}
} Interestingly for the Did you attempt to force stop the package before attempting to hide it? Maybe your issue is just that the
It removes it immediately (as it should). No latency, it's immediate and the same goes when unfreezing an app. I plan to hopefully do a PR to add support for hidden apps in KISS. It currently supports “hibernating” apps, but it's just an Note that their documentation claims that “Hibernated app do not consume any battery or memory until you launch them again” but it doesn't match my experience: this command is pretty much useless because apps just restart at the next broadcast or intent.
Sounds good to me so far. Pretending that the package was uninstalled from the point of view of user apps is the goal of
It seems to match the behavior of uninstalled apps, which I guess boils down to the fact that Neo-Backup thinks that they are actually uninstalled because it doesn't pass the
I agree, but on the other hand silently ignoring these apps for backup operations is dangerous IMO. I wouldn't be too surprised if some manufacturer ROMs started using this
I agree. The goal here for Android is to pretend that the app was entirely uninstalled, because it makes sure that it doesn't break anything from the point of view of other apps. But under-the-hood it keeps its package and data, and pretends that it just got installed again when the
This could definitely be an option. I think it would be a bit costly for the battery if you use the
As far as I understand it's the expected behavior.
Interesting… Are you certain that this constant indeed has the value |
@hg42 Friendly bump 🙂 |
the bump worked... Well, I already have a branch that should list hidden apps, but I forgot, what the state of that patch is... I also forgot, that I wrote parts of the test results here (which is natural, haha). I agree,
Some services even restart immediately. I guess, the only thing, such an app should do, is restricting background work, that is de-register alarms, broadcasts etc. (which hide/disable/suspend etc. do). Actually, it should do this only for unnecessary work, like downloading advertisements etc. Btw. it seems that At the moment, I think,
is the correct (or consequent) behavior, because NB currently only works for other current user and hide uninstalls the app for that user. When NB starts supporting work profile and multiuser when running on the main user, the condition would change.
this should be the same with commands or API calls
I think, disable and hide are very similar. At least disable is also like uninstalled for all intents and purposes.
no, I only looked at the current SDK and Android N. |
Context
Some battery-saving apps such as Hail offer to automatically freeze apps in order to prevent them from running background services that drain the battery. It can also create a shortcut for each application so that they can be transparently launched without manually unfreezing them.
Among the popular methods, there is
pm disable
,am force-stop
, and suspend/pause). These three all have problematic limitations: received broadcasts and/or services and/or activities can still run in the background!Then there is a fourth (incorrectly-named) solution:
pm hide
(formerly calledpm block
)This very similar to uninstalling an app, but it doesn't actually remove the data and the package file, and the application still appears in
Settings
→Apps
→See all 142 apps
in Android. In this state an app cannot run any service, activities, intents, receive any broadcasts, etc.. It has a massive impact on battery life. I have around 60 apps frozen this way and my phone is as fast as stock.Description
Neo-Backup doesn't display and thus cannot back up packages that were frozen using
pm hide
.Currently Neo-Backup passes
0
for theflags
argument ofgetInstalledPackages()
:Neo-Backup/app/src/main/java/com/machiav3lli/backup/utils/ItemUtils.kt
Line 61 in bfc895b
In comparison, Hail instead passes
8192
:aistra0528/Hail/app/src/main/kotlin/com/aistra/hail/utils/HPackages.kt (line 12-16)
This is probably the reason why Neo-Backup doesn't see the “hidden” apps even though they appear on both Hail and the list of apps in the Android settings.
Note that you can check whether a given app is in the “hidden” state or not by accessing its private flags.
Steps To Reproduce
Kiwi Browser
indeed appears in the list of apps that can be backed up. You can close Neo-Backup now.adb shell pm hide com.kiwibrowser.browser
, or alternatively freeze the app with Hail using theHide
freezing mode.Settings
→Apps
→See all 142 apps
→Kiwi Browser
.Uninstall
button).Kiwi Browser
doesn't appear anymore in the list of apps. It's impossible to back it up with Neo-Backup now.Expected behavior
Kiwi Browser still shows up in the list of apps in Neo-Backup and can be backed up without issues.
Screenshots
On the left Android shows Kiwi Browser in the list of apps and I can click on it to see the details, which enables me to uninstall it for example. On the right Neo-Backup doesn't show Kiwi Browser in the list, acting as if it were completely uninstalled.
System Information
Xiaomi Mi Note 10 Lite
14
PixelOS (PixelOS_toco-14.0-20231223-2156)
8.3.5
The text was updated successfully, but these errors were encountered: