Merge "[NFC] Disable contactless payments when no payment application installed" into rvc-dev am: 0181643bb7
Change-Id: I96469f4d0938d9f5f913ee531d4e5e72a11a7ed4
This commit is contained in:
@@ -7438,6 +7438,8 @@
|
||||
<string name="connected_devices_dashboard_no_driving_mode_no_nfc_summary">Bluetooth</string>
|
||||
<!-- Summary for Tap & pay settings, explaning a few important settings under it [CHAR LIMIT=NONE]-->
|
||||
<string name="nfc_and_payment_settings_payment_off_nfc_off_summary">Unavailable because NFC is off</string>
|
||||
<!-- Summary for Tap & pay settings, explaning a few important settings under it [CHAR LIMIT=NONE]-->
|
||||
<string name="nfc_and_payment_settings_no_payment_installed_summary">To use, first install a payment app</string>
|
||||
<!-- Title for setting tile leading to Apps & Notification settings [CHAR LIMIT=40]-->
|
||||
<string name="app_and_notification_dashboard_title">Apps & notifications</string>
|
||||
<!-- Summary for Apps & Notification settings, explaining a few important settings under it [CHAR LIMIT=NONE]-->
|
||||
|
@@ -18,6 +18,7 @@ package com.android.settings.applications.specialaccess;
|
||||
|
||||
import android.content.Context;
|
||||
import android.nfc.NfcAdapter;
|
||||
import android.nfc.cardemulation.CardEmulation;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
|
||||
@@ -30,10 +31,14 @@ import com.android.settings.nfc.BaseNfcEnabler;
|
||||
* preference is updated.
|
||||
*/
|
||||
public class PaymentSettingsEnabler extends BaseNfcEnabler {
|
||||
private final CardEmulation mCardEmuManager;
|
||||
private final Preference mPreference;
|
||||
boolean mIsPaymentAvailable;
|
||||
|
||||
public PaymentSettingsEnabler(Context context, Preference preference) {
|
||||
super(context);
|
||||
mCardEmuManager = CardEmulation.getInstance(super.mNfcAdapter);
|
||||
mIsPaymentAvailable = false;
|
||||
mPreference = preference;
|
||||
}
|
||||
|
||||
@@ -46,9 +51,29 @@ public class PaymentSettingsEnabler extends BaseNfcEnabler {
|
||||
mPreference.setEnabled(false);
|
||||
break;
|
||||
case NfcAdapter.STATE_ON:
|
||||
if (mIsPaymentAvailable) {
|
||||
mPreference.setSummary(null);
|
||||
mPreference.setEnabled(true);
|
||||
} else {
|
||||
mPreference.setSummary(
|
||||
R.string.nfc_and_payment_settings_no_payment_installed_summary);
|
||||
|
||||
mPreference.setEnabled(false);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resume() {
|
||||
if (!isNfcAvailable()) {
|
||||
return;
|
||||
}
|
||||
if (mCardEmuManager.getServices(CardEmulation.CATEGORY_PAYMENT).isEmpty()) {
|
||||
mIsPaymentAvailable = false;
|
||||
} else {
|
||||
mIsPaymentAvailable = true;
|
||||
}
|
||||
super.resume();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user