blob: f4a48efe91b103dce65e021941c6a978f9cc7dd9 [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
Amith Yamasanid7993472010-08-18 13:59:28 -070019import android.app.Activity;
Wink Saville5d5a2692013-06-29 07:54:13 -070020import android.app.AlertDialog;
21import android.app.Dialog;
Amith Yamasanid7993472010-08-18 13:59:28 -070022import android.app.admin.DevicePolicyManager;
Amith Yamasanid7993472010-08-18 13:59:28 -070023import android.content.Context;
Wink Saville5d5a2692013-06-29 07:54:13 -070024import android.content.DialogInterface;
Amith Yamasanid7993472010-08-18 13:59:28 -070025import android.content.Intent;
Irfan Sheriff167d7182011-09-07 14:51:11 -070026import android.content.pm.PackageManager;
Wink Saville5d5a2692013-06-29 07:54:13 -070027import android.content.res.Resources;
Amith Yamasanid7993472010-08-18 13:59:28 -070028import android.net.ConnectivityManager;
Wink Saville5d5a2692013-06-29 07:54:13 -070029import android.net.NetworkInfo;
30import android.net.Uri;
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
Amith Yamasanid7993472010-08-18 13:59:28 -070047public class WirelessSettings extends SettingsPreferenceFragment {
Wink Saville5d5a2692013-06-29 07:54:13 -070048 private static final String TAG = "WirelessSettiings";
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
Chouting Zhang71cc49e2009-08-28 14:36:35 -050077 /**
78 * Invoked on each preference click in this hierarchy, overrides
79 * PreferenceActivity's implementation. Used to make sure we track the
80 * preference click events.
81 */
82 @Override
83 public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
Wink Saville5d5a2692013-06-29 07:54:13 -070084 log("onPreferenceTreeClick: preference=" + preference);
Chia-chi Yeh4e142112009-12-25 14:48:46 +080085 if (preference == mAirplaneModePreference && Boolean.parseBoolean(
86 SystemProperties.get(TelephonyProperties.PROPERTY_INECM_MODE))) {
Chouting Zhang71cc49e2009-08-28 14:36:35 -050087 // In ECM mode launch ECM app dialog
88 startActivityForResult(
89 new Intent(TelephonyIntents.ACTION_SHOW_NOTICE_ECM_BLOCK_OTHERS, null),
90 REQUEST_CODE_EXIT_ECM);
Chouting Zhang71cc49e2009-08-28 14:36:35 -050091 return true;
Wink Saville5d5a2692013-06-29 07:54:13 -070092 } else if (preference == findPreference(KEY_MANAGE_MOBILE_PLAN)) {
93 onManageMobilePlanClick();
Chouting Zhang71cc49e2009-08-28 14:36:35 -050094 }
Chia-chi Yeh4e142112009-12-25 14:48:46 +080095 // Let the intents be launched by the Preference manager
Amith Yamasanid7993472010-08-18 13:59:28 -070096 return super.onPreferenceTreeClick(preferenceScreen, preference);
Chouting Zhang71cc49e2009-08-28 14:36:35 -050097 }
Chia-chi Yehb90452f2010-01-13 06:11:29 +080098
Wink Saville5d5a2692013-06-29 07:54:13 -070099 private String mManageMobilePlanMessage;
100
101 public void onManageMobilePlanClick() {
102 log("onManageMobilePlanClick:");
103 mManageMobilePlanMessage = null;
104 Resources resources = getActivity().getResources();
105
106 NetworkInfo ni = mCm.getActiveNetworkInfo();
107 if (mTm.hasIccCard() && (ni != null)) {
108 // Get provisioning URL
109 String url = getProvisioningUrl();
110 if (!TextUtils.isEmpty(url)) {
111 // Send user to provisioning webpage
112 Intent intent = new Intent(Intent.ACTION_VIEW);
113 intent.setData(Uri.parse(url));
114 startActivity(intent);
115 mManageMobilePlanMessage = null;
116 } else {
117 // No provisioning URL
118 String operatorName = mTm.getSimOperatorName();
119 if (TextUtils.isEmpty(operatorName)) {
120 // Use NetworkOperatorName as second choice in case there is no
121 // SPN (Service Provider Name on the SIM). Such as with T-mobile.
122 operatorName = mTm.getNetworkOperatorName();
123 if (TextUtils.isEmpty(operatorName)) {
124 mManageMobilePlanMessage = resources.getString(
125 R.string.mobile_unknown_sim_operator);
126 } else {
127 mManageMobilePlanMessage = resources.getString(
128 R.string.mobile_no_provisioning_url, operatorName);
129 }
130 } else {
131 mManageMobilePlanMessage = resources.getString(
132 R.string.mobile_no_provisioning_url, operatorName);
133 }
134 }
135 } else if (mTm.hasIccCard() == false) {
136 // No sim card
137 mManageMobilePlanMessage = resources.getString(R.string.mobile_insert_sim_card);
138 } else {
139 // NetworkInfo is null, there is no connection
140 mManageMobilePlanMessage = resources.getString(R.string.mobile_connect_to_internet);
141 }
142 if (!TextUtils.isEmpty(mManageMobilePlanMessage)) {
143 log("onManageMobilePlanClick: message=" + mManageMobilePlanMessage);
144 showDialog(MANAGE_MOBILE_PLAN_DIALOG_ID);
145 }
146 }
147
148 private String getProvisioningUrl() {
149 String url = getActivity().getResources()
150 .getString(com.android.internal.R.string.mobile_provisioning_url);
151 log("getProvisioningUrl: mobile_provisioning_url=" + url);
152
Wink Savilleb4644782013-07-10 22:19:26 -0700153 // populate the iccid, imei and phone number in the provisioning url.
Wink Saville5d5a2692013-06-29 07:54:13 -0700154 if (!TextUtils.isEmpty(url)) {
Wink Savilleb4644782013-07-10 22:19:26 -0700155 String phoneNumber = mTm.getLine1Number();
156 if (TextUtils.isEmpty(phoneNumber)) {
157 phoneNumber = "0000000000";
158 }
Wink Saville5d5a2692013-06-29 07:54:13 -0700159 url = String.format(url,
160 mTm.getSimSerialNumber() /* ICCID */,
161 mTm.getDeviceId() /* IMEI */,
Wink Savilleb4644782013-07-10 22:19:26 -0700162 phoneNumber /* Phone number */);
Wink Saville5d5a2692013-06-29 07:54:13 -0700163 }
164
Wink Saville5d5a2692013-06-29 07:54:13 -0700165 return url;
166 }
167
168 @Override
169 public Dialog onCreateDialog(int dialogId) {
170 log("onCreateDialog: dialogId=" + dialogId);
171 switch (dialogId) {
172 case MANAGE_MOBILE_PLAN_DIALOG_ID:
173 return new AlertDialog.Builder(getActivity())
174 .setMessage(mManageMobilePlanMessage)
175 .setCancelable(false)
176 .setPositiveButton(com.android.internal.R.string.ok,
177 new DialogInterface.OnClickListener() {
178 @Override
179 public void onClick(DialogInterface dialog, int id) {
180 log("MANAGE_MOBILE_PLAN_DIALOG.onClickListener id=" + id);
181 mManageMobilePlanMessage = null;
182 }
183 })
184 .create();
185 }
186 return super.onCreateDialog(dialogId);
187 }
188
189 private void log(String s) {
190 Log.d(TAG, s);
191 }
192
Chia-chi Yehb90452f2010-01-13 06:11:29 +0800193 public static boolean isRadioAllowed(Context context, String type) {
194 if (!AirplaneModeEnabler.isAirplaneModeOn(context)) {
195 return true;
196 }
197 // Here we use the same logic in onCreate().
Christopher Tate6a5929b2012-09-10 15:39:05 -0700198 String toggleable = Settings.Global.getString(context.getContentResolver(),
199 Settings.Global.AIRPLANE_MODE_TOGGLEABLE_RADIOS);
Chia-chi Yehb90452f2010-01-13 06:11:29 +0800200 return toggleable != null && toggleable.contains(type);
201 }
202
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800203 @Override
Amith Yamasanid7993472010-08-18 13:59:28 -0700204 public void onCreate(Bundle savedInstanceState) {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800205 super.onCreate(savedInstanceState);
Wink Saville5d5a2692013-06-29 07:54:13 -0700206 if (savedInstanceState != null) {
207 mManageMobilePlanMessage = savedInstanceState.getString(SAVED_MANAGE_MOBILE_PLAN_MSG);
208 }
209 log("onCreate: mManageMobilePlanMessage=" + mManageMobilePlanMessage);
210
211 mCm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
212 mTm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800213
214 addPreferencesFromResource(R.xml.wireless_settings);
215
Amith Yamasani9627a8e2012-09-23 12:54:14 -0700216 final boolean isSecondaryUser = UserHandle.myUserId() != UserHandle.USER_OWNER;
217
Amith Yamasanid7993472010-08-18 13:59:28 -0700218 final Activity activity = getActivity();
Gilles Debunnee78c1872011-06-20 15:00:07 -0700219 mAirplaneModePreference = (CheckBoxPreference) findPreference(KEY_TOGGLE_AIRPLANE);
Nick Pellyad50ba02010-09-22 10:55:13 -0700220 CheckBoxPreference nfc = (CheckBoxPreference) findPreference(KEY_TOGGLE_NFC);
Jeff Hamilton3d670de2011-09-21 16:44:36 -0500221 PreferenceScreen androidBeam = (PreferenceScreen) findPreference(KEY_ANDROID_BEAM_SETTINGS);
Irfan Sheriff536c3d72012-04-17 23:17:46 -0700222 CheckBoxPreference nsd = (CheckBoxPreference) findPreference(KEY_TOGGLE_NSD);
Chia-chi Yeh4e142112009-12-25 14:48:46 +0800223
Gilles Debunnee78c1872011-06-20 15:00:07 -0700224 mAirplaneModeEnabler = new AirplaneModeEnabler(activity, mAirplaneModePreference);
Jeff Hamilton3d670de2011-09-21 16:44:36 -0500225 mNfcEnabler = new NfcEnabler(activity, nfc, androidBeam);
Irfan Sheriff936e3fa2012-05-07 15:51:37 -0700226
227 // Remove NSD checkbox by default
228 getPreferenceScreen().removePreference(nsd);
229 //mNsdEnabler = new NsdEnabler(activity, nsd);
Chia-chi Yeh4e142112009-12-25 14:48:46 +0800230
Christopher Tate6a5929b2012-09-10 15:39:05 -0700231 String toggleable = Settings.Global.getString(activity.getContentResolver(),
232 Settings.Global.AIRPLANE_MODE_TOGGLEABLE_RADIOS);
Chia-chi Yeh4e142112009-12-25 14:48:46 +0800233
tk.mun7c5c1652011-10-13 22:56:18 +0900234 //enable/disable wimax depending on the value in config.xml
Amith Yamasani9627a8e2012-09-23 12:54:14 -0700235 boolean isWimaxEnabled = !isSecondaryUser && this.getResources().getBoolean(
tk.mun7c5c1652011-10-13 22:56:18 +0900236 com.android.internal.R.bool.config_wimaxEnabled);
237 if (!isWimaxEnabled) {
238 PreferenceScreen root = getPreferenceScreen();
239 Preference ps = (Preference) findPreference(KEY_WIMAX_SETTINGS);
240 if (ps != null) root.removePreference(ps);
241 } else {
Christopher Tate6a5929b2012-09-10 15:39:05 -0700242 if (toggleable == null || !toggleable.contains(Settings.Global.RADIO_WIMAX )
tk.mun7c5c1652011-10-13 22:56:18 +0900243 && isWimaxEnabled) {
244 Preference ps = (Preference) findPreference(KEY_WIMAX_SETTINGS);
245 ps.setDependency(KEY_TOGGLE_AIRPLANE);
246 }
247 }
Chia-chi Yehb90452f2010-01-13 06:11:29 +0800248 // Manually set dependencies for Wifi when not toggleable.
Christopher Tate6a5929b2012-09-10 15:39:05 -0700249 if (toggleable == null || !toggleable.contains(Settings.Global.RADIO_WIFI)) {
Chia-chi Yeh4e142112009-12-25 14:48:46 +0800250 findPreference(KEY_VPN_SETTINGS).setDependency(KEY_TOGGLE_AIRPLANE);
251 }
Amith Yamasani9627a8e2012-09-23 12:54:14 -0700252 if (isSecondaryUser) { // Disable VPN
253 removePreference(KEY_VPN_SETTINGS);
254 }
Chia-chi Yeh4e142112009-12-25 14:48:46 +0800255
256 // Manually set dependencies for Bluetooth when not toggleable.
Christopher Tate6a5929b2012-09-10 15:39:05 -0700257 if (toggleable == null || !toggleable.contains(Settings.Global.RADIO_BLUETOOTH)) {
Gilles Debunnee78c1872011-06-20 15:00:07 -0700258 // No bluetooth-dependent items in the list. Code kept in case one is added later.
Nick Pellyad50ba02010-09-22 10:55:13 -0700259 }
260
Nick Pelly9894d4a2011-08-09 07:10:16 -0700261 // Manually set dependencies for NFC when not toggleable.
Christopher Tate6a5929b2012-09-10 15:39:05 -0700262 if (toggleable == null || !toggleable.contains(Settings.Global.RADIO_NFC)) {
Nick Pelly9894d4a2011-08-09 07:10:16 -0700263 findPreference(KEY_TOGGLE_NFC).setDependency(KEY_TOGGLE_AIRPLANE);
Jeff Hamilton3d670de2011-09-21 16:44:36 -0500264 findPreference(KEY_ANDROID_BEAM_SETTINGS).setDependency(KEY_TOGGLE_AIRPLANE);
Nick Pelly9894d4a2011-08-09 07:10:16 -0700265 }
266
Nick Pellyad50ba02010-09-22 10:55:13 -0700267 // Remove NFC if its not available
Martijn Coenenbb4bdc22011-07-27 17:31:41 -0500268 mNfcAdapter = NfcAdapter.getDefaultAdapter(activity);
269 if (mNfcAdapter == null) {
Nick Pellyad50ba02010-09-22 10:55:13 -0700270 getPreferenceScreen().removePreference(nfc);
Jeff Hamilton3d670de2011-09-21 16:44:36 -0500271 getPreferenceScreen().removePreference(androidBeam);
Nick Pelly9894d4a2011-08-09 07:10:16 -0700272 mNfcEnabler = null;
Chia-chi Yeh4e142112009-12-25 14:48:46 +0800273 }
Robert Greenwaltc4764d22010-02-12 14:21:37 -0800274
Wink Saville5d5a2692013-06-29 07:54:13 -0700275 // Remove Mobile Network Settings and Manage Mobile Plan if it's a wifi-only device.
Amith Yamasani9627a8e2012-09-23 12:54:14 -0700276 if (isSecondaryUser || Utils.isWifiOnly(getActivity())) {
277 removePreference(KEY_MOBILE_NETWORK_SETTINGS);
Wink Saville5d5a2692013-06-29 07:54:13 -0700278 removePreference(KEY_MANAGE_MOBILE_PLAN);
Amith Yamasani0f85c482011-02-23 17:19:11 -0800279 }
280
Oscar Montemayor05411892010-08-03 16:56:09 -0700281 // Enable Proxy selector settings if allowed.
282 Preference mGlobalProxy = findPreference(KEY_PROXY_SETTINGS);
Amith Yamasanid7993472010-08-18 13:59:28 -0700283 DevicePolicyManager mDPM = (DevicePolicyManager)
284 activity.getSystemService(Context.DEVICE_POLICY_SERVICE);
Robert Greenwalt6f3a98b2010-12-28 16:11:12 -0800285 // proxy UI disabled until we have better app support
286 getPreferenceScreen().removePreference(mGlobalProxy);
Oscar Montemayor05411892010-08-03 16:56:09 -0700287 mGlobalProxy.setEnabled(mDPM.getGlobalProxyAdmin() == null);
288
Amith Yamasani0f85c482011-02-23 17:19:11 -0800289 // Disable Tethering if it's not allowed or if it's a wifi-only device
Robert Greenwaltc4764d22010-02-12 14:21:37 -0800290 ConnectivityManager cm =
Amith Yamasanid7993472010-08-18 13:59:28 -0700291 (ConnectivityManager) activity.getSystemService(Context.CONNECTIVITY_SERVICE);
Amith Yamasani9627a8e2012-09-23 12:54:14 -0700292 if (isSecondaryUser || !cm.isTetheringSupported()) {
Robert Greenwaltc4764d22010-02-12 14:21:37 -0800293 getPreferenceScreen().removePreference(findPreference(KEY_TETHER_SETTINGS));
Robert Greenwalte434bfb2010-05-08 15:20:24 -0700294 } else {
Robert Greenwalte434bfb2010-05-08 15:20:24 -0700295 Preference p = findPreference(KEY_TETHER_SETTINGS);
Jeff Sharkeya83a24f2011-09-16 01:52:39 -0700296 p.setTitle(Utils.getTetheringLabel(cm));
Robert Greenwaltc4764d22010-02-12 14:21:37 -0800297 }
Jake Hambyef57ed72012-06-21 10:59:22 -0700298
299 // Enable link to CMAS app settings depending on the value in config.xml.
300 boolean isCellBroadcastAppLinkEnabled = this.getResources().getBoolean(
301 com.android.internal.R.bool.config_cellBroadcastAppLinks);
302 try {
303 if (isCellBroadcastAppLinkEnabled) {
304 PackageManager pm = getPackageManager();
305 if (pm.getApplicationEnabledSetting("com.android.cellbroadcastreceiver")
306 == PackageManager.COMPONENT_ENABLED_STATE_DISABLED) {
307 isCellBroadcastAppLinkEnabled = false; // CMAS app disabled
308 }
309 }
310 } catch (IllegalArgumentException ignored) {
311 isCellBroadcastAppLinkEnabled = false; // CMAS app not installed
312 }
Amith Yamasani9627a8e2012-09-23 12:54:14 -0700313 if (isSecondaryUser || !isCellBroadcastAppLinkEnabled) {
Jake Hambyef57ed72012-06-21 10:59:22 -0700314 PreferenceScreen root = getPreferenceScreen();
315 Preference ps = findPreference(KEY_CELL_BROADCAST_SETTINGS);
316 if (ps != null) root.removePreference(ps);
317 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800318 }
Robert Greenwaltc4764d22010-02-12 14:21:37 -0800319
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800320 @Override
Amith Yamasanid7993472010-08-18 13:59:28 -0700321 public void onResume() {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800322 super.onResume();
Danica Chang32711b62010-08-10 18:41:29 -0700323
Chia-chi Yeh4e142112009-12-25 14:48:46 +0800324 mAirplaneModeEnabler.resume();
Nick Pelly9894d4a2011-08-09 07:10:16 -0700325 if (mNfcEnabler != null) {
326 mNfcEnabler.resume();
Martijn Coenenbb4bdc22011-07-27 17:31:41 -0500327 }
Irfan Sheriff936e3fa2012-05-07 15:51:37 -0700328 if (mNsdEnabler != null) {
329 mNsdEnabler.resume();
330 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800331 }
Danica Chang32711b62010-08-10 18:41:29 -0700332
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800333 @Override
Wink Saville5d5a2692013-06-29 07:54:13 -0700334 public void onSaveInstanceState(Bundle outState) {
335 super.onSaveInstanceState(outState);
336
337 if (!TextUtils.isEmpty(mManageMobilePlanMessage)) {
338 outState.putString(SAVED_MANAGE_MOBILE_PLAN_MSG, mManageMobilePlanMessage);
339 }
340 }
341
342 @Override
Amith Yamasanid7993472010-08-18 13:59:28 -0700343 public void onPause() {
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800344 super.onPause();
Danica Chang32711b62010-08-10 18:41:29 -0700345
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800346 mAirplaneModeEnabler.pause();
Nick Pelly9894d4a2011-08-09 07:10:16 -0700347 if (mNfcEnabler != null) {
348 mNfcEnabler.pause();
349 }
Irfan Sheriff936e3fa2012-05-07 15:51:37 -0700350 if (mNsdEnabler != null) {
351 mNsdEnabler.pause();
352 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800353 }
Danica Chang32711b62010-08-10 18:41:29 -0700354
Chouting Zhang71cc49e2009-08-28 14:36:35 -0500355 @Override
Amith Yamasanid7993472010-08-18 13:59:28 -0700356 public void onActivityResult(int requestCode, int resultCode, Intent data) {
Chia-chi Yeh4e142112009-12-25 14:48:46 +0800357 if (requestCode == REQUEST_CODE_EXIT_ECM) {
358 Boolean isChoiceYes = data.getBooleanExtra(EXIT_ECM_RESULT, false);
Chouting Zhang71cc49e2009-08-28 14:36:35 -0500359 // Set Airplane mode based on the return value and checkbox state
360 mAirplaneModeEnabler.setAirplaneModeInECM(isChoiceYes,
361 mAirplaneModePreference.isChecked());
Chouting Zhang71cc49e2009-08-28 14:36:35 -0500362 }
363 }
Amith Yamasanib0b37ae2012-04-23 15:35:36 -0700364
365 @Override
366 protected int getHelpResource() {
367 return R.string.help_url_more_networks;
368 }
The Android Open Source Projectafc4ab22009-03-03 19:32:34 -0800369}