internal void UninstallApp(string packageName) { DownloadInstallApk.SerialWorkQueueInstaller(this.ParentWindow.mVmName).Enqueue((SerialWorkQueue.Work)(() => { Logger.Info("Uninstall started : " + packageName); Dictionary <string, string> data = new Dictionary <string, string>() { ["package"] = packageName }; try { JArray jarray = JArray.Parse(HTTPUtils.SendRequestToAgent("uninstall", data, this.ParentWindow.mVmName, 0, (Dictionary <string, string>)null, false, 1, 0, "bgp", true)); try { if (!JObject.Parse(jarray[0].ToString())["success"].ToObject <bool>()) { ClientStats.SendClientStatsAsync("uninstall", "fail", "app_install", packageName, "", ""); } else { this.UpdateCdnAppEntry(false, packageName, ""); } } catch { } } catch (Exception ex) { Logger.Error("Failed to uninstall app. Err: " + ex.Message); } Logger.Info("Uninstall completed for " + packageName); })); }
private AppIconUI GetNewAppIconUI( AppIconModel iconModel, DownloadInstallApk downloadInstallApk = null) { AppIconUI appIconUi = new AppIconUI(this.ParentWindow, iconModel); if (downloadInstallApk != null) { appIconUi.InitAppDownloader(downloadInstallApk); } return(appIconUi); }
public void DownloadApk( string apkUrl, string packageName, bool isLaunchAfterInstall, bool isDeleteApk, string timestamp = "") { string str = Path.Combine(RegistryStrings.DataDir, "DownloadedApk"); if (!Directory.Exists(str)) { Directory.CreateDirectory(str); } string path2 = Regex.Replace(packageName + ".apk", "[\\x22\\\\\\/:*?|<>]", " "); string apkFilePath = Path.Combine(str, path2); Logger.Info("Downloading Apk file to: " + apkFilePath); this.ParentWindow.mWelcomeTab.mHomeAppManager.DownloadStarted(packageName); ClientStats.SendClientStatsAsync("download", "unknown", "app_install", packageName, "", ""); this.mDownloadThread = new Thread((ThreadStart)(() => { string apkUrl1 = apkUrl; if (DownloadInstallApk.IsContainsGoogleAdId(apkUrl1)) { apkUrl = this.AddGoogleAdidWithApk(apkUrl1); } apkUrl = BlueStacksUIUtils.GetFinalRedirectedUrl(apkUrl); if (string.IsNullOrEmpty(apkUrl)) { return; } this.mIsDownloading = true; this.mDownloader = new LegacyDownloader(3, apkUrl, apkFilePath); this.mDownloader.Download((LegacyDownloader.UpdateProgressCallback)(percent => this.ParentWindow.mWelcomeTab.mHomeAppManager.UpdateAppDownloadProgress(packageName, percent)), (LegacyDownloader.DownloadCompletedCallback)(filePath => { ClientStats.SendClientStatsAsync("download", "success", "app_install", packageName, "", ""); this.mIsDownloading = false; this.ParentWindow.mWelcomeTab.mHomeAppManager.DownloadCompleted(packageName, filePath); this.InstallApk(packageName, filePath, isLaunchAfterInstall, isDeleteApk, timestamp); DownloadInstallApk.sDownloadedApkList.Add(packageName); }), (LegacyDownloader.ExceptionCallback)(ex => { ClientStats.SendClientStatsAsync("download", "fail", "app_install", packageName, "", ""); this.ParentWindow.mWelcomeTab.mHomeAppManager.DownloadFailed(packageName); Logger.Error("Failed to download file: {0}. err: {1}", (object)apkFilePath, (object)ex.Message); }), (LegacyDownloader.ContentTypeCallback)null, (LegacyDownloader.SizeDownloadedCallback)null, (LegacyDownloader.PayloadInfoCallback)null); })) { IsBackground = true }; this.mDownloadThread.Start(); }
private void DownloadingApp(AppIconDownloadingPhases downloadPhase) { this.Dispatcher.Invoke((Delegate)(() => { switch (downloadPhase) { case AppIconDownloadingPhases.DownloadStarted: this.ParentWindow.mTopBar.mAppTabButtons.GoToTab("Home", true, false); this.mErrorGrid.Visibility = Visibility.Hidden; this.mProgressGrid.Visibility = Visibility.Visible; break; case AppIconDownloadingPhases.DownloadFailed: this.mErrorGrid.Visibility = Visibility.Visible; break; case AppIconDownloadingPhases.Downloading: this.mProgressGrid.Visibility = Visibility.Visible; break; case AppIconDownloadingPhases.DownloadCompleted: this.mProgressGrid.Visibility = Visibility.Hidden; this.mBusyGrid.Visibility = Visibility.Visible; break; case AppIconDownloadingPhases.InstallStarted: this.ShowAppUninstallButton(false); this.mErrorGrid.Visibility = Visibility.Hidden; this.mBusyGrid.Visibility = Visibility.Visible; break; case AppIconDownloadingPhases.InstallFailed: if (this.mAppIconModel.mIsAppInstalled) { break; } this.mBusyGrid.Visibility = Visibility.Hidden; this.mErrorGrid.Visibility = Visibility.Visible; break; case AppIconDownloadingPhases.InstallCompleted: this.mBusyGrid.Visibility = Visibility.Hidden; this.mDownloader = (DownloadInstallApk)null; this.mAppIconModel.mAppDownloadingEvent -= new System.Action <AppIconDownloadingPhases>(this.DownloadingApp); break; } })); }
internal void AddAppIcon( string package, string appName, string apkUrl, DownloadInstallApk downloader) { if (string.IsNullOrEmpty(package)) { return; } AppIconModel newIconForKey = this.GetNewIconForKey(package); newIconForKey.Init(package, appName, apkUrl); newIconForKey.AddToInstallDrawer(); this.mHomeApp?.AddInstallDrawerIcon(newIconForKey, downloader); }
internal void AddInstallDrawerIcon(AppIconModel icon, DownloadInstallApk downloadInstallApk = null) { int index = 0; foreach (AppIconUI appIconUi in this.InstalledAppsDrawer.Children.OfType <AppIconUI>()) { if (appIconUi.mAppIconModel.MyAppPriority <= icon.MyAppPriority) { ++index; } else { break; } } AppIconUI newAppIconUi = this.GetNewAppIconUI(icon, downloadInstallApk); this.InstalledAppsDrawer.Children.Insert(index, (UIElement)newAppIconUi); }
internal void AddDockPanelIcon(AppIconModel icon, DownloadInstallApk downloadInstallApk = null) { int index = 0; foreach (AppIconUI appIconUi in this.mDockPanel.Children.OfType <AppIconUI>()) { if (appIconUi.mAppIconModel.MyAppPriority <= icon.MyAppPriority) { ++index; } else { break; } } AppIconUI newAppIconUi = this.GetNewAppIconUI(icon, downloadInstallApk); this.mDockPanel.Children.Insert(index, (UIElement)newAppIconUi); this.mDockPanel.Children.Remove((UIElement)this.moreAppsIcon); this.mDockPanel.Children.Add((UIElement)this.moreAppsIcon); }
internal void InitAppDownloader(DownloadInstallApk downloadInstallApk = null) { this.mDownloader = downloadInstallApk; this.mAppIconModel.mAppDownloadingEvent += new System.Action <AppIconDownloadingPhases>(this.DownloadingApp); }
internal void InstallApk( string packageName, string apkPath, bool isLaunchAfterInstall, bool isDeleteApk, string timestamp = "") { this.ParentWindow.mWelcomeTab.mHomeAppManager.ApkInstallStart(packageName, apkPath); DownloadInstallApk.SerialWorkQueueInstaller(this.ParentWindow.mVmName).Enqueue((SerialWorkQueue.Work)(() => { Logger.Info("Installing apk: {0}", (object)apkPath); int num = BluestacksProcessHelper.RunApkInstaller(apkPath, true, this.ParentWindow.mVmName); Logger.Info("Apk installer exit code: {0}", (object)num); if (num == 0) { if (DownloadInstallApk.sDownloadedApkList.Contains(packageName)) { ClientStats.SendClientStatsAsync("install_from_download", "success", "app_install", packageName, "", ""); DownloadInstallApk.sDownloadedApkList.Remove(packageName); this.UpdateCdnAppEntry(true, packageName, timestamp); } else if (DownloadInstallApk.sApkInstalledFromChooser.Contains(packageName)) { ClientStats.SendClientStatsAsync("install", "success", "app_install", packageName, "", ""); DownloadInstallApk.sApkInstalledFromChooser.Remove(packageName); } this.ParentWindow.mWelcomeTab.mHomeAppManager.ApkInstallCompleted(packageName); if (isLaunchAfterInstall) { this.ParentWindow.Utils.RunAppOrCreateTabButton(packageName); } Logger.Info("Installation successful."); if (isDeleteApk) { File.Delete(apkPath); } Logger.Info("Install Completed : " + packageName); } else { if (DownloadInstallApk.sDownloadedApkList.Contains(packageName)) { ClientStats.SendClientStatsAsync("install_from_download", "fail", "app_install", packageName, num.ToString((IFormatProvider)CultureInfo.InvariantCulture), ""); DownloadInstallApk.sDownloadedApkList.Remove(packageName); } else if (DownloadInstallApk.sApkInstalledFromChooser.Contains(packageName)) { ClientStats.SendClientStatsAsync("install", "fail", "app_install", packageName, num.ToString((IFormatProvider)CultureInfo.InvariantCulture), ""); DownloadInstallApk.sApkInstalledFromChooser.Remove(packageName); } ClientStats.SendGeneralStats("apk_inst_error", new Dictionary <string, string>() { { "errcode", Convert.ToString(num, (IFormatProvider)CultureInfo.InvariantCulture) }, { "precode", "0" }, { "app_pkg", packageName } }); this.ParentWindow.mWelcomeTab.mHomeAppManager.ApkInstallFailed(packageName); } })); }