Skip to content

Commit 2ce9ebb

Browse files
pawitpWhitehawkx
authored andcommitted
Make "SD Card removed" notification dismissible if the removed SD Card is not the primary storage
Change-Id: I1e3aa0964e7b5652a61d4dd9ed6dde313efd3fd1 Signed-off-by: kecinzer <kecinzer@gmail.com>
1 parent 4f16efd commit 2ce9ebb

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,9 @@ public void run() {
127127
}
128128

129129
private void onStorageStateChangedAsync(String path, String oldState, String newState) {
130+
boolean isPrimary = mStorageManager.getPrimaryVolume().getPath().equals(path);
130131
Slog.i(TAG, String.format(
131-
"Media {%s} state changed from {%s} -> {%s}", path, oldState, newState));
132+
"Media {%s} state changed from {%s} -> {%s} (primary = %b)", path, oldState, newState, isPrimary));
132133
if (newState.equals(Environment.MEDIA_SHARED)) {
133134
/*
134135
* Storage is now shared. Modify the UMS notification
@@ -228,25 +229,25 @@ private void onStorageStateChangedAsync(String path, String oldState, String new
228229
} else if (newState.equals(Environment.MEDIA_REMOVED)) {
229230
/*
230231
* Storage has been removed. Show nomedia media notification,
231-
* and disable UMS notification regardless of connection state.
232+
* and disable UMS notification if the removed storage is the primary storage.
232233
*/
233234
setMediaStorageNotification(
234235
com.android.internal.R.string.ext_media_nomedia_notification_title,
235236
com.android.internal.R.string.ext_media_nomedia_notification_message,
236237
com.android.internal.R.drawable.stat_notify_sdcard_usb,
237-
true, false, null);
238-
updateUsbMassStorageNotification(false);
238+
true, !isPrimary, null);
239+
updateUsbMassStorageNotification(isPrimary ? false : mUmsAvailable);
239240
} else if (newState.equals(Environment.MEDIA_BAD_REMOVAL)) {
240241
/*
241242
* Storage has been removed unsafely. Show bad removal media notification,
242-
* and disable UMS notification regardless of connection state.
243+
* and disable UMS notification if the removed storage is the primary storage.
243244
*/
244245
setMediaStorageNotification(
245246
com.android.internal.R.string.ext_media_badremoval_notification_title,
246247
com.android.internal.R.string.ext_media_badremoval_notification_message,
247248
com.android.internal.R.drawable.stat_sys_warning,
248249
true, true, null);
249-
updateUsbMassStorageNotification(false);
250+
updateUsbMassStorageNotification(isPrimary ? false : mUmsAvailable);
250251
} else {
251252
Slog.w(TAG, String.format("Ignoring unknown state {%s}", newState));
252253
}

0 commit comments

Comments
 (0)