diff options
author | Sarah Chin <sarahchin@google.com> | 2023-08-24 17:20:26 -0700 |
---|---|---|
committer | Sarah Chin <sarahchin@google.com> | 2023-10-17 15:47:23 -0700 |
commit | 3ea6fb00730c9cc4edd12169a4f4e755b096146d (patch) | |
tree | c465fdebb82803186cac4b43ee2a03acc2368287 | |
parent | 72a73b5c5ec0d94c0fac279e0e3ab4705f502aa9 (diff) | |
download | service_entitlement-3ea6fb00730c9cc4edd12169a4f4e755b096146d.tar.gz |
Add support for EAP-AKA authentication bypass
Bypass by running the following commands on a userdebug build, where
<response> should be the expected response from an EAP-AKA request.
adb root
adb shell setprop persist.entitlement.fake_eap_aka_response <response>
Test: manual testing
Change-Id: I7b155c70a7d769f27c8bec9e94611be7e528c9cf
-rw-r--r-- | java/com/android/libraries/entitlement/ServiceEntitlement.java | 10 | ||||
-rw-r--r-- | java/com/android/libraries/entitlement/utils/DebugUtils.java | 24 |
2 files changed, 27 insertions, 7 deletions
diff --git a/java/com/android/libraries/entitlement/ServiceEntitlement.java b/java/com/android/libraries/entitlement/ServiceEntitlement.java index 5151c32..0ced9e0 100644 --- a/java/com/android/libraries/entitlement/ServiceEntitlement.java +++ b/java/com/android/libraries/entitlement/ServiceEntitlement.java @@ -23,6 +23,7 @@ import androidx.annotation.VisibleForTesting; import com.android.libraries.entitlement.eapaka.EapAkaApi; import com.android.libraries.entitlement.http.HttpResponse; +import com.android.libraries.entitlement.utils.DebugUtils; import com.android.libraries.entitlement.utils.Ts43Constants; import com.google.common.collect.ImmutableList; @@ -98,12 +99,7 @@ public class ServiceEntitlement { * for how to get the subscription ID. */ public ServiceEntitlement(Context context, CarrierConfig carrierConfig, int simSubscriptionId) { - this( - context, - carrierConfig, - simSubscriptionId, - /* saveHttpHistory= */ false, - /* bypassEapAkaResponse= */ ""); + this(context, carrierConfig, simSubscriptionId, /* saveHttpHistory= */ false); } /** @@ -128,7 +124,7 @@ public class ServiceEntitlement { carrierConfig, simSubscriptionId, saveHttpHistory, - /* bypassEapAkaResponse= */ ""); + DebugUtils.getBypassEapAkaResponse()); } /** diff --git a/java/com/android/libraries/entitlement/utils/DebugUtils.java b/java/com/android/libraries/entitlement/utils/DebugUtils.java index 062c9b4..d89c572 100644 --- a/java/com/android/libraries/entitlement/utils/DebugUtils.java +++ b/java/com/android/libraries/entitlement/utils/DebugUtils.java @@ -18,14 +18,19 @@ package com.android.libraries.entitlement.utils; import android.os.Build; import android.os.SystemProperties; +import android.text.TextUtils; import android.util.Log; +import androidx.annotation.NonNull; + /** Provides API for debugging and not allow to debug on user build. */ public final class DebugUtils { private static final String TAG = "ServiceEntitlement"; private static final String PROP_PII_LOGGABLE = "dbg.se.pii_loggable"; private static final String BUILD_TYPE_USER = "user"; + private static final String PROP_FAKE_EAP_AKA_RESPONSE = + "persist.entitlement.fake_eap_aka_response"; private DebugUtils() {} @@ -36,6 +41,25 @@ public final class DebugUtils { } } + /** + * Get the bypass EAP-AKA response. This is only available on debug builds and can be set by + * running the following commands, where {@code response} should be the expected response from + * an EAP-AKA request: + * adb root + * adb shell setprop persist.entitlement.fake_eap_aka_response response + * + * @return The bypass EAP-AKA response, or an empty string if it is either not set or the device + * is not on a debug build. + */ + @NonNull + public static String getBypassEapAkaResponse() { + String bypassResponse = SystemProperties.get(PROP_FAKE_EAP_AKA_RESPONSE); + if (TextUtils.isEmpty(bypassResponse) || !isDebugBuild()) { + return ""; + } + return bypassResponse; + } + private static boolean isDebugBuild() { return !BUILD_TYPE_USER.equals(Build.TYPE); } |