• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 
17 package com.android.phone;
18 
19 import android.preference.CheckBoxPreference;
20 import android.preference.Preference;
21 import android.preference.PreferenceActivity;
22 import android.preference.PreferenceScreen;
23 
24 import com.android.internal.telephony.Phone;
25 import com.android.internal.telephony.PhoneConstants;
26 import com.android.internal.telephony.PhoneFactory;
27 
28 /**
29  * List of Network-specific settings screens.
30  */
31 public class GsmUmtsOptions {
32     private static final String LOG_TAG = "GsmUmtsOptions";
33 
34     private PreferenceScreen mButtonAPNExpand;
35     private PreferenceScreen mButtonOperatorSelectionExpand;
36     private CheckBoxPreference mButtonPrefer2g;
37 
38     private static final String BUTTON_APN_EXPAND_KEY = "button_apn_key";
39     private static final String BUTTON_OPERATOR_SELECTION_EXPAND_KEY = "button_carrier_sel_key";
40     private static final String BUTTON_PREFER_2G_KEY = "button_prefer_2g_key";
41     private PreferenceActivity mPrefActivity;
42     private PreferenceScreen mPrefScreen;
43 
GsmUmtsOptions(PreferenceActivity prefActivity, PreferenceScreen prefScreen)44     public GsmUmtsOptions(PreferenceActivity prefActivity, PreferenceScreen prefScreen) {
45         mPrefActivity = prefActivity;
46         mPrefScreen = prefScreen;
47         create();
48     }
49 
create()50     protected void create() {
51         mPrefActivity.addPreferencesFromResource(R.xml.gsm_umts_options);
52         mButtonAPNExpand = (PreferenceScreen) mPrefScreen.findPreference(BUTTON_APN_EXPAND_KEY);
53         mButtonOperatorSelectionExpand =
54                 (PreferenceScreen) mPrefScreen.findPreference(BUTTON_OPERATOR_SELECTION_EXPAND_KEY);
55         mButtonPrefer2g = (CheckBoxPreference) mPrefScreen.findPreference(BUTTON_PREFER_2G_KEY);
56         if (PhoneFactory.getDefaultPhone().getPhoneType() != PhoneConstants.PHONE_TYPE_GSM) {
57             log("Not a GSM phone");
58             mButtonAPNExpand.setEnabled(false);
59             mButtonOperatorSelectionExpand.setEnabled(false);
60             mButtonPrefer2g.setEnabled(false);
61         } else if (mPrefActivity.getResources().getBoolean(R.bool.csp_enabled)) {
62             if (PhoneFactory.getDefaultPhone().isCspPlmnEnabled()) {
63                 log("[CSP] Enabling Operator Selection menu.");
64                 mButtonOperatorSelectionExpand.setEnabled(true);
65             } else {
66                 log("[CSP] Disabling Operator Selection menu.");
67                 mPrefScreen.removePreference(mPrefScreen
68                       .findPreference(BUTTON_OPERATOR_SELECTION_EXPAND_KEY));
69             }
70         }
71     }
72 
preferenceTreeClick(Preference preference)73     public boolean preferenceTreeClick(Preference preference) {
74         if (preference.getKey().equals(BUTTON_PREFER_2G_KEY)) {
75             log("preferenceTreeClick: return true");
76             return true;
77         }
78         log("preferenceTreeClick: return false");
79         return false;
80     }
81 
log(String s)82     protected void log(String s) {
83         android.util.Log.d(LOG_TAG, s);
84     }
85 }
86