示例#1
0
 private void BGCreateNewInstance_RunWorkerCompleted(
     object sender,
     RunWorkerCompletedEventArgs e)
 {
     if (!(e.Result is Dictionary <string, string> result))
     {
         return;
     }
     if (result["status"].Equals("success", StringComparison.InvariantCultureIgnoreCase))
     {
         InstalledOem.SetInstalledCoexistingOems();
         RegistryManager.RegistryManagers[this.currentDownloadingOem.AppPlayerOem].Guest[result["vmname"]].DisplayName = Strings.ProductDisplayName + " " + Utils.GetVmIdFromVmName(result["vmname"]) + " " + this.currentDownloadingOem.Suffix;
         Publisher.PublishMessage(BrowserControlTags.oemInstallCompleted, this.ParentWindow.mVmName, (JObject)null);
     }
     else
     {
         if (!result["status"].Equals("fail", StringComparison.InvariantCultureIgnoreCase))
         {
             return;
         }
         Publisher.PublishMessage(BrowserControlTags.oemInstallFailed, this.ParentWindow.mVmName, new JObject()
         {
             ["MessageTitle"] = (JToken)LocaleStrings.GetLocalizedString("STRING_INSTALL_FAIL", ""),
             ["MessageBody"]  = (JToken)LocaleStrings.GetLocalizedString("STRING_INSTALLATION_FAILED", ""),
             ["ActionType"]   = (JToken)"failed"
         });
     }
 }
        public SettingsWindow(Window window, string vmName, string startUpTab, bool isEcoModeEnabled)
        {
            this.mIsEcoModeEnabled = isEcoModeEnabled;
            this.vmNameWithSuffix  = vmName;
            this.VmName            = this.vmNameWithSuffix;
            this.ParentWindow      = window;
            this.SettingsControlNameList.Add("STRING_ENGINE_SETTING");
            this.SettingsControlNameList.Add("STRING_DISPLAY_SETTINGS");
            this.OEM = InstalledOem.GetOemFromVmnameWithSuffix(this.vmNameWithSuffix);
            string oldValue = this.OEM.Equals("bgp", StringComparison.InvariantCultureIgnoreCase) ? "" : "_" + this.OEM;

            if (!string.IsNullOrEmpty(oldValue))
            {
                this.VmName = this.vmNameWithSuffix?.Replace(oldValue, "");
            }
            this.Loaded += (RoutedEventHandler)((sender, e) => this.SettingsWindow_Loaded(sender, e));
            if (!string.IsNullOrEmpty(startUpTab))
            {
                this.StartUpTab = startUpTab;
            }
            this.CreateAllButtons(this.StartUpTab);
            UserControl control = this.GetUserControl(this.StartUpTab) ?? this.GetUserControl("STRING_ENGINE_SETTING");

            this.AddControlInGridAndDict(this.StartUpTab, control);
            this.BringToFront(control);
        }
