From 75b230b1d5abb1089173392f294f7fc5ce00e56c Mon Sep 17 00:00:00 2001 From: "Philip P. Moltmann" Date: Mon, 11 Apr 2016 15:27:58 -0700 Subject: [PATCH] If a Disk goes away, remove the notifications that asks the user to format it. Fixes: 22091912 Change-Id: I78448427c5d2f02d61251e4d697931d0d4e5c517 --- .../android/systemui/usb/StorageNotification.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java b/packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java index 180d9180a9f7e..2c53e29620494 100644 --- a/packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java +++ b/packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java @@ -16,6 +16,7 @@ package com.android.systemui.usb; +import android.annotation.NonNull; import android.app.Notification; import android.app.Notification.Action; import android.app.NotificationManager; @@ -97,6 +98,11 @@ public class StorageNotification extends SystemUI { public void onDiskScanned(DiskInfo disk, int volumeCount) { onDiskScannedInternal(disk, volumeCount); } + + @Override + public void onDiskDestroyed(DiskInfo disk) { + onDiskDestroyedInternal(disk); + } }; private final BroadcastReceiver mSnoozeReceiver = new BroadcastReceiver() { @@ -238,6 +244,15 @@ public class StorageNotification extends SystemUI { } } + /** + * Remove all notifications for a disk when it goes away. + * + * @param disk The disk that went away. + */ + private void onDiskDestroyedInternal(@NonNull DiskInfo disk) { + mNotificationManager.cancelAsUser(disk.getId(), DISK_ID, UserHandle.ALL); + } + private void onVolumeStateChangedInternal(VolumeInfo vol) { switch (vol.getType()) { case VolumeInfo.TYPE_PRIVATE: