Beispiel #1
0
        private static void Monitor_DeviceDisconnected(object sender, DeviceDataEventArgs e)
        {
            Log.Information("Device disconnected", e.Device);
            List <VirtualDrive> drivesToRemove = new List <VirtualDrive>();

            foreach (VirtualDrive d in Devices)
            {
                if (e.Device.Serial.Equals(d.AndroidDevice.Serial))
                {
                    if (Dokan.Unmount(d.DriveLetter))
                    {
                        Log.Information("Successfully unmounted drive " + d.DriveLetter);
                    }
                    else
                    {
                        Log.Warning("Error while unmounting " + d.DriveLetter);
                    }
                    drivesToRemove.Add(d);
                }
            }
            foreach (VirtualDrive d in drivesToRemove)
            {
                Devices.Remove(d);
            }
        }
Beispiel #2
0
        private void OnDeviceConnected(object sender, DeviceDataEventArgs e)
        {
            //when the start position is Fastboot, the devices get duplicated in Recovery mode
            AndroidDevice        device  = new AndroidDevice();
            List <AndroidDevice> devices = ADB.GetConnectedDevices();

            foreach (AndroidDevice item in devices)
            {
                if (item.Serial == e.Device.Serial)
                {
                    device      = item;
                    device.IMEI = ADB.GetIMEI(item.GetDevice());
                    adbDevices.Add(device);
                    mainForm.AddADBDevice(device);
                    break;
                }
            }
            if (e.Device.State == DeviceState.Unknown)
            {
            }
            else if (e.Device.State == DeviceState.Unauthorized)
            {
                MessageBox.Show("Bitte USB-Debugging auf alle Geräte erlauben!");
                Task.Run(() => WaitUntilAuthorized(e.Device.Serial));
            }
            else if (e.Device.State == DeviceState.Offline)
            {
            }
            CreateLog($"Device Connected: {e.Device.Serial}");
            CreateLog($"Device State: {e.Device.State}");
        }
Beispiel #3
0
        private void DeviceChanged(object sender, DeviceDataEventArgs e)
        {
            var device = new Device(e.Device);

            Logger.Debug("ADB Device changed: {}", device.Serial);
            OnDeviceConnected(sender, e);
        }
Beispiel #4
0
        /// <summary>
        /// Processes the strike received for V2 receiver (EIDSS 3.0)
        /// </summary>
        /// <param name="e">The <see cref="LaJust.EIDSS.Communications.Hardware.DataPacketReceivedEventArgs"/> instance containing the event data.</param>
        /// <returns>Device Event Data</returns>
        private DeviceDataEventArgs Process_HoguDataReceivedV2(DataPacketReceivedEventArgs e)
        {
            // Generate acknowledgement packet and send to receiver
            this.receiverComm.SendDataPacket(new byte[3]
            {
                e.DataPacket[(byte)HoguDataFieldsV2.GameNumber],
                (byte)OpCodeCmds.Acknowledgement,
                e.DataPacket[(byte)HoguDataFieldsV2.SequenceNumber]
            });

            // Parse data packet
            DeviceDataEventArgs deviceData = new DeviceDataEventArgs()
            {
                ReceiverId           = this.Id,
                GameNumber           = e.DataPacket[(byte)HoguDataFieldsV2.GameNumber],
                OperationCode        = (OpCodes)e.DataPacket[(byte)HoguDataFieldsV2.OpCode],
                RegistrationSequence = e.DataPacket[(byte)HoguDataFieldsV2.RegSequence],
                VestHitValue         = e.DataPacket[(byte)HoguDataFieldsV2.VestHitValue],
                HeadHitValue         = e.DataPacket[(byte)HoguDataFieldsV2.HeadHitValue],
                TouchStatus          = (TouchSensorStatusEnum)e.DataPacket[(byte)HoguDataFieldsV2.TouchStatus],
                DeviceStatus         = (DeviceStatusEnum)e.DataPacket[(byte)HoguDataFieldsV2.HoguStatus],
                DeviceId             = new DeviceId(e.DataPacket[(byte)HoguDataFieldsV2.ID1], e.DataPacket[(byte)HoguDataFieldsV2.ID2], e.DataPacket[(byte)HoguDataFieldsV2.ID3]),
                SequenceNumber       = e.DataPacket[(byte)HoguDataFieldsV2.SequenceNumber]
            };

            return(deviceData);
        }
