aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2017-09-22 23:08:28 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2017-09-22 23:08:28 +0000
commit02d5c148af58bc4e498ddedad971ceb49eb3f19f (patch)
tree8c9c7ad926f79228cb3984edff37e2c3abc45428
parentb00aaf7576d6b52d155397ff2f8cb767fdf89d1b (diff)
parent559fb631da32075b1f7b60c81dad66cca14b2e4e (diff)
downloadtelephony-oreo-dr3-release.tar.gz
Merge cherrypicks of [2947060, 2947061, 2947062, 2947063, 2946091, 2946092, 2946093, 2946094, 2947008, 2947209, 2947064, 2947065, 2947066, 2947067, 2947068, 2947229, 2947230, 2947231, 2947232, 2947233, 2947234, 2947249, 2945563, 2945564, 2945565, 2945566, 2946975, 2946526, 2945567, 2946527, 2947100, 2947101, 2947102, 2946528, 2947210, 2945568, 2947105, 2947250] into oc-dr3-releaseandroid-8.0.0_r34android-8.0.0_r27oreo-dr3-release
Change-Id: Id5c1103d1bf7426bfc39824fe4f5aba81ddb656c
-rw-r--r--src/java/com/android/internal/telephony/GsmCdmaPhone.java1
-rw-r--r--src/java/com/android/internal/telephony/Phone.java2
-rw-r--r--src/java/com/android/internal/telephony/imsphone/ImsPhoneCallTracker.java33
-rw-r--r--tests/telephonytests/src/com/android/internal/telephony/imsphone/ImsPhoneCallTrackerTest.java32
4 files changed, 66 insertions, 2 deletions
diff --git a/src/java/com/android/internal/telephony/GsmCdmaPhone.java b/src/java/com/android/internal/telephony/GsmCdmaPhone.java
index d608c70dfb..4251567302 100644
--- a/src/java/com/android/internal/telephony/GsmCdmaPhone.java
+++ b/src/java/com/android/internal/telephony/GsmCdmaPhone.java
@@ -2060,6 +2060,7 @@ public class GsmCdmaPhone extends Phone {
private void syncClirSetting() {
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getContext());
int clirSetting = sp.getInt(CLIR_KEY + getPhoneId(), -1);
+ Rlog.i(LOG_TAG, "syncClirSetting: " + CLIR_KEY + getPhoneId() + "=" + clirSetting);
if (clirSetting >= 0) {
mCi.setCLIR(clirSetting, null);
}
diff --git a/src/java/com/android/internal/telephony/Phone.java b/src/java/com/android/internal/telephony/Phone.java
index 11c8e610a8..0238793b6b 100644
--- a/src/java/com/android/internal/telephony/Phone.java
+++ b/src/java/com/android/internal/telephony/Phone.java
@@ -1362,6 +1362,8 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getContext());
SharedPreferences.Editor editor = sp.edit();
editor.putInt(CLIR_KEY + getPhoneId(), commandInterfaceCLIRMode);
+ Rlog.i(LOG_TAG, "saveClirSetting: " + CLIR_KEY + getPhoneId() + "=" +
+ commandInterfaceCLIRMode);
// Commit and log the result.
if (!editor.commit()) {
diff --git a/src/java/com/android/internal/telephony/imsphone/ImsPhoneCallTracker.java b/src/java/com/android/internal/telephony/imsphone/ImsPhoneCallTracker.java
index 8e3773c4f4..165350d7ae 100644
--- a/src/java/com/android/internal/telephony/imsphone/ImsPhoneCallTracker.java
+++ b/src/java/com/android/internal/telephony/imsphone/ImsPhoneCallTracker.java
@@ -113,6 +113,10 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
void onPhoneStateChanged(PhoneConstants.State oldState, PhoneConstants.State newState);
}
+ public interface SharedPreferenceProxy {
+ SharedPreferences getDefaultSharedPreferences(Context context);
+ }
+
private static final boolean DBG = true;
// When true, dumps the state of ImsPhoneCallTracker after changes to foreground and background
@@ -598,6 +602,13 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
*/
private boolean mShouldUpdateImsConfigOnDisconnect = false;
+ /**
+ * Default implementation for retrieving shared preferences; uses the actual PreferencesManager.
+ */
+ private SharedPreferenceProxy mSharedPreferenceProxy = (Context context) -> {
+ return PreferenceManager.getDefaultSharedPreferences(context);
+ };
+
// Callback fires when ImsManager MMTel Feature changes state
private ImsServiceProxy.INotifyStatusChanged mNotifyStatusChangedCallback = () -> {
try {
@@ -678,6 +689,16 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
sendEmptyMessage(EVENT_GET_IMS_SERVICE);
}
+ /**
+ * Test-only method used to mock out access to the shared preferences through the
+ * {@link PreferenceManager}.
+ * @param sharedPreferenceProxy
+ */
+ @VisibleForTesting
+ public void setSharedPreferenceProxy(SharedPreferenceProxy sharedPreferenceProxy) {
+ mSharedPreferenceProxy = sharedPreferenceProxy;
+ }
+
private int getPackageUid(Context context, String pkg) {
if (pkg == null) {
return NetworkStats.UID_ALL;
@@ -796,8 +817,16 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
public Connection dial(String dialString, int videoState, Bundle intentExtras) throws
CallStateException {
- SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(mPhone.getContext());
- int oirMode = sp.getInt(Phone.CLIR_KEY, CommandsInterface.CLIR_DEFAULT);
+ int oirMode;
+ if (mSharedPreferenceProxy != null && mPhone.getDefaultPhone() != null) {
+ SharedPreferences sp = mSharedPreferenceProxy.getDefaultSharedPreferences(
+ mPhone.getContext());
+ oirMode = sp.getInt(Phone.CLIR_KEY + mPhone.getDefaultPhone().getPhoneId(),
+ CommandsInterface.CLIR_DEFAULT);
+ } else {
+ loge("dial; could not get default CLIR mode.");
+ oirMode = CommandsInterface.CLIR_DEFAULT;
+ }
return dial(dialString, oirMode, videoState, intentExtras);
}
diff --git a/tests/telephonytests/src/com/android/internal/telephony/imsphone/ImsPhoneCallTrackerTest.java b/tests/telephonytests/src/com/android/internal/telephony/imsphone/ImsPhoneCallTrackerTest.java
index db3f29fe2f..713467790e 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/imsphone/ImsPhoneCallTrackerTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/imsphone/ImsPhoneCallTrackerTest.java
@@ -37,11 +37,13 @@ import static org.mockito.Mockito.verify;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
+import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Message;
import android.support.test.filters.FlakyTest;
+import android.telecom.VideoProfile;
import android.telephony.PhoneNumberUtils;
import android.telephony.ims.feature.ImsFeature;
import android.test.suitebuilder.annotation.SmallTest;
@@ -56,6 +58,8 @@ import com.android.ims.ImsReasonInfo;
import com.android.ims.ImsServiceClass;
import com.android.ims.internal.ImsCallSession;
import com.android.internal.telephony.Call;
+import com.android.internal.telephony.CallStateException;
+import com.android.internal.telephony.CommandsInterface;
import com.android.internal.telephony.Connection;
import com.android.internal.telephony.PhoneConstants;
import com.android.internal.telephony.TelephonyTest;
@@ -65,6 +69,7 @@ import org.junit.Assert;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
+import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
@@ -80,6 +85,8 @@ public class ImsPhoneCallTrackerTest extends TelephonyTest {
private int mServiceId;
@Mock
private ImsCallSession mImsCallSession;
+ @Mock
+ private SharedPreferences mSharedPreferences;
private Handler mCTHander;
private class ImsCTHandlerThread extends HandlerThread {
@@ -347,6 +354,31 @@ public class ImsPhoneCallTrackerTest extends TelephonyTest {
assertEquals(Call.State.HOLDING, mCTUT.mBackgroundCall.getState());
}
+ /**
+ * Ensures that the dial method will perform a shared preferences lookup using the correct
+ * shared preference key to determine the CLIR mode.
+ */
+ @Test
+ @SmallTest
+ public void testDialClirMode() {
+ mCTUT.setSharedPreferenceProxy((Context context) -> {
+ return mSharedPreferences;
+ });
+ ArgumentCaptor<String> mStringCaptor = ArgumentCaptor.forClass(String.class);
+ doReturn(CommandsInterface.CLIR_INVOCATION).when(mSharedPreferences).getInt(
+ mStringCaptor.capture(), anyInt());
+
+ try {
+ mCTUT.dial("+17005554141", VideoProfile.STATE_AUDIO_ONLY, null);
+ } catch (CallStateException cse) {
+ cse.printStackTrace();
+ Assert.fail("unexpected exception thrown" + cse.getMessage());
+ }
+
+ // Ensure that the correct key was queried from the shared prefs.
+ assertEquals("clir_key0", mStringCaptor.getValue());
+ }
+
@FlakyTest
@Test
@SmallTest