Merge "fstman: add HAL version 1.0"
diff --git a/Android.bp b/Android.bp
index 3769b92..5e90856 100644
--- a/Android.bp
+++ b/Android.bp
@@ -39,3 +39,8 @@
     name: "vendor.qti.hardware.bluetooth_dun",
     path: "vendor/qcom/opensource/interfaces/bluetooth_dun",
 }
+
+hidl_package_root {
+    name: "vendor.qti.hardware.fstman",
+    path: "vendor/qcom/opensource/interfaces/fstman",
+}
diff --git a/fstman/1.0/IFstGroup.hal b/fstman/1.0/IFstGroup.hal
new file mode 100644
index 0000000..9fd10c8
--- /dev/null
+++ b/fstman/1.0/IFstGroup.hal
@@ -0,0 +1,213 @@
+/* Copyright (c) 2019, The Linux Foundation. All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are
+* met:
+*     * Redistributions of source code must retain the above copyright
+*       notice, this list of conditions and the following disclaimer.
+*     * Redistributions in binary form must reproduce the above
+*       copyright notice, this list of conditions and the following
+*       disclaimer in the documentation and/or other materials provided
+*       with the distribution.
+*     * Neither the name of The Linux Foundation nor the names of its
+*       contributors may be used to endorse or promote products derived
+*       from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+* ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*/
+
+
+package vendor.qti.hardware.fstman@1.0;
+
+import IFstGroupCallback;
+
+/**
+ * Interface exposed by the supplicant for each FST group (e.g bond0)
+ * it controls.
+ */
+interface IFstGroup {
+
+  /**
+   * Retrieves the name of the FST group.
+   *
+   * @return status Status of the operation.
+   *         Possible status codes:
+   *         |FstManagerStatusCode.SUCCESS|,
+   *         |FstManagerStatusCode.FAILURE_UNKNOWN|
+   * @return name Name of the FST group, e.g., bond0
+   */
+  getName() generates (FstManagerStatus status, string name);
+
+  /**
+   * Register for callbacks from this group.
+   *
+   * These callbacks are invoked for events that are specific to this group.
+   * Registration of multiple callback objects is supported. These objects must
+   * be automatically deleted when the corresponding client process is dead or
+   * if this group is removed.
+   *
+   * @param callback An instance of the |IFstGroupCallback| HIDL
+   *        interface object.
+   * @return status Status of the operation.
+   *         Possible status codes:
+   *         |FstManagerStatusCode.SUCCESS|,
+   *         |FstManagerStatusCode.FAILURE_UNKNOWN|,
+   */
+  registerCallback(IFstGroupCallback callback)
+      generates (FstManagerStatus status);
+
+  /**
+   * Retrieve a list of all interfaces belonging to this group.
+   *
+   * @return status Status of the operation.
+   *         Possible status codes:
+   *         |FstManagerStatusCode.SUCCESS|,
+   *         |FstManagerStatusCode.FAILURE_UNKNOWN|
+   * @return ifaceNames List of names for interfaces belonging to this group.
+   */
+  listInterfaces() generates (FstManagerStatus status, vec<string> ifaceNames);
+
+  /**
+   * check if FST mode is supported for this group.
+   * When FST mode is supported, framework should detect FST-capable AP by
+   * checking for presence of MB IE in probe response.
+   *
+   * @return status Status of the operation.
+   *         Possible status codes:
+   *         |FstManagerStatusCode.SUCCESS|,
+   *         |FstManagerStatusCode.FAILURE_UNKNOWN|,
+   * @return supported true if FST mode is supported, false if not.
+   */
+  isFstModeSupported() generates (FstManagerStatus status, bool supported);
+
+  /**
+   * check if WIFI SON mode is supported for this group.
+   * When SON mode is supported, framework should detect SON-capable AP by
+   * checking for presence of SON IE in probe response.
+   *
+   * @return status Status of the operation.
+   *         Possible status codes:
+   *         |FstManagerStatusCode.SUCCESS|,
+   *         |FstManagerStatusCode.FAILURE_UNKNOWN|,
+   * @return supported true if WIFI SON mode supported, false if not.
+   */
+  isWifiSonModeSupported() generates (FstManagerStatus status, bool supported);
+
+  /**
+   * get the name of the MUX interface used by this group.
+   *
+   * @return status Status of the operation.
+   *         Possible status codes:
+   *         |FstManagerStatusCode.SUCCESS|,
+   *         |FstManagerStatusCode.FAILURE_UNKNOWN|,
+   * @return name name of the MUX interface (such as bond0)
+   */
+  getMuxInterfaceName() generates (FstManagerStatus status, string name);
+
+  /**
+   * set the name of the MUX interface used by this group.
+   * The group must not have any enslaved interfaces or active connection.
+   *
+   * @param name new name for the MUX interface.
+   * @return status Status of the operation.
+   *         Possible status codes:
+   *         |FstManagerStatusCode.SUCCESS|,
+   *         |FstManagerStatusCode.FAILURE_UNKNOWN|,
+   */
+  setMuxInterfaceName(string name) generates (FstManagerStatus status);
+
+  /**
+   * Enslave or release a group interface.
+   * When enslaving, interface will be added to master
+   * interface as a slave.
+   * When releasing, interface will be detached from
+   * master interface and no longer be a slave.
+   * When releasing, fst-manager will also disconnect
+   * any active connection on the interface (via supplicant)
+   *
+   * @param ifname interface name, must be one of the group interfaces.
+   * @param enslave true to enslave, false to release
+   *
+   * @return status Status of the operation.
+   *         Possible status codes:
+   *         |FstManagerStatusCode.SUCCESS|,
+   *         |FstManagerStatusCode.FAILURE_ARGS_INVALID|,
+   *         |FstManagerStatusCode.FAILURE_UNKNOWN|,
+   */
+   enslave(string ifname, bool enslave)
+       generates (FstManagerStatus status);
+
+  /**
+   * check if the interface is currently enslaved under the
+   * MUX interface.
+   *
+   * @param ifname interface name, must be one of the group interfaces.
+   *
+   * @return status Status of the operation.
+   *         Possible status codes:
+   *         |FstManagerStatusCode.SUCCESS|,
+   *         |FstManagerStatusCode.FAILURE_ARGS_INVALID|,
+   *         |FstManagerStatusCode.FAILURE_UNKNOWN|,
+   * @return enslaved true if interface is enslaved, false if not.
+   */
+   isEnslaved(string ifname)
+       generates (FstManagerStatus status, bool enslaved);
+
+   /**
+    * Changes the MAC address of the group master interface
+    * and its underlying interfaces.
+    *
+    * @param mac MAC address to change into.
+    * @return status WifiStatus of the operation.
+    *         Possible status codes:
+    *         |FstManagerStatusCode.SUCCESS|,
+    *         |FstManagerStatusCode.FAILURE_UNKNOWN|,
+    */
+   setMacAddress(MacAddress mac) generates (FstManagerStatus status);
+
+  /**
+   * check if the specified interface is the rate upgrade master for
+   * this group. The rate upgrade master is typically the "always on"
+   * connection which is used as a fallback when the faster (but less
+   * reliable) interface is not available.
+   *
+   * @param ifname interface name, must be one of the group interfaces.
+   *
+   * @return status Status of the operation.
+   *         Possible status codes:
+   *         |FstManagerStatusCode.SUCCESS|,
+   *         |FstManagerStatusCode.FAILURE_ARGS_INVALID|,
+   *         |FstManagerStatusCode.FAILURE_UNKNOWN|,
+   * @return isMaster true if interface is rate upgrade master, false if not.
+   */
+   isRateUpgradeMaster(string ifname)
+       generates (FstManagerStatus status, bool isMaster);
+
+  /**
+   * rename one of the group interfaces.
+   * The interface must not be enslaved, and the group must
+   * not have an active connection.
+   *
+   * @param ifname interface name, must be one of the group interfaces.
+   * @param newifname new interface name for this interface.
+   *
+   * @return status Status of the operation.
+   *         Possible status codes:
+   *         |FstManagerStatusCode.SUCCESS|,
+   *         |FstManagerStatusCode.FAILURE_ARGS_INVALID|,
+   *         |FstManagerStatusCode.FAILURE_UNKNOWN|,
+   */
+   renameInterface(string ifname, string newifname)
+       generates (FstManagerStatus status);
+};
diff --git a/fstman/1.0/IFstGroupCallback.hal b/fstman/1.0/IFstGroupCallback.hal
new file mode 100644
index 0000000..ae6de9b
--- /dev/null
+++ b/fstman/1.0/IFstGroupCallback.hal
@@ -0,0 +1,42 @@
+/* Copyright (c) 2019, The Linux Foundation. All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are
+* met:
+*     * Redistributions of source code must retain the above copyright
+*       notice, this list of conditions and the following disclaimer.
+*     * Redistributions in binary form must reproduce the above
+*       copyright notice, this list of conditions and the following
+*       disclaimer in the documentation and/or other materials provided
+*       with the distribution.
+*     * Neither the name of The Linux Foundation nor the names of its
+*       contributors may be used to endorse or promote products derived
+*       from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+* ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*/
+
+package vendor.qti.hardware.fstman@1.0;
+
+/**
+ * Callback Interface exposed by the fst-manager service
+ * for each FST group (IFstGroup).
+ *
+ * Clients need to host an instance of this HIDL interface object and
+ * pass a reference of the object to the supplicant via the
+ * corresponding |IFstGroup.registerCallback| method.
+ */
+interface IFstGroupCallback {
+
+};
diff --git a/fstman/1.0/IFstManager.hal b/fstman/1.0/IFstManager.hal
new file mode 100644
index 0000000..3909703
--- /dev/null
+++ b/fstman/1.0/IFstManager.hal
@@ -0,0 +1,118 @@
+/* Copyright (c) 2019, The Linux Foundation. All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are
+* met:
+*     * Redistributions of source code must retain the above copyright
+*       notice, this list of conditions and the following disclaimer.
+*     * Redistributions in binary form must reproduce the above
+*       copyright notice, this list of conditions and the following
+*       disclaimer in the documentation and/or other materials provided
+*       with the distribution.
+*     * Neither the name of The Linux Foundation nor the names of its
+*       contributors may be used to endorse or promote products derived
+*       from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+* ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*/
+package vendor.qti.hardware.fstman@1.0;
+
+import IFstGroup;
+
+/**
+ * interface for communicating with fst-manager
+ */
+interface IFstManager {
+
+  /**
+   * Debug levels for the fst-manager.
+   * Only log messages with a level greater than the set level
+   * (via |setDebugParams|) will be logged.
+   */
+  enum DebugLevel : uint32_t {
+    EXCESSIVE = 0,
+    MSGDUMP = 1,
+    DEBUG = 2,
+    INFO = 3,
+    WARNING = 4,
+    ERROR = 5
+  };
+
+  /**
+   * Gets a HIDL interface object for the group corresponding to group
+   * name which the fst-manager already controls.
+   *
+   * @param groupName The group name.
+   * @return status Status of the operation.
+   *         Possible status codes:
+   *         |FstManagerStatusCode.SUCCESS|,
+   *         |FstManagerStatusCode.FAILURE_UNKNOWN|,
+   *         |FstManagerStatusCode.FAILURE_GROUP_UNKOWN|
+   * @return group HIDL interface object representing the group if
+   *         successful, null otherwise.
+   */
+  getGroup(string groupName)
+      generates (FstManagerStatus status, IFstGroup group);
+
+  /**
+   * Retrieve a list of all the groups controlled by the fst-manager.
+   *
+   * The corresponding |IFstGroup| object for any group can be
+   * retrieved using |getGroup| method.
+   *
+   * @return status Status of the operation.
+   *         Possible status codes:
+   *         |FstManagerStatusCode.SUCCESS|,
+   *         |FstManagerStatusCode.FAILURE_UNKNOWN|
+   * @return groupNames List of all group names controlled by the fst-manager.
+   */
+  listGroups() generates (FstManagerStatus status, vec<string> groupNames);
+
+  /**
+   * Set debug parameters for the fst-manager.
+   *
+   * @param level Debug logging level for the fst-manager.
+   *        (one of |DebugLevel| values).
+   * @param timestamp Determines whether to show timestamps in logs or
+   *        not.
+   * @return status Status of the operation.
+   *         Possible status codes:
+   *         |FstManagerStatusCode.SUCCESS|,
+   *         |FstManagerStatusCode.FAILURE_UNKNOWN|
+   */
+  setDebugParams(DebugLevel level, bool showTimestamp)
+      generates (FstManagerStatus status);
+
+  /**
+   * Get the debug level set.
+   *
+   * @return level one of |DebugLevel| values.
+   */
+  getDebugLevel() generates (DebugLevel level);
+
+  /**
+   * Get whether the timestamps are shown in the debug logs or not.
+   *
+   * @return enabled true if set, false otherwise.
+   */
+  isDebugShowTimestampEnabled() generates (bool enabled);
+
+  /**
+   * Terminate the service.
+   * This must de-register the service and clear all state. If this HAL
+   * supports the lazy HAL protocol, then this may trigger daemon to exit and
+   * wait to be restarted.
+   */
+  oneway terminate();
+};
diff --git a/fstman/1.0/types.hal b/fstman/1.0/types.hal
new file mode 100644
index 0000000..824a4cd
--- /dev/null
+++ b/fstman/1.0/types.hal
@@ -0,0 +1,61 @@
+/* Copyright (c) 2019, The Linux Foundation. All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are
+* met:
+*     * Redistributions of source code must retain the above copyright
+*       notice, this list of conditions and the following disclaimer.
+*     * Redistributions in binary form must reproduce the above
+*       copyright notice, this list of conditions and the following
+*       disclaimer in the documentation and/or other materials provided
+*       with the distribution.
+*     * Neither the name of The Linux Foundation nor the names of its
+*       contributors may be used to endorse or promote products derived
+*       from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+* ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*/
+
+package vendor.qti.hardware.fstman@1.0;
+/**
+ * Enum values indicating the status of any FST manager operation.
+ */
+enum FstManagerStatusCode : uint32_t {
+  /** No errors. */
+  SUCCESS,
+  /** Unknown failure occured. */
+  FAILURE_UNKNOWN,
+  /** One of the incoming args is invalid. */
+  FAILURE_ARGS_INVALID,
+  /** Unknown FST group */
+  FAILURE_GROUP_UNKNOWN,
+};
+
+/**
+ * Generic structure to return the status of any FST manager operation.
+ */
+struct FstManagerStatus {
+  FstManagerStatusCode code;
+  /**
+   * A vendor specific error message to provide more information beyond the
+   * status code.
+   * This will be used for debbuging purposes only.
+   */
+  string debugMessage;
+};
+
+/**
+ * Mac Address type. 6 octets representing physical address of a device.
+ */
+typedef uint8_t[6] MacAddress;
diff --git a/fstman/current.txt b/fstman/current.txt
new file mode 100644
index 0000000..dd02587
--- /dev/null
+++ b/fstman/current.txt
@@ -0,0 +1,36 @@
+# Copyright (c) 2019, The Linux Foundation. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#     * Redistributions of source code must retain the above copyright
+#       notice, this list of conditions and the following disclaimer.
+#     * Redistributions in binary form must reproduce the above
+#       copyright notice, this list of conditions and the following
+#       disclaimer in the documentation and/or other materials provided
+#       with the distribution.
+#     * Neither the name of The Linux Foundation nor the names of its
+#       contributors may be used to endorse or promote products derived
+#       from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+#
+
+
+######HAL released in Android Q######
+a916925177373b896bf211eb00faaeae7063ef40351286a64f4bec8e0079e6db vendor.qti.hardware.fstman@1.0::types
+951b29cb64137afe92a225d85af245d96c89405dae56c6af5339f13f4c4e2904 vendor.qti.hardware.fstman@1.0::IFstGroup
+24bd58f69a5d3be9294f9a671b81da1f36120ff17954d0ec94fbbff14f968a62 vendor.qti.hardware.fstman@1.0::IFstGroupCallback
+d9f95a2ba931ce60b39b564d52ae4644e875b10e7ec27ce42da83a95dcff4e81 vendor.qti.hardware.fstman@1.0::IFstManager
+