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

Commit afee1bbc authored by Mike Ma's avatar Mike Ma Committed by Android (Google) Code Review
Browse files

Merge "Core proto definition for "dumpsys nfc --proto""

parents 8ac64bc0 5313cbcb
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package android.nfc;

import android.os.Parcel;
import android.os.Parcelable;
import android.util.proto.ProtoOutputStream;

import java.nio.ByteBuffer;
import java.util.Arrays;
@@ -250,4 +251,22 @@ public final class NdefMessage implements Parcelable {
    public String toString() {
        return "NdefMessage " + Arrays.toString(mRecords);
    }

    /**
     * Dump debugging information as a NdefMessageProto
     * @hide
     *
     * Note:
     * See proto definition in frameworks/base/core/proto/android/nfc/ndef.proto
     * When writing a nested message, must call {@link ProtoOutputStream#start(long)} before and
     * {@link ProtoOutputStream#end(long)} after.
     * Never reuse a proto field number. When removing a field, mark it as reserved.
     */
    public void dumpDebug(ProtoOutputStream proto) {
        for (NdefRecord record : mRecords) {
            long token = proto.start(NdefMessageProto.NDEF_RECORDS);
            record.dumpDebug(proto);
            proto.end(token);
        }
    }
}
 No newline at end of file
+17 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.content.Intent;
import android.net.Uri;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.proto.ProtoOutputStream;

import java.nio.BufferUnderflowException;
import java.nio.ByteBuffer;
@@ -1051,6 +1052,22 @@ public final class NdefRecord implements Parcelable {
        return b.toString();
    }

    /**
     * Dump debugging information as a NdefRecordProto
     * @hide
     *
     * Note:
     * See proto definition in frameworks/base/core/proto/android/nfc/ndef.proto
     * When writing a nested message, must call {@link ProtoOutputStream#start(long)} before and
     * {@link ProtoOutputStream#end(long)} after.
     * Never reuse a proto field number. When removing a field, mark it as reserved.
     */
    public void dumpDebug(ProtoOutputStream proto) {
        proto.write(NdefRecordProto.TYPE, mType);
        proto.write(NdefRecordProto.ID, mId);
        proto.write(NdefRecordProto.PAYLOAD_BYTES, mPayload.length);
    }

    private static StringBuilder bytesToString(byte[] bs) {
        StringBuilder s = new StringBuilder();
        for (byte b : bs) {
+16 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.compat.annotation.UnsupportedAppUsage;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.Log;
import android.util.proto.ProtoOutputStream;

import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
@@ -117,6 +118,21 @@ public final class AidGroup implements Parcelable {
        return out.toString();
    }

    /**
     * Dump debugging info as AidGroupProto
     *
     * If the output belongs to a sub message, the caller is responsible for wrapping this function
     * between {@link ProtoOutputStream#start(long)} and {@link ProtoOutputStream#end(long)}.
     *
     * @param proto the ProtoOutputStream to write to
     */
    public void dump(ProtoOutputStream proto) {
        proto.write(AidGroupProto.CATEGORY, category);
        for (String aid : aids) {
            proto.write(AidGroupProto.AIDS, aid);
        }
    }

    @Override
    public int describeContents() {
        return 0;
+31 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import android.os.Parcelable;
import android.util.AttributeSet;
import android.util.Log;
import android.util.Xml;
import android.util.proto.ProtoOutputStream;

import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
@@ -607,4 +608,34 @@ public final class ApduServiceInfo implements Parcelable {
        }
        pw.println("    Settings Activity: " + mSettingsActivityName);
    }

    /**
     * Dump debugging info as ApduServiceInfoProto
     *
     * If the output belongs to a sub message, the caller is responsible for wrapping this function
     * between {@link ProtoOutputStream#start(long)} and {@link ProtoOutputStream#end(long)}.
     * See proto definition in frameworks/base/core/proto/android/nfc/apdu_service_info.proto
     *
     * @param proto the ProtoOutputStream to write to
     */
    public void dumpDebug(ProtoOutputStream proto) {
        getComponent().dumpDebug(proto, ApduServiceInfoProto.COMPONENT_NAME);
        proto.write(ApduServiceInfoProto.DESCRIPTION, getDescription());
        proto.write(ApduServiceInfoProto.ON_HOST, mOnHost);
        if (!mOnHost) {
            proto.write(ApduServiceInfoProto.OFF_HOST_NAME, mOffHostName);
            proto.write(ApduServiceInfoProto.STATIC_OFF_HOST_NAME, mStaticOffHostName);
        }
        for (AidGroup group : mStaticAidGroups.values()) {
            long token = proto.start(ApduServiceInfoProto.STATIC_AID_GROUPS);
            group.dump(proto);
            proto.end(token);
        }
        for (AidGroup group : mDynamicAidGroups.values()) {
            long token = proto.start(ApduServiceInfoProto.STATIC_AID_GROUPS);
            group.dump(proto);
            proto.end(token);
        }
        proto.write(ApduServiceInfoProto.SETTINGS_ACTIVITY_NAME, mSettingsActivityName);
    }
}
+17 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import android.os.Parcelable;
import android.util.AttributeSet;
import android.util.Log;
import android.util.Xml;
import android.util.proto.ProtoOutputStream;

import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
@@ -325,5 +326,21 @@ public final class NfcFServiceInfo implements Parcelable {
        pw.println("    NFCID2: " + getNfcid2());
        pw.println("    T3tPmm: " + getT3tPmm());
    }

    /**
     * Dump debugging info as NfcFServiceInfoProto
     *
     * If the output belongs to a sub message, the caller is responsible for wrapping this function
     * between {@link ProtoOutputStream#start(long)} and {@link ProtoOutputStream#end(long)}.
     *
     * @param proto the ProtoOutputStream to write to
     */
    public void dumpDebug(ProtoOutputStream proto) {
        getComponent().dumpDebug(proto, NfcFServiceInfoProto.COMPONENT_NAME);
        proto.write(NfcFServiceInfoProto.DESCRIPTION, getDescription());
        proto.write(NfcFServiceInfoProto.SYSTEM_CODE, getSystemCode());
        proto.write(NfcFServiceInfoProto.NFCID2, getNfcid2());
        proto.write(NfcFServiceInfoProto.T3T_PMM, getT3tPmm());
    }
}
Loading