am 90e2301e: am d2a11d97: Merge "Add explicit close of Scanner input"

* commit '90e2301e23532c92dd4c24394b7407e243389e9f':
  Add explicit close of Scanner input
This commit is contained in:
Elliott Hughes
2014-04-11 17:21:20 +00:00
committed by Android Git Automerger

View File

@@ -594,14 +594,19 @@ public class UsbDeviceManager {
intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
intent.putExtra("state", (enabled ? 1 : 0));
if (enabled) {
Scanner scanner = null;
try {
Scanner scanner = new Scanner(new File(AUDIO_SOURCE_PCM_PATH));
scanner = new Scanner(new File(AUDIO_SOURCE_PCM_PATH));
int card = scanner.nextInt();
int device = scanner.nextInt();
intent.putExtra("card", card);
intent.putExtra("device", device);
} catch (FileNotFoundException e) {
Slog.e(TAG, "could not open audio source PCM file", e);
} finally {
if (scanner != null) {
scanner.close();
}
}
}
mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);