Merge "Dumps total size of primary storage." am: 55dc66dde4
am: 12b387dd87
Change-Id: I08e98467d212a7f9ec01b16a46540bc3d059ee51
This commit is contained in:
@@ -40,6 +40,7 @@ import android.os.UserHandle;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.util.Pair;
|
||||
import android.util.Slog;
|
||||
import android.util.SparseArray;
|
||||
|
||||
@@ -930,22 +931,29 @@ public class StorageManager {
|
||||
}
|
||||
|
||||
/** {@hide} */
|
||||
public long getPrimaryStorageSize() {
|
||||
public static Pair<String, Long> getPrimaryStoragePathAndSize() {
|
||||
for (String path : INTERNAL_STORAGE_SIZE_PATHS) {
|
||||
final long numberBlocks = readLong(path);
|
||||
if (numberBlocks > 0) {
|
||||
return numberBlocks * INTERNAL_STORAGE_SECTOR_SIZE;
|
||||
return new Pair<>(path, Long.valueOf(numberBlocks * INTERNAL_STORAGE_SECTOR_SIZE));
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return null;
|
||||
}
|
||||
|
||||
private long readLong(String path) {
|
||||
|
||||
/** {@hide} */
|
||||
public long getPrimaryStorageSize() {
|
||||
final Pair<String, Long> pair = getPrimaryStoragePathAndSize();
|
||||
return pair == null ? 0 : pair.second.longValue();
|
||||
}
|
||||
|
||||
private static long readLong(String path) {
|
||||
try (final FileInputStream fis = new FileInputStream(path);
|
||||
final BufferedReader reader = new BufferedReader(new InputStreamReader(fis));) {
|
||||
return Long.parseLong(reader.readLine());
|
||||
} catch (Exception e) {
|
||||
Slog.w(TAG, "Could not read " + path, e);
|
||||
Slog.w(TAG, "readLong(): could not read " + path + ": " + e);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@ import android.content.pm.ProviderInfo;
|
||||
import android.content.pm.UserInfo;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.ObbInfo;
|
||||
import android.net.TrafficStats;
|
||||
import android.net.Uri;
|
||||
import android.os.Binder;
|
||||
import android.os.DropBoxManager;
|
||||
@@ -86,6 +87,7 @@ import android.text.format.DateUtils;
|
||||
import android.util.ArrayMap;
|
||||
import android.util.AtomicFile;
|
||||
import android.util.Log;
|
||||
import android.util.Pair;
|
||||
import android.util.Slog;
|
||||
import android.util.TimeUtils;
|
||||
import android.util.Xml;
|
||||
@@ -3738,6 +3740,18 @@ class MountService extends IMountService.Stub
|
||||
|
||||
pw.println();
|
||||
pw.println("Primary storage UUID: " + mPrimaryStorageUuid);
|
||||
final Pair<String, Long> pair = StorageManager.getPrimaryStoragePathAndSize();
|
||||
if (pair == null) {
|
||||
pw.println("Internal storage total size: N/A");
|
||||
} else {
|
||||
pw.print("Internal storage (");
|
||||
pw.print(pair.first);
|
||||
pw.print(") total size: ");
|
||||
pw.print(pair.second);
|
||||
pw.print(" (");
|
||||
pw.print((float) pair.second / TrafficStats.GB_IN_BYTES);
|
||||
pw.println(" GB)");
|
||||
}
|
||||
pw.println("Force adoptable: " + mForceAdoptable);
|
||||
pw.println();
|
||||
pw.println("Local unlocked users: " + Arrays.toString(mLocalUnlockedUsers));
|
||||
|
||||
Reference in New Issue
Block a user