public static int SilentUninstallApp( string package, bool nolookup, string vmName, out string reason) { reason = ""; JsonParser jsonParser = new JsonParser(vmName); AppUninstaller.s_originalJson = jsonParser.GetAppList(); Logger.Info("nolookup: " + nolookup.ToString()); string str; if (!nolookup) { string imageName; jsonParser.GetAppInfoFromPackageName(package, out string _, out imageName, out string _, out str); Logger.Info("AppUninstaller: Got image name: " + imageName); if (imageName == null) { Logger.Info("AppUninstaller: App not found"); return(-1); } } if (!Utils.IsAppInstalled(package, vmName, out str)) { Logger.Info("App not installed, removing entry from apps.json if there"); AppUninstaller.RemoveFromJson(package, vmName); reason = "App Not Installed"; return(1); } int num = AppUninstaller.UninstallApp(package, vmName); if (num == 0) { Logger.Info("AppUninstaller: Uninstallation successful"); return(num); } Logger.Warning("AppUninstaller: Uninstallation failed"); return(num); }
public static string RemoveFromJson(string packageName, string vmName) { Logger.Info("AppUninstaller: Removing app from json: " + packageName); JsonParser jsonParser = new JsonParser(vmName); AppUninstaller.s_originalJson = jsonParser.GetAppList(); int num = 0; string str = ""; for (int index = 0; index < AppUninstaller.s_originalJson.Length; ++index) { if (AppUninstaller.s_originalJson[index].Package == packageName) { str = AppUninstaller.s_originalJson[index].Name; ++num; } } AppInfo[] json = new AppInfo[AppUninstaller.s_originalJson.Length - num]; int index1 = 0; int index2 = 0; for (; index1 < AppUninstaller.s_originalJson.Length; ++index1) { if (AppUninstaller.s_originalJson[index1].Package == packageName) { AppUninstaller.RemoveFromLibrary(AppUninstaller.s_originalJson[index1].Name, AppUninstaller.s_originalJson[index1].Package, AppUninstaller.s_originalJson[index1].Img); AppUninstaller.RemoveAppTile(AppUninstaller.s_originalJson[index1].Package); } else { json[index2] = AppUninstaller.s_originalJson[index1]; ++index2; } } jsonParser.WriteJson(json); return(str); }
public static void AppUninstalled( string packageName, string vmName, string source, string campaignName, string clientVersion) { string appName = AppUninstaller.RemoveFromJson(packageName, vmName); try { if (Oem.Instance.IsCreateDesktopIconForApp) { if (string.Compare(vmName, "Android", true) == 0) { foreach (string file in Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), "*.lnk", SearchOption.AllDirectories)) { try { if (Utils.IsShortcutArgumentContainsPackage(file, packageName)) { File.Delete(file); } } catch (Exception ex) { Logger.Warning("Error while checking file for deleting shortcut, filename: " + file); } } } } } catch (Exception ex) { Logger.Warning("Error while deleting shortcut icons for apps from desktop. Error: " + ex.ToString()); } if (Oem.Instance.IsOEMWithBGPClient) { try { HTTPUtils.SendRequestToClient("appUninstalled", new Dictionary <string, string>() { { "package", packageName }, { "name", appName } }, vmName, 0, (Dictionary <string, string>)null, false, 1, 0, "bgp"); } catch (Exception ex) { Logger.Error("Exception in AppUninstalled: " + ex.ToString()); } } AppUninstaller.DeleteGlAppDataIfExist(packageName); Logger.Info("Sending App Uninstall stats"); string versionFromPackage = HDAgent.GetVersionFromPackage(packageName, vmName); string versionNameFromPackage = HDAgent.GetVersionNameFromPackage(packageName, vmName); Stats.SendAppInstallStats(appName, packageName, versionFromPackage, versionNameFromPackage, "false", "false", source, vmName, campaignName, clientVersion, ""); if (appName == "") { appName = packageName; } string message = string.Format("{0} {1}", (object)appName, (object)LocaleStrings.GetLocalizedString("STRING_UNINSTALL_SUCCESS", "")); if (!Features.IsFeatureEnabled(4UL)) { return; } SysTray.ShowInfoShort(LocaleStrings.GetLocalizedString("STRING_BLUESTACKS", ""), message, vmName, packageName, "0"); }