Class SensusServiceHelper
Provides platform-independent functionality.
Inheritance
System.Object
SensusServiceHelper
Assembly: SensusAndroid.dll
Syntax
public abstract class SensusServiceHelper : Object, ISensusServiceHelper
Constructors
SensusServiceHelper()
Declaration
protected SensusServiceHelper()
Fields
APP_CENTER_KEY_ANDROID
App Center key for Android app. To obtain this key, create a new Xamarin Android app within the Microsoft App Center. This
is optional. If you do not provide this key, then Sensus will not send Android crash reports and remote health telemetry
to the App Center.
Declaration
public const string APP_CENTER_KEY_ANDROID = ""
Field Value
Type |
Description |
System.String |
|
APP_CENTER_KEY_IOS
App Center key for iOS app. To obtain this key, create a new Xamarin iOS app within the Microsoft App Center. This
is optional. If you do not provide this key, then Sensus will not send iOS crash reports and remote health telemetry
to the App Center.
Declaration
public const string APP_CENTER_KEY_IOS = ""
Field Value
Type |
Description |
System.String |
|
BUILD_ID
The build ID, used to tag each Datum. This is an arbitrary string value, and it is optional.
Declaration
public const string BUILD_ID = ""
Field Value
Type |
Description |
System.String |
|
ENCRYPTION_KEY
The 64-character hex-encoded string for a 256-bit symmetric AES encryption key. Used to secure protocols for distribution. Can be generated with the following command:
openssl enc -aes-256-cbc -k secret -P -md sha1
The above was adapted from this guide.
This is mandatory.
Declaration
public const string ENCRYPTION_KEY = ""
Field Value
Type |
Description |
System.String |
|
HEALTH_TEST_DELAY
The health test interval.
Declaration
public static readonly TimeSpan HEALTH_TEST_DELAY
Field Value
Type |
Description |
System.TimeSpan |
|
JSON_SERIALIZER_SETTINGS
Declaration
public static readonly JsonSerializerSettings JSON_SERIALIZER_SETTINGS
Field Value
Type |
Description |
Newtonsoft.Json.JsonSerializerSettings |
|
PARTICIPATION_VERIFICATION_TIMEOUT_SECONDS
Declaration
public const int PARTICIPATION_VERIFICATION_TIMEOUT_SECONDS = 60
Field Value
Type |
Description |
System.Int32 |
|
SHARE_DIRECTORY
Declaration
public static readonly string SHARE_DIRECTORY
Field Value
Type |
Description |
System.String |
|
Properties
BarcodeWriter
Declaration
public BarcodeWriter BarcodeWriter { get; }
Property Value
Type |
Description |
ZXing.Mobile.BarcodeWriter |
|
BatteryChargePercent
Declaration
public abstract float BatteryChargePercent { get; }
Property Value
Type |
Description |
System.Single |
|
DeviceId
Declaration
public abstract string DeviceId { get; }
Property Value
Type |
Description |
System.String |
|
DeviceManufacturer
Declaration
public abstract string DeviceManufacturer { get; }
Property Value
Type |
Description |
System.String |
|
DeviceModel
Declaration
public abstract string DeviceModel { get; }
Property Value
Type |
Description |
System.String |
|
FlashNotificationsEnabled
Declaration
public bool FlashNotificationsEnabled { get; set; }
Property Value
Type |
Description |
System.Boolean |
|
GpsDesiredAccuracyMeters
Declaration
public float GpsDesiredAccuracyMeters { get; }
Property Value
Type |
Description |
System.Single |
|
GpsMinDistanceDelayMeters
Declaration
public float GpsMinDistanceDelayMeters { get; }
Property Value
Type |
Description |
System.Single |
|
GpsMinTimeDelayMS
Declaration
public int GpsMinTimeDelayMS { get; }
Property Value
Type |
Description |
System.Int32 |
|
IsCharging
Declaration
public abstract bool IsCharging { get; }
Property Value
Type |
Description |
System.Boolean |
|
Logger
Declaration
public ILogger Logger { get; }
Property Value
OperatingSystem
Declaration
public abstract string OperatingSystem { get; }
Property Value
Type |
Description |
System.String |
|
PointsOfInterest
Declaration
public List<PointOfInterest> PointsOfInterest { get; }
Property Value
PushNotificationToken
Declaration
public abstract string PushNotificationToken { get; }
Property Value
Type |
Description |
System.String |
|
RegisteredProtocols
Declaration
public ConcurrentObservableCollection<Protocol> RegisteredProtocols { get; }
Property Value
RunningProtocolIds
Declaration
public List<string> RunningProtocolIds { get; }
Property Value
Type |
Description |
System.Collections.Generic.List<System.String> |
|
ScriptsToRun
Declaration
public ConcurrentObservableCollection<Script> ScriptsToRun { get; }
Property Value
Version
Declaration
public abstract string Version { get; }
Property Value
Type |
Description |
System.String |
|
WiFiConnected
Declaration
public abstract bool WiFiConnected { get; }
Property Value
Type |
Description |
System.Boolean |
|
Methods
AddRunningProtocolIdAsync(String)
Declaration
public Task AddRunningProtocolIdAsync(string id)
Parameters
Type |
Name |
Description |
System.String |
id |
|
Returns
Type |
Description |
System.Threading.Tasks.Task |
|
AddScriptAsync(Script, RunMode)
Declaration
public Task AddScriptAsync(Script script, RunMode runMode)
Parameters
Returns
Type |
Description |
System.Threading.Tasks.Task |
|
CancelPendingSurveysNotification()
Declaration
public void CancelPendingSurveysNotification()
ClearScriptsAsync()
Declaration
public Task<bool> ClearScriptsAsync()
Returns
Type |
Description |
System.Threading.Tasks.Task<System.Boolean> |
|
ClearSingleton()
Declaration
public static void ClearSingleton()
Declaration
public string ConvertJsonForCrossPlatform(string json)
Parameters
Type |
Name |
Description |
System.String |
json |
|
Returns
Type |
Description |
System.String |
|
DisableBluetoothAsync(Boolean, Boolean, String)
Declaration
public abstract Task<bool> DisableBluetoothAsync(bool reenable, bool lowEnergy, string rationale)
Parameters
Type |
Name |
Description |
System.Boolean |
reenable |
|
System.Boolean |
lowEnergy |
|
System.String |
rationale |
|
Returns
Type |
Description |
System.Threading.Tasks.Task<System.Boolean> |
|
EnableBluetoothAsync(Boolean, String)
Declaration
public abstract Task<bool> EnableBluetoothAsync(bool lowEnergy, string rationale)
Parameters
Type |
Name |
Description |
System.Boolean |
lowEnergy |
|
System.String |
rationale |
|
Returns
Type |
Description |
System.Threading.Tasks.Task<System.Boolean> |
|
EnableProbeWhenEnablingAll(Probe)
The user can enable all probes at once. When this is done, it doesn't make sense to enable, e.g., the
listening location probe as well as the polling location probe. This method allows the platforms to
decide which probes to enable when enabling all probes.
Declaration
public abstract bool EnableProbeWhenEnablingAll(Probe probe)
Parameters
Type |
Name |
Description |
Probe |
probe |
Probe.
|
Returns
Type |
Description |
System.Boolean |
true , if probe should be enabled, false otherwise.
|
FlashNotificationAsync(String)
Declaration
public Task FlashNotificationAsync(string message)
Parameters
Type |
Name |
Description |
System.String |
message |
Message.
|
Returns
Type |
Description |
System.Threading.Tasks.Task |
The notification async.
|
Get()
Declaration
public static SensusServiceHelper Get()
Returns
GetDirectorySizeMB(String)
Declaration
public static double GetDirectorySizeMB(string directory)
Parameters
Type |
Name |
Description |
System.String |
directory |
|
Returns
Type |
Description |
System.Double |
|
GetFileSizeMB(String[])
Declaration
public static double GetFileSizeMB(params string[] paths)
Parameters
Type |
Name |
Description |
System.String[] |
paths |
|
Returns
Type |
Description |
System.Double |
|
GetHash(String)
Declaration
public string GetHash(string s)
Parameters
Type |
Name |
Description |
System.String |
s |
|
Returns
Type |
Description |
System.String |
|
Declaration
public void GetPositionsFromMapAsync(string address, string newPinName, Action<List<Position>> callback)
Parameters
Type |
Name |
Description |
System.String |
address |
|
System.String |
newPinName |
|
System.Action<System.Collections.Generic.List<Xamarin.Forms.Maps.Position>> |
callback |
|
Declaration
public void GetPositionsFromMapAsync(Position address, string newPinName, Action<List<Position>> callback)
Parameters
Type |
Name |
Description |
Xamarin.Forms.Maps.Position |
address |
|
System.String |
newPinName |
|
System.Action<System.Collections.Generic.List<Xamarin.Forms.Maps.Position>> |
callback |
|
GetQrCodeImageSource(String)
Declaration
public abstract ImageSource GetQrCodeImageSource(string contents)
Parameters
Type |
Name |
Description |
System.String |
contents |
|
Returns
Type |
Description |
Xamarin.Forms.ImageSource |
|
GetRunningProtocols()
Declaration
public List<Protocol> GetRunningProtocols()
Returns
Type |
Description |
System.Collections.Generic.List<Protocol> |
|
GetSharePath(String)
Gets the share path with an extension.
Declaration
public string GetSharePath(string extension)
Parameters
Type |
Name |
Description |
System.String |
extension |
Extension (with or without preceding ".")
|
Returns
Type |
Description |
System.String |
The share path.
|
Initialize(Func<SensusServiceHelper>)
Initializes the sensus service helper. Must be called when app first starts, from the main / UI thread.
Declaration
public static void Initialize(Func<SensusServiceHelper> createNew)
Parameters
Type |
Name |
Description |
System.Func<SensusServiceHelper> |
createNew |
Function for creating a new service helper, if one is needed.
|
IssuePendingSurveysNotificationAsync(PendingSurveyNotificationMode, Protocol)
Declaration
public Task IssuePendingSurveysNotificationAsync(PendingSurveyNotificationMode notificationMode, Protocol protocol)
Parameters
Returns
Type |
Description |
System.Threading.Tasks.Task |
|
KeepDeviceAwakeAsync()
Declaration
public abstract Task KeepDeviceAwakeAsync()
Returns
Type |
Description |
System.Threading.Tasks.Task |
|
LetDeviceSleepAsync()
Declaration
public abstract Task LetDeviceSleepAsync()
Returns
Type |
Description |
System.Threading.Tasks.Task |
|
ObtainPermissionAsync(Permission)
Declaration
public Task<PermissionStatus> ObtainPermissionAsync(Permission permission)
Parameters
Type |
Name |
Description |
Plugin.Permissions.Abstractions.Permission |
permission |
|
Returns
Type |
Description |
System.Threading.Tasks.Task<Plugin.Permissions.Abstractions.PermissionStatus> |
|
PromptForAndReadTextFileAsync()
Declaration
public Task<string> PromptForAndReadTextFileAsync()
Returns
Type |
Description |
System.Threading.Tasks.Task<System.String> |
|
Declaration
public Task<Input> PromptForInputAsync(string windowTitle, Input input, Nullable<CancellationToken> cancellationToken, bool showCancelButton, string nextButtonText, string cancelConfirmation, string incompleteSubmissionConfirmation, string submitConfirmation, bool displayProgress)
Parameters
Type |
Name |
Description |
System.String |
windowTitle |
|
Input |
input |
|
System.Nullable<System.Threading.CancellationToken> |
cancellationToken |
|
System.Boolean |
showCancelButton |
|
System.String |
nextButtonText |
|
System.String |
cancelConfirmation |
|
System.String |
incompleteSubmissionConfirmation |
|
System.String |
submitConfirmation |
|
System.Boolean |
displayProgress |
|
Returns
Type |
Description |
System.Threading.Tasks.Task<Input> |
|
Declaration
public Task<IEnumerable<InputGroup>> PromptForInputsAsync(Nullable<DateTimeOffset> firstPromptTimestamp, IEnumerable<InputGroup> inputGroups, Nullable<CancellationToken> cancellationToken, bool showCancelButton, string nextButtonText, string cancelConfirmation, string incompleteSubmissionConfirmation, string submitConfirmation, bool displayProgress, Action postDisplayCallback)
Parameters
Type |
Name |
Description |
System.Nullable<System.DateTimeOffset> |
firstPromptTimestamp |
|
System.Collections.Generic.IEnumerable<InputGroup> |
inputGroups |
|
System.Nullable<System.Threading.CancellationToken> |
cancellationToken |
|
System.Boolean |
showCancelButton |
|
System.String |
nextButtonText |
|
System.String |
cancelConfirmation |
|
System.String |
incompleteSubmissionConfirmation |
|
System.String |
submitConfirmation |
|
System.Boolean |
displayProgress |
|
System.Action |
postDisplayCallback |
|
Returns
Type |
Description |
System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<InputGroup>> |
|
Declaration
public Task<List<Input>> PromptForInputsAsync(string windowTitle, IEnumerable<Input> inputs, Nullable<CancellationToken> cancellationToken, bool showCancelButton, string nextButtonText, string cancelConfirmation, string incompleteSubmissionConfirmation, string submitConfirmation, bool displayProgress)
Parameters
Type |
Name |
Description |
System.String |
windowTitle |
|
System.Collections.Generic.IEnumerable<Input> |
inputs |
|
System.Nullable<System.Threading.CancellationToken> |
cancellationToken |
|
System.Boolean |
showCancelButton |
|
System.String |
nextButtonText |
|
System.String |
cancelConfirmation |
|
System.String |
incompleteSubmissionConfirmation |
|
System.String |
submitConfirmation |
|
System.Boolean |
displayProgress |
|
Returns
Type |
Description |
System.Threading.Tasks.Task<System.Collections.Generic.List<Input>> |
|
ProtectedFlashNotificationAsync(String)
Declaration
protected abstract Task ProtectedFlashNotificationAsync(string message)
Parameters
Type |
Name |
Description |
System.String |
message |
|
Returns
Type |
Description |
System.Threading.Tasks.Task |
|
ReadAllBytes(String)
Reads all bytes from a file. There's a File.ReadAllBytes method in Android / iOS, but not in WinPhone.
Declaration
public static byte[] ReadAllBytes(string path)
Parameters
Type |
Name |
Description |
System.String |
path |
Path.
|
Returns
Type |
Description |
System.Byte[] |
The bytes.
|
RegisterProtocol(Protocol)
Declaration
public void RegisterProtocol(Protocol protocol)
Parameters
RegisterWithNotificationHubAsync(Tuple<String, String>)
Declaration
protected abstract Task RegisterWithNotificationHubAsync(Tuple<string, string> hubSas)
Parameters
Type |
Name |
Description |
System.Tuple<System.String, System.String> |
hubSas |
|
Returns
Type |
Description |
System.Threading.Tasks.Task |
|
RemoveExpiredScriptsAsync()
Declaration
public Task<bool> RemoveExpiredScriptsAsync()
Returns
Type |
Description |
System.Threading.Tasks.Task<System.Boolean> |
|
RemoveRunningProtocolIdAsync(String)
Declaration
public Task RemoveRunningProtocolIdAsync(string id)
Parameters
Type |
Name |
Description |
System.String |
id |
|
Returns
Type |
Description |
System.Threading.Tasks.Task |
|
RemoveScripts(Script[])
Declaration
public bool RemoveScripts(params Script[] scripts)
Parameters
Type |
Name |
Description |
Script[] |
scripts |
|
Returns
Type |
Description |
System.Boolean |
|
RemoveScriptsForRunner(ScriptRunner)
Declaration
public bool RemoveScriptsForRunner(ScriptRunner runner)
Parameters
Returns
Type |
Description |
System.Boolean |
|
RequestNewPushNotificationToken()
Declaration
protected abstract void RequestNewPushNotificationToken()
RunVoicePromptAsync(String, Action)
Declaration
public abstract Task<string> RunVoicePromptAsync(string prompt, Action postDisplayCallback)
Parameters
Type |
Name |
Description |
System.String |
prompt |
|
System.Action |
postDisplayCallback |
|
Returns
Type |
Description |
System.Threading.Tasks.Task<System.String> |
|
SaveAsync()
Declaration
Returns
Type |
Description |
System.Threading.Tasks.Task |
|
ScanQrCodeAsync(String)
Declaration
public Task<string> ScanQrCodeAsync(string resultPrefix)
Parameters
Type |
Name |
Description |
System.String |
resultPrefix |
|
Returns
Type |
Description |
System.Threading.Tasks.Task<System.String> |
|
SendEmailAsync(String, String, String)
Declaration
public abstract Task SendEmailAsync(string toAddress, string subject, string message)
Parameters
Type |
Name |
Description |
System.String |
toAddress |
|
System.String |
subject |
|
System.String |
message |
|
Returns
Type |
Description |
System.Threading.Tasks.Task |
|
ShareFileAsync(String, String, String)
Declaration
public abstract Task ShareFileAsync(string path, string subject, string mimeType)
Parameters
Type |
Name |
Description |
System.String |
path |
|
System.String |
subject |
|
System.String |
mimeType |
|
Returns
Type |
Description |
System.Threading.Tasks.Task |
|
StartAsync()
Starts platform-independent service functionality, including protocols that should be running. Okay to call multiple times, even if the service is already running.
Declaration
Returns
Type |
Description |
System.Threading.Tasks.Task |
|
StopAsync()
Called when the system or user wishes to stop the app entirely. Will stop all protocols and clean up.
Declaration
Returns
Type |
Description |
System.Threading.Tasks.Task |
Task
|
TextToSpeechAsync(String)
Declaration
public abstract Task TextToSpeechAsync(string text)
Parameters
Type |
Name |
Description |
System.String |
text |
|
Returns
Type |
Description |
System.Threading.Tasks.Task |
|
UnregisterFromNotificationHubAsync(Tuple<String, String>)
Declaration
protected abstract Task UnregisterFromNotificationHubAsync(Tuple<string, string> hubSas)
Parameters
Type |
Name |
Description |
System.Tuple<System.String, System.String> |
hubSas |
|
Returns
Type |
Description |
System.Threading.Tasks.Task |
|
UnregisterProtocolAsync(Protocol)
Declaration
public Task UnregisterProtocolAsync(Protocol protocol)
Parameters
Returns
Type |
Description |
System.Threading.Tasks.Task |
|
UpdatePushNotificationRegistrationsAsync(CancellationToken)
Declaration
public Task UpdatePushNotificationRegistrationsAsync(CancellationToken cancellationToken)
Parameters
Type |
Name |
Description |
System.Threading.CancellationToken |
cancellationToken |
|
Returns
Type |
Description |
System.Threading.Tasks.Task |
|
Implements