Skip to content

Commit

Permalink
capture device info message (in case of nopermissions)
Browse files Browse the repository at this point in the history
  • Loading branch information
bartsaintgermain committed Feb 1, 2019
1 parent 8f60bb3 commit 1cc96fc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions SharpAdbClient.Tests/DeviceDataTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public void CreateFromDeviceNoPermissionTest2()
Assert.Equal(string.Empty, device.Name);
Assert.Equal(string.Empty, device.Features);
Assert.Equal<DeviceState>(DeviceState.NoPermissions, device.State);
Assert.Equal(" (user in plugdev group; are your udev rules wrong?); see [http://developer.android.com/tools/device.html", device.Message);
Assert.Equal(string.Empty, device.Usb);
Assert.Equal(string.Empty, device.TransportId);
}
Expand Down
14 changes: 12 additions & 2 deletions 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|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>[^:]+))?$";
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)(?<message>.*?)(\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 Expand Up @@ -96,6 +96,15 @@ public string TransportId
set;
}

/// <summary>
/// Gets or sets the device info message. Currently only seen for NoPermissions state.
/// </summary>
public string Message
{
get;
set;
}

/// <summary>
/// Creates a new instance of the <see cref="DeviceData"/> class based on
/// data retrieved from the Android Debug Bridge.
Expand All @@ -120,7 +129,8 @@ public static DeviceData CreateFromAdbData(string data)
Name = m.Groups["device"].Value,
Features = m.Groups["features"].Value,
Usb = m.Groups["usb"].Value,
TransportId = m.Groups["transport_id"].Value
TransportId = m.Groups["transport_id"].Value,
Message = m.Groups["message"].Value
};
}
else
Expand Down

0 comments on commit 1cc96fc

Please sign in to comment.