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

This commit is contained in:
Mike Ma
2020-02-17 23:38:10 +00:00
committed by Android (Google) Code Review
13 changed files with 503 additions and 0 deletions

View File

@@ -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);
}
}
}

View File

@@ -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) {

View File

@@ -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;

View File

@@ -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);
}
}

View File

@@ -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());
}
}

View File

@@ -0,0 +1 @@
include platform/packages/apps/Nfc:/OWNERS

View File

@@ -0,0 +1,32 @@
/*
* Copyright (C) 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
syntax = "proto2";
package android.nfc.cardemulation;
import "frameworks/base/core/proto/android/privacy.proto";
option java_multiple_files = true;
// Debugging information for android.nfc.cardemulation.AidGroup
message AidGroupProto {
option (.android.msg_privacy).dest = DEST_AUTOMATIC;
optional string category = 1;
// A group of Application Identifiers. A hexadecimal string, with an even amount of hexadecimal
// characters, e.g. "F014811481".
repeated string aids = 2;
}

View File

@@ -0,0 +1,38 @@
/*
* Copyright (C) 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
syntax = "proto2";
package android.nfc.cardemulation;
import "frameworks/base/core/proto/android/content/component_name.proto";
import "frameworks/base/core/proto/android/nfc/aid_group.proto";
import "frameworks/base/core/proto/android/privacy.proto";
option java_multiple_files = true;
// Debugging information for android.nfc.cardemulation.ApduServiceInfo
message ApduServiceInfoProto {
option (.android.msg_privacy).dest = DEST_AUTOMATIC;
optional .android.content.ComponentNameProto component_name = 1;
optional string description = 2;
optional bool on_host = 3;
optional string off_host_name = 4;
optional string static_off_host_name = 5;
repeated AidGroupProto static_aid_groups = 6;
repeated AidGroupProto dynamic_aid_groups = 7;
optional string settings_activity_name = 8;
}

View File

@@ -0,0 +1,129 @@
/*
* Copyright (C) 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
syntax = "proto2";
package com.android.nfc.cardemulation;
import "frameworks/base/core/proto/android/content/component_name.proto";
import "frameworks/base/core/proto/android/nfc/apdu_service_info.proto";
import "frameworks/base/core/proto/android/nfc/nfc_fservice_info.proto";
import "frameworks/base/core/proto/android/privacy.proto";
option java_multiple_files = true;
// Debugging information for com.android.nfc.cardemulation.CardEmulationManager
message CardEmulationManagerProto {
option (.android.msg_privacy).dest = DEST_AUTOMATIC;
optional RegisteredServicesCacheProto registered_services_cache = 1;
optional RegisteredNfcFServicesCacheProto registered_nfc_f_services_cache = 2;
optional PreferredServicesProto preferred_services = 3;
optional EnabledNfcFServicesProto enabled_nfc_f_services = 4;
optional RegisteredAidCacheProto aid_cache = 5;
optional RegisteredT3tIdentifiersCacheProto t3t_identifiers_cache = 6;
optional HostEmulationManagerProto host_emulation_manager = 7;
optional HostNfcFEmulationManagerProto host_nfc_f_emulation_manager = 8;
}
// Debugging information for com.android.nfc.cardemulation.RegisteredServicesCache
message RegisteredServicesCacheProto {
option (.android.msg_privacy).dest = DEST_AUTOMATIC;
repeated .android.nfc.cardemulation.ApduServiceInfoProto apdu_service_infos = 1;
}
// Debugging information for com.android.nfc.cardemulation.RegisteredNfcFServicesCache
message RegisteredNfcFServicesCacheProto {
option (.android.msg_privacy).dest = DEST_AUTOMATIC;
repeated .android.nfc.cardemulation.NfcFServiceInfoProto nfc_fservice_info = 1;
}
// Debugging information for com.android.nfc.cardemulation.PreferredServices
message PreferredServicesProto {
option (.android.msg_privacy).dest = DEST_AUTOMATIC;
optional .android.content.ComponentNameProto foreground_current = 1;
optional .android.content.ComponentNameProto current_preferred = 2;
optional .android.content.ComponentNameProto next_tap_default = 3;
optional int32 foreground_uid = 4;
optional .android.content.ComponentNameProto foreground_requested = 5;
optional .android.content.ComponentNameProto settings_default = 6;
optional bool prefer_foreground = 7;
}
// Debugging information for com.android.nfc.cardemulation.EnabledNfcFServices
message EnabledNfcFServicesProto {
option (.android.msg_privacy).dest = DEST_AUTOMATIC;
optional .android.content.ComponentNameProto foreground_component = 1;
optional .android.content.ComponentNameProto foreground_requested = 2;
optional bool activated = 3;
optional bool compute_fg_requested = 4;
optional int32 foreground_uid = 5;
}
// Debugging information for com.android.nfc.cardemulation.RegisteredAidCache
message RegisteredAidCacheProto {
option (.android.msg_privacy).dest = DEST_AUTOMATIC;
message AidCacheEntry {
optional string key = 1;
optional string category = 2;
optional .android.content.ComponentNameProto default_component = 3;
repeated .android.nfc.cardemulation.ApduServiceInfoProto services = 4;
}
repeated AidCacheEntry aid_cache_entries = 1;
optional .android.content.ComponentNameProto preferred_foreground_service = 2;
optional .android.content.ComponentNameProto preferred_payment_service = 3;
optional AidRoutingManagerProto routing_manager = 4;
}
message AidRoutingManagerProto {
option (.android.msg_privacy).dest = DEST_AUTOMATIC;
message Route {
option (.android.msg_privacy).dest = DEST_AUTOMATIC;
optional int32 id = 1;
repeated string aids = 2;
}
optional int32 default_route = 1;
repeated Route routes = 2;
}
// Debugging information for com.android.nfc.cardemulation.RegisteredT3tIdentifiersCache
message RegisteredT3tIdentifiersCacheProto {
option (.android.msg_privacy).dest = DEST_AUTOMATIC;
repeated .android.nfc.cardemulation.NfcFServiceInfoProto t3t_identifier_cache_entries = 1;
optional SystemCodeRoutingManagerProto routing_manager = 2;
}
// Debugging information for com.android.nfc.cardemulation.SystemCodeRoutingManager
message SystemCodeRoutingManagerProto {
option (.android.msg_privacy).dest = DEST_AUTOMATIC;
message T3tIdentifier {
option (.android.msg_privacy).dest = DEST_AUTOMATIC;
optional string system_code = 1;
optional string nfcid2 = 2;
}
repeated T3tIdentifier t3t_identifiers = 1;
}
// Debugging information for com.android.nfc.cardemulation.HostEmulationManager
message HostEmulationManagerProto {
option (.android.msg_privacy).dest = DEST_AUTOMATIC;
optional .android.content.ComponentNameProto payment_service_name = 1;
optional .android.content.ComponentNameProto service_name = 2;
}
// Debugging information for com.android.nfc.cardemulation.HostNfcFEmulationManager
message HostNfcFEmulationManagerProto {
option (.android.msg_privacy).dest = DEST_AUTOMATIC;
optional .android.content.ComponentNameProto service_name = 1;
}

View File

@@ -0,0 +1,37 @@
/*
* Copyright (C) 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
syntax = "proto2";
package android.nfc;
import "frameworks/base/core/proto/android/privacy.proto";
option java_multiple_files = true;
// Debugging information for android.nfc.NdefMessage
message NdefMessageProto {
option (.android.msg_privacy).dest = DEST_AUTOMATIC;
repeated NdefRecordProto ndef_records = 1;
}
message NdefRecordProto {
option (.android.msg_privacy).dest = DEST_AUTOMATIC;
optional bytes type = 1;
optional bytes id = 2;
optional int32 payload_bytes = 3;
}

View File

@@ -0,0 +1,38 @@
/*
* Copyright (C) 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
syntax = "proto2";
package android.nfc.cardemulation;
import "frameworks/base/core/proto/android/content/component_name.proto";
import "frameworks/base/core/proto/android/privacy.proto";
option java_multiple_files = true;
// Debugging information for android.nfc.cardemulation.NfcFServiceInfo
message NfcFServiceInfoProto {
option (.android.msg_privacy).dest = DEST_AUTOMATIC;
optional .android.content.ComponentNameProto component_name = 1;
// Description of the service
optional string description = 2;
// System Code of the service
optional string system_code = 3;
// NFCID2 of the service
optional string nfcid2 = 4;
// LF_T3T_PMM of the service
optional string t3t_pmm = 5;
}

View File

@@ -0,0 +1,122 @@
/*
* Copyright (C) 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
syntax = "proto2";
package com.android.nfc;
import "frameworks/base/core/proto/android/app/pendingintent.proto";
import "frameworks/base/core/proto/android/content/intent.proto";
import "frameworks/base/core/proto/android/nfc/card_emulation.proto";
import "frameworks/base/core/proto/android/nfc/ndef.proto";
import "frameworks/base/core/proto/android/privacy.proto";
option java_multiple_files = true;
// Debugging information for com.android.nfc.NfcService
message NfcServiceDumpProto {
option (.android.msg_privacy).dest = DEST_AUTOMATIC;
enum State {
STATE_UNKNOWN = 0;
STATE_OFF = 1;
STATE_TURNING_ON = 2;
STATE_ON = 3;
STATE_TURNING_OFF = 4;
}
enum ScreenState {
SCREEN_STATE_UNKNOWN = 0;
SCREEN_STATE_OFF_UNLOCKED = 1;
SCREEN_STATE_OFF_LOCKED = 2;
SCREEN_STATE_ON_LOCKED = 3;
SCREEN_STATE_ON_UNLOCKED = 4;
}
optional State state = 1;
optional bool in_provision_mode = 2;
optional bool ndef_push_enabled = 3;
optional ScreenState screen_state = 4;
optional bool secure_nfc_enabled = 5;
optional bool polling_paused = 6;
optional int32 num_tags_detected = 7;
optional int32 num_p2p_detected = 8;
optional int32 num_hce_detected = 9;
optional bool hce_capable = 10;
optional bool hce_f_capable = 11;
optional bool beam_capable = 12;
optional bool secure_nfc_capable = 13;
optional bool vr_mode_enabled = 14;
optional DiscoveryParamsProto discovery_params = 15;
optional P2pLinkManagerProto p2p_link_manager = 16;
optional com.android.nfc.cardemulation.CardEmulationManagerProto card_emulation_manager = 17;
optional NfcDispatcherProto nfc_dispatcher = 18;
optional string native_crash_logs = 19 [(.android.privacy).dest = DEST_EXPLICIT];
}
// Debugging information for com.android.nfc.NfcDiscoveryParameters
message DiscoveryParamsProto {
option (.android.msg_privacy).dest = DEST_AUTOMATIC;
optional int32 tech_mask = 1;
optional bool enable_lpd = 2;
optional bool enable_reader = 3;
optional bool enable_host_routing = 4;
optional bool enable_p2p = 5;
}
// Debugging information for com.android.nfc.P2pLinkManager
message P2pLinkManagerProto {
option (.android.msg_privacy).dest = DEST_AUTOMATIC;
enum LinkState {
LINK_STATE_UNKNOWN = 0;
LINK_STATE_DOWN = 1;
LINK_STATE_DEBOUNCE = 2;
LINK_STATE_UP = 3;
}
enum SendState {
SEND_STATE_UNKNOWN = 0;
SEND_STATE_NOTHING_TO_SEND = 1;
SEND_STATE_NEED_CONFIRMATION = 2;
SEND_STATE_SENDING = 3;
SEND_STATE_COMPLETE = 4;
SEND_STATE_CANCELED = 5;
}
optional int32 default_miu = 1;
optional int32 default_rw_size = 2;
optional LinkState link_state = 3;
optional SendState send_state = 4;
optional int32 send_flags = 5;
optional bool send_enabled = 6;
optional bool receive_enabled = 7;
optional string callback_ndef = 8;
optional .android.nfc.NdefMessageProto message_to_send = 9;
repeated string uris_to_send = 10 [(.android.privacy).dest = DEST_EXPLICIT];
}
// Debugging information for com.android.nfc.NfcDispatcher
message NfcDispatcherProto {
option (.android.msg_privacy).dest = DEST_AUTOMATIC;
optional bool device_supports_bluetooth = 1;
optional bool bluetooth_enabled_by_nfc = 2;
optional bool provisioning_only = 3;
optional .android.app.PendingIntentProto override_intent = 4;
repeated .android.content.IntentFilterProto override_filters = 5;
optional string override_tech_lists = 6;
}

View File

@@ -17,6 +17,7 @@
syntax = "proto2";
option java_multiple_files = true;
import "frameworks/base/core/proto/android/nfc/nfc_service.proto";
import "frameworks/base/core/proto/android/os/backtrace.proto";
import "frameworks/base/core/proto/android/os/batterytype.proto";
import "frameworks/base/core/proto/android/os/cpufreq.proto";
@@ -499,6 +500,11 @@ message IncidentProto {
(section).args = "contexthub --proto"
];
optional com.android.nfc.NfcServiceDumpProto nfc_service = 3052 [
(section).type = SECTION_DUMPSYS,
(section).args = "nfc --proto"
];
optional android.service.SensorServiceProto sensor_service = 3053 [
(section).type = SECTION_DUMPSYS,
(section).args = "sensorservice --proto"