Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ec69003d authored by Erik Kline's avatar Erik Kline Committed by Android Git Automerger
Browse files

am 9d598e11: Pass signal strength thresholds inside a Bundle

* commit '9d598e11':
  Pass signal strength thresholds inside a Bundle
parents da355c80 9d598e11
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -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;
            }
        }
+5 −12
Original line number Diff line number Diff line
@@ -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();
        synchronized (nai) {
            for (NetworkRequestInfo nri : mNetworkRequests.values()) {
@@ -3621,22 +3621,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