Merge "NFC support in work profile" am: c2647199ce
Original change: https://android-review.googlesource.com/c/platform/packages/apps/Settings/+/1856215 Change-Id: Iac30f77fd5d732bb3b50fc531600fed02d477919
This commit is contained in:
@@ -21,12 +21,14 @@ import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.nfc.cardemulation.CardEmulation;
|
||||
import android.os.Bundle;
|
||||
import android.os.UserHandle;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.internal.app.AlertActivity;
|
||||
import com.android.internal.app.AlertController;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.nfc.PaymentBackend.PaymentAppInfo;
|
||||
import com.android.settings.nfc.PaymentBackend.PaymentInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -39,7 +41,7 @@ public final class PaymentDefaultDialog extends AlertActivity implements
|
||||
private static final int PAYMENT_APP_MAX_CAPTION_LENGTH = 40;
|
||||
|
||||
private PaymentBackend mBackend;
|
||||
private ComponentName mNewDefault;
|
||||
private PaymentInfo mNewDefault;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@@ -56,9 +58,10 @@ public final class PaymentDefaultDialog extends AlertActivity implements
|
||||
ComponentName component = intent.getParcelableExtra(
|
||||
CardEmulation.EXTRA_SERVICE_COMPONENT);
|
||||
String category = intent.getStringExtra(CardEmulation.EXTRA_CATEGORY);
|
||||
int userId = intent.getIntExtra(CardEmulation.EXTRA_USERID, UserHandle.myUserId());
|
||||
|
||||
setResult(RESULT_CANCELED);
|
||||
if (!buildDialog(component, category)) {
|
||||
if (!buildDialog(component, category, userId)) {
|
||||
finish();
|
||||
}
|
||||
|
||||
@@ -68,7 +71,7 @@ public final class PaymentDefaultDialog extends AlertActivity implements
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
switch (which) {
|
||||
case BUTTON_POSITIVE:
|
||||
mBackend.setDefaultPaymentApp(mNewDefault);
|
||||
mBackend.setDefaultPaymentApp(mNewDefault.componentName, mNewDefault.userId);
|
||||
setResult(RESULT_OK);
|
||||
break;
|
||||
case BUTTON_NEGATIVE:
|
||||
@@ -76,7 +79,7 @@ public final class PaymentDefaultDialog extends AlertActivity implements
|
||||
}
|
||||
}
|
||||
|
||||
private boolean buildDialog(ComponentName component, String category) {
|
||||
private boolean buildDialog(ComponentName component, String category, int userId) {
|
||||
if (component == null || category == null) {
|
||||
Log.e(TAG, "Component or category are null");
|
||||
return false;
|
||||
@@ -93,10 +96,12 @@ public final class PaymentDefaultDialog extends AlertActivity implements
|
||||
|
||||
List<PaymentAppInfo> services = mBackend.getPaymentAppInfos();
|
||||
for (PaymentAppInfo service : services) {
|
||||
if (component.equals(service.componentName)) {
|
||||
// check if userId matches
|
||||
if (component.equals(service.componentName)
|
||||
&& service.userHandle.getIdentifier() == userId) {
|
||||
requestedPaymentApp = service;
|
||||
}
|
||||
if (service.isDefault) {
|
||||
if (service.isDefault && service.userHandle.getIdentifier() == userId) {
|
||||
defaultPaymentApp = service;
|
||||
}
|
||||
}
|
||||
@@ -107,13 +112,17 @@ public final class PaymentDefaultDialog extends AlertActivity implements
|
||||
}
|
||||
|
||||
// Get current mode and default component
|
||||
ComponentName defaultComponent = mBackend.getDefaultPaymentApp();
|
||||
if (defaultComponent != null && defaultComponent.equals(component)) {
|
||||
PaymentInfo defaultComponent = mBackend.getDefaultPaymentApp();
|
||||
if (defaultComponent != null && defaultComponent.componentName.equals(component)
|
||||
&& defaultComponent.userId == userId) {
|
||||
Log.e(TAG, "Component " + component + " is already default.");
|
||||
return false;
|
||||
}
|
||||
|
||||
mNewDefault = component;
|
||||
mNewDefault = new PaymentInfo();
|
||||
mNewDefault.componentName = component;
|
||||
mNewDefault.userId = userId;
|
||||
|
||||
// Compose dialog; get
|
||||
final AlertController.AlertParams p = mAlertParams;
|
||||
if (defaultPaymentApp == null) {
|
||||
|
||||
Reference in New Issue
Block a user