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 18 import android.content.Context; 19 import android.os.SystemProperties; 20 import android.telephony.CarrierConfigManager; 21 22 public class TetherUtil { 23 isEntitlementCheckRequired(Context context)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 isProvisioningNeeded(Context context)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 } 40 // Check carrier config for entitlement checks 41 if (isEntitlementCheckRequired(context) == false) { 42 return false; 43 } 44 return (provisionApp.length == 2); 45 } 46 } 47