• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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  * Also, note that all WifiNative calls should happen in the
30  * WifiStateTracker class except for waitForEvent() call which is
31  * on a separate monitor channel for WifiMonitor
32  *
33  * {@hide}
34  */
35 public class WifiNative {
36 
37     static final int BLUETOOTH_COEXISTENCE_MODE_ENABLED = 0;
38     static final int BLUETOOTH_COEXISTENCE_MODE_DISABLED = 1;
39     static final int BLUETOOTH_COEXISTENCE_MODE_SENSE = 2;
40 
getErrorString(int errorCode)41     public native static String getErrorString(int errorCode);
42 
loadDriver()43     public native static boolean loadDriver();
44 
unloadDriver()45     public native static boolean unloadDriver();
46 
startSupplicant()47     public native static boolean startSupplicant();
48 
stopSupplicant()49     public native static boolean stopSupplicant();
50 
connectToSupplicant()51     public native static boolean connectToSupplicant();
52 
closeSupplicantConnection()53     public native static void closeSupplicantConnection();
54 
pingCommand()55     public native static boolean pingCommand();
56 
scanCommand(boolean forceActive)57     public native static boolean scanCommand(boolean forceActive);
58 
setScanModeCommand(boolean setActive)59     public native static boolean setScanModeCommand(boolean setActive);
60 
listNetworksCommand()61     public native static String listNetworksCommand();
62 
addNetworkCommand()63     public native static int addNetworkCommand();
64 
setNetworkVariableCommand(int netId, String name, String value)65     public native static boolean setNetworkVariableCommand(int netId, String name, String value);
66 
getNetworkVariableCommand(int netId, String name)67     public native static String getNetworkVariableCommand(int netId, String name);
68 
removeNetworkCommand(int netId)69     public native static boolean removeNetworkCommand(int netId);
70 
enableNetworkCommand(int netId, boolean disableOthers)71     public native static boolean enableNetworkCommand(int netId, boolean disableOthers);
72 
disableNetworkCommand(int netId)73     public native static boolean disableNetworkCommand(int netId);
74 
reconnectCommand()75     public native static boolean reconnectCommand();
76 
reassociateCommand()77     public native static boolean reassociateCommand();
78 
disconnectCommand()79     public native static boolean disconnectCommand();
80 
statusCommand()81     public native static String statusCommand();
82 
getRssiCommand()83     public native static int getRssiCommand();
84 
getRssiApproxCommand()85     public native static int getRssiApproxCommand();
86 
getLinkSpeedCommand()87     public native static int getLinkSpeedCommand();
88 
getMacAddressCommand()89     public native static String getMacAddressCommand();
90 
scanResultsCommand()91     public native static String scanResultsCommand();
92 
startDriverCommand()93     public native static boolean startDriverCommand();
94 
stopDriverCommand()95     public native static boolean stopDriverCommand();
96 
97     /**
98      * Start filtering out multicast packets, to reduce battery consumption
99      * that would result from processing them, only to discard them.
100      * @return {@code true} if the operation succeeded, {@code false} otherwise
101      */
startPacketFiltering()102     public native static boolean startPacketFiltering();
103 
104     /**
105      * Stop filtering out multicast packets.
106      * @return {@code true} if the operation succeeded, {@code false} otherwise
107      */
stopPacketFiltering()108     public native static boolean stopPacketFiltering();
109 
setPowerModeCommand(int mode)110     public native static boolean setPowerModeCommand(int mode);
111 
getPowerModeCommand()112     public native static int getPowerModeCommand();
113 
setNumAllowedChannelsCommand(int numChannels)114     public native static boolean setNumAllowedChannelsCommand(int numChannels);
115 
getNumAllowedChannelsCommand()116     public native static int getNumAllowedChannelsCommand();
117 
118     /**
119      * Sets the bluetooth coexistence mode.
120      *
121      * @param mode One of {@link #BLUETOOTH_COEXISTENCE_MODE_DISABLED},
122      *            {@link #BLUETOOTH_COEXISTENCE_MODE_ENABLED}, or
123      *            {@link #BLUETOOTH_COEXISTENCE_MODE_SENSE}.
124      * @return Whether the mode was successfully set.
125      */
setBluetoothCoexistenceModeCommand(int mode)126     public native static boolean setBluetoothCoexistenceModeCommand(int mode);
127 
128     /**
129      * Enable or disable Bluetooth coexistence scan mode. When this mode is on,
130      * some of the low-level scan parameters used by the driver are changed to
131      * reduce interference with A2DP streaming.
132      *
133      * @param isSet whether to enable or disable this mode
134      * @return {@code true} if the command succeeded, {@code false} otherwise.
135      */
setBluetoothCoexistenceScanModeCommand(boolean setCoexScanMode)136     public native static boolean setBluetoothCoexistenceScanModeCommand(boolean setCoexScanMode);
137 
saveConfigCommand()138     public native static boolean saveConfigCommand();
139 
reloadConfigCommand()140     public native static boolean reloadConfigCommand();
141 
setScanResultHandlingCommand(int mode)142     public native static boolean setScanResultHandlingCommand(int mode);
143 
addToBlacklistCommand(String bssid)144     public native static boolean addToBlacklistCommand(String bssid);
145 
clearBlacklistCommand()146     public native static boolean clearBlacklistCommand();
147 
doDhcpRequest(DhcpInfo results)148     public native static boolean doDhcpRequest(DhcpInfo results);
149 
getDhcpError()150     public native static String getDhcpError();
151 
setSuspendOptimizationsCommand(boolean enabled)152     public native static boolean setSuspendOptimizationsCommand(boolean enabled);
153 
154     /**
155      * Wait for the supplicant to send an event, returning the event string.
156      * @return the event string sent by the supplicant.
157      */
waitForEvent()158     public native static String waitForEvent();
159 }
160