Merge "[NFC] Disable contactless payments when no payment application installed" into rvc-dev am: 0181643bb7
am: 5a6d05885a
am: 270ea3400b
Change-Id: I757d7573aab372d8f35b838e9b287308e5d142d2
This commit is contained in:
@@ -7438,6 +7438,8 @@
|
|||||||
<string name="connected_devices_dashboard_no_driving_mode_no_nfc_summary">Bluetooth</string>
|
<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]-->
|
<!-- 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>
|
<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]-->
|
<!-- Title for setting tile leading to Apps & Notification settings [CHAR LIMIT=40]-->
|
||||||
<string name="app_and_notification_dashboard_title">Apps & notifications</string>
|
<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]-->
|
<!-- 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.content.Context;
|
||||||
import android.nfc.NfcAdapter;
|
import android.nfc.NfcAdapter;
|
||||||
|
import android.nfc.cardemulation.CardEmulation;
|
||||||
|
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
|
|
||||||
@@ -30,10 +31,14 @@ import com.android.settings.nfc.BaseNfcEnabler;
|
|||||||
* preference is updated.
|
* preference is updated.
|
||||||
*/
|
*/
|
||||||
public class PaymentSettingsEnabler extends BaseNfcEnabler {
|
public class PaymentSettingsEnabler extends BaseNfcEnabler {
|
||||||
|
private final CardEmulation mCardEmuManager;
|
||||||
private final Preference mPreference;
|
private final Preference mPreference;
|
||||||
|
boolean mIsPaymentAvailable;
|
||||||
|
|
||||||
public PaymentSettingsEnabler(Context context, Preference preference) {
|
public PaymentSettingsEnabler(Context context, Preference preference) {
|
||||||
super(context);
|
super(context);
|
||||||
|
mCardEmuManager = CardEmulation.getInstance(super.mNfcAdapter);
|
||||||
|
mIsPaymentAvailable = false;
|
||||||
mPreference = preference;
|
mPreference = preference;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,9 +51,29 @@ public class PaymentSettingsEnabler extends BaseNfcEnabler {
|
|||||||
mPreference.setEnabled(false);
|
mPreference.setEnabled(false);
|
||||||
break;
|
break;
|
||||||
case NfcAdapter.STATE_ON:
|
case NfcAdapter.STATE_ON:
|
||||||
mPreference.setSummary(null);
|
if (mIsPaymentAvailable) {
|
||||||
mPreference.setEnabled(true);
|
mPreference.setSummary(null);
|
||||||
|
mPreference.setEnabled(true);
|
||||||
|
} else {
|
||||||
|
mPreference.setSummary(
|
||||||
|
R.string.nfc_and_payment_settings_no_payment_installed_summary);
|
||||||
|
|
||||||
|
mPreference.setEnabled(false);
|
||||||
|
}
|
||||||
break;
|
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