示例#3
0
        public CreateNewInstanceViewModel(
            NewInstanceType instanceType,
            AppPlayerModel appPlayerModel = null,
            string cloneFromVm            = null,
            string oem = "",
            string abi = null,
            bool isAndroidDownloaded = true)
        {
            this.InstanceType = instanceType;
            this.SetAppPlayerModel(appPlayerModel);
            this.OEM = oem;
            this.IsAndroidDownloaded = isAndroidDownloaded;
            string oldValue = string.Empty;

            this.CpuCorePerformanceWidth    = 320;
            this.CpuCoreCustomVisibility    = false;
            this.PerformanceRamComboWidth   = 320;
            this.CustomRamTextBoxVisibility = false;
            if (cloneFromVm != null)
            {
                this.OEM = InstalledOem.GetOemFromVmnameWithSuffix(cloneFromVm);
                oldValue = this.OEM.Equals("bgp", StringComparison.InvariantCultureIgnoreCase) ? "" : "_" + this.OEM;
                if (!string.IsNullOrEmpty(oldValue))
                {
                    cloneFromVm = cloneFromVm.Replace(oldValue, "");
                }
            }
            if (string.IsNullOrEmpty(this.OEM))
            {
                this.OEM = "bgp";
            }
            if (this.InstanceType == NewInstanceType.Clone && !RegistryManager.RegistryManagers[this.OEM].Guest.ContainsKey(cloneFromVm))
            {
                cloneFromVm = "Android";
            }
            this.InitCPUInfo();
            this.InitRAMInfo();
            this.BuildCPUCombinationList();
            this.BuildRAMCombinationList();
            this.BuildResolutionsList();
            this.BuildInstanceCountList();
            this.BuildCloneFromInstanceList();
            this.ResolutionType = this.ResolutionsList.First <ResolutionModel>((Func <ResolutionModel, bool>)(x => x.OrientationType == OrientationType.Landscape));
            this.InstanceCount  = 1;
            if (this.InstanceType == NewInstanceType.Clone)
            {
                this.CloneFromInstanceVmName = cloneFromVm + oldValue;
            }
            else
            {
                this.InitABISettings("Android", abi);
            }
            this.MaxResolutionWidth               = Math.Max(this.MaxResolutionWidth, Screen.PrimaryScreen.Bounds.Width);
            this.MaxResolutionHeight              = Math.Max(this.MaxResolutionHeight, Screen.PrimaryScreen.Bounds.Height);
            this.CloseWindowCommand               = (ICommand) new RelayCommand(new System.Action(this.CloseCreateNewInstanceWindow), false);
            this.ABIHelpSupportCommand            = (ICommand) new RelayCommand(new System.Action(this.ABIHelpSupport), false);
            this.CreateInstanceButtonClickCommand = (ICommand) new RelayCommand(new System.Action(this.CreateInstanceButtonClick), false);
        }
 internal void InitProperties(string abi = "")
 {
     try
     {
         string vmIdFromVmName = Utils.GetVmIdFromVmName(this.VmName);
         string empty          = string.Empty;
         this.Abi             = string.IsNullOrEmpty(abi) ? Utils.GetValueInBootParams("abivalue", this.VmName, string.Empty, this.OEM) : abi;
         this.mAppPlayerModel = InstalledOem.GetAppPlayerModel(this.OEM, this.Abi);
         string suffix = this.mAppPlayerModel.Suffix;
         if (RegistryManager.RegistryManagers.ContainsKey(this.OEM) && ((IEnumerable <string>)RegistryManager.RegistryManagers[this.OEM].VmList).Contains <string>(this.VmName))
         {
             if (string.IsNullOrEmpty(RegistryManager.RegistryManagers[this.OEM].Guest[this.VmName].DisplayName) && string.IsNullOrEmpty(this.InstanceDisplayName))
             {
                 if (string.Equals(this.VmName, "Android", StringComparison.InvariantCultureIgnoreCase))
                 {
                     this.InstanceDisplayName = BlueStacks.Common.Strings.ProductDisplayName + " " + suffix;
                 }
                 else
                 {
                     this.InstanceDisplayName = BlueStacks.Common.Strings.ProductDisplayName + " " + vmIdFromVmName + " " + suffix;
                 }
                 RegistryManager.RegistryManagers[this.OEM].Guest[this.VmName].DisplayName = this.InstanceDisplayName.Trim();
             }
             else if (!string.IsNullOrEmpty(this.InstanceDisplayName))
             {
                 RegistryManager.RegistryManagers[this.OEM].Guest[this.VmName].DisplayName = this.InstanceDisplayName + " " + suffix;
             }
             else
             {
                 this.InstanceDisplayName = RegistryManager.RegistryManagers[this.OEM].Guest[this.VmName].DisplayName;
             }
         }
         else if (string.IsNullOrEmpty(this.InstanceDisplayName))
         {
             if (string.Equals(this.VmName, "Android", StringComparison.InvariantCultureIgnoreCase))
             {
                 this.InstanceDisplayName = BlueStacks.Common.Strings.ProductDisplayName + " " + suffix;
             }
             else
             {
                 this.InstanceDisplayName = BlueStacks.Common.Strings.ProductDisplayName + " " + vmIdFromVmName + " " + suffix;
             }
         }
         this.InstanceCheckBoxChecked = false;
         this.InitInstanceState();
     }
     catch (Exception ex)
     {
         Logger.Error("Error in setting properties of instance" + ex?.ToString() + this.InstanceDisplayName + this.OEM + this.VmName + this.VmNameWithSuffix);
     }
 }
