blob: 51d1b662ebf052bb755570357a698e38c3b8a9ab [file] [log] [blame]
Santos Cordon7d4ddf62013-07-10 11:58:08 -07001/*
2 * Copyright (C) 2006 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 android.os.Bundle;
Aida Takeshi7c3b4a32016-08-11 13:42:24 +080020import android.os.PersistableBundle;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070021import android.preference.Preference;
22import android.preference.PreferenceActivity;
23import android.preference.PreferenceScreen;
SongFerngWang022b5da2019-11-25 22:52:03 +080024import android.provider.Settings;
Aida Takeshi7c3b4a32016-08-11 13:42:24 +080025import android.telephony.CarrierConfigManager;
Sanket Padawee09a6f62015-03-05 11:59:39 -080026import android.view.MenuItem;
Santos Cordon7d4ddf62013-07-10 11:58:08 -070027
Santos Cordon7d4ddf62013-07-10 11:58:08 -070028import com.android.internal.telephony.PhoneConstants;
29
30public class GsmUmtsCallOptions extends PreferenceActivity {
31 private static final String LOG_TAG = "GsmUmtsCallOptions";
32 private final boolean DBG = (PhoneGlobals.DBG_LEVEL >= 2);
33
SongFerngWangbed485e2018-07-09 21:15:29 +080034 public static final String CALL_FORWARDING_KEY = "call_forwarding_key";
35 public static final String CALL_BARRING_KEY = "call_barring_key";
SongFerngWang022b5da2019-11-25 22:52:03 +080036 public static final String ADDITIONAL_GSM_SETTINGS_KEY = "additional_gsm_call_settings_key";
Sanket Padawee09a6f62015-03-05 11:59:39 -080037
Santos Cordon7d4ddf62013-07-10 11:58:08 -070038 @Override
39 protected void onCreate(Bundle icicle) {
40 super.onCreate(icicle);
41
42 addPreferencesFromResource(R.xml.gsm_umts_call_options);
43
Sanket Padawee09a6f62015-03-05 11:59:39 -080044 SubscriptionInfoHelper subInfoHelper = new SubscriptionInfoHelper(this, getIntent());
45 subInfoHelper.setActionBarTitle(
46 getActionBar(), getResources(), R.string.labelGsmMore_with_label);
47 init(getPreferenceScreen(), subInfoHelper);
48
49 if (subInfoHelper.getPhone().getPhoneType() != PhoneConstants.PHONE_TYPE_GSM) {
Santos Cordon7d4ddf62013-07-10 11:58:08 -070050 //disable the entire screen
51 getPreferenceScreen().setEnabled(false);
52 }
53 }
Sanket Padawee09a6f62015-03-05 11:59:39 -080054
55 @Override
56 public boolean onOptionsItemSelected(MenuItem item) {
57 final int itemId = item.getItemId();
58 if (itemId == android.R.id.home) {
59 onBackPressed();
60 return true;
61 }
62 return super.onOptionsItemSelected(item);
63 }
64
65 public static void init(PreferenceScreen prefScreen, SubscriptionInfoHelper subInfoHelper) {
Aida Takeshi7c3b4a32016-08-11 13:42:24 +080066 PersistableBundle b = null;
67 if (subInfoHelper.hasSubId()) {
68 b = PhoneGlobals.getInstance().getCarrierConfigForSubId(subInfoHelper.getSubId());
69 } else {
70 b = PhoneGlobals.getInstance().getCarrierConfig();
71 }
SongFerngWangf6fd9922018-06-28 17:21:43 +080072
SongFerngWang022b5da2019-11-25 22:52:03 +080073 boolean isAirplaneModeOff = true;
74 if (b != null && b.getBoolean(
75 CarrierConfigManager.KEY_DISABLE_SUPPLEMENTARY_SERVICES_IN_AIRPLANE_MODE_BOOL)) {
76 int airplaneMode = Settings.Global.getInt(
77 subInfoHelper.getPhone().getContext().getContentResolver(),
78 Settings.Global.AIRPLANE_MODE_ON, PhoneGlobals.AIRPLANE_OFF);
79 isAirplaneModeOff = PhoneGlobals.AIRPLANE_ON != airplaneMode;
80 }
81
SongFerngWangf6fd9922018-06-28 17:21:43 +080082 Preference callForwardingPref = prefScreen.findPreference(CALL_FORWARDING_KEY);
83 if (callForwardingPref != null) {
84 if (b != null && b.getBoolean(
85 CarrierConfigManager.KEY_CALL_FORWARDING_VISIBILITY_BOOL)) {
86 callForwardingPref.setIntent(
87 subInfoHelper.getIntent(GsmUmtsCallForwardOptions.class));
SongFerngWang022b5da2019-11-25 22:52:03 +080088 callForwardingPref.setEnabled(isAirplaneModeOff);
SongFerngWangf6fd9922018-06-28 17:21:43 +080089 } else {
90 prefScreen.removePreference(callForwardingPref);
91 }
92 }
93
94 Preference additionalGsmSettingsPref =
95 prefScreen.findPreference(ADDITIONAL_GSM_SETTINGS_KEY);
96 if (additionalGsmSettingsPref != null) {
97 if (b != null && (b.getBoolean(
98 CarrierConfigManager.KEY_ADDITIONAL_SETTINGS_CALL_WAITING_VISIBILITY_BOOL)
99 || b.getBoolean(
100 CarrierConfigManager.KEY_ADDITIONAL_SETTINGS_CALLER_ID_VISIBILITY_BOOL))) {
101 additionalGsmSettingsPref.setIntent(
102 subInfoHelper.getIntent(GsmUmtsAdditionalCallOptions.class));
SongFerngWang022b5da2019-11-25 22:52:03 +0800103 additionalGsmSettingsPref.setEnabled(isAirplaneModeOff);
SongFerngWangf6fd9922018-06-28 17:21:43 +0800104 } else {
105 prefScreen.removePreference(additionalGsmSettingsPref);
106 }
107 }
108
109 Preference callBarringPref = prefScreen.findPreference(CALL_BARRING_KEY);
110 if (callBarringPref != null) {
111 if (b != null && b.getBoolean(CarrierConfigManager.KEY_CALL_BARRING_VISIBILITY_BOOL)) {
112 callBarringPref.setIntent(subInfoHelper.getIntent(GsmUmtsCallBarringOptions.class));
SongFerngWang022b5da2019-11-25 22:52:03 +0800113 callBarringPref.setEnabled(isAirplaneModeOff);
SongFerngWangf6fd9922018-06-28 17:21:43 +0800114 } else {
115 prefScreen.removePreference(callBarringPref);
116 }
Aida Takeshi7c3b4a32016-08-11 13:42:24 +0800117 }
Sanket Padawee09a6f62015-03-05 11:59:39 -0800118 }
Santos Cordon7d4ddf62013-07-10 11:58:08 -0700119}