Android 8.0 WIFI差異分析
128860 ワード
========================================================================
/packages/apps/Settings/src/com/android/settings/wifi/WifiMasterSwitchPreferenceController.java
mWifiEnabler = new WifiEnabler
(mContext, new MasterSwitchController(mWifiPreference),mMetricsFeatureProvider);
/packages/apps/Settings/src/com/android/settings/wifi/WifiSettings.java
new WifiEnabler(activity, new SwitchBarController(activity.getSwitchBar()),mMetricsFeatureProvider);
========================================================================
/packages/apps/Settings/src/com/android/settings/widget/MasterSwitchController.java
public class MasterSwitchController extends SwitchWidgetController implements
Preference.OnPreferenceChangeListener { // 【Preference (bar ) onPreferenceChange】
private final MasterSwitchPreference mPreference;
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
if (mListener != null) {
return mListener.onSwitchToggled((Boolean) newValue);// 【 WifiEnabler.java】
}
return false;
}
protected OnSwitchChangeListener mListener;
public void setListener(OnSwitchChangeListener listener) {
mListener = listener;
}
} MasterSwitchController ↑
WifiEnabler(Context context, SwitchWidgetController switchWidget,
MetricsFeatureProvider metricsFeatureProvider,ConnectivityManagerWrapper connectivityManagerWrapper) {
mSwitchWidget = switchWidget;
mSwitchWidget.setListener(this);
//【 WifiEnabler SwitchWidgetController .mListener 】
========================================================================
/packages/apps/Settings/src/com/android/settings/wifi/WifiEnabler.java
public class WifiEnabler implements SwitchWidgetController.OnSwitchChangeListener { // 【 】
private final SwitchWidgetController mSwitchWidget; 【BAR 】
private final WifiManager mWifiManager;
@Override
public boolean onSwitchToggled(boolean isChecked) {
//Do nothing if called as a result of a state machine event
if (mStateMachineEvent) {
return true;
}
// Show toast message if Wi-Fi is not allowed in airplane mode
if (isChecked && !WirelessUtils.isRadioAllowed(mContext, Settings.Global.RADIO_WIFI)) {
Toast.makeText(mContext, R.string.wifi_in_airplane_mode, Toast.LENGTH_SHORT).show();
// Reset switch to off. No infinite check/listenenr loop.
mSwitchWidget.setChecked(false);
return false;
}
// Disable tethering if enabling Wifi
if (mayDisableTethering(isChecked)) {
mConnectivityManager.stopTethering(ConnectivityManager.TETHERING_WIFI);
}
if (isChecked) {
mMetricsFeatureProvider.action(mContext, MetricsEvent.ACTION_WIFI_ON);
} else {
// Log if user was connected at the time of switching off.
mMetricsFeatureProvider.action(mContext, MetricsEvent.ACTION_WIFI_OFF,
mConnected.get());
}
if (!mWifiManager.setWifiEnabled(isChecked)) {
// Error
mSwitchWidget.setEnabled(true);
Toast.makeText(mContext, R.string.wifi_error, Toast.LENGTH_SHORT).show();
}
return true;
}
:
1. MasterSwitchController WIFI Preference, Preference on/off
, onPreferenceChange 。
2. MasterSwitchController OnSwitchChangeListener , WifiEnabler ,
WifiEnabler mSwitchWidget.setListener(this);
3. switch WifiEnabler onSwitchToggled WifiManager
/frameworks/base/wifi/java/android/net/wifi/WifiManager.java
mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
mWifiManager.setWifiEnabled(isChecked)
"new WifiManager"
public class WifiManager {
IWifiManager mService; // WifiManager , Client Service
public boolean setWifiEnabled(boolean enabled) {
try {
// IWifiManager setWifiEnabled
return mService.setWifiEnabled(mContext.getOpPackageName(), enabled);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
}
=========================================================================
/frameworks/base/core/java/android/app/SystemServiceRegistry.java
registerService(Context.WIFI_SERVICE, WifiManager.class,new CachedServiceFetcher() {
@Override
public WifiManager createService(ContextImpl ctx) throws ServiceNotFoundException {
IBinder b = ServiceManager.getServiceOrThrow(Context.WIFI_SERVICE 【"wifi"】);
IWifiManager service = IWifiManager.Stub.asInterface(b);
return new WifiManager(ctx.getOuterContext(), service,ConnectivityThread.getInstanceLooper());
}}); //【 WifiManager wifi, IWifiManager Client 】
【 Binder Service 】
=========================================================================
/frameworks/base/wifi/java/android/net/wifi/IWifiManager.aidl AIDL
interface IWifiManager
{
void disconnect();
void reconnect();
void reassociate();
WifiInfo getConnectionInfo();
boolean setWifiEnabled(String packageName, boolean enable);
......
}
// 【 Service adb shell services list 】
public class WifiServiceImpl extends IWifiManager.Stub {
@Override
public synchronized boolean setWifiEnabled(String packageName, boolean enable)
throws RemoteException {
enforceChangePermission();
Slog.d(TAG, "setWifiEnabled: " + enable + " pid=" + Binder.getCallingPid()
+ ", uid=" + Binder.getCallingUid() + ", package=" + packageName);
mLog.trace("setWifiEnabled package=% uid=% enable=%").c(packageName)
.c(Binder.getCallingUid()).c(enable).flush();
// If SoftAp is enabled, only Settings is allowed to toggle wifi
boolean apEnabled =
mWifiStateMachine.syncGetWifiApState() != WifiManager.WIFI_AP_STATE_DISABLED;
boolean isFromSettings = checkNetworkSettingsPermission();
if (apEnabled && !isFromSettings) {
mLog.trace("setWifiEnabled SoftAp not disabled: only Settings can enable wifi").flush();
return false;
}
/*
* Caller might not have WRITE_SECURE_SETTINGS,
* only CHANGE_WIFI_STATE is enforced
*/
long ident = Binder.clearCallingIdentity();
try {
if (! mSettingsStore.handleWifiToggled(enable)) {
// Nothing to do if wifi cannot be toggled
return true;
}
} finally {
Binder.restoreCallingIdentity(ident);
}
if (mPermissionReviewRequired) {
final int wiFiEnabledState = getWifiEnabledState();
if (enable) {
if (wiFiEnabledState == WifiManager.WIFI_STATE_DISABLING
|| wiFiEnabledState == WifiManager.WIFI_STATE_DISABLED) {
if (startConsentUi(packageName, Binder.getCallingUid(),
WifiManager.ACTION_REQUEST_ENABLE)) {
return true;
}
}
} else if (wiFiEnabledState == WifiManager.WIFI_STATE_ENABLING
|| wiFiEnabledState == WifiManager.WIFI_STATE_ENABLED) {
if (startConsentUi(packageName, Binder.getCallingUid(),
WifiManager.ACTION_REQUEST_DISABLE)) {
return true;
}
}
}
// static final int CMD_WIFI_TOGGLED = BASE + 8; sendMessage mWifiController
mWifiController.sendMessage(CMD_WIFI_TOGGLED); // 【 BASE + 8】
return true;
}
}
=========================================================================
/frameworks/opt/net/wifi/service/java/com/android/server/wifi/WifiController.java
public class WifiController extends StateMachine {
@override sendMessage(int what); // sendMessage
}
public class StateMachine {
private static class SmHandler extends Handler {} // SmHandler StateMachine
public void sendMessage(int what) {
// mSmHandler can be null if the state machine has quit.
SmHandler smh = mSmHandler;
if (smh == null) return;
smh.sendMessage(obtainMessage(what)); // CMD_WIFI_TOGGLED Message
}
private void initStateMachine(String name, Looper looper) {
mName = name;
mSmHandler = new SmHandler(looper, this); // SmHandler
}
@Override
public final void handleMessage(Message msg) {
if (!mHasQuit) {
if (mSm != null && msg.what != SM_INIT_CMD && msg.what != SM_QUIT_CMD) {
mSm.onPreHandleMessage(msg);
}
if (mDbg) mSm.log("handleMessage: E msg.what=" + msg.what);
/** Save the current message */
mMsg = msg;
/** State that processed the message */
State msgProcessedState = null;
if (mIsConstructionCompleted) {
/** Normal path */
msgProcessedState = processMsg(msg); //【 】
} else if (!mIsConstructionCompleted && (mMsg.what == SM_INIT_CMD)
&& (mMsg.obj == mSmHandlerObj)) {
/** Initial one time path. */
mIsConstructionCompleted = true;
invokeEnterMethods(0);
} else {
throw new RuntimeException("StateMachine.handleMessage: "
+ "The start method not called, received msg: " + msg);
}
performTransitions(msgProcessedState, msg); // 【 enter 】
// We need to check if mSm == null here as we could be quitting.
if (mDbg && mSm != null) mSm.log("handleMessage: X");
if (mSm != null && msg.what != SM_INIT_CMD && msg.what != SM_QUIT_CMD) {
mSm.onPostHandleMessage(msg); // 【 】
}
}
}
}
private class StateInfo { //
/** The state */
State state;
/** The parent of this state, null if there is no parent */
StateInfo parentStateInfo;
/** True when the state has been entered and on the stack */
boolean active;
/**
* Convert StateInfo to string
*/
@Override
public String toString() {
return "state=" + state.getName() + ",active=" + active + ",parent="
+ ((parentStateInfo == null) ? "null" : parentStateInfo.state.getName());
}
/**
* Process the message. If the current state doesn't handle
* it, call the states parent and so on. If it is never handled then
* call the state machines unhandledMessage method.
* @return the state that processed the message
*/
private final State processMsg(Message msg) { //【 , 】
// private StateInfo mStateStack[]; mStateStack = new StateInfo[maxDepth];
// private int mStateStackTopIndex = -1;
StateInfo curStateInfo = mStateStack[mStateStackTopIndex];
if (mDbg) {
mSm.log("processMsg: " + curStateInfo.state.getName());
}
if (isQuit(msg)) {
transitionTo(mQuittingState);
} else {
while (!curStateInfo.state.processMessage(msg)) {
// processMessage
/**
* Not processed
*/
curStateInfo = curStateInfo.parentStateInfo; //
if (curStateInfo == null) { // while
/**
* No parents left so it's not handled
*/
mSm.unhandledMessage(msg);
break;
}
if (mDbg) {
mSm.log("processMsg: " + curStateInfo.state.getName());
}
}
}
return (curStateInfo != null) ? curStateInfo.state : null; //
}
class StaDisabledWithScanState extends State {
@Override
public boolean processMessage(Message msg) {
switch (msg.what) {
case CMD_WIFI_TOGGLED:
if (mSettingsStore.isWifiToggleEnabled()) { //
if (doDeferEnable(msg)) {
if (mHaveDeferredEnable) {
// have 2 toggles now, inc serial number and ignore both
mDeferredEnableSerialNumber++;
}
mHaveDeferredEnable = !mHaveDeferredEnable;
break;
}
if (mDeviceIdle == false) {
transitionTo(mDeviceActiveState); // enter
} else {
checkLocksAndTransitionWhenDeviceIdle();
}
}
}
return HANDLED;
}
private final void transitionTo(IState destState) {
if (mTransitionInProgress) {
Log.wtf(mSm.mName, "transitionTo called while transition already in progress to " +
mDestState + ", new target state=" + destState);
}
mDestState = (State) destState; // mDestState , enter
if (mDbg) mSm.log("transitionTo: destState=" + mDestState.getName());
}
private void performTransitions(State msgProcessedState, Message msg ) {
/** exit enter
* If transitionTo has been called, exit and then enter
* the appropriate states. We loop on this to allow
* enter and exit methods to use transitionTo.
*/
State orgState = mStateStack[mStateStackTopIndex].state; //
State destState = mDestState; //
if (destState != null) {
while (true) {
if (mDbg) mSm.log("handleMessage: new destination call exit/enter");
/**
* Determine the states to exit and enter and return the
* common ancestor state of the enter/exit states. Then
* invoke the exit methods then the enter methods.
*/
// null enter
StateInfo commonStateInfo = setupTempStateStackWithStatesToEnter(destState);
// flag is cleared in invokeEnterMethods before entering the target state
mTransitionInProgress = true;
invokeExitMethods(commonStateInfo); // exit
int stateStackEnteringIndex = moveTempStateStackToStateStack(); enter
invokeEnterMethods(stateStackEnteringIndex); // enter
/**
* Since we have transitioned to a new state we need to have
* any deferred messages moved to the front of the message queue
* so they will be processed before any other messages in the
* message queue.
*/
moveDeferredMessageAtFrontOfQueue();
if (destState != mDestState) {
// A new mDestState so continue looping
destState = mDestState;
} else {
// No change in mDestState so we're done
break; // enter exit while
}
}
mDestState = null;
}
class StaEnabledState extends State {} enter
class StaEnabledState extends State {
@Override
public void enter() {
mWifiStateMachine.setSupplicantRunning(true); // WIFI mWifiStateMachine
}}
class ApStaDisabledState extends State {
@Override
public void enter() {
mWifiStateMachine.setSupplicantRunning(false); // WIFI
}}
========================================================================
WifiController.java
import com.android.internal.util.State;
class DefaultState extends State {
class ApStaDisabledState extends State {
class StaEnabledState extends State {
class StaDisabledWithScanState extends State {
class ApEnabledState extends State {
class EcmState extends State {
class DeviceActiveState extends State {
class DeviceInactiveState extends State {
class ScanOnlyLockHeldState extends State {
class FullLockHeldState extends State {
class FullHighPerfLockHeldState extends State {
class NoLockHeldState extends State {
WifiController.java
addState(mDefaultState);
addState(mApStaDisabledState, mDefaultState);
addState(mStaEnabledState, mDefaultState);
addState(mDeviceActiveState, mStaEnabledState);
addState(mDeviceInactiveState, mStaEnabledState);
addState(mScanOnlyLockHeldState, mDeviceInactiveState);
addState(mFullLockHeldState, mDeviceInactiveState);
addState(mFullHighPerfLockHeldState, mDeviceInactiveState);
addState(mNoLockHeldState, mDeviceInactiveState);
addState(mStaDisabledWithScanState, mDefaultState);
addState(mApEnabledState, mDefaultState);
addState(mEcmState, mDefaultState);
StateMachine.java
HaltingState extends State {
QuittingState extends State {
/frameworks/base/core/java/com/android/internal/util/State.java
public class State implements IState {
protected State() {
}
public void enter() { //
}
public void exit() { //
}
public boolean processMessage(Message msg) { //
return false;
}
}
/frameworks/opt/net/wifi/service/java/com/android/server/wifi/WifiStateMachine.java
addState(mDefaultState);
addState(mInitialState, mDefaultState);
addState(mSupplicantStartingState, mDefaultState);
addState(mSupplicantStartedState, mDefaultState);
addState(mScanModeState, mSupplicantStartedState);
addState(mConnectModeState, mSupplicantStartedState);
addState(mL2ConnectedState, mConnectModeState);
addState(mObtainingIpState, mL2ConnectedState);
addState(mConnectedState, mL2ConnectedState);
addState(mRoamingState, mL2ConnectedState);
addState(mDisconnectingState, mConnectModeState);
addState(mDisconnectedState, mConnectModeState);
addState(mWpsRunningState, mConnectModeState);
addState(mWaitForP2pDisableState, mSupplicantStartedState);
addState(mSupplicantStoppingState, mDefaultState);
addState(mSoftApState, mDefaultState);
========================================================================
public class WifiController extends StateMachine { // StateMachine WifiStateMachine
private final WifiStateMachine mWifiStateMachine;
class StaEnabledState extends State {
@Override
public void enter() {
mWifiStateMachine.setSupplicantRunning(true); // WIFI mWifiStateMachine
}}
}
frameworks/opt/net/wifi/service/java/com/android/server/wifi/WifiInjector.java
public class WifiInjector {
private final WifiNative mWifiNative;
private final WifiStateMachine mWifiStateMachine;
private final WifiController mWifiController;
mWifiNative = new WifiNative(SystemProperties.get("wifi.interface", "wlan0"),
mWifiVendorHal, mSupplicantStaIfaceHal, mWificondControl);
mWifiStateMachine = new WifiStateMachine(mContext, mFrameworkFacade,
wifiStateMachineLooper, UserManager.get(mContext),
this, mBackupManagerProxy, mCountryCode, mWifiNative);
mWifiController = new WifiController(mContext, mWifiStateMachine, mSettingsStore,
mLockManager, mWifiServiceHandlerThread.getLooper(), mFrameworkFacade);
}
WifiStateMachine.java
public void setSupplicantRunning(boolean enable) {
if (enable) {
sendMessage(CMD_START_SUPPLICANT); // SUPPLICANT StateMachine sendMessage
} else {
sendMessage(CMD_STOP_SUPPLICANT);
}
}
public void sendMessage(int what) {
// mSmHandler can be null if the state machine has quit.
SmHandler smh = mSmHandler;
if (smh == null) return;
smh.sendMessage(obtainMessage(what【BASE + 11】));
}
// CMD_START_SUPPLICANT Message StateMachine handleMessage
// processMessage enter exit
@Override
public final void handleMessage(Message msg) {
State msgProcessedState = null;
msgProcessedState = processMsg(msg); //【 】
performTransitions(msgProcessedState, msg); // 【 enter 】
mSm.onPostHandleMessage(msg); // 【 】
}
class InitialState extends State {
public boolean processMessage(Message message) {
switch (message.what) {
case CMD_START_SUPPLICANT:
mClientInterface = mWifiNative.setupForClientMode();
mWifiNative.enableSupplicant();
setSupplicantLogLevel();
transitionTo(mSupplicantStartingState);
// InitialState SupplicantStartingState
}
}
****************************************************************
// InitialState SupplicantStartingState
/frameworks/opt/net/wifi/service/java/com/android/server/wifi/WifiNative.java
class WifiNative {
public boolean enableSupplicant() {
return mWificondControl.enableSupplicant();
}
}
/frameworks/opt/net/wifi/service/java/com/android/server/wifi/WificondControl.java
public class WificondControl {
private IClientInterface mClientInterface; // 【 ? 】
public boolean enableSupplicant() {
if (mClientInterface == null) {
Log.e(TAG, "No valid wificond client interface handler");
return false;
}
try {
return mClientInterface.enableSupplicant();
} catch (RemoteException e) {
Log.e(TAG, "Failed to enable supplicant due to remote exception");
}
return false;
}
}
IClientInterface.aidl
1.Java import android.net.wifi.IClientInterface; IClientInterface.java
2.C #include "android/net/wifi/BnClientInterface.h" BnClientInterface.h
/system/connectivity/wificond/aidl/android/net/wifi/IClientInterface.aidl
IClientInterface.aidl IClientInterface.Stub
interface IClientInterface {
boolean enableSupplicant();
boolean disableSupplicant();
int[] getPacketCounters();
int[] signalPoll();
byte[] getMacAddress();
@utf8InCpp String getInterfaceName();
@nullable IWifiScannerImpl getWifiScannerImpl();
boolean requestANQP(in byte[] bssid, IANQPDoneCallback callback);
}
AIDL C /system/connectivity/wificond/client_interface_binder.cpp ?
!!
===============
/system/connectivity/wificond/client_interface_binder.cpp
8 Java-C AIDL
: /system/connectivity/wificond/client_interface_binder.h
//【 android::net::wifi::BnClientInterface IClientInterface.aidl ?】
//【 IClientInterface.Stub ?】
//【/system/connectivity/wificond/aidl/android/net/wifi/IClientInterface.aidl .h
// android/net/wifi/BnClientInterface.h ?】
#include "android/net/wifi/BnClientInterface.h" //
class ClientInterfaceBinder : public android::net::wifi::BnClientInterface { // IClientInterface.aidl
Status ClientInterfaceBinder::enableSupplicant(bool* success) { // IPC ?
*success = impl_ && impl_->EnableSupplicant(); // ClientInterfaceImpl.cpp EnableSupplicant
return Status::ok();
}
private: ClientInterfaceImpl* impl_;
}
-----------------
/system/connectivity/wificond/client_interface_impl.cpp
android::wifi_system::SupplicantManager* const supplicant_manager_;
bool ClientInterfaceImpl::EnableSupplicant() {
return supplicant_manager_->StartSupplicant();
}
/frameworks/opt/net/wifi/libwifi_system/include/wifi_system/supplicant_manager.h
class SupplicantManager {
virtual bool StartSupplicant();
}
/frameworks/opt/net/wifi/libwifi_system/supplicant_manager.cpp
bool SupplicantManager::StartSupplicant() {
sched_yield(); // Linux Supplicant
while (count-- > 0) {
if (strcmp(supp_status, "running") == 0) {
return true;
}
}
}
======================================
Java-Java AIDL
XXXXX.aidl{
private android.os.IBinder mRemote; // mRemote Binder.BinderProxy
int aidlMethod(int val ){
android.os.Parcel _data = android.os.Parcel.obtain();
android.os.Parcel _reply = android.os.Parcel.obtain();
_data.writeInterfaceToken(DESCRIPTOR); // Parcel
_data.writeInt(val);
mRemote.transact(Stub.TRANSACTION_getVal, _data, _reply, 0); // JNI _reply
_reply.readException();
_result = _reply.readInt(); // Parcel IPC
}
}
Binder.java{ // BinderProxy Binder.java
final class BinderProxy implements IBinder {
public boolean transact(int code, Parcel data, Parcel reply, int flags) throws RemoteException {
return transactNative(code, data, reply, flags);
}
public native boolean transactNative(int code, Parcel data, Parcel reply,int flags) throws RemoteException;
}
}
/frameworks/base/core/jni/android_util_Binder.cpp
{"transactNative", "(ILandroid/os/Parcel;Landroid/os/Parcel;I)Z", (void*)android_os_BinderProxy_transact}
static jboolean android_os_BinderProxy_transact(JNIEnv* env, jobject obj,
jint code, jobject dataObj, jobject replyObj, jint flags) // throws RemoteException
{
status_t err = target->transact(code, *data, reply, flags); // ▲ IPC
if (err == NO_ERROR) { // IPC
return JNI_TRUE;
}
return JNI_FALSE; // cpp JNI_TRUE JNI_FALSE
}
****************************************************************
WifiStateMachine.java
/* The base for wifi message types */
static final int BASE = Protocol.BASE_WIFI;
static final int CMD_START_SUPPLICANT = BASE + 11;
static final int CMD_STOP_SUPPLICANT = BASE + 12;
static final int CMD_STATIC_IP_SUCCESS = BASE + 15;
static final int CMD_STATIC_IP_FAILURE = BASE + 16;
static final int CMD_DRIVER_START_TIMED_OUT = BASE + 19;
static final int CMD_START_AP = BASE + 21;
static final int CMD_START_AP_FAILURE = BASE + 22;
static final int CMD_STOP_AP = BASE + 23;
static final int CMD_AP_STOPPED = BASE + 24;
static final int CMD_BLUETOOTH_ADAPTER_STATE_CHANGE = BASE + 31;
WifiController.java
private static final int BASE = Protocol.BASE_WIFI_CONTROLLER;
static final int CMD_EMERGENCY_MODE_CHANGED = BASE + 1;
static final int CMD_SCREEN_ON = BASE + 2;
static final int CMD_SCREEN_OFF = BASE + 3;
static final int CMD_BATTERY_CHANGED = BASE + 4;
static final int CMD_DEVICE_IDLE = BASE + 5;
static final int CMD_LOCKS_CHANGED = BASE + 6;
static final int CMD_SCAN_ALWAYS_MODE_CHANGED = BASE + 7;
static final int CMD_WIFI_TOGGLED = BASE + 8;
static final int CMD_AIRPLANE_TOGGLED = BASE + 9;
static final int CMD_SET_AP = BASE + 10;
static final int CMD_DEFERRED_TOGGLE = BASE + 11;
static final int CMD_USER_PRESENT = BASE + 12;
static final int CMD_AP_START_FAILURE = BASE + 13;
static final int CMD_EMERGENCY_CALL_STATE_CHANGED = BASE + 14;
static final int CMD_AP_STOPPED = BASE + 15;
static final int CMD_STA_START_FAILURE = BASE + 16;
// Command used to trigger a wifi stack restart when in active mode
static final int CMD_RESTART_WIFI = BASE + 17;
// Internal command used to complete wifi stack restart
private static final int CMD_RESTART_WIFI_CONTINUE = BASE + 18;
========================================================================
/frameworks/opt/net/wifi/service/java/com/android/server/wifi/WifiNative.java
public IClientInterface setupForClientMode() {
if (!startHalIfNecessary(true)) {
Log.e(mTAG, "Failed to start HAL for client mode");
return null;
}
return mWificondControl.setupDriverForClientMode();
}
/**
* Setup driver for client mode via wificond.
* @return An IClientInterface as wificond client interface binder handler.
* Returns null on failure.
*/
public IClientInterface setupDriverForClientMode() {
Log.d(TAG, "Setting up driver for client mode");
mWificond = mWifiInjector.makeWificond();
if (mWificond == null) {
Log.e(TAG, "Failed to get reference to wificond");
return null;
}
IClientInterface clientInterface = null;
try {
clientInterface = mWificond.createClientInterface();
} catch (RemoteException e1) {
Log.e(TAG, "Failed to get IClientInterface due to remote exception");
return null;
}
if (clientInterface == null) {
Log.e(TAG, "Could not get IClientInterface instance from wificond");
return null;
}
Binder.allowBlocking(clientInterface.asBinder());
// Refresh Handlers
mClientInterface = clientInterface;
try {
mClientInterfaceName = clientInterface.getInterfaceName();
mWificondScanner = mClientInterface.getWifiScannerImpl();
if (mWificondScanner == null) {
Log.e(TAG, "Failed to get WificondScannerImpl");
return null;
}
Binder.allowBlocking(mWificondScanner.asBinder());
mScanEventHandler = new ScanEventHandler();
mWificondScanner.subscribeScanEvents(mScanEventHandler);
mPnoScanEventHandler = new PnoScanEventHandler();
mWificondScanner.subscribePnoScanEvents(mPnoScanEventHandler);
} catch (RemoteException e) {
Log.e(TAG, "Failed to refresh wificond scanner due to remote exception");
}
return clientInterface;
}
--------------------------------------------------
mSupplicantStaIfaceHal !!!
mWifiVendorHal !!!
JNI operations
/********************************************************
* JNI operations
********************************************************/
/* Register native functions */
static {
/* Native functions are defined in libwifi-service.so */
System.loadLibrary("wifi-service");
registerNatives();
}
private static native int registerNatives();
/* kernel logging support */
private static native byte[] readKernelLogNative()
/frameworks/opt/net/wifi/service/jni/com_android_server_wifi_WifiNative.cpp
/*
* JNI registration.
*/
static JNINativeMethod gWifiMethods[] = {
/* name, signature, funcPtr */
{"readKernelLogNative", "()[B", (void*)android_net_wifi_readKernelLog},
};
/* User to register native functions */
extern "C"
jint Java_com_android_server_wifi_WifiNative_registerNatives(JNIEnv* env, jclass clazz) {
// initialization needed for unit test APK
JniConstants::init(env);
return jniRegisterNativeMethods(env,
"com/android/server/wifi/WifiNative", gWifiMethods, NELEM(gWifiMethods));
}
}; // namespace android
/frameworks/opt/net/wifi/service/java/com/android/server/wifi/SupplicantStaIfaceHal.java
private SupplicantStaNetworkHal addNetwork() {
synchronized (mLock) {
final String methodStr = "addNetwork";
if (!checkSupplicantStaIfaceAndLogFailure(methodStr)) return null;
Mutable newNetwork = new Mutable<>();
try {
mISupplicantStaIface.addNetwork ((SupplicantStatus status,
ISupplicantNetwork network) -> {
if (checkStatusAndLogFailure(status, methodStr)) {
newNetwork.value = network;
} //
}) ;
checkSupplicantStaIfaceAndLogFailure(methodStr) ?
checkStatusAndLogFailure?
final String methodStr = "addNetwork"; mISupplicantStaIface.addNetwork
final String methodStr = "removeNetwork"; mISupplicantStaIface.removeNetwork
final String methodStr = "getNetwork"; mISupplicantStaIface.getNetwork(
final String methodStr = "registerCallback"; mISupplicantStaIface.registerCallback
final String methodStr = "listNetworks"; mISupplicantStaIface.listNetworks((
final String methodStr = "setWpsDeviceName"; mISupplicantStaIface.setWpsDeviceName(name)
final String methodStr = "setWpsDeviceType"; mISupplicantStaIface.setWpsDeviceType(type);
final String methodStr = "setWpsManufacturer"; mISupplicantStaIface.setWpsManufacturer(manufacturer)
final String methodStr = "setWpsModelName"; mISupplicantStaIface.setWpsModelName(modelName);
final String methodStr = "setWpsModelNumber"; mISupplicantStaIface.setWpsModelNumber(modelNumber);
final String methodStr = "setWpsSerialNumber"; mISupplicantStaIface.setWpsSerialNumber(serialNumber);
final String methodStr = "setWpsConfigMethods"; mISupplicantStaIface.setWpsConfigMethods(configMethods);
final String methodStr = "reassociate"; mISupplicantStaIface.reassociate();
final String methodStr = "reconnect"; mISupplicantStaIface.reconnect();
final String methodStr = "disconnect"; mISupplicantStaIface.disconnect();
final String methodStr = "setPowerSave"; mISupplicantStaIface.setPowerSave(enable);
final String methodStr = "initiateTdlsDiscover"; mISupplicantStaIface.initiateTdlsDiscover(macAddress);
final String methodStr = "initiateTdlsSetup"; mISupplicantStaIface.initiateTdlsSetup(macAddress)
final String methodStr = "initiateTdlsTeardown"; mISupplicantStaIface.initiateTdlsTeardown(macAddress);
final String methodStr = "initiateAnqpQuery"; mISupplicantStaIface.initiateAnqpQuery(macAddress,infoElements, subTypes);
final String methodStr = "initiateHs20IconQuery"; mISupplicantStaIface.initiateHs20IconQuery(macAddress,fileName);
final String methodStr = "getMacAddress"; mISupplicantStaIface.getMacAddress((SupplicantStatus status,byte[/* 6 */] macAddr)
final String methodStr = "startRxFilter"; mISupplicantStaIface.startRxFilter();
final String methodStr = "stopRxFilter"; mISupplicantStaIface.stopRxFilter();
final String methodStr = "addRxFilter"; mISupplicantStaIface.addRxFilter(type);
final String methodStr = "removeRxFilter"; mISupplicantStaIface.removeRxFilter(type);
final String methodStr = "setBtCoexistenceMode"; mISupplicantStaIface.setBtCoexistenceMode(mode);
final String methodStr = "setBtCoexistenceScanModeEnabled"; mISupplicantStaIface.setBtCoexistenceScanModeEnabled(enable);
final String methodStr = "setSuspendModeEnabled"; mISupplicantStaIface.setSuspendModeEnabled(enable);
final String methodStr = "setCountryCode"; mISupplicantStaIface.setCountryCode(code);
final String methodStr = "startWpsRegistrar"; mISupplicantStaIface.startWpsRegistrar(bssid, pin);
final String methodStr = "startWpsPbc"; mISupplicantStaIface.startWpsPbc(bssid);
final String methodStr = "startWpsPinKeypad"; mISupplicantStaIface.startWpsPinKeypad(pin);
final String methodStr = "startWpsPinDisplay"; mISupplicantStaIface.startWpsPinDisplay(
final String methodStr = "cancelWps"; mISupplicantStaIface.cancelWps();
final String methodStr = "setExternalSim"; mISupplicantStaIface.setExternalSim(useExternalSim);
final String methodStr = "enableAutoReconnect"; mISupplicantStaIface.enableAutoReconnect(enable);
final String methodStr = "setDebugParams"; mISupplicant.setDebugParams(level, showTimestamp, showKeys);
final String methodStr = "setConcurrencyPriority"; mISupplicant.setConcurrencyPriority(type);
private ISupplicantStaIface mISupplicantStaIface;
private ISupplicant mISupplicant;
private boolean initSupplicantStaIface() {
/** List all supplicant Ifaces */
final ArrayList supplicantIfaces = new ArrayList<>();
try {
mISupplicant.listInterfaces((SupplicantStatus status,
ArrayList ifaces) -> {
if (status.code != SupplicantStatusCode.SUCCESS) {
Log.e(TAG, "Getting Supplicant Interfaces failed: " + status.code);
return;
}
supplicantIfaces.addAll(ifaces);
});
}
// HIDL HAL Interface Define Lagurage
if (supplicantIfaces.size() == 0) {
Log.e(TAG, "Got zero HIDL supplicant ifaces. Stopping supplicant HIDL startup.");
return false;
}
Mutable supplicantIface = new Mutable<>();
Mutable ifaceName = new Mutable<>();
for (ISupplicant.IfaceInfo ifaceInfo : supplicantIfaces) {
if (ifaceInfo.type == IfaceType.STA) {
try { // mISupplicant.getInterface Client Service Proxy IBinder
mISupplicant.getInterface(ifaceInfo,
(SupplicantStatus status, ISupplicantIface【IBinder】 iface) -> {
if (status.code != SupplicantStatusCode.SUCCESS) {
Log.e(TAG, "Failed to get ISupplicantIface " + status.code);
return;
}
supplicantIface.value = iface【IBinder】;
});
} catch (RemoteException e) {
Log.e(TAG, "ISupplicant.getInterface exception: " + e);
return false;
}
ifaceName.value = ifaceInfo.name;
break;
}
}
mISupplicantStaIface = getStaIfaceMockable(supplicantIface.value);
}
private boolean initSupplicantService() {
synchronized (mLock) {
try {
mISupplicant = getSupplicantMockable();
}
}
}
protected ISupplicantStaIface getStaIfaceMockable(ISupplicantIface iface) {
return ISupplicantStaIface.asInterface(iface.asBinder());
}
protected ISupplicant getSupplicantMockable() throws RemoteException {
return ISupplicant.getService();
}
========================================================
/hardware/interfaces/wifi/supplicant/1.0/ISupplicant.hal
package [email protected];
import ISupplicantCallback;
import ISupplicantIface;
interface ISupplicant {
enum DebugLevel : uint32_t {
EXCESSIVE = 0,
MSGDUMP = 1,
DEBUG = 2,
INFO = 3,
WARNING = 4,
ERROR = 5
};
struct IfaceInfo {
IfaceType type;
string name;
};
getInterface(IfaceInfo ifaceInfo)
generates (SupplicantStatus status, ISupplicantIface iface);
listInterfaces() generates (SupplicantStatus status, vec ifaces);
registerCallback(ISupplicantCallback callback) generates (SupplicantStatus status);
setDebugParams(DebugLevel level, bool showTimestamp, bool showKeys) generates (SupplicantStatus status);
getDebugLevel() generates (DebugLevel level);
isDebugShowTimestampEnabled() generates (bool enabled);
isDebugShowKeysEnabled() generates (bool enabled);
setConcurrencyPriority(IfaceType type) generates (SupplicantStatus status);
};
========================================================
/hardware/interfaces/wifi/supplicant/1.0/ISupplicantStaIface.hal
package [email protected];
import ISupplicantIface;
import ISupplicantStaIfaceCallback;
interface ISupplicantStaIface extends ISupplicantIface {
enum AnqpInfoId : uint16_t {
VENUE_NAME = 258,
ROAMING_CONSORTIUM = 261,
IP_ADDR_TYPE_AVAILABILITY = 262,
NAI_REALM = 263,
ANQP_3GPP_CELLULAR_NETWORK = 264,
DOMAIN_NAME = 268
};
enum Hs20AnqpSubtypes : uint32_t {
OPERATOR_FRIENDLY_NAME = 3,
WAN_METRICS = 4,
CONNECTION_CAPABILITY = 5,
OSU_PROVIDERS_LIST = 8,
};
enum RxFilterType : uint8_t {
V4_MULTICAST = 0,
V6_MULTICAST = 1
};
enum BtCoexistenceMode : uint8_t {
ENABLED = 0,
DISABLED = 1,
SENSE = 2
};
enum ExtRadioWorkDefaults : uint32_t {
TIMEOUT_IN_SECS = 10
};
registerCallback(ISupplicantStaIfaceCallback callback) generates (SupplicantStatus status);
reassociate() generates (SupplicantStatus status);
reconnect() generates (SupplicantStatus status);
disconnect() generates (SupplicantStatus status);
setPowerSave(bool enable) generates (SupplicantStatus status);
initiateTdlsDiscover(MacAddress macAddress) generates (SupplicantStatus status);
initiateTdlsSetup(MacAddress macAddress) generates (SupplicantStatus status);
initiateTdlsTeardown(MacAddress macAddress)generates (SupplicantStatus status);
initiateAnqpQuery(MacAddress macAddress,vec infoElements,vec subTypes)
generates (SupplicantStatus status);
initiateHs20IconQuery(MacAddress macAddress, string fileName) generates (SupplicantStatus status);
getMacAddress() generates (SupplicantStatus status, MacAddress macAddr);
startRxFilter() generates (SupplicantStatus status);
stopRxFilter() generates (SupplicantStatus status);
addRxFilter(RxFilterType type) generates (SupplicantStatus status);
removeRxFilter(RxFilterType type) generates (SupplicantStatus status);
setBtCoexistenceMode(BtCoexistenceMode mode) generates (SupplicantStatus status);
setBtCoexistenceScanModeEnabled(bool enable) generates (SupplicantStatus status);
setSuspendModeEnabled(bool enable) generates (SupplicantStatus status);
setCountryCode(int8_t[2] code) generates (SupplicantStatus status);
startWpsRegistrar(Bssid bssid, string pin) generates (SupplicantStatus status);
startWpsPbc(Bssid bssid) generates (SupplicantStatus status);
startWpsPinKeypad(string pin) generates (SupplicantStatus status);
startWpsPinDisplay(Bssid bssid) generates (SupplicantStatus status, string generatedPin);
cancelWps() generates (SupplicantStatus status);
setExternalSim(bool useExternalSim) generates (SupplicantStatus status);
addExtRadioWork(string name, uint32_t freqInMhz, uint32_t timeoutInSec) generates (SupplicantStatus status, uint32_t id);
removeExtRadioWork(uint32_t id) generates (SupplicantStatus status);
enableAutoReconnect(bool enable) generates (SupplicantStatus status);
};
========================================================
/hardware/interfaces/wifi/supplicant/1.0/ISupplicantIface.hal
package [email protected];
import ISupplicantNetwork;
/**
* Interface exposed by the supplicant for each network interface (e.g wlan0)
* it controls.
*/
interface ISupplicantIface {
enum ParamSizeLimits : uint32_t {
WPS_DEVICE_NAME_MAX_LEN = 32,
WPS_MANUFACTURER_MAX_LEN = 64,
WPS_MODEL_NAME_MAX_LEN = 32,
WPS_MODEL_NUMBER_MAX_LEN = 32,
WPS_SERIAL_NUMBER_MAX_LEN = 32
};
getName() generates (SupplicantStatus status, string name);
getType() generates (SupplicantStatus status, IfaceType type);
addNetwork() generates (SupplicantStatus status, ISupplicantNetwork network);
removeNetwork(SupplicantNetworkId id) generates (SupplicantStatus status);
getNetwork(SupplicantNetworkId id) generates (SupplicantStatus status, ISupplicantNetwork network);
listNetworks() generates (SupplicantStatus status, vec networkIds);
setWpsDeviceName(string name) generates (SupplicantStatus status);
setWpsDeviceType(uint8_t[8] type) generates (SupplicantStatus status);
setWpsManufacturer(string manufacturer) generates (SupplicantStatus status);
setWpsModelName(string modelName) generates (SupplicantStatus status);
setWpsModelNumber(string modelNumber) generates (SupplicantStatus status);
setWpsSerialNumber(string serialNumber) generates (SupplicantStatus status);
setWpsConfigMethods(bitfield configMethods) generates (SupplicantStatus status);
};
========================================================
/external/wpa_supplicant_8/wpa_supplicant/hidl/1.0/sta_iface.h
namespace android {
namespace hardware {
namespace wifi {
namespace supplicant {
namespace V1_0 {
namespace implementation {
class StaIface
: public android::hardware::wifi::supplicant::V1_0::ISupplicantStaIface
{ // 【 HIDL ISupplicantStaIface 】
public:
StaIface(struct wpa_global* wpa_global, const char ifname[]);
~StaIface() override = default;
void invalidate();
bool isValid();
// Hidl methods exposed.
Return getName(getName_cb _hidl_cb) override;
Return getType(getType_cb _hidl_cb) override;
Return addNetwork(addNetwork_cb _hidl_cb) override;
Return removeNetwork(SupplicantNetworkId id, removeNetwork_cb _hidl_cb) override;
Return getNetwork(SupplicantNetworkId id, getNetwork_cb _hidl_cb) override;
Return listNetworks(listNetworks_cb _hidl_cb) override;
Return registerCallback(const sp& callback,registerCallback_cb _hidl_cb) override;
Return reassociate(reassociate_cb _hidl_cb) override;
Return reconnect(reconnect_cb _hidl_cb) override;
Return disconnect(disconnect_cb _hidl_cb) override;
Return setPowerSave(bool enable, setPowerSave_cb _hidl_cb) override;
Return initiateTdlsDiscover(const hidl_array& mac_address,initiateTdlsDiscover_cb _hidl_cb) override;
Return initiateTdlsSetup(const hidl_array& mac_address,initiateTdlsSetup_cb _hidl_cb) override;
Return initiateTdlsTeardown(const hidl_array& mac_address,initiateTdlsTeardown_cb _hidl_cb) override;
Return initiateAnqpQuery(const hidl_array& mac_address,const hidl_vec<:anqpinfoid>& info_elements,const hidl_vec<:hs20anqpsubtypes>& sub_types,initiateAnqpQuery_cb _hidl_cb) override;
Return initiateHs20IconQuery(const hidl_array& mac_address,const hidl_string& file_name,initiateHs20IconQuery_cb _hidl_cb) override;
Return getMacAddress(getMacAddress_cb _hidl_cb) override;
Return startRxFilter(startRxFilter_cb _hidl_cb) override;
Return stopRxFilter(stopRxFilter_cb _hidl_cb) override;
Return addRxFilter(ISupplicantStaIface::RxFilterType type,addRxFilter_cb _hidl_cb) override;
Return removeRxFilter(ISupplicantStaIface::RxFilterType type,removeRxFilter_cb _hidl_cb) override;
Return setBtCoexistenceMode(ISupplicantStaIface::BtCoexistenceMode mode,setBtCoexistenceMode_cb _hidl_cb) override;
Return setBtCoexistenceScanModeEnabled(bool enable, setBtCoexistenceScanModeEnabled_cb _hidl_cb) override;
Return setSuspendModeEnabled(bool enable, setSuspendModeEnabled_cb _hidl_cb) override;
Return setCountryCode(const hidl_array& code,setCountryCode_cb _hidl_cb) override;
Return startWpsRegistrar(const hidl_array& bssid, const hidl_string& pin,startWpsRegistrar_cb _hidl_cb) override;
Return startWpsPbc(const hidl_array& bssid,startWpsPbc_cb _hidl_cb) override;
Return startWpsPinKeypad(const hidl_string& pin, startWpsPinKeypad_cb _hidl_cb) override;
Return startWpsPinDisplay(const hidl_array& bssid,startWpsPinDisplay_cb _hidl_cb) override;
Return cancelWps(cancelWps_cb _hidl_cb) override;
Return setWpsDeviceName(const hidl_string& name, setWpsDeviceName_cb _hidl_cb) override;
Return setWpsDeviceType(const hidl_array& type,setWpsDeviceType_cb _hidl_cb) override;
Return setWpsManufacturer(const hidl_string& manufacturer,setWpsManufacturer_cb _hidl_cb) override;
Return setWpsModelName(const hidl_string& model_name,setWpsModelName_cb _hidl_cb) override;
Return setWpsModelNumber(const hidl_string& model_number,setWpsModelNumber_cb _hidl_cb) override;
Return setWpsSerialNumber(const hidl_string& serial_number,setWpsSerialNumber_cb _hidl_cb) override;
Return setWpsConfigMethods(uint16_t config_methods, setWpsConfigMethods_cb _hidl_cb) override;
Return setExternalSim(bool useExternalSim, setExternalSim_cb _hidl_cb) override;
Return addExtRadioWork(const hidl_string& name, uint32_t freq_in_mhz,uint32_t timeout_in_sec, addExtRadioWork_cb _hidl_cb) override;
Return removeExtRadioWork(uint32_t id, removeExtRadioWork_cb _hidl_cb) override;
Return enableAutoReconnect(bool enable, enableAutoReconnect_cb _hidl_cb) override;
=============================================================================
/external/wpa_supplicant_8/wpa_supplicant/hidl/1.0/sta_iface.c
using hidl_return_util::validateAndCall; // HIDL ?
StaIface::StaIface(struct wpa_global *wpa_global, const char ifname[])
: wpa_global_(wpa_global), ifname_(ifname), is_valid_(true)
{
}
Return StaIface::getName(getName_cb _hidl_cb)
{
return validateAndCall(
this, SupplicantStatusCode::FAILURE_IFACE_INVALID,
&StaIface::getNameInternal 【 】, _hidl_cb);
}
Return StaIface::getType(getType_cb _hidl_cb)
{
return validateAndCall(
this【 】, SupplicantStatusCode::FAILURE_IFACE_INVALID【 】,
&StaIface::getTypeInternal 【WorkFuncT 【 】】, _hidl_cb【 】);
}
Return StaIface::enableAutoReconnect(
bool enable, enableAutoReconnect_cb _hidl_cb)
{
return validateAndCall(
this, SupplicantStatusCode::FAILURE_IFACE_INVALID,
&StaIface::enableAutoReconnectInternal【 】, _hidl_cb, enable);
}
template
Return validateAndCall(
ObjT* obj, SupplicantStatusCode status_code_if_invalid, WorkFuncT&& work,
const std::function& hidl_cb, Args&&... args)
{
if (obj->isValid()) {
//【 ObjT , WorkFuncT, WorkFuncT hidl_cb】
hidl_cb((obj->*work)(std::forward(args)...)); //
} else {
//【 ObjT hidl_cb, SupplicantStatusCode::FAILURE_IFACE_INVALID【 】】
hidl_cb({status_code_if_invalid, ""});
}
return Void();
}
template
Return validateAndCall(
ObjT* obj, SupplicantStatusCode status_code_if_invalid, WorkFuncT&& work,
const std::function& hidl_cb,
Args&&... args)
{
if (obj->isValid()) {
const auto& ret_pair =
(obj->*work)(std::forward(args)...);
const SupplicantStatus& status = std::get<0>(ret_pair);
const auto& ret_value = std::get<1>(ret_pair);
hidl_cb(status, ret_value); // 【 , 】
} else {
hidl_cb(
{status_code_if_invalid, ""},
typename std::remove_reference::type());
}
return Void();
}
Return validateAndCall(
ObjT* obj, SupplicantStatusCode status_code_if_invalid, WorkFuncT&& work,
const std::function&
hidl_cb 【 , 】,
Args&&... args)
{
if (obj->isValid()) {
const auto& ret_tuple =
(obj->*work)(std::forward(args)...);
const SupplicantStatus& status = std::get<0>(ret_tuple);
const auto& ret_value1 = std::get<1>(ret_tuple);
const auto& ret_value2 = std::get<2>(ret_tuple);
hidl_cb(status, ret_value1, ret_value2);
} else {
hidl_cb(
{status_code_if_invalid, ""},
typename std::remove_reference::type(),
typename std::remove_reference::type());
}
return Void();
}
/external/wpa_supplicant_8/wpa_supplicant/hidl/1.0/sta_iface.c
Return StaIface::enableAutoReconnect(
bool enable, enableAutoReconnect_cb _hidl_cb)
{
return validateAndCall(
this, SupplicantStatusCode::FAILURE_IFACE_INVALID,
&StaIface::enableAutoReconnectInternal 【 】, _hidl_cb, enable);
}
/external/wpa_supplicant_8/wpa_supplicant/hidl/1.0/sta_iface.c
SupplicantStatus StaIface::enableAutoReconnectInternal(bool enable)
{
struct wpa_supplicant *wpa_s = retrieveIfacePtr();
wpa_s->auto_reconnect_disabled = enable ? 0 : 1; // wpa_s->auto_reconnect_disabled
return {SupplicantStatusCode::SUCCESS, ""}; // ,
}
/external/wpa_supplicant_8/wpa_supplicant/hidl/1.0/sta_iface.c
Return StaIface::getMacAddress(getMacAddress_cb _hidl_cb)
{
return validateAndCall(
this, SupplicantStatusCode::FAILURE_IFACE_INVALID,
&StaIface::getMacAddressInternal, _hidl_cb);
}
constexpr char kGetMacAddress[] = "MACADDR";
StaIface::getMacAddressInternal()
{
struct wpa_supplicant *wpa_s = retrieveIfacePtr();
std::vector cmd(kGetMacAddress 【"MACADDR" 】, kGetMacAddress【 】 + sizeof(kGetMacAddress) 【 】);
char driver_cmd_reply_buf[4096] = {};
// MACADDR driver_cmd_reply_buf"Macaddr = XX:XX:XX:XX:XX:XX"
// ret
int ret = wpa_drv_driver_cmd(wpa_s, cmd.data(), driver_cmd_reply_buf,sizeof(driver_cmd_reply_buf));
// Reply is of the format: "Macaddr = XX:XX:XX:XX:XX:XX"
std::string reply_str = driver_cmd_reply_buf;
//
if (ret < 0 || reply_str.empty() || reply_str.find("=") == std::string::npos) {
return {{SupplicantStatusCode::FAILURE_UNKNOWN, ""}, {}};
}
eply_str.erase(remove_if(reply_str.begin(), reply_str.end(), isspace),reply_str.end());
std::string mac_addr_str =reply_str.substr(reply_str.find("=") + 1, reply_str.size()); // =
std::array mac_addr; //
if (hwaddr_aton(mac_addr_str.c_str(), mac_addr.data())) {
//【hwaddr_aton(const char *txt, u8 *addr)】 Convert ASCII string to MAC address
// 0 on success, -1 on failure MAC address as a string (e.g., "00:11:22:33:44:55")
return {{SupplicantStatusCode::FAILURE_UNKNOWN, ""}, {}};
}
// SupplicantStatusCode mac
return {{SupplicantStatusCode::SUCCESS, ""}, mac_addr};
}
/frameworks/opt/net/wifi/service/java/com/android/server/wifi/SupplicantStaIfaceHal.java
/** See ISupplicant.hal for documentation */
public boolean enableAutoReconnect(boolean enable) {
synchronized (mLock) {
final String methodStr = "enableAutoReconnect";
if (!checkSupplicantAndLogFailure(methodStr)) return false;
try { // enableAutoReconnect
SupplicantStatus status = mISupplicantStaIface.enableAutoReconnect(enable);
return checkStatusAndLogFailure(status, methodStr);
} catch (RemoteException e) {
handleRemoteException(e, methodStr);
return false;
}
}
}
public String getMacAddress() {
synchronized (mLock) {
final String methodStr = "getMacAddress";
if (!checkSupplicantStaIfaceAndLogFailure(methodStr)) return null;
Mutable gotMac = new Mutable<>();
try { // getMacAddress macAddr, ->{} ,
// SupplicantStatus ->{}
mISupplicantStaIface.getMacAddress((SupplicantStatus status,
byte[/* 6 */] macAddr) -> {
if (checkStatusAndLogFailure(status, methodStr)) {
// , {{SupplicantStatusCode::SUCCESS, ""}, mac_addr} mac_addr
gotMac.value = NativeUtil.macAddressFromByteArray(macAddr);
}
});
} catch (RemoteException e) {
handleRemoteException(e, methodStr);
}
return gotMac.value;
}
}
=============================================================================
disconnect .hal -------
disconnect(disconnect_cb _hidl_cb)--->disconnectInternal()--->wpas_request_disconnection(wpa_s)
--->wpa_drv_deauthenticate()--->wpa_s->driver->deauthenticate--->NL80211_CMD_DISCONNECT
/external/wpa_supplicant_8/wpa_supplicant/hidl/1.0/sta_iface.h
Return disconnect(disconnect_cb _hidl_cb) override;
/external/wpa_supplicant_8/wpa_supplicant/hidl/1.0/sta_iface.cpp
Return StaIface::disconnect(disconnect_cb _hidl_cb)
{
return validateAndCall(this, SupplicantStatusCode::FAILURE_IFACE_INVALID, &StaIface::disconnectInternal, _hidl_cb);
}
SupplicantStatus StaIface::disconnectInternal()
{
struct wpa_supplicant *wpa_s = retrieveIfacePtr();
if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED) {
return {SupplicantStatusCode::FAILURE_IFACE_DISABLED, ""};
}
wpas_request_disconnection(wpa_s); //
return {SupplicantStatusCode::SUCCESS, ""};
}
/external/wpa_supplicant_8/wpa_supplicant/wpa_supplicant.c
void wpas_request_disconnection(struct wpa_supplicant *wpa_s)
{
#ifdef CONFIG_SME
wpa_s->sme.prev_bssid_set = 0;
#endif /* CONFIG_SME */
wpa_s->reassociate = 0;
wpa_s->disconnected = 1;
wpa_supplicant_cancel_sched_scan(wpa_s);
wpa_supplicant_cancel_scan(wpa_s);
#define WLAN_REASON_DEAUTH_LEAVING 3
wpa_supplicant_deauthenticate(wpa_s, WLAN_REASON_DEAUTH_LEAVING);
eloop_cancel_timeout(wpas_network_reenabled, wpa_s, NULL);
}
void wpa_supplicant_deauthenticate(struct wpa_supplicant *wpa_s,int reason_code)
{
wpa_drv_deauthenticate(wpa_s, addr, reason_code);
wpa_supplicant_event(wpa_s, EVENT_DEAUTH, &event);
}
/external/wpa_supplicant_8/wpa_supplicant/driver_i.h
static inline int wpa_drv_deauthenticate(struct wpa_supplicant *wpa_s,const u8 *addr, int reason_code)
{
if (wpa_s->driver->deauthenticate) {
return wpa_s->driver->deauthenticate(wpa_s->drv_priv, addr,reason_code); 【 】
}
return -1;
}
/external/wpa_supplicant_8/src/drivers/driver_nl80211.c
//【 nl80211 wpa_s->driver 】
const struct wpa_driver_ops wpa_driver_nl80211_ops = {
// ret = wpa_driver_nl80211_mlme(drv, NULL, NL80211_CMD_DISCONNECT,reason_code, 0);
.deauthenticate = driver_nl80211_deauthenticate,
}
disconnect .hal -------
=============================================================================
/frameworks/opt/net/wifi/service/jni/com_android_server_wifi_WifiNative.cpp
/frameworks/opt/net/wifi/service/java/com/android/server/wifi/WifiNative.java
doBooleanCommand("SET device_name " + name); ======= mSupplicantStaIfaceHal.setWpsDeviceName(name);
doBooleanCommand("SET serial_number " + value); =====mSupplicantStaIfaceHal.setWpsSerialNumber(value);
doBooleanCommand("SET ps 1"); doBooleanCommand("SET ps 0");===mSupplicantStaIfaceHal.setPowerSave(enabled);
doBooleanCommand("DISCONNECT"); =======mSupplicantStaIfaceHal.disconnect();
doBooleanCommand("DRIVER SETSUSPENDMODE 1"); doBooleanCommand("DRIVER SETSUSPENDMODE 0");
======mSupplicantStaIfaceHal.setSuspendModeEnabled(enabled);
:
8.0 JNI ~~~ HIDL , IPC
~~~~
Treable , Framework
,
disconnect(disconnect_cb _hidl_cb)--->disconnectInternal()--->wpas_request_disconnection(wpa_s)
--->wpa_drv_deauthenticate()--->wpa_s->driver->deauthenticate--->NL80211_CMD_DISCONNECT
/external/wpa_supplicant_8/wpa_supplicant/hidl/1.0/sta_iface.h
Return disconnect(disconnect_cb _hidl_cb) override;
/external/wpa_supplicant_8/wpa_supplicant/hidl/1.0/sta_iface.cpp
Return StaIface::disconnect(disconnect_cb _hidl_cb)
{
return validateAndCall(this, SupplicantStatusCode::FAILURE_IFACE_INVALID,&StaIface::disconnectInternal, _hidl_cb);
}
SupplicantStatus StaIface::disconnectInternal()
{
struct wpa_supplicant *wpa_s = retrieveIfacePtr();
if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED) {
return {SupplicantStatusCode::FAILURE_IFACE_DISABLED, ""};
}
wpas_request_disconnection(wpa_s); //
return {SupplicantStatusCode::SUCCESS, ""};
}
/external/wpa_supplicant_8/wpa_supplicant/wpa_supplicant.c
void wpas_request_disconnection(struct wpa_supplicant *wpa_s)
{
#ifdef CONFIG_SME
wpa_s->sme.prev_bssid_set = 0;
#endif /* CONFIG_SME */
wpa_s->reassociate = 0;
wpa_s->disconnected = 1;
wpa_supplicant_cancel_sched_scan(wpa_s);
wpa_supplicant_cancel_scan(wpa_s);
#define WLAN_REASON_DEAUTH_LEAVING 3
wpa_supplicant_deauthenticate(wpa_s, WLAN_REASON_DEAUTH_LEAVING);
eloop_cancel_timeout(wpas_network_reenabled, wpa_s, NULL);
}
void wpa_supplicant_deauthenticate(struct wpa_supplicant *wpa_s,int reason_code)
{
wpa_drv_deauthenticate(wpa_s, addr, reason_code);
wpa_supplicant_event(wpa_s, EVENT_DEAUTH, &event);
}
/external/wpa_supplicant_8/wpa_supplicant/driver_i.h
static inline int wpa_drv_deauthenticate(struct wpa_supplicant *wpa_s,const u8 *addr, int reason_code)
{
if (wpa_s->driver->deauthenticate) {
return wpa_s->driver->deauthenticate(wpa_s->drv_priv, addr,reason_code); 【 】
}
return -1;
}
/external/wpa_supplicant_8/src/drivers/driver_nl80211.c
//【 nl80211 wpa_s->driver 】
const struct wpa_driver_ops wpa_driver_nl80211_ops = {
//ret = wpa_driver_nl80211_mlme(drv, NULL, NL80211_CMD_DISCONNECT,reason_code, 0);
.deauthenticate = driver_nl80211_deauthenticate,
}
【 HIDL 】
// Hidl methods exposed.
Return getName(getName_cb _hidl_cb) override;
Return getType(getType_cb _hidl_cb) override;
Return addNetwork(addNetwork_cb _hidl_cb) override;
Return removeNetwork(SupplicantNetworkId id, removeNetwork_cb _hidl_cb) override;
Return getNetwork(SupplicantNetworkId id, getNetwork_cb _hidl_cb) override;
Return listNetworks(listNetworks_cb _hidl_cb) override;
Return registerCallback(const sp& callback,registerCallback_cb _hidl_cb) override;
Return reassociate(reassociate_cb _hidl_cb) override;
Return reconnect(reconnect_cb _hidl_cb) override;
Return disconnect(disconnect_cb _hidl_cb) override; 【8 disconnect_cb】
Return setPowerSave(bool enable, setPowerSave_cb _hidl_cb) override;
Return initiateTdlsDiscover(const hidl_array& mac_address,initiateTdlsDiscover_cb _hidl_cb) override;
Return initiateTdlsSetup(const hidl_array& mac_address,initiateTdlsSetup_cb _hidl_cb) override;
Return initiateTdlsTeardown(const hidl_array& mac_address,initiateTdlsTeardown_cb _hidl_cb) override;
Return initiateAnqpQuery(const hidl_array& mac_address,const hidl_vec<:anqpinfoid>& info_elements,const hidl_vec<:hs20anqpsubtypes>& sub_types,initiateAnqpQuery_cb _hidl_cb) override;
Return initiateHs20IconQuery(const hidl_array& mac_address,const hidl_string& file_name,initiateHs20IconQuery_cb _hidl_cb) override;
Return getMacAddress(getMacAddress_cb _hidl_cb) override;
Return startRxFilter(startRxFilter_cb _hidl_cb) override;
Return stopRxFilter(stopRxFilter_cb _hidl_cb) override;
Return addRxFilter(ISupplicantStaIface::RxFilterType type,addRxFilter_cb _hidl_cb) override;
Return removeRxFilter(ISupplicantStaIface::RxFilterType type,removeRxFilter_cb _hidl_cb) override;
Return setBtCoexistenceMode(ISupplicantStaIface::BtCoexistenceMode mode,setBtCoexistenceMode_cb _hidl_cb) override;
Return setBtCoexistenceScanModeEnabled(bool enable, setBtCoexistenceScanModeEnabled_cb _hidl_cb) override;
Return setSuspendModeEnabled(bool enable, setSuspendModeEnabled_cb _hidl_cb) override;
Return setCountryCode(const hidl_array& code,setCountryCode_cb _hidl_cb) override;
Return startWpsRegistrar(const hidl_array& bssid, const hidl_string& pin,startWpsRegistrar_cb _hidl_cb) override;
Return startWpsPbc(const hidl_array& bssid,startWpsPbc_cb _hidl_cb) override;
Return startWpsPinKeypad(const hidl_string& pin, startWpsPinKeypad_cb _hidl_cb) override;
Return startWpsPinDisplay(const hidl_array& bssid,startWpsPinDisplay_cb _hidl_cb) override;
Return cancelWps(cancelWps_cb _hidl_cb) override;
Return setWpsDeviceName(const hidl_string& name, setWpsDeviceName_cb _hidl_cb) override;
Return setWpsDeviceType(const hidl_array& type,setWpsDeviceType_cb _hidl_cb) override;
Return setWpsManufacturer(const hidl_string& manufacturer,setWpsManufacturer_cb _hidl_cb) override;
Return setWpsModelName(const hidl_string& model_name,setWpsModelName_cb _hidl_cb) override;
Return setWpsModelNumber(const hidl_string& model_number,setWpsModelNumber_cb _hidl_cb) override;
Return setWpsSerialNumber(const hidl_string& serial_number,setWpsSerialNumber_cb _hidl_cb) override;
Return setWpsConfigMethods(uint16_t config_methods, setWpsConfigMethods_cb _hidl_cb) override;
Return setExternalSim(bool useExternalSim, setExternalSim_cb _hidl_cb) override;
Return addExtRadioWork(const hidl_string& name, uint32_t freq_in_mhz,uint32_t timeout_in_sec, addExtRadioWork_cb _hidl_cb) override;
Return removeExtRadioWork(uint32_t id, removeExtRadioWork_cb _hidl_cb) override;
Return enableAutoReconnect(bool enable, enableAutoReconnect_cb _hidl_cb) override;
=====================================【】===========================
=======================================【1 getName_cb 】===================================
getName(getName_cb _hidl_cb) --->getNameInternal()--->{{SupplicantStatusCode::SUCCESS, ""}, ifname_}
Return getName(getName_cb _hidl_cb) override;
std::pair StaIface::getNameInternal()
{
return {{SupplicantStatusCode::SUCCESS, ""}, ifname_};
}
/external/wpa_supplicant_8/wpa_supplicant/hidl/1.0/sta_iface.h
/external/wpa_supplicant_8/wpa_supplicant/hidl/1.0/sta_iface.cpp
=====================================【2 getType_cb 】==============================================
getType(getType_cb _hidl_cb) ---> getTypeInternal()---> {{SupplicantStatusCode::SUCCESS, ""}, IfaceType::STA}
Return getType(getType_cb _hidl_cb) override;
std::pair StaIface::getTypeInternal()
{
return {{SupplicantStatusCode::SUCCESS, ""}, IfaceType::STA};
}
/external/wpa_supplicant_8/wpa_supplicant/hidl/1.0/sta_iface.h
/external/wpa_supplicant_8/wpa_supplicant/hidl/1.0/sta_iface.cpp
=====================================【3 addNetwork_cb 】===========================
addNetwork(addNetwork_cb _hidl_cb) ---> addNetworkInternal() ---> wpa_supplicant_add_network(wpa_s)
--->wpa_config_add_network(wpa_s->conf)--->wpa_config_add_network()
Return addNetwork(addNetwork_cb _hidl_cb) override;
std::pair>
StaIface::addNetworkInternal()
{
android::sp network;
struct wpa_supplicant *wpa_s = retrieveIfacePtr();
struct wpa_ssid *ssid = wpa_supplicant_add_network(wpa_s);
HidlManager *hidl_manager = HidlManager::getInstance();
hidl_manager->getStaNetworkHidlObjectByIfnameAndNetworkId(wpa_s->ifname, ssid->id, &network)
return {{SupplicantStatusCode::SUCCESS, ""}, network};
}
int HidlManager::getStaNetworkHidlObjectByIfnameAndNetworkId(const std::string &ifname, int network_id,
android::sp *network_object)
{
if (ifname.empty() || network_id < 0 || !network_object) return 1;
// Generate the key to be used to lookup the network.
const std::string network_key = getNetworkObjectMapKey(ifname, network_id);
auto network_object_iter = sta_network_object_map_.find(network_key);
if (network_object_iter == sta_network_object_map_.end()) return 1;
*network_object = network_object_iter->second;
return 0;
}
struct wpa_ssid * wpa_supplicant_add_network(struct wpa_supplicant *wpa_s)
{
struct wpa_ssid *ssid;
ssid = wpa_config_add_network(wpa_s->conf);
wpas_notify_network_added(wpa_s, ssid);
ssid->disabled = 1;
wpa_config_set_network_defaults(ssid);
return ssid;
}
struct wpa_ssid * wpa_config_add_network(struct wpa_config *config)
{
wpa_config_update_prio_list(config);
}
int wpa_config_update_prio_list(struct wpa_config *config)
{
wpa_config_add_prio_network(config, ssid)
}
int wpa_config_add_prio_network(struct wpa_config *config,struct wpa_ssid *ssid){
nlist = os_realloc_array(config->pssid, config->num_prio + 1,sizeof(struct wpa_ssid *));
nlist[prio] = ssid;
}
msg = dbus_message_new_signal(wpa_s->dbus_new_path,WPAS_DBUS_NEW_IFACE_INTERFACE,sig_name)
dbus_message_iter_init_append(msg, &iter);
/external/wpa_supplicant_8/wpa_supplicant/hidl/1.0/sta_iface.h
/external/wpa_supplicant_8/wpa_supplicant/hidl/1.0/sta_iface.cpp
/external/wpa_supplicant_8/wpa_supplicant/hidl/1.0/hidl_manager.cpp
/external/wpa_supplicant_8/wpa_supplicant/config.c
/external/wpa_supplicant_8/wpa_supplicant/dbus/dbus_new.c
=====================================【3 removeNetwork_cb 】===========================
removeNetwork(removeNetwork_cb _hidl_cb) ---> removeNetworkInternal() ---> wpa_supplicant_remove_network(wpa_s)
--->wpa_supplicant_deauthenticate(wpa_s->conf)--->wpa_drv_deauthenticate()--->NL80211_CMD_DISCONNECT
Return removeNetwork(SupplicantNetworkId id, removeNetwork_cb _hidl_cb) override;
SupplicantStatus StaIface::removeNetworkInternal(SupplicantNetworkId id)
{
struct wpa_supplicant *wpa_s = retrieveIfacePtr();
int result = wpa_supplicant_remove_network(wpa_s, id);
}
int wpa_supplicant_remove_network(struct wpa_supplicant *wpa_s, int id)
{
wpa_supplicant_deauthenticate(wpa_s, WLAN_REASON_DEAUTH_LEAVING);
}
void wpa_supplicant_deauthenticate(struct wpa_supplicant *wpa_s,int reason_code)
{
wpa_drv_deauthenticate(wpa_s, addr, reason_code);
}
static inline int wpa_drv_deauthenticate(struct wpa_supplicant *wpa_s,const u8 *addr, int reason_code)
{
return wpa_s->driver->deauthenticate(wpa_s->drv_priv, addr,reason_code);
}
/external/wpa_supplicant_8/wpa_supplicant/hidl/1.0/sta_iface.h
/external/wpa_supplicant_8/wpa_supplicant/hidl/1.0/sta_iface.cpp
/external/wpa_supplicant_8/wpa_supplicant/wpa_supplicant.c
/external/wpa_supplicant_8/wpa_supplicant/driver_i.h
/external/wpa_supplicant_8/src/drivers/driver_nl80211.c
=====================================【4 getNetwork_cb 】===========================
Return getNetwork(SupplicantNetworkId id, getNetwork_cb _hidl_cb) override;
P2pIface::getNetworkInternal(SupplicantNetworkId id)
{
android::sp network;
struct wpa_supplicant* wpa_s = retrieveIfacePtr();
struct wpa_ssid* ssid = wpa_config_get_network(wpa_s->conf, id);
}
=====================================【5 listNetworks_cb 】===========================
Return listNetworks(listNetworks_cb _hidl_cb) override;
StaIface::listNetworksInternal()
{
std::vector network_ids;
struct wpa_supplicant *wpa_s = retrieveIfacePtr();
for (struct wpa_ssid *wpa_ssid = wpa_s->conf->ssid; wpa_ssid;wpa_ssid = wpa_ssid->next) {
network_ids.emplace_back(wpa_ssid->id);
}
return {{SupplicantStatusCode::SUCCESS, ""}, std::move(network_ids)};
}
=====================================【6 registerCallback_cb 】===========================
Return registerCallback(const sp& callback,registerCallback_cb _hidl_cb) override;
SupplicantStatus StaIface::registerCallbackInternal( const sp &callback)
{
HidlManager *hidl_manager = HidlManager::getInstance();
if (!hidl_manager || hidl_manager->addStaIfaceCallbackHidlObject(ifname_, callback)) {
return {SupplicantStatusCode::FAILURE_UNKNOWN, ""};
}
return {SupplicantStatusCode::SUCCESS, ""};
}
=====================================【7 reassociate 】===========================
Return reassociate(reassociate_cb _hidl_cb) override;
SupplicantStatus StaIface::reassociateInternal()
{
struct wpa_supplicant *wpa_s = retrieveIfacePtr();
if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED) {
return {SupplicantStatusCode::FAILURE_IFACE_DISABLED, ""};
}
wpas_request_connection(wpa_s);
return {SupplicantStatusCode::SUCCESS, ""};
}
void wpas_request_connection(struct wpa_supplicant *wpa_s)
{
wpa_supplicant_fast_associate(wpa_s)
}
int wpa_supplicant_fast_associate(struct wpa_supplicant *wpa_s)
{
wpas_select_network_from_last_scan(wpa_s, 0, 1);
}
wpas_select_network_from_last_scan(){
wpa_supplicant_connect(wpa_s, selected, ssid)
}
wpa_supplicant_associate(wpa_s, selected, ssid);
=====================================【7 reconnect_cb 】===========================
Return reconnect(reconnect_cb _hidl_cb) override;
SupplicantStatus StaIface::reconnectInternal()
{
struct wpa_supplicant *wpa_s = retrieveIfacePtr();
wpas_request_connection(wpa_s);
return {SupplicantStatusCode::SUCCESS, ""};
}
void wpas_request_connection(struct wpa_supplicant *wpa_s)
{
wpa_supplicant_reinit_autoscan(wpa_s);
wpa_supplicant_fast_associate(wpa_s)
}
=====================================【8 disconnect_cb】================================
disconnect(disconnect_cb _hidl_cb)--->disconnectInternal()--->wpas_request_disconnection(wpa_s)
--->wpa_drv_deauthenticate()--->wpa_s->driver->deauthenticate--->NL80211_CMD_DISCONNECT
/external/wpa_supplicant_8/wpa_supplicant/hidl/1.0/sta_iface.h
/external/wpa_supplicant_8/wpa_supplicant/hidl/1.0/sta_iface.cpp
/external/wpa_supplicant_8/wpa_supplicant/wpa_supplicant.c
/external/wpa_supplicant_8/wpa_supplicant/driver_i.h
/external/wpa_supplicant_8/src/drivers/driver_nl80211.c
=====================================【 setPowerSave 】===========================
Return setPowerSave(bool enable, setPowerSave_cb _hidl_cb) override;
SupplicantStatus StaIface::setPowerSaveInternal(bool enable)
{
struct wpa_supplicant *wpa_s = retrieveIfacePtr();
wpa_drv_set_p2p_powersave(wpa_s, enable, -1, -1))
return {SupplicantStatusCode::SUCCESS, ""};
}
static inline int wpa_drv_set_p2p_powersave(struct wpa_supplicant *wpa_s,int legacy_ps, int opp_ps,
int ctwindow)
{
if (!wpa_s->driver->set_p2p_powersave) return -1;
return wpa_s->driver->set_p2p_powersave(wpa_s->drv_priv, legacy_ps,opp_ps, ctwindow);
}
=====================================【 getMacAddress 】===========================
Return getMacAddress(getMacAddress_cb _hidl_cb) override;
std::pair>
StaIface::getMacAddressInternal()
{
struct wpa_supplicant *wpa_s = retrieveIfacePtr();
char driver_cmd_reply_buf[4096] = {};
int ret = wpa_drv_driver_cmd(wpa_s, cmd.data(), driver_cmd_reply_buf,
}
static inline int wpa_drv_driver_cmd(struct wpa_supplicant *wpa_s,
char *cmd, char *buf, size_t buf_len)
{
if (!wpa_s->driver->driver_cmd)
return -1;
return wpa_s->driver->driver_cmd(wpa_s->drv_priv, cmd, buf, buf_len);
}
=================================================================================
【 HIDL ? ISupplicantStaIface HIDL ?】
/external/wpa_supplicant_8/wpa_supplicant/hidl/1.0/sta_iface.h
StaIface : public android::hardware::wifi::supplicant::V1_0::ISupplicantStaIface
【 HIDL ? ISupplicant HIDL ?】
/external/wpa_supplicant_8/wpa_supplicant/hidl/1.0/supplicant.h
class Supplicant : public android::hardware::wifi::supplicant::V1_0::ISupplicant
【 HIDL ? ISupplicantP2pIface HIDL ?】
/external/wpa_supplicant_8/wpa_supplicant/hidl/1.0/p2p_iface.h
class P2pIface : public android::hardware::wifi::supplicant::V1_0::ISupplicantP2pIface
/external/wpa_supplicant_8/wpa_supplicant/hidl/1.0/p2p_network.h
【 HIDL ? ISupplicantP2pNetwork HIDL ?】
class P2pNetwork : public ISupplicantP2pNetwork
/external/wpa_supplicant_8/wpa_supplicant/hidl/1.0/sta_network.h
【 HIDL ? ISupplicantStaNetwork HIDL ?】
class StaNetwork : public ISupplicantStaNetwork
/hardware/interfaces/wifi/supplicant/1.0/ISupplicantStaIface.hal 【ok】
/hardware/interfaces/wifi/supplicant/1.0/ISupplicantIface.hal
/hardware/interfaces/wifi/supplicant/1.0/ISupplicant.hal 【ok】
【 #include 】
【 .bp 】
/hardware/interfaces/wifi/supplicant/1.0/ISupplicantCallback.hal
/hardware/interfaces/wifi/supplicant/1.0/ISupplicantNetwork.hal
/hardware/interfaces/wifi/supplicant/1.0/ISupplicantP2pIface.hal 【ok】
/hardware/interfaces/wifi/supplicant/1.0/ISupplicantP2pIfaceCallback.hal
/hardware/interfaces/wifi/supplicant/1.0/ISupplicantP2pNetwork.hal 【ok】
/hardware/interfaces/wifi/supplicant/1.0/ISupplicantP2pNetworkCallback.hal
/hardware/interfaces/wifi/supplicant/1.0/ISupplicantStaIface.hal
/hardware/interfaces/wifi/supplicant/1.0/ISupplicantStaIfaceCallback.hal
/hardware/interfaces/wifi/supplicant/1.0/ISupplicantStaNetwork.hal 【ok】
/hardware/interfaces/wifi/supplicant/1.0/ISupplicantStaNetworkCallback.hal
/hardware/interfaces/wifi/supplicant/1.0/types.hal
interface ISupplicantStaIface extends ISupplicantIface { }
interface ISupplicantIface { }
interface ISupplicant {}
interface ISupplicantCallback {}
interface ISupplicantNetwork {}
interface ISupplicantP2pIface {}
interface ISupplicantP2pIfaceCallback {}
interface ISupplicantP2pNetwork {}
interface ISupplicantP2pNetworkCallback {}
interface ISupplicantStaIface {}
interface ISupplicantStaIfaceCallback {}
interface ISupplicantStaNetwork {}
interface ISupplicantStaNetworkCallback {}
interface types {}
=================================================================================
/hardware/interfaces/wifi/supplicant/1.0/ suplicant HIDL
/external/wpa_supplicant_8/wpa_supplicant/hidl/1.0/ supplicant
/hardware/interfaces/wifi/supplicant/1.0/ 【 supplicant hidl 】
ISupplicant.hal 29-Aug-2017 5.1 KiB
ISupplicantCallback.hal 29-Aug-2017 1.4 KiB
ISupplicantIface.hal 29-Aug-2017 7.8 KiB
ISupplicantNetwork.hal 29-Aug-2017 2.3 KiB
ISupplicantP2pIface.hal 29-Aug-2017 25.7 KiB
ISupplicantP2pIfaceCallback.hal 29-Aug-2017 7.9 KiB
ISupplicantP2pNetwork.hal 29-Aug-2017 4.7 KiB
ISupplicantP2pNetworkCallback.hal 29-Aug-2017 1 KiB
ISupplicantStaIface.hal 29-Aug-2017 16.8 KiB
ISupplicantStaIfaceCallback.hal 29-Aug-2017 17.4 KiB
ISupplicantStaNetwork.hal 29-Aug-2017 36.1 KiB
ISupplicantStaNetworkCallback.hal 29-Aug-2017 2.3 KiB
types.hal 29-Aug-2017 3 KiB
/external/wpa_supplicant_8/wpa_supplicant/hidl/1.0/
hidl.cpp 29-Aug-2017 14.8 KiB
hidl.h 29-Aug-2017 8.2 KiB
hidl_constants.h 29-Aug-2017 578
hidl_i.h 29-Aug-2017 513
hidl_manager.cpp 29-Aug-2017 51.6 KiB
hidl_manager.h 29-Aug-2017 24.7 KiB
hidl_return_util.h 29-Aug-2017 3.2 KiB
iface_config_utils.cpp 29-Aug-2017 5.7 KiB
iface_config_utils.h 29-Aug-2017 1.8 KiB
misc_utils.h 29-Aug-2017 1.8 KiB
p2p_iface.cpp 29-Aug-2017 40 KiB
p2p_iface.h 29-Aug-2017 12.8 KiB
p2p_network.cpp 29-Aug-2017 7.3 KiB
p2p_network.h 29-Aug-2017 3.4 KiB
sta_iface.cpp 29-Aug-2017 30.7 KiB
sta_iface.h 29-Aug-2017 10 KiB
sta_network.cpp 29-Aug-2017 58.5 KiB
sta_network.h 29-Aug-2017 14.3 KiB
supplicant.cpp 29-Aug-2017 5.5 KiB
supplicant.h 29-Aug-2017 2.9 KiB
/hardware/interfaces/wifi/1.0/ wifi hal .hal
/hardware/interfaces/wifi/1.0/default/ .c .h
/hardware/interfaces/wifi/1.0/
IWifi.hal 29-Aug-2017 4.1 KiB
IWifiApIface.hal 29-Aug-2017 1.9 KiB
IWifiChip.hal 29-Aug-2017 26.1 KiB
IWifiChipEventCallback.hal 29-Aug-2017 3.6 KiB
IWifiEventCallback.hal 29-Aug-2017 1.5 KiB
IWifiIface.hal 29-Aug-2017 1.4 KiB
IWifiNanIface.hal 29-Aug-2017 10.3 KiB
IWifiNanIfaceEventCallback.hal 29-Aug-2017 12.4 KiB
IWifiP2pIface.hal 29-Aug-2017 832
IWifiRttController.hal 29-Aug-2017 6.4 KiB
IWifiRttControllerEventCallback.hal 29-Aug-2017 990
IWifiStaIface.hal 29-Aug-2017 20.9 KiB
IWifiStaIfaceEventCallback.hal 29-Aug-2017 2.3 KiB
types.hal 29-Aug-2017 69.4 KiB
/hardware/interfaces/wifi/1.0/default/ // .hal
hidl_callback_util.h 29-Aug-2017 3.6 KiB
hidl_return_util.h 29-Aug-2017 3.8 KiB
hidl_struct_util.cpp 29-Aug-2017 89.7 KiB
hidl_struct_util.h 29-Aug-2017 7 KiB
hidl_sync_util.cpp 29-Aug-2017 1.1 KiB
hidl_sync_util.h 29-Aug-2017 1.2 KiB
service.cpp 29-Aug-2017 1.4 KiB
THREADING.README 29-Aug-2017 1.9 KiB
wifi.cpp 29-Aug-2017 6.6 KiB
wifi.h 29-Aug-2017 2.6 KiB
wifi_ap_iface.cpp 29-Aug-2017 3.6 KiB
wifi_ap_iface.h 29-Aug-2017 2.2 KiB
wifi_chip.cpp 29-Aug-2017 33.1 KiB
wifi_chip.h 29-Aug-2017 9.2 KiB
wifi_feature_flags.h 29-Aug-2017 1.1 KiB
wifi_legacy_hal.cpp 29-Aug-2017 49.9 KiB
wifi_legacy_hal.h 29-Aug-2017 13.7 KiB
wifi_legacy_hal_stubs.cpp 29-Aug-2017 6.1 KiB
wifi_legacy_hal_stubs.h 29-Aug-2017 1.1 KiB
wifi_mode_controller.cpp 29-Aug-2017 2.3 KiB
wifi_mode_controller.h 29-Aug-2017 1.8 KiB
wifi_nan_iface.cpp 29-Aug-2017 29.6 KiB
wifi_nan_iface.h 29-Aug-2017 6.4 KiB
wifi_p2p_iface.cpp 29-Aug-2017 2.1 KiB
wifi_p2p_iface.h 29-Aug-2017 1.8 KiB
wifi_rtt_controller.cpp 29-Aug-2017 11.3 KiB
wifi_rtt_controller.h 29-Aug-2017 4.3 KiB
wifi_sta_iface.cpp 29-Aug-2017 24.5 KiB
wifi_sta_iface.h 29-Aug-2017 7 KiB
wifi_status_util.cpp 29-Aug-2017 3.5 KiB
wifi_status_util.h 29-Aug-2017 1.4 KiB
========================================================================================
/hardware/interfaces/wifi/supplicant/1.0/Android.bp .hal .h
// This file is autogenerated by hidl-gen. Do not edit manually.
filegroup {
name: "[email protected]_hal",
srcs: [
"types.hal",
"ISupplicant.hal",
"ISupplicantCallback.hal",
"ISupplicantIface.hal",
"ISupplicantNetwork.hal",
"ISupplicantP2pIface.hal",
"ISupplicantP2pIfaceCallback.hal",
"ISupplicantP2pNetwork.hal",
"ISupplicantP2pNetworkCallback.hal",
"ISupplicantStaIface.hal",
"ISupplicantStaIfaceCallback.hal",
"ISupplicantStaNetwork.hal",
"ISupplicantStaNetworkCallback.hal",
],
}
genrule {
name: "[email protected]_genc++",
tools: ["hidl-gen"],
cmd: "$(location hidl-gen) -o $(genDir) -Lc++-sources -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport [email protected]",
srcs: [
":[email protected]_hal",
],
out: [
"android/hardware/wifi/supplicant/1.0/types.cpp",
"android/hardware/wifi/supplicant/1.0/SupplicantAll.cpp",
"android/hardware/wifi/supplicant/1.0/SupplicantCallbackAll.cpp",
"android/hardware/wifi/supplicant/1.0/SupplicantIfaceAll.cpp",
"android/hardware/wifi/supplicant/1.0/SupplicantNetworkAll.cpp",
"android/hardware/wifi/supplicant/1.0/SupplicantP2pIfaceAll.cpp",
"android/hardware/wifi/supplicant/1.0/SupplicantP2pIfaceCallbackAll.cpp",
"android/hardware/wifi/supplicant/1.0/SupplicantP2pNetworkAll.cpp",
"android/hardware/wifi/supplicant/1.0/SupplicantP2pNetworkCallbackAll.cpp",
"android/hardware/wifi/supplicant/1.0/SupplicantStaIfaceAll.cpp",
"android/hardware/wifi/supplicant/1.0/SupplicantStaIfaceCallbackAll.cpp",
"android/hardware/wifi/supplicant/1.0/SupplicantStaNetworkAll.cpp",
"android/hardware/wifi/supplicant/1.0/SupplicantStaNetworkCallbackAll.cpp",
],
}
genrule {
name: "[email protected]_genc++_headers",
tools: ["hidl-gen"],
cmd: "$(location hidl-gen) -o $(genDir) -Lc++-headers -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport [email protected]",
srcs: [
":[email protected]_hal",
],
out: [
"android/hardware/wifi/supplicant/1.0/types.h",
"android/hardware/wifi/supplicant/1.0/hwtypes.h",
"android/hardware/wifi/supplicant/1.0/ISupplicant.h",
"android/hardware/wifi/supplicant/1.0/IHwSupplicant.h",
"android/hardware/wifi/supplicant/1.0/BnHwSupplicant.h",
"android/hardware/wifi/supplicant/1.0/BpHwSupplicant.h",
"android/hardware/wifi/supplicant/1.0/BsSupplicant.h",
"android/hardware/wifi/supplicant/1.0/ISupplicantCallback.h",
"android/hardware/wifi/supplicant/1.0/IHwSupplicantCallback.h",
"android/hardware/wifi/supplicant/1.0/BnHwSupplicantCallback.h",
"android/hardware/wifi/supplicant/1.0/BpHwSupplicantCallback.h",
"android/hardware/wifi/supplicant/1.0/BsSupplicantCallback.h",
"android/hardware/wifi/supplicant/1.0/ISupplicantIface.h",
"android/hardware/wifi/supplicant/1.0/IHwSupplicantIface.h",
"android/hardware/wifi/supplicant/1.0/BnHwSupplicantIface.h",
"android/hardware/wifi/supplicant/1.0/BpHwSupplicantIface.h",
"android/hardware/wifi/supplicant/1.0/BsSupplicantIface.h",
"android/hardware/wifi/supplicant/1.0/ISupplicantNetwork.h",
"android/hardware/wifi/supplicant/1.0/IHwSupplicantNetwork.h",
"android/hardware/wifi/supplicant/1.0/BnHwSupplicantNetwork.h",
"android/hardware/wifi/supplicant/1.0/BpHwSupplicantNetwork.h",
"android/hardware/wifi/supplicant/1.0/BsSupplicantNetwork.h",
"android/hardware/wifi/supplicant/1.0/ISupplicantP2pIface.h",
"android/hardware/wifi/supplicant/1.0/IHwSupplicantP2pIface.h",
"android/hardware/wifi/supplicant/1.0/BnHwSupplicantP2pIface.h",
"android/hardware/wifi/supplicant/1.0/BpHwSupplicantP2pIface.h",
"android/hardware/wifi/supplicant/1.0/BsSupplicantP2pIface.h",
"android/hardware/wifi/supplicant/1.0/ISupplicantP2pIfaceCallback.h",
"android/hardware/wifi/supplicant/1.0/IHwSupplicantP2pIfaceCallback.h",
"android/hardware/wifi/supplicant/1.0/BnHwSupplicantP2pIfaceCallback.h",
"android/hardware/wifi/supplicant/1.0/BpHwSupplicantP2pIfaceCallback.h",
"android/hardware/wifi/supplicant/1.0/BsSupplicantP2pIfaceCallback.h",
"android/hardware/wifi/supplicant/1.0/ISupplicantP2pNetwork.h",
"android/hardware/wifi/supplicant/1.0/IHwSupplicantP2pNetwork.h",
"android/hardware/wifi/supplicant/1.0/BnHwSupplicantP2pNetwork.h",
"android/hardware/wifi/supplicant/1.0/BpHwSupplicantP2pNetwork.h",
"android/hardware/wifi/supplicant/1.0/BsSupplicantP2pNetwork.h",
"android/hardware/wifi/supplicant/1.0/ISupplicantP2pNetworkCallback.h",
"android/hardware/wifi/supplicant/1.0/IHwSupplicantP2pNetworkCallback.h",
"android/hardware/wifi/supplicant/1.0/BnHwSupplicantP2pNetworkCallback.h",
"android/hardware/wifi/supplicant/1.0/BpHwSupplicantP2pNetworkCallback.h",
"android/hardware/wifi/supplicant/1.0/BsSupplicantP2pNetworkCallback.h",
"android/hardware/wifi/supplicant/1.0/ISupplicantStaIface.h",
"android/hardware/wifi/supplicant/1.0/IHwSupplicantStaIface.h",
"android/hardware/wifi/supplicant/1.0/BnHwSupplicantStaIface.h",
"android/hardware/wifi/supplicant/1.0/BpHwSupplicantStaIface.h",
"android/hardware/wifi/supplicant/1.0/BsSupplicantStaIface.h",
"android/hardware/wifi/supplicant/1.0/ISupplicantStaIfaceCallback.h",
"android/hardware/wifi/supplicant/1.0/IHwSupplicantStaIfaceCallback.h",
"android/hardware/wifi/supplicant/1.0/BnHwSupplicantStaIfaceCallback.h",
"android/hardware/wifi/supplicant/1.0/BpHwSupplicantStaIfaceCallback.h",
"android/hardware/wifi/supplicant/1.0/BsSupplicantStaIfaceCallback.h",
"android/hardware/wifi/supplicant/1.0/ISupplicantStaNetwork.h",
"android/hardware/wifi/supplicant/1.0/IHwSupplicantStaNetwork.h",
"android/hardware/wifi/supplicant/1.0/BnHwSupplicantStaNetwork.h",
"android/hardware/wifi/supplicant/1.0/BpHwSupplicantStaNetwork.h",
"android/hardware/wifi/supplicant/1.0/BsSupplicantStaNetwork.h",
"android/hardware/wifi/supplicant/1.0/ISupplicantStaNetworkCallback.h",
"android/hardware/wifi/supplicant/1.0/IHwSupplicantStaNetworkCallback.h",
"android/hardware/wifi/supplicant/1.0/BnHwSupplicantStaNetworkCallback.h",
"android/hardware/wifi/supplicant/1.0/BpHwSupplicantStaNetworkCallback.h",
"android/hardware/wifi/supplicant/1.0/BsSupplicantStaNetworkCallback.h",
],
}
cc_library_shared {
name: "[email protected]",
defaults: ["hidl-module-defaults"],
generated_sources: ["[email protected]_genc++"],
generated_headers: ["[email protected]_genc++_headers"],
export_generated_headers: ["[email protected]_genc++_headers"],
vendor_available: true,
shared_libs: [
"libhidlbase",
"libhidltransport",
"libhwbinder",
"liblog",
"libutils",
"libcutils",
"[email protected]",
],
export_shared_lib_headers: [
"libhidlbase",
"libhidltransport",
"libhwbinder",
"libutils",
"[email protected]",
],
}
========================================================================================
/hardware/interfaces/wifi/1.0/default/[email protected]
service wifi_hal_legacy /vendor/bin/hw/[email protected]
class hal
user wifi
group wifi gps
=================================================================================
##############################################
# android8.0 8.0 hal
# Do not change this file except to add new interfaces. Changing
# pre-existing interfaces will fail VTS and break framework-only OTAs
# HALs released in Android O
[email protected]::IDevice
[email protected]::IDevicesFactory
[email protected]::IPrimaryDevice
[email protected]::IStream
[email protected]::IStreamIn
[email protected]::IStreamOut
[email protected]::IStreamOutCallback
[email protected]::types
[email protected]::types
[email protected]::IAcousticEchoCancelerEffect
[email protected]::IAutomaticGainControlEffect
[email protected]::IBassBoostEffect
[email protected]::IDownmixEffect
[email protected]::IEffect
[email protected]::IEffectBufferProviderCallback
[email protected]::IEffectsFactory
[email protected]::IEnvironmentalReverbEffect
[email protected]::IEqualizerEffect
[email protected]::ILoudnessEnhancerEffect
[email protected]::INoiseSuppressionEffect
[email protected]::IPresetReverbEffect
[email protected]::IVirtualizerEffect
[email protected]::IVisualizerEffect
[email protected]::types
[email protected]::IEvsCamera
[email protected]::IEvsCameraStream
[email protected]::IEvsDisplay
[email protected]::IEvsEnumerator
[email protected]::types
[email protected]::IVehicle
[email protected]::IVehicleCallback
[email protected]::types
[email protected]::IBiometricsFingerprint
[email protected]::IBiometricsFingerprintClientCallback
[email protected]::types
[email protected]::IBluetoothHci
[email protected]::IBluetoothHciCallbacks
[email protected]::types
[email protected]::IBootControl
[email protected]::types
[email protected]::IBroadcastRadio
[email protected]::IBroadcastRadioFactory
[email protected]::ITuner
[email protected]::ITunerCallback
[email protected]::types
[email protected]::types
[email protected]::ICameraDevice
[email protected]::ICameraDeviceCallback
[email protected]::ICameraDevicePreviewCallback
[email protected]::types
[email protected]::ICameraDevice
[email protected]::ICameraDeviceCallback
[email protected]::ICameraDeviceSession
[email protected]::types
[email protected]::types
[email protected]::ICameraProvider
[email protected]::ICameraProviderCallback
[email protected]::ISurfaceFlingerConfigs
[email protected]::types
[email protected]::IContexthub
[email protected]::IContexthubCallback
[email protected]::types
[email protected]::ICryptoFactory
[email protected]::ICryptoPlugin
[email protected]::IDrmFactory
[email protected]::IDrmPlugin
[email protected]::IDrmPluginListener
[email protected]::types
[email protected]::IDumpstateDevice
[email protected]::IGatekeeper
[email protected]::types
[email protected]::IAGnss
[email protected]::IAGnssCallback
[email protected]::IAGnssRil
[email protected]::IAGnssRilCallback
[email protected]::IGnss
[email protected]::IGnssBatching
[email protected]::IGnssBatchingCallback
[email protected]::IGnssCallback
[email protected]::IGnssConfiguration
[email protected]::IGnssDebug
[email protected]::IGnssGeofenceCallback
[email protected]::IGnssGeofencing
[email protected]::IGnssMeasurement
[email protected]::IGnssMeasurementCallback
[email protected]::IGnssNavigationMessage
[email protected]::IGnssNavigationMessageCallback
[email protected]::IGnssNi
[email protected]::IGnssNiCallback
[email protected]::IGnssXtra
[email protected]::IGnssXtraCallback
[email protected]::types
[email protected]::IAllocator
[email protected]::IGraphicBufferProducer
[email protected]::IProducerListener
[email protected]::types
[email protected]::IComposer
[email protected]::IComposerCallback
[email protected]::IComposerClient
[email protected]::types
[email protected]::IMapper
[email protected]::types
[email protected]::IHealth
[email protected]::types
[email protected]::IConsumerIr
[email protected]::types
[email protected]::IKeymasterDevice
[email protected]::types
[email protected]::ILight
[email protected]::types
[email protected]::types
[email protected]::IGraphicBufferSource
[email protected]::IOmx
[email protected]::IOmxBufferSource
[email protected]::IOmxNode
[email protected]::IOmxObserver
[email protected]::IOmxStore
[email protected]::types
[email protected]::IMemtrack
[email protected]::types
[email protected]::INfc
[email protected]::INfcClientCallback
[email protected]::types
[email protected]::IPower
[email protected]::types
[email protected]::IRadio
[email protected]::IRadioIndication
[email protected]::IRadioResponse
[email protected]::ISap
[email protected]::ISapCallback
[email protected]::types
[email protected]::IOemHook
[email protected]::IOemHookIndication
[email protected]::IOemHookResponse
[email protected]::IContext
[email protected]::IDevice
[email protected]::types
[email protected]::ISensors
[email protected]::types
[email protected]::ISoundTriggerHw
[email protected]::ISoundTriggerHwCallback
[email protected]::types
[email protected]::IThermal
[email protected]::types
[email protected]::IHdmiCec
[email protected]::IHdmiCecCallback
[email protected]::types
[email protected]::ITvInput
[email protected]::ITvInputCallback
[email protected]::types
[email protected]::IUsb
[email protected]::IUsbCallback
[email protected]::types
[email protected]::IVibrator
[email protected]::types
[email protected]::IVr
[email protected]::IWifi
[email protected]::IWifiApIface
[email protected]::IWifiChip
[email protected]::IWifiChipEventCallback
[email protected]::IWifiEventCallback
[email protected]::IWifiIface
[email protected]::IWifiNanIface
[email protected]::IWifiNanIfaceEventCallback
[email protected]::IWifiP2pIface
[email protected]::IWifiRttController
[email protected]::IWifiRttControllerEventCallback
[email protected]::IWifiStaIface
[email protected]::IWifiStaIfaceEventCallback
[email protected]::types
[email protected]::ISupplicant
[email protected]::ISupplicantCallback
[email protected]::ISupplicantIface
[email protected]::ISupplicantNetwork
[email protected]::ISupplicantP2pIface
[email protected]::ISupplicantP2pIfaceCallback
[email protected]::ISupplicantP2pNetwork
[email protected]::ISupplicantP2pNetworkCallback
[email protected]::ISupplicantStaIface
[email protected]::ISupplicantStaIfaceCallback
[email protected]::ISupplicantStaNetwork
[email protected]::ISupplicantStaNetworkCallback
[email protected]::types
##############################################
===============================wificond ( 8.0 )↓======================
//system/connectivity/wificond/aidl/android/net/wifi/IWificond.aidl
// Service interface that exposes primitives for controlling the WiFi
// subsystems of a device.
interface IWificond {
@nullable IApInterface createApInterface();
@nullable IClientInterface createClientInterface();
void tearDownInterfaces();
}
/frameworks/opt/net/wifi/service/java/com/android/server/wifi/WifiInjector.java
public IWificond makeWificond() {
// We depend on being able to refresh our binder in WifiStateMachine, so don't cache it.
IBinder binder = ServiceManager.getService(WIFICOND_SERVICE_NAME【"wificond"】);
return IWificond.Stub.asInterface(binder);
}
adb shell service list | findstr wifi
59 wifip2p: [android.net.wifi.p2p.IWifiP2pManager]
60 rttmanager: [android.net.wifi.IRttManager]
61 wifiscanner: [android.net.wifi.IWifiScanner]
62 wifi: [android.net.wifi.IWifiManager]
125 wificond: [] // service
============================================
/system/sepolicy/private/wificond.te
typeattribute wificond coredomain;
init_daemon_domain(wificond)
hal_client_domain(wificond, hal_wifi_offload)
============================================
/system/sepolicy/public/wificond.te
# wificond
type wificond, domain;
type wificond_exec, exec_type, file_type;
binder_use(wificond)
binder_call(wificond, system_server)
add_service(wificond, wificond_service)
set_prop(wificond, wifi_prop)
set_prop(wificond, ctl_default_prop)
# create sockets to set interfaces up and down
allow wificond self:udp_socket create_socket_perms;
# setting interface state up/down is a privileged ioctl
allowxperm wificond self:udp_socket ioctl { SIOCSIFFLAGS };
allow wificond self:capability { net_admin net_raw };
# allow wificond to speak to nl80211 in the kernel
allow wificond self:netlink_socket create_socket_perms_no_ioctl;
# newer kernels (e.g. 4.4 but not 4.1) have a new class for sockets
allow wificond self:netlink_generic_socket create_socket_perms_no_ioctl;
r_dir_file(wificond, proc_net)
# wificond writes out configuration files for wpa_supplicant/hostapd.
# wificond also reads pid files out of this directory
allow wificond wifi_data_file:dir rw_dir_perms;
allow wificond wifi_data_file:file create_file_perms;
# allow wificond to check permission for dumping logs
allow wificond permission_service:service_manager find;
# dumpstate support
allow wificond dumpstate:fd use;
allow wificond dumpstate:fifo_file write;
============================================
/system/connectivity/wificond/wificond.rc
service wificond /system/bin/wificond
class main
user wifi
group wifi net_raw net_admin
============================================
/frameworks/opt/net/wifi/service/java/com/android/server/wifi/WificondControl.java
/frameworks/opt/net/wifi/service/java/com/android/server/wifi/WifiNative.java
/**
* Disable wpa_supplicant via wificond. wpa_supplicant wificond
* @return Returns true on success.
*/
public boolean disableSupplicant() {
return mWificondControl.disableSupplicant();
}
/**
* Enable wpa_supplicant via wificond. wpa_supplicant wificond
* @return Returns true on success.
*/
public boolean enableSupplicant() {
return mWificondControl.enableSupplicant();
}
===============================wificond ( 8.0 )↑======================
/frameworks/opt/net/wifi/service/java/com/android/server/wifi/WifiNative.java
/**
* Disable wpa_supplicant via wificond. wpa_supplicant wificond
* @return Returns true on success.
*/
public boolean disableSupplicant() {
return mWificondControl.disableSupplicant();
}
/**
* Enable wpa_supplicant via wificond. wpa_supplicant wificond
* @return Returns true on success.
*/
public boolean enableSupplicant() {
return mWificondControl.enableSupplicant();
}
=========================WifiInjector↓================================
/frameworks/opt/net/wifi/service/java/com/android/server/wifi/WifiInjector.java
public class WifiInjector {
private final WificondControl mWificondControl;
public WifiInjector(Context context) {
mWifiMonitor = new WifiMonitor(this);
mHalDeviceManager = new HalDeviceManager(); // ?
// IWifiVendor.Hal ? ISupplicantStaIface.Hal
mWifiVendorHal =new WifiVendorHal(mHalDeviceManager, mWifiStateMachineHandlerThread.getLooper());
mSupplicantStaIfaceHal = new SupplicantStaIfaceHal(mContext, mWifiMonitor);
mWificondControl = new WificondControl(this, mWifiMonitor);
mWifiNative = new WifiNative(SystemProperties.get("wifi.interface", "wlan0"),mWifiVendorHal, mSupplicantStaIfaceHal, mWificondControl);
//----------------------P2P --------------------------
mWifiP2pMonitor = new WifiP2pMonitor(this);
mSupplicantP2pIfaceHal = new SupplicantP2pIfaceHal(mWifiP2pMonitor);
mWifiP2pNative = new WifiP2pNative(SystemProperties.get("wifi.direct.interface","p2p0"),mSupplicantP2pIfaceHal);
// handlerThread Now get instances of all the objects that depend on the HandlerThreads
mTrafficPoller = new WifiTrafficPoller(mContext,mWifiServiceHandlerThread.getLooper(),mWifiNative.getInterfaceName());
mCountryCode = new WifiCountryCode(mWifiNative,SystemProperties.get(BOOT_DEFAULT_WIFI_COUNTRY_CODE),
mContext.getResources().getBoolean(R.bool.config_wifi_revert_country_code_on_cellular_loss));
mWifiApConfigStore = new WifiApConfigStore(mContext, mBackupManagerProxy);
}
private static final String BOOT_DEFAULT_WIFI_COUNTRY_CODE = "ro.boot.wificountrycode";
=========================WifiInjector↑================================
=========================WifiMonitor ==================
【 WifiMonitor :】 wpa_supplicant , , attach
Listens for events from the wpa_supplicant server, and passes them on
to the {@link StateMachine} for handling.
MAP
Map mHandlerMap (key= ,value= handler )
map mMonitoringMap ( key= ,value= Boolean )
private final Map>> mHandlerMap = new HashMap<>();
private final Map mMonitoringMap = new HashMap<>();
// TODO(b/27569474) remove support for multiple handlers for the same event
private final Map>> mHandlerMap = new HashMap<>();
// registerHandler WifiMonitor , key iface what
// handler
public synchronized void registerHandler(String iface, int what, Handler handler) {
SparseArray> ifaceHandlers = mHandlerMap.get(iface);
if (ifaceHandlers == null) {
ifaceHandlers = new SparseArray<>();
mHandlerMap.put(iface, ifaceHandlers);
}
Set ifaceWhatHandlers = ifaceHandlers.get(what);
if (ifaceWhatHandlers == null) {
ifaceWhatHandlers = new ArraySet<>();
ifaceHandlers.put(what, ifaceWhatHandlers);
}
ifaceWhatHandlers.add(handler);
}
/**
* Start Monitoring for wpa_supplicant events.
*
* @param iface Name of iface.
* TODO: Add unit tests for these once we remove the legacy code.
*/
public synchronized void startMonitoring(String iface, boolean isStaIface) {
if (ensureConnectedLocked()) { // WifiNative Supplicant
setMonitoring(iface, true);
broadcastSupplicantConnectionEvent(iface); //
} else {
boolean originalMonitoring = isMonitoring(iface);
setMonitoring(iface, true);
broadcastSupplicantDisconnectionEvent(iface);
setMonitoring(iface, originalMonitoring);
Log.e(TAG, "startMonitoring(" + iface + ") failed!");
}
}
/**
* Stop Monitoring for wpa_supplicant events.
*
* @param iface Name of iface.
* TODO: Add unit tests for these once we remove the legacy code.
*/
public synchronized void stopMonitoring(String iface) {
if (mVerboseLoggingEnabled) Log.d(TAG, "stopMonitoring(" + iface + ")");
setMonitoring(iface, true);
broadcastSupplicantDisconnectionEvent(iface);
setMonitoring(iface, false);
}
/* Connection to supplicant established */
private static final int BASE = Protocol.BASE_WIFI_MONITOR;//0x00024000
public static final int SUP_CONNECTION_EVENT = BASE + 1
public void broadcastSupplicantConnectionEvent(String iface) { // handler Message
sendMessage(iface, SUP_CONNECTION_EVENT);
}
private void sendMessage(String iface, int what) {
sendMessage(iface, Message.obtain(null, what)); // Message
}
private void sendMessage(String iface, Message message) {
// iface handler
SparseArray> ifaceHandlers = mHandlerMap.get(iface);
if (iface != null && ifaceHandlers != null) {
if (isMonitoring(iface)) {
// message.what handler message handler
Set ifaceWhatHandlers = ifaceHandlers.get(message.what);
if (ifaceWhatHandlers != null) {
for (Handler handler : ifaceWhatHandlers) {
if (handler != null) {
// handler
sendMessage(handler, Message.obtain(message));
}
}
}
} else {
if (mVerboseLoggingEnabled) {
Log.d(TAG, "Dropping event because (" + iface + ") is stopped");
}
}
} else {
if (mVerboseLoggingEnabled) {
Log.d(TAG, "Sending to all monitors because there's no matching iface");
}
for (Map.Entry>> entry : mHandlerMap.entrySet()) {
if (isMonitoring(entry.getKey())) {
Set ifaceWhatHandlers = entry.getValue().get(message.what);
for (Handler handler : ifaceWhatHandlers) {
if (handler != null) {
sendMessage(handler, Message.obtain(message));
}
}
}
}
}
message.recycle();
}
private void sendMessage(Handler handler, Message message) {
message.setTarget(handler);
message.sendToTarget(); // handler
}
WifiMonitor /frameworks/opt/net/wifi/service/java/com/android/server/wifi/WificondControl.java
/frameworks/opt/net/wifi/service/java/com/android/server/wifi/SupplicantStaIfaceHal.java
sendMessage(String iface, Message message) sendMessage(Handler handler, Message message)
broadcastAnqpDoneEvent(String iface, AnqpEvent anqpEvent) {
sendMessage(iface, ANQP_DONE_EVENT, anqpEvent);
}
public void broadcastAssociatedBssidEvent(String iface, String bssid) {
sendMessage(iface, WifiStateMachine.CMD_ASSOCIATED_BSSID, 0, 0, bssid);
}
public void broadcastAssociationRejectionEvent(String iface, int status, boolean timedOut,String bssid) {
sendMessage(iface, ASSOCIATION_REJECTION_EVENT, timedOut ? 1 : 0, status, bssid);
}
public void broadcastAuthenticationFailureEvent(String iface, int reason) {
sendMessage(iface, AUTHENTICATION_FAILURE_EVENT, 0, reason);
}
public void broadcastIconDoneEvent(String iface, IconEvent iconEvent) {
sendMessage(iface, RX_HS20_ANQP_ICON_EVENT, iconEvent);
}
public void broadcastNetworkConnectionEvent(String iface, int networkId, String bssid) {
sendMessage(iface, NETWORK_CONNECTION_EVENT, networkId, 0, bssid);
}
public void broadcastNetworkDisconnectionEvent(String iface, int local, int reason,String bssid) {
sendMessage(iface, NETWORK_DISCONNECTION_EVENT, local, reason, bssid);
}
public void broadcastNetworkGsmAuthRequestEvent(String iface, int networkId, String ssid,String[] data) {
sendMessage(iface, SUP_REQUEST_SIM_AUTH,new SimAuthRequestData(networkId, WifiEnterpriseConfig.Eap.SIM, ssid, data));
}
public void broadcastNetworkIdentityRequestEvent(String iface, int networkId, String ssid) {
sendMessage(iface, SUP_REQUEST_IDENTITY, 0, networkId, ssid);
}
public void broadcastNetworkUmtsAuthRequestEvent(String iface, int networkId, String ssid,String[] data) {
sendMessage(iface, SUP_REQUEST_SIM_AUTH,
new SimAuthRequestData(networkId, WifiEnterpriseConfig.Eap.AKA, ssid, data));
}
public void broadcastPnoScanResultEvent(String iface) {
sendMessage(iface, PNO_SCAN_RESULTS_EVENT);
}
public void broadcastScanFailedEvent(String iface) {
sendMessage(iface, SCAN_FAILED_EVENT);
}
public void broadcastScanResultEvent(String iface) { // 【 】
sendMessage(iface, SCAN_RESULTS_EVENT);
}
public void broadcastSupplicantConnectionEvent(String iface) {
sendMessage(iface, SUP_CONNECTION_EVENT);
}
public void broadcastSupplicantDisconnectionEvent(String iface) {
sendMessage(iface, SUP_DISCONNECTION_EVENT);
}
public void broadcastSupplicantStateChangeEvent(String iface, int networkId, WifiSsid wifiSsid,
String bssid,SupplicantState newSupplicantState) {
sendMessage(iface, SUPPLICANT_STATE_CHANGE_EVENT, 0, 0,
new StateChangeResult(networkId, wifiSsid, bssid, newSupplicantState));
}
public void broadcastTargetBssidEvent(String iface, String bssid) {
sendMessage(iface, WifiStateMachine.CMD_TARGET_BSSID, 0, 0, bssid);
}
public void broadcastWnmEvent(String iface, WnmData wnmData) {
sendMessage(iface, HS20_REMEDIATION_EVENT, wnmData);
}
public void broadcastWpsFailEvent(String iface, int cfgError, int vendorErrorCode) {
int reason = 0;
switch(vendorErrorCode) {
case REASON_TKIP_ONLY_PROHIBITED:
sendMessage(iface, WPS_FAIL_EVENT, WifiManager.WPS_TKIP_ONLY_PROHIBITED);
return;
case REASON_WEP_PROHIBITED:
sendMessage(iface, WPS_FAIL_EVENT, WifiManager.WPS_WEP_PROHIBITED);
return;
default:
reason = vendorErrorCode;
break;
}
switch(cfgError) {
case CONFIG_AUTH_FAILURE:
sendMessage(iface, WPS_FAIL_EVENT, WifiManager.WPS_AUTH_FAILURE);
return;
case CONFIG_MULTIPLE_PBC_DETECTED:
sendMessage(iface, WPS_FAIL_EVENT, WifiManager.WPS_OVERLAP_ERROR);
return;
default:
if (reason == 0) {
reason = cfgError;
}
break;
}
//For all other errors, return a generic internal error
sendMessage(iface, WPS_FAIL_EVENT, WifiManager.ERROR, reason);
}
public void broadcastWpsOverlapEvent(String iface) {
sendMessage(iface, WPS_OVERLAP_EVENT);
}
public void broadcastWpsSuccessEvent(String iface) {
sendMessage(iface, WPS_SUCCESS_EVENT);
}
public void broadcastWpsTimeoutEvent(String iface) {
sendMessage(iface, WPS_TIMEOUT_EVENT);
}
/frameworks/opt/net/wifi/service/java/com/android/server/wifi/WificondControl.java
/frameworks/opt/net/wifi/service/java/com/android/server/wifi/SupplicantStaIfaceHal.java
broadcastAnqpDoneEvent WificondControl.java
broadcastAssociatedBssidEvent SupplicantStaIfaceHal.java
broadcastAssociationRejectionEvent SupplicantStaIfaceHal.java
broadcastAuthenticationFailureEvent SupplicantStaIfaceHal.java
broadcastIconDoneEvent SupplicantStaIfaceHal.java
broadcastNetworkConnectionEvent SupplicantStaIfaceHal.java
broadcastNetworkDisconnectionEvent SupplicantStaIfaceHal.java
broadcastNetworkGsmAuthRequestEvent SupplicantStaIfaceHal.java
broadcastNetworkIdentityRequestEvent SupplicantStaIfaceHal.java
broadcastNetworkUmtsAuthRequestEvent SupplicantStaIfaceHal.java
broadcastPnoScanResultEvent SupplicantStaIfaceHal.java
broadcastScanFailedEvent SupplicantStaIfaceHal.java
broadcastScanResultEvent WificondControl.java
broadcastSupplicantConnectionEvent
broadcastSupplicantDisconnectionEvent
broadcastSupplicantStateChangeEvent
broadcastTargetBssidEvent
broadcastWnmEvent
broadcastWpsFailEvent
broadcastWpsOverlapEvent
broadcastWpsSuccessEvent
broadcastWpsTimeoutEvent
ISupplicantStaIfaceCallback.Stub ISupplicantStaIfaceCallback.hal ?
/frameworks/opt/net/wifi/service/java/com/android/server/wifi/SupplicantStaIfaceHal.java
private class SupplicantStaIfaceHalCallback extends ISupplicantStaIfaceCallback.Stub {
, ?
onAnqpQueryDone ()
onAssociationRejected ()
public void onAuthenticationTimeout( byte [/* 6 */] bssid)
onBssidChanged ()
onDisconnected ()
onEapFailure ()
onExtRadioWorkStart ()
onExtRadioWorkTimeout ()
onHs20DeauthImminentNotice ()
onHs20IconQueryDone ()
onHs20SubscriptionRemediation ()
onNetworkAdded ()
onNetworkRemoved ()
onStateChanged ()
onWpsEventFail ()
onWpsEventPbcOverlap ()
onWpsEventSuccess ()
}
/external/wpa_supplicant_8/wpa_supplicant/hidl/1.0/hidl_manager.cpp
void HidlManager::notifyAuthTimeout(struct wpa_supplicant *wpa_s)
{
if (!wpa_s)
return;
const std::string ifname(wpa_s->ifname);
if (sta_iface_object_map_.find(ifname) == sta_iface_object_map_.end())
return;
const u8 *bssid = wpa_s->bssid;
if (is_zero_ether_addr(bssid)) {
bssid = wpa_s->pending_bssid;
}
callWithEachStaIfaceCallback(
wpa_s->ifname,
std::bind(
&ISupplicantStaIfaceCallback::onAuthenticationTimeout, // ?? Fuck Understand!!
std::placeholders::_1, bssid));
}
callWithEachStaIfaceCallback(
wpa_s->ifname, std::bind(
&ISupplicantStaIfaceCallback::onAnqpQueryDone,
std::placeholders::_1, bssid, hidl_anqp_data,
hidl_hs20_anqp_data));
void HidlManager::callWithEachStaIfaceCallback(
const std::string &ifname,
const std::function(android::sp)> &method)
{
callWithEachIfaceCallback(ifname, method, sta_iface_callbacks_map_);
}
template // CallbackType &method
void callWithEachIfaceCallback(
const std::string &ifname,
const std::function<:hardware::return>(android::sp)> &method,
const std::map>> &callbacks_map)
{
if (ifname.empty())
return;
auto iface_callback_map_iter = callbacks_map.find(ifname);
if (iface_callback_map_iter == callbacks_map.end())
return;
const auto &iface_callback_list = iface_callback_map_iter->second;
for (const auto &callback : iface_callback_list) {
if (!method(callback).isOk()) {
wpa_printf(MSG_ERROR, "Failed to invoke HIDL iface callback");
}
}
}
sta_iface_callbacks_map_[wpa_s->ifname] =std::vector<:sp>>();
(removeAllIfaceCallbackHidlObjectsFromMap(wpa_s->ifname, sta_iface_callbacks_map_))
addIfaceCallbackHidlObjectToMap(ifname, callback, on_hidl_died_fctor, sta_iface_callbacks_map_);
template
int addIfaceCallbackHidlObjectToMap(
const std::string &ifname,
const android::sp &callback,
const std::function &)> &on_hidl_died_fctor,
std::map>> &callbacks_map)
{
if (ifname.empty())
return 1;
auto iface_callback_map_iter = callbacks_map.find(ifname);
if (iface_callback_map_iter == callbacks_map.end())
return 1;
auto &iface_callback_list = iface_callback_map_iter->second;
// Register for death notification before we add it to our list.
return registerForDeathAndAddCallbackHidlObjectToList(
callback, on_hidl_died_fctor, iface_callback_list);
}
template
int registerForDeathAndAddCallbackHidlObjectToList(
const android::sp &callback,
const std::function &)>
&on_hidl_died_fctor,
std::vector<:sp>> &callback_list)
{
#if 0 // TODO(b/31632518): HIDL object death notifications.
auto death_notifier = new CallbackObjectDeathNotifier(
callback, on_hidl_died_fctor);
// Use the |callback.get()| as cookie so that we don't need to
// store a reference to this |CallbackObjectDeathNotifier| instance
// to use in |unlinkToDeath| later.
// NOTE: This may cause an immediate callback if the object is already
// dead, so add it to the list before we register for callback!
if (android::hardware::IInterface::asBinder(callback)->linkToDeath(
death_notifier, callback.get()) != android::OK) {
wpa_printf(
MSG_ERROR,
"Error registering for death notification for "
"supplicant callback object");
callback_list.erase(
std::remove(
callback_list.begin(), callback_list.end(), callback),
callback_list.end());
return 1;
}
#endif // TODO(b/31632518): HIDL object death notifications.
callback_list.push_back(callback); // CallbackType iface_callback_list
return 0;
}
template
int removeAllIfaceCallbackHidlObjectsFromMap(
const std::string &ifname,
std::map>> &callbacks_map)
{
auto iface_callback_map_iter = callbacks_map.find(ifname);
if (iface_callback_map_iter == callbacks_map.end())
return 1;
#if 0 // TODO(b/31632518): HIDL object death notifications.
const auto &iface_callback_list = iface_callback_map_iter->second;
for (const auto &callback : iface_callback_list) {
if (android::hardware::IInterface::asBinder(callback)
->unlinkToDeath(nullptr, callback.get()) !=
android::OK) {
wpa_printf(
MSG_ERROR,
"Error deregistering for death notification for "
"iface callback object");
}
}
#endif // TODO(b/31632518): HIDL object death notifications.
callbacks_map.erase(iface_callback_map_iter);
return 0;
}
===============================================================
/**
* Register an interface to hidl manager.
*
* @param wpa_s |wpa_supplicant| struct corresponding to the interface.
*
* @return 0 on success, 1 on failure.
*/
int HidlManager::registerInterface(struct wpa_supplicant *wpa_s)
{
sta_iface_callbacks_map_[wpa_s->ifname] =std::vector<:sp>>();
// Invoke the |onInterfaceCreated| method on all registered callbacks.
callWithEachSupplicantCallback(std::bind(
&ISupplicantCallback::onInterfaceCreated, std::placeholders::_1,
wpa_s->ifname));
}
// hidl manager?
//std::vector<:sp>>() map ?
/**
* Helper function to invoke the provided callback method on all the
* registered |ISupplicantCallback| callback hidl objects.
*
* @param method Pointer to the required hidl method from
* |ISupplicantCallback|.
*/
void HidlManager::callWithEachSupplicantCallback(
const std::function(android::sp)> &method)
{
for (const auto &callback : supplicant_callbacks_) {
// supplicant_callbacks_ &ISupplicantCallback::onInterfaceCreated
// onInterfaceCreated
if (!method(callback).isOk()) {
wpa_printf(MSG_ERROR, "Failed to invoke HIDL callback");
}
}
}
// http://blog.csdn.net/eclipser1987/article/details/24406203 C++
// http://coliru.stacked-crooked.com/ C++
// std::bind std::placeholders::_1, std::placeholders::_2 FUCK