Jason Monk | 95f03c4 | 2015-02-11 13:28:26 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2015 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | package com.android.settingslib; |
| 17 | |
Jason Monk | 95f03c4 | 2015-02-11 13:28:26 -0500 | [diff] [blame] | 18 | import android.content.Context; |
Jason Monk | 95f03c4 | 2015-02-11 13:28:26 -0500 | [diff] [blame] | 19 | import android.os.SystemProperties; |
Chris Manton | 1ba0fa0 | 2015-09-01 13:56:46 -0700 | [diff] [blame] | 20 | import android.telephony.CarrierConfigManager; |
Jason Monk | 95f03c4 | 2015-02-11 13:28:26 -0500 | [diff] [blame] | 21 | |
| 22 | public class TetherUtil { |
| 23 | |
Chris Manton | 1ba0fa0 | 2015-09-01 13:56:46 -0700 | [diff] [blame] | 24 | private static boolean isEntitlementCheckRequired(Context context) { |
| 25 | final CarrierConfigManager configManager = (CarrierConfigManager) context |
| 26 | .getSystemService(Context.CARRIER_CONFIG_SERVICE); |
| 27 | return configManager.getConfig().getBoolean(CarrierConfigManager |
| 28 | .KEY_REQUIRE_ENTITLEMENT_CHECKS_BOOL); |
| 29 | } |
| 30 | |
Jason Monk | 95f03c4 | 2015-02-11 13:28:26 -0500 | [diff] [blame] | 31 | public static boolean isProvisioningNeeded(Context context) { |
| 32 | // Keep in sync with other usage of config_mobile_hotspot_provision_app. |
| 33 | // ConnectivityManager#enforceTetherChangePermission |
| 34 | String[] provisionApp = context.getResources().getStringArray( |
| 35 | com.android.internal.R.array.config_mobile_hotspot_provision_app); |
| 36 | if (SystemProperties.getBoolean("net.tethering.noprovisioning", false) |
| 37 | || provisionApp == null) { |
| 38 | return false; |
| 39 | } |
Chris Manton | 1ba0fa0 | 2015-09-01 13:56:46 -0700 | [diff] [blame] | 40 | // Check carrier config for entitlement checks |
| 41 | if (isEntitlementCheckRequired(context) == false) { |
| 42 | return false; |
| 43 | } |
Jason Monk | 95f03c4 | 2015-02-11 13:28:26 -0500 | [diff] [blame] | 44 | return (provisionApp.length == 2); |
| 45 | } |
Jason Monk | 95f03c4 | 2015-02-11 13:28:26 -0500 | [diff] [blame] | 46 | } |