public void ExecuteBadge(Context context, ComponentName componentName, int badgeCount)
        {
            if (badgeCount == 0)
            {
                badgeCount = -1;
            }
            var intent = new Intent(IntentAction);

            intent.PutExtra(IntentExtraPackagename, componentName.PackageName);
            intent.PutExtra(IntentExtraBadgeCount, badgeCount);
            intent.PutExtra(IntentExtraBadgeUpgradenumber, badgeCount);
            if (BroadcastHelper.CanResolveBroadcast(context, intent))
            {
                context.SendBroadcast(intent);
            }
            else
            {
                int version = SupportVersion;
                if (version == 6)
                {
                    try
                    {
                        var extras = new Bundle();
                        extras.PutInt(IntentExtraBadgeupgradeCount, badgeCount);
                        context.ContentResolver.Call(Uri.Parse(ProviderContentUri), "setAppBadgeCount", null, extras);
                    }
                    catch (Throwable)
                    {
                        throw new ShortcutBadgeException("unable to resolve intent: " + intent);
                    }
                }
            }
        }
Exemplo n.º 2
0
        public void ExecuteBadge(Context context, ComponentName componentName, int badgeCount)
        {
            try
            {
                var miuiNotificationClass = Class.ForName("android.app.MiuiNotification");
                var miuiNotification      = miuiNotificationClass.NewInstance();
                var field = miuiNotificationClass.GetDeclaredField("messageCount");
                field.Accessible = true;

                try
                {
                    field.Set(miuiNotification, String.ValueOf(badgeCount == 0 ? "" : badgeCount.ToString()));
                }
                catch (Exception)
                {
                    field.Set(miuiNotification, badgeCount);
                }
            }
            catch (Exception)
            {
                var localIntent = new Intent(IntentAction);
                localIntent.PutExtra(ExtraUpdateAppComponentName, $"{componentName.PackageName}/{componentName.ClassName}");
                localIntent.PutExtra(ExtraUpdateAppMsgText, String.ValueOf(badgeCount == 0 ? "" : badgeCount.ToString()));

                if (BroadcastHelper.CanResolveBroadcast(context, localIntent))
                {
                    context.SendBroadcast(localIntent);
                }
            }

            if (Build.Manufacturer.Equals("Xiaomi", StringComparison.CurrentCultureIgnoreCase))
            {
                TryNewMiuiBadge(context, badgeCount);
            }
        }
Exemplo n.º 3
0
        public void StartGame(Room room, string[] map)
        {
            //Now, Player 1 must supply map, Player 2 just attack.
            MapInfo mapInfo = new MapInfo(room, map);

            MapInfos.Add(room.Id, mapInfo);
            BroadcastHelper.BroadcastStartGame(_hubContext, room);
        }
Exemplo n.º 4
0
        private static bool ExecuteBadgeByBroadcast(Context context, ComponentName componentName, int badgeCount)
        {
            Intent intent = new Intent(INTENT_ACTION);

            intent.PutExtra(INTENT_EXTRA_PACKAGE_NAME, componentName.PackageName);
            intent.PutExtra(INTENT_EXTRA_ACTIVITY_NAME, componentName.ClassName);
            intent.PutExtra(INTENT_EXTRA_MESSAGE, badgeCount.ToString());
            intent.PutExtra(INTENT_EXTRA_SHOW_MESSAGE, badgeCount > 0);
            return(BroadcastHelper.SendBroadcast(context, intent));
        }
Exemplo n.º 5
0
        public virtual bool Set(Context context, ComponentName component, int badgeCount)
        {
            Intent intent = new Intent(IntentName);

            AddExtra(intent, PackageParameterName, component.PackageName);
            AddExtra(intent, ClassParameterName, component.ClassName);
            AddExtra(intent, CountParameterName, badgeCount);
            AddExtraToIntent(intent, context, component, badgeCount);

            return(BroadcastHelper.SendBroadcast(context, intent));
        }
Exemplo n.º 6
0
        public bool Set(Context context, ComponentName component, int badgeCount)
        {
            Intent intent1 = new Intent(INTENT_SET_NOTIFICATION);

            intent1.PutExtra(EXTRA_COMPONENT, component.FlattenToShortString());
            intent1.PutExtra(EXTRA_COUNT, badgeCount);

            Intent intent2 = new Intent(INTENT_UPDATE_SHORTCUT);

            intent2.PutExtra(PACKAGENAME, component.PackageName);
            intent2.PutExtra(COUNT, badgeCount);

            return(BroadcastHelper.SendBroadcast(context, intent1) & BroadcastHelper.SendBroadcast(context, intent2));
        }
