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