Make defaultToObserveMode public
Bug: b/324634324
Test: Tested with new CTS tests run locally
Change-Id: I906b2eb00548b91d293335762318419c9f13852c
diff --git a/core/api/current.txt b/core/api/current.txt
index db7334e2..3c77ea6 100644
--- a/core/api/current.txt
+++ b/core/api/current.txt
@@ -687,6 +687,7 @@
field public static final int defaultHeight = 16844021; // 0x10104f5
field @FlaggedApi("android.content.res.default_locale") public static final int defaultLocale;
field public static final int defaultToDeviceProtectedStorage = 16844036; // 0x1010504
+ field @FlaggedApi("android.nfc.Flags.FLAG_OBSERVE_MODE") public static final int defaultToObserveMode;
field public static final int defaultValue = 16843245; // 0x10101ed
field public static final int defaultWidth = 16844020; // 0x10104f4
field public static final int delay = 16843212; // 0x10101cc
diff --git a/core/api/system-current.txt b/core/api/system-current.txt
index 88f9aff..d7124cb 100644
--- a/core/api/system-current.txt
+++ b/core/api/system-current.txt
@@ -10227,6 +10227,7 @@
ctor @FlaggedApi("android.nfc.enable_nfc_mainline") public ApduServiceInfo(@NonNull android.content.pm.PackageManager, @NonNull android.content.pm.ResolveInfo, boolean) throws java.io.IOException, org.xmlpull.v1.XmlPullParserException;
method @FlaggedApi("android.nfc.nfc_read_polling_loop") public void addPollingLoopFilter(@NonNull String);
method @FlaggedApi("android.nfc.nfc_read_polling_loop") public void addPollingLoopFilterToAutoTransact(@NonNull String);
+ method @FlaggedApi("android.nfc.nfc_observe_mode") public boolean defaultToObserveMode();
method @FlaggedApi("android.nfc.enable_nfc_mainline") public int describeContents();
method @FlaggedApi("android.nfc.enable_nfc_mainline") public void dump(@NonNull android.os.ParcelFileDescriptor, @NonNull java.io.PrintWriter, @NonNull String[]);
method @FlaggedApi("android.nfc.enable_nfc_mainline") public void dumpDebug(@NonNull android.util.proto.ProtoOutputStream);
@@ -10256,6 +10257,7 @@
method @FlaggedApi("android.nfc.enable_nfc_mainline") public boolean requiresUnlock();
method @FlaggedApi("android.nfc.enable_nfc_mainline") public void resetOffHostSecureElement();
method @FlaggedApi("android.nfc.enable_nfc_mainline") public void setCategoryOtherServiceEnabled(boolean);
+ method @FlaggedApi("android.nfc.nfc_observe_mode") public void setDefaultToObserveMode(boolean);
method @FlaggedApi("android.nfc.enable_nfc_mainline") public void setDynamicAidGroup(@NonNull android.nfc.cardemulation.AidGroup);
method @FlaggedApi("android.nfc.enable_nfc_mainline") public void setOffHostSecureElement(@NonNull String);
method @FlaggedApi("android.nfc.enable_nfc_mainline") public void writeToParcel(@NonNull android.os.Parcel, int);
diff --git a/core/res/res/values/public-staging.xml b/core/res/res/values/public-staging.xml
index dcb6bb0..981969a 100644
--- a/core/res/res/values/public-staging.xml
+++ b/core/res/res/values/public-staging.xml
@@ -159,6 +159,8 @@
<public name="contentSensitivity" />
<!-- @FlaggedApi("android.view.inputmethod.connectionless_handwriting") -->
<public name="supportsConnectionlessStylusHandwriting" />
+ <!-- @FlaggedApi("android.nfc.Flags.FLAG_OBSERVE_MODE") -->
+ <public name="defaultToObserveMode"/>
</staging-public-group>
<staging-public-group type="id" first-id="0x01bc0000">
diff --git a/nfc/java/android/nfc/cardemulation/ApduServiceInfo.java b/nfc/java/android/nfc/cardemulation/ApduServiceInfo.java
index 3254a39..f264b16 100644
--- a/nfc/java/android/nfc/cardemulation/ApduServiceInfo.java
+++ b/nfc/java/android/nfc/cardemulation/ApduServiceInfo.java
@@ -44,6 +44,8 @@
import android.util.Xml;
import android.util.proto.ProtoOutputStream;
+import com.android.internal.R;
+
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
@@ -138,6 +140,11 @@
private boolean mCategoryOtherServiceEnabled;
/**
+ * Whether the NFC stack should default to Observe Mode when this preferred service.
+ */
+ private boolean mDefaultToObserveMode;
+
+ /**
* @hide
*/
@UnsupportedAppUsage
@@ -257,6 +264,9 @@
com.android.internal.R.styleable.HostApduService_settingsActivity);
mOffHostName = null;
mStaticOffHostName = mOffHostName;
+ mDefaultToObserveMode = sa.getBoolean(
+ R.styleable.HostApduService_defaultToObserveMode,
+ false);
sa.recycle();
} else {
TypedArray sa = res.obtainAttributes(attrs,
@@ -276,6 +286,9 @@
com.android.internal.R.styleable.HostApduService_settingsActivity);
mOffHostName = sa.getString(
com.android.internal.R.styleable.OffHostApduService_secureElementName);
+ mDefaultToObserveMode = sa.getBoolean(
+ R.styleable.HostApduService_defaultToObserveMode,
+ false);
if (mOffHostName != null) {
if (mOffHostName.equals("eSE")) {
mOffHostName = "eSE1";
@@ -611,6 +624,25 @@
}
/**
+ * Returns whether the NFC stack should default to observe mode when this servise is preferred.
+ * @return whether the NFC stack should default to observe mode when this servise is preferred
+ */
+ @FlaggedApi(Flags.FLAG_NFC_OBSERVE_MODE)
+ public boolean defaultToObserveMode() {
+ return mDefaultToObserveMode;
+ }
+
+ /**
+ * Sets whether the NFC stack should default to observe mode when this servise is preferred.
+ * @param defaultToObserveMode whether the NFC stack should default to observe mode when this
+ * servise is preferred
+ */
+ @FlaggedApi(Flags.FLAG_NFC_OBSERVE_MODE)
+ public void setDefaultToObserveMode(boolean defaultToObserveMode) {
+ mDefaultToObserveMode = defaultToObserveMode;
+ }
+
+ /**
* Returns description of service.
* @return user readable description of service
*/