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

Commit 3390d27b authored by Hyunho's avatar Hyunho Committed by Hyunho Shin
Browse files

Create a PublishAttributes class that tells the result of a publish request,...

Create a PublishAttributes class that tells the result of a publish request, including sip debug information.

In order to more debug issues during the publication, the caller should have access to specfic SIP signaling information.
To access SIP information, using the created SipDetails class and set it as a variable in PublishAttributes class.
And the existing interface change to set the SipDetails class as a parameter.

Bug: b/238192081
Test: cts CtsTelephonyTestCases:ImsServiceTest
Test: atest DeviceCapabilityInfoTest PublishControllerImplTest PublishProcessorTest
Change-Id: Iac21d484aeafad511a0dcaf82ea0fcc6d8b2c1e2
parent 82708642
Loading
Loading
Loading
Loading
+16 −4
Original line number Diff line number Diff line
@@ -15393,6 +15393,15 @@ package android.telephony.ims {
    method public void onRemoved();
  }
  public final class PublishAttributes implements android.os.Parcelable {
    method public int describeContents();
    method @NonNull public java.util.List<android.telephony.ims.RcsContactPresenceTuple> getPresenceTuples();
    method public int getPublishState();
    method @Nullable public android.telephony.ims.SipDetails getSipDetails();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.telephony.ims.PublishAttributes> CREATOR;
  }
  public final class RcsClientConfiguration implements android.os.Parcelable {
    ctor @Deprecated public RcsClientConfiguration(@NonNull String, @NonNull String, @NonNull String, @NonNull String);
    ctor public RcsClientConfiguration(@NonNull String, @NonNull String, @NonNull String, @NonNull String, boolean);
@@ -15555,7 +15564,8 @@ package android.telephony.ims {
  }
  public static interface RcsUceAdapter.OnPublishStateChangedListener {
    method public void onPublishStateChange(int);
    method @Deprecated public void onPublishStateChange(int);
    method public default void onPublishStateChange(@NonNull android.telephony.ims.PublishAttributes);
  }
  public interface RegistrationManager {
@@ -15835,7 +15845,8 @@ package android.telephony.ims.feature {
package android.telephony.ims.stub {
  public interface CapabilityExchangeEventListener {
    method public default void onPublishUpdated(int, @NonNull String, int, @NonNull String) throws android.telephony.ims.ImsException;
    method @Deprecated public default void onPublishUpdated(int, @NonNull String, int, @NonNull String) throws android.telephony.ims.ImsException;
    method public default void onPublishUpdated(@NonNull android.telephony.ims.SipDetails) throws android.telephony.ims.ImsException;
    method public void onRemoteCapabilityRequest(@NonNull android.net.Uri, @NonNull java.util.Set<java.lang.String>, @NonNull android.telephony.ims.stub.CapabilityExchangeEventListener.OptionsRequestCallback) throws android.telephony.ims.ImsException;
    method public void onRequestPublishCapabilities(int) throws android.telephony.ims.ImsException;
    method public void onUnpublish() throws android.telephony.ims.ImsException;
@@ -16058,8 +16069,9 @@ package android.telephony.ims.stub {
  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;
    method public void onNetworkResponse(@IntRange(from=100, to=699) int, @NonNull String, @IntRange(from=100, to=699) int, @NonNull String) throws android.telephony.ims.ImsException;
    method @Deprecated public void onNetworkResponse(@IntRange(from=100, to=699) int, @NonNull String) throws android.telephony.ims.ImsException;
    method @Deprecated public void onNetworkResponse(@IntRange(from=100, to=699) int, @NonNull String, @IntRange(from=100, to=699) int, @NonNull String) throws android.telephony.ims.ImsException;
    method public default void onNetworkResponse(@NonNull android.telephony.ims.SipDetails) throws android.telephony.ims.ImsException;
  }
  public static interface RcsCapabilityExchangeImplBase.SubscribeResponseCallback {
+19 −0
Original line number Diff line number Diff line
/*
 * Copyright (c) 2022 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;

parcelable PublishAttributes;
+180 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 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;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.os.Parcel;
import android.os.Parcelable;
import android.telephony.ims.RcsUceAdapter.PublishState;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;

/**
 * This class provides detailed information related to publish state, SIP information and
 * presence tuples in publication.
 * This allows the application can check the detailed information of publication.
 * @hide
 */
@SystemApi
public final class PublishAttributes implements Parcelable {

    private final @PublishState int mPublishState;
    private List<RcsContactPresenceTuple> mPresenceTuples;
    private @Nullable SipDetails mSipDetails;

    /**
     * Builder for creating {@link Builder} instances.
     * @hide
     */
    public static final class Builder {
        private PublishAttributes mAttributes;
        /**
         * Build a new instance of {@link PublishAttributes}.
         *
         * @param publishState The current publication state {@link RcsUceAdapter.PublishState}.
         */
        public Builder(@PublishState int publishState) {
            mAttributes = new PublishAttributes(publishState);
        }

        /**
         * Sets the SIP information in received response to a publish operation.
         * @param details The {@link SipDetails} in received response.
         * @return The same instance of the builder.
         */
        public @NonNull Builder setSipDetails(@Nullable SipDetails details) {
            mAttributes.mSipDetails = details;
            return this;
        }

        /**
         * The tuple elements associated with the presence element portion of the PIDF document
         * successfully sent to the network.
         * @param tuples The list of the {@link RcsContactPresenceTuple} sent to the server.
         *               The contact URI should not be included in this tuples.
         * @return this The same instance of the builder.
         */
        public @NonNull Builder setPresenceTuples(@NonNull List<RcsContactPresenceTuple> tuples) {
            mAttributes.mPresenceTuples = tuples;
            return this;
        }

        /**
         * @return a new PublishAttributes from this Builder.
         */
        public @NonNull PublishAttributes build() {
            return mAttributes;
        }
    }

    /**
     * Generate the attributes related to the publication.
     *
     * @param publishState The current publication state.
     *                     See {@link RcsUceAdapter.PublishState}.
     */
    private PublishAttributes(@PublishState int publishState) {
        mPublishState = publishState;
    }

    /**
     * @return The current publication state. See {@link RcsUceAdapter.PublishState}.
     */
    public int getPublishState() {
        return mPublishState;
    }

    /**
     * @return The list of the {@link RcsContactPresenceTuple} sent to the server.
     */
    public @NonNull List<RcsContactPresenceTuple> getPresenceTuples() {
        if (mPresenceTuples == null) {
            return Collections.emptyList();
        }
        return mPresenceTuples;
    }

    /**
     * @return The {@link SipDetails} received in response.
     */
    public @Nullable SipDetails getSipDetails() {
        return mSipDetails;
    }

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

    @Override
    public void writeToParcel(@NonNull Parcel dest, int flags) {
        dest.writeInt(mPublishState);
        dest.writeList(mPresenceTuples);
        dest.writeParcelable(mSipDetails, 0);
    }

    public static final @NonNull Creator<PublishAttributes> CREATOR =
            new Creator<PublishAttributes>() {
                @Override
                public PublishAttributes createFromParcel(Parcel source) {
                    return new PublishAttributes(source);
                }

                @Override
                public PublishAttributes[] newArray(int size) {
                    return new PublishAttributes[size];
                }
            };

    /**
     * Construct a PublishAttributes object from the given parcel.
     */
    private PublishAttributes(Parcel in) {
        mPublishState = in.readInt();
        mPresenceTuples = new ArrayList<>();
        in.readList(mPresenceTuples, null, RcsContactPresenceTuple.class);
        mSipDetails = in.readParcelable(SipDetails.class.getClassLoader(),
                android.telephony.ims.SipDetails.class);
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        PublishAttributes that = (PublishAttributes) o;
        return mPublishState == that.mPublishState
                && Objects.equals(mPresenceTuples, that.mPresenceTuples)
                && Objects.equals(mSipDetails, that.mSipDetails);
    }

    @Override
    public int hashCode() {
        return Objects.hash(mPublishState, mPresenceTuples, mSipDetails);
    }

    @Override
    public String toString() {
        return "PublishAttributes { publishState= " + mPublishState
                + ", presenceTuples=[" + mPresenceTuples + "]" + "SipDetails=" + mSipDetails + "}";
    }
}
+15 −2
Original line number Diff line number Diff line
@@ -382,8 +382,21 @@ public class RcsUceAdapter {
        /**
         * Notifies the callback when the publish state has changed.
         * @param publishState The latest update to the publish state.
         *
         * @deprecated Replaced by {@link #onPublishStateChange}, deprecated for
         * sip information.
         */
        @Deprecated
        void onPublishStateChange(@PublishState int publishState);

        /**
         * Notifies the callback when the publish state has changed or the publish operation is
         * done.
         * @param attributes The latest information related to the publish.
         */
        default void onPublishStateChange(@NonNull PublishAttributes attributes) {
            onPublishStateChange(attributes.getPublishState());
        };
    }

    /**
@@ -404,13 +417,13 @@ public class RcsUceAdapter {
            }

            @Override
            public void onPublishStateChanged(int publishState) {
            public void onPublishUpdated(@NonNull PublishAttributes attributes) {
                if (mPublishStateChangeListener == null) return;

                final long callingIdentity = Binder.clearCallingIdentity();
                try {
                    mExecutor.execute(() ->
                            mPublishStateChangeListener.onPublishStateChange(publishState));
                            mPublishStateChangeListener.onPublishStateChange(attributes));
                } finally {
                    restoreCallingIdentity(callingIdentity);
                }
+28 −2
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.os.Binder;
import android.os.RemoteException;
import android.telephony.ims.ImsException;
import android.telephony.ims.RcsContactUceCapability;
import android.telephony.ims.SipDetails;
import android.telephony.ims.stub.CapabilityExchangeEventListener;
import android.util.Log;

@@ -83,7 +84,11 @@ public class CapabilityExchangeAidlWrapper implements CapabilityExchangeEventLis
    /**
     * Receives the status of changes in the publishing connection from ims service
     * and deliver this callback to the framework.
     *
     * @deprecated Replaced by {@link #onPublishUpdated(SipDetails)}, deprecated for
     * sip information.
     */
    @Deprecated
    public void onPublishUpdated(int reasonCode, @NonNull String reasonPhrase,
            int reasonHeaderCause, @NonNull String reasonHeaderText) throws ImsException {
        ICapabilityExchangeEventListener listener = mListenerBinder;
@@ -91,8 +96,29 @@ public class CapabilityExchangeAidlWrapper implements CapabilityExchangeEventLis
            return;
        }
        try {
            listener.onPublishUpdated(reasonCode, reasonPhrase,
                    reasonHeaderCause, reasonHeaderText);
            SipDetails details = new SipDetails.Builder(SipDetails.METHOD_PUBLISH)
                    .setSipResponseCode(reasonCode, reasonPhrase)
                    .setSipResponseReasonHeader(reasonHeaderCause, reasonHeaderText)
                    .build();
            listener.onPublishUpdated(details);
        } catch (RemoteException e) {
            Log.w(LOG_TAG, "onPublishUpdated exception: " + e);
            throw new ImsException("Remote is not available",
                    ImsException.CODE_ERROR_SERVICE_UNAVAILABLE);
        }
    }

    /**
     * Receives the status of changes in the publishing connection from ims service
     * and deliver this callback to the framework.
     */
    public void onPublishUpdated(@NonNull SipDetails details) throws ImsException {
        ICapabilityExchangeEventListener listener = mListenerBinder;
        if (listener == null) {
            return;
        }
        try {
            listener.onPublishUpdated(details);
        } catch (RemoteException e) {
            Log.w(LOG_TAG, "onPublishUpdated exception: " + e);
            throw new ImsException("Remote is not available",
Loading