Methods Summary |
---|
protected static java.lang.String[] | getNameServerList(java.lang.String[] propertyNames)Return the IP addresses of the DNS servers available for this
network interface.
String[] dnsAddresses = new String[propertyNames.length];
int i, j;
for (i = 0, j = 0; i < propertyNames.length; i++) {
String value = SystemProperties.get(propertyNames[i]);
// The GSM layer sometimes sets a bogus DNS server address of
// 0.0.0.0
if (!TextUtils.isEmpty(value) && !TextUtils.equals(value, "0.0.0.0")) {
dnsAddresses[j++] = value;
}
}
return dnsAddresses;
|
public abstract java.lang.String[] | getNameServers()Return the list of DNS servers associated with this network.
|
public NetworkInfo | getNetworkInfo()
return mNetworkInfo;
|
public abstract java.lang.String | getTcpBufferSizesPropName()Return the system properties name associated with the tcp buffer sizes
for this network.
|
public void | interpretScanResultsAvailable()Interprets scan results. This will be called at a safe time for
processing, and from a safe thread.
|
public abstract boolean | isAvailable()Returns an indication of whether this network is available for
connections. A value of {@code false} means that some quasi-permanent
condition prevents connectivity to this network.
|
public boolean | isTeardownRequested()
return mTeardownRequested;
|
public abstract boolean | reconnect()Reenable connectivity to a network after a {@link #teardown()}.
|
public void | releaseWakeLock()Release the wakelock, if any, that may be held while handling a
disconnect operation.
|
public boolean | requestRouteToHost(int hostAddress)Ensure that a network route exists to deliver traffic to the specified
host via this network interface.
return false;
|
protected void | sendScanResultsAvailable()Send a notification that the results of a scan for network access
points has completed, and results are available.
Message msg = mTarget.obtainMessage(EVENT_SCAN_RESULTS_AVAILABLE, mNetworkInfo);
msg.sendToTarget();
|
private void | setBufferSize(java.lang.String bufferSizes)Writes TCP buffer sizes to /sys/kernel/ipv4/tcp_[r/w]mem_[min/def/max]
which maps to /proc/sys/net/ipv4/tcp_rmem and tcpwmem
try {
String[] values = bufferSizes.split(",");
if (values.length == 6) {
final String prefix = "/sys/kernel/ipv4/tcp_";
stringToFile(prefix + "rmem_min", values[0]);
stringToFile(prefix + "rmem_def", values[1]);
stringToFile(prefix + "rmem_max", values[2]);
stringToFile(prefix + "wmem_min", values[3]);
stringToFile(prefix + "wmem_def", values[4]);
stringToFile(prefix + "wmem_max", values[5]);
} else {
Log.e(TAG, "Invalid buffersize string: " + bufferSizes);
}
} catch (IOException e) {
Log.e(TAG, "Can't set tcp buffer sizes:" + e);
}
|
public void | setDetailedState(NetworkInfo.DetailedState state)Record the detailed state of a network, and if it is a
change from the previous state, send a notification to
any listeners.
setDetailedState(state, null, null);
|
public void | setDetailedState(NetworkInfo.DetailedState state, java.lang.String reason, java.lang.String extraInfo)Record the detailed state of a network, and if it is a
change from the previous state, send a notification to
any listeners.
if (state != mNetworkInfo.getDetailedState()) {
boolean wasConnecting = (mNetworkInfo.getState() == NetworkInfo.State.CONNECTING);
String lastReason = mNetworkInfo.getReason();
/*
* If a reason was supplied when the CONNECTING state was entered, and no
* reason was supplied for entering the CONNECTED state, then retain the
* reason that was supplied when going to CONNECTING.
*/
if (wasConnecting && state == NetworkInfo.DetailedState.CONNECTED && reason == null
&& lastReason != null)
reason = lastReason;
mNetworkInfo.setDetailedState(state, reason, extraInfo);
Message msg = mTarget.obtainMessage(EVENT_STATE_CHANGED, mNetworkInfo);
msg.sendToTarget();
}
|
protected void | setDetailedStateInternal(NetworkInfo.DetailedState state)
mNetworkInfo.setDetailedState(state, null, null);
|
public abstract boolean | setRadio(boolean turnOn)Turn the wireless radio off for a network.
|
protected void | setRoamingStatus(boolean isRoaming)Record the roaming status of the device, and if it is a change from the previous
status, send a notification to any listeners.
if (isRoaming != mNetworkInfo.isRoaming()) {
mNetworkInfo.setRoaming(isRoaming);
Message msg = mTarget.obtainMessage(EVENT_ROAMING_CHANGED, mNetworkInfo);
msg.sendToTarget();
}
|
protected void | setSubtype(int subtype, java.lang.String subtypeName)
if (mNetworkInfo.isConnected()) {
int oldSubtype = mNetworkInfo.getSubtype();
if (subtype != oldSubtype) {
mNetworkInfo.setSubtype(subtype, subtypeName);
Message msg = mTarget.obtainMessage(
EVENT_NETWORK_SUBTYPE_CHANGED, oldSubtype, 0, mNetworkInfo);
msg.sendToTarget();
}
}
|
public void | setTeardownRequested(boolean isRequested)
mTeardownRequested = isRequested;
|
public abstract void | startMonitoring()
|
public abstract int | startUsingNetworkFeature(java.lang.String feature, int callingPid, int callingUid)Tells the underlying networking system that the caller wants to
begin using the named feature. The interpretation of {@code feature}
is completely up to each networking implementation.
|
public abstract int | stopUsingNetworkFeature(java.lang.String feature, int callingPid, int callingUid)Tells the underlying networking system that the caller is finished
using the named feature. The interpretation of {@code feature}
is completely up to each networking implementation.
|
private void | stringToFile(java.lang.String filename, java.lang.String string)Writes string to file. Basically same as "echo -n $string > $filename"
FileWriter out = new FileWriter(filename);
try {
out.write(string);
} finally {
out.close();
}
|
public abstract boolean | teardown()Disable connectivity to a network
|
public void | updateNetworkSettings()Reads the network specific TCP buffer sizes from SystemProperties
net.tcp.buffersize.[default|wifi|umts|edge|gprs] and set them for system
wide use
String key = getTcpBufferSizesPropName();
String bufferSizes = SystemProperties.get(key);
if (bufferSizes.length() == 0) {
Log.e(TAG, key + " not found in system properties. Using defaults");
// Setting to default values so we won't be stuck to previous values
key = "net.tcp.buffersize.default";
bufferSizes = SystemProperties.get(key);
}
// Set values in kernel
if (bufferSizes.length() != 0) {
if (DBG) {
Log.v(TAG, "Setting TCP values: [" + bufferSizes
+ "] which comes from [" + key + "]");
}
setBufferSize(bufferSizes);
}
|