Fix test bitrot breakages
Change-Id: I39cbcd078c07fd48ca9b00abce21871ef273b19d
diff --git a/src/com/android/server/telecom/PhoneAccountRegistrar.java b/src/com/android/server/telecom/PhoneAccountRegistrar.java
index 3531df6..1ef869b 100644
--- a/src/com/android/server/telecom/PhoneAccountRegistrar.java
+++ b/src/com/android/server/telecom/PhoneAccountRegistrar.java
@@ -1235,7 +1235,7 @@
// TODO: Need to set tint.
}
- builder.build();
+ return builder.build();
}
return null;
}
diff --git a/tests/src/com/android/server/telecom/tests/ComponentContextFixture.java b/tests/src/com/android/server/telecom/tests/ComponentContextFixture.java
index 573ef4a..bf7834e 100644
--- a/tests/src/com/android/server/telecom/tests/ComponentContextFixture.java
+++ b/tests/src/com/android/server/telecom/tests/ComponentContextFixture.java
@@ -52,6 +52,7 @@
import android.telecom.ConnectionService;
import android.telecom.InCallService;
import android.telecom.PhoneAccount;
+import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.test.mock.MockContext;
@@ -147,6 +148,8 @@
return mNotificationManager;
case Context.USER_SERVICE:
return mUserManager;
+ case Context.TELEPHONY_SUBSCRIPTION_SERVICE:
+ return mSubscriptionManager;
default:
return null;
}
@@ -222,6 +225,12 @@
}
@Override
+ public void sendOrderedBroadcastAsUser(Intent intent, UserHandle user,
+ String receiverPermission, int appOp, BroadcastReceiver resultReceiver,
+ Handler scheduler, int initialCode, String initialData, Bundle initialExtras) {
+ }
+
+ @Override
public Context createPackageContextAsUser(String packageName, int flags, UserHandle user)
throws PackageManager.NameNotFoundException {
return this;
@@ -256,6 +265,7 @@
private final AppOpsManager mAppOpsManager = mock(AppOpsManager.class);
private final NotificationManager mNotificationManager = mock(NotificationManager.class);
private final UserManager mUserManager = mock(UserManager.class);
+ private final SubscriptionManager mSubscriptionManager = mock(SubscriptionManager.class);
private final Resources mResources = mock(Resources.class);
private final Configuration mResourceConfiguration = new Configuration();
diff --git a/tests/src/com/android/server/telecom/tests/PhoneAccountRegistrarTest.java b/tests/src/com/android/server/telecom/tests/PhoneAccountRegistrarTest.java
index c55e89c..aa4a8e6 100644
--- a/tests/src/com/android/server/telecom/tests/PhoneAccountRegistrarTest.java
+++ b/tests/src/com/android/server/telecom/tests/PhoneAccountRegistrarTest.java
@@ -16,7 +16,6 @@
package com.android.server.telecom.tests;
-import android.annotation.TargetApi;
import android.os.Binder;
import com.android.internal.telecom.IConnectionService;
@@ -30,7 +29,6 @@
import android.content.ComponentName;
import android.content.Context;
-import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.Icon;
import android.net.Uri;
@@ -96,6 +94,7 @@
.build();
PhoneAccount result = roundTripXml(this, input, PhoneAccountRegistrar.sPhoneAccountXml,
mContext);
+
assertPhoneAccountEquals(input, result);
}
@@ -107,6 +106,11 @@
assertStateEquals(input, result);
}
+ private void registerAndEnableAccount(PhoneAccount account) {
+ mRegistrar.registerPhoneAccount(account);
+ mRegistrar.enablePhoneAccount(account.getAccountHandle(), true);
+ }
+
public void testAccounts() throws Exception {
int i = 0;
@@ -114,19 +118,19 @@
makeQuickConnectionServiceComponentName(),
Mockito.mock(IConnectionService.class));
- mRegistrar.registerPhoneAccount(makeQuickAccountBuilder("id" + i, i++)
+ registerAndEnableAccount(makeQuickAccountBuilder("id" + i, i++)
.setCapabilities(PhoneAccount.CAPABILITY_CONNECTION_MANAGER
| PhoneAccount.CAPABILITY_CALL_PROVIDER)
.build());
- mRegistrar.registerPhoneAccount(makeQuickAccountBuilder("id" + i, i++)
+ registerAndEnableAccount(makeQuickAccountBuilder("id" + i, i++)
.setCapabilities(PhoneAccount.CAPABILITY_CONNECTION_MANAGER
| PhoneAccount.CAPABILITY_CALL_PROVIDER)
.build());
- mRegistrar.registerPhoneAccount(makeQuickAccountBuilder("id" + i, i++)
+ registerAndEnableAccount(makeQuickAccountBuilder("id" + i, i++)
.setCapabilities(PhoneAccount.CAPABILITY_CONNECTION_MANAGER
| PhoneAccount.CAPABILITY_CALL_PROVIDER)
.build());
- mRegistrar.registerPhoneAccount(makeQuickAccountBuilder("id" + i, i++)
+ registerAndEnableAccount(makeQuickAccountBuilder("id" + i, i++)
.setCapabilities(PhoneAccount.CAPABILITY_CONNECTION_MANAGER)
.build());
@@ -146,7 +150,7 @@
.setCapabilities(PhoneAccount.CAPABILITY_CALL_PROVIDER
| PhoneAccount.CAPABILITY_CONNECTION_MANAGER)
.build();
- mRegistrar.registerPhoneAccount(simManagerAccount);
+ registerAndEnableAccount(simManagerAccount);
assertNull(mRegistrar.getSimCallManager());
// Test the basic case
@@ -158,7 +162,7 @@
assertNull(mRegistrar.getSimCallManager());
// Re-registering it makes the setting come back
- mRegistrar.registerPhoneAccount(simManagerAccount);
+ registerAndEnableAccount(simManagerAccount);
assertEquals(simManager, mRegistrar.getSimCallManager());
// Make sure that the manager has CAPABILITY_CONNECTION_MANAGER
@@ -185,7 +189,7 @@
// Register one tel: account
PhoneAccountHandle telAccount = makeQuickAccountHandle("tel_acct");
- mRegistrar.registerPhoneAccount(new PhoneAccount.Builder(telAccount, "tel_acct")
+ registerAndEnableAccount(new PhoneAccount.Builder(telAccount, "tel_acct")
.setCapabilities(PhoneAccount.CAPABILITY_CALL_PROVIDER)
.addSupportedUriScheme(PhoneAccount.SCHEME_TEL)
.build());
@@ -195,7 +199,7 @@
// Add a SIP account, make sure tel: doesn't change
PhoneAccountHandle sipAccount = makeQuickAccountHandle("sip_acct");
- mRegistrar.registerPhoneAccount(new PhoneAccount.Builder(sipAccount, "sip_acct")
+ registerAndEnableAccount(new PhoneAccount.Builder(sipAccount, "sip_acct")
.setCapabilities(PhoneAccount.CAPABILITY_CALL_PROVIDER)
.addSupportedUriScheme(PhoneAccount.SCHEME_SIP)
.build());
@@ -206,7 +210,7 @@
// Add a connection manager, make sure tel: doesn't change
PhoneAccountHandle connectionManager = makeQuickAccountHandle("mgr_acct");
- mRegistrar.registerPhoneAccount(new PhoneAccount.Builder(connectionManager, "mgr_acct")
+ registerAndEnableAccount(new PhoneAccount.Builder(connectionManager, "mgr_acct")
.setCapabilities(PhoneAccount.CAPABILITY_CONNECTION_MANAGER)
.addSupportedUriScheme(PhoneAccount.SCHEME_TEL)
.build());
@@ -276,6 +280,7 @@
.setIcon(Icon.createWithResource(
"com.android.server.telecom.tests", R.drawable.stat_sys_phone_call))
.setShortDescription("desc" + idx)
+ .setIsEnabled(true)
.build();
}
@@ -311,7 +316,7 @@
data = baos.toByteArray();
}
- Log.d(self, "====== XML data ======\n%s", new String(data));
+ Log.i(self, "====== XML data ======\n%s", new String(data));
T result = null;
{
@@ -321,7 +326,7 @@
result = xml.readFromXml(parser, MAX_VERSION, context);
}
- Log.d(self, "result = " + result);
+ Log.i(self, "result = " + result);
return result;
}
@@ -338,17 +343,31 @@
}
}
+ private static void assertIconEquals(Icon a, Icon b) {
+ if (a != b) {
+ if (a != null && b != null) {
+ assertEquals(a.toString(), b.toString());
+ } else {
+ fail("Icons not equal: " + a + ", " + b);
+ }
+ }
+ }
+
private static void assertPhoneAccountEquals(PhoneAccount a, PhoneAccount b) {
if (a != b) {
- assertPhoneAccountHandleEquals(a.getAccountHandle(), b.getAccountHandle());
- assertEquals(a.getAddress(), b.getAddress());
- assertEquals(a.getSubscriptionAddress(), b.getSubscriptionAddress());
- assertEquals(a.getCapabilities(), b.getCapabilities());
- assertEquals(a.getIcon().toString(), b.getIcon().toString());
- assertEquals(a.getHighlightColor(), b.getHighlightColor());
- assertEquals(a.getLabel(), b.getLabel());
- assertEquals(a.getShortDescription(), b.getShortDescription());
- assertEquals(a.getSupportedUriSchemes(), b.getSupportedUriSchemes());
+ if (a != null && b != null) {
+ assertPhoneAccountHandleEquals(a.getAccountHandle(), b.getAccountHandle());
+ assertEquals(a.getAddress(), b.getAddress());
+ assertEquals(a.getSubscriptionAddress(), b.getSubscriptionAddress());
+ assertEquals(a.getCapabilities(), b.getCapabilities());
+ assertIconEquals(a.getIcon(), b.getIcon());
+ assertEquals(a.getHighlightColor(), b.getHighlightColor());
+ assertEquals(a.getLabel(), b.getLabel());
+ assertEquals(a.getShortDescription(), b.getShortDescription());
+ assertEquals(a.getSupportedUriSchemes(), b.getSupportedUriSchemes());
+ } else {
+ fail("Phone accounts not equal: " + a + ", " + b);
+ }
}
}
diff --git a/tests/src/com/android/server/telecom/tests/TelecomSystemTest.java b/tests/src/com/android/server/telecom/tests/TelecomSystemTest.java
index b2ee6a2..ad48370 100644
--- a/tests/src/com/android/server/telecom/tests/TelecomSystemTest.java
+++ b/tests/src/com/android/server/telecom/tests/TelecomSystemTest.java
@@ -34,6 +34,7 @@
import android.os.Bundle;
import android.os.Handler;
import android.os.UserHandle;
+import android.telecom.Call;
import android.telecom.ConnectionRequest;
import android.telecom.DisconnectCause;
import android.telecom.ParcelableCall;
@@ -43,10 +44,6 @@
import android.telephony.TelephonyManager;
import com.android.internal.telecom.IInCallAdapter;
-import com.android.internal.telephony.CallerInfo;
-import com.android.internal.telephony.CallerInfoAsyncQuery;
-import com.android.server.telecom.CallerInfoAsyncQueryFactory;
-import com.android.server.telecom.CallState;
import com.android.server.telecom.CallsManager;
import com.android.server.telecom.HeadsetMediaButton;
import com.android.server.telecom.HeadsetMediaButtonFactory;
@@ -216,6 +213,9 @@
mTelecomSystem.getPhoneAccountRegistrar().registerPhoneAccount(mPhoneAccountA0);
mTelecomSystem.getPhoneAccountRegistrar().registerPhoneAccount(mPhoneAccountA1);
mTelecomSystem.getPhoneAccountRegistrar().registerPhoneAccount(mPhoneAccountB0);
+
+ mTelecomSystem.getPhoneAccountRegistrar().setUserSelectedOutgoingPhoneAccount(
+ mPhoneAccountA0.getAccountHandle());
}
private void setupInCallServices() throws Exception {
@@ -263,6 +263,7 @@
newOutgoingCallIntent.capture(),
any(UserHandle.class),
anyString(),
+ anyInt(),
newOutgoingCallReceiver.capture(),
any(Handler.class),
anyInt(),
@@ -394,20 +395,21 @@
assertEquals(1, mInCallServiceFixtureX.mCallById.size());
String callId = mInCallServiceFixtureX.mLatestCallId;
- assertEquals(CallState.DIALING, mInCallServiceFixtureX.getCall(callId).getState());
- assertEquals(CallState.DIALING, mInCallServiceFixtureY.getCall(callId).getState());
+ assertEquals(Call.STATE_DIALING, mInCallServiceFixtureX.getCall(callId).getState());
+ assertEquals(Call.STATE_DIALING, mInCallServiceFixtureY.getCall(callId).getState());
mConnectionServiceFixtureA.sendSetActive(connectionId);
- assertEquals(CallState.ACTIVE, mInCallServiceFixtureX.getCall(callId).getState());
- assertEquals(CallState.ACTIVE, mInCallServiceFixtureY.getCall(callId).getState());
+
+ assertEquals(Call.STATE_ACTIVE, mInCallServiceFixtureX.getCall(callId).getState());
+ assertEquals(Call.STATE_ACTIVE, mInCallServiceFixtureY.getCall(callId).getState());
mInCallServiceFixtureX.mInCallAdapter.disconnectCall(callId);;
- assertEquals(CallState.ACTIVE, mInCallServiceFixtureX.getCall(callId).getState());
- assertEquals(CallState.ACTIVE, mInCallServiceFixtureY.getCall(callId).getState());
+ assertEquals(Call.STATE_ACTIVE, mInCallServiceFixtureX.getCall(callId).getState());
+ assertEquals(Call.STATE_ACTIVE, mInCallServiceFixtureY.getCall(callId).getState());
mConnectionServiceFixtureA.sendSetDisconnected(connectionId, DisconnectCause.LOCAL);
- assertEquals(CallState.DISCONNECTED, mInCallServiceFixtureX.getCall(callId).getState());
- assertEquals(CallState.DISCONNECTED, mInCallServiceFixtureY.getCall(callId).getState());
+ assertEquals(Call.STATE_DISCONNECTED, mInCallServiceFixtureX.getCall(callId).getState());
+ assertEquals(Call.STATE_DISCONNECTED, mInCallServiceFixtureY.getCall(callId).getState());
}
// A simple incoming call, similar in scope to the previous test
@@ -423,20 +425,20 @@
assertEquals(1, mInCallServiceFixtureX.mCallById.size());
String callId = mInCallServiceFixtureX.mLatestCallId;
- assertEquals(CallState.RINGING, mInCallServiceFixtureX.getCall(callId).getState());
- assertEquals(CallState.RINGING, mInCallServiceFixtureY.getCall(callId).getState());
+ assertEquals(Call.STATE_RINGING, mInCallServiceFixtureX.getCall(callId).getState());
+ assertEquals(Call.STATE_RINGING, mInCallServiceFixtureY.getCall(callId).getState());
mConnectionServiceFixtureA.sendSetActive(connectionId);
- assertEquals(CallState.ACTIVE, mInCallServiceFixtureX.getCall(callId).getState());
- assertEquals(CallState.ACTIVE, mInCallServiceFixtureY.getCall(callId).getState());
+ assertEquals(Call.STATE_ACTIVE, mInCallServiceFixtureX.getCall(callId).getState());
+ assertEquals(Call.STATE_ACTIVE, mInCallServiceFixtureY.getCall(callId).getState());
mInCallServiceFixtureX.mInCallAdapter.disconnectCall(callId);;
- assertEquals(CallState.ACTIVE, mInCallServiceFixtureX.getCall(callId).getState());
- assertEquals(CallState.ACTIVE, mInCallServiceFixtureY.getCall(callId).getState());
+ assertEquals(Call.STATE_ACTIVE, mInCallServiceFixtureX.getCall(callId).getState());
+ assertEquals(Call.STATE_ACTIVE, mInCallServiceFixtureY.getCall(callId).getState());
mConnectionServiceFixtureA.sendSetDisconnected(connectionId, DisconnectCause.LOCAL);
- assertEquals(CallState.DISCONNECTED, mInCallServiceFixtureX.getCall(callId).getState());
- assertEquals(CallState.DISCONNECTED, mInCallServiceFixtureY.getCall(callId).getState());
+ assertEquals(Call.STATE_DISCONNECTED, mInCallServiceFixtureX.getCall(callId).getState());
+ assertEquals(Call.STATE_DISCONNECTED, mInCallServiceFixtureY.getCall(callId).getState());
}
public void testDeadlockOnOutgoingCall() throws Exception {