Merge "Always reevaluate whether to show the notification for USB_DEVICE_* intents" into oc-dr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
d5f442d65b
@@ -956,11 +956,6 @@ public class UsbDeviceManager {
|
|||||||
Slog.i(TAG, "HOST_STATE connected:" + connected);
|
Slog.i(TAG, "HOST_STATE connected:" + connected);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((mHideUsbNotification && connected)
|
|
||||||
|| (!mHideUsbNotification && !connected)) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
mHideUsbNotification = false;
|
mHideUsbNotification = false;
|
||||||
while (devices.hasNext()) {
|
while (devices.hasNext()) {
|
||||||
Map.Entry pair = (Map.Entry) devices.next();
|
Map.Entry pair = (Map.Entry) devices.next();
|
||||||
@@ -1061,12 +1056,22 @@ public class UsbDeviceManager {
|
|||||||
|
|
||||||
private void updateUsbNotification(boolean force) {
|
private void updateUsbNotification(boolean force) {
|
||||||
if (mNotificationManager == null || !mUseUsbNotification
|
if (mNotificationManager == null || !mUseUsbNotification
|
||||||
|| ("0".equals(SystemProperties.get("persist.charging.notify")))
|
|| ("0".equals(SystemProperties.get("persist.charging.notify")))) {
|
||||||
// Dont show the notification when connected to a USB peripheral
|
|
||||||
// and the link does not support PR_SWAP and DR_SWAP
|
|
||||||
|| (mHideUsbNotification && !mSupportsAllCombinations)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Dont show the notification when connected to a USB peripheral
|
||||||
|
// and the link does not support PR_SWAP and DR_SWAP
|
||||||
|
if (mHideUsbNotification && !mSupportsAllCombinations) {
|
||||||
|
if (mUsbNotificationId != 0) {
|
||||||
|
mNotificationManager.cancelAsUser(null, mUsbNotificationId,
|
||||||
|
UserHandle.ALL);
|
||||||
|
mUsbNotificationId = 0;
|
||||||
|
Slog.d(TAG, "Clear notification");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int id = 0;
|
int id = 0;
|
||||||
int titleRes = 0;
|
int titleRes = 0;
|
||||||
Resources r = mContext.getResources();
|
Resources r = mContext.getResources();
|
||||||
@@ -1117,6 +1122,7 @@ public class UsbDeviceManager {
|
|||||||
if (mUsbNotificationId != 0) {
|
if (mUsbNotificationId != 0) {
|
||||||
mNotificationManager.cancelAsUser(null, mUsbNotificationId,
|
mNotificationManager.cancelAsUser(null, mUsbNotificationId,
|
||||||
UserHandle.ALL);
|
UserHandle.ALL);
|
||||||
|
Slog.d(TAG, "Clear notification");
|
||||||
mUsbNotificationId = 0;
|
mUsbNotificationId = 0;
|
||||||
}
|
}
|
||||||
if (id != 0) {
|
if (id != 0) {
|
||||||
@@ -1173,6 +1179,7 @@ public class UsbDeviceManager {
|
|||||||
|
|
||||||
mNotificationManager.notifyAsUser(null, id, notification,
|
mNotificationManager.notifyAsUser(null, id, notification,
|
||||||
UserHandle.ALL);
|
UserHandle.ALL);
|
||||||
|
Slog.d(TAG, "push notification:" + title);
|
||||||
mUsbNotificationId = id;
|
mUsbNotificationId = id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user