Use fullScreenIntent to show the USB mass storage dialog.
Note that this is not a FLAG_HIGH_PRIORITY notification. In
immersive mode the UMS dialog will be suppressed entirely
(but an icon will still appear in the status bar).
Bug: 2821219
Change-Id: I21f910c8830aff8d0633deda4eb59dbda13262ed
diff --git a/packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java b/packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java
index f8abc5a..b9e915a4 100644
--- a/packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java
+++ b/packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java
@@ -244,27 +244,12 @@
intent.setClass(mContext, com.android.systemui.usb.UsbStorageActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- final boolean adbOn = 1 == Settings.Secure.getInt(
- mContext.getContentResolver(),
- Settings.Secure.ADB_ENABLED,
- 0);
-
PendingIntent pi = PendingIntent.getActivity(mContext, 0, intent, 0);
setUsbStorageNotification(
com.android.internal.R.string.usb_storage_notification_title,
com.android.internal.R.string.usb_storage_notification_message,
com.android.internal.R.drawable.stat_sys_data_usb,
false, true, pi);
-
- if (POP_UMS_ACTIVITY_ON_CONNECT && !adbOn) {
- // We assume that developers don't want to enable UMS every
- // time they attach a device to a USB host. The average user,
- // however, is looking to charge the phone (in which case this
- // is harmless) or transfer files (in which case this coaches
- // the user about how to complete that task and saves several
- // steps).
- mContext.startActivity(intent);
- }
} else {
setUsbStorageNotification(0, 0, 0, false, false, null);
}
@@ -313,6 +298,23 @@
}
mUsbStorageNotification.setLatestEventInfo(mContext, title, message, pi);
+ final boolean adbOn = 1 == Settings.Secure.getInt(
+ mContext.getContentResolver(),
+ Settings.Secure.ADB_ENABLED,
+ 0);
+
+ if (POP_UMS_ACTIVITY_ON_CONNECT && !adbOn) {
+ // Pop up a full-screen alert to coach the user through enabling UMS. The average
+ // user has attached the device to USB either to charge the phone (in which case
+ // this is harmless) or transfer files, and in the latter case this alert saves
+ // several steps (as well as subtly indicates that you shouldn't mix UMS with other
+ // activities on the device).
+ //
+ // If ADB is enabled, however, we suppress this dialog (under the assumption that a
+ // developer (a) knows how to enable UMS, and (b) is probably using USB to install
+ // builds or use adb commands.
+ mUsbStorageNotification.fullScreenIntent = pi;
+ }
}
final int notificationId = mUsbStorageNotification.icon;