import android.provider.Settings;
import android.text.TextUtils;
import android.util.Log;
+import android.util.Pair;
import android.util.Slog;
import android.util.SparseArray;
}
/** {@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;
+ }
+
+
+ /** {@hide} */
+ public long getPrimaryStorageSize() {
+ final Pair<String, Long> pair = getPrimaryStoragePathAndSize();
+ return pair == null ? 0 : pair.second.longValue();
}
- private long readLong(String path) {
+ 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;
}
}
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;
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;
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));