internal void OpenApp(string packageName, bool isCheckForGrm = true)
        {
            AppIconModel appIcon = this.GetAppIcon(packageName);

            if (appIcon == null)
            {
                return;
            }
            if ((uint)appIcon.AppIncompatType > 0U & isCheckForGrm && !this.mParentWindow.mTopBar.mAppTabButtons.mDictTabs.ContainsKey(packageName))
            {
                GrmHandler.HandleCompatibility(appIcon.PackageName, this.mParentWindow.mVmName);
            }
            else
            {
                this.mParentWindow.mTopBar.mAppTabButtons.AddAppTab(appIcon.AppName, appIcon.PackageName, appIcon.ActivityName, appIcon.ImageName, false, true, false);
                this.mParentWindow.mAppHandler.SwitchWhenPackageNameRecieved = appIcon.PackageName;
                this.mParentWindow.mAppHandler.SendRunAppRequestAsync(appIcon.PackageName, "", false);
                if (appIcon.IsRedDotVisible)
                {
                    appIcon.IsRedDotVisible = false;
                    HomeAppManager.AddPackageInRedDotShownRegistry(appIcon.PackageName);
                }
                HomeAppManager.SendStats(appIcon.PackageName);
            }
        }
Пример #2
0
 internal static void RefreshGrmIndicationForAllInstances(string package)
 {
     foreach (string key in BlueStacksUIUtils.DictWindows.Keys)
     {
         GrmHandler.RefreshGrmIndication(package, key);
         GrmHandler.SendUpdateGrmPackagesToAndroid(key);
         GrmHandler.SendUpdateGrmPackagesToBrowser(key);
     }
 }
Пример #3
0
 internal static void RequirementConfigUpdated(string vmName = "Android")
 {
     if (AppRequirementsParser.Instance.Requirements == null)
     {
         return;
     }
     foreach (AppInfo appInfo in ((IEnumerable <AppInfo>) new JsonParser(vmName).GetAppList()).ToList <AppInfo>())
     {
         GrmHandler.RefreshGrmIndication(appInfo.Package, vmName);
     }
     GrmHandler.SendUpdateGrmPackagesToAndroid(vmName);
     GrmHandler.SendUpdateGrmPackagesToBrowser(vmName);
 }
Пример #4
0
 internal void Init(
     string args,
     string appName,
     PlayStoreAction action,
     bool isWindowForcedTillLoaded = false)
 {
     this.Dispatcher.Invoke((Delegate)(() =>
     {
         if (!this.ParentWindow.mGuestBootCompleted)
         {
             CustomMessageWindow customMessageWindow = new CustomMessageWindow();
             BlueStacksUIBinding.Bind(customMessageWindow.TitleTextBlock, "STRING_POST_OTS_SYNCING_BUTTON_MESSAGE", "");
             BlueStacksUIBinding.Bind(customMessageWindow.BodyTextBlock, "STRING_GUEST_NOT_BOOTED", "");
             customMessageWindow.AddButton(ButtonColors.Blue, "STRING_OK", (EventHandler)null, (string)null, false, (object)null, true);
             customMessageWindow.Owner = (Window)this.ParentWindow;
             customMessageWindow.ShowDialog();
         }
         else if (action == PlayStoreAction.OpenApp && this.ParentWindow.mAppHandler.IsAppInstalled(args) && !"com.android.vending".Equals(args, StringComparison.InvariantCultureIgnoreCase))
         {
             AppIconModel appIcon = this.ParentWindow.mWelcomeTab.mHomeAppManager.GetAppIcon(args);
             if (appIcon == null)
             {
                 return;
             }
             if (appIcon.AppIncompatType != AppIncompatType.None && !this.ParentWindow.mTopBar.mAppTabButtons.mDictTabs.ContainsKey(appIcon.PackageName))
             {
                 GrmHandler.HandleCompatibility(appIcon.PackageName, this.ParentWindow.mVmName);
             }
             else
             {
                 this.ParentWindow.mTopBar.mAppTabButtons.AddAppTab(appIcon.AppName, appIcon.PackageName, appIcon.ActivityName, appIcon.ImageName, true, true, false);
             }
         }
         else
         {
             if (string.IsNullOrEmpty(args))
             {
                 return;
             }
             if (!this.ParentWindow.WelcomeTabParentGrid.IsVisible)
             {
                 this.ParentWindow.mCommonHandler.HomeButtonHandler(false, false);
             }
             this.mBaseControl.mTitleLabel.Content = (object)appName;
             this.mAction = action;
             this.Visibility = Visibility.Visible;
             this.ParentWindow.ChangeOrientationFromClient(false, false);
             this.ProcessArgs(args, isWindowForcedTillLoaded);
         }
     }));
 }
