Skip to content

Commit 8b198fe

Browse files
committed
feat: Add 'quiet' option for RawCommand and GetVar
Introduce a quiet flag to RawCommand and propagate it to GetVar so callers can suppress response handling/logging. RawCommand(string command, bool quiet = false) will return immediately after receiving the response when quiet is true (skipping additional failure handling), and GetVar(key, useCache=true, quiet=false) forwards the flag and updates the debug message. The change also uses quiet=true when checking is-userspace to avoid triggering verbose/failure handling for that probe.
1 parent 52e5506 commit 8b198fe

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

FirmwareKit.Comm.Fastboot/Command/InternalRawCommand.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public partial class FastbootDriver
88
/// <summary>
99
/// Sends the command
1010
/// </summary>
11-
public FastbootResponse RawCommand(string command)
11+
public FastbootResponse RawCommand(string command, bool quiet = false)
1212
{
1313
FastbootDebug.Log("Sending command: " + command);
1414
byte[] cmdBytes = Encoding.UTF8.GetBytes(command);
@@ -39,6 +39,11 @@ public FastbootResponse RawCommand(string command)
3939
var response = HandleResponse();
4040
FastbootDebug.Log("Response received: " + response.Response);
4141

42+
if (quiet)
43+
{
44+
return response;
45+
}
46+
4247
if (response.Result == FastbootState.Fail)
4348
{
4449
if (command.StartsWith("snapshot-update", StringComparison.OrdinalIgnoreCase))

FirmwareKit.Comm.Fastboot/FastbootDriver.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public bool IsUserspace()
4040
try
4141
{
4242
// Always query device directly; cached values can be stale across reboot mode changes.
43-
return GetVar("is-userspace", useCache: false) == "yes";
43+
return GetVar("is-userspace", useCache: false, quiet: true) == "yes";
4444
}
4545
catch
4646
{
@@ -291,11 +291,11 @@ public Dictionary<string, string> GetVarAll()
291291
/// <summary>
292292
/// Gets a single attribute (with caching if enabled)
293293
/// </summary>
294-
public string GetVar(string key, bool useCache = true)
294+
public string GetVar(string key, bool useCache = true, bool quiet = false)
295295
{
296-
FastbootDebug.Log($"GetVar(key={key}, useCache={useCache})");
296+
FastbootDebug.Log($"GetVar(key={key}, useCache={useCache}, quiet={quiet})");
297297
if (useCache && _varCache.TryGetValue(key, out string? cached)) return cached;
298-
var resObj = RawCommand("getvar:" + key);
298+
var resObj = RawCommand("getvar:" + key, quiet);
299299
if (resObj.Result == FastbootState.Fail || resObj.Result == FastbootState.Timeout)
300300
{
301301
// Do not cache transient failures/timeouts; caller can retry later.

0 commit comments

Comments
 (0)