Merge "[NAN-AWARE] Rename NAN to Aware" am: 74b1131cc8
am: 6571007101
Change-Id: Ief54b313dc5ca5d30645b55ed2ad0333036a1671
This commit is contained in:
12
Android.mk
12
Android.mk
@@ -456,9 +456,9 @@ LOCAL_SRC_FILES += \
|
|||||||
telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl \
|
telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl \
|
||||||
telephony/java/com/android/internal/telephony/IWapPushManager.aidl \
|
telephony/java/com/android/internal/telephony/IWapPushManager.aidl \
|
||||||
wifi/java/android/net/wifi/IWifiManager.aidl \
|
wifi/java/android/net/wifi/IWifiManager.aidl \
|
||||||
wifi/java/android/net/wifi/nan/IWifiNanEventCallback.aidl \
|
wifi/java/android/net/wifi/aware/IWifiAwareEventCallback.aidl \
|
||||||
wifi/java/android/net/wifi/nan/IWifiNanManager.aidl \
|
wifi/java/android/net/wifi/aware/IWifiAwareManager.aidl \
|
||||||
wifi/java/android/net/wifi/nan/IWifiNanDiscoverySessionCallback.aidl \
|
wifi/java/android/net/wifi/aware/IWifiAwareDiscoverySessionCallback.aidl \
|
||||||
wifi/java/android/net/wifi/p2p/IWifiP2pManager.aidl \
|
wifi/java/android/net/wifi/p2p/IWifiP2pManager.aidl \
|
||||||
wifi/java/android/net/wifi/IWifiScanner.aidl \
|
wifi/java/android/net/wifi/IWifiScanner.aidl \
|
||||||
wifi/java/android/net/wifi/IRttManager.aidl \
|
wifi/java/android/net/wifi/IRttManager.aidl \
|
||||||
@@ -548,9 +548,9 @@ aidl_files := \
|
|||||||
frameworks/base/media/java/android/media/tv/TvTrackInfo.aidl \
|
frameworks/base/media/java/android/media/tv/TvTrackInfo.aidl \
|
||||||
frameworks/base/media/java/android/media/browse/MediaBrowser.aidl \
|
frameworks/base/media/java/android/media/browse/MediaBrowser.aidl \
|
||||||
frameworks/base/wifi/java/android/net/wifi/ScanSettings.aidl \
|
frameworks/base/wifi/java/android/net/wifi/ScanSettings.aidl \
|
||||||
frameworks/base/wifi/java/android/net/wifi/nan/ConfigRequest.aidl \
|
frameworks/base/wifi/java/android/net/wifi/aware/ConfigRequest.aidl \
|
||||||
frameworks/base/wifi/java/android/net/wifi/nan/PublishConfig.aidl \
|
frameworks/base/wifi/java/android/net/wifi/aware/PublishConfig.aidl \
|
||||||
frameworks/base/wifi/java/android/net/wifi/nan/SubscribeConfig.aidl \
|
frameworks/base/wifi/java/android/net/wifi/aware/SubscribeConfig.aidl \
|
||||||
frameworks/base/wifi/java/android/net/wifi/p2p/WifiP2pInfo.aidl \
|
frameworks/base/wifi/java/android/net/wifi/p2p/WifiP2pInfo.aidl \
|
||||||
frameworks/base/wifi/java/android/net/wifi/p2p/WifiP2pDeviceList.aidl \
|
frameworks/base/wifi/java/android/net/wifi/p2p/WifiP2pDeviceList.aidl \
|
||||||
frameworks/base/wifi/java/android/net/wifi/p2p/WifiP2pConfig.aidl \
|
frameworks/base/wifi/java/android/net/wifi/p2p/WifiP2pConfig.aidl \
|
||||||
|
|||||||
@@ -84,8 +84,8 @@ import android.net.wifi.IWifiScanner;
|
|||||||
import android.net.wifi.RttManager;
|
import android.net.wifi.RttManager;
|
||||||
import android.net.wifi.WifiManager;
|
import android.net.wifi.WifiManager;
|
||||||
import android.net.wifi.WifiScanner;
|
import android.net.wifi.WifiScanner;
|
||||||
import android.net.wifi.nan.IWifiNanManager;
|
import android.net.wifi.aware.IWifiAwareManager;
|
||||||
import android.net.wifi.nan.WifiNanManager;
|
import android.net.wifi.aware.WifiAwareManager;
|
||||||
import android.net.wifi.p2p.IWifiP2pManager;
|
import android.net.wifi.p2p.IWifiP2pManager;
|
||||||
import android.net.wifi.p2p.WifiP2pManager;
|
import android.net.wifi.p2p.WifiP2pManager;
|
||||||
import android.nfc.NfcManager;
|
import android.nfc.NfcManager;
|
||||||
@@ -514,16 +514,16 @@ final class SystemServiceRegistry {
|
|||||||
return new WifiP2pManager(service);
|
return new WifiP2pManager(service);
|
||||||
}});
|
}});
|
||||||
|
|
||||||
registerService(Context.WIFI_NAN_SERVICE, WifiNanManager.class,
|
registerService(Context.WIFI_AWARE_SERVICE, WifiAwareManager.class,
|
||||||
new CachedServiceFetcher<WifiNanManager>() {
|
new CachedServiceFetcher<WifiAwareManager>() {
|
||||||
@Override
|
@Override
|
||||||
public WifiNanManager createService(ContextImpl ctx) {
|
public WifiAwareManager createService(ContextImpl ctx) {
|
||||||
IBinder b = ServiceManager.getService(Context.WIFI_NAN_SERVICE);
|
IBinder b = ServiceManager.getService(Context.WIFI_AWARE_SERVICE);
|
||||||
IWifiNanManager service = IWifiNanManager.Stub.asInterface(b);
|
IWifiAwareManager service = IWifiAwareManager.Stub.asInterface(b);
|
||||||
if (service == null) {
|
if (service == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return new WifiNanManager(ctx.getOuterContext(), service);
|
return new WifiAwareManager(ctx.getOuterContext(), service);
|
||||||
}});
|
}});
|
||||||
|
|
||||||
registerService(Context.WIFI_SCANNING_SERVICE, WifiScanner.class,
|
registerService(Context.WIFI_SCANNING_SERVICE, WifiScanner.class,
|
||||||
|
|||||||
@@ -2667,7 +2667,7 @@ public abstract class Context {
|
|||||||
NETWORK_STATS_SERVICE,
|
NETWORK_STATS_SERVICE,
|
||||||
//@hide: NETWORK_POLICY_SERVICE,
|
//@hide: NETWORK_POLICY_SERVICE,
|
||||||
WIFI_SERVICE,
|
WIFI_SERVICE,
|
||||||
WIFI_NAN_SERVICE,
|
WIFI_AWARE_SERVICE,
|
||||||
WIFI_P2P_SERVICE,
|
WIFI_P2P_SERVICE,
|
||||||
WIFI_SCANNING_SERVICE,
|
WIFI_SCANNING_SERVICE,
|
||||||
//@hide: WIFI_RTT_SERVICE,
|
//@hide: WIFI_RTT_SERVICE,
|
||||||
@@ -3139,14 +3139,14 @@ public abstract class Context {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Use with {@link #getSystemService} to retrieve a
|
* Use with {@link #getSystemService} to retrieve a
|
||||||
* {@link android.net.wifi.nan.WifiNanManager} for handling management of
|
* {@link android.net.wifi.aware.WifiAwareManager} for handling management of
|
||||||
* Wi-Fi NAN.
|
* Wi-Fi Aware.
|
||||||
*
|
*
|
||||||
* @see #getSystemService
|
* @see #getSystemService
|
||||||
* @see android.net.wifi.nan.WifiNanManager
|
* @see android.net.wifi.aware.WifiAwareManager
|
||||||
* @hide PROPOSED_NAN_API
|
* @hide PROPOSED_AWARE_API
|
||||||
*/
|
*/
|
||||||
public static final String WIFI_NAN_SERVICE = "wifinan";
|
public static final String WIFI_AWARE_SERVICE = "wifiaware";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use with {@link #getSystemService} to retrieve a {@link
|
* Use with {@link #getSystemService} to retrieve a {@link
|
||||||
|
|||||||
@@ -2040,12 +2040,12 @@ public abstract class PackageManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Feature for {@link #getSystemAvailableFeatures} and
|
* Feature for {@link #getSystemAvailableFeatures} and
|
||||||
* {@link #hasSystemFeature}: The device supports Wi-Fi NAN.
|
* {@link #hasSystemFeature}: The device supports Wi-Fi Aware.
|
||||||
*
|
*
|
||||||
* @hide PROPOSED_NAN_API
|
* @hide PROPOSED_AWARE_API
|
||||||
*/
|
*/
|
||||||
@SdkConstant(SdkConstantType.FEATURE)
|
@SdkConstant(SdkConstantType.FEATURE)
|
||||||
public static final String FEATURE_WIFI_NAN = "android.hardware.wifi.nan";
|
public static final String FEATURE_WIFI_AWARE = "android.hardware.wifi.aware";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Feature for {@link #getSystemAvailableFeatures} and
|
* Feature for {@link #getSystemAvailableFeatures} and
|
||||||
|
|||||||
@@ -419,14 +419,14 @@ public final class NetworkCapabilities implements Parcelable {
|
|||||||
public static final int TRANSPORT_VPN = 4;
|
public static final int TRANSPORT_VPN = 4;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates this network uses a Wi-Fi NAN transport.
|
* Indicates this network uses a Wi-Fi Aware transport.
|
||||||
*
|
*
|
||||||
* @hide PROPOSED_NAN_API
|
* @hide PROPOSED_AWARE_API
|
||||||
*/
|
*/
|
||||||
public static final int TRANSPORT_WIFI_NAN = 5;
|
public static final int TRANSPORT_WIFI_AWARE = 5;
|
||||||
|
|
||||||
private static final int MIN_TRANSPORT = TRANSPORT_CELLULAR;
|
private static final int MIN_TRANSPORT = TRANSPORT_CELLULAR;
|
||||||
private static final int MAX_TRANSPORT = TRANSPORT_WIFI_NAN;
|
private static final int MAX_TRANSPORT = TRANSPORT_WIFI_AWARE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the given transport type to this {@code NetworkCapability} instance.
|
* Adds the given transport type to this {@code NetworkCapability} instance.
|
||||||
@@ -896,7 +896,7 @@ public final class NetworkCapabilities implements Parcelable {
|
|||||||
case TRANSPORT_BLUETOOTH: transports += "BLUETOOTH"; break;
|
case TRANSPORT_BLUETOOTH: transports += "BLUETOOTH"; break;
|
||||||
case TRANSPORT_ETHERNET: transports += "ETHERNET"; break;
|
case TRANSPORT_ETHERNET: transports += "ETHERNET"; break;
|
||||||
case TRANSPORT_VPN: transports += "VPN"; break;
|
case TRANSPORT_VPN: transports += "VPN"; break;
|
||||||
case TRANSPORT_WIFI_NAN: transports += "WIFI_NAN"; break;
|
case TRANSPORT_WIFI_AWARE: transports += "WIFI_AWARE"; break;
|
||||||
}
|
}
|
||||||
if (++i < types.length) transports += "|";
|
if (++i < types.length) transports += "|";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -292,7 +292,7 @@
|
|||||||
<protected-broadcast android:name="android.net.wifi.WIFI_AP_STATE_CHANGED" />
|
<protected-broadcast android:name="android.net.wifi.WIFI_AP_STATE_CHANGED" />
|
||||||
<protected-broadcast android:name="android.net.wifi.WIFI_CREDENTIAL_CHANGED" />
|
<protected-broadcast android:name="android.net.wifi.WIFI_CREDENTIAL_CHANGED" />
|
||||||
<protected-broadcast android:name="android.net.wifi.WIFI_SCAN_AVAILABLE" />
|
<protected-broadcast android:name="android.net.wifi.WIFI_SCAN_AVAILABLE" />
|
||||||
<protected-broadcast android:name="android.net.wifi.nan.action.WIFI_NAN_STATE_CHANGED" />
|
<protected-broadcast android:name="android.net.wifi.aware.action.WIFI_AWARE_STATE_CHANGED" />
|
||||||
<protected-broadcast android:name="android.net.wifi.SCAN_RESULTS" />
|
<protected-broadcast android:name="android.net.wifi.SCAN_RESULTS" />
|
||||||
<protected-broadcast android:name="android.net.wifi.RSSI_CHANGED" />
|
<protected-broadcast android:name="android.net.wifi.RSSI_CHANGED" />
|
||||||
<protected-broadcast android:name="android.net.wifi.STATE_CHANGE" />
|
<protected-broadcast android:name="android.net.wifi.STATE_CHANGE" />
|
||||||
@@ -300,7 +300,6 @@
|
|||||||
<protected-broadcast android:name="android.net.wifi.CONFIGURED_NETWORKS_CHANGE" />
|
<protected-broadcast android:name="android.net.wifi.CONFIGURED_NETWORKS_CHANGE" />
|
||||||
<protected-broadcast android:name="android.net.wifi.supplicant.CONNECTION_CHANGE" />
|
<protected-broadcast android:name="android.net.wifi.supplicant.CONNECTION_CHANGE" />
|
||||||
<protected-broadcast android:name="android.net.wifi.supplicant.STATE_CHANGE" />
|
<protected-broadcast android:name="android.net.wifi.supplicant.STATE_CHANGE" />
|
||||||
<protected-broadcast android:name="android.net.wifi.nan.STATE_CHANGED" />
|
|
||||||
<protected-broadcast android:name="android.net.wifi.p2p.STATE_CHANGED" />
|
<protected-broadcast android:name="android.net.wifi.p2p.STATE_CHANGED" />
|
||||||
<protected-broadcast android:name="android.net.wifi.p2p.DISCOVERY_STATE_CHANGE" />
|
<protected-broadcast android:name="android.net.wifi.p2p.DISCOVERY_STATE_CHANGE" />
|
||||||
<protected-broadcast android:name="android.net.wifi.p2p.THIS_DEVICE_CHANGED" />
|
<protected-broadcast android:name="android.net.wifi.p2p.THIS_DEVICE_CHANGED" />
|
||||||
|
|||||||
@@ -142,8 +142,8 @@ public final class SystemServer {
|
|||||||
"com.android.server.midi.MidiService$Lifecycle";
|
"com.android.server.midi.MidiService$Lifecycle";
|
||||||
private static final String WIFI_SERVICE_CLASS =
|
private static final String WIFI_SERVICE_CLASS =
|
||||||
"com.android.server.wifi.WifiService";
|
"com.android.server.wifi.WifiService";
|
||||||
private static final String WIFI_NAN_SERVICE_CLASS =
|
private static final String WIFI_AWARE_SERVICE_CLASS =
|
||||||
"com.android.server.wifi.nan.WifiNanService";
|
"com.android.server.wifi.aware.WifiAwareService";
|
||||||
private static final String WIFI_P2P_SERVICE_CLASS =
|
private static final String WIFI_P2P_SERVICE_CLASS =
|
||||||
"com.android.server.wifi.p2p.WifiP2pService";
|
"com.android.server.wifi.p2p.WifiP2pService";
|
||||||
private static final String ETHERNET_SERVICE_CLASS =
|
private static final String ETHERNET_SERVICE_CLASS =
|
||||||
@@ -834,10 +834,11 @@ public final class SystemServer {
|
|||||||
}
|
}
|
||||||
Trace.traceEnd(Trace.TRACE_TAG_SYSTEM_SERVER);
|
Trace.traceEnd(Trace.TRACE_TAG_SYSTEM_SERVER);
|
||||||
|
|
||||||
if (context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_WIFI_NAN)) {
|
if (context.getPackageManager().hasSystemFeature(
|
||||||
mSystemServiceManager.startService(WIFI_NAN_SERVICE_CLASS);
|
PackageManager.FEATURE_WIFI_AWARE)) {
|
||||||
|
mSystemServiceManager.startService(WIFI_AWARE_SERVICE_CLASS);
|
||||||
} else {
|
} else {
|
||||||
Slog.i(TAG, "No Wi-Fi NAN Service (NAN support Not Present)");
|
Slog.i(TAG, "No Wi-Fi Aware Service (Aware support Not Present)");
|
||||||
}
|
}
|
||||||
mSystemServiceManager.startService(WIFI_P2P_SERVICE_CLASS);
|
mSystemServiceManager.startService(WIFI_P2P_SERVICE_CLASS);
|
||||||
mSystemServiceManager.startService(WIFI_SERVICE_CLASS);
|
mSystemServiceManager.startService(WIFI_SERVICE_CLASS);
|
||||||
|
|||||||
@@ -1043,7 +1043,7 @@ public class WifiManager {
|
|||||||
/** @hide */
|
/** @hide */
|
||||||
public static final int WIFI_FEATURE_SCANNER = 0x0020; // WifiScanner APIs
|
public static final int WIFI_FEATURE_SCANNER = 0x0020; // WifiScanner APIs
|
||||||
/** @hide */
|
/** @hide */
|
||||||
public static final int WIFI_FEATURE_NAN = 0x0040; // Neighbor Awareness Networking
|
public static final int WIFI_FEATURE_AWARE = 0x0040; // Wi-Fi AWare networking
|
||||||
/** @hide */
|
/** @hide */
|
||||||
public static final int WIFI_FEATURE_D2D_RTT = 0x0080; // Device-to-device RTT
|
public static final int WIFI_FEATURE_D2D_RTT = 0x0080; // Device-to-device RTT
|
||||||
/** @hide */
|
/** @hide */
|
||||||
@@ -1124,8 +1124,8 @@ public class WifiManager {
|
|||||||
* @return true if this adapter supports Neighbour Awareness Network APIs
|
* @return true if this adapter supports Neighbour Awareness Network APIs
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public boolean isNanSupported() {
|
public boolean isWifiAwareSupported() {
|
||||||
return isFeatureSupported(WIFI_FEATURE_NAN);
|
return isFeatureSupported(WIFI_FEATURE_AWARE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -14,6 +14,6 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package android.net.wifi.nan;
|
package android.net.wifi.aware;
|
||||||
|
|
||||||
parcelable ConfigRequest;
|
parcelable ConfigRequest;
|
||||||
@@ -14,15 +14,15 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package android.net.wifi.nan;
|
package android.net.wifi.aware;
|
||||||
|
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines a request object to configure a Wi-Fi NAN network. Built using
|
* Defines a request object to configure a Wi-Fi Aware network. Built using
|
||||||
* {@link ConfigRequest.Builder}. Configuration is requested using
|
* {@link ConfigRequest.Builder}. Configuration is requested using
|
||||||
* {@link WifiNanManager#attach(android.os.Handler, WifiNanAttachCallback)}.
|
* {@link WifiAwareManager#attach(android.os.Handler, WifiAwareAttachCallback)}.
|
||||||
* Note that the actual achieved configuration may be different from the
|
* Note that the actual achieved configuration may be different from the
|
||||||
* requested configuration - since different applications may request different
|
* requested configuration - since different applications may request different
|
||||||
* configurations.
|
* configurations.
|
||||||
@@ -221,7 +221,7 @@ public final class ConfigRequest implements Parcelable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Cluster ID is generated randomly for new NAN networks. Specify
|
* The Cluster ID is generated randomly for new Aware networks. Specify
|
||||||
* the lower range of the cluster ID. The upper range is specified using
|
* the lower range of the cluster ID. The upper range is specified using
|
||||||
* the {@link ConfigRequest.Builder#setClusterHigh(int)}. The permitted
|
* the {@link ConfigRequest.Builder#setClusterHigh(int)}. The permitted
|
||||||
* range is 0 (the default) to the value specified by
|
* range is 0 (the default) to the value specified by
|
||||||
@@ -246,7 +246,7 @@ public final class ConfigRequest implements Parcelable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Cluster ID is generated randomly for new NAN networks. Specify
|
* The Cluster ID is generated randomly for new Aware networks. Specify
|
||||||
* the lower upper of the cluster ID. The lower range is specified using
|
* the lower upper of the cluster ID. The lower range is specified using
|
||||||
* the {@link ConfigRequest.Builder#setClusterLow(int)}. The permitted
|
* the {@link ConfigRequest.Builder#setClusterLow(int)}. The permitted
|
||||||
* range is the value specified by
|
* range is the value specified by
|
||||||
@@ -14,14 +14,14 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package android.net.wifi.nan;
|
package android.net.wifi.aware;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Callback interface that WifiNanManager implements
|
* Callback interface that WifiAwareManager implements
|
||||||
*
|
*
|
||||||
* {@hide}
|
* {@hide}
|
||||||
*/
|
*/
|
||||||
oneway interface IWifiNanDiscoverySessionCallback
|
oneway interface IWifiAwareDiscoverySessionCallback
|
||||||
{
|
{
|
||||||
void onSessionStarted(int discoverySessionId);
|
void onSessionStarted(int discoverySessionId);
|
||||||
void onSessionConfigSuccess();
|
void onSessionConfigSuccess();
|
||||||
@@ -14,17 +14,17 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package android.net.wifi.nan;
|
package android.net.wifi.aware;
|
||||||
|
|
||||||
import android.net.wifi.nan.ConfigRequest;
|
import android.net.wifi.aware.ConfigRequest;
|
||||||
import android.net.wifi.RttManager;
|
import android.net.wifi.RttManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Callback interface that WifiNanManager implements
|
* Callback interface that WifiAwareManager implements
|
||||||
*
|
*
|
||||||
* {@hide}
|
* {@hide}
|
||||||
*/
|
*/
|
||||||
oneway interface IWifiNanEventCallback
|
oneway interface IWifiAwareEventCallback
|
||||||
{
|
{
|
||||||
void onConnectSuccess(int clientId);
|
void onConnectSuccess(int clientId);
|
||||||
void onConnectFail(int reason);
|
void onConnectFail(int reason);
|
||||||
@@ -14,40 +14,40 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package android.net.wifi.nan;
|
package android.net.wifi.aware;
|
||||||
|
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
|
|
||||||
import android.net.wifi.nan.ConfigRequest;
|
import android.net.wifi.aware.ConfigRequest;
|
||||||
import android.net.wifi.nan.IWifiNanDiscoverySessionCallback;
|
import android.net.wifi.aware.IWifiAwareDiscoverySessionCallback;
|
||||||
import android.net.wifi.nan.IWifiNanEventCallback;
|
import android.net.wifi.aware.IWifiAwareEventCallback;
|
||||||
import android.net.wifi.nan.PublishConfig;
|
import android.net.wifi.aware.PublishConfig;
|
||||||
import android.net.wifi.nan.SubscribeConfig;
|
import android.net.wifi.aware.SubscribeConfig;
|
||||||
import android.net.wifi.nan.WifiNanCharacteristics;
|
import android.net.wifi.aware.WifiAwareCharacteristics;
|
||||||
import android.net.wifi.RttManager;
|
import android.net.wifi.RttManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface that WifiNanService implements
|
* Interface that WifiAwareService implements
|
||||||
*
|
*
|
||||||
* {@hide}
|
* {@hide}
|
||||||
*/
|
*/
|
||||||
interface IWifiNanManager
|
interface IWifiAwareManager
|
||||||
{
|
{
|
||||||
// NAN API
|
// Aware API
|
||||||
void enableUsage();
|
void enableUsage();
|
||||||
void disableUsage();
|
void disableUsage();
|
||||||
boolean isUsageEnabled();
|
boolean isUsageEnabled();
|
||||||
WifiNanCharacteristics getCharacteristics();
|
WifiAwareCharacteristics getCharacteristics();
|
||||||
|
|
||||||
// client API
|
// client API
|
||||||
void connect(in IBinder binder, in String callingPackage, in IWifiNanEventCallback callback,
|
void connect(in IBinder binder, in String callingPackage, in IWifiAwareEventCallback callback,
|
||||||
in ConfigRequest configRequest, boolean notifyOnIdentityChanged);
|
in ConfigRequest configRequest, boolean notifyOnIdentityChanged);
|
||||||
void disconnect(int clientId, in IBinder binder);
|
void disconnect(int clientId, in IBinder binder);
|
||||||
|
|
||||||
void publish(int clientId, in PublishConfig publishConfig,
|
void publish(int clientId, in PublishConfig publishConfig,
|
||||||
in IWifiNanDiscoverySessionCallback callback);
|
in IWifiAwareDiscoverySessionCallback callback);
|
||||||
void subscribe(int clientId, in SubscribeConfig subscribeConfig,
|
void subscribe(int clientId, in SubscribeConfig subscribeConfig,
|
||||||
in IWifiNanDiscoverySessionCallback callback);
|
in IWifiAwareDiscoverySessionCallback callback);
|
||||||
|
|
||||||
// session API
|
// session API
|
||||||
void updatePublish(int clientId, int discoverySessionId, in PublishConfig publishConfig);
|
void updatePublish(int clientId, int discoverySessionId, in PublishConfig publishConfig);
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package android.net.wifi.nan;
|
package android.net.wifi.aware;
|
||||||
|
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
|
|
||||||
@@ -28,7 +28,7 @@ import java.util.Iterator;
|
|||||||
* Length/Value format. The utilities accept a configuration of the size of
|
* Length/Value format. The utilities accept a configuration of the size of
|
||||||
* the Length field.
|
* the Length field.
|
||||||
*
|
*
|
||||||
* @hide PROPOSED_NAN_API
|
* @hide PROPOSED_AWARE_API
|
||||||
*/
|
*/
|
||||||
public class LvBufferUtils {
|
public class LvBufferUtils {
|
||||||
private LvBufferUtils() {
|
private LvBufferUtils() {
|
||||||
@@ -14,6 +14,6 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package android.net.wifi.nan;
|
package android.net.wifi.aware;
|
||||||
|
|
||||||
parcelable PublishConfig;
|
parcelable PublishConfig;
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package android.net.wifi.nan;
|
package android.net.wifi.aware;
|
||||||
|
|
||||||
import android.annotation.IntDef;
|
import android.annotation.IntDef;
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
@@ -30,13 +30,14 @@ import java.nio.charset.StandardCharsets;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines the configuration of a NAN publish session. Built using
|
* Defines the configuration of a Aware publish session. Built using
|
||||||
* {@link PublishConfig.Builder}. A publish session is created using
|
* {@link PublishConfig.Builder}. A publish session is created using
|
||||||
* {@link WifiNanSession#publish(android.os.Handler, PublishConfig, WifiNanDiscoverySessionCallback)}
|
* {@link WifiAwareSession#publish(android.os.Handler, PublishConfig,
|
||||||
|
* WifiAwareDiscoverySessionCallback)}
|
||||||
* or updated using
|
* or updated using
|
||||||
* {@link WifiNanPublishDiscoverySession#updatePublish(PublishConfig)}.
|
* {@link WifiAwarePublishDiscoverySession#updatePublish(PublishConfig)}.
|
||||||
*
|
*
|
||||||
* @hide PROPOSED_NAN_API
|
* @hide PROPOSED_AWARE_API
|
||||||
*/
|
*/
|
||||||
public final class PublishConfig implements Parcelable {
|
public final class PublishConfig implements Parcelable {
|
||||||
/** @hide */
|
/** @hide */
|
||||||
@@ -182,8 +183,9 @@ public final class PublishConfig implements Parcelable {
|
|||||||
*
|
*
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public void assertValid(WifiNanCharacteristics characteristics) throws IllegalArgumentException {
|
public void assertValid(WifiAwareCharacteristics characteristics)
|
||||||
WifiNanUtils.validateServiceName(mServiceName);
|
throws IllegalArgumentException {
|
||||||
|
WifiAwareUtils.validateServiceName(mServiceName);
|
||||||
|
|
||||||
if (!LvBufferUtils.isValid(mMatchFilter, 1)) {
|
if (!LvBufferUtils.isValid(mMatchFilter, 1)) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
@@ -320,12 +322,12 @@ public final class PublishConfig implements Parcelable {
|
|||||||
* Sets the number of times an unsolicited (configured using
|
* Sets the number of times an unsolicited (configured using
|
||||||
* {@link PublishConfig.Builder#setPublishType(int)}) publish session
|
* {@link PublishConfig.Builder#setPublishType(int)}) publish session
|
||||||
* will be broadcast. When the count is reached an event will be
|
* will be broadcast. When the count is reached an event will be
|
||||||
* generated for {@link WifiNanDiscoverySessionCallback#onSessionTerminated(int)}
|
* generated for {@link WifiAwareDiscoverySessionCallback#onSessionTerminated(int)}
|
||||||
* with {@link WifiNanDiscoverySessionCallback#TERMINATE_REASON_DONE} [unless
|
* with {@link WifiAwareDiscoverySessionCallback#TERMINATE_REASON_DONE} [unless
|
||||||
* {@link #setTerminateNotificationEnabled(boolean)} disables the callback].
|
* {@link #setTerminateNotificationEnabled(boolean)} disables the callback].
|
||||||
* <p>
|
* <p>
|
||||||
* Optional. 0 by default - indicating the session doesn't terminate on its own.
|
* Optional. 0 by default - indicating the session doesn't terminate on its own.
|
||||||
* Session will be terminated when {@link WifiNanDiscoveryBaseSession#destroy()} is
|
* Session will be terminated when {@link WifiAwareDiscoveryBaseSession#destroy()} is
|
||||||
* called.
|
* called.
|
||||||
*
|
*
|
||||||
* @param publishCount Number of publish packets to broadcast.
|
* @param publishCount Number of publish packets to broadcast.
|
||||||
@@ -346,12 +348,12 @@ public final class PublishConfig implements Parcelable {
|
|||||||
* {@link PublishConfig.Builder#setPublishType(int)}) publish session
|
* {@link PublishConfig.Builder#setPublishType(int)}) publish session
|
||||||
* will be alive - broadcasting a packet. When the TTL is reached
|
* will be alive - broadcasting a packet. When the TTL is reached
|
||||||
* an event will be generated for
|
* an event will be generated for
|
||||||
* {@link WifiNanDiscoverySessionCallback#onSessionTerminated(int)} with
|
* {@link WifiAwareDiscoverySessionCallback#onSessionTerminated(int)} with
|
||||||
* {@link WifiNanDiscoverySessionCallback#TERMINATE_REASON_DONE} [unless
|
* {@link WifiAwareDiscoverySessionCallback#TERMINATE_REASON_DONE} [unless
|
||||||
* {@link #setTerminateNotificationEnabled(boolean)} disables the callback].
|
* {@link #setTerminateNotificationEnabled(boolean)} disables the callback].
|
||||||
* <p>
|
* <p>
|
||||||
* Optional. 0 by default - indicating the session doesn't terminate on its own.
|
* Optional. 0 by default - indicating the session doesn't terminate on its own.
|
||||||
* Session will be terminated when {@link WifiNanDiscoveryBaseSession#destroy()} is
|
* Session will be terminated when {@link WifiAwareDiscoveryBaseSession#destroy()} is
|
||||||
* called.
|
* called.
|
||||||
*
|
*
|
||||||
* @param ttlSec Lifetime of a publish session in seconds.
|
* @param ttlSec Lifetime of a publish session in seconds.
|
||||||
@@ -369,7 +371,7 @@ public final class PublishConfig implements Parcelable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Configure whether a publish terminate notification
|
* Configure whether a publish terminate notification
|
||||||
* {@link WifiNanDiscoverySessionCallback#onSessionTerminated(int)} is reported
|
* {@link WifiAwareDiscoverySessionCallback#onSessionTerminated(int)} is reported
|
||||||
* back to the callback.
|
* back to the callback.
|
||||||
*
|
*
|
||||||
* @param enable If true the terminate callback will be called when the
|
* @param enable If true the terminate callback will be called when the
|
||||||
@@ -14,6 +14,6 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package android.net.wifi.nan;
|
package android.net.wifi.aware;
|
||||||
|
|
||||||
parcelable SubscribeConfig;
|
parcelable SubscribeConfig;
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package android.net.wifi.nan;
|
package android.net.wifi.aware;
|
||||||
|
|
||||||
import android.annotation.IntDef;
|
import android.annotation.IntDef;
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
@@ -30,13 +30,14 @@ import java.nio.charset.StandardCharsets;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines the configuration of a NAN subscribe session. Built using
|
* Defines the configuration of a Aware subscribe session. Built using
|
||||||
* {@link SubscribeConfig.Builder}. Subscribe is done using
|
* {@link SubscribeConfig.Builder}. Subscribe is done using
|
||||||
* {@link WifiNanSession#subscribe(android.os.Handler, SubscribeConfig, WifiNanDiscoverySessionCallback)}
|
* {@link WifiAwareSession#subscribe(android.os.Handler, SubscribeConfig,
|
||||||
|
* WifiAwareDiscoverySessionCallback)}
|
||||||
* or
|
* or
|
||||||
* {@link WifiNanSubscribeDiscoverySession#updateSubscribe(SubscribeConfig)}.
|
* {@link WifiAwareSubscribeDiscoverySession#updateSubscribe(SubscribeConfig)}.
|
||||||
*
|
*
|
||||||
* @hide PROPOSED_NAN_API
|
* @hide PROPOSED_AWARE_API
|
||||||
*/
|
*/
|
||||||
public final class SubscribeConfig implements Parcelable {
|
public final class SubscribeConfig implements Parcelable {
|
||||||
/** @hide */
|
/** @hide */
|
||||||
@@ -209,8 +210,9 @@ public final class SubscribeConfig implements Parcelable {
|
|||||||
*
|
*
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public void assertValid(WifiNanCharacteristics characteristics) throws IllegalArgumentException {
|
public void assertValid(WifiAwareCharacteristics characteristics)
|
||||||
WifiNanUtils.validateServiceName(mServiceName);
|
throws IllegalArgumentException {
|
||||||
|
WifiAwareUtils.validateServiceName(mServiceName);
|
||||||
|
|
||||||
if (!LvBufferUtils.isValid(mMatchFilter, 1)) {
|
if (!LvBufferUtils.isValid(mMatchFilter, 1)) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
@@ -352,11 +354,11 @@ public final class SubscribeConfig implements Parcelable {
|
|||||||
* Sets the number of times an active (
|
* Sets the number of times an active (
|
||||||
* {@link SubscribeConfig.Builder#setSubscribeType(int)}) subscribe session
|
* {@link SubscribeConfig.Builder#setSubscribeType(int)}) subscribe session
|
||||||
* will broadcast. When the count is reached an event will be
|
* will broadcast. When the count is reached an event will be
|
||||||
* generated for {@link WifiNanDiscoverySessionCallback#onSessionTerminated(int)}
|
* generated for {@link WifiAwareDiscoverySessionCallback#onSessionTerminated(int)}
|
||||||
* with {@link WifiNanDiscoverySessionCallback#TERMINATE_REASON_DONE}.
|
* with {@link WifiAwareDiscoverySessionCallback#TERMINATE_REASON_DONE}.
|
||||||
* <p>
|
* <p>
|
||||||
* Optional. 0 by default - indicating the session doesn't terminate on its own.
|
* Optional. 0 by default - indicating the session doesn't terminate on its own.
|
||||||
* Session will be terminated when {@link WifiNanDiscoveryBaseSession#destroy()} is
|
* Session will be terminated when {@link WifiAwareDiscoveryBaseSession#destroy()} is
|
||||||
* called.
|
* called.
|
||||||
*
|
*
|
||||||
* @param subscribeCount Number of subscribe packets to broadcast.
|
* @param subscribeCount Number of subscribe packets to broadcast.
|
||||||
@@ -377,11 +379,11 @@ public final class SubscribeConfig implements Parcelable {
|
|||||||
* {@link SubscribeConfig.Builder#setSubscribeType(int)}) subscribe session
|
* {@link SubscribeConfig.Builder#setSubscribeType(int)}) subscribe session
|
||||||
* will be alive - i.e. broadcasting a packet. When the TTL is reached
|
* will be alive - i.e. broadcasting a packet. When the TTL is reached
|
||||||
* an event will be generated for
|
* an event will be generated for
|
||||||
* {@link WifiNanDiscoverySessionCallback#onSessionTerminated(int)} with
|
* {@link WifiAwareDiscoverySessionCallback#onSessionTerminated(int)} with
|
||||||
* {@link WifiNanDiscoverySessionCallback#TERMINATE_REASON_DONE}.
|
* {@link WifiAwareDiscoverySessionCallback#TERMINATE_REASON_DONE}.
|
||||||
* <p>
|
* <p>
|
||||||
* Optional. 0 by default - indicating the session doesn't terminate on its own.
|
* Optional. 0 by default - indicating the session doesn't terminate on its own.
|
||||||
* Session will be terminated when {@link WifiNanDiscoveryBaseSession#destroy()} is
|
* Session will be terminated when {@link WifiAwareDiscoveryBaseSession#destroy()} is
|
||||||
* called.
|
* called.
|
||||||
*
|
*
|
||||||
* @param ttlSec Lifetime of a subscribe session in seconds.
|
* @param ttlSec Lifetime of a subscribe session in seconds.
|
||||||
@@ -401,7 +403,7 @@ public final class SubscribeConfig implements Parcelable {
|
|||||||
* Sets the match style of the subscription - how are matches from a
|
* Sets the match style of the subscription - how are matches from a
|
||||||
* single match session (corresponding to the same publish action on the
|
* single match session (corresponding to the same publish action on the
|
||||||
* peer) reported to the host (using the
|
* peer) reported to the host (using the
|
||||||
* {@link WifiNanDiscoverySessionCallback#onServiceDiscovered(Object, byte[], byte[])}
|
* {@link WifiAwareDiscoverySessionCallback#onServiceDiscovered(Object, byte[], byte[])}
|
||||||
* ). The options are: only report the first match and ignore the rest
|
* ). The options are: only report the first match and ignore the rest
|
||||||
* {@link SubscribeConfig#MATCH_STYLE_FIRST_ONLY} or report every single
|
* {@link SubscribeConfig#MATCH_STYLE_FIRST_ONLY} or report every single
|
||||||
* match {@link SubscribeConfig#MATCH_STYLE_ALL} (the default).
|
* match {@link SubscribeConfig#MATCH_STYLE_ALL} (the default).
|
||||||
@@ -421,7 +423,7 @@ public final class SubscribeConfig implements Parcelable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Configure whether a subscribe terminate notification
|
* Configure whether a subscribe terminate notification
|
||||||
* {@link WifiNanDiscoverySessionCallback#onSessionTerminated(int)} is reported
|
* {@link WifiAwareDiscoverySessionCallback#onSessionTerminated(int)} is reported
|
||||||
* back to the callback.
|
* back to the callback.
|
||||||
*
|
*
|
||||||
* @param enable If true the terminate callback will be called when the
|
* @param enable If true the terminate callback will be called when the
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package android.net.wifi.nan;
|
package android.net.wifi.aware;
|
||||||
|
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
|
|
||||||
@@ -32,7 +32,7 @@ import java.util.NoSuchElementException;
|
|||||||
* the Type field and the Length field. A Type field size of 0 is allowed -
|
* the Type field and the Length field. A Type field size of 0 is allowed -
|
||||||
* allowing usage for LV (no T) array formats.
|
* allowing usage for LV (no T) array formats.
|
||||||
*
|
*
|
||||||
* @hide PROPOSED_NAN_API
|
* @hide PROPOSED_AWARE_API
|
||||||
*/
|
*/
|
||||||
public class TlvBufferUtils {
|
public class TlvBufferUtils {
|
||||||
private TlvBufferUtils() {
|
private TlvBufferUtils() {
|
||||||
@@ -14,32 +14,32 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package android.net.wifi.nan;
|
package android.net.wifi.aware;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for NAN attach callbacks. Should be extended by applications and set when calling
|
* Base class for Aware attach callbacks. Should be extended by applications and set when calling
|
||||||
* {@link WifiNanManager#attach(android.os.Handler, WifiNanAttachCallback)}. These are callbacks
|
* {@link WifiAwareManager#attach(android.os.Handler, WifiAwareAttachCallback)}. These are callbacks
|
||||||
* applying to the NAN connection as a whole - not to specific publish or subscribe sessions -
|
* applying to the Aware connection as a whole - not to specific publish or subscribe sessions -
|
||||||
* for that see {@link WifiNanDiscoverySessionCallback}.
|
* for that see {@link WifiAwareDiscoverySessionCallback}.
|
||||||
*
|
*
|
||||||
* @hide PROPOSED_NAN_API
|
* @hide PROPOSED_AWARE_API
|
||||||
*/
|
*/
|
||||||
public class WifiNanAttachCallback {
|
public class WifiAwareAttachCallback {
|
||||||
/**
|
/**
|
||||||
* Called when NAN attach operation
|
* Called when Aware attach operation
|
||||||
* {@link WifiNanManager#attach(android.os.Handler, WifiNanAttachCallback)}
|
* {@link WifiAwareManager#attach(android.os.Handler, WifiAwareAttachCallback)}
|
||||||
* is completed and that we can now start discovery sessions or connections.
|
* is completed and that we can now start discovery sessions or connections.
|
||||||
*
|
*
|
||||||
* @param session The NAN object on which we can execute further NAN operations - e.g.
|
* @param session The Aware object on which we can execute further Aware operations - e.g.
|
||||||
* discovery, connections.
|
* discovery, connections.
|
||||||
*/
|
*/
|
||||||
public void onAttached(WifiNanSession session) {
|
public void onAttached(WifiAwareSession session) {
|
||||||
/* empty */
|
/* empty */
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when NAN attach operation
|
* Called when Aware attach operation
|
||||||
* {@link WifiNanManager#attach(android.os.Handler, WifiNanAttachCallback)} failed.
|
* {@link WifiAwareManager#attach(android.os.Handler, WifiAwareAttachCallback)} failed.
|
||||||
*/
|
*/
|
||||||
public void onAttachFailed() {
|
public void onAttachFailed() {
|
||||||
/* empty */
|
/* empty */
|
||||||
@@ -14,6 +14,6 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package android.net.wifi.nan;
|
package android.net.wifi.aware;
|
||||||
|
|
||||||
parcelable WifiNanCharacteristics;
|
parcelable WifiAwareCharacteristics;
|
||||||
@@ -14,18 +14,18 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package android.net.wifi.nan;
|
package android.net.wifi.aware;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The characteristics of the Wi-Fi NAN implementation.
|
* The characteristics of the Wi-Fi Aware implementation.
|
||||||
*
|
*
|
||||||
* @hide PROPOSED_NAN_API
|
* @hide PROPOSED_AWARE_API
|
||||||
*/
|
*/
|
||||||
public class WifiNanCharacteristics implements Parcelable {
|
public class WifiAwareCharacteristics implements Parcelable {
|
||||||
/** @hide */
|
/** @hide */
|
||||||
public static final String KEY_MAX_SERVICE_NAME_LENGTH = "key_max_service_name_length";
|
public static final String KEY_MAX_SERVICE_NAME_LENGTH = "key_max_service_name_length";
|
||||||
/** @hide */
|
/** @hide */
|
||||||
@@ -37,41 +37,41 @@ public class WifiNanCharacteristics implements Parcelable {
|
|||||||
private Bundle mCharacteristics = new Bundle();
|
private Bundle mCharacteristics = new Bundle();
|
||||||
|
|
||||||
/** @hide : should not be created by apps */
|
/** @hide : should not be created by apps */
|
||||||
public WifiNanCharacteristics(Bundle characteristics) {
|
public WifiAwareCharacteristics(Bundle characteristics) {
|
||||||
mCharacteristics = characteristics;
|
mCharacteristics = characteristics;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the maximum string length that can be used to specify a NAN service name. Restricts
|
* Returns the maximum string length that can be used to specify a Aware service name. Restricts
|
||||||
* the parameters of the {@link PublishConfig.Builder#setServiceName(String)} and
|
* the parameters of the {@link PublishConfig.Builder#setServiceName(String)} and
|
||||||
* {@link SubscribeConfig.Builder#setServiceName(String)}.
|
* {@link SubscribeConfig.Builder#setServiceName(String)}.
|
||||||
*
|
*
|
||||||
* @return A positive integer, maximum string length of NAN service name.
|
* @return A positive integer, maximum string length of Aware service name.
|
||||||
*/
|
*/
|
||||||
public int getMaxServiceNameLength() {
|
public int getMaxServiceNameLength() {
|
||||||
return mCharacteristics.getInt(KEY_MAX_SERVICE_NAME_LENGTH);
|
return mCharacteristics.getInt(KEY_MAX_SERVICE_NAME_LENGTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the maximum length of byte array that can be used to specify a NAN service specific
|
* Returns the maximum length of byte array that can be used to specify a Aware service specific
|
||||||
* information field: the arbitrary load used in discovery or the message length of NAN
|
* information field: the arbitrary load used in discovery or the message length of Aware
|
||||||
* message exchange. Restricts the parameters of the
|
* message exchange. Restricts the parameters of the
|
||||||
* {@link PublishConfig.Builder#setServiceSpecificInfo(byte[])},
|
* {@link PublishConfig.Builder#setServiceSpecificInfo(byte[])},
|
||||||
* {@link SubscribeConfig.Builder#setServiceSpecificInfo(byte[])}, and
|
* {@link SubscribeConfig.Builder#setServiceSpecificInfo(byte[])}, and
|
||||||
* {@link WifiNanDiscoveryBaseSession#sendMessage(Object, int, byte[])} variants.
|
* {@link WifiAwareDiscoveryBaseSession#sendMessage(Object, int, byte[])} variants.
|
||||||
*
|
*
|
||||||
* @return A positive integer, maximum length of byte array for NAN messaging.
|
* @return A positive integer, maximum length of byte array for Aware messaging.
|
||||||
*/
|
*/
|
||||||
public int getMaxServiceSpecificInfoLength() {
|
public int getMaxServiceSpecificInfoLength() {
|
||||||
return mCharacteristics.getInt(KEY_MAX_SERVICE_SPECIFIC_INFO_LENGTH);
|
return mCharacteristics.getInt(KEY_MAX_SERVICE_SPECIFIC_INFO_LENGTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the maximum length of byte array that can be used to specify a NAN match filter.
|
* Returns the maximum length of byte array that can be used to specify a Aware match filter.
|
||||||
* Restricts the parameters of the {@link PublishConfig.Builder#setMatchFilter(byte[])} and
|
* Restricts the parameters of the {@link PublishConfig.Builder#setMatchFilter(byte[])} and
|
||||||
* {@link SubscribeConfig.Builder#setMatchFilter(byte[])}.
|
* {@link SubscribeConfig.Builder#setMatchFilter(byte[])}.
|
||||||
*
|
*
|
||||||
* @return A positive integer, maximum legngth of byte array for NAN discovery match filter.
|
* @return A positive integer, maximum legngth of byte array for Aware discovery match filter.
|
||||||
*/
|
*/
|
||||||
public int getMaxMatchFilterLength() {
|
public int getMaxMatchFilterLength() {
|
||||||
return mCharacteristics.getInt(KEY_MAX_MATCH_FILTER_LENGTH);
|
return mCharacteristics.getInt(KEY_MAX_MATCH_FILTER_LENGTH);
|
||||||
@@ -87,17 +87,17 @@ public class WifiNanCharacteristics implements Parcelable {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Creator<WifiNanCharacteristics> CREATOR =
|
public static final Creator<WifiAwareCharacteristics> CREATOR =
|
||||||
new Creator<WifiNanCharacteristics>() {
|
new Creator<WifiAwareCharacteristics>() {
|
||||||
@Override
|
@Override
|
||||||
public WifiNanCharacteristics createFromParcel(Parcel in) {
|
public WifiAwareCharacteristics createFromParcel(Parcel in) {
|
||||||
WifiNanCharacteristics c = new WifiNanCharacteristics(in.readBundle());
|
WifiAwareCharacteristics c = new WifiAwareCharacteristics(in.readBundle());
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WifiNanCharacteristics[] newArray(int size) {
|
public WifiAwareCharacteristics[] newArray(int size) {
|
||||||
return new WifiNanCharacteristics[size];
|
return new WifiAwareCharacteristics[size];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package android.net.wifi.nan;
|
package android.net.wifi.aware;
|
||||||
|
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
@@ -27,30 +27,30 @@ import dalvik.system.CloseGuard;
|
|||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A class representing a single publish or subscribe NAN session. This object
|
* A class representing a single publish or subscribe Aware session. This object
|
||||||
* will not be created directly - only its child classes are available:
|
* will not be created directly - only its child classes are available:
|
||||||
* {@link WifiNanPublishDiscoverySession} and {@link WifiNanSubscribeDiscoverySession}. This
|
* {@link WifiAwarePublishDiscoverySession} and {@link WifiAwareSubscribeDiscoverySession}. This
|
||||||
* class provides functionality common to both publish and subscribe discovery sessions:
|
* class provides functionality common to both publish and subscribe discovery sessions:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>Sending messages: {@link #sendMessage(Object, int, byte[])} or
|
* <li>Sending messages: {@link #sendMessage(Object, int, byte[])} or
|
||||||
* {@link #sendMessage(Object, int, byte[], int)} methods.
|
* {@link #sendMessage(Object, int, byte[], int)} methods.
|
||||||
* <li>Creating a network-specifier when requesting a NAN connection:
|
* <li>Creating a network-specifier when requesting a Aware connection:
|
||||||
* {@link #createNetworkSpecifier(int, Object, byte[])}.
|
* {@link #createNetworkSpecifier(int, Object, byte[])}.
|
||||||
* </ul>
|
* </ul>
|
||||||
* The {@link #destroy()} method must be called to destroy discovery sessions once they are
|
* The {@link #destroy()} method must be called to destroy discovery sessions once they are
|
||||||
* no longer needed.
|
* no longer needed.
|
||||||
*
|
*
|
||||||
* @hide PROPOSED_NAN_API
|
* @hide PROPOSED_AWARE_API
|
||||||
*/
|
*/
|
||||||
public class WifiNanDiscoveryBaseSession {
|
public class WifiAwareDiscoveryBaseSession {
|
||||||
private static final String TAG = "WifiNanDiscoveryBaseSsn";
|
private static final String TAG = "WifiAwareDiscBaseSsn";
|
||||||
private static final boolean DBG = false;
|
private static final boolean DBG = false;
|
||||||
private static final boolean VDBG = false; // STOPSHIP if true
|
private static final boolean VDBG = false; // STOPSHIP if true
|
||||||
|
|
||||||
private static final int MAX_SEND_RETRY_COUNT = 5;
|
private static final int MAX_SEND_RETRY_COUNT = 5;
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
protected WeakReference<WifiNanManager> mMgr;
|
protected WeakReference<WifiAwareManager> mMgr;
|
||||||
/** @hide */
|
/** @hide */
|
||||||
protected final int mClientId;
|
protected final int mClientId;
|
||||||
/** @hide */
|
/** @hide */
|
||||||
@@ -71,7 +71,7 @@ public class WifiNanDiscoveryBaseSession {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
public WifiNanDiscoveryBaseSession(WifiNanManager manager, int clientId, int sessionId) {
|
public WifiAwareDiscoveryBaseSession(WifiAwareManager manager, int clientId, int sessionId) {
|
||||||
if (VDBG) {
|
if (VDBG) {
|
||||||
Log.v(TAG, "New discovery session created: manager=" + manager + ", clientId="
|
Log.v(TAG, "New discovery session created: manager=" + manager + ", clientId="
|
||||||
+ clientId + ", sessionId=" + sessionId);
|
+ clientId + ", sessionId=" + sessionId);
|
||||||
@@ -93,12 +93,12 @@ public class WifiNanDiscoveryBaseSession {
|
|||||||
* This operation must be done on a session which is no longer needed. Otherwise system
|
* This operation must be done on a session which is no longer needed. Otherwise system
|
||||||
* resources will continue to be utilized until the application exits. The only
|
* resources will continue to be utilized until the application exits. The only
|
||||||
* exception is a session for which we received a termination callback,
|
* exception is a session for which we received a termination callback,
|
||||||
* {@link WifiNanDiscoverySessionCallback#onSessionTerminated(int)}.
|
* {@link WifiAwareDiscoverySessionCallback#onSessionTerminated(int)}.
|
||||||
*/
|
*/
|
||||||
public void destroy() {
|
public void destroy() {
|
||||||
WifiNanManager mgr = mMgr.get();
|
WifiAwareManager mgr = mMgr.get();
|
||||||
if (mgr == null) {
|
if (mgr == null) {
|
||||||
Log.w(TAG, "destroy: called post GC on WifiNanManager");
|
Log.w(TAG, "destroy: called post GC on WifiAwareManager");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mgr.terminateSession(mClientId, mSessionId);
|
mgr.terminateSession(mClientId, mSessionId);
|
||||||
@@ -137,26 +137,26 @@ public class WifiNanDiscoveryBaseSession {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends a message to the specified destination. NAN messages are transmitted in the context
|
* Sends a message to the specified destination. Aware messages are transmitted in the context
|
||||||
* of a discovery session - executed subsequent to a publish/subscribe
|
* of a discovery session - executed subsequent to a publish/subscribe
|
||||||
* {@link WifiNanDiscoverySessionCallback#onServiceDiscovered(Object, byte[], byte[])} event.
|
* {@link WifiAwareDiscoverySessionCallback#onServiceDiscovered(Object, byte[], byte[])} event.
|
||||||
* <p>
|
* <p>
|
||||||
* NAN messages are not guaranteed delivery. Callbacks on
|
* Aware messages are not guaranteed delivery. Callbacks on
|
||||||
* {@link WifiNanDiscoverySessionCallback} indicate message was transmitted successfully,
|
* {@link WifiAwareDiscoverySessionCallback} indicate message was transmitted successfully,
|
||||||
* {@link WifiNanDiscoverySessionCallback#onMessageSent(int)}, or transmission failed
|
* {@link WifiAwareDiscoverySessionCallback#onMessageSent(int)}, or transmission failed
|
||||||
* (possibly after several retries) -
|
* (possibly after several retries) -
|
||||||
* {@link WifiNanDiscoverySessionCallback#onMessageSendFailed(int)}.
|
* {@link WifiAwareDiscoverySessionCallback#onMessageSendFailed(int)}.
|
||||||
* <p>
|
* <p>
|
||||||
* The peer will get a callback indicating a message was received using
|
* The peer will get a callback indicating a message was received using
|
||||||
* {@link WifiNanDiscoverySessionCallback#onMessageReceived(Object, byte[])}.
|
* {@link WifiAwareDiscoverySessionCallback#onMessageReceived(Object, byte[])}.
|
||||||
*
|
*
|
||||||
* @param peerHandle The peer's handle for the message. Must be a result of an
|
* @param peerHandle The peer's handle for the message. Must be a result of an
|
||||||
* {@link WifiNanDiscoverySessionCallback#onServiceDiscovered(Object, byte[], byte[])}
|
* {@link WifiAwareDiscoverySessionCallback#onServiceDiscovered(Object, byte[], byte[])}
|
||||||
* or
|
* or
|
||||||
* {@link WifiNanDiscoverySessionCallback#onMessageReceived(Object, byte[])} events.
|
* {@link WifiAwareDiscoverySessionCallback#onMessageReceived(Object, byte[])} events.
|
||||||
* @param messageId An arbitrary integer used by the caller to identify the message. The same
|
* @param messageId An arbitrary integer used by the caller to identify the message. The same
|
||||||
* integer ID will be returned in the callbacks indicating message send success or
|
* integer ID will be returned in the callbacks indicating message send success or
|
||||||
* failure. The {@code messageId} is not used internally by the NAN service - it
|
* failure. The {@code messageId} is not used internally by the Aware service - it
|
||||||
* can be arbitrary and non-unique.
|
* can be arbitrary and non-unique.
|
||||||
* @param message The message to be transmitted.
|
* @param message The message to be transmitted.
|
||||||
* @param retryCount An integer specifying how many additional service-level (as opposed to PHY
|
* @param retryCount An integer specifying how many additional service-level (as opposed to PHY
|
||||||
@@ -170,9 +170,9 @@ public class WifiNanDiscoveryBaseSession {
|
|||||||
Log.w(TAG, "sendMessage: called on terminated session");
|
Log.w(TAG, "sendMessage: called on terminated session");
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
WifiNanManager mgr = mMgr.get();
|
WifiAwareManager mgr = mMgr.get();
|
||||||
if (mgr == null) {
|
if (mgr == null) {
|
||||||
Log.w(TAG, "sendMessage: called post GC on WifiNanManager");
|
Log.w(TAG, "sendMessage: called post GC on WifiAwareManager");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -181,28 +181,28 @@ public class WifiNanDiscoveryBaseSession {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends a message to the specified destination. NAN messages are transmitted in the context
|
* Sends a message to the specified destination. Aware messages are transmitted in the context
|
||||||
* of a discovery session - executed subsequent to a publish/subscribe
|
* of a discovery session - executed subsequent to a publish/subscribe
|
||||||
* {@link WifiNanDiscoverySessionCallback#onServiceDiscovered(Object, byte[], byte[])} event.
|
* {@link WifiAwareDiscoverySessionCallback#onServiceDiscovered(Object, byte[], byte[])} event.
|
||||||
* <p>
|
* <p>
|
||||||
* NAN messages are not guaranteed delivery. Callbacks on
|
* Aware messages are not guaranteed delivery. Callbacks on
|
||||||
* {@link WifiNanDiscoverySessionCallback} indicate message was transmitted successfully,
|
* {@link WifiAwareDiscoverySessionCallback} indicate message was transmitted successfully,
|
||||||
* {@link WifiNanDiscoverySessionCallback#onMessageSent(int)}, or transmission failed
|
* {@link WifiAwareDiscoverySessionCallback#onMessageSent(int)}, or transmission failed
|
||||||
* (possibly after several retries) -
|
* (possibly after several retries) -
|
||||||
* {@link WifiNanDiscoverySessionCallback#onMessageSendFailed(int)}.
|
* {@link WifiAwareDiscoverySessionCallback#onMessageSendFailed(int)}.
|
||||||
* <p>
|
* <p>
|
||||||
* The peer will get a callback indicating a message was received using
|
* The peer will get a callback indicating a message was received using
|
||||||
* {@link WifiNanDiscoverySessionCallback#onMessageReceived(Object, byte[])}.
|
* {@link WifiAwareDiscoverySessionCallback#onMessageReceived(Object, byte[])}.
|
||||||
* Equivalent to {@link #sendMessage(Object, int, byte[], int)} with a {@code retryCount} of
|
* Equivalent to {@link #sendMessage(Object, int, byte[], int)} with a {@code retryCount} of
|
||||||
* 0.
|
* 0.
|
||||||
*
|
*
|
||||||
* @param peerHandle The peer's handle for the message. Must be a result of an
|
* @param peerHandle The peer's handle for the message. Must be a result of an
|
||||||
* {@link WifiNanDiscoverySessionCallback#onServiceDiscovered(Object, byte[], byte[])}
|
* {@link WifiAwareDiscoverySessionCallback#onServiceDiscovered(Object, byte[], byte[])}
|
||||||
* or
|
* or
|
||||||
* {@link WifiNanDiscoverySessionCallback#onMessageReceived(Object, byte[])} events.
|
* {@link WifiAwareDiscoverySessionCallback#onMessageReceived(Object, byte[])} events.
|
||||||
* @param messageId An arbitrary integer used by the caller to identify the message. The same
|
* @param messageId An arbitrary integer used by the caller to identify the message. The same
|
||||||
* integer ID will be returned in the callbacks indicating message send success or
|
* integer ID will be returned in the callbacks indicating message send success or
|
||||||
* failure. The {@code messageId} is not used internally by the NAN service - it
|
* failure. The {@code messageId} is not used internally by the Aware service - it
|
||||||
* can be arbitrary and non-unique.
|
* can be arbitrary and non-unique.
|
||||||
* @param message The message to be transmitted.
|
* @param message The message to be transmitted.
|
||||||
*/
|
*/
|
||||||
@@ -212,8 +212,8 @@ public class WifiNanDiscoveryBaseSession {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Start a ranging operation with the specified peers. The peer IDs are obtained from an
|
* Start a ranging operation with the specified peers. The peer IDs are obtained from an
|
||||||
* {@link WifiNanDiscoverySessionCallback#onServiceDiscovered(Object, byte[], byte[])} or
|
* {@link WifiAwareDiscoverySessionCallback#onServiceDiscovered(Object, byte[], byte[])} or
|
||||||
* {@link WifiNanDiscoverySessionCallback#onMessageReceived(Object, byte[])} operation - can
|
* {@link WifiAwareDiscoverySessionCallback#onMessageReceived(Object, byte[])} operation - can
|
||||||
* only range devices which are part of an ongoing discovery session.
|
* only range devices which are part of an ongoing discovery session.
|
||||||
*
|
*
|
||||||
* @param params RTT parameters - each corresponding to a specific peer ID (the array sizes
|
* @param params RTT parameters - each corresponding to a specific peer ID (the array sizes
|
||||||
@@ -221,16 +221,17 @@ public class WifiNanDiscoveryBaseSession {
|
|||||||
* {@link android.net.wifi.RttManager.RttParams#bssid} member must be set to
|
* {@link android.net.wifi.RttManager.RttParams#bssid} member must be set to
|
||||||
* a peer ID - not to a MAC address.
|
* a peer ID - not to a MAC address.
|
||||||
* @param listener The listener to receive the results of the ranging session.
|
* @param listener The listener to receive the results of the ranging session.
|
||||||
* @hide PROPOSED_NAN_SYSTEM_API [TODO: b/28847998 - track RTT API & visilibity]
|
* @hide PROPOSED_AWARE_SYSTEM_API
|
||||||
|
* [TODO: b/28847998 - track RTT API & visilibity]
|
||||||
*/
|
*/
|
||||||
public void startRanging(RttManager.RttParams[] params, RttManager.RttListener listener) {
|
public void startRanging(RttManager.RttParams[] params, RttManager.RttListener listener) {
|
||||||
if (mTerminated) {
|
if (mTerminated) {
|
||||||
Log.w(TAG, "startRanging: called on terminated session");
|
Log.w(TAG, "startRanging: called on terminated session");
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
WifiNanManager mgr = mMgr.get();
|
WifiAwareManager mgr = mMgr.get();
|
||||||
if (mgr == null) {
|
if (mgr == null) {
|
||||||
Log.w(TAG, "startRanging: called post GC on WifiNanManager");
|
Log.w(TAG, "startRanging: called post GC on WifiAwareManager");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,23 +241,23 @@ public class WifiNanDiscoveryBaseSession {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a {@link android.net.NetworkRequest.Builder#setNetworkSpecifier(String)} for a
|
* Create a {@link android.net.NetworkRequest.Builder#setNetworkSpecifier(String)} for a
|
||||||
* WiFi NAN connection to the specified peer. The
|
* WiFi Aware connection to the specified peer. The
|
||||||
* {@link android.net.NetworkRequest.Builder#addTransportType(int)} should be set to
|
* {@link android.net.NetworkRequest.Builder#addTransportType(int)} should be set to
|
||||||
* {@link android.net.NetworkCapabilities#TRANSPORT_WIFI_NAN}.
|
* {@link android.net.NetworkCapabilities#TRANSPORT_WIFI_AWARE}.
|
||||||
* <p>
|
* <p>
|
||||||
* This method should be used when setting up a connection with a peer discovered through NAN
|
* This method should be used when setting up a connection with a peer discovered through Aware
|
||||||
* discovery or communication (in such scenarios the MAC address of the peer is shielded by
|
* discovery or communication (in such scenarios the MAC address of the peer is shielded by
|
||||||
* an opaque peer ID handle). If a NAN connection is needed to a peer discovered using other
|
* an opaque peer ID handle). If a Aware connection is needed to a peer discovered using other
|
||||||
* OOB (out-of-band) mechanism then use the alternative
|
* OOB (out-of-band) mechanism then use the alternative
|
||||||
* {@link WifiNanSession#createNetworkSpecifier(int, byte[], byte[])} method - which uses the
|
* {@link WifiAwareSession#createNetworkSpecifier(int, byte[], byte[])} method - which uses the
|
||||||
* peer's MAC address.
|
* peer's MAC address.
|
||||||
*
|
*
|
||||||
* @param role The role of this device:
|
* @param role The role of this device:
|
||||||
* {@link WifiNanManager#WIFI_NAN_DATA_PATH_ROLE_INITIATOR} or
|
* {@link WifiAwareManager#WIFI_AWARE_DATA_PATH_ROLE_INITIATOR} or
|
||||||
* {@link WifiNanManager#WIFI_NAN_DATA_PATH_ROLE_RESPONDER}
|
* {@link WifiAwareManager#WIFI_AWARE_DATA_PATH_ROLE_RESPONDER}
|
||||||
* @param peerHandle The peer's handle obtained through
|
* @param peerHandle The peer's handle obtained through
|
||||||
* {@link WifiNanDiscoverySessionCallback#onServiceDiscovered(Object, byte[], byte[])} or
|
* {@link WifiAwareDiscoverySessionCallback#onServiceDiscovered(Object, byte[], byte[])} or
|
||||||
* {@link WifiNanDiscoverySessionCallback#onMessageReceived(Object, byte[])}. On a RESPONDER
|
* {@link WifiAwareDiscoverySessionCallback#onMessageReceived(Object, byte[])}. On a RESPONDER
|
||||||
* this value is used to gate the acceptance of a connection request from only
|
* this value is used to gate the acceptance of a connection request from only
|
||||||
* that peer. A RESPONDER may specified a null - indicating that it will accept
|
* that peer. A RESPONDER may specified a null - indicating that it will accept
|
||||||
* connection requests from any device.
|
* connection requests from any device.
|
||||||
@@ -268,18 +269,19 @@ public class WifiNanDiscoveryBaseSession {
|
|||||||
*
|
*
|
||||||
* @return A string to be used to construct
|
* @return A string to be used to construct
|
||||||
* {@link android.net.NetworkRequest.Builder#setNetworkSpecifier(String)} to pass to
|
* {@link android.net.NetworkRequest.Builder#setNetworkSpecifier(String)} to pass to
|
||||||
* {@link android.net.ConnectivityManager#requestNetwork(android.net.NetworkRequest,android.net.ConnectivityManager.NetworkCallback)}
|
* {@link android.net.ConnectivityManager#requestNetwork(android.net.NetworkRequest,
|
||||||
|
* android.net.ConnectivityManager.NetworkCallback)}
|
||||||
* [or other varieties of that API].
|
* [or other varieties of that API].
|
||||||
*/
|
*/
|
||||||
public String createNetworkSpecifier(@WifiNanManager.DataPathRole int role,
|
public String createNetworkSpecifier(@WifiAwareManager.DataPathRole int role,
|
||||||
@Nullable Object peerHandle, @Nullable byte[] token) {
|
@Nullable Object peerHandle, @Nullable byte[] token) {
|
||||||
if (mTerminated) {
|
if (mTerminated) {
|
||||||
Log.w(TAG, "createNetworkSpecifier: called on terminated session");
|
Log.w(TAG, "createNetworkSpecifier: called on terminated session");
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
WifiNanManager mgr = mMgr.get();
|
WifiAwareManager mgr = mMgr.get();
|
||||||
if (mgr == null) {
|
if (mgr == null) {
|
||||||
Log.w(TAG, "createNetworkSpecifier: called post GC on WifiNanManager");
|
Log.w(TAG, "createNetworkSpecifier: called post GC on WifiAwareManager");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package android.net.wifi.nan;
|
package android.net.wifi.aware;
|
||||||
|
|
||||||
import android.annotation.IntDef;
|
import android.annotation.IntDef;
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
@@ -23,18 +23,20 @@ import java.lang.annotation.Retention;
|
|||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for NAN session events callbacks. Should be extended by
|
* Base class for Aware session events callbacks. Should be extended by
|
||||||
* applications wanting notifications. The callbacks are set when a
|
* applications wanting notifications. The callbacks are set when a
|
||||||
* publish or subscribe session is created using
|
* publish or subscribe session is created using
|
||||||
* {@link WifiNanSession#publish(android.os.Handler, PublishConfig, WifiNanDiscoverySessionCallback)}
|
* {@link WifiAwareSession#publish(android.os.Handler, PublishConfig,
|
||||||
|
* WifiAwareDiscoverySessionCallback)}
|
||||||
* or
|
* or
|
||||||
* {@link WifiNanSession#subscribe(android.os.Handler, SubscribeConfig, WifiNanDiscoverySessionCallback)} .
|
* {@link WifiAwareSession#subscribe(android.os.Handler, SubscribeConfig,
|
||||||
|
* WifiAwareDiscoverySessionCallback)} .
|
||||||
* <p>
|
* <p>
|
||||||
* A single callback is set at session creation - it cannot be replaced.
|
* A single callback is set at session creation - it cannot be replaced.
|
||||||
*
|
*
|
||||||
* @hide PROPOSED_NAN_API
|
* @hide PROPOSED_AWARE_API
|
||||||
*/
|
*/
|
||||||
public class WifiNanDiscoverySessionCallback {
|
public class WifiAwareDiscoverySessionCallback {
|
||||||
/** @hide */
|
/** @hide */
|
||||||
@IntDef({
|
@IntDef({
|
||||||
TERMINATE_REASON_DONE, TERMINATE_REASON_FAIL })
|
TERMINATE_REASON_DONE, TERMINATE_REASON_FAIL })
|
||||||
@@ -46,7 +48,7 @@ public class WifiNanDiscoverySessionCallback {
|
|||||||
* Indicates that publish or subscribe session is done - all the
|
* Indicates that publish or subscribe session is done - all the
|
||||||
* requested operations (per {@link PublishConfig} or
|
* requested operations (per {@link PublishConfig} or
|
||||||
* {@link SubscribeConfig}) have been executed. Failure reason flag for
|
* {@link SubscribeConfig}) have been executed. Failure reason flag for
|
||||||
* {@link WifiNanDiscoverySessionCallback#onSessionTerminated(int)} callback.
|
* {@link WifiAwareDiscoverySessionCallback#onSessionTerminated(int)} callback.
|
||||||
*/
|
*/
|
||||||
public static final int TERMINATE_REASON_DONE = 100;
|
public static final int TERMINATE_REASON_DONE = 100;
|
||||||
|
|
||||||
@@ -54,39 +56,41 @@ public class WifiNanDiscoverySessionCallback {
|
|||||||
* Indicates that publish or subscribe session is terminated due to a
|
* Indicates that publish or subscribe session is terminated due to a
|
||||||
* failure.
|
* failure.
|
||||||
* Failure reason flag for
|
* Failure reason flag for
|
||||||
* {@link WifiNanDiscoverySessionCallback#onSessionTerminated(int)} callback.
|
* {@link WifiAwareDiscoverySessionCallback#onSessionTerminated(int)} callback.
|
||||||
*/
|
*/
|
||||||
public static final int TERMINATE_REASON_FAIL = 101;
|
public static final int TERMINATE_REASON_FAIL = 101;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a publish operation is started successfully in response to a
|
* Called when a publish operation is started successfully in response to a
|
||||||
* {@link WifiNanSession#publish(android.os.Handler, PublishConfig, WifiNanDiscoverySessionCallback)}
|
* {@link WifiAwareSession#publish(android.os.Handler, PublishConfig,
|
||||||
|
* WifiAwareDiscoverySessionCallback)}
|
||||||
* operation.
|
* operation.
|
||||||
*
|
*
|
||||||
* @param session The {@link WifiNanPublishDiscoverySession} used to control the
|
* @param session The {@link WifiAwarePublishDiscoverySession} used to control the
|
||||||
* discovery session.
|
* discovery session.
|
||||||
*/
|
*/
|
||||||
public void onPublishStarted(@NonNull WifiNanPublishDiscoverySession session) {
|
public void onPublishStarted(@NonNull WifiAwarePublishDiscoverySession session) {
|
||||||
/* empty */
|
/* empty */
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a subscribe operation is started successfully in response to a
|
* Called when a subscribe operation is started successfully in response to a
|
||||||
* {@link WifiNanSession#subscribe(android.os.Handler, SubscribeConfig, WifiNanDiscoverySessionCallback)}
|
* {@link WifiAwareSession#subscribe(android.os.Handler, SubscribeConfig,
|
||||||
|
* WifiAwareDiscoverySessionCallback)}
|
||||||
* operation.
|
* operation.
|
||||||
*
|
*
|
||||||
* @param session The {@link WifiNanSubscribeDiscoverySession} used to control the
|
* @param session The {@link WifiAwareSubscribeDiscoverySession} used to control the
|
||||||
* discovery session.
|
* discovery session.
|
||||||
*/
|
*/
|
||||||
public void onSubscribeStarted(@NonNull WifiNanSubscribeDiscoverySession session) {
|
public void onSubscribeStarted(@NonNull WifiAwareSubscribeDiscoverySession session) {
|
||||||
/* empty */
|
/* empty */
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a publish or subscribe discovery session configuration update request
|
* Called when a publish or subscribe discovery session configuration update request
|
||||||
* succeeds. Called in response to
|
* succeeds. Called in response to
|
||||||
* {@link WifiNanPublishDiscoverySession#updatePublish(PublishConfig)} or
|
* {@link WifiAwarePublishDiscoverySession#updatePublish(PublishConfig)} or
|
||||||
* {@link WifiNanSubscribeDiscoverySession#updateSubscribe(SubscribeConfig)}.
|
* {@link WifiAwareSubscribeDiscoverySession#updateSubscribe(SubscribeConfig)}.
|
||||||
*/
|
*/
|
||||||
public void onSessionConfigUpdated() {
|
public void onSessionConfigUpdated() {
|
||||||
/* empty */
|
/* empty */
|
||||||
@@ -94,12 +98,14 @@ public class WifiNanDiscoverySessionCallback {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a publish or subscribe discovery session cannot be created:
|
* Called when a publish or subscribe discovery session cannot be created:
|
||||||
* {@link WifiNanSession#publish(android.os.Handler, PublishConfig, WifiNanDiscoverySessionCallback)}
|
* {@link WifiAwareSession#publish(android.os.Handler, PublishConfig,
|
||||||
|
* WifiAwareDiscoverySessionCallback)}
|
||||||
* or
|
* or
|
||||||
* {@link WifiNanSession#subscribe(android.os.Handler, SubscribeConfig, WifiNanDiscoverySessionCallback)},
|
* {@link WifiAwareSession#subscribe(android.os.Handler, SubscribeConfig,
|
||||||
|
* WifiAwareDiscoverySessionCallback)},
|
||||||
* or when a configuration update fails:
|
* or when a configuration update fails:
|
||||||
* {@link WifiNanPublishDiscoverySession#updatePublish(PublishConfig)} or
|
* {@link WifiAwarePublishDiscoverySession#updatePublish(PublishConfig)} or
|
||||||
* {@link WifiNanSubscribeDiscoverySession#updateSubscribe(SubscribeConfig)}.
|
* {@link WifiAwareSubscribeDiscoverySession#updateSubscribe(SubscribeConfig)}.
|
||||||
* <p>
|
* <p>
|
||||||
* For discovery session updates failure leaves the session running with its previous
|
* For discovery session updates failure leaves the session running with its previous
|
||||||
* configuration - the discovery session is not terminated.
|
* configuration - the discovery session is not terminated.
|
||||||
@@ -110,12 +116,12 @@ public class WifiNanDiscoverySessionCallback {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a discovery session (publish or subscribe) terminates. Termination may be due
|
* Called when a discovery session (publish or subscribe) terminates. Termination may be due
|
||||||
* to user-request (either directly through {@link WifiNanDiscoveryBaseSession#destroy()} or
|
* to user-request (either directly through {@link WifiAwareDiscoveryBaseSession#destroy()} or
|
||||||
* application-specified expiration, e.g. {@link PublishConfig.Builder#setPublishCount(int)}
|
* application-specified expiration, e.g. {@link PublishConfig.Builder#setPublishCount(int)}
|
||||||
* or {@link SubscribeConfig.Builder#setTtlSec(int)}) or due to a failure.
|
* or {@link SubscribeConfig.Builder#setTtlSec(int)}) or due to a failure.
|
||||||
*
|
*
|
||||||
* @param reason The termination reason using
|
* @param reason The termination reason using
|
||||||
* {@code WifiNanDiscoverySessionCallback.TERMINATE_*} codes.
|
* {@code WifiAwareDiscoverySessionCallback.TERMINATE_*} codes.
|
||||||
*/
|
*/
|
||||||
public void onSessionTerminated(@SessionTerminateCodes int reason) {
|
public void onSessionTerminated(@SessionTerminateCodes int reason) {
|
||||||
/* empty */
|
/* empty */
|
||||||
@@ -138,12 +144,12 @@ public class WifiNanDiscoverySessionCallback {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called in response to {@link WifiNanDiscoveryBaseSession#sendMessage(Object, int, byte[])}
|
* Called in response to {@link WifiAwareDiscoveryBaseSession#sendMessage(Object, int, byte[])}
|
||||||
* when a message is transmitted successfully - i.e. when it was received successfully by the
|
* when a message is transmitted successfully - i.e. when it was received successfully by the
|
||||||
* peer (corresponds to an ACK being received).
|
* peer (corresponds to an ACK being received).
|
||||||
* <p>
|
* <p>
|
||||||
* Note that either this callback or
|
* Note that either this callback or
|
||||||
* {@link WifiNanDiscoverySessionCallback#onMessageSendFailed(int)} will be
|
* {@link WifiAwareDiscoverySessionCallback#onMessageSendFailed(int)} will be
|
||||||
* received - never both.
|
* received - never both.
|
||||||
*
|
*
|
||||||
* @param messageId The arbitrary message ID specified when sending the message.
|
* @param messageId The arbitrary message ID specified when sending the message.
|
||||||
@@ -154,12 +160,12 @@ public class WifiNanDiscoverySessionCallback {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when message transmission fails - when no ACK is received from the peer.
|
* Called when message transmission fails - when no ACK is received from the peer.
|
||||||
* Retries when ACKs are not received are done by hardware, MAC, and in the NAN stack (using
|
* Retries when ACKs are not received are done by hardware, MAC, and in the Aware stack (using
|
||||||
* the {@link WifiNanDiscoveryBaseSession#sendMessage(Object, int, byte[], int)} method) - this
|
* the {@link WifiAwareDiscoveryBaseSession#sendMessage(Object, int, byte[], int)} method) -
|
||||||
* event is received after all retries are exhausted.
|
* this event is received after all retries are exhausted.
|
||||||
* <p>
|
* <p>
|
||||||
* Note that either this callback or
|
* Note that either this callback or
|
||||||
* {@link WifiNanDiscoverySessionCallback#onMessageSent(int)} will be received
|
* {@link WifiAwareDiscoverySessionCallback#onMessageSent(int)} will be received
|
||||||
* - never both.
|
* - never both.
|
||||||
*
|
*
|
||||||
* @param messageId The arbitrary message ID specified when sending the message.
|
* @param messageId The arbitrary message ID specified when sending the message.
|
||||||
@@ -170,8 +176,8 @@ public class WifiNanDiscoverySessionCallback {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a message is received from a discovery session peer - in response to the
|
* Called when a message is received from a discovery session peer - in response to the
|
||||||
* peer's {@link WifiNanDiscoveryBaseSession#sendMessage(Object, int, byte[])} or
|
* peer's {@link WifiAwareDiscoveryBaseSession#sendMessage(Object, int, byte[])} or
|
||||||
* {@link WifiNanDiscoveryBaseSession#sendMessage(Object, int, byte[], int)}.
|
* {@link WifiAwareDiscoveryBaseSession#sendMessage(Object, int, byte[], int)}.
|
||||||
*
|
*
|
||||||
* @param peerHandle An opaque handle to the peer matching our discovery operation.
|
* @param peerHandle An opaque handle to the peer matching our discovery operation.
|
||||||
* @param message A byte array containing the message.
|
* @param message A byte array containing the message.
|
||||||
@@ -14,23 +14,23 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package android.net.wifi.nan;
|
package android.net.wifi.aware;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for a listener which is called with the MAC address of the NAN interface whenever
|
* Base class for a listener which is called with the MAC address of the Aware interface whenever
|
||||||
* it is changed. Change may be due to device joining a cluster, starting a cluster, or discovery
|
* it is changed. Change may be due to device joining a cluster, starting a cluster, or discovery
|
||||||
* interface change (addresses are randomized at regular intervals). The implication is that
|
* interface change (addresses are randomized at regular intervals). The implication is that
|
||||||
* peers you've been communicating with may no longer recognize you and you need to re-establish
|
* peers you've been communicating with may no longer recognize you and you need to re-establish
|
||||||
* your identity - e.g. by starting a discovery session. This actual MAC address of the
|
* your identity - e.g. by starting a discovery session. This actual MAC address of the
|
||||||
* interface may also be useful if the application uses alternative (non-NAN) discovery but needs
|
* interface may also be useful if the application uses alternative (non-Aware) discovery but needs
|
||||||
* to set up a NAN connection. The provided NAN discovery interface MAC address can then be used
|
* to set up a Aware connection. The provided Aware discovery interface MAC address can then be used
|
||||||
* in {@link WifiNanSession#createNetworkSpecifier(int, byte[], byte[])}.
|
* in {@link WifiAwareSession#createNetworkSpecifier(int, byte[], byte[])}.
|
||||||
*
|
*
|
||||||
* @hide PROPOSED_NAN_API
|
* @hide PROPOSED_AWARE_API
|
||||||
*/
|
*/
|
||||||
public class WifiNanIdentityChangedListener {
|
public class WifiAwareIdentityChangedListener {
|
||||||
/**
|
/**
|
||||||
* @param mac The MAC address of the NAN discovery interface. The application must have the
|
* @param mac The MAC address of the Aware discovery interface. The application must have the
|
||||||
* {@link android.Manifest.permission#ACCESS_COARSE_LOCATION} to get the actual MAC address,
|
* {@link android.Manifest.permission#ACCESS_COARSE_LOCATION} to get the actual MAC address,
|
||||||
* otherwise all 0's will be provided.
|
* otherwise all 0's will be provided.
|
||||||
*/
|
*/
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package android.net.wifi.nan;
|
package android.net.wifi.aware;
|
||||||
|
|
||||||
import android.annotation.IntDef;
|
import android.annotation.IntDef;
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
@@ -48,80 +48,86 @@ import java.lang.ref.WeakReference;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class provides the primary API for managing Wi-Fi NAN operations:
|
* This class provides the primary API for managing Wi-Fi Aware operations:
|
||||||
* discovery and peer-to-peer data connections. Get an instance of this class by calling
|
* discovery and peer-to-peer data connections. Get an instance of this class by calling
|
||||||
* {@link android.content.Context#getSystemService(String)
|
* {@link android.content.Context#getSystemService(String)
|
||||||
* Context.getSystemService(Context.WIFI_NAN_SERVICE)}.
|
* Context.getSystemService(Context.WIFI_AWARE_SERVICE)}.
|
||||||
* <p>
|
* <p>
|
||||||
* The class provides access to:
|
* The class provides access to:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>Initialize a NAN cluster (peer-to-peer synchronization). Refer to
|
* <li>Initialize a Aware cluster (peer-to-peer synchronization). Refer to
|
||||||
* {@link #attach(Handler, WifiNanAttachCallback)}.
|
* {@link #attach(Handler, WifiAwareAttachCallback)}.
|
||||||
* <li>Create discovery sessions (publish or subscribe sessions). Refer to
|
* <li>Create discovery sessions (publish or subscribe sessions). Refer to
|
||||||
* {@link WifiNanSession#publish(Handler, PublishConfig, WifiNanDiscoverySessionCallback)} and
|
* {@link WifiAwareSession#publish(Handler, PublishConfig, WifiAwareDiscoverySessionCallback)} and
|
||||||
* {@link WifiNanSession#subscribe(Handler, SubscribeConfig, WifiNanDiscoverySessionCallback)}.
|
* {@link WifiAwareSession#subscribe(Handler, SubscribeConfig, WifiAwareDiscoverySessionCallback)}.
|
||||||
* <li>Create a NAN network specifier to be used with
|
* <li>Create a Aware network specifier to be used with
|
||||||
* {@link ConnectivityManager#requestNetwork(NetworkRequest, ConnectivityManager.NetworkCallback)}
|
* {@link ConnectivityManager#requestNetwork(NetworkRequest, ConnectivityManager.NetworkCallback)}
|
||||||
* to set-up a NAN connection with a peer. Refer to
|
* to set-up a Aware connection with a peer. Refer to
|
||||||
* {@link WifiNanDiscoveryBaseSession#createNetworkSpecifier(int, Object, byte[])} and
|
* {@link WifiAwareDiscoveryBaseSession#createNetworkSpecifier(int, Object, byte[])} and
|
||||||
* {@link WifiNanSession#createNetworkSpecifier(int, byte[], byte[])}.
|
* {@link WifiAwareSession#createNetworkSpecifier(int, byte[], byte[])}.
|
||||||
* </ul>
|
* </ul>
|
||||||
* <p>
|
* <p>
|
||||||
* NAN may not be usable when Wi-Fi is disabled (and other conditions). To validate that
|
* Aware may not be usable when Wi-Fi is disabled (and other conditions). To validate that
|
||||||
* the functionality is available use the {@link #isAvailable()} function. To track
|
* the functionality is available use the {@link #isAvailable()} function. To track
|
||||||
* changes in NAN usability register for the {@link #ACTION_WIFI_NAN_STATE_CHANGED} broadcast.
|
* changes in Aware usability register for the {@link #ACTION_WIFI_AWARE_STATE_CHANGED}
|
||||||
* Note that this broadcast is not sticky - you should register for it and then check the
|
* broadcast. Note that this broadcast is not sticky - you should register for it and then
|
||||||
* above API to avoid a race condition.
|
* check the above API to avoid a race condition.
|
||||||
* <p>
|
* <p>
|
||||||
* An application must use {@link #attach(Handler, WifiNanAttachCallback)} to initialize a NAN
|
* An application must use {@link #attach(Handler, WifiAwareAttachCallback)} to initialize a
|
||||||
* cluster - before making any other NAN operation. NAN cluster membership is a device-wide
|
* Aware cluster - before making any other Aware operation. Aware cluster membership is a
|
||||||
* operation - the API guarantees that the device is in a cluster or joins a NAN cluster (or
|
* device-wide operation - the API guarantees that the device is in a cluster or joins a
|
||||||
* starts one if none can be found). Information about attach success (or failure) are
|
* Aware cluster (or starts one if none can be found). Information about attach success (or
|
||||||
* returned in callbacks of {@link WifiNanAttachCallback}. Proceed with NAN discovery or
|
* failure) are returned in callbacks of {@link WifiAwareAttachCallback}. Proceed with Aware
|
||||||
* connection setup only after receiving confirmation that NAN attach succeeded -
|
* discovery or connection setup only after receiving confirmation that Aware attach
|
||||||
* {@link WifiNanAttachCallback#onAttached(WifiNanSession)}. When an application is
|
* succeeded - {@link WifiAwareAttachCallback#onAttached(WifiAwareSession)}. When an
|
||||||
* finished using NAN it <b>must</b> use the {@link WifiNanSession#destroy()} API
|
* application is finished using Aware it <b>must</b> use the
|
||||||
* to indicate to the NAN service that the device may detach from the NAN cluster. The
|
* {@link WifiAwareSession#destroy()} API to indicate to the Aware service that the device
|
||||||
* device will actually disable NAN once the last application detaches.
|
* may detach from the Aware cluster. The device will actually disable Aware once the last
|
||||||
|
* application detaches.
|
||||||
* <p>
|
* <p>
|
||||||
* Once a NAN attach is confirmed use the
|
* Once a Aware attach is confirmed use the
|
||||||
* {@link WifiNanSession#publish(Handler, PublishConfig, WifiNanDiscoverySessionCallback)} or
|
* {@link WifiAwareSession#publish(Handler, PublishConfig, WifiAwareDiscoverySessionCallback)}
|
||||||
* {@link WifiNanSession#subscribe(Handler, SubscribeConfig, WifiNanDiscoverySessionCallback)}
|
* or
|
||||||
* to create publish or subscribe NAN discovery sessions. Events are called on the provided
|
* {@link WifiAwareSession#subscribe(Handler, SubscribeConfig,
|
||||||
* callback object {@link WifiNanDiscoverySessionCallback}. Specifically, the
|
* WifiAwareDiscoverySessionCallback)}
|
||||||
* {@link WifiNanDiscoverySessionCallback#onPublishStarted(WifiNanPublishDiscoverySession)}
|
* to create publish or subscribe Aware discovery sessions. Events are called on the provided
|
||||||
|
* callback object {@link WifiAwareDiscoverySessionCallback}. Specifically, the
|
||||||
|
* {@link WifiAwareDiscoverySessionCallback#onPublishStarted(WifiAwarePublishDiscoverySession)}
|
||||||
* and
|
* and
|
||||||
* {@link WifiNanDiscoverySessionCallback#onSubscribeStarted(WifiNanSubscribeDiscoverySession)}
|
* {@link WifiAwareDiscoverySessionCallback#onSubscribeStarted(
|
||||||
* return {@link WifiNanPublishDiscoverySession} and {@link WifiNanSubscribeDiscoverySession}
|
* WifiAwareSubscribeDiscoverySession)}
|
||||||
|
* return {@link WifiAwarePublishDiscoverySession} and
|
||||||
|
* {@link WifiAwareSubscribeDiscoverySession}
|
||||||
* objects respectively on which additional session operations can be performed, e.g. updating
|
* objects respectively on which additional session operations can be performed, e.g. updating
|
||||||
* the session {@link WifiNanPublishDiscoverySession#updatePublish(PublishConfig)} and
|
* the session {@link WifiAwarePublishDiscoverySession#updatePublish(PublishConfig)} and
|
||||||
* {@link WifiNanSubscribeDiscoverySession#updateSubscribe(SubscribeConfig)}. Sessions can also
|
* {@link WifiAwareSubscribeDiscoverySession#updateSubscribe(SubscribeConfig)}. Sessions can
|
||||||
* be used to send messages using the
|
* also be used to send messages using the
|
||||||
* {@link WifiNanDiscoveryBaseSession#sendMessage(Object, int, byte[])} APIs. When an
|
* {@link WifiAwareDiscoveryBaseSession#sendMessage(Object, int, byte[])} APIs. When an
|
||||||
* application is finished with a discovery session it <b>must</b> terminate it using the
|
* application is finished with a discovery session it <b>must</b> terminate it using the
|
||||||
* {@link WifiNanDiscoveryBaseSession#destroy()} API.
|
* {@link WifiAwareDiscoveryBaseSession#destroy()} API.
|
||||||
* <p>
|
* <p>
|
||||||
* Creating connections between NAN devices is managed by the standard
|
* Creating connections between Aware devices is managed by the standard
|
||||||
* {@link ConnectivityManager#requestNetwork(NetworkRequest, ConnectivityManager.NetworkCallback)}.
|
* {@link ConnectivityManager#requestNetwork(NetworkRequest,
|
||||||
|
* ConnectivityManager.NetworkCallback)}.
|
||||||
* The {@link NetworkRequest} object should be constructed with:
|
* The {@link NetworkRequest} object should be constructed with:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>{@link NetworkRequest.Builder#addTransportType(int)} of
|
* <li>{@link NetworkRequest.Builder#addTransportType(int)} of
|
||||||
* {@link android.net.NetworkCapabilities#TRANSPORT_WIFI_NAN}.
|
* {@link android.net.NetworkCapabilities#TRANSPORT_WIFI_AWARE}.
|
||||||
* <li>{@link NetworkRequest.Builder#setNetworkSpecifier(String)} using
|
* <li>{@link NetworkRequest.Builder#setNetworkSpecifier(String)} using
|
||||||
* {@link WifiNanSession#createNetworkSpecifier(int, byte[], byte[])} or
|
* {@link WifiAwareSession#createNetworkSpecifier(int, byte[], byte[])} or
|
||||||
* {@link WifiNanDiscoveryBaseSession#createNetworkSpecifier(int, Object, byte[])}.
|
* {@link WifiAwareDiscoveryBaseSession#createNetworkSpecifier(int, Object, byte[])}.
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
* @hide PROPOSED_NAN_API
|
* @hide PROPOSED_AWARE_API
|
||||||
*/
|
*/
|
||||||
public class WifiNanManager {
|
public class WifiAwareManager {
|
||||||
private static final String TAG = "WifiNanManager";
|
private static final String TAG = "WifiAwareManager";
|
||||||
private static final boolean DBG = false;
|
private static final boolean DBG = false;
|
||||||
private static final boolean VDBG = false; // STOPSHIP if true
|
private static final boolean VDBG = false; // STOPSHIP if true
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Keys used to generate a Network Specifier for the NAN network request. The network specifier
|
* Keys used to generate a Network Specifier for the Aware network request. The network
|
||||||
* is formatted as a JSON string.
|
* specifier is formatted as a JSON string.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -197,44 +203,44 @@ public class WifiNanManager {
|
|||||||
public static final String NETWORK_SPECIFIER_KEY_TOKEN = "token";
|
public static final String NETWORK_SPECIFIER_KEY_TOKEN = "token";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Broadcast intent action to indicate that the state of Wi-Fi NAN availability has changed.
|
* Broadcast intent action to indicate that the state of Wi-Fi Aware availability has changed.
|
||||||
* Use the {@link #isAvailable()} to query the current status.
|
* Use the {@link #isAvailable()} to query the current status.
|
||||||
* This broadcast is <b>not</b> sticky, use the {@link #isAvailable()} API after registering
|
* This broadcast is <b>not</b> sticky, use the {@link #isAvailable()} API after registering
|
||||||
* the broadcast to check the current state of Wi-Fi NAN.
|
* the broadcast to check the current state of Wi-Fi Aware.
|
||||||
* <p>Note: The broadcast is only delivered to registered receivers - no manifest registered
|
* <p>Note: The broadcast is only delivered to registered receivers - no manifest registered
|
||||||
* components will be launched.
|
* components will be launched.
|
||||||
*/
|
*/
|
||||||
@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
|
@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
|
||||||
public static final String ACTION_WIFI_NAN_STATE_CHANGED =
|
public static final String ACTION_WIFI_AWARE_STATE_CHANGED =
|
||||||
"android.net.wifi.nan.action.WIFI_NAN_STATE_CHANGED";
|
"android.net.wifi.aware.action.WIFI_AWARE_STATE_CHANGED";
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
@IntDef({
|
@IntDef({
|
||||||
WIFI_NAN_DATA_PATH_ROLE_INITIATOR, WIFI_NAN_DATA_PATH_ROLE_RESPONDER})
|
WIFI_AWARE_DATA_PATH_ROLE_INITIATOR, WIFI_AWARE_DATA_PATH_ROLE_RESPONDER})
|
||||||
@Retention(RetentionPolicy.SOURCE)
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
public @interface DataPathRole {
|
public @interface DataPathRole {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Connection creation role is that of INITIATOR. Used to create a network specifier string
|
* Connection creation role is that of INITIATOR. Used to create a network specifier string
|
||||||
* when requesting a NAN network.
|
* when requesting a Aware network.
|
||||||
*
|
*
|
||||||
* @see WifiNanDiscoveryBaseSession#createNetworkSpecifier(int, Object, byte[])
|
* @see WifiAwareDiscoveryBaseSession#createNetworkSpecifier(int, Object, byte[])
|
||||||
* @see WifiNanSession#createNetworkSpecifier(int, byte[], byte[])
|
* @see WifiAwareSession#createNetworkSpecifier(int, byte[], byte[])
|
||||||
*/
|
*/
|
||||||
public static final int WIFI_NAN_DATA_PATH_ROLE_INITIATOR = 0;
|
public static final int WIFI_AWARE_DATA_PATH_ROLE_INITIATOR = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Connection creation role is that of RESPONDER. Used to create a network specifier string
|
* Connection creation role is that of RESPONDER. Used to create a network specifier string
|
||||||
* when requesting a NAN network.
|
* when requesting a Aware network.
|
||||||
*
|
*
|
||||||
* @see WifiNanDiscoveryBaseSession#createNetworkSpecifier(int, Object, byte[])
|
* @see WifiAwareDiscoveryBaseSession#createNetworkSpecifier(int, Object, byte[])
|
||||||
* @see WifiNanSession#createNetworkSpecifier(int, byte[], byte[])
|
* @see WifiAwareSession#createNetworkSpecifier(int, byte[], byte[])
|
||||||
*/
|
*/
|
||||||
public static final int WIFI_NAN_DATA_PATH_ROLE_RESPONDER = 1;
|
public static final int WIFI_AWARE_DATA_PATH_ROLE_RESPONDER = 1;
|
||||||
|
|
||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
private final IWifiNanManager mService;
|
private final IWifiAwareManager mService;
|
||||||
|
|
||||||
private final Object mLock = new Object(); // lock access to the following vars
|
private final Object mLock = new Object(); // lock access to the following vars
|
||||||
|
|
||||||
@@ -242,14 +248,14 @@ public class WifiNanManager {
|
|||||||
private SparseArray<RttManager.RttListener> mRangingListeners = new SparseArray<>();
|
private SparseArray<RttManager.RttListener> mRangingListeners = new SparseArray<>();
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
public WifiNanManager(Context context, IWifiNanManager service) {
|
public WifiAwareManager(Context context, IWifiAwareManager service) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mService = service;
|
mService = service;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable the usage of the NAN API. Doesn't actually turn on NAN cluster formation - that
|
* Enable the usage of the Aware API. Doesn't actually turn on Aware cluster formation - that
|
||||||
* only happens when an attach is attempted. {@link #ACTION_WIFI_NAN_STATE_CHANGED} broadcast
|
* only happens when an attach is attempted. {@link #ACTION_WIFI_AWARE_STATE_CHANGED} broadcast
|
||||||
* will be triggered.
|
* will be triggered.
|
||||||
*
|
*
|
||||||
* @hide
|
* @hide
|
||||||
@@ -263,9 +269,9 @@ public class WifiNanManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disable the usage of the NAN API. All attempts to attach() will be rejected. All open
|
* Disable the usage of the Aware API. All attempts to attach() will be rejected. All open
|
||||||
* connections and sessions will be terminated. {@link #ACTION_WIFI_NAN_STATE_CHANGED} broadcast
|
* connections and sessions will be terminated. {@link #ACTION_WIFI_AWARE_STATE_CHANGED}
|
||||||
* will be triggered.
|
* broadcast will be triggered.
|
||||||
*
|
*
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
@@ -278,10 +284,11 @@ public class WifiNanManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the current status of NAN API: whether or not NAN is available. To track changes
|
* Returns the current status of Aware API: whether or not Aware is available. To track
|
||||||
* in the state of NAN API register for the {@link #ACTION_WIFI_NAN_STATE_CHANGED} broadcast.
|
* changes in the state of Aware API register for the
|
||||||
|
* {@link #ACTION_WIFI_AWARE_STATE_CHANGED} broadcast.
|
||||||
*
|
*
|
||||||
* @return A boolean indicating whether the app can use the NAN API at this time (true) or
|
* @return A boolean indicating whether the app can use the Aware API at this time (true) or
|
||||||
* not (false).
|
* not (false).
|
||||||
*/
|
*/
|
||||||
public boolean isAvailable() {
|
public boolean isAvailable() {
|
||||||
@@ -293,12 +300,12 @@ public class WifiNanManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the characteristics of the Wi-Fi NAN interface: a set of parameters which specify
|
* Returns the characteristics of the Wi-Fi Aware interface: a set of parameters which specify
|
||||||
* limitations on configurations, e.g. the maximum service name length.
|
* limitations on configurations, e.g. the maximum service name length.
|
||||||
*
|
*
|
||||||
* @return An object specifying configuration limitations of NAN.
|
* @return An object specifying configuration limitations of Aware.
|
||||||
*/
|
*/
|
||||||
public WifiNanCharacteristics getCharacteristics() {
|
public WifiAwareCharacteristics getCharacteristics() {
|
||||||
try {
|
try {
|
||||||
return mService.getCharacteristics();
|
return mService.getCharacteristics();
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
@@ -307,14 +314,14 @@ public class WifiNanManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attach to the Wi-Fi NAN service - enabling the application to create discovery sessions or
|
* Attach to the Wi-Fi Aware service - enabling the application to create discovery sessions or
|
||||||
* create connections to peers. The device will attach to an existing cluster if it can find
|
* create connections to peers. The device will attach to an existing cluster if it can find
|
||||||
* one or create a new cluster (if it is the first to enable NAN in its vicinity). Results
|
* one or create a new cluster (if it is the first to enable Aware in its vicinity). Results
|
||||||
* (e.g. successful attach to a cluster) are provided to the {@code attachCallback} object.
|
* (e.g. successful attach to a cluster) are provided to the {@code attachCallback} object.
|
||||||
* An application <b>must</b> call {@link WifiNanSession#destroy()} when done with the
|
* An application <b>must</b> call {@link WifiAwareSession#destroy()} when done with the
|
||||||
* Wi-Fi NAN object.
|
* Wi-Fi Aware object.
|
||||||
* <p>
|
* <p>
|
||||||
* Note: a NAN cluster is a shared resource - if the device is already attached to a cluster
|
* Note: a Aware cluster is a shared resource - if the device is already attached to a cluster
|
||||||
* then this function will simply indicate success immediately using the same {@code
|
* then this function will simply indicate success immediately using the same {@code
|
||||||
* attachCallback}.
|
* attachCallback}.
|
||||||
*
|
*
|
||||||
@@ -322,29 +329,29 @@ public class WifiNanManager {
|
|||||||
* attachCallback} object. If a null is provided then the application's main thread will be
|
* attachCallback} object. If a null is provided then the application's main thread will be
|
||||||
* used.
|
* used.
|
||||||
* @param attachCallback A callback for attach events, extended from
|
* @param attachCallback A callback for attach events, extended from
|
||||||
* {@link WifiNanAttachCallback}.
|
* {@link WifiAwareAttachCallback}.
|
||||||
*/
|
*/
|
||||||
public void attach(@Nullable Handler handler, @NonNull WifiNanAttachCallback attachCallback) {
|
public void attach(@Nullable Handler handler, @NonNull WifiAwareAttachCallback attachCallback) {
|
||||||
attach(handler, null, attachCallback, null);
|
attach(handler, null, attachCallback, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attach to the Wi-Fi NAN service - enabling the application to create discovery sessions or
|
* Attach to the Wi-Fi Aware service - enabling the application to create discovery sessions or
|
||||||
* create connections to peers. The device will attach to an existing cluster if it can find
|
* create connections to peers. The device will attach to an existing cluster if it can find
|
||||||
* one or create a new cluster (if it is the first to enable NAN in its vicinity). Results
|
* one or create a new cluster (if it is the first to enable Aware in its vicinity). Results
|
||||||
* (e.g. successful attach to a cluster) are provided to the {@code attachCallback} object.
|
* (e.g. successful attach to a cluster) are provided to the {@code attachCallback} object.
|
||||||
* An application <b>must</b> call {@link WifiNanSession#destroy()} when done with the
|
* An application <b>must</b> call {@link WifiAwareSession#destroy()} when done with the
|
||||||
* Wi-Fi NAN object.
|
* Wi-Fi Aware object.
|
||||||
* <p>
|
* <p>
|
||||||
* Note: a NAN cluster is a shared resource - if the device is already attached to a cluster
|
* Note: a Aware cluster is a shared resource - if the device is already attached to a cluster
|
||||||
* then this function will simply indicate success immediately using the same {@code
|
* then this function will simply indicate success immediately using the same {@code
|
||||||
* attachCallback}.
|
* attachCallback}.
|
||||||
* <p>
|
* <p>
|
||||||
* This version of the API attaches a listener to receive the MAC address of the NAN interface
|
* This version of the API attaches a listener to receive the MAC address of the Aware interface
|
||||||
* on startup and whenever it is updated (it is randomized at regular intervals for privacy).
|
* on startup and whenever it is updated (it is randomized at regular intervals for privacy).
|
||||||
* The application must have the {@link android.Manifest.permission#ACCESS_COARSE_LOCATION}
|
* The application must have the {@link android.Manifest.permission#ACCESS_COARSE_LOCATION}
|
||||||
* permission to execute this attach request. Otherwise, use the
|
* permission to execute this attach request. Otherwise, use the
|
||||||
* {@link #attach(Handler, WifiNanAttachCallback)} version. Note that aside from permission
|
* {@link #attach(Handler, WifiAwareAttachCallback)} version. Note that aside from permission
|
||||||
* requirements this listener will wake up the host at regular intervals causing higher power
|
* requirements this listener will wake up the host at regular intervals causing higher power
|
||||||
* consumption, do not use it unless the information is necessary (e.g. for OOB discovery).
|
* consumption, do not use it unless the information is necessary (e.g. for OOB discovery).
|
||||||
*
|
*
|
||||||
@@ -352,19 +359,19 @@ public class WifiNanManager {
|
|||||||
* attachCallback} and {@code identityChangedListener} objects. If a null is provided then the
|
* attachCallback} and {@code identityChangedListener} objects. If a null is provided then the
|
||||||
* application's main thread will be used.
|
* application's main thread will be used.
|
||||||
* @param attachCallback A callback for attach events, extended from
|
* @param attachCallback A callback for attach events, extended from
|
||||||
* {@link WifiNanAttachCallback}.
|
* {@link WifiAwareAttachCallback}.
|
||||||
* @param identityChangedListener A listener for changed identity, extended from
|
* @param identityChangedListener A listener for changed identity, extended from
|
||||||
* {@link WifiNanIdentityChangedListener}.
|
* {@link WifiAwareIdentityChangedListener}.
|
||||||
*/
|
*/
|
||||||
public void attach(@Nullable Handler handler, @NonNull WifiNanAttachCallback attachCallback,
|
public void attach(@Nullable Handler handler, @NonNull WifiAwareAttachCallback attachCallback,
|
||||||
@NonNull WifiNanIdentityChangedListener identityChangedListener) {
|
@NonNull WifiAwareIdentityChangedListener identityChangedListener) {
|
||||||
attach(handler, null, attachCallback, identityChangedListener);
|
attach(handler, null, attachCallback, identityChangedListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
public void attach(Handler handler, ConfigRequest configRequest,
|
public void attach(Handler handler, ConfigRequest configRequest,
|
||||||
WifiNanAttachCallback attachCallback,
|
WifiAwareAttachCallback attachCallback,
|
||||||
WifiNanIdentityChangedListener identityChangedListener) {
|
WifiAwareIdentityChangedListener identityChangedListener) {
|
||||||
if (VDBG) {
|
if (VDBG) {
|
||||||
Log.v(TAG, "attach(): handler=" + handler + ", callback=" + attachCallback
|
Log.v(TAG, "attach(): handler=" + handler + ", callback=" + attachCallback
|
||||||
+ ", configRequest=" + configRequest + ", identityChangedListener="
|
+ ", configRequest=" + configRequest + ", identityChangedListener="
|
||||||
@@ -377,7 +384,7 @@ public class WifiNanManager {
|
|||||||
try {
|
try {
|
||||||
Binder binder = new Binder();
|
Binder binder = new Binder();
|
||||||
mService.connect(binder, mContext.getOpPackageName(),
|
mService.connect(binder, mContext.getOpPackageName(),
|
||||||
new WifiNanEventCallbackProxy(this, looper, binder, attachCallback,
|
new WifiAwareEventCallbackProxy(this, looper, binder, attachCallback,
|
||||||
identityChangedListener), configRequest,
|
identityChangedListener), configRequest,
|
||||||
identityChangedListener != null);
|
identityChangedListener != null);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
@@ -399,12 +406,12 @@ public class WifiNanManager {
|
|||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
public void publish(int clientId, Looper looper, PublishConfig publishConfig,
|
public void publish(int clientId, Looper looper, PublishConfig publishConfig,
|
||||||
WifiNanDiscoverySessionCallback callback) {
|
WifiAwareDiscoverySessionCallback callback) {
|
||||||
if (VDBG) Log.v(TAG, "publish(): clientId=" + clientId + ", config=" + publishConfig);
|
if (VDBG) Log.v(TAG, "publish(): clientId=" + clientId + ", config=" + publishConfig);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
mService.publish(clientId, publishConfig,
|
mService.publish(clientId, publishConfig,
|
||||||
new WifiNanDiscoverySessionCallbackProxy(this, looper, true, callback,
|
new WifiAwareDiscoverySessionCallbackProxy(this, looper, true, callback,
|
||||||
clientId));
|
clientId));
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
throw e.rethrowFromSystemServer();
|
throw e.rethrowFromSystemServer();
|
||||||
@@ -427,7 +434,7 @@ public class WifiNanManager {
|
|||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
public void subscribe(int clientId, Looper looper, SubscribeConfig subscribeConfig,
|
public void subscribe(int clientId, Looper looper, SubscribeConfig subscribeConfig,
|
||||||
WifiNanDiscoverySessionCallback callback) {
|
WifiAwareDiscoverySessionCallback callback) {
|
||||||
if (VDBG) {
|
if (VDBG) {
|
||||||
if (VDBG) {
|
if (VDBG) {
|
||||||
Log.v(TAG,
|
Log.v(TAG,
|
||||||
@@ -437,7 +444,7 @@ public class WifiNanManager {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
mService.subscribe(clientId, subscribeConfig,
|
mService.subscribe(clientId, subscribeConfig,
|
||||||
new WifiNanDiscoverySessionCallbackProxy(this, looper, false, callback,
|
new WifiAwareDiscoverySessionCallbackProxy(this, looper, false, callback,
|
||||||
clientId));
|
clientId));
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
throw e.rethrowFromSystemServer();
|
throw e.rethrowFromSystemServer();
|
||||||
@@ -535,13 +542,13 @@ public class WifiNanManager {
|
|||||||
type = NETWORK_SPECIFIER_TYPE_1D;
|
type = NETWORK_SPECIFIER_TYPE_1D;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (role != WIFI_NAN_DATA_PATH_ROLE_INITIATOR
|
if (role != WIFI_AWARE_DATA_PATH_ROLE_INITIATOR
|
||||||
&& role != WIFI_NAN_DATA_PATH_ROLE_RESPONDER) {
|
&& role != WIFI_AWARE_DATA_PATH_ROLE_RESPONDER) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"createNetworkSpecifier: Invalid 'role' argument when creating a network "
|
"createNetworkSpecifier: Invalid 'role' argument when creating a network "
|
||||||
+ "specifier");
|
+ "specifier");
|
||||||
}
|
}
|
||||||
if (role == WIFI_NAN_DATA_PATH_ROLE_INITIATOR) {
|
if (role == WIFI_AWARE_DATA_PATH_ROLE_INITIATOR) {
|
||||||
if (token == null) {
|
if (token == null) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"createNetworkSpecifier: Invalid null token - not permitted on INITIATOR");
|
"createNetworkSpecifier: Invalid null token - not permitted on INITIATOR");
|
||||||
@@ -592,13 +599,13 @@ public class WifiNanManager {
|
|||||||
type = NETWORK_SPECIFIER_TYPE_2D;
|
type = NETWORK_SPECIFIER_TYPE_2D;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (role != WIFI_NAN_DATA_PATH_ROLE_INITIATOR
|
if (role != WIFI_AWARE_DATA_PATH_ROLE_INITIATOR
|
||||||
&& role != WIFI_NAN_DATA_PATH_ROLE_RESPONDER) {
|
&& role != WIFI_AWARE_DATA_PATH_ROLE_RESPONDER) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"createNetworkSpecifier: Invalid 'role' argument when creating a network "
|
"createNetworkSpecifier: Invalid 'role' argument when creating a network "
|
||||||
+ "specifier");
|
+ "specifier");
|
||||||
}
|
}
|
||||||
if (role == WIFI_NAN_DATA_PATH_ROLE_INITIATOR) {
|
if (role == WIFI_AWARE_DATA_PATH_ROLE_INITIATOR) {
|
||||||
if (peer == null || peer.length != 6) {
|
if (peer == null || peer.length != 6) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"createNetworkSpecifier: Invalid peer MAC address");
|
"createNetworkSpecifier: Invalid peer MAC address");
|
||||||
@@ -634,7 +641,7 @@ public class WifiNanManager {
|
|||||||
return json.toString();
|
return json.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class WifiNanEventCallbackProxy extends IWifiNanEventCallback.Stub {
|
private static class WifiAwareEventCallbackProxy extends IWifiAwareEventCallback.Stub {
|
||||||
private static final int CALLBACK_CONNECT_SUCCESS = 0;
|
private static final int CALLBACK_CONNECT_SUCCESS = 0;
|
||||||
private static final int CALLBACK_CONNECT_FAIL = 1;
|
private static final int CALLBACK_CONNECT_FAIL = 1;
|
||||||
private static final int CALLBACK_IDENTITY_CHANGED = 2;
|
private static final int CALLBACK_IDENTITY_CHANGED = 2;
|
||||||
@@ -643,12 +650,12 @@ public class WifiNanManager {
|
|||||||
private static final int CALLBACK_RANGING_ABORTED = 5;
|
private static final int CALLBACK_RANGING_ABORTED = 5;
|
||||||
|
|
||||||
private final Handler mHandler;
|
private final Handler mHandler;
|
||||||
private final WeakReference<WifiNanManager> mNanManager;
|
private final WeakReference<WifiAwareManager> mAwareManager;
|
||||||
private final Binder mBinder;
|
private final Binder mBinder;
|
||||||
private final Looper mLooper;
|
private final Looper mLooper;
|
||||||
|
|
||||||
RttManager.RttListener getAndRemoveRangingListener(int rangingId) {
|
RttManager.RttListener getAndRemoveRangingListener(int rangingId) {
|
||||||
WifiNanManager mgr = mNanManager.get();
|
WifiAwareManager mgr = mAwareManager.get();
|
||||||
if (mgr == null) {
|
if (mgr == null) {
|
||||||
Log.w(TAG, "getAndRemoveRangingListener: called post GC");
|
Log.w(TAG, "getAndRemoveRangingListener: called post GC");
|
||||||
return null;
|
return null;
|
||||||
@@ -662,39 +669,40 @@ public class WifiNanManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a {@link WifiNanAttachCallback} using the specified looper.
|
* Constructs a {@link WifiAwareAttachCallback} using the specified looper.
|
||||||
* All callbacks will delivered on the thread of the specified looper.
|
* All callbacks will delivered on the thread of the specified looper.
|
||||||
*
|
*
|
||||||
* @param looper The looper on which to execute the callbacks.
|
* @param looper The looper on which to execute the callbacks.
|
||||||
*/
|
*/
|
||||||
WifiNanEventCallbackProxy(WifiNanManager mgr, Looper looper, Binder binder,
|
WifiAwareEventCallbackProxy(WifiAwareManager mgr, Looper looper, Binder binder,
|
||||||
final WifiNanAttachCallback attachCallback,
|
final WifiAwareAttachCallback attachCallback,
|
||||||
final WifiNanIdentityChangedListener identityChangedListener) {
|
final WifiAwareIdentityChangedListener identityChangedListener) {
|
||||||
mNanManager = new WeakReference<>(mgr);
|
mAwareManager = new WeakReference<>(mgr);
|
||||||
mLooper = looper;
|
mLooper = looper;
|
||||||
mBinder = binder;
|
mBinder = binder;
|
||||||
|
|
||||||
if (VDBG) Log.v(TAG, "WifiNanEventCallbackProxy ctor: looper=" + looper);
|
if (VDBG) Log.v(TAG, "WifiAwareEventCallbackProxy ctor: looper=" + looper);
|
||||||
mHandler = new Handler(looper) {
|
mHandler = new Handler(looper) {
|
||||||
@Override
|
@Override
|
||||||
public void handleMessage(Message msg) {
|
public void handleMessage(Message msg) {
|
||||||
if (DBG) {
|
if (DBG) {
|
||||||
Log.d(TAG, "WifiNanEventCallbackProxy: What=" + msg.what + ", msg=" + msg);
|
Log.d(TAG, "WifiAwareEventCallbackProxy: What=" + msg.what + ", msg="
|
||||||
|
+ msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
WifiNanManager mgr = mNanManager.get();
|
WifiAwareManager mgr = mAwareManager.get();
|
||||||
if (mgr == null) {
|
if (mgr == null) {
|
||||||
Log.w(TAG, "WifiNanEventCallbackProxy: handleMessage post GC");
|
Log.w(TAG, "WifiAwareEventCallbackProxy: handleMessage post GC");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (msg.what) {
|
switch (msg.what) {
|
||||||
case CALLBACK_CONNECT_SUCCESS:
|
case CALLBACK_CONNECT_SUCCESS:
|
||||||
attachCallback.onAttached(
|
attachCallback.onAttached(
|
||||||
new WifiNanSession(mgr, mBinder, msg.arg1));
|
new WifiAwareSession(mgr, mBinder, msg.arg1));
|
||||||
break;
|
break;
|
||||||
case CALLBACK_CONNECT_FAIL:
|
case CALLBACK_CONNECT_FAIL:
|
||||||
mNanManager.clear();
|
mAwareManager.clear();
|
||||||
attachCallback.onAttachFailed();
|
attachCallback.onAttachFailed();
|
||||||
break;
|
break;
|
||||||
case CALLBACK_IDENTITY_CHANGED:
|
case CALLBACK_IDENTITY_CHANGED:
|
||||||
@@ -801,8 +809,8 @@ public class WifiNanManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class WifiNanDiscoverySessionCallbackProxy extends
|
private static class WifiAwareDiscoverySessionCallbackProxy extends
|
||||||
IWifiNanDiscoverySessionCallback.Stub {
|
IWifiAwareDiscoverySessionCallback.Stub {
|
||||||
private static final int CALLBACK_SESSION_STARTED = 0;
|
private static final int CALLBACK_SESSION_STARTED = 0;
|
||||||
private static final int CALLBACK_SESSION_CONFIG_SUCCESS = 1;
|
private static final int CALLBACK_SESSION_CONFIG_SUCCESS = 1;
|
||||||
private static final int CALLBACK_SESSION_CONFIG_FAIL = 2;
|
private static final int CALLBACK_SESSION_CONFIG_FAIL = 2;
|
||||||
@@ -815,23 +823,24 @@ public class WifiNanManager {
|
|||||||
private static final String MESSAGE_BUNDLE_KEY_MESSAGE = "message";
|
private static final String MESSAGE_BUNDLE_KEY_MESSAGE = "message";
|
||||||
private static final String MESSAGE_BUNDLE_KEY_MESSAGE2 = "message2";
|
private static final String MESSAGE_BUNDLE_KEY_MESSAGE2 = "message2";
|
||||||
|
|
||||||
private final WeakReference<WifiNanManager> mNanManager;
|
private final WeakReference<WifiAwareManager> mAwareManager;
|
||||||
private final boolean mIsPublish;
|
private final boolean mIsPublish;
|
||||||
private final WifiNanDiscoverySessionCallback mOriginalCallback;
|
private final WifiAwareDiscoverySessionCallback mOriginalCallback;
|
||||||
private final int mClientId;
|
private final int mClientId;
|
||||||
|
|
||||||
private final Handler mHandler;
|
private final Handler mHandler;
|
||||||
private WifiNanDiscoveryBaseSession mSession;
|
private WifiAwareDiscoveryBaseSession mSession;
|
||||||
|
|
||||||
WifiNanDiscoverySessionCallbackProxy(WifiNanManager mgr, Looper looper, boolean isPublish,
|
WifiAwareDiscoverySessionCallbackProxy(WifiAwareManager mgr, Looper looper,
|
||||||
WifiNanDiscoverySessionCallback originalCallback, int clientId) {
|
boolean isPublish, WifiAwareDiscoverySessionCallback originalCallback,
|
||||||
mNanManager = new WeakReference<>(mgr);
|
int clientId) {
|
||||||
|
mAwareManager = new WeakReference<>(mgr);
|
||||||
mIsPublish = isPublish;
|
mIsPublish = isPublish;
|
||||||
mOriginalCallback = originalCallback;
|
mOriginalCallback = originalCallback;
|
||||||
mClientId = clientId;
|
mClientId = clientId;
|
||||||
|
|
||||||
if (VDBG) {
|
if (VDBG) {
|
||||||
Log.v(TAG, "WifiNanDiscoverySessionCallbackProxy ctor: isPublish=" + isPublish);
|
Log.v(TAG, "WifiAwareDiscoverySessionCallbackProxy ctor: isPublish=" + isPublish);
|
||||||
}
|
}
|
||||||
|
|
||||||
mHandler = new Handler(looper) {
|
mHandler = new Handler(looper) {
|
||||||
@@ -839,8 +848,8 @@ public class WifiNanManager {
|
|||||||
public void handleMessage(Message msg) {
|
public void handleMessage(Message msg) {
|
||||||
if (DBG) Log.d(TAG, "What=" + msg.what + ", msg=" + msg);
|
if (DBG) Log.d(TAG, "What=" + msg.what + ", msg=" + msg);
|
||||||
|
|
||||||
if (mNanManager.get() == null) {
|
if (mAwareManager.get() == null) {
|
||||||
Log.w(TAG, "WifiNanDiscoverySessionCallbackProxy: handleMessage post GC");
|
Log.w(TAG, "WifiAwareDiscoverySessionCallbackProxy: handleMessage post GC");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -858,7 +867,7 @@ public class WifiNanManager {
|
|||||||
* creation failed (as opposed to update
|
* creation failed (as opposed to update
|
||||||
* failing)
|
* failing)
|
||||||
*/
|
*/
|
||||||
mNanManager.clear();
|
mAwareManager.clear();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CALLBACK_SESSION_TERMINATED:
|
case CALLBACK_SESSION_TERMINATED:
|
||||||
@@ -977,20 +986,20 @@ public class WifiNanManager {
|
|||||||
"onSessionStarted: sessionId=" + sessionId + ": session already created!?");
|
"onSessionStarted: sessionId=" + sessionId + ": session already created!?");
|
||||||
}
|
}
|
||||||
|
|
||||||
WifiNanManager mgr = mNanManager.get();
|
WifiAwareManager mgr = mAwareManager.get();
|
||||||
if (mgr == null) {
|
if (mgr == null) {
|
||||||
Log.w(TAG, "onProxySessionStarted: mgr GC'd");
|
Log.w(TAG, "onProxySessionStarted: mgr GC'd");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mIsPublish) {
|
if (mIsPublish) {
|
||||||
WifiNanPublishDiscoverySession session = new WifiNanPublishDiscoverySession(mgr,
|
WifiAwarePublishDiscoverySession session = new WifiAwarePublishDiscoverySession(mgr,
|
||||||
mClientId, sessionId);
|
mClientId, sessionId);
|
||||||
mSession = session;
|
mSession = session;
|
||||||
mOriginalCallback.onPublishStarted(session);
|
mOriginalCallback.onPublishStarted(session);
|
||||||
} else {
|
} else {
|
||||||
WifiNanSubscribeDiscoverySession
|
WifiAwareSubscribeDiscoverySession
|
||||||
session = new WifiNanSubscribeDiscoverySession(mgr, mClientId, sessionId);
|
session = new WifiAwareSubscribeDiscoverySession(mgr, mClientId, sessionId);
|
||||||
mSession = session;
|
mSession = session;
|
||||||
mOriginalCallback.onSubscribeStarted(session);
|
mOriginalCallback.onSubscribeStarted(session);
|
||||||
}
|
}
|
||||||
@@ -1004,7 +1013,7 @@ public class WifiNanManager {
|
|||||||
} else {
|
} else {
|
||||||
Log.w(TAG, "Proxy: onSessionTerminated called but mSession is null!?");
|
Log.w(TAG, "Proxy: onSessionTerminated called but mSession is null!?");
|
||||||
}
|
}
|
||||||
mNanManager.clear();
|
mAwareManager.clear();
|
||||||
mOriginalCallback.onSessionTerminated(reason);
|
mOriginalCallback.onSessionTerminated(reason);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -14,39 +14,40 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package android.net.wifi.nan;
|
package android.net.wifi.aware;
|
||||||
|
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A class representing a NAN publish session. Created when
|
* A class representing a Aware publish session. Created when
|
||||||
* {@link WifiNanSession#publish(android.os.Handler, PublishConfig, WifiNanDiscoverySessionCallback)}
|
* {@link WifiAwareSession#publish(android.os.Handler, PublishConfig,
|
||||||
|
* WifiAwareDiscoverySessionCallback)}
|
||||||
* is called and a discovery session is created and returned in
|
* is called and a discovery session is created and returned in
|
||||||
* {@link WifiNanDiscoverySessionCallback#onPublishStarted(WifiNanPublishDiscoverySession)}. See
|
* {@link WifiAwareDiscoverySessionCallback#onPublishStarted(WifiAwarePublishDiscoverySession)}. See
|
||||||
* baseline functionality of all discovery sessions in {@link WifiNanDiscoveryBaseSession}. This
|
* baseline functionality of all discovery sessions in {@link WifiAwareDiscoveryBaseSession}. This
|
||||||
* object allows updating an existing/running publish discovery session using
|
* object allows updating an existing/running publish discovery session using
|
||||||
* {@link #updatePublish(PublishConfig)}.
|
* {@link #updatePublish(PublishConfig)}.
|
||||||
*
|
*
|
||||||
* @hide PROPOSED_NAN_API
|
* @hide PROPOSED_AWARE_API
|
||||||
*/
|
*/
|
||||||
public class WifiNanPublishDiscoverySession extends WifiNanDiscoveryBaseSession {
|
public class WifiAwarePublishDiscoverySession extends WifiAwareDiscoveryBaseSession {
|
||||||
private static final String TAG = "WifiNanPublishDiscSsn";
|
private static final String TAG = "WifiAwarePublishDiscSsn";
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
public WifiNanPublishDiscoverySession(WifiNanManager manager, int clientId, int sessionId) {
|
public WifiAwarePublishDiscoverySession(WifiAwareManager manager, int clientId, int sessionId) {
|
||||||
super(manager, clientId, sessionId);
|
super(manager, clientId, sessionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Re-configure the currently active publish session. The
|
* Re-configure the currently active publish session. The
|
||||||
* {@link WifiNanDiscoverySessionCallback} is not replaced - the same listener used
|
* {@link WifiAwareDiscoverySessionCallback} is not replaced - the same listener used
|
||||||
* at creation is still used. The results of the configuration are returned using
|
* at creation is still used. The results of the configuration are returned using
|
||||||
* {@link WifiNanDiscoverySessionCallback}:
|
* {@link WifiAwareDiscoverySessionCallback}:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>{@link WifiNanDiscoverySessionCallback#onSessionConfigUpdated()}: configuration
|
* <li>{@link WifiAwareDiscoverySessionCallback#onSessionConfigUpdated()}: configuration
|
||||||
* update succeeded.
|
* update succeeded.
|
||||||
* <li>{@link WifiNanDiscoverySessionCallback#onSessionConfigFailed()}: configuration
|
* <li>{@link WifiAwareDiscoverySessionCallback#onSessionConfigFailed()}: configuration
|
||||||
* update failed. The publish discovery session is still running using its previous
|
* update failed. The publish discovery session is still running using its previous
|
||||||
* configuration (i.e. update failure does not terminate the session).
|
* configuration (i.e. update failure does not terminate the session).
|
||||||
* </ul>
|
* </ul>
|
||||||
@@ -58,9 +59,9 @@ public class WifiNanPublishDiscoverySession extends WifiNanDiscoveryBaseSession
|
|||||||
Log.w(TAG, "updatePublish: called on terminated session");
|
Log.w(TAG, "updatePublish: called on terminated session");
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
WifiNanManager mgr = mMgr.get();
|
WifiAwareManager mgr = mMgr.get();
|
||||||
if (mgr == null) {
|
if (mgr == null) {
|
||||||
Log.w(TAG, "updatePublish: called post GC on WifiNanManager");
|
Log.w(TAG, "updatePublish: called post GC on WifiAwareManager");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -14,11 +14,10 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package android.net.wifi.nan;
|
package android.net.wifi.aware;
|
||||||
|
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.net.NetworkRequest;
|
|
||||||
import android.os.Binder;
|
import android.os.Binder;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
@@ -29,17 +28,17 @@ import dalvik.system.CloseGuard;
|
|||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class represents a Wi-Fi NAN session - an attachment to the Wi-Fi NAN service through
|
* This class represents a Wi-Fi Aware session - an attachment to the Wi-Fi Aware service through
|
||||||
* which the app can execute discovery operations.
|
* which the app can execute discovery operations.
|
||||||
*
|
*
|
||||||
* @hide PROPOSED_NAN_API
|
* @hide PROPOSED_AWARE_API
|
||||||
*/
|
*/
|
||||||
public class WifiNanSession {
|
public class WifiAwareSession {
|
||||||
private static final String TAG = "WifiNanSession";
|
private static final String TAG = "WifiAwareSession";
|
||||||
private static final boolean DBG = false;
|
private static final boolean DBG = false;
|
||||||
private static final boolean VDBG = false; // STOPSHIP if true
|
private static final boolean VDBG = false; // STOPSHIP if true
|
||||||
|
|
||||||
private final WeakReference<WifiNanManager> mMgr;
|
private final WeakReference<WifiAwareManager> mMgr;
|
||||||
private final Binder mBinder;
|
private final Binder mBinder;
|
||||||
private final int mClientId;
|
private final int mClientId;
|
||||||
|
|
||||||
@@ -47,7 +46,7 @@ public class WifiNanSession {
|
|||||||
private final CloseGuard mCloseGuard = CloseGuard.get();
|
private final CloseGuard mCloseGuard = CloseGuard.get();
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
public WifiNanSession(WifiNanManager manager, Binder binder, int clientId) {
|
public WifiAwareSession(WifiAwareManager manager, Binder binder, int clientId) {
|
||||||
if (VDBG) Log.v(TAG, "New session created: manager=" + manager + ", clientId=" + clientId);
|
if (VDBG) Log.v(TAG, "New session created: manager=" + manager + ", clientId=" + clientId);
|
||||||
|
|
||||||
mMgr = new WeakReference<>(manager);
|
mMgr = new WeakReference<>(manager);
|
||||||
@@ -59,19 +58,19 @@ public class WifiNanSession {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destroy the Wi-Fi NAN service session and, if no other applications are attached to NAN,
|
* Destroy the Wi-Fi Aware service session and, if no other applications are attached to Aware,
|
||||||
* also disable NAN. This method destroys all outstanding operations - i.e. all publish and
|
* also disable Aware. This method destroys all outstanding operations - i.e. all publish and
|
||||||
* subscribes are terminated, and any outstanding data-links are shut-down. However, it is
|
* subscribes are terminated, and any outstanding data-links are shut-down. However, it is
|
||||||
* good practice to destroy these discovery sessions and connections explicitly before a
|
* good practice to destroy these discovery sessions and connections explicitly before a
|
||||||
* session-wide destroy.
|
* session-wide destroy.
|
||||||
* <p>
|
* <p>
|
||||||
* An application may re-attach after a destroy using
|
* An application may re-attach after a destroy using
|
||||||
* {@link WifiNanManager#attach(Handler, WifiNanAttachCallback)} .
|
* {@link WifiAwareManager#attach(Handler, WifiAwareAttachCallback)} .
|
||||||
*/
|
*/
|
||||||
public void destroy() {
|
public void destroy() {
|
||||||
WifiNanManager mgr = mMgr.get();
|
WifiAwareManager mgr = mMgr.get();
|
||||||
if (mgr == null) {
|
if (mgr == null) {
|
||||||
Log.w(TAG, "destroy: called post GC on WifiNanManager");
|
Log.w(TAG, "destroy: called post GC on WifiAwareManager");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mgr.disconnect(mClientId, mBinder);
|
mgr.disconnect(mClientId, mBinder);
|
||||||
@@ -94,23 +93,24 @@ public class WifiNanSession {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Issue a request to the NAN service to create a new NAN publish discovery session, using
|
* Issue a request to the Aware service to create a new Aware publish discovery session, using
|
||||||
* the specified {@code publishConfig} configuration. The results of the publish operation
|
* the specified {@code publishConfig} configuration. The results of the publish operation
|
||||||
* are routed to the callbacks of {@link WifiNanDiscoverySessionCallback}:
|
* are routed to the callbacks of {@link WifiAwareDiscoverySessionCallback}:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>
|
* <li>
|
||||||
* {@link WifiNanDiscoverySessionCallback#onPublishStarted(WifiNanPublishDiscoverySession)}
|
* {@link WifiAwareDiscoverySessionCallback#onPublishStarted(
|
||||||
|
* WifiAwarePublishDiscoverySession)}
|
||||||
* is called when the publish session is created and provides a handle to the session.
|
* is called when the publish session is created and provides a handle to the session.
|
||||||
* Further operations on the publish session can be executed on that object.
|
* Further operations on the publish session can be executed on that object.
|
||||||
* <li>{@link WifiNanDiscoverySessionCallback#onSessionConfigFailed()} is called if the
|
* <li>{@link WifiAwareDiscoverySessionCallback#onSessionConfigFailed()} is called if the
|
||||||
* publish operation failed.
|
* publish operation failed.
|
||||||
* </ul>
|
* </ul>
|
||||||
* <p>
|
* <p>
|
||||||
* Other results of the publish session operations will also be routed to callbacks
|
* Other results of the publish session operations will also be routed to callbacks
|
||||||
* on the {@code callback} object. The resulting publish session can be modified using
|
* on the {@code callback} object. The resulting publish session can be modified using
|
||||||
* {@link WifiNanPublishDiscoverySession#updatePublish(PublishConfig)}.
|
* {@link WifiAwarePublishDiscoverySession#updatePublish(PublishConfig)}.
|
||||||
* <p>
|
* <p>
|
||||||
* An application must use the {@link WifiNanDiscoveryBaseSession#destroy()} to
|
* An application must use the {@link WifiAwareDiscoveryBaseSession#destroy()} to
|
||||||
* terminate the publish discovery session once it isn't needed. This will free
|
* terminate the publish discovery session once it isn't needed. This will free
|
||||||
* resources as well terminate any on-air transmissions.
|
* resources as well terminate any on-air transmissions.
|
||||||
* <p>The application must have the {@link android.Manifest.permission#ACCESS_COARSE_LOCATION}
|
* <p>The application must have the {@link android.Manifest.permission#ACCESS_COARSE_LOCATION}
|
||||||
@@ -120,14 +120,14 @@ public class WifiNanSession {
|
|||||||
* callback} object. If a null is provided then the application's main thread will be used.
|
* callback} object. If a null is provided then the application's main thread will be used.
|
||||||
* @param publishConfig The {@link PublishConfig} specifying the
|
* @param publishConfig The {@link PublishConfig} specifying the
|
||||||
* configuration of the requested publish session.
|
* configuration of the requested publish session.
|
||||||
* @param callback A {@link WifiNanDiscoverySessionCallback} derived object to be used for
|
* @param callback A {@link WifiAwareDiscoverySessionCallback} derived object to be used for
|
||||||
* session event callbacks.
|
* session event callbacks.
|
||||||
*/
|
*/
|
||||||
public void publish(@Nullable Handler handler, @NonNull PublishConfig publishConfig,
|
public void publish(@Nullable Handler handler, @NonNull PublishConfig publishConfig,
|
||||||
@NonNull WifiNanDiscoverySessionCallback callback) {
|
@NonNull WifiAwareDiscoverySessionCallback callback) {
|
||||||
WifiNanManager mgr = mMgr.get();
|
WifiAwareManager mgr = mMgr.get();
|
||||||
if (mgr == null) {
|
if (mgr == null) {
|
||||||
Log.e(TAG, "publish: called post GC on WifiNanManager");
|
Log.e(TAG, "publish: called post GC on WifiAwareManager");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (mTerminated) {
|
if (mTerminated) {
|
||||||
@@ -139,23 +139,24 @@ public class WifiNanSession {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Issue a request to the NAN service to create a new NAN subscribe discovery session, using
|
* Issue a request to the Aware service to create a new Aware subscribe discovery session, using
|
||||||
* the specified {@code subscribeConfig} configuration. The results of the subscribe
|
* the specified {@code subscribeConfig} configuration. The results of the subscribe
|
||||||
* operation are routed to the callbacks of {@link WifiNanDiscoverySessionCallback}:
|
* operation are routed to the callbacks of {@link WifiAwareDiscoverySessionCallback}:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>
|
* <li>
|
||||||
* {@link WifiNanDiscoverySessionCallback#onSubscribeStarted(WifiNanSubscribeDiscoverySession)}
|
* {@link WifiAwareDiscoverySessionCallback#onSubscribeStarted(
|
||||||
|
* WifiAwareSubscribeDiscoverySession)}
|
||||||
* is called when the subscribe session is created and provides a handle to the session.
|
* is called when the subscribe session is created and provides a handle to the session.
|
||||||
* Further operations on the subscribe session can be executed on that object.
|
* Further operations on the subscribe session can be executed on that object.
|
||||||
* <li>{@link WifiNanDiscoverySessionCallback#onSessionConfigFailed()} is called if the
|
* <li>{@link WifiAwareDiscoverySessionCallback#onSessionConfigFailed()} is called if the
|
||||||
* subscribe operation failed.
|
* subscribe operation failed.
|
||||||
* </ul>
|
* </ul>
|
||||||
* <p>
|
* <p>
|
||||||
* Other results of the subscribe session operations will also be routed to callbacks
|
* Other results of the subscribe session operations will also be routed to callbacks
|
||||||
* on the {@code callback} object. The resulting subscribe session can be modified using
|
* on the {@code callback} object. The resulting subscribe session can be modified using
|
||||||
* {@link WifiNanSubscribeDiscoverySession#updateSubscribe(SubscribeConfig)}.
|
* {@link WifiAwareSubscribeDiscoverySession#updateSubscribe(SubscribeConfig)}.
|
||||||
* <p>
|
* <p>
|
||||||
* An application must use the {@link WifiNanDiscoveryBaseSession#destroy()} to
|
* An application must use the {@link WifiAwareDiscoveryBaseSession#destroy()} to
|
||||||
* terminate the subscribe discovery session once it isn't needed. This will free
|
* terminate the subscribe discovery session once it isn't needed. This will free
|
||||||
* resources as well terminate any on-air transmissions.
|
* resources as well terminate any on-air transmissions.
|
||||||
* <p>The application must have the {@link android.Manifest.permission#ACCESS_COARSE_LOCATION}
|
* <p>The application must have the {@link android.Manifest.permission#ACCESS_COARSE_LOCATION}
|
||||||
@@ -165,14 +166,14 @@ public class WifiNanSession {
|
|||||||
* callback} object. If a null is provided then the application's main thread will be used.
|
* callback} object. If a null is provided then the application's main thread will be used.
|
||||||
* @param subscribeConfig The {@link SubscribeConfig} specifying the
|
* @param subscribeConfig The {@link SubscribeConfig} specifying the
|
||||||
* configuration of the requested subscribe session.
|
* configuration of the requested subscribe session.
|
||||||
* @param callback A {@link WifiNanDiscoverySessionCallback} derived object to be used for
|
* @param callback A {@link WifiAwareDiscoverySessionCallback} derived object to be used for
|
||||||
* session event callbacks.
|
* session event callbacks.
|
||||||
*/
|
*/
|
||||||
public void subscribe(@Nullable Handler handler, @NonNull SubscribeConfig subscribeConfig,
|
public void subscribe(@Nullable Handler handler, @NonNull SubscribeConfig subscribeConfig,
|
||||||
@NonNull WifiNanDiscoverySessionCallback callback) {
|
@NonNull WifiAwareDiscoverySessionCallback callback) {
|
||||||
WifiNanManager mgr = mMgr.get();
|
WifiAwareManager mgr = mMgr.get();
|
||||||
if (mgr == null) {
|
if (mgr == null) {
|
||||||
Log.e(TAG, "publish: called post GC on WifiNanManager");
|
Log.e(TAG, "publish: called post GC on WifiAwareManager");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (mTerminated) {
|
if (mTerminated) {
|
||||||
@@ -184,20 +185,20 @@ public class WifiNanSession {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a {@link NetworkRequest.Builder#setNetworkSpecifier(String)} for a
|
* Create a {@link android.net.NetworkRequest.Builder#setNetworkSpecifier(String)} for a
|
||||||
* WiFi NAN connection to the specified peer. The
|
* WiFi Aware connection to the specified peer. The
|
||||||
* {@link NetworkRequest.Builder#addTransportType(int)} should be set to
|
* {@link android.net.NetworkRequest.Builder#addTransportType(int)} should be set to
|
||||||
* {@link android.net.NetworkCapabilities#TRANSPORT_WIFI_NAN}.
|
* {@link android.net.NetworkCapabilities#TRANSPORT_WIFI_AWARE}.
|
||||||
* <p>
|
* <p>
|
||||||
* This API is targeted for applications which can obtain the peer MAC address using OOB
|
* This API is targeted for applications which can obtain the peer MAC address using OOB
|
||||||
* (out-of-band) discovery. NAN discovery does not provide the MAC address of the peer -
|
* (out-of-band) discovery. Aware discovery does not provide the MAC address of the peer -
|
||||||
* when using NAN discovery use the alternative network specifier method -
|
* when using Aware discovery use the alternative network specifier method -
|
||||||
* {@link WifiNanDiscoveryBaseSession#createNetworkSpecifier(int, Object, byte[])}.
|
* {@link WifiAwareDiscoveryBaseSession#createNetworkSpecifier(int, Object, byte[])}.
|
||||||
*
|
*
|
||||||
* @param role The role of this device:
|
* @param role The role of this device:
|
||||||
* {@link WifiNanManager#WIFI_NAN_DATA_PATH_ROLE_INITIATOR} or
|
* {@link WifiAwareManager#WIFI_AWARE_DATA_PATH_ROLE_INITIATOR} or
|
||||||
* {@link WifiNanManager#WIFI_NAN_DATA_PATH_ROLE_RESPONDER}
|
* {@link WifiAwareManager#WIFI_AWARE_DATA_PATH_ROLE_RESPONDER}
|
||||||
* @param peer The MAC address of the peer's NAN discovery interface. On a RESPONDER this
|
* @param peer The MAC address of the peer's Aware discovery interface. On a RESPONDER this
|
||||||
* value is used to gate the acceptance of a connection request from only that
|
* value is used to gate the acceptance of a connection request from only that
|
||||||
* peer. A RESPONDER may specified a null - indicating that it will accept
|
* peer. A RESPONDER may specified a null - indicating that it will accept
|
||||||
* connection requests from any device.
|
* connection requests from any device.
|
||||||
@@ -209,14 +210,15 @@ public class WifiNanSession {
|
|||||||
*
|
*
|
||||||
* @return A string to be used to construct
|
* @return A string to be used to construct
|
||||||
* {@link android.net.NetworkRequest.Builder#setNetworkSpecifier(String)} to pass to
|
* {@link android.net.NetworkRequest.Builder#setNetworkSpecifier(String)} to pass to
|
||||||
* {@link android.net.ConnectivityManager#requestNetwork(NetworkRequest, android.net.ConnectivityManager.NetworkCallback)}
|
* {@link android.net.ConnectivityManager#requestNetwork(NetworkRequest,
|
||||||
|
* android.net.ConnectivityManager.NetworkCallback)}
|
||||||
* [or other varieties of that API].
|
* [or other varieties of that API].
|
||||||
*/
|
*/
|
||||||
public String createNetworkSpecifier(@WifiNanManager.DataPathRole int role, @Nullable byte[] peer,
|
public String createNetworkSpecifier(@WifiAwareManager.DataPathRole int role,
|
||||||
@Nullable byte[] token) {
|
@Nullable byte[] peer, @Nullable byte[] token) {
|
||||||
WifiNanManager mgr = mMgr.get();
|
WifiAwareManager mgr = mMgr.get();
|
||||||
if (mgr == null) {
|
if (mgr == null) {
|
||||||
Log.e(TAG, "createNetworkSpecifier: called post GC on WifiNanManager");
|
Log.e(TAG, "createNetworkSpecifier: called post GC on WifiAwareManager");
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
if (mTerminated) {
|
if (mTerminated) {
|
||||||
@@ -14,41 +14,43 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package android.net.wifi.nan;
|
package android.net.wifi.aware;
|
||||||
|
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A class representing a NAN subscribe session. Created when
|
* A class representing a Aware subscribe session. Created when
|
||||||
* {@link WifiNanSession#subscribe(android.os.Handler, SubscribeConfig, WifiNanDiscoverySessionCallback)}
|
* {@link WifiAwareSession#subscribe(android.os.Handler, SubscribeConfig,
|
||||||
|
* WifiAwareDiscoverySessionCallback)}
|
||||||
* is called and a discovery session is created and returned in
|
* is called and a discovery session is created and returned in
|
||||||
* {@link WifiNanDiscoverySessionCallback#onSubscribeStarted(WifiNanSubscribeDiscoverySession)}.
|
* {@link WifiAwareDiscoverySessionCallback#onSubscribeStarted(WifiAwareSubscribeDiscoverySession)}.
|
||||||
* See baseline functionality of all discovery sessions in {@link WifiNanDiscoveryBaseSession}.
|
* See baseline functionality of all discovery sessions in {@link WifiAwareDiscoveryBaseSession}.
|
||||||
* This object allows updating an existing/running subscribe discovery session using
|
* This object allows updating an existing/running subscribe discovery session using
|
||||||
* {@link #updateSubscribe(SubscribeConfig)}.
|
* {@link #updateSubscribe(SubscribeConfig)}.
|
||||||
*
|
*
|
||||||
* @hide PROPOSED_NAN_API
|
* @hide PROPOSED_AWARE_API
|
||||||
*/
|
*/
|
||||||
public class WifiNanSubscribeDiscoverySession extends WifiNanDiscoveryBaseSession {
|
public class WifiAwareSubscribeDiscoverySession extends WifiAwareDiscoveryBaseSession {
|
||||||
private static final String TAG = "WifiNanSubscribeDiscSsn";
|
private static final String TAG = "WifiAwareSubsDiscSsn";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@hide}
|
* {@hide}
|
||||||
*/
|
*/
|
||||||
public WifiNanSubscribeDiscoverySession(WifiNanManager manager, int clientId, int sessionId) {
|
public WifiAwareSubscribeDiscoverySession(WifiAwareManager manager, int clientId,
|
||||||
|
int sessionId) {
|
||||||
super(manager, clientId, sessionId);
|
super(manager, clientId, sessionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Re-configure the currently active subscribe session. The
|
* Re-configure the currently active subscribe session. The
|
||||||
* {@link WifiNanDiscoverySessionCallback} is not replaced - the same listener used
|
* {@link WifiAwareDiscoverySessionCallback} is not replaced - the same listener used
|
||||||
* at creation is still used. The results of the configuration are returned using
|
* at creation is still used. The results of the configuration are returned using
|
||||||
* {@link WifiNanDiscoverySessionCallback}:
|
* {@link WifiAwareDiscoverySessionCallback}:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>{@link WifiNanDiscoverySessionCallback#onSessionConfigUpdated()}: configuration
|
* <li>{@link WifiAwareDiscoverySessionCallback#onSessionConfigUpdated()}: configuration
|
||||||
* update succeeded.
|
* update succeeded.
|
||||||
* <li>{@link WifiNanDiscoverySessionCallback#onSessionConfigFailed()}: configuration
|
* <li>{@link WifiAwareDiscoverySessionCallback#onSessionConfigFailed()}: configuration
|
||||||
* update failed. The subscribe discovery session is still running using its previous
|
* update failed. The subscribe discovery session is still running using its previous
|
||||||
* configuration (i.e. update failure does not terminate the session).
|
* configuration (i.e. update failure does not terminate the session).
|
||||||
* </ul>
|
* </ul>
|
||||||
@@ -61,9 +63,9 @@ public class WifiNanSubscribeDiscoverySession extends WifiNanDiscoveryBaseSessio
|
|||||||
Log.w(TAG, "updateSubscribe: called on terminated session");
|
Log.w(TAG, "updateSubscribe: called on terminated session");
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
WifiNanManager mgr = mMgr.get();
|
WifiAwareManager mgr = mMgr.get();
|
||||||
if (mgr == null) {
|
if (mgr == null) {
|
||||||
Log.w(TAG, "updateSubscribe: called post GC on WifiNanManager");
|
Log.w(TAG, "updateSubscribe: called post GC on WifiAwareManager");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -14,14 +14,14 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package android.net.wifi.nan;
|
package android.net.wifi.aware;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides utilities for the Wifi NAN manager/service.
|
* Provides utilities for the Wifi Aware manager/service.
|
||||||
*
|
*
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public class WifiNanUtils {
|
public class WifiAwareUtils {
|
||||||
/**
|
/**
|
||||||
* Per spec: The Service Name is a UTF-8 encoded string from 1 to 255 bytes in length. The
|
* Per spec: The Service Name is a UTF-8 encoded string from 1 to 255 bytes in length. The
|
||||||
* only acceptable single-byte UTF-8 symbols for a Service Name are alphanumeric values (A-Z,
|
* only acceptable single-byte UTF-8 symbols for a Service Name are alphanumeric values (A-Z,
|
||||||
@@ -1,15 +1,15 @@
|
|||||||
<HTML>
|
<HTML>
|
||||||
<BODY>
|
<BODY>
|
||||||
<p>Provides classes which allow applications to use Wi-Fi NAN to discover peers and create
|
<p>Provides classes which allow applications to use Wi-Fi Aware to discover peers and create
|
||||||
connections to them.</p>
|
connections to them.</p>
|
||||||
<p>Using the Wi-Fi NAN APIs, applications can advertise services, discover peers which are
|
<p>Using the Wi-Fi Aware APIs, applications can advertise services, discover peers which are
|
||||||
advertising services, and connect to them.
|
advertising services, and connect to them.
|
||||||
Wi-Fi NAN is independent of Wi-Fi infrastructure (i.e. a device may or may
|
Wi-Fi Aware is independent of Wi-Fi infrastructure (i.e. a device may or may
|
||||||
not be associated with an AP concurrent to using Wi-Fi NAN). </p>
|
not be associated with an AP concurrent to using Wi-Fi Aware). </p>
|
||||||
<p>The primary entry point to Wi-Fi NAN capabilities is the
|
<p>The primary entry point to Wi-Fi Aware capabilities is the
|
||||||
{@link android.net.wifi.nan.WifiNanManager} class, which is acquired by calling
|
{@link android.net.wifi.aware.WifiAwareManager} class, which is acquired by calling
|
||||||
{@link android.content.Context#getSystemService(String)
|
{@link android.content.Context#getSystemService(String)
|
||||||
Context.getSystemService(Context.WIFI_NAN_SERVICE)}</p>
|
Context.getSystemService(Context.WIFI_AWARE_SERVICE)}</p>
|
||||||
|
|
||||||
<p>Some APIs may require the following user permissions:</p>
|
<p>Some APIs may require the following user permissions:</p>
|
||||||
<ul>
|
<ul>
|
||||||
@@ -18,26 +18,26 @@
|
|||||||
<li>{@link android.Manifest.permission#ACCESS_COARSE_LOCATION}</li>
|
<li>{@link android.Manifest.permission#ACCESS_COARSE_LOCATION}</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<p class="note"><strong>Note:</strong> Not all Android-powered devices support Wi-Fi NAN
|
<p class="note"><strong>Note:</strong> Not all Android-powered devices support Wi-Fi Aware
|
||||||
functionality.
|
functionality.
|
||||||
If your application only works with Wi-Fi NAN (i.e. it should only be installed on devices which
|
If your application only works with Wi-Fi Aware (i.e. it should only be installed on devices which
|
||||||
support Wi-Fi NAN), declare so with a <a
|
support Wi-Fi Aware), declare so with a <a
|
||||||
href="{@docRoot}guide/topics/manifest/uses-feature-element.html">
|
href="{@docRoot}guide/topics/manifest/uses-feature-element.html">
|
||||||
{@code <uses-feature>}</a>
|
{@code <uses-feature>}</a>
|
||||||
element in the manifest file:</p>
|
element in the manifest file:</p>
|
||||||
<pre>
|
<pre>
|
||||||
<manifest ...>
|
<manifest ...>
|
||||||
<uses-feature android:name="android.hardware.wifi.nan" />
|
<uses-feature android:name="android.hardware.wifi.aware" />
|
||||||
...
|
...
|
||||||
</manifest>
|
</manifest>
|
||||||
</pre>
|
</pre>
|
||||||
<p>Alternatively, if you application does not require Wi-Fi NAN but can take advantage of it if
|
<p>Alternatively, if you application does not require Wi-Fi Aware but can take advantage of it if
|
||||||
available, you can perform
|
available, you can perform
|
||||||
the check at run-time in your code using {@link
|
the check at run-time in your code using {@link
|
||||||
android.content.pm.PackageManager#hasSystemFeature(String)} with {@link
|
android.content.pm.PackageManager#hasSystemFeature(String)} with {@link
|
||||||
android.content.pm.PackageManager#FEATURE_WIFI_NAN}:</p>
|
android.content.pm.PackageManager#FEATURE_WIFI_AWARE}:</p>
|
||||||
<pre>
|
<pre>
|
||||||
getPackageManager().hasSystemFeature(PackageManager.FEATURE_WIFI_NAN)
|
getPackageManager().hasSystemFeature(PackageManager.FEATURE_WIFI_AWARE)
|
||||||
</pre>
|
</pre>
|
||||||
</BODY>
|
</BODY>
|
||||||
</HTML>
|
</HTML>
|
||||||
Reference in New Issue
Block a user