C# Class ExpansionDownloader.Service.DownloaderService

The downloader service.
Inheritance: ExpansionDownloader.Service.CustomIntentService, IDownloaderService
Exibir arquivo Open project: mattleibow/Android.Play.ExpansionLibrary Class Usage Examples

Public Properties

Property Type Description
MaxRetryAfter int

Private Properties

Property Type Description
CancelAlarms void
GetNetworkAvailabilityState NetworkDisabledState
GetNetworkState NetworkState
HandleFileUpdated bool
PollNetworkState void
ScheduleAlarm void
UpdateLvl void
UpdateNetworkState void

Public Methods

Method Description
GenerateSaveFile ( string filename, long filesize ) : string

Creates a filename (where the file should be saved) from info about a download.

GenerateTempSaveFileName ( string fileName ) : string

Returns the filename (where the file should be saved) from info about a download

GetLogMessageForNetworkError ( NetworkDisabledState networkError ) : string

a non-localized string appropriate for logging corresponding to one of the NETWORK_* constants.

NotifyUpdateBytes ( long totalBytesSoFar ) : void

Calculating a moving average for the speed so we don't get jumpy calculations for time etc.

OnBind ( Android.Content.Intent intent ) : IBinder

The on bind.

OnClientUpdated ( Messenger messenger ) : void

The on client updated.

OnCreate ( ) : void

The on create.

OnDestroy ( ) : void

The on destroy.

RequestAbortDownload ( ) : void

The request abort download.

RequestContinueDownload ( ) : void

The request continue download.

RequestDownloadStatus ( ) : void

The request download status.

RequestPauseDownload ( ) : void

The request pause download.

SetDownloadFlags ( ServiceFlags flags ) : void

The set download flags.

StartDownloadServiceIfRequired ( Android.Content.Context context, Android.Content.Intent intent, Type serviceType ) : DownloadServiceRequirement

This version assumes that the intent contains the pending intent as a parameter. This is used for responding to alarms. The pending intent must be in an extra with the key DownloaderService#PendingIntent.

StartDownloadServiceIfRequired ( Android.Content.Context context, Android.App.PendingIntent pendingIntent, Type serviceType ) : DownloadServiceRequirement

Starts the download if necessary.

This function starts a flow that does many things: 1) Checks to see if the APK version has been checked and the metadata database updated 2) If the APK version does not match, checks the new LVL status to see if a new download is required 3) If the APK version does match, then checks to see if the download(s) have been completed 4) If the downloads have been completed, returns DownloadServiceRequirement.NoDownloadRequired The idea is that this can be called during the startup of an application to quickly ascertain if the application needs to wait to hear about any updated APK expansion files. This does mean that the application MUST be run with a network connection for the first time, even if Market delivers all of the files.

Protected Methods

Method Description
DownloaderService ( ) : System

Initializes a new instance of the DownloaderService class.

OnHandleIntent ( Android.Content.Intent intent ) : void

This is the main thread for the Downloader. This thread is responsible for queuing up downloads and other goodness.

ShouldStop ( ) : bool

Returns a value indicating whether the downloader should stop. This will return True if all the downloads are complete.

Private Methods

Method Description
CancelAlarms ( ) : void

The cancel alarms.

GetNetworkAvailabilityState ( ) : NetworkDisabledState

The get network availability state.

GetNetworkState ( NetworkInfo info ) : NetworkState

Updates the network type based upon the info returned from the connectivity manager.

HandleFileUpdated ( string filename, long fileSize ) : bool

The APK has been updated and a filename has been sent down from the Market call. If the file has the same name as the previous file, we do nothing as the file is guaranteed to be the same. If the file does not have the same name, we download it if it hasn't already been delivered by Market.

PollNetworkState ( ) : void

Polls the network state, setting the flags appropriately.

ScheduleAlarm ( int wakeUp ) : void

The schedule alarm.

UpdateLvl ( DownloaderService context ) : void

Updates the LVL information from the server.

UpdateNetworkState ( NetworkInfo info ) : void

The update network state.

Method Details

DownloaderService() protected method

Initializes a new instance of the DownloaderService class.
protected DownloaderService ( ) : System
return System

GenerateSaveFile() public method

