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

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

Merge "Make ProtoLog client registration atomic" into main

parents 5852a6fc 4d153619
Loading
Loading
Loading
Loading
+22 −20
Original line number Diff line number Diff line
@@ -199,9 +199,9 @@ public class ProtoLogConfigurationServiceImpl extends IProtoLogConfigurationServ
                mConfigFileCounts.put(viewerConfigFile,
                        mConfigFileCounts.getOrDefault(viewerConfigFile, 0) + 1);
            }
        }

        registerGroups(client, args.groups, args.groupsDefaultLogcatStatus);
            registerGroupsLocked(client, args.groups, args.groupsDefaultLogcatStatus);
        }

        clientBinder.linkToDeath(this, /* flags= */ 0);
    }
@@ -209,7 +209,9 @@ public class ProtoLogConfigurationServiceImpl extends IProtoLogConfigurationServ
    @Override
    public void registerGroups(@NonNull IProtoLogClient client, @NonNull RegisterGroupsArgs args)
            throws RemoteException {
        registerGroups(client, args.groups, args.groupsDefaultLogcatStatus);
        synchronized (mConfigLock) {
            registerGroupsLocked(client, args.groups, args.groupsDefaultLogcatStatus);
        }
    }

    /**
@@ -327,7 +329,8 @@ public class ProtoLogConfigurationServiceImpl extends IProtoLogConfigurationServ
        unregisterClient(IProtoLogClient.Stub.asInterface(clientBinder));
    }

    private void registerGroups(@NonNull IProtoLogClient client, @NonNull String[] groups,
    @GuardedBy("mConfigLock")
    private void registerGroupsLocked(@NonNull IProtoLogClient client, @NonNull String[] groups,
            @NonNull boolean[] logcatStatuses) throws RemoteException {
        if (groups.length != logcatStatuses.length) {
            throw new RuntimeException(
@@ -336,10 +339,10 @@ public class ProtoLogConfigurationServiceImpl extends IProtoLogConfigurationServ
                        + " and logcatStatuses has length " + logcatStatuses.length);
        }

        synchronized (mConfigLock) {
        final var clientRecord = mClientRecords.get(client.asBinder());
        if (clientRecord == null) {
                throw new RuntimeException("Client " + client + " is not registered");
            Log.wtf(LOG_TAG, "Trying to add groups to unregistered client: " + client);
            return;
        }

        for (int i = 0; i < groups.length; i++) {
@@ -358,7 +361,6 @@ public class ProtoLogConfigurationServiceImpl extends IProtoLogConfigurationServ
            }
        }
    }
    }

    private void toggleProtoLogToLogcat(
            @NonNull PrintWriter pw, boolean enabled, @NonNull String[] groups