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

Commit 9ded26e2 authored by Lorenzo Colitti's avatar Lorenzo Colitti
Browse files

Delete the NetworkFactory running-on-correct-thread assertion.

The change to make NetworkFactory use NetworkProvider included an
assertion that the onNetworkRequested and onRequestWithdrawn
methods were called on the factory's Looper.

This is not really necessary since it cannot happen in the
current code unless there is a bug in Looper. It also makes it
impossible to test this code using TestLooper, which dispatches
messages on the test thread instead of on the looper thread.

So, delete the check.

Bug: 138306002
Test: atest FrameworksWifiTests now passes
Change-Id: I37449efb50287c683312f0b19909bd4c61b38585
parent 89a7c628
Loading
Loading
Loading
Loading
+0 −9
Original line number Diff line number Diff line
@@ -146,13 +146,6 @@ public class NetworkFactory extends Handler {
        mCapabilityFilter = filter;
    }

    private void assertOnLooperThread(Looper looper) {
        if (Thread.currentThread().getId() != looper.getThread().getId()) {
            throw new AssertionError("Unexpected thread: "
                    + Thread.currentThread().getId() + " != " + looper.getThread().getId());
        }
    }

    public void register() {
        if (mProvider != null) {
            Log.e(LOG_TAG, "Ignoring attempt to register already-registered NetworkFactory");
@@ -164,13 +157,11 @@ public class NetworkFactory extends Handler {
            @Override
            public void onNetworkRequested(@NonNull NetworkRequest request, int score,
                    int servingFactoryProviderId) {
                assertOnLooperThread(getLooper());
                handleAddRequest((NetworkRequest) request, score, servingFactoryProviderId);
            }

            @Override
            public void onRequestWithdrawn(@NonNull NetworkRequest request) {
                assertOnLooperThread(getLooper());
                handleRemoveRequest(request);
            }
        };