Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 75ffc4ab authored by d34d's avatar d34d Committed by Danesh M
Browse files

Check for externally installed apps if sdcard ejected

If the SD card is ejected without being properly unmounted, it is
possible for PackageManagerService to be holding onto an app that
was currently mounted in an ASEC.  In this case
PackageHelper.getSecureContainerList() will return an empty list so
we should iterate over all the packages and any that are flagged as
being installed on external storage should be added to the list so
that those apps that were running can be killed and PackageManager
can stop holding onto the open file (apk).

Change-Id: Ie2a313a5bcf7a97d52ab04eeb51a5ec6fd1fa4cd
TICKET: CYNGNOS-903
(cherry picked from commit 27756075)
parent c9103fa7
Loading
Loading
Loading
Loading
+19 −1
Original line number Diff line number Diff line
@@ -13804,7 +13804,25 @@ public class PackageManagerService extends IPackageManager.Stub {
        ArrayMap<AsecInstallArgs, String> processCids = new ArrayMap<>();
        int[] uidArr = EmptyArray.INT;
        final String[] list = PackageHelper.getSecureContainerList();
        String[] list = PackageHelper.getSecureContainerList();
        // In case external storage was ejected without unmounting, populate the list with all apps
        // that are installed on external storage
        if (!isMounted && ArrayUtils.isEmpty(list)) {
            synchronized (mPackages) {
                ArrayList<String> newList = new ArrayList<String>();
                for (Map.Entry<String, Package> entry : mPackages.entrySet()) {
                    final Package pkg = entry.getValue();
                    if (isExternal(pkg.applicationInfo)) {
                        String cid = cidFromCodePath(pkg.baseCodePath);
                        newList.add(cid);
                    }
                }
                if (!newList.isEmpty()) {
                    list = newList.toArray(new String[newList.size()]);
                }
            }
        }
        if (ArrayUtils.isEmpty(list)) {
            Log.i(TAG, "No secure containers found");
        } else {