Pass signal strength thresholds inside a Bundle
Bug: 21407651 Change-Id: I2c80e89441e2eb15a246cb1fa9347f886cefa80f
This commit is contained in:
committed by
Prerepa Viswanadham
parent
5d2656c181
commit
8d59d1c718
@@ -17,6 +17,7 @@
|
|||||||
package android.net;
|
package android.net;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
@@ -296,7 +297,15 @@ public abstract class NetworkAgent extends Handler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case CMD_SET_SIGNAL_STRENGTH_THRESHOLDS: {
|
case CMD_SET_SIGNAL_STRENGTH_THRESHOLDS: {
|
||||||
setSignalStrengthThresholds((int[]) msg.obj);
|
ArrayList<Integer> thresholds =
|
||||||
|
((Bundle) msg.obj).getIntegerArrayList("thresholds");
|
||||||
|
// TODO: Change signal strength thresholds API to use an ArrayList<Integer>
|
||||||
|
// rather than convert to int[].
|
||||||
|
int[] intThresholds = new int[(thresholds != null) ? thresholds.size() : 0];
|
||||||
|
for (int i = 0; i < intThresholds.length; i++) {
|
||||||
|
intThresholds[i] = thresholds.get(i);
|
||||||
|
}
|
||||||
|
setSignalStrengthThresholds(intThresholds);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3611,7 +3611,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int[] getSignalStrengthThresholds(NetworkAgentInfo nai) {
|
private ArrayList<Integer> getSignalStrengthThresholds(NetworkAgentInfo nai) {
|
||||||
final SortedSet<Integer> thresholds = new TreeSet();
|
final SortedSet<Integer> thresholds = new TreeSet();
|
||||||
synchronized (nai) {
|
synchronized (nai) {
|
||||||
for (NetworkRequestInfo nri : mNetworkRequests.values()) {
|
for (NetworkRequestInfo nri : mNetworkRequests.values()) {
|
||||||
@@ -3621,22 +3621,15 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// We can't just do something like:
|
return new ArrayList<Integer>(thresholds);
|
||||||
// return thresholds.toArray(new int[thresholds.size()]);
|
|
||||||
// because autoboxing does not work for primitive arrays.
|
|
||||||
final int[] out = new int[thresholds.size()];
|
|
||||||
int pos = 0;
|
|
||||||
for (Integer threshold : thresholds) {
|
|
||||||
out[pos] = threshold;
|
|
||||||
pos++;
|
|
||||||
}
|
|
||||||
return out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateSignalStrengthThresholds(NetworkAgentInfo nai) {
|
private void updateSignalStrengthThresholds(NetworkAgentInfo nai) {
|
||||||
|
Bundle thresholds = new Bundle();
|
||||||
|
thresholds.putIntegerArrayList("thresholds", getSignalStrengthThresholds(nai));
|
||||||
nai.asyncChannel.sendMessage(
|
nai.asyncChannel.sendMessage(
|
||||||
android.net.NetworkAgent.CMD_SET_SIGNAL_STRENGTH_THRESHOLDS,
|
android.net.NetworkAgent.CMD_SET_SIGNAL_STRENGTH_THRESHOLDS,
|
||||||
0, 0, getSignalStrengthThresholds(nai));
|
0, 0, thresholds);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user