Пример #5
0
 internal void OpenFrontendAppTabControl(string packageName, PlayStoreAction action)
 {
     this.Dispatcher.Invoke((Delegate)(() =>
     {
         if (action == PlayStoreAction.OpenApp && this.ParentWindow.mAppHandler.IsAppInstalled(packageName) && !"com.android.vending".Equals(packageName, StringComparison.InvariantCultureIgnoreCase))
         {
             AppIconModel appIcon = this.mHomeAppManager.GetAppIcon(packageName);
             if (appIcon == null)
             {
                 return;
             }
             if (appIcon.AppIncompatType != AppIncompatType.None && !this.ParentWindow.mTopBar.mAppTabButtons.mDictTabs.ContainsKey(packageName))
             {
                 GrmHandler.HandleCompatibility(appIcon.PackageName, this.ParentWindow.mVmName);
             }
             else
             {
                 this.ParentWindow.mTopBar.mAppTabButtons.AddAppTab(appIcon.AppName, appIcon.PackageName, appIcon.ActivityName, appIcon.ImageName, true, true, false);
             }
         }
         else
         {
             if (string.IsNullOrEmpty(packageName))
             {
                 return;
             }
             AppIconModel appIcon = this.mHomeAppManager.GetAppIcon("com.android.vending");
             if (appIcon == null)
             {
                 return;
             }
             if (action == PlayStoreAction.OpenApp)
             {
                 this.ParentWindow.mTopBar.mAppTabButtons.AddAppTab(appIcon.AppName, appIcon.PackageName, appIcon.ActivityName, appIcon.ImageName, false, true, false);
                 this.ParentWindow.mAppHandler.SwitchWhenPackageNameRecieved = "com.android.vending";
                 this.ParentWindow.mAppHandler.LaunchPlayRequestAsync(packageName);
             }
             else
             {
                 if (action != PlayStoreAction.SearchApp)
                 {
                     return;
                 }
                 this.ParentWindow.mTopBar.mAppTabButtons.AddAppTab(appIcon.AppName, appIcon.PackageName, appIcon.ActivityName, appIcon.ImageName, false, true, false);
                 this.ParentWindow.mAppHandler.SwitchWhenPackageNameRecieved = "com.android.vending";
                 this.ParentWindow.mAppHandler.SendSearchPlayRequestAsync(packageName);
             }
         }
     }));
 }
Пример #6
0
 internal static void RefreshGrmIndication(string package, string vmName = "Android")
 {
     try
     {
         List <AppRequirement> requirements = AppRequirementsParser.Instance.Requirements;
         if (requirements == null)
         {
             return;
         }
         if (!GrmHandler.sDictAppRuleSet.ContainsKey(vmName))
         {
             GrmHandler.sDictAppRuleSet[vmName] = new Dictionary <string, GrmRuleSet>();
         }
         AppIconModel appIcon = BlueStacksUIUtils.DictWindows[vmName].mWelcomeTab.mHomeAppManager.GetAppIcon(package);
         if (appIcon == null)
         {
             return;
         }
         if (appIcon.AppIncompatType != AppIncompatType.None && !requirements.Any <AppRequirement>((Func <AppRequirement, bool>)(_ => string.Equals(_.PackageName, package, StringComparison.OrdinalIgnoreCase))))
         {
             GrmHandler.RemoveAppCompatError(appIcon, BlueStacksUIUtils.DictWindows[vmName]);
         }
         AppRequirement appRequirement = requirements.Where <AppRequirement>((Func <AppRequirement, bool>)(_ => string.Compare(_.PackageName, package, StringComparison.OrdinalIgnoreCase) == 0)).FirstOrDefault <AppRequirement>() ?? requirements.Where <AppRequirement>((Func <AppRequirement, bool>)(_ =>
         {
             if (!_.PackageName.EndsWith("*", StringComparison.InvariantCulture))
             {
                 return(false);
             }
             return(package.StartsWith(_.PackageName.Trim('*'), StringComparison.InvariantCulture));
         })).FirstOrDefault <AppRequirement>();
         if (appRequirement == null)
         {
             return;
         }
         GrmRuleSet requirement = appRequirement.EvaluateRequirement(package, vmName);
         if (requirement != null)
         {
             GrmHandler.AddGRMIndicationForIncompatibleApp(appIcon, BlueStacksUIUtils.DictWindows[vmName], requirement);
         }
         else
         {
             GrmHandler.RemoveAppCompatError(appIcon, BlueStacksUIUtils.DictWindows[vmName]);
         }
     }
     catch (Exception ex)
     {
         Logger.Error("Exception in RefreshGrmIndication. Exception: " + ex?.ToString());
     }
 }
 internal void RemoveAppAfterUninstall(string package)
 {
     GrmHandler.RemovePackageFromGrmList(package, this.mParentWindow.mVmName);
     this.RemoveAppIcon(package, (AppIconModel)null);
     this.RemoveAppIcon(package + "_macro", (AppIconModel)null);
     try
     {
         string path = Path.Combine(RegistryStrings.GadgetDir, Regex.Replace(package + ".png", "[\\x22\\\\\\/:*?|<>]", " "));
         if (!File.Exists(path))
         {
             return;
         }
         File.Delete(path);
     }
     catch (Exception ex)
     {
         Logger.Info("Not able to delete image file : " + ex.ToString());
     }
 }
