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

Commit 1a7408cd authored by David 'Digit' Turner's avatar David 'Digit' Turner Committed by Mike Lockwood
Browse files

UsbService: Remove stack-trace message during boot. DO NOT MERGE

This removes a stack trace message during the boot under emulation.

The observers tried to access a null reference when no USB configuration
is supported by the emulated device. So do not start them in this case.

+ Change a Slog.w into a Slog.i since this is an acceptable condition.

Change-Id: I801f352574716d7868f182bb6e5ee49e5b12e4f1
parent f13ec7a3
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -134,14 +134,17 @@ class UsbService {
        mContext = context;
        init();  // set initial status

        if (mConfiguration >= 0) {
            mUEventObserver.startObserving(USB_CONNECTED_MATCH);
            mUEventObserver.startObserving(USB_CONFIGURATION_MATCH);
            mUEventObserver.startObserving(USB_FUNCTIONS_MATCH);
        }
    }

    private final void init() {
        char[] buffer = new char[1024];

        mConfiguration = -1;
        try {
            FileReader file = new FileReader(USB_CONNECTED_PATH);
            int len = file.read(buffer, 0, 1024);
@@ -153,10 +156,12 @@ class UsbService {
            file.close();
            mConfiguration = Integer.valueOf((new String(buffer, 0, len)).trim());
        } catch (FileNotFoundException e) {
            Slog.w(TAG, "This kernel does not have USB configuration switch support");
            Slog.i(TAG, "This kernel does not have USB configuration switch support");
        } catch (Exception e) {
            Slog.e(TAG, "" , e);
        }
        if (mConfiguration < 0)
            return;

        try {
            File[] files = new File(USB_COMPOSITE_CLASS_PATH).listFiles();