1 /* 2 * Copyright (C) 2021 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package com.android.server.wifi; 17 18 import android.annotation.NonNull; 19 import android.net.MacAddress; 20 import android.net.wifi.SoftApConfiguration; 21 22 import com.android.server.wifi.WifiNative.HostapdDeathEventHandler; 23 import com.android.server.wifi.WifiNative.SoftApHalCallback; 24 25 import java.io.PrintWriter; 26 import java.util.List; 27 28 /** Abstraction of HAL interface */ 29 interface IHostapdHal { 30 /** 31 * Begin initializing the IHostapdHal object. Specific initialization logic differs 32 * between the HIDL and AIDL implementations. 33 * 34 * @return true if the initialization routine was successful 35 */ initialize()36 boolean initialize(); 37 38 /** 39 * Start hostapd daemon. 40 */ startDaemon()41 boolean startDaemon(); 42 43 /** 44 * Enable/Disable verbose logging. 45 * 46 * @param verboseEnabled true to enable, false to disable. 47 * @param halVerboseEnabled true to enable hal verbose logging, false to disable. 48 */ enableVerboseLogging(boolean verboseEnabled, boolean halVerboseEnabled)49 void enableVerboseLogging(boolean verboseEnabled, boolean halVerboseEnabled); 50 51 /** 52 * Add and start a new access point. 53 * 54 * @param ifaceName Name of the interface. 55 * @param config Configuration to use for the AP. 56 * @param isMetered Indicates the network is metered or not. Ignored in AIDL imp. 57 * @param isUsingMultiLinkOperation Indicate the AP is using MLO or not. 58 * @param onFailureListener A runnable to be triggered on failure. 59 * @return true on success, false otherwise. 60 */ addAccessPoint(@onNull String ifaceName, @NonNull SoftApConfiguration config, boolean isMetered, boolean isUsingMultiLinkOperation, @NonNull List<String> instanceIdentities, Runnable onFailureListener)61 boolean addAccessPoint(@NonNull String ifaceName, 62 @NonNull SoftApConfiguration config, boolean isMetered, 63 boolean isUsingMultiLinkOperation, @NonNull List<String> instanceIdentities, 64 Runnable onFailureListener); 65 66 /** 67 * Remove a previously started access point. 68 * 69 * @param ifaceName Name of the interface. 70 * @return true on success, false otherwise. 71 */ removeAccessPoint(@onNull String ifaceName)72 boolean removeAccessPoint(@NonNull String ifaceName); 73 74 /** 75 * Remove a previously connected client. 76 * 77 * @param ifaceName Name of the interface. 78 * @param client Mac Address of the client. 79 * @param reasonCode One of disconnect reason code which defined in {@link WifiManager}. 80 * @return true on success, false otherwise. 81 */ forceClientDisconnect(@onNull String ifaceName, @NonNull MacAddress client, int reasonCode)82 boolean forceClientDisconnect(@NonNull String ifaceName, 83 @NonNull MacAddress client, int reasonCode); 84 85 /** 86 * Register the provided callback handler for SoftAp events. 87 * <p> 88 * Note that only one callback can be registered at a time - any registration overrides previous 89 * registrations. 90 * 91 * @param ifaceName Name of the interface. 92 * @param callback Callback listener for AP events. 93 * @return true on success, false on failure. 94 */ registerApCallback(@onNull String ifaceName, @NonNull SoftApHalCallback callback)95 boolean registerApCallback(@NonNull String ifaceName, 96 @NonNull SoftApHalCallback callback); 97 98 /** 99 * Returns whether or not the hostapd supports getting the AP info from the callback. 100 */ isApInfoCallbackSupported()101 boolean isApInfoCallbackSupported(); 102 103 /** 104 * Registers a death notification for hostapd. 105 * @return Returns true on success. 106 */ registerDeathHandler(@onNull HostapdDeathEventHandler handler)107 boolean registerDeathHandler(@NonNull HostapdDeathEventHandler handler); 108 109 /** 110 * Deregisters a death notification for hostapd. 111 * @return Returns true on success. 112 */ deregisterDeathHandler()113 boolean deregisterDeathHandler(); 114 115 /** 116 * Signals whether Initialization started successfully. 117 */ isInitializationStarted()118 boolean isInitializationStarted(); 119 120 /** 121 * Signals whether Initialization completed successfully. 122 */ isInitializationComplete()123 boolean isInitializationComplete(); 124 125 /** 126 * Terminate the hostapd daemon & wait for it's death. 127 */ terminate()128 void terminate(); 129 130 /** 131 * Dump information about the specific implementation. 132 */ dump(PrintWriter pw)133 void dump(PrintWriter pw); 134 135 /** 136 * Removes an existing link from multiple link device which the current AP resides on. 137 * Note: It is being implemented for AIDL interface only. 138 * 139 * @param ifaceName Name of the iface. 140 * @param apIfaceInstance The identity of the link which associated to the multiple link device 141 * that the current AP resides on. 142 */ removeLinkFromMultipleLinkBridgedApIface(@onNull String ifaceName, @NonNull String apIfaceInstance)143 default void removeLinkFromMultipleLinkBridgedApIface(@NonNull String ifaceName, 144 @NonNull String apIfaceInstance) {}; 145 } 146