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

Commit a66a3b9b authored by bohu's avatar bohu Committed by android-build-merger
Browse files

Merge "Ensure Netd Service is alive" into nyc-dev am: d521a6d1 am: 9549841e

am: a2ca55ec

* commit 'a2ca55ec':
  Ensure Netd Service is alive

Change-Id: I8c527b272fbed77f3aa7858eadd50e9c72da972d
parents afa8fe67 a2ca55ec
Loading
Loading
Loading
Loading
+13 −5
Original line number Diff line number Diff line
@@ -330,6 +330,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub
        if (DBG) Slog.d(TAG, "Awaiting socket connection");
        connectedSignal.await();
        if (DBG) Slog.d(TAG, "Connected");
        service.connectNativeNetdService();
        return service;
    }

@@ -560,11 +561,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub
        }
    }

    /**
     * Prepare native daemon once connected, enabling modules and pushing any
     * existing in-memory rules.
     */
    private void prepareNativeDaemon() {
    private void connectNativeNetdService() {
        boolean nativeServiceAvailable = false;
        try {
            mNetdService = INetd.Stub.asInterface(ServiceManager.getService(NETD_SERVICE_NAME));
@@ -573,6 +570,13 @@ public class NetworkManagementService extends INetworkManagementService.Stub
        if (!nativeServiceAvailable) {
            Slog.wtf(TAG, "Can't connect to NativeNetdService " + NETD_SERVICE_NAME);
        }
    }

    /**
     * Prepare native daemon once connected, enabling modules and pushing any
     * existing in-memory rules.
     */
    private void prepareNativeDaemon() {

        mBandwidthControlEnabled = false;

@@ -767,12 +771,16 @@ public class NetworkManagementService extends INetworkManagementService.Stub
            // event is dispatched from internal NDC thread, so we prepare the
            // daemon back on main thread.
            if (mConnectedSignal != null) {
                // The system is booting and we're connecting to netd for the first time.
                mConnectedSignal.countDown();
                mConnectedSignal = null;
            } else {
                // We're reconnecting to netd after the socket connection
                // was interrupted (e.g., if it crashed).
                mFgHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        connectNativeNetdService();
                        prepareNativeDaemon();
                    }
                });