Пример #8
0
        internal void AppInstalled(string package, bool isUpdate)
        {
            AppInfo appInfo = this.ParentWindow.mWelcomeTab.mHomeAppManager.AddAppIcon(package);

            Publisher.PublishMessage(BrowserControlTags.appInstalled, this.ParentWindow.mVmName, new JObject()
            {
                ["PackageName"]         = (JToken)package,
                ["AppName"]             = (JToken)appInfo?.Name,
                ["IsGamepadCompatible"] = (JToken)appInfo?.IsGamepadCompatible
            });
            if (FeatureManager.Instance.IsShowAppRecommendations || !RegistryManager.Instance.IsPremium)
            {
                this.ParentWindow.mWelcomeTab.mHomeAppManager.UpdateRecommendedAppsInstallStatus(package);
            }
            GrmHandler.RefreshGrmIndication(package, this.ParentWindow.mVmName);
            GrmHandler.SendUpdateGrmPackagesToAndroid(this.ParentWindow.mVmName);
            GrmHandler.SendUpdateGrmPackagesToBrowser(this.ParentWindow.mVmName);
            GuidanceCloudInfoManager.Instance.AppsGuidanceCloudInfoRefresh();
            NotificationManager.Instance.SetDefaultState(package, this.ParentWindow.mVmName);
            if (RegistryManager.Instance.FirstAppLaunchState == AppLaunchState.Fresh)
            {
                RegistryManager.Instance.FirstAppLaunchState = AppLaunchState.Installed;
            }
            if (!AppConfigurationManager.Instance.VmAppConfig[this.ParentWindow.mVmName].ContainsKey(package))
            {
                AppConfigurationManager.Instance.VmAppConfig[this.ParentWindow.mVmName][package] = new BlueStacks.Common.AppSettings();
            }
            if (!isUpdate)
            {
                AppConfigurationManager.Instance.VmAppConfig[this.ParentWindow.mVmName][package].AppInstallTime                  = DateTime.Now.ToString((IFormatProvider)CultureInfo.InvariantCulture);
                AppConfigurationManager.Instance.VmAppConfig[this.ParentWindow.mVmName][package].IsAppOnboardingCompleted        = false;
                AppConfigurationManager.Instance.VmAppConfig[this.ParentWindow.mVmName][package].IsGeneralAppOnBoardingCompleted = false;
            }
            string str = string.Format((IFormatProvider)CultureInfo.InvariantCulture, Path.Combine(RegistryStrings.InputMapperFolder, package) + ".cfg");

            if (!File.Exists(str))
            {
                return;
            }
            string md5HashFromFile = Utils.GetMD5HashFromFile(str);

            AppConfigurationManager.Instance.VmAppConfig[this.ParentWindow.mVmName][package].CfgStored = md5HashFromFile;
        }
Пример #9
0
 private static void PerformGrmActionsWorker_RunWorkerCompleted(
     RunWorkerCompletedEventArgs e,
     MainWindow ParentWindow)
 {
     if (e.Result == null)
     {
         return;
     }
     if (!(bool)e.Result)
     {
         ParentWindow.Dispatcher.Invoke((Delegate)(() =>
         {
             ParentWindow.mFrontendGrid.Visibility = Visibility.Visible;
             ParentWindow.mExitProgressGrid.Visibility = Visibility.Hidden;
         }));
         GrmHandler.RequirementConfigUpdated(ParentWindow.mVmName);
     }
     else
     {
         BlueStacksUIUtils.RestartInstance(ParentWindow.mVmName, false);
     }
 }
