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 27 /** Abstraction of HAL interface */ 28 interface IHostapdHal { 29 /** 30 * Begin initializing the IHostapdHal object. Specific initialization logic differs 31 * between the HIDL and AIDL implementations. 32 * 33 * @return true if the initialization routine was successful 34 */ initialize()35 boolean initialize(); 36 37 /** 38 * Start hostapd daemon. 39 */ startDaemon()40 boolean startDaemon(); 41 42 /** 43 * Enable/Disable verbose logging. 44 * 45 * @param verboseEnabled true to enable, false to disable. 46 * @param halVerboseEnabled true to enable hal verbose logging, false to disable. 47 */ enableVerboseLogging(boolean verboseEnabled, boolean halVerboseEnabled)48 void enableVerboseLogging(boolean verboseEnabled, boolean halVerboseEnabled); 49 50 /** 51 * Add and start a new access point. 52 * 53 * @param ifaceName Name of the interface. 54 * @param config Configuration to use for the AP. 55 * @param isMetered Indicates the network is metered or not. Ignored in AIDL imp. 56 * @param onFailureListener A runnable to be triggered on failure. 57 * @return true on success, false otherwise. 58 */ addAccessPoint(@onNull String ifaceName, @NonNull SoftApConfiguration config, boolean isMetered, Runnable onFailureListener)59 boolean addAccessPoint(@NonNull String ifaceName, 60 @NonNull SoftApConfiguration config, boolean isMetered, 61 Runnable onFailureListener); 62 63 /** 64 * Remove a previously started access point. 65 * 66 * @param ifaceName Name of the interface. 67 * @return true on success, false otherwise. 68 */ removeAccessPoint(@onNull String ifaceName)69 boolean removeAccessPoint(@NonNull String ifaceName); 70 71 /** 72 * Remove a previously connected client. 73 * 74 * @param ifaceName Name of the interface. 75 * @param client Mac Address of the client. 76 * @param reasonCode One of disconnect reason code which defined in {@link WifiManager}. 77 * @return true on success, false otherwise. 78 */ forceClientDisconnect(@onNull String ifaceName, @NonNull MacAddress client, int reasonCode)79 boolean forceClientDisconnect(@NonNull String ifaceName, 80 @NonNull MacAddress client, int reasonCode); 81 82 /** 83 * Register the provided callback handler for SoftAp events. 84 * <p> 85 * Note that only one callback can be registered at a time - any registration overrides previous 86 * registrations. 87 * 88 * @param ifaceName Name of the interface. 89 * @param callback Callback listener for AP events. 90 * @return true on success, false on failure. 91 */ registerApCallback(@onNull String ifaceName, @NonNull SoftApHalCallback callback)92 boolean registerApCallback(@NonNull String ifaceName, 93 @NonNull SoftApHalCallback callback); 94 95 /** 96 * Returns whether or not the hostapd supports getting the AP info from the callback. 97 */ isApInfoCallbackSupported()98 boolean isApInfoCallbackSupported(); 99 100 /** 101 * Registers a death notification for hostapd. 102 * @return Returns true on success. 103 */ registerDeathHandler(@onNull HostapdDeathEventHandler handler)104 boolean registerDeathHandler(@NonNull HostapdDeathEventHandler handler); 105 106 /** 107 * Deregisters a death notification for hostapd. 108 * @return Returns true on success. 109 */ deregisterDeathHandler()110 boolean deregisterDeathHandler(); 111 112 /** 113 * Signals whether Initialization started successfully. 114 */ isInitializationStarted()115 boolean isInitializationStarted(); 116 117 /** 118 * Signals whether Initialization completed successfully. 119 */ isInitializationComplete()120 boolean isInitializationComplete(); 121 122 /** 123 * Terminate the hostapd daemon & wait for it's death. 124 */ terminate()125 void terminate(); 126 127 /** 128 * Dump information about the specific implementation. 129 */ dump(PrintWriter pw)130 void dump(PrintWriter pw); 131 } 132