diff options
author | Jeff Sharkey <jsharkey@android.com> | 2012-04-22 18:57:44 -0700 |
---|---|---|
committer | Jeff Sharkey <jsharkey@android.com> | 2012-04-22 18:58:34 -0700 |
commit | 44dda2d7f52007d2ef33b9e9b9b9b1ec84c5582e (patch) | |
tree | 328cf9b3e42caa4f8f2a398415838b489330c654 /src/com/android/settings/deviceinfo | |
parent | d4260682b763a4004ad4a9724694914db4edca0a (diff) | |
download | packages_apps_Settings-44dda2d7f52007d2ef33b9e9b9b9b1ec84c5582e.tar.gz packages_apps_Settings-44dda2d7f52007d2ef33b9e9b9b9b1ec84c5582e.tar.bz2 packages_apps_Settings-44dda2d7f52007d2ef33b9e9b9b9b1ec84c5582e.zip |
Use statfs() in IMediaContainerService.
Since Settings runs in system UID, it needs to export statfs()
operations to IMediaContainerService.
Bug: 6346248
Change-Id: I5801948211f0e55040da4850e3dd55b93f80798f
Diffstat (limited to 'src/com/android/settings/deviceinfo')
-rw-r--r-- | src/com/android/settings/deviceinfo/StorageMeasurement.java | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/com/android/settings/deviceinfo/StorageMeasurement.java b/src/com/android/settings/deviceinfo/StorageMeasurement.java index b4004e92e..2792d0904 100644 --- a/src/com/android/settings/deviceinfo/StorageMeasurement.java +++ b/src/com/android/settings/deviceinfo/StorageMeasurement.java @@ -31,7 +31,7 @@ import android.os.HandlerThread; import android.os.IBinder; import android.os.Looper; import android.os.Message; -import android.os.StatFs; +import android.os.RemoteException; import android.os.storage.StorageVolume; import android.util.Log; @@ -53,7 +53,7 @@ import java.util.concurrent.ConcurrentHashMap; * know about by just keeping an array of measurement types of the following * properties: * - * Filesystem stats (using StatFs) + * Filesystem stats (using DefaultContainerService) * Directory measurements (using DefaultContainerService.measureDir) * Application measurements (using PackageManager) * @@ -81,7 +81,7 @@ public class StorageMeasurement { private static final String DEFAULT_CONTAINER_PACKAGE = "com.android.defcontainer"; - private static final ComponentName DEFAULT_CONTAINER_COMPONENT = new ComponentName( + public static final ComponentName DEFAULT_CONTAINER_COMPONENT = new ComponentName( DEFAULT_CONTAINER_PACKAGE, "com.android.defcontainer.DefaultContainerService"); private final MeasurementHandler mHandler; @@ -258,8 +258,6 @@ public class StorageMeasurement { return; } - measureApproximateStorage(); - synchronized (mLock) { if (mBound) { removeMessages(MSG_DISCONNECT); @@ -274,6 +272,7 @@ public class StorageMeasurement { } case MSG_CONNECTED: { IMediaContainerService imcs = (IMediaContainerService) msg.obj; + measureApproximateStorage(imcs); measureExactStorage(imcs); break; } @@ -367,15 +366,16 @@ public class StorageMeasurement { sendEmptyMessage(MSG_COMPLETED); } - private void measureApproximateStorage() { - final StatFs stat = new StatFs(mStorageVolume != null - ? mStorageVolume.getPath() : Environment.getDataDirectory().getPath()); - final long blockSize = stat.getBlockSize(); - final long totalBlocks = stat.getBlockCount(); - final long availableBlocks = stat.getAvailableBlocks(); - - mTotalSize = totalBlocks * blockSize; - mAvailSize = availableBlocks * blockSize; + private void measureApproximateStorage(IMediaContainerService imcs) { + final String path = mStorageVolume != null ? mStorageVolume.getPath() + : Environment.getDataDirectory().getPath(); + try { + final long[] stats = imcs.getFileSystemStats(path); + mTotalSize = stats[0]; + mAvailSize = stats[1]; + } catch (RemoteException e) { + Log.w(TAG, "Problem in container service", e); + } sendInternalApproximateUpdate(); } |