HCE foreground support.

Allow users to configure they want to favor the foreground
app for tap&pay.
Change-Id: I25e1058e84f468e47fd40f43b65389c04373a3ab
This commit is contained in:
Martijn Coenen
2014-04-25 16:58:59 -07:00
parent 3f7e0571d3
commit 00dbb74b8d
5 changed files with 46 additions and 16 deletions

View File

@@ -24,6 +24,7 @@ import android.nfc.NfcAdapter;
import android.nfc.cardemulation.ApduServiceInfo;
import android.nfc.cardemulation.CardEmulation;
import android.provider.Settings;
import android.provider.Settings.SettingNotFoundException;
import java.util.ArrayList;
import java.util.List;
@@ -74,6 +75,20 @@ public class PaymentBackend {
return appInfos;
}
boolean isForegroundMode() {
try {
return Settings.Secure.getInt(mContext.getContentResolver(),
Settings.Secure.NFC_PAYMENT_FOREGROUND) != 0;
} catch (SettingNotFoundException e) {
return false;
}
}
void setForegroundMode(boolean foreground) {
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.NFC_PAYMENT_FOREGROUND, foreground ? 1 : 0) ;
}
ComponentName getDefaultPaymentApp() {
String componentString = Settings.Secure.getString(mContext.getContentResolver(),
Settings.Secure.NFC_PAYMENT_DEFAULT_COMPONENT);