Merge "IpManager: add distinct DhcpActionTimeoutAlarm" into nyc-dev
am: 42c9a1d
* commit '42c9a1d07adec44ae4c7eadafdb644f9bac9978b':
IpManager: add distinct DhcpActionTimeoutAlarm
Change-Id: I5bc7c6c96b33f4be7806fadadbd0a122028dc97b
This commit is contained in:
@@ -282,7 +282,12 @@ public class IpManager extends StateMachine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Builder withPreDhcpAction() {
|
public Builder withPreDhcpAction() {
|
||||||
mConfig.mRequestedPreDhcpAction = true;
|
mConfig.mRequestedPreDhcpActionMs = DEFAULT_TIMEOUT_MS;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder withPreDhcpAction(int dhcpActionTimeoutMs) {
|
||||||
|
mConfig.mRequestedPreDhcpActionMs = dhcpActionTimeoutMs;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -307,7 +312,7 @@ public class IpManager extends StateMachine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* package */ boolean mUsingIpReachabilityMonitor = true;
|
/* package */ boolean mUsingIpReachabilityMonitor = true;
|
||||||
/* package */ boolean mRequestedPreDhcpAction;
|
/* package */ int mRequestedPreDhcpActionMs;
|
||||||
/* package */ StaticIpConfiguration mStaticIpConfig;
|
/* package */ StaticIpConfiguration mStaticIpConfig;
|
||||||
/* package */ ApfCapabilities mApfCapabilities;
|
/* package */ ApfCapabilities mApfCapabilities;
|
||||||
/* package */ int mProvisioningTimeoutMs = DEFAULT_TIMEOUT_MS;
|
/* package */ int mProvisioningTimeoutMs = DEFAULT_TIMEOUT_MS;
|
||||||
@@ -316,7 +321,7 @@ public class IpManager extends StateMachine {
|
|||||||
|
|
||||||
public ProvisioningConfiguration(ProvisioningConfiguration other) {
|
public ProvisioningConfiguration(ProvisioningConfiguration other) {
|
||||||
mUsingIpReachabilityMonitor = other.mUsingIpReachabilityMonitor;
|
mUsingIpReachabilityMonitor = other.mUsingIpReachabilityMonitor;
|
||||||
mRequestedPreDhcpAction = other.mRequestedPreDhcpAction;
|
mRequestedPreDhcpActionMs = other.mRequestedPreDhcpActionMs;
|
||||||
mStaticIpConfig = other.mStaticIpConfig;
|
mStaticIpConfig = other.mStaticIpConfig;
|
||||||
mApfCapabilities = other.mApfCapabilities;
|
mApfCapabilities = other.mApfCapabilities;
|
||||||
mProvisioningTimeoutMs = other.mProvisioningTimeoutMs;
|
mProvisioningTimeoutMs = other.mProvisioningTimeoutMs;
|
||||||
@@ -326,7 +331,7 @@ public class IpManager extends StateMachine {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
return new StringJoiner(", ", getClass().getSimpleName() + "{", "}")
|
return new StringJoiner(", ", getClass().getSimpleName() + "{", "}")
|
||||||
.add("mUsingIpReachabilityMonitor: " + mUsingIpReachabilityMonitor)
|
.add("mUsingIpReachabilityMonitor: " + mUsingIpReachabilityMonitor)
|
||||||
.add("mRequestedPreDhcpAction: " + mRequestedPreDhcpAction)
|
.add("mRequestedPreDhcpActionMs: " + mRequestedPreDhcpActionMs)
|
||||||
.add("mStaticIpConfig: " + mStaticIpConfig)
|
.add("mStaticIpConfig: " + mStaticIpConfig)
|
||||||
.add("mApfCapabilities: " + mApfCapabilities)
|
.add("mApfCapabilities: " + mApfCapabilities)
|
||||||
.add("mProvisioningTimeoutMs: " + mProvisioningTimeoutMs)
|
.add("mProvisioningTimeoutMs: " + mProvisioningTimeoutMs)
|
||||||
@@ -346,6 +351,7 @@ public class IpManager extends StateMachine {
|
|||||||
private static final int CMD_UPDATE_HTTP_PROXY = 7;
|
private static final int CMD_UPDATE_HTTP_PROXY = 7;
|
||||||
private static final int CMD_SET_MULTICAST_FILTER = 8;
|
private static final int CMD_SET_MULTICAST_FILTER = 8;
|
||||||
private static final int EVENT_PROVISIONING_TIMEOUT = 9;
|
private static final int EVENT_PROVISIONING_TIMEOUT = 9;
|
||||||
|
private static final int EVENT_DHCPACTION_TIMEOUT = 10;
|
||||||
|
|
||||||
private static final int MAX_LOG_RECORDS = 500;
|
private static final int MAX_LOG_RECORDS = 500;
|
||||||
|
|
||||||
@@ -369,6 +375,7 @@ public class IpManager extends StateMachine {
|
|||||||
private final INetworkManagementService mNwService;
|
private final INetworkManagementService mNwService;
|
||||||
private final NetlinkTracker mNetlinkTracker;
|
private final NetlinkTracker mNetlinkTracker;
|
||||||
private final WakeupMessage mProvisioningTimeoutAlarm;
|
private final WakeupMessage mProvisioningTimeoutAlarm;
|
||||||
|
private final WakeupMessage mDhcpActionTimeoutAlarm;
|
||||||
private final LocalLog mLocalLog;
|
private final LocalLog mLocalLog;
|
||||||
|
|
||||||
private NetworkInterface mNetworkInterface;
|
private NetworkInterface mNetworkInterface;
|
||||||
@@ -445,6 +452,8 @@ public class IpManager extends StateMachine {
|
|||||||
|
|
||||||
mProvisioningTimeoutAlarm = new WakeupMessage(mContext, getHandler(),
|
mProvisioningTimeoutAlarm = new WakeupMessage(mContext, getHandler(),
|
||||||
mTag + ".EVENT_PROVISIONING_TIMEOUT", EVENT_PROVISIONING_TIMEOUT);
|
mTag + ".EVENT_PROVISIONING_TIMEOUT", EVENT_PROVISIONING_TIMEOUT);
|
||||||
|
mDhcpActionTimeoutAlarm = new WakeupMessage(mContext, getHandler(),
|
||||||
|
mTag + ".EVENT_DHCPACTION_TIMEOUT", EVENT_DHCPACTION_TIMEOUT);
|
||||||
|
|
||||||
// Super simple StateMachine.
|
// Super simple StateMachine.
|
||||||
addState(mStoppedState);
|
addState(mStoppedState);
|
||||||
@@ -1023,6 +1032,7 @@ public class IpManager extends StateMachine {
|
|||||||
@Override
|
@Override
|
||||||
public void exit() {
|
public void exit() {
|
||||||
mProvisioningTimeoutAlarm.cancel();
|
mProvisioningTimeoutAlarm.cancel();
|
||||||
|
mDhcpActionTimeoutAlarm.cancel();
|
||||||
|
|
||||||
if (mIpReachabilityMonitor != null) {
|
if (mIpReachabilityMonitor != null) {
|
||||||
mIpReachabilityMonitor.stop();
|
mIpReachabilityMonitor.stop();
|
||||||
@@ -1042,6 +1052,18 @@ public class IpManager extends StateMachine {
|
|||||||
resetLinkProperties();
|
resetLinkProperties();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void startDhcpAction() {
|
||||||
|
mCallback.onPreDhcpAction();
|
||||||
|
final long alarmTime = SystemClock.elapsedRealtime() +
|
||||||
|
mConfiguration.mRequestedPreDhcpActionMs;
|
||||||
|
mDhcpActionTimeoutAlarm.schedule(alarmTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void stopDhcpAction() {
|
||||||
|
mDhcpActionTimeoutAlarm.cancel();
|
||||||
|
mCallback.onPostDhcpAction();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean processMessage(Message msg) {
|
public boolean processMessage(Message msg) {
|
||||||
switch (msg.what) {
|
switch (msg.what) {
|
||||||
@@ -1104,10 +1126,14 @@ public class IpManager extends StateMachine {
|
|||||||
handleProvisioningFailure();
|
handleProvisioningFailure();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case EVENT_DHCPACTION_TIMEOUT:
|
||||||
|
stopDhcpAction();
|
||||||
|
break;
|
||||||
|
|
||||||
case DhcpClient.CMD_PRE_DHCP_ACTION:
|
case DhcpClient.CMD_PRE_DHCP_ACTION:
|
||||||
if (VDBG) { Log.d(mTag, "onPreDhcpAction()"); }
|
if (VDBG) { Log.d(mTag, "onPreDhcpAction()"); }
|
||||||
if (mConfiguration.mRequestedPreDhcpAction) {
|
if (mConfiguration.mRequestedPreDhcpActionMs > 0) {
|
||||||
mCallback.onPreDhcpAction();
|
startDhcpAction();
|
||||||
} else {
|
} else {
|
||||||
sendMessage(EVENT_PRE_DHCP_ACTION_COMPLETE);
|
sendMessage(EVENT_PRE_DHCP_ACTION_COMPLETE);
|
||||||
}
|
}
|
||||||
@@ -1123,17 +1149,23 @@ public class IpManager extends StateMachine {
|
|||||||
mDhcpClient.sendMessage(DhcpClient.EVENT_LINKADDRESS_CONFIGURED);
|
mDhcpClient.sendMessage(DhcpClient.EVENT_LINKADDRESS_CONFIGURED);
|
||||||
} else {
|
} else {
|
||||||
Log.e(mTag, "Failed to set IPv4 address!");
|
Log.e(mTag, "Failed to set IPv4 address!");
|
||||||
|
dispatchCallback(ProvisioningChange.LOST_PROVISIONING,
|
||||||
|
new LinkProperties(mLinkProperties));
|
||||||
transitionTo(mStoppingState);
|
transitionTo(mStoppingState);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This message is only received when:
|
||||||
|
//
|
||||||
|
// a) initial address acquisition succeeds,
|
||||||
|
// b) renew succeeds,
|
||||||
|
// c) renew fails,
|
||||||
|
//
|
||||||
|
// but never when initial address acquisition fails. The latter
|
||||||
|
// condition is now governed by the provisioning timeout.
|
||||||
case DhcpClient.CMD_POST_DHCP_ACTION: {
|
case DhcpClient.CMD_POST_DHCP_ACTION: {
|
||||||
// Note that onPostDhcpAction() is likely to be
|
stopDhcpAction();
|
||||||
// asynchronous, and thus there is no guarantee that we
|
|
||||||
// will be able to observe any of its effects here.
|
|
||||||
if (VDBG) { Log.d(mTag, "onPostDhcpAction()"); }
|
|
||||||
mCallback.onPostDhcpAction();
|
|
||||||
|
|
||||||
final DhcpResults dhcpResults = (DhcpResults) msg.obj;
|
final DhcpResults dhcpResults = (DhcpResults) msg.obj;
|
||||||
switch (msg.arg1) {
|
switch (msg.arg1) {
|
||||||
|
|||||||
Reference in New Issue
Block a user