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); })); }
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); } })); }