blob: 6829dec41500ec17f5ae09e3af9ff431624bd50a [file] [log] [blame]
Santos Cordon7d4ddf62013-07-10 11:58:08 -07001/*
2 * Copyright (C) 2008 The Android Open Source Project
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
17package com.android.phone;
18
Santos Cordon7d4ddf62013-07-10 11:58:08 -070019import android.preference.Preference;
20import android.preference.PreferenceActivity;
21import android.preference.PreferenceScreen;
22import android.content.res.Resources;
23
24import com.android.internal.telephony.Phone;
25import com.android.internal.telephony.PhoneConstants;
26import com.android.internal.telephony.PhoneFactory;
27
28/**
29 * List of Network-specific settings screens.
30 */
31public class GsmUmtsOptions {
32 private static final String LOG_TAG = "GsmUmtsOptions";
33
34 private PreferenceScreen mButtonAPNExpand;
35 private PreferenceScreen mButtonOperatorSelectionExpand;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070036
37 private static final String BUTTON_APN_EXPAND_KEY = "button_apn_key";
38 private static final String BUTTON_OPERATOR_SELECTION_EXPAND_KEY = "button_carrier_sel_key";
Santos Cordon7d4ddf62013-07-10 11:58:08 -070039 private PreferenceActivity mPrefActivity;
40 private PreferenceScreen mPrefScreen;
41
42 public GsmUmtsOptions(PreferenceActivity prefActivity, PreferenceScreen prefScreen) {
43 mPrefActivity = prefActivity;
44 mPrefScreen = prefScreen;
45 create();
46 }
47
48 protected void create() {
49 mPrefActivity.addPreferencesFromResource(R.xml.gsm_umts_options);
50 mButtonAPNExpand = (PreferenceScreen) mPrefScreen.findPreference(BUTTON_APN_EXPAND_KEY);
51 mButtonOperatorSelectionExpand =
52 (PreferenceScreen) mPrefScreen.findPreference(BUTTON_OPERATOR_SELECTION_EXPAND_KEY);
Santos Cordon7d4ddf62013-07-10 11:58:08 -070053 if (PhoneFactory.getDefaultPhone().getPhoneType() != PhoneConstants.PHONE_TYPE_GSM) {
54 log("Not a GSM phone");
55 mButtonAPNExpand.setEnabled(false);
56 mButtonOperatorSelectionExpand.setEnabled(false);
Santos Cordon7d4ddf62013-07-10 11:58:08 -070057 } else {
58 log("Not a CDMA phone");
59 Resources res = mPrefActivity.getResources();
60
61 // Determine which options to display, for GSM these are defaulted
62 // are defaulted to true in Phone/res/values/config.xml. But for
63 // some operators like verizon they maybe overriden in operator
64 // specific resources or device specifc overlays.
65 if (!res.getBoolean(R.bool.config_apn_expand)) {
66 mPrefScreen.removePreference(mPrefScreen.findPreference(BUTTON_APN_EXPAND_KEY));
67 }
68 if (!res.getBoolean(R.bool.config_operator_selection_expand)) {
69 mPrefScreen.removePreference(mPrefScreen
70 .findPreference(BUTTON_OPERATOR_SELECTION_EXPAND_KEY));
71 }
Santos Cordon7d4ddf62013-07-10 11:58:08 -070072
73 if (res.getBoolean(R.bool.csp_enabled)) {
74 if (PhoneFactory.getDefaultPhone().isCspPlmnEnabled()) {
75 log("[CSP] Enabling Operator Selection menu.");
76 mButtonOperatorSelectionExpand.setEnabled(true);
77 } else {
78 log("[CSP] Disabling Operator Selection menu.");
79 mPrefScreen.removePreference(mPrefScreen
80 .findPreference(BUTTON_OPERATOR_SELECTION_EXPAND_KEY));
81 }
82 }
83 }
84 }
85
86 public boolean preferenceTreeClick(Preference preference) {
Santos Cordon7d4ddf62013-07-10 11:58:08 -070087 log("preferenceTreeClick: return false");
88 return false;
89 }
90
91 protected void log(String s) {
92 android.util.Log.d(LOG_TAG, s);
93 }
94}