示例#5
0
 private void BGCreateInstanceSameEngine_RunWorkerCompleted(
     object sender,
     RunWorkerCompletedEventArgs e)
 {
     if (!(e.Result is Dictionary <string, string> result))
     {
         return;
     }
     if (result["status"].Equals("success", StringComparison.InvariantCultureIgnoreCase))
     {
         InstalledOem.SetInstalledCoexistingOems();
         JObject extraData = new JObject();
         extraData["vmname"]          = (JToken)result["vmname"];
         extraData["averageBootTime"] = (JToken)RegistryManager.Instance.AvgBootTime;
         string[]      vmList     = RegistryManager.Instance.VmList;
         List <string> stringList = new List <string>();
         foreach (string index in vmList)
         {
             stringList.Add(RegistryManager.Instance.Guest[index].DisplayName);
         }
         if (!string.IsNullOrEmpty(this.vmDisplayName) && stringList.Contains(this.vmDisplayName))
         {
             int num = 1;
             while (stringList.Contains(this.vmDisplayName + " (" + num.ToString() + ")"))
             {
                 ++num;
             }
             this.vmDisplayName = this.vmDisplayName + " (" + num.ToString() + ")";
         }
         RegistryManager.Instance.Guest[result["vmname"]].DisplayName = this.vmDisplayName;
         string resolution = "Landscape " + RegistryManager.Instance.Guest[this.ParentWindow.mVmName].GuestWidth.ToString() + " x " + RegistryManager.Instance.Guest[this.ParentWindow.mVmName].GuestHeight.ToString();
         string str        = this.ParentWindow.mInstanceWiseCloudInfoManager.mInstanceWiseCloudInfo.GameFeaturePopupInfo.GameFeaturePopupPackages?.GetAppPackageObject(this.ParentWindow.StaticComponents.mSelectedTabButton.PackageName)?.ExtraInfo["game_popup_id"];
         BlueStacks.Common.Stats.SendMultiInstanceStatsAsync("instance_creation_completed", this.vmDisplayName, "Medium (2 CPU cores) and Medium (2 GB)", resolution, int.Parse(result["abivalue"], (IFormatProvider)CultureInfo.InvariantCulture), result["DPI"], 1, result["oem"], "", (string)null, "Fresh", Utils.GetVmIdFromVmName(result["vmname"]), "", true, str);
         Publisher.PublishMessage(BrowserControlTags.oemInstallCompleted, this.ParentWindow.mVmName, extraData);
     }
     else
     {
         if (!result["status"].Equals("fail", StringComparison.InvariantCultureIgnoreCase))
         {
             return;
         }
         Publisher.PublishMessage(BrowserControlTags.oemInstallFailed, this.ParentWindow.mVmName, new JObject()
         {
             ["MessageTitle"] = (JToken)LocaleStrings.GetLocalizedString("STRING_INSTALL_FAIL", ""),
             ["MessageBody"]  = (JToken)LocaleStrings.GetLocalizedString("STRING_INSTALLATION_FAILED", ""),
             ["ActionType"]   = (JToken)"failed"
         });
     }
 }
 public void SetEngineName()
 {
     try
     {
         if (this.mAppPlayerModel == null)
         {
             this.mAppPlayerModel = InstalledOem.GetAppPlayerModel(this.OEM, this.Abi);
         }
         this.EngineName = this.mAppPlayerModel.AppPlayerOemDisplayName;
     }
     catch (Exception ex)
     {
         Logger.Error("Error in setting vmname" + ex?.ToString() + InstalledOem.CoexistingOemList.ToString());
     }
 }
        private void OnCreateNewInstance(NewInstanceType instanceType)
        {
            Window window = (Window)null;

            if (this.View is Window view)
            {
                window = view.Owner;
            }
            this.CloseCurrentWindow();
            string str = "bgp".Equals("bgp", StringComparison.InvariantCultureIgnoreCase) ? "" : "_bgp";

            if (instanceType == NewInstanceType.Clone)
            {
                AppPlayerModel appPlayerModel = InstalledOem.GetAppPlayerModel("bgp", Utils.GetValueInBootParams("abivalue", "Android", string.Empty, "bgp"));
                Stats.SendMultiInstanceStatsAsync("clone_instance_clicked", "", "", "", 0, "", 0, "bgp", "", "", "", "", RegistryManager.Instance.CampaignMD5, true, "");
                Messenger.Default.Send <InstanceCreationMessage>(new InstanceCreationMessage()
                {
                    AppPlayerModel = appPlayerModel,
                    InstanceType   = instanceType,
                    CloneFromVm    = instanceType == NewInstanceType.Clone ? "Android" + str : (string)null
                });
            }
            else
            {
                Stats.SendMultiInstanceStatsAsync("fresh_instance_clicked", "", "", "", 0, "", 0, "bgp", "", "", "", "", RegistryManager.Instance.CampaignMD5, true, "");
                Messenger.Default.Send <ControlVisibilityMessage>(new ControlVisibilityMessage()
                {
                    IsVisible = true
                });
                SimpleIoc.Default.Unregister <NewEngineSelectorViewModel>();
                SimpleIoc.Default.Register <NewEngineSelectorViewModel>();
                NewEngineSelectorView engineSelectorView1 = new NewEngineSelectorView();
                engineSelectorView1.Owner = window;
                engineSelectorView1.WindowStartupLocation = WindowStartupLocation.CenterOwner;
                NewEngineSelectorView engineSelectorView2 = engineSelectorView1;
                SimpleIoc.Default.GetInstance <NewEngineSelectorViewModel>().View = (IView)engineSelectorView2;
                SimpleIoc.Default.GetInstance <NewEngineSelectorViewModel>().SetOemData(InstalledOem.GetAppPlayerModel("bgp", Utils.GetValueInBootParams("abivalue", "Android", string.Empty, "bgp")));
                if (InstalledOem.CoexistingOemList.Count < 2)
                {
                    SimpleIoc.Default.GetInstance <NewEngineSelectorViewModel>().OemInstalledCheckABI();
                }
                else
                {
                    engineSelectorView2.ShowDialog();
                }
            }
        }
