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

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

Merge "Link wm shell command to enable protolog in shell"

parents b068bb02 d2b60176
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -263,6 +263,18 @@ public abstract class BasicShellCommandHandler {
        }
    }

    /**
     * @return all the remaining arguments in the command without moving the current position.
     */
    public String[] peekRemainingArgs() {
        int remaining = getRemainingArgsCount();
        String[] args = new String[remaining];
        for (int pos = mArgPos; pos < mArgs.length; pos++) {
            args[pos - mArgPos] = mArgs[pos];
        }
        return args;
    }

    /**
     * Returns number of arguments that haven't been processed yet.
     */
+0 −1
Original line number Diff line number Diff line
@@ -277,7 +277,6 @@ public class BaseProtoLogImpl {
            String group = groups[i];
            IProtoLogGroup g = LOG_GROUPS.get(group);
            if (g != null) {
                System.out.println("G: "+ g);
                if (setTextLogging) {
                    g.setLogToLogcat(value);
                } else {
+6 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.graphics.Rect;
import android.hardware.biometrics.IBiometricSysuiReceiver;
import android.hardware.biometrics.PromptInfo;
import android.os.Bundle;
import android.os.ParcelFileDescriptor;
import android.service.notification.StatusBarNotification;

import com.android.internal.statusbar.StatusBarIcon;
@@ -223,6 +224,11 @@ oneway interface IStatusBar
     */
    void stopTracing();

    /**
     * Handles a logging command from the WM shell command.
     */
    void handleWindowManagerLoggingCommand(in String[] args, in ParcelFileDescriptor outFd);

    /**
     * If true, suppresses the ambient display from showing. If false, re-enables the ambient
     * display.
+2 −0
Original line number Diff line number Diff line
@@ -24,6 +24,8 @@ import com.android.internal.protolog.common.IProtoLogGroup;
 * This file is used by the ProtoLogTool to generate optimized logging code.
 */
public enum ShellProtoLogGroup implements IProtoLogGroup {
    // NOTE: Since we enable these from the same WM ShellCommand, these names should not conflict
    // with those in the framework ProtoLogGroup
    WM_SHELL_TASK_ORG(Consts.ENABLE_DEBUG, Consts.ENABLE_LOG_TO_PROTO_DEBUG, false,
            Consts.TAG_WM_SHELL),
    TEST_GROUP(true, true, false, "WindowManagerShellProtoLogTest");
+6 −9
Original line number Diff line number Diff line
@@ -44,8 +44,6 @@ public class ShellProtoLogImpl extends BaseProtoLogImpl {

    private static ShellProtoLogImpl sServiceInstance = null;

    private final PrintWriter mSystemOutWriter;

    static {
        addLogGroupEnum(ShellProtoLogGroup.values());
    }
@@ -111,11 +109,11 @@ public class ShellProtoLogImpl extends BaseProtoLogImpl {
        return sServiceInstance;
    }

    public void startTextLogging(Context context, String... groups) {
    public int startTextLogging(Context context, String[] groups, PrintWriter pw) {
        try {
            mViewerConfig.loadViewerConfig(
                    context.getResources().openRawResource(R.raw.wm_shell_protolog));
            setLogging(true /* setTextLogging */, true, mSystemOutWriter, groups);
            return setLogging(true /* setTextLogging */, true, pw, groups);
        } catch (IOException e) {
            Log.i(TAG, "Unable to load log definitions: IOException while reading "
                    + "wm_shell_protolog. " + e);
@@ -123,16 +121,15 @@ public class ShellProtoLogImpl extends BaseProtoLogImpl {
            Log.i(TAG, "Unable to load log definitions: JSON parsing exception while reading "
                    + "wm_shell_protolog. " + e);
        }
        return -1;
    }

    public void stopTextLogging(String... groups) {
        setLogging(true /* setTextLogging */, false, mSystemOutWriter, groups);
    public int stopTextLogging(String[] groups, PrintWriter pw) {
        return setLogging(true /* setTextLogging */, false, pw, groups);
    }

    private ShellProtoLogImpl() {
        super(new File(LOG_FILENAME), null, BUFFER_CAPACITY,
                new ProtoLogViewerConfigReader());
        mSystemOutWriter = new PrintWriter(System.out, true);
        super(new File(LOG_FILENAME), null, BUFFER_CAPACITY, new ProtoLogViewerConfigReader());
    }
}
Loading