/// <summary> /// Creates a new debug bridge from the location of the command line tool. /// </summary> /// <param name="osLocation">the location of the command line tool 'adb'</param> /// <param name="forceNewBridge">force creation of a new bridge even if one with the same location /// already exists.</param> /// <returns>a connected bridge.</returns> /// <remarks>Any existing server will be disconnected, unless the location is the same and /// <code>forceNewBridge</code> is set to false. /// </remarks> public static AndroidDebugBridge CreateBridge(String osLocation, bool forceNewBridge) { if (_instance != null) { if (!String.IsNullOrEmpty(AdbOsLocation) && string.Compare(AdbOsLocation, osLocation, true) == 0 && !forceNewBridge) { return(_instance); } else { // stop the current server Log.d(TAG, "Stopping Current Instance"); _instance.Stop( ); } } try { _instance = new AndroidDebugBridge(osLocation); _instance.Start( ); _instance.OnBridgeChanged(new AndroidDebugBridgeEventArgs(_instance)); } catch (ArgumentException) { _instance.OnBridgeChanged(new AndroidDebugBridgeEventArgs(null)); _instance = null; } return(_instance); }
/// <summary> /// Creates a {@link AndroidDebugBridge} that is not linked to any particular executable. /// This bridge will expect adb to be running. It will not be able to start/stop/restart</summary> /// adb. /// If a bridge has already been started, it is directly returned with no changes /// <returns></returns> public static AndroidDebugBridge CreateBridge( ) { if (_instance != null) { return(_instance); } try { _instance = new AndroidDebugBridge( ); _instance.Start( ); _instance.OnBridgeChanged(new AndroidDebugBridgeEventArgs(_instance)); } catch (ArgumentException) { _instance.OnBridgeChanged(new AndroidDebugBridgeEventArgs(null)); _instance = null; } return(_instance); }
public AndroidTestRunner(string jdkLocation, string sdkLocation, string apkLocation) : base() { _apkLocation = apkLocation; _jdkLocation = jdkLocation; _adbLocation = string.Format ("{0}{1}", sdkLocation, "//platform-tools//adb"); _keyTool = string.Format ("{0}{1}", _jdkLocation, "//bin//keytool"); _jarSigner = string.Format ("{0}{1}", _jdkLocation, "//bin//jarsigner"); _adb = AndroidDebugBridge.CreateBridge (_adbLocation, true); _devices = new List<IDevice> (); _androidVersionHelper = new AndroidVersionHelper (sdkLocation); _fingerprintHelper = new FingerprintHelper (_keyTool, _apkLocation); _keystoreHelper = new KeystoreHelper (_keyTool); _apkInstallHelper = new ApkInstallHelper (_adbLocation); _testHelper = new AndroidTestHelper (_adbLocation); BuildToolsVersion buildToolsVersion = _androidVersionHelper.GetHighestBuildToolsVersion (); _aaptLocation = string.Format ("{0}/{1}", buildToolsVersion.Location, "aapt"); _keystores = _keystoreHelper.GetKeystores (); _apkFingerprint = _fingerprintHelper.FingerprintFromApk (); _adb.DeviceConnected += OnDeviceConnected; _adb.DeviceChanged += OnDeviceChanged; _adb.DeviceDisconnected += OnDeviceDisconnected; _adb.Start (); Console.WriteLine ("Checking apk signing..."); if (!CheckFingerprint ()) { Console.WriteLine ("No sign match, re-sign needed"); ResignApk (); } else { Console.WriteLine ("Sign match, no need to re-sign"); } GetPackageName (); Console.WriteLine ("Preparing Test Server"); PrepareTestServer (); CheckDevicesForInstall (); }
/// <summary> /// Creates a new debug bridge from the location of the command line tool. /// </summary> /// <param name="osLocation">the location of the command line tool 'adb'</param> /// <param name="forceNewBridge">force creation of a new bridge even if one with the same location /// already exists.</param> /// <returns>a connected bridge.</returns> /// <remarks>Any existing server will be disconnected, unless the location is the same and /// <code>forceNewBridge</code> is set to false. /// </remarks> public static AndroidDebugBridge CreateBridge( String osLocation, bool forceNewBridge ) { if ( _instance != null ) { if ( !String.IsNullOrEmpty ( AdbOsLocation ) && string.Compare ( AdbOsLocation, osLocation, true ) == 0 && !forceNewBridge ) { return _instance; } else { // stop the current server Log.d (TAG, "Stopping Current Instance" ); _instance.Stop ( ); } } try { _instance = new AndroidDebugBridge ( osLocation ); _instance.Start ( ); _instance.OnBridgeChanged ( new AndroidDebugBridgeEventArgs ( _instance ) ); } catch ( ArgumentException ) { _instance.OnBridgeChanged ( new AndroidDebugBridgeEventArgs ( null ) ); _instance = null; } return _instance; }
/// <summary> /// Creates a {@link AndroidDebugBridge} that is not linked to any particular executable. /// This bridge will expect adb to be running. It will not be able to start/stop/restart</summary> /// adb. /// If a bridge has already been started, it is directly returned with no changes /// <returns></returns> public static AndroidDebugBridge CreateBridge( ) { if ( _instance != null ) { return _instance; } try { _instance = new AndroidDebugBridge ( ); _instance.Start ( ); _instance.OnBridgeChanged ( new AndroidDebugBridgeEventArgs ( _instance ) ); } catch ( ArgumentException ) { _instance.OnBridgeChanged ( new AndroidDebugBridgeEventArgs ( null ) ); _instance = null; } return _instance; }