Merge "HCE foreground support."
This commit is contained in:
committed by
Android (Google) Code Review
commit
1535bcfbbc
@@ -19,7 +19,7 @@
|
|||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:id="@+id/nfc_payment_pref"
|
android:id="@+id/nfc_payment_pref"
|
||||||
android:focusable="true"
|
android:focusable="true"
|
||||||
android:clickable="true"
|
android:clickable="false"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:paddingTop="10dp"
|
android:paddingTop="10dp"
|
||||||
android:paddingBottom="10dp"
|
android:paddingBottom="10dp"
|
||||||
@@ -37,6 +37,7 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="96dp"
|
android:layout_height="96dp"
|
||||||
android:scaleType="centerInside"
|
android:scaleType="centerInside"
|
||||||
|
android:clickable="true"
|
||||||
/>
|
/>
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
<RadioButton
|
<RadioButton
|
||||||
@@ -46,6 +47,6 @@
|
|||||||
android:layout_alignParentEnd="true"
|
android:layout_alignParentEnd="true"
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
android:duplicateParentState="true"
|
android:duplicateParentState="true"
|
||||||
android:clickable="false"
|
android:clickable="true"
|
||||||
android:focusable="false" />
|
android:focusable="false" />
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
@@ -4957,6 +4957,9 @@
|
|||||||
<string name="nfc_payment_settings_title">Tap & pay</string>
|
<string name="nfc_payment_settings_title">Tap & pay</string>
|
||||||
<!-- String shown when there are no NFC payment applications installed -->
|
<!-- String shown when there are no NFC payment applications installed -->
|
||||||
<string name="nfc_payment_no_apps">Pay with just a tap</string>
|
<string name="nfc_payment_no_apps">Pay with just a tap</string>
|
||||||
|
<!-- String shown before a checkbox, allowing the user to indicate that he wants foreground apps
|
||||||
|
to be able to override the configured default app -->
|
||||||
|
<string name="nfc_payment_favor_foreground">Favor foreground app</string>
|
||||||
<!-- String shown when there are no NFC payment applications installed, clickable, pointing to
|
<!-- String shown when there are no NFC payment applications installed, clickable, pointing to
|
||||||
a website to learn more-->
|
a website to learn more-->
|
||||||
<string name="nfc_payment_learn_more">Learn more</string>
|
<string name="nfc_payment_learn_more">Learn more</string>
|
||||||
|
@@ -24,6 +24,7 @@ import android.nfc.NfcAdapter;
|
|||||||
import android.nfc.cardemulation.ApduServiceInfo;
|
import android.nfc.cardemulation.ApduServiceInfo;
|
||||||
import android.nfc.cardemulation.CardEmulation;
|
import android.nfc.cardemulation.CardEmulation;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
|
import android.provider.Settings.SettingNotFoundException;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -74,6 +75,20 @@ public class PaymentBackend {
|
|||||||
return appInfos;
|
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() {
|
ComponentName getDefaultPaymentApp() {
|
||||||
String componentString = Settings.Secure.getString(mContext.getContentResolver(),
|
String componentString = Settings.Secure.getString(mContext.getContentResolver(),
|
||||||
Settings.Secure.NFC_PAYMENT_DEFAULT_COMPONENT);
|
Settings.Secure.NFC_PAYMENT_DEFAULT_COMPONENT);
|
||||||
|
@@ -19,14 +19,7 @@ package com.android.settings.nfc;
|
|||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.ApplicationInfo;
|
|
||||||
import android.content.pm.PackageManager;
|
|
||||||
import android.content.pm.ResolveInfo;
|
|
||||||
import android.content.pm.PackageManager.NameNotFoundException;
|
|
||||||
import android.nfc.cardemulation.ApduServiceInfo;
|
|
||||||
import android.nfc.cardemulation.CardEmulation;
|
import android.nfc.cardemulation.CardEmulation;
|
||||||
import android.nfc.cardemulation.HostApduService;
|
|
||||||
import android.nfc.cardemulation.OffHostApduService;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
@@ -35,11 +28,8 @@ import com.android.internal.app.AlertController;
|
|||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.nfc.PaymentBackend.PaymentAppInfo;
|
import com.android.settings.nfc.PaymentBackend.PaymentAppInfo;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.xmlpull.v1.XmlPullParserException;
|
|
||||||
|
|
||||||
public final class PaymentDefaultDialog extends AlertActivity implements
|
public final class PaymentDefaultDialog extends AlertActivity implements
|
||||||
DialogInterface.OnClickListener {
|
DialogInterface.OnClickListener {
|
||||||
|
|
||||||
|
@@ -22,7 +22,9 @@ import android.net.Uri;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
|
import android.preference.CheckBoxPreference;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
|
import android.preference.Preference.OnPreferenceChangeListener;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.preference.PreferenceScreen;
|
import android.preference.PreferenceScreen;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
@@ -48,7 +50,7 @@ import com.android.settings.nfc.PaymentBackend.PaymentAppInfo;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class PaymentSettings extends SettingsPreferenceFragment implements
|
public class PaymentSettings extends SettingsPreferenceFragment implements
|
||||||
OnClickListener {
|
OnClickListener, OnPreferenceChangeListener {
|
||||||
public static final String TAG = "PaymentSettings";
|
public static final String TAG = "PaymentSettings";
|
||||||
private LayoutInflater mInflater;
|
private LayoutInflater mInflater;
|
||||||
private PaymentBackend mPaymentBackend;
|
private PaymentBackend mPaymentBackend;
|
||||||
@@ -67,6 +69,7 @@ public class PaymentSettings extends SettingsPreferenceFragment implements
|
|||||||
public void refresh() {
|
public void refresh() {
|
||||||
PreferenceManager manager = getPreferenceManager();
|
PreferenceManager manager = getPreferenceManager();
|
||||||
PreferenceScreen screen = manager.createPreferenceScreen(getActivity());
|
PreferenceScreen screen = manager.createPreferenceScreen(getActivity());
|
||||||
|
|
||||||
// Get all payment services
|
// Get all payment services
|
||||||
List<PaymentAppInfo> appInfos = mPaymentBackend.getPaymentAppInfos();
|
List<PaymentAppInfo> appInfos = mPaymentBackend.getPaymentAppInfos();
|
||||||
if (appInfos != null && appInfos.size() > 0) {
|
if (appInfos != null && appInfos.size() > 0) {
|
||||||
@@ -92,6 +95,13 @@ public class PaymentSettings extends SettingsPreferenceFragment implements
|
|||||||
emptyImage.setVisibility(View.VISIBLE);
|
emptyImage.setVisibility(View.VISIBLE);
|
||||||
getListView().setVisibility(View.GONE);
|
getListView().setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
|
CheckBoxPreference foreground = new CheckBoxPreference(getActivity());
|
||||||
|
boolean foregroundMode = mPaymentBackend.isForegroundMode();
|
||||||
|
foreground.setPersistent(false);
|
||||||
|
foreground.setTitle(getString(R.string.nfc_payment_favor_foreground));
|
||||||
|
foreground.setChecked(foregroundMode);
|
||||||
|
foreground.setOnPreferenceChangeListener(this);
|
||||||
|
screen.addPreference(foreground);
|
||||||
emptyText.setVisibility(View.GONE);
|
emptyText.setVisibility(View.GONE);
|
||||||
learnMore.setVisibility(View.GONE);
|
learnMore.setVisibility(View.GONE);
|
||||||
emptyImage.setVisibility(View.GONE);
|
emptyImage.setVisibility(View.GONE);
|
||||||
@@ -207,14 +217,25 @@ public class PaymentSettings extends SettingsPreferenceFragment implements
|
|||||||
protected void onBindView(View view) {
|
protected void onBindView(View view) {
|
||||||
super.onBindView(view);
|
super.onBindView(view);
|
||||||
|
|
||||||
view.setOnClickListener(listener);
|
|
||||||
view.setTag(appInfo);
|
|
||||||
|
|
||||||
RadioButton radioButton = (RadioButton) view.findViewById(android.R.id.button1);
|
RadioButton radioButton = (RadioButton) view.findViewById(android.R.id.button1);
|
||||||
radioButton.setChecked(appInfo.isDefault);
|
radioButton.setChecked(appInfo.isDefault);
|
||||||
|
radioButton.setOnClickListener(listener);
|
||||||
|
radioButton.setTag(appInfo);
|
||||||
|
|
||||||
ImageView banner = (ImageView) view.findViewById(R.id.banner);
|
ImageView banner = (ImageView) view.findViewById(R.id.banner);
|
||||||
banner.setImageDrawable(appInfo.banner);
|
banner.setImageDrawable(appInfo.banner);
|
||||||
|
banner.setOnClickListener(listener);
|
||||||
|
banner.setTag(appInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
|
if (preference instanceof CheckBoxPreference) {
|
||||||
|
mPaymentBackend.setForegroundMode(((Boolean) newValue).booleanValue());
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user