Loading core/java/com/android/internal/app/IMediaContainerService.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -33,8 +33,10 @@ interface IMediaContainerService { boolean checkExternalFreeStorage(in Uri fileUri, boolean isForwardLocked); ObbInfo getObbInfo(in String filename); long calculateDirectorySize(in String directory); byte[] listDirectory(in String directory); /** Return file system stats: [0] is total bytes, [1] is available bytes */ long[] getFileSystemStats(in String path); void clearDirectory(in String directory); void deleteFile(in String file); long calculateInstalledSize(in String packagePath, boolean isForwardLocked); } packages/DefaultContainerService/src/com/android/defcontainer/DefaultContainerService.java +46 −0 Original line number Diff line number Diff line Loading @@ -38,6 +38,7 @@ import android.os.Environment; import android.os.Environment.UserEnvironment; import android.os.FileUtils; import android.os.IBinder; import android.os.Parcel; import android.os.ParcelFileDescriptor; import android.os.Process; import android.os.RemoteException; Loading Loading @@ -236,6 +237,40 @@ public class DefaultContainerService extends IntentService { } } /** * List content of the directory and return as marshalled Parcel. * Used for calculating misc size in Settings -> Storage */ @Override public byte[] listDirectory(String path) throws RemoteException { Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND); final File directory = new File(path); final File[] files = directory.listFiles(); final Parcel out = Parcel.obtain(); if (files == null) { out.writeInt(0); } else { out.writeInt(files.length); for (final File file : files) { out.writeString(file.getAbsolutePath()); out.writeString(file.getName()); out.writeInt(file.isDirectory() ? 1 : 0); if (file.isFile()) { out.writeInt(1); out.writeLong(file.length()); } else { out.writeInt(0); } } } return out.marshall(); } @Override public long[] getFileSystemStats(String path) { Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND); Loading @@ -260,6 +295,17 @@ public class DefaultContainerService extends IntentService { } } // Same as clearDirectory, but also work for files @Override public void deleteFile(String path) throws RemoteException { Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND); final File file = new File(path); if (file.exists()) { eraseFiles(file); } } @Override public long calculateInstalledSize(String packagePath, boolean isForwardLocked) throws RemoteException { Loading Loading
core/java/com/android/internal/app/IMediaContainerService.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -33,8 +33,10 @@ interface IMediaContainerService { boolean checkExternalFreeStorage(in Uri fileUri, boolean isForwardLocked); ObbInfo getObbInfo(in String filename); long calculateDirectorySize(in String directory); byte[] listDirectory(in String directory); /** Return file system stats: [0] is total bytes, [1] is available bytes */ long[] getFileSystemStats(in String path); void clearDirectory(in String directory); void deleteFile(in String file); long calculateInstalledSize(in String packagePath, boolean isForwardLocked); }
packages/DefaultContainerService/src/com/android/defcontainer/DefaultContainerService.java +46 −0 Original line number Diff line number Diff line Loading @@ -38,6 +38,7 @@ import android.os.Environment; import android.os.Environment.UserEnvironment; import android.os.FileUtils; import android.os.IBinder; import android.os.Parcel; import android.os.ParcelFileDescriptor; import android.os.Process; import android.os.RemoteException; Loading Loading @@ -236,6 +237,40 @@ public class DefaultContainerService extends IntentService { } } /** * List content of the directory and return as marshalled Parcel. * Used for calculating misc size in Settings -> Storage */ @Override public byte[] listDirectory(String path) throws RemoteException { Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND); final File directory = new File(path); final File[] files = directory.listFiles(); final Parcel out = Parcel.obtain(); if (files == null) { out.writeInt(0); } else { out.writeInt(files.length); for (final File file : files) { out.writeString(file.getAbsolutePath()); out.writeString(file.getName()); out.writeInt(file.isDirectory() ? 1 : 0); if (file.isFile()) { out.writeInt(1); out.writeLong(file.length()); } else { out.writeInt(0); } } } return out.marshall(); } @Override public long[] getFileSystemStats(String path) { Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND); Loading @@ -260,6 +295,17 @@ public class DefaultContainerService extends IntentService { } } // Same as clearDirectory, but also work for files @Override public void deleteFile(String path) throws RemoteException { Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND); final File file = new File(path); if (file.exists()) { eraseFiles(file); } } @Override public long calculateInstalledSize(String packagePath, boolean isForwardLocked) throws RemoteException { Loading