wifi(interface): Add status for every method

Add a status parameter for every HIDL interface object method which can
possibly become invalid. This should help inform the caller that the
object being used is stale/invalid now.

While there,
Rename |CommandFailureReson| to |FailureReasonCode|.

NOTE: |FailureReason| will continue to indicate any errors during the
processing of the command via the corresponding |onFailure| callback.

Bug: 32056230
Test: Compiles
Change-Id: I2ec5af3075221e483579410f344bcedd6bf17a93
diff --git a/wifi/1.0/Android.mk b/wifi/1.0/Android.mk
index a1a716d..e345dd2 100644
--- a/wifi/1.0/Android.mk
+++ b/wifi/1.0/Android.mk
@@ -13,23 +13,6 @@
 HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
 
 #
-# Build types.hal (CommandFailureReason)
-#
-GEN := $(intermediates)/android/hardware/wifi/1.0/CommandFailureReason.java
-$(GEN): $(HIDL)
-$(GEN): PRIVATE_HIDL := $(HIDL)
-$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
-$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
-$(GEN): PRIVATE_CUSTOM_TOOL = \
-        $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
-        -Ljava -randroid.hardware:hardware/interfaces \
-        android.hardware.wifi@1.0::types.CommandFailureReason
-
-$(GEN): $(LOCAL_PATH)/types.hal
-	$(transform-generated-source)
-LOCAL_GENERATED_SOURCES += $(GEN)
-
-#
 # Build types.hal (FailureReason)
 #
 GEN := $(intermediates)/android/hardware/wifi/1.0/FailureReason.java
@@ -47,6 +30,23 @@
 LOCAL_GENERATED_SOURCES += $(GEN)
 
 #
