[NAN] Add type and nullability annotations. Update hide annotation.
Additional annotations on (what are planned to be) public APIs. Fixed exposed API: @hide to a few new methods. Bug: 27122760 Change-Id: Iea91de1b1c3c32a93378b5d90c1e88d994a10526
This commit is contained in:
@@ -16,9 +16,13 @@
|
||||
|
||||
package android.net.wifi.nan;
|
||||
|
||||
import android.annotation.IntDef;
|
||||
import android.annotation.NonNull;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
@@ -30,6 +34,12 @@ import java.util.Arrays;
|
||||
* @hide PROPOSED_NAN_API
|
||||
*/
|
||||
public class PublishConfig implements Parcelable {
|
||||
@IntDef({
|
||||
PUBLISH_TYPE_UNSOLICITED, PUBLISH_TYPE_SOLICITED })
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface PublishTypes {
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines an unsolicited publish session - i.e. a publish session where
|
||||
* publish packets are transmitted over-the-air. Configuration is done using
|
||||
@@ -327,7 +337,7 @@ public class PublishConfig implements Parcelable {
|
||||
* @return The builder to facilitate chaining
|
||||
* {@code builder.setXXX(..).setXXX(..)}.
|
||||
*/
|
||||
public Builder setServiceName(String serviceName) {
|
||||
public Builder setServiceName(@NonNull String serviceName) {
|
||||
mServiceName = serviceName;
|
||||
return this;
|
||||
}
|
||||
@@ -369,7 +379,7 @@ public class PublishConfig implements Parcelable {
|
||||
* @return The builder to facilitate chaining
|
||||
* {@code builder.setXXX(..).setXXX(..)}.
|
||||
*/
|
||||
public Builder setServiceSpecificInfo(String serviceSpecificInfoStr) {
|
||||
public Builder setServiceSpecificInfo(@NonNull String serviceSpecificInfoStr) {
|
||||
mServiceSpecificInfoLength = serviceSpecificInfoStr.length();
|
||||
mServiceSpecificInfo = serviceSpecificInfoStr.getBytes();
|
||||
return this;
|
||||
@@ -444,7 +454,7 @@ public class PublishConfig implements Parcelable {
|
||||
* @return The builder to facilitate chaining
|
||||
* {@code builder.setXXX(..).setXXX(..)}.
|
||||
*/
|
||||
public Builder setPublishType(int publishType) {
|
||||
public Builder setPublishType(@PublishTypes int publishType) {
|
||||
if (publishType < PUBLISH_TYPE_UNSOLICITED || publishType > PUBLISH_TYPE_SOLICITED) {
|
||||
throw new IllegalArgumentException("Invalid publishType - " + publishType);
|
||||
}
|
||||
|
||||
@@ -16,9 +16,13 @@
|
||||
|
||||
package android.net.wifi.nan;
|
||||
|
||||
import android.annotation.IntDef;
|
||||
import android.annotation.NonNull;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
@@ -30,6 +34,11 @@ import java.util.Arrays;
|
||||
* @hide PROPOSED_NAN_API
|
||||
*/
|
||||
public class SubscribeConfig implements Parcelable {
|
||||
@IntDef({
|
||||
SUBSCRIBE_TYPE_PASSIVE, SUBSCRIBE_TYPE_ACTIVE })
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface SubscribeTypes {
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines a passive subscribe session - i.e. a subscribe session where
|
||||
@@ -46,6 +55,12 @@ public class SubscribeConfig implements Parcelable {
|
||||
*/
|
||||
public static final int SUBSCRIBE_TYPE_ACTIVE = 1;
|
||||
|
||||
@IntDef({
|
||||
MATCH_STYLE_FIRST_ONLY, MATCH_STYLE_ALL })
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface MatchStyles {
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies that only the first match of a set of identical matches (same
|
||||
* publish) will be reported to the subscriber.
|
||||
@@ -354,7 +369,7 @@ public class SubscribeConfig implements Parcelable {
|
||||
* @return The builder to facilitate chaining
|
||||
* {@code builder.setXXX(..).setXXX(..)}.
|
||||
*/
|
||||
public Builder setServiceName(String serviceName) {
|
||||
public Builder setServiceName(@NonNull String serviceName) {
|
||||
mServiceName = serviceName;
|
||||
return this;
|
||||
}
|
||||
@@ -397,7 +412,7 @@ public class SubscribeConfig implements Parcelable {
|
||||
* @return The builder to facilitate chaining
|
||||
* {@code builder.setXXX(..).setXXX(..)}.
|
||||
*/
|
||||
public Builder setServiceSpecificInfo(String serviceSpecificInfoStr) {
|
||||
public Builder setServiceSpecificInfo(@NonNull String serviceSpecificInfoStr) {
|
||||
mServiceSpecificInfoLength = serviceSpecificInfoStr.length();
|
||||
mServiceSpecificInfo = serviceSpecificInfoStr.getBytes();
|
||||
return this;
|
||||
@@ -470,7 +485,7 @@ public class SubscribeConfig implements Parcelable {
|
||||
* @return The builder to facilitate chaining
|
||||
* {@code builder.setXXX(..).setXXX(..)}.
|
||||
*/
|
||||
public Builder setSubscribeType(int subscribeType) {
|
||||
public Builder setSubscribeType(@SubscribeTypes int subscribeType) {
|
||||
if (subscribeType < SUBSCRIBE_TYPE_PASSIVE || subscribeType > SUBSCRIBE_TYPE_ACTIVE) {
|
||||
throw new IllegalArgumentException("Invalid subscribeType - " + subscribeType);
|
||||
}
|
||||
@@ -531,7 +546,7 @@ public class SubscribeConfig implements Parcelable {
|
||||
* @return The builder to facilitate chaining
|
||||
* {@code builder.setXXX(..).setXXX(..)}.
|
||||
*/
|
||||
public Builder setMatchStyle(int matchStyle) {
|
||||
public Builder setMatchStyle(@MatchStyles int matchStyle) {
|
||||
if (matchStyle != MATCH_STYLE_FIRST_ONLY && matchStyle != MATCH_STYLE_ALL) {
|
||||
throw new IllegalArgumentException(
|
||||
"Invalid matchType - must be MATCH_FIRST_ONLY or MATCH_ALL");
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package android.net.wifi.nan;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.annotation.SdkConstant;
|
||||
import android.annotation.SdkConstant.SdkConstantType;
|
||||
import android.os.Binder;
|
||||
@@ -174,7 +176,7 @@ public class WifiNanManager {
|
||||
* connection.
|
||||
* @param callback A callback extended from {@link WifiNanEventCallback}.
|
||||
*/
|
||||
public void connect(Looper looper, WifiNanEventCallback callback) {
|
||||
public void connect(@NonNull Looper looper, @NonNull WifiNanEventCallback callback) {
|
||||
connect(looper, callback, null);
|
||||
}
|
||||
|
||||
@@ -189,7 +191,8 @@ public class WifiNanManager {
|
||||
* @param callback A callback extended from {@link WifiNanEventCallback}.
|
||||
* @param configRequest The requested NAN configuration.
|
||||
*/
|
||||
public void connect(Looper looper, WifiNanEventCallback callback, ConfigRequest configRequest) {
|
||||
public void connect(@NonNull Looper looper, @NonNull WifiNanEventCallback callback,
|
||||
@Nullable ConfigRequest configRequest) {
|
||||
if (VDBG) {
|
||||
Log.v(TAG, "connect(): looper=" + looper + ", callback=" + callback + ", configRequest="
|
||||
+ configRequest);
|
||||
@@ -273,7 +276,8 @@ public class WifiNanManager {
|
||||
* @param callback The {@link WifiNanSessionCallback} derived objects to be
|
||||
* used for the event callbacks specified by {@code events}.
|
||||
*/
|
||||
public void publish(PublishConfig publishConfig, WifiNanSessionCallback callback) {
|
||||
public void publish(@NonNull PublishConfig publishConfig,
|
||||
@NonNull WifiNanSessionCallback callback) {
|
||||
if (VDBG) Log.v(TAG, "publish(): config=" + publishConfig);
|
||||
|
||||
int clientId;
|
||||
@@ -330,7 +334,8 @@ public class WifiNanManager {
|
||||
* @param callback The {@link WifiNanSessionCallback} derived objects to be
|
||||
* used for the event callbacks specified by {@code events}.
|
||||
*/
|
||||
public void subscribe(SubscribeConfig subscribeConfig, WifiNanSessionCallback callback) {
|
||||
public void subscribe(@NonNull SubscribeConfig subscribeConfig,
|
||||
@NonNull WifiNanSessionCallback callback) {
|
||||
if (VDBG) {
|
||||
Log.v(TAG, "subscribe(): config=" + subscribeConfig);
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package android.net.wifi.nan;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.util.Log;
|
||||
|
||||
/**
|
||||
@@ -44,7 +45,7 @@ public class WifiNanPublishSession extends WifiNanSession {
|
||||
* @param publishConfig The configuration ({@link PublishConfig}) of the
|
||||
* publish session.
|
||||
*/
|
||||
public void updatePublish(PublishConfig publishConfig) {
|
||||
public void updatePublish(@NonNull PublishConfig publishConfig) {
|
||||
if (mTerminated) {
|
||||
Log.w(TAG, "updatePublish: called on terminated session");
|
||||
return;
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package android.net.wifi.nan;
|
||||
|
||||
import android.annotation.IntDef;
|
||||
import android.annotation.NonNull;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
@@ -104,7 +105,7 @@ public class WifiNanSessionCallback {
|
||||
* @param session The {@link WifiNanPublishSession} used to control the
|
||||
* discovery session.
|
||||
*/
|
||||
public void onPublishStarted(WifiNanPublishSession session) {
|
||||
public void onPublishStarted(@NonNull WifiNanPublishSession session) {
|
||||
/* empty */
|
||||
}
|
||||
|
||||
@@ -114,7 +115,7 @@ public class WifiNanSessionCallback {
|
||||
* @param session The {@link WifiNanSubscribeSession} used to control the
|
||||
* discovery session.
|
||||
*/
|
||||
public void onSubscribeStarted(WifiNanSubscribeSession session) {
|
||||
public void onSubscribeStarted(@NonNull WifiNanSubscribeSession session) {
|
||||
/* empty */
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package android.net.wifi.nan;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.util.Log;
|
||||
|
||||
/**
|
||||
@@ -44,7 +45,7 @@ public class WifiNanSubscribeSession extends WifiNanSession {
|
||||
* @param subscribeConfig The configuration ({@link SubscribeConfig}) of the
|
||||
* subscribe session.
|
||||
*/
|
||||
public void updateSubscribe(SubscribeConfig subscribeConfig) {
|
||||
public void updateSubscribe(@NonNull SubscribeConfig subscribeConfig) {
|
||||
if (mTerminated) {
|
||||
Log.w(TAG, "updateSubscribe: called on terminated session");
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user