Пример #10
0
        private static void PerformGrmActionsWorker_DoWork(
            DoWorkEventArgs e,
            List <GrmAction> actions,
            string package,
            MainWindow ParentWindow)
        {
            try
            {
                ParentWindow.Dispatcher.Invoke((Delegate)(() =>
                {
                    ParentWindow.mFrontendGrid.Visibility = Visibility.Hidden;
                    ParentWindow.mExitProgressGrid.ProgressText = LocaleStrings.GetLocalizedString("STRING_PERFORMING_ACTIONS", "");
                    ParentWindow.mExitProgressGrid.Visibility = Visibility.Visible;
                }));
                try
                {
                    ClientStats.SendMiscellaneousStatsAsync("grm_action_clicked", RegistryManager.Instance.UserGuid, string.Join(",", actions.Select <GrmAction, string>((Func <GrmAction, string>)(_ => _.ActionType.ToString((IFormatProvider)CultureInfo.InvariantCulture))).ToArray <string>()), RegistryManager.Instance.ClientVersion, RegistryManager.Instance.Version, "bgp", package, (string)null, (string)null, "Android");
                }
                catch (Exception ex)
                {
                    Logger.Error("Exception while sending misc stat for grm. " + ex?.ToString());
                }
                e.Result = (object)false;
                foreach (GrmAction action1 in actions)
                {
                    GrmActionType grmActionType = EnumHelper.Parse <GrmActionType>(action1.ActionType, GrmActionType.NoAction);
                    bool?         nullable1     = new bool?(false);
                    EngineState   engineState;
                    switch (grmActionType)
                    {
                    case GrmActionType.UpdateRam:
                        int num1 = int.Parse(action1.ActionDictionary["actionValue"], (IFormatProvider)CultureInfo.InvariantCulture);
                        int num2 = 4096;
                        int result;
                        if (int.TryParse(PhysicalRamEvaluator.RAM, out result))
                        {
                            num2 = (int)((double)result * 0.5);
                        }
                        string currentEngine1 = RegistryManager.Instance.CurrentEngine;
                        engineState = EngineState.raw;
                        string str1 = engineState.ToString();
                        if (currentEngine1 == str1 && num2 >= 3072)
                        {
                            num2 = 3072;
                        }
                        if (num2 < num1)
                        {
                            num1 = num2;
                        }
                        RegistryManager.Instance.Guest[ParentWindow.mVmName].Memory = num1;
                        nullable1 = new bool?(true);
                        break;

                    case GrmActionType.UserBrowser:
                        ParentWindow.Utils.HandleGenericActionFromDictionary(action1.ActionDictionary, "grm", "");
                        nullable1 = new bool?(false);
                        break;

                    case GrmActionType.DownloadFileAndExecute:
                        Random random = new Random();
                        string str2   = action1.ActionDictionary["fileName"] + " ";
                        string str3   = str2.Substring(0, str2.IndexOf(' '));
                        string str4   = str2.Substring(str2.IndexOf(' ') + 1);
                        string str5   = Path.Combine(RegistryStrings.PromotionDirectory, string.Format((IFormatProvider)CultureInfo.InvariantCulture, "{0}_{1}", (object)random.Next(), (object)str3));
                        try
                        {
                            using (WebClient webClient = new WebClient())
                                webClient.DownloadFile(action1.ActionDictionary["url"], str5);
                            Thread.Sleep(2000);
                            using (Process process = new Process())
                            {
                                process.StartInfo.UseShellExecute = true;
                                process.StartInfo.CreateNoWindow  = true;
                                if ((str5.ToUpperInvariant().EndsWith(".msi", StringComparison.InvariantCultureIgnoreCase) || str5.ToUpperInvariant().EndsWith(".exe", StringComparison.InvariantCultureIgnoreCase)) && !BlueStacksUtils.IsSignedByBlueStacks(str5))
                                {
                                    Logger.Info("Not executing unsigned binary " + str5);
                                    GrmHandler.GrmExceptionMessageBox(ParentWindow);
                                    return;
                                }
                                if (str5.ToUpperInvariant().EndsWith(".msi", StringComparison.InvariantCultureIgnoreCase))
                                {
                                    process.StartInfo.FileName = "msiexec";
                                    str4 = string.Format((IFormatProvider)CultureInfo.InvariantCulture, "/i {0} {1}", (object)str5, (object)str4);
                                    process.StartInfo.Arguments = str4;
                                }
                                else
                                {
                                    process.StartInfo.FileName  = str5;
                                    process.StartInfo.Arguments = str4;
                                }
                                Logger.Info("Starting process: {0} {1}", (object)process.StartInfo.FileName, (object)str4);
                                process.Start();
                            }
                        }
                        catch (Exception ex)
                        {
                            GrmHandler.GrmExceptionMessageBox(ParentWindow);
                            Logger.Error("Failed to download and execute. err: " + ex?.ToString());
                        }
                        nullable1 = new bool?(false);
                        break;

                    case GrmActionType.NoAction:
                        nullable1 = new bool?(false);
                        break;

                    case GrmActionType.ContinueAnyway:
                        ParentWindow.Dispatcher.Invoke((Delegate)(() =>
                        {
                            ParentWindow.mFrontendGrid.Visibility = Visibility.Visible;
                            ParentWindow.mExitProgressGrid.Visibility = Visibility.Hidden;
                            if (GrmHandler.sDictAppRuleSet[ParentWindow.mVmName][package].MessageWindow.DontShowOption)
                            {
                                GrmHandler.DonotShowCheckboxHandling(ParentWindow, package);
                                GrmHandler.RefreshGrmIndication(package, ParentWindow.mVmName);
                                GrmHandler.SendUpdateGrmPackagesToAndroid(ParentWindow.mVmName);
                                GrmHandler.SendUpdateGrmPackagesToBrowser(ParentWindow.mVmName);
                            }
                            ParentWindow.mWelcomeTab.mHomeAppManager.OpenApp(package, false);
                        }));
                        nullable1 = new bool?();
                        break;

                    case GrmActionType.GlMode:
                        string action2      = action1.ActionDictionary["actionValue"];
                        int    glRenderMode = RegistryManager.Instance.Guest[ParentWindow.mVmName].GlRenderMode;
                        int    glMode1      = RegistryManager.Instance.Guest[ParentWindow.mVmName].GlMode;
                        GlMode glMode2      = GlMode.PGA_GL;
                        if (glRenderMode == 1 && glMode1 == 1)
                        {
                            glMode2 = GlMode.PGA_GL;
                        }
                        else if (glRenderMode == 1 && glMode1 == 2)
                        {
                            glMode2 = GlMode.AGA_GL;
                        }
                        else
                        {
                            switch (glMode1)
                            {
                            case 1:
                                glMode2 = GlMode.PGA_DX;
                                break;

                            case 2:
                                glMode2 = GlMode.AGA_DX;
                                break;
                            }
                        }
                        List <string> list1 = ((IEnumerable <string>)action2.Split(',')).Select <string, string>((Func <string, string>)(_ => _.Trim())).ToList <string>();
                        if (list1.Contains <string>(glMode2.ToString(), (IEqualityComparer <string>)StringComparer.InvariantCultureIgnoreCase))
                        {
                            nullable1 = new bool?(false);
                            break;
                        }
                        string str6 = list1.RandomElement <string>();
                        string str7 = "";
                        int    num3;
                        string str8;
                        if (string.Compare(str6.Split('_')[1].Trim(), "GL", StringComparison.OrdinalIgnoreCase) == 0)
                        {
                            num3 = 1;
                            str8 = str7 + "1";
                        }
                        else
                        {
                            num3 = 4;
                            str8 = str7 + "4";
                        }
                        int    num4;
                        string args;
                        if (string.Compare(str6.Split('_')[0].Trim(), "PGA", StringComparison.OrdinalIgnoreCase) == 0)
                        {
                            num4 = 1;
                            args = str8 + " 1";
                        }
                        else
                        {
                            num4 = 2;
                            args = str8 + " 2";
                        }
                        if (RunCommand.RunCmd(Path.Combine(RegistryStrings.InstallDir, "HD-GlCheck"), args, true, true, false, 0).ExitCode == 0)
                        {
                            RegistryManager.Instance.Guest[ParentWindow.mVmName].GlRenderMode = num3;
                            Utils.UpdateValueInBootParams("GlMode", num4.ToString((IFormatProvider)CultureInfo.InvariantCulture), ParentWindow.mVmName, true, "bgp");
                            RegistryManager.Instance.Guest[ParentWindow.mVmName].GlMode = num4;
                        }
                        else
                        {
                            GrmHandler.GrmExceptionMessageBox(ParentWindow);
                            Logger.Info("GL check execution for the required combination failed.");
                        }
                        nullable1 = new bool?(true);
                        break;

                    case GrmActionType.DeviceProfile:
                        string strA  = action1.ActionDictionary["pCode"];
                        string empty = string.Empty;
                        string str9;
                        if (string.Compare(strA, "custom", StringComparison.OrdinalIgnoreCase) == 0)
                        {
                            str9 = "{" + string.Format((IFormatProvider)CultureInfo.InvariantCulture, "\"createcustomprofile\":\"{0}\",", (object)"true") + string.Format((IFormatProvider)CultureInfo.InvariantCulture, "\"model\":\"{0}\",", (object)action1.ActionDictionary["model"]) + string.Format((IFormatProvider)CultureInfo.InvariantCulture, "\"brand\":\"{0}\",", (object)action1.ActionDictionary["brand"]) + string.Format((IFormatProvider)CultureInfo.InvariantCulture, "\"manufacturer\":\"{0}\"", (object)action1.ActionDictionary["manufacturer"]) + "}";
                        }
                        else
                        {
                            List <string> list2             = ((IEnumerable <string>)strA.Split(',')).Select <string, string>((Func <string, string>)(_ => _.Trim())).ToList <string>();
                            string        valueInBootParams = Utils.GetValueInBootParams("pcode", ParentWindow.mVmName, "", "bgp");
                            if (!list2.Contains(valueInBootParams))
                            {
                                strA = list2.RandomElement <string>();
                                str9 = "{" + string.Format((IFormatProvider)CultureInfo.InvariantCulture, "\"createcustomprofile\":\"{0}\",", (object)"false") + string.Format((IFormatProvider)CultureInfo.InvariantCulture, "\"pcode\":\"{0}\"", (object)strA) + "}";
                            }
                            else
                            {
                                break;
                            }
                        }
                        if (string.Equals(VmCmdHandler.RunCommand(string.Format((IFormatProvider)CultureInfo.InvariantCulture, "{0} {1}", (object)"changeDeviceProfile", (object)str9), ParentWindow.mVmName, "bgp"), "ok", StringComparison.InvariantCulture))
                        {
                            Utils.UpdateValueInBootParams("pcode", strA, ParentWindow.mVmName, false, "bgp");
                            if (PackageActivityNames.ThirdParty.AllCallOfDutyPackageNames.Contains(package))
                            {
                                HTTPUtils.SendRequestToAgentAsync("clearAppData", new Dictionary <string, string>()
                                {
                                    {
                                        nameof(package),
                                        package
                                    }
                                }, ParentWindow.mVmName, 0, (Dictionary <string, string>)null, false, 1, 0, "bgp");
                            }
                        }
                        else
                        {
                            GrmHandler.GrmExceptionMessageBox(ParentWindow);
                            Logger.Error("Setting device profile for the required combination failed.");
                        }
                        nullable1 = new bool?(false);
                        break;

                    case GrmActionType.BootParam:
                        Utils.UpdateValueInBootParams(action1.ActionDictionary["param"].Trim(), action1.ActionDictionary["actionValue"].Trim(), ParentWindow.mVmName, true, "bgp");
                        nullable1 = new bool?(true);
                        break;

                    case GrmActionType.DPI:
                        string action3 = action1.ActionDictionary["actionValue"];
                        Utils.SetDPIInBootParameters(RegistryManager.Instance.Guest[ParentWindow.mVmName].BootParameters, action3, ParentWindow.mVmName, "bgp");
                        nullable1 = new bool?(true);
                        break;

                    case GrmActionType.CpuCores:
                        int    num5           = int.Parse(action1.ActionDictionary["actionValue"], (IFormatProvider)CultureInfo.InvariantCulture);
                        string currentEngine2 = RegistryManager.Instance.CurrentEngine;
                        engineState = EngineState.raw;
                        string str10 = engineState.ToString();
                        if (currentEngine2 != str10)
                        {
                            RegistryManager.Instance.Guest[ParentWindow.mVmName].VCPUs = num5 > 8 ? 8 : num5;
                        }
                        nullable1 = new bool?(true);
                        break;

                    case GrmActionType.Resolution:
                        List <string> list3 = ((IEnumerable <string>)action1.ActionDictionary["actionValue"].Split(',')).Select <string, string>((Func <string, string>)(_ => _.Replace(" ", string.Empty))).ToList <string>();
                        string        str11 = RegistryManager.Instance.Guest[ParentWindow.mVmName].GuestWidth.ToString((IFormatProvider)CultureInfo.InvariantCulture) + "x" + RegistryManager.Instance.Guest[ParentWindow.mVmName].GuestHeight.ToString((IFormatProvider)CultureInfo.InvariantCulture);
                        if (!list3.Contains <string>(str11, (IEqualityComparer <string>)StringComparer.InvariantCultureIgnoreCase))
                        {
                            string str12 = list3.RandomElement <string>();
                            RegistryManager.Instance.Guest[ParentWindow.mVmName].GuestWidth  = int.Parse(str12.Split('x')[0].Trim(), (IFormatProvider)CultureInfo.InvariantCulture);
                            RegistryManager.Instance.Guest[ParentWindow.mVmName].GuestHeight = int.Parse(str12.Split('x')[1].Trim(), (IFormatProvider)CultureInfo.InvariantCulture);
                            nullable1 = new bool?(true);
                            break;
                        }
                        break;

                    case GrmActionType.RestartBluestacks:
                        nullable1 = new bool?(true);
                        break;

                    case GrmActionType.RestartMachine:
                        Process.Start("shutdown.exe", "-r -t 0");
                        break;

                    case GrmActionType.Fps:
                        int newFps = int.Parse(action1.ActionDictionary["actionValue"], (IFormatProvider)CultureInfo.InvariantCulture);
                        RegistryManager.Instance.Guest[ParentWindow.mVmName].FPS = newFps;
                        Utils.UpdateValueInBootParams("fps", newFps.ToString((IFormatProvider)CultureInfo.InvariantCulture), ParentWindow.mVmName, true, "bgp");
                        Utils.SendChangeFPSToInstanceASync(ParentWindow.mVmName, newFps, "bgp");
                        nullable1 = new bool?(false);
                        break;

                    case GrmActionType.EditRegistry:
                        string action4 = action1.ActionDictionary["location"];
                        if (string.Compare(action4, "registryManager", StringComparison.OrdinalIgnoreCase) == 0)
                        {
                            PropertyInfo property = typeof(RegistryManager).GetProperty(action1.ActionDictionary["propertyName"]);
                            object       obj      = Convert.ChangeType((object)action1.ActionDictionary["propertyValue"], Type.GetTypeCode(property.PropertyType), (IFormatProvider)CultureInfo.InvariantCulture);
                            property.SetValue((object)RegistryManager.Instance, obj, (object[])null);
                        }
                        else if (string.Compare(action4, "instanceManager", StringComparison.OrdinalIgnoreCase) == 0)
                        {
                            PropertyInfo property = typeof(InstanceRegistry).GetProperty(action1.ActionDictionary["propertyName"]);
                            object       obj      = Convert.ChangeType((object)action1.ActionDictionary["propertyValue"], Type.GetTypeCode(property.PropertyType), (IFormatProvider)CultureInfo.InvariantCulture);
                            property.SetValue((object)RegistryManager.Instance.Guest[ParentWindow.mVmName], obj, (object[])null);
                        }
                        else
                        {
                            string            registryPath = string.Format((IFormatProvider)CultureInfo.InvariantCulture, "Software\\BlueStacks{0}\\{1}", (object)BlueStacks.Common.Strings.GetOemTag(), (object)action1.ActionDictionary["propertyPath"].Replace("vmName", ParentWindow.mVmName));
                            object            obj          = (object)null;
                            RegistryValueKind type         = EnumHelper.Parse <RegistryValueKind>(action1.ActionDictionary["propertyRegistryKind"], RegistryValueKind.String);
                            switch (type)
                            {
                            case RegistryValueKind.String:
                                obj = (object)action1.ActionDictionary["propertyValue"];
                                break;

                            case RegistryValueKind.DWord:
                                obj = (object)int.Parse(action1.ActionDictionary["propertyValue"], (IFormatProvider)CultureInfo.InvariantCulture);
                                break;
                            }
                            RegistryUtils.SetRegistryValue(registryPath, action1.ActionDictionary["propertyName"], obj, type, RegistryKeyKind.HKEY_LOCAL_MACHINE);
                        }
                        nullable1 = new bool?(false);
                        break;

                    case GrmActionType.ClearAppData:
                        HTTPUtils.SendRequestToAgentAsync("clearAppData", new Dictionary <string, string>()
                        {
                            {
                                nameof(package),
                                package
                            }
                        }, ParentWindow.mVmName, 0, (Dictionary <string, string>)null, false, 1, 0, "bgp");
                        break;
                    }
                    bool?nullable2 = nullable1;
                    bool flag      = true;
                    if (nullable2.GetValueOrDefault() == flag & nullable2.HasValue)
                    {
                        e.Result = (object)true;
                    }
                    else if (!nullable1.HasValue)
                    {
                        e.Result = (object)null;
                    }
                }
                Thread.Sleep(1000);
            }
            catch (Exception ex)
            {
                Logger.Error("Exception in performing grm actions, ex: " + ex.ToString());
                ClientStats.SendMiscellaneousStatsAsync("grm_action_error", RegistryManager.Instance.UserGuid, GrmHandler.sDictAppRuleSet[ParentWindow.mVmName][package].RuleId, RegistryManager.Instance.ClientVersion, RegistryManager.Instance.Version, "bgp", package, ex.Message, (string)null, "Android");
                GrmHandler.GrmExceptionMessageBox(ParentWindow);
                e.Result = (object)null;
            }
        }
