Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4adbfba1 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes I110ce281,I3e1d2c73 into main

* changes:
  Inject mock ProtoLogConfigurationService in Input Method Manager Service tests
  Make the `RegisterClientArgs` a `parcelable` instead of an `interface`
parents 974aea57 9374ca11
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -40,12 +40,12 @@ import com.android.internal.protolog.IProtoLogClient;
 *
 * {@hide}
 */
oneway interface IProtoLogConfigurationService {
    interface IRegisterClientArgs {
        String[] getGroups();
        boolean[] getGroupsDefaultLogcatStatus();
        String getViewerConfigFile();
interface IProtoLogConfigurationService {
    parcelable RegisterClientArgs {
        String[] groups;
        boolean[] groupsDefaultLogcatStatus;
        String viewerConfigFile;
    }

    void registerClient(IProtoLogClient client, IRegisterClientArgs args);
    oneway void registerClient(IProtoLogClient client, in RegisterClientArgs args);
}
 No newline at end of file
+10 −6
Original line number Diff line number Diff line
@@ -62,7 +62,7 @@ import android.util.Slog;
import android.util.proto.ProtoOutputStream;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.protolog.ProtoLogConfigurationServiceImpl.RegisterClientArgs;
import com.android.internal.protolog.IProtoLogConfigurationService.RegisterClientArgs;
import com.android.internal.protolog.common.ILogger;
import com.android.internal.protolog.common.IProtoLog;
import com.android.internal.protolog.common.IProtoLogGroup;
@@ -164,11 +164,15 @@ public abstract class PerfettoProtoLogImpl extends IProtoLogClient.Stub implemen
            try {
                var args = createConfigurationServiceRegisterClientArgs();

                final var groupArgs = mLogGroups.values().stream()
                        .map(group -> new RegisterClientArgs
                                .GroupConfig(group.name(), group.isLogToLogcat()))
                        .toArray(RegisterClientArgs.GroupConfig[]::new);
                args.setGroups(groupArgs);
                args.groups = new String[mLogGroups.size()];
                args.groupsDefaultLogcatStatus = new boolean[mLogGroups.size()];

                var groups = mLogGroups.values().stream().toList();
                for (var i = 0; i < groups.size(); i++) {
                    var group = groups.get(i);
                    args.groups[i] = group.name();
                    args.groupsDefaultLogcatStatus[i] = group.isLogToLogcat();
                }

                mConfigurationService.registerClient(this, args);
            } catch (RemoteException e) {
+4 −3
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ import android.os.ServiceManager;
import android.util.Log;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.protolog.ProtoLogConfigurationServiceImpl.RegisterClientArgs;
import com.android.internal.protolog.IProtoLogConfigurationService.RegisterClientArgs;
import com.android.internal.protolog.common.ILogger;
import com.android.internal.protolog.common.IProtoLogGroup;

@@ -104,8 +104,9 @@ public class ProcessedPerfettoProtoLogImpl extends PerfettoProtoLogImpl {
    @NonNull
    @Override
    protected RegisterClientArgs createConfigurationServiceRegisterClientArgs() {
        return new RegisterClientArgs()
                .setViewerConfigFile(mViewerConfigFilePath);
        var args = new RegisterClientArgs();
        args.viewerConfigFile = mViewerConfigFilePath;
        return args;
    }

    /**
+3 −71
Original line number Diff line number Diff line
@@ -134,74 +134,6 @@ public class ProtoLogConfigurationServiceImpl extends IProtoLogConfigurationServ
        mDataSource = datasource;
    }

    public static class RegisterClientArgs extends IRegisterClientArgs.Stub {
        /**
         * The viewer config file to be registered for this client ProtoLog process.
         */
        @Nullable
        private String mViewerConfigFile = null;
        /**
         * The list of all groups that this client protolog process supports and might trace.
         */
        @NonNull
        private String[] mGroups = new String[0];
        /**
         * The default logcat status of the ProtoLog client. True is logging to logcat, false
         * otherwise. The indices should match the indices in {@link mGroups}.
         */
        @NonNull
        private boolean[] mLogcatStatus = new boolean[0];

        public record GroupConfig(@NonNull String group, boolean logToLogcat) {}

        /**
         * Specify groups to register with this client that will be used for protologging in this
         * process.
         * @param groups to register with this client.
         * @return self
         */
        public RegisterClientArgs setGroups(GroupConfig... groups) {
            mGroups = new String[groups.length];
            mLogcatStatus = new boolean[groups.length];

            for (int i = 0; i < groups.length; i++) {
                mGroups[i] = groups[i].group;
                mLogcatStatus[i] = groups[i].logToLogcat;
            }

            return this;
        }

        /**
         * Set the viewer config file that the logs in this process are using.
         * @param viewerConfigFile The file path of the viewer config.
         * @return self
         */
        public RegisterClientArgs setViewerConfigFile(@NonNull String viewerConfigFile) {
            mViewerConfigFile = viewerConfigFile;

            return this;
        }

        @Override
        @NonNull
        public String[] getGroups() {
            return mGroups;
        }

        @Override
        @NonNull
        public boolean[] getGroupsDefaultLogcatStatus() {
            return mLogcatStatus;
        }

        @Nullable
        @Override
        public String getViewerConfigFile() {
            return mViewerConfigFile;
        }
    }

    @FunctionalInterface
    public interface ViewerConfigFileTracer {
        /**
@@ -216,16 +148,16 @@ public class ProtoLogConfigurationServiceImpl extends IProtoLogConfigurationServ
    }

    @Override
    public void registerClient(@NonNull IProtoLogClient client, @NonNull IRegisterClientArgs args)
    public void registerClient(@NonNull IProtoLogClient client, @NonNull RegisterClientArgs args)
            throws RemoteException {
        client.asBinder().linkToDeath(() -> onClientBinderDeath(client), /* flags */ 0);

        final String viewerConfigFile = args.getViewerConfigFile();
        final String viewerConfigFile = args.viewerConfigFile;
        if (viewerConfigFile != null) {
            registerViewerConfigFile(client, viewerConfigFile);
        }

        registerGroups(client, args.getGroups(), args.getGroupsDefaultLogcatStatus());
        registerGroups(client, args.groups, args.groupsDefaultLogcatStatus);
    }

    @Override
+1 −1
Original line number Diff line number Diff line
@@ -19,7 +19,7 @@ package com.android.internal.protolog;
import android.annotation.NonNull;
import android.os.ServiceManager;

import com.android.internal.protolog.ProtoLogConfigurationServiceImpl.RegisterClientArgs;
import com.android.internal.protolog.IProtoLogConfigurationService.RegisterClientArgs;
import com.android.internal.protolog.common.IProtoLogGroup;

public class UnprocessedPerfettoProtoLogImpl extends PerfettoProtoLogImpl {
Loading