Ejemplo n.º 1
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            rootPage = MainPage.Current;
            // Clear the messages
            rootPage.NotifyUser(String.Empty, NotifyType.StatusMessage, true);

            if (!ApplicationData.Current.RoamingSettings.Values.ContainsKey("DenyIfPhoneLocked"))
            {
                ApplicationData.Current.RoamingSettings.Values["DenyIfPhoneLocked"] = false;
            }

            if (!ApplicationData.Current.RoamingSettings.Values.ContainsKey("LaunchAboveLock"))
            {
                ApplicationData.Current.RoamingSettings.Values["LaunchAboveLock"] = false;
            }

            chkDenyIfPhoneLocked.IsChecked = (bool)ApplicationData.Current.RoamingSettings.Values["DenyIfPhoneLocked"];
            chkLaunchAboveLock.IsChecked   = (bool)ApplicationData.Current.RoamingSettings.Values["LaunchAboveLock"];

            isHceSupported = await CheckHceSupport();

            if (!isHceSupported)
            {
                btnRegisterBgTask.IsEnabled = false;
                btnAddCard.IsEnabled        = false;
            }
            else
            {
                lstCards.ItemsSource = await SmartCardEmulator.GetAppletIdGroupRegistrationsAsync();
            }

            Window.Current.VisibilityChanged += Window_VisibilityChanged;
        }
Ejemplo n.º 2
0
        private async void btnUnregisterCard_Click(object sender, RoutedEventArgs e)
        {
            // Clear the messages
            rootPage.NotifyUser(String.Empty, NotifyType.StatusMessage, true);

            var reg = (SmartCardAppletIdGroupRegistration)lstCards.SelectedItem;

            if (reg == null)
            {
                LogMessage("No card selected, must select from listbox", NotifyType.ErrorMessage);
                return;
            }

            // Unregister the card
            await SmartCardEmulator.UnregisterAppletIdGroupAsync(reg);

            if (reg.AppletIdGroup.SmartCardEmulationCategory == SmartCardEmulationCategory.Payment &&
                reg.AppletIdGroup.SmartCardEmulationType == SmartCardEmulationType.Host)
            {
                // Delete the data file for the card
                await(await Windows.Storage.ApplicationData.Current.LocalFolder.GetFileAsync("ReadRecordResponse-" + reg.Id.ToString("B") + ".dat")).DeleteAsync();
            }

            // Refresh the listbox
            lstCards.ItemsSource = await SmartCardEmulator.GetAppletIdGroupRegistrationsAsync();

            LogMessage("AID group successfully unregistered");
        }
Ejemplo n.º 3
0
        private async void Window_VisibilityChanged(object sender, VisibilityChangedEventArgs e)
        {
            // Since a registration can change from ForegroundOverride to Disabled when the device
            // is locked, update the registrations when the app window becomes visible
            if (e.Visible && isHceSupported)
            {
                // Clear the messages
                rootPage.NotifyUser(String.Empty, NotifyType.StatusMessage, true);

                lstCards.ItemsSource = await SmartCardEmulator.GetAppletIdGroupRegistrationsAsync();
            }
        }
        private async void btnForegroundOverrideCard_Click(object sender, RoutedEventArgs e)
        {
            // Clear the messages
            rootPage.NotifyUser(String.Empty, NotifyType.StatusMessage, true);

            var reg = (SmartCardAppletIdGroupRegistration)lstCards.SelectedItem;

            if (reg == null)
            {
                LogMessage("No card selected, must select from listbox", NotifyType.ErrorMessage);
                return;
            }

            await NfcUtils.SetCardActivationPolicy(reg, SmartCardAppletIdGroupActivationPolicy.ForegroundOverride);

            // Refresh the listbox
            lstCards.ItemsSource = await SmartCardEmulator.GetAppletIdGroupRegistrationsAsync();
        }
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            rootPage = MainPage.Current;

            if (!ApplicationData.Current.RoamingSettings.Values.ContainsKey("DenyIfPhoneLocked"))
            {
                ApplicationData.Current.RoamingSettings.Values["DenyIfPhoneLocked"] = false;
            }

            if (!ApplicationData.Current.RoamingSettings.Values.ContainsKey("LaunchAboveLock"))
            {
                ApplicationData.Current.RoamingSettings.Values["LaunchAboveLock"] = false;
            }

            chkDenyIfPhoneLocked.IsChecked = (bool)ApplicationData.Current.RoamingSettings.Values["DenyIfPhoneLocked"];
            chkLaunchAboveLock.IsChecked   = (bool)ApplicationData.Current.RoamingSettings.Values["LaunchAboveLock"];

            lstCards.ItemsSource = await SmartCardEmulator.GetAppletIdGroupRegistrationsAsync();
        }
Ejemplo n.º 6
0
        public static async Task <SmartCardAppletIdGroupRegistration> GetAidGroupById(Guid id)
        {
            try
            {
                // Find registration
                var reg = (from r in await SmartCardEmulator.GetAppletIdGroupRegistrationsAsync()
                           where r.Id == id
                           select r).SingleOrDefault();
                if (reg == null)
                {
                    LogMessage("No matching AID group found for specified ID", NotifyType.ErrorMessage);
                }

                return(reg);
            }
            catch (Exception ex)
            {
                LogMessage("Failed to get AID group by ID: " + ex.ToString(), NotifyType.StatusMessage);
                throw;
            }
        }