From a9ee641bd6db37593839d270087c9bdd39b14178 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Tue, 13 Oct 2026 19:20:51 +0800 Subject: [PATCH] Display (Android): fixes Android display detection reporting nothing on Android 11 --- src/detection/displayserver/displayserver_android.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/detection/displayserver/displayserver_android.c b/src/detection/displayserver/displayserver_android.c index 7a70ae4c9..c0ff1a8ad 100644 --- a/src/detection/displayserver/displayserver_android.c +++ b/src/detection/displayserver/displayserver_android.c @@ -545,10 +545,18 @@ static bool readerScalar(FFDisplayAndroidReader* reader, const char* type, FFDis } if (ffStrEquals(type, "[I") || ffStrEquals(type, "[F")) { const int32_t count = readerI32(reader); - if (reader->failed || count < 0 || count > 1024) { + if (reader->failed || count > 1024) { reader->failed = true; return false; } + // A negative count is a null array and carries no elements: `writeIntArray(null)` and + // `writeFloatArray(null)` both write a bare -1 where the count would be. Android 11 has one + // of these in the record -- `DeviceProductInfo.mRelativeAddress` is an `[I` there and is null + // on the built-in display. `readerSkipArray` spells the same rule for the arrays it steps + // over, and a null is a value everywhere else in this walk too. + if (count < 0) { + return true; + } value->count = count; return readerSkip(reader, (size_t) count * (ffStrEquals(type, "[I") ? sizeof(int32_t) : sizeof(float))); }