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

Commit e564fa29 authored by Alisher Alikhodjaev's avatar Alisher Alikhodjaev
Browse files

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

The former is a hidden API, the latter isn't.

Bug: 244264995
Test: build ok
Change-Id: Ie68aa00452cec96339c016634515593820243896
parent 6ffa5fcc
Loading
Loading
Loading
Loading
+41 −31
Original line number Diff line number Diff line
@@ -209,7 +209,8 @@ public final class CardEmulation {
     */
    public boolean isDefaultServiceForCategory(ComponentName service, String category) {
        try {
            return sService.isDefaultServiceForCategory(mContext.getUserId(), service, category);
            return sService.isDefaultServiceForCategory(mContext.getUser().getIdentifier(),
                    service, category);
        } catch (RemoteException e) {
            // Try one more time
            recoverService();
@@ -218,8 +219,8 @@ public final class CardEmulation {
                return false;
            }
            try {
                return sService.isDefaultServiceForCategory(mContext.getUserId(), service,
                        category);
                return sService.isDefaultServiceForCategory(mContext.getUser().getIdentifier(),
                        service, category);
            } catch (RemoteException ee) {
                Log.e(TAG, "Failed to recover CardEmulationService.");
                return false;
@@ -240,7 +241,8 @@ public final class CardEmulation {
     */
    public boolean isDefaultServiceForAid(ComponentName service, String aid) {
        try {
            return sService.isDefaultServiceForAid(mContext.getUserId(), service, aid);
            return sService.isDefaultServiceForAid(mContext.getUser().getIdentifier(),
                    service, aid);
        } catch (RemoteException e) {
            // Try one more time
            recoverService();
@@ -249,7 +251,8 @@ public final class CardEmulation {
                return false;
            }
            try {
                return sService.isDefaultServiceForAid(mContext.getUserId(), service, aid);
                return sService.isDefaultServiceForAid(mContext.getUser().getIdentifier(),
                        service, aid);
            } catch (RemoteException ee) {
                Log.e(TAG, "Failed to reach CardEmulationService.");
                return false;
@@ -348,7 +351,8 @@ public final class CardEmulation {
            List<String> aids) {
        AidGroup aidGroup = new AidGroup(aids, category);
        try {
            return sService.registerAidGroupForService(mContext.getUserId(), service, aidGroup);
            return sService.registerAidGroupForService(mContext.getUser().getIdentifier(),
                    service, aidGroup);
        } catch (RemoteException e) {
            // Try one more time
            recoverService();
@@ -357,8 +361,8 @@ public final class CardEmulation {
                return false;
            }
            try {
                return sService.registerAidGroupForService(mContext.getUserId(), service,
                        aidGroup);
                return sService.registerAidGroupForService(mContext.getUser().getIdentifier(),
                        service, aidGroup);
            } catch (RemoteException ee) {
                Log.e(TAG, "Failed to reach CardEmulationService.");
                return false;
@@ -391,7 +395,7 @@ public final class CardEmulation {
        }

        try {
            return sService.unsetOffHostForService(mContext.getUserId(), service);
            return sService.unsetOffHostForService(mContext.getUser().getIdentifier(), service);
        } catch (RemoteException e) {
            // Try one more time
            recoverService();
@@ -400,7 +404,7 @@ public final class CardEmulation {
                return false;
            }
            try {
                return sService.unsetOffHostForService(mContext.getUserId(), service);
                return sService.unsetOffHostForService(mContext.getUser().getIdentifier(), service);
            } catch (RemoteException ee) {
                Log.e(TAG, "Failed to reach CardEmulationService.");
                return false;
@@ -468,7 +472,7 @@ public final class CardEmulation {
        }

        try {
            return sService.setOffHostForService(mContext.getUserId(), service,
            return sService.setOffHostForService(mContext.getUser().getIdentifier(), service,
                offHostSecureElement);
        } catch (RemoteException e) {
            // Try one more time
@@ -478,7 +482,7 @@ public final class CardEmulation {
                return false;
            }
            try {
                return sService.setOffHostForService(mContext.getUserId(), service,
                return sService.setOffHostForService(mContext.getUser().getIdentifier(), service,
                        offHostSecureElement);
            } catch (RemoteException ee) {
                Log.e(TAG, "Failed to reach CardEmulationService.");
@@ -503,8 +507,8 @@ public final class CardEmulation {
     */
    public List<String> getAidsForService(ComponentName service, String category) {
        try {
            AidGroup group =  sService.getAidGroupForService(mContext.getUserId(), service,
                    category);
            AidGroup group =  sService.getAidGroupForService(mContext.getUser().getIdentifier(),
                    service, category);
            return (group != null ? group.getAids() : null);
        } catch (RemoteException e) {
            recoverService();
@@ -513,8 +517,8 @@ public final class CardEmulation {
                return null;
            }
            try {
                AidGroup group = sService.getAidGroupForService(mContext.getUserId(), service,
                        category);
                AidGroup group = sService.getAidGroupForService(mContext.getUser().getIdentifier(),
                        service, category);
                return (group != null ? group.getAids() : null);
            } catch (RemoteException ee) {
                Log.e(TAG, "Failed to recover CardEmulationService.");
@@ -540,7 +544,8 @@ public final class CardEmulation {
     */
    public boolean removeAidsForService(ComponentName service, String category) {
        try {
            return sService.removeAidGroupForService(mContext.getUserId(), service, category);
            return sService.removeAidGroupForService(mContext.getUser().getIdentifier(), service,
                    category);
        } catch (RemoteException e) {
            // Try one more time
            recoverService();
@@ -549,7 +554,8 @@ public final class CardEmulation {
                return false;
            }
            try {
                return sService.removeAidGroupForService(mContext.getUserId(), service, category);
                return sService.removeAidGroupForService(mContext.getUser().getIdentifier(),
                        service, category);
            } catch (RemoteException ee) {
                Log.e(TAG, "Failed to reach CardEmulationService.");
                return false;
@@ -684,7 +690,8 @@ public final class CardEmulation {
    @Nullable
    public List<String> getAidsForPreferredPaymentService() {
        try {
            ApduServiceInfo serviceInfo = sService.getPreferredPaymentService(mContext.getUserId());
            ApduServiceInfo serviceInfo = sService.getPreferredPaymentService(
                    mContext.getUser().getIdentifier());
            return (serviceInfo != null ? serviceInfo.getAids() : null);
        } catch (RemoteException e) {
            recoverService();
@@ -694,7 +701,7 @@ public final class CardEmulation {
            }
            try {
                ApduServiceInfo serviceInfo =
                        sService.getPreferredPaymentService(mContext.getUserId());
                        sService.getPreferredPaymentService(mContext.getUser().getIdentifier());
                return (serviceInfo != null ? serviceInfo.getAids() : null);
            } catch (RemoteException ee) {
                Log.e(TAG, "Failed to recover CardEmulationService.");
@@ -723,7 +730,8 @@ public final class CardEmulation {
    @Nullable
    public String getRouteDestinationForPreferredPaymentService() {
        try {
            ApduServiceInfo serviceInfo = sService.getPreferredPaymentService(mContext.getUserId());
            ApduServiceInfo serviceInfo = sService.getPreferredPaymentService(
                    mContext.getUser().getIdentifier());
            if (serviceInfo != null) {
                if (!serviceInfo.isOnHost()) {
                    return serviceInfo.getOffHostSecureElement() == null ?
@@ -740,7 +748,7 @@ public final class CardEmulation {
            }
            try {
                ApduServiceInfo serviceInfo =
                        sService.getPreferredPaymentService(mContext.getUserId());
                        sService.getPreferredPaymentService(mContext.getUser().getIdentifier());
                if (serviceInfo != null) {
                    if (!serviceInfo.isOnHost()) {
                        return serviceInfo.getOffHostSecureElement() == null ?
@@ -766,7 +774,8 @@ public final class CardEmulation {
    @Nullable
    public CharSequence getDescriptionForPreferredPaymentService() {
        try {
            ApduServiceInfo serviceInfo = sService.getPreferredPaymentService(mContext.getUserId());
            ApduServiceInfo serviceInfo = sService.getPreferredPaymentService(
                    mContext.getUser().getIdentifier());
            return (serviceInfo != null ? serviceInfo.getDescription() : null);
        } catch (RemoteException e) {
            recoverService();
@@ -776,7 +785,7 @@ public final class CardEmulation {
            }
            try {
                ApduServiceInfo serviceInfo =
                        sService.getPreferredPaymentService(mContext.getUserId());
                        sService.getPreferredPaymentService(mContext.getUser().getIdentifier());
                return (serviceInfo != null ? serviceInfo.getDescription() : null);
            } catch (RemoteException ee) {
                Log.e(TAG, "Failed to recover CardEmulationService.");
@@ -790,7 +799,8 @@ public final class CardEmulation {
     */
    public boolean setDefaultServiceForCategory(ComponentName service, String category) {
        try {
            return sService.setDefaultServiceForCategory(mContext.getUserId(), service, category);
            return sService.setDefaultServiceForCategory(mContext.getUser().getIdentifier(),
                    service, category);
        } catch (RemoteException e) {
            // Try one more time
            recoverService();
@@ -799,8 +809,8 @@ public final class CardEmulation {
                return false;
            }
            try {
                return sService.setDefaultServiceForCategory(mContext.getUserId(), service,
                        category);
                return sService.setDefaultServiceForCategory(mContext.getUser().getIdentifier(),
                        service, category);
            } catch (RemoteException ee) {
                Log.e(TAG, "Failed to reach CardEmulationService.");
                return false;
@@ -813,7 +823,7 @@ public final class CardEmulation {
     */
    public boolean setDefaultForNextTap(ComponentName service) {
        try {
            return sService.setDefaultForNextTap(mContext.getUserId(), service);
            return sService.setDefaultForNextTap(mContext.getUser().getIdentifier(), service);
        } catch (RemoteException e) {
            // Try one more time
            recoverService();
@@ -822,7 +832,7 @@ public final class CardEmulation {
                return false;
            }
            try {
                return sService.setDefaultForNextTap(mContext.getUserId(), service);
                return sService.setDefaultForNextTap(mContext.getUser().getIdentifier(), service);
            } catch (RemoteException ee) {
                Log.e(TAG, "Failed to reach CardEmulationService.");
                return false;
@@ -857,7 +867,7 @@ public final class CardEmulation {
     */
    public List<ApduServiceInfo> getServices(String category) {
        try {
            return sService.getServices(mContext.getUserId(), category);
            return sService.getServices(mContext.getUser().getIdentifier(), category);
        } catch (RemoteException e) {
            // Try one more time
            recoverService();
@@ -866,7 +876,7 @@ public final class CardEmulation {
                return null;
            }
            try {
                return sService.getServices(mContext.getUserId(), category);
                return sService.getServices(mContext.getUser().getIdentifier(), category);
            } catch (RemoteException ee) {
                Log.e(TAG, "Failed to reach CardEmulationService.");
                return null;
+14 −12
Original line number Diff line number Diff line
@@ -117,7 +117,7 @@ public final class NfcFCardEmulation {
            throw new NullPointerException("service is null");
        }
        try {
            return sService.getSystemCodeForService(mContext.getUserId(), service);
            return sService.getSystemCodeForService(mContext.getUser().getIdentifier(), service);
        } catch (RemoteException e) {
            // Try one more time
            recoverService();
@@ -126,7 +126,8 @@ public final class NfcFCardEmulation {
                return null;
            }
            try {
                return sService.getSystemCodeForService(mContext.getUserId(), service);
                return sService.getSystemCodeForService(mContext.getUser().getIdentifier(),
                        service);
            } catch (RemoteException ee) {
                Log.e(TAG, "Failed to reach CardEmulationService.");
                ee.rethrowAsRuntimeException();
@@ -163,7 +164,7 @@ public final class NfcFCardEmulation {
            throw new NullPointerException("service or systemCode is null");
        }
        try {
            return sService.registerSystemCodeForService(mContext.getUserId(),
            return sService.registerSystemCodeForService(mContext.getUser().getIdentifier(),
                    service, systemCode);
        } catch (RemoteException e) {
            // Try one more time
@@ -173,7 +174,7 @@ public final class NfcFCardEmulation {
                return false;
            }
            try {
                return sService.registerSystemCodeForService(mContext.getUserId(),
                return sService.registerSystemCodeForService(mContext.getUser().getIdentifier(),
                        service, systemCode);
            } catch (RemoteException ee) {
                Log.e(TAG, "Failed to reach CardEmulationService.");
@@ -194,7 +195,7 @@ public final class NfcFCardEmulation {
            throw new NullPointerException("service is null");
        }
        try {
            return sService.removeSystemCodeForService(mContext.getUserId(), service);
            return sService.removeSystemCodeForService(mContext.getUser().getIdentifier(), service);
        } catch (RemoteException e) {
            // Try one more time
            recoverService();
@@ -203,7 +204,8 @@ public final class NfcFCardEmulation {
                return false;
            }
            try {
                return sService.removeSystemCodeForService(mContext.getUserId(), service);
                return sService.removeSystemCodeForService(mContext.getUser().getIdentifier(),
                        service);
            } catch (RemoteException ee) {
                Log.e(TAG, "Failed to reach CardEmulationService.");
                ee.rethrowAsRuntimeException();
@@ -229,7 +231,7 @@ public final class NfcFCardEmulation {
            throw new NullPointerException("service is null");
        }
        try {
            return sService.getNfcid2ForService(mContext.getUserId(), service);
            return sService.getNfcid2ForService(mContext.getUser().getIdentifier(), service);
        } catch (RemoteException e) {
            // Try one more time
            recoverService();
@@ -238,7 +240,7 @@ public final class NfcFCardEmulation {
                return null;
            }
            try {
                return sService.getNfcid2ForService(mContext.getUserId(), service);
                return sService.getNfcid2ForService(mContext.getUser().getIdentifier(), service);
            } catch (RemoteException ee) {
                Log.e(TAG, "Failed to reach CardEmulationService.");
                ee.rethrowAsRuntimeException();
@@ -272,7 +274,7 @@ public final class NfcFCardEmulation {
            throw new NullPointerException("service or nfcid2 is null");
        }
        try {
            return sService.setNfcid2ForService(mContext.getUserId(),
            return sService.setNfcid2ForService(mContext.getUser().getIdentifier(),
                    service, nfcid2);
        } catch (RemoteException e) {
            // Try one more time
@@ -282,7 +284,7 @@ public final class NfcFCardEmulation {
                return false;
            }
            try {
                return sService.setNfcid2ForService(mContext.getUserId(),
                return sService.setNfcid2ForService(mContext.getUser().getIdentifier(),
                        service, nfcid2);
            } catch (RemoteException ee) {
                Log.e(TAG, "Failed to reach CardEmulationService.");
@@ -380,7 +382,7 @@ public final class NfcFCardEmulation {
     */
    public List<NfcFServiceInfo> getNfcFServices() {
        try {
            return sService.getNfcFServices(mContext.getUserId());
            return sService.getNfcFServices(mContext.getUser().getIdentifier());
        } catch (RemoteException e) {
            // Try one more time
            recoverService();
@@ -389,7 +391,7 @@ public final class NfcFCardEmulation {
                return null;
            }
            try {
                return sService.getNfcFServices(mContext.getUserId());
                return sService.getNfcFServices(mContext.getUser().getIdentifier());
            } catch (RemoteException ee) {
                Log.e(TAG, "Failed to reach CardEmulationService.");
                return null;