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

Commit 50f8bbb9 authored by Paul McLean's avatar Paul McLean
Browse files

Catch IO Exception in UsbDevicesParser and don't add failed devices.

Note: This is related to bug 66988327, but NOT a fix for it.

Bug: 66988327
Test: Manual
Change-Id: Ib9ccaa9634c7fc011f70513d5589870e9190418a
parent 592a1e30
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -258,7 +258,7 @@ public class AlsaDevicesParser {
        return line.charAt(kIndex_CardDeviceField) == '[';
    }

    public void scan() {
    public boolean scan() {
        mDeviceRecords.clear();

        File devicesFile = new File(kDevicesFilePath);
@@ -274,11 +274,13 @@ public class AlsaDevicesParser {
                }
            }
            reader.close();
            return true;
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return false;
    }

    //
+5 −1
Original line number Diff line number Diff line
@@ -314,7 +314,11 @@ public final class UsbAlsaManager {
            return null;
        }

        mDevicesParser.scan();
        if (!mDevicesParser.scan()) {
            Slog.e(TAG, "Error parsing ALSA devices file.");
            return null;
        }

        int device = mDevicesParser.getDefaultDeviceNum(card);

        boolean hasPlayback = mDevicesParser.hasPlaybackDevices(card);