Skip to content

Commit

Permalink
Kill off USB notification sound.
Browse files Browse the repository at this point in the history
It's entirely pointless to alert the user by playing a sound on USB
connection, as he likely already knew he just plugged the cable.

Change-Id: I794615ab74a2c56ae8fc8ce7cae91182f92116f2
  • Loading branch information
maniac103 committed Apr 27, 2012
1 parent 36aac15 commit 86ca4d7
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions src/com/motorola/usb/UsbService.java
Expand Up @@ -373,6 +373,7 @@ public void onCreate() {
mNotification.icon = com.android.internal.R.drawable.stat_sys_data_usb;
mNotification.when = 0;
mNotification.flags = Notification.FLAG_ONGOING_EVENT;
mNotification.defaults &= ~Notification.DEFAULT_SOUND;

Intent intent = new Intent();
intent.setClass(this, UsbModeSelectionActivity.class);
Expand Down Expand Up @@ -453,7 +454,7 @@ private synchronized void handleUsbEvent(int event) {
if (mIsSwitchFrom != USB_SWITCH_FROM_IDLE) {
if (mIsSwitchFrom != USB_SWITCH_FROM_ADB) {
showConnectedToast(currentMode);
setUsbConnectionNotificationVisibility(true, false);
setUsbConnectionNotificationVisibility(true);
enableInternalDataConnectivity(currentMode != USB_MODE_MODEM);
}
emitReconfigurationIntent(true);
Expand Down Expand Up @@ -805,8 +806,7 @@ private String getUsbModeString(int mode) {
return info != null ? info.name : null;
}

private void setUsbConnectionNotificationVisibility(boolean visible, boolean forceDefaultSound)
{
private void setUsbConnectionNotificationVisibility(boolean visible) {
Log.d(TAG, "setUsbConnectionNotificationVisibility()");

if (mNotification == null) {
Expand All @@ -815,12 +815,6 @@ private void setUsbConnectionNotificationVisibility(boolean visible, boolean for
}

if (visible) {
if (forceDefaultSound) {
mNotification.defaults = mNotification.defaults | Notification.DEFAULT_SOUND;
} else {
mNotification.defaults = mNotification.defaults & ~Notification.DEFAULT_SOUND;
}

mNotification.tickerText = getString(R.string.usb_selection_notification_title);

int messageRes = getCurrentUsbMode() == USB_MODE_MODEM
Expand Down Expand Up @@ -953,7 +947,7 @@ public void handleGetDescriptor() {
mUsbCableAttached = true;

int currentMode = getCurrentUsbMode();
setUsbConnectionNotificationVisibility(true, true);
setUsbConnectionNotificationVisibility(true);
enableInternalDataConnectivity(currentMode != USB_MODE_MODEM);
sendBroadcast(new Intent(ACTION_CABLE_ATTACHED));
emitReconfigurationIntent(true);
Expand Down Expand Up @@ -997,7 +991,7 @@ public void handleUsbCableDetachment() {

if (mUsbCableAttached) {
mUsbCableAttached = false;
setUsbConnectionNotificationVisibility(false, false);
setUsbConnectionNotificationVisibility(false);
enableInternalDataConnectivity(true);
sendBroadcast(new Intent(ACTION_CABLE_DETACHED));
emitReconfigurationIntent(false);
Expand Down

0 comments on commit 86ca4d7

Please sign in to comment.