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 c8b29ac6f0)
Bug: 36056324
Test: builds, boots
Merged-In: Ibdf1ee4e8885680e106df6a9269b6309ddc61af8
Change-Id: Ibdf1ee4e8885680e106df6a9269b6309ddc61af8
This commit is contained in:
committed by
Andreas Gampe
parent
834be81189
commit
1285cfd48f
@@ -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>() {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user