NFC support in work profile
Add one function to get service based on user id. Add one function to set deafult for next tap based on user id. Bug: 202367033 Test: mauanl tests Change-Id: Ib5bd36528c0d398215b078dbbd4f19305ce1402c
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
@@ -269,8 +270,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 +827,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 +871,28 @@ public final class CardEmulation {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
public List<ApduServiceInfo> 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:
|
||||
* <ul>
|
||||
|
||||
Reference in New Issue
Block a user