예제 #1
0
        public static void AppInstalled(
            string name,
            string package,
            string activity,
            string img,
            string version,
            string isUpdate,
            string vmName,
            string source,
            string campaignName,
            string clientVersion,
            bool isGl3Required,
            bool isVideoPresent,
            string apkType,
            string versionName)
        {
            Logger.Info("Replacing invalid characters, if any, with whitespace");
            ApkInstall.sAppName                = Regex.Replace(name, "[\\x22\\\\\\/:*?|<>]", " ");
            ApkInstall.sPackageName            = package;
            ApkInstall.sLaunchableActivityName = activity;
            ApkInstall.sAppIcon                = img;
            ApkInstall.sVersion                = version;
            ApkInstall.sGl3Required            = isGl3Required;
            ApkInstall.sVideoPresent           = isVideoPresent;
            ApkInstall.sVersionName            = versionName;
            ApkInstall.sIsGamepadCompatible    = Utils.CheckGamepadCompatible(package);
            ApkInstall.sOriginalJson           = new JsonParser(vmName).GetAppList();
            ApkInstall.AddToJson(vmName);
            Stats.SendAppInstallStats(name, package, version, versionName, "true", isUpdate, source, vmName, campaignName, clientVersion, apkType);
            string str1 = Path.Combine(RegistryStrings.GadgetDir, string.Format("{0}.{1}.png", (object)package, (object)activity));
            string str2 = Path.Combine(RegistryStrings.GadgetDir, string.Format("{0}.png", (object)package));

            if (System.IO.File.Exists(str2))
            {
                if (!System.IO.File.Exists(str1))
                {
                    System.IO.File.Copy(str2, str1, false);
                }
            }
            else if (Oem.Instance.IsDownloadIconFromWeb)
            {
                try
                {
                    Utils.DownloadIcon(package, "", false);
                }
                catch
                {
                }
            }
            if (Oem.Instance.IsOEMWithBGPClient)
            {
                ApkInstall.InformPartner(vmName, package, isUpdate);
            }
            if (Features.IsFeatureEnabled(8192UL))
            {
                ApkInstall.CreateAppShortcut(vmName, isUpdate);
            }
            Logger.Info("InstallApk: Got AppName: {0}", (object)ApkInstall.sAppName);
            string str3    = ApkInstall.sAppName + " ";
            string message = string.Compare(isUpdate, "true", true) != 0 ? str3 + LocaleStrings.GetLocalizedString("STRING_INSTALL_SUCCESS", "") : str3 + LocaleStrings.GetLocalizedString("STRING_UPDATE_SUCCESS", "");

            try
            {
                if (Features.IsFeatureEnabled(2UL))
                {
                    if (Array.IndexOf <string>(ApkInstall.sIgnoreEvents, package) == -1)
                    {
                        SysTray.ShowInfoShort(LocaleStrings.GetLocalizedString("STRING_BLUESTACKS", ""), message, vmName, package, "0");
                    }
                    else
                    {
                        Logger.Debug("Not showing notification for: " + package);
                    }
                }
                else
                {
                    Logger.Info("Not showing install notification...");
                }
            }
            catch (Exception ex)
            {
                Logger.Error("Failed to get ShowInstallerNotification value. err: " + ex.Message);
            }
        }
        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");
        }