From 8492673b90d3e41f4d1507e276dfb7eaa5bbc7bd Mon Sep 17 00:00:00 2001 From: Svet Ganov Date: Fri, 28 Oct 2022 23:15:02 -0700 Subject: [PATCH] ShutdownThread: flag off debug logging Debug logging is now statically flagged off to avoid allocations and spamming the log. Test: builds Upstream from Meta. Change-Id: If483840401692f0ad73e60fe1b5932ab606914d2 --- .../android/server/power/ShutdownThread.java | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/services/core/java/com/android/server/power/ShutdownThread.java b/services/core/java/com/android/server/power/ShutdownThread.java index a82d4eaa5b28b..5096ad1faf73a 100644 --- a/services/core/java/com/android/server/power/ShutdownThread.java +++ b/services/core/java/com/android/server/power/ShutdownThread.java @@ -61,6 +61,7 @@ import java.nio.charset.StandardCharsets; public final class ShutdownThread extends Thread { // constants + private static final boolean DEBUG = false; private static final String TAG = "ShutdownThread"; private static final int ACTION_DONE_POLL_WAIT_MS = 500; private static final int RADIOS_STATE_POLL_SLEEP_MS = 100; @@ -161,7 +162,9 @@ public final class ShutdownThread extends Thread { // any additional calls are just returned synchronized (sIsStartedGuard) { if (sIsStarted) { - Log.d(TAG, "Request to shutdown already running, returning."); + if (DEBUG) { + Log.d(TAG, "Request to shutdown already running, returning."); + } return; } } @@ -178,7 +181,9 @@ public final class ShutdownThread extends Thread { ? com.android.internal.R.string.shutdown_confirm_question : com.android.internal.R.string.shutdown_confirm); - Log.d(TAG, "Notifying thread to start shutdown longPressBehavior=" + longPressBehavior); + if (DEBUG) { + Log.d(TAG, "Notifying thread to start shutdown longPressBehavior=" + longPressBehavior); + } if (confirm) { final CloseDialogReceiver closer = new CloseDialogReceiver(context); @@ -348,26 +353,34 @@ public final class ShutdownThread extends Thread { } private static boolean showSysuiReboot() { - Log.d(TAG, "Attempting to use SysUI shutdown UI"); + if (DEBUG) { + Log.d(TAG, "Attempting to use SysUI shutdown UI"); + } try { StatusBarManagerInternal service = LocalServices.getService( StatusBarManagerInternal.class); if (service.showShutdownUi(mReboot, mReason)) { // Sysui will handle shutdown UI. - Log.d(TAG, "SysUI handling shutdown UI"); + if (DEBUG) { + Log.d(TAG, "SysUI handling shutdown UI"); + } return true; } } catch (Exception e) { // If anything went wrong, ignore it and use fallback ui } - Log.d(TAG, "SysUI is unavailable"); + if (DEBUG) { + Log.d(TAG, "SysUI is unavailable"); + } return false; } private static void beginShutdownSequence(Context context) { synchronized (sIsStartedGuard) { if (sIsStarted) { - Log.d(TAG, "Shutdown sequence already running, returning."); + if (DEBUG) { + Log.d(TAG, "Shutdown sequence already running, returning."); + } return; } sIsStarted = true;