Use an ArrayMap instead of HashMap to track tether interfaces
( cherry-pick of 36f6f4e394 )
Since the number of tetherable interfaces should be small (e.g. <10),
the computational cost of a looking up objects in an ArrayMap is negligible,
and the memory required is less than a HashMap.
While here, remove some unused imports.
Change-Id: I3fb7091cfb93697d2fc6388b843d60f7e8e7e1a6
Test: Compiles.
This commit is contained in:
@@ -34,8 +34,6 @@ import android.hardware.usb.UsbManager;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.ConnectivityManager.NetworkCallback;
|
||||
import android.net.INetworkStatsService;
|
||||
import android.net.InterfaceConfiguration;
|
||||
import android.net.LinkAddress;
|
||||
import android.net.LinkProperties;
|
||||
import android.net.Network;
|
||||
import android.net.NetworkCapabilities;
|
||||
@@ -58,12 +56,12 @@ import android.provider.Settings;
|
||||
import android.telephony.CarrierConfigManager;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.text.TextUtils;
|
||||
import android.util.ArrayMap;
|
||||
import android.util.Log;
|
||||
import android.util.SparseArray;
|
||||
|
||||
import com.android.internal.telephony.IccCardConstants;
|
||||
import com.android.internal.telephony.TelephonyIntents;
|
||||
import com.android.internal.util.IState;
|
||||
import com.android.internal.util.IndentingPrintWriter;
|
||||
import com.android.internal.util.MessageUtils;
|
||||
import com.android.internal.util.Protocol;
|
||||
@@ -83,6 +81,7 @@ import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
@@ -127,7 +126,7 @@ public class Tethering extends BaseNetworkObserver implements IControlsTethering
|
||||
private final INetworkStatsService mStatsService;
|
||||
private final Looper mLooper;
|
||||
|
||||
private HashMap<String, TetherInterfaceStateMachine> mIfaces; // all tethered/tetherable ifaces
|
||||
private Map<String, TetherInterfaceStateMachine> mIfaces; // all tethered/tetherable ifaces
|
||||
|
||||
private BroadcastReceiver mStateReceiver;
|
||||
|
||||
@@ -172,7 +171,7 @@ public class Tethering extends BaseNetworkObserver implements IControlsTethering
|
||||
|
||||
mPublicSync = new Object();
|
||||
|
||||
mIfaces = new HashMap<String, TetherInterfaceStateMachine>();
|
||||
mIfaces = new ArrayMap<String, TetherInterfaceStateMachine>();
|
||||
|
||||
// make our own thread so we don't anr the system
|
||||
mLooper = IoThread.get().getLooper();
|
||||
|
||||
Reference in New Issue
Block a user