summaryrefslogtreecommitdiff
path: root/java/com/android/server/ethernet/EthernetNetworkFactory.java
diff options
context:
space:
mode:
authorErik Kline <ek@google.com>2016-02-22 11:11:38 +0900
committerErik Kline <ek@google.com>2016-02-22 17:41:12 +0900
commit5b4baf7330e22b93fd32a44824b27f43e4f2a549 (patch)
tree76a9629b56c3259cc81b768c883a728ccdce6e79 /java/com/android/server/ethernet/EthernetNetworkFactory.java
parent5972bfdf382db384946ba10a8caf2a04270fef43 (diff)
downloadethernet-5b4baf7330e22b93fd32a44824b27f43e4f2a549.tar.gz
Use more IpManager features
- WaitForProvisioningCallback - setHttpProxy - setTcpBufferSizes Bug: 26991160 Change-Id: I5e02039a35006f0466fb40c43805f0443cd758c2
Diffstat (limited to 'java/com/android/server/ethernet/EthernetNetworkFactory.java')
-rw-r--r--java/com/android/server/ethernet/EthernetNetworkFactory.java71
1 files changed, 27 insertions, 44 deletions
diff --git a/java/com/android/server/ethernet/EthernetNetworkFactory.java b/java/com/android/server/ethernet/EthernetNetworkFactory.java
index 3c230fb..7186863 100644
--- a/java/com/android/server/ethernet/EthernetNetworkFactory.java
+++ b/java/com/android/server/ethernet/EthernetNetworkFactory.java
@@ -33,6 +33,7 @@ import android.net.NetworkInfo;
import android.net.NetworkInfo.DetailedState;
import android.net.StaticIpConfiguration;
import android.net.ip.IpManager;
+import android.net.ip.IpManager.WaitForProvisioningCallback;
import android.os.Handler;
import android.os.IBinder;
import android.os.INetworkManagementService;
@@ -274,36 +275,6 @@ class EthernetNetworkFactory {
}
}
- private class IpManagerCallback extends IpManager.Callback {
- private LinkProperties mCallbackLinkProperties;
-
- public LinkProperties waitForProvisioning() {
- synchronized (this) {
- try {
- wait();
- } catch (InterruptedException e) {}
- return mCallbackLinkProperties;
- }
- }
-
- @Override
- public void onProvisioningSuccess(LinkProperties newLp) {
- synchronized (this) {
- mCallbackLinkProperties = newLp;
- notify();
- }
- }
-
- @Override
- public void onProvisioningFailure(LinkProperties newLp) {
- synchronized (this) {
- mCallbackLinkProperties = null;
- notify();
- }
- }
- }
-
-
/* Called by the NetworkFactory on the handler thread. */
public void onRequestNetwork() {
synchronized(EthernetNetworkFactory.this) {
@@ -332,13 +303,36 @@ class EthernetNetworkFactory {
linkProperties = config.getStaticIpConfiguration().toLinkProperties(mIface);
} else {
mNetworkInfo.setDetailedState(DetailedState.OBTAINING_IPADDR, null, mHwAddr);
- IpManagerCallback blockingCallback = new IpManagerCallback();
+ WaitForProvisioningCallback ipmCallback = new WaitForProvisioningCallback() {
+ @Override
+ public void onLinkPropertiesChange(LinkProperties newLp) {
+ synchronized(EthernetNetworkFactory.this) {
+ if (mNetworkAgent != null && mNetworkInfo.isConnected()) {
+ mNetworkAgent.sendLinkProperties(newLp);
+ }
+ }
+ }
+ };
+
synchronized(EthernetNetworkFactory.this) {
stopIpManagerLocked();
- mIpManager = new IpManager(mContext, mIface, blockingCallback);
+ mIpManager = new IpManager(mContext, mIface, ipmCallback);
+
+ if (config.getProxySettings() == ProxySettings.STATIC ||
+ config.getProxySettings() == ProxySettings.PAC) {
+ mIpManager.setHttpProxy(config.getHttpProxy());
+ }
+
+ final String tcpBufferSizes = mContext.getResources().getString(
+ com.android.internal.R.string.config_ethernet_tcp_buffers);
+ if (!TextUtils.isEmpty(tcpBufferSizes)) {
+ mIpManager.setTcpBufferSizes(tcpBufferSizes);
+ }
+
mIpManager.startProvisioning();
}
- linkProperties = blockingCallback.waitForProvisioning();
+
+ linkProperties = ipmCallback.waitForProvisioning();
if (linkProperties == null) {
Log.e(TAG, "IP provisioning error");
// set our score lower than any network could go
@@ -351,17 +345,6 @@ class EthernetNetworkFactory {
}
}
- if (config.getProxySettings() == ProxySettings.STATIC ||
- config.getProxySettings() == ProxySettings.PAC) {
- linkProperties.setHttpProxy(config.getHttpProxy());
- }
-
- final String tcpBufferSizes = mContext.getResources().getString(
- com.android.internal.R.string.config_ethernet_tcp_buffers);
- if (!TextUtils.isEmpty(tcpBufferSizes)) {
- linkProperties.setTcpBufferSizes(tcpBufferSizes);
- }
-
synchronized(EthernetNetworkFactory.this) {
if (mNetworkAgent != null) {
Log.e(TAG, "Already have a NetworkAgent - aborting new request");