The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 1 | /* |
Chia-chi Yeh | 4e14211 | 2009-12-25 14:48:46 +0800 | [diff] [blame] | 2 | * Copyright (C) 2009 The Android Open Source Project |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 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 | |
| 17 | package com.android.settings; |
| 18 | |
Geoffrey Borggaard | fe21d9a | 2013-08-02 18:16:27 -0400 | [diff] [blame] | 19 | |
Amith Yamasani | d799347 | 2010-08-18 13:59:28 -0700 | [diff] [blame] | 20 | import android.app.Activity; |
Wink Saville | 5d5a269 | 2013-06-29 07:54:13 -0700 | [diff] [blame] | 21 | import android.app.AlertDialog; |
| 22 | import android.app.Dialog; |
Amith Yamasani | d799347 | 2010-08-18 13:59:28 -0700 | [diff] [blame] | 23 | import android.app.admin.DevicePolicyManager; |
Paul Jensen | d96c5fc | 2014-10-17 22:09:37 -0400 | [diff] [blame] | 24 | import android.content.ActivityNotFoundException; |
Amith Yamasani | d799347 | 2010-08-18 13:59:28 -0700 | [diff] [blame] | 25 | import android.content.Context; |
Wink Saville | 5d5a269 | 2013-06-29 07:54:13 -0700 | [diff] [blame] | 26 | import android.content.DialogInterface; |
Amith Yamasani | d799347 | 2010-08-18 13:59:28 -0700 | [diff] [blame] | 27 | import android.content.Intent; |
Irfan Sheriff | 167d718 | 2011-09-07 14:51:11 -0700 | [diff] [blame] | 28 | import android.content.pm.PackageManager; |
Wink Saville | 5d5a269 | 2013-06-29 07:54:13 -0700 | [diff] [blame] | 29 | import android.content.res.Resources; |
Amith Yamasani | d799347 | 2010-08-18 13:59:28 -0700 | [diff] [blame] | 30 | import android.net.ConnectivityManager; |
Wink Saville | 5d5a269 | 2013-06-29 07:54:13 -0700 | [diff] [blame] | 31 | import android.net.NetworkInfo; |
Paul Jensen | d96c5fc | 2014-10-17 22:09:37 -0400 | [diff] [blame] | 32 | import android.net.Uri; |
Nick Pelly | a57eace | 2010-10-15 01:19:43 -0700 | [diff] [blame] | 33 | import android.nfc.NfcAdapter; |
Fabrice Di Meglio | dba577f | 2014-06-06 16:31:45 -0700 | [diff] [blame] | 34 | import android.nfc.NfcManager; |
Amith Yamasani | d799347 | 2010-08-18 13:59:28 -0700 | [diff] [blame] | 35 | import android.os.Bundle; |
Amith Yamasani | d799347 | 2010-08-18 13:59:28 -0700 | [diff] [blame] | 36 | import android.os.SystemProperties; |
Sudheer Shanka | 9e9e63b | 2016-02-11 18:48:14 +0000 | [diff] [blame] | 37 | import android.os.UserHandle; |
Julia Reynolds | ee27b9d | 2014-05-09 13:36:20 -0400 | [diff] [blame] | 38 | import android.os.UserManager; |
Fabrice Di Meglio | dba577f | 2014-06-06 16:31:45 -0700 | [diff] [blame] | 39 | import android.provider.SearchIndexableResource; |
Amith Yamasani | d799347 | 2010-08-18 13:59:28 -0700 | [diff] [blame] | 40 | import android.provider.Settings; |
Jason Monk | 39b4674 | 2015-09-10 15:52:51 -0400 | [diff] [blame] | 41 | import android.support.v14.preference.SwitchPreference; |
| 42 | import android.support.v7.preference.Preference; |
| 43 | import android.support.v7.preference.PreferenceScreen; |
Wink Saville | 5d5a269 | 2013-06-29 07:54:13 -0700 | [diff] [blame] | 44 | import android.telephony.TelephonyManager; |
| 45 | import android.text.TextUtils; |
| 46 | import android.util.Log; |
David Braun | 4e9f04d | 2013-09-16 13:45:42 -0700 | [diff] [blame] | 47 | |
Pavel Zhamaitsiak | 4ab3256 | 2015-02-23 15:34:07 -0800 | [diff] [blame] | 48 | import com.android.ims.ImsManager; |
Chris Wren | 9d1bfd1 | 2016-01-26 18:04:01 -0500 | [diff] [blame] | 49 | import com.android.internal.logging.MetricsProto.MetricsEvent; |
Gilles Debunne | e78c187 | 2011-06-20 15:00:07 -0700 | [diff] [blame] | 50 | import com.android.internal.telephony.TelephonyIntents; |
| 51 | import com.android.internal.telephony.TelephonyProperties; |
| 52 | import com.android.settings.nfc.NfcEnabler; |
Fabrice Di Meglio | dba577f | 2014-06-06 16:31:45 -0700 | [diff] [blame] | 53 | import com.android.settings.search.BaseSearchIndexProvider; |
| 54 | import com.android.settings.search.Indexable; |
Sudheer Shanka | 8b86830 | 2016-01-26 13:50:23 +0000 | [diff] [blame] | 55 | import com.android.settingslib.RestrictedLockUtils; |
Sudheer Shanka | 682a916 | 2016-01-13 22:10:18 +0000 | [diff] [blame] | 56 | import com.android.settingslib.RestrictedPreference; |
Jason Monk | 73a2496 | 2015-04-13 20:58:05 -0400 | [diff] [blame] | 57 | |
Fabrice Di Meglio | dba577f | 2014-06-06 16:31:45 -0700 | [diff] [blame] | 58 | import java.util.ArrayList; |
| 59 | import java.util.Arrays; |
Fyodor Kupolov | ca060e3 | 2016-06-24 13:01:11 -0700 | [diff] [blame] | 60 | import java.util.Collections; |
Fabrice Di Meglio | dba577f | 2014-06-06 16:31:45 -0700 | [diff] [blame] | 61 | import java.util.List; |
David Braun | 4e9f04d | 2013-09-16 13:45:42 -0700 | [diff] [blame] | 62 | |
Jason Monk | 73a2496 | 2015-04-13 20:58:05 -0400 | [diff] [blame] | 63 | public class WirelessSettings extends SettingsPreferenceFragment implements Indexable { |
Robert Greenwalt | 4929e91 | 2013-07-16 13:09:24 -0700 | [diff] [blame] | 64 | private static final String TAG = "WirelessSettings"; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 65 | |
| 66 | private static final String KEY_TOGGLE_AIRPLANE = "toggle_airplane"; |
Nick Pelly | ad50ba0 | 2010-09-22 10:55:13 -0700 | [diff] [blame] | 67 | private static final String KEY_TOGGLE_NFC = "toggle_nfc"; |
tk.mun | 7c5c165 | 2011-10-13 22:56:18 +0900 | [diff] [blame] | 68 | private static final String KEY_WIMAX_SETTINGS = "wimax_settings"; |
Jeff Hamilton | 3d670de | 2011-09-21 16:44:36 -0500 | [diff] [blame] | 69 | private static final String KEY_ANDROID_BEAM_SETTINGS = "android_beam_settings"; |
Mike Lockwood | 83bcc98 | 2009-07-29 23:25:10 -0700 | [diff] [blame] | 70 | private static final String KEY_VPN_SETTINGS = "vpn_settings"; |
Robert Greenwalt | c4764d2 | 2010-02-12 14:21:37 -0800 | [diff] [blame] | 71 | private static final String KEY_TETHER_SETTINGS = "tether_settings"; |
Oscar Montemayor | 0541189 | 2010-08-03 16:56:09 -0700 | [diff] [blame] | 72 | private static final String KEY_PROXY_SETTINGS = "proxy_settings"; |
Amith Yamasani | 0f85c48 | 2011-02-23 17:19:11 -0800 | [diff] [blame] | 73 | private static final String KEY_MOBILE_NETWORK_SETTINGS = "mobile_network_settings"; |
Wink Saville | 5d5a269 | 2013-06-29 07:54:13 -0700 | [diff] [blame] | 74 | private static final String KEY_MANAGE_MOBILE_PLAN = "manage_mobile_plan"; |
Pavel Zhamaitsiak | 4ab3256 | 2015-02-23 15:34:07 -0800 | [diff] [blame] | 75 | private static final String KEY_WFC_SETTINGS = "wifi_calling_settings"; |
Doris Ling | e6f635f | 2016-06-07 17:56:00 -0700 | [diff] [blame] | 76 | private static final String KEY_NETWORK_RESET = "network_reset"; |
Nick Pelly | ad50ba0 | 2010-09-22 10:55:13 -0700 | [diff] [blame] | 77 | |
Chouting Zhang | 71cc49e | 2009-08-28 14:36:35 -0500 | [diff] [blame] | 78 | public static final String EXIT_ECM_RESULT = "exit_ecm_result"; |
| 79 | public static final int REQUEST_CODE_EXIT_ECM = 1; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 80 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 81 | private AirplaneModeEnabler mAirplaneModeEnabler; |
Fabrice Di Meglio | e3bced2 | 2014-08-06 10:22:52 -0700 | [diff] [blame] | 82 | private SwitchPreference mAirplaneModePreference; |
Nick Pelly | ad50ba0 | 2010-09-22 10:55:13 -0700 | [diff] [blame] | 83 | private NfcEnabler mNfcEnabler; |
Martijn Coenen | bb4bdc2 | 2011-07-27 17:31:41 -0500 | [diff] [blame] | 84 | private NfcAdapter mNfcAdapter; |
Chouting Zhang | 71cc49e | 2009-08-28 14:36:35 -0500 | [diff] [blame] | 85 | |
Wink Saville | 5d5a269 | 2013-06-29 07:54:13 -0700 | [diff] [blame] | 86 | private ConnectivityManager mCm; |
| 87 | private TelephonyManager mTm; |
Andrew Flynn | 17c008e | 2013-10-11 09:06:22 -0700 | [diff] [blame] | 88 | private PackageManager mPm; |
Julia Reynolds | ee27b9d | 2014-05-09 13:36:20 -0400 | [diff] [blame] | 89 | private UserManager mUm; |
Wink Saville | 5d5a269 | 2013-06-29 07:54:13 -0700 | [diff] [blame] | 90 | |
| 91 | private static final int MANAGE_MOBILE_PLAN_DIALOG_ID = 1; |
| 92 | private static final String SAVED_MANAGE_MOBILE_PLAN_MSG = "mManageMobilePlanMessage"; |
| 93 | |
Pavel Zhamaitsiak | 4ab3256 | 2015-02-23 15:34:07 -0800 | [diff] [blame] | 94 | private PreferenceScreen mButtonWfc; |
David Braun | 4e9f04d | 2013-09-16 13:45:42 -0700 | [diff] [blame] | 95 | |
Chouting Zhang | 71cc49e | 2009-08-28 14:36:35 -0500 | [diff] [blame] | 96 | /** |
| 97 | * Invoked on each preference click in this hierarchy, overrides |
Fabrice Di Meglio | 263bcc8 | 2014-01-17 19:17:58 -0800 | [diff] [blame] | 98 | * PreferenceFragment's implementation. Used to make sure we track the |
Chouting Zhang | 71cc49e | 2009-08-28 14:36:35 -0500 | [diff] [blame] | 99 | * preference click events. |
| 100 | */ |
| 101 | @Override |
Jason Monk | 39b4674 | 2015-09-10 15:52:51 -0400 | [diff] [blame] | 102 | public boolean onPreferenceTreeClick(Preference preference) { |
Wink Saville | 5d5a269 | 2013-06-29 07:54:13 -0700 | [diff] [blame] | 103 | log("onPreferenceTreeClick: preference=" + preference); |
Chia-chi Yeh | 4e14211 | 2009-12-25 14:48:46 +0800 | [diff] [blame] | 104 | if (preference == mAirplaneModePreference && Boolean.parseBoolean( |
| 105 | SystemProperties.get(TelephonyProperties.PROPERTY_INECM_MODE))) { |
Chouting Zhang | 71cc49e | 2009-08-28 14:36:35 -0500 | [diff] [blame] | 106 | // In ECM mode launch ECM app dialog |
| 107 | startActivityForResult( |
| 108 | new Intent(TelephonyIntents.ACTION_SHOW_NOTICE_ECM_BLOCK_OTHERS, null), |
| 109 | REQUEST_CODE_EXIT_ECM); |
Chouting Zhang | 71cc49e | 2009-08-28 14:36:35 -0500 | [diff] [blame] | 110 | return true; |
Wink Saville | 5d5a269 | 2013-06-29 07:54:13 -0700 | [diff] [blame] | 111 | } else if (preference == findPreference(KEY_MANAGE_MOBILE_PLAN)) { |
| 112 | onManageMobilePlanClick(); |
Chouting Zhang | 71cc49e | 2009-08-28 14:36:35 -0500 | [diff] [blame] | 113 | } |
Chia-chi Yeh | 4e14211 | 2009-12-25 14:48:46 +0800 | [diff] [blame] | 114 | // Let the intents be launched by the Preference manager |
Jason Monk | 39b4674 | 2015-09-10 15:52:51 -0400 | [diff] [blame] | 115 | return super.onPreferenceTreeClick(preference); |
Chouting Zhang | 71cc49e | 2009-08-28 14:36:35 -0500 | [diff] [blame] | 116 | } |
Chia-chi Yeh | b90452f | 2010-01-13 06:11:29 +0800 | [diff] [blame] | 117 | |
Wink Saville | 5d5a269 | 2013-06-29 07:54:13 -0700 | [diff] [blame] | 118 | private String mManageMobilePlanMessage; |
Wink Saville | 5d5a269 | 2013-06-29 07:54:13 -0700 | [diff] [blame] | 119 | public void onManageMobilePlanClick() { |
| 120 | log("onManageMobilePlanClick:"); |
| 121 | mManageMobilePlanMessage = null; |
| 122 | Resources resources = getActivity().getResources(); |
| 123 | |
Paul Jensen | 6953eea | 2015-06-11 10:26:33 -0400 | [diff] [blame] | 124 | NetworkInfo ni = mCm.getActiveNetworkInfo(); |
Wink Saville | 5d5a269 | 2013-06-29 07:54:13 -0700 | [diff] [blame] | 125 | if (mTm.hasIccCard() && (ni != null)) { |
Andrew Flynn | 17c008e | 2013-10-11 09:06:22 -0700 | [diff] [blame] | 126 | // Check for carrier apps that can handle provisioning first |
| 127 | Intent provisioningIntent = new Intent(TelephonyIntents.ACTION_CARRIER_SETUP); |
Diego Pontoriero | ff9f67d | 2014-08-11 18:25:51 -0700 | [diff] [blame] | 128 | List<String> carrierPackages = |
Diego Pontoriero | be7adcc | 2014-08-28 13:52:24 -0700 | [diff] [blame] | 129 | mTm.getCarrierPackageNamesForIntent(provisioningIntent); |
Diego Pontoriero | ff9f67d | 2014-08-11 18:25:51 -0700 | [diff] [blame] | 130 | if (carrierPackages != null && !carrierPackages.isEmpty()) { |
| 131 | if (carrierPackages.size() != 1) { |
| 132 | Log.w(TAG, "Multiple matching carrier apps found, launching the first."); |
| 133 | } |
| 134 | provisioningIntent.setPackage(carrierPackages.get(0)); |
Andrew Flynn | 17c008e | 2013-10-11 09:06:22 -0700 | [diff] [blame] | 135 | startActivity(provisioningIntent); |
| 136 | return; |
| 137 | } |
| 138 | |
Wink Saville | 5d5a269 | 2013-06-29 07:54:13 -0700 | [diff] [blame] | 139 | // Get provisioning URL |
Robert Greenwalt | 4929e91 | 2013-07-16 13:09:24 -0700 | [diff] [blame] | 140 | String url = mCm.getMobileProvisioningUrl(); |
Wink Saville | 5d5a269 | 2013-06-29 07:54:13 -0700 | [diff] [blame] | 141 | if (!TextUtils.isEmpty(url)) { |
Paul Jensen | d96c5fc | 2014-10-17 22:09:37 -0400 | [diff] [blame] | 142 | Intent intent = Intent.makeMainSelectorActivity(Intent.ACTION_MAIN, |
| 143 | Intent.CATEGORY_APP_BROWSER); |
| 144 | intent.setData(Uri.parse(url)); |
| 145 | intent.setFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT | |
| 146 | Intent.FLAG_ACTIVITY_NEW_TASK); |
| 147 | try { |
| 148 | startActivity(intent); |
| 149 | } catch (ActivityNotFoundException e) { |
| 150 | Log.w(TAG, "onManageMobilePlanClick: startActivity failed" + e); |
| 151 | } |
Wink Saville | 5d5a269 | 2013-06-29 07:54:13 -0700 | [diff] [blame] | 152 | } else { |
| 153 | // No provisioning URL |
| 154 | String operatorName = mTm.getSimOperatorName(); |
| 155 | if (TextUtils.isEmpty(operatorName)) { |
| 156 | // Use NetworkOperatorName as second choice in case there is no |
| 157 | // SPN (Service Provider Name on the SIM). Such as with T-mobile. |
| 158 | operatorName = mTm.getNetworkOperatorName(); |
| 159 | if (TextUtils.isEmpty(operatorName)) { |
| 160 | mManageMobilePlanMessage = resources.getString( |
| 161 | R.string.mobile_unknown_sim_operator); |
| 162 | } else { |
| 163 | mManageMobilePlanMessage = resources.getString( |
| 164 | R.string.mobile_no_provisioning_url, operatorName); |
| 165 | } |
| 166 | } else { |
| 167 | mManageMobilePlanMessage = resources.getString( |
| 168 | R.string.mobile_no_provisioning_url, operatorName); |
| 169 | } |
| 170 | } |
| 171 | } else if (mTm.hasIccCard() == false) { |
| 172 | // No sim card |
| 173 | mManageMobilePlanMessage = resources.getString(R.string.mobile_insert_sim_card); |
| 174 | } else { |
| 175 | // NetworkInfo is null, there is no connection |
| 176 | mManageMobilePlanMessage = resources.getString(R.string.mobile_connect_to_internet); |
| 177 | } |
| 178 | if (!TextUtils.isEmpty(mManageMobilePlanMessage)) { |
| 179 | log("onManageMobilePlanClick: message=" + mManageMobilePlanMessage); |
| 180 | showDialog(MANAGE_MOBILE_PLAN_DIALOG_ID); |
| 181 | } |
| 182 | } |
| 183 | |
Wink Saville | 5d5a269 | 2013-06-29 07:54:13 -0700 | [diff] [blame] | 184 | @Override |
| 185 | public Dialog onCreateDialog(int dialogId) { |
| 186 | log("onCreateDialog: dialogId=" + dialogId); |
| 187 | switch (dialogId) { |
| 188 | case MANAGE_MOBILE_PLAN_DIALOG_ID: |
| 189 | return new AlertDialog.Builder(getActivity()) |
| 190 | .setMessage(mManageMobilePlanMessage) |
| 191 | .setCancelable(false) |
| 192 | .setPositiveButton(com.android.internal.R.string.ok, |
| 193 | new DialogInterface.OnClickListener() { |
| 194 | @Override |
| 195 | public void onClick(DialogInterface dialog, int id) { |
| 196 | log("MANAGE_MOBILE_PLAN_DIALOG.onClickListener id=" + id); |
| 197 | mManageMobilePlanMessage = null; |
| 198 | } |
| 199 | }) |
| 200 | .create(); |
| 201 | } |
| 202 | return super.onCreateDialog(dialogId); |
| 203 | } |
| 204 | |
Fan Zhang | 20374fd | 2016-09-23 12:10:38 -0700 | [diff] [blame] | 205 | @Override |
| 206 | public int getDialogMetricsCategory(int dialogId) { |
| 207 | if (MANAGE_MOBILE_PLAN_DIALOG_ID == dialogId) { |
| 208 | return MetricsEvent.DIALOG_MANAGE_MOBILE_PLAN; |
| 209 | } |
| 210 | return 0; |
| 211 | } |
| 212 | |
Wink Saville | 5d5a269 | 2013-06-29 07:54:13 -0700 | [diff] [blame] | 213 | private void log(String s) { |
| 214 | Log.d(TAG, s); |
| 215 | } |
| 216 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 217 | @Override |
Fan Zhang | 6507613 | 2016-08-08 10:25:13 -0700 | [diff] [blame] | 218 | public int getMetricsCategory() { |
Chris Wren | 9d1bfd1 | 2016-01-26 18:04:01 -0500 | [diff] [blame] | 219 | return MetricsEvent.WIRELESS; |
Chris Wren | 8a963ba | 2015-03-20 10:29:14 -0400 | [diff] [blame] | 220 | } |
| 221 | |
| 222 | @Override |
Amith Yamasani | d799347 | 2010-08-18 13:59:28 -0700 | [diff] [blame] | 223 | public void onCreate(Bundle savedInstanceState) { |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 224 | super.onCreate(savedInstanceState); |
Wink Saville | 5d5a269 | 2013-06-29 07:54:13 -0700 | [diff] [blame] | 225 | if (savedInstanceState != null) { |
| 226 | mManageMobilePlanMessage = savedInstanceState.getString(SAVED_MANAGE_MOBILE_PLAN_MSG); |
| 227 | } |
| 228 | log("onCreate: mManageMobilePlanMessage=" + mManageMobilePlanMessage); |
| 229 | |
| 230 | mCm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); |
| 231 | mTm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); |
Andrew Flynn | 17c008e | 2013-10-11 09:06:22 -0700 | [diff] [blame] | 232 | mPm = getPackageManager(); |
Julia Reynolds | ee27b9d | 2014-05-09 13:36:20 -0400 | [diff] [blame] | 233 | mUm = (UserManager) getSystemService(Context.USER_SERVICE); |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 234 | |
| 235 | addPreferencesFromResource(R.xml.wireless_settings); |
| 236 | |
Xiaohui Chen | 6f03829 | 2015-09-02 16:54:00 -0700 | [diff] [blame] | 237 | final boolean isAdmin = mUm.isAdminUser(); |
Amith Yamasani | 9627a8e | 2012-09-23 12:54:14 -0700 | [diff] [blame] | 238 | |
Amith Yamasani | d799347 | 2010-08-18 13:59:28 -0700 | [diff] [blame] | 239 | final Activity activity = getActivity(); |
Fabrice Di Meglio | e3bced2 | 2014-08-06 10:22:52 -0700 | [diff] [blame] | 240 | mAirplaneModePreference = (SwitchPreference) findPreference(KEY_TOGGLE_AIRPLANE); |
Fabrice Di Meglio | 4325f80 | 2014-08-15 14:14:17 -0700 | [diff] [blame] | 241 | SwitchPreference nfc = (SwitchPreference) findPreference(KEY_TOGGLE_NFC); |
Sudheer Shanka | 682a916 | 2016-01-13 22:10:18 +0000 | [diff] [blame] | 242 | RestrictedPreference androidBeam = (RestrictedPreference) findPreference( |
| 243 | KEY_ANDROID_BEAM_SETTINGS); |
Chia-chi Yeh | 4e14211 | 2009-12-25 14:48:46 +0800 | [diff] [blame] | 244 | |
Fan Zhang | aa71afe | 2016-09-22 10:43:12 -0700 | [diff] [blame] | 245 | mAirplaneModeEnabler = new AirplaneModeEnabler(activity, mAirplaneModePreference, |
| 246 | mMetricsFeatureProvider); |
Jeff Hamilton | 3d670de | 2011-09-21 16:44:36 -0500 | [diff] [blame] | 247 | mNfcEnabler = new NfcEnabler(activity, nfc, androidBeam); |
Irfan Sheriff | 936e3fa | 2012-05-07 15:51:37 -0700 | [diff] [blame] | 248 | |
Pavel Zhamaitsiak | 3e7e2c5 | 2015-07-23 09:31:58 -0700 | [diff] [blame] | 249 | mButtonWfc = (PreferenceScreen) findPreference(KEY_WFC_SETTINGS); |
Pavel Zhamaitsiak | 4ab3256 | 2015-02-23 15:34:07 -0800 | [diff] [blame] | 250 | |
Christopher Tate | 6a5929b | 2012-09-10 15:39:05 -0700 | [diff] [blame] | 251 | String toggleable = Settings.Global.getString(activity.getContentResolver(), |
| 252 | Settings.Global.AIRPLANE_MODE_TOGGLEABLE_RADIOS); |
Chia-chi Yeh | 4e14211 | 2009-12-25 14:48:46 +0800 | [diff] [blame] | 253 | |
tk.mun | 7c5c165 | 2011-10-13 22:56:18 +0900 | [diff] [blame] | 254 | //enable/disable wimax depending on the value in config.xml |
Xiaohui Chen | 6f03829 | 2015-09-02 16:54:00 -0700 | [diff] [blame] | 255 | final boolean isWimaxEnabled = isAdmin && this.getResources().getBoolean( |
tk.mun | 7c5c165 | 2011-10-13 22:56:18 +0900 | [diff] [blame] | 256 | com.android.internal.R.bool.config_wimaxEnabled); |
Sudheer Shanka | 9e9e63b | 2016-02-11 18:48:14 +0000 | [diff] [blame] | 257 | if (!isWimaxEnabled || RestrictedLockUtils.hasBaseUserRestriction(activity, |
| 258 | UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS, UserHandle.myUserId())) { |
tk.mun | 7c5c165 | 2011-10-13 22:56:18 +0900 | [diff] [blame] | 259 | PreferenceScreen root = getPreferenceScreen(); |
Xiaohui Chen | 6f03829 | 2015-09-02 16:54:00 -0700 | [diff] [blame] | 260 | Preference ps = findPreference(KEY_WIMAX_SETTINGS); |
tk.mun | 7c5c165 | 2011-10-13 22:56:18 +0900 | [diff] [blame] | 261 | if (ps != null) root.removePreference(ps); |
| 262 | } else { |
Christopher Tate | 6a5929b | 2012-09-10 15:39:05 -0700 | [diff] [blame] | 263 | if (toggleable == null || !toggleable.contains(Settings.Global.RADIO_WIMAX ) |
tk.mun | 7c5c165 | 2011-10-13 22:56:18 +0900 | [diff] [blame] | 264 | && isWimaxEnabled) { |
Xiaohui Chen | 6f03829 | 2015-09-02 16:54:00 -0700 | [diff] [blame] | 265 | Preference ps = findPreference(KEY_WIMAX_SETTINGS); |
tk.mun | 7c5c165 | 2011-10-13 22:56:18 +0900 | [diff] [blame] | 266 | ps.setDependency(KEY_TOGGLE_AIRPLANE); |
| 267 | } |
| 268 | } |
Geoffrey Borggaard | fe21d9a | 2013-08-02 18:16:27 -0400 | [diff] [blame] | 269 | |
Chia-chi Yeh | b90452f | 2010-01-13 06:11:29 +0800 | [diff] [blame] | 270 | // Manually set dependencies for Wifi when not toggleable. |
Christopher Tate | 6a5929b | 2012-09-10 15:39:05 -0700 | [diff] [blame] | 271 | if (toggleable == null || !toggleable.contains(Settings.Global.RADIO_WIFI)) { |
Chia-chi Yeh | 4e14211 | 2009-12-25 14:48:46 +0800 | [diff] [blame] | 272 | findPreference(KEY_VPN_SETTINGS).setDependency(KEY_TOGGLE_AIRPLANE); |
| 273 | } |
Julia Reynolds | ee27b9d | 2014-05-09 13:36:20 -0400 | [diff] [blame] | 274 | // Disable VPN. |
Xiaohui Chen | 6f03829 | 2015-09-02 16:54:00 -0700 | [diff] [blame] | 275 | // TODO: http://b/23693383 |
Sudheer Shanka | 9e9e63b | 2016-02-11 18:48:14 +0000 | [diff] [blame] | 276 | if (!isAdmin || RestrictedLockUtils.hasBaseUserRestriction(activity, |
| 277 | UserManager.DISALLOW_CONFIG_VPN, UserHandle.myUserId())) { |
Amith Yamasani | 9627a8e | 2012-09-23 12:54:14 -0700 | [diff] [blame] | 278 | removePreference(KEY_VPN_SETTINGS); |
| 279 | } |
Julia Reynolds | ee27b9d | 2014-05-09 13:36:20 -0400 | [diff] [blame] | 280 | |
Chia-chi Yeh | 4e14211 | 2009-12-25 14:48:46 +0800 | [diff] [blame] | 281 | // Manually set dependencies for Bluetooth when not toggleable. |
Christopher Tate | 6a5929b | 2012-09-10 15:39:05 -0700 | [diff] [blame] | 282 | if (toggleable == null || !toggleable.contains(Settings.Global.RADIO_BLUETOOTH)) { |
Gilles Debunne | e78c187 | 2011-06-20 15:00:07 -0700 | [diff] [blame] | 283 | // No bluetooth-dependent items in the list. Code kept in case one is added later. |
Nick Pelly | ad50ba0 | 2010-09-22 10:55:13 -0700 | [diff] [blame] | 284 | } |
| 285 | |
Nick Pelly | 9894d4a | 2011-08-09 07:10:16 -0700 | [diff] [blame] | 286 | // Manually set dependencies for NFC when not toggleable. |
Christopher Tate | 6a5929b | 2012-09-10 15:39:05 -0700 | [diff] [blame] | 287 | if (toggleable == null || !toggleable.contains(Settings.Global.RADIO_NFC)) { |
Nick Pelly | 9894d4a | 2011-08-09 07:10:16 -0700 | [diff] [blame] | 288 | findPreference(KEY_TOGGLE_NFC).setDependency(KEY_TOGGLE_AIRPLANE); |
Jeff Hamilton | 3d670de | 2011-09-21 16:44:36 -0500 | [diff] [blame] | 289 | findPreference(KEY_ANDROID_BEAM_SETTINGS).setDependency(KEY_TOGGLE_AIRPLANE); |
Nick Pelly | 9894d4a | 2011-08-09 07:10:16 -0700 | [diff] [blame] | 290 | } |
| 291 | |
Fabrice Di Meglio | dba577f | 2014-06-06 16:31:45 -0700 | [diff] [blame] | 292 | // Remove NFC if not available |
Martijn Coenen | bb4bdc2 | 2011-07-27 17:31:41 -0500 | [diff] [blame] | 293 | mNfcAdapter = NfcAdapter.getDefaultAdapter(activity); |
| 294 | if (mNfcAdapter == null) { |
Nick Pelly | ad50ba0 | 2010-09-22 10:55:13 -0700 | [diff] [blame] | 295 | getPreferenceScreen().removePreference(nfc); |
Jeff Hamilton | 3d670de | 2011-09-21 16:44:36 -0500 | [diff] [blame] | 296 | getPreferenceScreen().removePreference(androidBeam); |
Nick Pelly | 9894d4a | 2011-08-09 07:10:16 -0700 | [diff] [blame] | 297 | mNfcEnabler = null; |
Chia-chi Yeh | 4e14211 | 2009-12-25 14:48:46 +0800 | [diff] [blame] | 298 | } |
Robert Greenwalt | c4764d2 | 2010-02-12 14:21:37 -0800 | [diff] [blame] | 299 | |
Julia Reynolds | ee27b9d | 2014-05-09 13:36:20 -0400 | [diff] [blame] | 300 | // Remove Mobile Network Settings and Manage Mobile Plan for secondary users, |
Sudheer Shanka | 8b86830 | 2016-01-26 13:50:23 +0000 | [diff] [blame] | 301 | // if it's a wifi-only device. |
Sudheer Shanka | 9e9e63b | 2016-02-11 18:48:14 +0000 | [diff] [blame] | 302 | if (!isAdmin || Utils.isWifiOnly(getActivity()) || |
| 303 | RestrictedLockUtils.hasBaseUserRestriction(activity, |
| 304 | UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS, UserHandle.myUserId())) { |
Amith Yamasani | 9627a8e | 2012-09-23 12:54:14 -0700 | [diff] [blame] | 305 | removePreference(KEY_MOBILE_NETWORK_SETTINGS); |
Wink Saville | 5d5a269 | 2013-06-29 07:54:13 -0700 | [diff] [blame] | 306 | removePreference(KEY_MANAGE_MOBILE_PLAN); |
Amith Yamasani | 0f85c48 | 2011-02-23 17:19:11 -0800 | [diff] [blame] | 307 | } |
Sungmin Choi | 2490315 | 2013-10-15 16:11:55 -0700 | [diff] [blame] | 308 | // Remove Mobile Network Settings and Manage Mobile Plan |
| 309 | // if config_show_mobile_plan sets false. |
Fabrice Di Meglio | dba577f | 2014-06-06 16:31:45 -0700 | [diff] [blame] | 310 | final boolean isMobilePlanEnabled = this.getResources().getBoolean( |
Sungmin Choi | 2490315 | 2013-10-15 16:11:55 -0700 | [diff] [blame] | 311 | R.bool.config_show_mobile_plan); |
| 312 | if (!isMobilePlanEnabled) { |
| 313 | Preference pref = findPreference(KEY_MANAGE_MOBILE_PLAN); |
| 314 | if (pref != null) { |
| 315 | removePreference(KEY_MANAGE_MOBILE_PLAN); |
| 316 | } |
| 317 | } |
Amith Yamasani | 0f85c48 | 2011-02-23 17:19:11 -0800 | [diff] [blame] | 318 | |
Jaewan Kim | 2e41e3d | 2013-04-19 13:40:23 +0900 | [diff] [blame] | 319 | // Remove Airplane Mode settings if it's a stationary device such as a TV. |
Andrew Flynn | 17c008e | 2013-10-11 09:06:22 -0700 | [diff] [blame] | 320 | if (mPm.hasSystemFeature(PackageManager.FEATURE_TELEVISION)) { |
Jaewan Kim | 2e41e3d | 2013-04-19 13:40:23 +0900 | [diff] [blame] | 321 | removePreference(KEY_TOGGLE_AIRPLANE); |
| 322 | } |
| 323 | |
Oscar Montemayor | 0541189 | 2010-08-03 16:56:09 -0700 | [diff] [blame] | 324 | // Enable Proxy selector settings if allowed. |
| 325 | Preference mGlobalProxy = findPreference(KEY_PROXY_SETTINGS); |
Fabrice Di Meglio | dba577f | 2014-06-06 16:31:45 -0700 | [diff] [blame] | 326 | final DevicePolicyManager mDPM = (DevicePolicyManager) |
Amith Yamasani | d799347 | 2010-08-18 13:59:28 -0700 | [diff] [blame] | 327 | activity.getSystemService(Context.DEVICE_POLICY_SERVICE); |
Robert Greenwalt | 6f3a98b | 2010-12-28 16:11:12 -0800 | [diff] [blame] | 328 | // proxy UI disabled until we have better app support |
| 329 | getPreferenceScreen().removePreference(mGlobalProxy); |
Oscar Montemayor | 0541189 | 2010-08-03 16:56:09 -0700 | [diff] [blame] | 330 | mGlobalProxy.setEnabled(mDPM.getGlobalProxyAdmin() == null); |
| 331 | |
Amith Yamasani | 0f85c48 | 2011-02-23 17:19:11 -0800 | [diff] [blame] | 332 | // Disable Tethering if it's not allowed or if it's a wifi-only device |
Fabrice Di Meglio | dba577f | 2014-06-06 16:31:45 -0700 | [diff] [blame] | 333 | final ConnectivityManager cm = |
Amith Yamasani | d799347 | 2010-08-18 13:59:28 -0700 | [diff] [blame] | 334 | (ConnectivityManager) activity.getSystemService(Context.CONNECTIVITY_SERVICE); |
Sudheer Shanka | 682a916 | 2016-01-13 22:10:18 +0000 | [diff] [blame] | 335 | |
Sudheer Shanka | 9e9e63b | 2016-02-11 18:48:14 +0000 | [diff] [blame] | 336 | final boolean adminDisallowedTetherConfig = RestrictedLockUtils.checkIfRestrictionEnforced( |
| 337 | activity, UserManager.DISALLOW_CONFIG_TETHERING, UserHandle.myUserId()) != null; |
| 338 | if ((!cm.isTetheringSupported() && !adminDisallowedTetherConfig) || |
| 339 | RestrictedLockUtils.hasBaseUserRestriction(activity, |
| 340 | UserManager.DISALLOW_CONFIG_TETHERING, UserHandle.myUserId())) { |
Robert Greenwalt | c4764d2 | 2010-02-12 14:21:37 -0800 | [diff] [blame] | 341 | getPreferenceScreen().removePreference(findPreference(KEY_TETHER_SETTINGS)); |
Sudheer Shanka | 8b86830 | 2016-01-26 13:50:23 +0000 | [diff] [blame] | 342 | } else if (!adminDisallowedTetherConfig) { |
Robert Greenwalt | e434bfb | 2010-05-08 15:20:24 -0700 | [diff] [blame] | 343 | Preference p = findPreference(KEY_TETHER_SETTINGS); |
Wei Liu | 6e58d51 | 2015-08-24 17:29:04 -0700 | [diff] [blame] | 344 | p.setTitle(com.android.settingslib.Utils.getTetheringLabel(cm)); |
PauloftheWest | 29aab7a | 2014-09-26 16:05:44 -0700 | [diff] [blame] | 345 | |
| 346 | // Grey out if provisioning is not available. |
| 347 | p.setEnabled(!TetherSettings |
| 348 | .isProvisioningNeededButUnavailable(getActivity())); |
Robert Greenwalt | c4764d2 | 2010-02-12 14:21:37 -0800 | [diff] [blame] | 349 | } |
Doris Ling | e6f635f | 2016-06-07 17:56:00 -0700 | [diff] [blame] | 350 | |
| 351 | // Remove network reset if not allowed |
| 352 | if (RestrictedLockUtils.hasBaseUserRestriction(activity, |
| 353 | UserManager.DISALLOW_NETWORK_RESET, UserHandle.myUserId())) { |
| 354 | removePreference(KEY_NETWORK_RESET); |
| 355 | } |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 356 | } |
Robert Greenwalt | c4764d2 | 2010-02-12 14:21:37 -0800 | [diff] [blame] | 357 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 358 | @Override |
Amith Yamasani | d799347 | 2010-08-18 13:59:28 -0700 | [diff] [blame] | 359 | public void onResume() { |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 360 | super.onResume(); |
Danica Chang | 32711b6 | 2010-08-10 18:41:29 -0700 | [diff] [blame] | 361 | |
Chia-chi Yeh | 4e14211 | 2009-12-25 14:48:46 +0800 | [diff] [blame] | 362 | mAirplaneModeEnabler.resume(); |
Nick Pelly | 9894d4a | 2011-08-09 07:10:16 -0700 | [diff] [blame] | 363 | if (mNfcEnabler != null) { |
| 364 | mNfcEnabler.resume(); |
Martijn Coenen | bb4bdc2 | 2011-07-27 17:31:41 -0500 | [diff] [blame] | 365 | } |
Pavel Zhamaitsiak | 4ab3256 | 2015-02-23 15:34:07 -0800 | [diff] [blame] | 366 | |
Pavel Zhamaitsiak | 3e7e2c5 | 2015-07-23 09:31:58 -0700 | [diff] [blame] | 367 | // update WFC setting |
Pavel Zhamaitsiak | 4ab3256 | 2015-02-23 15:34:07 -0800 | [diff] [blame] | 368 | final Context context = getActivity(); |
Pavel Zhamaitsiak | e2f59b9 | 2016-06-20 17:52:48 -0700 | [diff] [blame] | 369 | if (ImsManager.isWfcEnabledByPlatform(context) && |
| 370 | ImsManager.isWfcProvisionedOnDevice(context)) { |
Pavel Zhamaitsiak | 3e7e2c5 | 2015-07-23 09:31:58 -0700 | [diff] [blame] | 371 | getPreferenceScreen().addPreference(mButtonWfc); |
| 372 | |
Pavel Zhamaitsiak | 4ab3256 | 2015-02-23 15:34:07 -0800 | [diff] [blame] | 373 | mButtonWfc.setSummary(WifiCallingSettings.getWfcModeSummary( |
Meng Wang | fe3749d | 2016-09-19 14:53:24 -0700 | [diff] [blame] | 374 | context, ImsManager.getWfcMode(context, mTm.isNetworkRoaming()))); |
Pavel Zhamaitsiak | 3e7e2c5 | 2015-07-23 09:31:58 -0700 | [diff] [blame] | 375 | } else { |
| 376 | removePreference(KEY_WFC_SETTINGS); |
Pavel Zhamaitsiak | 4ab3256 | 2015-02-23 15:34:07 -0800 | [diff] [blame] | 377 | } |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 378 | } |
Danica Chang | 32711b6 | 2010-08-10 18:41:29 -0700 | [diff] [blame] | 379 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 380 | @Override |
Wink Saville | 5d5a269 | 2013-06-29 07:54:13 -0700 | [diff] [blame] | 381 | public void onSaveInstanceState(Bundle outState) { |
| 382 | super.onSaveInstanceState(outState); |
| 383 | |
| 384 | if (!TextUtils.isEmpty(mManageMobilePlanMessage)) { |
| 385 | outState.putString(SAVED_MANAGE_MOBILE_PLAN_MSG, mManageMobilePlanMessage); |
| 386 | } |
| 387 | } |
| 388 | |
| 389 | @Override |
Amith Yamasani | d799347 | 2010-08-18 13:59:28 -0700 | [diff] [blame] | 390 | public void onPause() { |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 391 | super.onPause(); |
Danica Chang | 32711b6 | 2010-08-10 18:41:29 -0700 | [diff] [blame] | 392 | |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 393 | mAirplaneModeEnabler.pause(); |
Nick Pelly | 9894d4a | 2011-08-09 07:10:16 -0700 | [diff] [blame] | 394 | if (mNfcEnabler != null) { |
| 395 | mNfcEnabler.pause(); |
| 396 | } |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 397 | } |
Danica Chang | 32711b6 | 2010-08-10 18:41:29 -0700 | [diff] [blame] | 398 | |
Chouting Zhang | 71cc49e | 2009-08-28 14:36:35 -0500 | [diff] [blame] | 399 | @Override |
Amith Yamasani | d799347 | 2010-08-18 13:59:28 -0700 | [diff] [blame] | 400 | public void onActivityResult(int requestCode, int resultCode, Intent data) { |
Chia-chi Yeh | 4e14211 | 2009-12-25 14:48:46 +0800 | [diff] [blame] | 401 | if (requestCode == REQUEST_CODE_EXIT_ECM) { |
| 402 | Boolean isChoiceYes = data.getBooleanExtra(EXIT_ECM_RESULT, false); |
Chouting Zhang | 71cc49e | 2009-08-28 14:36:35 -0500 | [diff] [blame] | 403 | // Set Airplane mode based on the return value and checkbox state |
| 404 | mAirplaneModeEnabler.setAirplaneModeInECM(isChoiceYes, |
| 405 | mAirplaneModePreference.isChecked()); |
Chouting Zhang | 71cc49e | 2009-08-28 14:36:35 -0500 | [diff] [blame] | 406 | } |
Geoffrey Borggaard | fe21d9a | 2013-08-02 18:16:27 -0400 | [diff] [blame] | 407 | super.onActivityResult(requestCode, resultCode, data); |
Chouting Zhang | 71cc49e | 2009-08-28 14:36:35 -0500 | [diff] [blame] | 408 | } |
Amith Yamasani | b0b37ae | 2012-04-23 15:35:36 -0700 | [diff] [blame] | 409 | |
| 410 | @Override |
| 411 | protected int getHelpResource() { |
| 412 | return R.string.help_url_more_networks; |
| 413 | } |
David Braun | 4e9f04d | 2013-09-16 13:45:42 -0700 | [diff] [blame] | 414 | |
Fabrice Di Meglio | dba577f | 2014-06-06 16:31:45 -0700 | [diff] [blame] | 415 | /** |
| 416 | * For Search. |
| 417 | */ |
| 418 | public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = |
| 419 | new BaseSearchIndexProvider() { |
| 420 | @Override |
| 421 | public List<SearchIndexableResource> getXmlResourcesToIndex( |
| 422 | Context context, boolean enabled) { |
Fyodor Kupolov | ca060e3 | 2016-06-24 13:01:11 -0700 | [diff] [blame] | 423 | // Remove wireless settings from search in demo mode |
| 424 | if (UserManager.isDeviceInDemoMode(context)) { |
| 425 | return Collections.emptyList(); |
| 426 | } |
Fabrice Di Meglio | dba577f | 2014-06-06 16:31:45 -0700 | [diff] [blame] | 427 | SearchIndexableResource sir = new SearchIndexableResource(context); |
| 428 | sir.xmlResId = R.xml.wireless_settings; |
| 429 | return Arrays.asList(sir); |
| 430 | } |
| 431 | |
| 432 | @Override |
| 433 | public List<String> getNonIndexableKeys(Context context) { |
| 434 | final ArrayList<String> result = new ArrayList<String>(); |
| 435 | |
Julia Reynolds | 00d19c7 | 2014-06-24 15:22:50 -0400 | [diff] [blame] | 436 | final UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE); |
Xiaohui Chen | 44879a3 | 2015-07-22 13:53:22 -0700 | [diff] [blame] | 437 | final boolean isSecondaryUser = !um.isAdminUser(); |
Amith Yamasani | 32505ac | 2014-11-12 13:46:43 -0800 | [diff] [blame] | 438 | final boolean isWimaxEnabled = !isSecondaryUser |
| 439 | && context.getResources().getBoolean( |
Fabrice Di Meglio | dba577f | 2014-06-06 16:31:45 -0700 | [diff] [blame] | 440 | com.android.internal.R.bool.config_wimaxEnabled); |
Sudheer Shanka | 8b86830 | 2016-01-26 13:50:23 +0000 | [diff] [blame] | 441 | if (!isWimaxEnabled) { |
Fabrice Di Meglio | dba577f | 2014-06-06 16:31:45 -0700 | [diff] [blame] | 442 | result.add(KEY_WIMAX_SETTINGS); |
| 443 | } |
| 444 | |
| 445 | if (isSecondaryUser) { // Disable VPN |
| 446 | result.add(KEY_VPN_SETTINGS); |
| 447 | } |
| 448 | |
| 449 | // Remove NFC if not available |
Amith Yamasani | 32505ac | 2014-11-12 13:46:43 -0800 | [diff] [blame] | 450 | final NfcManager manager = (NfcManager) |
| 451 | context.getSystemService(Context.NFC_SERVICE); |
Fabrice Di Meglio | dba577f | 2014-06-06 16:31:45 -0700 | [diff] [blame] | 452 | if (manager != null) { |
| 453 | NfcAdapter adapter = manager.getDefaultAdapter(); |
| 454 | if (adapter == null) { |
| 455 | result.add(KEY_TOGGLE_NFC); |
| 456 | result.add(KEY_ANDROID_BEAM_SETTINGS); |
| 457 | } |
| 458 | } |
| 459 | |
| 460 | // Remove Mobile Network Settings and Manage Mobile Plan if it's a wifi-only device. |
| 461 | if (isSecondaryUser || Utils.isWifiOnly(context)) { |
| 462 | result.add(KEY_MOBILE_NETWORK_SETTINGS); |
| 463 | result.add(KEY_MANAGE_MOBILE_PLAN); |
| 464 | } |
| 465 | |
| 466 | // Remove Mobile Network Settings and Manage Mobile Plan |
| 467 | // if config_show_mobile_plan sets false. |
| 468 | final boolean isMobilePlanEnabled = context.getResources().getBoolean( |
| 469 | R.bool.config_show_mobile_plan); |
| 470 | if (!isMobilePlanEnabled) { |
| 471 | result.add(KEY_MANAGE_MOBILE_PLAN); |
| 472 | } |
| 473 | |
Fabrice Di Meglio | dba577f | 2014-06-06 16:31:45 -0700 | [diff] [blame] | 474 | final PackageManager pm = context.getPackageManager(); |
| 475 | |
| 476 | // Remove Airplane Mode settings if it's a stationary device such as a TV. |
| 477 | if (pm.hasSystemFeature(PackageManager.FEATURE_TELEVISION)) { |
| 478 | result.add(KEY_TOGGLE_AIRPLANE); |
| 479 | } |
| 480 | |
| 481 | // proxy UI disabled until we have better app support |
| 482 | result.add(KEY_PROXY_SETTINGS); |
| 483 | |
| 484 | // Disable Tethering if it's not allowed or if it's a wifi-only device |
Amith Yamasani | 32505ac | 2014-11-12 13:46:43 -0800 | [diff] [blame] | 485 | ConnectivityManager cm = (ConnectivityManager) |
| 486 | context.getSystemService(Context.CONNECTIVITY_SERVICE); |
Fabrice Di Meglio | dba577f | 2014-06-06 16:31:45 -0700 | [diff] [blame] | 487 | if (isSecondaryUser || !cm.isTetheringSupported()) { |
| 488 | result.add(KEY_TETHER_SETTINGS); |
| 489 | } |
| 490 | |
Pavel Zhamaitsiak | e2f59b9 | 2016-06-20 17:52:48 -0700 | [diff] [blame] | 491 | if (!ImsManager.isWfcEnabledByPlatform(context) || |
| 492 | !ImsManager.isWfcProvisionedOnDevice(context)) { |
Anju Mathapati | ec4706a | 2015-07-27 17:14:14 +0530 | [diff] [blame] | 493 | result.add(KEY_WFC_SETTINGS); |
| 494 | } |
| 495 | |
Doris Ling | e6f635f | 2016-06-07 17:56:00 -0700 | [diff] [blame] | 496 | if (RestrictedLockUtils.hasBaseUserRestriction(context, |
| 497 | UserManager.DISALLOW_NETWORK_RESET, UserHandle.myUserId())) { |
| 498 | result.add(KEY_NETWORK_RESET); |
| 499 | } |
| 500 | |
Fabrice Di Meglio | dba577f | 2014-06-06 16:31:45 -0700 | [diff] [blame] | 501 | return result; |
| 502 | } |
| 503 | }; |
The Android Open Source Project | afc4ab2 | 2009-03-03 19:32:34 -0800 | [diff] [blame] | 504 | } |