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