OSDN Git Service

Change storage migration to use quota APIs.
authorJeff Sharkey <jsharkey@android.com>
Thu, 6 Jul 2017 17:29:06 +0000 (11:29 -0600)
committerJeff Sharkey <jsharkey@android.com>
Thu, 6 Jul 2017 17:29:10 +0000 (11:29 -0600)
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.

Bug: 36056324
Test: builds, boots
Change-Id: Ibdf1ee4e8885680e106df6a9269b6309ddc61af8

core/java/android/app/usage/ExternalStorageStats.java
core/java/com/android/internal/app/IMediaContainerService.aidl
packages/DefaultContainerService/src/com/android/defcontainer/DefaultContainerService.java
services/core/java/com/android/server/pm/Installer.java
services/usage/java/com/android/server/usage/StorageStatsService.java

index d7e570f..f00e5c2 100644 (file)
@@ -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
@@ -97,6 +98,11 @@ public final class ExternalStorageStats implements Parcelable {
     }
 
     /** {@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>() {
index 81ea191..36e4c1c 100644 (file)
@@ -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);
 }
index 9347877..3800e6f 100644 (file)
@@ -213,27 +213,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);
 
index 5c4c040..bd765b4 100644 (file)
@@ -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) {
index 9f4fb85..21b11b0 100644 (file)
@@ -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;
     }