示例#8
0
 private void InstallOemOperation()
 {
     try
     {
         Publisher.PublishMessage(BrowserControlTags.oemInstallStarted, this.ParentWindow.mVmName, (JObject)null);
         int mInstallFailedErrorCode = this.currentDownloadingOem.InstallOem();
         if (mInstallFailedErrorCode != 0 || !RegistryManager.CheckOemInRegistry(this.currentDownloadingOem.AppPlayerOem, "Android"))
         {
             Logger.Warning("Installation failed: " + mInstallFailedErrorCode.ToString());
             string str = mInstallFailedErrorCode == 0 ? LocaleStrings.GetLocalizedString("STRING_INSTALLATION_FAILED", "") : InstallerErrorHandling.AssignErrorStringForInstallerExitCodes(mInstallFailedErrorCode, "STRING_INSTALLATION_FAILED");
             Publisher.PublishMessage(BrowserControlTags.oemInstallFailed, this.ParentWindow.mVmName, new JObject()
             {
                 ["MessageTitle"] = (JToken)LocaleStrings.GetLocalizedString("STRING_INSTALL_FAIL", ""),
                 ["MessageBody"]  = (JToken)str,
                 ["ActionType"]   = (JToken)"failed"
             });
         }
         else
         {
             InstalledOem.SetInstalledCoexistingOems();
             if (this.currentDownloadingOem.AppPlayerOem.Contains("bgp64"))
             {
                 Utils.UpdateValueInBootParams("abivalue", this.currentDownloadingOem.AbiValue.ToString((IFormatProvider)CultureInfo.InvariantCulture), "Android", true, this.currentDownloadingOem.AppPlayerOem);
             }
             RegistryManager.RegistryManagers[this.currentDownloadingOem.AppPlayerOem].Guest["Android"].DisplayName = Strings.ProductDisplayName + " " + this.currentDownloadingOem.Suffix;
             Publisher.PublishMessage(BrowserControlTags.oemInstallCompleted, this.ParentWindow.mVmName, (JObject)null);
         }
     }
     catch (Exception ex)
     {
         Logger.Error("Failed after running installer process: " + ex?.ToString());
         Publisher.PublishMessage(BrowserControlTags.oemInstallFailed, this.ParentWindow.mVmName, new JObject()
         {
             ["MessageTitle"] = (JToken)LocaleStrings.GetLocalizedString("STRING_INSTALL_FAIL", ""),
             ["MessageBody"]  = (JToken)LocaleStrings.GetLocalizedString("STRING_INSTALLATION_FAILED", ""),
             ["ActionType"]   = (JToken)"failed"
         });
     }
 }
        public AboutSettingsControl(MainWindow window, SettingsWindow _)
        {
            this.ParentWindow = window;
            this.InitializeComponent();
            this.Visibility = Visibility.Hidden;
            this.Loaded    += new RoutedEventHandler(this.AboutSettingsControl_Loaded);
            AppPlayerModel appPlayerModel = InstalledOem.GetAppPlayerModel("bgp", Utils.GetValueInBootParams("abivalue", "Android", string.Empty, "bgp"));

            this.mVersionLabel.Content = (object)("v" + RegistryManager.Instance.Version);
            BlueStacksUIBinding.Bind(this.mSupportLabel, "STRING_SUPPORT");
            this.mSupportLabel.ContentStringFormat = "{0} - ";
            BlueStacksUIBinding.Bind(this.mWebsiteLabel, "STRING_WEBSITE");
            this.mWebsiteLabel.ContentStringFormat = "{0} - ";
            BlueStacksUIBinding.Bind(this.mSupportMailLabel, "STRING_SUPPORT_EMAIL");
            this.mSupportMailLabel.ContentStringFormat = "{0} - ";
            if (Oem.Instance.IsProductBeta)
            {
                Label mVersionLabel = this.mVersionLabel;
                mVersionLabel.Content = (object)(mVersionLabel.Content?.ToString() + LocaleStrings.GetLocalizedString("STRING_BETA", ""));
            }
            if (appPlayerModel != null && appPlayerModel.AppPlayerOsArch != null)
            {
                Label mVersionLabel = this.mVersionLabel;
                mVersionLabel.Content = (object)(mVersionLabel.Content?.ToString() + ", " + appPlayerModel.AppPlayerOsArch);
            }
            else if (Oem.Instance.IsAndroid64Bit)
            {
                Label mVersionLabel = this.mVersionLabel;
                mVersionLabel.Content = (object)(mVersionLabel.Content?.ToString() + ", " + LocaleStrings.GetLocalizedString("STRING_64BIT_ANDROID", ""));
            }
            else
            {
                Label mVersionLabel = this.mVersionLabel;
                mVersionLabel.Content = (object)(mVersionLabel.Content?.ToString() + ", " + LocaleStrings.GetLocalizedString("STRING_32BIT_ANDROID", ""));
            }
            this.mTermsOfUseLink.NavigateUri = new Uri(WebHelper.GetUrlWithParams(string.Format((IFormatProvider)CultureInfo.InvariantCulture, "{0}/{1}", (object)WebHelper.GetServerHost(), (object)"help_articles"), (string)null, (string)null, (string)null) + "&article=" + "terms_of_use");
            this.mDetailedChangeLogs.Inlines.Clear();
            this.mDetailedChangeLogs.Inlines.Add(LocaleStrings.GetLocalizedString("STRING_LEARN_WHATS_NEW", "Learn What's New"));
        }
 public string IsOemAlreadyInstalled(string oem, string abi)
 {
     return(InstalledOem.CheckIfOemInstancePresent(oem, abi).ToString((IFormatProvider)CultureInfo.InvariantCulture));
 }
