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

Commit 1285cfd4 authored by Jeff Sharkey's avatar Jeff Sharkey Committed by Andreas Gampe
Browse files

Change storage migration to use quota APIs.

New quota APIs are much faster than trying to measure manually, and
removing this last user of calculateDirectorySize() means we can
remove it once and for all.

(cherry picked from commit c8b29ac6)

Bug: 36056324
Test: builds, boots
Merged-In: Ibdf1ee4e8885680e106df6a9269b6309ddc61af8
Change-Id: Ibdf1ee4e8885680e106df6a9269b6309ddc61af8
parent 834be811
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ public final class ExternalStorageStats implements Parcelable {
    /** {@hide} */ public long videoBytes;
    /** {@hide} */ public long imageBytes;
    /** {@hide} */ public long appBytes;
    /** {@hide} */ public long obbBytes;

    /**
     * Return the total bytes used by all files in the shared/external storage
@@ -96,6 +97,11 @@ public final class ExternalStorageStats implements Parcelable {
        return appBytes;
    }

    /** {@hide} */
    public @BytesLong long getObbBytes() {
        return obbBytes;
    }

    /** {@hide} */
    public ExternalStorageStats() {
    }
@@ -107,6 +113,7 @@ public final class ExternalStorageStats implements Parcelable {
        this.videoBytes = in.readLong();
        this.imageBytes = in.readLong();
        this.appBytes = in.readLong();
        this.obbBytes = in.readLong();
    }

    @Override
@@ -121,6 +128,7 @@ public final class ExternalStorageStats implements Parcelable {
        dest.writeLong(videoBytes);
        dest.writeLong(imageBytes);
        dest.writeLong(appBytes);
        dest.writeLong(obbBytes);
    }

    public static final Creator<ExternalStorageStats> CREATOR = new Creator<ExternalStorageStats>() {
+0 −3
Original line number Diff line number Diff line
@@ -27,9 +27,6 @@ interface IMediaContainerService {

    PackageInfoLite getMinimalPackageInfo(String packagePath, int flags, String abiOverride);
    ObbInfo getObbInfo(String filename);
    long calculateDirectorySize(String directory);
    /** Return file system stats: [0] is total bytes, [1] is available bytes */
    long[] getFileSystemStats(String path);
    void clearDirectory(String directory);
    long calculateInstalledSize(String packagePath, boolean isForwardLocked, String abiOverride);
}
+0 −21
Original line number Diff line number Diff line
@@ -212,27 +212,6 @@ public class DefaultContainerService extends IntentService {
            }
        }

        @Override
        public long calculateDirectorySize(String path) throws RemoteException {
            Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);

            final File dir = Environment.maybeTranslateEmulatedPathToInternal(new File(path));
            if (dir.exists() && dir.isDirectory()) {
                final String targetPath = dir.getAbsolutePath();
                return MeasurementUtils.measureDirectory(targetPath);
            } else {
                return 0L;
            }
        }

        @Override
        public long[] getFileSystemStats(String path) {
            Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);

            final File file = new File(path);
            return new long[] { file.getTotalSpace(), file.getUsableSpace() };
        }

        @Override
        public void clearDirectory(String path) throws RemoteException {
            Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
+1 −1
Original line number Diff line number Diff line
@@ -258,7 +258,7 @@ public class Installer extends SystemService {

    public long[] getExternalSize(String uuid, int userId, int flags, int[] appIds)
            throws InstallerException {
        if (!checkBeforeRemote()) return new long[4];
        if (!checkBeforeRemote()) return new long[6];
        try {
            return mInstalld.getExternalSize(uuid, userId, flags, appIds);
        } catch (Exception e) {
+1 −0
Original line number Diff line number Diff line
@@ -392,6 +392,7 @@ public class StorageStatsService extends IStorageStatsManager.Stub {
        res.videoBytes = stats[2];
        res.imageBytes = stats[3];
        res.appBytes = stats[4];
        res.obbBytes = stats[5];
        return res;
    }