| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 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 android.net.wifi; |
| 18 | |
| 19 | import android.net.DhcpInfo; |
| 20 | |
| 21 | /** |
| 22 | * Native calls for sending requests to the supplicant daemon, and for |
| 23 | * receiving asynchronous events. All methods of the form "xxxxCommand()" |
| 24 | * must be single-threaded, to avoid requests and responses initiated |
| 25 | * from multiple threads from being intermingled. |
| 26 | * <p/> |
| 27 | * Note that methods whose names are not of the form "xxxCommand()" do |
| 28 | * not talk to the supplicant daemon. |
| 29 | * |
| 30 | * {@hide} |
| 31 | */ |
| 32 | public class WifiNative { |
| 33 | |
| 34 | static final int BLUETOOTH_COEXISTENCE_MODE_ENABLED = 0; |
| 35 | static final int BLUETOOTH_COEXISTENCE_MODE_DISABLED = 1; |
| 36 | static final int BLUETOOTH_COEXISTENCE_MODE_SENSE = 2; |
| 37 | |
| 38 | public native static String getErrorString(int errorCode); |
| 39 | |
| 40 | public native static boolean loadDriver(); |
| 41 | |
| 42 | public native static boolean unloadDriver(); |
| 43 | |
| 44 | public native static boolean startSupplicant(); |
| 45 | |
| 46 | public native static boolean stopSupplicant(); |
| 47 | |
| 48 | public native static boolean connectToSupplicant(); |
| 49 | |
| 50 | public native static void closeSupplicantConnection(); |
| 51 | |
| 52 | public native static boolean pingCommand(); |
| 53 | |
| Mike Lockwood | a5ec95c | 2009-07-08 17:11:17 -0400 | [diff] [blame] | 54 | public native static boolean scanCommand(boolean forceActive); |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 55 | |
| 56 | public native static boolean setScanModeCommand(boolean setActive); |
| 57 | |
| 58 | public native static String listNetworksCommand(); |
| 59 | |
| 60 | public native static int addNetworkCommand(); |
| 61 | |
| 62 | public native static boolean setNetworkVariableCommand(int netId, String name, String value); |
| 63 | |
| 64 | public native static String getNetworkVariableCommand(int netId, String name); |
| 65 | |
| 66 | public native static boolean removeNetworkCommand(int netId); |
| 67 | |
| 68 | public native static boolean enableNetworkCommand(int netId, boolean disableOthers); |
| 69 | |
| 70 | public native static boolean disableNetworkCommand(int netId); |
| 71 | |
| 72 | public native static boolean reconnectCommand(); |
| 73 | |
| 74 | public native static boolean reassociateCommand(); |
| 75 | |
| 76 | public native static boolean disconnectCommand(); |
| 77 | |
| 78 | public native static String statusCommand(); |
| 79 | |
| 80 | public native static int getRssiCommand(); |
| 81 | |
| Robert Greenwalt | 91f22f90 | 2009-06-08 18:15:21 -0700 | [diff] [blame] | 82 | public native static int getRssiApproxCommand(); |
| 83 | |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 84 | public native static int getLinkSpeedCommand(); |
| 85 | |
| 86 | public native static String getMacAddressCommand(); |
| 87 | |
| 88 | public native static String scanResultsCommand(); |
| 89 | |
| 90 | public native static boolean startDriverCommand(); |
| 91 | |
| 92 | public native static boolean stopDriverCommand(); |
| 93 | |
| 94 | /** |
| 95 | * Start filtering out multicast packets, to reduce battery consumption |
| 96 | * that would result from processing them, only to discard them. |
| 97 | * @return {@code true} if the operation succeeded, {@code false} otherwise |
| 98 | */ |
| 99 | public native static boolean startPacketFiltering(); |
| 100 | |
| 101 | /** |
| 102 | * Stop filtering out multicast packets. |
| 103 | * @return {@code true} if the operation succeeded, {@code false} otherwise |
| 104 | */ |
| 105 | public native static boolean stopPacketFiltering(); |
| 106 | |
| 107 | public native static boolean setPowerModeCommand(int mode); |
| 108 | |
| 109 | public native static boolean setNumAllowedChannelsCommand(int numChannels); |
| 110 | |
| 111 | public native static int getNumAllowedChannelsCommand(); |
| 112 | |
| 113 | /** |
| 114 | * Sets the bluetooth coexistence mode. |
| 115 | * |
| 116 | * @param mode One of {@link #BLUETOOTH_COEXISTENCE_MODE_DISABLED}, |
| 117 | * {@link #BLUETOOTH_COEXISTENCE_MODE_ENABLED}, or |
| 118 | * {@link #BLUETOOTH_COEXISTENCE_MODE_SENSE}. |
| 119 | * @return Whether the mode was successfully set. |
| 120 | */ |
| 121 | public native static boolean setBluetoothCoexistenceModeCommand(int mode); |
| The Android Open Source Project | b2a3dd8 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 122 | |
| 123 | /** |
| 124 | * Enable or disable Bluetooth coexistence scan mode. When this mode is on, |
| 125 | * some of the low-level scan parameters used by the driver are changed to |
| 126 | * reduce interference with A2DP streaming. |
| 127 | * |
| 128 | * @param isSet whether to enable or disable this mode |
| 129 | * @return {@code true} if the command succeeded, {@code false} otherwise. |
| 130 | */ |
| 131 | public native static boolean setBluetoothCoexistenceScanModeCommand(boolean setCoexScanMode); |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 132 | |
| 133 | public native static boolean saveConfigCommand(); |
| 134 | |
| 135 | public native static boolean reloadConfigCommand(); |
| 136 | |
| 137 | public native static boolean setScanResultHandlingCommand(int mode); |
| 138 | |
| 139 | public native static boolean addToBlacklistCommand(String bssid); |
| 140 | |
| 141 | public native static boolean clearBlacklistCommand(); |
| 142 | |
| 143 | public native static boolean doDhcpRequest(DhcpInfo results); |
| 144 | |
| 145 | public native static String getDhcpError(); |
| 146 | |
| 147 | /** |
| 148 | * Wait for the supplicant to send an event, returning the event string. |
| 149 | * @return the event string sent by the supplicant. |
| 150 | */ |
| 151 | public native static String waitForEvent(); |
| 152 | } |