//Get network connection name internal static async Task <string> GetNetworkName() { try { //Check connection ConnectionProfile ConnectionProfile = NetworkInformation.GetInternetConnectionProfile(); if (ConnectionProfile == null) { return("No connection"); } else { //Get Wi-Fi / Ethernet name string FirstNetwork = ConnectionProfile.GetNetworkNames().FirstOrDefault(); if (!string.IsNullOrWhiteSpace(FirstNetwork)) { return(FirstNetwork); } //Get Cellular name if (ConnectionProfile.IsWwanConnectionProfile) { PhoneCallStore phoneCallStore = await PhoneCallManager.RequestStoreAsync(); PhoneLine phoneLine = await PhoneLine.FromIdAsync(await phoneCallStore.GetDefaultLineAsync()); return(phoneLine.NetworkName); } return("Unknown"); } } catch { return("Unknown"); } }
private async void callButton_Click(object sender, RoutedEventArgs e) { if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent( "Windows.ApplicationModel.Calls.PhoneLine")) { var store = await PhoneCallManager.RequestStoreAsync(); var phoneLineId = await store.GetDefaultLineAsync(); var phoneLine = await PhoneLine.FromIdAsync(phoneLineId); phoneLine.Dial(_translatedNumber, ""); } else { var uriSkype = new Uri($"Skype:{Regex.Replace(_translatedNumber, @"[-\s]", "")}?call"); //var uriSkype = new Uri($"Skype:{_translatedNumber}?call"); // Set the option to show a warning var promptOptions = new Windows.System.LauncherOptions { TreatAsUntrusted = false }; // Launch the URI await Windows.System.Launcher.LaunchUriAsync(uriSkype, promptOptions); } }
protected async override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); if (_LineWatcher == null) { PhoneCallStore store = await PhoneCallManager.RequestStoreAsync(); _LineWatcher = store.RequestLineWatcher(); _LineWatcher.LineAdded += _watcher_LineAdded; _LineWatcher.LineRemoved += _watcher_LineRemoved; _LineWatcher.Start(); } string str = PhoneLineTransportDevice.GetDeviceSelector(PhoneLineTransport.Bluetooth); if (_DeviceWatcher == null) { _DeviceWatcher = DeviceInformation.CreateWatcher(str); _DeviceWatcher.Added += _DeviceWatcher_Added; _DeviceWatcher.Removed += _DeviceWatcher_Removed; _DeviceWatcher.Start(); } string str1 = BluetoothDevice.GetDeviceSelector(); var watch = DeviceInformation.CreateWatcher(str1); watch.Added += _DeviceWatcher_Added; watch.Removed += _DeviceWatcher_Removed; watch.Start(); }
/// <summary> /// Enumerate through all phone lines and returns a list of all phone lines /// </summary> /// <returns>A dictionary of cellular phone lines and their guids.</returns> private async Task <Dictionary <Guid, PhoneLine> > GetPhoneLinesAsync() { PhoneCallStore store = await PhoneCallManager.RequestStoreAsync(); // Start the PhoneLineWatcher var watcher = store.RequestLineWatcher(); var phoneLines = new List <PhoneLine>(); var lineEnumerationCompletion = new TaskCompletionSource <bool>(); watcher.LineAdded += async(o, args) => { var line = await PhoneLine.FromIdAsync(args.LineId); phoneLines.Add(line); }; watcher.Stopped += (o, args) => lineEnumerationCompletion.TrySetResult(false); watcher.EnumerationCompleted += (o, args) => lineEnumerationCompletion.TrySetResult(true); watcher.Start(); // Wait for enumeration completion if (!await lineEnumerationCompletion.Task) { throw new Exception("Phone Line Enumeration failed"); } watcher.Stop(); Dictionary <Guid, PhoneLine> returnedLines = new Dictionary <Guid, PhoneLine>(); foreach (PhoneLine phoneLine in phoneLines) { if (phoneLine != null && phoneLine.Transport == PhoneLineTransport.Cellular) { returnedLines.Add(phoneLine.Id, phoneLine); } } return(returnedLines); }
public static async Task Initialize() { DeviceInformationCollection devices; CallManager = await CallManager.GetSystemPhoneCallManagerAsync(); CallStore = await PhoneCallManager.RequestStoreAsync(); CallHistoryStore = await PhoneCallHistoryManager.RequestStoreAsync(PhoneCallHistoryStoreAccessType.AllEntriesReadWrite); devices = await DeviceInformation.FindAllAsync(ProximitySensor.GetDeviceSelector()); ProximitySensor = devices.Count > 0 ? ProximitySensor.FromId(devices.First().Id) : null; VibrationAccessStatus accessStatus = await VibrationDevice.RequestAccessAsync(); if (accessStatus == VibrationAccessStatus.Allowed) { VibrationDevice = await VibrationDevice.GetDefaultAsync(); } try { DefaultLine = await PhoneLine.FromIdAsync(await CallStore.GetDefaultLineAsync()); } catch { } Initialized = true; }
async Task <PhoneLine> GetDefaultPhoneLineAsync() { var phoneCallStore = await PhoneCallManager.RequestStoreAsync(); var lineId = await phoneCallStore.GetDefaultLineAsync(); return(await PhoneLine.FromIdAsync(lineId)); }
public static string DEBUG = "+420604540531"; /*INSERT NUMBER*/ public static async Task CallAsync() { PhoneCallStore PhoneCallStore = await PhoneCallManager.RequestStoreAsync(); Guid LineGuid = await PhoneCallStore.GetDefaultLineAsync(); PhoneLine line = await PhoneLine.FromIdAsync(LineGuid); line.Dial(DEBUG, "CALL"); }
public async Task <bool> RequestCallingAccess() { try { Calling = !(await PhoneCallManager.RequestStoreAsync() is null); } catch { Calling = null; } return(Calling.HasValue); }
private async Task InitializateCallSystem() { CallManager = await CallManager.GetCallManagerAsync(); CallStore = await PhoneCallManager.RequestStoreAsync(); CallHistoryStore = await PhoneCallHistoryManager.RequestStoreAsync(PhoneCallHistoryStoreAccessType.AllEntriesReadWrite); CallHandler = new CallHandler(); CallHandler.Start(); CallManager.CallAppeared += CallManager_CallAppeared; }
public static async Task <bool> EnsureInitPhoneLineWatcher() { if (LineWatcher == null) { PhoneCallStore store = await PhoneCallManager.RequestStoreAsync(); if (store == null) { return(false); } LineWatcher = store.RequestLineWatcher(); LineWatcher.LineAdded += LineWatcher_LineAdded; LineWatcher.LineRemoved += LineWatcher_LineRemoved; LineWatcher.LineUpdated += LineWatcher_LineUpdated; } return(true); }
private async void listView_DoubleTapped(object sender, DoubleTappedRoutedEventArgs e) { if (listView.SelectedItem != null) { contato = listView.SelectedItem as Contato; PhoneCallStore phoneCallStore = await PhoneCallManager.RequestStoreAsync(); Guid lineGuid = await phoneCallStore.GetDefaultLineAsync(); MessageDialog msg = new MessageDialog(lineGuid.ToString()); await msg.ShowAsync(); PhoneLine phoneLine = await PhoneLine.FromIdAsync(lineGuid); phoneLine.Dial(contato.Fone, contato.Nome); } }
private async void PlaceCall(string number) { try { PhoneCallStore PhoneCallStore = await PhoneCallManager.RequestStoreAsync(); Guid LineGuid = await PhoneCallStore.GetDefaultLineAsync(); var phoneLine = await PhoneLine.FromIdAsync(LineGuid); phoneLine.Dial(number, "New Call"); } catch { var uri = $"callto:{number}"; var launch = await Launcher.LaunchUriAsync(new Uri(uri)); } }
private async void Button_Click(object sender, RoutedEventArgs e) { switch ((sender as Button).Content.ToString()) { case "Contact Doctor": PhoneCallStore PhoneCallStore = await PhoneCallManager.RequestStoreAsync(); Guid LineGuid = await PhoneCallStore.GetDefaultLineAsync(); var phoneCall = await PhoneLine.FromIdAsync(LineGuid); phoneCall.Dial(phNo.Text, name.Text); break; case "View List": viewList.Visibility = Visibility.Visible; viewSingle.Visibility = Visibility.Collapsed; break; default: break; } }
private async void Load() { string displayname = ""; if (device != null) { if (device.AccountPhoneNumber != null) { displayname = device.AccountPhoneNumber; } switch (device.DeviceStatus) { case SmsDeviceStatus.DeviceBlocked: { StatusIcon.Text = ""; var pad = StatusIcon.Padding; pad.Top = 0; StatusIcon.Padding = pad; break; } case SmsDeviceStatus.DeviceFailure: { StatusIcon.Text = ""; var pad = StatusIcon.Padding; pad.Top = 0; StatusIcon.Padding = pad; break; } case SmsDeviceStatus.DeviceLocked: { StatusIcon.Text = ""; break; } case SmsDeviceStatus.Off: { StatusIcon.Text = ""; var pad = StatusIcon.Padding; pad.Top = 0; StatusIcon.Padding = pad; break; } case SmsDeviceStatus.Ready: { StatusIcon.Text = ""; var pad = StatusIcon.Padding; pad.Top = 0; StatusIcon.Padding = pad; break; } case SmsDeviceStatus.SimNotInserted: case SmsDeviceStatus.SubscriptionNotActivated: case SmsDeviceStatus.BadSim: { StatusIcon.Text = ""; break; } } } try { string selectorStr = MobileBroadbandModem.GetDeviceSelector(); DeviceInformationCollection devices = await DeviceInformation.FindAllAsync(selectorStr); foreach (var mdevice in devices) { MobileBroadbandModem modem = MobileBroadbandModem.FromId(mdevice.Id); if (modem.DeviceInformation.TelephoneNumbers.Count > 0) { if (modem.DeviceInformation.TelephoneNumbers.Any(x => x == device.AccountPhoneNumber)) { displayname = modem.CurrentNetwork.RegisteredProviderName; // from https://github.com/ADeltaX/MobileShell/blob/experiments/src/App.xaml.cs PhoneCallStore store = await PhoneCallManager.RequestStoreAsync(); PhoneLineWatcher watcher = store.RequestLineWatcher(); List <PhoneLine> phoneLines = new List <PhoneLine>(); TaskCompletionSource <bool> lineEnumerationCompletion = new TaskCompletionSource <bool>(); watcher.LineAdded += async(o, args) => { var line = await PhoneLine.FromIdAsync(args.LineId); phoneLines.Add(line); }; watcher.Stopped += (o, args) => lineEnumerationCompletion.TrySetResult(false); watcher.EnumerationCompleted += (o, args) => lineEnumerationCompletion.TrySetResult(true); watcher.Start(); if (await lineEnumerationCompletion.Task) { watcher.Stop(); List <PhoneLine> returnedLines = new List <PhoneLine>(); foreach (PhoneLine phoneLine in phoneLines) { if (phoneLine != null && phoneLine.Transport == PhoneLineTransport.Cellular) { returnedLines.Add(phoneLine); } } if (returnedLines.Any(x => x.NetworkName == modem.CurrentNetwork.RegisteredProviderName)) { var line = returnedLines.First(x => x.NetworkName == modem.CurrentNetwork.RegisteredProviderName); displayname += " (SIM " + (line.CellularDetails.SimSlotIndex + 1) + ")"; } } break; } } } } catch { } if (string.IsNullOrEmpty(displayname)) { displayname = "Unidentified SIM"; } LineName.Text = displayname; }