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

Commit 49db8535 authored by David 'Digit' Turner's avatar David 'Digit' Turner
Browse files

UsbService: Remove stack-trace message during boot.

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: I126b7f05c9648e39a060eb0974cc6f4ac7533791
parent 73fddbae
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);
@@ -154,10 +157,12 @@ class UsbService {
            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();