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

Commit 6ed82dc6 authored by Brad Ebinger's avatar Brad Ebinger Committed by android-build-merger
Browse files

Merge "Adds a filtering bitmask to DownloadStateCallback" am: 177bd652

am: 387b90aa

Change-Id: I4332a7f839aec731acaafbb9fa6213f2ada39857
parents 91c55f18 387b90aa
Loading
Loading
Loading
Loading
+5 −0
Original line number Original line Diff line number Diff line
@@ -40476,8 +40476,13 @@ package android.telephony.mbms {
  public class DownloadStateCallback {
  public class DownloadStateCallback {
    ctor public DownloadStateCallback();
    ctor public DownloadStateCallback();
    ctor public DownloadStateCallback(int);
    method public final boolean isFilterFlagSet(int);
    method public void onProgressUpdated(android.telephony.mbms.DownloadRequest, android.telephony.mbms.FileInfo, int, int, int, int);
    method public void onProgressUpdated(android.telephony.mbms.DownloadRequest, android.telephony.mbms.FileInfo, int, int, int, int);
    method public void onStateUpdated(android.telephony.mbms.DownloadRequest, android.telephony.mbms.FileInfo, int);
    method public void onStateUpdated(android.telephony.mbms.DownloadRequest, android.telephony.mbms.FileInfo, int);
    field public static final int ALL_UPDATES = 0; // 0x0
    field public static final int PROGRESS_UPDATES = 1; // 0x1
    field public static final int STATE_UPDATES = 2; // 0x2
  }
  }
  public final class FileInfo implements android.os.Parcelable {
  public final class FileInfo implements android.os.Parcelable {
+5 −0
Original line number Original line Diff line number Diff line
@@ -43996,8 +43996,13 @@ package android.telephony.mbms {
  public class DownloadStateCallback {
  public class DownloadStateCallback {
    ctor public DownloadStateCallback();
    ctor public DownloadStateCallback();
    ctor public DownloadStateCallback(int);
    method public final boolean isFilterFlagSet(int);
    method public void onProgressUpdated(android.telephony.mbms.DownloadRequest, android.telephony.mbms.FileInfo, int, int, int, int);
    method public void onProgressUpdated(android.telephony.mbms.DownloadRequest, android.telephony.mbms.FileInfo, int, int, int, int);
    method public void onStateUpdated(android.telephony.mbms.DownloadRequest, android.telephony.mbms.FileInfo, int);
    method public void onStateUpdated(android.telephony.mbms.DownloadRequest, android.telephony.mbms.FileInfo, int);
    field public static final int ALL_UPDATES = 0; // 0x0
    field public static final int PROGRESS_UPDATES = 1; // 0x1
    field public static final int STATE_UPDATES = 2; // 0x2
  }
  }
  public final class FileInfo implements android.os.Parcelable {
  public final class FileInfo implements android.os.Parcelable {
+5 −0
Original line number Original line Diff line number Diff line
@@ -40700,8 +40700,13 @@ package android.telephony.mbms {
  public class DownloadStateCallback {
  public class DownloadStateCallback {
    ctor public DownloadStateCallback();
    ctor public DownloadStateCallback();
    ctor public DownloadStateCallback(int);
    method public final boolean isFilterFlagSet(int);
    method public void onProgressUpdated(android.telephony.mbms.DownloadRequest, android.telephony.mbms.FileInfo, int, int, int, int);
    method public void onProgressUpdated(android.telephony.mbms.DownloadRequest, android.telephony.mbms.FileInfo, int, int, int, int);
    method public void onStateUpdated(android.telephony.mbms.DownloadRequest, android.telephony.mbms.FileInfo, int);
    method public void onStateUpdated(android.telephony.mbms.DownloadRequest, android.telephony.mbms.FileInfo, int);
    field public static final int ALL_UPDATES = 0; // 0x0
    field public static final int PROGRESS_UPDATES = 1; // 0x1
    field public static final int STATE_UPDATES = 2; // 0x2
  }
  }
  public final class FileInfo implements android.os.Parcelable {
  public final class FileInfo implements android.os.Parcelable {
+3 −3
Original line number Original line Diff line number Diff line
@@ -522,8 +522,7 @@ public class MbmsDownloadSession implements AutoCloseable {
     * @param handler The {@link Handler} on which calls to {@code callback} should be enqueued on.
     * @param handler The {@link Handler} on which calls to {@code callback} should be enqueued on.
     */
     */
    public void registerStateCallback(@NonNull DownloadRequest request,
    public void registerStateCallback(@NonNull DownloadRequest request,
            @NonNull DownloadStateCallback callback,
            @NonNull DownloadStateCallback callback, @NonNull Handler handler) {
            @NonNull Handler handler) {
        IMbmsDownloadService downloadService = mService.get();
        IMbmsDownloadService downloadService = mService.get();
        if (downloadService == null) {
        if (downloadService == null) {
            throw new IllegalStateException("Middleware not yet bound");
            throw new IllegalStateException("Middleware not yet bound");
@@ -533,7 +532,8 @@ public class MbmsDownloadSession implements AutoCloseable {
                new InternalDownloadStateCallback(callback, handler);
                new InternalDownloadStateCallback(callback, handler);


        try {
        try {
            int result = downloadService.registerStateCallback(request, internalCallback);
            int result = downloadService.registerStateCallback(request, internalCallback,
                    callback.getCallbackFilterFlags());
            if (result != MbmsErrors.SUCCESS) {
            if (result != MbmsErrors.SUCCESS) {
                if (result == MbmsErrors.DownloadErrors.ERROR_UNKNOWN_DOWNLOAD_REQUEST) {
                if (result == MbmsErrors.DownloadErrors.ERROR_UNKNOWN_DOWNLOAD_REQUEST) {
                    throw new IllegalArgumentException("Unknown download request.");
                    throw new IllegalArgumentException("Unknown download request.");
+69 −0
Original line number Original line Diff line number Diff line
@@ -16,8 +16,12 @@


package android.telephony.mbms;
package android.telephony.mbms;


import android.annotation.IntDef;
import android.telephony.MbmsDownloadSession;
import android.telephony.MbmsDownloadSession;


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

/**
/**
 * A optional listener class used by download clients to track progress. Apps should extend this
 * A optional listener class used by download clients to track progress. Apps should extend this
 * class and pass an instance into
 * class and pass an instance into
@@ -28,6 +32,71 @@ import android.telephony.MbmsDownloadSession;
 */
 */
public class DownloadStateCallback {
public class DownloadStateCallback {


    /**
     * Bitmask flags used for filtering out callback methods. Used when constructing the
     * DownloadStateCallback as an optional parameter.
     * @hide
     */
    @Retention(RetentionPolicy.SOURCE)
    @IntDef({ALL_UPDATES, PROGRESS_UPDATES, STATE_UPDATES})
    public @interface FilterFlag {}

    /**
     * Receive all callbacks.
     * Default value.
     */
    public static final int ALL_UPDATES = 0x00;
    /**
     * Receive callbacks for {@link #onProgressUpdated}.
     */
    public static final int PROGRESS_UPDATES = 0x01;
    /**
     * Receive callbacks for {@link #onStateUpdated}.
     */
    public static final int STATE_UPDATES = 0x02;

    private final int mCallbackFilterFlags;

    /**
     * Creates a DownloadStateCallback that will receive all callbacks.
     */
    public DownloadStateCallback() {
        mCallbackFilterFlags = ALL_UPDATES;
    }

    /**
     * Creates a DownloadStateCallback that will only receive callbacks for the methods specified
     * via the filterFlags parameter.
     * @param filterFlags A bitmask of filter flags that will specify which callback this instance
     *     is interested in.
     */
    public DownloadStateCallback(int filterFlags) {
        mCallbackFilterFlags = filterFlags;
    }

    /**
     * Return the currently set filter flags.
     * @return An integer containing the bitmask of flags that this instance is interested in.
     * @hide
     */
    public int getCallbackFilterFlags() {
        return mCallbackFilterFlags;
    }

    /**
     * Returns true if a filter flag is set for a particular callback method. If the flag is set,
     * the callback will be delivered to the listening process.
     * @param flag A filter flag specifying whether or not a callback method is registered to
     *     receive callbacks.
     * @return true if registered to receive callbacks in the listening process, false if not.
     */
    public final boolean isFilterFlagSet(@FilterFlag int flag) {
        if (mCallbackFilterFlags == ALL_UPDATES) {
            return true;
        }
        return (mCallbackFilterFlags & flag) > 0;
    }

    /**
    /**
     * Called when the middleware wants to report progress for a file in a {@link DownloadRequest}.
     * Called when the middleware wants to report progress for a file in a {@link DownloadRequest}.
     *
     *
Loading