diff options
author | Jack Yu <jackyu@google.com> | 2023-07-21 19:10:43 -0700 |
---|---|---|
committer | Jack Yu <jackyu@google.com> | 2023-07-23 12:20:31 -0700 |
commit | 2003d5142243d12c852997b1aea0fc374b4276ab (patch) | |
tree | fb9e0c162f669c181fc495114fba43360383d258 | |
parent | 23bf54028d7973975b2c8f7fd038e0fcb44e06aa (diff) | |
download | service_entitlement-2003d5142243d12c852997b1aea0fc374b4276ab.tar.gz |
Fixed incorrect nullability
Fix: 292303882
Test: atest service-entitlement-tests
Change-Id: Iac85a2088f2f1d10a57b953547b88de9f222ab1f
-rw-r--r-- | java/com/android/libraries/entitlement/ServiceEntitlement.java | 25 | ||||
-rw-r--r-- | java/com/android/libraries/entitlement/eapaka/EapAkaApi.java | 10 |
2 files changed, 23 insertions, 12 deletions
diff --git a/java/com/android/libraries/entitlement/ServiceEntitlement.java b/java/com/android/libraries/entitlement/ServiceEntitlement.java index a4c3b3b..398e0a9 100644 --- a/java/com/android/libraries/entitlement/ServiceEntitlement.java +++ b/java/com/android/libraries/entitlement/ServiceEntitlement.java @@ -18,7 +18,7 @@ package com.android.libraries.entitlement; import android.content.Context; -import androidx.annotation.Nullable; +import androidx.annotation.NonNull; import androidx.annotation.VisibleForTesting; import com.android.libraries.entitlement.eapaka.EapAkaApi; @@ -201,7 +201,7 @@ public class ServiceEntitlement { * @param appId an app ID string defined in TS.43 section 2.2, e.g. {@link #APP_VOWIFI}. * @param request contains parameters that can be used in the HTTP request. */ - @Nullable + @NonNull public String queryEntitlementStatus(String appId, ServiceEntitlementRequest request) throws ServiceEntitlementException { return queryEntitlementStatus(ImmutableList.of(appId), request); @@ -216,12 +216,11 @@ public class ServiceEntitlement { * multiple "app" parameters will be set in the HTTP request, in the order as they appear in * parameter {@code appIds}. */ - @Nullable + @NonNull public String queryEntitlementStatus(ImmutableList<String> appIds, ServiceEntitlementRequest request) throws ServiceEntitlementException { - HttpResponse response = getEntitlementStatusResponse(appIds, request); - return response == null ? null : response.body(); + return getEntitlementStatusResponse(appIds, request).body(); } /** @@ -232,7 +231,7 @@ public class ServiceEntitlement { * <p>Same as {@link #queryEntitlementStatus(ImmutableList, ServiceEntitlementRequest)} * except that it returns the full HTTP response instead of just the body. */ - @Nullable + @NonNull public HttpResponse getEntitlementStatusResponse(ImmutableList<String> appIds, ServiceEntitlementRequest request) throws ServiceEntitlementException { @@ -249,20 +248,21 @@ public class ServiceEntitlement { * needed, and returns the raw configuration doc as a string. Additional parameters from {@code * operation} are set to the HTTP request. See {@link EsimOdsaOperation} for details. */ + @NonNull public String performEsimOdsa( String appId, ServiceEntitlementRequest request, EsimOdsaOperation operation) throws ServiceEntitlementException { - HttpResponse response = getEsimOdsaResponse(appId, request, operation); - return response == null ? null : response.body(); + return getEsimOdsaResponse(appId, request, operation).body(); } /** * Retrieves the HTTP response after performing on device service activation (ODSA) of eSIM for * companion/primary devices. * - * <p>Same as {@link #performEsimOdsa(String, ServiceEntitlementRequest, OdsaOperation)} + * <p>Same as {@link #performEsimOdsa(String, ServiceEntitlementRequest, EsimOdsaOperation)} * except that it returns the full HTTP response instead of just the body. */ + @NonNull public HttpResponse getEsimOdsaResponse( String appId, ServiceEntitlementRequest request, EsimOdsaOperation operation) throws ServiceEntitlementException { @@ -280,6 +280,7 @@ public class ServiceEntitlement { * @param appId an app ID string defined in TS.43 section 2.2 * @param request contains parameters that can be used in the HTTP request */ + @NonNull public String acquireOidcAuthenticationEndpoint(String appId, ServiceEntitlementRequest request) throws ServiceEntitlementException { mOidcAcceptContentType = request.acceptContentType(); @@ -295,9 +296,9 @@ public class ServiceEntitlement { * * @param url the redirect url from OIDC authentication result. */ + @NonNull public String queryEntitlementStatusFromOidc(String url) throws ServiceEntitlementException { - HttpResponse response = getEntitlementStatusResponseFromOidc(url); - return response == null ? null : response.body(); + return getEntitlementStatusResponseFromOidc(url).body(); } /** @@ -309,6 +310,7 @@ public class ServiceEntitlement { * * @param url the redirect url from OIDC authentication result. */ + @NonNull public HttpResponse getEntitlementStatusResponseFromOidc(String url) throws ServiceEntitlementException { return eapAkaApi.queryEntitlementStatusFromOidc(url, carrierConfig, mOidcAcceptContentType); @@ -318,6 +320,7 @@ public class ServiceEntitlement { * Retrieves the history of past HTTP request and responses if {@code saveHttpHistory} was set * in constructor. */ + @NonNull public List<String> getHistory() { return eapAkaApi.getHistory(); } diff --git a/java/com/android/libraries/entitlement/eapaka/EapAkaApi.java b/java/com/android/libraries/entitlement/eapaka/EapAkaApi.java index adb4140..a54c669 100644 --- a/java/com/android/libraries/entitlement/eapaka/EapAkaApi.java +++ b/java/com/android/libraries/entitlement/eapaka/EapAkaApi.java @@ -26,6 +26,7 @@ import android.telephony.TelephonyManager; import android.text.TextUtils; import android.util.Log; +import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; @@ -135,7 +136,7 @@ public class EapAkaApi { * * @throws ServiceEntitlementException when getting an unexpected http response. */ - @Nullable + @NonNull public HttpResponse queryEntitlementStatus(ImmutableList<String> appIds, CarrierConfig carrierConfig, ServiceEntitlementRequest request) throws ServiceEntitlementException { @@ -188,6 +189,7 @@ public class EapAkaApi { * * @return Challenge response from server whose content type is JSON */ + @NonNull private HttpResponse respondToEapAkaChallenge( CarrierConfig carrierConfig, String eapAkaChallenge, @@ -256,6 +258,7 @@ public class EapAkaApi { } } + @NonNull private HttpResponse challengeResponse( String eapAkaChallengeResponse, CarrierConfig carrierConfig, @@ -292,6 +295,7 @@ public class EapAkaApi { * * <p>Implementation based on GSMA TS.43-v5.0 6.1. */ + @NonNull public HttpResponse performEsimOdsaOperation(String appId, CarrierConfig carrierConfig, ServiceEntitlementRequest request, EsimOdsaOperation odsaOperation) throws ServiceEntitlementException { @@ -337,6 +341,7 @@ public class EapAkaApi { * {@link #queryEntitlementStatusFromOidc(String, CarrierConfig, String)} with the * authentication result to retrieve the service entitlement configuration. */ + @NonNull public String acquireOidcAuthenticationEndpoint(String appId, CarrierConfig carrierConfig, ServiceEntitlementRequest request) throws ServiceEntitlementException { Uri.Builder urlBuilder = Uri.parse(carrierConfig.serverUrl()).buildUpon(); @@ -354,6 +359,7 @@ public class EapAkaApi { * * <p>{@link #acquireOidcAuthenticationEndpoint} must be called before calling this method. */ + @NonNull public HttpResponse queryEntitlementStatusFromOidc( String url, CarrierConfig carrierConfig, String acceptContentType) throws ServiceEntitlementException { @@ -468,6 +474,7 @@ public class EapAkaApi { odsaOperation.oldTerminalId()); } + @NonNull private HttpResponse httpGet(String url, CarrierConfig carrierConfig, String contentType) throws ServiceEntitlementException { HttpRequest httpRequest = @@ -545,6 +552,7 @@ public class EapAkaApi { /** * Retrieves the history of past HTTP request and responses. */ + @NonNull public List<String> getHistory() { return mHttpClient.getHistory(); } |