Add auto-restore timeout for secondary networks.

Settable per network so you can have not timeout for some and some for others.
If you set the old NETWORK_RESTORE_DELAY_PROP_NAME system property
(android.telephony.apn-restore) it will override this value.

Change-Id: Icca706fdc74245dce679209116660e5dc4b05d23
This commit is contained in:
Robert Greenwalt
2011-05-03 19:02:44 -07:00
parent 2240524be9
commit 20f819c64b
2 changed files with 24 additions and 5 deletions

View File

@@ -49,6 +49,13 @@ public class NetworkConfig {
*/
public boolean dependencyMet;
/**
* indicates the default restoral timer in seconds
* if the network is used as a special network feature
* -1 indicates no restoration of default
*/
public int restoreTime;
/**
* input string from config.xml resource. Uses the form:
* [Connection name],[ConnectivityManager connection type],
@@ -60,7 +67,8 @@ public class NetworkConfig {
type = Integer.parseInt(fragments[1]);
radio = Integer.parseInt(fragments[2]);
priority = Integer.parseInt(fragments[3]);
dependencyMet = Boolean.parseBoolean(fragments[4]);
restoreTime = Integer.parseInt(fragments[4]);
dependencyMet = Boolean.parseBoolean(fragments[5]);
}
/**

View File

@@ -718,9 +718,13 @@ public class ConnectivityService extends IConnectivityManager.Stub {
mNetRequestersPids[usedNetworkType].add(currentPid);
}
}
mHandler.sendMessageDelayed(mHandler.obtainMessage(EVENT_RESTORE_DEFAULT_NETWORK,
f), getRestoreDefaultNetworkDelay());
int restoreTimer = getRestoreDefaultNetworkDelay(usedNetworkType);
if (restoreTimer >= 0) {
mHandler.sendMessageDelayed(
mHandler.obtainMessage(EVENT_RESTORE_DEFAULT_NETWORK, f), restoreTimer);
}
if ((ni.isConnectedOrConnecting() == true) &&
!network.isTeardownRequested()) {
@@ -1652,7 +1656,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
}
}
private int getRestoreDefaultNetworkDelay() {
private int getRestoreDefaultNetworkDelay(int networkType) {
String restoreDefaultNetworkDelayStr = SystemProperties.get(
NETWORK_RESTORE_DELAY_PROP_NAME);
if(restoreDefaultNetworkDelayStr != null &&
@@ -1662,7 +1666,14 @@ public class ConnectivityService extends IConnectivityManager.Stub {
} catch (NumberFormatException e) {
}
}
return RESTORE_DEFAULT_NETWORK_DELAY;
// if the system property isn't set, use the value for the apn type
int ret = RESTORE_DEFAULT_NETWORK_DELAY;
if ((networkType <= ConnectivityManager.MAX_NETWORK_TYPE) &&
(mNetConfigs[networkType] != null)) {
ret = mNetConfigs[networkType].restoreTime;
}
return ret;
}
@Override