• 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  *
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 
getErrorString(int errorCode)38     public native static String getErrorString(int errorCode);
39 
loadDriver()40     public native static boolean loadDriver();
41 
unloadDriver()42     public native static boolean unloadDriver();
43 
startSupplicant()44     public native static boolean startSupplicant();
45 
stopSupplicant()46     public native static boolean stopSupplicant();
47 
connectToSupplicant()48     public native static boolean connectToSupplicant();
49 
closeSupplicantConnection()50     public native static void closeSupplicantConnection();
51 
pingCommand()52     public native static boolean pingCommand();
53 
scanCommand(boolean forceActive)54     public native static boolean scanCommand(boolean forceActive);
55 
setScanModeCommand(boolean setActive)56     public native static boolean setScanModeCommand(boolean setActive);
57 
listNetworksCommand()58     public native static String listNetworksCommand();
59 
addNetworkCommand()60     public native static int addNetworkCommand();
61 
setNetworkVariableCommand(int netId, String name, String value)62     public native static boolean setNetworkVariableCommand(int netId, String name, String value);
63 
getNetworkVariableCommand(int netId, String name)64     public native static String getNetworkVariableCommand(int netId, String name);
65 
removeNetworkCommand(int netId)66     public native static boolean removeNetworkCommand(int netId);
67 
enableNetworkCommand(int netId, boolean disableOthers)68     public native static boolean enableNetworkCommand(int netId, boolean disableOthers);
69 
disableNetworkCommand(int netId)70     public native static boolean disableNetworkCommand(int netId);
71 
reconnectCommand()72     public native static boolean reconnectCommand();
73 
reassociateCommand()74     public native static boolean reassociateCommand();
75 
disconnectCommand()76     public native static boolean disconnectCommand();
77 
statusCommand()78     public native static String statusCommand();
79 
getRssiCommand()80     public native static int getRssiCommand();
81 
getRssiApproxCommand()82     public native static int getRssiApproxCommand();
83 
getLinkSpeedCommand()84     public native static int getLinkSpeedCommand();
85 
getMacAddressCommand()86     public native static String getMacAddressCommand();
87 
scanResultsCommand()88     public native static String scanResultsCommand();
89 
startDriverCommand()90     public native static boolean startDriverCommand();
91 
stopDriverCommand()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      */
startPacketFiltering()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      */
stopPacketFiltering()105     public native static boolean stopPacketFiltering();
106 
setPowerModeCommand(int mode)107     public native static boolean setPowerModeCommand(int mode);
108 
setNumAllowedChannelsCommand(int numChannels)109     public native static boolean setNumAllowedChannelsCommand(int numChannels);
110 
getNumAllowedChannelsCommand()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      */
setBluetoothCoexistenceModeCommand(int mode)121     public native static boolean setBluetoothCoexistenceModeCommand(int mode);
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      */
setBluetoothCoexistenceScanModeCommand(boolean setCoexScanMode)131     public native static boolean setBluetoothCoexistenceScanModeCommand(boolean setCoexScanMode);
132 
saveConfigCommand()133     public native static boolean saveConfigCommand();
134 
reloadConfigCommand()135     public native static boolean reloadConfigCommand();
136 
setScanResultHandlingCommand(int mode)137     public native static boolean setScanResultHandlingCommand(int mode);
138 
addToBlacklistCommand(String bssid)139     public native static boolean addToBlacklistCommand(String bssid);
140 
clearBlacklistCommand()141     public native static boolean clearBlacklistCommand();
142 
doDhcpRequest(DhcpInfo results)143     public native static boolean doDhcpRequest(DhcpInfo results);
144 
getDhcpError()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      */
waitForEvent()151     public native static String waitForEvent();
152 }
153