Exemple #1
0
        private void BGCreateNewInstance_DoWork(object sender, DoWorkEventArgs e)
        {
            Publisher.PublishMessage(BrowserControlTags.oemDownloadStarted, this.ParentWindow.mVmName, (JObject)null);
            Publisher.PublishMessage(BrowserControlTags.oemDownloadCompleted, this.ParentWindow.mVmName, (JObject)null);
            Publisher.PublishMessage(BrowserControlTags.oemInstallStarted, this.ParentWindow.mVmName, (JObject)null);
            Dictionary <string, string> dictionary = new Dictionary <string, string>();

            try
            {
                Dictionary <string, string> data = new Dictionary <string, string>();
                JObject jobject1 = new JObject()
                {
                    {
                        "cpu",
                        (JToken)2
                    },
                    {
                        "ram",
                        (JToken)2048
                    },
                    {
                        "dpi",
                        (JToken)240
                    },
                    {
                        "abi",
                        (JToken)this.currentDownloadingOem.AbiValue
                    },
                    {
                        "resolutionwidth",
                        (JToken)1920
                    },
                    {
                        "resolutionheight",
                        (JToken)1080
                    }
                };
                data["settings"] = jobject1.ToString(Formatting.None);
                data["vmtype"]   = "fresh";
                data["vmname"]   = string.Format((IFormatProvider)CultureInfo.InvariantCulture, "Android_{0}", (object)Utils.GetVmIdToCreate(this.currentDownloadingOem.AppPlayerOem));
                JObject jobject2 = JObject.Parse(HTTPUtils.SendRequestToAgent("createInstance", data, "Android", 240000, (Dictionary <string, string>)null, false, 1, 0, this.currentDownloadingOem.AppPlayerOem, true));
                if (jobject2["success"].ToObject <bool>())
                {
                    RegistryManager.ClearRegistryMangerInstance();
                    string str = JObject.Parse(jobject2["vmconfig"].ToString().Trim())["vmname"].ToString().Trim();
                    dictionary["vmname"] = str;
                    dictionary["status"] = "success";
                }
                else
                {
                    dictionary["status"] = "fail";
                    dictionary["reason"] = jobject2["reason"].ToString().Trim();
                }
            }
            catch (Exception ex)
            {
                Logger.Error("error in creating new instance" + ex.ToString());
                dictionary["status"] = "fail";
                dictionary["reason"] = "UnknownException";
            }
            finally
            {
                e.Result = (object)dictionary;
            }
        }
Exemple #2
0
        private void BGCreateInstanceSameEngine_DoWork(object sender, DoWorkEventArgs e)
        {
            Publisher.PublishMessage(BrowserControlTags.oemInstallStarted, this.ParentWindow.mVmName, (JObject)null);
            Dictionary <string, string> dictionary = new Dictionary <string, string>();

            try
            {
                Dictionary <string, string> data = new Dictionary <string, string>();
                Dictionary <string, string> fromBootParamString = Utils.GetBootParamsDictFromBootParamString(RegistryManager.Instance.Guest[this.ParentWindow.mVmName].BootParameters);
                string  s1       = fromBootParamString.ContainsKey("DPI") ? fromBootParamString["DPI"] : "240";
                string  s2       = fromBootParamString.ContainsKey("abivalue") ? fromBootParamString["abivalue"] : "15";
                string  oem      = fromBootParamString.ContainsKey("OEM") ? fromBootParamString["OEM"] : "bgp";
                JObject jobject1 = new JObject()
                {
                    {
                        "cpu",
                        (JToken)2
                    },
                    {
                        "ram",
                        (JToken)2048
                    },
                    {
                        "dpi",
                        (JToken)int.Parse(s1, (IFormatProvider)CultureInfo.InvariantCulture)
                    },
                    {
                        "abi",
                        (JToken)int.Parse(s2, (IFormatProvider)CultureInfo.InvariantCulture)
                    },
                    {
                        "resolutionwidth",
                        (JToken)RegistryManager.Instance.Guest[this.ParentWindow.mVmName].GuestWidth
                    },
                    {
                        "resolutionheight",
                        (JToken)RegistryManager.Instance.Guest[this.ParentWindow.mVmName].GuestHeight
                    }
                };
                data["settings"] = jobject1.ToString(Formatting.None);
                data["vmtype"]   = "fresh";
                data["vmname"]   = string.Format((IFormatProvider)CultureInfo.InvariantCulture, "Android_{0}", (object)Utils.GetVmIdToCreate(oem));
                JObject jobject2 = JObject.Parse(HTTPUtils.SendRequestToAgent("createInstance", data, "Android", 240000, (Dictionary <string, string>)null, false, 1, 0, oem, true));
                if (jobject2["success"].ToObject <bool>())
                {
                    RegistryManager.ClearRegistryMangerInstance();
                    string str = JObject.Parse(jobject2["vmconfig"].ToString().Trim())["vmname"].ToString().Trim();
                    dictionary["vmname"]   = str;
                    dictionary["status"]   = "success";
                    dictionary["DPI"]      = s1;
                    dictionary["abivalue"] = s2;
                    dictionary["oem"]      = oem;
                }
                else
                {
                    dictionary["status"] = "fail";
                    dictionary["reason"] = jobject2["reason"].ToString().Trim();
                }
            }
            catch (Exception ex)
            {
                Logger.Error("error in creating new instance" + ex.ToString());
                dictionary["status"] = "fail";
                dictionary["reason"] = "UnknownException";
            }
            finally
            {
                e.Result = (object)dictionary;
            }
        }