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

Commit 5b51530d authored by James Lin's avatar James Lin Committed by Gerrit Code Review
Browse files

Merge "[RCS UCE] Expose the RCS UCE publishing device's capabilities APIs"

parents bbd9fb5c 50c18c12
Loading
Loading
Loading
Loading
+55 −1
Original line number Diff line number Diff line
@@ -11570,7 +11570,32 @@ package android.telephony.ims {
  }
  public class RcsUceAdapter {
    method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public void addOnPublishStateChangedListener(@NonNull java.util.concurrent.Executor, @NonNull android.telephony.ims.RcsUceAdapter.OnPublishStateChangedListener) throws android.telephony.ims.ImsException;
    method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public int getUcePublishState() throws android.telephony.ims.ImsException;
    method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public void removeOnPublishStateChangedListener(@NonNull android.telephony.ims.RcsUceAdapter.OnPublishStateChangedListener) throws android.telephony.ims.ImsException;
    method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setUceSettingEnabled(boolean) throws android.telephony.ims.ImsException;
    field public static final int CAPABILITY_UPDATE_TRIGGER_ETAG_EXPIRED = 1; // 0x1
    field public static final int CAPABILITY_UPDATE_TRIGGER_MOVE_TO_2G = 7; // 0x7
    field public static final int CAPABILITY_UPDATE_TRIGGER_MOVE_TO_3G = 6; // 0x6
    field public static final int CAPABILITY_UPDATE_TRIGGER_MOVE_TO_EHRPD = 4; // 0x4
    field public static final int CAPABILITY_UPDATE_TRIGGER_MOVE_TO_HSPAPLUS = 5; // 0x5
    field public static final int CAPABILITY_UPDATE_TRIGGER_MOVE_TO_IWLAN = 9; // 0x9
    field public static final int CAPABILITY_UPDATE_TRIGGER_MOVE_TO_LTE_VOPS_DISABLED = 2; // 0x2
    field public static final int CAPABILITY_UPDATE_TRIGGER_MOVE_TO_LTE_VOPS_ENABLED = 3; // 0x3
    field public static final int CAPABILITY_UPDATE_TRIGGER_MOVE_TO_NR5G_VOPS_DISABLED = 10; // 0xa
    field public static final int CAPABILITY_UPDATE_TRIGGER_MOVE_TO_NR5G_VOPS_ENABLED = 11; // 0xb
    field public static final int CAPABILITY_UPDATE_TRIGGER_MOVE_TO_WLAN = 8; // 0x8
    field public static final int CAPABILITY_UPDATE_TRIGGER_UNKNOWN = 0; // 0x0
    field public static final int PUBLISH_STATE_NOT_PUBLISHED = 2; // 0x2
    field public static final int PUBLISH_STATE_OK = 1; // 0x1
    field public static final int PUBLISH_STATE_OTHER_ERROR = 6; // 0x6
    field public static final int PUBLISH_STATE_RCS_PROVISION_ERROR = 4; // 0x4
    field public static final int PUBLISH_STATE_REQUEST_TIMEOUT = 5; // 0x5
    field public static final int PUBLISH_STATE_VOICE_PROVISION_ERROR = 3; // 0x3
  }
  public static interface RcsUceAdapter.OnPublishStateChangedListener {
    method public void onPublishStateChange(int);
  }
  public final class RtpHeaderExtension implements android.os.Parcelable {
@@ -11777,16 +11802,24 @@ package android.telephony.ims.feature {
  }
  public class RcsFeature extends android.telephony.ims.feature.ImsFeature {
    ctor public RcsFeature();
    ctor @Deprecated public RcsFeature();
    ctor public RcsFeature(@NonNull java.util.concurrent.Executor);
    method public void changeEnabledCapabilities(@NonNull android.telephony.ims.feature.CapabilityChangeRequest, @NonNull android.telephony.ims.feature.ImsFeature.CapabilityCallbackProxy);
    method @NonNull public android.telephony.ims.stub.RcsCapabilityExchangeImplBase createCapabilityExchangeImpl(@NonNull java.util.concurrent.Executor, @NonNull android.telephony.ims.stub.CapabilityExchangeEventListener);
    method public void onFeatureReady();
    method public void onFeatureRemoved();
    method public void removeCapabilityExchangeImpl(@NonNull android.telephony.ims.stub.RcsCapabilityExchangeImplBase);
  }
}
package android.telephony.ims.stub {
  public interface CapabilityExchangeEventListener {
    method public void onRequestPublishCapabilities(int) throws android.telephony.ims.ImsException;
    method public void onUnpublish() throws android.telephony.ims.ImsException;
  }
  public interface DelegateConnectionMessageCallback {
    method public void onMessageReceived(@NonNull android.telephony.ims.SipMessage);
    method public void onMessageSendFailure(@NonNull String, int);
@@ -11967,6 +12000,27 @@ package android.telephony.ims.stub {
    method public int updateColr(int);
  }
  public class RcsCapabilityExchangeImplBase {
    ctor public RcsCapabilityExchangeImplBase(@NonNull java.util.concurrent.Executor);
    method public void publishCapabilities(@NonNull String, @NonNull android.telephony.ims.stub.RcsCapabilityExchangeImplBase.PublishResponseCallback);
    field public static final int COMMAND_CODE_FETCH_ERROR = 3; // 0x3
    field public static final int COMMAND_CODE_GENERIC_FAILURE = 1; // 0x1
    field public static final int COMMAND_CODE_INSUFFICIENT_MEMORY = 5; // 0x5
    field public static final int COMMAND_CODE_INVALID_PARAM = 2; // 0x2
    field public static final int COMMAND_CODE_LOST_NETWORK_CONNECTION = 6; // 0x6
    field public static final int COMMAND_CODE_NOT_FOUND = 8; // 0x8
    field public static final int COMMAND_CODE_NOT_SUPPORTED = 7; // 0x7
    field public static final int COMMAND_CODE_NO_CHANGE = 10; // 0xa
    field public static final int COMMAND_CODE_REQUEST_TIMEOUT = 4; // 0x4
    field public static final int COMMAND_CODE_SERVICE_UNAVAILABLE = 9; // 0x9
    field public static final int COMMAND_CODE_SERVICE_UNKNOWN = 0; // 0x0
  }
  public static interface RcsCapabilityExchangeImplBase.PublishResponseCallback {
    method public void onCommandError(int) throws android.telephony.ims.ImsException;
    method public void onNetworkResponse(@IntRange(from=100, to=699) int, @NonNull String) throws android.telephony.ims.ImsException;
  }
  public interface SipDelegate {
    method public void closeDialog(@NonNull String);
    method public void notifyMessageReceiveError(@NonNull String, int);
+13 −13
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@ import java.util.List;
 * network during a SUBSCRIBE request. See RFC3863 for more information.
 * @hide
 */
public class RcsContactPresenceTuple implements Parcelable {
public final class RcsContactPresenceTuple implements Parcelable {

    /** The service id of the MMTEL */
    public static final String SERVICE_ID_MMTEL = "org.3gpp.urn:urn-7:3gpp-service.ims.icsi.mmtel";
@@ -61,7 +61,7 @@ public class RcsContactPresenceTuple implements Parcelable {
     * An optional addition to the PIDF Presence Tuple containing service capabilities, which is
     * defined in the servcaps element. See RFC5196, section 3.2.1.
     */
    public static class ServiceCapabilities implements Parcelable {
    public static final class ServiceCapabilities implements Parcelable {

        /** The service can simultaneously send and receive data. */
        public static final String DUPLEX_MODE_FULL = "full";
@@ -88,7 +88,7 @@ public class RcsContactPresenceTuple implements Parcelable {
        /**
         * Builder to help construct {@link ServiceCapabilities} instances.
         */
        public static class Builder {
        public static final class Builder {

            private ServiceCapabilities mCapabilities;

@@ -106,7 +106,7 @@ public class RcsContactPresenceTuple implements Parcelable {
             * Add the supported duplex mode.
             * @param mode The supported duplex mode
             */
            public Builder addSupportedDuplexMode(@NonNull @DuplexMode String mode) {
            public @NonNull Builder addSupportedDuplexMode(@NonNull @DuplexMode String mode) {
                mCapabilities.mSupportedDuplexModeList.add(mode);
                return this;
            }
@@ -115,7 +115,7 @@ public class RcsContactPresenceTuple implements Parcelable {
             * Add the unsupported duplex mode.
             * @param mode The unsupported duplex mode
             */
            public Builder addUnsupportedDuplexMode(@NonNull @DuplexMode String mode) {
            public @NonNull Builder addUnsupportedDuplexMode(@NonNull @DuplexMode String mode) {
                mCapabilities.mUnsupportedDuplexModeList.add(mode);
                return this;
            }
@@ -123,7 +123,7 @@ public class RcsContactPresenceTuple implements Parcelable {
            /**
             * @return the ServiceCapabilities instance.
             */
            public ServiceCapabilities build() {
            public @NonNull ServiceCapabilities build() {
                return mCapabilities;
            }
        }
@@ -211,9 +211,9 @@ public class RcsContactPresenceTuple implements Parcelable {
    /**
     * Builder to help construct {@link RcsContactPresenceTuple} instances.
     */
    public static class Builder {
    public static final class Builder {

        private RcsContactPresenceTuple mPresenceTuple;
        private final RcsContactPresenceTuple mPresenceTuple;

        /**
         * Builds a RcsContactPresenceTuple instance.
@@ -230,7 +230,7 @@ public class RcsContactPresenceTuple implements Parcelable {
        /**
         * The optional SIP Contact URI associated with the PIDF tuple element.
         */
        public Builder addContactUri(@NonNull Uri contactUri) {
        public @NonNull Builder addContactUri(@NonNull Uri contactUri) {
            mPresenceTuple.mContactUri = contactUri;
            return this;
        }
@@ -239,7 +239,7 @@ public class RcsContactPresenceTuple implements Parcelable {
         * The optional timestamp indicating the data and time of the status change of this tuple.
         * See RFC3863, section 4.1.7 for more information on the expected format.
         */
        public Builder addTimeStamp(@NonNull String timestamp) {
        public @NonNull Builder addTimeStamp(@NonNull String timestamp) {
            mPresenceTuple.mTimestamp = timestamp;
            return this;
        }
@@ -248,7 +248,7 @@ public class RcsContactPresenceTuple implements Parcelable {
         * An optional parameter containing the description element of the service-description. See
         * OMA Presence SIMPLE specification v1.1
         */
        public Builder addDescription(@NonNull String description) {
        public @NonNull Builder addDescription(@NonNull String description) {
            mPresenceTuple.mServiceDescription = description;
            return this;
        }
@@ -257,7 +257,7 @@ public class RcsContactPresenceTuple implements Parcelable {
         * An optional parameter containing the service capabilities of the presence tuple if they
         * are present in the servcaps element.
         */
        public Builder addServiceCapabilities(@NonNull ServiceCapabilities caps) {
        public @NonNull Builder addServiceCapabilities(@NonNull ServiceCapabilities caps) {
            mPresenceTuple.mServiceCapabilities = caps;
            return this;
        }
@@ -265,7 +265,7 @@ public class RcsContactPresenceTuple implements Parcelable {
        /**
         * @return the constructed instance.
         */
        public RcsContactPresenceTuple build() {
        public @NonNull RcsContactPresenceTuple build() {
            return mPresenceTuple;
        }
    }
+9 −8
Original line number Diff line number Diff line
@@ -144,7 +144,7 @@ public final class RcsContactUceCapability implements Parcelable {
         * @param tag the supported feature tag
         * @return this OptionBuilder
         */
        public @NonNull OptionsBuilder addFeatureTag(String tag) {
        public @NonNull OptionsBuilder addFeatureTag(@NonNull String tag) {
            mCapabilities.mFeatureTags.add(tag);
            return this;
        }
@@ -154,7 +154,7 @@ public final class RcsContactUceCapability implements Parcelable {
         * @param tags the list of the supported feature tags
         * @return this OptionBuilder
         */
        public @NonNull OptionsBuilder addFeatureTags(List<String> tags) {
        public @NonNull OptionsBuilder addFeatureTags(@NonNull List<String> tags) {
            mCapabilities.mFeatureTags.addAll(tags);
            return this;
        }
@@ -195,7 +195,7 @@ public final class RcsContactUceCapability implements Parcelable {
         * @param tuple The {@link RcsContactPresenceTuple} to be added into.
         * @return this PresenceBuilder
         */
        public @NonNull PresenceBuilder addCapabilityTuple(RcsContactPresenceTuple tuple) {
        public @NonNull PresenceBuilder addCapabilityTuple(@NonNull RcsContactPresenceTuple tuple) {
            mCapabilities.mPresenceTuples.add(tuple);
            return this;
        }
@@ -205,7 +205,8 @@ public final class RcsContactUceCapability implements Parcelable {
         * @param tuples The list of the {@link RcsContactPresenceTuple} to be added into.
         * @return this PresenceBuilder
         */
        public @NonNull PresenceBuilder addCapabilityTuples(List<RcsContactPresenceTuple> tuples) {
        public @NonNull PresenceBuilder addCapabilityTuples(
                @NonNull List<RcsContactPresenceTuple> tuples) {
            mCapabilities.mPresenceTuples.addAll(tuples);
            return this;
        }
@@ -282,7 +283,7 @@ public final class RcsContactUceCapability implements Parcelable {
     * @return The feature tags present in the OPTIONS response from the network.
     * <p>
     * Note: this is only populated if {@link #getCapabilityMechanism} is
     * {@link CAPABILITY_MECHANISM_OPTIONS}
     * {@link RcsContactUceCapability#CAPABILITY_MECHANISM_OPTIONS}
     */
    public @NonNull List<String> getOptionsFeatureTags() {
        if (mCapabilityMechanism != CAPABILITY_MECHANISM_OPTIONS) {
@@ -296,7 +297,7 @@ public final class RcsContactUceCapability implements Parcelable {
     * contained in the NOTIFY response from the network.
     * <p>
     * Note: this is only populated if {@link #getCapabilityMechanism} is
     * {@link CAPABILITY_MECHANISM_PRESENCE}
     * {@link RcsContactUceCapability#CAPABILITY_MECHANISM_PRESENCE}
     */
    public @NonNull List<RcsContactPresenceTuple> getPresenceTuples() {
        if (mCapabilityMechanism != CAPABILITY_MECHANISM_PRESENCE) {
@@ -312,9 +313,9 @@ public final class RcsContactUceCapability implements Parcelable {
     *
     * <p>
     * Note: this is only populated if {@link #getCapabilityMechanism} is
     * {@link CAPABILITY_MECHANISM_PRESENCE}
     * {@link RcsContactUceCapability#CAPABILITY_MECHANISM_PRESENCE}
     */
    public @Nullable RcsContactPresenceTuple getPresenceTuple(String serviceId) {
    public @Nullable RcsContactPresenceTuple getPresenceTuple(@NonNull String serviceId) {
        if (mCapabilityMechanism != CAPABILITY_MECHANISM_PRESENCE) {
            return null;
        }
+152 −72

File changed.

Preview size limit exceeded, changes collapsed.

+115 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2020 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.telephony.ims.aidl;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.net.Uri;
import android.os.Binder;
import android.os.RemoteException;
import android.telephony.ims.RcsContactUceCapability;
import android.telephony.ims.stub.CapabilityExchangeEventListener;
import android.util.Log;

import java.util.List;

/**
 * The ICapabilityExchangeEventListener wrapper class to store the listener which is registered by
 * the framework. This wrapper class also delivers the request to the framework when receive the
 * request from the network.
 * @hide
 */
public class CapabilityExchangeAidlWrapper implements CapabilityExchangeEventListener {

    private static final String LOG_TAG = "CapExchangeListener";

    private final ICapabilityExchangeEventListener mListenerBinder;

    public CapabilityExchangeAidlWrapper(@Nullable ICapabilityExchangeEventListener listener) {
        mListenerBinder = listener;
    }

    /**
     * Receives the request of publishing capabilities from the network and deliver this request
     * to the framework via the registered capability exchange event listener.
     */
    public void onRequestPublishCapabilities(int publishTriggerType) {
        ICapabilityExchangeEventListener listener = mListenerBinder;
        if (listener == null) {
            return;
        }
        try {
            listener.onRequestPublishCapabilities(publishTriggerType);
        } catch (RemoteException e) {
            Log.w(LOG_TAG, "request publish capabilities exception: " + e);
        }
    }

    /**
     * Receives the unpublish notification and deliver this callback to the framework.
     */
    public void onUnpublish() {
        ICapabilityExchangeEventListener listener = mListenerBinder;
        if (listener == null) {
            return;
        }
        try {
            listener.onUnpublish();
        } catch (RemoteException e) {
            Log.w(LOG_TAG, "Unpublish exception: " + e);
        }
    }

    /**
     * Receives the callback of the remote capability request from the network and deliver this
     * request to the framework.
     */
    public void onRemoteCapabilityRequest(@NonNull Uri contactUri,
            @NonNull List<String> remoteCapabilities, @NonNull OptionsRequestCallback callback) {
        ICapabilityExchangeEventListener listener = mListenerBinder;
        if (listener == null) {
            return;
        }

        IOptionsRequestCallback internalCallback = new IOptionsRequestCallback.Stub() {
            @Override
            public void respondToCapabilityRequest(RcsContactUceCapability ownCapabilities) {
                final long callingIdentity = Binder.clearCallingIdentity();
                try {
                    callback.onRespondToCapabilityRequest(ownCapabilities);
                } finally {
                    restoreCallingIdentity(callingIdentity);
                }
            }
            @Override
            public void respondToCapabilityRequestWithError(int code, String reason) {
                final long callingIdentity = Binder.clearCallingIdentity();
                try {
                    callback.onRespondToCapabilityRequestWithError(code, reason);
                } finally {
                    restoreCallingIdentity(callingIdentity);
                }
            }
        };

        try {
            listener.onRemoteCapabilityRequest(contactUri, remoteCapabilities, internalCallback);
        } catch (RemoteException e) {
            Log.w(LOG_TAG, "Remote capability request exception: " + e);
        }
    }
}
Loading