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

Commit 78575081 authored by Robert Quattlebaum's avatar Robert Quattlebaum Committed by Android (Google) Code Review
Browse files

Merge changes from topic 'android-lowpan-next'

* changes:
  lowpan: AIDL refactor to no longer use property design pattern
  LowpanException: Refactor exception handling
  lowpan: Introduce new unit tests for data classes
  lowpan: Make various data classes Parcelable
  lowpan: Remove libandroid_net_lowpan from platform/frameworks/base
  LowpanEnergyScanResult: Remove `public` designation from setChannel/setMaxRssi
parents cee9fdf9 6cfc490c
Loading
Loading
Loading
Loading

lowpan/Android.mk

deleted100644 → 0
+0 −33
Original line number Diff line number Diff line
#
# Copyright (C) 2017 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

LOCAL_PATH := $(call my-dir)

ifneq (,$(findstring lowpan/java,$(FRAMEWORKS_BASE_SUBDIRS)))
include $(CLEAR_VARS)
LOCAL_MODULE := libandroid_net_lowpan
LOCAL_MODULE_TAGS := optional
LOCAL_SHARED_LIBRARIES += libbase
LOCAL_SHARED_LIBRARIES += libbinder
LOCAL_SHARED_LIBRARIES += libutils
LOCAL_AIDL_INCLUDES += frameworks/native/aidl/binder
LOCAL_AIDL_INCLUDES += frameworks/base/lowpan/java
LOCAL_AIDL_INCLUDES += frameworks/base/core/java
LOCAL_SRC_FILES += $(call all-Iaidl-files-under, java/android/net/lowpan)
include $(BUILD_SHARED_LIBRARY)

include $(call all-makefiles-under,$(LOCAL_PATH))
endif
+75 −115
Original line number Diff line number Diff line
@@ -16,103 +16,39 @@

package android.net.lowpan;

import android.net.IpPrefix;
import android.net.lowpan.ILowpanEnergyScanCallback;
import android.net.lowpan.ILowpanInterfaceListener;
import android.net.lowpan.ILowpanNetScanCallback;
import android.net.lowpan.ILowpanEnergyScanCallback;
import android.os.PersistableBundle;
import android.net.IpPrefix;
import android.net.lowpan.LowpanBeaconInfo;
import android.net.lowpan.LowpanChannelInfo;
import android.net.lowpan.LowpanCredential;
import android.net.lowpan.LowpanIdentity;
import android.net.lowpan.LowpanProvision;

/** {@hide} */
interface ILowpanInterface {

    //////////////////////////////////////////////////////////////////////////
    // Permission String Constants

    /* These are here for the sake of C++ interface implementations. */
    // These are here for the sake of C++ interface implementations.

    const String PERM_ACCESS_LOWPAN_STATE    = "android.permission.ACCESS_LOWPAN_STATE";
    const String PERM_CHANGE_LOWPAN_STATE    = "android.permission.CHANGE_LOWPAN_STATE";
    const String PERM_READ_LOWPAN_CREDENTIAL = "android.permission.READ_LOWPAN_CREDENTIAL";

    //////////////////////////////////////////////////////////////////////////
    // 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[] */
    /**
     * Channel mask key.
     * Used for setting a channel mask when starting a scan.
     * Type: int[]
     * */
    const String KEY_CHANNEL_MASK       = "android.net.lowpan.property.CHANNEL_MASK";

    /** Type: Integer */
    /**
     * Max Transmit Power Key.
     * Used for setting the maximum transmit power when starting a network scan.
     * 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";

    /** 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";

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

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

    //////////////////////////////////////////////////////////////////////////
    // Interface States

    const String STATE_OFFLINE = "offline";
@@ -121,58 +57,87 @@ interface ILowpanInterface {
    const String STATE_ATTACHED = "attached";
    const String STATE_FAULT = "fault";

    //////////////////////////////////////////////////////////////////////////
    // Device Roles

    const String ROLE_END_DEVICE = "end-device";
    const String ROLE_ROUTER = "router";
    const String ROLE_SLEEPY_END_DEVICE = "sleepy-end-device";
    const String ROLE_SLEEPY_ROUTER = "sleepy-router";
    const String ROLE_UNKNOWN = "unknown";
    const String ROLE_LEADER = "leader";
    const String ROLE_COORDINATOR = "coordinator";
    const String ROLE_DETACHED = "detached";

    const String NETWORK_TYPE_UNKNOWN = "unknown";

    /**
     * Network type for Thread 1.x networks.
     *
     * @see android.net.lowpan.LowpanIdentity#getType
     * @see #getLowpanIdentity
     */
    const String NETWORK_TYPE_THREAD_V1 = "org.threadgroup.thread.v1";

    //////////////////////////////////////////////////////////////////////////
    // Service-Specific Error Code Constants

