Exemple #1
0
        /// <summary>
        /// Check that the client is opened with the proper debugger port for the
        /// specified application name, and if not, reopen it. </summary>
        /// <param name="client"> </param>
        /// <param name="uiThread"> </param>
        /// <param name="appName">
        /// @return </param>
        protected internal static Client checkDebuggerPortForAppName(Client client, string appName)
        {
            DebugPortManager.IDebugPortProvider provider = DebugPortManager.provider;
            if (provider != null)
            {
                Device device  = client.deviceImpl;
                int    newPort = provider.getPort(device, appName);

                if (newPort != DebugPortManager.DebugPortProvider.NO_STATIC_PORT && newPort != client.debuggerListenPort)
                {
                    AndroidDebugBridge bridge = AndroidDebugBridge.bridge;
                    if (bridge != null)
                    {
                        DeviceMonitor deviceMonitor = bridge.deviceMonitor;
                        if (deviceMonitor != null)
                        {
                            deviceMonitor.addClientToDropAndReopen(client, newPort);
                            client = null;
                        }
                    }
                }
            }

            return(client);
        }
		/// <summary>
		/// Restarts adb, but not the services around it. </summary>
		/// <returns> true if success. </returns>
		public bool restart()
		{
			if (mAdbOsLocation == null)
			{
				Log.e(ADB, "Cannot restart adb when AndroidDebugBridge is created without the location of adb."); //$NON-NLS-1$
				return false;
			}

			if (mVersionCheck == false)
			{
				Log.logAndDisplay(Log.LogLevel.ERROR, ADB, "Attempting to restart adb, but version check failed!"); //$NON-NLS-1$
				return false;
			}
			lock (this)
			{
				stopAdb();

				bool restart = startAdb();

				if (restart && mDeviceMonitor == null)
				{
					mDeviceMonitor = new DeviceMonitor(this);
					mDeviceMonitor.start();
				}

				return restart;
			}
		}
	   /// <summary>
	   /// Kills the debug bridge, and the adb host server. </summary>
	   /// <returns> true if success </returns>
		internal bool stop()
		{
			// if we haven't started we return false;
			if (mStarted == false)
			{
				return false;
			}

			// kill the monitoring services
			mDeviceMonitor.stop();
			mDeviceMonitor = null;

			if (stopAdb() == false)
			{
				return false;
			}

			mStarted = false;
			return true;
		}
		/// <summary>
		/// Starts the debug bridge. </summary>
		/// <returns> true if success. </returns>
		internal bool start()
		{
			if (mAdbOsLocation != null && (mVersionCheck == false || startAdb() == false))
			{
				return false;
			}

			mStarted = true;

			// now that the bridge is connected, we start the underlying services.
			mDeviceMonitor = new DeviceMonitor(this);
			mDeviceMonitor.start();

			return true;
		}
Exemple #5
0
		internal Device(DeviceMonitor monitor, string serialNumber, DeviceState deviceState)
		{
			mMonitor = monitor;
			mSerialNumber = serialNumber;
			mState = deviceState;
		}
Exemple #6
0
 internal Device(DeviceMonitor monitor, string serialNumber, DeviceState deviceState)
 {
     mMonitor      = monitor;
     mSerialNumber = serialNumber;
     mState        = deviceState;
 }