[NAN] Replace session callback configuration control
Controlling session callback invocation:
- Remove event registration
- Add configurations to the subset (actually just termination) which
can be configured through the HAL
(cherry-pick of e393f57d0d)
Bug: 27607613
Change-Id: I608314cc2a9b077b4d5a2d2d0d315d55c6a7724b
This commit is contained in:
@@ -37,7 +37,7 @@ interface IWifiNanManager
|
||||
void requestConfig(int clientId, in ConfigRequest configRequest);
|
||||
|
||||
// session API
|
||||
int createSession(int clientId, in IWifiNanSessionCallback callback, int events);
|
||||
int createSession(int clientId, in IWifiNanSessionCallback callback);
|
||||
void publish(int clientId, int sessionId, in PublishConfig publishConfig);
|
||||
void subscribe(int clientId, int sessionId, in SubscribeConfig subscribeConfig);
|
||||
void sendMessage(int clientId, int sessionId, int peerId, in byte[] message, int messageLength,
|
||||
|
||||
@@ -95,9 +95,15 @@ public class PublishConfig implements Parcelable {
|
||||
*/
|
||||
public final int mTtlSec;
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
public final boolean mEnableTerminateNotification;
|
||||
|
||||
private PublishConfig(String serviceName, byte[] serviceSpecificInfo,
|
||||
int serviceSpecificInfoLength, byte[] txFilter, int txFilterLength, byte[] rxFilter,
|
||||
int rxFilterLength, int publishType, int publichCount, int ttlSec) {
|
||||
int rxFilterLength, int publishType, int publichCount, int ttlSec,
|
||||
boolean enableTerminateNotification) {
|
||||
mServiceName = serviceName;
|
||||
mServiceSpecificInfoLength = serviceSpecificInfoLength;
|
||||
mServiceSpecificInfo = serviceSpecificInfo;
|
||||
@@ -108,6 +114,7 @@ public class PublishConfig implements Parcelable {
|
||||
mPublishType = publishType;
|
||||
mPublishCount = publichCount;
|
||||
mTtlSec = ttlSec;
|
||||
mEnableTerminateNotification = enableTerminateNotification;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -119,7 +126,8 @@ public class PublishConfig implements Parcelable {
|
||||
+ ", mRxFilter="
|
||||
+ (new TlvBufferUtils.TlvIterable(0, 1, mRxFilter, mRxFilterLength)).toString()
|
||||
+ ", mPublishType=" + mPublishType + ", mPublishCount=" + mPublishCount
|
||||
+ ", mTtlSec=" + mTtlSec + "']";
|
||||
+ ", mTtlSec=" + mTtlSec + ", mEnableTerminateNotification="
|
||||
+ mEnableTerminateNotification + "]";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -145,6 +153,7 @@ public class PublishConfig implements Parcelable {
|
||||
dest.writeInt(mPublishType);
|
||||
dest.writeInt(mPublishCount);
|
||||
dest.writeInt(mTtlSec);
|
||||
dest.writeInt(mEnableTerminateNotification ? 1 : 0);
|
||||
}
|
||||
|
||||
public static final Creator<PublishConfig> CREATOR = new Creator<PublishConfig>() {
|
||||
@@ -174,8 +183,11 @@ public class PublishConfig implements Parcelable {
|
||||
int publishType = in.readInt();
|
||||
int publishCount = in.readInt();
|
||||
int ttlSec = in.readInt();
|
||||
boolean enableTerminateNotification = in.readInt() != 0;
|
||||
|
||||
return new PublishConfig(serviceName, ssi, ssiLength, txFilter, txFilterLength,
|
||||
rxFilter, rxFilterLength, publishType, publishCount, ttlSec);
|
||||
rxFilter, rxFilterLength, publishType, publishCount, ttlSec,
|
||||
enableTerminateNotification);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -229,7 +241,8 @@ public class PublishConfig implements Parcelable {
|
||||
}
|
||||
|
||||
return mPublishType == lhs.mPublishType && mPublishCount == lhs.mPublishCount
|
||||
&& mTtlSec == lhs.mTtlSec;
|
||||
&& mTtlSec == lhs.mTtlSec
|
||||
&& mEnableTerminateNotification == lhs.mEnableTerminateNotification;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -246,6 +259,7 @@ public class PublishConfig implements Parcelable {
|
||||
result = 31 * result + mPublishType;
|
||||
result = 31 * result + mPublishCount;
|
||||
result = 31 * result + mTtlSec;
|
||||
result = 31 * result + (mEnableTerminateNotification ? 1 : 0);
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -261,9 +275,10 @@ public class PublishConfig implements Parcelable {
|
||||
private byte[] mTxFilter = new byte[0];
|
||||
private int mRxFilterLength;
|
||||
private byte[] mRxFilter = new byte[0];
|
||||
private int mPublishType;
|
||||
private int mPublishCount;
|
||||
private int mTtlSec;
|
||||
private int mPublishType = PUBLISH_TYPE_UNSOLICITED;
|
||||
private int mPublishCount = 0;
|
||||
private int mTtlSec = 0;
|
||||
private boolean mEnableTerminateNotification = true;
|
||||
|
||||
/**
|
||||
* Specify the service name of the publish session. The actual on-air
|
||||
@@ -437,6 +452,21 @@ public class PublishConfig implements Parcelable {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure whether a publish terminate notification
|
||||
* {@link WifiNanSessionCallback#onPublishTerminated(int)} is reported
|
||||
* back to the callback.
|
||||
*
|
||||
* @param enable If true the terminate callback will be called when the
|
||||
* publish is terminated. Otherwise it will not be called.
|
||||
* @return The builder to facilitate chaining
|
||||
* {@code builder.setXXX(..).setXXX(..)}.
|
||||
*/
|
||||
public Builder setEnableTerminateNotification(boolean enable) {
|
||||
mEnableTerminateNotification = enable;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build {@link PublishConfig} given the current requests made on the
|
||||
* builder.
|
||||
@@ -444,7 +474,7 @@ public class PublishConfig implements Parcelable {
|
||||
public PublishConfig build() {
|
||||
return new PublishConfig(mServiceName, mServiceSpecificInfo, mServiceSpecificInfoLength,
|
||||
mTxFilter, mTxFilterLength, mRxFilter, mRxFilterLength, mPublishType,
|
||||
mPublishCount, mTtlSec);
|
||||
mPublishCount, mTtlSec, mEnableTerminateNotification);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,8 +24,8 @@ import java.util.Arrays;
|
||||
/**
|
||||
* Defines the configuration of a NAN subscribe session. Built using
|
||||
* {@link SubscribeConfig.Builder}. Subscribe is done using
|
||||
* {@link WifiNanManager#subscribe(SubscribeConfig, WifiNanSessionCallback, int)}
|
||||
* or {@link WifiNanSubscribeSession#subscribe(SubscribeConfig)}.
|
||||
* {@link WifiNanManager#subscribe(SubscribeConfig, WifiNanSessionCallback)} or
|
||||
* {@link WifiNanSubscribeSession#subscribe(SubscribeConfig)}.
|
||||
*
|
||||
* @hide PROPOSED_NAN_API
|
||||
*/
|
||||
@@ -113,9 +113,15 @@ public class SubscribeConfig implements Parcelable {
|
||||
*/
|
||||
public final int mMatchStyle;
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
public final boolean mEnableTerminateNotification;
|
||||
|
||||
private SubscribeConfig(String serviceName, byte[] serviceSpecificInfo,
|
||||
int serviceSpecificInfoLength, byte[] txFilter, int txFilterLength, byte[] rxFilter,
|
||||
int rxFilterLength, int subscribeType, int publichCount, int ttlSec, int matchStyle) {
|
||||
int rxFilterLength, int subscribeType, int publichCount, int ttlSec, int matchStyle,
|
||||
boolean enableTerminateNotification) {
|
||||
mServiceName = serviceName;
|
||||
mServiceSpecificInfoLength = serviceSpecificInfoLength;
|
||||
mServiceSpecificInfo = serviceSpecificInfo;
|
||||
@@ -127,6 +133,7 @@ public class SubscribeConfig implements Parcelable {
|
||||
mSubscribeCount = publichCount;
|
||||
mTtlSec = ttlSec;
|
||||
mMatchStyle = matchStyle;
|
||||
mEnableTerminateNotification = enableTerminateNotification;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -138,7 +145,8 @@ public class SubscribeConfig implements Parcelable {
|
||||
+ ", mRxFilter="
|
||||
+ (new TlvBufferUtils.TlvIterable(0, 1, mRxFilter, mRxFilterLength)).toString()
|
||||
+ ", mSubscribeType=" + mSubscribeType + ", mSubscribeCount=" + mSubscribeCount
|
||||
+ ", mTtlSec=" + mTtlSec + ", mMatchType=" + mMatchStyle + "']";
|
||||
+ ", mTtlSec=" + mTtlSec + ", mMatchType=" + mMatchStyle
|
||||
+ ", mEnableTerminateNotification=" + mEnableTerminateNotification + "]";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -165,6 +173,7 @@ public class SubscribeConfig implements Parcelable {
|
||||
dest.writeInt(mSubscribeCount);
|
||||
dest.writeInt(mTtlSec);
|
||||
dest.writeInt(mMatchStyle);
|
||||
dest.writeInt(mEnableTerminateNotification ? 1 : 0);
|
||||
}
|
||||
|
||||
public static final Creator<SubscribeConfig> CREATOR = new Creator<SubscribeConfig>() {
|
||||
@@ -195,8 +204,11 @@ public class SubscribeConfig implements Parcelable {
|
||||
int subscribeCount = in.readInt();
|
||||
int ttlSec = in.readInt();
|
||||
int matchStyle = in.readInt();
|
||||
boolean enableTerminateNotification = in.readInt() != 0;
|
||||
|
||||
return new SubscribeConfig(serviceName, ssi, ssiLength, txFilter, txFilterLength,
|
||||
rxFilter, rxFilterLength, subscribeType, subscribeCount, ttlSec, matchStyle);
|
||||
rxFilter, rxFilterLength, subscribeType, subscribeCount, ttlSec, matchStyle,
|
||||
enableTerminateNotification);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -250,7 +262,8 @@ public class SubscribeConfig implements Parcelable {
|
||||
}
|
||||
|
||||
return mSubscribeType == lhs.mSubscribeType && mSubscribeCount == lhs.mSubscribeCount
|
||||
&& mTtlSec == lhs.mTtlSec && mMatchStyle == lhs.mMatchStyle;
|
||||
&& mTtlSec == lhs.mTtlSec && mMatchStyle == lhs.mMatchStyle
|
||||
&& mEnableTerminateNotification == lhs.mEnableTerminateNotification;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -268,6 +281,7 @@ public class SubscribeConfig implements Parcelable {
|
||||
result = 31 * result + mSubscribeCount;
|
||||
result = 31 * result + mTtlSec;
|
||||
result = 31 * result + mMatchStyle;
|
||||
result = 31 * result + (mEnableTerminateNotification ? 1 : 0);
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -287,6 +301,7 @@ public class SubscribeConfig implements Parcelable {
|
||||
private int mSubscribeCount = 0;
|
||||
private int mTtlSec = 0;
|
||||
private int mMatchStyle = MATCH_STYLE_ALL;
|
||||
private boolean mEnableTerminateNotification = true;
|
||||
|
||||
/**
|
||||
* Specify the service name of the subscribe session. The actual on-air
|
||||
@@ -469,6 +484,21 @@ public class SubscribeConfig implements Parcelable {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure whether a subscribe terminate notification
|
||||
* {@link WifiNanSessionCallback#onSubscribeTerminated(int)} is reported
|
||||
* back to the callback.
|
||||
*
|
||||
* @param enable If true the terminate callback will be called when the
|
||||
* subscribe is terminated. Otherwise it will not be called.
|
||||
* @return The builder to facilitate chaining
|
||||
* {@code builder.setXXX(..).setXXX(..)}.
|
||||
*/
|
||||
public Builder setEnableTerminateNotification(boolean enable) {
|
||||
mEnableTerminateNotification = enable;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build {@link SubscribeConfig} given the current requests made on the
|
||||
* builder.
|
||||
@@ -476,7 +506,8 @@ public class SubscribeConfig implements Parcelable {
|
||||
public SubscribeConfig build() {
|
||||
return new SubscribeConfig(mServiceName, mServiceSpecificInfo,
|
||||
mServiceSpecificInfoLength, mTxFilter, mTxFilterLength, mRxFilter,
|
||||
mRxFilterLength, mSubscribeType, mSubscribeCount, mTtlSec, mMatchStyle);
|
||||
mRxFilterLength, mSubscribeType, mSubscribeCount, mTtlSec, mMatchStyle,
|
||||
mEnableTerminateNotification);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,25 +134,11 @@ public class WifiNanManager {
|
||||
* configuration of the publish session.
|
||||
* @param callback The {@link WifiNanSessionCallback} derived objects to be
|
||||
* used for the event callbacks specified by {@code events}.
|
||||
* @param events The list of events to be delivered to the {@code callback}
|
||||
* object. An OR'd value of {@link WifiNanSessionCallback
|
||||
* WifiNanSessionCallback.LISTEN_*}.
|
||||
* @return The {@link WifiNanPublishSession} which can be used to further
|
||||
* control the publish session.
|
||||
*/
|
||||
public WifiNanPublishSession publish(PublishConfig publishConfig,
|
||||
WifiNanSessionCallback callback, int events) {
|
||||
return publishRaw(publishConfig, callback,
|
||||
events | WifiNanSessionCallback.LISTEN_HIDDEN_FLAGS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Same as publish(*) but does not modify the event flag
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public WifiNanPublishSession publishRaw(PublishConfig publishConfig,
|
||||
WifiNanSessionCallback callback, int events) {
|
||||
WifiNanSessionCallback callback) {
|
||||
if (VDBG) Log.v(TAG, "publish(): config=" + publishConfig);
|
||||
|
||||
if (publishConfig.mPublishType == PublishConfig.PUBLISH_TYPE_UNSOLICITED
|
||||
@@ -172,7 +158,7 @@ public class WifiNanManager {
|
||||
int sessionId;
|
||||
|
||||
try {
|
||||
sessionId = mService.createSession(mClientId, callback.callback, events);
|
||||
sessionId = mService.createSession(mClientId, callback.callback);
|
||||
if (DBG) Log.d(TAG, "publish: session created - sessionId=" + sessionId);
|
||||
mService.publish(mClientId, sessionId, publishConfig);
|
||||
} catch (RemoteException e) {
|
||||
@@ -215,25 +201,11 @@ public class WifiNanManager {
|
||||
* configuration of the subscribe session.
|
||||
* @param callback The {@link WifiNanSessionCallback} derived objects to be
|
||||
* used for the event callbacks specified by {@code events}.
|
||||
* @param events The list of events to be delivered to the {@code callback}
|
||||
* object. An OR'd value of {@link WifiNanSessionCallback
|
||||
* WifiNanSessionCallback.LISTEN_*}.
|
||||
* @return The {@link WifiNanSubscribeSession} which can be used to further
|
||||
* control the subscribe session.
|
||||
*/
|
||||
public WifiNanSubscribeSession subscribe(SubscribeConfig subscribeConfig,
|
||||
WifiNanSessionCallback callback, int events) {
|
||||
return subscribeRaw(subscribeConfig, callback,
|
||||
events | WifiNanSessionCallback.LISTEN_HIDDEN_FLAGS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Same as subscribe(*) but does not modify the event flag
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public WifiNanSubscribeSession subscribeRaw(SubscribeConfig subscribeConfig,
|
||||
WifiNanSessionCallback callback, int events) {
|
||||
WifiNanSessionCallback callback) {
|
||||
if (VDBG) {
|
||||
Log.v(TAG, "subscribe(): config=" + subscribeConfig);
|
||||
}
|
||||
@@ -252,7 +224,7 @@ public class WifiNanManager {
|
||||
int sessionId;
|
||||
|
||||
try {
|
||||
sessionId = mService.createSession(mClientId, callback.callback, events);
|
||||
sessionId = mService.createSession(mClientId, callback.callback);
|
||||
if (DBG) Log.d(TAG, "subscribe: session created - sessionId=" + sessionId);
|
||||
mService.subscribe(mClientId, sessionId, subscribeConfig);
|
||||
} catch (RemoteException e) {
|
||||
|
||||
@@ -26,18 +26,12 @@ import android.util.Log;
|
||||
* Base class for NAN session events callbacks. Should be extended by
|
||||
* applications wanting notifications. The callbacks are registered when a
|
||||
* publish or subscribe session is created using
|
||||
* {@link WifiNanManager#publish(PublishConfig, WifiNanSessionCallback, int)} or
|
||||
* {@link WifiNanManager#subscribe(SubscribeConfig, WifiNanSessionCallback, int)}
|
||||
* . These are callbacks applying to a specific NAN session. Events
|
||||
* corresponding to the NAN link are delivered using
|
||||
* {@link WifiNanEventCallback}.
|
||||
* {@link WifiNanManager#publish(PublishConfig, WifiNanSessionCallback)} or
|
||||
* {@link WifiNanManager#subscribe(SubscribeConfig, WifiNanSessionCallback)} .
|
||||
* These are callbacks applying to a specific NAN session. Events corresponding
|
||||
* to the NAN link are delivered using {@link WifiNanEventCallback}.
|
||||
* <p>
|
||||
* A single callback is registered at session creation - it cannot be replaced.
|
||||
* <p>
|
||||
* During registration specify which specific events are desired using a set of
|
||||
* {@code WifiNanSessionCallback.LISTEN_*} flags OR'd together. Only those
|
||||
* events will be delivered to the registered callback. Override those callbacks
|
||||
* {@code WifiNanSessionCallback.on*} for the registered events.
|
||||
*
|
||||
* @hide PROPOSED_NAN_API
|
||||
*/
|
||||
@@ -46,76 +40,22 @@ public class WifiNanSessionCallback {
|
||||
private static final boolean DBG = false;
|
||||
private static final boolean VDBG = false; // STOPSHIP if true
|
||||
|
||||
/**
|
||||
* Publish fail callback event registration flag. Corresponding callback is
|
||||
* {@link WifiNanSessionCallback#onPublishFail(int)}.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public static final int FLAG_LISTEN_PUBLISH_FAIL = 0x1 << 0;
|
||||
|
||||
/**
|
||||
* Publish terminated callback event registration flag. Corresponding
|
||||
* callback is {@link WifiNanSessionCallback#onPublishTerminated(int)}.
|
||||
*/
|
||||
public static final int FLAG_LISTEN_PUBLISH_TERMINATED = 0x1 << 1;
|
||||
|
||||
/**
|
||||
* Subscribe fail callback event registration flag. Corresponding callback
|
||||
* is {@link WifiNanSessionCallback#onSubscribeFail(int)}.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public static final int FLAG_LISTEN_SUBSCRIBE_FAIL = 0x1 << 2;
|
||||
|
||||
/**
|
||||
* Subscribe terminated callback event registration flag. Corresponding
|
||||
* callback is {@link WifiNanSessionCallback#onSubscribeTerminated(int)}.
|
||||
*/
|
||||
public static final int FLAG_LISTEN_SUBSCRIBE_TERMINATED = 0x1 << 3;
|
||||
|
||||
/**
|
||||
* Match (discovery: publish or subscribe) callback event registration flag.
|
||||
* Corresponding callback is
|
||||
* {@link WifiNanSessionCallback#onMatch(int, byte[], int, byte[], int)}.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public static final int FLAG_LISTEN_MATCH = 0x1 << 4;
|
||||
|
||||
/**
|
||||
* Message sent successfully callback event registration flag. Corresponding
|
||||
* callback is {@link WifiNanSessionCallback#onMessageSendSuccess()}.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public static final int FLAG_LISTEN_MESSAGE_SEND_SUCCESS = 0x1 << 5;
|
||||
|
||||
/**
|
||||
* Message sending failure callback event registration flag. Corresponding
|
||||
* callback is {@link WifiNanSessionCallback#onMessageSendFail(int)}.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public static final int FLAG_LISTEN_MESSAGE_SEND_FAIL = 0x1 << 6;
|
||||
|
||||
/**
|
||||
* Message received callback event registration flag. Corresponding callback
|
||||
* is {@link WifiNanSessionCallback#onMessageReceived(int, byte[], int)}.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public static final int FLAG_LISTEN_MESSAGE_RECEIVED = 0x1 << 7;
|
||||
|
||||
/**
|
||||
* List of hidden events: which are mandatory - i.e. they will be added to
|
||||
* every request.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public static final int LISTEN_HIDDEN_FLAGS = FLAG_LISTEN_PUBLISH_FAIL
|
||||
| FLAG_LISTEN_SUBSCRIBE_FAIL | FLAG_LISTEN_MATCH | FLAG_LISTEN_MESSAGE_SEND_SUCCESS
|
||||
| FLAG_LISTEN_MESSAGE_SEND_FAIL | FLAG_LISTEN_MESSAGE_RECEIVED;
|
||||
/** @hide */
|
||||
public static final int CALLBACK_PUBLISH_FAIL = 0;
|
||||
/** @hide */
|
||||
public static final int CALLBACK_PUBLISH_TERMINATED = 1;
|
||||
/** @hide */
|
||||
public static final int CALLBACK_SUBSCRIBE_FAIL = 2;
|
||||
/** @hide */
|
||||
public static final int CALLBACK_SUBSCRIBE_TERMINATED = 3;
|
||||
/** @hide */
|
||||
public static final int CALLBACK_MATCH = 4;
|
||||
/** @hide */
|
||||
public static final int CALLBACK_MESSAGE_SEND_SUCCESS = 5;
|
||||
/** @hide */
|
||||
public static final int CALLBACK_MESSAGE_SEND_FAIL = 6;
|
||||
/** @hide */
|
||||
public static final int CALLBACK_MESSAGE_RECEIVED = 7;
|
||||
|
||||
/**
|
||||
* Failure reason flag for {@link WifiNanEventCallback} and
|
||||
@@ -192,31 +132,31 @@ public class WifiNanSessionCallback {
|
||||
public void handleMessage(Message msg) {
|
||||
if (DBG) Log.d(TAG, "What=" + msg.what + ", msg=" + msg);
|
||||
switch (msg.what) {
|
||||
case FLAG_LISTEN_PUBLISH_FAIL:
|
||||
case CALLBACK_PUBLISH_FAIL:
|
||||
WifiNanSessionCallback.this.onPublishFail(msg.arg1);
|
||||
break;
|
||||
case FLAG_LISTEN_PUBLISH_TERMINATED:
|
||||
case CALLBACK_PUBLISH_TERMINATED:
|
||||
WifiNanSessionCallback.this.onPublishTerminated(msg.arg1);
|
||||
break;
|
||||
case FLAG_LISTEN_SUBSCRIBE_FAIL:
|
||||
case CALLBACK_SUBSCRIBE_FAIL:
|
||||
WifiNanSessionCallback.this.onSubscribeFail(msg.arg1);
|
||||
break;
|
||||
case FLAG_LISTEN_SUBSCRIBE_TERMINATED:
|
||||
case CALLBACK_SUBSCRIBE_TERMINATED:
|
||||
WifiNanSessionCallback.this.onSubscribeTerminated(msg.arg1);
|
||||
break;
|
||||
case FLAG_LISTEN_MATCH:
|
||||
case CALLBACK_MATCH:
|
||||
WifiNanSessionCallback.this.onMatch(
|
||||
msg.getData().getInt(MESSAGE_BUNDLE_KEY_PEER_ID),
|
||||
msg.getData().getByteArray(MESSAGE_BUNDLE_KEY_MESSAGE), msg.arg1,
|
||||
msg.getData().getByteArray(MESSAGE_BUNDLE_KEY_MESSAGE2), msg.arg2);
|
||||
break;
|
||||
case FLAG_LISTEN_MESSAGE_SEND_SUCCESS:
|
||||
case CALLBACK_MESSAGE_SEND_SUCCESS:
|
||||
WifiNanSessionCallback.this.onMessageSendSuccess(msg.arg1);
|
||||
break;
|
||||
case FLAG_LISTEN_MESSAGE_SEND_FAIL:
|
||||
case CALLBACK_MESSAGE_SEND_FAIL:
|
||||
WifiNanSessionCallback.this.onMessageSendFail(msg.arg1, msg.arg2);
|
||||
break;
|
||||
case FLAG_LISTEN_MESSAGE_RECEIVED:
|
||||
case CALLBACK_MESSAGE_RECEIVED:
|
||||
WifiNanSessionCallback.this.onMessageReceived(msg.arg2,
|
||||
msg.getData().getByteArray(MESSAGE_BUNDLE_KEY_MESSAGE), msg.arg1);
|
||||
break;
|
||||
@@ -240,7 +180,7 @@ public class WifiNanSessionCallback {
|
||||
/**
|
||||
* Called when a publish operation terminates. Event will only be delivered
|
||||
* if registered using
|
||||
* {@link WifiNanSessionCallback#FLAG_LISTEN_PUBLISH_TERMINATED}. A dummy (empty
|
||||
* {@link WifiNanSessionCallback#CALLBACK_PUBLISH_TERMINATED}. A dummy (empty
|
||||
* implementation printing out a warning). Make sure to override if
|
||||
* registered.
|
||||
*
|
||||
@@ -266,7 +206,7 @@ public class WifiNanSessionCallback {
|
||||
/**
|
||||
* Called when a subscribe operation terminates. Event will only be
|
||||
* delivered if registered using
|
||||
* {@link WifiNanSessionCallback#FLAG_LISTEN_SUBSCRIBE_TERMINATED}. A dummy
|
||||
* {@link WifiNanSessionCallback#CALLBACK_SUBSCRIBE_TERMINATED}. A dummy
|
||||
* (empty implementation printing out a warning). Make sure to override if
|
||||
* registered.
|
||||
*
|
||||
@@ -353,7 +293,7 @@ public class WifiNanSessionCallback {
|
||||
public void onPublishFail(int reason) {
|
||||
if (VDBG) Log.v(TAG, "onPublishFail: reason=" + reason);
|
||||
|
||||
Message msg = mHandler.obtainMessage(FLAG_LISTEN_PUBLISH_FAIL);
|
||||
Message msg = mHandler.obtainMessage(CALLBACK_PUBLISH_FAIL);
|
||||
msg.arg1 = reason;
|
||||
mHandler.sendMessage(msg);
|
||||
}
|
||||
@@ -362,7 +302,7 @@ public class WifiNanSessionCallback {
|
||||
public void onPublishTerminated(int reason) {
|
||||
if (VDBG) Log.v(TAG, "onPublishResponse: reason=" + reason);
|
||||
|
||||
Message msg = mHandler.obtainMessage(FLAG_LISTEN_PUBLISH_TERMINATED);
|
||||
Message msg = mHandler.obtainMessage(CALLBACK_PUBLISH_TERMINATED);
|
||||
msg.arg1 = reason;
|
||||
mHandler.sendMessage(msg);
|
||||
}
|
||||
@@ -371,7 +311,7 @@ public class WifiNanSessionCallback {
|
||||
public void onSubscribeFail(int reason) {
|
||||
if (VDBG) Log.v(TAG, "onSubscribeFail: reason=" + reason);
|
||||
|
||||
Message msg = mHandler.obtainMessage(FLAG_LISTEN_SUBSCRIBE_FAIL);
|
||||
Message msg = mHandler.obtainMessage(CALLBACK_SUBSCRIBE_FAIL);
|
||||
msg.arg1 = reason;
|
||||
mHandler.sendMessage(msg);
|
||||
}
|
||||
@@ -380,7 +320,7 @@ public class WifiNanSessionCallback {
|
||||
public void onSubscribeTerminated(int reason) {
|
||||
if (VDBG) Log.v(TAG, "onSubscribeTerminated: reason=" + reason);
|
||||
|
||||
Message msg = mHandler.obtainMessage(FLAG_LISTEN_SUBSCRIBE_TERMINATED);
|
||||
Message msg = mHandler.obtainMessage(CALLBACK_SUBSCRIBE_TERMINATED);
|
||||
msg.arg1 = reason;
|
||||
mHandler.sendMessage(msg);
|
||||
}
|
||||
@@ -395,7 +335,7 @@ public class WifiNanSessionCallback {
|
||||
data.putByteArray(MESSAGE_BUNDLE_KEY_MESSAGE, serviceSpecificInfo);
|
||||
data.putByteArray(MESSAGE_BUNDLE_KEY_MESSAGE2, matchFilter);
|
||||
|
||||
Message msg = mHandler.obtainMessage(FLAG_LISTEN_MATCH);
|
||||
Message msg = mHandler.obtainMessage(CALLBACK_MATCH);
|
||||
msg.arg1 = serviceSpecificInfoLength;
|
||||
msg.arg2 = matchFilterLength;
|
||||
msg.setData(data);
|
||||
@@ -406,7 +346,7 @@ public class WifiNanSessionCallback {
|
||||
public void onMessageSendSuccess(int messageId) {
|
||||
if (VDBG) Log.v(TAG, "onMessageSendSuccess");
|
||||
|
||||
Message msg = mHandler.obtainMessage(FLAG_LISTEN_MESSAGE_SEND_SUCCESS);
|
||||
Message msg = mHandler.obtainMessage(CALLBACK_MESSAGE_SEND_SUCCESS);
|
||||
msg.arg1 = messageId;
|
||||
mHandler.sendMessage(msg);
|
||||
}
|
||||
@@ -415,7 +355,7 @@ public class WifiNanSessionCallback {
|
||||
public void onMessageSendFail(int messageId, int reason) {
|
||||
if (VDBG) Log.v(TAG, "onMessageSendFail: reason=" + reason);
|
||||
|
||||
Message msg = mHandler.obtainMessage(FLAG_LISTEN_MESSAGE_SEND_FAIL);
|
||||
Message msg = mHandler.obtainMessage(CALLBACK_MESSAGE_SEND_FAIL);
|
||||
msg.arg1 = messageId;
|
||||
msg.arg2 = reason;
|
||||
mHandler.sendMessage(msg);
|
||||
@@ -431,7 +371,7 @@ public class WifiNanSessionCallback {
|
||||
Bundle data = new Bundle();
|
||||
data.putByteArray(MESSAGE_BUNDLE_KEY_MESSAGE, message);
|
||||
|
||||
Message msg = mHandler.obtainMessage(FLAG_LISTEN_MESSAGE_RECEIVED);
|
||||
Message msg = mHandler.obtainMessage(CALLBACK_MESSAGE_RECEIVED);
|
||||
msg.arg1 = messageLength;
|
||||
msg.arg2 = peerId;
|
||||
msg.setData(data);
|
||||
|
||||
Reference in New Issue
Block a user