blob: 151e0eafd96d3d6865ff88f04f2f8434ef61a0c8 [file] [log] [blame]
Jason Monk95f03c42015-02-11 13:28:26 -05001/*
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 */
16package com.android.settingslib;
17
Jason Monk95f03c42015-02-11 13:28:26 -050018import android.content.Context;
Jason Monk95f03c42015-02-11 13:28:26 -050019import android.os.SystemProperties;
Chris Manton1ba0fa02015-09-01 13:56:46 -070020import android.telephony.CarrierConfigManager;
Jason Monk95f03c42015-02-11 13:28:26 -050021
22public class TetherUtil {
23
Chris Manton1ba0fa02015-09-01 13:56:46 -070024 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 Monk95f03c42015-02-11 13:28:26 -050031 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 Manton1ba0fa02015-09-01 13:56:46 -070040 // Check carrier config for entitlement checks
41 if (isEntitlementCheckRequired(context) == false) {
42 return false;
43 }
Jason Monk95f03c42015-02-11 13:28:26 -050044 return (provisionApp.length == 2);
45 }
Jason Monk95f03c42015-02-11 13:28:26 -050046}