diff options
author | markchien <markchien@google.com> | 2020-06-03 12:27:37 +0800 |
---|---|---|
committer | markchien <markchien@google.com> | 2020-06-20 10:19:25 +0800 |
commit | b39a7b35cb15b47ef92f2aeebc5c36131b4f929d (patch) | |
tree | 53551808f3bf0a3a716d1c9dcadc87c31966fbf1 /packages/SettingsLib/src | |
parent | 4b198cb8c3e80d3b1af969391a16595920564df9 (diff) |
Protect invalid entitlement app configuration
There is a protection in Settings that Settings would gray out if
tethering requires entitlement check but the entitlement app is
invalid. Tethering resource is moved from framework to tethering
module, so Settings can not fetch entitlement app name anymore.
In this change, tethering module would check whether entitltement app
package name is exsited if entitlement check is needed. Tethering would
be not supported (Settings tethering option would be hidded) if
entitlement app is not installed.
After moving the protection into tethering module,
TetherUtil#isProvisioningNeeded is no longer needed. Because The
only use case is Settings wants to gray out tethering setting
when entitltement check is needed but entitlement app is invalid.
Bug: 146918263
Test: atest TetheringCoverageTests
Change-Id: I9a5ff5dbc1db3f3be7fcd7146862a16b373507e6
Merged-In: I9a5ff5dbc1db3f3be7fcd7146862a16b373507e6
Diffstat (limited to 'packages/SettingsLib/src')
-rw-r--r-- | packages/SettingsLib/src/com/android/settingslib/TetherUtil.java | 33 |
1 files changed, 0 insertions, 33 deletions
diff --git a/packages/SettingsLib/src/com/android/settingslib/TetherUtil.java b/packages/SettingsLib/src/com/android/settingslib/TetherUtil.java index c3993e9063b2..dc9384aa7c5d 100644 --- a/packages/SettingsLib/src/com/android/settingslib/TetherUtil.java +++ b/packages/SettingsLib/src/com/android/settingslib/TetherUtil.java @@ -19,42 +19,9 @@ import static android.os.UserManager.DISALLOW_CONFIG_TETHERING; import android.content.Context; import android.net.ConnectivityManager; -import android.os.SystemProperties; import android.os.UserHandle; -import android.telephony.CarrierConfigManager; - -import androidx.annotation.VisibleForTesting; public class TetherUtil { - - @VisibleForTesting - static boolean isEntitlementCheckRequired(Context context) { - final CarrierConfigManager configManager = (CarrierConfigManager) context - .getSystemService(Context.CARRIER_CONFIG_SERVICE); - if (configManager == null || configManager.getConfig() == null) { - // return service default - return true; - } - return configManager.getConfig().getBoolean(CarrierConfigManager - .KEY_REQUIRE_ENTITLEMENT_CHECKS_BOOL); - } - - public static boolean isProvisioningNeeded(Context context) { - // Keep in sync with other usage of config_mobile_hotspot_provision_app. - // ConnectivityManager#enforceTetherChangePermission - String[] provisionApp = context.getResources().getStringArray( - com.android.internal.R.array.config_mobile_hotspot_provision_app); - if (SystemProperties.getBoolean("net.tethering.noprovisioning", false) - || provisionApp == null) { - return false; - } - // Check carrier config for entitlement checks - if (isEntitlementCheckRequired(context) == false) { - return false; - } - return (provisionApp.length == 2); - } - public static boolean isTetherAvailable(Context context) { final ConnectivityManager cm = context.getSystemService(ConnectivityManager.class); final boolean tetherConfigDisallowed = RestrictedLockUtilsInternal |