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

Commit e87735bd authored by Felipe Leme's avatar Felipe Leme
Browse files

Improved dump on services that implement isSupported(UserInfo).

Test: adb shell dumpsys voiceinteraction
Test: adb shell dumpsys autofill

Bug: 146349941

Change-Id: Ibc3001515081ba0efc72b3651f900a4e4f630faa
parent 04eaf14f
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
@@ -29,6 +29,10 @@ import android.os.UserManager;

import com.android.server.pm.UserManagerService;

import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

/**
 * The base class for services running in the system process. Override and implement
 * the lifecycle event callback methods as needed.
@@ -163,6 +167,25 @@ public abstract class SystemService {
        return true;
    }

    /**
     * Helper method used to dump which users are {@link #onStartUser(UserInfo) supported}.
     */
    protected void dumpSupportedUsers(@NonNull PrintWriter pw, @NonNull String prefix) {
        final List<UserInfo> allUsers = UserManager.get(mContext).getUsers();
        final List<Integer> supportedUsers = new ArrayList<>(allUsers.size());
        for (UserInfo user : allUsers) {
            supportedUsers.add(user.id);
        }
        if (allUsers.isEmpty()) {
            pw.print(prefix); pw.println("No supported users");
        } else {
            final int size = supportedUsers.size();
            pw.print(prefix); pw.print(size); pw.print(" supported user");
            if (size > 1) pw.print("s");
            pw.print(": "); pw.println(supportedUsers);
        }
    }

    /**
     * @deprecated subclasses should extend {@link #onStartUser(UserInfo)} instead (which by default
     * calls this method).
+1 −0
Original line number Diff line number Diff line
@@ -762,6 +762,7 @@ public abstract class AbstractMasterSystemService<M extends AbstractMasterSystem
            if (mUpdatingPackageNames != null) {
                pw.print("Packages being updated: "); pw.println(mUpdatingPackageNames);
            }
            dumpSupportedUsers(pw, prefix);
            if (mServiceNameResolver != null) {
                pw.print(prefix); pw.print("Name resolver: ");
                mServiceNameResolver.dumpShort(pw); pw.println();
+1 −0
Original line number Diff line number Diff line
@@ -1291,6 +1291,7 @@ public class VoiceInteractionManagerService extends SystemService {
                pw.println("  mCurUser: " + mCurUser);
                pw.println("  mCurUserUnlocked: " + mCurUserUnlocked);
                pw.println("  mCurUserSupported: " + mCurUserSupported);
                dumpSupportedUsers(pw, "  ");
                if (mImpl == null) {
                    pw.println("  (No active implementation)");
                    return;