private void btnInstall_Click(object sender, RoutedEventArgs e) { pb.Visibility = Visibility.Visible; Thread.Sleep(100); string apkfile = $"{Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)}\\AppDatas\\" + FilterSpecial(DelChinese(((Button)sender).Content.ToString()).Trim()).Trim(); if (_runningGroupIndex == -1) { MessageDialogManager.ShowDialogAsync(SystemLanguageManager.Instance.ResourceManager.GetString("Error_Please_Launch_A_Vm", SystemLanguageManager.Instance.CultureInfo)); return; } for (int i = 0; i < VmManager.Instance.Column; i++) { int vmIndex = VmManager.Instance.VmIndexArray[_runningGroupIndex, i]; if (vmIndex != -1) { Task.Run(() => { //ProcessUtils.AdbCloseService(vmIndex);//关闭服务 //int id = ProcessUtils.AdbSilentInstallation(vmIndex, apkfile); int id = ProcessUtils.AdbInstallApp(vmIndex, apkfile); Thread.Sleep(200); }); } } ((Button)e.Source).Click -= btnInstall_Click; ((Button)e.Source).Click += btnUninstall_Click; ((Button)e.Source).Content = SystemLanguageManager.Instance.ResourceManager.GetString("Uninstall", SystemLanguageManager.Instance.CultureInfo) + " " + ((InstallButton)e.Source).FileName; btnProgress_Click(sender, e); }
public async Task <string> InstallNewestApp() { try { await Task.Delay(2000); if (VmManager.Instance.RunningGroupIndex == -1) { return(MainView.resourceManager.GetString("Error_Please_Launch_A_Vm", MainView.cultureInfo)); } string appFolder = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "UpgradeApp"); if (!Directory.Exists(appFolder)) { Directory.CreateDirectory(appFolder); } string appFile = Path.Combine(appFolder, "app-release.apk"); if (!File.Exists(appFile)) { return(MainView.resourceManager.GetString("No_Updated_App", MainView.cultureInfo)); } for (int i = 0; i < VmManager.Instance.Column; i++) { int vmIndex = VmManager.Instance.VmIndexArray[VmManager.Instance.RunningGroupIndex, i]; if (vmIndex != -1) { ProcessUtils.AdbInstallApp(vmIndex, appFile); Thread.Sleep(200); } } File.Delete(appFile); return(MainView.resourceManager.GetString("Finish_App_Update", MainView.cultureInfo)); } catch (Exception ex) { LogUtils.Error($"{ex}"); return(MainView.resourceManager.GetString("Failed_App_Update", MainView.cultureInfo)); } }
private void btnInstall_Click(object sender, RoutedEventArgs e) { string apkfile = $"{Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)}\\AppDatas\\" + ((Button)sender).Content; if (_runningGroupIndex == -1) { MessageBox.Show(resourceManager.GetString("Error_Please_Launch_A_Vm", cultureInfo)); return; } for (int i = 0; i < VmManager.Instance.Column; i++) { int vmIndex = VmManager.Instance.VmIndexArray[_runningGroupIndex, i]; if (vmIndex != -1) { int id = ProcessUtils.AdbInstallApp(vmIndex, apkfile); Thread.Sleep(200); } } }
//安装whatsApp private void btn_installapp_Click(object sender, EventArgs e) { string apkfile = $"{Application.StartupPath}/AppDatas/WhatsApp.apk"; if (_runningGroupIndex == -1) { MessageBox.Show(resourceManager.GetString("Error_Please_Launch_A_Vm", cultureInfo)); return; } for (int i = 0; i < VmManager.Instance.Column; i++) { int vmIndex = VmManager.Instance.VmIndexArray[_runningGroupIndex, i]; if (vmIndex != -1) { int id = ProcessUtils.AdbInstallApp(vmIndex, apkfile); Thread.Sleep(200); } } }