Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package com.android.phone; |
| 18 | |
| 19 | import android.os.Bundle; |
Aida Takeshi | 7c3b4a3 | 2016-08-11 13:42:24 +0800 | [diff] [blame] | 20 | import android.os.PersistableBundle; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 21 | import android.preference.Preference; |
| 22 | import android.preference.PreferenceActivity; |
| 23 | import android.preference.PreferenceScreen; |
Aida Takeshi | 7c3b4a3 | 2016-08-11 13:42:24 +0800 | [diff] [blame] | 24 | import android.telephony.CarrierConfigManager; |
Sanket Padawe | e09a6f6 | 2015-03-05 11:59:39 -0800 | [diff] [blame] | 25 | import android.view.MenuItem; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 26 | |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 27 | import com.android.internal.telephony.PhoneConstants; |
| 28 | |
| 29 | public class GsmUmtsCallOptions extends PreferenceActivity { |
| 30 | private static final String LOG_TAG = "GsmUmtsCallOptions"; |
| 31 | private final boolean DBG = (PhoneGlobals.DBG_LEVEL >= 2); |
| 32 | |
Sanket Padawe | e09a6f6 | 2015-03-05 11:59:39 -0800 | [diff] [blame] | 33 | private static final String CALL_FORWARDING_KEY = "call_forwarding_key"; |
Aida Takeshi | 7c3b4a3 | 2016-08-11 13:42:24 +0800 | [diff] [blame] | 34 | private static final String CALL_BARRING_KEY = "call_barring_key"; |
Sanket Padawe | e09a6f6 | 2015-03-05 11:59:39 -0800 | [diff] [blame] | 35 | private static final String ADDITIONAL_GSM_SETTINGS_KEY = "additional_gsm_call_settings_key"; |
| 36 | |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 37 | @Override |
| 38 | protected void onCreate(Bundle icicle) { |
| 39 | super.onCreate(icicle); |
| 40 | |
| 41 | addPreferencesFromResource(R.xml.gsm_umts_call_options); |
| 42 | |
Sanket Padawe | e09a6f6 | 2015-03-05 11:59:39 -0800 | [diff] [blame] | 43 | 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 Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 49 | //disable the entire screen |
| 50 | getPreferenceScreen().setEnabled(false); |
| 51 | } |
| 52 | } |
Sanket Padawe | e09a6f6 | 2015-03-05 11:59:39 -0800 | [diff] [blame] | 53 | |
| 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 Takeshi | 7c3b4a3 | 2016-08-11 13:42:24 +0800 | [diff] [blame] | 65 | PersistableBundle b = null; |
| 66 | if (subInfoHelper.hasSubId()) { |
| 67 | b = PhoneGlobals.getInstance().getCarrierConfigForSubId(subInfoHelper.getSubId()); |
| 68 | } else { |
| 69 | b = PhoneGlobals.getInstance().getCarrierConfig(); |
| 70 | } |
SongFerngWang | f6fd992 | 2018-06-28 17:21:43 +0800 | [diff] [blame^] | 71 | |
| 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 Takeshi | 7c3b4a3 | 2016-08-11 13:42:24 +0800 | [diff] [blame] | 104 | } |
Sanket Padawe | e09a6f6 | 2015-03-05 11:59:39 -0800 | [diff] [blame] | 105 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 106 | } |