blob: ee4f018bf6ac1001b55504047df9ce5a755e811f [file] [log] [blame]
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08001/*
Chia-chi Yeh4e142112009-12-25 14:48:46 +08002 * Copyright (C) 2009 The Android Open Source Project
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -08003 *
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
17package com.android.settings;
18
Geoffrey Borggaardfe21d9a2013-08-02 18:16:27 -040019
Amith Yamasanid7993472010-08-18 13:59:28 -070020import android.app.Activity;
Wink Saville5d5a2692013-06-29 07:54:13 -070021import android.app.AlertDialog;
22import android.app.Dialog;
Amith Yamasanid7993472010-08-18 13:59:28 -070023import android.app.admin.DevicePolicyManager;
Amith Yamasanid7993472010-08-18 13:59:28 -070024import android.content.Context;
Wink Saville5d5a2692013-06-29 07:54:13 -070025import android.content.DialogInterface;
Amith Yamasanid7993472010-08-18 13:59:28 -070026import android.content.Intent;
Irfan Sheriff167d7182011-09-07 14:51:11 -070027import android.content.pm.PackageManager;
Wink Saville5d5a2692013-06-29 07:54:13 -070028import android.content.res.Resources;
Amith Yamasanid7993472010-08-18 13:59:28 -070029import android.net.ConnectivityManager;
Wink Saville5d5a2692013-06-29 07:54:13 -070030import android.net.NetworkInfo;
Nick Pellya57eace2010-10-15 01:19:43 -070031import android.nfc.NfcAdapter;
Amith Yamasanid7993472010-08-18 13:59:28 -070032import android.os.Bundle;
Amith Yamasanid7993472010-08-18 13:59:28 -070033import android.os.SystemProperties;
Amith Yamasani9627a8e2012-09-23 12:54:14 -070034import android.os.UserHandle;
Amith Yamasanid7993472010-08-18 13:59:28 -070035import android.preference.CheckBoxPreference;
36import android.preference.Preference;
37import android.preference.PreferenceScreen;
38import android.provider.Settings;
Wink Saville5d5a2692013-06-29 07:54:13 -070039import android.telephony.TelephonyManager;
40import android.text.TextUtils;
41import android.util.Log;
Gilles Debunnee78c1872011-06-20 15:00:07 -070042import com.android.internal.telephony.TelephonyIntents;
43import com.android.internal.telephony.TelephonyProperties;
44import com.android.settings.nfc.NfcEnabler;
Irfan Sheriff536c3d72012-04-17 23:17:46 -070045import com.android.settings.NsdEnabler;
Gilles Debunnee78c1872011-06-20 15:00:07 -070046
Geoffrey Borggaardfe21d9a2013-08-02 18:16:27 -040047public class WirelessSettings extends RestrictedSettingsFragment {
Robert Greenwalt4929e912013-07-16 13:09:24 -070048 private static final String TAG = "WirelessSettings";
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080049
50 private static final String KEY_TOGGLE_AIRPLANE = "toggle_airplane";
Nick Pellyad50ba02010-09-22 10:55:13 -070051 private static final String KEY_TOGGLE_NFC = "toggle_nfc";
tk.mun7c5c1652011-10-13 22:56:18 +090052 private static final String KEY_WIMAX_SETTINGS = "wimax_settings";
Jeff Hamilton3d670de2011-09-21 16:44:36 -050053 private static final String KEY_ANDROID_BEAM_SETTINGS = "android_beam_settings";
Mike Lockwood83bcc982009-07-29 23:25:10 -070054 private static final String KEY_VPN_SETTINGS = "vpn_settings";
Robert Greenwaltc4764d22010-02-12 14:21:37 -080055 private static final String KEY_TETHER_SETTINGS = "tether_settings";
Oscar Montemayor05411892010-08-03 16:56:09 -070056 private static final String KEY_PROXY_SETTINGS = "proxy_settings";
Amith Yamasani0f85c482011-02-23 17:19:11 -080057 private static final String KEY_MOBILE_NETWORK_SETTINGS = "mobile_network_settings";
Wink Saville5d5a2692013-06-29 07:54:13 -070058 private static final String KEY_MANAGE_MOBILE_PLAN = "manage_mobile_plan";
Irfan Sheriff536c3d72012-04-17 23:17:46 -070059 private static final String KEY_TOGGLE_NSD = "toggle_nsd"; //network service discovery
Jake Hambyef57ed72012-06-21 10:59:22 -070060 private static final String KEY_CELL_BROADCAST_SETTINGS = "cell_broadcast_settings";
Nick Pellyad50ba02010-09-22 10:55:13 -070061
Chouting Zhang71cc49e2009-08-28 14:36:35 -050062 public static final String EXIT_ECM_RESULT = "exit_ecm_result";
63 public static final int REQUEST_CODE_EXIT_ECM = 1;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080064
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080065 private AirplaneModeEnabler mAirplaneModeEnabler;
Chouting Zhang71cc49e2009-08-28 14:36:35 -050066 private CheckBoxPreference mAirplaneModePreference;
Nick Pellyad50ba02010-09-22 10:55:13 -070067 private NfcEnabler mNfcEnabler;
Martijn Coenenbb4bdc22011-07-27 17:31:41 -050068 private NfcAdapter mNfcAdapter;
Irfan Sheriff536c3d72012-04-17 23:17:46 -070069 private NsdEnabler mNsdEnabler;
Chouting Zhang71cc49e2009-08-28 14:36:35 -050070
Wink Saville5d5a2692013-06-29 07:54:13 -070071 private ConnectivityManager mCm;
72 private TelephonyManager mTm;
73
74 private static final int MANAGE_MOBILE_PLAN_DIALOG_ID = 1;
75 private static final String SAVED_MANAGE_MOBILE_PLAN_MSG = "mManageMobilePlanMessage";
76
Geoffrey Borggaardfe21d9a2013-08-02 18:16:27 -040077 public WirelessSettings() {
78 super(null);
79 }
Chouting Zhang71cc49e2009-08-28 14:36:35 -050080 /**
81 * Invoked on each preference click in this hierarchy, overrides
82 * PreferenceActivity's implementation. Used to make sure we track the
83 * preference click events.
84 */
85 @Override
86 public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
Geoffrey Borggaard6e1102d2013-08-07 14:57:43 -040087 if (ensurePinRestrictedPreference(preference)) {
88 return true;
Geoffrey Borggaardfe21d9a2013-08-02 18:16:27 -040089 }
Wink Saville5d5a2692013-06-29 07:54:13 -070090 log("onPreferenceTreeClick: preference=" + preference);
Chia-chi Yeh4e142112009-12-25 14:48:46 +080091 if (preference == mAirplaneModePreference && Boolean.parseBoolean(
92 SystemProperties.get(TelephonyProperties.PROPERTY_INECM_MODE))) {
Chouting Zhang71cc49e2009-08-28 14:36:35 -050093 // In ECM mode launch ECM app dialog
94 startActivityForResult(
95 new Intent(TelephonyIntents.ACTION_SHOW_NOTICE_ECM_BLOCK_OTHERS, null),
96 REQUEST_CODE_EXIT_ECM);
Chouting Zhang71cc49e2009-08-28 14:36:35 -050097 return true;
Wink Saville5d5a2692013-06-29 07:54:13 -070098 } else if (preference == findPreference(KEY_MANAGE_MOBILE_PLAN)) {
99 onManageMobilePlanClick();
Chouting Zhang71cc49e2009-08-28 14:36:35 -0500100 }
Chia-chi Yeh4e142112009-12-25 14:48:46 +0800101 // Let the intents be launched by the Preference manager
Amith Yamasanid7993472010-08-18 13:59:28 -0700102 return super.onPreferenceTreeClick(preferenceScreen, preference);
Chouting Zhang71cc49e2009-08-28 14:36:35 -0500103 }
Chia-chi Yehb90452f2010-01-13 06:11:29 +0800104
Wink Saville5d5a2692013-06-29 07:54:13 -0700105 private String mManageMobilePlanMessage;
Wink Savillee24e5962013-08-28 14:26:27 -0700106 private static final String MOBILE_PROVISIONING_ACTION
107 = "com.android.server.connectivityservice.MOBILE_PROVISIONING_ACTION";
Wink Saville5d5a2692013-06-29 07:54:13 -0700108 public void onManageMobilePlanClick() {
109 log("onManageMobilePlanClick:");
110 mManageMobilePlanMessage = null;
111 Resources resources = getActivity().getResources();
112
Wink Savillee24e5962013-08-28 14:26:27 -0700113 NetworkInfo ni = mCm.getProvisioningOrActiveNetworkInfo();
Wink Saville5d5a2692013-06-29 07:54:13 -0700114 if (mTm.hasIccCard() && (ni != null)) {
115 // Get provisioning URL
Robert Greenwalt4929e912013-07-16 13:09:24 -0700116 String url = mCm.getMobileProvisioningUrl();
Wink Saville5d5a2692013-06-29 07:54:13 -0700117 if (!TextUtils.isEmpty(url)) {
Wink Savillee24e5962013-08-28 14:26:27 -0700118 Intent intent = new Intent(MOBILE_PROVISIONING_ACTION);
119 intent.putExtra("EXTRA_URL", url);
120 Context context = getActivity().getBaseContext();
121 context.sendBroadcast(intent);
Wink Saville5d5a2692013-06-29 07:54:13 -0700122 mManageMobilePlanMessage = null;
123 } else {
124 // No provisioning URL
125 String operatorName = mTm.getSimOperatorName();
126 if (TextUtils.isEmpty(operatorName)) {
127 // Use NetworkOperatorName as second choice in case there is no
128 // SPN (Service Provider Name on the SIM). Such as with T-mobile.
129 operatorName = mTm.getNetworkOperatorName();
130 if (TextUtils.isEmpty(operatorName)) {
131 mManageMobilePlanMessage = resources.getString(
132 R.string.mobile_unknown_sim_operator);
133 } else {
134 mManageMobilePlanMessage = resources.getString(
135 R.string.mobile_no_provisioning_url, operatorName);
136 }
137 } else {
138 mManageMobilePlanMessage = resources.getString(
139 R.string.mobile_no_provisioning_url, operatorName);
140 }
141 }
142 } else if (mTm.hasIccCard() == false) {
143 // No sim card
144 mManageMobilePlanMessage = resources.getString(R.string.mobile_insert_sim_card);
145 } else {
146 // NetworkInfo is null, there is no connection
147 mManageMobilePlanMessage = resources.getString(R.string.mobile_connect_to_internet);
148 }
149 if (!TextUtils.isEmpty(mManageMobilePlanMessage)) {
150 log("onManageMobilePlanClick: message=" + mManageMobilePlanMessage);
151 showDialog(MANAGE_MOBILE_PLAN_DIALOG_ID);
152 }
153 }
154
Wink Saville5d5a2692013-06-29 07:54:13 -0700155 @Override
156 public Dialog onCreateDialog(int dialogId) {
157 log("onCreateDialog: dialogId=" + dialogId);
158 switch (dialogId) {
159 case MANAGE_MOBILE_PLAN_DIALOG_ID:
160 return new AlertDialog.Builder(getActivity())
161 .setMessage(mManageMobilePlanMessage)
162 .setCancelable(false)
163 .setPositiveButton(com.android.internal.R.string.ok,
164 new DialogInterface.OnClickListener() {
165 @Override
166 public void onClick(DialogInterface dialog, int id) {
167 log("MANAGE_MOBILE_PLAN_DIALOG.onClickListener id=" + id);
168 mManageMobilePlanMessage = null;
169 }
170 })
171 .create();
172 }
173 return super.onCreateDialog(dialogId);
174 }
175
176 private void log(String s) {
177 Log.d(TAG, s);
178 }
179
Chia-chi Yehb90452f2010-01-13 06:11:29 +0800180 public static boolean isRadioAllowed(Context context, String type) {
181 if (!AirplaneModeEnabler.isAirplaneModeOn(context)) {
182 return true;
183 }
184 // Here we use the same logic in onCreate().
Christopher Tate6a5929b2012-09-10 15:39:05 -0700185 String toggleable = Settings.Global.getString(context.getContentResolver(),
186 Settings.Global.AIRPLANE_MODE_TOGGLEABLE_RADIOS);
Chia-chi Yehb90452f2010-01-13 06:11:29 +0800187 return toggleable != null && toggleable.contains(type);
188 }
189
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800190 @Override
Amith Yamasanid7993472010-08-18 13:59:28 -0700191 public void onCreate(Bundle savedInstanceState) {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800192 super.onCreate(savedInstanceState);
Wink Saville5d5a2692013-06-29 07:54:13 -0700193 if (savedInstanceState != null) {
194 mManageMobilePlanMessage = savedInstanceState.getString(SAVED_MANAGE_MOBILE_PLAN_MSG);
195 }
196 log("onCreate: mManageMobilePlanMessage=" + mManageMobilePlanMessage);
197
198 mCm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
199 mTm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800200
201 addPreferencesFromResource(R.xml.wireless_settings);
202
Amith Yamasani9627a8e2012-09-23 12:54:14 -0700203 final boolean isSecondaryUser = UserHandle.myUserId() != UserHandle.USER_OWNER;
204
Amith Yamasanid7993472010-08-18 13:59:28 -0700205 final Activity activity = getActivity();
Gilles Debunnee78c1872011-06-20 15:00:07 -0700206 mAirplaneModePreference = (CheckBoxPreference) findPreference(KEY_TOGGLE_AIRPLANE);
Nick Pellyad50ba02010-09-22 10:55:13 -0700207 CheckBoxPreference nfc = (CheckBoxPreference) findPreference(KEY_TOGGLE_NFC);
Jeff Hamilton3d670de2011-09-21 16:44:36 -0500208 PreferenceScreen androidBeam = (PreferenceScreen) findPreference(KEY_ANDROID_BEAM_SETTINGS);
Irfan Sheriff536c3d72012-04-17 23:17:46 -0700209 CheckBoxPreference nsd = (CheckBoxPreference) findPreference(KEY_TOGGLE_NSD);
Chia-chi Yeh4e142112009-12-25 14:48:46 +0800210
Gilles Debunnee78c1872011-06-20 15:00:07 -0700211 mAirplaneModeEnabler = new AirplaneModeEnabler(activity, mAirplaneModePreference);
Jeff Hamilton3d670de2011-09-21 16:44:36 -0500212 mNfcEnabler = new NfcEnabler(activity, nfc, androidBeam);
Irfan Sheriff936e3fa2012-05-07 15:51:37 -0700213
214 // Remove NSD checkbox by default
215 getPreferenceScreen().removePreference(nsd);
216 //mNsdEnabler = new NsdEnabler(activity, nsd);
Chia-chi Yeh4e142112009-12-25 14:48:46 +0800217
Christopher Tate6a5929b2012-09-10 15:39:05 -0700218 String toggleable = Settings.Global.getString(activity.getContentResolver(),
219 Settings.Global.AIRPLANE_MODE_TOGGLEABLE_RADIOS);
Chia-chi Yeh4e142112009-12-25 14:48:46 +0800220
tk.mun7c5c1652011-10-13 22:56:18 +0900221 //enable/disable wimax depending on the value in config.xml
Amith Yamasani9627a8e2012-09-23 12:54:14 -0700222 boolean isWimaxEnabled = !isSecondaryUser && this.getResources().getBoolean(
tk.mun7c5c1652011-10-13 22:56:18 +0900223 com.android.internal.R.bool.config_wimaxEnabled);
224 if (!isWimaxEnabled) {
225 PreferenceScreen root = getPreferenceScreen();
226 Preference ps = (Preference) findPreference(KEY_WIMAX_SETTINGS);
227 if (ps != null) root.removePreference(ps);
228 } else {
Christopher Tate6a5929b2012-09-10 15:39:05 -0700229 if (toggleable == null || !toggleable.contains(Settings.Global.RADIO_WIMAX )
tk.mun7c5c1652011-10-13 22:56:18 +0900230 && isWimaxEnabled) {
231 Preference ps = (Preference) findPreference(KEY_WIMAX_SETTINGS);
232 ps.setDependency(KEY_TOGGLE_AIRPLANE);
233 }
234 }
Geoffrey Borggaardfe21d9a2013-08-02 18:16:27 -0400235 protectByRestrictions(KEY_WIMAX_SETTINGS);
236
Chia-chi Yehb90452f2010-01-13 06:11:29 +0800237 // Manually set dependencies for Wifi when not toggleable.
Christopher Tate6a5929b2012-09-10 15:39:05 -0700238 if (toggleable == null || !toggleable.contains(Settings.Global.RADIO_WIFI)) {
Chia-chi Yeh4e142112009-12-25 14:48:46 +0800239 findPreference(KEY_VPN_SETTINGS).setDependency(KEY_TOGGLE_AIRPLANE);
240 }
Amith Yamasani9627a8e2012-09-23 12:54:14 -0700241 if (isSecondaryUser) { // Disable VPN
242 removePreference(KEY_VPN_SETTINGS);
243 }
Geoffrey Borggaardfe21d9a2013-08-02 18:16:27 -0400244 protectByRestrictions(KEY_VPN_SETTINGS);
Chia-chi Yeh4e142112009-12-25 14:48:46 +0800245 // Manually set dependencies for Bluetooth when not toggleable.
Christopher Tate6a5929b2012-09-10 15:39:05 -0700246 if (toggleable == null || !toggleable.contains(Settings.Global.RADIO_BLUETOOTH)) {
Gilles Debunnee78c1872011-06-20 15:00:07 -0700247 // No bluetooth-dependent items in the list. Code kept in case one is added later.
Nick Pellyad50ba02010-09-22 10:55:13 -0700248 }
249
Nick Pelly9894d4a2011-08-09 07:10:16 -0700250 // Manually set dependencies for NFC when not toggleable.
Christopher Tate6a5929b2012-09-10 15:39:05 -0700251 if (toggleable == null || !toggleable.contains(Settings.Global.RADIO_NFC)) {
Nick Pelly9894d4a2011-08-09 07:10:16 -0700252 findPreference(KEY_TOGGLE_NFC).setDependency(KEY_TOGGLE_AIRPLANE);
Jeff Hamilton3d670de2011-09-21 16:44:36 -0500253 findPreference(KEY_ANDROID_BEAM_SETTINGS).setDependency(KEY_TOGGLE_AIRPLANE);
Nick Pelly9894d4a2011-08-09 07:10:16 -0700254 }
255
Nick Pellyad50ba02010-09-22 10:55:13 -0700256 // Remove NFC if its not available
Martijn Coenenbb4bdc22011-07-27 17:31:41 -0500257 mNfcAdapter = NfcAdapter.getDefaultAdapter(activity);
258 if (mNfcAdapter == null) {
Nick Pellyad50ba02010-09-22 10:55:13 -0700259 getPreferenceScreen().removePreference(nfc);
Jeff Hamilton3d670de2011-09-21 16:44:36 -0500260 getPreferenceScreen().removePreference(androidBeam);
Nick Pelly9894d4a2011-08-09 07:10:16 -0700261 mNfcEnabler = null;
Chia-chi Yeh4e142112009-12-25 14:48:46 +0800262 }
Robert Greenwaltc4764d22010-02-12 14:21:37 -0800263
Wink Saville5d5a2692013-06-29 07:54:13 -0700264 // Remove Mobile Network Settings and Manage Mobile Plan if it's a wifi-only device.
Amith Yamasani9627a8e2012-09-23 12:54:14 -0700265 if (isSecondaryUser || Utils.isWifiOnly(getActivity())) {
266 removePreference(KEY_MOBILE_NETWORK_SETTINGS);
Wink Saville5d5a2692013-06-29 07:54:13 -0700267 removePreference(KEY_MANAGE_MOBILE_PLAN);
Amith Yamasani0f85c482011-02-23 17:19:11 -0800268 }
Geoffrey Borggaardfe21d9a2013-08-02 18:16:27 -0400269 protectByRestrictions(KEY_MOBILE_NETWORK_SETTINGS);
270 protectByRestrictions(KEY_MANAGE_MOBILE_PLAN);
Amith Yamasani0f85c482011-02-23 17:19:11 -0800271
Jaewan Kim2e41e3d2013-04-19 13:40:23 +0900272 // Remove Airplane Mode settings if it's a stationary device such as a TV.
273 if (getActivity().getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEVISION)) {
274 removePreference(KEY_TOGGLE_AIRPLANE);
275 }
276
Oscar Montemayor05411892010-08-03 16:56:09 -0700277 // Enable Proxy selector settings if allowed.
278 Preference mGlobalProxy = findPreference(KEY_PROXY_SETTINGS);
Amith Yamasanid7993472010-08-18 13:59:28 -0700279 DevicePolicyManager mDPM = (DevicePolicyManager)
280 activity.getSystemService(Context.DEVICE_POLICY_SERVICE);
Robert Greenwalt6f3a98b2010-12-28 16:11:12 -0800281 // proxy UI disabled until we have better app support
282 getPreferenceScreen().removePreference(mGlobalProxy);
Oscar Montemayor05411892010-08-03 16:56:09 -0700283 mGlobalProxy.setEnabled(mDPM.getGlobalProxyAdmin() == null);
284
Amith Yamasani0f85c482011-02-23 17:19:11 -0800285 // Disable Tethering if it's not allowed or if it's a wifi-only device
Robert Greenwaltc4764d22010-02-12 14:21:37 -0800286 ConnectivityManager cm =
Amith Yamasanid7993472010-08-18 13:59:28 -0700287 (ConnectivityManager) activity.getSystemService(Context.CONNECTIVITY_SERVICE);
Amith Yamasani9627a8e2012-09-23 12:54:14 -0700288 if (isSecondaryUser || !cm.isTetheringSupported()) {
Robert Greenwaltc4764d22010-02-12 14:21:37 -0800289 getPreferenceScreen().removePreference(findPreference(KEY_TETHER_SETTINGS));
Robert Greenwalte434bfb2010-05-08 15:20:24 -0700290 } else {
Robert Greenwalte434bfb2010-05-08 15:20:24 -0700291 Preference p = findPreference(KEY_TETHER_SETTINGS);
Jeff Sharkeya83a24f2011-09-16 01:52:39 -0700292 p.setTitle(Utils.getTetheringLabel(cm));
Robert Greenwaltc4764d22010-02-12 14:21:37 -0800293 }
Geoffrey Borggaardfe21d9a2013-08-02 18:16:27 -0400294 protectByRestrictions(KEY_TETHER_SETTINGS);
Jake Hambyef57ed72012-06-21 10:59:22 -0700295
296 // Enable link to CMAS app settings depending on the value in config.xml.
297 boolean isCellBroadcastAppLinkEnabled = this.getResources().getBoolean(
298 com.android.internal.R.bool.config_cellBroadcastAppLinks);
299 try {
300 if (isCellBroadcastAppLinkEnabled) {
301 PackageManager pm = getPackageManager();
302 if (pm.getApplicationEnabledSetting("com.android.cellbroadcastreceiver")
303 == PackageManager.COMPONENT_ENABLED_STATE_DISABLED) {
304 isCellBroadcastAppLinkEnabled = false; // CMAS app disabled
305 }
306 }
307 } catch (IllegalArgumentException ignored) {
308 isCellBroadcastAppLinkEnabled = false; // CMAS app not installed
309 }
Amith Yamasani9627a8e2012-09-23 12:54:14 -0700310 if (isSecondaryUser || !isCellBroadcastAppLinkEnabled) {
Jake Hambyef57ed72012-06-21 10:59:22 -0700311 PreferenceScreen root = getPreferenceScreen();
312 Preference ps = findPreference(KEY_CELL_BROADCAST_SETTINGS);
313 if (ps != null) root.removePreference(ps);
314 }
Geoffrey Borggaardfe21d9a2013-08-02 18:16:27 -0400315 protectByRestrictions(KEY_CELL_BROADCAST_SETTINGS);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800316 }
Robert Greenwaltc4764d22010-02-12 14:21:37 -0800317
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800318 @Override
Amith Yamasanid7993472010-08-18 13:59:28 -0700319 public void onResume() {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800320 super.onResume();
Danica Chang32711b62010-08-10 18:41:29 -0700321
Chia-chi Yeh4e142112009-12-25 14:48:46 +0800322 mAirplaneModeEnabler.resume();
Nick Pelly9894d4a2011-08-09 07:10:16 -0700323 if (mNfcEnabler != null) {
324 mNfcEnabler.resume();
Martijn Coenenbb4bdc22011-07-27 17:31:41 -0500325 }
Irfan Sheriff936e3fa2012-05-07 15:51:37 -0700326 if (mNsdEnabler != null) {
327 mNsdEnabler.resume();
328 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800329 }
Danica Chang32711b62010-08-10 18:41:29 -0700330
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800331 @Override
Wink Saville5d5a2692013-06-29 07:54:13 -0700332 public void onSaveInstanceState(Bundle outState) {
333 super.onSaveInstanceState(outState);
334
335 if (!TextUtils.isEmpty(mManageMobilePlanMessage)) {
336 outState.putString(SAVED_MANAGE_MOBILE_PLAN_MSG, mManageMobilePlanMessage);
337 }
338 }
339
340 @Override
Amith Yamasanid7993472010-08-18 13:59:28 -0700341 public void onPause() {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800342 super.onPause();
Danica Chang32711b62010-08-10 18:41:29 -0700343
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800344 mAirplaneModeEnabler.pause();
Nick Pelly9894d4a2011-08-09 07:10:16 -0700345 if (mNfcEnabler != null) {
346 mNfcEnabler.pause();
347 }
Irfan Sheriff936e3fa2012-05-07 15:51:37 -0700348 if (mNsdEnabler != null) {
349 mNsdEnabler.pause();
350 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800351 }
Danica Chang32711b62010-08-10 18:41:29 -0700352
Chouting Zhang71cc49e2009-08-28 14:36:35 -0500353 @Override
Amith Yamasanid7993472010-08-18 13:59:28 -0700354 public void onActivityResult(int requestCode, int resultCode, Intent data) {
Chia-chi Yeh4e142112009-12-25 14:48:46 +0800355 if (requestCode == REQUEST_CODE_EXIT_ECM) {
356 Boolean isChoiceYes = data.getBooleanExtra(EXIT_ECM_RESULT, false);
Chouting Zhang71cc49e2009-08-28 14:36:35 -0500357 // Set Airplane mode based on the return value and checkbox state
358 mAirplaneModeEnabler.setAirplaneModeInECM(isChoiceYes,
359 mAirplaneModePreference.isChecked());
Chouting Zhang71cc49e2009-08-28 14:36:35 -0500360 }
Geoffrey Borggaardfe21d9a2013-08-02 18:16:27 -0400361 super.onActivityResult(requestCode, resultCode, data);
Chouting Zhang71cc49e2009-08-28 14:36:35 -0500362 }
Amith Yamasanib0b37ae2012-04-23 15:35:36 -0700363
364 @Override
365 protected int getHelpResource() {
366 return R.string.help_url_more_networks;
367 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800368}