Merge "Use resource instead of carrier config"
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index c9281d1..b14ce89 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -93,6 +93,7 @@
So, declare this permission here for backwards compatibility so the phone process can send
the broadcasts to those same receivers. -->
<uses-permission android:name="android.permission.CONTROL_INCALL_EXPERIENCE" />
+ <uses-permission android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
@@ -266,10 +267,7 @@
android:theme="@style/NetworkOperatorsSettingsTheme"
android:configChanges="orientation|screenSize">
<intent-filter>
- <action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.MAIN" />
- <action android:name="android.settings.NETWORK_OPERATOR_SETTINGS" />
- <action android:name="android.settings.DATA_ROAMING_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
diff --git a/src/com/android/phone/CarrierConfigLoader.java b/src/com/android/phone/CarrierConfigLoader.java
index 86f0aa4..dab2177 100644
--- a/src/com/android/phone/CarrierConfigLoader.java
+++ b/src/com/android/phone/CarrierConfigLoader.java
@@ -390,7 +390,7 @@
PersistableBundle config =
resultData.getParcelable(KEY_CONFIG_BUNDLE);
saveConfigToXml(
- mPlatformCarrierConfigPackage, iccid, config);
+ getCarrierPackageForPhoneId(phoneId), iccid, config);
mConfigFromCarrierApp[phoneId] = config;
sendMessage(
obtainMessage(
diff --git a/src/com/android/phone/CdmaOptions.java b/src/com/android/phone/CdmaOptions.java
index ff37c70..7f7d58c 100644
--- a/src/com/android/phone/CdmaOptions.java
+++ b/src/com/android/phone/CdmaOptions.java
@@ -26,9 +26,11 @@
import android.telephony.CarrierConfigManager;
import android.text.TextUtils;
+import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.internal.telephony.Phone;
+import com.android.internal.telephony.PhoneConstants;
import com.android.settingslib.RestrictedLockUtils;
/**
@@ -53,6 +55,12 @@
private PreferenceScreen mPrefScreen;
private Phone mPhone;
+ // Constructor for CdmaOptionsTest, since PreferenceScreen is final and cannot be mocked
+ @VisibleForTesting
+ public CdmaOptions(Phone phone) {
+ mPhone = phone;
+ }
+
public CdmaOptions(PreferenceFragment prefFragment, PreferenceScreen prefScreen, Phone phone) {
mPrefFragment = prefFragment;
mPrefScreen = prefScreen;
@@ -79,8 +87,7 @@
PersistableBundle carrierConfig =
PhoneGlobals.getInstance().getCarrierConfigForSubId(mPhone.getSubId());
// Some CDMA carriers want the APN settings.
- boolean addAPNExpand =
- carrierConfig.getBoolean(CarrierConfigManager.KEY_SHOW_APN_SETTING_CDMA_BOOL);
+ boolean addAPNExpand = shouldAddApnExpandPreference(carrierConfig);
boolean addCdmaSubscription =
deviceSupportsNvAndRuim();
// Read platform settings for carrier settings
@@ -94,6 +101,7 @@
// Calling add or remove explicitly to make sure they are updated.
if (addAPNExpand) {
+ log("update: addAPNExpand");
mButtonAPNExpand.setDisabledByAdmin(
MobileNetworkSettings.isDpcApnEnforced(mButtonAPNExpand.getContext())
? RestrictedLockUtils.getDeviceOwner(mButtonAPNExpand.getContext())
@@ -136,6 +144,19 @@
}
}
+ /**
+ * Return whether we should add the APN expandable preference based on the phone type and
+ * carrier config
+ */
+ @VisibleForTesting
+ public boolean shouldAddApnExpandPreference(PersistableBundle config) {
+ if (mPhone.getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA
+ && config.getBoolean(CarrierConfigManager.KEY_SHOW_APN_SETTING_CDMA_BOOL)) {
+ return true;
+ }
+ return false;
+ }
+
private boolean deviceSupportsNvAndRuim() {
// retrieve the list of subscription types supported by device.
String subscriptionsSupported = SystemProperties.get("ril.subscription.types");
diff --git a/src/com/android/phone/GsmUmtsOptions.java b/src/com/android/phone/GsmUmtsOptions.java
index 220cf34..19cd3ef 100644
--- a/src/com/android/phone/GsmUmtsOptions.java
+++ b/src/com/android/phone/GsmUmtsOptions.java
@@ -26,8 +26,8 @@
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
+import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneConstants;
-import com.android.internal.telephony.PhoneFactory;
import com.android.settingslib.RestrictedLockUtils;
/**
@@ -72,9 +72,11 @@
boolean addAPNExpand = true;
boolean addNetworkOperatorsCategory = true;
boolean addCarrierSettings = true;
- if (PhoneFactory.getDefaultPhone().getPhoneType() != PhoneConstants.PHONE_TYPE_GSM) {
+ Phone phone = PhoneGlobals.getPhone(subId);
+ if (phone == null) return;
+ if (phone.getPhoneType() != PhoneConstants.PHONE_TYPE_GSM) {
log("Not a GSM phone");
- mCategoryAPNExpand.setEnabled(false);
+ addAPNExpand = false;
mNetworkOperator.setEnabled(false);
} else {
log("Not a CDMA phone");
@@ -96,7 +98,7 @@
}
if (carrierConfig.getBoolean(CarrierConfigManager.KEY_CSP_ENABLED_BOOL)) {
- if (PhoneFactory.getDefaultPhone().isCspPlmnEnabled()) {
+ if (phone.isCspPlmnEnabled()) {
log("[CSP] Enabling Operator Selection menu.");
mNetworkOperator.setEnabled(true);
} else {
@@ -114,6 +116,7 @@
// Calling add or remove explicitly to make sure they are updated.
if (addAPNExpand) {
+ log("update: addAPNExpand");
mButtonAPNExpand.setDisabledByAdmin(
MobileNetworkSettings.isDpcApnEnforced(mButtonAPNExpand.getContext())
? RestrictedLockUtils.getDeviceOwner(mButtonAPNExpand.getContext())
diff --git a/src/com/android/phone/MobileNetworkSettings.java b/src/com/android/phone/MobileNetworkSettings.java
index 43f57aa..1f406ea 100644
--- a/src/com/android/phone/MobileNetworkSettings.java
+++ b/src/com/android/phone/MobileNetworkSettings.java
@@ -1855,15 +1855,10 @@
updateGsmUmtsOptions(this, prefSet, mPhone.getSubId(), mNetworkQueryService);
- PreferenceCategory apnExpand =
- (PreferenceCategory) prefSet.findPreference(CATEGORY_GSM_APN_EXPAND_KEY);
PreferenceCategory networkOperatorCategory =
(PreferenceCategory) prefSet.findPreference(
NetworkOperators.CATEGORY_NETWORK_OPERATORS_KEY);
Preference carrierSettings = prefSet.findPreference(BUTTON_CARRIER_SETTINGS_KEY);
- if (apnExpand != null) {
- apnExpand.setEnabled(isWorldMode() || enable);
- }
if (networkOperatorCategory != null) {
if (enable) {
networkOperatorCategory.setEnabled(true);
diff --git a/src/com/android/phone/NetworkOperators.java b/src/com/android/phone/NetworkOperators.java
index 44af267..b3231f1 100644
--- a/src/com/android/phone/NetworkOperators.java
+++ b/src/com/android/phone/NetworkOperators.java
@@ -66,8 +66,9 @@
private int mSubId;
private ProgressDialog mProgressDialog;
- // There's two sets of Auto-Select UI in this class. {@link mNetworkSelect} is used for all
- // pre-Pixel 3 devices, while {@link mChooseNetwork} is used for all devices after Pixel3.
+ // There's two sets of Auto-Select UI in this class.
+ // If {@code com.android.internal.R.bool.config_enableNewAutoSelectNetworkUI} set as true
+ // {@link mChooseNetwork} will be used, otherwise {@link mNetworkSelect} will be used.
boolean mEnableNewManualSelectNetworkUI;
public NetworkOperators(Context context, AttributeSet attrs) {
@@ -241,17 +242,16 @@
private void selectNetworkAutomatic(boolean autoSelect) {
if (DBG) logd("selectNetworkAutomatic: " + String.valueOf(autoSelect));
- if (mEnableNewManualSelectNetworkUI) {
- if (mChooseNetwork != null) {
- mChooseNetwork.setEnabled(!autoSelect);
- }
- } else {
- if (mNetworkSelect != null) {
- mNetworkSelect.setEnabled(!autoSelect);
- }
- }
-
if (autoSelect) {
+ if (mEnableNewManualSelectNetworkUI) {
+ if (mChooseNetwork != null) {
+ mChooseNetwork.setEnabled(!autoSelect);
+ }
+ } else {
+ if (mNetworkSelect != null) {
+ mNetworkSelect.setEnabled(!autoSelect);
+ }
+ }
if (DBG) logd("select network automatically...");
showAutoSelectProgressBar();
mAutoSelect.setEnabled(false);
@@ -325,4 +325,4 @@
private void loge(String msg) {
Log.e(LOG_TAG, "[NetworksList] " + msg);
}
-}
\ No newline at end of file
+}
diff --git a/src/com/android/phone/NetworkSelectListPreference.java b/src/com/android/phone/NetworkSelectListPreference.java
index 4bb03b0..3ba1512 100644
--- a/src/com/android/phone/NetworkSelectListPreference.java
+++ b/src/com/android/phone/NetworkSelectListPreference.java
@@ -19,7 +19,6 @@
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
-import android.metrics.LogMaker;
import android.os.AsyncResult;
import android.os.Handler;
import android.os.Message;
@@ -90,7 +89,6 @@
@Override
protected void onClick() {
- sendMetricsEvent(null);
// Start the one-time network scan via {@link Phone#getAvailableNetworks()}.
// {@link NetworkQueryService will return a {@link onResults()} callback first with a list
// of CellInfo, and then will return a {@link onComplete} indicating the scan completed.
@@ -200,7 +198,6 @@
@Override
protected void onDialogClosed(boolean positiveResult) {
super.onDialogClosed(positiveResult);
-
// If dismissed, we query NetworkSelectMode and update states of AutoSelect button.
if (!positiveResult) {
mNetworkOperators.getNetworkSelectionMode();
@@ -317,8 +314,7 @@
// connected after this activity is moved to background.
loge("Fail to dismiss network load list dialog " + e);
}
-
- setEnabled(true);
+ mNetworkOperators.getNetworkSelectionMode();
if (mCellInfoList != null) {
// create a preference for each item in the list.
// just use the operator name instead of the mildly
@@ -393,7 +389,8 @@
mCellInfo = mCellInfoList.get(operatorIndex);
if (DBG) logd("selected network: " + mCellInfo.toString());
- sendMetricsEvent(getNetworkTitle(mCellInfo));
+ MetricsLogger.action(getContext(),
+ MetricsEvent.ACTION_MOBILE_NETWORK_MANUAL_SELECT_NETWORK);
Message msg = mHandler.obtainMessage(EVENT_NETWORK_SELECTION_DONE);
Phone phone = PhoneFactory.getPhone(mPhoneId);
@@ -554,21 +551,6 @@
};
}
- private void sendMetricsEvent(String network) {
- final LogMaker logMaker =
- new LogMaker(MetricsEvent.ACTION_MOBILE_NETWORK_MANUAL_SELECT_NETWORK)
- .setType(MetricsEvent.TYPE_ACTION);
-
- if (network != null) {
- // Since operator list is loaded dynamically from modem, we cannot know which network
- // user chooses if we only record integer index of newValue. So a new tag and a string
- // value (network) is added in this MetricsEvent.
- logMaker.addTaggedData(MetricsEvent.FIELD_MOBILE_NETWORK, network);
- }
-
- MetricsLogger.action(logMaker);
- }
-
private void logd(String msg) {
Log.d(LOG_TAG, "[NetworksList] " + msg);
}
@@ -576,4 +558,4 @@
private void loge(String msg) {
Log.e(LOG_TAG, "[NetworksList] " + msg);
}
-}
\ No newline at end of file
+}
diff --git a/src/com/android/phone/NetworkSelectSetting.java b/src/com/android/phone/NetworkSelectSetting.java
index ff918e2..efa8684 100644
--- a/src/com/android/phone/NetworkSelectSetting.java
+++ b/src/com/android/phone/NetworkSelectSetting.java
@@ -21,7 +21,6 @@
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
-import android.metrics.LogMaker;
import android.os.AsyncResult;
import android.os.Bundle;
import android.os.Handler;
@@ -45,7 +44,7 @@
import android.view.ViewGroup;
import com.android.internal.logging.MetricsLogger;
-import com.android.internal.logging.nano.MetricsProto;
+import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.internal.telephony.OperatorInfo;
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneFactory;
@@ -184,17 +183,8 @@
if (DBG) logd("User click a NetworkOperatorPreference: " + cellInfo.toString());
// Send metrics event
- final LogMaker logMaker = new LogMaker(
- MetricsProto.MetricsEvent.ACTION_MOBILE_NETWORK_MANUAL_SELECT_NETWORK)
- .setType(MetricsProto.MetricsEvent.TYPE_ACTION);
- if (CellInfoUtil.getNetworkTitle(cellInfo) != null) {
- // Since operator list is loaded dynamically from modem, we cannot know which
- // network user chooses if we only record integer index of newValue. So a new tag
- // and a string value (network) is added in this MetricsEvent.
- logMaker.addTaggedData(MetricsProto.MetricsEvent.FIELD_MOBILE_NETWORK,
- CellInfoUtil.getNetworkTitle(cellInfo));
- }
- MetricsLogger.action(logMaker);
+ MetricsLogger.action(getContext(),
+ MetricsEvent.ACTION_MOBILE_NETWORK_MANUAL_SELECT_NETWORK);
// Connect to the network
Message msg = mHandler.obtainMessage(EVENT_NETWORK_SELECTION_DONE);
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index 1219185..1666174 100755
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -385,6 +385,11 @@
request = (MainThreadRequest) msg.obj;
int answer_subId = request.subId;
answerRingingCallInternal(answer_subId);
+ request.result = ""; // dummy result for notifying the waiting thread
+ // Wake up the requesting thread
+ synchronized (request) {
+ request.notifyAll();
+ }
break;
case CMD_END_CALL:
diff --git a/src/com/android/services/telephony/ConferenceParticipantConnection.java b/src/com/android/services/telephony/ConferenceParticipantConnection.java
index 19dda54..324d512 100644
--- a/src/com/android/services/telephony/ConferenceParticipantConnection.java
+++ b/src/com/android/services/telephony/ConferenceParticipantConnection.java
@@ -74,6 +74,7 @@
address = getParticipantAddress(participant.getHandle(), countryIso);
}
setAddress(address, presentation);
+ setVideoState(parentConnection.getVideoState());
setCallerDisplayName(participant.getDisplayName(), presentation);
mUserEntity = participant.getHandle();
diff --git a/src/com/android/services/telephony/ImsConference.java b/src/com/android/services/telephony/ImsConference.java
index dd74d28..830027c 100644
--- a/src/com/android/services/telephony/ImsConference.java
+++ b/src/com/android/services/telephony/ImsConference.java
@@ -673,6 +673,7 @@
Log.i(this, "handleConferenceParticipantsUpdate: updateState, participant = %s",
participant);
connection.updateState(participant.getState());
+ connection.setVideoState(parent.getVideoState());
}
}
@@ -685,6 +686,7 @@
newParticipant.getHandle(),
newParticipant.getEndpoint()));
connection.updateState(newParticipant.getState());
+ connection.setVideoState(parent.getVideoState());
}
}
diff --git a/src/com/android/services/telephony/TelephonyConnection.java b/src/com/android/services/telephony/TelephonyConnection.java
index af9e9d5..55a13bb 100644
--- a/src/com/android/services/telephony/TelephonyConnection.java
+++ b/src/com/android/services/telephony/TelephonyConnection.java
@@ -162,15 +162,6 @@
mSsNotification =
(SuppServiceNotification)((AsyncResult) msg.obj).result;
if (mOriginalConnection != null) {
- if (mSsNotification.history != null) {
- Bundle lastForwardedNumber = new Bundle();
- Log.v(TelephonyConnection.this,
- "Updating call history info in extras.");
- lastForwardedNumber.putStringArrayList(
- Connection.EXTRA_LAST_FORWARDED_NUMBER,
- new ArrayList(Arrays.asList(mSsNotification.history)));
- putExtras(lastForwardedNumber);
- }
handleSuppServiceNotification(mSsNotification);
}
}
diff --git a/tests/src/com/android/phone/CdmaOptionsTest.java b/tests/src/com/android/phone/CdmaOptionsTest.java
new file mode 100644
index 0000000..446f2c5
--- /dev/null
+++ b/tests/src/com/android/phone/CdmaOptionsTest.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.phone;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.os.PersistableBundle;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.runner.AndroidJUnit4;
+import android.telephony.CarrierConfigManager;
+
+import com.android.internal.telephony.Phone;
+import com.android.internal.telephony.PhoneConstants;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+@RunWith(AndroidJUnit4.class)
+public class CdmaOptionsTest {
+ @Mock
+ private Phone mMockPhone;
+
+ private CdmaOptions mCdmaOptions;
+ private Context mContext;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mContext = InstrumentationRegistry.getContext();
+ mCdmaOptions = new CdmaOptions(mMockPhone);
+ }
+
+ @Test
+ public void shouldAddApnExpandPreference_doesNotExpandOnGsm() {
+ when(mMockPhone.getPhoneType()).thenReturn(PhoneConstants.PHONE_TYPE_GSM);
+ PersistableBundle bundle = new PersistableBundle();
+ bundle.putBoolean(CarrierConfigManager.KEY_SHOW_APN_SETTING_CDMA_BOOL, true);
+ assertFalse(mCdmaOptions.shouldAddApnExpandPreference(bundle));
+
+ when(mMockPhone.getPhoneType()).thenReturn(PhoneConstants.PHONE_TYPE_CDMA);
+ bundle.putBoolean(CarrierConfigManager.KEY_SHOW_APN_SETTING_CDMA_BOOL, false);
+ assertFalse(mCdmaOptions.shouldAddApnExpandPreference(bundle));
+
+ when(mMockPhone.getPhoneType()).thenReturn(PhoneConstants.PHONE_TYPE_CDMA);
+ bundle.putBoolean(CarrierConfigManager.KEY_SHOW_APN_SETTING_CDMA_BOOL, true);
+ assertTrue(mCdmaOptions.shouldAddApnExpandPreference(bundle));
+ }
+}