blob: ecb984d338168db847bca50679981c05b2aa81f5 [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 -040019import java.util.HashSet;
20
Amith Yamasanid7993472010-08-18 13:59:28 -070021import android.app.Activity;
Wink Saville5d5a2692013-06-29 07:54:13 -070022import android.app.AlertDialog;
23import android.app.Dialog;
Amith Yamasanid7993472010-08-18 13:59:28 -070024import android.app.admin.DevicePolicyManager;
Amith Yamasanid7993472010-08-18 13:59:28 -070025import android.content.Context;
Wink Saville5d5a2692013-06-29 07:54:13 -070026import android.content.DialogInterface;
Amith Yamasanid7993472010-08-18 13:59:28 -070027import android.content.Intent;
Irfan Sheriff167d7182011-09-07 14:51:11 -070028import android.content.pm.PackageManager;
Wink Saville5d5a2692013-06-29 07:54:13 -070029import android.content.res.Resources;
Amith Yamasanid7993472010-08-18 13:59:28 -070030import android.net.ConnectivityManager;
Wink Saville5d5a2692013-06-29 07:54:13 -070031import android.net.NetworkInfo;
32import android.net.Uri;
Nick Pellya57eace2010-10-15 01:19:43 -070033import android.nfc.NfcAdapter;
Amith Yamasanid7993472010-08-18 13:59:28 -070034import android.os.Bundle;
Amith Yamasanid7993472010-08-18 13:59:28 -070035import android.os.SystemProperties;
Amith Yamasani9627a8e2012-09-23 12:54:14 -070036import android.os.UserHandle;
Amith Yamasanid7993472010-08-18 13:59:28 -070037import android.preference.CheckBoxPreference;
38import android.preference.Preference;
39import android.preference.PreferenceScreen;
40import android.provider.Settings;
Wink Saville5d5a2692013-06-29 07:54:13 -070041import android.telephony.TelephonyManager;
42import android.text.TextUtils;
43import android.util.Log;
Gilles Debunnee78c1872011-06-20 15:00:07 -070044import com.android.internal.telephony.TelephonyIntents;
45import com.android.internal.telephony.TelephonyProperties;
46import com.android.settings.nfc.NfcEnabler;
Irfan Sheriff536c3d72012-04-17 23:17:46 -070047import com.android.settings.NsdEnabler;
Gilles Debunnee78c1872011-06-20 15:00:07 -070048
Geoffrey Borggaardfe21d9a2013-08-02 18:16:27 -040049public class WirelessSettings extends RestrictedSettingsFragment {
Robert Greenwalt4929e912013-07-16 13:09:24 -070050 private static final String TAG = "WirelessSettings";
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080051
52 private static final String KEY_TOGGLE_AIRPLANE = "toggle_airplane";
Nick Pellyad50ba02010-09-22 10:55:13 -070053 private static final String KEY_TOGGLE_NFC = "toggle_nfc";
tk.mun7c5c1652011-10-13 22:56:18 +090054 private static final String KEY_WIMAX_SETTINGS = "wimax_settings";
Jeff Hamilton3d670de2011-09-21 16:44:36 -050055 private static final String KEY_ANDROID_BEAM_SETTINGS = "android_beam_settings";
Mike Lockwood83bcc982009-07-29 23:25:10 -070056 private static final String KEY_VPN_SETTINGS = "vpn_settings";
Robert Greenwaltc4764d22010-02-12 14:21:37 -080057 private static final String KEY_TETHER_SETTINGS = "tether_settings";
Oscar Montemayor05411892010-08-03 16:56:09 -070058 private static final String KEY_PROXY_SETTINGS = "proxy_settings";
Amith Yamasani0f85c482011-02-23 17:19:11 -080059 private static final String KEY_MOBILE_NETWORK_SETTINGS = "mobile_network_settings";
Wink Saville5d5a2692013-06-29 07:54:13 -070060 private static final String KEY_MANAGE_MOBILE_PLAN = "manage_mobile_plan";
Irfan Sheriff536c3d72012-04-17 23:17:46 -070061 private static final String KEY_TOGGLE_NSD = "toggle_nsd"; //network service discovery
Jake Hambyef57ed72012-06-21 10:59:22 -070062 private static final String KEY_CELL_BROADCAST_SETTINGS = "cell_broadcast_settings";
Nick Pellyad50ba02010-09-22 10:55:13 -070063
Chouting Zhang71cc49e2009-08-28 14:36:35 -050064 public static final String EXIT_ECM_RESULT = "exit_ecm_result";
65 public static final int REQUEST_CODE_EXIT_ECM = 1;
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080066
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -080067 private AirplaneModeEnabler mAirplaneModeEnabler;
Chouting Zhang71cc49e2009-08-28 14:36:35 -050068 private CheckBoxPreference mAirplaneModePreference;
Nick Pellyad50ba02010-09-22 10:55:13 -070069 private NfcEnabler mNfcEnabler;
Martijn Coenenbb4bdc22011-07-27 17:31:41 -050070 private NfcAdapter mNfcAdapter;
Irfan Sheriff536c3d72012-04-17 23:17:46 -070071 private NsdEnabler mNsdEnabler;
Chouting Zhang71cc49e2009-08-28 14:36:35 -050072
Wink Saville5d5a2692013-06-29 07:54:13 -070073 private ConnectivityManager mCm;
74 private TelephonyManager mTm;
75
76 private static final int MANAGE_MOBILE_PLAN_DIALOG_ID = 1;
77 private static final String SAVED_MANAGE_MOBILE_PLAN_MSG = "mManageMobilePlanMessage";
Geoffrey Borggaardfe21d9a2013-08-02 18:16:27 -040078 private final HashSet<Preference> mProtectedByRestictionsPrefs = new HashSet<Preference>();
Wink Saville5d5a2692013-06-29 07:54:13 -070079
Geoffrey Borggaardfe21d9a2013-08-02 18:16:27 -040080 public WirelessSettings() {
81 super(null);
82 }
Chouting Zhang71cc49e2009-08-28 14:36:35 -050083 /**
84 * Invoked on each preference click in this hierarchy, overrides
85 * PreferenceActivity's implementation. Used to make sure we track the
86 * preference click events.
87 */
88 @Override
89 public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
Geoffrey Borggaardfe21d9a2013-08-02 18:16:27 -040090 if (mProtectedByRestictionsPrefs.contains(preference) && !hasChallengeSucceeded()) {
91 restrictionsPinCheck(RESTRICTIONS_PIN_SET);
92 return false;
93 }
Wink Saville5d5a2692013-06-29 07:54:13 -070094 log("onPreferenceTreeClick: preference=" + preference);
Chia-chi Yeh4e142112009-12-25 14:48:46 +080095 if (preference == mAirplaneModePreference && Boolean.parseBoolean(
96 SystemProperties.get(TelephonyProperties.PROPERTY_INECM_MODE))) {
Chouting Zhang71cc49e2009-08-28 14:36:35 -050097 // In ECM mode launch ECM app dialog
98 startActivityForResult(
99 new Intent(TelephonyIntents.ACTION_SHOW_NOTICE_ECM_BLOCK_OTHERS, null),
100 REQUEST_CODE_EXIT_ECM);
Chouting Zhang71cc49e2009-08-28 14:36:35 -0500101 return true;
Wink Saville5d5a2692013-06-29 07:54:13 -0700102 } else if (preference == findPreference(KEY_MANAGE_MOBILE_PLAN)) {
103 onManageMobilePlanClick();
Chouting Zhang71cc49e2009-08-28 14:36:35 -0500104 }
Chia-chi Yeh4e142112009-12-25 14:48:46 +0800105 // Let the intents be launched by the Preference manager
Amith Yamasanid7993472010-08-18 13:59:28 -0700106 return super.onPreferenceTreeClick(preferenceScreen, preference);
Chouting Zhang71cc49e2009-08-28 14:36:35 -0500107 }
Chia-chi Yehb90452f2010-01-13 06:11:29 +0800108
Wink Saville5d5a2692013-06-29 07:54:13 -0700109 private String mManageMobilePlanMessage;
110
111 public void onManageMobilePlanClick() {
112 log("onManageMobilePlanClick:");
113 mManageMobilePlanMessage = null;
114 Resources resources = getActivity().getResources();
115
116 NetworkInfo ni = mCm.getActiveNetworkInfo();
117 if (mTm.hasIccCard() && (ni != null)) {
118 // Get provisioning URL
Robert Greenwalt4929e912013-07-16 13:09:24 -0700119 String url = mCm.getMobileProvisioningUrl();
Wink Saville5d5a2692013-06-29 07:54:13 -0700120 if (!TextUtils.isEmpty(url)) {
121 // Send user to provisioning webpage
122 Intent intent = new Intent(Intent.ACTION_VIEW);
123 intent.setData(Uri.parse(url));
124 startActivity(intent);
125 mManageMobilePlanMessage = null;
126 } else {
127 // No provisioning URL
128 String operatorName = mTm.getSimOperatorName();
129 if (TextUtils.isEmpty(operatorName)) {
130 // Use NetworkOperatorName as second choice in case there is no
131 // SPN (Service Provider Name on the SIM). Such as with T-mobile.
132 operatorName = mTm.getNetworkOperatorName();
133 if (TextUtils.isEmpty(operatorName)) {
134 mManageMobilePlanMessage = resources.getString(
135 R.string.mobile_unknown_sim_operator);
136 } else {
137 mManageMobilePlanMessage = resources.getString(
138 R.string.mobile_no_provisioning_url, operatorName);
139 }
140 } else {
141 mManageMobilePlanMessage = resources.getString(
142 R.string.mobile_no_provisioning_url, operatorName);
143 }
144 }
145 } else if (mTm.hasIccCard() == false) {
146 // No sim card
147 mManageMobilePlanMessage = resources.getString(R.string.mobile_insert_sim_card);
148 } else {
149 // NetworkInfo is null, there is no connection
150 mManageMobilePlanMessage = resources.getString(R.string.mobile_connect_to_internet);
151 }
152 if (!TextUtils.isEmpty(mManageMobilePlanMessage)) {
153 log("onManageMobilePlanClick: message=" + mManageMobilePlanMessage);
154 showDialog(MANAGE_MOBILE_PLAN_DIALOG_ID);
155 }
156 }
157
Geoffrey Borggaardfe21d9a2013-08-02 18:16:27 -0400158 private void protectByRestrictions(String key) {
159 Preference pref = findPreference(key);
160 if (pref != null) {
161 mProtectedByRestictionsPrefs.add(pref);
162 }
163 }
164
Wink Saville5d5a2692013-06-29 07:54:13 -0700165 @Override
166 public Dialog onCreateDialog(int dialogId) {
167 log("onCreateDialog: dialogId=" + dialogId);
168 switch (dialogId) {
169 case MANAGE_MOBILE_PLAN_DIALOG_ID:
170 return new AlertDialog.Builder(getActivity())
171 .setMessage(mManageMobilePlanMessage)
172 .setCancelable(false)
173 .setPositiveButton(com.android.internal.R.string.ok,
174 new DialogInterface.OnClickListener() {
175 @Override
176 public void onClick(DialogInterface dialog, int id) {
177 log("MANAGE_MOBILE_PLAN_DIALOG.onClickListener id=" + id);
178 mManageMobilePlanMessage = null;
179 }
180 })
181 .create();
182 }
183 return super.onCreateDialog(dialogId);
184 }
185
186 private void log(String s) {
187 Log.d(TAG, s);
188 }
189
Chia-chi Yehb90452f2010-01-13 06:11:29 +0800190 public static boolean isRadioAllowed(Context context, String type) {
191 if (!AirplaneModeEnabler.isAirplaneModeOn(context)) {
192 return true;
193 }
194 // Here we use the same logic in onCreate().
Christopher Tate6a5929b2012-09-10 15:39:05 -0700195 String toggleable = Settings.Global.getString(context.getContentResolver(),
196 Settings.Global.AIRPLANE_MODE_TOGGLEABLE_RADIOS);
Chia-chi Yehb90452f2010-01-13 06:11:29 +0800197 return toggleable != null && toggleable.contains(type);
198 }
199
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800200 @Override
Amith Yamasanid7993472010-08-18 13:59:28 -0700201 public void onCreate(Bundle savedInstanceState) {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800202 super.onCreate(savedInstanceState);
Wink Saville5d5a2692013-06-29 07:54:13 -0700203 if (savedInstanceState != null) {
204 mManageMobilePlanMessage = savedInstanceState.getString(SAVED_MANAGE_MOBILE_PLAN_MSG);
205 }
206 log("onCreate: mManageMobilePlanMessage=" + mManageMobilePlanMessage);
207
208 mCm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
209 mTm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800210
211 addPreferencesFromResource(R.xml.wireless_settings);
212
Amith Yamasani9627a8e2012-09-23 12:54:14 -0700213 final boolean isSecondaryUser = UserHandle.myUserId() != UserHandle.USER_OWNER;
214
Amith Yamasanid7993472010-08-18 13:59:28 -0700215 final Activity activity = getActivity();
Gilles Debunnee78c1872011-06-20 15:00:07 -0700216 mAirplaneModePreference = (CheckBoxPreference) findPreference(KEY_TOGGLE_AIRPLANE);
Nick Pellyad50ba02010-09-22 10:55:13 -0700217 CheckBoxPreference nfc = (CheckBoxPreference) findPreference(KEY_TOGGLE_NFC);
Jeff Hamilton3d670de2011-09-21 16:44:36 -0500218 PreferenceScreen androidBeam = (PreferenceScreen) findPreference(KEY_ANDROID_BEAM_SETTINGS);
Irfan Sheriff536c3d72012-04-17 23:17:46 -0700219 CheckBoxPreference nsd = (CheckBoxPreference) findPreference(KEY_TOGGLE_NSD);
Chia-chi Yeh4e142112009-12-25 14:48:46 +0800220
Gilles Debunnee78c1872011-06-20 15:00:07 -0700221 mAirplaneModeEnabler = new AirplaneModeEnabler(activity, mAirplaneModePreference);
Jeff Hamilton3d670de2011-09-21 16:44:36 -0500222 mNfcEnabler = new NfcEnabler(activity, nfc, androidBeam);
Irfan Sheriff936e3fa2012-05-07 15:51:37 -0700223
224 // Remove NSD checkbox by default
225 getPreferenceScreen().removePreference(nsd);
226 //mNsdEnabler = new NsdEnabler(activity, nsd);
Chia-chi Yeh4e142112009-12-25 14:48:46 +0800227
Christopher Tate6a5929b2012-09-10 15:39:05 -0700228 String toggleable = Settings.Global.getString(activity.getContentResolver(),
229 Settings.Global.AIRPLANE_MODE_TOGGLEABLE_RADIOS);
Chia-chi Yeh4e142112009-12-25 14:48:46 +0800230
tk.mun7c5c1652011-10-13 22:56:18 +0900231 //enable/disable wimax depending on the value in config.xml
Amith Yamasani9627a8e2012-09-23 12:54:14 -0700232 boolean isWimaxEnabled = !isSecondaryUser && this.getResources().getBoolean(
tk.mun7c5c1652011-10-13 22:56:18 +0900233 com.android.internal.R.bool.config_wimaxEnabled);
234 if (!isWimaxEnabled) {
235 PreferenceScreen root = getPreferenceScreen();
236 Preference ps = (Preference) findPreference(KEY_WIMAX_SETTINGS);
237 if (ps != null) root.removePreference(ps);
238 } else {
Christopher Tate6a5929b2012-09-10 15:39:05 -0700239 if (toggleable == null || !toggleable.contains(Settings.Global.RADIO_WIMAX )
tk.mun7c5c1652011-10-13 22:56:18 +0900240 && isWimaxEnabled) {
241 Preference ps = (Preference) findPreference(KEY_WIMAX_SETTINGS);
242 ps.setDependency(KEY_TOGGLE_AIRPLANE);
243 }
244 }
Geoffrey Borggaardfe21d9a2013-08-02 18:16:27 -0400245 protectByRestrictions(KEY_WIMAX_SETTINGS);
246
Chia-chi Yehb90452f2010-01-13 06:11:29 +0800247 // Manually set dependencies for Wifi when not toggleable.
Christopher Tate6a5929b2012-09-10 15:39:05 -0700248 if (toggleable == null || !toggleable.contains(Settings.Global.RADIO_WIFI)) {
Chia-chi Yeh4e142112009-12-25 14:48:46 +0800249 findPreference(KEY_VPN_SETTINGS).setDependency(KEY_TOGGLE_AIRPLANE);
250 }
Amith Yamasani9627a8e2012-09-23 12:54:14 -0700251 if (isSecondaryUser) { // Disable VPN
252 removePreference(KEY_VPN_SETTINGS);
253 }
Geoffrey Borggaardfe21d9a2013-08-02 18:16:27 -0400254 protectByRestrictions(KEY_VPN_SETTINGS);
Chia-chi Yeh4e142112009-12-25 14:48:46 +0800255 // Manually set dependencies for Bluetooth when not toggleable.
Christopher Tate6a5929b2012-09-10 15:39:05 -0700256 if (toggleable == null || !toggleable.contains(Settings.Global.RADIO_BLUETOOTH)) {
Gilles Debunnee78c1872011-06-20 15:00:07 -0700257 // No bluetooth-dependent items in the list. Code kept in case one is added later.
Nick Pellyad50ba02010-09-22 10:55:13 -0700258 }
259
Nick Pelly9894d4a2011-08-09 07:10:16 -0700260 // Manually set dependencies for NFC when not toggleable.
Christopher Tate6a5929b2012-09-10 15:39:05 -0700261 if (toggleable == null || !toggleable.contains(Settings.Global.RADIO_NFC)) {
Nick Pelly9894d4a2011-08-09 07:10:16 -0700262 findPreference(KEY_TOGGLE_NFC).setDependency(KEY_TOGGLE_AIRPLANE);
Jeff Hamilton3d670de2011-09-21 16:44:36 -0500263 findPreference(KEY_ANDROID_BEAM_SETTINGS).setDependency(KEY_TOGGLE_AIRPLANE);
Nick Pelly9894d4a2011-08-09 07:10:16 -0700264 }
265
Nick Pellyad50ba02010-09-22 10:55:13 -0700266 // Remove NFC if its not available
Martijn Coenenbb4bdc22011-07-27 17:31:41 -0500267 mNfcAdapter = NfcAdapter.getDefaultAdapter(activity);
268 if (mNfcAdapter == null) {
Nick Pellyad50ba02010-09-22 10:55:13 -0700269 getPreferenceScreen().removePreference(nfc);
Jeff Hamilton3d670de2011-09-21 16:44:36 -0500270 getPreferenceScreen().removePreference(androidBeam);
Nick Pelly9894d4a2011-08-09 07:10:16 -0700271 mNfcEnabler = null;
Chia-chi Yeh4e142112009-12-25 14:48:46 +0800272 }
Robert Greenwaltc4764d22010-02-12 14:21:37 -0800273
Wink Saville5d5a2692013-06-29 07:54:13 -0700274 // Remove Mobile Network Settings and Manage Mobile Plan if it's a wifi-only device.
Amith Yamasani9627a8e2012-09-23 12:54:14 -0700275 if (isSecondaryUser || Utils.isWifiOnly(getActivity())) {
276 removePreference(KEY_MOBILE_NETWORK_SETTINGS);
Wink Saville5d5a2692013-06-29 07:54:13 -0700277 removePreference(KEY_MANAGE_MOBILE_PLAN);
Amith Yamasani0f85c482011-02-23 17:19:11 -0800278 }
Geoffrey Borggaardfe21d9a2013-08-02 18:16:27 -0400279 protectByRestrictions(KEY_MOBILE_NETWORK_SETTINGS);
280 protectByRestrictions(KEY_MANAGE_MOBILE_PLAN);
Amith Yamasani0f85c482011-02-23 17:19:11 -0800281
Jaewan Kim2e41e3d2013-04-19 13:40:23 +0900282 // Remove Airplane Mode settings if it's a stationary device such as a TV.
283 if (getActivity().getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEVISION)) {
284 removePreference(KEY_TOGGLE_AIRPLANE);
285 }
286
Oscar Montemayor05411892010-08-03 16:56:09 -0700287 // Enable Proxy selector settings if allowed.
288 Preference mGlobalProxy = findPreference(KEY_PROXY_SETTINGS);
Amith Yamasanid7993472010-08-18 13:59:28 -0700289 DevicePolicyManager mDPM = (DevicePolicyManager)
290 activity.getSystemService(Context.DEVICE_POLICY_SERVICE);
Robert Greenwalt6f3a98b2010-12-28 16:11:12 -0800291 // proxy UI disabled until we have better app support
292 getPreferenceScreen().removePreference(mGlobalProxy);
Oscar Montemayor05411892010-08-03 16:56:09 -0700293 mGlobalProxy.setEnabled(mDPM.getGlobalProxyAdmin() == null);
294
Amith Yamasani0f85c482011-02-23 17:19:11 -0800295 // Disable Tethering if it's not allowed or if it's a wifi-only device
Robert Greenwaltc4764d22010-02-12 14:21:37 -0800296 ConnectivityManager cm =
Amith Yamasanid7993472010-08-18 13:59:28 -0700297 (ConnectivityManager) activity.getSystemService(Context.CONNECTIVITY_SERVICE);
Amith Yamasani9627a8e2012-09-23 12:54:14 -0700298 if (isSecondaryUser || !cm.isTetheringSupported()) {
Robert Greenwaltc4764d22010-02-12 14:21:37 -0800299 getPreferenceScreen().removePreference(findPreference(KEY_TETHER_SETTINGS));
Robert Greenwalte434bfb2010-05-08 15:20:24 -0700300 } else {
Robert Greenwalte434bfb2010-05-08 15:20:24 -0700301 Preference p = findPreference(KEY_TETHER_SETTINGS);
Jeff Sharkeya83a24f2011-09-16 01:52:39 -0700302 p.setTitle(Utils.getTetheringLabel(cm));
Robert Greenwaltc4764d22010-02-12 14:21:37 -0800303 }
Geoffrey Borggaardfe21d9a2013-08-02 18:16:27 -0400304 protectByRestrictions(KEY_TETHER_SETTINGS);
Jake Hambyef57ed72012-06-21 10:59:22 -0700305
306 // Enable link to CMAS app settings depending on the value in config.xml.
307 boolean isCellBroadcastAppLinkEnabled = this.getResources().getBoolean(
308 com.android.internal.R.bool.config_cellBroadcastAppLinks);
309 try {
310 if (isCellBroadcastAppLinkEnabled) {
311 PackageManager pm = getPackageManager();
312 if (pm.getApplicationEnabledSetting("com.android.cellbroadcastreceiver")
313 == PackageManager.COMPONENT_ENABLED_STATE_DISABLED) {
314 isCellBroadcastAppLinkEnabled = false; // CMAS app disabled
315 }
316 }
317 } catch (IllegalArgumentException ignored) {
318 isCellBroadcastAppLinkEnabled = false; // CMAS app not installed
319 }
Amith Yamasani9627a8e2012-09-23 12:54:14 -0700320 if (isSecondaryUser || !isCellBroadcastAppLinkEnabled) {
Jake Hambyef57ed72012-06-21 10:59:22 -0700321 PreferenceScreen root = getPreferenceScreen();
322 Preference ps = findPreference(KEY_CELL_BROADCAST_SETTINGS);
323 if (ps != null) root.removePreference(ps);
324 }
Geoffrey Borggaardfe21d9a2013-08-02 18:16:27 -0400325 protectByRestrictions(KEY_CELL_BROADCAST_SETTINGS);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800326 }
Robert Greenwaltc4764d22010-02-12 14:21:37 -0800327
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800328 @Override
Amith Yamasanid7993472010-08-18 13:59:28 -0700329 public void onResume() {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800330 super.onResume();
Danica Chang32711b62010-08-10 18:41:29 -0700331
Chia-chi Yeh4e142112009-12-25 14:48:46 +0800332 mAirplaneModeEnabler.resume();
Nick Pelly9894d4a2011-08-09 07:10:16 -0700333 if (mNfcEnabler != null) {
334 mNfcEnabler.resume();
Martijn Coenenbb4bdc22011-07-27 17:31:41 -0500335 }
Irfan Sheriff936e3fa2012-05-07 15:51:37 -0700336 if (mNsdEnabler != null) {
337 mNsdEnabler.resume();
338 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800339 }
Danica Chang32711b62010-08-10 18:41:29 -0700340
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800341 @Override
Wink Saville5d5a2692013-06-29 07:54:13 -0700342 public void onSaveInstanceState(Bundle outState) {
343 super.onSaveInstanceState(outState);
344
345 if (!TextUtils.isEmpty(mManageMobilePlanMessage)) {
346 outState.putString(SAVED_MANAGE_MOBILE_PLAN_MSG, mManageMobilePlanMessage);
347 }
348 }
349
350 @Override
Amith Yamasanid7993472010-08-18 13:59:28 -0700351 public void onPause() {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800352 super.onPause();
Danica Chang32711b62010-08-10 18:41:29 -0700353
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800354 mAirplaneModeEnabler.pause();
Nick Pelly9894d4a2011-08-09 07:10:16 -0700355 if (mNfcEnabler != null) {
356 mNfcEnabler.pause();
357 }
Irfan Sheriff936e3fa2012-05-07 15:51:37 -0700358 if (mNsdEnabler != null) {
359 mNsdEnabler.pause();
360 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800361 }
Danica Chang32711b62010-08-10 18:41:29 -0700362
Chouting Zhang71cc49e2009-08-28 14:36:35 -0500363 @Override
Amith Yamasanid7993472010-08-18 13:59:28 -0700364 public void onActivityResult(int requestCode, int resultCode, Intent data) {
Chia-chi Yeh4e142112009-12-25 14:48:46 +0800365 if (requestCode == REQUEST_CODE_EXIT_ECM) {
366 Boolean isChoiceYes = data.getBooleanExtra(EXIT_ECM_RESULT, false);
Chouting Zhang71cc49e2009-08-28 14:36:35 -0500367 // Set Airplane mode based on the return value and checkbox state
368 mAirplaneModeEnabler.setAirplaneModeInECM(isChoiceYes,
369 mAirplaneModePreference.isChecked());
Chouting Zhang71cc49e2009-08-28 14:36:35 -0500370 }
Geoffrey Borggaardfe21d9a2013-08-02 18:16:27 -0400371 super.onActivityResult(requestCode, resultCode, data);
Chouting Zhang71cc49e2009-08-28 14:36:35 -0500372 }
Amith Yamasanib0b37ae2012-04-23 15:35:36 -0700373
374 @Override
375 protected int getHelpResource() {
376 return R.string.help_url_more_networks;
377 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800378}