Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2009 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 | |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 19 | import android.os.Bundle; |
Jonathan Basseri | c31f1f3 | 2015-05-12 10:13:03 -0700 | [diff] [blame] | 20 | import android.os.PersistableBundle; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 21 | import android.preference.Preference; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 22 | import android.preference.PreferenceScreen; |
Jonathan Basseri | 3649bdb | 2015-04-30 22:39:11 -0700 | [diff] [blame] | 23 | import android.telephony.CarrierConfigManager; |
Sanket Padawe | e09a6f6 | 2015-03-05 11:59:39 -0800 | [diff] [blame] | 24 | import android.view.MenuItem; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 25 | |
Aravind Sreekumar | afc08c5 | 2018-04-10 15:34:32 -0700 | [diff] [blame] | 26 | import com.android.internal.telephony.PhoneConstants; |
| 27 | |
Jang Hayeong | 4022b38 | 2019-07-16 20:05:17 +0900 | [diff] [blame] | 28 | public class CdmaCallOptions extends TimeConsumingPreferenceActivity { |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 29 | private static final String LOG_TAG = "CdmaCallOptions"; |
| 30 | private final boolean DBG = (PhoneGlobals.DBG_LEVEL >= 2); |
| 31 | |
| 32 | private static final String BUTTON_VP_KEY = "button_voice_privacy_key"; |
Jang Hayeong | 43bd140 | 2019-07-16 15:40:47 +0900 | [diff] [blame] | 33 | private static final String CALL_FORWARDING_KEY = "call_forwarding_key"; |
Jang Hayeong | 4022b38 | 2019-07-16 20:05:17 +0900 | [diff] [blame] | 34 | private static final String CALL_WAITING_KEY = "call_waiting_key"; |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 35 | |
| 36 | @Override |
| 37 | protected void onCreate(Bundle icicle) { |
| 38 | super.onCreate(icicle); |
| 39 | |
| 40 | addPreferencesFromResource(R.xml.cdma_call_privacy); |
| 41 | |
Sanket Padawe | e09a6f6 | 2015-03-05 11:59:39 -0800 | [diff] [blame] | 42 | SubscriptionInfoHelper subInfoHelper = new SubscriptionInfoHelper(this, getIntent()); |
| 43 | subInfoHelper.setActionBarTitle( |
| 44 | getActionBar(), getResources(), R.string.labelCdmaMore_with_label); |
| 45 | |
Brad Ebinger | 931ab21 | 2021-06-14 11:50:39 -0700 | [diff] [blame^] | 46 | CdmaVoicePrivacySwitchPreference buttonVoicePrivacy = |
| 47 | (CdmaVoicePrivacySwitchPreference) findPreference(BUTTON_VP_KEY); |
| 48 | buttonVoicePrivacy.setPhone(subInfoHelper.getPhone()); |
Jonathan Basseri | c31f1f3 | 2015-05-12 10:13:03 -0700 | [diff] [blame] | 49 | PersistableBundle carrierConfig; |
Jonathan Basseri | 3649bdb | 2015-04-30 22:39:11 -0700 | [diff] [blame] | 50 | if (subInfoHelper.hasSubId()) { |
| 51 | carrierConfig = PhoneGlobals.getInstance().getCarrierConfigForSubId( |
| 52 | subInfoHelper.getSubId()); |
| 53 | } else { |
| 54 | carrierConfig = PhoneGlobals.getInstance().getCarrierConfig(); |
| 55 | } |
Sanket Padawe | e09a6f6 | 2015-03-05 11:59:39 -0800 | [diff] [blame] | 56 | if (subInfoHelper.getPhone().getPhoneType() != PhoneConstants.PHONE_TYPE_CDMA |
Jonathan Basseri | f0b3911 | 2015-06-09 15:14:06 -0700 | [diff] [blame] | 57 | || carrierConfig.getBoolean(CarrierConfigManager.KEY_VOICE_PRIVACY_DISABLE_UI_BOOL)) { |
Brad Ebinger | 931ab21 | 2021-06-14 11:50:39 -0700 | [diff] [blame^] | 58 | buttonVoicePrivacy.setEnabled(false); |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 59 | } |
Jang Hayeong | 43bd140 | 2019-07-16 15:40:47 +0900 | [diff] [blame] | 60 | |
| 61 | Preference callForwardingPref = getPreferenceScreen().findPreference(CALL_FORWARDING_KEY); |
Brad Ebinger | 931ab21 | 2021-06-14 11:50:39 -0700 | [diff] [blame^] | 62 | if (carrierConfig != null && carrierConfig.getBoolean( |
| 63 | CarrierConfigManager.KEY_CALL_FORWARDING_VISIBILITY_BOOL)) { |
| 64 | callForwardingPref.setIntent( |
| 65 | subInfoHelper.getIntent(CdmaCallForwardOptions.class)); |
| 66 | } else { |
| 67 | getPreferenceScreen().removePreference(callForwardingPref); |
| 68 | } |
Jang Hayeong | 4022b38 | 2019-07-16 20:05:17 +0900 | [diff] [blame] | 69 | |
| 70 | CdmaCallWaitingPreference callWaitingPref = (CdmaCallWaitingPreference)getPreferenceScreen() |
| 71 | .findPreference(CALL_WAITING_KEY); |
Brad Ebinger | 931ab21 | 2021-06-14 11:50:39 -0700 | [diff] [blame^] | 72 | if (carrierConfig != null && carrierConfig.getBoolean( |
| 73 | CarrierConfigManager.KEY_ADDITIONAL_SETTINGS_CALL_WAITING_VISIBILITY_BOOL)) { |
| 74 | callWaitingPref.init(this, subInfoHelper.getPhone()); |
| 75 | } else { |
| 76 | getPreferenceScreen().removePreference(callWaitingPref); |
| 77 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 78 | } |
| 79 | |
| 80 | @Override |
Sanket Padawe | e09a6f6 | 2015-03-05 11:59:39 -0800 | [diff] [blame] | 81 | public boolean onOptionsItemSelected(MenuItem item) { |
| 82 | final int itemId = item.getItemId(); |
| 83 | if (itemId == android.R.id.home) { |
| 84 | onBackPressed(); |
| 85 | return true; |
| 86 | } |
| 87 | return super.onOptionsItemSelected(item); |
| 88 | } |
| 89 | |
| 90 | @Override |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 91 | public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) { |
| 92 | if (preference.getKey().equals(BUTTON_VP_KEY)) { |
| 93 | return true; |
| 94 | } |
| 95 | return false; |
| 96 | } |
Santos Cordon | 7d4ddf6 | 2013-07-10 11:58:08 -0700 | [diff] [blame] | 97 | } |