Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 14888548 authored by Jeff Sharkey's avatar Jeff Sharkey Committed by The Android Automerger
Browse files

Push initial disk state, handle empty media.

Stash volume count from last scan, and use it to push initial storage
notifications state when listener is first attached.

Also omit disks with invalid size, which usually means they're an
empty slot with no media.

Bug: 20503551
Change-Id: I75097035aebaad70ba32437179a863f6a0910aa5
parent abdd61da
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -50,6 +50,8 @@ public class DiskInfo implements Parcelable {
    public final int flags;
    public long size;
    public String label;
    /** Hacky; don't rely on this count */
    public int volumeCount;

    public DiskInfo(String id, int flags) {
        this.id = Preconditions.checkNotNull(id);
@@ -61,6 +63,7 @@ public class DiskInfo implements Parcelable {
        flags = parcel.readInt();
        size = parcel.readLong();
        label = parcel.readString();
        volumeCount = parcel.readInt();
    }

    public @NonNull String getId() {
@@ -181,5 +184,6 @@ public class DiskInfo implements Parcelable {
        parcel.writeInt(this.flags);
        parcel.writeLong(size);
        parcel.writeString(label);
        parcel.writeInt(volumeCount);
    }
}
+6 −1
Original line number Diff line number Diff line
@@ -148,6 +148,11 @@ public class StorageNotification extends SystemUI {
                android.Manifest.permission.MOUNT_UNMOUNT_FILESYSTEMS, null);

        // Kick current state into place
        final List<DiskInfo> disks = mStorageManager.getDisks();
        for (DiskInfo disk : disks) {
            onDiskScannedInternal(disk, disk.volumeCount);
        }

        final List<VolumeInfo> vols = mStorageManager.getVolumes();
        for (VolumeInfo vol : vols) {
            onVolumeStateChangedInternal(vol);
@@ -194,7 +199,7 @@ public class StorageNotification extends SystemUI {
    }

    private void onDiskScannedInternal(DiskInfo disk, int volumeCount) {
        if (volumeCount == 0) {
        if (volumeCount == 0 && disk.size > 0) {
            // No supported volumes found, give user option to format
            final CharSequence title = mContext.getString(
                    R.string.ext_media_unmountable_notification_title, disk.getDescription());
+1 −0
Original line number Diff line number Diff line
@@ -973,6 +973,7 @@ class MountService extends IMountService.Stub
            }
        }

        disk.volumeCount = volumeCount;
        mCallbacks.notifyDiskScanned(disk, volumeCount);
    }