示例#11
0
        public static int Main(string[] args)
        {
            newRunApp.Opt opt = new newRunApp.Opt();
            opt.Parse(args);
            newRunApp.s_AppName       = opt.name;
            newRunApp.s_AppPackage    = opt.p;
            newRunApp.s_AppActivity   = opt.a;
            newRunApp.s_ApkUrl        = opt.url;
            newRunApp.s_HideMode      = opt.h;
            newRunApp.s_CampaignId    = opt.campaign_id;
            newRunApp.s_SourceVersion = opt.source_version;
            BlueStacks.Common.Strings.CurrentDefaultVmName = opt.vmname;
            newRunApp.s_Oem          = opt.oem;
            newRunApp.s_CampaignHash = opt.campaignhash;
            newRunApp.s_AddFlePkg    = opt.addflepkg;
            Logger.InitUserLog();
            InstalledOem.SetAllInstalledOems();
            for (int index = 0; index < args.Length; ++index)
            {
                Logger.Info("CMD: arg{0}: {1}", (object)index, (object)args[index]);
            }
            newRunApp.InitExceptionHandlers();
            string runningProcName;

            if (!opt.force && ProcessUtils.IsAnyInstallerProcesRunning(out runningProcName) && !string.IsNullOrEmpty(runningProcName))
            {
                Logger.Error(runningProcName + " process is running. Exiting BlueStacks Runapp.");
                Environment.Exit(-1);
            }
            RegistryManager.Instance.DefaultGuest.RunAppProcessId = Process.GetCurrentProcess().Id;
            if (!((IEnumerable <string>)RegistryManager.Instance.VmList).Contains <string>(BlueStacks.Common.Strings.CurrentDefaultVmName))
            {
                Logger.Info("VM Name: " + BlueStacks.Common.Strings.CurrentDefaultVmName + " does not exist");
                Environment.Exit(-8);
            }
            ServicePointManager.ServerCertificateValidationCallback += new RemoteCertificateValidationCallback(newRunApp.ValidateRemoteCertificate);
            if (string.IsNullOrEmpty(opt.Json))
            {
                opt.Json = new JObject()
                {
                    {
                        "app_icon_url",
                        (JToken)""
                    },
                    {
                        "app_name",
                        (JToken)newRunApp.s_AppName
                    },
                    {
                        "app_url",
                        (JToken)""
                    },
                    {
                        "app_pkg",
                        (JToken)newRunApp.s_AppPackage
                    },
                    {
                        "campaign_id",
                        (JToken)newRunApp.s_CampaignId
                    },
                    {
                        "source_version",
                        (JToken)newRunApp.s_SourceVersion
                    }
                }
            }