diff options
| -rw-r--r-- | core/java/android/content/Context.java | 7 | ||||
| -rw-r--r-- | core/java/com/android/internal/protolog/IProtoLogClient.aidl | 2 | ||||
| -rw-r--r-- | core/java/com/android/internal/protolog/IProtoLogConfigurationService.aidl (renamed from core/java/com/android/internal/protolog/IProtoLogService.aidl) | 2 | ||||
| -rw-r--r-- | core/java/com/android/internal/protolog/PerfettoProtoLogImpl.java | 24 | ||||
| -rw-r--r-- | core/java/com/android/internal/protolog/ProtoLogCommandHandler.java | 25 | ||||
| -rw-r--r-- | core/java/com/android/internal/protolog/ProtoLogConfigurationService.java (renamed from core/java/com/android/internal/protolog/ProtoLogService.java) | 12 | ||||
| -rw-r--r-- | services/java/com/android/server/SystemServer.java | 7 | ||||
| -rw-r--r-- | tests/Internal/src/com/android/internal/protolog/ProtoLogCommandHandlerTest.java | 89 | ||||
| -rw-r--r-- | tests/Internal/src/com/android/internal/protolog/ProtoLogConfigurationServiceTest.java (renamed from tests/Internal/src/com/android/internal/protolog/ProtoLogServiceTest.java) | 70 |
9 files changed, 130 insertions, 108 deletions
diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java index ffcb1cbec94e..9c711bcb1521 100644 --- a/core/java/android/content/Context.java +++ b/core/java/android/content/Context.java @@ -106,6 +106,7 @@ import android.window.WindowContext; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.compat.IPlatformCompat; import com.android.internal.compat.IPlatformCompatNative; +import com.android.internal.protolog.ProtoLogConfigurationService; import java.io.File; import java.io.FileInputStream; @@ -6701,13 +6702,13 @@ public abstract class Context { /** * Use with {@link #getSystemService(String)} to retrieve the - * {@link com.android.internal.protolog.ProtoLogService} for registering ProtoLog clients. + * {@link ProtoLogConfigurationService} for registering ProtoLog clients. * * @see #getSystemService(String) - * @see com.android.internal.protolog.ProtoLogService + * @see ProtoLogConfigurationService * @hide */ - public static final String PROTOLOG_SERVICE = "protolog"; + public static final String PROTOLOG_CONFIGURATION_SERVICE = "protolog_configuration"; /** * Determine whether the given permission is allowed for a particular diff --git a/core/java/com/android/internal/protolog/IProtoLogClient.aidl b/core/java/com/android/internal/protolog/IProtoLogClient.aidl index 969ed99d3aca..64944f42374b 100644 --- a/core/java/com/android/internal/protolog/IProtoLogClient.aidl +++ b/core/java/com/android/internal/protolog/IProtoLogClient.aidl @@ -20,7 +20,7 @@ package com.android.internal.protolog; * The ProtoLog client interface. * * These clients will communicate bi-directionally with the ProtoLog service - * (@see IProtoLogService.aidl) running in the system process. + * (@see IProtoLogConfigurationService.aidl) running in the system process. * * {@hide} */ diff --git a/core/java/com/android/internal/protolog/IProtoLogService.aidl b/core/java/com/android/internal/protolog/IProtoLogConfigurationService.aidl index cc349ea2985a..ce948281bbd6 100644 --- a/core/java/com/android/internal/protolog/IProtoLogService.aidl +++ b/core/java/com/android/internal/protolog/IProtoLogConfigurationService.aidl @@ -40,7 +40,7 @@ import com.android.internal.protolog.IProtoLogClient; * * {@hide} */ -interface IProtoLogService { +interface IProtoLogConfigurationService { interface IRegisterClientArgs { String[] getGroups(); boolean[] getGroupsDefaultLogcatStatus(); diff --git a/core/java/com/android/internal/protolog/PerfettoProtoLogImpl.java b/core/java/com/android/internal/protolog/PerfettoProtoLogImpl.java index 49ed55dbdb9f..740a5e168581 100644 --- a/core/java/com/android/internal/protolog/PerfettoProtoLogImpl.java +++ b/core/java/com/android/internal/protolog/PerfettoProtoLogImpl.java @@ -16,7 +16,7 @@ package com.android.internal.protolog; -import static android.content.Context.PROTOLOG_SERVICE; +import static android.content.Context.PROTOLOG_CONFIGURATION_SERVICE; import static android.internal.perfetto.protos.InternedDataOuterClass.InternedData.PROTOLOG_STACKTRACE; import static android.internal.perfetto.protos.InternedDataOuterClass.InternedData.PROTOLOG_STRING_ARGS; import static android.internal.perfetto.protos.ProfileCommon.InternedString.IID; @@ -114,7 +114,7 @@ public class PerfettoProtoLogImpl extends IProtoLogClient.Stub implements IProto private final Runnable mCacheUpdater; @Nullable // null when the flag android.tracing.client_side_proto_logging is not flipped - private final IProtoLogService mProtoLogService; + private final IProtoLogConfigurationService mProtoLogConfigurationService; @NonNull private final int[] mDefaultLogLevelCounts = new int[LogLevel.values().length]; @@ -186,30 +186,32 @@ public class PerfettoProtoLogImpl extends IProtoLogClient.Stub implements IProto registerGroupsLocally(groups); if (android.tracing.Flags.clientSideProtoLogging()) { - mProtoLogService = - IProtoLogService.Stub.asInterface(ServiceManager.getService(PROTOLOG_SERVICE)); - Objects.requireNonNull(mProtoLogService, + mProtoLogConfigurationService = + IProtoLogConfigurationService.Stub.asInterface(ServiceManager.getService( + PROTOLOG_CONFIGURATION_SERVICE)); + Objects.requireNonNull(mProtoLogConfigurationService, "ServiceManager returned a null ProtoLog service"); try { - var args = new ProtoLogService.RegisterClientArgs(); + var args = new ProtoLogConfigurationService.RegisterClientArgs(); if (viewerConfigFilePath != null) { args.setViewerConfigFile(viewerConfigFilePath); } final var groupArgs = Stream.of(groups) - .map(group -> new ProtoLogService.RegisterClientArgs.GroupConfig( - group.name(), group.isLogToLogcat())) - .toArray(ProtoLogService.RegisterClientArgs.GroupConfig[]::new); + .map(group -> new ProtoLogConfigurationService.RegisterClientArgs + .GroupConfig(group.name(), group.isLogToLogcat())) + .toArray( + ProtoLogConfigurationService.RegisterClientArgs.GroupConfig[]::new); args.setGroups(groupArgs); - mProtoLogService.registerClient(this, args); + mProtoLogConfigurationService.registerClient(this, args); } catch (RemoteException e) { throw new RuntimeException("Failed to register ProtoLog client"); } } else { - mProtoLogService = null; + mProtoLogConfigurationService = null; } } diff --git a/core/java/com/android/internal/protolog/ProtoLogCommandHandler.java b/core/java/com/android/internal/protolog/ProtoLogCommandHandler.java index 3dab2e39b852..82d8d3431a9d 100644 --- a/core/java/com/android/internal/protolog/ProtoLogCommandHandler.java +++ b/core/java/com/android/internal/protolog/ProtoLogCommandHandler.java @@ -29,18 +29,20 @@ import java.util.Set; public class ProtoLogCommandHandler extends ShellCommand { @NonNull - private final ProtoLogService mProtoLogService; + private final ProtoLogConfigurationService mProtoLogConfigurationService; @Nullable private final PrintWriter mPrintWriter; - public ProtoLogCommandHandler(@NonNull ProtoLogService protoLogService) { - this(protoLogService, null); + public ProtoLogCommandHandler( + @NonNull ProtoLogConfigurationService protoLogConfigurationService) { + this(protoLogConfigurationService, null); } @VisibleForTesting public ProtoLogCommandHandler( - @NonNull ProtoLogService protoLogService, @Nullable PrintWriter printWriter) { - this.mProtoLogService = protoLogService; + @NonNull ProtoLogConfigurationService protoLogConfigurationService, + @Nullable PrintWriter printWriter) { + this.mProtoLogConfigurationService = protoLogConfigurationService; this.mPrintWriter = printWriter; } @@ -94,7 +96,7 @@ public class ProtoLogCommandHandler extends ShellCommand { switch (cmd) { case "list": { - final String[] availableGroups = mProtoLogService.getGroups(); + final String[] availableGroups = mProtoLogConfigurationService.getGroups(); if (availableGroups.length == 0) { pw.println("No ProtoLog groups registered with ProtoLog service."); return 0; @@ -117,12 +119,13 @@ public class ProtoLogCommandHandler extends ShellCommand { pw.println("ProtoLog group " + group + "'s status:"); - if (!Set.of(mProtoLogService.getGroups()).contains(group)) { + if (!Set.of(mProtoLogConfigurationService.getGroups()).contains(group)) { pw.println("UNREGISTERED"); return 0; } - pw.println("LOG_TO_LOGCAT = " + mProtoLogService.isLoggingToLogcat(group)); + pw.println("LOG_TO_LOGCAT = " + + mProtoLogConfigurationService.isLoggingToLogcat(group)); return 0; } default: { @@ -142,11 +145,11 @@ public class ProtoLogCommandHandler extends ShellCommand { switch (cmd) { case "enable" -> { - mProtoLogService.enableProtoLogToLogcat(processGroups()); + mProtoLogConfigurationService.enableProtoLogToLogcat(processGroups()); return 0; } case "disable" -> { - mProtoLogService.disableProtoLogToLogcat(processGroups()); + mProtoLogConfigurationService.disableProtoLogToLogcat(processGroups()); return 0; } default -> { @@ -159,7 +162,7 @@ public class ProtoLogCommandHandler extends ShellCommand { @NonNull private String[] processGroups() { if (getRemainingArgsCount() == 0) { - return mProtoLogService.getGroups(); + return mProtoLogConfigurationService.getGroups(); } final List<String> groups = new ArrayList<>(); diff --git a/core/java/com/android/internal/protolog/ProtoLogService.java b/core/java/com/android/internal/protolog/ProtoLogConfigurationService.java index 2333a062d897..176573870679 100644 --- a/core/java/com/android/internal/protolog/ProtoLogService.java +++ b/core/java/com/android/internal/protolog/ProtoLogConfigurationService.java @@ -70,9 +70,9 @@ import java.util.TreeMap; * <p> * This service is intended to run on the system server, such that it never gets frozen. */ -@SystemService(Context.PROTOLOG_SERVICE) -public final class ProtoLogService extends IProtoLogService.Stub { - private static final String LOG_TAG = "ProtoLogService"; +@SystemService(Context.PROTOLOG_CONFIGURATION_SERVICE) +public final class ProtoLogConfigurationService extends IProtoLogConfigurationService.Stub { + private static final String LOG_TAG = "ProtoLogConfigurationService"; private final ProtoLogDataSource mDataSource = new ProtoLogDataSource( this::onTracingInstanceStart, @@ -114,12 +114,12 @@ public final class ProtoLogService extends IProtoLogService.Stub { private final ViewerConfigFileTracer mViewerConfigFileTracer; - public ProtoLogService() { - this(ProtoLogService::dumpTransitionTraceConfig); + public ProtoLogConfigurationService() { + this(ProtoLogConfigurationService::dumpTransitionTraceConfig); } @VisibleForTesting - public ProtoLogService(@NonNull ViewerConfigFileTracer tracer) { + public ProtoLogConfigurationService(@NonNull ViewerConfigFileTracer tracer) { // Initialize the Perfetto producer and register the Perfetto ProtoLog datasource to be // receive the lifecycle callbacks of the datasource and write the viewer configs if and // when required to the datasource. diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java index 09c54cb40373..37e7cfc6ef98 100644 --- a/services/java/com/android/server/SystemServer.java +++ b/services/java/com/android/server/SystemServer.java @@ -106,7 +106,7 @@ import com.android.internal.notification.SystemNotificationChannels; import com.android.internal.os.BinderInternal; import com.android.internal.os.RuntimeInit; import com.android.internal.policy.AttributeCache; -import com.android.internal.protolog.ProtoLogService; +import com.android.internal.protolog.ProtoLogConfigurationService; import com.android.internal.util.ConcurrentUtils; import com.android.internal.util.EmergencyAffordanceManager; import com.android.internal.util.FrameworkStatsLog; @@ -1092,8 +1092,9 @@ public final class SystemServer implements Dumpable { // Orchestrates some ProtoLogging functionality. if (android.tracing.Flags.clientSideProtoLogging()) { - t.traceBegin("StartProtoLogService"); - ServiceManager.addService(Context.PROTOLOG_SERVICE, new ProtoLogService()); + t.traceBegin("StartProtoLogConfigurationService"); + ServiceManager.addService( + Context.PROTOLOG_CONFIGURATION_SERVICE, new ProtoLogConfigurationService()); t.traceEnd(); } diff --git a/tests/Internal/src/com/android/internal/protolog/ProtoLogCommandHandlerTest.java b/tests/Internal/src/com/android/internal/protolog/ProtoLogCommandHandlerTest.java index e3ec62d5b5a6..aba6722c0813 100644 --- a/tests/Internal/src/com/android/internal/protolog/ProtoLogCommandHandlerTest.java +++ b/tests/Internal/src/com/android/internal/protolog/ProtoLogCommandHandlerTest.java @@ -41,14 +41,14 @@ import java.io.PrintWriter; public class ProtoLogCommandHandlerTest { @Mock - ProtoLogService mProtoLogService; + ProtoLogConfigurationService mProtoLogConfigurationService; @Mock PrintWriter mPrintWriter; @Test public void printsHelpForAllAvailableCommands() { final ProtoLogCommandHandler cmdHandler = - new ProtoLogCommandHandler(mProtoLogService, mPrintWriter); + new ProtoLogCommandHandler(mProtoLogConfigurationService, mPrintWriter); cmdHandler.onHelp(); validateOnHelpPrinted(); @@ -57,7 +57,7 @@ public class ProtoLogCommandHandlerTest { @Test public void printsHelpIfCommandIsNull() { final ProtoLogCommandHandler cmdHandler = - new ProtoLogCommandHandler(mProtoLogService, mPrintWriter); + new ProtoLogCommandHandler(mProtoLogConfigurationService, mPrintWriter); cmdHandler.onCommand(null); validateOnHelpPrinted(); @@ -65,13 +65,13 @@ public class ProtoLogCommandHandlerTest { @Test public void handlesGroupListCommand() { - Mockito.when(mProtoLogService.getGroups()) + Mockito.when(mProtoLogConfigurationService.getGroups()) .thenReturn(new String[] {"MY_TEST_GROUP", "MY_OTHER_GROUP"}); final ProtoLogCommandHandler cmdHandler = - new ProtoLogCommandHandler(mProtoLogService, mPrintWriter); + new ProtoLogCommandHandler(mProtoLogConfigurationService, mPrintWriter); - cmdHandler.exec(mProtoLogService, FileDescriptor.in, FileDescriptor.out, FileDescriptor.err, - new String[] { "groups", "list" }); + cmdHandler.exec(mProtoLogConfigurationService, FileDescriptor.in, FileDescriptor.out, + FileDescriptor.err, new String[] { "groups", "list" }); Mockito.verify(mPrintWriter, times(1)) .println(contains("MY_TEST_GROUP")); @@ -82,10 +82,10 @@ public class ProtoLogCommandHandlerTest { @Test public void handlesIncompleteGroupsCommand() { final ProtoLogCommandHandler cmdHandler = - new ProtoLogCommandHandler(mProtoLogService, mPrintWriter); + new ProtoLogCommandHandler(mProtoLogConfigurationService, mPrintWriter); - cmdHandler.exec(mProtoLogService, FileDescriptor.in, FileDescriptor.out, FileDescriptor.err, - new String[] { "groups" }); + cmdHandler.exec(mProtoLogConfigurationService, FileDescriptor.in, FileDescriptor.out, + FileDescriptor.err, new String[] { "groups" }); Mockito.verify(mPrintWriter, times(1)) .println(contains("Incomplete command")); @@ -93,13 +93,14 @@ public class ProtoLogCommandHandlerTest { @Test public void handlesGroupStatusCommand() { - Mockito.when(mProtoLogService.getGroups()).thenReturn(new String[] {"MY_GROUP"}); - Mockito.when(mProtoLogService.isLoggingToLogcat("MY_GROUP")).thenReturn(true); + Mockito.when(mProtoLogConfigurationService.getGroups()) + .thenReturn(new String[] {"MY_GROUP"}); + Mockito.when(mProtoLogConfigurationService.isLoggingToLogcat("MY_GROUP")).thenReturn(true); final ProtoLogCommandHandler cmdHandler = - new ProtoLogCommandHandler(mProtoLogService, mPrintWriter); + new ProtoLogCommandHandler(mProtoLogConfigurationService, mPrintWriter); - cmdHandler.exec(mProtoLogService, FileDescriptor.in, FileDescriptor.out, FileDescriptor.err, - new String[] { "groups", "status", "MY_GROUP" }); + cmdHandler.exec(mProtoLogConfigurationService, FileDescriptor.in, FileDescriptor.out, + FileDescriptor.err, new String[] { "groups", "status", "MY_GROUP" }); Mockito.verify(mPrintWriter, times(1)) .println(contains("MY_GROUP")); @@ -109,12 +110,12 @@ public class ProtoLogCommandHandlerTest { @Test public void handlesGroupStatusCommandOfUnregisteredGroups() { - Mockito.when(mProtoLogService.getGroups()).thenReturn(new String[] {}); + Mockito.when(mProtoLogConfigurationService.getGroups()).thenReturn(new String[] {}); final ProtoLogCommandHandler cmdHandler = - new ProtoLogCommandHandler(mProtoLogService, mPrintWriter); + new ProtoLogCommandHandler(mProtoLogConfigurationService, mPrintWriter); - cmdHandler.exec(mProtoLogService, FileDescriptor.in, FileDescriptor.out, FileDescriptor.err, - new String[] { "groups", "status", "MY_GROUP" }); + cmdHandler.exec(mProtoLogConfigurationService, FileDescriptor.in, FileDescriptor.out, + FileDescriptor.err, new String[] { "groups", "status", "MY_GROUP" }); Mockito.verify(mPrintWriter, times(1)) .println(contains("MY_GROUP")); @@ -125,10 +126,10 @@ public class ProtoLogCommandHandlerTest { @Test public void handlesGroupStatusCommandWithNoGroups() { final ProtoLogCommandHandler cmdHandler = - new ProtoLogCommandHandler(mProtoLogService, mPrintWriter); + new ProtoLogCommandHandler(mProtoLogConfigurationService, mPrintWriter); - cmdHandler.exec(mProtoLogService, FileDescriptor.in, FileDescriptor.out, FileDescriptor.err, - new String[] { "groups", "status" }); + cmdHandler.exec(mProtoLogConfigurationService, FileDescriptor.in, FileDescriptor.out, + FileDescriptor.err, new String[] { "groups", "status" }); Mockito.verify(mPrintWriter, times(1)) .println(contains("Incomplete command")); @@ -137,10 +138,10 @@ public class ProtoLogCommandHandlerTest { @Test public void handlesIncompleteLogcatCommand() { final ProtoLogCommandHandler cmdHandler = - new ProtoLogCommandHandler(mProtoLogService, mPrintWriter); + new ProtoLogCommandHandler(mProtoLogConfigurationService, mPrintWriter); - cmdHandler.exec(mProtoLogService, FileDescriptor.in, FileDescriptor.out, FileDescriptor.err, - new String[] { "logcat" }); + cmdHandler.exec(mProtoLogConfigurationService, FileDescriptor.in, FileDescriptor.out, + FileDescriptor.err, new String[] { "logcat" }); Mockito.verify(mPrintWriter, times(1)) .println(contains("Incomplete command")); @@ -149,50 +150,52 @@ public class ProtoLogCommandHandlerTest { @Test public void handlesLogcatEnableCommand() { final ProtoLogCommandHandler cmdHandler = - new ProtoLogCommandHandler(mProtoLogService, mPrintWriter); + new ProtoLogCommandHandler(mProtoLogConfigurationService, mPrintWriter); - cmdHandler.exec(mProtoLogService, FileDescriptor.in, FileDescriptor.out, FileDescriptor.err, - new String[] { "logcat", "enable", "MY_GROUP" }); - Mockito.verify(mProtoLogService).enableProtoLogToLogcat("MY_GROUP"); + cmdHandler.exec(mProtoLogConfigurationService, FileDescriptor.in, FileDescriptor.out, + FileDescriptor.err, new String[] { "logcat", "enable", "MY_GROUP" }); + Mockito.verify(mProtoLogConfigurationService).enableProtoLogToLogcat("MY_GROUP"); - cmdHandler.exec(mProtoLogService, FileDescriptor.in, FileDescriptor.out, FileDescriptor.err, + cmdHandler.exec(mProtoLogConfigurationService, FileDescriptor.in, FileDescriptor.out, + FileDescriptor.err, new String[] { "logcat", "enable", "MY_GROUP", "MY_OTHER_GROUP" }); - Mockito.verify(mProtoLogService) + Mockito.verify(mProtoLogConfigurationService) .enableProtoLogToLogcat("MY_GROUP", "MY_OTHER_GROUP"); } @Test public void handlesLogcatDisableCommand() { final ProtoLogCommandHandler cmdHandler = - new ProtoLogCommandHandler(mProtoLogService, mPrintWriter); + new ProtoLogCommandHandler(mProtoLogConfigurationService, mPrintWriter); - cmdHandler.exec(mProtoLogService, FileDescriptor.in, FileDescriptor.out, FileDescriptor.err, - new String[] { "logcat", "disable", "MY_GROUP" }); - Mockito.verify(mProtoLogService).disableProtoLogToLogcat("MY_GROUP"); + cmdHandler.exec(mProtoLogConfigurationService, FileDescriptor.in, FileDescriptor.out, + FileDescriptor.err, new String[] { "logcat", "disable", "MY_GROUP" }); + Mockito.verify(mProtoLogConfigurationService).disableProtoLogToLogcat("MY_GROUP"); - cmdHandler.exec(mProtoLogService, FileDescriptor.in, FileDescriptor.out, FileDescriptor.err, + cmdHandler.exec(mProtoLogConfigurationService, FileDescriptor.in, FileDescriptor.out, + FileDescriptor.err, new String[] { "logcat", "disable", "MY_GROUP", "MY_OTHER_GROUP" }); - Mockito.verify(mProtoLogService) + Mockito.verify(mProtoLogConfigurationService) .disableProtoLogToLogcat("MY_GROUP", "MY_OTHER_GROUP"); } @Test public void handlesLogcatEnableCommandWithNoGroups() { final ProtoLogCommandHandler cmdHandler = - new ProtoLogCommandHandler(mProtoLogService, mPrintWriter); + new ProtoLogCommandHandler(mProtoLogConfigurationService, mPrintWriter); - cmdHandler.exec(mProtoLogService, FileDescriptor.in, FileDescriptor.out, FileDescriptor.err, - new String[] { "logcat", "enable" }); + cmdHandler.exec(mProtoLogConfigurationService, FileDescriptor.in, FileDescriptor.out, + FileDescriptor.err, new String[] { "logcat", "enable" }); Mockito.verify(mPrintWriter).println(contains("Incomplete command")); } @Test public void handlesLogcatDisableCommandWithNoGroups() { final ProtoLogCommandHandler cmdHandler = - new ProtoLogCommandHandler(mProtoLogService, mPrintWriter); + new ProtoLogCommandHandler(mProtoLogConfigurationService, mPrintWriter); - cmdHandler.exec(mProtoLogService, FileDescriptor.in, FileDescriptor.out, FileDescriptor.err, - new String[] { "logcat", "disable" }); + cmdHandler.exec(mProtoLogConfigurationService, FileDescriptor.in, FileDescriptor.out, + FileDescriptor.err, new String[] { "logcat", "disable" }); Mockito.verify(mPrintWriter).println(contains("Incomplete command")); } diff --git a/tests/Internal/src/com/android/internal/protolog/ProtoLogServiceTest.java b/tests/Internal/src/com/android/internal/protolog/ProtoLogConfigurationServiceTest.java index feac59c702ea..e1bdd777dc5f 100644 --- a/tests/Internal/src/com/android/internal/protolog/ProtoLogServiceTest.java +++ b/tests/Internal/src/com/android/internal/protolog/ProtoLogConfigurationServiceTest.java @@ -67,7 +67,7 @@ import java.util.List; */ @Presubmit @RunWith(MockitoJUnitRunner.class) -public class ProtoLogServiceTest { +public class ProtoLogConfigurationServiceTest { private static final String TEST_GROUP = "MY_TEST_GROUP"; private static final String OTHER_TEST_GROUP = "MY_OTHER_TEST_GROUP"; @@ -128,7 +128,7 @@ public class ProtoLogServiceTest { private File mViewerConfigFile; - public ProtoLogServiceTest() throws IOException { + public ProtoLogConfigurationServiceTest() throws IOException { } @Before @@ -150,10 +150,12 @@ public class ProtoLogServiceTest { @Test public void canRegisterClientWithGroupsOnly() throws RemoteException { - final ProtoLogService service = new ProtoLogService(); + final ProtoLogConfigurationService service = new ProtoLogConfigurationService(); - final ProtoLogService.RegisterClientArgs args = new ProtoLogService.RegisterClientArgs() - .setGroups(new ProtoLogService.RegisterClientArgs.GroupConfig(TEST_GROUP, true)); + final ProtoLogConfigurationService.RegisterClientArgs args = + new ProtoLogConfigurationService.RegisterClientArgs() + .setGroups(new ProtoLogConfigurationService.RegisterClientArgs + .GroupConfig(TEST_GROUP, true)); service.registerClient(mMockClient, args); Truth.assertThat(service.isLoggingToLogcat(TEST_GROUP)).isTrue(); @@ -163,11 +165,13 @@ public class ProtoLogServiceTest { @Test public void willDumpViewerConfigOnlyOnceOnTraceStop() throws RemoteException, InvalidProtocolBufferException { - final ProtoLogService service = new ProtoLogService(); + final ProtoLogConfigurationService service = new ProtoLogConfigurationService(); - final ProtoLogService.RegisterClientArgs args = new ProtoLogService.RegisterClientArgs() - .setGroups(new ProtoLogService.RegisterClientArgs.GroupConfig(TEST_GROUP, true)) - .setViewerConfigFile(mViewerConfigFile.getAbsolutePath()); + final ProtoLogConfigurationService.RegisterClientArgs args = + new ProtoLogConfigurationService.RegisterClientArgs() + .setGroups(new ProtoLogConfigurationService.RegisterClientArgs + .GroupConfig(TEST_GROUP, true)) + .setViewerConfigFile(mViewerConfigFile.getAbsolutePath()); service.registerClient(mMockClient, args); service.registerClient(mSecondMockClient, args); @@ -196,14 +200,15 @@ public class ProtoLogServiceTest { @Test public void willDumpViewerConfigOnLastClientDisconnected() throws RemoteException, FileNotFoundException { - final ProtoLogService.ViewerConfigFileTracer tracer = - Mockito.mock(ProtoLogService.ViewerConfigFileTracer.class); - final ProtoLogService service = new ProtoLogService(tracer); - - final ProtoLogService.RegisterClientArgs args = new ProtoLogService.RegisterClientArgs() - .setGroups(new ProtoLogService.RegisterClientArgs.GroupConfig( - TEST_GROUP, true)) - .setViewerConfigFile(mViewerConfigFile.getAbsolutePath()); + final ProtoLogConfigurationService.ViewerConfigFileTracer tracer = + Mockito.mock(ProtoLogConfigurationService.ViewerConfigFileTracer.class); + final ProtoLogConfigurationService service = new ProtoLogConfigurationService(tracer); + + final ProtoLogConfigurationService.RegisterClientArgs args = + new ProtoLogConfigurationService.RegisterClientArgs() + .setGroups(new ProtoLogConfigurationService.RegisterClientArgs + .GroupConfig(TEST_GROUP, true)) + .setViewerConfigFile(mViewerConfigFile.getAbsolutePath()); service.registerClient(mMockClient, args); service.registerClient(mSecondMockClient, args); @@ -220,10 +225,11 @@ public class ProtoLogServiceTest { @Test public void sendEnableLoggingToLogcatToClient() throws RemoteException { - final var service = new ProtoLogService(); + final var service = new ProtoLogConfigurationService(); - final var args = new ProtoLogService.RegisterClientArgs() - .setGroups(new ProtoLogService.RegisterClientArgs.GroupConfig(TEST_GROUP, false)); + final var args = new ProtoLogConfigurationService.RegisterClientArgs() + .setGroups(new ProtoLogConfigurationService.RegisterClientArgs + .GroupConfig(TEST_GROUP, false)); service.registerClient(mMockClient, args); Truth.assertThat(service.isLoggingToLogcat(TEST_GROUP)).isFalse(); @@ -236,10 +242,12 @@ public class ProtoLogServiceTest { @Test public void sendDisableLoggingToLogcatToClient() throws RemoteException { - final ProtoLogService service = new ProtoLogService(); + final ProtoLogConfigurationService service = new ProtoLogConfigurationService(); - final ProtoLogService.RegisterClientArgs args = new ProtoLogService.RegisterClientArgs() - .setGroups(new ProtoLogService.RegisterClientArgs.GroupConfig(TEST_GROUP, true)); + final ProtoLogConfigurationService.RegisterClientArgs args = + new ProtoLogConfigurationService.RegisterClientArgs() + .setGroups(new ProtoLogConfigurationService.RegisterClientArgs + .GroupConfig(TEST_GROUP, true)); service.registerClient(mMockClient, args); Truth.assertThat(service.isLoggingToLogcat(TEST_GROUP)).isTrue(); @@ -252,10 +260,12 @@ public class ProtoLogServiceTest { @Test public void doNotSendLoggingToLogcatToClientWithoutRegisteredGroup() throws RemoteException { - final ProtoLogService service = new ProtoLogService(); + final ProtoLogConfigurationService service = new ProtoLogConfigurationService(); - final ProtoLogService.RegisterClientArgs args = new ProtoLogService.RegisterClientArgs() - .setGroups(new ProtoLogService.RegisterClientArgs.GroupConfig(TEST_GROUP, false)); + final ProtoLogConfigurationService.RegisterClientArgs args = + new ProtoLogConfigurationService.RegisterClientArgs() + .setGroups(new ProtoLogConfigurationService.RegisterClientArgs + .GroupConfig(TEST_GROUP, false)); service.registerClient(mMockClient, args); Truth.assertThat(service.isLoggingToLogcat(TEST_GROUP)).isFalse(); @@ -267,14 +277,16 @@ public class ProtoLogServiceTest { @Test public void handlesToggleToLogcatBeforeClientIsRegistered() throws RemoteException { - final ProtoLogService service = new ProtoLogService(); + final ProtoLogConfigurationService service = new ProtoLogConfigurationService(); Truth.assertThat(service.getGroups()).asList().doesNotContain(TEST_GROUP); service.enableProtoLogToLogcat(TEST_GROUP); Truth.assertThat(service.isLoggingToLogcat(TEST_GROUP)).isTrue(); - final ProtoLogService.RegisterClientArgs args = new ProtoLogService.RegisterClientArgs() - .setGroups(new ProtoLogService.RegisterClientArgs.GroupConfig(TEST_GROUP, false)); + final ProtoLogConfigurationService.RegisterClientArgs args = + new ProtoLogConfigurationService.RegisterClientArgs() + .setGroups(new ProtoLogConfigurationService.RegisterClientArgs + .GroupConfig(TEST_GROUP, false)); service.registerClient(mMockClient, args); Mockito.verify(mMockClient).toggleLogcat(eq(true), |