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

Commit 1cd94ef9 authored by Irfan Sheriff's avatar Irfan Sheriff
Browse files

Do not add unsolicited events to queue

Adding unsolicited events to response queue
results in doCommand() returning the wrong
result.

Pulling this change from master.

Bug: 3258529
Change-Id: I2a4b0bd8bb30b31682d7d61ee94a0d246bf10de2
parent b73203ab
Loading
Loading
Loading
Loading
+7 −5
Original line number Original line Diff line number Diff line
@@ -132,12 +132,13 @@ final class NativeDaemonConnector implements Runnable {
                                    Slog.e(TAG, String.format(
                                    Slog.e(TAG, String.format(
                                            "Error handling '%s'", event), ex);
                                            "Error handling '%s'", event), ex);
                                }
                                }
                            }
                            } else {
                                try {
                                try {
                                    mResponseQueue.put(event);
                                    mResponseQueue.put(event);
                                } catch (InterruptedException ex) {
                                } catch (InterruptedException ex) {
                                    Slog.e(TAG, "Failed to put response onto queue", ex);
                                    Slog.e(TAG, "Failed to put response onto queue", ex);
                                }
                                }
                            }
                        } catch (NumberFormatException nfe) {
                        } catch (NumberFormatException nfe) {
                            Slog.w(TAG, String.format("Bad msg (%s)", event));
                            Slog.w(TAG, String.format("Bad msg (%s)", event));
                        }
                        }
@@ -219,6 +220,7 @@ final class NativeDaemonConnector implements Runnable {
     */
     */
    public synchronized ArrayList<String> doCommand(String cmd)
    public synchronized ArrayList<String> doCommand(String cmd)
            throws NativeDaemonConnectorException  {
            throws NativeDaemonConnectorException  {
        mResponseQueue.clear();
        sendCommand(cmd);
        sendCommand(cmd);


        ArrayList<String> response = new ArrayList<String>();
        ArrayList<String> response = new ArrayList<String>();