Пример #11
0
 private static void PerformGrmActions(
     List <GrmAction> actions,
     string package,
     MainWindow ParentWindow)
 {
     using (BackgroundWorker backgroundWorker = new BackgroundWorker())
     {
         backgroundWorker.DoWork             += (DoWorkEventHandler)((obj, e) => GrmHandler.PerformGrmActionsWorker_DoWork(e, actions, package, ParentWindow));
         backgroundWorker.RunWorkerCompleted += (RunWorkerCompletedEventHandler)((obj, e) => GrmHandler.PerformGrmActionsWorker_RunWorkerCompleted(e, ParentWindow));
         backgroundWorker.RunWorkerAsync();
     }
 }
Пример #12
0
 internal static void HandleCompatibility(string package, string vmName)
 {
     try
     {
         GrmHandler.AppCompatErrorWindow = new CustomMessageWindow();
         GrmHandler.AppCompatErrorWindow.TitleTextBlock.Text = BlueStacksUIUtils.DictWindows[vmName].mWelcomeTab.mHomeAppManager.GetAppIcon(package).AppName;
         if (!string.IsNullOrEmpty(AppRequirementsParser.Instance.GetLocalizedString(GrmHandler.sDictAppRuleSet[vmName][package].MessageWindow.HeaderStringKey)))
         {
             GrmHandler.AppCompatErrorWindow.BodyTextBlockTitle.Text       = AppRequirementsParser.Instance.GetLocalizedString(GrmHandler.sDictAppRuleSet[vmName][package].MessageWindow.HeaderStringKey);
             GrmHandler.AppCompatErrorWindow.BodyTextBlockTitle.Visibility = Visibility.Visible;
         }
         GrmHandler.AppCompatErrorWindow.BodyTextBlock.Text = AppRequirementsParser.Instance.GetLocalizedString(GrmHandler.sDictAppRuleSet[vmName][package].MessageWindow.MessageStringKey);
         if (GrmHandler.sDictAppRuleSet[vmName][package].MessageWindow.MessageType == MessageType.Info.ToString())
         {
             GrmHandler.AppCompatErrorWindow.MessageIcon.ImageName = "message_info";
         }
         else if (GrmHandler.sDictAppRuleSet[vmName][package].MessageWindow.MessageType == MessageType.Error.ToString())
         {
             GrmHandler.AppCompatErrorWindow.MessageIcon.ImageName = "message_error";
         }
         GrmHandler.AppCompatErrorWindow.MessageIcon.Visibility = Visibility.Visible;
         if (GrmHandler.sDictAppRuleSet[vmName][package].MessageWindow.DontShowOption)
         {
             GrmHandler.AppCompatErrorWindow.CheckBox.Content    = (object)LocaleStrings.GetLocalizedString("STRING_DOWNLOAD_GOOGLE_APP_POPUP_STRING_04", "");
             GrmHandler.AppCompatErrorWindow.CheckBox.Visibility = Visibility.Visible;
         }
         foreach (GrmMessageButton button1 in GrmHandler.sDictAppRuleSet[vmName][package].MessageWindow.Buttons)
         {
             GrmMessageButton button = button1;
             ButtonColors     color  = EnumHelper.Parse <ButtonColors>(button.ButtonColor, ButtonColors.Blue);
             GrmHandler.AppCompatErrorWindow.AddButton(color, AppRequirementsParser.Instance.GetLocalizedString(button.ButtonStringKey), (EventHandler)((o, e) => GrmHandler.PerformGrmActions(button.Actions, package, BlueStacksUIUtils.DictWindows[vmName])), (string)null, false, (object)null, true);
         }
         GrmHandler.AppCompatErrorWindow.Owner = (Window)BlueStacksUIUtils.DictWindows[vmName];
         BlueStacksUIUtils.DictWindows[vmName].ShowDimOverlay((IDimOverlayControl)null);
         GrmHandler.AppCompatErrorWindow.ShowDialog();
         BlueStacksUIUtils.DictWindows[vmName].HideDimOverlay();
     }
     catch (Exception ex)
     {
         Logger.Error("Exception while showing appcompat message to user. Exception: " + ex.ToString());
         BlueStacksUIUtils.DictWindows[vmName].mWelcomeTab.mHomeAppManager.OpenApp(package, false);
     }
 }