Exemplo n.º 7
0
        public void AttackOnMap(Room room, int x, int y)
        {
            MapInfo MapInfo = null;

            MapInfos.TryGetValue(room.Id, out MapInfo);
            string message = MapInfo.Attack(x, y);

            if (MapInfo.GameSet())
            {
                BroadcastHelper.BroadcastGameSet(_hubContext, room);
            }
            else
            {
                BroadcastHelper.BroadcastAttackResult(_hubContext, room, MapInfo.VisualizeMap(), message);
            }
        }
        public void ExecuteBadge(Context context, ComponentName componentName, int badgeCount)
        {
            var intent = new Intent(IntentAction);

            intent.PutExtra(IntentExtraBadgeCount, badgeCount);
            intent.PutExtra(IntentExtraPackageName, componentName.PackageName);
            intent.PutExtra(IntentExtraActivityName, componentName.ClassName);

            if (BroadcastHelper.CanResolveBroadcast(context, intent))
            {
                context.SendBroadcast(intent);
            }
            else
            {
                throw new ShortcutBadgeException("unable to resolve intent: " + intent);
            }
        }
Exemplo n.º 9
0
    public Simulator(Parameters parameters, bool do_not_start)
    {
      _parameters = parameters;
      StartingNetworkSize = parameters.Size;
      CurrentNetworkSize = 0;
      Nodes = new SortedList<Address, NodeMapping>();
      TakenIDs = new SortedList<int, NodeMapping>();
      _bcast = new BroadcastHelper();

      if(parameters.Seed != -1) {
        Console.WriteLine(parameters.Seed);
        _rand = new Random(parameters.Seed);
      } else {
        _rand = new Random();
      }

      BrunetNamespace = "testing" + _rand.Next();
      _broken = parameters.Broken;
      _secure_edges = parameters.SecureEdges;
      _secure_senders = parameters.SecureSenders;
      _pathing = parameters.Pathing;
      _dtls = parameters.Dtls;
      if(_secure_edges || _secure_senders) {
        _se_key = new RSACryptoServiceProvider();
        byte[] blob = _se_key.ExportCspBlob(false);
        RSACryptoServiceProvider rsa_pub = new RSACryptoServiceProvider();
        rsa_pub.ImportCspBlob(blob);
        CertificateMaker cm = new CertificateMaker("United States", "UFL", 
            "ACIS", "David Wolinsky", "*****@*****.**", rsa_pub,
            "brunet:node:abcdefghijklmnopqrs");
        Certificate cert = cm.Sign(cm, _se_key);
        _ca_cert = cert;
      }

      if(parameters.LatencyMap != null) {
        SimulationEdgeListener.LatencyMap = parameters.LatencyMap;
      }

      _start = parameters.Evaluation;
      if(!do_not_start) {
        Start();
      }
      _start = false;
    }
Exemplo n.º 10
0
        public async Task <ActionResult <Player> > PostPlayer(Player onlyName)
        {
            string inputName = onlyName.Name;
            var    player    = await _context.Players.SingleOrDefaultAsync(e => e.Name == inputName);

            if (player != null)
            {
                _context.Entry(player).State = EntityState.Modified;
            }
            else
            {
                player = new Player(inputName);
                _context.Players.Add(player);
            }
            player.Ip = _accessor.ActionContext.HttpContext.Connection.RemoteIpAddress.MapToIPv4().ToString();
            await _context.SaveChangesAsync();

            BroadcastHelper.Online(_hubContext, player);
            _gamecenter.AddOnlinePlayer(player);
            return(CreatedAtAction(nameof(GetPlayer), new { id = player.Id }, player));
        }
Exemplo n.º 11
0
        public void ExecuteBadge(Context context, ComponentName componentName, int badgeCount)
        {
            var intent1 = new Intent(IntentSetNotification);

            intent1.PutExtra(ExtraComponent, componentName.FlattenToShortString());
            intent1.PutExtra(ExtraCount, badgeCount);

            var intent = new Intent(IntentUpdateShortcut);

            intent.PutExtra(PackageName, componentName.PackageName);
            intent.PutExtra(Count, badgeCount);

            if (BroadcastHelper.CanResolveBroadcast(context, intent1) ||
                BroadcastHelper.CanResolveBroadcast(context, intent))
            {
                context.SendBroadcast(intent1);
                context.SendBroadcast(intent);
            }
            else
            {
                throw new ShortcutBadgeException("unable to resolve intent: " + intent);
            }
        }