+# Build types.hal (FailureReasonCode)
+#
+GEN := $(intermediates)/android/hardware/wifi/1.0/FailureReasonCode.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+        $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+        -Ljava -randroid.hardware:hardware/interfaces \
+        android.hardware.wifi@1.0::types.FailureReasonCode
+
+$(GEN): $(LOCAL_PATH)/types.hal
+	$(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
 # Build types.hal (IfaceType)
 #
 GEN := $(intermediates)/android/hardware/wifi/1.0/IfaceType.java
@@ -64,6 +64,23 @@
 LOCAL_GENERATED_SOURCES += $(GEN)
 
 #
+# Build types.hal (StatusCode)
+#
+GEN := $(intermediates)/android/hardware/wifi/1.0/StatusCode.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+        $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+        -Ljava -randroid.hardware:hardware/interfaces \
+        android.hardware.wifi@1.0::types.StatusCode
+
+$(GEN): $(LOCAL_PATH)/types.hal
+	$(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
 # Build IWifi.hal
 #
 GEN := $(intermediates)/android/hardware/wifi/1.0/IWifi.java
@@ -242,6 +259,8 @@
 $(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IWifiRttController.hal
 $(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/IWifiIface.hal
 $(GEN): $(LOCAL_PATH)/IWifiIface.hal
+$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/types.hal
+$(GEN): $(LOCAL_PATH)/types.hal
 $(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
 $(GEN): PRIVATE_CUSTOM_TOOL = \
         $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
@@ -307,23 +326,6 @@
 HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
 
 #
-# Build types.hal (CommandFailureReason)
-#
-GEN := $(intermediates)/android/hardware/wifi/1.0/CommandFailureReason.java
-$(GEN): $(HIDL)
-$(GEN): PRIVATE_HIDL := $(HIDL)
-$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
-$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
-$(GEN): PRIVATE_CUSTOM_TOOL = \
-        $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
-        -Ljava -randroid.hardware:hardware/interfaces \
-        android.hardware.wifi@1.0::types.CommandFailureReason
-
-$(GEN): $(LOCAL_PATH)/types.hal
-	$(transform-generated-source)
-LOCAL_GENERATED_SOURCES += $(GEN)
-
-#
 # Build types.hal (FailureReason)
 #
 GEN := $(intermediates)/android/hardware/wifi/1.0/FailureReason.java
@@ -341,6 +343,23 @@
 LOCAL_GENERATED_SOURCES += $(GEN)
 
 #
+# Build types.hal (FailureReasonCode)
+#
+GEN := $(intermediates)/android/hardware/wifi/1.0/FailureReasonCode.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+        $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+        -Ljava -randroid.hardware:hardware/interfaces \
+        android.hardware.wifi@1.0::types.FailureReasonCode
+
+$(GEN): $(LOCAL_PATH)/types.hal
+	$(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
 # Build types.hal (IfaceType)
 #
 GEN := $(intermediates)/android/hardware/wifi/1.0/IfaceType.java
@@ -358,6 +377,23 @@
 LOCAL_GENERATED_SOURCES += $(GEN)
 
 #
+# Build types.hal (StatusCode)
+#
+GEN := $(intermediates)/android/hardware/wifi/1.0/StatusCode.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+        $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+        -Ljava -randroid.hardware:hardware/interfaces \
+        android.hardware.wifi@1.0::types.StatusCode
+
+$(GEN): $(LOCAL_PATH)/types.hal
+	$(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
 # Build IWifi.hal
 #
 GEN := $(intermediates)/android/hardware/wifi/1.0/IWifi.java
@@ -536,6 +572,8 @@
 $(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IWifiRttController.hal
 $(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/IWifiIface.hal
 $(GEN): $(LOCAL_PATH)/IWifiIface.hal
+$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/types.hal
+$(GEN): $(LOCAL_PATH)/types.hal
 $(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
 $(GEN): PRIVATE_CUSTOM_TOOL = \
         $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
diff --git a/wifi/1.0/IWifiChip.hal b/wifi/1.0/IWifiChip.hal
index 55f6d61..c9ff038 100644
--- a/wifi/1.0/IWifiChip.hal
+++ b/wifi/1.0/IWifiChip.hal
@@ -121,9 +121,13 @@
   /**
    * Get the id assigned to this chip.
    *
+   * @return status Status of the operation.
+   *         Possible status codes:
+   *         |StatusCode.SUCCESS|,
+   *         |StatusCode.ERROR_WIFI_CHIP_INVALID|
    * @return id Assigned chip Id.
    */
-  getId() generates (ChipId id);
+  getId() generates (StatusCode status, ChipId id);
 
   /**
    * Requests notifications of significant events on this chip. Multiple calls
@@ -132,15 +136,23 @@
    *
    * @param callback An instance of the |IWifiChipEventCallback| HIDL interface
    *        object.
+   * @return status Status of the operation.
+   *         Possible status codes:
+   *         |StatusCode.SUCCESS|,
+   *         |StatusCode.ERROR_WIFI_CHIP_INVALID|
    */
-  oneway registerEventCallback(IWifiChipEventCallback callback);
+  registerEventCallback(IWifiChipEventCallback callback) generates (StatusCode status);
 
   /**
    * Get the set of operation modes that the chip supports.
    *
+   * @return status Status of the operation.
+   *         Possible status codes:
+   *         |StatusCode.SUCCESS|,
+   *         |StatusCode.ERROR_WIFI_CHIP_INVALID|
    * @return modes List of modes supported by the device.
    */
-  getAvailableModes() generates (vec<ChipMode> modes);
+  getAvailableModes() generates (StatusCode status, vec<ChipMode> modes);
 
   /**
    * Reconfigure the Chip.
@@ -149,37 +161,60 @@
    *
    * @param modeId The mode that the chip should switch to, corresponding to the
    *        id property of the target ChipMode.
+   * @return status Status of the operation.
+   *         Possible status codes:
+   *         |StatusCode.SUCCESS|,
+   *         |StatusCode.ERROR_WIFI_CHIP_INVALID|
    */
-  oneway configureChip(ChipModeId modeId);
+  configureChip(ChipModeId modeId) generates (StatusCode status);
 
   /**
    * Get the current mode that the chip is in.
    *
    * @return modeId The mode that the chip is currently configured to,
    *         corresponding to the id property of the target ChipMode.
+   * @return status Status of the operation.
+   *         Possible status codes:
+   *         |StatusCode.SUCCESS|,
+   *         |StatusCode.ERROR_WIFI_CHIP_INVALID|
    */
-  getMode() generates (ChipModeId modeId);
+  getMode() generates (StatusCode status, ChipModeId modeId);
 
   /**
    * Request information about the chip.
    * Must trigger |IWifiChipEventCallback.onChipDebugInfoAvailable| on sucess,
    * or |IWifiChipEventCallback.onChipDebugInfoFailure| on failure.
+   *
+   * @return status Status of the operation.
+   *         Possible status codes:
+   *         |StatusCode.SUCCESS|,
+   *         |StatusCode.ERROR_WIFI_CHIP_INVALID|
    */
-  oneway requestChipDebugInfo();
+  requestChipDebugInfo() generates (StatusCode status);
 
   /**
    * Request vendor debug info from the driver.
    * Must trigger |IWifiChipEventCallback.onDriverDebugDumpAvailable| on success,
    * or |IWifiChipEventCallback.onDriverDebugDumpFailure| on failure.
+   *
+   * @return status Status of the operation.
+   *         Possible status codes:
+   *         |StatusCode.SUCCESS|,
+   *         |StatusCode.ERROR_WIFI_CHIP_INVALID|
    */
-  oneway requestDriverDebugDump();
+  requestDriverDebugDump() generates (StatusCode status);
 
   /**
    * Request vendor debug info from the firmware.
    * Must trigger |IWifiChipEventCallback.onFirmwareDebugDumpAvailable| on
    * success, or |IWifiChipEventCallback.onFirmwareDebugDumpFailure| on failure.
+   *
+   * @return status Status of the operation.
+   *         Possible status codes:
+   *         |StatusCode.SUCCESS|,
+   *         |StatusCode.ERROR_WIFI_CHIP_INVALID|
    */
-  oneway requestFirmwareDebugDump();
+  requestFirmwareDebugDump() generates (StatusCode status);
 
   /**
    * Create an AP iface on the chip.
@@ -188,29 +223,41 @@
    * may fail if we've already reached the maximum allowed
    * (specified in |ChipIfaceCombination|) number of ifaces of the AP type.
    *
+   * @return status Status of the operation.
+   *         Possible status codes:
+   *         |StatusCode.SUCCESS|,
+   *         |StatusCode.ERROR_WIFI_CHIP_INVALID|
    * @return iface HIDL interface object representing the iface if
    *         successful, null otherwise.
    */
-  createApIface() generates (IWifiApIface iface);
+  createApIface() generates (StatusCode status, IWifiApIface iface);
 
   /**
    * List all the AP iface names configured on the chip.
    * The corresponding |IWifiApIface| object for any iface are
    * retrieved using |getApIface| method.
    *
+   * @return status Status of the operation.
+   *         Possible status codes:
+   *         |StatusCode.SUCCESS|,
+   *         |StatusCode.ERROR_WIFI_CHIP_INVALID|
    * @return ifnames List of all AP iface names on the chip.
    */
-  getApIfaceNames() generates (vec<string> ifnames);
+  getApIfaceNames() generates (StatusCode status, vec<string> ifnames);
 
   /**
    * Gets a HIDL interface object for the AP Iface corresponding
    * to the provided ifname.
    *
    * @param ifname Name of the iface.
+   * @return status Status of the operation.
+   *         Possible status codes:
+   *         |StatusCode.SUCCESS|,
+   *         |StatusCode.ERROR_WIFI_CHIP_INVALID|
    * @return iface HIDL interface object representing the iface if
    *         it exists, null otherwise.
    */
-  getApIface(string ifname) generates (IWifiApIface iface);
+  getApIface(string ifname) generates (StatusCode status, IWifiApIface iface);
 
   /**
    * Create a NAN iface on the chip.
@@ -219,29 +266,41 @@
    * may fail if we've already reached the maximum allowed
    * (specified in |ChipIfaceCombination|) number of ifaces of the NAN type.
    *
+   * @return status Status of the operation.
+   *         Possible status codes:
+   *         |StatusCode.SUCCESS|,
+   *         |StatusCode.ERROR_WIFI_CHIP_INVALID|
    * @return iface HIDL interface object representing the iface if
    *         successful, null otherwise.
    */
-  createNanIface() generates (IWifiNanIface iface);
+  createNanIface() generates (StatusCode status, IWifiNanIface iface);
 
   /**
    * List all the NAN iface names configured on the chip.
    * The corresponding |IWifiNanIface| object for any iface are
    * retrieved using |getNanIface| method.
    *
+   * @return status Status of the operation.
+   *         Possible status codes:
+   *         |StatusCode.SUCCESS|,
+   *         |StatusCode.ERROR_WIFI_CHIP_INVALID|
    * @return ifnames List of all NAN iface names on the chip.
    */
-  getNanIfaceNames() generates (vec<string> ifnames);
+  getNanIfaceNames() generates (StatusCode status, vec<string> ifnames);
 
   /**
    * Gets a HIDL interface object for the NAN Iface corresponding
    * to the provided ifname.
    *
    * @param ifname Name of the iface.
+   * @return status Status of the operation.
+   *         Possible status codes:
+   *         |StatusCode.SUCCESS|,
+   *         |StatusCode.ERROR_WIFI_CHIP_INVALID|
    * @return iface HIDL interface object representing the iface if
    *         it exists, null otherwise.
    */
-  getNanIface(string ifname) generates (IWifiNanIface iface);
+  getNanIface(string ifname) generates (StatusCode status, IWifiNanIface iface);
 
   /**
    * Create a P2P iface on the chip.
@@ -250,29 +309,41 @@
    * may fail if we've already reached the maximum allowed
    * (specified in |ChipIfaceCombination|) number of ifaces of the P2P type.
    *
+   * @return status Status of the operation.
+   *         Possible status codes:
+   *         |StatusCode.SUCCESS|,
+   *         |StatusCode.ERROR_WIFI_CHIP_INVALID|
    * @return iface HIDL interface object representing the iface if
    *         successful, null otherwise.
    */
-  createP2pIface() generates (IWifiP2pIface iface);
+  createP2pIface() generates (StatusCode status, IWifiP2pIface iface);
 
   /**
    * List all the P2P iface names configured on the chip.
    * The corresponding |IWifiP2pIface| object for any iface are
    * retrieved using |getP2pIface| method.
    *
+   * @return status Status of the operation.
+   *         Possible status codes:
+   *         |StatusCode.SUCCESS|,
+   *         |StatusCode.ERROR_WIFI_CHIP_INVALID|
    * @return ifnames List of all P2P iface names on the chip.
    */
-  getP2pIfaceNames() generates (vec<string> ifnames);
+  getP2pIfaceNames() generates (StatusCode status, vec<string> ifnames);
 
   /**
    * Gets a HIDL interface object for the P2P Iface corresponding
    * to the provided ifname.
    *
    * @param ifname Name of the iface.
+   * @return status Status of the operation.
+   *         Possible status codes:
+   *         |StatusCode.SUCCESS|,
+   *         |StatusCode.ERROR_WIFI_CHIP_INVALID|
    * @return iface HIDL interface object representing the iface if
    *         it exists, null otherwise.
    */
-  getP2pIface(string ifname) generates (IWifiP2pIface iface);
+  getP2pIface(string ifname) generates (StatusCode status, IWifiP2pIface iface);
 
   /**
    * Create an STA iface on the chip.
@@ -281,29 +352,41 @@
    * may fail if we've already reached the maximum allowed
    * (specified in |ChipIfaceCombination|) number of ifaces of the STA type.
    *
+   * @return status Status of the operation.
+   *         Possible status codes:
+   *         |StatusCode.SUCCESS|,
+   *         |StatusCode.ERROR_WIFI_CHIP_INVALID|
    * @return iface HIDL interface object representing the iface if
    *         successful, null otherwise.
    */
-  createStaIface() generates (IWifiStaIface iface);
+  createStaIface() generates (StatusCode status, IWifiStaIface iface);
 
   /**
    * List all the STA iface names configured on the chip.
    * The corresponding |IWifiStaIface| object for any iface are
    * retrieved using |getStaIface| method.
    *
+   * @return status Status of the operation.
+   *         Possible status codes:
+   *         |StatusCode.SUCCESS|,
+   *         |StatusCode.ERROR_WIFI_CHIP_INVALID|
    * @return ifnames List of all STA iface names on the chip.
    */
-  getStaIfaceNames() generates (vec<string> ifnames);
+  getStaIfaceNames() generates (StatusCode status, vec<string> ifnames);
 
   /**
    * Gets a HIDL interface object for the STA Iface corresponding
    * to the provided ifname.
    *
    * @param ifname Name of the iface.
+   * @return status Status of the operation.
+   *         Possible status codes:
+   *         |StatusCode.SUCCESS|,
+   *         |StatusCode.ERROR_WIFI_CHIP_INVALID|
    * @return iface HIDL interface object representing the iface if
    *         it exists, null otherwise.
    */
-  getStaIface(string ifname) generates (IWifiStaIface iface);
+  getStaIface(string ifname) generates (StatusCode status, IWifiStaIface iface);
 
   /**
    * Create a RTTController instance.
@@ -316,6 +399,11 @@
    *
    * @param boundIface HIDL interface object representing the iface if
    *        the responder must be bound to a specific iface, null otherwise.
+   * @return status Status of the operation.
+   *         Possible status codes:
+   *         |StatusCode.SUCCESS|,
+   *         |StatusCode.ERROR_WIFI_CHIP_INVALID|
    */
-  createRttController(IWifiIface boundIface) generates (IWifiRttController rtt);
+  createRttController(IWifiIface boundIface)
+      generates (StatusCode status, IWifiRttController rtt);
 };
diff --git a/wifi/1.0/IWifiIface.hal b/wifi/1.0/IWifiIface.hal
index f4150e7..726a973 100644
--- a/wifi/1.0/IWifiIface.hal
+++ b/wifi/1.0/IWifiIface.hal
@@ -23,14 +23,22 @@
   /**
    * Get the type of this iface.
    *
+   * @return status Status of the operation.
+   *         Possible status codes:
+   *         |StatusCode.SUCCESS|,
+   *         |StatusCode.ERROR_WIFI_IFACE_INVALID|
    * @return type One of the supported iface types.
    */
-  getType() generates (IfaceType type);
+  getType() generates (StatusCode status, IfaceType type);
 
   /**
    * Get the name of this iface.
    *
+   * @return status Status of the operation.
+   *         Possible status codes:
+   *         |StatusCode.SUCCESS|,
+   *         |StatusCode.ERROR_WIFI_IFACE_INVALID|
    * @return name Name of the iface.
    */
-  getName() generates (string name);
+  getName() generates (StatusCode status, string name);
 };
diff --git a/wifi/1.0/IWifiRttController.hal b/wifi/1.0/IWifiRttController.hal
index d735da7..cc827bb 100644
--- a/wifi/1.0/IWifiRttController.hal
+++ b/wifi/1.0/IWifiRttController.hal
@@ -25,8 +25,12 @@
   /**
    * Get the iface on which the RTT operations will be performed.
    *
+   * @return status Status of the operation.
+   *         Possible status codes:
+   *         |StatusCode.SUCCESS|,
+   *         |StatusCode.ERROR_WIFI_RTT_CONTROLLER_INVALID|
    * @return boundIface HIDL interface object representing the iface if bound
    *         to a specific iface, null otherwise
    */
-  getBoundIface() generates (IWifiIface boundIface);
+  getBoundIface() generates (StatusCode status, IWifiIface boundIface);
 };
diff --git a/wifi/1.0/IWifiStaIface.hal b/wifi/1.0/IWifiStaIface.hal
index a738ebe..402385b 100644
--- a/wifi/1.0/IWifiStaIface.hal
+++ b/wifi/1.0/IWifiStaIface.hal
@@ -213,24 +213,37 @@
    *
    * @param callback An instance of the |IWifiStaIfaceEventCallback| HIDL interface
    *        object.
+   * @return status Status of the operation.
+   *         Possible status codes:
+   *         |StatusCode.SUCCESS|,
+   *         |StatusCode.ERROR_WIFI_IFACE_INVALID|
    */
-  oneway registerEventCallback(IWifiStaIfaceEventCallback callback);
+  registerEventCallback(IWifiStaIfaceEventCallback callback)
+      generates (StatusCode status);
 
   /**
    * Get the capabilities supported by this STA iface.
    *
+   * @return status Status of the operation.
+   *         Possible status codes:
+   *         |StatusCode.SUCCESS|,
+   *         |StatusCode.ERROR_WIFI_IFACE_INVALID|
    * @return capabilities Bitset of |StaIfaceCapabilityMask| values.
    */
-  getCapabilities() generates (uint64_t capabilities);
+  getCapabilities() generates (StatusCode status, uint64_t capabilities);
 
   /**
    * Used to query additional information about the chip's APF capabilities.
    * Will fail if |StaIfaceCapabilityMask.APF| is not set.
    *
+   * @return status Status of the operation.
+   *         Possible status codes:
+   *         |StatusCode.SUCCESS|,
+   *         |StatusCode.ERROR_WIFI_IFACE_INVALID|
    * @return capabilities Instance of |ApfPacketFilterCapabilities|.
    */
   getApfPacketFilterCapabilities()
-      generates (ApfPacketFilterCapabilities capabilities);
+      generates (StatusCode status, ApfPacketFilterCapabilities capabilities);
 
   /**
    * Installs an APF program on this iface, replacing an existing
@@ -238,18 +251,27 @@
    * Will fail if |StaIfaceCapabilityMask.APF| is not set.
    *
    * @param cmdId command Id to use for this invocation.
-   * @param program APF Program to be set.
+   * @param APF Program to be set.
+   * @return status Status of the operation.
+   *         Possible status codes:
+   *         |StatusCode.SUCCESS|,
+   *         |StatusCode.ERROR_WIFI_IFACE_INVALID|
    */
-  oneway installApfPacketFilter(CommandId cmdId, vec<uint8_t> program);
+  installApfPacketFilter(CommandId cmdId, vec<uint8_t> program)
+      generates (StatusCode status);
 
   /**
    * Used to query additional information about the chip's APF capabilities.
    * Will fail if |StaIfaceCapabilityMask.BACKGROUND_SCAN| is not set.
    *
+   * @return status Status of the operation.
+   *         Possible status codes:
+   *         |StatusCode.SUCCESS|,
+   *         |StatusCode.ERROR_WIFI_IFACE_INVALID|
    * @return capabilities Instance of |BackgroundScanCapabilities|.
    */
   getBackgroundScanCapabilities()
-      generates (BackgroundScanCapabilities capabilities);
+      generates (StatusCode status, BackgroundScanCapabilities capabilities);
 
   /**
    * Start a background scan using the given cmdId as an identifier. Only one
@@ -278,14 +300,23 @@
    * WIFI_SCAN_FLAG_INTERRUPTED flag set.
    *
    * @param cmdId command Id to use for this invocation.
-   * @param params Background scan parameters.
+   * @params Background scan parameters.
+   * @return status Status of the operation.
+   *         Possible status codes:
+   *         |StatusCode.SUCCESS|,
+   *         |StatusCode.ERROR_WIFI_IFACE_INVALID|
    */
-  oneway startBackgroundScan(CommandId cmdId, BackgroundScanParameters params);
+  startBackgroundScan(CommandId cmdId, BackgroundScanParameters params)
+      generates (StatusCode status);
 
   /**
    * Stop the background scan started.
    *
    * @param cmdId command Id corresponding to the request.
+   * @return status Status of the operation.
+   *         Possible status codes:
+   *         |StatusCode.SUCCESS|,
+   *         |StatusCode.ERROR_WIFI_IFACE_INVALID|
    */
-  oneway stopBackgroundScan(CommandId cmdId);
+  stopBackgroundScan(CommandId cmdId) generates (StatusCode status);
 };
diff --git a/wifi/1.0/types.hal b/wifi/1.0/types.hal
index cabb97d..25d4fa1 100644
--- a/wifi/1.0/types.hal
+++ b/wifi/1.0/types.hal
@@ -17,9 +17,24 @@
 package android.hardware.wifi@1.0;
 
 /**
- * List of failure reasons returned.
+ * Enum values indicating whether the command processing was successfully
+ * initiated or not.
  */
-enum CommandFailureReason : uint32_t {
+enum StatusCode : uint32_t {
+  /** No errors. Command processing successfully initiated. */
+  SUCCESS,
+  /** Method invoked on an invalid |IWifiChip| object. */
+  ERROR_WIFI_CHIP_INVALID,
+  /** Method invoked on an invalid |IWifiIface| object. */
+  ERROR_WIFI_IFACE_INVALID,
+  /** Method invoked on an invalid |IWifiRttController| object. */
+  ERROR_WIFI_RTT_CONTROLLER_INVALID
+};
+
+/**
+ * List of failure reasons returned in |FailureReason|.
+ */
+enum FailureReasonCode : uint32_t {
   UNKNOWN,
   DUPLICATE_COMMAND_ID,
   NOT_SUPPORTED,
@@ -32,10 +47,11 @@
 
 /**
  * Generic structure to return information about a failure.
+ * The failure reason will be returned in the corresponding |onFailure|
+ * callback.
  */
 struct FailureReason {
-  CommandFailureReason reason;
-
+  FailureReasonCode reason;
   /**
    * A vendor specific error message from the vendor to provide more
    * information beyond the reason code.