Rename Telecomm "Subscription" to "Account" (6/7)
Change-Id: I9458216c06e7bbb68ef27e8b084f18e6c7f2fc8b
diff --git a/src/com/android/telecomm/Call.java b/src/com/android/telecomm/Call.java
index ddd4b1d..0771df9 100644
--- a/src/com/android/telecomm/Call.java
+++ b/src/com/android/telecomm/Call.java
@@ -27,8 +27,8 @@
import android.telecomm.CallServiceDescriptor;
import android.telecomm.CallState;
import android.telecomm.GatewayInfo;
+import android.telecomm.PhoneAccount;
import android.telecomm.Response;
-import android.telecomm.Subscription;
import android.telecomm.TelecommConstants;
import android.telephony.DisconnectCause;
import android.telephony.PhoneNumberUtils;
@@ -117,7 +117,7 @@
* service. */
private final GatewayInfo mGatewayInfo;
- private final Subscription mSubscription;
+ private final PhoneAccount mAccount;
private final Handler mHandler = new Handler();
@@ -226,15 +226,15 @@
*
* @param handle The handle to dial.
* @param gatewayInfo Gateway information to use for the call.
- * @param subscription Subscription information to use for the call.
+ * @param account Account information to use for the call.
* @param isIncoming True if this is an incoming call.
*/
- Call(Uri handle, GatewayInfo gatewayInfo, Subscription subscription,
+ Call(Uri handle, GatewayInfo gatewayInfo, PhoneAccount account,
boolean isIncoming, boolean isConference) {
mState = isConference ? CallState.ACTIVE : CallState.NEW;
setHandle(handle);
mGatewayInfo = gatewayInfo;
- mSubscription = subscription;
+ mAccount = account;
mIsIncoming = isIncoming;
mIsConference = isConference;
maybeLoadCannedSmsResponses();
@@ -360,8 +360,8 @@
return mGatewayInfo;
}
- Subscription getSubscription() {
- return mSubscription;
+ PhoneAccount getAccount() {
+ return mAccount;
}
boolean isIncoming() {
@@ -728,7 +728,7 @@
mGatewayInfo.getOriginalHandle());
}
- return new CallInfo(callId, mState, mHandle, mGatewayInfo, mSubscription,
+ return new CallInfo(callId, mState, mHandle, mGatewayInfo, mAccount,
extras, descriptor);
}
diff --git a/src/com/android/telecomm/CallLogManager.java b/src/com/android/telecomm/CallLogManager.java
index 53d2072..906ecd4 100644
--- a/src/com/android/telecomm/CallLogManager.java
+++ b/src/com/android/telecomm/CallLogManager.java
@@ -21,14 +21,11 @@
import android.os.AsyncTask;
import android.provider.CallLog.Calls;
import android.telecomm.CallState;
-import android.telecomm.Subscription;
+import android.telecomm.PhoneAccount;
import android.telephony.PhoneNumberUtils;
import com.android.internal.telephony.PhoneConstants;
-import java.io.UnsupportedEncodingException;
-import java.net.URLDecoder;
-
/**
* Helper class that provides functionality to write information about calls and their associated
* caller details to the call log. All logging activity will be performed asynchronously in a
@@ -49,14 +46,14 @@
* @param durationInMillis Duration of the call (milliseconds).
*/
public AddCallArgs(Context context, ContactInfo contactInfo, String number,
- int presentation, int callType, Subscription subscription,
+ int presentation, int callType, PhoneAccount account,
long creationDate, long durationInMillis) {
this.context = context;
this.contactInfo = contactInfo;
this.number = number;
this.presentation = presentation;
this.callType = callType;
- this.subscription = subscription;
+ this.mAccount = account;
this.timestamp = creationDate;
this.durationInSec = (int)(durationInMillis / 1000);
}
@@ -67,7 +64,7 @@
public final String number;
public final int presentation;
public final int callType;
- public final Subscription subscription;
+ public final PhoneAccount mAccount;
public final long timestamp;
public final int durationInSec;
}
@@ -115,9 +112,9 @@
Log.d(TAG, "logNumber set to: %s", Log.pii(logNumber));
final int presentation = getPresentation(call, contactInfo);
- final Subscription subscription = call.getSubscription();
+ final PhoneAccount account = call.getAccount();
- logCall(contactInfo, logNumber, presentation, callLogType, subscription, creationTime, age);
+ logCall(contactInfo, logNumber, presentation, callLogType, account, creationTime, age);
}
/**
@@ -135,7 +132,7 @@
String number,
int presentation,
int callType,
- Subscription subscription,
+ PhoneAccount account,
long start,
long duration) {
boolean isEmergencyNumber = PhoneNumberUtils.isLocalEmergencyNumber(mContext, number);
@@ -154,7 +151,7 @@
+ Log.pii(number) + "," + presentation + ", " + callType
+ ", " + start + ", " + duration);
AddCallArgs args = new AddCallArgs(mContext, contactInfo, number, presentation,
- callType, subscription, start, duration);
+ callType, account, start, duration);
logCallAsync(args);
} else {
Log.d(TAG, "Not adding emergency call to call log.");
@@ -226,7 +223,7 @@
try {
// May block.
result[i] = Calls.addCall(null, c.context, c.number, c.presentation,
- c.callType, c.subscription, c.timestamp, c.durationInSec);
+ c.callType, c.mAccount, c.timestamp, c.durationInSec);
} catch (Exception e) {
// This is very rare but may happen in legitimate cases.
// E.g. If the phone is encrypted and thus write request fails, it may cause
diff --git a/src/com/android/telecomm/CallsManager.java b/src/com/android/telecomm/CallsManager.java
index cd5cb2a..664fc55 100644
--- a/src/com/android/telecomm/CallsManager.java
+++ b/src/com/android/telecomm/CallsManager.java
@@ -23,7 +23,7 @@
import android.telecomm.CallServiceDescriptor;
import android.telecomm.CallState;
import android.telecomm.GatewayInfo;
-import android.telecomm.Subscription;
+import android.telecomm.PhoneAccount;
import android.telephony.DisconnectCause;
import com.google.common.base.Preconditions;
@@ -304,7 +304,7 @@
* @param speakerphoneOn Whether or not to turn the speakerphone on once the call connects.
*/
void placeOutgoingCall(Uri handle, ContactInfo contactInfo, GatewayInfo gatewayInfo,
- Subscription subscription, boolean speakerphoneOn) {
+ PhoneAccount account, boolean speakerphoneOn) {
final Uri uriHandle = (gatewayInfo == null) ? handle : gatewayInfo.getGatewayHandle();
if (gatewayInfo == null) {
@@ -315,7 +315,7 @@
}
Call call = new Call(
- uriHandle, gatewayInfo, subscription,
+ uriHandle, gatewayInfo, account,
false /* isIncoming */, false /* isConference */);
call.setStartWithSpeakerphoneOn(speakerphoneOn);
@@ -497,7 +497,7 @@
// service.
Call tempCall = new Call(
originalCall.getHandoffHandle(), originalCall.getGatewayInfo(),
- originalCall.getSubscription(), false, false);
+ originalCall.getAccount(), false, false);
tempCall.setOriginalCall(originalCall);
tempCall.setExtras(originalCall.getExtras());
mPendingHandoffCalls.add(tempCall);
diff --git a/src/com/android/telecomm/InCallController.java b/src/com/android/telecomm/InCallController.java
index 90d24fd..9b53609 100644
--- a/src/com/android/telecomm/InCallController.java
+++ b/src/com/android/telecomm/InCallController.java
@@ -320,7 +320,7 @@
return new InCallCall(callId, state, call.getDisconnectCause(), call.getDisconnectMessage(),
call.getCannedSmsResponses(), capabilities, connectTimeMillis, call.getHandle(),
- call.getGatewayInfo(), call.getSubscription(), descriptor,
+ call.getGatewayInfo(), call.getAccount(), descriptor,
call.getHandoffCallServiceDescriptor(), call.getCallVideoProvider(),
parentCallId, childCallIds, call.getFeatures());
}
diff --git a/src/com/android/telecomm/NewOutgoingCallIntentBroadcaster.java b/src/com/android/telecomm/NewOutgoingCallIntentBroadcaster.java
index c18dbc5..770b75d 100644
--- a/src/com/android/telecomm/NewOutgoingCallIntentBroadcaster.java
+++ b/src/com/android/telecomm/NewOutgoingCallIntentBroadcaster.java
@@ -17,34 +17,18 @@
package com.android.telecomm;
import android.app.Activity;
-import android.app.ActivityManagerNative;
-import android.app.AlertDialog;
-import android.app.AppOpsManager;
-import android.app.Dialog;
import android.content.BroadcastReceiver;
import android.content.Context;
-import android.content.DialogInterface;
import android.content.Intent;
-import android.content.res.Configuration;
import android.content.res.Resources;
-import android.database.Cursor;
import android.net.Uri;
-import android.os.Binder;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.Message;
-import android.os.RemoteException;
-import android.os.SystemProperties;
import android.os.UserHandle;
-import android.provider.ContactsContract;
import android.telecomm.GatewayInfo;
-import android.telecomm.Subscription;
+import android.telecomm.PhoneAccount;
import android.telecomm.TelecommConstants;
import android.telephony.PhoneNumberUtils;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
-import android.view.View;
-import android.widget.ProgressBar;
/**
* OutgoingCallIntentBroadcaster receives CALL and CALL_PRIVILEGED Intents, and broadcasts the
@@ -135,9 +119,9 @@
}
GatewayInfo gatewayInfo = getGateWayInfoFromIntent(intent, resultHandleUri);
- Subscription subscription = getSubscriptionFromIntent(intent);
+ PhoneAccount account = getAccountFromIntent(intent);
mCallsManager.placeOutgoingCall(resultHandleUri, mContactInfo, gatewayInfo,
- subscription,
+ account,
mIntent.getBooleanExtra(TelecommConstants.EXTRA_START_CALL_WITH_SPEAKERPHONE,
false));
}
@@ -276,11 +260,11 @@
Log.d(this, "Found and copied gateway provider extras to broadcast intent.");
return;
}
- Subscription extraSubscription = src.getParcelableExtra(
- TelephonyManager.EXTRA_SUBSCRIPTION);
- if (extraSubscription != null) {
- dst.putExtra(TelephonyManager.EXTRA_SUBSCRIPTION, extraSubscription);
- Log.d(this, "Found and copied subscription extra to broadcast intent.");
+ PhoneAccount extraAccount = src.getParcelableExtra(
+ TelephonyManager.EXTRA_ACCOUNT);
+ if (extraAccount != null) {
+ dst.putExtra(TelephonyManager.EXTRA_ACCOUNT, extraAccount);
+ Log.d(this, "Found and copied account extra to broadcast intent.");
}
Log.d(this, "No provider extras found in call intent.");
@@ -327,17 +311,17 @@
}
/**
- * Extracts subscription/connection provider information from a provided intent..
+ * Extracts account/connection provider information from a provided intent..
*
- * @param intent to extract subscription information from.
- * @return Subscription object containing extracted subscription information
+ * @param intent to extract account information from.
+ * @return Account object containing extracted account information
*/
- public static Subscription getSubscriptionFromIntent(Intent intent) {
+ public static PhoneAccount getAccountFromIntent(Intent intent) {
if (intent == null) {
return null;
}
- return intent.getParcelableExtra(TelephonyManager.EXTRA_SUBSCRIPTION);
+ return intent.getParcelableExtra(TelephonyManager.EXTRA_ACCOUNT);
}
private void launchSystemDialer(Context context, Uri handle) {
diff --git a/src/com/android/telecomm/TelecommServiceImpl.java b/src/com/android/telecomm/TelecommServiceImpl.java
index 24d6cc4..6ba90d0 100644
--- a/src/com/android/telecomm/TelecommServiceImpl.java
+++ b/src/com/android/telecomm/TelecommServiceImpl.java
@@ -21,6 +21,7 @@
import com.android.internal.telecomm.ITelecommService;
import android.content.ComponentName;
+import android.content.Context;
import android.content.res.Resources;
import android.net.Uri;
import android.os.Handler;
@@ -28,8 +29,8 @@
import android.os.Message;
import android.os.ServiceManager;
import android.telecomm.CallState;
-import android.telecomm.Subscription;
import android.text.TextUtils;
+import android.telecomm.PhoneAccount;
import java.util.List;
@@ -131,18 +132,57 @@
//
@Override
- public List<Subscription> getSubscriptions() {
- return sSubscriptions;
+ public List<PhoneAccount> getAccounts() {
+ // TODO (STOPSHIP): Static list of Accounts for testing and UX work only.
+ ComponentName componentName = new ComponentName(
+ "com.android.telecomm",
+ TelecommServiceImpl.class.getName()); // This field is a no-op
+ Context app = TelecommApp.getInstance();
+
+ return Lists.newArrayList(
+ new PhoneAccount(
+ componentName,
+ "account0",
+ Uri.parse("tel:999-555-1212"),
+ app.getString(R.string.test_account_0_label),
+ app.getString(R.string.test_account_0_short_description),
+ true,
+ true),
+ new PhoneAccount(
+ componentName,
+ "account1",
+ Uri.parse("tel:333-111-2222"),
+ app.getString(R.string.test_account_1_label),
+ app.getString(R.string.test_account_1_short_description),
+ true,
+ false),
+ new PhoneAccount(
+ componentName,
+ "account2",
+ Uri.parse("mailto:two@example.com"),
+ app.getString(R.string.test_account_2_label),
+ app.getString(R.string.test_account_2_short_description),
+ true,
+ false),
+ new PhoneAccount(
+ componentName,
+ "account3",
+ Uri.parse("mailto:three@example.com"),
+ app.getString(R.string.test_account_3_label),
+ app.getString(R.string.test_account_3_short_description),
+ true,
+ false)
+ );
}
@Override
- public void setEnabled(Subscription subscription, boolean enabled) {
+ public void setEnabled(PhoneAccount account, boolean enabled) {
// Enforce MODIFY_PHONE_STATE ?
// TODO
}
@Override
- public void setSystemDefault(Subscription subscription) {
+ public void setSystemDefault(PhoneAccount account) {
// Enforce MODIFY_PHONE_STATE ?
// TODO
}
@@ -260,50 +300,9 @@
android.Manifest.permission.READ_PHONE_STATE, null);
}
- // TODO (STOPSHIP): Static list of Subscriptions for testing and UX work only.
-
- private static final ComponentName sComponentName = new ComponentName(
- "com.android.telecomm",
- TelecommServiceImpl.class.getName()); // This field is a no-op
-
- private static final List<Subscription> sSubscriptions = Lists.newArrayList(
- new Subscription(
- sComponentName,
- "subscription0",
- Uri.parse("tel:999-555-1212"),
- R.string.test_subscription_0_label,
- R.string.test_subscription_0_short_description,
- R.drawable.q_mobile,
- true,
- true),
- new Subscription(
- sComponentName,
- "subscription1",
- Uri.parse("tel:333-111-2222"),
- R.string.test_subscription_1_label,
- R.string.test_subscription_1_short_description,
- R.drawable.market_wireless,
- true,
- false),
- new Subscription(
- sComponentName,
- "subscription2",
- Uri.parse("mailto:two@example.com"),
- R.string.test_subscription_2_label,
- R.string.test_subscription_2_short_description,
- R.drawable.talk_to_your_circles,
- true,
- false),
- new Subscription(
- sComponentName,
- "subscription3",
- Uri.parse("mailto:three@example.com"),
- R.string.test_subscription_3_label,
- R.string.test_subscription_3_short_description,
- R.drawable.chat_with_others,
- true,
- false)
- );
+ private void showCallScreenInternal(boolean showDialpad) {
+ CallsManager.getInstance().getInCallController().bringToForeground(showDialpad);
+ }
private void publish() {
Log.d(this, "publish: %s", this);