diff --git a/core/api/current.txt b/core/api/current.txt index b519cbeffe249..a70a0a9042905 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -27413,6 +27413,7 @@ package android.nfc.cardemulation { field public static final String CATEGORY_PAYMENT = "payment"; field public static final String EXTRA_CATEGORY = "category"; field public static final String EXTRA_SERVICE_COMPONENT = "component"; + field public static final String EXTRA_USERID = "android.nfc.cardemulation.extra.USERID"; field public static final int SELECTION_MODE_ALWAYS_ASK = 1; // 0x1 field public static final int SELECTION_MODE_ASK_IF_CONFLICT = 2; // 0x2 field public static final int SELECTION_MODE_PREFER_DEFAULT = 0; // 0x0 diff --git a/core/java/android/nfc/cardemulation/ApduServiceInfo.java b/core/java/android/nfc/cardemulation/ApduServiceInfo.java index 0af322e885b1a..09540132fe0d4 100644 --- a/core/java/android/nfc/cardemulation/ApduServiceInfo.java +++ b/core/java/android/nfc/cardemulation/ApduServiceInfo.java @@ -528,6 +528,7 @@ public final class ApduServiceInfo implements Parcelable { public String toString() { StringBuilder out = new StringBuilder("ApduService: "); out.append(getComponent()); + out.append(", UID: " + mUid); out.append(", description: " + mDescription); out.append(", Static AID Groups: "); for (AidGroup aidGroup : mStaticAidGroups.values()) { @@ -546,7 +547,8 @@ public final class ApduServiceInfo implements Parcelable { if (!(o instanceof ApduServiceInfo)) return false; ApduServiceInfo thatService = (ApduServiceInfo) o; - return thatService.getComponent().equals(this.getComponent()); + return thatService.getComponent().equals(this.getComponent()) + && thatService.getUid() == this.getUid(); } @Override @@ -619,8 +621,9 @@ public final class ApduServiceInfo implements Parcelable { }; public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { - pw.println(" " + getComponent() + - " (Description: " + getDescription() + ")"); + pw.println(" " + getComponent() + + " (Description: " + getDescription() + ")" + + " (UID: " + getUid() + ")"); if (mOnHost) { pw.println(" On Host Service"); } else { diff --git a/core/java/android/nfc/cardemulation/CardEmulation.java b/core/java/android/nfc/cardemulation/CardEmulation.java index d498535ce52c4..0a9fe90f25249 100644 --- a/core/java/android/nfc/cardemulation/CardEmulation.java +++ b/core/java/android/nfc/cardemulation/CardEmulation.java @@ -30,6 +30,7 @@ import android.content.pm.PackageManager; import android.nfc.INfcCardEmulation; import android.nfc.NfcAdapter; import android.os.RemoteException; +import android.os.UserHandle; import android.provider.Settings; import android.provider.Settings.SettingNotFoundException; import android.util.Log; @@ -82,6 +83,13 @@ public final class CardEmulation { */ public static final String EXTRA_SERVICE_COMPONENT = "component"; + /** + * The caller userId extra for {@link #ACTION_CHANGE_DEFAULT}. + * + * @see #ACTION_CHANGE_DEFAULT + */ + public static final String EXTRA_USERID = "android.nfc.cardemulation.extra.USERID"; + /** * Category used for NFC payment services. */ @@ -269,8 +277,8 @@ public final class CardEmulation { if (CATEGORY_PAYMENT.equals(category)) { boolean preferForeground = false; try { - preferForeground = Settings.Secure.getInt(mContext.getContentResolver(), - Settings.Secure.NFC_PAYMENT_FOREGROUND) != 0; + preferForeground = Settings.Secure.getIntForUser(mContext.getContentResolver(), + Settings.Secure.NFC_PAYMENT_FOREGROUND, UserHandle.myUserId()) != 0; } catch (SettingNotFoundException e) { } return preferForeground; @@ -826,6 +834,28 @@ public final class CardEmulation { } } + /** + * @hide + */ + public boolean setDefaultForNextTap(int userId, ComponentName service) { + try { + return sService.setDefaultForNextTap(userId, service); + } catch (RemoteException e) { + // Try one more time + recoverService(); + if (sService == null) { + Log.e(TAG, "Failed to recover CardEmulationService."); + return false; + } + try { + return sService.setDefaultForNextTap(userId, service); + } catch (RemoteException ee) { + Log.e(TAG, "Failed to reach CardEmulationService."); + return false; + } + } + } + /** * @hide */ @@ -848,6 +878,28 @@ public final class CardEmulation { } } + /** + * @hide + */ + public List getServices(String category, int userId) { + try { + return sService.getServices(userId, category); + } catch (RemoteException e) { + // Try one more time + recoverService(); + if (sService == null) { + Log.e(TAG, "Failed to recover CardEmulationService."); + return null; + } + try { + return sService.getServices(userId, category); + } catch (RemoteException ee) { + Log.e(TAG, "Failed to reach CardEmulationService."); + return null; + } + } + } + /** * A valid AID according to ISO/IEC 7816-4: *