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

Commit 6d475970 authored by Christopher Wiley's avatar Christopher Wiley
Browse files

Fix trivial warnings in Tethering.java

Add some missing @Override annotations.
Use template arguments to avoid explicit casting.
Ignore unclosed IndentingPrintWriter in dump().

Bug: 28798823
Test: Compiles.

Change-Id: I2cb6eb384ca23057c8059f4842b1c0d8248d03f8
parent 3055f3dd
Loading
Loading
Loading
Loading
+28 −32
Original line number Original line Diff line number Diff line
@@ -227,7 +227,7 @@ public class Tethering extends BaseNetworkObserver {


        int ifaceTypes[] = mContext.getResources().getIntArray(
        int ifaceTypes[] = mContext.getResources().getIntArray(
                com.android.internal.R.array.config_tether_upstream_types);
                com.android.internal.R.array.config_tether_upstream_types);
        Collection<Integer> upstreamIfaceTypes = new ArrayList();
        Collection<Integer> upstreamIfaceTypes = new ArrayList<>();
        for (int i : ifaceTypes) {
        for (int i : ifaceTypes) {
            upstreamIfaceTypes.add(new Integer(i));
            upstreamIfaceTypes.add(new Integer(i));
        }
        }
@@ -644,23 +644,23 @@ public class Tethering extends BaseNetworkObserver {
        boolean bluetoothTethered = false;
        boolean bluetoothTethered = false;


        synchronized (mPublicSync) {
        synchronized (mPublicSync) {
            Set ifaces = mIfaces.keySet();
            Set<String> ifaces = mIfaces.keySet();
            for (Object iface : ifaces) {
            for (String iface : ifaces) {
                TetherInterfaceSM sm = mIfaces.get(iface);
                TetherInterfaceSM sm = mIfaces.get(iface);
                if (sm != null) {
                if (sm != null) {
                    if (sm.isErrored()) {
                    if (sm.isErrored()) {
                        erroredList.add((String)iface);
                        erroredList.add(iface);
                    } else if (sm.isAvailable()) {
                    } else if (sm.isAvailable()) {
                        availableList.add((String)iface);
                        availableList.add(iface);
                    } else if (sm.isTethered()) {
                    } else if (sm.isTethered()) {
                        if (isUsb((String)iface)) {
                        if (isUsb(iface)) {
                            usbTethered = true;
                            usbTethered = true;
                        } else if (isWifi((String)iface)) {
                        } else if (isWifi(iface)) {
                            wifiTethered = true;
                            wifiTethered = true;
                      } else if (isBluetooth((String)iface)) {
                      } else if (isBluetooth(iface)) {
                            bluetoothTethered = true;
                            bluetoothTethered = true;
                        }
                        }
                        activeList.add((String)iface);
                        activeList.add(iface);
                    }
                    }
                }
                }
            }
            }
@@ -952,11 +952,11 @@ public class Tethering extends BaseNetworkObserver {
    public String[] getTetheredIfaces() {
    public String[] getTetheredIfaces() {
        ArrayList<String> list = new ArrayList<String>();
        ArrayList<String> list = new ArrayList<String>();
        synchronized (mPublicSync) {
        synchronized (mPublicSync) {
            Set keys = mIfaces.keySet();
            Set<String> keys = mIfaces.keySet();
            for (Object key : keys) {
            for (String key : keys) {
                TetherInterfaceSM sm = mIfaces.get(key);
                TetherInterfaceSM sm = mIfaces.get(key);
                if (sm.isTethered()) {
                if (sm.isTethered()) {
                    list.add((String)key);
                    list.add(key);
                }
                }
            }
            }
        }
        }
@@ -970,11 +970,11 @@ public class Tethering extends BaseNetworkObserver {
    public String[] getTetherableIfaces() {
    public String[] getTetherableIfaces() {
        ArrayList<String> list = new ArrayList<String>();
        ArrayList<String> list = new ArrayList<String>();
        synchronized (mPublicSync) {
        synchronized (mPublicSync) {
            Set keys = mIfaces.keySet();
            Set<String> keys = mIfaces.keySet();
            for (Object key : keys) {
            for (String key : keys) {
                TetherInterfaceSM sm = mIfaces.get(key);
                TetherInterfaceSM sm = mIfaces.get(key);
                if (sm.isAvailable()) {
                if (sm.isAvailable()) {
                    list.add((String)key);
                    list.add(key);
                }
                }
            }
            }
        }
        }
@@ -992,11 +992,11 @@ public class Tethering extends BaseNetworkObserver {
    public String[] getErroredIfaces() {
    public String[] getErroredIfaces() {
        ArrayList<String> list = new ArrayList<String>();
        ArrayList<String> list = new ArrayList<String>();
        synchronized (mPublicSync) {
        synchronized (mPublicSync) {
            Set keys = mIfaces.keySet();
            Set<String> keys = mIfaces.keySet();
            for (Object key : keys) {
            for (String key : keys) {
                TetherInterfaceSM sm = mIfaces.get(key);
                TetherInterfaceSM sm = mIfaces.get(key);
                if (sm.isErrored()) {
                if (sm.isErrored()) {
                    list.add((String)key);
                    list.add(key);
                }
                }
            }
            }
        }
        }
@@ -1076,6 +1076,7 @@ public class Tethering extends BaseNetworkObserver {
            setInitialState(mInitialState);
            setInitialState(mInitialState);
        }
        }


        @Override
        public String toString() {
        public String toString() {
            String res = new String();
            String res = new String();
            res += mIfaceName + " - ";
            res += mIfaceName + " - ";
@@ -1442,7 +1443,7 @@ public class Tethering extends BaseNetworkObserver {
     * could/should be moved here.
     * could/should be moved here.
     */
     */
    class UpstreamNetworkMonitor {
    class UpstreamNetworkMonitor {
        final HashMap<Network, NetworkState> mNetworkMap = new HashMap();
        final HashMap<Network, NetworkState> mNetworkMap = new HashMap<>();
        NetworkCallback mDefaultNetworkCallback;
        NetworkCallback mDefaultNetworkCallback;
        NetworkCallback mDunTetheringCallback;
        NetworkCallback mDunTetheringCallback;


@@ -1520,12 +1521,6 @@ public class Tethering extends BaseNetworkObserver {
        static final int EVENT_UPSTREAM_LINKPROPERTIES_CHANGED  = BASE_MASTER + 5;
        static final int EVENT_UPSTREAM_LINKPROPERTIES_CHANGED  = BASE_MASTER + 5;
        static final int EVENT_UPSTREAM_LOST                    = BASE_MASTER + 6;
        static final int EVENT_UPSTREAM_LOST                    = BASE_MASTER + 6;


        // This indicates what a timeout event relates to.  A state that
        // sends itself a delayed timeout event and handles incoming timeout events
        // should inc this when it is entered and whenever it sends a new timeout event.
        // We do not flush the old ones.
        private int mSequenceNumber;

        private State mInitialState;
        private State mInitialState;
        private State mTetherModeAliveState;
        private State mTetherModeAliveState;


@@ -1845,17 +1840,17 @@ public class Tethering extends BaseNetworkObserver {
                                config_mobile_hotspot_provision_app_no_ui).isEmpty() == false) {
                                config_mobile_hotspot_provision_app_no_ui).isEmpty() == false) {
                            ArrayList<Integer> tethered = new ArrayList<Integer>();
                            ArrayList<Integer> tethered = new ArrayList<Integer>();
                            synchronized (mPublicSync) {
                            synchronized (mPublicSync) {
                                Set ifaces = mIfaces.keySet();
                                Set<String> ifaces = mIfaces.keySet();
                                for (Object iface : ifaces) {
                                for (String iface : ifaces) {
                                    TetherInterfaceSM sm = mIfaces.get(iface);
                                    TetherInterfaceSM sm = mIfaces.get(iface);
                                    if (sm != null && sm.isTethered()) {
                                    if (sm != null && sm.isTethered()) {
                                        if (isUsb((String)iface)) {
                                        if (isUsb(iface)) {
                                            tethered.add(new Integer(
                                            tethered.add(new Integer(
                                                    ConnectivityManager.TETHERING_USB));
                                                    ConnectivityManager.TETHERING_USB));
                                        } else if (isWifi((String)iface)) {
                                        } else if (isWifi(iface)) {
                                            tethered.add(new Integer(
                                            tethered.add(new Integer(
                                                    ConnectivityManager.TETHERING_WIFI));
                                                    ConnectivityManager.TETHERING_WIFI));
                                        } else if (isBluetooth((String)iface)) {
                                        } else if (isBluetooth(iface)) {
                                            tethered.add(new Integer(
                                            tethered.add(new Integer(
                                                    ConnectivityManager.TETHERING_BLUETOOTH));
                                                    ConnectivityManager.TETHERING_BLUETOOTH));
                                        }
                                        }
@@ -2080,9 +2075,11 @@ public class Tethering extends BaseNetworkObserver {
        }
        }
    }
    }


    @Override
    public void dump(FileDescriptor fd, PrintWriter writer, String[] args) {
    public void dump(FileDescriptor fd, PrintWriter writer, String[] args) {
        // Binder.java closes the resource for us.
        @SuppressWarnings("resource")
        final IndentingPrintWriter pw = new IndentingPrintWriter(writer, "  ");
        final IndentingPrintWriter pw = new IndentingPrintWriter(writer, "  ");

        if (mContext.checkCallingOrSelfPermission(
        if (mContext.checkCallingOrSelfPermission(
                android.Manifest.permission.DUMP) != PackageManager.PERMISSION_GRANTED) {
                android.Manifest.permission.DUMP) != PackageManager.PERMISSION_GRANTED) {
            pw.println("Permission Denial: can't dump ConnectivityService.Tether " +
            pw.println("Permission Denial: can't dump ConnectivityService.Tether " +
@@ -2108,6 +2105,5 @@ public class Tethering extends BaseNetworkObserver {
            pw.decreaseIndent();
            pw.decreaseIndent();
        }
        }
        pw.decreaseIndent();
        pw.decreaseIndent();
        return;
    }
    }
}
}