1 /* 2 * Copyright (C) 2022 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 17 package com.android.server.wifi.hal; 18 19 import android.annotation.Nullable; 20 21 import java.util.List; 22 23 /** Abstraction of the root Wifi HAL */ 24 public interface IWifiHal { 25 /** 26 * Get the chip corresponding to the provided chipId. 27 * 28 * @param chipId ID of the chip. 29 * @return {@link WifiChip} if successful, null otherwise. 30 */ 31 @Nullable getChip(int chipId)32 WifiChip getChip(int chipId); 33 34 /** 35 * Retrieves the list of all chip id's on the device. 36 * The corresponding |WifiChip| object for any chip can be 37 * retrieved using the |getChip| method. 38 * 39 * @return List of all chip id's on the device, or null if an error occurred. 40 */ 41 @Nullable getChipIds()42 List<Integer> getChipIds(); 43 44 /** 45 * Register for HAL event callbacks. 46 * 47 * @param callback Instance of {@link WifiHal.Callback} 48 * @return true if successful, false otherwise. 49 */ registerEventCallback(WifiHal.Callback callback)50 boolean registerEventCallback(WifiHal.Callback callback); 51 52 /** 53 * Initialize the Wi-Fi HAL service. Must initialize before calling {@link #start()} 54 * 55 * @param deathRecipient Instance of {@link WifiHal.DeathRecipient} 56 */ initialize(WifiHal.DeathRecipient deathRecipient)57 void initialize(WifiHal.DeathRecipient deathRecipient); 58 59 /** 60 * Check if the initialization is complete and the HAL is ready to accept commands. 61 * 62 * @return true if initialization is complete, false otherwise. 63 */ isInitializationComplete()64 boolean isInitializationComplete(); 65 66 /** 67 * Check if the Wi-Fi HAL supported on this device. 68 * 69 * @return true if supported, false otherwise. 70 */ isSupported()71 boolean isSupported(); 72 73 /** 74 * Start the Wi-Fi HAL. 75 * 76 * @return {@link WifiHal.WifiStatusCode} indicating the result. 77 */ start()78 @WifiHal.WifiStatusCode int start(); 79 80 /** 81 * Get the current state of the HAL. 82 * 83 * @return true if started, false otherwise. 84 */ isStarted()85 boolean isStarted(); 86 87 /** 88 * Stop the Wi-Fi HAL. 89 * 90 * Note: Calling stop() and then start() is a valid way of resetting state in 91 * the HAL, driver, and firmware. 92 * 93 * @return true if successful, false otherwise. 94 */ stop()95 boolean stop(); 96 97 /** 98 * Invalidate the Wi-Fi HAL. Call when a significant error occurred external to the root 99 * Wi-Fi HAL, for instance in a Wi-Fi chip retrieved from this HAL. 100 */ invalidate()101 void invalidate(); 102 } 103