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

Commit 930029fa authored by Pawit Pornkitprasan's avatar Pawit Pornkitprasan Committed by Gerrit Code Review
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

Adapted for JB 4.2

Change-Id: Ic752a3da917e0d7736a619fb68f07905106987fb
parent 416d7cbf
Loading
Loading
Loading
Loading
+7 −6
Original line number Diff line number Diff line
@@ -127,8 +127,9 @@ public class StorageNotification extends StorageEventListener {
    }

    private void onStorageStateChangedAsync(String path, String oldState, String newState) {
        boolean isPrimary = mStorageManager.getPrimaryVolume().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
@@ -228,25 +229,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));
        }