Exemplo n.º 12
0
    // Use this for initialization
    void Awake()
    {
        if (Instance != null)
        {
            GameObject.DestroyImmediate(this);
            return;
        }
        Instance = this;
        DontDestroyOnLoad(this);

        NetworkManager  = GameObject.Find("NetworkManager").GetComponent <NetworkManager>();
        BroadcastHelper = GetComponent <BroadcastHelper>();

        _landing = GameObject.Find("Landing");

        Button hostButton   = GameObject.Find("Landing/Host/HostButton").GetComponent <Button>();
        Button clientButton = GameObject.Find("Landing/Client/ClientButton").GetComponent <Button>();
        //Button startButton = GameObject.Find("ServerPanel/Button").GetComponent<Button>();

        Text respawnTimer = GameObject.Find("Canvas").transform.Find("RespawnTimer").GetComponent <Text>();

        respawnTimer.gameObject.SetActive(false);

        //InputField nameInput = GameObject.Find("Landing/NameInput").GetComponent<InputField>();
        //nameInput.onEndEdit.AddListener((s) => {
        //    PlayerName = s;
        //});

        ConnectedPlayers = new Dictionary <string, Player>();

        hostButton.onClick.AddListener(() => {
            Debug.Log("Host button clicked");
            if (Map != null)
            {
                NetworkServer.Destroy(Map);
            }
            Map                      = GameObject.Instantiate(Resources.Load("Prefabs/Map") as GameObject);
            Map.name                 = "Map";
            var mapManager           = Map.GetComponent <MapManager>();
            Map.transform.position   = Vector3.zero;
            Map.transform.localScale = Vector3.one;
            Map.transform.rotation   = Quaternion.identity;

            //Start as host
            NetworkManager.StartHost();

            mapManager.GenerateMap(5, 5);
            NetworkServer.Spawn(Map);
            BroadcastHelper.StartServerBroadcast();
            StartGame();
        });

        clientButton.onClick.AddListener(() => {
            Debug.Log("Client button clicked");
            BroadcastHelper.StartClientBroadcast();
            //Lucas was here
            _landing.SetActive(false);
        });

        //MapManager.GenerateMap(System.DateTime.UtcNow.Second, 10, 10);
    }
Exemplo n.º 13
0
        public bool IsSupported(Context context)
        {
            var intent = new Intent(IntentAction);

            return(BroadcastHelper.CanResolveBroadcast(context, intent));
        }
Exemplo n.º 14
0
        public bool Set(Context context, ComponentName component, int badgeCount)
        {
            try
            {
                try
                {
                    Class  miuiNotificationClass = Class.ForName("android.app.MiuiNotification");
                    Object miuiNotification      = miuiNotificationClass.NewInstance();
                    Field  field = miuiNotification.Class.GetDeclaredField("messageCount");
                    field.Accessible = true;

                    try
                    {
                        field.Set(miuiNotification, badgeCount == 0 ? "" : badgeCount.ToString());
                    }
                    catch (Exception)
                    {
                        field.Set(miuiNotification, badgeCount);
                    }
                }
                catch (Exception)
                {
                    Intent intent = new Intent(INTENT_ACTION);
                    intent.PutExtra(EXTRA_UPDATE_APP_COMPONENT_NAME, component.PackageName + "/" + component.ClassName);
                    intent.PutExtra(EXTRA_UPDATE_APP_MSG_TEXT, badgeCount == 0 ? "" : badgeCount.ToString());

                    try
                    {
                        BroadcastHelper.SendBroadcast(context, intent);
                    }
                    catch (Exception)
                    {
                        //ignored
                    }
                }

                if (Build.Manufacturer.Equals("Xiaomi", StringComparison.InvariantCultureIgnoreCase))
                {
                    if (_resolveInfo == null)
                    {
                        Intent intent = new Intent(Intent.ActionMain);
                        intent.AddCategory(Intent.CategoryHome);
                        _resolveInfo = context.PackageManager.ResolveActivity(intent, PackageInfoFlags.MatchDefaultOnly);
                    }

                    if (_resolveInfo == null)
                    {
                        return(true);
                    }

                    NotificationManager  mNotificationManager = (NotificationManager)context.GetSystemService(Context.NotificationService);
                    Notification.Builder builder = new Notification.Builder(context)
                                                   .SetContentTitle("")
                                                   .SetContentText("")
                                                   .SetSmallIcon(_resolveInfo.IconResource);
                    Notification notification = builder.Build();
                    try
                    {
                        Field  field             = notification.Class.GetDeclaredField("extraNotification");
                        Object extraNotification = field.Get(notification);
                        Method method            = extraNotification.Class.GetDeclaredMethod("setMessageCount", Integer.Type);
                        method.Invoke(extraNotification, badgeCount);
                        mNotificationManager.Notify(0, notification);
                    }
                    catch (Exception)
                    {
                        return(false);
                    }
                }
            }
            catch (Exception)
            {
                //ignored
            }

            return(true);
        }
Exemplo n.º 15
0
 public bool IsSupported(Context context)
 {
     return(BroadcastHelper.CanResolveBroadcast(context, new Intent(Constants.DEFAULT_INTENT_ACTION)) ||
            (Build.VERSION.SdkInt >= BuildVersionCodes.O &&
             BroadcastHelper.CanResolveBroadcast(context, new Intent(Constants.DEFAULT_OREO_INTENT_ACTION))));
 }