Пример #13
0
 internal void CloseTabAfterQuitPopup(string tabKey, bool sendStopAppToAndroid, bool forceClose)
 {
     try
     {
         Logger.Info("CloseTab after quitpopup, key: {0}, sendStopApp: {1}, forceClose: {2}", (object)tabKey, (object)sendStopAppToAndroid, (object)forceClose);
         if (!this.mDictTabs.ContainsKey(tabKey))
         {
             return;
         }
         Logger.Info("mDict Tab contains key");
         AppTabButton mDictTab = this.mDictTabs[tabKey];
         if (mDictTab.mTabType != TabType.HomeTab)
         {
             Logger.Info("Button was not hometab");
             if (this.ParentWindow.mDimOverlay != null && this.ParentWindow.mDimOverlay.Control != null)
             {
                 Logger.Info("DimOverlay and control exist");
                 if (FeatureManager.Instance.IsCustomUIForNCSoft && (object)this.ParentWindow.mDimOverlay.Control.GetType() == (object)this.ParentWindow.ScreenLockInstance.GetType() || !FeatureManager.Instance.IsCustomUIForNCSoft)
                 {
                     Logger.Info("hiding");
                     this.ParentWindow.HideDimOverlay();
                     this.mPopup.IsOpen = false;
                 }
             }
         }
         this.mLastPackageForQuitPopupDisplayed = "";
         Logger.Info("Trying non hometab");
         if (!(mDictTab.mTabType != TabType.HomeTab | forceClose))
         {
             return;
         }
         Logger.Info("Button is not hometab or forceclose");
         Publisher.PublishMessage(BrowserControlTags.tabClosing, this.ParentWindow.mVmName, new JObject((object)new JProperty("PackageName", (object)mDictTab.PackageName)));
         (mDictTab.Parent as Panel).Children.Remove((UIElement)mDictTab);
         this.mDictTabs.Remove(tabKey);
         Logger.Info("XXXSR: Tab removed");
         if (mDictTab.mTabType == TabType.AppTab || mDictTab.mTabType == TabType.HomeTab)
         {
             this.ParentWindow.mCommonHandler.ToggleMacroAndSyncVisibility();
         }
         if (sendStopAppToAndroid && mDictTab.mTabType == TabType.AppTab)
         {
             this.ParentWindow.mAppHandler.StopAppRequest(mDictTab.PackageName);
         }
         Logger.Info("MacroAndSync gone and StopApp sent");
         this.ListTabHistory.RemoveAll((Predicate <string>)(n => n.Equals(tabKey, StringComparison.OrdinalIgnoreCase)));
         Logger.Info("TabHistory cleared");
         if (this.ParentWindow.mDiscordhandler != null)
         {
             this.ParentWindow.mDiscordhandler.RemoveAppFromTimestampList(tabKey);
         }
         if (mDictTab.mTabType == TabType.AppTab)
         {
             GrmHandler.RefreshGrmIndicationForAllInstances(mDictTab.PackageName);
         }
         Publisher.PublishMessage(BrowserControlTags.currentlyRunningApps, this.ParentWindow.mVmName, new JObject((object)new JProperty("packages", (object)new JArray((object)this.mDictTabs.Values.Select <AppTabButton, string>((Func <AppTabButton, string>)(_ => _.TabKey))))));
         if (Oem.IsOEMDmm && this.ListTabHistory.Count == 0)
         {
             this.ParentWindow.Hide();
             this.ParentWindow.RestoreWindows(false);
             if (this.ParentWindow.mDMMRecommendedWindow != null)
             {
                 this.ParentWindow.mDMMRecommendedWindow.Visibility = Visibility.Hidden;
             }
             this.ParentWindow.StaticComponents.mSelectedTabButton.IsPortraitModeTab = false;
         }
         else if (mDictTab.IsSelected)
         {
             Logger.Info("Button was selected");
             if (this.ListTabHistory.Count != 0)
             {
                 Logger.Info("goto tab");
                 this.GoToTab(this.ListTabHistory[this.ListTabHistory.Count - 1], true, false);
             }
             else
             {
                 Logger.Fatal("No tab to go back to! Ignoring");
             }
         }
         Logger.Info("Resizing tabs");
         this.ResizeTabs();
     }
     catch (Exception ex)
     {
         Logger.Error("XXXSR-UFD945 Couldn't close tab after quit popup.Ex: {0}", (object)ex);
     }
 }
