diff options
author | Jack Yu <jackcwyu@google.com> | 2021-02-03 03:00:32 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2021-02-03 03:00:32 +0000 |
commit | 87e9535aa3088c579c1901c87665ef89dab93e06 (patch) | |
tree | 6ed7161adbc2f08699c54983fdba00364672b55d | |
parent | 66783f7bb66748018713ea5e56dd2c8077671e82 (diff) | |
parent | 809b2f2459ef3732c0c67a100df7a7bb2ba42d84 (diff) |
Merge "Add attr for nfc applications to configure support power states" am: 809b2f2459
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1470724
MUST ONLY BE SUBMITTED BY AUTOMERGER
Change-Id: I3d789cfa9ba6cc199e53663eda34f8c4586b1dbf
-rw-r--r-- | core/api/current.txt | 1 | ||||
-rw-r--r-- | core/java/android/nfc/cardemulation/ApduServiceInfo.java | 41 | ||||
-rw-r--r-- | core/res/res/values/attrs.xml | 9 | ||||
-rw-r--r-- | core/res/res/values/public.xml | 1 |
4 files changed, 50 insertions, 2 deletions
diff --git a/core/api/current.txt b/core/api/current.txt index 285506f0556d..f453ccaf75ad 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -1142,6 +1142,7 @@ package android { field public static final int reqNavigation = 16843306; // 0x101022a field public static final int reqTouchScreen = 16843303; // 0x1010227 field public static final int requestLegacyExternalStorage = 16844291; // 0x1010603 + field public static final int requireDeviceScreenOn = 16844312; // 0x1010618 field public static final int requireDeviceUnlock = 16843756; // 0x10103ec field public static final int required = 16843406; // 0x101028e field public static final int requiredAccountType = 16843734; // 0x10103d6 diff --git a/core/java/android/nfc/cardemulation/ApduServiceInfo.java b/core/java/android/nfc/cardemulation/ApduServiceInfo.java index d7c2e0522b0f..64ab074f397a 100644 --- a/core/java/android/nfc/cardemulation/ApduServiceInfo.java +++ b/core/java/android/nfc/cardemulation/ApduServiceInfo.java @@ -97,6 +97,11 @@ public final class ApduServiceInfo implements Parcelable { final boolean mRequiresDeviceUnlock; /** + * Whether this service should only be started when the device is screen on. + */ + final boolean mRequiresDeviceScreenOn; + + /** * The id of the service banner specified in XML. */ final int mBannerResourceId; @@ -119,6 +124,18 @@ public final class ApduServiceInfo implements Parcelable { ArrayList<AidGroup> staticAidGroups, ArrayList<AidGroup> dynamicAidGroups, boolean requiresUnlock, int bannerResource, int uid, String settingsActivityName, String offHost, String staticOffHost) { + this(info, onHost, description, staticAidGroups, dynamicAidGroups, + requiresUnlock, onHost ? true : false, bannerResource, uid, + settingsActivityName, offHost, staticOffHost); + } + + /** + * @hide + */ + public ApduServiceInfo(ResolveInfo info, boolean onHost, String description, + ArrayList<AidGroup> staticAidGroups, ArrayList<AidGroup> dynamicAidGroups, + boolean requiresUnlock, boolean requiresScreenOn, int bannerResource, int uid, + String settingsActivityName, String offHost, String staticOffHost) { this.mService = info; this.mDescription = description; this.mStaticAidGroups = new HashMap<String, AidGroup>(); @@ -127,6 +144,7 @@ public final class ApduServiceInfo implements Parcelable { this.mStaticOffHostName = staticOffHost; this.mOnHost = onHost; this.mRequiresDeviceUnlock = requiresUnlock; + this.mRequiresDeviceScreenOn = requiresScreenOn; for (AidGroup aidGroup : staticAidGroups) { this.mStaticAidGroups.put(aidGroup.category, aidGroup); } @@ -183,6 +201,9 @@ public final class ApduServiceInfo implements Parcelable { mRequiresDeviceUnlock = sa.getBoolean( com.android.internal.R.styleable.HostApduService_requireDeviceUnlock, false); + mRequiresDeviceScreenOn = sa.getBoolean( + com.android.internal.R.styleable.HostApduService_requireDeviceScreenOn, + true); mBannerResourceId = sa.getResourceId( com.android.internal.R.styleable.HostApduService_apduServiceBanner, -1); mSettingsActivityName = sa.getString( @@ -196,7 +217,12 @@ public final class ApduServiceInfo implements Parcelable { mService = info; mDescription = sa.getString( com.android.internal.R.styleable.OffHostApduService_description); - mRequiresDeviceUnlock = false; + mRequiresDeviceUnlock = sa.getBoolean( + com.android.internal.R.styleable.OffHostApduService_requireDeviceUnlock, + false); + mRequiresDeviceScreenOn = sa.getBoolean( + com.android.internal.R.styleable.OffHostApduService_requireDeviceScreenOn, + false); mBannerResourceId = sa.getResourceId( com.android.internal.R.styleable.OffHostApduService_apduServiceBanner, -1); mSettingsActivityName = sa.getString( @@ -419,6 +445,13 @@ public final class ApduServiceInfo implements Parcelable { return mRequiresDeviceUnlock; } + /** + * Returns whether this service should only be started when the device is screen on. + */ + public boolean requiresScreenOn() { + return mRequiresDeviceScreenOn; + } + @UnsupportedAppUsage public String getDescription() { return mDescription; @@ -542,6 +575,7 @@ public final class ApduServiceInfo implements Parcelable { dest.writeTypedList(new ArrayList<AidGroup>(mDynamicAidGroups.values())); } dest.writeInt(mRequiresDeviceUnlock ? 1 : 0); + dest.writeInt(mRequiresDeviceScreenOn ? 1 : 0); dest.writeInt(mBannerResourceId); dest.writeInt(mUid); dest.writeString(mSettingsActivityName); @@ -568,11 +602,12 @@ public final class ApduServiceInfo implements Parcelable { source.readTypedList(dynamicAidGroups, AidGroup.CREATOR); } boolean requiresUnlock = source.readInt() != 0; + boolean requiresScreenOn = source.readInt() != 0; int bannerResource = source.readInt(); int uid = source.readInt(); String settingsActivityName = source.readString(); return new ApduServiceInfo(info, onHost, description, staticAidGroups, - dynamicAidGroups, requiresUnlock, bannerResource, uid, + dynamicAidGroups, requiresUnlock, requiresScreenOn, bannerResource, uid, settingsActivityName, offHostName, staticOffHostName); } @@ -607,6 +642,8 @@ public final class ApduServiceInfo implements Parcelable { } } pw.println(" Settings Activity: " + mSettingsActivityName); + pw.println(" Requires Device Unlock: " + mRequiresDeviceUnlock); + pw.println(" Requires Device ScreenOn: " + mRequiresDeviceScreenOn); } /** diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml index 4b3d82a04b8b..9cc0690126e9 100644 --- a/core/res/res/values/attrs.xml +++ b/core/res/res/values/attrs.xml @@ -3856,6 +3856,9 @@ <!-- Component name of an activity that allows the user to modify the settings for this service. --> <attr name="settingsActivity"/> + <!-- Whether the device must be screen on before routing data to this service. + The default is true.--> + <attr name="requireDeviceScreenOn" format="boolean"/> </declare-styleable> <!-- Use <code>offhost-apdu-service</code> as the root tag of the XML resource that @@ -3874,6 +3877,12 @@ <attr name="settingsActivity"/> <!-- Secure Element which the AIDs should be routed to --> <attr name="secureElementName" format="string"/> + <!-- Whether the device must be unlocked before routing data to this service. + The default is false.--> + <attr name="requireDeviceUnlock"/> + <!-- Whether the device must be screen on before routing data to this service. + The default is false.--> + <attr name="requireDeviceScreenOn"/> </declare-styleable> <!-- Specify one or more <code>aid-group</code> elements inside a diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml index a0be0681bd38..0874a77815b5 100644 --- a/core/res/res/values/public.xml +++ b/core/res/res/values/public.xml @@ -3045,6 +3045,7 @@ <public-group type="attr" first-id="0x01010617"> <public name="canPauseRecording" /> <!-- attribute definitions go here --> + <public name="requireDeviceScreenOn" /> </public-group> <public-group type="drawable" first-id="0x010800b5"> |