Skip to content
This repository has been archived by the owner on Sep 22, 2022. It is now read-only.

Commit

Permalink
Miscellaneous
Browse files Browse the repository at this point in the history
Color some console prints, clarify what is being started
  • Loading branch information
AtlasTheProto committed Oct 13, 2021
1 parent 8cb7223 commit af8e7c5
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions ADBForwarder/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ internal class Program

private static void Main()
{
Console.ResetColor();
var currentDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
if (currentDirectory == null)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Path error!");
return;
}
Expand Down Expand Up @@ -68,7 +70,7 @@ private static void Main()
SetExecutable(absoluteAdbPath);
}

Console.WriteLine("Starting ADB Daemon...");
Console.WriteLine("Starting ADB Server...");
server.StartServer(absoluteAdbPath, false);

client.Connect(endPoint);
Expand All @@ -87,12 +89,14 @@ private static void Main()

private static void Monitor_DeviceConnected(object sender, DeviceDataEventArgs e)
{
Console.ForegroundColor = ConsoleColor.DarkGreen;
Console.WriteLine($"Connected device: {e.Device.Serial}");
Forward(e.Device);
}

private static void Monitor_DeviceDisconnected(object sender, DeviceDataEventArgs e)
{
Console.ForegroundColor = ConsoleColor.DarkRed;
Console.WriteLine($"Disconnected device: {e.Device.Serial}");
}

Expand All @@ -105,13 +109,15 @@ private static void Forward(DeviceData device)
{
if (!deviceNames.Contains(deviceData.Product))
{
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine($"Skipped forwarding device: {(string.IsNullOrEmpty(deviceData.Product) ? deviceData.Serial : deviceData.Product)}");
return;
}

client.CreateForward(deviceData, 9943, 9943);
client.CreateForward(deviceData, 9944, 9944);


Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine($"Successfully forwarded device: {deviceData.Serial} [{deviceData.Product}]");

return;
Expand Down

0 comments on commit af8e7c5

Please sign in to comment.