Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b039c1fa authored by George Chang's avatar George Chang
Browse files

Fix getSelectionModeForCategory

NFC_PAYMENT_DEFAULT_COMPONENT is not accessable for market apps
Check if default payment name already registered in settings by NfcService.
Add a new AIDL interface isDefaultPaymentRegistered in INfcCardEmulation.aidl

Bug: 189178386
Test: atest CtsNfcTestCases
Merged-In: I0a09c9763d39c8e0b9b28df85603bdc7f281669d
Change-Id: I0a09c9763d39c8e0b9b28df85603bdc7f281669d
parent dfc852ca
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -40,4 +40,5 @@ interface INfcCardEmulation
    boolean unsetPreferredService();
    boolean supportsAidPrefixRegistration();
    ApduServiceInfo getPreferredPaymentService(int userHandle);
    boolean isDefaultPaymentRegistered();
}
+17 −3
Original line number Diff line number Diff line
@@ -294,9 +294,23 @@ public final class CardEmulation {
     */
    public int getSelectionModeForCategory(String category) {
        if (CATEGORY_PAYMENT.equals(category)) {
            String defaultComponent = Settings.Secure.getString(mContext.getContentResolver(),
                    Settings.Secure.NFC_PAYMENT_DEFAULT_COMPONENT);
            if (defaultComponent != null) {
            boolean paymentRegistered = false;
            try {
                paymentRegistered = sService.isDefaultPaymentRegistered();
            } catch (RemoteException e) {
                recoverService();
                if (sService == null) {
                    Log.e(TAG, "Failed to recover CardEmulationService.");
                    return SELECTION_MODE_ALWAYS_ASK;
                }
                try {
                    paymentRegistered = sService.isDefaultPaymentRegistered();
                } catch (RemoteException ee) {
                    Log.e(TAG, "Failed to reach CardEmulationService.");
                    return SELECTION_MODE_ALWAYS_ASK;
                }
            }
            if (paymentRegistered) {
                return SELECTION_MODE_PREFER_DEFAULT;
            } else {
                return SELECTION_MODE_ALWAYS_ASK;