Pass signal strength thresholds inside a Bundle
Bug: 21407651 Change-Id: I2c80e89441e2eb15a246cb1fa9347f886cefa80f
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
package android.net;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
@@ -296,7 +297,15 @@ public abstract class NetworkAgent extends Handler {
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3595,7 +3595,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
}
|
||||
}
|
||||
|
||||
private int[] getSignalStrengthThresholds(NetworkAgentInfo nai) {
|
||||
private ArrayList<Integer> getSignalStrengthThresholds(NetworkAgentInfo nai) {
|
||||
final SortedSet<Integer> thresholds = new TreeSet();
|
||||
synchronized (nai) {
|
||||
for (NetworkRequestInfo nri : mNetworkRequests.values()) {
|
||||
@@ -3605,22 +3605,15 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
}
|
||||
}
|
||||
}
|
||||
// We can't just do something like:
|
||||
// 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;
|
||||
return new ArrayList<Integer>(thresholds);
|
||||
}
|
||||
|
||||
private void updateSignalStrengthThresholds(NetworkAgentInfo nai) {
|
||||
Bundle thresholds = new Bundle();
|
||||
thresholds.putIntegerArrayList("thresholds", getSignalStrengthThresholds(nai));
|
||||
nai.asyncChannel.sendMessage(
|
||||
android.net.NetworkAgent.CMD_SET_SIGNAL_STRENGTH_THRESHOLDS,
|
||||
0, 0, getSignalStrengthThresholds(nai));
|
||||
0, 0, thresholds);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user