Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 864a2b29 authored by Sailesh Nepal's avatar Sailesh Nepal
Browse files

Remove CallServiceProvider and CallServiceDescriptor do not merge

This CL removes CallServiceProvider. Instead of using a
provider we'll look up ConnectionServices using the package
manager instead.

This CL also removes CallServiceDescriptor. For incoming calls,
connection services will now pass a PhoneAccount instead
of a call descriptor. For outgoing calls we already use
PhoneAccounts for everything.

Change-Id: I2e40c5c64c0d242dc41b680943d7e9209142db5b
(cherry picked from commit 7ade570fdc1ae719abca54867d97dc7f0130d664)
parent d60804d5
Loading
Loading
Loading
Loading
+0 −6
Original line number Diff line number Diff line
@@ -340,8 +340,6 @@ LOCAL_SRC_FILES += \
	media/java/android/media/tv/ITvInputServiceCallback.aidl \
	media/java/android/media/tv/ITvInputSession.aidl \
	media/java/android/media/tv/ITvInputSessionCallback.aidl \
	telecomm/java/com/android/internal/telecomm/ICallServiceLookupResponse.aidl \
	telecomm/java/com/android/internal/telecomm/ICallServiceProvider.aidl \
	telecomm/java/com/android/internal/telecomm/ICallVideoProvider.aidl \
	telecomm/java/com/android/internal/telecomm/ICallVideoClient.aidl \
	telecomm/java/com/android/internal/telecomm/IConnectionService.aidl \
@@ -362,10 +360,6 @@ LOCAL_SRC_FILES += \
	telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl \
	telephony/java/com/android/internal/telephony/IPhoneSubInfo.aidl \
	telephony/java/com/android/internal/telephony/ITelephony.aidl \
	telephony/java/com/android/internal/telephony/IThirdPartyCallListener.aidl \
	telephony/java/com/android/internal/telephony/IThirdPartyCallProvider.aidl \
	telephony/java/com/android/internal/telephony/IThirdPartyCallSendDtmfCallback.aidl \
	telephony/java/com/android/internal/telephony/IThirdPartyCallService.aidl \
	telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl \
	telephony/java/com/android/internal/telephony/ISms.aidl \
	telephony/java/com/android/internal/telephony/IWapPushManager.aidl \