Пример #14
0
 internal void AddAppTab(
     string appName,
     string packageName,
     string activityName,
     string imageName,
     bool isSwitch,
     bool isLaunch,
     bool receivedFromImap = false)
 {
     this.DoExtraHandlingForApp(packageName);
     if (PostBootCloudInfoManager.Instance.mPostBootCloudInfo?.GameNotificationAppPackages?.NotificationModeAppPackages?.IsPackageAvailable(packageName).GetValueOrDefault())
     {
         this.ParentWindow.EngineInstanceRegistry.LastNotificationEnabledAppLaunched = packageName;
     }
     if (this.mDictTabs.ContainsKey(packageName))
     {
         this.GoToTab(packageName, isLaunch, receivedFromImap);
     }
     else
     {
         AppTabButton selectedTabButton = this.ParentWindow.StaticComponents.mSelectedTabButton;
         AppTabButton button            = new AppTabButton();
         button.Init(appName, packageName, activityName, imageName, this.ParentWindow.FrontendParentGrid, packageName);
         button.MouseUp += new MouseButtonEventHandler(this.AppTabButton_MouseUp);
         if (this.ParentWindow.mDiscordhandler != null)
         {
             this.ParentWindow.mDiscordhandler.AssignTabChangeEvent(button);
         }
         if (Oem.IsOEMDmm && this.ParentWindow.mDmmBottomBar != null)
         {
             button.EventOnTabChanged += new EventHandler <TabChangeEventArgs>(this.ParentWindow.mDmmBottomBar.Tab_Changed);
         }
         this.mDictTabs.Add(packageName, button);
         this.mPanel.Children.Add((UIElement)button);
         if (Oem.Instance.SendAppClickStatsFromClient)
         {
             ThreadPool.QueueUserWorkItem((WaitCallback)(obj =>
             {
                 AppInfo infoFromPackageName = new JsonParser(this.ParentWindow.mVmName).GetAppInfoFromPackageName(packageName);
                 string appVersion = string.Empty;
                 string appVersionName = string.Empty;
                 if (infoFromPackageName != null)
                 {
                     if (!string.IsNullOrEmpty(infoFromPackageName.Version))
                     {
                         appVersion = infoFromPackageName.Version;
                     }
                     if (!string.IsNullOrEmpty(infoFromPackageName.VersionName))
                     {
                         appVersionName = infoFromPackageName.VersionName;
                     }
                 }
                 BlueStacks.Common.Stats.SendAppStats(appName, packageName, appVersion, "HomeVersionNotKnown", BlueStacks.Common.Stats.AppType.app, this.ParentWindow.mVmName, appVersionName);
             }));
         }
         if (RegistryManager.Instance.InstallationType == InstallationTypes.GamingEdition)
         {
             button.Visibility = Visibility.Collapsed;
         }
         else if (selectedTabButton != null && selectedTabButton.IsPortraitModeTab && selectedTabButton.mTabType == TabType.AppTab)
         {
             button.IsPortraitModeTab = true;
         }
         this.ResizeTabs();
         GrmHandler.RefreshGrmIndicationForAllInstances(packageName);
         Publisher.PublishMessage(BrowserControlTags.currentlyRunningApps, this.ParentWindow.mVmName, new JObject((object)new JProperty("packages", (object)new JArray((object)this.mDictTabs.Values.Select <AppTabButton, string>((Func <AppTabButton, string>)(_ => _.TabKey))))));
         if (!isSwitch)
         {
             return;
         }
         this.GoToTab(packageName, isLaunch, receivedFromImap);
     }
 }