Пример #1
0
        /// <summary>
        /// Queries a device for its build info. </summary>
        /// <param name="device"> the device to query. </param>
        private void queryNewDeviceForInfo(Device device)
        {
            // TODO: do this in a separate thread.
            try
            {
                // first get the list of properties.
                device.executeShellCommand(GetPropReceiver.GETPROP_COMMAND, new GetPropReceiver(device));

                queryNewDeviceForMountingPoint(device, DeviceConstants.MNT_EXTERNAL_STORAGE);
                queryNewDeviceForMountingPoint(device, DeviceConstants.MNT_DATA);
                queryNewDeviceForMountingPoint(device, DeviceConstants.MNT_ROOT);

                // now get the emulator Virtual Device name (if applicable).
                if (device.emulator)
                {
                    EmulatorConsole console = EmulatorConsole.getConsole(device);
                    if (console != null)
                    {
                        device.avdName = console.avdName;
                    }
                }
            }
            catch (TimeoutException)
            {
                Log.w("DeviceMonitor", string.Format("Connection timeout getting info for device {0}", device.serialNumber));
            }
            catch (AdbCommandRejectedException e)
            {
                // This should never happen as we only do this once the device is online.
                Log.w("DeviceMonitor", string.Format("Adb rejected command to get  device {0} info: {1}", device.serialNumber, e.Message));
            }
            catch (ShellCommandUnresponsiveException)
            {
                Log.w("DeviceMonitor", string.Format("Adb shell command took too long returning info for device {0}", device.serialNumber));
            }
            catch (IOException)
            {
                Log.w("DeviceMonitor", string.Format("IO Error getting info for device {0}", device.serialNumber));
            }
        }
Пример #2
0
		public static EmulatorConsole getConsole(IDevice d)
		{
			// we need to make sure that the device is an emulator
			// get the port number. This is the console port.
			int? port = getEmulatorPort(d.serialNumber);
			if (!port.HasValue)
			{
				return null;
			}

			EmulatorConsole console = sEmulators[port.Value];

			if (console != null)
			{
				// if the console exist, we ping the emulator to check the connection.
				if (console.ping() == false)
				{
					RemoveConsole(console.mPort);
					console = null;
				}
			}

			if (console == null)
			{
				// no console object exists for this port so we create one, and start
				// the connection.
				console = new EmulatorConsole(port.Value);
				if (console.start())
				{
					sEmulators.Add(port.Value, console);
				}
				else
				{
					console = null;
				}
			}

			return console;
		}