+1 −32
Original line number Diff line number Diff line
@@ -27900,35 +27900,6 @@ package android.telecomm {
    field public static final int UNKNOWN = 2; // 0x2
  }
  public final class CallServiceDescriptor implements android.os.Parcelable {
    method public int describeContents();
    method public java.lang.String getConnectionServiceId();
    method public int getNetworkType();
    method public android.content.ComponentName getServiceComponent();
    method public static android.telecomm.CallServiceDescriptor.Builder newBuilder(android.content.Context);
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator CREATOR;
    field public static final int FLAG_MOBILE = 4; // 0x4
    field public static final int FLAG_PSTN = 2; // 0x2
    field public static final int FLAG_WIFI = 1; // 0x1
  }
  public static class CallServiceDescriptor.Builder {
    method public android.telecomm.CallServiceDescriptor build();
    method public android.telecomm.CallServiceDescriptor.Builder setConnectionService(java.lang.Class<? extends android.telecomm.ConnectionService>);
    method public android.telecomm.CallServiceDescriptor.Builder setNetworkType(int);
  }
  public final class CallServiceLookupResponse {
    method public void setCallServiceDescriptors(java.util.List<android.telecomm.CallServiceDescriptor>);
  }
  public abstract class CallServiceProvider extends android.app.Service {
    ctor protected CallServiceProvider();
    method public abstract void lookupCallServices(android.telecomm.CallServiceLookupResponse);
    method public android.os.IBinder onBind(android.content.Intent);
  }
  public final class CallState extends java.lang.Enum {
    method public static android.telecomm.CallState valueOf(java.lang.String);
    method public static final android.telecomm.CallState[] values();
@@ -28100,7 +28071,6 @@ package android.telecomm {
    method public java.util.List<java.lang.String> getCannedSmsResponses();
    method public int getCapabilities();
    method public long getConnectTimeMillis();
    method public android.telecomm.CallServiceDescriptor getCurrentCallServiceDescriptor();
    method public int getDisconnectCauseCode();
    method public java.lang.String getDisconnectCauseMsg();
    method public android.telecomm.GatewayInfo getGatewayInfo();
@@ -28230,7 +28200,6 @@ package android.telecomm {
  public final class TelecommConstants {
    ctor public TelecommConstants();
    field public static final java.lang.String ACTION_CALL_SERVICE_PROVIDER;
    field public static final java.lang.String ACTION_CONNECTION_SERVICE;
    field public static final java.lang.String ACTION_CONNECTION_SERVICE_CONFIGURE = "android.intent.action.CONNECTION_SERVICE_CONFIGURE";
    field public static final java.lang.String ACTION_INCOMING_CALL = "android.intent.action.INCOMING_CALL";
@@ -28238,9 +28207,9 @@ package android.telecomm {
    field public static final char DTMF_CHARACTER_WAIT = 59; // 0x003b ';'
    field public static final java.lang.String EXTRA_CALL_DISCONNECT_CAUSE = "android.telecomm.extra.CALL_DISCONNECT_CAUSE";
    field public static final java.lang.String EXTRA_CALL_DISCONNECT_MESSAGE = "android.telecomm.extra.CALL_DISCONNECT_MESSAGE";
    field public static final java.lang.String EXTRA_CALL_SERVICE_DESCRIPTOR = "android.intent.extra.CALL_SERVICE_DESCRIPTOR";
    field public static final java.lang.String EXTRA_CONNECTION_SERVICE = "android.telecomm.extra.CONNECTION_SERVICE";
    field public static final java.lang.String EXTRA_INCOMING_CALL_EXTRAS = "android.intent.extra.INCOMING_CALL_EXTRAS";
    field public static final java.lang.String EXTRA_PHONE_ACCOUNT = "android.intent.extra.PHONE_ACCOUNT";
    field public static final java.lang.String EXTRA_START_CALL_WITH_SPEAKERPHONE = "android.intent.extra.START_CALL_WITH_SPEAKERPHONE";
    field public static final java.lang.String EXTRA_START_CALL_WITH_VIDEO_STATE = "android.intent.extra.START_CALL_WITH_VIDEO_STATE";
  }
+0 −19
Original line number Diff line number Diff line
/*
 * Copyright 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;

parcelable CallServiceDescriptor;
+0 −233
Original line number Diff line number Diff line
/*
 * Copyright 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.os.Parcel;
import android.os.Parcelable;
import android.util.Log;

import java.util.Locale;
import java.util.UUID;

/**
 * An immutable object containing information about a given {@link ConnectionService}. Instances are
 * created using the enclosed {@link Builder}.
 */
public final class CallServiceDescriptor implements Parcelable {
    private static final String TAG = CallServiceDescriptor.class.getSimpleName();

    /**
     * A placeholder value indicating an invalid network type.
     * @hide
     */
    private static final int FLAG_INVALID = 0;

    /**
     * Indicates that the device must be connected to a Wi-Fi network in order for the backing
     * {@link ConnectionService} to be used.
     */
    public static final int FLAG_WIFI = 0x01;

    /**
     * Indicates that the device must be connected to a cellular PSTN network in order for the
     * backing {@link ConnectionService} to be used.
     */
    public static final int FLAG_PSTN = 0x02;

    /**
     * Indicates that the device must be connected to a cellular data network in order for the
     * backing {@link ConnectionService} to be used.
     */
    public static final int FLAG_MOBILE = 0x04;

    /**
     * Represents all of the defined FLAG_ constants so validity can be easily checked.
     * @hide
     */
    public static final int FLAG_ALL = FLAG_WIFI | FLAG_PSTN | FLAG_MOBILE;

    /**
     * A unique ID used to identify a given instance.
     */
    private final String mConnectionServiceId;

    /**
     * The {@link ComponentName} of the {@link ConnectionService} implementation which this is
     * describing.
     */
    private final ComponentName mComponentName;

    /**
     * The type of connection that the {@link ConnectionService} requires; will be one of the FLAG_*
     * constants defined in this class.
     */
    private final int mNetworkType;

    private CallServiceDescriptor(
            String connectionServiceId,
            ComponentName componentName,
            int networkType) {

        mConnectionServiceId = connectionServiceId;
        mComponentName = componentName;
        mNetworkType = networkType;
    }

    /**
     * @return The ID used to identify this {@link ConnectionService}.
     */
    public String getConnectionServiceId() {
        return mConnectionServiceId;
    }

    /**
     * @return The {@link ComponentName} of the {@link ConnectionService}.
     */
    public ComponentName getServiceComponent() {
        return mComponentName;
    }

    /**
     * @return The network type required by the {@link ConnectionService} to place a call.
     */
    public int getNetworkType() {
        return mNetworkType;
    }

    /** {@inheritDoc} */
    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (!(obj instanceof CallServiceDescriptor)) {
            return false;
        }
        CallServiceDescriptor descriptor = (CallServiceDescriptor) obj;
        return mConnectionServiceId.equals(descriptor.mConnectionServiceId) &&
                mComponentName.equals(descriptor.mComponentName) &&
                mNetworkType == descriptor.mNetworkType;
    }

    @Override
    public String toString() {
        return String.format(Locale.US, "[%s, component: %s]",
                CallServiceDescriptor.class.getSimpleName(),
                mComponentName == null ? "null" : mComponentName.flattenToShortString());
    }

    /**
     * @param context {@link Context} to use for the construction of the {@link Builder}.
     * @return A new {@link Builder} instance.
     */
    public static Builder newBuilder(Context context) {
        return new Builder(context);
    }

    /**
     * Creates {@link CallServiceDescriptor} instances. Builders should be created with the
     * {@link CallServiceDescriptor#newBuilder(Context)} method.
     */
    public static class Builder {
        /** The {@link Context} to use to verify {@link ComponentName} ownership. */
        private Context mContext;

        /** The {@link ComponentName} pointing to the backing {@link ConnectionService}. */
        private ComponentName mComponentName;

        /** The required network type that the {@link ConnectionService} needs. */
        private int mNetworkType = FLAG_INVALID;

        private Builder(Context context) {
            mContext = context;
        }

        /**
         * Set which {@link ConnectionService} this {@link CallServiceDescriptor} is describing.
         *
         * @param serviceClass The {@link ConnectionService} class
         * @return This {@link Builder} for method chaining.
         */
        public Builder setConnectionService(Class<? extends ConnectionService> serviceClass) {
            mComponentName = new ComponentName(mContext, serviceClass);
            return this;
        }

        /**
         * Which network type the backing {@link ConnectionService} requires. This must be one of
         * the {@link CallServiceDescriptor}.TYPE_* fields.
         *
         * @param networkType Which network type the backing {@link ConnectionService} requires.
         * @return This {@link Builder} for method chaining.
         */
        public Builder setNetworkType(int networkType) {
            mNetworkType = networkType;
            return this;
        }

        /**
         * @return A constructed {@link CallServiceDescriptor} object.
         */
        public CallServiceDescriptor build() {
            // STOPSHIP: Verify validity of ComponentName (permissions, intents, etc)

            // Make sure that they passed in a valid network flag combination
            if (mNetworkType == FLAG_INVALID || ((mNetworkType & FLAG_ALL) == 0)) {

                Log.wtf(TAG, "Invalid network type for " + mComponentName);
                // Revert them back to TYPE_INVALID so it won't be considered.
                mNetworkType = FLAG_INVALID;
            }

            // TODO: Should we use a sha1 of the ComponentName? Would prevent duplicates.
            return new CallServiceDescriptor(
                UUID.randomUUID().toString(), mComponentName, mNetworkType);
        }
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(mConnectionServiceId);
        dest.writeParcelable(mComponentName, 0);
        dest.writeInt(mNetworkType);
    }

    public static final Creator<CallServiceDescriptor> CREATOR =
            new Creator<CallServiceDescriptor>() {
        @Override
        public CallServiceDescriptor createFromParcel(Parcel source) {
            String id = source.readString();
            ComponentName componentName = source.readParcelable(
                    CallServiceDescriptor.class.getClassLoader());
            int networkType = source.readInt();

            return new CallServiceDescriptor(id, componentName, networkType);
        }

        @Override
        public CallServiceDescriptor[] newArray(int size) {
            return new CallServiceDescriptor[size];
        }
    };
}
+0 −51
Original line number Diff line number Diff line
/*
 * 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.os.RemoteException;

import com.android.internal.telecomm.ICallServiceLookupResponse;

import java.util.List;

/**
 * Used by {@link CallServiceProvider} to return a list of {@link CallServiceDescriptor}s.
 */
public final class CallServiceLookupResponse {
    private final ICallServiceLookupResponse mResponse;

    /**
     * {@hide}
     */
    public CallServiceLookupResponse(ICallServiceLookupResponse response) {
        mResponse = response;
    }

    /**
     * Passes the sorted list of preferred {@link CallServiceDescriptor}s back to Telecomm.  Used
     * in the context of attempting to place a pending outgoing call.
     *
     * @param callServiceDescriptors The set of call-service descriptors from
     * {@link CallServiceProvider}.
     */
    public void setCallServiceDescriptors(List<CallServiceDescriptor> callServiceDescriptors) {
        try {
            mResponse.setCallServiceDescriptors(callServiceDescriptors);
        } catch (RemoteException e) {
        }
    }
}
Loading