seedvault icon indicating copy to clipboard operation
seedvault copied to clipboard

Frozen apps in Work profile are not backed up

Open schklom opened this issue 1 year ago • 7 comments

  1. Set up a Work profile using Shelter
  2. Install an app there
  3. Freeze the app
  4. Use SeedVault to start a backup
  5. The app is not listed on SeedVault

Meanwhile, a disabled app on the main profile (GrapheneOS has a toggle on user apps to disable them) is included in the backup list of SeedVault.

Is there a way to include frozen apps in the backup of a Work profile?

schklom avatar Mar 02 '23 10:03 schklom

What does "freeze" an app even mean?

This might be related: https://github.com/seedvault-app/seedvault/wiki/FAQ#why-do-some-apps-not-allow-to-get-backed-up

grote avatar Mar 02 '23 11:03 grote

AFAIK, freezing is defined here

https://github.com/PeterCxy/Shelter/blob/5c7e4b3b267f7be594f083c271d1b6cf36903418/app/src/main/java/net/typeblog/shelter/services/ShelterService.java using the library on line 8

import android.app.admin.DevicePolicyManager;

the variable on line 33

    private DevicePolicyManager mPolicyManager = null;

the un/freeze code is

        @Override
        public void freezeApp(ApplicationInfoWrapper app) {
            if (!mIsProfileOwner)
                throw new IllegalArgumentException("Cannot freeze app without being profile owner");

            mPolicyManager.setApplicationHidden(
                    mAdminComponent,
                    app.getPackageName(), true);
        }

        @Override
        public void unfreezeApp(ApplicationInfoWrapper app) {
            if (!mIsProfileOwner)
                throw new IllegalArgumentException("Cannot unfreeze app without being profile owner");

            mPolicyManager.setApplicationHidden(
                    mAdminComponent,
                    app.getPackageName(), false);
        }

A frozen app is similar to a disabled app. A frozen app is not technically disabled, but the effect is very similar: the app cannot start by itself, is hidden from the launcher, and can not do anything in the background.

The link you mentioned explains that apps can opt out of system backups, which is related but not useful for this issue.

schklom avatar Mar 02 '23 12:03 schklom

@grote on CalyxOS this is called "hide app", available from app info.

The app is pretty much hidden from everything which is why it isn't getting backed up here. But there are ways.

chirayudesai avatar Mar 02 '23 12:03 chirayudesai

From https://review.calyxos.org/c/CalyxOS/platform_frameworks_base/+/11873

PackageManager.MATCH_UNINSTALLED_PACKAGES - as that's what setApplicationHidden does.

It uninstalls the app - but keeps the APK and data around, ready for re-install when you unfreeze/unhide.

chirayudesai avatar Mar 02 '23 12:03 chirayudesai

@grote For more information, setApplicationHidden is explained at https://developer.android.com/reference/android/app/admin/DevicePolicyManager#setApplicationHidden(android.content.ComponentName,%20java.lang.String,%20boolean)

In practice, i install privacy-invading apps and all Google dependent apps in the Work profile using Shelter, and Shelter automatically freezes most apps in the Work profile a few seconds after locking the screen. Freezing apps also helps a lot to lower battery usage.

Is it possible to back up such hidden apps?

schklom avatar Mar 02 '23 12:03 schklom

We'd need to check if adding the flag PackageManager.MATCH_UNINSTALLED_PACKAGES does the trick, but if the system is not even backing up stopped apps, I am not holding my breath for uninstalled apps.

grote avatar Mar 22 '23 14:03 grote

FYI, the other popular Work profile app "Insular" seems to do it the same way: https://gitlab.com/search?search=setApplicationHidden&nav_source=navbar&project_id=18237274&group_id=7721834&search_code=true&repository_ref=dev-ci

schklom avatar Mar 22 '23 15:03 schklom