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

Commit 300c13a4 authored by Kenny Root's avatar Kenny Root
Browse files

Erase OBB files when removing packages

OBB files on USB storage or SD card should be removed when an
application is removed.

Bug: 3356804
Change-Id: Ifbbf043368b125fcd47fd74e5cd2e5167a8deb00
parent 26c1ab2e
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -190,6 +190,7 @@ public class DefaultContainerService extends IntentService {
                while ((pkg=pm.nextPackageToClean(pkg)) != null) {
                    eraseFiles(Environment.getExternalStorageAppDataDirectory(pkg));
                    eraseFiles(Environment.getExternalStorageAppMediaDirectory(pkg));
                    eraseFiles(Environment.getExternalStorageAppObbDirectory(pkg));
                }
            } catch (RemoteException e) {
            }
+12 −3
Original line number Diff line number Diff line
@@ -4408,9 +4408,18 @@ class PackageManagerService extends IPackageManager.Stub {
        }
    }

    /**
     * Check if the external storage media is available. This is true if there
     * is a mounted external storage medium or if the external storage is
     * emulated.
     */
    private boolean isExternalMediaAvailable() {
        return mMediaMounted || Environment.isExternalStorageEmulated();
    }

    public String nextPackageToClean(String lastPackage) {
        synchronized (mPackages) {
            if (!mMediaMounted) {
            if (!isExternalMediaAvailable()) {
                // If the external storage is no longer mounted at this point,
                // the caller may not have been able to delete all of this
                // packages files and can not delete any more.  Bail.
@@ -4430,7 +4439,7 @@ class PackageManagerService extends IPackageManager.Stub {
    
    void startCleaningPackages() {
        synchronized (mPackages) {
            if (!mMediaMounted) {
            if (!isExternalMediaAvailable()) {
                return;
            }
            if (mSettings.mPackagesToBeCleaned.size() <= 0) {