Merge "Skip MTP launch notification for devices having FEATURE_AUTOMOTIVE." into nyc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
05133ad090
@@ -24,6 +24,7 @@ import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Resources;
|
||||
import android.hardware.usb.UsbConstants;
|
||||
import android.hardware.usb.UsbDevice;
|
||||
@@ -101,8 +102,8 @@ class MtpNotificationManager {
|
||||
TAG, device.getDeviceId(), notification);
|
||||
}
|
||||
|
||||
void hideNotification(UsbDevice device) {
|
||||
mContext.getSystemService(NotificationManager.class).cancel(TAG, device.getDeviceId());
|
||||
void hideNotification(int deviceId) {
|
||||
mContext.getSystemService(NotificationManager.class).cancel(TAG, deviceId);
|
||||
}
|
||||
|
||||
private class Receiver extends BroadcastReceiver {
|
||||
@@ -121,7 +122,13 @@ class MtpNotificationManager {
|
||||
}
|
||||
}
|
||||
|
||||
static boolean isMtpDevice(UsbDevice device) {
|
||||
static boolean shouldShowNotification(PackageManager packageManager, UsbDevice device) {
|
||||
// We don't show MTP notification for devices that has FEATURE_AUTOMOTIVE.
|
||||
return !packageManager.hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE) &&
|
||||
isMtpDevice(device);
|
||||
}
|
||||
|
||||
private static boolean isMtpDevice(UsbDevice device) {
|
||||
for (int i = 0; i < device.getInterfaceCount(); i++) {
|
||||
final UsbInterface usbInterface = device.getInterface(i);
|
||||
if ((usbInterface.getInterfaceClass() == UsbConstants.USB_CLASS_STILL_IMAGE &&
|
||||
|
||||
@@ -738,7 +738,7 @@ class UsbSettingsManager {
|
||||
// Send broadcast to running activity with registered intent
|
||||
mUserContext.sendBroadcast(intent);
|
||||
|
||||
if (MtpNotificationManager.isMtpDevice(device)) {
|
||||
if (MtpNotificationManager.shouldShowNotification(mPackageManager, device)) {
|
||||
// Show notification if the device is MTP storage.
|
||||
mMtpNotificationManager.showNotification(device);
|
||||
} else {
|
||||
@@ -769,9 +769,7 @@ class UsbSettingsManager {
|
||||
if (DEBUG) Slog.d(TAG, "usbDeviceRemoved, sending " + intent);
|
||||
mContext.sendBroadcastAsUser(intent, UserHandle.ALL);
|
||||
|
||||
if (MtpNotificationManager.isMtpDevice(device)) {
|
||||
mMtpNotificationManager.hideNotification(device);
|
||||
}
|
||||
mMtpNotificationManager.hideNotification(device.getDeviceId());
|
||||
}
|
||||
|
||||
public void accessoryAttached(UsbAccessory accessory) {
|
||||
|
||||
Reference in New Issue
Block a user