Loading core/java/android/os/storage/StorageManager.java +25 −0 Original line number Diff line number Diff line Loading @@ -45,8 +45,11 @@ import android.util.SparseArray; import com.android.internal.os.SomeArgs; import com.android.internal.util.Preconditions; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.Arrays; Loading Loading @@ -114,6 +117,11 @@ public class StorageManager { /** {@hide} */ public static final int FLAG_INCLUDE_INVISIBLE = 1 << 10; private static final String INTERNAL_STORAGE_SIZE_PATH = "/sys/block/mmcblk0/size"; private static final String INTERNAL_STORAGE_SECTOR_SIZE = "/sys/block/mmcblk0/queue/hw_sector_size"; private final Context mContext; private final ContentResolver mResolver; Loading Loading @@ -901,6 +909,23 @@ public class StorageManager { return getVolumeList(UserHandle.myUserId(), FLAG_REAL_STATE | FLAG_INCLUDE_INVISIBLE)[0]; } /** {@hide} */ public long getPrimaryStorageSize() { final long numberBlocks = readLong(INTERNAL_STORAGE_SIZE_PATH); final long sectorSize = readLong(INTERNAL_STORAGE_SECTOR_SIZE); return numberBlocks * sectorSize; } private 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("Could not read " + path, e); return 0; } } /** @removed */ public @NonNull StorageVolume[] getVolumeList() { return getVolumeList(mContext.getUserId(), 0); Loading Loading
core/java/android/os/storage/StorageManager.java +25 −0 Original line number Diff line number Diff line Loading @@ -45,8 +45,11 @@ import android.util.SparseArray; import com.android.internal.os.SomeArgs; import com.android.internal.util.Preconditions; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.Arrays; Loading Loading @@ -114,6 +117,11 @@ public class StorageManager { /** {@hide} */ public static final int FLAG_INCLUDE_INVISIBLE = 1 << 10; private static final String INTERNAL_STORAGE_SIZE_PATH = "/sys/block/mmcblk0/size"; private static final String INTERNAL_STORAGE_SECTOR_SIZE = "/sys/block/mmcblk0/queue/hw_sector_size"; private final Context mContext; private final ContentResolver mResolver; Loading Loading @@ -901,6 +909,23 @@ public class StorageManager { return getVolumeList(UserHandle.myUserId(), FLAG_REAL_STATE | FLAG_INCLUDE_INVISIBLE)[0]; } /** {@hide} */ public long getPrimaryStorageSize() { final long numberBlocks = readLong(INTERNAL_STORAGE_SIZE_PATH); final long sectorSize = readLong(INTERNAL_STORAGE_SECTOR_SIZE); return numberBlocks * sectorSize; } private 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("Could not read " + path, e); return 0; } } /** @removed */ public @NonNull StorageVolume[] getVolumeList() { return getVolumeList(mContext.getUserId(), 0); Loading