コード例 #1
0
        internal static void HandleCallMethod(JObject resJson, string vmName)
        {
            string result = "";

            JObject.Parse(resJson["bluestacks_notification"][(object)"payload"].ToString()).AssignStringIfContains("methodName", ref result);
            string lower = result.ToLower(CultureInfo.InvariantCulture);

            if (lower != null)
            {
                // ISSUE: reference to a compiler-generated method
                switch (\u003CPrivateImplementationDetails\u003E.ComputeStringHash(lower))
                {
                case 443221764:
                    if (lower == "updategrm")
                    {
                        GrmManager.UpdateGrmAsync(resJson["bluestacks_notification"][(object)"payload"][(object)"app_pkg_list"].ToIenumerableString());
                        return;
                    }
                    break;

                case 886249708:
                    if (lower == "openquitpopup")
                    {
                        CloudNotificationManager.OpenQuitPopup(resJson, vmName);
                        return;
                    }
                    break;

                case 1238708169:
                    if (lower == "calendarentry")
                    {
                        try
                        {
                            JObject androidPayload = (JObject)resJson["bluestacks_notification"][(object)"payload"][(object)"androidPayload"];
                            ClientStats.SendCalendarStats("calendar_" + resJson["bluestacks_notification"][(object)"payload"][(object)"methodType"].ToString() + "_firebase", androidPayload.ContainsKey("startDate") ? androidPayload["startDate"].ToString() : "", androidPayload.ContainsKey("endDate") ? androidPayload["endDate"].ToString() : "", androidPayload["location"].ToString(), "", "");
                            string str;
                            switch (resJson["bluestacks_notification"][(object)"payload"][(object)"methodType"].ToString())
                            {
                            case "add":
                                str = "addcalendarevent";
                                break;

                            case "update":
                                str = "updatecalendarevent";
                                break;

                            case "delete":
                                str = "deletecalendarevent";
                                break;

                            default:
                                throw new Exception("could not identify the methodType ");
                            }
                            string  endpoint = str;
                            JObject jobject1 = new JObject((object)new JProperty("event", (object)androidPayload));
                            Dictionary <string, string> data = new Dictionary <string, string>()
                            {
                                ["event"] = jobject1.ToString()
                            };
                            CloudNotificationManager.WorkQueue.Enqueue((SerialWorkQueue.Work)(() =>
                            {
                                try
                                {
                                    string guest = HTTPUtils.SendRequestToGuest(endpoint, data, vmName, 0, (Dictionary <string, string>)null, false, 1, 0, "bgp");
                                    Logger.Info("Response for calendarEntry " + guest);
                                    JObject jobject = JObject.Parse(guest);
                                    ClientStats.SendCalendarStats("calendar_" + resJson["bluestacks_notification"][(object)"payload"][(object)"methodType"].ToString() + "_android", androidPayload.ContainsKey("startDate") ? androidPayload["startDate"].ToString() : "", androidPayload.ContainsKey("endDate") ? androidPayload["endDate"].ToString() : "", androidPayload["location"].ToString(), string.Equals(jobject["result"].ToString(), "ok", StringComparison.InvariantCultureIgnoreCase).ToString((IFormatProvider)CultureInfo.InvariantCulture), jobject.ContainsKey("rowsDeleted") ? jobject["rowsDeleted"].ToString() : (jobject.ContainsKey("rowsUpdated") ? jobject["rowsUpdated"].ToString() : ""));
                                }
                                catch (Exception ex)
                                {
                                    Logger.Warning(string.Format("Guest not booted, error in sending Calendar entry event: {0}", (object)ex));
                                }
                            }));
                            return;
                        }
                        catch (Exception ex)
                        {
                            Logger.Warning(string.Format("Error in sending Calendar entry event data to android.. Json:{0} error:  {1}", (object)resJson, (object)ex));
                            return;
                        }
                    }
                    else
                    {
                        break;
                    }

                case 1286957143:
                    if (lower == "updatebstconfig")
                    {
                        CloudNotificationManager.UpdateBstConfig();
                        return;
                    }
                    break;

                case 1330308668:
                    if (lower == "downloadkeymappingcfg")
                    {
                        try
                        {
                            if (resJson["bluestacks_notification"][(object)"payload"][(object)"parserVersionList"] != null && resJson["bluestacks_notification"][(object)"payload"][(object)"parserVersionList"] is JArray jarray)
                            {
                                List <string> stringList = jarray.ToObject <List <string> >();
                                int           num1       = int.Parse(KMManager.MinParserVersion, (IFormatProvider)CultureInfo.InvariantCulture);
                                int           num2       = int.Parse(KMManager.ParserVersion, (IFormatProvider)CultureInfo.InvariantCulture);
                                using (List <string> .Enumerator enumerator = stringList.GetEnumerator())
                                {
                                    while (enumerator.MoveNext())
                                    {
                                        int num3 = int.Parse(enumerator.Current, (IFormatProvider)CultureInfo.InvariantCulture);
                                        if (num3 <= num2 && num3 >= num1)
                                        {
                                            string packageName = resJson["bluestacks_notification"][(object)"payload"][(object)"pkgName"].ToString();
                                            Logger.Info("downloadkeymappingcfg request sent to Android due to pv " + num3.ToString() + " pkg:" + packageName);
                                            Utils.SendKeymappingFiledownloadRequest(packageName, vmName);
                                            break;
                                        }
                                    }
                                    return;
                                }
                            }
                            else
                            {
                                Logger.Warning("Not processing downloadkeymappingcfg as parserVersionList not found");
                                return;
                            }
                        }
                        catch (Exception ex)
                        {
                            Logger.Warning("Error in sending download keymapping cfg request " + ex?.ToString());
                            return;
                        }
                    }
                    else
                    {
                        break;
                    }

                case 3602408690:
                    if (lower == "updatepromotions")
                    {
                        PromotionManager.ReloadPromotionsAsync();
                        return;
                    }
                    break;

                case 4066957630:
                    if (lower == "appusagestats")
                    {
                        CloudNotificationManager.HandleUsageNotification(resJson, vmName);
                        return;
                    }
                    break;
                }
            }
            Logger.Error("No method type found in HandleCallMethod json: " + resJson?.ToString());
        }