blob: 3b27d28130219f779cf969ee84e0be18faade5f3 [file] [log] [blame]
Santos Cordon7d4ddf62013-07-10 11:58:08 -07001/*
2 * Copyright (C) 2006 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
19import android.os.Bundle;
Aida Takeshi7c3b4a32016-08-11 13:42:24 +080020import android.os.PersistableBundle;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070021import android.preference.CheckBoxPreference;
22import android.preference.Preference;
23import android.preference.PreferenceActivity;
24import android.preference.PreferenceScreen;
Aida Takeshi7c3b4a32016-08-11 13:42:24 +080025import android.telephony.CarrierConfigManager;
Sanket Padawee09a6f62015-03-05 11:59:39 -080026import android.view.MenuItem;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070027
28import com.android.internal.telephony.Phone;
29import com.android.internal.telephony.PhoneConstants;
30
31public class GsmUmtsCallOptions extends PreferenceActivity {
32 private static final String LOG_TAG = "GsmUmtsCallOptions";
33 private final boolean DBG = (PhoneGlobals.DBG_LEVEL >= 2);
34
Sanket Padawee09a6f62015-03-05 11:59:39 -080035 private static final String CALL_FORWARDING_KEY = "call_forwarding_key";
Aida Takeshi7c3b4a32016-08-11 13:42:24 +080036 private static final String CALL_BARRING_KEY = "call_barring_key";
Sanket Padawee09a6f62015-03-05 11:59:39 -080037 private static final String ADDITIONAL_GSM_SETTINGS_KEY = "additional_gsm_call_settings_key";
38
Santos Cordon7d4ddf62013-07-10 11:58:08 -070039 @Override
40 protected void onCreate(Bundle icicle) {
41 super.onCreate(icicle);
42
43 addPreferencesFromResource(R.xml.gsm_umts_call_options);
44
Sanket Padawee09a6f62015-03-05 11:59:39 -080045 SubscriptionInfoHelper subInfoHelper = new SubscriptionInfoHelper(this, getIntent());
46 subInfoHelper.setActionBarTitle(
47 getActionBar(), getResources(), R.string.labelGsmMore_with_label);
48 init(getPreferenceScreen(), subInfoHelper);
49
50 if (subInfoHelper.getPhone().getPhoneType() != PhoneConstants.PHONE_TYPE_GSM) {
Santos Cordon7d4ddf62013-07-10 11:58:08 -070051 //disable the entire screen
52 getPreferenceScreen().setEnabled(false);
53 }
54 }
Sanket Padawee09a6f62015-03-05 11:59:39 -080055
56 @Override
57 public boolean onOptionsItemSelected(MenuItem item) {
58 final int itemId = item.getItemId();
59 if (itemId == android.R.id.home) {
60 onBackPressed();
61 return true;
62 }
63 return super.onOptionsItemSelected(item);
64 }
65
66 public static void init(PreferenceScreen prefScreen, SubscriptionInfoHelper subInfoHelper) {
67 Preference callForwardingPref = prefScreen.findPreference(CALL_FORWARDING_KEY);
68 callForwardingPref.setIntent(subInfoHelper.getIntent(GsmUmtsCallForwardOptions.class));
69
70 Preference additionalGsmSettingsPref =
71 prefScreen.findPreference(ADDITIONAL_GSM_SETTINGS_KEY);
72 additionalGsmSettingsPref.setIntent(
73 subInfoHelper.getIntent(GsmUmtsAdditionalCallOptions.class));
Aida Takeshi7c3b4a32016-08-11 13:42:24 +080074
75 Preference callBarringPref = prefScreen.findPreference(CALL_BARRING_KEY);
76 PersistableBundle b = null;
77 if (subInfoHelper.hasSubId()) {
78 b = PhoneGlobals.getInstance().getCarrierConfigForSubId(subInfoHelper.getSubId());
79 } else {
80 b = PhoneGlobals.getInstance().getCarrierConfig();
81 }
82 if (b != null && b.getBoolean(CarrierConfigManager.KEY_CALL_BARRING_VISIBILITY_BOOL)) {
83 callBarringPref.setIntent(subInfoHelper.getIntent(GsmUmtsCallBarringOptions.class));
84 } else {
85 prefScreen.removePreference(callBarringPref);
86 }
Sanket Padawee09a6f62015-03-05 11:59:39 -080087 }
Santos Cordon7d4ddf62013-07-10 11:58:08 -070088}