mirror of
https://github.com/MobileTooling/AndroidDebugBridge.git
synced 2026-07-27 12:48:37 -07:00
57 lines
1.8 KiB
C#
57 lines
1.8 KiB
C#
using System;
|
|
using System.Linq;
|
|
|
|
namespace AndroidDebugBridge
|
|
{
|
|
public partial class AndroidDebugBridgeTransport
|
|
{
|
|
public (string variableName, string variableValue)[]? GetAllVariables()
|
|
{
|
|
if (!IsConnected)
|
|
{
|
|
throw new Exception("Cannot get all variables with no accepted connection!");
|
|
}
|
|
|
|
(string variableName, string variableValue)[]? result = null;
|
|
|
|
try
|
|
{
|
|
string getPropAnswer = Shell("getprop");
|
|
|
|
return getPropAnswer.Split("\n")
|
|
.Where(t =>
|
|
t.Contains(':') &&
|
|
t.Contains('[') &&
|
|
t.Contains(']') &&
|
|
t.Contains("]: ["))
|
|
.Select(t =>
|
|
{
|
|
string[] cleanedUpPart = t.Trim()[1..^1].Split("]: [");
|
|
return (cleanedUpPart[0], string.Join("]: [", cleanedUpPart.Skip(1)));
|
|
})
|
|
.ToArray();
|
|
}
|
|
catch (Exception) { }
|
|
|
|
return result;
|
|
}
|
|
|
|
public string? GetVariableValue(string variableName)
|
|
{
|
|
if (!IsConnected)
|
|
{
|
|
throw new Exception("Cannot get a specific variable with no accepted connection!");
|
|
}
|
|
|
|
string? result = null;
|
|
|
|
try
|
|
{
|
|
result = Shell($"getprop {variableName}").TrimEnd('\u0003').TrimEnd('\n').TrimEnd('\r');
|
|
}
|
|
catch (Exception) { }
|
|
|
|
return result;
|
|
}
|
|
}
|
|
} |