diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2022-04-15 03:56:35 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2022-04-15 03:56:35 +0000 |
commit | 96af7cc1a71200c77037efce2190a5d03ff1a0fb (patch) | |
tree | 17dfef964790e7066e23ed33406395afd5ac4d02 | |
parent | 0dda49c2a5d2d229f29c3db7c409e229d127eb08 (diff) | |
parent | 664faafeab1c58d198ca9d879bb838315da1ba94 (diff) | |
download | Nfc-96af7cc1a71200c77037efce2190a5d03ff1a0fb.tar.gz |
Merge changes from topic "presubmit-am-e1be6dc5385f4c36aa191dbaa3e74753-sc-v2-dev" into sc-v2-dev-plus-aosp
* changes:
[automerge] Revert "Do not set default contactless application without user interaction" 2p: 5774f824ab
Revert "Do not set default contactless application without user interaction"
-rw-r--r-- | src/com/android/nfc/cardemulation/CardEmulationManager.java | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/src/com/android/nfc/cardemulation/CardEmulationManager.java b/src/com/android/nfc/cardemulation/CardEmulationManager.java index 6fd61375..872ceb84 100644 --- a/src/com/android/nfc/cardemulation/CardEmulationManager.java +++ b/src/com/android/nfc/cardemulation/CardEmulationManager.java @@ -264,9 +264,30 @@ public class CardEmulationManager implements RegisteredServicesCache.Callback, getDefaultServiceForCategory(userId, CardEmulation.CATEGORY_PAYMENT, true); if (DBG) Log.d(TAG, "Current default: " + defaultPaymentService + " for user:" + userId); if (defaultPaymentService == null) { - // A payment service may have been removed, set default payment selection to "not set". - if (DBG) Log.d(TAG, "No default set, last payment service removed."); - setDefaultServiceForCategoryChecked(userId, null, CardEmulation.CATEGORY_PAYMENT); + // A payment service may have been removed, leaving only one; + // in that case, automatically set that app as default. + int numPaymentServices = 0; + ComponentName lastFoundPaymentService = null; + for (ApduServiceInfo service : services) { + if (service.hasCategory(CardEmulation.CATEGORY_PAYMENT)) { + numPaymentServices++; + lastFoundPaymentService = service.getComponent(); + } + } + if (numPaymentServices > 1) { + // More than one service left, leave default unset + if (DBG) Log.d(TAG, "No default set, more than one service left."); + setDefaultServiceForCategoryChecked(userId, null, CardEmulation.CATEGORY_PAYMENT); + } else if (numPaymentServices == 1) { + // Make single found payment service the default + if (DBG) Log.d(TAG, "No default set, making single service default."); + setDefaultServiceForCategoryChecked(userId, lastFoundPaymentService, + CardEmulation.CATEGORY_PAYMENT); + } else { + // No payment services left, leave default at null + if (DBG) Log.d(TAG, "No default set, last payment service removed."); + setDefaultServiceForCategoryChecked(userId, null, CardEmulation.CATEGORY_PAYMENT); + } } } |