blob: 40e351719a6178cd26bdf713e2b36e71e2711186 [file] [log] [blame]
Santos Cordon7d4ddf62013-07-10 11:58:08 -07001/*
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
17package com.android.phone;
18
Santos Cordon7d4ddf62013-07-10 11:58:08 -070019import android.os.Bundle;
Jonathan Basseric31f1f32015-05-12 10:13:03 -070020import android.os.PersistableBundle;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070021import android.preference.Preference;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070022import android.preference.PreferenceScreen;
Jonathan Basseri3649bdb2015-04-30 22:39:11 -070023import android.telephony.CarrierConfigManager;
Sanket Padawee09a6f62015-03-05 11:59:39 -080024import android.view.MenuItem;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070025
Aravind Sreekumarafc08c52018-04-10 15:34:32 -070026import com.android.internal.telephony.PhoneConstants;
27
Jang Hayeong4022b382019-07-16 20:05:17 +090028public class CdmaCallOptions extends TimeConsumingPreferenceActivity {
Santos Cordon7d4ddf62013-07-10 11:58:08 -070029 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 Hayeong43bd1402019-07-16 15:40:47 +090033 private static final String CALL_FORWARDING_KEY = "call_forwarding_key";
Jang Hayeong4022b382019-07-16 20:05:17 +090034 private static final String CALL_WAITING_KEY = "call_waiting_key";
Santos Cordon7d4ddf62013-07-10 11:58:08 -070035
36 @Override
37 protected void onCreate(Bundle icicle) {
38 super.onCreate(icicle);
39
40 addPreferencesFromResource(R.xml.cdma_call_privacy);
41
Sanket Padawee09a6f62015-03-05 11:59:39 -080042 SubscriptionInfoHelper subInfoHelper = new SubscriptionInfoHelper(this, getIntent());
43 subInfoHelper.setActionBarTitle(
44 getActionBar(), getResources(), R.string.labelCdmaMore_with_label);
45
Brad Ebinger931ab212021-06-14 11:50:39 -070046 CdmaVoicePrivacySwitchPreference buttonVoicePrivacy =
47 (CdmaVoicePrivacySwitchPreference) findPreference(BUTTON_VP_KEY);
48 buttonVoicePrivacy.setPhone(subInfoHelper.getPhone());
Jonathan Basseric31f1f32015-05-12 10:13:03 -070049 PersistableBundle carrierConfig;
Jonathan Basseri3649bdb2015-04-30 22:39:11 -070050 if (subInfoHelper.hasSubId()) {
51 carrierConfig = PhoneGlobals.getInstance().getCarrierConfigForSubId(
52 subInfoHelper.getSubId());
53 } else {
54 carrierConfig = PhoneGlobals.getInstance().getCarrierConfig();
55 }
Sanket Padawee09a6f62015-03-05 11:59:39 -080056 if (subInfoHelper.getPhone().getPhoneType() != PhoneConstants.PHONE_TYPE_CDMA
Jonathan Basserif0b39112015-06-09 15:14:06 -070057 || carrierConfig.getBoolean(CarrierConfigManager.KEY_VOICE_PRIVACY_DISABLE_UI_BOOL)) {
Brad Ebinger931ab212021-06-14 11:50:39 -070058 buttonVoicePrivacy.setEnabled(false);
Santos Cordon7d4ddf62013-07-10 11:58:08 -070059 }
Jang Hayeong43bd1402019-07-16 15:40:47 +090060
61 Preference callForwardingPref = getPreferenceScreen().findPreference(CALL_FORWARDING_KEY);
Brad Ebinger931ab212021-06-14 11:50:39 -070062 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 Hayeong4022b382019-07-16 20:05:17 +090069
70 CdmaCallWaitingPreference callWaitingPref = (CdmaCallWaitingPreference)getPreferenceScreen()
71 .findPreference(CALL_WAITING_KEY);
Brad Ebinger931ab212021-06-14 11:50:39 -070072 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 Cordon7d4ddf62013-07-10 11:58:08 -070078 }
79
80 @Override
Sanket Padawee09a6f62015-03-05 11:59:39 -080081 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 Cordon7d4ddf62013-07-10 11:58:08 -070091 public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
92 if (preference.getKey().equals(BUTTON_VP_KEY)) {
93 return true;
94 }
95 return false;
96 }
Santos Cordon7d4ddf62013-07-10 11:58:08 -070097}