Beispiel #5
0
        // Monitor Functions
        private void OnDeviceDisconnected(object sender, DeviceDataEventArgs e)
        {
            ConsoleLogger.WriteTime("The device " + _device.Name + " has disconnected to this PC", textColor: ConsoleColor.Red);
            ConsoleLogger.WriteTime("Please restart the application and go back to the Mission Select Menu.");

            Environment.Exit(0);
        }
Beispiel #6
0
 /// <summary>
 /// Check if the device is connected multiple times when it changes it's state
 /// If so, invoke the MultipleSameDevices event
 /// </summary>
 /// <param name="sender"> The sender </param>
 /// <param name="e"> Event to recognize devices </param>
 private static void OnDeviceChanged(object sender, DeviceDataEventArgs e)
 {
     if (Client.GetDevices().FindAll(x => x.Serial.Equals(e.Device.Serial)).Count > 1)
     {
         Instance.OnMultipleSameDevicesConnected(new EventArgs());
     }
 }
Beispiel #7
0
        private void Monitor_DeviceConnected(object sender, DeviceDataEventArgs e)
        {
            var res = MessageBox.Show(string.Format("Found new device: {0}\nConnect to it?", e.Device.Name), "AdbLiveTweaks", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (res == DialogResult.Yes)
            {
                Device = e.Device;
                Invoke(new EnableButtonsDelegate((s) =>
                {
                    button2.Enabled  = s;
                    button3.Enabled  = s;
                    button4.Enabled  = s;
                    button5.Enabled  = s;
                    button6.Enabled  = s;
                    button7.Enabled  = s;
                    button8.Enabled  = s;
                    button9.Enabled  = s;
                    button10.Enabled = s;
                    button11.Enabled = s;
                }), true);
            }
            else
            {
                //don't do anything
            }
        }
        /// <summary>
        /// Called when the receiver reports data from a device indicating a hit has registered.
        /// We need to update the scorekeeper service if a game is in progress.
        /// </summary>
        /// <param name="deviceData">The sensor impact data.</param>
        protected void OnSensorHit(DeviceDataEventArgs deviceData)
        {
            CompetitorModel competitor = this.ScoreKeeperService.Competitors.FirstOrDefault(c => c.DeviceId.Equals(deviceData.DeviceId));

            if (competitor != null)
            {
                byte impactLevel = Math.Max(deviceData.HeadHitValue, deviceData.VestHitValue);

                // If we are in partnering mode, we need to flip to award score/impact to the correct person
                if (competitor.HasPartner)
                {
                    competitor = competitor.Partner;
                }

                competitor.LastImpactLevel = impactLevel;

                if (!this.StopWatchService.IsRunning && this.StopWatchService.DisplayTime == this.StopWatchService.Duration)
                {
                    competitor.Score = competitor.HighestImpactLevel;
                }
                else if (this.StopWatchService.IsRunning && impactLevel >= competitor.RequiredImpactLevel)
                {
                    competitor.Score += 1; // TODO: Allow configurable points
                    this.Logger.Log("KickAndPunch score for " + competitor.DisplayName + " is now " + competitor.Score, Category.Info, Priority.Low);
                }
            }
        }
Beispiel #9
0
        private void onDeviceDisConnected(object sender, DeviceDataEventArgs e)
        {
            e.Device.State    = DeviceState.Offline;
            CurrentDeviceData = e.Device;

            DeviceStatusChanged?.Invoke(this, e);
            Console.WriteLine($"The device {e.Device.Name} has disconnected to this PC " + e.Device.State);
        }
Beispiel #10
0
        private static void OnDeviceConnected(object sender, DeviceDataEventArgs args)
        {
            var dev = args.Device;

            CacheDeviceList();
            Console.WriteLine($"Device connected {dev.Name}[{dev.Model}/{dev.Serial}]");
            ListDir(dev.Serial, "/");
            //EchoTest(args.Device.Serial);
        }
Beispiel #11
0
 private void UpdateComboBox(object sender, DeviceDataEventArgs e)
 {
     this.Dispatcher.Invoke(() =>
     {
         UsbControl.InitializeDeviceList();
         TcpControl.InitializeDeviceList();
         ConnectControl.InitializeDeviceList();
     });
 }
Beispiel #12
0
        private void DeviceDisconnected(object sender, DeviceDataEventArgs e)
        {
            var device = new Device(e.Device);

            Logger.Debug("ADB Device disconnected: {}", device.Serial);
            if (device.Serial == currentDevice.Serial)
            {
                SwitchFallback();
            }
        }
Beispiel #13
0
 /// <summary>
 /// Display a toast
 /// </summary>
 /// <param name="sender"> The sender </param>
 /// <param name="e"> Event to recognize devices </param>
 private static void OnDeviceDisconnected(object sender, DeviceDataEventArgs e)
 {
     ThreadPool.SetMaxThreads(GetConnectedDevices().Count, GetConnectedDevices().Count);
     LoggingManager.DeleteEntry(e.Device.Serial);
     Console.WriteLine($"The device {e.Device} has disconnected from this PC");
     RecController.StopScrRec(e.Device);
     if (MarkerList.ActiveDeviceData is not null && MarkerList.ActiveDeviceData.Serial.Equals(e.Device.Serial))
     {
         MarkerList.ActiveDeviceData = null;
     }
 }
 private void OnDeviceConnected(object sender, DeviceDataEventArgs e)
 {
     try
     {
         devices.Add(e.Device);
         Console.Out.WriteLine("Device connected " + e.Device.ToString());
     }
     catch
     {
     }
 }
Beispiel #15
0
        private static void Monitor_DeviceConnected(object sender, DeviceDataEventArgs e)
        {
            Log.Information("Device connected", e.Device);
            char         letter = DriveHelpers.GetNextAvailableDriveLetter();
            VirtualDrive drive  = new VirtualDrive(e.Device, Monitor.Socket, letter);

            Devices.Add(drive);
            new Thread(new ThreadStart(() =>
            {
                drive.Mount(letter + ":\\", /*DokanOptions.DebugMode | DokanOptions.StderrOutput | */ DokanOptions.RemovableDrive, new NullLogger());
            })).Start();
        }
Beispiel #16
0
 private void OnDeviceDisconnected(object sender, DeviceDataEventArgs e)
 {
     try
     {
         var disconnectedDeviceViewModel = new AndroidDeviceViewModel(e.Device);
         ThreadingExtensions.DispatchOnUIThread(() => AndroidDeviceViewModels.Remove(disconnectedDeviceViewModel));
     }
     catch (Exception exception)
     {
         LoggingService.Logger.Error(exception.Message);
     }
 }
Beispiel #17
0
        internal void OnDeviceDisconnected(object sender, DeviceDataEventArgs e)
        {
            string s = "";

            foreach (AndroidDevice item in adbAndroidDevices)
            {
                if (item.Serial == e.Device.Serial)
                {
                    s = item.Model + ": " + item.IMEI;
                }
            }
            ChangeLastStatus($"The device {s} has disconnected from this PC via ADB");
            RefreshDevices();
        }
        /// <summary>
        /// Raises the <see cref="E:HitReceived"/> event.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="LaJust.EIDSS.Communications.Entities.DeviceDataEventArgs"/> instance containing the event data.</param>
        protected virtual void OnStrikeDetected(object sender, DeviceDataEventArgs e)
        {
            EventHandler <DeviceDataEventArgs> handler = this.StrikeDetected;

            try
            {
                handler(this, e);
            }
            catch (Exception ex)
            {
                Trace.TraceError("{0}.OnStrikeDetected: {1}", CLASSNAME, ex.GetBaseException());
                throw;
            }
        }
 private void OnDeviceDisconnected(object sender, DeviceDataEventArgs e)
 {
     try
     {
         devices.Remove(e.Device);
         Console.Out.WriteLine("Device disconnected " + e.Device.ToString());
         if (e.Device == this.selectedDevice)
         {
             //Restart
         }
     }
     catch
     {
     }
 }
Beispiel #20
0
        private void OnDeviceConnected(object sender, DeviceDataEventArgs e)
        {
            var device = new Device(e.Device);
            var devs   = AdbClient.Instance.GetDevices().Where(m => m.Serial == device.Data.Serial);

            if (devs.Count() < 1)
            {
                return;
            }
            device = new Device(devs.First());
            Logger.Debug("ADB Device connected: {}", device.Serial);
            if (device.IsQuest && (currentDevice is null || !currentDevice.IsConnected || (currentDevice.IsWifi && !device.IsWifi)))
            {
                Logger.Info("Quest {} found, switching...", device.Serial);
                UseDevice(device);
            }
        }
Beispiel #21
0
 private void OnDeviceDisconnected(object sender, DeviceDataEventArgs e)
 {
     if (e.Device.Equals(GetSelecetedDevice()))
     {
         objectListViewPackages.ClearObjects();
     }
     if (this.InvokeRequired)
     {
         this.Invoke((MethodInvoker) delegate() { this.devices.Remove(e.Device); });
     }
     else
     {
         this.devices.Remove(e.Device);
     }
     SetProduct(String.Empty);
     WriteLog($"The device {e.Device.Name} {e.Device.Serial} has disconnected to this PC");
 }
Beispiel #22
0
 private void OnDeviceConnected(object sender, DeviceDataEventArgs e)
 {
     try
     {
         // Sleep for a few seconds otherwise device data not complete, this is a bug
         Thread.Sleep(1000);
         DeviceData connectedDevice          = _adbClient.GetDevices().Find(device => device.Serial == e.Device.Serial);
         var        connectedDeviceViewModel = new AndroidDeviceViewModel(connectedDevice);
         if (!AndroidDeviceViewModels.Contains(connectedDeviceViewModel))
         {
             ThreadingExtensions.DispatchOnUIThread(() => AndroidDeviceViewModels.Add(connectedDeviceViewModel));
         }
     }
     catch (Exception exception)
     {
         LoggingService.Logger.Error(exception.Message);
     }
 }
Beispiel #23
0
        private void OnDeviceConnected(object sender, DeviceDataEventArgs e)
        {
            Thread.Sleep(500);  //  Giving time for thinking to device
            Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() =>
            {
                if (connectWindow != null)
                {
                    CloseConnectWindow();
                }

                switch (AdbClient.Instance.GetDevices().First().State)
                {
                case DeviceState.Online:
                    try
                    {
                        GrantPermission();
                    }
                    catch
                    {
                        // ignored
                    }
                    break;

                case DeviceState.Unauthorized:
                    device = AdbClient.Instance.GetDevices().First();

                    //Showing help window to authorize server
                    authorizeWindow = new AuthorizeWindow()
                    {
                        Owner = Application.Current.MainWindow
                    };

                    authorizeWindow.Show();
                    AdbClient.Instance.GetDevices();

                    authorizeWindow.ContentRendered += AuthorizeWindowContentRendered;
                    break;

                default:
                    OpenConnectWindow();
                    break;
                }
            }));
        }
