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

Commit 1f23a49b authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add AttentionSerivce into dumpsys"

parents 01273af8 5f5b5f48
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -4014,6 +4014,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
@@ -59,6 +59,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;

/**
@@ -103,6 +104,7 @@ public class AttentionManagerService extends SystemService {

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

@@ -329,17 +331,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++) {
@@ -591,4 +591,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, "  "));
        }
    }
}