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

Commit 3379a3ef authored by Pavel Maltsev's avatar Pavel Maltsev Committed by android-build-merger
Browse files

Merge "Enable multiple active Ethernet interfaces" am: 0a6c5399

am: ac908d67

Change-Id: I95a4e5d519857950297f5948525990c4808cd5fd
parents 048b1517 ac908d67
Loading
Loading
Loading
Loading
+33 −16
Original line number Diff line number Diff line
@@ -18,9 +18,6 @@ package android.net;

import android.annotation.SystemService;
import android.content.Context;
import android.net.IEthernetManager;
import android.net.IEthernetServiceListener;
import android.net.IpConfiguration;
import android.os.Handler;
import android.os.Message;
import android.os.RemoteException;
@@ -45,18 +42,18 @@ public class EthernetManager {
            if (msg.what == MSG_AVAILABILITY_CHANGED) {
                boolean isAvailable = (msg.arg1 == 1);
                for (Listener listener : mListeners) {
                    listener.onAvailabilityChanged(isAvailable);
                    listener.onAvailabilityChanged((String) msg.obj, isAvailable);
                }
            }
        }
    };
    private final ArrayList<Listener> mListeners = new ArrayList<Listener>();
    private final ArrayList<Listener> mListeners = new ArrayList<>();
    private final IEthernetServiceListener.Stub mServiceListener =
            new IEthernetServiceListener.Stub() {
                @Override
                public void onAvailabilityChanged(boolean isAvailable) {
                public void onAvailabilityChanged(String iface, boolean isAvailable) {
                    mHandler.obtainMessage(
                            MSG_AVAILABILITY_CHANGED, isAvailable ? 1 : 0, 0, null).sendToTarget();
                            MSG_AVAILABILITY_CHANGED, isAvailable ? 1 : 0, 0, iface).sendToTarget();
                }
            };

@@ -66,9 +63,10 @@ public class EthernetManager {
    public interface Listener {
        /**
         * Called when Ethernet port's availability is changed.
         * @param isAvailable {@code true} if one or more Ethernet port exists.
         * @param iface Ethernet interface name
         * @param isAvailable {@code true} if Ethernet port exists.
         */
        public void onAvailabilityChanged(boolean isAvailable);
        void onAvailabilityChanged(String iface, boolean isAvailable);
    }

    /**
@@ -86,9 +84,9 @@ public class EthernetManager {
     * Get Ethernet configuration.
     * @return the Ethernet Configuration, contained in {@link IpConfiguration}.
     */
    public IpConfiguration getConfiguration() {
    public IpConfiguration getConfiguration(String iface) {
        try {
            return mService.getConfiguration();
            return mService.getConfiguration(iface);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
@@ -97,21 +95,29 @@ public class EthernetManager {
    /**
     * Set Ethernet configuration.
     */
    public void setConfiguration(IpConfiguration config) {
    public void setConfiguration(String iface, IpConfiguration config) {
        try {
            mService.setConfiguration(config);
            mService.setConfiguration(iface, config);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Indicates whether the system currently has one or more
     * Ethernet interfaces.
     * Indicates whether the system currently has one or more Ethernet interfaces.
     */
    public boolean isAvailable() {
        return getAvailableInterfaces().length > 0;
    }

    /**
     * Indicates whether the system has given interface.
     *
     * @param iface Ethernet interface name
     */
    public boolean isAvailable(String iface) {
        try {
            return mService.isAvailable();
            return mService.isAvailable(iface);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
@@ -136,6 +142,17 @@ public class EthernetManager {
        }
    }

    /**
     * Returns an array of available Ethernet interface names.
     */
    public String[] getAvailableInterfaces() {
        try {
            return mService.getAvailableInterfaces();
        } catch (RemoteException e) {
            throw e.rethrowAsRuntimeException();
        }
    }

    /**
     * Removes a listener.
     * @param listener A {@link Listener} to remove.
+4 −3
Original line number Diff line number Diff line
@@ -26,9 +26,10 @@ import android.net.IEthernetServiceListener;
/** {@hide} */
interface IEthernetManager
{
    IpConfiguration getConfiguration();
    void setConfiguration(in IpConfiguration config);
    boolean isAvailable();
    String[] getAvailableInterfaces();
    IpConfiguration getConfiguration(String iface);
    void setConfiguration(String iface, in IpConfiguration config);
    boolean isAvailable(String iface);
    void addListener(in IEthernetServiceListener listener);
    void removeListener(in IEthernetServiceListener listener);
}
+1 −1
Original line number Diff line number Diff line
@@ -19,5 +19,5 @@ package android.net;
/** @hide */
oneway interface IEthernetServiceListener
{
    void onAvailabilityChanged(boolean isAvailable);
    void onAvailabilityChanged(String iface, boolean isAvailable);
}
+17 −0
Original line number Diff line number Diff line
@@ -360,6 +360,23 @@
    <!-- Regex of wired ethernet ifaces -->
    <string translatable="false" name="config_ethernet_iface_regex">eth\\d</string>



    <!-- Configuration of Ethernet interfaces in the following format:
         <interface name|mac address>;[Network Capabilities];[IP config]
         Where
               [Network Capabilities] Optional. A comma seprated list of network capabilities.
                   Values must be from NetworkCapabilities#NET_CAPABILITIES_* constants.
               [IP config] Optional. If empty or not specified - DHCP will be used, otherwise
                    static IP address with the mask.
         -->
    <string-array translatable="false" name="config_ethernet_interfaces">
        <!--
        <item>eth1;12,13,14,15;192.168.0.10/24</item>
        <item>eth2;;192.168.0.11/24</item>
        -->
    </string-array>

    <!-- If the mobile hotspot feature requires provisioning, a package name and class name
        can be provided to launch a supported application that provisions the devices.

+1 −0
Original line number Diff line number Diff line
@@ -634,6 +634,7 @@
  <java-symbol type="string" name="chooseActivity" />
  <java-symbol type="string" name="config_default_dns_server" />
  <java-symbol type="string" name="config_ethernet_iface_regex" />
  <java-symbol type="array" name="config_ethernet_interfaces" />
  <java-symbol type="string" name="config_forceVoiceInteractionServicePackage" />
  <java-symbol type="string" name="config_mms_user_agent" />
  <java-symbol type="string" name="config_mms_user_agent_profile_url" />
Loading