Beispiel #24
0
        private void OnDeviceDisconnected(object sender, DeviceDataEventArgs e)
        {
            string        s      = "";
            AndroidDevice device = new AndroidDevice(e.Device.Model, e.Device.Name, e.Device.Product, e.Device.Serial, e.Device.State, e.Device.TransportId, ADB.GetIMEI(e.Device));

            foreach (AndroidDevice item in adbDevices)
            {
                if (item.Serial == e.Device.Serial)
                {
                    if (item.IMEI != "not available")
                    {
                        s = item.Model + ": " + item.IMEI;
                    }
                    else
                    {
                        s = item.Model + ": " + item.Serial;
                    }
                }
            }
            mainForm.RemoveADBDevice(device);
        }
Beispiel #25
0
        /// <summary>
        /// Processes the strike received for version 1 receiver (EIDSS 2.0)
        /// </summary>
        /// <param name="e">The <see cref="LaJust.EIDSS.Communications.Hardware.DataPacketReceivedEventArgs"/> instance containing the event data.</param>
        /// <returns>Device Event Data</returns>
#if EIDSS2
        private DeviceDataEventArgs Process_HoguDataReceivedV1(DataPacketReceivedEventArgs e)
        {
            // Generate acknowledgement packet and send to receiver
            this.receiverComm.SendDataPacket(new byte[3]
            {
                e.DataPacket[(byte)HoguDataFieldsV1.GameNumber],
                (byte)OpCodeCmds.Acknowledgement,
                e.DataPacket[(byte)HoguDataFieldsV1.SequenceNumber]
            });

            // Parse data packet
            DeviceDataEventArgs deviceData = new DeviceDataEventArgs()
            {
                ReceiverId           = this.Id,
                GameNumber           = e.DataPacket[(byte)HoguDataFieldsV1.GameNumber],
                OperationCode        = (OpCodes)e.DataPacket[(byte)HoguDataFieldsV1.OpCode],
                RegistrationSequence = e.DataPacket[(byte)HoguDataFieldsV1.RegSequence],
                VestHitValue         = e.DataPacket[(byte)HoguDataFieldsV1.VestHitValue],
                HeadHitValue         = e.DataPacket[(byte)HoguDataFieldsV1.HeadHitValue],
                TouchStatus          = (TouchSensorStatusEnum)e.DataPacket[(byte)HoguDataFieldsV1.TouchStatus],
                DeviceStatus         = (DeviceStatusEnum)e.DataPacket[(byte)HoguDataFieldsV1.HoguStatus],
                SequenceNumber       = e.DataPacket[(byte)HoguDataFieldsV1.SequenceNumber]
            };

            // Insert device Id information we stored during registration as V1 data packet does not include it
            switch (deviceData.OperationCode)
            {
            case OpCodes.ChungDataV1:
                deviceData.DeviceId = this.chungDeviceId;
                break;

            case OpCodes.HongDataV1:
                deviceData.DeviceId = this.hongDeviceId;
                break;
            }

            return(deviceData);
        }
