Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b84ad806 authored by Etan Cohen's avatar Etan Cohen
Browse files

[AWARE] Remove reason from discovery session terminate callback

Only valid reason is per request (destroy or timeout/count).

Bug: 32670068
Test: unit tests & integration tests (sl4a) passing
Change-Id: I85d417442e26a16d7f09d6d2d4cbb8ae7a9eba7e
parent 3de35a5e
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -93,7 +93,7 @@ public class DiscoverySession {
     *     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 DiscoverySessionCallback#onSessionTerminated(int)}.
     *     {@link DiscoverySessionCallback#onSessionTerminated()}.
     */
     */
    public void destroy() {
    public void destroy() {
        WifiAwareManager mgr = mMgr.get();
        WifiAwareManager mgr = mMgr.get();
+2 −31
Original line number Original line Diff line number Diff line
@@ -16,11 +16,8 @@


package android.net.wifi.aware;
package android.net.wifi.aware;


import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.NonNull;


import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.List;
import java.util.List;


/**
/**
@@ -37,29 +34,6 @@ import java.util.List;
 * @hide PROPOSED_AWARE_API
 * @hide PROPOSED_AWARE_API
 */
 */
public class DiscoverySessionCallback {
public class DiscoverySessionCallback {
    /** @hide */
    @IntDef({
            TERMINATE_REASON_DONE, TERMINATE_REASON_FAIL })
    @Retention(RetentionPolicy.SOURCE)
    public @interface SessionTerminateCodes {
    }

    /**
     * Indicates that publish or subscribe session is done - all the
     * requested operations (per {@link PublishConfig} or
     * {@link SubscribeConfig}) have been executed. Failure reason flag for
     * {@link DiscoverySessionCallback#onSessionTerminated(int)} callback.
     */
    public static final int TERMINATE_REASON_DONE = 100;

    /**
     * Indicates that publish or subscribe session is terminated due to a
     * failure.
     * Failure reason flag for
     * {@link DiscoverySessionCallback#onSessionTerminated(int)} callback.
     */
    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 WifiAwareSession#publish(PublishConfig, DiscoverySessionCallback,
     * {@link WifiAwareSession#publish(PublishConfig, DiscoverySessionCallback,
@@ -114,12 +88,9 @@ public class DiscoverySessionCallback {
     * 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 DiscoverySession#destroy()} or
     * to user-request (either directly through {@link DiscoverySession#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)}).
     *
     * @param reason The termination reason using
     *            {@code DiscoverySessionCallback.TERMINATE_*} codes.
     */
     */
    public void onSessionTerminated(@SessionTerminateCodes int reason) {
    public void onSessionTerminated() {
        /* empty */
        /* empty */
    }
    }


+4 −6
Original line number Original line Diff line number Diff line
@@ -322,9 +322,8 @@ 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 DiscoverySessionCallback#onSessionTerminated(int)}
         * generated for {@link DiscoverySessionCallback#onSessionTerminated()}
         * with {@link DiscoverySessionCallback#TERMINATE_REASON_DONE} [unless
         * [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 DiscoverySession#destroy()} is
         *     Session will be terminated when {@link DiscoverySession#destroy()} is
@@ -348,8 +347,7 @@ 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 DiscoverySessionCallback#onSessionTerminated(int)} with
         * {@link DiscoverySessionCallback#onSessionTerminated()} [unless
         * {@link DiscoverySessionCallback#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.
@@ -371,7 +369,7 @@ public final class PublishConfig implements Parcelable {


        /**
        /**
         * Configure whether a publish terminate notification
         * Configure whether a publish terminate notification
         * {@link DiscoverySessionCallback#onSessionTerminated(int)} is reported
         * {@link DiscoverySessionCallback#onSessionTerminated()} 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
+3 −5
Original line number Original line Diff line number Diff line
@@ -355,8 +355,7 @@ 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 DiscoverySessionCallback#onSessionTerminated(int)}
         * generated for {@link DiscoverySessionCallback#onSessionTerminated()}.
         * with {@link DiscoverySessionCallback#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 DiscoverySession#destroy()} is
         *     Session will be terminated when {@link DiscoverySession#destroy()} is
@@ -380,8 +379,7 @@ 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 DiscoverySessionCallback#onSessionTerminated(int)} with
         * {@link DiscoverySessionCallback#onSessionTerminated()}.
         * {@link DiscoverySessionCallback#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 DiscoverySession#destroy()} is
         *     Session will be terminated when {@link DiscoverySession#destroy()} is
@@ -424,7 +422,7 @@ public final class SubscribeConfig implements Parcelable {


        /**
        /**
         * Configure whether a subscribe terminate notification
         * Configure whether a subscribe terminate notification
         * {@link DiscoverySessionCallback#onSessionTerminated(int)} is reported
         * {@link DiscoverySessionCallback#onSessionTerminated()} 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
+1 −1
Original line number Original line Diff line number Diff line
@@ -32,7 +32,7 @@ import android.util.Log;
 * @hide PROPOSED_AWARE_API
 * @hide PROPOSED_AWARE_API
 */
 */
public class SubscribeDiscoverySession extends DiscoverySession {
public class SubscribeDiscoverySession extends DiscoverySession {
    private static final String TAG = "SubscribeDiscoverySession";
    private static final String TAG = "SubscribeDiscSession";


    /**
    /**
     * {@hide}
     * {@hide}
Loading