Framework fixes for RSSI offload.
1. When registering a NetworkCallback, only update RSSI thresholds if the request specifies a signal strength. 2. When releasing a NetworkCallback, only update RSSI thresholds if the request specified a signal strength. 3. Add logging. Add logging. Bug: 21405941 Bug: 23679346 Bug: 23815756 Change-Id: I4bc42d0ab02285a7a9d14e09f8a1cd868f4d9d7f
This commit is contained in:
@@ -2270,8 +2270,9 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
mNetworkRequestInfoLogs.log("REGISTER " + nri);
|
mNetworkRequestInfoLogs.log("REGISTER " + nri);
|
||||||
if (!nri.isRequest) {
|
if (!nri.isRequest) {
|
||||||
for (NetworkAgentInfo network : mNetworkAgentInfos.values()) {
|
for (NetworkAgentInfo network : mNetworkAgentInfos.values()) {
|
||||||
if (network.satisfiesImmutableCapabilitiesOf(nri.request)) {
|
if (nri.request.networkCapabilities.hasSignalStrength() &&
|
||||||
updateSignalStrengthThresholds(network);
|
network.satisfiesImmutableCapabilitiesOf(nri.request)) {
|
||||||
|
updateSignalStrengthThresholds(network, "REGISTER", nri.request);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2388,8 +2389,9 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
// if this listen request applies and remove it.
|
// if this listen request applies and remove it.
|
||||||
for (NetworkAgentInfo nai : mNetworkAgentInfos.values()) {
|
for (NetworkAgentInfo nai : mNetworkAgentInfos.values()) {
|
||||||
nai.networkRequests.remove(nri.request.requestId);
|
nai.networkRequests.remove(nri.request.requestId);
|
||||||
if (nai.satisfiesImmutableCapabilitiesOf(nri.request)) {
|
if (nri.request.networkCapabilities.hasSignalStrength() &&
|
||||||
updateSignalStrengthThresholds(nai);
|
nai.satisfiesImmutableCapabilitiesOf(nri.request)) {
|
||||||
|
updateSignalStrengthThresholds(nai, "RELEASE", nri.request);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3639,9 +3641,24 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
return new ArrayList<Integer>(thresholds);
|
return new ArrayList<Integer>(thresholds);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateSignalStrengthThresholds(NetworkAgentInfo nai) {
|
private void updateSignalStrengthThresholds(
|
||||||
|
NetworkAgentInfo nai, String reason, NetworkRequest request) {
|
||||||
|
ArrayList<Integer> thresholdsArray = getSignalStrengthThresholds(nai);
|
||||||
Bundle thresholds = new Bundle();
|
Bundle thresholds = new Bundle();
|
||||||
thresholds.putIntegerArrayList("thresholds", getSignalStrengthThresholds(nai));
|
thresholds.putIntegerArrayList("thresholds", thresholdsArray);
|
||||||
|
|
||||||
|
// TODO: Switch to VDBG.
|
||||||
|
if (DBG) {
|
||||||
|
String detail;
|
||||||
|
if (request != null && request.networkCapabilities.hasSignalStrength()) {
|
||||||
|
detail = reason + " " + request.networkCapabilities.getSignalStrength();
|
||||||
|
} else {
|
||||||
|
detail = reason;
|
||||||
|
}
|
||||||
|
log(String.format("updateSignalStrengthThresholds: %s, sending %s to %s",
|
||||||
|
detail, Arrays.toString(thresholdsArray.toArray()), nai.name()));
|
||||||
|
}
|
||||||
|
|
||||||
nai.asyncChannel.sendMessage(
|
nai.asyncChannel.sendMessage(
|
||||||
android.net.NetworkAgent.CMD_SET_SIGNAL_STRENGTH_THRESHOLDS,
|
android.net.NetworkAgent.CMD_SET_SIGNAL_STRENGTH_THRESHOLDS,
|
||||||
0, 0, thresholds);
|
0, 0, thresholds);
|
||||||
@@ -4624,7 +4641,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
// so we could decide to tear it down immediately afterwards. That's fine though - on
|
// so we could decide to tear it down immediately afterwards. That's fine though - on
|
||||||
// disconnection NetworkAgents should stop any signal strength monitoring they have been
|
// disconnection NetworkAgents should stop any signal strength monitoring they have been
|
||||||
// doing.
|
// doing.
|
||||||
updateSignalStrengthThresholds(networkAgent);
|
updateSignalStrengthThresholds(networkAgent, "CONNECT", null);
|
||||||
|
|
||||||
// Consider network even though it is not yet validated.
|
// Consider network even though it is not yet validated.
|
||||||
rematchNetworkAndRequests(networkAgent, ReapUnvalidatedNetworks.REAP);
|
rematchNetworkAndRequests(networkAgent, ReapUnvalidatedNetworks.REAP);
|
||||||
|
|||||||
Reference in New Issue
Block a user