• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package android.nfc;
17 
18 import android.annotation.FlaggedApi;
19 import android.annotation.IntDef;
20 import android.annotation.SystemApi;
21 import android.nfc.cardemulation.CardEmulation;
22 
23 import java.lang.annotation.Retention;
24 import java.lang.annotation.RetentionPolicy;
25 
26 /**
27  * Represents a technology entry in current routing table.
28  * @hide
29  */
30 @FlaggedApi(Flags.FLAG_NFC_OEM_EXTENSION)
31 @SystemApi
32 public class RoutingTableTechnologyEntry extends NfcRoutingTableEntry {
33     /**
34      * Technology-A.
35      * <p>Tech-A is mostly used for payment and ticketing applications. It supports various
36      * Tag platforms including Type 1, Type 2 and Type 4A tags. </p>
37      */
38     @FlaggedApi(Flags.FLAG_NFC_OEM_EXTENSION)
39     public static final int TECHNOLOGY_A = 0;
40     /**
41      * Technology-B which is based on ISO/IEC 14443-3 standard.
42      */
43     @FlaggedApi(Flags.FLAG_NFC_OEM_EXTENSION)
44     public static final int TECHNOLOGY_B = 1;
45     /**
46      * Technology-F.
47      * <p>Tech-F is a standard which supports Type 3 Tags and NFC-DEP protocol etc.</p>
48      */
49     @FlaggedApi(Flags.FLAG_NFC_OEM_EXTENSION)
50     public static final int TECHNOLOGY_F = 2;
51     /**
52      * Technology-V.
53      * <p>Tech-V is an NFC technology used for communication with passive tags that operate
54      * at a longer range than other NFC technologies. </p>
55      */
56     @FlaggedApi(Flags.FLAG_NFC_OEM_EXTENSION)
57     public static final int TECHNOLOGY_V = 3;
58     /**
59      * Unsupported technology
60      */
61     @FlaggedApi(Flags.FLAG_NFC_OEM_EXTENSION)
62     public static final int TECHNOLOGY_UNSUPPORTED = -1;
63 
64     /**
65      *
66      * @hide
67      */
68     @IntDef(prefix = { "TECHNOLOGY_" }, value = {
69             TECHNOLOGY_A,
70             TECHNOLOGY_B,
71             TECHNOLOGY_F,
72             TECHNOLOGY_V,
73             TECHNOLOGY_UNSUPPORTED
74     })
75     @Retention(RetentionPolicy.SOURCE)
76     public @interface TechnologyValue{}
77 
78     private final @TechnologyValue int mValue;
79 
80     /** @hide */
RoutingTableTechnologyEntry(int nfceeId, @TechnologyValue int value, @CardEmulation.ProtocolAndTechnologyRoute int routeType)81     public RoutingTableTechnologyEntry(int nfceeId, @TechnologyValue int value,
82             @CardEmulation.ProtocolAndTechnologyRoute int routeType) {
83         super(nfceeId, TYPE_TECHNOLOGY, routeType);
84         this.mValue = value;
85     }
86 
87     /**
88      * Gets technology value.
89      * @return technology value
90      */
91     @TechnologyValue
92     @FlaggedApi(Flags.FLAG_NFC_OEM_EXTENSION)
getTechnology()93     public int getTechnology() {
94         return mValue;
95     }
96 
97     /** @hide */
98     @TechnologyValue
techStringToInt(String tech)99     public static int techStringToInt(String tech) {
100         return switch (tech) {
101             case "TECHNOLOGY_A" -> TECHNOLOGY_A;
102             case "TECHNOLOGY_B" -> TECHNOLOGY_B;
103             case "TECHNOLOGY_F" -> TECHNOLOGY_F;
104             case "TECHNOLOGY_V" -> TECHNOLOGY_V;
105             default -> TECHNOLOGY_UNSUPPORTED;
106         };
107     }
108 }
109