Creates a filename (where the file should be saved) from info about a download.
public GenerateSaveFile ( string filename, long filesize ) : string
filename string /// The filename. ///
filesize long /// The filesize. ///
return string

GenerateTempSaveFileName() public method

Returns the filename (where the file should be saved) from info about a download
public GenerateTempSaveFileName ( string fileName ) : string
fileName string /// The file Name. ///
return string

GetLogMessageForNetworkError() public method

a non-localized string appropriate for logging corresponding to one of the NETWORK_* constants.
public GetLogMessageForNetworkError ( NetworkDisabledState networkError ) : string
networkError NetworkDisabledState /// The network Error. ///
return string

NotifyUpdateBytes() public method

Calculating a moving average for the speed so we don't get jumpy calculations for time etc.
public NotifyUpdateBytes ( long totalBytesSoFar ) : void
totalBytesSoFar long /// The total Bytes So Far. ///
return void

OnBind() public method

The on bind.
public OnBind ( Android.Content.Intent intent ) : IBinder
intent Android.Content.Intent /// The intent. ///
return IBinder

OnClientUpdated() public method

The on client updated.
public OnClientUpdated ( Messenger messenger ) : void
messenger Messenger /// The client messenger. ///
return void

OnCreate() public method

The on create.
public OnCreate ( ) : void
return void

OnDestroy() public method

The on destroy.
public OnDestroy ( ) : void
return void

OnHandleIntent() protected method

This is the main thread for the Downloader. This thread is responsible for queuing up downloads and other goodness.
protected OnHandleIntent ( Android.Content.Intent intent ) : void
intent Android.Content.Intent /// The intent that was recieved. ///
return void

RequestAbortDownload() public method

The request abort download.
public RequestAbortDownload ( ) : void
return void

RequestContinueDownload() public method

The request continue download.
public RequestContinueDownload ( ) : void
return void

RequestDownloadStatus() public method

The request download status.
public RequestDownloadStatus ( ) : void
return void

RequestPauseDownload() public method

The request pause download.
public RequestPauseDownload ( ) : void
return void

SetDownloadFlags() public method

The set download flags.
public SetDownloadFlags ( ServiceFlags flags ) : void
flags ServiceFlags /// The flags. ///
return void

ShouldStop() protected method

Returns a value indicating whether the downloader should stop. This will return True if all the downloads are complete.
protected ShouldStop ( ) : bool
return bool

StartDownloadServiceIfRequired() public static method

This version assumes that the intent contains the pending intent as a parameter. This is used for responding to alarms. The pending intent must be in an extra with the key DownloaderService#PendingIntent.
public static StartDownloadServiceIfRequired ( Android.Content.Context context, Android.Content.Intent intent, Type serviceType ) : DownloadServiceRequirement
context Android.Content.Context /// Your application Context. ///
intent Android.Content.Intent /// An Intent to start the Activity in your application that /// shows the download progress and which will also start the /// application when downloadcompletes. ///
serviceType System.Type /// The type of the service to start. ///
return DownloadServiceRequirement

StartDownloadServiceIfRequired() public static method

Starts the download if necessary.
This function starts a flow that does many things: 1) Checks to see if the APK version has been checked and the metadata database updated 2) If the APK version does not match, checks the new LVL status to see if a new download is required 3) If the APK version does match, then checks to see if the download(s) have been completed 4) If the downloads have been completed, returns DownloadServiceRequirement.NoDownloadRequired The idea is that this can be called during the startup of an application to quickly ascertain if the application needs to wait to hear about any updated APK expansion files. This does mean that the application MUST be run with a network connection for the first time, even if Market delivers all of the files.
public static StartDownloadServiceIfRequired ( Android.Content.Context context, Android.App.PendingIntent pendingIntent, Type serviceType ) : DownloadServiceRequirement
context Android.Content.Context /// Your application Context. ///
pendingIntent Android.App.PendingIntent /// A PendingIntent to start the Activity in your application that /// shows the download progress and which will also start the /// application when downloadcompletes. ///
serviceType System.Type /// The class of your implementation. ///
return DownloadServiceRequirement

Property Details

MaxRetryAfter public_oe static_oe property

The maximum amount of time that the download manager accepts for a Retry-After response header with a parameter in delta-seconds.
public static int MaxRetryAfter
return int