Rename PhoneAccountMetadata to PhoneAccount
Change-Id: I4597b14110c1cee7f637ec125b839852ef0f34c4
diff --git a/src/com/android/telecomm/Call.java b/src/com/android/telecomm/Call.java
index 5b5bf09..9cd5d6f 100644
--- a/src/com/android/telecomm/Call.java
+++ b/src/com/android/telecomm/Call.java
@@ -269,21 +269,21 @@
*
* @param handle The handle to dial.
* @param gatewayInfo Gateway information to use for the call.
- * @param account Account information to use for the call.
+ * @param accountHandle Account information to use for the call.
* @param isIncoming True if this is an incoming call.
*/
Call(
ConnectionServiceRepository repository,
Uri handle,
GatewayInfo gatewayInfo,
- PhoneAccountHandle account,
+ PhoneAccountHandle accountHandle,
boolean isIncoming,
boolean isConference) {
mState = isConference ? CallState.ACTIVE : CallState.NEW;
mRepository = repository;
setHandle(handle, CallPropertyPresentation.ALLOWED);
mGatewayInfo = gatewayInfo;
- mPhoneAccountHandle = account;
+ mPhoneAccountHandle = accountHandle;
mIsIncoming = isIncoming;
mIsConference = isConference;
maybeLoadCannedSmsResponses();
@@ -569,7 +569,7 @@
@Override
public void handleCreateConnectionSuccessful(ConnectionRequest request) {
mCreateConnectionProcessor = null;
- mPhoneAccountHandle = request.getAccount();
+ mPhoneAccountHandle = request.getAccountHandle();
if (mIsIncoming) {
// We do not handle incoming calls immediately when they are verified by the connection
diff --git a/src/com/android/telecomm/CallLogManager.java b/src/com/android/telecomm/CallLogManager.java
index cc1ec24..f8cd86f 100644
--- a/src/com/android/telecomm/CallLogManager.java
+++ b/src/com/android/telecomm/CallLogManager.java
@@ -119,12 +119,12 @@
Log.d(TAG, "logNumber set to: %s", Log.pii(logNumber));
final int presentation = getPresentation(call);
- final PhoneAccountHandle account = call.getPhoneAccount();
+ final PhoneAccountHandle accountHandle = call.getPhoneAccount();
// TODO(vt): Once data usage is available, wire it up here.
int callFeatures = getCallFeatures(call.getVideoStateHistory());
- logCall(call.getCallerInfo(), logNumber, presentation, callLogType, callFeatures, account,
- creationTime, age, null);
+ logCall(call.getCallerInfo(), logNumber, presentation, callLogType, callFeatures,
+ accountHandle, creationTime, age, null);
}
/**
diff --git a/src/com/android/telecomm/CreateConnectionProcessor.java b/src/com/android/telecomm/CreateConnectionProcessor.java
index 6a2b796..d0af6f0 100644
--- a/src/com/android/telecomm/CreateConnectionProcessor.java
+++ b/src/com/android/telecomm/CreateConnectionProcessor.java
@@ -35,7 +35,7 @@
private final Call mCall;
private final ConnectionServiceRepository mRepository;
private List<PhoneAccountHandle> mPhoneAccountHandles;
- private Iterator<PhoneAccountHandle> mPhoneAccountIterator;
+ private Iterator<PhoneAccountHandle> mPhoneAccountHandleIterator;
private CreateConnectionResponse mResponse;
private int mLastErrorCode = DisconnectCause.ERROR_UNSPECIFIED;
private String mLastErrorMsg;
@@ -54,7 +54,7 @@
mPhoneAccountHandles.add(mCall.getPhoneAccount());
}
adjustPhoneAccountsForEmergency();
- mPhoneAccountIterator = mPhoneAccountHandles.iterator();
+ mPhoneAccountHandleIterator = mPhoneAccountHandles.iterator();
attemptNextPhoneAccount();
}
@@ -79,15 +79,16 @@
private void attemptNextPhoneAccount() {
Log.v(this, "attemptNextPhoneAccount");
- if (mResponse != null && mPhoneAccountIterator.hasNext()) {
- PhoneAccountHandle account = mPhoneAccountIterator.next();
- Log.i(this, "Trying account %s", account);
- ConnectionServiceWrapper service = mRepository.getService(account.getComponentName());
+ if (mResponse != null && mPhoneAccountHandleIterator.hasNext()) {
+ PhoneAccountHandle accountHandle = mPhoneAccountHandleIterator.next();
+ Log.i(this, "Trying accountHandle %s", accountHandle);
+ ConnectionServiceWrapper service =
+ mRepository.getService(accountHandle.getComponentName());
if (service == null) {
- Log.i(this, "Found no connection service for account %s", account);
+ Log.i(this, "Found no connection service for accountHandle %s", accountHandle);
attemptNextPhoneAccount();
} else {
- mCall.setPhoneAccount(account);
+ mCall.setPhoneAccount(accountHandle);
mCall.setConnectionService(service);
Log.i(this, "Attempting to call from %s", service.getComponentName());
service.createConnection(mCall, new Response(service));
@@ -108,12 +109,13 @@
if (TelephonyUtil.shouldProcessAsEmergency(TelecommApp.getInstance(), mCall.getHandle())) {
Log.i(this, "Emergency number detected");
mPhoneAccountHandles.clear();
- List<PhoneAccountHandle> allAccounts = TelecommApp.getInstance().getPhoneAccountRegistrar()
- .getEnabledPhoneAccounts();
- for (int i = 0; i < allAccounts.size(); i++) {
- if (TelephonyUtil.isPstnComponentName(allAccounts.get(i).getComponentName())) {
- Log.i(this, "Will try PSTN account %s for emergency", allAccounts.get(i));
- mPhoneAccountHandles.add(allAccounts.get(i));
+ List<PhoneAccountHandle> allAccountHandles = TelecommApp.getInstance()
+ .getPhoneAccountRegistrar().getEnabledPhoneAccounts();
+ for (int i = 0; i < allAccountHandles.size(); i++) {
+ if (TelephonyUtil.isPstnComponentName(
+ allAccountHandles.get(i).getComponentName())) {
+ Log.i(this, "Will try PSTN account %s for emergency", allAccountHandles.get(i));
+ mPhoneAccountHandles.add(allAccountHandles.get(i));
}
}
}
diff --git a/src/com/android/telecomm/PhoneAccountPreferencesActivity.java b/src/com/android/telecomm/PhoneAccountPreferencesActivity.java
index e80b413..ae01497 100644
--- a/src/com/android/telecomm/PhoneAccountPreferencesActivity.java
+++ b/src/com/android/telecomm/PhoneAccountPreferencesActivity.java
@@ -63,7 +63,7 @@
for ( ; i < accountHandles.size(); i++) {
entryValues[i] = Integer.toString(i);
entries[i] = mRegistrar
- .getPhoneAccountMetadata(accountHandles.get(i))
+ .getPhoneAccount(accountHandles.get(i))
.getLabel();
if (Objects.equals(currentDefault, accountHandles.get(i))) {
selectedIndex = i;
diff --git a/src/com/android/telecomm/PhoneAccountRegistrar.java b/src/com/android/telecomm/PhoneAccountRegistrar.java
index a739250..7fd000a 100644
--- a/src/com/android/telecomm/PhoneAccountRegistrar.java
+++ b/src/com/android/telecomm/PhoneAccountRegistrar.java
@@ -16,6 +16,7 @@
package com.android.telecomm;
+import android.telecomm.PhoneAccount;
import android.telecomm.PhoneAccountHandle;
import org.json.JSONArray;
import org.json.JSONException;
@@ -27,7 +28,6 @@
import android.content.SharedPreferences;
import android.net.Uri;
-import android.telecomm.PhoneAccountMetadata;
import android.telecomm.TelecommManager;
import java.util.ArrayList;
@@ -67,8 +67,8 @@
s.defaultOutgoingHandle = null;
} else {
boolean found = false;
- for (PhoneAccountMetadata m : s.accounts) {
- if (Objects.equals(accountHandle, m.getAccount())) {
+ for (PhoneAccount m : s.accounts) {
+ if (Objects.equals(accountHandle, m.getAccountHandle())) {
found = true;
break;
}
@@ -91,10 +91,10 @@
return accountHandlesOnly(s);
}
- public PhoneAccountMetadata getPhoneAccountMetadata(PhoneAccountHandle accountHandle) {
+ public PhoneAccount getPhoneAccount(PhoneAccountHandle accountHandle) {
State s = read();
- for (PhoneAccountMetadata m : s.accounts) {
- if (Objects.equals(accountHandle, m.getAccount())) {
+ for (PhoneAccount m : s.accounts) {
+ if (Objects.equals(accountHandle, m.getAccountHandle())) {
return m;
}
}
@@ -103,13 +103,13 @@
// TODO: Should we implement an artificial limit for # of accounts associated with a single
// ComponentName?
- public void registerPhoneAccount(PhoneAccountMetadata metadata) {
+ public void registerPhoneAccount(PhoneAccount metadata) {
State s = read();
s.accounts.add(metadata);
// Search for duplicates and remove any that are found.
for (int i = 0; i < s.accounts.size() - 1; i++) {
- if (Objects.equals(metadata.getAccount(), s.accounts.get(i).getAccount())) {
+ if (Objects.equals(metadata.getAccountHandle(), s.accounts.get(i).getAccountHandle())) {
// replace existing entry.
s.accounts.remove(i);
break;
@@ -123,7 +123,7 @@
State s = read();
for (int i = 0; i < s.accounts.size(); i++) {
- if (Objects.equals(accountHandle, s.accounts.get(i).getAccount())) {
+ if (Objects.equals(accountHandle, s.accounts.get(i).getAccountHandle())) {
s.accounts.remove(i);
break;
}
@@ -140,7 +140,7 @@
for (int i = 0; i < s.accounts.size(); i++) {
if (Objects.equals(
packageName,
- s.accounts.get(i).getAccount().getComponentName().getPackageName())) {
+ s.accounts.get(i).getAccountHandle().getComponentName().getPackageName())) {
s.accounts.remove(i);
}
}
@@ -153,8 +153,8 @@
private void checkDefaultOutgoing(State s) {
// Check that, after an operation that removes accounts, the account set up as the "default
// outgoing" has not been deleted. If it has, then clear out the setting.
- for (PhoneAccountMetadata m : s.accounts) {
- if (Objects.equals(s.defaultOutgoingHandle, m.getAccount())) {
+ for (PhoneAccount m : s.accounts) {
+ if (Objects.equals(s.defaultOutgoingHandle, m.getAccountHandle())) {
return;
}
}
@@ -162,11 +162,11 @@
}
private List<PhoneAccountHandle> accountHandlesOnly(State s) {
- List<PhoneAccountHandle> result = new ArrayList<>();
- for (PhoneAccountMetadata m : s.accounts) {
- result.add(m.getAccount());
+ List<PhoneAccountHandle> accountHandles = new ArrayList<>();
+ for (PhoneAccount m : s.accounts) {
+ accountHandles.add(m.getAccountHandle());
}
- return result;
+ return accountHandles;
}
private State read() {
@@ -216,7 +216,7 @@
private static class State {
public PhoneAccountHandle defaultOutgoingHandle = null;
- public final List<PhoneAccountMetadata> accounts = new ArrayList<>();
+ public final List<PhoneAccount> accounts = new ArrayList<>();
}
//
@@ -240,7 +240,7 @@
json.put(DEFAULT_OUTGOING, sPhoneAccountJson.toJson(o.defaultOutgoingHandle));
}
JSONArray accounts = new JSONArray();
- for (PhoneAccountMetadata m : o.accounts) {
+ for (PhoneAccount m : o.accounts) {
accounts.put(sPhoneAccountMetadataJson.toJson(m));
}
json.put(ACCOUNTS, accounts);
@@ -269,8 +269,8 @@
}
};
- private static final Json<PhoneAccountMetadata> sPhoneAccountMetadataJson =
- new Json<PhoneAccountMetadata>() {
+ private static final Json<PhoneAccount> sPhoneAccountMetadataJson =
+ new Json<PhoneAccount>() {
private static final String ACCOUNT = "account";
private static final String HANDLE = "handle";
private static final String SUBSCRIPTION_NUMBER = "subscription_number";
@@ -281,9 +281,9 @@
private static final String VIDEO_CALLING_SUPPORTED = "video_calling_supported";
@Override
- public JSONObject toJson(PhoneAccountMetadata o) throws JSONException {
+ public JSONObject toJson(PhoneAccount o) throws JSONException {
return new JSONObject()
- .put(ACCOUNT, sPhoneAccountJson.toJson(o.getAccount()))
+ .put(ACCOUNT, sPhoneAccountJson.toJson(o.getAccountHandle()))
.put(HANDLE, o.getHandle().toString())
.put(SUBSCRIPTION_NUMBER, o.getSubscriptionNumber())
.put(CAPABILITIES, o.getCapabilities())
@@ -294,8 +294,8 @@
}
@Override
- public PhoneAccountMetadata fromJson(JSONObject json) throws JSONException {
- return new PhoneAccountMetadata(
+ public PhoneAccount fromJson(JSONObject json) throws JSONException {
+ return new PhoneAccount(
sPhoneAccountJson.fromJson((JSONObject) json.get(ACCOUNT)),
Uri.parse((String) json.get(HANDLE)),
(String) json.get(SUBSCRIPTION_NUMBER),
diff --git a/src/com/android/telecomm/TelecommApp.java b/src/com/android/telecomm/TelecommApp.java
index 3884d08..cf7b8df 100644
--- a/src/com/android/telecomm/TelecommApp.java
+++ b/src/com/android/telecomm/TelecommApp.java
@@ -20,8 +20,8 @@
import android.content.ComponentName;
import android.net.Uri;
import android.os.UserHandle;
+import android.telecomm.PhoneAccount;
import android.telecomm.PhoneAccountHandle;
-import android.telecomm.PhoneAccountMetadata;
/**
* Top-level Application class for Telecomm.
@@ -76,7 +76,7 @@
// TODO: STOPSHIP. We are adding a hacked PhoneAccountHandle to ensure that Wi-Fi calling in
// Hangouts continues to work. This needs to be replaced with proper Wi-Fi calling wiring
// to the appropriate Connection Services.
- PhoneAccountMetadata hangouts = new PhoneAccountMetadata(
+ PhoneAccount hangouts = new PhoneAccount(
new PhoneAccountHandle(
new ComponentName(
"com.google.android.talk",
@@ -84,13 +84,13 @@
"null_id"),
Uri.fromParts("tel", "null_uri", null),
"650-253-0000",
- PhoneAccountMetadata.CAPABILITY_CALL_PROVIDER,
+ PhoneAccount.CAPABILITY_CALL_PROVIDER,
R.drawable.stat_sys_phone_call,
"Wi-Fi calling",
"Wi-Fi calling by Google Hangouts",
false);
mPhoneAccountRegistrar.clearAccounts(
- hangouts.getAccount().getComponentName().getPackageName());
+ hangouts.getAccountHandle().getComponentName().getPackageName());
mPhoneAccountRegistrar.registerPhoneAccount(hangouts);
}
}
diff --git a/src/com/android/telecomm/TelecommServiceImpl.java b/src/com/android/telecomm/TelecommServiceImpl.java
index d413642..3234aee 100644
--- a/src/com/android/telecomm/TelecommServiceImpl.java
+++ b/src/com/android/telecomm/TelecommServiceImpl.java
@@ -27,8 +27,8 @@
import android.os.ServiceManager;
import android.phone.PhoneManager;
import android.telecomm.CallState;
+import android.telecomm.PhoneAccount;
import android.telecomm.PhoneAccountHandle;
-import android.telecomm.PhoneAccountMetadata;
import android.telecomm.TelecommManager;
import android.telephony.TelephonyManager;
@@ -167,34 +167,35 @@
}
@Override
- public PhoneAccountMetadata getPhoneAccountMetadata(PhoneAccountHandle account) {
+ public PhoneAccount getPhoneAccount(PhoneAccountHandle accountHandle) {
try {
- return mPhoneAccountRegistrar.getPhoneAccountMetadata(account);
+ return mPhoneAccountRegistrar.getPhoneAccount(accountHandle);
} catch (Exception e) {
- Log.e(this, e, "getPhoneAccountMetadata %s", account);
+ Log.e(this, e, "getPhoneAccount %s", accountHandle);
throw e;
}
}
@Override
- public void registerPhoneAccount(PhoneAccountMetadata metadata) {
+ public void registerPhoneAccount(PhoneAccount account) {
try {
enforceModifyPermissionOrCallingPackage(
- metadata.getAccount().getComponentName().getPackageName());
- mPhoneAccountRegistrar.registerPhoneAccount(metadata);
+ account.getAccountHandle().getComponentName().getPackageName());
+ mPhoneAccountRegistrar.registerPhoneAccount(account);
} catch (Exception e) {
- Log.e(this, e, "registerPhoneAccount %s", metadata);
+ Log.e(this, e, "registerPhoneAccount %s", account);
throw e;
}
}
@Override
- public void unregisterPhoneAccount(PhoneAccountHandle account) {
+ public void unregisterPhoneAccount(PhoneAccountHandle accountHandle) {
try {
- enforceModifyPermissionOrCallingPackage(account.getComponentName().getPackageName());
- mPhoneAccountRegistrar.unregisterPhoneAccount(account);
+ enforceModifyPermissionOrCallingPackage(
+ accountHandle.getComponentName().getPackageName());
+ mPhoneAccountRegistrar.unregisterPhoneAccount(accountHandle);
} catch (Exception e) {
- Log.e(this, e, "unregisterPhoneAccount %s", account);
+ Log.e(this, e, "unregisterPhoneAccount %s", accountHandle);
throw e;
}
}