From 282b7be3c64d3665c83e0d84c84d5c93008b2e97 Mon Sep 17 00:00:00 2001 From: Remi NGUYEN VAN Date: Mon, 25 Nov 2024 12:39:55 +0900 Subject: [PATCH] Fix setup on devices without printflags Instead of running printflags directly, which on devices that do not have the binary hangs indefinitely, run "sh -c printflags". printflags is in the default base_system.mk but some OEMs may strip it out. sh is much less likely to be removed. Bug: 379183423 Test: atest Change-Id: I66af42b2cfbf5cb427c740ef710d8eb3d1d7f1ef --- .../connectivitypreparer/CarrierConfigSetupTest.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/staticlibs/testutils/app/connectivitychecker/src/com/android/testutils/connectivitypreparer/CarrierConfigSetupTest.kt b/staticlibs/testutils/app/connectivitychecker/src/com/android/testutils/connectivitypreparer/CarrierConfigSetupTest.kt index 46e511e1de..78b34a8121 100644 --- a/staticlibs/testutils/app/connectivitychecker/src/com/android/testutils/connectivitypreparer/CarrierConfigSetupTest.kt +++ b/staticlibs/testutils/app/connectivitychecker/src/com/android/testutils/connectivitypreparer/CarrierConfigSetupTest.kt @@ -123,7 +123,13 @@ class CarrierConfigSetupTest { """telephony/com\.android\.internal\.telephony\.flags\.force_iwlan_mms:""" + """.*ENABLED \(system\)""") ParcelFileDescriptor.AutoCloseInputStream( - uiAutomation.executeShellCommand("printflags")).bufferedReader().use { reader -> + // If the command fails (for example if printflags is missing) this will return false + // and the IWLAN disable will be skipped, which should be fine at it only helps with + // flakiness. + // This uses "sh -c" to cover that case as if "printflags" is used directly and the + // binary is missing, the remote end will crash and the InputStream EOF is never + // reached, so the read would hang. + uiAutomation.executeShellCommand("sh -c printflags")).bufferedReader().use { reader -> return reader.lines().anyMatch { it.contains(flagEnabledRegex) }