summaryrefslogtreecommitdiffstats
path: root/telecomm
diff options
context:
space:
mode:
authorSantos Cordon <santoscordon@google.com>2014-07-14 23:20:15 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-07-14 18:38:02 +0000
commita5a2cf419d72b28d0ce3948199d6f6874d6dbf9b (patch)
tree5360ec07964867f0570a9aecbf3965d805a2fa14 /telecomm
parent49a22e82025ea947d81681a0abb7ef00600eac3b (diff)
parent807fe0a19a710ae4e053e80f610807ff5718f1a1 (diff)
downloadframeworks_base-a5a2cf419d72b28d0ce3948199d6f6874d6dbf9b.zip
frameworks_base-a5a2cf419d72b28d0ce3948199d6f6874d6dbf9b.tar.gz
frameworks_base-a5a2cf419d72b28d0ce3948199d6f6874d6dbf9b.tar.bz2
Merge "Implement multi-SIM capabilities (1/6) [DO NOT MERGE]" into lmp-dev
Diffstat (limited to 'telecomm')
-rw-r--r--telecomm/java/android/telecomm/PhoneAccount.java167
-rw-r--r--telecomm/java/android/telecomm/PhoneAccountMetadata.aidl22
-rw-r--r--telecomm/java/android/telecomm/PhoneAccountMetadata.java140
-rw-r--r--telecomm/java/android/telecomm/RemoteConnectionService.java5
-rw-r--r--telecomm/java/android/telecomm/TelecommManager.java110
-rw-r--r--telecomm/java/com/android/internal/telecomm/ITelecommService.aidl25
6 files changed, 338 insertions, 131 deletions
diff --git a/telecomm/java/android/telecomm/PhoneAccount.java b/telecomm/java/android/telecomm/PhoneAccount.java
index 4e440d8..c1eec83 100644
--- a/telecomm/java/android/telecomm/PhoneAccount.java
+++ b/telecomm/java/android/telecomm/PhoneAccount.java
@@ -17,52 +17,64 @@
package android.telecomm;
import android.content.ComponentName;
-import android.content.Context;
-import android.content.pm.PackageManager;
-import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Parcel;
import android.os.Parcelable;
-import android.telephony.Rlog;
-import android.util.DisplayMetrics;
-import android.util.Log;
-import java.util.MissingResourceException;
import java.util.Objects;
/**
* Represents a distinct account, line of service or call placement method that
* the system can use to place phone calls.
*/
-public final class PhoneAccount implements Parcelable {
+public class PhoneAccount implements Parcelable {
- private static final int NO_DENSITY = -1;
- private static final String LOG_TAG = "Account";
+ /**
+ * Flag indicating that this {@code PhoneAccount} can act as a call manager for traditional
+ * SIM-based telephony calls. The {@link ConnectionService} associated with this phone-account
+ * will be allowed to manage SIM-based phone calls including using its own proprietary
+ * phone-call implementation (like VoIP calling) to make calls instead of the telephony stack.
+ * When a user opts to place a call using the SIM-based telephony stack, the connection-service
+ * associated with this phone-account will be attempted first if the user has explicitly
+ * selected it to be used as the default call-manager.
+ * <p>
+ * See {@link #getCapabilities}
+ */
+ public static final int CAPABILITY_SIM_CALL_MANAGER = 0x1;
+
+ /**
+ * Flag indicating that this {@code PhoneAccount} can make phone calls in place of traditional
+ * SIM-based telephony calls. This account will be treated as a distinct method for placing
+ * calls alongside the traditional SIM-based telephony stack. This flag is distinct from
+ * {@link #CAPABILITY_SIM_CALL_MANAGER} in that it is not allowed to manage calls from or use
+ * the built-in telephony stack to place its calls.
+ * <p>
+ * See {@link #getCapabilities}
+ */
+ public static final int CAPABILITY_CALL_PROVIDER = 0x2;
+
+ /**
+ * Flag indicating that this {@code PhoneAccount} represents a built-in PSTN SIM subscription.
+ * <p>
+ * Only the android framework can set this capability on a phone-account.
+ */
+ public static final int CAPABILITY_SIM_SUBSCRIPTION = 0x4;
- private final ComponentName mComponentName;
- private final String mId;
- private final Uri mHandle;
- private final String mLabel;
- private final String mShortDescription;
- private final boolean mIsEnabled;
- private final boolean mIsSystemDefault;
+ private ComponentName mComponentName;
+ private String mId;
+ private Uri mHandle;
+ private int mCapabilities;
public PhoneAccount(
ComponentName componentName,
String id,
Uri handle,
- String label,
- String shortDescription,
- boolean isEnabled,
- boolean isSystemDefault) {
+ int capabilities) {
mComponentName = componentName;
mId = id;
mHandle = handle;
- mLabel = label;
- mShortDescription = shortDescription;
- mIsSystemDefault = isSystemDefault;
- mIsEnabled = isEnabled;
+ mCapabilities = capabilities;
}
/**
@@ -87,8 +99,8 @@ public final class PhoneAccount implements Parcelable {
/**
* The handle (e.g., a phone number) associated with this {@code PhoneAccount}. This represents
- * the destination from which outgoing calls using this {@code PhoneAccount} will appear to come
- * from, if applicable, and the destination to which incoming calls using this
+ * the destination from which outgoing calls using this {@code PhoneAccount} will appear to
+ * come, if applicable, and the destination to which incoming calls using this
* {@code PhoneAccount} may be addressed.
*
* @return A handle expressed as a {@code Uri}, for example, a phone number.
@@ -98,76 +110,23 @@ public final class PhoneAccount implements Parcelable {
}
/**
- * A short string label describing this {@code PhoneAccount}.
- *
- * @param context The invoking {@code Context}, used for retrieving resources.
+ * The capabilities of this {@code PhoneAccount}.
*
- * TODO(ihab): If don't need context, remove param
- *
- * @return A label for this {@code PhoneAccount}.
+ * @return A bit field of flags describing this {@code PhoneAccount}'s capabilities.
*/
- public String getLabel(Context context) {
- return mLabel;
+ public int getCapabilities() {
+ return mCapabilities;
}
- /**
- * A short paragraph describing this {@code PhoneAccount}.
- *
- * @param context The invoking {@code Context}, used for retrieving resources.
- *
- * TODO(ihab): If don't need context, remove param
- *
- * @return A description for this {@code PhoneAccount}.
- */
- public String getShortDescription(Context context) {
- return mShortDescription;
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(mComponentName) + Objects.hashCode(mId) +
+ Objects.hashCode(mHandle) + mCapabilities;
}
- // TODO(ihab): Representation of the icons
//
- // Refactor to pass a Bitmap (scale it at runtime), but if they don't pass one, fall
- // back to the android:icon attr in the manifest (<service /> first, <application /> second)
-
- /**
- * An icon to represent this {@code PhoneAccount} in a user interface.
- *
- * @param context The invoking {@code Context}, used for retrieving resources.
- *
- * @return An icon for this {@code PhoneAccount}.
- */
- public Drawable getIcon(Context context) {
- return null; // TODO(ihab): See above
- }
-
- /**
- * An icon to represent this {@code PhoneAccount} in a user interface.
- *
- * @param context The invoking {@code Context}, used for retrieving resources.
- * @param density A display density from {@link DisplayMetrics}.
- *
- * @return An icon for this {@code PhoneAccount}.
- */
- public Drawable getIcon(Context context, int density) {
- return null; // TODO(ihab): See above
- }
-
- /**
- * Whether this {@code PhoneAccount} is enabled for use.
- *
- * @return {@code true} if this {@code PhoneAccount} is enabled.
- */
- public boolean isEnabled() {
- return mIsEnabled;
- }
-
- /**
- * Whether this {@code PhoneAccount} is the system default.
- *
- * @return {@code true} if this {@code PhoneAccount} is the system default.
- */
- public boolean isSystemDefault() {
- return mIsSystemDefault;
- }
+ // Parcelable implementation.
+ //
@Override
public int describeContents() {
@@ -179,18 +138,16 @@ public final class PhoneAccount implements Parcelable {
out.writeParcelable(mComponentName, flags);
out.writeString(mId);
out.writeString(mHandle != null ? mHandle.toString() : "");
- out.writeString(mLabel);
- out.writeString(mShortDescription);
- out.writeInt(mIsEnabled ? 1 : 0);
- out.writeInt(mIsSystemDefault ? 1 : 0);
+ out.writeInt(mCapabilities);
}
- public static final Creator<PhoneAccount> CREATOR
- = new Creator<PhoneAccount>() {
+ public static final Creator<PhoneAccount> CREATOR = new Creator<PhoneAccount>() {
+ @Override
public PhoneAccount createFromParcel(Parcel in) {
return new PhoneAccount(in);
}
+ @Override
public PhoneAccount[] newArray(int size) {
return new PhoneAccount[size];
}
@@ -201,22 +158,6 @@ public final class PhoneAccount implements Parcelable {
mId = in.readString();
String uriString = in.readString();
mHandle = uriString.length() > 0 ? Uri.parse(uriString) : null;
- mLabel = in.readString();
- mShortDescription = in.readString();
- mIsEnabled = in.readInt() == 1;
- mIsSystemDefault = in.readInt() == 1;
- }
-
- @Override
- public boolean equals(Object other) {
- return
- other instanceof PhoneAccount &&
- Objects.equals(mComponentName, ((PhoneAccount) other).mComponentName) &&
- Objects.equals(mId, ((PhoneAccount) other).mId);
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(mComponentName) + Objects.hashCode(mId);
+ mCapabilities = in.readInt();
}
}
diff --git a/telecomm/java/android/telecomm/PhoneAccountMetadata.aidl b/telecomm/java/android/telecomm/PhoneAccountMetadata.aidl
new file mode 100644
index 0000000..55b8900
--- /dev/null
+++ b/telecomm/java/android/telecomm/PhoneAccountMetadata.aidl
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2014 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 android.telecomm;
+
+/**
+ * {@hide}
+ */
+parcelable PhoneAccountMetadata;
diff --git a/telecomm/java/android/telecomm/PhoneAccountMetadata.java b/telecomm/java/android/telecomm/PhoneAccountMetadata.java
new file mode 100644
index 0000000..20a4d47
--- /dev/null
+++ b/telecomm/java/android/telecomm/PhoneAccountMetadata.java
@@ -0,0 +1,140 @@
+/*
+ * Copyright (C) 2014 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 android.telecomm;
+
+import android.content.Context;
+import android.content.pm.PackageManager;
+import android.graphics.drawable.Drawable;
+import android.os.Parcel;
+import android.os.Parcelable;
+
+import java.io.IOException;
+import java.io.ObjectStreamException;
+import java.io.Serializable;
+import java.util.MissingResourceException;
+
+/**
+ * Provides user interface description information for a {@code PhoneAccount}.
+ */
+public class PhoneAccountMetadata implements Parcelable {
+ private PhoneAccount mAccount;
+ private int mIconResId;
+ private String mLabel;
+ private String mShortDescription;
+
+ public PhoneAccountMetadata(
+ PhoneAccount account,
+ int iconResId,
+ String label,
+ String shortDescription) {
+ mAccount = account;
+ mIconResId = iconResId;
+ mLabel = label;
+ mShortDescription = shortDescription;
+ }
+
+ /**
+ * The {@code PhoneAccount} to which this metadata pertains.
+ *
+ * @return A {@code PhoneAccount}.
+ */
+ public PhoneAccount getAccount() {
+ return mAccount;
+ }
+
+ /**
+ * A short string label describing a {@code PhoneAccount}.
+ *
+ * @return A label for this {@code PhoneAccount}.
+ */
+ public String getLabel() {
+ return mLabel;
+ }
+
+ /**
+ * A short paragraph describing a {@code PhoneAccount}.
+ *
+ * @return A description for this {@code PhoneAccount}.
+ */
+ public String getShortDescription() {
+ return mShortDescription;
+ }
+
+ /**
+ * An icon to represent this {@code PhoneAccount} in a user interface.
+ *
+ * @return An icon for this {@code PhoneAccount}.
+ */
+ public Drawable getIcon(Context context) {
+ return getIcon(context, mIconResId);
+ }
+
+ private Drawable getIcon(Context context, int resId) {
+ Context packageContext;
+ try {
+ packageContext = context.createPackageContext(
+ mAccount.getComponentName().getPackageName(), 0);
+ } catch (PackageManager.NameNotFoundException e) {
+ Log.w(this, "Cannot find package %s", mAccount.getComponentName().getPackageName());
+ return null;
+ }
+ try {
+ return packageContext.getResources().getDrawable(resId);
+ } catch (MissingResourceException e) {
+ Log.e(this, e, "Cannot find icon %d in package %s",
+ resId, mAccount.getComponentName().getPackageName());
+ return null;
+ }
+ }
+
+ //
+ // Parcelable implementation
+ //
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel out, int flags) {
+ out.writeParcelable(mAccount, 0);
+ out.writeInt(mIconResId);
+ out.writeString(mLabel);
+ out.writeString(mShortDescription);
+ }
+
+ public static final Creator<PhoneAccountMetadata> CREATOR
+ = new Creator<PhoneAccountMetadata>() {
+ @Override
+ public PhoneAccountMetadata createFromParcel(Parcel in) {
+ return new PhoneAccountMetadata(in);
+ }
+
+ @Override
+ public PhoneAccountMetadata[] newArray(int size) {
+ return new PhoneAccountMetadata[size];
+ }
+ };
+
+ private PhoneAccountMetadata(Parcel in) {
+ mAccount = in.readParcelable(getClass().getClassLoader());
+ mIconResId = in.readInt();
+ mLabel = in.readString();
+ mShortDescription = in.readString();
+ }
+}
diff --git a/telecomm/java/android/telecomm/RemoteConnectionService.java b/telecomm/java/android/telecomm/RemoteConnectionService.java
index a436af2..430133c 100644
--- a/telecomm/java/android/telecomm/RemoteConnectionService.java
+++ b/telecomm/java/android/telecomm/RemoteConnectionService.java
@@ -266,10 +266,7 @@ final class RemoteConnectionService implements DeathRecipient {
mComponentName,
null /* id */,
null /* handle */,
- "" /* label */,
- "" /* shortDescription */,
- true /* isEnabled */,
- false /* isSystemDefault */));
+ 0 /* capabilities */));
return accounts;
}
diff --git a/telecomm/java/android/telecomm/TelecommManager.java b/telecomm/java/android/telecomm/TelecommManager.java
index 1bb18f2..fcd2eba 100644
--- a/telecomm/java/android/telecomm/TelecommManager.java
+++ b/telecomm/java/android/telecomm/TelecommManager.java
@@ -23,37 +23,133 @@ import android.util.Log;
import com.android.internal.telecomm.ITelecommService;
+import java.util.List;
+
/**
* Provides access to Telecomm-related functionality.
* TODO(santoscordon): Move this all into PhoneManager.
* @hide
*/
public class TelecommManager {
+
+ /**
+ * The extra used with an {@link android.content.Intent#ACTION_CALL} or
+ * {@link android.content.Intent#ACTION_DIAL} {@code Intent} to specify a {@link PhoneAccount}
+ * to use when making the call.
+ *
+ * <p class="note">
+ * Retrieve with
+ * {@link android.content.Intent#getParcelableExtra(String)}.
+ */
+ public static final String EXTRA_PHONE_ACCOUNT = "account";
+
private static final String TAG = "TelecommManager";
private static final String TELECOMM_SERVICE_NAME = "telecomm";
private final Context mContext;
- private final ITelecommService mService;
/**
* @hide
*/
- public TelecommManager(Context context, ITelecommService service) {
+ public static TelecommManager from(Context context) {
+ return (TelecommManager) context.getSystemService(Context.TELECOMM_SERVICE);
+ }
+
+ /**
+ * @hide
+ */
+ public TelecommManager(Context context) {
Context appContext = context.getApplicationContext();
if (appContext != null) {
mContext = appContext;
} else {
mContext = context;
}
+ }
- mService = service;
+ /**
+ * Return a list of {@link PhoneAccount}s which can be used to make and receive phone calls.
+ *
+ * @see #EXTRA_PHONE_ACCOUNT
+ * @return A list of {@code PhoneAccount} objects.
+ */
+ public List<PhoneAccount> getEnabledPhoneAccounts() {
+ try {
+ if (isServiceConnected()) {
+ return getTelecommService().getEnabledPhoneAccounts();
+ }
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error calling ITelecommService#getEnabledPhoneAccounts", e);
+ }
+ return null;
}
/**
+ * Return the metadata for a specified {@link PhoneAccount}. Metadata includes resources which
+ * can be used in a user interface.
+ *
+ * @param account The {@link PhoneAccount}.
+ *
+ * @return The metadata for the account.
+ */
+ public PhoneAccountMetadata getPhoneAccountMetadata(PhoneAccount account) {
+ try {
+ if (isServiceConnected()) {
+ return getTelecommService().getPhoneAccountMetadata(account);
+ }
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error calling ITelecommService#getPhoneAccountMetadata", e);
+ }
+ return null;
+ }
+
+ /**
+ * Register a {@link PhoneAccount} for use by the system.
+ *
+ * @param account The {@link PhoneAccount}.
+ * @param metadata The metadata for the account.
+ */
+ public void registerPhoneAccount(PhoneAccount account, PhoneAccountMetadata metadata) {
+ try {
+ if (isServiceConnected()) {
+ getTelecommService().registerPhoneAccount(account, metadata);
+ }
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error calling ITelecommService#registerPhoneAccount", e);
+ }
+ }
+
+ /**
+ * Remove a {@link PhoneAccount} registration from the system.
+ *
+ * @param account An Account.
+ */
+ public void unregisterPhoneAccount(PhoneAccount account) {
+ try {
+ if (isServiceConnected()) {
+ getTelecommService().unregisterPhoneAccount(account);
+ }
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error calling ITelecommService#unregisterPhoneAccount", e);
+ }
+ }
+
+ /**
+ * Remove all Accounts for a given package from the system.
+ *
+ * @param packageName A package name that may have registered Accounts.
+ *
* @hide
*/
- public static TelecommManager from(Context context) {
- return (TelecommManager) context.getSystemService(Context.TELECOMM_SERVICE);
+ @SystemApi
+ public void clearAccounts(String packageName) {
+ try {
+ if (isServiceConnected()) {
+ getTelecommService().clearAccounts(packageName);
+ }
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error calling ITelecommService#clearAccounts", e);
+ }
}
/**
@@ -108,7 +204,7 @@ public class TelecommManager {
/**
* Ends an ongoing call. TODO(santoscordon): L-release - need to convert all invocations of
- * ITelephony#endCall to use this method (clockwork & gearhead).
+ * ITelecommService#endCall to use this method (clockwork & gearhead).
*
* @hide
*/
@@ -127,7 +223,7 @@ public class TelecommManager {
/**
* If there is a ringing incoming call, this method accepts the call on behalf of the user.
* TODO(santoscordon): L-release - need to convert all invocation of
- * ITelephony#answerRingingCall to use this method (clockwork & gearhead).
+ * ITelecommService#answerRingingCall to use this method (clockwork & gearhead).
*
* @hide
*/
diff --git a/telecomm/java/com/android/internal/telecomm/ITelecommService.aidl b/telecomm/java/com/android/internal/telecomm/ITelecommService.aidl
index 30e4bdc..3334385 100644
--- a/telecomm/java/com/android/internal/telecomm/ITelecommService.aidl
+++ b/telecomm/java/com/android/internal/telecomm/ITelecommService.aidl
@@ -18,6 +18,7 @@ package com.android.internal.telecomm;
import android.content.ComponentName;
import android.telecomm.PhoneAccount;
+import android.telecomm.PhoneAccountMetadata;
/**
* Interface used to interact with Telecomm. Mostly this is used by TelephonyManager for passing
@@ -33,22 +34,32 @@ interface ITelecommService {
void showCallScreen(boolean showDialpad);
/**
- * Gets a list of accounts.
+ * @see TelecommManager#getEnabledPhoneAccounts
*/
- List<PhoneAccount> getAccounts();
+ List<PhoneAccount> getEnabledPhoneAccounts();
/**
- * Sets the enabled state of a given account.
+ * @see TelecommManager#getPhoneAccountMetadata
*/
- void setEnabled(in PhoneAccount account, boolean enabled);
+ PhoneAccountMetadata getPhoneAccountMetadata(in PhoneAccount account);
/**
- * Sets a given account as the system default.
+ * @see TelecommManager#registerPhoneAccount
*/
- void setSystemDefault(in PhoneAccount account);
+ void registerPhoneAccount(in PhoneAccount account, in PhoneAccountMetadata metadata);
/**
- * Returns the component name of the default phone application.
+ * @see TelecommManager#unregisterPhoneAccount
+ */
+ void unregisterPhoneAccount(in PhoneAccount account);
+
+ /**
+ * @see TelecommManager#clearAccounts
+ */
+ void clearAccounts(String packageName);
+
+ /**
+ * @see TelecommManager#getDefaultPhoneApp
*/
ComponentName getDefaultPhoneApp();