Merge "Replace usages of Context.getUserId() by Context.getUser()"

This commit is contained in:
Alisher Alikhodjaev
2022-09-30 01:23:49 +00:00
committed by Gerrit Code Review
2 changed files with 55 additions and 43 deletions

View File

@@ -209,7 +209,8 @@ public final class CardEmulation {
*/ */
public boolean isDefaultServiceForCategory(ComponentName service, String category) { public boolean isDefaultServiceForCategory(ComponentName service, String category) {
try { try {
return sService.isDefaultServiceForCategory(mContext.getUserId(), service, category); return sService.isDefaultServiceForCategory(mContext.getUser().getIdentifier(),
service, category);
} catch (RemoteException e) { } catch (RemoteException e) {
// Try one more time // Try one more time
recoverService(); recoverService();
@@ -218,8 +219,8 @@ public final class CardEmulation {
return false; return false;
} }
try { try {
return sService.isDefaultServiceForCategory(mContext.getUserId(), service, return sService.isDefaultServiceForCategory(mContext.getUser().getIdentifier(),
category); service, category);
} catch (RemoteException ee) { } catch (RemoteException ee) {
Log.e(TAG, "Failed to recover CardEmulationService."); Log.e(TAG, "Failed to recover CardEmulationService.");
return false; return false;
@@ -240,7 +241,8 @@ public final class CardEmulation {
*/ */
public boolean isDefaultServiceForAid(ComponentName service, String aid) { public boolean isDefaultServiceForAid(ComponentName service, String aid) {
try { try {
return sService.isDefaultServiceForAid(mContext.getUserId(), service, aid); return sService.isDefaultServiceForAid(mContext.getUser().getIdentifier(),
service, aid);
} catch (RemoteException e) { } catch (RemoteException e) {
// Try one more time // Try one more time
recoverService(); recoverService();
@@ -249,7 +251,8 @@ public final class CardEmulation {
return false; return false;
} }
try { try {
return sService.isDefaultServiceForAid(mContext.getUserId(), service, aid); return sService.isDefaultServiceForAid(mContext.getUser().getIdentifier(),
service, aid);
} catch (RemoteException ee) { } catch (RemoteException ee) {
Log.e(TAG, "Failed to reach CardEmulationService."); Log.e(TAG, "Failed to reach CardEmulationService.");
return false; return false;
@@ -348,7 +351,8 @@ public final class CardEmulation {
List<String> aids) { List<String> aids) {
AidGroup aidGroup = new AidGroup(aids, category); AidGroup aidGroup = new AidGroup(aids, category);
try { try {
return sService.registerAidGroupForService(mContext.getUserId(), service, aidGroup); return sService.registerAidGroupForService(mContext.getUser().getIdentifier(),
service, aidGroup);
} catch (RemoteException e) { } catch (RemoteException e) {
// Try one more time // Try one more time
recoverService(); recoverService();
@@ -357,8 +361,8 @@ public final class CardEmulation {
return false; return false;
} }
try { try {
return sService.registerAidGroupForService(mContext.getUserId(), service, return sService.registerAidGroupForService(mContext.getUser().getIdentifier(),
aidGroup); service, aidGroup);
} catch (RemoteException ee) { } catch (RemoteException ee) {
Log.e(TAG, "Failed to reach CardEmulationService."); Log.e(TAG, "Failed to reach CardEmulationService.");
return false; return false;
@@ -391,7 +395,7 @@ public final class CardEmulation {
} }
try { try {
return sService.unsetOffHostForService(mContext.getUserId(), service); return sService.unsetOffHostForService(mContext.getUser().getIdentifier(), service);
} catch (RemoteException e) { } catch (RemoteException e) {
// Try one more time // Try one more time
recoverService(); recoverService();
@@ -400,7 +404,7 @@ public final class CardEmulation {
return false; return false;
} }
try { try {
return sService.unsetOffHostForService(mContext.getUserId(), service); return sService.unsetOffHostForService(mContext.getUser().getIdentifier(), service);
} catch (RemoteException ee) { } catch (RemoteException ee) {
Log.e(TAG, "Failed to reach CardEmulationService."); Log.e(TAG, "Failed to reach CardEmulationService.");
return false; return false;
@@ -468,7 +472,7 @@ public final class CardEmulation {
} }
try { try {
return sService.setOffHostForService(mContext.getUserId(), service, return sService.setOffHostForService(mContext.getUser().getIdentifier(), service,
offHostSecureElement); offHostSecureElement);
} catch (RemoteException e) { } catch (RemoteException e) {
// Try one more time // Try one more time
@@ -478,7 +482,7 @@ public final class CardEmulation {
return false; return false;
} }
try { try {
return sService.setOffHostForService(mContext.getUserId(), service, return sService.setOffHostForService(mContext.getUser().getIdentifier(), service,
offHostSecureElement); offHostSecureElement);
} catch (RemoteException ee) { } catch (RemoteException ee) {
Log.e(TAG, "Failed to reach CardEmulationService."); Log.e(TAG, "Failed to reach CardEmulationService.");
@@ -503,8 +507,8 @@ public final class CardEmulation {
*/ */
public List<String> getAidsForService(ComponentName service, String category) { public List<String> getAidsForService(ComponentName service, String category) {
try { try {
AidGroup group = sService.getAidGroupForService(mContext.getUserId(), service, AidGroup group = sService.getAidGroupForService(mContext.getUser().getIdentifier(),
category); service, category);
return (group != null ? group.getAids() : null); return (group != null ? group.getAids() : null);
} catch (RemoteException e) { } catch (RemoteException e) {
recoverService(); recoverService();
@@ -513,8 +517,8 @@ public final class CardEmulation {
return null; return null;
} }
try { try {
AidGroup group = sService.getAidGroupForService(mContext.getUserId(), service, AidGroup group = sService.getAidGroupForService(mContext.getUser().getIdentifier(),
category); service, category);
return (group != null ? group.getAids() : null); return (group != null ? group.getAids() : null);
} catch (RemoteException ee) { } catch (RemoteException ee) {
Log.e(TAG, "Failed to recover CardEmulationService."); Log.e(TAG, "Failed to recover CardEmulationService.");
@@ -540,7 +544,8 @@ public final class CardEmulation {
*/ */
public boolean removeAidsForService(ComponentName service, String category) { public boolean removeAidsForService(ComponentName service, String category) {
try { try {
return sService.removeAidGroupForService(mContext.getUserId(), service, category); return sService.removeAidGroupForService(mContext.getUser().getIdentifier(), service,
category);
} catch (RemoteException e) { } catch (RemoteException e) {
// Try one more time // Try one more time
recoverService(); recoverService();
@@ -549,7 +554,8 @@ public final class CardEmulation {
return false; return false;
} }
try { try {
return sService.removeAidGroupForService(mContext.getUserId(), service, category); return sService.removeAidGroupForService(mContext.getUser().getIdentifier(),
service, category);
} catch (RemoteException ee) { } catch (RemoteException ee) {
Log.e(TAG, "Failed to reach CardEmulationService."); Log.e(TAG, "Failed to reach CardEmulationService.");
return false; return false;
@@ -684,7 +690,8 @@ public final class CardEmulation {
@Nullable @Nullable
public List<String> getAidsForPreferredPaymentService() { public List<String> getAidsForPreferredPaymentService() {
try { try {
ApduServiceInfo serviceInfo = sService.getPreferredPaymentService(mContext.getUserId()); ApduServiceInfo serviceInfo = sService.getPreferredPaymentService(
mContext.getUser().getIdentifier());
return (serviceInfo != null ? serviceInfo.getAids() : null); return (serviceInfo != null ? serviceInfo.getAids() : null);
} catch (RemoteException e) { } catch (RemoteException e) {
recoverService(); recoverService();
@@ -694,7 +701,7 @@ public final class CardEmulation {
} }
try { try {
ApduServiceInfo serviceInfo = ApduServiceInfo serviceInfo =
sService.getPreferredPaymentService(mContext.getUserId()); sService.getPreferredPaymentService(mContext.getUser().getIdentifier());
return (serviceInfo != null ? serviceInfo.getAids() : null); return (serviceInfo != null ? serviceInfo.getAids() : null);
} catch (RemoteException ee) { } catch (RemoteException ee) {
Log.e(TAG, "Failed to recover CardEmulationService."); Log.e(TAG, "Failed to recover CardEmulationService.");
@@ -723,7 +730,8 @@ public final class CardEmulation {
@Nullable @Nullable
public String getRouteDestinationForPreferredPaymentService() { public String getRouteDestinationForPreferredPaymentService() {
try { try {
ApduServiceInfo serviceInfo = sService.getPreferredPaymentService(mContext.getUserId()); ApduServiceInfo serviceInfo = sService.getPreferredPaymentService(
mContext.getUser().getIdentifier());
if (serviceInfo != null) { if (serviceInfo != null) {
if (!serviceInfo.isOnHost()) { if (!serviceInfo.isOnHost()) {
return serviceInfo.getOffHostSecureElement() == null ? return serviceInfo.getOffHostSecureElement() == null ?
@@ -740,7 +748,7 @@ public final class CardEmulation {
} }
try { try {
ApduServiceInfo serviceInfo = ApduServiceInfo serviceInfo =
sService.getPreferredPaymentService(mContext.getUserId()); sService.getPreferredPaymentService(mContext.getUser().getIdentifier());
if (serviceInfo != null) { if (serviceInfo != null) {
if (!serviceInfo.isOnHost()) { if (!serviceInfo.isOnHost()) {
return serviceInfo.getOffHostSecureElement() == null ? return serviceInfo.getOffHostSecureElement() == null ?
@@ -766,7 +774,8 @@ public final class CardEmulation {
@Nullable @Nullable
public CharSequence getDescriptionForPreferredPaymentService() { public CharSequence getDescriptionForPreferredPaymentService() {
try { try {
ApduServiceInfo serviceInfo = sService.getPreferredPaymentService(mContext.getUserId()); ApduServiceInfo serviceInfo = sService.getPreferredPaymentService(
mContext.getUser().getIdentifier());
return (serviceInfo != null ? serviceInfo.getDescription() : null); return (serviceInfo != null ? serviceInfo.getDescription() : null);
} catch (RemoteException e) { } catch (RemoteException e) {
recoverService(); recoverService();
@@ -776,7 +785,7 @@ public final class CardEmulation {
} }
try { try {
ApduServiceInfo serviceInfo = ApduServiceInfo serviceInfo =
sService.getPreferredPaymentService(mContext.getUserId()); sService.getPreferredPaymentService(mContext.getUser().getIdentifier());
return (serviceInfo != null ? serviceInfo.getDescription() : null); return (serviceInfo != null ? serviceInfo.getDescription() : null);
} catch (RemoteException ee) { } catch (RemoteException ee) {
Log.e(TAG, "Failed to recover CardEmulationService."); Log.e(TAG, "Failed to recover CardEmulationService.");
@@ -790,7 +799,8 @@ public final class CardEmulation {
*/ */
public boolean setDefaultServiceForCategory(ComponentName service, String category) { public boolean setDefaultServiceForCategory(ComponentName service, String category) {
try { try {
return sService.setDefaultServiceForCategory(mContext.getUserId(), service, category); return sService.setDefaultServiceForCategory(mContext.getUser().getIdentifier(),
service, category);
} catch (RemoteException e) { } catch (RemoteException e) {
// Try one more time // Try one more time
recoverService(); recoverService();
@@ -799,8 +809,8 @@ public final class CardEmulation {
return false; return false;
} }
try { try {
return sService.setDefaultServiceForCategory(mContext.getUserId(), service, return sService.setDefaultServiceForCategory(mContext.getUser().getIdentifier(),
category); service, category);
} catch (RemoteException ee) { } catch (RemoteException ee) {
Log.e(TAG, "Failed to reach CardEmulationService."); Log.e(TAG, "Failed to reach CardEmulationService.");
return false; return false;
@@ -813,7 +823,7 @@ public final class CardEmulation {
*/ */
public boolean setDefaultForNextTap(ComponentName service) { public boolean setDefaultForNextTap(ComponentName service) {
try { try {
return sService.setDefaultForNextTap(mContext.getUserId(), service); return sService.setDefaultForNextTap(mContext.getUser().getIdentifier(), service);
} catch (RemoteException e) { } catch (RemoteException e) {
// Try one more time // Try one more time
recoverService(); recoverService();
@@ -822,7 +832,7 @@ public final class CardEmulation {
return false; return false;
} }
try { try {
return sService.setDefaultForNextTap(mContext.getUserId(), service); return sService.setDefaultForNextTap(mContext.getUser().getIdentifier(), service);
} catch (RemoteException ee) { } catch (RemoteException ee) {
Log.e(TAG, "Failed to reach CardEmulationService."); Log.e(TAG, "Failed to reach CardEmulationService.");
return false; return false;
@@ -857,7 +867,7 @@ public final class CardEmulation {
*/ */
public List<ApduServiceInfo> getServices(String category) { public List<ApduServiceInfo> getServices(String category) {
try { try {
return sService.getServices(mContext.getUserId(), category); return sService.getServices(mContext.getUser().getIdentifier(), category);
} catch (RemoteException e) { } catch (RemoteException e) {
// Try one more time // Try one more time
recoverService(); recoverService();
@@ -866,7 +876,7 @@ public final class CardEmulation {
return null; return null;
} }
try { try {
return sService.getServices(mContext.getUserId(), category); return sService.getServices(mContext.getUser().getIdentifier(), category);
} catch (RemoteException ee) { } catch (RemoteException ee) {
Log.e(TAG, "Failed to reach CardEmulationService."); Log.e(TAG, "Failed to reach CardEmulationService.");
return null; return null;

View File

@@ -117,7 +117,7 @@ public final class NfcFCardEmulation {
throw new NullPointerException("service is null"); throw new NullPointerException("service is null");
} }
try { try {
return sService.getSystemCodeForService(mContext.getUserId(), service); return sService.getSystemCodeForService(mContext.getUser().getIdentifier(), service);
} catch (RemoteException e) { } catch (RemoteException e) {
// Try one more time // Try one more time
recoverService(); recoverService();
@@ -126,7 +126,8 @@ public final class NfcFCardEmulation {
return null; return null;
} }
try { try {
return sService.getSystemCodeForService(mContext.getUserId(), service); return sService.getSystemCodeForService(mContext.getUser().getIdentifier(),
service);
} catch (RemoteException ee) { } catch (RemoteException ee) {
Log.e(TAG, "Failed to reach CardEmulationService."); Log.e(TAG, "Failed to reach CardEmulationService.");
ee.rethrowAsRuntimeException(); ee.rethrowAsRuntimeException();
@@ -163,7 +164,7 @@ public final class NfcFCardEmulation {
throw new NullPointerException("service or systemCode is null"); throw new NullPointerException("service or systemCode is null");
} }
try { try {
return sService.registerSystemCodeForService(mContext.getUserId(), return sService.registerSystemCodeForService(mContext.getUser().getIdentifier(),
service, systemCode); service, systemCode);
} catch (RemoteException e) { } catch (RemoteException e) {
// Try one more time // Try one more time
@@ -173,7 +174,7 @@ public final class NfcFCardEmulation {
return false; return false;
} }
try { try {
return sService.registerSystemCodeForService(mContext.getUserId(), return sService.registerSystemCodeForService(mContext.getUser().getIdentifier(),
service, systemCode); service, systemCode);
} catch (RemoteException ee) { } catch (RemoteException ee) {
Log.e(TAG, "Failed to reach CardEmulationService."); Log.e(TAG, "Failed to reach CardEmulationService.");
@@ -194,7 +195,7 @@ public final class NfcFCardEmulation {
throw new NullPointerException("service is null"); throw new NullPointerException("service is null");
} }
try { try {
return sService.removeSystemCodeForService(mContext.getUserId(), service); return sService.removeSystemCodeForService(mContext.getUser().getIdentifier(), service);
} catch (RemoteException e) { } catch (RemoteException e) {
// Try one more time // Try one more time
recoverService(); recoverService();
@@ -203,7 +204,8 @@ public final class NfcFCardEmulation {
return false; return false;
} }
try { try {
return sService.removeSystemCodeForService(mContext.getUserId(), service); return sService.removeSystemCodeForService(mContext.getUser().getIdentifier(),
service);
} catch (RemoteException ee) { } catch (RemoteException ee) {
Log.e(TAG, "Failed to reach CardEmulationService."); Log.e(TAG, "Failed to reach CardEmulationService.");
ee.rethrowAsRuntimeException(); ee.rethrowAsRuntimeException();
@@ -229,7 +231,7 @@ public final class NfcFCardEmulation {
throw new NullPointerException("service is null"); throw new NullPointerException("service is null");
} }
try { try {
return sService.getNfcid2ForService(mContext.getUserId(), service); return sService.getNfcid2ForService(mContext.getUser().getIdentifier(), service);
} catch (RemoteException e) { } catch (RemoteException e) {
// Try one more time // Try one more time
recoverService(); recoverService();
@@ -238,7 +240,7 @@ public final class NfcFCardEmulation {
return null; return null;
} }
try { try {
return sService.getNfcid2ForService(mContext.getUserId(), service); return sService.getNfcid2ForService(mContext.getUser().getIdentifier(), service);
} catch (RemoteException ee) { } catch (RemoteException ee) {
Log.e(TAG, "Failed to reach CardEmulationService."); Log.e(TAG, "Failed to reach CardEmulationService.");
ee.rethrowAsRuntimeException(); ee.rethrowAsRuntimeException();
@@ -272,7 +274,7 @@ public final class NfcFCardEmulation {
throw new NullPointerException("service or nfcid2 is null"); throw new NullPointerException("service or nfcid2 is null");
} }
try { try {
return sService.setNfcid2ForService(mContext.getUserId(), return sService.setNfcid2ForService(mContext.getUser().getIdentifier(),
service, nfcid2); service, nfcid2);
} catch (RemoteException e) { } catch (RemoteException e) {
// Try one more time // Try one more time
@@ -282,7 +284,7 @@ public final class NfcFCardEmulation {
return false; return false;
} }
try { try {
return sService.setNfcid2ForService(mContext.getUserId(), return sService.setNfcid2ForService(mContext.getUser().getIdentifier(),
service, nfcid2); service, nfcid2);
} catch (RemoteException ee) { } catch (RemoteException ee) {
Log.e(TAG, "Failed to reach CardEmulationService."); Log.e(TAG, "Failed to reach CardEmulationService.");
@@ -380,7 +382,7 @@ public final class NfcFCardEmulation {
*/ */
public List<NfcFServiceInfo> getNfcFServices() { public List<NfcFServiceInfo> getNfcFServices() {
try { try {
return sService.getNfcFServices(mContext.getUserId()); return sService.getNfcFServices(mContext.getUser().getIdentifier());
} catch (RemoteException e) { } catch (RemoteException e) {
// Try one more time // Try one more time
recoverService(); recoverService();
@@ -389,7 +391,7 @@ public final class NfcFCardEmulation {
return null; return null;
} }
try { try {
return sService.getNfcFServices(mContext.getUserId()); return sService.getNfcFServices(mContext.getUser().getIdentifier());
} catch (RemoteException ee) { } catch (RemoteException ee) {
Log.e(TAG, "Failed to reach CardEmulationService."); Log.e(TAG, "Failed to reach CardEmulationService.");
return null; return null;