private async void Page_LoadedAsync(object sender, RoutedEventArgs e) { foreach (var info in await AppDiagnosticInfo.RequestInfoAsync()) { /*Items.Add(new AppInfo * { * Id = info.AppInfo.Id, * PackageFamilyName = info.AppInfo.PackageFamilyName, * Description = info.AppInfo.DisplayInfo.Description, * DisplayName = info.AppInfo.DisplayInfo.DisplayName, * AppUserModelId = info.AppInfo.AppUserModelId, * });*/ } foreach (var info in ProcessDiagnosticInfo.GetForProcesses()) { /*ProcessItems.Add(new ProcessInfo * { * ExecutableFileName = info.ExecutableFileName, * ProcessId = $"{info.ProcessId}", * CpuUsage = $"{info.CpuUsage.GetReport().UserTime:hh':'mm':'ss}", * MemoryUsage = $"{info.MemoryUsage.GetReport().WorkingSetSizeInBytes:N0}", * });*/ } }
private void InvokeLaunch(Version v) { if (_hasLaunchTask) { return; } _hasLaunchTask = true; Task.Run(async() => { string gameDir = Path.GetFullPath(v.GameDirectory); try { await ReRegisterPackage(gameDir); } catch (Exception e) { Debug.WriteLine("App re-register failed:\n" + e.ToString()); MessageBox.Show("App re-register failed:\n" + e.ToString()); _hasLaunchTask = false; return; } try { var pkg = await AppDiagnosticInfo.RequestInfoForPackageAsync(MINECRAFT_PACKAGE_FAMILY); if (pkg.Count > 0) { await pkg[0].LaunchAsync(); } Debug.WriteLine("App launch finished!"); _hasLaunchTask = false; } catch (Exception e) { Debug.WriteLine("App launch failed:\n" + e.ToString()); MessageBox.Show("App launch failed:\n" + e.ToString()); _hasLaunchTask = false; return; } }); }
async public Task <DiagnosticAccessStatus> GetAccessStatus() { // Request user consent to use the diagnostic APIs. DiagnosticAccessStatus accessStatus = await AppDiagnosticInfo.RequestAccessAsync(); return(accessStatus); }
async Task PlatformAnnotate(NGContact contact, NGAnnotations annotations) { ContactAnnotationOperations winAnnotations = (ContactAnnotationOperations)annotations; if (winAnnotations == ContactAnnotationOperations.None) { winAnnotations = ContactAnnotationOperations.ContactProfile; } // Annotate this contact with a remote ID, which you can then retrieve when the Contact Panel is activated. var contactAnnotation = new ContactAnnotation { ContactId = contact.Id, RemoteId = contact.RemoteId, SupportedOperations = winAnnotations }; // Annotate that this contact can load this app's Contact Panel or Contact Share. var infos = await AppDiagnosticInfo.RequestInfoForAppAsync(); contactAnnotation.ProviderProperties.Add("ContactPanelAppID", infos[0].AppInfo.AppUserModelId); if ((winAnnotations & ContactAnnotationOperations.Share) == ContactAnnotationOperations.Share) { contactAnnotation.ProviderProperties.Add("ContactShareAppID", infos[0].AppInfo.AppUserModelId); } var annotationList = await FindOrRegisterAnnotationList(); await annotationList.TrySaveAnnotationAsync(contactAnnotation); }
private async void Grid_Loaded(object sender, RoutedEventArgs e) { try { Windows.Storage.StorageFolder storageFolder = Windows.Storage.ApplicationData.Current.LocalFolder; Windows.Storage.StorageFile sampleFile = await storageFolder.GetFileAsync("pass.txt"); var lp = (await Windows.Storage.FileIO.ReadTextAsync(sampleFile)).Split('\n'); singlton.api.Authorize(new ApiAuthParams() { Login = lp[1], Password = lp[0], ApplicationId = singlton.appId, Settings = Settings.All }); } catch (Exception ex) { answTextBlock.Text = ex.Message; } DiagnosticAccessStatus diagnosticAccessStatus = await AppDiagnosticInfo.RequestAccessAsync(); var requestStatus = await Windows.ApplicationModel.Background.BackgroundExecutionManager.RequestAccessAsync(); DispatcherTimer timer = new DispatcherTimer() { Interval = new TimeSpan(0, 0, 0, 20, 0) }; timer.Tick += Timer_Tick; timer.Start(); }
private async Task Minimize() { IList <AppDiagnosticInfo> infos = await AppDiagnosticInfo.RequestInfoForAppAsync(); IList <AppResourceGroupInfo> resourceInfos = infos[0].GetResourceGroups(); await resourceInfos[0].StartSuspendAsync(); }
public static async void MinimizeWindow() { IList <AppDiagnosticInfo> infos = await AppDiagnosticInfo.RequestInfoForAppAsync(); IList <AppResourceGroupInfo> resourceInfos = infos[0].GetResourceGroups(); await resourceInfos[0].StartSuspendAsync(); }
private async Task<bool> LaunchGame(MCVersion v, bool KeepLauncherOpen) { try { ViewModels.LauncherModel.Default.CurrentState = ViewModels.LauncherModel.StateChange.isLaunching; var pkg = await AppDiagnosticInfo.RequestInfoForPackageAsync(MINECRAFT_PACKAGE_FAMILY); AppActivationResult activationResult = null; if (pkg.Count > 0) activationResult = await pkg[0].LaunchAsync(); System.Diagnostics.Debug.WriteLine("App launch finished!"); if (KeepLauncherOpen && activationResult != null) GetGameProcess(activationResult); if (KeepLauncherOpen == false) { await Application.Current.Dispatcher.InvokeAsync(() => { Application.Current.MainWindow.Close(); }); return true; } else { ViewModels.LauncherModel.Default.CurrentState = ViewModels.LauncherModel.StateChange.None; return false; } } catch (Exception e) { ViewModels.LauncherModel.Default.CurrentState = ViewModels.LauncherModel.StateChange.None; System.Diagnostics.Debug.WriteLine("App launch failed:\n" + e.ToString()); ErrorScreenShow.errormsg("Error_AppLaunchFailed_Title", "Error_AppLaunchFailed", e); throw e; } }
/// <summary> /// request for app diagnostic info /// </summary> private async void LoadAppInfo() { mainViewModel.AppInfoList.Clear(); IList <AppDiagnosticInfo> list = await AppDiagnosticInfo.RequestInfoAsync(); list.ToList().ForEach(o => mainViewModel.AppInfoList.Add(new AppInfoModel(o.AppInfo))); }
private async void runBack() { IList <AppDiagnosticInfo> infos = await AppDiagnosticInfo.RequestInfoForAppAsync(); IList <AppResourceGroupInfo> appResources = infos[0].GetResourceGroups(); await appResources[0].StartSuspendAsync(); }
public object Convert(object value, Type targetType, object parameter, string language) { if (value is PhoneCallHistoryEntry entry) { try { IRandomAccessStream stream; switch (entry.RemoteId) { case string celluarID when celluarID.StartsWith(PhoneLineTransport.Cellular.ToString()): celluarID = celluarID.Split('|')[1]; IAsyncOperation <PhoneLine> task0 = PhoneLine.FromIdAsync(Guid.Parse(celluarID)); task0.AsTask().Wait(); IAsyncOperation <IReadOnlyList <AppListEntry> > task3 = Package.Current.GetAppListEntriesAsync(); task3.AsTask().Wait(); IAsyncOperation <IRandomAccessStreamWithContentType> task2 = task3.GetResults().First().DisplayInfo.GetLogo(new Size(512, 512)).OpenReadAsync(); task2.AsTask().Wait(); stream = task2.GetResults(); break; case string appID when appID.StartsWith(PhoneLineTransport.VoipApp.ToString()): appID = appID.Split('|')[1]; IAsyncOperation <IList <AppDiagnosticInfo> > task1 = AppDiagnosticInfo.RequestInfoForPackageAsync(appID); task1.AsTask().Wait(); task2 = task1.GetResults().First().AppInfo.DisplayInfo.GetLogo(new Size(512, 512)).OpenReadAsync(); task2.AsTask().Wait(); stream = task2.GetResults(); break; case string deviceID when deviceID.StartsWith(PhoneLineTransport.Bluetooth.ToString()): //deviceID = deviceID.Split('|')[1]; //task0 = PhoneLine.FromIdAsync(Guid.Parse(deviceID)); //task0.AsTask().Wait(); //IAsyncOperation<DeviceInformation> task3 = DeviceInformation.CreateFromIdAsync(task0.GetResults().TransportDeviceId); //task3.AsTask().Wait(); //IAsyncOperation<DeviceThumbnail> task4 = task3.GetResults().GetThumbnailAsync(); //task4.AsTask().Wait(); //stream = task4.GetResults(); //break; default: return(null); } BitmapImage a = new BitmapImage(); a.SetSource(stream); return(a); } catch { return(null); } } else { return(null); } }
/// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used such as when the application is launched to open a specific file. /// </summary> /// <param name="e">Details about the launch request and process.</param> protected override async void OnLaunched(LaunchActivatedEventArgs e) { _logger.LogInformation("=== Start Application ==="); _settingsService.SetProgramLanguage(null); SystemNavigationManager.GetForCurrentView().BackRequested += OnBackRequested; var rootFrame = Window.Current.Content as Frame; // Do not repeat app initialization when the Window already has content, // just ensure that the window is active if (rootFrame == null) { // Create a Frame to act as the navigation context and navigate to the first page rootFrame = new Frame(); rootFrame.NavigationFailed += OnNavigationFailed; if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { // TODO: Load state from previously suspended application } // Place the frame in the current Window Window.Current.Content = rootFrame; } if (e.PrelaunchActivated == false) { if (rootFrame.Content == null) { // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter rootFrame.Navigate(typeof(MainPage), e.Arguments); } // Ensure the current window is active Window.Current.Activate(); Settings settings = _settingsService.Load(); if (settings.StartAppMinimized.HasValue && settings.StartAppMinimized.Value) { IList <AppDiagnosticInfo> infos = await AppDiagnosticInfo.RequestInfoForAppAsync(); AppDiagnosticInfo appDiagnosticInfo = infos.FirstOrDefault(); if (appDiagnosticInfo != null) { IList <AppResourceGroupInfo> resourceInfos = appDiagnosticInfo.GetResourceGroups(); await resourceInfos[0].StartSuspendAsync(); } } } }
private async void GetProcessRequest_Click(object sender, RoutedEventArgs e) { var judge = await GetRequest(); if (judge == true) { AppDiagnosticInfo.RequestAccessAsync(); } }
public static async Task StartTerminateAsync() { IList <AppDiagnosticInfo> infos = await AppDiagnosticInfo.RequestInfoForAppAsync(); IList <AppResourceGroupInfo> resourceInfos = infos[0].GetResourceGroups(); var pid = Windows.System.Diagnostics.ProcessDiagnosticInfo.GetForCurrentProcess().ProcessId; await resourceInfos.Single(r => r.GetProcessDiagnosticInfos()[0].ProcessId == pid).StartTerminateAsync(); //Application.Current.Exit(); }
public static async Task SuspendAppAsync() { AppResourceGroupInfo appResourceGroupInfo = null; // for Windows v1803 aka build 17134 and above, we can minimize by suspending // cannot minimize a full screen window, so take the app out of full screen ApplicationView view = ApplicationView.GetForCurrentView(); if (view.IsFullScreenMode) { view.ExitFullScreenMode(); } // figure out if we can suspend and can get the references we need if (ConfigurationService.DoesOSBuildSupportSuspend()) { // get app diagnostic information IList <AppDiagnosticInfo> diagnosticInformations = await AppDiagnosticInfo.RequestInfoForAppAsync(); // if we got them if ((null != diagnosticInformations) && (diagnosticInformations.Count > 0)) { // loop through the informations foreach (AppDiagnosticInfo diagnosticInformation in diagnosticInformations) { // if we find one with Id = "App" if (0 == String.Compare(diagnosticInformation.AppInfo.Id, "App", true)) { // get the resource groups from that diagnostic information IList <AppResourceGroupInfo> resourceGroups = diagnosticInformation.GetResourceGroups(); // if we got them if ((null != resourceGroups) && (resourceGroups.Count > 0)) { // take the first resource group appResourceGroupInfo = resourceGroups[0]; } } } } } // if we got a suspendable object, use it if (null != appResourceGroupInfo) { // we can suspend and got an resource info object to use AppExecutionStateChangeResult result = await appResourceGroupInfo.StartSuspendAsync(); } else { // we can't suspend, so must exit App.Current.Exit(); } }
private static async Task <BitmapImage> GetLogoAsync(AppDiagnosticInfo app) { RandomAccessStreamReference stream = app.AppInfo.DisplayInfo.GetLogo(new Size(64, 64)); IRandomAccessStreamWithContentType content = await stream.OpenReadAsync(); BitmapImage bitmapImage = new BitmapImage(); await bitmapImage.SetSourceAsync(content); return(bitmapImage); }
public static async Task <bool> CheckForRunningProcess(string processName) { //Requests permission for app. await AppDiagnosticInfo.RequestAccessAsync(); //Gets the running processes. var processes = ProcessDiagnosticInfo.GetForProcesses(); //Returns result of searching for process name. return(processes.Any(processDiagnosticInfo => processDiagnosticInfo.ExecutableFileName.Contains(processName))); }
public async Task ExitApp() { StopRecording(); ClearExtendedExecution(); await Utils.JumpListMenu.Clear(); IList <AppDiagnosticInfo> infos = await AppDiagnosticInfo.RequestInfoForAppAsync(); IList <AppResourceGroupInfo> resourceInfos = infos[0].GetResourceGroups(); await resourceInfos[0].StartTerminateAsync(); // terminate the app }
private bool AddOrUpdateApp( AppDiagnosticInfo app, RowAggregateData appData, ExecutionStateEx appExecutionState) { bool result = false; string name = "(unknown)"; string appId = string.Empty; if (app.AppInfo != null && app.AppInfo.DisplayInfo != null) { appId = app.AppInfo.AppUserModelId; name = app.AppInfo.DisplayInfo.DisplayName; } // Check to see if this app is already in our list, and only add it if it wasn't already there. bool isAppFound = false; foreach (AppRowInfo existingRow in this) { if (appId == existingRow.Id) { isAppFound = true; break; } } // Don't add apps for resource groups that are not running. // Otherwise, for one thing, trying to get the logo would throw. if (!isAppFound && appExecutionState != ExecutionStateEx.NotRunning) { BitmapImage logo = GetLogoFromAppInfo(app); // A new app has appeared, so we add it to the list. AppRowInfo appRow = new AppRowInfo( app, appId, logo, name, appData.CommitLimit, appData.TotalCommit, appData.PrivateCommit, appData.ExecutionState, appData.EnergyState, appData.BgTaskCount); Add(appRow); result = true; } else { // For existing rows, we'll update the dynamic state. IEnumerable <AppRowInfo> appRows = this.Where(r => r.Id == appId); if (appRows != null && appRows.Count() > 0) { AppRowInfo existingApp = appRows.First(); existingApp.Update( appData.CommitLimit, appData.TotalCommit, appData.PrivateCommit, appData.ExecutionState, appData.EnergyState, appData.BgTaskCount); } } return(result); }
public async Task <bool> RequestDiagnosticAccess() { try { Diagnostic = await AppDiagnosticInfo.RequestAccessAsync(); } catch { Diagnostic = null; } return(Diagnostic.HasValue); }
public async void Minimize() { try { IList <AppDiagnosticInfo> infos = await AppDiagnosticInfo.RequestInfoForAppAsync(); IList <AppResourceGroupInfo> resourceInfos = infos[0].GetResourceGroups(); resourceInfos[0].StartSuspendAsync(); } catch (Exception ex) { Debug.Write(ex); } }
public async static void RequestAccessAsync() { DiagnosticAccessStatus diagnosticAccessStatus = await AppDiagnosticInfo.RequestAccessAsync(); switch (diagnosticAccessStatus) { case DiagnosticAccessStatus.Allowed: Debug.WriteLine("We can get diagnostics for all apps."); break; case DiagnosticAccessStatus.Limited: Debug.WriteLine("We can only get diagnostics for this app package."); break; } }
private BitmapImage GetLogoFromAppInfo(AppDiagnosticInfo app) { BitmapImage bitmapImage = new BitmapImage(); if (app != null && app.AppInfo != null && app.AppInfo.DisplayInfo != null) { // AppDisplayInfo.GetLogo gets the largest logo defined in the package that fits the given size. RandomAccessStreamReference stream = app.AppInfo.DisplayInfo.GetLogo(new Size(64, 64)); IAsyncOperation <IRandomAccessStreamWithContentType> streamOperation = stream.OpenReadAsync(); Task <IRandomAccessStreamWithContentType> streamTask = streamOperation.AsTask(); streamTask.Wait(); IRandomAccessStreamWithContentType content = streamTask.Result; IAsyncAction imageAction = bitmapImage.SetSourceAsync(content); } return(bitmapImage); }
static async void ThreadProc() { var result = await AppDiagnosticInfo.RequestAccessAsync(); if (result == DiagnosticAccessStatus.Allowed) { string baseAddress = "http://localhost:5000/"; WebApp.Start <Startup>(url: baseAddress); } var info = await AppDiagnosticInfo.RequestInfoForAppAsync(); var watcher = info.FirstOrDefault().CreateResourceGroupWatcher(); watcher.ExecutionStateChanged += Watcher_ExecutionStateChanged; watcher.Start(); }
public AppRowInfo( AppDiagnosticInfo a, string id, BitmapImage logo, string name, ulong limit, ulong totCommit, ulong prvCommit, ExecutionStateEx exState, EnergyQuotaStateEx eqState, int taskCount) { Adi = a; Id = id; Logo = logo; Name = name; commitLimit = limit; totalCommit = totCommit; privateCommit = prvCommit; executionState = exState; energyQuotaState = eqState; backgroundTaskCount = taskCount; }
private async void MediaPlayer_CurrentStateChanged(MediaPlayer sender, object args) { if (sender.PlaybackSession.PlaybackState == MediaPlaybackState.Playing) { session = new ExtendedExecutionForegroundSession(); session.Reason = ExtendedExecutionForegroundReason.BackgroundAudio; var result = await session.RequestExtensionAsync(); if (result != ExtendedExecutionForegroundResult.Allowed) { throw new Exception("EE denied"); } IList <AppDiagnosticInfo> infos = await AppDiagnosticInfo.RequestInfoForAppAsync(); IList <AppResourceGroupInfo> resourceInfos = infos[0].GetResourceGroups(); await resourceInfos[0].StartSuspendAsync(); } }
public object Convert(object value, Type targetType, object parameter, string language) { if (value is PhoneCallHistoryEntry entry) { try { switch (entry.RemoteId) { case string celluarID when celluarID.StartsWith(PhoneLineTransport.Cellular.ToString()): celluarID = celluarID.Split('|')[1]; IAsyncOperation <PhoneLine> task0 = PhoneLine.FromIdAsync(Guid.Parse(celluarID)); task0.AsTask().Wait(); return(task0.GetResults().NetworkName); case string appID when appID.StartsWith(PhoneLineTransport.VoipApp.ToString()): appID = appID.Split('|')[1]; IAsyncOperation <IList <AppDiagnosticInfo> > task1 = AppDiagnosticInfo.RequestInfoForPackageAsync(appID); task1.AsTask().Wait(); return(task1.GetResults().First().AppInfo.DisplayInfo.DisplayName); case string deviceID when deviceID.StartsWith(PhoneLineTransport.Bluetooth.ToString()): deviceID = deviceID.Split('|')[1]; IAsyncOperation <DeviceInformation> task2 = DeviceInformation.CreateFromIdAsync(deviceID); task2.AsTask().Wait(); return(task2.GetResults().Name); default: return(string.Empty); } } catch { return(string.Empty); } } else { return(string.Empty); } }
private async Task <bool> LaunchGame(MCVersion v) { try { ViewModels.LauncherModel.Default.CurrentState = ViewModels.LauncherModel.StateChange.isLaunching; var pkg = await AppDiagnosticInfo.RequestInfoForPackageAsync(MINECRAFT_PACKAGE_FAMILY); if (pkg.Count > 0) { await pkg[0].LaunchAsync(); } System.Diagnostics.Debug.WriteLine("App launch finished!"); if (Properties.LauncherSettings.Default.KeepLauncherOpen) { GetGameProcess(v); } if (Properties.LauncherSettings.Default.KeepLauncherOpen == false) { await Application.Current.Dispatcher.InvokeAsync(() => { Application.Current.MainWindow.Close(); }); return(true); } else { ViewModels.LauncherModel.Default.CurrentState = ViewModels.LauncherModel.StateChange.None; return(false); } } catch (Exception e) { ViewModels.LauncherModel.Default.CurrentState = ViewModels.LauncherModel.StateChange.None; System.Diagnostics.Debug.WriteLine("App launch failed:\n" + e.ToString()); Application.Current.Dispatcher.Invoke(() => { ErrorScreenShow.errormsg("applauncherror"); }); throw e; } }
private async Task <bool> GetRequest() { DiagnosticAccessStatus temp = await AppDiagnosticInfo.RequestAccessAsync(); switch (temp) { case DiagnosticAccessStatus.Allowed: { GetProcessRequest.IsEnabled = false; break; } case DiagnosticAccessStatus.Limited: { AppDiagnosticInfo.RequestAccessAsync(); GetProcessRequest.IsEnabled = true; return(true); } } return(false); }
private async void NotiBootstrap() { var builder = new ToastContentBuilder(); try { var infos = await AppDiagnosticInfo.RequestInfoForAppAsync(); var resourceInfos = infos[0].GetResourceGroups(); await resourceInfos[0].StartSuspendAsync(); if (UWPAppEnvironment.toastNotifier == null) { UWPAppEnvironment.toastNotifier = ToastNotificationManager.CreateToastNotifier(); } var notiUWP = new NotiScheduleUWP(); notiUWP.CancelAll(); notiUWP.ScheduleAll(); builder.AddToastActivationInfo("BootNotiRegister", ToastActivationType.Foreground); builder.AddText(AppResources.BootAlarmRegisterSuccess); } catch (Exception) { builder.AddText(AppResources.BootAlarmRegisterFail); } finally { if (builder != null) { UWPAppEnvironment.toastNotifier.AddToSchedule(new ScheduledToastNotification(builder.GetToastContent().GetXml(), DateTime.Now.AddSeconds(3))); } await Task.Delay(3000); Exit(); } }