blob: 6791f2753cd0482852fa5010aab46fdafb4b1594 [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";
Sandeep Gutta91007152014-07-01 12:05:52 +053039 private static final String BUTTON_CARRIER_SETTINGS_KEY = "carrier_settings_key";
Santos Cordon7d4ddf62013-07-10 11:58:08 -070040 private PreferenceActivity mPrefActivity;
41 private PreferenceScreen mPrefScreen;
42
43 public GsmUmtsOptions(PreferenceActivity prefActivity, PreferenceScreen prefScreen) {
44 mPrefActivity = prefActivity;
45 mPrefScreen = prefScreen;
46 create();
47 }
48
49 protected void create() {
50 mPrefActivity.addPreferencesFromResource(R.xml.gsm_umts_options);
51 mButtonAPNExpand = (PreferenceScreen) mPrefScreen.findPreference(BUTTON_APN_EXPAND_KEY);
52 mButtonOperatorSelectionExpand =
53 (PreferenceScreen) mPrefScreen.findPreference(BUTTON_OPERATOR_SELECTION_EXPAND_KEY);
Santos Cordon7d4ddf62013-07-10 11:58:08 -070054 if (PhoneFactory.getDefaultPhone().getPhoneType() != PhoneConstants.PHONE_TYPE_GSM) {
55 log("Not a GSM phone");
56 mButtonAPNExpand.setEnabled(false);
57 mButtonOperatorSelectionExpand.setEnabled(false);
Santos Cordon7d4ddf62013-07-10 11:58:08 -070058 } else {
59 log("Not a CDMA phone");
60 Resources res = mPrefActivity.getResources();
61
62 // Determine which options to display, for GSM these are defaulted
63 // are defaulted to true in Phone/res/values/config.xml. But for
64 // some operators like verizon they maybe overriden in operator
65 // specific resources or device specifc overlays.
66 if (!res.getBoolean(R.bool.config_apn_expand)) {
67 mPrefScreen.removePreference(mPrefScreen.findPreference(BUTTON_APN_EXPAND_KEY));
68 }
69 if (!res.getBoolean(R.bool.config_operator_selection_expand)) {
70 mPrefScreen.removePreference(mPrefScreen
71 .findPreference(BUTTON_OPERATOR_SELECTION_EXPAND_KEY));
72 }
Santos Cordon7d4ddf62013-07-10 11:58:08 -070073
74 if (res.getBoolean(R.bool.csp_enabled)) {
75 if (PhoneFactory.getDefaultPhone().isCspPlmnEnabled()) {
76 log("[CSP] Enabling Operator Selection menu.");
77 mButtonOperatorSelectionExpand.setEnabled(true);
78 } else {
79 log("[CSP] Disabling Operator Selection menu.");
80 mPrefScreen.removePreference(mPrefScreen
81 .findPreference(BUTTON_OPERATOR_SELECTION_EXPAND_KEY));
82 }
83 }
Sandeep Gutta91007152014-07-01 12:05:52 +053084
85 // Read platform settings for carrier settings
86 final boolean isCarrierSettingsEnabled = mPrefActivity.getResources().getBoolean(
87 R.bool.config_carrier_settings_enable);
88 if (!isCarrierSettingsEnabled) {
89 Preference pref = mPrefScreen.findPreference(BUTTON_CARRIER_SETTINGS_KEY);
90 if (pref != null) {
91 mPrefScreen.removePreference(pref);
92 }
93 }
Santos Cordon7d4ddf62013-07-10 11:58:08 -070094 }
95 }
96
97 public boolean preferenceTreeClick(Preference preference) {
Santos Cordon7d4ddf62013-07-10 11:58:08 -070098 log("preferenceTreeClick: return false");
99 return false;
100 }
101
102 protected void log(String s) {
103 android.util.Log.d(LOG_TAG, s);
104 }
105}