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

Commit 5f5b5f48 authored by Alex Salo's avatar Alex Salo
Browse files

Add AttentionSerivce into dumpsys

Add debug info about AttentionService state into dumpsys by publishing a
binder service which only has the dump() method

Bug: 126472144, 111939367
Test: adb shell dumpsys attention

Change-Id: Id28749d0da6ae9e750ec7319202c27e09dadaaaa
parent 380edb9e
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -3959,6 +3959,16 @@ public abstract class Context {
     */
    public static final String TEXT_CLASSIFICATION_SERVICE = "textclassification";

    /**
     * Use with {@link #getSystemService(String)} to retrieve a
     * {@link com.android.server.attention.AttentionManagerService} for attention services.
     *
     * @see #getSystemService(String)
     * @see android.server.attention.AttentionManagerService
     * @hide
     */
    public static final String ATTENTION_SERVICE = "attention";

    /**
     * Use with {@link #getSystemService(String)} to retrieve a
     * {@link android.view.inputmethod.InputMethodManager} for accessing input
+17 −6
Original line number Diff line number Diff line
@@ -61,6 +61,7 @@ import com.android.internal.util.IndentingPrintWriter;
import com.android.internal.util.Preconditions;
import com.android.server.SystemService;

import java.io.FileDescriptor;
import java.io.PrintWriter;

/**
@@ -99,6 +100,7 @@ public class AttentionManagerService extends SystemService {

    @Override
    public void onStart() {
        publishBinderService(Context.ATTENTION_SERVICE, new BinderService());
        publishLocalService(AttentionManagerInternal.class, new LocalService());
    }

@@ -324,17 +326,15 @@ public class AttentionManagerService extends SystemService {
        return null;
    }

    private void dumpInternal(PrintWriter pw) {
        if (!DumpUtils.checkDumpPermission(mContext, LOG_TAG, pw)) return;
        IndentingPrintWriter ipw = new IndentingPrintWriter(pw, "  ");
        ipw.println("Attention Manager Service (dumpsys attention)\n");
    private void dumpInternal(IndentingPrintWriter ipw) {
        ipw.println("Attention Manager Service (dumpsys attention) state:\n");

        ipw.printPair("context", mContext);
        pw.println();
        ipw.println();
        synchronized (mLock) {
            int size = mUserStates.size();
            ipw.print("Number user states: ");
            pw.println(size);
            ipw.println(size);
            if (size > 0) {
                ipw.increaseIndent();
                for (int i = 0; i < size; i++) {
@@ -586,4 +586,15 @@ public class AttentionManagerService extends SystemService {
            }
        }
    }

    private final class BinderService extends Binder {
        @Override
        protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
            if (!DumpUtils.checkDumpPermission(mContext, LOG_TAG, pw)) {
                return;
            }

            dumpInternal(new IndentingPrintWriter(pw, "  "));
        }
    }
}