public IReadOnlyList <SimCard> GetSimCards() { var results = new List <SimCard>(); var modem = MobileBroadbandModem.GetDefault(); if (modem == null) { return(results.AsReadOnly()); } var account = modem.CurrentAccount; if (account == null) { return(results.AsReadOnly()); } var simCard = new SimCard(); simCard.ICCID = account.CurrentDeviceInformation.SimIccId; simCard.IMSI = account.CurrentDeviceInformation.SubscriberId; simCard.MSISDN = modem.DeviceInformation.TelephoneNumbers; simCard.MCC = ExtractMCC(simCard.IMSI); simCard.MNC = ExtractMNC(simCard.IMSI); simCard.MSID = ExtractMSID(simCard.IMSI); results.Add(simCard); return(results.AsReadOnly()); }
private async void btnGetUICC_Click(object sender, RoutedEventArgs e) { try { var modem = MobileBroadbandModem.GetDefault(); MobileBroadbandModemConfiguration modemCfg = await modem.GetCurrentConfigurationAsync(); MobileBroadbandUicc uicc = modemCfg.Uicc; if (uicc != null) { StringBuilder sb = new StringBuilder(); sb.AppendLine("SIM Card ICCID:" + uicc.SimIccId); sb.AppendLine("Application on SIM Card"); MobileBroadbandUiccAppsResult appsResult = await uicc.GetUiccAppsAsync(); foreach (var uiccApp in appsResult.UiccApps) { sb.AppendLine("Kind: " + uiccApp.Kind); } txtSIMInformation.Text = sb.ToString(); } } catch (Exception ex) { rootPage.NotifyUser("Error:" + ex.Message, NotifyType.ErrorMessage); } }
private void btnRefresh_Click(object sender, RoutedEventArgs e) { try { var modem = MobileBroadbandModem.GetDefault(); StringBuilder sb = new StringBuilder(); sb.AppendLine("Cellular Class: " + modem.DeviceInformation.CellularClass.ToString()); sb.AppendLine("Current Radio Powerstate: " + modem.DeviceInformation.CurrentRadioState.ToString()); sb.AppendLine("Custom Data Class: " + modem.DeviceInformation.CustomDataClass.ToString()); sb.AppendLine("Supported Data Classes: " + modem.DeviceInformation.DataClasses.ToString()); sb.AppendLine("Device ID: " + modem.DeviceInformation.DeviceId.ToString()); sb.AppendLine("Device Type: " + modem.DeviceInformation.DeviceType.ToString()); sb.AppendLine("Firmware Information: " + modem.DeviceInformation.FirmwareInformation); sb.AppendLine("Manufacturer: " + modem.DeviceInformation.Manufacturer); sb.AppendLine("IMEI (Mobile Equipment ID): " + modem.DeviceInformation.MobileEquipmentId); sb.AppendLine("Device Model: " + modem.DeviceInformation.Model); sb.AppendLine("Device Status: " + modem.DeviceInformation.NetworkDeviceStatus.ToString()); sb.AppendLine("Suppported PINs: " + CheckForNullOrEmptyField(modem.DeviceInformation.PinManager.SupportedPins.ToString())); sb.AppendLine("Revision: " + modem.DeviceInformation.Revision); sb.AppendLine("Serial Number: " + modem.DeviceInformation.SerialNumber); sb.AppendLine("SIM ICCID: " + modem.DeviceInformation.SimIccId); sb.AppendLine("Subscriber ID: " + modem.DeviceInformation.SubscriberId); sb.AppendLine("Telephone Numbers: " + CheckForNullOrEmptyField(modem.DeviceInformation.TelephoneNumbers.ToString())); txtModemInformation.Text = sb.ToString(); rootPage.NotifyUser("Success: Modem information loaded", NotifyType.StatusMessage); } catch (Exception ex) { rootPage.NotifyUser("Error:" + ex.Message, NotifyType.ErrorMessage); } }
private async Task Load() { string selectorStr = MobileBroadbandModem.GetDeviceSelector(); DeviceInformationCollection devices = await DeviceInformation.FindAllAsync(selectorStr); List <string> modemList = new List <string>(); bool MoreThanOne = devices.Count > 1; int counter = 0; foreach (DeviceInformation device in devices) { counter++; MobileBroadbandModem modem = MobileBroadbandModem.FromId(device.Id); string suffix = ": "; if (MoreThanOne) { suffix = " " + counter + ": "; } modemList.Add("IMEI" + suffix + modem.DeviceInformation.SerialNumber); if (modem.DeviceInformation.TelephoneNumbers.Count > 0) { foreach (var number in modem.DeviceInformation.TelephoneNumbers) { modemList.Add("MDN" + suffix + number); } } } ModemInformation = modemList.AsReadOnly(); }
private async void btnGetUICC_Click(object sender, RoutedEventArgs e) { try { var modem = MobileBroadbandModem.GetDefault(); MobileBroadbandModemConfiguration modemCfg = await modem.GetCurrentConfigurationAsync(); MobileBroadbandUicc uicc = modemCfg.Uicc; if (uicc != null) { StringBuilder sb = new StringBuilder(); sb.AppendLine("SIM Card ICCID:" + uicc.SimIccId); MobileBroadbandUiccAppsResult appsResult = await uicc.GetUiccAppsAsync(); System.Collections.ObjectModel.ObservableCollection <object> AppList = new System.Collections.ObjectModel.ObservableCollection <object>(); foreach (var uiccApp in appsResult.UiccApps) { ListBoxItem item = new ListBoxItem(); item.Name = uiccApp.Kind.ToString(); item.Content = uiccApp; AppList.Add(item); } listUiccApps.ItemsSource = AppList; if (AppList.Count > 0) { listUiccApps.SelectedIndex = 0; } else { sb.AppendLine("No UICC app found."); } txtUICCInformation.Text = sb.ToString(); } } catch (Exception ex) { rootPage.NotifyUser("Error:" + ex.Message, NotifyType.ErrorMessage); } }
private void btnDeviceService_Click(object sender, RoutedEventArgs e) { var modem = MobileBroadbandModem.GetDefault(); var deviceService = modem.DeviceServices; if (deviceService != null) { StringBuilder sb = new StringBuilder(); foreach (var d in deviceService) { sb.AppendLine(String.Format("DeviceService ID:{0}, Read Allowed:{1}, Write Allowed:{2}", d.DeviceServiceId.ToString(), d.IsDataReadSupported.ToString(), d.IsDataWriteSupported.ToString())); } txtModemInformation.Text = sb.ToString(); } else { rootPage.NotifyUser("No Device Services found.", NotifyType.ErrorMessage); } }
void GetCurrentDeviceInfo(string accountId) { try { // Test touching new TH objectq var modem = MobileBroadbandModem.GetDefault(); var deviceId = modem.DeviceInformation.DeviceId; var mobileBroadbandAccount = MobileBroadbandAccount.CreateFromNetworkAccountId(accountId); ProviderName.Text = mobileBroadbandAccount.ServiceProviderName; ProviderGuid.Text = mobileBroadbandAccount.ServiceProviderGuid.ToString(); NetworkAccountId.Text = mobileBroadbandAccount.NetworkAccountId; var currentNetwork = mobileBroadbandAccount.CurrentNetwork; if (currentNetwork != null) { string accessPointName = currentNetwork.AccessPointName; if (String.IsNullOrEmpty(accessPointName)) { accessPointName = "(not connected)"; } NetRegister.Text = currentNetwork.NetworkRegistrationState.ToString(); NetRegError.Text = NetErrorToString(currentNetwork.RegistrationNetworkError); PacketAttachError.Text = NetErrorToString(currentNetwork.PacketAttachNetworkError); ActivateError.Text = NetErrorToString(currentNetwork.ActivationNetworkError); AccessPointName.Text = accessPointName; NetworkAdapterId.Text = currentNetwork.NetworkAdapter.NetworkAdapterId.ToString(); NetworkType.Text = currentNetwork.NetworkAdapter.NetworkItem.GetNetworkTypes().ToString(); RegisteredProviderId.Text = currentNetwork.RegisteredProviderId; RegisteredProviderName.Text = currentNetwork.RegisteredProviderName; RegisteredDataClass.Text = currentNetwork.RegisteredDataClass.ToString(); } else { NetRegister.Text = ""; NetRegError.Text = ""; PacketAttachError.Text = ""; ActivateError.Text = ""; AccessPointName.Text = ""; NetworkAdapterId.Text = ""; NetworkType.Text = ""; RegisteredProviderId.Text = ""; RegisteredProviderName.Text = ""; RegisteredDataClass.Text = ""; } var deviceInformation = mobileBroadbandAccount.CurrentDeviceInformation; if (deviceInformation != null) { string mobileNumber = ""; if (deviceInformation.TelephoneNumbers.Count > 0) { mobileNumber = deviceInformation.TelephoneNumbers[0]; } DeviceManufacturer.Text = deviceInformation.Manufacturer; DeviceModel.Text = deviceInformation.Model; Firmware.Text = deviceInformation.FirmwareInformation; CellularClasses.Text = deviceInformation.CellularClass.ToString(); DataClasses.Text = deviceInformation.DataClasses.ToString(); if (deviceInformation.DataClasses.HasFlag(Windows.Networking.NetworkOperators.DataClasses.Custom)) { DataClasses.Text += " (custom is " + deviceInformation.CustomDataClass + ")"; } MobileNumber.Text = mobileNumber; SimId.Text = deviceInformation.SimIccId; DeviceType.Text = deviceInformation.DeviceType.ToString(); DeviceId.Text = deviceInformation.DeviceId.ToString(); NetworkDeviceStatus.Text = deviceInformation.NetworkDeviceStatus.ToString(); if (deviceInformation.CellularClass == CellularClass.Gsm) { MobEquipIdLabel.Text = "IMEI:"; MobEquipIdValue.Text = deviceInformation.MobileEquipmentId; SubIdLabel.Text = "IMSI:"; SubIdValue.Text = deviceInformation.SubscriberId; } else if (deviceInformation.CellularClass == CellularClass.Cdma) { MobEquipIdLabel.Text = "ESN/MEID:"; MobEquipIdValue.Text = deviceInformation.MobileEquipmentId; SubIdLabel.Text = "MIN/IRM:"; SubIdValue.Text = deviceInformation.SubscriberId; } else { MobEquipIdLabel.Text = ""; MobEquipIdValue.Text = ""; SubIdLabel.Text = ""; SubIdValue.Text = ""; } } else { DeviceManufacturer.Text = ""; DeviceModel.Text = ""; Firmware.Text = ""; CellularClasses.Text = ""; DataClasses.Text = ""; MobileNumber.Text = ""; SimId.Text = ""; DeviceType.Text = ""; DeviceId.Text = ""; NetworkDeviceStatus.Text = ""; MobEquipIdLabel.Text = ""; MobEquipIdValue.Text = ""; SubIdLabel.Text = ""; SubIdValue.Text = ""; } } catch (Exception ex) { rootPage.NotifyUser("Error:" + ex.Message, NotifyType.ErrorMessage); ProviderName.Text = ""; ProviderGuid.Text = ""; NetworkAccountId.Text = ""; NetRegister.Text = ""; NetRegError.Text = ""; PacketAttachError.Text = ""; ActivateError.Text = ""; AccessPointName.Text = ""; NetworkAdapterId.Text = ""; NetworkType.Text = ""; DeviceManufacturer.Text = ""; DeviceModel.Text = ""; Firmware.Text = ""; CellularClasses.Text = ""; DataClasses.Text = ""; MobileNumber.Text = ""; SimId.Text = ""; DeviceType.Text = ""; DeviceId.Text = ""; NetworkDeviceStatus.Text = ""; MobEquipIdLabel.Text = ""; MobEquipIdValue.Text = ""; SubIdLabel.Text = ""; SubIdValue.Text = ""; RegisteredProviderId.Text = ""; RegisteredProviderName.Text = ""; RegisteredDataClass.Text = ""; } }
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; }