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

Commit 31acbce4 authored by Chalard Jean's avatar Chalard Jean
Browse files

[NS04.7] Reinstate a necessary change

NS04.5 removed a security that it shouldn't have. Reinstate it.

Bug: 167544279
Test: ConnectivityServiceTest
Change-Id: If614da813a96d1b50a16fa4be5659e1647d9469d
parent f4315edf
Loading
Loading
Loading
Loading
+14 −1
Original line number Diff line number Diff line
@@ -6467,6 +6467,13 @@ public class ConnectivityService extends IConnectivityManager.Stub
        }
    }

    private boolean isNetworkProviderWithIdRegistered(final int providerId) {
        for (final NetworkProviderInfo npi : mNetworkProviderInfos.values()) {
            if (npi.providerId == providerId) return true;
        }
        return false;
    }

    /**
     * Register or update a network offer.
     * @param newOffer The new offer. If the callback member is the same as an existing
@@ -6474,7 +6481,13 @@ public class ConnectivityService extends IConnectivityManager.Stub
     */
    private void handleRegisterNetworkOffer(@NonNull final NetworkOffer newOffer) {
        ensureRunningOnConnectivityServiceThread();

        if (!isNetworkProviderWithIdRegistered(newOffer.providerId)) {
            // This may actually happen if a provider updates its score or registers and then
            // immediately unregisters. The offer would still be in the handler queue, but the
            // provider would have been removed.
            if (DBG) log("Received offer from an unregistered provider");
            return;
        }
        final NetworkOfferInfo existingOffer = findNetworkOfferInfoByCallback(newOffer.callback);
        if (null != existingOffer) {
            handleUnregisterNetworkOffer(existingOffer);