From 4fff058e9f649dd736bfdadb9f65dd3aae2b48a7 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Wed, 21 Oct 2020 13:06:36 -0700 Subject: [PATCH] Allow disabling protolog exceptions Bug: 171417169 Test: Build and make sure protologs still works and sysui gradle project can build as well Change-Id: I29684d8b3b5fc49e8179dc15eac9c37cf706322b --- .../internal/protolog/common/ProtoLog.java | 40 +++++++++++++------ .../android/systemui/SystemUIApplication.java | 3 ++ 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/core/java/com/android/internal/protolog/common/ProtoLog.java b/core/java/com/android/internal/protolog/common/ProtoLog.java index ab58d351d3b91..01cc1ed37ad4c 100644 --- a/core/java/com/android/internal/protolog/common/ProtoLog.java +++ b/core/java/com/android/internal/protolog/common/ProtoLog.java @@ -35,6 +35,10 @@ package com.android.internal.protolog.common; * during build. */ public class ProtoLog { + + // Needs to be set directly otherwise the protologtool tries to transform the method call + public static boolean REQUIRE_PROTOLOGTOOL = true; + /** * DEBUG level log. * @@ -44,8 +48,10 @@ public class ProtoLog { */ public static void d(IProtoLogGroup group, String messageString, Object... args) { // Stub, replaced by the ProtoLogTool. - throw new UnsupportedOperationException( - "ProtoLog calls MUST be processed with ProtoLogTool"); + if (REQUIRE_PROTOLOGTOOL) { + throw new UnsupportedOperationException( + "ProtoLog calls MUST be processed with ProtoLogTool"); + } } /** @@ -57,8 +63,10 @@ public class ProtoLog { */ public static void v(IProtoLogGroup group, String messageString, Object... args) { // Stub, replaced by the ProtoLogTool. - throw new UnsupportedOperationException( - "ProtoLog calls MUST be processed with ProtoLogTool"); + if (REQUIRE_PROTOLOGTOOL) { + throw new UnsupportedOperationException( + "ProtoLog calls MUST be processed with ProtoLogTool"); + } } /** @@ -70,8 +78,10 @@ public class ProtoLog { */ public static void i(IProtoLogGroup group, String messageString, Object... args) { // Stub, replaced by the ProtoLogTool. - throw new UnsupportedOperationException( - "ProtoLog calls MUST be processed with ProtoLogTool"); + if (REQUIRE_PROTOLOGTOOL) { + throw new UnsupportedOperationException( + "ProtoLog calls MUST be processed with ProtoLogTool"); + } } /** @@ -83,8 +93,10 @@ public class ProtoLog { */ public static void w(IProtoLogGroup group, String messageString, Object... args) { // Stub, replaced by the ProtoLogTool. - throw new UnsupportedOperationException( - "ProtoLog calls MUST be processed with ProtoLogTool"); + if (REQUIRE_PROTOLOGTOOL) { + throw new UnsupportedOperationException( + "ProtoLog calls MUST be processed with ProtoLogTool"); + } } /** @@ -96,8 +108,10 @@ public class ProtoLog { */ public static void e(IProtoLogGroup group, String messageString, Object... args) { // Stub, replaced by the ProtoLogTool. - throw new UnsupportedOperationException( - "ProtoLog calls MUST be processed with ProtoLogTool"); + if (REQUIRE_PROTOLOGTOOL) { + throw new UnsupportedOperationException( + "ProtoLog calls MUST be processed with ProtoLogTool"); + } } /** @@ -109,7 +123,9 @@ public class ProtoLog { */ public static void wtf(IProtoLogGroup group, String messageString, Object... args) { // Stub, replaced by the ProtoLogTool. - throw new UnsupportedOperationException( - "ProtoLog calls MUST be processed with ProtoLogTool"); + if (REQUIRE_PROTOLOGTOOL) { + throw new UnsupportedOperationException( + "ProtoLog calls MUST be processed with ProtoLogTool"); + } } } diff --git a/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java b/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java index e709830342b5a..bf42a60ac0339 100644 --- a/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java +++ b/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java @@ -34,6 +34,7 @@ import android.provider.Settings; import android.util.Log; import android.util.TimingsTraceLog; +import com.android.internal.protolog.common.ProtoLog; import com.android.systemui.dagger.ContextComponentHelper; import com.android.systemui.dagger.GlobalRootComponent; import com.android.systemui.dagger.SysUIComponent; @@ -69,6 +70,8 @@ public class SystemUIApplication extends Application implements public SystemUIApplication() { super(); Log.v(TAG, "SystemUIApplication constructed."); + // SysUI may be building without protolog preprocessing in some cases + ProtoLog.REQUIRE_PROTOLOGTOOL = false; } @Override