blob: a2bc9cb12fbca97739688a059eae909e42eb4d35 [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;
22import android.preference.PreferenceActivity;
23import android.preference.PreferenceScreen;
fionaxue46e69f2017-04-27 14:32:46 -070024import android.preference.SwitchPreference;
Jonathan Basseri3649bdb2015-04-30 22:39:11 -070025import android.telephony.CarrierConfigManager;
Sanket Padawee09a6f62015-03-05 11:59:39 -080026import android.view.MenuItem;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070027
Aravind Sreekumarafc08c52018-04-10 15:34:32 -070028import com.android.internal.telephony.PhoneConstants;
29
Santos Cordon7d4ddf62013-07-10 11:58:08 -070030public class CdmaCallOptions extends PreferenceActivity {
31 private static final String LOG_TAG = "CdmaCallOptions";
32 private final boolean DBG = (PhoneGlobals.DBG_LEVEL >= 2);
33
34 private static final String BUTTON_VP_KEY = "button_voice_privacy_key";
Jang Hayeong43bd1402019-07-16 15:40:47 +090035 private static final String CALL_FORWARDING_KEY = "call_forwarding_key";
fionaxue46e69f2017-04-27 14:32:46 -070036 private SwitchPreference mButtonVoicePrivacy;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070037
38 @Override
39 protected void onCreate(Bundle icicle) {
40 super.onCreate(icicle);
41
42 addPreferencesFromResource(R.xml.cdma_call_privacy);
43
Sanket Padawee09a6f62015-03-05 11:59:39 -080044 SubscriptionInfoHelper subInfoHelper = new SubscriptionInfoHelper(this, getIntent());
45 subInfoHelper.setActionBarTitle(
46 getActionBar(), getResources(), R.string.labelCdmaMore_with_label);
47
fionaxue46e69f2017-04-27 14:32:46 -070048 mButtonVoicePrivacy = (SwitchPreference) findPreference(BUTTON_VP_KEY);
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));
Santos Cordon7d4ddf62013-07-10 11:58:08 -070064 }
65
66 @Override
Sanket Padawee09a6f62015-03-05 11:59:39 -080067 public boolean onOptionsItemSelected(MenuItem item) {
68 final int itemId = item.getItemId();
69 if (itemId == android.R.id.home) {
70 onBackPressed();
71 return true;
72 }
73 return super.onOptionsItemSelected(item);
74 }
75
76 @Override
Santos Cordon7d4ddf62013-07-10 11:58:08 -070077 public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
78 if (preference.getKey().equals(BUTTON_VP_KEY)) {
79 return true;
80 }
81 return false;
82 }
83
84}