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

Commit 0f684fec authored by Pawit Pornkitprasan's avatar Pawit Pornkitprasan
Browse files

Make "SD Card removed" notification dismissible if the removed SD Card is not the primary storage

The Galaxy S uses the "external SD Card" as the extended storage
and it the notification should be dismissible as it's okay not
to have it.

Additionally, this patch also not hide the USB storage mount dialog
if the removed storage is not the primary storage

Change-Id: I524b294c57ba80f19cf1af808af65ce1308f5a0b
parent 2567573b
Loading
Loading
Loading
Loading
+8 −6
Original line number Diff line number Diff line
@@ -126,8 +126,9 @@ public class StorageNotification extends StorageEventListener {
    }

    private void onStorageStateChangedAsync(String path, String oldState, String newState) {
        boolean isPrimary = Environment.getExternalStorageDirectory().getPath().equals(path);
        Slog.i(TAG, String.format(
                "Media {%s} state changed from {%s} -> {%s}", path, oldState, newState));
                "Media {%s} state changed from {%s} -> {%s} (primary = %b)", path, oldState, newState, isPrimary));
        if (newState.equals(Environment.MEDIA_SHARED)) {
            /*
             * Storage is now shared. Modify the UMS notification
@@ -227,25 +228,25 @@ public class StorageNotification extends StorageEventListener {
        } else if (newState.equals(Environment.MEDIA_REMOVED)) {
            /*
             * Storage has been removed. Show nomedia media notification,
             * and disable UMS notification regardless of connection state.
             * and disable UMS notification if the removed storage is the primary storage.
             */
            setMediaStorageNotification(
                    com.android.internal.R.string.ext_media_nomedia_notification_title,
                    com.android.internal.R.string.ext_media_nomedia_notification_message,
                    com.android.internal.R.drawable.stat_notify_sdcard_usb,
                    true, false, null);
            updateUsbMassStorageNotification(false);
                    true, !isPrimary, null);
            updateUsbMassStorageNotification(isPrimary ? false : mUmsAvailable);
        } else if (newState.equals(Environment.MEDIA_BAD_REMOVAL)) {
            /*
             * Storage has been removed unsafely. Show bad removal media notification,
             * and disable UMS notification regardless of connection state.
             * and disable UMS notification if the removed storage is the primary storage.
             */
            setMediaStorageNotification(
                    com.android.internal.R.string.ext_media_badremoval_notification_title,
                    com.android.internal.R.string.ext_media_badremoval_notification_message,
                    com.android.internal.R.drawable.stat_sys_warning,
                    true, true, null);
            updateUsbMassStorageNotification(false);
            updateUsbMassStorageNotification(isPrimary ? false : mUmsAvailable);
        } else {
            Slog.w(TAG, String.format("Ignoring unknown state {%s}", newState));
        }
@@ -412,4 +413,5 @@ public class StorageNotification extends StorageEventListener {
            notificationManager.cancel(notificationId);
        }
    }

}