Add Connection.setStatusHints
This CL allows a connection to specify a status hint. The hint contains a label and icon that can be displayed in the InCallUI. For example, wifi calling can set a wifi icon and ssid. Change-Id: I125628b74784d2303b9a429038a9f7ee604f241e
This commit is contained in:
@@ -27618,6 +27618,7 @@ package android.telecomm {
|
||||
method public final android.net.Uri getHandle();
|
||||
method public final android.telecomm.Connection getParentConnection();
|
||||
method public final int getState();
|
||||
method public final android.telecomm.StatusHints getStatusHints();
|
||||
method public final boolean isConferenceCapable();
|
||||
method public final boolean isConferenceConnection();
|
||||
method public final boolean isRequestingRingback();
|
||||
@@ -27650,6 +27651,7 @@ package android.telecomm {
|
||||
method public final void setRequestingRingback(boolean);
|
||||
method public final void setRinging();
|
||||
method public final void setSignal(android.os.Bundle);
|
||||
method public final void setStatusHints(android.telecomm.StatusHints);
|
||||
method public static java.lang.String stateToString(int);
|
||||
}
|
||||
|
||||
@@ -27734,6 +27736,7 @@ package android.telecomm {
|
||||
method public android.net.Uri getHandle();
|
||||
method public java.lang.String getId();
|
||||
method public android.telecomm.CallState getState();
|
||||
method public android.telecomm.StatusHints getStatusHints();
|
||||
method public void writeToParcel(android.os.Parcel, int);
|
||||
field public static final android.os.Parcelable.Creator CREATOR;
|
||||
}
|
||||
@@ -27751,7 +27754,7 @@ package android.telecomm {
|
||||
method protected abstract void updateCall(android.telecomm.InCallCall);
|
||||
}
|
||||
|
||||
public class PhoneAccount implements android.os.Parcelable {
|
||||
public final class PhoneAccount implements android.os.Parcelable {
|
||||
ctor public PhoneAccount(android.content.ComponentName, java.lang.String, android.net.Uri, java.lang.String, java.lang.String, boolean, boolean);
|
||||
method public int describeContents();
|
||||
method public android.content.ComponentName getComponentName();
|
||||
@@ -27802,6 +27805,7 @@ package android.telecomm {
|
||||
method public java.lang.String getDisconnectMessage();
|
||||
method public int getFeatures();
|
||||
method public int getState();
|
||||
method public android.telecomm.StatusHints getStatusHints();
|
||||
method public void hold();
|
||||
method public void playDtmf(char);
|
||||
method public void postDialContinue(boolean);
|
||||
@@ -27819,6 +27823,7 @@ package android.telecomm {
|
||||
method public abstract void onPostDialWait(android.telecomm.RemoteConnection, java.lang.String);
|
||||
method public abstract void onRequestingRingback(android.telecomm.RemoteConnection, boolean);
|
||||
method public abstract void onSetAudioModeIsVoip(android.telecomm.RemoteConnection, boolean);
|
||||
method public abstract void onSetStatusHints(android.telecomm.RemoteConnection, android.telecomm.StatusHints);
|
||||
method public abstract void onStateChanged(android.telecomm.RemoteConnection, int);
|
||||
}
|
||||
|
||||
@@ -27832,6 +27837,17 @@ package android.telecomm {
|
||||
method public abstract void onResult(IN, OUT);
|
||||
}
|
||||
|
||||
public final class StatusHints implements android.os.Parcelable {
|
||||
ctor public StatusHints(android.content.ComponentName, java.lang.String, int);
|
||||
method public int describeContents();
|
||||
method public android.content.ComponentName getComponentName();
|
||||
method public android.graphics.drawable.Drawable getIcon(android.content.Context);
|
||||
method public int getIconId();
|
||||
method public java.lang.String getLabel();
|
||||
method public void writeToParcel(android.os.Parcel, int);
|
||||
field public static final android.os.Parcelable.Creator CREATOR;
|
||||
}
|
||||
|
||||
public final class TelecommConstants {
|
||||
ctor public TelecommConstants();
|
||||
field public static final java.lang.String ACTION_CALL_SERVICE_PROVIDER;
|
||||
|
||||
@@ -45,6 +45,7 @@ public abstract class Connection {
|
||||
void onParentConnectionChanged(Connection c, Connection parent);
|
||||
void onSetCallVideoProvider(Connection c, CallVideoProvider callVideoProvider);
|
||||
void onSetAudioModeIsVoip(Connection c, boolean isVoip);
|
||||
void onSetStatusHints(Connection c, StatusHints statusHints);
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
@@ -85,6 +86,9 @@ public abstract class Connection {
|
||||
|
||||
@Override
|
||||
public void onSetAudioModeIsVoip(Connection c, boolean isVoip) {}
|
||||
|
||||
@Override
|
||||
public void onSetStatusHints(Connection c, StatusHints statusHints) {}
|
||||
}
|
||||
|
||||
public final class State {
|
||||
@@ -109,6 +113,7 @@ public abstract class Connection {
|
||||
private boolean mIsConferenceCapable = false;
|
||||
private Connection mParentConnection;
|
||||
private boolean mAudioModeIsVoip;
|
||||
private StatusHints mStatusHints;
|
||||
|
||||
/**
|
||||
* Create a new Connection.
|
||||
@@ -176,6 +181,13 @@ public abstract class Connection {
|
||||
return mAudioModeIsVoip;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The status hints for this connection.
|
||||
*/
|
||||
public final StatusHints getStatusHints() {
|
||||
return mStatusHints;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assign a listener to be notified of state changes.
|
||||
*
|
||||
@@ -431,6 +443,18 @@ public abstract class Connection {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the label and icon status to display in the in-call UI.
|
||||
*
|
||||
* @param statusHints The status label and icon to set.
|
||||
*/
|
||||
public final void setStatusHints(StatusHints statusHints) {
|
||||
mStatusHints = statusHints;
|
||||
for (Listener l : mListeners) {
|
||||
l.onSetStatusHints(this, statusHints);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notifies this Connection and listeners that the {@link #getCallAudioState()} property
|
||||
* has a new value.
|
||||
|
||||
@@ -370,6 +370,12 @@ public abstract class ConnectionService extends Service {
|
||||
String id = mIdByConnection.get(c);
|
||||
mAdapter.setAudioModeIsVoip(id, isVoip);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSetStatusHints(Connection c, StatusHints statusHints) {
|
||||
String id = mIdByConnection.get(c);
|
||||
mAdapter.setStatusHints(id, statusHints);
|
||||
}
|
||||
};
|
||||
|
||||
/** {@inheritDoc} */
|
||||
|
||||
@@ -335,6 +335,15 @@ final class ConnectionServiceAdapter implements DeathRecipient {
|
||||
}
|
||||
}
|
||||
|
||||
void setStatusHints(String callId, StatusHints statusHints) {
|
||||
for (IConnectionServiceAdapter adapter : mAdapters) {
|
||||
try {
|
||||
adapter.setStatusHints(callId, statusHints);
|
||||
} catch (RemoteException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the features associated with the given call.
|
||||
* Features are defined in {@link android.telecomm.CallFeatures} and are passed in as a
|
||||
|
||||
@@ -48,6 +48,7 @@ public final class InCallCall implements Parcelable {
|
||||
private final String mParentCallId;
|
||||
private final List<String> mChildCallIds;
|
||||
private final int mFeatures;
|
||||
private final StatusHints mStatusHints;
|
||||
|
||||
/** @hide */
|
||||
public InCallCall(
|
||||
@@ -65,7 +66,8 @@ public final class InCallCall implements Parcelable {
|
||||
ICallVideoProvider callVideoProvider,
|
||||
String parentCallId,
|
||||
List<String> childCallIds,
|
||||
int features) {
|
||||
int features,
|
||||
StatusHints statusHints) {
|
||||
mId = id;
|
||||
mState = state;
|
||||
mDisconnectCauseCode = disconnectCauseCode;
|
||||
@@ -81,6 +83,7 @@ public final class InCallCall implements Parcelable {
|
||||
mParentCallId = parentCallId;
|
||||
mChildCallIds = childCallIds;
|
||||
mFeatures = features;
|
||||
mStatusHints = statusHints;
|
||||
}
|
||||
|
||||
/** The unique ID of the call. */
|
||||
@@ -188,6 +191,15 @@ public final class InCallCall implements Parcelable {
|
||||
return mFeatures;
|
||||
}
|
||||
|
||||
/**
|
||||
* The status label and icon.
|
||||
*
|
||||
* @return Status hints.
|
||||
*/
|
||||
public StatusHints getStatusHints() {
|
||||
return mStatusHints;
|
||||
}
|
||||
|
||||
/** Responsible for creating InCallCall objects for deserialized Parcels. */
|
||||
public static final Parcelable.Creator<InCallCall> CREATOR =
|
||||
new Parcelable.Creator<InCallCall> () {
|
||||
@@ -212,9 +224,11 @@ public final class InCallCall implements Parcelable {
|
||||
List<String> childCallIds = new ArrayList<>();
|
||||
source.readList(childCallIds, classLoader);
|
||||
int features = source.readInt();
|
||||
StatusHints statusHints = source.readParcelable(classLoader);
|
||||
return new InCallCall(id, state, disconnectCauseCode, disconnectCauseMsg,
|
||||
cannedSmsResponses, capabilities, connectTimeMillis, handle, gatewayInfo,
|
||||
account, descriptor, callVideoProvider, parentCallId, childCallIds, features);
|
||||
account, descriptor, callVideoProvider, parentCallId, childCallIds, features,
|
||||
statusHints);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -248,6 +262,7 @@ public final class InCallCall implements Parcelable {
|
||||
destination.writeString(mParentCallId);
|
||||
destination.writeList(mChildCallIds);
|
||||
destination.writeInt(mFeatures);
|
||||
destination.writeParcelable(mStatusHints, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -34,7 +34,7 @@ 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 class PhoneAccount implements Parcelable {
|
||||
public final class PhoneAccount implements Parcelable {
|
||||
|
||||
private static final int NO_DENSITY = -1;
|
||||
|
||||
@@ -169,10 +169,12 @@ public class PhoneAccount implements Parcelable {
|
||||
return mIsSystemDefault;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel out, int flags) {
|
||||
out.writeParcelable(mComponentName, flags);
|
||||
out.writeString(mId);
|
||||
|
||||
@@ -38,6 +38,7 @@ public final class RemoteConnection {
|
||||
void onPostDialWait(RemoteConnection connection, String remainingDigits);
|
||||
void onFeaturesChanged(RemoteConnection connection, int features);
|
||||
void onSetAudioModeIsVoip(RemoteConnection connection, boolean isVoip);
|
||||
void onSetStatusHints(RemoteConnection connection, StatusHints statusHints);
|
||||
void onDestroyed(RemoteConnection connection);
|
||||
}
|
||||
|
||||
@@ -52,6 +53,7 @@ public final class RemoteConnection {
|
||||
private boolean mConnected;
|
||||
private int mFeatures;
|
||||
private boolean mAudioModeIsVoip;
|
||||
private StatusHints mStatusHints;
|
||||
|
||||
/**
|
||||
* @hide
|
||||
@@ -91,6 +93,10 @@ public final class RemoteConnection {
|
||||
return mAudioModeIsVoip;
|
||||
}
|
||||
|
||||
public StatusHints getStatusHints() {
|
||||
return mStatusHints;
|
||||
}
|
||||
|
||||
public void abort() {
|
||||
try {
|
||||
if (mConnected) {
|
||||
@@ -266,4 +272,12 @@ public final class RemoteConnection {
|
||||
l.onSetAudioModeIsVoip(this, isVoip);
|
||||
}
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
void setStatusHints(StatusHints statusHints) {
|
||||
mStatusHints = statusHints;
|
||||
for (Listener l : mListeners) {
|
||||
l.onSetStatusHints(this, statusHints);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,6 +201,14 @@ final class RemoteConnectionService implements DeathRecipient {
|
||||
mConnection.setAudioModeIsVoip(isVoip);
|
||||
}
|
||||
}
|
||||
|
||||
/** ${inheritDoc} */
|
||||
@Override
|
||||
public final void setStatusHints(String connectionId, StatusHints statusHints) {
|
||||
if (isCurrentConnection(connectionId)) {
|
||||
mConnection.setStatusHints(statusHints);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
RemoteConnectionService(ComponentName componentName, IConnectionService connectionService)
|
||||
|
||||
22
telecomm/java/android/telecomm/StatusHints.aidl
Normal file
22
telecomm/java/android/telecomm/StatusHints.aidl
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright (C) 2008 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 StatusHints;
|
||||
118
telecomm/java/android/telecomm/StatusHints.java
Normal file
118
telecomm/java/android/telecomm/StatusHints.java
Normal file
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
* 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.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.util.DisplayMetrics;
|
||||
|
||||
import java.util.MissingResourceException;
|
||||
|
||||
/**
|
||||
* Contains status label and icon displayed in the in-call UI.
|
||||
*/
|
||||
public final class StatusHints implements Parcelable {
|
||||
|
||||
private final ComponentName mComponentName;
|
||||
private final String mLabel;
|
||||
private final int mIconId;
|
||||
|
||||
public StatusHints(ComponentName componentName, String label, int iconId) {
|
||||
mComponentName = componentName;
|
||||
mLabel = label;
|
||||
mIconId = iconId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A component used to load the icon.
|
||||
*/
|
||||
public ComponentName getComponentName() {
|
||||
return mComponentName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The label displayed in the in-call UI.
|
||||
*/
|
||||
public String getLabel() {
|
||||
return mLabel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The icon resource identifier.
|
||||
*/
|
||||
public int getIconId() {
|
||||
return mIconId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return An icon displayed in the in-call UI.
|
||||
*/
|
||||
public Drawable getIcon(Context context) {
|
||||
return getIcon(context, mIconId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel out, int flags) {
|
||||
out.writeParcelable(mComponentName, flags);
|
||||
out.writeString(mLabel);
|
||||
out.writeInt(mIconId);
|
||||
}
|
||||
|
||||
public static final Creator<StatusHints> CREATOR
|
||||
= new Creator<StatusHints>() {
|
||||
public StatusHints createFromParcel(Parcel in) {
|
||||
return new StatusHints(in);
|
||||
}
|
||||
|
||||
public StatusHints[] newArray(int size) {
|
||||
return new StatusHints[size];
|
||||
}
|
||||
};
|
||||
|
||||
private StatusHints(Parcel in) {
|
||||
mComponentName = in.readParcelable(getClass().getClassLoader());
|
||||
mLabel = in.readString();
|
||||
mIconId = in.readInt();
|
||||
}
|
||||
|
||||
private Drawable getIcon(Context context, int resId) {
|
||||
Context packageContext;
|
||||
try {
|
||||
packageContext = context.createPackageContext(mComponentName.getPackageName(), 0);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
Log.e(this, e, "Cannot find package %s", mComponentName.getPackageName());
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return packageContext.getResources().getDrawable(resId);
|
||||
} catch (MissingResourceException e) {
|
||||
Log.e(this, e, "Cannot find icon %d in package %s",
|
||||
resId, mComponentName.getPackageName());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.android.internal.telecomm;
|
||||
|
||||
import android.telecomm.ConnectionRequest;
|
||||
import android.telecomm.StatusHints;
|
||||
|
||||
import com.android.internal.telecomm.ICallVideoProvider;
|
||||
import com.android.internal.telecomm.RemoteServiceCallback;
|
||||
@@ -66,4 +67,6 @@ oneway interface IConnectionServiceAdapter {
|
||||
void setFeatures(String callId, int features);
|
||||
|
||||
void setAudioModeIsVoip(String callId, boolean isVoip);
|
||||
|
||||
void setStatusHints(String callId, in StatusHints statusHints);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user