Merge "Ensure Netd Service is alive" into nyc-dev am: d521a6d146
am: 9549841ec4
* commit '9549841ec488c21a848b240275c8af42deedb46e':
Ensure Netd Service is alive
Change-Id: Ic0f6f3cbe9ede4d6a9dfd3e0e8788a7a997db234
This commit is contained in:
@@ -330,6 +330,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub
|
|||||||
if (DBG) Slog.d(TAG, "Awaiting socket connection");
|
if (DBG) Slog.d(TAG, "Awaiting socket connection");
|
||||||
connectedSignal.await();
|
connectedSignal.await();
|
||||||
if (DBG) Slog.d(TAG, "Connected");
|
if (DBG) Slog.d(TAG, "Connected");
|
||||||
|
service.connectNativeNetdService();
|
||||||
return service;
|
return service;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -560,11 +561,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private void connectNativeNetdService() {
|
||||||
* Prepare native daemon once connected, enabling modules and pushing any
|
|
||||||
* existing in-memory rules.
|
|
||||||
*/
|
|
||||||
private void prepareNativeDaemon() {
|
|
||||||
boolean nativeServiceAvailable = false;
|
boolean nativeServiceAvailable = false;
|
||||||
try {
|
try {
|
||||||
mNetdService = INetd.Stub.asInterface(ServiceManager.getService(NETD_SERVICE_NAME));
|
mNetdService = INetd.Stub.asInterface(ServiceManager.getService(NETD_SERVICE_NAME));
|
||||||
@@ -573,6 +570,13 @@ public class NetworkManagementService extends INetworkManagementService.Stub
|
|||||||
if (!nativeServiceAvailable) {
|
if (!nativeServiceAvailable) {
|
||||||
Slog.wtf(TAG, "Can't connect to NativeNetdService " + NETD_SERVICE_NAME);
|
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;
|
mBandwidthControlEnabled = false;
|
||||||
|
|
||||||
@@ -767,12 +771,16 @@ public class NetworkManagementService extends INetworkManagementService.Stub
|
|||||||
// event is dispatched from internal NDC thread, so we prepare the
|
// event is dispatched from internal NDC thread, so we prepare the
|
||||||
// daemon back on main thread.
|
// daemon back on main thread.
|
||||||
if (mConnectedSignal != null) {
|
if (mConnectedSignal != null) {
|
||||||
|
// The system is booting and we're connecting to netd for the first time.
|
||||||
mConnectedSignal.countDown();
|
mConnectedSignal.countDown();
|
||||||
mConnectedSignal = null;
|
mConnectedSignal = null;
|
||||||
} else {
|
} else {
|
||||||
|
// We're reconnecting to netd after the socket connection
|
||||||
|
// was interrupted (e.g., if it crashed).
|
||||||
mFgHandler.post(new Runnable() {
|
mFgHandler.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
connectNativeNetdService();
|
||||||
prepareNativeDaemon();
|
prepareNativeDaemon();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user