diff options
author | Justin Klaassen <justinklaassen@google.com> | 2017-10-10 15:20:13 -0400 |
---|---|---|
committer | Justin Klaassen <justinklaassen@google.com> | 2017-10-10 15:20:13 -0400 |
commit | 93b7ee4fce01df52a6607f0b1965cbafdfeaf1a6 (patch) | |
tree | 49f76f879a89c256a4f65b674086be50760bdffb /android/telephony/mbms/DownloadStateCallback.java | |
parent | bc81c7ada5aab3806dd0b17498f5c9672c9b33c4 (diff) | |
download | android-28-93b7ee4fce01df52a6607f0b1965cbafdfeaf1a6.tar.gz |
Import Android SDK Platform P [4386628]
/google/data/ro/projects/android/fetch_artifact \
--bid 4386628 \
--target sdk_phone_armv7-win_sdk \
sdk-repo-linux-sources-4386628.zip
AndroidVersion.ApiLevel has been modified to appear as 28
Change-Id: I9b8400ac92116cae4f033d173f7a5682b26ccba9
Diffstat (limited to 'android/telephony/mbms/DownloadStateCallback.java')
-rw-r--r-- | android/telephony/mbms/DownloadStateCallback.java | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/android/telephony/mbms/DownloadStateCallback.java b/android/telephony/mbms/DownloadStateCallback.java index 86920bd3..892fbf07 100644 --- a/android/telephony/mbms/DownloadStateCallback.java +++ b/android/telephony/mbms/DownloadStateCallback.java @@ -16,8 +16,12 @@ package android.telephony.mbms; +import android.annotation.IntDef; 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 * class and pass an instance into @@ -29,6 +33,71 @@ import android.telephony.MbmsDownloadSession; 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}. * * @param request a {@link DownloadRequest}, indicating which download is being referenced. |