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 19 import android.os.Bundle; 20 import android.os.PersistableBundle; 21 import android.preference.Preference; 22 import android.preference.PreferenceActivity; 23 import android.preference.PreferenceScreen; 24 import android.telephony.CarrierConfigManager; 25 import android.view.MenuItem; 26 27 import com.android.internal.telephony.PhoneConstants; 28 29 public class CdmaCallOptions extends PreferenceActivity { 30 private static final String LOG_TAG = "CdmaCallOptions"; 31 private final boolean DBG = (PhoneGlobals.DBG_LEVEL >= 2); 32 33 private static final String BUTTON_VP_KEY = "button_voice_privacy_key"; 34 private CdmaVoicePrivacySwitchPreference mButtonVoicePrivacy; 35 36 @Override onCreate(Bundle icicle)37 protected void onCreate(Bundle icicle) { 38 super.onCreate(icicle); 39 40 addPreferencesFromResource(R.xml.cdma_call_privacy); 41 42 SubscriptionInfoHelper subInfoHelper = new SubscriptionInfoHelper(this, getIntent()); 43 subInfoHelper.setActionBarTitle( 44 getActionBar(), getResources(), R.string.labelCdmaMore_with_label); 45 46 mButtonVoicePrivacy = (CdmaVoicePrivacySwitchPreference) findPreference(BUTTON_VP_KEY); 47 mButtonVoicePrivacy.setPhone(subInfoHelper.getPhone()); 48 PersistableBundle carrierConfig; 49 if (subInfoHelper.hasSubId()) { 50 carrierConfig = PhoneGlobals.getInstance().getCarrierConfigForSubId( 51 subInfoHelper.getSubId()); 52 } else { 53 carrierConfig = PhoneGlobals.getInstance().getCarrierConfig(); 54 } 55 if (subInfoHelper.getPhone().getPhoneType() != PhoneConstants.PHONE_TYPE_CDMA 56 || carrierConfig.getBoolean(CarrierConfigManager.KEY_VOICE_PRIVACY_DISABLE_UI_BOOL)) { 57 // disable the entire screen 58 getPreferenceScreen().setEnabled(false); 59 } 60 } 61 62 @Override onOptionsItemSelected(MenuItem item)63 public boolean onOptionsItemSelected(MenuItem item) { 64 final int itemId = item.getItemId(); 65 if (itemId == android.R.id.home) { 66 onBackPressed(); 67 return true; 68 } 69 return super.onOptionsItemSelected(item); 70 } 71 72 @Override onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference)73 public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) { 74 if (preference.getKey().equals(BUTTON_VP_KEY)) { 75 return true; 76 } 77 return false; 78 } 79 80 } 81