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

Commit dfd6889a authored by Robert Quattlebaum's avatar Robert Quattlebaum
Browse files

Updates and fixes to android.net.lowpan

This commit is an incremental improvement to the LoWPAN support API.

Bug: b/33073713
Test: Successfully ran unit tests from Ib3750be5052bf1a90bf871756e9121b047d3871f
Change-Id: I7ca6374b6a7135411eadf631bd7d84d7dc008203
parent ff093145
Loading
Loading
Loading
Loading
+46 −5
Original line number Diff line number Diff line
@@ -37,41 +37,79 @@ interface ILowpanInterface {
    //////////////////////////////////////////////////////////////////////////
    // Property Key Constants

    /** Type: Boolean */
    const String KEY_INTERFACE_ENABLED      = "android.net.lowpan.property.INTERFACE_ENABLED";

    /** Type: Boolean */
    const String KEY_INTERFACE_UP           = "android.net.lowpan.property.INTERFACE_UP";

    /** Type: Boolean */
    const String KEY_INTERFACE_COMMISSIONED = "android.net.lowpan.property.INTERFACE_COMMISSIONED";

    /** Type: Boolean */
    const String KEY_INTERFACE_CONNECTED    = "android.net.lowpan.property.INTERFACE_CONNECTED";

    /** Type: String */
    const String KEY_INTERFACE_STATE        = "android.net.lowpan.property.INTERFACE_STATE";

    /** Type: String */
    const String KEY_NETWORK_NAME             = "android.net.lowpan.property.NETWORK_NAME";

    /** Type: Integer */
    const String KEY_NETWORK_TYPE             = "android.net.lowpan.property.NETWORK_TYPE";

    /** Type: Integer */
    const String KEY_NETWORK_PANID            = "android.net.lowpan.property.NETWORK_PANID";

    /** Type: byte[] */
    const String KEY_NETWORK_XPANID           = "android.net.lowpan.property.NETWORK_XPANID";

    /** Type: String */
    const String KEY_NETWORK_ROLE             = "android.net.lowpan.property.NETWORK_ROLE";

    /** Type: byte[] */
    const String KEY_NETWORK_MASTER_KEY       = "android.net.lowpan.property.NETWORK_MASTER_KEY";

    /** Type: Integer */
    const String KEY_NETWORK_MASTER_KEY_INDEX
        = "android.net.lowpan.property.NETWORK_MASTER_KEY_INDEX";

    /** Type: int[] */
    const String KEY_SUPPORTED_CHANNELS = "android.net.lowpan.property.SUPPORTED_CHANNELS";

    /** Type: Integer */
    const String KEY_CHANNEL            = "android.net.lowpan.property.CHANNEL";

    /** Type: int[] */
    const String KEY_CHANNEL_MASK       = "android.net.lowpan.property.CHANNEL_MASK";

    /** Type: Integer */
    const String KEY_MAX_TX_POWER       = "android.net.lowpan.property.MAX_TX_POWER";

    /** Type: Integer */
    const String KEY_RSSI               = "android.net.lowpan.property.RSSI";
    const String KEY_LQI                = "android.net.lowpan.property.LQI";

    const String KEY_LINK_ADDRESS_ARRAY = "android.net.lowpan.property.LINK_ADDRESS_ARRAY";
    const String KEY_ROUTE_INFO_ARRAY   = "android.net.lowpan.property.ROUTE_INFO_ARRAY";
    /** Type: Integer */
    const String KEY_LQI                = "android.net.lowpan.property.LQI";

    /** Type: byte[] */
    const String KEY_BEACON_ADDRESS     = "android.net.lowpan.property.BEACON_ORIGIN_ADDRESS";

    /** Type: Boolean */
    const String KEY_BEACON_CAN_ASSIST  = "android.net.lowpan.property.BEACON_CAN_ASSIST";

    /** Type: String */
    const String DRIVER_VERSION         = "android.net.lowpan.property.DRIVER_VERSION";

    /** Type: String */
    const String NCP_VERSION            = "android.net.lowpan.property.NCP_VERSION";

    /** @hide */
    /** Type: byte[]
     * @hide */
    const String KEY_EXTENDED_ADDRESS = "android.net.lowpan.property.EXTENDED_ADDRESS";

    /** @hide */
    /** Type: byte[]
     * @hide */
    const String KEY_MAC_ADDRESS      = "android.net.lowpan.property.MAC_ADDRESS";

    //////////////////////////////////////////////////////////////////////////
@@ -144,6 +182,9 @@ interface ILowpanInterface {
    void startEnergyScan(in Map properties, ILowpanEnergyScanCallback listener);
    oneway void stopEnergyScan();

    String[] copyLinkAddresses();
    IpPrefix[] copyLinkNetworks();

    void addOnMeshPrefix(in IpPrefix prefix, int flags);
    oneway void removeOnMeshPrefix(in IpPrefix prefix);

+8 −0
Original line number Diff line number Diff line
@@ -16,7 +16,15 @@

package android.net.lowpan;

import android.net.IpPrefix;

/** {@hide} */
interface ILowpanInterfaceListener {
    oneway void onPropertiesChanged(in Map properties);

    oneway void onLinkNetworkAdded(in IpPrefix prefix);
    oneway void onLinkNetworkRemoved(in IpPrefix prefix);

    oneway void onLinkAddressAdded(in String address);
    oneway void onLinkAddressRemoved(in String address);
}
+1 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.net.lowpan.ILowpanManagerListener;
/** {@hide} */
interface ILowpanManager {

    /* Keep this in sync with Context.LOWPAN_SERVICE */
    const String LOWPAN_SERVICE_NAME = "lowpan";

    ILowpanInterface getInterface(@utf8InCpp String name);
+69 −87
Original line number Diff line number Diff line
@@ -16,8 +16,6 @@

package android.net.lowpan;

import android.os.DeadObjectException;
import android.os.RemoteException;
import android.os.ServiceSpecificException;
import android.util.AndroidException;

@@ -49,15 +47,8 @@ public class LowpanException extends AndroidException {
    public static final int LOWPAN_JOIN_FAILED_AT_AUTH = 16;
    public static final int LOWPAN_FORM_FAILED_AT_SCAN = 17;

    /**
     * Convert ServiceSpecificExceptions and Binder RemoteExceptions from LoWPAN binder interfaces
     * into the correct public exceptions.
     *
     * @hide
     */
    public static void throwAsPublicException(Throwable t) throws LowpanException {
        if (t instanceof ServiceSpecificException) {
            ServiceSpecificException e = (ServiceSpecificException) t;
    public static LowpanException rethrowAsLowpanException(ServiceSpecificException e)
            throws LowpanException {
        int reason;
        switch (e.errorCode) {
            case ILowpanInterface.ERROR_INVALID_ARGUMENT:
@@ -126,15 +117,6 @@ public class LowpanException extends AndroidException {
                break;
        }
        throw new LowpanException(reason, e.getMessage(), e);
        } else if (t instanceof DeadObjectException) {
            throw new LowpanException(LOWPAN_DEAD, t);
        } else if (t instanceof RemoteException) {
            throw new UnsupportedOperationException(
                    "An unknown RemoteException was thrown" + " which should never happen.", t);
        } else if (t instanceof RuntimeException) {
            RuntimeException e = (RuntimeException) t;
            throw e;
        }
    }

    private final int mReason;
+2 −2
Original line number Diff line number Diff line
@@ -53,7 +53,7 @@ public class LowpanIdentity {
        }

        public Builder setXpanid(byte x[]) {
            identity.mXpanid = x.clone();
            identity.mXpanid = (x != null ? x.clone() : null);
            return this;
        }

@@ -115,7 +115,7 @@ public class LowpanIdentity {
    }

    public byte[] getXpanid() {
        return mXpanid.clone();
        return mXpanid != null ? mXpanid.clone() : null;
    }

    public int getPanid() {
Loading