/// <summary> /// Initializes a new instance of the PSSmsReceiver class. /// </summary> /// <param name="receiver">The receiver to wrap.</param> public PSSmsReceiver(SmsReceiver receiver) { this.Name = receiver.Name; this.CountryCode = receiver.CountryCode; this.PhoneNumber = receiver.PhoneNumber; this.Status = TransitionalClasses.TransitionHelpers.ConvertNamespace(receiver.Status); }
/// <summary> /// Initializes a new instance of the PSSmsReceiver class. /// </summary> /// <param name="receiver">The receiver to wrap.</param> public PSSmsReceiver(SmsReceiver receiver) { this.Name = receiver.Name; this.CountryCode = receiver.CountryCode; this.PhoneNumber = receiver.PhoneNumber; this.Status = receiver.Status; }
private void AreEqual(SmsReceiver exp, SmsReceiver act) { Assert.AreEqual(exp.CountryCode, act.CountryCode); Assert.AreEqual(exp.Name, act.Name); Assert.AreEqual(exp.Status, act.Status); Assert.AreEqual(exp.PhoneNumber, act.PhoneNumber); }
private static void AreEqual(SmsReceiver exp, SmsReceiver act) { if (exp != null) { Assert.Equal(exp.PhoneNumber, act.PhoneNumber); Assert.Equal(exp.Name, act.Name); Assert.Equal(exp.Status, act.Status); } }
public void SmsRecieverEventTest() { SmsReceiver smsReceiver = new SmsReceiver(); MobileLab3 mobile = new MobileLab3(smsReceiver); string built = ""; string sms = "Message received"; mobile.Sms.SmsReceived += (string message) => { built = message; }; mobile.ReceiveSms(sms); Assert.IsTrue(built.Equals(sms)); }
///GENMHASH:B1C01D344AC2E2E2A88189E7C986CA10:51672C6C6F0ABF78362B77B2C4D0C68E public ActionGroupImpl WithSms(string countryCode, string phoneNumber) { this.WithoutSms(); var compositeKey = this.actionReceiverPrefix + smsSuffix; var sr = new SmsReceiver { Name = compositeKey, CountryCode = countryCode, PhoneNumber = phoneNumber }; this.smsReceivers[compositeKey] = sr; return(this); }
public override void OnDestroy() { base.OnDestroy(); UnregisterReceiver(_smsReceiver); _smsReceiver = null; if (_isServiceRunning) { Intent restartServiceIntent = new Intent("passTheBarrier.intents.serviceRestart"); SendBroadcast(restartServiceIntent); } else { _isServiceRunning = false; } }
public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId) { base.OnStartCommand(intent, flags, startId); var toStart = intent.GetBooleanExtra(GetString(Resource.String.startIntentExtra), true); if (toStart) { Intent notificationIntent = new Intent(ApplicationContext, typeof(MainActivity)); notificationIntent.SetAction(Intent.ActionMain); notificationIntent.AddCategory(Intent.CategoryLauncher); notificationIntent.AddFlags(ActivityFlags.NewTask); PendingIntent pendingIntent = PendingIntent.GetActivity(this, 0, notificationIntent, PendingIntentFlags.UpdateCurrent); NotificationCompat.Builder builder = new NotificationCompat.Builder(this.ApplicationContext) .SetSmallIcon(Resource.Drawable.ic_barrier_open_black_24dp) .SetContentTitle(GetString(Resource.String.serviceRunningNotificationTitle)) .SetContentText(GetString(Resource.String.serviceRunningNotificationText)) .SetContentIntent(pendingIntent) .SetOngoing(true); StartForeground(NotificationId, builder.Build()); _smsReceiver = new SmsReceiver(); RegisterReceiver(_smsReceiver, new IntentFilter(Telephony.Sms.Intents.SmsReceivedAction)); _isServiceRunning = true; } else { StopSelf(); _isServiceRunning = false; } return(StartCommandResult.Sticky); }
internal static ActionGroupData DeserializeActionGroupData(JsonElement element) { Optional <string> kind = default; Optional <string> identity = default; IDictionary <string, string> tags = default; AzureLocation location = default; ResourceIdentifier id = default; string name = default; ResourceType type = default; SystemData systemData = default; Optional <string> groupShortName = default; Optional <bool> enabled = default; Optional <IList <EmailReceiver> > emailReceivers = default; Optional <IList <SmsReceiver> > smsReceivers = default; Optional <IList <WebhookReceiver> > webhookReceivers = default; Optional <IList <ItsmReceiver> > itsmReceivers = default; Optional <IList <AzureAppPushReceiver> > azureAppPushReceivers = default; Optional <IList <AutomationRunbookReceiver> > automationRunbookReceivers = default; Optional <IList <VoiceReceiver> > voiceReceivers = default; Optional <IList <LogicAppReceiver> > logicAppReceivers = default; Optional <IList <AzureFunctionReceiver> > azureFunctionReceivers = default; Optional <IList <ArmRoleReceiver> > armRoleReceivers = default; Optional <IList <EventHubReceiver> > eventHubReceivers = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("kind")) { kind = property.Value.GetString(); continue; } if (property.NameEquals("identity")) { identity = property.Value.GetString(); continue; } if (property.NameEquals("tags")) { Dictionary <string, string> dictionary = new Dictionary <string, string>(); foreach (var property0 in property.Value.EnumerateObject()) { dictionary.Add(property0.Name, property0.Value.GetString()); } tags = dictionary; continue; } if (property.NameEquals("location")) { location = property.Value.GetString(); continue; } if (property.NameEquals("id")) { id = new ResourceIdentifier(property.Value.GetString()); continue; } if (property.NameEquals("name")) { name = property.Value.GetString(); continue; } if (property.NameEquals("type")) { type = property.Value.GetString(); continue; } if (property.NameEquals("systemData")) { systemData = JsonSerializer.Deserialize <SystemData>(property.Value.ToString()); continue; } if (property.NameEquals("properties")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } foreach (var property0 in property.Value.EnumerateObject()) { if (property0.NameEquals("groupShortName")) { groupShortName = property0.Value.GetString(); continue; } if (property0.NameEquals("enabled")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } enabled = property0.Value.GetBoolean(); continue; } if (property0.NameEquals("emailReceivers")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } List <EmailReceiver> array = new List <EmailReceiver>(); foreach (var item in property0.Value.EnumerateArray()) { array.Add(EmailReceiver.DeserializeEmailReceiver(item)); } emailReceivers = array; continue; } if (property0.NameEquals("smsReceivers")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } List <SmsReceiver> array = new List <SmsReceiver>(); foreach (var item in property0.Value.EnumerateArray()) { array.Add(SmsReceiver.DeserializeSmsReceiver(item)); } smsReceivers = array; continue; } if (property0.NameEquals("webhookReceivers")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } List <WebhookReceiver> array = new List <WebhookReceiver>(); foreach (var item in property0.Value.EnumerateArray()) { array.Add(WebhookReceiver.DeserializeWebhookReceiver(item)); } webhookReceivers = array; continue; } if (property0.NameEquals("itsmReceivers")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } List <ItsmReceiver> array = new List <ItsmReceiver>(); foreach (var item in property0.Value.EnumerateArray()) { array.Add(ItsmReceiver.DeserializeItsmReceiver(item)); } itsmReceivers = array; continue; } if (property0.NameEquals("azureAppPushReceivers")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } List <AzureAppPushReceiver> array = new List <AzureAppPushReceiver>(); foreach (var item in property0.Value.EnumerateArray()) { array.Add(AzureAppPushReceiver.DeserializeAzureAppPushReceiver(item)); } azureAppPushReceivers = array; continue; } if (property0.NameEquals("automationRunbookReceivers")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } List <AutomationRunbookReceiver> array = new List <AutomationRunbookReceiver>(); foreach (var item in property0.Value.EnumerateArray()) { array.Add(AutomationRunbookReceiver.DeserializeAutomationRunbookReceiver(item)); } automationRunbookReceivers = array; continue; } if (property0.NameEquals("voiceReceivers")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } List <VoiceReceiver> array = new List <VoiceReceiver>(); foreach (var item in property0.Value.EnumerateArray()) { array.Add(VoiceReceiver.DeserializeVoiceReceiver(item)); } voiceReceivers = array; continue; } if (property0.NameEquals("logicAppReceivers")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } List <LogicAppReceiver> array = new List <LogicAppReceiver>(); foreach (var item in property0.Value.EnumerateArray()) { array.Add(LogicAppReceiver.DeserializeLogicAppReceiver(item)); } logicAppReceivers = array; continue; } if (property0.NameEquals("azureFunctionReceivers")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } List <AzureFunctionReceiver> array = new List <AzureFunctionReceiver>(); foreach (var item in property0.Value.EnumerateArray()) { array.Add(AzureFunctionReceiver.DeserializeAzureFunctionReceiver(item)); } azureFunctionReceivers = array; continue; } if (property0.NameEquals("armRoleReceivers")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } List <ArmRoleReceiver> array = new List <ArmRoleReceiver>(); foreach (var item in property0.Value.EnumerateArray()) { array.Add(ArmRoleReceiver.DeserializeArmRoleReceiver(item)); } armRoleReceivers = array; continue; } if (property0.NameEquals("eventHubReceivers")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } List <EventHubReceiver> array = new List <EventHubReceiver>(); foreach (var item in property0.Value.EnumerateArray()) { array.Add(EventHubReceiver.DeserializeEventHubReceiver(item)); } eventHubReceivers = array; continue; } } continue; } } return(new ActionGroupData(id, name, type, systemData, tags, location, kind.Value, identity.Value, groupShortName.Value, Optional.ToNullable(enabled), Optional.ToList(emailReceivers), Optional.ToList(smsReceivers), Optional.ToList(webhookReceivers), Optional.ToList(itsmReceivers), Optional.ToList(azureAppPushReceivers), Optional.ToList(automationRunbookReceivers), Optional.ToList(voiceReceivers), Optional.ToList(logicAppReceivers), Optional.ToList(azureFunctionReceivers), Optional.ToList(armRoleReceivers), Optional.ToList(eventHubReceivers))); }
public override void OnCreatePreferences(Bundle savedInstanceState, string rootKey) { AddPreferencesFromResource(Resource.Xml.settings); mPreferences = PreferenceManager.GetDefaultSharedPreferences(Activity); SettingsDir = new File(Activity.DataDir, "shared_prefs"); var exportPreference = FindPreference("export_settings"); exportPreference.PreferenceClick += (sender, args) => { var paths = new List <File> { new File(SettingsDir, SettingsFileName) }; foreach (var file in Activity.FilesDir.ListFiles()) { if (file.IsFile) { paths.Add(file); } } if (paths.Count > 0) { if (OtherUtils.CreateZipArchive(paths, exportFile.AbsolutePath)) { Toast.MakeText(Activity, Activity.GetString(Resource.String.toast_export_successful), ToastLength.Short).Show(); } else { Toast.MakeText(Activity, Activity.GetString(Resource.String.toast_export_failed), ToastLength.Short).Show(); } } else { Toast.MakeText(Activity, Activity.GetString(Resource.String.toast_export_no_files), ToastLength.Short).Show(); } }; var importPreference = FindPreference("import_settings"); importPreference.PreferenceClick += (sender, args) => { if (!exportFile.Exists()) { Toast.MakeText(Activity, Activity.GetString(Resource.String.toast_import_no_file), ToastLength.Short).Show(); return; } if (exportFile.Length() > 1024 * 1024) { Toast.MakeText(Activity, Activity.GetString(Resource.String.toast_import_big_file), ToastLength.Short).Show(); return; } if (OtherUtils.UnpackZipArchive(exportFile.AbsolutePath, Activity.CacheDir)) { Toast.MakeText(Activity, Activity.GetString(Resource.String.toast_import_successful), ToastLength.Short).Show(); } else { Toast.MakeText(Activity, Activity.GetString(Resource.String.toast_import_failed), ToastLength.Short).Show(); return; } foreach (var file in Activity.CacheDir.ListFiles()) { Stream outputStream; if (file.Name == SettingsFileName) { var path = new File(SettingsDir, SettingsFileName).AbsolutePath; Log.Debug(nameof(OtherUtils.UnpackZipArchive), path); outputStream = new FileStream(path, FileMode.Create); } else { outputStream = Activity.OpenFileOutput(file.Name, FileCreationMode.Private); } string text; if (!file.Exists()) { continue; } using (var reader = new StreamReader(new FileStream(file.AbsolutePath, FileMode.Open))) { text = reader.ReadToEnd(); } using (var writer = new StreamWriter(outputStream)) { writer.Write(text); } file.Delete(); } }; var categoriesPreference = (MultiSelectListPreference)FindPreference("selected_categories"); categoriesPreference.PreferenceChange += (sender, args) => { var set = args.NewValue.JavaCast <HashSet>(); SystemModListenerService.SetSystemMonitoringStatus(Activity, set.Contains(DataHolder.SystemCategory)); LocationUtils.SetLocationTrackingEnabled(set.Contains(DataHolder.LocationCategory)); ScreenUnlockReceiver.SetUnlockReceiverStatus(Activity, set.Contains(DataHolder.ScreenCategory)); PhoneCallReceiver.SetCallReceiverStatus(Activity, set.Contains(DataHolder.PhoneCategory)); SmsReceiver.SetSmsReceiverStatus(Activity, set.Contains(DataHolder.SmsCategory)); var categories = new List <string>(); foreach (var val in set.ToArray()) { categories.Add(val.ToString()); } mPreferences.Edit().PutStringSet(categoriesPreference.Key, categories).Apply(); }; var about = FindPreference("app_info"); about.Summary = Activity.ApplicationContext.PackageManager.GetPackageInfo(Activity.PackageName, 0).VersionName; about.PreferenceClick += (sender, args) => { if ((mDevClickedTimes = (mDevClickedTimes + 1) % 7) == 0) { if (Activity is SettingsActivity parent) { parent.LoadScreen(SettingsCategory.Developer); } } }; try { var summaryNotifyPreference = FindPreference(MonitoringSummaryType); summaryNotifyPreference.PreferenceChange += (sender, args) => { AlarmReceiver.RegisterReceiver(Activity, (bool)args.NewValue ? 1 : 0); }; } catch (Exception e) { Console.WriteLine(e.Message); Log.Error(nameof(MonitoringSummaryType), e.Message); } }
public MobileLab3(SmsReceiver smsReceiver) { Sms = smsReceiver; }