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

Commit 33d8e5cc authored by Erik Kline's avatar Erik Kline
Browse files

change NMS removeNetwork to netd binder variant

Also: require NETWORK_STACK instead of CONNECTIVITY_INTERNAL.

Bug: 34953048
Bug: 64133961
Test: as follows
    - built
    - flashed
    - booted
    - runtest frameworks-net
Change-Id: I26f07f51a8a2f4a8bb43a276da7c5e66c355c848
parent 4418418a
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -2472,6 +2472,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
    private void handleRemoveNetworkRequest(final NetworkRequestInfo nri) {
        nri.unlinkDeathRecipient();
        mNetworkRequests.remove(nri.request);

        synchronized (mUidToNetworkRequestCount) {
            int requests = mUidToNetworkRequestCount.get(nri.mUid, 0);
            if (requests < 1) {
@@ -2484,6 +2485,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
                mUidToNetworkRequestCount.put(nri.mUid, requests - 1);
            }
        }

        mNetworkRequestInfoLogs.log("RELEASE " + nri);
        if (nri.request.isRequest()) {
            boolean wasKept = false;
+8 −4
Original line number Diff line number Diff line
@@ -2508,12 +2508,16 @@ public class NetworkManagementService extends INetworkManagementService.Stub

    @Override
    public void removeNetwork(int netId) {
        mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG);
        mContext.enforceCallingOrSelfPermission(NETWORK_STACK, TAG);

        try {
            mConnector.execute("network", "destroy", netId);
        } catch (NativeDaemonConnectorException e) {
            throw e.rethrowAsParcelableException();
            mNetdService.networkDestroy(netId);
        } catch (ServiceSpecificException e) {
            Log.w(TAG, "removeNetwork(" + netId + "): ", e);
            throw e;
        } catch (RemoteException e) {
            Log.w(TAG, "removeNetwork(" + netId + "): ", e);
            throw e.rethrowAsRuntimeException();
        }
    }