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

Commit 74f6c03b authored by Patrick Scott's avatar Patrick Scott
Browse files

Set a flag that indicates a response is pending.

This will keep track of multiple calls to proceed/cancel. If an error has
occurred and the client calls proceed or cancel more than once, the loader may
be null. Set the flag during the callback and reset after a response.

Bug: 2371305
parent 79896bd1
Loading
Loading
Loading
Loading
+16 −2
Original line number Diff line number Diff line
@@ -51,6 +51,11 @@ public class SslErrorHandler extends Handler {
     */
    private Bundle mSslPrefTable;

    /**
     * Flag indicating that a client reponse is pending.
     */
    private boolean mResponsePending;

    // Message id for handling the response
    private static final int HANDLE_RESPONSE = 100;

@@ -191,6 +196,7 @@ public class SslErrorHandler extends Handler {
            // if we do not have information on record, ask
            // the user (display a dialog)
            CallbackProxy proxy = loader.getFrame().getCallbackProxy();
            mResponsePending = true;
            proxy.onReceivedSslError(this, error);
        }

@@ -202,7 +208,11 @@ public class SslErrorHandler extends Handler {
     * Proceed with the SSL certificate.
     */
    public void proceed() {
        sendMessage(obtainMessage(HANDLE_RESPONSE, 1, 0, mLoaderQueue.poll()));
        if (mResponsePending) {
            mResponsePending = false;
            sendMessage(obtainMessage(HANDLE_RESPONSE, 1, 0,
                        mLoaderQueue.poll()));
        }
    }

    /**
@@ -210,7 +220,11 @@ public class SslErrorHandler extends Handler {
     * the error.
     */
    public void cancel() {
        sendMessage(obtainMessage(HANDLE_RESPONSE, 0, 0, mLoaderQueue.poll()));
        if (mResponsePending) {
            mResponsePending = false;
            sendMessage(obtainMessage(HANDLE_RESPONSE, 0, 0,
                        mLoaderQueue.poll()));
        }
    }

    /**