diff options
author | Etan Cohen <etancohen@google.com> | 2016-11-06 03:13:56 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2016-11-06 03:13:56 +0000 |
commit | a59f7d1ab2b9e912a9918eef96a29676c1725824 (patch) | |
tree | c5ec511db5df240743f347c92093985fdd749586 /service | |
parent | 91710061f8cff2aec476bcecfacc160b85706b5b (diff) | |
parent | c29acea6ceda3aa4ee537c05ce7d05dac2655cf9 (diff) |
[NAN-AWARE] Rename NAN to Aware
am: c29acea6ce
Change-Id: I83892bc745ae27e0b9d5dcee5799d4aa0baab968
Diffstat (limited to 'service')
-rw-r--r-- | service/Android.mk | 8 | ||||
-rw-r--r-- | service/java/com/android/server/wifi/WifiStateMachine.java | 24 | ||||
-rw-r--r-- | service/java/com/android/server/wifi/aware/WifiAwareClientState.java (renamed from service/java/com/android/server/wifi/nan/WifiNanClientState.java) | 42 | ||||
-rw-r--r-- | service/java/com/android/server/wifi/aware/WifiAwareDataPathStateManager.java (renamed from service/java/com/android/server/wifi/nan/WifiNanDataPathStateManager.java) | 272 | ||||
-rw-r--r-- | service/java/com/android/server/wifi/aware/WifiAwareDiscoverySessionState.java (renamed from service/java/com/android/server/wifi/nan/WifiNanDiscoverySessionState.java) | 40 | ||||
-rw-r--r-- | service/java/com/android/server/wifi/aware/WifiAwareNative.java (renamed from service/java/com/android/server/wifi/nan/WifiNanNative.java) | 554 | ||||
-rw-r--r-- | service/java/com/android/server/wifi/aware/WifiAwareRttStateManager.java (renamed from service/java/com/android/server/wifi/nan/WifiNanRttStateManager.java) | 28 | ||||
-rw-r--r-- | service/java/com/android/server/wifi/aware/WifiAwareService.java (renamed from service/java/com/android/server/wifi/nan/WifiNanService.java) | 20 | ||||
-rw-r--r-- | service/java/com/android/server/wifi/aware/WifiAwareServiceImpl.java (renamed from service/java/com/android/server/wifi/nan/WifiNanServiceImpl.java) | 63 | ||||
-rw-r--r-- | service/java/com/android/server/wifi/aware/WifiAwareStateManager.java (renamed from service/java/com/android/server/wifi/nan/WifiNanStateManager.java) | 327 | ||||
-rw-r--r-- | service/jni/com_android_server_wifi_WifiNative.cpp | 2 | ||||
-rw-r--r-- | service/jni/com_android_server_wifi_aware_WifiAwareNative.cpp (renamed from service/jni/com_android_server_wifi_nan_WifiNanNative.cpp) | 38 |
12 files changed, 716 insertions, 702 deletions
diff --git a/service/Android.mk b/service/Android.mk index 988f2edc6..3dac559f0 100644 --- a/service/Android.mk +++ b/service/Android.mk @@ -39,9 +39,9 @@ LOCAL_SRC_FILES := \ jni/com_android_server_wifi_WifiNative.cpp \ jni/jni_helper.cpp -ifeq ($(BOARD_HAS_NAN), true) +ifeq ($(BOARD_HAS_AWARE), true) LOCAL_SRC_FILES += \ - jni/com_android_server_wifi_nan_WifiNanNative.cpp + jni/com_android_server_wifi_aware_WifiAwareNative.cpp endif LOCAL_MODULE := libwifi-service @@ -63,9 +63,9 @@ LOCAL_SRC_FILES := $(call all-java-files-under, java) \ $(call all-logtags-files-under, java) \ $(call all-proto-files-under, proto) -ifneq ($(BOARD_HAS_NAN), true) +ifneq ($(BOARD_HAS_AWARE), true) LOCAL_SRC_FILES := $(filter-out $(call all-java-files-under, \ - java/com/android/server/wifi/nan),$(LOCAL_SRC_FILES)) + java/com/android/server/wifi/aware),$(LOCAL_SRC_FILES)) endif LOCAL_JAVA_LIBRARIES := bouncycastle conscrypt jsr305 services diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java index bc767dafa..41a726a38 100644 --- a/service/java/com/android/server/wifi/WifiStateMachine.java +++ b/service/java/com/android/server/wifi/WifiStateMachine.java @@ -76,7 +76,7 @@ import android.net.wifi.WifiSsid; import android.net.wifi.WpsInfo; import android.net.wifi.WpsResult; import android.net.wifi.WpsResult.Status; -import android.net.wifi.nan.WifiNanManager; +import android.net.wifi.aware.WifiAwareManager; import android.net.wifi.p2p.IWifiP2pManager; import android.os.BatteryStats; import android.os.Binder; @@ -208,7 +208,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss private WifiApConfigStore mWifiApConfigStore; private final boolean mP2pSupported; private final AtomicBoolean mP2pConnected = new AtomicBoolean(false); - private final boolean mNanSupported; + private final boolean mAwareSupported; private boolean mTemporarilyDisconnectWifi = false; private final String mPrimaryDeviceType; private final Clock mClock; @@ -431,7 +431,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss private AsyncChannel mReplyChannel = new AsyncChannel(); private WifiP2pServiceImpl mWifiP2pServiceImpl; - private WifiNanManager mWifiNanManager; + private WifiAwareManager mWifiAwareManager; // Used to initiate a connection with WifiP2pService private AsyncChannel mWifiP2pChannel; @@ -875,8 +875,8 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss mP2pSupported = mContext.getPackageManager().hasSystemFeature( PackageManager.FEATURE_WIFI_DIRECT); - mNanSupported = mContext.getPackageManager() - .hasSystemFeature(PackageManager.FEATURE_WIFI_NAN); + mAwareSupported = mContext.getPackageManager() + .hasSystemFeature(PackageManager.FEATURE_WIFI_AWARE); mWifiConfigManager = mWifiInjector.getWifiConfigManager(); mWifiSupplicantControl = mWifiInjector.getWifiSupplicantControl(); @@ -896,8 +896,8 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss IBinder s1 = mFacade.getService(Context.WIFI_P2P_SERVICE); mWifiP2pServiceImpl = (WifiP2pServiceImpl) IWifiP2pManager.Stub.asInterface(s1); - if (mNanSupported) { - mWifiNanManager = mContext.getSystemService(WifiNanManager.class); + if (mAwareSupported) { + mWifiAwareManager = mContext.getSystemService(WifiAwareManager.class); } mNetworkInfo.setIsAvailable(false); @@ -4242,12 +4242,12 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss } } - if (mNanSupported && mWifiNanManager != null) { + if (mAwareSupported && mWifiAwareManager != null) { if (mOperationalMode == CONNECT_MODE) { - mWifiNanManager.enableUsage(); + mWifiAwareManager.enableUsage(); } else { /* - * NAN state machine starts in disabled state. Nothing + * Aware state machine starts in disabled state. Nothing * needed to keep it disabled. */ } @@ -4417,8 +4417,8 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL); mBufferedScanMsg.clear(); - if (mNanSupported && mWifiNanManager != null) { - mWifiNanManager.disableUsage(); + if (mAwareSupported && mWifiAwareManager != null) { + mWifiAwareManager.disableUsage(); } mNetworkInfo.setIsAvailable(false); diff --git a/service/java/com/android/server/wifi/nan/WifiNanClientState.java b/service/java/com/android/server/wifi/aware/WifiAwareClientState.java index 03a2cd2e7..fca3d835b 100644 --- a/service/java/com/android/server/wifi/nan/WifiNanClientState.java +++ b/service/java/com/android/server/wifi/aware/WifiAwareClientState.java @@ -14,15 +14,15 @@ * limitations under the License. */ -package com.android.server.wifi.nan; +package com.android.server.wifi.aware; import android.Manifest; import android.app.AppOpsManager; import android.content.Context; import android.content.pm.PackageManager; import android.net.wifi.RttManager; -import android.net.wifi.nan.ConfigRequest; -import android.net.wifi.nan.IWifiNanEventCallback; +import android.net.wifi.aware.ConfigRequest; +import android.net.wifi.aware.IWifiAwareEventCallback; import android.os.RemoteException; import android.util.Log; import android.util.SparseArray; @@ -34,16 +34,16 @@ import java.io.PrintWriter; import java.util.Arrays; /** - * Manages the service-side NAN state of an individual "client". A client - * corresponds to a single instantiation of the WifiNanManager - there could be + * Manages the service-side Aware state of an individual "client". A client + * corresponds to a single instantiation of the WifiAwareManager - there could be * multiple ones per UID/process (each of which is a separate client with its * own session namespace). The client state is primarily: (1) callback (a - * singleton per client) through which NAN-wide events are called, and (2) a set + * singleton per client) through which Aware-wide events are called, and (2) a set * of discovery sessions (publish and/or subscribe) which are created through * this client and whose lifetime is tied to the lifetime of the client. */ -public class WifiNanClientState { - private static final String TAG = "WifiNanClientState"; +public class WifiAwareClientState { + private static final String TAG = "WifiAwareClientState"; private static final boolean DBG = false; private static final boolean VDBG = false; // STOPSHIP if true @@ -51,8 +51,8 @@ public class WifiNanClientState { /* package */ static final int CLUSTER_CHANGE_EVENT_JOINED = 1; private final Context mContext; - private final IWifiNanEventCallback mCallback; - private final SparseArray<WifiNanDiscoverySessionState> mSessions = new SparseArray<>(); + private final IWifiAwareEventCallback mCallback; + private final SparseArray<WifiAwareDiscoverySessionState> mSessions = new SparseArray<>(); private final int mClientId; private ConfigRequest mConfigRequest; @@ -66,8 +66,8 @@ public class WifiNanClientState { private static final byte[] ALL_ZERO_MAC = new byte[] {0, 0, 0, 0, 0, 0}; private byte[] mLastDiscoveryInterfaceMac = ALL_ZERO_MAC; - public WifiNanClientState(Context context, int clientId, int uid, int pid, - String callingPackage, IWifiNanEventCallback callback, ConfigRequest configRequest, + public WifiAwareClientState(Context context, int clientId, int uid, int pid, + String callingPackage, IWifiAwareEventCallback callback, ConfigRequest configRequest, boolean notifyIdentityChange) { mContext = context; mClientId = clientId; @@ -111,11 +111,11 @@ public class WifiNanClientState { * map callbacks to the correct discovery session. * * @param pubSubId The publish/subscribe match session ID. - * @return NAN session corresponding to the requested ID. + * @return Aware session corresponding to the requested ID. */ - public WifiNanDiscoverySessionState getNanSessionStateForPubSubId(int pubSubId) { + public WifiAwareDiscoverySessionState getAwareSessionStateForPubSubId(int pubSubId) { for (int i = 0; i < mSessions.size(); ++i) { - WifiNanDiscoverySessionState session = mSessions.valueAt(i); + WifiAwareDiscoverySessionState session = mSessions.valueAt(i); if (session.isPubSubIdSession(pubSubId)) { return session; } @@ -129,7 +129,7 @@ public class WifiNanClientState { * * @param session Session to be added. */ - public void addSession(WifiNanDiscoverySessionState session) { + public void addSession(WifiAwareDiscoverySessionState session) { int sessionId = session.getSessionId(); if (mSessions.get(sessionId) != null) { Log.w(TAG, "createSession: sessionId already exists (replaced) - " + sessionId); @@ -161,7 +161,7 @@ public class WifiNanClientState { * @param sessionId The session ID of the session to be destroyed. */ public void terminateSession(int sessionId) { - WifiNanDiscoverySessionState session = mSessions.get(sessionId); + WifiAwareDiscoverySessionState session = mSessions.get(sessionId); if (session == null) { Log.e(TAG, "terminateSession: sessionId doesn't exist - " + sessionId); return; @@ -178,12 +178,12 @@ public class WifiNanClientState { * @return Session or null if there's no session corresponding to the * sessionId. */ - public WifiNanDiscoverySessionState getSession(int sessionId) { + public WifiAwareDiscoverySessionState getSession(int sessionId) { return mSessions.get(sessionId); } /** - * Called to dispatch the NAN interface address change to the client - as an + * Called to dispatch the Aware interface address change to the client - as an * identity change (interface address information not propagated to client - * privacy concerns). * @@ -212,7 +212,7 @@ public class WifiNanClientState { } /** - * Called to dispatch the NAN cluster change (due to joining of a new + * Called to dispatch the Aware cluster change (due to joining of a new * cluster or starting a cluster) to the client - as an identity change * (interface address information not propagated to client - privacy * concerns). Dispatched if the client registered for the identity changed @@ -298,7 +298,7 @@ public class WifiNanClientState { * Dump the internal state of the class. */ public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { - pw.println("NanClientState:"); + pw.println("AwareClientState:"); pw.println(" mClientId: " + mClientId); pw.println(" mConfigRequest: " + mConfigRequest); pw.println(" mCallback: " + mCallback); diff --git a/service/java/com/android/server/wifi/nan/WifiNanDataPathStateManager.java b/service/java/com/android/server/wifi/aware/WifiAwareDataPathStateManager.java index 4bcfd1546..3f77a62e7 100644 --- a/service/java/com/android/server/wifi/nan/WifiNanDataPathStateManager.java +++ b/service/java/com/android/server/wifi/aware/WifiAwareDataPathStateManager.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.server.wifi.nan; +package com.android.server.wifi.aware; import android.content.Context; import android.net.ConnectivityManager; @@ -27,7 +27,7 @@ import android.net.NetworkFactory; import android.net.NetworkInfo; import android.net.NetworkRequest; import android.net.RouteInfo; -import android.net.wifi.nan.WifiNanManager; +import android.net.wifi.aware.WifiAwareManager; import android.os.IBinder; import android.os.INetworkManagementService; import android.os.Looper; @@ -59,12 +59,12 @@ import java.util.Map; import java.util.Set; /** - * Manages NAN data-path lifetime: interface creation/deletion, data-path setup and tear-down. - * The NAN network configuration is: - * - transport = TRANSPORT_WIFI_NAN + * Manages Aware data-path lifetime: interface creation/deletion, data-path setup and tear-down. + * The Aware network configuration is: + * - transport = TRANSPORT_WIFI_AWARE * - capabilities = NET_CAPABILITY_NOT_VPN - * - network specifier generated by WifiNanDiscoveryBaseSession.createNetworkSpecifier(...) or - * WifiNanManager.createNetworkSpecifier(...). + * - network specifier generated by WifiAwareDiscoveryBaseSession.createNetworkSpecifier(...) or + * WifiAwareManager.createNetworkSpecifier(...). * The network specifier is encoded as a JSON string with the following key combos: * TYPE_1A: type, role, client_id, session_id, peer_id, token * TYPE_1B: type, role, client_id, session_id, peer_id [only permitted for RESPONDER] @@ -73,36 +73,36 @@ import java.util.Set; * TYPE_2C: type, role, client_id, token [only permitted for RESPONDER] * TYPE_2D: type, role, client_id [only permitted for RESPONDER] */ -public class WifiNanDataPathStateManager { - private static final String TAG = "WifiNanDataPathStateMgr"; +public class WifiAwareDataPathStateManager { + private static final String TAG = "WifiAwareDataPathStMgr"; private static final boolean DBG = false; private static final boolean VDBG = false; // STOPSHIP if true - private static final String NAN_INTERFACE_PREFIX = "nan"; - private static final String NETWORK_TAG = "WIFI_NAN_FACTORY"; - private static final String AGENT_TAG_PREFIX = "WIFI_NAN_AGENT_"; + private static final String AWARE_INTERFACE_PREFIX = "aware"; + private static final String NETWORK_TAG = "WIFI_AWARE_FACTORY"; + private static final String AGENT_TAG_PREFIX = "WIFI_AWARE_AGENT_"; private static final int NETWORK_FACTORY_SCORE_AVAIL = 1; private static final int NETWORK_FACTORY_BANDWIDTH_AVAIL = 1; private static final int NETWORK_FACTORY_SIGNAL_STRENGTH_AVAIL = 1; - private final WifiNanStateManager mMgr; + private final WifiAwareStateManager mMgr; private final NetworkInterfaceWrapper mNiWrapper = new NetworkInterfaceWrapper(); private final NetworkCapabilities mNetworkCapabilitiesFilter = new NetworkCapabilities(); private final Set<String> mInterfaces = new HashSet<>(); - private final Map<String, NanNetworkRequestInformation> mNetworkRequestsCache = + private final Map<String, AwareNetworkRequestInformation> mNetworkRequestsCache = new ArrayMap<>(); private Context mContext; private Looper mLooper; - private WifiNanNetworkFactory mNetworkFactory; + private WifiAwareNetworkFactory mNetworkFactory; private INetworkManagementService mNwService; - public WifiNanDataPathStateManager(WifiNanStateManager mgr) { + public WifiAwareDataPathStateManager(WifiAwareStateManager mgr) { mMgr = mgr; } /** - * Initialize the NAN data-path state manager. Specifically register the network factory with + * Initialize the Aware data-path state manager. Specifically register the network factory with * connectivity service. */ public void start(Context context, Looper looper) { @@ -112,7 +112,7 @@ public class WifiNanDataPathStateManager { mLooper = looper; mNetworkCapabilitiesFilter.clearAll(); - mNetworkCapabilitiesFilter.addTransportType(NetworkCapabilities.TRANSPORT_WIFI_NAN); + mNetworkCapabilitiesFilter.addTransportType(NetworkCapabilities.TRANSPORT_WIFI_AWARE); mNetworkCapabilitiesFilter .addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VPN) .addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_METERED) @@ -124,7 +124,7 @@ public class WifiNanDataPathStateManager { mNetworkCapabilitiesFilter.setLinkDownstreamBandwidthKbps(NETWORK_FACTORY_BANDWIDTH_AVAIL); mNetworkCapabilitiesFilter.setSignalStrength(NETWORK_FACTORY_SIGNAL_STRENGTH_AVAIL); - mNetworkFactory = new WifiNanNetworkFactory(looper, context, mNetworkCapabilitiesFilter); + mNetworkFactory = new WifiAwareNetworkFactory(looper, context, mNetworkCapabilitiesFilter); mNetworkFactory.setScoreFilter(NETWORK_FACTORY_SCORE_AVAIL); mNetworkFactory.register(); @@ -132,8 +132,8 @@ public class WifiNanDataPathStateManager { mNwService = INetworkManagementService.Stub.asInterface(b); } - private Map.Entry<String, NanNetworkRequestInformation> getNetworkRequestByNdpId(int ndpId) { - for (Map.Entry<String, NanNetworkRequestInformation> entry : mNetworkRequestsCache + private Map.Entry<String, AwareNetworkRequestInformation> getNetworkRequestByNdpId(int ndpId) { + for (Map.Entry<String, AwareNetworkRequestInformation> entry : mNetworkRequestsCache .entrySet()) { if (entry.getValue().ndpId == ndpId) { return entry; @@ -144,7 +144,7 @@ public class WifiNanDataPathStateManager { } /** - * Create all NAN data-path interfaces which are possible on the device - based on the + * Create all Aware data-path interfaces which are possible on the device - based on the * capabilities of the firmware. */ public void createAllInterfaces() { @@ -156,7 +156,7 @@ public class WifiNanDataPathStateManager { } for (int i = 0; i < mMgr.getCapabilities().maxNdiInterfaces; ++i) { - String name = NAN_INTERFACE_PREFIX + i; + String name = AWARE_INTERFACE_PREFIX + i; if (mInterfaces.contains(name)) { Log.e(TAG, "createAllInterfaces(): interface already up, " + name + ", possibly failed to delete - deleting/creating again to be safe"); @@ -171,7 +171,7 @@ public class WifiNanDataPathStateManager { } /** - * Delete all NAN data-path interfaces which are currently up. + * Delete all Aware data-path interfaces which are currently up. */ public void deleteAllInterfaces() { if (VDBG) Log.v(TAG, "deleteAllInterfaces"); @@ -221,7 +221,7 @@ public class WifiNanDataPathStateManager { + ndpId); } - NanNetworkRequestInformation nnri = mNetworkRequestsCache.get(networkSpecifier); + AwareNetworkRequestInformation nnri = mNetworkRequestsCache.get(networkSpecifier); if (nnri == null) { Log.w(TAG, "onDataPathInitiateSuccess: network request not found for networkSpecifier=" + networkSpecifier); @@ -229,7 +229,8 @@ public class WifiNanDataPathStateManager { return; } - if (nnri.state != NanNetworkRequestInformation.STATE_INITIATOR_WAIT_FOR_REQUEST_RESPONSE) { + if (nnri.state + != AwareNetworkRequestInformation.STATE_INITIATOR_WAIT_FOR_REQUEST_RESPONSE) { Log.w(TAG, "onDataPathInitiateSuccess: network request in incorrect state: state=" + nnri.state); mNetworkRequestsCache.remove(networkSpecifier); @@ -237,7 +238,7 @@ public class WifiNanDataPathStateManager { return; } - nnri.state = NanNetworkRequestInformation.STATE_INITIATOR_WAIT_FOR_CONFIRM; + nnri.state = AwareNetworkRequestInformation.STATE_INITIATOR_WAIT_FOR_CONFIRM; nnri.ndpId = ndpId; } @@ -254,14 +255,15 @@ public class WifiNanDataPathStateManager { + reason); } - NanNetworkRequestInformation nnri = mNetworkRequestsCache.remove(networkSpecifier); + AwareNetworkRequestInformation nnri = mNetworkRequestsCache.remove(networkSpecifier); if (nnri == null) { Log.w(TAG, "onDataPathInitiateFail: network request not found for networkSpecifier=" + networkSpecifier); return; } - if (nnri.state != NanNetworkRequestInformation.STATE_INITIATOR_WAIT_FOR_REQUEST_RESPONSE) { + if (nnri.state + != AwareNetworkRequestInformation.STATE_INITIATOR_WAIT_FOR_REQUEST_RESPONSE) { Log.w(TAG, "onDataPathInitiateFail: network request in incorrect state: state=" + nnri.state); } @@ -289,8 +291,8 @@ public class WifiNanDataPathStateManager { } String networkSpecifier = null; - NanNetworkRequestInformation nnri = null; - for (Map.Entry<String, NanNetworkRequestInformation> entry : mNetworkRequestsCache + AwareNetworkRequestInformation nnri = null; + for (Map.Entry<String, AwareNetworkRequestInformation> entry : mNetworkRequestsCache .entrySet()) { /* * Checking that the incoming request (from the Initiator) matches the request @@ -330,7 +332,7 @@ public class WifiNanDataPathStateManager { return null; } - if (nnri.state != NanNetworkRequestInformation.STATE_RESPONDER_WAIT_FOR_REQUEST) { + if (nnri.state != AwareNetworkRequestInformation.STATE_RESPONDER_WAIT_FOR_REQUEST) { Log.w(TAG, "onDataPathRequest: request " + networkSpecifier + " is incorrect state=" + nnri.state); mMgr.respondToDataPathRequest(false, ndpId, "", ""); @@ -339,7 +341,7 @@ public class WifiNanDataPathStateManager { return null; } - nnri.state = NanNetworkRequestInformation.STATE_RESPONDER_WAIT_FOR_CONFIRM; + nnri.state = AwareNetworkRequestInformation.STATE_RESPONDER_WAIT_FOR_CONFIRM; nnri.ndpId = ndpId; nnri.interfaceName = selectInterfaceForRequest(nnri); mMgr.respondToDataPathRequest(true, ndpId, nnri.interfaceName, ""); @@ -372,7 +374,7 @@ public class WifiNanDataPathStateManager { HexEncoding.encode(mac)) + ", accept=" + accept + ", reason=" + reason); } - Map.Entry<String, NanNetworkRequestInformation> nnriE = getNetworkRequestByNdpId(ndpId); + Map.Entry<String, AwareNetworkRequestInformation> nnriE = getNetworkRequestByNdpId(ndpId); if (nnriE == null) { Log.w(TAG, "onDataPathConfirm: network request not found for ndpId=" + ndpId); if (accept) { @@ -382,11 +384,11 @@ public class WifiNanDataPathStateManager { } String networkSpecifier = nnriE.getKey(); - NanNetworkRequestInformation nnri = nnriE.getValue(); + AwareNetworkRequestInformation nnri = nnriE.getValue(); // validate state - if (nnri.role == WifiNanManager.WIFI_NAN_DATA_PATH_ROLE_INITIATOR - && nnri.state != NanNetworkRequestInformation.STATE_INITIATOR_WAIT_FOR_CONFIRM) { + if (nnri.role == WifiAwareManager.WIFI_AWARE_DATA_PATH_ROLE_INITIATOR + && nnri.state != AwareNetworkRequestInformation.STATE_INITIATOR_WAIT_FOR_CONFIRM) { Log.w(TAG, "onDataPathConfirm: INITIATOR in invalid state=" + nnri.state); mNetworkRequestsCache.remove(networkSpecifier); if (accept) { @@ -394,8 +396,8 @@ public class WifiNanDataPathStateManager { } return networkSpecifier; } - if (nnri.role == WifiNanManager.WIFI_NAN_DATA_PATH_ROLE_RESPONDER - && nnri.state != NanNetworkRequestInformation.STATE_RESPONDER_WAIT_FOR_CONFIRM) { + if (nnri.role == WifiAwareManager.WIFI_AWARE_DATA_PATH_ROLE_RESPONDER + && nnri.state != AwareNetworkRequestInformation.STATE_RESPONDER_WAIT_FOR_CONFIRM) { Log.w(TAG, "onDataPathConfirm: RESPONDER in invalid state=" + nnri.state); mNetworkRequestsCache.remove(networkSpecifier); if (accept) { @@ -405,9 +407,9 @@ public class WifiNanDataPathStateManager { } if (accept) { - nnri.state = (nnri.role == WifiNanManager.WIFI_NAN_DATA_PATH_ROLE_INITIATOR) - ? NanNetworkRequestInformation.STATE_INITIATOR_CONFIRMED - : NanNetworkRequestInformation.STATE_RESPONDER_CONFIRMED; + nnri.state = (nnri.role == WifiAwareManager.WIFI_AWARE_DATA_PATH_ROLE_INITIATOR) + ? AwareNetworkRequestInformation.STATE_INITIATOR_CONFIRMED + : AwareNetworkRequestInformation.STATE_RESPONDER_CONFIRMED; nnri.peerDataMac = mac; NetworkInfo networkInfo = new NetworkInfo(ConnectivityManager.TYPE_WIFI_P2P, 0, @@ -432,7 +434,7 @@ public class WifiNanDataPathStateManager { return networkSpecifier; } - nnri.networkAgent = new WifiNanNetworkAgent(mLooper, mContext, + nnri.networkAgent = new WifiAwareNetworkAgent(mLooper, mContext, AGENT_TAG_PREFIX + nnri.ndpId, new NetworkInfo(ConnectivityManager.TYPE_WIFI_P2P, 0, NETWORK_TAG, ""), networkCapabilities, new LinkProperties(), NETWORK_FACTORY_SCORE_AVAIL, @@ -459,7 +461,7 @@ public class WifiNanDataPathStateManager { public void onDataPathEnd(int ndpId) { if (VDBG) Log.v(TAG, "onDataPathEnd: ndpId=" + ndpId); - Map.Entry<String, NanNetworkRequestInformation> nnriE = getNetworkRequestByNdpId(ndpId); + Map.Entry<String, AwareNetworkRequestInformation> nnriE = getNetworkRequestByNdpId(ndpId); if (nnriE == null) { if (DBG) { Log.d(TAG, "onDataPathEnd: network request not found for ndpId=" + ndpId); @@ -472,12 +474,12 @@ public class WifiNanDataPathStateManager { } /** - * Called whenever NAN comes down. Clean up all pending and up network requeests and agents. + * Called whenever Aware comes down. Clean up all pending and up network requeests and agents. */ - public void onNanDownCleanupDataPaths() { - if (VDBG) Log.v(TAG, "onNanDownCleanupDataPaths"); + public void onAwareDownCleanupDataPaths() { + if (VDBG) Log.v(TAG, "onAwareDownCleanupDataPaths"); - for (NanNetworkRequestInformation nnri : mNetworkRequestsCache.values()) { + for (AwareNetworkRequestInformation nnri : mNetworkRequestsCache.values()) { tearDownInterface(nnri); } mNetworkRequestsCache.clear(); @@ -492,7 +494,7 @@ public class WifiNanDataPathStateManager { public void handleDataPathTimeout(String networkSpecifier) { if (VDBG) Log.v(TAG, "handleDataPathTimeout: networkSpecifier=" + networkSpecifier); - NanNetworkRequestInformation nnri = mNetworkRequestsCache.remove(networkSpecifier); + AwareNetworkRequestInformation nnri = mNetworkRequestsCache.remove(networkSpecifier); if (nnri == null) { if (DBG) { Log.d(TAG, @@ -505,44 +507,44 @@ public class WifiNanDataPathStateManager { mMgr.endDataPath(nnri.ndpId); } - private class WifiNanNetworkFactory extends NetworkFactory { - WifiNanNetworkFactory(Looper looper, Context context, NetworkCapabilities filter) { + private class WifiAwareNetworkFactory extends NetworkFactory { + WifiAwareNetworkFactory(Looper looper, Context context, NetworkCapabilities filter) { super(looper, context, NETWORK_TAG, filter); } @Override public boolean acceptRequest(NetworkRequest request, int score) { if (VDBG) { - Log.v(TAG, "WifiNanNetworkFactory.acceptRequest: request=" + request + ", score=" + Log.v(TAG, "WifiAwareNetworkFactory.acceptRequest: request=" + request + ", score=" + score); } if (!mMgr.isUsageEnabled()) { if (VDBG) { - Log.v(TAG, "WifiNanNetworkFactory.acceptRequest: request=" + request - + " -- NAN disabled"); + Log.v(TAG, "WifiAwareNetworkFactory.acceptRequest: request=" + request + + " -- Aware disabled"); } return false; } if (mInterfaces.isEmpty()) { - Log.w(TAG, "WifiNanNetworkFactory.acceptRequest: request=" + request - + " -- No NAN interfaces are up"); + Log.w(TAG, "WifiAwareNetworkFactory.acceptRequest: request=" + request + + " -- No Aware interfaces are up"); return false; } String networkSpecifier = request.networkCapabilities.getNetworkSpecifier(); if (TextUtils.isEmpty(networkSpecifier)) { - Log.w(TAG, "WifiNanNetworkFactory.acceptRequest: request=" + request + Log.w(TAG, "WifiAwareNetworkFactory.acceptRequest: request=" + request + " - empty (or null) NetworkSpecifier"); return false; } // look up specifier - are we being called again? - NanNetworkRequestInformation nnri = mNetworkRequestsCache.get(networkSpecifier); + AwareNetworkRequestInformation nnri = mNetworkRequestsCache.get(networkSpecifier); if (nnri != null) { if (DBG) { - Log.d(TAG, "WifiNanNetworkFactory.acceptRequest: request=" + request + Log.d(TAG, "WifiAwareNetworkFactory.acceptRequest: request=" + request + " - already in cache!?"); } @@ -554,9 +556,9 @@ public class WifiNanDataPathStateManager { // parse network specifier (JSON) & cache // TODO: validate that the client ID actually comes from the correct process and is // not faked? - nnri = NanNetworkRequestInformation.parseNetworkSpecifier(networkSpecifier, mMgr); + nnri = AwareNetworkRequestInformation.parseNetworkSpecifier(networkSpecifier, mMgr); if (nnri == null) { - Log.e(TAG, "WifiNanNetworkFactory.acceptRequest: request=" + request + Log.e(TAG, "WifiAwareNetworkFactory.acceptRequest: request=" + request + " - can't parse network specifier"); return false; } @@ -568,22 +570,22 @@ public class WifiNanDataPathStateManager { @Override protected void needNetworkFor(NetworkRequest networkRequest, int score) { if (VDBG) { - Log.v(TAG, "WifiNanNetworkFactory.needNetworkFor: networkRequest=" + networkRequest - + ", score=" + score); + Log.v(TAG, "WifiAwareNetworkFactory.needNetworkFor: networkRequest=" + + networkRequest + ", score=" + score); } String networkSpecifier = networkRequest.networkCapabilities.getNetworkSpecifier(); - NanNetworkRequestInformation nnri = mNetworkRequestsCache.get(networkSpecifier); + AwareNetworkRequestInformation nnri = mNetworkRequestsCache.get(networkSpecifier); if (nnri == null) { - Log.e(TAG, "WifiNanNetworkFactory.needNetworkFor: networkRequest=" + networkRequest - + " not in cache!?"); + Log.e(TAG, "WifiAwareNetworkFactory.needNetworkFor: networkRequest=" + + networkRequest + " not in cache!?"); return; } - if (nnri.role == WifiNanManager.WIFI_NAN_DATA_PATH_ROLE_INITIATOR) { - if (nnri.state != NanNetworkRequestInformation.STATE_INITIATOR_IDLE) { + if (nnri.role == WifiAwareManager.WIFI_AWARE_DATA_PATH_ROLE_INITIATOR) { + if (nnri.state != AwareNetworkRequestInformation.STATE_INITIATOR_IDLE) { if (DBG) { - Log.d(TAG, "WifiNanNetworkFactory.needNetworkFor: networkRequest=" + Log.d(TAG, "WifiAwareNetworkFactory.needNetworkFor: networkRequest=" + networkRequest + " - already in progress"); // TODO: understand how/when can be called again/while in progress (seems // to be related to score re-calculation after a network agent is created) @@ -593,13 +595,15 @@ public class WifiNanDataPathStateManager { nnri.interfaceName = selectInterfaceForRequest(nnri); mMgr.initiateDataPathSetup(networkSpecifier, nnri.peerId, - WifiNanNative.CHANNEL_REQUEST_TYPE_REQUESTED, selectChannelForRequest(nnri), - nnri.peerDiscoveryMac, nnri.interfaceName, nnri.token); - nnri.state = NanNetworkRequestInformation.STATE_INITIATOR_WAIT_FOR_REQUEST_RESPONSE; + WifiAwareNative.CHANNEL_REQUEST_TYPE_REQUESTED, + selectChannelForRequest(nnri), nnri.peerDiscoveryMac, nnri.interfaceName, + nnri.token); + nnri.state = + AwareNetworkRequestInformation.STATE_INITIATOR_WAIT_FOR_REQUEST_RESPONSE; } else { - if (nnri.state != NanNetworkRequestInformation.STATE_RESPONDER_IDLE) { + if (nnri.state != AwareNetworkRequestInformation.STATE_RESPONDER_IDLE) { if (DBG) { - Log.d(TAG, "WifiNanNetworkFactory.needNetworkFor: networkRequest=" + Log.d(TAG, "WifiAwareNetworkFactory.needNetworkFor: networkRequest=" + networkRequest + " - already in progress"); // TODO: understand how/when can be called again/while in progress (seems // to be related to score re-calculation after a network agent is created) @@ -607,29 +611,28 @@ public class WifiNanDataPathStateManager { return; } - nnri.state = NanNetworkRequestInformation.STATE_RESPONDER_WAIT_FOR_REQUEST; + nnri.state = AwareNetworkRequestInformation.STATE_RESPONDER_WAIT_FOR_REQUEST; } } @Override protected void releaseNetworkFor(NetworkRequest networkRequest) { if (VDBG) { - Log.v(TAG, "WifiNanNetworkFactory.releaseNetworkFor: networkRequest=" + Log.v(TAG, "WifiAwareNetworkFactory.releaseNetworkFor: networkRequest=" + networkRequest); } String networkSpecifier = networkRequest.networkCapabilities.getNetworkSpecifier(); - NanNetworkRequestInformation nnri = mNetworkRequestsCache.get(networkSpecifier); + AwareNetworkRequestInformation nnri = mNetworkRequestsCache.get(networkSpecifier); if (nnri == null) { - Log.e(TAG, - "WifiNanNetworkFactory.releaseNetworkFor: networkRequest=" + networkRequest - + " not in cache!?"); + Log.e(TAG, "WifiAwareNetworkFactory.releaseNetworkFor: networkRequest=" + + networkRequest + " not in cache!?"); return; } if (nnri.networkAgent != null) { if (VDBG) { - Log.v(TAG, "WifiNanNetworkFactory.releaseNetworkFor: networkRequest=" + Log.v(TAG, "WifiAwareNetworkFactory.releaseNetworkFor: networkRequest=" + networkRequest + ", nnri=" + nnri + ": agent already created - deferring ending data-path to agent" + ".unwanted()"); @@ -637,12 +640,12 @@ public class WifiNanDataPathStateManager { return; } - if (nnri.role == WifiNanManager.WIFI_NAN_DATA_PATH_ROLE_INITIATOR && nnri.state - > NanNetworkRequestInformation.STATE_INITIATOR_WAIT_FOR_REQUEST_RESPONSE) { + if (nnri.role == WifiAwareManager.WIFI_AWARE_DATA_PATH_ROLE_INITIATOR && nnri.state + > AwareNetworkRequestInformation.STATE_INITIATOR_WAIT_FOR_REQUEST_RESPONSE) { mMgr.endDataPath(nnri.ndpId); } - if (nnri.role == WifiNanManager.WIFI_NAN_DATA_PATH_ROLE_RESPONDER - && nnri.state > NanNetworkRequestInformation.STATE_RESPONDER_WAIT_FOR_REQUEST) { + if (nnri.role == WifiAwareManager.WIFI_AWARE_DATA_PATH_ROLE_RESPONDER && nnri.state + > AwareNetworkRequestInformation.STATE_RESPONDER_WAIT_FOR_REQUEST) { mMgr.endDataPath(nnri.ndpId); } @@ -651,12 +654,12 @@ public class WifiNanDataPathStateManager { } } - private class WifiNanNetworkAgent extends NetworkAgent { + private class WifiAwareNetworkAgent extends NetworkAgent { private NetworkInfo mNetworkInfo; private String mNetworkSpecifier; private int mNdpId; - WifiNanNetworkAgent(Looper looper, Context context, String logTag, NetworkInfo ni, + WifiAwareNetworkAgent(Looper looper, Context context, String logTag, NetworkInfo ni, NetworkCapabilities nc, LinkProperties lp, int score, String networkSpecifier, int ndpId) { super(looper, context, logTag, ni, nc, lp, score); @@ -669,7 +672,7 @@ public class WifiNanDataPathStateManager { @Override protected void unwanted() { if (VDBG) { - Log.v(TAG, "WifiNanNetworkAgent.unwanted: networkSpecifier=" + mNetworkSpecifier + Log.v(TAG, "WifiAwareNetworkAgent.unwanted: networkSpecifier=" + mNetworkSpecifier + ", ndpId=" + mNdpId); } @@ -681,7 +684,7 @@ public class WifiNanDataPathStateManager { void reconfigureAgentAsDisconnected() { if (VDBG) { - Log.v(TAG, "WifiNanNetworkAgent.reconfigureAgentAsDisconnected: networkSpecifier=" + Log.v(TAG, "WifiAwareNetworkAgent.reconfigureAgentAsDisconnected: networkSpecifier=" + mNetworkSpecifier + ", ndpId=" + mNdpId); } @@ -690,7 +693,7 @@ public class WifiNanDataPathStateManager { } } - private void tearDownInterface(NanNetworkRequestInformation nnri) { + private void tearDownInterface(AwareNetworkRequestInformation nnri) { if (VDBG) Log.v(TAG, "tearDownInterface: nnri=" + nnri); if (nnri.interfaceName != null && !nnri.interfaceName.isEmpty()) { @@ -713,7 +716,7 @@ public class WifiNanDataPathStateManager { * * TODO: for now there is only a single interface - simply pick it. */ - private String selectInterfaceForRequest(NanNetworkRequestInformation req) { + private String selectInterfaceForRequest(AwareNetworkRequestInformation req) { Iterator<String> it = mInterfaces.iterator(); if (it.hasNext()) { return it.next(); @@ -729,16 +732,16 @@ public class WifiNanDataPathStateManager { * * TODO: for now simply select channel 6 */ - private int selectChannelForRequest(NanNetworkRequestInformation req) { + private int selectChannelForRequest(AwareNetworkRequestInformation req) { return 2437; } /** - * NAN network request. State object: contains network request information/state through its + * Aware network request. State object: contains network request information/state through its * lifetime. */ @VisibleForTesting - public static class NanNetworkRequestInformation { + public static class AwareNetworkRequestInformation { static final int STATE_INITIATOR_IDLE = 100; static final int STATE_INITIATOR_WAIT_FOR_REQUEST_RESPONSE = 101; static final int STATE_INITIATOR_WAIT_FOR_CONFIRM = 102; @@ -762,10 +765,10 @@ public class WifiNanDataPathStateManager { public int ndpId; public byte[] peerDataMac; - public WifiNanNetworkAgent networkAgent; + public WifiAwareNetworkAgent networkAgent; - static NanNetworkRequestInformation parseNetworkSpecifier(String networkSpecifier, - WifiNanStateManager mgr) { + static AwareNetworkRequestInformation parseNetworkSpecifier(String networkSpecifier, + WifiAwareStateManager mgr) { int type, role, uid, clientId, sessionId = 0, peerId = 0, pubSubId = 0; byte[] peerMac = null; byte[] token = null; @@ -778,25 +781,25 @@ public class WifiNanDataPathStateManager { JSONObject jsonObject = new JSONObject(networkSpecifier); // type: always present - type = jsonObject.getInt(WifiNanManager.NETWORK_SPECIFIER_KEY_TYPE); - if (type < 0 || type > WifiNanManager.NETWORK_SPECIFIER_TYPE_MAX_VALID) { + type = jsonObject.getInt(WifiAwareManager.NETWORK_SPECIFIER_KEY_TYPE); + if (type < 0 || type > WifiAwareManager.NETWORK_SPECIFIER_TYPE_MAX_VALID) { Log.e(TAG, "parseNetworkSpecifier: networkSpecifier=" + networkSpecifier + ", invalid 'type' value"); return null; } // role: always present - role = jsonObject.getInt(WifiNanManager.NETWORK_SPECIFIER_KEY_ROLE); - if (role != WifiNanManager.WIFI_NAN_DATA_PATH_ROLE_INITIATOR - && role != WifiNanManager.WIFI_NAN_DATA_PATH_ROLE_RESPONDER) { + role = jsonObject.getInt(WifiAwareManager.NETWORK_SPECIFIER_KEY_ROLE); + if (role != WifiAwareManager.WIFI_AWARE_DATA_PATH_ROLE_INITIATOR + && role != WifiAwareManager.WIFI_AWARE_DATA_PATH_ROLE_RESPONDER) { Log.e(TAG, "parseNetworkSpecifier: networkSpecifier=" + networkSpecifier + " -- invalid 'role' value"); return null; } - if (role == WifiNanManager.WIFI_NAN_DATA_PATH_ROLE_INITIATOR - && type != WifiNanManager.NETWORK_SPECIFIER_TYPE_1A - && type != WifiNanManager.NETWORK_SPECIFIER_TYPE_2A) { + if (role == WifiAwareManager.WIFI_AWARE_DATA_PATH_ROLE_INITIATOR + && type != WifiAwareManager.NETWORK_SPECIFIER_TYPE_1A + && type != WifiAwareManager.NETWORK_SPECIFIER_TYPE_2A) { Log.e(TAG, "parseNetworkSpecifier: networkSpecifier=" + networkSpecifier + " -- invalid 'type' value for INITIATOR (only 1A and 2A are " + "permitted)"); @@ -804,28 +807,29 @@ public class WifiNanDataPathStateManager { } // clientId: always present - clientId = jsonObject.getInt(WifiNanManager.NETWORK_SPECIFIER_KEY_CLIENT_ID); + clientId = jsonObject.getInt(WifiAwareManager.NETWORK_SPECIFIER_KEY_CLIENT_ID); // sessionId: present for types 1A, 1B, 1C, 1D - if (type == WifiNanManager.NETWORK_SPECIFIER_TYPE_1A - || type == WifiNanManager.NETWORK_SPECIFIER_TYPE_1B - || type == WifiNanManager.NETWORK_SPECIFIER_TYPE_1C - || type == WifiNanManager.NETWORK_SPECIFIER_TYPE_1D) { - sessionId = jsonObject.getInt(WifiNanManager.NETWORK_SPECIFIER_KEY_SESSION_ID); + if (type == WifiAwareManager.NETWORK_SPECIFIER_TYPE_1A + || type == WifiAwareManager.NETWORK_SPECIFIER_TYPE_1B + || type == WifiAwareManager.NETWORK_SPECIFIER_TYPE_1C + || type == WifiAwareManager.NETWORK_SPECIFIER_TYPE_1D) { + sessionId = jsonObject.getInt( + WifiAwareManager.NETWORK_SPECIFIER_KEY_SESSION_ID); } // peer Id: present for types 1A, 1B - if (type == WifiNanManager.NETWORK_SPECIFIER_TYPE_1A - || type == WifiNanManager.NETWORK_SPECIFIER_TYPE_1B) { - peerId = jsonObject.getInt(WifiNanManager.NETWORK_SPECIFIER_KEY_PEER_ID); + if (type == WifiAwareManager.NETWORK_SPECIFIER_TYPE_1A + || type == WifiAwareManager.NETWORK_SPECIFIER_TYPE_1B) { + peerId = jsonObject.getInt(WifiAwareManager.NETWORK_SPECIFIER_KEY_PEER_ID); } // peerMac: present for types 2A, 2B - if (type == WifiNanManager.NETWORK_SPECIFIER_TYPE_2A - || type == WifiNanManager.NETWORK_SPECIFIER_TYPE_2B) { + if (type == WifiAwareManager.NETWORK_SPECIFIER_TYPE_2A + || type == WifiAwareManager.NETWORK_SPECIFIER_TYPE_2B) { try { peerMac = HexEncoding.decode(jsonObject.getString( - WifiNanManager.NETWORK_SPECIFIER_KEY_PEER_MAC).toCharArray(), + WifiAwareManager.NETWORK_SPECIFIER_KEY_PEER_MAC).toCharArray(), false); if (peerMac == null || peerMac.length != 6) { Log.e(TAG, "parseNetworkSpecifier: networkSpecifier=" + networkSpecifier @@ -840,12 +844,12 @@ public class WifiNanDataPathStateManager { } // token: present for types 1A, 1C, 2A, 2C - if (type == WifiNanManager.NETWORK_SPECIFIER_TYPE_1A - || type == WifiNanManager.NETWORK_SPECIFIER_TYPE_1C - || type == WifiNanManager.NETWORK_SPECIFIER_TYPE_2A - || type == WifiNanManager.NETWORK_SPECIFIER_TYPE_2C) { + if (type == WifiAwareManager.NETWORK_SPECIFIER_TYPE_1A + || type == WifiAwareManager.NETWORK_SPECIFIER_TYPE_1C + || type == WifiAwareManager.NETWORK_SPECIFIER_TYPE_2A + || type == WifiAwareManager.NETWORK_SPECIFIER_TYPE_2C) { token = Base64.decode( - jsonObject.getString(WifiNanManager.NETWORK_SPECIFIER_KEY_TOKEN), + jsonObject.getString(WifiAwareManager.NETWORK_SPECIFIER_KEY_TOKEN), Base64.DEFAULT); } } catch (JSONException e) { @@ -854,8 +858,8 @@ public class WifiNanDataPathStateManager { return null; } - // look up network specifier information in NAN state manager - WifiNanClientState client = mgr.getClient(clientId); + // look up network specifier information in Aware state manager + WifiAwareClientState client = mgr.getClient(clientId); if (client == null) { Log.e(TAG, "parseNetworkSpecifier: networkSpecifier=" + networkSpecifier + " -- not client with this id -- clientId=" + clientId); @@ -863,9 +867,9 @@ public class WifiNanDataPathStateManager { } uid = client.getUid(); - if (type == WifiNanManager.NETWORK_SPECIFIER_TYPE_1A - || type == WifiNanManager.NETWORK_SPECIFIER_TYPE_1B) { - WifiNanDiscoverySessionState session = client.getSession(sessionId); + if (type == WifiAwareManager.NETWORK_SPECIFIER_TYPE_1A + || type == WifiAwareManager.NETWORK_SPECIFIER_TYPE_1B) { + WifiAwareDiscoverySessionState session = client.getSession(sessionId); if (session == null) { Log.e(TAG, "parseNetworkSpecifier: networkSpecifier=" + networkSpecifier @@ -897,10 +901,10 @@ public class WifiNanDataPathStateManager { } // create container and populate - NanNetworkRequestInformation nnri = new NanNetworkRequestInformation(); - nnri.state = (role == WifiNanManager.WIFI_NAN_DATA_PATH_ROLE_INITIATOR) - ? NanNetworkRequestInformation.STATE_INITIATOR_IDLE - : NanNetworkRequestInformation.STATE_RESPONDER_IDLE; + AwareNetworkRequestInformation nnri = new AwareNetworkRequestInformation(); + nnri.state = (role == WifiAwareManager.WIFI_AWARE_DATA_PATH_ROLE_INITIATOR) + ? AwareNetworkRequestInformation.STATE_INITIATOR_IDLE + : AwareNetworkRequestInformation.STATE_RESPONDER_IDLE; nnri.role = role; nnri.uid = uid; nnri.pubSubId = pubSubId; @@ -913,7 +917,7 @@ public class WifiNanDataPathStateManager { @Override public String toString() { - StringBuilder sb = new StringBuilder("NanNetworkRequestInformation: "); + StringBuilder sb = new StringBuilder("AwareNetworkRequestInformation: "); sb.append("state=").append(state).append(", role=").append(role).append( ", uid=").append(uid).append(", interfaceName=").append(interfaceName).append( ", pubSubId=").append(pubSubId).append(", peerDiscoveryMac=").append( @@ -935,7 +939,7 @@ public class WifiNanDataPathStateManager { * Configures network agent properties: link-local address, connected status, interface * name. Delegated to enable mocking. */ - public boolean configureAgentProperties(NanNetworkRequestInformation nnri, + public boolean configureAgentProperties(AwareNetworkRequestInformation nnri, String networkSpecifier, int ndpId, NetworkInfo networkInfo, NetworkCapabilities networkCapabilities, LinkProperties linkProperties) { // find link-local address @@ -989,7 +993,7 @@ public class WifiNanDataPathStateManager { * Dump the internal state of the class. */ public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { - pw.println("WifiNanDataPathStateManager:"); + pw.println("WifiAwareDataPathStateManager:"); pw.println(" mInterfaces: " + mInterfaces); pw.println(" mNetworkCapabilitiesFilter: " + mNetworkCapabilitiesFilter); pw.println(" mNetworkRequestsCache: " + mNetworkRequestsCache); diff --git a/service/java/com/android/server/wifi/nan/WifiNanDiscoverySessionState.java b/service/java/com/android/server/wifi/aware/WifiAwareDiscoverySessionState.java index e393f869f..c5598d763 100644 --- a/service/java/com/android/server/wifi/nan/WifiNanDiscoverySessionState.java +++ b/service/java/com/android/server/wifi/aware/WifiAwareDiscoverySessionState.java @@ -14,11 +14,11 @@ * limitations under the License. */ -package com.android.server.wifi.nan; +package com.android.server.wifi.aware; -import android.net.wifi.nan.IWifiNanDiscoverySessionCallback; -import android.net.wifi.nan.PublishConfig; -import android.net.wifi.nan.SubscribeConfig; +import android.net.wifi.aware.IWifiAwareDiscoverySessionCallback; +import android.net.wifi.aware.PublishConfig; +import android.net.wifi.aware.SubscribeConfig; import android.os.RemoteException; import android.util.Log; import android.util.SparseArray; @@ -29,25 +29,25 @@ import java.io.FileDescriptor; import java.io.PrintWriter; /** - * Manages the state of a single NAN discovery session (publish or subscribe). + * Manages the state of a single Aware discovery session (publish or subscribe). * Primary state consists of a callback through which session callbacks are * executed as well as state related to currently active discovery sessions: * publish/subscribe ID, and MAC address caching (hiding) from clients. */ -public class WifiNanDiscoverySessionState { - private static final String TAG = "WifiNanDiscSessionState"; +public class WifiAwareDiscoverySessionState { + private static final String TAG = "WifiAwareDiscSessState"; private static final boolean DBG = false; private static final boolean VDBG = false; // STOPSHIP if true private int mSessionId; private int mPubSubId; - private IWifiNanDiscoverySessionCallback mCallback; + private IWifiAwareDiscoverySessionCallback mCallback; private boolean mIsPublishSession; private final SparseArray<String> mMacByRequestorInstanceId = new SparseArray<>(); - public WifiNanDiscoverySessionState(int sessionId, int pubSubId, - IWifiNanDiscoverySessionCallback callback, boolean isPublishSession) { + public WifiAwareDiscoverySessionState(int sessionId, int pubSubId, + IWifiAwareDiscoverySessionCallback callback, boolean isPublishSession) { mSessionId = sessionId; mPubSubId = pubSubId; mCallback = callback; @@ -62,7 +62,7 @@ public class WifiNanDiscoverySessionState { return mPubSubId; } - public IWifiNanDiscoverySessionCallback getCallback() { + public IWifiAwareDiscoverySessionCallback getCallback() { return mCallback; } @@ -87,9 +87,9 @@ public class WifiNanDiscoverySessionState { mCallback = null; if (mIsPublishSession) { - WifiNanNative.getInstance().stopPublish((short) 0, mPubSubId); + WifiAwareNative.getInstance().stopPublish((short) 0, mPubSubId); } else { - WifiNanNative.getInstance().stopSubscribe((short) 0, mPubSubId); + WifiAwareNative.getInstance().stopSubscribe((short) 0, mPubSubId); } } @@ -115,14 +115,14 @@ public class WifiNanDiscoverySessionState { if (!mIsPublishSession) { Log.e(TAG, "A SUBSCRIBE session is being used to publish"); try { - mCallback.onSessionConfigFail(WifiNanNative.NAN_STATUS_ERROR); + mCallback.onSessionConfigFail(WifiAwareNative.AWARE_STATUS_ERROR); } catch (RemoteException e) { Log.e(TAG, "updatePublish: RemoteException=" + e); } return false; } - return WifiNanNative.getInstance().publish(transactionId, mPubSubId, config); + return WifiAwareNative.getInstance().publish(transactionId, mPubSubId, config); } /** @@ -136,14 +136,14 @@ public class WifiNanDiscoverySessionState { if (mIsPublishSession) { Log.e(TAG, "A PUBLISH session is being used to subscribe"); try { - mCallback.onSessionConfigFail(WifiNanNative.NAN_STATUS_ERROR); + mCallback.onSessionConfigFail(WifiAwareNative.AWARE_STATUS_ERROR); } catch (RemoteException e) { Log.e(TAG, "updateSubscribe: RemoteException=" + e); } return false; } - return WifiNanNative.getInstance().subscribe(transactionId, mPubSubId, config); + return WifiAwareNative.getInstance().subscribe(transactionId, mPubSubId, config); } /** @@ -163,7 +163,7 @@ public class WifiNanDiscoverySessionState { Log.e(TAG, "sendMessage: attempting to send a message to an address which didn't " + "match/contact us"); try { - mCallback.onMessageSendFail(messageId, WifiNanNative.NAN_STATUS_ERROR); + mCallback.onMessageSendFail(messageId, WifiAwareNative.AWARE_STATUS_ERROR); } catch (RemoteException e) { Log.e(TAG, "sendMessage: RemoteException=" + e); } @@ -171,7 +171,7 @@ public class WifiNanDiscoverySessionState { } byte[] peerMac = HexEncoding.decode(peerMacStr.toCharArray(), false); - return WifiNanNative.getInstance().sendMessage(transactionId, mPubSubId, peerId, peerMac, + return WifiAwareNative.getInstance().sendMessage(transactionId, mPubSubId, peerId, peerMac, message, messageId); } @@ -232,7 +232,7 @@ public class WifiNanDiscoverySessionState { * Dump the internal state of the class. */ public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { - pw.println("NanSessionState:"); + pw.println("AwareSessionState:"); pw.println(" mSessionId: " + mSessionId); pw.println(" mIsPublishSession: " + mIsPublishSession); pw.println(" mPubSubId: " + mPubSubId); diff --git a/service/java/com/android/server/wifi/nan/WifiNanNative.java b/service/java/com/android/server/wifi/aware/WifiAwareNative.java index ba65d40e5..305f26a53 100644 --- a/service/java/com/android/server/wifi/nan/WifiNanNative.java +++ b/service/java/com/android/server/wifi/aware/WifiAwareNative.java @@ -14,13 +14,13 @@ * limitations under the License. */ -package com.android.server.wifi.nan; +package com.android.server.wifi.aware; -import android.net.wifi.nan.ConfigRequest; -import android.net.wifi.nan.PublishConfig; -import android.net.wifi.nan.SubscribeConfig; -import android.net.wifi.nan.WifiNanCharacteristics; -import android.net.wifi.nan.WifiNanDiscoverySessionCallback; +import android.net.wifi.aware.ConfigRequest; +import android.net.wifi.aware.PublishConfig; +import android.net.wifi.aware.SubscribeConfig; +import android.net.wifi.aware.WifiAwareCharacteristics; +import android.net.wifi.aware.WifiAwareDiscoverySessionCallback; import android.os.Bundle; import android.util.Log; @@ -31,30 +31,30 @@ import libcore.util.HexEncoding; import java.util.Arrays; /** - * Native calls to access the Wi-Fi NAN HAL. + * Native calls to access the Wi-Fi Aware HAL. * * Relies on WifiNative to perform the actual HAL registration. */ -public class WifiNanNative { - private static final String TAG = "WifiNanNative"; +public class WifiAwareNative { + private static final String TAG = "WifiAwareNative"; private static final boolean DBG = false; private static final boolean VDBG = false; // STOPSHIP if true private static final int WIFI_SUCCESS = 0; - private static WifiNanNative sWifiNanNativeSingleton; + private static WifiAwareNative sWifiAwareNativeSingleton; private boolean mNativeHandlersIsInitialized = false; - private static native int registerNanNatives(); + private static native int registerAwareNatives(); /** - * Returns the singleton WifiNanNative used to manage the actual NAN HAL + * Returns the singleton WifiAwareNative used to manage the actual Aware HAL * interface. * * @return Singleton object. */ - public static WifiNanNative getInstance() { + public static WifiAwareNative getInstance() { // dummy reference - used to make sure that WifiNative is loaded before // us since it is the one to load the shared library and starts its // initialization. @@ -64,20 +64,20 @@ public class WifiNanNative { return null; } - if (sWifiNanNativeSingleton == null) { - sWifiNanNativeSingleton = new WifiNanNative(); - registerNanNatives(); + if (sWifiAwareNativeSingleton == null) { + sWifiAwareNativeSingleton = new WifiAwareNative(); + registerAwareNatives(); } - return sWifiNanNativeSingleton; + return sWifiAwareNativeSingleton; } /** - * A container class for NAN (vendor) implementation capabilities (or + * A container class for Aware (vendor) implementation capabilities (or * limitations). Filled-in by the firmware. */ public static class Capabilities { - public int maxConcurrentNanClusters; + public int maxConcurrentAwareClusters; public int maxPublishes; public int maxSubscribes; public int maxServiceNameLen; @@ -95,18 +95,18 @@ public class WifiNanNative { * Converts the internal capabilities to a parcelable & potentially app-facing * characteristics bundle. Only some of the information is exposed. */ - public WifiNanCharacteristics toPublicCharacteristics() { + public WifiAwareCharacteristics toPublicCharacteristics() { Bundle bundle = new Bundle(); - bundle.putInt(WifiNanCharacteristics.KEY_MAX_SERVICE_NAME_LENGTH, maxServiceNameLen); - bundle.putInt(WifiNanCharacteristics.KEY_MAX_SERVICE_SPECIFIC_INFO_LENGTH, + bundle.putInt(WifiAwareCharacteristics.KEY_MAX_SERVICE_NAME_LENGTH, maxServiceNameLen); + bundle.putInt(WifiAwareCharacteristics.KEY_MAX_SERVICE_SPECIFIC_INFO_LENGTH, maxServiceSpecificInfoLen); - bundle.putInt(WifiNanCharacteristics.KEY_MAX_MATCH_FILTER_LENGTH, maxMatchFilterLen); - return new WifiNanCharacteristics(bundle); + bundle.putInt(WifiAwareCharacteristics.KEY_MAX_MATCH_FILTER_LENGTH, maxMatchFilterLen); + return new WifiAwareCharacteristics(bundle); } @Override public String toString() { - return "Capabilities [maxConcurrentNanClusters=" + maxConcurrentNanClusters + return "Capabilities [maxConcurrentAwareClusters=" + maxConcurrentAwareClusters + ", maxPublishes=" + maxPublishes + ", maxSubscribes=" + maxSubscribes + ", maxServiceNameLen=" + maxServiceNameLen + ", maxMatchFilterLen=" + maxMatchFilterLen + ", maxTotalMatchFilterLen=" + maxTotalMatchFilterLen @@ -118,9 +118,9 @@ public class WifiNanNative { } } - /* package */ static native int initNanHandlersNative(Class<WifiNative> cls, int iface); + /* package */ static native int initAwareHandlersNative(Class<WifiNative> cls, int iface); - private boolean isNanInit() { + private boolean isAwareInit() { synchronized (WifiNative.sLock) { if (!WifiNative.getWlanNativeInterface().isHalStarted()) { /* @@ -130,8 +130,8 @@ public class WifiNanNative { mNativeHandlersIsInitialized = false; return false; } else if (!mNativeHandlersIsInitialized) { - int ret = initNanHandlersNative(WifiNative.class, WifiNative.sWlan0Index); - if (DBG) Log.d(TAG, "initNanHandlersNative: res=" + ret); + int ret = initAwareHandlersNative(WifiNative.class, WifiNative.sWlan0Index); + if (DBG) Log.d(TAG, "initAwareHandlersNative: res=" + ret); mNativeHandlersIsInitialized = ret == WIFI_SUCCESS; return mNativeHandlersIsInitialized; @@ -142,16 +142,16 @@ public class WifiNanNative { } /** - * Tell the NAN JNI to re-initialize the NAN callback pointers next time it starts up. + * Tell the Aware JNI to re-initialize the Aware callback pointers next time it starts up. */ - public void deInitNan() { + public void deInitAware() { if (VDBG) { - Log.v(TAG, "deInitNan: mNativeHandlersIsInitialized=" + mNativeHandlersIsInitialized); + Log.v(TAG, "deInitAware: mNativeHandlersIsInitialized=" + mNativeHandlersIsInitialized); } mNativeHandlersIsInitialized = false; } - private WifiNanNative() { + private WifiAwareNative() { // do nothing } @@ -159,14 +159,14 @@ public class WifiNanNative { int iface); /** - * Query the NAN firmware's capabilities. + * Query the Aware firmware's capabilities. * * @param transactionId Transaction ID for the transaction - used in the async callback to * match with the original request. */ public boolean getCapabilities(short transactionId) { if (VDBG) Log.d(TAG, "getCapabilities"); - if (isNanInit()) { + if (isAwareInit()) { int ret; synchronized (WifiNative.sLock) { ret = getCapabilitiesNative(transactionId, WifiNative.class, @@ -177,7 +177,7 @@ public class WifiNanNative { } return ret == WIFI_SUCCESS; } else { - Log.w(TAG, "getCapabilities: cannot initialize NAN"); + Log.w(TAG, "getCapabilities: cannot initialize Aware"); return false; } } @@ -189,18 +189,18 @@ public class WifiNanNative { int iface, ConfigRequest configRequest); /** - * Enable and configure NAN. + * Enable and configure Aware. * * @param transactionId Transaction ID for the transaction - used in the * async callback to match with the original request. - * @param configRequest Requested NAN configuration. + * @param configRequest Requested Aware configuration. * @param initialConfiguration Specifies whether initial configuration * (true) or an update (false) to the configuration. */ public boolean enableAndConfigure(short transactionId, ConfigRequest configRequest, boolean initialConfiguration) { if (VDBG) Log.d(TAG, "enableAndConfigure: configRequest=" + configRequest); - if (isNanInit()) { + if (isAwareInit()) { int ret; if (initialConfiguration) { synchronized (WifiNative.sLock) { @@ -221,7 +221,7 @@ public class WifiNanNative { } return ret == WIFI_SUCCESS; } else { - Log.w(TAG, "enableAndConfigure: NanInit fails"); + Log.w(TAG, "enableAndConfigure: AwareInit fails"); return false; } } @@ -229,14 +229,14 @@ public class WifiNanNative { private static native int disableNative(short transactionId, Class<WifiNative> cls, int iface); /** - * Disable NAN. + * Disable Aware. * * @param transactionId transactionId Transaction ID for the transaction - * used in the async callback to match with the original request. */ public boolean disable(short transactionId) { - if (VDBG) Log.d(TAG, "disableNan"); - if (isNanInit()) { + if (VDBG) Log.d(TAG, "disableAware"); + if (isAwareInit()) { int ret; synchronized (WifiNative.sLock) { ret = disableNative(transactionId, WifiNative.class, WifiNative.sWlan0Index); @@ -246,7 +246,7 @@ public class WifiNanNative { } return ret == WIFI_SUCCESS; } else { - Log.w(TAG, "disable: cannot initialize NAN"); + Log.w(TAG, "disable: cannot initialize Aware"); return false; } } @@ -268,7 +268,7 @@ public class WifiNanNative { Log.d(TAG, "publish: transactionId=" + transactionId + ", config=" + publishConfig); } - if (isNanInit()) { + if (isAwareInit()) { int ret; synchronized (WifiNative.sLock) { ret = publishNative(transactionId, publishId, WifiNative.class, @@ -279,7 +279,7 @@ public class WifiNanNative { } return ret == WIFI_SUCCESS; } else { - Log.w(TAG, "publish: cannot initialize NAN"); + Log.w(TAG, "publish: cannot initialize Aware"); return false; } } @@ -302,7 +302,7 @@ public class WifiNanNative { Log.d(TAG, "subscribe: transactionId=" + transactionId + ", config=" + subscribeConfig); } - if (isNanInit()) { + if (isAwareInit()) { int ret; synchronized (WifiNative.sLock) { ret = subscribeNative(transactionId, subscribeId, WifiNative.class, @@ -313,7 +313,7 @@ public class WifiNanNative { } return ret == WIFI_SUCCESS; } else { - Log.w(TAG, "subscribe: cannot initialize NAN"); + Log.w(TAG, "subscribe: cannot initialize Aware"); return false; } } @@ -345,7 +345,7 @@ public class WifiNanNative { + messageId); } - if (isNanInit()) { + if (isAwareInit()) { int ret; synchronized (WifiNative.sLock) { ret = sendMessageNative(transactionId, WifiNative.class, WifiNative.sWlan0Index, @@ -356,7 +356,7 @@ public class WifiNanNative { } return ret == WIFI_SUCCESS; } else { - Log.w(TAG, "sendMessage: cannot initialize NAN"); + Log.w(TAG, "sendMessage: cannot initialize Aware"); return false; } } @@ -377,7 +377,7 @@ public class WifiNanNative { Log.d(TAG, "stopPublish: transactionId=" + transactionId + ", pubSubId=" + pubSubId); } - if (isNanInit()) { + if (isAwareInit()) { int ret; synchronized (WifiNative.sLock) { ret = stopPublishNative(transactionId, WifiNative.class, WifiNative.sWlan0Index, @@ -388,7 +388,7 @@ public class WifiNanNative { } return ret == WIFI_SUCCESS; } else { - Log.w(TAG, "stopPublish: cannot initialize NAN"); + Log.w(TAG, "stopPublish: cannot initialize Aware"); return false; } } @@ -409,7 +409,7 @@ public class WifiNanNative { Log.d(TAG, "stopSubscribe: transactionId=" + transactionId + ", pubSubId=" + pubSubId); } - if (isNanInit()) { + if (isAwareInit()) { int ret; synchronized (WifiNative.sLock) { ret = stopSubscribeNative(transactionId, WifiNative.class, WifiNative.sWlan0Index, @@ -420,76 +420,76 @@ public class WifiNanNative { } return ret == WIFI_SUCCESS; } else { - Log.w(TAG, "stopSubscribe: cannot initialize NAN"); + Log.w(TAG, "stopSubscribe: cannot initialize Aware"); return false; } } - private static native int createNanNetworkInterfaceNative(short transactionId, + private static native int createAwareNetworkInterfaceNative(short transactionId, Class<WifiNative> cls, int iface, String interfaceName); /** - * Create a NAN network interface. This only creates the Linux interface - it doesn't actually + * Create a Aware network interface. This only creates the Linux interface - it doesn't actually * create the data connection. * * @param transactionId Transaction ID for the transaction - used in the async callback to * match with the original request. - * @param interfaceName The name of the interface, e.g. "nan0". + * @param interfaceName The name of the interface, e.g. "aware0". */ - public boolean createNanNetworkInterface(short transactionId, String interfaceName) { + public boolean createAwareNetworkInterface(short transactionId, String interfaceName) { if (VDBG) { - Log.v(TAG, "createNanNetworkInterface: transactionId=" + transactionId + ", " + Log.v(TAG, "createAwareNetworkInterface: transactionId=" + transactionId + ", " + "interfaceName=" + interfaceName); } - if (isNanInit()) { + if (isAwareInit()) { int ret; synchronized (WifiNative.sLock) { - ret = createNanNetworkInterfaceNative(transactionId, WifiNative.class, WifiNative + ret = createAwareNetworkInterfaceNative(transactionId, WifiNative.class, WifiNative .sWlan0Index, interfaceName); } if (ret != WIFI_SUCCESS) { - Log.w(TAG, - "createNanNetworkInterfaceNative: HAL API returned non-success -- " + ret); + Log.w(TAG, "createAwareNetworkInterfaceNative: HAL API returned non-success -- " + + ret); } return ret == WIFI_SUCCESS; } else { - Log.w(TAG, "createNanNetworkInterface: cannot initialize NAN"); + Log.w(TAG, "createAwareNetworkInterface: cannot initialize Aware"); return false; } } - private static native int deleteNanNetworkInterfaceNative(short transactionId, + private static native int deleteAwareNetworkInterfaceNative(short transactionId, Class<WifiNative> cls, int iface, String interfaceName); /** - * Deletes a NAN network interface. The data connection can (should?) be torn down previously. + * Deletes a Aware network interface. The data connection can (should?) be torn down previously. * * @param transactionId Transaction ID for the transaction - used in the async callback to * match with the original request. - * @param interfaceName The name of the interface, e.g. "nan0". + * @param interfaceName The name of the interface, e.g. "aware0". */ - public boolean deleteNanNetworkInterface(short transactionId, String interfaceName) { + public boolean deleteAwareNetworkInterface(short transactionId, String interfaceName) { if (VDBG) { - Log.v(TAG, "deleteNanNetworkInterface: transactionId=" + transactionId + ", " + Log.v(TAG, "deleteAwareNetworkInterface: transactionId=" + transactionId + ", " + "interfaceName=" + interfaceName); } - if (isNanInit()) { + if (isAwareInit()) { int ret; synchronized (WifiNative.sLock) { - ret = deleteNanNetworkInterfaceNative(transactionId, WifiNative.class, WifiNative + ret = deleteAwareNetworkInterfaceNative(transactionId, WifiNative.class, WifiNative .sWlan0Index, interfaceName); } if (ret != WIFI_SUCCESS) { - Log.w(TAG, - "deleteNanNetworkInterfaceNative: HAL API returned non-success -- " + ret); + Log.w(TAG, "deleteAwareNetworkInterfaceNative: HAL API returned non-success -- " + + ret); } return ret == WIFI_SUCCESS; } else { - Log.w(TAG, "deleteNanNetworkInterface: cannot initialize NAN"); + Log.w(TAG, "deleteAwareNetworkInterface: cannot initialize Aware"); return false; } } @@ -527,7 +527,7 @@ public class WifiNanNative { + interfaceName); } - if (isNanInit()) { + if (isAwareInit()) { int ret; synchronized (WifiNative.sLock) { ret = initiateDataPathNative(transactionId, WifiNative.class, WifiNative @@ -539,7 +539,7 @@ public class WifiNanNative { } return ret == WIFI_SUCCESS; } else { - Log.w(TAG, "initiateDataPath: cannot initialize NAN"); + Log.w(TAG, "initiateDataPath: cannot initialize Aware"); return false; } } @@ -554,7 +554,7 @@ public class WifiNanNative { * @param transactionId Transaction ID for the transaction - used in the async callback to * match with the original request. * @param accept Accept (true) or reject (false) the original call. - * @param ndpId The NDP (NAN data path) ID. Obtained from the request callback. + * @param ndpId The NDP (Aware data path) ID. Obtained from the request callback. * @param interfaceName The interface on which the data path will be setup. Obtained from the * request callback. * @param message An arbitrary byte array to forward to the peer in the respond message. @@ -566,7 +566,7 @@ public class WifiNanNative { + accept + ", int ndpId=" + ndpId + ", interfaceName=" + interfaceName); } - if (isNanInit()) { + if (isAwareInit()) { int ret; synchronized (WifiNative.sLock) { ret = respondToDataPathRequestNative(transactionId, WifiNative.class, WifiNative @@ -578,7 +578,7 @@ public class WifiNanNative { } return ret == WIFI_SUCCESS; } else { - Log.w(TAG, "respondToDataPathRequest: cannot initialize NAN"); + Log.w(TAG, "respondToDataPathRequest: cannot initialize Aware"); return false; } } @@ -591,14 +591,14 @@ public class WifiNanNative { * * @param transactionId Transaction ID for the transaction - used in the async callback to * match with the original request. - * @param ndpId The NDP (NAN data path) ID to be terminated. + * @param ndpId The NDP (Aware data path) ID to be terminated. */ public boolean endDataPath(short transactionId, int ndpId) { if (VDBG) { Log.v(TAG, "endDataPath: transactionId=" + transactionId + ", ndpId=" + ndpId); } - if (isNanInit()) { + if (isAwareInit()) { int ret; synchronized (WifiNative.sLock) { ret = endDataPathNative(transactionId, WifiNative.class, WifiNative.sWlan0Index, @@ -609,290 +609,295 @@ public class WifiNanNative { } return ret == WIFI_SUCCESS; } else { - Log.w(TAG, "endDataPath: cannot initialize NAN"); + Log.w(TAG, "endDataPath: cannot initialize Aware"); return false; } } // EVENTS - // NanResponseType for API responses: will add values as needed - public static final int NAN_RESPONSE_ENABLED = 0; - public static final int NAN_RESPONSE_PUBLISH = 2; - public static final int NAN_RESPONSE_PUBLISH_CANCEL = 3; - public static final int NAN_RESPONSE_TRANSMIT_FOLLOWUP = 4; - public static final int NAN_RESPONSE_SUBSCRIBE = 5; - public static final int NAN_RESPONSE_SUBSCRIBE_CANCEL = 6; - public static final int NAN_RESPONSE_CONFIG = 8; - public static final int NAN_RESPONSE_GET_CAPABILITIES = 12; - public static final int NAN_RESPONSE_DP_INTERFACE_CREATE = 13; - public static final int NAN_RESPONSE_DP_INTERFACE_DELETE = 14; - public static final int NAN_RESPONSE_DP_INITIATOR_RESPONSE = 15; - public static final int NAN_RESPONSE_DP_RESPONDER_RESPONSE = 16; - public static final int NAN_RESPONSE_DP_END = 17; + // AwareResponseType for API responses: will add values as needed + public static final int AWARE_RESPONSE_ENABLED = 0; + public static final int AWARE_RESPONSE_PUBLISH = 2; + public static final int AWARE_RESPONSE_PUBLISH_CANCEL = 3; + public static final int AWARE_RESPONSE_TRANSMIT_FOLLOWUP = 4; + public static final int AWARE_RESPONSE_SUBSCRIBE = 5; + public static final int AWARE_RESPONSE_SUBSCRIBE_CANCEL = 6; + public static final int AWARE_RESPONSE_CONFIG = 8; + public static final int AWARE_RESPONSE_GET_CAPABILITIES = 12; + public static final int AWARE_RESPONSE_DP_INTERFACE_CREATE = 13; + public static final int AWARE_RESPONSE_DP_INTERFACE_DELETE = 14; + public static final int AWARE_RESPONSE_DP_INITIATOR_RESPONSE = 15; + public static final int AWARE_RESPONSE_DP_RESPONDER_RESPONSE = 16; + public static final int AWARE_RESPONSE_DP_END = 17; // TODO: place-holder until resolve error codes/feedback to user b/29443148 - public static final int NAN_STATUS_ERROR = -1; + public static final int AWARE_STATUS_ERROR = -1; // direct copy from wifi_nan.h: need to keep in sync - /* NAN Protocol Response Codes */ - public static final int NAN_STATUS_SUCCESS = 0; - public static final int NAN_STATUS_TIMEOUT = 1; - public static final int NAN_STATUS_DE_FAILURE = 2; - public static final int NAN_STATUS_INVALID_MSG_VERSION = 3; - public static final int NAN_STATUS_INVALID_MSG_LEN = 4; - public static final int NAN_STATUS_INVALID_MSG_ID = 5; - public static final int NAN_STATUS_INVALID_HANDLE = 6; - public static final int NAN_STATUS_NO_SPACE_AVAILABLE = 7; - public static final int NAN_STATUS_INVALID_PUBLISH_TYPE = 8; - public static final int NAN_STATUS_INVALID_TX_TYPE = 9; - public static final int NAN_STATUS_INVALID_MATCH_ALGORITHM = 10; - public static final int NAN_STATUS_DISABLE_IN_PROGRESS = 11; - public static final int NAN_STATUS_INVALID_TLV_LEN = 12; - public static final int NAN_STATUS_INVALID_TLV_TYPE = 13; - public static final int NAN_STATUS_MISSING_TLV_TYPE = 14; - public static final int NAN_STATUS_INVALID_TOTAL_TLVS_LEN = 15; - public static final int NAN_STATUS_INVALID_MATCH_HANDLE = 16; - public static final int NAN_STATUS_INVALID_TLV_VALUE = 17; - public static final int NAN_STATUS_INVALID_TX_PRIORITY = 18; - public static final int NAN_STATUS_INVALID_CONNECTION_MAP = 19; - public static final int NAN_STATUS_INVALID_TCA_ID = 20; - public static final int NAN_STATUS_INVALID_STATS_ID = 21; - public static final int NAN_STATUS_NAN_NOT_ALLOWED = 22; - public static final int NAN_STATUS_NO_OTA_ACK = 23; - public static final int NAN_STATUS_TX_FAIL = 24; - public static final int NAN_STATUS_ALREADY_ENABLED = 25; - - /* NAN Configuration Response codes */ - public static final int NAN_STATUS_INVALID_RSSI_CLOSE_VALUE = 4096; - public static final int NAN_STATUS_INVALID_RSSI_MIDDLE_VALUE = 4097; - public static final int NAN_STATUS_INVALID_HOP_COUNT_LIMIT = 4098; - public static final int NAN_STATUS_INVALID_MASTER_PREFERENCE_VALUE = 4099; - public static final int NAN_STATUS_INVALID_LOW_CLUSTER_ID_VALUE = 4100; - public static final int NAN_STATUS_INVALID_HIGH_CLUSTER_ID_VALUE = 4101; - public static final int NAN_STATUS_INVALID_BACKGROUND_SCAN_PERIOD = 4102; - public static final int NAN_STATUS_INVALID_RSSI_PROXIMITY_VALUE = 4103; - public static final int NAN_STATUS_INVALID_SCAN_CHANNEL = 4104; - public static final int NAN_STATUS_INVALID_POST_NAN_CONNECTIVITY_CAPABILITIES_BITMAP = 4105; - public static final int NAN_STATUS_INVALID_FA_MAP_NUMCHAN_VALUE = 4106; - public static final int NAN_STATUS_INVALID_FA_MAP_DURATION_VALUE = 4107; - public static final int NAN_STATUS_INVALID_FA_MAP_CLASS_VALUE = 4108; - public static final int NAN_STATUS_INVALID_FA_MAP_CHANNEL_VALUE = 4109; - public static final int NAN_STATUS_INVALID_FA_MAP_AVAILABILITY_INTERVAL_BITMAP_VALUE = 4110; - public static final int NAN_STATUS_INVALID_FA_MAP_MAP_ID = 4111; - public static final int NAN_STATUS_INVALID_POST_NAN_DISCOVERY_CONN_TYPE_VALUE = 4112; - public static final int NAN_STATUS_INVALID_POST_NAN_DISCOVERY_DEVICE_ROLE_VALUE = 4113; - public static final int NAN_STATUS_INVALID_POST_NAN_DISCOVERY_DURATION_VALUE = 4114; - public static final int NAN_STATUS_INVALID_POST_NAN_DISCOVERY_BITMAP_VALUE = 4115; - public static final int NAN_STATUS_MISSING_FUTHER_AVAILABILITY_MAP = 4116; - public static final int NAN_STATUS_INVALID_BAND_CONFIG_FLAGS = 4117; - public static final int NAN_STATUS_INVALID_RANDOM_FACTOR_UPDATE_TIME_VALUE = 4118; - public static final int NAN_STATUS_INVALID_ONGOING_SCAN_PERIOD = 4119; - public static final int NAN_STATUS_INVALID_DW_INTERVAL_VALUE = 4120; - public static final int NAN_STATUS_INVALID_DB_INTERVAL_VALUE = 4121; + /* Aware Protocol Response Codes */ + public static final int AWARE_STATUS_SUCCESS = 0; + public static final int AWARE_STATUS_TIMEOUT = 1; + public static final int AWARE_STATUS_DE_FAILURE = 2; + public static final int AWARE_STATUS_INVALID_MSG_VERSION = 3; + public static final int AWARE_STATUS_INVALID_MSG_LEN = 4; + public static final int AWARE_STATUS_INVALID_MSG_ID = 5; + public static final int AWARE_STATUS_INVALID_HANDLE = 6; + public static final int AWARE_STATUS_NO_SPACE_AVAILABLE = 7; + public static final int AWARE_STATUS_INVALID_PUBLISH_TYPE = 8; + public static final int AWARE_STATUS_INVALID_TX_TYPE = 9; + public static final int AWARE_STATUS_INVALID_MATCH_ALGORITHM = 10; + public static final int AWARE_STATUS_DISABLE_IN_PROGRESS = 11; + public static final int AWARE_STATUS_INVALID_TLV_LEN = 12; + public static final int AWARE_STATUS_INVALID_TLV_TYPE = 13; + public static final int AWARE_STATUS_MISSING_TLV_TYPE = 14; + public static final int AWARE_STATUS_INVALID_TOTAL_TLVS_LEN = 15; + public static final int AWARE_STATUS_INVALID_MATCH_HANDLE = 16; + public static final int AWARE_STATUS_INVALID_TLV_VALUE = 17; + public static final int AWARE_STATUS_INVALID_TX_PRIORITY = 18; + public static final int AWARE_STATUS_INVALID_CONNECTION_MAP = 19; + public static final int AWARE_STATUS_INVALID_TCA_ID = 20; + public static final int AWARE_STATUS_INVALID_STATS_ID = 21; + public static final int AWARE_STATUS_AWARE_NOT_ALLOWED = 22; + public static final int AWARE_STATUS_NO_OTA_ACK = 23; + public static final int AWARE_STATUS_TX_FAIL = 24; + public static final int AWARE_STATUS_ALREADY_ENABLED = 25; + + /* Aware Configuration Response codes */ + public static final int AWARE_STATUS_INVALID_RSSI_CLOSE_VALUE = 4096; + public static final int AWARE_STATUS_INVALID_RSSI_MIDDLE_VALUE = 4097; + public static final int AWARE_STATUS_INVALID_HOP_COUNT_LIMIT = 4098; + public static final int AWARE_STATUS_INVALID_MASTER_PREFERENCE_VALUE = 4099; + public static final int AWARE_STATUS_INVALID_LOW_CLUSTER_ID_VALUE = 4100; + public static final int AWARE_STATUS_INVALID_HIGH_CLUSTER_ID_VALUE = 4101; + public static final int AWARE_STATUS_INVALID_BACKGROUND_SCAN_PERIOD = 4102; + public static final int AWARE_STATUS_INVALID_RSSI_PROXIMITY_VALUE = 4103; + public static final int AWARE_STATUS_INVALID_SCAN_CHANNEL = 4104; + public static final int AWARE_STATUS_INVALID_POST_AWARE_CONNECTIVITY_CAPABILITIES_BITMAP = 4105; + public static final int AWARE_STATUS_INVALID_FA_MAP_NUMCHAN_VALUE = 4106; + public static final int AWARE_STATUS_INVALID_FA_MAP_DURATION_VALUE = 4107; + public static final int AWARE_STATUS_INVALID_FA_MAP_CLASS_VALUE = 4108; + public static final int AWARE_STATUS_INVALID_FA_MAP_CHANNEL_VALUE = 4109; + public static final int AWARE_STATUS_INVALID_FA_MAP_AVAILABILITY_INTERVAL_BITMAP_VALUE = 4110; + public static final int AWARE_STATUS_INVALID_FA_MAP_MAP_ID = 4111; + public static final int AWARE_STATUS_INVALID_POST_AWARE_DISCOVERY_CONN_TYPE_VALUE = 4112; + public static final int AWARE_STATUS_INVALID_POST_AWARE_DISCOVERY_DEVICE_ROLE_VALUE = 4113; + public static final int AWARE_STATUS_INVALID_POST_AWARE_DISCOVERY_DURATION_VALUE = 4114; + public static final int AWARE_STATUS_INVALID_POST_AWARE_DISCOVERY_BITMAP_VALUE = 4115; + public static final int AWARE_STATUS_MISSING_FUTHER_AVAILABILITY_MAP = 4116; + public static final int AWARE_STATUS_INVALID_BAND_CONFIG_FLAGS = 4117; + public static final int AWARE_STATUS_INVALID_RANDOM_FACTOR_UPDATE_TIME_VALUE = 4118; + public static final int AWARE_STATUS_INVALID_ONGOING_SCAN_PERIOD = 4119; + public static final int AWARE_STATUS_INVALID_DW_INTERVAL_VALUE = 4120; + public static final int AWARE_STATUS_INVALID_DB_INTERVAL_VALUE = 4121; /* publish/subscribe termination reasons */ - public static final int NAN_TERMINATED_REASON_INVALID = 8192; - public static final int NAN_TERMINATED_REASON_TIMEOUT = 8193; - public static final int NAN_TERMINATED_REASON_USER_REQUEST = 8194; - public static final int NAN_TERMINATED_REASON_FAILURE = 8195; - public static final int NAN_TERMINATED_REASON_COUNT_REACHED = 8196; - public static final int NAN_TERMINATED_REASON_DE_SHUTDOWN = 8197; - public static final int NAN_TERMINATED_REASON_DISABLE_IN_PROGRESS = 8198; - public static final int NAN_TERMINATED_REASON_POST_DISC_ATTR_EXPIRED = 8199; - public static final int NAN_TERMINATED_REASON_POST_DISC_LEN_EXCEEDED = 8200; - public static final int NAN_TERMINATED_REASON_FURTHER_AVAIL_MAP_EMPTY = 8201; + public static final int AWARE_TERMINATED_REASON_INVALID = 8192; + public static final int AWARE_TERMINATED_REASON_TIMEOUT = 8193; + public static final int AWARE_TERMINATED_REASON_USER_REQUEST = 8194; + public static final int AWARE_TERMINATED_REASON_FAILURE = 8195; + public static final int AWARE_TERMINATED_REASON_COUNT_REACHED = 8196; + public static final int AWARE_TERMINATED_REASON_DE_SHUTDOWN = 8197; + public static final int AWARE_TERMINATED_REASON_DISABLE_IN_PROGRESS = 8198; + public static final int AWARE_TERMINATED_REASON_POST_DISC_ATTR_EXPIRED = 8199; + public static final int AWARE_TERMINATED_REASON_POST_DISC_LEN_EXCEEDED = 8200; + public static final int AWARE_TERMINATED_REASON_FURTHER_AVAIL_MAP_EMPTY = 8201; /* 9000-9500 NDP Status type */ - public static final int NAN_STATUS_NDP_UNSUPPORTED_CONCURRENCY = 9000; - public static final int NAN_STATUS_NDP_NAN_DATA_IFACE_CREATE_FAILED = 9001; - public static final int NAN_STATUS_NDP_NAN_DATA_IFACE_DELETE_FAILED = 9002; - public static final int NAN_STATUS_NDP_DATA_INITIATOR_REQUEST_FAILED = 9003; - public static final int NAN_STATUS_NDP_DATA_RESPONDER_REQUEST_FAILED = 9004; - public static final int NAN_STATUS_NDP_INVALID_SERVICE_INSTANCE_ID = 9005; - public static final int NAN_STATUS_NDP_INVALID_NDP_INSTANCE_ID = 9006; - public static final int NAN_STATUS_NDP_INVALID_RESPONSE_CODE = 9007; - public static final int NAN_STATUS_NDP_INVALID_APP_INFO_LEN = 9008; + public static final int AWARE_STATUS_NDP_UNSUPPORTED_CONCURRENCY = 9000; + public static final int AWARE_STATUS_NDP_AWARE_DATA_IFACE_CREATE_FAILED = 9001; + public static final int AWARE_STATUS_NDP_AWARE_DATA_IFACE_DELETE_FAILED = 9002; + public static final int AWARE_STATUS_NDP_DATA_INITIATOR_REQUEST_FAILED = 9003; + public static final int AWARE_STATUS_NDP_DATA_RESPONDER_REQUEST_FAILED = 9004; + public static final int AWARE_STATUS_NDP_INVALID_SERVICE_INSTANCE_ID = 9005; + public static final int AWARE_STATUS_NDP_INVALID_NDP_INSTANCE_ID = 9006; + public static final int AWARE_STATUS_NDP_INVALID_RESPONSE_CODE = 9007; + public static final int AWARE_STATUS_NDP_INVALID_APP_INFO_LEN = 9008; /* OTA failures and timeouts during negotiation */ - public static final int NAN_STATUS_NDP_MGMT_FRAME_REQUEST_FAILED = 9009; - public static final int NAN_STATUS_NDP_MGMT_FRAME_RESPONSE_FAILED = 9010; - public static final int NAN_STATUS_NDP_MGMT_FRAME_CONFIRM_FAILED = 9011; - public static final int NAN_STATUS_NDP_END_FAILED = 9012; - public static final int NAN_STATUS_NDP_MGMT_FRAME_END_REQUEST_FAILED = 9013; + public static final int AWARE_STATUS_NDP_MGMT_FRAME_REQUEST_FAILED = 9009; + public static final int AWARE_STATUS_NDP_MGMT_FRAME_RESPONSE_FAILED = 9010; + public static final int AWARE_STATUS_NDP_MGMT_FRAME_CONFIRM_FAILED = 9011; + public static final int AWARE_STATUS_NDP_END_FAILED = 9012; + public static final int AWARE_STATUS_NDP_MGMT_FRAME_END_REQUEST_FAILED = 9013; /* 9500 onwards vendor specific error codes */ - public static final int NAN_STATUS_NDP_VENDOR_SPECIFIC_ERROR = 9500; + public static final int AWARE_STATUS_NDP_VENDOR_SPECIFIC_ERROR = 9500; - private static int translateHalStatusToNanSessionCallbackTerminate(int halStatus) { + private static int translateHalStatusToAwareSessionCallbackTerminate(int halStatus) { switch (halStatus) { - case NAN_TERMINATED_REASON_TIMEOUT: - case NAN_TERMINATED_REASON_USER_REQUEST: - case NAN_TERMINATED_REASON_COUNT_REACHED: - return WifiNanDiscoverySessionCallback.TERMINATE_REASON_DONE; + case AWARE_TERMINATED_REASON_TIMEOUT: + case AWARE_TERMINATED_REASON_USER_REQUEST: + case AWARE_TERMINATED_REASON_COUNT_REACHED: + return WifiAwareDiscoverySessionCallback.TERMINATE_REASON_DONE; - case NAN_TERMINATED_REASON_INVALID: - case NAN_TERMINATED_REASON_FAILURE: - case NAN_TERMINATED_REASON_DE_SHUTDOWN: - case NAN_TERMINATED_REASON_DISABLE_IN_PROGRESS: - case NAN_TERMINATED_REASON_POST_DISC_ATTR_EXPIRED: - case NAN_TERMINATED_REASON_POST_DISC_LEN_EXCEEDED: - case NAN_TERMINATED_REASON_FURTHER_AVAIL_MAP_EMPTY: - return WifiNanDiscoverySessionCallback.TERMINATE_REASON_FAIL; + case AWARE_TERMINATED_REASON_INVALID: + case AWARE_TERMINATED_REASON_FAILURE: + case AWARE_TERMINATED_REASON_DE_SHUTDOWN: + case AWARE_TERMINATED_REASON_DISABLE_IN_PROGRESS: + case AWARE_TERMINATED_REASON_POST_DISC_ATTR_EXPIRED: + case AWARE_TERMINATED_REASON_POST_DISC_LEN_EXCEEDED: + case AWARE_TERMINATED_REASON_FURTHER_AVAIL_MAP_EMPTY: + return WifiAwareDiscoverySessionCallback.TERMINATE_REASON_FAIL; } - return WifiNanDiscoverySessionCallback.TERMINATE_REASON_FAIL; + return WifiAwareDiscoverySessionCallback.TERMINATE_REASON_FAIL; } // callback from native - private static void onNanNotifyResponse(short transactionId, int responseType, int status, + private static void onAwareNotifyResponse(short transactionId, int responseType, int status, int value) { if (VDBG) { Log.v(TAG, - "onNanNotifyResponse: transactionId=" + transactionId + ", responseType=" + "onAwareNotifyResponse: transactionId=" + transactionId + ", responseType=" + responseType + ", status=" + status + ", value=" + value); } - WifiNanStateManager stateMgr = WifiNanStateManager.getInstance(); + WifiAwareStateManager stateMgr = WifiAwareStateManager.getInstance(); switch (responseType) { - case NAN_RESPONSE_ENABLED: + case AWARE_RESPONSE_ENABLED: /* fall through */ - case NAN_RESPONSE_CONFIG: - if (status == NAN_STATUS_SUCCESS) { + case AWARE_RESPONSE_CONFIG: + if (status == AWARE_STATUS_SUCCESS) { stateMgr.onConfigSuccessResponse(transactionId); } else { stateMgr.onConfigFailedResponse(transactionId, status); } break; - case NAN_RESPONSE_PUBLISH_CANCEL: - if (status != NAN_STATUS_SUCCESS) { - Log.e(TAG, "onNanNotifyResponse: NAN_RESPONSE_PUBLISH_CANCEL error - status=" - + status + ", value=" + value); + case AWARE_RESPONSE_PUBLISH_CANCEL: + if (status != AWARE_STATUS_SUCCESS) { + Log.e(TAG, + "onAwareNotifyResponse: AWARE_RESPONSE_PUBLISH_CANCEL error - status=" + + status + ", value=" + value); } break; - case NAN_RESPONSE_TRANSMIT_FOLLOWUP: - if (status == NAN_STATUS_SUCCESS) { + case AWARE_RESPONSE_TRANSMIT_FOLLOWUP: + if (status == AWARE_STATUS_SUCCESS) { stateMgr.onMessageSendQueuedSuccessResponse(transactionId); } else { stateMgr.onMessageSendQueuedFailResponse(transactionId, status); } break; - case NAN_RESPONSE_SUBSCRIBE_CANCEL: - if (status != NAN_STATUS_SUCCESS) { - Log.e(TAG, "onNanNotifyResponse: NAN_RESPONSE_PUBLISH_CANCEL error - status=" - + status + ", value=" + value); + case AWARE_RESPONSE_SUBSCRIBE_CANCEL: + if (status != AWARE_STATUS_SUCCESS) { + Log.e(TAG, + "onAwareNotifyResponse: AWARE_RESPONSE_PUBLISH_CANCEL error - status=" + + status + ", value=" + value); } break; - case NAN_RESPONSE_DP_INTERFACE_CREATE: - if (status != NAN_STATUS_SUCCESS) { + case AWARE_RESPONSE_DP_INTERFACE_CREATE: + if (status != AWARE_STATUS_SUCCESS) { Log.e(TAG, - "onNanNotifyResponse: NAN_RESPONSE_DP_INTERFACE_CREATE error - status=" + "onAwareNotifyResponse: AWARE_RESPONSE_DP_INTERFACE_CREATE error - " + + "status=" + status + ", value=" + value); } stateMgr.onCreateDataPathInterfaceResponse(transactionId, - status == NAN_STATUS_SUCCESS, status); + status == AWARE_STATUS_SUCCESS, status); break; - case NAN_RESPONSE_DP_INTERFACE_DELETE: - if (status != NAN_STATUS_SUCCESS) { + case AWARE_RESPONSE_DP_INTERFACE_DELETE: + if (status != AWARE_STATUS_SUCCESS) { Log.e(TAG, - "onNanNotifyResponse: NAN_RESPONSE_DP_INTERFACE_DELETE error - status=" + "onAwareNotifyResponse: AWARE_RESPONSE_DP_INTERFACE_DELETE error - " + + "status=" + status + ", value=" + value); } stateMgr.onDeleteDataPathInterfaceResponse(transactionId, - status == NAN_STATUS_SUCCESS, status); + status == AWARE_STATUS_SUCCESS, status); break; - case NAN_RESPONSE_DP_RESPONDER_RESPONSE: - if (status != NAN_STATUS_SUCCESS) { + case AWARE_RESPONSE_DP_RESPONDER_RESPONSE: + if (status != AWARE_STATUS_SUCCESS) { Log.e(TAG, - "onNanNotifyResponse: NAN_RESPONSE_DP_RESPONDER_RESPONSE error - " + "onAwareNotifyResponse: AWARE_RESPONSE_DP_RESPONDER_RESPONSE error - " + "status=" + status + ", value=" + value); } stateMgr.onRespondToDataPathSetupRequestResponse(transactionId, - status == NAN_STATUS_SUCCESS, status); + status == AWARE_STATUS_SUCCESS, status); break; - case NAN_RESPONSE_DP_END: - if (status != NAN_STATUS_SUCCESS) { - Log.e(TAG, "onNanNotifyResponse: NAN_RESPONSE_DP_END error - status=" + status - + ", value=" + value); + case AWARE_RESPONSE_DP_END: + if (status != AWARE_STATUS_SUCCESS) { + Log.e(TAG, "onAwareNotifyResponse: AWARE_RESPONSE_DP_END error - status=" + + status + ", value=" + value); } - stateMgr.onEndDataPathResponse(transactionId, status == NAN_STATUS_SUCCESS, + stateMgr.onEndDataPathResponse(transactionId, status == AWARE_STATUS_SUCCESS, status); break; default: - Log.e(TAG, "onNanNotifyResponse: unclassified responseType=" + responseType); + Log.e(TAG, "onAwareNotifyResponse: unclassified responseType=" + responseType); break; } } - private static void onNanNotifyResponsePublishSubscribe(short transactionId, int responseType, + private static void onAwareNotifyResponsePublishSubscribe(short transactionId, int responseType, int status, int value, int pubSubId) { if (VDBG) { Log.v(TAG, - "onNanNotifyResponsePublishSubscribe: transactionId=" + transactionId + "onAwareNotifyResponsePublishSubscribe: transactionId=" + transactionId + ", responseType=" + responseType + ", status=" + status + ", value=" + value + ", pubSubId=" + pubSubId); } switch (responseType) { - case NAN_RESPONSE_PUBLISH: - if (status == NAN_STATUS_SUCCESS) { - WifiNanStateManager.getInstance().onSessionConfigSuccessResponse(transactionId, - true, pubSubId); + case AWARE_RESPONSE_PUBLISH: + if (status == AWARE_STATUS_SUCCESS) { + WifiAwareStateManager.getInstance().onSessionConfigSuccessResponse( + transactionId, true, pubSubId); } else { - WifiNanStateManager.getInstance().onSessionConfigFailResponse(transactionId, + WifiAwareStateManager.getInstance().onSessionConfigFailResponse(transactionId, true, status); } break; - case NAN_RESPONSE_SUBSCRIBE: - if (status == NAN_STATUS_SUCCESS) { - WifiNanStateManager.getInstance().onSessionConfigSuccessResponse(transactionId, - false, pubSubId); + case AWARE_RESPONSE_SUBSCRIBE: + if (status == AWARE_STATUS_SUCCESS) { + WifiAwareStateManager.getInstance().onSessionConfigSuccessResponse( + transactionId, false, pubSubId); } else { - WifiNanStateManager.getInstance().onSessionConfigFailResponse(transactionId, + WifiAwareStateManager.getInstance().onSessionConfigFailResponse(transactionId, false, status); } break; default: - Log.wtf(TAG, "onNanNotifyResponsePublishSubscribe: unclassified responseType=" + Log.wtf(TAG, "onAwareNotifyResponsePublishSubscribe: unclassified responseType=" + responseType); break; } } - private static void onNanNotifyResponseCapabilities(short transactionId, int status, int value, - Capabilities capabilities) { + private static void onAwareNotifyResponseCapabilities(short transactionId, int status, + int value, Capabilities capabilities) { if (VDBG) { - Log.v(TAG, "onNanNotifyResponseCapabilities: transactionId=" + transactionId + Log.v(TAG, "onAwareNotifyResponseCapabilities: transactionId=" + transactionId + ", status=" + status + ", value=" + value + ", capabilities=" + capabilities); } - if (status == NAN_STATUS_SUCCESS) { - WifiNanStateManager.getInstance().onCapabilitiesUpdateResponse(transactionId, + if (status == AWARE_STATUS_SUCCESS) { + WifiAwareStateManager.getInstance().onCapabilitiesUpdateResponse(transactionId, capabilities); } else { - Log.e(TAG, - "onNanNotifyResponseCapabilities: error status=" + status + ", value=" + value); + Log.e(TAG, "onAwareNotifyResponseCapabilities: error status=" + status + + ", value=" + value); } } - private static void onNanNotifyResponseDataPathInitiate(short transactionId, int status, + private static void onAwareNotifyResponseDataPathInitiate(short transactionId, int status, int value, int ndpId) { if (VDBG) { Log.v(TAG, - "onNanNotifyResponseDataPathInitiate: transactionId=" + transactionId + "onAwareNotifyResponseDataPathInitiate: transactionId=" + transactionId + ", status=" + status + ", value=" + value + ", ndpId=" + ndpId); } - if (status == NAN_STATUS_SUCCESS) { - WifiNanStateManager.getInstance().onInitiateDataPathResponseSuccess(transactionId, + if (status == AWARE_STATUS_SUCCESS) { + WifiAwareStateManager.getInstance().onInitiateDataPathResponseSuccess(transactionId, ndpId); } else { - WifiNanStateManager.getInstance().onInitiateDataPathResponseFail(transactionId, status); + WifiAwareStateManager.getInstance().onInitiateDataPathResponseFail(transactionId, + status); } } - public static final int NAN_EVENT_ID_DISC_MAC_ADDR = 0; - public static final int NAN_EVENT_ID_STARTED_CLUSTER = 1; - public static final int NAN_EVENT_ID_JOINED_CLUSTER = 2; + public static final int AWARE_EVENT_ID_DISC_MAC_ADDR = 0; + public static final int AWARE_EVENT_ID_STARTED_CLUSTER = 1; + public static final int AWARE_EVENT_ID_JOINED_CLUSTER = 2; // callback from native private static void onDiscoveryEngineEvent(int eventType, byte[] mac) { @@ -901,14 +906,14 @@ public class WifiNanNative { + String.valueOf(HexEncoding.encode(mac))); } - if (eventType == NAN_EVENT_ID_DISC_MAC_ADDR) { - WifiNanStateManager.getInstance().onInterfaceAddressChangeNotification(mac); - } else if (eventType == NAN_EVENT_ID_STARTED_CLUSTER) { - WifiNanStateManager.getInstance().onClusterChangeNotification( - WifiNanClientState.CLUSTER_CHANGE_EVENT_STARTED, mac); - } else if (eventType == NAN_EVENT_ID_JOINED_CLUSTER) { - WifiNanStateManager.getInstance().onClusterChangeNotification( - WifiNanClientState.CLUSTER_CHANGE_EVENT_JOINED, mac); + if (eventType == AWARE_EVENT_ID_DISC_MAC_ADDR) { + WifiAwareStateManager.getInstance().onInterfaceAddressChangeNotification(mac); + } else if (eventType == AWARE_EVENT_ID_STARTED_CLUSTER) { + WifiAwareStateManager.getInstance().onClusterChangeNotification( + WifiAwareClientState.CLUSTER_CHANGE_EVENT_STARTED, mac); + } else if (eventType == AWARE_EVENT_ID_JOINED_CLUSTER) { + WifiAwareStateManager.getInstance().onClusterChangeNotification( + WifiAwareClientState.CLUSTER_CHANGE_EVENT_JOINED, mac); } else { Log.w(TAG, "onDiscoveryEngineEvent: invalid eventType=" + eventType); } @@ -924,7 +929,7 @@ public class WifiNanNative { + ", matchFilter=" + Arrays.toString(matchFilter)); } - WifiNanStateManager.getInstance().onMatchNotification(pubSubId, requestorInstanceId, mac, + WifiAwareStateManager.getInstance().onMatchNotification(pubSubId, requestorInstanceId, mac, serviceSpecificInfo, matchFilter); } @@ -932,8 +937,8 @@ public class WifiNanNative { private static void onPublishTerminated(int publishId, int status) { if (VDBG) Log.v(TAG, "onPublishTerminated: publishId=" + publishId + ", status=" + status); - WifiNanStateManager.getInstance().onSessionTerminatedNotification(publishId, - translateHalStatusToNanSessionCallbackTerminate(status), true); + WifiAwareStateManager.getInstance().onSessionTerminatedNotification(publishId, + translateHalStatusToAwareSessionCallbackTerminate(status), true); } // callback from native @@ -942,8 +947,8 @@ public class WifiNanNative { Log.v(TAG, "onSubscribeTerminated: subscribeId=" + subscribeId + ", status=" + status); } - WifiNanStateManager.getInstance().onSessionTerminatedNotification(subscribeId, - translateHalStatusToNanSessionCallbackTerminate(status), false); + WifiAwareStateManager.getInstance().onSessionTerminatedNotification(subscribeId, + translateHalStatusToAwareSessionCallbackTerminate(status), false); } // callback from native @@ -954,7 +959,7 @@ public class WifiNanNative { + requestorInstanceId + ", mac=" + String.valueOf(HexEncoding.encode(mac))); } - WifiNanStateManager.getInstance().onMessageReceivedNotification(pubSubId, + WifiAwareStateManager.getInstance().onMessageReceivedNotification(pubSubId, requestorInstanceId, mac, message); } @@ -962,7 +967,7 @@ public class WifiNanNative { private static void onDisabledEvent(int status) { if (VDBG) Log.v(TAG, "onDisabledEvent: status=" + status); - WifiNanStateManager.getInstance().onNanDownNotification(status); + WifiAwareStateManager.getInstance().onAwareDownNotification(status); } // callback from native @@ -972,10 +977,11 @@ public class WifiNanNative { + reason); } - if (reason == NAN_STATUS_SUCCESS) { - WifiNanStateManager.getInstance().onMessageSendSuccessNotification(transactionId); + if (reason == AWARE_STATUS_SUCCESS) { + WifiAwareStateManager.getInstance().onMessageSendSuccessNotification(transactionId); } else { - WifiNanStateManager.getInstance().onMessageSendFailNotification(transactionId, reason); + WifiAwareStateManager.getInstance().onMessageSendFailNotification(transactionId, + reason); } } @@ -985,7 +991,7 @@ public class WifiNanNative { HexEncoding.encode(mac)) + ", ndpId=" + ndpId); } - WifiNanStateManager.getInstance() + WifiAwareStateManager.getInstance() .onDataPathRequestNotification(pubSubId, mac, ndpId, message); } @@ -996,7 +1002,7 @@ public class WifiNanNative { .encode(mac)) + ", accept=" + accept + ", reason=" + reason); } - WifiNanStateManager.getInstance() + WifiAwareStateManager.getInstance() .onDataPathConfirmNotification(ndpId, mac, accept, reason, message); } @@ -1005,6 +1011,6 @@ public class WifiNanNative { Log.v(TAG, "onDataPathEndNotification: ndpId=" + ndpId); } - WifiNanStateManager.getInstance().onDataPathEndNotification(ndpId); + WifiAwareStateManager.getInstance().onDataPathEndNotification(ndpId); } } diff --git a/service/java/com/android/server/wifi/nan/WifiNanRttStateManager.java b/service/java/com/android/server/wifi/aware/WifiAwareRttStateManager.java index 4e1548658..74f34b362 100644 --- a/service/java/com/android/server/wifi/nan/WifiNanRttStateManager.java +++ b/service/java/com/android/server/wifi/aware/WifiAwareRttStateManager.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.server.wifi.nan; +package com.android.server.wifi.aware; import android.content.Context; import android.net.wifi.IRttManager; @@ -39,16 +39,16 @@ import java.util.Arrays; /** - * Manages interactions between the NAN and the RTT service. Duplicates some of the functionality + * Manages interactions between the Aware and the RTT service. Duplicates some of the functionality * of the RttManager. */ -public class WifiNanRttStateManager { - private static final String TAG = "WifiNanRttStateManager"; +public class WifiAwareRttStateManager { + private static final String TAG = "WifiAwareRttStateMgr"; private static final boolean DBG = false; private static final boolean VDBG = false; // STOPSHIP if true - private final SparseArray<WifiNanClientState> mPendingOperations = new SparseArray<>(); + private final SparseArray<WifiAwareClientState> mPendingOperations = new SparseArray<>(); private AsyncChannel mAsyncChannel; /** @@ -81,11 +81,11 @@ public class WifiNanRttStateManager { } mAsyncChannel = new AsyncChannel(); - mAsyncChannel.connect(context, new NanRttHandler(looper), messenger); + mAsyncChannel.connect(context, new AwareRttHandler(looper), messenger); } - private WifiNanClientState getAndRemovePendingOperationClient(int rangingId) { - WifiNanClientState client = mPendingOperations.get(rangingId); + private WifiAwareClientState getAndRemovePendingOperationClient(int rangingId) { + WifiAwareClientState client = mPendingOperations.get(rangingId); mPendingOperations.delete(rangingId); return client; } @@ -93,7 +93,7 @@ public class WifiNanRttStateManager { /** * Start a ranging operation for the client + peer MAC. */ - public void startRanging(int rangingId, WifiNanClientState client, + public void startRanging(int rangingId, WifiAwareClientState client, RttManager.RttParams[] params) { if (VDBG) { Log.v(TAG, "startRanging: rangingId=" + rangingId + ", parms=" @@ -103,7 +103,7 @@ public class WifiNanRttStateManager { if (mAsyncChannel == null) { Log.d(TAG, "startRanging(): AsyncChannel to RTT service not configured - failing"); client.onRangingFailure(rangingId, RttManager.REASON_NOT_AVAILABLE, - "NAN service not able to configure connection to RTT service"); + "Aware service not able to configure connection to RTT service"); return; } @@ -112,8 +112,8 @@ public class WifiNanRttStateManager { mAsyncChannel.sendMessage(RttManager.CMD_OP_START_RANGING, 0, rangingId, pparams); } - private class NanRttHandler extends Handler { - NanRttHandler(Looper looper) { + private class AwareRttHandler extends Handler { + AwareRttHandler(Looper looper) { super(looper); } @@ -141,7 +141,7 @@ public class WifiNanRttStateManager { } // RTT-specific messages - WifiNanClientState client = getAndRemovePendingOperationClient(msg.arg2); + WifiAwareClientState client = getAndRemovePendingOperationClient(msg.arg2); if (client == null) { Log.e(TAG, "handleMessage(): RTT message (" + msg.what + ") -- cannot find registered pending operation client for ID " @@ -197,7 +197,7 @@ public class WifiNanRttStateManager { * Dump the internal state of the class. */ public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { - pw.println("WifiNanRttStateManager:"); + pw.println("WifiAwareRttStateManager:"); pw.println(" mPendingOperations: [" + mPendingOperations + "]"); } } diff --git a/service/java/com/android/server/wifi/nan/WifiNanService.java b/service/java/com/android/server/wifi/aware/WifiAwareService.java index 658906743..afccfb66a 100644 --- a/service/java/com/android/server/wifi/nan/WifiNanService.java +++ b/service/java/com/android/server/wifi/aware/WifiAwareService.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.server.wifi.nan; +package com.android.server.wifi.aware; import android.content.Context; import android.util.Log; @@ -22,22 +22,22 @@ import android.util.Log; import com.android.server.SystemService; /** - * Service implementing Wi-Fi NAN functionality. Delegates actual interface - * implementation to WifiNanServiceImpl. + * Service implementing Wi-Fi Aware functionality. Delegates actual interface + * implementation to WifiAwareServiceImpl. */ -public final class WifiNanService extends SystemService { - private static final String TAG = "WifiNanService"; - final WifiNanServiceImpl mImpl; +public final class WifiAwareService extends SystemService { + private static final String TAG = "WifiAwareService"; + final WifiAwareServiceImpl mImpl; - public WifiNanService(Context context) { + public WifiAwareService(Context context) { super(context); - mImpl = new WifiNanServiceImpl(context); + mImpl = new WifiAwareServiceImpl(context); } @Override public void onStart() { - Log.i(TAG, "Registering " + Context.WIFI_NAN_SERVICE); - publishBinderService(Context.WIFI_NAN_SERVICE, mImpl); + Log.i(TAG, "Registering " + Context.WIFI_AWARE_SERVICE); + publishBinderService(Context.WIFI_AWARE_SERVICE, mImpl); } @Override diff --git a/service/java/com/android/server/wifi/nan/WifiNanServiceImpl.java b/service/java/com/android/server/wifi/aware/WifiAwareServiceImpl.java index f6647b6c0..4c66e0070 100644 --- a/service/java/com/android/server/wifi/nan/WifiNanServiceImpl.java +++ b/service/java/com/android/server/wifi/aware/WifiAwareServiceImpl.java @@ -14,19 +14,19 @@ * limitations under the License. */ -package com.android.server.wifi.nan; +package com.android.server.wifi.aware; import android.content.Context; import android.content.pm.PackageManager; import android.net.wifi.RttManager; -import android.net.wifi.nan.ConfigRequest; -import android.net.wifi.nan.IWifiNanDiscoverySessionCallback; -import android.net.wifi.nan.IWifiNanEventCallback; -import android.net.wifi.nan.IWifiNanManager; -import android.net.wifi.nan.PublishConfig; -import android.net.wifi.nan.SubscribeConfig; -import android.net.wifi.nan.WifiNanCharacteristics; -import android.net.wifi.nan.WifiNanDiscoveryBaseSession; +import android.net.wifi.aware.ConfigRequest; +import android.net.wifi.aware.IWifiAwareDiscoverySessionCallback; +import android.net.wifi.aware.IWifiAwareEventCallback; +import android.net.wifi.aware.IWifiAwareManager; +import android.net.wifi.aware.PublishConfig; +import android.net.wifi.aware.SubscribeConfig; +import android.net.wifi.aware.WifiAwareCharacteristics; +import android.net.wifi.aware.WifiAwareDiscoveryBaseSession; import android.os.Binder; import android.os.HandlerThread; import android.os.IBinder; @@ -40,18 +40,18 @@ import java.io.PrintWriter; import java.util.Arrays; /** - * Implementation of the IWifiNanManager AIDL interface. Performs validity + * Implementation of the IWifiAwareManager AIDL interface. Performs validity * (permission and clientID-UID mapping) checks and delegates execution to the - * WifiNanStateManager singleton handler. Limited state to feedback which has to + * WifiAwareStateManager singleton handler. Limited state to feedback which has to * be provided instantly: client and session IDs. */ -public class WifiNanServiceImpl extends IWifiNanManager.Stub { - private static final String TAG = "WifiNanService"; +public class WifiAwareServiceImpl extends IWifiAwareManager.Stub { + private static final String TAG = "WifiAwareService"; private static final boolean DBG = false; private static final boolean VDBG = false; // STOPSHIP if true private Context mContext; - private WifiNanStateManager mStateManager; + private WifiAwareStateManager mStateManager; private final Object mLock = new Object(); private final SparseArray<IBinder.DeathRecipient> mDeathRecipientsByClientId = @@ -60,9 +60,9 @@ public class WifiNanServiceImpl extends IWifiNanManager.Stub { private int mNextRangingId = 1; private final SparseIntArray mUidByClientId = new SparseIntArray(); - public WifiNanServiceImpl(Context context) { + public WifiAwareServiceImpl(Context context) { mContext = context.getApplicationContext(); - mStateManager = WifiNanStateManager.getInstance(); + mStateManager = WifiAwareStateManager.getInstance(); } /** @@ -78,20 +78,20 @@ public class WifiNanServiceImpl extends IWifiNanManager.Stub { * the components of the service. */ public void start() { - Log.i(TAG, "Starting Wi-Fi NAN service"); + Log.i(TAG, "Starting Wi-Fi Aware service"); // TODO: share worker thread with other Wi-Fi handlers (b/27924886) - HandlerThread wifiNanThread = new HandlerThread("wifiNanService"); - wifiNanThread.start(); + HandlerThread wifiAwareThread = new HandlerThread("wifiAwareService"); + wifiAwareThread.start(); - mStateManager.start(mContext, wifiNanThread.getLooper()); + mStateManager.start(mContext, wifiAwareThread.getLooper()); } /** * Start/initialize portions of the service which require the boot stage to be complete. */ public void startLate() { - Log.i(TAG, "Late initialization of Wi-Fi NAN service"); + Log.i(TAG, "Late initialization of Wi-Fi Aware service"); mStateManager.startLate(); } @@ -130,7 +130,7 @@ public class WifiNanServiceImpl extends IWifiNanManager.Stub { } @Override - public WifiNanCharacteristics getCharacteristics() { + public WifiAwareCharacteristics getCharacteristics() { enforceAccessPermission(); return mStateManager.getCapabilities() == null ? null @@ -138,8 +138,9 @@ public class WifiNanServiceImpl extends IWifiNanManager.Stub { } @Override - public void connect(final IBinder binder, String callingPackage, IWifiNanEventCallback callback, - ConfigRequest configRequest, boolean notifyOnIdentityChanged) { + public void connect(final IBinder binder, String callingPackage, + IWifiAwareEventCallback callback, ConfigRequest configRequest, + boolean notifyOnIdentityChanged) { enforceAccessPermission(); enforceChangePermission(); if (callback == null) { @@ -193,7 +194,7 @@ public class WifiNanServiceImpl extends IWifiNanManager.Stub { } catch (RemoteException e) { Log.e(TAG, "Error on linkToDeath - " + e); try { - callback.onConnectFail(WifiNanNative.NAN_STATUS_ERROR); + callback.onConnectFail(WifiAwareNative.AWARE_STATUS_ERROR); } catch (RemoteException e1) { Log.e(TAG, "Error on onConnectFail()"); } @@ -251,7 +252,7 @@ public class WifiNanServiceImpl extends IWifiNanManager.Stub { @Override public void publish(int clientId, PublishConfig publishConfig, - IWifiNanDiscoverySessionCallback callback) { + IWifiAwareDiscoverySessionCallback callback) { enforceAccessPermission(); enforceChangePermission(); enforceLocationPermission(); @@ -296,7 +297,7 @@ public class WifiNanServiceImpl extends IWifiNanManager.Stub { @Override public void subscribe(int clientId, SubscribeConfig subscribeConfig, - IWifiNanDiscoverySessionCallback callback) { + IWifiAwareDiscoverySessionCallback callback) { enforceAccessPermission(); enforceChangePermission(); enforceLocationPermission(); @@ -350,9 +351,9 @@ public class WifiNanServiceImpl extends IWifiNanManager.Stub { throw new IllegalArgumentException( "Message length longer than supported by device characteristics"); } - if (retryCount < 0 || retryCount > WifiNanDiscoveryBaseSession.getMaxSendRetryCount()) { + if (retryCount < 0 || retryCount > WifiAwareDiscoveryBaseSession.getMaxSendRetryCount()) { throw new IllegalArgumentException("Invalid 'retryCount' must be non-negative " - + "and <= WifiNanDiscoveryBaseSession.MAX_SEND_RETRY_COUNT"); + + "and <= WifiAwareDiscoveryBaseSession.MAX_SEND_RETRY_COUNT"); } int uid = getMockableCallingUid(); @@ -395,11 +396,11 @@ public class WifiNanServiceImpl extends IWifiNanManager.Stub { protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) { if (mContext.checkCallingOrSelfPermission( android.Manifest.permission.DUMP) != PackageManager.PERMISSION_GRANTED) { - pw.println("Permission Denial: can't dump WifiNanService from pid=" + pw.println("Permission Denial: can't dump WifiAwareService from pid=" + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid()); return; } - pw.println("Wi-Fi NAN Service"); + pw.println("Wi-Fi Aware Service"); synchronized (mLock) { pw.println(" mNextClientId: " + mNextClientId); pw.println(" mDeathRecipientsByClientId: " + mDeathRecipientsByClientId); diff --git a/service/java/com/android/server/wifi/nan/WifiNanStateManager.java b/service/java/com/android/server/wifi/aware/WifiAwareStateManager.java index b6bd6a788..a1f5d28d6 100644 --- a/service/java/com/android/server/wifi/nan/WifiNanStateManager.java +++ b/service/java/com/android/server/wifi/aware/WifiAwareStateManager.java @@ -14,18 +14,18 @@ * limitations under the License. */ -package com.android.server.wifi.nan; +package com.android.server.wifi.aware; import android.content.Context; import android.content.Intent; import android.net.wifi.RttManager; -import android.net.wifi.nan.ConfigRequest; -import android.net.wifi.nan.IWifiNanDiscoverySessionCallback; -import android.net.wifi.nan.IWifiNanEventCallback; -import android.net.wifi.nan.PublishConfig; -import android.net.wifi.nan.SubscribeConfig; -import android.net.wifi.nan.WifiNanCharacteristics; -import android.net.wifi.nan.WifiNanManager; +import android.net.wifi.aware.ConfigRequest; +import android.net.wifi.aware.IWifiAwareDiscoverySessionCallback; +import android.net.wifi.aware.IWifiAwareEventCallback; +import android.net.wifi.aware.PublishConfig; +import android.net.wifi.aware.SubscribeConfig; +import android.net.wifi.aware.WifiAwareCharacteristics; +import android.net.wifi.aware.WifiAwareManager; import android.os.Bundle; import android.os.Looper; import android.os.Message; @@ -53,10 +53,10 @@ import java.util.LinkedHashMap; import java.util.Map; /** - * Manages the state of the Wi-Fi NAN system service. + * Manages the state of the Wi-Fi Aware system service. */ -public class WifiNanStateManager { - private static final String TAG = "WifiNanStateManager"; +public class WifiAwareStateManager { + private static final String TAG = "WifiAwareStateManager"; private static final boolean DBG = false; private static final boolean VDBG = false; // STOPSHIP if true @@ -70,7 +70,7 @@ public class WifiNanStateManager { public static final String HAL_DATA_PATH_CONFIRM_TIMEOUT_TAG = TAG + " HAL Data Path Confirm Timeout"; - private static WifiNanStateManager sNanStateManagerSingleton; + private static WifiAwareStateManager sAwareStateManagerSingleton; /* * State machine message types. There are sub-types for the messages (except for TIMEOUTs). @@ -128,7 +128,7 @@ public class WifiNanStateManager { private static final int NOTIFICATION_TYPE_MATCH = 303; private static final int NOTIFICATION_TYPE_SESSION_TERMINATED = 304; private static final int NOTIFICATION_TYPE_MESSAGE_RECEIVED = 305; - private static final int NOTIFICATION_TYPE_NAN_DOWN = 306; + private static final int NOTIFICATION_TYPE_AWARE_DOWN = 306; private static final int NOTIFICATION_TYPE_ON_MESSAGE_SEND_SUCCESS = 307; private static final int NOTIFICATION_TYPE_ON_MESSAGE_SEND_FAIL = 308; private static final int NOTIFICATION_TYPE_ON_DATA_PATH_REQUEST = 309; @@ -136,7 +136,7 @@ public class WifiNanStateManager { private static final int NOTIFICATION_TYPE_ON_DATA_PATH_END = 311; private static final SparseArray<String> sSmToString = MessageUtils.findMessageNames( - new Class[]{WifiNanStateManager.class}, + new Class[]{WifiAwareStateManager.class}, new String[]{"MESSAGE_TYPE", "COMMAND_TYPE", "RESPONSE_TYPE", "NOTIFICATION_TYPE"}); /* @@ -180,34 +180,34 @@ public class WifiNanStateManager { * handler thread: no need to use a lock. */ private Context mContext; - private volatile WifiNanNative.Capabilities mCapabilities; - private volatile WifiNanCharacteristics mCharacteristics = null; - private WifiNanStateMachine mSm; - private WifiNanRttStateManager mRtt; - private WifiNanDataPathStateManager mDataPathMgr; + private volatile WifiAwareNative.Capabilities mCapabilities; + private volatile WifiAwareCharacteristics mCharacteristics = null; + private WifiAwareStateMachine mSm; + private WifiAwareRttStateManager mRtt; + private WifiAwareDataPathStateManager mDataPathMgr; - private final SparseArray<WifiNanClientState> mClients = new SparseArray<>(); - private ConfigRequest mCurrentNanConfiguration = null; + private final SparseArray<WifiAwareClientState> mClients = new SparseArray<>(); + private ConfigRequest mCurrentAwareConfiguration = null; private static final byte[] ALL_ZERO_MAC = new byte[] {0, 0, 0, 0, 0, 0}; private byte[] mCurrentDiscoveryInterfaceMac = ALL_ZERO_MAC; - private WifiNanStateManager() { + private WifiAwareStateManager() { // EMPTY: singleton pattern } /** - * Access the singleton NAN state manager. Use a singleton since need to be + * Access the singleton Aware state manager. Use a singleton since need to be * accessed (for now) from several other child classes. * * @return The state manager singleton. */ - public static WifiNanStateManager getInstance() { - if (sNanStateManagerSingleton == null) { - sNanStateManagerSingleton = new WifiNanStateManager(); + public static WifiAwareStateManager getInstance() { + if (sAwareStateManagerSingleton == null) { + sAwareStateManagerSingleton = new WifiAwareStateManager(); } - return sNanStateManagerSingleton; + return sAwareStateManagerSingleton; } /** @@ -220,12 +220,12 @@ public class WifiNanStateManager { Log.i(TAG, "start()"); mContext = context; - mSm = new WifiNanStateMachine(TAG, looper); + mSm = new WifiAwareStateMachine(TAG, looper); mSm.setDbg(DBG); mSm.start(); - mRtt = new WifiNanRttStateManager(); - mDataPathMgr = new WifiNanDataPathStateManager(this); + mRtt = new WifiAwareRttStateManager(); + mDataPathMgr = new WifiAwareDataPathStateManager(this); mDataPathMgr.start(mContext, mSm.getHandler().getLooper()); } @@ -239,21 +239,21 @@ public class WifiNanStateManager { /** * Get the client state for the specified ID (or null if none exists). */ - /* package */ WifiNanClientState getClient(int clientId) { + /* package */ WifiAwareClientState getClient(int clientId) { return mClients.get(clientId); } /** * Get the capabilities. */ - public WifiNanNative.Capabilities getCapabilities() { + public WifiAwareNative.Capabilities getCapabilities() { return mCapabilities; } /** * Get the public characteristics derived from the capabilities. Use lazy initialization. */ - public WifiNanCharacteristics getCharacteristics() { + public WifiAwareCharacteristics getCharacteristics() { if (mCharacteristics == null && mCapabilities != null) { mCharacteristics = mCapabilities.toPublicCharacteristics(); } @@ -269,7 +269,7 @@ public class WifiNanStateManager { * Place a request for a new client connection on the state machine queue. */ public void connect(int clientId, int uid, int pid, String callingPackage, - IWifiNanEventCallback callback, ConfigRequest configRequest, + IWifiAwareEventCallback callback, ConfigRequest configRequest, boolean notifyOnIdentityChanged) { Message msg = mSm.obtainMessage(MESSAGE_TYPE_COMMAND); msg.arg1 = COMMAND_TYPE_CONNECT; @@ -311,7 +311,7 @@ public class WifiNanStateManager { * machine queue. */ public void publish(int clientId, PublishConfig publishConfig, - IWifiNanDiscoverySessionCallback callback) { + IWifiAwareDiscoverySessionCallback callback) { Message msg = mSm.obtainMessage(MESSAGE_TYPE_COMMAND); msg.arg1 = COMMAND_TYPE_PUBLISH; msg.arg2 = clientId; @@ -338,7 +338,7 @@ public class WifiNanStateManager { * machine queue. */ public void subscribe(int clientId, SubscribeConfig subscribeConfig, - IWifiNanDiscoverySessionCallback callback) { + IWifiAwareDiscoverySessionCallback callback) { Message msg = mSm.obtainMessage(MESSAGE_TYPE_COMMAND); msg.arg1 = COMMAND_TYPE_SUBSCRIBE; msg.arg2 = clientId; @@ -392,7 +392,7 @@ public class WifiNanStateManager { } /** - * Enable usage of NAN. Doesn't actually turn on NAN (form clusters) - that + * Enable usage of Aware. Doesn't actually turn on Aware (form clusters) - that * only happens when a connection is created. */ public void enableUsage() { @@ -402,7 +402,7 @@ public class WifiNanStateManager { } /** - * Disable usage of NAN. Terminates all existing clients with onNanDown(). + * Disable usage of Aware. Terminates all existing clients with onAwareDown(). */ public void disableUsage() { Message msg = mSm.obtainMessage(MESSAGE_TYPE_COMMAND); @@ -411,10 +411,10 @@ public class WifiNanStateManager { } /** - * Checks whether NAN usage is enabled (not necessarily that NAN is up right + * Checks whether Aware usage is enabled (not necessarily that Aware is up right * now) or disabled. * - * @return A boolean indicating whether NAN usage is enabled (true) or + * @return A boolean indicating whether Aware usage is enabled (true) or * disabled (false). */ public boolean isUsageEnabled() { @@ -422,7 +422,7 @@ public class WifiNanStateManager { } /** - * Get the capabilities of the current NAN firmware. + * Get the capabilities of the current Aware firmware. */ public void queryCapabilities() { Message msg = mSm.obtainMessage(MESSAGE_TYPE_COMMAND); @@ -431,7 +431,7 @@ public class WifiNanStateManager { } /** - * Create all NAN data path interfaces which are supported by the firmware capabilities. + * Create all Aware data path interfaces which are supported by the firmware capabilities. */ public void createAllDataPathInterfaces() { Message msg = mSm.obtainMessage(MESSAGE_TYPE_COMMAND); @@ -440,7 +440,7 @@ public class WifiNanStateManager { } /** - * delete all NAN data path interfaces. + * delete all Aware data path interfaces. */ public void deleteAllDataPathInterfaces() { Message msg = mSm.obtainMessage(MESSAGE_TYPE_COMMAND); @@ -510,7 +510,7 @@ public class WifiNanStateManager { } /** - * NAN follow-on messages (L2 messages) are queued by the firmware for transmission + * Aware follow-on messages (L2 messages) are queued by the firmware for transmission * on-the-air. The firmware has limited queue depth. The host queues all messages and doles * them out to the firmware when possible. This command removes the next messages for * transmission from the host queue and attempts to send it through the firmware. The queues @@ -600,10 +600,10 @@ public class WifiNanStateManager { /** * Place a callback request on the state machine queue: update vendor - * capabilities of the NAN stack. + * capabilities of the Aware stack. */ public void onCapabilitiesUpdateResponse(short transactionId, - WifiNanNative.Capabilities capabilities) { + WifiAwareNative.Capabilities capabilities) { Message msg = mSm.obtainMessage(MESSAGE_TYPE_RESPONSE); msg.arg1 = RESPONSE_TYPE_ON_CAPABILITIES_UPDATED; msg.arg2 = transactionId; @@ -763,11 +763,11 @@ public class WifiNanStateManager { } /** - * Place a callback request on the state machine queue: NAN is going down. + * Place a callback request on the state machine queue: Aware is going down. */ - public void onNanDownNotification(int reason) { + public void onAwareDownNotification(int reason) { Message msg = mSm.obtainMessage(MESSAGE_TYPE_NOTIFICATION); - msg.arg1 = NOTIFICATION_TYPE_NAN_DOWN; + msg.arg1 = NOTIFICATION_TYPE_AWARE_DOWN; msg.arg2 = reason; mSm.sendMessage(msg); } @@ -838,7 +838,7 @@ public class WifiNanStateManager { * State machine. */ @VisibleForTesting - class WifiNanStateMachine extends StateMachine { + class WifiAwareStateMachine extends StateMachine { private static final int TRANSACTION_ID_IGNORE = 0; private DefaultState mDefaultState = new DefaultState(); @@ -851,7 +851,7 @@ public class WifiNanStateManager { private Message mCurrentCommand; private short mCurrentTransactionId = TRANSACTION_ID_IGNORE; - private static final long NAN_SEND_MESSAGE_TIMEOUT = 10_000; + private static final long AWARE_SEND_MESSAGE_TIMEOUT = 10_000; private int mSendArrivalSequenceCounter = 0; private boolean mSendQueueBlocked = false; private final SparseArray<Message> mHostQueuedSendMessages = new SparseArray<>(); @@ -859,10 +859,10 @@ public class WifiNanStateManager { private WakeupMessage mSendMessageTimeoutMessage = new WakeupMessage(mContext, getHandler(), HAL_SEND_MESSAGE_TIMEOUT_TAG, MESSAGE_TYPE_SEND_MESSAGE_TIMEOUT); - private static final long NAN_WAIT_FOR_DP_CONFIRM_TIMEOUT = 5_000; + private static final long AWARE_WAIT_FOR_DP_CONFIRM_TIMEOUT = 5_000; private final Map<String, WakeupMessage> mDataPathConfirmTimeoutMessages = new ArrayMap<>(); - WifiNanStateMachine(String name, Looper looper) { + WifiAwareStateMachine(String name, Looper looper) { super(name, looper); addState(mDefaultState); @@ -872,7 +872,7 @@ public class WifiNanStateManager { setInitialState(mWaitState); } - public void onNanDownCleanupSendQueueState() { + public void onAwareDownCleanupSendQueueState() { mSendQueueBlocked = false; mHostQueuedSendMessages.clear(); mFwQueuedSendMessages.clear(); @@ -946,14 +946,14 @@ public class WifiNanStateManager { } private class WaitForResponseState extends State { - private static final long NAN_COMMAND_TIMEOUT = 5_000; + private static final long AWARE_COMMAND_TIMEOUT = 5_000; private WakeupMessage mTimeoutMessage; @Override public void enter() { mTimeoutMessage = new WakeupMessage(mContext, getHandler(), HAL_COMMAND_TIMEOUT_TAG, MESSAGE_TYPE_RESPONSE_TIMEOUT, mCurrentCommand.arg1, mCurrentTransactionId); - mTimeoutMessage.schedule(SystemClock.elapsedRealtime() + NAN_COMMAND_TIMEOUT); + mTimeoutMessage.schedule(SystemClock.elapsedRealtime() + AWARE_COMMAND_TIMEOUT); } @Override @@ -1055,16 +1055,16 @@ public class WifiNanStateManager { onMessageReceivedLocal(pubSubId, requestorInstanceId, peerMac, message); break; } - case NOTIFICATION_TYPE_NAN_DOWN: { + case NOTIFICATION_TYPE_AWARE_DOWN: { int reason = msg.arg2; /* * TODO: b/28615938. Use reason code to determine whether or not need clean-up - * local state (only needed if NAN_DOWN is due to internal firmware reason, e.g. - * concurrency, rather than due to a requested shutdown). + * local state (only needed if AWARE_DOWN is due to internal firmware reason, + * e.g. concurrency, rather than due to a requested shutdown). */ - onNanDownLocal(); + onAwareDownLocal(); break; } @@ -1109,8 +1109,8 @@ public class WifiNanStateManager { int retryCount = sentMessage.getData() .getInt(MESSAGE_BUNDLE_KEY_RETRY_COUNT); - if (retryCount > 0 && (reason == WifiNanNative.NAN_STATUS_NO_OTA_ACK - || reason == WifiNanNative.NAN_STATUS_TX_FAIL)) { + if (retryCount > 0 && (reason == WifiAwareNative.AWARE_STATUS_NO_OTA_ACK + || reason == WifiAwareNative.AWARE_STATUS_TX_FAIL)) { if (DBG) { Log.d(TAG, "NOTIFICATION_TYPE_ON_MESSAGE_SEND_FAIL: transactionId=" @@ -1143,7 +1143,7 @@ public class WifiNanStateManager { 0, 0, networkSpecifier); mDataPathConfirmTimeoutMessages.put(networkSpecifier, timeout); timeout.schedule( - SystemClock.elapsedRealtime() + NAN_WAIT_FOR_DP_CONFIRM_TIMEOUT); + SystemClock.elapsedRealtime() + AWARE_WAIT_FOR_DP_CONFIRM_TIMEOUT); } break; @@ -1201,7 +1201,7 @@ public class WifiNanStateManager { switch (msg.arg1) { case COMMAND_TYPE_CONNECT: { int clientId = msg.arg2; - IWifiNanEventCallback callback = (IWifiNanEventCallback) msg.obj; + IWifiAwareEventCallback callback = (IWifiAwareEventCallback) msg.obj; ConfigRequest configRequest = (ConfigRequest) msg.getData() .getParcelable(MESSAGE_BUNDLE_KEY_CONFIG); int uid = msg.getData().getInt(MESSAGE_BUNDLE_KEY_UID); @@ -1231,8 +1231,8 @@ public class WifiNanStateManager { } case COMMAND_TYPE_PUBLISH: { int clientId = msg.arg2; - IWifiNanDiscoverySessionCallback callback = - (IWifiNanDiscoverySessionCallback) msg.obj; + IWifiAwareDiscoverySessionCallback callback = + (IWifiAwareDiscoverySessionCallback) msg.obj; PublishConfig publishConfig = (PublishConfig) msg.getData() .getParcelable(MESSAGE_BUNDLE_KEY_CONFIG); @@ -1251,8 +1251,8 @@ public class WifiNanStateManager { } case COMMAND_TYPE_SUBSCRIBE: { int clientId = msg.arg2; - IWifiNanDiscoverySessionCallback callback = - (IWifiNanDiscoverySessionCallback) msg.obj; + IWifiAwareDiscoverySessionCallback callback = + (IWifiAwareDiscoverySessionCallback) msg.obj; SubscribeConfig subscribeConfig = (SubscribeConfig) msg.getData() .getParcelable(MESSAGE_BUNDLE_KEY_CONFIG); @@ -1341,7 +1341,7 @@ public class WifiNanStateManager { } case COMMAND_TYPE_GET_CAPABILITIES: if (mCapabilities == null) { - waitForResponse = WifiNanNative.getInstance().getCapabilities( + waitForResponse = WifiAwareNative.getInstance().getCapabilities( mCurrentTransactionId); } else { if (VDBG) { @@ -1360,11 +1360,11 @@ public class WifiNanStateManager { waitForResponse = false; break; case COMMAND_TYPE_CREATE_DATA_PATH_INTERFACE: - waitForResponse = WifiNanNative.getInstance().createNanNetworkInterface( + waitForResponse = WifiAwareNative.getInstance().createAwareNetworkInterface( mCurrentTransactionId, (String) msg.obj); break; case COMMAND_TYPE_DELETE_DATA_PATH_INTERFACE: - waitForResponse = WifiNanNative.getInstance().deleteNanNetworkInterface( + waitForResponse = WifiAwareNative.getInstance().deleteAwareNetworkInterface( mCurrentTransactionId, (String) msg.obj); break; case COMMAND_TYPE_INITIATE_DATA_PATH_SETUP: { @@ -1388,7 +1388,7 @@ public class WifiNanStateManager { 0, 0, networkSpecifier); mDataPathConfirmTimeoutMessages.put(networkSpecifier, timeout); timeout.schedule( - SystemClock.elapsedRealtime() + NAN_WAIT_FOR_DP_CONFIRM_TIMEOUT); + SystemClock.elapsedRealtime() + AWARE_WAIT_FOR_DP_CONFIRM_TIMEOUT); } break; } @@ -1499,7 +1499,7 @@ public class WifiNanStateManager { break; } case RESPONSE_TYPE_ON_CAPABILITIES_UPDATED: { - onCapabilitiesUpdatedResponseLocal((WifiNanNative.Capabilities) msg.obj); + onCapabilitiesUpdatedResponseLocal((WifiAwareNative.Capabilities) msg.obj); break; } case RESPONSE_TYPE_ON_CREATE_INTERFACE: @@ -1555,7 +1555,7 @@ public class WifiNanStateManager { */ switch (msg.arg1) { case COMMAND_TYPE_CONNECT: { - onConfigFailedLocal(mCurrentCommand, WifiNanNative.NAN_STATUS_ERROR); + onConfigFailedLocal(mCurrentCommand, WifiAwareNative.AWARE_STATUS_ERROR); break; } case COMMAND_TYPE_DISCONNECT: { @@ -1563,7 +1563,7 @@ public class WifiNanStateManager { * Will only get here on DISCONNECT if was downgrading. The * callback will do a NOP - but should still call it. */ - onConfigFailedLocal(mCurrentCommand, WifiNanNative.NAN_STATUS_ERROR); + onConfigFailedLocal(mCurrentCommand, WifiAwareNative.AWARE_STATUS_ERROR); break; } case COMMAND_TYPE_TERMINATE_SESSION: { @@ -1571,21 +1571,23 @@ public class WifiNanStateManager { break; } case COMMAND_TYPE_PUBLISH: { - onSessionConfigFailLocal(mCurrentCommand, true, WifiNanNative.NAN_STATUS_ERROR); + onSessionConfigFailLocal(mCurrentCommand, true, + WifiAwareNative.AWARE_STATUS_ERROR); break; } case COMMAND_TYPE_UPDATE_PUBLISH: { - onSessionConfigFailLocal(mCurrentCommand, true, WifiNanNative.NAN_STATUS_ERROR); + onSessionConfigFailLocal(mCurrentCommand, true, + WifiAwareNative.AWARE_STATUS_ERROR); break; } case COMMAND_TYPE_SUBSCRIBE: { onSessionConfigFailLocal(mCurrentCommand, false, - WifiNanNative.NAN_STATUS_ERROR); + WifiAwareNative.AWARE_STATUS_ERROR); break; } case COMMAND_TYPE_UPDATE_SUBSCRIBE: { onSessionConfigFailLocal(mCurrentCommand, false, - WifiNanNative.NAN_STATUS_ERROR); + WifiAwareNative.AWARE_STATUS_ERROR); break; } case COMMAND_TYPE_ENQUEUE_SEND_MESSAGE: { @@ -1595,7 +1597,7 @@ public class WifiNanStateManager { case COMMAND_TYPE_TRANSMIT_NEXT_MESSAGE: { Message sentMessage = mCurrentCommand.getData().getParcelable( MESSAGE_BUNDLE_KEY_SENT_MESSAGE); - onMessageSendFailLocal(sentMessage, WifiNanNative.NAN_STATUS_ERROR); + onMessageSendFailLocal(sentMessage, WifiAwareNative.AWARE_STATUS_ERROR); mSendQueueBlocked = false; transmitNextMessage(); break; @@ -1669,7 +1671,7 @@ public class WifiNanStateManager { Message msg = it.next(); mSendMessageTimeoutMessage.schedule( msg.getData().getLong(MESSAGE_BUNDLE_KEY_SEND_MESSAGE_ENQUEUE_TIME) - + NAN_SEND_MESSAGE_TIMEOUT); + + AWARE_SEND_MESSAGE_TIMEOUT); } else { mSendMessageTimeoutMessage.cancel(); } @@ -1697,14 +1699,14 @@ public class WifiNanStateManager { Message message = entry.getValue(); long messageEnqueueTime = message.getData().getLong( MESSAGE_BUNDLE_KEY_SEND_MESSAGE_ENQUEUE_TIME); - if (first || messageEnqueueTime + NAN_SEND_MESSAGE_TIMEOUT <= currentTime) { + if (first || messageEnqueueTime + AWARE_SEND_MESSAGE_TIMEOUT <= currentTime) { if (VDBG) { Log.v(TAG, "processSendMessageTimeout: expiring - transactionId=" + transactionId + ", message=" + message + ", due to messageEnqueueTime=" + messageEnqueueTime + ", currentTime=" + currentTime); } - onMessageSendFailLocal(message, WifiNanNative.NAN_STATUS_ERROR); + onMessageSendFailLocal(message, WifiAwareNative.AWARE_STATUS_ERROR); it.remove(); first = false; } else { @@ -1718,7 +1720,7 @@ public class WifiNanStateManager { @Override protected String getLogRecString(Message msg) { - StringBuilder sb = new StringBuilder(WifiNanStateManager.messageToString(msg)); + StringBuilder sb = new StringBuilder(WifiAwareStateManager.messageToString(msg)); if (msg.what == MESSAGE_TYPE_COMMAND && mCurrentTransactionId != TRANSACTION_ID_IGNORE) { @@ -1730,7 +1732,7 @@ public class WifiNanStateManager { @Override public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { - pw.println("WifiNanStateMachine:"); + pw.println("WifiAwareStateMachine:"); pw.println(" mNextTransactionId: " + mNextTransactionId); pw.println(" mNextSessionId: " + mNextSessionId); pw.println(" mCurrentCommand: " + mCurrentCommand); @@ -1743,11 +1745,11 @@ public class WifiNanStateManager { } } - private void sendNanStateChangedBroadcast(boolean enabled) { + private void sendAwareStateChangedBroadcast(boolean enabled) { if (VDBG) { - Log.v(TAG, "sendNanStateChangedBroadcast: enabled=" + enabled); + Log.v(TAG, "sendAwareStateChangedBroadcast: enabled=" + enabled); } - final Intent intent = new Intent(WifiNanManager.ACTION_WIFI_NAN_STATE_CHANGED); + final Intent intent = new Intent(WifiAwareManager.ACTION_WIFI_AWARE_STATE_CHANGED); intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY); mContext.sendBroadcastAsUser(intent, UserHandle.ALL); } @@ -1757,7 +1759,7 @@ public class WifiNanStateManager { */ private boolean connectLocal(short transactionId, int clientId, int uid, int pid, - String callingPackage, IWifiNanEventCallback callback, ConfigRequest configRequest, + String callingPackage, IWifiAwareEventCallback callback, ConfigRequest configRequest, boolean notifyIdentityChange) { if (VDBG) { Log.v(TAG, "connectLocal(): transactionId=" + transactionId + ", clientId=" + clientId @@ -1775,10 +1777,10 @@ public class WifiNanStateManager { Log.e(TAG, "connectLocal: entry already exists for clientId=" + clientId); } - if (mCurrentNanConfiguration != null - && !mCurrentNanConfiguration.equals(configRequest)) { + if (mCurrentAwareConfiguration != null + && !mCurrentAwareConfiguration.equals(configRequest)) { try { - callback.onConnectFail(WifiNanNative.NAN_STATUS_ERROR); + callback.onConnectFail(WifiAwareNative.AWARE_STATUS_ERROR); } catch (RemoteException e) { Log.w(TAG, "connectLocal onConnectFail(): RemoteException (FYI): " + e); } @@ -1786,21 +1788,21 @@ public class WifiNanStateManager { } ConfigRequest merged = mergeConfigRequests(configRequest); - if (mCurrentNanConfiguration != null && mCurrentNanConfiguration.equals(merged)) { + if (mCurrentAwareConfiguration != null && mCurrentAwareConfiguration.equals(merged)) { try { callback.onConnectSuccess(clientId); } catch (RemoteException e) { Log.w(TAG, "connectLocal onConnectSuccess(): RemoteException (FYI): " + e); } - WifiNanClientState client = new WifiNanClientState(mContext, clientId, uid, pid, + WifiAwareClientState client = new WifiAwareClientState(mContext, clientId, uid, pid, callingPackage, callback, configRequest, notifyIdentityChange); client.onInterfaceAddressChange(mCurrentDiscoveryInterfaceMac); mClients.append(clientId, client); return false; } - return WifiNanNative.getInstance().enableAndConfigure(transactionId, merged, - mCurrentNanConfiguration == null); + return WifiAwareNative.getInstance().enableAndConfigure(transactionId, merged, + mCurrentAwareConfiguration == null); } private boolean disconnectLocal(short transactionId, int clientId) { @@ -1809,7 +1811,7 @@ public class WifiNanStateManager { "disconnectLocal(): transactionId=" + transactionId + ", clientId=" + clientId); } - WifiNanClientState client = mClients.get(clientId); + WifiAwareClientState client = mClients.get(clientId); if (client == null) { Log.e(TAG, "disconnectLocal: no entry for clientId=" + clientId); return false; @@ -1818,17 +1820,17 @@ public class WifiNanStateManager { client.destroy(); if (mClients.size() == 0) { - mCurrentNanConfiguration = null; - WifiNanNative.getInstance().disable((short) 0); + mCurrentAwareConfiguration = null; + WifiAwareNative.getInstance().disable((short) 0); return false; } ConfigRequest merged = mergeConfigRequests(null); - if (merged.equals(mCurrentNanConfiguration)) { + if (merged.equals(mCurrentAwareConfiguration)) { return false; } - return WifiNanNative.getInstance().enableAndConfigure(transactionId, merged, false); + return WifiAwareNative.getInstance().enableAndConfigure(transactionId, merged, false); } private void terminateSessionLocal(int clientId, int sessionId) { @@ -1837,7 +1839,7 @@ public class WifiNanStateManager { "terminateSessionLocal(): clientId=" + clientId + ", sessionId=" + sessionId); } - WifiNanClientState client = mClients.get(clientId); + WifiAwareClientState client = mClients.get(clientId); if (client == null) { Log.e(TAG, "terminateSession: no client exists for clientId=" + clientId); return; @@ -1847,19 +1849,19 @@ public class WifiNanStateManager { } private boolean publishLocal(short transactionId, int clientId, PublishConfig publishConfig, - IWifiNanDiscoverySessionCallback callback) { + IWifiAwareDiscoverySessionCallback callback) { if (VDBG) { Log.v(TAG, "publishLocal(): transactionId=" + transactionId + ", clientId=" + clientId + ", publishConfig=" + publishConfig + ", callback=" + callback); } - WifiNanClientState client = mClients.get(clientId); + WifiAwareClientState client = mClients.get(clientId); if (client == null) { Log.e(TAG, "publishLocal: no client exists for clientId=" + clientId); return false; } - return WifiNanNative.getInstance().publish(transactionId, 0, publishConfig); + return WifiAwareNative.getInstance().publish(transactionId, 0, publishConfig); } private boolean updatePublishLocal(short transactionId, int clientId, int sessionId, @@ -1869,13 +1871,13 @@ public class WifiNanStateManager { + clientId + ", sessionId=" + sessionId + ", publishConfig=" + publishConfig); } - WifiNanClientState client = mClients.get(clientId); + WifiAwareClientState client = mClients.get(clientId); if (client == null) { Log.e(TAG, "updatePublishLocal: no client exists for clientId=" + clientId); return false; } - WifiNanDiscoverySessionState session = client.getSession(sessionId); + WifiAwareDiscoverySessionState session = client.getSession(sessionId); if (session == null) { Log.e(TAG, "updatePublishLocal: no session exists for clientId=" + clientId + ", sessionId=" + sessionId); @@ -1886,19 +1888,19 @@ public class WifiNanStateManager { } private boolean subscribeLocal(short transactionId, int clientId, - SubscribeConfig subscribeConfig, IWifiNanDiscoverySessionCallback callback) { + SubscribeConfig subscribeConfig, IWifiAwareDiscoverySessionCallback callback) { if (VDBG) { Log.v(TAG, "subscribeLocal(): transactionId=" + transactionId + ", clientId=" + clientId + ", subscribeConfig=" + subscribeConfig + ", callback=" + callback); } - WifiNanClientState client = mClients.get(clientId); + WifiAwareClientState client = mClients.get(clientId); if (client == null) { Log.e(TAG, "subscribeLocal: no client exists for clientId=" + clientId); return false; } - return WifiNanNative.getInstance().subscribe(transactionId, 0, subscribeConfig); + return WifiAwareNative.getInstance().subscribe(transactionId, 0, subscribeConfig); } private boolean updateSubscribeLocal(short transactionId, int clientId, int sessionId, @@ -1910,13 +1912,13 @@ public class WifiNanStateManager { + subscribeConfig); } - WifiNanClientState client = mClients.get(clientId); + WifiAwareClientState client = mClients.get(clientId); if (client == null) { Log.e(TAG, "updateSubscribeLocal: no client exists for clientId=" + clientId); return false; } - WifiNanDiscoverySessionState session = client.getSession(sessionId); + WifiAwareDiscoverySessionState session = client.getSession(sessionId); if (session == null) { Log.e(TAG, "updateSubscribeLocal: no session exists for clientId=" + clientId + ", sessionId=" + sessionId); @@ -1935,13 +1937,13 @@ public class WifiNanStateManager { + ", messageId=" + messageId); } - WifiNanClientState client = mClients.get(clientId); + WifiAwareClientState client = mClients.get(clientId); if (client == null) { Log.e(TAG, "sendFollowonMessageLocal: no client exists for clientId=" + clientId); return false; } - WifiNanDiscoverySessionState session = client.getSession(sessionId); + WifiAwareDiscoverySessionState session = client.getSession(sessionId); if (session == null) { Log.e(TAG, "sendFollowonMessageLocal: no session exists for clientId=" + clientId + ", sessionId=" + sessionId); @@ -1958,12 +1960,12 @@ public class WifiNanStateManager { return; } - WifiNanNative.getInstance().deInitNan(); // force a re-init of NAN HAL + WifiAwareNative.getInstance().deInitAware(); // force a re-init of Aware HAL mUsageEnabled = true; queryCapabilities(); createAllDataPathInterfaces(); - sendNanStateChangedBroadcast(true); + sendAwareStateChangedBroadcast(true); } private void disableUsageLocal() { @@ -1973,14 +1975,14 @@ public class WifiNanStateManager { return; } - onNanDownLocal(); + onAwareDownLocal(); deleteAllDataPathInterfaces(); mUsageEnabled = false; - WifiNanNative.getInstance().disable((short) 0); - WifiNanNative.getInstance().deInitNan(); + WifiAwareNative.getInstance().disable((short) 0); + WifiAwareNative.getInstance().deInitAware(); - sendNanStateChangedBroadcast(false); + sendAwareStateChangedBroadcast(false); } private void startRangingLocal(int clientId, int sessionId, RttManager.RttParams[] params, @@ -1990,13 +1992,13 @@ public class WifiNanStateManager { + ", parms=" + Arrays.toString(params) + ", rangingId=" + rangingId); } - WifiNanClientState client = mClients.get(clientId); + WifiAwareClientState client = mClients.get(clientId); if (client == null) { Log.e(TAG, "startRangingLocal: no client exists for clientId=" + clientId); return; } - WifiNanDiscoverySessionState session = client.getSession(sessionId); + WifiAwareDiscoverySessionState session = client.getSession(sessionId); if (session == null) { Log.e(TAG, "startRangingLocal: no session exists for clientId=" + clientId + ", sessionId=" + sessionId); @@ -2033,7 +2035,7 @@ public class WifiNanStateManager { + ", interfaceName=" + interfaceName + ", token=" + token); } - return WifiNanNative.getInstance().initiateDataPath(transactionId, peerId, + return WifiAwareNative.getInstance().initiateDataPath(transactionId, peerId, channelRequestType, channel, peer, interfaceName, token); } @@ -2048,7 +2050,7 @@ public class WifiNanStateManager { byte[] tokenBytes = token.getBytes(); - return WifiNanNative.getInstance().respondToDataPathRequest(transactionId, accept, ndpId, + return WifiAwareNative.getInstance().respondToDataPathRequest(transactionId, accept, ndpId, interfaceName, tokenBytes); } @@ -2058,7 +2060,7 @@ public class WifiNanStateManager { "endDataPathLocal: transactionId=" + transactionId + ", ndpId=" + ndpId); } - return WifiNanNative.getInstance().endDataPath(transactionId, ndpId); + return WifiAwareNative.getInstance().endDataPath(transactionId, ndpId); } /* @@ -2074,7 +2076,7 @@ public class WifiNanStateManager { Bundle data = completedCommand.getData(); int clientId = completedCommand.arg2; - IWifiNanEventCallback callback = (IWifiNanEventCallback) completedCommand.obj; + IWifiAwareEventCallback callback = (IWifiAwareEventCallback) completedCommand.obj; ConfigRequest configRequest = (ConfigRequest) data .getParcelable(MESSAGE_BUNDLE_KEY_CONFIG); int uid = data.getInt(MESSAGE_BUNDLE_KEY_UID); @@ -2083,7 +2085,7 @@ public class WifiNanStateManager { MESSAGE_BUNDLE_KEY_NOTIFY_IDENTITY_CHANGE); String callingPackage = data.getString(MESSAGE_BUNDLE_KEY_CALLING_PACKAGE); - WifiNanClientState client = new WifiNanClientState(mContext, clientId, uid, pid, + WifiAwareClientState client = new WifiAwareClientState(mContext, clientId, uid, pid, callingPackage, callback, configRequest, notifyIdentityChange); mClients.put(clientId, client); try { @@ -2102,7 +2104,7 @@ public class WifiNanStateManager { return; } - mCurrentNanConfiguration = mergeConfigRequests(null); + mCurrentAwareConfiguration = mergeConfigRequests(null); } private void onConfigFailedLocal(Message failedCommand, int reason) { @@ -2112,7 +2114,7 @@ public class WifiNanStateManager { } if (failedCommand.arg1 == COMMAND_TYPE_CONNECT) { - IWifiNanEventCallback callback = (IWifiNanEventCallback) failedCommand.obj; + IWifiAwareEventCallback callback = (IWifiAwareEventCallback) failedCommand.obj; try { callback.onConnectFail(reason); @@ -2142,10 +2144,10 @@ public class WifiNanStateManager { if (completedCommand.arg1 == COMMAND_TYPE_PUBLISH || completedCommand.arg1 == COMMAND_TYPE_SUBSCRIBE) { int clientId = completedCommand.arg2; - IWifiNanDiscoverySessionCallback callback = - (IWifiNanDiscoverySessionCallback) completedCommand.obj; + IWifiAwareDiscoverySessionCallback callback = + (IWifiAwareDiscoverySessionCallback) completedCommand.obj; - WifiNanClientState client = mClients.get(clientId); + WifiAwareClientState client = mClients.get(clientId); if (client == null) { Log.e(TAG, "onSessionConfigSuccessLocal: no client exists for clientId=" + clientId); @@ -2160,7 +2162,7 @@ public class WifiNanStateManager { return; } - WifiNanDiscoverySessionState session = new WifiNanDiscoverySessionState(sessionId, + WifiAwareDiscoverySessionState session = new WifiAwareDiscoverySessionState(sessionId, pubSubId, callback, isPublish); client.addSession(session); } else if (completedCommand.arg1 == COMMAND_TYPE_UPDATE_PUBLISH @@ -2168,14 +2170,14 @@ public class WifiNanStateManager { int clientId = completedCommand.arg2; int sessionId = completedCommand.getData().getInt(MESSAGE_BUNDLE_KEY_SESSION_ID); - WifiNanClientState client = mClients.get(clientId); + WifiAwareClientState client = mClients.get(clientId); if (client == null) { Log.e(TAG, "onSessionConfigSuccessLocal: no client exists for clientId=" + clientId); return; } - WifiNanDiscoverySessionState session = client.getSession(sessionId); + WifiAwareDiscoverySessionState session = client.getSession(sessionId); if (session == null) { Log.e(TAG, "onSessionConfigSuccessLocal: no session exists for clientId=" + clientId + ", sessionId=" + sessionId); @@ -2202,8 +2204,8 @@ public class WifiNanStateManager { if (failedCommand.arg1 == COMMAND_TYPE_PUBLISH || failedCommand.arg1 == COMMAND_TYPE_SUBSCRIBE) { - IWifiNanDiscoverySessionCallback callback = - (IWifiNanDiscoverySessionCallback) failedCommand.obj; + IWifiAwareDiscoverySessionCallback callback = + (IWifiAwareDiscoverySessionCallback) failedCommand.obj; try { callback.onSessionConfigFail(reason); } catch (RemoteException e) { @@ -2215,13 +2217,13 @@ public class WifiNanStateManager { int clientId = failedCommand.arg2; int sessionId = failedCommand.getData().getInt(MESSAGE_BUNDLE_KEY_SESSION_ID); - WifiNanClientState client = mClients.get(clientId); + WifiAwareClientState client = mClients.get(clientId); if (client == null) { Log.e(TAG, "onSessionConfigFailLocal: no client exists for clientId=" + clientId); return; } - WifiNanDiscoverySessionState session = client.getSession(sessionId); + WifiAwareDiscoverySessionState session = client.getSession(sessionId); if (session == null) { Log.e(TAG, "onSessionConfigFailLocal: no session exists for clientId=" + clientId + ", sessionId=" + sessionId); @@ -2247,13 +2249,13 @@ public class WifiNanStateManager { int sessionId = completedCommand.getData().getInt(MESSAGE_BUNDLE_KEY_SESSION_ID); int messageId = completedCommand.getData().getInt(MESSAGE_BUNDLE_KEY_MESSAGE_ID); - WifiNanClientState client = mClients.get(clientId); + WifiAwareClientState client = mClients.get(clientId); if (client == null) { Log.e(TAG, "onMessageSendSuccessLocal: no client exists for clientId=" + clientId); return; } - WifiNanDiscoverySessionState session = client.getSession(sessionId); + WifiAwareDiscoverySessionState session = client.getSession(sessionId); if (session == null) { Log.e(TAG, "onMessageSendSuccessLocal: no session exists for clientId=" + clientId + ", sessionId=" + sessionId); @@ -2276,13 +2278,13 @@ public class WifiNanStateManager { int sessionId = failedCommand.getData().getInt(MESSAGE_BUNDLE_KEY_SESSION_ID); int messageId = failedCommand.getData().getInt(MESSAGE_BUNDLE_KEY_MESSAGE_ID); - WifiNanClientState client = mClients.get(clientId); + WifiAwareClientState client = mClients.get(clientId); if (client == null) { Log.e(TAG, "onMessageSendFailLocal: no client exists for clientId=" + clientId); return; } - WifiNanDiscoverySessionState session = client.getSession(sessionId); + WifiAwareDiscoverySessionState session = client.getSession(sessionId); if (session == null) { Log.e(TAG, "onMessageSendFailLocal: no session exists for clientId=" + clientId + ", sessionId=" + sessionId); @@ -2296,7 +2298,7 @@ public class WifiNanStateManager { } } - private void onCapabilitiesUpdatedResponseLocal(WifiNanNative.Capabilities capabilities) { + private void onCapabilitiesUpdatedResponseLocal(WifiAwareNative.Capabilities capabilities) { if (VDBG) { Log.v(TAG, "onCapabilitiesUpdatedResponseLocal: capabilites=" + capabilities); } @@ -2396,7 +2398,7 @@ public class WifiNanStateManager { mCurrentDiscoveryInterfaceMac = mac; for (int i = 0; i < mClients.size(); ++i) { - WifiNanClientState client = mClients.valueAt(i); + WifiAwareClientState client = mClients.valueAt(i); client.onInterfaceAddressChange(mac); } } @@ -2408,7 +2410,7 @@ public class WifiNanStateManager { } for (int i = 0; i < mClients.size(); ++i) { - WifiNanClientState client = mClients.valueAt(i); + WifiAwareClientState client = mClients.valueAt(i); client.onClusterChange(flag, clusterId, mCurrentDiscoveryInterfaceMac); } } @@ -2423,8 +2425,8 @@ public class WifiNanStateManager { + ", matchFilter=" + Arrays.toString(matchFilter)); } - Pair<WifiNanClientState, WifiNanDiscoverySessionState> data = getClientSessionForPubSubId( - pubSubId); + Pair<WifiAwareClientState, WifiAwareDiscoverySessionState> data = + getClientSessionForPubSubId(pubSubId); if (data == null) { Log.e(TAG, "onMatch: no session found for pubSubId=" + pubSubId); return; @@ -2439,8 +2441,8 @@ public class WifiNanStateManager { + ", reason=" + reason); } - Pair<WifiNanClientState, WifiNanDiscoverySessionState> data = getClientSessionForPubSubId( - pubSubId); + Pair<WifiAwareClientState, WifiAwareDiscoverySessionState> data = + getClientSessionForPubSubId(pubSubId); if (data == null) { Log.e(TAG, "onSessionTerminatedLocal: no session found for pubSubId=" + pubSubId); return; @@ -2464,8 +2466,8 @@ public class WifiNanStateManager { + String.valueOf(HexEncoding.encode(peerMac))); } - Pair<WifiNanClientState, WifiNanDiscoverySessionState> data = getClientSessionForPubSubId( - pubSubId); + Pair<WifiAwareClientState, WifiAwareDiscoverySessionState> data = + getClientSessionForPubSubId(pubSubId); if (data == null) { Log.e(TAG, "onMessageReceivedLocal: no session found for pubSubId=" + pubSubId); return; @@ -2474,15 +2476,15 @@ public class WifiNanStateManager { data.second.onMessageReceived(requestorInstanceId, peerMac, message); } - private void onNanDownLocal() { + private void onAwareDownLocal() { if (VDBG) { - Log.v(TAG, "onNanDown"); + Log.v(TAG, "onAwareDown"); } mClients.clear(); - mCurrentNanConfiguration = null; - mSm.onNanDownCleanupSendQueueState(); - mDataPathMgr.onNanDownCleanupDataPaths(); + mCurrentAwareConfiguration = null; + mSm.onAwareDownCleanupSendQueueState(); + mDataPathMgr.onAwareDownCleanupDataPaths(); mCurrentDiscoveryInterfaceMac = ALL_ZERO_MAC; } @@ -2490,11 +2492,12 @@ public class WifiNanStateManager { * Utilities */ - private Pair<WifiNanClientState, WifiNanDiscoverySessionState> getClientSessionForPubSubId( + private Pair<WifiAwareClientState, WifiAwareDiscoverySessionState> getClientSessionForPubSubId( int pubSubId) { for (int i = 0; i < mClients.size(); ++i) { - WifiNanClientState client = mClients.valueAt(i); - WifiNanDiscoverySessionState session = client.getNanSessionStateForPubSubId(pubSubId); + WifiAwareClientState client = mClients.valueAt(i); + WifiAwareDiscoverySessionState session = client.getAwareSessionStateForPubSubId( + pubSubId); if (session != null) { return new Pair<>(client, session); } @@ -2586,11 +2589,11 @@ public class WifiNanStateManager { * Dump the internal state of the class. */ public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { - pw.println("NanStateManager:"); + pw.println("AwareStateManager:"); pw.println(" mClients: [" + mClients + "]"); pw.println(" mUsageEnabled: " + mUsageEnabled); pw.println(" mCapabilities: [" + mCapabilities + "]"); - pw.println(" mCurrentNanConfiguration: " + mCurrentNanConfiguration); + pw.println(" mCurrentAwareConfiguration: " + mCurrentAwareConfiguration); for (int i = 0; i < mClients.size(); ++i) { mClients.valueAt(i).dump(fd, pw, args); } diff --git a/service/jni/com_android_server_wifi_WifiNative.cpp b/service/jni/com_android_server_wifi_WifiNative.cpp index 17e469358..e18eed112 100644 --- a/service/jni/com_android_server_wifi_WifiNative.cpp +++ b/service/jni/com_android_server_wifi_WifiNative.cpp @@ -54,7 +54,7 @@ using android::wifi_system::InterfaceTool; namespace android { extern "C" -jint Java_com_android_server_wifi_WifiNative_registerNanNatives(JNIEnv* env, jclass clazz); +jint Java_com_android_server_wifi_WifiNative_registerAwareNatives(JNIEnv* env, jclass clazz); static jint DBG = false; diff --git a/service/jni/com_android_server_wifi_nan_WifiNanNative.cpp b/service/jni/com_android_server_wifi_aware_WifiAwareNative.cpp index 26ffab387..f1d292b41 100644 --- a/service/jni/com_android_server_wifi_nan_WifiNanNative.cpp +++ b/service/jni/com_android_server_wifi_aware_WifiAwareNative.cpp @@ -34,7 +34,7 @@ namespace android { -static jclass mCls; /* saved WifiNanNative object */ +static jclass mCls; /* saved WifiAwareNative object */ static JavaVM *mVM = NULL; /* saved JVM pointer */ wifi_handle getWifiHandle(JNIHelper &helper, jclass cls); @@ -52,28 +52,28 @@ static void OnNanNotifyResponse(transaction_id id, NanResponseMsg* msg) { JNIHelper helper(mVM); switch (msg->response_type) { case NAN_RESPONSE_PUBLISH: - helper.reportEvent(mCls, "onNanNotifyResponsePublishSubscribe", + helper.reportEvent(mCls, "onAwareNotifyResponsePublishSubscribe", "(SIIII)V", (short) id, (int) msg->response_type, (int) msg->status, (int) msg->value, msg->body.publish_response.publish_id); break; case NAN_RESPONSE_SUBSCRIBE: - helper.reportEvent(mCls, "onNanNotifyResponsePublishSubscribe", + helper.reportEvent(mCls, "onAwareNotifyResponsePublishSubscribe", "(SIIII)V", (short) id, (int) msg->response_type, (int) msg->status, (int) msg->value, msg->body.subscribe_response.subscribe_id); break; case NAN_GET_CAPABILITIES: { JNIObject<jobject> data = helper.createObject( - "com/android/server/wifi/nan/WifiNanNative$Capabilities"); + "com/android/server/wifi/aware/WifiAwareNative$Capabilities"); if (data == NULL) { ALOGE( - "Error in allocating WifiNanNative.Capabilities OnNanNotifyResponse"); + "Error in allocating WifiAwareNative.Capabilities OnNanNotifyResponse"); return; } helper.setIntField( - data, "maxConcurrentNanClusters", + data, "maxConcurrentAwareClusters", (int) msg->body.nan_capabilities.max_concurrent_nan_clusters); helper.setIntField(data, "maxPublishes", (int) msg->body.nan_capabilities.max_publishes); @@ -103,18 +103,18 @@ static void OnNanNotifyResponse(transaction_id id, NanResponseMsg* msg) { (int) msg->body.nan_capabilities.max_queued_transmit_followup_msgs); helper.reportEvent( - mCls, "onNanNotifyResponseCapabilities", - "(SIILcom/android/server/wifi/nan/WifiNanNative$Capabilities;)V", + mCls, "onAwareNotifyResponseCapabilities", + "(SIILcom/android/server/wifi/aware/WifiAwareNative$Capabilities;)V", (short) id, (int) msg->status, (int) msg->value, data.get()); break; } case NAN_DP_INITIATOR_RESPONSE: - helper.reportEvent(mCls, "onNanNotifyResponseDataPathInitiate", "(SIII)V", (short) id, + helper.reportEvent(mCls, "onAwareNotifyResponseDataPathInitiate", "(SIII)V", (short) id, (int) msg->status, (int) msg->value, msg->body.data_request_response.ndp_instance_id); break; default: - helper.reportEvent(mCls, "onNanNotifyResponse", "(SIII)V", (short) id, + helper.reportEvent(mCls, "onAwareNotifyResponse", "(SIII)V", (short) id, (int) msg->response_type, (int) msg->status, (int) msg->value); break; @@ -748,18 +748,18 @@ static jint android_net_wifi_nan_end_nan_data_path(JNIEnv *env, jclass cls, static JNINativeMethod gWifiNanMethods[] = { /* name, signature, funcPtr */ - {"initNanHandlersNative", "(Ljava/lang/Class;I)I", (void*)android_net_wifi_nan_register_handler }, + {"initAwareHandlersNative", "(Ljava/lang/Class;I)I", (void*)android_net_wifi_nan_register_handler }, {"getCapabilitiesNative", "(SLjava/lang/Class;I)I", (void*)android_net_wifi_nan_get_capabilities }, - {"enableAndConfigureNative", "(SLjava/lang/Class;ILandroid/net/wifi/nan/ConfigRequest;)I", (void*)android_net_wifi_nan_enable_request }, - {"updateConfigurationNative", "(SLjava/lang/Class;ILandroid/net/wifi/nan/ConfigRequest;)I", (void*)android_net_wifi_nan_config_request }, + {"enableAndConfigureNative", "(SLjava/lang/Class;ILandroid/net/wifi/aware/ConfigRequest;)I", (void*)android_net_wifi_nan_enable_request }, + {"updateConfigurationNative", "(SLjava/lang/Class;ILandroid/net/wifi/aware/ConfigRequest;)I", (void*)android_net_wifi_nan_config_request }, {"disableNative", "(SLjava/lang/Class;I)I", (void*)android_net_wifi_nan_disable_request }, - {"publishNative", "(SILjava/lang/Class;ILandroid/net/wifi/nan/PublishConfig;)I", (void*)android_net_wifi_nan_publish }, - {"subscribeNative", "(SILjava/lang/Class;ILandroid/net/wifi/nan/SubscribeConfig;)I", (void*)android_net_wifi_nan_subscribe }, + {"publishNative", "(SILjava/lang/Class;ILandroid/net/wifi/aware/PublishConfig;)I", (void*)android_net_wifi_nan_publish }, + {"subscribeNative", "(SILjava/lang/Class;ILandroid/net/wifi/aware/SubscribeConfig;)I", (void*)android_net_wifi_nan_subscribe }, {"sendMessageNative", "(SLjava/lang/Class;III[B[B)I", (void*)android_net_wifi_nan_send_message }, {"stopPublishNative", "(SLjava/lang/Class;II)I", (void*)android_net_wifi_nan_stop_publish }, {"stopSubscribeNative", "(SLjava/lang/Class;II)I", (void*)android_net_wifi_nan_stop_subscribe }, - {"createNanNetworkInterfaceNative", "(SLjava/lang/Class;ILjava/lang/String;)I", (void*)android_net_wifi_nan_create_nan_network_interface }, - {"deleteNanNetworkInterfaceNative", "(SLjava/lang/Class;ILjava/lang/String;)I", (void*)android_net_wifi_nan_delete_nan_network_interface }, + {"createAwareNetworkInterfaceNative", "(SLjava/lang/Class;ILjava/lang/String;)I", (void*)android_net_wifi_nan_create_nan_network_interface }, + {"deleteAwareNetworkInterfaceNative", "(SLjava/lang/Class;ILjava/lang/String;)I", (void*)android_net_wifi_nan_delete_nan_network_interface }, {"initiateDataPathNative", "(SLjava/lang/Class;IIII[BLjava/lang/String;[B)I", (void*)android_net_wifi_nan_initiate_nan_data_path }, {"respondToDataPathRequestNative", "(SLjava/lang/Class;IZILjava/lang/String;[B)I", (void*)android_net_wifi_nan_respond_nan_data_path_request }, {"endDataPathNative", "(SLjava/lang/Class;II)I", (void*)android_net_wifi_nan_end_nan_data_path }, @@ -767,9 +767,9 @@ static JNINativeMethod gWifiNanMethods[] = { /* User to register native functions */ extern "C" -jint Java_com_android_server_wifi_nan_WifiNanNative_registerNanNatives(JNIEnv* env, jclass clazz) { +jint Java_com_android_server_wifi_aware_WifiAwareNative_registerAwareNatives(JNIEnv* env, jclass clazz) { return jniRegisterNativeMethods(env, - "com/android/server/wifi/nan/WifiNanNative", gWifiNanMethods, NELEM(gWifiNanMethods)); + "com/android/server/wifi/aware/WifiAwareNative", gWifiNanMethods, NELEM(gWifiNanMethods)); } }; // namespace android |