summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
authorMike Ma <yanmin@google.com>2020-01-22 13:28:16 -0800
committerMike Ma <yanmin@google.com>2020-02-17 15:34:36 -0800
commit5313cbcb1ba0de5b7f14946026a0696bcfc4c9d1 (patch)
tree217f7bcafd92528268c5d6f9c5dab5ec01f6cfb0 /core/java/android
parent4daaa833de78d8a00fec496af856a330db8b28a3 (diff)
Core proto definition for "dumpsys nfc --proto"
Add NfcServiceProto for protobuf dumpsys of nfc service. Primarily used by incident service to capture an incident report proto. Command to invoke (any of the following after lunch and env setup): $ adb shell dumpsys nfc --proto $ adb shell incident 3052 $ incident_report 3052 Bug: 146086108 Exempt-From-Owner-Approval: Owners not reachable. Test: Execute the above commands and compare the output against dumpsys nfc. Change-Id: I024e148d64ccef5441a67efcbad95c622e5df12a
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/nfc/NdefMessage.java19
-rw-r--r--core/java/android/nfc/NdefRecord.java17
-rw-r--r--core/java/android/nfc/cardemulation/AidGroup.java16
-rw-r--r--core/java/android/nfc/cardemulation/ApduServiceInfo.java31
-rw-r--r--core/java/android/nfc/cardemulation/NfcFServiceInfo.java17
5 files changed, 100 insertions, 0 deletions
diff --git a/core/java/android/nfc/NdefMessage.java b/core/java/android/nfc/NdefMessage.java
index 57d79c80ba90..35dae55f1c80 100644
--- a/core/java/android/nfc/NdefMessage.java
+++ b/core/java/android/nfc/NdefMessage.java
@@ -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
diff --git a/core/java/android/nfc/NdefRecord.java b/core/java/android/nfc/NdefRecord.java
index fe316c45fb55..74f8cb4c1d3d 100644
--- a/core/java/android/nfc/NdefRecord.java
+++ b/core/java/android/nfc/NdefRecord.java
@@ -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) {
diff --git a/core/java/android/nfc/cardemulation/AidGroup.java b/core/java/android/nfc/cardemulation/AidGroup.java
index c4f5e0b2ddf2..2436e57b74bc 100644
--- a/core/java/android/nfc/cardemulation/AidGroup.java
+++ b/core/java/android/nfc/cardemulation/AidGroup.java
@@ -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;
diff --git a/core/java/android/nfc/cardemulation/ApduServiceInfo.java b/core/java/android/nfc/cardemulation/ApduServiceInfo.java
index 8da9db17252f..d7c2e0522b0f 100644
--- a/core/java/android/nfc/cardemulation/ApduServiceInfo.java
+++ b/core/java/android/nfc/cardemulation/ApduServiceInfo.java
@@ -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);
+ }
}
diff --git a/core/java/android/nfc/cardemulation/NfcFServiceInfo.java b/core/java/android/nfc/cardemulation/NfcFServiceInfo.java
index bda14299019a..885a0b540646 100644
--- a/core/java/android/nfc/cardemulation/NfcFServiceInfo.java
+++ b/core/java/android/nfc/cardemulation/NfcFServiceInfo.java
@@ -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());
+ }
}