blob: 2e310aab20a667476804c2f6897cc80bd2dae9a5 [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";
Grace Jiad0ba6312020-03-23 15:12:55 -070035 private CdmaVoicePrivacySwitchPreference mButtonVoicePrivacy;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070036
37 @Override
38 protected void onCreate(Bundle icicle) {
39 super.onCreate(icicle);
40
41 addPreferencesFromResource(R.xml.cdma_call_privacy);
42
Sanket Padawee09a6f62015-03-05 11:59:39 -080043 SubscriptionInfoHelper subInfoHelper = new SubscriptionInfoHelper(this, getIntent());
44 subInfoHelper.setActionBarTitle(
45 getActionBar(), getResources(), R.string.labelCdmaMore_with_label);
46
Grace Jiad0ba6312020-03-23 15:12:55 -070047 mButtonVoicePrivacy = (CdmaVoicePrivacySwitchPreference) findPreference(BUTTON_VP_KEY);
48 mButtonVoicePrivacy.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)) {
Jonathan Basseri3649bdb2015-04-30 22:39:11 -070058 // disable the entire screen
Jang Hayeong43bd1402019-07-16 15:40:47 +090059 mButtonVoicePrivacy.setEnabled(false);
Santos Cordon7d4ddf62013-07-10 11:58:08 -070060 }
Jang Hayeong43bd1402019-07-16 15:40:47 +090061
62 Preference callForwardingPref = getPreferenceScreen().findPreference(CALL_FORWARDING_KEY);
63 callForwardingPref.setIntent(subInfoHelper.getIntent(CdmaCallForwardOptions.class));
Jang Hayeong4022b382019-07-16 20:05:17 +090064
65 CdmaCallWaitingPreference callWaitingPref = (CdmaCallWaitingPreference)getPreferenceScreen()
66 .findPreference(CALL_WAITING_KEY);
67 callWaitingPref.init(this, subInfoHelper.getPhone());
Santos Cordon7d4ddf62013-07-10 11:58:08 -070068 }
69
70 @Override
Sanket Padawee09a6f62015-03-05 11:59:39 -080071 public boolean onOptionsItemSelected(MenuItem item) {
72 final int itemId = item.getItemId();
73 if (itemId == android.R.id.home) {
74 onBackPressed();
75 return true;
76 }
77 return super.onOptionsItemSelected(item);
78 }
79
80 @Override
Santos Cordon7d4ddf62013-07-10 11:58:08 -070081 public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
82 if (preference.getKey().equals(BUTTON_VP_KEY)) {
83 return true;
84 }
85 return false;
86 }
Santos Cordon7d4ddf62013-07-10 11:58:08 -070087}