blob: ab44b54bb128191f021accf21c01267915cfa941 [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.Preference;
22import android.preference.PreferenceActivity;
23import android.preference.PreferenceScreen;
Aida Takeshi7c3b4a32016-08-11 13:42:24 +080024import android.telephony.CarrierConfigManager;
Sanket Padawee09a6f62015-03-05 11:59:39 -080025import android.view.MenuItem;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070026
Santos Cordon7d4ddf62013-07-10 11:58:08 -070027import com.android.internal.telephony.PhoneConstants;
28
29public class GsmUmtsCallOptions extends PreferenceActivity {
30 private static final String LOG_TAG = "GsmUmtsCallOptions";
31 private final boolean DBG = (PhoneGlobals.DBG_LEVEL >= 2);
32
Sanket Padawee09a6f62015-03-05 11:59:39 -080033 private static final String CALL_FORWARDING_KEY = "call_forwarding_key";
Aida Takeshi7c3b4a32016-08-11 13:42:24 +080034 private static final String CALL_BARRING_KEY = "call_barring_key";
Sanket Padawee09a6f62015-03-05 11:59:39 -080035 private static final String ADDITIONAL_GSM_SETTINGS_KEY = "additional_gsm_call_settings_key";
36
Santos Cordon7d4ddf62013-07-10 11:58:08 -070037 @Override
38 protected void onCreate(Bundle icicle) {
39 super.onCreate(icicle);
40
41 addPreferencesFromResource(R.xml.gsm_umts_call_options);
42
Sanket Padawee09a6f62015-03-05 11:59:39 -080043 SubscriptionInfoHelper subInfoHelper = new SubscriptionInfoHelper(this, getIntent());
44 subInfoHelper.setActionBarTitle(
45 getActionBar(), getResources(), R.string.labelGsmMore_with_label);
46 init(getPreferenceScreen(), subInfoHelper);
47
48 if (subInfoHelper.getPhone().getPhoneType() != PhoneConstants.PHONE_TYPE_GSM) {
Santos Cordon7d4ddf62013-07-10 11:58:08 -070049 //disable the entire screen
50 getPreferenceScreen().setEnabled(false);
51 }
52 }
Sanket Padawee09a6f62015-03-05 11:59:39 -080053
54 @Override
55 public boolean onOptionsItemSelected(MenuItem item) {
56 final int itemId = item.getItemId();
57 if (itemId == android.R.id.home) {
58 onBackPressed();
59 return true;
60 }
61 return super.onOptionsItemSelected(item);
62 }
63
64 public static void init(PreferenceScreen prefScreen, SubscriptionInfoHelper subInfoHelper) {
Aida Takeshi7c3b4a32016-08-11 13:42:24 +080065 PersistableBundle b = null;
66 if (subInfoHelper.hasSubId()) {
67 b = PhoneGlobals.getInstance().getCarrierConfigForSubId(subInfoHelper.getSubId());
68 } else {
69 b = PhoneGlobals.getInstance().getCarrierConfig();
70 }
SongFerngWangf6fd9922018-06-28 17:21:43 +080071
72 Preference callForwardingPref = prefScreen.findPreference(CALL_FORWARDING_KEY);
73 if (callForwardingPref != null) {
74 if (b != null && b.getBoolean(
75 CarrierConfigManager.KEY_CALL_FORWARDING_VISIBILITY_BOOL)) {
76 callForwardingPref.setIntent(
77 subInfoHelper.getIntent(GsmUmtsCallForwardOptions.class));
78 } else {
79 prefScreen.removePreference(callForwardingPref);
80 }
81 }
82
83 Preference additionalGsmSettingsPref =
84 prefScreen.findPreference(ADDITIONAL_GSM_SETTINGS_KEY);
85 if (additionalGsmSettingsPref != null) {
86 if (b != null && (b.getBoolean(
87 CarrierConfigManager.KEY_ADDITIONAL_SETTINGS_CALL_WAITING_VISIBILITY_BOOL)
88 || b.getBoolean(
89 CarrierConfigManager.KEY_ADDITIONAL_SETTINGS_CALLER_ID_VISIBILITY_BOOL))) {
90 additionalGsmSettingsPref.setIntent(
91 subInfoHelper.getIntent(GsmUmtsAdditionalCallOptions.class));
92 } else {
93 prefScreen.removePreference(additionalGsmSettingsPref);
94 }
95 }
96
97 Preference callBarringPref = prefScreen.findPreference(CALL_BARRING_KEY);
98 if (callBarringPref != null) {
99 if (b != null && b.getBoolean(CarrierConfigManager.KEY_CALL_BARRING_VISIBILITY_BOOL)) {
100 callBarringPref.setIntent(subInfoHelper.getIntent(GsmUmtsCallBarringOptions.class));
101 } else {
102 prefScreen.removePreference(callBarringPref);
103 }
Aida Takeshi7c3b4a32016-08-11 13:42:24 +0800104 }
Sanket Padawee09a6f62015-03-05 11:59:39 -0800105 }
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700106}