Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d2a11d97 authored by Elliott Hughes's avatar Elliott Hughes Committed by Gerrit Code Review
Browse files

Merge "Add explicit close of Scanner input"

parents 909a6a0e 2a39c6ff
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -573,14 +573,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);