Beispiel #26
0
 private void Monitor_DeviceDisconnected(object sender, DeviceDataEventArgs e)
 {
     if (Device.Equals(e.Device))
     {
         MessageBox.Show(string.Format("{0} has been disconnected unexpectedly", e.Device.Name), "AdbLiveTweaks", MessageBoxButtons.OK, MessageBoxIcon.Error);
         Invoke(new EnableButtonsDelegate((s) =>
         {
             button2.Enabled  = s;
             button3.Enabled  = s;
             button4.Enabled  = s;
             button5.Enabled  = s;
             button6.Enabled  = s;
             button7.Enabled  = s;
             button8.Enabled  = s;
             button9.Enabled  = s;
             button10.Enabled = s;
             button11.Enabled = s;
         }), false);
     }
     else
     {
         MessageBox.Show(string.Format("{0} has been disconnected unexpectedly", e.Device.Name), "AdbLiveTweaks", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Beispiel #27
0
        /// <summary>
        /// Processes the strike received for V2 receiver (EIDSS 3.0)
        /// </summary>
        /// <param name="e">The <see cref="LaJust.EIDSS.Communications.Hardware.DataPacketReceivedEventArgs"/> instance containing the event data.</param>
        /// <returns>Device Event Data</returns>
        private DeviceDataEventArgs Process_TargetDataReceivedV2(DataPacketReceivedEventArgs e)
        {
            // Generate acknowledgement packet and send to receiver
            this.receiverComm.SendDataPacket(new byte[3]
            {
                e.DataPacket[(int)TargetDataFieldsV2.GameNumber],
                (byte)OpCodeCmds.Acknowledgement,
                e.DataPacket[(int)TargetDataFieldsV2.SequenceNumber]
            });

            // Parse data packet
            DeviceDataEventArgs deviceData = new DeviceDataEventArgs()
            {
                ReceiverId           = this.Id,
                GameNumber           = e.DataPacket[(byte)TargetDataFieldsV2.GameNumber],
                OperationCode        = (OpCodes)e.DataPacket[(byte)TargetDataFieldsV2.OpCode],
                RegistrationSequence = e.DataPacket[(byte)TargetDataFieldsV2.RegSequence],
                VestHitValue         = e.DataPacket[(byte)TargetDataFieldsV2.VestHitValue],
                HeadHitValue         = e.DataPacket[(byte)TargetDataFieldsV2.HeadHitValue],

                // Remove "touch sensor" bit from wet bag panel byte by AND with 0x77 (0111 0111)
                WetBagPanel = (WetBagPanelEnum)(e.DataPacket[(byte)TargetDataFieldsV2.TargetPanel] & 0x77),

                // Determine "touch sensor" bit from wet bag panel byte by checking 0x08 or 0x80 bits
                TouchStatus = (((e.DataPacket[(byte)TargetDataFieldsV2.TargetPanel] & 0x08) == 0x08) ||
                               ((e.DataPacket[(byte)TargetDataFieldsV2.TargetPanel] & 0x80) == 0x80)) ?
                              TouchSensorStatusEnum.Required : TouchSensorStatusEnum.NotRequired,
                DeviceStatus   = (DeviceStatusEnum)e.DataPacket[(byte)TargetDataFieldsV2.TargetStatus],
                DeviceId       = new DeviceId(e.DataPacket[(byte)TargetDataFieldsV2.ID1], e.DataPacket[(byte)TargetDataFieldsV2.ID2], e.DataPacket[(byte)TargetDataFieldsV2.ID3]),
                SequenceNumber = e.DataPacket[(byte)TargetDataFieldsV2.SequenceNumber],
                TargetNumber   = e.DataPacket[(byte)TargetDataFieldsV2.TargetNumber],
                TargetTotal    = e.DataPacket[(byte)TargetDataFieldsV2.TargetTotal]
            };

            return(deviceData);
        }
Beispiel #28
0
 private void OnDeviceDisconnected(object sender, DeviceDataEventArgs args)
 {
     this.DevicesChanged?.Invoke(this, new EventArgs());
 }
Beispiel #29
0
 /// <summary>
 /// age device connect shod => IsConnect True mishe & timer_event Start mishe
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Monitor_DeviceConnected(object sender, DeviceDataEventArgs e)
 {
     IsConnect = true;
     timer_event.Start();
 }
Beispiel #30
0
 /// <summary>
 /// age device disconnect shod => IsDisconnect True mishe & timer_event Start mishe
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Monitor_DeviceDisconnected(object sender, DeviceDataEventArgs e)
 {
     DisposeAllChildForm();
     IsDisconnect = true;
     timer_event.Start();
 }
Beispiel #31
0
 protected virtual void OnDeviceChanged(object sender, DeviceDataEventArgs e)
 {
     this.ChangedEvents.Add(e);
 }
Beispiel #32
0
 protected virtual void OnDeviceDisconnected(object sender, DeviceDataEventArgs e)
 {
     this.DisconnectedEvents.Add(e);
 }