Skip to content

Commit

Permalink
Add support for authorizing state
Browse files Browse the repository at this point in the history
  • Loading branch information
bartsaintgermain committed Jan 17, 2019
1 parent a10b1db commit c06fc52
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
16 changes: 16 additions & 0 deletions SharpAdbClient.Tests/DeviceDataTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,22 @@ public void CreateFromDeviceDataVSEmulatorTest()
Assert.Equal(string.Empty, device.Usb);
}

[Fact]
public void CreateFromDeviceDataAuthorizingTest()
{
string data = "52O00ULA01 authorizing usb:9-1.4.1 transport_id:8149";

var device = DeviceData.CreateFromAdbData(data);
Assert.Equal("52O00ULA01", device.Serial);
Assert.Equal(string.Empty, device.Product);
Assert.Equal(string.Empty, device.Model);
Assert.Equal(string.Empty, device.Name);
Assert.Equal(string.Empty, device.Features);
Assert.Equal<DeviceState>(DeviceState.Authorizing, device.State);
Assert.Equal("9-1.4.1", device.Usb);
Assert.Equal("8149", device.TransportId);
}

[Fact]
public void CreateFromDeviceDataUnauthorizedTest()
{
Expand Down
2 changes: 1 addition & 1 deletion SharpAdbClient/DeviceData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class DeviceData
/// A regular expression that can be used to parse the device information that is returned
/// by the Android Debut Bridge.
/// </summary>
internal const string DeviceDataRegexString = @"^(?<serial>[a-zA-Z0-9_-]+(?:\s?[\.a-zA-Z0-9_-]+)?(?:\:\d{1,})?)\s+(?<state>device|connecting|offline|unknown|bootloader|recovery|download|unauthorized|host|no permissions)(\s+usb:(?<usb>[^:]+))?(?:\s+product:(?<product>[^:]+))?(\s+model\:(?<model>[\S]+))?(\s+device\:(?<device>[\S]+))?(\s+features:(?<features>[^:]+))?(\s+transport_id:(?<transport_id>[^:]+))?$";
internal const string DeviceDataRegexString = @"^(?<serial>[a-zA-Z0-9_-]+(?:\s?[\.a-zA-Z0-9_-]+)?(?:\:\d{1,})?)\s+(?<state>device|connecting|offline|unknown|bootloader|recovery|download|authorizing|unauthorized|host|no permissions)(\s+usb:(?<usb>[^:]+))?(?:\s+product:(?<product>[^:]+))?(\s+model\:(?<model>[\S]+))?(\s+device\:(?<device>[\S]+))?(\s+features:(?<features>[^:]+))?(\s+transport_id:(?<transport_id>[^:]+))?$";

/// <summary>
/// A regular expression that can be used to parse the device information that is returned
Expand Down
5 changes: 5 additions & 0 deletions SharpAdbClient/DeviceState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ public enum DeviceState
/// </summary>
Unauthorized,

/// <summary>
/// The device is connected to adb, but adb authorizing for remote debugging of this device.
/// </summary>
Authorizing,

/// <summary>
/// The device state is unknown.
/// </summary>
Expand Down

0 comments on commit c06fc52

Please sign in to comment.