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

Commit a73aa322 authored by Martijn Coenen's avatar Martijn Coenen
Browse files

NFC Tap&Pay: deal with changes from API review.

Also, removed "Ask every time" mode.

Bug: 10550349
Change-Id: If7c300f9f446e3c31d594116ac8e20fb50d9ec3f
parent 573a21ad
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -1609,9 +1609,14 @@
                  android:excludeFromRecents="true"
                  android:theme="@*android:style/Theme.Holo.Light.Dialog.Alert">
            <intent-filter>
                <!-- TODO this filter can be removed -->
                <action android:name="android.nfc.cardemulation.ACTION_CHANGE_DEFAULT" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.nfc.cardemulation.action.ACTION_CHANGE_DEFAULT" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>

        <activity android:name="Settings$NotificationAccessSettingsActivity"
+4 −4
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ import android.content.pm.PackageManager;
import android.graphics.drawable.Drawable;
import android.nfc.NfcAdapter;
import android.nfc.cardemulation.ApduServiceInfo;
import android.nfc.cardemulation.CardEmulationManager;
import android.nfc.cardemulation.CardEmulation;
import android.provider.Settings;

import java.util.ArrayList;
@@ -40,19 +40,19 @@ public class PaymentBackend {

    private final Context mContext;
    private final NfcAdapter mAdapter;
    private final CardEmulationManager mCardEmuManager;
    private final CardEmulation mCardEmuManager;

    public PaymentBackend(Context context) {
        mContext = context;

        mAdapter = NfcAdapter.getDefaultAdapter(context);
        mCardEmuManager = CardEmulationManager.getInstance(mAdapter);
        mCardEmuManager = CardEmulation.getInstance(mAdapter);
    }

    public List<PaymentAppInfo> getPaymentAppInfos() {
        PackageManager pm = mContext.getPackageManager();
        List<ApduServiceInfo> serviceInfos =
                mCardEmuManager.getServices(CardEmulationManager.CATEGORY_PAYMENT);
                mCardEmuManager.getServices(CardEmulation.CATEGORY_PAYMENT);
        List<PaymentAppInfo> appInfos = new ArrayList<PaymentAppInfo>();

        if (serviceInfos == null) return appInfos;
+4 −4
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.nfc.cardemulation.CardEmulationManager;
import android.nfc.cardemulation.CardEmulation;
import android.os.Bundle;
import android.util.Log;

@@ -47,8 +47,8 @@ public final class PaymentDefaultDialog extends AlertActivity implements
        mBackend = new PaymentBackend(this);
        Intent intent = getIntent();
        ComponentName component = intent.getParcelableExtra(
                CardEmulationManager.EXTRA_SERVICE_COMPONENT);
        String category = intent.getStringExtra(CardEmulationManager.EXTRA_CATEGORY);
                CardEmulation.EXTRA_SERVICE_COMPONENT);
        String category = intent.getStringExtra(CardEmulation.EXTRA_CATEGORY);

        setResult(RESULT_CANCELED);
        if (!buildDialog(component, category)) {
@@ -75,7 +75,7 @@ public final class PaymentDefaultDialog extends AlertActivity implements
            return false;
        }

        if (!CardEmulationManager.CATEGORY_PAYMENT.equals(category)) {
        if (!CardEmulation.CATEGORY_PAYMENT.equals(category)) {
            Log.e(TAG, "Don't support defaults for category " + category);
            return false;
        }
+0 −15
Original line number Diff line number Diff line
@@ -55,23 +55,10 @@ public class PaymentSettings extends SettingsPreferenceFragment implements
            for (PaymentAppInfo appInfo : appInfos) {
                PaymentAppPreference preference =
                        new PaymentAppPreference(getActivity(), appInfo, this);
                // If for some reason isAuto gets out of sync, clear out app default
                preference.setIcon(appInfo.icon);
                preference.setTitle(appInfo.caption);
                screen.addPreference(preference);
            }
            if (appInfos.size() > 1) {
                PaymentAppInfo appInfo = new PaymentAppInfo();
                appInfo.icon = null;
                appInfo.componentName = null;
                appInfo.isDefault = !(mPaymentBackend.getDefaultPaymentApp() != null);
                // Add "Ask every time" option
                PaymentAppPreference preference =
                        new PaymentAppPreference(getActivity(), appInfo, this);
                preference.setIcon(null);
                preference.setTitle(R.string.nfc_payment_ask);
                screen.addPreference(preference);
            }
        }
        setPreferenceScreen(screen);
    }
@@ -82,8 +69,6 @@ public class PaymentSettings extends SettingsPreferenceFragment implements
            PaymentAppInfo appInfo = (PaymentAppInfo) v.getTag();
            if (appInfo.componentName != null) {
                mPaymentBackend.setDefaultPaymentApp(appInfo.componentName);
            } else {
                mPaymentBackend.setDefaultPaymentApp(null);
            }
            refresh();
        }