From b14cd877fbb9debf73712d8c3ab25d74202cff40 Mon Sep 17 00:00:00 2001 From: Junyu Lai Date: Fri, 6 Dec 2024 17:15:32 +0800 Subject: [PATCH] Disable multi-user check for entitlement provisioning This commit updates the logic for launching the entitlement UI for tethering when there are multiple users. It disables the check for whether the current user can change tethering settings for secondary users due to a potential issue with calling createContextAsUser. This reverts the behavior change introduced in aosp/3289821. One expected outcome is this change will break tethering with entilement check enabled for HSUM-enabled devices. Since there is no currently HSUM-enabled projects, disable this check is safe. Test: Manual 1. Mock requires entitlement 2. adb shell cmd user set-system-user-mode-emulation headless 3. enable hotspot Test: atest TetheringTests:EntitlementManagerTest Bug: 382624069 Change-Id: Ife3b721d1374602a8fa760954b372429cda1bf71 --- .../networkstack/tethering/EntitlementManager.java | 4 +++- .../tethering/EntitlementManagerTest.java | 11 +---------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/Tethering/src/com/android/networkstack/tethering/EntitlementManager.java b/Tethering/src/com/android/networkstack/tethering/EntitlementManager.java index fb162267bb..a9421660d9 100644 --- a/Tethering/src/com/android/networkstack/tethering/EntitlementManager.java +++ b/Tethering/src/com/android/networkstack/tethering/EntitlementManager.java @@ -154,7 +154,9 @@ public class EntitlementManager { // Only launch entitlement UI for the current user if it is allowed to // change tethering. This usually means the system user or the admin users in HSUM. - if (SdkLevel.isAtLeastT()) { + // TODO (b/382624069): Figure out whether it is safe to call createContextAsUser + // from secondary user. And re-enable the check or remove the code accordingly. + if (false) { // Create a user context for the current foreground user as UserManager#isAdmin() // operates on the context user. final int currentUserId = getCurrentUser(); diff --git a/Tethering/tests/unit/src/com/android/networkstack/tethering/EntitlementManagerTest.java b/Tethering/tests/unit/src/com/android/networkstack/tethering/EntitlementManagerTest.java index 51c2d56d09..16ebbbbdbb 100644 --- a/Tethering/tests/unit/src/com/android/networkstack/tethering/EntitlementManagerTest.java +++ b/Tethering/tests/unit/src/com/android/networkstack/tethering/EntitlementManagerTest.java @@ -38,7 +38,6 @@ import static android.telephony.SubscriptionManager.INVALID_SUBSCRIPTION_ID; import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn; import static com.android.dx.mockito.inline.extended.ExtendedMockito.mockitoSession; import static com.android.networkstack.apishim.ConstantsShim.KEY_CARRIER_SUPPORTS_TETHERING_BOOL; -import static com.android.testutils.DevSdkIgnoreRule.IgnoreAfter; import static com.android.testutils.DevSdkIgnoreRule.IgnoreUpTo; import static com.android.testutils.DevSdkIgnoreRuleKt.SC_V2; @@ -592,16 +591,8 @@ public final class EntitlementManagerTest { .onTetherProvisioningFailed(TETHERING_WIFI, FAILED_TETHERING_REASON); } - @IgnoreUpTo(SC_V2) @Test - public void testUiProvisioningMultiUser_aboveT() { - doTestUiProvisioningMultiUser(true, 1); - doTestUiProvisioningMultiUser(false, 0); - } - - @IgnoreAfter(SC_V2) - @Test - public void testUiProvisioningMultiUser_belowT() { + public void testUiProvisioningMultiUser() { doTestUiProvisioningMultiUser(true, 1); doTestUiProvisioningMultiUser(false, 1); }