    const int ERROR_UNSPECIFIED = 1;
    const int ERROR_INVALID_ARGUMENT = 2;
    const int ERROR_DISABLED = 3;
    const int ERROR_WRONG_STATE = 4;
    const int ERROR_INVALID_TYPE = 5;
    const int ERROR_INVALID_VALUE = 6;
    const int ERROR_TIMEOUT = 7;
    const int ERROR_IO_FAILURE = 8;
    const int ERROR_BUSY = 9;
    const int ERROR_ALREADY = 10;
    const int ERROR_CANCELED = 11;
    const int ERROR_CREDENTIAL_NEEDED = 12;
    const int ERROR_FEATURE_NOT_SUPPORTED = 14;
    const int ERROR_PROPERTY_NOT_FOUND = 16;
    const int ERROR_JOIN_FAILED_UNKNOWN = 18;
    const int ERROR_JOIN_FAILED_AT_SCAN = 19;
    const int ERROR_JOIN_FAILED_AT_AUTH = 20;
    const int ERROR_FORM_FAILED_AT_SCAN = 21;
    const int ERROR_NCP_PROBLEM = 27;
    const int ERROR_PERMISSION_DENIED = 28;

    //////////////////////////////////////////////////////////////////////////
    const int ERROR_TIMEOUT = 5;
    const int ERROR_IO_FAILURE = 6;
    const int ERROR_NCP_PROBLEM = 7;
    const int ERROR_BUSY = 8;
    const int ERROR_ALREADY = 9;
    const int ERROR_CANCELED = 10;
    const int ERROR_FEATURE_NOT_SUPPORTED = 11;
    const int ERROR_JOIN_FAILED_UNKNOWN = 12;
    const int ERROR_JOIN_FAILED_AT_SCAN = 13;
    const int ERROR_JOIN_FAILED_AT_AUTH = 14;
    const int ERROR_FORM_FAILED_AT_SCAN = 15;

    // Methods

    @utf8InCpp String getName();

    void join(in Map parameters);
    void form(in Map parameters);
    @utf8InCpp String getNcpVersion();
    @utf8InCpp String getDriverVersion();
    LowpanChannelInfo[] getSupportedChannels();
    @utf8InCpp String[] getSupportedNetworkTypes();
    byte[] getMacAddress();

    boolean isEnabled();
    void setEnabled(boolean enabled);

    boolean isUp();
    boolean isCommissioned();
    boolean isConnected();
    @utf8InCpp String getState();

    @utf8InCpp String getRole();
    @utf8InCpp String getPartitionId();
    byte[] getExtendedAddress();

    LowpanIdentity getLowpanIdentity();
    LowpanCredential getLowpanCredential();

    @utf8InCpp String[] getLinkAddresses();
    IpPrefix[] getLinkNetworks();

    void join(in LowpanProvision provision);
    void form(in LowpanProvision provision);
    void attach(in LowpanProvision provision);
    void leave();
    void reset();

    void startCommissioningSession(in LowpanBeaconInfo beaconInfo);
    void closeCommissioningSession();
    oneway void sendToCommissioner(in byte[] packet);

    void beginLowPower();
    void pollForData();
    oneway void pollForData();

    oneway void onHostWake();

    @utf8InCpp String[] getPropertyKeys();
    Map getProperties(in @utf8InCpp String[] keys);
    void setProperties(in Map properties);

    void addListener(ILowpanInterfaceListener listener);
    oneway void removeListener(ILowpanInterfaceListener listener);

@@ -182,14 +147,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);

    void addExternalRoute(in IpPrefix prefix, int flags);
    oneway void removeExternalRoute(in IpPrefix prefix);

    @utf8InCpp String getPropertyAsString(@utf8InCpp String key);
}
+20 −5
Original line number Diff line number Diff line
@@ -17,14 +17,29 @@
package android.net.lowpan;

import android.net.IpPrefix;
import android.net.lowpan.LowpanIdentity;

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

    oneway void onLinkNetworkAdded(in IpPrefix prefix);
    oneway void onLinkNetworkRemoved(in IpPrefix prefix);
    oneway void onConnectedChanged(boolean value);

    oneway void onLinkAddressAdded(in String address);
    oneway void onLinkAddressRemoved(in String address);
    oneway void onUpChanged(boolean value);

    oneway void onRoleChanged(@utf8InCpp String value);

    oneway void onStateChanged(@utf8InCpp String value);

    oneway void onLowpanIdentityChanged(in LowpanIdentity value);

    oneway void onLinkNetworkAdded(in IpPrefix value);

    oneway void onLinkNetworkRemoved(in IpPrefix value);

    oneway void onLinkAddressAdded(@utf8InCpp String value);

    oneway void onLinkAddressRemoved(@utf8InCpp String value);

    oneway void onReceiveFromCommissioner(in byte[] packet);
}
+4 −2
Original line number Diff line number Diff line
/*
 * Copyright (C) 2016 The Android Open Source Project
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
@@ -16,8 +16,10 @@

package android.net.lowpan;

import android.net.lowpan.LowpanBeaconInfo;

/** {@hide} */
interface ILowpanNetScanCallback {
    oneway void onNetScanBeacon(in Map parameters);
    oneway void onNetScanBeacon(in LowpanBeaconInfo beacon);
    oneway void onNetScanFinished();
}
+41 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.net.lowpan;

/**
 * Exception indicating this operation requires the interface to be enabled.
 *
 * @see LowpanInterface
 * @hide
 */
// @SystemApi
public class InterfaceDisabledException extends LowpanException {

    public InterfaceDisabledException() {}

    public InterfaceDisabledException(String message) {
        super(message);
    }

    public InterfaceDisabledException(String message, Throwable cause) {
        super(message, cause);
    }

    protected InterfaceDisabledException(Exception cause) {
        super(cause);
    }
}
Loading